Skip to content

palettelib

A palette is a Blitz object, numbered from 0, that holds a list of colours and its colour cycles. LoadPalette reads one from an IFF ILBM file, DecodePalette from such a file included in the program, and InitPalette, PalRGB, AGAPalRGB and PaletteRange make one in the program. Changing a palette object does not change the display: Use Palette or ShowPalette copy its colours to the used screen (in Amiga mode) or to the used slice (in Blitz mode).

InitPalette 0,32
PaletteRange 0,0,31,0,0,0,255,128,0
ShowPalette 0

RGB, Red, Green and Blue set and read a colour of the screen or slice directly, without a palette object, with components from 0 to 15. From Kickstart 3.0 on (exec version 39), AGARGB, AGARed, AGAGreen and AGABlue do the same for the used screen with components from 0 to 255, and AGAPalRGB sets a colour of a palette object that way. A palette holds 8 bits per component, so it keeps AGA colours exactly; PalRGB stores a component of 0 to 15 as 0 to 255.

FadePalette and MixPalette compute a new palette from one or two others, for fading in and out. Cycle lets the colour cycles of a palette run on the used screen, CyclePalette moves them one step in the palette object only, for displays of the display library.

With runtime error checking, a colour or component out of range and a screen or slice that is not there are errors.

Based on the palettelib guide by Acid Software.

Library number 156. It manages Palette objects, by default at most 4 (the compiler options set the maximum).

Commands

AGABlue

The blue component, from 0 to 255, of a colour register of the used screen. It needs Kickstart 3.0 or later (exec version 39).

Function, result .w. Help text: (Colour Register)
Arguments: .w

AGAGreen

The green component, from 0 to 255, of a colour register of the used screen. It needs Kickstart 3.0 or later (exec version 39).

Function, result .w. Help text: (Colour Register)
Arguments: .w

AGAPalRGB

Sets a colour of a palette object, with components from 0 to 255. The palette grows if needed; the display changes with the next Use Palette or ShowPalette.

Statement. Help text: Palette#,Colour Register,Red,Green,Blue
Arguments: .w, .w, .w, .w, .w

AGARed

The red component, from 0 to 255, of a colour register of the used screen. It needs Kickstart 3.0 or later (exec version 39).

Function, result .w. Help text: (Colour Register)
Arguments: .w

Without a used screen this is the error “Uninitialized Screen”.

AGARGB

Sets a colour register of the used screen to components from 0 to 255. It needs Kickstart 3.0 or later (exec version 39) and works in Amiga mode only.

Statement. Help text: Colour Register,Red,Green,Blue
Arguments: .w, .w, .w, .w

Blue

The blue component, from 0 to 15, of a colour register of the used screen (Amiga mode) or slice (Blitz mode).

Function, result .w. Help text: (Colour Register)
Arguments: .l

Cycle

Lets the colour cycles of a palette run on the used screen, in the background, until StopCycle. Amiga mode only.

Statement. Help text: Palette#
Arguments: .w

CyclePalette

Moves the colours of the cycles of a palette that are due by one step, in the palette object only; nothing is shown. Call it once per frame and show the palette, for example with a display of the display library.

Statement. Help text: Palette#
Arguments: .w

DecodePalette

As LoadPalette, but reads the IFF ILBM data from memory, for example from a file included in the program with IncBin.

Statement. Help text: Palette#,MemoryLocation[,Palette Offset]
2 forms:

  • .w, .l, .w
  • .w, .l

A palette too small for the colours at the offset grows and keeps its colours, as with PalRGB. A file that is not an IFF ILBM is the error “Can’t Open IFF”, one without colours “Can’t find IFF ‘CMAP’”.

DuplicatePalette

Copies the colours, not the cycles, of SrcPalette# into DestPalette#, which gets the same number of colours.

Statement. Help text: SrcPalette#,DestPalette#
Arguments: .w, .w

FadePalette

Multiplies every colour of SrcPalette# by Brightness and puts the result into DestPalette#; 1 keeps the colours, 0 makes them black, and values above 1 brighten them up to full brightness.

Statement. Help text: SrcPalette#,DestPalette#,Brightness.q
Arguments: .w, .w, .q

Nothing happens when the destination has fewer colours than the source. Called in a loop with a falling brightness, followed by ShowPalette, it fades the display out.

Green

The green component, from 0 to 15, of a colour register of the used screen (Amiga mode) or slice (Blitz mode).

Function, result .w. Help text: (Colour Register)
Arguments: .l

InitPalette

Gives a palette room for NumColors colours, all black; its old colours are freed.

Statement. Help text: Palette#,NumColors
Arguments: .w, .w

The colour cycles set for the palette with SetCycle stay as they are.

LoadPalette

Loads the colours and colour cycles of an IFF ILBM file into a palette object, from colour register Palette Offset on if it is given. The display does not change. Amiga mode only.

Statement. Help text: Palette#,Filename$[,Palette Offset]
2 forms:

  • .w, $
  • .w, $, .w

The offset helps for sprite colours, which start at colour register 16. A file that cannot be opened is the error “Can’t Open IFF”, a file without colours the error “Can’t find IFF ‘CMAP’”.

MixPalette

Mixes two palettes into DestPalette#, fraction of the first and the rest of the second; 1 gives the first palette, 0 the second.

Statement. Help text: Palette#,Palette#,DestPalette#,fraction
Arguments: .w, .w, .w, .q

As many colours as the first palette has are written into the destination, which is not checked; make sure it has room for them, for example with InitPalette.

NewPaletteMode

With On, Use Palette only makes the palette the used one and leaves the display alone; with Off, the start value, it also shows the palette as ShowPalette does.

Statement. Help text: On|Off
Arguments: .w

Palette

The object of a palette, its colours and colour cycles, as the introduction describes.

Object name. Help text: colour and cycling information

PaletteRange

Fills the colours from StartCol to EndCol of a palette with a gradient from r0,g0,b0 to r1,g1,b1, components from 0 to 255.

Statement. Help text: Palette#,StartCol,EndCol,r0,g0,b0,r1,g1,b1
Arguments: .w, .w, .w, .w, .w, .w, .w, .w, .w

Nothing happens when EndCol is less than StartCol or the range is larger than the palette. With StartCol equal to EndCol, that colour gets r0,g0,b0.

PalRGB

Sets a colour of a palette object, with components from 0 to 15. The palette grows if needed; the display changes with the next Use Palette or ShowPalette.

Statement. Help text: Palette#,Colour Register,Red,Green,Blue
Arguments: .w, .w, .w, .w, .w

Red

The red component, from 0 to 15, of a colour register of the used screen (Amiga mode) or slice (Blitz mode).

Function, result .w. Help text: (Colour Register)
Arguments: .l

RGB

Sets a colour register of the used screen (Amiga mode) or slice (Blitz mode) to components from 0 to 15. No palette object changes.

Statement. Help text: Colour Register,Red,Green,Blue
Arguments: .w, .w, .w, .w

SetCycle

Sets colour cycle number Cycle (0 to 6) of a palette, for the colours from Low Colour to High Colour. Speed goes from -1 to 1; 1, the value without Speed, moves the colours one step per frame, and a negative speed moves them the other way.

Statement. Help text: Palette#,Cycle,Low Colour,High Colour[,Speed]
2 forms:

  • .w, .w, .w, .w
  • .w, .w, .w, .w, .q

Cycles must be set in order: a cycle more than one after the last one set is the error “Cycles must be added in order, you silly sausage!”.

ShowPalette

Copies the colours of a palette to the used screen (Amiga mode) or to the used slice (Blitz mode), as many as the slice has.

Statement. Help text: Palette#
Arguments: .w

Before Kickstart 3.0 (exec version 39), a screen gets at most 32 colours, with 4 bits per component.

StopCycle

Stops the colour cycling that Cycle started.

Statement. No help text.
No arguments.

A later Cycle starts the cycling again.