Herringway / ebsrc

Source code recreation for the game Earthbound
133 stars 8 forks source link

Fix hard-coded name lengths #23

Closed Anonymous941 closed 7 months ago

Anonymous941 commented 7 months ago

Because the lengths of these are always 0006 (as opposed to character names), Nintendo's compiler probably optimized them out

Herringway commented 7 months ago

game_state::favorite_thing is 12 bytes ("PSI "+8 more bytes) in earthbound, not 6 bytes

Anonymous941 commented 7 months ago

game_state::favorite_thing is 12 bytes ("PSI "+8 more bytes) in earthbound, not 6 bytes

This is used for the text boxes in the naming screen, so it wouldn't include the "PSI ", but you're right, it should be different. I'll look into it

Anonymous941 commented 7 months ago

This is strange. It should be 8, when you remove the "PSI " prefix (.SIZEOF(game_state::favourite_thing) - 4), but it's 6. Is there something else that is using the 2 bytes somehow?

Anonymous941 commented 7 months ago

I've changed this for now, as it glitches somewhat when this is removed, hinting that there are 2 extra bytes needed for some reason

Herringway commented 7 months ago

This is strange. It should be 8, when you remove the "PSI " prefix (.SIZEOF(game_state::favourite_thing) - 4), but it's 6. Is there something else that is using the 2 bytes somehow?

The game adds a space after the favourite thing as well, which only leaves 1 byte unaccounted for. It's worth pointing out that the prototype used only 11 bytes but had the same 6 character limit, which suggests this might be an off-by-one error they were trying to work around, or possibly an indication of an unused single byte field after the favourite thing...

Anonymous941 commented 7 months ago

The game adds a space after the favourite thing as well, which only leaves 1 byte unaccounted for.

Isn't 4 counting the byte? Or is there a NUL terminator after as well?

Herringway commented 7 months ago

The game adds a space after the favourite thing as well, which only leaves 1 byte unaccounted for.

Isn't 4 counting the byte? Or is there a NUL terminator after as well?

4 bytes ("PSI ") + 6 bytes ("rockin" or whatever) + 1 (' ') + 1 (?) = 12 bytes

There is a \0 at the end, but only because it was cleared beforehand. After checking the code, it seems the difference between the prototype and the final appears to be that the prototype does not add a space to the favourite thing like the final version does, so it only needed 11 bytes instead of 12.