scroll_up_down.s 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023
  1. section Generic,Code_C
  2. OPT C-,D+
  3. opt p=68020
  4. BPR EQU 64
  5. GRAPHICS_MOD EQU 0
  6. XSIZE EQU 4
  7. YSIZE EQU 36
  8. XDEST EQU 42
  9. YDEST EQU 164
  10. SCROLL_WIDTH EQU 27
  11. NOP EQU 18
  12. NOC EQU 0
  13. CUSTOM EQU $DFF000
  14. BPLCONO EQU $100
  15. BPLCON1 EQU $102
  16. BPLCON2 EQU $104
  17. BPL1MOD EQU $108
  18. DDFSTRT EQU $092
  19. DDFSTOP EQU $094
  20. DIWSTRT EQU $08E
  21. DIWSTOP EQU $090
  22. VPSOR EQU $004
  23. COLOUR0 EQU $180
  24. COLOUR1 EQU $182
  25. COLOUR2 EQU $184
  26. COLOUR3 EQU $186
  27. DMACON EQU $096
  28. COP1LCH EQU $080
  29. COPJMP1 EQU $088
  30. DMAF_BLITTER EQU $0040
  31. DMAF_BLTDONE EQU $4000
  32. DMAF_BLTNZERO EQU $2000
  33. DMAB_BLTDONE EQU 14
  34. bltddat EQU $000
  35. dmaconr EQU $002
  36. vposr EQU $004
  37. vhposr EQU $006
  38. dskdatr EQU $008
  39. joy0dat EQU $00A
  40. joy1dat EQU $00C
  41. clxdat EQU $00E
  42. bltcon0 EQU $040
  43. bltcon1 EQU $042
  44. bltafwm EQU $044
  45. bltalwm EQU $046
  46. bltcpth EQU $048
  47. bltbpth EQU $04C
  48. bltapth EQU $050
  49. bltdpth EQU $054
  50. bltsize EQU $058
  51. bltcmod EQU $060
  52. bltbmod EQU $062
  53. bltamod EQU $064
  54. bltdmod EQU $066
  55. bltcdat EQU $070
  56. bltbdat EQU $072
  57. bltadat EQU $074
  58. dsksync EQU $07E
  59. cop1lc EQU $080
  60. cop2lc EQU $084
  61. bpl2mod EQU $10A
  62. bpldat EQU $110
  63. intreq EQU $09c
  64. intreqr EQU $01e
  65. MODE_OLDFILE EQU 1005
  66. MODE_NEWFILE EQU 1006
  67. SCROLL_HEIGHT EQU 256+64
  68. start:
  69. move.l 4,a6
  70. jsr -132(A6) ;DISABLE tasking
  71. move.l 4,a6
  72. move.l #(SCROLL_HEIGHT*BPR)*8,d0 ;
  73. move.l #1<<1+1<<16,d1 ;chip and clear
  74. jsr -198(a6) ;try
  75. tst.l d0
  76. bne allocated_mem
  77. rts ;otherwise quit
  78. allocated_mem
  79. move.l d0,Memory_Base
  80. move.l d0,Plane1
  81. add.l #(SCROLL_HEIGHT*BPR),d0
  82. move.l d0,plane2
  83. add.l #(SCROLL_HEIGHT*BPR),d0
  84. move.l d0,plane3
  85. add.l #(SCROLL_HEIGHT*BPR),d0
  86. move.l d0,plane4
  87. add.l #(SCROLL_HEIGHT*BPR),d0
  88. move.l d0,buff_plane1
  89. add.l #(SCROLL_HEIGHT*BPR),d0
  90. move.l d0,buff_plane2
  91. add.l #(SCROLL_HEIGHT*BPR),d0
  92. move.l d0,buff_plane3
  93. add.l #(SCROLL_HEIGHT*BPR),d0
  94. move.l d0,buff_plane4
  95. bsr setup
  96. move.w #$0,$dff106
  97. move.l #$dff000,a6
  98. bsr fill_screen_with_blocks
  99. bsr set_up_scroll_position
  100. bsr Main_Demo
  101. QUIT_OUT
  102. MOVE.L 4,A6
  103. JSR -138(A6) ;ENABLE tasking
  104. move.l oldint,$6c
  105. move.l 4,a6
  106. move.l #(SCROLL_HEIGHT*BPR)*8,d0
  107. move.l Memory_Base,a1
  108. jsr -210(a6)
  109. MOVE.L #graf_NAME,A1
  110. MOVEQ #0,D0
  111. JSR -552(A6) ;OPEN GRAPHICS LIBRARY
  112. MOVE.L D0,a4
  113. MOVE.W #$8020,DMACON+$dff000 ; sprites back
  114. move.l 38(a4),$dff080
  115. clr.w $dff088
  116. move.b #$9b,$bfed01
  117. rts
  118. graf_NAME dc.b "graphics.library",0
  119. even
  120. setup
  121. bsr setup_colours
  122. LEA CUSTOM,A0
  123. MOVE.W #0,BPLCON1(A0)
  124. move.w #%1000000,BPLCON2(a0)
  125. move.w #$83a0,DMACON(a0)
  126. MOVE.W #$2C81,DIWSTRT(A0)
  127. MOVE.W #$2cC1,DIWSTOP(A0)
  128. MOVE.L #COPPERL,COP1LCH(A0)
  129. MOVE.W COPJMP1(A0),D0
  130. move.l $6c,oldint
  131. move.l #darkint,$6c
  132. rts
  133. setup_colours
  134. move.w #$180,d0
  135. move.l #copper_colours,a0
  136. move.l #col_list,a1
  137. move.w #16-1,d1
  138. col_loop
  139. move.w d0,(a0)+
  140. move.w (a1)+,(a0)+
  141. add.w #$2,d0
  142. dbra d1,col_loop
  143. rts
  144. col_list
  145. dc.w $000,$f00,$0f0,$00f,$ff0,$0ff,$f0f
  146. dc.w $fff,$77f,$707,$f77,$f7f,$7ff,$777
  147. dc.w $707,$070
  148. ************************************************************
  149. **** D A R K L I T E I N T E R R U P T ****
  150. ************************************************************
  151. darkint
  152. movem.l d0-d7/a0-a6,-(sp)
  153. movem.l (sp)+,d0-d7/a0-a6
  154. dc.w $4ef9
  155. oldint dc.l 0
  156. mt_data dc.l 0
  157. music_flag dc.b 0
  158. even
  159. play_colours
  160. dc.b 0
  161. even
  162. two_channel_flag dc.b 0
  163. even
  164. ************************************************************
  165. ***** S C R E E N S Y N C **********
  166. ************************************************************
  167. sync
  168. move.l #$dff000,a6
  169. move.w #$0010,intreq(a6)
  170. wait_for_bit
  171. btst.b #4,intreqr+1(a6)
  172. beq.s wait_for_bit
  173. rts
  174. home
  175. Main_Demo
  176. bsr sync
  177. bsr get_stick_readings
  178. bsr calculate_scroll_movement
  179. bsr move_scroll
  180. bsr draw_blocks_for_scroll
  181. wait btst.b #6,$bfe001
  182. bne.s main_demo
  183. btst.b #10,$dff016
  184. bne.s main_demo
  185. rts
  186. Single_Mouse_Press
  187. btst #6,$BFE001
  188. Bne out
  189. * move.w #$11,jobba
  190. not_released
  191. btst #6,$BFE001
  192. Beq not_released
  193. out
  194. rts
  195. COPPERL
  196. dc.w bplcono
  197. dc.w $4200
  198. dc.w $102 ; scrolly bit
  199. dc.w $000
  200. dc.w DDFSTRT
  201. dc.w $0038
  202. dc.w DDFSTOP
  203. dc.w $00d8
  204. dc.w bpl1mod
  205. dc.w 16
  206. dc.w bpl2mod
  207. dc.w 16
  208. dc.w $1e4
  209. dc.w $2100
  210. dc.w $10c
  211. dc.w $11
  212. dc.w $1fc
  213. dc.w $f
  214. copper_colours
  215. ds.w 16*2
  216. ************sprites
  217. dc.w $180,$0
  218. dc.w $120 ;all sprite stuff
  219. sprite0h dc.w $0
  220. dc.w $122
  221. sprite0l dc.w 0
  222. dc.w $124
  223. sprite1h dc.w $0
  224. dc.w $126
  225. sprite1l dc.w 0
  226. dc.w $128
  227. sprite2h dc.w $0
  228. dc.w $12a
  229. sprite2l dc.w 0
  230. dc.w $12c
  231. sprite3h dc.w $0
  232. dc.w $12e
  233. sprite3l dc.w 0
  234. dc.w $130
  235. sprite4h dc.w $0
  236. dc.w $132
  237. sprite4l dc.w 0
  238. dc.w $134
  239. sprite5h dc.w $0
  240. dc.w $136
  241. sprite5l dc.w 0
  242. dc.w $138
  243. sprite6h dc.w $0
  244. dc.w $13a
  245. sprite6l dc.w 0
  246. dc.w $13c
  247. sprite7h dc.w $0
  248. dc.w $13e
  249. sprite7l dc.w 0
  250. top_of_screen
  251. DC.W $00E0 ;top bank of plane initialisers
  252. Plane1_Hi DC.W 0
  253. DC.W $00E2
  254. Plane1_Lo DC.W 0
  255. DC.W $00E4
  256. Plane2_Hi DC.W 0
  257. DC.W $00E6
  258. Plane2_Lo DC.W 0
  259. DC.W $00E8
  260. Plane3_Hi DC.W 0
  261. DC.W $00Ea
  262. Plane3_Lo DC.W 0
  263. DC.W $00Ec
  264. Plane4_Hi DC.W 0
  265. DC.W $00Ee
  266. Plane4_Lo DC.W 0
  267. scroll_bank_1
  268. dc.w $2c01,$fffe
  269. DC.W $00E0
  270. DC.W 0
  271. DC.W $00E2
  272. DC.W 0
  273. DC.W $00E4
  274. DC.W 0
  275. DC.W $00E6
  276. DC.W 0
  277. DC.W $00E8
  278. DC.W 0
  279. DC.W $00Ea
  280. DC.W 0
  281. DC.W $00Ec
  282. DC.W 0
  283. DC.W $00Ee
  284. DC.W 0
  285. dc.w $180,$fff
  286. dc.w $ffdf,$fffe
  287. scroll_bank_2
  288. dc.w $2c01,$fffe
  289. DC.W $00E0
  290. DC.W 0
  291. DC.W $00E2
  292. DC.W 0
  293. DC.W $00E4
  294. DC.W 0
  295. DC.W $00E6
  296. DC.W 0
  297. DC.W $00E8
  298. DC.W 0
  299. DC.W $00Ea
  300. DC.W 0
  301. DC.W $00Ec
  302. DC.W 0
  303. DC.W $00Ee
  304. DC.W 0
  305. dc.w intreq
  306. dc.w $8010
  307. DC.W $2cff,$FFFE
  308. ds.w 1000*2
  309. display_buffers
  310. move.l plane1,d0
  311. move.l plane2,d1
  312. move.l plane3,d2
  313. move.l plane4,d3
  314. move.w d0,plane1_lo
  315. swap d0
  316. move.w d0,plane1_hi
  317. move.w d1,plane2_lo
  318. swap d1
  319. move.w d1,plane2_hi
  320. move.w d2,plane3_lo
  321. swap d2
  322. move.w d2,plane3_hi
  323. move.w d3,plane4_lo
  324. swap d3
  325. move.w d3,plane4_hi
  326. rts
  327. Blank Dc.l 0
  328. Memory_Base dc.l 0
  329. draw_pixel
  330. mulu.w #BPR,d1
  331. add.l d1,a0
  332. move.w d0,d3
  333. lsr.w #3,d0 ; get bytes
  334. andi.b #%111,d3 ; pixel bits
  335. moveq #7,d1
  336. sub.b d3,d1
  337. bset.b d1,(a0,d0.w) ;
  338. rts
  339. clear_pixel
  340. mulu.w #BPR,d1
  341. add.l d1,a0
  342. move.w d0,d3
  343. lsr.w #3,d0 ; get bytes
  344. andi.b #%111,d3 ; pixel bits
  345. moveq #7,d1
  346. sub.b d3,d1
  347. bclr.b d1,(a0,d0.w) ;
  348. rts
  349. plane1
  350. dc.l 0
  351. plane2
  352. dc.l 0
  353. plane3
  354. dc.l 0
  355. plane4
  356. dc.l 0
  357. buff_plane1
  358. dc.l 0
  359. buff_plane2
  360. dc.l 0
  361. buff_plane3
  362. dc.l 0
  363. buff_plane4
  364. dc.l 0
  365. *----------------------------SCROLL CODE----------------------
  366. reset
  367. wait_pos rs.w 1
  368. wait_mask rs.w 1
  369. plane_1_hi_ptr rs.w 1
  370. plane_1_hi_val rs.w 1
  371. plane_1_lo_ptr rs.w 1
  372. plane_1_lo_val rs.w 1
  373. plane_2_hi_ptr rs.w 1
  374. plane_2_hi_val rs.w 1
  375. plane_2_lo_ptr rs.w 1
  376. plane_2_lo_val rs.w 1
  377. plane_3_hi_ptr rs.w 1
  378. plane_3_hi_val rs.w 1
  379. plane_3_lo_ptr rs.w 1
  380. plane_3_lo_val rs.w 1
  381. plane_4_hi_ptr rs.w 1
  382. plane_4_hi_val rs.w 1
  383. plane_4_lo_ptr rs.w 1
  384. plane_4_lo_val rs.w 1
  385. TEST_SPEED EQU 4
  386. WAIT_DRAW_BLOCKS EQU 0
  387. START_DRAW_BLOCKS EQU 1
  388. MAP_LINE_SIZE EQU 100
  389. SCROLL_GOING_DOWN EQU -48*BPR ;up from bottom of scroll
  390. SCROLL_GOING_UP EQU -16*BPR
  391. MAP_SCREEN_OFFSET_UP EQU 17*MAP_LINE_SIZE
  392. MAP_SCREEN_OFFSET_DOWN EQU -1*MAP_LINE_SIZE
  393. NUMBER_OF_BLOCKS_PER_FRAME EQU 7
  394. ******************************************
  395. **** CALCULATE SCROLL MOVEMENT *****
  396. ******************************************
  397. calculate_scroll_movement
  398. *separate stick from scroll thus this routine can send
  399. *any value to scroll allowing velocity scrolls etc
  400. move.w #0,d0
  401. tst.w xdirec
  402. beq.w no_x_movement
  403. bpl.s scroll_moving_to_right
  404. move.w #-TEST_SPEED,d0
  405. bra.s no_x_movement
  406. scroll_moving_to_right
  407. move.w #TEST_SPEED,d0
  408. no_x_movement
  409. move.w #0,d1
  410. tst.w ydirec
  411. beq.w no_y_movement
  412. bmi.s scroll_moving_down
  413. move.w #-TEST_SPEED,d1
  414. bra.s no_y_movement
  415. scroll_moving_down
  416. move.w #TEST_SPEED,d1
  417. no_y_movement
  418. rts
  419. ******************************************
  420. **** MOVE SCROLL *****
  421. ******************************************
  422. move_scroll
  423. *send in x and y increments in d0 and d1
  424. add.w d0,scroll_x_position
  425. add.w d1,scroll_y_position
  426. cmp.w #0,scroll_y_position
  427. bge.s scroll_not_hit_bounds
  428. move.w scroll_y_position,d2
  429. neg.w d2
  430. add.w d2,d1 ;give proper speed
  431. move.w #0,scroll_y_position
  432. scroll_not_hit_bounds
  433. bsr check_add_blocks
  434. bsr position_scroll
  435. *do various boundary checks
  436. rts
  437. ******************************************
  438. **** CHECK ADD BLOCKS *****
  439. ******************************************
  440. check_add_blocks
  441. add.w d1,check_add
  442. cmp.w #17,check_add
  443. blt.s check_min_add
  444. sub.w #16,check_add
  445. move.w #START_DRAW_BLOCKS,ready_flag
  446. move.l #SCROLL_GOING_DOWN,add_block_direction
  447. bra.s drawing_please_wait
  448. check_min_add
  449. cmp.w #-17,check_add
  450. bgt.s drawing_please_wait
  451. move.w #START_DRAW_BLOCKS,ready_flag
  452. move.l #SCROLL_GOING_UP,add_block_direction
  453. add.w #16,check_add
  454. drawing_please_wait
  455. rts
  456. add_block_direction dc.l 0
  457. check_add dc.w 0
  458. ready_flag dc.w 0
  459. ******************************************
  460. **** POSITION SCROLL *****
  461. ******************************************
  462. position_scroll
  463. *Positions scroll by the x and y values stored
  464. move.w scroll_x_position,d0
  465. move.w scroll_y_position,d1
  466. position_scroll_along_x
  467. *ignor x for now
  468. position_scroll_along_y
  469. *---
  470. moveq #0,d2
  471. move.w d1,d2
  472. asr.w #4,d2
  473. mulu #MAP_LINE_SIZE,d2
  474. move.l #map_data,a0
  475. add.l d2,a0
  476. move.l a0,current_map_mem_position
  477. *---
  478. ext.l d1
  479. divu #SCROLL_HEIGHT,d1
  480. swap d1 ;this is all we want - split position down screen
  481. neg.w d1 ;so scroll goes right way
  482. add.w #SCROLL_HEIGHT,d1
  483. *---calc where to draw
  484. moveq #0,d3
  485. move.w #SCROLL_HEIGHT,d3 ;position above buffer area
  486. sub.w d1,d3 ;position of buffer area
  487. andi.w #$fff0,d3
  488. asl.w #6,d3
  489. add.l plane1,d3
  490. move.l d3,current_screen_position
  491. *------
  492. move.w d1,d2
  493. add.w #$2c,d1
  494. moveq #0,d0
  495. cmp.w #$ff,d1
  496. ble.s not_over_dodgy_line
  497. moveq #1,d0
  498. not_over_dodgy_line
  499. cmp.w #$ff+$2c,d1
  500. ble.s not_off_copper
  501. move.w #-1,d0
  502. bra.s calc_screen_split
  503. not_off_copper
  504. andi.w #$ff,d1 ;so values wraps round
  505. asl.w #8,d1
  506. addq.w #1,d1 ; = wait value
  507. calc_screen_split
  508. neg.w d2
  509. add.w #SCROLL_HEIGHT,d2
  510. asl.w #6,d2 ;mulu by 64 - get line down
  511. ext.l d2
  512. add.l plane1,d2 ;to display at top
  513. move.l plane1,d3 ;top display at split
  514. bsr insert_plane_pointers
  515. rts
  516. ******************************************
  517. **** INSERT PLANE POINTERS *****
  518. ******************************************
  519. insert_plane_pointers
  520. *d0 indicates if inserting after 255 gap
  521. *d1 contains wait value
  522. *d2 = top of display
  523. *d3 = split part of display
  524. tst d0
  525. bmi clear_all_banks
  526. beq.s insert_before_line
  527. insert_after_line
  528. move.l #scroll_bank_2,a0
  529. move.l #scroll_bank_1,a1
  530. bsr fill_banks
  531. rts
  532. insert_before_line
  533. move.l #scroll_bank_1,a0
  534. move.l #scroll_bank_2,a1
  535. bsr fill_banks
  536. rts
  537. clear_all_banks
  538. move.l #scroll_bank_1,a0
  539. move.l #scroll_bank_2,a1
  540. bsr clear_banks
  541. rts
  542. ******************************************
  543. **** FILL BANKS *****
  544. ******************************************
  545. fill_banks
  546. *a0 = bank to fill
  547. *a1 = bank to clear
  548. *d1 = wait
  549. *d2 = top of display
  550. *d3 = split display
  551. *change to copper jump later - but get it working first!!!
  552. * IN USE SPLIT POINTERS
  553. move.w d1,wait_pos(a0)
  554. move.w #$fffe,wait_mask(a0)
  555. move.w #$e2,plane_1_lo_ptr(a0)
  556. move.w d3,plane_1_lo_val(a0)
  557. swap d3
  558. move.w #$e0,plane_1_hi_ptr(a0)
  559. move.w d3,plane_1_hi_val(a0)
  560. swap d3
  561. add.l #SCROLL_HEIGHT*BPR,d3
  562. move.w #$e6,plane_2_lo_ptr(a0)
  563. move.w d3,plane_2_lo_val(a0)
  564. swap d3
  565. move.w #$e4,plane_2_hi_ptr(a0)
  566. move.w d3,plane_2_hi_val(a0)
  567. swap d3
  568. add.l #SCROLL_HEIGHT*BPR,d3
  569. move.w #$ea,plane_3_lo_ptr(a0)
  570. move.w d3,plane_3_lo_val(a0)
  571. swap d3
  572. move.w #$e8,plane_3_hi_ptr(a0)
  573. move.w d3,plane_3_hi_val(a0)
  574. swap d3
  575. add.l #SCROLL_HEIGHT*BPR,d3
  576. move.w #$ee,plane_4_lo_ptr(a0)
  577. move.w d3,plane_4_lo_val(a0)
  578. swap d3
  579. move.w #$ec,plane_4_hi_ptr(a0)
  580. move.w d3,plane_4_hi_val(a0)
  581. * UNUSED SET OF SPLIT POINTERS
  582. move.w #$1f0,wait_pos(a1)
  583. move.w #$1f0,plane_1_hi_ptr(a1)
  584. move.w #$1f0,plane_1_lo_ptr(a1)
  585. move.w #$1f0,plane_2_hi_ptr(a1)
  586. move.w #$1f0,plane_2_lo_ptr(a1)
  587. move.w #$1f0,plane_3_hi_ptr(a1)
  588. move.w #$1f0,plane_3_lo_ptr(a1)
  589. move.w #$1f0,plane_4_hi_ptr(a1)
  590. move.w #$1f0,plane_4_lo_ptr(a1)
  591. * TOP OF SCREEN
  592. move.l #top_of_screen-4,a0 ;so rs.w's work
  593. move.w d2,plane_1_lo_val(a0)
  594. swap d2
  595. move.w d2,plane_1_hi_val(a0)
  596. swap d2
  597. add.l #SCROLL_HEIGHT*BPR,d2
  598. move.w d2,plane_2_lo_val(a0)
  599. swap d2
  600. move.w d2,plane_2_hi_val(a0)
  601. swap d2
  602. add.l #SCROLL_HEIGHT*BPR,d2
  603. move.w d2,plane_3_lo_val(a0)
  604. swap d2
  605. move.w d2,plane_3_hi_val(a0)
  606. swap d2
  607. add.l #SCROLL_HEIGHT*BPR,d2
  608. move.w d2,plane_4_lo_val(a0)
  609. swap d2
  610. move.w d2,plane_4_hi_val(a0)
  611. rts
  612. ******************************************
  613. **** CLEAR BANKS *****
  614. ******************************************
  615. clear_banks
  616. * UNUSED SET OF SPLIT POINTERS 1
  617. move.w #$1f0,wait_pos(a1)
  618. move.w #$1f0,plane_1_hi_ptr(a1)
  619. move.w #$1f0,plane_1_lo_ptr(a1)
  620. move.w #$1f0,plane_2_hi_ptr(a1)
  621. move.w #$1f0,plane_2_lo_ptr(a1)
  622. move.w #$1f0,plane_3_hi_ptr(a1)
  623. move.w #$1f0,plane_3_lo_ptr(a1)
  624. move.w #$1f0,plane_4_hi_ptr(a1)
  625. move.w #$1f0,plane_4_lo_ptr(a1)
  626. * UNUSED SET OF SPLIT POINTERS 2
  627. move.w #$1f0,wait_pos(a0)
  628. move.w #$1f0,plane_1_hi_ptr(a0)
  629. move.w #$1f0,plane_1_lo_ptr(a0)
  630. move.w #$1f0,plane_2_hi_ptr(a0)
  631. move.w #$1f0,plane_2_lo_ptr(a0)
  632. move.w #$1f0,plane_3_hi_ptr(a0)
  633. move.w #$1f0,plane_3_lo_ptr(a0)
  634. move.w #$1f0,plane_4_hi_ptr(a0)
  635. move.w #$1f0,plane_4_lo_ptr(a0)
  636. * TOP OF SCREEN
  637. move.l #top_of_screen-4,a0 ;so rs.w's work
  638. move.w d2,plane_1_lo_val(a0)
  639. swap d2
  640. move.w d2,plane_1_hi_val(a0)
  641. swap d2
  642. add.l #SCROLL_HEIGHT*BPR,d2
  643. move.w d2,plane_2_lo_val(a0)
  644. swap d2
  645. move.w d2,plane_2_hi_val(a0)
  646. swap d2
  647. add.l #SCROLL_HEIGHT*BPR,d2
  648. move.w d2,plane_3_lo_val(a0)
  649. swap d2
  650. move.w d2,plane_3_hi_val(a0)
  651. swap d2
  652. add.l #SCROLL_HEIGHT*BPR,d2
  653. move.w d2,plane_4_lo_val(a0)
  654. swap d2
  655. move.w d2,plane_4_hi_val(a0)
  656. rts
  657. scroll_x_position dc.w 0
  658. scroll_y_position dc.w 0
  659. **********************************************************
  660. *********** DRAW BLOCKS FOR SCROLL ***********
  661. **********************************************************
  662. draw_blocks_for_scroll
  663. tst.w ready_flag
  664. beq.s quit_draw_blocks_for_scroll
  665. move.l current_screen_position,a0
  666. move.l current_map_mem_position,a1
  667. bsr draw_blocks
  668. quit_draw_blocks_for_scroll
  669. rts
  670. current_screen_position dc.l 0
  671. current_map_mem_position dc.l 0
  672. **********************************************************
  673. *********** DRAW BLOCKS ***********
  674. **********************************************************
  675. draw_blocks
  676. *current screen mem position in a0
  677. *current map position in a1
  678. add.l add_block_direction,a0
  679. cmp.l plane1,a0
  680. bge.s draw_inside_plane_area
  681. add.l #SCROLL_HEIGHT*BPR,a0
  682. draw_inside_plane_area
  683. cmp.l #SCROLL_GOING_UP,add_block_direction
  684. bne.s scroll_down
  685. add.l #MAP_SCREEN_OFFSET_DOWN,a1
  686. bra.s draw_blocks_up
  687. scroll_down
  688. add.l #MAP_SCREEN_OFFSET_UP,a1
  689. draw_blocks_up
  690. *-----------draw blocks loop-------------
  691. draw_blocks_main
  692. moveq #0,d0
  693. move.w current_map_position,d0
  694. ext.l d0
  695. add.l d0,a1 ;current map position
  696. asl d0 ;get into bytes
  697. add.l d0,a0 ;get to current line
  698. move.w total_number_of_blocks_to_draw,d2
  699. moveq #0,d7 ;count number of blocks drawn
  700. init_blit_values
  701. btst #14,dmaconr(a6)
  702. bne.s init_blit_values
  703. move.w #BPR-2,bltdmod(a6)
  704. move.w #0,bltamod(a6)
  705. move.l #$ffffffff,bltafwm(a6)
  706. move.l #$09F00000,bltcon0(A6)
  707. moveq #NUMBER_OF_BLOCKS_PER_FRAME-1,d0
  708. draw_loop
  709. move.l #blocks,a2
  710. moveq #0,d1
  711. move.b (a1),d1
  712. asl.w #7,d1 ;same as mulu (16*2)*4
  713. add.l d1,a2 ;get to correct position in block data
  714. draw_block_on_screen
  715. btst #14,dmaconr(a6)
  716. bne.s draw_block_on_screen
  717. move.l a0,bltdpth(a6) ;screen
  718. move.l a2,bltapth(a6) ;graphics
  719. move.w #16<<6+1,bltsize(a6) ;1 word by 16 pixels
  720. move.l a0,a3
  721. add.l #BPR*SCROLL_HEIGHT,a3
  722. add.l #16*2,a2
  723. draw_block_on_screenp2
  724. btst #14,dmaconr(a6)
  725. bne.s draw_block_on_screenp2
  726. move.l a3,bltdpth(a6) ;screen
  727. move.l a2,bltapth(a6) ;graphics
  728. move.w #16<<6+1,bltsize(a6) ;1 word by 16 pixels
  729. add.l #BPR*SCROLL_HEIGHT,a3
  730. add.l #16*2,a2
  731. draw_block_on_screenp3
  732. btst #14,dmaconr(a6)
  733. bne.s draw_block_on_screenp3
  734. move.l a3,bltdpth(a6) ;screen
  735. move.l a2,bltapth(a6) ;graphics
  736. move.w #16<<6+1,bltsize(a6) ;1 word by 16 pixels
  737. add.l #BPR*SCROLL_HEIGHT,a3
  738. add.l #16*2,a2
  739. draw_block_on_screenp4
  740. btst #14,dmaconr(a6)
  741. bne.s draw_block_on_screenp4
  742. move.l a3,bltdpth(a6) ;screen
  743. move.l a2,bltapth(a6) ;graphics
  744. move.w #16<<6+1,bltsize(a6) ;1 word by 16 pixels
  745. done_a_block
  746. addq.l #2,a0 ;next block position along screen
  747. addq.l #1,a1 ;next map position
  748. addq.w #1,current_map_position
  749. addq.w #1,d7 ;count number blocks drawn
  750. cmp.w current_map_position,d2
  751. bne.s not_yet_done_line
  752. move.w #0,current_map_position
  753. move.w #WAIT_DRAW_BLOCKS,ready_flag ;done our line now wait for screen to scroll 16
  754. bra.s done_all_blocks
  755. not_yet_done_line
  756. dbra d0,draw_loop
  757. done_all_blocks
  758. rts
  759. total_number_of_blocks_to_draw dc.w 20
  760. current_map_position dc.w 0
  761. ********************************************************
  762. **** FILL SCREEN WITH BLOCKS ****
  763. ********************************************************
  764. fill_screen_with_blocks
  765. move.l plane1,a0
  766. move.l #map_data,a1
  767. move.w #18-1,d0
  768. do_all_blocks
  769. move.w #START_DRAW_BLOCKS,ready_flag
  770. keep_drawing
  771. movem.l a0-a1/d0,-(sp)
  772. bsr draw_blocks_main
  773. movem.l (sp)+,a0-a1/d0
  774. tst ready_flag
  775. bne.s keep_drawing
  776. add.l #16*BPR,a0
  777. add.l #MAP_LINE_SIZE,a1
  778. dbra d0,do_all_blocks
  779. move.w #WAIT_DRAW_BLOCKS,ready_flag
  780. rts
  781. ********************************************************
  782. **** SET UP SCROLL POSITION ****
  783. ********************************************************
  784. set_up_scroll_position
  785. move.w #0,scroll_y_position
  786. rts
  787. include "code:platform/glens_code/joy_routines.s"
  788. blocks
  789. incbin "scratch:empty/testblks"
  790. EVEN
  791. map_data
  792. incbin "scratch:empty/testmapraw"
  793. EVEN