I am trying to create a code that increments the selected unit's speed by 1. Basically "speed resetting" without the resetting, so if I get a speed up, fine, if I don't, I can use this.
Here's what I have, I'll try to comment it.
The base address for the selected unit is 21D5020.
// If the unit's speed is less than 150 (cap is 149). I manually added 1C to the base address // here because when I tried loading it, then doing an if on 1C it didn't work. 721D503C FF000095 // Activate when SELECT is pressed 94000130 FFFB0000 // Load the base address into the offset register B21D5020 00000000 // Load the current speed into the stored register DB000000 0000001C // Increment the value in the stored register D4000000 00000001 // Write the updated value from the stored register to the address D7000000 0000001C // Close conditional and and clear registers D2000000 00000000
When I try this, the results are erroneous, with speed being incremented by 50-60 or so.
If I replace the bold line above with the line below, I get speed changed to 16, or 0xF+1, which is what should happen, so it looks like increment works. // Write the value F to the stored register D5000000 0000000F
If I remove the underlined line above, speed doesn't change, which is what I think should happen because it should be reading the current value, then just putting it back. So it looks like that part works.
But apparently when I put them together it goes nuts. Can someone please help me with this? Thanks.
|