pre-release 0.2 Edited By Dr Phibes
STOS Manual 7: THE SCREEN
Multiple Screens
Stos basic holds two screens in memory at one time. The first is called
the Physical screen, and is the screen which is actually displayed on the
monitor. There is however, also a separate Background screen which is used
by the sprite commands. Normally the only difference between the two screens
are the sprites, which are only drawn on the physical screen. Stos basic
uses this background to redraw any areas of the screen which are revealed
underneath the sprites when they are moved.
BACK
This variable holds the location of the background screen.
PHYSIC
Is a reserved variable which contains the location of the screen currently
being displayed. If a different address is loaded into this variable, the
screen will be immediately redrawn using the screen stored at the new address.
example:
10 reserve as screen 5
20 physic=5
30 cls
The above example reserves a memory bank as a screen and then assigns the
address of this bank to the physical screen. Notice how you are able to
use the number of the bank instead of an address. When you run this program,
the new screen will be cleared. If you new press the [UNDO] key twice,
The screen address will be returned to normal and the original picture
will be restored. The screen address must always be a multiple of 256,
the reserve command takes this into account when allocating memory for
a screen.
LOGIC
The Logical screen is the screen which is operated on by any of the text
or graphics instructions. Normally this will be the same as the physical
screen, but occasionally it's useful to hold an image while it is being
drawn. This allows you to draw one picture while displaying another, and
then instantly switch between them using a special SCREEN SWAP command.
SCREEN SWAP Swaps the addresses of the physical and logical screens, thus
enabling instant picture switching.
DEFAULT BACK
Returns initial value of back
DEFAULT PHYSIC
Returns initial value of physic DEFAULT LOGIC Returns initial value of
logic. To return a screen to it's original address the following simple
instruction will do: physic=default physic
Reserving A Screen
RESERVE AS SCREEN n
Reserves bank number n as a screen of 32768 bytes. Note that this is only
a temporary allocation and will be reinitialised every time the program
is run.
RESERVE AS DATASCREEN n
Identical to the above command except that the memory is allocated permanently
and will be saved along with the program.
Loading A Screen
LOAD "IMAGE.NEO[PI?]",scrn
Will load an image into address or bank scrn. GET PALETTE(n) Loads the
colour settings of a screen stored in bank n, and display them to the present
screen.
CLS
In addition to the normal CLS instruction there is also an expanded version
which enables you to erase sections of a screen stored anywhere in the
ST's memory. These are the three possible formats of the statement:
CLS scr
Clears the screen at scr
CLS scr,col
Fills the screen at scr with colour col
CLS scr,col,x,y to x2,y2
Replaces the rectangle at scr with a block of colour col using the x,y
and x2,y2 coordinates. scr refers either to an address of a screen or the
number of a memory bank.
ZOOM scr1,x,y,x2,y2 TO [scr2,]x3,y3,x4,y4
Magnifies any rectangular section of the screen stored at scr1. scr1 and
scr2 can be either an address or the number of a memory bank. scr2 is optional
and if it is not specified then the screen will be enlarged onto the background
held in BACK, and then copied into the current screen. This avoids any
problems with the mouse or sprites, and also displays the object in one
smooth operation.
REDUCE scr1 TO [scr2,]x,y,x2,y2
Compresses the entire screen stored at scr1 into the box specified by x,y,x2,y2.
scr1 and scr2 refer to either a screen address or the number of a memory
bank. As with ZOOM, if the optional destination screen is omitted, the
drawing is first compressed onto the background and then moved into the
physical screen, appearing smoothly in one operation.
SCREEN COPY scr1 TO scr2
Copies scr1 to scr2 A more powerful version of this command is also available
and is used as follows:
SCREEN COPY scr1,x,y,x2,y2 TO scr2,x3,y3
Which copies the section of scr1 to the position on scr2 defined by x3,y3.
As usual scr1 and scr2 can refer to a memory bank or an address. The x
coordinates are automatically rounded down to the nearest multiple of 16.
Also the values taken by these numbers can be negative as well as positive.
graphics mode X range Y range
low -320 to 320 -200 to 200
medium -640 to 640 -200 to 200
high -640 to 640 -400 to 400
Any points in the destination outside the normal screen are simply not
copied on the screen.
The Screen As A String
SCREEN$ There are two forms of this command:
s$=SCREEN$(scrn,x,y to x2,y2)
The SCREEN$ function loads the area of screen defined with x,y and x2,y2
into a string. As usual scrn can refer to a memory bank or an address and
as with SCREENCOPY the x coordinates are automatically rounded down to
the nearest multiple of 16.
SCREEN$(scrn,x,y)=a$
This instruction copies a screen area from the string a$ to the screen
scrn, starting at the coordinates x,y. As usual scrn can refer to a screen
address or a bank number and that x coordinates are rounded down to the
nearest multiple of 16. WARNING This command only works with strings that
were defined using the other SCREEN$ function.
Scrolling The Screen
DEF SCROLL n,x,y to x2,y2,dx,dy
Allows you to define up to 16 different scrolling zones. Each of these
is associated with a specific scrolling operation determined by the variables
dx and dy. n denotes the number of the zone and can range from 1-16.x,y
to x2,y2 refer to the area to be scrolled. dx denotes the number of pixels
the zone will be shifted horizontally, a positive value results in a scroll
to the right and a negative value results in a scroll to the left. Similarly
dy denotes the vertical scrolling, a positive value results in the screen
scrolling down and a negative value in the screen scrolling up.
SCROLL n
The SCROLL command scrolls the screen in accordance with the values previously
specified with the DEF SCROLL instruction. n is the scroll zone.
Screen Synchronisation
WAIT VBL
The WAIT VBL instruction halts the ST until the next vertical blank is
performed. It is commonly used after a PUT SPRITE or SCREEN SWAP instruction
and results in flicker free and smoother graphics.
SYNCHRO
Stos basic performs all sprite movements every 50th of a second.
This generally works fine, but occasionally it leads to a synchronisation
problem. There are three forms of this instruction:
SYNCHRO OFF
Turns off the normal sprite interrupt which moves the sprites. SYNCHRO
Executes all the sprite movements exactly once.
SYNCHRO ON
Reverts the sprite movements to normal.
Compacting The Screen
STOS basic comes complete with a useful accessory which allows you to compact
any screen files stored in either Neo or Degas format into just a fraction
of their normal size. You can load the program from the accessory disc
using the line : accnew:accload "compact.acb" To compact the whole screen
use the PACK WHOLE SCREEN option from the picture menu. The file can be
saved as a raw binary file or, more usefully as a memory bank, the reason
for this being that it can then be imported directly into a Stos basic
program. In order to compact only part of the screen follow these instructions:
1 Click on a mouse button to display the whole screen. 2 Click the left
mouse button on the top left corner of the rectangle,press the right button
and hold it down whilst moving the mouse right and down, release the button
when you are happy with the size of the rectangle. At this point the whole
rectangle can be moved by pressing the left button again and holding it
while positioning the rectangle. 3 As soon as you are happy with the position
of the rectangle, press the spacebar to compress the picture. You can now
save this picture on the disc using the disc menu.
UNPACK bnk,scr
The UNPACK command restores a compacted screen stored in bank number bnk
into the screen scr. As usual scr can refer to either a bank defined as
a SCREEN or DATASCREEN, or as a screen address.
PACK
Function to pack a screen
l=PACK scr,bnk
The reverse of the UNPACK command scr refers to a memory bank or an address,
bnk refers to a bank which is to be used as a destination. After the PACK
function has been used l is loaded with the length of the compacted screen.
Special Screen Effects
APPEAR x[,y]
Enables you to produce fades between a picture stored in address x or in
bank x, and the current screen. The y value is optional and refers to the
type of fade to be used and can range from 1 to 79. fades between 172 always
result in a COMPLETE image being copied from x to the screen. Fades from
73-79 leave the final screen display slightly different from the original
in bank x.
FADE
Blend one or more colours to new colour values. This function has three
formats:
FADE speed
FADE all colours to black at the speed speed
FADE speed TO sbank
FADE the present colours to those of the specified screen, The current
colours are blended into the palette of the screen stored in sbank
FADE speed,col1,col2
FADE separate colours to a new value. You may have to use the wait command
after a FADE instruction to allow the full fade to take place. The time
that will be taken and the value that should be used for wait can be calculated
using: wait value=fade speed*7. Another way to use the FADE command results
in colours fading up to a colour and is done in the following way: fade
3,,$777,$700 Notice that there are two commas after the speed parameter,
this tells STOS that you don't wish to change the value of colour 0 and
this can be applied to any colour in the palette.
Pattern Setting
SET PATTERN a$
You can set up a user defined fill pattern with this command. a$ must contain
the fill definition which must be a 16 X 16 block. The two versions of
SET PATTERN will not work in high resolution and take the following format:
a$=screen$(physic,1,1 to 16,16):set pattern a$ This is in addition to the
other SET PATTERN format.
KEY ON/OFF
Set or clear the function key window. KEY ON Turns on the function key
window.
KEY OFF
Turns it off, you can still use the function keys as usual. versions of
SET PATTERN will not work in high resolution and take the following format:
a$=screen$(physic,1,1 to 16,16):set pattern a$ This is in addition to the
other SET PATTERN format. KEY ON/OFF Set or clear the function key window.
KEY ON
Turns on the function key window.
KEY OFF
Turns it off, you can still use the function keys as usual.