four_way_scroll_old.c 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300
  1. *This uses the blitter to copy in the blocks rather than the 68000
  2. * - this of course requires the blocks to be in chip mem
  3. *----------------------------SCROLL CODE----------------------
  4. rsreset
  5. wait_pos rs.w 1
  6. wait_mask rs.w 1
  7. plane_1_hi_ptr rs.w 1
  8. plane_1_hi_val rs.w 1
  9. plane_1_lo_ptr rs.w 1
  10. plane_1_lo_val rs.w 1
  11. plane_2_hi_ptr rs.w 1
  12. plane_2_hi_val rs.w 1
  13. plane_2_lo_ptr rs.w 1
  14. plane_2_lo_val rs.w 1
  15. plane_3_hi_ptr rs.w 1
  16. plane_3_hi_val rs.w 1
  17. plane_3_lo_ptr rs.w 1
  18. plane_3_lo_val rs.w 1
  19. plane_4_hi_ptr rs.w 1
  20. plane_4_hi_val rs.w 1
  21. plane_4_lo_ptr rs.w 1
  22. plane_4_lo_val rs.w 1
  23. TEST_SPEED EQU 1
  24. WAIT_DRAW_BLOCKS EQU 0
  25. START_DRAW_BLOCKS EQU 1
  26. SCROLL_GOING_DOWN EQU (-48*BPR) ;up from bottom of scroll
  27. SCROLL_GOING_UP EQU (-32*BPR)
  28. MAP_SCREEN_OFFSET_DOWN EQU (17*BIGGEST_MAP_X)-2
  29. MAP_SCREEN_OFFSET_UP EQU (-2*BIGGEST_MAP_X)-2
  30. SCROLL_GOING_LEFT EQU (-32*BPR)+42
  31. SCROLL_GOING_RIGHT EQU (-32*BPR)-4
  32. MAP_SCREEN_OFFSET_LEFT EQU (-BIGGEST_MAP_X*2)+21
  33. MAP_SCREEN_OFFSET_RIGHT EQU (-BIGGEST_MAP_X*2)-2
  34. SCROLL_POSITION_OFFSET_LEFT EQU 20*16 ;-(-16*2) from y
  35. SCROLL_POSITION_OFFSET_RIGHT EQU (-2+1)*16 ;-(-16*2)
  36. SCROLL_POSITION_OFFSET_DOWN EQU (16*16) ;-4*8 -from x (was 2*8)
  37. SCROLL_POSITION_OFFSET_UP EQU (-1*16) ;-4*8
  38. ******************************************
  39. **** MOVE SCROLL *****
  40. ******************************************
  41. move_scroll
  42. move.w player_x_inc,d0
  43. move.w player_y_inc,d1
  44. *-Test x bounds
  45. add.w d0,scroll_x_position
  46. bge.s scroll_x_not_hit_bounds
  47. clr.w scroll_x_position
  48. bra.s scroll_x_not_hit_max_bounds
  49. scroll_x_not_hit_bounds
  50. move.w map_x_size,d3
  51. cmp.w scroll_x_position,d3
  52. bgt.s scroll_x_not_hit_max_bounds
  53. move.w d3,scroll_x_position
  54. scroll_x_not_hit_max_bounds
  55. *-<
  56. *-Test y bounds
  57. add.w d1,scroll_y_position
  58. bge.s scroll_not_hit_bounds
  59. clr.w scroll_y_position
  60. bra.s scroll_y_not_hit_max_bounds
  61. scroll_not_hit_bounds
  62. move.w map_y_size,d5
  63. cmp.w scroll_y_position,d5
  64. bgt.s scroll_y_not_hit_max_bounds
  65. move.w d5,scroll_y_position
  66. scroll_y_not_hit_max_bounds
  67. *-<
  68. move.w scroll_x_position,d0
  69. move.w scroll_y_position,d1
  70. sub.w last_scroll_x,d0
  71. sub.w last_scroll_y,d1
  72. move.w scroll_x_position,last_scroll_x
  73. move.w scroll_y_position,last_scroll_y
  74. bsr check_add_blocks
  75. bsr position_scroll
  76. rts
  77. last_scroll_x dc.w 0
  78. last_scroll_y dc.w 0
  79. ******************************************
  80. **** CHECK ADD BLOCKS *****
  81. ******************************************
  82. check_add_blocks
  83. *-Do for y blocks
  84. add.w d1,check_y_add
  85. cmp.w #16,check_y_add
  86. blt.s check_min_add
  87. sub.w #16,check_y_add
  88. move.w #START_DRAW_BLOCKS,y_ready_flag
  89. move.l #SCROLL_GOING_DOWN,add_y_block_direction
  90. move.l #MAP_SCREEN_OFFSET_DOWN*MAP_BLOCK_SIZE,add_y_map_direction
  91. move.l #MAP_SCREEN_OFFSET_DOWN,add_y_map_alien_direction
  92. move.w #SCROLL_POSITION_OFFSET_DOWN,scroll_add_y_offset
  93. move.l current_screen_position,current_y_screen_position
  94. move.l current_map_mem_position,current_y_map_mem_position
  95. move.l current_alien_map_mem_position,current_y_alien_map_mem_position
  96. bra.s drawing_please_wait
  97. check_min_add
  98. cmp.w #-16,check_y_add
  99. bgt.s drawing_please_wait
  100. add.w #16,check_y_add
  101. move.w #START_DRAW_BLOCKS,y_ready_flag
  102. move.l #SCROLL_GOING_UP,add_y_block_direction
  103. move.l #MAP_SCREEN_OFFSET_UP*MAP_BLOCK_SIZE,add_y_map_direction
  104. move.l #MAP_SCREEN_OFFSET_UP,add_y_map_alien_direction
  105. move.w #SCROLL_POSITION_OFFSET_UP,scroll_add_y_offset
  106. move.l current_screen_position,current_y_screen_position
  107. move.l current_map_mem_position,current_y_map_mem_position
  108. move.l current_alien_map_mem_position,current_y_alien_map_mem_position
  109. drawing_please_wait
  110. *-<
  111. *- Do for x blocks
  112. add.w d0,check_x_add
  113. cmp.w #16,check_x_add
  114. blt.s check_x_min_add
  115. sub.w #16,check_x_add
  116. move.w #START_DRAW_BLOCKS,x_ready_flag
  117. move.l #SCROLL_GOING_LEFT,add_x_block_direction
  118. move.l #MAP_SCREEN_OFFSET_LEFT*MAP_BLOCK_SIZE,add_x_map_direction
  119. move.l #MAP_SCREEN_OFFSET_LEFT,add_x_map_alien_direction
  120. move.w #SCROLL_POSITION_OFFSET_LEFT,scroll_add_x_offset
  121. move.l current_screen_position,current_x_screen_position
  122. move.l current_map_mem_position,current_x_map_mem_position
  123. move.l current_alien_map_mem_position,current_x_alien_map_mem_position
  124. bra.s drawing_x_please_wait
  125. check_x_min_add
  126. cmp.w #-16,check_x_add
  127. bgt.s drawing_x_please_wait
  128. add.w #16,check_x_add
  129. move.w #START_DRAW_BLOCKS,x_ready_flag
  130. move.l #SCROLL_GOING_RIGHT,add_x_block_direction
  131. move.l #MAP_SCREEN_OFFSET_RIGHT*MAP_BLOCK_SIZE,add_x_map_direction
  132. move.l #MAP_SCREEN_OFFSET_RIGHT,add_x_map_alien_direction
  133. move.w #SCROLL_POSITION_OFFSET_RIGHT,scroll_add_x_offset
  134. move.l current_screen_position,current_x_screen_position
  135. move.l current_map_mem_position,current_x_map_mem_position
  136. move.l current_alien_map_mem_position,current_x_alien_map_mem_position
  137. drawing_x_please_wait
  138. *-<
  139. sub.w d0,actual_x_position
  140. sub.w d1,actual_y_position
  141. asl #PLAYER_SCALE,d0
  142. asl #PLAYER_SCALE,d1
  143. sub.w d0,player_x_position
  144. sub.w d1,player_y_position
  145. rts
  146. add_y_block_direction dc.l 0
  147. check_y_add dc.w 0
  148. y_ready_flag dc.w 0
  149. add_x_block_direction dc.l 0
  150. check_x_add dc.w 0
  151. x_ready_flag dc.w 0
  152. add_y_map_direction dc.l 0
  153. add_x_map_direction dc.l 0
  154. add_y_map_alien_direction dc.l 0
  155. add_x_map_alien_direction dc.l 0
  156. scroll_add_y_offset dc.w 0
  157. scroll_add_x_offset dc.w 0
  158. ******************************************
  159. **** POSITION SCROLL *****
  160. ******************************************
  161. position_scroll
  162. *Positions scroll by the x and y values stored
  163. move.w scroll_x_position,d0
  164. move.w scroll_y_position,d1
  165. position_scroll_along_x
  166. moveq #0,d3
  167. move.w d0,d2
  168. move.w d0,d3
  169. andi.w #$000f,d2 ;shift value
  170. move.w d2,alien_shift
  171. asr.w #4,d3 ;number of blocks in
  172. andi.w #$fff0,d0
  173. asr.w #3,d0
  174. ext.l d0 ;bytes in
  175. neg.w d2
  176. add.w #15,d2
  177. move.w d2,d4
  178. asl.w #4,d2
  179. or.w d2,d4
  180. move.w d4,scroll_value
  181. position_scroll_along_y
  182. *--- get current map positions
  183. moveq #0,d2
  184. move.w d1,d2
  185. asr.w #4,d2
  186. mulu #BIGGEST_MAP_X,d2
  187. move.l current_alien_map_pointer,a0
  188. add.l d2,a0 ;add y
  189. add.l d3,a0 ;add x
  190. move.l a0,current_alien_map_mem_position
  191. asl d2 ;cos map mem = word
  192. asl d3
  193. move.l current_map_pointer,a0
  194. add.l d2,a0 ;add y
  195. add.l d3,a0 ;add x
  196. move.l a0,current_map_mem_position
  197. *---
  198. ext.l d1
  199. divu #SCROLL_HEIGHT,d1
  200. swap d1 ;this is all we want - split position down screen
  201. neg.w d1 ;so scroll goes right way
  202. add.w #SCROLL_HEIGHT,d1
  203. move.w d1,split_position
  204. *---calc where to draw
  205. moveq #0,d3
  206. move.w #SCROLL_HEIGHT,d3 ;position above buffer area
  207. sub.w d1,d3 ;position of buffer area
  208. andi.w #$fff0,d3
  209. mulu #BPR,d3
  210. add.l scroll_area,d3
  211. add.l d0,d3 ;add x in
  212. move.l d3,current_screen_position
  213. *------
  214. move.w d1,d2
  215. add.w #$2c,d1
  216. moveq #0,d4
  217. cmp.w #$ff,d1
  218. ble.s not_over_dodgy_line
  219. moveq #1,d4
  220. not_over_dodgy_line
  221. cmp.w #$ff+$2c-16,d1
  222. ble.s not_off_copper
  223. move.w #-1,d4
  224. bra.s calc_screen_split
  225. not_off_copper
  226. andi.w #$ff,d1 ;so values wraps round
  227. asl.w #8,d1
  228. addq.w #1,d1 ; = wait value
  229. calc_screen_split
  230. neg.w d2
  231. add.w #SCROLL_HEIGHT,d2
  232. mulu #BPR,d2
  233. ext.l d2
  234. move.l d2,d5
  235. add.l buff_plane1,d5
  236. add.l plane1,d2 ;to display at top
  237. move.l plane1,d3 ;top display at split
  238. add.l d0,d2 ;add x in
  239. add.l d0,d5
  240. move.l d5,current_alien_draw_position
  241. move.l buff_plane1,d5
  242. add.l d0,d5
  243. move.l d5,current_alien_split_draw_position
  244. add.l d0,d3 ;add x in
  245. bsr insert_plane_pointers
  246. rts
  247. ******************************************
  248. **** INSERT PLANE POINTERS *****
  249. ******************************************
  250. insert_plane_pointers
  251. *d1 contains wait value
  252. *d2 = top of display
  253. *d3 = split part of display
  254. *d4 indicates if inserting after 255 gap
  255. tst d4
  256. bmi clear_all_banks
  257. beq.s insert_before_line
  258. insert_after_line
  259. move.l #scroll_bank_2,a0
  260. move.l #scroll_bank_1,a1
  261. bsr fill_banks
  262. rts
  263. insert_before_line
  264. move.l #scroll_bank_1,a0
  265. move.l #scroll_bank_2,a1
  266. bsr fill_banks
  267. rts
  268. clear_all_banks
  269. move.l #scroll_bank_1,a0
  270. move.l #scroll_bank_2,a1
  271. bsr clear_banks
  272. rts
  273. ******************************************
  274. **** FILL BANKS *****
  275. ******************************************
  276. fill_banks
  277. *a0 = bank to fill
  278. *a1 = bank to clear
  279. *d1 = wait
  280. *d2 = top of display
  281. *d3 = split display
  282. *change to copper jump later - but get it working first!!!
  283. * IN USE SPLIT POINTERS
  284. move.w d1,wait_pos(a0)
  285. move.w #$fffe,wait_mask(a0)
  286. move.w #$e2,plane_1_lo_ptr(a0)
  287. move.w d3,plane_1_lo_val(a0)
  288. swap d3
  289. move.w #$e0,plane_1_hi_ptr(a0)
  290. move.w d3,plane_1_hi_val(a0)
  291. swap d3
  292. add.l #PLANE_INC,d3
  293. move.w #$e6,plane_2_lo_ptr(a0)
  294. move.w d3,plane_2_lo_val(a0)
  295. swap d3
  296. move.w #$e4,plane_2_hi_ptr(a0)
  297. move.w d3,plane_2_hi_val(a0)
  298. swap d3
  299. add.l #PLANE_INC,d3
  300. move.w #$ea,plane_3_lo_ptr(a0)
  301. move.w d3,plane_3_lo_val(a0)
  302. swap d3
  303. move.w #$e8,plane_3_hi_ptr(a0)
  304. move.w d3,plane_3_hi_val(a0)
  305. swap d3
  306. add.l #PLANE_INC,d3
  307. move.w #$ee,plane_4_lo_ptr(a0)
  308. move.w d3,plane_4_lo_val(a0)
  309. swap d3
  310. move.w #$ec,plane_4_hi_ptr(a0)
  311. move.w d3,plane_4_hi_val(a0)
  312. * UNUSED SET OF SPLIT POINTERS
  313. move.w #$1f0,wait_pos(a1)
  314. move.w #$1f0,plane_1_hi_ptr(a1)
  315. move.w #$1f0,plane_1_lo_ptr(a1)
  316. move.w #$1f0,plane_2_hi_ptr(a1)
  317. move.w #$1f0,plane_2_lo_ptr(a1)
  318. move.w #$1f0,plane_3_hi_ptr(a1)
  319. move.w #$1f0,plane_3_lo_ptr(a1)
  320. move.w #$1f0,plane_4_hi_ptr(a1)
  321. move.w #$1f0,plane_4_lo_ptr(a1)
  322. * TOP OF SCREEN
  323. move.l #top_of_screen-4,a0 ;so rs.w's work
  324. move.w d2,plane_1_lo_val(a0)
  325. swap d2
  326. move.w d2,plane_1_hi_val(a0)
  327. swap d2
  328. add.l #PLANE_INC,d2
  329. move.w d2,plane_2_lo_val(a0)
  330. swap d2
  331. move.w d2,plane_2_hi_val(a0)
  332. swap d2
  333. add.l #PLANE_INC,d2
  334. move.w d2,plane_3_lo_val(a0)
  335. swap d2
  336. move.w d2,plane_3_hi_val(a0)
  337. swap d2
  338. add.l #PLANE_INC,d2
  339. move.w d2,plane_4_lo_val(a0)
  340. swap d2
  341. move.w d2,plane_4_hi_val(a0)
  342. rts
  343. ******************************************
  344. **** CLEAR BANKS *****
  345. ******************************************
  346. clear_banks
  347. * UNUSED SET OF SPLIT POINTERS 1
  348. move.w #$1f0,wait_pos(a1)
  349. move.w #$1f0,plane_1_hi_ptr(a1)
  350. move.w #$1f0,plane_1_lo_ptr(a1)
  351. move.w #$1f0,plane_2_hi_ptr(a1)
  352. move.w #$1f0,plane_2_lo_ptr(a1)
  353. move.w #$1f0,plane_3_hi_ptr(a1)
  354. move.w #$1f0,plane_3_lo_ptr(a1)
  355. move.w #$1f0,plane_4_hi_ptr(a1)
  356. move.w #$1f0,plane_4_lo_ptr(a1)
  357. * UNUSED SET OF SPLIT POINTERS 2
  358. move.w #$1f0,wait_pos(a0)
  359. move.w #$1f0,plane_1_hi_ptr(a0)
  360. move.w #$1f0,plane_1_lo_ptr(a0)
  361. move.w #$1f0,plane_2_hi_ptr(a0)
  362. move.w #$1f0,plane_2_lo_ptr(a0)
  363. move.w #$1f0,plane_3_hi_ptr(a0)
  364. move.w #$1f0,plane_3_lo_ptr(a0)
  365. move.w #$1f0,plane_4_hi_ptr(a0)
  366. move.w #$1f0,plane_4_lo_ptr(a0)
  367. * TOP OF SCREEN
  368. move.l #top_of_screen-4,a0 ;so rs.w's work
  369. move.w d2,plane_1_lo_val(a0)
  370. swap d2
  371. move.w d2,plane_1_hi_val(a0)
  372. swap d2
  373. add.l #PLANE_INC,d2
  374. move.w d2,plane_2_lo_val(a0)
  375. swap d2
  376. move.w d2,plane_2_hi_val(a0)
  377. swap d2
  378. add.l #PLANE_INC,d2
  379. move.w d2,plane_3_lo_val(a0)
  380. swap d2
  381. move.w d2,plane_3_hi_val(a0)
  382. swap d2
  383. add.l #PLANE_INC,d2
  384. move.w d2,plane_4_lo_val(a0)
  385. swap d2
  386. move.w d2,plane_4_hi_val(a0)
  387. rts
  388. scroll_x_position dc.w 0
  389. scroll_y_position dc.w 0
  390. split_position dc.w 0
  391. **********************************************************
  392. *********** DRAW BLOCKS FOR SCROLL ***********
  393. **********************************************************
  394. draw_blocks_for_scroll
  395. tst.w y_ready_flag
  396. beq.s see_if_x_to_draw
  397. move.l current_y_screen_position,a0
  398. move.l current_y_map_mem_position,a1
  399. move.l current_y_alien_map_mem_position,a4
  400. bsr draw_y_blocks
  401. see_if_x_to_draw
  402. tst.w x_ready_flag
  403. beq.s quit_draw_blocks_for_scroll
  404. move.l current_x_screen_position,a0
  405. move.l current_x_map_mem_position,a1
  406. move.l current_x_alien_map_mem_position,a4
  407. bsr draw_x_blocks
  408. quit_draw_blocks_for_scroll
  409. rts
  410. current_screen_position dc.l 0
  411. current_y_screen_position dc.l 0
  412. current_x_screen_position dc.l 0
  413. current_map_mem_position dc.l 0
  414. current_alien_map_mem_position dc.l 0
  415. current_x_map_mem_position dc.l 0
  416. current_y_map_mem_position dc.l 0
  417. current_x_alien_map_mem_position dc.l 0
  418. current_y_alien_map_mem_position dc.l 0
  419. **********************************************************
  420. *********** DRAW Y BLOCKS ***********
  421. **********************************************************
  422. draw_y_blocks
  423. *current screen mem position in a0
  424. *current map position in a1
  425. add.l add_y_block_direction,a0
  426. cmp.l scroll_area,a0
  427. bge.s draw_inside_plane_area
  428. add.l #SCROLL_HEIGHT*BPR,a0
  429. draw_inside_plane_area
  430. *---- So starts one block back so filling in x strips - see design
  431. subq.l #4,a0
  432. *-<
  433. add.l add_y_map_direction,a1
  434. add.l add_y_map_alien_direction,a4
  435. draw_blocks_main
  436. *---Set up start x and y values
  437. move.w scroll_x_position,d5
  438. sub.w #4*8,d5
  439. move.w scroll_y_position,d6
  440. andi.w #$fff0,d5
  441. andi.w #$fff0,d6
  442. add.w scroll_add_y_offset,d6
  443. *----
  444. move.l Alien_Add_List_Pointer,a5
  445. moveq #0,d0
  446. move.w current_y_map_position,d0
  447. ext.l d0
  448. add.l d0,a4 ;current alien map position
  449. asl d0 ;cos map data = word
  450. add.l d0,a1 ;current map position
  451. * asl d0 ;get into bytes
  452. add.l d0,a0 ;get to current line
  453. asl #3,d0
  454. add.w d0,d5 ;current add x position
  455. move.l a0,start_draw_pos ;store for buff write
  456. move.w total_number_of_y_blocks_to_draw,d2
  457. moveq #0,d7 ;count number of blocks drawn
  458. init_blit_values
  459. btst #14,dmaconr(a6)
  460. bne.s init_blit_values
  461. move.w #BPR-2,bltdmod(a6)
  462. move.w #0,bltamod(a6)
  463. move.l #$ffffffff,bltafwm(a6)
  464. move.l #$09F00000,bltcon0(A6)
  465. move.w number_of_y_blocks_per_frame,d0
  466. draw_loop
  467. move.l level_background_blocks,a2
  468. moveq #0,d1
  469. *--- Adding aliens from map
  470. move.b (a4),d1
  471. beq.s alien_already_in_map
  472. btst #ALIEN_BUSY,d1
  473. bne.s alien_already_in_map
  474. move.l a4,Add_Map_Position(a5)
  475. move.w d5,Add_X_Position(a5)
  476. move.w d6,Add_Y_Position(a5)
  477. move.w d1,Add_Alien_number(a5)
  478. add.l #Add_Struct_Size,a5
  479. bset.b #ALIEN_BUSY,(a4)
  480. alien_already_in_map
  481. *--- Done adding for this block
  482. move.w (a1),d1
  483. asl.w #7,d1 ;same as mulu (16*2)*4
  484. add.l d1,a2 ;get to correct position in block data
  485. draw_block_on_screen
  486. btst #14,dmaconr(a6)
  487. bne.s draw_block_on_screen
  488. move.l a0,bltdpth(a6) ;screen
  489. move.l a2,bltapth(a6) ;graphics
  490. move.w #16<<6+1,bltsize(a6) ;1 word by 16 pixels
  491. move.l a0,a3
  492. add.l #PLANE_INC,a3
  493. add.l #16*2,a2
  494. draw_block_on_screenp2
  495. btst #14,dmaconr(a6)
  496. bne.s draw_block_on_screenp2
  497. move.l a3,bltdpth(a6) ;screen
  498. move.l a2,bltapth(a6) ;graphics
  499. move.w #16<<6+1,bltsize(a6) ;1 word by 16 pixels
  500. add.l #PLANE_INC,a3
  501. add.l #16*2,a2
  502. draw_block_on_screenp3
  503. btst #14,dmaconr(a6)
  504. bne.s draw_block_on_screenp3
  505. move.l a3,bltdpth(a6) ;screen
  506. move.l a2,bltapth(a6) ;graphics
  507. move.w #16<<6+1,bltsize(a6) ;1 word by 16 pixels
  508. add.l #PLANE_INC,a3
  509. add.l #16*2,a2
  510. draw_block_on_screenp4
  511. btst #14,dmaconr(a6)
  512. bne.s draw_block_on_screenp4
  513. move.l a3,bltdpth(a6) ;screen
  514. move.l a2,bltapth(a6) ;graphics
  515. move.w #16<<6+1,bltsize(a6) ;1 word by 16 pixels
  516. done_a_block
  517. add.w #16,d5 ;x position of block
  518. addq.l #2,a0 ;next block position along screen
  519. addq.l #2,a1 ;next map position
  520. addq.l #1,a4 ;next alien map position
  521. addq.w #1,current_y_map_position
  522. addq.w #1,d7 ;count number blocks drawn
  523. cmp.w current_y_map_position,d2
  524. bne.s not_yet_done_line
  525. clr current_y_map_position
  526. move.w #WAIT_DRAW_BLOCKS,y_ready_flag ;done our line now wait for screen to scroll 16
  527. bra.s done_all_blocks
  528. not_yet_done_line
  529. dbra d0,draw_loop
  530. done_all_blocks
  531. move.w #-1,(a5) ;end add list
  532. move.l a5,Alien_Add_List_Pointer
  533. *------------------Draw y blocks into buffer--------------
  534. move.l start_draw_pos,a5 ;source positiion
  535. move.l a5,a4
  536. add.l #PLANE_INC*4,a5 ;buff position
  537. move.l a5,a3
  538. add.l #PLANE_INC*4,a3
  539. move.w #BPR,d0
  540. move.w d7,d1
  541. asl d1
  542. sub.w d1,d0 ;modulus
  543. add.w #16<<6,d7 ;blitsize
  544. wait_y_buff_start
  545. btst #14,dmaconr(a6)
  546. bne.s wait_y_buff_start
  547. move.w d0,bltamod(a6)
  548. move.w d0,bltdmod(a6)
  549. move.l a4,bltapth(a6)
  550. move.l a5,bltdpth(a6)
  551. move.w d7,bltsize(a6)
  552. draw_y_copy1
  553. btst #14,dmaconr(a6)
  554. bne.s draw_y_copy1
  555. move.l a3,bltdpth(a6)
  556. move.l a4,bltapth(a6)
  557. move.w d7,bltsize(a6)
  558. add.l #PLANE_INC,a4
  559. add.l #PLANE_INC,a5
  560. add.l #PLANE_INC,a3
  561. y_buff_block_p2
  562. btst #14,dmaconr(a6)
  563. bne.s y_buff_block_p2
  564. move.l a4,bltapth(a6)
  565. move.l a5,bltdpth(a6)
  566. move.w d7,bltsize(a6)
  567. draw_y_copy2
  568. btst #14,dmaconr(a6)
  569. bne.s draw_y_copy2
  570. move.l a3,bltdpth(a6)
  571. move.l a4,bltapth(a6)
  572. move.w d7,bltsize(a6)
  573. add.l #PLANE_INC,a4
  574. add.l #PLANE_INC,a5
  575. add.l #PLANE_INC,a3
  576. y_buff_block_p3
  577. btst #14,dmaconr(a6)
  578. bne.s y_buff_block_p3
  579. move.l a4,bltapth(a6)
  580. move.l a5,bltdpth(a6)
  581. move.w d7,bltsize(a6)
  582. draw_y_copy3
  583. btst #14,dmaconr(a6)
  584. bne.s draw_y_copy3
  585. move.l a3,bltdpth(a6)
  586. move.l a4,bltapth(a6)
  587. move.w d7,bltsize(a6)
  588. add.l #PLANE_INC,a4
  589. add.l #PLANE_INC,a5
  590. add.l #PLANE_INC,a3
  591. y_buff_block_p4
  592. btst #14,dmaconr(a6)
  593. bne.s y_buff_block_p4
  594. move.l a4,bltapth(a6)
  595. move.l a5,bltdpth(a6)
  596. move.w d7,bltsize(a6)
  597. draw_y_copy4
  598. btst #14,dmaconr(a6)
  599. bne.s draw_y_copy4
  600. move.l a3,bltdpth(a6)
  601. move.l a4,bltapth(a6)
  602. move.w d7,bltsize(a6)
  603. rts
  604. start_draw_pos dc.l 0
  605. **********************************************************
  606. *********** DRAW X BLOCKS ***********
  607. **********************************************************
  608. draw_x_blocks
  609. *current screen mem position in a0
  610. *current map position in a1
  611. **make it draw always on right
  612. add.l add_x_block_direction,a0
  613. add.l add_x_map_direction,a1
  614. add.l add_x_map_alien_direction,a4
  615. draw_x_blocks_straight
  616. *---Set up start x and y values
  617. move.w scroll_x_position,d4
  618. move.w scroll_y_position,d5
  619. sub.w #16*2,d5
  620. andi.w #$fff0,d4
  621. andi.w #$fff0,d5
  622. add.w scroll_add_x_offset,d4
  623. *----
  624. move.l Alien_Add_List_Pointer,a5
  625. moveq #0,d0
  626. moveq #0,d6
  627. move.w current_x_map_position,d0
  628. move.w d0,d1
  629. mulu #BIGGEST_MAP_X,d0
  630. add.l d0,a4 ;get to current line in alien map
  631. asl d0 ;cos map data = word
  632. add.l d0,a1 ;get to current line
  633. asl #4,d1
  634. add.w d1,d5 ;current y position on screen
  635. mulu #BPR,d1 ;way BPR*16 but already done *16
  636. add.l d1,a0 ;current screen block position
  637. move.l scroll_area,a3
  638. cmp.l a3,a0
  639. bge.s within_plane_still
  640. add.l #SCROLL_HEIGHT*BPR,a0
  641. within_plane_still
  642. add.l #SCROLL_HEIGHT*BPR,a3
  643. cmp.l a3,a0
  644. blt.s test2
  645. sub.l #SCROLL_HEIGHT*BPR,a0
  646. test2
  647. move.l a0,start_draw_pos ;for buff purposes
  648. move.w total_number_of_x_blocks_to_draw,d2
  649. moveq #0,d7 ;count number of blocks drawn
  650. init_x_blit_values
  651. btst #14,dmaconr(a6)
  652. bne.s init_x_blit_values
  653. move.w #BPR-2,bltdmod(a6)
  654. move.w #0,bltamod(a6)
  655. move.l #$ffffffff,bltafwm(a6)
  656. move.l #$09F00000,bltcon0(A6)
  657. move.w number_of_x_blocks_per_frame,d0
  658. draw_x_loop
  659. move.l level_background_blocks,a2
  660. moveq #0,d1
  661. *--- Adding aliens from map
  662. move.b (a4),d1
  663. beq.s alien_x_already_in_map
  664. btst #ALIEN_BUSY,d1
  665. bne.s alien_x_already_in_map
  666. move.l a4,Add_Map_Position(a5)
  667. move.w d4,Add_X_Position(a5)
  668. move.w d5,Add_Y_Position(a5)
  669. move.w d1,Add_Alien_number(a5)
  670. add.l #Add_Struct_Size,a5
  671. bset.b #ALIEN_BUSY,(a4)
  672. alien_x_already_in_map
  673. *--- Done adding for this block
  674. move.w (a1),d1
  675. asl.w #7,d1 ;same as mulu (16*2)*4
  676. add.l d1,a2 ;get to correct position in block data
  677. draw_x_block_on_screen
  678. btst #14,dmaconr(a6)
  679. bne.s draw_x_block_on_screen
  680. move.l a0,bltdpth(a6) ;screen
  681. move.l a2,bltapth(a6) ;graphics
  682. move.w #16<<6+1,bltsize(a6) ;1 word by 16 pixels
  683. move.l a0,a3
  684. add.l #PLANE_INC,a3
  685. add.l #16*2,a2
  686. draw_x_block_on_screenp2
  687. btst #14,dmaconr(a6)
  688. bne.s draw_x_block_on_screenp2
  689. move.l a3,bltdpth(a6) ;screen
  690. move.l a2,bltapth(a6) ;graphics
  691. move.w #16<<6+1,bltsize(a6) ;1 word by 16 pixels
  692. add.l #PLANE_INC,a3
  693. add.l #16*2,a2
  694. draw_x_block_on_screenp3
  695. btst #14,dmaconr(a6)
  696. bne.s draw_x_block_on_screenp3
  697. move.l a3,bltdpth(a6) ;screen
  698. move.l a2,bltapth(a6) ;graphics
  699. move.w #16<<6+1,bltsize(a6) ;1 word by 16 pixels
  700. add.l #PLANE_INC,a3
  701. add.l #16*2,a2
  702. draw_x_block_on_screenp4
  703. btst #14,dmaconr(a6)
  704. bne.s draw_x_block_on_screenp4
  705. move.l a3,bltdpth(a6) ;screen
  706. move.l a2,bltapth(a6) ;graphics
  707. move.w #16<<6+1,bltsize(a6) ;1 word by 16 pixels
  708. done_x_block
  709. add.w #16,d5 ;current y pixel position
  710. add.l #BPR*16,a0
  711. move.l scroll_area,a3
  712. cmp.l a3,a0
  713. bge.s no_need_to_wrap
  714. add.l #SCROLL_HEIGHT*BPR,a0
  715. no_need_to_wrap
  716. add.l #SCROLL_HEIGHT*BPR,a3
  717. cmp.l a3,a0
  718. blt.s test7777
  719. move.w d7,d6 ;point where split
  720. addq.w #1,d6
  721. sub.l #SCROLL_HEIGHT*BPR,a0
  722. test7777
  723. add.l #BIGGEST_MAP_X*MAP_BLOCK_SIZE,a1
  724. add.l #BIGGEST_MAP_X,a4
  725. addq.w #1,current_x_map_position
  726. addq.w #1,d7 ;count number blocks drawn
  727. cmp.w current_x_map_position,d2
  728. bne.s not_yet_done_x_line
  729. clr current_x_map_position
  730. move.w #WAIT_DRAW_BLOCKS,x_ready_flag ;done our line now wait for screen to scroll 16
  731. bra.s done_all_x_blocks
  732. not_yet_done_x_line
  733. dbra d0,draw_x_loop
  734. done_all_x_blocks
  735. move.w #-1,(a5) ;end add list
  736. move.l a5,Alien_Add_List_Pointer
  737. *----------------Now do one big blit to buffer areas---------------
  738. *need to know if wrapped - so have to do two blits
  739. move.l start_draw_pos,a4
  740. move.l a4,a0
  741. buff_wait_fin
  742. btst #14,dmaconr(a6)
  743. bne.s buff_wait_fin
  744. move.w #BPR-2,bltamod(a6)
  745. move.l a4,a5
  746. add.l #PLANE_INC*4,a4 ;buff start position
  747. move.l a4,a3
  748. add.l #PLANE_INC*4,a3 ;copyback area
  749. moveq #0,d0
  750. tst d6
  751. beq.s no_split_occured
  752. move.w d7,d0 ;number of blocks to draw
  753. sub.w d6,d0 ;blocks after split
  754. move.w d6,d7
  755. no_split_occured
  756. move.l a4,bltdpth(a6) ;screen
  757. move.l a5,bltapth(a6) ;graphics
  758. asl.w #4,d7 ;height of blocks
  759. asl.w #6,d7
  760. addq.w #1,d7
  761. move.w d7,bltsize(a6)
  762. draw_x_copy1
  763. btst #14,dmaconr(a6)
  764. bne.s draw_x_copy1
  765. move.l a3,bltdpth(a6)
  766. move.l a4,bltapth(a6)
  767. move.w d7,bltsize(a6)
  768. add.l #PLANE_INC,a4
  769. add.l #PLANE_INC,a5
  770. add.l #PLANE_INC,a3
  771. draw_x_buff2
  772. btst #14,dmaconr(a6)
  773. bne.s draw_x_buff2
  774. move.l a4,bltdpth(a6)
  775. move.l a5,bltapth(a6)
  776. move.w d7,bltsize(a6)
  777. draw_x_copy2
  778. btst #14,dmaconr(a6)
  779. bne.s draw_x_copy2
  780. move.l a3,bltdpth(a6)
  781. move.l a4,bltapth(a6)
  782. move.w d7,bltsize(a6)
  783. add.l #PLANE_INC,a4
  784. add.l #PLANE_INC,a5
  785. add.l #PLANE_INC,a3
  786. draw_x_buff3
  787. btst #14,dmaconr(a6)
  788. bne.s draw_x_buff3
  789. move.l a4,bltdpth(a6)
  790. move.l a5,bltapth(a6)
  791. move.w d7,bltsize(a6)
  792. draw_x_copy3
  793. btst #14,dmaconr(a6)
  794. bne.s draw_x_copy3
  795. move.l a3,bltdpth(a6)
  796. move.l a4,bltapth(a6)
  797. move.w d7,bltsize(a6)
  798. add.l #PLANE_INC,a4
  799. add.l #PLANE_INC,a5
  800. add.l #PLANE_INC,a3
  801. draw_x_buff4
  802. btst #14,dmaconr(a6)
  803. bne.s draw_x_buff4
  804. move.l a4,bltdpth(a6)
  805. move.l a5,bltapth(a6)
  806. move.w d7,bltsize(a6)
  807. draw_x_copy4
  808. btst #14,dmaconr(a6)
  809. bne.s draw_x_copy4
  810. move.l a3,bltdpth(a6)
  811. move.l a4,bltapth(a6)
  812. move.w d7,bltsize(a6)
  813. tst d0
  814. beq no_need_to_draw_more_blocks
  815. move.l a0,a5
  816. asl.w #4,d6
  817. mulu #BPR,d6
  818. add.l d6,a5
  819. sub.l #SCROLL_HEIGHT*BPR,a5
  820. move.l a5,a4
  821. add.l #PLANE_INC*4,a4
  822. move.l a4,a3
  823. add.l #PLANE_INC*4,a3
  824. move.w d0,d7 ;blocks after split
  825. draw_x_buff1_split
  826. btst #14,dmaconr(a6)
  827. bne.s draw_x_buff1_split
  828. move.l a4,bltdpth(a6) ;screen
  829. move.l a5,bltapth(a6) ;graphics
  830. asl.w #4,d7 ;height of blocks
  831. asl.w #6,d7
  832. addq.w #1,d7
  833. move.w d7,bltsize(a6)
  834. draw_x_copy1_split
  835. btst #14,dmaconr(a6)
  836. bne.s draw_x_copy1_split
  837. move.l a3,bltdpth(a6)
  838. move.l a4,bltapth(a6)
  839. move.w d7,bltsize(a6)
  840. add.l #PLANE_INC,a4
  841. add.l #PLANE_INC,a5
  842. add.l #PLANE_INC,a3
  843. draw_x_buff2_split
  844. btst #14,dmaconr(a6)
  845. bne.s draw_x_buff2_split
  846. move.l a4,bltdpth(a6)
  847. move.l a5,bltapth(a6)
  848. move.w d7,bltsize(a6)
  849. draw_x_copy2_split
  850. btst #14,dmaconr(a6)
  851. bne.s draw_x_copy2_split
  852. move.l a3,bltdpth(a6)
  853. move.l a4,bltapth(a6)
  854. move.w d7,bltsize(a6)
  855. add.l #PLANE_INC,a4
  856. add.l #PLANE_INC,a5
  857. add.l #PLANE_INC,a3
  858. draw_x_buff3_split
  859. btst #14,dmaconr(a6)
  860. bne.s draw_x_buff3_split
  861. move.l a4,bltdpth(a6)
  862. move.l a5,bltapth(a6)
  863. move.w d7,bltsize(a6)
  864. draw_x_copy3_split
  865. btst #14,dmaconr(a6)
  866. bne.s draw_x_copy3_split
  867. move.l a3,bltdpth(a6)
  868. move.l a4,bltapth(a6)
  869. move.w d7,bltsize(a6)
  870. add.l #PLANE_INC,a4
  871. add.l #PLANE_INC,a5
  872. add.l #PLANE_INC,a3
  873. draw_x_buff4_split
  874. btst #14,dmaconr(a6)
  875. bne.s draw_x_buff4_split
  876. move.l a4,bltdpth(a6)
  877. move.l a5,bltapth(a6)
  878. move.w d7,bltsize(a6)
  879. draw_x_copy4_split
  880. btst #14,dmaconr(a6)
  881. bne.s draw_x_copy4_split
  882. move.l a3,bltdpth(a6)
  883. move.l a4,bltapth(a6)
  884. move.w d7,bltsize(a6)
  885. no_need_to_draw_more_blocks
  886. rts
  887. total_number_of_y_blocks_to_draw dc.w 24
  888. current_y_map_position dc.w 0
  889. total_number_of_x_blocks_to_draw dc.w 20
  890. current_x_map_position dc.w 0
  891. number_of_x_blocks_per_frame dc.w 3-1
  892. number_of_y_blocks_per_frame dc.w 3-1
  893. ********************************************************
  894. **** FILL SCREEN WITH BLOCKS ****
  895. ********************************************************
  896. fill_screen_with_blocks
  897. *send in d0 and d1 as the x and y
  898. move.l #Alien_Add_List,Alien_Add_List_Pointer
  899. move.w d0,scroll_x_position
  900. move.w d1,scroll_y_position
  901. move.w d0,last_scroll_x
  902. move.w d1,last_scroll_y
  903. bsr Position_Scroll
  904. move.l current_alien_draw_position,a0
  905. move.l current_map_mem_position,a1
  906. move.l current_alien_map_mem_position,a4 ;just so no crash
  907. sub.l #PLANE_INC*4,a0 ;cos buff
  908. *--Position back two lines to fill gap above
  909. tst scroll_y_position
  910. beq.s dont_do_extra2
  911. sub.l #(BPR*16)*2,a0
  912. cmp.l plane1,a0
  913. bge.s not_wrapped_off
  914. add.l #SCROLL_HEIGHT*BPR,a0
  915. not_wrapped_off
  916. sub.l #(2*BIGGEST_MAP_X)*MAP_BLOCK_SIZE,a1
  917. dont_do_extra2
  918. *---------
  919. move.w #20-1,d0
  920. do_all_blocks
  921. move.w #START_DRAW_BLOCKS,y_ready_flag
  922. keep_drawing
  923. movem.l a0-a5/d0-d7,-(sp)
  924. bsr draw_blocks_main
  925. move.w #-1,Alien_Add_List
  926. move.l #Alien_Add_List,Alien_Add_List_Pointer
  927. movem.l (sp)+,a0-a5/d0-d7
  928. tst y_ready_flag
  929. bne.s keep_drawing
  930. add.l #16*BPR,a0
  931. move.l plane1,a2
  932. add.l #SCROLL_HEIGHT*BPR,a2
  933. cmp.l a2,a0
  934. blt.s not_in_area_yet
  935. sub.l #SCROLL_HEIGHT*BPR,a0
  936. not_in_area_yet
  937. add.l #(BIGGEST_MAP_X*MAP_BLOCK_SIZE),a1
  938. dbra d0,do_all_blocks
  939. move.w #WAIT_DRAW_BLOCKS,y_ready_flag
  940. move.w #START_DRAW_BLOCKS,x_ready_flag
  941. wait_until_done
  942. move.l current_alien_draw_position,a0
  943. sub.l #PLANE_INC*4,a0 ;cos buff
  944. move.l current_map_mem_position,a1
  945. move.l current_alien_map_mem_position,a4
  946. add.l #40,a0
  947. add.l #21*MAP_BLOCK_SIZE,a1
  948. bsr draw_x_blocks_straight
  949. cmp.w #WAIT_DRAW_BLOCKS,x_ready_flag
  950. bne.s wait_until_done
  951. move.w #START_DRAW_BLOCKS,x_ready_flag
  952. wait_until_done2
  953. move.l current_alien_draw_position,a0
  954. sub.l #PLANE_INC*4,a0 ;cos buff
  955. move.l current_map_mem_position,a1
  956. move.l current_alien_map_mem_position,a4
  957. add.l #42,a0
  958. add.l #21*MAP_BLOCK_SIZE,a1
  959. bsr draw_x_blocks_straight
  960. cmp.w #WAIT_DRAW_BLOCKS,x_ready_flag
  961. bne.s wait_until_done2
  962. move.w #WAIT_DRAW_BLOCKS,x_ready_flag
  963. move.w #-1,Alien_Add_List
  964. move.l #Alien_Add_List,Alien_Add_List_Pointer
  965. rts
  966. ********************************************************
  967. **** SET UP SCROLL POSITION ****
  968. ********************************************************
  969. set_up_scroll_position
  970. clr.w current_x_map_position ;position of drawn blocks
  971. clr.w current_y_map_position
  972. clr.w check_x_add
  973. clr.w check_y_add
  974. move.l level_map,a0
  975. move.w map_data_x(a0),d0
  976. move.w d0,map_x_size
  977. move.w map_datasize(a0),d1
  978. asl d1,d0
  979. mulu map_data_y(a0),d0 ;=size of map
  980. move.w map_data_y(a0),map_y_size
  981. add.l #map_data_start,a0
  982. move.l a0,current_map_pointer
  983. add.l d0,a0
  984. move.l a0,current_alien_map_pointer
  985. move.w map_x_size,d0
  986. move.w map_y_size,d1
  987. sub.w #20-2,d0
  988. sub.w #15,d1
  989. asl #4,d0
  990. asl #4,d1
  991. subq.w #1,d0
  992. move.w d0,map_x_size
  993. move.w d1,map_y_size
  994. rts
  995. ********************************************************
  996. **** DRAW CURRENT SCROLL POINT ****
  997. ********************************************************
  998. Draw_Current_Scroll_Point
  999. *Routine sets up screen
  1000. move.l current_map_pointer,a0
  1001. move.w scroll_x_position,d0
  1002. move.w scroll_y_position,d1
  1003. moveq #0,d0
  1004. asr #4,d1
  1005. asr #3,d0 ;cos word map
  1006. mulu #BIGGEST_MAP_X*MAP_BLOCK_SIZE,d1
  1007. add.l d1,a0
  1008. add.l d0,a0 ;map
  1009. rts
  1010. current_map_pointer dc.l 0
  1011. current_alien_map_pointer dc.l 0
  1012. rsreset
  1013. map_file_header rs.l 1
  1014. map_blk_size rs.w 1
  1015. map_data_x rs.w 1
  1016. map_data_y rs.w 1
  1017. map_planes rs.w 1
  1018. map_datasize rs.w 1
  1019. map_data_start rs.w 1