audio_macros.asm 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. StopAllMusic: MACRO
  2. ld a, $ff
  3. call PlaySound
  4. ENDM
  5. Ch0 EQU 0
  6. Ch1 EQU 1
  7. Ch2 EQU 2
  8. Ch3 EQU 3
  9. Ch4 EQU 4
  10. Ch5 EQU 5
  11. Ch6 EQU 6
  12. Ch7 EQU 7
  13. audio: MACRO
  14. db (_NARG - 2) << 6 | \2
  15. dw \1_\2
  16. IF _NARG > 2
  17. db \3
  18. dw \1_\3
  19. ENDC
  20. IF _NARG > 3
  21. db \4
  22. dw \1_\4
  23. ENDC
  24. IF _NARG > 4
  25. db \5
  26. dw \1_\5
  27. ENDC
  28. ENDM
  29. ;format: length [0, 7], pitch change [-7, 7]
  30. pitchenvelope: MACRO
  31. db $10
  32. IF \2 > 0
  33. db (\1 << 4) | \2
  34. ELSE
  35. db (\1 << 4) | (%1000 | (\2 * -1))
  36. ENDC
  37. ENDM
  38. ;format: length [0, 15], volume [0, 15], volume change [-7, 7], pitch
  39. squarenote: MACRO
  40. db $20 | \1
  41. IF \3 < 0
  42. db (\2 << 4) | (%1000 | (\3 * -1))
  43. ELSE
  44. db (\2 << 4) | \3
  45. ENDC
  46. dw \4
  47. ENDM
  48. ;format: length [0, 15], volume [0, 15], volume change [-7, 7], pitch
  49. noisenote: MACRO
  50. db $20 | \1
  51. IF \3 < 0
  52. db (\2 << 4) | (%1000 | (\3 * -1))
  53. ELSE
  54. db (\2 << 4) | \3
  55. ENDC
  56. db \4
  57. ENDM
  58. ;format: pitch length (in 16ths)
  59. C_: MACRO
  60. db $00 | (\1 - 1)
  61. ENDM
  62. C#: MACRO
  63. db $10 | (\1 - 1)
  64. ENDM
  65. D_: MACRO
  66. db $20 | (\1 - 1)
  67. ENDM
  68. D#: MACRO
  69. db $30 | (\1 - 1)
  70. ENDM
  71. E_: MACRO
  72. db $40 | (\1 - 1)
  73. ENDM
  74. F_: MACRO
  75. db $50 | (\1 - 1)
  76. ENDM
  77. F#: MACRO
  78. db $60 | (\1 - 1)
  79. ENDM
  80. G_: MACRO
  81. db $70 | (\1 - 1)
  82. ENDM
  83. G#: MACRO
  84. db $80 | (\1 - 1)
  85. ENDM
  86. A_: MACRO
  87. db $90 | (\1 - 1)
  88. ENDM
  89. A#: MACRO
  90. db $A0 | (\1 - 1)
  91. ENDM
  92. B_: MACRO
  93. db $B0 | (\1 - 1)
  94. ENDM
  95. ;format: instrument length (in 16ths)
  96. snare1: MACRO
  97. db $B0 | (\1 - 1)
  98. db $01
  99. ENDM
  100. snare2: MACRO
  101. db $B0 | (\1 - 1)
  102. db $02
  103. ENDM
  104. snare3: MACRO
  105. db $B0 | (\1 - 1)
  106. db $03
  107. ENDM
  108. snare4: MACRO
  109. db $B0 | (\1 - 1)
  110. db $04
  111. ENDM
  112. snare5: MACRO
  113. db $B0 | (\1 - 1)
  114. db $05
  115. ENDM
  116. triangle1: MACRO
  117. db $B0 | (\1 - 1)
  118. db $06
  119. ENDM
  120. triangle2: MACRO
  121. db $B0 | (\1 - 1)
  122. db $07
  123. ENDM
  124. snare6: MACRO
  125. db $B0 | (\1 - 1)
  126. db $08
  127. ENDM
  128. snare7: MACRO
  129. db $B0 | (\1 - 1)
  130. db $09
  131. ENDM
  132. snare8: MACRO
  133. db $B0 | (\1 - 1)
  134. db $0A
  135. ENDM
  136. snare9: MACRO
  137. db $B0 | (\1 - 1)
  138. db $0B
  139. ENDM
  140. cymbal1: MACRO
  141. db $B0 | (\1 - 1)
  142. db $0C
  143. ENDM
  144. cymbal2: MACRO
  145. db $B0 | (\1 - 1)
  146. db $0D
  147. ENDM
  148. cymbal3: MACRO
  149. db $B0 | (\1 - 1)
  150. db $0E
  151. ENDM
  152. mutedsnare1: MACRO
  153. db $B0 | (\1 - 1)
  154. db $0F
  155. ENDM
  156. triangle3: MACRO
  157. db $B0 | (\1 - 1)
  158. db $10
  159. ENDM
  160. mutedsnare2: MACRO
  161. db $B0 | (\1 - 1)
  162. db $11
  163. ENDM
  164. mutedsnare3: MACRO
  165. db $B0 | (\1 - 1)
  166. db $12
  167. ENDM
  168. mutedsnare4: MACRO
  169. db $B0 | (\1 - 1)
  170. db $13
  171. ENDM
  172. ;format: rest length (in 16ths)
  173. rest: MACRO
  174. db $C0 | (\1 - 1)
  175. ENDM
  176. ; format: notetype speed, volume, fade
  177. notetype: MACRO
  178. db $D0 | \1
  179. db (\2 << 4) | \3
  180. ENDM
  181. dspeed: MACRO
  182. db $D0 | \1
  183. ENDM
  184. octave: MACRO
  185. db $E8 - \1
  186. ENDM
  187. toggleperfectpitch: MACRO
  188. db $E8
  189. ENDM
  190. ;format: vibrato delay, rate, depth
  191. vibrato: MACRO
  192. db $EA
  193. db \1
  194. db (\2 << 4) | \3
  195. ENDM
  196. pitchbend: MACRO
  197. db $EB
  198. db \1
  199. db \2
  200. ENDM
  201. duty: MACRO
  202. db $EC
  203. db \1
  204. ENDM
  205. tempo: MACRO
  206. db $ED
  207. db \1 / $100
  208. db \1 % $100
  209. ENDM
  210. stereopanning: MACRO
  211. db $EE
  212. db \1
  213. ENDM
  214. volume: MACRO
  215. db $F0
  216. db (\1 << 4) | \2
  217. ENDM
  218. executemusic: MACRO
  219. db $F8
  220. ENDM
  221. dutycycle: MACRO
  222. db $FC
  223. db \1
  224. ENDM
  225. ;format: callchannel address
  226. callchannel: MACRO
  227. db $FD
  228. dw \1
  229. ENDM
  230. ;format: loopchannel count, address
  231. loopchannel: MACRO
  232. db $FE
  233. db \1
  234. dw \2
  235. ENDM
  236. endchannel: MACRO
  237. db $FF
  238. ENDM