JPEG support and other fixes from Nick Clark
[ssr] / StraySrc / Libraries / Sapphire / s / roVersion
1 ;
2 ; roVersion.s
3 ;
4 ; Handling of the RISC OS version (MDW)
5 ;
6 ; © 1994-1998 Straylight
7 ;
8
9 ;----- Licensing note -------------------------------------------------------
10 ;
11 ; This file is part of Straylight's Sapphire library.
12 ;
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)
16 ; any later version.
17 ;
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.
22 ;
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.
26
27 ;----- Standard header ------------------------------------------------------
28
29 GET libs:swis
30 GET libs:header
31
32 ;----- External dependencies ------------------------------------------------
33
34 GET sapphire:sapphire
35
36 ;----- Main code ------------------------------------------------------------
37
38 AREA |Sapphire$$Code|,CODE,READONLY
39
40 ; --- rov_init ---
41 ;
42 ; On entry: --
43 ;
44 ; On exit: --
45 ;
46 ; Use: Sets up the OS version in a cache.
47
48 EXPORT rov_init
49 rov_init ROUT
50
51 STMFD R13!,{R0-R4,R12,R14} ;Save some registers away
52 WSPACE rov__wSpace ;Find my workspace pointer
53 LDR R14,rov__version ;Get the cached version
54 CMP R14,#0 ;Is it set up yet?
55 LDMNEFD R13!,{R0-R4,R12,PC}^ ;Yes -- return to caller
56
57 ; --- Work out the RISC OS version properly ---
58
59 MOV R0,#129 ;Read key (or OS version) :-/
60 MOV R1,#0 ;Want OS version
61 MOV R2,#255 ;Still want OS version
62 SWI OS_Byte ;Read the version number
63
64 ADR R2,rov__verTable ;Point to my version table
65 MOV R0,#-1 ;Start off with bad version
66 10rov_init LDMIA R2!,{R3,R4} ;Load the version numbers
67 CMP R3,R1 ;Does this version match?
68 MOVLE R0,R4 ;Yes -- use this version
69 BGT %10rov_init ;Otherwise continue search
70
71 STR R0,rov__version ;Save this version away
72 LDMFD R13!,{R0-R4,R12,PC}^ ;Return to caller
73
74 rov__verTable DCD &A7,370
75 DCD &A6,360
76 DCD &A5,350
77 DCD &A4,310
78 DCD &A3,300
79 DCD &A2,201
80 DCD &A1,200
81 DCD 0,0
82
83 rov__wSpace DCD 0
84
85 LTORG
86
87 ; --- rov_version ---
88 ;
89 ; On entry: --
90 ;
91 ; On exit: R0 == current RISC OS version
92 ;
93 ; Use: Returns the current operating system version number.
94
95 EXPORT rov_version
96 rov_version ROUT
97
98 STMFD R13!,{R14} ;Save a register
99 LDR R0,rov__wSpace ;Find my workspace offset
100 LDR R14,sapph_workspace ;Find workspace base
101 LDR R0,[R0,R14] ;Load version number
102 LDMFD R13!,{PC}^ ;Return to caller
103
104 LTORG
105
106 ;----- Workspace ------------------------------------------------------------
107
108 ^ 0,R12
109 rov__wStart # 0
110
111 rov__version # 4 ;Current OS version number
112
113 rov__wSize EQU {VAR}-rov__wStart
114
115 AREA |Sapphire$$LibData|,CODE,READONLY
116
117 DCD rov__wSize
118 DCD rov__wSpace
119 DCD 0
120 DCD rov_init
121
122 ;----- That's all, folks ----------------------------------------------------
123
124 END