foxygit / fake-08-xbox360 Log in
commit 41e64ffb0c006e28a78b0973742e5ac9408ec481
Author:     Jon Bell <jondbell@protonmail.com>
AuthorDate: Sun Apr 26 21:18:54 2020 -0600
Commit:     Jon Bell <jondbell@protonmail.com>
CommitDate: Sun Apr 26 21:18:54 2020 -0600

    Fix changing color of print()
---
 source/graphics.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/source/graphics.cpp b/source/graphics.cpp
index 95411cd..c4909ba 100644
--- a/source/graphics.cpp
+++ b/source/graphics.cpp
@@ -613,6 +613,15 @@ short Graphics::print(std::string str, short x, short y, uint16_t c) {
 	_gfxState_text_x = x;
 	_gfxState_text_y = y;

+	//font sprite sheet has text as color 7, with 0 as transparent. We need to override
+	//these values and restore them after
+	uint8_t prevCol7Map = _gfxState_drawPaletteMap[7];
+	bool prevCol0Transp = _gfxState_transparencyPalette[0];
+
+	_gfxState_drawPaletteMap[7] = c;
+	_gfxState_transparencyPalette[0] = true;
+
+
 	for (size_t n = 0; n < str.length(); n++) {
 		uint8_t ch = str[n];
 		if (ch >= 0x10 && ch < 0x80) {
@@ -629,6 +638,9 @@ short Graphics::print(std::string str, short x, short y, uint16_t c) {
 		}
 	}

+	_gfxState_drawPaletteMap[7] = prevCol7Map;
+	_gfxState_transparencyPalette[0] = prevCol0Transp;
+
 	//todo: auto scrolling

 	return x;