KungFuFurby / AddMusicKFF

Fork of AddMusicK, a compiler/inserter of music for Super Mario World
23 stars 16 forks source link

stats/ files show "Channel x ticks: 0x1234" but the number is actually decimal #385

Closed spooonsss closed 1 year ago

spooonsss commented 1 year ago

Example input

#amk 2

#SPC
{
    #author "-"
    #title "Blank"
    #game "Super Mario World"
}

#option TempoImmunity
#option NoLoop

#0
r=2
#1
r=8
#2
r=10
#3
r=11
#4
r=15

outputs:

CHANNEL 0 TICKS:            0x0002
CHANNEL 1 TICKS:            0x0008
CHANNEL 2 TICKS:            0x0010
CHANNEL 3 TICKS:            0x0011
CHANNEL 4 TICKS:            0x0015

This is because channelLengths[0] is a double and std::hex only affects integral types.

The output can get stranger. https://smwc.me/s/31881 outputs CHANNEL 5 TICKS: 0x1.18728E+06

I'd send a PR, but I'm not sure if the proper fix is to just cast channelLengths[i] when creating the stats file, or to change channelLengths (and the variables that are used in its computation) to an integral type.

spooonsss commented 1 year ago

Apologies, this is a dup of #321

KungFuFurby commented 1 year ago

Duplicate acknowledged. However, you did give me an extreme example case in the process... though it didn't reach the 32-bit limit, signed or unsigned in that case.