|
BB2 C port
API reference: Blitz libraries in C and the shared code
|
Data Structures | |
| struct | paldata |
| struct | iffchunk |
| struct | shhd |
| struct | lehead |
| struct | leshape |
Macros | |
| #define | __NOLIBBASE__ |
| #define | DOS_BASE_NAME dosbase |
| #define | TOK_packpbm ((LIB_ripacklib << 7) + 1) |
| #define | TOK_unpackpbm ((LIB_ripacklib << 7) + 8) |
| #define | TOK_loadshapes ((LIB_shapeslib << 7) + 10) |
| #define | SW(p, o) |
| #define | SL(p, o) |
| #define | ID(a, b, c, d) |
| #define | FW(p, T, f) |
| #define | FL(p, T, f) |
| #define | FPAIR(p, T, f) |
| #define | SHW(p, f) |
| #define | SHL(p, f) |
| #define | SHPAIR(p, f) |
Enumerations | |
| enum | { FREEALL , FREEMEMORY , FREEFILE } |
Functions | |
| void | _loadshapes (void) |
| void | _loadshapestoaddress (void) |
| void | _safetoblit (void) |
| void | _leloadshapes (void) |
| void | _leloadshapesnop (void) |
| void | _leloadshapesinglenop (void) |
| void | _leloadshapesingle (void) |
| void | _lesaveshapesnop (void) |
| void | _lesaveshapes (void) |
| void | _setcompress (void) |
| void | _lecludgeshapes (void) |
| void | _lecludgeshapes2 (void) |
| void | _leinitshape (void) |
| void | _lescanshapes (void) |
| void | _leMaxShapeWidth (void) |
| void | _leMaxShapeHeight (void) |
| void | _leMaxShapeDepth (void) |
| void | _leautocookie (void) |
| void | rishapeslib_libinit (void) |
| void | rishapeslib_libfinit (void) |
| finit (_libfinit): nothing, an RTS. | |
| static UWORD | getw (const UBYTE *p) |
| static ULONG | getl (const UBYTE *p) |
| static ULONG | galloc (ULONG size, ULONG flags) |
| static ULONG | gfree (ULONG mem, ULONG size) |
| static void | rs_crash (UBYTE *pushed) |
| static void | libinit_c (void) |
| init: LECompressShapes off, LEAutoCookie on, the maxima of LEScanShapes 0. | |
| static void | leautocookie_c (BB_BOOL on) |
| LEAutoCookie on|off: whether CludgeShapes makes the cookies of its shapes (on at the start). | |
| static void | setcompress_c (BB_BOOL on) |
| LECompressShapes True|False: whether LESaveShapes packs the shape data (PackPBM of RIPackLib). | |
| static ULONG | maxwidth_c (void) |
| LEMaxShapeWidth: the largest width of the last LEScanShapes. | |
| static ULONG | maxheight_c (void) |
| LEMaxShapeHeight: the largest height of the last LEScanShapes. | |
| static ULONG | maxdepth_c (void) |
| LEMaxShapeDepth: the largest depth of the last LEScanShapes. | |
| static void | lescanshapes_c (UBYTE *shape, UBYTE *last) |
| LEScanShapes startshape#,endshape#: the largest width, height and depth of the used shapes in the range (for LEMaxShape...). | |
| static BB_BOOL | safetoblit_c (ULONG shapenum, ULONG x, ULONG y, UBYTE *bitmap, UBYTE *shape, ULONG maxshapes) |
| SafeToBlit(shape,x,y): whether the shape can be blitted at x,y into the used bitmap. | |
| static void | createcookie (UBYTE *shape, UBYTE *pushed) |
| static void | freecookie (UBYTE *shape) |
| static void | freeshapesm (UBYTE *shape) |
| static BB_BOOL | loadshapes_c (ULONG shapenum, ULONG numshapes, ULONG address, UBYTE *objects) |
| CludgeShapes shape#,numshapes,address: makes shapes of shapes in memory (a 32-byte shape header + the data each), copied into chip memory. | |
| static BB_BOOL | loadshapestoaddress_c (ULONG objects, ULONG numshapes, ULONG address) |
| CludgeShapesToAddress Address,numshapes,address: CludgeShapes into shape objects at an address of the program's own. | |
| static void | shapesizes (UBYTE *shape, int all) |
| static void | leinitshape_c (ULONG width, ULONG height, ULONG depth, UBYTE *shape) |
| LEInitShape shape#,width,height,depth: makes an empty shape. | |
| static void | read_palette (const UBYTE *cmap) |
| static void | readshapes (UBYTE *data) |
| static UBYTE * | skipchunk (UBYTE *p, ULONG len) |
| static void | lecludgeshapes2_c (ULONG file, ULONG copymem, UBYTE *palette, UBYTE *first, UBYTE *last) |
| LECludgeShapes shape#,shape#,address,palette#,copymemflag: the shapes (and the palette) of an LE file in memory. | |
| static void | lecludgeshapes_c (ULONG file, UBYTE *palette, UBYTE *first, UBYTE *last) |
| LECludgeShapes shape#,shape#,address,palette#: as above with copymemflag 0 (CLR.l d4). | |
| static void | acidloadshapes (UBYTE *first, UBYTE *last) |
| static void | freechunk (void) |
| static ULONG | cleanup (int from) |
| static ULONG | readchunk (BPTR fh) |
| static ULONG | leloadshapes (ULONG shape1, ULONG shape2, ULONG name, UBYTE *palette, UBYTE *first, UBYTE *last, struct DosLibrary *dos) |
| static void | leloadshapesp_c (ULONG shape1, ULONG shape2, ULONG name, UBYTE *palette, UBYTE *first, UBYTE *last, struct DosLibrary *dos) |
| LELoadShapes shape#,shape#,filename$,palette#: loads the shapes (and the palette) of an LE file into the range of shapes. | |
| static void | leloadshapesnop_c (ULONG shape1, ULONG shape2, ULONG name, UBYTE *first, UBYTE *last, struct DosLibrary *dos) |
| LELoadShapes shape#,shape#,filename$: as above without a palette (the CMAP is skipped). | |
| static void | leloadshapesingle_c (ULONG shapenum, ULONG name, ULONG maxshapes, UBYTE *palette, UBYTE *first, UBYTE *objects, struct DosLibrary *dos) |
| LELoadShapes shape#,filename$,palette#: as above from shape# up to the last shape (the maximum - 1), as many as the file has. | |
| static void | leloadshapesinglenop_c (ULONG shapenum, ULONG name, ULONG maxshapes, UBYTE *first, UBYTE *objects, struct DosLibrary *dos) |
| LELoadShapes shape#,filename$: as above without a palette. | |
| static ULONG | savecmap (BPTR fh, ULONG result) |
| static ULONG | writeshapes (BPTR fh) |
| static void | lesaveshapes_c (ULONG shape1, ULONG shape2, ULONG name, UBYTE *palette, UBYTE *first, UBYTE *last, struct DosLibrary *dos) |
| LESaveShapes shape#,shape#,filename$,palette#: saves the range of shapes (and the palette) as an LE file. | |
| static void | lesaveshapesnop_c (ULONG shape1, ULONG shape2, ULONG name, UBYTE *first, UBYTE *last, struct DosLibrary *dos) |
| LESaveShapes shape#,shape#,filename$: as above without a palette (no CMAP). | |
Variables | |
| static struct DosLibrary * | dosbase |
| static UWORD | maxw |
| static UWORD | maxh |
| static UWORD | maxd |
| static ULONG | bytespershape |
| static ULONG | centry |
| static ULONG | chunksize |
| static ULONG | chunkptr |
| static ULONG | chunkid |
| static ULONG | filehandle |
| static UBYTE * | paletteptr |
| static UBYTE * | startshape |
| static UBYTE * | endshape |
| static ULONG | shapecount |
| static UWORD | colourcount |
| static UWORD | aciddata_s1 |
| static UWORD | aciddata_s2 |
| static ULONG | aciddata_name |
| static UWORD | compress |
| static UWORD | compressed |
| static ULONG | packsize |
| static ULONG | packptr |
| static ULONG | packedsize |
| static LONG | inchip |
| static ULONG | cookeeemode = 1 |
| static struct lehead | emptyheader |
| static const char | pme [] = "Not enough memory to pack shapes" |
| static const char | coer [] = "Shape Compression Failed!" |
| #define __NOLIBBASE__ |
| #define DOS_BASE_NAME dosbase |
| #define FL | ( | p, | |
| T, | |||
| f ) |
| #define FW | ( | p, | |
| T, | |||
| f ) |
| #define SHL | ( | p, | |
| f ) |
| #define SHPAIR | ( | p, | |
| f ) |
| #define SL | ( | p, | |
| o ) |
| #define SW | ( | p, | |
| o ) |
| #define TOK_loadshapes ((LIB_shapeslib << 7) + 10) |
| #define TOK_packpbm ((LIB_ripacklib << 7) + 1) |
| #define TOK_unpackpbm ((LIB_ripacklib << 7) + 8) |
| void _leautocookie | ( | void | ) |
| void _lecludgeshapes | ( | void | ) |
| void _lecludgeshapes2 | ( | void | ) |
| void _leinitshape | ( | void | ) |
| void _leloadshapes | ( | void | ) |
| void _leloadshapesingle | ( | void | ) |
| void _leloadshapesinglenop | ( | void | ) |
| void _leloadshapesnop | ( | void | ) |
| void _leMaxShapeDepth | ( | void | ) |
| void _leMaxShapeHeight | ( | void | ) |
| void _leMaxShapeWidth | ( | void | ) |
| void _lesaveshapes | ( | void | ) |
| void _lesaveshapesnop | ( | void | ) |
| void _lescanshapes | ( | void | ) |
| void _loadshapes | ( | void | ) |
| void _loadshapestoaddress | ( | void | ) |
| void _safetoblit | ( | void | ) |
| void _setcompress | ( | void | ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
inlinestatic |
|
inlinestatic |
|
static |
|
static |
LEAutoCookie on|off: whether CludgeShapes makes the cookies of its shapes (on at the start).
| on | d0: any nonzero value is on Returns nothing (all registers kept). |
|
static |
LECludgeShapes shape#,shape#,address,palette#,copymemflag: the shapes (and the palette) of an LE file in memory.
Nothing if the file is no FORM LESH with SHHD first or has no SDAT. The shapes are linked into the memory ("cL", no copy) if the file is uncompressed and below 2 MB, unless copymemflag is negative or the shape lies at an odd address; otherwise copied (unpacked) into chip memory. Every shape gets a cookie. At most count + 1 shapes of the file are read. Fixed (#811): the SHHD and CMAP chunks are passed by their lengths with the IFF pad byte (a byte other than 0 there starts the next chunk); the original skipped SHHD as 20 bytes and the CMAP by the colours decoded, so a longer SHHD, a CMAP size that is no multiple of 3 or a pad byte missed SDAT. The palette as in LELoadShapes (fixed #820). Fixed (#1118): the chunk headers behind SHHD and the shape headers are read byte by byte, and a shape whose data lies at an odd address is copied (LESaveShapes writes an odd CMAP without its pad byte; the original read words there, an address error on a 68000, and linked the shapes at the odd address). Fixed (#810): the old cookies are freed. Fixed (#807): a shape in use that is cludged is replaced like any other (the original pops a0 it never pushed and returns past the caller).
|
static |
|
static |
LEInitShape shape#,width,height,depth: makes an empty shape.
A shape in use is freed first; the sizes are computed, the data and the cookie get new cleared chip memory (the cookie is not computed), the handles are 0. Without memory for the data no cookie is allocated. Fixed (#810): the old cookie is freed (the original's MOVE.l 18(a2),a1:BEQ tested the Z flag of the CLR before it, so it never freed it).
|
static |
|
static |
LELoadShapes shape#,filename$,palette#: as above from shape# up to the last shape (the maximum - 1), as many as the file has.
The declaration asks for the palette of d3, not of the third argument (!libs pd3), but no compiled program reaches this form: the compiler takes form 1 (shape#,shape#,filename$), the first with three arguments, as the manual says (not a defect, #812).
|
static |
|
static |
LELoadShapes shape#,shape#,filename$: as above without a palette (the CMAP is skipped).
|
static |
LELoadShapes shape#,shape#,filename$,palette#: loads the shapes (and the palette) of an LE file into the range of shapes.
At most count + 1 shapes of the file, unpacked if compressed, each with a cookie; the CMAP into the palette object. A file that is no FORM goes to shapeslib's LoadShapes (form 1), with the shape numbers (d0/d1 >> 5). BUG(orig): a failing chunk allocation frees the header buffer and closes the file twice (#819, never in practice); the palette: no check of the allocation (#821). Fixed (#820): a CMAP of no colour or of more than 65535 leaves the palette. Fixed (#810): the old cookies are freed. Fixed (#807): a shape in use that is cludged is replaced like any other (the original pops a0 it never pushed and returns past the caller without freeing the buffers or closing the file).
|
static |
LESaveShapes shape#,shape#,filename$,palette#: saves the range of shapes (and the palette) as an LE file.
FORM LESH, SHHD (count, compression), CMAP if there is a palette, SDAT with the shapes (packed with PackPBM if LECompressShapes is on, -1 = stored when packing fails). Nothing if the file cannot be opened. BUG(orig): a missing pack buffer is two runtime errors (#818). PackPBM's failure returns -1 and the shape is stored (ripacklib's fix of #772: the original's PackPBM ran on into UnPackPBM, here with d3 = 12, which rishapeslib passes as before). Fixed (#814): the CMAP is written whenever there is a palette with data (the original tested the Z flag of dos Write). Fixed (#823): a palette of 0 colours writes no CMAP (the original copied 65536). Fixed (#816): the FORM length is the file's size - 8 (the original's was 8 larger and had the CMAP size of the last save with a palette). Fixed (#817): the shape header buffer is 12 bytes (the original's had the upper word of the d0 that _saveCMAP left). Fixed (#815): the count is last - first as a word, sign-extended (the original's word subtraction kept the upper word of d1, which compiled code leaves from a long expression).
|
static |
|
static |
LEScanShapes startshape#,endshape#: the largest width, height and depth of the used shapes in the range (for LEMaxShape...).
Signed word compares; empty shapes (width 0) are skipped.
| shape | a2: the first shape object |
| last | a3: the last shape object Returns nothing (all registers kept). |
|
static |
init: LECompressShapes off, LEAutoCookie on, the maxima of LEScanShapes 0.
Fixed (#1109): the original's init clears only the compression flag, so a second run of a program with the library still loaded (from the editor) started with the LEAutoCookie setting and the maxima of the run before.
|
static |
CludgeShapes shape#,numshapes,address: makes shapes of shapes in memory (a 32-byte shape header + the data each), copied into chip memory.
Shapes that are in use are freed first; a cookie is made if LEAutoCookie is on. A failing cookie allocation would jump to the data address (#806, never in practice). Fixed (#809): an empty shape in memory (width or height 0) advances by 32 (the original by 32 + the low word of the size of the shape before, also of an earlier call). Fixed (#808): a shape whose size (plane size x depth) is 0 is taken as empty, and a size above 64 KB is copied whole (the original copied 65536 bytes for a size of 0, and only the low word of a larger size).
| shapenum | d0: shape# (unused: shifted by 5, as the original) |
| numshapes | d1: the number of shapes |
| address | d2: the shapes in memory |
| objects | a0: the shape object of shape# |
|
static |
CludgeShapesToAddress Address,numshapes,address: CludgeShapes into shape objects at an address of the program's own.
MOVE.l d0,a0:MOVEQ #0,d0, then as CludgeShapes (fixed: #808, #809).
| objects | d0: the first of numshapes shape objects (32 bytes each) |
| numshapes | d1: the number of shapes |
| address | d2: the shapes in memory |
|
static |
LEMaxShapeDepth: the largest depth of the last LEScanShapes.
|
static |
LEMaxShapeHeight: the largest height of the last LEScanShapes.
|
static |
LEMaxShapeWidth: the largest width of the last LEScanShapes.
|
static |
|
static |
|
static |
| void rishapeslib_libfinit | ( | void | ) |
finit (_libfinit): nothing, an RTS.
| void rishapeslib_libinit | ( | void | ) |
|
static |
|
static |
SafeToBlit(shape,x,y): whether the shape can be blitted at x,y into the used bitmap.
True if the shape exists (in range, has a cookie), x and y are not negative, and it fits into the bitmap's width and height (+56.w/+58.w of the bitmap object). d0 is the shape number shifted by 5, as compiled code passes it (pd0); the ASR #5 gives the number back for the compare with the maximum (not a defect, #822).
| shapenum | d0.w: shape * 32 |
| x | d1.w: x |
| y | d2.w: y |
| bitmap | a2: the used bitmap object |
| shape | a3: the shape object |
| maxshapes | d6: the maximum of shapes |
|
static |
|
static |
LECompressShapes True|False: whether LESaveShapes packs the shape data (PackPBM of RIPackLib).
| on | d0.w: negative (True) packs, else stored Returns nothing (all registers kept). |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |