The SGADE Documentation

the SGADE The Socrates Gameboy Advance Development Engine

The SGADE is a development library for the Nintendo Gameboy Advance. It's free for all uses and is distributed without guarantees. For more information visit the SGADE page.


Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

SoPalette

All palette handling. More...

Files

file  SoPalette.c
file  SoPalette.h

Defines

#define SO_SPRITE_PALETTE
 Sprite palette.

#define SO_SCREEN_PALETTE
 Screen palette.

#define SO_SPRITE_PALETTE_0
 Sprite palette 0 (16 color mode).

#define SO_SPRITE_PALETTE_1
 Sprite palette 1 (16 color mode).

#define SO_SPRITE_PALETTE_2
 Sprite palette 2 (16 color mode).

#define SO_SPRITE_PALETTE_3
 Sprite palette 3 (16 color mode).

#define SO_SPRITE_PALETTE_4
 Sprite palette 4 (16 color mode).

#define SO_SPRITE_PALETTE_5
 Sprite palette 5 (16 color mode).

#define SO_SPRITE_PALETTE_6
 Sprite palette 6 (16 color mode).

#define SO_SPRITE_PALETTE_7
 Sprite palette 7 (16 color mode).

#define SO_SPRITE_PALETTE_8
 Sprite palette 8 (16 color mode).

#define SO_SPRITE_PALETTE_9
 Sprite palette 9 (16 color mode).

#define SO_SPRITE_PALETTE_10
 Sprite palette 10 (16 color mode).

#define SO_SPRITE_PALETTE_11
 Sprite palette 11 (16 color mode).

#define SO_SPRITE_PALETTE_12
 Sprite palette 12 (16 color mode).

#define SO_SPRITE_PALETTE_13
 Sprite palette 13 (16 color mode).

#define SO_SPRITE_PALETTE_14
 Sprite palette 14 (16 color mode).

#define SO_SPRITE_PALETTE_15
 Sprite palette 15 (16 color mode).

#define SO_SPRITE_PALETTE_GET(_n_)
 Select the sprite palette n (16 color mode).

#define SO_BKG_PALETTE
 Background palette (same as screen palette).

#define SO_BKG_PALETTE_0
 Background palette 0 (16 color mode).

#define SO_BKG_PALETTE_1
 Background palette 1 (16 color mode).

#define SO_BKG_PALETTE_2
 Background palette 2 (16 color mode).

#define SO_BKG_PALETTE_3
 Background palette 3 (16 color mode).

#define SO_BKG_PALETTE_4
 Background palette 4 (16 color mode).

#define SO_BKG_PALETTE_5
 Background palette 5 (16 color mode).

#define SO_BKG_PALETTE_6
 Background palette 6 (16 color mode).

#define SO_BKG_PALETTE_7
 Background palette 7 (16 color mode).

#define SO_BKG_PALETTE_8
 Background palette 8 (16 color mode).

#define SO_BKG_PALETTE_9
 Background palette 9 (16 color mode).

#define SO_BKG_PALETTE_10
 Background palette 10 (16 color mode).

#define SO_BKG_PALETTE_11
 Background palette 11 (16 color mode).

#define SO_BKG_PALETTE_12
 Background palette 12 (16 color mode).

#define SO_BKG_PALETTE_13
 Background palette 13 (16 color mode).

#define SO_BKG_PALETTE_14
 Background palette 14 (16 color mode).

#define SO_BKG_PALETTE_15
 Background palette 15 (16 color mode).

#define SO_BKG_PALETTE_GET(_n_)
 Select the background palette n (16 color mode).

#define SoColor(r, g, b)
 construct 15-bit BGR color value

#define SoColorGetRed(rgb)
 Extract 5-bit red component of color value.

#define SoColorGetGreen(rgb)
 Extract 5-bit green component of color value.

#define SoColorGetBlue(rgb)
 Extract 5-bit blue component of color value.


Functions

void SoPaletteSetColor (u16 *a_This, u32 a_PalIndex, u32 a_16BitColor)
 Sets an individual color into the given palette.

void SoPaletteSetBlack (u16 *a_This, bool a_256ColorPalette)
 Makes the entire palette fully black (every color equals zero).

void SoPaletteSetGreyScale (u16 *a_This, bool a_256ColorPalette)
 Greyscales the palette.

void SoPaletteSetRandom (u16 *a_This, bool a_256ColorPalette)
 Just throws random colors in the palette;.

void SoPaletteSetPalette (u16 *a_This, const u16 *a_Palette, bool a_256ColorPalette)
 Copies an entire palette into another one.

void SoPaletteFadeGreyScale (u16 *a_This, u32 a_Fade, bool a_256ColorPalette)
 Makes the pallette a faded greyscale palette;.

void SoPaletteFadePalette (u16 *a_This, const u16 *a_Palette, u32 a_Fade, bool a_256ColorPalette)
 Makes the pallette a faded version of another palette.

void SoPaletteAddToPalette (u16 *a_This, u32 a_Red, u32 a_Green, u32 a_Blue, bool a_256ColorPalette)
 Saturated addition to each color of the given palette.

void SoPaletteSubtractFromPalette (u16 *a_This, u32 a_Red, u32 a_Green, u32 a_Blue, bool a_256ColorPalette)
 Saturated subtraction from each color of the given palette.


Detailed Description

All palette handling.

This module takes care of everything that has to do with palettes.

A palette is just an array of 15 bit BGR color values, each in a 16 bit word. So we're just using u16*'s for palettes.

A palette contains either 16 or 256 colors. This information is not stored inside the palette. Most of the time you know it when using it anyway.

Because a palette is already a pointer in itself, we can directly use the SoPalette object as a this pointer.

You can use the SoPaletteConverter.exe tool in the /tools/ directory to convert Jasc palettes to a Socrates compatible header file. Ready to be included in a socrates project.


Function Documentation

void SoPaletteAddToPalette u16   a_This,
u32    a_Red,
u32    a_Green,
u32    a_Blue,
bool    a_256ColorPalette
 

Saturated addition to each color of the given palette.

Parameters:
a_This  Palette you want to add values to.
a_Red  Value you want to add to red (0 to 31).
a_Green  Value you want to add to green (0 to 31).
a_Blue  Value you want to add to blue (0 to 31).
a_256ColorPalette  True if there are 256 colors in the given palettes, false if there are 16.
Does a saturated addition to each color in the palette. This means that if a color component has reached its maximum value (31), it no longer increases.

void SoPaletteFadeGreyScale u16   a_This,
u32    a_Fade,
bool    a_256ColorPalette
 

Makes the pallette a faded greyscale palette;.

Parameters:
a_This  Palette you want to fade;
a_Fade  Value you want to fade with. Anything in between 0 and (SO_FADE_MAX-1).
a_256ColorPalette  True if there are 256 colors in the given palettes, false if there are 16.
If the fade value equals zero then the entire palette will become black, if the fade value equals (SO_FADE_MAX - 1) then this function does the same as SoPaletteSetGreyScale, namely just making it a greyscale palette. If the fade value is something in between, the greyscale values are scaled accordingly.

void SoPaletteFadePalette u16   a_This,
const u16   a_Palette,
u32    a_Fade,
bool    a_256ColorPalette
 

Makes the pallette a faded version of another palette.

Parameters:
a_This  Palette you want to fade
a_Palette  Source palette
a_Fade  Value you want to fade with. Anything in between 0 and (SO_FADE_MAX-1).
a_256ColorPalette  True if there are 256 colors in the given palettes, false if there are 16.
If the fade value equals zero then the entire palette will become black, if the fade value equals (SO_FADE_MAX - 1) then this function does the same as SoPaletteSetPalette, namely just making it the same as the source palette. If the fade value is something in between, the color values are scaled accordingly.

void SoPaletteSetBlack u16   a_This,
bool    a_256ColorPalette
 

Makes the entire palette fully black (every color equals zero).

Parameters:
a_This  Palette you want to blacken.
a_256ColorPalette  True if there are 256 colors in the given palette, false if there are 16.

void SoPaletteSetColor u16   a_This,
u32    a_PalIndex,
u32    a_16BitColor
 

Sets an individual color into the given palette.

Parameters:
a_This  Palette you want to set the color for;
a_PalIndex  Index into the palette.
a_16BitColor  New color in 15 bit BGR format, for the given index;

void SoPaletteSetGreyScale u16   a_This,
bool    a_256ColorPalette
 

Greyscales the palette.

Parameters:
a_This  Makes a greyscale palette of the given palette;
a_256ColorPalette  True if there are 256 colors in the given palette, false if there are 16.

void SoPaletteSetPalette u16   a_This,
const u16   a_Palette,
bool    a_256ColorPalette
 

Copies an entire palette into another one.

Parameters:
a_This  Palette you want to set
a_Palette  Palette that is the source
a_256ColorPalette  True if there are 256 colors in the given palettes, false if there are 16.

void SoPaletteSetRandom u16   a_This,
bool    a_256ColorPalette
 

Just throws random colors in the palette;.

Parameters:
a_This  Palette you want to subtract values from.
a_256ColorPalette  True if there are 256 colors in the given palettes, false if there are 16.
Keeps black as the zero color, and white as the 255th or 16th color though. Also, tries to avoid darkish colors. So it's not truly random... :). But it suits my purposes.

void SoPaletteSubtractFromPalette u16   a_This,
u32    a_Red,
u32    a_Green,
u32    a_Blue,
bool    a_256ColorPalette
 

Saturated subtraction from each color of the given palette.

Parameters:
a_This  Palette you want to subtract values from.
a_Red  Value you want to subtract from red (0 to 31).
a_Green  Value you want to subtract from green (0 to 31).
a_Blue  Value you want to subtract from blue (0 to 31).
a_256ColorPalette  True if there are 256 colors in the given palettes, false if there are 16.
Does a saturated subtraction from each color in the palette. This means that if a color component has reached its minimum value (31), it no longer decreases.


Copyright 2002 by the SGADE authors. See SoLicense.h or Visit the SGADE page for more information.