10-26-2020, 05:34 PM
(This post was last modified: 03-02-2021, 12:57 PM by CLF78.
Edit Reason: Updated code
)
This code will let you load a random track from a specific folder, based on the picked track. Usage notes below.
NTSC-U
0453B2BC 48000050
060002B0 00000040
01010101 01010101
01010101 01010101
01010101 01010101
01010101 01010101
01010101 01010101
01010000 52616365
2F436F75 7273652F
25732F25 64000000
C253B32C 0000000D
7CCB3378 7CAA2B78
540CF0BE 2C0C0029
41810050 3C608000
606302B0 7C8360AE
38840001 38600000
3CE0800F 60E72E40
7CE903A6 4E800421
2C030000 40A20010
7D455378 7D665B78
48000014 3CA08000
60A502DC 7D665B78
7C671B78 38610008
38800080 00000000
C253C680 0000000D
7CCB3378 7CAA2B78
540CF0BE 2C0C0029
41810050 3C608000
606302B0 7C8360AE
38840001 38600000
3CE0800F 60E72E40
7CE903A6 4E800421
2C030000 40A20010
7D455378 7D665B78
48000014 3CA08000
60A502DC 7D665B78
7C671B78 38610008
38800080 00000000
PAL
045407F8 48000050
060002B0 00000040
01010101 01010101
01010101 01010101
01010101 01010101
01010101 01010101
01010101 01010101
01010000 52616365
2F436F75 7273652F
25732F25 64000000
C2540868 0000000D
7CCB3378 7CAA2B78
540CF0BE 2C0C0029
41810050 3C608000
606302B0 7C8360AE
38840001 38600000
3CE0800F 60E72EE0
7CE903A6 4E800421
2C030000 40A20010
7D455378 7D665B78
48000014 3CA08000
60A502DC 7D665B78
7C671B78 38610008
38800080 00000000
C2541BBC 0000000D
7CCB3378 7CAA2B78
540CF0BE 2C0C0029
41810050 3C608000
606302B0 7C8360AE
38840001 38600000
3CE0800F 60E72EE0
7CE903A6 4E800421
2C030000 40A20010
7D455378 7D665B78
48000014 3CA08000
60A502DC 7D665B78
7C671B78 38610008
38800080 00000000
NTSC-J
04540178 48000050
060002B0 00000040
01010101 01010101
01010101 01010101
01010101 01010101
01010101 01010101
01010101 01010101
01010000 52616365
2F436F75 7273652F
25732F25 64000000
C25401E8 0000000D
7CCB3378 7CAA2B78
540CF0BE 2C0C0029
41810050 3C608000
606302B0 7C8360AE
38840001 38600000
3CE0800F 60E72E00
7CE903A6 4E800421
2C030000 40A20010
7D455378 7D665B78
48000014 3CA08000
60A502DC 7D665B78
7C671B78 38610008
38800080 00000000
C254153C 0000000D
7CCB3378 7CAA2B78
540CF0BE 2C0C0029
41810050 3C608000
606302B0 7C8360AE
38840001 38600000
3CE0800F 60E72E00
7CE903A6 4E800421
2C030000 40A20010
7D455378 7D665B78
48000014 3CA08000
60A502DC 7D665B78
7C671B78 38610008
38800080 00000000
NTSC-K
0452E850 48000050
060002B0 00000040
01010101 01010101
01010101 01010101
01010101 01010101
01010101 01010101
01010101 01010101
01010000 52616365
2F436F75 7273652F
25732F25 64000000
C252E8C0 0000000D
7CCB3378 7CAA2B78
540CF0BE 2C0C0029
41810050 3C608000
606302B0 7C8360AE
38840001 38600000
3CE0800F 60E72F58
7CE903A6 4E800421
2C030000 40A20010
7D455378 7D665B78
48000014 3CA08000
60A502DC 7D665B78
7C671B78 38610008
38800080 00000000
C252FC14 0000000D
7CCB3378 7CAA2B78
540CF0BE 2C0C0029
41810050 3C608000
606302B0 7C8360AE
38840001 38600000
3CE0800F 60E72F58
7CE903A6 4E800421
2C030000 40A20010
7D455378 7D665B78
48000014 3CA08000
60A502DC 7D665B78
7C671B78 38610008
38800080 00000000
Usage Notes:
Source:
Code created by: CLF78
NTSC-U
0453B2BC 48000050
060002B0 00000040
01010101 01010101
01010101 01010101
01010101 01010101
01010101 01010101
01010101 01010101
01010000 52616365
2F436F75 7273652F
25732F25 64000000
C253B32C 0000000D
7CCB3378 7CAA2B78
540CF0BE 2C0C0029
41810050 3C608000
606302B0 7C8360AE
38840001 38600000
3CE0800F 60E72E40
7CE903A6 4E800421
2C030000 40A20010
7D455378 7D665B78
48000014 3CA08000
60A502DC 7D665B78
7C671B78 38610008
38800080 00000000
C253C680 0000000D
7CCB3378 7CAA2B78
540CF0BE 2C0C0029
41810050 3C608000
606302B0 7C8360AE
38840001 38600000
3CE0800F 60E72E40
7CE903A6 4E800421
2C030000 40A20010
7D455378 7D665B78
48000014 3CA08000
60A502DC 7D665B78
7C671B78 38610008
38800080 00000000
PAL
045407F8 48000050
060002B0 00000040
01010101 01010101
01010101 01010101
01010101 01010101
01010101 01010101
01010101 01010101
01010000 52616365
2F436F75 7273652F
25732F25 64000000
C2540868 0000000D
7CCB3378 7CAA2B78
540CF0BE 2C0C0029
41810050 3C608000
606302B0 7C8360AE
38840001 38600000
3CE0800F 60E72EE0
7CE903A6 4E800421
2C030000 40A20010
7D455378 7D665B78
48000014 3CA08000
60A502DC 7D665B78
7C671B78 38610008
38800080 00000000
C2541BBC 0000000D
7CCB3378 7CAA2B78
540CF0BE 2C0C0029
41810050 3C608000
606302B0 7C8360AE
38840001 38600000
3CE0800F 60E72EE0
7CE903A6 4E800421
2C030000 40A20010
7D455378 7D665B78
48000014 3CA08000
60A502DC 7D665B78
7C671B78 38610008
38800080 00000000
NTSC-J
04540178 48000050
060002B0 00000040
01010101 01010101
01010101 01010101
01010101 01010101
01010101 01010101
01010101 01010101
01010000 52616365
2F436F75 7273652F
25732F25 64000000
C25401E8 0000000D
7CCB3378 7CAA2B78
540CF0BE 2C0C0029
41810050 3C608000
606302B0 7C8360AE
38840001 38600000
3CE0800F 60E72E00
7CE903A6 4E800421
2C030000 40A20010
7D455378 7D665B78
48000014 3CA08000
60A502DC 7D665B78
7C671B78 38610008
38800080 00000000
C254153C 0000000D
7CCB3378 7CAA2B78
540CF0BE 2C0C0029
41810050 3C608000
606302B0 7C8360AE
38840001 38600000
3CE0800F 60E72E00
7CE903A6 4E800421
2C030000 40A20010
7D455378 7D665B78
48000014 3CA08000
60A502DC 7D665B78
7C671B78 38610008
38800080 00000000
NTSC-K
0452E850 48000050
060002B0 00000040
01010101 01010101
01010101 01010101
01010101 01010101
01010101 01010101
01010101 01010101
01010000 52616365
2F436F75 7273652F
25732F25 64000000
C252E8C0 0000000D
7CCB3378 7CAA2B78
540CF0BE 2C0C0029
41810050 3C608000
606302B0 7C8360AE
38840001 38600000
3CE0800F 60E72F58
7CE903A6 4E800421
2C030000 40A20010
7D455378 7D665B78
48000014 3CA08000
60A502DC 7D665B78
7C671B78 38610008
38800080 00000000
C252FC14 0000000D
7CCB3378 7CAA2B78
540CF0BE 2C0C0029
41810050 3C608000
606302B0 7C8360AE
38840001 38600000
3CE0800F 60E72F58
7CE903A6 4E800421
2C030000 40A20010
7D455378 7D665B78
48000014 3CA08000
60A502DC 7D665B78
7C671B78 38610008
38800080 00000000
Usage Notes:
- Let's pretend you want to have 3 random tracks over Mario Circuit.
- Find the correct byte in the first 06 code (see source below) and change it to the amount of tracks (in this case, 3)
- Note down which entry in the byte list Mario Circuit is (in this case, it's 1)
- Make a new folder named with the track's name in Race/Course
- In that folder, place the tracks and rename them to 1.szs, 2.szs and so on (the game will pick a random number everytime)
- The game can also pick value 0, which will load the original track
- The end result will be a folder in Race/Course named castle_course, which will contain 1.szs, 2.szs and 3.szs
- Enjoy!
Source:
Code:
# Set mode here
.set mode, 0
# Mode 1, Multiplayer File Skip
.if (mode == 1)
# @8053B2BC NTSC-U, 805407F8 PAL, 80540178 NTSC-J, 8052E850 NTSC-K
b 80
# Mode 2, Track Amounts and Track String
.elseif (mode == 2)
# @800002B0
.byte 1, 1, 1, 1 # Mario Circuit, Moo Moo Meadows, Mushroom Gorge, Grumble Volcano
.byte 1, 1, 1, 1 # Toad's Factory, Coconut Mall, DK Summit, Wario's Gold Mine
.byte 1, 1, 1, 1 # Luigi Circuit, Daisy Circuit, Moonview Highway, Maple Treeway
.byte 1, 1, 1, 1 # Bowser Castle, Rainbow Road, Dry Dry Ruins, Koopa Cape
.byte 1, 1, 1, 1 # GCN Peach Beach, GCN Mario Circuit, GCN Waluigi Stadium, GCN DK Mountain
.byte 1, 1, 1, 1 # DS Yoshi Falls, DS Desert Hills, DS Peach Gardens, DS Delfino Square
.byte 1, 1, 1, 1 # SNES Mario Circuit 3, SNES Ghost Valley 2, N64 Mario Raceway, N64 Sherbet Land
.byte 1, 1, 1, 1 # N64 Bowser's Castle, N64 DK's Jungle Parkway, GBA Bowser Castle 3, GBA Shy Guy Beach
.byte 1, 1, 1, 1, 1 # Delfino Pier, Block Plaza, Chain Chomp Wheel, Funky Stadium, Thwomp Desert
.byte 1, 1, 1, 1, 1 # GCN Cookie Land, DS Twilight House, SNES Battle Course 4, GBA Battle Course 3, N64 Skyscraper
.align 2
# Do NOT touch this string
.string "Race/Course/%s/%d"
.align 2
# Mode 3, ASM
.elseif (mode == 3)
# Injects
# @8053B32C NTSC-U, 80540868 PAL, 805401E8 NTSC-J, 8052E8C0 NTSC-K
# @8053C680 NTSC-U, 80541BBC PAL, 8054153C NTSC-J, 8052FC14 NTSC-K
# Addresses
.set ByteAmounts, 0x800002B0
.set CharString, 0x800002DC
.set region, ''
.if (region == 'P' || region == 'p')
.set UtilRandom, 0x800F2EE0
.elseif (region == 'U' || region == 'u' || region == 'E' || region == 'e')
.set UtilRandom, 0x800F2E40
.elseif (region == 'J' || region == 'j')
.set UtilRandom, 0x800F2E00
.elseif (region == 'K' || region == 'k')
.set UtilRandom, 0x800F2F58
.else
.err
.endif
# Backup some registers for later use
mr r11, r6
mr r10, r5
# Divide slot index by 4
srwi r12, r0, 2
# Check if it's a track/battle arena
cmpwi r12, 41
bgt end
# Setup arguments for UtilRandom
lis r3, ByteAmounts@h
ori r3, r3, ByteAmounts@l
lbzx r4, r3, r12
addi r4, r4, 1
li r3, 0
# Call UtilRandom
lis r7, UtilRandom@h
ori r7, r7, UtilRandom@l
mtctr r7
bctrl
# Check if result is 0
cmpwi r3, 0
bne+ pickRandomTrack
# If so use the original arguments
mr r5, r10
mr r6, r11
b finishSetup
# Use custom arguments otherwise
pickRandomTrack:
lis r5, CharString@h
ori r5, r5, CharString@l
mr r6, r11
mr r7, r3
# Common argument
finishSetup:
addi r3, r1, 0x8
# Original instruction
end:
li r4, 0x80
.else
.err
.endif
Code created by: CLF78