Does anyone know where the currently selected unit’s class is stored in ram? I know that the deployment number is at 0x30046AA, but I’m wondering if the active unit’s class is stored anywhere.
I’m attempting to make a check to read in the class of the ‘Active’ unit (really just the unit that’s visiting the event place), and compare that to a table of bytes in some arbitrary point in the rom.
Alternatively, does anyone know of a tool that can find differences between two files based on a pattern, rather than absolute differences? Given two files, it would find all instances where it said, say, 28 instead of 21.
For FE7, 0x3004690 holds a pointer to the selected unit. Dereference it, get the class, then get the number from the class data.
Is that the simplest way? Also, following that leads to a pointer to the character data in the ROM. What happens if the unit is promoted/is a different class than in the unit data?
I try to write code so it’s as functional as possible, while being as simple as possible. If it’s possible to get a single byte that’s always in the same position, that’d be ideal. Then the code could be easily re-purposed for any other given byte (especially because I’m trying to compare the given byte to a table of bytes somewhere off in the aether)
No, I mean like, 0x3004690 is the RAM character, e.g. 0202bd50. Then load that offset+4. Then load (the byte at) THAT offset+4, and you have the class #. This is the simplest yet most polymorphic way to do this.
Ah, I see now. So you’d (probably a messy implementation)
ldr r5, =0x03004690 @ load the current active unit
ldr r5, [r5] @ load the word in r5 to r5 (contains the pointer to the character in ram)
add r5, #0x04 @ add 4 to that offset (now the class data of the unit in ram)
ldr r5, [r5] @ load the word in r5 to r5 (now contains the pointer to the class in the class table(?) in rom)
add r5, #0x04 @ add 4 to that (now the pointer to the class number of the unit)
ldrb r5, [r5] @ loads the byte at r5 into r5
And then go from there, comparing r5 to my table somewhere?
yes, though with
ldr r5, [r5, #0x4]
And by changing that #0x4, I can use it to look at different things in the class data, since the structure is documented here.
e: Well, roughly. \Have to comment out the next jump for the non-pointer bytes.
It’s better documented in the nightmare module.
Sorry, meant unit data in ram. Useful tools.
Personally I use this for when I forget something in ram:
cheat search in vba is your friend