home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / f / fastspr / !FastSpr / FSprHelp / Manual next >
Encoding:
Text File  |  1993-11-05  |  6.7 KB  |  159 lines

  1. FastSpr Documentation - version 2.00
  2. =====================
  3.  
  4.   FastSpr is a module occupying about 5K, 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.
  5.  
  6. Using FastSpr
  7. =============
  8.  
  9.   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:
  10.  
  11.   o  Make a SpriteFile (using !Paint) with sprites called 0,1,2,3,4...etc
  12.  
  13.   o  Save this in the same directory as !FSPConv
  14.  
  15.   o  Run !FSPConv
  16.  
  17.   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.  !FSPConv treats colour 0 as transparent, and the more pixels which have colour 0, the smaller the FastSpr file.
  18.  
  19. Loading the Module
  20. ==================
  21.  
  22.   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.
  23.  
  24. Loading your sprites
  25. ====================
  26.  
  27.   The FastSpr file may be loaded in either of two ways:
  28.  
  29. (i)  Into the RMA    : Using *FastSprLoad or the SWI "FastSpr_Load"
  30. (ii) Into user memory: For example, DIMming space from basic, loading the file into that space, and using SWI "FastSpr_SpritesAreAt" to tell FastSpr where they are.
  31.  
  32. Typical BASIC coding:
  33.  
  34. 10 *FastSprLoad Filename
  35.  
  36. or
  37.  
  38. 10 SYS "FastSpr_Load","Filename"
  39.  
  40. or
  41.  
  42. 10 SYS "OS_File",&5,"Filename" TO ,,,,length  -  get the file length
  43. 20 DIM sprites length                         -  make space for it
  44. 30 OSCLI "Load Filename "+STR$~(sprites)      -  load it in
  45. 40 SYS "FastSpr_SpritesAreAt",sprites             -  tell FastSpr
  46.  
  47. Plotting
  48. ========
  49.  
  50.   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.
  51.  
  52. Typical BASIC coding:
  53.  
  54. 10 SYS &47D00,0,160,128  - Plots sprite 0 at coordinates 160,128.
  55.  
  56. Coordinates
  57. ===========
  58.  
  59.   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.
  60.  
  61. Clipping Window
  62. ===============
  63.  
  64.   The sprites are clipped (ie parts outside of the window are not plotted) according to the window set by SWI "FastSpr_SetClipWindow".
  65.  
  66. Typical BASIC coding:
  67.  
  68. 10 SYS "FastSpr_SetClipWindow",xmin,ymin,xmax,ymax
  69.  
  70. 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.
  71.  
  72.   The SWI "FastSpr_ClearWindow" fills the clip window with the current backdrop colour, set by SWI "FastSpr_SetBackdrop" or *FastSprBackdrop.
  73.  
  74.  
  75. ScreenBanks
  76. ===========
  77.  
  78.   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).
  79.  
  80. Typical BASIC coding:
  81.  
  82. 10 b%=1
  83. 20 REPEAT               loop starts
  84.  
  85. Do plotting, etc, here
  86.  
  87. 30 WAIT
  88. 40 SYS &47D06,b%     sets FastSpr's bank to one bank
  89. 50 SYS &6,&71,b%     sets the displayed bank to the other (SWI is OS_Byte)
  90. (55 SYS &6,&70,2-b%) only if you're using normal plotting routines as well
  91. 60 SYS &47D01        clears FastSpr's window
  92. 70 bank%=3-b%        switches the banks for next time 
  93.  
  94. 80 UNTIL FALSE          loop ends
  95.  
  96.   Note : The most common problem with switching banks is neglecting to allocate enough screen memory.  No errors are produced - it just doesn’t work.
  97.  
  98. Other Features
  99. ==============
  100.  
  101.   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.
  102.  
  103. Typical BASIC coding:
  104.  
  105. 10 SYS "FastSpr_GetAddress",plotadr,clearadr,bankadr
  106. ...
  107. 20 A%=0
  108. 30 B%=160
  109. 40 C%=128
  110. 50 CALL plotadr
  111.  
  112. is equivalent to
  113.  
  114. 10 SYS "FastSpr_Plot",0,160,128
  115.  
  116.   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.
  117.  
  118. Speed Considerations
  119. ====================
  120.  
  121.   The following guidelines should provide maximum speed.
  122.  
  123. (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.
  124.  
  125. (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.
  126.  
  127. (3)  In BASIC refer to all SWIs by number if they need to be fast, or use direct calls from machine code. 
  128.  
  129. (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.
  130.  
  131. What it can't cope with
  132. =======================
  133.  
  134. (1)  Sprites bigger than 255 pixels along either axis.
  135.  
  136. (2)  Screen modes wider than 640 pixels, or narrower than 4 (window clearing only).
  137.  
  138. (3)  Commands such as MODE 128+13 will cause FastSpr to misread the start of screen memory.  Use MODE 15 followed by MODE 13 to reserve two screenbanks.
  139.  
  140.   To avoid problems, the following may be helpful.
  141.  
  142. (1)  Make sure you are in the right mode for your sprite.
  143.  
  144. (2)  Don't set clip windows and then change mode (which resets them).
  145.  
  146. (3)  Don't chop up your machine with an axe.
  147.  
  148. (4)  Don't forget that the module uses non-standard coordinates.
  149.  
  150. (5)  Errors of the form 'Address exception at &18228F4' (or some similar number) are usually down to FastSpr trying to write outside the screen.  Check that your sprite file is OK and you have enough screen memory etc.
  151.  
  152. Conditions
  153. ==========
  154.  
  155.   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.
  156.   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.
  157.  
  158. Andy Southgate, 5th Nov 1993.
  159.