aboutsummaryrefslogtreecommitdiff
path: root/src-z80
diff options
context:
space:
mode:
Diffstat (limited to 'src-z80')
-rw-r--r--src-z80/core/main.z804
-rw-r--r--src-z80/player/pcm.z8027
2 files changed, 31 insertions, 0 deletions
diff --git a/src-z80/core/main.z80 b/src-z80/core/main.z80
index 1bd6074..33d8ec4 100644
--- a/src-z80/core/main.z80
+++ b/src-z80/core/main.z80
@@ -101,6 +101,8 @@ PollPCM: macro
;****************************************************************************
; RunCommand
; Checks which command to run
+;----------------------------------------------------------------------------
+; To-do: replace with pointer list?
;****************************************************************************
RunCommand:
@@ -116,6 +118,8 @@ RunCommand:
jp z, StopBGMCmd
dec a ; Command $06: resume BGM
jp z, ResumeBGM
+ dec a ; Command $07: set PCM rate
+ jp z, SetPCMRate
PollPCM
diff --git a/src-z80/player/pcm.z80 b/src-z80/player/pcm.z80
index 18527d9..b5a4434 100644
--- a/src-z80/player/pcm.z80
+++ b/src-z80/player/pcm.z80
@@ -239,3 +239,30 @@ LockChannelPCM:
call StopPCM ; Stop PCM playback
jp ProcessSFXRun ; End of subroutine
+
+;****************************************************************************
+; SetPCMRate [command $07]
+; Changes the sample rate of PCM
+;****************************************************************************
+
+SetPCMRate:
+ ld a, (RAM_ComBank) ; Get new rate
+ cpl
+ ld b, a
+
+ xor a ; Parsed command already
+ ld (RAM_Command), a
+
+ ld a, b ; Set high bits of timer
+ ld (ix+0), $24
+ rrca
+ rrca
+ or $C0
+ ld (ix+1), a
+
+ ld a, b ; Set low bits of timer
+ ld (ix+0), $25
+ and $03
+ ld (ix+1), a
+
+ jp IdleLoop ; End of subroutine