UnclePunch
Smash Ace
- Joined
- Nov 9, 2014
- Messages
- 673
This code allows you to add additional hps files to Melee's song table. The additional songs will start at ID 98 (0x62). You must assemble this code to use it. I recommend using CodeWrite to assemble into a gecko code, or MCM to assemble into an ISO mod.
To modify the extended song list:
Navigate to the song table near the end of the code, surrounded in #'s. To add songs, simply add the following to the bottom of the list:
.string "SONGNAMEHERE.hps"
MCM Library File
To modify the extended song list:
Navigate to the song table near the end of the code, surrounded in #'s. To add songs, simply add the following to the bottom of the list:
.string "SONGNAMEHERE.hps"
MCM Library File
Code:
#To be inserted at 80023f50
.macro backup
mflr r0
stw r0, 0x4(r1)
stwu r1,-0x100(r1) # make space for 12 registers
stmw r20,0x8(r1)
.endm
.macro restore
lmw r20,0x8(r1)
lwz r0, 0x104(r1)
addi r1,r1,0x100 # release the space
mtlr r0
.endm
.macro branchl reg, address
lis \reg, \address @h
ori \reg,\reg,\address @l
mtctr \reg
bctrl
.endm
.macro branch reg, address
lis \reg, \address @h
ori \reg,\reg,\address @l
mtctr \reg
bctr
.endm
.macro load reg, address
lis \reg, \address @h
ori \reg, \reg, \address @l
.endm
.set strlen,0x80325b04
#Check if custom song
cmpwi r3,98
blt Injection_Exit
#Init search loop
.set REG_CustomSongIndex,31
.set REG_SongList,30
.set REG_LoopCount,29
backup
subi REG_CustomSongIndex,r3,98
bl SongTable
mflr REG_SongList
li REG_LoopCount,0
StringSearchLoop:
#Check if end of list
lbz r3,0x0(REG_SongList)
extsb r3,r3
cmpwi r3,-1
beq SongNotFound
#Check if this is the song we are looking for
cmpw REG_LoopCount,REG_CustomSongIndex
beq SongFound
#Get next string
mr r3,REG_SongList
branchl r12,strlen
add REG_SongList,REG_SongList,r3
addi REG_SongList,REG_SongList,1 #add 1 to skip past the 0 terminator
addi REG_LoopCount,REG_LoopCount,1
b StringSearchLoop
#####################################
SongTable:
blrl
#First song on this list is song ID 98 (0x62)
.string "FirstSong.hps" #this will be song 0x62
.string "SecondSong.hps" #this will be song 0x63
.string "YouGetTheIdea.hps" #etc
.byte -1
.align 2
#####################################
SongFound:
mr r4,REG_SongList
restore
load r3,0x803bb300+128
lwz r5, -0x7DCC (r13)
add r3,r3,r5
branch r12,0x80023f98
SongNotFound:
restore
branch r12,0x80023fc0
Injection_Exit:
Attachments
-
2.1 KB Views: 86
Last edited: