BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
rigfxlib.c File Reference
#include "blitzlib.h"
#include "blitzobj.h"
#include <datatypes/pictureclass.h>
#include <stddef.h>

Data Structures

struct  palcol
struct  paldata
struct  cmapfile

Macros

#define TOK_bsave   ((LIB_riamosfunclib << 7) + 16)
#define COLBYTES(d)
#define PALOF(c)
#define PALDATA(o)
#define PAIR(b, m)

Functions

void palred (void)
void palgreen (void)
void palblue (void)
void paletteinfo (void)
void agapalred (void)
void agapalgreen (void)
void agapalblue (void)
void paladjust (void)
void paladjust2 (void)
void fillpalette (void)
void fillpalette2 (void)
void agafillpalette (void)
void agafillpalette2 (void)
void copycolour (void)
void cpucls (void)
void savecmap (void)
void mergebitplanes (void)
void cpuclschk (void)
void paladj2chk (void)
void colchk (void)
void paladjchk (void)
static void codeinit (void)
 init: no PaletteInfo palette.
static LONG colindex (ULONG c)
static void paletteinfo_c (struct bb_palette *obj)
 PaletteInfo palette#: select the palette PalRed ... and PalAdjust read.
static ULONG palred_c (ULONG c)
 PalRed(colour#): the red value (4 bit) of a colour of PaletteInfo's palette.
static ULONG palgreen_c (ULONG c)
 PalGreen(colour#): the green value (4 bit); as PalRed (fixed #686, #677).
static ULONG palblue_c (ULONG c)
 PalBlue(colour#): the blue value (4 bit); as PalRed (fixed #686, #677).
static ULONG agapalred_c (ULONG c)
 AGAPalRed(colour#): the red value (8 bit); as PalRed (fixed #686, #677).
static ULONG agapalgreen_c (ULONG c)
 AGAPalGreen(colour#): the green value (8 bit); as PalRed (fixed #686, #677).
static ULONG agapalblue_c (ULONG c)
 AGAPalBlue(colour#): the blue value (8 bit); as PalRed (fixed #686, #677).
static void paladjust2_c (struct bb_palette *obj, ULONG ratio, ULONG start, ULONG end)
 PalAdjust palette#,ratio.q,start_col,end_col: scale colours of PaletteInfo's palette into a palette.
static void paladjust_c (struct bb_palette *obj, ULONG ratio, ULONG end)
 PalAdjust palette#,ratio.q: c_paladjust2() for the colours 0 .. n-1.
static void fill (struct bb_palette *obj, ULONG r, ULONG g, ULONG b, ULONG start, ULONG end)
static ULONG nib (ULONG v)
static void agafillpalette2_c (struct bb_palette *obj, ULONG r, ULONG g, ULONG b, ULONG start, ULONG end)
 AGAFillPalette palette#,r,g,b,start_col,end_col: fill colours with an 8 bit r,g,b.
static void agafillpalette_c (struct bb_palette *obj, ULONG r, ULONG g, ULONG b)
 AGAFillPalette palette#,r,g,b: fill the whole palette with an 8 bit r,g,b.
static void fillpalette2_c (struct bb_palette *obj, ULONG r, ULONG g, ULONG b, ULONG start, ULONG end)
 FillPalette palette#,r,g,b,start_col,end_col: fill colours with a 4 bit r,g,b.
static void fillpalette_c (struct bb_palette *obj, ULONG r, ULONG g, ULONG b)
 FillPalette palette#,r,g,b: fill the whole palette with a 4 bit r,g,b.
static BB_BOOL copycolour_c (struct bb_palette *src, struct bb_palette *dst, ULONG cs, ULONG cd)
 CopyColour(sourcepal#,destpal#,colsource#,coldest#): copy one colour between palettes.
static void clearplane (UBYTE *end, ULONG moves, BOOL blocks, BOOL odd)
static void cpucls_c (struct bb_bitmap *bm)
 CPUCls bitmap#: clear every plane of a bitmap with the CPU.
static ULONG savecmap_c (struct bb_palette *obj, ULONG name)
 SaveCMAP(palette#,filename$): save a palette as an IFF ILBM with a CMAP.
static void mergebitplanes_c (struct bb_bitmap *src1, struct bb_bitmap *src2, struct bb_bitmap *dst, ULONG planes)
 MergeBitplanes srcbitmap,srcbitmap,destbitmap,numplanes: a bitmap of the planes of two others.
static void cpuclschk_c (const struct bb_bitmap *bm)
 The error check of CPUCls (debugger only).
static void infochk (void)
static void colnumchk (ULONG c)
static void colchk_c (ULONG c)
 The error check of PalRed ... AGAPalBlue (debugger only).
static void paladjchk_c (const struct bb_palette *obj)
 The error check of PalAdjust's short form (debugger only).
static void paladj2chk_c (const struct bb_palette *obj, ULONG start, ULONG end)
 The error check of PalAdjust's long form (debugger only).

Variables

static UBYTE * paladdr

Macro Definition Documentation

◆ COLBYTES

#define COLBYTES ( d)
Value:
((UBYTE *)(d) + offsetof(struct paldata, col))
static struct @065163037313156332013005143365272036211065172003 d
Definition rigfxlib.c:232

◆ PAIR

#define PAIR ( b,
m )
Value:
(*(ULONG *)&(b)->m)

◆ PALDATA

#define PALDATA ( o)
Value:
((struct paldata *)(o)->pdata)

◆ PALOF

#define PALOF ( c)
Value:
((struct paldata *)((UBYTE *)(c) - offsetof(struct paldata, col)))
ULONG WORD UWORD c
Definition 2dlib.c:2491

◆ TOK_bsave

#define TOK_bsave   ((LIB_riamosfunclib << 7) + 16)

Function Documentation

◆ agafillpalette()

void agafillpalette ( void )

◆ agafillpalette2()

void agafillpalette2 ( void )

◆ agafillpalette2_c()

void agafillpalette2_c ( struct bb_palette * obj,
ULONG r,
ULONG g,
ULONG b,
ULONG start,
ULONG end )
static

AGAFillPalette palette#,r,g,b,start_col,end_col: fill colours with an 8 bit r,g,b.

The low bytes of r, g, b become the top bytes of the channels. end = 0 means the last colour; that test is on the word, as the comparison with start (fixed #683: the original tested the whole register, so an end whose upper word was not 0 was colour 0). Nothing if end < start.

Parameters
obja0: the palette object (!libs palettelib,ia0|pd0)
rd1: red
gd2: green
bd3: blue
startd4: the first colour
endd5: the last colour (0: the palette's last)

◆ agafillpalette_c()

void agafillpalette_c ( struct bb_palette * obj,
ULONG r,
ULONG g,
ULONG b )
static

AGAFillPalette palette#,r,g,b: fill the whole palette with an 8 bit r,g,b.

Parameters
obja0: the palette object
rd1: red
gd2: green
bd3: blue

◆ agapalblue()

void agapalblue ( void )

◆ agapalblue_c()

ULONG agapalblue_c ( ULONG c)
static

AGAPalBlue(colour#): the blue value (8 bit); as PalRed (fixed #686, #677).

Parameters
cd0: colour#
Returns
d0: the colour's blue byte

◆ agapalgreen()

void agapalgreen ( void )

◆ agapalgreen_c()

ULONG agapalgreen_c ( ULONG c)
static

AGAPalGreen(colour#): the green value (8 bit); as PalRed (fixed #686, #677).

Parameters
cd0: colour#
Returns
d0: the colour's green byte

◆ agapalred()

void agapalred ( void )

◆ agapalred_c()

ULONG agapalred_c ( ULONG c)
static

AGAPalRed(colour#): the red value (8 bit); as PalRed (fixed #686, #677).

Parameters
cd0: colour#
Returns
d0: the colour's red byte

◆ clearplane()

void clearplane ( UBYTE * end,
ULONG moves,
BOOL blocks,
BOOL odd )
static

◆ codeinit()

void codeinit ( void )
static

init: no PaletteInfo palette.

Fixed (#1125): the original has no init, so a second run of a program with the library still loaded (from the editor) started with the PaletteInfo palette of the run before: PalRed ... AGAPalBlue and PalAdjust before a PaletteInfo read the first run's freed palette. Clears with CLR.l on an absolute address: no register changes.

◆ colchk()

void colchk ( void )

◆ colchk_c()

void colchk_c ( ULONG c)
static

The error check of PalRed ... AGAPalBlue (debugger only).

Fixed (#686, #677), not in the original: the colour functions read the palette of the last PaletteInfo without a test, before the first one from address 0 (the exception vectors), and index it with the low word of 12 * colour as a signed offset, so a colour number from 2731 on read before the palette, and any number past the palette's colours behind it. The release code is unchanged (a command before its setup command, a programming error, as #176; an invalid argument, D-005).

Errors: "No palette selected with PaletteInfo"; "Colour number outside the PaletteInfo palette" (the colour's word not below the number of colours of that palette).

Parameters
cd0: colour#

◆ colindex()

LONG colindex ( ULONG c)
static

◆ colnumchk()

void colnumchk ( ULONG c)
static

◆ copycolour()

void copycolour ( void )

◆ copycolour_c()

BB_BOOL copycolour_c ( struct bb_palette * src,
struct bb_palette * dst,
ULONG cs,
ULONG cd )
static

CopyColour(sourcepal#,destpal#,colsource#,coldest#): copy one colour between palettes.

The three channel longs of colsource# of the source palette go to coldest# of the target. The colour numbers are compared with the palettes' number of colours as unsigned words (fixed #678: the original compared them signed, so negative ones passed and indexed up to 786 KB behind the palette, MULU.w).

Parameters
srca0: the source palette object (ia0)
dsta1: the target palette object (ia1)
csd2: the source colour
cdd3: the target colour
Returns
d0: BB_TRUE, BB_FALSE if a colour number is not below its palette's number of colours

◆ cpucls()

void cpucls ( void )

◆ cpucls_c()

void cpucls_c ( struct bb_bitmap * bm)
static

CPUCls bitmap#: clear every plane of a bitmap with the CPU.

Nothing without plane 0 (fixed #680: the original's test left through the wrong exit, see the file's head). BytesPerRow*Rows bytes per plane, cleared from the end down; the original's register arithmetic for the block count (DIVU #40, the rest as words). Blocks of 40 bytes, DBRA on blocks - 1; a plane of less than 40 bytes has no block (fixed #682: the original's counter was $FFFF, 65536 blocks, 2.6 MB below the plane); the last byte of an odd rest, the plane's first, is cleared as well (fixed #681: the original cleared the rest as words, ASR.w #1, and left it). Both decided once per call. The depth is the byte Depth (fixed #679: the original read the word Flags<<8|Depth); depth 0 gives the DBRA counter $FFFF, 65536 planes, a depth above 8 plane pointers behind the 8 - an invalid argument, refused by cpuclschk with runtime error checking (fixed #679), here unchecked.

Parameters
bma0: the bitmap object (!libs bitmaplib,ia0|pd0)

◆ cpuclschk()

void cpuclschk ( void )

◆ cpuclschk_c()

void cpuclschk_c ( const struct bb_bitmap * bm)
static

The error check of CPUCls (debugger only).

Fixed (#679), not in the original (rigfxlib had no error check area): CPUCls counts the planes with SUBQ.w #1 ... DBRA on the depth, so a bitmap of depth 0 clears 65536 "planes" through the longs behind the object's 8 plane pointers, and a depth above 8 takes the longs behind them as plane addresses as well. The release code is unchanged (an invalid argument, D-005).

Errors: "Illegal BitMap Depth" (bitmaplib's text) for a depth of 0 or above 8 (as bitmaplib's checks; the depth above 8 by the user's decision "rigfxlib" of W6, as #674 in rifxlib).

Parameters
bma0: the bitmap object (!libs bitmaplib,ia0|pd0)

◆ fill()

void fill ( struct bb_palette * obj,
ULONG r,
ULONG g,
ULONG b,
ULONG start,
ULONG end )
static

◆ fillpalette()

void fillpalette ( void )

◆ fillpalette2()

void fillpalette2 ( void )

◆ fillpalette2_c()

void fillpalette2_c ( struct bb_palette * obj,
ULONG r,
ULONG g,
ULONG b,
ULONG start,
ULONG end )
static

FillPalette palette#,r,g,b,start_col,end_col: fill colours with a 4 bit r,g,b.

As AGAFillPalette with the low nibbles of r, g, b as the top nibbles of the channel bytes (ANDI.b $f:ASL.b #4) (the end test fixed, #683).

Parameters
obja0: the palette object (!libs palettelib,ia0|pd0)
rd1: red
gd2: green
bd3: blue
startd4: the first colour
endd5: the last colour (0: the palette's last)

◆ fillpalette_c()

void fillpalette_c ( struct bb_palette * obj,
ULONG r,
ULONG g,
ULONG b )
static

FillPalette palette#,r,g,b: fill the whole palette with a 4 bit r,g,b.

Parameters
obja0: the palette object
rd1: red
gd2: green
bd3: blue

◆ infochk()

void infochk ( void )
static

◆ mergebitplanes()

void mergebitplanes ( void )

◆ mergebitplanes_c()

void mergebitplanes_c ( struct bb_bitmap * src1,
struct bb_bitmap * src2,
struct bb_bitmap * dst,
ULONG planes )
static

MergeBitplanes srcbitmap,srcbitmap,destbitmap,numplanes: a bitmap of the planes of two others.

The plane pointers of src1, then of src2, go into dest (numplanes of them; 0 = all of both, DBRA from -1); dest gets src1's BytesPerRow, Rows, width and height, numplanes as its Flags<<8|Depth word, +52 = 0 and +62 = 1. Nothing if a source has word 62 = 0, dest not, or numplanes > the sum of the depths (signed words).

Parameters
src1a0: the first source bitmap object (ia0)
src2a1: the second source bitmap object (ia1)
dsta2: the target bitmap object (ia2)
planesd3: numplanes

◆ nib()

ULONG nib ( ULONG v)
static

◆ paladj2chk()

void paladj2chk ( void )

◆ paladj2chk_c()

void paladj2chk_c ( const struct bb_palette * obj,
ULONG start,
ULONG end )
static

The error check of PalAdjust's long form (debugger only).

Fixed (#684, #686, #677, #685), not in the original: PalAdjust reads the palette of the last PaletteInfo without a test (before the first one: address 0); it takes the count end - start + 1 as a word, * 3 (MULU.w) - 1 as the DBRA counter, so end = start - 1 wrote 65536 channels (256 KB) from colour start on, and a smaller end about as many; it indexes both palettes with the low word of 12 * start as a signed offset, so a start from 2731 on wrote before the target palette, a range past PaletteInfo's colours read behind them; and a range past the target's colours wrote behind them. The release code is unchanged (invalid arguments, D-005; FillPalette refuses end < start in its release code, PalAdjust has no such test).

Errors: "No palette selected with PaletteInfo"; "PalAdjust end colour before the start colour" (end < start as signed words, FillPalette's compare); "Colour number outside the PaletteInfo palette" (the word of start or end not below the number of colours of that palette); "PalAdjust colours outside the target palette" (the word of end not below the number of colours of the target's colour data).

Parameters
obja0: the target palette object (!libs palettelib,ia0|pd0)
startd2: the first colour
endd3: the last colour

◆ paladjchk()

void paladjchk ( void )

◆ paladjchk_c()

void paladjchk_c ( const struct bb_palette * obj)
static

The error check of PalAdjust's short form (debugger only).

Fixed (#686, #685), not in the original: PalAdjust takes the colours and their number from the palette of the last PaletteInfo, before the first one from address 0 and the count from address -4, and writes that many colours into the target without a look at the target's number: a target smaller than the source was written behind its colours. The release code is unchanged (a programming error as #176; an invalid argument, D-005; the manual: the target "should be AT LEAST as big [as] the source palette").

Errors: "No palette selected with PaletteInfo"; "PalAdjust colours outside the target palette" (the target's colour data have fewer colours than PaletteInfo's palette).

Parameters
obja0: the target palette object (!libs palettelib,ia0|pd0)

◆ paladjust()

void paladjust ( void )

◆ paladjust2()

void paladjust2 ( void )

◆ paladjust2_c()

void paladjust2_c ( struct bb_palette * obj,
ULONG ratio,
ULONG start,
ULONG end )
static

PalAdjust palette#,ratio.q,start_col,end_col: scale colours of PaletteInfo's palette into a palette.

Target colours start..end = PaletteInfo's colours * ratio (8.8 fixed point from the Quick 16.16), saturated at 255; only the top byte of each channel is written. PaletteInfo's palette is used unchecked (before one: address 0), end < start runs 65536*3 channels (count 0 after MULU.w/SUBQ.w) and colour numbers from 2731 on index before the palettes: refused by paladj2chk with runtime error checking (fixed #686, #684, #677), here unchecked.

Parameters
obja0: the target palette object (!libs palettelib,ia0|pd0)
ratiod1: the ratio, a Quick (16.16)
startd2: the first colour
endd3: the last colour

◆ paladjust_c()

void paladjust_c ( struct bb_palette * obj,
ULONG ratio,
ULONG end )
static

PalAdjust palette#,ratio.q: c_paladjust2() for the colours 0 .. n-1.

n is the number of colours of PaletteInfo's palette, not of the target: a smaller target is refused by paladjchk with runtime error checking (fixed #685), here unchecked; the upper word of end is the caller's d3 (SUB.w), unused.

Parameters
obja0: the target palette object
ratiod1: the ratio, a Quick (16.16)
endd3: the caller's d3 (its low word is replaced)

◆ palblue()

void palblue ( void )

◆ palblue_c()

ULONG palblue_c ( ULONG c)
static

PalBlue(colour#): the blue value (4 bit); as PalRed (fixed #686, #677).

Parameters
cd0: colour#
Returns
d0: the top 4 bits of the colour's blue byte

◆ paletteinfo()

void paletteinfo ( void )

◆ paletteinfo_c()

void paletteinfo_c ( struct bb_palette * obj)
static

PaletteInfo palette#: select the palette PalRed ... and PalAdjust read.

Remembers the address of its colour 0 (paladdr); the object's data pointer is taken as it is, not checked.

Parameters
obja0: the palette object (!libs palettelib,ia0|pd0)

◆ palgreen()

void palgreen ( void )

◆ palgreen_c()

ULONG palgreen_c ( ULONG c)
static

PalGreen(colour#): the green value (4 bit); as PalRed (fixed #686, #677).

Parameters
cd0: colour#
Returns
d0: the top 4 bits of the colour's green byte

◆ palred()

void palred ( void )

◆ palred_c()

ULONG palred_c ( ULONG c)
static

PalRed(colour#): the red value (4 bit) of a colour of PaletteInfo's palette.

MOVE.b 0/4/8(a0,d0.w),d0: ASR.l #4:ANDI.l #15 (4 bit) or ANDI.l $ff (the AGA functions). The palette of the last PaletteInfo is used unchecked (before one: address 0), and colour numbers from 2731 on index before the palette (12 * c as a signed word), any past its colours behind it: refused by colchk with runtime error checking (fixed #686, #677), here unchecked.

Parameters
cd0: colour# (its low word)
Returns
d0: the top 4 bits of the colour's red byte

◆ savecmap()

void savecmap ( void )

◆ savecmap_c()

ULONG savecmap_c ( struct bb_palette * obj,
ULONG name )
static

SaveCMAP(palette#,filename$): save a palette as an IFF ILBM with a CMAP.

Builds FORM ILBM with an empty BMHD (20 zero bytes: no defect, a palette file) and the CMAP (3 bytes per colour, the channels' top bytes) in memory (memlib globalloc, MEMF_CLEAR), writes it with RIAmosFuncLib's BSave (form 1: d0 name, d1 address, d2 length) and frees it. A CMAP of odd length gets its pad byte (the cleared memory; the file and the FORM length rounded up to even, the CMAP length not: fixed #687, the original wrote none). A palette of 0 colours gives a CMAP of length 0, a file of 48 bytes (fixed #688: the original's DBRA from numcols - 1 copied 65536 colours, 196608 bytes behind the block).

Parameters
obja0: the palette object (!libs palettelib,ia0|pd0)
named1: the file name
Returns
d0: BSave's result, 0 if the palette has no data or there is no memory

Variable Documentation

◆ paladdr

UBYTE* paladdr
static