Set Value to ASM C2

Started by Deathwolf, June 21, 2010, 02:56:28 PM

Previous topic - Next topic

dcx2

There are many ways to do it.  li r3,9999 may work.  I like mr r3,r5 better, because r5 is what the max should be.  The max may not always be 9999.

Deathwolf

lolz

Romaap

The bl 'branches' to the address given (which means the next instruction being executed is the one at the address specified) and stores the address after the bl in the Link Register.
At the end of the subroutine where you just branched to is the instruction blr, this instructions branches to the address in the Link Register which should be the address after the bl.

Deathwolf

thanks.

btw here another way.

change

804DE09C:  7C602214   add   r3,r0,r4

to

804DE09C:  38600000   li  r3,99
lolz

dcx2

bl "calls functions"

When you pick up a star bit, the game "calls" me.  It tells me to add 1 to Mario's Star Bits.  So I add one.

But then we have to make sure we don't go over 9999.  So I "call" Romaap, and Romaap makes sure that Mario's Star Bits are 0 <= starbits <= 9999.  Then Romaap "hangs up" ( = blr), and then I "hang up".  Then the game continues.

Using Gecko.NET's Logging, here's what it looks like.  I had 0x816 star bits, and I was picking one up (note how r4 = 1 @ 804DE09C)


804DE080:  9421FFF0   stwu   r1,-16(r1)   r1 = 807F2FD0   r1 = 807F2FD0
804DE084:  7C0802A6   mflr   r0         LR = 804D3BA8   r0 = 80023A20
804DE088:  38A0270F   li   r5,9999    r5 = 8065BA70
804DE08C:  90010014   stw   r0,20(r1)   r0 = 804D3BA8   r1 = 807F2FC0
804DE090:  93E1000C   stw   r31,12(r1)   r31 = 00000001   r1 = 807F2FC0
804DE094:  7C7F1B78   mr   r31,r3     r31 = 00000001   r3 = 80E40E70
804DE098:  A003000A   lhz   r0,10(r3)   r0 = 804D3BA8   r3 = 80E40E70
804DE09C:  7C602214   add   r3,r0,r4   r3 = 80E40E70   r0 = 00000816   r4 = 00000001
804DE0A0:  38800000   li   r4,0       r4 = 00000001
804DE0A4:  4BB3BD5D   bl   0x80019e00
   80019E00:  7C032000   cmpw   r3,r4      r3 = 00000817   r4 = 00000000
   80019E04:  40800008   bge-   0x80019e0c
   80019E0C:  7C032800   cmpw   r3,r5      r3 = 00000817   r5 = 0000270F
   80019E10:  40810008   ble-   0x80019e18
   80019E18:  7C641B78   mr   r4,r3      r4 = 00000000   r3 = 00000817
   80019E1C:  7C832378   mr   r3,r4      r3 = 00000817   r4 = 00000817
   80019E20:  4E800020   blr              LR = 804DE0A8
804DE0A8:  B07F000A   sth   r3,10(r31)   r3 = 00000817   r31 = 80E40E70
804DE0AC:  83E1000C   lwz   r31,12(r1)   r31 = 80E40E70   r1 = 807F2FC0
804DE0B0:  80010014   lwz   r0,20(r1)   r0 = 00000816   r1 = 807F2FC0
804DE0B4:  7C0803A6   mtlr   r0         LR = 804DE0A8   r0 = 804D3BA8
804DE0B8:  38210010   addi   r1,r1,16   r1 = 807F2FC0   r1 = 807F2FC0
804DE0BC:  4E800020   blr              LR = 804D3BA8

Deathwolf

ohh makes sense for me.

thanks alot
lolz

hetoan2

@dcx2, I liked your telephone analogy...

In my mind Romaap and you broke out into a Lady Gaga tune that I can't recall the name of right now...

Very catchy... Also you and Romaap Murdered a bunch of functions :o

[/ladygagajokes]

Still a good analogy. Although that really is what the game does if you think about it.


Check out my site with codes obviously...
http://hetoan2.com/

and youtube...
http://youtube.com/hetoan2