foxygit / fake-08-xbox360 Log in
commit 92c1310e5345635d0585fc529598e8a48167ce36
Author:     Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Thu Apr 7 17:36:12 2022 -0600
Commit:     Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Thu Apr 7 17:36:12 2022 -0600

    Honor print mode defaults poked into memory
---
 source/printHelper.cpp    |  7 ++++++-
 test/printHelperTests.cpp | 40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/source/printHelper.cpp b/source/printHelper.cpp
index d1131ab..7341935 100644
--- a/source/printHelper.cpp
+++ b/source/printHelper.cpp
@@ -85,7 +85,12 @@ int print(std::string str, int x, int y, uint8_t c) {
     int charWidth = 4;
     int charHeight = 6;
     int lineHeight = 6;
-    uint8_t printMode = 0;
+
+    uint8_t printMode = _ph_mem->hwState.printAttributes;
+
+    if ((printMode & 0x1) == 0) {
+        printMode = 0;
+    }

 	uint8_t effectiveC = _ph_graphics->getDrawPalMappedColor(c);

diff --git a/test/printHelperTests.cpp b/test/printHelperTests.cpp
index 9f7c41e..d5fdbc0 100644
--- a/test/printHelperTests.cpp
+++ b/test/printHelperTests.cpp
@@ -535,6 +535,46 @@ TEST_CASE("Print helper functions") {

         checkPoints(graphics, expectedPoints);
     }
+    SUBCASE("Poke default print mode but not turned on") {
+        graphics->cls();
+
+        //not turned on
+        //                   wide  tall  dotty/stripey
+        vm->vm_poke(0x5f58, (0x4 | 0x8 | 0x40));
+        print(":", 0, 0);
+
+        std::vector<coloredPoint> expectedPoints = {
+            {1, 0, 0},
+            {1, 1, 6},
+            {1, 2, 0},
+            {1, 3, 6},
+            {1, 4, 0},
+        };
+
+        checkPoints(graphics, expectedPoints);
+    }
+    SUBCASE("Poke default print mode (pinball)") {
+        graphics->cls();
+
+        //                  on    wide  tall  dotty/stripey
+        vm->vm_poke(0x5f58, (0x1 | 0x4 | 0x8 | 0x40));
+        print(":", 0, 0);
+
+        std::vector<coloredPoint> expectedPoints = {
+            {2, 0, 0}, {3, 0, 0},
+            {2, 1, 0}, {3, 1, 0},
+            {2, 2, 6}, {3, 2, 0},
+            {2, 3, 0}, {3, 3, 0},
+            {2, 4, 0}, {3, 4, 0},
+            {2, 5, 0}, {3, 5, 0},
+            {2, 6, 6}, {3, 6, 0},
+            {2, 7, 0}, {3, 7, 0},
+            {2, 8, 0}, {3, 8, 0},
+            {2, 9, 0}, {3, 9, 0}
+        };
+
+        checkPoints(graphics, expectedPoints);
+    }


     delete stubHost;