Define constants for audio commands

This commit is contained in:
Rangi 2020-07-16 13:25:02 -04:00
parent 84abdb0237
commit 7306c1dc2d
4 changed files with 185 additions and 137 deletions

View file

@ -41,7 +41,7 @@ Audio1_ApplyMusicAffects:
ld hl, wChannelNoteDelayCounters ; delay until next note
add hl, bc
ld a, [hl]
cp $1 ; if the delay is 1, play next note
cp 1 ; if the delay is 1, play next note
jp z, Audio1_PlayNextNote
dec a ; otherwise, decrease the delay timer
ld [hl], a
@ -163,8 +163,8 @@ Audio1_PlayNextNote:
Audio1_sound_ret:
call Audio1_GetNextMusicByte
ld d, a
cp $ff ; is this command a sound_ret?
jp nz, Audio1_sound_call ; no
cp sound_ret_cmd
jp nz, Audio1_sound_call
ld b, 0
ld hl, wChannelFlags1
add hl, bc
@ -251,8 +251,8 @@ Audio1_sound_ret:
ret
Audio1_sound_call:
cp $fd ; is this command a sound_call?
jp nz, Audio1_sound_loop ; no
cp sound_call_cmd
jp nz, Audio1_sound_loop
call Audio1_GetNextMusicByte
push af
call Audio1_GetNextMusicByte
@ -288,8 +288,8 @@ Audio1_sound_call:
jp Audio1_sound_ret
Audio1_sound_loop:
cp $fe ; is this command a sound_loop?
jp nz, Audio1_note_type ; no
cp sound_loop_cmd
jp nz, Audio1_note_type
call Audio1_GetNextMusicByte
ld e, a
and a
@ -327,8 +327,8 @@ Audio1_sound_loop:
Audio1_note_type:
and $f0
cp $d0 ; is this command a note_type?
jp nz, Audio1_toggle_perfect_pitch ; no
cp note_type_cmd
jp nz, Audio1_toggle_perfect_pitch
ld a, d
and $f
ld b, $0
@ -371,8 +371,8 @@ Audio1_note_type:
Audio1_toggle_perfect_pitch:
ld a, d
cp $e8 ; is this command a toggle_perfect_pitch?
jr nz, Audio1_vibrato ; no
cp toggle_perfect_pitch_cmd
jr nz, Audio1_vibrato
ld b, 0
ld hl, wChannelFlags1
add hl, bc
@ -382,8 +382,8 @@ Audio1_toggle_perfect_pitch:
jp Audio1_sound_ret
Audio1_vibrato:
cp $ea ; is this command a vibrato?
jr nz, Audio1_pitch_slide ; no
cp vibrato_cmd
jr nz, Audio1_pitch_slide
call Audio1_GetNextMusicByte
ld b, 0
ld hl, wChannelVibratoDelayCounters
@ -430,8 +430,8 @@ Audio1_vibrato:
jp Audio1_sound_ret
Audio1_pitch_slide:
cp $eb ; is this command a pitch_slide?
jr nz, Audio1_duty_cycle ; no
cp pitch_slide_cmd
jr nz, Audio1_duty_cycle
call Audio1_GetNextMusicByte
ld b, 0
ld hl, wChannelPitchSlideLengthModifiers
@ -461,8 +461,8 @@ Audio1_pitch_slide:
jp Audio1_note_length
Audio1_duty_cycle:
cp $ec ; is this command a duty_cycle?
jr nz, Audio1_tempo ; no
cp duty_cycle_cmd
jr nz, Audio1_tempo
call Audio1_GetNextMusicByte
rrca
rrca
@ -474,8 +474,8 @@ Audio1_duty_cycle:
jp Audio1_sound_ret
Audio1_tempo:
cp $ed ; is this command a tempo?
jr nz, Audio1_stereo_panning ; no
cp tempo_cmd
jr nz, Audio1_stereo_panning
ld a, c
cp Ch5
jr nc, .sfxChannel
@ -503,16 +503,16 @@ Audio1_tempo:
jp Audio1_sound_ret
Audio1_stereo_panning:
cp $ee ; is this command a stereo_panning?
jr nz, Audio1_unknownmusic0xef ; no
cp stereo_panning_cmd
jr nz, Audio1_unknownmusic0xef
call Audio1_GetNextMusicByte
ld [wStereoPanning], a ; store panning
jp Audio1_sound_ret
; this appears to never be used
Audio1_unknownmusic0xef:
cp $ef ; is this command an unknownmusic0xef?
jr nz, Audio1_duty_cycle_pattern ; no
cp unknownmusic0xef_cmd
jr nz, Audio1_duty_cycle_pattern
call Audio1_GetNextMusicByte
push bc
call Audio1_PlaySound
@ -528,8 +528,8 @@ Audio1_unknownmusic0xef:
jp Audio1_sound_ret
Audio1_duty_cycle_pattern:
cp $fc ; is this command a duty_cycle_pattern?
jr nz, Audio1_volume ; no
cp duty_cycle_pattern_cmd
jr nz, Audio1_volume
call Audio1_GetNextMusicByte
ld b, 0
ld hl, wChannelDutyCyclePatterns
@ -545,15 +545,15 @@ Audio1_duty_cycle_pattern:
jp Audio1_sound_ret
Audio1_volume:
cp $f0 ; is this command a volume?
jr nz, Audio1_execute_music ; no
cp volume_cmd
jr nz, Audio1_execute_music
call Audio1_GetNextMusicByte
ldh [rNR50], a ; store volume
jp Audio1_sound_ret
Audio1_execute_music:
cp $f8 ; is this command an execute_music?
jr nz, Audio1_octave ; no
cp execute_music_cmd
jr nz, Audio1_octave
ld b, $0
ld hl, wChannelFlags2
add hl, bc
@ -562,8 +562,8 @@ Audio1_execute_music:
Audio1_octave:
and $f0
cp $e0 ; is this command an octave?
jr nz, Audio1_sfx_note ; no
cp octave_cmd
jr nz, Audio1_sfx_note
ld hl, wChannelOctaves
ld b, 0
add hl, bc
@ -574,7 +574,7 @@ Audio1_octave:
; sfx_note is either square_note or noise_note depending on the channel
Audio1_sfx_note:
cp $20 ; is this command a sfx_note?
cp sfx_note_cmd
jr nz, Audio1_pitch_sweep
ld a, c
cp Ch4 ; is this a noise or sfx channel?
@ -630,8 +630,8 @@ Audio1_pitch_sweep:
cp Ch5
jr c, Audio1_note ; if not a sfx
ld a, d
cp $10 ; is this command a pitch_sweep?
jr nz, Audio1_note ; no
cp pitch_sweep_cmd
jr nz, Audio1_note
ld b, $0
ld hl, wChannelFlags2
add hl, bc
@ -647,12 +647,12 @@ Audio1_note:
jr nz, Audio1_note_length ; if not noise channel
ld a, d
and $f0
cp $b0 ; is this command a drum_note?
cp drum_note_cmd
jr z, .drum_note
jr nc, Audio1_note_length ; no
jr nc, Audio1_note_length
; this executes when on the noise channel and
; the command id is less than $b0
; the command id is less than drum_note_cmd ($b0)
; in this case, the upper nybble is used as the noise instrument ($1-$a)
; and the lower nybble is the length minus 1 (0-15)
; however, this doesn't work for instrument #2 because the command id
@ -748,7 +748,7 @@ Audio1_note_length:
Audio1_note_pitch:
pop af
and $f0
cp $c0 ; compare to rest
cp rest_cmd
jr nz, .notRest
ld a, c
cp Ch5
@ -1330,7 +1330,7 @@ Audio1_CalculateFrequency:
Audio1_PlaySound::
ld [wSoundID], a
cp $ff
cp SFX_STOP_ALL_MUSIC
jp z, .stopAllAudio
cp MAX_SFX_ID_1
jp z, .playSfx

View file

@ -43,7 +43,7 @@ Audio2_ApplyMusicAffects:
ld hl, wChannelNoteDelayCounters ; delay until next note
add hl, bc
ld a, [hl]
cp $1 ; if the delay is 1, play next note
cp 1 ; if the delay is 1, play next note
jp z, Audio2_PlayNextNote
dec a ; otherwise, decrease the delay timer
ld [hl], a
@ -174,8 +174,8 @@ Audio2_PlayNextNote:
Audio2_sound_ret:
call Audio2_GetNextMusicByte
ld d, a
cp $ff ; is this command a sound_ret?
jp nz, Audio2_sound_call ; no
cp sound_ret_cmd
jp nz, Audio2_sound_call
ld b, 0
ld hl, wChannelFlags1
add hl, bc
@ -262,8 +262,8 @@ Audio2_sound_ret:
ret
Audio2_sound_call:
cp $fd ; is this command a sound_call?
jp nz, Audio2_sound_loop ; no
cp sound_call_cmd
jp nz, Audio2_sound_loop
call Audio2_GetNextMusicByte
push af
call Audio2_GetNextMusicByte
@ -299,8 +299,8 @@ Audio2_sound_call:
jp Audio2_sound_ret
Audio2_sound_loop:
cp $fe ; is this command a sound_loop?
jp nz, Audio2_note_type ; no
cp sound_loop_cmd
jp nz, Audio2_note_type
call Audio2_GetNextMusicByte
ld e, a
and a
@ -338,8 +338,8 @@ Audio2_sound_loop:
Audio2_note_type:
and $f0
cp $d0 ; is this command a note_type?
jp nz, Audio2_toggle_perfect_pitch ; no
cp note_type_cmd
jp nz, Audio2_toggle_perfect_pitch
ld a, d
and $f
ld b, $0
@ -382,8 +382,8 @@ Audio2_note_type:
Audio2_toggle_perfect_pitch:
ld a, d
cp $e8 ; is this command a toggle_perfect_pitch?
jr nz, Audio2_vibrato ; no
cp toggle_perfect_pitch_cmd
jr nz, Audio2_vibrato
ld b, 0
ld hl, wChannelFlags1
add hl, bc
@ -393,8 +393,8 @@ Audio2_toggle_perfect_pitch:
jp Audio2_sound_ret
Audio2_vibrato:
cp $ea ; is this command a vibrato?
jr nz, Audio2_pitch_slide ; no
cp vibrato_cmd
jr nz, Audio2_pitch_slide
call Audio2_GetNextMusicByte
ld b, 0
ld hl, wChannelVibratoDelayCounters
@ -441,8 +441,8 @@ Audio2_vibrato:
jp Audio2_sound_ret
Audio2_pitch_slide:
cp $eb ; is this command a pitch_slide?
jr nz, Audio2_duty_cycle ; no
cp pitch_slide_cmd
jr nz, Audio2_duty_cycle
call Audio2_GetNextMusicByte
ld b, 0
ld hl, wChannelPitchSlideLengthModifiers
@ -472,8 +472,8 @@ Audio2_pitch_slide:
jp Audio2_note_length
Audio2_duty_cycle:
cp $ec ; is this command a duty_cycle?
jr nz, Audio2_tempo ; no
cp duty_cycle_cmd
jr nz, Audio2_tempo
call Audio2_GetNextMusicByte
rrca
rrca
@ -485,8 +485,8 @@ Audio2_duty_cycle:
jp Audio2_sound_ret
Audio2_tempo:
cp $ed ; is this command a tempo?
jr nz, Audio2_stereo_panning ; no
cp tempo_cmd
jr nz, Audio2_stereo_panning
ld a, c
cp Ch5
jr nc, .sfxChannel
@ -514,16 +514,16 @@ Audio2_tempo:
jp Audio2_sound_ret
Audio2_stereo_panning:
cp $ee ; is this command a stereo_panning?
jr nz, Audio2_unknownmusic0xef ; no
cp stereo_panning_cmd
jr nz, Audio2_unknownmusic0xef
call Audio2_GetNextMusicByte
ld [wStereoPanning], a ; store panning
jp Audio2_sound_ret
; this appears to never be used
Audio2_unknownmusic0xef:
cp $ef ; is this command an unknownmusic0xef?
jr nz, Audio2_duty_cycle_pattern ; no
cp unknownmusic0xef_cmd
jr nz, Audio2_duty_cycle_pattern
call Audio2_GetNextMusicByte
push bc
call Audio2_PlaySound
@ -539,8 +539,8 @@ Audio2_unknownmusic0xef:
jp Audio2_sound_ret
Audio2_duty_cycle_pattern:
cp $fc ; is this command a duty_cycle_pattern?
jr nz, Audio2_volume ; no
cp duty_cycle_pattern_cmd
jr nz, Audio2_volume
call Audio2_GetNextMusicByte
ld b, 0
ld hl, wChannelDutyCyclePatterns
@ -556,15 +556,15 @@ Audio2_duty_cycle_pattern:
jp Audio2_sound_ret
Audio2_volume:
cp $f0 ; is this command a volume?
jr nz, Audio2_execute_music ; no
cp volume_cmd
jr nz, Audio2_execute_music
call Audio2_GetNextMusicByte
ldh [rNR50], a ; store volume
jp Audio2_sound_ret
Audio2_execute_music:
cp $f8 ; is this command an execute_music?
jr nz, Audio2_octave ; no
cp execute_music_cmd
jr nz, Audio2_octave
ld b, $0
ld hl, wChannelFlags2
add hl, bc
@ -573,8 +573,8 @@ Audio2_execute_music:
Audio2_octave:
and $f0
cp $e0 ; is this command an octave?
jr nz, Audio2_sfx_note ; no
cp octave_cmd
jr nz, Audio2_sfx_note
ld hl, wChannelOctaves
ld b, 0
add hl, bc
@ -585,7 +585,7 @@ Audio2_octave:
; sfx_note is either square_note or noise_note depending on the channel
Audio2_sfx_note:
cp $20 ; is this command a sfx_note?
cp sfx_note_cmd
jr nz, Audio2_pitch_sweep
ld a, c
cp Ch4 ; is this a noise or sfx channel?
@ -641,8 +641,8 @@ Audio2_pitch_sweep:
cp Ch5
jr c, Audio2_note ; if not a sfx
ld a, d
cp $10 ; is this command a pitch_sweep?
jr nz, Audio2_note ; no
cp pitch_sweep_cmd
jr nz, Audio2_note
ld b, $0
ld hl, wChannelFlags2
add hl, bc
@ -658,12 +658,12 @@ Audio2_note:
jr nz, Audio2_note_length ; if not noise channel
ld a, d
and $f0
cp $b0 ; is this command a drum_note?
cp drum_note_cmd
jr z, .drum_note
jr nc, Audio2_note_length ; no
jr nc, Audio2_note_length
; this executes when on the noise channel and
; the command id is less than $b0
; the command id is less than drum_note_cmd ($b0)
; in this case, the upper nybble is used as the noise instrument ($1-$a)
; and the lower nybble is the length minus 1 (0-15)
; however, this doesn't work for instrument #2 because the command id
@ -759,7 +759,7 @@ Audio2_note_length:
Audio2_note_pitch:
pop af
and $f0
cp $c0 ; compare to rest
cp rest_cmd
jr nz, .notRest
ld a, c
cp Ch5
@ -1393,7 +1393,7 @@ Audio2_CalculateFrequency:
Audio2_PlaySound::
ld [wSoundID], a
cp $ff
cp SFX_STOP_ALL_MUSIC
jp z, .stopAllAudio
cp MAX_SFX_ID_2
jp z, .playSfx

View file

@ -41,7 +41,7 @@ Audio3_ApplyMusicAffects:
ld hl, wChannelNoteDelayCounters ; delay until next note
add hl, bc
ld a, [hl]
cp $1 ; if the delay is 1, play next note
cp 1 ; if the delay is 1, play next note
jp z, Audio3_PlayNextNote
dec a ; otherwise, decrease the delay timer
ld [hl], a
@ -163,8 +163,8 @@ Audio3_PlayNextNote:
Audio3_sound_ret:
call Audio3_GetNextMusicByte
ld d, a
cp $ff ; is this command a sound_ret?
jp nz, Audio3_sound_call ; no
cp sound_ret_cmd
jp nz, Audio3_sound_call
ld b, 0
ld hl, wChannelFlags1
add hl, bc
@ -251,8 +251,8 @@ Audio3_sound_ret:
ret
Audio3_sound_call:
cp $fd ; is this command a sound_call?
jp nz, Audio3_sound_loop ; no
cp sound_call_cmd
jp nz, Audio3_sound_loop
call Audio3_GetNextMusicByte
push af
call Audio3_GetNextMusicByte
@ -288,8 +288,8 @@ Audio3_sound_call:
jp Audio3_sound_ret
Audio3_sound_loop:
cp $fe ; is this command a sound_loop?
jp nz, Audio3_note_type ; no
cp sound_loop_cmd
jp nz, Audio3_note_type
call Audio3_GetNextMusicByte
ld e, a
and a
@ -327,8 +327,8 @@ Audio3_sound_loop:
Audio3_note_type:
and $f0
cp $d0 ; is this command a note_type?
jp nz, Audio3_toggle_perfect_pitch ; no
cp note_type_cmd
jp nz, Audio3_toggle_perfect_pitch
ld a, d
and $f
ld b, $0
@ -371,8 +371,8 @@ Audio3_note_type:
Audio3_toggle_perfect_pitch:
ld a, d
cp $e8 ; is this command a toggle_perfect_pitch?
jr nz, Audio3_vibrato ; no
cp toggle_perfect_pitch_cmd
jr nz, Audio3_vibrato
ld b, 0
ld hl, wChannelFlags1
add hl, bc
@ -382,8 +382,8 @@ Audio3_toggle_perfect_pitch:
jp Audio3_sound_ret
Audio3_vibrato:
cp $ea ; is this command a vibrato?
jr nz, Audio3_pitch_slide ; no
cp vibrato_cmd
jr nz, Audio3_pitch_slide
call Audio3_GetNextMusicByte
ld b, 0
ld hl, wChannelVibratoDelayCounters
@ -430,8 +430,8 @@ Audio3_vibrato:
jp Audio3_sound_ret
Audio3_pitch_slide:
cp $eb ; is this command a pitch_slide?
jr nz, Audio3_duty_cycle ; no
cp pitch_slide_cmd
jr nz, Audio3_duty_cycle
call Audio3_GetNextMusicByte
ld b, 0
ld hl, wChannelPitchSlideLengthModifiers
@ -461,8 +461,8 @@ Audio3_pitch_slide:
jp Audio3_note_length
Audio3_duty_cycle:
cp $ec ; is this command a duty_cycle?
jr nz, Audio3_tempo ; no
cp duty_cycle_cmd
jr nz, Audio3_tempo
call Audio3_GetNextMusicByte
rrca
rrca
@ -474,8 +474,8 @@ Audio3_duty_cycle:
jp Audio3_sound_ret
Audio3_tempo:
cp $ed ; is this command a tempo?
jr nz, Audio3_stereo_panning ; no
cp tempo_cmd
jr nz, Audio3_stereo_panning
ld a, c
cp Ch5
jr nc, .sfxChannel
@ -503,16 +503,16 @@ Audio3_tempo:
jp Audio3_sound_ret
Audio3_stereo_panning:
cp $ee ; is this command a stereo_panning?
jr nz, Audio3_unknownmusic0xef ; no
cp stereo_panning_cmd
jr nz, Audio3_unknownmusic0xef
call Audio3_GetNextMusicByte
ld [wStereoPanning], a ; store panning
jp Audio3_sound_ret
; this appears to never be used
Audio3_unknownmusic0xef:
cp $ef ; is this command an unknownmusic0xef?
jr nz, Audio3_duty_cycle_pattern ; no
cp unknownmusic0xef_cmd
jr nz, Audio3_duty_cycle_pattern
call Audio3_GetNextMusicByte
push bc
call Audio3_PlaySound
@ -528,8 +528,8 @@ Audio3_unknownmusic0xef:
jp Audio3_sound_ret
Audio3_duty_cycle_pattern:
cp $fc ; is this command a duty_cycle_pattern?
jr nz, Audio3_volume ; no
cp duty_cycle_pattern_cmd
jr nz, Audio3_volume
call Audio3_GetNextMusicByte
ld b, 0
ld hl, wChannelDutyCyclePatterns
@ -545,15 +545,15 @@ Audio3_duty_cycle_pattern:
jp Audio3_sound_ret
Audio3_volume:
cp $f0 ; is this command a volume?
jr nz, Audio3_execute_music ; no
cp volume_cmd
jr nz, Audio3_execute_music
call Audio3_GetNextMusicByte
ldh [rNR50], a ; store volume
jp Audio3_sound_ret
Audio3_execute_music:
cp $f8 ; is this command an execute_music?
jr nz, Audio3_octave ; no
cp execute_music_cmd
jr nz, Audio3_octave
ld b, $0
ld hl, wChannelFlags2
add hl, bc
@ -562,8 +562,8 @@ Audio3_execute_music:
Audio3_octave:
and $f0
cp $e0 ; is this command an octave?
jr nz, Audio3_sfx_note ; no
cp octave_cmd
jr nz, Audio3_sfx_note
ld hl, wChannelOctaves
ld b, 0
add hl, bc
@ -574,7 +574,7 @@ Audio3_octave:
; sfx_note is either square_note or noise_note depending on the channel
Audio3_sfx_note:
cp $20 ; is this command a sfx_note?
cp sfx_note_cmd
jr nz, Audio3_pitch_sweep
ld a, c
cp Ch4 ; is this a noise or sfx channel?
@ -630,8 +630,8 @@ Audio3_pitch_sweep:
cp Ch5
jr c, Audio3_note ; if not a sfx
ld a, d
cp $10 ; is this command a pitch_sweep?
jr nz, Audio3_note ; no
cp pitch_sweep_cmd
jr nz, Audio3_note
ld b, $0
ld hl, wChannelFlags2
add hl, bc
@ -647,12 +647,12 @@ Audio3_note:
jr nz, Audio3_note_length ; if not noise channel
ld a, d
and $f0
cp $b0 ; is this command a drum_note?
cp drum_note_cmd
jr z, .drum_note
jr nc, Audio3_note_length ; no
jr nc, Audio3_note_length
; this executes when on the noise channel and
; the command id is less than $b0
; the command id is less than drum_note_cmd ($b0)
; in this case, the upper nybble is used as the noise instrument ($1-$a)
; and the lower nybble is the length minus 1 (0-15)
; however, this doesn't work for instrument #2 because the command id
@ -748,7 +748,7 @@ Audio3_note_length:
Audio3_note_pitch:
pop af
and $f0
cp $c0 ; compare to rest
cp rest_cmd
jr nz, .notRest
ld a, c
cp Ch5
@ -1330,7 +1330,7 @@ Audio3_CalculateFrequency:
Audio3_PlaySound::
ld [wSoundID], a
cp $ff
cp SFX_STOP_ALL_MUSIC
jp z, .stopAllAudio
cp MAX_SFX_ID_3
jp z, .playSfx