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

Data Structures

struct  buffer
struct  record
struct  stencil
struct  blitstate

Macros

#define __NOLIBBASE__
#define GRAPHICS_BASE_NAME   gfx
#define BBLIT_LIBS
#define BBLIT_REGS

Functions

void dobuffer (void)
void bblitlib_doblit (void)
void bblitlib_doblitex (void)
void dounbuffer (void)
void dobblitmode (void)
void doshowstencil (void)
void doflushbuff (void)
void bblitlib_codeinit (void)
void freebuffer (void)
void bblitchk (void)
void unbufferchk (void)
void unbufferchk2 (void)
static void dobblitmode_c (UWORD m)
 BBlitMode BLTCON0: the minterm/channel bits of BBlit's BLTCON0 (ORed with the shift; blitlib's CookieMode ... give the values).
 BLITZ_ALIAS (dobblitmode, dobblitmode_c)
static ULONG codeinit_c (ULONG incoming)
 init: BBlitMode $FCA (cookie cut).
static void freebuf (struct buffer *b)
static void freebuffer_c (void)
 Free Buffer (the object's _free nullsub): free the memory of the buffer in a3.
static void dobuffer_c (ULONG len)
 Buffer Buffer#,Memorylen: (re)allocate the buffer.
 BLITZ_ALIAS (dobuffer, dobuffer_c)
static void doflushbuff_c (void)
 FlushBuffer Buffer#: empty the buffer without restoring the background (MOVE.l 8(a3),(a3)+:CLR.l (a3)).
 BLITZ_ALIAS (doflushbuff, doflushbuff_c)
BL_ALWAYS_INLINE void bblit (struct buffer *b, const struct bb_shape *shape, const struct bb_bitmap *bm, UBYTE *cb, WORD x, WORD y, struct blitstate *st)
BL_ALWAYS_INLINE void bblitex (struct buffer *b, const struct bb_shape *shape, const struct bb_bitmap *bm, UBYTE *cb, WORD x, WORD y, UWORD bits)
BL_ALWAYS_INLINE void unbuffer (struct buffer *b, UBYTE *cb)
BL_ALWAYS_INLINE void showstencil (struct buffer *b, UBYTE *cb, const struct stencil *stencil)
static BLITZ_ENTRYPOINT void b_doblit_c (WORD x, WORD y, struct buffer *b, UBYTE *cb, const struct bb_bitmap *bm)
 BBlit Buffer#,Shape#,X,Y: blit the shape into the used bitmap, the background saved in the buffer (Blitz mode).
 BLITZ_EP_MARK (b_doblit_c)
static void a_doblit_c (WORD x, WORD y, struct buffer *b, UBYTE *cb, const struct bb_bitmap *bm, struct Library *gfx)
 BBlit Buffer#,Shape#,X,Y (Amiga mode).
static BLITZ_ENTRYPOINT void b_doblitex_c (WORD x, WORD y, struct buffer *b, UBYTE *cb, const struct bb_bitmap *bm, UWORD bits)
 BBlit Buffer#,Shape#,X,Y,Excessonoff (Blitz mode).
 BLITZ_EP_MARK (b_doblitex_c)
static void a_doblitex_c (WORD x, WORD y, struct buffer *b, UBYTE *cb, const struct bb_bitmap *bm, UWORD bits, struct Library *gfx)
 BBlit Buffer#,Shape#,X,Y,Excessonoff (Amiga mode).
static BLITZ_ENTRYPOINT void b_dounbuffer_c (UBYTE *cb)
 UnBuffer Buffer#: restore the background of all BBlits of the buffer (Blitz mode).
 BLITZ_EP_MARK (b_dounbuffer_c)
void a_dounbuffer_c (UBYTE *cb, struct Library *gfx)
 UnBuffer Buffer# (Amiga mode).
static BLITZ_ENTRYPOINT void b_showstencil_c (const struct stencil *st, UBYTE *cb)
 ShowStencil Buffer#,Stencil#: restore the background of the buffer's BBlits through a stencil (Blitz mode).
 BLITZ_EP_MARK (b_showstencil_c)
void a_showstencil_c (const struct stencil *st, UBYTE *cb, struct Library *gfx)
 ShowStencil Buffer#,Stencil# (Amiga mode; the wait is a single BTST loop).
static int maxchk (const struct bb_shape *shape, const struct bb_bitmap *bm)
static int poschk (const struct bb_shape *shape, const struct bb_bitmap *bm, WORD x, WORD y)
static void bblitchk_c (WORD x, WORD y, const struct buffer *b, const struct bb_bitmap *bm)
static void unbufferchk_c (void)
static void unbufferchk2_c (const struct stencil *st)

Variables

 BBLIT_LIBS
static UWORD bcon0 = 0xfca

Macro Definition Documentation

◆ __NOLIBBASE__

#define __NOLIBBASE__

◆ BBLIT_LIBS

#define BBLIT_LIBS
Value:
BLITZ_LIBS(LIB_shapeslib, BL_IA3|BL_PD1, LIB_bblitlib, BL_IA0|BL_PD0, \
LIB_bitmaplib, BL_UA2, LIB_chipbaselib, BL_LA1, \
LIB_graphicslib, BL_IFAMIGA|BL_LA6)
#define BL_IA0
Definition blitzlib.h:239
#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_PD1
Definition blitzlib.h:232
#define BL_UA2
Definition blitzlib.h:213
#define BL_IFAMIGA
Definition blitzlib.h:187
#define BLITZ_LIBS(...)
Definition blitzlib.h:361

◆ BBLIT_REGS

#define BBLIT_REGS
Value:
WORD x BL_REG(d2), WORD y BL_REG(d3), struct buffer *b BL_REG(a0), \
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
Definition bblitlib.c:127

◆ GRAPHICS_BASE_NAME

#define GRAPHICS_BASE_NAME   gfx

Function Documentation

◆ a_doblit_c()

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

BBlit Buffer#,Shape#,X,Y (Amiga mode).

Amiga mode: OwnBlitter, the blit, wait for the blitter, DisownBlitter. First the bitmap area under the shape is saved (A -> D copy, every bitmap plane) into a record at the buffer's write position, then the shape is blitted like blitlib's Blit (A = cookie, B = data, C = D = bitmap, BLTCON0 = shift | BBlitMode). Not a bug: the last word mask of the blit is cleared, the first stays $FFFF from the save blit. BUG(orig): only the error check tests for an overflow of the buffer (#73). Fixed (#74): a bitmap or shape of depth 0 loops 65536 times (DBF), refused at its creation in the error check area. Errors (debugger, bblitchk): "Uninitialized Buffer", "Shape does not have a cookie cut", "Unitialized BitMap", "Uninialized Shape", "Shape has too many BitPlanes", "Coords outside of BitMap", "Buffer Overflow". The shape comes in a3 (!libs {shapeslib,$1381}, from Shape# in d1).

Parameters
xd2.w: x (the shape's handle is subtracted)
yd3.w: y
ba0: the buffer (!libs {bblitlib,$1080}, from Buffer# in d0)
cba1: the custom chip base $DFF000 (chipbaselib)
bma2: the used bitmap (!libs {bitmaplib,$1202})
gfxa6: graphics.library (!libs {graphicslib,$5600})

◆ a_doblitex_c()

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

BBlit Buffer#,Shape#,X,Y,Excessonoff (Amiga mode).

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

Parameters
xd2.w: x (the shape's handle is subtracted)
yd3.w: y
ba0: the buffer (!libs {bblitlib,$1080}, from Buffer# in d0)
cba1: the custom chip base $DFF000 (chipbaselib)
bma2: the used bitmap (!libs {bitmaplib,$1202})
bitsd4.w: Excessonoff, one bit per excess plane (set = $FA)
gfxa6: graphics.library (!libs {graphicslib,$5600})

◆ a_dounbuffer_c()

void a_dounbuffer_c ( UBYTE * cb,
struct Library * gfx )

UnBuffer Buffer# (Amiga mode).

Amiga mode: OwnBlitter, the blit, wait for the blitter, DisownBlitter. The records are copied back (newest first, A -> D), then the buffer is empty. Errors (debugger, unbufferchk): "Uninitialized Buffer". The buffer comes in a3 (!libs {bblitlib,$1380}, from Buffer# in d0).

Parameters
cba2: the custom chip base $DFF000 (chipbaselib)
gfxa6: graphics.library (!libs {graphicslib,$5600})

◆ a_showstencil_c()

void a_showstencil_c ( const struct stencil * st,
UBYTE * cb,
struct Library * gfx )

ShowStencil Buffer#,Stencil# (Amiga mode; the wait is a single BTST loop).

Amiga mode: OwnBlitter, the blit, wait for the blitter, DisownBlitter. As UnBuffer, through the stencil as B (minterm $E2); the buffer stays. Errors (debugger, unbufferchk2): "Uninitialized Stencil" (the buffer is not checked). The buffer comes in a3 (!libs {bblitlib,$1380}, from Buffer# in d0).

Parameters
sta1: the stencil (!libs {stencillib,$1181}, from Stencil# in d1)
cba2: the custom chip base $DFF000 (chipbaselib)
gfxa6: graphics.library (!libs {graphicslib,$5600})

◆ b_doblit_c()

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

BBlit Buffer#,Shape#,X,Y: blit the shape into the used bitmap, the background saved in the buffer (Blitz mode).

First the bitmap area under the shape is saved (A -> D copy, every bitmap plane) into a record at the buffer's write position, then the shape is blitted like blitlib's Blit (A = cookie, B = data, C = D = bitmap, BLTCON0 = shift | BBlitMode). Not a bug: the last word mask of the blit is cleared, the first stays $FFFF from the save blit. BUG(orig): only the error check tests for an overflow of the buffer (#73). Fixed (#74): a bitmap or shape of depth 0 loops 65536 times (DBF), refused at its creation in the error check area. Errors (debugger, bblitchk): "Uninitialized Buffer", "Shape does not have a cookie cut", "Unitialized BitMap", "Uninialized Shape", "Shape has too many BitPlanes", "Coords outside of BitMap", "Buffer Overflow". The shape comes in a3 (!libs {shapeslib,$1381}, from Shape# in d1).

Parameters
xd2.w: x (the shape's handle is subtracted)
yd3.w: y
ba0: the buffer (!libs {bblitlib,$1080}, from Buffer# in d0)
cba1: the custom chip base $DFF000 (chipbaselib)
bma2: the used bitmap (!libs {bitmaplib,$1202})

◆ b_doblitex_c()

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

BBlit Buffer#,Shape#,X,Y,Excessonoff (Blitz mode).

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

Parameters
xd2.w: x (the shape's handle is subtracted)
yd3.w: y
ba0: the buffer (!libs {bblitlib,$1080}, from Buffer# in d0)
cba1: the custom chip base $DFF000 (chipbaselib)
bma2: the used bitmap (!libs {bitmaplib,$1202})
bitsd4.w: Excessonoff, one bit per excess plane (set = $FA)

◆ b_dounbuffer_c()

BLITZ_ENTRYPOINT void b_dounbuffer_c ( UBYTE * cb)
static

UnBuffer Buffer#: restore the background of all BBlits of the buffer (Blitz mode).

The records are copied back (newest first, A -> D), then the buffer is empty. Errors (debugger, unbufferchk): "Uninitialized Buffer". The buffer comes in a3 (!libs {bblitlib,$1380}, from Buffer# in d0).

Parameters
cba2: the custom chip base $DFF000 (chipbaselib)

◆ b_showstencil_c()

BLITZ_ENTRYPOINT void b_showstencil_c ( const struct stencil * st,
UBYTE * cb )
static

ShowStencil Buffer#,Stencil#: restore the background of the buffer's BBlits through a stencil (Blitz mode).

As UnBuffer, through the stencil as B (minterm $E2); the buffer stays. Errors (debugger, unbufferchk2): "Uninitialized Stencil" (the buffer is not checked). The buffer comes in a3 (!libs {bblitlib,$1380}, from Buffer# in d0).

Parameters
sta1: the stencil (!libs {stencillib,$1181}, from Stencil# in d1)
cba2: the custom chip base $DFF000 (chipbaselib)

◆ bblit()

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

◆ bblitchk()

void bblitchk ( void )

◆ bblitchk_c()

void bblitchk_c ( WORD x,
WORD y,
const struct buffer * b,
const struct bb_bitmap * bm )
static

◆ bblitex()

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

◆ bblitlib_codeinit()

void bblitlib_codeinit ( void )

◆ bblitlib_doblit()

void bblitlib_doblit ( void )

◆ bblitlib_doblitex()

void bblitlib_doblitex ( void )

◆ BLITZ_ALIAS() [1/3]

BLITZ_ALIAS ( dobblitmode ,
dobblitmode_c  )

◆ BLITZ_ALIAS() [2/3]

BLITZ_ALIAS ( dobuffer ,
dobuffer_c  )

◆ BLITZ_ALIAS() [3/3]

BLITZ_ALIAS ( doflushbuff ,
doflushbuff_c  )

◆ BLITZ_EP_MARK() [1/4]

BLITZ_EP_MARK ( b_doblit_c )

◆ BLITZ_EP_MARK() [2/4]

BLITZ_EP_MARK ( b_doblitex_c )

◆ BLITZ_EP_MARK() [3/4]

BLITZ_EP_MARK ( b_dounbuffer_c )

◆ BLITZ_EP_MARK() [4/4]

BLITZ_EP_MARK ( b_showstencil_c )

◆ codeinit_c()

ULONG codeinit_c ( ULONG incoming)
static

init: BBlitMode $FCA (cookie cut).

Parameters
incomingd0: what the caller had in d0
Returns
d0: incoming with $FCA in the low word

◆ dobblitmode()

void dobblitmode ( void )

◆ dobblitmode_c()

void dobblitmode_c ( UWORD m)
static

BBlitMode BLTCON0: the minterm/channel bits of BBlit's BLTCON0 (ORed with the shift; blitlib's CookieMode ... give the values).

Parameters
md0.w: the BLTCON0 value without the shift

◆ dobuffer()

void dobuffer ( void )

◆ dobuffer_c()

void dobuffer_c ( ULONG len)
static

Buffer Buffer#,Memorylen: (re)allocate the buffer.

Frees the old memory, allocates Memorylen bytes MEMF_CHIP (not cleared, memlib globalloc); the buffer is empty. The buffer comes in a3 (!libs {bblitlib,$1380}, from Buffer# in d0).

Parameters
lend1: the length in bytes

◆ doflushbuff()

void doflushbuff ( void )

◆ doflushbuff_c()

void doflushbuff_c ( void )
static

FlushBuffer Buffer#: empty the buffer without restoring the background (MOVE.l 8(a3),(a3)+:CLR.l (a3)).

Errors (debugger, unbufferchk): "Uninitialized Buffer". The buffer comes in a3 (!libs {bblitlib,$1380}, from Buffer# in d0).

◆ doshowstencil()

void doshowstencil ( void )

◆ dounbuffer()

void dounbuffer ( void )

◆ freebuf()

void freebuf ( struct buffer * b)
static

◆ freebuffer()

void freebuffer ( void )

◆ freebuffer_c()

void freebuffer_c ( void )
static

Free Buffer (the object's _free nullsub): free the memory of the buffer in a3.

BUG(orig) (#75): the write position and the last record pointer are left stale.

◆ maxchk()

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

◆ poschk()

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

◆ showstencil()

BL_ALWAYS_INLINE void showstencil ( struct buffer * b,
UBYTE * cb,
const struct stencil * stencil )

◆ unbuffer()

BL_ALWAYS_INLINE void unbuffer ( struct buffer * b,
UBYTE * cb )

◆ unbufferchk()

void unbufferchk ( void )

◆ unbufferchk2()

void unbufferchk2 ( void )

◆ unbufferchk2_c()

void unbufferchk2_c ( const struct stencil * st)
static

◆ unbufferchk_c()

void unbufferchk_c ( void )
static

Variable Documentation

◆ BBLIT_LIBS

BBLIT_LIBS

◆ bcon0

UWORD bcon0 = 0xfca
static