Skip to content

Commit 3930914

Browse files
committed
SDL: Remove forced 60fps cap on the interface's side.
Some apps and benchmarks can go over 60fps, which was completely by sdl_interface that only drew frames at 60fps forcibly. We already have a pretty decent frame limiter on the Java side of things now, so we can up the SDL side to 1000fps and enjoy faster/smoother apps in the rare cases where they support it.
1 parent c7377c9 commit 3930914

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

Diff for: src/sdl2/anbu.cpp

+9-7
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ double overlayScale = 1;
5454
int lastTime = 0;
5555

5656
SDL_Renderer *mRenderer;
57-
SDL_Texture *mBackground;
5857
SDL_Texture *mOverlay;
5958
SDL_Texture *mTexture;
6059
SDL_Window *mWindow;
@@ -173,7 +172,7 @@ void initKeys(bool fromConfig)
173172
// There are only 17 emulated functions right now
174173
for(int key = 0; key < 17; key++)
175174
{
176-
if(fromConfig)
175+
if(fromConfig) // TODO: This should load keys from a SDL-Specific config file
177176
{
178177

179178
}
@@ -360,18 +359,21 @@ bool updateFrame(size_t numChars, unsigned char* buffer, FILE* input = stdin)
360359
return read_count == numChars;
361360
}
362361

363-
void drawFrame(unsigned char *frame, size_t pitch, SDL_Rect& dest, int angle, int interFrame = 16)
362+
void drawFrame(unsigned char *frame, size_t pitch, SDL_Rect& dest, int angle)
364363
{
365-
// Cutoff rendering at 60fps
366-
if (SDL_GetTicks() - lastTime < interFrame) {
364+
/*
365+
* Let's refrain from doing unnecessary stuff here, display at maximum of
366+
* 1000 fps (1ms frametime), which is far more than most J2ME apps will
367+
* reach anyway, aside from certain benchmarks.
368+
*/
369+
if (SDL_GetTicks() - lastTime < 1) {
367370
return;
368371
}
369372

370373
lastTime = SDL_GetTicks();
371374

372375
SDL_RenderClear(mRenderer);
373376
SDL_UpdateTexture(mTexture, NULL, frame, pitch);
374-
SDL_RenderCopyEx(mRenderer, mBackground, NULL, NULL, 0, NULL, SDL_FLIP_NONE);
375377
SDL_RenderCopyEx(mRenderer, mTexture, NULL, &dest, angle, NULL, SDL_FLIP_NONE);
376378
SDL_RenderCopyEx(mRenderer, mOverlay, NULL, &dest, angle, NULL, SDL_FLIP_NONE);
377379
SDL_RenderPresent(mRenderer);
@@ -438,7 +440,7 @@ void init(Uint8 r = 0, Uint8 g = 0, Uint8 b = 0)
438440

439441
loadDisplayDimensions();
440442

441-
if(false) // This will check for the presence of a SDL-specific config file for input mappings and other game-independent stuff
443+
if(false) // TODO: This will check for the presence of a SDL-specific config file for input mappings and other game-independent stuff
442444
{
443445

444446
}

0 commit comments

Comments
 (0)