vel.s 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. section Generic,Code_C
  2. OPT C-,D+
  3. opt p=68020
  4. BPR EQU 40
  5. GRAPHICS_MOD EQU 0
  6. XSIZE EQU 4
  7. YSIZE EQU 36
  8. XDEST EQU 42
  9. YDEST EQU 164
  10. SCROLL_WIDTH EQU 27
  11. NOP EQU 18
  12. NOC EQU 0
  13. CUSTOM EQU $DFF000 ;start of amiga custom hardware
  14. BPLCONO EQU $100
  15. BPLCON1 EQU $102
  16. BPLCON2 EQU $104
  17. BPL1MOD EQU $108
  18. DDFSTRT EQU $092
  19. DDFSTOP EQU $094
  20. DIWSTRT EQU $08E
  21. DIWSTOP EQU $090
  22. VPSOR EQU $004
  23. COLOUR0 EQU $180
  24. COLOUR1 EQU $182
  25. COLOUR2 EQU $184
  26. COLOUR3 EQU $186
  27. DMACON EQU $096
  28. COP1LCH EQU $080
  29. COPJMP1 EQU $088
  30. DMAF_BLITTER EQU $0040
  31. DMAF_BLTDONE EQU $4000
  32. DMAF_BLTNZERO EQU $2000
  33. DMAB_BLTDONE EQU 14
  34. bltddat EQU $000
  35. dmaconr EQU $002
  36. vposr EQU $004
  37. vhposr EQU $006
  38. dskdatr EQU $008
  39. joy0dat EQU $00A
  40. joy1dat EQU $00C
  41. clxdat EQU $00E
  42. bltcon0 EQU $040
  43. bltcon1 EQU $042
  44. bltafwm EQU $044
  45. bltalwm EQU $046
  46. bltcpt EQU $048
  47. bltbpt EQU $04C
  48. bltapt EQU $050
  49. bltdpt EQU $054
  50. bltsize EQU $058
  51. bltcmod EQU $060
  52. bltbmod EQU $062
  53. bltamod EQU $064
  54. bltdmod EQU $066
  55. bltcdat EQU $070
  56. bltbdat EQU $072
  57. bltadat EQU $074
  58. dsksync EQU $07E
  59. cop1lc EQU $080
  60. cop2lc EQU $084
  61. bpl2mod EQU $10A
  62. bpldat EQU $110
  63. intreq EQU $09c
  64. intreqr EQU $01e
  65. start:
  66. bsr Turn_Off_Tasking
  67. bsr Allocate_Plane_Memory
  68. tst.l d0
  69. bne.s Memory_Successfully_Allocated
  70. rts ;quit out if error
  71. Memory_Successfully_Allocated
  72. bsr Setup
  73. bsr Main_Demo
  74. bsr Quit_Out
  75. rts
  76. QUIT_OUT
  77. MOVE.L 4,A6
  78. JSR -138(A6) ;ENABLE tasking
  79. move.l 4,a6
  80. move.l #(256*BPR)*8,d0
  81. move.l Memory_Base,a1
  82. jsr -210(a6)
  83. MOVE.L #graf_NAME,A1
  84. MOVEQ #0,D0
  85. JSR -552(A6) ;OPEN GRAPHICS LIBRARY
  86. MOVE.L D0,a4
  87. MOVE.W #$8020,DMACON+$dff000 ; sprites back
  88. move.l 38(a4),$dff080
  89. clr.w $dff088
  90. rts
  91. graf_NAME dc.b "graphics.library",0
  92. even
  93. ********************************
  94. *** SET UP ***
  95. ********************************
  96. setup
  97. bsr Setup_Colours
  98. LEA CUSTOM,A6
  99. MOVE.W #0,BPLCON1(A6)
  100. move.w #%1000000,BPLCON2(a6)
  101. move.w #$83a0,DMACON(a6)
  102. MOVE.W #$2C81,DIWSTRT(A6)
  103. MOVE.W #$2cC1,DIWSTOP(A6)
  104. MOVE.L #COPPERL,COP1LCH(A6)
  105. clr.w COPJMP1(A6)
  106. rts
  107. ********************************************
  108. **** ALLOCATE PLANE MEMORY ***
  109. ********************************************
  110. Allocate_Plane_Memory
  111. move.l 4,a6
  112. move.l #(256*BPR)*8,d0 ;
  113. move.l #1<<1+1<<16,d1 ;chip and clear
  114. jsr -198(a6) ;try
  115. tst.l d0 ;memory allocated?
  116. bne allocated_mem
  117. rts ;otherwise quit
  118. allocated_mem
  119. move.l d0,Memory_Base
  120. move.l d0,Plane1
  121. add.l #(256*BPR),d0
  122. move.l d0,plane2
  123. add.l #(256*BPR),d0
  124. move.l d0,plane3
  125. add.l #(256*BPR),d0
  126. move.l d0,plane4
  127. add.l #(256*BPR),d0
  128. move.l d0,buff_plane1
  129. add.l #(256*BPR),d0
  130. move.l d0,buff_plane2
  131. add.l #(256*BPR),d0
  132. move.l d0,buff_plane3
  133. add.l #(256*BPR),d0
  134. move.l d0,buff_plane4
  135. rts
  136. *************************************
  137. ** TURN OFF TASKING ***
  138. *************************************
  139. Turn_Off_Tasking
  140. move.l 4,a6
  141. jsr -132(A6) ;DISABLE tasking
  142. rts
  143. ************************************
  144. *** SET UP COLOURS ***
  145. ************************************
  146. Setup_Colours
  147. move.w #$180,d0
  148. move.l #copper_colours,a0
  149. move.l #col_list,a1
  150. move.w #16-1,d1
  151. col_loop
  152. move.w d0,(a0)+
  153. move.w (a1)+,(a0)+
  154. add.w #$2,d0
  155. dbra d1,col_loop
  156. move.w #$182,copper_colours
  157. rts
  158. col_list
  159. dc.w $000,$fff,$0f0,$00f,$ff0,$0ff,$f0f
  160. dc.w $fff,$77f,$707,$f77,$f7f,$7ff,$777
  161. dc.w $707,$070
  162. ************************************************************
  163. ***** S C R E E N S Y N C **********
  164. ************************************************************
  165. sync
  166. move.l #$dff000,a6
  167. move.w #$0010,intreq(a6)
  168. wait_for_bit
  169. btst.b #4,intreqr+1(a6)
  170. beq.s wait_for_bit
  171. rts
  172. **************************************
  173. *** MAIN DEMO ***
  174. **************************************
  175. Main_Demo
  176. bsr sync
  177. bsr swap_buffers
  178. btst.b #6,$bfe001 ;has user pressed left mouse button
  179. beq.s quit_demo
  180. move.w #$fff,$dff180
  181. move.w #160,d0
  182. move.w #125,d1
  183. move.w mouse_x,d2
  184. move.w mouse_y,d3
  185. move.l plane1,a0
  186. bsr Draw_Slice_Line
  187. bsr GetMousePosition
  188. move.w #160,d0
  189. move.w #125,d1
  190. move.w mouse_x,d2
  191. move.w mouse_y,d3
  192. move.l plane1,a0
  193. bsr Draw_Slice_Line
  194. move.w #$000,$dff180
  195. bra Main_Demo
  196. quit_demo
  197. rts
  198. x_pos dc.w 10
  199. y_pos dc.w 10
  200. counter dc.w 100
  201. **************************************
  202. *** DRAW PIXEL ***
  203. **************************************
  204. Draw_Pixel
  205. *send x and y in d0,d1
  206. mulu #BPR,d1 ;get y down the screen
  207. move.w d0,d2 ;make copy of x-coord
  208. asr.w #3,d0 ;get bytes in x
  209. add.w d0,d1 ;add x in to linear value
  210. and.w #%0000000000000111,d2 ;get remainder
  211. neg.w d2 ;make value negative
  212. add.w #7,d2 ;reverse number
  213. move.l plane1,a0 ;get address of plane1
  214. bset.b d2,(a0,d1.l) ;set value
  215. rts
  216. include "code:develop/slice_line2.s"
  217. x_incy dc.w 0
  218. crap dc.w 0
  219. **************************************
  220. *** CLEAR PIXEL ***
  221. **************************************
  222. Clear_Pixel
  223. *send x and y in d0,d1
  224. mulu #BPR,d1 ;get y down the screen
  225. move.w d0,d2 ;make copy of x-coord
  226. asr.w #3,d0 ;get bytes in x
  227. add.w d0,d1 ;add x in to linear value
  228. and.w #%0000000000000111,d2 ;get remainder
  229. neg.w d2 ;make value negative
  230. add.w #7,d2 ;reverse number
  231. move.l plane1,a0 ;get address of plane1
  232. * add.l d1,a0 ;same as below
  233. * bclr.b d2,(a0)
  234. bclr.b d2,(a0,d1.l) ;set value
  235. rts
  236. **************************************
  237. *** SWAP BUFFERS ***
  238. **************************************
  239. Swap_Buffers
  240. move.l plane1,d0
  241. move.l plane2,d1
  242. move.l plane3,d2
  243. move.l plane4,d3
  244. * move.l buff_plane1,plane1
  245. * move.l buff_plane2,plane2
  246. * move.l buff_plane3,plane3
  247. * move.l buff_plane4,plane4
  248. * move.l d0,buff_plane1
  249. * move.l d1,buff_plane2
  250. * move.l d2,buff_plane3
  251. * move.l d3,buff_plane4
  252. move.w d0,plane1_lo
  253. swap d0
  254. move.w d0,plane1_hi
  255. move.w d1,plane2_lo
  256. swap d1
  257. move.w d1,plane2_hi
  258. move.w d2,plane3_lo
  259. swap d2
  260. move.w d2,plane3_hi
  261. move.w d3,plane4_lo
  262. swap d3
  263. move.w d3,plane4_hi
  264. rts
  265. ************************************************
  266. ***** GET MOUSE POSITION ***
  267. ************************************************
  268. GetMousePosition
  269. bsr ReadMouse
  270. move.w mouse_x,d0
  271. move.w mouse_y,d1
  272. add.w mousex_inc,d0
  273. add.w mousey_inc,d1
  274. move.w d0,mouse_x
  275. move.w d1,mouse_y
  276. rts
  277. ***********************************************
  278. ***** READ MOUSE *****
  279. ************************************************
  280. ReadMouse
  281. *updates mousex_inc and mousey_inc - it is done this way
  282. *for total flexibility as it can be used to scroll the
  283. *screen or move an on screen pointer or be used to increase
  284. *levels volume menu options etc etc
  285. moveq #0,d0
  286. move.w $dff00a,d0 ;mouse port
  287. move.w d0,d1
  288. andi.w #$00ff,d1
  289. move.w last_mousex,d3
  290. sub.w d1,d3
  291. cmp.w #127,d3
  292. blt.s test_under
  293. add.w #-255,d3
  294. bra.s add_to_scrollx
  295. test_under
  296. cmp.w #-127,d3
  297. bgt.s add_to_scrollx
  298. add.w #255,d3
  299. add_to_scrollx
  300. neg.w d3
  301. move.w d3,mousex_inc
  302. test_sp_y
  303. move.w d1,last_mousex
  304. move.w last_mousey,d3
  305. lsr.w #8,d0
  306. sub.w d0,d3
  307. cmp.w #127,d3
  308. blt.s test_under_y
  309. add.w #-255,d3
  310. neg.w d3
  311. bra.s add_to_scrolly
  312. test_under_y
  313. cmp.w #-127,d3
  314. bgt.s add_to_scrolly
  315. add.w #255,d3
  316. add_to_scrolly
  317. neg.w d3
  318. move.w d3,mousey_inc
  319. move_y_value
  320. move.w d0,last_mousey
  321. rts
  322. last_mousey dc.w 0
  323. last_mousex dc.w 0
  324. mousex_inc dc.w 0
  325. mousey_inc dc.w 0
  326. mouse_x dc.w 160
  327. mouse_y dc.w 125
  328. Blank Dc.l 0
  329. Memory_Base dc.l 0
  330. plane1
  331. dc.l 0
  332. plane2
  333. dc.l 0
  334. plane3
  335. dc.l 0
  336. plane4
  337. dc.l 0
  338. buff_plane1
  339. dc.l 0
  340. buff_plane2
  341. dc.l 0
  342. buff_plane3
  343. dc.l 0
  344. buff_plane4
  345. dc.l 0
  346. COPPERL
  347. dc.w bplcono
  348. dc.w $4200
  349. dc.w $102 ; scrolly bit
  350. dc.w $000
  351. dc.w DDFSTRT
  352. dc.w $0038
  353. dc.w DDFSTOP
  354. dc.w $00d0
  355. dc.w bpl1mod
  356. dc.w 0
  357. dc.w bpl2mod
  358. dc.w 0
  359. dc.w $1e4
  360. dc.w $2100
  361. dc.w $1fc
  362. dc.w $0
  363. dc.w $106,0
  364. copper_colours
  365. ds.w 16*2
  366. ************sprites
  367. dc.w $120 ;all sprite stuff
  368. sprite0h dc.w $0
  369. dc.w $122
  370. sprite0l dc.w 0
  371. dc.w $124
  372. sprite1h dc.w $0
  373. dc.w $126
  374. sprite1l dc.w 0
  375. dc.w $128
  376. sprite2h dc.w $0
  377. dc.w $12a
  378. sprite2l dc.w 0
  379. dc.w $12c
  380. sprite3h dc.w $0
  381. dc.w $12e
  382. sprite3l dc.w 0
  383. dc.w $130
  384. sprite4h dc.w $0
  385. dc.w $132
  386. sprite4l dc.w 0
  387. dc.w $134
  388. sprite5h dc.w $0
  389. dc.w $136
  390. sprite5l dc.w 0
  391. dc.w $138
  392. sprite6h dc.w $0
  393. dc.w $13a
  394. sprite6l dc.w 0
  395. dc.w $13c
  396. sprite7h dc.w $0
  397. dc.w $13e
  398. sprite7l dc.w 0
  399. DC.W $00E0
  400. Plane1_Hi DC.W 0
  401. DC.W $00E2
  402. Plane1_Lo DC.W 0
  403. DC.W $00E4
  404. Plane2_Hi DC.W 0
  405. DC.W $00E6
  406. Plane2_Lo DC.W 0
  407. DC.W $00E8
  408. Plane3_Hi DC.W 0
  409. DC.W $00Ea
  410. Plane3_Lo DC.W 0
  411. DC.W $00Ec
  412. Plane4_Hi DC.W 0
  413. DC.W $00Ee
  414. Plane4_Lo DC.W 0
  415. dc.w $ffdf,$fffe
  416. dc.w $2c01,$fffe
  417. dc.w intreq
  418. dc.w $8010
  419. DC.W $2cff,$FFFE