mirror of https://github.com/mgba-emu/mgba.git
GBA Video: Optimize affine iteration
This commit is contained in:
parent
328bebbc01
commit
d2e8eaffa4
|
@ -11,27 +11,25 @@
|
||||||
#define BACKGROUND_BITMAP_ITERATE(W, H) \
|
#define BACKGROUND_BITMAP_ITERATE(W, H) \
|
||||||
x += background->dx; \
|
x += background->dx; \
|
||||||
y += background->dy; \
|
y += background->dy; \
|
||||||
if ((x < 0 || y < 0 || (x >> 8) >= W || (y >> 8) >= H) && !mosaicWait) { \
|
if (((x | y) < 0 || x >= (W << 8) || y >= (H << 8)) && !mosaicWait) { \
|
||||||
continue; \
|
continue; \
|
||||||
} \
|
} \
|
||||||
localX = x; \
|
localX = x; \
|
||||||
localY = y;
|
localY = y;
|
||||||
|
|
||||||
#define MODE_2_COORD_OVERFLOW \
|
#define MODE_2_COORD_OVERFLOW \
|
||||||
localX = x & (sizeAdjusted - 1); \
|
x &= (sizeAdjusted - 1); \
|
||||||
localY = y & (sizeAdjusted - 1); \
|
y &= (sizeAdjusted - 1); \
|
||||||
|
|
||||||
#define MODE_2_COORD_NO_OVERFLOW \
|
#define MODE_2_COORD_NO_OVERFLOW \
|
||||||
if ((x | y) & ~(sizeAdjusted - 1)) { \
|
if ((x | y) & ~(sizeAdjusted - 1)) { \
|
||||||
continue; \
|
continue; \
|
||||||
} \
|
}
|
||||||
localX = x; \
|
|
||||||
localY = y;
|
|
||||||
|
|
||||||
#define MODE_2_NO_MOSAIC(COORD) \
|
#define MODE_2_NO_MOSAIC(COORD) \
|
||||||
COORD \
|
COORD \
|
||||||
mapData = screenBase[(localX >> 11) + (((localY >> 7) & 0x7F0) << background->size)]; \
|
mapData = screenBase[(x >> 11) + (((y >> 7) & 0x7F0) << background->size)]; \
|
||||||
pixelData = charBase[(mapData << 6) + ((localY & 0x700) >> 5) + ((localX & 0x700) >> 8)];
|
pixelData = charBase[(mapData << 6) + ((y & 0x700) >> 5) + ((x & 0x700) >> 8)];
|
||||||
|
|
||||||
#define MODE_2_MOSAIC(COORD) \
|
#define MODE_2_MOSAIC(COORD) \
|
||||||
if (!mosaicWait) { \
|
if (!mosaicWait) { \
|
||||||
|
@ -56,9 +54,13 @@
|
||||||
#define DRAW_BACKGROUND_MODE_2(BLEND, OBJWIN) \
|
#define DRAW_BACKGROUND_MODE_2(BLEND, OBJWIN) \
|
||||||
if (background->overflow) { \
|
if (background->overflow) { \
|
||||||
if (mosaicH > 1) { \
|
if (mosaicH > 1) { \
|
||||||
localX &= sizeAdjusted - 1; \
|
int tmpX = x; \
|
||||||
localY &= sizeAdjusted - 1; \
|
int tmpY = y; \
|
||||||
|
x = localX & (sizeAdjusted - 1); \
|
||||||
|
y = localY & (sizeAdjusted - 1); \
|
||||||
MODE_2_NO_MOSAIC(); \
|
MODE_2_NO_MOSAIC(); \
|
||||||
|
x = tmpX; \
|
||||||
|
y = tmpY; \
|
||||||
MODE_2_LOOP(MODE_2_MOSAIC, MODE_2_COORD_OVERFLOW, BLEND, OBJWIN); \
|
MODE_2_LOOP(MODE_2_MOSAIC, MODE_2_COORD_OVERFLOW, BLEND, OBJWIN); \
|
||||||
} else { \
|
} else { \
|
||||||
MODE_2_LOOP(MODE_2_NO_MOSAIC, MODE_2_COORD_OVERFLOW, BLEND, OBJWIN); \
|
MODE_2_LOOP(MODE_2_NO_MOSAIC, MODE_2_COORD_OVERFLOW, BLEND, OBJWIN); \
|
||||||
|
@ -66,9 +68,13 @@
|
||||||
} else { \
|
} else { \
|
||||||
if (mosaicH > 1) { \
|
if (mosaicH > 1) { \
|
||||||
if (!((x | y) & ~(sizeAdjusted - 1))) { \
|
if (!((x | y) & ~(sizeAdjusted - 1))) { \
|
||||||
localX &= sizeAdjusted - 1; \
|
int tmpX = x; \
|
||||||
localY &= sizeAdjusted - 1; \
|
int tmpY = y; \
|
||||||
|
x = localX & (sizeAdjusted - 1); \
|
||||||
|
y = localY & (sizeAdjusted - 1); \
|
||||||
MODE_2_NO_MOSAIC(); \
|
MODE_2_NO_MOSAIC(); \
|
||||||
|
x = tmpX; \
|
||||||
|
y = tmpY; \
|
||||||
} \
|
} \
|
||||||
MODE_2_LOOP(MODE_2_MOSAIC, MODE_2_COORD_NO_OVERFLOW, BLEND, OBJWIN); \
|
MODE_2_LOOP(MODE_2_MOSAIC, MODE_2_COORD_NO_OVERFLOW, BLEND, OBJWIN); \
|
||||||
} else { \
|
} else { \
|
||||||
|
|
Loading…
Reference in New Issue