How can I add a new Value to an existing Value?

Started by lindtec, July 28, 2008, 09:29:50 AM

Previous topic - Next topic

lindtec

Hello

I want to add a predefined number to a value at a specific adress.

Example:
I have 1.000 Gold. Now I want to add to that another 1.000 Gold
with each pressing of the button 1.

But since its only a 16bit-Value, the maximum has to be 65.535 Gold.
The code-execution has to end at this point, so that pressing the
button won't give you any more Gold.

Could someone tell me generally, how I can do this?

Thanks in advance...

Greetings lindtec

Link

What you plan is generally possible.. but not too easy!

First of all.. once 1 is pressed..

28______ 00000200 (do not remember activator for 1)
82100000 XXXXXXXX (XXXXXXXX being the address where gold is stored)
-->loads the 16bit value at address [xxxxxxxx] into register 0
86000000 000003E8
--> add 0x3E8 (1000) to the value
84100000 XXXXXXXX
-->store register 0 back to XXXXXXXX
-->now what if we exceeded 65535? Then the values restart counting.. so 65535+1000=999
-->to simply check that.. we check if the value at [XXXXXXXX] is lower than 0x03E8 - if it is we just exceeded 65535
2EXXXXXX 000003E8 (make sure XXXXXX is in the correct ba/po area)
-->whoops we did exceed?
02XXXXXX 0000FFFF
-->set value to 0xFFFF (65535)
E0000000 80008000
-->full terminator return code status to normal

I know that's pretty much I hope it's understandable!
Note the stuff is untested!

lindtec

Thanks a lot

so far, I can follow. After the third time reading it, it's even quite logical ^_^.

By the way, with your code, you would write to register 0. Are there other registers,
I could write to? And how do I address them?


Maybe you could help me with another question.

Is it possible, to execute a code via button-combination and to end this code-execution
(and start another one) with another combination?

James0x57

Ahh! I was going to ask about this too, is it okay to use any of those registers? I was worried that it could mess something up.

And I know the full terminator is there for the activators but the 8X codetypes don't need terminated too, do they?


Link

You can simply leave stuff in the registers.. they'll be cleared when the code handler exits. They won't be cleared on a terminator!

QuoteBy the way, with your code, you would write to register 0. Are there other registers,
I could write to? And how do I address them?

Yes there are..
http://www.usbgecko.com/codetypes.htm
refer to "CT4 Gecko Register Operations"

In every code type mentioned there you'll see an N.. this is the register.. there are 16 registers from 0 to F!

James0x57

And it's okay to use any of them at any point? You don't have to back them up at all?


Link

no, the gecko registers are not like cpu registers.. they are internal for WiiRd.. they are not related to any other stuff!

Panda On Smack

Hey chaps

Is this buggy? Seem to recall a thread that pointed out some issues with gecko registers

Just trying to make a code and it freezes my game, have I made an error?

283E17AA 00000100
82100000 91BE12A4
86000000 00000001
84100000 91BE12A4
E0000000 80008000

ta