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

Data Structures

struct  copmove
struct  spritecop

Macros

#define __NOLIBBASE__
#define AMIGAONLY(entry)
#define BLITZONLY(chk)
#define DOSBase   dosbase /* for proto/dos.h */

Functions

void dogetsprite (void)
void doshowsprite (void)
 ShowSprite Sprite#,X,Y,Sprite Channel - show a sprite on the used slice (Blitz mode only).
void doinfront1 (void)
void doinfront2 (void)
void dosavesprites (void)
void doloadsprites (void)
void doloadsprites2 (void)
void dospritemode (void)
void freeasprite (void)
static ULONG codeinit (void)
void gspchk (void)
void spriteslib_sspchk (void)
void infchk (void)
void ssz (void)
void spritemodechk (void)
static void * globalloc (ULONG size, ULONG flags)
static void globfree (void *mem, ULONG size)
static UWORD lslw (UWORD v, UWORD n)
static ULONG spsize (const struct bb_sprite *sp)
static void dospritemode_c (ULONG m)
 SpriteMode 0=16 1=32 2=64 - the sprite width (FMODE) for the following GetaSprite/ShowSprite.
 BLITZ_ALIAS (dospritemode, dospritemode_c)
static void freeasprite_ (struct bb_sprite *sp)
static void freeasprite_c (void)
static UBYTE * partsprite (const UBYTE *src, UBYTE *dst, UWORD height, const struct bb_shape *shape, UWORD avail)
static UBYTE * onesprite (const UBYTE *src, UBYTE *dst, UWORD height, const struct bb_shape *shape, WORD avail)
static void dogetsprite_c (struct bb_shape *shape)
 GetaSprite Sprite#,Shape# - make a sprite from a 4 or 16 colour shape.
 BLITZ_ALIAS (dogetsprite, dogetsprite_c)
static void doinfront1_c (ULONG ch, struct bb_slice *slice)
 InFront Sprite Channel, InFrontB Sprite Channel - sprites from the channel on appear in front of playfield 2 (Blitz mode only).
 BLITZ_ALIAS (doinfront1, doinfront1_c)
static void doinfront2_c (ULONG ch, struct bb_slice *slice)
 InFrontF Sprite Channel - sprites from the channel on appear in front of playfield 1 (Blitz mode only).
 BLITZ_ALIAS (doinfront2, doinfront2_c)
static void dosavesprites_c (UBYTE *last, const char *name, struct DosLibrary *dos)
 SaveSprites Sprite#,Sprite#,Filename$ - save a range of sprites to a file (Amiga mode only).
 BLITZ_ALIAS (dosavesprites, dosavesprites_c)
static void loadsprites (struct bb_sprite *sp, const UBYTE *last, const char *name, struct DosLibrary *dos)
static void doloadsprites_c (UBYTE *last, const char *name, struct DosLibrary *dos)
 LoadSprites Sprite#,Sprite#,Filename$ - load a range of sprites from a file made by SaveSprites (Amiga mode only).
 BLITZ_ALIAS (doloadsprites, doloadsprites_c)
static void doloadsprites2_c (UBYTE *base, ULONG max, const char *name, struct DosLibrary *dos)
 LoadSprites Sprite#,Filename$ - load sprites from the given one up to the last of the object table (Amiga mode only).
 BLITZ_ALIAS (doloadsprites2, doloadsprites2_c)
static void gspchk_c (struct bb_shape *shape)
static void sspchk_c (ULONG ch, struct bb_slice *slice)
static void infchk_c (ULONG ch, struct bb_slice *slice)
static void ssz_c (UBYTE *last)
static void spritemodechk_c (ULONG m)

Variables

struct { 
   UWORD   shlup [3] 
   UWORD   mode 
   UWORD   wid 
   UWORD   shift 
} sv = { { 2, 4, 8 }, 0, 0, 0 }
static struct DosLibrary * dosbase
static const char mess10 [] = "Can't open Sprites file"
static const char mess11 [] = "Error reading/writing Sprites file"

Macro Definition Documentation

◆ __NOLIBBASE__

#define __NOLIBBASE__

◆ AMIGAONLY

#define AMIGAONLY ( entry)
Value:
((char *)(entry) + 1)
static struct snowfield * entry(ULONG n)
Definition risnowlib.c:205

◆ BLITZONLY

#define BLITZONLY ( chk)
Value:
((char *)(chk) + 1)

◆ DOSBase

#define DOSBase   dosbase /* for proto/dos.h */

Function Documentation

◆ BLITZ_ALIAS() [1/7]

BLITZ_ALIAS ( dogetsprite ,
dogetsprite_c  )

◆ BLITZ_ALIAS() [2/7]

BLITZ_ALIAS ( doinfront1 ,
doinfront1_c  )

◆ BLITZ_ALIAS() [3/7]

BLITZ_ALIAS ( doinfront2 ,
doinfront2_c  )

◆ BLITZ_ALIAS() [4/7]

BLITZ_ALIAS ( doloadsprites ,
doloadsprites_c  )

◆ BLITZ_ALIAS() [5/7]

BLITZ_ALIAS ( doloadsprites2 ,
doloadsprites2_c  )

◆ BLITZ_ALIAS() [6/7]

BLITZ_ALIAS ( dosavesprites ,
dosavesprites_c  )

◆ BLITZ_ALIAS() [7/7]

BLITZ_ALIAS ( dospritemode ,
dospritemode_c  )

◆ codeinit()

ULONG codeinit ( void )
static

◆ dogetsprite()

void dogetsprite ( void )

◆ dogetsprite_c()

void dogetsprite_c ( struct bb_shape * shape)
static

GetaSprite Sprite#,Shape# - make a sprite from a 4 or 16 colour shape.

Frees the sprite's old data, allocates CHIP memory for ((width-1) >> (shift+2)) + 1 hardware sprites (twice for 16 colours: attached pairs, planes 2+3 in the attached sprite) and copies per sprite and row the two planes' words/longs, then a 0 line (no control words: ShowSprite writes position and control into the slice's copper list). Takes the shape's handle.

Errors (debugger, gspchk): "Uninitialized Shape", "Shape MUST be 4 or 16 colours", "Sprite too Wide".

Fixed (#282): the last sprite of a shape whose byte width is no multiple of the sprite width (SpriteMode 1/2) takes only the bytes of the row and 0 for the rest; the original copied the whole sprite width (bytes of the next row).

Parameters
shapea2: the shape object; a3: the sprite object

◆ doinfront1()

void doinfront1 ( void )

◆ doinfront1_c()

void doinfront1_c ( ULONG ch,
struct bb_slice * slice )
static

InFront Sprite Channel, InFrontB Sprite Channel - sprites from the channel on appear in front of playfield 2 (Blitz mode only).

Sets the playfield 2 priority bits (BPLCON2 3-5) to channel/2 in the copper list of the used slice.

Errors (debugger, infchk): "Sprite Channel not in range" (odd or > 8), "Uninitialized Slice", "Slice does not support priority".

Parameters
chd0.w: the sprite channel (even, 0-8)
slicea2: the used slice

◆ doinfront2()

void doinfront2 ( void )

◆ doinfront2_c()

void doinfront2_c ( ULONG ch,
struct bb_slice * slice )
static

InFrontF Sprite Channel - sprites from the channel on appear in front of playfield 1 (Blitz mode only).

Sets the playfield 1 priority bits (BPLCON2 0-2) to channel/2 in the copper list of the used slice.

Errors (debugger, infchk): as InFront.

Parameters
chd0.w: the sprite channel (even, 0-8)
slicea2: the used slice

◆ doloadsprites()

void doloadsprites ( void )

◆ doloadsprites2()

void doloadsprites2 ( void )

◆ doloadsprites2_c()

void doloadsprites2_c ( UBYTE * base,
ULONG max,
const char * name,
struct DosLibrary * dos )
static

LoadSprites Sprite#,Filename$ - load sprites from the given one up to the last of the object table (Amiga mode only).

As LoadSprites with two sprites; the last is base + (maximum - 1) << 4.

Fixed (#999): that offset is a long (the maximum is the low word of d2); the original adds it as a word (from a maximum of 2049 on the last sprite lies before the table).

Parameters
basea2: the sprite table (object base); a3: the first sprite
maxd2: the maximum number of sprites
named1: the file name
dosa6: dos.library

◆ doloadsprites_c()

void doloadsprites_c ( UBYTE * last,
const char * name,
struct DosLibrary * dos )
static

LoadSprites Sprite#,Sprite#,Filename$ - load a range of sprites from a file made by SaveSprites (Amiga mode only).

Frees each sprite, reads its 16 byte object and its data (CHIP memory); stops at the end of the file.

Errors: as SaveSprites.

Fixed (#280): the data size is the sprite's own (bytes per image x hardware sprites); the original used the current SpriteMode.

Parameters
lasta2: the last sprite object; a3: the first
named2: the file name
dosa6: dos.library

◆ dosavesprites()

void dosavesprites ( void )

◆ dosavesprites_c()

void dosavesprites_c ( UBYTE * last,
const char * name,
struct DosLibrary * dos )
static

SaveSprites Sprite#,Sprite#,Filename$ - save a range of sprites to a file (Amiga mode only).

Per sprite the 16 byte object, then its data if it has any.

Errors: "Can't open Sprites file", "Error reading/writing Sprites file" (runtime errors also without the debugger, their messages in the normal code: #954); debugger (ssz): "First Sprite must be lower than second".

Fixed (#280): the data size is the sprite's own (bytes per image x hardware sprites); the original used the current SpriteMode.

Parameters
lasta2: the last sprite object; a3: the first
named2: the file name
dosa6: dos.library

◆ doshowsprite()

void doshowsprite ( void )

ShowSprite Sprite#,X,Y,Sprite Channel - show a sprite on the used slice (Blitz mode only).

Writes position, control and data pointer of each hardware sprite into the slice's copper list from the channel on. Clips at the top (the data pointer is advanced by the clipped lines, 4/8/16 bytes each) and the bottom of the slice; switches the sprites off when completely outside.

Errors (debugger, sspchk): "Uninitialized Sprite", "Uninitialized Slice", "Sprite Channel Unavailable".

Fixed (#283): the original's top clipping skips 4 bytes per line also in the 32/64 pixel modes and adds the upper word of the y register.

  • d1 x, x position
  • d2 y, y position
  • d3 ch, the first sprite channel
  • a2 slice, the used slice; a3: the sprite object

◆ dospritemode()

void dospritemode ( void )

◆ dospritemode_c()

void dospritemode_c ( ULONG m)
static

SpriteMode 0=16 1=32 2=64 - the sprite width (FMODE) for the following GetaSprite/ShowSprite.

Mode 0/1/2 = 16/32/64 pixels per sprite: widthshift 2/3/4, spritewid 2/4/8 bytes (from the table shlup).

The width is read from a table of 3 words: modes above 2 read the variables behind it. Errors (debugger only, spritemodechk): a mode above 2 -> "Illegal SpriteMode" (Fixed (#281): the original has no check). Fixed (#280): sprites made before the change keep their size (the original freed, saved and loaded them with the size of the new mode).

Parameters
md0.w: the mode

◆ freeasprite()

void freeasprite ( void )

◆ freeasprite_()

void freeasprite_ ( struct bb_sprite * sp)
static

◆ freeasprite_c()

void freeasprite_c ( void )
static

◆ globalloc()

void * globalloc ( ULONG size,
ULONG flags )
static

◆ globfree()

void globfree ( void * mem,
ULONG size )
static

◆ gspchk()

void gspchk ( void )

◆ gspchk_c()

void gspchk_c ( struct bb_shape * shape)
static

◆ infchk()

void infchk ( void )

◆ infchk_c()

void infchk_c ( ULONG ch,
struct bb_slice * slice )
static

◆ loadsprites()

void loadsprites ( struct bb_sprite * sp,
const UBYTE * last,
const char * name,
struct DosLibrary * dos )
static

◆ lslw()

UWORD lslw ( UWORD v,
UWORD n )
static

◆ onesprite()

UBYTE * onesprite ( const UBYTE * src,
UBYTE * dst,
UWORD height,
const struct bb_shape * shape,
WORD avail )
static

◆ partsprite()

UBYTE * partsprite ( const UBYTE * src,
UBYTE * dst,
UWORD height,
const struct bb_shape * shape,
UWORD avail )
static

◆ spritemodechk()

void spritemodechk ( void )

◆ spritemodechk_c()

void spritemodechk_c ( ULONG m)
static

◆ spriteslib_sspchk()

void spriteslib_sspchk ( void )

◆ spsize()

ULONG spsize ( const struct bb_sprite * sp)
static

◆ sspchk_c()

void sspchk_c ( ULONG ch,
struct bb_slice * slice )
static

◆ ssz()

void ssz ( void )

◆ ssz_c()

void ssz_c ( UBYTE * last)
static

Variable Documentation

◆ dosbase

struct DosLibrary* dosbase
static

◆ mess10

const char mess10[] = "Can't open Sprites file"
static

◆ mess11

const char mess11[] = "Error reading/writing Sprites file"
static

◆ mode

UWORD mode

◆ shift

UWORD shift

◆ shlup

UWORD shlup[3]

◆ [struct]

struct { ... } sv

◆ wid

UWORD wid