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

For every online race, you will be given a random character+vehicle combo. Code does NOT work in Battles!

This SHOULD be okay to use on Wiimmfi WW's since the combo you get is random and there are no advantages due to using this code. However, ask a Wiimmfi Staff member beforehand to be sure.

Final NOTE: This code use of memory addresses 0x800004C0 & 0x800004C1. Make sure no other codes you have equipped are using those addresses.

NTSC-U
C0000000 00000007
3D808000 896C04C0
396B0001 280B0018
41A00008 39600000
996C04C0 894C04C1
394A0001 280A000C
41A00008 39400000
994C04C1 4E800020
C2612EF4 0000000E
8063D930 48000041
00030609 0C0F1215
181B1E21 0104070A
0D101316 191C1F22
0205080B 0E111417
1A1D2023 0C001818
0000000C 00180C18
0000000C 0C0C0C18
0C181818 7D8802A6
3D608000 894B04C0
896B04C1 392C0024
7D0A48AE 7D8C4214
7D0C58AE 9943001C
9903001D 00000000

PAL
C0000000 00000007
3D808000 896C04C0
396B0001 280B0018
41A00008 39600000
996C04C0 894C04C1
394A0001 280A000C
41A00008 39400000
994C04C1 4E800020
C2644314 0000000E
80632100 48000041
00030609 0C0F1215
181B1E21 0104070A
0D101316 191C1F22
0205080B 0E111417
1A1D2023 0C001818
0000000C 00180C18
0000000C 0C0C0C18
0C181818 7D8802A6
3D608000 894B04C0
896B04C1 392C0024
7D0A48AE 7D8C4214
7D0C58AE 9943001C
9903001D 00000000

NTSC-J
C0000000 00000007
3D808000 896C04C0
396B0001 280B0018
41A00008 39600000
996C04C0 894C04C1
394A0001 280A000C
41A00008 39400000
994C04C1 4E800020
C2643980 0000000E
80631160 48000041
00030609 0C0F1215
181B1E21 0104070A
0D101316 191C1F22
0205080B 0E111417
1A1D2023 0C001818
0000000C 00180C18
0000000C 0C0C0C18
0C181818 7D8802A6
3D608000 894B04C0
896B04C1 392C0024
7D0A48AE 7D8C4214
7D0C58AE 9943001C
9903001D 00000000

NTSC-K
C0000000 00000007
3D808000 896C04C0
396B0001 280B0018
41A00008 39600000
996C04C0 894C04C1
394A0001 280A000C
41A00008 39400000
994C04C1 4E800020
C263262C 0000000E
80630740 48000041
00030609 0C0F1215
181B1E21 0104070A
0D101316 191C1F22
0205080B 0E111417
1A1D2023 0C001818
0000000C 00180C18
0000000C 0C0C0C18
0C181818 7D8802A6
3D608000 894B04C0
896B04C1 392C0024
7D0A48AE 7D8C4214
7D0C58AE 9943001C
9903001D 00000000

Code creator: Vega

C0 Source:
Code:
#C0

#cycle random Value 1 (character)
lis r12, 0x8000
lbz r11, 0x4C0 (r12)
addi r11, r11, 1
cmplwi r11, 0x18
blt+ 0x8
li r11, 0
stb r11, 0x4C0 (r12)

#Cycle random Value 2 (vehicle)
lbz r10, 0x4C1 (r12)
addi r10, r10, 1
cmplwi r10, 12 #0 thru 11 is 12 numbers
blt+ 0x8
li r10, 0
stb r10, 0x4C1 (r12)

#Done
#blr

C2 Source:
Code:
#C2 Hook Addresses
#NTSC-U 80612EF4
#PAL    80644314
#NTSC-J 80643980
#NTSC-K 8063262C

#Region Set
.set region, '' #Use e,p,j, or k

#Register Notes
#LR safe
#r3 is SELECT Packet Ptr

#Hook Address Notes
#Code hooked at first parent that calls SELECT_Get_Winning_Track

#SELECT Packet Notes
#0x1C Your Character
#0x1D Your Vehicle
#0x1E Your Track Pick
#0x1F Your Star Ranking
#0x24 Your Guests Char
#0x25 Your Guests Vechicle
#0x26 Your Guests Track Pick (is yours ofc)
#0x27 Reserved/null byte
#0x28 Select ID word (unique)
#0x2C Battle Type
#0x2E Team Bits
#0x3C Selected Track
#0x3D Selection/Lottery Phase
#0x3E Who Won Track Pick
#0x3F CC

#Original Instruction; grab SELECT ptr
.if     (region == 'E' || region == 'e') #NTSC-U
        lwz r3, -0x26D0 (r3)
.elseif (region == 'P' || region == 'p') #PAL
        lwz r3, 0x2100 (r3)
.elseif (region == 'J' || region == 'j') #NTSC-J
        lwz r3, 0x1160 (r3)
.elseif (region == 'K' || region == 'k') #NTSC-K
        lwz r3, 0x0740 (r3)
.else #Invalid Region
        .err #Region match not detected. Tell the Assembler to halt and throw an error.
.endif

#Create Lookup Table
bl table #Index 0; Values for small vehicles
small_table:
.byte 0
.byte 3
.byte 6
.byte 9
.byte 0xC
.byte 0xF
.byte 0x12
.byte 0x15
.byte 0x18
.byte 0x1B
.byte 0x1E
.byte 0x21
medium_table: #Index 12; Values for medium vehicles
.byte 1
.byte 4
.byte 7
.byte 0xA
.byte 0xD
.byte 0x10
.byte 0x13
.byte 0x16
.byte 0x19
.byte 0x1C
.byte 0x1F
.byte 0x22
large_table: #Index 24; Values for large vehicles
.byte 2
.byte 5
.byte 8
.byte 0xB
.byte 0xE
.byte 0x11
.byte 0x14
.byte 0x17
.byte 0x1A
.byte 0x1D
.byte 0x20
.byte 0x23
table_index_values:
.byte 12 #Mario
.byte 0 #Baby Peach
.byte 24 #Waluigi
.byte 24 #Bowser
.byte 0 #Baby Daisy
.byte 0 #Dry Bones
.byte 0 #Baby Mario
.byte 12 #Luigi
.byte 0 #Toad
.byte 24 #Donkey Kong
.byte 12 #Yoshi
.byte 24 #Wario
.byte 0 #Baby Luigi
.byte 0 #Toadette
.byte 0 #koopa
.byte 12 #Daisy
.byte 12 #Peach
.byte 12 #Birdo
.byte 12 #Diddy Kong
.byte 24 #King Boo
.byte 12 #Bowser Jr
.byte 24 #Dry Bowser
.byte 24 #Funky Kong
.byte 24 #Rosalina
.align 2
table:
mflr r12

#Grab Random Value 1 (char) and 2 (veh) from EVA
lis r11, 0x8000
lbz r10, 0x4C0 (r11)
lbz r11, 0x4C1 (r11)

#Set a ptr to table_index_values, and then based on random value 1, grab characters 0/12/24 value
addi r9, r12, 36
lbzx r8, r10, r9

#Now set adjust the Root Table ptr to within the table based on r8's value (r8 will be 0, 12, or 24)
add r12, r12, r8

#Grab vehicle using new r12 ptr and random value 2
lbzx r8, r12, r11

#Write Char+Vehicle to SELECT packet
stb r10, 0x1C (r3)
stb r8, 0x1D (r3)
Reply
#2
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.
Reply
#3
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...
Reply
#4
Im getting the delicious EEEEEEEEEEEEEEEEEEEEEEE Sound when I pick a track (console only). Is it because of LE-CODE?
Reply
#5
Probably.
Reply
#6
Welp. Using a different Code Handler, same result. So im guessing its a Code/LE-CODE issue?
Reply
#7
Finally remembered to revisit and fix this code. Viola
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)