Need help with converting Button activators.

Started by Arudo, July 04, 2011, 11:15:39 PM

Previous topic - Next topic

Arudo

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?
-Crazy Hacker Hates You All (definitely)-

ノಠ益ಠ)ノ彡â"»â"â"»

Do NOT PM me about Code Requests

Pro-tip: Hit the Applaud Button

Oh? Failed to read the rules? You're already dead.

Thomas83Lin

#1
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


Arudo

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...
-Crazy Hacker Hates You All (definitely)-

ノಠ益ಠ)ノ彡â"»â"â"»

Do NOT PM me about Code Requests

Pro-tip: Hit the Applaud Button

Oh? Failed to read the rules? You're already dead.

Thomas83Lin

#3
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

Arudo

Ack! Didn't see that. Let's try it again...

I'm using a 16bit Button address however.
-Crazy Hacker Hates You All (definitely)-

ノಠ益ಠ)ノ彡â"»â"â"»

Do NOT PM me about Code Requests

Pro-tip: Hit the Applaud Button

Oh? Failed to read the rules? You're already dead.

dcx2

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.

Arudo

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.
-Crazy Hacker Hates You All (definitely)-

ノಠ益ಠ)ノ彡â"»â"â"»

Do NOT PM me about Code Requests

Pro-tip: Hit the Applaud Button

Oh? Failed to read the rules? You're already dead.

dcx2

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

Arudo

-Crazy Hacker Hates You All (definitely)-

ノಠ益ಠ)ノ彡â"»â"â"»

Do NOT PM me about Code Requests

Pro-tip: Hit the Applaud Button

Oh? Failed to read the rules? You're already dead.

Thomas83Lin

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

Arudo

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.
-Crazy Hacker Hates You All (definitely)-

ノಠ益ಠ)ノ彡â"»â"â"»

Do NOT PM me about Code Requests

Pro-tip: Hit the Applaud Button

Oh? Failed to read the rules? You're already dead.

Thomas83Lin

#11
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.

dcx2

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

Thomas83Lin

Nice catch, I bet it will work this time around ;D

Arudo

...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.
-Crazy Hacker Hates You All (definitely)-

ノಠ益ಠ)ノ彡â"»â"â"»

Do NOT PM me about Code Requests

Pro-tip: Hit the Applaud Button

Oh? Failed to read the rules? You're already dead.