This article was originally written for the French fan club, ARMada, and covers the following topics:
All Basic routines referred to are on the Archive magazine disc. They have been developed with OS 3.6, so I am sorry if you haven't upgraded your OS to that level yet, but this information is ready for when you do.
Sprites with 256 true-colour palette
Our first problem is how to deal with 256 true-colour palette sprites. I will further designate these sprites as 256 true-colour sprites to distinguish them from 256 pseudo-colour sprites. From the desktop iconbar, you can select two 256-colour modes:
There are many ways to create a 256 true-colour sprite.
As an example, a 60 pixel × 60 pixel sprite called 'test256c' has been created by the same process, but it has then been edited with Paint to add a pattern and a mask. Part of the PRM code supplied on page 1.833 has been used to build this application. OS 3.6 doesn't provide a routine to define the size of a user sprite area to contain sprites to be created. In this application, the memory allocated has been over-sized - I will talk about this problem another time.
To finish this section, one final trick: to discriminate quickly between 256 true-colour sprites and 256 pseudo-colour sprites you just try to edit the palette with Paint. If you succeed, you are editing a 256 true-colour sprite.
Plotting any sprites in any mode
I want to move on to explain how to plot sprites in any native modes onto a screen of any mode.
This issue is very important should you want to develop an application. At one time or another, you will have to handle some redraws of window sections that may contain some sprites of your own and that you want to handle yourself. These sprites have a native format; that is to say a definition dependent on a colour mode. Dimensions are in pixels as conversion to OS units will be handled by the system when you provide the necessary info. Two universal Basic routines are proposed:
I use all old sprite types but also new sprites, such as 256 true-colour sprites dealt with earlier, and sprites with 32 thousand and 16 million colours (with no palette) where applicable. Sprites display information on their native mode and are all fitted with a mask. When a palette is attached, it has been edited while creating the sprite to change typical colours as proposed by the system and consequently to show some colour differences between both applications.
How does it work? A universal routine called 'PROCInitialiseSpriteToScreenArray()' is run to initialise both the scale and colour arrays needed as input for the command 'OS_SpriteOp 52' that plots the sprite on screen. While the scale array dimension is fixed at 16 bytes, apparently the colour array dimension never exceeds 256 bytes.
Command 'ColourTrans_GenerateTable' allows determination of the dimensions of the colour array, but I didn't use this procedure as it complicates the code for no reason.
Command 'Wimp_ReadPixTrans' is always needed to initialise the scale array. As for the colour array, it is a little bit more complicated for no obvious reason.
Command 'Wimp_ReadPixTrans' works up to 16 colours, for initialising colour arrays, but beyond 16 colour modes, use of command 'ColourTrans_ GenerateTable' is required to initialise the colour array. This command doesn't work below 256 colours on sprites with no built-in palettes. With these two arrays properly initialised, command 'OS_SpriteOp 52' can display your sprites on screen.
Next time, I will put forward an application that will make use of the same palette stored separately to plot a series of sprites originally edited with this palette, but saved with no palette attached to save disc and memory space.
Source: | Archive Magazine 13.9 |
Publication: | Archive Magazine |
Contributor: | Daniel Moyne |