four_way_scrolltest.s 30 KB

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