3.4 Palette mode

When using palette mode with Plananarama, you can achieve a better performance than in remapping mode but it comes at the cost that you must design your script specifically for Plananarama's palette mode. For example, you must make sure that your Hollywood display is a palette display. Otherwise you obviously won't gain any performance improvement because if the Hollywood display doesn't use a palette but RGB graphics, all graphics still have to be remapped just like in remapping mode.

Here is some example code that sets up a palette display and puts Plananarama in palette mode:

@REQUIRE "plananarama", {PaletteMode = True}

Box(#CENTER, #CENTER, 320, 240)

The code does several very important steps that are necessary to take full advantage of Plananarama's palette mode: First, it creates a palette display by using the Palette tag to assign the inbuilt palette #PALETTE_AGA to the display. Alternatively, you could also create a palette display by simply assigning a palette BGPic to it, e.g. like so:

@REQUIRE "plananarama", {PaletteMode = True}
@BGPIC 1, "background.iff", {LoadPalette = True}

Since we set LoadPalette to True in the code above, your display will automatically become a palette display because its BGPic is a palette one.

The second very important thing the first code snippet does is calling SetPaletteMode() with #PALETTEMODE_PEN passed to it. This is very important because if you don't do that, Hollywood will still remap all graphics to your display's palette which is slow. Only by setting palette mode to #PALETTEMODE_PEN can you tell Hollywood to not do any remapping but just copy the raw pixels. Of course, this means that if you draw images their palette must match the display palette or you'll get wrong colors.

Finally, the code snippet calls SetDrawPen() to set a drawing pen. This step is very important if you want to draw graphics primitives like lines, rectangles, circles, and so on. If the palette mode has been set to #PALETTEMODE_PEN, Hollywood functions like Box(), Line(), Circle(), etc. will ignore the RGB color that is passed to them. Instead, they will draw using the pen that has been set using SetDrawPen(). This is why the code above will draw a white rectangle and not a black one, even though the color argument in the call to Box() defaults to black because it has been left out.

Since we have full control over the hardware color registers, we could now easily turn the white rectangle into a red one by just changing the color of palette pen 2. This can be done like this:

SetPen(2, #RED)

Then we could smoothly fade out the red rectangle to black by doing something like this:

For Local k = 32 To 0 Step -1
   SetPen(2, RGB(255 * (k/32), 0, 0))

Of course you could also cycle the palette colors and apply a completely new palette using Hollywood's SetPalette() function. Lots of things are possible in palette mode.

Another advantage of using palette mode is that your script won't require guigfx.library and render.library. To speed up drawing in palette mode, it's advised to install BlazeWCP though. See Requirements for details.

Show TOC