BlendTable

Introduction and Overview

The BlendTable module was introduced in 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.

SWI Calls

BlendTable_GenerateTableSWI &56280
Generate a table of blended palette entries
R0=Flags:
Bit(s)Meaning
0Source sprite is a pointer to a sprite, not a pointer to a name
1Destination sprite is a pointer to a sprite, not a pointer to a name
2Lock table after creation
3-31Reserved, must be 0
R1=Source mode, or pointer to source sprite area
R2=0, or pointer to source sprite/sprite name
R3=Destination mode, or pointer to destination sprite area
R4=0, or pointer to destination sprite/sprite name
R5=Translucency factor (0-255): 0 for opaque sprites, 255 for transparent sprites; that is, increasing values reduce the opacity of source (or, in converse terms, increase the translucency of the source)
R6=Pointer to buffer for table, or 0 to return size required (may be omitted if locking area)
R0=Number of colours in source
R1=Number of colours in destination
R2=Size of buffer required (if R6 = 0 on entry), or size of buffer used (if R6 was a pointer on entry)
R6=Preserved (if R0 bit 2 clear), or pointer to cached data buffer (if R0 bit 2 set)
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

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 <translucency factor>:(255-<translucency factor>).

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. If bit 2 is set, then the value in R6 on entry will be ignored (that is, no user buffer is required) and space will be allocated by the BlendTable module. A pointer to the buffer will be returned in R6 on exit and the client may use this as it wishes until the next mode change or until the buffer is unlocked. The buffer should be treated as read only.

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

BlendTable_UnlockTableSWI &56281
Unlock a table previously locked by BlendTable_GenerateTable
R0=Pointer to cached data buffer to unlock
R0preserved
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This SWI is used to unlock a table previously locked by setting bit 2 on entry to SWI BlendTable_GenerateTable.