aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/fm/ebass.eifbin0 -> 29 bytes
-rw-r--r--data/fm/eguitar.eifbin0 -> 29 bytes
-rw-r--r--data/fm/flute.eifbin0 -> 29 bytes
-rw-r--r--data/fm/piano.eifbin0 -> 29 bytes
-rw-r--r--data/fm/saw.eifbin0 -> 29 bytes
-rw-r--r--data/fm/sawf.eifbin0 -> 29 bytes
-rw-r--r--data/fm/square.eifbin0 -> 29 bytes
-rw-r--r--data/fm/squaref.eifbin0 -> 29 bytes
-rw-r--r--data/music/doomsday.esfbin0 -> 59574 bytes
-rw-r--r--data/music/megajysays.esfbin0 -> 19108 bytes
-rw-r--r--data/music/midnas.esfbin0 -> 2213 bytes
-rw-r--r--data/music/nelpel.esfbin0 -> 18774 bytes
-rw-r--r--data/music/test-drums.esf1
-rw-r--r--data/music/test-flute.esfbin0 -> 49 bytes
-rw-r--r--data/music/test-piano.esfbin0 -> 328 bytes
-rw-r--r--data/music/test-psg.esfbin0 -> 137 bytes
-rw-r--r--data/music/test-squsaw-1ch.esfbin0 -> 89 bytes
-rw-r--r--data/music/test-squsaw-2ch.esfbin0 -> 67 bytes
-rw-r--r--src-68k/core/entry.68k2
-rw-r--r--src-68k/core/songlist.68k61
-rw-r--r--src-68k/sound/bgms.68k31
-rw-r--r--src-68k/sound/list.68k145
-rw-r--r--src-z80/core/bgm.z8010
-rw-r--r--src-z80/core/sfx.z8018
-rw-r--r--src-z80/core/vars.z807
-rw-r--r--src-z80/player/fm.z8072
-rw-r--r--src-z80/player/freq.z808
-rw-r--r--src-z80/player/psg.z806
28 files changed, 298 insertions, 63 deletions
diff --git a/data/fm/ebass.eif b/data/fm/ebass.eif
new file mode 100644
index 0000000..ee9dc65
--- /dev/null
+++ b/data/fm/ebass.eif
Binary files differ
diff --git a/data/fm/eguitar.eif b/data/fm/eguitar.eif
new file mode 100644
index 0000000..1cbca92
--- /dev/null
+++ b/data/fm/eguitar.eif
Binary files differ
diff --git a/data/fm/flute.eif b/data/fm/flute.eif
new file mode 100644
index 0000000..18efa31
--- /dev/null
+++ b/data/fm/flute.eif
Binary files differ
diff --git a/data/fm/piano.eif b/data/fm/piano.eif
new file mode 100644
index 0000000..902a29b
--- /dev/null
+++ b/data/fm/piano.eif
Binary files differ
diff --git a/data/fm/saw.eif b/data/fm/saw.eif
new file mode 100644
index 0000000..76e3b50
--- /dev/null
+++ b/data/fm/saw.eif
Binary files differ
diff --git a/data/fm/sawf.eif b/data/fm/sawf.eif
new file mode 100644
index 0000000..f8b876f
--- /dev/null
+++ b/data/fm/sawf.eif
Binary files differ
diff --git a/data/fm/square.eif b/data/fm/square.eif
new file mode 100644
index 0000000..cbeef53
--- /dev/null
+++ b/data/fm/square.eif
Binary files differ
diff --git a/data/fm/squaref.eif b/data/fm/squaref.eif
new file mode 100644
index 0000000..9e9d5f6
--- /dev/null
+++ b/data/fm/squaref.eif
Binary files differ
diff --git a/data/music/doomsday.esf b/data/music/doomsday.esf
new file mode 100644
index 0000000..c657566
--- /dev/null
+++ b/data/music/doomsday.esf
Binary files differ
diff --git a/data/music/megajysays.esf b/data/music/megajysays.esf
new file mode 100644
index 0000000..8566f77
--- /dev/null
+++ b/data/music/megajysays.esf
Binary files differ
diff --git a/data/music/midnas.esf b/data/music/midnas.esf
new file mode 100644
index 0000000..9f7d3eb
--- /dev/null
+++ b/data/music/midnas.esf
Binary files differ
diff --git a/data/music/nelpel.esf b/data/music/nelpel.esf
new file mode 100644
index 0000000..05a4fad
--- /dev/null
+++ b/data/music/nelpel.esf
Binary files differ
diff --git a/data/music/test-drums.esf b/data/music/test-drums.esf
new file mode 100644
index 0000000..3f7939a
--- /dev/null
+++ b/data/music/test-drums.esf
@@ -0,0 +1 @@
+��� � � � � � � � � � � � � � � � � � � � � � � � � � � � �� \ No newline at end of file
diff --git a/data/music/test-flute.esf b/data/music/test-flute.esf
new file mode 100644
index 0000000..7a378e6
--- /dev/null
+++ b/data/music/test-flute.esf
Binary files differ
diff --git a/data/music/test-piano.esf b/data/music/test-piano.esf
new file mode 100644
index 0000000..c957da1
--- /dev/null
+++ b/data/music/test-piano.esf
Binary files differ
diff --git a/data/music/test-psg.esf b/data/music/test-psg.esf
new file mode 100644
index 0000000..87390b0
--- /dev/null
+++ b/data/music/test-psg.esf
Binary files differ
diff --git a/data/music/test-squsaw-1ch.esf b/data/music/test-squsaw-1ch.esf
new file mode 100644
index 0000000..39bce9b
--- /dev/null
+++ b/data/music/test-squsaw-1ch.esf
Binary files differ
diff --git a/data/music/test-squsaw-2ch.esf b/data/music/test-squsaw-2ch.esf
new file mode 100644
index 0000000..b0ffb05
--- /dev/null
+++ b/data/music/test-squsaw-2ch.esf
Binary files differ
diff --git a/src-68k/core/entry.68k b/src-68k/core/entry.68k
index b8a6f27..5da6abc 100644
--- a/src-68k/core/entry.68k
+++ b/src-68k/core/entry.68k
@@ -164,7 +164,7 @@ EntryPoint:
; 123456789012345678901234567890123456
@Str_Title1: dc.b "Echo sound engine", 0
-@Str_Title2: dc.b "Version 0.8 by Sik", 0
+@Str_Title2: dc.b "Version 0.9 by Sik", 0
@Str_Instr1: dc.b "Use D-pad to select song", 0
@Str_Instr2: dc.b "A/C: play, B: stop", 0
even
diff --git a/src-68k/core/songlist.68k b/src-68k/core/songlist.68k
index 69562af..527ea6d 100644
--- a/src-68k/core/songlist.68k
+++ b/src-68k/core/songlist.68k
@@ -4,19 +4,64 @@
;****************************************************************************
SongList:
- dc.l BGM_Minion, @Str_Minion_1, @Str_Minion_2, @Str_Minion_3
- dc.l BGM_HoL, @Str_HoL_1, @Str_Null, @Str_Null
+ dc.l BGM_Midnas, @Str_Midnas_1, @Str_Midnas_2, @Str_Midnas_3
+ dc.l BGM_Nelpel, @Str_Nelpel_1, @Str_Nelpel_2, @Str_Nelpel_3
+ dc.l BGM_Megajysays, @Str_Megajysays_1, @Str_Megajysays_2, @Str_Megajysays_3
+ dc.l BGM_Doomsday, @Str_Doomsday_1, @Str_Doomsday_2, @Str_Doomsday_3
+ dc.l BGM_PianoTest, @Str_PianoTest_1, @Str_PianoTest_2, @Str_Null
+ dc.l BGM_SquSawTest2, @Str_SquSawTest_1a, @Str_SquSawTest_2, @Str_SquSawTest_3a
+ dc.l BGM_SquSawTest1, @Str_SquSawTest_1b, @Str_SquSawTest_2, @Str_SquSawTest_3b
+ dc.l BGM_PSGTest, @Str_PSGTest_1, @Str_PSGTest_2, @Str_Null
+ dc.l BGM_DrumTest, @Str_DrumTest_1, @Str_DrumTest_2, @Str_Null
+ dc.l BGM_FluteTest, @Str_FluteTest_1, @Str_FluteTest_2, @Str_FluteTest_3
; 012345678901234567890123456
-
@Str_Null: dc.b 0
@Str_Untitled: dc.b "[untitled]", 0
-@Str_Minion_1: dc.b "Evil's Minion", 0
-@Str_Minion_2: dc.b "My distortion guitar is", 0
-@Str_Minion_3: dc.b "better than Tiido's B)", 0
+ ; 012345678901234567890123456
+@Str_Midnas_1: dc.b "Midna's Desperate Hour", 0
+@Str_Midnas_2: dc.b "Composed by Koji Kondo", 0
+@Str_Midnas_3: dc.b "Transcribed by Aivi Tran", 0
-@Str_HoL_1: dc.b "Hall of Loneliness", 0
+ ; 012345678901234567890123456
+@Str_Nelpel_1: dc.b "Nelpel Four (crappy ver.)", 0
+@Str_Nelpel_2: dc.b "XM > MIDI > ESF conversion", 0
+@Str_Nelpel_3: dc.b "and really bad instruments", 0
+
+ ; 012345678901234567890123456
+@Str_Megajysays_1: dc.b "Megajysays", 0
+@Str_Megajysays_2: dc.b "That second A should have", 0
+@Str_Megajysays_3: dc.b "two dots on top of it.", 0
+
+ ; 012345678901234567890123456
+@Str_Doomsday_1: dc.b "The Doomsday Project", 0
+@Str_Doomsday_2: dc.b "Another module conversion.", 0
+@Str_Doomsday_3: dc.b "Like I give a crap :P", 0
+
+ ; 012345678901234567890123456
+@Str_PianoTest_1: dc.b "test-piano.mid", 0
+@Str_PianoTest_2: dc.b "Some generic piano...", 0
+
+ ; 012345678901234567890123456
+@Str_SquSawTest_1a: dc.b "test-squsaw-2ch.mid", 0
+@Str_SquSawTest_1b: dc.b "test-squsaw-1ch.mid", 0
+@Str_SquSawTest_2: dc.b "FM square and sawtooth", 0
+@Str_SquSawTest_3a: dc.b "2 channels version", 0
+@Str_SquSawTest_3b: dc.b "1 channel version", 0
+
+ ; 012345678901234567890123456
+@Str_PSGTest_1: dc.b "test-psg.mid", 0
+@Str_PSGTest_2: dc.b "Two square PSG channels.", 0
+
+ ; 012345678901234567890123456
+@Str_DrumTest_1: dc.b "test-drums.mid", 0
+@Str_DrumTest_2: dc.b "Snare and kicks!", 0
+
+ ; 012345678901234567890123456
+@Str_FluteTest_1: dc.b "test-flute.mid", 0
+@Str_FluteTest_2: dc.b "Flute and a seashore.", 0
+@Str_FluteTest_3: dc.b "Feels so calm...", 0
even
@@ -25,4 +70,4 @@ SongList:
; Number of songs in song list
;****************************************************************************
-NumSongs equ 2
+NumSongs equ 10
diff --git a/src-68k/sound/bgms.68k b/src-68k/sound/bgms.68k
index 7264048..4069628 100644
--- a/src-68k/sound/bgms.68k
+++ b/src-68k/sound/bgms.68k
@@ -7,17 +7,32 @@ BGM_Test:
dc.b $FF
;****************************************************************************
-; BGM_Minion
-; "Evil's Minion"
+; Some conversions
;****************************************************************************
-BGM_Minion:
- incbin "data/music/minion.esf"
+BGM_Midnas:
+ incbin "data/music/midnas.esf"
+BGM_Nelpel:
+ incbin "data/music/nelpel.esf"
+BGM_Megajysays:
+ incbin "data/music/megajysays.esf"
+BGM_Doomsday:
+ incbin "data/music/doomsday.esf"
;****************************************************************************
-; BGM_HoL
-; "Hall of Loneliness"
+; Several tests used for midi2esf
;****************************************************************************
-BGM_HoL:
- incbin "data/music/hol.esf"
+BGM_PianoTest:
+ incbin "data/music/test-piano.esf"
+BGM_SquSawTest2:
+ incbin "data/music/test-squsaw-2ch.esf"
+BGM_SquSawTest1:
+ incbin "data/music/test-squsaw-1ch.esf"
+BGM_PSGTest:
+ incbin "data/music/test-psg.esf"
+BGM_DrumTest:
+ incbin "data/music/test-drums.esf"
+BGM_FluteTest:
+ incbin "data/music/test-flute.esf"
+
diff --git a/src-68k/sound/list.68k b/src-68k/sound/list.68k
index f871b0a..10f7a42 100644
--- a/src-68k/sound/list.68k
+++ b/src-68k/sound/list.68k
@@ -12,6 +12,19 @@ PointerList:
Echo_ListEntry Instr_Bass ; $05 [FM] Standard bass
Echo_ListEntry Instr_SoftPSG ; $06 [PSG] Soft PSG envelope
Echo_ListEntry Instr_PianoPSG ; $07 [PSG] Piano PSG instrument
+ Echo_ListEntry Instr_MidiPSG ; $08 [PSG] MIDI square lead
+ Echo_ListEntry Instr_MidiPiano ; $09 [FM] MIDI piano
+ Echo_ListEntry Instr_MidiLead1 ; $0A [FM] MIDI square lead
+ Echo_ListEntry Instr_MidiLead2 ; $0B [FM] MIDI sawtooth lead
+ Echo_ListEntry Instr_MidiFlute ; $0C [FM] MIDI flute
+ Echo_ListEntry Instr_NepelPSG ; $0D [PSG] Nepel Four PSG instr.
+ Echo_ListEntry Instr_MidiSynthBass ; $0E [FM] MIDI synth bass
+ Echo_ListEntry Instr_MidiLead1F ; $0F [FM] MIDI square (filtered)
+ Echo_ListEntry Instr_MidiLead2F ; $10 [FM] MIDI sawtooth (filtered)
+ Echo_ListEntry Instr_Seashore ; $11 [PSG] Seashore
+ Echo_ListEntry Instr_HitHat ; $12 [PSG] Hit-hat
+ Echo_ListEntry Instr_PSGString ; $13 [PSG] PSG string
+ Echo_ListEntry Instr_EGuitar ; $14 [FM] Electric guitar
Echo_ListEnd
;****************************************************************************
@@ -83,3 +96,135 @@ Instr_PianoPSG:
dc.b $0C,$0C,$0C,$0C,$0D,$0D,$0D,$0D
dc.b $0D,$0D,$0D,$0D,$0E,$0E,$0E,$0E
dc.b $0E,$0E,$0E,$0E,$FE,$0F,$FF
+
+;****************************************************************************
+; Instrument $08 [PSG]
+; MIDI square wave instrument (GM81)
+;****************************************************************************
+
+Instr_MidiPSG:
+ dc.b $00,$01,$02,$FE,$03,$FF
+
+;****************************************************************************
+; Instrument $09 [FM]
+; MIDI acoustic piano (GM01)
+;****************************************************************************
+
+Instr_MidiPiano:
+ incbin "data/fm/piano.eif"
+
+;****************************************************************************
+; Instrument $0A [FM]
+; MIDI square wave instrument (GM81)
+;****************************************************************************
+
+Instr_MidiLead1:
+ incbin "data/fm/square.eif"
+
+;****************************************************************************
+; Instrument $0B [FM]
+; MIDI sawtooth wave instrument (GM82)
+;****************************************************************************
+
+Instr_MidiLead2:
+ incbin "data/fm/saw.eif"
+
+;****************************************************************************
+; Instrument $0C [FM]
+; MIDI flute instrument (GM74)
+;****************************************************************************
+
+Instr_MidiFlute:
+ incbin "data/fm/flute.eif"
+
+;****************************************************************************
+; Instrument $0D [PSG]
+; Nepel Four PSG instrument
+;****************************************************************************
+
+Instr_NepelPSG:
+ dc.b $05,$06,$FE,$07,$FF
+
+;****************************************************************************
+; Instrument $0E [FM]
+; MIDI synth bass (GM39)
+;****************************************************************************
+
+Instr_MidiSynthBass:
+ incbin "data/fm/ebass.eif"
+
+;****************************************************************************
+; Instrument $0F [FM]
+; MIDI square wave instrument (GM81) (filtered)
+;****************************************************************************
+
+Instr_MidiLead1F:
+ incbin "data/fm/squaref.eif"
+
+;****************************************************************************
+; Instrument $10 [FM]
+; MIDI sawtooth wave instrument (GM82) (filtered)
+;****************************************************************************
+
+Instr_MidiLead2F:
+ incbin "data/fm/sawf.eif"
+
+;****************************************************************************
+; Instrument $11 [PSG]
+; Seashore
+;****************************************************************************
+
+Instr_Seashore:
+ dcb.b 4, $0E
+ dcb.b 4, $0D
+ dcb.b 4, $0C
+ dcb.b 4, $0B
+ dcb.b 4, $0A
+ dcb.b 4, $09
+ dcb.b 4, $08
+ dcb.b 4, $07
+ dcb.b 4, $06
+ dcb.b 60, $05
+ dcb.b 4, $06
+ dcb.b 4, $07
+ dcb.b 4, $08
+ dcb.b 4, $09
+ dcb.b 4, $0A
+ dcb.b 4, $0B
+ dcb.b 4, $0C
+ dcb.b 4, $0D
+ dcb.b 4, $0E
+ dc.b $FE, $0F, $FF
+
+;****************************************************************************
+; Instrument $12 [PSG]
+; Hit-hat
+;****************************************************************************
+
+Instr_HitHat:
+ dc.b $00, $01, $02, $04, $06, $08, $0C
+ dc.b $FE, $0F, $FF
+
+;****************************************************************************
+; Instrument $13 [PSG]
+; PSG string
+;****************************************************************************
+
+Instr_PSGString:
+ dcb.b 4, $0E
+ dcb.b 4, $0D
+ dcb.b 4, $0C
+ dcb.b 4, $0B
+ dcb.b 4, $0A
+ dcb.b 4, $09
+ dcb.b 4, $08
+ dc.b $FE, $07, $FF
+
+;****************************************************************************
+; Instrument $14 [FM]
+; Electric guitar
+;****************************************************************************
+
+Instr_EGuitar:
+ incbin "data/fm/eguitar.eif"
+
diff --git a/src-z80/core/bgm.z80 b/src-z80/core/bgm.z80
index 27cb89c..ea245a1 100644
--- a/src-z80/core/bgm.z80
+++ b/src-z80/core/bgm.z80
@@ -42,16 +42,6 @@ PlayBGM:
ld hl, ProcessBGM ; Tell Echo to process BGM
ld (DoTick_BGM+1), hl
-; ld b, 8 ; Kill all FM channels explicitly
-;.resetallfm:
-; ld a, b
-; and $04
-; rrca
-; ld iyl, a
-; ld a, b
-; call KillFM
-; djnz .resetallfm
-
jp IdleLoop ; End of subroutine
;****************************************************************************
diff --git a/src-z80/core/sfx.z80 b/src-z80/core/sfx.z80
index d008f0b..6eb844d 100644
--- a/src-z80/core/sfx.z80
+++ b/src-z80/core/sfx.z80
@@ -299,6 +299,24 @@ ClearSFX:
ld b, (hl)
call SetFMVolLoad
pop bc
+
+ ld a, b
+ and $04
+ rrca
+ ld iyl, a
+
+ push bc ; Restore BGM FM panning
+ ld a, b
+ ld h, RAM_BGMFMPan>>8
+ add RAM_BGMFMPan&$FF
+ ld l, a
+ ld a, b
+ ld b, (hl)
+ and $03
+ add $B4
+ ld (iy+0), b
+ ld (iy+1), a
+ pop bc
PollPCM
inc b
diff --git a/src-z80/core/vars.z80 b/src-z80/core/vars.z80
index 8b6593a..c1dc8b5 100644
--- a/src-z80/core/vars.z80
+++ b/src-z80/core/vars.z80
@@ -15,7 +15,8 @@ RAM_PSGData: ds 4*16 ; PSG envelope data
RAM_BGMFMInstr: ds 8 ; FM instruments used by BGM
RAM_BGMFMVol: ds 8 ; FM volumes used by BGM
-;RAM_FMVolume: ds 8 ; Volume of each FM channel
+RAM_BGMFMPan: ds 8 ; FM panning used by BGM
+
RAM_FMData: ds 8*5 ; FM info (for volume handling)
; ds 8*1 ... Register $B0
; ds 8*1 ... Register $40
@@ -23,6 +24,8 @@ RAM_FMData: ds 8*5 ; FM info (for volume handling)
; ds 8*1 ... Register $48
; ds 8*1 ... Register $4C
+RAM_Locked: ds 12 ; Locked channels
+
RAM_LastBank: ds 1 ; Last accessed bank
RAM_BGMData: ; Where BGM data starts
@@ -38,8 +41,6 @@ RAM_SFXDelay: ds 1 ; How many ticks to wait
RAM_SFXBank: ds 1 ; Current SFX bank
RAM_SFXAddress: ds 2 ; Current SFX address
-RAM_Locked: ds 12 ; Locked channels
-
RAM_Scratch: ds 32 ; Scratch bytes, may be useful when
; buffering to speed up to avoid bank
; switching conflicts
diff --git a/src-z80/player/fm.z80 b/src-z80/player/fm.z80
index b48e79b..4c0b565 100644
--- a/src-z80/player/fm.z80
+++ b/src-z80/player/fm.z80
@@ -668,50 +668,73 @@ SetFMVolLoad:
;****************************************************************************
SetFMParamSFX:
- call SetFMParam ; We're just a wrapper
- jp ProcessSFXRun ; End of subroutine
-
-SetFMParamBGM:
ld b, a
PollPCM
- ld a, b
- push hl
- and $07 ; Check if channel is free
- ld hl, RAM_Locked
- add l
- ld l, a
- ld a, (hl)
- pop hl
- or a
- jp nz, ProcessBGMSkip1 ; Don't modify if locked
+ ld a, b ; Determine which port to write
+ and $04
+ rrca
+ ld iyl, a
ld a, b
- call SetFMParam ; We're just a wrapper
- jp ProcessBGMRun ; End of subroutine
+ ex af, af'
+ PollPCM
+ call GetParam ; Get parameters
+ PollPCM
+ ex af, af'
-SetFMParam:
+ and $03 ; Get channel ID
+ add $B4
+ ld (iy+0), a ; Set new parameters
+ ld (iy+1), b
+
+ jp ProcessSFXRun ; End of subroutine
+
+SetFMParamBGM:
ld b, a
PollPCM
-
+ ld a, b
+
ld a, b ; Determine which port to write
and $04
rrca
ld iyl, a
- ld a, b
ex af, af'
PollPCM
call GetParam ; Get parameters
PollPCM
ex af, af'
+
+ push hl
+ and $07 ; Store parameters
+ ld h, RAM_BGMFMPan>>8
+ add RAM_BGMFMPan&$FF
+ ld l, h
+ ld (hl), b
+
+ ex af, af'
+ PollPCM
+ ex af, af'
+
+ and $07 ; Check if channel is free
+ add RAM_Locked&$FF
+ ld l, a
+ ex af, af'
+ ld a, (hl)
+ or a
+ pop hl
+ jp nz, ProcessBGMRun ; Don't modify if locked
+
+ PollPCM
+ ex af, af'
and $03 ; Get channel ID
add $B4
ld (iy+0), a ; Set new parameters
ld (iy+1), b
-
- ret ; End of subroutine
+
+ jp ProcessBGMRun ; End of subroutine
;****************************************************************************
; LockChannelFM [events $E0-$E7]
@@ -766,9 +789,6 @@ KillFM:
ld iyl, a
ld a, c
- ld (ix+0), $28 ; Stop current note (if any)
- ld (ix+1), a
-
and $03 ; Load dummy FM instrument
add $40
ld c, 6
@@ -804,9 +824,11 @@ KillFM:
PollPCM
pop af
- ld c, a ; Reset ADSR
+ ld c, a ; Cause the ADSR to reset
or $F0
ld (ix+0), $28
+ ld (ix+1), c
+ ld (ix+0), $28
ld (ix+1), a
ld (ix+0), $28
ld (ix+1), c
diff --git a/src-z80/player/freq.z80 b/src-z80/player/freq.z80
index d12ee2b..97dafbe 100644
--- a/src-z80/player/freq.z80
+++ b/src-z80/player/freq.z80
@@ -97,9 +97,9 @@ FMFreqTable:
;****************************************************************************
DummyFMInstr:
- db $FF ; $40..$4C
- db $FF ; $50..$5C
- db $FF ; $60..$6C
- db $FF ; $70..$7C
+ db $7F ; $40..$4C
+ db $00 ; $50..$5C
+ db $1F ; $60..$6C
+ db $1F ; $70..$7C
db $FF ; $80..$8C
db $00 ; $90..$9C
diff --git a/src-z80/player/psg.z80 b/src-z80/player/psg.z80
index 46df82a..f0c5a76 100644
--- a/src-z80/player/psg.z80
+++ b/src-z80/player/psg.z80
@@ -573,8 +573,6 @@ SetNotePSGBGM:
push hl
and $0F ; Check if channel is free
- ;ld hl, RAM_Locked
- ;add l
ld h, RAM_Locked>>8
add RAM_Locked&$FF
ld l, a
@@ -640,14 +638,14 @@ SetNoteNoiseBGM:
;****************************************************************************
LockChannelPSG:
+ and $03
ld b, a
PollPCM
push hl
ld h, RAM_Locked>>8 ; Get address of channel to lock
ld a, b
- and $0F
- add RAM_Locked&$FF
+ add (RAM_Locked&$FF)+8
ld l, a
ld (hl), $01 ; Lock channel