commit 8b90786fab780b4dfc95240ccd1c905eec80fc9b
Author: Simon Howard <fraggle@soulsphere.org>
AuthorDate: Fri Dec 28 16:27:23 2018 -0500
Commit: Simon Howard <fraggle@soulsphere.org>
CommitDate: Fri Dec 28 16:27:23 2018 -0500
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".
---
textscreen/txt_main.h | 3 +++
textscreen/txt_sdl.c | 11 ++++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/textscreen/txt_main.h b/textscreen/txt_main.h
index 3c98265c..d8cdda1a 100644
--- a/textscreen/txt_main.h
+++ b/textscreen/txt_main.h
@@ -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);
diff --git a/textscreen/txt_sdl.c b/textscreen/txt_sdl.c
index ac563b23..91bdffd9 100644
--- a/textscreen/txt_sdl.c
+++ b/textscreen/txt_sdl.c
@@ -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;