all repos — mgba @ c7f85f7b7e36e8241b48dd13800201a1380a2958

mGBA Game Boy Advance Emulator

GBA Video: Fix more merge regressions
Vicki Pfau vi@endrift.com
Thu, 16 Jul 2020 23:42:49 -0700
commit

c7f85f7b7e36e8241b48dd13800201a1380a2958

parent

9fd6a5bf7b94d2153243ace8c30d7bee9cab9d8b

1 files changed, 67 insertions(+), 61 deletions(-)

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

@@ -21,15 +21,17 @@ paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \

palette = &mainPalette[paletteData]; \ charBase = (background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 5)) + (localY << 2); \ vram = renderer->d.vramBG[charBase >> VRAM_BLOCK_OFFSET]; \ - LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ - if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ - tileData >>= 4 * mod8; \ - for (; outX < end; ++outX) { \ - BACKGROUND_DRAW_PIXEL_16(BLEND, OBJWIN, 0); \ - } \ - } else { \ - for (outX = end - 1; outX >= renderer->start; --outX) { \ - BACKGROUND_DRAW_PIXEL_16(BLEND, OBJWIN, 0); \ + if (LIKELY(vram)) { \ + LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ + if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ + tileData >>= 4 * mod8; \ + for (; outX < end; ++outX) { \ + BACKGROUND_DRAW_PIXEL_16(BLEND, OBJWIN, 0); \ + } \ + } else { \ + for (outX = end - 1; outX >= renderer->start; --outX) { \ + BACKGROUND_DRAW_PIXEL_16(BLEND, OBJWIN, 0); \ + } \ } \ }

@@ -189,37 +191,39 @@

#define DRAW_BACKGROUND_MODE_0_TILE_SUFFIX_256(BLEND, OBJWIN) \ charBase = (background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 6)) + (localY << 3); \ vram = renderer->d.vramBG[charBase >> VRAM_BLOCK_OFFSET]; \ - int end2 = end - 4; \ - if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ - int shift = inX & 0x3; \ - if (end2 > outX) { \ - LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ + if (LIKELY(vram)) { \ + int end2 = end - 4; \ + if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ + int shift = inX & 0x3; \ + if (end2 > outX) { \ + LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ + tileData >>= 8 * shift; \ + shift = 0; \ + for (; outX < end2; ++outX) { \ + BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN, 0); \ + } \ + } \ + \ + LOAD_32(tileData, (charBase + 4) & VRAM_BLOCK_MASK, vram); \ tileData >>= 8 * shift; \ - shift = 0; \ - for (; outX < end2; ++outX) { \ + for (; outX < end; ++outX) { \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN, 0); \ } \ - } \ - \ - LOAD_32(tileData, (charBase + 4) & VRAM_BLOCK_MASK, vram); \ - tileData >>= 8 * shift; \ - for (; outX < end; ++outX) { \ - BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN, 0); \ - } \ - } else { \ - int start = outX; \ - outX = end - 1; \ - if (end2 > start) { \ + } else { \ + int start = outX; \ + outX = end - 1; \ + if (end2 > start) { \ + LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ + for (; outX >= end2; --outX) { \ + BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN, 0); \ + } \ + charBase += 4; \ + } \ + \ LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ - for (; outX >= end2; --outX) { \ + for (; outX >= renderer->start; --outX) { \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN, 0); \ } \ - charBase += 4; \ - } \ - \ - LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ - for (; outX >= renderer->start; --outX) { \ - BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN, 0); \ } \ }

@@ -412,39 +416,41 @@

#define DRAW_BACKGROUND_MODE_0_TILE_SUFFIX_256EXT(BLEND, OBJWIN) \ charBase = (background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 6)) + (localY << 3); \ vram = renderer->d.vramBG[charBase >> VRAM_BLOCK_OFFSET]; \ - int end2 = end - 4; \ - paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 8; \ - palette = &mainPalette[paletteData]; \ - if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ - int shift = inX & 0x3; \ - if (end2 > outX) { \ - LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ + if (LIKELY(vram)) { \ + int end2 = end - 4; \ + paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 8; \ + palette = &mainPalette[paletteData]; \ + if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ + int shift = inX & 0x3; \ + if (end2 > outX) { \ + LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ + tileData >>= 8 * shift; \ + shift = 0; \ + for (; outX < end2; ++outX) { \ + BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN, 0); \ + } \ + } \ + \ + LOAD_32(tileData, (charBase + 4) & VRAM_BLOCK_MASK, vram); \ tileData >>= 8 * shift; \ - shift = 0; \ - for (; outX < end2; ++outX) { \ + for (; outX < end; ++outX) { \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN, 0); \ } \ - } \ - \ - LOAD_32(tileData, (charBase + 4) & VRAM_BLOCK_MASK, vram); \ - tileData >>= 8 * shift; \ - for (; outX < end; ++outX) { \ - BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN, 0); \ - } \ - } else { \ - int start = outX; \ - outX = end - 1; \ - if (end2 > start) { \ + } else { \ + int start = outX; \ + outX = end - 1; \ + if (end2 > start) { \ + LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ + for (; outX >= end2; --outX) { \ + BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN, 0); \ + } \ + charBase += 4; \ + } \ + \ LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ - for (; outX >= end2; --outX) { \ + for (; outX >= renderer->start; --outX) { \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN, 0); \ } \ - charBase += 4; \ - } \ - \ - LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ - for (; outX >= renderer->start; --outX) { \ - BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN, 0); \ } \ }