Mario Kart Wii Gecko Codes, Cheats, & Hacks
Random Character+Vehicle Combo For Every Race -Online- [Vega] - Printable Version

+- Mario Kart Wii Gecko Codes, Cheats, & Hacks (https://mariokartwii.com)
+-- Forum: Cheat Codes (https://mariokartwii.com/forumdisplay.php?fid=51)
+--- Forum: Online Non-Item (https://mariokartwii.com/forumdisplay.php?fid=52)
+--- Thread: Random Character+Vehicle Combo For Every Race -Online- [Vega] (/showthread.php?tid=1410)



Random Character+Vehicle Combo For Every Race -Online- [Vega] - Vega - 01-03-2020

Random Character+Vehicle Combo For Every Race -Online- [Vega]

Works for Online only. Doesn't work in battle.

This code will give you a completely random character+Vehicle combo for each race you do Online. There's no telling what character+vehicle combo you will be when the race begins! Have fun.

This code will NEVER give you the Mii as a character to use, and your chosen drift/transmission mode is NEVER effected.

NOTE: This code makes use of memory addresses 0x800004C0 and 0x800004C1. Make sure no other codes in your GCT/Cheat-Manager are using those addresses!

Region-Free
C0000000 0000002B
7CA802A6 3D808000
896C04C0 396B0001
280B0018 41A00008
39600000 996C04C0
894C04C1 394A0003
280A0024 41A00008
39400000 994C04C1
39200000 2C0B0001
41820084 2C0B0004
4182007C 2C0B0005
41820074 2C0B0006
4182006C 2C0B0008
41820064 2C0B000C
4182005C 2C0B000D
41820054 2C0B000E
4182004C 39200001
2C0B0000 41820040
2C0B0007 41820038
2C0B000A 41820030
2C0B000F 41820028
2C0B0010 41820020
2C0B0011 41820018
2C0B0012 41820010
2C0B0014 41820008
39200002 7C0A4A14
28000024 41A00008
7D204B78 898C5F27
2C0C00EC 41820020
2C0C0010 41820024
2C0C0054 41820028
3D808061 618C2328
48000024 3D808064
618C374C 48000018
3D808064 618C2DB4
4800000C 3D808063
618C1A60 3D403880
7D4A5B78 914C0000
48000019 3D4038A0
7D4A0378 398C0004
914C0000 7CA803A6
7C00606C 7C0004AC
7C0067AC 4C00012C
4E800020 00000000



Code creator: Vega



#~~~~~~~~~~~~~~~~~~~~~~~~#
# START ASSEMBLY C0 Code #
#~~~~~~~~~~~~~~~~~~~~~~~~#

#######################
#NOTES ABOUT COMPILING#
#######################

#(Even if you use PyiiASMH), compile this as a C2 (no address), then change C2 to C0.
#If you compile as a C0 in PyiiASMH, there will be an extra unnecessary blr at the very end
#Makes no difference, just an fyi

#~~~~~~~~~~~~~~#
# Memory Notes #
#~~~~~~~~~~~~~~#

#0x800004C0 = Byte cycle character
#0x800004C1 = Byte cycle for vehicle (+3 per increment)

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Backup C0 LR, Setup Vector Address, Increment Character Value #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

mflr r5
lis r12, 0x8000
lbz r11, 0x04C0 (r12)

addi r11, r11, 1

cmplwi r11, 0x18 #range 0 thru 0x17
blt+ store_char_byte

li r11, 0 #Reset cycle

store_char_byte:
stb r11, 0x04C0 (r12)

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Increment Vehicle. Gaps of 3 due to how Game sorts Vehicle-to-Class Values #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

lbz r10, 0x04C1 (r12)

addi r10, r10, 3

cmplwi r10, 0x24 #range 0 thru 0x23
blt+ store_veh_group_byte

li r10, 0 #Reset cycle

store_veh_group_byte:
stb r10, 0x04C1 (r12)

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Check Lightweight, then Middleweight. If not those, ofc its Heavy #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

#The Vehicle values in the game as listed by weight class as L, M, W, L, M, W etc etc.
#This pattern of grouping helps a lot.
#If lightweight character is r11, then just add 0 to the loaded vehicle byte value
#If middleweight for r11, then just add 1
#If heavy, add 2
#This allows vehicle byte to always be aligned with the weight class, ofc there's a max check further down

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Set r9 to 0 add lightweight pattern add. Check for lightweight #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

li r9, 0

cmpwi r11, 1
beq- add_values
cmpwi r11, 4
beq- add_values
cmpwi r11, 5
beq- add_values
cmpwi r11, 6
beq- add_values
cmpwi r11, 8
beq- add_values
cmpwi r11, 0xC
beq- add_values
cmpwi r11, 0xD
beq- add_values
cmpwi r11, 0xE
beq- add_values

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Set r9 to 1 add middleweight pattern add. Check for middleweight #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

li r9, 1

cmpwi r11, 0
beq- add_values
cmpwi r11, 7
beq- add_values
cmpwi r11, 0xA
beq- add_values
cmpwi r11, 0xF
beq- add_values
cmpwi r11, 0x10
beq- add_values
cmpwi r11, 0x11
beq- add_values
cmpwi r11, 0x12
beq- add_values
cmpwi r11, 0x14
beq- add_values

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Character is heavyweight. Set r9 to add 2 for pattern #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

li r9, 2

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Add the pattern (r9) amount to the loaded vehicle value #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

add_values:
add r0, r10, r9

cmplwi r0, 0x24 #Make sure Max isn't exceeded
blt+ check_region

mr r0, r9 #Very rare for this to occur. Max was exceeded, use default 1st vehicle (standard kart) of weight class aka the pattern value

#~~~~~~~~~~~~~~~~~~~~~~#
# Find the Game Region #
#~~~~~~~~~~~~~~~~~~~~~~#

check_region:
lbz r12, 0x5F27 (r12) #Instruction here is vital. Virtually impossible for this to be modded by something unrelated

cmpwi r12, 0xEC
beq- pal
cmpwi r12, 0x10
beq- japan
cmpwi r12, 0x54
beq- korea

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Apply Character Address Based on Game Region #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

#usa
lis r12, 0x8061
ori r12, r12, 0x2328
b write_values

pal:
lis r12, 0x8064
ori r12, r12, 0x374C
b write_values

japan:
lis r12, 0x8064
ori r12, r12, 0x2DB4
b write_values

korea:
lis r12, 0x8063
ori r12, r12, 0x1A60

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Write New Instructions to Static Memory #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

write_values:
lis r10, 0x3880
or r10, r10, r11
stw r10, 0 (r12) #Store Character Value

bl clear_cache

lis r10, 0x38A0
or r10, r10, r0
addi r12, r12, 4 #Needed for upcoming cache flush
stw r10, 0 (r12) #Store Vehicle Value

#~~~~~~~~~~~~~~~#
# Restore C0 LR #
#~~~~~~~~~~~~~~~#

mtlr r5

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
# Clear Cache, so Instructions always update #
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#

clear_cache:
dcbst 0, r12
sync
icbi 0, r12
isync
blr #When called 2nd time, this will be the C0 LR

#~~~~~~~~~~~~~~#
# END ASSEMBLY #
#~~~~~~~~~~~~~~#


RE: Random Character+Vehicle Combo For Every Race -Online- [Vega] - salmon01 - 01-03-2020

Maybe, since you use the cmpwi / beq- pattern a lot in the weight class checks, you could implement a loop w/ BL trick to shorten the code. What I mean is something like:

lightweight:
li r9, 0
bl check
.llong 0x01040506080C0D0E

middleweight:
li r9, 0x1
bl check
.llong 0x00070A0F10111214

check:
mflr rA
subi rA, rA, 0x1
li rC, 0x8

loop:
lbzu rB, 0x1 (rA)
cmpw r11, rB
beq- add_values
subic. rC, rC, 0x1
bne loop

cmpwi r9, 0x1
bne middleweight
li r9, 0x2

where rA, rB, rC are free registers. Just my two cents. Kinda cool you implemented region checks into the code itself.


RE: Random Character+Vehicle Combo For Every Race -Online- [Vega] - Vega - 01-04-2020

I heard USB loader GX with Debug off can fit a Max GCT of 478 lines of code. I have always thought that having codes for every region is silly. The end user shouldn't have to deal with that. Every code should be region free.

Funny thing is I started making this code wanting something to use as what you provided. Some sort of self modifying code just to get a feel for it. Unfortunately, I was unable to get my self-mod source to be shorter than the current one. Then again I'm slow at learning new tricks...


RE: Random Character+Vehicle Combo For Every Race -Online- [Vega] - Luigi Hack Fan - 06-11-2023

Im getting the delicious EEEEEEEEEEEEEEEEEEEEEEE Sound when I pick a track (console only). Is it because of LE-CODE?


RE: Random Character+Vehicle Combo For Every Race -Online- [Vega] - Vega - 06-14-2023

Probably.


RE: Random Character+Vehicle Combo For Every Race -Online- [Vega] - Luigi Hack Fan - 11-17-2023

Welp. Using a different Code Handler, same result. So im guessing its a Code/LE-CODE issue?


RE: Random Character+Vehicle Combo For Every Race -Online- [Vega] - Vega - 11-17-2023

Could be because I'm not restoring the new character and vehicle data back into Memory.

Try this~

NTSC-U
C261232C 0000001C
3D808000 88AC04C0
38A50001 28050018
41A00008 38A00000
98AC04C0 896C04C1
396B0003 280B0024
41A00008 39600000
996C04C1 39200000
2C050001 41820084
2C050004 4182007C
2C050005 41820074
2C050006 4182006C
2C050008 41820064
2C05000C 4182005C
2C05000D 41820054
2C05000E 4182004C
39200001 2C050000
41820040 2C050007
41820038 2C05000A
41820030 2C05000F
41820028 2C050010
41820020 2C050011
41820018 2C050012
41820010 2C050014
41820008 39200002
7D6B4A14 280B0024
41A00008 7D2B4B78
90A80224 91680228
7D685B78 00000000

PAL
C2643750 0000001C
3D808000 88AC04C0
38A50001 28050018
41A00008 38A00000
98AC04C0 896C04C1
396B0003 280B0024
41A00008 39600000
996C04C1 39200000
2C050001 41820084
2C050004 4182007C
2C050005 41820074
2C050006 4182006C
2C050008 41820064
2C05000C 4182005C
2C05000D 41820054
2C05000E 4182004C
39200001 2C050000
41820040 2C050007
41820038 2C05000A
41820030 2C05000F
41820028 2C050010
41820020 2C050011
41820018 2C050012
41820010 2C050014
41820008 39200002
7D6B4A14 280B0024
41A00008 7D2B4B78
90A80224 91680228
7D685B78 00000000

NTSC-J
C2642DB8 0000001C
3D808000 88AC04C0
38A50001 28050018
41A00008 38A00000
98AC04C0 896C04C1
396B0003 280B0024
41A00008 39600000
996C04C1 39200000
2C050001 41820084
2C050004 4182007C
2C050005 41820074
2C050006 4182006C
2C050008 41820064
2C05000C 4182005C
2C05000D 41820054
2C05000E 4182004C
39200001 2C050000
41820040 2C050007
41820038 2C05000A
41820030 2C05000F
41820028 2C050010
41820020 2C050011
41820018 2C050012
41820010 2C050014
41820008 39200002
7D6B4A14 280B0024
41A00008 7D2B4B78
90A80224 91680228
7D685B78 00000000

NTSC-K
C2631A64 0000001C
3D808000 88AC04C0
38A50001 28050018
41A00008 38A00000
98AC04C0 896C04C1
396B0003 280B0024
41A00008 39600000
996C04C1 39200000
2C050001 41820084
2C050004 4182007C
2C050005 41820074
2C050006 4182006C
2C050008 41820064
2C05000C 4182005C
2C05000D 41820054
2C05000E 4182004C
39200001 2C050000
41820040 2C050007
41820038 2C05000A
41820030 2C05000F
41820028 2C050010
41820020 2C050011
41820018 2C050012
41820010 2C050014
41820008 39200002
7D6B4A14 280B0024
41A00008 7D2B4B78
90A80224 91680228
7D685B78 00000000


Code:
#Address's (C2)
#NTSC-U 8061232C
#PAL 80643750
#NTSC-J 80642DB8
#NTSC-K 80631A64

#Register Safety + Notes
#r0, r9 thru r12 safe
#r8 + 0x224 = Char Mem Spot
#r8 + 0x228 = Veh Mem Spot
#r5 = Char Value
#r11 (before end) = Veh Value
#r8 (at end) must = Veh Value

#Increment Character Byte
lis r12, 0x8000
lbz r5, 0x04C0 (r12)
addi r5, r5, 1
cmplwi r5, 0x18 #range 0 thru 0x17
blt+ store_char_byte
li r5, 0 #Reset cycle
store_char_byte:
stb r5, 0x04C0 (r12)

#Increment Vehicle Byte. Gaps of 3 due to how Game sorts Vehicle-to-Class Values #
lbz r11, 0x04C1 (r12)
addi r11, r11, 3
cmplwi r11, 0x24 #range 0 thru 0x23
blt+ store_veh_group_byte
li r11, 0 #Reset cycle
store_veh_group_byte:
stb r11, 0x04C1 (r12)

#Check Lightweight, then Middleweight. If not those, ofc its Heavy #
#The Vehicle values in the game as listed by weight class as L, M, W, L, M, W etc etc.
#This pattern of grouping helps a lot.
#If lightweight character for r5, then just add 0 to the loaded vehicle byte value
#If middleweight for r5, then just add 1
#If heavy, add 2
#This allows vehicle byte to always be aligned with the weight class, ofc there's a max check further down

#Set r9 to 0 add lightweight pattern add. Check for lightweight #
li r9, 0

cmpwi r5, 1
beq- add_values
cmpwi r5, 4
beq- add_values
cmpwi r5, 5
beq- add_values
cmpwi r5, 6
beq- add_values
cmpwi r5, 8
beq- add_values
cmpwi r5, 0xC
beq- add_values
cmpwi r5, 0xD
beq- add_values
cmpwi r5, 0xE
beq- add_values

#Set r9 to 1 add middleweight pattern add. Check for middleweight #
li r9, 1

cmpwi r5, 0
beq- add_values
cmpwi r5, 7
beq- add_values
cmpwi r5, 0xA
beq- add_values
cmpwi r5, 0xF
beq- add_values
cmpwi r5, 0x10
beq- add_values
cmpwi r5, 0x11
beq- add_values
cmpwi r5, 0x12
beq- add_values
cmpwi r5, 0x14
beq- add_values

#Character is heavyweight. Set r9 to add 2 for pattern #
li r9, 2

#Add the pattern (r9) amount to the loaded vehicle value #
add_values:
add r11, r11, r9

cmplwi r11, 0x24 #Make sure Max isn't exceeded
blt+ store_stuff

mr r11, r9 #Very rare for this to occur. Max was exceeded, use default 1st vehicle (standard kart) of weight class aka the pattern value

#Store Char and Veh bytes to Memory, then set r8 to Veh byte
store_stuff:
stw r5, 0x224 (r8)
stw r11, 0x228 (r8)
mr r8, r11

#End