foxygit / fake-08-xbox360 Log in
commit 76a6c08bc3cb8f437d8bc81d4afe95cb2341940f
Author:     Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Mon Jan 16 19:10:26 2023 -0700
Commit:     Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Mon Jan 16 19:10:26 2023 -0700

    add support for solid bg text render mode
---
 source/graphics.cpp       | 11 +++++++----
 test/printHelperTests.cpp | 15 +++++++++++++++
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/source/graphics.cpp b/source/graphics.cpp
index b032c2b..cdf8cc2 100644
--- a/source/graphics.cpp
+++ b/source/graphics.cpp
@@ -1425,7 +1425,7 @@ std::tuple<int, int> Graphics::drawCharacterFromBytes(
 	//TODO: character modes
 	bool evenPxOnly = false;
 	bool invertColors = false;
-	//bool solidBg = false;
+	bool solidBg = false;

 	if ((printMode & PRINT_MODE_ON) == PRINT_MODE_ON){
 		if ((printMode & PRINT_MODE_WIDE) == PRINT_MODE_WIDE) {
@@ -1443,9 +1443,9 @@ std::tuple<int, int> Graphics::drawCharacterFromBytes(
 		if((printMode & PRINT_MODE_INVERTED) == PRINT_MODE_INVERTED) {
 			invertColors = true;
 		}
-		//if((printMode & PRINT_MODE_SOLID_BG) == PRINT_MODE_SOLID_BG) {
-		//	solidBg = true;
-		//}
+		if((printMode & PRINT_MODE_SOLID_BG) == PRINT_MODE_SOLID_BG) {
+			solidBg = true;
+		}
 		//TODO: other print modes
 	}

@@ -1473,6 +1473,9 @@ std::tuple<int, int> Graphics::drawCharacterFromBytes(
 			if (on && isWithinClip(absDestX, absDestY)) {
 				setPixelNibble(absDestX, absDestY, fgColor, screenBuffer);
 			}
+			if(!on && solidBg && isWithinClip(absDestX, absDestY)) {
+				setPixelNibble(absDestX, absDestY, bgColor, screenBuffer);
+			}
 		}
 	}

diff --git a/test/printHelperTests.cpp b/test/printHelperTests.cpp
index e9d8944..e4c9194 100644
--- a/test/printHelperTests.cpp
+++ b/test/printHelperTests.cpp
@@ -818,6 +818,21 @@ TEST_CASE("Print helper functions") {

         checkPoints(graphics, expectedPoints);
     }
+    SUBCASE("p8scii special control code for solid background(\\^#) ") {
+        graphics->cls(2);
+
+        print("\x06""#:", 0, 0);
+
+        std::vector<coloredPoint> expectedPoints = {
+            {0, 0, 0}, {1, 0, 0}, {2, 0, 0},
+            {0, 1, 0}, {1, 1, 6}, {2, 1, 0},
+            {0, 2, 0}, {1, 2, 0}, {2, 2, 0},
+            {0, 3, 0}, {1, 3, 6}, {2, 3, 0},
+            {0, 4, 0}, {1, 4, 0}, {2, 4, 0},
+        };
+
+        checkPoints(graphics, expectedPoints);
+    }


     delete stubHost;