Alchemy
Loading...
Searching...
No Matches

colorfx.c File Reference

Go to the source code of this file.

Data Structures

struct  Reel
 One of the slot machine's five reels: how far it has turned, its 21 symbols, whether it is held, and the countdown to its stop (-1 until one starts). More...
struct  ReelWork
 The slot machine's work in heap slot 45: its reels, state, bet and spins, keys, timer, winning lines, sprites and windows. More...
struct  ReelSave
 gGameState seen from +12, the base the bytes load: wonPrizes is gGameState.wonPrizes (through the field itself ReelGame_RunFrame differs 12) More...

Macros

#define REEL_SPARKS   ((struct EffectStep *)Ram_MapCellBuffer)
 The sparks of the jackpot, kept in the map cell buffer.
#define REEL_HEAP_SLOT   45
 The slot machine's own work block (struct ReelWork), beside the battle effect blocks it borrows.
#define REEL_CANVAS_SIZE   (256 * 128)
 The paylines' canvas: 256 x 128 pixels of 8-bit colour, shown on BG2 from its tile 212, where the third row of its map begins.
#define REEL_CANVAS_TILES   (BG_CHAR_BLOCK(0) + 0x3500)
#define PACK_WINDOW_MASK   0x3ff
#define PACK_MATCH_MAX   272
#define PACK_DISTANCE_MAX   63
#define PACK_LOOKAHEAD   672

Enumerations

enum  ReelGameState {
  REEL_BETTING = 0 , REEL_SPINNING = 1 , REEL_WON = 2 , REEL_SHOWING_WIN = 3 ,
  REEL_CHOOSING_HOLDS = 5 , REEL_DONE = 10 , REEL_NO_WIN = 11 , REEL_OUT_OF_SPINS = 20
}
 The slot machine's states (ReelWork.state). More...

Functions

s32 ReelGame_Start (void)
 Plays the slot machine: blanks the screen, seeds the random numbers with the play time and runs the game.
s32 Graphics_ScaleRgb555 (u16 *src, u16 *dst, s32 scale, s32 count)
 Writes count RGB555 colours from src to dst scaled by scale (16.16, 0x10000 keeps them).
void ReelGame_TransferCanvas (void)
 A scheduler callback: on a frame whose canvas is ready (transferPending), sends the canvas to its tiles in VRAM (REEL_CANVAS_TILES), then clears it or fades it into trails as transferMode says.
void Palette_DarkenSceneStep (void)
 Darkens the screen one step: lowers each channel of the 16 colours of BG palette 10 and of OBJ colours 1 to 239 by 1.
void Palette_StepTowardResource (s32 resource)
 Moves the first 64 BG colours one step toward the palette of resource; the backdrop colour is not written back.
void ReelGame_DrawCanvasLine (s32 x0, s32 y0, s32 x1, s32 y1, s32 color)
 Draws a line from (x0, y0) to (x1, y1) on the 256 x 128 8bpp canvas (32 tiles across), writing only over lower colour numbers.
void ReelGame_RunFrame (void)
 The slot machine's frame callback: reads the keys, runs the game's state (betting, spinning and stopping the reels, scoring the paylines, choosing reels to hold, showing a win) and builds all 128 sprites: the cursor, the title letters of a win, the frame, the hold lamps, the spin counter, the paylines, the reel symbols, the lever and the bottom bar.
void ReelGame_InitTitle (void)
 Sets up the bouncing title letters of a win, the brightness wave of the screen's lines and the betting window, and starts at betting.
void ReelGame_Run (void)
 The slot machine: loads its backgrounds, sprites and palettes, fills each of the five reels with 21 random symbols (with eight placed symbols of rank 0 to 5), then runs until the player leaves: fading in, drawing the paylines on the canvas while betting or winning, and the jackpot's sparks and colour cycle while showing a win.
void LzPack_ResetSlotBuckets (void)
 The LZ packer below: empties its 256 hash chains (one per byte value) and numbers its 1024 window nodes.
void LzPack_InsertSlotNode (s32 index)
 Adds window position index to the chain of the byte it holds.
void LzPack_RemoveSlotNode (s32 slot)
 Removes window position slot from its chain.
void LzPack_ConsumeSlotBytes (s32 start, s32 count, const u8 *input)
 Reads count more input bytes into the window from position start, dropping the bytes they replace from their chains; past the end of the input the positions are marked empty (-1).
void LzPack_CopyBufferedBytes (u8 *destination)
 Appends the finished group (a flag byte and up to eight items) to the output.
static __inline__ void LzPack_FindWindowMatch (s32 start)
 Finds the longest earlier match (up to PACK_MATCH_MAX bytes, at most PACK_DISTANCE_MAX back) for the bytes at window position start; matchLen stays 1 for none.
UNUSED s32 LzPack_PackStream (const u8 *input, u8 *dst, s32 size)
 Packs size bytes of input into dst with a small LZ scheme and returns the packed size.

Macro Definition Documentation

◆ REEL_SPARKS

#define REEL_SPARKS   ((struct EffectStep *)Ram_MapCellBuffer)

The sparks of the jackpot, kept in the map cell buffer.

Definition at line 45 of file colorfx.c.

Referenced by ReelGame_InitTitle(), and ReelGame_Run().

◆ REEL_HEAP_SLOT

#define REEL_HEAP_SLOT   45

The slot machine's own work block (struct ReelWork), beside the battle effect blocks it borrows.

Definition at line 49 of file colorfx.c.

Referenced by ReelGame_InitTitle(), ReelGame_Run(), and ReelGame_RunFrame().

◆ REEL_CANVAS_SIZE

#define REEL_CANVAS_SIZE   (256 * 128)

The paylines' canvas: 256 x 128 pixels of 8-bit colour, shown on BG2 from its tile 212, where the third row of its map begins.

Definition at line 53 of file colorfx.c.

Referenced by ReelGame_Run(), and ReelGame_TransferCanvas().

◆ REEL_CANVAS_TILES

#define REEL_CANVAS_TILES   (BG_CHAR_BLOCK(0) + 0x3500)

Definition at line 54 of file colorfx.c.

Referenced by ReelGame_Run(), and ReelGame_TransferCanvas().

◆ PACK_WINDOW_MASK

#define PACK_WINDOW_MASK   0x3ff

Definition at line 1286 of file colorfx.c.

Referenced by LzPack_ConsumeSlotBytes(), LzPack_FindWindowMatch(), and LzPack_PackStream().

◆ PACK_MATCH_MAX

#define PACK_MATCH_MAX   272

Definition at line 1287 of file colorfx.c.

Referenced by LzPack_FindWindowMatch().

◆ PACK_DISTANCE_MAX

#define PACK_DISTANCE_MAX   63

Definition at line 1288 of file colorfx.c.

Referenced by LzPack_FindWindowMatch().

◆ PACK_LOOKAHEAD

#define PACK_LOOKAHEAD   672

Definition at line 1289 of file colorfx.c.

Referenced by LzPack_PackStream().

Enumeration Type Documentation

◆ ReelGameState

The slot machine's states (ReelWork.state).

Enumerator
REEL_BETTING 

Up and Down change the bet, A spins, B leaves.

REEL_SPINNING 

the reels spin until R or time stops each

REEL_WON 

a payline won: a pause

REEL_SHOWING_WIN 

the win is shown until A

REEL_CHOOSING_HOLDS 

choose reels to hold, or pull the lever

REEL_DONE 

the game ends

REEL_NO_WIN 

no payline won: A to choose holds

REEL_OUT_OF_SPINS 

the fourth spin lost: a pause, then the end

Definition at line 301 of file colorfx.c.

Function Documentation

◆ ReelGame_Start()

s32 ReelGame_Start ( void )

Plays the slot machine: blanks the screen, seeds the random numbers with the play time and runs the game.

Returns 0.

Definition at line 58 of file colorfx.c.

Referenced by ReelGame_Start().

◆ Graphics_ScaleRgb555()

s32 Graphics_ScaleRgb555 ( u16 * src,
u16 * dst,
s32 scale,
s32 count )

Writes count RGB555 colours from src to dst scaled by scale (16.16, 0x10000 keeps them).

Returns 0.

Definition at line 68 of file colorfx.c.

Referenced by Graphics_ScaleRgb555(), and ReelGame_Run().

◆ ReelGame_TransferCanvas()

void ReelGame_TransferCanvas ( void )

A scheduler callback: on a frame whose canvas is ready (transferPending), sends the canvas to its tiles in VRAM (REEL_CANVAS_TILES), then clears it or fades it into trails as transferMode says.

Definition at line 106 of file colorfx.c.

Referenced by ReelGame_Run(), and ReelGame_TransferCanvas().

◆ Palette_DarkenSceneStep()

void Palette_DarkenSceneStep ( void )

Darkens the screen one step: lowers each channel of the 16 colours of BG palette 10 and of OBJ colours 1 to 239 by 1.

Definition at line 139 of file colorfx.c.

Referenced by Palette_DarkenSceneStep(), and ReelGame_Run().

◆ Palette_StepTowardResource()

void Palette_StepTowardResource ( s32 resource)

Moves the first 64 BG colours one step toward the palette of resource; the backdrop colour is not written back.

Definition at line 183 of file colorfx.c.

Referenced by Palette_StepTowardResource(), and ReelGame_Run().

◆ ReelGame_DrawCanvasLine()

void ReelGame_DrawCanvasLine ( s32 x0,
s32 y0,
s32 x1,
s32 y1,
s32 color )

Draws a line from (x0, y0) to (x1, y1) on the 256 x 128 8bpp canvas (32 tiles across), writing only over lower colour numbers.

Definition at line 217 of file colorfx.c.

Referenced by ReelGame_DrawCanvasLine(), and ReelGame_Run().

◆ ReelGame_RunFrame()

void ReelGame_RunFrame ( void )

The slot machine's frame callback: reads the keys, runs the game's state (betting, spinning and stopping the reels, scoring the paylines, choosing reels to hold, showing a win) and builds all 128 sprites: the cursor, the title letters of a win, the frame, the hold lamps, the spin counter, the paylines, the reel symbols, the lever and the bottom bar.

Definition at line 351 of file colorfx.c.

Referenced by ReelGame_Run(), and ReelGame_RunFrame().

◆ ReelGame_InitTitle()

void ReelGame_InitTitle ( void )

Sets up the bouncing title letters of a win, the brightness wave of the screen's lines and the betting window, and starts at betting.

Definition at line 897 of file colorfx.c.

Referenced by ReelGame_InitTitle(), and ReelGame_Run().

◆ ReelGame_Run()

void ReelGame_Run ( void )

The slot machine: loads its backgrounds, sprites and palettes, fills each of the five reels with 21 random symbols (with eight placed symbols of rank 0 to 5), then runs until the player leaves: fading in, drawing the paylines on the canvas while betting or winning, and the jackpot's sparks and colour cycle while showing a win.

Then fades out and frees its memory.

Definition at line 958 of file colorfx.c.

Referenced by ReelGame_Run(), and ReelGame_Start().

◆ LzPack_ResetSlotBuckets()

void LzPack_ResetSlotBuckets ( void )

The LZ packer below: empties its 256 hash chains (one per byte value) and numbers its 1024 window nodes.

Definition at line 1293 of file colorfx.c.

Referenced by LzPack_PackStream(), and LzPack_ResetSlotBuckets().

◆ LzPack_InsertSlotNode()

void LzPack_InsertSlotNode ( s32 index)

Adds window position index to the chain of the byte it holds.

Definition at line 1308 of file colorfx.c.

Referenced by LzPack_ConsumeSlotBytes(), and LzPack_InsertSlotNode().

◆ LzPack_RemoveSlotNode()

void LzPack_RemoveSlotNode ( s32 slot)

Removes window position slot from its chain.

Definition at line 1320 of file colorfx.c.

Referenced by LzPack_ConsumeSlotBytes(), and LzPack_RemoveSlotNode().

◆ LzPack_ConsumeSlotBytes()

void LzPack_ConsumeSlotBytes ( s32 start,
s32 count,
const u8 * input )

Reads count more input bytes into the window from position start, dropping the bytes they replace from their chains; past the end of the input the positions are marked empty (-1).

Definition at line 1332 of file colorfx.c.

Referenced by LzPack_ConsumeSlotBytes(), and LzPack_PackStream().

◆ LzPack_CopyBufferedBytes()

void LzPack_CopyBufferedBytes ( u8 * destination)

Appends the finished group (a flag byte and up to eight items) to the output.

Definition at line 1386 of file colorfx.c.

Referenced by LzPack_CopyBufferedBytes(), and LzPack_PackStream().

◆ LzPack_FindWindowMatch()

__inline__ void LzPack_FindWindowMatch ( s32 start)
static

Finds the longest earlier match (up to PACK_MATCH_MAX bytes, at most PACK_DISTANCE_MAX back) for the bytes at window position start; matchLen stays 1 for none.

Definition at line 1399 of file colorfx.c.

Referenced by LzPack_FindWindowMatch(), and LzPack_PackStream().

◆ LzPack_PackStream()

UNUSED s32 LzPack_PackStream ( const u8 * input,
u8 * dst,
s32 size )

Packs size bytes of input into dst with a small LZ scheme and returns the packed size.

Each group starts with a flag byte, a set bit marking a match: two bytes of distance and length (lengths 2 to 16), or three for lengths up to 272; a match is put off by one byte when the next position matches further. A zero match ends the stream. Nothing in this game calls it.

Definition at line 1460 of file colorfx.c.

Referenced by LzPack_PackStream().