ok this one actually works

This commit is contained in:
Jaklyy 2023-12-10 19:22:30 -05:00
parent 2bf033e0bc
commit 0d6a8e0fb9
2 changed files with 18 additions and 9 deletions

View File

@ -129,27 +129,36 @@ bool SoftRenderer::DoTimings(s32 cycles, bool odd)
return true; return true;
} }
s32 SoftRenderer::DoTimingsPixels(u32 pixels, bool odd) u32 SoftRenderer::DoTimingsPixels(u32 pixels, bool odd)
{ {
// return the difference between the old span and the new span // return the difference between the old span and the new span
if (pixels <= 4) return 0; if (pixels <= 4) return 0;
u32 pixeltiming = (pixels - 4) * RasterFrac; u32 pixelsremain = pixels-4;
u32 timinglimit = RasterTimingCap - RasterTimingCounterPrev;
//todo: do this without a for loop somehow.
if (odd) if (odd)
{ {
u32 rasterend = RasterTimingCap - (RasterTimingCounterOdd + RasterTimingCounterPrev); for (; pixelsremain > 0; pixelsremain--)
pixeltiming = rasterend - pixeltiming; {
RasterTimingCounterOdd += RasterFrac;
if (RasterTimingCounterOdd >= timinglimit) break;
}
} }
else else
{ {
u32 rasterend = RasterTimingCap - (RasterTimingCounterEven + RasterTimingCounterPrev); for (; pixelsremain > 0; pixelsremain--)
pixeltiming = rasterend - pixeltiming; {
RasterTimingCounterEven += RasterFrac;
if (RasterTimingCounterEven >= timinglimit) break;
}
} }
if (pixeltiming > 0) return 0;
if (pixelsremain <= 0) return 0;
GPU.GPU3D.DispCnt |= (1<<12); GPU.GPU3D.DispCnt |= (1<<12);
return pixels - (((pixeltiming + (RasterFrac-1)) / RasterFrac) + 4); return pixelsremain;
} }
void SoftRenderer::EndScanline(bool odd) void SoftRenderer::EndScanline(bool odd)

View File

@ -455,7 +455,7 @@ private:
melonDS::GPU& GPU; melonDS::GPU& GPU;
RendererPolygon PolygonList[2048]; RendererPolygon PolygonList[2048];
bool DoTimings(s32 cycles, bool odd); bool DoTimings(s32 cycles, bool odd);
s32 DoTimingsPixels(u32 pixels, bool odd); u32 DoTimingsPixels(u32 pixels, bool odd);
void EndScanline(bool odd); void EndScanline(bool odd);
void TextureLookup(u32 texparam, u32 texpal, s16 s, s16 t, u16* color, u8* alpha); void TextureLookup(u32 texparam, u32 texpal, s16 s, s16 t, u16* color, u8* alpha);
u32 RenderPixel(Polygon* polygon, u8 vr, u8 vg, u8 vb, s16 s, s16 t); u32 RenderPixel(Polygon* polygon, u8 vr, u8 vg, u8 vb, s16 s, s16 t);