small issue with safe registers

Started by paprika_killer, May 04, 2009, 04:02:16 PM

Previous topic - Next topic

paprika_killer

I'm trying to port over a code from NTSC brawl to PAL, and I found the break, but it gets glitchy when using it.

the code in question is "handicap = buffer frames"
C285B784 00000006
807F002C 3C809018
806300F4 60840FDC
1C63005C 7C83202E
3860000A 2C040064
40800008 7C641BD6
60000000 00000000


and this is the assembly
lwz r3,44(r31)
lis r4,-28648
lwz r3,244(r3)
ori r4,r4,4060
mulli r3,r3,92
lwzx r4,r3,r4
li r3,10
cmpwi r4,100
bge- 0x08
divw r3,r4,r3
nop


the only registers touched are r3 and r4 but the problem is that the breakpoint is a "bctrl" instruction.
this means it branches to some location, and makes it pretty hard to find safe registers.

if anyone can help me with this, or tell me what registers NOT to, it would be much appreciated.
[SIGPIC][/SIGPIC]

Y.S.

80856BE4:  4E800421 bctrl


lwz r3,44(r31)
lis r4,-28648
lwz r3,244(r3)
ori r4,r4,4060
mulli r3,r3,92
lwzx r4,r3,r4
li r3,10
cmpwi r4,100
bge- 0x08
divw r3,r4,r3
nop

80856BE8:  907F015C stw r3,348(r31)
80856BEC:  83E1000C lwz r31,12(r1)
80856BF0:  80010014 lwz r0,20(r1)
80856BF4:  7C0803A6 mtlr r0
80856BF8:  38210010 addi r1,r1,16
80856BFC:  4E800020 blr


The instruction at 8001CD10 stores the buffer in r3 , and the inserted codes calculate the new buffer based on handicap. That is, using r3 in the code is absolutely no problem. I'm not sure about r4 though.
r12 can be used safely in most cases, as it's used in function jump or such.


dragonboy269

#2
Maniac sent me this awhile ago

Here is the list of registers that can be freely used :

r3
r5
r9
r10
r11
r12
r13
r14
r17
r19
r27
r30
f2
f3
If you have any requests for AC:WW/AC:CF codes, send me a message. :D

paprika_killer

ok gotta try changing r4 to something else.
and is that list version/game/whatever specific, because NTSC doesn't seem to have the problem
[SIGPIC][/SIGPIC]

Link

Quote from: dragonboy269 on May 05, 2009, 03:42:15 AM
Maniac sent me this awhile ago

Here is the list of registers that can be freely used :

r3
r5
r9
r10
r11
r12
r13
r14
r17
r19
r27
r30
f2
f3


I wonder.. is this list always free to be used? Might depend on a game but that would most likely mean you can use them as long as the game does not.

dragonboy269

Well, according to Maniac/Virus, it's for all games
If you have any requests for AC:WW/AC:CF codes, send me a message. :D

brkirch

Quote from: dragonboy269 on May 07, 2009, 01:31:02 AM
Well, according to Maniac/Virus, it's for all games
It's probably safe registers for the C0 code type, there is no such thing as registers being safe for all games since what registers are safe depends on where you are putting the ASM insert.  Some registers are special purpose and you can never use them though (except for the purpose for which they are intended):
r1 -  Stack Pointer (SP)
r2 -  Read-only small data area anchor
r13 -  Read-write small data area anchor