Equips and Collisions
The Power of ASM Flags

Checking for Equips You should know from TSC that `<EQ+0064` will cause the Mimiga mask to be put on. How do we check for this in assembly? First convert 64 (decimal) to a hex number, which will be 40. If you look inside the ASM Compendium, you'll see that equips are stored inside a single DWORD at 49E650. Take a look at the following code:
    MOV EAX, DWORD [49E650]
    AND EAX, 40        ;Sets Z flag if player has no Mimiga mask equipped.
    JE 49E002          ;This jump to 49E002 will be taken if the Mimiga mask is not equipped.
    NOP                ;This NOP will be executed if the Mimiga mask is equipped.
This is the general method for checking for equips. Each equip is actually a binary flag stored inside the DWORD at 49E650. In this case, the result of the AND instruction will be 0 if the Mimiga mask is not equipped (therefore, the JE will be taken) and it will be 40 if the Mimiga mask is equipped (in that case, the JE is not taken). To make this more clear, here's how to check if the player is allowed to use the Map system. The map system becomes available as soon as you do `<EQ+0002`. Because 2 (decimal) is the same as 2 (hex), then use:
    MOV EAX, DWORD [49E650]
    AND EAX, 2         ;Sets Z flag if player has no map system equipped.
    JE 49E002          ;This jump to 49E002 will be taken if the map system is not equipped.
    NOP                ;This NOP will be executed if the map system is equipped.
In most of the ASM demonstrations so far, I've told you what code to put into the executable and where to put it. Now, here's a little challenge that you should try to do yourself. Create the new TSC command `<EQJXXXX:YYYY`, that will jump to event Y if the equip X is equipped. For example, `<EQJ0064:0500` should jump to event 500 only if the Mimiga mask is equipped. (Hint: You should look at this previous lesson if you're stuck. Just so you know, you will need to call the function 421AF0 somewhere inside this hacked command.) Setting Equips To actually make something equipped without using TSC, use the OR command.
    OR DWORD [49E650], 40     ;Forces the player to put on the Mimiga mask.
    OR DWORD [49E650], 20     ;Forces the player to equip the Booster 2.0.
Remember that OR will "forcibly set bits". The difference between using OR and using the built-in TSC command `<EQ+` is that OR is more lenient. If you use `<EQ+0032` two or three times, something bad will happen to your equip flags, causing possibly unexpected results. However, you can use `OR DWORD [49E650], 20` two or three times, and nothing bad will happen to you. `OR DWORD [49E650], 20` will set the equip flag for the Booster 2.0, but if you use it multiple times, the same flag is just set again, so there's no difference. [More information to come.] Navigation Previous Lesson: ASM Flags Next Lesson: [NOT FINISHED YET] Table of Contents