-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path09-04-interface-resources.html
297 lines (225 loc) · 12.3 KB
/
09-04-interface-resources.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
<!doctype html>
<html lang="en">
<head>
<!--
This Amos Professional Manual is written by asymetrix for the Amiga community and should stay completely FREE FOREVER.
Created 2008. :)
It was created from the original AMOS Professional Manual by Europress Software Ltd.
It has been updated by Fredrik Rambris.
-->
<title>Interface Resources - AMOS Professional Manual</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="keywords" content="Amos Professional, Amiga, Programming, Basic, Francois Lionet, Europress Software Ltd, Amos, computing, code, AmigaDOS">
<meta name="author" content="asymetrix,Fredrik Rambris">
<link rel="GitHub" href="https://github.com/fredrik-rambris/amospromanual">
<meta property="og:site_name" content="AMOS Professional Manual">
<meta property="og:image" content="https://amospromanual.dev/images/cover.jpg">
<link rel="stylesheet" type="text/css" href="styles.css">
<link rel="canonical" href="https://amospromanual.dev/09-04-interface-resources.html">
</head>
<body>
<section>
<h1>Interface Resources</h1>
<p>
Up to now, it has been explained how Interface graphics are generated using built-in Interface
commands. It is also possible to create superb effects using pre-defined images stored in
memory.</p>
<p>
Each Interface program has access to a set of special resources held in an appropriate memory
bank. These resources can be created with the Resource Bank Maker, which has <a href="13-07-resource-creator.html">Chapter 13.7</a>
devoted to it. Once defined, resources can be installed for use with the AMOS Professional
Interface.</p>
<p>
The Resource Bank is normally allocated to memory bank 16, and the loading of a resources file
is explained at the very end of this Chapter.</p>
<p>
Alternatively, this process can be avoided if the current Editor settings are used. As a default,
AMOS Professional provides instant access to all of the system messages and Editor objects.
These provide everything needed to generate a wide variety of attractive dialogue boxes.</p>
<p>
There are two types of resources: messages, which hold a series of button definitions and titles,
and packed pictures, which can be anything at all.</p>
<h3 class="command" id="intf-me">ME<span>ssage</span></h3>
<p><i>Interface function: return a message from the Resource Bank</i><br>
message=number <b>ME</b></p>
<p>
The MEssage function takes a number from the stack and returns the appropriate message from
the Resource Bank. If the value for the number of the message is out of range, an error will be
generated. MEssage can be used in a PRint or PrintOutline command, like this:</p>
<code class="prefix edit">A$="PRint 0,0,7,MEssage,5;"
A$=A$+"EXit;"
D=Dialog Box(A$)
</code>
<p>
A message can also be displayed directly from the main AMOS Professional program, using the
RESOURCES function, which is explained later.</p>
<h3 class="command" id="inti-un">UN<span>pack</span></h3>
<p><i>Interface instruction: unpack an image from Resource Bank</i><br>
<b>UN</b> x,y,image number;</p>
<p>
Packed pictures can be taken from the Resource Bank, and unpacked for items such as buttons
or dialogue boxes. First specify the x,y-coordinates at which the image is to be unpacked. In this
case, the x-coordinate is rounded to a multiple of eight. Then specify the number of the single
image to be unpacked.</p>
<code class="prefix edit">Resource Screen Open 0,640,200,2
A$="UNpack 10,10,13; EXit;"
D=Dialog Box(A$)
</code>
<p>
In addition to single images, more complex arrangements can be built up from combining a
group of individual component images, and the following commands are available to exploit
this facility.</p>
<h3 class="command" id="inti-li">LI<span>ne</span></h3>
<p><i>Interface instruction: draw a line from Resource Bank image components</i><br>
<b>LI</b> x,y,first image,width;</p>
<p>
The LIne command is used to construct a line from three single images held in the Resource
Bank. The x,y-coordinates set the position of the top left-hand corner of the line, with the x-
coordinate rounded to the nearest multiple of eight pixels. Then the number of the first image to
be used for the line is given. Lastly, the width of the line is set in pixels, and this width should be
an exact multiple of the image width, otherwise the width of the line will be increased to the
nearest image boundary.</p>
<p>
The following diagram illustrates the three component images, defining the start, the middle
and the end of the line.</p>
<pre>
[1 2 3]
</pre>
<p>These components can be rearranged to generate larger lines, as illustrated next:</p>
<pre>
[1|2|2|2|2|3]
</pre>
<h3 class="command" id="inti-vl">V<span>ertical</span>L<span>ine</span></h3>
<p><i>Interface instruction: draw a vertical line from Resource Bank components</i><br>
<b>VL</b> x,y,first image,height</p>
<p>
This is very similar to the LIne command, except that it displays a vertical line composed of a
series of three images held in the Resource Bank. The x,y-coordinates for the top left-hand
corner of the line are given, followed by the number of the first of the three images to be used in
the display. Finally, the height of the line is specified, and it will be rounded up to the nearest
multiple of three automatically.</p>
<h3 class="command" id="inti-bo">BO<span>x</span></h3>
<p><i>Interface instruction: draw a box from Resource Bank image components</i><br>
<b>BO</b> x,y,first image,width,height;</p>
<p>
Similarly, the BOx instruction draws a rectangular bar from an assortment of nine packed
images from the Resource Bank. The parameters are the same as for a LIne command, with the
additional parameter of the height of the box, which can be anything you wish. The component
images for the rectangle are in the following format:</p>
<pre>
[1|2|3]
[4|5|6]
[7|8|9]
</pre>
<p>
These components can be re-used to produce a large number of possible displays, such as in the
next example diagram:</p>
<pre>
[1|2|2|2|3]
[4|5|5|5|6]
[4|5|5|5|6]
[7|8|8|8|9]
</pre>
<h3 class="command" id="inti-pu">PU<span>sh</span></h3>
<p><i>Interface instruction: push image to an offset position in the Resource Bank</i><br>
<b>PU</b> offset;</p>
<p>
The PUsh command sets an offset value to the first image in the Resource Bank, and this offset
will be added to all subsequent image numbers. This means that you can make a dialogue box
totally independent from the images in the Resource Bank. For example, if new images are
added at the beginning of the bank at any subsequent time, the images used by your existing
resource commands will be pushed down the required number of places, and they will work
perfectly without any changes in numbering required. To demonstrate this, the following two
lines would have exactly the same effect:</p>
<code class="prefix ex">PUsh 0; UNpack 0,0,13;
PUsh 13; UNpack 0,0,0;
</code>
</section>
<section id="01-the-resource-commands">
<h2>The Resource commands</h2>
<p>
Here is a full explanation of the additional AMOS Professional instructions and functions that
can be used to exploit the Resource Bank.</p>
<h3 class="command" id="i-resource-bank">RESOURCE BANK</h3>
<p><i>instruction: select a bank to be used for resources</i><br>
<b>Resource Bank</b> number</p>
<p>
This command is used to tell AMOS Professional in which bank the resources to be used by
Interface programs are kept. The number parameter holds the number of the memory bank to
be allocated. If this bank does not exist, the Editor's internal resource bank will be used as a
default. This means that after this command has been called, you can return to the Editor
resources by employing a dummy value, such as zero. Here is an example:</p>
<code class="prefix ex">Load "Resource.Abk",16 : <comment>Rem This can be any filename</comment>
Resource Bank 16: <comment>Rem Set resources to Bank 16</comment>
</code>
<h3 class="command" id="fn-resource-dollar">RESOURCE$</h3>
<p><i>function: read a message from the Resource Bank</i><br>
message=<b>Resource$</b>(message number)</p>
<p>
The RESOURCE$ function returns one of the messages from the current Resource Bank, to be
used by an AMOS Professional program. If the bank has not been defined, the standard Editor
messages will be made available from the Configuration file.</p>
<p>
Each national grouping is provided with its own set of messages in the appropriate language,
and these messages can be used to generate multi-language programs.
The message number parameter enters the number of the message. Here is an example:</p>
<code class="prefix direct">For A=1 To 7
Print Resource$(A)
Next A
</code>
<p>The following list shows the strings related to the various numbers:</p>
<pre>
<b>Number Message</b>
>0 String from the Resource bank
0 Full pathname of APSystem folder
<0 Configuration system strings, as follows:
-1 to -9 Default file names
-10 to -36 All 26 extensions
38, -38 Communication ports
-40 Default cursor flashing
2001 to -2044 Miscellaneous strings used by Editor
-2045 to -2049 Editor system files
</pre>
<h3 class="command" id="i-resource-screen-open">RESOURCE SCREEN OPEN</h3>
<p><i>instruction: open a screen using the resource settings</i><br>
<b>Resource Screen Open</b> number,width,height,flash</p>
<p>
This instruction opens a screen using the settings that are stored in the Resource Bank. These
screen settings include the number of colours, the resolution and the entire colour palette.</p>
<p>
The parameters are given in the following order: the number of the screen to be defined from
zero to 7, the width of this screen in pixels and the height of the screen in lines. Finally a simple
flag is set for the flash feature, with a value of zero to turn off the flash, or any other appropriate
value to assign the flash effect to that colour index number.</p>
<p>The new screen will be installed with the colour palette held in the Resource Bank.</p>
<p>
The following example opens a screen using the settings from the internal Resource Bank, just
like the Editor screen, where the flashing colour is index number 2.</p>
<code class="prefix edit">Resource Screen Open 0,640,200,2</code>
<h3 class="command" id="i-resource-unpack">RESOURCE UNPACK</h3>
<p><i>instruction: unpack an image from the Resource Bank</i><br>
<b>Resource Unpack</b> number,x,y</p>
<p>
This AMOS Professional command unpacks a single element from the current Resource Bank
and displays it on the screen.</p>
<p>
The number parameter refers to the number of the element to be displayed, and the x,y-
coordinates specify the position of the new image on screen.</p>
<p>
The instruction can be used directly in games programs to hold the various graphics
components in a very compact format. These images can be saved in the Resource Bank using
the Resource Bank Maker, and installed into memory along the following lines:</p>
<code class="prefix ex">Load "Resource.Abk",l6 : <comment>Rem This can be any filename</comment>
Resource Bank 16 : <comment>Rem set the resources to bank 16</comment>
</code>
</section>
<footer>
<a href="09-03-advanced-control-panels.html" rel="prev">Advanced Control Panels</a>
<a href="./">Contents</a>
<a href="14-appendix-g-command-index.html">Index</a>
<a href="10-01-using-the-keyboard.html" rel="next">Using the Keyboard</a>
</footer>
</body>
</html>