Applying Custom Music and Music Macros
TODO: Change the way some of the content of this page is typed as it's a bit weird.
Step 1
Click on this link to go to the page where you'll be downloading castIeRook's alttp_-_lost_ancient_ruins.s, as that'll be the music file we'll be using for this example.
Optionally, to be consistent with the other music files and to simplify things, rename the music file to lostAncientRuins.s. Inside of it, replace any instances of AlttpLostAncientRuins with LostAncientRuins.
Next, we'll be importing ZerotoKoops' tempo macro, as our music file needs that in order to work properly.
Make a new .s file and name it customMusicMacros.s. Then, add this to the file:
.macro tempo
.redefine Q (150*24 - (150*24) # \1) / \1
.if ((150*24) # \1) >= 0.5*\1
.redefine Q Q+1
.endif
.redefine T1 (Q - (Q # 8))/8
.redefine T2 (Q * 2 - ((Q * 2) # 8))/8 - T1
.redefine T3 (Q * 3 - ((Q * 3) # 8))/8 - (T1+T2)
.redefine T4 (Q * 4 - ((Q * 4) # 8))/8 - (T1+T2+T3)
.redefine T5 (Q * 5 - ((Q * 5) # 8))/8 - (T1+T2+T3+T4)
.redefine T6 (Q * 6 - ((Q * 6) # 8))/8 - (T1+T2+T3+T4+T5)
.redefine T7 (Q * 7 - ((Q * 7) # 8))/8 - (T1+T2+T3+T4+T5+T6)
.redefine T8 (Q * 8 - ((Q * 8) # 8))/8 - (T1+T2+T3+T4+T5+T6+T7)
.redefine S1 T1+T2
.redefine S2 T3+T4
.redefine S3 T5+T6
.redefine S4 T7+T8
.redefine E1 S1+S2
.redefine E2 S3+S4
.redefine HF Q*2
.redefine W Q*4
.redefine BEAT 1
.redefine W1 (Q - (Q # 12))/12
.redefine W2 (Q * 2 - ((Q * 2) # 12))/12 - W1
.redefine W3 (Q * 3 - ((Q * 3) # 12))/12 - (W1+W2)
.redefine W4 (Q * 4 - ((Q * 4) # 12))/12 - (W1+W2+W3)
.redefine W5 (Q * 5 - ((Q * 5) # 12))/12 - (W1+W2+W3+W4)
.redefine W6 (Q * 6 - ((Q * 6) # 12))/12 - (W1+W2+W3+W4+W5)
.redefine W7 (Q * 7 - ((Q * 7) # 12))/12 - (W1+W2+W3+W4+W5+W6)
.redefine W8 (Q * 8 - ((Q * 8) # 12))/12 - (W1+W2+W3+W4+W5+W6+W7)
.redefine W9 (Q * 9 - ((Q * 9) # 12))/12 - (W1+W2+W3+W4+W5+W6+W7+W8)
.redefine W10 (Q * 10 - ((Q * 10) # 12))/12 - (W1+W2+W3+W4+W5+W6+W7+W8+W9)
.redefine W11 (Q * 11 - ((Q * 11) # 12))/12 - (W1+W2+W3+W4+W5+W6+W7+W8+W9+W10)
.redefine W12 (Q * 12 - ((Q * 12) # 12))/12 - (W1+W2+W3+W4+W5+W6+W7+W8+W9+W10+W11)
.redefine Y1 W1+W2
.redefine Y2 W3+W4
.redefine Y3 W5+W6
.redefine Y4 W7+W8
.redefine Y5 W9+W10
.redefine Y6 W11+W12
.redefine R1 Y1+Y2
.redefine R2 Y3+Y4
.redefine R3 Y5+Y6
.endmNow, move our macro file to include. Next to .include "include/musicMacros.s" in {game of your choice}.s and code/audio.s, add .include "include/customMusicMacros.s".
Finally, move our music file to audio/{game of your choice}/mus.
Step 2
There are two ways to do this.
Way 1
Since the mus37 sound pointer in audio/{game of your choice}/soundPointers.s is a whole bunch of nothing, replace that with our music file's.
Optionally, replace the MUS_37 constant in constants/common/music.s with either MUS_ALTTP_LOST_ANCIENT_RUINS or MUS_LOST_ANCIENT_RUINS.
Way 2
In audio/{game of your choice}/soundPointers.s, add a sound pointer for our music file, whose index will be $df.
Then, around line 395 in constants/common/music.s, add either .define MUS_ALTTP_LOST_ANCIENT_RUINS $df or .define MUS_LOST_ANCIENT_RUINS $df.
The Last Two Things for Both Ways
Add our music file's sound channel pointer in audio/{game of your choice}/soundChannelPointers.s,
then .include our music file around line 71 in audio/{game of your choice}/soundChannelData.s.