Kodewerx

Our culture has advanced beyond all that you could possibly comprehend with one hundred percent of your brain.
It is currently Thu Mar 28, 2024 1:57 am

All times are UTC - 8 hours [ DST ]




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
PostPosted: Mon Mar 29, 2010 6:02 pm 
Offline
Kommunist
Kommunist

Joined: Mon Mar 29, 2010 3:55 pm
Posts: 3
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 92 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group