Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. ; -------------------------------------------------------------------------
  2. ; Stream a channel's sample to its PCM wave RAM
  3. ; -------------------------------------------------------------------------
  4.  
  5. StreamPCM:
  6. move.b tPCMPrv(a4),d0 ; Get previous buffer block that was being played in
  7.  
  8. moveq #0,d1 ; Get current buffer block that's being played in
  9. move.b tTrack(a4),d1
  10. add.b d1,d1
  11. add.b d1,d1
  12. add.b #pcmAddr+2,d1
  13. move.b (a6,d1.w),d1
  14. bsr.w WaitPCM
  15. andi.b #$1E,d1
  16.  
  17. move.b d1,tPCMPrv(a4) ; Set new previous block played in
  18. cmp.b d0,d1 ; Have we swapped buffer blocks?
  19. bne.s .DoStream ; If so, stream the next block
  20. rts
  21.  
  22. .DoStream:
  23. StreamPCM_Init:
  24. moveq #$FFFFFF80,d0 ; Set wave bank to store data in
  25. add.b tPCMBank(a4),d0
  26. move.b tTrack(a4),d1
  27. add.b d1,d1
  28. add.b d1,d0
  29. move.b d0,pcmCtrl(a6)
  30. bsr.w WaitPCM
  31.  
  32. movea.l tSampPos(a4),a0 ; Sample position
  33. movea.l tPCMPos(a4),a1 ; Stream position
  34.  
  35. move.w #$200-1,d1 ; Copy $200 bytes
  36.  
  37. .Copy:
  38. move.b (a0)+,d0 ; Get sample byte
  39. cmpi.b #$FF,d0 ; Is it the termination flag?
  40. bne.s .Write ; If not, branch
  41. movea.l tSampLoop(a4),a0 ; Reset sample position
  42. move.b (a0)+,d0 ; Get byte from there
  43.  
  44. .Write:
  45. move.b d0,(a1)+ ; Store in wave bank
  46. addq.w #1,a1 ; Fix wave bank address
  47. dbf d1,.Copy ; Copy until done
  48.  
  49. subq.b #1,tPCMBlks(a4) ; Subtract block amount
  50. bne.s .End ; Branch if we have filled the bank
  51. moveq #8,d0 ; Number of blocks in bank 0
  52. bchg #0,tPCMBank(a4) ; Swap banks
  53. bne.s .SetBlockCnt
  54. moveq #7,d0 ; Number of blocks in bank 1
  55.  
  56. .SetBlockCnt:
  57. move.b d0,tPCMBlks(a4) ; Set block count
  58. lea PCM_WAVE,a1 ; Reset stream position
  59.  
  60. .End:
  61. move.l a0,tSampPos(a4) ; Save new sample position
  62. move.l a1,tPCMPos(a4) ; Save new stream position
  63. rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement