map_routines.s 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268
  1. ********************************************
  2. *** CONVERT NEW MAP ***
  3. ********************************************
  4. convert_new_map
  5. movem.l d0-d7/a0-a6,-(sp)
  6. moveq #0,d0
  7. moveq #0,d1
  8. move.l current_map_ptr,a0
  9. move.w map_xsize(a0),d0
  10. mulu map_ysize(a0),d0
  11. move.w map_datasize(a0),d1
  12. asl.l d1,d0 ;double if word map
  13. move.l #MEM_PUBLIC+MEM_CLEAR,d1
  14. movem.l a6/a0,-(sp)
  15. move.l 4,a6
  16. jsr -198(a6) ;get mem
  17. movem.l (sp)+,a6/a0
  18. tst.l d0
  19. bne.s got_new_map_mem
  20. *raise error
  21. bra end_convert
  22. got_new_map_mem
  23. move.l d0,a1 ;store pointer
  24. *-----get new alien map mem
  25. move.w map_xsize(a0),d0
  26. mulu map_ysize(a0),d0
  27. move.l #MEM_PUBLIC+MEM_CLEAR,d1
  28. movem.l a6/a0-a1,-(sp)
  29. move.l 4,a6
  30. jsr -198(a6) ;get mem
  31. movem.l (sp)+,a6/a0-a1
  32. tst.l d0
  33. bne.s got_new_alien_map_mem
  34. *raise error
  35. bra end_convert
  36. got_new_alien_map_mem
  37. move.l d0,new_alien_mem
  38. *store the following so you know what size of block data is associated
  39. *with the data currently in the structure
  40. *and also old x and y sizes
  41. convert_old_map_data
  42. move.l a1,a2 ;new map data
  43. move.l map_mem(a0),a3 ;old map data
  44. move.l new_alien_mem,a2_reg
  45. move.l map_alien_mem(a0),a3_reg
  46. move.w map_ysize(a0),d1
  47. move.w map_allocy(a0),d3
  48. do_x_convert
  49. move.w map_xsize(a0),d0
  50. move.w map_allocx(a0),d4
  51. move.l a2,a4
  52. move.l a3,a5
  53. move.l a2_reg,a4_reg
  54. move.l a3_reg,a5_reg
  55. start_convert
  56. moveq #0,d2
  57. tst.w map_allocdatasize(a0)
  58. beq.s was_byte_data
  59. move.w (a5)+,d2
  60. bra.s insert_into_new_map
  61. was_byte_data
  62. move.b (a5)+,d2
  63. insert_into_new_map
  64. tst map_datasize(a0)
  65. beq.s new_map_byte
  66. move.w d2,(a4)+
  67. bra.s check_sizes
  68. new_map_byte
  69. move.b d2,(a4)+
  70. check_sizes
  71. movem.l a4/a5,-(sp)
  72. move.l a4_reg,a4
  73. move.l a5_reg,a5
  74. move.b (a5)+,(a4)+
  75. move.l a5,a5_reg
  76. move.l a4,a4_reg
  77. movem.l (sp)+,a4/a5
  78. subq.w #1,d0
  79. beq.s do_next_line
  80. subq.w #1,d4
  81. beq.s do_next_line
  82. bra.s start_convert
  83. do_next_line
  84. moveq #0,d7
  85. move.w map_xsize(a0),d7
  86. move.w map_datasize(a0),d6
  87. add.l d7,a2_reg ;alien map always byte
  88. asl.w d6,d7
  89. add.l d7,a2
  90. moveq #0,d7
  91. move.w map_allocx(a0),d7
  92. move.w map_allocdatasize(a0),d6
  93. add.l d7,a3_reg ;alien map always byte
  94. asl.w d6,d7
  95. add.l d7,a3
  96. subq.w #1,d1
  97. beq done_all_map
  98. subq.w #1,d3 ; was d2 - bug
  99. beq done_all_map
  100. bra do_x_convert
  101. done_all_map
  102. ******FINISHED
  103. movem.l a1/a0/a6,-(sp)
  104. move.l map_mem(a0),a1
  105. moveq #0,d0
  106. moveq #0,d1
  107. move.w map_allocx(a0),d0
  108. mulu map_allocy(a0),d0
  109. move.w map_allocdatasize(a0),d1
  110. asl.l d1,d0
  111. move.l 4,a6
  112. jsr -210(a6) ;deallocate old memory
  113. movem.l (sp)+,a1/a0/a6
  114. *---dealloc alien mem
  115. movem.l a1/a0/a6,-(sp)
  116. move.l map_alien_mem(a0),a1
  117. moveq #0,d0
  118. moveq #0,d1
  119. move.w map_allocx(a0),d0
  120. mulu map_allocy(a0),d0
  121. move.l 4,a6
  122. jsr -210(a6) ;deallocate old memory
  123. movem.l (sp)+,a1/a0/a6
  124. no_previous_map_allocated
  125. move.l a1,map_mem(a0)
  126. move.l new_alien_mem,map_alien_mem(a0)
  127. move.w map_datasize(a0),map_allocdatasize(a0)
  128. move.w map_xsize(a0),map_allocx(a0)
  129. move.w map_ysize(a0),map_allocy(a0)
  130. *reset
  131. bsr reset_all_page_positions
  132. clr.w map_x_position
  133. clr.w map_y_position
  134. move.w #0,current_block
  135. move.l page_pointer,a0
  136. move.l screen_mem(a0),current_block_mem
  137. end_convert
  138. bsr Calculate_Blocks_In_One_Page
  139. movem.l (sp)+,d0-d7/a0-a6
  140. rts
  141. Calculate_Blocks_In_One_Page
  142. *calc number of blocks in one page*
  143. moveq #0,d1
  144. moveq #0,d2
  145. move.l #main_screen_struct,a0
  146. move.l current_map_ptr,a1
  147. move.w screen_x_size(a0),d1
  148. move.w screen_y_size(a0),d2
  149. divu map_block_size(a1),d1
  150. divu map_block_size(a1),d2
  151. move.w d1,num_x_blocks_in_page
  152. mulu d1,d2
  153. move.w d2,num_blocks_in_page
  154. move.w #BUTTON_WINDOW_OFFSET,d0
  155. divu map_block_size(a1),d0
  156. move.w d0,num_y_blocks_in_page
  157. rts
  158. num_x_blocks_in_page
  159. dc.w 0
  160. num_y_blocks_in_page
  161. dc.w 0
  162. new_alien_mem
  163. dc.l 0
  164. a2_reg dc.l 0
  165. a3_reg dc.l 0
  166. a4_reg dc.l 0
  167. a5_reg dc.l 0
  168. num_blocks_in_page
  169. dc.w 320 ;default
  170. *****************************************
  171. *** DISPLAY X Y ***
  172. *****************************************
  173. Display_X_Y
  174. tst edit_data_flag
  175. bne.s display_those_xy
  176. cmp.w #1,edit_mode
  177. beq.s display_those_xy
  178. rts
  179. display_those_xy
  180. bsr Remove_Edit_Nums
  181. bsr Display_Edit_Nums
  182. rts
  183. *******************************************
  184. ****** DISPLAY EDIT BUTTONS ******
  185. *******************************************
  186. display_edit_buttons
  187. move.w #1,show_box2 ;current block box
  188. move.l #edit_page_buttons,a0 ;depress current page
  189. moveq #0,d0
  190. move.w current_page,d0
  191. asl.w #2,d0
  192. move.l (a0,d0.w),a0
  193. move.b #1,button_start(a0)
  194. move.l #top_level_list,a0
  195. bsr remove_button_list
  196. move.l #edit_buttons_list,a0
  197. bsr display_button_list
  198. bsr display_map_on_screen
  199. tst.w fullscreen_mode
  200. bne.s dont_display_extras
  201. bsr display_blocks_on_screen
  202. bsr display_box_sprite2
  203. dont_display_extras
  204. bsr display_edit_text
  205. bsr draw_current_buff_name
  206. bsr Display_Selected_Block_Num
  207. bsr display_edit_nums
  208. move.w #ADD_BLOCK_MODE,map_function_mode
  209. move.w #1,edit_mode
  210. rts
  211. *******************************************
  212. ****** REMOVE EDIT BUTTONS ******
  213. *******************************************
  214. remove_edit_buttons
  215. move.l #edit_buttons_list,a0
  216. bsr remove_button_list
  217. move.l #top_level_list,a0
  218. bsr display_button_list
  219. bsr clear_screen
  220. bsr remove_edit_text
  221. bsr remove_edit_nums
  222. bsr remove_current_buff_name
  223. bsr Remove_Selected_Block_Num
  224. move.w #0,edit_mode
  225. move.w #0,sprite_to_attach
  226. move.w #0,show_box2
  227. bsr position_box_sprite2
  228. bsr remove_undo
  229. rts
  230. edit_mode
  231. dc.w 0
  232. *******************************************
  233. ****** EDIT MAP PALETTE ******
  234. *******************************************
  235. edit_map_palette
  236. move.w #0,sprite_to_attach
  237. move.w #ADD_BLOCK_MODE,map_function_mode
  238. bsr set_up_palette_window
  239. rts
  240. *******************************************
  241. ****** HANDY WRITE ******
  242. *******************************************
  243. handy_write
  244. move.l #button_window_struct,a0
  245. move.w #(540+9*5)+2,d0
  246. move.w #42,d1
  247. move.w #4,d2
  248. move.w #1,d4
  249. bsr write_button_num
  250. rts
  251. *******************************************
  252. ****** DISPLAY SELECTED BLOCK NUM ******
  253. *******************************************
  254. Display_Selected_Block_Num
  255. move.w #1,d4
  256. bsr Display_Blk_Num
  257. rts
  258. Remove_Selected_Block_Num
  259. move.w #0,d4
  260. bsr Display_Blk_Num
  261. rts
  262. Display_Blk_Num
  263. move.l #button_window_struct,a0
  264. move.w #440+8,d0
  265. move.w #FOURTH_ROW+5,d1
  266. move.w #4,d2
  267. move.w current_block,d3
  268. bsr write_button_num
  269. rts
  270. *******************************************
  271. ****** DISPLAY EDIT NUMS ******
  272. *******************************************
  273. display_edit_nums
  274. move.l current_map_ptr,a0
  275. bsr convert_mouse_and_store
  276. divu map_block_size(a0),d0
  277. divu map_block_size(a0),d1
  278. move.w map_x_position,d3
  279. add.w d0,d3
  280. move.w d3,last_posx
  281. move.w map_y_position,d2
  282. add.w d1,d2
  283. move.w d2,last_posy
  284. move.l #button_window_struct,a0
  285. move.w #(540+9*5)+2,d0
  286. move.w #FIRST_ROW,d1
  287. move.w #4,d2
  288. move.w #1,d4
  289. bsr write_button_num
  290. move.l #button_window_struct,a0
  291. move.w #(540+9*5)+2,d0
  292. move.w #FIRST_ROW+11,d1
  293. move.w #4,d2
  294. move.w #1,d4
  295. move.w last_posy,d3
  296. bsr write_button_num
  297. rts
  298. *******************************************
  299. ****** REMOVE EDIT NUMS ******
  300. *******************************************
  301. remove_edit_nums
  302. move.l #button_window_struct,a0
  303. move.w #(540+9*5)+2,d0
  304. move.w #FIRST_ROW,d1
  305. move.w #4,d2
  306. move.w #0,d4
  307. move.w last_posx,d3
  308. bsr write_button_num
  309. move.l #button_window_struct,a0
  310. move.w #(540+9*5)+2,d0
  311. move.w #FIRST_ROW+11,d1
  312. move.w #4,d2
  313. move.w #0,d4
  314. move.w last_posy,d3
  315. bsr write_button_num
  316. rts
  317. last_posx dc.w 0
  318. last_posy dc.w 0
  319. *******************************************
  320. ****** DISPLAY EDIT TEXT ******
  321. *******************************************
  322. display_edit_text
  323. move.l #button_window_struct,a0
  324. move.l #edit_text,a1
  325. move.w #540+9,d0
  326. move.w #FIRST_ROW,d1
  327. move.w #4,d2
  328. move.w #1,d3
  329. bsr write_button_text
  330. rts
  331. *******************************************
  332. ****** REMOVE EDIT TEXT ******
  333. *******************************************
  334. remove_edit_text
  335. move.l #button_window_struct,a0
  336. move.l #edit_text,a1
  337. move.w #540+9,d0
  338. move.w #FIRST_ROW,d1
  339. move.w #4,d2
  340. move.w #0,d3
  341. bsr write_button_text
  342. rts
  343. edit_text
  344. dc.b " X :",$a
  345. dc.b " Y :",0
  346. even
  347. *******************************************
  348. ****** DISPLAY BLOCKS ON SCREEN ******
  349. *******************************************
  350. display_blocks_on_screen
  351. tst.w fullscreen_mode
  352. bne end_display_blocks
  353. bsr position_box_sprite2
  354. move.l page_pointer,a0
  355. move.l screen_palette(a0),a1
  356. bsr setup_screen_colours
  357. move.l #main_screen_struct,a2
  358. move.w screen_y_pos(a0),d0
  359. move.w screen_x_size(a2),d1
  360. asr.w #3,d1
  361. mulu d0,d1
  362. move.l current_map_ptr,a4
  363. move.w map_planes(a4),d7
  364. subq.w #1,d7
  365. move.l screen_mem(a0),a0
  366. add.l d1,a0
  367. move.l screen_mem(a2),a1
  368. move.w screen_x_size(a2),d1
  369. asr.w #3,d1
  370. move.w d1,d4
  371. mulu #BUTTON_WINDOW_OFFSET-32,d4
  372. add.l d4,a1 ;so starts down bottom
  373. mulu screen_y_size(a2),d1 ;plane
  374. copy_planes_blocks
  375. move.l a0,a2 ;page
  376. move.l a1,a3 ;screen
  377. move.l #(10*32)-1,d0
  378. copy_chunk
  379. move.l (a2)+,(a3)+
  380. dbra d0,copy_chunk
  381. add.l d1,a0
  382. add.l d1,a1
  383. dbra d7,copy_planes_blocks
  384. bsr display_lines_on_screen
  385. end_display_blocks
  386. rts
  387. *******************************************
  388. ****** DISPLAY LINES ON SCREEN ******
  389. *******************************************
  390. display_lines_on_screen
  391. tst.w fullscreen_mode
  392. bne dont_display_grid_lines
  393. tst.w grid_on
  394. beq dont_display_grid_lines
  395. move.l current_map_ptr,a1
  396. move.l #main_screen_struct,a0
  397. move.l screen_mem(a0),a0
  398. move.w map_planes(a1),d5
  399. subq.w #1,d5
  400. draw_lines_planes
  401. move.w #0,d0
  402. move.w #BUTTON_WINDOW_OFFSET-32,d1
  403. move.w #320,d2
  404. move.w #BUTTON_WINDOW_OFFSET-32,d3
  405. draw_lines_down
  406. movem.l d0-d5/a0-a1,-(sp)
  407. bsr dark_line
  408. movem.l (sp)+,d0-d5/a0-a1
  409. add.w map_block_size(a1),d1
  410. move.w d1,d3
  411. cmp.w #BUTTON_WINDOW_OFFSET,d1
  412. ble.s draw_lines_down
  413. move.w #0,d0
  414. move.w #BUTTON_WINDOW_OFFSET-32,d1
  415. move.w #0,d2
  416. move.w #BUTTON_WINDOW_OFFSET,d3
  417. draw_lines_across
  418. movem.l d0-d5/a0-a1,-(sp)
  419. bsr dark_line
  420. movem.l (sp)+,d0-d5/a0-a1
  421. add.w map_block_size(a1),d0
  422. move.w d0,d2
  423. cmp.w #320,d0
  424. ble.s draw_lines_across
  425. move.l #main_screen_struct,a2
  426. move.w screen_x_size(a2),d0
  427. asr.w #3,d0
  428. mulu screen_y_size(a2),d0
  429. add.l d0,a0
  430. dbra d5,draw_lines_planes
  431. dont_display_grid_lines
  432. rts
  433. grid_on
  434. dc.w 1 ;grid lines on
  435. current_block
  436. dc.w 0
  437. *******************************************
  438. ****** DISPLAY MAP ON SCREEN ******
  439. *******************************************
  440. display_map_on_screen
  441. movem.l a6,-(sp)
  442. move.l current_map_ptr,a0
  443. move.l map_mem(a0),a1
  444. moveq #0,d0
  445. moveq #0,d1
  446. moveq #0,d2
  447. moveq #0,d5
  448. move.w map_datasize(a0),d7
  449. move.w map_xsize(a0),d1
  450. ***d1 is size of one line of map
  451. asl.w d7,d1 ;mult up size of map
  452. move.w map_y_position,d2
  453. mulu d1,d2
  454. move.w map_x_position,d3
  455. asl.w d7,d3 ;x pos into map
  456. ******d0 - map data size
  457. ******d1 - one line of map
  458. add.l d3,a1 ; x
  459. add.l d2,a1 ;top left hand corner of map
  460. move.l #main_screen_struct,a6
  461. moveq #0,d0
  462. move.w screen_x_size(a6),d0
  463. move.w map_block_size(a0),d1
  464. divu d1,d0 ; blocks to draw in x axis
  465. move.w d0,d5 ; d5 divide factor
  466. cmp.w map_xsize(a0),d0
  467. ble.s screen_not_bigger_than_xmap
  468. move.w map_xsize(a0),d0
  469. screen_not_bigger_than_xmap
  470. subq.w #1,d0
  471. move.w max_map_screen_pos,d3
  472. ext.l d3
  473. divu d1,d3 ;number of blocks to draw down
  474. cmp.w map_ysize(a0),d3
  475. ble.s screen_not_bigger_than_ymap
  476. move.w map_ysize(a0),d3
  477. screen_not_bigger_than_ymap
  478. subq.w #1,d3
  479. move.l screen_mem(a6),a3
  480. draw_map_y_lines
  481. move.w d0,d2
  482. move.l a1,a2 ;temp pointer for map
  483. move.l a3,a4 ;temp pointer for screen
  484. draw_map_x_lines
  485. moveq #0,d4
  486. tst d7
  487. bne.s map_word
  488. move.b (a2)+,d4
  489. bra.s display_block
  490. map_word
  491. move.w (a2)+,d4
  492. display_block
  493. movem.l d0,-(sp)
  494. *------
  495. divu num_blocks_in_page,d4 ;div by num blocks in one page
  496. move.w d4,d0 ;page num to use
  497. clr.w d4
  498. swap d4 ;new block num
  499. asl #2,d0
  500. *------
  501. move.l #picture_pages,a5
  502. move.l (a5,d0),a5 ;first page
  503. move.l screen_mem(a5),a5 ; page mem
  504. moveq #0,d6
  505. tst d4
  506. beq.s no_divide
  507. divu d5,d4 ;divide block number by divide factor
  508. no_divide
  509. ****value in lower d4 will be the block row number
  510. ****and the remainder will be the number of block along
  511. move.w screen_x_size(a6),d6
  512. asr.w #3,d6
  513. mulu d1,d6 ;one row
  514. moveq #0,d0
  515. move.w d4,d0 ;number of rows
  516. mulu d0,d6 ;total rows down data
  517. add.l d6,a5 ;do
  518. moveq #0,d6
  519. swap d4
  520. moveq #0,d0
  521. move.w d4,d0 ;number of blocks in
  522. moveq #0,d6
  523. move.w d1,d6
  524. asr.w #3,d6 ;get block size into bytes
  525. mulu d0,d6 ;number of blocks in
  526. add.l d6,a5 ;position in graphic data to copy from
  527. movem.l (sp)+,d0
  528. movem.l a0-a1/d7,-(sp)
  529. move.w map_planes(a0),d7 ;number of planes specified by the user for map
  530. move.l a5,a0 ;source - graphic page
  531. move.l a4,a1 ;dest - screen
  532. bsr copy_block_to_block
  533. movem.l (sp)+,a0-a1/d7
  534. ******crasged
  535. moveq #0,d6
  536. move.w d1,d6
  537. asr.w #3,d6 ;get block size into bytes
  538. add.l d6,a4 ;move along block in screen
  539. dbra d2,draw_map_x_lines
  540. moveq #0,d6
  541. move.w screen_x_size(a6),d6
  542. asr.w #3,d6
  543. mulu d1,d6
  544. add.l d6,a3 ;move screen down column
  545. moveq #0,d6
  546. move.w map_xsize(a0),d6
  547. asl.w d7,d6 ;mult up size of map
  548. add.l d6,a1
  549. dbra d3,draw_map_y_lines
  550. movem.l (sp)+,a6
  551. rts
  552. ********************************
  553. **** CHANGE BLOCK PAGE *****
  554. ********************************
  555. change_block_page
  556. move.l clicked_button,a0
  557. move.b button_data(a0),d0
  558. manual_change_block_page
  559. ext.w d0
  560. subq.w #1,d0
  561. cmp.w current_page,d0
  562. bne.s editnot_clicked_on_same_butt
  563. move.b #DEPRESSED,button_start(a0)
  564. bra.s editupdate_gr_button
  565. editnot_clicked_on_same_butt
  566. moveq #0,d1
  567. move.w current_page,d1
  568. move.w d0,current_page
  569. move.l #edit_page_buttons,a0
  570. asl.w #2,d1
  571. move.l (a0,d1.w),a0
  572. move.b #NOT_DEPRESSED,button_start(a0)
  573. editupdate_gr_button
  574. bsr remove_button
  575. bsr display_button
  576. move.l #picture_pages,a0
  577. moveq #0,d0
  578. move.w current_page,d0
  579. asl.w #2,d0
  580. move.l (a0,d0.w),page_pointer
  581. bsr display_blocks_on_screen
  582. rts
  583. ***************************************
  584. **** CHANGE BLOCKS POSITION UP *****
  585. ***************************************
  586. change_blocks_position_up
  587. move.l #main_screen_struct,a0
  588. move.w screen_y_size(a0),d0
  589. sub.w #32,d0 ; gives part of screen hiding
  590. move.l page_pointer,a0
  591. cmp.w screen_y_pos(a0),d0
  592. beq.s no_more_blocks_scroll
  593. move.l current_map_ptr,a1
  594. move.w map_block_size(a1),d0
  595. add.w d0,screen_y_pos(a0)
  596. bsr display_blocks_on_screen
  597. no_more_blocks_scroll
  598. rts
  599. ******************************************
  600. **** CHANGE BLOCKS POSITION DOWN *****
  601. ******************************************
  602. change_blocks_position_down
  603. move.l page_pointer,a0
  604. cmp.w #0,screen_y_pos(a0)
  605. ble.s no_more_blocks_scrolld
  606. move.l current_map_ptr,a1
  607. move.w map_block_size(a1),d0
  608. sub.w d0,screen_y_pos(a0)
  609. bsr display_blocks_on_screen
  610. no_more_blocks_scrolld
  611. rts
  612. map_x_position
  613. dc.w 0
  614. map_y_position
  615. dc.w 0
  616. ******************************************
  617. **** EXECUTE MAP FUNCTION *****
  618. ******************************************
  619. execute_map_function
  620. move.w mouse_y,d0
  621. cmp.w max_map_screen_pos,d0
  622. bge.s quit_add_data
  623. bsr test_for_out_of_bounds
  624. tst.l d0
  625. bmi quit_add_data
  626. moveq #0,d0
  627. move.w map_function_mode,d0
  628. move.l #map_functions,a0
  629. add.l d0,a0
  630. move.l (a0),a0
  631. jsr (a0) ;call relavant function
  632. quit_add_data
  633. rts
  634. left_first
  635. dc.w 0
  636. **************************************
  637. ******** ADD BLOCK TO MAP *****
  638. **************************************
  639. add_block_to_map
  640. tst left_first
  641. bne.s left_hit_by_user
  642. move.w #1,left_first
  643. bsr make_screen_backup
  644. bsr display_undo
  645. left_hit_by_user
  646. bsr convert_mouse_and_store
  647. move.l #main_screen_struct,a0
  648. moveq #0,d2
  649. move.w screen_x_size(a0),d2
  650. asr.w #3,d2
  651. mulu d2,d1
  652. asr.w #3,d0
  653. move.l screen_mem(a0),a1
  654. add.l d1,a1
  655. add.l d0,a1
  656. move.l current_block_mem,a0
  657. move.w current_block,d7
  658. bsr put_data_into_block
  659. move.l current_map_ptr,a2
  660. moveq #0,d7
  661. move.w map_planes(a2),d7
  662. bsr copy_block_to_block
  663. rts
  664. ****************************************
  665. **** PUT DATA INTO BLOCK *****
  666. ****************************************
  667. put_data_into_block
  668. movem.l a0-a2/d1-d7,-(sp)
  669. move.l current_map_ptr,a2
  670. move.l map_mem(a2),a0
  671. move.w map_datasize(a2),d5
  672. moveq #0,d1
  673. move.w map_x_position,d1
  674. asl d5,d1
  675. add.l d1,a0
  676. move.w map_y_position,d1
  677. move.w map_xsize(a2),d6
  678. asl.w d5,d6
  679. mulu d6,d1
  680. add.l d1,a0 ;map position
  681. bsr convert_mouse_and_store
  682. divu map_block_size(a2),d0
  683. swap d0
  684. clr.w d0
  685. swap d0
  686. move.w d0,d2
  687. add.w map_x_position,d2
  688. addq.w #1,d2
  689. asl d5,d0
  690. add.l d0,a0
  691. divu map_block_size(a2),d1
  692. move.w d1,d0
  693. add.w map_y_position,d0
  694. addq.w #1,d0
  695. mulu d6,d1
  696. add.l d1,a0 ;got it !!!!
  697. *---
  698. * move.w current_page,d1
  699. * mulu num_blocks_in_page,d1 ;blocks page
  700. * add.w d1,d7
  701. *----
  702. tst d5
  703. bne.s word_data_map
  704. move.b d7,(a0)
  705. bra.s quit_place_ok
  706. word_data_map
  707. move.w d7,(a0)
  708. quit_place_ok
  709. movem.l (sp)+,a0-a2/d1-d7
  710. rts
  711. ******************************************
  712. **** TEST FOR OUT OF BOUNDS *****
  713. ******************************************
  714. test_for_out_of_bounds
  715. movem.l a0-a5/d1-d7,-(sp)
  716. move.l current_map_ptr,a2
  717. move.w map_datasize(a2),d5
  718. moveq #0,d1
  719. move.w map_x_position,d1
  720. asl d5,d1
  721. move.w map_y_position,d1
  722. move.w map_xsize(a2),d6
  723. asl.w d5,d6
  724. bsr convert_mouse_and_store
  725. divu map_block_size(a2),d0
  726. swap d0
  727. clr.w d0
  728. swap d0
  729. move.w d0,d2
  730. add.w map_x_position,d2
  731. addq.w #1,d2
  732. cmp.w map_xsize(a2),d2
  733. bgt.s dont_put_data_in_out_of_bounds
  734. divu map_block_size(a2),d1
  735. move.w d1,d0
  736. add.w map_y_position,d0
  737. addq.w #1,d0
  738. cmp.w map_ysize(a2),d0
  739. bgt.s dont_put_data_in_out_of_bounds
  740. clr.l d0
  741. bra.s quit_test_bounds
  742. dont_put_data_in_out_of_bounds
  743. moveq #-1,d0
  744. quit_test_bounds
  745. movem.l (sp)+,a0-a5/d1-d7
  746. rts
  747. right_first
  748. dc.w 0
  749. ******************************************
  750. **** DELETE MAP BLOCK *****
  751. ******************************************
  752. delete_map_block
  753. cmp.w #ADD_BLOCK_MODE,map_function_mode
  754. beq.s ok_in_right_mode
  755. move.w #0,sprite_to_attach
  756. move.w #ADD_BLOCK_MODE,map_function_mode
  757. ***wait for mouse button to come back up
  758. wait_for_release
  759. btst #10,$dff016
  760. beq.s wait_for_release
  761. rts ;have reset back to default edit mode
  762. ok_in_right_mode
  763. move.w mouse_y,d2
  764. cmp.w max_map_screen_pos,d2
  765. bge.s quit_del_data
  766. bsr test_for_out_of_bounds
  767. tst.l d0
  768. bmi quit_del_data
  769. tst right_first
  770. bne.s right_down_by_user
  771. move.w #1,right_first
  772. bsr make_screen_backup
  773. bsr display_undo
  774. right_down_by_user
  775. bsr convert_mouse_and_store
  776. move.l #main_screen_struct,a0
  777. moveq #0,d2
  778. move.w screen_x_size(a0),d2
  779. asr.w #3,d2
  780. mulu d2,d1
  781. asr.w #3,d0
  782. move.l screen_mem(a0),a1
  783. add.l d1,a1
  784. add.l d0,a1
  785. move.l delete_block_mem,a0
  786. move.l current_map_ptr,a2
  787. move.w delete_block,d7
  788. bsr put_data_into_block
  789. move.w map_planes(a2),d7
  790. bsr copy_block_to_block
  791. quit_del_data
  792. rts
  793. ******************************************
  794. **** update_current_block *****
  795. ******************************************
  796. update_current_block
  797. bsr Remove_Selected_Block_Num
  798. moveq #0,d0
  799. moveq #0,d1
  800. moveq #0,d4
  801. moveq #0,d5
  802. move.w mouse_x,d0
  803. move.w mouse_y,d1
  804. move.l page_pointer,a0
  805. sub.w max_map_screen_pos,d1
  806. add.w screen_y_pos(a0),d1
  807. move.l current_map_ptr,a1
  808. move.w map_block_size(a1),d3
  809. cmp.w #8,d3
  810. bne.s current_block16
  811. andi.w #$fff8,d0
  812. move.w d0,d5
  813. andi.w #$fff8,d1
  814. move.w d1,d4
  815. asr.w #3,d1
  816. asr.w #3,d0
  817. mulu #40,d1
  818. bra.s store_current_block
  819. current_block16
  820. cmp.w #16,d3
  821. bne.s current_block32
  822. andi.w #$fff0,d0
  823. move.w d0,d5
  824. andi.w #$fff0,d1
  825. move.w d1,d4
  826. asr.w #4,d1
  827. asr.w #4,d0
  828. mulu #20,d1
  829. bra.s store_current_block
  830. current_block32
  831. andi.w #$ffe0,d0
  832. move.w d0,d5
  833. andi.w #$ffe0,d1
  834. move.w d1,d4
  835. asr.w #5,d1
  836. asr.w #5,d0
  837. mulu #10,d1
  838. store_current_block
  839. add.w d0,d1
  840. move.w d1,current_block
  841. move.w num_blocks_in_page,d0
  842. mulu current_page,d0
  843. add.w d0,current_block
  844. ****test if block > map data
  845. move.l #main_screen_struct,a1
  846. move.w screen_x_size(a1),d0
  847. asr.w #3,d0
  848. mulu d0,d4
  849. asr.w #3,d5
  850. add.l d5,d4
  851. move.l screen_mem(a0),a0
  852. add.l d4,a0
  853. move.l a0,current_block_mem
  854. bsr position_box_sprite2
  855. bsr Display_Selected_Block_Num
  856. rts
  857. convert_block_number_to_memory
  858. moveq #0,d0
  859. move.w current_block,d0
  860. bsr Get_Block_Mem_Pos
  861. move.l a2,current_block_mem
  862. rts
  863. convert_delete_block_number_to_memory
  864. moveq #0,d0
  865. move.w delete_block,d0
  866. bsr Get_Block_Mem_Pos
  867. move.l a2,delete_block_mem
  868. rts
  869. Get_Block_Mem_Pos
  870. *Send in d0 returns a2
  871. clr.l d1
  872. move.w num_blocks_in_page,d1
  873. divu d1,d0
  874. move.w d0,d1 ;number of pages
  875. clr.w d0
  876. swap d0 ;remainder into page
  877. lsl.w #2,d1
  878. move.l #picture_pages,a0
  879. move.l (a0,d1),a0
  880. move.l screen_mem(a0),a2
  881. move.l #main_screen_struct,a1
  882. move.w screen_x_size(a1),d2
  883. asr.w #3,d2 ;number of bytes per row
  884. moveq #0,d1
  885. move.l current_map_ptr,a1
  886. cmp.w #8,map_block_size(a1)
  887. beq.s rs40
  888. cmp.w #16,map_block_size(a1)
  889. beq.s rs20
  890. divu #10,d0
  891. swap d0
  892. move.w d0,d1
  893. swap d0
  894. asl #2,d1
  895. asl.w #5,d0 ;get size of one line
  896. bra.s convert_to_mem
  897. rs40
  898. divu #40,d0
  899. swap d0
  900. move.w d0,d1
  901. swap d0
  902. asl.w #3,d0 ;get size of one line
  903. bra.s convert_to_mem
  904. rs20
  905. divu #20,d0
  906. swap d0
  907. move.w d0,d1
  908. swap d0
  909. asl d1
  910. asl.w #4,d0 ;get size of one line
  911. convert_to_mem
  912. mulu d2,d0 ;row start
  913. add.l d0,a2
  914. add.l d1,a2
  915. rts
  916. current_block_mem
  917. dc.l 0
  918. current_block_x
  919. dc.w 0
  920. current_block_y
  921. dc.w 0
  922. ******************************************
  923. **** SCROLL MAP DOWN *****
  924. ******************************************
  925. scroll_map_down
  926. ifnd hard_only
  927. bsr own_the_blitter
  928. endc
  929. move.l current_map_ptr,a0
  930. move.w max_map_screen_pos,d0
  931. ext.l d0
  932. divu map_block_size(a0),d0
  933. add.w map_y_position,d0
  934. cmp.w map_ysize(a0),d0
  935. bge no_scroll_map_down
  936. *bsr sync
  937. addq.w #1,map_y_position
  938. moveq #0,d2
  939. move.l #main_screen_struct,a0
  940. move.l current_map_ptr,a1
  941. move.w map_block_size(a1),d4
  942. move.l screen_mem(a0),a2
  943. move.w screen_x_size(a0),d0
  944. move.w max_map_screen_pos,d2
  945. sub.w d4,d2
  946. move.w screen_y_size(a0),d5
  947. asl.w #6,d2
  948. asr.w #3,d0
  949. mulu d0,d5 ;num to next planes
  950. mulu d0,d4 ;chunk to move down
  951. asr.w d0
  952. add.w d0,d2 ;d2 = blit size
  953. move.w map_planes(a1),d1
  954. subq.w #1,d1
  955. scroll_map_loop
  956. btst #14,DMACONR(a6)
  957. bne.s scroll_map_loop
  958. move.l a2,bltdpt(a6)
  959. move.l a2,a3
  960. add.l d4,a3
  961. move.l a3,bltapt(a6)
  962. clr.w bltamod(a6)
  963. clr.w bltdmod(a6)
  964. move.l #$ffffffff,bltafwm(a6)
  965. move.l #$09f00000,bltcon0(a6)
  966. move.w d2,bltsize(a6)
  967. add.l d5,a2
  968. dbra d1,scroll_map_loop
  969. bsr copy_blocks_bottom
  970. no_scroll_map_down
  971. ifnd hard_only
  972. bsr disown_the_blitter
  973. endc
  974. rts
  975. ******************************************
  976. **** SCROLL MAP UP *****
  977. ******************************************
  978. scroll_map_up
  979. ifnd hard_only
  980. bsr own_the_blitter
  981. endc
  982. tst map_y_position
  983. beq no_scroll_up_map
  984. *bsr sync
  985. subq.w #1,map_y_position
  986. moveq #0,d2
  987. move.l #main_screen_struct,a0
  988. move.l current_map_ptr,a1
  989. move.w map_block_size(a1),d4
  990. move.l screen_mem(a0),a2
  991. move.w screen_x_size(a0),d0
  992. move.w max_map_screen_pos,d2
  993. sub.w d4,d2
  994. move.w d2,d6
  995. move.w screen_y_size(a0),d5
  996. asl.w #6,d2
  997. asr.w #3,d0
  998. mulu d0,d5 ;num to next planes
  999. mulu d0,d4 ;chunk to move down
  1000. mulu d0,d6
  1001. asr.w d0
  1002. add.w d0,d2 ;d2 = blit size
  1003. add.l d6,a2
  1004. subq.l #2,a2
  1005. move.w map_planes(a1),d1
  1006. subq.w #1,d1
  1007. scroll_map_loop_up
  1008. btst #14,DMACONR(a6)
  1009. bne.s scroll_map_loop_up
  1010. move.l a2,bltapt(a6)
  1011. move.l a2,a3
  1012. add.l d4,a3
  1013. move.l a3,bltdpt(a6)
  1014. clr.w bltamod(a6)
  1015. clr.w bltdmod(a6)
  1016. move.l #$ffffffff,bltafwm(a6)
  1017. move.l #$09f00002,bltcon0(a6)
  1018. move.w d2,bltsize(a6)
  1019. add.l d5,a2
  1020. dbra d1,scroll_map_loop_up
  1021. ***copy block line
  1022. bsr copy_blocks_top
  1023. no_scroll_up_map
  1024. ifnd hard_only
  1025. bsr disown_the_blitter
  1026. endc
  1027. rts
  1028. ******************************************
  1029. **** SCROLL MAP RIGHT *****
  1030. ******************************************
  1031. scroll_map_RIGHT
  1032. ifnd hard_only
  1033. bsr own_the_blitter
  1034. endc
  1035. tst map_x_position
  1036. beq no_scroll_right_map
  1037. *jsr sync
  1038. subq.w #1,map_x_position
  1039. move.l #main_screen_struct,a0
  1040. move.l current_map_ptr,a1
  1041. cmp.w #8,map_block_size(a1)
  1042. beq scroll_right_8
  1043. moveq #0,d2
  1044. moveq #0,d6
  1045. move.w map_block_size(a1),d4
  1046. move.w d4,d6
  1047. divu #16,d6 ;bottom half will be number of words in
  1048. swap d6
  1049. move.w d6,d7 ;d7 is pixel shift to right
  1050. ror.w #4,d7
  1051. ori.w #$09f0,d7 ;terms
  1052. swap d7
  1053. move.w #2,d7 ;set decending
  1054. move.w #0,d6
  1055. swap d6
  1056. move.l screen_mem(a0),a2
  1057. move.w screen_x_size(a0),d0
  1058. move.w max_map_screen_pos,d2
  1059. move.w screen_y_size(a0),d5
  1060. asl.w #6,d2
  1061. asr.w #3,d0
  1062. move.w d0,d3
  1063. mulu d0,d5 ;num to next planes
  1064. asr.w d0
  1065. sub.w d6,d0 ;minus shift size
  1066. add.w d0,d2 ;d2 = blit size
  1067. asl.w d6 ;to give bytes
  1068. move.w max_map_screen_pos,d4
  1069. mulu d3,d4
  1070. add.l d4,a2
  1071. sub.l #2,a2 ;put at bottom
  1072. sub.l d6,a2 ;start in
  1073. move.w map_planes(a1),d1
  1074. subq.w #1,d1
  1075. scroll_map_loop_right
  1076. btst #14,DMACONR(a6)
  1077. bne.s scroll_map_loop_right
  1078. move.l a2,bltapt(a6)
  1079. move.l a2,a3
  1080. add.l d6,a3
  1081. move.l a3,bltdpt(a6)
  1082. move.w d6,bltamod(a6)
  1083. move.w d6,bltdmod(a6)
  1084. move.l #$ffffffff,bltafwm(a6)
  1085. move.l d7,bltcon0(a6)
  1086. move.w d2,bltsize(a6)
  1087. add.l d5,a2
  1088. dbra d1,scroll_map_loop_right
  1089. ***copy block line
  1090. bsr copy_blocks_left
  1091. no_scroll_right_map
  1092. ifnd hard_only
  1093. bsr disown_the_blitter
  1094. endc
  1095. rts
  1096. scroll_right_8
  1097. ifnd hard_only
  1098. bsr own_the_blitter
  1099. endc
  1100. move.l screen_mem(a0),a2
  1101. move.w screen_x_size(a0),d0
  1102. move.w max_map_screen_pos,d2
  1103. move.w screen_y_size(a0),d5
  1104. asl.w #6,d2
  1105. asr.w #3,d0
  1106. mulu d0,d5 ;num to next planes
  1107. asr.w d0
  1108. add.w d0,d2 ;d2 = blit size
  1109. move.w map_planes(a1),d1
  1110. subq.w #1,d1
  1111. scroll8_map_loop_right
  1112. btst #14,DMACONR(a6)
  1113. bne.s scroll8_map_loop_right
  1114. move.l a2,bltapt(a6)
  1115. move.l a2,bltdpt(a6)
  1116. move.w #0,bltamod(a6)
  1117. move.w #0,bltdmod(a6)
  1118. move.l #$ffffffff,bltafwm(a6)
  1119. move.l #$89f00000,bltcon0(a6)
  1120. move.w d2,bltsize(a6)
  1121. add.l d5,a2
  1122. dbra d1,scroll8_map_loop_right
  1123. bsr copy_blocks_left
  1124. ifnd hard_only
  1125. bsr disown_the_blitter
  1126. endc
  1127. rts
  1128. ******************************************
  1129. **** SCROLL MAP LEFT *****
  1130. ******************************************
  1131. scroll_map_left
  1132. ifnd hard_only
  1133. bsr own_the_blitter
  1134. endc
  1135. move.l current_map_ptr,a1
  1136. move.l #main_screen_struct,a0
  1137. move.w screen_x_size(a0),d0
  1138. divu map_block_size(a1),d0
  1139. add.w map_x_position,d0
  1140. cmp.w map_xsize(a1),d0
  1141. bge no_scroll_left_map
  1142. addq.w #1,map_x_position
  1143. move.l current_map_ptr,a1
  1144. moveq #0,d2
  1145. move.l #main_screen_struct,a0
  1146. cmp.w #8,map_block_size(a1)
  1147. beq.s shift_by_8_pixels
  1148. moveq #0,d6
  1149. move.w map_block_size(a1),d4
  1150. move.w d4,d6
  1151. divu #16,d6 ;bottom half will be number of words in
  1152. swap d6
  1153. move.w d6,d7 ;d7 is pixel shift to right
  1154. ror.w #4,d7
  1155. ori.w #$09f0,d7 ;terms
  1156. swap d7
  1157. move.w #0,d7
  1158. move.w #0,d6
  1159. swap d6
  1160. move.l screen_mem(a0),a2
  1161. move.w screen_x_size(a0),d0
  1162. move.w max_map_screen_pos,d2
  1163. move.w screen_y_size(a0),d5
  1164. asl.w #6,d2
  1165. asr.w #3,d0
  1166. mulu d0,d5 ;num to next planes
  1167. asr.w d0
  1168. sub.w d6,d0 ;minus shift size
  1169. add.w d0,d2 ;d2 = blit size
  1170. asl.w d6 ;to give bytes
  1171. move.w map_planes(a1),d1
  1172. subq.w #1,d1
  1173. scroll_map_loop_left
  1174. btst #14,DMACONR(a6)
  1175. bne.s scroll_map_loop_left
  1176. move.l a2,bltdpt(a6)
  1177. move.l a2,a3
  1178. add.l d6,a3
  1179. move.l a3,bltapt(a6)
  1180. move.w d6,bltamod(a6)
  1181. move.w d6,bltdmod(a6)
  1182. move.l #$ffffffff,bltafwm(a6)
  1183. move.l d7,bltcon0(a6)
  1184. move.w d2,bltsize(a6)
  1185. add.l d5,a2
  1186. dbra d1,scroll_map_loop_left
  1187. ***copy block line
  1188. bsr copy_blocks_right
  1189. no_scroll_left_map
  1190. ifnd hard_only
  1191. bsr disown_the_blitter
  1192. endc
  1193. rts
  1194. shift_by_8_pixels
  1195. ifnd hard_only
  1196. bsr own_the_blitter
  1197. endc
  1198. move.l screen_mem(a0),a2
  1199. move.w screen_x_size(a0),d0
  1200. move.w max_map_screen_pos,d2
  1201. move.w screen_y_size(a0),d5
  1202. asl.w #6,d2
  1203. asr.w #3,d0
  1204. move.w max_map_screen_pos,d3
  1205. mulu d0,d3
  1206. add.l d3,a2
  1207. subq.l #2,a2
  1208. mulu d0,d5 ;num to next planes
  1209. asr.w d0
  1210. add.w d0,d2 ;d2 = blit size
  1211. move.w map_planes(a1),d1
  1212. subq.w #1,d1
  1213. scroll8_map_loop_left
  1214. btst #14,DMACONR(a6)
  1215. bne.s scroll8_map_loop_left
  1216. move.l a2,bltapt(a6)
  1217. move.l a2,bltdpt(a6)
  1218. move.w #0,bltamod(a6)
  1219. move.w #0,bltdmod(a6)
  1220. move.l #$ffffffff,bltafwm(a6)
  1221. move.l #$89f00002,bltcon0(a6)
  1222. move.w d2,bltsize(a6)
  1223. add.l d5,a2
  1224. dbra d1,scroll8_map_loop_left
  1225. bsr copy_blocks_right
  1226. ifnd hard_only
  1227. bsr disown_the_blitter
  1228. endc
  1229. rts
  1230. ******************************************
  1231. **** WAIT BLIT FIN *****
  1232. ******************************************
  1233. wait_blit_fin
  1234. btst #14,dmaconr(a6)
  1235. bne.s wait_blit_fin
  1236. rts
  1237. ******************************************
  1238. **** COPY BLOCKS BOTTOM *****
  1239. ******************************************
  1240. copy_blocks_bottom
  1241. bsr wait_blit_fin
  1242. movem.l a6,-(sp)
  1243. move.l current_map_ptr,a0
  1244. move.l map_mem(a0),a1
  1245. moveq #0,d0
  1246. moveq #0,d1
  1247. moveq #0,d2
  1248. move.w map_datasize(a0),d7
  1249. move.w map_xsize(a0),d1
  1250. asl.w d7,d1 ;mult up size of map
  1251. move.w map_y_position,d2
  1252. move.w max_map_screen_pos,d3
  1253. ext.l d3
  1254. divu map_block_size(a0),d3
  1255. subq.w #1,d3
  1256. add.w d3,d2 ;add so bottom line is being used
  1257. moveq #0,d3
  1258. mulu d1,d2
  1259. move.w map_x_position,d3
  1260. asl.w d7,d3 ;x pos into map
  1261. add.l d3,a1 ; x
  1262. add.l d2,a1 ;top left hand corner of map
  1263. move.l #main_screen_struct,a6
  1264. moveq #0,d0
  1265. move.w screen_x_size(a6),d0
  1266. move.w d0,d6
  1267. move.w map_block_size(a0),d1
  1268. divu d1,d0 ; blocks to draw in x axis
  1269. move.w d0,d5 ; d5 divide factor
  1270. move.l screen_mem(a6),a3
  1271. move.w max_map_screen_pos,d2
  1272. sub.w d1,d2
  1273. asr.w #3,d6
  1274. mulu d6,d2
  1275. add.l d2,a3 ;move it down to bottom of blocks
  1276. move.w d0,d2
  1277. cmp.w map_xsize(a0),d2
  1278. ble.s not_bigger_bottom
  1279. move.w map_xsize(a0),d2
  1280. not_bigger_bottom
  1281. subq.w #1,d2
  1282. move.l a1,a2 ;temp pointer for map
  1283. move.l a3,a4 ;temp pointer for screen
  1284. scroll_updraw_map_x_lines
  1285. moveq #0,d4
  1286. tst d7
  1287. bne.s scumap_word
  1288. move.b (a2)+,d4
  1289. bra.s scudisplay_block
  1290. scumap_word
  1291. move.w (a2)+,d4
  1292. scudisplay_block
  1293. *------
  1294. moveq #0,d6
  1295. divu num_blocks_in_page,d4 ;div by num blocks in one page
  1296. move.w d4,d6 ;page num to use
  1297. clr.w d4
  1298. swap d4 ;new block num
  1299. asl #2,d6
  1300. *------
  1301. move.l #picture_pages,a5
  1302. move.l (a5,d6),a5 ;first page
  1303. move.l screen_mem(a5),a5 ; page mem
  1304. moveq #0,d6
  1305. tst d4
  1306. beq.s scuno_divide
  1307. divu d5,d4 ;divide block number by divide factor
  1308. scuno_divide
  1309. move.w screen_x_size(a6),d6
  1310. asr.w #3,d6
  1311. mulu d1,d6 ;one row
  1312. moveq #0,d0
  1313. move.w d4,d0 ;number of rows
  1314. mulu d0,d6 ;total rows down data
  1315. add.l d6,a5 ;do
  1316. moveq #0,d6
  1317. swap d4
  1318. moveq #0,d0
  1319. move.w d4,d0 ;number of blocks in
  1320. moveq #0,d6
  1321. move.w d1,d6
  1322. asr.w #3,d6 ;get block size into bytes
  1323. mulu d0,d6 ;number of blocks in
  1324. add.l d6,a5 ;position in graphic data to copy from
  1325. movem.l a0-a1/d7,-(sp)
  1326. move.w map_planes(a0),d7 ;number of planes specified by the user for map
  1327. move.l a5,a0 ;source - graphic page
  1328. move.l a4,a1 ;dest - screen
  1329. bsr copy_block_to_block
  1330. movem.l (sp)+,a0-a1/d7
  1331. moveq #0,d6
  1332. move.w d1,d6
  1333. asr.w #3,d6 ;get block size into bytes
  1334. add.l d6,a4 ;move along block in screen
  1335. dbra d2,scroll_updraw_map_x_lines
  1336. movem.l (sp)+,a6
  1337. rts
  1338. ******************************************
  1339. **** COPY BLOCKS TOP *****
  1340. ******************************************
  1341. copy_blocks_top
  1342. ***copy blocks in gap
  1343. bsr wait_blit_fin
  1344. movem.l a6,-(sp)
  1345. move.l current_map_ptr,a0
  1346. move.l map_mem(a0),a1
  1347. moveq #0,d0
  1348. moveq #0,d1
  1349. moveq #0,d2
  1350. move.w map_datasize(a0),d7
  1351. move.w map_xsize(a0),d1
  1352. asl.w d7,d1 ;mult up size of map
  1353. move.w map_y_position,d2
  1354. mulu d1,d2
  1355. moveq #0,d3
  1356. move.w map_x_position,d3
  1357. asl.w d7,d3 ;x pos into map
  1358. add.l d3,a1 ; x
  1359. add.l d2,a1 ;top left hand corner of map
  1360. move.l #main_screen_struct,a6
  1361. moveq #0,d0
  1362. move.w screen_x_size(a6),d0
  1363. move.w map_block_size(a0),d1
  1364. divu d1,d0 ; blocks to draw in x axis
  1365. move.w d0,d5 ; d5 divide factor
  1366. move.l screen_mem(a6),a3
  1367. move.w d0,d2
  1368. cmp.w map_xsize(a0),d2
  1369. ble.s not_bigger_top
  1370. move.w map_xsize(a0),d2
  1371. not_bigger_top
  1372. subq.w #1,d2
  1373. move.l a1,a2 ;temp pointer for map
  1374. move.l a3,a4 ;temp pointer for screen
  1375. scroll_downdraw_map_x_lines
  1376. moveq #0,d4
  1377. tst d7
  1378. bne.s scdmap_word
  1379. move.b (a2)+,d4
  1380. bra.s scddisplay_block
  1381. scdmap_word
  1382. move.w (a2)+,d4
  1383. scddisplay_block
  1384. *------
  1385. moveq #0,d6
  1386. divu num_blocks_in_page,d4 ;div by num blocks in one page
  1387. move.w d4,d6 ;page num to use
  1388. clr.w d4
  1389. swap d4 ;new block num
  1390. asl #2,d6
  1391. *------
  1392. move.l #picture_pages,a5
  1393. move.l (a5,d6),a5 ;first page
  1394. move.l screen_mem(a5),a5 ; page mem
  1395. moveq #0,d6
  1396. tst d4
  1397. beq.s scdno_divide
  1398. ext.l d5
  1399. divu d5,d4 ;divide block number by divide factor
  1400. scdno_divide
  1401. move.w screen_x_size(a6),d6
  1402. asr.w #3,d6
  1403. mulu d1,d6 ;one row
  1404. moveq #0,d0
  1405. move.w d4,d0 ;number of rows
  1406. mulu d0,d6 ;total rows down data
  1407. add.l d6,a5 ;do
  1408. moveq #0,d6
  1409. swap d4
  1410. moveq #0,d0
  1411. move.w d4,d0 ;number of blocks in
  1412. moveq #0,d6
  1413. move.w d1,d6
  1414. asr.w #3,d6 ;get block size into bytes
  1415. mulu d0,d6 ;number of blocks in
  1416. add.l d6,a5 ;position in graphic data to copy from
  1417. movem.l a0-a1/d7,-(sp)
  1418. move.w map_planes(a0),d7 ;number of planes specified by the user for map
  1419. move.l a5,a0 ;source - graphic page
  1420. move.l a4,a1 ;dest - screen
  1421. bsr copy_block_to_block
  1422. movem.l (sp)+,a0-a1/d7
  1423. moveq #0,d6
  1424. move.w d1,d6
  1425. asr.w #3,d6 ;get block size into bytes
  1426. add.l d6,a4 ;move along block in screen
  1427. dbra d2,scroll_downdraw_map_x_lines
  1428. movem.l (sp)+,a6
  1429. rts
  1430. *******************************************
  1431. ****** COPY BLOCKS LEFT ******
  1432. *******************************************
  1433. copy_blocks_left
  1434. bsr wait_blit_fin
  1435. movem.l a6,-(sp)
  1436. move.l current_map_ptr,a0
  1437. move.l map_mem(a0),a1
  1438. moveq #0,d0
  1439. moveq #0,d1
  1440. moveq #0,d2
  1441. moveq #0,d5
  1442. move.w map_datasize(a0),d7
  1443. move.w map_xsize(a0),d1
  1444. asl.w d7,d1 ;mult up size of map
  1445. move.w map_y_position,d2
  1446. mulu d1,d2
  1447. moveq #0,d3
  1448. move.w map_x_position,d3
  1449. asl.w d7,d3 ;x pos into map
  1450. add.l d3,a1 ; x
  1451. add.l d2,a1 ;top left hand corner of map
  1452. move.l #main_screen_struct,a6
  1453. moveq #0,d0
  1454. move.w screen_x_size(a6),d0
  1455. move.w map_block_size(a0),d1
  1456. divu d1,d0 ; blocks to draw in x axis
  1457. move.w d0,d5 ; d5 divide factor
  1458. subq.w #1,d0
  1459. move.w max_map_screen_pos,d3
  1460. ext.l d3
  1461. divu d1,d3 ;number of blocks to draw down
  1462. cmp.w map_ysize(a0),d3
  1463. ble.s not_bigger_left
  1464. move.w map_ysize(a0),d3
  1465. not_bigger_left
  1466. subq.w #1,d3
  1467. move.l screen_mem(a6),a3
  1468. bldraw_map_y_lines
  1469. ;move.w d0,d2
  1470. move.l a1,a2 ;temp pointer for map
  1471. move.l a3,a4 ;temp pointer for screen
  1472. bldraw_map_x_lines
  1473. moveq #0,d4
  1474. tst d7
  1475. bne.s blmap_word
  1476. move.b (a2)+,d4
  1477. bra.s bldisplay_block
  1478. blmap_word
  1479. move.w (a2)+,d4
  1480. bldisplay_block
  1481. movem.l d0,-(sp)
  1482. *------
  1483. moveq #0,d6
  1484. divu num_blocks_in_page,d4 ;div by num blocks in one page
  1485. move.w d4,d6 ;page num to use
  1486. clr.w d4
  1487. swap d4 ;new block num
  1488. asl #2,d6
  1489. *------
  1490. move.l #picture_pages,a5
  1491. move.l (a5,d6),a5 ;first page
  1492. move.l screen_mem(a5),a5 ; page mem
  1493. moveq #0,d6
  1494. tst d4
  1495. beq.s blno_divide
  1496. divu d5,d4 ;divide block number by divide factor
  1497. blno_divide
  1498. move.w screen_x_size(a6),d6
  1499. asr.w #3,d6
  1500. mulu d1,d6 ;one row
  1501. moveq #0,d0
  1502. move.w d4,d0 ;number of rows
  1503. mulu d0,d6 ;total rows down data
  1504. add.l d6,a5 ;do
  1505. moveq #0,d6
  1506. swap d4
  1507. moveq #0,d0
  1508. move.w d4,d0 ;number of blocks in
  1509. moveq #0,d6
  1510. move.w d1,d6
  1511. asr.w #3,d6 ;get block size into bytes
  1512. mulu d0,d6 ;number of blocks in
  1513. add.l d6,a5 ;position in graphic data to copy from
  1514. movem.l (sp)+,d0
  1515. movem.l a0-a1/d7,-(sp)
  1516. move.w map_planes(a0),d7 ;number of planes specified by the user for map
  1517. move.l a5,a0 ;source - graphic page
  1518. move.l a4,a1 ;dest - screen
  1519. bsr copy_block_to_block
  1520. movem.l (sp)+,a0-a1/d7
  1521. moveq #0,d6
  1522. move.w screen_x_size(a6),d6
  1523. asr.w #3,d6
  1524. mulu d1,d6
  1525. add.l d6,a3 ;move screen down column
  1526. moveq #0,d6
  1527. move.w map_xsize(a0),d6
  1528. asl.w d7,d6 ;mult up size of map
  1529. add.l d6,a1
  1530. dbra d3,bldraw_map_y_lines
  1531. movem.l (sp)+,a6
  1532. rts
  1533. *******************************************
  1534. ****** COPY BLOCKS RIGHT ******
  1535. *******************************************
  1536. copy_blocks_right
  1537. bsr wait_blit_fin
  1538. movem.l a6,-(sp)
  1539. move.l current_map_ptr,a0
  1540. move.l map_mem(a0),a1
  1541. move.l #main_screen_struct,a6
  1542. moveq #0,d0
  1543. move.w screen_x_size(a6),d0
  1544. divu map_block_size(a0),d0
  1545. move.w map_datasize(a0),d1
  1546. swap d0
  1547. clr.w d0
  1548. swap d0
  1549. subq.w #1,d0
  1550. asl.w d1,d0
  1551. add.l d0,a1 ;so pointing to blocks far left
  1552. moveq #0,d0
  1553. moveq #0,d1
  1554. moveq #0,d2
  1555. move.w map_datasize(a0),d7
  1556. move.w map_xsize(a0),d1
  1557. asl.w d7,d1 ;mult up size of map
  1558. move.w map_y_position,d2
  1559. mulu d1,d2
  1560. moveq #0,d3
  1561. move.w map_x_position,d3
  1562. asl.w d7,d3 ;x pos into map
  1563. add.l d3,a1 ; x
  1564. add.l d2,a1 ;top left hand corner of map
  1565. moveq #0,d0
  1566. move.w screen_x_size(a6),d0
  1567. move.w map_block_size(a0),d1
  1568. ext.l d0
  1569. divu d1,d0 ; blocks to draw in x axis
  1570. move.w d0,d5 ; d5 divide factor
  1571. subq.w #1,d0
  1572. move.w max_map_screen_pos,d3
  1573. ext.l d3
  1574. divu d1,d3 ;number of blocks to draw down
  1575. cmp.w map_ysize(a0),d3
  1576. ble.s not_bigger_right
  1577. move.w map_ysize(a0),d3
  1578. not_bigger_right
  1579. subq.w #1,d3
  1580. moveq #0,d2
  1581. move.l screen_mem(a6),a3
  1582. move.w screen_x_size(a6),d2
  1583. asr.w #3,d2
  1584. move.w map_block_size(a0),d4
  1585. asr.w #3,d4
  1586. sub.w d4,d2
  1587. add.l d2,a3
  1588. brdraw_map_y_lines
  1589. move.l a1,a2 ;temp pointer for map
  1590. move.l a3,a4 ;temp pointer for screen
  1591. brdraw_map_x_lines
  1592. moveq #0,d4
  1593. tst d7
  1594. bne.s brmap_word
  1595. move.b (a2)+,d4
  1596. bra.s brdisplay_block
  1597. brmap_word
  1598. move.w (a2)+,d4
  1599. brdisplay_block
  1600. movem.l d0,-(sp)
  1601. *------
  1602. moveq #0,d6
  1603. divu num_blocks_in_page,d4 ;div by num blocks in one page
  1604. move.w d4,d6 ;page num to use
  1605. clr.w d4
  1606. swap d4 ;new block num
  1607. asl #2,d6
  1608. *------
  1609. move.l #picture_pages,a5
  1610. move.l (a5,d6),a5 ;first page
  1611. move.l screen_mem(a5),a5 ; page mem
  1612. moveq #0,d6
  1613. tst d4
  1614. beq.s brno_divide
  1615. divu d5,d4 ;divide block number by divide factor
  1616. brno_divide
  1617. move.w screen_x_size(a6),d6
  1618. asr.w #3,d6
  1619. mulu d1,d6 ;one row
  1620. moveq #0,d0
  1621. move.w d4,d0 ;number of rows
  1622. mulu d0,d6 ;total rows down data
  1623. add.l d6,a5 ;do
  1624. moveq #0,d6
  1625. swap d4
  1626. moveq #0,d0
  1627. move.w d4,d0 ;number of blocks in
  1628. moveq #0,d6
  1629. move.w d1,d6
  1630. asr.w #3,d6 ;get block size into bytes
  1631. mulu d0,d6 ;number of blocks in
  1632. add.l d6,a5 ;position in graphic data to copy from
  1633. movem.l (sp)+,d0
  1634. movem.l a0-a1/d7,-(sp)
  1635. move.w map_planes(a0),d7 ;number of planes specified by the user for map
  1636. move.l a5,a0 ;source - graphic page
  1637. move.l a4,a1 ;dest - screen
  1638. bsr copy_block_to_block
  1639. movem.l (sp)+,a0-a1/d7
  1640. moveq #0,d6
  1641. move.w screen_x_size(a6),d6
  1642. asr.w #3,d6
  1643. mulu d1,d6
  1644. add.l d6,a3 ;move screen down column
  1645. moveq #0,d6
  1646. move.w map_xsize(a0),d6
  1647. asl.w d7,d6 ;mult up size of map
  1648. add.l d6,a1
  1649. dbra d3,brdraw_map_y_lines
  1650. movem.l (sp)+,a6
  1651. rts
  1652. *******************************************
  1653. ****** INSERT MAP ROW ******
  1654. *******************************************
  1655. insert_map_row
  1656. move.w #INSERT_ROW_MODE,map_function_mode
  1657. move.w #PICK,sprite_to_attach
  1658. rts
  1659. *******************************************
  1660. ****** DELETE MAP ROW ******
  1661. *******************************************
  1662. delete_map_row
  1663. move.w #DELETE_ROW_MODE,map_function_mode
  1664. move.w #PICK,sprite_to_attach
  1665. rts
  1666. *******************************************
  1667. ****** INSERT MAP COLUMN ******
  1668. *******************************************
  1669. insert_map_column
  1670. move.w #INSERT_COL_MODE,map_function_mode
  1671. move.w #PICK,sprite_to_attach
  1672. rts
  1673. *******************************************
  1674. ****** DELETE MAP COLUMN ******
  1675. *******************************************
  1676. delete_map_column
  1677. move.w #DELETE_COL_MODE,map_function_mode
  1678. move.w #PICK,sprite_to_attach
  1679. rts
  1680. *******************************************
  1681. ****** FILL MAP ******
  1682. *******************************************
  1683. fill_map
  1684. move.w #FILL_WITH_BLOCK,map_function_mode
  1685. move.w #PICK,sprite_to_attach
  1686. rts
  1687. *******************************************
  1688. ****** INSERT MAP ROW FUNCTION ******
  1689. *******************************************
  1690. insert_map_row_function
  1691. bsr remove_undo
  1692. bsr convert_mouse_and_store
  1693. move.l current_map_ptr,a0
  1694. divu map_block_size(a0),d1
  1695. move.w map_ysize(a0),d3 ;map y size
  1696. add.w map_y_position,d1 ;number of lines down
  1697. move.w map_datasize(a0),d0
  1698. moveq #0,d2
  1699. move.w map_xsize(a0),d2
  1700. asl.w d0,d2 ;size of one line
  1701. move.l map_mem(a0),a1
  1702. move.w d2,d4
  1703. move.w d3,d7
  1704. subq.w #1,d7
  1705. mulu d7,d4 ;get to bottom of map
  1706. add.l d4,a1 ;map mem position
  1707. move.l a1,a2
  1708. sub.l d2,a2 ;line to copy from
  1709. sub.w d1,d3 ;number of lines to shift
  1710. subq.w #1,d3 ;sub another one as we lose a line
  1711. * ;as we are copying from the line above
  1712. * ;to the line below
  1713. beq.s dont_shift_anything ;nothing to shift
  1714. insert_row_y
  1715. move.w d2,d4
  1716. subq.w #1,d4 ;size of x line in bytes
  1717. move.l a1,a3 ;dest
  1718. move.l a2,a4 ;source
  1719. insert_row_x
  1720. move.b (a4),(a3)+
  1721. tst d3
  1722. bne.s not_last_line_shifted
  1723. move.b #0,(a4)+
  1724. bra.s shift_cols_up
  1725. not_last_line_shifted
  1726. addq.l #1,a4
  1727. shift_cols_up
  1728. dbra d4,insert_row_x
  1729. sub.l d2,a1
  1730. sub.l d2,a2
  1731. dbra d3,insert_row_y
  1732. bsr display_map_on_screen
  1733. dont_shift_anything
  1734. rts
  1735. *******************************************
  1736. ****** DELETE MAP ROW FUNCTION ******
  1737. *******************************************
  1738. delete_map_row_function
  1739. bsr remove_undo
  1740. bsr convert_mouse_and_store
  1741. move.l current_map_ptr,a0
  1742. divu map_block_size(a0),d1
  1743. move.w map_ysize(a0),d3 ;map y size
  1744. add.w map_y_position,d1 ;number of lines down
  1745. move.w map_datasize(a0),d0
  1746. moveq #0,d2
  1747. move.w map_xsize(a0),d2
  1748. asl.w d0,d2 ;size of one line
  1749. move.l map_mem(a0),a1
  1750. move.w d1,d4
  1751. mulu d2,d4 ;get to position in map
  1752. add.l d4,a1 ;map mem position
  1753. move.l a1,a2
  1754. add.l d2,a2 ;line to copy to
  1755. sub.w d1,d3 ;number of lines to shift
  1756. subq.w #2,d3
  1757. bmi.s dont_delete_anything ;nothing to shift
  1758. delete_row_y
  1759. move.w d2,d4
  1760. subq.w #1,d4 ;size of x line in bytes
  1761. move.l a1,a3 ;dest
  1762. move.l a2,a4 ;source
  1763. delete_row_x
  1764. move.b (a4)+,(a3)+
  1765. dbra d4,delete_row_x
  1766. add.l d2,a1
  1767. add.l d2,a2
  1768. dbra d3,delete_row_y
  1769. dont_delete_anything
  1770. subq.w #1,d2
  1771. delete_last_line_in_map
  1772. move.b #0,(a1)+
  1773. dbra d2,delete_last_line_in_map
  1774. bsr display_map_on_screen
  1775. rts
  1776. *******************************************
  1777. ****** DELETE MAP COLUMN FUNCTION ******
  1778. *******************************************
  1779. delete_map_column_function
  1780. bsr remove_undo
  1781. bsr convert_mouse_and_store
  1782. moveq #0,d1
  1783. move.l current_map_ptr,a0
  1784. divu map_block_size(a0),d0
  1785. add.w map_x_position,d0 ;x position in map
  1786. move.w map_datasize(a0),d1
  1787. move.w map_ysize(a0),d2 ;number of lines to do
  1788. move.w map_xsize(a0),d3
  1789. move.w d3,d4
  1790. asl d1,d3 ;one line of map
  1791. moveq #0,d5
  1792. move.w d0,d5
  1793. asl d1,d5
  1794. move.l map_mem(a0),a1
  1795. add.l d5,a1 ;start position (dest)
  1796. move.l a1,a2
  1797. move.w #1,d5
  1798. asl d1,d5
  1799. add.l d5,a2 ;source
  1800. sub.w d0,d4 ;no. blocks to shift
  1801. subq.w #2,d4
  1802. bmi dont_delete_col
  1803. asl d1,d4 ;if word map convert to bytes
  1804. subq.w #1,d2 ;y lines to do
  1805. delete_y_col
  1806. move.w d4,d6
  1807. move.l a1,a3
  1808. move.l a2,a4
  1809. delete_x_col
  1810. move.b (a4)+,(a3)+
  1811. dbra d6,delete_x_col
  1812. add.l d3,a1
  1813. add.l d3,a2
  1814. dbra d2,delete_y_col
  1815. dont_delete_col
  1816. *****delete last line of blocks in data
  1817. move.l map_mem(a0),a1
  1818. moveq #0,d0
  1819. move.w map_xsize(a0),d0
  1820. asl.w d1,d0
  1821. add.l d0,a1
  1822. subq.l #1,a1
  1823. move.w map_ysize(a0),d2
  1824. subq.w #1,d2
  1825. sub.l d1,a1 ;if word sub one byte
  1826. blank_out_end_bits
  1827. tst d1
  1828. beq.s map_blank_byte
  1829. move.w #0,(a1)
  1830. bra.s fetch_other_line
  1831. map_blank_byte
  1832. move.b #0,(a1)
  1833. fetch_other_line
  1834. add.l d3,a1
  1835. dbra d2,blank_out_end_bits
  1836. bsr display_map_on_screen
  1837. rts
  1838. ******************************************
  1839. ****** INSERT MAP COLUMN FUNCTION ******
  1840. *******************************************
  1841. insert_map_column_function
  1842. bsr remove_undo
  1843. bsr convert_mouse_and_store
  1844. moveq #0,d1
  1845. move.l current_map_ptr,a0
  1846. divu map_block_size(a0),d0
  1847. add.w map_x_position,d0 ;x position in map
  1848. move.w map_datasize(a0),d1
  1849. move.w map_ysize(a0),d2 ;number of lines to do
  1850. move.w map_xsize(a0),d3
  1851. move.w d3,d4
  1852. asl d1,d3 ;one line of map
  1853. move.l map_mem(a0),a1
  1854. add.l d3,a1 ;start position (dest)
  1855. subq.l #1,a1 ;move back onto last byte
  1856. move.l a1,a2
  1857. subq.l #1,a2
  1858. * tst d1
  1859. * beq.s done_all_offsets
  1860. sub.l d1,a2
  1861. *done_all_offsets
  1862. sub.w d0,d4 ;no. blocks to shift
  1863. subq.w #2,d4
  1864. bmi dont_insert_col
  1865. asl d1,d4 ;if word map convert to bytes
  1866. subq.w #1,d2 ;y lines to do
  1867. insert_y_col
  1868. move.w d4,d6
  1869. move.l a1,a3
  1870. move.l a2,a4
  1871. insert_x_col
  1872. move.b (a4),(a3)
  1873. subq.l #1,a4
  1874. subq.l #1,a3
  1875. dbra d6,insert_x_col
  1876. add.l d3,a1
  1877. add.l d3,a2
  1878. dbra d2,insert_y_col
  1879. dont_insert_col
  1880. *****delete line of blocks in data
  1881. move.l map_mem(a0),a1
  1882. asl d1,d0
  1883. add.l d0,a1
  1884. move.w map_ysize(a0),d2
  1885. subq.w #1,d2
  1886. blank_out_end_bits_ins
  1887. tst d1
  1888. beq.s map_blank_byte_ins
  1889. move.w #0,(a1)
  1890. bra.s fetch_other_line_ins
  1891. map_blank_byte_ins
  1892. move.b #0,(a1)
  1893. fetch_other_line_ins
  1894. add.l d3,a1
  1895. dbra d2,blank_out_end_bits_ins
  1896. bsr display_map_on_screen
  1897. rts
  1898. *******************************************
  1899. ****** RESET SPRITE AND MODE ******
  1900. *******************************************
  1901. reset_sprite_and_mode
  1902. move.w #0,sprite_to_attach
  1903. move.w #ADD_BLOCK_MODE,map_function_mode
  1904. rts
  1905. ADD_BLOCK_MODE EQU 0
  1906. INSERT_ROW_MODE EQU 4
  1907. INSERT_COL_MODE EQU 8
  1908. DELETE_ROW_MODE EQU 12
  1909. DELETE_COL_MODE EQU 16
  1910. FILL_WITH_BLOCK EQU 20
  1911. COPYCUT_BLOCK_MODE EQU 24
  1912. PASTE_BLOCK_MODE EQU 28
  1913. PICK_BUFF_MODE EQU 32
  1914. map_function_mode
  1915. dc.w ADD_BLOCK_MODE ;always default
  1916. map_functions
  1917. dc.l add_block_to_map
  1918. dc.l insert_map_row_function
  1919. dc.l insert_map_column_function
  1920. dc.l delete_map_row_function
  1921. dc.l delete_map_column_function
  1922. dc.l fill_block_function
  1923. dc.l get_buffer_box
  1924. dc.l paste_hold_to_map
  1925. remove_undo
  1926. tst undo_on
  1927. beq.s no_rem_undo
  1928. move.l #edit_undo_button,a0
  1929. bsr remove_button
  1930. no_rem_undo
  1931. move.w #0,undo_on
  1932. rts
  1933. display_undo
  1934. tst undo_on
  1935. bne.s no_dis_undo
  1936. move.l #edit_undo_button,a0
  1937. bsr display_button
  1938. no_dis_undo
  1939. move.w #1,undo_on
  1940. rts
  1941. undo_on
  1942. dc.w 0