From e40ee1d7a66f6220ffa2ab8dc027ac58bb37c600 Mon Sep 17 00:00:00 2001 From: "Adrian.Conlon" Date: Fri, 15 Sep 2017 17:48:06 +0100 Subject: [PATCH] X/Y sprite flip implemented. Easy! Signed-off-by: Adrian.Conlon --- LR35902/src/Display.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/LR35902/src/Display.cpp b/LR35902/src/Display.cpp index bdc9d4e..9d46cc6 100644 --- a/LR35902/src/Display.cpp +++ b/LR35902/src/Display.cpp @@ -67,19 +67,21 @@ void EightBit::GameBoy::Display::renderObjects(int objBlockHeight) { const auto spriteX = current.positionX(); const auto spriteY = current.positionY(); const auto& palette = palettes[current.palette()]; + const auto flipX = current.flipX(); + const auto flipY = current.flipY(); - // TODO: x/y flip for (int cy = 0; cy < 8; ++cy) { + + uint8_t y = spriteY + (flipY ? 7 - cy : cy); + if (y >= RasterHeight) + break; + for (int cx = 0; cx < 8; ++cx) { - uint8_t x = spriteX + cx; + uint8_t x = spriteX + (flipX ? 7 - cx : cx); if (x >= RasterWidth) break; - uint8_t y = spriteX + cy; - if (y >= RasterHeight) - break; - auto outputPixel = y * RasterWidth + x; auto colour = definition.get()[cy * 8 + cx];