[GBAFE] Confirming some maximum parameters of things

Since I have no idea where to find just a big ol’ document with all this information (please do point me to it if one exists!) I thought I’d ask about the maximum values supported for certain things in the GBAFE games.

Particularly, I’m wondering about things like weapon uses, character stats, and characters present in the player army. Essentially, how many bits are allocated to which of these types of data, and how many units’ worth of space is available in a save file for recruited party members. I feel it’s important to clarify that I mean characters in your overall party, not characters deployed at one time. I doubt I’ll have need to go over the series’ standard used maximum of 16 or so in that respect.

My understanding is…

Max HP has a maximum value of 127
Other stats have maximum values of 31 (maybe?)
Item durability cannot exceed 63 (I recall hearing this somewhere in the past)
Max recruited characters varies by game but also definitely cannot ever exceed 63

I don’t necessarily plan on pushing any of these without reason, but I would like to be aware of what these maximums are so I can plan around them where necessary.

Stats are stored as bytes but inconsistently read as signed and unsigned numbers, and as such any value over 127 is going to in some cases be read as negative. This then makes HP cap at 127, but all other stats will also cap here. While the game is running each stat is, as stated, stored as a byte and as such can be any value from 0-255; since anything over 127 is read as signed, that’s still the cap on every stat. The problems start when saving and loading units. In vanilla, to save on space, non-HP stats get bitpacked down to 5 bits; a 5-bit value can store 2^5=32 values, which as this includes 0 makes a cap of 31. Similarly, item durability gets bitpacked to a 6-bit value or 2^6=64 values and a cap of 63. Both of these limits can be removed, however, with the use of engine hacks:

Expanded Modular Save changes the unit save & load functions such that stats and item durability save the entire byte, giving you the full range of values at your disposal of 127 caps on all stats and 255 cap on durability.
Max recruited characters is a bit of a different situation. There is space in memory dedicated to player units large enough to store 63 units, which makes that technically the cap without moving where player units are located in memory. However, as the game does not expect you to ever get this high, once you’re over 50 units a lot of small things will break in one way or another. Some hacks like Vision Quest have mitigated these issues, though I’m unsure if said mitigations have been released publically.

1 Like

This was a joint effort between Snakey1 and Tequila that they were able to sort out to get them to not conflict.

There are still some small issues with their implementation, most visibly that the battle preps screen is likely to run into RAM issues displaying all of the map sprites for 62 units.

Additionally, we had some weirdness with the chapters once we hit 60 player units that caused some players to have random glitches or resets, and an inability to access the formation in battle preps, which 7743 was able to make a more brute force solution for. However, some of this may be associated with interactions with old save files that have conflicting storage or other issues that I am less privy to because I am a major noob.

There’s still some unknowns to my knowledge, but I’ll defer to Snek and Teq to share more details if there is curiosity on how others can do this more scalably in the future.

1 Like

Thank you both very much!

I don’t think I’ll actually be needing any of the patches (I was actually thinking of going lower than the GBA games in terms of average unit stats, if anything; something closer to FE1/3/5), but it’s good to know that they exist!

I just like to be aware of these things so that if I, say, wanted to make an enemy with super high physical durability as a gimmick or something, I’d know what Defense value not to exceed with them… or like, if I wanted to have a big final boss enemy use the system cap of 127 HP instead of the standard 120 value or something. I think the item durability cap is most important for me to know for my purposes, since I’m more likely to be pushing that than any of the others.

Thanks again!