bench mode (disabled by default)

This commit is contained in:
Sigrid Solveig Haflínudóttir 2021-05-19 07:29:00 +00:00
parent ea0584a249
commit 74e8a59d2f
1 changed files with 8 additions and 4 deletions

View File

@ -26,7 +26,7 @@ static Apu apu[POLYPHONY];
static Mpu mpu; static Mpu mpu;
static Device *devscreen, *devmouse, *devctrl, *devmidi, *devaudio0; static Device *devscreen, *devmouse, *devctrl, *devmidi, *devaudio0;
Uint8 zoom = 0, debug = 0, reqdraw = 0; Uint8 zoom = 0, debug = 0, reqdraw = 0, bench = 0;
int int
clamp(int val, int min, int max) clamp(int val, int min, int max)
@ -323,7 +323,9 @@ start(Uxn *u)
while(1) { while(1) {
int i; int i;
SDL_Event event; SDL_Event event;
double elapsed, start = SDL_GetPerformanceCounter(); double elapsed, start;
if(!bench)
start = SDL_GetPerformanceCounter();
while(SDL_PollEvent(&event) != 0) { while(SDL_PollEvent(&event) != 0) {
switch(event.type) { switch(event.type) {
case SDL_QUIT: case SDL_QUIT:
@ -360,8 +362,10 @@ start(Uxn *u)
evaluxn(u, mempeek16(devscreen->dat, 0)); evaluxn(u, mempeek16(devscreen->dat, 0));
if(reqdraw) if(reqdraw)
redraw(ppu.output, u); redraw(ppu.output, u);
elapsed = (SDL_GetPerformanceCounter() - start) / (double)SDL_GetPerformanceFrequency() * 1000.0f; if(!bench){
SDL_Delay(clamp(16.666f - elapsed, 0, 1000)); elapsed = (SDL_GetPerformanceCounter() - start) / (double)SDL_GetPerformanceFrequency() * 1000.0f;
SDL_Delay(clamp(16.666f - elapsed, 0, 1000));
}
} }
return 1; return 1;
} }