exper.s 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. section Generic,Code_C
  2. OPT C-,D+
  3. opt p=68020
  4. BPR EQU 64
  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
  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. MODE_OLDFILE EQU 1005
  66. MODE_NEWFILE EQU 1006
  67. start:
  68. move.l 4,a6
  69. jsr -132(A6) ;DISABLE tasking
  70. move.l 4,a6
  71. move.l #(256*64)*8,d0 ;
  72. move.l #1<<1+1<<16,d1 ;chip and clear
  73. jsr -198(a6) ;try
  74. tst.l d0
  75. bne allocated_mem
  76. rts ;otherwise quit
  77. allocated_mem
  78. move.l d0,Memory_Base
  79. move.l d0,Plane1
  80. add.l #(256*64),d0
  81. move.l d0,plane2
  82. add.l #(256*64),d0
  83. move.l d0,plane3
  84. add.l #(256*64),d0
  85. move.l d0,plane4
  86. add.l #(256*64),d0
  87. move.l d0,buff_plane1
  88. add.l #(256*64),d0
  89. move.l d0,buff_plane2
  90. add.l #(256*64),d0
  91. move.l d0,buff_plane3
  92. add.l #(256*64),d0
  93. move.l d0,buff_plane4
  94. bsr setup
  95. move.w #$0,$dff106
  96. bsr Main_Demo
  97. QUIT_OUT
  98. MOVE.L 4,A6
  99. JSR -138(A6) ;ENABLE tasking
  100. move.l oldint,$6c
  101. move.l 4,a6
  102. move.l #(256*64)*8,d0
  103. move.l Memory_Base,a1
  104. jsr -210(a6)
  105. MOVE.L #graf_NAME,A1
  106. MOVEQ #0,D0
  107. JSR -552(A6) ;OPEN GRAPHICS LIBRARY
  108. MOVE.L D0,a4
  109. MOVE.W #$8020,DMACON+$dff000 ; sprites back
  110. move.l 38(a4),$dff080
  111. clr.w $dff088
  112. move.b #$9b,$bfed01
  113. rts
  114. graf_NAME dc.b "graphics.library",0
  115. even
  116. setup
  117. bsr setup_colours
  118. LEA CUSTOM,A0
  119. MOVE.W #0,BPLCON1(A0)
  120. move.w #%1000000,BPLCON2(a0)
  121. move.w #$83a0,DMACON(a0)
  122. MOVE.W #$2C81,DIWSTRT(A0)
  123. MOVE.W #$2cC1,DIWSTOP(A0)
  124. MOVE.L #COPPERL,COP1LCH(A0)
  125. MOVE.W COPJMP1(A0),D0
  126. move.l $6c,oldint
  127. move.l #darkint,$6c
  128. rts
  129. setup_colours
  130. move.w #$180,d0
  131. move.l #copper_colours,a0
  132. move.l #col_list,a1
  133. move.w #16-1,d1
  134. col_loop
  135. move.w d0,(a0)+
  136. move.w (a1)+,(a0)+
  137. add.w #$2,d0
  138. dbra d1,col_loop
  139. rts
  140. col_list
  141. dc.w $000,$f00,$0f0,$00f,$ff0,$0ff,$f0f
  142. dc.w $fff,$77f,$707,$f77,$f7f,$7ff,$777
  143. dc.w $707,$070
  144. ************************************************************
  145. **** D A R K L I T E I N T E R R U P T ****
  146. ************************************************************
  147. darkint
  148. movem.l d0-d7/a0-a6,-(sp)
  149. movem.l (sp)+,d0-d7/a0-a6
  150. dc.w $4ef9
  151. oldint dc.l 0
  152. mt_data dc.l 0
  153. music_flag dc.b 0
  154. even
  155. play_colours
  156. dc.b 0
  157. even
  158. two_channel_flag dc.b 0
  159. even
  160. ************************************************************
  161. ***** S C R E E N S Y N C **********
  162. ************************************************************
  163. sync
  164. move.l #$dff000,a6
  165. move.w #$0010,intreq(a6)
  166. wait_for_bit
  167. btst.b #4,intreqr+1(a6)
  168. beq.s wait_for_bit
  169. rts
  170. Main_Demo
  171. bsr sync
  172. bsr display_whole_map
  173. bsr swap_buffers
  174. wait btst.b #6,$bfe001
  175. bne.s main_demo
  176. btst.b #10,$dff016
  177. bne.s main_demo
  178. rts
  179. Single_Mouse_Press
  180. btst #6,$BFE001
  181. Bne out
  182. * move.w #$11,jobba
  183. not_released
  184. btst #6,$BFE001
  185. Beq not_released
  186. out
  187. rts
  188. COPPERL
  189. dc.w bplcono
  190. dc.w $4200
  191. dc.w $102 ; scrolly bit
  192. dc.w $000
  193. dc.w DDFSTRT
  194. dc.w $0038
  195. dc.w DDFSTOP
  196. dc.w $00d8
  197. dc.w bpl1mod
  198. dc.w 16
  199. dc.w bpl2mod
  200. dc.w 16
  201. dc.w $1e4
  202. dc.w $2100
  203. dc.w $10c
  204. dc.w $11
  205. dc.w $1fc
  206. dc.w $f
  207. copper_colours
  208. ds.w 16*2
  209. ************sprites
  210. dc.w $120 ;all sprite stuff
  211. sprite0h dc.w $0
  212. dc.w $122
  213. sprite0l dc.w 0
  214. dc.w $124
  215. sprite1h dc.w $0
  216. dc.w $126
  217. sprite1l dc.w 0
  218. dc.w $128
  219. sprite2h dc.w $0
  220. dc.w $12a
  221. sprite2l dc.w 0
  222. dc.w $12c
  223. sprite3h dc.w $0
  224. dc.w $12e
  225. sprite3l dc.w 0
  226. dc.w $130
  227. sprite4h dc.w $0
  228. dc.w $132
  229. sprite4l dc.w 0
  230. dc.w $134
  231. sprite5h dc.w $0
  232. dc.w $136
  233. sprite5l dc.w 0
  234. dc.w $138
  235. sprite6h dc.w $0
  236. dc.w $13a
  237. sprite6l dc.w 0
  238. dc.w $13c
  239. sprite7h dc.w $0
  240. dc.w $13e
  241. sprite7l dc.w 0
  242. DC.W $00E0
  243. Plane1_Hi DC.W 0
  244. DC.W $00E2
  245. Plane1_Lo DC.W 0
  246. DC.W $00E4
  247. Plane2_Hi DC.W 0
  248. DC.W $00E6
  249. Plane2_Lo DC.W 0
  250. DC.W $00E8
  251. Plane3_Hi DC.W 0
  252. DC.W $00Ea
  253. Plane3_Lo DC.W 0
  254. DC.W $00Ec
  255. Plane4_Hi DC.W 0
  256. DC.W $00Ee
  257. Plane4_Lo DC.W 0
  258. dc.w $2c01,$ff00
  259. dc.w intreq
  260. dc.w $8010
  261. DC.W $2cff,$FFFE
  262. ds.w 1000*2
  263. swap_buffers
  264. move.l plane1,d0
  265. move.l plane2,d1
  266. move.l plane3,d2
  267. move.l plane4,d3
  268. move.l buff_plane1,plane1
  269. move.l buff_plane2,plane2
  270. move.l buff_plane3,plane3
  271. move.l buff_plane4,plane4
  272. move.l d0,buff_plane1
  273. move.l d1,buff_plane2
  274. move.l d2,buff_plane3
  275. move.l d3,buff_plane4
  276. move.w d0,plane1_lo
  277. swap d0
  278. move.w d0,plane1_hi
  279. move.w d1,plane2_lo
  280. swap d1
  281. move.w d1,plane2_hi
  282. move.w d2,plane3_lo
  283. swap d2
  284. move.w d2,plane3_hi
  285. move.w d3,plane4_lo
  286. swap d3
  287. move.w d3,plane4_hi
  288. rts
  289. Blank Dc.l 0
  290. Memory_Base dc.l 0
  291. clear_pixel
  292. mulu.w #BPR,d1
  293. add.l d1,a0
  294. move.w d0,d3
  295. lsr.w #3,d0 ; get bytes
  296. andi.b #%111,d3 ; pixel bits
  297. moveq #7,d1
  298. sub.b d3,d1
  299. bclr.b d1,(a0,d0.w) ;
  300. rts
  301. plane1
  302. dc.l 0
  303. plane2
  304. dc.l 0
  305. plane3
  306. dc.l 0
  307. plane4
  308. dc.l 0
  309. buff_plane1
  310. dc.l 0
  311. buff_plane2
  312. dc.l 0
  313. buff_plane3
  314. dc.l 0
  315. buff_plane4
  316. dc.l 0
  317. WHOLE_ACR EQU 6 ;accuracy
  318. ACCURACY EQU 64
  319. crap1 dc.w 11
  320. inc dc.w 4
  321. ******************************************
  322. ***** DISPLAY WHOLE MAP *****
  323. ******************************************
  324. display_whole_map
  325. clear_block_on_screen
  326. btst #14,dmaconr(a6)
  327. bne.s clear_block_on_screen
  328. move.w #BPR-40,bltdmod(a6)
  329. move.w #0,bltadat(a6)
  330. move.l #$ffffffff,bltafwm(a6)
  331. move.l #$01F00000,bltcon0(A6)
  332. move.l plane1,bltdpt(a6) ;screen
  333. move.w #256<<6+20,bltsize(a6) ;1 word by 16 pixels
  334. wait_block_on_screen
  335. btst #14,dmaconr(a6)
  336. bne.s wait_block_on_screen
  337. move.w inc,d0
  338. add.w d0,crap1
  339. cmp.w #10,crap1
  340. bgt.s ok_x
  341. neg.w inc
  342. ok_x
  343. cmp.w #200,crap1
  344. blt.s ok_x2
  345. neg.w inc
  346. ok_x2
  347. move.w crap1,y_show_size
  348. move.w crap1,x_show_size
  349. moveq #0,d2 ;increment values
  350. moveq #0,d3
  351. moveq #16,d5 ;y
  352. move.l plane1,a0
  353. move.w #100,d0
  354. asl.w #WHOLE_ACR,d0
  355. ext.l d0
  356. move.w d0,d1
  357. divu x_show_size,d0
  358. move.w #100,d1
  359. asr.w #WHOLE_ACR,d1
  360. add.w d1,x_show_size
  361. move.w #100,d1
  362. asl.w #WHOLE_ACR,d1
  363. ext.l d1
  364. divu y_show_size,d1
  365. move.w #100,d2
  366. asr.w #WHOLE_ACR,d2
  367. add.w d2,y_show_size
  368. add.w #16,x_show_size
  369. add.w #16,y_show_size
  370. move.l #map_data,a2
  371. move.l a2,a4 ;store for later
  372. do_pixel_y
  373. move.w #16,d4
  374. moveq #0,d2
  375. do_pixel_x
  376. tst.b (a2)
  377. bne.s draw_a_pixel
  378. bra.s get_next
  379. draw_a_pixel
  380. move.w d4,d6
  381. move.w d5,d7
  382. move.l a0,a5
  383. bsr draw_pixel
  384. get_next
  385. addq.w #1,d4
  386. cmp.w x_show_size,d4
  387. bgt.s done_x_line
  388. *calculate block step for x
  389. add.w d0,d2
  390. move.w d2,d7
  391. andi.w #ACCURACY-1,d2
  392. asr.w #WHOLE_ACR,d7
  393. tst d7
  394. beq.s do_pixel_x
  395. ext.l d7
  396. add.l d7,a2
  397. bra.s do_pixel_x
  398. done_x_line
  399. addq.w #1,d5
  400. cmp.w y_show_size,d5
  401. bgt.s done_y_line
  402. *calculate block step for y
  403. add.w d1,d3
  404. move.w d3,d7
  405. andi.w #ACCURACY-1,d3
  406. asr.w #WHOLE_ACR,d7
  407. tst d7
  408. beq.s dont_increase_y_block
  409. move.w #100,d6
  410. mulu d7,d6 ;number of lines to add
  411. add.l d6,a4
  412. dont_increase_y_block
  413. move.l a4,a2
  414. bra do_pixel_y
  415. done_y_line
  416. rts
  417. x_show_size dc.w 0
  418. y_show_size dc.w 0
  419. ******************************************
  420. ***** DRAW PIXEL *****
  421. ******************************************
  422. draw_pixel
  423. *send mem in a0, x and y in d0 and d1
  424. mulu #BPR,d7
  425. add.l d7,a5
  426. move.w d6,d7
  427. lsr.w #3,d6 ; get bytes
  428. andi.b #%111,d7 ; pixel bits
  429. neg.w d7
  430. addq.w #7,d7
  431. ext.l d6
  432. bset.b d7,(a5,d6)
  433. rts
  434. graphics
  435. incbin "scratch:empty/grap.bin"
  436. even
  437. map_data
  438. incbin "scratch:empty/testmapraw"
  439. even