BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
animlib.c File Reference
#include "blitzlib.h"
#include "blitzobj.h"

Data Structures

struct  delta
struct  anim
struct  iffstuff

Macros

#define HEADNODE(a)
#define TOK_ilbminit   ((LIB_ilbmifflib << 7) + 1) /* a0 = name -> a0 = info, d0 = 0: failed */
#define TOK_getpal   ((LIB_palettelib << 7) + 3) /* a0 = name, a1 = palette */
#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) /* d0 = id -> d0 = length, NE: not found */
#define TOK_iffskip   ((LIB_iffiolib << 7) + 7) /* d0 = number of bytes */
#define TOK_iffread   ((LIB_iffiolib << 7) + 8) /* a0 = buffer, d0 = length */
#define ALIBJSR_Z(tok, r)
#define OPAQUE(x)
#define iffbyte()
#define ifflong()
#define iffskip(n)
#define iffread(a, n)
#define iffclose()

Functions

void doframes (void)
 Frames(Anim#): the number of frames (inline MOVE 8(a0),d0).
void freeanim (void)
 Free Anim (the object's _free nullsub): free BODY and the delta nodes of the anim in a3.
void doanimload (struct anim *anim, ULONG name)
 LoadAnim Anim#,Filename$: load an IFF ANIM (op 5) into the anim.
void doanimload2 (struct anim *anim, ULONG name, ULONG pal)
 LoadAnim Anim#,Filename$,Palette#: LoadAnim, first the palette.
void doinitanim (void)
void doinitanim2 (void)
void donextframe (void)
void animchk (void)
void animchk2 (void)
void animchk3 (void)
void animchk4 (void)
static ULONG mulu16 (UWORD a, UWORD b)
static ULONG iffcall (UWORD tok, ULONG count, ULONG buf)
static ULONG ifffind (ULONG id, int *found)
static ULONG globalloc (ULONG size, ULONG flags)
static void globfree (ULONG mem, ULONG size)
static void freeanim_c (struct anim *anim)
static void initanim (struct anim *anim, struct bb_bitmap *bm)
static void doinitanim_c (struct anim *anim, struct bb_bitmap *bm)
 InitAnim Anim#: decode BODY into the used bitmap.
 BLITZ_ALIAS (doinitanim, doinitanim_c)
static void doinitanim2_c (struct anim *anim, struct bb_bitmap *bm, struct bb_bitmap *bm2)
 InitAnim Anim#,BitMap#: InitAnim, then the planes copied to the second bitmap (double buffering).
 BLITZ_ALIAS (doinitanim2, doinitanim2_c)
static void donextframe_c (struct anim *anim, struct bb_bitmap *bm)
 NextFrame Anim#: apply the current delta to the used bitmap.
 BLITZ_ALIAS (donextframe, donextframe_c)
 BLITZ_ERRCHK_ASM (errors, "_err1: move.l #_mess1,d0\n trap #0\n" "_err2: move.l #_mess2,d0\n trap #0\n" "_err3: move.l #_mess3,d0\n trap #0\n" "_err4: move.l #_mess4,d0\n trap #0\n" "_err5: move.l #_mess5,d0\n trap #0\n")
static void animchk_c (struct anim *anim, struct bb_bitmap *bm)
static void animchk2_c (struct anim *anim, struct bb_bitmap *bm2)
static void animchk3_c (struct anim *anim, struct bb_bitmap *bm)
static void animchk4_c (struct anim *anim)

Variables

static const char mess6 [] = "Anim format not supported"
static const char mess7 [] = "Can't Open Anim File"

Macro Definition Documentation

◆ ALIBJSR_Z

#define ALIBJSR_Z ( tok,
r )
Value:
({ \
register ULONG _d0 __asm("d0") = (r).d0; \
register ULONG _d1 __asm("d1") = (r).d1; \
register ULONG _a0 __asm("a0") = (r).a0; \
register ULONG _a1 __asm("a1") = (r).a1; \
UBYTE _z; \
__asm volatile("jsr _blitz_tok+%c5\n\tseq %4" \
: "+d"(_d0), "+d"(_d1), "+a"(_a0), "+a"(_a1), "=m"(_z) \
: "i"(BL_TOKVAL(tok, 0)) \
: "d2", "d3", "d4", "d5", "d6", "d7", "a2", "a6", "cc", "memory"); \
(r).d0 = _d0; (r).d1 = _d1; (r).a0 = _a0; (r).a1 = _a1; _z; })
#define BL_TOKVAL(tok, form)
Definition blitzlib.h:526

◆ HEADNODE

#define HEADNODE ( a)
Value:
((struct delta *)&(a)->first)
Definition animlib.c:142

◆ iffbyte

void iffbyte ( )
Value:
iffcall(0, 0, 0)
static ULONG iffcall(UWORD tok, ULONG count, ULONG buf)
Definition animlib.c:221

◆ iffclose

void iffclose ( )
Value:
iffcall(4, 0, 0)

◆ ifflong

void ifflong ( )
Value:
iffcall(1, 0, 0)

◆ iffread

#define iffread ( a,
n )
Value:
iffcall(3, (n), (ULONG)(a))
ULONG WORD UWORD UWORD border ULONG ULONG struct bb_bitmap *dst void UWORD n
Definition 2dlib.c:2498

◆ iffskip

#define iffskip ( n)
Value:
iffcall(2, (n), 0)

◆ OPAQUE

#define OPAQUE ( x)
Value:
__asm__("" : "+r"(x))
ULONG x
Definition 2dlib.c:2491

◆ TOK_getpal

#define TOK_getpal   ((LIB_palettelib << 7) + 3) /* a0 = name, a1 = palette */

◆ TOK_iffbyte

#define TOK_iffbyte   ((LIB_iffiolib << 7) + 3)

◆ TOK_iffclose

#define TOK_iffclose   ((LIB_iffiolib << 7) + 2)

◆ TOK_ifffind

#define TOK_ifffind   ((LIB_iffiolib << 7) + 6) /* d0 = id -> d0 = length, NE: not found */

◆ TOK_ifflong

#define TOK_ifflong   ((LIB_iffiolib << 7) + 5)

◆ TOK_iffread

#define TOK_iffread   ((LIB_iffiolib << 7) + 8) /* a0 = buffer, d0 = length */

◆ TOK_iffskip

#define TOK_iffskip   ((LIB_iffiolib << 7) + 7) /* d0 = number of bytes */

◆ TOK_ilbminit

#define TOK_ilbminit   ((LIB_ilbmifflib << 7) + 1) /* a0 = name -> a0 = info, d0 = 0: failed */

Function Documentation

◆ animchk()

void animchk ( void )

◆ animchk2()

void animchk2 ( void )

◆ animchk2_c()

void animchk2_c ( struct anim * anim,
struct bb_bitmap * bm2 )
static

◆ animchk3()

void animchk3 ( void )

◆ animchk3_c()

void animchk3_c ( struct anim * anim,
struct bb_bitmap * bm )
static

◆ animchk4()

void animchk4 ( void )

◆ animchk4_c()

void animchk4_c ( struct anim * anim)
static

◆ animchk_c()

void animchk_c ( struct anim * anim,
struct bb_bitmap * bm )
static

◆ BLITZ_ALIAS() [1/3]

BLITZ_ALIAS ( doinitanim ,
doinitanim_c  )

◆ BLITZ_ALIAS() [2/3]

BLITZ_ALIAS ( doinitanim2 ,
doinitanim2_c  )

◆ BLITZ_ALIAS() [3/3]

BLITZ_ALIAS ( donextframe ,
donextframe_c  )

◆ BLITZ_ERRCHK_ASM()

BLITZ_ERRCHK_ASM ( errors ,
"_err1: move.l # _mess1,
d0\n trap #0\n" "_err2:move.l # _mess2,
d0\n trap #0\n" "_err3:move.l # _mess3,
d0\n trap #0\n" "_err4:move.l # _mess4,
d0\n trap #0\n" "_err5:move.l # _mess5,
d0\n trap #0\n"  )

◆ doanimload()

void doanimload ( struct anim * anim,
ULONG name )

LoadAnim Anim#,Filename$: load an IFF ANIM (op 5) into the anim.

Amiga mode only (code+1). Frees the anim, opens the file with ilbmifflib ilbminit (BMHD -> width, height, depth, byte width), reads BODY, then ANHD (the operation byte must be 5; 19 bytes skipped, bit 1 of bits = EOR) and every following DLTA chunk into a delta node; frames = number of DLTAs - 1 (1 without ANHD). The file is read through iffiolib. a3 is left on the last delta node (or anim+18; not a bug). Errors: "Can't Open Anim File" (err7), "Anim format not supported" (err6), both in the normal code (fixed, #398: the original's err7 is in the error check area, err6's text too). Fixed (#400): a missing BODY is length 0 and nothing is allocated (the original took the "not found" -1 as the length).

Parameters
anima0: the anim (!libs {animlib,$1080}, from Anim# in d0)
named1: the file name

◆ doanimload2()

void doanimload2 ( struct anim * anim,
ULONG name,
ULONG pal )

LoadAnim Anim#,Filename$,Palette#: LoadAnim, first the palette.

Calls palettelib +3 (a0 = file name, a1 = palette), then LoadAnim.

Parameters
anima0: the anim (!libs {animlib,$1080}, from Anim# in d0)
named1: the file name
pala1: the palette (!libs {palettelib,$1182}, from Palette# in d2)

◆ doframes()

void doframes ( void )

Frames(Anim#): the number of frames (inline MOVE 8(a0),d0).

a0 = the anim (!libs {animlib,$1080}); d0.w = the number of DLTA chunks - 1 (1 without ANHD). Error (debugger, animchk4): "Uninitialized Anim".

◆ doinitanim()

void doinitanim ( void )

◆ doinitanim2()

void doinitanim2 ( void )

◆ doinitanim2_c()

void doinitanim2_c ( struct anim * anim,
struct bb_bitmap * bm,
struct bb_bitmap * bm2 )
static

InitAnim Anim#,BitMap#: InitAnim, then the planes copied to the second bitmap (double buffering).

a3 is left in the last plane of the second bitmap (not a bug). Errors (debugger, animchk2): as InitAnim, checked for the second bitmap.

Parameters
anima0: the anim (!libs {animlib,$1080}, from Anim# in d0)
bma1: the used bitmap (!libs {bitmaplib,$1102})
bm2a2: the second bitmap (!libs {bitmaplib,$1281}, from BitMap# in d1)

◆ doinitanim_c()

void doinitanim_c ( struct anim * anim,
struct bb_bitmap * bm )
static

InitAnim Anim#: decode BODY into the used bitmap.

BODY is decoded as ByteRun1, or copied row by row for the BMHD compression 0, and a run ends at the end of the row (fixed, #397: the original decoded every BODY as ByteRun1 and wrote a long run behind the row); the current delta becomes the first one; an anim without BODY data decodes nothing (fixed, #400, #402: a missing BODY or a dimension 0, the original ran its counters 65536 times). a3 is left behind the BODY data (not a bug). Errors (debugger, animchk): "Uninitialized Anim", "Uninitialized BitMap", "BitMap not large enough for ANIM".

Parameters
anima0: the anim (!libs {animlib,$1080}, from Anim# in d0)
bma1: the used bitmap (!libs {bitmaplib,$1102})

◆ donextframe()

void donextframe ( void )

◆ donextframe_c()

void donextframe_c ( struct anim * anim,
struct bb_bitmap * bm )
static

NextFrame Anim#: apply the current delta to the used bitmap.

Per plane the column ops skip/uniq/same, written (MOVE) or EORed; then the next node, after the last one the SECOND node (not a bug: the ANIM op-5 double-buffer loop, the last two deltas lead back to frames 0/1). Fixed (#401): the first node if there is no second one (the original makes the current delta 0), and nothing at all without a current delta. a3 is left on the current (or first) node (not a bug). Errors (debugger, animchk3): "Anim has only 1 frame", "Anim not Initialized", then as InitAnim.

Parameters
anima0: the anim (!libs {animlib,$1080}, from Anim# in d0)
bma1: the used bitmap (!libs {bitmaplib,$1102})

◆ freeanim()

void freeanim ( void )

Free Anim (the object's _free nullsub): free BODY and the delta nodes of the anim in a3.

Only a loaded anim (width not 0); width is cleared. Fixed (#399): the next pointer of a delta node is read before the node is freed (the original read it after the FreeMem).

◆ freeanim_c()

void freeanim_c ( struct anim * anim)
static

◆ globalloc()

ULONG globalloc ( ULONG size,
ULONG flags )
static

◆ globfree()

void globfree ( ULONG mem,
ULONG size )
static

◆ iffcall()

ULONG iffcall ( UWORD tok,
ULONG count,
ULONG buf )
static

◆ ifffind()

ULONG ifffind ( ULONG id,
int * found )
static

◆ initanim()

void initanim ( struct anim * anim,
struct bb_bitmap * bm )
static

◆ mulu16()

ULONG mulu16 ( UWORD a,
UWORD b )
inlinestatic

Variable Documentation

◆ mess6

const char mess6[] = "Anim format not supported"
static

◆ mess7

const char mess7[] = "Can't Open Anim File"
static