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

Macros

#define __NOLIBBASE__
#define HANDLES(s)
#define TOK_docookie   ((LIB_shapeslib << 7) + 11)
#define TOK_qmultiply   0xca00 /* lmullib: d0.q * d1.q */
#define TOK_qdivide   0xcb00 /* ldivlib: d0.q / d1.q */

Functions

void doscale (void)
void doscale2 (void)
void doxflip (void)
void doyflip (void)
void dorotate (void)
void scalechk (void)
void scalechk2 (void)
void shapetrixlib_fchk (void)
void rotchk (void)
static void * globalloc (ULONG size, ULONG flags)
static void globfree (void *mem, ULONG size)
static void docookie (struct bb_shape *shape)
static ULONG qcall (ULONG val, ULONG a, ULONG b)
static void cookieit (struct bb_shape *s)
static void allocshape (struct bb_shape *ns)
static void makeshape (struct bb_shape *shape)
static UBYTE flipbyte (UBYTE b)
static void blitwait (volatile UBYTE *chip)
static void xflip (struct bb_shape *s, volatile UBYTE *chip)
void b_doxflip_c (volatile UBYTE *chip)
 XFlip Shape# - mirror a shape horizontally (Blitz mode).
 BLITZ_ALIAS (b_doxflip, b_doxflip_c)
void a_doxflip_c (volatile UBYTE *chip, struct GfxBase *gfx)
 XFlip Shape# in Amiga mode: OwnBlitter, flip, wait for the blitter, DisownBlitter (fixed #271: the original's wait is BTST twice without a loop).
static void doyflip_c (void)
 YFlip Shape# - mirror a shape vertically (rows swapped plane by plane); a3 = the shape.
 BLITZ_ALIAS (doyflip, doyflip_c)
static ULONG mulsin (WORD val, UWORD angle)
static ULONG mulcos (WORD val, UWORD angle)
static void rotit (WORD x, WORD y, UWORD angle, WORD *nx, WORD *ny)
static void rotit2 (WORD x, WORD y, UWORD angle)
static void dorotate_c (ULONG q)
 Rotate Shape#,Angle Ratio - rotate a shape.
 BLITZ_ALIAS (dorotate, dorotate_c)
static void scale (struct bb_shape *shape, ULONG xr, ULONG yr)
static void doscale2_c (ULONG xr, ULONG yr)
 Scale Shape#,X Ratio,Y Ratio - scale a shape.
 BLITZ_ALIAS (doscale2, doscale2_c)
static void doscale_c (ULONG xr, ULONG yr, struct bb_palette *pal)
 Scale Shape#,X Ratio,Y Ratio,Palette# - scale a shape, the colour choice weighted by the palette.
 BLITZ_ALIAS (doscale, doscale_c)
static void fchk_c (void)
static void sizechk (UWORD w, UWORD h)
static UWORD scaled (UWORD n, ULONG ratio)
static void scalechk2_c (ULONG xr, ULONG yr)
static void scalechk_c (ULONG xr, ULONG yr, struct bb_palette *pal)
static void rotchk_c (ULONG q)

Variables

static struct bb_shape newshape
static UWORD colvals [256]
static UWORD usevals [256]
static ULONG xadd
static ULONG yadd
static ULONG scaleall
static UWORD numcols
static const UWORD qrots [65]
static WORD xl
static WORD yl
static WORD xh
static WORD yh

Macro Definition Documentation

◆ __NOLIBBASE__

#define __NOLIBBASE__

◆ HANDLES

#define HANDLES ( s)
Value:
(*(ULONG *)&(s)->handlex)

◆ TOK_docookie

#define TOK_docookie   ((LIB_shapeslib << 7) + 11)

◆ TOK_qdivide

#define TOK_qdivide   0xcb00 /* ldivlib: d0.q / d1.q */

◆ TOK_qmultiply

#define TOK_qmultiply   0xca00 /* lmullib: d0.q * d1.q */

Function Documentation

◆ a_doxflip_c()

void a_doxflip_c ( volatile UBYTE * chip,
struct GfxBase * gfx )

XFlip Shape# in Amiga mode: OwnBlitter, flip, wait for the blitter, DisownBlitter (fixed #271: the original's wait is BTST twice without a loop).

Parameters
chipa1: the chip base ($DFF000)
gfxa6: graphics.library

◆ allocshape()

void allocshape ( struct bb_shape * ns)
static

◆ b_doxflip_c()

void b_doxflip_c ( volatile UBYTE * chip)

XFlip Shape# - mirror a shape horizontally (Blitz mode).

a3 = the shape. First the planes are shifted right with the blitter by ebw*8-width pixels (so the image is "hard left" after the flip; one blit per plane, the same pointer as source and destination, modulo 0), then every row's bytes are mirrored and bit-reversed by the CPU; a cookie is made again if the shape had one (shapeslib +11).

The shift uses the shape's bltsize-1 words per plane. Fixed (#271): the CPU waits for the last blit before it flips the bytes (the original did not; the result depended on timing). Fixed (#274): the row count (depth x height) is a long (the original: a MULU low word). Errors: "Uninitialized Shape" (fchk, debugger only).

Parameters
chipa1: the chip base ($DFF000, chipbaselib)

◆ blitwait()

void blitwait ( volatile UBYTE * chip)
static

◆ BLITZ_ALIAS() [1/5]

BLITZ_ALIAS ( b_doxflip ,
b_doxflip_c  )

◆ BLITZ_ALIAS() [2/5]

BLITZ_ALIAS ( dorotate ,
dorotate_c  )

◆ BLITZ_ALIAS() [3/5]

BLITZ_ALIAS ( doscale ,
doscale_c  )

◆ BLITZ_ALIAS() [4/5]

BLITZ_ALIAS ( doscale2 ,
doscale2_c  )

◆ BLITZ_ALIAS() [5/5]

BLITZ_ALIAS ( doyflip ,
doyflip_c  )

◆ cookieit()

void cookieit ( struct bb_shape * s)
static

◆ docookie()

void docookie ( struct bb_shape * shape)
static

◆ dorotate()

void dorotate ( void )

◆ dorotate_c()

void dorotate_c ( ULONG q)
static

Rotate Shape#,Angle Ratio - rotate a shape.

a3 = the shape. angle = Quick 0..1 -> 256 steps; the new size comes from the rotated corners; every destination pixel is rotated back (rotit, sin table, rounding +$8000) and copied when it falls inside the source. The new shape (newshape, MEMF_CHIP|MEMF_CLEAR, not checked, handle 0) replaces the old one; a cookie is made again if the shape had one.

Fixed (#274): the plane steps are unsigned (the original's ADDA.w went backwards for planes of 32K and more). Errors (rotchk, debugger only): "Uninitialized Shape", "Shape too Big" (the rotated size with a plane of 64K or more with the extra word per row; fixed, #1047: the original has no check).

Parameters
qd1: the angle as a Quick (0..1 = a full turn)

◆ doscale()

void doscale ( void )

◆ doscale2()

void doscale2 ( void )

◆ doscale2_c()

void doscale2_c ( ULONG xr,
ULONG yr )
static

Scale Shape#,X Ratio,Y Ratio - scale a shape.

a3 = the shape. New size = size * ratio (lmullib $CA00, at least 1), source steps 1/ratio (ldivlib $CB00); every destination pixel takes the colour with the highest sum of "brightness" over the source pixels it covers - without a palette every colour counts 1, so the most frequent colour. The new shape replaces the old one as in Rotate.

Fixed (#273): a target size below 1 raised to 1 collects exactly the shape's row/column (the original read 1/Ratio pixels, past the shape). Fixed (#274): unsigned plane steps, the step back over all planes a long (the original: ADDA.w, the word +26). Errors (scalechk2, debugger only): "Uninitialized Shape", "Shape too Big" (the scaled size with a plane of 64K or more with the extra word per row; fixed, #1047: the original has no check).

Parameters
xrd1: the x ratio (Quick)
yrd2: the y ratio (Quick)

◆ doscale_c()

void doscale_c ( ULONG xr,
ULONG yr,
struct bb_palette * pal )
static

Scale Shape#,X Ratio,Y Ratio,Palette# - scale a shape, the colour choice weighted by the palette.

As doscale2_c, the brightness of a colour = r+g+b+3 of the top bytes of the palette's entries. Not a bug (#272): entries beyond the current palette keep the values of an earlier Scale (never used: the choice only compares usevals[0..numcols]).

Errors (scalechk, debugger only): "Uninitialized Palette", "Uninitialized Shape", "Shape too Big" (fixed, #1047).

Parameters
xrd1: the x ratio (Quick)
yrd2: the y ratio (Quick)
pala2: the palette object

◆ doxflip()

void doxflip ( void )

◆ doyflip()

void doyflip ( void )

◆ doyflip_c()

void doyflip_c ( void )
static

YFlip Shape# - mirror a shape vertically (rows swapped plane by plane); a3 = the shape.

A cookie is made again if the shape had one (shapeslib +11). Fixed (#274): the plane steps are unsigned (the original's ADDA.w went backwards for planes of 32K and more). Errors: "Uninitialized Shape" (fchk, debugger only).

◆ fchk_c()

void fchk_c ( void )
static

◆ flipbyte()

UBYTE flipbyte ( UBYTE b)
static

◆ globalloc()

void * globalloc ( ULONG size,
ULONG flags )
static

◆ globfree()

void globfree ( void * mem,
ULONG size )
static

◆ makeshape()

void makeshape ( struct bb_shape * shape)
static

◆ mulcos()

ULONG mulcos ( WORD val,
UWORD angle )
static

◆ mulsin()

ULONG mulsin ( WORD val,
UWORD angle )
static

◆ qcall()

ULONG qcall ( ULONG val,
ULONG a,
ULONG b )
static

◆ rotchk()

void rotchk ( void )

◆ rotchk_c()

void rotchk_c ( ULONG q)
static

◆ rotit()

void rotit ( WORD x,
WORD y,
UWORD angle,
WORD * nx,
WORD * ny )
static

◆ rotit2()

void rotit2 ( WORD x,
WORD y,
UWORD angle )
static

◆ scale()

void scale ( struct bb_shape * shape,
ULONG xr,
ULONG yr )
static

◆ scalechk()

void scalechk ( void )

◆ scalechk2()

void scalechk2 ( void )

◆ scalechk2_c()

void scalechk2_c ( ULONG xr,
ULONG yr )
static

◆ scalechk_c()

void scalechk_c ( ULONG xr,
ULONG yr,
struct bb_palette * pal )
static

◆ scaled()

UWORD scaled ( UWORD n,
ULONG ratio )
static

◆ shapetrixlib_fchk()

void shapetrixlib_fchk ( void )

◆ sizechk()

void sizechk ( UWORD w,
UWORD h )
static

◆ xflip()

void xflip ( struct bb_shape * s,
volatile UBYTE * chip )
static

Variable Documentation

◆ colvals

UWORD colvals[256]
static

◆ newshape

struct bb_shape newshape
static

◆ numcols

UWORD numcols
static

◆ qrots

const UWORD qrots[65]
static
Initial value:
= {
0x0000, 0x0648, 0x0c8f, 0x12d5, 0x1917, 0x1f56, 0x2590, 0x2bc4,
0x31f1, 0x3817, 0x3e33, 0x4447, 0x4a50, 0x504d, 0x563e, 0x5c22,
0x61f7, 0x67bd, 0x6d74, 0x7319, 0x78ad, 0x7e2e, 0x839c, 0x88f5,
0x8e39, 0x9368, 0x987f, 0x9d7f, 0xa267, 0xa736, 0xabeb, 0xb085,
0xb504, 0xb968, 0xbdae, 0xc1d8, 0xc5e4, 0xc9d1, 0xcd9f, 0xd14d,
0xd4db, 0xd848, 0xdb94, 0xdebe, 0xe1c5, 0xe4aa, 0xe76b, 0xea09,
0xec83, 0xeed8, 0xf109, 0xf314, 0xf4fa, 0xf6ba, 0xf853, 0xf9c7,
0xfb14, 0xfc3b, 0xfd3a, 0xfe13, 0xfec4, 0xff4e, 0xffb1, 0xffec,
0xffff
}

◆ scaleall

ULONG scaleall
static

◆ usevals

UWORD usevals[256]
static

◆ xadd

ULONG xadd
static

◆ xh

WORD xh
static

◆ xl

WORD xl
static

◆ yadd

ULONG yadd
static

◆ yh

WORD yh
static

◆ yl

WORD yl
static