home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 60 / 060.d81 / color.chase.pal (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  3KB  |  167 lines

  1. 100 sys700
  2. 110 ;
  3. 120 .opt oo
  4. 130 ;
  5. 140 ; 'color chaser', by scott e. resh
  6. 150 ;
  7. 160 ;
  8. 170 ; code will be at $c000 (49152)
  9. 180 ;
  10. 190 lcmem = $d800 - 40
  11. 200 r0l = $fb
  12. 210 r0h = r0l + 1
  13. 220 r1l = r0h + 1
  14. 230 r1h = r1l + 1
  15. 240 bkgrnd = $d021
  16. 250 ;
  17. 260 ;
  18. 270 jmp init ;
  19. 280 jmp past ;
  20. 290 ;
  21. 300 ;
  22. 310 init ldx #3 ; copy values to
  23. 320 l1 lda r0l,x ;  local storage
  24. 330 sta local,x ;
  25. 340 dex ;
  26. 350 bpl l1 ;
  27. 360 ;
  28. 370 lda r1l ; if either length = 0,
  29. 380 beq ooh ;  then exit, else ok
  30. 390 lda r1h ;
  31. 400 bne ok1 ;
  32. 410 ;
  33. 420 ooh rts ; return to basic
  34. 430 ;
  35. 440 ok1 dec column ;
  36. 450 dec row ;
  37. 460 ;
  38. 470 clc ;
  39. 480 lda xc ; if x+column>39 then error
  40. 490 adc column ;
  41. 500 cmp #40 ;
  42. 510 bcs ooh ;
  43. 520 lda yc ; if y+row>24 then error
  44. 530 adc row ;
  45. 540 cmp #25 ;
  46. 550 bcs ooh ;
  47. 560 ;
  48. 570 lda #>lcmem ; init colormem pntr
  49. 580 sta r0h ;
  50. 590 lda #<lcmem ;
  51. 600 sta r0l ;
  52. 610 ldx yc ; x = row count
  53. 620 ;
  54. 630 clc ; add in row offset
  55. 640 l2 lda #40 ;  to colormem pointer
  56. 650 adc r0l ;
  57. 660 sta r0l ;
  58. 670 bcc ok2 ;
  59. 680 inc r0h ;
  60. 690 clc ;
  61. 700 ok2 dex ;
  62. 710 bpl l2 ;
  63. 720 ;
  64. 730 lda xc ; add in x-coord to
  65. 740 adc r0l ;  colormem pointer
  66. 750 sta r0l ;
  67. 760 bcc ok3 ;
  68. 770 inc r0h ;
  69. 780 ok3 lda r0l ; preserve base pntr
  70. 790 sta temp ;
  71. 800 lda r0h ;
  72. 810 sta temp+1 ;
  73. 820 ;
  74. 830 ldy #0 ; fetch color seed value
  75. 840 lda (r0l),y ;
  76. 850 sta mainc ;
  77. 860 ;
  78. 870 ;==================================
  79. 880 ;
  80. 890 past lda temp ; init colormem pntr
  81. 900 sta r0l ;
  82. 910 lda temp+1 ;
  83. 920 sta r0h ;
  84. 930 ;
  85. 940 lda mainc ; init color value for
  86. 950 sta color ;  this round
  87. 960 ;
  88. 970 dec mainc ; update color value
  89. 980 ; (note: change 'dec' to 'inc' to
  90. 990 ; move colors counter-clockwise)
  91. 1000 ;
  92. 1010 lda bkgrnd ; fetch backgrnd color
  93. 1020 and #15 ;  for 'cfetch' routine
  94. 1030 sta btemp ;
  95. 1040 ;
  96. 1050 ldy #0 ;
  97. 1060 ldx column ; # characters across
  98. 1070 ;
  99. 1080 l3 jsr fcolor ; move color left to
  100. 1090 sta (r0l),y ;  right along the top
  101. 1100 iny ;
  102. 1110 dex ;
  103. 1120 bpl l3 ;
  104. 1130 ;
  105. 1140 ldx row ;
  106. 1150 dex ;
  107. 1160 ldy column ;
  108. 1170 ;
  109. 1180 l4 lda r0l ; move color 'down'
  110. 1190 clc ;  along the right side
  111. 1200 adc #40 ;
  112. 1210 sta r0l ;
  113. 1220 bcc nc1 ;
  114. 1230 inc r0h ;
  115. 1240 nc1 jsr fcolor ;
  116. 1250 sta (r0l),y ;
  117. 1260 dex ;
  118. 1270 bne l4 ;
  119. 1280 ;
  120. 1290 ldx column ;
  121. 1300 txa ;
  122. 1310 clc ;
  123. 1320 adc #40 ;
  124. 1330 tay ;
  125. 1340 ;
  126. 1350 dl jsr fcolor ; move the color
  127. 1360 sta (r0l),y ;  right to left along
  128. 1370 dey ;  the bottom
  129. 1380 dex ;
  130. 1390 bpl dl ;
  131. 1400 ;
  132. 1410 ldy #0 ;
  133. 1420 ldx row ;
  134. 1430 dex ;
  135. 1440 ;
  136. 1450 final jsr fcolor ; move the color
  137. 1460 sta (r0l),y ;  'up' along the
  138. 1470 lda r0l ;  left column
  139. 1480 sec ;
  140. 1490 sbc #40 ;
  141. 1500 sta r0l ;
  142. 1510 bcs nborrow ; dec r0h only if a
  143. 1520 dec r0h ;  'borrow' cond. exists
  144. 1530 nborrow dex
  145. 1540 bne final
  146. 1550 ;
  147. 1560 rts ; return to basic
  148. 1570 ;
  149. 1580 fcolor lda color ; 'fetch color'
  150. 1590 inc color ;  routine, gets next
  151. 1600 and #15 ;  color (won't allow
  152. 1610 cmp btemp ;  background color)
  153. 1620 beq fcolor ;
  154. 1630 rts ;
  155. 1640 ;
  156. 1650 local .byte 0,0,0,0
  157. 1660 ;
  158. 1670 xc = local
  159. 1680 yc = local+1
  160. 1690 column = local+2
  161. 1700 row = local+3
  162. 1710 ;
  163. 1720 temp .word 0
  164. 1730 color .byte 0
  165. 1740 mainc .byte 0
  166. 1750 btemp .byte 0
  167.