ScummVM API documentation
PaletteManager Class Referenceabstract

#include <paletteman.h>

Inheritance diagram for PaletteManager:
Common::NonCopyable DefaultPaletteManager GraphicsManager N3DS::OSystem_3DS OSystem_Dreamcast OSystem_DS OSystem_N64 OSystem_PSP OSystem_Wii

Public Member Functions

virtual void setPalette (const byte *colors, uint start, uint num)=0
 
void setPalette (const Graphics::Palette &pal, uint start=0)
 
virtual void grabPalette (byte *colors, uint start, uint num) const =0
 
Graphics::Palette grabPalette (uint start, uint num)
 

Detailed Description

The PaletteManager is part of the OSystem backend API and responsible for handling the (possibly emulated) "hardware" palette needed for many old games (e.g. in EGA and VGA mode).

By itself it is a pure abstract class, i.e. an "interface"; you can use the OSystem::getPaletteManager() method to obtain an instance that you can use to perform actual palette modifications.

Member Function Documentation

◆ setPalette()

virtual void PaletteManager::setPalette ( const byte *  colors,
uint  start,
uint  num 
)
pure virtual

Replace the specified range of the palette with new colors. The palette entries from 'start' till (start+num-1) will be replaced - so a full palette update is accomplished via start=0, num=256.

The palette data is specified in interleaved RGB format. That is, the first byte of the memory block 'colors' points at is the red component of the first new color; the second byte the green component of the first new color; the third byte the blue component, the last byte to the alpha (transparency) value. Then the second color starts, and so on. So memory looks like this: R1-G1-B1-R2-G2-B2-R3-...

Parameters
colorsthe new palette data, in interleaved RGB format
startthe first palette entry to be updated
numthe number of palette entries to be updated
Note
It is an error if start+num exceeds 256, behavior is undefined in that case (the backend may ignore it silently or assert).
It is an error if this function gets called when the pixel format in use (the return value of getScreenFormat) has more than one byte per pixel.
See also
getScreenFormat

Implemented in OSystem_Wii, OSystem_N64, N3DS::OSystem_3DS, OpenGL::OpenGLGraphicsManager, LibretroGraphics, OSystem_DS, OSystem_Dreamcast, AndroidGraphics3dManager, OSystem_PSP, SurfaceSdlGraphicsManager, GraphicsManager, AtariGraphicsManager, NullGraphicsManager, and DefaultPaletteManager.

◆ grabPalette()

virtual void PaletteManager::grabPalette ( byte *  colors,
uint  start,
uint  num 
) const
pure virtual

Grabs a specified part of the currently active palette. The format is the same as for setPalette.

This should return exactly the same RGB data as was setup via previous setPalette calls.

For example, for every valid value of start and num of the following code:

byte origPal[num*3]; // Setup origPal's data however you like g_system->setPalette(origPal, start, num); byte obtainedPal[num*3]; g_system->grabPalette(obtainedPal, start, num);

the following should be true:

memcmp(origPal, obtainedPal, num*3) == 0

See also
setPalette
Parameters
colorsthe palette data, in interleaved RGB format
startthe first platte entry to be read
numthe number of palette entries to be read
Note
It is an error if this function gets called when the pixel format in use (the return value of getScreenFormat) has more than one byte per pixel.
See also
getScreenFormat

Implemented in OSystem_Wii, OSystem_N64, N3DS::OSystem_3DS, OpenGL::OpenGLGraphicsManager, LibretroGraphics, OSystem_DS, OSystem_Dreamcast, AndroidGraphics3dManager, OSystem_PSP, SurfaceSdlGraphicsManager, GraphicsManager, AtariGraphicsManager, NullGraphicsManager, and DefaultPaletteManager.


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