commit 1a085944efca0d351c3763a101a78faacd3cae67
Author: Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Tue Aug 16 21:53:06 2022 -0600
Commit: Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Tue Aug 16 21:53:06 2022 -0600
Fix drawing upper half of sprite sheet with sspr
---
source/graphics.cpp | 4 ++--
test/graphicstests.cpp | 28 +++++++++++++++++++++++++++-
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/source/graphics.cpp b/source/graphics.cpp
index a194331..6025e3e 100644
--- a/source/graphics.cpp
+++ b/source/graphics.cpp
@@ -302,7 +302,7 @@ void Graphics::copyStretchSpriteToScreen(
if (hwState.colorBitmask == 0xff){
for (int y = 0; y < scr_h; y++) {
int sprY = ((spr_y + y * dy) >> 16);
- if (sprY > 63) {
+ if (sprY > 127) {
continue;
}
uint8_t* spr = spritebuffer + (sprY * 64);
@@ -362,7 +362,7 @@ void Graphics::copyStretchSpriteToScreen(
else {
for (int y = 0; y < scr_h; y++) {
int sprY = ((spr_y + y * dy) >> 16);
- if (sprY > 63) {
+ if (sprY > 127) {
continue;
}
uint8_t* spr = spritebuffer + (sprY) * 64;
diff --git a/test/graphicstests.cpp b/test/graphicstests.cpp
index 8f5de3b..01fd17b 100644
--- a/test/graphicstests.cpp
+++ b/test/graphicstests.cpp
@@ -933,7 +933,6 @@ TEST_CASE("graphics class behaves as expected") {
{102, 51, 5},
{102, 52, 5},
{102, 53, 5},
-
};
checkPoints(graphics, expectedPoints);
@@ -989,6 +988,33 @@ TEST_CASE("graphics class behaves as expected") {
checkPoints(graphics, expectedPoints);
}
+ SUBCASE("sspr(...) draws last sprite (sprite 255)") {
+ graphics->cls();
+ for(int y = 0; y < 128; y++) {
+ for(int x = 0; x < 128; x++) {
+ graphics->sset(x, y, (x+y)%15+1);
+ }
+ }
+
+ graphics->sspr(120, 120, 3, 4, 100, 50, 6, 8, false, false);
+
+ std::vector<coloredPoint> expectedPoints = {
+ {100, 50, 1},
+ {100, 51, 1},
+ {100, 52, 2},
+ {100, 53, 2},
+ {101, 50, 1},
+ {101, 51, 1},
+ {101, 52, 2},
+ {101, 53, 2},
+ {102, 50, 2},
+ {102, 51, 2},
+ {102, 52, 3},
+ {102, 53, 3},
+ };
+
+ checkPoints(graphics, expectedPoints);
+ }
/*//TODO: come back and make SSPR stretch exactly how pico 8 does
SUBCASE("sspr(...) draws unevenly stretched sprite") {
graphics->cls();