aboutsummaryrefslogtreecommitdiff
path: root/src-z80
diff options
context:
space:
mode:
authorJavier Degirolmo2011-12-09 08:29:41 -0300
committerJavier Degirolmo2011-12-09 08:29:41 -0300
commitf7ef91fd060eaa724bdb6940fd1b21dd08923837 (patch)
tree6eb32206d72aa7928a1c75bbdb1e0a322b5ce1a7 /src-z80
parent6446fde6c853329dd62621e5e82e868d7f132f00 (diff)
Fixed FM volume restoring bug (I hope?)
Diffstat (limited to 'src-z80')
-rw-r--r--src-z80/core/bgm.z8022
-rw-r--r--src-z80/core/main.z802
-rw-r--r--src-z80/core/sfx.z802
-rw-r--r--src-z80/core/vars.z802
-rw-r--r--src-z80/player/fm.z8021
5 files changed, 23 insertions, 26 deletions
diff --git a/src-z80/core/bgm.z80 b/src-z80/core/bgm.z80
index ebda240..27cb89c 100644
--- a/src-z80/core/bgm.z80
+++ b/src-z80/core/bgm.z80
@@ -42,15 +42,15 @@ 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
+; 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
@@ -83,6 +83,7 @@ ProcessBGM:
ex de, hl
ProcessBGMRun:
+ProcessBGMSkip:
PollPCM ; Fetch next event
call GetParam
PollPCM
@@ -172,9 +173,6 @@ ProcessBGMSkip1: ; This is where we land after a locked event
inc c
.nobankskip1:
-ProcessBGMSkip: ; This is where we land after a locked event
- PollPCM ; without parameters
-
jp ProcessBGMRun ; Keep processing
;****************************************************************************
diff --git a/src-z80/core/main.z80 b/src-z80/core/main.z80
index bc63da9..5d9b7f6 100644
--- a/src-z80/core/main.z80
+++ b/src-z80/core/main.z80
@@ -309,7 +309,7 @@ GetParam:
.noswitchp:
ld b, (hl) ; Get volume
- PollPCM
+ ;PollPCM
inc l ; Get next address
jp nz, .nonewbankp
diff --git a/src-z80/core/sfx.z80 b/src-z80/core/sfx.z80
index 6a553bb..d008f0b 100644
--- a/src-z80/core/sfx.z80
+++ b/src-z80/core/sfx.z80
@@ -291,12 +291,14 @@ ClearSFX:
PollPCM
+ push bc
ld a, b ; Restore BGM FM volume
add RAM_BGMFMVol&$FF
ld l, a
ld a, b
ld b, (hl)
call SetFMVolLoad
+ pop bc
PollPCM
inc b
diff --git a/src-z80/core/vars.z80 b/src-z80/core/vars.z80
index ef9a676..8b6593a 100644
--- a/src-z80/core/vars.z80
+++ b/src-z80/core/vars.z80
@@ -15,7 +15,7 @@ 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_FMVolume: ds 8 ; Volume of each FM channel
RAM_FMData: ds 8*5 ; FM info (for volume handling)
; ds 8*1 ... Register $B0
; ds 8*1 ... Register $40
diff --git a/src-z80/player/fm.z80 b/src-z80/player/fm.z80
index 96c9f4c..b48e79b 100644
--- a/src-z80/player/fm.z80
+++ b/src-z80/player/fm.z80
@@ -222,9 +222,8 @@ LoadFMBGM:
PollPCM
call GetParam
PollPCM
- ex de, hl
- ld (hl), b
- ex de, hl
+ ld a, b
+ ld (de), a
ld a, e ; Reset volume
add 8
@@ -240,9 +239,9 @@ LoadFMBGM:
PollPCM
push hl ; Check if channel is free
- ld hl, RAM_Locked
ld a, b
- add l
+ ld h, RAM_Locked>>8
+ add RAM_Locked&$FF
ld l, a
ld a, (hl)
pop hl
@@ -251,8 +250,7 @@ LoadFMBGM:
PollPCM
- ld a, b
- and $07
+ ld a, b ; Get back instrument ID
push hl
ld hl, RAM_BGMFMInstr
add l
@@ -260,9 +258,9 @@ LoadFMBGM:
ld b, (hl)
pop hl
- push af
+ ex af, af'
PollPCM
- pop af
+ ex af, af'
call LoadFMDirect ; We're just a wrapper
jp ProcessBGMRun ; End of subroutine
@@ -350,8 +348,7 @@ LoadFMDirect:
add $B0
ld hl, RAM_Scratch ; Get address of buffer with the instrument
- ; data
-
+ ; data
ex af, af'
PollPCM ; Write operator
ex af, af'
@@ -741,7 +738,7 @@ LockChannelFM:
rrca
ld iyl, a
- ld a, b ; Reset stereo
+ ld a, b ; Reset FM parameters
and $03
add a
add a