aboutsummaryrefslogtreecommitdiff
path: root/src-z80/core
diff options
context:
space:
mode:
Diffstat (limited to 'src-z80/core')
-rw-r--r--src-z80/core/bgm.z8044
-rw-r--r--src-z80/core/main.z8010
-rw-r--r--src-z80/core/sfx.z8030
-rw-r--r--src-z80/core/vars.z802
4 files changed, 39 insertions, 47 deletions
diff --git a/src-z80/core/bgm.z80 b/src-z80/core/bgm.z80
index eac10d9..c1650f1 100644
--- a/src-z80/core/bgm.z80
+++ b/src-z80/core/bgm.z80
@@ -73,7 +73,6 @@ ProcessBGM:
ld d, (hl)
ex de, hl
-ProcessBGMSkip:
ProcessBGMRun:
PollPCM ; Fetch next event
call GetParam
@@ -164,7 +163,9 @@ ProcessBGMSkip1: ; This is where we land after a locked event
inc c
.nobankskip1:
- PollPCM
+ProcessBGMSkip: ; This is where we land after a locked event
+ PollPCM ; without parameters
+
jp ProcessBGMRun ; Keep processing
;****************************************************************************
@@ -211,46 +212,55 @@ ClearBGM:
;----------------------------------------------------------------------------
- ld b, 4 ; Mute all non-locked PSG channels
- ld de, RAM_PSGData+48
+ ld b, 4 ; Reset all PSG channels
+ ld de, RAM_PSGData+48+15
ld hl, RAM_Locked+11
.mutepsg:
PollPCM
- ld a, (hl)
+ ld (hl), $00 ; Reset BGM volume
+
+ ld a, e
+ sub 15
+ ld e, a
+
+ ld a, (hl) ; Mute PSG channel if it isn't locked
or a
- jp nz, .nopsgmute
+ jr nz, .nopsgmute
xor a
ld (de), a
+
.nopsgmute:
PollPCM
- ld a, e
- sub 16
- ld e, a
-
+ dec e
dec l
djnz .mutepsg
;----------------------------------------------------------------------------
- ld b, 8 ; Mute all non-locked FM channels
-.mutefm:
+ ld b, 8 ; Reset all FM channels
+ ld de, RAM_BGMFMVol+7
+.resetfm:
PollPCM
- ld a, (hl) ; Check if channel is locked
+ xor a ; Reset BGM volume
+ ld (de), a
+ dec e
+
+ ld a, (hl) ; Kill FM channel if not locked
or a
- jp nz, .nofmmute
+ jp nz, .nofmkill
PollPCM
- ld a, b ; Kill FM channel
+ ld a, b
dec a
call KillFM
-.nofmmute: ; Go for next channel
+.nofmkill:
dec l
- djnz .mutefm
+ djnz .resetfm
;----------------------------------------------------------------------------
diff --git a/src-z80/core/main.z80 b/src-z80/core/main.z80
index c5aef0f..9ac1aa4 100644
--- a/src-z80/core/main.z80
+++ b/src-z80/core/main.z80
@@ -87,8 +87,7 @@ EntryPoint:
ld (ix+0), $25
ld (ix+1), $03
ld (ix+0), $26
- ld (ix+1), $C8
- ;ld (ix+1), $FF
+ ld (ix+1), $C9
ld (ix+0), $27
ld (ix+1), $3F
@@ -159,16 +158,9 @@ DoTick:
bit 0, a
call nz, UpdatePCM
-; ld (ix+0), $26 ; Reset timer
-;.timerset:
-; ld (ix+1), $C8
ld (ix+0), $27
ld (ix+1), $2F
-; ld a, (.timerset+3) ; $C8 is too fast, $C9 is too slow
-; xor $01 ; So, we alternate between them to compensate
-; ld (.timerset+3), a
-
PollPCM
DoTick_SFX: ; Process SFXs
diff --git a/src-z80/core/sfx.z80 b/src-z80/core/sfx.z80
index 0a7d1e8..f32a8f0 100644
--- a/src-z80/core/sfx.z80
+++ b/src-z80/core/sfx.z80
@@ -273,14 +273,14 @@ ClearSFX:
rrca
ld iyl, a
- ld a, b ; Kill ADSR
+ ld a, b ; Kill ADSR
call KillFM
PollPCM
- ld hl, RAM_BGMFMInstr ; Restore BGM FM instrument
- ld a, b
- add l
+ ld a, b ; Restore BGM FM instrument
+ ld h, RAM_BGMFMInstr>>8
+ add RAM_BGMFMInstr&$FF
ld l, a
push bc
@@ -292,22 +292,14 @@ ClearSFX:
pop hl
pop de
pop bc
-
- ;PollPCM
- ;ld a, l
- ;add 8
- ;ld l, a
-
- ;ld hl, RAM_BGMFMVol ; Restore BGM FM volume
- ;ld a, b
- ;add l
- ;ld l, a
- ;ld c, (hl)
- ;ld a, l
- ;add 8
- ;ld l, a
- ;ld (hl), c
+ PollPCM
+
+ ld a, b ; Restore BGM FM volume
+ add RAM_BGMFMVol&$FF
+ ld l, a
+ ld b, (hl)
+ call SetFMVolLoad
PollPCM
inc b
diff --git a/src-z80/core/vars.z80 b/src-z80/core/vars.z80
index 64a1dde..ef9a676 100644
--- a/src-z80/core/vars.z80
+++ b/src-z80/core/vars.z80
@@ -15,9 +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_FMData: ds 8*5 ; FM info (for volume handling)
; ds 8*1 ... Register $B0
; ds 8*1 ... Register $40