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

Debug why songs with multiple `#BRANCHSTART r,1,2` conditions aren't branching correctly #40

Closed vivaria closed 1 year ago

vivaria commented 1 year ago

I've been given some feedback on the Discord that BATTLE NO. 1 (and probably others) aren't branching like they should.

vivaria commented 1 year ago

My main point of confusion in the Discord was that I didn't understand the difference between:

#SECTION
#BRANCHSTART r,1,2

[notes]

#SECTION
#BRANCHSTART r,1,2

and

#BRANCHSTART r,1,2

[notes]

#BRANCHSTART r,1,2

I was under the impression that #BRANCHSTART automatically reset the accuracy by itself. So, in my head, #SECTION was meaningless when placed before a #BRANCHSTART. However, when I inputted 2 versions of BATTLE NO 1. into a TJAPlayer, I found:

So, this makes immediate sense. I now understand how #SECTION works when placed next to #BRANCHSTART.

However, this is just the expected behavior in the TJAPlayer. What about the actual behavior in TDMX from my converted TJA?

vivaria commented 1 year ago

What about the actual behavior in TDMX from my converted TJA?

It turns out that drumroll conditions are working fine in my converter. (0 drumrolls -> Normal, 1 drumroll -> Professional, 2 drumrolls -> Master)

However, if you hit normal D/K notes, this somehow factors in to how the song branches? If I hit even just a single normal note, the song will branch to master. I think that's why I was being told that my converter wasn't working properly?

The question now is: Which bytes is tja2fumen setting, and what bytes should be set for a fumen? To answer this I will need to find a song with #SECTION and #BRANCHSTART r, and then compare with an official fumen.


Note: I do have one song with #BRANCHSTART r in my test suite:

https://github.com/vivaria/tja2fumen/blob/46ef08434e18b130b7525184ace8ee43ac61d6e6/testing/data/butou5.tja#L18

However, this song only branches once due to drumrolls. It doesn't branch multiple times, like BATTLE NO 1. does. I think that explains why I missed the buggy behavior.

vivaria commented 1 year ago

However, if you hit normal D/K notes, this somehow factors in to how the song branches? If I hit even just a single normal note, the song will branch to master. I think that's why I was being told that my converter wasn't working properly?

This behavior is due to how I currently set the header metadata. It turns out, many of the "unknown" header metadata bytes were actually:

1D4-1D7 - 良 diverge points. Common value is 20.
1D8-1DB - 可 diverge points. Common value is 10.
1DC-1DF - 不可 diverge points.    Common value is 0.
1E0-1E3 - 連打 diverge points.    Common value is 1.
1E4-1E7 - 良 diverge points (big notes). Common value is 20.
1E8-1EB - 可 diverge points (big notes). Common value is 10.
1EC-1EF - 連打(大) diverge points. Common value is 1.
1F0-1F3 - Balloon diverge points.   Common value is 30.
1F4-1F7 - Bell/Yam diverge points.  Common value is 30.

I was automatically setting these to their "Common values". However, for a song like BATTLE NO 1., where ONLY drumrolls are relevant for the branching condition, then the 良/可 (GOOD/OK) values should be set to 0, so that hitting normal notes has no effect on whether the branch diverges.

I have a lot of fixes to do to make sure I'm setting the header properly.