X/Y sprite flip implemented. Easy!

Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian.Conlon 2017-09-15 17:48:06 +01:00
parent 94fe1a7494
commit e40ee1d7a6

View File

@ -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];