4 ; Sapphire shared resources (MDW)
6 ; © 1995-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 ------------------------------------------------------
34 ;----- External dependencies ------------------------------------------------
36 IMPORT |Image$$RO$$Base|
44 ;----- Main code ------------------------------------------------------------
46 AREA |Main$$Code|,CODE,READONLY
48 ; --- sapphRes_find ---
50 ; On entry: R0 == resource type code
51 ; R1 == pointer to resource name (only required for
54 ; On exit: CS if found, and
55 ; R0 == address of resource
56 ; R1 == limit (for messages)
60 ; Use: Looks up the address of a resource in the shared resource
66 CMP R0,#srType_max ;Is the type in range?
67 ADDCC PC,PC,R0,LSL #2 ;Yes -- dispatch it then
68 BICS PC,R14,#C_flag ;Otherwise couldn't find it
70 B sr__findSprite ;Find a sprite resource
71 B sr__findMessages ;Find a messages resource
72 B sr__findTemplate ;Find a template resource
76 ; --- sr__findSprite ---
80 ; On exit: R0 == address of a sprite area
82 ; Use: Locates the sprite resource within the DLL.
86 LDR R0,=rsc_sprites ;Find the sprite area
87 ORRS PC,R14,#C_flag ;And return to caller
91 ; --- sr__findMessages ---
95 ; On exit: R0 == address of messages base
96 ; R1 == address of messages limit
98 ; Use: Locates the messages resource within the DLL.
100 sr__findMessages ROUT
102 ADR R0,sr__msgs ;Point to messages base/limit
103 LDMIA R0,{R0,R1} ;Load them out
104 ORRS PC,R14,#C_flag ;And return to caller
106 sr__msgs DCD rsc_msgBase
111 ; --- sr__findTemplate ---
113 ; On entry: R1 == pointer to template name
115 ; On exit: CS and R0 == pointer to embedded template block, or CC
117 ; Use: Locates a named window defintion.
119 sr__findTemplate ROUT
121 STMFD R13!,{R2-R6,R14} ;Save some registers
122 ADR R14,sr__tpls ;Point to base and limit
123 LDMIA R14,{R2,R3} ;Load them out
125 ; --- Search the template table ---
127 10 CMP R2,R3 ;Have we finished yet?
128 BCS %90sr__findTemplate ;Yes -- then we failed
130 ; --- Check for a name match ---
133 00 LDRB R5,[R4],#1 ;Load first char of name
134 SUB R14,R5,#'A' ;Convert to a letter index
135 CMP R14,#26 ;Is it in range?
136 ORRCC R5,R5,#&20 ;Yes -- convert to lowercase
137 CMP R5,#&20 ;Is the byte a control char?
138 MOVCC R5,#0 ;Yes -- say it's zero
140 LDRB R6,[R2],#1 ;Load first char of name
141 SUB R14,R6,#'A' ;Convert to a letter index
142 CMP R14,#26 ;Is it in range?
143 ORRCC R6,R6,#&20 ;Yes -- convert to lowercase
144 CMP R6,#&20 ;Is the byte a control char?
145 MOVCC R6,#0 ;Yes -- say it's zero
147 ; --- Compare the characters
149 CMP R5,R6 ;Do the chars match?
150 BNE %50sr__findTemplate ;No -- move on to next one
151 CMP R5,#0 ;Is it the end?
152 BNE %b00 ;No -- keep looking
154 ; --- Found a match ---
156 ADD R2,R2,#3 ;Word align the output
157 BIC R2,R2,#3 ;To make sure
158 LDR R0,[R2,#0] ;Load the template base
159 LDMFD R13!,{R2-R6,R14} ;Restore registers
160 ORRS PC,R14,#C_flag ;And return success
162 ; --- Failed -- move on to next entry ---
164 50 CMP R6,#&20 ;Reached the end yet?
165 LDRCSB R6,[R2],#1 ;No -- load next byte
166 BCS %b50 ;And keep on looping
167 ADD R2,R2,#4+3 ;Word align the output
168 BIC R2,R2,#3 ;To make sure
169 B %10sr__findTemplate ;And rejoin the main loop
171 ; --- Failed entirely ---
173 90 LDMFD R13!,{R2-R6,R14} ;Restore registers
174 BICS PC,R14,#C_flag ;And return to caller
176 sr__tpls DCD rsc_tplBase
181 ;----- Resource types -------------------------------------------------------
184 srType_sprites # 1 ;Sprite resource, returned as
185 ;address of sprite area
187 srType_messages # 1 ;Messages resource, returned
188 ;as address of base and limit
191 srType_template # 1 ;Template (window) resource,
192 ;returned as address of
193 ;embedded template def.
197 ;----- That's all, folks ----------------------------------------------------