revise windows to be even closer to hardware.

apparently hardware only ever updates its 'inside/outside window' status when reaching the coordinates. which becomes apparent if you, like, try to invert a window midframe.
This commit is contained in:
StapleButter 2018-11-25 19:13:23 +01:00
parent 2035784f9f
commit 4b8cea3b38
2 changed files with 36 additions and 28 deletions

View File

@ -107,6 +107,9 @@ void GPU2D::Reset()
memset(Win1Coords, 0, 4); memset(Win1Coords, 0, 4);
memset(WinCnt, 0, 4); memset(WinCnt, 0, 4);
Win0Active = 0;
Win1Active = 0;
BGMosaicSize[0] = 0; BGMosaicSize[0] = 0;
BGMosaicSize[1] = 0; BGMosaicSize[1] = 0;
OBJMosaicSize[0] = 0; OBJMosaicSize[0] = 0;
@ -961,10 +964,10 @@ u16* GPU2D::GetOBJExtPal(u32 pal)
void GPU2D::CheckWindows(u32 line) void GPU2D::CheckWindows(u32 line)
{ {
line &= 0xFF; line &= 0xFF;
if (line == Win0Coords[3]) Win0Active = false; if (line == Win0Coords[3]) Win0Active &= ~0x1;
else if (line == Win0Coords[2]) Win0Active = true; else if (line == Win0Coords[2]) Win0Active |= 0x1;
if (line == Win1Coords[3]) Win1Active = false; if (line == Win1Coords[3]) Win1Active &= ~0x1;
else if (line == Win1Coords[2]) Win1Active = true; else if (line == Win1Coords[2]) Win1Active |= 0x1;
} }
void GPU2D::CalculateWindowMask(u32 line, u8* mask) void GPU2D::CalculateWindowMask(u32 line, u8* mask)
@ -972,35 +975,40 @@ void GPU2D::CalculateWindowMask(u32 line, u8* mask)
for (u32 i = 0; i < 256; i++) for (u32 i = 0; i < 256; i++)
mask[i] = WinCnt[2]; // window outside mask[i] = WinCnt[2]; // window outside
if ((DispCnt & (1<<15)) && (DispCnt & (1<<12))) if (DispCnt & ((1<<15)|(1<<12)))
{ {
// OBJ window // OBJ window
u8 objwin[256]; DrawSpritesWindow(line, mask);
memset(objwin, 0, 256);
DrawSpritesWindow(line, objwin);
for (u32 i = 0; i < 256; i++)
{
if (objwin[i]) mask[i] = WinCnt[3];
}
} }
if ((DispCnt & (1<<14)) && Win1Active) if (DispCnt & (1<<14))
{ {
// window 1 // window 1
u8 x1 = Win1Coords[0]; u8 x1 = Win1Coords[0];
u8 x2 = Win1Coords[1]; u8 x2 = Win1Coords[1];
while (x1 != x2) mask[x1++] = WinCnt[1]; for (int i = 0; i < 256; i++)
{
if (i == x2) Win1Active &= ~0x2;
else if (i == x1) Win1Active |= 0x2;
if (Win1Active == 0x3) mask[i] = WinCnt[1];
}
} }
if ((DispCnt & (1<<13)) && Win0Active) if (DispCnt & (1<<13))
{ {
// window 0 // window 0
u8 x1 = Win0Coords[0]; u8 x1 = Win0Coords[0];
u8 x2 = Win0Coords[1]; u8 x2 = Win0Coords[1];
while (x1 != x2) mask[x1++] = WinCnt[0]; for (int i = 0; i < 256; i++)
{
if (i == x2) Win0Active &= ~0x2;
else if (i == x1) Win0Active |= 0x2;
if (Win0Active == 0x3) mask[i] = WinCnt[0];
}
} }
} }
@ -2157,7 +2165,7 @@ void GPU2D::DrawSprite_Rotscale(u16* attrib, u16* rotparams, u32 boundwidth, u32
if (color & 0x8000) if (color & 0x8000)
{ {
if (window) ((u8*)dst)[xpos] = 1; if (window) ((u8*)dst)[xpos] = WinCnt[3];
else dst[xpos] = color | prio; else dst[xpos] = color | prio;
} }
} }
@ -2221,7 +2229,7 @@ void GPU2D::DrawSprite_Rotscale(u16* attrib, u16* rotparams, u32 boundwidth, u32
if (color) if (color)
{ {
if (window) ((u8*)dst)[xpos] = 1; if (window) ((u8*)dst)[xpos] = WinCnt[3];
else dst[xpos] = pal[color] | prio; else dst[xpos] = pal[color] | prio;
} }
} }
@ -2279,7 +2287,7 @@ void GPU2D::DrawSprite_Rotscale(u16* attrib, u16* rotparams, u32 boundwidth, u32
if (color) if (color)
{ {
if (window) ((u8*)dst)[xpos] = 1; if (window) ((u8*)dst)[xpos] = WinCnt[3];
else dst[xpos] = pal[color] | prio; else dst[xpos] = pal[color] | prio;
} }
} }
@ -2393,7 +2401,7 @@ void GPU2D::DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, s32 ypos, u32* d
if (color & 0x8000) if (color & 0x8000)
{ {
if (window) ((u8*)dst)[xpos] = 1; if (window) ((u8*)dst)[xpos] = WinCnt[3];
else dst[xpos] = color | prio; else dst[xpos] = color | prio;
} }
@ -2420,7 +2428,7 @@ void GPU2D::DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, s32 ypos, u32* d
if (color & 0x8000) if (color & 0x8000)
{ {
if (window) ((u8*)dst)[xpos] = 1; if (window) ((u8*)dst)[xpos] = WinCnt[3];
else dst[xpos] = color | prio; else dst[xpos] = color | prio;
} }
@ -2480,7 +2488,7 @@ void GPU2D::DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, s32 ypos, u32* d
if (color) if (color)
{ {
if (window) ((u8*)dst)[xpos] = 1; if (window) ((u8*)dst)[xpos] = WinCnt[3];
else dst[xpos] = pal[color] | prio; else dst[xpos] = pal[color] | prio;
} }
@ -2509,7 +2517,7 @@ void GPU2D::DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, s32 ypos, u32* d
if (color) if (color)
{ {
if (window) ((u8*)dst)[xpos] = 1; if (window) ((u8*)dst)[xpos] = WinCnt[3];
else dst[xpos] = pal[color] | prio; else dst[xpos] = pal[color] | prio;
} }
@ -2558,7 +2566,7 @@ void GPU2D::DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, s32 ypos, u32* d
if (color) if (color)
{ {
if (window) ((u8*)dst)[xpos] = 1; if (window) ((u8*)dst)[xpos] = WinCnt[3];
else dst[xpos] = pal[color] | prio; else dst[xpos] = pal[color] | prio;
} }
@ -2592,7 +2600,7 @@ void GPU2D::DrawSprite_Normal(u16* attrib, u32 width, s32 xpos, s32 ypos, u32* d
if (color) if (color)
{ {
if (window) ((u8*)dst)[xpos] = 1; if (window) ((u8*)dst)[xpos] = WinCnt[3];
else dst[xpos] = pal[color] | prio; else dst[xpos] = pal[color] | prio;
} }

View File

@ -90,8 +90,8 @@ private:
u8 Win0Coords[4]; u8 Win0Coords[4];
u8 Win1Coords[4]; u8 Win1Coords[4];
u8 WinCnt[4]; u8 WinCnt[4];
bool Win0Active; u32 Win0Active;
bool Win1Active; u32 Win1Active;
u8 BGMosaicSize[2]; u8 BGMosaicSize[2];
u8 OBJMosaicSize[2]; u8 OBJMosaicSize[2];