improve when 3d dispcnt underflow flag updates

This commit is contained in:
Jaklyy 2024-04-19 12:56:38 -04:00
parent 520f7a0f3a
commit 1c24fe03c2
4 changed files with 16 additions and 12 deletions

View file

@ -1002,6 +1002,13 @@ void GPU::StartScanline(u32 line) noexcept
NDS.ScheduleEvent(Event_DisplayFIFO, false, 32, 0, 0);
}
if (VCount == GPU3D.UnderflowFlagVCount)
{
// appears to get set the vcount before the underflow occured?
// probably gets updated the instant the underflow happened, which might be annoying to work out with precision.
GPU3D.DispCnt |= (1<<12);
}
if (VCount == 262)
{
// frame end
@ -1017,7 +1024,7 @@ void GPU::StartScanline(u32 line) noexcept
// and games might already start to modify texture memory.
// That doesn't matter for us because we cache the entire
// texture memory anyway and only update it before the start
//of the next frame.
// of the next frame.
// So we can give the rasteriser a bit more headroom
GPU3D.VCount144(*this);
@ -1041,10 +1048,6 @@ void GPU::StartScanline(u32 line) noexcept
if (GPU3D.IsRendererAccelerated())
GPU3D.Blit(*this);
}
else if (VCount == 183)
{
GPU3D.DispCnt |= GPU3D.RDLinesUnderflow << 12; // CHECKME: does this get set *exactly* at vcount 183? earlier? later?
}
}
NDS.ScheduleEvent(Event_LCD, true, HBLANK_CYCLES, LCD_StartHBlank, line);

View file

@ -255,7 +255,8 @@ void GPU3D::Reset() noexcept
ClearAttr2 = 0x00007FFF;
ResetRenderingState();
UnderflowFlagVCount = -1;
RDLines = 63;
AbortFrame = false;

View file

@ -251,7 +251,7 @@ public:
u32 DispCnt = 0;
bool RDLinesUnderflow = false;
u16 UnderflowFlagVCount = 0;
u8 RDLines = 0;
u8 RDLinesTemp = 0;

View file

@ -228,16 +228,16 @@ void SoftRenderer::FindFirstPolyDoTimings(int npolys, s32 y, int* firstpolyeven,
}
*timingcountereven = fixeddelay*FirstPolyDelay;// + perslope*FirstPerSlope + etc*2;
*timingcounterodd = fixeddelay*FirstPolyDelay;/// + perslope*FirstPerSlope + etc*2;
*timingcounterodd = fixeddelay*FirstPolyDelay;// + perslope*FirstPerSlope + etc*2;
if (!perslope)
{
*timingcountereven += etc*2;// + perslope*FirstPerSlope + etc*2;
*timingcounterodd += etc*2;/// + perslope*FirstPerSlope + etc*2;
*timingcounterodd += etc*2;// + perslope*FirstPerSlope + etc*2;
}
else
{
*timingcountereven += perslope*FirstPerSlope;// + perslope*FirstPerSlope + etc*2;
*timingcounterodd += perslope*FirstPerSlope;/// + perslope*FirstPerSlope + etc*2;
*timingcounterodd += perslope*FirstPerSlope;// + perslope*FirstPerSlope + etc*2;
}
}
@ -1959,7 +1959,7 @@ void SoftRenderer::FinishPushScanline(s32 y, s32 pixelsremain)
RasterTiming += std::clamp(ScanlineTimeout - RasterTiming, 0, 12);\
\
/* set the underflow flag if one of the scanlines came within 14 cycles of visible underflow */\
if (ScanlineTimeout <= RasterTiming) gpu.GPU3D.RDLinesUnderflow = true;
if ((ScanlineTimeout <= RasterTiming) && (gpu.GPU3D.UnderflowFlagVCount == (u16)-1)) gpu.GPU3D.UnderflowFlagVCount = y-1;
void SoftRenderer::RenderPolygonsFast(GPU& gpu, Polygon** polygons, int npolys)
{
@ -1992,7 +1992,7 @@ void SoftRenderer::RenderPolygonsTiming(GPU& gpu, Polygon** polygons, int npolys
}
// reset scanline trackers
gpu.GPU3D.RDLinesUnderflow = false;
gpu.GPU3D.UnderflowFlagVCount = -1;
gpu.GPU3D.RDLinesTemp = 63;
ScanlineTimeout = FrameLength; // CHECKME
s32 rastertimingeven, rastertimingodd; // always init to 0 at the start of a scanline render