Change Miis In Between Races -Online- [Vega]
#1
Change Miis In Between Races -Online- [Vega]

An upgrade compared to this code HERE.

Video - https://www.youtube.com/watch?v=1fSt4mZ3Rjk

This code will automatically change your Mii to a entirely different Mii after every Online Race/Battle. At the results every race/battle, the code selects the next Mii in your Mii Channel. When said next race/battle starts (or at Player listing preview for public rooms), everyone will see the new Mii. Once the last Mii in your Mii Channel has been used, the cycle repeats all over again starting at the first Mii.

Everyone will see the effects. Everything is automated. There are no button activators.

NOTE: If you have zero Miis, the code will regress into an infinite loop (game freeze). Code is pointless if you have only 1 Mii.
NOTE: Slight de-syncing will occur after a Friend Room GP Race/Battle. After the last Room GP Race/Battle, when everyone goes back to Idle Room, your Mii will update to the next Mii again on your screen, but everyone will see the prior Mii from the last Race/Battle. Not a big deal as once you do another online race/battle (regardless of room or public), everything will re-sync again.
NOTE: This code makes use of memory addresses 0x800007D0 thru 0x800007DC. Make sure no other codes you have equipped are using those addresses.
NOTE: This code does its first Mii Change to Mii Index 1 (second Mii of Mii Channel). Therefore, if you start a WW/Room with that Mii, no Mii changes will occur after the first race/battle.
NOTE: Weird bugs can occur if you do offline races/battles with this code equipped. I'm too lazy to add extra code in for Online Mode checking, Code is already too long as it is.

PAL
C25FB098 00000002
3D808000 80830068
906C07D0 00000000
C27F5FF4 00000003
90010024 3D808000
818C07D4 7D8903A6
4E800421 00000000
C285BFB8 00000003
90030044 3D808000
818C07D4 7D8903A6
4E800421 00000000
C2642F90 00000009
9421FFD0 3D808000
896C07DC 814D9698
814A0010 396B0001
280B0064 41A00008
39600000 996C07DC
1D2B004A 7D0A4A14
80080004 2C000000
41A2FFDC 39080002
910C07D8 00000000
C21AA9D4 0000001C
480000CD 9421FFE0
7C0802A6 BF810008
90010024 7C7E1B78
7C9D2378 7CBC2B78
3D80809C 818C2108
2C0C0000 41820080
880C0000 2C000000
41820074 3D608000
806B07D0 888B07DC
80CB07D8 98830008
38000025 3BEC0010
38EC000E 7C0903A6
A5060002 B5070002
4200FFF8 38000000
980300A4 3D808052
38A0FFFF 618C6020
7D8903A6 4E800421
38000000 7FE3FB78
3D80800C B01F004A
618C78D0 3880004C
7D8903A6 4E800421
B07F004A 7FC3F378
7FA4EB78 7F85E378
80010024 BB810008
7C0803A6 38210020
4E800020 7D8802A6
3C808000 918407D4
60000000 00000000

NTSC-U
C25DA7B4 00000002
3D808000 80830068
906C07D0 00000000
C27EB9CC 00000003
90010024 3D808000
818C07D4 7D8903A6
4E800421 00000000
C283A528 00000003
90030044 3D808000
818C07D4 7D8903A6
4E800421 00000000
C2611B70 00000009
9421FFD0 3D808000
896C07DC 814D9698
814A0010 396B0001
280B0064 41A00008
39600000 996C07DC
1D2B004A 7D0A4A14
80080004 2C000000
41A2FFDC 39080002
910C07D8 00000000
C21AA934 0000001C
480000CD 9421FFE0
7C0802A6 BF810008
90010024 7C7E1B78
7C9D2378 7CBC2B78
3D80809C 818CD958
2C0C0000 41820080
880C0000 2C000000
41820074 3D608000
806B07D0 888B07DC
80CB07D8 98830008
38000025 3BEC0010
38EC000E 7C0903A6
A5060002 B5070002
4200FFF8 38000000
980300A4 3D808052
38A0FFFF 618C1BAC
7D8903A6 4E800421
38000000 7FE3FB78
3D80800C B01F004A
618C7830 3880004C
7D8903A6 4E800421
B07F004A 7FC3F378
7FA4EB78 7F85E378
80010024 BB810008
7C0803A6 38210020
4E800020 7D8802A6
3C808000 918407D4
60000000 00000000

NTSC-J
C25FA974 00000002
3D808000 80830068
906C07D0 00000000
C27F5660 00000003
90010024 3D808000
818C07D4 7D8903A6
4E800421 00000000
C285B624 00000003
90030044 3D808000
818C07D4 7D8903A6
4E800421 00000000
C26425FC 00000009
9421FFD0 3D808000
896C07DC 814D9698
814A0010 396B0001
280B0064 41A00008
39600000 996C07DC
1D2B004A 7D0A4A14
80080004 2C000000
41A2FFDC 39080002
910C07D8 00000000
C21AA8F4 0000001C
480000CD 9421FFE0
7C0802A6 BF810008
90010024 7C7E1B78
7C9D2378 7CBC2B78
3D80809C 818C1168
2C0C0000 41820080
880C0000 2C000000
41820074 3D608000
806B07D0 888B07DC
80CB07D8 98830008
38000025 3BEC0010
38EC000E 7C0903A6
A5060002 B5070002
4200FFF8 38000000
980300A4 3D808052
38A0FFFF 618C59A0
7D8903A6 4E800421
38000000 7FE3FB78
3D80800C B01F004A
618C77F0 3880004C
7D8903A6 4E800421
B07F004A 7FC3F378
7FA4EB78 7F85E378
80010024 BB810008
7C0803A6 38210020
4E800020 7D8802A6
3C808000 918407D4
60000000 00000000

NTSC-K
C25E94B8 00000002
3D808000 80830068
906C07D0 00000000
C27E43B4 00000003
90010024 3D808000
818C07D4 7D8903A6
4E800421 00000000
C284A378 00000003
90030044 3D808000
818C07D4 7D8903A6
4E800421 00000000
C26312A8 00000009
9421FFD0 3D808000
896C07DC 814D96B8
814A0010 396B0001
280B0064 41A00008
39600000 996C07DC
1D2B004A 7D0A4A14
80080004 2C000000
41A2FFDC 39080002
910C07D8 00000000
C21AAD30 0000001C
480000CD 9421FFE0
7C0802A6 BF810008
90010024 7C7E1B78
7C9D2378 7CBC2B78
3D80809B 818C0748
2C0C0000 41820080
880C0000 2C000000
41820074 3D608000
806B07D0 888B07DC
80CB07D8 98830008
38000025 3BEC0010
38EC000E 7C0903A6
A5060002 B5070002
4200FFF8 38000000
980300A4 3D808051
38A0FFFF 618C4044
7D8903A6 4E800421
38000000 7FE3FB78
3D80800C B01F004A
618C7930 3880004C
7D8903A6 4E800421
B07F004A 7FC3F378
7FA4EB78 7F85E378
80010024 BB810008
7C0803A6 38210020
4E800020 7D8802A6
3C808000 918407D4
60000000 00000000



Code creator: Vega
Code credits: Seeky (USER Static Ptr), Kevin & RiiDefi (used funcs found by them for 2nd, 3rd, and 4th ASM hooks)



First ASM:
Code:
#Hooked at a spot in the MiiGroup_copy function where the first parts of the Mii Data are being transferred across memory
#Store Online Self Mii Struct Ptr Thinyg to EVA 0x7D0
#PAL    805FB098
#NTSC-U 805DA7B4
#NTSC-J 805FA974
#NTSC-K 805E94B8
lis r12, 0x8000
lwz r4, 0x0068 (r3) #Original Instruction
stw r3, 0x7D0 (r12)

Second ASM:
Code:
#Hooked to prologue of mkw_result_position (UI)
#Hook occurs at end of any online VS-type race
#Call custom ChangeMiiOnline func that resides in the 5th C2/ASM code
#PAL    807F5FF4
#NTSC-U 807EB9CC
#NTSC-J 807F5660
#NTSC-K 807E43B4
stw r0, 0x0024 (sp) #OG Instruction
lis r12, 0x8000
lwz r12, 0x7D4 (r12)
mtctr r12
bctrl

Third ASM:
Code:
#Hooked immediately after prologue of UI::ScorePage::onActivate((void))
#Hook occurs at end of any online Battle/Coin-Runners and Team VS
#Call custom ChangeMiiOnline func that resides in the 5th C2/ASM code
#PAL    8085BFB8
#NTSC-U 8083A528
#NTSC-J 8085B624
#NTSC-K 8084A378
stw r0, 0x0044 (r3) #OG Instruction
lis r12, 0x8000
lwz r12, 0x7D4 (r12)
mtctr r12
bctrl

Fourth ASM:
Code:
#Hooked to prologue of screen_courseVotes_construct
#Hook occurs very moment AFTER the Getting Ready to Race screen (once in between every race/battle)
#Summary: Load the Index that is used for searching Mii Database. Grab Mii Database Root ptr. Increment Index to next valid Mii. Use new index to navigate within the DB to get the new Mii's exact ptr. Store that ptr-2 to EVA for C0 custom func to use.
#PAL    80642F90
#NTSC-U 80611B70
#NTSC-J 806425FC
#NTSC-K 806312A8

#Region Assembling Option
.set region, '' #Fill in E, P, J, or K within the quotes for your region when Compiling! Lowercase letters can also be used.

#Directives
.if     (region == 'P' || region == 'p') #PAL
    .macro load_unk_ptr register
        lwz \register, -0x6968 (r13) #func 0x800bc3e0
    .endm
.elseif (region == 'E' || region == 'e') #NTSC-U
    .macro load_unk_ptr register
        lwz \register, -0x6968 (r13) #func 0x800bc340
    .endm
.elseif (region == 'J' || region == 'j') #NTSC-J
    .macro load_unk_ptr register
        lwz \register, -0x6968 (r13) #func 0x800bc300
    .endm
.elseif (region == 'K' || region == 'k') #NTSC-K
    .macro load_unk_ptr register
        lwz \register, -0x6948 (r13) #func 0x800bc440
    .endm
.else #Invalid Region
    .err #Region match not detected. Tell the Assembler to halt and throw an error.
.endif

#Original Instruction
stwu sp, -0x0030 (sp)

#Grab Mii Database Index
lis r12, 0x8000 #Original Instruction
lbz r11, 0x7DC (r12)

#Get Mii's ptr-4 within Mii Database (RNOD header not factored in)
load_unk_ptr r10
lwz r10, 0x10 (r10)

#Increment/Reset DB Byte
increment_db_byte:
addi r11, r11, 1
cmplwi r11, 100 #Highest index is 99. 0 thru 99 is 100 Miis which is the Max
blt+ 0x8
li r11, 0
stb r11, 0x7DC (r12) #Update DB index in EVA

#Use Byte value to calc Mii ptr-4 (not factoring in RNOD header)
mulli r9, r11, 74
add r8, r10, r9

#Make sure a Mii exists
lwz r0, 0x4 (r8)
cmpwi r0, 0 #Valid Mii will always have some non-zero data for its first 4 bytes
beq- increment_db_byte #Redo for next possible mii entry

#Add 2 to Mii-4 ptr and store to EVA
addi r8, r8, 2
stw r8, 0x7D8 (r12)

Fifth ASM:
Code:
#Hooked at OSSleepThread right after its child Func call of OSDisableInterrupts
#PAL    801AA9D4
#NTSC-U 801AA934
#NTSC-J 801AA8F4
#NTSC-K 801AAD30

#Region Assembling Option
.set region, '' #Fill in E, P, J, or K within the quotes for your region when Compiling! Lowercase letters can also be used.

#EVA Notes
#800007D0 (word) is Online Self Mii Struct Ptr
#800007D4 (word) Custom Func ptr
#800007D8 (word) Mii Ptr -2 inside Mii DB
#800007DC (byte) DB index for custom func to use
#Register Notes
#r3 unsafe, LR unsafe

#Directives
.if     (region == 'P' || region == 'p') #PAL
    .set USER_Static_ptr, 0x809c2108
    .set CRC16, 0x800C78D0
    .macro load_unk_ptr register
        lwz \register, -0x6968 (got) #func 0x800bc3e0
    .endm
    .set ChangeRawMiiToNetLite_Func, 0x80526020
.elseif (region == 'E' || region == 'e') #NTSC-U
    .set USER_Static_ptr, 0x809bd958
    .set CRC16, 0x800C7830
    .macro load_unk_ptr register
        lwz \register, -0x6968 (got) #func 0x800bc340
    .endm
    .set ChangeRawMiiToNetLite_Func, 0x80521BAC
.elseif (region == 'J' || region == 'j') #NTSC-J
    .set USER_Static_ptr, 0x809c1168
    .set CRC16, 0x800C77F0
    .macro load_unk_ptr register
        lwz \register, -0x6968 (got) #func 0x800bc300
    .endm
    .set ChangeRawMiiToNetLite_Func, 0x805259A0
.elseif (region == 'K' || region == 'k') #NTSC-K
    .set USER_Static_ptr, 0x809b0748
    .set CRC16, 0x800C7930
    .macro load_unk_ptr register
        lwz \register, -0x6948 (got) #func 0x800bc440
    .endm
    .set ChangeRawMiiToNetLite_Func, 0x80514044
.else #Invalid Region
    .err #Region match not detected. Tell the Assembler to halt and throw an error.
.endif

#Make Space in C2 code for custom func
bl custom_func

#################
#Prologue
stwu sp, -0x0020 (sp)
mflr r0
stmw r28, 0x8 (sp)
stw r0, 0x0024 (sp)

#Save 2nd and 3rd ASM Hook args
mr r30, r3
mr r29, r4
mr r28, r5

#Load USER Packet Static Ptr
lis r12, USER_Static_ptr@ha
lwz r12, USER_Static_ptr@l (r12)

#Check if we have a ptr (on wifi)
cmpwi r12, 0
beq- end

#Check if a room is active (very first byte of packet will be non-null)
lbz r0, 0 (r12)
cmpwi r0, 0
beq- end

#Grab Online Self Mii Struct Ptr Thingy
lis r11, 0x8000
lwz r3, 0x7D0 (r11)

#Grab EVA's Mii DB Index and Specific Mii Ptr -2
lbz r4, 0x7DC (r11)
lwz r6, 0x7D8 (r11)

#Place new Mii DB index in Self Mii Struct thingy, Probably not needed, but just in case....
stb r4, 0x8 (r3)

#Transfer Mii Data from DB to USER Packet
li r0, 37 #74 bytes
addi r31, r12, 0x10 #Need exact ptr for later
addi r7, r12, 0xE #-2 of mii data in your USER packet
mtctr r0
loop:
lhzu r8, 0x2 (r6)
sthu r8, 0x2 (r7)
bdnz+ loop

#Now we need to update our Online Self Mii char/icon packet thingy
#Theres a byte held in the mii struct that tells the mii-related funcs that its already processed, clear this byte
li r0, 0
stb r0, 0x00A4 (r3)

#Call ChangeMiiRawToNetLite
#r3 ptr to Online Self Mii Struct
#r4 index of DB
#r5 is -1 always
#r3 and r4 arg already set
#Set r5 and call the func
lis r12, ChangeRawMiiToNetLite_Func@h
li r5, -1
ori r12, r12, ChangeRawMiiToNetLite_Func@l
mtctr r12
bctrl #No return values to check

#Generate CRC16 for new Mii. Game generates with the 76 byte Mii Entry but with a null checksum present
li r0, 0
mr r3, r31
lis r12, CRC16@h
sth r0, 0x4A (r31)
ori r12, r12, CRC16@l
li r4, 76 #0x4C
mtctr r12
bctrl

#Write new checksum
sth r3, 0x4A (r31)

#Restore 2nd and 3rd ASM Hook args
end:
mr r3, r30
mr r4, r29
mr r5, r28

#Epilogue
lwz r0, 0x0024 (sp)
lmw r28, 0x8 (sp)
mtlr r0
addi sp, sp, 0x0020
blr
#################

custom_func:
mflr r12
lis r4, 0x8000 #NOTE NOTE NOTE YES THIS IS THE ORIGINAL INSTRUCTION
stw r12, 0x7D4 (r4)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)