WiiRd forum

Wii & Gamecube Hacking => Wii Game hacking help => Topic started by: Arudo on July 04, 2011, 11:15:39 PM

Title: Need help with converting Button activators.
Post by: Arudo on July 04, 2011, 11:15:39 PM
Here we have TNTkryzt's code for Harvest Moon: Animal Parade NTSC-U

Hour Modifier
0777C070 0000002C
7C7B1B78 3D608058
816BC608 2C0B2001
4082000C 3B9CFFFF
48000010 2C0B2002
40820008 3B9C0001
4A98B900 00000000
04107994 496746DC
(Press Z+Left/Z+Right D-Pad)

I want to change the activators from Wii-Mote+Nunchuck to Classic Controller Plus, where the activator is R+Left and R+Right
I know that button address for the CCPlus is 8057C66A and the activators are 0202 for R+Left and 8200 for R+Right

So where would I have to change/plug in my values to make this work?
Title: Re: Need help with converting Button activators.
Post by: Thomas83Lin on July 05, 2011, 01:11:11 AM
Hour Modifier [TNTkryzt]
0777C070 0000002C
7C7B1B78 3D608058
816BC608 2C0B2001
4082000C 3B9CFFFF
48000010 2C0B2002
40820008 3B9C0001
4A98B900 00000000
04107994 496746DC
(Press Z+Left/Z+Right D-Pad)

Black=Button Address
Green= button value if equal sub 1
Red=button value if equal add 1

mr r27,r3
lis r11,-32680
lwz r11,-14840(r11)
cmpwi r11,8193
bne- 0x0C
subi r28,r28,1
b 0x10
cmpwi r11,8194
bne- 0x08
addi r28,r28,1
b 0xFE98B900

Title: Re: Need help with converting Button activators.
Post by: Arudo on July 05, 2011, 01:21:21 AM
Hoo-boy.

0777C070 0000002C
7C7B1B78 3D608057
8057C66A 2C0B0202
4082000C 3B9CFFFF
48000010 2C0B8200
40820008 3B9C0001
4A98B900 00000000
04107994 496746DC

I changed it to this and the game didn't like it all...
Title: Re: Need help with converting Button activators.
Post by: Thomas83Lin on July 05, 2011, 01:26:13 AM
Quote from: Arudo on July 05, 2011, 01:21:21 AM
Hoo-boy.

0777C070 0000002C
7C7B1B78 3D608057
8057C66A 2C0B0202
4082000C 3B9CFFFF
48000010 2C0B8200
40820008 3B9C0001
4A98B900 00000000
04107994 496746DC

I changed it to this and the game didn't like it all...

why did you change whats in bold?? you shouldn't have. and make sure your button address is correct.

edit: i noticed your button address ends in a A and his in a 8 make sure your using a 32bit address aswell
Title: Re: Need help with converting Button activators.
Post by: Arudo on July 05, 2011, 01:48:42 AM
Ack! Didn't see that. Let's try it again...

I'm using a 16bit Button address however.
Title: Re: Need help with converting Button activators.
Post by: dcx2 on July 05, 2011, 01:50:25 AM
This is the old way to do C2 codes before the code handler did all the branching for you.  There is some significance to the address 8177C070, in that apparently it is never used.  The ASM is then stored there.  The 4A98B900 = b 0xFE98B900 is a hand-calculated back-branch to 4 bytes after the hook address.  The last line, 04107994 496746DC, is the initial hook.  So 80107994 is the hook address.  496746DC will make the branch at the hook address to 8177C070.

Quote from: thomas83lin on July 05, 2011, 01:26:13 AM
edit: i noticed your button address ends in a A and his in a 8 make sure your using a 32bit address aswell

The ASM does a lwz, so yeah it should end in an 8 instead of an A.
Title: Re: Need help with converting Button activators.
Post by: Arudo on July 05, 2011, 01:59:16 AM
Well now... I've changed it to this right now:

0777C070 0000002C
7C7B1B78 3D608057
816BC668 2C0B0202
4082000C 3B9CFFFF
48000010 2C0B8200
40820008 3B9C0001
4A98B900 00000000
04107994 496746DC

However it doesn't seem to register anything. I'll try a different button address then.
Title: Re: Need help with converting Button activators.
Post by: dcx2 on July 05, 2011, 02:01:12 AM
You could set an execute BP on 8177C070 while you're holding the button combination down, and then Step a few times to see what happens and to make sure it's loading from the button activator address you want
Title: Re: Need help with converting Button activators.
Post by: Arudo on July 05, 2011, 02:09:22 AM
Hmm... no good.
Title: Re: Need help with converting Button activators.
Post by: Thomas83Lin on July 05, 2011, 02:13:33 AM
Quote from: Arudo on July 05, 2011, 01:59:16 AM
Well now... I've changed it to this right now:

0777C070 0000002C
7C7B1B78 3D608057
816BC668 2C0B0202
4082000C 3B9CFFFF
48000010 2C0B8200
40820008 3B9C0001
4A98B900 00000000
04107994 496746DC

However it doesn't seem to register anything. I'll try a different button address then.


you could try changing the code over to 16bit

try this

0777C070 0000002C
7C7B1B78 3D608057
A16BC66A 2C0B0202
4082000C 3B9CFFFF
48000010 2C0B8200
40820008 3B9C0001
4A98B900 00000000
04107994 496746DC

i changed your button address back to 16bit and changed the lwz to lhz
Title: Re: Need help with converting Button activators.
Post by: Arudo on July 05, 2011, 02:16:45 AM
Quote from: thomas83lin on July 05, 2011, 02:13:33 AM
Quote from: Arudo on July 05, 2011, 01:59:16 AM
Well now... I've changed it to this right now:

0777C070 0000002C
7C7B1B78 3D608057
816BC668 2C0B0202
4082000C 3B9CFFFF
48000010 2C0B8200
40820008 3B9C0001
4A98B900 00000000
04107994 496746DC

However it doesn't seem to register anything. I'll try a different button address then.


you could try changing the code over to 16bit

try this

0777C070 0000002C
7C7B1B78 3D608057
A16BC66A 2C0B0202
4082000C 3B9CFFFF
48000010 2C0B8200
40820008 3B9C0001
4A98B900 00000000
04107994 496746DC

i changed your button address back to 16bit and changed the lwz to lhz

Sadly that didn't work either.
Title: Re: Need help with converting Button activators.
Post by: Thomas83Lin on July 05, 2011, 02:18:36 AM
I'm going to let dcx2 help you from here on out, i'm out of ideas besides debugging it myself, but i don't have the game.
Title: Re: Need help with converting Button activators.
Post by: dcx2 on July 05, 2011, 03:16:34 AM
My only suggestion would be to set an execute BP on 8177C070 and make sure that's getting executed.  I would also watch the button activator in memory viewer with auto-update to make sure it's actually doing things.  Press Step Into a few times and stop on the lwz r11,-14840(r11).  Then press Show Mem.  Press Run, then check auto-update, and make sure you're at your button activator address.

...hmm, I think I see what went wrong.  Because the original code wasn't using lis/ori, the address must be handled different.  The displacement operand of a memory access is signed!  So instead of 8057C66A, you get 8056C66A.  (it's subtracting!  lwz r11,-14840(r11) )  This is the purpose of the @ha macro, to account for sign extension.

Notice how the original code uses 8058.  Try this code instead.

0777C070 0000002C
7C7B1B78 3D608058
A16BC66A 2C0B0202
4082000C 3B9CFFFF
48000010 2C0B8200
40820008 3B9C0001
4A98B900 00000000
04107994 496746DC

You can also upgrade this to a proper C2 code and save a line.

C2107994 00000006
7C7B1B78 3D608058
816BC608 2C0B2001
4082000C 3B9CFFFF
48000010 2C0B2002
40820008 3B9C0001
60000000 00000000
Title: Re: Need help with converting Button activators.
Post by: Thomas83Lin on July 05, 2011, 04:48:00 AM
Nice catch, I bet it will work this time around ;D
Title: Re: Need help with converting Button activators.
Post by: Arudo on July 05, 2011, 04:51:13 AM
...wow. Something whacky-scary happened.

The C2 code wouldn't do it, but using the original version, I hit R+Left and time went backward (waaay too fast).

However pushing R+Right doesn't do anything.
Title: Re: Need help with converting Button activators.
Post by: dcx2 on July 05, 2011, 04:56:26 AM
err...what?

Did the C2 code not work?
Title: Re: Need help with converting Button activators.
Post by: Arudo on July 05, 2011, 04:58:06 AM
The C2 one did not react at all (strangely) and the long version one can only make time go backward.
Title: Re: Need help with converting Button activators.
Post by: Patedj on July 05, 2011, 05:42:01 AM
Is this what you guys are doing?

mr r27,r3 #I don't know why this is happening but anyways(maybe it's the address' instruction). Move volatile register r3 to non-volatile r27
lis r11,-32680 #is this the remote control?
lwz r11,-14840(r11) #load the remotes value?
cmpwi r11,8193 #compare remote with button??
bne- 0x0C #branch if not equal to
subi r28,r28,1 #subtract immdediate value by 1 if equal
b 0x10 #branch to ??? this is weird. could it be x14 instead?
cmpwi r11,8194 #compare remote value to this
bne- 0x08 #branch if not equal
addi r28,r28,1 #if equal add immediate value by 1
nop

if so I would like to do this

lis r12, 0x8057 #classic remote address
ori r12, ori 0xC66A (if not r12 then r11) #classic remote address
lwz r12,0(r12) #classic remote address value  
cmpw r12,8200 #compare value with R+right
beq- ADD #branch to add
cpmw r12,202 #compare value with R+lef
beq- SUB #branch to sub
b END #if not branch to end

ADD:
addi r28,r28,1
b END

SUB:
subi r28,r28,1
b END

END:
nop # stop time (if the original value is placed here ie: lwz r28, 0(r27), the original value will then continue to count normally. Perhaps mr r27,r3 is necessary and could be placed here instead of the beginning.

Title: Re: Need help with converting Button activators.
Post by: Arudo on July 06, 2011, 08:04:56 AM
I found a way around it, I'll just stick with brute-force poking addresses.