|
BB2 C port
API reference: Blitz libraries in C and the shared code
|
#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!" |
| #define __NOLIBBASE__ |
| #define COLMOVES | ( | s | ) |
| #define ERRTHUNK | ( | n | ) |
| #define GRAPHICS_BASE_NAME gfx |
| #define IFFCALL | ( | tok, | |
| in0, | |||
| ina0, | |||
| z ) |
| #define L | ( | p, | |
| o ) |
| #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 SL | ( | p | ) |
| #define W | ( | p, | |
| o ) |
| void _cludgepalette | ( | void | ) |
| void _cludgepalette2 | ( | void | ) |
|
static |
DecodePalette Palette#,MemoryLocation - as DecodePalette with offset 0.
| mem | d1: the IFF file in memory. |
|
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'".
| mem | d1: the IFF file in memory. |
| off | d2: the palette offset. |
| void _cyclepalette | ( | void | ) |
|
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).
| p | a2: the palette (!libs palettelib,$1280). |
| void _duplicatepalette | ( | void | ) |
|
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.
| s | a2: the source palette (!libs palettelib,$1280). |
| 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.
| void _initpalette | ( | void | ) |
|
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.
| n | d1: the number of colours. |
| void _mixpalette | ( | void | ) |
|
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.
| f | d3: the fraction (Quick, 0..1). |
| p1 | a0: the first palette. |
| p2 | a2: the second palette. |
| void _paletterange | ( | void | ) |
|
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).
| start | d1: StartCol. |
| stop | d2: EndCol. |
| r0 | d3: the start red. |
| g0 | d4: the start green. |
| b0 | d5: the start blue. |
| args | a2: the argument stack: r1, g1, b1 at -2, -4, -6. |
| void aaprgbchk | ( | void | ) |
|
static |
| void aargbchk | ( | void | ) |
|
static |
| AGA_FN | ( | doagablue | , |
| "AGABlue" | ) |
| AGA_FN | ( | doagagreen | , |
| "AGAGreen" | ) |
| AGA_FN | ( | doagared | , |
| "AGARed" | ) |
|
static |
| void agacolchk | ( | void | ) |
|
static |
| BLITZ_ALIAS | ( | _cludgepalette | , |
| _cludgepalette_c | ) |
| BLITZ_ALIAS | ( | _cludgepalette2 | , |
| _cludgepalette2_c | ) |
| BLITZ_ALIAS | ( | _cyclepalette | , |
| _cyclepalette_c | ) |
| BLITZ_ALIAS | ( | _duplicatepalette | , |
| _duplicatepalette_c | ) |
| BLITZ_ALIAS | ( | _initpalette | , |
| _initpalette_c | ) |
| BLITZ_ALIAS | ( | _mixpalette | , |
| _mixpalette_c | ) |
| BLITZ_ALIAS | ( | _paletterange | , |
| _paletterange_c | ) |
| BLITZ_ALIAS | ( | doagablue | , |
| doagablue_c | ) |
| BLITZ_ALIAS | ( | doagagreen | , |
| doagagreen_c | ) |
| BLITZ_ALIAS | ( | doagared | , |
| doagared_c | ) |
| BLITZ_ALIAS | ( | dopalload | , |
| dopalload_c | ) |
| BLITZ_ALIAS | ( | dopalload2 | , |
| dopalload2_c | ) |
| BLITZ_ALIAS | ( | dosetcycle1 | , |
| dosetcycle1_c | ) |
| BLITZ_ALIAS | ( | dosetcycle2 | , |
| dosetcycle2_c | ) |
| BLITZ_ALIAS | ( | dostopcycle | , |
| dostopcycle_c | ) |
| BLITZ_ALIAS | ( | newpalmode | , |
| newpalmode_c | ) |
| BLITZ_ALIAS_EP | ( | do4bitpalrgb | , |
| do4bitpalrgb_c | ) |
| BLITZ_ALIAS_EP | ( | dopalrgb | , |
| dopalrgb_c | ) |
| BLITZ_EP_MARK | ( | dorgb_b | ) |
| BLITZ_EP_MARK | ( | showpal_b | ) |
| BLITZ_EP_MARK | ( | usepal_b | ) |
|
static |
|
static |
Library finit (cycoff) - cycling interrupt off, cycle list freed.
The list is freed but not cleared (not a bug: only at program end).
|
static |
Library init - agamode = ExecVersion >= 39 (environlib), no cycling.
| callerd0 | d0: the caller's d0 (passed to ExecVersion). |
| gfx | a0: graphics.library (!libs graphicslib,la0). |
| void colchk | ( | void | ) |
|
static |
|
static |
| COLFN | ( | doblue | , |
| 0 | ) |
| COLFN | ( | dogreen | , |
| 4 | ) |
| 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".
|
static |
| void cycleem | ( | void | ) |
|
static |
|
static |
| void do4bitpalrgb | ( | void | ) |
|
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).
| void doaargb | ( | void | ) |
|
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).
| void doagablue | ( | void | ) |
|
static |
AGABlue(Colour Register) - the 8 bit blue component, as AGARed.
| c | d0: the colour register. |
| scr | a0: the used screen (object). |
| gfx | a6: graphics.library. |
| void doagagreen | ( | void | ) |
|
static |
AGAGreen(Colour Register) - the 8 bit green component, as AGARed.
| c | d0: the colour register. |
| scr | a0: the used screen (object). |
| gfx | a6: graphics.library. |
| void doagared | ( | void | ) |
|
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!".
| c | d0: the colour register. |
| scr | a0: the used screen (object; !libs screenslib,$1002). |
| gfx | a6: graphics.library. |
| void doblue | ( | void | ) |
| void docycle | ( | void | ) |
|
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).
| scr | a2: the used screen (object; !libs screenslib,$1202). |
| void docyclechk | ( | void | ) |
|
static |
| void dogreen | ( | void | ) |
| void dopalload | ( | void | ) |
| void dopalload2 | ( | void | ) |
|
static |
LoadPalette Palette#,Filename$,Palette Offset - as LoadPalette, the colours from the given colour register on (Amiga mode only).
| name | d1: the file name. |
| off | d2: the palette offset. |
| p | a1: the palette. |
|
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).
| name | d1: the file name. |
| p | a1: the palette (!libs palettelib,$1180). |
| void dopalrgb | ( | void | ) |
|
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).
| void dored | ( | void | ) |
| void dorgb | ( | void | ) |
|
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).
| void dosetcycle1 | ( | void | ) |
|
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).
| cyc | d1: the cycle number. |
| lo | d2: the low colour. |
| hi | d3: the high colour. |
| p | a0: the palette. |
| void dosetcycle2 | ( | void | ) |
|
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).
| cyc | d1: the cycle number. |
| lo | d2: the low colour. |
| hi | d3: the high colour. |
| speed | d4: the speed (Quick). |
| p | a0: the palette (!libs palettelib,$1080). |
| void dostopcycle | ( | 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 | ( | aaprgbchk | ) |
| ERRTHUNK | ( | aargbchk | ) |
| ERRTHUNK | ( | agacolchk | ) |
| ERRTHUNK | ( | colchk_a | ) |
| ERRTHUNK | ( | colchk_b | ) |
| ERRTHUNK | ( | docyclechk | ) |
| ERRTHUNK | ( | prgbchk | ) |
| ERRTHUNK | ( | rgbchk_a | ) |
| ERRTHUNK | ( | rgbchk_b | ) |
| ERRTHUNK | ( | setcyclechk | ) |
| ERRTHUNK | ( | setcyclechk2 | ) |
| ERRTHUNK | ( | showpalchk_a | ) |
| ERRTHUNK | ( | showpalchk_b | ) |
| ERRTHUNK | ( | usepalchk_a | ) |
| ERRTHUNK | ( | usepalchk_b | ) |
| void freepal | ( | 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.
| 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 ) |
| void getpal | ( | void | ) |
| void getpal2 | ( | void | ) |
|
static |
getpal2 (a nullsub for other libraries) - getpal with a palette offset.
| off | d0: the first colour register to load into. |
| name | a0: the file name. |
| p | a1: the palette. |
|
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.
| name | a0: the file name. |
| p | a1: the palette. |
|
static |
|
static |
|
static |
|
static |
|
static |
| void make4bitrgbs | ( | void | ) |
|
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.
| p | a0: the palette. |
| void newpalmode | ( | void | ) |
|
static |
NewPaletteMode On|Off - whether Use Palette shows the palette (Off, the default) or only makes it the used one (On).
| m | d0: On (<> 0) or Off (0). |
| void palettelib_codefinit | ( | void | ) |
| void palettelib_codeinit | ( | void | ) |
|
static |
| BL_ALWAYS_INLINE void palrgb | ( | struct bb_palette * | p, |
| UWORD | c, | ||
| UWORD | r, | ||
| UWORD | g, | ||
| UWORD | b ) |
| void prgbchk | ( | void | ) |
|
static |
| BL_ALWAYS_INLINE ULONG rep | ( | UWORD | v | ) |
|
static |
| void rgbchk | ( | void | ) |
|
static |
|
static |
|
static |
| void setcyclechk | ( | void | ) |
| void setcyclechk2 | ( | void | ) |
|
static |
|
static |
| void showpal | ( | void | ) |
| 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".
| scr | a2: the used screen (object). |
| gfx | a6: graphics.library. |
|
static |
|
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).
| slice | a0: the used slice (!libs blitzcoplib,$9002). |
| BL_ALWAYS_INLINE void showpal_blitz | ( | struct bb_palette * | p, |
| struct bb_slice * | slice ) |
| void showpalchk | ( | void | ) |
|
static |
|
static |
|
static |
|
static |
| void usepal | ( | void | ) |
| 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.
| scr | a2: the used screen (object). |
| gfx | a6: graphics.library. |
|
static |
_use of the Palette object (Use Palette), Blitz mode - ShowPalette unless NewPaletteMode On.
| slice | a0: the used slice. |
| void usepalchk | ( | void | ) |
|
static |
|
static |
|
static |
|
static |
| ULONG blue |
| UWORD count |
|
static |
|
static |
| ULONG end |
| UWORD first |
|
static |
| ULONG green |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| ULONG red |
|
static |
| struct { ... } table |