fasttube.s 24 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205
  1. *------------------------------------------------------------------*
  2. *-(c) 1995 Glen Cumming, took about 4 hours to write -*
  3. *-Rough code just to test theory of super fast pixel ring plotting-*
  4. *-Code is a bit messy, but hey its only a bit of fun!!! -*
  5. *------------------------------------------------------------------*
  6. section Generic,Code_C
  7. OPT C-,D+
  8. opt NODEBUG
  9. opt p=68000
  10. EXEC EQU 4
  11. BPR EQU 64
  12. GRAPHICS_MOD EQU 0
  13. XSIZE EQU 4
  14. YSIZE EQU 36
  15. XDEST EQU 42
  16. YDEST EQU 164
  17. SCROLL_WIDTH EQU 27
  18. NOP EQU 18
  19. NOC EQU 0
  20. CUSTOM EQU $DFF000 ;start of amiga custom hardware
  21. BPLCONO EQU $100
  22. BPLCON1 EQU $102
  23. BPLCON2 EQU $104
  24. BPL1MOD EQU $108
  25. DDFSTRT EQU $092
  26. DDFSTOP EQU $094
  27. DIWSTRT EQU $08E
  28. DIWSTOP EQU $090
  29. VPSOR EQU $004
  30. COLOUR0 EQU $180
  31. COLOUR1 EQU $182
  32. COLOUR2 EQU $184
  33. COLOUR3 EQU $186
  34. DMACON EQU $096
  35. COP1LCH EQU $080
  36. COPJMP1 EQU $088
  37. DMAF_BLITTER EQU $0040
  38. DMAF_BLTDONE EQU $4000
  39. DMAF_BLTNZERO EQU $2000
  40. DMAB_BLTDONE EQU 14
  41. bltddat EQU $000
  42. dmaconr EQU $002
  43. vposr EQU $004
  44. vhposr EQU $006
  45. dskdatr EQU $008
  46. joy0dat EQU $00A
  47. joy1dat EQU $00C
  48. clxdat EQU $00E
  49. bltcon0 EQU $040
  50. bltcon1 EQU $042
  51. bltafwm EQU $044
  52. bltalwm EQU $046
  53. bltcpt EQU $048
  54. bltbpt EQU $04C
  55. bltapt EQU $050
  56. bltdpt EQU $054
  57. bltsize EQU $058
  58. bltcmod EQU $060
  59. bltbmod EQU $062
  60. bltamod EQU $064
  61. bltdmod EQU $066
  62. bltcdat EQU $070
  63. bltbdat EQU $072
  64. bltadat EQU $074
  65. dsksync EQU $07E
  66. cop1lc EQU $080
  67. cop2lc EQU $084
  68. bpl2mod EQU $10A
  69. bpldat EQU $110
  70. intreq EQU $09c
  71. intreqr EQU $01e
  72. dofasttube
  73. bsr Turn_Off_Tasking
  74. bsr Tube_Set_Up
  75. tst.l d0
  76. beq.s quit
  77. bsr Allocate_Plane_Memory
  78. tst.l d0
  79. bne.s Memory_Successfully_Allocated
  80. quit
  81. rts ;quit out if error
  82. Memory_Successfully_Allocated
  83. bsr Setup
  84. bsr Add_New_Ring
  85. bsr Main_Demo
  86. bsr Quit_Out
  87. rts
  88. QUIT_OUT
  89. MOVE.L 4,A6
  90. JSR -138(A6) ;ENABLE tasking
  91. bsr Tube_Quit
  92. move.l 4,a6
  93. move.l #(256*BPR)*8,d0
  94. move.l Memory_Base,a1
  95. jsr -210(a6)
  96. MOVE.L #graf_NAME,A1
  97. MOVEQ #0,D0
  98. JSR -552(A6) ;OPEN GRAPHICS LIBRARY
  99. MOVE.L D0,a4
  100. MOVE.W #$8020,DMACON+$dff000 ; sprites back
  101. move.l 38(a4),$dff080
  102. clr.w $dff088
  103. rts
  104. graf_NAME dc.b "graphics.library",0
  105. even
  106. ********************************
  107. *** SET UP ***
  108. ********************************
  109. setup
  110. bsr Setup_Colours
  111. LEA CUSTOM,A6
  112. MOVE.W #0,BPLCON1(A6)
  113. move.w #%1000000,BPLCON2(a6)
  114. move.w #$83a0,DMACON(a6)
  115. MOVE.W #$2C81,DIWSTRT(A6)
  116. MOVE.W #$2cC1,DIWSTOP(A6)
  117. MOVE.L #COPPERL,COP1LCH(A6)
  118. clr.w COPJMP1(A6)
  119. rts
  120. ********************************************
  121. **** ALLOCATE PLANE MEMORY ***
  122. ********************************************
  123. Allocate_Plane_Memory
  124. move.l 4,a6
  125. move.l #(256*BPR)*8,d0 ;
  126. move.l #1<<1+1<<16,d1 ;chip and clear
  127. jsr -198(a6) ;try
  128. tst.l d0 ;memory allocated?
  129. bne allocated_mem
  130. rts ;otherwise quit
  131. allocated_mem
  132. move.l d0,Memory_Base
  133. move.l d0,Plane1
  134. add.l #(256*BPR),d0
  135. move.l d0,plane2
  136. add.l #(256*BPR),d0
  137. move.l d0,plane3
  138. add.l #(256*BPR),d0
  139. move.l d0,plane4
  140. add.l #(256*BPR),d0
  141. move.l d0,buff_plane1
  142. add.l #(256*BPR),d0
  143. move.l d0,buff_plane2
  144. add.l #(256*BPR),d0
  145. move.l d0,buff_plane3
  146. add.l #(256*BPR),d0
  147. move.l d0,buff_plane4
  148. rts
  149. *************************************
  150. ** TURN OFF TASKING ***
  151. *************************************
  152. Turn_Off_Tasking
  153. move.l 4,a6
  154. jsr -132(A6) ;DISABLE tasking
  155. rts
  156. ************************************
  157. *** SET UP COLOURS ***
  158. ************************************
  159. Setup_Colours
  160. move.w #$180,d0
  161. move.l #copper_colours,a0
  162. move.l #col_list,a1
  163. move.w #16-1,d1
  164. col_loop
  165. move.w d0,(a0)+
  166. move.w (a1)+,(a0)+
  167. add.w #$2,d0
  168. dbra d1,col_loop
  169. rts
  170. col_list
  171. dc.w $000,$012,$124,$136,$158,$17a,$1ac
  172. dc.w $012,$012,$707,$f77,$f7f,$7ff,$777
  173. dc.w $707,$070
  174. ************************************************************
  175. ***** S C R E E N S Y N C **********
  176. ************************************************************
  177. sync
  178. move.l #$dff000,a6
  179. move.w #$0010,intreq(a6)
  180. wait_for_bit
  181. btst.b #4,intreqr+1(a6)
  182. beq.s wait_for_bit
  183. rts
  184. Wait_R_Mouse
  185. btst.b #10,$dff016
  186. beq.s Wait_R_Mouse
  187. rts
  188. Click_R_Mouse
  189. btst.b #10,$dff016
  190. bne.s Click_R_Mouse
  191. Release_R
  192. btst.b #10,$dff016
  193. beq.s Click_R_Mouse
  194. rts
  195. **************************************
  196. *** MAIN DEMO ***
  197. **************************************
  198. Main_Demo
  199. bsr sync
  200. bsr swap_buffers
  201. btst.b #6,$bfe001 ;has user pressed left mouse button
  202. beq.s quit_demo
  203. bsr GetMousePosition
  204. bsr Add_New_Ring
  205. bsr Clear_Pixels
  206. bsr Draw_Rings
  207. bsr Swap_Ring_Buffers
  208. bra.s Main_Demo
  209. quit_demo
  210. rts
  211. **************************************
  212. *** SWAP BUFFERS ***
  213. **************************************
  214. Swap_Buffers
  215. move.l plane1,d0
  216. move.l plane2,d1
  217. move.l plane3,d2
  218. move.l plane4,d3
  219. move.l buff_plane1,plane1
  220. move.l buff_plane2,plane2
  221. move.l buff_plane3,plane3
  222. move.l buff_plane4,plane4
  223. move.l d0,buff_plane1
  224. move.l d1,buff_plane2
  225. move.l d2,buff_plane3
  226. move.l d3,buff_plane4
  227. move.w d0,plane1_lo
  228. swap d0
  229. move.w d0,plane1_hi
  230. move.w d1,plane2_lo
  231. swap d1
  232. move.w d1,plane2_hi
  233. move.w d2,plane3_lo
  234. swap d2
  235. move.w d2,plane3_hi
  236. move.w d3,plane4_lo
  237. swap d3
  238. move.w d3,plane4_hi
  239. rts
  240. ************************************************
  241. ***** GET MOUSE POSITION ***
  242. ************************************************
  243. GetMousePosition
  244. bsr ReadMouse
  245. move.w mouse_x,d0
  246. move.w mouse_y,d1
  247. add.w mousex_inc,d0
  248. add.w mousey_inc,d1
  249. move.w d0,mouse_x
  250. move.w d1,mouse_y
  251. rts
  252. ***********************************************
  253. ***** READ MOUSE *****
  254. ************************************************
  255. ReadMouse
  256. *updates mousex_inc and mousey_inc - it is done this way
  257. *for total flexibility as it can be used to scroll the
  258. *screen or move an on screen pointer or be used to increase
  259. *levels volume menu options etc etc
  260. moveq #0,d0
  261. move.w $dff00a,d0 ;mouse port
  262. move.w d0,d1
  263. andi.w #$00ff,d1
  264. move.w last_mousex,d3
  265. sub.w d1,d3
  266. cmp.w #127,d3
  267. blt.s test_under
  268. add.w #-255,d3
  269. bra.s add_to_scrollx
  270. test_under
  271. cmp.w #-127,d3
  272. bgt.s add_to_scrollx
  273. add.w #255,d3
  274. add_to_scrollx
  275. neg.w d3
  276. move.w d3,mousex_inc
  277. test_sp_y
  278. move.w d1,last_mousex
  279. move.w last_mousey,d3
  280. lsr.w #8,d0
  281. sub.w d0,d3
  282. cmp.w #127,d3
  283. blt.s test_under_y
  284. add.w #-255,d3
  285. neg.w d3
  286. bra.s add_to_scrolly
  287. test_under_y
  288. cmp.w #-127,d3
  289. bgt.s add_to_scrolly
  290. add.w #255,d3
  291. add_to_scrolly
  292. neg.w d3
  293. move.w d3,mousey_inc
  294. move_y_value
  295. move.w d0,last_mousey
  296. rts
  297. last_mousey dc.w 0
  298. last_mousex dc.w 0
  299. mousex_inc dc.w 0
  300. mousey_inc dc.w 0
  301. mouse_x dc.w 160
  302. mouse_y dc.w 125
  303. Blank Dc.l 0
  304. Memory_Base dc.l 0
  305. plane1
  306. dc.l 0
  307. plane2
  308. dc.l 0
  309. plane3
  310. dc.l 0
  311. plane4
  312. dc.l 0
  313. buff_plane1
  314. dc.l 0
  315. buff_plane2
  316. dc.l 0
  317. buff_plane3
  318. dc.l 0
  319. buff_plane4
  320. dc.l 0
  321. rsreset
  322. Ring_x rs.w 1
  323. Ring_y rs.w 1
  324. Ring_Size rs.w 1
  325. Ring_Struct_Size rs.w 1
  326. START_RADIUS EQU 20
  327. RADIUS_STEP EQU 10
  328. START_INC EQU 1
  329. NUMBER_OF_RINGS EQU 64
  330. DOTS_PER_RING EQU 31
  331. ANGLE_INC EQU 360/(DOTS_PER_RING-1)
  332. COLOUR_INC EQU NUMBER_OF_RINGS/7
  333. RING_MEMORY_SIZE EQU (DOTS_PER_RING*NUMBER_OF_RINGS*6)
  334. RING_STRUCTS_SIZE EQU NUMBER_OF_RINGS*6
  335. RING_PTR_SIZE EQU (NUMBER_OF_RINGS+1)*4 ;// extra one for terminator
  336. RING_LIST_SIZE EQU NUMBER_OF_RINGS*4
  337. RING_DEL_SIZE EQU NUMBER_OF_RINGS*DOTS_PER_RING*4*3
  338. RINGS_TOTAL_MEMORY EQU RING_MEMORY_SIZE+RING_STRUCTS_SIZE+RING_PTR_SIZE+RING_LIST_SIZE+RING_DEL_SIZE*2
  339. ********************************************************
  340. ***** TUBE SET UP ****
  341. ********************************************************
  342. Tube_Set_Up
  343. bsr Allocate_Memory_For_Rings
  344. tst.l d0
  345. beq.s Quit_Tube_Set_Up
  346. bsr Create_Rings
  347. move.w #NUMBER_OF_RINGS-1,d0
  348. move.l Ring_Ptrs,a0
  349. move.l Ring_Structs,a1
  350. Set_Up_Ring_Ptrs
  351. move.l a1,(a0)+
  352. add.l #Ring_Struct_Size,a1
  353. dbra d0,Set_Up_Ring_Ptrs
  354. move.l #$ffffffff,-4(a0)
  355. move.l Ring_List,a0
  356. move.l a0,Current_List_Ptr
  357. move.l #$ffffffff,(a0) ;term list ptr
  358. move.l Ring_Del_List,a0
  359. move.l a0,End_Del_List
  360. move.l #$ffffffff,(a0) ;term list
  361. move.l Ring_Del_List_Buff,a0
  362. move.l a0,End_Del_List_Buff
  363. move.l #$ffffffff,(a0) ;term list
  364. Quit_Tube_Set_Up
  365. rts
  366. ********************************************************
  367. ***** TUBE QUIT ****
  368. ********************************************************
  369. Tube_Quit
  370. move.l exec,a6
  371. move.l #RINGS_TOTAL_MEMORY,d0
  372. move.l Ring_Memory,a1
  373. jsr -210(a6)
  374. rts
  375. ********************************************************
  376. ***** ALLOCATE MEMORY FOR RINGS ****
  377. ********************************************************
  378. Allocate_Memory_For_Rings
  379. move.l EXEC,a6
  380. move.l #RINGS_TOTAL_MEMORY,d0 ;
  381. move.l #1<<1+1<<16,d1 ;chip and clear
  382. jsr -198(a6) ;try
  383. tst.l d0 ;memory alloca
  384. beq.s could_not_allocate_rings
  385. move.l d0,Ring_Memory
  386. add.l #RING_MEMORY_SIZE,d0
  387. move.l d0,Ring_Structs
  388. add.l #RING_STRUCTS_SIZE,d0
  389. move.l d0,Ring_Ptrs
  390. add.l #RING_PTR_SIZE,d0
  391. move.l d0,Ring_List
  392. add.l #RING_LIST_SIZE,d0
  393. move.l d0,Ring_Del_List
  394. move.l d0,End_Del_List
  395. add.l #RING_DEL_SIZE,d0
  396. move.l d0,Ring_Del_List_Buff
  397. could_not_allocate_rings
  398. rts
  399. ********************************************************
  400. ***** CREATE RINGS ****
  401. ********************************************************
  402. Create_Rings
  403. move.l Ring_Memory,a0
  404. move.l #cosradtable,a1
  405. move.l #sinradtable,a2
  406. move.w #START_RADIUS,init_rad
  407. clr.l d3
  408. move.w #START_RADIUS,d7
  409. clr.w d6
  410. clr.w Col_Counter
  411. clr.w Current_Col
  412. move.w #NUMBER_OF_RINGS-1,d0
  413. Create_Rings_Loop
  414. move.w #80,Last_y
  415. move.w #160,Last_x
  416. clr.w d1
  417. move.w #DOTS_PER_RING-1,d2
  418. Create_Ring_Points
  419. move.w d1,d3
  420. asl d3
  421. move.w (a1,d3),d4
  422. move.w (a2,d3),d5
  423. muls d7,d4
  424. muls d7,d5
  425. asr.l #8,d4
  426. asr.l #2,d4
  427. asr.l #8,d5
  428. asr.l #2,d5
  429. add.w #160,d4
  430. add.w #80,d5
  431. movem.l d7,-(sp)
  432. clr.l d6
  433. clr.l d7
  434. move.w Last_X,d6
  435. move.w Last_Y,d7
  436. move.w d4,Last_X
  437. move.w d5,Last_Y
  438. sub.w d6,d4
  439. sub.w d7,d5
  440. muls #BPR,d5 ;num lines diff
  441. move.w d4,d6
  442. asr.w #3,d4
  443. ext.l d4
  444. add.l d5,d4
  445. move.l d4,2(a0)
  446. andi.w #$7,d6 ;remainder diff
  447. move.w d6,(a0)
  448. movem.l (sp)+,d7
  449. addq.l #6,a0
  450. add.w #ANGLE_INC,d1
  451. cmp.w #360,d1
  452. blt.s not_lapped
  453. sub.w #360,d1
  454. not_lapped
  455. dbra d2,Create_Ring_Points
  456. clr.l d5
  457. move.l #Ring_Routine_Table,a3
  458. move.w Current_Col,d5
  459. lsl #2,d5
  460. move.l (a3,d5.l),(-DOTS_PER_RING*6)+2(a0)
  461. move.w d7,-DOTS_PER_RING*6(a0)
  462. addq.w #1,Col_Counter
  463. cmp.w #COLOUR_INC,Col_Counter
  464. bne.s Dont_Change_Colour
  465. clr.w Col_Counter
  466. addq.w #1,Current_Col
  467. Dont_Change_Colour
  468. addq.w #1,rad_step
  469. cmp.w #RADIUS_STEP,rad_step
  470. bne.s dont_inc_rad
  471. addq.w #1,rad_inc
  472. clr.w rad_step
  473. dont_inc_rad
  474. add.w rad_inc,d7
  475. dbra d0,Create_Rings_Loop
  476. rts
  477. current_col
  478. dc.w 0
  479. col_counter
  480. dc.w 0
  481. init_rad
  482. dc.w 0
  483. last_x
  484. dc.w 0
  485. last_y
  486. dc.w 0
  487. rad_step
  488. dc.w 0
  489. rad_inc dc.w START_INC
  490. ********************************************************
  491. ***** ADD NEW RING ****
  492. ********************************************************
  493. Add_New_Ring
  494. move.l Ring_Ptrs,a0
  495. cmp.l #$ffffffff,(a0)
  496. beq.s Cant_Add_New_Ring
  497. move.l Current_List_Ptr,a2
  498. move.l (a0)+,a1
  499. move.w Mouse_X,Ring_X(a1)
  500. move.w Mouse_Y,Ring_Y(a1)
  501. clr.w Ring_Size(a1)
  502. move.l a1,(a2)+
  503. move.l a2,Current_List_Ptr
  504. move.l #$ffffffff,(a2) ;term list
  505. move.l a0,Ring_Ptrs
  506. Cant_Add_New_Ring
  507. rts
  508. ********************************************************
  509. ***** DRAW RING ****
  510. ********************************************************
  511. Draw_Ring
  512. *send ring size in d0
  513. *send initial x,y in d4,d5
  514. move.l Ring_Memory,a5
  515. mulu #DOTS_PER_RING*6,d3
  516. add.l d3,a5
  517. add.w (a5)+,d0
  518. lsl.l #6,d1 ;get y down screen
  519. move.w d0,d2 ;make copy of x-coord
  520. asr.w #3,d0 ;get bytes in x
  521. add.w d0,d1 ;add x in to linear value
  522. and.w #%111,d2 ;get remainder
  523. neg.w d2 ;make value negative
  524. add.w #7,d2 ;reverse number
  525. move.w #(DOTS_PER_RING/2)-1,d7 ;set up loop
  526. move.l (a5)+,a6
  527. jsr (a6) ;jump to draw routine
  528. rts
  529. Draw_Ring_Col1
  530. move.l plane1,a0 ;get address of plane1
  531. add.l d1,a0
  532. bset.b d2,(a0) ;draw initial pixel
  533. move.l a0,(a3)+
  534. Draw_Ring_Loop
  535. move.w (a5)+,d0 ;remainder value
  536. add.l (a5)+,a0
  537. sub.w d0,d2
  538. bge.s Draw_In_Pixel
  539. addq.l #1,a0
  540. addq.w #8,d2
  541. Draw_In_Pixel
  542. move.l a0,(a3)+ ;ring del list
  543. bset.b d2,(a0)
  544. move.w (a5)+,d0 ;remainder value
  545. add.l (a5)+,a0
  546. sub.w d0,d2
  547. bge.s Second_Draw_In_Pixel
  548. Second_increment_mem
  549. addq.l #1,a0
  550. addq.w #8,d2
  551. Second_Draw_In_Pixel
  552. move.l a0,(a3)+ ;ring del list
  553. bset.b d2,(a0)
  554. dbra d7,Draw_Ring_Loop
  555. rts
  556. Draw_Ring_Col2
  557. move.l plane2,a0 ;get address of plane1
  558. add.l d1,a0
  559. bset.b d2,(a0) ;draw initial pixel
  560. move.l a0,(a3)+
  561. Draw_Ring_Loop2
  562. move.w (a5)+,d0 ;remainder value
  563. add.l (a5)+,a0
  564. sub.w d0,d2
  565. bge.s Draw_In_Pixel2
  566. addq.l #1,a0
  567. addq.w #8,d2
  568. Draw_In_Pixel2
  569. move.l a0,(a3)+ ;ring del list
  570. bset.b d2,(a0)
  571. move.w (a5)+,d0 ;remainder value
  572. add.l (a5)+,a0
  573. sub.w d0,d2
  574. bge.s Second_Draw_In_Pixel2
  575. addq.l #1,a0
  576. addq.w #8,d2
  577. Second_Draw_In_Pixel2
  578. move.l a0,(a3)+ ;ring del list
  579. bset.b d2,(a0)
  580. dbra d7,Draw_Ring_Loop2
  581. rts
  582. Draw_Ring_Col3
  583. move.l plane1,a0 ;get address of plane1
  584. move.l a0,a1 ;temp
  585. move.l plane2,a6
  586. add.l d1,a0
  587. cmp.l a1,a0
  588. blt.s Draw_Ring_Loop3
  589. cmp.l a6,a0
  590. bge.s Draw_Ring_Loop3
  591. bset.b d2,(a0) ;draw initial pixel
  592. bset.b d2,BPR*256(a0)
  593. move.l a0,(a3)+
  594. move.l a0,(a3) ;not fastest way!!!
  595. add.l #BPR*256,(a3)+
  596. Draw_Ring_Loop3
  597. move.w (a5)+,d0 ;remainder value
  598. add.l (a5)+,a0
  599. sub.w d0,d2
  600. bge.s Draw_In_Pixel3
  601. addq.l #1,a0
  602. addq.w #8,d2
  603. Draw_In_Pixel3
  604. cmp.l a1,a0
  605. blt.s Dont_Dr_Point3
  606. cmp.l a6,a0
  607. bge.s Dont_Dr_Point3
  608. move.l a0,(a3)+ ;ring del list
  609. move.l a0,(a3) ;not fastest way!!!
  610. add.l #BPR*256,(a3)+
  611. bset.b d2,(a0)
  612. bset.b d2,BPR*256(a0)
  613. Dont_Dr_Point3
  614. move.w (a5)+,d0 ;remainder value
  615. add.l (a5)+,a0
  616. sub.w d0,d2
  617. bge.s Second_Draw_In_Pixel3
  618. addq.l #1,a0
  619. addq.w #8,d2
  620. Second_Draw_In_Pixel3
  621. cmp.l a1,a0
  622. blt.s Second_Dont_Dr_Point3
  623. cmp.l a6,a0
  624. bge.s Second_Dont_Dr_Point3
  625. move.l a0,(a3)+ ;ring del list
  626. move.l a0,(a3) ;not fastest way!!!
  627. add.l #BPR*256,(a3)+
  628. bset.b d2,(a0)
  629. bset.b d2,BPR*256(a0)
  630. Second_Dont_Dr_Point3
  631. dbra d7,Draw_Ring_Loop3
  632. rts
  633. Draw_Ring_Col4
  634. move.l plane3,a0 ;get address of plane1
  635. move.l a0,a1 ;temp
  636. move.l plane4,a6
  637. add.l d1,a0
  638. cmp.l a1,a0
  639. blt.s Draw_Ring_Loop4
  640. cmp.l a6,a0
  641. bge.s Draw_Ring_Loop4
  642. bset.b d2,(a0) ;draw initial pixel
  643. move.l a0,(a3)+
  644. Draw_Ring_Loop4
  645. move.w (a5)+,d0 ;remainder value
  646. add.l (a5)+,a0
  647. sub.w d0,d2
  648. bge.s Draw_In_Pixel4
  649. addq.l #1,a0
  650. addq.w #8,d2
  651. Draw_In_Pixel4
  652. cmp.l a1,a0
  653. blt.s Dont_Dr_Point4
  654. cmp.l a6,a0
  655. bge.s Dont_Dr_Point4
  656. move.l a0,(a3)+ ;ring del list
  657. bset.b d2,(a0)
  658. Dont_Dr_Point4
  659. move.w (a5)+,d0 ;remainder value
  660. add.l (a5)+,a0
  661. sub.w d0,d2
  662. bge.s Second_Draw_In_Pixel4
  663. addq.l #1,a0
  664. addq.w #8,d2
  665. Second_Draw_In_Pixel4
  666. cmp.l a1,a0
  667. blt.s Second_Dont_Dr_Point4
  668. cmp.l a6,a0
  669. bge.s Second_Dont_Dr_Point4
  670. move.l a0,(a3)+ ;ring del list
  671. bset.b d2,(a0)
  672. Second_Dont_Dr_Point4
  673. dbra d7,Draw_Ring_Loop4
  674. rts
  675. Draw_Ring_Col5
  676. move.l plane1,a0 ;get address of plane1
  677. move.l a0,a1 ;temp
  678. add.l d1,a0
  679. cmp.l a1,a0
  680. blt.s Draw_Ring_Loop5
  681. cmp.l plane2,a0
  682. bge.s Draw_Ring_Loop5
  683. bset.b d2,(a0) ;draw initial pixel
  684. move.l a0,(a3)+
  685. move.l a0,a6
  686. add.l #BPR*256*2,a6
  687. move.l a6,(a3)+
  688. bset.b d2,(a6)
  689. Draw_Ring_Loop5
  690. move.w (a5)+,d0 ;remainder value
  691. add.l (a5)+,a0
  692. sub.w d0,d2
  693. bge.s Draw_In_Pixel5
  694. addq.l #1,a0
  695. addq.w #8,d2
  696. Draw_In_Pixel5
  697. cmp.l a1,a0
  698. blt.s Dont_Dr_Point5
  699. cmp.l plane2,a0
  700. bge.s Dont_Dr_Point5
  701. move.l a0,(a3)+ ;ring del list
  702. move.l a0,a6
  703. add.l #BPR*256*2,a6
  704. move.l a6,(a3)+
  705. bset.b d2,(a0)
  706. bset.b d2,(a6)
  707. Dont_Dr_Point5
  708. move.w (a5)+,d0 ;remainder value
  709. add.l (a5)+,a0
  710. sub.w d0,d2
  711. bge.s Second_Draw_In_Pixel5
  712. addq.l #1,a0
  713. addq.w #8,d2
  714. Second_Draw_In_Pixel5
  715. cmp.l a1,a0
  716. blt.s Second_Dont_Dr_Point5
  717. cmp.l plane2,a0
  718. bge.s Second_Dont_Dr_Point5
  719. move.l a0,(a3)+ ;ring del list
  720. move.l a0,a6
  721. add.l #BPR*256*2,a6
  722. move.l a6,(a3)+
  723. bset.b d2,(a0)
  724. bset.b d2,(a6)
  725. Second_Dont_Dr_Point5
  726. dbra d7,Draw_Ring_Loop5
  727. rts
  728. Draw_Ring_Col6
  729. move.l plane2,a0 ;get address of plane1
  730. move.l a0,a1 ;temp
  731. move.l plane3,a6
  732. add.l d1,a0
  733. cmp.l a1,a0
  734. blt.s Draw_Ring_Loop6
  735. cmp.l a6,a0
  736. bge.s Draw_Ring_Loop6
  737. bset.b d2,(a0) ;draw initial pixel
  738. bset.b d2,BPR*256(a0)
  739. move.l a0,(a3)+
  740. move.l a0,(a3) ;not fastest way!!!
  741. add.l #BPR*256,(a3)+
  742. Draw_Ring_Loop6
  743. move.w (a5)+,d0 ;remainder value
  744. add.l (a5)+,a0
  745. sub.w d0,d2
  746. bge.s Draw_In_Pixel6
  747. addq.l #1,a0
  748. addq.w #8,d2
  749. Draw_In_Pixel6
  750. cmp.l a1,a0
  751. blt.s Dont_Dr_Point6
  752. cmp.l a6,a0
  753. bge.s Dont_Dr_Point6
  754. move.l a0,(a3)+ ;ring del list
  755. move.l a0,(a3) ;not fastest way!!!
  756. add.l #BPR*256,(a3)+
  757. bset.b d2,(a0)
  758. bset.b d2,BPR*256(a0)
  759. Dont_Dr_Point6
  760. move.w (a5)+,d0 ;remainder value
  761. add.l (a5)+,a0
  762. sub.w d0,d2
  763. bge.s Second_Draw_In_Pixel6
  764. addq.l #1,a0
  765. addq.w #8,d2
  766. Second_Draw_In_Pixel6
  767. cmp.l a1,a0
  768. blt.s Second_Dont_Dr_Point6
  769. cmp.l a6,a0
  770. bge.s Second_Dont_Dr_Point6
  771. move.l a0,(a3)+ ;ring del list
  772. move.l a0,(a3) ;not fastest way!!!
  773. add.l #BPR*256,(a3)+
  774. bset.b d2,(a0)
  775. bset.b d2,BPR*256(a0)
  776. Second_Dont_Dr_Point6
  777. dbra d7,Draw_Ring_Loop6
  778. rts
  779. Ring_Routine_Table
  780. dc.l Draw_Ring_Col1
  781. dc.l Draw_Ring_Col2
  782. dc.l Draw_Ring_Col3
  783. dc.l Draw_Ring_Col4
  784. dc.l Draw_Ring_Col5
  785. dc.l Draw_Ring_Col6
  786. dc.l Draw_Ring_Col6
  787. dc.l Draw_Ring_Col6
  788. ********************************************************
  789. ***** DRAW RINGS ****
  790. ********************************************************
  791. Draw_Rings
  792. move.l a6,-(sp)
  793. move.l Ring_List,a4
  794. move.l a4,a2
  795. move.l Ring_Del_List,a3
  796. Draw_Rings_Loop
  797. cmp.l #$ffffffff,(a4)
  798. beq.s Quit_Draw_Rings
  799. move.l (a4),a5
  800. move.w Ring_X(a5),d0 ;initial x
  801. move.w Ring_Y(a5),d1 ;initial y
  802. move.w Ring_Size(a5),d3 ;size
  803. cmp.w #NUMBER_OF_RINGS-2,d3
  804. bge.s Remove_Ring_From_List
  805. addq.w #1,Ring_Size(a5)
  806. move.l (a4)+,(a2)+
  807. bsr Draw_Ring
  808. bra.s Draw_Rings_Loop
  809. Remove_Ring_From_List
  810. move.l Ring_Ptrs,a0
  811. move.l a5,-(a0)
  812. move.l a0,Ring_Ptrs
  813. addq.l #4,a4
  814. bra.s Draw_Rings_Loop
  815. Quit_Draw_Rings
  816. move.l #$ffffffff,(a2) ;term current list
  817. move.l #$ffffffff,(a3) ;term del list
  818. move.l a3,End_Del_List
  819. move.l a2,Current_List_Ptr
  820. move.l (sp)+,a6
  821. rts
  822. **************************************
  823. *** SWAP RING BUFFERS ***
  824. **************************************
  825. Swap_Ring_Buffers
  826. move.l Ring_Del_List,d0
  827. move.l Ring_Del_List_Buff,Ring_Del_List
  828. move.l d0,Ring_Del_List_Buff
  829. move.l End_Del_List,d0
  830. move.l End_Del_List_Buff,End_Del_List
  831. move.l d0,End_Del_List_Buff
  832. rts
  833. *********************************************
  834. *** CLEAR PIXELS ****
  835. *********************************************
  836. Clear_Pixels
  837. move.l Ring_Del_List,a3
  838. move.l End_Del_List,d0
  839. sub.l a3,d0
  840. tst.l d0
  841. beq Skip_Remainder
  842. lsr.w #6,d0 ;div by 4 and then by 16
  843. subq.w #1,d0
  844. Clear_Loop
  845. move.l (a3)+,a0
  846. clr.b (a0)
  847. move.l (a3)+,a0
  848. clr.b (a0)
  849. move.l (a3)+,a0
  850. clr.b (a0)
  851. move.l (a3)+,a0
  852. clr.b (a0)
  853. move.l (a3)+,a0
  854. clr.b (a0)
  855. move.l (a3)+,a0
  856. clr.b (a0)
  857. move.l (a3)+,a0
  858. clr.b (a0)
  859. move.l (a3)+,a0
  860. clr.b (a0)
  861. move.l (a3)+,a0
  862. clr.b (a0)
  863. move.l (a3)+,a0
  864. clr.b (a0)
  865. move.l (a3)+,a0
  866. clr.b (a0)
  867. move.l (a3)+,a0
  868. clr.b (a0)
  869. move.l (a3)+,a0
  870. clr.b (a0)
  871. move.l (a3)+,a0
  872. clr.b (a0)
  873. move.l (a3)+,a0
  874. clr.b (a0)
  875. move.l (a3)+,a0
  876. clr.b (a0)
  877. dbra d0,Clear_Loop
  878. Remainder_Loop
  879. cmp.l #$ffffffff,(a3)
  880. beq.s Skip_Remainder
  881. move.l (a3)+,a0
  882. clr.b (a0)
  883. bra.s Remainder_Loop
  884. Skip_Remainder
  885. rts
  886. End_Del_List
  887. dc.l 0
  888. End_Del_List_Buff
  889. dc.l 0
  890. Ring_Memory
  891. dc.l 0
  892. Ring_Structs
  893. dc.l 0
  894. Ring_Ptrs
  895. dc.l 0
  896. Ring_List
  897. dc.l 0
  898. Current_List_Ptr
  899. dc.l 0
  900. Ring_Del_List
  901. dc.l 0
  902. Ring_Del_List_Buff
  903. dc.l 0
  904. Add_Count dc.w 0
  905. sinradtable
  906. DC.W 17,35,53,71,89,107,124,142,160,177
  907. DC.W 195,212,230,247,265,282,299,316,333,350
  908. DC.W 366,383,400,416,432,448,464,480,496,511
  909. DC.W 527,542,557,572,587,601,616,630,644,658
  910. DC.W 671,685,698,711,724,736,748,760,772,784
  911. DC.W 795,806,817,828,838,848,858,868,877,886
  912. DC.W 895,904,912,920,928,935,942,949,955,962
  913. DC.W 968,973,979,984,989,993,997,1001,1005,1008
  914. DC.W 1011,1014,1016,1018,1020,1021,1022,1023,1023,1024
  915. DC.W 1023,1023,1022,1021,1020,1018,1016,1014,1011,1008
  916. DC.W 1005,1001,997,993,989,984,979,973,968,962
  917. DC.W 955,949,942,935,928,920,912,904,895,886
  918. DC.W 877,868,858,848,838,828,817,806,795,784
  919. DC.W 772,760,748,736,724,711,698,685,671,658
  920. DC.W 644,630,616,601,587,572,557,542,527,512
  921. DC.W 496,480,464,448,432,416,400,383,366,350
  922. DC.W 333,316,299,282,265,247,230,212,195,177
  923. DC.W 160,142,124,107,89,71,53,35,17,0
  924. DC.W -18,-36,-54,-72,-90,-108,-125,-143,-161,-178
  925. DC.W -196,-213,-231,-248,-266,-283,-300,-317,-334,-351
  926. DC.W -367,-384,-401,-417,-433,-449,-465,-481,-497,-512
  927. DC.W -528,-543,-558,-573,-588,-602,-617,-631,-645,-659
  928. DC.W -672,-686,-699,-712,-725,-737,-749,-761,-773,-785
  929. DC.W -796,-807,-818,-829,-839,-849,-859,-869,-878,-887
  930. DC.W -896,-905,-913,-921,-929,-936,-943,-950,-956,-963
  931. DC.W -969,-974,-980,-985,-990,-994,-998,-1002,-1006,-1009
  932. DC.W -1012,-1015,-1017,-1019,-1021,-1022,-1023,-1024,-1024,-1025
  933. DC.W -1024,-1024,-1023,-1022,-1021,-1019,-1017,-1015,-1012,-1009
  934. DC.W -1006,-1002,-998,-994,-990,-985,-980,-974,-969,-963
  935. DC.W -956,-950,-943,-936,-929,-921,-913,-905,-896,-887
  936. DC.W -878,-869,-859,-849,-839,-829,-818,-807,-796,-785
  937. DC.W -773,-761,-749,-737,-725,-712,-699,-686,-672,-659
  938. DC.W -645,-631,-617,-602,-588,-573,-558,-543,-528,-513
  939. DC.W -497,-481,-465,-449,-433,-417,-401,-384,-367,-351
  940. DC.W -334,-317,-300,-283,-266,-248,-231,-213,-196,-178
  941. DC.W -161,-143,-125,-108,-90,-72,-54,-36,-18,0
  942. cosradtable
  943. DC.W 1023,1023,1022,1021,1020,1018,1016,1014,1011,1008
  944. DC.W 1005,1001,997,993,989,984,979,973,968,962
  945. DC.W 955,949,942,935,928,920,912,904,895,886
  946. DC.W 877,868,858,848,838,828,817,806,795,784
  947. DC.W 772,760,748,736,724,711,698,685,671,658
  948. DC.W 644,630,616,601,587,572,557,542,527,511
  949. DC.W 496,480,464,448,432,416,400,383,366,350
  950. DC.W 333,316,299,282,265,247,230,212,195,177
  951. DC.W 160,142,124,107,89,71,53,35,17,0
  952. DC.W -18,-36,-54,-72,-90,-108,-125,-143,-161,-178
  953. DC.W -196,-213,-231,-248,-266,-283,-300,-317,-334,-351
  954. DC.W -367,-384,-401,-417,-433,-449,-465,-481,-497,-513
  955. DC.W -528,-543,-558,-573,-588,-602,-617,-631,-645,-659
  956. DC.W -672,-686,-699,-712,-725,-737,-749,-761,-773,-785
  957. DC.W -796,-807,-818,-829,-839,-849,-859,-869,-878,-887
  958. DC.W -896,-905,-913,-921,-929,-936,-943,-950,-956,-963
  959. DC.W -969,-974,-980,-985,-990,-994,-998,-1002,-1006,-1009
  960. DC.W -1012,-1015,-1017,-1019,-1021,-1022,-1023,-1024,-1024,-1025
  961. DC.W -1024,-1024,-1023,-1022,-1021,-1019,-1017,-1015,-1012,-1009
  962. DC.W -1006,-1002,-998,-994,-990,-985,-980,-974,-969,-963
  963. DC.W -956,-950,-943,-936,-929,-921,-913,-905,-896,-887
  964. DC.W -878,-869,-859,-849,-839,-829,-818,-807,-796,-785
  965. DC.W -773,-761,-749,-737,-725,-712,-699,-686,-672,-659
  966. DC.W -645,-631,-617,-602,-588,-573,-558,-543,-528,-512
  967. DC.W -497,-481,-465,-449,-433,-417,-401,-384,-367,-351
  968. DC.W -334,-317,-300,-283,-266,-248,-231,-213,-196,-178
  969. DC.W -161,-143,-125,-108,-90,-72,-54,-36,-18,0
  970. DC.W 17,35,53,71,89,107,124,142,160,177
  971. DC.W 195,212,230,247,265,282,299,316,333,350
  972. DC.W 366,383,400,416,432,448,464,480,496,511
  973. DC.W 527,542,557,572,587,601,616,630,644,658
  974. DC.W 671,685,698,711,724,736,748,760,772,784
  975. DC.W 795,806,817,828,838,848,858,868,877,886
  976. DC.W 895,904,912,920,928,935,942,949,955,962
  977. DC.W 968,973,979,984,989,993,997,1001,1005,1008
  978. DC.W 1011,1014,1016,1018,1020,1021,1022,1023,1023,1024
  979. ENDSINRAD
  980. COPPERL
  981. dc.w bplcono
  982. dc.w $4200
  983. dc.w $102 ; scrolly bit
  984. dc.w $000
  985. dc.w DDFSTRT
  986. dc.w $0038
  987. dc.w DDFSTOP
  988. dc.w $00d0
  989. dc.w bpl1mod
  990. dc.w 64-40
  991. dc.w bpl2mod
  992. dc.w 64-40
  993. dc.w $1e4
  994. dc.w $2100
  995. dc.w $1fc
  996. dc.w $0
  997. dc.w $106,0
  998. copper_colours
  999. ds.w 16*2
  1000. ************sprites
  1001. dc.w $120 ;all sprite stuff
  1002. sprite0h dc.w $0
  1003. dc.w $122
  1004. sprite0l dc.w 0
  1005. dc.w $124
  1006. sprite1h dc.w $0
  1007. dc.w $126
  1008. sprite1l dc.w 0
  1009. dc.w $128
  1010. sprite2h dc.w $0
  1011. dc.w $12a
  1012. sprite2l dc.w 0
  1013. dc.w $12c
  1014. sprite3h dc.w $0
  1015. dc.w $12e
  1016. sprite3l dc.w 0
  1017. dc.w $130
  1018. sprite4h dc.w $0
  1019. dc.w $132
  1020. sprite4l dc.w 0
  1021. dc.w $134
  1022. sprite5h dc.w $0
  1023. dc.w $136
  1024. sprite5l dc.w 0
  1025. dc.w $138
  1026. sprite6h dc.w $0
  1027. dc.w $13a
  1028. sprite6l dc.w 0
  1029. dc.w $13c
  1030. sprite7h dc.w $0
  1031. dc.w $13e
  1032. sprite7l dc.w 0
  1033. DC.W $00E0
  1034. Plane1_Hi DC.W 0
  1035. DC.W $00E2
  1036. Plane1_Lo DC.W 0
  1037. DC.W $00E4
  1038. Plane2_Hi DC.W 0
  1039. DC.W $00E6
  1040. Plane2_Lo DC.W 0
  1041. DC.W $00E8
  1042. Plane3_Hi DC.W 0
  1043. DC.W $00Ea
  1044. Plane3_Lo DC.W 0
  1045. DC.W $00Ec
  1046. Plane4_Hi DC.W 0
  1047. DC.W $00Ee
  1048. Plane4_Lo DC.W 0
  1049. dc.w $ffdf,$fffe
  1050. dc.w $2c01,$fffe
  1051. dc.w intreq
  1052. dc.w $8010
  1053. DC.W $2cff,$FFFE