window_routines.s 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. *****************************************************************
  2. * MODULE TITLE :window_routines *
  3. * *
  4. * DESCRIPTION :window display and handling software *
  5. * *
  6. * *
  7. * *
  8. * NAME DATE *
  9. * *
  10. * LIST OF ROUTINES :create_window *
  11. * destroy_window *
  12. * draw_lines_round_window *
  13. * *
  14. *****************************************************************
  15. ***********************************************
  16. ***** CREATE WINDOW *****
  17. ***********************************************
  18. create_window
  19. ifnd hard_only
  20. bsr own_the_blitter
  21. endc
  22. cmp.w #MAX_NUM_WINDOWS,window_count
  23. beq.s window_create_error
  24. move.l a0,-(sp)
  25. bsr draw_buttons
  26. move.l (sp)+,a0
  27. move.w #0,show_box ;turn off
  28. *send in window descriptor in a0
  29. moveq #0,d0
  30. move.w window_x_size(a0),d0
  31. andi.w #$fff0,d0
  32. move.w d0,window_x_size(a0) ;just to make sure nothing can go wrong
  33. asr.w #3,d0
  34. mulu window_y_size(a0),d0
  35. move.l #main_screen_struct,a1
  36. mulu number_of_planes(a1),d0
  37. move.l #1<<1+1<<16,d1 ; chip and clear
  38. movem.l a0/a1/a6,-(sp)
  39. move.l EXEC,a6
  40. jsr -198(a6) ; try
  41. movem.l (sp)+,a0/a1/a6
  42. tst.l d0
  43. bne got_window_mem
  44. window_create_error
  45. move.w #-1,d0
  46. move.w #$f00,$dff180
  47. rts
  48. got_window_mem
  49. move.w #WINDOW,current_frame
  50. move.l d0,window_pointer(a0)
  51. move.l window_list_ptr,a2 ;update list
  52. move.l a0,(a2)+
  53. move.l a0,current_window_ptr ;current window
  54. move.l #$ffffffff,(a2)
  55. move.l a2,window_list_ptr
  56. addq.w #1,window_count
  57. ****get start pos
  58. move.l screen_mem(a1),a2
  59. moveq #0,d0
  60. moveq #0,d1
  61. move.w window_x(a0),d0
  62. andi.w #$fff0,d0
  63. move.w d0,window_x(a0) ;to make sure
  64. asr.w #3,d0 ;get bytes across
  65. move.w screen_x_size(a1),d1
  66. asr.w #3,d1
  67. move.l d1,d3
  68. mulu window_y(a0),d1
  69. add.l d1,d0
  70. add.l d0,a2 ;start position on screen
  71. move.l a2,window_start(a0)
  72. move.w window_x_size(a0),d6 ;calculate modulus for all
  73. asr.w #3,d6
  74. sub.w d6,d3
  75. ****done
  76. ****save background
  77. move.w number_of_planes(a1),d7
  78. subq.w #1,d7
  79. move.l window_pointer(a0),a2
  80. move.l window_start(a0),a3
  81. save_area_on_screen
  82. btst #14,DMACONR(a6)
  83. bne.s save_area_on_screen
  84. move.l a2,bltdpt(a6)
  85. move.l a3,bltapt(a6)
  86. move.w d3,bltamod(a6)
  87. clr.w bltdmod(a6)
  88. move.w #$09f0,bltcon0(a6)
  89. clr.w bltcon1(a6)
  90. move.l #$ffffffff,bltafwm(a6)
  91. moveq #0,d0
  92. move.w window_y_size(a0),d0
  93. asl.w #6,d0
  94. move.w window_x_size(a0),d1
  95. asr.w #4,d1
  96. add.w d1,d0
  97. move.w d0,bltsize(a6)
  98. moveq #0,d0
  99. move.w window_x_size(a0),d0
  100. asr.w #3,d0
  101. mulu window_y_size(a0),d0
  102. add.l d0,a2
  103. moveq #0,d0
  104. move.w screen_x_size(a1),d0
  105. asr.w #3,d0
  106. mulu screen_y_size(a1),d0
  107. add.l d0,a3
  108. dbra d7,save_area_on_screen
  109. ****set up blitter to slap a plane of graphics on
  110. move.w number_of_planes(a1),d7
  111. subq.w #1,d7
  112. move.w d7,d6
  113. move.l window_start(a0),a2
  114. clear_area_on_screen
  115. btst #14,DMACONR(a6)
  116. bne.s clear_area_on_screen
  117. cmp.w d6,d7
  118. bne.s clear_as_normal
  119. move.w #$ffff,bltadat(a6)
  120. bra.s do_the_clear
  121. clear_as_normal
  122. move.w #$0000,bltadat(a6)
  123. do_the_clear
  124. move.l a2,bltdpt(a6)
  125. move.w d3,bltdmod(a6)
  126. move.w #$01f0,bltcon0(a6)
  127. clr.w bltcon1(a6)
  128. move.l #$ffffffff,bltafwm(a6)
  129. moveq #0,d0
  130. move.w window_y_size(a0),d0
  131. asl.w #6,d0
  132. move.w window_x_size(a0),d1
  133. asr.w #4,d1
  134. add.w d1,d0
  135. move.w d0,bltsize(a6)
  136. moveq #0,d0
  137. move.w screen_x_size(a1),d0
  138. asr.l #3,d0
  139. mulu screen_y_size(a1),d0
  140. add.l d0,a2
  141. dbra d7,clear_area_on_screen
  142. move.l window_start(a0),a5
  143. move.l a0,a2
  144. add.l #window_name,a2
  145. move.l a2,a3
  146. moveq #0,d7
  147. window_count_letters
  148. cmp.b #0,(a2)+
  149. beq.s window_counted_letters
  150. addq.w #1,d7
  151. bra.s window_count_letters
  152. window_counted_letters
  153. mulu #FONT_PIX_WIDTH,d7
  154. move.w window_x_size(a0),d6
  155. sub.w d7,d6
  156. asr.w #1,d6
  157. moveq #0,d0
  158. move.w d6,d7
  159. window_draw_in_text
  160. move.w d7,d0
  161. move.l a5,a2
  162. moveq #0,d1
  163. move.w d0,d1
  164. andi.w #$000f,d0
  165. andi.w #$fff0,d1
  166. ror.w #4,d0
  167. or.w #$0d0c,d0 ;not and b
  168. asr.w #3,d1
  169. add.l d1,a2
  170. moveq #0,d4
  171. move.b (a3)+,d4
  172. beq.s done_window_text
  173. move.l #button_font,a4
  174. sub.w #32,d4
  175. mulu #FONT_HEIGHT*4,d4 ;get letter in font
  176. add.l d4,a4
  177. window_blit_on_text
  178. btst #14,DMACONR(a6)
  179. bne.s window_blit_on_text
  180. move.l a4,bltapt(a6)
  181. move.l a2,bltdpt(a6)
  182. move.l a2,bltbpt(a6)
  183. move.w #BYTES_PER_ROW-4,bltdmod(a6)
  184. move.w #BYTES_PER_ROW-4,bltbmod(a6)
  185. clr.w bltamod(a6)
  186. move.w d0,bltcon0(a6)
  187. clr.w bltcon1(a6)
  188. move.l #$ffffffff,bltafwm(a6)
  189. move.w #11<<6+2,bltsize(a6)
  190. add.w #FONT_PIX_WIDTH,d7
  191. bra.s window_draw_in_text
  192. done_window_text
  193. ****make frame
  194. move.l window_start(a0),a2
  195. moveq #0,d0
  196. move.w screen_x_size(a1),d0
  197. add.l d0,a2
  198. add.l #BORDER_X/8,a2 ;one word in
  199. move.l a2,window_start(a0)
  200. addq.w #BORDER_X/4,d3 ;two word shorter now
  201. clear_frame_on_screen
  202. btst #14,DMACONR(a6)
  203. bne.s clear_frame_on_screen
  204. move.w #$0000,bltadat(a6)
  205. move.l a2,bltdpt(a6)
  206. move.w d3,bltdmod(a6)
  207. move.w #$01f0,bltcon0(a6)
  208. clr.w bltcon1(a6)
  209. move.l #$00ffff00,bltafwm(a6)
  210. moveq #0,d0
  211. move.w window_y_size(a0),d0
  212. sub.w #BORDER_Y*2,d0 ;allow for border
  213. asl.w #6,d0
  214. move.w window_x_size(a0),d1
  215. asr.w #4,d1
  216. sub.w #2,d1 ;allow for border
  217. add.w d1,d0
  218. move.w d0,bltsize(a6)
  219. bsr draw_lines_round_window
  220. ******done
  221. FF btst #14,dmaconr(a6)
  222. bne.s FF
  223. move.w #1,d0 ;so user knows it has worked
  224. ifnd hard_only
  225. bsr disown_the_blitter
  226. endc
  227. rts
  228. ***********************************************
  229. ***** DRAW LINES ROUND WINDOW *****
  230. ***********************************************
  231. draw_lines_round_window
  232. move.l a0,a1
  233. move.l #main_screen_struct,a0
  234. move.w window_x(a1),d0
  235. move.w window_y(a1),d1
  236. move.w d1,d3
  237. move.w d0,d2
  238. add.w window_x_size(a1),d2
  239. movem.l d0-d3/a0,-(sp)
  240. bsr eor_draw_line ;line across_top
  241. movem.l (sp)+,d0-d3/a0
  242. add.w window_y_size(a1),d3
  243. add.w window_x_size(a1),d0
  244. subq.w #1,d0
  245. addq.w #1,d1
  246. subq.w #1,d2
  247. movem.l d0-d3/a0,-(sp)
  248. bsr eor_draw_line ;top right to bottom
  249. movem.l (sp)+,d0-d3/a0
  250. add.w window_y_size(a1),d1
  251. subq.w #2,d1 ;
  252. subq.w #1,d3
  253. subq.w #1,d0
  254. sub.w window_x_size(a1),d2
  255. addq.w #1,d2
  256. movem.l d0-d3/a0,-(sp)
  257. bsr eor_draw_line ;bottom right to bottom left
  258. movem.l (sp)+,d0-d3/a0
  259. move.w window_x(a1),d0
  260. move.w window_y(a1),d1
  261. addq.w #1,d1 ;
  262. addq.w #1,d3
  263. *subq.w #2,d3
  264. movem.l d0-d3/a0,-(sp)
  265. bsr eor_draw_line ;join up
  266. movem.l (sp)+,d0-d3/a0
  267. rts
  268. ***********************************************
  269. ***** DESTROY WINDOW *****
  270. ***********************************************
  271. destroy_window
  272. ifnd hard_only
  273. bsr own_the_blitter
  274. endc
  275. *no need to send anything as it always destroys last window displayed
  276. move.l a0,-(sp)
  277. bsr delete_buttons
  278. move.l (sp)+,a0
  279. move.l window_list_ptr,a0
  280. move.l -(a0),a1 ;window_ptr
  281. move.l -4(a0),current_window_ptr
  282. move.l #$ffffffff,(a0) ;delete entry in list
  283. move.l a0,window_list_ptr
  284. move.l a1,a0
  285. move.l #main_screen_struct,a1
  286. move.w screen_x_size(a1),d3
  287. asr.w #3,d3
  288. move.w window_x_size(a0),d6 ;calculate modulus for all
  289. asr.w #3,d6
  290. sub.w d6,d3
  291. ****restore background
  292. move.w number_of_planes(a1),d7
  293. subq.w #1,d7
  294. move.l window_pointer(a0),a3
  295. move.l window_start(a0),a2
  296. moveq #0,d0 ;reposition screen start for border
  297. move.w screen_x_size(a1),d0
  298. asr.w #3,d0
  299. mulu #BORDER_Y,d0
  300. add.w #BORDER_X/8,d0
  301. sub.l d0,a2
  302. restore_area_on_screen
  303. btst #14,DMACONR(a6)
  304. bne.s restore_area_on_screen
  305. move.l a2,bltdpt(a6)
  306. move.l a3,bltapt(a6)
  307. move.w d3,bltdmod(a6)
  308. clr.w bltamod(a6)
  309. move.w #$09f0,bltcon0(a6)
  310. clr.w bltcon1(a6)
  311. move.l #$ffffffff,bltafwm(a6)
  312. moveq #0,d0
  313. move.w window_y_size(a0),d0
  314. asl.w #6,d0
  315. move.w window_x_size(a0),d1
  316. asr.w #4,d1
  317. add.w d1,d0
  318. move.w d0,bltsize(a6)
  319. moveq #0,d0
  320. move.w window_x_size(a0),d0
  321. asr.w #3,d0
  322. mulu window_y_size(a0),d0
  323. add.l d0,a3
  324. moveq #0,d0
  325. move.w screen_x_size(a1),d0
  326. asr.l #3,d0
  327. mulu screen_y_size(a1),d0
  328. add.l d0,a2
  329. dbra d7,restore_area_on_screen
  330. ****deallocate mem
  331. moveq #0,d0
  332. move.w window_x_size(a0),d0
  333. asr.w #3,d0
  334. mulu window_y_size(a0),d0
  335. mulu number_of_planes(a1),d0
  336. move.l window_pointer(a0),a1
  337. movem.l a6,-(sp)
  338. move.l EXEC,a6
  339. jsr -210(a6)
  340. movem.l (sp)+,a6
  341. subq.w #1,window_count
  342. bne.s windows_still_active
  343. move.w #MAIN_BUTTON_SCREEN,current_frame
  344. move.w #1,show_box
  345. windows_still_active
  346. FF2 btst #14,dmaconr(a6)
  347. bne.s FF2
  348. ifnd hard_only
  349. bsr disown_the_blitter
  350. endc
  351. rts
  352. MAX_NUM_WINDOWS EQU 9
  353. BORDER_X equ 16
  354. BORDER_Y equ 8
  355. window_count dc.w 0
  356. window_list
  357. dc.l $ffffffff
  358. ds.l 10
  359. window_list_ptr
  360. dc.l window_list
  361. current_window_ptr
  362. dc.l 0
  363. rsreset
  364. window_x_size rs.w 1 ;multiple of 16
  365. window_y_size rs.w 1
  366. window_x rs.w 1 ;multiple of 16
  367. window_y rs.w 1
  368. window_start rs.l 1
  369. window_pointer rs.l 1
  370. window_name rs.b 1
  371. even