RGBDS syntax updates (#905)

New MACRO and DEF syntax
This commit is contained in:
vulcandth
2022-06-06 16:25:42 -05:00
committed by GitHub
parent a4d346cc8c
commit 3648afda16
179 changed files with 2546 additions and 2545 deletions

View File

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