|
BB2 C port
API reference: Blitz libraries in C and the shared code
|
#include "blitzlib.h"#include "blitzobj.h"#include <stddef.h>#include <proto/dos.h>#include <proto/graphics.h>Data Structures | |
| struct | xregs |
Macros | |
| #define | __NOLIBBASE__ |
| #define | AMIGAONLY(entry) |
| #define | XJSR(tok, r) |
| #define | TOK_extbitmap ((LIB_bitmaplib << 7) + 4) |
| #define | TOK_scroll ((LIB_scrolllib << 7) + 2) |
| #define | TOK_palload ((LIB_palettelib << 7) + 3) |
| #define | TOK_ilbminit ((LIB_ilbmifflib << 7) + 1) |
| #define | TOK_ilbmgetbyte ((LIB_ilbmifflib << 7) + 2) |
| #define | TOK_iffclose ((LIB_iffiolib << 7) + 2) |
| #define | TOK_iffbyte ((LIB_iffiolib << 7) + 3) |
| #define | TOK_ifflong ((LIB_iffiolib << 7) + 5) |
| #define | TOK_ifffind ((LIB_iffiolib << 7) + 6) |
| #define | TOK_iffskip ((LIB_iffiolib << 7) + 7) |
| #define | SW(s, o) |
| #define | SL(s, o) |
| #define | SP(s, o) |
| #define | HANDLES(s) |
| #define | DOSBase dosbase /* for proto/dos.h */ |
| #define | IJSRZ(tok, d0v, a0v, zp) |
| #define | IJSR(tok, d0v, a0v) |
Functions | |
| void | doshload (void) |
| void | doshload2 (void) |
| void | docookie (void) |
| void | doshapew (void) |
| ShapeWidth(Shape#) - the shape's pixel width. | |
| void | doshapeh (void) |
| ShapeHeight(Shape#) - the shape's pixel height (only the low word of d0, as ShapeWidth). | |
| void | dohandle (void) |
| Handle Shape#,X,Y - set the shape's handle; a3 = the shape. | |
| void | doautocookie (void) |
| void | docopyshape (void) |
| void | dogetashape (void) |
| void | b_getashape (void) |
| void | dosaveshapes (void) |
| void | doloadshapes (void) |
| void | doloadshapes2 (void) |
| void | domidhandle (void) |
| void | _cludgeshapes (void) |
| void | _cludgeshapes2 (void) |
| void | _initshape (void) |
| void | shapeslib_codeinit (void) |
| void | freeashape (void) |
| void | cookiechk (void) |
| void | initchk (void) |
| void | funcchk (void) |
| void | gschk (void) |
| void | schkz (void) |
| static void * | globalloc (ULONG size, ULONG flags) |
| static void | globfree (void *mem, ULONG size) |
| static void | codeinit_c (void) |
| Library init: AutoCookie on. | |
| static ULONG | shsize (const struct bb_shape *s) |
| static void | freeashape_ (struct bb_shape *s) |
| static void | freeashape_c (void) |
| Object free routine (_free) of a Shape: free its data and cookie. | |
| static void | cookie_ (struct bb_shape *s) |
| static void | docookie_c (void) |
| MakeCookie Shape# - make the shape's cookie, also nullsub +11 docookie for other libraries (shapetrixlib). | |
| static void | doautocookie_c (ULONG v) |
| AutoCookie On|Off - make cookies automatically for the shapes of LoadShape(s), GetaShape, InitShape and DecodeShapes. | |
| BLITZ_ALIAS (doautocookie, doautocookie_c) | |
| static void | domidhandle_c (void) |
| MidHandle Shape# - put the handle in the middle (width/2, height/2); a3 = the shape. | |
| BLITZ_ALIAS (domidhandle, domidhandle_c) | |
| static void | nall (struct bb_shape *from, struct bb_shape *to, UWORD ptroff, ULONG size) |
| static void | copyshape2 (struct bb_shape *from, struct bb_shape *to) |
| static void | docopyshape_c (struct bb_shape *dst) |
| CopyShape Shape#,Shape# - copy the first shape (a3) into the second. | |
| BLITZ_ALIAS (docopyshape, docopyshape_c) | |
| static void | initshape_c (ULONG w, ULONG h, ULONG d) |
| InitShape Shape#,Width,Height,Depth - create an empty shape. | |
| BLITZ_ALIAS (_initshape, initshape_c) | |
| static void | getashape (struct bb_shape *shape, struct bb_bitmap *bm, UWORD x, UWORD y, UWORD w, UWORD h) |
| void | b_getashape_c (ULONG x, ULONG y, ULONG w, ULONG h, struct bb_bitmap *bm) |
| GetaShape Shape#,X,Y,Width,Height - make a shape from an area of the used bitmap (Blitz mode; also nullsub +14 b_getashape). | |
| void | a_getashape_c (ULONG x, ULONG y, ULONG w, ULONG h, struct bb_bitmap *bm, struct GfxBase *gfx) |
| GetaShape in Amiga mode: OwnBlitter, the Blitz mode routine, wait, DisownBlitter. | |
| static void | dosaveshapes_c (struct bb_shape *last, const char *name, struct DosLibrary *dos) |
| SaveShapes Shape#,Shape#,Filename$ - save the shapes a3..a2. | |
| BLITZ_ALIAS (dosaveshapes, dosaveshapes_c) | |
| static void | loadshapes (struct bb_shape *s, struct bb_shape *last, const char *name, struct DosLibrary *dos) |
| static void | doloadshapes_c (struct bb_shape *last, const char *name, struct DosLibrary *dos) |
| LoadShapes Shape#,Shape#,Filename$ - load the shapes a3..a2 from a SaveShapes file. | |
| BLITZ_ALIAS (doloadshapes, doloadshapes_c) | |
| static void | doloadshapes2_c (UBYTE *base, ULONG max, const char *name, struct DosLibrary *dos) |
| LoadShapes Shape#,Filename$ - load shapes from a3 on up to the last shape object (as doloadshapes_c). | |
| BLITZ_ALIAS (doloadshapes2, doloadshapes2_c) | |
| static void | cludge (struct bb_shape *shape, struct bb_shape *last, UBYTE *mem) |
| static void | cludgeshapes_c (struct bb_shape *last, UBYTE *mem) |
| DecodeShapes Shape#,Shape#,MemoryLocation - the shapes a3..a2 from a SaveShapes file in memory. | |
| BLITZ_ALIAS (_cludgeshapes, cludgeshapes_c) | |
| static void | cludgeshapes2_c (UBYTE *base, ULONG max, UBYTE *mem) |
| DecodeShapes Shape#,MemoryLocation - as cludgeshapes_c from a3 on up to the last shape object. | |
| BLITZ_ALIAS (_cludgeshapes2, cludgeshapes2_c) | |
| static void | doshload_ (struct bb_shape *shape, const char *name, const struct bb_shape *last) |
| static void | doshload_c (struct bb_shape *shape, const char *name, UBYTE *base, ULONG max) |
| LoadShape Shape#,Filename$ - load an ILBM (or ANIM) as a shape. | |
| BLITZ_ALIAS (doshload, doshload_c) | |
| static void | doshload2_c (struct bb_shape *shape, const char *name, void *pal, UBYTE *base, ULONG max) |
| LoadShape Shape#,Filename$,Palette# - load the file's palette (palettelib +3: a0 = file name, a1 = palette), then as doshload_c. | |
| BLITZ_ALIAS (doshload2, doshload2_c) | |
| static void | schkz_c (struct bb_shape *last) |
| static void | funcchk_c (const struct bb_shape *s) |
| static void | cookiechk_c (void) |
| static int | toobig (UWORD w, UWORD h) |
| static void | initchk_c (ULONG w, ULONG h, ULONG d) |
| static void | gschk_c (ULONG x, ULONG y, ULONG w, ULONG h, struct bb_bitmap *bm) |
Variables | |
| static UWORD | autocook = 0xffff |
| struct { | |
| struct bb_bitmap bm | |
| UWORD h | |
| UWORD w | |
| } | tb |
| static const char | mess10 [] = "Shapes file at memory location 0? NOWAY!" |
| static const char | mess2 [] = "Can't open Shapes File" |
| static const char | mess3 [] = "Can't Read/Write Shapes File" |
| static const char | mess14 [] = "Illegal Shape Depth" |
| static const char | mess15 [] = "Illegal Shape Size" |
| static const char | mess7 [] = "ANIM format not supported" |
| static struct DosLibrary * | dosbase |
| static UWORD | xordelta |
| static ULONG | planeoffs [8] |
| #define __NOLIBBASE__ |
| #define AMIGAONLY | ( | entry | ) |
| #define HANDLES | ( | s | ) |
| #define IJSR | ( | tok, | |
| d0v, | |||
| a0v ) |
| #define IJSRZ | ( | tok, | |
| d0v, | |||
| a0v, | |||
| zp ) |
| #define SL | ( | s, | |
| o ) |
| #define SP | ( | s, | |
| o ) |
| #define SW | ( | s, | |
| o ) |
| #define TOK_extbitmap ((LIB_bitmaplib << 7) + 4) |
| #define TOK_iffbyte ((LIB_iffiolib << 7) + 3) |
| #define TOK_iffclose ((LIB_iffiolib << 7) + 2) |
| #define TOK_ifffind ((LIB_iffiolib << 7) + 6) |
| #define TOK_ifflong ((LIB_iffiolib << 7) + 5) |
| #define TOK_iffskip ((LIB_iffiolib << 7) + 7) |
| #define TOK_ilbmgetbyte ((LIB_ilbmifflib << 7) + 2) |
| #define TOK_ilbminit ((LIB_ilbmifflib << 7) + 1) |
| #define TOK_palload ((LIB_palettelib << 7) + 3) |
| #define TOK_scroll ((LIB_scrolllib << 7) + 2) |
| #define XJSR | ( | tok, | |
| r ) |
| void _cludgeshapes | ( | void | ) |
| void _cludgeshapes2 | ( | void | ) |
| void _initshape | ( | void | ) |
| void a_getashape_c | ( | ULONG | x, |
| ULONG | y, | ||
| ULONG | w, | ||
| ULONG | h, | ||
| struct bb_bitmap * | bm, | ||
| struct GfxBase * | gfx ) |
GetaShape in Amiga mode: OwnBlitter, the Blitz mode routine, wait, DisownBlitter.
| gfx | a6: graphics.library |
| void b_getashape | ( | void | ) |
| void b_getashape_c | ( | ULONG | x, |
| ULONG | y, | ||
| ULONG | w, | ||
| ULONG | h, | ||
| struct bb_bitmap * | bm ) |
GetaShape Shape#,X,Y,Width,Height - make a shape from an area of the used bitmap (Blitz mode; also nullsub +14 b_getashape).
a3 = the shape; the old one is freed. bitmaplib +4 (extbitmap) creates a bitmap of the area's size in tbmap, scrolllib Scroll copies the area into it, and its planes become the shape's data; then a blitter wait ("20/8/93 waitblit after getashape b4 makecookie") and the cookie with AutoCookie on.
Errors (gschk, debugger only): "Uninitialized BitMap", "Cannot GetaShape from an interleaved Bitmap", "Illegal area for GetaShape", "Shape too Big" (a plane of 64K or more with the extra word per row, more than 1023 rows or 62 words; fixed, #1047, #1046: the original has no check).
| BLITZ_ALIAS | ( | _cludgeshapes | , |
| cludgeshapes_c | ) |
| BLITZ_ALIAS | ( | _cludgeshapes2 | , |
| cludgeshapes2_c | ) |
| BLITZ_ALIAS | ( | _initshape | , |
| initshape_c | ) |
| BLITZ_ALIAS | ( | doautocookie | , |
| doautocookie_c | ) |
| BLITZ_ALIAS | ( | docopyshape | , |
| docopyshape_c | ) |
| BLITZ_ALIAS | ( | doloadshapes | , |
| doloadshapes_c | ) |
| BLITZ_ALIAS | ( | doloadshapes2 | , |
| doloadshapes2_c | ) |
| BLITZ_ALIAS | ( | domidhandle | , |
| domidhandle_c | ) |
| BLITZ_ALIAS | ( | dosaveshapes | , |
| dosaveshapes_c | ) |
| BLITZ_ALIAS | ( | doshload | , |
| doshload_c | ) |
| BLITZ_ALIAS | ( | doshload2 | , |
| doshload2_c | ) |
|
static |
DecodeShapes Shape#,MemoryLocation - as cludgeshapes_c from a3 on up to the last shape object.
Fixed (#999): the last shape is a2 + (max - 1) << 5 as a long, as in doloadshapes2_c. Address 0: runtime error, as cludgeshapes_c (#270).
| base | a2: shape 0 |
| max | d2: the maximum |
| mem | d1: the address of the data |
|
static |
DecodeShapes Shape#,Shape#,MemoryLocation - the shapes a3..a2 from a SaveShapes file in memory.
Stops silently at the first block that does not match (not a bug: the end of the sequence). Memory below 2 MB ($FFE00000 clear, chip RAM) is used in place and marked "cL" (never freed), above it is copied to CHIP memory. Cookie with AutoCookie on. Fixed (#267): +30 of a block is not taken over (a copied shape owns its data).
Address 0: runtime error "Shapes file at memory location 0? NOWAY!" (err10, in the normal code; the original branches into the error check area, fixed: #270).
| last | a2: the last shape |
| mem | d2: the address of the data |
|
static |
Library init: AutoCookie on.
|
static |
| void cookiechk | ( | void | ) |
|
static |
| void doautocookie | ( | void | ) |
|
static |
AutoCookie On|Off - make cookies automatically for the shapes of LoadShape(s), GetaShape, InitShape and DecodeShapes.
| v | d0.w: <> 0 = on |
| void docookie | ( | void | ) |
|
static |
MakeCookie Shape# - make the shape's cookie, also nullsub +11 docookie for other libraries (shapetrixlib).
a3 = the shape. An old cookie is freed; the new one (bytes per plane, CHIP, cleared, not checked) is the OR of all planes.
Errors: "Uninitialized Shape" (cookiechk, debugger only).
| void docopyshape | ( | void | ) |
|
static |
CopyShape Shape#,Shape# - copy the first shape (a3) into the second.
The destination is freed, the 32 byte block copied, then the data and the cookie are copied into new CHIP memory (not checked).
Fixed (#268): +30 of the copy is cleared (the original copied "cL" of a DecodeShapes shape along, and the copy was never freed). Errors: "Uninitialized Shape" (cookiechk, debugger only).
| dst | a2: the destination shape |
| void dogetashape | ( | void | ) |
| void dohandle | ( | void | ) |
Handle Shape#,X,Y - set the shape's handle; a3 = the shape.
Errors: "Uninitialized Shape" (cookiechk, debugger only).
In: a3 the shape, d1.w the handle x, d2.w the handle y
| void doloadshapes | ( | void | ) |
| void doloadshapes2 | ( | void | ) |
|
static |
LoadShapes Shape#,Filename$ - load shapes from a3 on up to the last shape object (as doloadshapes_c).
Fixed (#999): the last shape is a2 + (max - 1) << 5 as a long (the maximum is the low word of d2); the original adds the offset as a word (from a maximum of 1025 on the last shape lies before the table).
| base | a2: shape 0 |
| max | d2: the maximum |
| name | d1: the file name |
| dos | a6: dos.library |
|
static |
LoadShapes Shape#,Shape#,Filename$ - load the shapes a3..a2 from a SaveShapes file.
Every block is checked (planesize, size), the data loaded into CHIP memory (not checked), the cookie made with AutoCookie on; the end of the file ends the loading.
Fixed (#267): +30 of the block is cleared (the original kept "cL" of a saved DecodeShapes shape, and the data was never freed). Errors: "Can't open Shapes File", "Can't Read/Write Shapes File" (in the normal code); "First shape must be lower than second" (schkz, debugger only).
| void domidhandle | ( | void | ) |
|
static |
MidHandle Shape# - put the handle in the middle (width/2, height/2); a3 = the shape.
Errors: "Uninitialized Shape" (cookiechk, debugger only).
| void dosaveshapes | ( | void | ) |
|
static |
SaveShapes Shape#,Shape#,Filename$ - save the shapes a3..a2.
Every shape's 32 byte block, followed by its data (+26 bytes) for a used shape.
Errors: "Can't open Shapes File", "Can't Read/Write Shapes File" (in the normal code with their texts, fixed: #953); "First shape must be lower than second" (schkz, debugger only).
| void doshapeh | ( | void | ) |
ShapeHeight(Shape#) - the shape's pixel height (only the low word of d0, as ShapeWidth).
Errors: "Uninitialized Shape" (funcchk, debugger only).
In: a0 the shape Out: d0.w the height
| void doshapew | ( | void | ) |
ShapeWidth(Shape#) - the shape's pixel width.
MOVE (a0),d0 - only the low word (not a bug: a word function, the compiler uses only d0.w).
Errors: "Uninitialized Shape" (funcchk, debugger only).
In: a0 the shape Out: d0.w the width
| void doshload | ( | void | ) |
| void doshload2 | ( | void | ) |
|
static |
LoadShape Shape#,Filename$,Palette# - load the file's palette (palettelib +3: a0 = file name, a1 = palette), then as doshload_c.
| shape | a0: the shape |
| name | d1: the file name |
| pal | a1: the palette object |
| base | a2: the shape table (object 0) |
| max | d3: the maximum number of shapes |
|
static |
LoadShape Shape#,Filename$ - load an ILBM (or ANIM) as a shape.
Through ilbmifflib (ilbminit, ilbmgetbyte) and iffiolib; data in CHIP memory (not checked), cookie with AutoCookie on. After the first frame every "ANHD" (ANIM op 5) gives a delta frame in the NEXT shape object (a copy of the frame its interleave names with the DLTA applied, XOR or set per the bits of its ANHD; the operation is checked in the first ANHD). Extension (#1166): the interleave of each ANHD is taken as the ANIM specification defines it, n frames back (0 = 2, double buffering); a frame with fewer frames before it is made from the first frame. The original took only 1 ("Illegal ANIM interleave value"). Fixed (#266): each frame takes the XOR bit of its own ANHD; the original read only the first ANHD's. Fixed (#265): the frames stop at the last shape object (the rest of the file is not read); the original wrote them behind the shape table.
Fixed (#263): the plane steps are unsigned (the original's word steps went backwards for planes of 32K and more); an ILBM with a plane of 64K or more is refused with "Can't Read/Write Shapes File" (the shape keeps the bytes per plane in a word). Fixed (#1055): the plane with the extra word of every row ((bytes per row + 2) x height, +24) is tested, as by the error checks of InitShape and GetaShape.
BUG(orig): "BODY" is not checked, the decoder reads whatever follows (#264). Errors (in the normal code, their texts in the error area): "Can't open Shapes File", "ANIM format not supported" (op <> 5 in the first ANHD; it closes the file first and keeps the first frame loaded, fixed #1072: the original left the file open), "Can't Read/Write Shapes File" (a plane with the extra word of every row of 64K or more, fixed #263, #1055; more than 1023 rows or 62 words, fixed #1046), "Illegal Shape Depth" (0 planes, fixed #1052: the original wrote 65536 planes of every row behind a block of 0 bytes), "Illegal Shape Size" (a width or height of 0, fixed #1054: the original ran its row or byte loop 65536 times behind a block of 0 bytes); "Can't Read File" of ilbmifflib's ilbmgetbyte (a file that ends inside the BODY; it closes the file first, fixed #1065: the original left it open).
| shape | a0: the shape (a3 for the IFF calls) |
| name | d1: the file name |
| base | a2: the shape table (object 0) |
| max | d3: the maximum number of shapes |
| void freeashape | ( | void | ) |
|
static |
|
static |
Object free routine (_free) of a Shape: free its data and cookie.
a3 = the shape. The width is cleared; the data is freed unless +30 is "cL" (DecodeShapes data in place), the cookie if there is one.
Fixed (#269): +30 is cleared for a "cL" shape too (the original left the mark, so a later shape in this object was never freed either).
| void funcchk | ( | void | ) |
|
static |
|
static |
|
static |
|
static |
| void gschk | ( | void | ) |
|
static |
| void initchk | ( | void | ) |
|
static |
|
static |
InitShape Shape#,Width,Height,Depth - create an empty shape.
a3 = the shape; the old one is freed. Data cleared (CHIP, not checked), handle 0, a cleared cookie with AutoCookie on.
The sizes +22/+26 are the low words of MULU; the data is allocated with the long product. Errors (debugger, initchk): "Illegal Shape Depth" for a depth of 0 (fixed, #243 #74: the original had no check; a shape of depth 0 made the plane loops of the blit commands run 65536 times); "Illegal Shape Size" for a width or height of 0 and "Shape too Big" for a plane of 64K or more with the extra word per row (fixed, #1047: not checked in the original, the word sizes +22/+24 were wrong) or a shape taller than 1023 rows or wider than 62 words (992 pixels; fixed, #1046: the blit size word +8 overflowed).
|
static |
| void schkz | ( | void | ) |
|
static |
| void shapeslib_codeinit | ( | void | ) |
|
static |
|
static |
|
static |
| struct bb_bitmap bm |
|
static |
| UWORD h |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| struct { ... } tb |
| UWORD w |
|
static |