home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
No Fragments Archive 10: Diskmags
/
nf_archive_10.iso
/
MAGS
/
POWERMAG
/
POWER16.MSA
/
POWER_16
/
SCRNSWAP.PWR
< prev
next >
Wrap
Text File
|
1985-11-20
|
5KB
|
107 lines
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~ How to perform screen swapping ~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BY CHRIS SHARP
When professional programmers start
making a new game, one of the first
things that they do is to set up a
seperate PHYSICAL and LOGICAL screen
within the game. The physical screen
is the one that you can actually see,
while the LOGICAL one stays hidden.
Using these two screens together,
flicker free graphics can be created
in even the fastest of games.
Graphics updates only take place on
the LOGICAL screen. This means that
you can draw graphics in the LOGICAL
screen, and then transfer them to the
PHYSICAL screen when a VERTICAL BLANK
is occuring. This makes sure that the
game player doesn't see the graphics
being drawn until they are complete,
which means that they wont see any
graphics flicker.
Consider the following program -:
10 KEY OFF:CURS OFF:HIDE ON:CLICK OFF
20 FLASH OFF
30 LOGIC=BACK
40 SPRITE 1,100,100,1
50 SCREEN SWAP:WAIT VBL
60 GOTO 50
This is a very crude version of the
SCREEN SWAP technique, but serves
well as an example.
Line 30 of the program simply tells
the computer not to draw any grahics
on the PHYSICAL screen.
Line 40 displays a sprite on the
screen, providing that there is a
sprite bank loaded into STOS memory
bank 1.
Although the program will run too
quickly for you to notice, you wont
see the sprite on the screen until
line 50, when the SCREENSWAP command
takes place. Normally the sprite
would be displayed almost instantly,
but in this example we have told STOS
not to drawn any sprites on the
PHYSICAL screen.
The WAIT VBL command in line 50
simply makes sure that the graphics
operations are performed correctly.
Line 60 Simply loops the program back
to line 50.
Supposing we were to add a movement
command to this code. Normally, when
we are displaying sprites, AND moving
them they tend to flicker. Using the
SCREEN SWAPPING technique, we can
completely eliminate this flicker,
and consequently, the program looks
better.
Add the following lines to the
program above.
45 MOVE X1,"(1,1,100)(1,-1,100)L"
46 MOVE ON 1
These 2 lines add animation to the
above program. You will notice that
because we already have seperate
LOGICAL and PHYSICAL screens, that
the graphics are smooth. Try taking
out the LOGIC=BACK command and the
SCREEN SWAP : WAIT VBL commands. You
will notice that the graphics have
a noticable shudder every now and
then.
Remember, that before you try typing
this program in to the computer, to
load a set of sprites into the sprite
bank of STOS Basic. If you do not,
the screen will simply stay blank.
To stop the program, press the
CONTROL and the C key together. This
has the action of halting the code.
Now, simply press the UNDO key on the
computer TWICE and the screen will
be back to normal.