From c7cf8a2eb4178f59a5dfe2c3ad6bf1a39eeca523 Mon Sep 17 00:00:00 2001 From: Javier Degirolmo Date: Sun, 15 Jul 2012 21:02:54 -0300 Subject: Added BGM pausing support (stop BGM to pause, resume BGM to unpause) --- src-z80/core/bgm.z80 | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ src-z80/core/main.z80 | 6 ++---- src-z80/core/sfx.z80 | 39 +++------------------------------------ 3 files changed, 55 insertions(+), 40 deletions(-) (limited to 'src-z80/core') 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: @@ -44,6 +46,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 -- cgit v1.2.3