BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
riwbspritelib.c File Reference
#include "blitzlib.h"
#include "blitzobj.h"
#include "blitzexec.h"
#include <exec/memory.h>
#include <graphics/gfx.h>
#include <graphics/sprite.h>
#include <graphics/view.h>
#include <utility/tagitem.h>
#include <proto/graphics.h>

Data Structures

struct  wbs
struct  sprfuncs

Macros

#define __NOLIBBASE__
#define GRAPHICS_BASE_NAME   wd.graphicslibbase
#define LOWORD(l)
#define SHAPEDATA(s)
#define ASLW2(d)
#define ENTRYW(ch)
#define V33IMG(h)

Functions

void _GetWBSprite (void)
void _freesprite (void)
void _movewbsprite (void)
void _changewbsprite (void)
void _wbspritex (void)
void _wbspritey (void)
void riwbspritelib_libinit (void)
void riwbspritelib_libfinit (void)
void _getwbspritechk (void)
void _freesprchk (void)
void _movewbspritechk (void)
void _changewbspritechk (void)
void _wbspritexychk (void)
static void movesprite (ULONG vp, ULONG spr, ULONG x, ULONG y)
static ULONG freespritedata (ULONG spr)
static LONG changeextsprite (ULONG vp, ULONG old, ULONG new, ULONG tags)
static ULONG v39get (void)
static ULONG v33get (void)
static ULONG v33freedata (ULONG spr)
static BB_BOOL v39change (void)
static BB_BOOL v33change (void)
static void libinit_c (void)
 init: opens graphics.library (any version) and chooses the sprite functions by its version: V39 and up the ExtSprite functions, below V39 those of the SimpleSprite (fixed #1151).
static void libfinit_c (void)
 finit: every sprite freed (FreeSprite, FreeSpriteData), the library closed.
static void copyshape (struct BitMap *bm)
static int shapebitmap (void)
static ULONG newsprite (void)
static ULONG getwbsprite_c (UWORD x, UWORD y, LONG ch, ULONG shape)
 GetWBSprite(x,y,shape[,spritechannel]): a Workbench sprite from a Blitz shape.
static ULONG freesprite_c (ULONG ch)
 FreeWBSprite sprite_channel: frees a sprite (FreeSprite, FreeSpriteData) and clears its table entry.
static ULONG movewbsprite_c (ULONG vp, ULONG x, ULONG y, ULONG ch)
 MoveWBSprite(viewport,x,y,sprite_channel): MoveSprite of the channel's sprite.
static BB_BOOL changewbsprite_c (ULONG vp, ULONG ch, ULONG shape)
 ChangeWBSprite(viewport,sprite_channel,shape#): a new image for a sprite (ChangeExtSpriteA).
static UWORD * v33image (void)
static ULONG wbspritex_c (ULONG ch)
 WBSpriteX(sprite_channel): the x of the channel's sprite.
static ULONG wbspritey_c (ULONG ch)
 WBSpriteY(sprite_channel): the y of the channel's sprite.
static void chchk (ULONG ch)
static void shapechk (const struct bb_shape *sh)
static void getwbspritechk_c (LONG ch, const struct bb_shape *shape)
 The error check of GetWBSprite (debugger only).
static void freesprchk_c (ULONG ch)
 The error check of FreeWBSprite (debugger only).
static void movewbspritechk_c (ULONG ch)
 The error check of MoveWBSprite (debugger only).
static void changewbspritechk_c (ULONG ch, const struct bb_shape *shape)
 The error check of ChangeWBSprite (debugger only).
static void wbspritexychk_c (ULONG ch)
 The error check of WBSpriteX and WBSpriteY (debugger only).

Variables

static struct wbs wd
static const struct sprfuncs v39funcs = { v39get, v39change, freespritedata }
static const struct sprfuncs v33funcs = { v33get, v33change, v33freedata }
static const struct sprfuncs * sf

Macro Definition Documentation

◆ __NOLIBBASE__

#define __NOLIBBASE__

◆ ASLW2

#define ASLW2 ( d)
Value:
(((ULONG)(d) & 0xffff0000UL) | (UWORD)((ULONG)(d) << 2))
static struct @065163037313156332013005143365272036211065172003 d

◆ ENTRYW

#define ENTRYW ( ch)
Value:
((ULONG *)((UBYTE *)wd.spritepointers + (WORD)((UWORD)(ch) << 2)))
static struct wbs wd
static void ch(struct out *o, char c)
Definition xtra_ab3.c:487

◆ GRAPHICS_BASE_NAME

#define GRAPHICS_BASE_NAME   wd.graphicslibbase

◆ LOWORD

#define LOWORD ( l)
Value:
(((UWORD *)&(l))[1])

◆ SHAPEDATA

#define SHAPEDATA ( s)
Value:
(*(const ULONG *)&((const struct bb_shape *)(s))->data)
void data(void)
A Shape object, 32 bytes (shapeslib's; also the block SaveShape(s) writes and the header of a shape f...
Definition blitzobj.h:48

◆ V33IMG

#define V33IMG ( h)
Value:
(((ULONG)(h) + 2) * 4)
struct TagItem h
Definition asllib.c:193

Function Documentation

◆ _changewbsprite()

void _changewbsprite ( void )

◆ _changewbspritechk()

void _changewbspritechk ( void )

◆ _freesprchk()

void _freesprchk ( void )

◆ _freesprite()

void _freesprite ( void )

◆ _GetWBSprite()

void _GetWBSprite ( void )

◆ _getwbspritechk()

void _getwbspritechk ( void )

◆ _movewbsprite()

void _movewbsprite ( void )

◆ _movewbspritechk()

void _movewbspritechk ( void )

◆ _wbspritex()

void _wbspritex ( void )

◆ _wbspritexychk()

void _wbspritexychk ( void )

◆ _wbspritey()

void _wbspritey ( void )

◆ changeextsprite()

LONG changeextsprite ( ULONG vp,
ULONG old,
ULONG new,
ULONG tags )
static

◆ changewbsprite_c()

BB_BOOL changewbsprite_c ( ULONG vp,
ULONG ch,
ULONG shape )
static

ChangeWBSprite(viewport,sprite_channel,shape#): a new image for a sprite (ChangeExtSpriteA).

Amiga mode only. The shape is converted as in GetWBSprite, at the sprite's position; on success the old sprite data are freed and the new ones replace them in the table. The channel and the shape: changewbspritechk (fixed #916, #917). Fixed (#915): if ChangeExtSpriteA fails, the new sprite data are freed (the original lost them).

Parameters
vpd0: the ViewPort
chd1: the channel
shapea0: the shape (!libs shapeslib,ia0|pd2)
Returns
d0: BB_TRUE, BB_FALSE without graphics.library, shape data or sprite, or if a step fails

◆ changewbspritechk_c()

void changewbspritechk_c ( ULONG ch,
const struct bb_shape * shape )
static

The error check of ChangeWBSprite (debugger only).

Fixed (#916), not in the original: the channel (a long) indexes the table without a check. Release code unchanged (D-005).

Fixed (#917): the shape as GetWBSprite's.

Errors: "Sprite channel must be 0 to 7"; "Illegal Shape Height", "Illegal Shape Depth".

Parameters
chd1: the channel
shapea0: the shape

◆ chchk()

void chchk ( ULONG ch)
static

◆ copyshape()

void copyshape ( struct BitMap * bm)
static

◆ freesprchk_c()

void freesprchk_c ( ULONG ch)
static

The error check of FreeWBSprite (debugger only).

Fixed (#916), not in the original: the release code takes the channel modulo 16 for the table (entries 8-15 are the library name and base) and passes the whole register to FreeSprite. Release code unchanged (D-005).

Errors: "Sprite channel must be 0 to 7".

Parameters
chd0.b: the channel

◆ freesprite_c()

ULONG freesprite_c ( ULONG ch)
static

FreeWBSprite sprite_channel: frees a sprite (FreeSprite, FreeSpriteData) and clears its table entry.

Amiga mode only. The table entry of channel & 15: entries 8-15 are the library name and base, and FreeSprite gets the whole register (a channel outside 0-7 is refused by freesprchk, fixed #916).

Parameters
chd0.b: the channel
Returns
d0: 0 without a sprite (failed: MOVEQ #0), else as FreeSpriteData leaves it (a statement: the value is not used)

◆ freespritedata()

ULONG freespritedata ( ULONG spr)
static

◆ getwbsprite_c()

ULONG getwbsprite_c ( UWORD x,
UWORD y,
LONG ch,
ULONG shape )
static

GetWBSprite(x,y,shape[,spritechannel]): a Workbench sprite from a Blitz shape.

Amiga mode only. The shape is copied into a bitmap of AllocBitMap, converted with AllocSpriteDataA (x, y set) and got with GetExtSpriteA (channel -1: any); the sprite goes into the table. The copy has DBRA counts; the channel and the shape: getwbspritechk (fixed #916, #917). Fixed (#918): the copy steps by the shape's ebwidth and the bitmap's BytesPerRow. Fixed (#920): every failure (no graphics.library, no shape data, a shape narrower than 16, a failing AllocBitMap, AllocSpriteDataA or GetExtSpriteA) gives -1; the original decided by the channel's table entry (the channel if the library held a sprite there, else 0) and gave 0 or -1 for the others.

Parameters
xd0: x (a word)
yd1: y (a word)
chd3: the channel, -1 for any
shapea0: the shape (!libs shapeslib,ia0|pd2)
Returns
d0: the channel 0-7, -1 if no sprite was got

◆ getwbspritechk_c()

void getwbspritechk_c ( LONG ch,
const struct bb_shape * shape )
static

The error check of GetWBSprite (debugger only).

Fixed (#916), not in the original (riwbspritelib had no error check area): the channel indexes the sprite table of 8 entries without a check (the tag lists before it, the library name and base behind it). The release code is unchanged (an invalid argument, D-005).

Fixed (#917): a shape with data and a height of 0, a depth of 0 or above 8 (an invalid object: Blitz's shape commands make none) is refused before AllocBitMap; the copy counts height - 1 and depth - 1 with DBRA (65536 rows or planes; the planes read behind the 8 of the bitmap). Release code unchanged (D-005).

Errors: "Sprite channel must be -1 to 7"; "Illegal Shape Height", "Illegal Shape Depth".

Parameters
chd3: the channel (a long), -1 for any
shapea0: the shape

◆ libfinit_c()

void libfinit_c ( void )
static

finit: every sprite freed (FreeSprite, FreeSpriteData), the library closed.

BUG(orig) (#919): the base is kept, a second finit closes graphics.library again.

◆ libinit_c()

void libinit_c ( void )
static

init: opens graphics.library (any version) and chooses the sprite functions by its version: V39 and up the ExtSprite functions, below V39 those of the SimpleSprite (fixed #1151).

◆ movesprite()

void movesprite ( ULONG vp,
ULONG spr,
ULONG x,
ULONG y )
static

◆ movewbsprite_c()

ULONG movewbsprite_c ( ULONG vp,
ULONG x,
ULONG y,
ULONG ch )
static

MoveWBSprite(viewport,x,y,sprite_channel): MoveSprite of the channel's sprite.

Amiga mode only; nothing without a sprite. The channel: movewbspritechk (fixed #916). Fixed (#921): the result is -1 when the sprite was moved (the original returned the d0 MoveSprite leaves, declared as a byte).

Parameters
vpd0: the ViewPort
xd1: x
yd2: y
chd3: the channel
Returns
d0: -1 moved, 0 without a sprite

◆ movewbspritechk_c()

void movewbspritechk_c ( ULONG ch)
static

The error check of MoveWBSprite (debugger only).

Fixed (#916), not in the original: the channel (a long) indexes the table without a check. Release code unchanged (D-005).

Errors: "Sprite channel must be 0 to 7".

Parameters
chd3: the channel

◆ newsprite()

ULONG newsprite ( void )
static

◆ riwbspritelib_libfinit()

void riwbspritelib_libfinit ( void )

◆ riwbspritelib_libinit()

void riwbspritelib_libinit ( void )

◆ shapebitmap()

int shapebitmap ( void )
static

◆ shapechk()

void shapechk ( const struct bb_shape * sh)
static

◆ v33change()

BB_BOOL v33change ( void )

◆ v33freedata()

ULONG v33freedata ( ULONG spr)

◆ v33get()

ULONG v33get ( void )

◆ v33image()

UWORD * v33image ( void )
static

◆ v39change()

BB_BOOL v39change ( void )
static

◆ v39get()

ULONG v39get ( void )
static

◆ wbspritex_c()

ULONG wbspritex_c ( ULONG ch)
static

WBSpriteX(sprite_channel): the x of the channel's sprite.

Amiga mode only. Without a sprite the word at 6 is read (address 6; the channel and the sprite: wbspritexychk, fixed #916, #922).

Parameters
chd0.w: the channel
Returns
d0: the low word replaced by es_SimpleSprite.x

◆ wbspritexychk_c()

void wbspritexychk_c ( ULONG ch)
static

The error check of WBSpriteX and WBSpriteY (debugger only).

Fixed (#916), not in the original: the channel (a word) indexes the table without a check. Release code unchanged (D-005).

Fixed (#922): a channel without a sprite of the library is refused; the release code reads the word at 6 or 8 of the entry, 0, without a test (a query of a sprite that does not exist, as #686, #1131).

Errors: "Sprite channel must be 0 to 7", "No sprite on this channel".

Parameters
chd0.w: the channel

◆ wbspritey_c()

ULONG wbspritey_c ( ULONG ch)
static

WBSpriteY(sprite_channel): the y of the channel's sprite.

As WBSpriteX, the word at 8 (wbspritexychk: fixed #916, #922).

Parameters
chd0.w: the channel
Returns
d0: the low word replaced by es_SimpleSprite.y

Variable Documentation

◆ sf

const struct sprfuncs* sf
static

◆ v33funcs

const struct sprfuncs v33funcs = { v33get, v33change, v33freedata }
static

◆ v39funcs

const struct sprfuncs v39funcs = { v39get, v39change, freespritedata }
static

◆ wd

struct wbs wd
static
Initial value:
= {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
{ { 0x81000000UL, 16 },
{ 0x81000006UL, 16 },
{ 0x81000002UL, 0 },
{ 0x81000004UL, 0 },
{ 0x81000008UL, 0 },
{ TAG_DONE, 0 } },
{ { 0x82000020UL, 1 },
{ 0x82000022UL, 0 },
{ 0x82000024UL, 0 } },
{ { TAG_DONE, 0 } },
{ 0 },
"graphics.library",
NULL,
}