diff options
Diffstat (limited to 'audio/engine_1.asm')
-rw-r--r-- | audio/engine_1.asm | 402 |
1 files changed, 205 insertions, 197 deletions
diff --git a/audio/engine_1.asm b/audio/engine_1.asm index 8b021acf..a8389819 100644 --- a/audio/engine_1.asm +++ b/audio/engine_1.asm @@ -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,20 +155,20 @@ Audio1_PlayNextNote: ld hl, wChannelFlags1 add hl, bc - res BIT_PITCH_BEND_ON, [hl] - res BIT_PITCH_BEND_DECREASING, [hl] - call Audio1_endchannel + res BIT_PITCH_SLIDE_ON, [hl] + res BIT_PITCH_SLIDE_DECREASING, [hl] + 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 Ch4 @@ -187,15 +187,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 @@ -215,19 +215,19 @@ 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 +.afterDisable ld a, [wChannelSoundIDs + Ch5] cp CRY_SFX_START - jr nc, .asm_9251 + jr nc, .maybeCry jr .skipCry -.asm_9251 +.maybeCry ld a, [wChannelSoundIDs + Ch5] cp CRY_SFX_END jr z, .skipCry @@ -236,10 +236,10 @@ Audio1_endchannel: .cry ld a, c cp Ch5 - jr z, .asm_9265 + jr z, .skipRewind call Audio1_GoBackOneCommandIfCry ret c -.asm_9265 +.skipRewind ld a, [wSavedVolume] ld [rNR50], a xor a @@ -250,9 +250,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 @@ -284,12 +284,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 @@ -304,7 +304,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 @@ -323,12 +323,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 @@ -367,11 +367,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 @@ -379,11 +379,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 @@ -427,14 +427,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 @@ -446,36 +446,36 @@ 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 Ch5 jr nc, .sfxChannel @@ -500,19 +500,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 call Audio1_PlaySound @@ -525,72 +525,72 @@ Audio1_unknownmusic0xef: xor 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_sfxnote ; 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 -; sfxnote is either squarenote or noisenote depending on the channel -Audio1_sfxnote: - cp $20 ; is this command a sfxnote? - jr nz, Audio1_pitchenvelope +; 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 Ch4 ; is this a noise or sfx channel? - jr c, Audio1_pitchenvelope ; no + 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_pitchenvelope ; 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 @@ -619,18 +619,18 @@ Audio1_sfxnote: .skip ld d, a push de - call Audio1_ApplyDutyAndSoundLength + call Audio1_ApplyDutyCycleAndSoundLength call Audio1_EnableChannelOutput pop de call Audio1_ApplyWavePatternAndFrequency ret -Audio1_pitchenvelope: +Audio1_pitch_sweep: ld a, c cp Ch5 jr c, Audio1_note ; if not a sfx ld a, d - cp $10 ; is this command a pitchenvelope? + cp $10 ; is this command a pitch_sweep? jr nz, Audio1_note ; no ld b, $0 ld hl, wChannelFlags2 @@ -639,17 +639,27 @@ Audio1_pitchenvelope: jr nz, Audio1_note ; no call Audio1_GetNextMusicByte ld [rNR10], a - jp Audio1_endchannel + jp Audio1_sound_ret Audio1_note: ld a, c cp Ch4 - jr nz, Audio1_notelength ; if not noise channel + 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 + jr z, .dnote + 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 dnote 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 @@ -658,26 +668,26 @@ Audio1_note: ld a, b push de push bc - jr asm_94fd + jr .playDnote -Audio1_dnote: +.dnote ld a, d and $f push af push bc call Audio1_GetNextMusicByte ; get dnote instrument -asm_94fd +.playDnote ld d, a ld a, [wDisableChannelOutputWhenSfxEnds] and a - jr nz, .asm_9508 + jr nz, .skipDnote ld a, d call Audio1_PlaySound -.asm_9508 +.skipDnote pop bc pop de -Audio1_notelength: +Audio1_note_length: ld a, d push af and $f @@ -727,15 +737,15 @@ 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 @@ -784,10 +794,10 @@ 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 Ch5 @@ -812,13 +822,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 @@ -867,7 +877,7 @@ 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 @@ -877,11 +887,11 @@ Audio1_ApplyDutyAndSoundLength: jr z, .skipDuty ; if music channel 3 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 @@ -1022,29 +1032,29 @@ Audio1_IsCry: 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 @@ -1056,26 +1066,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 @@ -1083,7 +1093,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 @@ -1094,22 +1104,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 @@ -1119,38 +1129,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 @@ -1158,18 +1168,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 @@ -1184,7 +1194,7 @@ Audio1_InitPitchBendVars: sbc b ld d, a - ld hl, wChannelPitchBendTargetFrequencyHighBytes + ld hl, wChannelPitchSlideTargetFrequencyHighBytes add hl, bc ld a, [hl] sub d @@ -1192,10 +1202,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 @@ -1214,20 +1224,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 @@ -1322,7 +1332,7 @@ Audio1_PlaySound:: ld [wSoundID], a cp $ff jp z, .stopAllAudio - cp MAX_SFX_ID + cp MAX_SFX_ID_1 jp z, .playSfx jp c, .playSfx cp $fe @@ -1346,10 +1356,10 @@ Audio1_PlaySound:: call .FillMem ld hl, wChannelFlags1 call .FillMem - ld hl, wChannelDuties - call .FillMem ld hl, wChannelDutyCycles call .FillMem + ld hl, wChannelDutyCyclePatterns + call .FillMem ld hl, wChannelVibratoDelayCounters call .FillMem ld hl, wChannelVibratoExtents @@ -1362,21 +1372,21 @@ Audio1_PlaySound:: call .FillMem ld hl, wChannelFlags2 call .FillMem - ld hl, wChannelPitchBendLengthModifiers + ld hl, wChannelPitchSlideLengthModifiers call .FillMem - ld hl, wChannelPitchBendFrequencySteps + ld hl, wChannelPitchSlideFrequencySteps call .FillMem - ld hl, wChannelPitchBendFrequencyStepsFractionalPart + ld hl, wChannelPitchSlideFrequencyStepsFractionalPart call .FillMem - ld hl, wChannelPitchBendCurrentFrequencyFractionalPart + ld hl, wChannelPitchSlideCurrentFrequencyFractionalPart call .FillMem - ld hl, wChannelPitchBendCurrentFrequencyHighBytes + ld hl, wChannelPitchSlideCurrentFrequencyHighBytes call .FillMem - ld hl, wChannelPitchBendCurrentFrequencyLowBytes + ld hl, wChannelPitchSlideCurrentFrequencyLowBytes call .FillMem - ld hl, wChannelPitchBendTargetFrequencyHighBytes + ld hl, wChannelPitchSlideTargetFrequencyHighBytes call .FillMem - ld hl, wChannelPitchBendTargetFrequencyLowBytes + ld hl, wChannelPitchSlideTargetFrequencyLowBytes call .FillMem ld a, $1 ld hl, wChannelLoopCounters @@ -1441,26 +1451,26 @@ 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 xor a push de ld h, d @@ -1483,10 +1493,10 @@ Audio1_PlaySound:: ld hl, wChannelFlags1 add hl, de ld [hl], a - ld hl, wChannelDuties + ld hl, wChannelDutyCycles add hl, de ld [hl], a - ld hl, wChannelDutyCycles + ld hl, wChannelDutyCyclePatterns add hl, de ld [hl], a ld hl, wChannelVibratoDelayCounters @@ -1504,28 +1514,28 @@ Audio1_PlaySound:: ld hl, wChannelVibratoDelayCounterReloadValues add hl, de ld [hl], a - ld hl, wChannelPitchBendLengthModifiers + ld hl, wChannelPitchSlideLengthModifiers add hl, de ld [hl], a - ld hl, wChannelPitchBendFrequencySteps + ld hl, wChannelPitchSlideFrequencySteps add hl, de ld [hl], a - ld hl, wChannelPitchBendFrequencyStepsFractionalPart + ld hl, wChannelPitchSlideFrequencyStepsFractionalPart add hl, de ld [hl], a - ld hl, wChannelPitchBendCurrentFrequencyFractionalPart + ld hl, wChannelPitchSlideCurrentFrequencyFractionalPart add hl, de ld [hl], a - ld hl, wChannelPitchBendCurrentFrequencyHighBytes + ld hl, wChannelPitchSlideCurrentFrequencyHighBytes add hl, de ld [hl], a - ld hl, wChannelPitchBendCurrentFrequencyLowBytes + ld hl, wChannelPitchSlideCurrentFrequencyLowBytes add hl, de ld [hl], a - ld hl, wChannelPitchBendTargetFrequencyHighBytes + ld hl, wChannelPitchSlideTargetFrequencyHighBytes add hl, de ld [hl], a - ld hl, wChannelPitchBendTargetFrequencyLowBytes + ld hl, wChannelPitchSlideTargetFrequencyLowBytes add hl, de ld [hl], a ld hl, wChannelFlags2 @@ -1543,10 +1553,10 @@ Audio1_PlaySound:: ld [hl], a ld a, e cp Ch5 - jr nz, .asm_9a2b + jr nz, .skipSweepDisable ld a, $8 ld [rNR10], a ; sweep off -.asm_9a2b +.skipSweepDisable ld a, c and a jp z, .playSoundCommon @@ -1667,9 +1677,9 @@ 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 @@ -1682,10 +1692,10 @@ Audio1_PlaySound:: ld [hli], a ld [hl], a ld hl, wChannelCommandPointers + Ch7 * 2 ; sfx wave channel pointer - ld de, Audio1_CryEndchannel + 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 @@ -1696,7 +1706,7 @@ Audio1_PlaySound:: .done ret -Audio1_CryEndchannel: +Audio1_CryRet: sound_ret Audio1_HWChannelBaseAddresses: @@ -1725,5 +1735,3 @@ Audio1_Pitches: dw $FB58 ; A_ dw $FB9B ; A# dw $FBDA ; B_ - - |