Introduction and Overview
Since Select 3 additional mask operations are available for alpha-channel sprites. These allow the alpha channel to be added or removed using a new SpriteOp call.
Technical Details
Alpha-channel removal
When removing the mask the 'cut off point' given in bits 0-7 will be used to decide which pixels will be masked and which will be solid. Any alpha-channel values which match or exceed the cut off point will be made solid. Any values which are below the cut off point will be made masked. The special value 0 is used to indicate that the operation should only reduce the mask if it is already binary - that is, if it consists of totally solid and totally masked pixels.
If bit 8 is set, the special case of a totally solid image will be reduced to no mask at all.
Examples on different sprite types :
| Sprite | Result |
|---|---|
| Sprite with solid mask (all &FF) | Will be reduced to 1bpp if b8 clear. Will be removed if b8 set. |
| Sprite with binary mask (all &FF or &00) | Will be reduced to 1bpp if b0-7 clear. Will be reduced to 1bpp with cutoff if any b0-7 set. |
| Sprite with variable mask (any values) | Will be ignored if b0-7 clear. Will be reduced to 1bpp with cutoff if any b0-7 set. |
The most usual use of this call would be to set bit 8 to remove the mask if it serves no purpose and to set the cut-off point at 128, making this a binary mask at the half-way point.
Alpha-channel promotion
Sprites may be promoted to alpha channel by setting bit 31. Bits 0-8 have no meaning when adding an alpha channel. If a mask already exists it will be promoted to alpha-channel. If no mask is present, the sprite will be promoted to be alpha-channel and a completely solid mask added.
Typical operations
Some typical operations that you might wish to perform are listed below, together with the method of achieving them :
- Add an alpha-channel mask to an existing 1bpp sprite: OS_SpriteOp 38 (&26), flags = b31
- Convert an alpha-channel sprite to a form that can be used on pre-Select 3 systems: OS_SpriteOp 38 (&26), flags = b8 + 128
- Reduce an alpha-channel sprite to its most compact form: OS_SpriteOp 38 (&26), flags = b8 + 128
- Remove an alpha-channel mask: OS_SpriteOp 30 (&1E). Note that this leaves the sprite as an alpha-channel sprite. You will have to modify the sprite type to remove the alpha-channel bit (bit 31 of the sprite mode) if you wish to use a 1 bpp mask.
SWI Calls
| R0 | = | Reason code (38 + area type) | |||||||||||||||
| R1 | = | Pointer to sprite area | |||||||||||||||
| R2 | = | Pointer to sprite, or pointer to sprite name | |||||||||||||||
| R3 | = | Flags:
| |||||||||||||||
| R3 | = | 0 if no area size change was necessary; additional space required if call failed (V set) |
This call is used to add or remove an alpha-channel mask on a sprite. This call will only function on 'new format' sprites - those using the sprite type. Operations on 'old format' sprites - those defined using mode numbers - will be faulted. The sprite type will have been modified by this call - there is no need for users of this call to modify the sprite data itself.