Set User Favorite Combo as Defaul like CTGP [Bully, CLF78, Kazuki]
#1
Set User Favorite Combo as Defaul like CTGP [Bully, CLF78, Kazuki]

Set the default combo to the most used character and vehicle in the upper left license.
If the upper left license is empty, the upper right license is used, if the upper right license is also empty, the lower left license is used, and if the lower left license is also empty, the lower right license is used.
Mii is excluded.

This code uses 0x800011DA

(PAL)
C25e4208 00000002
3D808000 88AC11DA
60000000 00000000
C25e4114 0000002F
9421FF80 7C0802A6
90010084 BC610008
3D80809C 818CD748
A16C0036 818C0014
3D400000 614A8CC0
3D20524B 61295044
38EC0008 39000000
80C70000 7CE75214
7C064800 41820014
39080001 2C080004
4082FFE8 39000000
7D4A41D6 396B00F4
7D8C5A14 7D8C5214
7D8A6378 39600000
38A00000 A08A0000
394A0002 7C045800
41800008 7C8B2378
38A50001 2C050018
4082FFE4 38A00000
7D8A6378 A08A0000
394A0002 7C045800
4182000C 38A50001
4BFFFFEC 2C050018
40820008 38A00000
3CC08000 98A611DA
4800001D 01000202
00000001 00020102
00000001 01010102
01020202 7CC802A6
7CC62A14 88C60000
39200002 7D2931D6
39600000 38A00000
398C0032 7D8C4A14
7D8A6378 A08A0000
394A0006 7C045800
41800008 7C8B2378
38A50001 2C05000C
4082FFE4 38A00000
7D8A6378 A08A0000
394A0006 7C045800
4182000C 38A50001
4BFFFFEC 1CA50003
7CA53214 90A1FFFC
B8610008 80010084
7C0803A6 38210080
8181FF7C 918A013C
60000000 00000000
025E418C 0000918A

(NTSC-U)
C25ce42c 00000002
3D808000 88AC11DA
60000000 00000000
C25ce338 0000002F
9421FF80 7C0802A6
90010084 BC610008
3D80809C 818C8F88
A16C0036 818C0014
3D400000 614A8CC0
3D20524B 61295044
38EC0008 39000000
80C70000 7CE75214
7C064800 41820014
39080001 2C080004
4082FFE8 39000000
7D4A41D6 396B00F4
7D8C5A14 7D8C5214
7D8A6378 39600000
38A00000 A08A0000
394A0002 7C045800
41800008 7C8B2378
38A50001 2C050018
4082FFE4 38A00000
7D8A6378 A08A0000
394A0002 7C045800
4182000C 38A50001
4BFFFFEC 2C050018
40820008 38A00000
3CC08000 98A611DA
4800001D 01000202
00000001 00020102
00000001 01010102
01020202 7CC802A6
7CC62A14 88C60000
39200002 7D2931D6
39600000 38A00000
398C0032 7D8C4A14
7D8A6378 A08A0000
394A0006 7C045800
41800008 7C8B2378
38A50001 2C05000C
4082FFE4 38A00000
7D8A6378 A08A0000
394A0006 7C045800
4182000C 38A50001
4BFFFFEC 1CA50003
7CA53214 90A1FFFC
B8610008 80010084
7C0803A6 38210080
8181FF7C 918A013C
60000000 00000000
025CE3B0 0000918A

(NTSC-J)
C25e3ae4 00000002
3D808000 88AC11DA
60000000 00000000
C25e39f0 0000002F
9421FF80 7C0802A6
90010084 BC610008
3D80809C 818CC7A8
A16C0036 818C0014
3D400000 614A8CC0
3D20524B 61295044
38EC0008 39000000
80C70000 7CE75214
7C064800 41820014
39080001 2C080004
4082FFE8 39000000
7D4A41D6 396B00F4
7D8C5A14 7D8C5214
7D8A6378 39600000
38A00000 A08A0000
394A0002 7C045800
41800008 7C8B2378
38A50001 2C050018
4082FFE4 38A00000
7D8A6378 A08A0000
394A0002 7C045800
4182000C 38A50001
4BFFFFEC 2C050018
40820008 38A00000
3CC08000 98A611DA
4800001D 01000202
00000001 00020102
00000001 01010102
01020202 7CC802A6
7CC62A14 88C60000
39200002 7D2931D6
39600000 38A00000
398C0032 7D8C4A14
7D8A6378 A08A0000
394A0006 7C045800
41800008 7C8B2378
38A50001 2C05000C
4082FFE4 38A00000
7D8A6378 A08A0000
394A0006 7C045800
4182000C 38A50001
4BFFFFEC 1CA50003
7CA53214 90A1FFFC
B8610008 80010084
7C0803A6 38210080
8181FF7C 918A013C
60000000 00000000
025E3A68 0000918A

(NTSC-K) (untested)
C25d23a4 00000002
3D808000 88AC11DA
60000000 00000000
C25d22b0 0000002F
9421FF80 7C0802A6
90010084 BC610008
3D80809B 818CBD88
A16C0036 818C0014
3D400000 614A8CC0
3D20524B 61295044
38EC0008 39000000
80C70000 7CE75214
7C064800 41820014
39080001 2C080004
4082FFE8 39000000
7D4A41D6 396B00F4
7D8C5A14 7D8C5214
7D8A6378 39600000
38A00000 A08A0000
394A0002 7C045800
41800008 7C8B2378
38A50001 2C050018
4082FFE4 38A00000
7D8A6378 A08A0000
394A0002 7C045800
4182000C 38A50001
4BFFFFEC 2C050018
40820008 38A00000
3CC08000 98A611DA
4800001D 01000202
00000001 00020102
00000001 01010102
01020202 7CC802A6
7CC62A14 88C60000
39200002 7D2931D6
39600000 38A00000
398C0032 7D8C4A14
7D8A6378 A08A0000
394A0006 7C045800
41800008 7C8B2378
38A50001 2C05000C
4082FFE4 38A00000
7D8A6378 A08A0000
394A0006 7C045800
4182000C 38A50001
4BFFFFEC 1CA50003
7CA53214 90A1FFFC
B8610008 80010084
7C0803A6 38210080
8181FF7C 918A013C
60000000 00000000
025D2328 0000918A

base codes:
https://mariokartwii.com/showthread.php?tid=357
https://mariokartwii.com/showthread.php?tid=1841

source:

Code:
# inject at 0x805e4208 (PAL)
# inject at 0x805ce42c (NTSC-U)
# inject at 0x805e3ae4 (NTSC-J)
# inject at 0x805d23a4 (NTSC-K)
.set character_id_save, 0x800011DA
lis r12, character_id_save@ha
lbz r5, character_id_save@l (r12)

Code:
# inject at 0x805e4114 (PAL)
# inject at 0x805ce338 (NTSC-U)
# inject at 0x805e39f0 (NTSC-J)
# inject at 0x805d22b0 (NTSC-K)
.set region, 'J'
.set character_id_save, 0x800011DA
.set rkpd_magic, 0x524B5044
.if (region == 'P')
    .set SaveDataManager__sInstance, 0x809bd748
.elseif (region == 'E')
    .set SaveDataManager__sInstance, 0x809b8f88
.elseif (region == 'J')
    .set SaveDataManager__sInstance, 0x809bc7a8
.elseif (region == 'K')
    .set SaveDataManager__sInstance, 0x809abd88
.else
    .err
.endif
.macro pushStack
    stwu sp, -0x80 (sp)
    mflr r0
    stw r0, 0x84 (sp)
    stmw r3, 8 (sp)
.endm
.macro popStack
    lmw r3, 8 (sp)
    lwz r0, 0x84 (sp)
    mtlr r0
    addi sp, sp, 0x80
.endm
pushStack
lis r12, SaveDataManager__sInstance@ha
lwz r12, SaveDataManager__sInstance@l (r12)
lhz r11, 0x36 (r12)
lwz r12, 0x14 (r12) #r12 = rksys.dat pointer
#https://wiki.tockdom.com/wiki/Rksys.dat
lis r10, 0
ori r10, r10, 0x8CC0
lis r9, rkpd_magic@h
ori r9, r9, rkpd_magic@l
addi r7, r12, 8
li r8, 0
find_valid_save_index_loop:
lwz r6, 0 (r7)
add r7, r7, r10
cmpw r6, r9
beq find_valid_save_index_loop_out
addi r8, r8, 1
cmpwi r8, 4
bne find_valid_save_index_loop
li r8, 0
find_valid_save_index_loop_out:
mullw r10, r10, r8
addi r11, r11, 0xF4 #0xF4 = 8 + 0xEC
add r12, r12, r11
add r12, r12, r10
mr r10, r12
li r11, 0
li r5, 0
loop_0:
lhz r4, 0 (r10)
addi r10, r10, 2
cmpw r4, r11
blt not_update_r11
mr r11, r4
not_update_r11:
addi r5, r5, 1
cmpwi r5, 0x18
bne loop_0
li r5, 0
mr r10, r12
loop_1:
lhz r4, 0 (r10)
addi r10, r10, 2
cmpw r4, r11
beq loop_1_out
addi r5, r5, 1
b loop_1
loop_1_out:
cmpwi r5, 0x18
bne character_not_mii
li r5, 0
character_not_mii:
lis r6, character_id_save@ha
stb r5, character_id_save@l (r6)
bl character_weight_table
.long 0x01000202 #Mario, Baby Peach, Waluigi, Bowser
.long 0x00000001 #Baby Daisy, Dry Bones, Baby Mario, Luigi
.long 0x00020102 #Toad, Donkey Kong, Yoshi, Wario
.long 0x00000001 #Baby Luigi, Toadette, Koopa Troopa, Daisy
.long 0x01010102 #Peach, Birdo, Diddy Kong, King Boo
.long 0x01020202 #Bowser Jr., Dry Bowser, Funke Kong, Rosalina
character_weight_table:
mflr r6
add r6, r6, r5
lbz r6, 0 (r6)
li r9, 2
mullw r9, r9, r6
li r11, 0
li r5, 0
addi r12, r12, 0x32 #0x116 - 0xEC
#https://wiki.tockdom.com/wiki/Rksys.dat
add r12, r12, r9
mr r10, r12
loop_2:
lhz r4, 0 (r10)
addi r10, r10, 6
cmpw r4, r11
blt not_update_r11_1
mr r11, r4
not_update_r11_1:
addi r5, r5, 1
cmpwi r5, 12 #12 * 3 = 36
bne loop_2
li r5, 0
mr r10, r12
loop_3:
lhz r4, 0 (r10)
addi r10, r10, 6
cmpw r4, r11
beq loop_3_out
addi r5, r5, 1
b loop_3
loop_3_out:
mulli r5, r5, 3
add r5, r5, r6
stw r5, -4 (sp)
popStack
lwz r12, -0x84 (sp)
stw r12, 0x13C(r10)

Code:
# replace at 0x805e418c (PAL)
# replace at 0x805ce3b0 (NTSC-U)
# replace at 0x805e3a68 (NTSC-J)
# replace at 0x805d2328 (NTSC-K)
stw r12, 0x140 (r10)

updated on 2024/02/03:
Stupidly, I mistakenly thought the number of vehicles was 30.
Of course it is 36.

credits:
Melg and kHacker35000vr for SaveDataManager class
CT-Wiiki contributors for rksys.dat format
Reply


Messages In This Thread
Set User Favorite Combo as Defaul like CTGP [Bully, CLF78, Kazuki] - by Kazuki - 02-01-2024, 12:22 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)