Question about object states in mega man x

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Question about object states in mega man x
by on (#185204)
I was looking through the mega man x RAM and I noticed tons of objects such as enemies and the player are state-based. But the weird thing is how they are used, like, states go 0, 2, 4, 6, 8, 10, 12 etc... not 0, 1, 2, 3, 4, etc... which in my opinion is pretty weird. I tried poking them and setting them to uneven values and every time, it just instantly froze the game.

What I am asking is, could there any actual technical reason for this or is it just completely arbitrary? :|

Please excuse me if any of my questions are dumb or annoying, I'm just trying to learn slowly and ask fro help so I can understand things that I don't understand yet.
Re: Question about object states in mega man x
by on (#185205)
Sounds to me like they have a table of addresses that lead to code for each given "state". If each entry in the table is two bytes long, then having the states increment by two each time eliminates an instruction to multiply by two when using said table. And using an odd number would cause the program to jump to an invalid address which uuuusually crashes right away.
Re: Question about object states in mega man x
by on (#185206)
Makes sense, thanks. :)