Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Checking mario's state using the C toolkit depends on which state you want to check
#1
Explanation
So in the C-toolkit you can check mario's state. But as of right now, depending on the state you want to check, you have to do one of two methods. In SMS there is a section of 32 bits in the memory that correspond to flags that indicate mario's state. Some of these flags have been identified and some of them haven't. If the flag has been identifed, then we can use a mask such as 00000001000 to check if that flag is on or off. We can take mario's state, and use a bit-wise AND operator to check if that specific flag is on. Some of the STATE_BLAHBLAH in sms.h are masks. For example you can see that STATE_DOJUMP is a mask as it is one big and the rest are 0s. However, when we don't know exactly which flag corresponds to what there is a different way of doing things. Let's say we are trying to see if mario is hovering. What we do is hover in game, then copy whatever those 32 bits are. When we want to check if mario is hovering, we can just check if the two states match. Hopefully they will but this won't always work.
What to do about it
[Image: JgFQ30N.png]
So how does this work in practice? In sms.h you can see the states are separated into 2 parts. The top part is the masks and the bottom part is the recorded states. To check a mask do this:

Code:
if (mario->status & STATE_AIRBORN)
   {
   ...
To check a recorded state do this:

Code:
if (mario->status == STATE_HOVER)
   {
   ...
Setting Mario's state
One more thing

When setting Mario's state, you can do it directly on the recorded states
But when setting it from a mask you have to bitwise OR the mask with mario's current state
Thanks for reading.
     Cool  
Reply
#2
Nice!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)