Interface Resources

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.

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 Chapter 13.7 devoted to it. Once defined, resources can be installed for use with the AMOS Professional Interface.

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.

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.

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.


Interface function: return a message from the Resource Bank
message=number ME

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:

A$="PRint 0,0,7,MEssage,5;" A$=A$+"EXit;" D=Dialog Box(A$)

A message can also be displayed directly from the main AMOS Professional program, using the RESOURCES function, which is explained later.


Interface instruction: unpack an image from Resource Bank
UN x,y,image number;

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.

Resource Screen Open 0,640,200,2 A$="UNpack 10,10,13; EXit;" D=Dialog Box(A$)

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.


Interface instruction: draw a line from Resource Bank image components
LI x,y,first image,width;

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.

The following diagram illustrates the three component images, defining the start, the middle and the end of the line.

[1 2 3]

These components can be rearranged to generate larger lines, as illustrated next:



Interface instruction: draw a vertical line from Resource Bank components
VL x,y,first image,height

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.


Interface instruction: draw a box from Resource Bank image components
BO x,y,first image,width,height;

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:


These components can be re-used to produce a large number of possible displays, such as in the next example diagram:



Interface instruction: push image to an offset position in the Resource Bank
PU offset;

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:

PUsh 0; UNpack 0,0,13; PUsh 13; UNpack 0,0,0;

The Resource commands

Here is a full explanation of the additional AMOS Professional instructions and functions that can be used to exploit the Resource Bank.


instruction: select a bank to be used for resources
Resource Bank number

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:

Load "Resource.Abk",16 : Rem This can be any filename Resource Bank 16: Rem Set resources to Bank 16


function: read a message from the Resource Bank
message=Resource$(message number)

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.

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:

For A=1 To 7 Print Resource$(A) Next A

The following list shows the strings related to the various numbers:

Number           Message
>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


instruction: open a screen using the resource settings
Resource Screen Open number,width,height,flash

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.

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.

The new screen will be installed with the colour palette held in the Resource Bank.

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.

Resource Screen Open 0,640,200,2


instruction: unpack an image from the Resource Bank
Resource Unpack number,x,y

This AMOS Professional command unpacks a single element from the current Resource Bank and displays it on the screen.

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.

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:

Load "Resource.Abk",l6 : Rem This can be any filename Resource Bank 16 : Rem set the resources to bank 16