5.2 Format of the PICTURE resource (from AGDS docs)
Last updated: 27 January 1998
(Translated from a russian document. The first part does not
refer to the PICTURE resource format but gives a more detailed
discussion of the picture commands used and the priority screen.
The second part gives the format of a PICTURE resource).
I.2.1 THE PICTURE RESOURCE
This resource is used for static images (props), which create
a background for animated objects programmatically associated
with VIEW resources. (see I.2.2). The background is 160 pixels
wide and 168 pixels high. Each pixel is painted using one of 16
colours. To create a 3D illusion, each pixel has another
attribute: priority.
Priority determines the distance of each pixel from the
viewer. Pixels which have the greater priority are considered to
be closer and vice- versa. Priority is a value in the range
between 0 and 15.
When an animated object (a VIEW resource) is displayed, it is
drawn only on top of the pixels with the priority not greater
than the object's. This creates an illusion of moving behind or
in front of other objects.
Priority 4 is considered in the far back (objects cannot move
behind it), priority 15 - the closest to the viewer (objects
cannot move in front of it).
Priorities 0, 1, 2, 3 are special. Lines and areas of a
PICTURE resource with priorities 0, 1, 2, 3 represent:
0 - unconditional barrier (border)
1 - conditional barrier
2 - alarm barrier
3 - water surface.
Picture resource is a sequence of commands produced by an
editor of static images, Picture Manager (PM). Playing back the
sequence draws an image used as the background of the action, and
assigns required priorities to its pixels, thus creating a 3D
scenery.
Please note that the drawing commands the picture-resource
includes (described in section I.2.1) are created automatically
by the Picture Manager (PM) as the artist draws the background he
or she wants.
Let us look closer at these commands (see also the PM
description).
I.2.1.1 SET COLOUR COMMAND
Initially all pixels of the background are white and have
priority 4. We can draw using the following colours:
| 0 - black |
8 - dark drey |
| 1 - blue |
9 - light blue |
| 2 - grueen |
10 - light green |
| 3 - cyan |
11 - light cyan |
| 4 - red |
12 - light red |
| 5 - magenta |
13 - light magenta |
| 6 - brown |
14 - yellow |
| 7 - light grey |
15 - white |
To change colours, this command is used. After it is executed,
all the subsequent graphic commands draw using the colour set by
the command.
I.2.1.2 CANCEL COLOUR COMMAND
This command is used if we have already drawn the image. Any
graphic command issued after this one will not change the colour
of image pixels the draw.
I.2.1.3 SET PRIORITY COMMAND
All graphic command issued after this one will set priority of
the pixels they draw to the one set by this command.
I.2.1.4 CANCEL PRIORITY COMMAND
Any graphic command issued after this one will not change
priority of the pixels they draw.
I.2.1.5 POLYLINE COMMAND
Several graphic commands are used to draw images. There are
several polyline drawing commands and a curved line command.
The first polyline command draws a line using the current
colour and priority. The line consists of horizontal and vertical
line fragments and begins with a vertical line.
Here is an example. First line fragment, always vertical:
(x,y)
|
|
V
(x,y1)
where x = horizontal coordinate, and y = vertical coordinate.
Since we draw a vertical line, X coordinate does not change.
The next line fragment is horizontal, so now Y coordinate does
not change:
(x,y)
|
|
V
*---------->(x2 ,y1)
(x,y1)
X is now x2, indicating that it is the second time it has
changed.
In a similar fashion:
(x,y) (x2,y3)
| *----------->(x4,y3)
| ^
V |
*--------->*
(x,y1) (x2,y1)
There is no need to specify the whole sequence of coordinates
(x,y), (x,y1), (x2, y1), (x2, y3), (x4, y3). Instead, it is
enough to list only the coordinates that change, since we know
the order of their changes (first - Y, then X, then Y again and
so on). Thus, to describe this line it is enough to list (x, y,
y1, x2, y3, x4).
It is this sequence of numbers that is used as the command
operands.
The second polyline command is similar to the first but the
first line fragment is horizontal.
(x,y) ------------>* (x1,y)
|
| ...
| |
V |
*-------------->*
(x1,y2) (x3,y2)
It is described by the sequence (x, y, x1, y2, x3, ...)
The third command draws an arbitrary polyline.
(x1,y1)
/\
/ \
/ \
/ \ ... (x3,y3)
/ \ /
(x,y) \ /
\/
(x2,y2)
It is described by the sequence (x, y, x1, y1, x2, y2, ...).
I.2.1.6 CURVE COMMAND
[I think "curve" is a actually a misnomer, this is
just a polyline with each successive point specified relative to
the previous one. --VB]
This is a variant of an arbitrary polyline command that draws
a polyline made of very short line fragments.
The line goes from point (x,y) to the point (x1,y1), then to
the point (x2,y2), etc.
The operands are x, y, dx1, dy1, dx2, dy2, ..., where dx(n) =
x(n-1) - x(n), dy(n) = y(n-1) - y(n)
I.2.1.7 FLOOD FILL COMMAND
This command fills a closed area using the current colour and
priority, beginning at a point inside the area. One command may
fill one or more areas using pairs of coordinates within them.
The command works as follows:
1. If the current colour is set and is not 15 (i.e. not
white), then the area to fill is the closed white area containing
the argument point.
2. If the current colour is not set (was cancelled), the area
to fill is the closed area of pixels with priority 4 containing
the argument point.
Thus, it is impossible to repaint non-white areas or change
priority if it is different from 4.
I.2.1.8 DOTS DRAWING COMMAND
This command has two parts. The first specifies the parameters
of the dots, the second - the dots themselves.
Dot parameters
Parameters in this part are:
1) a number from 0 to 7 giving the size of the dot.
2) if the size above is greater than 2, this parameter chooses
whether the dot is drawn as a square (1) or as a circle (0).
3) selects whether the dot is opaque or
"translucent", so that 1/3 of the pixels within the dot
are left unchanged.
Dots
This part lists the coordinates where to draw the dots: x1,
y1, x2, y2, ... where x(i), y(i) is the coordinate of the center
of the dot.
If the dots are "translucent", a third parameter
r(i) is required for each dot, determining the distribution of
painted pixels within the dot.
I.2.1.9 END COMMAND
This command ends the drawing, and is required at the end of a
picture resource. See the description of PM editor for more
information about graphics commands.
A.2.1 PICTURE RESOURCE FORMAT
Picture resource is a sequence of graphics commands, execution
of which creates the background pictures and assigns required
priorities to its pixels.
A command is a one-byte operation code, optionally followed by
one-byte operands. Commands are stored one after another.
1. Set current colour
Code F0. Operand: colour code
Initially all pixels of the background are white and priority
4.
Example: F0 0C - set current colour to bright red
All command following this command will use this colour for
drawing.
2. Cancel current colour
Code F1.
3. Set current priority
Code F2. operand: priority
Example: F2 0D - set current priority to 13
4. Cancel current colour
Code F3.
5. Display polyline
The commands display polylines
Code F4. Operands: x,y,y1,x2,y3,x4,...
Draws a polyline using current colour and priority. The line
consists of horizontal and vertical fragments, the first fragment
is vertical.
Example: F4 28 32 64 78 32 29
Draws a rectangle in the centre of the screen
(40,50) (120,50)
*--------------------*
| |
| |
*--------------------*
(40,100) (120,100)
Code F5. Operands: x, y, x1, y2, x3, y4,....
Similar to F4 but the first line fragment is horizontal.
Example: F5 28 32 78 64 28 33
Draws the same rectangle.
Code F6. Operands: x,y,x1,y1,x2,y2,x3,y3,.....
Draws a polyline of random line fragments.
Example: F6 50 32 28 64 78 64 50 32
Triangle (80,50)
/\
/ \
/ \
(40,100) ------ (120,100)
Code F7. Operands: x,y, dd1, dd2, dd3,....
This is a variant of a random polyline drawing command which
draws a polyline made of very short line fragments.
dd1, dd2, etc. mean packed in one byte two values dx and dy -
offsets from the previous polyline vertex.
x x x - value between 0 and 6 - value of dx if Sx = 1; between
0 and 7 - if Sx = 0; y y y - value between 0 and 7 - value of dy;
Sx, Sy - if this bit is 0, the value is positive, otherwise it
is negative.
Example: F7 4D 4D 60 06 E0 0D
(77,77) (83,77)
*------------*
| |
| |
| |
*------------*
(77,83) (83,83)
6. Draw a dot
Code F8. Operands x1, y1, x2, y2, x3, y3,.....
7. Draw a dot
Code F9. Operand: p.
Operand format:
s s s - a number between 0 and 7: the size of the dot
c - if the dot is larger than 2 and this bit is 1, the dot is
drawn as a circle, otherwise - as a square.
r - if this bit is 1, the dot is "translucent", so
that 1/3 of the pixels are not painted.
Other bits should be set to 0.
Code FA.
Operands: if in the previous F9 command bit r=0, then x1, y1,
x2, y2, x3, y3,..... if r=1 r1, x1, y1, r2, x2, y2, r3, x3,
y3,.....
x(i), y(i) - coordinates of the dot centre
r(i) - arbitrary value which determines the distribution of
painted elements within a "translucent" dot.
8. End
Code FF.