pokecrystal-board/macros/scripts/audio.asm

321 lines
5.3 KiB
NASM
Raw Normal View History

MACRO channel_count
assert 0 < (\1) && (\1) <= NUM_MUSIC_CHANS, \
"channel_count must be 1-{d:NUM_MUSIC_CHANS}"
DEF _num_channels = \1 - 1
ENDM
MACRO channel
assert 0 < (\1) && (\1) <= NUM_CHANNELS, \
"channel id must be 1-{d:NUM_CHANNELS}"
dn (_num_channels << 2), \1 - 1 ; channel id
dw \2 ; address
DEF _num_channels = 0
2017-12-28 13:31:16 -08:00
ENDM
MACRO note
dn (\1), (\2) - 1 ; pitch, length
ENDM
MACRO drum_note
note \1, \2 ; drum instrument, length
ENDM
MACRO rest
note 0, \1 ; length
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 14:26:16 -08:00
MACRO square_note
db \1 ; length
2021-03-22 13:41:17 -07:00
if \3 < 0
dn \2, %1000 | (\3 * -1) ; volume envelope
2021-03-22 13:41:17 -07:00
else
dn \2, \3 ; volume envelope
2021-03-22 13:41:17 -07:00
endc
2015-12-07 08:28:58 -08:00
dw \4 ; frequency
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 14:26:16 -08:00
MACRO noise_note
db \1 ; length
2021-03-22 13:41:17 -07:00
if \3 < 0
dn \2, %1000 | (\3 * -1) ; volume envelope
2021-03-22 13:41:17 -07:00
else
dn \2, \3 ; volume envelope
2021-03-22 13:41:17 -07:00
endc
2015-12-07 08:28:58 -08:00
db \4 ; frequency
2017-12-28 13:31:16 -08:00
ENDM
2015-12-07 08:28:58 -08:00
; MusicCommands indexes (see audio/engine.asm)
const_def $d0
DEF FIRST_MUSIC_CMD EQU const_value
const octave_cmd ; $d0
MACRO octave
2021-03-21 17:09:34 -07:00
assert 1 <= (\1) && (\1) <= 8, "octave must be 1-8"
db octave_cmd + 8 - (\1) ; octave
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const_skip 7 ; all octave values
const note_type_cmd ; $d8
MACRO note_type
db note_type_cmd
db \1 ; note length
2021-03-22 13:41:17 -07:00
if _NARG >= 2
if \3 < 0
dn \2, %1000 | (\3 * -1) ; volume envelope
2021-03-22 13:41:17 -07:00
else
dn \2, \3 ; volume envelope
2021-03-22 13:41:17 -07:00
endc
endc
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
; only valid on the noise channel
MACRO drum_speed
note_type \1 ; note length
ENDM
const transpose_cmd ; $d9
MACRO transpose
db transpose_cmd
dn \1, \2 ; num octaves, num pitches
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const tempo_cmd ; $da
MACRO tempo
2015-12-06 19:36:09 -08:00
db tempo_cmd
2015-01-20 00:01:23 -08:00
bigdw \1 ; tempo
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const duty_cycle_cmd ; $db
MACRO duty_cycle
db duty_cycle_cmd
db \1 ; duty cycle
ENDM
const volume_envelope_cmd ; $dc
MACRO volume_envelope
db volume_envelope_cmd
2021-03-22 13:41:17 -07:00
if \2 < 0
dn \1, %1000 | (\2 * -1) ; volume envelope
2021-03-22 13:41:17 -07:00
else
dn \1, \2 ; volume envelope
2021-03-22 13:41:17 -07:00
endc
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const pitch_sweep_cmd ; $dd
MACRO pitch_sweep
db pitch_sweep_cmd
2021-03-22 13:41:17 -07:00
if \2 < 0
dn \1, %1000 | (\2 * -1) ; pitch sweep
2021-03-22 13:41:17 -07:00
else
dn \1, \2 ; pitch sweep
2021-03-22 13:41:17 -07:00
endc
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const duty_cycle_pattern_cmd ; $de
MACRO duty_cycle_pattern
db duty_cycle_pattern_cmd
db (\1 << 6) | (\2 << 4) | (\3 << 2) | (\4 << 0) ; duty cycle pattern
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const toggle_sfx_cmd ; $df
MACRO toggle_sfx
db toggle_sfx_cmd
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const pitch_slide_cmd ; $e0
MACRO pitch_slide
db pitch_slide_cmd
db \1 - 1 ; duration
dn 8 - \2, \3 % 12 ; octave, pitch
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const vibrato_cmd ; $e1
MACRO vibrato
2015-12-06 19:36:09 -08:00
db vibrato_cmd
2015-01-20 00:01:23 -08:00
db \1 ; delay
2021-03-22 13:41:17 -07:00
if _NARG > 2
2019-09-03 22:17:10 -07:00
dn \2, \3 ; extent, rate
2021-03-22 13:41:17 -07:00
else
2019-09-03 22:17:10 -07:00
db \2 ; LEGACY: Support for 1-arg extent
2021-03-22 13:41:17 -07:00
endc
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const unknownmusic0xe2_cmd ; $e2
MACRO unknownmusic0xe2
2015-12-06 19:36:09 -08:00
db unknownmusic0xe2_cmd
2015-01-20 00:01:23 -08:00
db \1 ; unknown
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const toggle_noise_cmd ; $e3
MACRO toggle_noise
db toggle_noise_cmd
2021-03-22 13:41:17 -07:00
if _NARG > 0
db \1 ; drum kit
2021-03-22 13:41:17 -07:00
endc
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const force_stereo_panning_cmd ; $e4
MACRO force_stereo_panning
db force_stereo_panning_cmd
dn %1111 * (1 && \1), %1111 * (1 && \2) ; left enable, right enable
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const volume_cmd ; $e5
MACRO volume
2015-12-06 19:36:09 -08:00
db volume_cmd
2021-03-22 13:41:17 -07:00
if _NARG > 1
2019-09-03 22:17:10 -07:00
dn \1, \2 ; left volume, right volume
2021-03-22 13:41:17 -07:00
else
2019-09-03 22:17:10 -07:00
db \1 ; LEGACY: Support for 1-arg volume
2021-03-22 13:41:17 -07:00
endc
ENDM
const pitch_offset_cmd ; $e6
MACRO pitch_offset
db pitch_offset_cmd
bigdw \1 ; pitch offset
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const unknownmusic0xe7_cmd ; $e7
MACRO unknownmusic0xe7
2015-12-06 19:36:09 -08:00
db unknownmusic0xe7_cmd
2015-01-20 00:01:23 -08:00
db \1 ; unknown
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const unknownmusic0xe8_cmd ; $e8
MACRO unknownmusic0xe8
2015-12-06 19:36:09 -08:00
db unknownmusic0xe8_cmd
2015-01-20 00:01:23 -08:00
db \1 ; unknown
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const tempo_relative_cmd ; $e9
MACRO tempo_relative
2015-12-08 13:06:13 -08:00
db tempo_relative_cmd
db \1 ; tempo adjustment
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const restart_channel_cmd ; $ea
MACRO restart_channel
db restart_channel_cmd
2015-01-20 00:01:23 -08:00
dw \1 ; address
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const new_song_cmd ; $eb
MACRO new_song
db new_song_cmd
dw \1 ; id
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const sfx_priority_on_cmd ; $ec
MACRO sfx_priority_on
db sfx_priority_on_cmd
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const sfx_priority_off_cmd ; $ed
MACRO sfx_priority_off
db sfx_priority_off_cmd
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const unknownmusic0xee_cmd ; $ee
MACRO unknownmusic0xee
2015-12-06 19:36:09 -08:00
db unknownmusic0xee_cmd
2015-01-20 00:01:23 -08:00
dw \1 ; address
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const stereo_panning_cmd ; $ef
MACRO stereo_panning
db stereo_panning_cmd
dn %1111 * (1 && \1), %1111 * (1 && \2) ; left enable, right enable
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const sfx_toggle_noise_cmd ; $f0
MACRO sfx_toggle_noise
db sfx_toggle_noise_cmd
2021-03-22 13:41:17 -07:00
if _NARG > 0
db \1 ; drum kit
2021-03-22 13:41:17 -07:00
endc
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const music0xf1_cmd ; $f1
MACRO music0xf1
2015-12-06 19:36:09 -08:00
db music0xf1_cmd
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const music0xf2_cmd ; $f2
MACRO music0xf2
2015-12-06 19:36:09 -08:00
db music0xf2_cmd
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const music0xf3_cmd ; $f3
MACRO music0xf3
2015-12-06 19:36:09 -08:00
db music0xf3_cmd
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const music0xf4_cmd ; $f4
MACRO music0xf4
2015-12-06 19:36:09 -08:00
db music0xf4_cmd
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const music0xf5_cmd ; $f5
MACRO music0xf5
2015-12-06 19:36:09 -08:00
db music0xf5_cmd
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const music0xf6_cmd ; $f6
MACRO music0xf6
2015-12-06 19:36:09 -08:00
db music0xf6_cmd
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const music0xf7_cmd ; $f7
MACRO music0xf7
2015-12-06 19:36:09 -08:00
db music0xf7_cmd
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const music0xf8_cmd ; $f8
MACRO music0xf8
2015-12-06 19:36:09 -08:00
db music0xf8_cmd
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const unknownmusic0xf9_cmd ; $f9
MACRO unknownmusic0xf9
2015-12-06 19:36:09 -08:00
db unknownmusic0xf9_cmd
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const set_condition_cmd ; $fa
MACRO set_condition
db set_condition_cmd
2015-01-20 00:01:23 -08:00
db \1 ; condition
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const sound_jump_if_cmd ; $fb
MACRO sound_jump_if
db sound_jump_if_cmd
2015-01-20 00:01:23 -08:00
db \1 ; condition
dw \2 ; address
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const sound_jump_cmd ; $fc
MACRO sound_jump
db sound_jump_cmd
2015-01-20 00:01:23 -08:00
dw \1 ; address
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const sound_loop_cmd ; $fd
MACRO sound_loop
db sound_loop_cmd
2015-01-20 00:01:23 -08:00
db \1 ; count
dw \2 ; address
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const sound_call_cmd ; $fe
MACRO sound_call
db sound_call_cmd
2015-01-20 00:01:23 -08:00
dw \1 ; address
2017-12-28 13:31:16 -08:00
ENDM
2015-01-20 00:01:23 -08:00
const sound_ret_cmd ; $ff
MACRO sound_ret
db sound_ret_cmd
2017-12-28 13:31:16 -08:00
ENDM