four_way_scrollnew.s 32 KB

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