textscreen: Add API to change color palette.

This is possible under DOS as well by writing to the appropriate VGA
registers, and the vanilla setup tool actually does this in earlier
versions to set "Romero Blue".
This commit is contained in:
Simon Howard 2018-12-28 16:27:23 -05:00
parent 12c984cff8
commit 8b90786fab
2 changed files with 13 additions and 1 deletions

View file

@ -149,6 +149,9 @@ void TXT_UpdateScreenArea(int x, int y, int w, int h);
// Update the whole screen
void TXT_UpdateScreen(void);
// Set the RGB value for a particular entry in the color palette:
void TXT_SetColor(txt_color_t color, int r, int g, int b);
// Read a character from the keyboard
int TXT_GetChar(void);

View file

@ -85,7 +85,7 @@ static const struct {
// Unicode key mapping; see codepage.h.
static const short code_page_to_unicode[] = CODE_PAGE_TO_UNICODE;
static SDL_Color ega_colors[] =
static const SDL_Color ega_colors[] =
{
{0x00, 0x00, 0x00, 0xff}, // 0: Black
{0x00, 0x00, 0xa8, 0xff}, // 1: Blue
@ -308,6 +308,15 @@ void TXT_Shutdown(void)
SDL_QuitSubSystem(SDL_INIT_VIDEO);
}
void TXT_SetColor(txt_color_t color, int r, int g, int b)
{
SDL_Color c = {r, g, b, 0xff};
SDL_LockSurface(screenbuffer);
SDL_SetPaletteColors(screenbuffer->format->palette, &c, color, 1);
SDL_UnlockSurface(screenbuffer);
}
unsigned char *TXT_GetScreenData(void)
{
return screendata;