Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; -------------------------------------------------------------------------
- ; Stream a channel's sample to its PCM wave RAM
- ; -------------------------------------------------------------------------
- StreamPCM:
- move.b tPCMPrv(a4),d0 ; Get previous buffer block that was being played in
- moveq #0,d1 ; Get current buffer block that's being played in
- move.b tTrack(a4),d1
- add.b d1,d1
- add.b d1,d1
- add.b #pcmAddr+2,d1
- move.b (a6,d1.w),d1
- bsr.w WaitPCM
- andi.b #$1E,d1
- move.b d1,tPCMPrv(a4) ; Set new previous block played in
- cmp.b d0,d1 ; Have we swapped buffer blocks?
- bne.s .DoStream ; If so, stream the next block
- rts
- .DoStream:
- StreamPCM_Init:
- moveq #$FFFFFF80,d0 ; Set wave bank to store data in
- add.b tPCMBank(a4),d0
- move.b tTrack(a4),d1
- add.b d1,d1
- add.b d1,d0
- move.b d0,pcmCtrl(a6)
- bsr.w WaitPCM
- movea.l tSampPos(a4),a0 ; Sample position
- movea.l tPCMPos(a4),a1 ; Stream position
- move.w #$200-1,d1 ; Copy $200 bytes
- .Copy:
- move.b (a0)+,d0 ; Get sample byte
- cmpi.b #$FF,d0 ; Is it the termination flag?
- bne.s .Write ; If not, branch
- movea.l tSampLoop(a4),a0 ; Reset sample position
- move.b (a0)+,d0 ; Get byte from there
- .Write:
- move.b d0,(a1)+ ; Store in wave bank
- addq.w #1,a1 ; Fix wave bank address
- dbf d1,.Copy ; Copy until done
- subq.b #1,tPCMBlks(a4) ; Subtract block amount
- bne.s .End ; Branch if we have filled the bank
- moveq #8,d0 ; Number of blocks in bank 0
- bchg #0,tPCMBank(a4) ; Swap banks
- bne.s .SetBlockCnt
- moveq #7,d0 ; Number of blocks in bank 1
- .SetBlockCnt:
- move.b d0,tPCMBlks(a4) ; Set block count
- lea PCM_WAVE,a1 ; Reset stream position
- .End:
- move.l a0,tSampPos(a4) ; Save new sample position
- move.l a1,tPCMPos(a4) ; Save new stream position
- rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement