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

Macros

#define __NOLIBBASE__
#define GRAPHICS_BASE_NAME   gfx
#define CWIDTH   144
#define CW(cb, o)
#define CL(cb, o)
#define BUSY(cb)
#define BLITWAIT(cb)
#define MW(p, o)
#define ML(p, o)
#define SCROLL_REGS

Functions

void doscroll (void)
void b_doscroll (void)
void docls (void)
void docls2 (void)
void doblockscroll (void)
void scrolllib_codeinit (void)
void doplot (void)
 Plot X,Y,Colour - set a pixel of the used bitmap.
void dopoint (void)
 Point(X,Y) - the colour of a pixel of the used bitmap.
void scchk1 (void)
void scchk2 (void)
void bmchk (void)
static void clsdepth (UBYTE *cb, const struct bb_bitmap *bm, UWORD col, UWORD size, UWORD mod, ULONG off)
static void clswidth (UBYTE *cb, const struct bb_bitmap *bm, UWORD col, UWORD h, ULONG off)
static void b_cls (UBYTE *cb, const struct bb_bitmap *bm, UWORD col)
static void b_docls_c (UBYTE *cb, const struct bb_bitmap *bm)
 Cls - clear the used bitmap to colour 0 (Blitz mode).
static void b_docls2_c (UWORD col, UBYTE *cb, const struct bb_bitmap *bm)
 Cls Colour - fill the used bitmap with a colour (Blitz mode).
static void a_docls_c (UBYTE *cb, const struct bb_bitmap *bm, struct GfxBase *gfx)
 Cls in Amiga mode: b_docls_c between OwnBlitter and DisownBlitter, waiting for the blitter at the end.
static void a_docls2_c (UWORD col, UBYTE *cb, const struct bb_bitmap *bm, struct GfxBase *gfx)
 Cls Colour in Amiga mode: b_docls2_c between OwnBlitter and DisownBlitter, waiting for the blitter at the end.
 BLITZ_ALIAS (b_docls, b_docls_c)
 BLITZ_ALIAS (b_docls2, b_docls2_c)
static void codeinit_c (void)
 Library init: allocate the 144 byte cookie buffer (memlib globalloc, CHIP, not checked) and fill it with $FFFFFFFF.
static UWORD * cookwait (UBYTE *cb)
static UBYTE * doit (UBYTE *cb, const struct bb_bitmap *src, const struct bb_bitmap *dst, const UWORD *args, ULONG srcoff, ULONG dstoff, UWORD words)
static UBYTE * doasc (UWORD x1, UWORD y1, UWORD x2, UWORD y2, const struct bb_bitmap *src, const struct bb_bitmap *dst, UBYTE *cb, const UWORD *args)
static UBYTE * dodesc (UWORD x1, UWORD y1, UWORD x2, UWORD y2, const struct bb_bitmap *src, const struct bb_bitmap *dst, UBYTE *cb, const UWORD *args)
static UBYTE * scroll (UWORD x1, UWORD y1, UWORD x2, UWORD y2, const struct bb_bitmap *src, UBYTE *cb, UWORD *args)
static void b_doscroll_c (UWORD x1, UWORD y1, UWORD x2, UWORD y2, const struct bb_bitmap *src, UBYTE *cb, UWORD *args)
 Scroll X1,Y1,Width,Height,X2,Y2[,BitMap#] - copy an area with the blitter (Blitz mode).
void b_doscroll_blitz (void)
static void a_doscroll_c (UWORD x1, UWORD y1, UWORD x2, UWORD y2, const struct bb_bitmap *src, UBYTE *cb, UWORD *args, struct GfxBase *gfx)
 Scroll in Amiga mode: b_doscroll_c between OwnBlitter and DisownBlitter, waiting for the blitter at the end.
static UBYTE * blockscroll (UWORD x1, UWORD y1, UWORD x2, UWORD y2, const struct bb_bitmap *src, UBYTE *cb, const UWORD *args)
static void b_doblockscroll_c (UWORD x1, UWORD y1, UWORD x2, UWORD y2, const struct bb_bitmap *src, UBYTE *cb, UWORD *args)
 BlockScroll X1,Y1,Width,Height,X2,Y2[,BitMap#] - copy whole bytes with the blitter (Blitz mode).
static void a_doblockscroll_c (UWORD x1, UWORD y1, UWORD x2, UWORD y2, const struct bb_bitmap *src, UBYTE *cb, UWORD *args, struct GfxBase *gfx)
 BlockScroll in Amiga mode: b_doblockscroll_c between OwnBlitter and DisownBlitter, waiting for the blitter at the end.
void b_doblockscroll (void)
 BLITZ_ALIAS (b_doblockscroll, b_doblockscroll_c)
static void scchk (UWORD x, UWORD y, const struct bb_bitmap *bm, const UWORD *args)
static void scchk1_c (UWORD x1, UWORD y1, UWORD x2, UWORD y2, const struct bb_bitmap *src, UBYTE *cb, UWORD *args)
static void scchk2_c (UWORD x1, UWORD y1, UWORD x2, UWORD y2, const struct bb_bitmap *src, UBYTE *cb, UWORD *args)
static void bmchk_c (const struct bb_bitmap *bm)

Variables

static UWORD * cookie
static UWORD offset
static UWORD scminiterm = 0xfe2
static const UWORD masks [17]
const char mess1 []
const char mess2 []
const char mess3 []

Macro Definition Documentation

◆ __NOLIBBASE__

#define __NOLIBBASE__

◆ BLITWAIT

#define BLITWAIT ( cb)
Value:
do { (void)BUSY(cb); while (BUSY(cb)) ; } while (0)
#define BUSY(cb)
Definition scrolllib.c:112

◆ BUSY

#define BUSY ( cb)
Value:
(*(volatile UBYTE *)((UBYTE *)(cb) + 2) & 0x40)

◆ CL

#define CL ( cb,
o )
Value:
(*(volatile ULONG *)((UBYTE *)(cb) + (o)))

◆ CW

#define CW ( cb,
o )
Value:
(*(volatile UWORD *)((UBYTE *)(cb) + (o)))

◆ CWIDTH

#define CWIDTH   144

◆ GRAPHICS_BASE_NAME

#define GRAPHICS_BASE_NAME   gfx

◆ ML

#define ML ( p,
o )
Value:
(*(ULONG *)((UBYTE *)(p) + (o)))

◆ MW

#define MW ( p,
o )
Value:
(*(UWORD *)((UBYTE *)(p) + (o)))

◆ SCROLL_REGS

#define SCROLL_REGS
Value:
UWORD x1 BL_REG(d0), UWORD y1 BL_REG(d1), UWORD x2 BL_REG(d2), \
UWORD y2 BL_REG(d3), const struct bb_bitmap *src BL_REG(a0), UBYTE *cb BL_REG(a1), \
UWORD *args BL_REG(a2)
#define BL_REG(r)
Definition blitzlib.h:280
APTR args
Definition rimisclib.c:397
A BitMap object, 64 bytes: a struct BitMap (+0 .. +39) and the Blitz fields behind it.
Definition blitzobj.h:87

Function Documentation

◆ a_doblockscroll_c()

void a_doblockscroll_c ( UWORD x1,
UWORD y1,
UWORD x2,
UWORD y2,
const struct bb_bitmap * src,
UBYTE * cb,
UWORD * args,
struct GfxBase * gfx )
static

BlockScroll in Amiga mode: b_doblockscroll_c between OwnBlitter and DisownBlitter, waiting for the blitter at the end.

Parameters
gfxd6: graphics.library (!libs)

◆ a_docls2_c()

void a_docls2_c ( UWORD col,
UBYTE * cb,
const struct bb_bitmap * bm,
struct GfxBase * gfx )
static

Cls Colour in Amiga mode: b_docls2_c between OwnBlitter and DisownBlitter, waiting for the blitter at the end.

Parameters
cold0.w: the colour
cba1: the chip base ($DFF000)
bma2: the used bitmap
gfxa6: graphics.library

◆ a_docls_c()

void a_docls_c ( UBYTE * cb,
const struct bb_bitmap * bm,
struct GfxBase * gfx )
static

Cls in Amiga mode: b_docls_c between OwnBlitter and DisownBlitter, waiting for the blitter at the end.

Parameters
cba1: the chip base ($DFF000)
bma2: the used bitmap
gfxa6: graphics.library

◆ a_doscroll_c()

void a_doscroll_c ( UWORD x1,
UWORD y1,
UWORD x2,
UWORD y2,
const struct bb_bitmap * src,
UBYTE * cb,
UWORD * args,
struct GfxBase * gfx )
static

Scroll in Amiga mode: b_doscroll_c between OwnBlitter and DisownBlitter, waiting for the blitter at the end.

Parameters
gfxd6: graphics.library (!libs)

◆ b_cls()

void b_cls ( UBYTE * cb,
const struct bb_bitmap * bm,
UWORD col )
static

◆ b_doblockscroll()

void b_doblockscroll ( void )

◆ b_doblockscroll_c()

void b_doblockscroll_c ( UWORD x1,
UWORD y1,
UWORD x2,
UWORD y2,
const struct bb_bitmap * src,
UBYTE * cb,
UWORD * args )
static

BlockScroll X1,Y1,Width,Height,X2,Y2[,BitMap#] - copy whole bytes with the blitter (Blitz mode).

As Scroll, but x / 8 and width / 8: no shift, no masks, ascending only. a3 is left behind the destination's plane pointers as in the original.

Errors: as Scroll (scchk1/scchk2, debugger only).

Parameters
x1d0.w: source x
y1d1.w: source y
x2d2.w: destination x
y2d3.w: destination y
srca0: the source bitmap
cba1: the chip base ($DFF000)
argsa2: the argument stack: -2(a2) width, -4(a2) height

◆ b_docls2_c()

void b_docls2_c ( UWORD col,
UBYTE * cb,
const struct bb_bitmap * bm )
static

Cls Colour - fill the used bitmap with a colour (Blitz mode).

As b_docls_c with the colour's bits.

Parameters
cold0.w: the colour
cba1: the chip base ($DFF000)
bma2: the used bitmap

◆ b_docls_c()

void b_docls_c ( UBYTE * cb,
const struct bb_bitmap * bm )
static

Cls - clear the used bitmap to colour 0 (Blitz mode).

The blitter fills every plane (D only, BLTCDAT = the colour's bit); an interleaved bitmap in bands of up to 1024 rows and 64 words, a normal one plane by plane in blits of up to 128K (clsnotint, as in the CD binary).

Fixed (#393): a bitmap of depth 0 runs the plane loop 65536 times (an invalid argument, refused at its creation in the error check area). Errors: "Uninitialized BitMap" (bmchk, debugger only).

Parameters
cba1: the chip base ($DFF000, chipbaselib)
bma2: the used bitmap

◆ b_doscroll()

void b_doscroll ( void )

◆ b_doscroll_blitz()

void b_doscroll_blitz ( void )

◆ b_doscroll_c()

void b_doscroll_c ( UWORD x1,
UWORD y1,
UWORD x2,
UWORD y2,
const struct bb_bitmap * src,
UBYTE * cb,
UWORD * args )
static

Scroll X1,Y1,Width,Height,X2,Y2[,BitMap#] - copy an area with the blitter (Blitz mode).

From the source bitmap (the used one, or BitMap#) to the used bitmap; ascending or descending depending on the overlap, the edges masked through the cookie buffer, as many planes as the shallower bitmap has. Areas wider than 960 pixels are copied in two blits: the width word on the caller's argument stack is changed for that, as in the original (not a bug: it belongs to this call and is discarded by the compiler afterwards). a3 is left as the original leaves it (dest bitmap planes

  • 4 * planes).

Errors (scchk1/scchk2, debugger only): "Illegal Scroll Area" (an area outside a bitmap), "Uninitialized BitMap", "Scroll area to large" (height > 1024).

Parameters
x1d0.w: source x
y1d1.w: source y
x2d2.w: destination x
y2d3.w: destination y
srca0: the source bitmap
cba1: the chip base ($DFF000)
argsa2: the argument stack: -2(a2) width, -4(a2) height

◆ BLITZ_ALIAS() [1/3]

BLITZ_ALIAS ( b_doblockscroll ,
b_doblockscroll_c  )

◆ BLITZ_ALIAS() [2/3]

BLITZ_ALIAS ( b_docls ,
b_docls_c  )

◆ BLITZ_ALIAS() [3/3]

BLITZ_ALIAS ( b_docls2 ,
b_docls2_c  )

◆ blockscroll()

UBYTE * blockscroll ( UWORD x1,
UWORD y1,
UWORD x2,
UWORD y2,
const struct bb_bitmap * src,
UBYTE * cb,
const UWORD * args )
static

◆ bmchk()

void bmchk ( void )

◆ bmchk_c()

void bmchk_c ( const struct bb_bitmap * bm)
static

◆ clsdepth()

void clsdepth ( UBYTE * cb,
const struct bb_bitmap * bm,
UWORD col,
UWORD size,
UWORD mod,
ULONG off )
static

◆ clswidth()

void clswidth ( UBYTE * cb,
const struct bb_bitmap * bm,
UWORD col,
UWORD h,
ULONG off )
static

◆ codeinit_c()

void codeinit_c ( void )
static

Library init: allocate the 144 byte cookie buffer (memlib globalloc, CHIP, not checked) and fill it with $FFFFFFFF.

◆ cookwait()

UWORD * cookwait ( UBYTE * cb)
static

◆ doasc()

UBYTE * doasc ( UWORD x1,
UWORD y1,
UWORD x2,
UWORD y2,
const struct bb_bitmap * src,
const struct bb_bitmap * dst,
UBYTE * cb,
const UWORD * args )
static

◆ doblockscroll()

void doblockscroll ( void )

◆ docls()

void docls ( void )

◆ docls2()

void docls2 ( void )

◆ dodesc()

UBYTE * dodesc ( UWORD x1,
UWORD y1,
UWORD x2,
UWORD y2,
const struct bb_bitmap * src,
const struct bb_bitmap * dst,
UBYTE * cb,
const UWORD * args )
static

◆ doit()

UBYTE * doit ( UBYTE * cb,
const struct bb_bitmap * src,
const struct bb_bitmap * dst,
const UWORD * args,
ULONG srcoff,
ULONG dstoff,
UWORD words )
static

◆ doplot()

void doplot ( void )

Plot X,Y,Colour - set a pixel of the used bitmap.

The bitmap's origin (+48/+50) is added; outside the clip size (+56/+58, unsigned compare) nothing happens. A negative colour complements the pixel in all planes (BCHG). The planes are counted with the word +4 (flags and depth, as the original).

The original's code (ADD 48(a2),d0 ... MULU (a2),d1 ... BCLR/BSET d0,(a1) per plane); it changes d0-d3, a0 and a1 like the original, so no caller can rely on d2 or d3 (MikesSpaceFXLib saves d0-d2 itself around its calls from the starfield loop, and nothing else of it is live). Assembler: the C function cost about 160 cycles more per call.

Fixed (#393): a bitmap of depth 0 runs the plane loop 65536 times (an invalid argument, refused at its creation in the error check area). Errors: "Uninitialized BitMap" (bmchk, debugger only).

In: d0.w x, d1.w y, d2.w the colour (< 0 = complement), a2 the used bitmap (struct bb_bitmap).

◆ dopoint()

void dopoint ( void )

Point(X,Y) - the colour of a pixel of the used bitmap.

Origin and clipping as in Plot. The original's code; it changes d1-d3, a0 and a1 (the register rule keeps a3-a7 for a function). Assembler: the C function cost about 290 cycles more per call.

Errors: "Uninitialized BitMap" (bmchk, debugger only).

In: d0.w x, d1.w y, a2 the used bitmap (struct bb_bitmap). Out: d0.w the colour, 0 outside the bitmap (MOVEQ #0,d0); the upper word is the one of the x argument (MOVE d2,d0)

◆ doscroll()

void doscroll ( void )

◆ scchk()

void scchk ( UWORD x,
UWORD y,
const struct bb_bitmap * bm,
const UWORD * args )
static

◆ scchk1()

void scchk1 ( void )

◆ scchk1_c()

void scchk1_c ( UWORD x1,
UWORD y1,
UWORD x2,
UWORD y2,
const struct bb_bitmap * src,
UBYTE * cb,
UWORD * args )
static

◆ scchk2()

void scchk2 ( void )

◆ scchk2_c()

void scchk2_c ( UWORD x1,
UWORD y1,
UWORD x2,
UWORD y2,
const struct bb_bitmap * src,
UBYTE * cb,
UWORD * args )
static

◆ scroll()

UBYTE * scroll ( UWORD x1,
UWORD y1,
UWORD x2,
UWORD y2,
const struct bb_bitmap * src,
UBYTE * cb,
UWORD * args )
static

◆ scrolllib_codeinit()

void scrolllib_codeinit ( void )

Variable Documentation

◆ cookie

UWORD* cookie
static

◆ masks

const UWORD masks[17]
static
Initial value:
= {
0xffff, 0x7fff, 0x3fff, 0x1fff, 0x0fff, 0x07ff, 0x03ff, 0x01ff,
0x00ff, 0x007f, 0x003f, 0x001f, 0x000f, 0x0007, 0x0003, 0x0001, 0x0000,
}

◆ mess1

const char mess1[]
extern

◆ mess2

const char mess2[]

◆ mess3

const char mess3[]

◆ offset

UWORD offset
static

◆ scminiterm

UWORD scminiterm = 0xfe2
static