Sona 0.50 Source

Sona 0.50/src-z80/psg_stop.z80

;****************************************************************************
; StopAllPsg
; Stops all PSG channels immediately.
;----------------------------------------------------------------------------
; breaks .... a,bc,de,hl,iy,a'
;****************************************************************************

StopAllPsg:
    ld      h, PsgAdsr>>8               ; Address of ADSR envelopes for
    ld      a, PsgAdsr&$FF              ; every channel
    
    ld      b, 4                        ; Loop through all channels
StopAllPsg_Loop:
    ld      l, a                        ; Make pointer to ADSR envelope
                                        ; for this channel
    
    ld      (hl), 0                     ; Set level to mute
    inc     l
    
    ld      (hl), PSGPHASE_RELEASE      ; Set phase to release
    
    add     a, SIZEOF_PSGADSR           ; Advance offset
    djnz    StopAllPsg_Loop             ; Onto next channel
    
    ret                                 ; End of subroutine

;****************************************************************************
; MutePsgOut
;
; Mutes all PSG channels (this by-passes the ADSR, so the moment the ADSR is
; ticked again it'll output through all channels again).
;----------------------------------------------------------------------------
; modifies ... hl
;****************************************************************************

MutePsgOut:
    ld      hl, PsgPort                 ; PSG port
    
    ld      (hl), $9F                   ; Mute PSG1
    ld      (hl), $BF                   ; Mute PSG2
    ld      (hl), $DF                   ; Mute PSG3
    ld      (hl), $FF                   ; Mute PSG4
    
    ret                                 ; End of subroutine