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:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
RISC OS BBC BASIC V Source
|
1993-01-28
|
58.3 KB
|
1,449 lines
>FontWindow
Run to create module (*)
If module we have `fw' = R11, `gb' = R12
If inline have `fw' = R12 (and assume constants are actually offsets into
global vars)
(*) need to run, run module, re-assemble as module contains calls to itself
MACHINE: Archimedes
LANGUAGE: BBC BASIC V, v1.05
AUTHOR: Cy Booker,
86 Church View, Main Road, Crockenhill, Swanley, Kent.
BR8 8JW
"<BasicV$Lib>.LibHandler" :
_handle_library_error
_hard_initialise_LibHandler( 20, 011 )
KDebug_Wimp%=
:Debug%=
:On_Lib_Error_MODE%=-3 :
Desktop Development
"XHourglass_On"
"XHourglass_Off":
_handle_library_error
Now to load in the library files used by this program.
_load_library( "<BasicV_Assembler$Lib>.Misc", 039 )
_load_library( "<BasicV_Assembler$Lib>.Messages", 004 )
_load_library( "<BasicV_Assembler$Lib>.Module", 005 )
_load_library( "<BasicV_Assembler$Lib>.Services", 004)
_load_library( "<BasicV_Assembler$Lib>.VduExt", 001)
_load_library( "<BasicV_Assembler$Lib>.WimpConst", 003)
code_len% = 4*1024
code% code_len%
sp = 13
lr = 14
PSR_V = 1 << 28
PSR_Z = 1 << 30
L% = code% + code_len%
_WimpConst(code%, L%)
_VduExt(code%, L%)
_Services(code%, L%)
_Messages(code%, L%)
pass%= %1100
%1110
P% = 0 : O% = code%
-'
_assemble_FontWindow(
(pass%
2) = 0
i%= 0
P%-1
code%!i% = 0
3
pass%
"OS_File", 10, "<FontWindow$Output>", &FFA,, code%, O%
1, "Created FontWindow module [size &"+
~(P%)+ "]"
pass%
o% = 50
o% = 0
"XHourglass_Percentage", ((
aadr(P%)-code%)/(L%-code%)*50)+o%
***************************************************************************
if module_p is non-zero then assemble a module
if debug_p is true [and module_p] then assemble in a wimp module task that
automatically closes fonts when a window dies
_assemble_FontWindow(module_p, FontWindow_debug_p)
gb, fw
module_p
gb = 12
fw = 11
gb = 12
fw = 12
(pass%
2) = 0
N1
_FontWindow_Constants(
aadr(P%), L%)
module_p
P:
_FontWindow_Module_Constants(
aadr(P%), L%)
Q
module_p
T>
_assemble_FontWindow_Module :
first
_assemble_FontWindow_Miscellaneous :
before others
_assemble_FontWindow_Initialise
_assemble_FontWindow_CreateWindow
_assemble_FontWindow_Update
_assemble_FontWindow_ModeChange
_assemble_FontWindow_DeleteWindow
_assemble_FontWindow_CloseDown
***************************************************************************
_FontWindow_Constants(code%, L%)
O%, P%, pass%
pass% = %1110
O%=code%:P%=0:[OPT pass%
g*; Used to store each registered window
iD.Win_Next EQUD 0 ; pointer to next in linked list
j@.Win_ExternalHandle EQUD 0 ; clients' handle for window
kf.Win_NIcons EQUD 0 ; number of anti-aliased font icons (> 0), follows after structure
lf.Win_NHandles EQUD 0 ; number of different font handles used (> 0), follows after icons
m?.Win_Size EQUD 0 ; size of window definition
.sizeof_Win
o* ; anti-aliased icons in format
p1 ; +0 uid of font in icon (word)
qE ; +4 icon number [-1 indicates window title] (word)
; handles stored as
s8 ; +0.B global uid [index] of this font
t8 ; +1.B font handle as stored in window
O%=code%:P%=0:[OPT pass%
x#; Used to store each font found
z7.Fnt_XSize EQUD 0 ; \ in pts * 16
{7.Fnt_YSize EQUD 0 ; -> in pts * 16
|D.Fnt_Next EQUD 0 ; pointer to next in linked list
}R.Fnt_Name
r(41) ; CR-terminated string [extra byte for safety!]
~0.Fnt_IndexB EQUB 0 ; global uid
F.Fnt_HandleB EQUB 0 ; handle used when loaded template
O.Fnt_CurHandleB EQUB 0 ; font handle for current screen resolution
.sizeof_Fnt
O%=code%:P%=0:[OPT pass%
; Used for each client
M.FW_Next EQUD 0 ; pointer to next in linked list of these
G.FW_MallocRoutine EQUD 0 ; \ pointer to xmalloc() routine
D.FW_FreeRoutine EQUD 0 ; \ pointer to free() routine
I.FW_GetHandleRoutine EQUD 0 ; \ pointer to gethandle() routine
H.FW_RecreateRoutine EQUD 0 ; ---> pointer to recreate() routine
?.FW_TaskHandle EQUD 0 ; applications' task handle
G.FW_Windows EQUD 0 ; pointer to linked list of Win_...
I.FW_Fonts EQUD 0 ; pointer to a linked list of Fnt_...
=.FW_ClientsR12 EQUD 0 ; used when call routines
'.FW_CurrentXDPI EQUD 0 ; \
K.FW_CurrentYDPI EQUD 0 ; -> screen resolution in dots per inch
M.FW_FontTable EQUD 0 ; pointer to 256-byte template font table
R ; [usually points to just past this structure]
ALIGN :
essential
.sizeof_FW
***************************************************************************
_assemble_FontWindow_Initialise
[OPT pass%
R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
?; This call initialises the FontWindow package for a client
; In R0 = task handle
1; R1 = pointer to xmalloc(uint) routine
1; R2 = pointer to free(pointer) routine
=; R3 = pointer to gethandle(handle, buffer) routine
<; R4 = pointer to recreate(handle, buffer) routine
; R5 = routines' R12
N; R6 = pointer to 256-byte font table to use while loading templates
6; [zero => it lies at end of structure]
N; Out R0 = pointer to 256-byte font table to use while loading templates
.xfontwindow_initialise
STMFD (sp)!, {lr}
, STR R0, [fw, #FW_TaskHandle]
, STR R5, [fw, #FW_ClientsR12]
MOVS lr, R6
& ADDeq lr, fw, #sizeof_FW
+ STR lr, [fw, #FW_FontTable]
MOV lr, #0
K STR lr, [fw, #FW_Windows] ; No windows registered
I STR lr, [fw, #FW_Fonts] ; No fonts registered
TEQ R1, #0
*
adrf("eq", 1, default_malloc)
TEQ R2, #0
(
adrf("eq", 2, default_free)
CMP R3, #1
/
adrf("eq", 3, default_gethandle_1)
-
adrf("lo", 3, default_gethandle)
CMP R4, #1
MOVhi lr, R4
/
adrf("eq", lr, default_recreate_1)
-
adrf("lo", lr, default_recreate)
- ADD R0, fw, #FW_MallocRoutine
D STMIA R0, {R1-R3, lr} ; Store routines
> BL xfontwindow_getcurrez ; In R0/R1
+ ADDvc R2, fw, #FW_CurrentXDPI
O STMvcIA R2, {R0-R1} ; Current screen resolution
+ LDRvc R0, [fw, #FW_FontTable]
LDMFD (sp)!, {lr}
" BICvcS pc, lr, #PSR_V
!
RS pc, lr, #PSR_V
***************************************************************************
_assemble_FontWindow_CreateWindow
b, f, flags, handles, handles, i, icon, icons, n, nhandles, nicons, o, one, t, win
loop
[OPT pass%
R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q; Register a window containing (maybe zero) anti-aliased font icons, and then
; create it
M; In R0 = users' handle for window (or zero to use wimp window handle)
D; R1 = pointer to window definition block (wimp_createstr)
6; Out R0 = window handle [we created the window]
3; R1 = non-zero if actually cached window
7; Window has been created [Wimp_CreateWindow]
S; This must be called with the window definition got from the template file ---
P; so that all font references are based on the same font handles. This does
T; not mean that this call has to be done while loading the template, though. Eg
T; could cache the window and then call this on all copies of the window as first
.; needed (even after a resolution change).
R; If the window did contain anti-aliased font icons then the font handles used
N; may be updated --- and so consider this call as a filter before actually
; creating the window
J; If the window has no anti-aliased icons then ok --- it is not cached
N; If the users' handle for the window is zero (0) then use the wimp window
!; handle as the window handle
.xfontwindow_createwindow
- STMFD (sp)!, {R0-R1, R4-R5, lr}
MOV R2, R1
MOV R1, #0
MOV R0, #0
c BL xfontwindow_registericons ; Count font icons only + handles (never error)
/ Bvs err_fontwindow_createwindow
MOVS R4, R0
c Beq ok_fontwindow_createwindow ; No anti-aliased icons in window (R1 = 0 also)
X MOV R5, R1 ; # different handles used in window
# MOV R0, #sizeof_Win
H ADD R0, R0, R4, LSL #3 ; two words per icon
J ADD R0, R0, R5, LSL #1 ; two bytes per handle
% BLvc fontwindow_malloc
/ Bvs err_fontwindow_createwindow
LDMFD sp, {R1-R2}
1 STR R1, [R0, #Win_ExternalHandle]
) STR R4, [R0, #Win_NIcons]
+ STR R5, [R0, #Win_NHandles]
' LDR R1, [R2, #w_nicons]
MOV lr, #w_icons
J ADD lr, lr, R1, LSL #i_shift ; Total size of window
' STR lr, [R0, #Win_Size]
MOV R5, R0
' ADD R0, R5, #sizeof_Win
U ADD R1, R0, R4, LSL #3 ; Implicit start of handle buffer
W BL xfontwindow_registericons ; Note which icons are anti-aliased
LDRvc R1, [sp, #4]
( SWIvc "XWimp_CreateWindow"
0 Bvs err2_fontwindow_createwindow
1 LDR R1, [R5, #Win_ExternalHandle]
TEQ R1, #0
T STReq R0, [R5, #Win_ExternalHandle] ; External handle IS wimp handle
) LDR R1, [fw, #FW_Windows]
' STR R1, [R5, #Win_Next]
I STR R5, [fw, #FW_Windows] ; Head of linked list
K MOV R1, #1 ; Signify cached window
- LDMFD (sp)!, {R2-R3, R4-R5, lr}
" BICS pc, lr, #PSR_V
!.err2_fontwindow_createwindow
MOV R4, R0
MOV R0, R5
D BL fontwindow_free ; Release memory
MOV R0, R4
.err_fontwindow_createwindow
- LDMFD (sp)!, {R1-R2, R4-R5, lr}
!
RS pc, lr, #PSR_V
.ok_fontwindow_createwindow
LDR R1, [sp, #4]
( SWI "XWimp_CreateWindow"
/ Bvs err_fontwindow_createwindow
- LDMFD (sp)!, {R1-R2, R4-R5, lr}
" BICS pc, lr, #PSR_V
!Q; ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
#S; This scans all icons (including window title) to see if they are anti-aliased
$P; If buffer pointers are zero then just count 'em otherwise store details in
; these buffers
&=; In R0 = pointer to buffer to store icons in, or zero
'D; R1 = pointer to buffer to store font handles in, or zero
(3; R2 = pointer to window definition block
) ; Out R0 = number of icons
*,; R1 = number of different handles
,Q; When come across a new font handle we cache its' info in a global array and
; assign it a global index
0H icons = 4 :
pointer to output buffer, or zero
1H handles = 5 :
pointer to output buffer, or zero
2C win = 6 :
pointer to window definition
37 nicons = 7 :
for loop counter
4C icon = 8 :
icon number {-1, 0, ...} > b
5I flags = 9 :
pointer to icon flags word [>= R9]
6] handle = 10 :
8-bit font handle [handle > icon >= R4] [handle >= R9]
71 b = 0 :
<R4 < icon
8/ o = 1 :
<R4 !=R0
94 t = 2 :
<R4 !=R0 !=R1
:* f = 3 :
;/ nhandles = 1 :
implicit
<= i = lr :
temporary loop counter
[OPT pass%
.xfontwindow_registericons
?' STMFD (sp)!, {R4-R10, lr}
@& SUB sp, sp, #256/8 + 4
AC MOV icons, R0 ; Safe register
BC MOV handles, R1 ; Safe register
CC MOV win, R2 ; Safe register
DX MOV t, #0 ; Number of anti-aliased icons found
E# STR t, [sp, #256/8]
MOV i, #256/8
GS.loop SUBS i, i, #4 ; Zero "handles used" bit array
STRhs t, [sp, i]
Bhi loop
J- ADD flags, win, #w_titleflags
KB MVN icon, #
(-1) ; Title bar icon
LB BL _fontwindow_registericon ; Process icon
M, LDR nicons, [win, #w_nicons]
N& ADD win, win, #w_icons
OO.loop ADD icon, icon, #1 ; Start from icon 0, 1, ...
P CMP icon, nicons
Q( ADDlt flags, win, #i_flags
RB BLlt _fontwindow_registericon ; Process icon
S% ADDlt win, win, #i_size
Blt loop
;
V. ; Now count number of handles used
;
X MOV nhandles, #0
Y! MOV i, #256/8 - 4
.loop LDR t, [sp, i]
[ .lp MOVS t, t, LSR #1
\* ADDcs nhandles, nhandles, #1
Bne lp
SUBS i, i, #4
Bhs loop
`P LDR R0, [sp, #256/8] ; Return value, #icons found
a& ADD sp, sp, #256/8 + 4
b' LDMFD (sp)!, {R4-R10, pc}
cQ; ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
e.; In flags = pointer to icon flags word
; icon = icon number
gI; icons = pointer to icon buffer [non-zero if handles non-zero]
h7; handles = pointer to handle buffer, or zero
iI; sp+256/8 = count of number of anti-aliased icons found so far
j&; sp points to 256-bit array
; Out if flags then
; [sp+256/8]++
; [handles]++
; [icons]++
o!; bit array updated
p%; Bad o, t, b, f, handle, R0-R3
._fontwindow_registericon
s' LDR handle, [flags], #0
t) TST handle, #if_fancyfont
uN MOVeqS pc, lr ; Ignore, not anti-aliased
vP MOV handle, handle, LSR #ifb_fontno ; handle = 8-bit font handle
w# LDR t, [sp, #256/8]
xM ADD t, t, #1 ; Success - one more icon
y# STR t, [sp, #256/8]
t, handle, #7
MOV o, #1
|I MOV t, o, LSL t ; bit in byte to test
}+ LDRB o, [sp, handle, LSR #3]
~H
R b, o, t ; Flag handle as used
+ STRB b, [sp, handle, LSR #3]
TEQ handles, #0
K MOVeqS pc, lr ; Just counting, return
J LDR f, [fw, #FW_Fonts] ; Map handles to index
.loop TEQ f, #0
T Beq new_font_fontwindow_registericon; not cached font - go and do it
Y LDRB b, [f, #Fnt_HandleB] ; original, maybe not current/correct
TEQ b, handle
% LDRne f, [f, #Fnt_Next]
Bne loop
+.hook LDRB b, [f, #Fnt_CurHandleB]
J TEQ b, handle ; Has handle changed ?
9 MOVne handle, b ; Yes
[ STRneB handle, [flags, #3] ; Write new font handle into icon flags
' LDRB b, [f, #Fnt_IndexB]
G STMIA (icons)!, {b, icon} ; Store index, icon
l TST o, t ; See if already cached handle (.eq. if not done so yet)
M STReqB b, [handles], #1 ; Index of font refers to
U STReqB handle, [handles], #1 ; Current handle stored in window
MOVS pc, lr
D; here when first time come across an icon with this font handle
#; we cache the font information
%.new_font_fontwindow_registericon
, STMFD (sp)!, {o, t, R4-R8, lr}
# MOV R0, #sizeof_Fnt
% BL fontwindow_malloc
/ Bvs err_fontwindow_registericon
C MOV R8, R0 ; Safe register
\ STRB handle, [R8, #Fnt_CurHandleB] ; Store handle (as currently open'ed at)
L STRB handle, [R8, #Fnt_HandleB] ; Store base font handle
MOV R0, handle
% ADD R1, R8, #Fnt_Name
> SWI "XFont_ReadDefn" ; To R1-R7
0 Bvs err2_fontwindow_registericon
& ADD lr, R8, #Fnt_XSize
E STMIA lr, {R2-R3} ; Store font size
+ ADD R6, fw, #FW_CurrentXDPI
^ LDMIA R6, {R6-R7} ; See if resolution different from current
TEQ R4, R6
TEQeq R5, R7
^ BLne xfontwindow_reopenfont ; Yes, re-open font for current resolution
0 Bvs err2_fontwindow_registericon
I STRneB R0, [R8, #Fnt_CurHandleB] ; Note current handle
MOV f, R8
& LDR t, [fw, #FW_Fonts]
% STR t, [f, #Fnt_Next]
TEQ t, #0
' LDRneB t, [t, #Fnt_IndexB]
W ADDne t, t, #1 ; New unique index (starts at zero)
' STRB t, [f, #Fnt_IndexB]
N STR f, [fw, #FW_Fonts] ; Make head of linked list
, LDMFD (sp)!, {o, t, R4-R8, lr}
B hook
!.err2_fontwindow_registericon
MOV R4, R0
D BL fontwindow_free ; Release memory
MOV R0, R4
.err_fontwindow_registericon
, LDMFD (sp)!, {o, t, R4-R8, lr}
!.err_fontwindow_registericons
$ ADD sp, sp, #256/8+4
' LDMFD (sp)!, {R4-R10, lr}
!
RS pc, lr, #PSR_V
***************************************************************************
_assemble_FontWindow_Update
buf, curhandle, font, icon, index, nhandles, nicons, rove, storedhandle, w
loop, lp
w = 4
rove = 5
nhandles = 6
buf = 7
index = 8
curhandle = 9
nicons = nhandles
storedhandle = 0
font = 1
3 icon = buf :
icon
[OPT pass%
R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
R; This checks that a windows' icons contain valid font handles for the current
; screen resolution
); In R0 = users' handle for window
; Out -
.; [R0 = pointer to Win_...structure]
O; If windows' anti-aliased font icons refer to a font opened to a different
N; screen resolution than the current then we update all the windows' icons
@; If title icon is anti-aliased then need to recreate window
.xfontwindow_update
& STMFD (sp)!, {R4-R9, lr}
& BL xfontwindow_locate
* Bvs exit_fontwindow_update
MOV w, R0
0 LDR nhandles, [w, #Win_NHandles]
* LDR rove, [w, #Win_NIcons]
H ADD rove, w, rove, LSL #3 ; two words per icon
S ADD rove, rove, #sizeof_Win ; Point to "used handle"s array
J.loop LDRB index, [rove], #1 ; Global index of font
) LDR font, [fw, #FW_Fonts]
A.lp LDRB lr, [font, #Fnt_IndexB] ; Locate font
TEQ index, lr
+ LDRne font, [font, #Fnt_Next]
Bne lp
, LDRB storedhandle, [rove], #1
6 LDRB curhandle, [font, #Fnt_CurHandleB]
] CMP storedhandle, curhandle ; See if handle has changed [clear PSR_V]
P BLne _xfontwindow_update_icons ; Yes - massage window icons
* Bvs exit_fontwindow_update
* SUBS nhandles, nhandles, #1
Bgt loop
.exit_fontwindow_update
N MOVvc R0, w ; [used by OpenWindow swi]
& LDMFD (sp)!, {R4-R9, lr}
" BICvcS pc, lr, #PSR_V
!
RS pc, lr, #PSR_V
=; Process all (at least 1) icon with this new font handle
._xfontwindow_update_icons
- STMFD (sp)!, {rove, nicons, lr}
> STRB curhandle, [rove, #-1] ; Update !
, LDR nicons, [w, #Win_NIcons]
@ ADD rove, w, #sizeof_Win ; Icon array
).loop LDMIA (rove)!, {font, icon}
C CMP font, index ; [clear PSR_V]
, BLeq _xfontwindow_update_icon
- LDMvsFD (sp)!, {rove, nicons, pc}
& SUBS nicons, nicons, #1
Bgt loop
- LDMFD (sp)!, {rove, nicons, pc}
._xfontwindow_update_icon
STMFD (sp)!, {lr}
O CMP icon, #0 ; -1 => title bar (awkward)
4 Blt titlebar__fontwindow_update_icon
0 LDR R0, [w, #Win_ExternalHandle]
( BL fontwindow_gethandle
MOV R1, icon
2 MOV R2, curhandle, LSL #ifb_fontno
* MOV R3, #&FF << ifb_fontno
" STMFD (sp)!, {R0-R3}
MOV R1, sp
( SWI "XWimp_SetIconState"
ADD sp, sp, #16
!.exit__fontwindow_update_icon
LDMFD (sp)!, {pc}
%.titlebar__fontwindow_update_icon
& LDR R0, [w, #Win_Size]
Z ADD R0, R0, #4 ; (extra word so can get window state)
R BL fontwindow_malloc ; Buffer for window definition
0 Bvs exit__fontwindow_update_icon
MOV buf, R0
0 LDR R0, [w, #Win_ExternalHandle]
!( BL fontwindow_gethandle
MOV R1, buf
# STR R0, [R1, #0]
$K SWI "XWimp_GetWindowInfo" ; Read full window info
ADDvc R1, buf, #4
&T LDRvc R0, [R1, #w_titleflags] ; Manually change title bar icon
'. BICvc R0, R0, #&FF << ifb_fontno
(5
Rvc R0, R0, curhandle, LSL #ifb_fontno
)+ STRvc R0, [R1, #w_titleflags]
*0 LDRvc R0, [w, #Win_ExternalHandle]
MOVvc R1, buf
,J BLvc fontwindow_recreate ; Delete/create window
-/ Bvs err__fontwindow_update_icon
.) LDR lr, [buf, #w_flags+4]
/ TST lr, #ws_open
0( BLne fontwindow_gethandle
MOVne R1, buf
2D SWIne "XWimp_OpenWindow" ; Re-open window
MOVvc R0, buf
4# BLvc fontwindow_free
50 Bvc exit__fontwindow_update_icon
6 .err__fontwindow_update_icon
STMFD (sp)!, {R0}
MOV R0, buf
9# BL fontwindow_free
LDMFD (sp)!, {R0}
;0 B exit__fontwindow_update_icon
***************************************************************************
_assemble_FontWindow_ModeChange
loop, lp
C' handle = 0 :
implicit
count = 1
font = 4
w = font
[OPT pass%
HR; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
JO; This should be called when application receives a Message_ModeChange from
; the wimp
; In -
; Out -
PM; If screen resolution has changed then all the old fonts are closed, and
QR; immediately re-opened at the new screen resolution (not closed necessarily!)
SN; If any of the clients' windows are open then they are changed to reflect
T(; the new font handles automatically
.xfontwindow_modechange
W# STMFD (sp)!, {R4, lr}
X) BL xfontwindow_getcurrez
Y- Bvs err_fontwindow_modechange
Z+ ADD lr, fw, #FW_CurrentXDPI
LDMIA lr, {R2-R3}
TEQ R0, R2
TEQeq R1, R3
^M Beq exit_fontwindow_modechange ; Not a resolution change
_I STMIA lr, {R0-R1} ; Note new resolution
`) LDR font, [fw, #FW_Fonts]
.loop TEQ font, #0
b0 Beq update_fontwindow_modechange
c3 LDRB handle, [font, #Fnt_CurHandleB]
d' ADD R1, font, #Fnt_Name
e( ADD lr, font, #Fnt_XSize
fO LDMIA lr, {R2-R3} ; Physical size (in points)
g* BL xfontwindow_reopenfont
h3 STRvcB handle, [font, #Fnt_CurHandleB]
i+ LDRvc font, [font, #Fnt_Next]
Bvc loop
.err_fontwindow_modechange
l# LDMFD (sp)!, {R4, lr}
m!
RS pc, lr, #PSR_V
o!.update_fontwindow_modechange
;
q? ; Here re-opened all (used) fonts to new resolution
rB ; Now see if any windows were open [and so update NOW]
;
t( LDR w, [fw, #FW_Windows]
.loop TEQ w, #0
v. Beq exit_fontwindow_modechange
w0 LDR R0, [w, #Win_ExternalHandle]
x( BL fontwindow_gethandle
y* SUB sp, sp, #u_windowstate
MOV R1, sp
{' STR R0, [R1, #u_handle]
|* SWI "XWimp_GetWindowState"
}' LDRvc R0, [R1, #u_wflags]
~* ADD sp, sp, #u_windowstate
- Bvs err_fontwindow_modechange
TST R0, #ws_open
0 LDRne R0, [w, #Win_ExternalHandle]
Q BLne xfontwindow_update ; Alter icons only if visible
- Bvs err_fontwindow_modechange
% LDR w, [w, #Win_Next]
B loop
.exit_fontwindow_modechange
# LDMFD (sp)!, {R4, lr}
" BICS pc, lr, #PSR_V
***************************************************************************
_assemble_FontWindow_DeleteWindow
[OPT pass%
R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I; This removes a previously registered window from the list, and then
; optionally delete's it
); In R0 = users' handle for window
3; R1 = non-zero if actually delete window
; Out -
#; Window has been deleted
.xfontwindow_deletewindow
' STMFD (sp)!, {R1, R4, lr}
& BL xfontwindow_locate
/ Bvs err_fontwindow_deletewindow
' LDR R2, [R0, #Win_Next]
M STR R2, [R1], #0 ; Remove from linked list
LDR R1, [sp, #0]
TEQ R1, #0
MOVne R4, R0
1 LDRne R0, [R4, #Win_ExternalHandle]
( BLne fontwindow_gethandle
STRne R0, [sp, #0]
MOVne R0, R4
D BL fontwindow_free ; Release memory
MOVne R1, sp
( SWIne "XWimp_DeleteWindow"
.err_fontwindow_deletewindow
' LDMFD (sp)!, {R1, R4, lr}
" BICvcS pc, lr, #PSR_V
!
RS pc, lr, #PSR_V
***************************************************************************
_assemble_FontWindow_CloseDown
[OPT pass%
R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
M; This removes all registered windows and optionally closes all the fonts
H; In R0 = non-zero if wish to close all open fonts [usually true]
G; R1 = non-zero if wish to delete all windows [usually false]
; Out -
2; Note Error only possible from closing fonts
.xfontwindow_closedown
+ STMFD (sp)!, {R0, R1, R4, lr}
).loop LDR R0, [fw, #FW_Windows]
CMP R0, #0
1 LDRne R0, [R0, #Win_ExternalHandle]
LDRne R1, [sp, #4]
F BLne xfontwindow_deletewindow ; (ignore error)
Bne loop
' LDR R4, [fw, #FW_Fonts]
.loop ADDS R0, R4, #0
' LDRne R4, [R4, #Fnt_Next]
D BLne fontwindow_free ; Release memory
Bne loop
H STR R4, [fw, #FW_Fonts] ; Zero head [safety]
# LDMFD (sp)!, {R0, R1}
TEQ R0, #0
- Beq exit_fontwindow_closedown
+ LDR R4, [fw, #FW_FontTable]
A MOV R0, #256 - 1 ; Font handle
A.loop LDRB R1, [R4, R0] ; Usage count
.lp SUBS R1, R1, #1
$ SWIhs "XFont_LoseFont"
, Bvs err_fontwindow_closedown
Bhi lp
F STReqB R1, [R4, R0] ; Zero usage count
SUBS R0, R0, #1
Bhs loop
.exit_fontwindow_closedown
# LDMFD (sp)!, {R4, lr}
" BICS pc, lr, #PSR_V
.err_fontwindow_closedown
# LDMFD (sp)!, {R4, lr}
!
RS pc, lr, #PSR_V
***************************************************************************
_assemble_FontWindow_Miscellaneous
[OPT pass%
Error(err_ukwindow, ErrorUKWindow, ErrorUKWindow$)
R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; In -
;; Out R0 = screen x pixel resolution in dots per inch
;; R1 = screen y pixel resolution in dots per inch
; Bad R2_R3
"; PSR_V set, R0 on error
; PSR_NZC corrupted
.xfontwindow_getcurrez
STMFD (sp)!, {lr}
MVN R0, #
* MOV R1, #VduExt_XEigFactor
* SWI "XOS_ReadModeVariable"
MOVvc R3, R2
* MOVvc R1, #VduExt_YEigFactor
* SWIvc "XOS_ReadModeVariable"
\ MOVvc R0, #180 ; Nominal 180 dots per inch (OS defined)
" MOVvc R1, R0, LSR R2
" MOVvc R0, R0, LSR R3
LDMFD (sp)!, {pc}
R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C; Given a pointer to window handle, locate FontWindow structure
); In R0 = users' handle for window
C; Out R0 = pointer to Win_... structure, or zero if not found
); R1 = pointer to pointer to R0
"; PSR_V set, R0 on error
; PSR_ZNC preserved
.xfontwindow_locate
MOV R2, R0
' ADD R1, fw, #FW_Windows
.loop LDR R0, [R1], #0
TEQ R0, #0
1 LDRne R3, [R0, #Win_ExternalHandle]
TEQne R3, R2
% ADDne R1, R0, #Win_Next
Bne loop
TEQ R0, #0
L TEQne R2, #0 ; Window handle 0 => bad
; BICneS pc, lr, #PSR_V ; Found
&
adrf("", 0, err_ukwindow)
!
RS pc, lr, #PSR_V
R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0; Close a font and re-open to new resolution
; In R0 = font handle
G; R1 = pointer to font name [font size in two preceding word]
-; R2 = width of font in points * 16
.; R3 = height of font in points * 16
; Out R0 = new font handle
"; PSR_V set, R0 on error
; PSR_NZC preserved
"A; Need to keep open at
AL size because otherwise wimp barfs
#2; badly on writable icons and invisible others
$G; To save hassle, just ensure font open at least once, but close if
; open more than once
.xfontwindow_reopenfont
(& STMFD (sp)!, {R4-R6, lr}
)+ LDR R6, [fw, #FW_FontTable]
*D LDRB lr, [R6, R0] ; Count of usage
+C CMP lr, #1 ; keep one open
SUBgt lr, lr, #1
- STRgtB lr, [R6, R0]
.$ SWIgt "XFont_LoseFont"
/+ ADDvc R4, fw, #FW_CurrentXDPI
LDMvcIA R4, {R4-R5}
1U SWIvc "XFont_FindFont" ; Open font to current resolution
2 LDRvcB lr, [R6, R0]
ADDvc lr, lr, #1
4P STRvcB lr, [R6, R0] ; Flag font opened once more
5& LDMFD (sp)!, {R4-R6, lr}
6" BICvcS pc, lr, #PSR_V
7!
RS pc, lr, #PSR_V
8R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9D; These are simple routines that indirect to the actual routines
.fontwindow_malloc
<( STMFD (sp)!, {R10-R12, lr}
=/ LDR lr, [fw, #FW_MallocRoutine]
.hook STMFD (sp)!, {lr}
?- LDR R12, [fw, #FW_ClientsR12]
MOV lr, pc
LDMFD (sp)!, {pc}
B( LDMFD (sp)!, {R10-R12, pc}
.fontwindow_free
D( STMFD (sp)!, {R10-R12, lr}
E- LDR lr, [fw, #FW_FreeRoutine]
B hook
.fontwindow_gethandle
H( STMFD (sp)!, {R10-R12, lr}
I2 LDR lr, [fw, #FW_GetHandleRoutine]
B hook
.fontwindow_recreate
L( STMFD (sp)!, {R10-R12, lr}
M1 LDR lr, [fw, #FW_RecreateRoutine]
B hook
OR; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Q>; In R0 = unsigned 32-bit amount of memory to claim > 0
R@; Out R0 = pointer to word-aligned memory of required size
; Bad R1-R3
T"; PSR_V set, R0 on error
; PSR_NZC preserved
.default_malloc
MOV R1, lr
MOV R3, R0
Y, MOV R0, #ModHandReason_Claim
Z SWI "XOS_Module"
MOVvc R0, R2
\" BICvcS pc, R1, #PSR_V
]!
RS pc, R1, #PSR_V
^R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`L; In R0 = pointer to previouly allocated word-aligned memory, or zero
; Out -
; Bad R0-R3
; PSR_NZCV preserved
.default_free
MOV R1, lr
MOVS R2, R0
g+ MOVne R0, #ModHandReason_Free
h SWIne "XOS_Module"
MOVS pc, R1
jR; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
l); In R0 = users' handle for window
; Out R0 = window handle
; Bad R1-R3
; PSR_NZCV preserved
q?; <users' handle is a pointer to actual wimp window handle>
.default_gethandle_1
t LDR R0, [R0], #0
MOVS pc, lr
w6; <users' handle is the actual wimp window handle>
.default_gethandle
MOVS pc, lr
{R; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}P; We wish to change the flags of the title icon. To this end the caller has
~E; done a Wimp_GetWindowInfo and massaged the title bar icon flags
O; This routine must now delete the window and then re-create it immediately
2; (the only way to update the title bar icon!)
; Note the return condition
); In R0 = users' handle for window
<; R1 = pointer to buffer containing wimp_createstr
@; Out R1 points to a wimp_openstr block for the new window
; Bad R0-R3
"; PSR_V set, R0 on error
; PSR_NZC preserved
?; <users' handle is a pointer to actual wimp window handle>
.default_recreate_1
MOV R3, R0
MOV R2, lr
( SWI "XWimp_DeleteWindow"
ADDvc R1, R1, #4
( SWIvc "XWimp_CreateWindow"
I STRvc R0, [R3], #0 ; Store window handle
SUBvc R1, R1, #4
T STRvc R0, [R1, #u_handle] ; R1 block is now a wimp_openstr
" BICvcS pc, R2, #PSR_V
!
RS pc, R2, #PSR_V
6; <users' handle is the actual wimp window handle>
M; This operation is not possible - do nothing (exit conditions fulfilled)
.default_recreate
" BICS pc, lr, #PSR_V
***************************************************************************
_FontWindow_Module_Constants(code%, L%)
O%, P%, pass%
pass% = %1110
U sizeof_Stack = 8*4 :
really small stack, all that's needed by app.
6 SWIChunk = &DBCC0 :
user swi chunk
< ErrorBadSWI$ = "Unknown FontWindow operation"
A ErrorBadVersion$ = "Bad version number for FontWindow"
C ErrorFlagsNotZero$ = "FontWindow: reserved flags not zero"
> ErrorModActive$ = "FontWindow is currently active"
7 ErrorUKClient$ = "Unknown FontWindow task"
9 ErrorUKWindow$ = "Unknown FontWindow window"
P ErrorNoWimp$ = "FontWindow: Window manager too old / not present"
" ErrorBadSWI = &110
$ O%=code%:P%=SWIChunk:[OPTpass%
" .ErrorUKClient EQUB 0
" .ErrorUKWindow EQUB 0
" .ErrorBadVersion EQUB 0
" .ErrorFlagsNotZero EQUB 0
" .ErrorModActive EQUB 0
" .ErrorNoWimp EQUB 0
ModHelp$ = "-The FontWindow module manages anti-aliased font icons in windows across screen resolution changes." :
help for *Dekstop_FontWindow
AppHelp$ = ":Start a wimp module task that detects programs dieing and closes fonts/releases memory --- a debugging aid during program development."
Desktop_Code = 0
O%=code%:P%=0:[OPT pass%
_FontWindow_globals
.sizeof_G
_FontWindow_globals
[OPT pass%
=.G_PrivateWord EQUD 0 ; pointer to private word
O.G_Clients EQUD 0 ; pointer to linked list of FW_..., or zero
FontWindow_debug_p
[OPT pass%
6.G_TaskHandle EQUD 0 ; wimp task handle
4.G_Poll
r(256); wimp poll block
6
r(sizeof_Stack); application stack
.G_Stack
***************************************************************************
_assemble_FontWindow_Module
(pass%
%0100)=0
1, "Must be offset assembly"
1, "Module not at zero offset"
[OPT pass%
% EQUD Module_Start_Code
/ EQUD Module_Initialisation_Code
, EQUD Module_Finalisation_Code
/ EQUD Module_Service_Call_Handler
' EQUD Module_Title_String
& EQUD Module_Help_String
9 EQUD Module_Help_And_Command_Keyword_Table
EQUD SWIChunk
" EQUD SWIHandlerCode
" EQUD SWIDecodeTable
.Module_Title_String
! EQUS "FontWindow"+
.Module_Help_String
C EQUS "FontWindow"+
(9)+ "1.00 ("+
$, 5, 11)+ ")"+
,.SWIDecodeTable EQUS "FontWindow"+
, EQUS "Initialise"+
+ EQUS "CloseDown"+
, EQUS "ModeChange"+
. EQUS "CreateWindow"+
. EQUS "DeleteWindow"+
, EQUS "OpenWindow"+
. EQUS "UpdateWindow"+
EQUB &00
*.Module_Help_And_Command_Keyword_Table
"
_Module_Command_Start
G
_Module_Command( "FontWindow", 0, &00000000, "", ModHelp$)
FontWindow_debug_p
X
_Module_Command( "Desktop_FontWindow", Desktop_Code, &00000000, "", AppHelp$)
[OPT pass%
_Module_Command_End
Error(err_badswi, ErrorBadSWI, ErrorBadSWI$)
Error(err_ukclient, ErrorUKClient, ErrorUKClient$)
Error(err_modactive, ErrorModActive, ErrorModActive$)
Error(err_flagsnotzero, ErrorFlagsNotZero, ErrorFlagsNotZero$)
Error(err_badversion, ErrorBadVersion, ErrorBadVersion$)
I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ALIGN
.SWIHandlerCode
! LDR gb, [R12], #0
Q BIC lr, lr, #PSR_V ; Faster successful returning
\ TEQP pc, #3 ; Ensure in SVC mode, interrupts enabled
CMP R11, #7
' ADDlo pc, pc, R11, LSL #2
% B FontWindow_BadSWI
, B FontWindow_InitialiseSWI
+ B FontWindow_CloseDownSWI
, B FontWindow_ModeChangeSWI
. B FontWindow_CreateWindowSWI
. B FontWindow_DeleteWindowSWI
, B FontWindow_OpenWindowSWI
. B FontWindow_UpdateWindowSWI
.FontWindow_BadSWI
" ADR R0, err_badswi
!
RS pc, lr, #PSR_V
I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; uses no stack
%; exit R2 = pointer to workspace
.Module_Initialisation_Code
! LDR R2, [R12], #0
TEQ R2, #0
" BICneS pc, lr, #PSR_V
MOV R1, lr
!
mov("", 3, sizeof_G)
, MOV R0, #ModHandReason_Claim
[ SWI "XOS_Module" ; Get workspace memory (generate error)
MOVvs pc, R1
F STR R2, [R12], #0 ; Set private word
MOV R0, #0
.loop SUBS R3, R3, #4
#c STRhs R0, [R2, R3] ; Zero private workspace (initialise variables)
Bhi loop
%E STR R12, [R2, #G_PrivateWord] ; Store for later
&" BICS pc, R1, #PSR_V
'I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.Module_Finalisation_Code
*! LDR gb, [R12], #0
CMP gb, #0
," BICleS pc, lr, #PSR_V
-' STMFD (sp)!, {R7-R11, lr}
.( LDR R0, [gb, #G_Clients]
TEQ R0, #0
0)
adrf("ne", 0, err_modactive)
1" CMPne pc, #&80000000
2C BLvc close_application ; Quit at once!
MOVvc R2, gb
4B LDRvc R12, [gb, #G_PrivateWord] ; Return value
MOVvc lr, #0
6H STRvc lr, [R12], #0 ; Clear private word
7+ MOVvc R0, #ModHandReason_Free
8G SWIvc "XOS_Module" ; Release workspace
9K LDMFD (sp)!, {R7-R11, pc} ; Propogate maybe error
:I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
< .Module_Service_Call_Handler
=& TEQ R1, #Service_Reset
>! Beq service_Reset
MOV pc, lr
A5; Here the user has just pressed the reset button
BH; If application was running then need to release all of its' memory
C.; Also clear any error flags (privateword)
.service_Reset
F& STMFD (sp)!, {R0-R3, lr}
G! LDR gb, [R12], #0
TEQ gb, #0
I< LDMeqFD (sp)!, {R0-R3, pc} ; Never!
FontWindow_debug_p
[OPT pass%
MOV R0, #0
N[ STR R0, [gb, #G_TaskHandle] ; Make sure don't try closing task down
[OPT pass%
RO BL close_application ; Release extra memory used
SO BL shutdown_all_clients ; [no-one survives a reset]
T' LDMFD (sp)!, {R0-R3, pc}^
UV\- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
W%; In gb = pointer to workspace
X5; Out all currently active clients are shutdown
Y$; All errors are suppresed
.shutdown_all_clients
STMFD (sp)!, {lr}
](.loop LDR fw, [gb, #G_Clients]
TEQ fw, #0
_ LDMeqFD (sp)!, {pc}^
`G MOV R0, #0 ; Don't close fonts
aJ MOV R1, #0 ; Don't delete windows
bG BL xfontwindow_shutdown ; Completely zap it
B loop
dV\- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
f5; This is called when WE wish to shut a task down
gR; If tasks' free() routine was not the default routine then replace with dummy
h1; code (the old address may not be valid now)
j"; In fw = pointer to client
k1; R0 = non-zero if close all open fonts
l+; R1 = non-zero if delete windows
; Out -
.xfontwindow_shutdown
p- LDR R3, [fw, #FW_FreeRoutine]
q&
adrl("", 2, default_free)
TEQ R3, R2
sH ADRne R3, dummy_free ; Don't use app code
t- STRne R3, [fw, #FW_FreeRoutine]
MOV R2, R1
MOV R1, R0
w, LDR R0, [fw, #FW_TaskHandle]
MOV R3, lr
y/
bootstrap("XFontWindow_CloseDown")
z" BICvcS pc, R3, #PSR_V
{!
RS pc, R3, #PSR_V
.dummy_free
MOVS pc, lr
~I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-; In R0 = task handle [0 => not found]
B; Out fw = pointer to FW_... structure, or zero if not found
"; PSR_V set, R0 if error
; PSR_NZC undefined
.xlocate_client
STMFD (sp)!, {lr}
( LDR fw, [gb, #G_Clients]
C.loop CMP fw, #0 ; [clear PSR_V]
, LDRne lr, [fw, #FW_TaskHandle]
TEQne R0, lr
& LDRne fw, [fw, #FW_Next]
Bne loop
TEQ fw, #0
S TEQne R0, #0 ; Error if task handle is zero!
LDMneFD (sp)!, {pc}
&
adrf("", 0, err_ukclient)
" CMP pc, #&80000000
LDMFD (sp)!, {pc}
I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'; In R0 = task handle (non-zero)
1; R1 = pointer to xmalloc(uint) routine
1; R2 = pointer to free(pointer) routine
=; R3 = pointer to gethandle(handle, buffer) routine
<; R4 = pointer to recreate(handle, buffer) routine
; R5 = routines' R12
]; R6 = pointer to 256-byte font table used while loading templates, pre-initialised
=; or zero to allocate one in RMA [and zero it]
N; R7 = latest version of FontWindow caller knows about * 100 + flags
N; Out R0 = pointer to 256-byte font table to use while loading templates
.FontWindow_InitialiseSWI
& STMFD (sp)!, {R0-R3, lr}
# MOVS lr, R7, LSR #16
,
adrf("ne", 0, err_flagsnotzero)
Bne err_SWI
" CMP R7, #1.0 * 100
*
adrf("lo", 0, err_badversion)
Blo err_SWI
" MOV R0, #sizeof_FW
TEQ R6, #0
E ADDeq R0, R0, #256 ; [append to end]
E BL default_malloc ; Allocate memory
Bvs err_SWI
MOV fw, R0
& ADD R0, fw, #sizeof_FW
M ADDeq R0, R0, #256 ; Zero font table as well
MOV lr, #0
P.loop STR lr, [R0, #-4]! ; Zero structure (essential)
CMP R0, fw
Bhi loop
LDMFD sp, {R0-R3}
* BL xfontwindow_initialise
( LDRvc lr, [gb, #G_Clients]
& STRvc lr, [fw, #FW_Next]
I STRvc fw, [gb, #G_Clients] ; Head of linked list
ADDvc sp, sp, #4
' LDMvcFD (sp)!, {R1-R3, pc}^
STMFD (sp)!, {R0}
MOV R0, fw
D BL default_free ; Release memory
LDMFD (sp)!, {R0}
.err_SWI
ADD sp, sp, #4
.hook_err_SWI
& LDMFD (sp)!, {R1-R3, lr}
!
RS pc, lr, #PSR_V
I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; In R0 = task handle
D; R1 = pointer to window definition block (wimp_createstr)
H; R2 = users' handle for window (or zero to use window handle)
; Out R0 window handle
@; R1 = non-zero if window contained anti-aliased fonts
7; Window has been created [Wimp_CreateWindow]
!; R1 preserved if error
.FontWindow_CreateWindowSWI
& STMFD (sp)!, {R1-R3, lr}
" BL xlocate_client
MOVvc R0, R2
, BLvc xfontwindow_createwindow
ADDvc sp, sp, #4
' LDMvcFD (sp)!, {R2-R3, pc}^
B hook_err_SWI
I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; In R0 = task handle
); R1 = users' handle for window
; Out -
.FontWindow_DeleteWindowSWI
& STMFD (sp)!, {R0-R3, lr}
" BL xlocate_client
MOVvc R0, R1
C MOVvc R1, #1 ; Delete window
, BLvc xfontwindow_deletewindow
' LDMvcFD (sp)!, {R0-R3, pc}^
b err_SWI
I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; In R0 = task handle
); R1 = users' handle for window
; Out -
.FontWindow_UpdateWindowSWI
& STMFD (sp)!, {R0-R3, lr}
" BL xlocate_client
MOVvc R0, R1
& BLvc xfontwindow_update
' LDMvcFD (sp)!, {R0-R3, pc}^
B err_SWI
I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; In R0 = task handle
L; R1 = pointer to wimp_openstr block [window handle not filled in]
); R2 = users' handle for window
; Out -
7; Window altered if necessary and then opened
.FontWindow_OpenWindowSWI
& STMFD (sp)!, {R0-R3, lr}
" BL xlocate_client
MOVvc R0, R2
& BLvc xfontwindow_update
1 LDRvc R0, [R0, #Win_ExternalHandle]
( BLvc fontwindow_gethandle
LDRvc R1, [sp, #4]
' STRvc R0, [R1, #u_handle]
= SWIvc "XWimp_OpenWindow" ; Open it
' LDMvcFD (sp)!, {R0-R3, pc}^
B err_SWI
I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; In R0 = task handle
; Out -
.FontWindow_ModeChangeSWI
& STMFD (sp)!, {R0-R3, lr}
" BL xlocate_client
* BLvc xfontwindow_modechange
' LDMvcFD (sp)!, {R0-R3, pc}^
B err_SWI
I; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; In R0 = task handle
I; R1 = non-zero if wish to close all open fonts [usually true!]
C; R2 = non-zero if wish to delete windows [usually false]
; Out -
2; Note Error only possible from closing fonts
.FontWindow_CloseDownSWI
& STMFD (sp)!, {R0-R3, lr}
" BL xlocate_client
Bvs err_SWI
MOV R0, R1
MOV R1, R2
) BL xfontwindow_closedown
! STRvs R0, [sp], #0
"L ADD R1, gb, #G_Clients ; Find pointer to client
# .loop LDR R0, [R1], #0
$F TEQ R0, fw ; [preserve PSR_V]
%$ ADDne R1, R0, #FW_Next
Bne loop
'& LDR R2, [R0, #FW_Next]
(M STR R2, [R1], #0 ; Remove from linked list
) BL default_free
*' LDMvcFD (sp)!, {R0-R3, pc}^
B err_SWI
FontWindow_debug_p
.-
_assemble_FontWindow_Module_Task
Module_Start_Code = 0
[OPT pass%
.close_application
MOVS pc, lr
*****************************************************************************
_assemble_FontWindow_Module_Task
error = &CBCBCB
[OPT pass%
Error(err_nowimp, ErrorNoWimp, ErrorNoWimp$)
>V\- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@,\ This gets called if *Desktop_...
AC\ If not already running then enter module as application
B$\ otherwise generate error
C(\ In R0 = pointer to command tail
\ in SVC mode
ALIGN
.Desktop_Code
G# STMFD (sp)!, {R0, lr}
HR LDR gb, [R12], #0 ; Get contents of private word
MOV R0, #0
J' SWI "XWimp_ReadSysInfo"
K# LDMvsFD (sp)!, {lr, pc}
CMP R0, #0
M" ADReq R0, err_nowimp
N$ Beq err_Desktop_Code
LDR R2, [sp]
P+ LDR lr, [gb, #G_TaskHandle]
TEQ lr, #0
R, MOVeq R0, #ModHandReason_Enter
S/
adrf("eq", 1, Module_Title_String)
TB SWIeq "XOS_Module" ; Enter module
U'
adrf("", 0, err_modactive)
.err_Desktop_Code
W" CMP pc, #&80000000
X# LDMFD (sp)!, {lr, pc}
YI; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Exits through OS_Exit
; Note no R13 set up!!!
.value_TASK EQUS "TASK"
.value_ABEX EQUS "ABEX"
.Module_Start_Code
;
c( ; Allocate memory for module
;
eM BL Module_Initialisation_Code ; Claim memory if need to
f& SWIvs "OS_GenerateError"
MOV gb, R2
hI
gb("", sp, G_Stack) ; Set up private stack
i+ LDR lr, [gb, #G_TaskHandle]
CMP lr, #0
k)
adrf("gt", 0, err_modactive)
l& SWIgt "OS_GenerateError"
;
; Initialise wimp
;
p@ MOV R0, #300 ; wimp value
q" LDR R1, value_TASK
r-
adrf("", 2, Module_Title_String)
s&
adrl("", 3, messages_end)
tX LDR R4, [R3], #0 ; R4 = number of messages understand
MOV R5, sp
vI.loop LDR lr, [R3, #-8]! ; lr = message number
w" STR lr, [sp, #-4]!
SUBS R4, R4, #1
Bhi loop
MOV R3, sp
{& SWI "XWimp_Initialise"
Bvs abort
CMP R0, #200
~&
adrf("lo", 0, err_nowimp)
Blo abort
MOV sp, R5
+ STR R1, [gb, #G_TaskHandle]
;
; Now loop
E ; Since no windows or icon bar icon just wait on messages
;
.poll_loop
6.loop MOV R0, #pointerchange_bits
null_bit
gb("", 1, G_Poll)
MOV R2, #0
SWI "XWimp_Poll"
! BLvc dispatch_poll
Bvc loop
MOV R1, #1
BL report_error
TEQ R1, #2
I Bne loop ; Quit from error box
.message_Quit
;
= ; Here must unconditionally exit from application
< ; (would already have handled a PreQuit message)
;
% BL close_application
" LDR R1, value_ABEX
MOV R2, #0
SWI "OS_Exit"
.dispatch_poll
STMFD (sp)!, {lr}
% TEQ R0, #User_Message
. TEQne R0, #User_Message_Recorded
' Beq _xpoll_User_Message
LDMFD (sp)!, {pc}
+; here couldn't initialise wimp program
.abort
MOV R4, R0
% BL close_application
MOV R0, R4
MVN lr, #0
S STR lr, [gb, #G_TaskHandle] ; flag as error in private word
& SWI "OS_GenerateError"
.abnormal_exit
MOV R1, #2
BL report_error
% BL close_application
SWI "OS_Exit"
V\- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1; In gb = pointer to workspace (validated)
:; Out R12 = pointer to private word (now holds zero)
5; all application-specific memory is purged
); Task is closed down if active
; workspace is free'd
N; Note that if called from in application, you just lost your stack!
$; All errors are suppresed
.close_application
STMFD (sp)!, {lr}
+ LDR R0, [gb, #G_TaskHandle]
CMP R0, #0
D BLgt shutdown_all_clients ; (ignore error)
MOVgt lr, #0
B STRgt lr, [gb, #G_TaskHandle] ; Flag died ok
" LDRgt R1, value_TASK
% SWIgt "XWimp_CloseDown"
` LDMFD (sp)!, {pc}^ ; Return address (incase stack in workspace)
V\- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7; Show error message in non-multi-tasking box
'; In R0 = pointer to error block
; R1 = flags
.report_error
STMFD (sp)!, {lr}
-
adrf("", 2, Module_Title_String)
' SWI "XWimp_ReportError"
LDMFD (sp)!, {pc}^
R; ----------------------------------------------------------------------------
; In Wimp_Poll (see docs)
._xpoll_User_Message
( LDR lr, [R1, #ms_action]
R ADR R0, messages ; Special-format ordered table
.loop LDMIA R0!, {R2-R3}
TEQ R2, lr
? ADDeq pc, R0, R3 ; Handle it
TEQ R2, #0
Bne loop
N LDMFD (sp)!, {pc}^ ; Should *never* get here!
message_start
B
message(Message_TaskCloseDown, message_TaskCloseDown)
C
message(Message_Quit, message_Quit) ; must be last!
message_end
.message_TaskCloseDown
, LDR R0, [R1, #ms_taskhandle]
" BL xlocate_client
A LDMvsFD (sp)!, {pc}^ ; (no error!)
+ LDR R0, [fw, #FW_FontTable]
& SUB R0, R0, #sizeof_FW
TEQ R0, fw
F MOVeq R0, #1 ; Close its' fonts
MOVne R0, #0
J MOV R1, #0 ; Don't delete windows
G BL xfontwindow_shutdown ; Completely zap it
LDMFD (sp)!, {pc}
*****************************************************************************
assemble a standard error block
Error(
e, number, e$)
[OPT pass%
ALIGN
.e EQUD number
EQUS e$
EQUB 0
ALIGN
]:= 0
fw_uxb(template$)
p_uxb(template$+ "%k%v"+
bootstrap(swi$)
pass%
E
"XOS_SWINumberFromString",, "FontWindow_Initialise"
; c%
>
"Module must be resident and then re-assembled"
?
"The module now being created is NOT usable ..."
k =
[OPT pass%
SWI swi$
]
P%+=4:O%+=4