diff --git a/src/gb/core.c b/src/gb/core.c index ebbacbfd2..e54db230f 100644 --- a/src/gb/core.c +++ b/src/gb/core.c @@ -63,8 +63,8 @@ static const struct mCoreMemoryBlock _GBCMemoryBlocks[] = { struct mVideoLogContext; struct GBCore { struct mCore d; - struct GBVideoSoftwareRenderer renderer; struct GBVideoRenderer dummyRenderer; + struct GBVideoSoftwareRenderer renderer; #ifndef MINIMAL_CORE struct GBVideoProxyRenderer proxyRenderer; struct mVideoLogContext* logContext; @@ -104,6 +104,9 @@ static bool _GBCoreInit(struct mCore* core) { mRTCGenericSourceInit(&core->rtc, core); gb->memory.rtc = &core->rtc.d; + GBVideoDummyRendererCreate(&gbcore->dummyRenderer); + GBVideoAssociateRenderer(&gb->video, &gbcore->dummyRenderer); + GBVideoSoftwareRendererCreate(&gbcore->renderer); gbcore->renderer.outputBuffer = NULL; @@ -420,9 +423,6 @@ static void _GBCoreReset(struct mCore* core) { struct GB* gb = (struct GB*) core->board; if (gbcore->renderer.outputBuffer) { GBVideoAssociateRenderer(&gb->video, &gbcore->renderer.d); - } else { - GBVideoDummyRendererCreate(&gbcore->dummyRenderer); - GBVideoAssociateRenderer(&gb->video, &gbcore->dummyRenderer); } if (gb->memory.rom) { diff --git a/src/gba/core.c b/src/gba/core.c index c1aa5b047..f78786562 100644 --- a/src/gba/core.c +++ b/src/gba/core.c @@ -129,8 +129,8 @@ struct mVideoLogContext; struct GBACore { struct mCore d; - struct GBAVideoSoftwareRenderer renderer; struct GBAVideoRenderer dummyRenderer; + struct GBAVideoSoftwareRenderer renderer; #if defined(BUILD_GLES2) || defined(BUILD_GLES3) struct GBAVideoGLRenderer glRenderer; #endif @@ -183,6 +183,9 @@ static bool _GBACoreInit(struct mCore* core) { mRTCGenericSourceInit(&core->rtc, core); gba->rtcSource = &core->rtc.d; + GBAVideoDummyRendererCreate(&gbacore->dummyRenderer); + GBAVideoAssociateRenderer(&gba->video, &gbacore->dummyRenderer); + GBAVideoSoftwareRendererCreate(&gbacore->renderer); gbacore->renderer.outputBuffer = NULL; @@ -383,11 +386,9 @@ static void _GBACoreReloadConfigOption(struct mCore* core, const char* option, c renderer = &gbacore->proxyRenderer.d; } #endif - if (!renderer) { - renderer = &gbacore->dummyRenderer; - GBAVideoDummyRendererCreate(renderer); + if (renderer) { + GBAVideoAssociateRenderer(&gba->video, renderer); } - GBAVideoAssociateRenderer(&gba->video, renderer); } } @@ -545,40 +546,43 @@ static void _GBACoreChecksum(const struct mCore* core, void* data, enum mCoreChe static void _GBACoreReset(struct mCore* core) { struct GBACore* gbacore = (struct GBACore*) core; struct GBA* gba = (struct GBA*) core->board; - struct GBAVideoRenderer* renderer = NULL; - if (gbacore->renderer.outputBuffer) { - renderer = &gbacore->renderer.d; - } - int fakeBool ATTRIBUTE_UNUSED; + if (gbacore->renderer.outputBuffer #if defined(BUILD_GLES2) || defined(BUILD_GLES3) - if (gbacore->glRenderer.outputTex != (unsigned) -1 && mCoreConfigGetIntValue(&core->config, "hwaccelVideo", &fakeBool) && fakeBool) { - mCoreConfigGetIntValue(&core->config, "videoScale", &gbacore->glRenderer.scale); - renderer = &gbacore->glRenderer.d; - } else { - gbacore->glRenderer.scale = 1; - } + || gbacore->glRenderer.outputTex != (unsigned) -1 +#endif + ) { + struct GBAVideoRenderer* renderer = NULL; + if (gbacore->renderer.outputBuffer) { + renderer = &gbacore->renderer.d; + } + int fakeBool ATTRIBUTE_UNUSED; +#if defined(BUILD_GLES2) || defined(BUILD_GLES3) + if (gbacore->glRenderer.outputTex != (unsigned) -1 && mCoreConfigGetIntValue(&core->config, "hwaccelVideo", &fakeBool) && fakeBool) { + mCoreConfigGetIntValue(&core->config, "videoScale", &gbacore->glRenderer.scale); + renderer = &gbacore->glRenderer.d; + } else { + gbacore->glRenderer.scale = 1; + } #endif #ifndef DISABLE_THREADING - if (mCoreConfigGetIntValue(&core->config, "threadedVideo", &fakeBool) && fakeBool) { - if (!core->videoLogger) { - core->videoLogger = &gbacore->threadProxy.d; + if (mCoreConfigGetIntValue(&core->config, "threadedVideo", &fakeBool) && fakeBool) { + if (!core->videoLogger) { + core->videoLogger = &gbacore->threadProxy.d; + } } - } #endif #ifndef MINIMAL_CORE - if (renderer && core->videoLogger) { - gbacore->proxyRenderer.logger = core->videoLogger; - GBAVideoProxyRendererCreate(&gbacore->proxyRenderer, renderer); - renderer = &gbacore->proxyRenderer.d; - } + if (renderer && core->videoLogger) { + gbacore->proxyRenderer.logger = core->videoLogger; + GBAVideoProxyRendererCreate(&gbacore->proxyRenderer, renderer); + renderer = &gbacore->proxyRenderer.d; + } #endif - if (!renderer) { - renderer = &gbacore->dummyRenderer; - GBAVideoDummyRendererCreate(renderer); + if (renderer) { + GBAVideoAssociateRenderer(&gba->video, renderer); + } } - GBAVideoAssociateRenderer(&gba->video, renderer); - #ifndef MINIMAL_CORE int useAudioMixer; if (!gbacore->audioMixer && mCoreConfigGetIntValue(&core->config, "gba.audioHle", &useAudioMixer) && useAudioMixer) {