home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / multimedia / b152_1 / !FastSpr / FSprHelp / Technical < prev   
Text File  |  1993-11-27  |  5KB  |  116 lines

  1. FastSpr Technical Info
  2. ======================
  3.  
  4.   FastSpr uses a bit more memory for its sprites than RISC OS, and reaps the benefit with higher plotting speed and built in masking.
  5.  
  6. The Plotting Code
  7. =================
  8.  
  9.   FastSpr data is stored as one 32 bit word per pixel; the 8 LSBs are the colour, and the 24 MSBs are the offset in bytes of this pixel from the top left of the sprite.
  10.  
  11.             3 bytes            1 byte
  12.     /-----------------------\ /------\
  13.             offset             colour
  14.  
  15.   The data can be lifted from memory and written to the screen using the followng code:
  16.  
  17. LDMIA R10!,{R0-R9}
  18. STRB R0,[R11,R0,LSR #8]
  19. STRB R1,[R11,R1,LSR #8]
  20. STRB R2,[R11,R2,LSR #8]
  21. etc etc....
  22.  
  23.   Here the data is at address R10, and the screen address of the top left of the sprite is R11.  In this way, data is transferred for one-and-a-bit instructions per pixel, and masking is automatic.
  24.  
  25. File Format
  26. ===========
  27.  
  28.   The file format is as follows:
  29.  
  30. [word]       the string "FSP1" - Identifies this as FastSpr type 1
  31. [word]       zero
  32. [word]       zero
  33. [word]       number of sprites
  34.  
  35. [word]       offset to sprite 0 from the start of the file
  36. [word]       offset to sprite 1
  37. [words]      ....
  38. [word]       offset to last sprite
  39.  
  40.   Sprite block
  41.  
  42. [byte]       x size
  43. [byte]       y size
  44. [byte]       x offset - which will be subtracted from the given x coord
  45. [byte]       y offset - same, from the y coord
  46. [word]       offset to start of first line of sprite data
  47.            - offsets here are from the start of the sprite block
  48. [word]       offset to start of second line of sprite data
  49.            - which is directly after the end of the first line
  50. [words]      ....
  51. [word]       offset to end of last line of sprite data
  52.  
  53. words        sprite data
  54.  
  55.   End of sprite block
  56.  
  57.  
  58.   Naturally, each sprite has its own sprite block, pointed to by its own offset.  The offsets in the sprite block are used for fast vertical clipping.  It's definitely best to produce FastSpr files using the application !FSPConv or similar, and edit the program if you need anything different from the standard conversion.
  59.  
  60. FastSpr's Variables
  61. ======================
  62.  
  63.   All of these are 32 bit words, stored at the address returned in R4 by SWI "FastSpr_GetAddress".
  64.  
  65. R4+0  Start of screen memory
  66. R4+4  Amount of screen memory
  67. R4+8  Vertical pixel resolution
  68. R4+12 Number of bytes in one line
  69.       = horizontal pixel resolution if a 256 colour mode
  70. R4+16 Size of the current mode in bytes
  71. R4+20 The start of the screen bank FastSpr is using at the moment
  72. R4+24 Address of sprite data
  73. R4+28 Clip window :  minimum x } Inclusive
  74. R4+32 Minimum y                }
  75. R4+36 Maximum x } Exclusive
  76. R4+40 Maximum y }
  77. R4+44 Backdrop colour, repeated four times ie &CFCFCFCF for colour &CF.
  78.  
  79. The mode-dependant variables are updated upon a mode changed, as is the clip window.  The clip window, screen bank and datastart may be written, to provide faster versions of the relavent SWIs.  Setting dodgy clip windows, which would otherwise be screened out by the SWI, may lead to address exceptions or worse.
  80.  
  81. SWI Documentation
  82. =================
  83.  
  84.   SWI "FastSpr_Plot"  :  Takes the sprite number in R0, and the coords in R1 & R2.  Returns promptly if the sprite is fully off the screen.
  85.  
  86.   SWI "FastSpr_ClearWindow"  :  Fills the current clip window, on the current screen bank, with the backdrop colour.  Is unlikely to produce a correctly filled window less than 4 pixels wide.
  87.  
  88.   SWI "FastSpr_SetClipWindow"  :  R0 = min x, R1 = min y, R2 = max x, R3 = max y.  Bad clip windows are trapped.  Clip windows are reset to full screen after a mode change.
  89.  
  90.   SWI "FastSpr_Load"  :  R0 must point to a valid filename.  File is loaded into the RMA if there’s room, otherwise an error is returned.
  91.  
  92.   SWI "FastSpr_GetAddress"  :  Returns addresses of routines which may need to be accessed quickly.  When used in this way, the routines preserve only R10-R13.  The SWI returns the following:
  93.  
  94. R0  Address to call for plot.
  95. R1  Address to call for clearwindow.
  96. R2  Address to call for screenbank changes.
  97.  
  98. R4  Address of the variables.
  99.  
  100. Most of the other module functions can be emulated by writing to the variable block pointed to by R4.  All code can be executed in user or supervisor mode.
  101.  
  102. Incidentally, to branch-link to a register, use:
  103.  
  104.  MOV R14,PC
  105.  MOV PC,R0    - for a branch to R0
  106. ...code continues
  107.  
  108.   SWI "FastSpr_SetBackdrop"  :  Sets the backdrop colour used by "FastSpr_ClearWindow".  R0 should contain the colour number 0-255 when the SWI is issued.
  109.  
  110.   SWI "FastSpr_ScreenBank"  :  Subsequently, FastSpr will use the normal screenbank if R0<>1, or the shadow bank if R0=1.  The normal bank is selected after a mode change.  Note that FastSpr will not check if screen memory is actually there before trying to write to it, so it’s best to make sure first.
  111.  
  112.   SWI "FastSpr_SpritesAreAt"  :  Sets FastSpr’s address of sprite data (vars+24) to a value passed in R0.  The file validity is checked when a plot command is issued.
  113.  
  114.   All of these SWIs should preserve all registers excluding R0.  The module supports the command *Help FastSprSWIs which provides a handy list of the SWIs.
  115.  
  116.