Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
wsgPalette.h File Reference

Detailed Description

Provides palette swap functionality for Swadge.

Author
Jeremy Stintzcum (jerem.nosp@m.y.st.nosp@m.intzc.nosp@m.um@g.nosp@m.mail..nosp@m.com)
Version
1.0.0
Date
2024-09-20

Design Philosophy

Provides functionality to WSGs to use a palette a la the NES. See wsg.h for how these are implemented.

Clones all the current options for drawing WSGs, but all of them require a new parameter, 'palette' which is a array of paletteColor_t objects. The functions largely just intercepts the color given by the WSG and converts it based on the newColor map.

Usage

There are three setup functions:

  • wsgPaletteReset(): Resets the provided palette to draw the default colors
  • wsgPaletteSet(): Provided the palette, a color to overwrite and a new color to use, sets the color
  • wsgPaletteSetGroup(): Does the same as above, but using lists to make generation easier

If wsgPaletteReset() isn't called for the palette being used, all colors not specifically assigned will be black.

There are four drawing functions provided with the palette

Example

// In modeData_t
{
}
// In modeEnter
{
// Palette setup
}
// Where the WSG is drawn
{
drawWsgPalette(&wsg, x, y, &pal, vertFlip, HorFlip, rotation);
}
@ c555
r = 5, g = 5, b = 5
Definition palette.h:239
@ c000
r = 0, g = 0, b = 0
Definition palette.h:24
void wsgPaletteSet(wsgPalette_t *palette, paletteColor_t replacedColor, paletteColor_t newColor)
Sets a single color to the provided palette.
Definition wsgPalette.c:392
void wsgPaletteReset(wsgPalette_t *palette)
Resets the palette to initial state.
Definition wsgPalette.c:376
void drawWsgPalette(const wsg_t *wsg, int16_t xOff, int16_t yOff, wsgPalette_t *palette, bool flipLR, bool flipUD, int16_t rotateDeg)
Draw a WSG to the display utilizing a palette.
Definition wsgPalette.c:37
Definition wsgPalette.h:74

Go to the source code of this file.

Data Structures

struct  wsgPalette_t
 

Functions

void drawWsgPalette (const wsg_t *wsg, int16_t xOff, int16_t yOff, wsgPalette_t *palette, bool flipLR, bool flipUD, int16_t rotateDeg)
 Draw a WSG to the display utilizing a palette.
 
void drawWsgPaletteSimple (const wsg_t *wsg, int16_t xOff, int16_t yOff, wsgPalette_t *palette)
 Draw a WSG to the display without flipping or rotation.
 
void drawWsgPaletteSimpleScaled (const wsg_t *wsg, int16_t xOff, int16_t yOff, wsgPalette_t *palette, int16_t xScale, int16_t yScale)
 Draw a WSG to the display without flipping or rotation.
 
void drawWsgPaletteSimpleHalf (const wsg_t *wsg, int16_t xOff, int16_t yOff, wsgPalette_t *palette)
 Draw a WSG to the display without flipping or rotation at half size.
 
void wsgPaletteReset (wsgPalette_t *palette)
 Resets the palette to initial state.
 
void wsgPaletteSet (wsgPalette_t *palette, paletteColor_t replaced, paletteColor_t newColor)
 Sets a single color to the provided palette.
 
void wsgPaletteSetGroup (wsgPalette_t *palette, paletteColor_t *replacedColors, paletteColor_t *newColors, uint8_t arrSize)
 

Data Structure Documentation

◆ wsgPalette_t

struct wsgPalette_t
Data Fields
paletteColor_t newColors[217] Color map.

Function Documentation

◆ drawWsgPalette()

void drawWsgPalette ( const wsg_t * wsg,
int16_t xOff,
int16_t yOff,
wsgPalette_t * palette,
bool flipLR,
bool flipUD,
int16_t rotateDeg )

Draw a WSG to the display utilizing a palette.

Parameters
wsgThe WSG to draw to the display
xOffThe x offset to draw the WSG at
yOffThe y offset to draw the WSG at
paletteThe new palette used to translate the colors
flipLRtrue to flip the image across the Y axis
flipUDtrue to flip the image across the X axis
rotateDegThe number of degrees to rotate clockwise, must be 0-359

◆ drawWsgPaletteSimple()

void drawWsgPaletteSimple ( const wsg_t * wsg,
int16_t xOff,
int16_t yOff,
wsgPalette_t * palette )

Draw a WSG to the display without flipping or rotation.

Parameters
wsgThe WSG to draw to the display
xOffThe x offset to draw the WSG at
yOffThe y offset to draw the WSG at
paletteColor Map to use

◆ drawWsgPaletteSimpleScaled()

void drawWsgPaletteSimpleScaled ( const wsg_t * wsg,
int16_t xOff,
int16_t yOff,
wsgPalette_t * palette,
int16_t xScale,
int16_t yScale )

Draw a WSG to the display without flipping or rotation.

Parameters
wsgThe WSG to draw to the display
xOffThe x offset to draw the WSG at
yOffThe y offset to draw the WSG at
paletteColor Map to use
xScaleThe amount to scale the image horizontally
yScaleThe amount to scale the image vertically

◆ drawWsgPaletteSimpleHalf()

void drawWsgPaletteSimpleHalf ( const wsg_t * wsg,
int16_t xOff,
int16_t yOff,
wsgPalette_t * palette )

Draw a WSG to the display without flipping or rotation at half size.

Parameters
wsgThe WSG to draw to the display
xOffThe x offset to draw the WSG at
yOffThe y offset to draw the WSG at
paletteColor Map to use

◆ wsgPaletteReset()

void wsgPaletteReset ( wsgPalette_t * palette)

Resets the palette to initial state.

Parameters
paletteColor map to modify

◆ wsgPaletteSet()

void wsgPaletteSet ( wsgPalette_t * palette,
paletteColor_t replacedColor,
paletteColor_t newColor )

Sets a single color to the provided palette.

Parameters
paletteColor map to modify
replacedColorColor to be replaced
newColorColor that will replace the previous

◆ wsgPaletteSetGroup()

void wsgPaletteSetGroup ( wsgPalette_t * palette,
paletteColor_t * replacedColors,
paletteColor_t * newColors,
uint8_t arrSize )