<?xml version="1.0"?>
<!DOCTYPE riscos-prm PUBLIC "-//Gerph//DTD PRM documentation 1.02//EN"
                            "http://www.movspclr.co.uk/dtd/102/prm.dtd">

<riscos-prm>
<chapter title="BlendTable">
<section title="Introduction and Overview">
<p>The BlendTable module is new to RISC OS 4.31. It supplies facilities for
merging paletted colours at arbitrary ratios. This is required for
SpriteExtend to provide support for translucent sprite rendering.</p>

<p>
<fixme>The technical details section is omitted at present. I'm sure this
requires greater description.</fixme>
</p>

</section>

<section title="SWI calls">
<swi-definition name="BlendTable_GenerateTable"
                number="56280"
                description="Generate blended palette entries table"
                irqs="disabled"
                fiqs="enabled"
                processor-mode="SVC"
                re-entrant="no">

<entry>
 <register-use number="0">Flags:
   <bitfield-table>
      <bit number="0">Source sprite is a pointer to a sprite, not a pointer
to a name</bit>
      <bit number="1">Destination sprite is a pointer to a sprite, not a
pointer to a name</bit>
      <bit number="2">Lock table after creation</bit>
   </bitfield-table>
 </register-use>
 <register-use number="1">Source mode, or pointer to source sprite area
 </register-use>
 <register-use number="2">0, or pointer to source sprite/sprite name</register-use>
 <register-use number="3">Destinaton mode, or pointer to destination sprite
area</register-use>
 <register-use number="4">0, or pointer to destination sprite/sprite name
</register-use>
 <register-use number="5">Translucency factor (0-255):
   <list>
     <item><p>0 for opaque sprites</p></item>
     <item><p>255 for transparent sprites</p></item>
   </list>
   <p>That is, increasing values reduce the opacity of source (or, in
converse terms, increae the translucency of the source).</p>
 </register-use>
 <register-use number="6">Pointer to buffer for table, or 0 to return size
required (may be omitted if locking area).</register-use>
</entry>

<exit>
 <register-use number="0">Number of colours in source</register-use>
 <register-use number="1">Number of colours in destination</register-use>
 <register-use number="2">Size of buffer required (if R6 = 0 on entry), or
size of buffer used (if R6 was a pointer on entry)</register-use>
 <register-use number="3-5" state="preserved" />
 <register-use number="6">Preserved (if R0 bit 2 clear), or pointer to
cached data buffer (if R0 bit 2 set)</register-use>
</exit>

<use>
<p>This SWI is used to generate a table of 'blended' palette entries for
SpriteExtend (and other clients). The tables generated will be the product
of the sizes of the palettes in the source and destination. The terms
'source' and 'destination' merely refer to the palettes in use. The 'source'
is the palette which is being overlaid on to the 'destination'. The palettes
will be blended in the ratio: <userinput>translucencyfactor</userinput> :
(255 - <userinput>translucency factor</userinput>).</p>

<p>By setting bit 2, it is possible to lock the area in BlendTable's
workspace, preventing the cached copy from being flushed by other clients.
This ensures that the space can be used until the area is unlocked.</p>

<p>The palettes are laid out in the form destination by source. That is,
given a source palette value (<userinput>src</userinput>) and a destination
palette value (<userinput>dst</userinput>), for a destination palette of
<userinput>dstcols</userinput> colours, the blended palette value - in the
destination palette - is to be found at (<userinput>dst</userinput> *
<userinput>dstcols</userinput> + <userinput>src</userinput>).</p>

</use>

<related>
  <reference type="swi" name="BlendTable_UnlockTable" />
</related>

</swi-definition>


<swi-definition name="BlendTable_UnlockTable"
                number="56281"
                description="Unlock a table previously flagged as locked"
                irqs="disabled"
                fiqs="enabled"
                processor-mode="SVC"
                re-entrant="no">

<entry>
 <register-use number="0">Pointer to cached data buffer to unlock
</register-use>
</entry>
<exit>
 <register-use number="0" state="preserved" />
</exit>

<use>
<p>This SWI is used to unlock a table previously locked by setting bit 2 on
entry to <reference type="swi" name="BlendTable_GenerateTable" />.</p>

</use>

<related>
  <reference type="swi" name="BlendTable_GenerateTable" />
</related>

</swi-definition>

</section>

</chapter>


<!-- MetaData -->
<meta>
 <maintainer>
  <email name="Andrew Hill" address="drew.hill@tesco.net" />
 </maintainer>
 <disclaimer>
  <import document="http://www.riscos.com/prm/prm-disclaimer.xml" path="root/*" />
  <import document="http://www.riscos.com/prm/amh-disclaimer.xml" path="root/*" />
 </disclaimer>

 <history>
  <revision number="pre-1" author="AMH" date="30 Mar 2003" title="Initial
version">
    <change>Lots of bits missing; more information needed in places, etc.
</change>
  </revision>
  <revision number="pre-2" author="ROL" date="30 Mar 2003" title="Minor fix">
    <change>Fix for SWI numbers which broke build.</change>
  </revision>
  <revision number="pre-3" author="ROL" date="03 May 2003" title="Corrections">
    <change>SWI register and IRQ states updated to be correct.</change>
  </revision>
  <revision number="pre-4" author="ROL" date="09 Mar 2004" title="Corrections">
    <change>UnlockTable's description corrected.</change>
  </revision>
 </history>
</meta>
</riscos-prm>
