Initial revision
[ssr] / StraySrc / Libraries / Quartz / s / screen
1 ;
2 ; screen.s
3 ;
4 ; Screen mode information caching (TMA)
5 ;
6 ; © 1994-1998 Straylight
7 ;
8
9 ;----- Licensing note -------------------------------------------------------
10 ;
11 ; This file is part of Straylight's Quartz library.
12 ;
13 ; Quartz 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 ; Quartz 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 Quartz. 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 ; None.
35
36 ;----- Main code ------------------------------------------------------------
37
38 AREA |Quartz$$Code|,CODE,READONLY
39
40 ; --- screen_getInfo ---
41 ;
42 ; On entry: --
43 ;
44 ; On exit: R0 == pointer to screen information block
45 ;
46 ; Use: This call returns a pointer to a block of information
47 ; about the current screen modes. The offset for different
48 ; bits of data are defined in screen.sh
49
50 EXPORT screen_getInfo
51 screen_getInfo ROUT
52
53 LDR R0,screen__wSpace ;Get my workspace
54 ADD R0,R0,#4 ;Point to the data block
55 MOVS PC,R14 ;Return to caller
56
57 LTORG
58
59 ; --- screen__cache ---
60 ;
61 ; On entry: --
62 ;
63 ; On exit: --
64 ;
65 ; Use: Caches screen information for the current mode
66
67 screen__cache ROUT
68
69 STMFD R13!,{R0-R10,R14} ;Stack some registers
70 LDR R12,screen__wSpace ;Locate my workspace
71
72 ; --- Now read relevent mode variables ---
73
74 MOV R3,#1 ;A useful value
75 MOV R0,#-1 ;Get info on current mode
76
77 MOV R1,#4 ;XEigFactor
78 SWI OS_ReadModeVariable ;Read its value
79 MOV R4,R2 ;Look after xEig
80 MOV R9,R3,LSL R4 ;Get dx correctly
81
82 MOV R1,#5 ;YEigFactor
83 SWI OS_ReadModeVariable ;Read its value
84 MOV R5,R2 ;Look after yEig
85 MOV R10,R3,LSL R5 ;Get dy correctly
86
87 MOV R1,#9 ;Log2BPP
88 SWI OS_ReadModeVariable ;Read its value
89 MOV R6,R3,LSL R2 ;Calculate bpp
90
91 MOV R1,#11 ;XWindLimit
92 SWI OS_ReadModeVariable ;Read its value
93 ADD R2,R2,#1 ;Calculate screen width
94 MOV R7,R2,LSL R4 ;width=(XwindLimit+1)<<xEig
95
96 MOV R1,#12 ;XWindLimit
97 SWI OS_ReadModeVariable ;Read its value
98 ADD R2,R2,#1 ;Calculate screen width
99 MOV R8,R2,LSL R5 ;height=(YwindLimit+1)<<yEig
100
101 ; --- Now store the cached information ---
102
103 STMIB R12,{R4-R10} ;Store in my workspace
104
105 ; --- And return to caller ---
106
107 LDMFD R13!,{R0-R10,PC}^ ;Return
108
109 LTORG
110
111 ; --- screen_init ---
112 ;
113 ; On entry: R12 == pointer to private workspace
114 ;
115 ; On exit: --
116 ;
117 ; Use: Initialises the ptr system
118
119 EXPORT screen_init
120 screen_init ROUT
121
122 STMFD R13!,{R0,R14} ;Stack some registers
123
124 ; --- Are we already initialised? ---
125
126 LDR R0,screen__flags ;Get my flags
127 TST R0,#sFlag__inited ;Are we initialised?
128 LDMNEFD R13!,{R0,PC}^ ;Yes -- return
129
130 ORR R0,R0,#sFlag__inited ;Set flags
131 STR R0,screen__flags ;And store them back
132
133 ; --- Now cache the current mode info ---
134
135 BL screen__cache ;Cache screen information
136
137 ; --- That's it now ---
138
139 LDMFD R13!,{R0,PC}^ ;Return
140
141 LTORG
142
143 screen__wSpace DCD 0 ;My workspace pointer
144
145 ;----- Workspace ------------------------------------------------------------
146
147 ^ 0,R12
148 screen__wStart # 0
149
150 screen__flags # 4 ;Flags
151
152 screen__xEig # 4 ;X Eig Factor
153 screen__yEig # 4 ;Y Eig Factor
154 screen__bpp # 4 ;Bits per pixel
155 screen__width # 4 ;Current screen width
156 screen__height # 4 ;Current screen height
157 screen__dx # 4 ;x pixel size
158 screen__dy # 4 ;y pixel size
159
160 screen__wSize EQU {VAR}-screen__wStart
161
162 sFlag__inited EQU (1<<0) ;I've been initialised
163
164 AREA |Quartz$$Service|,CODE,READONLY
165
166 DCD screen__cache,&46
167
168 AREA |Quartz$$Table|,CODE,READONLY
169
170 DCD screen__wSize ;Workspace size
171 DCD screen__wSpace ;Workspace pointer
172 DCD screen_init ;Initialisation code
173 DCD 0 ;Finalisation
174
175 ;----- That's all, folks ----------------------------------------------------
176
177 END