;****************************************************************************
; RestorePsg
; Restores a PSG channel after a SFX stream is over.
;----------------------------------------------------------------------------
; input a .... channel ID (0..3)
;----------------------------------------------------------------------------
; modifies ... a,a'
;****************************************************************************
RestorePsg:
push bc ; Save registers
push de
push hl
push af
add a, BgmPsgVol&$FF ; Reload the BGM volume
ld d, BgmPsgVol>>8
ld e, a
add a, RealPsgVol-BgmPsgVol
ld (PsgSetVolume_RealPtr), a
call RawPsgSetVolume
PollPcm
pop af
add a, BgmPsgInstr&$FF ; Get instrument ID used by BGM
ld h, BgmPsgInstr>>8 ; for this channel
ld l, a
ld b, (hl)
sub BgmPsgInstr&$FF ; Reload the instrument (which
call LoadPsgInstr ; conveniently will also stop any
; leftover notes)
PollPcm
pop hl ; Restore registers
pop de
pop bc
ret ; End of subroutine