Random Character+Vehicle Combo For Every Race -Online- [Vega]
#1
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 #
#~~~~~~~~~~~~~~#
Reply


Messages In This Thread
Random Character+Vehicle Combo For Every Race -Online- [Vega] - by Vega - 01-03-2020, 10:01 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)