DSC Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
DSC::PaletteManager Class Reference

Automatic palette manager. More...

#include <palette_manager.hpp>

Public Member Functions

 PaletteManager (void *palettes_offset)
 creates a new PaletteManager instance More...
 
int reserve1 (int color)
 choose an index for the specified color More...
 
int reserve16 (const void *palette4)
 loads a 4-bit palette More...
 
void unload1 (int color)
 removes a certain color from the palette More...
 
void unload16 (const void *palette4)
 removes a 4-bit palette More...
 
PaletteAllocationResult try_load (const AssetData *asset)
 Attempts to load colors from asset data palette. More...
 
void unload (const AssetData *asset)
 Unloads colors from a previously loaded asset data palette. More...
 

Detailed Description

Automatic palette manager.

Constructor & Destructor Documentation

◆ PaletteManager()

DSC::PaletteManager::PaletteManager ( void *  palettes_offset)

creates a new PaletteManager instance

Parameters
palettes_offsetthe address of the palette data managed by the instance

Member Function Documentation

◆ reserve1()

int DSC::PaletteManager::reserve1 ( int  color)

choose an index for the specified color

Parameters
colora BGR15 color value
Returns
a value V that tells the palette index it has been placed at.

If the color already exists in the palette, it is not added once again and the position of the already existing color is returned.

◆ reserve16()

int DSC::PaletteManager::reserve16 ( const void *  palette4)

loads a 4-bit palette

Parameters
palette4address to a stream of 16 unsigned shorts represing the BGR15 color codes
Returns
the id of the palette slot assigned to the given 4-bit palette has been, a number from 0 (0x0) to 15 (0xF)

This function does not have the expected effect unless the target palette is a standard palette. Do not load 4-bit palettes in extended slots. They may be loaded, but can't be used in the intended ways.

◆ try_load()

PaletteAllocationResult DSC::PaletteManager::try_load ( const AssetData asset)

Attempts to load colors from asset data palette.

Parameters
assetasset data source
Returns
allocation result information

◆ unload()

void DSC::PaletteManager::unload ( const AssetData asset)

Unloads colors from a previously loaded asset data palette.

Parameters
assetasset data source
Warning
No checks are performed to ensure that the asset's palette has been previously loaded before deallocation happens. Accidentally unloading "unloaded" data may result in possible data loss and corruption.

◆ unload1()

void DSC::PaletteManager::unload1 ( int  color)

removes a certain color from the palette

Parameters
colora BGR15 color value

If the color is being used by more than one asset, it is still kept in the palette even after unloading it. A color is fully released only after no other resources use it. Attempts to unload an inexistent color are simply ignored.

◆ unload16()

void DSC::PaletteManager::unload16 ( const void *  palette4)

removes a 4-bit palette

Parameters
palette4address to a stream of 16 unsigned shorts represing the BGR15 color codes

A 4-bit palette is fully released only after no other resources use it. Attempts to unload an inexistent palette are simply ignored.


The documentation for this class was generated from the following file: