Introduction and Overview
Deep sprites - those of 16bpp or 24bpp depths - cannot be operated on using standard pixel translation tables. The tables necessary to operate on such sprites would be 2<<16 bytes (128k), or 4<<24 bytes (64M). Since such tables would be impractical at best, and the range of operations that are possible on such images is large, a manner in which these images can be manipulated has been implemented.
For non-deep sprites pixel translation tables are generated using ColourTrans (q.v. SWI ColourTrans_SelectTable, SWI ColourTrans_GenerateTable) or manually. This initial scheme was suitable for paletted images. It was later extended to encompass more accurate plotting of paletted images in deep modes, and to allow the translation tables to be transformed through a transfer function. The transfer function allows arbitrary translation of an RGB value to another RGB value before that value is used in calculations.
For deep sprites a similar method has been adopted. As before, a transfer function provides a conversion between one source RGB value and a destination RGB value. This allows any deep sprite to be colour transformed. Since this transformation must be performed on every pixel plotted the additional processing required for the colour transformation (henceforth called 'colour mapping', or more simply 'mapping' to distinguish it from a spatial transformations) may be much greater than a plain plot of the same graphic.
Technical Details
API changes
The interface for rendering colour mapped sprites is an extension of that used for plain plotting. Sprite operations PutSpriteScaled and PutSpriteTransformed, and JPEG operations JPEG_PlotScaled, JPEG_PlotFileScaled, JPEG_PlotTransformed and JPEG_PlotFileTransformed have updated APIs to handle the new form of colour mapping.
Colour mapping functions only apply to deep sprites. Using the functions on non-deep sprites will generate an error. Such sprites should use pixel translation tables if they wish to be colour mapped.
Colour mapping descriptor and transfer function
The colour mapping descriptor is a small structure containing the workspace and transfer function pointer. The structure has the following layout :
| Offset | Contents |
|---|---|
| 0 | Workspace to pass in R12 to transfer function |
| 4 | Pointer to transfer function |
The transfer function used by these operations is exactly the same as that used by the SWI ColourTrans_SelectTable calls (PRM 3-346). The function will be called in SVC mode with the usual supervisor stack limits. It is described under ColourMapTransfer.
SWI Calls
| R0 | = | 52 + operation type (refer to the OS_SpriteOp documentation) | ||||||||||||
| R1 | = | Pointer to sprite area | ||||||||||||
| R2 | = | Pointer to sprite name, or sprite pointer | ||||||||||||
| R3 | = | X coordinate | ||||||||||||
| R4 | = | Y coordinate | ||||||||||||
| R5 | = | Plot action; valid bits:
| ||||||||||||
| R6 | = | Pointer to scale factors (refer to the OS_SpriteOp documentation) | ||||||||||||
| R7 | = | Pointer to colour mapping descriptor | ||||||||||||
| R0 - R7 | = | Preserved |
This operation will plot a deep sprite using the colour mapping supplied.
| R0 | = | 56 + operation type (refer to the OS_SpriteOp documentation) | |||||||||
| R1 | = | Pointer to sprite area | |||||||||
| R2 | = | Pointer to sprite name, or sprite pointer | |||||||||
| R3 | = | Flags (refer to the OS_SpriteOp documentation) | |||||||||
| R4 | = | Pointer to source rectangle within sprite | |||||||||
| R5 | = | Plot action; valid bits:
| |||||||||
| R6 | = | Pointer to transformation matrix, or destination co-ordinates (refer to the OS_SpriteOp documentation) | |||||||||
| R7 | = | Pointer to colour mapping descriptor | |||||||||
| R0 - R7 | = | Preserved |
This operation will plot a deep sprite using the colour mapping supplied.
| R0 | = | Pointer to JPEG | ||||||||||||
| R1 | = | X coordinate | ||||||||||||
| R2 | = | Y coordinate | ||||||||||||
| R3 | = | Pointer to scale factors (refer to the JPEG_PlotScaled documentation) | ||||||||||||
| R4 | = | Length of image | ||||||||||||
| R5 | = | Plot flag bits:
| ||||||||||||
| R6 | = | Pointer to colour mapping descriptor | ||||||||||||
| R0 - R6 | = | Preserved |
This operation plots a JPEG using the colour mapping supplied.
| R0 | = | Pointer to filename of JPEG file | ||||||||||||
| R1 | = | X coordinate | ||||||||||||
| R2 | = | Y coordinate | ||||||||||||
| R3 | = | Pointer to scale factors (refer to the JPEG_PlotFileScaled documentation) | ||||||||||||
| R4 | = | Plot flag bits:
| ||||||||||||
| R5 | = | Pointer to colour mapping descriptor | ||||||||||||
| R0 - R5 | = | Preserved |
This operation plots a JPEG using the colour mapping supplied.
| R0 | = | Pointer to JPEG | |||||||||||||||
| R1 | = | Transformation flag bits:
| |||||||||||||||
| R2 | = | Pointer to transformation matrix, or destination co-ordinates (refer to the JPEG_PlotTransformed documentation) | |||||||||||||||
| R3 | = | Length of image | |||||||||||||||
| R4 | = | Pointer to colour mapping descriptor | |||||||||||||||
| R0 - R4 | = | Preserved |
This operation plots a JPEG using the colour mapping supplied.
| R0 | = | Pointer to filename of JPEG file | |||||||||||||||
| R1 | = | Transformation flag bits:
| |||||||||||||||
| R2 | = | Pointer to transformation matrix, or destination co-ordinates (refer to the JPEG_PlotFileTransformed documentation) | |||||||||||||||
| R3 | = | Pointer to colour mapping descriptor | |||||||||||||||
| R0 - R3 | = | Preserved |
This operation plots a JPEG using the colour mapping supplied.
Entry Points
| R0 | = | Palette entry (&BBGGRR00) |
| R12 | = | Workspace value passed when call made |
| R13 | = | Supervisor stack |
| R14 | = | Return address |
| R0 | = | Palette entry (&BBGGRR00) |
| R12 | = | May be corrupt |
| R14 | = | May be corrupt |
The transfer function should perform whatever processing is required on the palette entry passed to it. The routine may not change mode, perform any operation which might cause SpriteExtend to be threaded out of (eg VDU output) or cause the machine to block. You should return with MOV pc,lr. The transfer function will not be called for masked pixels.