home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
games
/
gamesuite
/
!FastSpr
/
FSprHelp
/
Manual
< prev
next >
Wrap
Text File
|
1995-01-29
|
6KB
|
190 lines
FastSpr Documentation - version 3.00
=====================
FastSpr is a module occupying about 8K, designed to offer high speed sprite
plotting to the games writer. Typically it is at least twice as fast as OS
routines, whilst providing full masking and a variable clipping window. The
routines may be accessed via SWIs or direct calls.
Using FastSpr
=============
FastSpr uses a special sprite format, which provides high speed plotting.
Sprite files are most easily produced using the application FSPConv, with
which instructions are provided. Basically, you need to do the following:
o Make a SpriteFile (using !Paint) with sprites called 0,1,2,3,4...etc
o Drag this to the FSPConv icon
o Click convert.
The FastSpr files are usually about twice the size of the originating
sprite file, but may be up to six times as large, or smaller, depending on
the amount of transparent area of the sprites. See the help files with
FSPConv for full details.
Loading the Module
==================
You can load the module by either double clicking the application, or using
the command *RMLoad FastSpr:FastSpr, or whatever you can engineer for
yourself.
Loading your sprites
====================
The FastSpr file may be loaded in either of two ways:
(i) Into the RMA : Using *FastSprLoad or the SWI "FastSpr_Load"
(ii) Into user memory. There is a simple way to load the file into an
Amnesia area. See the entry on FastSpr_GetPointer in the SWIDocs file.
Typical BASIC coding:
10 *FastSprLoad 1 Filename
or
10 SYS "FastSpr_Load","Filename",1
Plotting
========
Before any FastSpr operation, select the correct MODE for the sprites you
are using. The SWI used to plot sprite is "FastSpr_Plot", number &47D00.
Remeber that for speed, the SWIs should be referred to by number, not name.
Typical BASIC coding:
10 SYS &47D00,&02000003,160,128 - Plots sprite 3 from pool 2 at coordinates
160,128.
Coordinates
===========
FastSpr uses memory coordinates. The top left of the screen is (0,0), and
the bottom right is (x-1,y-1) where x is the number of bytes in one line, and
y is the number of lines. For example, in MODE 13 (256 colour,320 by 256
pixels), (319,255) is the bottom right corner of the screen. The application
!FSPConv produces sprites for which the middle of the sprite is plotted at
the coordinates given. Negative coords and those off the screen are
acceptable.
Clipping Window
===============
The sprites are clipped (ie parts outside of the window are not plotted)
according to the window set by SWI "FastSpr_SetClipWindow".
Typical BASIC coding:
10 SYS "FastSpr_SetClipWindow",xmin,ymin,xmax,ymax
Xmin and ymin are inclusive, whereas xmax and ymax are exclusive, so the
correct window for the whole of a MODE 13 screen is 0,0,320,256.
The SWI "FastSpr_ClearWindow" fills the clip window with the current
backdrop colour, set by SWI "FastSpr_SetBackdrop" or *FastSprBackdrop.
ScreenBanks
===========
FastSpr supports switching of screen banks to provide flicker free updates.
SWI "FastSpr_Screenbank" does the job. A value of 1 supplied switches all
subsequent operations to the shadow bank (the OS bank 2), any other value to
the main bank (OS bank 1).
Typical BASIC coding:
10 b%=1
20 REPEAT loop starts
Do plotting, etc, here
30 WAIT
40 SYS &47D06,b% sets FastSpr's bank to one bank
50 SYS &6,&71,b% sets the displayed bank to the other (SWI is OS_Byte)
(55 SYS &6,&70,2-b%) only if you're using normal plotting routines as well
60 SYS &47D01 clears FastSpr's window
70 bank%=3-b% switches the banks for next time
80 UNTIL FALSE loop ends
Note : The most common problem with switching banks is neglecting to
allocate enough screen memory. No errors are produced - it just doesn’t
work.
Other Features
==============
For ultimate speed, you can call some routines directly to save time
decoding the SWI issued. The SWI "FastSpr_GetAddress" returns the addresses
of the useful routines.
Typical BASIC coding:
10 SYS "FastSpr_GetAddress",plotadr,clearadr,bankadr
...
20 A%=0
30 B%=160
40 C%=128
50 CALL plotadr
is equivalent to
10 SYS "FastSpr_Plot",0,160,128
Remember that these routines are in the RMA, so the desktop and RMTidy
commands may move the module and your addresses will no longer be valid.
Speed Considerations
====================
The following guidelines should provide maximum speed.
(1) Use sprites with as many transparent pixels as possible. A sprite with
twice as many solid pixels takes almost twice as long to plot in most cases.
(2) If you're using SWI FastSpr_ClearWindow, choose a clip window which
(best) includes the whole width of the screen, or (next best) where xmin and
xmax are multiples of 4.
(3) In BASIC refer to all SWIs by number if they need to be fast.
(4) Avoid horizontal clipping if you can. Clipping the top or bottom of a
sprite carries no time penalty, but clipping the sides may increase plotting
time to up to twice. When clipping both sides, plotting time may be x3.
What it can't cope with
=======================
(1) Sprites bigger than 255 pixels along either axis in FSP1 format.
(2) Screen modes wider than 640 pixels, or narrower than 4 (window clearing
only).
To avoid problems, the following may be helpful.
(1) Make sure you are in the right mode for your sprite.
(2) Don't set clip windows and then change mode (which resets them).
(3) Don't chop up your machine with an axe.
(4) Don't forget that the module uses non-standard coordinates.
Conditions
==========
This version of FastSpr may be freely used and distributed for commercial
or non-commercial applications. If you can distribute the whole application
and the application !FSPConv with your software then so much the better, but
otherwise just include whatever you need. You must not remove my copyright
notice from the module.
This software is supplied as is, and no liability will be accepted for loss
or damage of any kind arising from its use or misuse.
Andy Southgate, 5th Nov 1993. Updated 16th October 1994.