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/player/fm.z80 | 72 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 25 deletions(-) (limited to 'src-z80/player/fm.z80') 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 -- cgit v1.2.3