WiiRd forum

Wii & Gamecube Hacking => Wii Game hacking help => Topic started by: Sharkbyte on October 01, 2010, 06:45:15 PM

Title: Load into gecko register (po)
Post by: Sharkbyte on October 01, 2010, 06:45:15 PM
Can someone explain this codetype in detail?

9201 : grN= 8bits at [XXXXXXXX+po]
9211 : grN= 16bits at [XXXXXXXX+po]
9221 : grN= 32bits at [XXXXXXXX+po]

i am wanting to use the 9221 codetype, but i am not sure how to use it. So I put the pointer address in where XXXXXXXX is? What about the offset? where does that go? example: the offset is 300. Where would that go? I think if i figure this part out then i can figure out how to use the other codetypes to write the values.
Title: Re: Load into gecko register (po)
Post by: dcx2 on October 01, 2010, 08:15:41 PM
Put the pointer address into po.  Put the offset into the XXXXXXXX part of the code.  When the code is executed, the offset X is added to the pointer in po, and the value at that address is then put into the gr.
Title: Re: Load into gecko register (po)
Post by: dcx2 on October 01, 2010, 08:34:19 PM
po is an anachronism.  It's not really an offset, it's actually a whole pointer on its own.

Use 4A code type to put an explicit value directly into the po.  Don't forget an E0 terminator.

EDIT: if your pointer is static, you can probably avoid modifying the po.  i.e. if your value is always at 80123458, then you can just use

92210007 00123458

And that would put the value @ address 80123458 into gr7.
Title: Re: Load into gecko register (po)
Post by: dcx2 on October 01, 2010, 10:50:47 PM
4A/48 code type can be a little confusing.  Let's use this line.  I'm going to correct you a bit, too...notice the brackets.

48000000 8032E274 <-- load [8032E274] into pointer

I don't know what value is @ address 8032E274, but let's pretend it's 80321234.  After that line executes, po = 80321234.

Contrast that with this.

4A000000 8032E274 <-- set po to 8032E274

After this line executes, po = 8032E274.

Do you see the difference?

EDIT:

Allow me to extend the example.  The following codes should be identical.

48000000 8032E274  # put [8032E274] into po

is exactly like

4A000000 8032E274  # put 8032E274 into po
58010000 00000000  # put [po + 0] into po
Title: Re: Load into gecko register (po)
Post by: dcx2 on October 01, 2010, 11:03:02 PM
Do you understand the bracket notation?  That is, what's the difference between 8032E274 and [8032E274]?
Title: Re: Load into gecko register (po)
Post by: dcx2 on October 01, 2010, 11:23:15 PM
Yes, that's correct.  In programmer parlance, we sometimes refer to pointers as "references", and we say that the []'s would "dereference" the pointer.  In other words, the []'s get at the underlying object being pointed to.

Without the brackets, it's just a value.  Like any other value.  So in that example, 8032E274 is put directly into the po.  If you were to step through the code handler, you'd see the register that holds the po is the value 8032E274.

But then I do [po + 0].  This takes the value in the po, 8032E274, and then extracts the value from that memory location.  Then, the 58 code type specifies that this value will replace the current po.

No brackets is like standing on the street, looking at the address of the house.  Brackets is like going up to the house, knocking on the door, and asking the fellow inside to come out for a beer.