all repos — mgba @ de55e441520f1678864c7fe9d1936a013b096a65

mGBA Game Boy Advance Emulator

DS Video: Simplify VRAM mapping
Vicki Pfau vi@endrift.com
Sun, 16 Jul 2017 15:58:49 -0700
commit

de55e441520f1678864c7fe9d1936a013b096a65

parent

f80bcfaf5dc3847aa17281906ce52f33fa01953c

5 files changed, 148 insertions(+), 180 deletions(-)

jump to
M CHANGESCHANGES

@@ -7,6 +7,7 @@ - DS GX: Automatically normalize winding culling calculations (fixes mgba.io/i/699)

Misc: - DS GX: Clean up and unify texture mapping - DS Core: Add symbol loading + - DS Video: Simplify VRAM mapping 0.7.0: (Future) Features:
M src/ds/renderers/software.csrc/ds/renderers/software.c

@@ -699,9 +699,6 @@ localX = 0x7FF - localX; \

} \ uint32_t charBase = (background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 6)) + ((localY & 0x700) >> 5) + ((localX & 0x700) >> 8); \ uint16_t* vram = renderer->d.vramBG[charBase >> VRAM_BLOCK_OFFSET]; \ - if (UNLIKELY(!vram)) { \ - continue; \ - } \ pixelData = ((uint8_t*) vram)[charBase & VRAM_BLOCK_MASK]; #define EXT_0_MOSAIC(COORD, PAL) \

@@ -839,9 +836,6 @@

if (!mosaicWait) { uint32_t address = (localX >> 8) + (localY >> 8) * width + screenBase; uint8_t* vram = (uint8_t*) renderer->d.vramBG[address >> VRAM_BLOCK_OFFSET]; - if (UNLIKELY(!vram)) { - continue; - } color = vram[address & VRAM_BLOCK_MASK]; mosaicWait = mosaicH; } else {

@@ -896,9 +890,6 @@

if (!mosaicWait) { uint32_t address = ((localX >> 8) + (localY >> 8) * width + screenBase) << 1; uint16_t* vram = renderer->d.vramBG[address >> VRAM_BLOCK_OFFSET]; - if (UNLIKELY(!vram)) { - continue; - } LOAD_16(color, address & VRAM_BLOCK_MASK, vram); #ifndef COLOR_16_BIT unsigned color32;
M src/ds/video.csrc/ds/video.c

@@ -45,6 +45,8 @@ 0x08000,

0x04000 }; +static uint16_t _zeroes[0x2000] = {}; + enum DSVRAMBankMode { MODE_A_BG = 0, MODE_B_BG = 1,

@@ -185,6 +187,20 @@ video->p->memory.vramBank[5] = &video->vram[0x48000];

video->p->memory.vramBank[6] = &video->vram[0x4A000]; video->p->memory.vramBank[7] = &video->vram[0x4C000]; video->p->memory.vramBank[8] = &video->vram[0x50000]; + + int i; + for (i = 0; i < 32; ++i) { + video->renderer->vramABG[i] = _zeroes; + video->renderer->vramBBG[i] = _zeroes; + video->renderer->vramAOBJ[i] = _zeroes; + video->renderer->vramBOBJ[i] = _zeroes; + } + for (i = 0; i < 4; ++i) { + video->renderer->vramABGExtPal[i] = NULL; + video->renderer->vramBBGExtPal[i] = NULL; + } + video->renderer->vramAOBJExtPal = NULL; + video->renderer->vramBOBJExtPal = NULL; video->renderer->deinit(video->renderer); video->renderer->init(video->renderer);

@@ -499,8 +515,8 @@ case MODE_A_BG:

for (j = offset; j < 0x20; j += oldInfo.mirrorSize) { for (i = 0; i < size; ++i) { if (ds->video.vramABG[i + j] == &memory->vramBank[index][i << (DS_VRAM_OFFSET - 1)]) { - ds->video.vramABG[i + j] = NULL; - ds->video.renderer->vramABG[i + j] = NULL; + ds->video.vramABG[i + j] = _zeroes; + ds->video.renderer->vramABG[i + j] = _zeroes; } } }

@@ -509,8 +525,8 @@ case MODE_B_BG:

for (j = offset; j < 0x20; j += oldInfo.mirrorSize) { for (i = 0; i < size; ++i) { if (ds->video.vramBBG[i + j] == &memory->vramBank[index][i << (DS_VRAM_OFFSET - 1)]) { - ds->video.vramBBG[i + j] = NULL; - ds->video.renderer->vramBBG[i + j] = NULL; + ds->video.vramBBG[i + j] = _zeroes; + ds->video.renderer->vramBBG[i + j] = _zeroes; } } }

@@ -519,8 +535,8 @@ case MODE_A_OBJ:

for (j = offset; j < 0x20; j += oldInfo.mirrorSize) { for (i = 0; i < size; ++i) { if (ds->video.vramAOBJ[i + j] == &memory->vramBank[index][i << (DS_VRAM_OFFSET - 1)]) { - ds->video.vramAOBJ[i + j] = NULL; - ds->video.renderer->vramAOBJ[i + j] = NULL; + ds->video.vramAOBJ[i + j] = _zeroes; + ds->video.renderer->vramAOBJ[i + j] = _zeroes; } } }

@@ -529,8 +545,8 @@ case MODE_B_OBJ:

for (j = offset; j < 0x20; j += oldInfo.mirrorSize) { for (i = 0; i < size; ++i) { if (ds->video.vramBOBJ[i + j] == &memory->vramBank[index][i << (DS_VRAM_OFFSET - 1)]) { - ds->video.vramBOBJ[i + j] = NULL; - ds->video.renderer->vramBOBJ[i + j] = NULL; + ds->video.vramBOBJ[i + j] = _zeroes; + ds->video.renderer->vramBOBJ[i + j] = _zeroes; } } }

@@ -569,16 +585,16 @@ }

break; case MODE_3D_TEX: if (ds->gx.tex[offset] == memory->vramBank[index]) { - ds->gx.tex[offset] = NULL; - ds->gx.renderer->tex[offset] = NULL; + ds->gx.tex[offset] = _zeroes; + ds->gx.renderer->tex[offset] = _zeroes; ds->gx.renderer->invalidateTex(ds->gx.renderer, offset); } break; case MODE_3D_TEX_PAL: for (i = 0; i < oldInfo.mirrorSize; ++i) { if (ds->gx.texPal[offset + i] == &memory->vramBank[index][i << 13]) { - ds->gx.texPal[offset + i] = NULL; - ds->gx.renderer->texPal[offset + i] = NULL; + ds->gx.texPal[offset + i] = _zeroes; + ds->gx.renderer->texPal[offset + i] = _zeroes; } } break;
M src/gba/renderers/software-mode0.csrc/gba/renderers/software-mode0.c

@@ -15,9 +15,6 @@ xBase += (localX & 0x100) << 5; \

} \ screenBase = background->screenBase + yBase + (xBase >> 2); \ uint16_t* screenBlock = renderer->d.vramBG[screenBase >> VRAM_BLOCK_OFFSET]; \ - if (UNLIKELY(!screenBlock)) { \ - return; \ - } \ LOAD_16(mapData, screenBase & VRAM_BLOCK_MASK, screenBlock); \ localY = inY & 0x7; \ if (GBA_TEXT_MAP_VFLIP(mapData)) { \

@@ -29,26 +26,21 @@ 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]; \ - 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); \ - } \ + 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); \ } \ } #define DRAW_BACKGROUND_MODE_0_TILE_PREFIX_16(BLEND, OBJWIN) \ charBase = (background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 5)) + (localY << 2); \ vram = renderer->d.vramBG[charBase >> VRAM_BLOCK_OFFSET]; \ - if (UNLIKELY(!vram)) { \ - return; \ - } \ LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \ palette = &mainPalette[paletteData]; \

@@ -91,23 +83,19 @@ BACKGROUND_TEXT_SELECT_CHARACTER; \

} \ charBase = (background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 5)) + (localY << 2); \ vram = renderer->d.vramBG[charBase >> VRAM_BLOCK_OFFSET]; \ - if (UNLIKELY(!vram)) { \ - carryData = 0; \ + paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \ + palette = &mainPalette[paletteData]; \ + LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ + if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ + tileData >>= 4 * baseX; \ } else { \ - paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \ - palette = &mainPalette[paletteData]; \ - LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ - if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ - tileData >>= 4 * baseX; \ - } else { \ - tileData >>= 4 * (7 - baseX); \ - } \ - tileData &= 0xF; \ - tileData |= tileData << 4; \ - tileData |= tileData << 8; \ - tileData |= tileData << 16; \ - carryData = tileData; \ + tileData >>= 4 * (7 - baseX); \ } \ + tileData &= 0xF; \ + tileData |= tileData << 4; \ + tileData |= tileData << 8; \ + tileData |= tileData << 16; \ + carryData = tileData; \ } \ for (; length; ++tileX) { \ BACKGROUND_TEXT_SELECT_CHARACTER; \

@@ -116,23 +104,19 @@ vram = renderer->d.vramBG[charBase >> VRAM_BLOCK_OFFSET]; \

tileData = carryData; \ for (; x < 8 && length; ++x, --length) { \ if (!mosaicWait) { \ - if (UNLIKELY(!vram)) { \ - carryData = 0; \ + paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \ + palette = &mainPalette[paletteData]; \ + LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ + if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ + tileData >>= x * 4; \ } else { \ - paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \ - palette = &mainPalette[paletteData]; \ - LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ - if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ - tileData >>= x * 4; \ - } else { \ - tileData >>= (7 - x) * 4; \ - } \ - tileData &= 0xF; \ - tileData |= tileData << 4; \ - tileData |= tileData << 8; \ - tileData |= tileData << 16; \ - carryData = tileData; \ + tileData >>= (7 - x) * 4; \ } \ + tileData &= 0xF; \ + tileData |= tileData << 4; \ + tileData |= tileData << 8; \ + tileData |= tileData << 16; \ + carryData = tileData; \ mosaicWait = mosaicH; \ } \ --mosaicWait; \

@@ -149,10 +133,6 @@ 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]; \ - if (UNLIKELY(!vram)) { \ - outX += 8; \ - continue; \ - } \ LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ if (tileData) { \ if (!GBA_TEXT_MAP_HFLIP(mapData)) { \

@@ -182,47 +162,42 @@ #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 (LIKELY(vram)) { \ - 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); \ + if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ + int shift = inX & 0x3; \ + if (end2 > outX) { \ + LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ tileData >>= 8 * shift; \ - for (; outX < end; ++outX) { \ + shift = 0; \ + for (; outX < end2; ++outX) { \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN, 0); \ } \ - } 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 + 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) { \ LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ - for (; outX >= renderer->start; --outX) { \ + for (; outX >= end2; --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); \ } \ } #define DRAW_BACKGROUND_MODE_0_TILE_PREFIX_256(BLEND, OBJWIN) \ charBase = (background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 6)) + (localY << 3); \ vram = renderer->d.vramBG[charBase >> VRAM_BLOCK_OFFSET]; \ - if (UNLIKELY(!vram)) { \ - return; \ - } \ int end = mod8 - 4; \ if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ if (end > 0) { \

@@ -266,10 +241,6 @@ for (; tileX < tileEnd; ++tileX) { \

BACKGROUND_TEXT_SELECT_CHARACTER; \ charBase = (background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 6)) + (localY << 3); \ vram = renderer->d.vramBG[charBase >> VRAM_BLOCK_OFFSET]; \ - if (UNLIKELY(!vram)) { \ - outX += 8; \ - continue; \ - } \ if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ if (tileData) { \

@@ -315,29 +286,25 @@ vram = renderer->d.vramBG[charBase >> VRAM_BLOCK_OFFSET]; \

tileData = carryData; \ for (x = 0; x < 8; ++x) { \ if (!mosaicWait) { \ - if (UNLIKELY(!vram)) { \ - carryData = 0; \ + if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ + if (x >= 4) { \ + LOAD_32(tileData, (charBase + 4) & VRAM_BLOCK_MASK, vram); \ + tileData >>= (x - 4) * 8; \ + } else { \ + LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ + tileData >>= x * 8; \ + } \ } else { \ - if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ - if (x >= 4) { \ - LOAD_32(tileData, (charBase + 4) & VRAM_BLOCK_MASK, vram); \ - tileData >>= (x - 4) * 8; \ - } else { \ - LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ - tileData >>= x * 8; \ - } \ + if (x >= 4) { \ + LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ + tileData >>= (7 - x) * 8; \ } else { \ - if (x >= 4) { \ - LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ - tileData >>= (7 - x) * 8; \ - } else { \ - LOAD_32(tileData, (charBase + 4) & VRAM_BLOCK_MASK, vram); \ - tileData >>= (3 - x) * 8; \ - } \ + LOAD_32(tileData, (charBase + 4) & VRAM_BLOCK_MASK, vram); \ + tileData >>= (3 - x) * 8; \ } \ - tileData &= 0xFF; \ - carryData = tileData; \ } \ + tileData &= 0xFF; \ + carryData = tileData; \ mosaicWait = mosaicH; \ } \ tileData |= tileData << 8; \

@@ -351,49 +318,44 @@ #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; \ - if (LIKELY(vram)) { \ - 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); \ + 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; \ - for (; outX < end; ++outX) { \ + shift = 0; \ + for (; outX < end2; ++outX) { \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN, 0); \ } \ - } 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 + 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) { \ LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ - for (; outX >= renderer->start; --outX) { \ + for (; outX >= end2; --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); \ } \ } #define DRAW_BACKGROUND_MODE_0_TILE_PREFIX_256EXT(BLEND, OBJWIN) \ charBase = (background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 6)) + (localY << 3); \ vram = renderer->d.vramBG[charBase >> VRAM_BLOCK_OFFSET]; \ - if (UNLIKELY(!vram)) { \ - return; \ - } \ paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 8; \ palette = &mainPalette[paletteData]; \ int end = mod8 - 4; \

@@ -441,10 +403,6 @@ paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 8; \

palette = &mainPalette[paletteData]; \ charBase = (background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 6)) + (localY << 3); \ vram = renderer->d.vramBG[charBase >> VRAM_BLOCK_OFFSET]; \ - if (UNLIKELY(!vram)) { \ - outX += 8; \ - continue; \ - } \ if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ if (tileData) { \

@@ -490,31 +448,27 @@ vram = renderer->d.vramBG[charBase >> VRAM_BLOCK_OFFSET]; \

tileData = carryData; \ for (x = 0; x < 8; ++x) { \ if (!mosaicWait) { \ - if (UNLIKELY(!vram)) { \ - carryData = 0; \ + paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 8; \ + palette = &mainPalette[paletteData]; \ + if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ + if (x >= 4) { \ + LOAD_32(tileData, (charBase + 4) & VRAM_BLOCK_MASK, vram); \ + tileData >>= (x - 4) * 8; \ + } else { \ + LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ + tileData >>= x * 8; \ + } \ } else { \ - paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 8; \ - palette = &mainPalette[paletteData]; \ - if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ - if (x >= 4) { \ - LOAD_32(tileData, (charBase + 4) & VRAM_BLOCK_MASK, vram); \ - tileData >>= (x - 4) * 8; \ - } else { \ - LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ - tileData >>= x * 8; \ - } \ + if (x >= 4) { \ + LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ + tileData >>= (7 - x) * 8; \ } else { \ - if (x >= 4) { \ - LOAD_32(tileData, charBase & VRAM_BLOCK_MASK, vram); \ - tileData >>= (7 - x) * 8; \ - } else { \ - LOAD_32(tileData, (charBase + 4) & VRAM_BLOCK_MASK, vram); \ - tileData >>= (3 - x) * 8; \ - } \ + LOAD_32(tileData, (charBase + 4) & VRAM_BLOCK_MASK, vram); \ + tileData >>= (3 - x) * 8; \ } \ - tileData &= 0xFF; \ - carryData = tileData; \ } \ + tileData &= 0xFF; \ + carryData = tileData; \ mosaicWait = mosaicH; \ } \ tileData |= tileData << 8; \
M src/gba/video.csrc/gba/video.c

@@ -32,6 +32,8 @@

static void _startHblank(struct mTiming*, void* context, uint32_t cyclesLate); static void _startHdraw(struct mTiming*, void* context, uint32_t cyclesLate); +static uint16_t _zeroes[0x2000] = {}; + const int GBAVideoObjSizes[16][2] = { { 8, 8 }, { 16, 16 },

@@ -103,6 +105,8 @@ video->renderer->vramBG[3] = &video->vram[0x6000];

memset(video->renderer->vramOBJ, 0, sizeof(video->renderer->vramOBJ)); video->renderer->vramOBJ[0] = &video->vram[0x8000]; video->renderer->vramOBJ[1] = &video->vram[0xA000]; + video->renderer->vramOBJ[2] = _zeroes; + video->renderer->vramOBJ[3] = _zeroes; memset(video->palette, 0, sizeof(video->palette)); memset(video->oam.raw, 0, sizeof(video->oam.raw));

@@ -129,6 +133,8 @@ renderer->vramBG[3] = &video->vram[0x6000];

memset(renderer->vramOBJ, 0, sizeof(renderer->vramOBJ)); renderer->vramOBJ[0] = &video->vram[0x8000]; renderer->vramOBJ[1] = &video->vram[0xA000]; + renderer->vramOBJ[2] = _zeroes; + renderer->vramOBJ[3] = _zeroes; renderer->oam = &video->oam; video->renderer->init(video->renderer); }