Adding Custom Music and Macros

From ZeldaHacking Wiki
Jump to navigation Jump to search

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 song file we'll be using for this example.

(We won't be using the .mml version since we'd have to convert that into a .s file anyway.)

Optionally, to be consistent with the other song files and to simplify things, rename the song file to lostAncientRuins.s. Then, inside of it, replace any instances of AlttpLostAncientRuins with LostAncientRuins.

Next, we'll be importing ZerotoKoops' tempo macro, as our song 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
.endm

Move our macro file to include. Then, next to .include "include/musicMacros.s" in {game of your choice}.s, add .include "include/customMusicMacros.s".

Finally, move our song file to audio/{game of your choice}/mus.

Now that we're done setting up, use this page as a reference for what to do next.