4 ; Handling of the RISC OS version (MDW)
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 ------------------------------------------------
36 ;----- Main code ------------------------------------------------------------
38 AREA |Sapphire$$Code|,CODE,READONLY
46 ; Use: Sets up the OS version in a cache.
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
57 ; --- Work out the RISC OS version properly ---
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
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
71 STR R0,rov__version ;Save this version away
72 LDMFD R13!,{R0-R4,R12,PC}^ ;Return to caller
74 rov__verTable DCD &A5,350
89 ; On exit: R0 == current RISC OS version
91 ; Use: Returns the current operating system version number.
96 STMFD R13!,{R14} ;Save a register
97 LDR R0,rov__wSpace ;Find my workspace offset
98 LDR R14,sapph_workspace ;Find workspace base
99 LDR R0,[R0,R14] ;Load version number
100 LDMFD R13!,{PC}^ ;Return to caller
104 ;----- Workspace ------------------------------------------------------------
109 rov__version # 4 ;Current OS version number
111 rov__wSize EQU {VAR}-rov__wStart
113 AREA |Sapphire$$LibData|,CODE,READONLY
120 ;----- That's all, folks ----------------------------------------------------