Key Remapper (GCN) [mdmwii]
#1
Key Remapper (GCN) [mdmwii]

Code will allow you to select a Button to be assigned/activated when using a different Button

NTSC-U
C21AFB58 00000004
38C0XXXX 7C073039
41A20010 38E0YYYY
7C003278 7C003B78
B0040000 00000000

PAL
C21AFBF8 00000004
38C0XXXX 7C073039
41A20010 38E0YYYY
7C003278 7C003B78
B0040000 00000000

NTSC-J
C21AFB18 00000004
38C0XXXX 7C073039
41A20010 38E0YYYY
7C003278 7C003B78
B0040000 00000000

NTSC-K
C21AFF54 00000004
38C0XXXX 7C073039
41A20010 38E0YYYY
7C003278 7C003B78
B0040000 00000000

XXXX = Key to have new feature (original feature will be disabled)
YYYY = Key to assign

Example: Replace Z button with D-Pad Up button so the User can use Z button to actuate Wheelies
XXXX = 0010
YYYY = 0008

X/Y Values:
0001 = D-Pad Left
0002 = D-Pad Right
0004 = D-Pad Down
0008 = D-Pad Up
0010 = Z
0020 = R
0040 = L
0100 = A
0200 = B
0400 = X
0800 = Y
1000 = Start

Source:
Code:
#inject(0x801AFBF8)\n\n (PAL)
#inject(0x801AFB58)\n\n (NTSC-U)
#inject(0x801AFB18)\n\n (NTSC-J)
#inject(0x801AFF54)\n\n (NTSC-K)

li r6, 0xXXXX
and. r7, r0, r6
beq+ end        #Small optimisation
li r7, 0xYYYY
xor r0, r0, r6  #A glorified sub
or r0, r0, r7   #Fix for the issue
end:
sth r0, 0x0(r4)

Code created by: mdmwii
Code credits: Melg (fixed bug when both keys pressed simultaneously, optimized source)
Reply
#2
Sorry for the random thread bump, but I was going to use this code and I should mention that due to this source using an  add instruction, it can create undefined inputs if for some reason you press both the remapped and the assigned key. 
Let's say you remap Y (0x800) to D-Pad up (0x8), and you press both at the same time: your combined input will be 0x888, the code will retract 0x800 and then add 0x8 for a total of 0x90 (80+8+8), which is definitely not D-Pad up and actually not even a GCN key. 
Using or instead fixes the issue:

Code:
#inject(0x801AFBF8)\n\n (PAL)
#inject(0x801AFB58)\n\n (NTSC-U)
#inject(0x801AFB18)\n\n (NTSC-J)
#inject(0x801AFF54)\n\n (NTSC-K)

li r6, XXXX
and. r7, r0, r6
beq+ end        #Small optimisation
li r7, YYYY
xor r0, r0, r6  #A glorified sub
or r0, r0, r7   #Fix for the issue
end:
sth r0, 0x0(r4)
Reply
#3
Thank you very much. Post updated.
Reply
#4
This code isn't working for me for some reason. I tried remapping my gcn d-pad up button to the z buttton:

C21AFB58 00000004
38C00090 7C073039
41A20010 38E00088
7C003278 7C003B78
B0040000 00000000

But when I tried to use this in game, the game acts like I'm holding down the d-pad up button, even when I'm not pressing down anything.
Reply
#5
It was an issue with the X/Y values having a mask of 0x0080 assigned ever since the source was updated using Xor for bit subtraction. Updated code. Tested and works now.
Reply
#6
If you want to remap multiple buttons, then duplicate lines 2-4 (shown in green below, XY values in red), then add 3 to the number at the end of the line (show in blue below), rinse and repeat for each button.

Original / 1 Button Remap:
C21AFB58 00000004
38C0XXXX 7C073039
41A20010 38E0YYYY
7C003278 7C003B78
B0040000 00000000

New / 2 Buttons Remap:
C21AFB58 00000007
38C0XXXX 7C073039
41A20010 38E0YYYY
7C003278 7C003B78
38C0WWWW 7C073039
41A20010 38E0ZZZZ
7C003278 7C003B78
B0040000 00000000

Notes:
  • For this example I used the NTSC-U version of this code (as that's what I needed), but refer to the original codes in the OP for other regions of the game.
  • If you want to remap a physical button, then use that buttons original function (for example, L -> Dpad Up/Wheelie & Y -> L/Item), make sure to replace the physical button first (use L / 0040 in the XXXX section of the code) before giving that functionality to another button (use L / 0040 in the YYYY section of the code). If you do it the other way around, you'll just make a longer version of Y -> Dpad Up/Wheelie & L -> Dpad Up/Wheelie.
  • No matter how many buttons you remap, even just 1, be careful mapping new functions to L and R, since this code will change digital L/R to the new function (wheelie), but analog L/R will still do the original function (item/drift). To avoid this, hold down L and/or R while plugging in your GC controller to "disable" analog L/R inputs.



Original Post...
I just gave this code a shot, with the aim to replace Y with L (item on Y), and replace L with Dpad Up (wheelie on L), but I had two issues.

1) Using two instances of the code, only the second one in the GCT actually does anything.
2) In the case of wheelie on L, it does not disable original function of the button, and thus L would trigger both items and wheelies (both if that was the second in the GCT, and after I removed the Y is item).

I made the GCT with mkw.com/GCT, and loaded it using USB Loader GX on my Wii. The 1st problem could be anything, but the second is really weird 'cause I can see in the source that the r0 r6 xor ought to remove the original button press but it doesn't, maybe it wasn't compiled as shown in the source? IDK about much about Wii ASM tho, so maybe I'm way off.

EDIT: WAIT I FIGURED IT OUT: Item uses analog L to trigger items, not just digital L, so while this removes the digital L input from being able to trigger items, analog L still can. I was able to hold down L while plugging in the controller to "disable" analog L, and L wheelie suddenly worked perfectly without triggering items. Fucking analog triggers >.> Now if only I can figure out how to make two replacements, might have to fuck around find out with Wii ASM.

EDIT 2: I got it! For the first problem, its because the game basically reads from location A (real controller inputs), the gecko code modifies it then saves it to location B (inputs given to game), then repeats the process with the second copy of the code thus making the second one overwrite the first. I had busted out dolphin to see the original instructions to confirm that much, gotten CodeWrite to make a modified version of the source that can handle two replacements in one go, ended up copy pasting the first 6 instructions (minus the "end" label) and then compiling and building GCT, and it didn't work because for whatever reason codewrite generated different hex instructions than the original post and nothing happened in game. I looked at the known good instructions on this page, and I ended up figuring out that if I just copy paste lines 2-4, then change the number of total ASM lines at the end of the first line to 7, it *finally* worked out perfectly! Of course, since both replacements involved the L button, I had to make sure to do L -> Dpad Up replacment first, then Y -> L second.

In the end, my code ended up looking like this:
Code:
C21AFB58 00000007
38C00040 7C073039
41A20010 38E00008
7C003278 7C003B78
38C00800 7C073039
41A20010 38E00040
7C003278 7C003B78
B0040000 00000000
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)