WiiRd forum

Wii & Gamecube Hacking => WiiRD Remote Debugger => Topic started by: lindtec on July 28, 2008, 09:29:50 AM

Title: How can I add a new Value to an existing Value?
Post by: lindtec on July 28, 2008, 09:29:50 AM
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
Title: How can I add a new Value to an existing Value?
Post by: Link on July 28, 2008, 10:49:27 AM
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!
Title: How can I add a new Value to an existing Value?
Post by: lindtec on July 28, 2008, 03:24:52 PM
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?
Title: How can I add a new Value to an existing Value?
Post by: James0x57 on July 28, 2008, 05:28:14 PM
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?
Title: How can I add a new Value to an existing Value?
Post by: Link on July 28, 2008, 06:22:15 PM
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!
Title: How can I add a new Value to an existing Value?
Post by: James0x57 on July 28, 2008, 07:15:50 PM
And it's okay to use any of them at any point? You don't have to back them up at all?
Title: How can I add a new Value to an existing Value?
Post by: Link on July 28, 2008, 07:43:48 PM
no, the gecko registers are not like cpu registers.. they are internal for WiiRd.. they are not related to any other stuff!
Title: How can I add a new Value to an existing Value?
Post by: Panda On Smack on August 27, 2008, 07:06:20 PM
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