all repos — mgba @ e2c3c4068db626f05ea4f013e62a72672ac66427

mGBA Game Boy Advance Emulator

Pull out vram pointer
Jeffrey Pfau jeffrey@endrift.com
Thu, 24 Jul 2014 02:52:02 -0700
commit

e2c3c4068db626f05ea4f013e62a72672ac66427

parent

553f345bbd1b26241d3c68f07b983b22ab22d8a0

1 files changed, 18 insertions(+), 17 deletions(-)

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

@@ -790,7 +790,7 @@ if (background->size & 1) { \

xBase += (localX & 0x100) << 5; \ } \ screenBase = yBase + (xBase >> 3); \ - mapData = renderer->d.vram[screenBase]; \ + mapData = vram[screenBase]; \ localY = inY & 0x7; \ if (GBA_TEXT_MAP_VFLIP(mapData)) { \ localY = 7 - localY; \

@@ -831,7 +831,7 @@ #define DRAW_BACKGROUND_MODE_0_TILE_SUFFIX_16(BLEND, OBJWIN) \

paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \ palette = &mainPalette[paletteData]; \ charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 5)) >> 2) + localY; \ - tileData = ((uint32_t*)renderer->d.vram)[charBase]; \ + tileData = ((uint32_t*) vram)[charBase]; \ if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ tileData >>= 4 * mod8; \ for (; outX < end; ++outX) { \

@@ -847,7 +847,7 @@ }

#define DRAW_BACKGROUND_MODE_0_TILE_PREFIX_16(BLEND, OBJWIN) \ charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 5)) >> 2) + localY; \ - tileData = ((uint32_t*)renderer->d.vram)[charBase]; \ + tileData = ((uint32_t*) vram)[charBase]; \ paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \ palette = &mainPalette[paletteData]; \ if (!GBA_TEXT_MAP_HFLIP(mapData)) { \

@@ -881,7 +881,7 @@ for (x = 0; x < 8; ++x) { \

if (!mosaicWait) { \ paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \ palette = &mainPalette[paletteData]; \ - tileData = ((uint32_t*)renderer->d.vram)[charBase]; \ + tileData = ((uint32_t*) vram)[charBase]; \ if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ tileData >>= x * 4; \ } else { \

@@ -910,7 +910,7 @@ BACKGROUND_TEXT_SELECT_CHARACTER; \

paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \ palette = &mainPalette[paletteData]; \ charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 5)) >> 2) + localY; \ - tileData = ((uint32_t*)renderer->d.vram)[charBase]; \ + tileData = ((uint32_t*) vram)[charBase]; \ if (tileData) { \ if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ BACKGROUND_DRAW_PIXEL_16(BLEND, OBJWIN); \

@@ -959,7 +959,7 @@ charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 6)) >> 2) + (localY << 1); \

int end2 = end - 4; \ int shift = inX & 0x3; \ if (end2 > 0) { \ - tileData = ((uint32_t*)renderer->d.vram)[charBase]; \ + tileData = ((uint32_t*) vram)[charBase]; \ tileData >>= 8 * shift; \ shift = 0; \ for (; outX < end2; ++outX) { \

@@ -968,7 +968,7 @@ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \

} \ } \ \ - tileData = ((uint32_t*)renderer->d.vram)[charBase + 1]; \ + tileData = ((uint32_t*) vram)[charBase + 1]; \ tileData >>= 8 * shift; \ for (; outX < end; ++outX) { \ uint32_t* pixel = &renderer->row[outX]; \

@@ -981,7 +981,7 @@ charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 6)) >> 2) + (localY << 1); \

outX = renderer->end - 8 + end; \ int end2 = 4 - end; \ if (end2 > 0) { \ - tileData = ((uint32_t*)renderer->d.vram)[charBase]; \ + tileData = ((uint32_t*) vram)[charBase]; \ for (; outX < renderer->end - end2; ++outX) { \ uint32_t* pixel = &renderer->row[outX]; \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \

@@ -989,7 +989,7 @@ } \

++charBase; \ } \ \ - tileData = ((uint32_t*)renderer->d.vram)[charBase]; \ + tileData = ((uint32_t*) vram)[charBase]; \ for (; outX < renderer->end; ++outX) { \ uint32_t* pixel = &renderer->row[outX]; \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \

@@ -1000,7 +1000,7 @@ for (; tileX < tileEnd; ++tileX) { \

BACKGROUND_TEXT_SELECT_CHARACTER; \ charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 6)) >> 2) + (localY << 1); \ if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ - tileData = ((uint32_t*)renderer->d.vram)[charBase]; \ + tileData = ((uint32_t*) vram)[charBase]; \ if (tileData) { \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \ ++pixel; \

@@ -1013,7 +1013,7 @@ ++pixel; \

} else { \ pixel += 4; \ } \ - tileData = ((uint32_t*)renderer->d.vram)[charBase + 1]; \ + tileData = ((uint32_t*) vram)[charBase + 1]; \ if (tileData) { \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \ ++pixel; \

@@ -1027,7 +1027,7 @@ } else { \

pixel += 4; \ } \ } else { \ - uint32_t tileData = ((uint32_t*)renderer->d.vram)[charBase + 1]; \ + uint32_t tileData = ((uint32_t*) vram)[charBase + 1]; \ if (tileData) { \ pixel += 3; \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \

@@ -1039,7 +1039,7 @@ --pixel; \

BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \ } \ pixel += 4; \ - tileData = ((uint32_t*)renderer->d.vram)[charBase]; \ + tileData = ((uint32_t*) vram)[charBase]; \ if (tileData) { \ pixel += 3; \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \

@@ -1063,18 +1063,18 @@ for (x = 0; x < 8; ++x) { \

if (!mosaicWait) { \ if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ if (x >= 4) { \ - tileData = ((uint32_t*)renderer->d.vram)[charBase + 1]; \ + tileData = ((uint32_t*) vram)[charBase + 1]; \ tileData >>= (x - 4) * 8; \ } else { \ - tileData = ((uint32_t*)renderer->d.vram)[charBase]; \ + tileData = ((uint32_t*) vram)[charBase]; \ tileData >>= x * 8; \ } \ } else { \ if (x >= 4) { \ - tileData = ((uint32_t*)renderer->d.vram)[charBase]; \ + tileData = ((uint32_t*) vram)[charBase]; \ tileData >>= (7 - x) * 8; \ } else { \ - tileData = ((uint32_t*)renderer->d.vram)[charBase + 1]; \ + tileData = ((uint32_t*) vram)[charBase + 1]; \ tileData >>= (3 - x) * 8; \ } \ } \

@@ -1176,6 +1176,7 @@ int pixelData;

int paletteData; int tileX = 0; int tileEnd = (renderer->end - renderer->start + (inX & 0x7)) >> 3; + uint16_t* vram = renderer->d.vram; if (!objwinSlowPath) { if (!(flags & FLAG_TARGET_2)) {