commit e2ff773416e466fef658b96eec91f18e6a31c22c
Author: Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Wed Aug 26 16:34:10 2020 -0600
Commit: jtothebell <j.to.the.bell@gmail.com>
CommitDate: Tue Sep 15 17:09:08 2020 -0600
Add basic test to verify screen palette mapping
---
source/graphics.cpp | 7 ++++++-
source/graphics.h | 3 ++-
test/graphicstests.cpp | 7 +++++--
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/source/graphics.cpp b/source/graphics.cpp
index c5c188d..9d38e23 100644
--- a/source/graphics.cpp
+++ b/source/graphics.cpp
@@ -306,11 +306,16 @@ bool Graphics::isColorTransparent(uint8_t color) {
return _memory->_gfxState_transparencyPalette[color];
}
-uint8_t Graphics::getPalMappedColor(uint8_t color) {
+uint8_t Graphics::getDrawPalMappedColor(uint8_t color) {
color = color & 15;
return _memory->_gfxState_drawPaletteMap[color];
}
+uint8_t Graphics::getScreenPalMappedColor(uint8_t color) {
+ color = color & 15;
+ return _memory->_gfxState_screenPaletteMap[color];
+}
+
bool Graphics::isWithinClip(int x, int y) {
return
x >= _memory->_gfxState_clip_xb &&
diff --git a/source/graphics.h b/source/graphics.h
index cb3de4b..13af099 100644
--- a/source/graphics.h
+++ b/source/graphics.h
@@ -81,7 +81,8 @@ class Graphics {
Color* GetPaletteColors();
bool isColorTransparent(uint8_t color);
- uint8_t getPalMappedColor(uint8_t color);
+ uint8_t getDrawPalMappedColor(uint8_t color);
+ uint8_t getScreenPalMappedColor(uint8_t color);
void cls();
void cls(uint8_t color);
diff --git a/test/graphicstests.cpp b/test/graphicstests.cpp
index a187ef2..31f5bb5 100644
--- a/test/graphicstests.cpp
+++ b/test/graphicstests.cpp
@@ -67,7 +67,7 @@ TEST_CASE("graphics class behaves as expected") {
SUBCASE("Constructor sets default draw color palette") {
//colors mapped to themselves
for (uint8_t c = 0; c < 16; c++) {
- CHECK(graphics->getPalMappedColor(c) == c);
+ CHECK(graphics->getDrawPalMappedColor(c) == c);
}
}
SUBCASE("Constructor sets default draw transparency palette") {
@@ -80,7 +80,10 @@ TEST_CASE("graphics class behaves as expected") {
}
}
SUBCASE("Constructor sets default screen palette") {
-
+ //colors mapped to themselves
+ for (uint8_t c = 0; c < 16; c++) {
+ CHECK(graphics->getScreenPalMappedColor(c) == c);
+ }
}
//check palette maps are set to default values