aboutsummaryrefslogtreecommitdiff
path: root/src-z80/player/fm.z80
diff options
context:
space:
mode:
Diffstat (limited to 'src-z80/player/fm.z80')
-rw-r--r--src-z80/player/fm.z8045
1 files changed, 45 insertions, 0 deletions
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