Preliminary pass at straightening out VRAM loads

This commit is contained in:
Jeffrey Pfau 2014-10-01 04:00:15 -07:00
parent 56a105e3da
commit 38e8cc1ee4
1 changed files with 23 additions and 23 deletions

View File

@ -811,7 +811,7 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
xBase += (localX & 0x100) << 5; \ xBase += (localX & 0x100) << 5; \
} \ } \
screenBase = yBase + (xBase >> 3); \ screenBase = yBase + (xBase >> 3); \
mapData = vram[screenBase]; \ LOAD_16(mapData, screenBase << 1, vram); \
localY = inY & 0x7; \ localY = inY & 0x7; \
if (GBA_TEXT_MAP_VFLIP(mapData)) { \ if (GBA_TEXT_MAP_VFLIP(mapData)) { \
localY = 7 - localY; \ localY = 7 - localY; \
@ -852,7 +852,7 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \ paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \
palette = &mainPalette[paletteData]; \ palette = &mainPalette[paletteData]; \
charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 5)) >> 2) + localY; \ charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 5)) >> 2) + localY; \
tileData = ((uint32_t*) vram)[charBase]; \ LOAD_32(tileData, charBase << 2, vram); \
if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ if (!GBA_TEXT_MAP_HFLIP(mapData)) { \
tileData >>= 4 * mod8; \ tileData >>= 4 * mod8; \
for (; outX < end; ++outX) { \ for (; outX < end; ++outX) { \
@ -868,7 +868,7 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
#define DRAW_BACKGROUND_MODE_0_TILE_PREFIX_16(BLEND, OBJWIN) \ #define DRAW_BACKGROUND_MODE_0_TILE_PREFIX_16(BLEND, OBJWIN) \
charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 5)) >> 2) + localY; \ charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 5)) >> 2) + localY; \
tileData = ((uint32_t*) vram)[charBase]; \ LOAD_32(tileData, charBase << 2, vram); \
paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \ paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \
palette = &mainPalette[paletteData]; \ palette = &mainPalette[paletteData]; \
if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ if (!GBA_TEXT_MAP_HFLIP(mapData)) { \
@ -902,7 +902,7 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
if (!mosaicWait) { \ if (!mosaicWait) { \
paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \ paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \
palette = &mainPalette[paletteData]; \ palette = &mainPalette[paletteData]; \
tileData = ((uint32_t*) vram)[charBase]; \ LOAD_32(tileData, charBase << 2, vram); \
if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ if (!GBA_TEXT_MAP_HFLIP(mapData)) { \
tileData >>= x * 4; \ tileData >>= x * 4; \
} else { \ } else { \
@ -931,7 +931,7 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \ paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4; \
palette = &mainPalette[paletteData]; \ palette = &mainPalette[paletteData]; \
charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 5)) >> 2) + localY; \ charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 5)) >> 2) + localY; \
tileData = ((uint32_t*) vram)[charBase]; \ LOAD_32(tileData, charBase << 2, vram); \
if (tileData) { \ if (tileData) { \
if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ if (!GBA_TEXT_MAP_HFLIP(mapData)) { \
BACKGROUND_DRAW_PIXEL_16(BLEND, OBJWIN); \ BACKGROUND_DRAW_PIXEL_16(BLEND, OBJWIN); \
@ -980,7 +980,7 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ if (!GBA_TEXT_MAP_HFLIP(mapData)) { \
int shift = inX & 0x3; \ int shift = inX & 0x3; \
if (end2 > outX) { \ if (end2 > outX) { \
tileData = ((uint32_t*) vram)[charBase]; \ LOAD_32(tileData, charBase << 2, vram); \
tileData >>= 8 * shift; \ tileData >>= 8 * shift; \
shift = 0; \ shift = 0; \
for (; outX < end2; ++outX) { \ for (; outX < end2; ++outX) { \
@ -989,7 +989,7 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
} \ } \
} \ } \
\ \
tileData = ((uint32_t*) vram)[charBase + 1]; \ LOAD_32(tileData, (charBase + 1) << 2, vram); \
tileData >>= 8 * shift; \ tileData >>= 8 * shift; \
for (; outX < end; ++outX) { \ for (; outX < end; ++outX) { \
pixel = &renderer->row[outX]; \ pixel = &renderer->row[outX]; \
@ -999,7 +999,7 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
int start = outX; \ int start = outX; \
outX = end - 1; \ outX = end - 1; \
if (end2 > start) { \ if (end2 > start) { \
tileData = ((uint32_t*) vram)[charBase]; \ LOAD_32(tileData, charBase << 2, vram); \
for (; outX >= end2; --outX) { \ for (; outX >= end2; --outX) { \
pixel = &renderer->row[outX]; \ pixel = &renderer->row[outX]; \
BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
@ -1007,7 +1007,7 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
++charBase; \ ++charBase; \
} \ } \
\ \
tileData = ((uint32_t*) vram)[charBase]; \ LOAD_32(tileData, charBase << 2, vram); \
for (; outX >= renderer->start; --outX) { \ for (; outX >= renderer->start; --outX) { \
pixel = &renderer->row[outX]; \ pixel = &renderer->row[outX]; \
BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
@ -1021,7 +1021,7 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
int end2 = 4 - end; \ int end2 = 4 - end; \
if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ if (!GBA_TEXT_MAP_HFLIP(mapData)) { \
if (end2 > 0) { \ if (end2 > 0) { \
tileData = ((uint32_t*) vram)[charBase]; \ LOAD_32(tileData, charBase << 2, vram); \
for (; outX < renderer->end - end2; ++outX) { \ for (; outX < renderer->end - end2; ++outX) { \
pixel = &renderer->row[outX]; \ pixel = &renderer->row[outX]; \
BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
@ -1029,7 +1029,7 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
++charBase; \ ++charBase; \
} \ } \
\ \
tileData = ((uint32_t*) vram)[charBase]; \ LOAD_32(tileData, charBase << 2, vram); \
for (; outX < renderer->end; ++outX) { \ for (; outX < renderer->end; ++outX) { \
pixel = &renderer->row[outX]; \ pixel = &renderer->row[outX]; \
BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
@ -1039,7 +1039,7 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
int start = outX; \ int start = outX; \
outX = renderer->end - 1; \ outX = renderer->end - 1; \
if (end2 > 0) { \ if (end2 > 0) { \
tileData = ((uint32_t*) vram)[charBase]; \ LOAD_32(tileData, charBase << 2, vram); \
tileData >>= 8 * shift; \ tileData >>= 8 * shift; \
for (; outX >= start + 4; --outX) { \ for (; outX >= start + 4; --outX) { \
pixel = &renderer->row[outX]; \ pixel = &renderer->row[outX]; \
@ -1048,7 +1048,7 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
shift = 0; \ shift = 0; \
} \ } \
\ \
tileData = ((uint32_t*) vram)[charBase + 1]; \ LOAD_32(tileData, (charBase + 1) << 2, vram); \
tileData >>= 8 * shift; \ tileData >>= 8 * shift; \
for (; outX >= start; --outX) { \ for (; outX >= start; --outX) { \
pixel = &renderer->row[outX]; \ pixel = &renderer->row[outX]; \
@ -1061,7 +1061,7 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
BACKGROUND_TEXT_SELECT_CHARACTER; \ BACKGROUND_TEXT_SELECT_CHARACTER; \
charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 6)) >> 2) + (localY << 1); \ charBase = ((background->charBase + (GBA_TEXT_MAP_TILE(mapData) << 6)) >> 2) + (localY << 1); \
if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ if (!GBA_TEXT_MAP_HFLIP(mapData)) { \
tileData = ((uint32_t*) vram)[charBase]; \ LOAD_32(tileData, charBase << 2, vram); \
if (tileData) { \ if (tileData) { \
BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
++pixel; \ ++pixel; \
@ -1074,7 +1074,7 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
} else { \ } else { \
pixel += 4; \ pixel += 4; \
} \ } \
tileData = ((uint32_t*) vram)[charBase + 1]; \ LOAD_32(tileData, (charBase + 1) << 2, vram); \
if (tileData) { \ if (tileData) { \
BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
++pixel; \ ++pixel; \
@ -1088,7 +1088,7 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
pixel += 4; \ pixel += 4; \
} \ } \
} else { \ } else { \
uint32_t tileData = ((uint32_t*) vram)[charBase + 1]; \ LOAD_32(tileData, (charBase + 1) << 2, vram); \
if (tileData) { \ if (tileData) { \
pixel += 3; \ pixel += 3; \
BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
@ -1100,7 +1100,7 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
} \ } \
pixel += 4; \ pixel += 4; \
tileData = ((uint32_t*) vram)[charBase]; \ LOAD_32(tileData, charBase << 2, vram); \
if (tileData) { \ if (tileData) { \
pixel += 3; \ pixel += 3; \
BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \ BACKGROUND_DRAW_PIXEL_256(BLEND, OBJWIN); \
@ -1124,18 +1124,18 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
if (!mosaicWait) { \ if (!mosaicWait) { \
if (!GBA_TEXT_MAP_HFLIP(mapData)) { \ if (!GBA_TEXT_MAP_HFLIP(mapData)) { \
if (x >= 4) { \ if (x >= 4) { \
tileData = ((uint32_t*) vram)[charBase + 1]; \ LOAD_32(tileData, (charBase + 1) << 2, vram); \
tileData >>= (x - 4) * 8; \ tileData >>= (x - 4) * 8; \
} else { \ } else { \
tileData = ((uint32_t*) vram)[charBase]; \ LOAD_32(tileData, charBase << 2, vram); \
tileData >>= x * 8; \ tileData >>= x * 8; \
} \ } \
} else { \ } else { \
if (x >= 4) { \ if (x >= 4) { \
tileData = ((uint32_t*) vram)[charBase]; \ LOAD_32(tileData, charBase << 2, vram); \
tileData >>= (7 - x) * 8; \ tileData >>= (7 - x) * 8; \
} else { \ } else { \
tileData = ((uint32_t*) vram)[charBase + 1]; \ LOAD_32(tileData, (charBase + 1) << 2, vram); \
tileData >>= (3 - x) * 8; \ tileData >>= (3 - x) * 8; \
} \ } \
} \ } \
@ -1348,7 +1348,7 @@ static void _drawBackgroundMode3(struct GBAVideoSoftwareRenderer* renderer, stru
for (outX = renderer->start, pixel = &renderer->row[outX]; outX < renderer->end; ++outX, ++pixel) { for (outX = renderer->start, pixel = &renderer->row[outX]; outX < renderer->end; ++outX, ++pixel) {
BACKGROUND_BITMAP_ITERATE(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS); BACKGROUND_BITMAP_ITERATE(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS);
color = ((uint16_t*)renderer->d.vram)[(localX >> 8) + (localY >> 8) * VIDEO_HORIZONTAL_PIXELS]; LOAD_16(color, (localX >> 8) + (localY >> 8) * VIDEO_HORIZONTAL_PIXELS << 1, renderer->d.vram);
#ifndef COLOR_16_BIT #ifndef COLOR_16_BIT
unsigned color32; unsigned color32;
color32 = 0; color32 = 0;
@ -1413,7 +1413,7 @@ static void _drawBackgroundMode5(struct GBAVideoSoftwareRenderer* renderer, stru
for (outX = renderer->start, pixel = &renderer->row[outX]; outX < renderer->end; ++outX, ++pixel) { for (outX = renderer->start, pixel = &renderer->row[outX]; outX < renderer->end; ++outX, ++pixel) {
BACKGROUND_BITMAP_ITERATE(160, 128); BACKGROUND_BITMAP_ITERATE(160, 128);
color = ((uint16_t*)renderer->d.vram)[offset + (localX >> 8) + (localY >> 8) * 160]; LOAD_16(color, offset + (localX >> 8) + (localY >> 8) * 320, renderer->d.vram);
#ifndef COLOR_16_BIT #ifndef COLOR_16_BIT
unsigned color32 = 0; unsigned color32 = 0;
color32 |= (color << 9) & 0xF80000; color32 |= (color << 9) & 0xF80000;