Track Music Expander [CLF78]
#1
This code lets you apply different music for each track (including Nintendo tracks) on CT-CODE and LE-CODE based distributions. Simply place two BRSTMs named SLOT.brstm and SLOT_F.brstm (where SLOT is the track slot in hex) in the "strm" folder. If the file cannot be found, the game will fall back to the original music file(s).

NTSC-U - CT-CODE
C209E01C 00000015
8861015C 2C03006E
41A20014 2C030053
41A2000C 2C030072
40820088 3CC08000
80C60DF4 4800001D
25737374 726D2F25
30337825 732E6272
73746D00 5F460000
7C8802A6 38BD0008
38E40014 391C0150
7D0808AE 2C080066
41820010 2C080046
41820008 38E70002
38610024 3D808001
618C0ECC 7D8903A6
4E800421 38610024
3D808015 618CDEAC
7D8903A6 4E800421
2C03FFFF 4182000C
3B410024 48000008
3B410150 00000000
C270A5F0 00000003
2C000036 40A20008
38800094 38A00000
60000000 00000000

NTSC-U - LE-CODE
C209E01C 00000018
8861015C 2C03006E
41A20014 2C030053
41A2000C 2C030072
408200A0 3C608054
6063DDE8 80830000
548401BA 7C632214
7C6903A6 4E800421
7C862378 4800001D
25737374 726D2F25
30337825 732E6272
73746D00 5F460000
7C8802A6 38BD0008
38E40014 391C0150
7D0808AE 2C080066
41820010 2C080046
41820008 38E70002
38610024 3D808001
618C0ECC 7D8903A6
4E800421 38610024
3D808015 618CDEAC
7D8903A6 4E800421
2C03FFFF 4182000C
3B410024 48000008
3B410150 00000000
C270A5F0 00000003
2C000036 40A20008
38800094 38A00000
60000000 00000000

PAL - CT-CODE
C209E0BC 00000015
8861015C 2C03006E
41A20014 2C030053
41A2000C 2C030072
40820088 3CC08000
80C60DF4 4800001D
25737374 726D2F25
30337825 732E6272
73746D00 5F460000
7C8802A6 38BD0008
38E40014 391C0150
7D0808AE 2C080066
41820010 2C080046
41820008 38E70002
38610024 3D808001
618C1A2C 7D8903A6
4E800421 38610024
3D808015 618CDF4C
7D8903A6 4E800421
2C03FFFF 4182000C
3B410024 48000008
3B410150 00000000
C2712094 00000003
2C000036 40A20008
38800094 38A00000
60000000 00000000

PAL - LE-CODE
C209E0BC 00000018
8861015C 2C03006E
41A20014 2C030053
41A2000C 2C030072
408200A0 3C608055
60633E08 80830000
548401BA 7C632214
7C6903A6 4E800421
7C862378 4800001D
25737374 726D2F25
30337825 732E6272
73746D00 5F460000
7C8802A6 38BD0008
38E40014 391C0150
7D0808AE 2C080066
41820010 2C080046
41820008 38E70002
38610024 3D808001
618C1A2C 7D8903A6
4E800421 38610024
3D808015 618CDF4C
7D8903A6 4E800421
2C03FFFF 4182000C
3B410024 48000008
3B410150 00000000
C2712094 00000003
2C000036 40A20008
38800094 38A00000
60000000 00000000

NTSC-J - CT-CODE
C209DFDC 00000015
8861015C 2C03006E
41A20014 2C030053
41A2000C 2C030072
40820088 3CC08000
80C60DF4 4800001D
25737374 726D2F25
30337825 732E6272
73746D00 5F460000
7C8802A6 38BD0008
38E40014 391C0150
7D0808AE 2C080066
41820010 2C080046
41820008 38E70002
38610024 3D808001
618C1950 7D8903A6
4E800421 38610024
3D808015 618CDE6C
7D8903A6 4E800421
2C03FFFF 4182000C
3B410024 48000008
3B410150 00000000
C2711700 00000003
2C000036 40A20008
38800094 38A00000
60000000 00000000

NTSC-J - LE-CODE
C209DFDC 00000018
8861015C 2C03006E
41A20014 2C030053
41A2000C 2C030072
408200A0 3C608055
60633788 80830000
548401BA 7C632214
7C6903A6 4E800421
7C862378 4800001D
25737374 726D2F25
30337825 732E6272
73746D00 5F460000
7C8802A6 38BD0008
38E40014 391C0150
7D0808AE 2C080066
41820010 2C080046
41820008 38E70002
38610024 3D808001
618C1950 7D8903A6
4E800421 38610024
3D808015 618CDE6C
7D8903A6 4E800421
2C03FFFF 4182000C
3B410024 48000008
3B410150 00000000
C2711700 00000003
2C000036 40A20008
38800094 38A00000
60000000 00000000

NTSC-K - CT-CODE
C209E11C 00000015
8861015C 2C03006E
41A20014 2C030053
41A2000C 2C030072
40820088 3CC08000
80C60DF4 4800001D
25737374 726D2F25
30337825 732E6272
73746D00 5F460000
7C8802A6 38BD0008
38E40014 391C0150
7D0808AE 2C080066
41820010 2C080046
41820008 38E70002
38610024 3D808001
618C1A94 7D8903A6
4E800421 38610024
3D808015 618CDFC4
7D8903A6 4E800421
2C03FFFF 4182000C
3B410024 48000008
3B410150 00000000
C270043C 00000003
2C000036 40A20008
38800094 38A00000
60000000 00000000

NTSC-K - LE-CODE
C209E11C 00000018
8861015C 2C03006E
41A20014 2C030053
41A2000C 2C030072
408200A0 3C608054
60631E60 80830000
548401BA 7C632214
7C6903A6 4E800421
7C862378 4800001D
25737374 726D2F25
30337825 732E6272
73746D00 5F460000
7C8802A6 38BD0008
38E40014 391C0150
7D0808AE 2C080066
41820010 2C080046
41820008 38E70002
38610024 3D808001
618C1A94 7D8903A6
4E800421 38610024
3D808015 618CDFC4
7D8903A6 4E800421
2C03FFFF 4182000C
3B410024 48000008
3B410150 00000000
C270043C 00000003
2C000036 40A20008
38800094 38A00000
60000000 00000000

Source 1:
Code:
# Hook = 0x8009E0BC PAL, 0x8009E01C NTSC-U, 0x8009DFDC NTSC-J, 0x8009E11C NTSC-K

# Address Ports
.set region, ''
.if (region == 'P' || region == 'p')
.set ctcodething, 0x80000DF4
.set sprintf, 0x80011A2C
.set DVDConvertPathToEntrynum, 0x8015DF4C
.set lecodething, 0x80553E08
.elseif (region == 'U' || region == 'u' || region == 'E' || region == 'e')
.set ctcodething, 0x80000DF4
.set sprintf, 0x80010ECC
.set DVDConvertPathToEntrynum, 0x8015DEAC
.set lecodething, 0x8054DDE8
.elseif (region == 'J' || region == 'j')
.set ctcodething, 0x80000DF4
.set sprintf, 0x80011950
.set DVDConvertPathToEntrynum, 0x8015DE6C
.set lecodething, 0x80553788
.elseif (region == 'K' || region == 'k')
.set ctcodething, 0x80000DF4
.set sprintf, 0x80011A94
.set DVDConvertPathToEntrynum, 0x8015DFC4
.set lecodething, 0x80541E60
.else
.err
.endif

# Track Expansion Mod Type (c = CT-CODE, l = LE-CODE)
.set game, ''
.if (game != 'l' && game != 'c')
.err
.endif

# Check if we are loading a track song by checking the file's first character
lbz r3, 0x15C(r1)

cmpwi r3, 'n'
beq+ isTrack

cmpwi r3, 'S'
beq+ isTrack

cmpwi r3, 'r'
bne originalTrack

# Get the track slot from the exception vector
isTrack:
.if (game == 'c')
lis r6, ctcodething@ha
lwz r6, ctcodething@l(r6)

# Get the instruction from the lecode address and branch to it, slot is returned in r4
.elseif (game == 'l')
lis r3, lecodething@h
ori r3, r3, lecodething@l
lwz r4, 0(r3)
rlwinm r4, r4, 0, 6, 29
add r3, r3, r4
mtctr r3
bctrl
mr r6, r4
.endif

# Do bl trick
bl trick

# Main format string
.string "%sstrm/%03x%s.brstm"

# Last lap string
.string "_F"
.align 2

# Set main format string
trick:
mflr r4

# Set root path
addi r5, r29, 0x8

# Set last lap string
addi r7, r4, 0x14

# Load last character of filename before the extension
addi r8, r28, 0x150
lbzx r8, r8, r1

# Check for an F either lower or uppercase
cmpwi r8, 'f'
beq isFast

cmpwi r8, 'F'
beq isFast

# Add two to fast lap string if not fast
addi r7, r7, 2

# String buffer (this part of the stack is no longer used at this point in the function)
isFast:
addi r3, r1, 0x24

# Call sprintf
lis r12, sprintf@h
ori r12, r12, sprintf@l
mtctr r12
bctrl

# Call DVDConvertPathToEntrynum
addi r3, r1, 0x24
lis r12, DVDConvertPathToEntrynum@h
ori r12, r12, DVDConvertPathToEntrynum@l
mtctr r12
bctrl

# Check if file exists
cmpwi r3, -1
beq originalTrack

# It does, we can use this path!
addi r26, r1, 0x24
b end

# Original instruction
originalTrack:
addi r26, r1, 0x150

# Return
end:

Source 2:
Code:
# Hook 0x80712094 PAL, 0x8070A5F0 NTSC-U, 0x80711700 NTSC-J, 0x8070043C NTSC-K

# Check if special slot is Galaxy Arena
cmpwi r0, 0x36
bne+ end

# If so replace final lap music with Rainbow Road's
li r4, 0x94

# Original instruction
end:
li r5, 0

Code created by: CLF78
Reply


Messages In This Thread
Track Music Expander [CLF78] - by CLF78 - 08-09-2021, 09:09 AM
RE: Track Music Expander [CLF78] - by Cealgair - 10-07-2021, 08:14 AM
RE: Track Music Expander [CLF78] - by Vega - 05-04-2022, 01:35 PM
RE: Track Music Expander [CLF78] - by Warwick92xD - 11-06-2022, 08:35 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)