Mario Kart Wii Gecko Codes, Cheats, & Hacks

Full Version: XYZ Position Swapper [Vega]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
XYZ Position Swapper [Vega]



Code creator: Vega
Code credits: Seeky (mkw structure github), Stebler (extra position documentation)
https://github.com/SeekyCt/mkw-structure...r/player.h



A very rudimentary code that allows you to instantly swap your XYZ position (where you are on the track) with any desired CPU during an offline race/battle. I added in a small check to the code to ensure that XYZ's were not constantly swapping when holding down the activator or else it will cause unwanted/weird moonjumping effects. Don't swap too fast or else those weird effects will start to occur.

Please keep in mind this code does not include...
- Checks if you are in a race/battle (will freeze if you activate at something like the main license menu)
- Checks if doing TTs (will probably just freeze if you tried or end up doing nothing)
- Camera Angling adjustments (be prepared to be facing in an odd direction after swapping)

S = CPU slot value to switch with (anything from 1 thru B). I haven't tested setting the slot value to 0 (yourself), should just end up doing nothing.

XXXX = Controller Address
ZZZZ = Button Activator

Handy reference page for X and Z values - https://mkwii.com/showthread.php?tid=44

W values:
5 = PAL w/ GCN controller
3 = NTSC-K (any controller)
4 = All other region+controller combos

Final NOTE: This code makes use of Memory Address 0x800003FF. Make sure no other codes in your GCT/Cheat-Manager are using that address, or if you are a coder/dev, then feel free to modify the code to use a different Memory Address.

Region-Free
C0000000 0000001A
3D80803W A18CXXXX
3960ZZZZ 7D606038
7C005800 3D808000
41820010 38000000
980C03FF 4E800020
880C03FF 2C000001
4D820020 38000001
980C03FF 3800000S
898C5F27 3D60809C
2C0C008C 806BD110
41820024 2C0C00EC
806B18F8 41820018
2C0C0010 806B0958
4182000C 3D60809B
806BFF38 80A30020
80A50000 81230020
5400103A 7D29002E
80A50000 80A50008
80A50090 80A50004
38A50068 81290000
81290008 81290090
81290004 39290068
7D4564AA 3861FFF4
7D4365AA 7D4964AA
7D4565AA 7D4364AA
7D4965AA 4E800020



#START ASSEMBLY (C0 Codetype)

#Memory Notes
#0x800003FF = Button Status
#0 = Not Pressed
#1 = Pressed

#Register Notes
#r5 = You
#r9 = CPU

#Check Button Activation
lis r12, 0x8033 #NTSC-K GCN Y button for compilation purposes, adjust this accordingly
lhz r12, 0x6200 (r12)
li r11, 0x0880
and r0, r11, r12
cmpw r0, r11
lis r12, 0x8000
beq- button_pressed

#Nothing Pressed, Reset Button Status, End C0
li r0, 0
stb r0, 0x3FF (r12)
blr

#Button Pressed, Adjust Button Status
#0 = Not Pressed
#1 = Pressed
button_pressed:
lbz r0, 0x3FF (r12)
cmpwi r0, 1
beqlr-
li r0, 1
stb r0, 0x3FF (r12)

#Set User Desired CPU Slot
li r0, 1 #Set to 1 for compilation purposes, adjust this accordingly

#Determine Game Region, Grab Initial Pointer
lbz r12, 0x5F27 (r12) #Instruction here is vital. Virtually impossible for this to be modded by something unrelated.

lis r11, 0x809C

cmpwi r12, 0x8C
lwz r3, 0xFFFFD110 (r11)
beq- usa

cmpwi r12, 0xEC
lwz r3, 0x18F8 (r11)
beq- pal

cmpwi r12, 0x10
lwz r3, 0x0958 (r11)
beq- japan

#korea;r12 = 0x54
lis r11, 0x809B
lwz r3, 0xFFFFFF38 (r11)

#Load Your Player Data Pointer
usa:
pal:
japan:
lwz r5, 0x0020 (r3)
lwz r5, 0 (r5)

#Load CPU Player Data Pointer
lwz r9, 0x0020 (r3)
rlwinm r0, r0, 2, 0, 29
lwzx r9, r9, r0

#Load Your XYZ Coordinate Pointer
lwz r5, 0 (r5)
lwz r5, 0x8 (r5)
lwz r5, 0x90 (r5)
lwz r5, 0x4 (r5)
addi r5, r5, 104

#Load CPU XYZ Coordinate Pointer
lwz r9, 0 (r9)
lwz r9, 0x8 (r9)
lwz r9, 0x90 (r9)
lwz r9, 0x4 (r9)
addi r9, r9, 104

#Load Your XYZ's, save to negative stack
lswi r10, r5, 12
addi r3, sp, -0xC
stswi r10, r3, 12

#Load CPU XYZ's
lswi r10, r9, 12

#Write CPU XYZ's to your Pointer
stswi r10, r5, 12

#Reload Your XYZ's back into r10 thru r12
lswi r10, r3, 12

#Write Your XYZ's to CPU's Pointer
stswi r10, r9, 12

#End C0
#blr #Uncomment if not compiling with pyii

#END ASSEMBLY