mirror of https://github.com/mgba-emu/mgba.git
Reuse code for splitting WIN0 for WIN1
This commit is contained in:
parent
d2f15f4af4
commit
3301cc9f97
|
@ -321,6 +321,44 @@ static void GBAVideoSoftwareRendererWritePalette(struct GBAVideoRenderer* render
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define BREAK_WINDOW(WIN) \
|
||||||
|
int activeWindow; \
|
||||||
|
int startX = 0; \
|
||||||
|
if (softwareRenderer->WIN ## H.end > 0) { \
|
||||||
|
for (activeWindow = 0; activeWindow < softwareRenderer->nWindows; ++activeWindow) { \
|
||||||
|
if (softwareRenderer->WIN ## H.start < softwareRenderer->windows[activeWindow].endX) { \
|
||||||
|
struct Window oldWindow = softwareRenderer->windows[activeWindow]; \
|
||||||
|
if (softwareRenderer->WIN ## H.start > startX) { \
|
||||||
|
int nextWindow = softwareRenderer->nWindows; \
|
||||||
|
++softwareRenderer->nWindows; \
|
||||||
|
for (; nextWindow > activeWindow; --nextWindow) { \
|
||||||
|
softwareRenderer->windows[nextWindow] = softwareRenderer->windows[nextWindow - 1]; \
|
||||||
|
} \
|
||||||
|
softwareRenderer->windows[activeWindow].endX = softwareRenderer->WIN ## H.start; \
|
||||||
|
++activeWindow; \
|
||||||
|
} \
|
||||||
|
softwareRenderer->windows[activeWindow].control = softwareRenderer->WIN; \
|
||||||
|
softwareRenderer->windows[activeWindow].endX = softwareRenderer->WIN ## H.end; \
|
||||||
|
if (softwareRenderer->WIN ## H.end >= oldWindow.endX) { \
|
||||||
|
for (++activeWindow; softwareRenderer->WIN ## H.end >= softwareRenderer->windows[activeWindow].endX && softwareRenderer->nWindows > 1; ++activeWindow) { \
|
||||||
|
softwareRenderer->windows[activeWindow] = softwareRenderer->windows[activeWindow + 1]; \
|
||||||
|
--softwareRenderer->nWindows; \
|
||||||
|
} \
|
||||||
|
} else { \
|
||||||
|
++activeWindow; \
|
||||||
|
int nextWindow = softwareRenderer->nWindows; \
|
||||||
|
++softwareRenderer->nWindows; \
|
||||||
|
for (; nextWindow > activeWindow; --nextWindow) { \
|
||||||
|
softwareRenderer->windows[nextWindow] = softwareRenderer->windows[nextWindow - 1]; \
|
||||||
|
} \
|
||||||
|
softwareRenderer->windows[activeWindow] = oldWindow; \
|
||||||
|
} \
|
||||||
|
break; \
|
||||||
|
} \
|
||||||
|
startX = softwareRenderer->windows[activeWindow].endX; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
static void GBAVideoSoftwareRendererDrawScanline(struct GBAVideoRenderer* renderer, int y) {
|
static void GBAVideoSoftwareRendererDrawScanline(struct GBAVideoRenderer* renderer, int y) {
|
||||||
struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer;
|
struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer;
|
||||||
if (renderer->frameskip > 0) {
|
if (renderer->frameskip > 0) {
|
||||||
|
@ -352,65 +390,10 @@ static void GBAVideoSoftwareRendererDrawScanline(struct GBAVideoRenderer* render
|
||||||
if (softwareRenderer->dispcnt.win0Enable || softwareRenderer->dispcnt.win1Enable) {
|
if (softwareRenderer->dispcnt.win0Enable || softwareRenderer->dispcnt.win1Enable) {
|
||||||
softwareRenderer->windows[0].control = softwareRenderer->winout;
|
softwareRenderer->windows[0].control = softwareRenderer->winout;
|
||||||
if (softwareRenderer->dispcnt.win1Enable && y < softwareRenderer->win1V.end && y >= softwareRenderer->win1V.start) {
|
if (softwareRenderer->dispcnt.win1Enable && y < softwareRenderer->win1V.end && y >= softwareRenderer->win1V.start) {
|
||||||
if (softwareRenderer->win1H.start > 0) {
|
BREAK_WINDOW(win1);
|
||||||
softwareRenderer->windows[softwareRenderer->nWindows].control = softwareRenderer->win1;
|
|
||||||
softwareRenderer->windows[softwareRenderer->nWindows].endX = softwareRenderer->win1H.start;
|
|
||||||
++softwareRenderer->nWindows;
|
|
||||||
softwareRenderer->windows[softwareRenderer->nWindows].endX = VIDEO_HORIZONTAL_PIXELS;
|
|
||||||
} else {
|
|
||||||
softwareRenderer->windows[softwareRenderer->nWindows - 1].control = softwareRenderer->win1;
|
|
||||||
}
|
|
||||||
if (softwareRenderer->win1H.end < VIDEO_HORIZONTAL_PIXELS) {
|
|
||||||
softwareRenderer->windows[softwareRenderer->nWindows].control = softwareRenderer->winout;
|
|
||||||
softwareRenderer->windows[softwareRenderer->nWindows].endX = softwareRenderer->win1H.end;
|
|
||||||
++softwareRenderer->nWindows;
|
|
||||||
softwareRenderer->windows[softwareRenderer->nWindows].endX = VIDEO_HORIZONTAL_PIXELS;
|
|
||||||
} else {
|
|
||||||
softwareRenderer->windows[softwareRenderer->nWindows - 1].endX = softwareRenderer->win1H.end;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (softwareRenderer->dispcnt.win0Enable && y < softwareRenderer->win0V.end && y >= softwareRenderer->win0V.start) {
|
if (softwareRenderer->dispcnt.win0Enable && y < softwareRenderer->win0V.end && y >= softwareRenderer->win0V.start) {
|
||||||
int activeWindow;
|
BREAK_WINDOW(win0);
|
||||||
int startX = 0;
|
|
||||||
for (activeWindow = 0; activeWindow < softwareRenderer->nWindows; ++activeWindow) {
|
|
||||||
if (softwareRenderer->win0H.start < softwareRenderer->windows[activeWindow].endX) {
|
|
||||||
// We start in this region
|
|
||||||
struct Window oldWindow = softwareRenderer->windows[activeWindow];
|
|
||||||
if (softwareRenderer->win0H.start > startX) {
|
|
||||||
// We need to split the region
|
|
||||||
int nextWindow = softwareRenderer->nWindows;
|
|
||||||
++softwareRenderer->nWindows;
|
|
||||||
for (; nextWindow > activeWindow; --nextWindow) {
|
|
||||||
softwareRenderer->windows[nextWindow] = softwareRenderer->windows[nextWindow - 1];
|
|
||||||
}
|
|
||||||
softwareRenderer->windows[activeWindow].endX = softwareRenderer->win0H.start;
|
|
||||||
++activeWindow;
|
|
||||||
}
|
|
||||||
softwareRenderer->windows[activeWindow].control = softwareRenderer->win0;
|
|
||||||
softwareRenderer->windows[activeWindow].endX = softwareRenderer->win0H.end;
|
|
||||||
if (softwareRenderer->win0H.end >= oldWindow.endX) {
|
|
||||||
// Consume subsequent regions
|
|
||||||
for (++activeWindow; softwareRenderer->win0H.end >= softwareRenderer->windows[activeWindow].endX; ++activeWindow) {
|
|
||||||
softwareRenderer->windows[activeWindow] = softwareRenderer->windows[activeWindow + 1];
|
|
||||||
--softwareRenderer->nWindows;
|
|
||||||
if (softwareRenderer->nWindows <= 1) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// ...and the other end
|
|
||||||
++activeWindow;
|
|
||||||
int nextWindow = softwareRenderer->nWindows;
|
|
||||||
++softwareRenderer->nWindows;
|
|
||||||
for (; nextWindow > activeWindow; --nextWindow) {
|
|
||||||
softwareRenderer->windows[nextWindow] = softwareRenderer->windows[nextWindow - 1];
|
|
||||||
}
|
|
||||||
softwareRenderer->windows[activeWindow] = oldWindow;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
startX = softwareRenderer->windows[activeWindow].endX;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
softwareRenderer->windows[0].control.packed = 0xFF;
|
softwareRenderer->windows[0].control.packed = 0xFF;
|
||||||
|
|
Loading…
Reference in New Issue