tube.s 23 KB

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