maptool.s 20 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213
  1. section maptool,code_c
  2. opt NODEBUG
  3. opt p=68000
  4. incdir "code:maptool/"
  5. opt c-
  6. exec equ 4 ; amiga executive o/s base
  7. SERPER equ $032 ; serial port period and control
  8. SERDATR equ $018 ; serial port data and status read
  9. SERDAT equ $030
  10. INTREQ equ $09c ; interrupt request bits
  11. intreqr equ $01e
  12. INTENA equ $09a ; interrupt enable bits
  13. CUSTOM EQU $DFF000 ; start of amigas hardware
  14. BPLCONO EQU $100
  15. BPLCON1 EQU $102
  16. BPLCON2 EQU $104
  17. BPL1MOD EQU $108
  18. BPL2MOD EQU $10a
  19. DDFSTRT EQU $092
  20. DDFSTOP EQU $094
  21. DIWSTRT EQU $08E
  22. DIWSTOP EQU $090
  23. VPSOR EQU $004
  24. COLOUR0 EQU $180
  25. COLOUR1 EQU $182
  26. COLOUR2 EQU $184
  27. COLOUR3 EQU $186
  28. DMACON EQU $096
  29. COP1LCH EQU $080
  30. COPJMP1 EQU $088
  31. DMAF_BLITTER EQU $0040
  32. DMAF_BLTDONE EQU $4000
  33. DMAF_BLTNZERO EQU $2000
  34. DMAB_BLTDONE EQU 14
  35. bltddat EQU $000
  36. dmaconr EQU $002
  37. vposr EQU $004
  38. vhposr EQU $006
  39. dskdatr EQU $008
  40. joy0dat EQU $00A
  41. joy1dat EQU $00C
  42. joytest equ $036
  43. clxdat EQU $00E
  44. bltcon0 EQU $040
  45. bltcon1 EQU $042
  46. bltafwm EQU $044
  47. bltalwm EQU $046
  48. bltcpt EQU $048
  49. bltbpt EQU $04C
  50. bltapt EQU $050
  51. bltdpt EQU $054
  52. bltsize EQU $058
  53. bltcmod EQU $060
  54. bltbmod EQU $062
  55. bltamod EQU $064
  56. bltdmod EQU $066
  57. bltcdat EQU $070
  58. bltbdat EQU $072
  59. bltadat EQU $074
  60. dsksync EQU $07E
  61. cop1lc EQU $080
  62. cop2lc EQU $084
  63. bpldat EQU $110
  64. MODE_OLD EQU 1005
  65. MODE_NEW EQU 1006
  66. hard_only equ 0
  67. save_alien_data equ 0
  68. output equ -60
  69. openlibrary equ -408
  70. closelibrary equ -414
  71. exec_base equ 4
  72. find_task equ -294
  73. write equ -48
  74. open equ -30
  75. close equ -36
  76. read equ -42
  77. forbid equ -132
  78. permit equ -138
  79. disable equ -120
  80. ownblitter equ -456
  81. disownblitter equ -462
  82. MEM_CHIP EQU $02
  83. MEM_FAST EQU $04
  84. MEM_PUBLIC EQU $01
  85. MEM_CLEAR EQU $10000
  86. COPPER_SCREEN_OFFSET EQU $2c
  87. BUTTON_WINDOW_OFFSET EQU 192
  88. BUTTON_SCREEN_POSITION EQU BUTTON_WINDOW_OFFSET+COPPER_SCREEN_OFFSET
  89. RES_BYTES equ 40
  90. RES_HEIGHT equ 256
  91. PLANE_HEIGHT equ 200
  92. BYTES_PER_ROW equ 320/8
  93. SECRES_BYTES equ 80
  94. SECRES_HEIGHT equ 256
  95. SECBYTES_PER_ROW equ 640/8
  96. STARTOFMAINCODE
  97. bsr setup
  98. cmp.w #0,error_flag
  99. bne quit_prog
  100. move.l $6c,oldint
  101. move.l #interrupt,$6c
  102. crap
  103. move.l #$dff000,a6
  104. jsr setup_button_list ;required for buttons to work
  105. move.l #top_level_list,a0
  106. jsr display_button_list
  107. bsr display_info_window
  108. bsr mainroutine
  109. bsr winddown
  110. quit_prog
  111. rts
  112. **********************************
  113. *** INTERRUPT ****
  114. **********************************
  115. interrupt
  116. movem.l d0-d7/a0-a6,-(sp)
  117. jsr position_cursor
  118. bsr readmouse
  119. bsr position_box_sprite
  120. bsr display_helpful_cursor
  121. movem.l (sp)+,d0-d7/a0-a6
  122. dc.w $4ef9
  123. oldint dc.l 0
  124. ***********************************************
  125. ***** MAINROUTINE *****
  126. ***********************************************
  127. mainroutine
  128. bsr sync
  129. bsr button_handler
  130. bsr get_stick_readings
  131. bsr read_keys
  132. cmp.b #0,quit_system
  133. beq.s mainroutine
  134. rts
  135. read_keys
  136. cmp.w #1,edit_mode
  137. bne.s no_key_pressed
  138. bsr get_pressed_key
  139. cmp.b #51,d0
  140. beq move_cursor_up
  141. cmp.b #50,d0
  142. beq move_cursor_down
  143. cmp.b #48,d0
  144. beq move_cursor_left
  145. cmp.b #49,d0
  146. beq move_cursor_right
  147. cmp.b #40,d0
  148. blt.s not_num_key
  149. cmp.b #47,d0
  150. bgt.s not_num_key
  151. bra.s select_key_buffer
  152. not_num_key
  153. rts
  154. no_key_pressed
  155. rts
  156. select_key_buffer
  157. ext.w d0
  158. sub.w #40,d0
  159. neg d0
  160. add.w #7,d0
  161. move.w d0,-(sp)
  162. jsr remove_current_buff_name
  163. move.w (sp)+,d0
  164. move.w d0,current_buffer
  165. jsr calculate_buffer_mem
  166. jsr display_current_buff_name
  167. rts
  168. move_cursor_up
  169. bsr Remove_Selected_Block_Num
  170. move.l #main_screen_struct,a0
  171. moveq #0,d0
  172. move.w screen_x_size(a0),d0
  173. move.l #map_details,a0
  174. divu map_block_size(a0),d0
  175. sub.w d0,current_block
  176. bsr convert_block_number_to_memory
  177. bsr position_box_sprite2
  178. bsr Display_Selected_Block_Num
  179. rts
  180. move_cursor_down
  181. bsr Remove_Selected_Block_Num
  182. move.l #main_screen_struct,a0
  183. moveq #0,d0
  184. move.w screen_x_size(a0),d0
  185. move.l #map_details,a0
  186. divu map_block_size(a0),d0
  187. add.w d0,current_block
  188. bsr convert_block_number_to_memory
  189. bsr position_box_sprite2
  190. bsr Display_Selected_Block_Num
  191. rts
  192. move_cursor_left
  193. bsr Remove_Selected_Block_Num
  194. subq.w #1,current_block
  195. bsr convert_block_number_to_memory
  196. bsr position_box_sprite2
  197. bsr Display_Selected_Block_Num
  198. rts
  199. move_cursor_right
  200. bsr Remove_Selected_Block_Num
  201. addq.w #1,current_block
  202. bsr convert_block_number_to_memory
  203. bsr position_box_sprite2
  204. bsr Display_Selected_Block_Num
  205. rts
  206. ***********************************************
  207. ***** SYNC *****
  208. ***********************************************
  209. sync
  210. move.w #$0010,intreq(a6)
  211. sc_sync
  212. btst #4,intreqr+1(a6)
  213. beq.s sc_sync
  214. rts
  215. ***********************************************
  216. ***** BUTTON HANDLER *****
  217. ***********************************************
  218. button_handler
  219. jsr check_for_call_routine
  220. jsr check_to_see_hit
  221. jsr frig_for_editor
  222. jsr delete_buttons
  223. jsr draw_buttons
  224. rts
  225. ***********************************************
  226. ***** FRIG FOR EDITOR *****
  227. ***********************************************
  228. frig_for_editor
  229. ***routine that breaks rules but is neccessary for
  230. ***editor system
  231. btst #10,$dff016 ;mouse button
  232. bne.s right_not_hit
  233. cmp.w #1,edit_data_flag
  234. bne.s check_other_flag
  235. jsr remove_alien_data
  236. bra right_not_hit_by_user
  237. check_other_flag
  238. cmp.w #1,edit_mode
  239. bne.s check_graphic
  240. bsr delete_map_block
  241. rts
  242. check_graphic
  243. cmp.w #2,edit_mode
  244. bne.s right_not_hit_by_user
  245. bsr cancel_block_ops
  246. rts
  247. right_not_hit
  248. move.w #0,right_first
  249. right_not_hit_by_user
  250. rts
  251. ***********************************************
  252. ***** PAUSE *****
  253. ***********************************************
  254. pause
  255. move.w #4000,d0
  256. wait
  257. dbra d0,wait
  258. rts
  259. ************************************************
  260. ***** READ MOUSE *****
  261. ************************************************
  262. readmouse
  263. *updates mousex_inc and mousey_inc - it is done this way
  264. *for total flexibility as it can be used to scroll the
  265. *screen or move an on screen pointer or be used to increase
  266. *levels volume menu options etc etc
  267. moveq #0,d0
  268. move.w $dff00a,d0 ;mouse port
  269. move.w d0,d1
  270. andi.w #$00ff,d1
  271. move.w last_mousex,d3
  272. sub.w d1,d3
  273. cmp.w #127,d3
  274. blt.s test_under
  275. add.w #-255,d3
  276. bra.s add_to_scrollx
  277. test_under
  278. cmp.w #-127,d3
  279. bgt.s add_to_scrollx
  280. add.w #255,d3
  281. add_to_scrollx
  282. neg.w d3
  283. move.w d3,mousex_inc
  284. test_sp_y
  285. move.w d1,last_mousex
  286. move.w last_mousey,d3
  287. lsr.w #8,d0
  288. sub.w d0,d3
  289. cmp.w #127,d3
  290. blt.s test_under_y
  291. add.w #-255,d3
  292. neg.w d3
  293. bra.s add_to_scrolly
  294. test_under_y
  295. cmp.w #-127,d3
  296. bgt.s add_to_scrolly
  297. add.w #255,d3
  298. add_to_scrolly
  299. neg.w d3
  300. move.w d3,mousey_inc
  301. move_y_value
  302. move.w d0,last_mousey
  303. rts
  304. ****************************************
  305. ****** GET STICK READINGS *****
  306. ****************************************
  307. get_stick_readings
  308. tst.w edit_data_flag ;crap code
  309. bne.s set_fire_up ;frigged for time
  310. cmp.w #1,edit_mode
  311. bne quit_scroll_joy
  312. move.w #0,fire
  313. btst #7,$bfe001
  314. bne.s set_fire_up
  315. move.w #1,fire
  316. set_fire_up
  317. move.w $dff00c,d0 ;joy1dat
  318. update_joy_values
  319. btst #9,d0
  320. beq.s tryleft
  321. move.w #-1,xdirec
  322. bra upanddown
  323. tryleft
  324. btst #1,d0
  325. beq.s movezero
  326. move.w #1,xdirec
  327. bra.s upanddown
  328. movezero
  329. move.w #0,xdirec
  330. upanddown
  331. move.w d0,d1
  332. rol.w #1,d0
  333. eor.w d0,d1
  334. btst #1,d1
  335. beq.s tryup
  336. move.w #-1,ydirec
  337. bra.s quitjoyread
  338. tryup
  339. btst #9,d1
  340. beq.s stop_y
  341. move.w #1,ydirec
  342. bra.s quitjoyread
  343. stop_y
  344. move.w #0,ydirec
  345. quitjoyread
  346. tst ydirec
  347. beq.s testlr
  348. bpl.s joy_scroll_up
  349. bsr scroll_map_down
  350. bra.s testlr
  351. joy_scroll_up
  352. bsr scroll_map_up
  353. testlr
  354. tst xdirec
  355. beq.s done_scroll_bits
  356. bpl.s joy_scroll_right
  357. bsr scroll_map_right
  358. bra.s done_scroll_bits
  359. joy_scroll_right
  360. bsr scroll_map_left
  361. done_scroll_bits
  362. tst edit_data_flag
  363. beq.s quit_scroll_joy
  364. jsr display_alien_numbers
  365. quit_scroll_joy
  366. rts
  367. fire dc.w 0
  368. fire2 dc.w 0
  369. xdirec dc.w 0
  370. ydirec dc.w 0
  371. *****************************************************************
  372. *Module Name :setup *
  373. *Function :sets up screen,allocates mem *
  374. *****************************************************************
  375. setup
  376. bsr open_dos
  377. bsr open_graphics_library
  378. tst.l d0
  379. move.l #main_screen_struct,a0
  380. jsr setup_screen_memory
  381. move.l screen_mem(a0),d0
  382. tst.l d0
  383. bne allocated_screen_mem
  384. error_with_allocation
  385. move.w #1,error_flag
  386. rts ; otherwise quit
  387. allocated_screen_mem
  388. bsr allocate_picstruct_mem
  389. tst.l d0
  390. beq.s error_with_allocation
  391. bsr allocate_map_mem
  392. tst.l d0
  393. beq.s error_with_allocation
  394. move.l #button_window_struct,a0
  395. jsr setup_screen_memory
  396. move.l screen_mem(a0),d0
  397. tst.l d0
  398. bne allocated_window_mem
  399. move.l #main_screen_struct,a0 ;give back screen mem
  400. jsr deallocate_screen_memory
  401. bra.s error_with_allocation
  402. allocated_window_mem
  403. bsr put_planes_in_copper
  404. LEA CUSTOM,A0
  405. MOVE.W #$2C81,DIWSTRT(A0)
  406. MOVE.W #$2CC1,DIWSTOP(A0)
  407. MOVE.L #COPPERL,COP1LCH(A0)
  408. MOVE.W COPJMP1(A0),D0
  409. MOVE.W #$8380,DMACON(A0)
  410. move.l #button_window_struct,a0
  411. move.l screen_mem(a0),d0
  412. moveq #0,d1
  413. move.w screen_x_size(a0),d1
  414. asr.w #3,d1
  415. mulu screen_y_size(a0),d1
  416. MOVE.W D0,BUTTONPLANELOW
  417. SWAP D0
  418. MOVE.W D0,BUTTONPLANEHIGH
  419. swap d0
  420. add.l d1,d0
  421. MOVE.W D0,BUTTONPLANE2LOW
  422. SWAP D0
  423. MOVE.W D0,BUTTONPLANE2HIGH
  424. swap d0
  425. add.l d1,d0
  426. MOVE.W D0,BUTTONPLANE3LOW
  427. SWAP D0
  428. MOVE.W D0,BUTTONPLANE3HIGH
  429. swap d0
  430. add.l d1,d0
  431. MOVE.W D0,BUTTONPLANE4LOW
  432. SWAP D0
  433. MOVE.W D0,BUTTONPLANE4HIGH
  434. bsr blank_sprites
  435. bsr setup_colours
  436. bsr low_pas_filter_off
  437. ifd hard_only
  438. move.l exec,a6
  439. jsr forbid(a6)
  440. endc
  441. rts
  442. open_graphics_library
  443. move.l exec,a6
  444. MOVE.L #graf_name,A1
  445. jsr -408(A6) ; OPEN GRAPHICS LIBRARY
  446. MOVE.L D0,graphics_lib_ptr
  447. rts
  448. **********************************
  449. *** LOW PAS FILTER OFF ****
  450. **********************************
  451. low_pas_filter_off
  452. bset #1,$bfe001
  453. rts
  454. **********************************
  455. *** ALLOCATE MAP MEM ****
  456. **********************************
  457. allocate_map_mem
  458. moveq #0,d0
  459. move.l #map_details,a0
  460. move.w map_xsize(a0),d0
  461. mulu map_ysize(a0),d0
  462. tst map_datasize(a0)
  463. beq.s albyte_map
  464. asl.l d0 ;mulu again by 2 for word map
  465. albyte_map
  466. move.l #MEM_FAST+MEM_CLEAR,d1
  467. movem.l d7/a6/a0,-(sp)
  468. move.l 4,a6
  469. jsr -198(a6) ;get mem
  470. movem.l (sp)+,d7/a6/a0
  471. tst.l d0
  472. bne.s al_new_map_mem
  473. *raise error
  474. move.l #0,d0
  475. bra end_map_al
  476. al_new_map_mem
  477. move.l d0,map_mem(a0)
  478. *alocate alien map mem
  479. moveq #0,d0
  480. move.l #map_details,a0
  481. move.w map_xsize(a0),d0
  482. mulu map_ysize(a0),d0
  483. move.l #MEM_FAST+MEM_CLEAR,d1
  484. movem.l d7/a6/a0,-(sp)
  485. move.l 4,a6
  486. jsr -198(a6) ;get mem
  487. movem.l (sp)+,d7/a6/a0
  488. tst.l d0
  489. bne.s al_new_al_map_mem
  490. *raise error
  491. move.l #0,d0
  492. bra end_map_al
  493. al_new_al_map_mem
  494. move.l d0,map_alien_mem(a0)
  495. move.w map_datasize(a0),map_allocdatasize(a0)
  496. move.w map_xsize(a0),map_allocx(a0)
  497. move.w map_ysize(a0),map_allocy(a0)
  498. end_map_al
  499. rts
  500. **********************************
  501. *** ALLOCATE PICSTRUCT MEM ****
  502. **********************************
  503. allocate_picstruct_mem
  504. movem.l a6,-(sp)
  505. move.l #main_screen_struct,a1
  506. move.w screen_x_size(a1),d3
  507. asr.w #3,d3
  508. mulu screen_y_size(a1),d3
  509. mulu number_of_planes(a1),d3
  510. move.l #picture_pages,a0
  511. moveq #3,d2
  512. allocate_piccy_mem
  513. move.l #MEM_FAST+MEM_CLEAR,d1
  514. move.l 4,a6
  515. move.l d3,d0
  516. movem.l d2-d3/a0-a1,-(sp)
  517. jsr -198(a6)
  518. movem.l (sp)+,d2-d3/a0-a1
  519. tst.l d0
  520. beq.s pa_exit_with_error
  521. move.l (a0),a1
  522. move.l #main_screen_struct,a2
  523. move.l d0,screen_mem(a1)
  524. move.w number_of_planes(a2),number_of_planes(a1)
  525. move.w screen_x_size(a2),screen_x_size(a1)
  526. move.w screen_y_size(a2),screen_y_size(a1)
  527. addq.l #4,a0 ;next struct
  528. dbra d2,allocate_piccy_mem
  529. moveq #1,d0
  530. pa_exit_with_error
  531. movem.l (sp)+,a6
  532. rts
  533. **********************************
  534. *** DEALLOCATE PICSTRUCT MEM ****
  535. **********************************
  536. deallocate_picstruct_mem
  537. movem.l a6,-(sp)
  538. move.l #picture_pages,a0
  539. moveq #3,d2
  540. deallocate_piccy_mem
  541. move.l (a0),a1
  542. move.l screen_mem(a1),a1
  543. move.l #main_screen_struct,a2
  544. move.w screen_x_size(a2),d0
  545. asr.w #3,d0
  546. mulu screen_y_size(a2),d0
  547. mulu number_of_planes(a2),d0
  548. move.l 4,a6
  549. movem.l d2/a0,-(sp)
  550. jsr -210(a6)
  551. movem.l (sp)+,d2/a0
  552. addq.l #4,a0 ;next struct
  553. dbra d2,deallocate_piccy_mem
  554. movem.l (sp)+,a6
  555. rts
  556. **********************************
  557. *** BLANK SPRITES ****
  558. **********************************
  559. blank_sprites
  560. move.l #blank_sprite,d0
  561. move.w d0,sprite1l
  562. move.w d0,sprite2l
  563. move.w d0,sprite3l
  564. move.w d0,sprite4l
  565. move.w d0,sprite5l
  566. move.w d0,sprite6l
  567. move.w d0,sprite7l
  568. swap d0
  569. move.w d0,sprite1h
  570. move.w d0,sprite2h
  571. move.w d0,sprite3h
  572. move.w d0,sprite4h
  573. move.w d0,sprite5h
  574. move.w d0,sprite6h
  575. move.w d0,sprite7h
  576. rts
  577. **********************************
  578. *** PUT PLANES IN COPPER ****
  579. **********************************
  580. put_planes_in_copper
  581. move.l #main_screen_struct,a0
  582. move.w screen_x_size(a0),d1
  583. asr.w #3,d1
  584. mulu screen_y_size(a0),d1
  585. move.l screen_mem(a0),d0
  586. MOVE.W D0,PLANELOW
  587. SWAP D0
  588. MOVE.W D0,PLANEHIGH
  589. swap d0
  590. add.l d1,d0
  591. MOVE.W D0,PLANE2LOW
  592. SWAP D0
  593. MOVE.W D0,PLANE2HIGH
  594. swap d0
  595. add.l d1,d0
  596. MOVE.W D0,PLANE3LOW
  597. SWAP D0
  598. MOVE.W D0,PLANE3HIGH
  599. swap d0
  600. add.l d1,d0
  601. MOVE.W D0,PLANE4LOW
  602. SWAP D0
  603. MOVE.W D0,PLANE4HIGH
  604. swap d0
  605. add.l d1,d0
  606. MOVE.W D0,PLANE5LOW
  607. SWAP D0
  608. MOVE.W D0,PLANE5HIGH
  609. rts
  610. **********************************
  611. *** SETUP COLOURS ****
  612. **********************************
  613. setup_colours
  614. move.l #main_screen_colour_map,a1
  615. bsr setup_screen_colours
  616. bsr setup_button_colours
  617. rts
  618. **********************************
  619. *** SETUP_SCREEN_COLOURS ****
  620. **********************************
  621. setup_screen_colours
  622. ***send colour map in a1
  623. move.l #main_screen_colours+2,a3
  624. move.w #32-1,d0
  625. fill_scr_colours
  626. move.w (a1)+,(a3)
  627. add.l #4,a3
  628. dbra d0,fill_scr_colours
  629. rts
  630. **********************************
  631. *** SETUP_GREY_COLOURS ****
  632. **********************************
  633. setup_grey_colours
  634. move.l #main_screen_colours+2,a3
  635. move.l #grey_colour_map,a1
  636. move.w #16-1,d0
  637. fill_gscr_colours
  638. move.w (a1)+,(a3)
  639. add.l #4,a3
  640. dbra d0,fill_gscr_colours
  641. rts
  642. **********************************
  643. *** SETUP BUTTON COLOURS ****
  644. **********************************
  645. setup_button_colours
  646. move.l #button_colours+2,a3
  647. move.l #button_colour_map,a1
  648. move.w #16-1,d0
  649. fill_butt_colours
  650. move.w (a1)+,(a3)
  651. add.l #4,a3
  652. dbra d0,fill_butt_colours
  653. rts
  654. *****************************************************************
  655. *Module Name :winddown *
  656. *Function :deallocates mem, exits to system *
  657. *****************************************************************
  658. winddown
  659. move.l oldint,$6c
  660. bsr deallocate_picstruct_mem
  661. move.l #main_screen_struct,a0
  662. jsr deallocate_screen_memory
  663. move.l #button_window_struct,a0
  664. jsr deallocate_screen_memory
  665. move.l graphics_lib_ptr,a4
  666. MOVE.L #$DFF000,A6
  667. MOVE.L 38(A4),COP1LCH(A6) ; GET SYSTEM COPPER
  668. CLR.W COPJMP1(A6)
  669. MOVE.W #$8030,$DFF096 ; ENABLE SPRITES
  670. move.w #$f,$dff096 ; turn off audio
  671. ifd hard_only
  672. move.l 4,a6
  673. jsr permit(a6)
  674. endc
  675. RTS
  676. graf_name dc.b "graphics.library",0
  677. EVEN
  678. graphics_lib_ptr
  679. dc.l 0
  680. error_flag dc.w 0
  681. screen_pointer dc.l 0
  682. backscr1 Dc.l 0
  683. backscr2 Dc.l 0
  684. backscr3 Dc.l 0
  685. backscr4 Dc.l 0
  686. last_mousex dc.w 0
  687. last_mousey dc.w 0
  688. mousex_inc dc.w 0
  689. mousey_inc dc.w 0
  690. mouse_x dc.w 160
  691. mouse_y dc.w 100
  692. **********************************
  693. *** KILL SYSTEM ****
  694. **********************************
  695. kill_system
  696. move.l #top_level_list,a0
  697. jsr remove_button_list
  698. move.b #1,quit_system
  699. rts
  700. change_colour
  701. move.w #$fff,$dff180
  702. rts
  703. *******SCREEN SETUPS
  704. main_screen_struct
  705. dc.w 320
  706. dc.w 256
  707. dc.w 0,0
  708. dc.l 0
  709. main_screen_planes
  710. dc.w 5
  711. button_window_struct
  712. dc.w 640
  713. dc.w 4*BUTTON_HEIGHT
  714. dc.w 0,0
  715. dc.l 0
  716. button_window_planes
  717. dc.w 4
  718. *********WINDOW SETUPS
  719. error_window
  720. dc.w 320
  721. dc.w 44+32
  722. dc.w 0
  723. dc.w 80
  724. dc.l 0
  725. dc.l 0
  726. dc.b "ERROR",0
  727. EVEN
  728. ok_button
  729. dc.w BUTTON_2-16
  730. dc.w THIRD_ROW
  731. dc.w WINDOW ;frame type
  732. dc.b STANDARD_BUTTON ;standard
  733. dc.b NOT_DEPRESSED
  734. dc.b 0
  735. dc.b 0 ;not used
  736. dc.l 0 ;not used
  737. dc.l 0 ;not used
  738. dc.l remove_error_window
  739. dc.b "OK",0
  740. EVEN
  741. info_window
  742. dc.w 200
  743. dc.w 180
  744. dc.w 60
  745. dc.w 10
  746. dc.l 0
  747. dc.l 0
  748. dc.b "INFO",0
  749. EVEN
  750. quit_info_button
  751. dc.w 55
  752. dc.w 140
  753. dc.w WINDOW ;frame type
  754. dc.b CUSTOM_BUTTON ;standard
  755. dc.b NOT_DEPRESSED
  756. dc.b 0
  757. dc.b 0 ;not used
  758. dc.l ok_custom_button
  759. dc.l 0 ;not used
  760. dc.l remove_info_window
  761. dc.b 0
  762. even
  763. **************************************
  764. **** DISPLAY INFO WINDOW ****
  765. **************************************
  766. display_info_window
  767. move.l #info_window,a0
  768. bsr create_window
  769. move.l #quit_info_button,a0
  770. jsr display_button
  771. move.l #info_window,a0
  772. move.l #info_text,a1
  773. move.w #5,d0
  774. move.w #3,d1
  775. move.w #1,d2
  776. move.w #1,d3
  777. bsr write_text
  778. rts
  779. **************************************
  780. **** REMOVE INFO WINDOW ****
  781. **************************************
  782. remove_info_window
  783. move.l #quit_info_button,a0
  784. jsr remove_button
  785. bsr destroy_window
  786. rts
  787. info_text
  788. dc.b $a,$a,-2,8
  789. dc.b " ECLIPSE SW ",$a
  790. dc.b " Map Editor ",$a,-2,9
  791. dc.b " ",$a,-2,10
  792. dc.b " Internal use ",$a,-2,11
  793. dc.b " only. ",$a,$a,-2,9
  794. dc.b " v1.0 ",$a
  795. dc.b " ",$a,-2,10
  796. dc.b " (c) 1992 ",0
  797. EVEN
  798. display_error
  799. bsr set_original_colours
  800. move.l #error_window,a0
  801. bsr create_window
  802. move.l #ok_button,a0
  803. jsr display_button
  804. movem.l a6,-(sp)
  805. move.l dosbase,a6
  806. jsr -132(a6)
  807. movem.l (sp)+,a6
  808. bsr get_error_message
  809. move.l #error_window,a0
  810. moveq #10,d0
  811. moveq #10,d1
  812. moveq #2,d2
  813. bsr write_text
  814. rts
  815. error_routine
  816. *send error in d0
  817. move.l d0,-(sp)
  818. bsr set_original_colours
  819. move.l #error_window,a0
  820. bsr create_window
  821. move.l #ok_button,a0
  822. jsr display_button
  823. move.l (sp)+,d0
  824. bsr get_error_message
  825. move.l #error_window,a0
  826. moveq #20,d0
  827. moveq #10,d1
  828. moveq #2,d2
  829. bsr write_text
  830. rts
  831. get_error_message
  832. *returns pointer to string in a1
  833. *error numin d0
  834. move.l #error_list,a0
  835. error_search
  836. cmp.w #-1,(a0)
  837. beq.s no_error_found
  838. cmp.w (a0),d0
  839. bne.s not_the_error
  840. move.l 2(a0),a1
  841. rts
  842. not_the_error
  843. addq.l #6,a0
  844. bra.s error_search
  845. no_error_found
  846. move.l #no_error,a1
  847. rts
  848. error_list
  849. dc.w 103
  850. dc.l e1
  851. dc.w 204
  852. dc.l e2
  853. dc.w 205
  854. dc.l e3
  855. dc.w 210
  856. dc.l e4
  857. dc.w 211
  858. dc.l e5
  859. dc.w 213
  860. dc.l e6
  861. dc.w 214
  862. dc.l e7
  863. dc.w 221
  864. dc.l e8
  865. dc.w 225
  866. dc.l e9
  867. dc.w 226
  868. dc.l e10
  869. dc.w 1000
  870. dc.l e11
  871. dc.w 1001
  872. dc.l e12
  873. dc.w 1002
  874. dc.l e13
  875. dc.w 2000
  876. dc.l e14
  877. dc.w 3000
  878. dc.l e15
  879. dc.w 4000
  880. dc.l e16
  881. dc.w 5000
  882. dc.l e17
  883. dc.w 5001
  884. dc.l e18
  885. dc.w -1
  886. e1
  887. dc.b "INSUFFICIENT FREE STORE.",0
  888. EVEN
  889. e2
  890. dc.b "DIRECTORY NOT FOUND.",0
  891. EVEN
  892. e3
  893. dc.b "OBJECT NOT FOUND.",0
  894. EVEN
  895. e4
  896. dc.b "INVALID STREAM COMPONENT NAME.",0
  897. EVEN
  898. e5
  899. dc.b "INVALID OBJECT LOCK.",0
  900. EVEN
  901. e6
  902. dc.b "DISK NOT VALIDATED.",0
  903. EVEN
  904. e7
  905. dc.b "DISK WRITE PROTECTED.",0
  906. EVEN
  907. e8
  908. dc.b "DISK FULL.",0
  909. EVEN
  910. e9
  911. dc.b "NOT A DOS DISK.",0
  912. EVEN
  913. e10
  914. dc.b "NO DISK IN DRIVE.",0
  915. EVEN
  916. e11
  917. dc.b "NOT AN IFF FILE.",0
  918. EVEN
  919. e12
  920. dc.b "CANNOT ALLOCATE FILE MEM.",0
  921. EVEN
  922. e13
  923. dc.b "CANNOT ALLOCATE PIC MEM.",0
  924. EVEN
  925. e14
  926. dc.b "SCANNER NOT CONNECTED!",0
  927. EVEN
  928. e15
  929. dc.b "NOT A MUSIC DATA FILE!",0
  930. EVEN
  931. e16
  932. dc.b "NOT AN EDITOR MAP FILE!",0
  933. EVEN
  934. e17
  935. dc.b "NOT A EDITOR BUFFER FILE!",0
  936. EVEN
  937. e18
  938. dc.b "DATA SIZE INCOMPATIBLE ",0
  939. EVEN
  940. no_error
  941. dc.b "NOT A VALID ERROR.",0
  942. EVEN
  943. remove_error_window
  944. move.l #ok_button,a0
  945. jsr remove_button
  946. bsr destroy_window
  947. bsr set_current_page_colours
  948. rts
  949. quit_system
  950. dc.b 0
  951. EVEN
  952. include "glens_code/text_routines.s"
  953. include "glens_code/darkline.s"
  954. include "glens_code/hex_screen_routines.s"
  955. include "stus_code/FileIO.s"
  956. include "glens_code/window_routines.s"
  957. include "glens_code/screen_routines.s"
  958. include "glens_code/button_routines.s"
  959. include "glens_code/iffroutinebk.s"
  960. include "glens_code/cursor_routines.s"
  961. include "glens_code/hex_data.s"
  962. include "glens_code/button_data.s"
  963. include "glens_code/graphic_routines.s"
  964. include "glens_code/mapsetup.s"
  965. include "glens_code/map_routines_buttons.s"
  966. include "glens_code/map_routines.s"
  967. include "glens_code/palette_setup.s"
  968. include "glens_code/fill_routines.s"
  969. include "glens_code/check_routines.s"
  970. include "glens_code/savepic_setup.s"
  971. include "glens_code/save_routines.s"
  972. include "glens_code/buffer_routines.s"
  973. include "glens_code/alien_data.s"
  974. include "stus_code/FileIO_DATA.s"
  975. include "glens_code/buffer_setup.s"
  976. include "glens_code/show_whole_map.s"
  977. blank dc.w 0
  978. include "data/copper_list.s"
  979. include "data/custom_buttons.s"
  980. include "data/buttongraphics.s"
  981. include "data/cursor_graphics.s"
  982. small_numbers
  983. incbin "data/nums.bin"
  984. EVEN
  985. fill_stack
  986. ds.w (40*30)*2