From da98253489b1334f9d23f477ec8fa2a76e664aa6 Mon Sep 17 00:00:00 2001 From: Javier Degirolmo Date: Sat, 7 Apr 2012 20:28:18 -0300 Subject: Bugfixes (especially killing FM channels), panning is restored, version bumped up to 0.9 - going to look mainly for bugs now... --- src-z80/core/bgm.z80 | 10 ------- src-z80/core/sfx.z80 | 18 +++++++++++++ src-z80/core/vars.z80 | 7 ++--- src-z80/player/fm.z80 | 72 ++++++++++++++++++++++++++++++++----------------- src-z80/player/freq.z80 | 8 +++--- src-z80/player/psg.z80 | 6 ++--- 6 files changed, 75 insertions(+), 46 deletions(-) (limited to 'src-z80') diff --git a/src-z80/core/bgm.z80 b/src-z80/core/bgm.z80 index 27cb89c..ea245a1 100644 --- a/src-z80/core/bgm.z80 +++ b/src-z80/core/bgm.z80 @@ -42,16 +42,6 @@ PlayBGM: ld hl, ProcessBGM ; Tell Echo to process BGM ld (DoTick_BGM+1), hl -; ld b, 8 ; Kill all FM channels explicitly -;.resetallfm: -; ld a, b -; and $04 -; rrca -; ld iyl, a -; ld a, b -; call KillFM -; djnz .resetallfm - jp IdleLoop ; End of subroutine ;**************************************************************************** diff --git a/src-z80/core/sfx.z80 b/src-z80/core/sfx.z80 index d008f0b..6eb844d 100644 --- a/src-z80/core/sfx.z80 +++ b/src-z80/core/sfx.z80 @@ -299,6 +299,24 @@ ClearSFX: ld b, (hl) call SetFMVolLoad pop bc + + ld a, b + and $04 + rrca + ld iyl, a + + push bc ; Restore BGM FM panning + ld a, b + ld h, RAM_BGMFMPan>>8 + add RAM_BGMFMPan&$FF + ld l, a + ld a, b + ld b, (hl) + and $03 + add $B4 + ld (iy+0), b + ld (iy+1), a + pop bc PollPCM inc b diff --git a/src-z80/core/vars.z80 b/src-z80/core/vars.z80 index 8b6593a..c1dc8b5 100644 --- a/src-z80/core/vars.z80 +++ b/src-z80/core/vars.z80 @@ -15,7 +15,8 @@ RAM_PSGData: ds 4*16 ; PSG envelope data RAM_BGMFMInstr: ds 8 ; FM instruments used by BGM RAM_BGMFMVol: ds 8 ; FM volumes used by BGM -;RAM_FMVolume: ds 8 ; Volume of each FM channel +RAM_BGMFMPan: ds 8 ; FM panning used by BGM + RAM_FMData: ds 8*5 ; FM info (for volume handling) ; ds 8*1 ... Register $B0 ; ds 8*1 ... Register $40 @@ -23,6 +24,8 @@ RAM_FMData: ds 8*5 ; FM info (for volume handling) ; ds 8*1 ... Register $48 ; ds 8*1 ... Register $4C +RAM_Locked: ds 12 ; Locked channels + RAM_LastBank: ds 1 ; Last accessed bank RAM_BGMData: ; Where BGM data starts @@ -38,8 +41,6 @@ RAM_SFXDelay: ds 1 ; How many ticks to wait RAM_SFXBank: ds 1 ; Current SFX bank RAM_SFXAddress: ds 2 ; Current SFX address -RAM_Locked: ds 12 ; Locked channels - RAM_Scratch: ds 32 ; Scratch bytes, may be useful when ; buffering to speed up to avoid bank ; switching conflicts diff --git a/src-z80/player/fm.z80 b/src-z80/player/fm.z80 index b48e79b..4c0b565 100644 --- a/src-z80/player/fm.z80 +++ b/src-z80/player/fm.z80 @@ -668,50 +668,73 @@ SetFMVolLoad: ;**************************************************************************** SetFMParamSFX: - call SetFMParam ; We're just a wrapper - jp ProcessSFXRun ; End of subroutine - -SetFMParamBGM: ld b, a PollPCM - ld a, b - push hl - and $07 ; Check if channel is free - ld hl, RAM_Locked - add l - ld l, a - ld a, (hl) - pop hl - or a - jp nz, ProcessBGMSkip1 ; Don't modify if locked + ld a, b ; Determine which port to write + and $04 + rrca + ld iyl, a ld a, b - call SetFMParam ; We're just a wrapper - jp ProcessBGMRun ; End of subroutine + ex af, af' + PollPCM + call GetParam ; Get parameters + PollPCM + ex af, af' -SetFMParam: + and $03 ; Get channel ID + add $B4 + ld (iy+0), a ; Set new parameters + ld (iy+1), b + + jp ProcessSFXRun ; End of subroutine + +SetFMParamBGM: ld b, a PollPCM - + ld a, b + ld a, b ; Determine which port to write and $04 rrca ld iyl, a - ld a, b ex af, af' PollPCM call GetParam ; Get parameters PollPCM ex af, af' + + push hl + and $07 ; Store parameters + ld h, RAM_BGMFMPan>>8 + add RAM_BGMFMPan&$FF + ld l, h + ld (hl), b + + ex af, af' + PollPCM + ex af, af' + + and $07 ; Check if channel is free + add RAM_Locked&$FF + ld l, a + ex af, af' + ld a, (hl) + or a + pop hl + jp nz, ProcessBGMRun ; Don't modify if locked + + PollPCM + ex af, af' and $03 ; Get channel ID add $B4 ld (iy+0), a ; Set new parameters ld (iy+1), b - - ret ; End of subroutine + + jp ProcessBGMRun ; End of subroutine ;**************************************************************************** ; LockChannelFM [events $E0-$E7] @@ -766,9 +789,6 @@ KillFM: ld iyl, a ld a, c - ld (ix+0), $28 ; Stop current note (if any) - ld (ix+1), a - and $03 ; Load dummy FM instrument add $40 ld c, 6 @@ -804,9 +824,11 @@ KillFM: PollPCM pop af - ld c, a ; Reset ADSR + ld c, a ; Cause the ADSR to reset or $F0 ld (ix+0), $28 + ld (ix+1), c + ld (ix+0), $28 ld (ix+1), a ld (ix+0), $28 ld (ix+1), c diff --git a/src-z80/player/freq.z80 b/src-z80/player/freq.z80 index d12ee2b..97dafbe 100644 --- a/src-z80/player/freq.z80 +++ b/src-z80/player/freq.z80 @@ -97,9 +97,9 @@ FMFreqTable: ;**************************************************************************** DummyFMInstr: - db $FF ; $40..$4C - db $FF ; $50..$5C - db $FF ; $60..$6C - db $FF ; $70..$7C + db $7F ; $40..$4C + db $00 ; $50..$5C + db $1F ; $60..$6C + db $1F ; $70..$7C db $FF ; $80..$8C db $00 ; $90..$9C diff --git a/src-z80/player/psg.z80 b/src-z80/player/psg.z80 index 46df82a..f0c5a76 100644 --- a/src-z80/player/psg.z80 +++ b/src-z80/player/psg.z80 @@ -573,8 +573,6 @@ SetNotePSGBGM: push hl and $0F ; Check if channel is free - ;ld hl, RAM_Locked - ;add l ld h, RAM_Locked>>8 add RAM_Locked&$FF ld l, a @@ -640,14 +638,14 @@ SetNoteNoiseBGM: ;**************************************************************************** LockChannelPSG: + and $03 ld b, a PollPCM push hl ld h, RAM_Locked>>8 ; Get address of channel to lock ld a, b - and $0F - add RAM_Locked&$FF + add (RAM_Locked&$FF)+8 ld l, a ld (hl), $01 ; Lock channel -- cgit v1.2.3