commit 2769c46681a95ffc06c5b77f68041b17cfc3309f
Author: Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Sat Mar 6 19:20:41 2021 -0700
Commit: Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Sat Mar 6 19:20:41 2021 -0700
handle negative sspr screen dimensions
---
source/graphics.cpp | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/source/graphics.cpp b/source/graphics.cpp
index 2b1a47a..3182d44 100644
--- a/source/graphics.cpp
+++ b/source/graphics.cpp
@@ -199,6 +199,9 @@ void Graphics::copyStretchSpriteToScreen(
bool flip_x,
bool flip_y)
{
+ if (scr_w == 0 || scr_h == 0)
+ return;
+
if (spr_h == scr_h && spr_w == scr_w) {
// use faster non stretch blitter if sprite is not stretched
copySpriteToScreen(spritebuffer, scr_x, scr_y, spr_x, spr_y, scr_w, scr_h, flip_x, flip_y);
@@ -207,6 +210,17 @@ void Graphics::copyStretchSpriteToScreen(
applyCameraToPoint(&scr_x, &scr_y);
+ if (scr_w < 0){
+ flip_x = !flip_x;
+ scr_w = -scr_w;
+ scr_x -= scr_w;
+ }
+ if (scr_h < 0) {
+ flip_y = !flip_y;
+ scr_h = -scr_h;
+ scr_y -= scr_h;
+ }
+
//shift bits to avoid floating point math
spr_x = spr_x << 16;
spr_y = spr_y << 16;