mirror of https://github.com/mgba-emu/mgba.git
GBA Video: Minor mode 2 optimization
This commit is contained in:
parent
92849dee1a
commit
642ed65ee2
|
@ -7,28 +7,41 @@
|
||||||
|
|
||||||
#include "gba/gba.h"
|
#include "gba/gba.h"
|
||||||
|
|
||||||
#define DRAW_BACKGROUND_MODE_2(BLEND, OBJWIN) \
|
#define MODE_2_COORD_OVERFLOW \
|
||||||
for (outX = renderer->start, pixel = &renderer->row[outX]; outX < renderer->end; ++outX, ++pixel) { \
|
|
||||||
x += background->dx; \
|
|
||||||
y += background->dy; \
|
|
||||||
\
|
|
||||||
if (!mosaicWait) { \
|
|
||||||
if (background->overflow) { \
|
|
||||||
localX = x & (sizeAdjusted - 1); \
|
localX = x & (sizeAdjusted - 1); \
|
||||||
localY = y & (sizeAdjusted - 1); \
|
localY = y & (sizeAdjusted - 1); \
|
||||||
} else if ((x | y) & ~(sizeAdjusted - 1)) { \
|
|
||||||
|
#define MODE_2_COORD_NO_OVERFLOW \
|
||||||
|
if ((x | y) & ~(sizeAdjusted - 1)) { \
|
||||||
continue; \
|
continue; \
|
||||||
} else { \
|
} else { \
|
||||||
localX = x; \
|
localX = x; \
|
||||||
localY = y; \
|
localY = y; \
|
||||||
} \
|
}
|
||||||
|
|
||||||
|
#define MODE_2_MOSAIC(COORD) \
|
||||||
|
if (!mosaicWait) { \
|
||||||
|
COORD \
|
||||||
mapData = ((uint8_t*)renderer->d.vram)[screenBase + (localX >> 11) + (((localY >> 7) & 0x7F0) << background->size)]; \
|
mapData = ((uint8_t*)renderer->d.vram)[screenBase + (localX >> 11) + (((localY >> 7) & 0x7F0) << background->size)]; \
|
||||||
pixelData = ((uint8_t*)renderer->d.vram)[charBase + (mapData << 6) + ((localY & 0x700) >> 5) + ((localX & 0x700) >> 8)]; \
|
pixelData = ((uint8_t*)renderer->d.vram)[charBase + (mapData << 6) + ((localY & 0x700) >> 5) + ((localX & 0x700) >> 8)]; \
|
||||||
\
|
\
|
||||||
mosaicWait = mosaicH; \
|
mosaicWait = mosaicH; \
|
||||||
} else { \
|
} else { \
|
||||||
--mosaicWait; \
|
--mosaicWait; \
|
||||||
} \
|
}
|
||||||
|
|
||||||
|
#define MODE_2_NO_MOSAIC(COORD) \
|
||||||
|
COORD \
|
||||||
|
mapData = ((uint8_t*)renderer->d.vram)[screenBase + (localX >> 11) + (((localY >> 7) & 0x7F0) << background->size)]; \
|
||||||
|
pixelData = ((uint8_t*)renderer->d.vram)[charBase + (mapData << 6) + ((localY & 0x700) >> 5) + ((localX & 0x700) >> 8)];
|
||||||
|
|
||||||
|
|
||||||
|
#define MODE_2_LOOP(MOSAIC, COORD, BLEND, OBJWIN) \
|
||||||
|
for (outX = renderer->start, pixel = &renderer->row[outX]; outX < renderer->end; ++outX, ++pixel) { \
|
||||||
|
x += background->dx; \
|
||||||
|
y += background->dy; \
|
||||||
|
\
|
||||||
|
MOSAIC(COORD) \
|
||||||
\
|
\
|
||||||
uint32_t current = *pixel; \
|
uint32_t current = *pixel; \
|
||||||
if (pixelData && IS_WRITABLE(current)) { \
|
if (pixelData && IS_WRITABLE(current)) { \
|
||||||
|
@ -36,6 +49,21 @@
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DRAW_BACKGROUND_MODE_2(BLEND, OBJWIN) \
|
||||||
|
if (background->overflow) { \
|
||||||
|
if (mosaicH > 1) { \
|
||||||
|
MODE_2_LOOP(MODE_2_MOSAIC, MODE_2_COORD_OVERFLOW, BLEND, OBJWIN); \
|
||||||
|
} else { \
|
||||||
|
MODE_2_LOOP(MODE_2_NO_MOSAIC, MODE_2_COORD_OVERFLOW, BLEND, OBJWIN); \
|
||||||
|
} \
|
||||||
|
} else { \
|
||||||
|
if (mosaicH > 1) { \
|
||||||
|
MODE_2_LOOP(MODE_2_MOSAIC, MODE_2_COORD_NO_OVERFLOW, BLEND, OBJWIN); \
|
||||||
|
} else { \
|
||||||
|
MODE_2_LOOP(MODE_2_NO_MOSAIC, MODE_2_COORD_NO_OVERFLOW, BLEND, OBJWIN); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
void GBAVideoSoftwareRendererDrawBackgroundMode2(struct GBAVideoSoftwareRenderer* renderer, struct GBAVideoSoftwareBackground* background, int inY) {
|
void GBAVideoSoftwareRendererDrawBackgroundMode2(struct GBAVideoSoftwareRenderer* renderer, struct GBAVideoSoftwareBackground* background, int inY) {
|
||||||
int sizeAdjusted = 0x8000 << background->size;
|
int sizeAdjusted = 0x8000 << background->size;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue