home *** CD-ROM | disk | FTP | other *** search
/ Commodore Disk User Volume 4 #5 / Commodore_Disk_User_Vol.4_5_1991_-.d64 / viewscreens.asm (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  10KB  |  404 lines

  1. 10 *=$c000
  2. 20 ! **********************************
  3. 30 !
  4. 40 !    seuck extension block/screen
  5. 50 !   expansion routine by ian (NULL)ffe
  6. 60 !      october, 1989 for cdu.
  7. 70 !
  8. 80 !   source file compatible with:
  9. 90 !
  10. 100 !
  11. 110 !    >  mikro assembler
  12. 120 !    >  6510+
  13. 130 !    >  my macro assembler
  14. 140 !
  15. 150 !       (change asl a to asla
  16. 160 !       with macro assembler)
  17. 170 !
  18. 180 ! **********************************
  19. 190 !
  20. 200 ! this program takes the data
  21. 210 ! saved from the s.e.u.c.k extension
  22. 220 ! editor, and displays a given
  23. 230 ! screen.
  24. 240 !
  25. 250 ! we are using bank 0 (default)
  26. 260 ! with the following set of data:-
  27. 270 !
  28. 280 ! block colours     at $2000-$2080
  29. 290 ! block definitions at $2100-$2d80
  30. 300 ! character set     at $3000-$3800
  31. 310 ! screen data       at $4000-$6000
  32. 320 ! screen            at $0400>default
  33. 330 !
  34. 340 !      first give values to
  35. 350 !      labels refering to the above
  36. 360 !
  37. 370 blockbase=$2100
  38. 380 screendata=$4000
  39. 390 bb=blockbase !  a shorter label for
  40. 400 !               later on!!
  41. 410 colblock=$2000
  42. 420 sc=1024
  43. 430 !
  44. 440 !           used to find colour map
  45. 450 !           from screen address...
  46. 460 !
  47. 470 difference=55296-sc
  48. 480 !
  49. 490 !      init zero page locations to
  50. 500 !      hold the addresses to work on
  51. 510 !
  52. 520 blockad=$fe
  53. 530 colourad=$fc
  54. 540 screenad=$fa
  55. 550 sad=$f8
  56. 560 !
  57. 570 ! *****************************
  58. 580 !
  59. 590 ! this is all that is required
  60. 600 ! of you to print a screen!!!
  61. 610 !
  62. 620 sei
  63. 630 lda #28 !     move char set to 12288
  64. 640 sta 53272
  65. 650 lda #216
  66. 660 sta 53270 !   multicolour on
  67. 670 !
  68. 680 lda #0  !   set colours as you wish
  69. 690 sta 53281
  70. 700 sta 53282
  71. 710 ldx #6
  72. 720 stx 53282
  73. 730 inx
  74. 740 stx 53283
  75. 750 lda #0  !     load a with screen #
  76. 760 jsr expascr
  77. 770 cli
  78. 780 rts
  79. 790 ! *****************************
  80. 800 !
  81. 810 ! ----------------------------------
  82. 820 !       the routine below prints
  83. 830 !       a single block to the screen
  84. 840 !       at the given x and y coords.
  85. 850 !      call this routine with:
  86. 860 !             a=block number
  87. 870 !     "xinit" any "yinit"
  88. 880 !  holding the relevant coordinates.
  89. 890 !
  90. 900 ! ----------------------------------
  91. 910 expblock !
  92. 920 !
  93. 930 !
  94. 940 sta blocknum
  95. 950 tax
  96. 960 !
  97. 970 !
  98. 980 !     ! get y=block number*2
  99. 990 !
  100. 1000 asl a !  shift left ie. *2
  101. 1010 tay
  102. 1020 !
  103. 1030 !     get the colour of this block
  104. 1040 lda colblock,x
  105. 1050 sta colour
  106. 1060 !
  107. 1070 !   now we need to get the start
  108. 1080 !   addr. of this block's definition
  109. 1090 !
  110. 1100 !   to do this we need to get :-
  111. 1110 !   (block no.*25)+block base addr.
  112. 1120 !   this may take much processor
  113. 1130 !   time as "multiple-addition"
  114. 1140 !   techniques are required.
  115. 1150 !
  116. 1160 ! instead i have set up a 256-byte
  117. 1170 ! table holding each of the 128
  118. 1180 ! block addresses.
  119. 1190 ! to index a particular block def.
  120. 1200 !       index=block no. *2
  121. 1210 !
  122. 1220 !        as y=block no*2
  123. 1230 !
  124. 1240 !
  125. 1250 lda blocktabad,y ! get lo byte
  126. 1260 sta blockad
  127. 1270 lda blocktabad+1,y ! hi byte
  128. 1280 sta blockad+1
  129. 1290 !
  130. 1300 !      simple isn't it, now"?"
  131. 1310 !
  132. 1320 ! this time saving is required
  133. 1330 ! as this routine is called 32
  134. 1340 ! times for each screen - you will
  135. 1350 ! notice the time difference
  136. 1360 ! if the address wasn't tabulated!
  137. 1370 ! we need to bang data onto the
  138. 1380 ! screen like a bat out of hell,
  139. 1390 !  so it's well worth the 256 bytes!
  140. 1400 ! -------------------------------
  141. 1410 !           summary:-
  142. 1420 !  blockad holds block/char addr
  143. 1430 !  for block in "blocknum"
  144. 1440 ! -------------------------------
  145. 1450 !
  146. 1460 !  now get screenad to hold the
  147. 1470 !  screen address for the y coord.
  148. 1480 !
  149. 1490 !    ie. so as screenad holds the
  150. 1500 !    screen address for when x=0.
  151. 1510 !
  152. 1520 !   i am employing the same
  153. 1530 !   "get the address out of the
  154. 1540 !   table[171]quick" method again as
  155. 1550 ! it is in the main routine still!
  156. 1560 !    get y coordinate*2 for offset
  157. 1570 !    in the screen address table.
  158. 1580 !
  159. 1590 lda yinit
  160. 1600 asl a
  161. 1610 tay
  162. 1620 lda screentable,y
  163. 1630 sta screenad
  164. 1640 lda screentable+1,y
  165. 1650 sta screenad+1
  166. 1660 !
  167. 1670 !
  168. 1680 !
  169. 1690 !
  170. 1700 ! -----------------------------
  171. 1710 ! now screenad=the y coord address
  172. 1720 ! of the screen for x=0
  173. 1730 ! -----------------------------
  174. 1740 !
  175. 1750 lda #0
  176. 1760 sta blkread !  count through 0-24
  177. 1770 !              chars. in this block
  178. 1780 lda #5
  179. 1790 sta ycount !     height of block
  180. 1800 !
  181. 1810 do1y lda xinit ! each new y coord -
  182. 1820 !                give the x start
  183. 1830 !                index across the
  184. 1840 !                the screen ie.
  185. 1850 !                value from 0-39.
  186. 1860 sta xcoord
  187. 1870 ldy #5 !         width of block
  188. 1880 sty xcount
  189. 1890 !
  190. 1900 do1x ldy blkread !    index (0-24)
  191. 1910 !                    through block
  192. 1920 !                    definition.
  193. 1930 !
  194. 1940 !           read a char. to print
  195. 1950 !           from this block's base
  196. 1960 !
  197. 1970 readblock lda (blockad),y
  198. 1980 !
  199. 1990 ldy xcoord !    store on screen
  200. 2000 !              taking into account
  201. 2010 !               the column index
  202. 2020 !
  203. 2030 sta (screenad),y
  204. 2040 !
  205. 2050 !     create the colourmap address
  206. 2060 !     relative from the screen.
  207. 2070 !
  208. 2080 !  note that if a screen address
  209. 2090 !  is being used that is >55296
  210. 2100 !   then the label difference
  211. 2110 !  would need to be changed to:-
  212. 2120 !      difference=scr-55296
  213. 2130 !
  214. 2140 !  and the "adc" instructions
  215. 2150 ! below would need to be changed
  216. 2160 ! to "sbc" - making sure that you
  217. 2170 ! set carry (sec) first instead of
  218. 2180 !   "clc"  - nuff said!
  219. 2190 !
  220. 2200 clc
  221. 2210 lda screenad
  222. 2220 adc #<difference
  223. 2230 sta colourad
  224. 2240 lda screenad+1
  225. 2250 adc #>difference
  226. 2260 sta colourad+1
  227. 2270 lda colour
  228. 2280 !
  229. 2290 !  y still holds column index
  230. 2300 ! so colour in that char on screen!
  231. 2310 sta (colourad),y
  232. 2320 !
  233. 2330 inc xcoord !     move along screen
  234. 2340 !                column
  235. 2350 inc blkread !   through 0-24 index
  236. 2360 !               in block
  237. 2370 !
  238. 2380 !
  239. 2390 dec xcount       loop width
  240. 2400 bne do1x
  241. 2410 !
  242. 2420 !
  243. 2430 ! now move down one y coordinate -
  244. 2440 ! just add 40 to the screen addr.
  245. 2450 !
  246. 2460 clc
  247. 2470 lda screenad
  248. 2480 adc #40
  249. 2490 sta screenad
  250. 2500 bcc oke
  251. 2510 inc screenad+1
  252. 2520 !
  253. 2530 oke dec ycount !   loop height
  254. 2540 bne do1y
  255. 2550 rts
  256. 2560 xcoord byt 0
  257. 2570 blkread byt 0
  258. 2580 xinit byt 0
  259. 2590 yinit byt 0
  260. 2600 blocknum byt 0
  261. 2610 ycount byt 0
  262. 2620 xcount byt 0
  263. 2630 ! ------------------------------
  264. 2640 !
  265. 2650 ! this routine expands a complete
  266. 2660 ! screen by calling the "expand
  267. 2670 ! a block routine" for each of the
  268. 2680 ! 32 blocks on a screen..
  269. 2690 !
  270. 2700 !it is called with a=screen number
  271. 2710 ! - simplicity it'self for you!
  272. 2720 !
  273. 2730 ! ------------------------------
  274. 2740 expascr !
  275. 2750 !
  276. 2760 ! right - what we must do
  277. 2770 ! is find the screen data address.
  278. 2780 ! each data address for a screen
  279. 2790 ! is 32 bytes long - so we must
  280. 2800 ! get (32*screen)+base
  281. 2810 ! of data addresses - ok...
  282. 2820 !
  283. 2830 ldx #0
  284. 2840 sta sad
  285. 2850 stx sad+1 !  init multiply
  286. 2860 !
  287. 2870 clc
  288. 2880 asl sad
  289. 2890 rol sad+1 !             *2
  290. 2900 asl sad
  291. 2910 rol sad+1 !             *4
  292. 2920 asl sad
  293. 2930 rol sad+1 !             *8
  294. 2940 asl sad
  295. 2950 rol sad+1 !             *16
  296. 2960 asl sad
  297. 2970 rol sad+1         !     *32
  298. 2980 !
  299. 2990 !     now to add in the base
  300. 3000 !     address of the screen data
  301. 3010 !
  302. 3020 clc
  303. 3030 lda sad
  304. 3040 adc #<screendata
  305. 3050 sta sad
  306. 3060 lda sad+1
  307. 3070 adc #>screendata
  308. 3080 sta sad+1
  309. 3090 !
  310. 3100 ! --------------------------
  311. 3110 ! wicked! - scrad/+1 holds base
  312. 3120 ! address for the screen - phew!
  313. 3130 ! ---------------------------
  314. 3140 !
  315. 3150 !
  316. 3160 stx xinit !      x coord on screen
  317. 3170 stx yinit !      y   "   "    "
  318. 3180 stx blokc ! index in screen [131]
  319. 3190 !           [164] [135] block numbers
  320. 3200 bka !
  321. 3210 ldy blokc
  322. 3220 lda (sad),y ! [135] block in
  323. 3230 !                 this screen
  324. 3240 !
  325. 3250 inc blokc !  [130] block in screen
  326. 3260 !
  327. 3270 ! bang that block [145][164] the screen !
  328. 3280 jsr [189]block
  329. 3290 !
  330. 3300 lda xinit
  331. 3310 clc
  332. 3320 adc #5 !      start [130] block
  333. 3330 !            al[145]g by 5 characters
  334. 3340 sta xinit
  335. 3350 cmp #40 ! right[171]most column
  336. 3360 !         reached
  337. 3370 !
  338. 3380 bne noxreac
  339. 3390 !
  340. 3400 ! [171][171][177] [139] x reached last column
  341. 3410 !     [167] reset x [164] 0, [175] move
  342. 3420 !     down by 5 y co[176]dinates!!
  343. 3430 !
  344. 3440 lda #0
  345. 3450 sta xinit
  346. 3460 clc
  347. 3470 lda yinit
  348. 3480 adc #5 !      down 5 chars(y)
  349. 3490 sta yinit
  350. 3500 !
  351. 3510 !
  352. 3520 cmp #20 !  check for max y coord.
  353. 3530 !         (must be a multiple of 5
  354. 3540 !          - or else !!!!)
  355. 3550 !
  356. 3560 beq [142]
  357. 3570 noxreac jmp bka
  358. 3580 !
  359. 3590 ! finally the whole screen has
  360. 3600 ! been displayed [171] sit back &
  361. 3610 ! admire your w[176]k..........
  362. 3620 !
  363. 3630 [142] !
  364. 3640 rts
  365. 3650 blokc byt 0
  366. 3660 colour byt 0
  367. 3670 !
  368. 3680 !
  369. 3690 !the addresses of block definitions
  370. 3700 ! (all 128 of them!)
  371. 3710 !
  372. 3720 blocktabad !
  373. 3730 w[176] bb,bb[170]25,bb[170]50,bb[170]75,bb[170]100,bb[170]125,bb[170]150,bb[170]175,bb[170]200,bb[170]225
  374. 3740 w[176] bb[170]250,bb[170]275,bb[170]300,bb[170]325
  375. 3750 w[176] bb[170]350,bb[170]375,bb[170]400,bb[170]425
  376. 3760 w[176] bb[170]450,bb[170]475,bb[170]500,bb[170]525
  377. 3770 w[176] bb[170]550,bb[170]575,bb[170]600,bb[170]625
  378. 3780 w[176] bb[170]650,bb[170]675,bb[170]700,bb[170]725,bb[170]750,bb[170]775,bb[170]800,bb[170]825,bb[170]850,bb[170]875
  379. 3790 w[176] bb[170]900,bb[170]925,bb[170]950,bb[170]975,bb[170]1000,bb[170]1025
  380. 3800 w[176] bb[170]1050,bb[170]1075,bb[170]1100,bb[170]1125,bb[170]1150,bb[170]1175,bb[170]1200,bb[170]1225
  381. 3810 w[176] bb[170]1250,bb[170]1275,bb[170]1300,bb[170]1325,bb[170]1350,bb[170]1375,bb[170]1400,bb[170]1425
  382. 3820 w[176] bb[170]1450,bb[170]1475,bb[170]1500,bb[170]1525,bb[170]1550,bb[170]1575,bb[170]1600,bb[170]1625
  383. 3830 w[176] bb[170]1650,bb[170]1675,bb[170]1700,bb[170]1725,bb[170]1750,bb[170]1775,bb[170]1800,bb[170]1825
  384. 3840 w[176] bb[170]1850,bb[170]1875,bb[170]1900,bb[170]1925
  385. 3850 w[176] bb[170]1950,bb[170]1975,bb[170]2000,bb[170]2025,bb[170]2050,bb[170]2075,bb[170]2100,bb[170]2125
  386. 3860 w[176] bb[170]2150,bb[170]2175,bb[170]2200,bb[170]2225,bb[170]2250,bb[170]2275,bb[170]2300,bb[170]2325
  387. 3870 w[176] bb[170]2350,bb[170]2375,bb[170]2400,bb[170]2425,bb[170]2450,bb[170]2475,bb[170]2500,bb[170]2525
  388. 3880 w[176] bb[170]2550,bb[170]2575,bb[170]2600,bb[170]2625,bb[170]2650,bb[170]2675,bb[170]2700,bb[170]2725
  389. 3890 w[176] bb[170]2750,bb[170]2775,bb[170]2800,bb[170]2825,bb[170]2850,bb[170]2875,bb[170]2900,bb[170]2925
  390. 3900 w[176] bb[170]2950,bb[170]2975,bb[170]3000,bb[170]3025,bb[170]3050,bb[170]3075,bb[170]3100,bb[170]3125
  391. 3910 w[176] bb[170]3150,bb[170]3175
  392. 3920 !
  393. 3930 ! [175] the screen addresses.....
  394. 3940 !
  395. 3950 screentable w[176] sc,sc[170]40,sc[170]80,sc[170]120,sc[170]160,sc[170]200,sc[170]240,sc[170]280,sc[170]320
  396. 3960 w[176] sc[170]360,sc[170]400,sc[170]440,sc[170]480,sc[170]520,sc[170]560,sc[170]600,sc[170]640,sc[170]680,sc[170]720
  397. 3970 w[176] sc[170]760,sc[170]800
  398. 3980 !
  399. 3990 !
  400. 4000 !         ig'89
  401. 4010 !
  402. 4020 !
  403. 4030 !
  404.