Initial revision
[ssr] / StraySrc / Libraries / Steel / s / wimp_dll
1 ;
2 ; wimp_dll.s
3 ;
4 ; Special DLL parts of wimp
5 ;
6 ; © 1994-1998 Straylight
7 ;
8
9 ;----- Licensing note -------------------------------------------------------
10 ;
11 ; This file is part of Straylight's Steel library.
12 ;
13 ; Steel is free software; you can redistribute it and/or modify
14 ; it under the terms of the GNU General Public License as published by
15 ; the Free Software Foundation; either version 2, or (at your option)
16 ; any later version.
17 ;
18 ; Steel is distributed in the hope that it will be useful,
19 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ; GNU General Public License for more details.
22 ;
23 ; You should have received a copy of the GNU General Public License
24 ; along with Steel. If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
27 ;----- Standard header ------------------------------------------------------
28
29 GET libs:header
30 GET libs:SWIs
31
32 ;----- External dependencies ------------------------------------------------
33
34 IMPORT |_dll_wimpPoll|
35 IMPORT |_dll_wimpPollIdle|
36
37 ;----- Some flags and things -----------------------------------------------
38
39 dpoll__savefp EQU 1<<24 ;Bit to set to save FP state
40
41 ;----- Private data ---------------------------------------------------------
42
43 AREA |C$$data|,DATA
44
45 wimp__savefp DCD 1
46
47 ;----- Polling code ---------------------------------------------------------
48
49 AREA |C$$Code|,CODE,READONLY
50
51 ; --- wimp_poll ---
52 ;
53 ; On entry: a1 == Wimp_Poll event mask
54 ; a2 == pointer to wimp_eventstr to be filled in
55 ; On exit: a1 == pointer to an os_error, or nothing
56
57 EXPORT wimp_poll
58 wimp_poll ROUT
59
60 STMFD sp!,{lr} ;Look after some registers
61
62 ; --- Figure out about saving the FP status ---
63
64 LDR a4,=wimp__savefp ;Find the magic flag
65 LDR ip,[sl,#-536] ;Get the relocation
66 ADD a4,ip,a4 ;And relocate this address
67 LDR a4,[a4] ;Get the value of the flag
68 CMP a4,#0 ;Do we have to save FP state?
69 ORRNE a1,a1,#dpoll__savefp ;Yes -- set the flag
70 BICNE a1,a1,#dpoll__savefp ;No -- clear the flag
71
72 ; --- Call the SWI and get out again ---
73
74 ADD a2,a2,#4 ;Point to the big poll block
75 BL |_dll_wimpPoll| ;Get a Wimp event
76 SUB a2,a2,#4 ;Point to the wimp_eventstr
77 STRVC a1,[a2] ;Store the reason code away
78 MOVVC a1,#0 ;If no error, return NULL
79 LDMFD sp!,{pc}^ ;Return to caller nicely
80
81 LTORG
82
83 ; --- wimp_pollidle ---
84 ;
85 ; On entry: a1 == Wimp_Poll event mask
86 ; a2 == pointer to wimp_eventstr to be filled in
87 ; a3 == time before which thou shalt not return
88 ; On exit: a1 == pointer to an os_error, or nothing
89
90 EXPORT wimp_pollidle
91 wimp_pollidle ROUT
92
93 STMFD sp!,{lr} ;Look after some registers
94
95 ; --- Figure out about saving the FP status ---
96
97 LDR a4,=wimp__savefp ;Find the magic flag
98 LDR ip,[sl,#-536] ;Get the relocation
99 ADD a4,ip,a4 ;And relocate this address
100 LDR a4,[a4] ;Get the value of the flag
101 CMP a4,#0 ;Do we have to save FP state?
102 ORRNE a1,a1,#dpoll__savefp ;Yes -- set the flag
103 BICNE a1,a1,#dpoll__savefp ;No -- clear the flag
104
105 ; --- Call the SWI and get out again ---
106
107 ADD a2,a2,#4 ;Point to the big poll block
108 BL |_dll_wimpPollIdle| ;Get a Wimp event
109 SUB a2,a2,#4 ;Point to the wimp_eventstr
110 STRVC a1,[a2] ;Store the reason code away
111 MOVVC a1,#0 ;If no error, return NULL
112 LDMFD sp!,{pc}^ ;Return to caller nicely
113
114 LTORG
115
116 ; --- wimp_save_fp_state_on_poll ---
117
118 EXPORT wimp_save_fp_state_on_poll
119 wimp_save_fp_state_on_poll
120 ROUT
121
122 LDR a1,=wimp__savefp ;Find the magic flag
123 LDR ip,[sl,#-536] ;Get the relocation
124 ADD a1,ip,a1 ;And relocate this address
125 MOV a2,#1 ;Store a TRUE value away
126 STR a2,[a1] ;Tuck it into my workspace
127 MOVS pc,lr ;Return to the caller
128
129 LTORG
130
131 ; --- wimp_corrupt_fp_state_on_poll ---
132
133 EXPORT wimp_corrupt_fp_state_on_poll
134 wimp_corrupt_fp_state_on_poll
135 ROUT
136
137 LDR a1,=wimp__savefp ;Find the magic flag
138 LDR ip,[sl,#-536] ;Get the relocation
139 ADD a1,ip,a1 ;And relocate this address
140 MOV a2,#0 ;Store a FALSE value away
141 STR a2,[a1] ;Tuck it into my workspace
142 MOVS pc,lr ;Return to the caller
143
144 LTORG
145
146 ;----- Include the main wimp veneers ----------------------------------------
147
148 LNK s.wimp_main