TempoQuill

rsc_macros.asm

Apr 16th, 2021 (edited)
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.04 KB | None | 0 0
  1. channel_count: MACRO
  2. _num_channels = \1 - 1
  3. ENDM
  4.  
  5. channel: MACRO
  6. dn (_num_channels << 2), \1 - 1 ; channel id
  7. IF _NARG == \2
  8. dw \2 ; address
  9. ENDC
  10. _num_channels = 0
  11. ENDM
  12.  
  13. wav_note: MACRO
  14. db \1 ; wavetable constant
  15. ENDM
  16.  
  17. env_note: MACRO
  18. dn \1, \2
  19. ENDM
  20.  
  21. note: MACRO
  22. dn (\1), (\2) - 1 ; pitch, length
  23. ENDM
  24.  
  25. drum_note: MACRO
  26. note \1, \2 ; drum instrument, length
  27. ENDM
  28.  
  29. rest: MACRO
  30. note 0, \1 ; length
  31. ENDM
  32.  
  33. square_note: MACRO
  34. db \1 ; length
  35. IF \3 < 0
  36. dn \2, %1000 | (\3 * -1) ; volume envelope
  37. ELSE
  38. dn \2, \3 ; volume envelope
  39. ENDC
  40. dw \4 ; pitch
  41. ENDM
  42.  
  43. noise_note: MACRO
  44. db \1 ; length
  45. IF \3 < 0
  46. dn \2, %1000 | (\3 * -1) ; volume envelope
  47. ELSE
  48. dn \2, \3 ; volume envelope
  49. ENDC
  50. db \4 ; division
  51. ENDM
  52.  
  53. ; MusicCommands indexes (see audio/engine.asm)
  54. const_def 208 ; $d0
  55. FIRST_MUSIC_CMD EQU const_value
  56. const octave_cmd ; $d0
  57. const_skip 7 ; all octave values
  58. const note_type_cmd ; $d8
  59. const transpose_cmd ; $d9
  60. const tempo_cmd ; $da
  61. const duty_cycle_cmd ; $db
  62. const volume_envelope_cmd ; $dc
  63. const pitch_sweep_cmd ; $dd
  64. const duty_cycle_pattern_cmd ; $de
  65. const toggle_music_cmd ; $df
  66. const pitch_slide_cmd ; $e0
  67. const vibrato_cmd ; $e1
  68. const set_mute_cmd ; $e2
  69. const toggle_noise_cmd ; $e3
  70. const old_panning_cmd ; $e4
  71. const volume_cmd ; $e5
  72. const pitch_offset_cmd ; $e6
  73. const relative_pitch_cmd ; $e7
  74. const volume_envelope_group_cmd ; $e8
  75. const tempo_relative_cmd ; $e9
  76. const restart_channel_cmd ; $ea
  77. const new_song_cmd ; $eb
  78. const sfx_priority_on_cmd ; $ec
  79. const sfx_priority_off_cmd ; $ed
  80. const sound_jump_ram_cmd ; $ee
  81. const stereo_panning_cmd ; $ef
  82. const sfx_toggle_noise_cmd ; $f0
  83. const pitch_inc_switch_cmd ; $f1
  84. const toggle_sound_event_cmd ; $f2
  85. const set_music_cmd ; $f3
  86. const dummy_f4_cmd ; $f4
  87. const dummy_f5_cmd ; $f5
  88. const dummy_f6_cmd ; $f6
  89. const dummy_f7_cmd ; $f7
  90. const dummy_f8_cmd ; $f8
  91. const set_sound_event_cmd ; $f9
  92. const set_condition_cmd ; $fa
  93. const sound_jump_if_cmd ; $fb
  94. const sound_jump_cmd ; $fc
  95. const sound_loop_cmd ; $fd
  96. env_loop_cmd EQU const_value
  97. const sound_call_cmd ; $fe
  98. env_ret_cmd EQU const_value
  99. const sound_ret_cmd ; $ff
  100.  
  101. octave: MACRO
  102. db octave_cmd + (8 - (\1)) ; octave
  103. ENDM
  104.  
  105. ; valid on Ch1-3 & 5-7
  106. ; noise is relegated to drum_speed
  107. note_type: MACRO
  108. db note_type_cmd
  109. db \1 ; note length
  110. IF _NARG >= 2
  111. IF \3 < 0
  112. dn \2, %1000 | (\3 * -1) ; volume envelope
  113. ELSE
  114. dn \2, \3 ; volume envelope
  115. ENDC
  116. ENDC
  117. ENDM
  118.  
  119. drum_speed: MACRO
  120. note_type \1 ; note length
  121. ENDM
  122.  
  123. transpose: MACRO
  124. db transpose_cmd
  125. dn \1, \2 ; octave offset, note offset
  126. ENDM
  127.  
  128. tempo: MACRO
  129. db tempo_cmd
  130. bigdw \1 ; tempo
  131. ENDM
  132.  
  133. duty_cycle: MACRO
  134. db duty_cycle_cmd
  135. db \1 ; duty cycle
  136. ENDM
  137.  
  138. volume_envelope: MACRO
  139. db volume_envelope_cmd
  140. IF \2 < 0
  141. dn \1, %1000 | (\2 * -1) ; volume envelope
  142. ELSE
  143. dn \1, \2 ; volume envelope
  144. ENDC
  145. ENDM
  146.  
  147. pitch_sweep: MACRO
  148. db pitch_sweep_cmd
  149. IF \2 < 0
  150. dn \1, %1000 | (\2 * -1) ; pitch sweep
  151. ELSE
  152. dn \1, \2 ; pitch sweep
  153. ENDC
  154. ENDM
  155.  
  156. duty_cycle_pattern: MACRO
  157. db duty_cycle_pattern_cmd
  158. dc \1, \2, \3, \4
  159. ENDM
  160.  
  161. toggle_music: MACRO
  162. db toggle_music_cmd
  163. ENDM
  164.  
  165. ; works only on Channel 1 and 5 in gold/silver/crystal
  166. ; works on all pitched channels in ray/shade/chaos
  167. pitch_slide: MACRO
  168. db pitch_slide_cmd
  169. db \1 - 1 ; duration
  170. dn 8 - \2, \3 % 12 ; octave, pitch
  171. ENDM
  172.  
  173. vibrato: MACRO
  174. db vibrato_cmd
  175. db \1 ; delay
  176. IF _NARG > 2
  177. dn \2, \3 ; depth, speed
  178. ELSE
  179. db \2 ; LEGACY: Support for 1-arg byte
  180. ENDC
  181. ENDM
  182.  
  183. ; from Gold, restored
  184. ; appears to be an equivalent to RBY's $ef
  185. set_mute: MACRO
  186. db set_mute_cmd
  187. db \1 ; mute flag
  188. ENDM
  189.  
  190. toggle_noise: MACRO
  191. db toggle_noise_cmd
  192. IF _NARG > 0
  193. db \1 ; drum kit
  194. ENDC
  195. ENDM
  196.  
  197. ; Yoshi/Gen 1's means of stereo
  198. old_panning: MACRO
  199. db old_panning_cmd
  200. dn \1, \2 ; binary values
  201. ENDM
  202.  
  203. volume: MACRO
  204. db volume_cmd
  205. IF _NARG > 1
  206. dn \1, \2 ; left volume, right volume
  207. ELSE
  208. db \1 ; LEGACY: Support for 1-arg volume
  209. ENDC
  210. ENDM
  211.  
  212. ; obselete equivalent to toggle_perfect_pitch
  213. pitch_offset: MACRO
  214. db pitch_offset_cmd
  215. IF \1 < 0
  216. bigdw $ffff - ((\1 + 1) * -1)
  217. ELSE
  218. bigdw \1 ; pitch offset
  219. ENDC
  220. ENDM
  221.  
  222. ; from Gold/Silver, restored
  223. relative_pitch: MACRO
  224. db relative_pitch_cmd
  225. db \1 ; pitch
  226. ENDM
  227.  
  228. ; from Gold/Silver, restored
  229. volume_envelope_group: MACRO
  230. db volume_envelope_group_cmd
  231. db \1 ; group
  232. ENDM
  233.  
  234. tempo_relative: MACRO
  235. db tempo_relative_cmd
  236. ; LEGACY: macro used 2-byte value in gold, fixed in ray
  237. IF \1 > 128
  238. bigdw \1
  239. ELIF \1 < 0
  240. db 255 - ((\1 * -1) - 1)
  241. ELSE
  242. db \1 ; tempo adjustment
  243. ENDC
  244. ENDM
  245.  
  246. restart_channel: MACRO
  247. db restart_channel_cmd
  248. dw \1 ; address
  249. ENDM
  250.  
  251. new_song: MACRO
  252. db new_song_cmd
  253. bigdw \1 ; id
  254. ENDM
  255.  
  256. sfx_priority_on: MACRO
  257. db sfx_priority_on_cmd
  258. ENDM
  259.  
  260. sfx_priority_off: MACRO
  261. db sfx_priority_off_cmd
  262. ENDM
  263.  
  264. ; from Gold, unused
  265. ; uses exclusive RAM, not set by any scripts
  266. sound_jump_ram: MACRO
  267. db sound_jump_ram_cmd
  268. dw \1 ; address
  269. ENDM
  270.  
  271. stereo_panning: MACRO
  272. ; LEGACY: support for PokeRed stereo_panning
  273. IF const_value == old_panning_cmd
  274. old_panning \1, \2
  275. ELSE
  276. db stereo_panning_cmd
  277. dn \1 * 15, \2 * 15 ; left, right
  278. ENDC
  279. ENDM
  280.  
  281. sfx_toggle_noise: MACRO
  282. db sfx_toggle_noise_cmd
  283. IF _NARG > 0
  284. db \1 ; drum kit
  285. ENDC
  286. ENDM
  287.  
  288. ; only present in ray/shade/chaos
  289. ; functionally identical to toggle_perfect_pitch
  290. pitch_inc_switch: MACRO
  291. db pitch_inc_switch_cmd
  292. ENDM
  293.  
  294. ; only present in ray/shade/chaos
  295. ; to be used when porting BGM tracks from Yoshi
  296. toggle_sound_event: MACRO
  297. db toggle_sound_event_cmd
  298. ENDM
  299.  
  300. ; only present in ray/shade/chaos
  301. ; functionally similar to execute_music
  302. set_music: MACRO
  303. db set_music_cmd
  304. ENDM
  305.  
  306. dummy_f4: MACRO
  307. db dummy_f4_cmd
  308. ENDM
  309.  
  310. dummy_f5: MACRO
  311. db dummy_f5_cmd
  312. ENDM
  313.  
  314. dummy_f6: MACRO
  315. db dummy_f6_cmd
  316. ENDM
  317.  
  318. dummy_f7: MACRO
  319. db dummy_f7_cmd
  320. ENDM
  321.  
  322. dummy_f8: MACRO
  323. db dummy_f8_cmd
  324. ENDM
  325.  
  326. ; from Gold, unused
  327. ; no scripts depend on this music command
  328. set_sound_event: MACRO
  329. db set_sound_event_cmd
  330. ENDM
  331.  
  332. set_condition: MACRO
  333. db set_condition_cmd
  334. db \1 ; condition
  335. ENDM
  336.  
  337. sound_jump_if: MACRO
  338. db sound_jump_if_cmd
  339. db \1 ; condition
  340. dw \2 ; address
  341. ENDM
  342.  
  343. ; renders "sound_loop 0" obselete
  344. sound_jump: MACRO
  345. db sound_jump_cmd
  346. dw \1 ; address
  347. ENDM
  348.  
  349. sound_loop: MACRO
  350. db sound_loop_cmd
  351. db \1 ; count
  352. dw \2 ; address
  353. ENDM
  354.  
  355. sound_call: MACRO
  356. db sound_call_cmd
  357. dw \1 ; address
  358. ENDM
  359.  
  360. sound_ret: MACRO
  361. db sound_ret_cmd
  362. ENDM
  363.  
  364. env_loop: MACRO
  365. db env_loop_cmd
  366. ENDM
  367.  
  368. env_ret: MACRO
  369. db env_ret_cmd
  370. ENDM
  371.  
Add Comment
Please, Sign In to add comment