diff --git a/CHANGES b/CHANGES index d322f1aca..e1764c314 100644 --- a/CHANGES +++ b/CHANGES @@ -58,6 +58,7 @@ Other fixes: - Debugger: Close trace log when done tracing - FFmpeg: Fix some small memory leaks - FFmpeg: Fix encoding of time base + - GB Video: Fix SGB video logs - mGUI: Don't attempt to preload files larger than can fit in RAM - Qt: Force OpenGL paint engine creation thread (fixes mgba.io/i/1642) - Qt: Fix static compilation in MinGW (fixes mgba.io/i/1769) diff --git a/include/mgba/internal/gb/serialize.h b/include/mgba/internal/gb/serialize.h index c7d1532be..b3cde1661 100644 --- a/include/mgba/internal/gb/serialize.h +++ b/include/mgba/internal/gb/serialize.h @@ -437,6 +437,9 @@ struct GBSerializedState { bool GBDeserialize(struct GB* gb, const struct GBSerializedState* state); void GBSerialize(struct GB* gb, struct GBSerializedState* state); +void GBSGBSerialize(struct GB* gb, struct GBSerializedState* state); +void GBSGBDeserialize(struct GB* gb, const struct GBSerializedState* state); + CXX_GUARD_END #endif diff --git a/src/gb/core.c b/src/gb/core.c index cddd3104f..f0dbac0ba 100644 --- a/src/gb/core.c +++ b/src/gb/core.c @@ -1163,6 +1163,9 @@ static bool _GBVLPLoadState(struct mCore* core, const void* buffer) { GBVideoDeserialize(&gb->video, state); GBIODeserialize(gb, state); GBAudioReset(&gb->audio); + if (gb->model & GB_MODEL_SGB) { + GBSGBDeserialize(gb, state); + } // Make sure CPU loop never spins gb->memory.ie = 0; diff --git a/src/gb/extra/proxy.c b/src/gb/extra/proxy.c index 29be8af49..cea273692 100644 --- a/src/gb/extra/proxy.c +++ b/src/gb/extra/proxy.c @@ -102,6 +102,12 @@ void GBVideoProxyRendererShim(struct GBVideo* video, struct GBVideoProxyRenderer renderer->backend = video->renderer; video->renderer = &renderer->d; renderer->d.cache = renderer->backend->cache; + renderer->d.sgbRenderMode = renderer->backend->sgbRenderMode; + renderer->d.sgbCharRam = renderer->backend->sgbCharRam; + renderer->d.sgbMapRam = renderer->backend->sgbMapRam; + renderer->d.sgbPalRam = renderer->backend->sgbPalRam; + renderer->d.sgbAttributeFiles = renderer->backend->sgbAttributeFiles; + renderer->d.sgbAttributes = renderer->backend->sgbAttributes; renderer->d.vram = video->vram; renderer->d.oam = &video->oam; _init(renderer); diff --git a/src/gb/serialize.c b/src/gb/serialize.c index 04060d641..056d1fd77 100644 --- a/src/gb/serialize.c +++ b/src/gb/serialize.c @@ -16,9 +16,6 @@ mLOG_DEFINE_CATEGORY(GB_STATE, "GB Savestate", "gb.serialize"); const uint32_t GB_SAVESTATE_MAGIC = 0x00400000; const uint32_t GB_SAVESTATE_VERSION = 0x00000002; -static void GBSGBSerialize(struct GB* gb, struct GBSerializedState* state); -static void GBSGBDeserialize(struct GB* gb, const struct GBSerializedState* state); - void GBSerialize(struct GB* gb, struct GBSerializedState* state) { STORE_32LE(GB_SAVESTATE_MAGIC + GB_SAVESTATE_VERSION, 0, &state->versionMagic); STORE_32LE(gb->romCrc32, 0, &state->romCrc32);