vivaria / tja2fumen

Mod tool to convert TJA chart files (.tja) into .bin files compatible with official games
https://pypi.org/project/tja2fumen/
MIT License
12 stars 1 forks source link

Fix how the header bytes are set (using new information) #44

Closed vivaria closed 1 year ago

vivaria commented 1 year ago

Currently, I set the header bytes based on reverse engineered values from my own research, and from observing what tja2bin sets:

https://github.com/vivaria/tja2fumen/blob/46ef08434e18b130b7525184ace8ee43ac61d6e6/src/tja2fumen/constants.py#L68-L73

However, there are many gaps in my understanding, e.g.:

https://github.com/vivaria/tja2fumen/blob/46ef08434e18b130b7525184ace8ee43ac61d6e6/testing/test_conversion.py#L251-L256

This all changed when I was given a document that fully explains what each byte represents:

``` Header: 000-431 000-1AF - timing windows. if _e or _n then easier timings, if _h or _m then harder timings. 432-435 1B0-1B3 - whether the chart has divergent paths. 1 if yes, 0 if no. (set to 01000001 if you'll be switching endianness) 436-439 1B4-1B7 - Max HP. Default is 10000. 440-443 1B8-1BB - Clear HP. _e is 6000, _n & _h is 7000 and _m is 8000. 444-447 1BC-1BF - HP earned per 良. 448-451 1C0-1C3 - HP earned per 可. 452-455 1C4-1C7 - HP loss per 不可. Negative value. 456-459 1C8-1CB - 普通 max combo/普通 max combo. Usually set to 65536. 460-463 1CC-1CF - Ratio of hp increase. 65536(普通 max combo/玄人 max combo). If no branch paths set to 65536. 464-467 1D0-1D3 - Ratio of hp increase. 65536(普通 max combo/達人 max combo). If no branch paths set to 65536. 468-471 1D4-1D7 - 良 diverge points. Common value is 20. 472-475 1D8-1DB - 可 diverge points. Common value is 10. 476-479 1DC-1DF - 不可 diverge points. Common value is 0. 480-483 1E0-1E3 - 連打 diverge points. Common value is 1. 484-487 1E4-1E7 - 良 diverge points (big notes). Common value is 20. 488-491 1E8-1EB - 可 diverge points (big notes). Common value is 10. 492-495 1EC-1EF - 連打(大) diverge points. Common value is 1. 496-499 1F0-1F3 - Balloon diverge points. Common value is 30. 500-503 1F4-1F7 - Bell/Yam diverge points. Common value is 30. 504-507 1F8-1FB - Number of diverge points?? Common value is 20. (can be 0, even with diverge points) 508-511 1FC-1FF - Max Score value (deprecated). Dummy data. 512-515 200-203 - Number of measures. The limit is 300, 200 on older platforms. 516-519 204-207 - Unknown data. Measure data: 208-20B - BPM (float) 20C-20F - Offset (float). Formula for calculation: (240000/bpm1)+(240000/bpm1)(x/y)-(240000/bpm2) 210 - Gogo time. 1 if yes, 0 if no. 211 - Barline visibility. 1 if yes, 0 if no. 212-213 - Dummy data. 214-217 - 普通譜面. 普通-玄人 diverge point requirement. For charts without divergent paths set to FFFFFFFF. 218-21B - 普通譜面. 普通-達人 diverge point requirement. For charts without divergent paths set to FFFFFFFF. 21C-21F - 玄人譜面. 玄人-玄人 diverge point requirement. For charts without divergent paths set to FFFFFFFF. 220-223 - 玄人譜面. 玄人-達人 diverge point requirement. For charts without divergent paths set to FFFFFFFF. 224-227 - 達人譜面. 達人-玄人 diverge point requirement. For charts without divergent paths set to FFFFFFFF. 228-22B - 達人譜面. 達人-達人 diverge point requirement. For charts without divergent paths set to FFFFFFFF. 22C-22F - Dummy data. Note data (普通譜面): 230-231 - Number of notes in this branch of the measure. 232-233 - Dummy data. 234-237 - Scroll speed (float). Default is 1. Note: 238-23B - Note. 01 - ドン, 02 - ド, 03 - コ, 04 - カッ, 05 - カ, 06 - 連打, 07 - ドン(大), 08 - カッ(大), 09 - 連打(大), 0A - Balloon, 0B - , 0C - Bell. 23C-23F - Note offset (ms float). 240-243 - Dummy data. 244-245 - Initial score value. If the note is a balloon then it's the balloon hit count. 246-247 - Score difference *4. If the note is a balloon then it's zero. 248-24B - Dummy Data. Old balloon count. 24C-24F - Length of 連打 and balloons (float). Zero otherwise. Note data (玄人譜面): If the chart has no branch paths then you just set the note count (to zero of course) and the scroll speed. If it does then repeat what you did for 普通譜面. Note data (達人譜面): Same deal. HP calculation: 良: Find out when the gauge is maxed out and divide 10000 by the combo amount at which the gauge hits max. Round up the value. 可: (these give very close to official values) _e = 0.75(良) _n = 0.75(良) _h = 0.75(良) _m = 0.5(良) -> rounded up ex = 0.5(良) -> rounded down 不可: (these give not-so-close to original values except for _e, _n and ex_) _e = -(良/2) _n = -(良) _h = -(1.25x良) _m = -(2良) ex = -(2良) Round up before changing the sign. ```

I will need to overhaul my header code so that all of this knowledge is properly represented.