aboutsummaryrefslogtreecommitdiff
path: root/src-z80/core/sfx.z80
diff options
context:
space:
mode:
Diffstat (limited to 'src-z80/core/sfx.z80')
-rw-r--r--src-z80/core/sfx.z8048
1 files changed, 39 insertions, 9 deletions
diff --git a/src-z80/core/sfx.z80 b/src-z80/core/sfx.z80
index 4bca4c7..8c5e7dd 100644
--- a/src-z80/core/sfx.z80
+++ b/src-z80/core/sfx.z80
@@ -25,9 +25,6 @@ PlaySFX:
PollPCM
- xor a ; Command parsed
- ld (RAM_Command), a
-
ld hl, RAM_SFXData ; Set SFX as playing
ld (hl), $01
inc l ; No delays!
@@ -45,7 +42,7 @@ PlaySFX:
ld (DoTick_SFX+1), hl
PollPCM
- jp IdleLoop ; End of subroutine
+ jp EndOfCommand ; End of subroutine
;****************************************************************************
; ProcessSFX
@@ -153,6 +150,14 @@ ProcessSFXRun:
jp c, SetFMParamSFX
cp $FA ; Events $F8-$F9: set FM register
jp c, SetFMRegSFX
+ jp z, SetFlagsSFX ; Events $FA-$FB: set/clear flags
+ cp $FB
+ jp z, ClearFlagsSFX
+
+ cp $FC
+ jp z, LoopSFX ; Event $FC: loop SFX
+ cp $FD
+ jp z, SetLoopSFX ; Event $FD: set loop point
;****************************************************************************
; StopSFX* [command $03, event $FF]
@@ -166,10 +171,8 @@ StopSFXEvent:
jp DoTick_SFXSkip ; End of subroutine
StopSFXCmd:
- xor a ; Command parsed
- ld (RAM_Command), a
call StopSFX ; We're just a wrapper
- jp IdleLoop ; End of subroutine
+ jp EndOfCommand ; End of subroutine
StopSFX:
PollPCM
@@ -283,9 +286,36 @@ ClearSFX:
.fmfree:
dec e ; Go for next FM channel to unlock
- dec b
- jp nz, .unlockfm
+ djnz .unlockfm
;----------------------------------------------------------------------------
ret ; End of subroutine
+
+;****************************************************************************
+; LoopSFX [event $FC]
+; Makes a SFX loop
+;****************************************************************************
+
+LoopSFX:
+ PollPCM
+
+ ld hl, (RAM_SFXLoopPoint+1) ; Get looping address
+ ld a, (RAM_SFXLoopPoint)
+ ld c, a
+
+ jp ProcessSFXRun ; End of subroutine
+
+;****************************************************************************
+; SetLoopSFX [event $FD]
+; Sets the SFX loop point
+;****************************************************************************
+
+SetLoopSFX:
+ PollPCM
+
+ ld a, c ; Store loop point address
+ ld (RAM_SFXLoopPoint), a
+ ld (RAM_SFXLoopPoint+1), hl
+
+ jp ProcessSFXRun ; End of subroutine