|
BB2 C port
API reference: Blitz libraries in C and the shared code
|
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 |
| #define COLBYTES | ( | d | ) |
| #define PAIR | ( | b, | |
| m ) |
| #define PALDATA | ( | o | ) |
| #define PALOF | ( | c | ) |
| #define TOK_bsave ((LIB_riamosfunclib << 7) + 16) |
| void agafillpalette | ( | void | ) |
| void agafillpalette2 | ( | void | ) |
|
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.
|
static |
AGAFillPalette palette#,r,g,b: fill the whole palette with an 8 bit r,g,b.
| obj | a0: the palette object |
| r | d1: red |
| g | d2: green |
| b | d3: blue |
| void agapalblue | ( | void | ) |
|
static |
AGAPalBlue(colour#): the blue value (8 bit); as PalRed (fixed #686, #677).
| c | d0: colour# |
| void agapalgreen | ( | void | ) |
|
static |
AGAPalGreen(colour#): the green value (8 bit); as PalRed (fixed #686, #677).
| c | d0: colour# |
| void agapalred | ( | void | ) |
|
static |
AGAPalRed(colour#): the red value (8 bit); as PalRed (fixed #686, #677).
| c | d0: colour# |
|
static |
|
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.
| void colchk | ( | void | ) |
|
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).
| c | d0: colour# |
|
static |
|
static |
| void copycolour | ( | void | ) |
|
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).
| src | a0: the source palette object (ia0) |
| dst | a1: the target palette object (ia1) |
| cs | d2: the source colour |
| cd | d3: the target colour |
| void cpucls | ( | void | ) |
|
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.
| bm | a0: the bitmap object (!libs bitmaplib,ia0|pd0) |
| void cpuclschk | ( | void | ) |
|
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).
| bm | a0: the bitmap object (!libs bitmaplib,ia0|pd0) |
|
static |
| void fillpalette | ( | void | ) |
| void fillpalette2 | ( | void | ) |
|
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).
|
static |
FillPalette palette#,r,g,b: fill the whole palette with a 4 bit r,g,b.
| obj | a0: the palette object |
| r | d1: red |
| g | d2: green |
| b | d3: blue |
|
static |
| void mergebitplanes | ( | void | ) |
|
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).
| src1 | a0: the first source bitmap object (ia0) |
| src2 | a1: the second source bitmap object (ia1) |
| dst | a2: the target bitmap object (ia2) |
| planes | d3: numplanes |
|
static |
| void paladj2chk | ( | void | ) |
|
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).
| obj | a0: the target palette object (!libs palettelib,ia0|pd0) |
| start | d2: the first colour |
| end | d3: the last colour |
| void paladjchk | ( | void | ) |
|
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).
| obj | a0: the target palette object (!libs palettelib,ia0|pd0) |
| void paladjust | ( | void | ) |
| void paladjust2 | ( | void | ) |
|
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.
| obj | a0: the target palette object (!libs palettelib,ia0|pd0) |
| ratio | d1: the ratio, a Quick (16.16) |
| start | d2: the first colour |
| end | d3: the last colour |
|
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.
| obj | a0: the target palette object |
| ratio | d1: the ratio, a Quick (16.16) |
| end | d3: the caller's d3 (its low word is replaced) |
| void palblue | ( | void | ) |
|
static |
PalBlue(colour#): the blue value (4 bit); as PalRed (fixed #686, #677).
| c | d0: colour# |
| void paletteinfo | ( | void | ) |
|
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.
| obj | a0: the palette object (!libs palettelib,ia0|pd0) |
| void palgreen | ( | void | ) |
|
static |
PalGreen(colour#): the green value (4 bit); as PalRed (fixed #686, #677).
| c | d0: colour# |
| void palred | ( | void | ) |
|
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.
| c | d0: colour# (its low word) |
| void savecmap | ( | void | ) |
|
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).
| obj | a0: the palette object (!libs palettelib,ia0|pd0) |
| name | d1: the file name |
|
static |