aboutsummaryrefslogtreecommitdiff
path: root/src-z80/core
diff options
context:
space:
mode:
Diffstat (limited to 'src-z80/core')
-rw-r--r--src-z80/core/bgm.z8027
-rw-r--r--src-z80/core/sfx.z8034
2 files changed, 30 insertions, 31 deletions
diff --git a/src-z80/core/bgm.z80 b/src-z80/core/bgm.z80
index ea245a1..e5d9892 100644
--- a/src-z80/core/bgm.z80
+++ b/src-z80/core/bgm.z80
@@ -241,26 +241,45 @@ ClearBGM:
.resetfm:
PollPCM
- ;xor a ; Reset BGM volume
- ld a, $7F
+ ld a, $7F ; Reset BGM volume
ld (de), a
dec e
+ PollPCM
+
ld a, (hl) ; Kill FM channel if not locked
or a
jp nz, .nofmkill
+ dec b
+
+ ld a, b
+ call KillFM
PollPCM
+ ld a, b ; Reset panning
+ and $04
+ ld iyl, a
ld a, b
- dec a
- call KillFM
+ and $03
+ add $B4
+ ld (iy+0), a
+ ld (iy+1), $C0
+ inc b
.nofmkill:
dec l
djnz .resetfm
;----------------------------------------------------------------------------
+
+ ld hl, RAM_BGMFMPan ; Reset panning status (for restoring)
+ ld a, $C0
+ ld b, 8
+.initpanstat:
+ ld (hl), a
+ inc l
+ djnz .initpanstat
ret ; End of subroutine
diff --git a/src-z80/core/sfx.z80 b/src-z80/core/sfx.z80
index 6eb844d..0e140e8 100644
--- a/src-z80/core/sfx.z80
+++ b/src-z80/core/sfx.z80
@@ -262,21 +262,9 @@ ClearSFX:
xor a
ld (de), a
- dec b ; Mute FM channel
- ld (ix+0), $28
- ld (ix+1), b
-
PollPCM
- ld a, b
- and $04 ; Determine which port to write
- rrca
- ld iyl, a
-
- ld a, b ; Kill ADSR
- call KillFM
-
- PollPCM
+ dec b
ld a, b ; Restore BGM FM instrument
ld h, RAM_BGMFMInstr>>8
@@ -292,31 +280,23 @@ ClearSFX:
PollPCM
push bc
- ld a, b ; Restore BGM FM volume
- add RAM_BGMFMVol&$FF
+ ld a, l ; Restore BGM FM volume
+ add 8
ld l, a
ld a, b
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 a, l ; Restore BGM FM panning
+ add 8
ld l, a
ld a, b
- ld b, (hl)
and $03
add $B4
- ld (iy+0), b
+ ld (iy+0), a
+ ld a, (hl)
ld (iy+1), a
- pop bc
PollPCM
inc b