mirror of https://github.com/mgba-emu/mgba.git
Turbo mode
This commit is contained in:
parent
190f9b41e6
commit
7c7e934dac
|
@ -143,6 +143,9 @@ struct GBAVideoRenderer {
|
||||||
uint16_t* palette;
|
uint16_t* palette;
|
||||||
uint16_t* vram;
|
uint16_t* vram;
|
||||||
union GBAOAM* oam;
|
union GBAOAM* oam;
|
||||||
|
|
||||||
|
int framesPending;
|
||||||
|
int turbo;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GBAVideo {
|
struct GBAVideo {
|
||||||
|
|
|
@ -26,6 +26,9 @@ void GBAVideoSoftwareRendererCreate(struct GBAVideoSoftwareRenderer* renderer) {
|
||||||
renderer->d.drawScanline = GBAVideoSoftwareRendererDrawScanline;
|
renderer->d.drawScanline = GBAVideoSoftwareRendererDrawScanline;
|
||||||
renderer->d.finishFrame = GBAVideoSoftwareRendererFinishFrame;
|
renderer->d.finishFrame = GBAVideoSoftwareRendererFinishFrame;
|
||||||
|
|
||||||
|
renderer->d.turbo = 0;
|
||||||
|
renderer->d.framesPending = 0;
|
||||||
|
|
||||||
renderer->sortedBg[0] = &renderer->bg[0];
|
renderer->sortedBg[0] = &renderer->bg[0];
|
||||||
renderer->sortedBg[1] = &renderer->bg[1];
|
renderer->sortedBg[1] = &renderer->bg[1];
|
||||||
renderer->sortedBg[2] = &renderer->bg[2];
|
renderer->sortedBg[2] = &renderer->bg[2];
|
||||||
|
@ -170,7 +173,10 @@ static void GBAVideoSoftwareRendererFinishFrame(struct GBAVideoRenderer* rendere
|
||||||
struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer;
|
struct GBAVideoSoftwareRenderer* softwareRenderer = (struct GBAVideoSoftwareRenderer*) renderer;
|
||||||
|
|
||||||
pthread_mutex_lock(&softwareRenderer->mutex);
|
pthread_mutex_lock(&softwareRenderer->mutex);
|
||||||
pthread_cond_wait(&softwareRenderer->cond, &softwareRenderer->mutex);
|
renderer->framesPending++;
|
||||||
|
if (!renderer->turbo) {
|
||||||
|
pthread_cond_wait(&softwareRenderer->cond, &softwareRenderer->mutex);
|
||||||
|
}
|
||||||
pthread_mutex_unlock(&softwareRenderer->mutex);
|
pthread_mutex_unlock(&softwareRenderer->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
src/main.c
10
src/main.c
|
@ -110,8 +110,13 @@ static void _GBASDLRunloop(struct GBAThread* context, struct GLSoftwareRenderer*
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB5, 256, 256, 0, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, renderer->d.outputBuffer);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB5, 256, 256, 0, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, renderer->d.outputBuffer);
|
||||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||||
|
|
||||||
SDL_GL_SwapBuffers();
|
|
||||||
pthread_mutex_lock(&renderer->d.mutex);
|
pthread_mutex_lock(&renderer->d.mutex);
|
||||||
|
if (renderer->d.d.framesPending) {
|
||||||
|
--renderer->d.d.framesPending;
|
||||||
|
pthread_mutex_unlock(&renderer->d.mutex);
|
||||||
|
SDL_GL_SwapBuffers();
|
||||||
|
pthread_mutex_lock(&renderer->d.mutex);
|
||||||
|
}
|
||||||
pthread_cond_broadcast(&renderer->d.cond);
|
pthread_cond_broadcast(&renderer->d.cond);
|
||||||
pthread_mutex_unlock(&renderer->d.mutex);
|
pthread_mutex_unlock(&renderer->d.mutex);
|
||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
|
@ -168,6 +173,9 @@ static void _GBASDLHandleKeypress(struct GBAThread* context, const struct SDL_Ke
|
||||||
case SDLK_RIGHT:
|
case SDLK_RIGHT:
|
||||||
key = GBA_KEY_RIGHT;
|
key = GBA_KEY_RIGHT;
|
||||||
break;
|
break;
|
||||||
|
case SDLK_TAB:
|
||||||
|
context->renderer->turbo = !context->renderer->turbo;
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue