four_way_scrollnewwank.s 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594
  1. *----------------------------SCROLL CODE----------------------
  2. WAIT_DRAW_BLOCKS EQU 0
  3. START_DRAW_BLOCKS EQU 1
  4. *-- Y OFFSETS
  5. SCROLL_GOING_DOWN EQU (-32*BPR) ;up from bottom of scroll
  6. SCROLL_GOING_UP EQU (-16*BPR)
  7. MAP_SCREEN_OFFSET_DOWN EQU (16*BIGGEST_MAP_X)
  8. MAP_SCREEN_OFFSET_UP EQU (-1*BIGGEST_MAP_X)
  9. SCROLL_POSITION_OFFSET_DOWN EQU (16*16)
  10. SCROLL_POSITION_OFFSET_UP EQU (-1*16)
  11. *-- X OFFSETS
  12. SCROLL_GOING_LEFT EQU 42
  13. SCROLL_GOING_RIGHT EQU -2
  14. MAP_SCREEN_OFFSET_LEFT EQU 21
  15. MAP_SCREEN_OFFSET_RIGHT EQU -1
  16. SCROLL_POSITION_OFFSET_LEFT EQU 21*16
  17. SCROLL_POSITION_OFFSET_RIGHT EQU -1*16
  18. total_number_of_y_blocks_to_draw dc.w 23
  19. current_y_map_position dc.w 0
  20. total_number_of_x_blocks_to_draw dc.w 18
  21. current_x_map_position dc.w 0
  22. number_of_x_blocks_per_frame dc.w 3-1
  23. number_of_y_blocks_per_frame dc.w 4-1
  24. ******************************************
  25. **** MOVE SCROLL *****
  26. ******************************************
  27. move_scroll
  28. move.w player_x_inc,d0
  29. move.w player_y_inc,d1
  30. *-Test x bounds
  31. add.w d0,scroll_x_position
  32. bge.s scroll_x_not_hit_bounds
  33. clr.w scroll_x_position
  34. bra.s scroll_x_not_hit_max_bounds
  35. scroll_x_not_hit_bounds
  36. move.w map_x_size,d3
  37. cmp.w scroll_x_position,d3
  38. bgt.s scroll_x_not_hit_max_bounds
  39. move.w d3,scroll_x_position
  40. scroll_x_not_hit_max_bounds
  41. *-<
  42. *-Test y bounds
  43. add.w d1,scroll_y_position
  44. bge.s scroll_not_hit_bounds
  45. clr.w scroll_y_position
  46. bra.s scroll_y_not_hit_max_bounds
  47. scroll_not_hit_bounds
  48. move.w map_y_size,d5
  49. cmp.w scroll_y_position,d5
  50. bgt.s scroll_y_not_hit_max_bounds
  51. move.w d5,scroll_y_position
  52. scroll_y_not_hit_max_bounds
  53. *-<
  54. move.w scroll_x_position,d0
  55. move.w scroll_y_position,d1
  56. sub.w last_scroll_x,d0
  57. sub.w last_scroll_y,d1
  58. move.w scroll_x_position,last_scroll_x
  59. move.w scroll_y_position,last_scroll_y
  60. sub.w d0,actual_x_position
  61. sub.w d1,actual_y_position
  62. movem.w d0/d1,-(sp)
  63. asl #PLAYER_SCALE,d0
  64. asl #PLAYER_SCALE,d1
  65. sub.w d0,player_x_position
  66. sub.w d1,player_y_position
  67. tst Invincible_Flag
  68. bne.s dont_display_player
  69. bra.s done_check_for_invin
  70. dont_display_player
  71. bsr Remove_Player
  72. done_check_for_invin
  73. bsr Display_Player
  74. bsr position_scroll
  75. movem.w (sp)+,d0/d1
  76. bsr check_add_blocks
  77. rts
  78. last_scroll_x dc.w 0
  79. last_scroll_y dc.w 0
  80. ******************************************
  81. **** CHECK ADD BLOCKS *****
  82. ******************************************
  83. check_add_blocks
  84. *-Do for y blocks
  85. add.w d1,check_y_add
  86. add.w d0,check_x_add
  87. tst.w y_direction_flag
  88. bne.s have_got_a_y_direction
  89. * clr.w y_ready_flag
  90. * clr.w current_y_map_position
  91. bra no_y_direction_yet
  92. have_got_a_y_direction
  93. bmi.s currently_going_up
  94. currently_going_down
  95. cmp.w #16,check_y_add
  96. blt.s check_not_smaller
  97. sub.w #16,check_y_add
  98. bne.s not_right_on_y_0
  99. clr.w y_direction_flag
  100. not_right_on_y_0
  101. bra.s no_y_direction_yet
  102. check_not_smaller
  103. tst check_y_add
  104. bge drawing_please_wait
  105. clr.w y_direction_flag ;reset drawing
  106. clr.w y_ready_flag ;stop drawing
  107. clr.w current_y_map_position
  108. bra.s no_y_direction_yet
  109. currently_going_up
  110. cmp.w #-16,check_y_add
  111. bgt.s check_not_greater
  112. add.w #16,check_y_add
  113. bne.s not_right_on_y_0_sec
  114. clr.w y_direction_flag
  115. not_right_on_y_0_sec
  116. bra.s no_y_direction_yet
  117. check_not_greater
  118. tst check_y_add
  119. blt drawing_please_wait
  120. clr.w y_direction_flag ;reset drawing
  121. clr.w y_ready_flag ;stop drawing
  122. clr.w current_y_map_position
  123. no_y_direction_yet
  124. tst.w check_y_add
  125. beq drawing_please_wait ;dont do anything
  126. bmi.s need_to_draw_for_up
  127. need_to_draw_for_down
  128. bsr output_y_val
  129. bsr output_yscroll_pos
  130. move.w #START_DRAW_BLOCKS,y_ready_flag
  131. move.w #GOING_DOWN,y_direction_flag
  132. move.w fixed_x,alien_x_pos
  133. move.w fixed_y,alien_y_pos
  134. move.l current_screen_position,current_y_screen_position
  135. move.l current_map_mem_position,current_y_map_mem_position
  136. move.l current_alien_map_mem_position,current_y_alien_map_mem_position
  137. bra.s drawing_please_wait
  138. need_to_draw_for_up
  139. bsr output_y_val
  140. bsr output_yscroll_pos
  141. move.w #START_DRAW_BLOCKS,y_ready_flag
  142. move.w #GOING_UP,y_direction_flag
  143. move.w fixed_x,alien_x_pos
  144. move.w fixed_y,alien_y_pos
  145. move.l current_screen_position,current_y_screen_position
  146. move.l current_map_mem_position,current_y_map_mem_position
  147. move.l current_alien_map_mem_position,current_y_alien_map_mem_position
  148. drawing_please_wait
  149. *-< NOW FOR X
  150. tst.w x_direction_flag
  151. bne.s have_got_an_x_direction
  152. * clr.w x_ready_flag ;stop drawing
  153. * clr.w current_x_map_position
  154. bra no_x_direction_yet
  155. have_got_an_x_direction
  156. bpl.s currently_going_left
  157. currently_going_right
  158. cmp.w #-16,check_x_add
  159. bgt.s check_x_not_greater
  160. add.w #16,check_x_add
  161. bne.s not_right_on_x_0_first
  162. clr.w x_direction_flag
  163. not_right_on_x_0_first
  164. bra.s no_x_direction_yet
  165. check_x_not_greater
  166. tst check_x_add
  167. blt finished_x_checks
  168. clr.w x_direction_flag ;reset drawing
  169. clr.w x_ready_flag ;stop drawing
  170. clr.w current_x_map_position
  171. bra.s no_x_direction_yet
  172. currently_going_left
  173. cmp.w #16,check_x_add
  174. blt.s check_x_not_smaller
  175. sub.w #16,check_x_add
  176. bne.s not_right_on_x_0
  177. clr.w x_direction_flag
  178. not_right_on_x_0
  179. bra.s no_x_direction_yet
  180. check_x_not_smaller
  181. tst.w check_x_add
  182. bge finished_x_checks
  183. clr.w x_direction_flag ;reset drawing
  184. clr.w x_ready_flag ;stop drawing
  185. clr.w current_x_map_position
  186. no_x_direction_yet
  187. tst.w check_x_add
  188. beq finished_x_checks ;dont do anything
  189. bmi.s need_to_draw_for_right
  190. need_to_draw_for_left
  191. bsr output_x_val
  192. bsr output_xscroll_pos
  193. move.w #START_DRAW_BLOCKS,x_ready_flag
  194. move.w #GOING_LEFT,x_direction_flag
  195. move.w fixed_x,alien_x_pos2
  196. move.w fixed_y,alien_y_pos2
  197. move.l current_screen_position,current_x_screen_position
  198. move.l current_map_mem_position,current_x_map_mem_position
  199. move.l current_alien_map_mem_position,current_x_alien_map_mem_position
  200. bra.s finished_x_checks
  201. need_to_draw_for_right
  202. bsr output_x_val
  203. bsr output_xscroll_pos
  204. move.w #START_DRAW_BLOCKS,x_ready_flag
  205. move.w #GOING_RIGHT,x_direction_flag
  206. move.w fixed_x,alien_x_pos2
  207. move.w fixed_y,alien_y_pos2
  208. move.l current_screen_position,current_x_screen_position
  209. move.l current_map_mem_position,current_x_map_mem_position
  210. move.l current_alien_map_mem_position,current_x_alien_map_mem_position
  211. finished_x_checks
  212. *-<
  213. rts
  214. GOING_LEFT EQU 1
  215. GOING_RIGHT EQU -1
  216. GOING_UP EQU -1
  217. GOING_DOWN EQU 1
  218. drawing_x_blocks dc.w 0
  219. drawing_y_blocks dc.w 0
  220. x_direction_flag dc.w 0
  221. y_direction_flag dc.w 0
  222. fixed_x dc.w 0
  223. fixed_y dc.w 0
  224. alien_x_pos dc.w 0
  225. alien_y_pos dc.w 0
  226. alien_x_pos2 dc.w 0
  227. alien_y_pos2 dc.w 0
  228. add_y_block_direction dc.l 0
  229. check_y_add dc.w 0
  230. y_ready_flag dc.w 0
  231. add_x_block_direction dc.l 0
  232. check_x_add dc.w 0
  233. x_ready_flag dc.w 0
  234. add_y_map_direction dc.l 0
  235. add_x_map_direction dc.l 0
  236. add_y_map_alien_direction dc.l 0
  237. add_x_map_alien_direction dc.l 0
  238. scroll_add_y_offset dc.w 0
  239. scroll_add_x_offset dc.w 0
  240. ******************************************
  241. **** POSITION SCROLL *****
  242. ******************************************
  243. position_scroll
  244. *Positions scroll by the x and y values stored
  245. move.w scroll_x_position,d0
  246. move.w scroll_y_position,d1
  247. position_scroll_along_x
  248. moveq #0,d3
  249. move.w d0,d2
  250. move.w d0,d3
  251. andi.w #$000f,d2 ;shift value
  252. move.w d2,alien_shift
  253. asr.w #4,d3 ;number of blocks in
  254. andi.w #$fff0,d0
  255. move.w d0,fixed_x
  256. asr.w #3,d0
  257. ext.l d0 ;bytes in
  258. neg.w d2
  259. add.w #15,d2
  260. move.w d2,d4
  261. asl.w #4,d2
  262. or.w d2,d4
  263. move.w d4,scroll_value
  264. position_scroll_along_y
  265. *--- get current map positions
  266. moveq #0,d2
  267. move.w d1,d2
  268. andi.w #$fff0,d2
  269. move.w d2,fixed_y
  270. move.w d1,d2
  271. asr.w #4,d2
  272. mulu #BIGGEST_MAP_X,d2
  273. move.l current_alien_map_pointer,a0
  274. add.l d2,a0 ;add y
  275. add.l d3,a0 ;add x
  276. move.l a0,current_alien_map_mem_position
  277. asl d2 ;cos map mem = word
  278. asl d3
  279. move.l current_map_pointer,a0
  280. add.l d2,a0 ;add y
  281. add.l d3,a0 ;add x
  282. move.l a0,current_map_mem_position
  283. *---
  284. ext.l d1
  285. divu #SCROLL_HEIGHT,d1
  286. swap d1 ;this is all we want - split position down screen
  287. neg.w d1 ;so scroll goes right way
  288. add.w #SCROLL_HEIGHT,d1
  289. move.w d1,split_position
  290. *---calc where to draw
  291. moveq #0,d3
  292. move.w #SCROLL_HEIGHT,d3 ;position above buffer area
  293. sub.w d1,d3 ;position of buffer area
  294. andi.w #$fff0,d3
  295. mulu #BPR,d3
  296. add.l scroll_area,d3
  297. add.l d0,d3 ;add x in
  298. move.l d3,current_screen_position
  299. *------
  300. move.w d1,d2
  301. add.w #$2c,d1
  302. moveq #0,d4
  303. cmp.w #$ff,d1
  304. ble.s not_over_dodgy_line
  305. moveq #1,d4
  306. not_over_dodgy_line
  307. cmp.w #$ff+$2c-16,d1
  308. ble.s not_off_copper
  309. move.w #-1,d4
  310. bra.s calc_screen_split
  311. not_off_copper
  312. andi.w #$ff,d1 ;so values wraps round
  313. asl.w #8,d1
  314. addq.w #1,d1 ; = wait value
  315. calc_screen_split
  316. neg.w d2
  317. add.w #SCROLL_HEIGHT,d2
  318. mulu #BPR,d2
  319. ext.l d2
  320. move.l d2,d5
  321. add.l buff_plane1,d5
  322. add.l plane1,d2 ;to display at top
  323. move.l plane1,d3 ;top display at split
  324. add.l d0,d2 ;add x in
  325. add.l d0,d5
  326. move.l d5,current_alien_draw_position
  327. move.l buff_plane1,d5
  328. add.l d0,d5
  329. move.l d5,current_alien_split_draw_position
  330. add.l d0,d3 ;add x in
  331. bsr insert_plane_pointers
  332. rts
  333. ******************************************
  334. **** INSERT PLANE POINTERS *****
  335. ******************************************
  336. insert_plane_pointers
  337. *d1 contains wait value
  338. *d2 = top of display
  339. *d3 = split part of display
  340. *d4 indicates if inserting after 255 gap
  341. tst d4
  342. bmi clear_all_banks
  343. beq.s insert_before_line
  344. insert_after_line
  345. move.l #scroll_bank_2,a0
  346. move.l #scroll_bank_1,a1
  347. bsr fill_banks
  348. rts
  349. insert_before_line
  350. move.l #scroll_bank_1,a0
  351. move.l #scroll_bank_2,a1
  352. bsr fill_banks
  353. rts
  354. clear_all_banks
  355. move.l #scroll_bank_1,a0
  356. move.l #scroll_bank_2,a1
  357. bsr clear_banks
  358. rts
  359. ******************************************
  360. **** FILL BANKS *****
  361. ******************************************
  362. fill_banks
  363. *a0 = bank to fill
  364. *a1 = bank to clear
  365. *d1 = wait
  366. *d2 = top of display
  367. *d3 = split display
  368. *change to copper jump later - but get it working first!!!
  369. * IN USE SPLIT POINTERS
  370. move.w d1,wait_pos(a0)
  371. move.w #$fffe,wait_mask(a0)
  372. move.w #$e2,plane_1_lo_ptr(a0)
  373. move.w d3,plane_1_lo_val(a0)
  374. swap d3
  375. move.w #$e0,plane_1_hi_ptr(a0)
  376. move.w d3,plane_1_hi_val(a0)
  377. swap d3
  378. add.l #PLANE_INC,d3
  379. move.w #$e6,plane_2_lo_ptr(a0)
  380. move.w d3,plane_2_lo_val(a0)
  381. swap d3
  382. move.w #$e4,plane_2_hi_ptr(a0)
  383. move.w d3,plane_2_hi_val(a0)
  384. swap d3
  385. add.l #PLANE_INC,d3
  386. move.w #$ea,plane_3_lo_ptr(a0)
  387. move.w d3,plane_3_lo_val(a0)
  388. swap d3
  389. move.w #$e8,plane_3_hi_ptr(a0)
  390. move.w d3,plane_3_hi_val(a0)
  391. swap d3
  392. add.l #PLANE_INC,d3
  393. move.w #$ee,plane_4_lo_ptr(a0)
  394. move.w d3,plane_4_lo_val(a0)
  395. swap d3
  396. move.w #$ec,plane_4_hi_ptr(a0)
  397. move.w d3,plane_4_hi_val(a0)
  398. * UNUSED SET OF SPLIT POINTERS
  399. move.w #$1f0,wait_pos(a1)
  400. move.w #$1f0,plane_1_hi_ptr(a1)
  401. move.w #$1f0,plane_1_lo_ptr(a1)
  402. move.w #$1f0,plane_2_hi_ptr(a1)
  403. move.w #$1f0,plane_2_lo_ptr(a1)
  404. move.w #$1f0,plane_3_hi_ptr(a1)
  405. move.w #$1f0,plane_3_lo_ptr(a1)
  406. move.w #$1f0,plane_4_hi_ptr(a1)
  407. move.w #$1f0,plane_4_lo_ptr(a1)
  408. * TOP OF SCREEN
  409. move.l #top_of_screen-4,a0 ;so rs.w's work
  410. move.w d2,plane_1_lo_val(a0)
  411. swap d2
  412. move.w d2,plane_1_hi_val(a0)
  413. swap d2
  414. add.l #PLANE_INC,d2
  415. move.w d2,plane_2_lo_val(a0)
  416. swap d2
  417. move.w d2,plane_2_hi_val(a0)
  418. swap d2
  419. add.l #PLANE_INC,d2
  420. move.w d2,plane_3_lo_val(a0)
  421. swap d2
  422. move.w d2,plane_3_hi_val(a0)
  423. swap d2
  424. add.l #PLANE_INC,d2
  425. move.w d2,plane_4_lo_val(a0)
  426. swap d2
  427. move.w d2,plane_4_hi_val(a0)
  428. rts
  429. ******************************************
  430. **** CLEAR BANKS *****
  431. ******************************************
  432. clear_banks
  433. * UNUSED SET OF SPLIT POINTERS 1
  434. move.w #$1f0,wait_pos(a1)
  435. move.w #$1f0,plane_1_hi_ptr(a1)
  436. move.w #$1f0,plane_1_lo_ptr(a1)
  437. move.w #$1f0,plane_2_hi_ptr(a1)
  438. move.w #$1f0,plane_2_lo_ptr(a1)
  439. move.w #$1f0,plane_3_hi_ptr(a1)
  440. move.w #$1f0,plane_3_lo_ptr(a1)
  441. move.w #$1f0,plane_4_hi_ptr(a1)
  442. move.w #$1f0,plane_4_lo_ptr(a1)
  443. * UNUSED SET OF SPLIT POINTERS 2
  444. move.w #$1f0,wait_pos(a0)
  445. move.w #$1f0,plane_1_hi_ptr(a0)
  446. move.w #$1f0,plane_1_lo_ptr(a0)
  447. move.w #$1f0,plane_2_hi_ptr(a0)
  448. move.w #$1f0,plane_2_lo_ptr(a0)
  449. move.w #$1f0,plane_3_hi_ptr(a0)
  450. move.w #$1f0,plane_3_lo_ptr(a0)
  451. move.w #$1f0,plane_4_hi_ptr(a0)
  452. move.w #$1f0,plane_4_lo_ptr(a0)
  453. * TOP OF SCREEN
  454. move.l #top_of_screen-4,a0 ;so rs.w's work
  455. move.w d2,plane_1_lo_val(a0)
  456. swap d2
  457. move.w d2,plane_1_hi_val(a0)
  458. swap d2
  459. add.l #PLANE_INC,d2
  460. move.w d2,plane_2_lo_val(a0)
  461. swap d2
  462. move.w d2,plane_2_hi_val(a0)
  463. swap d2
  464. add.l #PLANE_INC,d2
  465. move.w d2,plane_3_lo_val(a0)
  466. swap d2
  467. move.w d2,plane_3_hi_val(a0)
  468. swap d2
  469. add.l #PLANE_INC,d2
  470. move.w d2,plane_4_lo_val(a0)
  471. swap d2
  472. move.w d2,plane_4_hi_val(a0)
  473. rts
  474. scroll_x_position dc.w 0
  475. scroll_y_position dc.w 0
  476. split_position dc.w 0
  477. **********************************************************
  478. *********** DRAW BLOCKS FOR SCROLL ***********
  479. **********************************************************
  480. draw_blocks_for_scroll
  481. tst.w y_ready_flag
  482. beq.s see_if_x_to_draw
  483. move.l current_y_screen_position,a0
  484. move.l current_y_map_mem_position,a1
  485. move.l current_y_alien_map_mem_position,a4
  486. bsr draw_y_blocks
  487. see_if_x_to_draw
  488. tst.w x_ready_flag
  489. beq.s quit_draw_blocks_for_scroll
  490. move.l current_x_screen_position,a0
  491. move.l current_x_map_mem_position,a1
  492. move.l current_x_alien_map_mem_position,a4
  493. bsr draw_x_blocks
  494. quit_draw_blocks_for_scroll
  495. rts
  496. current_screen_position dc.l 0
  497. current_y_screen_position dc.l 0
  498. current_x_screen_position dc.l 0
  499. current_map_mem_position dc.l 0
  500. current_alien_map_mem_position dc.l 0
  501. current_x_map_mem_position dc.l 0
  502. current_y_map_mem_position dc.l 0
  503. current_x_alien_map_mem_position dc.l 0
  504. current_y_alien_map_mem_position dc.l 0
  505. **********************************************************
  506. *********** DRAW Y BLOCKS ***********
  507. **********************************************************
  508. draw_y_blocks
  509. *current screen mem position in a0
  510. *current map position in a1
  511. tst.w y_direction_flag
  512. bmi.s scroll_moving_up
  513. scroll_moving_down
  514. add.l #SCROLL_GOING_DOWN,a0
  515. add.l #MAP_SCREEN_OFFSET_DOWN*MAP_BLOCK_SIZE,a1
  516. add.l #MAP_SCREEN_OFFSET_DOWN,a4
  517. move.w #SCROLL_POSITION_OFFSET_DOWN,d6
  518. bra.s finished_adding_y_offsets
  519. scroll_moving_up
  520. add.l #SCROLL_GOING_UP,a0
  521. add.l #MAP_SCREEN_OFFSET_UP*MAP_BLOCK_SIZE,a1
  522. add.l #MAP_SCREEN_OFFSET_UP,a4
  523. move.w #SCROLL_POSITION_OFFSET_UP,d6
  524. finished_adding_y_offsets
  525. cmp.l scroll_area,a0
  526. bge.s draw_inside_plane_area
  527. add.l #SCROLL_HEIGHT*BPR,a0
  528. draw_inside_plane_area
  529. *-- Following bit is a bit confusing:
  530. tst.w x_direction_flag
  531. bge.s wank_bollox
  532. tst y_direction_flag
  533. bpl.s wank_bollox
  534. subq.l #2*MAP_BLOCK_SIZE,a1
  535. subq.l #2,a4
  536. subq.l #4,a0
  537. move.w #-32,d5
  538. bra.s shit_cunt
  539. wank_bollox
  540. subq.l #1*MAP_BLOCK_SIZE,a1
  541. subq.l #1,a4
  542. subq.l #2,a0
  543. move.w #-16,d5
  544. shit_cunt
  545. *-<
  546. draw_blocks_main
  547. *---Set up start x and y values
  548. add.w alien_x_pos,d5
  549. add.w alien_y_pos,d6
  550. *----
  551. move.l Alien_Add_List_Pointer,a5
  552. moveq #0,d0
  553. move.w current_y_map_position,d0
  554. ext.l d0
  555. add.l d0,a4 ;current alien map position
  556. asl d0 ;cos map data = word
  557. add.l d0,a1 ;current map position
  558. add.l d0,a0 ;get to current line
  559. asl #3,d0
  560. add.w d0,d5 ;current add x position
  561. move.l a0,start_draw_pos ;store for buff write
  562. move.w total_number_of_y_blocks_to_draw,d2
  563. moveq #0,d7 ;count number of blocks drawn
  564. init_blit_values
  565. btst #14,dmaconr(a6)
  566. bne.s init_blit_values
  567. move.w #BPR-2,bltdmod(a6)
  568. move.w #0,bltamod(a6)
  569. move.l #$ffffffff,bltafwm(a6)
  570. move.l #$09F00000,bltcon0(A6)
  571. move.w number_of_y_blocks_per_frame,d0
  572. draw_loop
  573. move.l level_background_blocks,a2
  574. moveq #0,d1
  575. *--- Adding aliens from map
  576. move.b (a4),d1
  577. beq.s alien_already_in_map
  578. btst #ALIEN_BUSY,d1
  579. bne.s alien_already_in_map
  580. move.l a4,Add_Map_Position(a5)
  581. move.w d5,Add_X_Position(a5)
  582. move.w d6,Add_Y_Position(a5)
  583. move.w d1,Add_Alien_number(a5)
  584. add.l #Add_Struct_Size,a5
  585. bset.b #ALIEN_BUSY,(a4)
  586. alien_already_in_map
  587. *--- Done adding for this block
  588. move.w (a1),d1
  589. asl.w #7,d1 ;same as mulu (16*2)*4
  590. add.l d1,a2 ;get to correct position in block data
  591. *Messy to look at but faster than 68000 - only very marginally
  592. *slower than blitter and map blocks can be in fast mem!!
  593. move.l a0,a3
  594. move.w (a2)+,(a3)
  595. move.w (a2)+,BPR(a3)
  596. move.w (a2)+,BPR*2(a3)
  597. move.w (a2)+,BPR*3(a3)
  598. move.w (a2)+,BPR*4(a3)
  599. move.w (a2)+,BPR*5(a3)
  600. move.w (a2)+,BPR*6(a3)
  601. move.w (a2)+,BPR*7(a3)
  602. move.w (a2)+,BPR*8(a3)
  603. move.w (a2)+,BPR*9(a3)
  604. move.w (a2)+,BPR*10(a3)
  605. move.w (a2)+,BPR*11(a3)
  606. move.w (a2)+,BPR*12(a3)
  607. move.w (a2)+,BPR*13(a3)
  608. move.w (a2)+,BPR*14(a3)
  609. move.w (a2)+,BPR*15(a3)
  610. add.l #PLANE_INC,a3
  611. move.w (a2)+,(a3)
  612. move.w (a2)+,BPR(a3)
  613. move.w (a2)+,BPR*2(a3)
  614. move.w (a2)+,BPR*3(a3)
  615. move.w (a2)+,BPR*4(a3)
  616. move.w (a2)+,BPR*5(a3)
  617. move.w (a2)+,BPR*6(a3)
  618. move.w (a2)+,BPR*7(a3)
  619. move.w (a2)+,BPR*8(a3)
  620. move.w (a2)+,BPR*9(a3)
  621. move.w (a2)+,BPR*10(a3)
  622. move.w (a2)+,BPR*11(a3)
  623. move.w (a2)+,BPR*12(a3)
  624. move.w (a2)+,BPR*13(a3)
  625. move.w (a2)+,BPR*14(a3)
  626. move.w (a2)+,BPR*15(a3)
  627. add.l #PLANE_INC,a3
  628. move.w (a2)+,(a3)
  629. move.w (a2)+,BPR(a3)
  630. move.w (a2)+,BPR*2(a3)
  631. move.w (a2)+,BPR*3(a3)
  632. move.w (a2)+,BPR*4(a3)
  633. move.w (a2)+,BPR*5(a3)
  634. move.w (a2)+,BPR*6(a3)
  635. move.w (a2)+,BPR*7(a3)
  636. move.w (a2)+,BPR*8(a3)
  637. move.w (a2)+,BPR*9(a3)
  638. move.w (a2)+,BPR*10(a3)
  639. move.w (a2)+,BPR*11(a3)
  640. move.w (a2)+,BPR*12(a3)
  641. move.w (a2)+,BPR*13(a3)
  642. move.w (a2)+,BPR*14(a3)
  643. move.w (a2)+,BPR*15(a3)
  644. add.l #PLANE_INC,a3
  645. move.w (a2)+,(a3)
  646. move.w (a2)+,BPR(a3)
  647. move.w (a2)+,BPR*2(a3)
  648. move.w (a2)+,BPR*3(a3)
  649. move.w (a2)+,BPR*4(a3)
  650. move.w (a2)+,BPR*5(a3)
  651. move.w (a2)+,BPR*6(a3)
  652. move.w (a2)+,BPR*7(a3)
  653. move.w (a2)+,BPR*8(a3)
  654. move.w (a2)+,BPR*9(a3)
  655. move.w (a2)+,BPR*10(a3)
  656. move.w (a2)+,BPR*11(a3)
  657. move.w (a2)+,BPR*12(a3)
  658. move.w (a2)+,BPR*13(a3)
  659. move.w (a2)+,BPR*14(a3)
  660. move.w (a2)+,BPR*15(a3)
  661. done_a_block
  662. add.w #16,d5 ;x position of block
  663. addq.l #2,a0 ;next block position along screen
  664. addq.l #2,a1 ;next map position
  665. addq.l #1,a4 ;next alien map position
  666. addq.w #1,current_y_map_position
  667. addq.w #1,d7 ;count number blocks drawn
  668. cmp.w current_y_map_position,d2
  669. bne.s not_yet_done_line
  670. clr current_y_map_position
  671. move.w #WAIT_DRAW_BLOCKS,y_ready_flag ;done our line now wait for screen to scroll 16
  672. bra.s done_all_blocks
  673. not_yet_done_line
  674. dbra d0,draw_loop
  675. done_all_blocks
  676. move.w #-1,(a5) ;end add list
  677. move.l a5,Alien_Add_List_Pointer
  678. *------------------Draw y blocks into buffer--------------
  679. move.l start_draw_pos,a5 ;source positiion
  680. move.l a5,a4
  681. add.l #PLANE_INC*4,a5 ;buff position
  682. move.l a5,a3
  683. add.l #PLANE_INC*4,a3
  684. move.w #BPR,d0
  685. move.w d7,d1
  686. asl d1
  687. sub.w d1,d0 ;modulus
  688. add.w #16<<6,d7 ;blitsize
  689. wait_y_buff_start
  690. btst #14,dmaconr(a6)
  691. bne.s wait_y_buff_start
  692. move.w d0,bltamod(a6)
  693. move.w d0,bltdmod(a6)
  694. move.l a4,bltapth(a6)
  695. move.l a5,bltdpth(a6)
  696. move.w d7,bltsize(a6)
  697. draw_y_copy1
  698. btst #14,dmaconr(a6)
  699. bne.s draw_y_copy1
  700. move.l a3,bltdpth(a6)
  701. move.l a4,bltapth(a6)
  702. move.w d7,bltsize(a6)
  703. add.l #PLANE_INC,a4
  704. add.l #PLANE_INC,a5
  705. add.l #PLANE_INC,a3
  706. y_buff_block_p2
  707. btst #14,dmaconr(a6)
  708. bne.s y_buff_block_p2
  709. move.l a4,bltapth(a6)
  710. move.l a5,bltdpth(a6)
  711. move.w d7,bltsize(a6)
  712. draw_y_copy2
  713. btst #14,dmaconr(a6)
  714. bne.s draw_y_copy2
  715. move.l a3,bltdpth(a6)
  716. move.l a4,bltapth(a6)
  717. move.w d7,bltsize(a6)
  718. add.l #PLANE_INC,a4
  719. add.l #PLANE_INC,a5
  720. add.l #PLANE_INC,a3
  721. y_buff_block_p3
  722. btst #14,dmaconr(a6)
  723. bne.s y_buff_block_p3
  724. move.l a4,bltapth(a6)
  725. move.l a5,bltdpth(a6)
  726. move.w d7,bltsize(a6)
  727. draw_y_copy3
  728. btst #14,dmaconr(a6)
  729. bne.s draw_y_copy3
  730. move.l a3,bltdpth(a6)
  731. move.l a4,bltapth(a6)
  732. move.w d7,bltsize(a6)
  733. add.l #PLANE_INC,a4
  734. add.l #PLANE_INC,a5
  735. add.l #PLANE_INC,a3
  736. y_buff_block_p4
  737. btst #14,dmaconr(a6)
  738. bne.s y_buff_block_p4
  739. move.l a4,bltapth(a6)
  740. move.l a5,bltdpth(a6)
  741. move.w d7,bltsize(a6)
  742. draw_y_copy4
  743. btst #14,dmaconr(a6)
  744. bne.s draw_y_copy4
  745. move.l a3,bltdpth(a6)
  746. move.l a4,bltapth(a6)
  747. move.w d7,bltsize(a6)
  748. rts
  749. start_draw_pos dc.l 0
  750. **********************************************************
  751. *********** DRAW X BLOCKS ***********
  752. **********************************************************
  753. draw_x_blocks
  754. *current screen mem position in a0
  755. *current map position in a1
  756. tst.w x_direction_flag
  757. bgt.s scroll_moving_left
  758. scroll_moving_right
  759. add.l #SCROLL_GOING_RIGHT,a0
  760. add.l #MAP_SCREEN_OFFSET_RIGHT*MAP_BLOCK_SIZE,a1
  761. add.l #MAP_SCREEN_OFFSET_RIGHT,a4
  762. move.w #SCROLL_POSITION_OFFSET_RIGHT,d4
  763. bra.s done_adding_x_offsets
  764. scroll_moving_left
  765. add.l #SCROLL_GOING_LEFT,a0
  766. add.l #MAP_SCREEN_OFFSET_LEFT*MAP_BLOCK_SIZE,a1
  767. add.l #MAP_SCREEN_OFFSET_LEFT,a4
  768. move.w #SCROLL_POSITION_OFFSET_LEFT,d4
  769. done_adding_x_offsets
  770. tst.w y_direction_flag
  771. bge.s suck_cock
  772. tst.w x_direction_flag
  773. bpl.s suck_cock
  774. sub.l #32*BPR,a0
  775. sub.l #(BIGGEST_MAP_X*2)*MAP_BLOCK_SIZE,a1
  776. sub.l #BIGGEST_MAP_X*2,a4
  777. move.w #-32,d5
  778. bra.s piss_cunt
  779. suck_cock
  780. sub.l #16*BPR,a0
  781. sub.l #(BIGGEST_MAP_X*1)*MAP_BLOCK_SIZE,a1
  782. sub.l #BIGGEST_MAP_X*1,a4
  783. move.w #-16,d5
  784. piss_cunt
  785. draw_x_blocks_straight
  786. *---Set up start x and y values
  787. add.w alien_x_pos2,d4
  788. add.w alien_y_pos2,d5
  789. *----
  790. move.l Alien_Add_List_Pointer,a5
  791. moveq #0,d0
  792. moveq #0,d6
  793. move.w current_x_map_position,d0
  794. move.w d0,d1
  795. mulu #BIGGEST_MAP_X,d0
  796. add.l d0,a4 ;get to current line in alien map
  797. asl d0 ;cos map data = word
  798. add.l d0,a1 ;get to current line
  799. asl #4,d1
  800. add.w d1,d5 ;current y position on screen
  801. mulu #BPR,d1 ;way BPR*16 but already done *16
  802. add.l d1,a0 ;current screen block position
  803. *Check that we are not trying to draw above scroll (remember we are
  804. * subtracting values so blocks are drawn at bottom first)
  805. move.l scroll_area,a3 ;top of scroll area
  806. cmp.l a3,a0
  807. bge.s within_plane_still
  808. add.l #SCROLL_HEIGHT*BPR,a0
  809. bra.s test2
  810. within_plane_still
  811. add.l #SCROLL_HEIGHT*BPR,a3
  812. cmp.l a3,a0
  813. blt.s test2
  814. sub.l #SCROLL_HEIGHT*BPR,a0
  815. test2
  816. move.l a0,start_draw_pos ;for buff purposes
  817. move.w total_number_of_x_blocks_to_draw,d2
  818. moveq #0,d7 ;count number of blocks drawn
  819. init_x_blit_values
  820. btst #14,dmaconr(a6)
  821. bne.s init_x_blit_values
  822. move.w #BPR-2,bltdmod(a6)
  823. move.w #0,bltamod(a6)
  824. move.l #$ffffffff,bltafwm(a6)
  825. move.l #$09F00000,bltcon0(A6)
  826. move.w number_of_x_blocks_per_frame,d0
  827. draw_x_loop
  828. move.l level_background_blocks,a2
  829. moveq #0,d1
  830. *--- Adding aliens from map
  831. move.b (a4),d1
  832. beq.s alien_x_already_in_map
  833. btst #ALIEN_BUSY,d1
  834. bne.s alien_x_already_in_map
  835. move.l a4,Add_Map_Position(a5)
  836. move.w d4,Add_X_Position(a5)
  837. move.w d5,Add_Y_Position(a5)
  838. move.w d1,Add_Alien_number(a5)
  839. add.l #Add_Struct_Size,a5
  840. bset.b #ALIEN_BUSY,(a4)
  841. alien_x_already_in_map
  842. *--- Done adding for this block
  843. move.w (a1),d1
  844. * moveq #1,d1
  845. asl.w #7,d1 ;same as mulu (16*2)*4
  846. add.l d1,a2 ;get to correct position in block data
  847. move.l a0,a3
  848. move.w (a2)+,(a3)
  849. move.w (a2)+,BPR(a3)
  850. move.w (a2)+,BPR*2(a3)
  851. move.w (a2)+,BPR*3(a3)
  852. move.w (a2)+,BPR*4(a3)
  853. move.w (a2)+,BPR*5(a3)
  854. move.w (a2)+,BPR*6(a3)
  855. move.w (a2)+,BPR*7(a3)
  856. move.w (a2)+,BPR*8(a3)
  857. move.w (a2)+,BPR*9(a3)
  858. move.w (a2)+,BPR*10(a3)
  859. move.w (a2)+,BPR*11(a3)
  860. move.w (a2)+,BPR*12(a3)
  861. move.w (a2)+,BPR*13(a3)
  862. move.w (a2)+,BPR*14(a3)
  863. move.w (a2)+,BPR*15(a3)
  864. add.l #PLANE_INC,a3
  865. move.w (a2)+,(a3)
  866. move.w (a2)+,BPR(a3)
  867. move.w (a2)+,BPR*2(a3)
  868. move.w (a2)+,BPR*3(a3)
  869. move.w (a2)+,BPR*4(a3)
  870. move.w (a2)+,BPR*5(a3)
  871. move.w (a2)+,BPR*6(a3)
  872. move.w (a2)+,BPR*7(a3)
  873. move.w (a2)+,BPR*8(a3)
  874. move.w (a2)+,BPR*9(a3)
  875. move.w (a2)+,BPR*10(a3)
  876. move.w (a2)+,BPR*11(a3)
  877. move.w (a2)+,BPR*12(a3)
  878. move.w (a2)+,BPR*13(a3)
  879. move.w (a2)+,BPR*14(a3)
  880. move.w (a2)+,BPR*15(a3)
  881. add.l #PLANE_INC,a3
  882. move.w (a2)+,(a3)
  883. move.w (a2)+,BPR(a3)
  884. move.w (a2)+,BPR*2(a3)
  885. move.w (a2)+,BPR*3(a3)
  886. move.w (a2)+,BPR*4(a3)
  887. move.w (a2)+,BPR*5(a3)
  888. move.w (a2)+,BPR*6(a3)
  889. move.w (a2)+,BPR*7(a3)
  890. move.w (a2)+,BPR*8(a3)
  891. move.w (a2)+,BPR*9(a3)
  892. move.w (a2)+,BPR*10(a3)
  893. move.w (a2)+,BPR*11(a3)
  894. move.w (a2)+,BPR*12(a3)
  895. move.w (a2)+,BPR*13(a3)
  896. move.w (a2)+,BPR*14(a3)
  897. move.w (a2)+,BPR*15(a3)
  898. add.l #PLANE_INC,a3
  899. move.w (a2)+,(a3)
  900. move.w (a2)+,BPR(a3)
  901. move.w (a2)+,BPR*2(a3)
  902. move.w (a2)+,BPR*3(a3)
  903. move.w (a2)+,BPR*4(a3)
  904. move.w (a2)+,BPR*5(a3)
  905. move.w (a2)+,BPR*6(a3)
  906. move.w (a2)+,BPR*7(a3)
  907. move.w (a2)+,BPR*8(a3)
  908. move.w (a2)+,BPR*9(a3)
  909. move.w (a2)+,BPR*10(a3)
  910. move.w (a2)+,BPR*11(a3)
  911. move.w (a2)+,BPR*12(a3)
  912. move.w (a2)+,BPR*13(a3)
  913. move.w (a2)+,BPR*14(a3)
  914. move.w (a2)+,BPR*15(a3)
  915. done_x_block
  916. add.w #16,d5 ;current y pixel position
  917. add.l #BPR*16,a0
  918. *Cant go off top only bottom so thats the only check
  919. move.l scroll_area,a3
  920. add.l #SCROLL_HEIGHT*BPR,a3
  921. cmp.l a3,a0
  922. blt.s have_not_gone_off_scroll_bottom
  923. move.w d7,d6 ;point where split
  924. addq.w #1,d6
  925. sub.l #SCROLL_HEIGHT*BPR,a0
  926. have_not_gone_off_scroll_bottom
  927. add.l #BIGGEST_MAP_X*MAP_BLOCK_SIZE,a1
  928. add.l #BIGGEST_MAP_X,a4
  929. addq.w #1,current_x_map_position
  930. addq.w #1,d7 ;count number blocks drawn
  931. cmp.w current_x_map_position,d2
  932. bne.s not_yet_done_x_line
  933. clr current_x_map_position
  934. move.w #WAIT_DRAW_BLOCKS,x_ready_flag ;done our line now wait for screen to scroll 16
  935. bra.s done_all_x_blocks
  936. not_yet_done_x_line
  937. dbra d0,draw_x_loop
  938. done_all_x_blocks
  939. move.w #-1,(a5) ;end add list
  940. move.l a5,Alien_Add_List_Pointer
  941. *----------------Now do one big blit to buffer areas---------------
  942. *need to know if wrapped - so have to do two blits
  943. move.l start_draw_pos,a4
  944. move.l a4,a0
  945. buff_wait_fin
  946. btst #14,dmaconr(a6)
  947. bne.s buff_wait_fin
  948. move.w #BPR-2,bltamod(a6)
  949. move.l a4,a5
  950. add.l #PLANE_INC*4,a4 ;buff start position
  951. move.l a4,a3
  952. add.l #PLANE_INC*4,a3 ;copyback area
  953. moveq #0,d0
  954. tst d6
  955. beq.s no_split_occured
  956. move.w d7,d0 ;number of blocks to draw
  957. sub.w d6,d0 ;blocks after split
  958. move.w d6,d7
  959. no_split_occured
  960. move.l a4,bltdpth(a6) ;screen
  961. move.l a5,bltapth(a6) ;graphics
  962. asl.w #4,d7 ;height of blocks
  963. asl.w #6,d7
  964. addq.w #1,d7
  965. move.w d7,bltsize(a6)
  966. draw_x_copy1
  967. btst #14,dmaconr(a6)
  968. bne.s draw_x_copy1
  969. move.l a3,bltdpth(a6)
  970. move.l a4,bltapth(a6)
  971. move.w d7,bltsize(a6)
  972. add.l #PLANE_INC,a4
  973. add.l #PLANE_INC,a5
  974. add.l #PLANE_INC,a3
  975. draw_x_buff2
  976. btst #14,dmaconr(a6)
  977. bne.s draw_x_buff2
  978. move.l a4,bltdpth(a6)
  979. move.l a5,bltapth(a6)
  980. move.w d7,bltsize(a6)
  981. draw_x_copy2
  982. btst #14,dmaconr(a6)
  983. bne.s draw_x_copy2
  984. move.l a3,bltdpth(a6)
  985. move.l a4,bltapth(a6)
  986. move.w d7,bltsize(a6)
  987. add.l #PLANE_INC,a4
  988. add.l #PLANE_INC,a5
  989. add.l #PLANE_INC,a3
  990. draw_x_buff3
  991. btst #14,dmaconr(a6)
  992. bne.s draw_x_buff3
  993. move.l a4,bltdpth(a6)
  994. move.l a5,bltapth(a6)
  995. move.w d7,bltsize(a6)
  996. draw_x_copy3
  997. btst #14,dmaconr(a6)
  998. bne.s draw_x_copy3
  999. move.l a3,bltdpth(a6)
  1000. move.l a4,bltapth(a6)
  1001. move.w d7,bltsize(a6)
  1002. add.l #PLANE_INC,a4
  1003. add.l #PLANE_INC,a5
  1004. add.l #PLANE_INC,a3
  1005. draw_x_buff4
  1006. btst #14,dmaconr(a6)
  1007. bne.s draw_x_buff4
  1008. move.l a4,bltdpth(a6)
  1009. move.l a5,bltapth(a6)
  1010. move.w d7,bltsize(a6)
  1011. draw_x_copy4
  1012. btst #14,dmaconr(a6)
  1013. bne.s draw_x_copy4
  1014. move.l a3,bltdpth(a6)
  1015. move.l a4,bltapth(a6)
  1016. move.w d7,bltsize(a6)
  1017. tst d0
  1018. beq no_need_to_draw_more_blocks
  1019. move.l a0,a5
  1020. asl.w #4,d6
  1021. mulu #BPR,d6
  1022. add.l d6,a5
  1023. sub.l #SCROLL_HEIGHT*BPR,a5
  1024. move.l a5,a4
  1025. add.l #PLANE_INC*4,a4
  1026. move.l a4,a3
  1027. add.l #PLANE_INC*4,a3
  1028. move.w d0,d7 ;blocks after split
  1029. draw_x_buff1_split
  1030. btst #14,dmaconr(a6)
  1031. bne.s draw_x_buff1_split
  1032. move.l a4,bltdpth(a6) ;screen
  1033. move.l a5,bltapth(a6) ;graphics
  1034. asl.w #4,d7 ;height of blocks
  1035. asl.w #6,d7
  1036. addq.w #1,d7
  1037. move.w d7,bltsize(a6)
  1038. draw_x_copy1_split
  1039. btst #14,dmaconr(a6)
  1040. bne.s draw_x_copy1_split
  1041. move.l a3,bltdpth(a6)
  1042. move.l a4,bltapth(a6)
  1043. move.w d7,bltsize(a6)
  1044. add.l #PLANE_INC,a4
  1045. add.l #PLANE_INC,a5
  1046. add.l #PLANE_INC,a3
  1047. draw_x_buff2_split
  1048. btst #14,dmaconr(a6)
  1049. bne.s draw_x_buff2_split
  1050. move.l a4,bltdpth(a6)
  1051. move.l a5,bltapth(a6)
  1052. move.w d7,bltsize(a6)
  1053. draw_x_copy2_split
  1054. btst #14,dmaconr(a6)
  1055. bne.s draw_x_copy2_split
  1056. move.l a3,bltdpth(a6)
  1057. move.l a4,bltapth(a6)
  1058. move.w d7,bltsize(a6)
  1059. add.l #PLANE_INC,a4
  1060. add.l #PLANE_INC,a5
  1061. add.l #PLANE_INC,a3
  1062. draw_x_buff3_split
  1063. btst #14,dmaconr(a6)
  1064. bne.s draw_x_buff3_split
  1065. move.l a4,bltdpth(a6)
  1066. move.l a5,bltapth(a6)
  1067. move.w d7,bltsize(a6)
  1068. draw_x_copy3_split
  1069. btst #14,dmaconr(a6)
  1070. bne.s draw_x_copy3_split
  1071. move.l a3,bltdpth(a6)
  1072. move.l a4,bltapth(a6)
  1073. move.w d7,bltsize(a6)
  1074. add.l #PLANE_INC,a4
  1075. add.l #PLANE_INC,a5
  1076. add.l #PLANE_INC,a3
  1077. draw_x_buff4_split
  1078. btst #14,dmaconr(a6)
  1079. bne.s draw_x_buff4_split
  1080. move.l a4,bltdpth(a6)
  1081. move.l a5,bltapth(a6)
  1082. move.w d7,bltsize(a6)
  1083. draw_x_copy4_split
  1084. btst #14,dmaconr(a6)
  1085. bne.s draw_x_copy4_split
  1086. move.l a3,bltdpth(a6)
  1087. move.l a4,bltapth(a6)
  1088. move.w d7,bltsize(a6)
  1089. no_need_to_draw_more_blocks
  1090. rts
  1091. ********************************************************
  1092. **** FILL SCREEN WITH BLOCKS ****
  1093. ********************************************************
  1094. fill_screen_with_blocks
  1095. *send in d0 and d1 as the x and y
  1096. *--
  1097. move.l #Alien_Add_List,Alien_Add_List_Pointer
  1098. move.w d0,scroll_x_position
  1099. move.w d1,scroll_y_position
  1100. move.w d0,last_scroll_x
  1101. move.w d1,last_scroll_y
  1102. bsr Position_Scroll
  1103. *--
  1104. *-- SET UP ALIEN ADD POSITIONS
  1105. clr.w scroll_add_y_offset
  1106. clr.w scroll_add_x_offset
  1107. sub.w #32,fixed_y ;position on screen properly
  1108. add.w #32,fixed_x ;position on screen properly
  1109. move.w fixed_x,alien_x_pos
  1110. move.w fixed_y,alien_y_pos
  1111. move.w fixed_x,alien_x_pos2
  1112. move.w fixed_y,alien_y_pos2
  1113. move.l current_alien_draw_position,a0
  1114. move.l current_map_mem_position,a1
  1115. move.l current_alien_map_mem_position,a4 ;just so no crash
  1116. sub.l #PLANE_INC*4,a0 ;cos buff
  1117. *--Position back two lines to fill gap above
  1118. tst scroll_y_position
  1119. beq.s dont_do_extra2
  1120. sub.l #(BPR*16)*2,a0
  1121. cmp.l plane1,a0
  1122. bge.s not_wrapped_off
  1123. add.l #SCROLL_HEIGHT*BPR,a0
  1124. not_wrapped_off
  1125. sub.l #(2*BIGGEST_MAP_X)*MAP_BLOCK_SIZE,a1
  1126. sub.l #2*BIGGEST_MAP_X,a4
  1127. dont_do_extra2
  1128. *---------
  1129. move.w #20-1,d0
  1130. do_all_blocks
  1131. move.w #START_DRAW_BLOCKS,y_ready_flag
  1132. keep_drawing
  1133. moveq #0,d6
  1134. movem.l a0-a5/d0-d7,-(sp)
  1135. bsr draw_blocks_main
  1136. movem.l (sp)+,a0-a5/d0-d7
  1137. tst y_ready_flag
  1138. bne.s keep_drawing
  1139. add.w #16,alien_y_pos
  1140. add.l #16*BPR,a0
  1141. move.l plane1,a2
  1142. add.l #SCROLL_HEIGHT*BPR,a2
  1143. cmp.l a2,a0
  1144. blt.s not_in_area_yet
  1145. sub.l #SCROLL_HEIGHT*BPR,a0
  1146. not_in_area_yet
  1147. add.l #(BIGGEST_MAP_X*MAP_BLOCK_SIZE),a1
  1148. add.l #BIGGEST_MAP_X,a4
  1149. dbra d0,do_all_blocks
  1150. move.w #WAIT_DRAW_BLOCKS,y_ready_flag
  1151. bsr Add_New_Aliens
  1152. *-- FILL IN TWO COLS OF X BLOCKS
  1153. move.w #START_DRAW_BLOCKS,x_ready_flag
  1154. wait_until_done
  1155. move.l current_alien_draw_position,a0
  1156. sub.l #PLANE_INC*4,a0 ;cos buff
  1157. move.l current_map_mem_position,a1
  1158. *--
  1159. sub.l #33*BPR,a0
  1160. sub.l #(2*BIGGEST_MAP_X)*MAP_BLOCK_SIZE,a1
  1161. *--
  1162. move.l current_alien_map_mem_position,a4
  1163. add.l #44,a0
  1164. sub.l #2*MAP_BLOCK_SIZE,a1
  1165. moveq #0,d4
  1166. bsr draw_x_blocks_straight
  1167. cmp.w #WAIT_DRAW_BLOCKS,x_ready_flag
  1168. bne.s wait_until_done
  1169. move.w #START_DRAW_BLOCKS,x_ready_flag
  1170. wait_until_done2
  1171. move.l current_alien_draw_position,a0
  1172. sub.l #PLANE_INC*4,a0 ;cos buff
  1173. move.l current_map_mem_position,a1
  1174. move.l current_alien_map_mem_position,a4
  1175. *--
  1176. sub.l #33*BPR,a0
  1177. sub.l #(2*BIGGEST_MAP_X)*MAP_BLOCK_SIZE,a1
  1178. *--
  1179. add.l #46,a0
  1180. sub.l #1*MAP_BLOCK_SIZE,a1
  1181. moveq #0,d4
  1182. bsr draw_x_blocks_straight
  1183. cmp.w #WAIT_DRAW_BLOCKS,x_ready_flag
  1184. bne.s wait_until_done2
  1185. move.w #WAIT_DRAW_BLOCKS,x_ready_flag
  1186. bsr Add_New_Aliens
  1187. clr.w scroll_x_position
  1188. clr.w scroll_y_position
  1189. rts
  1190. ********************************************************
  1191. **** SET UP SCROLL POSITION ****
  1192. ********************************************************
  1193. set_up_scroll_position
  1194. clr.w current_x_map_position ;position of drawn blocks
  1195. clr.w current_y_map_position
  1196. clr.w check_x_add
  1197. clr.w check_y_add
  1198. move.l level_map,a0
  1199. move.w map_data_x(a0),d0
  1200. move.w d0,map_x_size
  1201. move.w map_datasize(a0),d1
  1202. asl d1,d0
  1203. mulu map_data_y(a0),d0 ;=size of map
  1204. move.w map_data_y(a0),map_y_size
  1205. add.l #map_data_start,a0
  1206. move.l a0,current_map_pointer
  1207. add.l d0,a0
  1208. move.l a0,current_alien_map_pointer
  1209. move.w map_x_size,d0
  1210. move.w map_y_size,d1
  1211. sub.w #20,d0
  1212. sub.w #15,d1
  1213. asl #4,d0
  1214. asl #4,d1
  1215. subq.w #1,d0
  1216. subq.w #1,d1
  1217. move.w d0,map_x_size
  1218. move.w d1,map_y_size
  1219. rts
  1220. ********************************************************
  1221. **** DRAW CURRENT SCROLL POINT ****
  1222. ********************************************************
  1223. Draw_Current_Scroll_Point
  1224. *Routine sets up screen
  1225. move.l current_map_pointer,a0
  1226. move.w scroll_x_position,d0
  1227. move.w scroll_y_position,d1
  1228. moveq #0,d0
  1229. asr #4,d1
  1230. asr #3,d0 ;cos word map
  1231. mulu #BIGGEST_MAP_X*MAP_BLOCK_SIZE,d1
  1232. add.l d1,a0
  1233. add.l d0,a0 ;map
  1234. rts
  1235. current_map_pointer dc.l 0
  1236. current_alien_map_pointer dc.l 0
  1237. rsreset
  1238. wait_pos rs.w 1
  1239. wait_mask rs.w 1
  1240. plane_1_hi_ptr rs.w 1
  1241. plane_1_hi_val rs.w 1
  1242. plane_1_lo_ptr rs.w 1
  1243. plane_1_lo_val rs.w 1
  1244. plane_2_hi_ptr rs.w 1
  1245. plane_2_hi_val rs.w 1
  1246. plane_2_lo_ptr rs.w 1
  1247. plane_2_lo_val rs.w 1
  1248. plane_3_hi_ptr rs.w 1
  1249. plane_3_hi_val rs.w 1
  1250. plane_3_lo_ptr rs.w 1
  1251. plane_3_lo_val rs.w 1
  1252. plane_4_hi_ptr rs.w 1
  1253. plane_4_hi_val rs.w 1
  1254. plane_4_lo_ptr rs.w 1
  1255. plane_4_lo_val rs.w 1
  1256. rsreset
  1257. map_file_header rs.l 1
  1258. map_blk_size rs.w 1
  1259. map_data_x rs.w 1
  1260. map_data_y rs.w 1
  1261. map_planes rs.w 1
  1262. map_datasize rs.w 1
  1263. map_data_start rs.w 1