I'm thinking about very basic memory organisation for an rpg and was hoping to get some advice/tips. If I have enemy stats defined as a struct-of-arrays in rom like:
Code: Select all
enemy_hps = .db 01 02 03 04 ... enemy_strs = .db 01 02 03 04 ...
Code: Select all
enum $0000 current_enemy .dsb 4 ende
1) As per-enemy information increases (steal list, elemental resistance, flee rate...) the number of fixed zp locations per-battle increases. I know speed vs space is the classic trade-off of CS, but I figured there may be alternatives.
2) For ensuring healing doesn't exceed max hp (and similarly for variable+stackable (de)buffs to stats) you seemingly need - not only the constant values mentioned above for reference in zp - but also *copies* you can modify too! That would mean duplicates of health, strength and other stats that can change during battle. Assuming you don't just have constant, non-stackable debuffs via a simple "is_silenced" sort of flag. From what I can tell from (https://www.nicholasmikstas.com/dragon-warrior-defines) this is what DW1 does, keeps copies of modifiable stats and has a byte that stores current statuses.
This is my first time doing any sort of memory organisation/planning, so please forgive any noobish errors or bad explanations. For anyone who has worked on any rpgs (or has reverse-engineered them) I'd be most grateful to know of any information you can offer in general regarding implementing this sort of system.
P.S I'm actually attempting to use a software stack whenever it seems appropriate (aka anything using temporary values that isn't too speed-critical) and I must say (for worse, I'm sure many are going to opine) it feels much comfier than worrying about manually managing shared-zp space all the time. Here, it didn't really seem ideal due to the values being persistent and also the number of them. You could put pointers to the zp copies on the stack but that just seems like dancing around the problem and using indirectly needlessly. However, if you'd personally still use a stack for handling these battle values, I'd love to hear how.