four_way_scrolltest.s 34 KB

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