BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
palettelib.c File Reference
#include "blitzlib.h"
#include "blitzobj.h"
#include <stddef.h>
#include <graphics/view.h>
#include <intuition/screens.h>
#include <proto/graphics.h>

Data Structures

struct  cnode

Macros

#define __NOLIBBASE__
#define GRAPHICS_BASE_NAME   gfx
#define COLMOVES(s)
#define L_GFXA   LIB_graphicslib, BL_IFAMIGA|BL_LA6
#define L_SCRA0   LIB_screenslib, BL_IFAMIGA|BL_UA0
#define L_SCRA2   LIB_screenslib, BL_IFAMIGA|BL_UA2
#define L_SLICE   LIB_blitzcoplib, BL_IFBLITZ|BL_UA0
#define AGA_FN(code, name)
#define L(p, o)
#define W(p, o)
#define SL(p)
#define IFFCALL(tok, in0, ina0, z)
#define PAD(len)
#define COLFN(name, shift)
#define ERRTHUNK(n)

Functions

void dopalload (void)
void dopalload2 (void)
void getpal (void)
void getpal2 (void)
void docycle (void)
void dorgb (void)
void dored (void)
void dogreen (void)
void doblue (void)
void do4bitpalrgb (void)
void dopalrgb (void)
void dosetcycle1 (void)
void dosetcycle2 (void)
void dostopcycle (void)
void doaargb (void)
void make4bitrgbs (void)
void doagared (void)
void doagagreen (void)
void doagablue (void)
void showpal (void)
void newpalmode (void)
void _cyclepalette (void)
void _fadepalette (void)
 FadePalette SrcPalette#,DestPalette#,Brightness.q - the source colours times the brightness into the destination.
void _initpalette (void)
void _paletterange (void)
void _duplicatepalette (void)
void _cludgepalette (void)
void _cludgepalette2 (void)
void _mixpalette (void)
void usepal (void)
void freepal (void)
void palettelib_codeinit (void)
void palettelib_codefinit (void)
void cycleem (void)
void rgbchk (void)
void colchk (void)
void prgbchk (void)
void setcyclechk (void)
void setcyclechk2 (void)
void aargbchk (void)
void aaprgbchk (void)
void agacolchk (void)
void showpalchk (void)
void usepalchk (void)
void docyclechk (void)
 AGA_FN (doagared, "AGARed")
 AGA_FN (doagagreen, "AGAGreen")
 AGA_FN (doagablue, "AGABlue")
static APTR globalloc (ULONG size, ULONG flags)
static void globfree (APTR mem, ULONG size)
BL_ALWAYS_INLINE ULONG rep (UWORD v)
static void cycend (struct bb_palette *p)
static UBYTE * palgrow (struct bb_palette *p, UWORD c)
BL_ALWAYS_INLINE void palrgb (struct bb_palette *p, UWORD c, UWORD r, UWORD g, UWORD b)
static BLITZ_ENTRYPOINT void dopalrgb_c (UWORD c, UWORD r, UWORD g, UWORD b, struct bb_palette *p)
 AGAPalRGB Palette#,Colour Register,Red,Green,Blue - set a colour of a palette, 8 bit components.
 BLITZ_ALIAS_EP (dopalrgb, dopalrgb_c)
static BLITZ_ENTRYPOINT void do4bitpalrgb_c (UWORD c, UWORD r, UWORD g, UWORD b, struct bb_palette *p)
 PalRGB Palette#,Colour Register,Red,Green,Blue - set a colour of a palette, 4 bit components.
 BLITZ_ALIAS_EP (do4bitpalrgb, do4bitpalrgb_c)
static UWORD make4 (const struct bb_palette *p)
static UWORD make4bitrgbs_c (const struct bb_palette *p)
 make4bitrgbs (a nullsub for other libraries) - the 4 bit RGB words of a palette, for LoadRGB4.
static ULONG codeinit_c (ULONG callerd0, struct Library *gfx)
 Library init - agamode = ExecVersion >= 39 (environlib), no cycling.
static void codefinit_c (void)
 Library finit (cycoff) - cycling interrupt off, cycle list freed.
static void loadthepal (const UBYTE *name, struct bb_palette *p, UWORD off)
static void getpal_c (const UBYTE *name, struct bb_palette *p)
 getpal (a nullsub for other libraries) - load the CMAP and CRNG chunks of an IFF file into a palette, as LoadPalette.
static void getpal2_c (UWORD off, const UBYTE *name, struct bb_palette *p)
 getpal2 (a nullsub for other libraries) - getpal with a palette offset.
static void dopalload_c (const UBYTE *name, struct bb_palette *p)
 LoadPalette Palette#,Filename$ - load the colours (CMAP) and colour cycles (CRNG) of an IFF file into a palette (Amiga mode only).
 BLITZ_ALIAS (dopalload, dopalload_c)
static void dopalload2_c (const UBYTE *name, UWORD off, struct bb_palette *p)
 LoadPalette Palette#,Filename$,Palette Offset - as LoadPalette, the colours from the given colour register on (Amiga mode only).
 BLITZ_ALIAS (dopalload2, dopalload2_c)
static void initpalette (struct bb_palette *p, UWORD n)
static void _initpalette_c (UWORD n)
 InitPalette Palette#,NumColors - give a palette new, cleared colour data for NumColors colours.
 BLITZ_ALIAS (_initpalette, _initpalette_c)
static void cludgepalette (UBYTE *chunk, UWORD off)
static void _cludgepalette_c (UBYTE *mem, UWORD off)
 DecodePalette Palette#,MemoryLocation,Palette Offset - take the colours (CMAP) and cycles (CRNG) of an IFF ILBM in memory.
static void _cludgepalette2_c (UBYTE *mem)
 DecodePalette Palette#,MemoryLocation - as DecodePalette with offset 0.
 BLITZ_ALIAS (_cludgepalette, _cludgepalette_c)
 BLITZ_ALIAS (_cludgepalette2, _cludgepalette2_c)
static void freepal_c (void)
 _free of the Palette object (Free Palette, program end) - free the colour data, no cycles.
static void dosetcycle2_c (UWORD cyc, UWORD lo, UWORD hi, ULONG speed, struct bb_palette *p)
 SetCycle Palette#,Cycle,Low Colour,High Colour,Speed - set a colour cycle of a palette.
 BLITZ_ALIAS (dosetcycle2, dosetcycle2_c)
static void dosetcycle1_c (UWORD cyc, UWORD lo, UWORD hi, struct bb_palette *p)
 SetCycle Palette#,Cycle,Low Colour,High Colour - as SetCycle with speed 1 (one step per frame).
 BLITZ_ALIAS (dosetcycle1, dosetcycle1_c)
static void newpalmode_c (UWORD m)
 NewPaletteMode On|Off - whether Use Palette shows the palette (Off, the default) or only makes it the used one (On).
 BLITZ_ALIAS (newpalmode, newpalmode_c)
static void showpal_amiga (struct bb_palette *p, APTR *scr, struct Library *gfx)
BL_ALWAYS_INLINE void showpal_blitz (struct bb_palette *p, struct bb_slice *slice)
void showpal_a (APTR *scr, struct Library *gfx)
 ShowPalette Palette#, Amiga mode - load the palette into the used screen's ViewPort.
static BLITZ_ENTRYPOINT void showpal_b (struct bb_slice *slice)
 ShowPalette Palette#, Blitz mode - write the palette into the colour moves of the used slice.
 BLITZ_EP_MARK (showpal_b)
void usepal_a (APTR *scr, struct Library *gfx)
 _use of the Palette object (Use Palette), Amiga mode - ShowPalette unless NewPaletteMode On.
static BLITZ_ENTRYPOINT void usepal_b (struct bb_slice *slice)
 _use of the Palette object (Use Palette), Blitz mode - ShowPalette unless NewPaletteMode On.
 BLITZ_EP_MARK (usepal_b)
static int cyclepal (struct bb_palette *p)
static void _cyclepalette_c (struct bb_palette *p)
 CyclePalette Palette# - move the colours of every cycle of the palette that is due by one step (in the palette only, nothing shown).
 BLITZ_ALIAS (_cyclepalette, _cyclepalette_c)
static ULONG cycleem_c (void)
static void docycle_c (APTR *scr)
 Cycle Palette# - cycle the palette's colours on the used screen (Amiga mode only).
 BLITZ_ALIAS (docycle, docycle_c)
static void dostopcycle_c (void)
 StopCycle - stop the colour cycling.
 BLITZ_ALIAS (dostopcycle, dostopcycle_c)
BL_ALWAYS_INLINE ULONG getcol_a (ULONG c, APTR *scr, struct Library *gfx, int shift)
BL_ALWAYS_INLINE ULONG getcol_b (ULONG c, struct bb_slice *slice, int shift)
 COLFN (dored, 8)
 Red(Colour Register), Green(...), Blue(...) - the 4 bit component of a colour of the used screen (Amiga mode) or slice (Blitz mode).
 COLFN (dogreen, 4)
 COLFN (doblue, 0)
static ULONG agacol (ULONG c, APTR *scr, struct Library *gfx, int i)
static ULONG doagared_c (ULONG c, APTR *scr, struct Library *gfx)
 AGARed(Colour Register) - the 8 bit red component of a colour of the used screen.
static ULONG doagagreen_c (ULONG c, APTR *scr, struct Library *gfx)
 AGAGreen(Colour Register) - the 8 bit green component, as AGARed.
static ULONG doagablue_c (ULONG c, APTR *scr, struct Library *gfx)
 AGABlue(Colour Register) - the 8 bit blue component, as AGARed.
 BLITZ_ALIAS (doagared, doagared_c)
 BLITZ_ALIAS (doagagreen, doagagreen_c)
 BLITZ_ALIAS (doagablue, doagablue_c)
static BLITZ_ENTRYPOINT void dorgb_b (UWORD c, UWORD r, UWORD g, UWORD b, struct bb_slice *slice)
 RGB Colour Register,Red,Green,Blue - set a colour of the used screen (Amiga mode) or slice (Blitz mode), 4 bit components.
 BLITZ_EP_MARK (dorgb_b)
static ULONG rep8 (UWORD v)
static void doaargb_c (UBYTE c, UWORD r, UWORD g, UWORD b, APTR *scr, struct Library *gfx)
 AGARGB Colour Register,Red,Green,Blue - set a colour of the used screen, 8 bit components (Amiga mode only).
 BLITZ_ALIAS (doaargb, doaargb_c)
static ULONG step (WORD delta, UWORD n)
static ULONG startval (WORD v)
static void _paletterange_c (UWORD start, UWORD stop, WORD r0, WORD g0, WORD b0, const WORD *args)
 PaletteRange Palette#,StartCol,EndCol,r0,g0,b0,r1,g1,b1 - a colour gradient from r0,g0,b0 at StartCol to r1,g1,b1 at EndCol.
 BLITZ_ALIAS (_paletterange, _paletterange_c)
static void _duplicatepalette_c (struct bb_palette *s)
 DuplicatePalette SrcPalette#,DestPalette# - copy the colours (not the cycles) of a palette.
 BLITZ_ALIAS (_duplicatepalette, _duplicatepalette_c)
static void _mixpalette_c (LONG f, struct bb_palette *p1, struct bb_palette *p2)
 MixPalette Palette#,Palette#,DestPalette#,fraction - mix two palettes into the destination.
 BLITZ_ALIAS (_mixpalette, _mixpalette_c)
static int rgbchk2 (UWORD r, UWORD g, UWORD b)
static void rgbchk_a_c (UWORD c, UWORD r, UWORD g, UWORD b, const ULONG *scr)
static void rgbchk_b_c (UWORD c, UWORD r, UWORD g, UWORD b, const struct bb_slice *slice)
static void aargbchk_c (UWORD c, UWORD r, UWORD g, UWORD b, const ULONG *scr)
static void showpalchk_a_c (const ULONG *scr)
static void showpalchk_b_c (const struct bb_slice *slice)
static void usepalchk_a_c (const ULONG *scr)
static void usepalchk_b_c (const struct bb_slice *slice)
static void docyclechk_c (void)
static void colchk_a_c (const ULONG *scr)
static void colchk_b_c (const struct bb_slice *slice)
static void agacolchk_c (const ULONG *scr)
static void prgbchk_c (UWORD c, UWORD r, UWORD g, UWORD b)
static void aaprgbchk_c (UWORD c, UWORD r, UWORD g, UWORD b)
static void setcyclechk_c (UWORD c, UWORD lo, UWORD hi)
static void setcyclechk2_c (UWORD c, UWORD lo, UWORD hi, LONG sp)
 ERRTHUNK (rgbchk_a)
 ERRTHUNK (rgbchk_b)
 ERRTHUNK (aargbchk)
 ERRTHUNK (showpalchk_a)
 ERRTHUNK (showpalchk_b)
 ERRTHUNK (usepalchk_a)
 ERRTHUNK (usepalchk_b)
 ERRTHUNK (docyclechk)
 ERRTHUNK (colchk_a)
 ERRTHUNK (colchk_b)
 ERRTHUNK (agacolchk)
 ERRTHUNK (prgbchk)
 ERRTHUNK (aaprgbchk)
 ERRTHUNK (setcyclechk)
 ERRTHUNK (setcyclechk2)

Variables

static struct Library * gfxbase
static WORD cycon
static struct cnode * cyclelist
static WORD agamode
static UWORD rgbs4bit [32]
static WORD palmode
static UWORD myoff
static ULONG agatable [3]
struct { 
   UWORD   count 
   UWORD   first 
   ULONG   red 
   ULONG   green 
   ULONG   blue 
   ULONG   end 
} table = { .count = 1 }
static const char mess0 [] = "Can't Open IFF"
static const char mess1 [] = "Can't find IFF 'CMAP'"
static const char mess3n [] = "Uninitialized Screen"
static const char messd [] = "Cycles must be added in order, you silly sausage!"

Macro Definition Documentation

◆ __NOLIBBASE__

#define __NOLIBBASE__

◆ AGA_FN

#define AGA_FN ( code,
name )
Value:
BLITZ_ARGS(BL_WORD); \
BLITZ_LIBS(LIB_screenslib, BL_UA0, LIB_graphicslib, BL_LA6); \
BLITZ_SUBS(code, agacolchk, 0); \
BLITZ_NAME(name, "(Colour Register)")
char * name
Definition asllib.c:150
#define BL_WORD
Definition blitzlib.h:91
#define BLITZ_AFUNCTION(t)
Definition blitzlib.h:344
#define BL_UA0
Definition blitzlib.h:211
#define BL_LA6
Definition blitzlib.h:201
void agacolchk(void)
UBYTE code[4]
Definition ridisasmlib.c:375

◆ COLFN

#define COLFN ( name,
shift )
Value:
ULONG BLITZ_ROUTINE name##_a(ULONG c BL_REG(d0), APTR *scr BL_REG(a0), \
struct Library *gfx BL_REG(a6)); \
ULONG BLITZ_ROUTINE name##_a(ULONG c BL_REG(d0), APTR *scr BL_REG(a0), \
struct Library *gfx BL_REG(a6)) \
{ \
return getcol_a(c, scr, gfx, shift); \
} \
static BLITZ_ENTRYPOINT ULONG BLITZ_ROUTINE name##_b(ULONG c BL_REG(d0), \
struct bb_slice *slice BL_REG(a0)) \
{ \
return getcol_b(c, slice, shift); \
} \
BLITZ_EP_MARK(name##_b); \
BLITZ_AB_ROUTINE(name, name##_b, " jmp _" #name "_a")
ULONG WORD UWORD c
Definition 2dlib.c:2491
#define BLITZ_ENTRYPOINT
Definition blitzlib.h:837
#define BL_REG(r)
Definition blitzlib.h:280
#define BLITZ_ROUTINE
Definition blitzlib.h:313
BL_ALWAYS_INLINE ULONG getcol_b(ULONG c, struct bb_slice *slice, int shift)
Definition palettelib.c:1272
BL_ALWAYS_INLINE ULONG getcol_a(ULONG c, APTR *scr, struct Library *gfx, int shift)
Definition palettelib.c:1264
UWORD shift
Definition spriteslib.c:170
A Slice object, 64 bytes (Blitz mode). The pointers are addresses in the copper list (0 = not there).
Definition blitzobj.h:181

◆ COLMOVES

#define COLMOVES ( s)
Value:
(*(UBYTE *const *)&(s)->colmoves)

◆ ERRTHUNK

#define ERRTHUNK ( n)
Value:
BLITZ_ERRCHK_THUNK(n, n##_c, "d0-d1/a0-a1")
ULONG WORD UWORD UWORD border ULONG ULONG struct bb_bitmap *dst void UWORD n
Definition 2dlib.c:2498
#define BLITZ_ERRCHK_THUNK(entry, cfunc, save)
Definition blitzlib.h:928

◆ GRAPHICS_BASE_NAME

#define GRAPHICS_BASE_NAME   gfx

◆ IFFCALL

#define IFFCALL ( tok,
in0,
ina0,
z )
Value:
({ \
register ULONG _d0 __asm("d0") = (in0); \
register ULONG _a0 __asm("a0") = (ina0); \
UBYTE _z; \
__asm volatile("jsr _blitz_tok+%c3\n seq %2" \
: "+d"(_d0), "+a"(_a0), "=d"(_z) : "i"(BL_TOKVAL(tok, 0)) \
: "d1", "a1", "cc", "memory"); \
(z) = _z; _d0; })
#define BL_TOKVAL(tok, form)
Definition blitzlib.h:526

◆ L

#define L ( p,
o )
Value:
(*(ULONG *)((UBYTE *)(p) + (o)))

◆ L_GFXA

#define L_GFXA   LIB_graphicslib, BL_IFAMIGA|BL_LA6

◆ L_SCRA0

#define L_SCRA0   LIB_screenslib, BL_IFAMIGA|BL_UA0

◆ L_SCRA2

#define L_SCRA2   LIB_screenslib, BL_IFAMIGA|BL_UA2

◆ L_SLICE

#define L_SLICE   LIB_blitzcoplib, BL_IFBLITZ|BL_UA0

◆ PAD

#define PAD ( len)
Value:
(((len) + 1) & ~1UL)
ULONG len
Definition asllib.c:158

◆ SL

#define SL ( p)
Value:
(&(*(struct Screen **)(p))->ViewPort)

◆ W

#define W ( p,
o )
Value:
(*(UWORD *)((UBYTE *)(p) + (o)))

Function Documentation

◆ _cludgepalette()

void _cludgepalette ( void )

◆ _cludgepalette2()

void _cludgepalette2 ( void )

◆ _cludgepalette2_c()

void _cludgepalette2_c ( UBYTE * mem)
static

DecodePalette Palette#,MemoryLocation - as DecodePalette with offset 0.

Parameters
memd1: the IFF file in memory.

◆ _cludgepalette_c()

void _cludgepalette_c ( UBYTE * mem,
UWORD off )
static

DecodePalette Palette#,MemoryLocation,Palette Offset - take the colours (CMAP) and cycles (CRNG) of an IFF ILBM in memory.

The components go into the top byte of each long; count = DIVU length/3 (the remainder stays in the upper word). Active cycles get var = the CRNG flag (1; not a bug: only the low word is used, a start value of 1 is invisible). The palette is in a3. Fixed (#1002): only ranges with bit 0 (RNG_ACTIVE) of the CRNG flags are entered, bit 1 (RNG_REVERSE) negates the rate; the original entered every range, reversed unless the flags were 1.

Fixed (#225): the chunks are walked with the pad byte of an odd length (the CMAP search, the end of the CMAP, the CRNG search); the original added the length only and read the chunk behind an odd one shifted by a byte. Fixed (#226): a palette too small for offset + count grows and keeps its colours (as PalRGB); the original re-initialised (cleared) it.

Errors: no FORM ILBM - "Can't Open IFF"; no CMAP - "Can't find IFF 'CMAP'".

Parameters
memd1: the IFF file in memory.
offd2: the palette offset.

◆ _cyclepalette()

void _cyclepalette ( void )

◆ _cyclepalette_c()

void _cyclepalette_c ( struct bb_palette * p)
static

CyclePalette Palette# - move the colours of every cycle of the palette that is due by one step (in the palette only, nothing shown).

Each cycle adds its speed to its var; at 16384 the colours low..high rotate by one (the sign of the speed is the direction).

Parameters
pa2: the palette (!libs palettelib,$1280).

◆ _duplicatepalette()

void _duplicatepalette ( void )

◆ _duplicatepalette_c()

void _duplicatepalette_c ( struct bb_palette * s)
static

DuplicatePalette SrcPalette#,DestPalette# - copy the colours (not the cycles) of a palette.

The destination (a3) is initialised to the source's number of colours first (InitPalette); nothing happens for an empty source.

Parameters
sa2: the source palette (!libs palettelib,$1280).

◆ _fadepalette()

void _fadepalette ( void )

FadePalette SrcPalette#,DestPalette#,Brightness.q - the source colours times the brightness into the destination.

Every component: MULU of its upper word (not a bug: the source is read 2 bytes early, see the top) with brightness >> 8, limited to $FF0000, << 8. Nothing happens for an empty source or a destination with fewer colours.

The original's code in assembler (the C of the loop stayed 12 % slower; its MOVEM.l loads and stores of the three components are the fastest form on the 68000): MULU takes the low word of each source long read from pdata + 2, the upper word of the component.

  • d2 br, the brightness (Quick, 1.0 = full brightness).
  • a0 s, the source palette.
  • a1 d, the destination palette.

◆ _initpalette()

void _initpalette ( void )

◆ _initpalette_c()

void _initpalette_c ( UWORD n)
static

InitPalette Palette#,NumColors - give a palette new, cleared colour data for NumColors colours.

The old data is freed. The palette is in a3. Not a bug (overflows only for palettes of 2731+ colours): the size with ADDQ.w #8.

Fixed (#229): a palette that had no colour data gets an end mark in its cycle table unless one of the 14 entries has one (a cycle SetCycle set on the empty palette stays); the original wrote none, so a palette object never used had 14 entries of 0 without an end.

Parameters
nd1: the number of colours.

◆ _mixpalette()

void _mixpalette ( void )

◆ _mixpalette_c()

void _mixpalette_c ( LONG f,
struct bb_palette * p1,
struct bb_palette * p2 )
static

MixPalette Palette#,Palette#,DestPalette#,fraction - mix two palettes into the destination.

Every component = first * fraction + second * (1 - fraction), with the upper words of the sources (+2, not a bug, see top); as many colours as the first palette has, the destination (a3) is not checked.

Parameters
fd3: the fraction (Quick, 0..1).
p1a0: the first palette.
p2a2: the second palette.

◆ _paletterange()

void _paletterange ( void )

◆ _paletterange_c()

void _paletterange_c ( UWORD start,
UWORD stop,
WORD r0,
WORD g0,
WORD b0,
const WORD * args )
static

PaletteRange Palette#,StartCol,EndCol,r0,g0,b0,r1,g1,b1 - a colour gradient from r0,g0,b0 at StartCol to r1,g1,b1 at EndCol.

The step of each component is DIVS (delta << 8)/(EndCol-StartCol). Nothing happens for EndCol < StartCol or a range larger than the palette. The palette is in a3.

Fixed (#227): StartCol = EndCol (a range of one colour) sets the start colour; the original divided by zero (DIVS, Guru 8000 0005).

Parameters
startd1: StartCol.
stopd2: EndCol.
r0d3: the start red.
g0d4: the start green.
b0d5: the start blue.
argsa2: the argument stack: r1, g1, b1 at -2, -4, -6.

◆ aaprgbchk()

void aaprgbchk ( void )

◆ aaprgbchk_c()

void aaprgbchk_c ( UWORD c,
UWORD r,
UWORD g,
UWORD b )
static

◆ aargbchk()

void aargbchk ( void )

◆ aargbchk_c()

void aargbchk_c ( UWORD c,
UWORD r,
UWORD g,
UWORD b,
const ULONG * scr )
static

◆ AGA_FN() [1/3]

AGA_FN ( doagablue ,
"AGABlue"  )

◆ AGA_FN() [2/3]

AGA_FN ( doagagreen ,
"AGAGreen"  )

◆ AGA_FN() [3/3]

AGA_FN ( doagared ,
"AGARed"  )

◆ agacol()

ULONG agacol ( ULONG c,
APTR * scr,
struct Library * gfx,
int i )
static

◆ agacolchk()

void agacolchk ( void )

◆ agacolchk_c()

void agacolchk_c ( const ULONG * scr)
static

◆ BLITZ_ALIAS() [1/18]

BLITZ_ALIAS ( _cludgepalette ,
_cludgepalette_c  )

◆ BLITZ_ALIAS() [2/18]

BLITZ_ALIAS ( _cludgepalette2 ,
_cludgepalette2_c  )

◆ BLITZ_ALIAS() [3/18]

BLITZ_ALIAS ( _cyclepalette ,
_cyclepalette_c  )

◆ BLITZ_ALIAS() [4/18]

◆ BLITZ_ALIAS() [5/18]

BLITZ_ALIAS ( _initpalette ,
_initpalette_c  )

◆ BLITZ_ALIAS() [6/18]

BLITZ_ALIAS ( _mixpalette ,
_mixpalette_c  )

◆ BLITZ_ALIAS() [7/18]

BLITZ_ALIAS ( _paletterange ,
_paletterange_c  )

◆ BLITZ_ALIAS() [8/18]

BLITZ_ALIAS ( doaargb ,
doaargb_c  )

◆ BLITZ_ALIAS() [9/18]

BLITZ_ALIAS ( doagablue ,
doagablue_c  )

◆ BLITZ_ALIAS() [10/18]

BLITZ_ALIAS ( doagagreen ,
doagagreen_c  )

◆ BLITZ_ALIAS() [11/18]

BLITZ_ALIAS ( doagared ,
doagared_c  )

◆ BLITZ_ALIAS() [12/18]

BLITZ_ALIAS ( docycle ,
docycle_c  )

◆ BLITZ_ALIAS() [13/18]

BLITZ_ALIAS ( dopalload ,
dopalload_c  )

◆ BLITZ_ALIAS() [14/18]

BLITZ_ALIAS ( dopalload2 ,
dopalload2_c  )

◆ BLITZ_ALIAS() [15/18]

BLITZ_ALIAS ( dosetcycle1 ,
dosetcycle1_c  )

◆ BLITZ_ALIAS() [16/18]

BLITZ_ALIAS ( dosetcycle2 ,
dosetcycle2_c  )

◆ BLITZ_ALIAS() [17/18]

BLITZ_ALIAS ( dostopcycle ,
dostopcycle_c  )

◆ BLITZ_ALIAS() [18/18]

BLITZ_ALIAS ( newpalmode ,
newpalmode_c  )

◆ BLITZ_ALIAS_EP() [1/2]

BLITZ_ALIAS_EP ( do4bitpalrgb ,
do4bitpalrgb_c  )

◆ BLITZ_ALIAS_EP() [2/2]

BLITZ_ALIAS_EP ( dopalrgb ,
dopalrgb_c  )

◆ BLITZ_EP_MARK() [1/3]

BLITZ_EP_MARK ( dorgb_b )

◆ BLITZ_EP_MARK() [2/3]

BLITZ_EP_MARK ( showpal_b )

◆ BLITZ_EP_MARK() [3/3]

BLITZ_EP_MARK ( usepal_b )

◆ cludgepalette()

void cludgepalette ( UBYTE * chunk,
UWORD off )
static

◆ codefinit_c()

void codefinit_c ( void )
static

Library finit (cycoff) - cycling interrupt off, cycle list freed.

The list is freed but not cleared (not a bug: only at program end).

◆ codeinit_c()

ULONG codeinit_c ( ULONG callerd0,
struct Library * gfx )
static

Library init - agamode = ExecVersion >= 39 (environlib), no cycling.

Parameters
callerd0d0: the caller's d0 (passed to ExecVersion).
gfxa0: graphics.library (!libs graphicslib,la0).
Returns
d0: agamode, the init value (-1 or 0; EXT.w: upper word from ExecVersion's d0).

◆ colchk()

void colchk ( void )

◆ colchk_a_c()

void colchk_a_c ( const ULONG * scr)
static

◆ colchk_b_c()

void colchk_b_c ( const struct bb_slice * slice)
static

◆ COLFN() [1/3]

COLFN ( doblue ,
0  )

◆ COLFN() [2/3]

COLFN ( dogreen ,
4  )

◆ COLFN() [3/3]

COLFN ( dored ,
8  )

Red(Colour Register), Green(...), Blue(...) - the 4 bit component of a colour of the used screen (Amiga mode) or slice (Blitz mode).

dored_a/_b, dogreen_a/_b, doblue_a/_b: Amiga - GetRGB4 of the used screen's ColorMap (the upper word of d0 is GetRGB4's); Blitz - the colour move of the used slice (the upper word of d0 stays). The binary takes the colour as a long.

Errors (debugger only, colchk): "Uninitialized Screen", "Uninitialized Slice".

  • c d0: the colour register.
  • scr a0: Amiga mode: the used screen (object).
  • gfx a6: Amiga mode: graphics.library.
  • slice a0: Blitz mode: the used slice.
    Result
    d0.w: the component (0-15).

◆ cycend()

void cycend ( struct bb_palette * p)
static

◆ cycleem()

void cycleem ( void )

◆ cycleem_c()

ULONG cycleem_c ( void )
static

◆ cyclepal()

int cyclepal ( struct bb_palette * p)
static

◆ do4bitpalrgb()

void do4bitpalrgb ( void )

◆ do4bitpalrgb_c()

BLITZ_ENTRYPOINT void do4bitpalrgb_c ( UWORD c,
UWORD r,
UWORD g,
UWORD b,
struct bb_palette * p )
static

PalRGB Palette#,Colour Register,Red,Green,Blue - set a colour of a palette, 4 bit components.

do4bitpalrgb - 4 bit components: n<<4|n (word), then as AGAPalRGB.

Errors (debugger only, prgbchk): "Colour must be in the range 0-31" (colour > 255, or > 31 without AGA), "RGB component out of range" (> 15).

Parameters
cd1: the colour register.
rd2: red (0-15).
gd3: green.
bd4: blue.
pa0: the palette (!libs palettelib,$1080).

◆ doaargb()

void doaargb ( void )

◆ doaargb_c()

void doaargb_c ( UBYTE c,
UWORD r,
UWORD g,
UWORD b,
APTR * scr,
struct Library * gfx )
static

AGARGB Colour Register,Red,Green,Blue - set a colour of the used screen, 8 bit components (Amiga mode only).

LoadRGB32 with one colour; each component's word r<<8|r.b in both halves.

Errors (debugger only, aargbchk): "Not an AGA machine!", "Uninitialized Screen", "Colour must be in the range 0-31" (> 255), "RGB component out of range" (> 255).

Parameters
cd0: the colour register.
rd1: red (0-255).
gd2: green.
bd3: blue.
scra0: the used screen (object; !libs screenslib,$1002).
gfxa6: graphics.library.

◆ doagablue()

void doagablue ( void )

◆ doagablue_c()

ULONG doagablue_c ( ULONG c,
APTR * scr,
struct Library * gfx )
static

AGABlue(Colour Register) - the 8 bit blue component, as AGARed.

Parameters
cd0: the colour register.
scra0: the used screen (object).
gfxa6: graphics.library.
Returns
d0.w: the component (0-255).

◆ doagagreen()

void doagagreen ( void )

◆ doagagreen_c()

ULONG doagagreen_c ( ULONG c,
APTR * scr,
struct Library * gfx )
static

AGAGreen(Colour Register) - the 8 bit green component, as AGARed.

Parameters
cd0: the colour register.
scra0: the used screen (object).
gfxa6: graphics.library.
Returns
d0.w: the component (0-255).

◆ doagared()

void doagared ( void )

◆ doagared_c()

ULONG doagared_c ( ULONG c,
APTR * scr,
struct Library * gfx )
static

AGARed(Colour Register) - the 8 bit red component of a colour of the used screen.

GetRGB32 of one colour (d0 & 255); the top byte of the component (ROL.l #8:AND.w #255). The binary checks the screen and masks the colour number.

Errors: "Uninitialized Screen" (err3; DIFF: the original jumps into the error check area for it, here it is in the normal code). Debugger only (agacolchk): "Not an AGA machine!".

Parameters
cd0: the colour register.
scra0: the used screen (object; !libs screenslib,$1002).
gfxa6: graphics.library.
Returns
d0.w: the component (0-255); the upper word is ROL's.

◆ doblue()

void doblue ( void )

◆ docycle()

void docycle ( void )

◆ docycle_c()

void docycle_c ( APTR * scr)
static

Cycle Palette# - cycle the palette's colours on the used screen (Amiga mode only).

The palette and the screen's ViewPort go into the cycle list (12 bytes, globalloc); the first Cycle installs cycleem in the vertical blank (intlib SetInt, level $8005), which cycles every palette of the list and reloads the ViewPort when colours moved. The palette is in a3.

Errors (debugger only, docyclechk): "Uninitialized cycle information" (a palette without colours).

Parameters
scra2: the used screen (object; !libs screenslib,$1202).

◆ docyclechk()

void docyclechk ( void )

◆ docyclechk_c()

void docyclechk_c ( void )
static

◆ dogreen()

void dogreen ( void )

◆ dopalload()

void dopalload ( void )

◆ dopalload2()

void dopalload2 ( void )

◆ dopalload2_c()

void dopalload2_c ( const UBYTE * name,
UWORD off,
struct bb_palette * p )
static

LoadPalette Palette#,Filename$,Palette Offset - as LoadPalette, the colours from the given colour register on (Amiga mode only).

Parameters
named1: the file name.
offd2: the palette offset.
pa1: the palette.

◆ dopalload_c()

void dopalload_c ( const UBYTE * name,
struct bb_palette * p )
static

LoadPalette Palette#,Filename$ - load the colours (CMAP) and colour cycles (CRNG) of an IFF file into a palette (Amiga mode only).

iffiolib opens the file; the palette grows to the CMAP's colours, every component an 8 bit value repeated in each byte. The cycles end with low = -1. Not a bug (both are overwritten later): with an offset, colour offset+count is first written with the offset as red value (overwritten by the loop); CRNG ranges with low = high only overwrite the low word of the cycle entry. Fixed (#1002): only ranges with bit 0 (RNG_ACTIVE) of the CRNG flags are entered, bit 1 (RNG_REVERSE) negates the rate; the original entered every range, reversed unless the flags were 1.

Errors: "Can't Open IFF", "Can't find IFF 'CMAP'" (runtime errors of the normal code; DIFF: their messages are in the normal code too).

Parameters
named1: the file name.
pa1: the palette (!libs palettelib,$1180).

◆ dopalrgb()

void dopalrgb ( void )

◆ dopalrgb_c()

BLITZ_ENTRYPOINT void dopalrgb_c ( UWORD c,
UWORD r,
UWORD g,
UWORD b,
struct bb_palette * p )
static

AGAPalRGB Palette#,Colour Register,Red,Green,Blue - set a colour of a palette, 8 bit components.

The value is repeated in every byte of the component's long; the palette grows if needed (new data, the old colours copied).

Errors (debugger only, aaprgbchk): "Not an AGA machine!", "Colour must be in the range 0-31" (colour > 255), "RGB component out of range" (> 255).

Parameters
cd1: the colour register.
rd2: red (0-255).
gd3: green.
bd4: blue.
pa0: the palette (!libs palettelib,$1080).

◆ dored()

void dored ( void )

◆ dorgb()

void dorgb ( void )

◆ dorgb_b()

BLITZ_ENTRYPOINT void dorgb_b ( UWORD c,
UWORD r,
UWORD g,
UWORD b,
struct bb_slice * slice )
static

RGB Colour Register,Red,Green,Blue - set a colour of the used screen (Amiga mode) or slice (Blitz mode), 4 bit components.

Blitz mode (dorgb_b): the colour move r<<8|g<<4|b of the used slice. Amiga mode: SetRGB4 of the used screen's ViewPort, in assembler (see above; d0-d3 and a6 as SetRGB4 takes them).

Errors (debugger only, rgbchk): Amiga - "Uninitialized Screen", "Colour must be in the range 0-31" (> 255, or > 31 without AGA); Blitz - "Uninitialized Slice", "Colour must be in the range 0-31", "Not enough colours in Slice"; both "RGB component out of range" (> 15).

Parameters
cd0: the colour register.
rd1: red (0-15).
gd2: green.
bd3: blue.
slicea0: Blitz mode: the used slice; Amiga mode: the used screen (object), a6 = graphics.library.

◆ dosetcycle1()

void dosetcycle1 ( void )

◆ dosetcycle1_c()

void dosetcycle1_c ( UWORD cyc,
UWORD lo,
UWORD hi,
struct bb_palette * p )
static

SetCycle Palette#,Cycle,Low Colour,High Colour - as SetCycle with speed 1 (one step per frame).

Errors as SetCycle (debugger only: setcyclechk, without the speed).

Parameters
cycd1: the cycle number.
lod2: the low colour.
hid3: the high colour.
pa0: the palette.

◆ dosetcycle2()

void dosetcycle2 ( void )

◆ dosetcycle2_c()

void dosetcycle2_c ( UWORD cyc,
UWORD lo,
UWORD hi,
ULONG speed,
struct bb_palette * p )
static

SetCycle Palette#,Cycle,Low Colour,High Colour,Speed - set a colour cycle of a palette.

Low and High are swapped if needed; speed = the Quick >> 2 (16384 = one step per frame, the sign is the direction). A cycle behind the last one is appended (with a new end mark).

Errors: a cycle more than one behind the last - "Cycles must be added in order, you silly sausage!" (a runtime error of the normal code). Debugger only (setcyclechk2): "Cycle speed MUST be >=-1 AND <=1", "Cycle MUST be >=0 AND <=6", "Cycle colours out of range" (>= 32).

Parameters
cycd1: the cycle number.
lod2: the low colour.
hid3: the high colour.
speedd4: the speed (Quick).
pa0: the palette (!libs palettelib,$1080).

◆ dostopcycle()

void dostopcycle ( void )

◆ dostopcycle_c()

void dostopcycle_c ( void )
static

StopCycle - stop the colour cycling.

ClrInt of the cycling interrupt; Fixed (#228): cycon is cleared and the cycle list freed, so a later Cycle installs the interrupt again with a new list (the original left cycon set: a later Cycle did nothing).

◆ ERRTHUNK() [1/15]

ERRTHUNK ( aaprgbchk )

◆ ERRTHUNK() [2/15]

ERRTHUNK ( aargbchk )

◆ ERRTHUNK() [3/15]

ERRTHUNK ( agacolchk )

◆ ERRTHUNK() [4/15]

ERRTHUNK ( colchk_a )

◆ ERRTHUNK() [5/15]

ERRTHUNK ( colchk_b )

◆ ERRTHUNK() [6/15]

ERRTHUNK ( docyclechk )

◆ ERRTHUNK() [7/15]

ERRTHUNK ( prgbchk )

◆ ERRTHUNK() [8/15]

ERRTHUNK ( rgbchk_a )

◆ ERRTHUNK() [9/15]

ERRTHUNK ( rgbchk_b )

◆ ERRTHUNK() [10/15]

ERRTHUNK ( setcyclechk )

◆ ERRTHUNK() [11/15]

ERRTHUNK ( setcyclechk2 )

◆ ERRTHUNK() [12/15]

ERRTHUNK ( showpalchk_a )

◆ ERRTHUNK() [13/15]

ERRTHUNK ( showpalchk_b )

◆ ERRTHUNK() [14/15]

ERRTHUNK ( usepalchk_a )

◆ ERRTHUNK() [15/15]

ERRTHUNK ( usepalchk_b )

◆ freepal()

void freepal ( void )

◆ freepal_c()

void freepal_c ( void )
static

_free of the Palette object (Free Palette, program end) - free the colour data, no cycles.

The palette is in a3; nothing happens for 0 colours.

◆ getcol_a()

BL_ALWAYS_INLINE ULONG getcol_a ( ULONG c,
APTR * scr,
struct Library * gfx,
int shift )

◆ getcol_b()

BL_ALWAYS_INLINE ULONG getcol_b ( ULONG c,
struct bb_slice * slice,
int shift )

◆ getpal()

void getpal ( void )

◆ getpal2()

void getpal2 ( void )

◆ getpal2_c()

void getpal2_c ( UWORD off,
const UBYTE * name,
struct bb_palette * p )
static

getpal2 (a nullsub for other libraries) - getpal with a palette offset.

Parameters
offd0: the first colour register to load into.
namea0: the file name.
pa1: the palette.

◆ getpal_c()

void getpal_c ( const UBYTE * name,
struct bb_palette * p )
static

getpal (a nullsub for other libraries) - load the CMAP and CRNG chunks of an IFF file into a palette, as LoadPalette.

Keeps d0-d5.

Parameters
namea0: the file name.
pa1: the palette.

◆ globalloc()

APTR globalloc ( ULONG size,
ULONG flags )
static

◆ globfree()

void globfree ( APTR mem,
ULONG size )
static

◆ initpalette()

void initpalette ( struct bb_palette * p,
UWORD n )
static

◆ loadthepal()

void loadthepal ( const UBYTE * name,
struct bb_palette * p,
UWORD off )
static

◆ make4()

UWORD make4 ( const struct bb_palette * p)
static

◆ make4bitrgbs()

void make4bitrgbs ( void )

◆ make4bitrgbs_c()

UWORD make4bitrgbs_c ( const struct bb_palette * p)
static

make4bitrgbs (a nullsub for other libraries) - the 4 bit RGB words of a palette, for LoadRGB4.

Up to 32 colours, from the top byte of each component.

Fixed (intended deviation, #224): the original took the low byte, the colours of DecodePalette (top byte only) came out black.

Parameters
pa0: the palette.
Returns
d0.w: the count (MOVE.w: the caller's upper word stays), a1 = the table (rgbs4bit); keeps a0/a2.

◆ newpalmode()

void newpalmode ( void )

◆ newpalmode_c()

void newpalmode_c ( UWORD m)
static

NewPaletteMode On|Off - whether Use Palette shows the palette (Off, the default) or only makes it the used one (On).

Parameters
md0: On (<> 0) or Off (0).

◆ palettelib_codefinit()

void palettelib_codefinit ( void )

◆ palettelib_codeinit()

void palettelib_codeinit ( void )

◆ palgrow()

UBYTE * palgrow ( struct bb_palette * p,
UWORD c )
static

◆ palrgb()

BL_ALWAYS_INLINE void palrgb ( struct bb_palette * p,
UWORD c,
UWORD r,
UWORD g,
UWORD b )

◆ prgbchk()

void prgbchk ( void )

◆ prgbchk_c()

void prgbchk_c ( UWORD c,
UWORD r,
UWORD g,
UWORD b )
static

◆ rep()

BL_ALWAYS_INLINE ULONG rep ( UWORD v)

◆ rep8()

ULONG rep8 ( UWORD v)
static

◆ rgbchk()

void rgbchk ( void )

◆ rgbchk2()

int rgbchk2 ( UWORD r,
UWORD g,
UWORD b )
static

◆ rgbchk_a_c()

void rgbchk_a_c ( UWORD c,
UWORD r,
UWORD g,
UWORD b,
const ULONG * scr )
static

◆ rgbchk_b_c()

void rgbchk_b_c ( UWORD c,
UWORD r,
UWORD g,
UWORD b,
const struct bb_slice * slice )
static

◆ setcyclechk()

void setcyclechk ( void )

◆ setcyclechk2()

void setcyclechk2 ( void )

◆ setcyclechk2_c()

void setcyclechk2_c ( UWORD c,
UWORD lo,
UWORD hi,
LONG sp )
static

◆ setcyclechk_c()

void setcyclechk_c ( UWORD c,
UWORD lo,
UWORD hi )
static

◆ showpal()

void showpal ( void )

◆ showpal_a()

void showpal_a ( APTR * scr,
struct Library * gfx )

ShowPalette Palette#, Amiga mode - load the palette into the used screen's ViewPort.

With agamode LoadRGB32 of the palette data, else LoadRGB4 of up to 32 colours (make4bitrgbs; with the original's low byte DecodePalette colours were black, fixed: #224). The palette is in a3.

BUG(orig) (#230): with an empty palette the original runs into b_showpal and writes nothing (count 0); here it simply returns (DIFF).

Errors (debugger only, showpalchk): "Uninitialized Screen".

Parameters
scra2: the used screen (object).
gfxa6: graphics.library.

◆ showpal_amiga()

void showpal_amiga ( struct bb_palette * p,
APTR * scr,
struct Library * gfx )
static

◆ showpal_b()

BLITZ_ENTRYPOINT void showpal_b ( struct bb_slice * slice)
static

ShowPalette Palette#, Blitz mode - write the palette into the colour moves of the used slice.

As many colours as the slice has (and the palette), 4 bit each from the top byte of the components. The palette is in a3.

Errors (debugger only, showpalchk): "Uninitialized Slice", "Not enough colours in Slice" (a slice without colours).

Parameters
slicea0: the used slice (!libs blitzcoplib,$9002).

◆ showpal_blitz()

BL_ALWAYS_INLINE void showpal_blitz ( struct bb_palette * p,
struct bb_slice * slice )

◆ showpalchk()

void showpalchk ( void )

◆ showpalchk_a_c()

void showpalchk_a_c ( const ULONG * scr)
static

◆ showpalchk_b_c()

void showpalchk_b_c ( const struct bb_slice * slice)
static

◆ startval()

ULONG startval ( WORD v)
static

◆ step()

ULONG step ( WORD delta,
UWORD n )
static

◆ usepal()

void usepal ( void )

◆ usepal_a()

void usepal_a ( APTR * scr,
struct Library * gfx )

_use of the Palette object (Use Palette), Amiga mode - ShowPalette unless NewPaletteMode On.

Errors (debugger only, usepalchk): as ShowPalette, also only without NewPaletteMode.

Parameters
scra2: the used screen (object).
gfxa6: graphics.library.

◆ usepal_b()

BLITZ_ENTRYPOINT void usepal_b ( struct bb_slice * slice)
static

_use of the Palette object (Use Palette), Blitz mode - ShowPalette unless NewPaletteMode On.

Parameters
slicea0: the used slice.

◆ usepalchk()

void usepalchk ( void )

◆ usepalchk_a_c()

void usepalchk_a_c ( const ULONG * scr)
static

◆ usepalchk_b_c()

void usepalchk_b_c ( const struct bb_slice * slice)
static

Variable Documentation

◆ agamode

WORD agamode
static

◆ agatable

ULONG agatable[3]
static

◆ blue

ULONG blue

◆ count

UWORD count

◆ cyclelist

struct cnode* cyclelist
static

◆ cycon

WORD cycon
static

◆ end

ULONG end

◆ first

UWORD first

◆ gfxbase

struct Library* gfxbase
static

◆ green

ULONG green

◆ mess0

const char mess0[] = "Can't Open IFF"
static

◆ mess1

const char mess1[] = "Can't find IFF 'CMAP'"
static

◆ mess3n

const char mess3n[] = "Uninitialized Screen"
static

◆ messd

const char messd[] = "Cycles must be added in order, you silly sausage!"
static

◆ myoff

UWORD myoff
static

◆ palmode

WORD palmode
static

◆ red

ULONG red

◆ rgbs4bit

UWORD rgbs4bit[32]
static

◆ [struct]

struct { ... } table