foxygit / fake-08-xbox360 Log in
commit 03b0de6f68899aa394e762054272570eb65627a2
Author:     Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Mon Sep 15 20:34:38 2025 -0600
Commit:     Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Mon Sep 15 20:34:38 2025 -0600

    basic underline p8scii support
---
 source/printHelper.cpp    |  7 +++++++
 test/printHelperTests.cpp | 17 +++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/source/printHelper.cpp b/source/printHelper.cpp
index 42822d7..a80befe 100644
--- a/source/printHelper.cpp
+++ b/source/printHelper.cpp
@@ -151,6 +151,7 @@ int print(std::string str, int x, int y, uint8_t c) {
     bool cancelWrap = false;
     uint8_t outlineColor = 0;
     uint8_t outlineNeighbors = 0;
+    bool underline = false;

     uint8_t printMode = _ph_mem->hwState.printAttributes;

@@ -424,6 +425,9 @@ int print(std::string str, int x, int y, uint8_t c) {
                 std::string neighborsHexStr = str.substr(n+1, 2);
                 n+=2;
                 outlineNeighbors = (uint8_t)strtol(neighborsHexStr.c_str(), NULL, 16);
+            }
+            else if (commandChar == 'u'){
+                underline = true;
             }
 		}
 		else if (ch == 7) { // "\a" audio command
@@ -518,6 +522,9 @@ int print(std::string str, int x, int y, uint8_t c) {
                             forceCharHeight);
                     }
                 }
+            }
+            if (underline) {
+                _ph_graphics->rectfill(x-1, y + lineHeight, x + charWidth - 1, y + lineHeight, fgColor);
             }
 			x += charWidth + _ph_graphics->drawCharacter(
                 ch,
diff --git a/test/printHelperTests.cpp b/test/printHelperTests.cpp
index 6c69123..ceac1b4 100644
--- a/test/printHelperTests.cpp
+++ b/test/printHelperTests.cpp
@@ -864,6 +864,23 @@ TEST_CASE("Print helper functions") {

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

     delete stubHost;
     delete graphics;