4 ; Screen mode information caching (TMA)
6 ; © 1994-1998 Straylight
9 ;----- Licensing note -------------------------------------------------------
11 ; This file is part of Straylight's Sapphire library.
13 ; Sapphire 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)
18 ; Sapphire 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.
23 ; You should have received a copy of the GNU General Public License
24 ; along with Sapphire. If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ;----- Standard header ------------------------------------------------------
32 ;----- External dependencies ------------------------------------------------
37 ;----- Main code ------------------------------------------------------------
39 AREA |Sapphire$$Code|,CODE,READONLY
41 ; --- screen_getInfo ---
45 ; On exit: R0 == pointer to screen information block
47 ; Use: This call returns a pointer to a block of information
48 ; about the current screen modes. The format of this block
54 STMFD R13!,{R14} ;Save a register
55 LDR R0,screen__wSpace ;Get my workspace offset
56 LDR R14,sapph_workspace ;Load workspace base address
57 ADD R0,R14,R0 ;Find workspace address
58 ADD R0,R0,#4 ;Point to the data block
59 LDMFD R13!,{PC}^ ;Return to caller
63 ; --- screen_cache ---
65 ; On entry: R12 points to workspace
69 ; Use: Caches screen information for the current mode.
74 STMFD R13!,{R0-R10,R14} ;Stack some registers
76 ; --- Now read relevent mode variables ---
78 MOV R3,#1 ;A useful value
79 MOV R0,#-1 ;Get info on current mode
82 SWI OS_ReadModeVariable ;Read its value
83 MOV R4,R2 ;Look after xEig
84 MOV R9,R3,LSL R4 ;Get dx correctly
87 SWI OS_ReadModeVariable ;Read its value
88 MOV R5,R2 ;Look after yEig
89 MOV R10,R3,LSL R5 ;Get dy correctly
92 SWI OS_ReadModeVariable ;Read its value
93 MOV R6,R3,LSL R2 ;Calculate bpp
95 MOV R1,#11 ;XWindLimit
96 SWI OS_ReadModeVariable ;Read its value
97 ADD R2,R2,#1 ;Calculate screen width
98 MOV R7,R2,LSL R4 ;width=(XwindLimit+1)<<xEig
100 MOV R1,#12 ;XWindLimit
101 SWI OS_ReadModeVariable ;Read its value
102 ADD R2,R2,#1 ;Calculate screen width
103 MOV R8,R2,LSL R5 ;height=(YwindLimit+1)<<yEig
105 ; --- Now store the cached information ---
107 STMIB R12,{R4-R10} ;Store in my workspace
109 ; --- And return to caller ---
111 LDMFD R13!,{R0-R10,PC}^ ;Return
115 ; --- screen__postFilter ---
117 ; On entry: R0 == wimp event type
118 ; R1 == pointer to returned block
119 ; R12 == pointer to my workspace
123 ; Use: Called as a post filter to cache screen information on
129 ; --- Do we want this event ---
131 CMP R0,#2 ;Open window request?
132 MOVEQS PC,R14 ;Yes -- return PDQ
134 STMFD R13!,{R0,R2,R14} ;Save registers
135 LDR R2,screen__flags ;Get the flags word
136 CMP R0,#17 ;Is event a message?
138 BICNE R2,R2,#sFlag__newMode ;No -- clear 'changed mode'
139 STRNE R2,screen__flags ;...store back flags
140 LDMNEFD R13!,{R0,R2,PC}^ ;...and return
142 ; --- Is it the right message ---
144 LDR R14,[R1,#16] ;Get the message type
145 LDR R0,=&400C1 ;Is it a mode change?
146 CMP R14,R0 ;Compare the values
147 BICNE R2,R2,#sFlag__newMode ;No -- clear 'changed mode'
148 STRNE R2,screen__flags ;...store back flags
149 LDMNEFD R13!,{R0,R2,PC}^ ;...and return
151 ; --- Cache the mode information ---
153 ORR R2,R2,#sFlag__newMode ;Set 'changed mode' bit
154 STR R2,screen__flags ;Store back flags
155 BL screen_cache ;Cache screen info
159 LDMFD R13!,{R0,R2,PC}^ ;Return to caller
163 ; --- screen_justChangedMode ---
167 ; On exit: CS if last event was a mode change, CC otherwise
169 ; Use: Informs the caller if the last event was a mode change.
170 ; The system ignores open window requests when making it's
173 EXPORT screen_justChangedMode
174 screen_justChangedMode ROUT
176 STMFD R13!,{R12,R14} ;Stack some registers
177 WSPACE screen__wSpace ;Locate my workspace
179 LDR R14,screen__flags ;Get the flags word
180 TST R14,#sFlag__newMode ;Test relevant bit
181 LDMFD R13!,{R12,R14} ;Restore my registers
182 BICEQS PC,R14,#C_flag ;It wasn't -- clear carry
183 ORRNES PC,R14,#C_flag ;It was -- set carry
187 ; --- screen_init ---
193 ; Use: Initialises the screen unit.
198 STMFD R13!,{R0,R1,R12,R14} ;Stack some registers
199 WSPACE screen__wSpace ;Get my workspace
201 ; --- Are we already initialised? ---
203 LDR R0,screen__flags ;Get my flags
204 TST R0,#sFlag__inited ;Are we initialised?
205 LDMNEFD R13!,{R0,R1,R12,PC}^ ;Yes -- return
207 ORR R0,R0,#sFlag__inited ;Set flags
208 STR R0,screen__flags ;And store them back
210 ; --- Now cache the current mode info ---
214 ; --- Ensure that the event system is initialised ---
218 ; --- Finally, set up a post filter to catch mode changes ---
220 ADR R0,screen__postFilter ;Routine to call
221 MOV R1,R12 ;Put my workspace in R12
222 BL event_postFilter ;Add the post filter
224 ; --- That's it now ---
226 LDMFD R13!,{R0,R1,R12,PC}^ ;Return
230 screen__wSpace DCD 0 ;My workspace pointer
232 ;----- Workspace ------------------------------------------------------------
237 screen__flags # 4 ;Flags
239 screen__xEig # 4 ;X Eig Factor
240 screen__yEig # 4 ;Y Eig Factor
241 screen__bpp # 4 ;Bits per pixel
242 screen__width # 4 ;Current screen width
243 screen__height # 4 ;Current screen height
244 screen__dx # 4 ;x pixel size
245 screen__dy # 4 ;y pixel size
247 screen__wSize EQU {VAR}-screen__wStart
249 sFlag__inited EQU (1<<0) ;I've been initialised
250 sFlag__newMode EQU (1<<1) ;Mode change just happened
252 AREA |Sapphire$$LibData|,CODE,READONLY
254 DCD screen__wSize ;Workspace size
255 DCD screen__wSpace ;Workspace pointer
256 DCD 0 ;Scratchpad size
257 DCD screen_init ;Initialisation code
259 ;----- That's all, folks ----------------------------------------------------