all repos — mgba @ 1c6fc26bf704a8a23ed9df2b92be0babb24887bf

mGBA Game Boy Advance Emulator

Support hflip on mode 0 edges
Jeffrey Pfau jeffrey@endrift.com
Thu, 02 May 2013 21:51:00 -0700
commit

1c6fc26bf704a8a23ed9df2b92be0babb24887bf

parent

ebb1c08840aba9166becb55bab9a83ce8b7e2060

1 files changed, 37 insertions(+), 11 deletions(-)

jump to
M src/gba/renderers/video-software.csrc/gba/renderers/video-software.c

@@ -540,15 +540,28 @@ int end = 0x8 - (inX & 0x7);

uint32_t tileData; BACKGROUND_TEXT_SELECT_CHARACTER; charBase = ((background->charBase + (mapData.tile << 5)) >> 2) + localY; + tileData = ((uint32_t*)renderer->d.vram)[charBase]; - tileData >>= 4 * (inX & 0x7); - if (!variant) { - for (outX = 0; outX < end; ++outX) { - BACKGROUND_DRAW_PIXEL_16_NORMAL; + if (!mapData.hflip) { + tileData >>= 4 * (inX & 0x7); + if (!variant) { + for (outX = 0; outX < end; ++outX) { + BACKGROUND_DRAW_PIXEL_16_NORMAL; + } + } else { + for (outX = 0; outX < end; ++outX) { + BACKGROUND_DRAW_PIXEL_16_VARIANT; + } } } else { - for (outX = 0; outX < end; ++outX) { - BACKGROUND_DRAW_PIXEL_16_VARIANT; + if (!variant) { + for (outX = end; outX--;) { + BACKGROUND_DRAW_PIXEL_16_NORMAL; + } + } else { + for (outX = end; outX--;) { + BACKGROUND_DRAW_PIXEL_16_VARIANT; + } } }

@@ -556,13 +569,26 @@ tileX = 30;

BACKGROUND_TEXT_SELECT_CHARACTER; charBase = ((background->charBase + (mapData.tile << 5)) >> 2) + localY; tileData = ((uint32_t*)renderer->d.vram)[charBase]; - if (!variant) { - for (outX = VIDEO_HORIZONTAL_PIXELS - 8 + end; outX < VIDEO_HORIZONTAL_PIXELS; ++outX) { - BACKGROUND_DRAW_PIXEL_16_NORMAL; + if (!mapData.hflip) { + if (!variant) { + for (outX = VIDEO_HORIZONTAL_PIXELS - 8 + end; outX < VIDEO_HORIZONTAL_PIXELS; ++outX) { + BACKGROUND_DRAW_PIXEL_16_NORMAL; + } + } else { + for (outX = VIDEO_HORIZONTAL_PIXELS - 8 + end; outX < VIDEO_HORIZONTAL_PIXELS; ++outX) { + BACKGROUND_DRAW_PIXEL_16_VARIANT; + } } } else { - for (outX = VIDEO_HORIZONTAL_PIXELS - 8 + end; outX < VIDEO_HORIZONTAL_PIXELS; ++outX) { - BACKGROUND_DRAW_PIXEL_16_VARIANT; + tileData >>= 4 * end; + if (!variant) { + for (outX = VIDEO_HORIZONTAL_PIXELS - 1; outX > VIDEO_HORIZONTAL_PIXELS - 8; --outX) { + BACKGROUND_DRAW_PIXEL_16_NORMAL; + } + } else { + for (outX = VIDEO_HORIZONTAL_PIXELS - 1; outX > VIDEO_HORIZONTAL_PIXELS - 8; --outX) { + BACKGROUND_DRAW_PIXEL_16_VARIANT; + } } }