* FPS counter displays target framerate

* fix potential hang and out-of-bounds drawing when VCount is modified during drawing
This commit is contained in:
StapleButter 2017-07-21 10:19:56 +02:00
parent cfb9e20fe1
commit 0df3a29374
5 changed files with 20 additions and 6 deletions

View File

@ -651,8 +651,11 @@ void StartHBlank(u32 line)
{ {
// draw // draw
// note: this should start 48 cycles after the scanline start // note: this should start 48 cycles after the scanline start
GPU2D_A->DrawScanline(line); if (line < 192)
GPU2D_B->DrawScanline(line); {
GPU2D_A->DrawScanline(line);
GPU2D_B->DrawScanline(line);
}
NDS::CheckDMAs(0, 0x02); NDS::CheckDMAs(0, 0x02);
} }

View File

@ -607,6 +607,10 @@ int ClipPolygon(Vertex* vertices, int nverts, int clipstart)
// TODO: check for 1-dot polygons // TODO: check for 1-dot polygons
// TODO: the hardware seems to use a different algorithm. it reacts differently to vertices with W=0 // TODO: the hardware seems to use a different algorithm. it reacts differently to vertices with W=0
// some vertices that should get Y=-0x1000 get Y=0x1000 for some reason on hardware. it doesn't make sense.
// clipping seems to process the Y plane before the X plane.
// also, polygons with any negative W are completely rejected. (TODO)
// X clipping // X clipping
nverts = ClipAgainstPlane<0, attribs>(vertices, nverts, clipstart); nverts = ClipAgainstPlane<0, attribs>(vertices, nverts, clipstart);

View File

@ -1522,8 +1522,7 @@ void ScanlineFinalPass(s32 y)
if (RenderDispCnt & (1<<5)) if (RenderDispCnt & (1<<5))
{ {
// edge marking // edge marking
// only applied to topmost pixels
// TODO: is it applied to bottom pixels?
for (int x = 0; x < 256; x++) for (int x = 0; x < 256; x++)
{ {
@ -1842,7 +1841,10 @@ void RenderThreadFunc()
void RequestLine(int line) void RequestLine(int line)
{ {
if (RenderThreadRunning) if (RenderThreadRunning)
Platform::Semaphore_Wait(Sema_ScanlineCount); {
if (line < 192)
Platform::Semaphore_Wait(Sema_ScanlineCount);
}
} }
u32* GetLine(int line) u32* GetLine(int line)

View File

@ -400,6 +400,7 @@ u32 RunFrame()
s32 ndscyclestorun; s32 ndscyclestorun;
s32 ndscycles = 0; s32 ndscycles = 0;
// TODO: give it some margin, so it can directly do 17 cycles instead of 16 then 1
CalcIterationCycles(); CalcIterationCycles();
if (CPUStop & 0xFFFF) if (CPUStop & 0xFFFF)

View File

@ -496,8 +496,12 @@ wxThread::ExitCode EmuThread::Entry()
u32 fps = (nframes * 1000) / diff; u32 fps = (nframes * 1000) / diff;
nframes = 0; nframes = 0;
float fpstarget;
if (framerate < 1) fpstarget = 999;
else fpstarget = 1000.0f/framerate;
char melontitle[100]; char melontitle[100];
sprintf(melontitle, "%d FPS - melonDS " MELONDS_VERSION, fps); sprintf(melontitle, "%d/%.0f FPS | melonDS " MELONDS_VERSION, fps, fpstarget);
SDL_SetWindowTitle(sdlwin, melontitle); SDL_SetWindowTitle(sdlwin, melontitle);
} }
} }