From e2c3c4068db626f05ea4f013e62a72672ac66427 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Thu, 24 Jul 2014 02:52:02 -0700 Subject: [PATCH] Pull out vram pointer --- src/gba/renderers/video-software.c | 35 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/gba/renderers/video-software.c b/src/gba/renderers/video-software.c index bb9bc12db..403e6e751 100644 --- a/src/gba/renderers/video-software.c +++ b/src/gba/renderers/video-software.c @@ -790,7 +790,7 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re 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 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re 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 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re #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 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re 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 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re 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 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re 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 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re } \ } \ \ - 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 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re 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 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re ++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 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re 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 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re } 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 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re 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 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re 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 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re 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 @@ static void _drawBackgroundMode0(struct GBAVideoSoftwareRenderer* renderer, stru 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)) {