home *** CD-ROM | disk | FTP | other *** search
/ Commodore Disk User Volume 3 #11 / Commodore_Disk_User_Vol.3_11_1990_-.d64 / sampleplayer.asm (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  4KB  |  181 lines

  1. 1000 *=$c300
  2. 1010 ! --------------------------------
  3. 1020 ! c64 sample kit - sample player
  4. 1030 ! source file for mikro & 6510+.
  5. 1040 !
  6. 1050 !   written by ian (NULL)ffe 1990
  7. 1060 !   for commodore disk user.
  8. 1070 !
  9. 1080 !       memory requirements:-
  10. 1090 !
  11. 1100 !    sample:-       $2000-$a000
  12. 1110 !    split data:-   $c000-$c100
  13. 1120 !    tune:-         $c100-$c300
  14. 1130 !
  15. 1140 !
  16. 1150 !
  17. 1160 sample=$2000
  18. 1170 splits=$c000
  19. 1180 tune=$c100
  20. 1190 !
  21. 1200 zero1=$fb
  22. 1210 !
  23. 1220 ! --------------------------------
  24. 1230 ! object code len:- $c5(197) bytes
  25. 1240 ! --------------------------------
  26. 1250 !
  27. 1260 lda #0
  28. 1270 sta 53280
  29. 1280 sta 53281    ! screen->black
  30. 1290 !
  31. 1300 sei          ! disable for speed
  32. 1310 lda $d011
  33. 1320 and #%11101111
  34. 1330 sta $d011    ! blank screen
  35. 1340 jsr clearsid ! clear sound chip
  36. 1350 jsr playseq  ! main player
  37. 1360 lda $d011
  38. 1370 ora #%00010000
  39. 1380 sta $d011    ! restore screen
  40. 1390 cli          ! interrupts back on
  41. 1400 rts
  42. 1410 !
  43. 1420 !
  44. 1430 ! --------------------------
  45. 1440 clearsid !     clear sound chip
  46. 1450 ldx #0
  47. 1460 txa
  48. 1470 lp1 sta $d400,x
  49. 1480 inx
  50. 1490 cpx #24
  51. 1500 bne lp1
  52. 1510 rts
  53. 1520 ! --------------------------
  54. 1530 !
  55. 1540 !
  56. 1550 ! --------------------------
  57. 1560 ! play a single sample split.
  58. 1570 ! 'start' holds start hi byte.
  59. 1580 ! of the sample data.
  60. 1590 ! 'last' holds the end-hi byte
  61. 1600 ! address of the sample.
  62. 1610 ! --------------------------
  63. 1620 playasample ldx #0
  64. 1630 ldy start
  65. 1640 stx zero1
  66. 1650 sty zero1+1
  67. 1660 ldy #0
  68. 1670 play !       ! loop a page of data
  69. 1680 lda (zero1),y  ! get sample byte
  70. 1690 lsr a         ! get desired nibble
  71. 1700 lsr a
  72. 1710 lsr a
  73. 1720 lsr a
  74. 1730 sta $d418    ! output as volume
  75. 1740 ldx speed    ! delay between bytes
  76. 1750 del2 dex
  77. 1760 bne del2
  78. 1770 iny          ! next byte in page
  79. 1780 bne play
  80. 1790 inc zero1+1  ! add 256 (hi byte+1)
  81. 1800 lda zero1+1  ! to read next page
  82. 1810 cmp last     ! check for last page
  83. 1820 bne play
  84. 1830 rts
  85. 1840 !
  86. 1850 start byt <sample
  87. 1860 last byt $a0
  88. 1870 speed byt 09
  89. 1880 !
  90. 1890 ! --------------------------------
  91. 1900 !  main player to play a "tune"
  92. 1910 !  of samples.
  93. 1920 ! --------------------------------
  94. 1930 playseq !
  95. 1940 ldx #0
  96. 1950 stx inseq
  97. 1960 rds !
  98. 1970 ldy tune,x  ! read sample # to y
  99. 1980 !
  100. 1990 ! ------> check for flags
  101. 2000 !
  102. 2010 cpy #131    ! 131=exit/end
  103. 2020 beq exitseq
  104. 2030 !
  105. 2040 cpy #129    ! 129=speed change
  106. 2050 beq makespeed
  107. 2060 cpy #130    ! 130=repeat tune
  108. 2070 beq repeat
  109. 2080 cpy #128    ! 128=delay with value
  110. 2090 beq dowait
  111. 2100 !
  112. 2110 !
  113. 2120 ! now y must be a "split" to play.
  114. 2130 !
  115. 2140 ! ----> read page numbers to play
  116. 2150 !       from .... to ....
  117. 2160 ! for the 'playasample' routine.
  118. 2170 !
  119. 2180 lda splits,y
  120. 2190 sta start
  121. 2200 lda splits+128,y
  122. 2210 sta last
  123. 2220 !
  124. 2230 ! read # times to play this split.
  125. 2240 !
  126. 2250 lda tune+256,x
  127. 2260 sta loopcount
  128. 2270 !
  129. 2280 ! -----> loopcount=repeat value.
  130. 2290 !
  131. 2300 lll jsr playasample ! play split
  132. 2310 lda $dc01          ! exit if space
  133. 2320 and #%00010000     ! bar pressed.
  134. 2330 bne iew
  135. 2340 jmp exitseq
  136. 2350 iew !
  137. 2360 dec loopcount      ! loop repeats
  138. 2370 bne lll
  139. 2380 nextinseq !
  140. 2390 inc inseq          ! seq. index+1
  141. 2400 ldx inseq
  142. 2410 jmp rds            ! next step
  143. 2420 !
  144. 2430 exitseq rts
  145. 2440 !
  146. 2450 inseq byt 0
  147. 2460 loopcount byt 0
  148. 2470 ! --------------------------------
  149. 2480 !
  150. 2490 ! handle the "sp" flag....
  151. 2500 !
  152. 2510 makespeed lda tune+256,x
  153. 2520 sta speed
  154. 2530 jmp nextinseq
  155. 2540 !
  156. 2550 ! "rp" flag....
  157. 2560 !
  158. 2570 repeat jmp playseq
  159. 2580 !
  160. 2590 ! "wt" flag....
  161. 2600 !
  162. 2610 dowait lda tune+256,x
  163. 2620 sta loopcount
  164. 2630 lli jsr delay
  165. 2640 dec loopcount
  166. 2650 bne lli
  167. 2660 jmp nextinseq
  168. 2670 !
  169. 2680 delay ldx #10
  170. 2690 d2 dey
  171. 2700 bne d2
  172. 2710 dex
  173. 2720 bne d2
  174. 2730 rts
  175. 2740 !
  176. 2750 !
  177. 2760 !        ig'1990.
  178. 2770 !
  179. 2780 !
  180. 2790 !
  181.