mirror of https://github.com/mgba-emu/mgba.git
GBA Video: Clean up flag calculation
This commit is contained in:
parent
16125e8623
commit
16df8fe957
|
@ -40,6 +40,9 @@ struct GBAVideoSoftwareBackground {
|
|||
int32_t sy;
|
||||
int yCache;
|
||||
uint16_t mapCache[64];
|
||||
uint32_t flags;
|
||||
uint32_t objwinFlags;
|
||||
bool variant;
|
||||
int32_t offsetX;
|
||||
int32_t offsetY;
|
||||
bool highlight;
|
||||
|
|
|
@ -517,19 +517,12 @@ void GBAVideoSoftwareRendererDrawBackgroundMode0(struct GBAVideoSoftwareRenderer
|
|||
|
||||
unsigned xBase;
|
||||
|
||||
uint32_t flags = (background->priority << OFFSET_PRIORITY) | (background->index << OFFSET_INDEX) | FLAG_IS_BACKGROUND;
|
||||
flags |= FLAG_TARGET_2 * background->target2;
|
||||
int objwinFlags = FLAG_TARGET_1 * (background->target1 && renderer->blendEffect == BLEND_ALPHA && GBAWindowControlIsBlendEnable(renderer->objwin.packed));
|
||||
objwinFlags |= flags;
|
||||
flags |= FLAG_TARGET_1 * (background->target1 && renderer->blendEffect == BLEND_ALPHA && GBAWindowControlIsBlendEnable(renderer->currentWindow.packed));
|
||||
if (renderer->blendEffect == BLEND_ALPHA && renderer->blda == 0x10 && renderer->bldb == 0) {
|
||||
flags &= ~(FLAG_TARGET_1 | FLAG_TARGET_2);
|
||||
objwinFlags &= ~(FLAG_TARGET_1 | FLAG_TARGET_2);
|
||||
}
|
||||
uint32_t flags = background->flags;
|
||||
uint32_t objwinFlags = background->objwinFlags;
|
||||
bool variant = background->variant;
|
||||
|
||||
uint32_t screenBase;
|
||||
uint32_t charBase;
|
||||
int variant = background->target1 && GBAWindowControlIsBlendEnable(renderer->currentWindow.packed) && (renderer->blendEffect == BLEND_BRIGHTEN || renderer->blendEffect == BLEND_DARKEN);
|
||||
color_t* mainPalette = renderer->normalPalette;
|
||||
if (renderer->d.highlightAmount && background->highlight) {
|
||||
mainPalette = renderer->highlightPalette;
|
||||
|
|
|
@ -189,19 +189,9 @@ static inline void _compositeNoBlendNoObjwin(struct GBAVideoSoftwareRenderer* re
|
|||
localY += background->sy + startX * background->dy; \
|
||||
} \
|
||||
\
|
||||
uint32_t flags = (background->priority << OFFSET_PRIORITY) | (background->index << OFFSET_INDEX) | FLAG_IS_BACKGROUND; \
|
||||
flags |= FLAG_TARGET_2 * background->target2; \
|
||||
int objwinFlags = FLAG_TARGET_1 * (background->target1 && renderer->blendEffect == BLEND_ALPHA && \
|
||||
GBAWindowControlIsBlendEnable(renderer->objwin.packed)); \
|
||||
objwinFlags |= flags; \
|
||||
flags |= FLAG_TARGET_1 * (background->target1 && renderer->blendEffect == BLEND_ALPHA && \
|
||||
GBAWindowControlIsBlendEnable(renderer->currentWindow.packed)); \
|
||||
if (renderer->blendEffect == BLEND_ALPHA && renderer->blda == 0x10 && renderer->bldb == 0) { \
|
||||
flags &= ~(FLAG_TARGET_1 | FLAG_TARGET_2); \
|
||||
objwinFlags &= ~(FLAG_TARGET_1 | FLAG_TARGET_2); \
|
||||
} \
|
||||
int variant = background->target1 && GBAWindowControlIsBlendEnable(renderer->currentWindow.packed) && \
|
||||
(renderer->blendEffect == BLEND_BRIGHTEN || renderer->blendEffect == BLEND_DARKEN); \
|
||||
uint32_t flags = background->flags; \
|
||||
uint32_t objwinFlags = background->objwinFlags; \
|
||||
bool variant = background->variant; \
|
||||
color_t* palette = renderer->normalPalette; \
|
||||
if (renderer->d.highlightAmount && background->highlight) { \
|
||||
palette = renderer->highlightPalette; \
|
||||
|
|
|
@ -40,6 +40,7 @@ static void GBAVideoSoftwareRendererPostprocessBuffer(struct GBAVideoSoftwareRen
|
|||
static int GBAVideoSoftwareRendererPreprocessSpriteLayer(struct GBAVideoSoftwareRenderer* renderer, int y);
|
||||
|
||||
static void _updatePalettes(struct GBAVideoSoftwareRenderer* renderer);
|
||||
static void _updateFlags(struct GBAVideoSoftwareRenderer* renderer, struct GBAVideoSoftwareBackground* bg);
|
||||
|
||||
static void _breakWindow(struct GBAVideoSoftwareRenderer* softwareRenderer, struct WindowN* win, int y);
|
||||
static void _breakWindowInner(struct GBAVideoSoftwareRenderer* softwareRenderer, struct WindowN* win);
|
||||
|
@ -579,6 +580,40 @@ static void GBAVideoSoftwareRendererDrawScanline(struct GBAVideoRenderer* render
|
|||
softwareRenderer->start = softwareRenderer->end;
|
||||
softwareRenderer->end = softwareRenderer->windows[w].endX;
|
||||
softwareRenderer->currentWindow = softwareRenderer->windows[w].control;
|
||||
switch (GBARegisterDISPCNTGetMode(softwareRenderer->dispcnt)) {
|
||||
case 0:
|
||||
if (softwareRenderer->bg[0].enabled == ENABLED_MAX) {
|
||||
_updateFlags(softwareRenderer, &softwareRenderer->bg[0]);
|
||||
}
|
||||
if (softwareRenderer->bg[1].enabled == ENABLED_MAX) {
|
||||
_updateFlags(softwareRenderer, &softwareRenderer->bg[1]);
|
||||
}
|
||||
// Fall through
|
||||
case 2:
|
||||
if (softwareRenderer->bg[3].enabled == ENABLED_MAX) {
|
||||
_updateFlags(softwareRenderer, &softwareRenderer->bg[3]);
|
||||
}
|
||||
// Fall through
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
if (softwareRenderer->bg[2].enabled == ENABLED_MAX) {
|
||||
_updateFlags(softwareRenderer, &softwareRenderer->bg[2]);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (softwareRenderer->bg[0].enabled == ENABLED_MAX) {
|
||||
_updateFlags(softwareRenderer, &softwareRenderer->bg[0]);
|
||||
}
|
||||
if (softwareRenderer->bg[1].enabled == ENABLED_MAX) {
|
||||
_updateFlags(softwareRenderer, &softwareRenderer->bg[1]);
|
||||
}
|
||||
if (softwareRenderer->bg[2].enabled == ENABLED_MAX) {
|
||||
_updateFlags(softwareRenderer, &softwareRenderer->bg[2]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
for (priority = 0; priority < 4; ++priority) {
|
||||
if (spriteLayers & (1 << priority)) {
|
||||
GBAVideoSoftwareRendererPostprocessSprite(softwareRenderer, priority);
|
||||
|
@ -761,6 +796,8 @@ static void GBAVideoSoftwareRendererWriteBGCNT(struct GBAVideoSoftwareRenderer*
|
|||
bg->overflow = GBARegisterBGCNTGetOverflow(value);
|
||||
bg->size = GBARegisterBGCNTGetSize(value);
|
||||
bg->yCache = -1;
|
||||
|
||||
_updateFlags(renderer, bg);
|
||||
}
|
||||
|
||||
static void GBAVideoSoftwareRendererWriteBGX_LO(struct GBAVideoSoftwareBackground* bg, uint16_t value) {
|
||||
|
@ -1007,3 +1044,27 @@ static void _updatePalettes(struct GBAVideoSoftwareRenderer* renderer) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _updateFlags(struct GBAVideoSoftwareRenderer* renderer, struct GBAVideoSoftwareBackground* background) {
|
||||
uint32_t flags = (background->priority << OFFSET_PRIORITY) | (background->index << OFFSET_INDEX) | FLAG_IS_BACKGROUND;
|
||||
if (background->target2) {
|
||||
flags |= FLAG_TARGET_2;
|
||||
}
|
||||
uint32_t objwinFlags = flags;
|
||||
if (renderer->blendEffect == BLEND_ALPHA) {
|
||||
if (renderer->blda == 0x10 && renderer->bldb == 0) {
|
||||
flags &= ~FLAG_TARGET_2;
|
||||
objwinFlags &= ~FLAG_TARGET_2;
|
||||
} else if (background->target1) {
|
||||
if (GBAWindowControlIsBlendEnable(renderer->currentWindow.packed)) {
|
||||
flags |= FLAG_TARGET_1;
|
||||
}
|
||||
if (GBAWindowControlIsBlendEnable(renderer->objwin.packed)) {
|
||||
objwinFlags |= FLAG_TARGET_1;
|
||||
}
|
||||
}
|
||||
}
|
||||
background->flags = flags;
|
||||
background->objwinFlags = objwinFlags;
|
||||
background->variant = background->target1 && GBAWindowControlIsBlendEnable(renderer->currentWindow.packed) && (renderer->blendEffect == BLEND_BRIGHTEN || renderer->blendEffect == BLEND_DARKEN);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue