summaryrefslogtreecommitdiff
path: root/audio/engine_1.asm
diff options
context:
space:
mode:
authordannye <33dannye@gmail.com>2020-05-20 19:40:33 -0500
committerdannye <33dannye@gmail.com>2020-05-20 20:02:53 -0500
commit10f9559eab8c93b94abb8ae8d1083704ad4e169a (patch)
tree7dbe7b152dde8a6e9b56664b5b8cdfc0d6be1253 /audio/engine_1.asm
parentb8954732a3eaa3a784a6e3eaaa68977a9ccd9816 (diff)
Sync with pokered
Diffstat (limited to 'audio/engine_1.asm')
-rw-r--r--audio/engine_1.asm448
1 files changed, 228 insertions, 220 deletions
diff --git a/audio/engine_1.asm b/audio/engine_1.asm
index bb780975..bd021ab3 100644
--- a/audio/engine_1.asm
+++ b/audio/engine_1.asm
@@ -1,7 +1,7 @@
; The first of three duplicated sound engines.
Audio1_UpdateMusic::
- ld c, CH0
+ ld c, Ch1
.loop
ld b, 0
ld hl, wChannelSoundIDs
@@ -10,7 +10,7 @@ Audio1_UpdateMusic::
and a
jr z, .nextChannel
ld a, c
- cp CH4
+ cp Ch5
jr nc, .applyAffects ; if sfx channel
ld a, [wMuteAudioAndPauseMusic]
and a
@@ -30,7 +30,7 @@ Audio1_UpdateMusic::
.nextChannel
ld a, c
inc c ; inc channel number
- cp CH7
+ cp Ch8
jr nz, .loop
ret
@@ -46,9 +46,9 @@ Audio1_ApplyMusicAffects:
dec a ; otherwise, decrease the delay timer
ld [hl], a
ld a, c
- cp CH4
+ cp Ch5
jr nc, .startChecks ; if a sfx channel
- ld hl, wChannelSoundIDs + CH4
+ ld hl, wChannelSoundIDs + Ch5
add hl, bc
ld a, [hl]
and a
@@ -57,25 +57,25 @@ Audio1_ApplyMusicAffects:
.startChecks
ld hl, wChannelFlags1
add hl, bc
- bit BIT_ROTATE_DUTY, [hl]
+ bit BIT_ROTATE_DUTY_CYCLE, [hl]
jr z, .checkForExecuteMusic
- call Audio1_ApplyDutyCycle
+ call Audio1_ApplyDutyCyclePattern
.checkForExecuteMusic
ld b, 0
ld hl, wChannelFlags2
add hl, bc
bit BIT_EXECUTE_MUSIC, [hl]
- jr nz, .checkForPitchBend
+ jr nz, .checkForPitchSlide
ld hl, wChannelFlags1
add hl, bc
bit BIT_NOISE_OR_SFX, [hl]
- jr nz, .skipPitchBendVibrato
-.checkForPitchBend
+ jr nz, .skipPitchSlideVibrato
+.checkForPitchSlide
ld hl, wChannelFlags1
add hl, bc
- bit BIT_PITCH_BEND_ON, [hl]
+ bit BIT_PITCH_SLIDE_ON, [hl]
jr z, .checkVibratoDelay
- jp Audio1_ApplyPitchBend
+ jp Audio1_ApplyPitchSlide
.checkVibratoDelay
ld hl, wChannelVibratoDelayCounters
add hl, bc
@@ -83,7 +83,7 @@ Audio1_ApplyMusicAffects:
and a ; check if delay is over
jr z, .checkForVibrato
dec [hl] ; otherwise, dec delay
-.skipPitchBendVibrato
+.skipPitchSlideVibrato
ret
.checkForVibrato
ld hl, wChannelVibratoExtents
@@ -142,7 +142,7 @@ Audio1_ApplyMusicAffects:
ret
; this routine executes all music commands that take up no time,
-; like tempo changes, duty changes etc. and doesn't return
+; like tempo changes, duty cycle changes etc. and doesn't return
; until the first note is reached
Audio1_PlayNextNote:
; reload the vibrato delay counter
@@ -155,8 +155,8 @@ Audio1_PlayNextNote:
ld hl, wChannelFlags1
add hl, bc
- res BIT_PITCH_BEND_ON, [hl]
- res BIT_PITCH_BEND_DECREASING, [hl]
+ res BIT_PITCH_SLIDE_ON, [hl]
+ res BIT_PITCH_SLIDE_DECREASING, [hl]
ld a, c
cp $4
jr nz, .asm_918c
@@ -166,21 +166,21 @@ Audio1_PlayNextNote:
call Audio1_EnableChannelOutput
ret
.asm_918c
- call Audio1_endchannel
+ call Audio1_sound_ret
ret
-Audio1_endchannel:
+Audio1_sound_ret:
call Audio1_GetNextMusicByte
ld d, a
- cp $ff ; is this command an endchannel?
- jp nz, Audio1_callchannel ; no
+ cp $ff ; is this command a sound_ret?
+ jp nz, Audio1_sound_call ; no
ld b, 0
ld hl, wChannelFlags1
add hl, bc
- bit BIT_CHANNEL_CALL, [hl]
+ bit BIT_SOUND_CALL, [hl]
jr nz, .returnFromCall
ld a, c
- cp CH3
+ cp Ch4
jr nc, .noiseOrSfxChannel
jr .disableChannelOutput
.noiseOrSfxChannel
@@ -188,7 +188,7 @@ Audio1_endchannel:
ld hl, wChannelFlags2
add hl, bc
res BIT_EXECUTE_MUSIC, [hl]
- cp CH6
+ cp Ch7
jr nz, .skipSfxChannel3
; restart hardware channel 3 (wave channel) output
ld a, $0
@@ -196,15 +196,15 @@ Audio1_endchannel:
ld a, $80
ld [rNR30], a
.skipSfxChannel3
- jr nz, .asm_9222
+ jr nz, .dontDisable
ld a, [wDisableChannelOutputWhenSfxEnds]
and a
- jr z, .asm_9222
+ jr z, .dontDisable
xor a
ld [wDisableChannelOutputWhenSfxEnds], a
jr .disableChannelOutput
-.asm_9222
- jr .asm_9248
+.dontDisable
+ jr .afterDisable
.returnFromCall
res 1, [hl]
ld d, $0
@@ -224,31 +224,31 @@ Audio1_endchannel:
inc de
ld a, [de]
ld [hl], a ; loads channel address to return to
- jp Audio1_endchannel
+ jp Audio1_sound_ret
.disableChannelOutput
ld hl, Audio1_HWChannelDisableMasks
add hl, bc
ld a, [rNR51]
and [hl]
ld [rNR51], a
-.asm_9248
- ld a, [wChannelSoundIDs + CH4]
+.afterDisable
+ ld a, [wChannelSoundIDs + Ch5]
cp CRY_SFX_START
- jr nc, .asm_9251
+ jr nc, .maybeCry
jr .skipCry
-.asm_9251
- ld a, [wChannelSoundIDs + CH4]
+.maybeCry
+ ld a, [wChannelSoundIDs + Ch5]
cp CRY_SFX_END
jr z, .skipCry
jr c, .cry
jr .skipCry
.cry
ld a, c
- cp CH4
- jr z, .asm_9265
+ cp Ch5
+ jr z, .skipRewind
call Audio1_GoBackOneCommandIfCry
ret c
-.asm_9265
+.skipRewind
ld a, [wSavedVolume]
ld [rNR50], a
xor a
@@ -259,9 +259,9 @@ Audio1_endchannel:
ld [hl], b
ret
-Audio1_callchannel:
- cp $fd ; is this command a callchannel?
- jp nz, Audio1_loopchannel ; no
+Audio1_sound_call:
+ cp $fd ; is this command a sound_call?
+ jp nz, Audio1_sound_loop ; no
call Audio1_GetNextMusicByte
push af
call Audio1_GetNextMusicByte
@@ -293,12 +293,12 @@ Audio1_callchannel:
ld b, $0
ld hl, wChannelFlags1
add hl, bc
- set BIT_CHANNEL_CALL, [hl] ; set the call flag
- jp Audio1_endchannel
+ set BIT_SOUND_CALL, [hl] ; set the call flag
+ jp Audio1_sound_ret
-Audio1_loopchannel:
- cp $fe ; is this command a loopchannel?
- jp nz, Audio1_notetype ; no
+Audio1_sound_loop:
+ cp $fe ; is this command a sound_loop?
+ jp nz, Audio1_note_type ; no
call Audio1_GetNextMusicByte
ld e, a
and a
@@ -313,7 +313,7 @@ Audio1_loopchannel:
ld [hl], a
call Audio1_GetNextMusicByte ; skip pointer
call Audio1_GetNextMusicByte
- jp Audio1_endchannel
+ jp Audio1_sound_ret
.loopAgain ; inc loop count
inc a
ld [hl], a
@@ -332,12 +332,12 @@ Audio1_loopchannel:
pop af
ld [hli], a
ld [hl], b
- jp Audio1_endchannel
+ jp Audio1_sound_ret
-Audio1_notetype:
+Audio1_note_type:
and $f0
- cp $d0 ; is this command a notetype?
- jp nz, Audio1_toggleperfectpitch ; no
+ cp $d0 ; is this command a note_type?
+ jp nz, Audio1_toggle_perfect_pitch ; no
ld a, d
and $f
ld b, $0
@@ -345,14 +345,14 @@ Audio1_notetype:
add hl, bc
ld [hl], a ; store low nibble as speed
ld a, c
- cp CH3
+ cp Ch4
jr z, .noiseChannel ; noise channel has 0 params
call Audio1_GetNextMusicByte
ld d, a
ld a, c
- cp CH2
+ cp Ch3
jr z, .musicChannel3
- cp CH6
+ cp Ch7
jr nz, .skipChannel3
ld hl, wSfxWaveInstrument
jr .channel3
@@ -376,11 +376,11 @@ Audio1_notetype:
add hl, bc
ld [hl], d
.noiseChannel
- jp Audio1_endchannel
+ jp Audio1_sound_ret
-Audio1_toggleperfectpitch:
+Audio1_toggle_perfect_pitch:
ld a, d
- cp $e8 ; is this command a toggleperfectpitch?
+ cp $e8 ; is this command a toggle_perfect_pitch?
jr nz, Audio1_vibrato ; no
ld b, 0
ld hl, wChannelFlags1
@@ -388,11 +388,11 @@ Audio1_toggleperfectpitch:
ld a, [hl]
xor $1
ld [hl], a ; flip bit 0 of wChannelFlags1
- jp Audio1_endchannel
+ jp Audio1_sound_ret
Audio1_vibrato:
cp $ea ; is this command a vibrato?
- jr nz, Audio1_pitchbend ; no
+ jr nz, Audio1_pitch_slide ; no
call Audio1_GetNextMusicByte
ld b, 0
ld hl, wChannelVibratoDelayCounters
@@ -436,14 +436,14 @@ Audio1_vibrato:
or d
ld [hl], a
- jp Audio1_endchannel
+ jp Audio1_sound_ret
-Audio1_pitchbend:
- cp $eb ; is this command a pitchbend?
- jr nz, Audio1_duty ; no
+Audio1_pitch_slide:
+ cp $eb ; is this command a pitch_slide?
+ jr nz, Audio1_duty_cycle ; no
call Audio1_GetNextMusicByte
ld b, 0
- ld hl, wChannelPitchBendLengthModifiers
+ ld hl, wChannelPitchSlideLengthModifiers
add hl, bc
ld [hl], a
call Audio1_GetNextMusicByte
@@ -455,38 +455,38 @@ Audio1_pitchbend:
and $f
call Audio1_CalculateFrequency
ld b, 0
- ld hl, wChannelPitchBendTargetFrequencyHighBytes
+ ld hl, wChannelPitchSlideTargetFrequencyHighBytes
add hl, bc
ld [hl], d
- ld hl, wChannelPitchBendTargetFrequencyLowBytes
+ ld hl, wChannelPitchSlideTargetFrequencyLowBytes
add hl, bc
ld [hl], e
ld b, 0
ld hl, wChannelFlags1
add hl, bc
- set BIT_PITCH_BEND_ON, [hl]
+ set BIT_PITCH_SLIDE_ON, [hl]
call Audio1_GetNextMusicByte
ld d, a
- jp Audio1_notelength
+ jp Audio1_note_length
-Audio1_duty:
- cp $ec ; is this command a duty?
+Audio1_duty_cycle:
+ cp $ec ; is this command a duty_cycle?
jr nz, Audio1_tempo ; no
call Audio1_GetNextMusicByte
rrca
rrca
and $c0
ld b, 0
- ld hl, wChannelDuties
+ ld hl, wChannelDutyCycles
add hl, bc
- ld [hl], a ; store duty
- jp Audio1_endchannel
+ ld [hl], a ; store duty cycle
+ jp Audio1_sound_ret
Audio1_tempo:
cp $ed ; is this command a tempo?
- jr nz, Audio1_stereopanning ; no
+ jr nz, Audio1_stereo_panning ; no
ld a, c
- cp CH4
+ cp Ch5
jr nc, .sfxChannel
call Audio1_GetNextMusicByte
ld [wMusicTempo], a ; store first param
@@ -509,19 +509,19 @@ Audio1_tempo:
ld [wChannelNoteDelayCountersFractionalPart + 6], a
ld [wChannelNoteDelayCountersFractionalPart + 7], a
.musicChannelDone
- jp Audio1_endchannel
+ jp Audio1_sound_ret
-Audio1_stereopanning:
- cp $ee ; is this command a stereopanning?
+Audio1_stereo_panning:
+ cp $ee ; is this command a stereo_panning?
jr nz, Audio1_unknownmusic0xef ; no
call Audio1_GetNextMusicByte
ld [wStereoPanning], a ; store panning
- jp Audio1_endchannel
+ jp Audio1_sound_ret
; this appears to never be used
Audio1_unknownmusic0xef:
cp $ef ; is this command an unknownmusic0xef?
- jr nz, Audio1_dutycycle ; no
+ jr nz, Audio1_duty_cycle_pattern ; no
call Audio1_GetNextMusicByte
push bc
ld b, a
@@ -530,76 +530,77 @@ Audio1_unknownmusic0xef:
ld a, [wDisableChannelOutputWhenSfxEnds]
and a
jr nz, .skip
- ld a, [wChannelSoundIDs + CH7]
+ ld a, [wChannelSoundIDs + Ch8]
ld [wDisableChannelOutputWhenSfxEnds], a
xor a
- ld [wChannelSoundIDs + CH7], a
+ ld [wChannelSoundIDs + Ch8], a
.skip
- jp Audio1_endchannel
+ jp Audio1_sound_ret
-Audio1_dutycycle:
- cp $fc ; is this command a dutycycle?
+Audio1_duty_cycle_pattern:
+ cp $fc ; is this command a duty_cycle_pattern?
jr nz, Audio1_volume ; no
call Audio1_GetNextMusicByte
ld b, 0
- ld hl, wChannelDutyCycles
+ ld hl, wChannelDutyCyclePatterns
add hl, bc
- ld [hl], a ; store full cycle
- and $c0
- ld hl, wChannelDuties
+ ld [hl], a ; store full pattern
+ and %11000000
+ ld hl, wChannelDutyCycles
add hl, bc
- ld [hl], a ; store first duty
+ ld [hl], a ; store first duty cycle
ld hl, wChannelFlags1
add hl, bc
- set BIT_ROTATE_DUTY, [hl]
- jp Audio1_endchannel
+ set BIT_ROTATE_DUTY_CYCLE, [hl]
+ jp Audio1_sound_ret
Audio1_volume:
cp $f0 ; is this command a volume?
- jr nz, Audio1_executemusic ; no
+ jr nz, Audio1_execute_music ; no
call Audio1_GetNextMusicByte
ld [rNR50], a ; store volume
- jp Audio1_endchannel
+ jp Audio1_sound_ret
-Audio1_executemusic:
- cp $f8 ; is this command an executemusic?
+Audio1_execute_music:
+ cp $f8 ; is this command an execute_music?
jr nz, Audio1_octave ; no
ld b, $0
ld hl, wChannelFlags2
add hl, bc
set BIT_EXECUTE_MUSIC, [hl]
- jp Audio1_endchannel
+ jp Audio1_sound_ret
Audio1_octave:
and $f0
cp $e0 ; is this command an octave?
- jr nz, Audio1_unknownsfx0x20 ; no
+ jr nz, Audio1_sfx_note ; no
ld hl, wChannelOctaves
ld b, 0
add hl, bc
ld a, d
and $f
ld [hl], a ; store low nibble as octave
- jp Audio1_endchannel
+ jp Audio1_sound_ret
-Audio1_unknownsfx0x20:
- cp $20 ; is this command an unknownsfx0x20?
- jr nz, Audio1_unknownsfx0x10
+; sfx_note is either square_note or noise_note depending on the channel
+Audio1_sfx_note:
+ cp $20 ; is this command a sfx_note?
+ jr nz, Audio1_pitch_sweep
ld a, c
- cp CH3 ; is this a noise or sfx channel?
- jr c, Audio1_unknownsfx0x10 ; no
+ cp Ch4 ; is this a noise or sfx channel?
+ jr c, Audio1_pitch_sweep ; no
ld b, 0
ld hl, wChannelFlags2
add hl, bc
- bit BIT_EXECUTE_MUSIC, [hl] ; is executemusic being used?
- jr nz, Audio1_unknownsfx0x10 ; yes
- call Audio1_notelength
+ bit BIT_EXECUTE_MUSIC, [hl] ; is execute_music being used?
+ jr nz, Audio1_pitch_sweep ; yes
+ call Audio1_note_length
-; This code seems to do the same thing as what Audio1_ApplyDutyAndSoundLength
+; This code seems to do the same thing as what Audio1_ApplyDutyCycleAndSoundLength
; does below.
ld d, a
ld b, 0
- ld hl, wChannelDuties
+ ld hl, wChannelDutyCycles
add hl, bc
ld a, [hl]
or d
@@ -616,7 +617,7 @@ Audio1_unknownsfx0x20:
call Audio1_GetNextMusicByte
ld e, a
ld a, c
- cp CH7
+ cp Ch8
ld a, 0
jr z, .skip
; Channels 1 through 3 have 2 registers that control frequency, but the noise
@@ -628,18 +629,18 @@ Audio1_unknownsfx0x20:
.skip
ld d, a
push de
- call Audio1_ApplyDutyAndSoundLength
+ call Audio1_ApplyDutyCycleAndSoundLength
call Audio1_EnableChannelOutput
pop de
call Audio1_ApplyWavePatternAndFrequency
ret
-Audio1_unknownsfx0x10:
+Audio1_pitch_sweep:
ld a, c
- cp CH4
+ cp Ch5
jr c, Audio1_note ; if not a sfx
ld a, d
- cp $10 ; is this command a unknownsfx0x10?
+ cp $10 ; is this command a pitch_sweep?
jr nz, Audio1_note ; no
ld b, $0
ld hl, wChannelFlags2
@@ -648,17 +649,27 @@ Audio1_unknownsfx0x10:
jr nz, Audio1_note ; no
call Audio1_GetNextMusicByte
ld [rNR10], a
- jp Audio1_endchannel
+ jp Audio1_sound_ret
Audio1_note:
ld a, c
- cp CH3
- jr nz, Audio1_notelength ; if not noise channel
+ cp Ch4
+ jr nz, Audio1_note_length ; if not noise channel
ld a, d
and $f0
- cp $b0 ; is this command a dnote?
- jr z, Audio1_dnote
- jr nc, Audio1_notelength ; no
+ cp $b0 ; is this command a drum_note?
+ jr z, .drum_note
+ jr nc, Audio1_note_length ; no
+
+ ; this executes when on the noise channel and
+ ; the command id is less than $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
+ ; is captured by the noise_note command (command id $2x)
+ ; this essentially acts like a drum_note command that is only 1 byte
+ ; instead of 2 and can only be used with instruments 1 and 3 through 10
+ ; this is unused by the game
swap a
ld b, a
ld a, d
@@ -667,26 +678,26 @@ Audio1_note:
ld a, b
push de
push bc
- jr asm_94fd
+ jr .playDnote
-Audio1_dnote:
+.drum_note
ld a, d
and $f
push af
push bc
- call Audio1_GetNextMusicByte ; get dnote instrument
-asm_94fd
+ call Audio1_GetNextMusicByte ; get drum_note instrument
+.playDnote
ld d, a
ld a, [wDisableChannelOutputWhenSfxEnds]
and a
- jr nz, .asm_9508
+ jr nz, .skipDnote
ld b, d
call DetermineAudioFunction
-.asm_9508
+.skipDnote
pop bc
pop de
-Audio1_notelength:
+Audio1_note_length:
ld a, d
push af
and $f
@@ -700,7 +711,7 @@ Audio1_notelength:
ld l, b
call Audio1_MultiplyAdd
ld a, c
- cp CH4
+ cp Ch5
jr nc, .sfxChannel
ld a, [wMusicTempo]
ld d, a
@@ -710,7 +721,7 @@ Audio1_notelength:
.sfxChannel
ld d, $1
ld e, $0
- cp CH7
+ cp Ch8
jr z, .skip ; if noise channel
call Audio1_SetSfxTempo
ld a, [wSfxTempo]
@@ -736,24 +747,24 @@ Audio1_notelength:
ld hl, wChannelFlags2
add hl, bc
bit BIT_EXECUTE_MUSIC, [hl]
- jr nz, Audio1_notepitch
+ jr nz, Audio1_note_pitch
ld hl, wChannelFlags1
add hl, bc
bit BIT_NOISE_OR_SFX, [hl]
- jr z, Audio1_notepitch
+ jr z, Audio1_note_pitch
pop hl
ret
-Audio1_notepitch:
+Audio1_note_pitch:
pop af
and $f0
cp $c0 ; compare to rest
jr nz, .notRest
ld a, c
- cp CH4
+ cp Ch5
jr nc, .next
; If this isn't an SFX channel, try the corresponding SFX channel.
- ld hl, wChannelSoundIDs + CH4
+ ld hl, wChannelSoundIDs + Ch5
add hl, bc
ld a, [hl]
and a
@@ -761,9 +772,9 @@ Audio1_notepitch:
; fall through
.next
ld a, c
- cp CH2
+ cp Ch3
jr z, .channel3
- cp CH6
+ cp Ch7
jr nz, .notChannel3
.channel3
ld b, 0
@@ -793,16 +804,16 @@ Audio1_notepitch:
ld b, 0
ld hl, wChannelFlags1
add hl, bc
- bit BIT_PITCH_BEND_ON, [hl]
- jr z, .skipPitchBend
- call Audio1_InitPitchBendVars
-.skipPitchBend
+ bit BIT_PITCH_SLIDE_ON, [hl]
+ jr z, .skipPitchSlide
+ call Audio1_InitPitchSlideVars
+.skipPitchSlide
push de
ld a, c
- cp CH4
+ cp Ch5
jr nc, .sfxChannel ; if sfx channel
; If this isn't an SFX channel, try the corresponding SFX channel.
- ld hl, wChannelSoundIDs + CH4
+ ld hl, wChannelSoundIDs + Ch5
ld d, 0
ld e, a
add hl, de
@@ -821,13 +832,13 @@ Audio1_notepitch:
ld b, REG_VOLUME_ENVELOPE
call Audio1_GetRegisterPointer
ld [hl], d
- call Audio1_ApplyDutyAndSoundLength
+ call Audio1_ApplyDutyCycleAndSoundLength
call Audio1_EnableChannelOutput
pop de
ld b, $0
ld hl, wChannelFlags1
add hl, bc
- bit BIT_PERFECT_PITCH, [hl] ; has toggleperfectpitch been used?
+ bit BIT_PERFECT_PITCH, [hl] ; has toggle_perfect_pitch been used?
jr z, .skipFrequencyInc
inc e ; if yes, increment the frequency by 1
jr nc, .skipFrequencyInc
@@ -847,12 +858,12 @@ Audio1_EnableChannelOutput:
or [hl] ; set this channel's bits
ld d, a
ld a, c
- cp CH7
+ cp Ch8
jr z, .noiseChannelOrNoSfx
- cp CH4
+ cp Ch5
jr nc, .skip ; if sfx channel
; If this isn't an SFX channel, try the corresponding SFX channel.
- ld hl, wChannelSoundIDs + CH4
+ ld hl, wChannelSoundIDs + Ch5
add hl, bc
ld a, [hl]
and a
@@ -876,21 +887,21 @@ Audio1_EnableChannelOutput:
ld [rNR51], a
ret
-Audio1_ApplyDutyAndSoundLength:
+Audio1_ApplyDutyCycleAndSoundLength:
ld b, 0
ld hl, wChannelNoteDelayCounters ; use the note delay as sound length
add hl, bc
ld d, [hl]
ld a, c
- cp CH2
+ cp Ch3
jr z, .skipDuty ; if music channel 3
- cp CH6
+ cp Ch7
jr z, .skipDuty ; if sfx channel 3
-; include duty (except on channel 3 which doesn't have it)
+; include duty cycle (except on channel 3 which doesn't have it)
ld a, d
and $3f
ld d, a
- ld hl, wChannelDuties
+ ld hl, wChannelDutyCycles
add hl, bc
ld a, [hl]
or d
@@ -903,15 +914,15 @@ Audio1_ApplyDutyAndSoundLength:
Audio1_ApplyWavePatternAndFrequency:
ld a, c
- cp CH2
+ cp Ch3
jr z, .channel3
- cp CH6
+ cp Ch7
jr nz, .notChannel3
; fall through
.channel3
push de
ld de, wMusicWaveInstrument
- cp CH2
+ cp Ch3
jr z, .next
ld de, wSfxWaveInstrument
.next
@@ -1035,7 +1046,7 @@ Audio1_GoBackOneCommandIfCry:
Audio1_IsCry:
; Returns whether the currently playing audio is a cry in carry.
- ld a, [wChannelSoundIDs + CH4]
+ ld a, [wChannelSoundIDs + Ch5]
cp CRY_SFX_START
jr nc, .next
jr .no
@@ -1055,9 +1066,9 @@ Audio1_96c3:
ld a, [wAudioROMBank]
cp BANK(AudioEngine2)
jr nz, .asm_96dc
- ld a, [wChannelSoundIDs + CH7]
+ ld a, [wChannelSoundIDs + Ch8]
ld b, a
- ld a, [wChannelSoundIDs + CH4]
+ ld a, [wChannelSoundIDs + Ch5]
or b
cp $9d
jr c, .asm_96dc
@@ -1071,29 +1082,29 @@ Audio1_96c3:
scf
ret
-Audio1_ApplyPitchBend:
+Audio1_ApplyPitchSlide:
ld hl, wChannelFlags1
add hl, bc
- bit BIT_PITCH_BEND_DECREASING, [hl]
+ bit BIT_PITCH_SLIDE_DECREASING, [hl]
jp nz, .frequencyDecreasing
; frequency increasing
- ld hl, wChannelPitchBendCurrentFrequencyLowBytes
+ ld hl, wChannelPitchSlideCurrentFrequencyLowBytes
add hl, bc
ld e, [hl]
- ld hl, wChannelPitchBendCurrentFrequencyHighBytes
+ ld hl, wChannelPitchSlideCurrentFrequencyHighBytes
add hl, bc
ld d, [hl]
- ld hl, wChannelPitchBendFrequencySteps
+ ld hl, wChannelPitchSlideFrequencySteps
add hl, bc
ld l, [hl]
ld h, b
add hl, de
ld d, h
ld e, l
- ld hl, wChannelPitchBendCurrentFrequencyFractionalPart
+ ld hl, wChannelPitchSlideCurrentFrequencyFractionalPart
add hl, bc
push hl
- ld hl, wChannelPitchBendFrequencyStepsFractionalPart
+ ld hl, wChannelPitchSlideFrequencyStepsFractionalPart
add hl, bc
ld a, [hl]
pop hl
@@ -1105,26 +1116,26 @@ Audio1_ApplyPitchBend:
ld a, 0
adc d
ld d, a
- ld hl, wChannelPitchBendTargetFrequencyHighBytes
+ ld hl, wChannelPitchSlideTargetFrequencyHighBytes
add hl, bc
ld a, [hl]
cp d
jp c, .reachedTargetFrequency
jr nz, .applyUpdatedFrequency
- ld hl, wChannelPitchBendTargetFrequencyLowBytes
+ ld hl, wChannelPitchSlideTargetFrequencyLowBytes
add hl, bc
ld a, [hl]
cp e
jp c, .reachedTargetFrequency
jr .applyUpdatedFrequency
.frequencyDecreasing
- ld hl, wChannelPitchBendCurrentFrequencyLowBytes
+ ld hl, wChannelPitchSlideCurrentFrequencyLowBytes
add hl, bc
ld a, [hl]
- ld hl, wChannelPitchBendCurrentFrequencyHighBytes
+ ld hl, wChannelPitchSlideCurrentFrequencyHighBytes
add hl, bc
ld d, [hl]
- ld hl, wChannelPitchBendFrequencySteps
+ ld hl, wChannelPitchSlideFrequencySteps
add hl, bc
ld e, [hl]
sub e
@@ -1132,7 +1143,7 @@ Audio1_ApplyPitchBend:
ld a, d
sbc b
ld d, a
- ld hl, wChannelPitchBendFrequencyStepsFractionalPart
+ ld hl, wChannelPitchSlideFrequencyStepsFractionalPart
add hl, bc
ld a, [hl]
add a
@@ -1143,22 +1154,22 @@ Audio1_ApplyPitchBend:
ld a, d
sbc b
ld d, a
- ld hl, wChannelPitchBendTargetFrequencyHighBytes
+ ld hl, wChannelPitchSlideTargetFrequencyHighBytes
add hl, bc
ld a, d
cp [hl]
jr c, .reachedTargetFrequency
jr nz, .applyUpdatedFrequency
- ld hl, wChannelPitchBendTargetFrequencyLowBytes
+ ld hl, wChannelPitchSlideTargetFrequencyLowBytes
add hl, bc
ld a, e
cp [hl]
jr c, .reachedTargetFrequency
.applyUpdatedFrequency
- ld hl, wChannelPitchBendCurrentFrequencyLowBytes
+ ld hl, wChannelPitchSlideCurrentFrequencyLowBytes
add hl, bc
ld [hl], e
- ld hl, wChannelPitchBendCurrentFrequencyHighBytes
+ ld hl, wChannelPitchSlideCurrentFrequencyHighBytes
add hl, bc
ld [hl], d
ld b, REG_FREQUENCY_LO
@@ -1168,38 +1179,38 @@ Audio1_ApplyPitchBend:
ld [hl], d
ret
.reachedTargetFrequency
-; Turn off pitch bend when the target frequency has been reached.
+; Turn off pitch slide when the target frequency has been reached.
ld hl, wChannelFlags1
add hl, bc
- res BIT_PITCH_BEND_ON, [hl]
- res BIT_PITCH_BEND_DECREASING, [hl]
+ res BIT_PITCH_SLIDE_ON, [hl]
+ res BIT_PITCH_SLIDE_DECREASING, [hl]
ret
-Audio1_InitPitchBendVars:
- ld hl, wChannelPitchBendCurrentFrequencyHighBytes
+Audio1_InitPitchSlideVars:
+ ld hl, wChannelPitchSlideCurrentFrequencyHighBytes
add hl, bc
ld [hl], d
- ld hl, wChannelPitchBendCurrentFrequencyLowBytes
+ ld hl, wChannelPitchSlideCurrentFrequencyLowBytes
add hl, bc
ld [hl], e
ld hl, wChannelNoteDelayCounters
add hl, bc
ld a, [hl]
- ld hl, wChannelPitchBendLengthModifiers
+ ld hl, wChannelPitchSlideLengthModifiers
add hl, bc
sub [hl]
jr nc, .next
ld a, 1
.next
ld [hl], a
- ld hl, wChannelPitchBendTargetFrequencyLowBytes
+ ld hl, wChannelPitchSlideTargetFrequencyLowBytes
add hl, bc
ld a, e
sub [hl]
ld e, a
ld a, d
sbc b
- ld hl, wChannelPitchBendTargetFrequencyHighBytes
+ ld hl, wChannelPitchSlideTargetFrequencyHighBytes
add hl, bc
sub [hl]
jr c, .targetFrequencyGreater
@@ -1207,18 +1218,18 @@ Audio1_InitPitchBendVars:
ld b, 0
ld hl, wChannelFlags1
add hl, bc
- set BIT_PITCH_BEND_DECREASING, [hl]
+ set BIT_PITCH_SLIDE_DECREASING, [hl]
jr .next2
.targetFrequencyGreater
; If the target frequency is greater, subtract the current frequency from
; the target frequency to get the absolute difference.
- ld hl, wChannelPitchBendCurrentFrequencyHighBytes
+ ld hl, wChannelPitchSlideCurrentFrequencyHighBytes
add hl, bc
ld d, [hl]
- ld hl, wChannelPitchBendCurrentFrequencyLowBytes
+ ld hl, wChannelPitchSlideCurrentFrequencyLowBytes
add hl, bc
ld e, [hl]
- ld hl, wChannelPitchBendTargetFrequencyLowBytes
+ ld hl, wChannelPitchSlideTargetFrequencyLowBytes
add hl, bc
ld a, [hl]
sub e
@@ -1233,7 +1244,7 @@ Audio1_InitPitchBendVars:
sbc b
ld d, a
- ld hl, wChannelPitchBendTargetFrequencyHighBytes
+ ld hl, wChannelPitchSlideTargetFrequencyHighBytes
add hl, bc
ld a, [hl]
sub d
@@ -1241,10 +1252,10 @@ Audio1_InitPitchBendVars:
ld b, 0
ld hl, wChannelFlags1
add hl, bc
- res BIT_PITCH_BEND_DECREASING, [hl]
+ res BIT_PITCH_SLIDE_DECREASING, [hl]
.next2
- ld hl, wChannelPitchBendLengthModifiers
+ ld hl, wChannelPitchSlideLengthModifiers
add hl, bc
.divideLoop
inc b
@@ -1263,20 +1274,20 @@ Audio1_InitPitchBendVars:
add [hl]
ld d, b ; d = quotient + 1
ld b, 0
- ld hl, wChannelPitchBendFrequencySteps
+ ld hl, wChannelPitchSlideFrequencySteps
add hl, bc
ld [hl], d ; store quotient + 1
- ld hl, wChannelPitchBendFrequencyStepsFractionalPart
+ ld hl, wChannelPitchSlideFrequencyStepsFractionalPart
add hl, bc
ld [hl], a ; store remainder - dividend
- ld hl, wChannelPitchBendCurrentFrequencyFractionalPart
+ ld hl, wChannelPitchSlideCurrentFrequencyFractionalPart
add hl, bc
ld [hl], a ; store remainder - dividend
ret
-Audio1_ApplyDutyCycle:
+Audio1_ApplyDutyCyclePattern:
ld b, 0
- ld hl, wChannelDutyCycles
+ ld hl, wChannelDutyCyclePatterns
add hl, bc
ld a, [hl]
rlca
@@ -1358,7 +1369,7 @@ Audio1_PlaySound::
ld a, [wSoundID]
cp $ff
jp z, .stopAllAudio
- cp MAX_SFX_ID
+ cp MAX_SFX_ID_1
jp z, .playSfx
jp c, .playSfx
cp $fe
@@ -1408,28 +1419,27 @@ Audio1_PlaySound::
add hl, de
ld a, [hl]
and a
- jr z, .asm_99a3
+ jr z, .playChannel
ld a, e
- cp $7
- jr nz, .asm_999a
+ cp Ch8
+ jr nz, .notNoiseChannel
ld a, [wSoundID]
- cp $14
- jr nc, .asm_9993
+ cp NOISE_INSTRUMENTS_END
+ jr nc, .notNoiseInstrument
ret
-.asm_9993
+.notNoiseInstrument
ld a, [hl]
- cp $14
- jr z, .asm_99a3
- jr c, .asm_99a3
-.asm_999a
+ cp NOISE_INSTRUMENTS_END
+ jr z, .playChannel
+ jr c, .playChannel
+.notNoiseChannel
ld a, [wSoundID]
cp [hl]
- jr z, .asm_99a3
- jr c, .asm_99a3
+ jr z, .playChannel
+ jr c, .playChannel
ret
-.asm_99a3
+.playChannel
call InitSFXVariables
-.asm_9a2b
ld a, c
and a
jp z, .playSoundCommon
@@ -1478,7 +1488,7 @@ Audio1_PlaySound::
push bc
ld b, 0
ld c, a
- cp CH3
+ cp Ch4
jr c, .skipSettingFlag
ld hl, wChannelFlags1
add hl, bc
@@ -1512,25 +1522,25 @@ Audio1_PlaySound::
jr nz, .commandPointerLoop
ld a, [wSoundID]
cp CRY_SFX_START
- jr nc, .asm_9aeb
+ jr nc, .maybeCry
jr .done
-.asm_9aeb
+.maybeCry
ld a, [wSoundID]
cp CRY_SFX_END
jr z, .done
jr c, .cry
jr .done
.cry
- ld hl, wChannelSoundIDs + CH4
+ ld hl, wChannelSoundIDs + Ch5
ld [hli], a
ld [hli], a
ld [hli], a
ld [hl], a
- ld hl, wChannelCommandPointers + CH6 * 2 ; sfx wave channel pointer
- ld de, Audio1_CryEndchannel
+ ld hl, wChannelCommandPointers + Ch7 * 2 ; sfx wave channel pointer
+ ld de, Audio1_CryRet
ld [hl], e
inc hl
- ld [hl], d ; overwrite pointer to point to endchannel
+ ld [hl], d ; overwrite pointer to point to sound_ret
ld a, [wSavedVolume]
and a
jr nz, .done
@@ -1541,8 +1551,8 @@ Audio1_PlaySound::
.done
ret
-Audio1_CryEndchannel:
- endchannel
+Audio1_CryRet:
+ sound_ret
Audio1_HWChannelBaseAddresses:
; the low bytes of each HW channel's base address
@@ -1590,5 +1600,3 @@ Audio1_Pitches:
dw $FB58 ; A_
dw $FB9B ; A#
dw $FBDA ; B_
-
-