aboutsummaryrefslogtreecommitdiff
path: root/src-z80
diff options
context:
space:
mode:
authorJavier Degirolmo2012-07-15 21:02:54 -0300
committerJavier Degirolmo2012-07-15 21:02:54 -0300
commitc7cf8a2eb4178f59a5dfe2c3ad6bf1a39eeca523 (patch)
treeddaf8602e1d089644753d6e0a52421f35b730b10 /src-z80
parent84ce0220dd5449587467c37d7afbd99fb1fbe69e (diff)
Added BGM pausing support (stop BGM to pause, resume BGM to unpause)
Diffstat (limited to 'src-z80')
-rw-r--r--src-z80/core/bgm.z8050
-rw-r--r--src-z80/core/main.z806
-rw-r--r--src-z80/core/sfx.z8039
-rw-r--r--src-z80/player/fm.z8045
4 files changed, 100 insertions, 40 deletions
diff --git a/src-z80/core/bgm.z80 b/src-z80/core/bgm.z80
index e5d9892..2ef3aad 100644
--- a/src-z80/core/bgm.z80
+++ b/src-z80/core/bgm.z80
@@ -1,6 +1,8 @@
;****************************************************************************
; PlayBGM [command $04]
; Plays a BGM
+;----------------------------------------------------------------------------
+; breaks: all
;****************************************************************************
PlayBGM:
@@ -45,6 +47,54 @@ PlayBGM:
jp IdleLoop ; End of subroutine
;****************************************************************************
+; ResumeBGM [command $06]
+; Resumes a stopped BGM
+;----------------------------------------------------------------------------
+; breaks: all
+;****************************************************************************
+
+ResumeBGM:
+ xor a ; Command parsed
+ ld (RAM_Command), a
+
+;----------------------------------------------------------------------------
+
+ ld b, 8 ; Restore all FM channels
+ ld de, RAM_Locked+7
+.restorefm:
+
+ PollPCM
+
+ ld a, (de) ; Check if this channel is locked
+ or a
+ jp nz, .fmlocked
+
+ PollPCM
+
+ dec b ; Restore FM channel
+ call RestoreFM
+ inc b
+
+.fmlocked:
+ dec e ; Go for next channel to restore
+ dec b
+ jp nz, .restorefm
+
+;----------------------------------------------------------------------------
+
+ ld a, (RAM_Status) ; Show BGM playback in Echo's status
+ or $02
+ ld (RAM_Status), a
+
+ ld hl, RAM_BGMData ; Set BGM as playing
+ ld (hl), $01
+
+ ld hl, ProcessBGM ; Tell Echo to process BGM
+ ld (DoTick_BGM+1), hl
+
+ jp IdleLoop ; End of subroutine
+
+;****************************************************************************
; ProcessBGM
; Processes a tick for a BGM
;****************************************************************************
diff --git a/src-z80/core/main.z80 b/src-z80/core/main.z80
index 491860a..3a5a441 100644
--- a/src-z80/core/main.z80
+++ b/src-z80/core/main.z80
@@ -31,10 +31,6 @@ EntryPoint:
ld (hl), l
ld (hl), l
- ;ex af, af' ; Set 9th bank bit to 0 by default
- ;xor a ; (0 = $000000-$7FFFFF range aka MD mode)
- ;ex af, af' ; (1 = $800000-$FFFFFF range aka 32X mode)
-
ld ix, $4000 ; YM2612 I/O ports base address
ld iyh, $40
@@ -120,6 +116,8 @@ RunCommand:
jp z, PlayBGM
dec a ; Command $05: stop BGM
jp z, StopBGMCmd
+ dec a ; Command $06: resume BGM
+ jp z, ResumeBGM
PollPCM
diff --git a/src-z80/core/sfx.z80 b/src-z80/core/sfx.z80
index 0e140e8..fc636e9 100644
--- a/src-z80/core/sfx.z80
+++ b/src-z80/core/sfx.z80
@@ -264,44 +264,11 @@ ClearSFX:
PollPCM
- dec b
-
- ld a, b ; Restore BGM FM instrument
- ld h, RAM_BGMFMInstr>>8
- add RAM_BGMFMInstr&$FF
- ld l, a
-
- push bc
- ld a, b
- ld b, (hl)
- call LoadFMDirect
- pop bc
-
- PollPCM
-
- push bc
- ld a, l ; Restore BGM FM volume
- add 8
- ld l, a
- ld a, b
- ld b, (hl)
- call SetFMVolLoad
- pop bc
-
- ld a, l ; Restore BGM FM panning
- add 8
- ld l, a
- ld a, b
- and $03
- add $B4
- ld (iy+0), a
- ld a, (hl)
- ld (iy+1), a
-
- PollPCM
+ dec b ; Restore FM channel
+ call RestoreFM
inc b
+
.fmfree:
- PollPCM
dec e ; Go for next FM channel to unlock
dec b
jp nz, .unlockfm
diff --git a/src-z80/player/fm.z80 b/src-z80/player/fm.z80
index ddfef66..65a6c55 100644
--- a/src-z80/player/fm.z80
+++ b/src-z80/player/fm.z80
@@ -755,3 +755,48 @@ KillFM:
PollPCM
ret ; End of subroutine
+
+;****************************************************************************
+; RestoreFM
+; Restores a FM channel (from BGM information)
+;----------------------------------------------------------------------------
+; input b ... FM channel (0..7)
+;----------------------------------------------------------------------------
+; breaks: af, hl
+;****************************************************************************
+
+RestoreFM:
+ ld a, b ; Restore BGM FM instrument
+ ld h, RAM_BGMFMInstr>>8
+ add RAM_BGMFMInstr&$FF
+ ld l, a
+
+ push bc
+ ld a, b
+ ld b, (hl)
+ call LoadFMDirect
+ pop bc
+
+ PollPCM
+
+ push bc
+ ld a, l ; Restore BGM FM volume
+ add 8
+ ld l, a
+ ld a, b
+ ld b, (hl)
+ call SetFMVolLoad
+ pop bc
+
+ ld a, l ; Restore BGM FM panning
+ add 8
+ ld l, a
+ ld a, b
+ and $03
+ add $B4
+ ld (iy+0), a
+ ld a, (hl)
+ ld (iy+1), a
+
+ PollPCM
+ ret ; End of subroutine