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