Pyromaniac

Pyromaniac PRM: BlendTable

Pyromaniac PRM: BlendTable

RISC OS PyromaniacBlendTable

Introduction and Overview

The BlendTable module is new to RISC OS 4.31. It supplies facilities formerging paletted colours at arbitrary ratios. This is required for SpriteExtend to provide support for translucent sprite rendering.

FIXME: The technical details section is omitted at present. I'm sure this requires greater description.

SWI calls

BlendTable_GenerateTableSWI &56280
Generate blended palette entries table
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
R1=Source mode, or pointer to source sprite area
R2=0, or pointer to source sprite/sprite name
R3=Destinaton 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, increae 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)
R3 - R5preserved
R6=Preserved (if R0 bit 2 clear), or pointer to cached data buffer (if R0 bit 2 set)
Interrupts are disabled
Fast interrupts are enabled
Processor is in SVC mode
SWI is not re-entrant

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: translucencyfactor : (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.

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 flagged as locked
R0=Pointer to cached data buffer to unlock
R0preserved
Interrupts are disabled
Fast interrupts are enabled
Processor is in SVC mode
SWI is not re-entrant

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