BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
fadelib.c File Reference
#include "blitzlib.h"
#include "blitzobj.h"

Macros

#define FADE_FORMS(palonly, withrate, withrange)
#define COLMOVES(s)

Functions

void fadechk0 (void)
void fadechk (void)
void dosetfade (void)
void dofadestatus (void)
void fadelib_codeinit (void)
void dofadein2 (const struct bb_palette *pal, struct bb_slice *slice)
 FadeIn Palette#: fade all colours in, rate 0.
void dofadein3 (UWORD rate, const struct bb_palette *pal, struct bb_slice *slice)
 FadeIn Palette#,Rate: fade all colours in.
void dofadein (UWORD rate, UWORD lo, UWORD hi, const struct bb_palette *pal, struct bb_slice *slice)
 FadeIn Palette#,Rate,Low Colour,High Colour: fade the colours of the used slice from black to the palette.
void dofadeout2 (const struct bb_palette *pal, struct bb_slice *slice)
 FadeOut Palette#: fade all colours out, rate 0.
void dofadeout3 (UWORD rate, const struct bb_palette *pal, struct bb_slice *slice)
 FadeOut Palette#,Rate: fade all colours out.
void dofadeout (UWORD rate, UWORD lo, UWORD hi, const struct bb_palette *pal, struct bb_slice *slice)
 FadeOut Palette#,Rate,Low Colour,High Colour: fade the colours of the used slice from the palette to black.
void doasyncfade (void)
 DoFade: one step of the fade.
 FADE_FORMS (dofadein2, dofadein3, dofadein)
 FADE_FORMS (dofadeout2, dofadeout3, dofadeout)
static void codeinit_c (void)
static void dosetfade_c (UWORD type)
 ASyncFade On|Off: fade synchronously or step by step.
 BLITZ_ALIAS (dosetfade, dosetfade_c)
static UWORD dofadestatus_c (void)
 FadeStatus: the steps of the fade still to do.
 BLITZ_ALIAS (dofadestatus, dofadestatus_c)
static void calcrange (const struct bb_palette *pal, const struct bb_slice *slice, UWORD *lo, UWORD *hi)
static void calcfade (const struct bb_palette *pal, struct bb_slice *slice, UWORD rate, UWORD lo, UWORD hi)
static void dosyncfade (void)
static int fadechk0_x (const struct bb_palette *pal, const struct bb_slice *slice)
static void fadechk0_c (const struct bb_palette *pal, const struct bb_slice *slice)
static void fadechk_c (UWORD lo, UWORD hi, const struct bb_palette *pal, const struct bb_slice *slice)

Variables

static UBYTE fade [96]
static UBYTE fadef [96]
struct { 
   UWORD   fadelow 
   UWORD   fadehi 
   struct bb_slice *   fadesl 
   UWORD   faderate 
   UWORD   fadenum 
   UWORD   fadetype 
} F

Macro Definition Documentation

◆ COLMOVES

#define COLMOVES ( s)
Value:
(*(UBYTE *const *)&(s)->colmoves)

◆ FADE_FORMS

#define FADE_FORMS ( palonly,
withrate,
withrange )
Value:
BLITZ_LIBS(LIB_palettelib, BL_IA0|BL_PD0, LIB_blitzcoplib, BL_UA1); \
BLITZ_SUBS(palonly, BLITZ_BLITZONLY_CHK(fadechk0), 0); \
BLITZ_ARGS(BL_WORD, BL_WORD); \
BLITZ_LIBS(LIB_palettelib, BL_IA0|BL_PD0, LIB_blitzcoplib, BL_UA1); \
BLITZ_SUBS(withrate, BLITZ_BLITZONLY_CHK(fadechk0), 0); \
BLITZ_ARGS(BL_WORD, BL_WORD, BL_WORD, BL_WORD); \
BLITZ_LIBS(LIB_palettelib, BL_IA0|BL_PD0, LIB_blitzcoplib, BL_UA1); \
BLITZ_SUBS(withrange, BLITZ_BLITZONLY_CHK(fadechk), 0)
#define BL_WORD
Definition blitzlib.h:91
#define BL_IA0
Definition blitzlib.h:239
#define BLITZ_BLITZONLY_CHK(chk)
Definition blitzlib.h:512
#define BL_PD0
Definition blitzlib.h:231
#define BL_UA1
Definition blitzlib.h:212
#define BLITZ_ARGS(...)
Definition blitzlib.h:349
void fadechk(void)
void fadechk0(void)

Function Documentation

◆ BLITZ_ALIAS() [1/2]

BLITZ_ALIAS ( dofadestatus ,
dofadestatus_c  )

◆ BLITZ_ALIAS() [2/2]

BLITZ_ALIAS ( dosetfade ,
dosetfade_c  )

◆ calcfade()

void calcfade ( const struct bb_palette * pal,
struct bb_slice * slice,
UWORD rate,
UWORD lo,
UWORD hi )
static

◆ calcrange()

void calcrange ( const struct bb_palette * pal,
const struct bb_slice * slice,
UWORD * lo,
UWORD * hi )
static

◆ codeinit_c()

void codeinit_c ( void )
static

◆ doasyncfade()

void doasyncfade ( void )

DoFade: one step of the fade.

Blitz mode only. If steps are left: adds the fractions to the colours from the low to the high colour and writes r<<8|g<<4|b of the high nibbles into the copper colour moves of the slice (slice+18).

◆ dofadein()

void dofadein ( UWORD rate,
UWORD lo,
UWORD hi,
const struct bb_palette * pal,
struct bb_slice * slice )

FadeIn Palette#,Rate,Low Colour,High Colour: fade the colours of the used slice from black to the palette.

Blitz mode only. Sets up 16 steps (calcfade: per colour the fraction = high byte of the component >> 4; low and high are swapped if low > high), starts at 0 and, with ASyncFade Off, does them all with VWait rate between them. Fixed (#134): the fractions are those of the palette alone (the original added bits of d0.w = palette# * 128 to the red and green fractions of the first colour for palettes 2 and up). By design (#136): the range is not clipped to the colours of palette and slice. Errors (debugger, fadechk): "Uninitialized Slice", "Uninitialized Palette" (fixed #330: the original gave "Not enough colours in Slice"), "Not enough colours in Slice", also for a colour beyond the slice's colours (fixed #331: the original gave "Uninitialized Slice"); fixed (#135): the palette's data pointer is tested as a long.

Parameters
rated1: the frames to wait between the steps (VWait)
lod2: the low colour
hid3: the high colour
pala0: the palette (!libs palettelib,$1080)
slicea1: the used slice (!libs blitzcoplib,$1102)

◆ dofadein2()

void dofadein2 ( const struct bb_palette * pal,
struct bb_slice * slice )

FadeIn Palette#: fade all colours in, rate 0.

Parameters
pala0: the palette
slicea1: the used slice

◆ dofadein3()

void dofadein3 ( UWORD rate,
const struct bb_palette * pal,
struct bb_slice * slice )

FadeIn Palette#,Rate: fade all colours in.

As FadeIn with the range 0 .. min(colours of the palette, colours of the slice) - 1. Errors (debugger, fadechk0): as FadeIn without the range check.

Parameters
rated1: the frames to wait between the steps
pala0: the palette
slicea1: the used slice

◆ dofadeout()

void dofadeout ( UWORD rate,
UWORD lo,
UWORD hi,
const struct bb_palette * pal,
struct bb_slice * slice )

FadeOut Palette#,Rate,Low Colour,High Colour: fade the colours of the used slice from the palette to black.

As FadeIn, but starts at the full colours (fraction << 4) and subtracts the fractions. Fixed (#134), by design (#136) and errors as FadeIn.

Parameters
rated1: the frames to wait between the steps (VWait)
lod2: the low colour
hid3: the high colour
pala0: the palette (!libs palettelib,$1080)
slicea1: the used slice (!libs blitzcoplib,$1102)

◆ dofadeout2()

void dofadeout2 ( const struct bb_palette * pal,
struct bb_slice * slice )

FadeOut Palette#: fade all colours out, rate 0.

Parameters
pala0: the palette
slicea1: the used slice

◆ dofadeout3()

void dofadeout3 ( UWORD rate,
const struct bb_palette * pal,
struct bb_slice * slice )

FadeOut Palette#,Rate: fade all colours out.

As FadeOut with the range 0 .. min(colours of the palette, colours of the slice) - 1.

Parameters
rated1: the frames to wait between the steps
pala0: the palette
slicea1: the used slice

◆ dofadestatus()

void dofadestatus ( void )

◆ dofadestatus_c()

UWORD dofadestatus_c ( void )
static

FadeStatus: the steps of the fade still to do.

Blitz mode only.

Returns
d0.w: the steps left (0..16); the upper word of d0 stays

◆ dosetfade()

void dosetfade ( void )

◆ dosetfade_c()

void dosetfade_c ( UWORD type)
static

ASyncFade On|Off: fade synchronously or step by step.

Off (default): FadeIn/FadeOut do all 16 steps with VWait rate between them. On: they only set the fade up, the program calls DoFade.

Parameters
typed0: 0 = synchronous, anything else = asynchronous

◆ dosyncfade()

void dosyncfade ( void )
static

◆ FADE_FORMS() [1/2]

FADE_FORMS ( dofadein2 ,
dofadein3 ,
dofadein  )

◆ FADE_FORMS() [2/2]

FADE_FORMS ( dofadeout2 ,
dofadeout3 ,
dofadeout  )

◆ fadechk()

void fadechk ( void )

◆ fadechk0()

void fadechk0 ( void )

◆ fadechk0_c()

void fadechk0_c ( const struct bb_palette * pal,
const struct bb_slice * slice )
static

◆ fadechk0_x()

int fadechk0_x ( const struct bb_palette * pal,
const struct bb_slice * slice )
static

◆ fadechk_c()

void fadechk_c ( UWORD lo,
UWORD hi,
const struct bb_palette * pal,
const struct bb_slice * slice )
static

◆ fadelib_codeinit()

void fadelib_codeinit ( void )

Variable Documentation

◆ [struct]

struct { ... } F

◆ fade

UBYTE fade[96]
static

◆ fadef

UBYTE fadef[96]
static

◆ fadehi

UWORD fadehi

◆ fadelow

UWORD fadelow

◆ fadenum

UWORD fadenum

◆ faderate

UWORD faderate

◆ fadesl

struct bb_slice* fadesl

◆ fadetype

UWORD fadetype