* always render normal BG/OBJ graphics (even if they're not getting displayed, they can still be fed to the capture unit)

* fix 3D viewport calculation
* keep track of the clearbuffer attributes before VBlank
This commit is contained in:
StapleButter 2017-04-10 20:24:41 +02:00
parent f2622c047b
commit 8bbcc83771
4 changed files with 41 additions and 32 deletions

View File

@ -368,6 +368,25 @@ void GPU2D::DrawScanline(u32 line)
u32 dispmode = DispCnt >> 16; u32 dispmode = DispCnt >> 16;
dispmode &= (Num ? 0x1 : 0x3); dispmode &= (Num ? 0x1 : 0x3);
// always render regular graphics
DrawScanline_Mode1(line, dst);
// capture
if ((Num == 0) && (CaptureCnt & (1<<31)))
{
u32 capwidth, capheight;
switch ((CaptureCnt >> 20) & 0x3)
{
case 0: capwidth = 128; capheight = 128; break;
case 1: capwidth = 256; capheight = 64; break;
case 2: capwidth = 256; capheight = 128; break;
case 3: capwidth = 256; capheight = 192; break;
}
if (line < capheight)
DoCapture(line, capwidth, dst);
}
switch (dispmode) switch (dispmode)
{ {
case 0: // screen off case 0: // screen off
@ -377,10 +396,7 @@ void GPU2D::DrawScanline(u32 line)
} }
break; break;
case 1: // regular display case 1: // regular display, already taken care of
{
DrawScanline_Mode1(line, dst);
}
break; break;
case 2: // VRAM display case 2: // VRAM display
@ -426,22 +442,6 @@ void GPU2D::DrawScanline(u32 line)
break; break;
} }
// capture
if ((!Num) && (CaptureCnt & (1<<31)))
{
u32 capwidth, capheight;
switch ((CaptureCnt >> 20) & 0x3)
{
case 0: capwidth = 128; capheight = 128; break;
case 1: capwidth = 256; capheight = 64; break;
case 2: capwidth = 256; capheight = 128; break;
case 3: capwidth = 256; capheight = 192; break;
}
if (line < capheight)
DoCapture(line, capwidth, dst);
}
// master brightness // master brightness
if (dispmode != 0) if (dispmode != 0)
{ {

View File

@ -57,6 +57,10 @@
// (the idea is that each position matrix has an associated vector matrix) // (the idea is that each position matrix has an associated vector matrix)
// //
// TODO: check if translate works on the vector matrix? seems pointless // TODO: check if translate works on the vector matrix? seems pointless
//
// viewport Y coordinates are upside-down
//
// clear color/depth/bitmap/etc registers (04000350/04000354) are double-buffered
namespace GPU3D namespace GPU3D
@ -237,6 +241,7 @@ Polygon* RenderPolygonRAM;
u32 RenderNumPolygons; u32 RenderNumPolygons;
u32 ClearAttr1, ClearAttr2; u32 ClearAttr1, ClearAttr2;
u32 RenderClearAttr1, RenderClearAttr2;
u32 FlushRequest; u32 FlushRequest;
u32 FlushAttributes; u32 FlushAttributes;
@ -1634,10 +1639,11 @@ void ExecuteCommand()
break; break;
case 0x60: // viewport x1,y1,x2,y2 case 0x60: // viewport x1,y1,x2,y2
// note: viewport Y coordinates are upside-down
Viewport[0] = ExecParams[0] & 0xFF; Viewport[0] = ExecParams[0] & 0xFF;
Viewport[1] = (ExecParams[0] >> 8) & 0xFF; Viewport[1] = 191 - (ExecParams[0] >> 24);
Viewport[2] = ((ExecParams[0] >> 16) & 0xFF) - Viewport[0] + 1; Viewport[2] = ((ExecParams[0] >> 16) & 0xFF) - Viewport[0] + 1;
Viewport[3] = (ExecParams[0] >> 24) - Viewport[1] + 1; Viewport[3] = (191 - ((ExecParams[0] >> 8) & 0xFF)) - Viewport[1] + 1;
break; break;
case 0x70: // box test case 0x70: // box test
@ -1725,6 +1731,9 @@ void VBlank()
RenderPolygonRAM = CurPolygonRAM; RenderPolygonRAM = CurPolygonRAM;
RenderNumPolygons = NumPolygons; RenderNumPolygons = NumPolygons;
RenderClearAttr1 = ClearAttr1;
RenderClearAttr2 = ClearAttr2;
CurRAMBank = CurRAMBank?0:1; CurRAMBank = CurRAMBank?0:1;
CurVertexRAM = &VertexRAM[CurRAMBank ? 6144 : 0]; CurVertexRAM = &VertexRAM[CurRAMBank ? 6144 : 0];
CurPolygonRAM = &PolygonRAM[CurRAMBank ? 2048 : 0]; CurPolygonRAM = &PolygonRAM[CurRAMBank ? 2048 : 0];

View File

@ -59,7 +59,7 @@ typedef struct
extern u32 DispCnt; extern u32 DispCnt;
extern u32 AlphaRef; extern u32 AlphaRef;
extern s32 Viewport[4]; extern s32 Viewport[4];
extern u32 ClearAttr1, ClearAttr2; extern u32 RenderClearAttr1, RenderClearAttr2;
bool Init(); bool Init();
void DeInit(); void DeInit();

View File

@ -781,12 +781,12 @@ void RenderPolygon(Polygon* polygon)
void RenderFrame(Vertex* vertices, Polygon* polygons, int npolys) void RenderFrame(Vertex* vertices, Polygon* polygons, int npolys)
{ {
u32 polyid = (ClearAttr1 >> 24) & 0x3F; u32 polyid = (RenderClearAttr1 >> 24) & 0x3F;
if (DispCnt & (1<<14)) if (DispCnt & (1<<14))
{ {
u8 xoff = (ClearAttr2 >> 16) & 0xFF; u8 xoff = (RenderClearAttr2 >> 16) & 0xFF;
u8 yoff = (ClearAttr2 >> 24) & 0xFF; u8 yoff = (RenderClearAttr2 >> 24) & 0xFF;
for (int y = 0; y < 256*192; y += 256) for (int y = 0; y < 256*192; y += 256)
{ {
@ -818,16 +818,16 @@ void RenderFrame(Vertex* vertices, Polygon* polygons, int npolys)
else else
{ {
// TODO: confirm color conversion // TODO: confirm color conversion
u32 r = (ClearAttr1 << 1) & 0x3E; if (r) r++; u32 r = (RenderClearAttr1 << 1) & 0x3E; if (r) r++;
u32 g = (ClearAttr1 >> 4) & 0x3E; if (g) g++; u32 g = (RenderClearAttr1 >> 4) & 0x3E; if (g) g++;
u32 b = (ClearAttr1 >> 9) & 0x3E; if (b) b++; u32 b = (RenderClearAttr1 >> 9) & 0x3E; if (b) b++;
u32 a = (ClearAttr1 >> 16) & 0x1F; u32 a = (RenderClearAttr1 >> 16) & 0x1F;
u32 color = r | (g << 8) | (b << 16) | (a << 24); u32 color = r | (g << 8) | (b << 16) | (a << 24);
u32 z = ((ClearAttr2 & 0x7FFF) * 0x200) + 0x1FF; u32 z = ((RenderClearAttr2 & 0x7FFF) * 0x200) + 0x1FF;
if (z >= 0x10000 && z < 0xFFFFFF) z++; if (z >= 0x10000 && z < 0xFFFFFF) z++;
polyid |= ((ClearAttr1 & 0x8000) >> 7); polyid |= ((RenderClearAttr1 & 0x8000) >> 7);
for (int i = 0; i < 256*192; i++) for (int i = 0; i < 256*192; i++)
{ {