mirror of https://github.com/mgba-emu/mgba.git
Optimize palette access
This commit is contained in:
parent
7d688ceb5a
commit
2c826e208c
|
@ -637,10 +637,10 @@ static void _composite(struct GBAVideoSoftwareRenderer* renderer, uint32_t* pixe
|
||||||
current = *pixel; \
|
current = *pixel; \
|
||||||
if (pixelData && !(current & FLAG_FINALIZED)) { \
|
if (pixelData && !(current & FLAG_FINALIZED)) { \
|
||||||
if (!objwinSlowPath) { \
|
if (!objwinSlowPath) { \
|
||||||
_composite(renderer, pixel, palette[pixelData | paletteData] | flags, current); \
|
_composite(renderer, pixel, palette[pixelData] | flags, current); \
|
||||||
} else if (objwinForceEnable || !(current & FLAG_OBJWIN) == objwinOnly) { \
|
} else if (objwinForceEnable || !(current & FLAG_OBJWIN) == objwinOnly) { \
|
||||||
color_t* currentPalette = (current & FLAG_OBJWIN) ? objwinPalette : palette; \
|
unsigned color = (current & FLAG_OBJWIN) ? objwinPalette[paletteData | pixelData] : palette[pixelData]; \
|
||||||
_composite(renderer, pixel, currentPalette[pixelData | paletteData] | flags, current); \
|
_composite(renderer, pixel, color | flags, current); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
tileData >>= 4;
|
tileData >>= 4;
|
||||||
|
@ -734,10 +734,11 @@ static void _drawBackgroundMode0(struct GBAVideoSoftwareRenderer* renderer, stru
|
||||||
uint32_t screenBase;
|
uint32_t screenBase;
|
||||||
uint32_t charBase;
|
uint32_t charBase;
|
||||||
int variant = background->target1 && renderer->currentWindow.blendEnable && (renderer->blendEffect == BLEND_BRIGHTEN || renderer->blendEffect == BLEND_DARKEN);
|
int variant = background->target1 && renderer->currentWindow.blendEnable && (renderer->blendEffect == BLEND_BRIGHTEN || renderer->blendEffect == BLEND_DARKEN);
|
||||||
color_t* palette = renderer->normalPalette;
|
color_t* mainPalette = renderer->normalPalette;
|
||||||
if (variant) {
|
if (variant) {
|
||||||
palette = renderer->variantPalette;
|
mainPalette = renderer->variantPalette;
|
||||||
}
|
}
|
||||||
|
color_t* palette = mainPalette;
|
||||||
PREPARE_OBJWIN;
|
PREPARE_OBJWIN;
|
||||||
|
|
||||||
int outX = renderer->start;
|
int outX = renderer->start;
|
||||||
|
@ -756,6 +757,7 @@ static void _drawBackgroundMode0(struct GBAVideoSoftwareRenderer* renderer, stru
|
||||||
int end = outX + 0x8 - mod8;
|
int end = outX + 0x8 - mod8;
|
||||||
if (!background->multipalette) {
|
if (!background->multipalette) {
|
||||||
paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4;
|
paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4;
|
||||||
|
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*)renderer->d.vram)[charBase];
|
tileData = ((uint32_t*)renderer->d.vram)[charBase];
|
||||||
if (!GBA_TEXT_MAP_HFLIP(mapData)) {
|
if (!GBA_TEXT_MAP_HFLIP(mapData)) {
|
||||||
|
@ -804,6 +806,7 @@ static void _drawBackgroundMode0(struct GBAVideoSoftwareRenderer* renderer, stru
|
||||||
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*)renderer->d.vram)[charBase];
|
tileData = ((uint32_t*)renderer->d.vram)[charBase];
|
||||||
paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4;
|
paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4;
|
||||||
|
palette = &mainPalette[paletteData];
|
||||||
if (!GBA_TEXT_MAP_HFLIP(mapData)) {
|
if (!GBA_TEXT_MAP_HFLIP(mapData)) {
|
||||||
outX = renderer->end - mod8;
|
outX = renderer->end - mod8;
|
||||||
if (outX < 0) {
|
if (outX < 0) {
|
||||||
|
@ -865,6 +868,7 @@ static void _drawBackgroundMode0(struct GBAVideoSoftwareRenderer* renderer, stru
|
||||||
for (x = 0; x < 8; ++x) {
|
for (x = 0; x < 8; ++x) {
|
||||||
if (!mosaicWait) {
|
if (!mosaicWait) {
|
||||||
paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4;
|
paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4;
|
||||||
|
palette = &mainPalette[paletteData];
|
||||||
tileData = ((uint32_t*)renderer->d.vram)[charBase];
|
tileData = ((uint32_t*)renderer->d.vram)[charBase];
|
||||||
if (!GBA_TEXT_MAP_HFLIP(mapData)) {
|
if (!GBA_TEXT_MAP_HFLIP(mapData)) {
|
||||||
tileData >>= x * 4;
|
tileData >>= x * 4;
|
||||||
|
@ -897,6 +901,7 @@ static void _drawBackgroundMode0(struct GBAVideoSoftwareRenderer* renderer, stru
|
||||||
for (; tileX < tileEnd; ++tileX) {
|
for (; tileX < tileEnd; ++tileX) {
|
||||||
BACKGROUND_TEXT_SELECT_CHARACTER;
|
BACKGROUND_TEXT_SELECT_CHARACTER;
|
||||||
paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4;
|
paletteData = GBA_TEXT_MAP_PALETTE(mapData) << 4;
|
||||||
|
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*)renderer->d.vram)[charBase];
|
tileData = ((uint32_t*)renderer->d.vram)[charBase];
|
||||||
if (tileData) {
|
if (tileData) {
|
||||||
|
|
Loading…
Reference in New Issue