diff --git a/audio/cries.asm b/audio/cries.asm index 7848d185e..ca6c569b3 100644 --- a/audio/cries.asm +++ b/audio/cries.asm @@ -226,9 +226,9 @@ Cry_Magcargo_Ch6: ; f2ed3 Cry_Magcargo_Ch8: ; f2ef2 noise __, 3, $e8, $3b -Cry_Magcargo_branch_f2ef5: ; f2ef5 +.loop noise __, 2, $f1, $4e - loopchannel 5, Cry_Magcargo_branch_f2ef5 + loopchannel 5, .loop noise __, 3, $d8, $3f noise C_, 5, $c2, $5f endchannel @@ -378,9 +378,8 @@ Cry_Togetic_branch_f3022: ; f3022 Cry_Togetic_Ch5: ; f3035 tone $0002 Cry_Togetic_Ch6: ; f3038 -Cry_Togetic_branch_f3038: ; f3038 callchannel Cry_Togetic_branch_f3022 - loopchannel 2, Cry_Togetic_branch_f3038 + loopchannel 2, Cry_Togetic_Ch6 sound __, 15, $0, 0 sound __, 9, $f2, $07c2 endchannel @@ -464,12 +463,12 @@ Cry_Hoothoot_Ch5: ; f30d6 Cry_Hoothoot_Ch6: ; f30f9 sound_duty 2, 0, 2, 0 -Cry_Hoothoot_branch_f30fb: ; f30fb +.loop1 sound __, 3, $a1, $0600 - loopchannel 3, Cry_Hoothoot_branch_f30fb -Cry_Hoothoot_branch_f3103: ; f3103 + loopchannel 3, .loop1 +.loop2 sound __, 3, $a1, $0630 - loopchannel 4, Cry_Hoothoot_branch_f3103 + loopchannel 4, .loop2 sound __, 5, $a2, $0634 sound __, 5, $91, $0638 endchannel @@ -525,14 +524,14 @@ Cry_Cyndaquil_Ch5: ; f3156 Cry_Cyndaquil_Ch6: ; f3159 dutycycle $2 sound __, 9, $2f, $0107 -Cry_Cyndaquil_branch_f315f: ; f315f +.loop1 sound __, 1, $e1, $0483 sound __, 1, $51, $044e - loopchannel 4, Cry_Cyndaquil_branch_f315f -Cry_Cyndaquil_branch_f316b: ; f316b + loopchannel 4, .loop1 +.loop2 sound __, 1, $e1, $03da sound __, 2, $51, $0312 - loopchannel 4, Cry_Cyndaquil_branch_f316b + loopchannel 4, .loop2 endchannel ; f3178 @@ -683,29 +682,24 @@ Cry_Donphan_Ch8: ; f3274 Cry_Typhlosion_Ch5: ; f3284 Cry_Teddiursa_Ch5: ; f3284 sound_duty 2, 0, 1, 0 -Cry_Typhlosion_branch_f3286: ; f3286 -Cry_Teddiursa_branch_f3286: ; f3286 +.loop1 sound __, 4, $c1, $0791 - loopchannel 3, Cry_Typhlosion_branch_f3286 -Cry_Typhlosion_branch_f328e: ; f328e -Cry_Teddiursa_branch_f328e: ; f328e + loopchannel 3, .loop1 +.loop2 sound __, 4, $d1, $04b1 - loopchannel 6, Cry_Typhlosion_branch_f328e -Cry_Typhlosion_branch_f3296: ; f3296 -Cry_Teddiursa_branch_f3296: ; f3296 + loopchannel 6, .loop2 +.loop3 sound __, 2, $d1, $0491 sound __, 2, $b1, $0451 - loopchannel 6, Cry_Typhlosion_branch_f3296 -Cry_Typhlosion_branch_f32a2: ; f32a2 -Cry_Teddiursa_branch_f32a2: ; f32a2 + loopchannel 6, .loop3 +.loop4 sound __, 2, $a3, $0471 sound __, 2, $81, $0441 - loopchannel 6, Cry_Typhlosion_branch_f32a2 -Cry_Typhlosion_branch_f32ae: ; f32ae -Cry_Teddiursa_branch_f32ae: ; f32ae + loopchannel 6, .loop4 +.loop5 sound __, 2, $41, $0421 sound __, 2, $21, $0401 - loopchannel 4, Cry_Typhlosion_branch_f32ae + loopchannel 4, .loop5 endchannel ; f32bb @@ -803,10 +797,10 @@ Cry_Mantine_Ch8: ; f334c Cry_Ampharos_Ch5: ; f3353 sound_duty 2, 3, 1, 3 -Cry_Ampharos_branch_f3355: ; f3355 +.loop sound __, 2, $c1, $0520 sound __, 2, $a1, $0420 - loopchannel 4, Cry_Ampharos_branch_f3355 + loopchannel 4, .loop dutycycle $0 sound __, 5, $78, $0760 sound __, 5, $78, $0730 @@ -911,23 +905,22 @@ Cry_Aipom_Ch5: ; f3422 Cry_Aipom_Ch6: ; f3441 sound_duty 3, 1, 2, 0 -Cry_Aipom_branch_f3443: ; f3443 +.loop1 sound __, 2, $f1, $07b4 - loopchannel 8, Cry_Aipom_branch_f3443 -Cry_Aipom_branch_f344b: ; f344b + loopchannel 8, .loop1 +.loop2 sound __, 2, $c1, $0790 - loopchannel 3, Cry_Aipom_branch_f344b -Cry_Aipom_branch_f3453: ; f3453 + loopchannel 3, .loop2 +.loop3 sound __, 2, $b1, $078d - loopchannel 2, Cry_Aipom_branch_f3453 + loopchannel 2, .loop3 sound C_, 1, $92, $0795 endchannel ; f3460 Cry_Aipom_Ch8: ; f3460 -Cry_Aipom_branch_f3460: ; f3460 noise __, 1, $f1, $28 - loopchannel 4, Cry_Aipom_branch_f3460 + loopchannel 4, Cry_Aipom_Ch8 noise __, 1, $91, $49 noise __, 2, $a8, $4a noise __, 1, $e1, $4b @@ -1656,7 +1649,6 @@ Cry_Slowpoke_Ch8: ; f3a19 ; f3a1a Cry_Drowzee_Ch5: ; f3a1a -Cry_Drowzee_branch_f3a1a: ; f3a1a sound_duty 0, 2, 0, 2 sound __, 6, $f2, $0650 sound __, 10, $d1, $0660 @@ -1664,7 +1656,7 @@ Cry_Drowzee_branch_f3a1a: ; f3a1a sound __, 10, $c1, $0622 sound __, 6, $f2, $0610 sound __, 7, $d1, $0620 - loopchannel 2, Cry_Drowzee_branch_f3a1a + loopchannel 2, Cry_Drowzee_Ch5 endchannel ; f3a39 diff --git a/audio/engine.asm b/audio/engine.asm index 1560cbd8b..d0f64088b 100644 --- a/audio/engine.asm +++ b/audio/engine.asm @@ -100,12 +100,12 @@ _UpdateSound:: ; e805c ld bc, wChannel1 .loop ; is the channel active? - ld hl, wChannel1Flags - wChannel1 + ld hl, CHANNEL_FLAGS1 add hl, bc bit SOUND_CHANNEL_ON, [hl] jp z, .nextchannel ; check time left in the current note - ld hl, wChannel1NoteDuration - wChannel1 + ld hl, CHANNEL_NOTE_DURATION add hl, bc ld a, [hl] cp $2 ; 1 or 0? @@ -115,14 +115,14 @@ _UpdateSound:: ; e805c .noteover ; reset vibrato delay - ld hl, wChannel1VibratoDelay - wChannel1 + ld hl, CHANNEL_VIBRATO_DELAY add hl, bc ld a, [hl] - ld hl, wChannel1VibratoDelayCount - wChannel1 + ld hl, CHANNEL_VIBRATO_DELAY_COUNT add hl, bc ld [hl], a ; turn vibrato off for now - ld hl, wChannel1Flags2 - wChannel1 + ld hl, CHANNEL_FLAGS2 add hl, bc res SOUND_PITCH_WHEEL, [hl] ; get next note @@ -130,7 +130,7 @@ _UpdateSound:: ; e805c .continue_sound_update call ApplyPitchWheel ; duty cycle - ld hl, wChannel1DutyCycle - wChannel1 + ld hl, CHANNEL_DUTY_CYCLE add hl, bc ld a, [hli] ld [wCurTrackDuty], a @@ -151,58 +151,58 @@ _UpdateSound:: ; e805c jr z, .next ; are we in a sfx channel right now? ld a, [wCurChannel] - cp CHAN5 + cp NUM_MUSIC_CHANS jr nc, .next ; are any sfx channels active? ; if so, mute - ld hl, wChannel5Flags + ld hl, wChannel5Flags1 bit SOUND_CHANNEL_ON, [hl] jr nz, .restnote - ld hl, wChannel6Flags + ld hl, wChannel6Flags1 bit SOUND_CHANNEL_ON, [hl] jr nz, .restnote - ld hl, wChannel7Flags + ld hl, wChannel7Flags1 bit SOUND_CHANNEL_ON, [hl] jr nz, .restnote - ld hl, wChannel8Flags + ld hl, wChannel8Flags1 bit SOUND_CHANNEL_ON, [hl] jr z, .next .restnote - ld hl, wChannel1NoteFlags - wChannel1 + ld hl, CHANNEL_NOTE_FLAGS add hl, bc set NOTE_REST, [hl] ; Rest .next ; are we in a sfx channel right now? ld a, [wCurChannel] - cp CHAN5 + cp NUM_MUSIC_CHANS jr nc, .sfx_channel - ld hl, wChannel5Flags - wChannel1 + ld hl, CHANNEL_STRUCT_LENGTH * NUM_MUSIC_CHANS + CHANNEL_FLAGS1 add hl, bc bit SOUND_CHANNEL_ON, [hl] jr nz, .sound_channel_on .sfx_channel call UpdateChannels - ld hl, wChannel1Tracks - wChannel1 + ld hl, CHANNEL_TRACKS add hl, bc ld a, [wSoundOutput] or [hl] ld [wSoundOutput], a .sound_channel_on ; clear note flags - ld hl, wChannel1NoteFlags - wChannel1 + ld hl, CHANNEL_NOTE_FLAGS add hl, bc xor a ld [hl], a .nextchannel ; next channel - ld hl, wChannel2 - wChannel1 + ld hl, CHANNEL_STRUCT_LENGTH add hl, bc ld c, l ld b, h ld a, [wCurChannel] inc a ld [wCurChannel], a - cp $8 ; are we done? + cp NUM_CHANNELS ; are we done? jp nz, .loop ; do it all again call PlayDanger @@ -248,7 +248,7 @@ UpdateChannels: ; e8125 bit DANGER_ON_F, a ret nz .Channel5: - ld hl, wChannel1NoteFlags - wChannel1 + ld hl, CHANNEL_NOTE_FLAGS add hl, bc bit NOTE_UNKN_3, [hl] jr z, .asm_e8159 @@ -317,7 +317,7 @@ UpdateChannels: ; e8125 .Channel2: .Channel6: - ld hl, wChannel1NoteFlags - wChannel1 + ld hl, CHANNEL_NOTE_FLAGS add hl, bc bit NOTE_REST, [hl] ; rest jr nz, .ch2rest @@ -377,7 +377,7 @@ UpdateChannels: ; e8125 .Channel3: .Channel7: - ld hl, wChannel1NoteFlags - wChannel1 + ld hl, CHANNEL_NOTE_FLAGS add hl, bc bit NOTE_REST, [hl] ; rest jr nz, .ch3rest @@ -478,7 +478,7 @@ endr .Channel4: .Channel8: - ld hl, wChannel1NoteFlags - wChannel1 + ld hl, CHANNEL_NOTE_FLAGS add hl, bc bit NOTE_REST, [hl] ; rest jr nz, .ch4rest @@ -514,16 +514,16 @@ endr _CheckSFX: ; e82e7 ; return carry if any sfx channels are active - ld hl, wChannel5Flags + ld hl, wChannel5Flags1 bit SOUND_CHANNEL_ON, [hl] jr nz, .sfxon - ld hl, wChannel6Flags + ld hl, wChannel6Flags1 bit SOUND_CHANNEL_ON, [hl] jr nz, .sfxon - ld hl, wChannel7Flags + ld hl, wChannel7Flags1 bit SOUND_CHANNEL_ON, [hl] jr nz, .sfxon - ld hl, wChannel8Flags + ld hl, wChannel8Flags1 bit SOUND_CHANNEL_ON, [hl] jr nz, .sfxon and a @@ -539,47 +539,57 @@ PlayDanger: ; e8307 ld a, [wLowHealthAlarm] bit DANGER_ON_F, a ret z + + ; Don't do anything if SFX is being played and $ff ^ (1 << DANGER_ON_F) ld d, a call _CheckSFX - jr c, .asm_e8335 + jr c, .increment + + ; Play the high tone and a - jr z, .asm_e8323 - cp 16 ; halfway - jr z, .asm_e831e - jr .asm_e8335 + jr z, .begin -.asm_e831e - ld hl, Tablee8354 - jr .updatehw + ; Play the low tone + cp 16 + jr z, .halfway -.asm_e8323 - ld hl, Tablee8350 -.updatehw + jr .increment + +.halfway + ld hl, DangerSoundLow + jr .applychannel + +.begin + ld hl, DangerSoundHigh + +.applychannel xor a - ld [rNR10], a ; sweep off + ld [rNR10], a ld a, [hli] - ld [rNR11], a ; sound length / duty cycle + ld [rNR11], a ld a, [hli] - ld [rNR12], a ; ch1 volume envelope + ld [rNR12], a ld a, [hli] - ld [rNR13], a ; ch1 frequency lo + ld [rNR13], a ld a, [hli] - ld [rNR14], a ; ch1 frequency hi -.asm_e8335 + ld [rNR14], a + +.increment ld a, d inc a - cp 30 - jr c, .asm_e833c + cp 30 ; Ending frame + jr c, .noreset xor a -.asm_e833c +.noreset + ; Make sure the danger sound is kept on or 1 << DANGER_ON_F ld [wLowHealthAlarm], a - ; is hw ch1 on? + + ; Enable channel 1 if it's off ld a, [wSoundOutput] and $11 ret nz - ; if not, turn it on ld a, [wSoundOutput] or $11 ld [wSoundOutput], a @@ -587,14 +597,14 @@ PlayDanger: ; e8307 ; e8350 -Tablee8350: ; e8350 +DangerSoundHigh: ; e8350 db $80 ; duty 50% db $e2 ; volume 14, envelope decrease sweep 2 db $50 ; frequency: $750 db $87 ; restart sound ; e8354 -Tablee8354: ; e8354 +DangerSoundLow: ; e8354 db $80 ; duty 50% db $e2 ; volume 14, envelope decrease sweep 2 db $ee ; frequency: $6ee @@ -693,7 +703,7 @@ FadeMusic: ; e8358 .fadein ; are we done? - cp $7 + cp MAX_VOLUME & $f jr nc, .maxvolume ; inc volume inc a @@ -717,12 +727,12 @@ FadeMusic: ; e8358 LoadNote: ; e83d1 ; wait for pitch wheel to finish - ld hl, wChannel1Flags2 - wChannel1 + ld hl, CHANNEL_FLAGS2 add hl, bc bit SOUND_PITCH_WHEEL, [hl] ret z ; get note duration - ld hl, wChannel1NoteDuration - wChannel1 + ld hl, CHANNEL_NOTE_DURATION add hl, bc ld a, [hl] ld hl, wCurNoteDuration @@ -732,13 +742,13 @@ LoadNote: ; e83d1 .ok ld [hl], a ; get frequency - ld hl, wChannel1Frequency - wChannel1 + ld hl, CHANNEL_FREQUENCY add hl, bc ld e, [hl] inc hl ld d, [hl] ; get direction of pitch wheel - ld hl, wChannel1PitchWheelTarget - wChannel1 + ld hl, CHANNEL_PITCH_WHEEL_TARGET add hl, bc ld a, e sub [hl] @@ -746,21 +756,21 @@ LoadNote: ; e83d1 ld a, d sbc 0 ld d, a - ld hl, wChannel1PitchWheelTarget + 1 - wChannel1 + ld hl, CHANNEL_PITCH_WHEEL_TARGET + 1 add hl, bc sub [hl] jr nc, .greater_than - ld hl, wChannel1Flags3 - wChannel1 + ld hl, CHANNEL_FLAGS3 add hl, bc set SOUND_PITCH_WHEEL_DIR, [hl] ; get frequency - ld hl, wChannel1Frequency - wChannel1 + ld hl, CHANNEL_FREQUENCY add hl, bc ld e, [hl] inc hl ld d, [hl] ; ???? - ld hl, wChannel1PitchWheelTarget - wChannel1 + ld hl, CHANNEL_PITCH_WHEEL_TARGET add hl, bc ld a, [hl] sub e @@ -769,7 +779,7 @@ LoadNote: ; e83d1 sbc 0 ld d, a ; ???? - ld hl, wChannel1PitchWheelTarget + 1 - wChannel1 + ld hl, CHANNEL_PITCH_WHEEL_TARGET + 1 add hl, bc ld a, [hl] sub d @@ -777,17 +787,17 @@ LoadNote: ; e83d1 jr .resume .greater_than - ld hl, wChannel1Flags3 - wChannel1 + ld hl, CHANNEL_FLAGS3 add hl, bc res SOUND_PITCH_WHEEL_DIR, [hl] ; get frequency - ld hl, wChannel1Frequency - wChannel1 + ld hl, CHANNEL_FREQUENCY add hl, bc ld e, [hl] inc hl ld d, [hl] ; get distance from pitch wheel target - ld hl, wChannel1PitchWheelTarget - wChannel1 + ld hl, CHANNEL_PITCH_WHEEL_TARGET add hl, bc ld a, e sub [hl] @@ -795,7 +805,7 @@ LoadNote: ; e83d1 ld a, d sbc 0 ld d, a - ld hl, wChannel1PitchWheelTarget + 1 - wChannel1 + ld hl, CHANNEL_PITCH_WHEEL_TARGET + 1 add hl, bc sub [hl] ld d, a @@ -823,13 +833,13 @@ LoadNote: ; e83d1 add [hl] ld d, b ; quotient pop bc - ld hl, wChannel1PitchWheelAmount - wChannel1 + ld hl, CHANNEL_PITCH_WHEEL_AMOUNT add hl, bc ld [hl], d ; quotient - ld hl, wChannel1PitchWheelAmountFraction - wChannel1 + ld hl, CHANNEL_PITCH_WHEEL_AMOUNT_FRACTION add hl, bc ld [hl], a ; remainder - ld hl, wChannel1Field25 - wChannel1 + ld hl, CHANNEL_FIELD25 add hl, bc xor a ld [hl], a @@ -839,11 +849,11 @@ LoadNote: ; e83d1 HandleTrackVibrato: ; e8466 ; handle duty, cry pitch, and vibrato - ld hl, wChannel1Flags2 - wChannel1 + ld hl, CHANNEL_FLAGS2 add hl, bc bit SOUND_DUTY, [hl] ; duty jr z, .next - ld hl, wChannel1SFXDutyLoop - wChannel1 + ld hl, CHANNEL_SFX_DUTY_LOOP add hl, bc ld a, [hl] rlca @@ -851,15 +861,15 @@ HandleTrackVibrato: ; e8466 ld [hl], a and $c0 ld [wCurTrackDuty], a - ld hl, wChannel1NoteFlags - wChannel1 + ld hl, CHANNEL_NOTE_FLAGS add hl, bc set NOTE_DUTY_OVERRIDE, [hl] .next - ld hl, wChannel1Flags2 - wChannel1 + ld hl, CHANNEL_FLAGS2 add hl, bc bit SOUND_CRY_PITCH, [hl] jr z, .vibrato - ld hl, wChannel1CryPitch - wChannel1 + ld hl, CHANNEL_CRY_PITCH add hl, bc ld e, [hl] inc hl @@ -877,19 +887,19 @@ HandleTrackVibrato: ; e8466 ld [hl], d .vibrato ; is vibrato on? - ld hl, wChannel1Flags2 - wChannel1 + ld hl, CHANNEL_FLAGS2 add hl, bc bit SOUND_VIBRATO, [hl] ; vibrato jr z, .quit ; is vibrato active for this note yet? ; is the delay over? - ld hl, wChannel1VibratoDelayCount - wChannel1 + ld hl, CHANNEL_VIBRATO_DELAY_COUNT add hl, bc ld a, [hl] and a jr nz, .subexit ; is the extent nonzero? - ld hl, wChannel1VibratoExtent - wChannel1 + ld hl, CHANNEL_VIBRATO_EXTENT add hl, bc ld a, [hl] and a @@ -897,7 +907,7 @@ HandleTrackVibrato: ; e8466 ; save it for later ld d, a ; is it time to toggle vibrato up/down? - ld hl, wChannel1VibratoRate - wChannel1 + ld hl, CHANNEL_VIBRATO_RATE add hl, bc ld a, [hl] and $f ; count @@ -916,7 +926,7 @@ HandleTrackVibrato: ; e8466 ld a, [wCurTrackFrequency] ld e, a ; toggle vibrato up/down - ld hl, wChannel1Flags3 - wChannel1 + ld hl, CHANNEL_FLAGS3 add hl, bc bit SOUND_VIBRATO_DIR, [hl] ; vibrato up/down jr z, .down @@ -948,7 +958,7 @@ HandleTrackVibrato: ; e8466 .no_carry ld [wCurTrackFrequency], a ; - ld hl, wChannel1NoteFlags - wChannel1 + ld hl, CHANNEL_NOTE_FLAGS add hl, bc set NOTE_VIBRATO_OVERRIDE, [hl] .quit @@ -958,23 +968,23 @@ HandleTrackVibrato: ; e8466 ApplyPitchWheel: ; e84f9 ; quit if pitch wheel inactive - ld hl, wChannel1Flags2 - wChannel1 + ld hl, CHANNEL_FLAGS2 add hl, bc bit SOUND_PITCH_WHEEL, [hl] ret z ; de = Frequency - ld hl, wChannel1Frequency - wChannel1 + ld hl, CHANNEL_FREQUENCY add hl, bc ld e, [hl] inc hl ld d, [hl] ; check whether pitch wheel is going up or down - ld hl, wChannel1Flags3 - wChannel1 + ld hl, CHANNEL_FLAGS3 add hl, bc bit SOUND_PITCH_WHEEL_DIR, [hl] jr z, .decreasing ; frequency += [Channel*PitchWheelAmount] - ld hl, wChannel1PitchWheelAmount - wChannel1 + ld hl, CHANNEL_PITCH_WHEEL_AMOUNT add hl, bc ld l, [hl] ld h, 0 @@ -983,10 +993,10 @@ ApplyPitchWheel: ; e84f9 ld e, l ; [Channel*Field25] += [Channel*PitchWheelAmountFraction] ; if rollover: Frequency += 1 - ld hl, wChannel1PitchWheelAmountFraction - wChannel1 + ld hl, CHANNEL_PITCH_WHEEL_AMOUNT_FRACTION add hl, bc ld a, [hl] - ld hl, wChannel1Field25 - wChannel1 + ld hl, CHANNEL_FIELD25 add hl, bc add [hl] ld [hl], a @@ -999,13 +1009,13 @@ ApplyPitchWheel: ; e84f9 ; Compare the dw at [Channel*PitchWheelTarget] to de. ; If frequency is greater, we're finished. ; Otherwise, load the frequency and set two flags. - ld hl, wChannel1PitchWheelTarget + 1 - wChannel1 + ld hl, CHANNEL_PITCH_WHEEL_TARGET + 1 add hl, bc ld a, [hl] cp d jp c, .finished_pitch_wheel jr nz, .continue_pitch_wheel - ld hl, wChannel1PitchWheelTarget - wChannel1 + ld hl, CHANNEL_PITCH_WHEEL_TARGET add hl, bc ld a, [hl] cp e @@ -1015,7 +1025,7 @@ ApplyPitchWheel: ; e84f9 .decreasing ; frequency -= [Channel*PitchWheelAmount] ld a, e - ld hl, wChannel1PitchWheelAmount - wChannel1 + ld hl, CHANNEL_PITCH_WHEEL_AMOUNT add hl, bc ld e, [hl] sub e @@ -1025,7 +1035,7 @@ ApplyPitchWheel: ; e84f9 ld d, a ; [Channel*Field25] *= 2 ; if rollover: Frequency -= 1 - ld hl, wChannel1PitchWheelAmountFraction - wChannel1 + ld hl, CHANNEL_PITCH_WHEEL_AMOUNT_FRACTION add hl, bc ld a, [hl] add a @@ -1039,33 +1049,33 @@ ApplyPitchWheel: ; e84f9 ; Compare the dw at [Channel*PitchWheelTarget] to de. ; If frequency is lower, we're finished. ; Otherwise, load the frequency and set two flags. - ld hl, wChannel1PitchWheelTarget + 1 - wChannel1 + ld hl, CHANNEL_PITCH_WHEEL_TARGET + 1 add hl, bc ld a, d cp [hl] jr c, .finished_pitch_wheel jr nz, .continue_pitch_wheel - ld hl, wChannel1PitchWheelTarget - wChannel1 + ld hl, CHANNEL_PITCH_WHEEL_TARGET add hl, bc ld a, e cp [hl] jr nc, .continue_pitch_wheel .finished_pitch_wheel - ld hl, wChannel1Flags2 - wChannel1 + ld hl, CHANNEL_FLAGS2 add hl, bc res SOUND_PITCH_WHEEL, [hl] - ld hl, wChannel1Flags3 - wChannel1 + ld hl, CHANNEL_FLAGS3 add hl, bc res SOUND_PITCH_WHEEL_DIR, [hl] ret .continue_pitch_wheel - ld hl, wChannel1Frequency - wChannel1 + ld hl, CHANNEL_FREQUENCY add hl, bc ld [hl], e inc hl ld [hl], d - ld hl, wChannel1NoteFlags - wChannel1 + ld hl, CHANNEL_NOTE_FLAGS add hl, bc set NOTE_FREQ_OVERRIDE, [hl] set NOTE_DUTY_OVERRIDE, [hl] @@ -1075,7 +1085,7 @@ ApplyPitchWheel: ; e84f9 HandleNoise: ; e858c ; is noise sampling on? - ld hl, wChannel1Flags - wChannel1 + ld hl, CHANNEL_FLAGS1 add hl, bc bit SOUND_NOISE, [hl] ; noise sampling ret z @@ -1084,7 +1094,7 @@ HandleNoise: ; e858c bit NOISE_CHAN_F, a jr nz, .next ; is ch8 on? (noise) - ld hl, wChannel8Flags + ld hl, wChannel8Flags1 bit SOUND_CHANNEL_ON, [hl] ; on? jr z, .next ; is ch8 playing noise? @@ -1143,7 +1153,7 @@ ReadNoiseSample: ; e85af inc hl ld [hl], d - ld hl, wChannel1NoteFlags - wChannel1 + ld hl, CHANNEL_NOTE_FLAGS add hl, bc set NOTE_NOISE_SAMPLING, [hl] ret @@ -1168,7 +1178,7 @@ ParseMusic: ; e85e1 .readnote ; wCurMusicByte contains current note ; special notes - ld hl, wChannel1Flags - wChannel1 + ld hl, CHANNEL_FLAGS1 add hl, bc bit SOUND_SFX, [hl] jp nz, ParseSFXOrRest @@ -1187,38 +1197,38 @@ ParseMusic: ; e85e1 and $f jr z, .rest ; pitch 0-> rest ; update pitch - ld hl, wChannel1Pitch - wChannel1 + ld hl, CHANNEL_PITCH add hl, bc ld [hl], a ; store pitch in e ld e, a ; store octave in d - ld hl, wChannel1Octave - wChannel1 + ld hl, CHANNEL_OCTAVE add hl, bc ld d, [hl] ; update frequency call GetFrequency - ld hl, wChannel1Frequency - wChannel1 + ld hl, CHANNEL_FREQUENCY add hl, bc ld [hl], e inc hl ld [hl], d ; ???? - ld hl, wChannel1NoteFlags - wChannel1 + ld hl, CHANNEL_NOTE_FLAGS add hl, bc set NOTE_NOISE_SAMPLING, [hl] jp LoadNote .rest ; note = rest - ld hl, wChannel1NoteFlags - wChannel1 + ld hl, CHANNEL_NOTE_FLAGS add hl, bc set NOTE_REST, [hl] ; Rest ret .endchannel ; $ff is reached in music data - ld hl, wChannel1Flags - wChannel1 + ld hl, CHANNEL_FLAGS1 add hl, bc bit SOUND_SUBROUTINE, [hl] ; in a subroutine? jr nz, .readcommand ; execute @@ -1226,12 +1236,12 @@ ParseMusic: ; e85e1 cp CHAN5 jr nc, .chan_5to8 ; ???? - ld hl, wChannel5Flags - wChannel1 + ld hl, CHANNEL_STRUCT_LENGTH * NUM_MUSIC_CHANS + CHANNEL_FLAGS1 add hl, bc bit SOUND_CHANNEL_ON, [hl] jr nz, .ok .chan_5to8 - ld hl, wChannel1Flags - wChannel1 + ld hl, CHANNEL_FLAGS1 add hl, bc bit SOUND_REST, [hl] call nz, RestoreVolume @@ -1245,15 +1255,15 @@ ParseMusic: ; e85e1 .ok ; stop playing ; turn channel off - ld hl, wChannel1Flags - wChannel1 + ld hl, CHANNEL_FLAGS1 add hl, bc res SOUND_CHANNEL_ON, [hl] ; note = rest - ld hl, wChannel1NoteFlags - wChannel1 + ld hl, CHANNEL_NOTE_FLAGS add hl, bc set NOTE_REST, [hl] ; clear music id & bank - ld hl, wChannel1MusicID - wChannel1 + ld hl, CHANNEL_MUSIC_ID add hl, bc xor a ld [hli], a ; id hi @@ -1286,7 +1296,7 @@ RestoreVolume: ; e8679 ParseSFXOrRest: ; e8698 ; turn noise sampling on - ld hl, wChannel1NoteFlags - wChannel1 + ld hl, CHANNEL_NOTE_FLAGS add hl, bc set NOTE_NOISE_SAMPLING, [hl] ; noise sample ; update note duration @@ -1294,12 +1304,12 @@ ParseSFXOrRest: ; e8698 call SetNoteDuration ; top nybble doesnt matter? ; update intensity from next param call GetMusicByte - ld hl, wChannel1Intensity - wChannel1 + ld hl, CHANNEL_INTENSITY add hl, bc ld [hl], a ; update lo frequency from next param call GetMusicByte - ld hl, wChannel1FrequencyLo - wChannel1 + ld hl, CHANNEL_FREQUENCY add hl, bc ld [hl], a ; are we on the last channel? (noise sampling) @@ -1309,7 +1319,7 @@ ParseSFXOrRest: ; e8698 ret z ; update hi frequency from next param call GetMusicByte - ld hl, wChannel1FrequencyHi - wChannel1 + ld hl, CHANNEL_FREQUENCY + 1 add hl, bc ld [hl], a ret @@ -1332,7 +1342,7 @@ GetNoiseSample: ; e86c5 ld a, [wCurChannel] bit NOISE_CHAN_F, a jr nz, .sfx - ld hl, wChannel8Flags + ld hl, wChannel8Flags1 bit SOUND_CHANNEL_ON, [hl] ; is ch8 on? (noise) ret nz ld a, [wMusicNoiseSampleSet] @@ -1462,16 +1472,16 @@ Music_EndChannel: ; e8781 ; end music stream ; return to caller of the subroutine ; reset subroutine flag - ld hl, wChannel1Flags - wChannel1 + ld hl, CHANNEL_FLAGS1 add hl, bc res SOUND_SUBROUTINE, [hl] ; copy LastMusicAddress to MusicAddress - ld hl, wChannel1LastMusicAddress - wChannel1 + ld hl, CHANNEL_LAST_MUSIC_ADDRESS add hl, bc ld e, [hl] inc hl ld d, [hl] - ld hl, wChannel1MusicAddress - wChannel1 + ld hl, CHANNEL_MUSIC_ADDRESS add hl, bc ld [hl], e inc hl @@ -1490,25 +1500,25 @@ Music_CallChannel: ; e8796 ld d, a push de ; copy MusicAddress to LastMusicAddress - ld hl, wChannel1MusicAddress - wChannel1 + ld hl, CHANNEL_MUSIC_ADDRESS add hl, bc ld e, [hl] inc hl ld d, [hl] - ld hl, wChannel1LastMusicAddress - wChannel1 + ld hl, CHANNEL_LAST_MUSIC_ADDRESS add hl, bc ld [hl], e inc hl ld [hl], d ; load pointer into MusicAddress pop de - ld hl, wChannel1MusicAddress - wChannel1 + ld hl, CHANNEL_MUSIC_ADDRESS add hl, bc ld [hl], e inc hl ld [hl], d ; set subroutine flag - ld hl, wChannel1Flags - wChannel1 + ld hl, CHANNEL_FLAGS1 add hl, bc set SOUND_SUBROUTINE, [hl] ret @@ -1523,7 +1533,7 @@ Music_JumpChannel: ; e87bc ld e, a call GetMusicByte ld d, a - ld hl, wChannel1MusicAddress - wChannel1 + ld hl, CHANNEL_MUSIC_ADDRESS add hl, bc ld [hl], e inc hl @@ -1542,7 +1552,7 @@ Music_LoopChannel: ; e87cc ; get loop count call GetMusicByte - ld hl, wChannel1Flags - wChannel1 + ld hl, CHANNEL_FLAGS1 add hl, bc bit SOUND_LOOPING, [hl] ; has the loop been initiated? jr nz, .checkloop @@ -1551,11 +1561,11 @@ Music_LoopChannel: ; e87cc ; initiate loop dec a set SOUND_LOOPING, [hl] ; set loop flag - ld hl, wChannel1LoopCount - wChannel1 + ld hl, CHANNEL_LOOP_COUNT add hl, bc ld [hl], a ; store loop counter .checkloop - ld hl, wChannel1LoopCount - wChannel1 + ld hl, CHANNEL_LOOP_COUNT add hl, bc ld a, [hl] and a ; are we done? @@ -1568,7 +1578,7 @@ Music_LoopChannel: ; e87cc call GetMusicByte ld d, a ; load new pointer into MusicAddress - ld hl, wChannel1MusicAddress - wChannel1 + ld hl, CHANNEL_MUSIC_ADDRESS add hl, bc ld [hl], e inc hl @@ -1577,11 +1587,11 @@ Music_LoopChannel: ; e87cc .endloop ; reset loop flag - ld hl, wChannel1Flags - wChannel1 + ld hl, CHANNEL_FLAGS1 add hl, bc res SOUND_LOOPING, [hl] ; skip to next command - ld hl, wChannel1MusicAddress - wChannel1 + ld hl, CHANNEL_MUSIC_ADDRESS add hl, bc ld e, [hl] inc hl @@ -1603,7 +1613,7 @@ Music_SetCondition: ; e880e ; set condition call GetMusicByte - ld hl, wChannel1Condition - wChannel1 + ld hl, CHANNEL_CONDITION add hl, bc ld [hl], a ret @@ -1621,13 +1631,13 @@ Music_JumpIf: ; e8817 ; a = condition call GetMusicByte ; if existing condition matches, jump to new address - ld hl, wChannel1Condition - wChannel1 + ld hl, CHANNEL_CONDITION add hl, bc cp [hl] jr z, .jump ; skip to next command ; get address - ld hl, wChannel1MusicAddress - wChannel1 + ld hl, CHANNEL_MUSIC_ADDRESS add hl, bc ld e, [hl] inc hl @@ -1649,7 +1659,7 @@ Music_JumpIf: ; e8817 call GetMusicByte ld d, a ; update pointer in MusicAddress - ld hl, wChannel1MusicAddress - wChannel1 + ld hl, CHANNEL_MUSIC_ADDRESS add hl, bc ld [hl], e inc hl @@ -1680,7 +1690,7 @@ MusicEE; e883e jr nz, .jump ; skip to next command ; get address - ld hl, wChannel1MusicAddress - wChannel1 + ld hl, CHANNEL_MUSIC_ADDRESS add hl, bc ld e, [hl] inc hl @@ -1703,7 +1713,7 @@ MusicEE; e883e call GetMusicByte ld d, a ; update address - ld hl, wChannel1MusicAddress - wChannel1 + ld hl, CHANNEL_MUSIC_ADDRESS add hl, bc ld [hl], e inc hl @@ -1726,10 +1736,10 @@ MusicE2: ; e8873 ; seems to have been dummied out ; params: 1 call GetMusicByte - ld hl, wChannel1Field2c - wChannel1 + ld hl, CHANNEL_FIELD2C add hl, bc ld [hl], a - ld hl, wChannel1Flags2 - wChannel1 + ld hl, CHANNEL_FLAGS2 add hl, bc set SOUND_UNKN_0B, [hl] ret @@ -1746,28 +1756,28 @@ Music_Vibrato: ; e8882 ; z: rate (# frames per cycle) ; set vibrato flag? - ld hl, wChannel1Flags2 - wChannel1 + ld hl, CHANNEL_FLAGS2 add hl, bc set SOUND_VIBRATO, [hl] ; start at lower frequency (extent is positive) - ld hl, wChannel1Flags3 - wChannel1 + ld hl, CHANNEL_FLAGS3 add hl, bc res SOUND_VIBRATO_DIR, [hl] ; get delay call GetMusicByte ; update delay - ld hl, wChannel1VibratoDelay - wChannel1 + ld hl, CHANNEL_VIBRATO_DELAY add hl, bc ld [hl], a ; update delay count - ld hl, wChannel1VibratoDelayCount - wChannel1 + ld hl, CHANNEL_VIBRATO_DELAY_COUNT add hl, bc ld [hl], a ; update extent ; this is split into halves only to get added back together at the last second ; get extent/rate call GetMusicByte - ld hl, wChannel1VibratoExtent - wChannel1 + ld hl, CHANNEL_VIBRATO_EXTENT add hl, bc ld d, a ; get top nybble @@ -1780,7 +1790,7 @@ Music_Vibrato: ; e8882 or e ld [hl], a ; update rate - ld hl, wChannel1VibratoRate - wChannel1 + ld hl, CHANNEL_VIBRATO_RATE add hl, bc ; get bottom nybble ld a, d @@ -1813,13 +1823,13 @@ Music_SlidePitchTo: ; e88bd and $f ld d, a call GetFrequency - ld hl, wChannel1PitchWheelTarget - wChannel1 + ld hl, CHANNEL_PITCH_WHEEL_TARGET add hl, bc ld [hl], e - ld hl, wChannel1PitchWheelTarget + 1 - wChannel1 + ld hl, CHANNEL_PITCH_WHEEL_TARGET + 1 add hl, bc ld [hl], d - ld hl, wChannel1Flags2 - wChannel1 + ld hl, CHANNEL_FLAGS2 add hl, bc set SOUND_PITCH_WHEEL, [hl] ret @@ -1829,10 +1839,10 @@ Music_SlidePitchTo: ; e88bd Music_Tone: ; e88e4 ; tone ; params: 1 (dw) - ld hl, wChannel1Flags2 - wChannel1 + ld hl, CHANNEL_FLAGS2 add hl, bc set SOUND_CRY_PITCH, [hl] - ld hl, wChannel1CryPitch + 1 - wChannel1 + ld hl, CHANNEL_CRY_PITCH + 1 add hl, bc call GetMusicByte ld [hld], a @@ -1845,11 +1855,11 @@ Music_Tone: ; e88e4 MusicE7: ; e88f7 ; unused ; params: 1 - ld hl, wChannel1Flags2 - wChannel1 + ld hl, CHANNEL_FLAGS2 add hl, bc set SOUND_UNKN_0E, [hl] call GetMusicByte - ld hl, wChannel1Field29 - wChannel1 + ld hl, CHANNEL_FIELD29 add hl, bc ld [hl], a ret @@ -1859,19 +1869,19 @@ MusicE7: ; e88f7 Music_SoundDuty: ; e8906 ; sequence of 4 duty cycles to be looped ; params: 1 (4 2-bit duty cycle arguments) - ld hl, wChannel1Flags2 - wChannel1 + ld hl, CHANNEL_FLAGS2 add hl, bc set SOUND_DUTY, [hl] ; duty cycle ; sound duty sequence call GetMusicByte rrca rrca - ld hl, wChannel1SFXDutyLoop - wChannel1 + ld hl, CHANNEL_SFX_DUTY_LOOP add hl, bc ld [hl], a ; update duty cycle and $c0 ; only uses top 2 bits - ld hl, wChannel1DutyCycle - wChannel1 + ld hl, CHANNEL_DUTY_CYCLE add hl, bc ld [hl], a ret @@ -1881,11 +1891,11 @@ Music_SoundDuty: ; e8906 MusicE8: ; e891e ; unused ; params: 1 - ld hl, wChannel1Flags2 - wChannel1 + ld hl, CHANNEL_FLAGS2 add hl, bc set SOUND_UNKN_0D, [hl] call GetMusicByte - ld hl, wChannel1Field2a - wChannel1 + ld hl, CHANNEL_FIELD2A add hl, bc ld [hl], a ret @@ -1895,7 +1905,7 @@ MusicE8: ; e891e Music_ToggleSFX: ; e892d ; toggle something ; params: none - ld hl, wChannel1Flags - wChannel1 + ld hl, CHANNEL_FLAGS1 add hl, bc bit SOUND_SFX, [hl] jr z, .on @@ -1915,7 +1925,7 @@ Music_ToggleNoise: ; e893b ; noise on: 1 ; noise off: 0 ; check if noise sampling is on - ld hl, wChannel1Flags - wChannel1 + ld hl, CHANNEL_FLAGS1 add hl, bc bit SOUND_NOISE, [hl] jr z, .on @@ -1938,7 +1948,7 @@ Music_SFXToggleNoise: ; e894f ; on: 1 ; off: 0 ; check if noise sampling is on - ld hl, wChannel1Flags - wChannel1 + ld hl, CHANNEL_FLAGS1 add hl, bc bit SOUND_NOISE, [hl] jr z, .on @@ -1962,7 +1972,7 @@ Music_NoteType: ; e8963 ; params: 2 ; note length call GetMusicByte - ld hl, wChannel1NoteLength - wChannel1 + ld hl, CHANNEL_NOTE_LENGTH add hl, bc ld [hl], a ld a, [wCurChannel] @@ -1980,7 +1990,7 @@ Music_SoundStatus: ; e8977 ; params: 1 call GetMusicByte ld [wSoundInput], a - ld hl, wChannel1NoteFlags - wChannel1 + ld hl, CHANNEL_NOTE_FLAGS add hl, bc set NOTE_UNKN_3, [hl] ret @@ -1994,7 +2004,7 @@ Music_DutyCycle: ; e8984 rrca rrca and $c0 - ld hl, wChannel1DutyCycle - wChannel1 + ld hl, CHANNEL_DUTY_CYCLE add hl, bc ld [hl], a ret @@ -2007,7 +2017,7 @@ Music_Intensity: ; e8991 ; hi: pressure ; lo: velocity call GetMusicByte - ld hl, wChannel1Intensity - wChannel1 + ld hl, CHANNEL_INTENSITY add hl, bc ld [hl], a ret @@ -2036,7 +2046,7 @@ Music_Octave3: ; e89a6 Music_Octave2: ; e89a6 Music_Octave1: ; e89a6 ; set octave based on lo nybble of the command - ld hl, wChannel1Octave - wChannel1 + ld hl, CHANNEL_OCTAVE add hl, bc ld a, [wCurMusicByte] and 7 @@ -2050,7 +2060,7 @@ Music_ForceOctave: ; e89b1 ; this forces all notes up by the starting octave ; params: 1 call GetMusicByte - ld hl, wChannel1PitchOffset - wChannel1 + ld hl, CHANNEL_PITCH_OFFSET add hl, bc ld [hl], a ret @@ -2075,7 +2085,7 @@ Music_Panning: ; e89c5 ; params: 1 call SetLRTracks call GetMusicByte - ld hl, wChannel1Tracks - wChannel1 + ld hl, CHANNEL_TRACKS add hl, bc and [hl] ld [hl], a @@ -2116,7 +2126,7 @@ Music_TempoRelative: ; e89e1 .negative ld d, -1 .ok - ld hl, wChannel1Tempo - wChannel1 + ld hl, CHANNEL_TEMPO add hl, bc ld a, [hli] ld h, [hl] @@ -2156,14 +2166,14 @@ Music_RestartChannel: ; e8a08 ; zzyy: pointer to new music data ; update music id - ld hl, wChannel1MusicID - wChannel1 + ld hl, CHANNEL_MUSIC_ID add hl, bc ld a, [hli] ld [wMusicID], a ld a, [hl] ld [wMusicID + 1], a ; update music bank - ld hl, wChannel1MusicBank - wChannel1 + ld hl, CHANNEL_MUSIC_BANK add hl, bc ld a, [hl] ld [wMusicBank], a @@ -2205,20 +2215,20 @@ GetMusicByte: ; e8a3e push hl push de ; load address into de - ld hl, wChannel1MusicAddress - wChannel1 + ld hl, CHANNEL_MUSIC_ADDRESS add hl, bc ld a, [hli] ld e, a ld d, [hl] ; load bank into a - ld hl, wChannel1MusicBank - wChannel1 + ld hl, CHANNEL_MUSIC_BANK add hl, bc ld a, [hl] ; get byte call _LoadMusicByte ; load data into wCurMusicByte inc de ; advance to next byte for next time this is called ; update channeldata address - ld hl, wChannel1MusicAddress - wChannel1 + ld hl, CHANNEL_MUSIC_ADDRESS add hl, bc ld a, e ld [hli], a @@ -2242,7 +2252,7 @@ GetFrequency: ; e8a5d ; get octave ; get starting octave - ld hl, wChannel1PitchOffset - wChannel1 + ld hl, CHANNEL_PITCH_OFFSET add hl, bc ld a, [hl] swap a ; hi nybble @@ -2251,7 +2261,7 @@ GetFrequency: ; e8a5d add d push af ; we'll use this later ; get starting octave - ld hl, wChannel1PitchOffset - wChannel1 + ld hl, CHANNEL_PITCH_OFFSET add hl, bc ld a, [hl] and $f ; lo nybble @@ -2293,7 +2303,7 @@ SetNoteDuration: ; e8a8d ld e, a ld d, 0 ; store NoteLength in a - ld hl, wChannel1NoteLength - wChannel1 + ld hl, CHANNEL_NOTE_LENGTH add hl, bc ld a, [hl] ; multiply NoteLength by delay units @@ -2301,13 +2311,13 @@ SetNoteDuration: ; e8a8d call .Multiply ld a, l ; low ; store Tempo in de - ld hl, wChannel1Tempo - wChannel1 + ld hl, CHANNEL_TEMPO add hl, bc ld e, [hl] inc hl ld d, [hl] ; add ???? to the next result - ld hl, wChannel1Field16 - wChannel1 + ld hl, CHANNEL_FIELD16 add hl, bc ld l, [hl] ; multiply Tempo by last result (NoteLength * LOW(delay)) @@ -2316,11 +2326,11 @@ SetNoteDuration: ; e8a8d ld e, l ld d, h ; store result in ???? - ld hl, wChannel1Field16 - wChannel1 + ld hl, CHANNEL_FIELD16 add hl, bc ld [hl], e ; store result in NoteDuration - ld hl, wChannel1NoteDuration - wChannel1 + ld hl, CHANNEL_NOTE_DURATION add hl, bc ld [hl], d ret @@ -2385,14 +2395,14 @@ Tempo: ; e8b03 ; input: ; de: note length ; update Tempo - ld hl, wChannel1Tempo - wChannel1 + ld hl, CHANNEL_TEMPO add hl, bc ld [hl], e inc hl ld [hl], d ; clear ???? xor a - ld hl, wChannel1Field16 - wChannel1 + ld hl, CHANNEL_FIELD16 add hl, bc ld [hl], a ret @@ -2401,7 +2411,7 @@ Tempo: ; e8b03 StartChannel: ; e8b11 call SetLRTracks - ld hl, wChannel1Flags - wChannel1 + ld hl, CHANNEL_FLAGS1 add hl, bc set SOUND_CHANNEL_ON, [hl] ; turn channel on ret @@ -2422,7 +2432,7 @@ SetLRTracks: ; e8b1b add hl, de ; de = channel 0-3 ld a, [hl] ; load lr tracks into Tracks - ld hl, wChannel1Tracks - wChannel1 + ld hl, CHANNEL_TRACKS add hl, bc ld [hl], a pop de @@ -2513,15 +2523,15 @@ _PlayCry:: ; e8b79 push af call LoadChannel - ld hl, wChannel1Flags - wChannel1 + ld hl, CHANNEL_FLAGS1 add hl, bc set SOUND_REST, [hl] - ld hl, wChannel1Flags2 - wChannel1 + ld hl, CHANNEL_FLAGS2 add hl, bc set SOUND_CRY_PITCH, [hl] - ld hl, wChannel1CryPitch - wChannel1 + ld hl, CHANNEL_CRY_PITCH add hl, bc ld a, [wCryPitch] ld [hli], a @@ -2535,7 +2545,7 @@ _PlayCry:: ; e8b79 jr nc, .start ; Tempo is effectively length - ld hl, wChannel1Tempo - wChannel1 + ld hl, CHANNEL_TEMPO add hl, bc ld a, [wCryLength] ld [hli], a @@ -2555,12 +2565,12 @@ _PlayCry:: ; e8b79 jr z, .next ; [Tracks] &= [wCryTracks] - ld hl, wChannel1Tracks - wChannel1 + ld hl, CHANNEL_TRACKS add hl, bc ld a, [hl] ld hl, wCryTracks and [hl] - ld hl, wChannel1Tracks - wChannel1 + ld hl, CHANNEL_TRACKS add hl, bc ld [hl], a @@ -2590,7 +2600,7 @@ _PlayCry:: ; e8b79 _PlaySFX:: ; e8c04 ; clear channels if they aren't already call MusicOff - ld hl, wChannel5Flags + ld hl, wChannel5Flags1 bit SOUND_CHANNEL_ON, [hl] ; ch5 on? jr z, .ch6 res SOUND_CHANNEL_ON, [hl] ; turn it off @@ -2606,7 +2616,7 @@ _PlaySFX:: ; e8c04 ld [wSoundInput], a ; global sound off ld [rNR10], a ; sweep = 0 .ch6 - ld hl, wChannel6Flags + ld hl, wChannel6Flags1 bit SOUND_CHANNEL_ON, [hl] jr z, .ch7 res SOUND_CHANNEL_ON, [hl] ; turn it off @@ -2619,7 +2629,7 @@ _PlaySFX:: ; e8c04 ld a, $80 ld [rNR24], a ; restart sound (freq hi = 0) .ch7 - ld hl, wChannel7Flags + ld hl, wChannel7Flags1 bit SOUND_CHANNEL_ON, [hl] jr z, .ch8 res SOUND_CHANNEL_ON, [hl] ; turn it off @@ -2633,7 +2643,7 @@ _PlaySFX:: ; e8c04 ld a, $80 ld [rNR34], a ; restart sound (freq hi = 0) .ch8 - ld hl, wChannel8Flags + ld hl, wChannel8Flags1 bit SOUND_CHANNEL_ON, [hl] jr z, .chscleared res SOUND_CHANNEL_ON, [hl] ; turn it off @@ -2674,7 +2684,7 @@ _PlaySFX:: ; e8c04 .startchannels push af call LoadChannel ; bc = current channel - ld hl, wChannel1Flags - wChannel1 + ld hl, CHANNEL_FLAGS1 add hl, bc set SOUND_SFX, [hl] call StartChannel @@ -2729,7 +2739,7 @@ PlayStereoSFX:: ; e8ca6 push af call LoadChannel - ld hl, wChannel1Flags - wChannel1 + ld hl, CHANNEL_FLAGS1 add hl, bc set SOUND_SFX, [hl] @@ -2745,11 +2755,11 @@ PlayStereoSFX:: ; e8ca6 ld hl, wStereoPanningMask and [hl] - ld hl, wChannel1Tracks - wChannel1 + ld hl, CHANNEL_TRACKS add hl, bc ld [hl], a - ld hl, wChannel1Field30 - wChannel1 + ld hl, CHANNEL_FIELD30 add hl, bc ld [hl], a @@ -2760,15 +2770,15 @@ PlayStereoSFX:: ; e8ca6 ; ch3-4 ld a, [wSFXDuration] - ld hl, wChannel1Field2e - wChannel1 + ld hl, CHANNEL_FIELD2E add hl, bc ld [hl], a - ld hl, wChannel1Field2f - wChannel1 + ld hl, CHANNEL_FIELD2F add hl, bc ld [hl], a - ld hl, wChannel1Flags2 - wChannel1 + ld hl, CHANNEL_FLAGS2 add hl, bc set SOUND_UNKN_0F, [hl] @@ -2776,7 +2786,7 @@ PlayStereoSFX:: ; e8ca6 pop de ; turn channel on - ld hl, wChannel1Flags - wChannel1 + ld hl, CHANNEL_FLAGS1 add hl, bc set SOUND_CHANNEL_ON, [hl] ; on @@ -2808,12 +2818,12 @@ LoadChannel: ; e8d1b ld c, [hl] inc hl ld b, [hl] ; bc = channel pointer - ld hl, wChannel1Flags - wChannel1 + ld hl, CHANNEL_FLAGS1 add hl, bc res SOUND_CHANNEL_ON, [hl] ; channel off call ChannelInit ; load music pointer - ld hl, wChannel1MusicAddress - wChannel1 + ld hl, CHANNEL_MUSIC_ADDRESS add hl, bc call LoadMusicByte ld [hli], a @@ -2822,14 +2832,14 @@ LoadChannel: ; e8d1b ld [hl], a inc de ; load music id - ld hl, wChannel1MusicID - wChannel1 + ld hl, CHANNEL_MUSIC_ID add hl, bc ld a, [wMusicID] ld [hli], a ld a, [wMusicID + 1] ld [hl], a ; load music bank - ld hl, wChannel1MusicBank - wChannel1 + ld hl, CHANNEL_MUSIC_BANK add hl, bc ld a, [wMusicBank] ld [hl], a @@ -2845,23 +2855,23 @@ ChannelInit: ; e8d5b push de xor a ; get channel struct location and length - ld hl, wChannel1MusicID - wChannel1 ; start + ld hl, CHANNEL_MUSIC_ID ; start add hl, bc - ld e, wChannel2 - wChannel1 ; channel struct length + ld e, CHANNEL_STRUCT_LENGTH ; channel struct length ; clear channel .loop ld [hli], a dec e jr nz, .loop ; set tempo to default ($100) - ld hl, wChannel1Tempo - wChannel1 + ld hl, CHANNEL_TEMPO add hl, bc xor a ld [hli], a inc a ld [hl], a ; set note length to default ($1) (fast) - ld hl, wChannel1NoteLength - wChannel1 + ld hl, CHANNEL_NOTE_LENGTH add hl, bc ld [hl], a pop de diff --git a/audio/sfx.asm b/audio/sfx.asm index 864e56558..2f80fa912 100644 --- a/audio/sfx.asm +++ b/audio/sfx.asm @@ -1545,9 +1545,9 @@ Sfx_2ndPlace_Ch8: ; f0fd2 togglesfx sfxtogglenoise $3 notetype $8 -Sfx_2ndPlace_branch_f0fd7: ; f0fd7 +.loop note C#, 1 - loopchannel 6, Sfx_2ndPlace_branch_f0fd7 + loopchannel 6, .loop note B_, 12 note B_, 12 note B_, 12 @@ -2085,7 +2085,7 @@ Sfx_GetBadge_Ch8: ; f121b togglesfx sfxtogglenoise $4 notetype $6 -Sfx_GetBadge_branch_f1220: ; f1220 +.loop note B_, 12 note D_, 1 note D_, 1 @@ -2100,7 +2100,7 @@ Sfx_GetBadge_branch_f1220: ; f1220 note C#, 1 note C#, 1 note C#, 1 - loopchannel 2, Sfx_GetBadge_branch_f1220 + loopchannel 2, .loop note B_, 16 note __, 6 endchannel @@ -2238,7 +2238,7 @@ Sfx_Protect_Ch5: ; f12ba togglesfx notetype $1, $f1 dutycycle $0 -Sfx_Protect_branch_f12c0: ; f12c0 +.loop octave 5 note F_, 5 note A_, 5 @@ -2251,7 +2251,7 @@ Sfx_Protect_branch_f12c0: ; f12c0 octave 6 note C#, 5 note E_, 5 - loopchannel 3, Sfx_Protect_branch_f12c0 + loopchannel 3, .loop intensity $c1 octave 5 note F_, 5 @@ -2272,10 +2272,9 @@ Sfx_Protect_branch_f12c0: ; f12c0 ; f12e5 Sfx_Protect_Ch8: ; f12e5 -Sfx_Protect_branch_f12e5: ; f12e5 noise __, 10, $9e, $0 noise __, 10, $be, $11 - loopchannel 6, Sfx_Protect_branch_f12e5 + loopchannel 6, Sfx_Protect_Ch8 noise __, 10, $a7, $0 noise C_, 1, $75, $11 endchannel @@ -2288,12 +2287,12 @@ Sfx_Sketch: ; f12f6 Sfx_Sketch_Ch5: ; f12f9 dutycycle $1 soundinput $a5 -Sfx_Sketch_branch_f12fd: ; f12fd +.loop sound __, 3, $f1, $06e0 sound __, 14, $af, $05b0 sound __, 5, $0, 0 sound __, 10, $f4, $0718 - loopchannel 3, Sfx_Sketch_branch_f12fd + loopchannel 3, .loop soundinput $8 endchannel ; f1314 @@ -2303,12 +2302,11 @@ Sfx_RainDance: ; f1314 ; f1317 Sfx_RainDance_Ch8: ; f1317 -Sfx_RainDance_branch_f1317: ; f1317 noise __, 12, $7d, $50 noise __, 7, $7d, $4f noise __, 12, $7f, $47 noise __, 16, $6e, $22 - loopchannel 3, Sfx_RainDance_branch_f1317 + loopchannel 3, Sfx_RainDance_Ch8 noise __, 7, $6d, $50 noise __, 6, $5d, $4f noise __, 6, $4f, $47 @@ -2342,10 +2340,9 @@ Sfx_Spark: ; f1352 ; f1355 Sfx_Spark_Ch8: ; f1355 -Sfx_Spark_branch_f1355: ; f1355 noise __, 5, $f8, $5d noise __, 5, $d8, $6f - loopchannel 2, Sfx_Spark_branch_f1355 + loopchannel 2, Sfx_Spark_Ch8 endchannel ; f1360 @@ -2393,12 +2390,11 @@ Sfx_Thief: ; f139c ; f139f Sfx_Thief_Ch8: ; f139f -Sfx_Thief_branch_f139f: ; f139f noise __, 1, $0, $0 noise __, 5, $e1, $12 noise __, 1, $0, $0 noise __, 3, $b1, $22 - loopchannel 2, Sfx_Thief_branch_f139f + loopchannel 2, Sfx_Thief_Ch8 endchannel ; f13b0 @@ -2488,7 +2484,7 @@ Sfx_Nightmare: ; f141d Sfx_Nightmare_Ch5: ; f1420 dutycycle $0 soundinput $34 -Sfx_Nightmare_branch_f1424: ; f1424 +.loop sound __, 4, $ba, $0631 sound __, 3, $0, 0 sound __, 4, $f8, $0621 @@ -2499,7 +2495,7 @@ Sfx_Nightmare_branch_f1424: ; f1424 sound __, 3, $0, 0 sound __, 4, $e8, $05f1 sound __, 3, $0, 0 - loopchannel 2, Sfx_Nightmare_branch_f1424 + loopchannel 2, .loop soundinput $8 endchannel ; f1453 @@ -2524,10 +2520,10 @@ Sfx_SweetKiss: ; f1469 Sfx_SweetKiss_Ch5: ; f146c dutycycle $2 -Sfx_SweetKiss_branch_f146e: ; f146e +.loop sound __, 3, $c1, $07c8 sound __, 3, $d1, $07da - loopchannel 2, Sfx_SweetKiss_branch_f146e + loopchannel 2, .loop sound C_, 11, $f1, $07e2 endchannel ; f147f @@ -2757,10 +2753,9 @@ Sfx_ZapCannon: ; f15de ; f15e1 Sfx_ZapCannon_Ch8: ; f15e1 -Sfx_ZapCannon_branch_f15e1: ; f15e1 noise __, 3, $e1, $49 noise __, 1, $0, $0 - loopchannel 8, Sfx_ZapCannon_branch_f15e1 + loopchannel 8, Sfx_ZapCannon_Ch8 noise __, 9, $e1, $49 endchannel ; f15ef @@ -2773,10 +2768,10 @@ Sfx_MeanLook_Ch5: ; f15f2 soundinput $77 dutycycle $3 sound __, 3, $f8, $0720 -Sfx_MeanLook_branch_f15fa: ; f15fa +.loop sound __, 2, $88, $0660 sound __, 3, $f8, $0790 - loopchannel 5, Sfx_MeanLook_branch_f15fa + loopchannel 5, .loop sound __, 13, $f8, $0700 sound __, 13, $c8, $0720 sound __, 13, $a8, $0700 @@ -2806,13 +2801,13 @@ Sfx_Return: ; f1637 Sfx_Return_Ch5: ; f163a dutycycle $0 -Sfx_Return_branch_f163c: ; f163c +.loop soundinput $bf sound __, 9, $f1, $0759 soundinput $57 sound __, 9, $f1, $0759 sound C_, 1, $0, 0 - loopchannel 2, Sfx_Return_branch_f163c + loopchannel 2, .loop soundinput $8 endchannel ; f1653 @@ -2843,14 +2838,14 @@ Sfx_MilkDrink: ; f167f Sfx_MilkDrink_Ch5: ; f1682 dutycycle $2 -Sfx_MilkDrink_branch_f1684: ; f1684 +.loop soundinput $a4 sound __, 3, $ea, $04e0 sound __, 14, $f7, $0290 soundinput $9e sound __, 5, $c9, $05e1 sound __, 3, $0, 0 - loopchannel 6, Sfx_MilkDrink_branch_f1684 + loopchannel 6, .loop soundinput $8 endchannel ; f169f @@ -2862,10 +2857,10 @@ Sfx_Present: ; f169f Sfx_Present_Ch5: ; f16a2 dutycycle $2 soundinput $d6 -Sfx_Present_branch_f16a6: ; f16a6 +.loop sound __, 3, $f1, $0740 sound __, 2, $0, 0 - loopchannel 3, Sfx_Present_branch_f16a6 + loopchannel 3, .loop sound C_, 1, $f1, $0780 soundinput $8 endchannel @@ -2877,11 +2872,11 @@ Sfx_MorningSun: ; f16b9 Sfx_MorningSun_Ch5: ; f16bc dutycycle $3 -Sfx_MorningSun_branch_f16be: ; f16be +.loop sound __, 3, $f1, $07e4 sound __, 3, $f1, $07e0 sound __, 6, $f2, $07e7 - loopchannel 3, Sfx_MorningSun_branch_f16be + loopchannel 3, .loop sound __, 2, $0, 0 sound __, 9, $c2, $07e7 sound __, 2, $0, 0 @@ -2895,10 +2890,10 @@ Sfx_Moonlight: ; f16df Sfx_Moonlight_Ch5: ; f16e2 dutycycle $2 -Sfx_Moonlight_branch_f16e4: ; f16e4 +.loop sound __, 2, $f8, $07d0 sound __, 5, $f1, $07e0 - loopchannel 2, Sfx_Moonlight_branch_f16e4 + loopchannel 2, .loop sound C_, 1, $f1, $07e0 sound C_, 1, $d1, $07e0 sound C_, 1, $81, $07e0 @@ -2914,10 +2909,10 @@ Sfx_Encore_Ch5: ; f1703 dutycycle $2 soundinput $ce sound C_, 1, $0, 0 -Sfx_Encore_branch_f170b: ; f170b +.loop sound __, 3, $f8, $0774 sound C#, 5, $0, 0 - loopchannel 2, Sfx_Encore_branch_f170b + loopchannel 2, .loop soundinput $8 endchannel ; f171a @@ -3085,12 +3080,12 @@ Sfx_GsIntroCharizardFireball: ; f17d9 Sfx_GsIntroCharizardFireball_Ch8: ; f17dc noise __, 9, $cf, $4d noise __, 9, $f1, $37 -Sfx_GsIntroCharizardFireball_branch_f17e2: ; f17e2 +.loop noise __, 2, $f8, $4f noise __, 1, $c8, $26 noise __, 2, $d8, $5f noise __, 1, $a8, $37 - loopchannel 12, Sfx_GsIntroCharizardFireball_branch_f17e2 + loopchannel 12, .loop noise __, 4, $f8, $6f noise __, 5, $d8, $5f noise __, 13, $d8, $5c @@ -3348,13 +3343,13 @@ Sfx_DexFanfare140169_Ch8: ; f193f sfxtogglenoise $4 notetype $c note C_, 4 -Sfx_DexFanfare140169_branch_f1945: ; f1945 +.loop note D_, 4 note C#, 1 note C#, 1 note C#, 1 note C#, 1 - loopchannel 3, Sfx_DexFanfare140169_branch_f1945 + loopchannel 3, .loop note D_, 8 endchannel ; f1950 @@ -3762,7 +3757,7 @@ Sfx_DexFanfare230Plus_Ch8: ; f1b0c note D_, 2 note D_, 2 note D_, 2 -Sfx_DexFanfare230Plus_branch_f1b14: ; f1b14 +.loop1 note D_, 6 note D_, 2 note D_, 2 @@ -3774,7 +3769,7 @@ Sfx_DexFanfare230Plus_branch_f1b14: ; f1b14 note C#, 1 note C#, 1 note C#, 1 - loopchannel 2, Sfx_DexFanfare230Plus_branch_f1b14 + loopchannel 2, .loop1 note D_, 6 note D_, 2 note D_, 2 @@ -3783,9 +3778,9 @@ Sfx_DexFanfare230Plus_branch_f1b14: ; f1b14 note D_, 4 note D_, 4 note D_, 4 -Sfx_DexFanfare230Plus_branch_f1b2b: ; f1b2b +.loop2 note C#, 1 - loopchannel 18, Sfx_DexFanfare230Plus_branch_f1b2b + loopchannel 18, .loop2 note D_, 6 endchannel ; f1b32 @@ -3878,11 +3873,11 @@ Sfx_SweetScent2_Ch5: ; f1bb9 Sfx_SweetScent2_Ch8: ; f1bcc noise __, 3, $e8, $22 noise C_, 2, $aa, $0 -Sfx_SweetScent2_branch_f1bd2: ; f1bd2 +.loop noise __, 5, $d9, $10 noise __, 9, $91, $0 noise __, 3, $61, $7 - loopchannel 5, Sfx_SweetScent2_branch_f1bd2 + loopchannel 5, .loop noise __, 5, $99, $0 noise __, 11, $61, $0 noise __, 7, $59, $0 @@ -3990,13 +3985,13 @@ Sfx_2Boops: ; f1cb4 Sfx_2Boops_Ch5: ; f1cb7 dutycycle $2 -Sfx_2Boops_branch_f1cb9: ; f1cb9 +.loop soundinput $79 sound __, 2, $99, $0563 sound __, 5, $f2, $04b5 soundinput $43 sound C_, 1, $f8, $05cd - loopchannel 2, Sfx_2Boops_branch_f1cb9 + loopchannel 2, .loop soundinput $8 endchannel ; f1cd0 @@ -4150,11 +4145,10 @@ Sfx_Potion_Ch5: ; f1d9d ; f1dac Sfx_Poison_Ch5: ; f1dac -Sfx_Poison_branch_f1dac: ; f1dac dutycycle $0 soundinput $14 sound __, 5, $f2, $0600 - loopchannel 4, Sfx_Poison_branch_f1dac + loopchannel 4, Sfx_Poison_Ch5 sound __, 16, $f3, $0600 soundinput $8 endchannel @@ -4572,11 +4566,10 @@ Sfx_Cut_Ch8: ; f20c3 ; f20d0 Sfx_WingAttack_Ch8: ; f20d0 -Sfx_WingAttack_branch_f20d0: ; f20d0 noise __, 9, $4f, $23 noise __, 5, $c4, $22 noise __, 7, $f2, $23 - loopchannel 4, Sfx_WingAttack_branch_f20d0 + loopchannel 4, Sfx_WingAttack_Ch8 endchannel ; f20de @@ -4754,9 +4747,9 @@ Sfx_Thunder_Ch8: ; f21d3 Sfx_Supersonic_Ch5: ; f21e9 dutycycle $2 sound __, 16, $3f, $07c0 -Sfx_Supersonic_branch_f21ef: ; f21ef +.loop sound __, 16, $df, $07c0 - loopchannel 4, Sfx_Supersonic_branch_f21ef + loopchannel 4, .loop sound __, 16, $d1, $07c0 endchannel ; f21fc @@ -4764,63 +4757,57 @@ Sfx_Supersonic_branch_f21ef: ; f21ef Sfx_Supersonic_Ch6: ; f21fc sound_duty 3, 0, 3, 2 sound __, 16, $2f, $07c8 -Sfx_Supersonic_branch_f2202: ; f2202 +.loop sound __, 16, $cf, $07c7 - loopchannel 4, Sfx_Supersonic_branch_f2202 + loopchannel 4, .loop sound __, 16, $c1, $07c8 endchannel ; f220f Sfx_Supersonic_Ch8: ; f220f -Sfx_Supersonic_branch_f220f: ; f220f noise __, 4, $97, $12 noise __, 4, $a1, $11 - loopchannel 10, Sfx_Supersonic_branch_f220f + loopchannel 10, Sfx_Supersonic_Ch8 endchannel ; f221a Sfx_Leer_Ch5: ; f221a -Sfx_Leer_branch_f221a: ; f221a dutycycle $0 sound __, 1, $f1, $07c0 sound __, 1, $f1, $0700 - loopchannel 12, Sfx_Leer_branch_f221a + loopchannel 12, Sfx_Leer_Ch5 endchannel ; f2229 Sfx_Leer_Ch6: ; f2229 -Sfx_Leer_branch_f2229: ; f2229 sound_duty 3, 0, 3, 2 sound __, 1, $e1, $07c1 sound __, 1, $e1, $0701 - loopchannel 12, Sfx_Leer_branch_f2229 + loopchannel 12, Sfx_Leer_Ch6 endchannel ; f2238 Sfx_Leer_Ch8: ; f2238 -Sfx_Leer_branch_f2238: ; f2238 noise __, 2, $d1, $49 noise __, 2, $d1, $29 - loopchannel 6, Sfx_Leer_branch_f2238 + loopchannel 6, Sfx_Leer_Ch8 endchannel ; f2243 Sfx_Ember_Ch5: ; f2243 -Sfx_Ember_branch_f2243: ; f2243 sound_duty 1, 2, 0, 3 sound __, 12, $f3, $0120 sound __, 10, $d3, $0150 - loopchannel 5, Sfx_Ember_branch_f2243 + loopchannel 5, Sfx_Ember_Ch5 sound __, 9, $e3, $0130 sound __, 16, $c2, $0110 endchannel ; f225a Sfx_Ember_Ch8: ; f225a -Sfx_Ember_branch_f225a: ; f225a noise __, 11, $f3, $35 noise __, 15, $f6, $45 - loopchannel 4, Sfx_Ember_branch_f225a + loopchannel 4, Sfx_Ember_Ch8 noise __, 13, $f4, $bc noise __, 13, $f5, $9c noise __, 16, $f4, $ac @@ -4828,178 +4815,161 @@ Sfx_Ember_branch_f225a: ; f225a ; f226e Sfx_Bubblebeam_Ch5: ; f226e -Sfx_Bubblebeam_branch_f226e: ; f226e sound_duty 1, 2, 3, 0 sound __, 5, $f4, $0600 sound __, 4, $c4, $0500 sound __, 6, $b5, $0600 sound __, 14, $e2, $06c0 - loopchannel 3, Sfx_Bubblebeam_branch_f226e + loopchannel 3, Sfx_Bubblebeam_Ch5 sound __, 9, $d1, $0600 endchannel ; f2289 Sfx_Bubblebeam_Ch6: ; f2289 -Sfx_Bubblebeam_branch_f2289: ; f2289 sound_duty 1, 3, 0, 2 sound __, 6, $e4, $05e0 sound __, 5, $b4, $04e0 sound __, 7, $a5, $05e8 sound __, 15, $d1, $06a0 - loopchannel 3, Sfx_Bubblebeam_branch_f2289 + loopchannel 3, Sfx_Bubblebeam_Ch6 endchannel ; f22a0 Sfx_Bubblebeam_Ch8: ; f22a0 -Sfx_Bubblebeam_branch_f22a0: ; f22a0 noise __, 6, $c3, $33 noise __, 4, $92, $43 noise __, 11, $b5, $33 noise __, 16, $c3, $32 - loopchannel 2, Sfx_Bubblebeam_branch_f22a0 + loopchannel 2, Sfx_Bubblebeam_Ch8 endchannel ; f22b1 Sfx_HydroPump_Ch5: ; f22b1 -Sfx_HydroPump_branch_f22b1: ; f22b1 sound_duty 2, 0, 1, 3 sound __, 4, $81, $0300 sound __, 4, $c1, $0400 sound __, 4, $f1, $0500 sound __, 4, $b1, $0400 sound __, 4, $71, $0300 - loopchannel 5, Sfx_HydroPump_branch_f22b1 + loopchannel 5, Sfx_HydroPump_Ch5 sound __, 9, $81, $0400 endchannel ; f22d0 Sfx_HydroPump_Ch8: ; f22d0 -Sfx_HydroPump_branch_f22d0: ; f22d0 noise __, 4, $62, $22 noise __, 4, $a2, $32 noise __, 4, $d2, $33 noise __, 4, $92, $23 noise __, 4, $52, $12 - loopchannel 5, Sfx_HydroPump_branch_f22d0 + loopchannel 5, Sfx_HydroPump_Ch8 noise __, 9, $81, $12 endchannel ; f22e7 Sfx_Surf_Ch5: ; f22e7 -Sfx_Surf_branch_f22e7: ; f22e7 sound_duty 1, 2, 3, 0 sound __, 16, $f4, $0500 sound __, 16, $c4, $0400 sound __, 16, $e2, $05c0 - loopchannel 3, Sfx_Surf_branch_f22e7 + loopchannel 3, Sfx_Surf_Ch5 endchannel ; f22fa Sfx_Surf_Ch6: ; f22fa -Sfx_Surf_branch_f22fa: ; f22fa sound_duty 1, 3, 0, 2 sound __, 8, $e4, $0430 sound __, 16, $b4, $0330 sound __, 16, $a2, $0438 - loopchannel 4, Sfx_Surf_branch_f22fa + loopchannel 4, Sfx_Surf_Ch6 endchannel ; f230d Sfx_Surf_Ch8: ; f230d -Sfx_Surf_branch_f230d: ; f230d noise __, 10, $f4, $44 noise __, 10, $f2, $43 noise __, 16, $f4, $42 noise __, 16, $f4, $41 - loopchannel 3, Sfx_Surf_branch_f230d + loopchannel 3, Sfx_Surf_Ch8 endchannel ; f231e Sfx_Psybeam_Ch5: ; f231e -Sfx_Psybeam_branch_f231e: ; f231e sound_duty 1, 0, 2, 2 sound __, 11, $f1, $0640 sound __, 11, $f3, $0680 sound __, 11, $f2, $0620 - loopchannel 4, Sfx_Psybeam_branch_f231e + loopchannel 4, Sfx_Psybeam_Ch5 sound __, 11, $f1, $0640 endchannel ; f2335 Sfx_Psybeam_Ch6: ; f2335 -Sfx_Psybeam_branch_f2335: ; f2335 sound_duty 3, 0, 3, 2 sound __, 11, $f3, $0571 sound __, 8, $e3, $0531 sound __, 11, $f1, $0551 - loopchannel 4, Sfx_Psybeam_branch_f2335 + loopchannel 4, Sfx_Psybeam_Ch6 sound __, 11, $f1, $0571 endchannel ; f234c Sfx_Psybeam_Ch8: ; f234c -Sfx_Psybeam_branch_f234c: ; f234c noise __, 3, $d1, $4a noise __, 3, $d2, $2a - loopchannel 21, Sfx_Psybeam_branch_f234c + loopchannel 21, Sfx_Psybeam_Ch8 endchannel ; f2357 Sfx_Charge_Ch5: ; f2357 -Sfx_Charge_branch_f2357: ; f2357 dutycycle $0 sound __, 3, $f1, $0200 sound __, 4, $f1, $0700 sound __, 5, $f1, $0500 sound __, 6, $f1, $07f0 - loopchannel 8, Sfx_Charge_branch_f2357 + loopchannel 8, Sfx_Charge_Ch5 endchannel ; f236e Sfx_Charge_Ch6: ; f236e -Sfx_Charge_branch_f236e: ; f236e sound_duty 3, 0, 3, 2 sound __, 3, $e1, $0302 sound __, 4, $e1, $07f2 sound __, 5, $e1, $0602 sound __, 6, $e1, $0702 - loopchannel 8, Sfx_Charge_branch_f236e + loopchannel 8, Sfx_Charge_Ch6 endchannel ; f2385 Sfx_Charge_Ch8: ; f2385 -Sfx_Charge_branch_f2385: ; f2385 noise __, 3, $d3, $10 noise __, 4, $d3, $11 noise __, 3, $d2, $10 noise __, 6, $d2, $12 - loopchannel 9, Sfx_Charge_branch_f2385 + loopchannel 9, Sfx_Charge_Ch8 endchannel ; f2396 Sfx_Thundershock_Ch5: ; f2396 -Sfx_Thundershock_branch_f2396: ; f2396 sound_duty 3, 2, 2, 0 sound __, 4, $f1, $07f0 sound __, 5, $f2, $0200 - loopchannel 8, Sfx_Thundershock_branch_f2396 + loopchannel 8, Sfx_Thundershock_Ch5 endchannel ; f23a5 Sfx_Thundershock_Ch6: ; f23a5 -Sfx_Thundershock_branch_f23a5: ; f23a5 sound_duty 3, 0, 3, 2 sound __, 5, $e2, $0202 sound __, 5, $e1, $07e2 - loopchannel 9, Sfx_Thundershock_branch_f23a5 + loopchannel 9, Sfx_Thundershock_Ch6 endchannel ; f23b4 Sfx_Thundershock_Ch8: ; f23b4 -Sfx_Thundershock_branch_f23b4: ; f23b4 noise __, 5, $ff, $43 noise __, 5, $f2, $44 - loopchannel 9, Sfx_Thundershock_branch_f23b4 + loopchannel 9, Sfx_Thundershock_Ch8 endchannel ; f23bf @@ -5159,10 +5129,10 @@ Sfx_HyperBeam_Ch5: ; f24ca sound __, 3, $f1, $07c0 sound __, 3, $f1, $0700 sound __, 3, $f1, $07d0 -Sfx_HyperBeam_branch_f24f8: ; f24f8 +.loop sound __, 3, $f1, $0700 sound __, 3, $f1, $07e0 - loopchannel 12, Sfx_HyperBeam_branch_f24f8 + loopchannel 12, .loop sound __, 16, $f1, $0700 endchannel ; f2509 @@ -5180,19 +5150,18 @@ Sfx_HyperBeam_Ch6: ; f2509 sound __, 3, $f1, $07c1 sound __, 3, $f1, $0701 sound __, 3, $f1, $07d1 -Sfx_HyperBeam_branch_f2537: ; f2537 +.loop sound __, 3, $f1, $0701 sound __, 3, $f1, $07e1 - loopchannel 12, Sfx_HyperBeam_branch_f2537 + loopchannel 12, .loop sound __, 16, $f1, $0701 endchannel ; f2548 Sfx_HyperBeam_Ch8: ; f2548 -Sfx_HyperBeam_branch_f2548: ; f2548 noise __, 2, $d1, $49 noise __, 2, $d1, $29 - loopchannel 26, Sfx_HyperBeam_branch_f2548 + loopchannel 26, Sfx_HyperBeam_Ch8 endchannel ; f2553 @@ -5302,10 +5271,9 @@ Sfx_Metronome_Ch5: ; f25ec ; f2617 Sfx_Unknown5F_Ch5: ; f2617 -Sfx_Unknown5F_branch_f2617: ; f2617 sound __, 3, $f7, $0601 sound __, 3, $f7, $0701 - loopchannel 8, Sfx_Unknown5F_branch_f2617 + loopchannel 8, Sfx_Unknown5F_Ch5 endchannel ; f2624 @@ -5313,7 +5281,7 @@ Sfx_Unknown5F_Ch6: ; f2624 sound __, 2, $f7, $ffff sound __, 3, $f7, $0602 sound __, 3, $f7, $0702 - loopchannel 8, Sfx_Unknown5F_branch_f2617 + loopchannel 8, Sfx_Unknown5F_Ch5 endchannel ; f2635 @@ -5484,35 +5452,31 @@ Sfx_HangUp_Ch5: ; f26f1 sound __, 5, $b8, $077b sound __, 3, $21, $077b sound C_, 1, $0, 0 -Sfx_HangUp_branch_f26ff: ; f26ff Sfx_NoSignal_Ch5: ; f26ff -Sfx_NoSignal_branch_f26ff: ; f26ff dutycycle $2 sound C_, 5, $e8, $070b sound C_, 13, $0, 0 - loopchannel 3, Sfx_HangUp_branch_f26ff + loopchannel 3, Sfx_NoSignal_Ch5 endchannel ; f270e Sfx_Sandstorm_Ch8: ; f270e -Sfx_Sandstorm_branch_f270e: ; f270e Sfx_Unknown5F_Ch8: ; f270e -Sfx_Unknown5F_branch_f270e: ; f270e noise __, 2, $f8, $41 noise __, 3, $9c, $24 noise __, 1, $0, $0 noise __, 4, $59, $16 noise __, 3, $0, $0 - loopchannel 3, Sfx_Sandstorm_branch_f270e + loopchannel 3, Sfx_Sandstorm_Ch8 endchannel ; f2722 Sfx_Elevator_Ch5: ; f2722 dutycycle $2 soundinput $5a -Sfx_Elevator_branch_f2726: ; f2726 +.loop sound __, 3, $f1, $0300 - loopchannel 48, Sfx_Elevator_branch_f2726 + loopchannel 48, .loop soundinput $8 dutycycle $2 sound __, 16, $f3, $0730 diff --git a/audio/sfx_crystal.asm b/audio/sfx_crystal.asm index 178d4b560..eb5cae561 100644 --- a/audio/sfx_crystal.asm +++ b/audio/sfx_crystal.asm @@ -196,7 +196,7 @@ Sfx_Tingle_Ch5: ; 179964 dutycycle $1 pitchoffset 0, B_ notetype $1, $b1 -Sfx_Tingle_branch_17996c: ; 17996c +.loop octave 5 note C_, 3 octave 6 @@ -204,7 +204,7 @@ Sfx_Tingle_branch_17996c: ; 17996c octave 5 note C_, 3 note __, 2 - loopchannel 2, Sfx_Tingle_branch_17996c + loopchannel 2, .loop note C_, 2 intensity $a1 note G_, 13 diff --git a/constants/audio_constants.asm b/constants/audio_constants.asm index 85c5cc577..ec8311dfe 100644 --- a/constants/audio_constants.asm +++ b/constants/audio_constants.asm @@ -31,6 +31,46 @@ NUM_NOISE_CHANS EQU const_value const CHAN8 ; 7 NUM_CHANNELS EQU const_value +; channel_struct members (see macros/wram.asm) +CHANNEL_MUSIC_ID EQUS "(wChannel1MusicID - wChannel1)" +CHANNEL_MUSIC_BANK EQUS "(wChannel1MusicBank - wChannel1)" +CHANNEL_FLAGS1 EQUS "(wChannel1Flags1 - wChannel1)" +CHANNEL_FLAGS2 EQUS "(wChannel1Flags2 - wChannel1)" +CHANNEL_FLAGS3 EQUS "(wChannel1Flags3 - wChannel1)" +CHANNEL_MUSIC_ADDRESS EQUS "(wChannel1MusicAddress - wChannel1)" +CHANNEL_LAST_MUSIC_ADDRESS EQUS "(wChannel1LastMusicAddress - wChannel1)" +CHANNEL_NOTE_FLAGS EQUS "(wChannel1NoteFlags - wChannel1)" +CHANNEL_CONDITION EQUS "(wChannel1Condition - wChannel1)" +CHANNEL_DUTY_CYCLE EQUS "(wChannel1DutyCycle - wChannel1)" +CHANNEL_INTENSITY EQUS "(wChannel1Intensity - wChannel1)" +CHANNEL_FREQUENCY EQUS "(wChannel1Frequency - wChannel1)" +CHANNEL_PITCH EQUS "(wChannel1Pitch - wChannel1)" +CHANNEL_OCTAVE EQUS "(wChannel1Octave - wChannel1)" +CHANNEL_PITCH_OFFSET EQUS "(wChannel1PitchOffset - wChannel1)" +CHANNEL_NOTE_DURATION EQUS "(wChannel1NoteDuration - wChannel1)" +CHANNEL_FIELD16 EQUS "(wChannel1Field16 - wChannel1)" +CHANNEL_LOOP_COUNT EQUS "(wChannel1LoopCount - wChannel1)" +CHANNEL_TEMPO EQUS "(wChannel1Tempo - wChannel1)" +CHANNEL_TRACKS EQUS "(wChannel1Tracks - wChannel1)" +CHANNEL_SFX_DUTY_LOOP EQUS "(wChannel1SFXDutyLoop - wChannel1)" +CHANNEL_VIBRATO_DELAY_COUNT EQUS "(wChannel1VibratoDelayCount - wChannel1)" +CHANNEL_VIBRATO_DELAY EQUS "(wChannel1VibratoDelay - wChannel1)" +CHANNEL_VIBRATO_EXTENT EQUS "(wChannel1VibratoExtent - wChannel1)" +CHANNEL_VIBRATO_RATE EQUS "(wChannel1VibratoRate - wChannel1)" +CHANNEL_PITCH_WHEEL_TARGET EQUS "(wChannel1PitchWheelTarget - wChannel1)" +CHANNEL_PITCH_WHEEL_AMOUNT EQUS "(wChannel1PitchWheelAmount - wChannel1)" +CHANNEL_PITCH_WHEEL_AMOUNT_FRACTION EQUS "(wChannel1PitchWheelAmountFraction - wChannel1)" +CHANNEL_FIELD25 EQUS "(wChannel1Field25 - wChannel1)" +CHANNEL_CRY_PITCH EQUS "(wChannel1CryPitch - wChannel1)" +CHANNEL_FIELD29 EQUS "(wChannel1Field29 - wChannel1)" +CHANNEL_FIELD2A EQUS "(wChannel1Field2a - wChannel1)" +CHANNEL_FIELD2C EQUS "(wChannel1Field2c - wChannel1)" +CHANNEL_NOTE_LENGTH EQUS "(wChannel1NoteLength - wChannel1)" +CHANNEL_FIELD2E EQUS "(wChannel1Field2e - wChannel1)" +CHANNEL_FIELD2F EQUS "(wChannel1Field2f - wChannel1)" +CHANNEL_FIELD30 EQUS "(wChannel1Field30 - wChannel1)" +CHANNEL_STRUCT_LENGTH EQUS "(wChannel2 - wChannel1)" + NOISE_CHAN_F EQU 2 ; bit set in CHAN5-CHAN7 ; Flags1 @@ -69,11 +109,11 @@ NOISE_CHAN_F EQU 2 ; bit set in CHAN5-CHAN7 const NOTE_VIBRATO_OVERRIDE ; 6 ; wVolume -VOLUME_SO1_F EQU 3 -VOLUME_SO2_F EQU 7 +VOLUME_SO1_F EQU 3 +VOLUME_SO2_F EQU 7 VOLUME_SO1_LEVEL EQU %00000111 VOLUME_SO2_LEVEL EQU %01110000 -MAX_VOLUME EQU $77 +MAX_VOLUME EQU $77 ; wSoundInput SOUND_INPUT_CH1_F EQU 0 diff --git a/data/items/attributes.asm b/data/items/attributes.asm index 9f669e979..e0198e3ad 100644 --- a/data/items/attributes.asm +++ b/data/items/attributes.asm @@ -269,7 +269,7 @@ ItemAttributes: ; 67c1 item_attribute 0, HELD_NONE, 0, CANT_SELECT | CANT_TOSS, KEY_ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE ; STARDUST item_attribute 2000, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE -; STAR PIECE +; STAR_PIECE item_attribute 9800, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE ; BASEMENT_KEY item_attribute 0, HELD_NONE, 0, CANT_SELECT | CANT_TOSS, KEY_ITEM, ITEMMENU_CLOSE, ITEMMENU_NOUSE diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm index 5fd37e054..2723bba6b 100644 --- a/engine/battle/effect_commands.asm +++ b/engine/battle/effect_commands.asm @@ -64,7 +64,7 @@ DoMove: ; 3402c inc hl ld [de], a inc de - cp -1 + cp endmove_command jr nz, .GetMoveEffect ; Start at the first command. diff --git a/engine/events/specials.asm b/engine/events/specials.asm index acfc3c450..533f59520 100644 --- a/engine/events/specials.asm +++ b/engine/events/specials.asm @@ -95,13 +95,13 @@ NameRival: ; 0xc29d farcall _NamingScreen ; default to "SILVER" ld hl, wRivalName - ld de, DefaultRivalName + ld de, .default call InitName ret -; 0xc2b2 -DefaultRivalName: ; 0xc2b2 +.default db "SILVER@" +; 0xc2b9 NameRater: ; c2b9 farcall _NameRater diff --git a/engine/gfx/pic_animation.asm b/engine/gfx/pic_animation.asm index 54999a6bb..925296388 100644 --- a/engine/gfx/pic_animation.asm +++ b/engine/gfx/pic_animation.asm @@ -399,11 +399,11 @@ PokeAnim_DoAnimScript: ; d0250 .RunAnim: ; d0261 call PokeAnim_GetPointer ld a, [wPokeAnimCommand] - cp -1 + cp endanim_command jr z, PokeAnim_End - cp -2 + cp setrepeat_command jr z, .SetRepeat - cp -3 + cp dorepeat_command jr z, .DoRepeat call PokeAnim_GetFrame ld a, [wPokeAnimParameter] diff --git a/engine/overworld/map_objects.asm b/engine/overworld/map_objects.asm index 6652beead..7ed1d5f5f 100644 --- a/engine/overworld/map_objects.asm +++ b/engine/overworld/map_objects.asm @@ -2116,13 +2116,13 @@ SpawnEmote: ; 5547 ShakeGrass: ; 5556 push bc - ld de, .data_5562 + ld de, .GrassObject call CopyTempObjectData call InitTempObject pop bc ret -.data_5562 +.GrassObject db $00, PAL_OW_TREE, SPRITEMOVEDATA_GRASS ; 5565 @@ -2140,6 +2140,7 @@ ShakeScreen: ; 5565 .ScreenShakeObject: db $00, PAL_OW_SILVER, SPRITEMOVEDATA_SCREENSHAKE ; 5579 + DespawnEmote: ; 5579 push bc ld a, [hMapObjectIndexBuffer] diff --git a/home/audio.asm b/home/audio.asm index 4b9c3a71c..05dbafa0a 100644 --- a/home/audio.asm +++ b/home/audio.asm @@ -249,16 +249,16 @@ WaitSFX:: ; 3c55 push hl .wait - ld hl, wChannel5Flags + ld hl, wChannel5Flags1 bit 0, [hl] jr nz, .wait - ld hl, wChannel6Flags + ld hl, wChannel6Flags1 bit 0, [hl] jr nz, .wait - ld hl, wChannel7Flags + ld hl, wChannel7Flags1 bit 0, [hl] jr nz, .wait - ld hl, wChannel8Flags + ld hl, wChannel8Flags1 bit 0, [hl] jr nz, .wait @@ -271,16 +271,16 @@ IsSFXPlaying:: ; 3c74 ; The inverse of CheckSFX. push hl - ld hl, wChannel5Flags + ld hl, wChannel5Flags1 bit 0, [hl] jr nz, .playing - ld hl, wChannel6Flags + ld hl, wChannel6Flags1 bit 0, [hl] jr nz, .playing - ld hl, wChannel7Flags + ld hl, wChannel7Flags1 bit 0, [hl] jr nz, .playing - ld hl, wChannel8Flags + ld hl, wChannel8Flags1 bit 0, [hl] jr nz, .playing @@ -540,16 +540,16 @@ Unreferenced_Function3d9f:: ; 3d9f CheckSFX:: ; 3dde ; Return carry if any SFX channels are active. - ld a, [wChannel5Flags] + ld a, [wChannel5Flags1] bit 0, a jr nz, .playing - ld a, [wChannel6Flags] + ld a, [wChannel6Flags1] bit 0, a jr nz, .playing - ld a, [wChannel7Flags] + ld a, [wChannel7Flags1] bit 0, a jr nz, .playing - ld a, [wChannel8Flags] + ld a, [wChannel8Flags1] bit 0, a jr nz, .playing and a @@ -561,7 +561,7 @@ CheckSFX:: ; 3dde TerminateExpBarSound:: ; 3dfe xor a - ld [wChannel5Flags], a + ld [wChannel5Flags1], a ld [wSoundInput], a ld [rNR10], a ld [rNR11], a @@ -575,10 +575,10 @@ TerminateExpBarSound:: ; 3dfe ChannelsOff:: ; 3e10 ; Quickly turn off music channels xor a - ld [wChannel1Flags], a - ld [wChannel2Flags], a - ld [wChannel3Flags], a - ld [wChannel4Flags], a + ld [wChannel1Flags1], a + ld [wChannel2Flags1], a + ld [wChannel3Flags1], a + ld [wChannel4Flags1], a ld [wSoundInput], a ret ; 3e21 @@ -586,10 +586,10 @@ ChannelsOff:: ; 3e10 SFXChannelsOff:: ; 3e21 ; Quickly turn off sound effect channels xor a - ld [wChannel5Flags], a - ld [wChannel6Flags], a - ld [wChannel7Flags], a - ld [wChannel8Flags], a + ld [wChannel5Flags1], a + ld [wChannel6Flags1], a + ld [wChannel7Flags1], a + ld [wChannel8Flags1], a ld [wSoundInput], a ret ; 3e32 diff --git a/macros/wram.asm b/macros/wram.asm index 469cc1022..6096d2bba 100644 --- a/macros/wram.asm +++ b/macros/wram.asm @@ -131,7 +131,7 @@ channel_struct: MACRO ; Addreses are wChannel1 (c101). \1MusicID:: dw \1MusicBank:: db -\1Flags:: db ; 0:on/off 1:subroutine 3:sfx 4:noise 5:rest +\1Flags1:: db ; 0:on/off 1:subroutine 3:sfx 4:noise 5:rest \1Flags2:: db ; 0:vibrato on/off 2:duty 4:cry pitch \1Flags3:: db ; 0:vibrato up/down \1MusicAddress:: dw @@ -141,9 +141,7 @@ channel_struct: MACRO \1Condition:: db ; conditional jumps \1DutyCycle:: db ; bits 6-7 (0:12.5% 1:25% 2:50% 3:75%) \1Intensity:: db ; hi:pressure lo:velocity -\1Frequency:: ; 11 bits -\1FrequencyLo:: db -\1FrequencyHi:: db +\1Frequency:: dw ; 11 bits \1Pitch:: db ; 0:rest 1-c:note \1Octave:: db ; 7-0 (0 is highest) \1PitchOffset:: db ; raises existing octaves (to repeat phrases)