home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / program / a / assembly / FontWindow / source / FontWindow (.txt) < prev   
Encoding:
RISC OS BBC BASIC V Source  |  1993-01-28  |  58.3 KB  |  1,449 lines

  1.  >FontWindow
  2.      Run to create module (*)
  3.      If module we have `fw' = R11, `gb' = R12
  4.      If inline have `fw' = R12 (and assume constants are actually offsets into
  5.      global vars)
  6.  (*) need to run, run module, re-assemble as module contains calls to itself
  7.   MACHINE:  Archimedes
  8.   LANGUAGE: BBC BASIC V, v1.05
  9.   AUTHOR:   Cy Booker,
  10.             86 Church View, Main Road, Crockenhill, Swanley, Kent.
  11.             BR8 8JW
  12.  "<BasicV$Lib>.LibHandler"  :  
  13. _handle_library_error
  14. _hard_initialise_LibHandler( 20, 011 )
  15. KDebug_Wimp%=
  16. :Debug%=
  17. :On_Lib_Error_MODE%=-3     :
  18.  Desktop Development
  19.  "XHourglass_On"
  20.  "XHourglass_Off":
  21. _handle_library_error
  22.   Now to load in the library files used by this program.
  23. _load_library( "<BasicV_Assembler$Lib>.Misc", 039 )
  24. _load_library( "<BasicV_Assembler$Lib>.Messages", 004 )
  25. _load_library( "<BasicV_Assembler$Lib>.Module", 005 )
  26. _load_library( "<BasicV_Assembler$Lib>.Services", 004)
  27. _load_library( "<BasicV_Assembler$Lib>.VduExt", 001)
  28. _load_library( "<BasicV_Assembler$Lib>.WimpConst", 003)
  29.   code_len% = 4*1024
  30.  code% code_len%
  31.   sp = 13
  32.   lr = 14
  33.   PSR_V   = 1 << 28
  34.   PSR_Z   = 1 << 30
  35.   L% = code% + code_len%
  36. _WimpConst(code%, L%)
  37. _VduExt(code%, L%)
  38. _Services(code%, L%)
  39. _Messages(code%, L%)
  40.  pass%= %1100 
  41.  %1110 
  42.     P% = 0 : O% = code%
  43. -'    
  44. _assemble_FontWindow(
  45.  (pass% 
  46.  2) = 0 
  47.       
  48.  i%= 0 
  49.  P%-1 
  50.         code%!i% = 0
  51.       
  52. 3        
  53.  pass%
  54.  "OS_File", 10, "<FontWindow$Output>", &FFA,, code%, O%
  55.  1, "Created FontWindow module [size &"+ 
  56. ~(P%)+ "]"
  57.  pass% 
  58.  o% = 50 
  59.  o% = 0
  60.  "XHourglass_Percentage", ((
  61. aadr(P%)-code%)/(L%-code%)*50)+o%
  62.  ***************************************************************************
  63.  if module_p is non-zero then assemble a module
  64.  if debug_p is true [and module_p] then assemble in a wimp module task that
  65.      automatically closes fonts when a window dies
  66. _assemble_FontWindow(module_p, FontWindow_debug_p)
  67.  gb, fw
  68.  module_p 
  69.     gb = 12
  70.     fw = 11
  71.     gb = 12
  72.     fw = 12
  73.  (pass% 
  74.  2) = 0 
  75. N1    
  76. _FontWindow_Constants(
  77. aadr(P%), L%)
  78.  module_p 
  79. P:      
  80. _FontWindow_Module_Constants(
  81. aadr(P%), L%)
  82. Q        
  83.  module_p 
  84. T>    
  85. _assemble_FontWindow_Module              :
  86.  first
  87. _assemble_FontWindow_Miscellaneous         :
  88.  before others
  89. _assemble_FontWindow_Initialise
  90. _assemble_FontWindow_CreateWindow
  91. _assemble_FontWindow_Update
  92. _assemble_FontWindow_ModeChange
  93. _assemble_FontWindow_DeleteWindow
  94. _assemble_FontWindow_CloseDown
  95.  ***************************************************************************
  96. _FontWindow_Constants(code%, L%)
  97.  O%, P%, pass%
  98.   pass% = %1110
  99.   O%=code%:P%=0:[OPT pass%
  100. g*; Used to store each registered window
  101. iD.Win_Next               EQUD 0  ; pointer to next in linked list
  102. j@.Win_ExternalHandle     EQUD 0  ; clients' handle for window
  103. kf.Win_NIcons             EQUD 0  ; number of anti-aliased font icons (> 0), follows after structure
  104. lf.Win_NHandles           EQUD 0  ; number of different font handles used (> 0), follows after icons
  105. m?.Win_Size               EQUD 0  ; size of window definition
  106. .sizeof_Win
  107. o*        ; anti-aliased icons in format
  108. p1        ;       +0 uid of font in icon (word)
  109. qE        ;       +4 icon number [-1 indicates window title] (word)
  110.         ; handles stored as
  111. s8        ;       +0.B global uid [index] of this font
  112. t8        ;       +1.B font handle as stored in window
  113.   O%=code%:P%=0:[OPT pass%
  114. x#; Used to store each font found
  115. z7.Fnt_XSize              EQUD 0  ; \     in pts * 16
  116. {7.Fnt_YSize              EQUD 0  ; ->    in pts * 16
  117. |D.Fnt_Next               EQUD 0  ; pointer to next in linked list
  118. }R.Fnt_Name               
  119. r(41) ; CR-terminated string [extra byte for safety!]
  120. ~0.Fnt_IndexB             EQUB 0  ; global uid
  121. F.Fnt_HandleB            EQUB 0  ; handle used when loaded template
  122. O.Fnt_CurHandleB         EQUB 0  ; font handle for current screen resolution
  123. .sizeof_Fnt
  124.   O%=code%:P%=0:[OPT pass%
  125. ; Used for each client
  126. M.FW_Next                EQUD 0  ; pointer to next in linked list of these
  127. G.FW_MallocRoutine       EQUD 0  ; \    pointer to xmalloc() routine
  128. D.FW_FreeRoutine         EQUD 0  ;  \   pointer to free() routine
  129. I.FW_GetHandleRoutine    EQUD 0  ;   \  pointer to gethandle() routine
  130. H.FW_RecreateRoutine     EQUD 0  ; ---> pointer to recreate() routine
  131. ?.FW_TaskHandle          EQUD 0  ; applications' task handle
  132. G.FW_Windows             EQUD 0  ; pointer to linked list of Win_...
  133. I.FW_Fonts               EQUD 0  ; pointer to a linked list of Fnt_...
  134. =.FW_ClientsR12          EQUD 0  ; used when call routines
  135. '.FW_CurrentXDPI         EQUD 0  ; \
  136. K.FW_CurrentYDPI         EQUD 0  ; -> screen resolution in dots per inch
  137. M.FW_FontTable           EQUD 0  ; pointer to 256-byte template font table
  138. R                                ; [usually points to just past this structure]
  139.          ALIGN   :
  140.  essential
  141. .sizeof_FW
  142.  ***************************************************************************
  143. _assemble_FontWindow_Initialise
  144. [OPT pass%
  145. R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  146. ?; This call initialises the FontWindow package for a client
  147. ; In    R0 = task handle
  148. 1;       R1 = pointer to xmalloc(uint) routine
  149. 1;       R2 = pointer to free(pointer) routine
  150. =;       R3 = pointer to gethandle(handle, buffer) routine
  151. <;       R4 = pointer to recreate(handle, buffer) routine
  152. ;       R5 = routines' R12
  153. N;       R6 = pointer to 256-byte font table to use while loading templates
  154. 6;            [zero => it lies at end of structure]
  155. N; Out   R0 = pointer to 256-byte font table to use while loading templates
  156. .xfontwindow_initialise
  157.         STMFD   (sp)!, {lr}
  158. ,        STR     R0, [fw, #FW_TaskHandle]
  159. ,        STR     R5, [fw, #FW_ClientsR12]
  160.         MOVS    lr, R6
  161. &        ADDeq   lr, fw, #sizeof_FW
  162. +        STR     lr, [fw, #FW_FontTable]
  163.         MOV     lr, #0
  164. K        STR     lr, [fw, #FW_Windows]           ; No windows registered
  165. I        STR     lr, [fw, #FW_Fonts]             ; No fonts registered
  166.         TEQ     R1, #0
  167. *        
  168. adrf("eq", 1, default_malloc)
  169.         TEQ     R2, #0
  170. (        
  171. adrf("eq", 2, default_free)
  172.         CMP     R3, #1
  173. /        
  174. adrf("eq", 3, default_gethandle_1)
  175. -        
  176. adrf("lo", 3, default_gethandle)
  177.         CMP     R4, #1
  178.         MOVhi   lr, R4
  179. /        
  180. adrf("eq", lr, default_recreate_1)
  181. -        
  182. adrf("lo", lr, default_recreate)
  183. -        ADD     R0, fw, #FW_MallocRoutine
  184. D        STMIA   R0, {R1-R3, lr}                 ; Store routines
  185. >        BL      xfontwindow_getcurrez           ; In R0/R1
  186. +        ADDvc   R2, fw, #FW_CurrentXDPI
  187. O        STMvcIA R2, {R0-R1}                     ; Current screen resolution
  188. +        LDRvc   R0, [fw, #FW_FontTable]
  189.         LDMFD   (sp)!, {lr}
  190. "        BICvcS  pc, lr, #PSR_V
  191. !        
  192. RS    pc, lr, #PSR_V
  193.  ***************************************************************************
  194. _assemble_FontWindow_CreateWindow
  195.  b, f, flags, handles, handles, i, icon, icons, n, nhandles, nicons, o, one, t, win
  196.  loop
  197. [OPT pass%
  198. R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  199. Q; Register a window containing (maybe zero) anti-aliased font icons, and then
  200. ; create it
  201. M; In    R0 = users' handle for window (or zero to use wimp window handle)
  202. D;       R1 = pointer to window definition block (wimp_createstr)
  203. 6; Out   R0 = window handle [we created the window]
  204. 3;       R1 = non-zero if actually cached window
  205. 7;       Window has been created [Wimp_CreateWindow]
  206. S; This must be called with the window definition got from the template file ---
  207. P; so that all font references are based on the same font handles.  This does
  208. T; not mean that this call has to be done while loading the template, though.  Eg
  209. T; could cache the window and then call this on all copies of the window as first
  210. .; needed (even after a resolution change).
  211. R; If the window did contain anti-aliased font icons then the font handles used
  212. N; may be updated --- and so consider this call as a filter before actually
  213. ; creating the window
  214. J; If the window has no anti-aliased icons then ok --- it is not cached
  215. N; If the users' handle for the window is zero (0) then use the wimp window
  216. !; handle as the window handle
  217. .xfontwindow_createwindow
  218. -        STMFD   (sp)!, {R0-R1, R4-R5, lr}
  219.         MOV     R2, R1
  220.         MOV     R1, #0
  221.         MOV     R0, #0
  222. c        BL      xfontwindow_registericons       ; Count font icons only + handles (never error)
  223. /        Bvs     err_fontwindow_createwindow
  224.         MOVS    R4, R0
  225. c        Beq     ok_fontwindow_createwindow      ; No anti-aliased icons in window (R1 = 0 also)
  226. X        MOV     R5, R1                          ; # different handles used in window
  227. #        MOV     R0, #sizeof_Win
  228. H        ADD     R0, R0, R4, LSL #3              ; two words per icon
  229. J        ADD     R0, R0, R5, LSL #1              ; two bytes per handle
  230. %        BLvc    fontwindow_malloc
  231. /        Bvs     err_fontwindow_createwindow
  232.         LDMFD   sp, {R1-R2}
  233. 1        STR     R1, [R0, #Win_ExternalHandle]
  234. )        STR     R4, [R0, #Win_NIcons]
  235. +        STR     R5, [R0, #Win_NHandles]
  236. '        LDR     R1, [R2, #w_nicons]
  237.          MOV     lr, #w_icons
  238. J        ADD     lr, lr, R1, LSL #i_shift        ; Total size of window
  239. '        STR     lr, [R0, #Win_Size]
  240.         MOV     R5, R0
  241. '        ADD     R0, R5, #sizeof_Win
  242. U        ADD     R1, R0, R4, LSL #3              ; Implicit start of handle buffer
  243. W        BL      xfontwindow_registericons       ; Note which icons are anti-aliased
  244.          LDRvc   R1, [sp, #4]
  245. (        SWIvc   "XWimp_CreateWindow"
  246.     0        Bvs     err2_fontwindow_createwindow
  247. 1        LDR     R1, [R5, #Win_ExternalHandle]
  248.         TEQ     R1, #0
  249. T        STReq   R0, [R5, #Win_ExternalHandle]   ; External handle IS wimp handle
  250. )        LDR     R1, [fw, #FW_Windows]
  251. '        STR     R1, [R5, #Win_Next]
  252. I        STR     R5, [fw, #FW_Windows]           ; Head of linked list
  253. K        MOV     R1, #1                          ; Signify cached window
  254. -        LDMFD   (sp)!, {R2-R3, R4-R5, lr}
  255. "        BICS    pc, lr, #PSR_V
  256. !.err2_fontwindow_createwindow
  257.         MOV     R4, R0
  258.         MOV     R0, R5
  259. D        BL      fontwindow_free                 ; Release memory
  260.         MOV     R0, R4
  261.  .err_fontwindow_createwindow
  262. -        LDMFD   (sp)!, {R1-R2, R4-R5, lr}
  263. !        
  264. RS    pc, lr, #PSR_V
  265. .ok_fontwindow_createwindow
  266.          LDR     R1, [sp, #4]
  267. (        SWI     "XWimp_CreateWindow"
  268. /        Bvs     err_fontwindow_createwindow
  269. -        LDMFD   (sp)!, {R1-R2, R4-R5, lr}
  270.  "        BICS    pc, lr, #PSR_V
  271. !Q; ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
  272. #S; This scans all icons (including window title) to see if they are anti-aliased
  273. $P; If buffer pointers are zero then just count 'em otherwise store details in
  274. ; these buffers
  275. &=; In    R0 = pointer to buffer to store icons in, or zero
  276. 'D;       R1 = pointer to buffer to store font handles in, or zero
  277. (3;       R2 = pointer to window definition block
  278. ) ; Out   R0 = number of icons
  279. *,;       R1 = number of different handles
  280. ,Q; When come across a new font handle we cache its' info in a global array and
  281. ; assign it a global index
  282. 0H  icons         = 4             :
  283.  pointer to output buffer, or zero
  284. 1H  handles       = 5             :
  285.  pointer to output buffer, or zero
  286. 2C  win           = 6             :
  287.  pointer to window definition
  288. 37  nicons        = 7             :
  289.  for loop counter
  290. 4C  icon          = 8             :
  291.  icon number {-1, 0, ...} > b
  292. 5I  flags         = 9             :
  293.  pointer to icon flags word [>= R9]
  294. 6]  handle        = 10            :
  295.  8-bit font handle [handle > icon >= R4] [handle >= R9]
  296. 71  b             = 0             :
  297.  <R4 < icon
  298. 8/  o             = 1             :
  299.  <R4 !=R0
  300. 94  t             = 2             :
  301.  <R4 !=R0 !=R1
  302. :*  f             = 3             :
  303. ;/  nhandles      = 1             :
  304.  implicit
  305. <=  i             = lr            :
  306.  temporary loop counter
  307. [OPT pass%
  308. .xfontwindow_registericons
  309. ?'        STMFD   (sp)!, {R4-R10, lr}
  310. @&        SUB     sp, sp, #256/8 + 4
  311. AC        MOV     icons, R0                       ; Safe register
  312. BC        MOV     handles, R1                     ; Safe register
  313. CC        MOV     win, R2                         ; Safe register
  314. DX        MOV     t, #0                           ; Number of anti-aliased icons found
  315. E#        STR     t, [sp, #256/8]
  316.         MOV     i, #256/8
  317. GS.loop   SUBS    i, i, #4                        ; Zero "handles used" bit array
  318.         STRhs   t, [sp, i]
  319.         Bhi     loop
  320. J-        ADD     flags, win, #w_titleflags
  321. KB        MVN     icon, #
  322. (-1)                  ; Title bar icon
  323. LB        BL      _fontwindow_registericon        ; Process icon
  324. M,        LDR     nicons, [win, #w_nicons]
  325. N&        ADD     win, win, #w_icons
  326. OO.loop   ADD     icon, icon, #1                  ; Start from icon 0, 1, ...
  327. P         CMP     icon, nicons
  328. Q(        ADDlt   flags, win, #i_flags
  329. RB        BLlt    _fontwindow_registericon        ; Process icon
  330. S%        ADDlt   win, win, #i_size
  331.         Blt     loop
  332.         ;
  333. V.        ; Now count number of handles used
  334.         ;
  335. X         MOV     nhandles, #0
  336. Y!        MOV     i, #256/8 - 4
  337. .loop   LDR     t, [sp, i]
  338. [ .lp     MOVS    t, t, LSR #1
  339. \*        ADDcs   nhandles, nhandles, #1
  340.         Bne     lp
  341.         SUBS    i, i, #4
  342.         Bhs     loop
  343. `P        LDR     R0, [sp, #256/8]                ; Return value, #icons found
  344. a&        ADD     sp, sp, #256/8 + 4
  345. b'        LDMFD   (sp)!, {R4-R10, pc}
  346. cQ; ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
  347. e.; In    flags = pointer to icon flags word
  348. ;       icon = icon number
  349. gI;       icons = pointer to icon buffer [non-zero if handles non-zero]
  350. h7;       handles = pointer to handle buffer, or zero
  351. iI;       sp+256/8 = count of number of anti-aliased icons found so far
  352. j&;       sp points to 256-bit array
  353. ; Out   if flags then
  354. ;           [sp+256/8]++
  355. ;           [handles]++
  356. ;           [icons]++
  357. o!;           bit array updated
  358. p%; Bad   o, t, b, f, handle, R0-R3
  359. ._fontwindow_registericon
  360. s'        LDR     handle, [flags], #0
  361. t)        TST     handle, #if_fancyfont
  362. uN        MOVeqS  pc, lr                          ; Ignore, not anti-aliased
  363. vP        MOV     handle, handle, LSR #ifb_fontno ; handle = 8-bit font handle
  364. w#        LDR     t, [sp, #256/8]
  365. xM        ADD     t, t, #1                        ; Success - one more icon
  366. y#        STR     t, [sp, #256/8]
  367.         
  368.      t, handle, #7
  369.         MOV     o, #1
  370. |I        MOV     t, o, LSL t                     ; bit in byte to test
  371. }+        LDRB    o, [sp, handle, LSR #3]
  372. ~H        
  373. R     b, o, t                         ; Flag handle as used
  374. +        STRB    b, [sp, handle, LSR #3]
  375.         TEQ     handles, #0
  376. K        MOVeqS  pc, lr                          ; Just counting, return
  377. J        LDR     f, [fw, #FW_Fonts]              ; Map handles to index
  378. .loop   TEQ     f, #0
  379. T        Beq     new_font_fontwindow_registericon; not cached font - go and do it
  380. Y        LDRB    b, [f, #Fnt_HandleB]            ; original, maybe not current/correct
  381.         TEQ     b, handle
  382. %        LDRne   f, [f, #Fnt_Next]
  383.         Bne     loop
  384. +.hook   LDRB    b, [f, #Fnt_CurHandleB]
  385. J        TEQ     b, handle                       ; Has handle changed ?
  386. 9        MOVne   handle, b                       ; Yes
  387. [        STRneB  handle, [flags, #3]             ; Write new font handle into icon flags
  388. '        LDRB    b, [f, #Fnt_IndexB]
  389. G        STMIA   (icons)!, {b, icon}             ; Store index, icon
  390. l        TST     o, t                            ; See if already cached handle (.eq. if not done so yet)
  391. M        STReqB  b, [handles], #1                ; Index of font refers to
  392. U        STReqB  handle, [handles], #1           ; Current handle stored in window
  393.         MOVS    pc, lr
  394. D; here when first time come across an icon with this font handle
  395. #; we cache the font information
  396. %.new_font_fontwindow_registericon
  397. ,        STMFD   (sp)!, {o, t, R4-R8, lr}
  398. #        MOV     R0, #sizeof_Fnt
  399. %        BL      fontwindow_malloc
  400. /        Bvs     err_fontwindow_registericon
  401. C        MOV     R8, R0                          ; Safe register
  402. \        STRB    handle, [R8, #Fnt_CurHandleB]   ; Store handle (as currently open'ed at)
  403. L        STRB    handle, [R8, #Fnt_HandleB]      ; Store base font handle
  404.         MOV     R0, handle
  405. %        ADD     R1, R8, #Fnt_Name
  406. >        SWI     "XFont_ReadDefn"                ; To R1-R7
  407. 0        Bvs     err2_fontwindow_registericon
  408. &        ADD     lr, R8, #Fnt_XSize
  409. E        STMIA   lr, {R2-R3}                     ; Store font size
  410. +        ADD     R6, fw, #FW_CurrentXDPI
  411. ^        LDMIA   R6, {R6-R7}                     ; See if resolution different from current
  412.         TEQ     R4, R6
  413.         TEQeq   R5, R7
  414. ^        BLne    xfontwindow_reopenfont          ; Yes, re-open font for current resolution
  415. 0        Bvs     err2_fontwindow_registericon
  416. I        STRneB  R0, [R8, #Fnt_CurHandleB]       ; Note current handle
  417.         MOV     f, R8
  418. &        LDR     t, [fw, #FW_Fonts]
  419. %        STR     t, [f, #Fnt_Next]
  420.         TEQ     t, #0
  421. '        LDRneB  t, [t, #Fnt_IndexB]
  422. W        ADDne   t, t, #1                        ; New unique index (starts at zero)
  423. '        STRB    t, [f, #Fnt_IndexB]
  424. N        STR     f, [fw, #FW_Fonts]              ; Make head of linked list
  425. ,        LDMFD   (sp)!, {o, t, R4-R8, lr}
  426.         B       hook
  427. !.err2_fontwindow_registericon
  428.         MOV     R4, R0
  429. D        BL      fontwindow_free                 ; Release memory
  430.         MOV     R0, R4
  431.  .err_fontwindow_registericon
  432. ,        LDMFD   (sp)!, {o, t, R4-R8, lr}
  433. !.err_fontwindow_registericons
  434. $        ADD     sp, sp, #256/8+4
  435. '        LDMFD   (sp)!, {R4-R10, lr}
  436. !        
  437. RS    pc, lr, #PSR_V
  438.  ***************************************************************************
  439. _assemble_FontWindow_Update
  440.  buf, curhandle, font, icon, index, nhandles, nicons, rove, storedhandle, w
  441.  loop, lp
  442.   w             = 4
  443.   rove          = 5
  444.   nhandles      = 6
  445.   buf           = 7
  446.   index         = 8
  447.   curhandle     = 9
  448.   nicons        = nhandles
  449.   storedhandle  = 0
  450.   font          = 1
  451. 3  icon          = buf                   :
  452.  icon
  453. [OPT pass%
  454. R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  455. R; This checks that a windows' icons contain valid font handles for the current
  456. ; screen resolution
  457. ); In    R0 = users' handle for window
  458. ; Out   -
  459. .;       [R0 = pointer to Win_...structure]
  460. O; If windows' anti-aliased font icons refer to a font opened to a different
  461. N; screen resolution than the current then we update all the windows' icons
  462. @; If title icon is anti-aliased then need to recreate window
  463. .xfontwindow_update
  464. &        STMFD   (sp)!, {R4-R9, lr}
  465. &        BL      xfontwindow_locate
  466. *        Bvs     exit_fontwindow_update
  467.         MOV     w, R0
  468. 0        LDR     nhandles, [w, #Win_NHandles]
  469. *        LDR     rove, [w, #Win_NIcons]
  470. H        ADD     rove, w, rove, LSL #3           ; two words per icon
  471. S        ADD     rove, rove, #sizeof_Win         ; Point to "used handle"s array
  472. J.loop   LDRB    index, [rove], #1               ; Global index of font
  473. )        LDR     font, [fw, #FW_Fonts]
  474. A.lp     LDRB    lr, [font, #Fnt_IndexB]         ; Locate font
  475.         TEQ     index, lr
  476. +        LDRne   font, [font, #Fnt_Next]
  477.         Bne     lp
  478. ,        LDRB    storedhandle, [rove], #1
  479. 6        LDRB    curhandle, [font, #Fnt_CurHandleB]
  480. ]        CMP     storedhandle, curhandle         ; See if handle has changed [clear PSR_V]
  481. P        BLne    _xfontwindow_update_icons       ; Yes - massage window icons
  482. *        Bvs     exit_fontwindow_update
  483. *        SUBS    nhandles, nhandles, #1
  484.         Bgt     loop
  485. .exit_fontwindow_update
  486. N        MOVvc   R0, w                           ; [used by OpenWindow swi]
  487. &        LDMFD   (sp)!, {R4-R9, lr}
  488. "        BICvcS  pc, lr, #PSR_V
  489. !        
  490. RS    pc, lr, #PSR_V
  491. =; Process all (at least 1) icon with this new font handle
  492. ._xfontwindow_update_icons
  493. -        STMFD   (sp)!, {rove, nicons, lr}
  494. >        STRB    curhandle, [rove, #-1]          ; Update !
  495. ,        LDR     nicons, [w, #Win_NIcons]
  496. @        ADD     rove, w, #sizeof_Win            ; Icon array
  497. ).loop   LDMIA   (rove)!, {font, icon}
  498. C        CMP     font, index                     ; [clear PSR_V]
  499. ,        BLeq    _xfontwindow_update_icon
  500. -        LDMvsFD (sp)!, {rove, nicons, pc}
  501. &        SUBS    nicons, nicons, #1
  502.         Bgt     loop
  503.     -        LDMFD   (sp)!, {rove, nicons, pc}
  504. ._xfontwindow_update_icon
  505.         STMFD   (sp)!, {lr}
  506. O        CMP     icon, #0                        ; -1 => title bar (awkward)
  507. 4        Blt     titlebar__fontwindow_update_icon
  508. 0        LDR     R0, [w, #Win_ExternalHandle]
  509. (        BL      fontwindow_gethandle
  510.         MOV     R1, icon
  511. 2        MOV     R2, curhandle, LSL #ifb_fontno
  512. *        MOV     R3, #&FF << ifb_fontno
  513. "        STMFD   (sp)!, {R0-R3}
  514.         MOV     R1, sp
  515. (        SWI     "XWimp_SetIconState"
  516.         ADD     sp, sp, #16
  517. !.exit__fontwindow_update_icon
  518.         LDMFD   (sp)!, {pc}
  519. %.titlebar__fontwindow_update_icon
  520. &        LDR     R0, [w, #Win_Size]
  521. Z        ADD     R0, R0, #4                      ; (extra word so can get window state)
  522. R        BL      fontwindow_malloc               ; Buffer for window definition
  523. 0        Bvs     exit__fontwindow_update_icon
  524.         MOV     buf, R0
  525.  0        LDR     R0, [w, #Win_ExternalHandle]
  526. !(        BL      fontwindow_gethandle
  527.         MOV     R1, buf
  528. #         STR     R0, [R1, #0]
  529. $K        SWI     "XWimp_GetWindowInfo"           ; Read full window info
  530.         ADDvc   R1, buf, #4
  531. &T        LDRvc   R0, [R1, #w_titleflags]         ; Manually change title bar icon
  532. '.        BICvc   R0, R0, #&FF << ifb_fontno
  533. (5        
  534. Rvc   R0, R0, curhandle, LSL #ifb_fontno
  535. )+        STRvc   R0, [R1, #w_titleflags]
  536. *0        LDRvc   R0, [w, #Win_ExternalHandle]
  537.         MOVvc   R1, buf
  538. ,J        BLvc    fontwindow_recreate             ; Delete/create window
  539. -/        Bvs     err__fontwindow_update_icon
  540. .)        LDR     lr, [buf, #w_flags+4]
  541. /         TST     lr, #ws_open
  542. 0(        BLne    fontwindow_gethandle
  543.         MOVne   R1, buf
  544. 2D        SWIne   "XWimp_OpenWindow"              ; Re-open window
  545.         MOVvc   R0, buf
  546. 4#        BLvc    fontwindow_free
  547. 50        Bvc     exit__fontwindow_update_icon
  548. 6 .err__fontwindow_update_icon
  549.         STMFD   (sp)!, {R0}
  550.         MOV     R0, buf
  551. 9#        BL      fontwindow_free
  552.         LDMFD   (sp)!, {R0}
  553. ;0        B       exit__fontwindow_update_icon
  554.  ***************************************************************************
  555. _assemble_FontWindow_ModeChange
  556.  loop, lp
  557. C'  handle        = 0     :
  558.  implicit
  559.   count         = 1
  560.   font          = 4
  561.   w             = font
  562. [OPT pass%
  563. HR; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  564. JO; This should be called when application receives a Message_ModeChange from
  565. ; the wimp
  566. ; In    -
  567. ; Out   -
  568. PM; If screen resolution has changed then all the old fonts are closed, and
  569. QR; immediately re-opened at the new screen resolution (not closed necessarily!)
  570. SN; If any of the clients' windows are open then they are changed to reflect
  571. T(; the new font handles automatically
  572. .xfontwindow_modechange
  573. W#        STMFD   (sp)!, {R4, lr}
  574. X)        BL      xfontwindow_getcurrez
  575. Y-        Bvs     err_fontwindow_modechange
  576. Z+        ADD     lr, fw, #FW_CurrentXDPI
  577.         LDMIA   lr, {R2-R3}
  578.         TEQ     R0, R2
  579.         TEQeq   R1, R3
  580. ^M        Beq     exit_fontwindow_modechange      ; Not a resolution change
  581. _I        STMIA   lr, {R0-R1}                     ; Note new resolution
  582. `)        LDR     font, [fw, #FW_Fonts]
  583. .loop   TEQ     font, #0
  584. b0        Beq     update_fontwindow_modechange
  585. c3        LDRB    handle, [font, #Fnt_CurHandleB]
  586. d'        ADD     R1, font, #Fnt_Name
  587. e(        ADD     lr, font, #Fnt_XSize
  588. fO        LDMIA   lr, {R2-R3}                     ; Physical size (in points)
  589. g*        BL      xfontwindow_reopenfont
  590. h3        STRvcB  handle, [font, #Fnt_CurHandleB]
  591. i+        LDRvc   font, [font, #Fnt_Next]
  592.         Bvc     loop
  593. .err_fontwindow_modechange
  594. l#        LDMFD   (sp)!, {R4, lr}
  595. m!        
  596. RS    pc, lr, #PSR_V
  597. o!.update_fontwindow_modechange
  598.         ;
  599. q?        ; Here re-opened all (used) fonts to new resolution
  600. rB        ; Now see if any windows were open [and so update NOW]
  601.         ;
  602. t(        LDR     w, [fw, #FW_Windows]
  603. .loop   TEQ     w, #0
  604. v.        Beq     exit_fontwindow_modechange
  605. w0        LDR     R0, [w, #Win_ExternalHandle]
  606. x(        BL      fontwindow_gethandle
  607. y*        SUB     sp, sp, #u_windowstate
  608.         MOV     R1, sp
  609. {'        STR     R0, [R1, #u_handle]
  610. |*        SWI     "XWimp_GetWindowState"
  611. }'        LDRvc   R0, [R1, #u_wflags]
  612. ~*        ADD     sp, sp, #u_windowstate
  613. -        Bvs     err_fontwindow_modechange
  614.          TST     R0, #ws_open
  615. 0        LDRne   R0, [w, #Win_ExternalHandle]
  616. Q        BLne    xfontwindow_update              ; Alter icons only if visible
  617. -        Bvs     err_fontwindow_modechange
  618. %        LDR     w, [w, #Win_Next]
  619.         B       loop
  620. .exit_fontwindow_modechange
  621. #        LDMFD   (sp)!, {R4, lr}
  622. "        BICS    pc, lr, #PSR_V
  623.  ***************************************************************************
  624. _assemble_FontWindow_DeleteWindow
  625. [OPT pass%
  626. R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  627. I; This removes a previously registered window from the list, and then
  628. ; optionally delete's it
  629. ); In    R0 = users' handle for window
  630. 3;       R1 = non-zero if actually delete window
  631. ; Out   -
  632. #;       Window has been deleted
  633. .xfontwindow_deletewindow
  634. '        STMFD   (sp)!, {R1, R4, lr}
  635. &        BL      xfontwindow_locate
  636. /        Bvs     err_fontwindow_deletewindow
  637. '        LDR     R2, [R0, #Win_Next]
  638. M        STR     R2, [R1], #0                    ; Remove from linked list
  639.          LDR     R1, [sp, #0]
  640.         TEQ     R1, #0
  641.         MOVne   R4, R0
  642. 1        LDRne   R0, [R4, #Win_ExternalHandle]
  643. (        BLne    fontwindow_gethandle
  644.          STRne   R0, [sp, #0]
  645.         MOVne   R0, R4
  646. D        BL      fontwindow_free                 ; Release memory
  647.         MOVne   R1, sp
  648. (        SWIne   "XWimp_DeleteWindow"
  649.  .err_fontwindow_deletewindow
  650. '        LDMFD   (sp)!, {R1, R4, lr}
  651. "        BICvcS  pc, lr, #PSR_V
  652. !        
  653. RS    pc, lr, #PSR_V
  654.  ***************************************************************************
  655. _assemble_FontWindow_CloseDown
  656. [OPT pass%
  657. R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  658. M; This removes all registered windows and optionally closes all the fonts
  659. H; In    R0 = non-zero if wish to close all open fonts [usually true]
  660. G;       R1 = non-zero if wish to delete all windows [usually false]
  661. ; Out   -
  662. 2; Note  Error only possible from closing fonts
  663. .xfontwindow_closedown
  664. +        STMFD   (sp)!, {R0, R1, R4, lr}
  665. ).loop   LDR     R0, [fw, #FW_Windows]
  666.         CMP     R0, #0
  667. 1        LDRne   R0, [R0, #Win_ExternalHandle]
  668.          LDRne   R1, [sp, #4]
  669. F        BLne    xfontwindow_deletewindow          ; (ignore error)
  670.         Bne     loop
  671. '        LDR     R4, [fw, #FW_Fonts]
  672. .loop   ADDS    R0, R4, #0
  673. '        LDRne   R4, [R4, #Fnt_Next]
  674. D        BLne    fontwindow_free                 ; Release memory
  675.         Bne     loop
  676. H        STR     R4, [fw, #FW_Fonts]             ; Zero head [safety]
  677. #        LDMFD   (sp)!, {R0, R1}
  678.         TEQ     R0, #0
  679. -        Beq     exit_fontwindow_closedown
  680. +        LDR     R4, [fw, #FW_FontTable]
  681. A        MOV     R0, #256 - 1                    ; Font handle
  682. A.loop   LDRB    R1, [R4, R0]                    ; Usage count
  683. .lp     SUBS    R1, R1, #1
  684. $        SWIhs   "XFont_LoseFont"
  685. ,        Bvs     err_fontwindow_closedown
  686.         Bhi     lp
  687. F        STReqB  R1, [R4, R0]                    ; Zero usage count
  688.         SUBS    R0, R0, #1
  689.         Bhs     loop
  690. .exit_fontwindow_closedown
  691. #        LDMFD   (sp)!, {R4, lr}
  692. "        BICS    pc, lr, #PSR_V
  693. .err_fontwindow_closedown
  694. #        LDMFD   (sp)!, {R4, lr}
  695. !        
  696. RS    pc, lr, #PSR_V
  697.  ***************************************************************************
  698. _assemble_FontWindow_Miscellaneous
  699. [OPT pass%
  700. Error(err_ukwindow, ErrorUKWindow, ErrorUKWindow$)
  701. R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  702. ; In    -
  703. ;; Out   R0 = screen x pixel resolution in dots per inch
  704. ;;       R1 = screen y pixel resolution in dots per inch
  705. ; Bad   R2_R3
  706. ";       PSR_V set, R0 on error
  707. ;       PSR_NZC corrupted
  708. .xfontwindow_getcurrez
  709.         STMFD   (sp)!, {lr}
  710.         MVN     R0, #
  711. *        MOV     R1, #VduExt_XEigFactor
  712. *        SWI     "XOS_ReadModeVariable"
  713.         MOVvc   R3, R2
  714. *        MOVvc   R1, #VduExt_YEigFactor
  715. *        SWIvc   "XOS_ReadModeVariable"
  716. \        MOVvc   R0, #180                        ; Nominal 180 dots per inch (OS defined)
  717. "        MOVvc   R1, R0, LSR R2
  718. "        MOVvc   R0, R0, LSR R3
  719.         LDMFD   (sp)!, {pc}
  720. R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  721. C; Given a pointer to window handle, locate FontWindow structure
  722. ); In    R0 = users' handle for window
  723. C; Out   R0 = pointer to Win_... structure, or zero if not found
  724. );       R1 = pointer to pointer to R0
  725. ";       PSR_V set, R0 on error
  726. ;       PSR_ZNC preserved
  727. .xfontwindow_locate
  728.         MOV     R2, R0
  729. '        ADD     R1, fw, #FW_Windows
  730.  .loop   LDR     R0, [R1], #0
  731.         TEQ     R0, #0
  732. 1        LDRne   R3, [R0, #Win_ExternalHandle]
  733.         TEQne   R3, R2
  734. %        ADDne   R1, R0, #Win_Next
  735.         Bne     loop
  736.         TEQ     R0, #0
  737. L        TEQne   R2, #0                          ; Window handle 0 => bad
  738. ;        BICneS  pc, lr, #PSR_V                  ; Found
  739. &        
  740. adrf("", 0, err_ukwindow)
  741. !        
  742. RS    pc, lr, #PSR_V
  743. R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  744. 0; Close a font and re-open to new resolution
  745. ; In    R0 = font handle
  746. G;       R1 = pointer to font name [font size in two preceding word]
  747. -;       R2 = width of font in points * 16
  748. .;       R3 = height of font in points * 16
  749.  ; Out   R0 = new font handle
  750. ";       PSR_V set, R0 on error
  751. ;       PSR_NZC preserved
  752. "A; Need to keep open at 
  753. AL size because otherwise wimp barfs
  754. #2; badly on writable icons and invisible others
  755. $G; To save hassle, just ensure font open at least once, but close if
  756. ; open more than once
  757. .xfontwindow_reopenfont
  758. (&        STMFD   (sp)!, {R4-R6, lr}
  759. )+        LDR     R6, [fw, #FW_FontTable]
  760. *D        LDRB    lr, [R6, R0]                    ; Count of usage
  761. +C        CMP     lr, #1                          ; keep one open
  762.         SUBgt   lr, lr, #1
  763. -         STRgtB  lr, [R6, R0]
  764. .$        SWIgt   "XFont_LoseFont"
  765. /+        ADDvc   R4, fw, #FW_CurrentXDPI
  766.         LDMvcIA R4, {R4-R5}
  767. 1U        SWIvc   "XFont_FindFont"                ; Open font to current resolution
  768. 2         LDRvcB  lr, [R6, R0]
  769.         ADDvc   lr, lr, #1
  770. 4P        STRvcB  lr, [R6, R0]                    ; Flag font opened once more
  771. 5&        LDMFD   (sp)!, {R4-R6, lr}
  772. 6"        BICvcS  pc, lr, #PSR_V
  773. 7!        
  774. RS    pc, lr, #PSR_V
  775. 8R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  776. 9D; These are simple routines that indirect to the actual routines
  777. .fontwindow_malloc
  778. <(        STMFD   (sp)!, {R10-R12, lr}
  779. =/        LDR     lr, [fw, #FW_MallocRoutine]
  780. .hook   STMFD   (sp)!, {lr}
  781. ?-        LDR     R12, [fw, #FW_ClientsR12]
  782.         MOV     lr, pc
  783.         LDMFD   (sp)!, {pc}
  784. B(        LDMFD   (sp)!, {R10-R12, pc}
  785. .fontwindow_free
  786. D(        STMFD   (sp)!, {R10-R12, lr}
  787. E-        LDR     lr, [fw, #FW_FreeRoutine]
  788.         B       hook
  789. .fontwindow_gethandle
  790. H(        STMFD   (sp)!, {R10-R12, lr}
  791. I2        LDR     lr, [fw, #FW_GetHandleRoutine]
  792.         B       hook
  793. .fontwindow_recreate
  794. L(        STMFD   (sp)!, {R10-R12, lr}
  795. M1        LDR     lr, [fw, #FW_RecreateRoutine]
  796.         B       hook
  797. OR; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  798. Q>; In    R0 = unsigned 32-bit amount of memory to claim > 0
  799. R@; Out   R0 = pointer to word-aligned memory of required size
  800. ; Bad   R1-R3
  801. T";       PSR_V set, R0 on error
  802. ;       PSR_NZC preserved
  803. .default_malloc
  804.         MOV     R1, lr
  805.         MOV     R3, R0
  806. Y,        MOV     R0, #ModHandReason_Claim
  807. Z         SWI     "XOS_Module"
  808.         MOVvc   R0, R2
  809. \"        BICvcS  pc, R1, #PSR_V
  810. ]!        
  811. RS    pc, R1, #PSR_V
  812. ^R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  813. `L; In    R0 = pointer to previouly allocated word-aligned memory, or zero
  814. ; Out   -
  815. ; Bad   R0-R3
  816. ;       PSR_NZCV preserved
  817. .default_free
  818.         MOV     R1, lr
  819.         MOVS    R2, R0
  820. g+        MOVne   R0, #ModHandReason_Free
  821. h         SWIne   "XOS_Module"
  822.         MOVS    pc, R1
  823. jR; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  824. l); In    R0 = users' handle for window
  825. ; Out   R0 = window handle
  826. ; Bad   R1-R3
  827. ;       PSR_NZCV preserved
  828. q?; <users' handle is a pointer to actual wimp window handle>
  829. .default_gethandle_1
  830. t         LDR     R0, [R0], #0
  831.         MOVS    pc, lr
  832. w6; <users' handle is the actual wimp window handle>
  833. .default_gethandle
  834.         MOVS    pc, lr
  835. {R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  836. }P; We wish to change the flags of the title icon.  To this end the caller has
  837. ~E; done a Wimp_GetWindowInfo and massaged the title bar icon flags
  838. O; This routine must now delete the window and then re-create it immediately
  839. 2; (the only way to update the title bar icon!)
  840. ; Note the return condition
  841. ); In    R0 = users' handle for window
  842. <;       R1 = pointer to buffer containing wimp_createstr
  843. @; Out   R1 points to a wimp_openstr block for the new window
  844. ; Bad   R0-R3
  845. ";       PSR_V set, R0 on error
  846. ;       PSR_NZC preserved
  847. ?; <users' handle is a pointer to actual wimp window handle>
  848. .default_recreate_1
  849.         MOV     R3, R0
  850.         MOV     R2, lr
  851. (        SWI     "XWimp_DeleteWindow"
  852.         ADDvc   R1, R1, #4
  853. (        SWIvc   "XWimp_CreateWindow"
  854. I        STRvc   R0, [R3], #0                    ; Store window handle
  855.         SUBvc   R1, R1, #4
  856. T        STRvc   R0, [R1, #u_handle]             ; R1 block is now a wimp_openstr
  857. "        BICvcS  pc, R2, #PSR_V
  858. !        
  859. RS    pc, R2, #PSR_V
  860. 6; <users' handle is the actual wimp window handle>
  861. M; This operation is not possible - do nothing (exit conditions fulfilled)
  862. .default_recreate
  863. "        BICS    pc, lr, #PSR_V
  864.  ***************************************************************************
  865. _FontWindow_Module_Constants(code%, L%)
  866.  O%, P%, pass%
  867.   pass% = %1110
  868. U  sizeof_Stack = 8*4            :
  869.   really small stack, all that's needed by app.
  870. 6  SWIChunk      = &DBCC0        :
  871.   user swi chunk
  872. <  ErrorBadSWI$          = "Unknown FontWindow operation"
  873. A  ErrorBadVersion$      = "Bad version number for FontWindow"
  874. C  ErrorFlagsNotZero$    = "FontWindow: reserved flags not zero"
  875. >  ErrorModActive$       = "FontWindow is currently active"
  876. 7  ErrorUKClient$        = "Unknown FontWindow task"
  877. 9  ErrorUKWindow$        = "Unknown FontWindow window"
  878. P  ErrorNoWimp$          = "FontWindow: Window manager too old / not present"
  879. "  ErrorBadSWI           = &110
  880. $  O%=code%:P%=SWIChunk:[OPTpass%
  881. "  .ErrorUKClient        EQUB 0
  882. "  .ErrorUKWindow        EQUB 0
  883. "  .ErrorBadVersion      EQUB 0
  884. "  .ErrorFlagsNotZero    EQUB 0
  885. "  .ErrorModActive       EQUB 0
  886. "  .ErrorNoWimp          EQUB 0
  887.   ModHelp$ = "-The FontWindow module manages anti-aliased font icons in windows across screen resolution changes."    :
  888.   help for *Dekstop_FontWindow
  889.   AppHelp$ = ":Start a wimp module task that detects programs dieing and closes fonts/releases memory --- a debugging aid during program development."
  890.   Desktop_Code = 0
  891.   O%=code%:P%=0:[OPT pass%
  892. _FontWindow_globals
  893. .sizeof_G
  894. _FontWindow_globals
  895. [OPT pass%
  896. =.G_PrivateWord          EQUD 0  ; pointer to private word
  897. O.G_Clients              EQUD 0  ; pointer to linked list of FW_..., or zero
  898.  FontWindow_debug_p 
  899. [OPT pass%
  900. 6.G_TaskHandle           EQUD 0  ; wimp task handle
  901. 4.G_Poll                 
  902. r(256); wimp poll block
  903. 6               
  904. r(sizeof_Stack); application stack
  905. .G_Stack
  906.  ***************************************************************************
  907. _assemble_FontWindow_Module
  908.  (pass% 
  909.  %0100)=0 
  910.  1, "Must be offset assembly"
  911.  1, "Module not at zero offset"
  912. [OPT pass%
  913. %        EQUD    Module_Start_Code
  914. /        EQUD    Module_Initialisation_Code 
  915. ,        EQUD    Module_Finalisation_Code
  916. /        EQUD    Module_Service_Call_Handler
  917. '        EQUD    Module_Title_String
  918. &        EQUD    Module_Help_String
  919. 9        EQUD    Module_Help_And_Command_Keyword_Table
  920.         EQUD    SWIChunk
  921. "        EQUD    SWIHandlerCode
  922. "        EQUD    SWIDecodeTable
  923. .Module_Title_String
  924. !        EQUS "FontWindow"+ 
  925. .Module_Help_String
  926. C        EQUS "FontWindow"+ 
  927. (9)+ "1.00 ("+ 
  928. $, 5, 11)+ ")"+ 
  929. ,.SWIDecodeTable EQUS    "FontWindow"+ 
  930. ,                EQUS    "Initialise"+ 
  931. +                EQUS    "CloseDown"+ 
  932. ,                EQUS    "ModeChange"+ 
  933. .                EQUS    "CreateWindow"+ 
  934. .                EQUS    "DeleteWindow"+ 
  935. ,                EQUS    "OpenWindow"+ 
  936. .                EQUS    "UpdateWindow"+ 
  937.                 EQUB    &00
  938. *.Module_Help_And_Command_Keyword_Table
  939. "        
  940. _Module_Command_Start
  941. G        
  942. _Module_Command( "FontWindow", 0, &00000000, "", ModHelp$)
  943.  FontWindow_debug_p 
  944. X    
  945. _Module_Command( "Desktop_FontWindow", Desktop_Code, &00000000, "", AppHelp$)
  946. [OPT pass%
  947.          
  948. _Module_Command_End
  949. Error(err_badswi, ErrorBadSWI, ErrorBadSWI$)
  950. Error(err_ukclient, ErrorUKClient, ErrorUKClient$)
  951. Error(err_modactive, ErrorModActive, ErrorModActive$)
  952. Error(err_flagsnotzero, ErrorFlagsNotZero, ErrorFlagsNotZero$)
  953. Error(err_badversion, ErrorBadVersion, ErrorBadVersion$)
  954. I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  955.         ALIGN
  956. .SWIHandlerCode
  957. !        LDR     gb, [R12], #0
  958. Q        BIC     lr, lr, #PSR_V                  ; Faster successful returning
  959. \        TEQP    pc, #3                          ; Ensure in SVC mode, interrupts enabled
  960.         CMP     R11, #7
  961. '        ADDlo   pc, pc, R11, LSL #2
  962. %        B       FontWindow_BadSWI
  963. ,        B       FontWindow_InitialiseSWI
  964.     +        B       FontWindow_CloseDownSWI
  965. ,        B       FontWindow_ModeChangeSWI
  966. .        B       FontWindow_CreateWindowSWI
  967. .        B       FontWindow_DeleteWindowSWI
  968. ,        B       FontWindow_OpenWindowSWI
  969. .        B       FontWindow_UpdateWindowSWI
  970. .FontWindow_BadSWI
  971. "        ADR     R0, err_badswi
  972. !        
  973. RS    pc, lr, #PSR_V
  974. I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  975. ; uses no stack
  976. %; exit  R2 = pointer to workspace
  977. .Module_Initialisation_Code
  978. !        LDR     R2, [R12], #0
  979.         TEQ     R2, #0
  980. "        BICneS  pc, lr, #PSR_V
  981.         MOV     R1, lr
  982. !        
  983. mov("", 3, sizeof_G)
  984. ,        MOV     R0, #ModHandReason_Claim
  985. [        SWI     "XOS_Module"                    ; Get workspace memory (generate error)
  986.         MOVvs   pc, R1
  987.  F        STR     R2, [R12], #0                   ; Set private word
  988.         MOV     R0, #0
  989. .loop   SUBS    R3, R3, #4
  990. #c        STRhs   R0, [R2, R3]                    ; Zero private workspace (initialise variables)
  991.         Bhi     loop
  992. %E        STR     R12, [R2, #G_PrivateWord]       ; Store for later
  993. &"        BICS    pc, R1, #PSR_V
  994. 'I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  995. .Module_Finalisation_Code
  996. *!        LDR     gb, [R12], #0
  997.         CMP     gb, #0
  998. ,"        BICleS  pc, lr, #PSR_V
  999. -'        STMFD   (sp)!, {R7-R11, lr}
  1000. .(        LDR     R0, [gb, #G_Clients]
  1001.         TEQ     R0, #0
  1002. 0)        
  1003. adrf("ne", 0, err_modactive)
  1004. 1"        CMPne   pc, #&80000000
  1005. 2C        BLvc    close_application               ; Quit at once!
  1006.         MOVvc   R2, gb
  1007. 4B        LDRvc   R12, [gb, #G_PrivateWord]       ; Return value
  1008.         MOVvc   lr, #0
  1009. 6H        STRvc   lr, [R12], #0                   ; Clear private word
  1010. 7+        MOVvc   R0, #ModHandReason_Free
  1011. 8G        SWIvc   "XOS_Module"                    ; Release workspace
  1012. 9K        LDMFD   (sp)!, {R7-R11, pc}             ; Propogate maybe error
  1013. :I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1014. < .Module_Service_Call_Handler
  1015. =&        TEQ     R1, #Service_Reset
  1016. >!        Beq     service_Reset
  1017.         MOV     pc, lr
  1018. A5; Here the user has just pressed the reset button
  1019. BH; If application was running then need to release all of its' memory
  1020. C.; Also clear any error flags (privateword)
  1021. .service_Reset
  1022. F&        STMFD   (sp)!, {R0-R3, lr}
  1023. G!        LDR     gb, [R12], #0
  1024.         TEQ     gb, #0
  1025. I<        LDMeqFD (sp)!, {R0-R3, pc}              ; Never!
  1026.  FontWindow_debug_p 
  1027. [OPT pass%
  1028.         MOV     R0, #0
  1029. N[        STR     R0, [gb, #G_TaskHandle]         ; Make sure don't try closing task down
  1030. [OPT pass%
  1031. RO        BL      close_application               ; Release extra memory used
  1032. SO        BL      shutdown_all_clients            ; [no-one survives a reset]
  1033. T'        LDMFD   (sp)!, {R0-R3, pc}^
  1034. UV\- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1035. W%; In    gb = pointer to workspace
  1036. X5; Out   all currently active clients are shutdown
  1037. Y$;       All errors are suppresed
  1038. .shutdown_all_clients
  1039.         STMFD   (sp)!, {lr}
  1040. ](.loop   LDR     fw, [gb, #G_Clients]
  1041.         TEQ     fw, #0
  1042. _         LDMeqFD (sp)!, {pc}^
  1043. `G        MOV     R0, #0                          ; Don't close fonts
  1044. aJ        MOV     R1, #0                          ; Don't delete windows
  1045. bG        BL      xfontwindow_shutdown            ; Completely zap it
  1046.         B       loop
  1047. dV\- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1048. f5; This is called when WE wish to shut a task down
  1049. gR; If tasks' free() routine was not the default routine then replace with dummy
  1050. h1; code (the old address may not be valid now)
  1051. j"; In    fw = pointer to client
  1052. k1;       R0 = non-zero if close all open fonts
  1053. l+;       R1 = non-zero if delete windows
  1054. ; Out   -
  1055. .xfontwindow_shutdown
  1056. p-        LDR     R3, [fw, #FW_FreeRoutine]
  1057. q&        
  1058. adrl("", 2, default_free)
  1059.         TEQ     R3, R2
  1060. sH        ADRne   R3, dummy_free                  ; Don't use app code
  1061. t-        STRne   R3, [fw, #FW_FreeRoutine]
  1062.         MOV     R2, R1
  1063.         MOV     R1, R0
  1064. w,        LDR     R0, [fw, #FW_TaskHandle]
  1065.         MOV     R3, lr
  1066. y/        
  1067. bootstrap("XFontWindow_CloseDown")
  1068. z"        BICvcS  pc, R3, #PSR_V
  1069. {!        
  1070. RS    pc, R3, #PSR_V
  1071. .dummy_free
  1072.         MOVS    pc, lr
  1073. ~I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1074. -; In    R0 = task handle [0 => not found]
  1075. B; Out   fw = pointer to FW_... structure, or zero if not found
  1076. ";       PSR_V set, R0 if error
  1077. ;       PSR_NZC undefined
  1078. .xlocate_client
  1079.         STMFD   (sp)!, {lr}
  1080. (        LDR     fw, [gb, #G_Clients]
  1081. C.loop   CMP     fw, #0                          ; [clear PSR_V]
  1082. ,        LDRne   lr, [fw, #FW_TaskHandle]
  1083.         TEQne   R0, lr
  1084. &        LDRne   fw, [fw, #FW_Next]
  1085.         Bne     loop
  1086.         TEQ     fw, #0
  1087. S        TEQne   R0, #0                          ; Error if task handle is zero!
  1088.         LDMneFD (sp)!, {pc}
  1089. &        
  1090. adrf("", 0, err_ukclient)
  1091. "        CMP     pc, #&80000000
  1092.         LDMFD   (sp)!, {pc}
  1093. I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1094. '; In    R0 = task handle (non-zero)
  1095. 1;       R1 = pointer to xmalloc(uint) routine
  1096. 1;       R2 = pointer to free(pointer) routine
  1097. =;       R3 = pointer to gethandle(handle, buffer) routine
  1098. <;       R4 = pointer to recreate(handle, buffer) routine
  1099. ;       R5 = routines' R12
  1100. ];       R6 = pointer to 256-byte font table used while loading templates, pre-initialised
  1101. =;            or zero to allocate one in RMA [and zero it]
  1102. N;       R7 = latest version of FontWindow caller knows about * 100 + flags
  1103. N; Out   R0 = pointer to 256-byte font table to use while loading templates
  1104. .FontWindow_InitialiseSWI
  1105. &        STMFD   (sp)!, {R0-R3, lr}
  1106. #        MOVS    lr, R7, LSR #16
  1107. ,        
  1108. adrf("ne", 0, err_flagsnotzero)
  1109.         Bne     err_SWI
  1110. "        CMP     R7, #1.0 * 100
  1111. *        
  1112. adrf("lo", 0, err_badversion)
  1113.         Blo     err_SWI
  1114. "        MOV     R0, #sizeof_FW
  1115.         TEQ     R6, #0
  1116. E        ADDeq   R0, R0, #256                    ; [append to end]
  1117. E        BL      default_malloc                  ; Allocate memory
  1118.         Bvs     err_SWI
  1119.         MOV     fw, R0
  1120. &        ADD     R0, fw, #sizeof_FW
  1121. M        ADDeq   R0, R0, #256                    ; Zero font table as well
  1122.         MOV     lr, #0
  1123. P.loop   STR     lr, [R0, #-4]!                  ; Zero structure (essential)
  1124.         CMP     R0, fw
  1125.         Bhi     loop
  1126.         LDMFD   sp, {R0-R3}
  1127. *        BL      xfontwindow_initialise
  1128. (        LDRvc   lr, [gb, #G_Clients]
  1129. &        STRvc   lr, [fw, #FW_Next]
  1130. I        STRvc   fw, [gb, #G_Clients]            ; Head of linked list
  1131.         ADDvc   sp, sp, #4
  1132. '        LDMvcFD (sp)!, {R1-R3, pc}^
  1133.         STMFD   (sp)!, {R0}
  1134.         MOV     R0, fw
  1135. D        BL      default_free                    ; Release memory
  1136.         LDMFD   (sp)!, {R0}
  1137. .err_SWI
  1138.         ADD     sp, sp, #4
  1139. .hook_err_SWI
  1140. &        LDMFD   (sp)!, {R1-R3, lr}
  1141. !        
  1142. RS    pc, lr, #PSR_V
  1143. I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1144. ; In    R0 = task handle
  1145. D;       R1 = pointer to window definition block (wimp_createstr)
  1146. H;       R2 = users' handle for window (or zero to use window handle)
  1147. ; Out   R0 window handle
  1148. @;       R1 = non-zero if window contained anti-aliased fonts
  1149. 7;       Window has been created [Wimp_CreateWindow]
  1150. !;       R1 preserved if error
  1151. .FontWindow_CreateWindowSWI
  1152. &        STMFD   (sp)!, {R1-R3, lr}
  1153. "        BL      xlocate_client
  1154.         MOVvc   R0, R2
  1155. ,        BLvc    xfontwindow_createwindow
  1156.         ADDvc   sp, sp, #4
  1157. '        LDMvcFD (sp)!, {R2-R3, pc}^
  1158.          B       hook_err_SWI
  1159. I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1160. ; In    R0 = task handle
  1161. );       R1 = users' handle for window
  1162. ; Out   -
  1163. .FontWindow_DeleteWindowSWI
  1164. &        STMFD   (sp)!, {R0-R3, lr}
  1165. "        BL      xlocate_client
  1166.         MOVvc   R0, R1
  1167. C        MOVvc   R1, #1                          ; Delete window
  1168. ,        BLvc    xfontwindow_deletewindow
  1169. '        LDMvcFD (sp)!, {R0-R3, pc}^
  1170.         b       err_SWI
  1171. I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1172. ; In    R0 = task handle
  1173. );       R1 = users' handle for window
  1174. ; Out   -
  1175. .FontWindow_UpdateWindowSWI
  1176. &        STMFD   (sp)!, {R0-R3, lr}
  1177. "        BL      xlocate_client
  1178.         MOVvc   R0, R1
  1179. &        BLvc    xfontwindow_update
  1180. '        LDMvcFD (sp)!, {R0-R3, pc}^
  1181.         B       err_SWI
  1182. I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1183. ; In    R0 = task handle
  1184. L;       R1 = pointer to wimp_openstr block [window handle not filled in]
  1185. );       R2 = users' handle for window
  1186. ; Out   -
  1187. 7;       Window altered if necessary and then opened
  1188. .FontWindow_OpenWindowSWI
  1189. &        STMFD   (sp)!, {R0-R3, lr}
  1190. "        BL      xlocate_client
  1191.         MOVvc   R0, R2
  1192. &        BLvc    xfontwindow_update
  1193. 1        LDRvc   R0, [R0, #Win_ExternalHandle]
  1194. (        BLvc    fontwindow_gethandle
  1195.          LDRvc   R1, [sp, #4]
  1196. '        STRvc   R0, [R1, #u_handle]
  1197. =        SWIvc   "XWimp_OpenWindow"              ; Open it
  1198. '        LDMvcFD (sp)!, {R0-R3, pc}^
  1199.         B       err_SWI
  1200. I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1201. ; In    R0 = task handle
  1202. ; Out   -
  1203. .FontWindow_ModeChangeSWI
  1204. &        STMFD   (sp)!, {R0-R3, lr}
  1205. "        BL      xlocate_client
  1206. *        BLvc    xfontwindow_modechange
  1207. '        LDMvcFD (sp)!, {R0-R3, pc}^
  1208.         B       err_SWI
  1209. I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1210. ; In    R0 = task handle
  1211. I;       R1 = non-zero if wish to close all open fonts [usually true!]
  1212. C;       R2 = non-zero if wish to delete windows [usually false]
  1213. ; Out   -
  1214. 2; Note  Error only possible from closing fonts
  1215. .FontWindow_CloseDownSWI
  1216. &        STMFD   (sp)!, {R0-R3, lr}
  1217. "        BL      xlocate_client
  1218.         Bvs     err_SWI
  1219.         MOV     R0, R1
  1220.         MOV     R1, R2
  1221.  )        BL      xfontwindow_closedown
  1222. !         STRvs   R0, [sp], #0
  1223. "L        ADD     R1, gb, #G_Clients              ; Find pointer to client
  1224. # .loop   LDR     R0, [R1], #0
  1225. $F        TEQ     R0, fw                          ; [preserve PSR_V]
  1226. %$        ADDne   R1, R0, #FW_Next
  1227.         Bne     loop
  1228. '&        LDR     R2, [R0, #FW_Next]
  1229. (M        STR     R2, [R1], #0                    ; Remove from linked list
  1230. )         BL      default_free
  1231. *'        LDMvcFD (sp)!, {R0-R3, pc}^
  1232.         B       err_SWI
  1233.  FontWindow_debug_p 
  1234. .-    
  1235. _assemble_FontWindow_Module_Task
  1236.     Module_Start_Code = 0
  1237. [OPT pass%
  1238. .close_application
  1239.         MOVS    pc, lr
  1240.  *****************************************************************************
  1241. _assemble_FontWindow_Module_Task
  1242. error = &CBCBCB
  1243. [OPT pass%
  1244. Error(err_nowimp, ErrorNoWimp, ErrorNoWimp$)
  1245. >V\- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1246. @,\       This gets called if *Desktop_...
  1247. AC\       If not already running then enter module as application
  1248. B$\       otherwise generate error
  1249. C(\ In    R0 = pointer to command tail
  1250. \       in SVC mode
  1251.         ALIGN
  1252. .Desktop_Code
  1253. G#        STMFD   (sp)!, {R0, lr}
  1254. HR        LDR     gb, [R12], #0                   ; Get contents of private word
  1255.         MOV     R0, #0
  1256. J'        SWI     "XWimp_ReadSysInfo"
  1257. K#        LDMvsFD (sp)!, {lr, pc}
  1258.         CMP     R0, #0
  1259. M"        ADReq   R0, err_nowimp
  1260. N$        Beq     err_Desktop_Code
  1261.         LDR     R2, [sp]
  1262. P+        LDR     lr, [gb, #G_TaskHandle]
  1263.         TEQ     lr, #0
  1264. R,        MOVeq   R0, #ModHandReason_Enter
  1265. S/        
  1266. adrf("eq", 1, Module_Title_String)
  1267. TB        SWIeq   "XOS_Module"                    ; Enter module
  1268. U'        
  1269. adrf("", 0, err_modactive)
  1270. .err_Desktop_Code
  1271. W"        CMP     pc, #&80000000
  1272. X#        LDMFD   (sp)!, {lr, pc}
  1273. YI; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1274. ; Exits through OS_Exit
  1275. ; Note  no R13 set up!!!
  1276. .value_TASK     EQUS "TASK"
  1277. .value_ABEX     EQUS "ABEX"
  1278. .Module_Start_Code
  1279.         ;
  1280. c(        ; Allocate memory for module
  1281.         ;
  1282. eM        BL      Module_Initialisation_Code      ; Claim memory if need to
  1283. f&        SWIvs   "OS_GenerateError"
  1284.         MOV     gb, R2
  1285. hI        
  1286. gb("", sp, G_Stack)                   ; Set up private stack
  1287. i+        LDR     lr, [gb, #G_TaskHandle]
  1288.         CMP     lr, #0
  1289. k)        
  1290. adrf("gt", 0, err_modactive)
  1291. l&        SWIgt   "OS_GenerateError"
  1292.         ;
  1293.         ; Initialise wimp
  1294.         ;
  1295. p@        MOV     R0, #300                        ; wimp value
  1296. q"        LDR     R1, value_TASK
  1297. r-        
  1298. adrf("", 2, Module_Title_String)
  1299. s&        
  1300. adrl("", 3, messages_end)
  1301. tX        LDR     R4, [R3], #0                    ; R4 = number of messages understand
  1302.         MOV     R5, sp
  1303. vI.loop   LDR     lr, [R3, #-8]!                  ; lr = message number
  1304. w"        STR     lr, [sp, #-4]!
  1305.         SUBS    R4, R4, #1
  1306.         Bhi     loop
  1307.         MOV     R3, sp
  1308. {&        SWI     "XWimp_Initialise"
  1309.         Bvs     abort
  1310.         CMP     R0, #200
  1311. ~&        
  1312. adrf("lo", 0, err_nowimp)
  1313.         Blo     abort
  1314.         MOV     sp, R5
  1315. +        STR     R1, [gb, #G_TaskHandle]
  1316.         ;
  1317.         ; Now loop
  1318. E        ; Since no windows or icon bar icon just wait on messages
  1319.         ;
  1320. .poll_loop
  1321. 6.loop   MOV     R0, #pointerchange_bits 
  1322.  null_bit
  1323.         
  1324. gb("", 1, G_Poll)
  1325.         MOV     R2, #0
  1326.          SWI     "XWimp_Poll"
  1327. !        BLvc    dispatch_poll
  1328.         Bvc     loop
  1329.         MOV     R1, #1
  1330.          BL      report_error
  1331.         TEQ     R1, #2
  1332. I        Bne     loop                            ; Quit from error box
  1333. .message_Quit
  1334.         ;
  1335. =        ; Here must unconditionally exit from application
  1336. <        ; (would already have handled a PreQuit message)
  1337.         ;
  1338. %        BL      close_application
  1339. "        LDR     R1, value_ABEX
  1340.         MOV     R2, #0
  1341.         SWI     "OS_Exit"
  1342. .dispatch_poll
  1343.         STMFD   (sp)!, {lr}
  1344. %        TEQ     R0, #User_Message
  1345. .        TEQne   R0, #User_Message_Recorded
  1346. '        Beq     _xpoll_User_Message
  1347.         LDMFD   (sp)!, {pc}
  1348. +; here couldn't initialise wimp program
  1349. .abort
  1350.         MOV     R4, R0
  1351. %        BL      close_application
  1352.         MOV     R0, R4
  1353.         MVN     lr, #0
  1354. S        STR     lr, [gb, #G_TaskHandle]         ; flag as error in private word
  1355. &        SWI     "OS_GenerateError"
  1356. .abnormal_exit
  1357.         MOV     R1, #2
  1358.          BL      report_error
  1359. %        BL      close_application
  1360.         SWI     "OS_Exit"
  1361. V\- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1362. 1; In    gb = pointer to workspace (validated)
  1363. :; Out   R12 = pointer to private word (now holds zero)
  1364. 5;       all application-specific memory is purged
  1365. );       Task is closed down if active
  1366. ;       workspace is free'd
  1367. N;       Note that if called from in application, you just lost your stack!
  1368. $;       All errors are suppresed
  1369. .close_application
  1370.         STMFD   (sp)!, {lr}
  1371. +        LDR     R0, [gb, #G_TaskHandle]
  1372.         CMP     R0, #0
  1373. D        BLgt    shutdown_all_clients            ; (ignore error)
  1374.         MOVgt   lr, #0
  1375. B        STRgt   lr, [gb, #G_TaskHandle]         ; Flag died ok
  1376. "        LDRgt   R1, value_TASK
  1377. %        SWIgt   "XWimp_CloseDown"
  1378. `        LDMFD   (sp)!, {pc}^                    ; Return address (incase stack in workspace)
  1379. V\- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  1380. 7;       Show error message in non-multi-tasking box
  1381. '; In    R0 = pointer to error block
  1382. ;       R1 = flags
  1383. .report_error
  1384.         STMFD   (sp)!, {lr}
  1385. -        
  1386. adrf("", 2, Module_Title_String)
  1387. '        SWI     "XWimp_ReportError"
  1388.          LDMFD   (sp)!, {pc}^
  1389. R; ----------------------------------------------------------------------------
  1390.  ; In    Wimp_Poll (see docs)
  1391. ._xpoll_User_Message
  1392. (        LDR     lr, [R1, #ms_action]
  1393. R        ADR     R0, messages                    ; Special-format ordered table
  1394.  .loop   LDMIA   R0!, {R2-R3}
  1395.         TEQ     R2, lr
  1396. ?        ADDeq   pc, R0, R3                      ; Handle it
  1397.         TEQ     R2, #0
  1398.         Bne     loop
  1399. N        LDMFD   (sp)!, {pc}^                    ; Should *never* get here!
  1400.         
  1401. message_start
  1402. B        
  1403. message(Message_TaskCloseDown, message_TaskCloseDown)
  1404. C        
  1405. message(Message_Quit, message_Quit)   ;  must be last!
  1406.         
  1407. message_end
  1408. .message_TaskCloseDown
  1409. ,        LDR     R0, [R1, #ms_taskhandle]
  1410. "        BL      xlocate_client
  1411. A        LDMvsFD (sp)!, {pc}^                    ; (no error!)
  1412. +        LDR     R0, [fw, #FW_FontTable]
  1413. &        SUB     R0, R0, #sizeof_FW
  1414.         TEQ     R0, fw
  1415. F        MOVeq   R0, #1                          ; Close its' fonts
  1416.         MOVne   R0, #0
  1417. J        MOV     R1, #0                          ; Don't delete windows
  1418. G        BL      xfontwindow_shutdown            ; Completely zap it
  1419.         LDMFD   (sp)!, {pc}
  1420.  *****************************************************************************
  1421.      assemble a standard error block
  1422. Error(
  1423.  e, number, e$)
  1424. [OPT pass%
  1425.         ALIGN
  1426. .e      EQUD    number
  1427.         EQUS    e$
  1428.         EQUB    0
  1429.         ALIGN
  1430.     ]:= 0
  1431. fw_uxb(template$)
  1432. p_uxb(template$+ "%k%v"+ 
  1433. bootstrap(swi$)
  1434.  pass% 
  1435. E    
  1436.  "XOS_SWINumberFromString",, "FontWindow_Initialise" 
  1437.  ; c%
  1438. >      
  1439.  "Module must be resident and then re-assembled"
  1440. ?      
  1441.  "The module now being created is NOT usable ..."
  1442.       k = 
  1443.             
  1444.       [OPT pass%
  1445.                 SWI swi$
  1446.       ]
  1447.         
  1448.     P%+=4:O%+=4
  1449.