aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRSDuck <RSDuck@users.noreply.github.com>2021-08-04 14:21:45 +0200
committerRSDuck <RSDuck@users.noreply.github.com>2021-08-04 14:21:45 +0200
commitf792d3e6a1cf563967823884da3fe5ef41086cb5 (patch)
treeb526803ee12021d382f8010081c2dd592ee3dc90 /src
parentf86ba0fcb34254151e512a4f30b358c489c182bb (diff)
handle changed VCount+threaded rasteriser more gracefully
Diffstat (limited to 'src')
-rw-r--r--src/GPU.cpp7
-rw-r--r--src/GPU3D.cpp43
-rw-r--r--src/GPU3D.h2
3 files changed, 37 insertions, 15 deletions
diff --git a/src/GPU.cpp b/src/GPU.cpp
index cbd1343..de229b3 100644
--- a/src/GPU.cpp
+++ b/src/GPU.cpp
@@ -1061,6 +1061,12 @@ void FinishFrame(u32 lines)
AssignFramebuffers();
TotalScanlines = lines;
+
+ if (GPU3D::AbortFrame)
+ {
+ GPU3D::RestartFrame();
+ GPU3D::AbortFrame = false;
+ }
}
void StartScanline(u32 line)
@@ -1180,6 +1186,7 @@ void SetVCount(u16 val)
// 3D engine seems to give up on the current frame in that situation, repeating the last two scanlines
// TODO: also check the various DMA types that can be involved
+ GPU3D::AbortFrame |= NextVCount != val;
NextVCount = val;
}
diff --git a/src/GPU3D.cpp b/src/GPU3D.cpp
index fa1f576..9c02b2f 100644
--- a/src/GPU3D.cpp
+++ b/src/GPU3D.cpp
@@ -275,6 +275,8 @@ u32 FlushAttributes;
std::unique_ptr<GPU3D::Renderer3D> CurrentRenderer = {};
+bool AbortFrame;
+
bool Init()
{
return true;
@@ -380,6 +382,8 @@ void Reset()
ResetRenderingState();
RenderXPos = 0;
+
+ AbortFrame = false;
}
void DoSavestate(Savestate* file)
@@ -621,6 +625,8 @@ void DoSavestate(Savestate* file)
file->Bool32(&UseShininessTable);
file->VarArray(ShininessTable, 128*sizeof(u8));
+
+ file->Bool32(&AbortFrame);
}
@@ -2611,27 +2617,34 @@ u32 ScrolledLine[256];
u32* GetLine(int line)
{
- u32* rawline = CurrentRenderer->GetLine(line);
+ if (!AbortFrame)
+ {
+ u32* rawline = CurrentRenderer->GetLine(line);
- if (RenderXPos == 0) return rawline;
+ if (RenderXPos == 0) return rawline;
- // apply X scroll
+ // apply X scroll
- if (RenderXPos & 0x100)
- {
- int i = 0, j = RenderXPos;
- for (; j < 512; i++, j++)
- ScrolledLine[i] = 0;
- for (j = 0; i < 256; i++, j++)
- ScrolledLine[i] = rawline[j];
+ if (RenderXPos & 0x100)
+ {
+ int i = 0, j = RenderXPos;
+ for (; j < 512; i++, j++)
+ ScrolledLine[i] = 0;
+ for (j = 0; i < 256; i++, j++)
+ ScrolledLine[i] = rawline[j];
+ }
+ else
+ {
+ int i = 0, j = RenderXPos;
+ for (; j < 256; i++, j++)
+ ScrolledLine[i] = rawline[j];
+ for (; i < 256; i++)
+ ScrolledLine[i] = 0;
+ }
}
else
{
- int i = 0, j = RenderXPos;
- for (; j < 256; i++, j++)
- ScrolledLine[i] = rawline[j];
- for (; i < 256; i++)
- ScrolledLine[i] = 0;
+ memset(ScrolledLine, 0, 256*4);
}
return ScrolledLine;
diff --git a/src/GPU3D.h b/src/GPU3D.h
index b243286..23f55eb 100644
--- a/src/GPU3D.h
+++ b/src/GPU3D.h
@@ -97,6 +97,8 @@ extern u16 RenderXPos;
extern std::array<Polygon*,2048> RenderPolygonRAM;
extern u32 RenderNumPolygons;
+extern bool AbortFrame;
+
extern u64 Timestamp;
bool Init();