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

Data Structures

struct  blitstate

Macros

#define __NOLIBBASE__
#define GRAPHICS_BASE_NAME   gfx
#define BLIT_LIBS
#define MODE_FN(code, name)
#define SHIFT(x)
#define REG_ARGS

Functions

void blitlib_doblit (void)
void blitlib_doblitex (void)
void b_doblitex (void)
void doblock (void)
void doblitcoll (void)
void blitlib_doblitmode (void)
void docookiemode (void)
 CookieMode, EraseMode, InvMode, SolidMode: the BlitMode values $FCA (cookie cut), $B0A (erase), $B5A (invert), $BFA (solid).
void doerasemode (void)
void doinvmode (void)
void dosolidmode (void)
void blitlib_codeinit (void)
void blitchk (void)
void blitchknc (void)
void blitchk3 (void)
 MODE_FN (docookiemode, "CookieMode")
 MODE_FN (doerasemode, "EraseMode")
 MODE_FN (doinvmode, "InvMode")
 MODE_FN (dosolidmode, "SolidMode")
BL_ALWAYS_INLINE ULONG offset (const struct bb_bitmap *bm, WORD x, WORD y)
BL_ALWAYS_INLINE void setmods (const struct bb_shape *shape, const struct bb_bitmap *bm, UBYTE *cb)
BL_ALWAYS_INLINE void blitsetup (const struct bb_shape *shape, const struct bb_bitmap *bm, UBYTE *cb, WORD x, WORD y, struct blitstate *st)
BL_ALWAYS_INLINE UBYTE ** blitplanes (UBYTE *cb, UBYTE **plane, UWORD n, ULONG cookie, ULONG off, UWORD size)
BL_ALWAYS_INLINE void blit (const struct bb_shape *shape, const struct bb_bitmap *bm, UBYTE *cb, WORD x, WORD y)
BL_ALWAYS_INLINE void blitex (const struct bb_shape *shape, const struct bb_bitmap *bm, UBYTE *cb, WORD x, WORD y, UWORD bits)
BL_ALWAYS_INLINE void block (const struct bb_shape *shape, const struct bb_bitmap *bm, UBYTE *cb, WORD x, WORD y)
BL_ALWAYS_INLINE LONG blitcoll (const struct bb_shape *shape, const struct bb_bitmap *bm, UBYTE *cb, WORD x, WORD y)
static BLITZ_ENTRYPOINT void b_doblit_c (WORD x, WORD y, UBYTE *cb, const struct bb_bitmap *bm)
 Blit Shape#,X,Y: blit the shape into the used bitmap (Blitz mode).
 BLITZ_EP_MARK (b_doblit_c)
static void a_doblit_c (WORD x, WORD y, UBYTE *cb, const struct bb_bitmap *bm, struct Library *gfx)
 Blit Shape#,X,Y (Amiga mode).
static BLITZ_ENTRYPOINT void b_doblitex_c (WORD x, WORD y, UBYTE *cb, const struct bb_bitmap *bm, UWORD bits)
 Blit Shape#,X,Y,Excessonoff (Blitz mode; the nullsub b_doblitex for other libraries is the same code as a normal C function).
 BLITZ_EP_MARK (b_doblitex_c)
static void n_doblitex_c (WORD x, WORD y, UBYTE *cb, const struct bb_bitmap *bm, UWORD bits)
static void a_doblitex_c (WORD x, WORD y, UBYTE *cb, const struct bb_bitmap *bm, UWORD bits, struct Library *gfx)
 Blit Shape#,X,Y,Excessonoff (Amiga mode).
static BLITZ_ENTRYPOINT void b_doblock_c (WORD x, WORD y, UBYTE *cb, const struct bb_bitmap *bm)
 Block Shape#,X,Y: copy the shape into the used bitmap (Blitz mode).
 BLITZ_EP_MARK (b_doblock_c)
void a_doblock_c (WORD x, WORD y, UBYTE *cb, const struct bb_bitmap *bm, struct Library *gfx)
 Block Shape#,X,Y (Amiga mode).
static BLITZ_ENTRYPOINT BB_BOOL b_doblitcoll_c (WORD x, WORD y, UBYTE *cb, const struct bb_bitmap *bm)
 BlitColl(Shape#,x,y): does the shape's cookie hit a set pixel of the used bitmap (Blitz mode)?
 BLITZ_EP_MARK (b_doblitcoll_c)
ULONG a_doblitcoll_c (WORD x, WORD y, UBYTE *cb, const struct bb_bitmap *bm, struct Library *gfx)
 BlitColl(Shape#,x,y) (Amiga mode).
static void doblitmode_c (UWORD m)
 BlitMode BLTCON0: the minterm/channel bits of Blit's BLTCON0 (ORed with the shift; CookieMode ... give the usual values).
 BLITZ_ALIAS (blitlib_doblitmode, doblitmode_c)
static ULONG codeinit_c (ULONG caller_d0)
 init: BlitMode $FCA (cookie cut) - MOVE $fca,d0 and on into doblitmode.
static int maxchk2 (const struct bb_shape *shape, const struct bb_bitmap *bm)
static int maxchk (const struct bb_shape *shape, const struct bb_bitmap *bm)
static void poschk2 (const struct bb_shape *shape, const struct bb_bitmap *bm, WORD x, WORD y)
static void poschk (const struct bb_shape *shape, const struct bb_bitmap *bm, WORD x, WORD y)
static void blitchk_c (WORD x, WORD y, const struct bb_bitmap *bm)
static void blitchknc_c (WORD x, WORD y, const struct bb_bitmap *bm)
static void blitchk3_c (WORD x, WORD y, const struct bb_bitmap *bm)

Variables

 BLIT_LIBS
static UWORD bcon0 = 0xfca

Macro Definition Documentation

◆ __NOLIBBASE__

#define __NOLIBBASE__

◆ BLIT_LIBS

#define BLIT_LIBS
Value:
BLITZ_LIBS(LIB_shapeslib, BL_IA3|BL_PD0, LIB_graphicslib, BL_IFAMIGA|BL_LA6, \
LIB_bitmaplib, BL_UA2, LIB_chipbaselib, BL_LA1)
#define BL_LA1
Definition blitzlib.h:198
#define BL_PD0
Definition blitzlib.h:231
#define BL_IA3
Definition blitzlib.h:242
#define BL_LA6
Definition blitzlib.h:201
#define BL_UA2
Definition blitzlib.h:213
#define BL_IFAMIGA
Definition blitzlib.h:187
#define BLITZ_LIBS(...)
Definition blitzlib.h:361

◆ GRAPHICS_BASE_NAME

#define GRAPHICS_BASE_NAME   gfx

◆ MODE_FN

#define MODE_FN ( code,
name )
Value:
BLITZ_ARGS0(); \
BLITZ_LIBS0(); \
BLITZ_SUBS(code, 0, 0); \
BLITZ_NAME(name, "")
char * name
Definition asllib.c:150
#define BL_WORD
Definition blitzlib.h:91
#define BLITZ_AFUNCTION(t)
Definition blitzlib.h:344
UBYTE code[4]
Definition ridisasmlib.c:375

◆ REG_ARGS

#define REG_ARGS
Value:
WORD x BL_REG(d1), WORD y BL_REG(d2), UBYTE *cb BL_REG(a1), \
const struct bb_bitmap *bm BL_REG(a2)
ULONG x
Definition 2dlib.c:2491
WORD y
Definition 2dlib.c:285
#define BL_REG(r)
Definition blitzlib.h:280
struct BitMap bm
Definition iffmakelib.c:162
A BitMap object, 64 bytes: a struct BitMap (+0 .. +39) and the Blitz fields behind it.
Definition blitzobj.h:87

◆ SHIFT

#define SHIFT ( x)
Value:
((UWORD)(((UWORD)(x) >> 4 | (UWORD)(x) << 12) & 0xf000))

Function Documentation

◆ a_doblit_c()

void a_doblit_c ( WORD x,
WORD y,
UBYTE * cb,
const struct bb_bitmap * bm,
struct Library * gfx )
static

Blit Shape#,X,Y (Amiga mode).

Amiga mode: OwnBlitter, the blit, wait for the blitter, DisownBlitter. Per shape plane A = cookie, B = shape data (one pointer for all planes), C = D = bitmap plane; BLTCON0 = shift | the BlitMode (default $FCA, cookie cut). Errors (debugger, blitchk): "Shape does not have a cookie cut", "Unitialized BitMap", "Uninialized Shape", "Shape has too many BitPlanes", "Coords outside of BitMap". The shape comes in a3 (!libs {shapeslib,$1380}, from Shape# in d0).

Parameters
xd1.w: x (the shape's handle is subtracted)
yd2.w: y
cba1: the custom chip base $DFF000 (chipbaselib)
bma2: the used bitmap (!libs {bitmaplib,$1202})
gfxa6: graphics.library (!libs {graphicslib,$5600})

◆ a_doblitcoll_c()

ULONG a_doblitcoll_c ( WORD x,
WORD y,
UBYTE * cb,
const struct bb_bitmap * bm,
struct Library * gfx )

BlitColl(Shape#,x,y) (Amiga mode).

OwnBlitter, the test, DisownBlitter (MOVE d0,-(a7):DisownBlitter:MOVE (a7)+,d0 - only the low word of the result is set, the upper word is what DisownBlitter left in d0; DIFF: here 0; BlitColl is a word function). A = cookie, C = bitmap plane, no D, for every plane of the bitmap (not a bug: of the bitmap, not of the shape). Errors (debugger, blitchk3): as Blit without the depth check. The shape comes in a3 (!libs {shapeslib,$1380}, from Shape# in d0).

Parameters
xd1.w: x (the shape's handle is subtracted)
yd2.w: y
cba1: the custom chip base $DFF000 (chipbaselib)
bma2: the used bitmap (!libs {bitmaplib,$1202})
gfxa6: graphics.library (!libs {graphicslib,$5600})
Returns
d0.w: -1 on a collision, else 0 (upper word 0)

◆ a_doblitex_c()

void a_doblitex_c ( WORD x,
WORD y,
UBYTE * cb,
const struct bb_bitmap * bm,
UWORD bits,
struct Library * gfx )
static

Blit Shape#,X,Y,Excessonoff (Amiga mode).

Amiga mode: OwnBlitter, the blit, wait for the blitter, DisownBlitter. Blit, then the bitmap planes beyond the shape's depth get A = cookie, minterm $0A (cleared where the cookie is) or $FA (set), one bit of Excessonoff per plane. Errors (debugger, blitchk): as Blit. The shape comes in a3 (!libs {shapeslib,$1380}, from Shape# in d0).

Parameters
xd1.w: x (the shape's handle is subtracted)
yd2.w: y
cba1: the custom chip base $DFF000 (chipbaselib)
bma2: the used bitmap (!libs {bitmaplib,$1202})
bitsd3.w: Excessonoff, one bit per excess plane (set = $FA)
gfxa6: graphics.library (!libs {graphicslib,$5600})

◆ a_doblock_c()

void a_doblock_c ( WORD x,
WORD y,
UBYTE * cb,
const struct bb_bitmap * bm,
struct Library * gfx )

Block Shape#,X,Y (Amiga mode).

Amiga mode: OwnBlitter, the blit, wait for the blitter, DisownBlitter. A -> D copy of the shape data: no shift, x / 8 bytes, bltsize - 1 (without the extra word). Not a bug: byte positions (the blitter ignores bit 0 of the address; Block is documented as word boundary blitting). Errors (debugger, blitchknc): as Blit, but no cookie needed. The shape comes in a3 (!libs {shapeslib,$1380}, from Shape# in d0).

Parameters
xd1.w: x (the shape's handle is subtracted)
yd2.w: y
cba1: the custom chip base $DFF000 (chipbaselib)
bma2: the used bitmap (!libs {bitmaplib,$1202})
gfxa6: graphics.library (!libs {graphicslib,$5600})

◆ b_doblit_c()

BLITZ_ENTRYPOINT void b_doblit_c ( WORD x,
WORD y,
UBYTE * cb,
const struct bb_bitmap * bm )
static

Blit Shape#,X,Y: blit the shape into the used bitmap (Blitz mode).

Per shape plane A = cookie, B = shape data (one pointer for all planes), C = D = bitmap plane; BLTCON0 = shift | the BlitMode (default $FCA, cookie cut). Errors (debugger, blitchk): "Shape does not have a cookie cut", "Unitialized BitMap", "Uninialized Shape", "Shape has too many BitPlanes", "Coords outside of BitMap". The shape comes in a3 (!libs {shapeslib,$1380}, from Shape# in d0).

Parameters
xd1.w: x (the shape's handle is subtracted)
yd2.w: y
cba1: the custom chip base $DFF000 (chipbaselib)
bma2: the used bitmap (!libs {bitmaplib,$1202})

◆ b_doblitcoll_c()

BLITZ_ENTRYPOINT BB_BOOL b_doblitcoll_c ( WORD x,
WORD y,
UBYTE * cb,
const struct bb_bitmap * bm )
static

BlitColl(Shape#,x,y): does the shape's cookie hit a set pixel of the used bitmap (Blitz mode)?

A = cookie, C = bitmap plane, no D, for every plane of the bitmap (not a bug: of the bitmap, not of the shape). Errors (debugger, blitchk3): as Blit without the depth check. The shape comes in a3 (!libs {shapeslib,$1380}, from Shape# in d0).

Parameters
xd1.w: x (the shape's handle is subtracted)
yd2.w: y
cba1: the custom chip base $DFF000 (chipbaselib)
bma2: the used bitmap (!libs {bitmaplib,$1202})
Returns
d0: BB_TRUE if any plane has a set pixel under the cookie (BZERO clear), else BB_FALSE (a word function, MOVEQ: the full long)

◆ b_doblitex()

void b_doblitex ( void )

◆ b_doblitex_c()

BLITZ_ENTRYPOINT void b_doblitex_c ( WORD x,
WORD y,
UBYTE * cb,
const struct bb_bitmap * bm,
UWORD bits )
static

Blit Shape#,X,Y,Excessonoff (Blitz mode; the nullsub b_doblitex for other libraries is the same code as a normal C function).

Blit, then the bitmap planes beyond the shape's depth get A = cookie, minterm $0A (cleared where the cookie is) or $FA (set), one bit of Excessonoff per plane. Errors (debugger, blitchk): as Blit. The shape comes in a3 (!libs {shapeslib,$1380}, from Shape# in d0).

Parameters
xd1.w: x (the shape's handle is subtracted)
yd2.w: y
cba1: the custom chip base $DFF000 (chipbaselib)
bma2: the used bitmap (!libs {bitmaplib,$1202})
bitsd3.w: Excessonoff, one bit per excess plane (set = $FA)

◆ b_doblock_c()

BLITZ_ENTRYPOINT void b_doblock_c ( WORD x,
WORD y,
UBYTE * cb,
const struct bb_bitmap * bm )
static

Block Shape#,X,Y: copy the shape into the used bitmap (Blitz mode).

A -> D copy of the shape data: no shift, x / 8 bytes, bltsize - 1 (without the extra word). Not a bug: byte positions (the blitter ignores bit 0 of the address; Block is documented as word boundary blitting). Errors (debugger, blitchknc): as Blit, but no cookie needed. The shape comes in a3 (!libs {shapeslib,$1380}, from Shape# in d0).

Parameters
xd1.w: x (the shape's handle is subtracted)
yd2.w: y
cba1: the custom chip base $DFF000 (chipbaselib)
bma2: the used bitmap (!libs {bitmaplib,$1202})

◆ blit()

BL_ALWAYS_INLINE void blit ( const struct bb_shape * shape,
const struct bb_bitmap * bm,
UBYTE * cb,
WORD x,
WORD y )

◆ blitchk()

void blitchk ( void )

◆ blitchk3()

void blitchk3 ( void )

◆ blitchk3_c()

void blitchk3_c ( WORD x,
WORD y,
const struct bb_bitmap * bm )
static

◆ blitchk_c()

void blitchk_c ( WORD x,
WORD y,
const struct bb_bitmap * bm )
static

◆ blitchknc()

void blitchknc ( void )

◆ blitchknc_c()

void blitchknc_c ( WORD x,
WORD y,
const struct bb_bitmap * bm )
static

◆ blitcoll()

BL_ALWAYS_INLINE LONG blitcoll ( const struct bb_shape * shape,
const struct bb_bitmap * bm,
UBYTE * cb,
WORD x,
WORD y )

◆ blitex()

BL_ALWAYS_INLINE void blitex ( const struct bb_shape * shape,
const struct bb_bitmap * bm,
UBYTE * cb,
WORD x,
WORD y,
UWORD bits )

◆ blitlib_codeinit()

void blitlib_codeinit ( void )

◆ blitlib_doblit()

void blitlib_doblit ( void )

◆ blitlib_doblitex()

void blitlib_doblitex ( void )

◆ blitlib_doblitmode()

void blitlib_doblitmode ( void )

◆ blitplanes()

BL_ALWAYS_INLINE UBYTE ** blitplanes ( UBYTE * cb,
UBYTE ** plane,
UWORD n,
ULONG cookie,
ULONG off,
UWORD size )

◆ blitsetup()

BL_ALWAYS_INLINE void blitsetup ( const struct bb_shape * shape,
const struct bb_bitmap * bm,
UBYTE * cb,
WORD x,
WORD y,
struct blitstate * st )

◆ BLITZ_ALIAS()

BLITZ_ALIAS ( blitlib_doblitmode ,
doblitmode_c  )

◆ BLITZ_EP_MARK() [1/4]

BLITZ_EP_MARK ( b_doblit_c )

◆ BLITZ_EP_MARK() [2/4]

BLITZ_EP_MARK ( b_doblitcoll_c )

◆ BLITZ_EP_MARK() [3/4]

BLITZ_EP_MARK ( b_doblitex_c )

◆ BLITZ_EP_MARK() [4/4]

BLITZ_EP_MARK ( b_doblock_c )

◆ block()

BL_ALWAYS_INLINE void block ( const struct bb_shape * shape,
const struct bb_bitmap * bm,
UBYTE * cb,
WORD x,
WORD y )

◆ codeinit_c()

ULONG codeinit_c ( ULONG caller_d0)
static

init: BlitMode $FCA (cookie cut) - MOVE $fca,d0 and on into doblitmode.

Parameters
caller_d0d0: what the caller had in d0
Returns
d0: caller_d0 with $FCA in the low word

◆ doblitcoll()

void doblitcoll ( void )

◆ doblitmode_c()

void doblitmode_c ( UWORD m)
static

BlitMode BLTCON0: the minterm/channel bits of Blit's BLTCON0 (ORed with the shift; CookieMode ... give the usual values).

Parameters
md0.w: the BLTCON0 value without the shift

◆ doblock()

void doblock ( void )

◆ docookiemode()

void docookiemode ( void )

CookieMode, EraseMode, InvMode, SolidMode: the BlitMode values $FCA (cookie cut), $B0A (erase), $B5A (invert), $BFA (solid).

Inline MOVE.w mode,d0 (not a bug: the upper word of d0 stays; word results, the compiler uses only d0.w).

Speed: the helpers are inline (BL_ALWAYS_INLINE), so the blit state is in registers as in the original, and the Blitz mode code of Blit, Block and BlitColl saves no register (BLITZ_ENTRYPOINT; the original changes d0-d7 and a0 too, the register rule keeps a3-a7).

◆ doerasemode()

void doerasemode ( void )

◆ doinvmode()

void doinvmode ( void )

◆ dosolidmode()

void dosolidmode ( void )

◆ maxchk()

int maxchk ( const struct bb_shape * shape,
const struct bb_bitmap * bm )
static

◆ maxchk2()

int maxchk2 ( const struct bb_shape * shape,
const struct bb_bitmap * bm )
static

◆ MODE_FN() [1/4]

MODE_FN ( docookiemode ,
"CookieMode"  )

◆ MODE_FN() [2/4]

MODE_FN ( doerasemode ,
"EraseMode"  )

◆ MODE_FN() [3/4]

MODE_FN ( doinvmode ,
"InvMode"  )

◆ MODE_FN() [4/4]

MODE_FN ( dosolidmode ,
"SolidMode"  )

◆ n_doblitex_c()

void n_doblitex_c ( WORD x,
WORD y,
UBYTE * cb,
const struct bb_bitmap * bm,
UWORD bits )
static

◆ offset()

BL_ALWAYS_INLINE ULONG offset ( const struct bb_bitmap * bm,
WORD x,
WORD y )

◆ poschk()

void poschk ( const struct bb_shape * shape,
const struct bb_bitmap * bm,
WORD x,
WORD y )
static

◆ poschk2()

void poschk2 ( const struct bb_shape * shape,
const struct bb_bitmap * bm,
WORD x,
WORD y )
static

◆ setmods()

BL_ALWAYS_INLINE void setmods ( const struct bb_shape * shape,
const struct bb_bitmap * bm,
UBYTE * cb )

Variable Documentation

◆ bcon0

UWORD bcon0 = 0xfca
static

◆ BLIT_LIBS

BLIT_LIBS