Sona 0.50 Source

Sona 0.50/src-z80/stream_flow.z80

;****************************************************************************
; SetLoopPoint [SONAOP_SETLOOP]
; Stores the current stream address as its loop point.
;----------------------------------------------------------------------------
; input c ..... current stream bank
; input hl .... current stream address
;----------------------------------------------------------------------------
; output c .... new stream bank
; output hl ... new stream address
;----------------------------------------------------------------------------
; modifies .... a,bc,de,hl,a'
;****************************************************************************

SetLoopPoint:
    PollPcm
    ex      de, hl                      ; Current address is in HL but we're
                                        ; using IY and those two registers
                                        ; don't mix, so swap it with DE while
                                        ; we're doing this
    
    ld      iy, (StreamPtr)             ; Get pointer to stream state and
    ld      (iy+STREAM_LOOPADDRLO), e   ; store the current stream position
    ld      (iy+STREAM_LOOPADDRHI), d   ; into the loop point
    ld      (iy+STREAM_LOOPBANK), c
    
    ex      de, hl                      ; Put current address back in HL
    ret                                 ; End of subroutine

;****************************************************************************
; GoToLoopPoint [SONAOP_GOTOLOOP]
; Resumes stream execution from its loop point.
;----------------------------------------------------------------------------
; output c .... new stream bank
; output hl ... new stream address
;----------------------------------------------------------------------------
; modifies .... a,bc,de,hl,a'
;****************************************************************************

GoToLoopPoint:
    PollPcm
    
    ld      iy, (StreamPtr)             ; Get pointer to stream state and
    ld      e, (iy+STREAM_LOOPADDRLO)   ; load the loop point as the new
    ld      d, (iy+STREAM_LOOPADDRHI)   ; current address
    ld      c, (iy+STREAM_LOOPBANK)
    ex      de, hl
    
    ret                                 ; End of subroutine