Package: release.debian.org Severity: normal User: release.debian....@packages.debian.org Usertags: unblock
Hi, I would like to upload mgba with the following changes: - fix undefined references in libretro-mgba (breaks using it with gnome-games-app; RC bug #986986); - backport some targeted fixes specifically requested by upstream for the version in bullseye. This is a pre-approval request, so that I can easily drop any patches that might not be approved for bullseye. Details about the changes: > * Add upstream patches to remove unused OpenGL code from the libretro core > and fix its undefined references. (Closes: #986986) > - debian/patches/CMake-Move-gl.c-and-gles2.c-to-FEATURE_SRC.patch > - debian/patches/CMake-Move-BUILD_GL-flags-to-FEATURE_DEFINES.patch - issue: mgba_libretro.so has undefined references which are not satisfied when retro-runner loads it. I opened #986986 with severity: important and Adrian Bunk recently bumped it to serious. - impact: libretro-mgba cannot be used with gnome-games-app (it does work with retroarch which provides the symbols by coincidence) - the relevant opengl code is not used in the libretro build, so not linking the library is intentional - I proposed cherry-picking these commits, upstream reviewed and approved - I compared build logs with and without the patches: - checked that the libretro build dropped the expected sources and defines; - checked that the other modules don't show any unexpected changes in the log; - the dpkg-shlibdeps warning about unresolved symbols also went away. - I verified the fix with gnome-games-app, and smoke tested retroarch as well. > * Add upstream patch to fix PC alignment check when loading a save state. > - debian/patches/GBA-Serialize-Fix-alignment-check-when-loading-state.patch - upstream specifically requested this as an important fix - issue: when loading a save state (equivalent to a VM snapshot), the CPU mode (ARM/Thumb) is checked in the wrong place - impact: if the saved state was in Thumb mode and at an odd offset, it can incorrectly truncate the emulated CPU's PC to 4-byte alignment (effectively setting it back by one instruction), causing undefined behaviour depending on the code being executed - with a little more context, the patch looks "obviously correct" as executionMode is actually initialized based on cpsr just a few lines later -- https://github.com/mgba-emu/mgba/blob/346f5dc0b53afa8ea1e11d8c94a0090b5d49abc9/src/gba/serialize.c#L157-L168 - original upstream report: https://github.com/libretro/mgba/issues/222 > * Add upstream patch to fix crash when unloading a Game Boy ROM in a > libretro frontend that doesn't implement the camera interface. > - debian/patches/Libretro-Only-set-camera-peripheral-when-it-is-avail.patch - upstream requested this, but noted it as less important - issue: if libretro-mgba is loaded in a libretro frontend that doesn't support the camera interface, it dereferences a NULL pointer when unloading a Game Boy ROM. - impact: gnome-games-app is an example of an affected frontend. After playing a Game Boy game in gnome-games-app, retro-runner SEGVs when closing it (observed in dmesg, gnome-games-app doesn't seem to raise a user-visible error in this case). retroarch is not affected. I am not aware of other frontends in Debian and I'm not sure what other frontends exist in the wild. > * Add upstream patches to fix crashes identified by fuzz testing. - the following are targeted fixes for issues identified by upstream via fuzz testing, that can cause crashes when loading invalid files such as ROM images or save states > - debian/patches/Core-Fix-destroying-an-mVL-with-an-invalid-channel-c.patch - upstream requested this as an important fix, leads to an invalid free() > - debian/patches/GB-MBC-Remove-unused-SRAM-size.patch - upstream requested this as an important fix, leads to possible out-of-bounds read/write because other code assumes the sramSize is a multiple of 8KiB (0x2000) and could access outside the area allocated for the smaller size > - debian/patches/GB-MBC-Force-minimum-SRAM-size-on-rare-MBCs-that-alw.patch > - debian/patches/GB-Video-Don-t-rendering-negative-batches.patch > - debian/patches/GB-Video-Fix-deserializing-negative-LX-state.patch > - debian/patches/GB-Video-Discard-SGB-packets-in-non-SGB-mVLs.patch - upstream requested all of these, but noted them as less important than the two above, these ones generally lead to null pointer dereferences The package does not have automated tests yet, sorry. I have manually tested both packaged frontends (SDL and Qt) as well as the libretro core using both retroarch and gnome-games-app. The full diff is attached. May I upload it to unstable? Thank you, Ryan
diff -Nru mgba-0.8.4+dfsg/debian/changelog mgba-0.8.4+dfsg/debian/changelog --- mgba-0.8.4+dfsg/debian/changelog 2020-11-01 18:31:10.000000000 -0800 +++ mgba-0.8.4+dfsg/debian/changelog 2021-04-20 18:31:14.000000000 -0700 @@ -1,3 +1,24 @@ +mgba (0.8.4+dfsg-2) UNRELEASED; urgency=medium + + * Add upstream patches to remove unused OpenGL code from the libretro core + and fix its undefined references. (Closes: #986986) + - debian/patches/CMake-Move-gl.c-and-gles2.c-to-FEATURE_SRC.patch + - debian/patches/CMake-Move-BUILD_GL-flags-to-FEATURE_DEFINES.patch + * Add upstream patch to fix PC alignment check when loading a save state. + - debian/patches/GBA-Serialize-Fix-alignment-check-when-loading-state.patch + * Add upstream patch to fix crash when unloading a Game Boy ROM in a + libretro frontend that doesn't implement the camera interface. + - debian/patches/Libretro-Only-set-camera-peripheral-when-it-is-avail.patch + * Add upstream patches to fix crashes identified by fuzz testing. + - debian/patches/Core-Fix-destroying-an-mVL-with-an-invalid-channel-c.patch + - debian/patches/GB-MBC-Remove-unused-SRAM-size.patch + - debian/patches/GB-MBC-Force-minimum-SRAM-size-on-rare-MBCs-that-alw.patch + - debian/patches/GB-Video-Don-t-rendering-negative-batches.patch + - debian/patches/GB-Video-Fix-deserializing-negative-LX-state.patch + - debian/patches/GB-Video-Discard-SGB-packets-in-non-SGB-mVLs.patch + + -- Ryan Tandy <r...@nardis.ca> Tue, 20 Apr 2021 18:31:14 -0700 + mgba (0.8.4+dfsg-1) unstable; urgency=medium * New upstream release. diff -Nru mgba-0.8.4+dfsg/debian/patches/CMake-Move-BUILD_GL-flags-to-FEATURE_DEFINES.patch mgba-0.8.4+dfsg/debian/patches/CMake-Move-BUILD_GL-flags-to-FEATURE_DEFINES.patch --- mgba-0.8.4+dfsg/debian/patches/CMake-Move-BUILD_GL-flags-to-FEATURE_DEFINES.patch 1969-12-31 16:00:00.000000000 -0800 +++ mgba-0.8.4+dfsg/debian/patches/CMake-Move-BUILD_GL-flags-to-FEATURE_DEFINES.patch 2021-04-20 18:31:14.000000000 -0700 @@ -0,0 +1,56 @@ +From 2e2ad705500f0f52769c14b6f9722def9057633c Mon Sep 17 00:00:00 2001 +From: Vicki Pfau <v...@endrift.com> +Date: Wed, 25 Nov 2020 21:16:30 -0800 +Subject: [PATCH] CMake: Move BUILD_GL flags to FEATURE_DEFINES + +--- + CMakeLists.txt | 15 +++------------ + 1 file changed, 3 insertions(+), 12 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 16c44c14c..49ca879d1 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -457,17 +457,20 @@ if(NOT BUILD_GLES2) + endif() + if(BUILD_GL) + list(APPEND FEATURE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gl.c) ++ list(APPEND FEATURE_DEFINES BUILD_GL) + list(APPEND DEPENDENCY_LIB ${OPENGL_LIBRARY}) + include_directories(${OPENGL_INCLUDE_DIR}) + endif() + if(BUILD_GLES2) + list(APPEND FEATURE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gles2.c) ++ list(APPEND FEATURE_DEFINES BUILD_GLES2) + list(APPEND DEPENDENCY_LIB ${OPENGLES2_LIBRARY}) + include_directories(${OPENGLES2_INCLUDE_DIR}) + endif() + if(BUILD_GLES3) + find_path(OPENGLES3_INCLUDE_DIR NAMES GLES3/gl3.h) + find_library(OPENGLES3_LIBRARY NAMES GLESv3 GLESv2) ++ list(APPEND FEATURE_DEFINES BUILD_GLES3) + if(NOT OPENGLES3_INCLUDE_DIR OR NOT OPENGLES3_LIBRARY) + set(BUILD_GLES3 OFF CACHE BOOL "OpenGL|ES 3 not found" FORCE) + endif() +@@ -912,18 +915,6 @@ else() + endif() + endif() + +-if(BUILD_GL) +- add_definitions(-DBUILD_GL) +-endif() +- +-if(BUILD_GLES2) +- add_definitions(-DBUILD_GLES2) +-endif() +- +-if(BUILD_GLES3) +- add_definitions(-DBUILD_GLES3) +-endif() +- + if(DISABLE_FRONTENDS) + set(BUILD_SDL OFF) + set(BUILD_QT OFF) +-- +2.20.1 + diff -Nru mgba-0.8.4+dfsg/debian/patches/CMake-Move-gl.c-and-gles2.c-to-FEATURE_SRC.patch mgba-0.8.4+dfsg/debian/patches/CMake-Move-gl.c-and-gles2.c-to-FEATURE_SRC.patch --- mgba-0.8.4+dfsg/debian/patches/CMake-Move-gl.c-and-gles2.c-to-FEATURE_SRC.patch 1969-12-31 16:00:00.000000000 -0800 +++ mgba-0.8.4+dfsg/debian/patches/CMake-Move-gl.c-and-gles2.c-to-FEATURE_SRC.patch 2021-04-20 18:31:14.000000000 -0700 @@ -0,0 +1,56 @@ +From a1c0318290b52302d919c33ce71763fc90353e4f Mon Sep 17 00:00:00 2001 +From: Vicki Pfau <v...@endrift.com> +Date: Tue, 24 Nov 2020 22:26:45 -0800 +Subject: [PATCH] CMake: Move gl.c and gles2.c to FEATURE_SRC + +--- + CMakeLists.txt | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index a0912d7f8..16c44c14c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -423,6 +423,7 @@ endif() + # Feature dependencies + set(FEATURE_DEFINES) + set(FEATURE_FLAGS) ++set(FEATURE_SRC) + set(FEATURES) + set(ENABLES) + if(CMAKE_SYSTEM_NAME MATCHES ".*BSD|DragonFly") +@@ -455,12 +456,12 @@ if(NOT BUILD_GLES2) + set(OPENGLES2_LIBRARY "" CACHE PATH "" FORCE) + endif() + if(BUILD_GL) +- list(APPEND OS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gl.c) ++ list(APPEND FEATURE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gl.c) + list(APPEND DEPENDENCY_LIB ${OPENGL_LIBRARY}) + include_directories(${OPENGL_INCLUDE_DIR}) + endif() + if(BUILD_GLES2) +- list(APPEND OS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gles2.c) ++ list(APPEND FEATURE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gles2.c) + list(APPEND DEPENDENCY_LIB ${OPENGLES2_LIBRARY}) + include_directories(${OPENGLES2_INCLUDE_DIR}) + endif() +@@ -515,7 +516,6 @@ endif() + add_subdirectory(src/debugger) + add_subdirectory(src/feature) + +-set(FEATURE_SRC) + set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6") + + if(USE_EDITLINE) +@@ -715,7 +715,7 @@ if (USE_LZMA) + endif() + + if(USE_EPOXY) +- list(APPEND OS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gl.c ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gles2.c) ++ list(APPEND FEATURE_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gl.c ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/opengl/gles2.c) + add_definitions(-DBUILD_GL -DBUILD_GLES2) + list(APPEND FEATURES EPOXY) + include_directories(AFTER ${EPOXY_INCLUDE_DIRS}) +-- +2.20.1 + diff -Nru mgba-0.8.4+dfsg/debian/patches/Core-Fix-destroying-an-mVL-with-an-invalid-channel-c.patch mgba-0.8.4+dfsg/debian/patches/Core-Fix-destroying-an-mVL-with-an-invalid-channel-c.patch --- mgba-0.8.4+dfsg/debian/patches/Core-Fix-destroying-an-mVL-with-an-invalid-channel-c.patch 1969-12-31 16:00:00.000000000 -0800 +++ mgba-0.8.4+dfsg/debian/patches/Core-Fix-destroying-an-mVL-with-an-invalid-channel-c.patch 2021-04-20 18:31:14.000000000 -0700 @@ -0,0 +1,24 @@ +From 44f031d89b9e33338916aeefddb94c3b494a47af Mon Sep 17 00:00:00 2001 +From: Vicki Pfau <v...@endrift.com> +Date: Tue, 23 Mar 2021 19:35:01 -0700 +Subject: [PATCH] Core: Fix destroying an mVL with an invalid channel count + +--- + src/feature/video-logger.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/feature/video-logger.c b/src/feature/video-logger.c +index b01e1c55d..ae2fa046e 100644 +--- a/src/feature/video-logger.c ++++ b/src/feature/video-logger.c +@@ -613,6 +613,7 @@ bool _readHeader(struct mVideoLogContext* context) { + + LOAD_32LE(context->nChannels, 0, &header.nChannels); + if (context->nChannels > mVL_MAX_CHANNELS) { ++ context->nChannels = 0; + return false; + } + +-- +2.20.1 + diff -Nru mgba-0.8.4+dfsg/debian/patches/GBA-Serialize-Fix-alignment-check-when-loading-state.patch mgba-0.8.4+dfsg/debian/patches/GBA-Serialize-Fix-alignment-check-when-loading-state.patch --- mgba-0.8.4+dfsg/debian/patches/GBA-Serialize-Fix-alignment-check-when-loading-state.patch 1969-12-31 16:00:00.000000000 -0800 +++ mgba-0.8.4+dfsg/debian/patches/GBA-Serialize-Fix-alignment-check-when-loading-state.patch 2021-04-20 18:31:14.000000000 -0700 @@ -0,0 +1,25 @@ +From 346f5dc0b53afa8ea1e11d8c94a0090b5d49abc9 Mon Sep 17 00:00:00 2001 +From: Vicki Pfau <v...@endrift.com> +Date: Sun, 13 Dec 2020 15:02:08 -0800 +Subject: [PATCH] GBA Serialize: Fix alignment check when loading states + +--- + src/gba/serialize.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/gba/serialize.c b/src/gba/serialize.c +index 464cef460..fbb7d99d9 100644 +--- a/src/gba/serialize.c ++++ b/src/gba/serialize.c +@@ -154,7 +154,7 @@ bool GBADeserialize(struct GBA* gba, const struct GBASerializedState* state) { + LOAD_32(gba->cpu->bankedSPSRs[i], i * sizeof(gba->cpu->bankedSPSRs[0]), state->cpu.bankedSPSRs); + } + gba->cpu->privilegeMode = gba->cpu->cpsr.priv; +- uint32_t pcMask = (gba->cpu->executionMode == MODE_THUMB ? WORD_SIZE_THUMB : WORD_SIZE_ARM) - 1; ++ uint32_t pcMask = (gba->cpu->cpsr.t ? WORD_SIZE_THUMB : WORD_SIZE_ARM) - 1; + if (gba->cpu->gprs[ARM_PC] & pcMask) { + mLOG(GBA_STATE, WARN, "Savestate has unaligned PC and is probably corrupted"); + gba->cpu->gprs[ARM_PC] &= ~pcMask; +-- +2.20.1 + diff -Nru mgba-0.8.4+dfsg/debian/patches/GB-MBC-Force-minimum-SRAM-size-on-rare-MBCs-that-alw.patch mgba-0.8.4+dfsg/debian/patches/GB-MBC-Force-minimum-SRAM-size-on-rare-MBCs-that-alw.patch --- mgba-0.8.4+dfsg/debian/patches/GB-MBC-Force-minimum-SRAM-size-on-rare-MBCs-that-alw.patch 1969-12-31 16:00:00.000000000 -0800 +++ mgba-0.8.4+dfsg/debian/patches/GB-MBC-Force-minimum-SRAM-size-on-rare-MBCs-that-alw.patch 2021-04-20 18:31:14.000000000 -0700 @@ -0,0 +1,32 @@ +From 32b7cc2fba9526ca64e561b433d8c7df13f5f066 Mon Sep 17 00:00:00 2001 +From: Vicki Pfau <v...@endrift.com> +Date: Wed, 24 Mar 2021 18:59:56 -0700 +Subject: [PATCH] GB MBC: Force minimum SRAM size on rare MBCs that always have + SRAM + +--- + src/gb/mbc.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +--- a/src/gb/mbc.c ++++ b/src/gb/mbc.c +@@ -300,6 +300,9 @@ + mLOG(GB_MBC, WARN, "unimplemented MBC: MBC6"); + gb->memory.mbcWrite = _GBMBC6; + gb->memory.mbcRead = _GBMBC6Read; ++ if (!gb->sramSize) { ++ gb->sramSize = GB_SIZE_EXTERNAL_RAM; // Force minimum size for convenience ++ } + break; + case GB_MBC7: + gb->memory.mbcWrite = _GBMBC7; +@@ -332,6 +335,9 @@ + case GB_POCKETCAM: + gb->memory.mbcWrite = _GBPocketCam; + gb->memory.mbcRead = _GBPocketCamRead; ++ if (!gb->sramSize) { ++ gb->sramSize = GB_SIZE_EXTERNAL_RAM; // Force minimum size for convenience ++ } + if (gb->memory.cam && gb->memory.cam->startRequestImage) { + gb->memory.cam->startRequestImage(gb->memory.cam, GBCAM_WIDTH, GBCAM_HEIGHT, mCOLOR_ANY); + } diff -Nru mgba-0.8.4+dfsg/debian/patches/GB-MBC-Remove-unused-SRAM-size.patch mgba-0.8.4+dfsg/debian/patches/GB-MBC-Remove-unused-SRAM-size.patch --- mgba-0.8.4+dfsg/debian/patches/GB-MBC-Remove-unused-SRAM-size.patch 1969-12-31 16:00:00.000000000 -0800 +++ mgba-0.8.4+dfsg/debian/patches/GB-MBC-Remove-unused-SRAM-size.patch 2021-04-20 18:31:14.000000000 -0700 @@ -0,0 +1,26 @@ +From 2a7626f1336048e4ad25c2af3b1f2118d97b4fe8 Mon Sep 17 00:00:00 2001 +From: Vicki Pfau <v...@endrift.com> +Date: Wed, 24 Mar 2021 18:54:42 -0700 +Subject: [PATCH] GB MBC: Remove unused SRAM size + +--- + src/gb/mbc.c | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/src/gb/mbc.c b/src/gb/mbc.c +index c17de4ce5..53d577452 100644 +--- a/src/gb/mbc.c ++++ b/src/gb/mbc.c +@@ -236,9 +236,6 @@ void GBMBCInit(struct GB* gb) { + case 0: + gb->sramSize = 0; + break; +- case 1: +- gb->sramSize = 0x800; +- break; + default: + case 2: + gb->sramSize = 0x2000; +-- +2.20.1 + diff -Nru mgba-0.8.4+dfsg/debian/patches/GB-Video-Discard-SGB-packets-in-non-SGB-mVLs.patch mgba-0.8.4+dfsg/debian/patches/GB-Video-Discard-SGB-packets-in-non-SGB-mVLs.patch --- mgba-0.8.4+dfsg/debian/patches/GB-Video-Discard-SGB-packets-in-non-SGB-mVLs.patch 1969-12-31 16:00:00.000000000 -0800 +++ mgba-0.8.4+dfsg/debian/patches/GB-Video-Discard-SGB-packets-in-non-SGB-mVLs.patch 2021-04-20 18:31:14.000000000 -0700 @@ -0,0 +1,41 @@ +From ffeb5cfe2779b5f0c633e13e15adef651658d160 Mon Sep 17 00:00:00 2001 +From: Vicki Pfau <v...@endrift.com> +Date: Tue, 23 Mar 2021 19:34:08 -0700 +Subject: [PATCH] GB Video: Discard SGB packets in non-SGB mVLs + +--- + include/mgba/internal/gb/renderers/proxy.h | 1 + + src/gb/extra/proxy.c | 5 ++++- + 2 files changed, 5 insertions(+), 1 deletion(-) + +--- a/include/mgba/internal/gb/renderers/proxy.h ++++ b/include/mgba/internal/gb/renderers/proxy.h +@@ -17,6 +17,7 @@ + struct GBVideoRenderer d; + struct GBVideoRenderer* backend; + struct mVideoLogger* logger; ++ enum GBModel model; + + struct GBObj objThisLine[40]; + size_t oamMax; +--- a/src/gb/extra/proxy.c ++++ b/src/gb/extra/proxy.c +@@ -107,6 +107,7 @@ + + _init(proxyRenderer); + ++ proxyRenderer->model = model; + proxyRenderer->backend->init(proxyRenderer->backend, model, borders); + } + +@@ -170,7 +171,9 @@ + break; + case BUFFER_SGB: + logger->readData(logger, sgbPacket, 16, true); +- proxyRenderer->backend->writeSGBPacket(proxyRenderer->backend, sgbPacket); ++ if (proxyRenderer->model & GB_MODEL_SGB) { ++ proxyRenderer->backend->writeSGBPacket(proxyRenderer->backend, sgbPacket); ++ } + break; + } + break; diff -Nru mgba-0.8.4+dfsg/debian/patches/GB-Video-Don-t-rendering-negative-batches.patch mgba-0.8.4+dfsg/debian/patches/GB-Video-Don-t-rendering-negative-batches.patch --- mgba-0.8.4+dfsg/debian/patches/GB-Video-Don-t-rendering-negative-batches.patch 1969-12-31 16:00:00.000000000 -0800 +++ mgba-0.8.4+dfsg/debian/patches/GB-Video-Don-t-rendering-negative-batches.patch 2021-04-20 18:31:14.000000000 -0700 @@ -0,0 +1,26 @@ +From 1b81c08de8fd10035d5ae060b81747c6b880c906 Mon Sep 17 00:00:00 2001 +From: Vicki Pfau <v...@endrift.com> +Date: Wed, 24 Mar 2021 18:58:40 -0700 +Subject: [PATCH] GB Video: Don't rendering negative batches + +--- + src/gb/renderers/software.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/gb/renderers/software.c b/src/gb/renderers/software.c +index 542aec901..f023d99b4 100644 +--- a/src/gb/renderers/software.c ++++ b/src/gb/renderers/software.c +@@ -565,6 +565,9 @@ static void GBVideoSoftwareRendererDrawRange(struct GBVideoRenderer* renderer, i + struct GBVideoSoftwareRenderer* softwareRenderer = (struct GBVideoSoftwareRenderer*) renderer; + softwareRenderer->lastY = y; + softwareRenderer->lastX = endX; ++ if (startX >= endX) { ++ return; ++ } + uint8_t* maps = &softwareRenderer->d.vram[GB_BASE_MAP]; + if (GBRegisterLCDCIsTileMap(softwareRenderer->lcdc)) { + maps += GB_SIZE_MAP; +-- +2.20.1 + diff -Nru mgba-0.8.4+dfsg/debian/patches/GB-Video-Fix-deserializing-negative-LX-state.patch mgba-0.8.4+dfsg/debian/patches/GB-Video-Fix-deserializing-negative-LX-state.patch --- mgba-0.8.4+dfsg/debian/patches/GB-Video-Fix-deserializing-negative-LX-state.patch 1969-12-31 16:00:00.000000000 -0800 +++ mgba-0.8.4+dfsg/debian/patches/GB-Video-Fix-deserializing-negative-LX-state.patch 2021-04-20 18:31:14.000000000 -0700 @@ -0,0 +1,25 @@ +From f34fa2b6af4f7cf196cc7ab76b6c10acff11b8b1 Mon Sep 17 00:00:00 2001 +From: Vicki Pfau <v...@endrift.com> +Date: Tue, 23 Mar 2021 19:51:03 -0700 +Subject: [PATCH] GB Video: Fix deserializing negative LX state + +--- + src/gb/video.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/gb/video.c b/src/gb/video.c +index ccaae7717..2dca89f17 100644 +--- a/src/gb/video.c ++++ b/src/gb/video.c +@@ -867,6 +867,8 @@ void GBVideoDeserialize(struct GBVideo* video, const struct GBSerializedState* s + LOAD_16LE(video->ly, 0, &state->video.ly); + LOAD_32LE(video->frameCounter, 0, &state->video.frameCounter); + LOAD_32LE(video->dotClock, 0, &state->video.dotCounter); ++ video->x = (int16_t) video->x; // Ensure proper sign extension--the LOAD_16 is unsigned ++ + video->vramCurrentBank = state->video.vramCurrentBank; + + GBSerializedVideoFlags flags = state->video.flags; +-- +2.20.1 + diff -Nru mgba-0.8.4+dfsg/debian/patches/Libretro-Only-set-camera-peripheral-when-it-is-avail.patch mgba-0.8.4+dfsg/debian/patches/Libretro-Only-set-camera-peripheral-when-it-is-avail.patch --- mgba-0.8.4+dfsg/debian/patches/Libretro-Only-set-camera-peripheral-when-it-is-avail.patch 1969-12-31 16:00:00.000000000 -0800 +++ mgba-0.8.4+dfsg/debian/patches/Libretro-Only-set-camera-peripheral-when-it-is-avail.patch 2021-04-20 18:31:14.000000000 -0700 @@ -0,0 +1,33 @@ +From 82f3432e7ad9d5a9b65e643779a0a71c69eacf79 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mfor...@mforney.org> +Date: Sat, 7 Nov 2020 14:23:34 -0800 +Subject: [PATCH] Libretro: Only set camera peripheral when it is available + (#1931) + +Otherwise, if the frontend does not support GET_CAMERA_INTERFACE, +the start and stop functions are NULL, causing a crash when a gameboy +ROM is unloaded. +--- + src/platform/libretro/libretro.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/platform/libretro/libretro.c b/src/platform/libretro/libretro.c +index 0d2d0e60b..0b59dd4ce 100644 +--- a/src/platform/libretro/libretro.c ++++ b/src/platform/libretro/libretro.c +@@ -606,9 +606,10 @@ bool retro_load_game(const struct retro_game_info* game) { + cam.width = GBCAM_WIDTH; + cam.caps = 1 << RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER; + cam.frame_raw_framebuffer = _updateCamera; +- core->setPeripheral(core, mPERIPH_IMAGE_SOURCE, &imageSource); ++ if (environCallback(RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE, &cam)) { ++ core->setPeripheral(core, mPERIPH_IMAGE_SOURCE, &imageSource); ++ } + +- environCallback(RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE, &cam); + const char* modelName = mCoreConfigGetValue(&core->config, "gb.model"); + struct GB* gb = core->board; + +-- +2.20.1 + diff -Nru mgba-0.8.4+dfsg/debian/patches/series mgba-0.8.4+dfsg/debian/patches/series --- mgba-0.8.4+dfsg/debian/patches/series 2020-11-01 18:31:10.000000000 -0800 +++ mgba-0.8.4+dfsg/debian/patches/series 2021-04-20 18:31:14.000000000 -0700 @@ -1,2 +1,12 @@ exclude-rapidjson.patch exclude-inih.patch +CMake-Move-gl.c-and-gles2.c-to-FEATURE_SRC.patch +CMake-Move-BUILD_GL-flags-to-FEATURE_DEFINES.patch +GBA-Serialize-Fix-alignment-check-when-loading-state.patch +Libretro-Only-set-camera-peripheral-when-it-is-avail.patch +Core-Fix-destroying-an-mVL-with-an-invalid-channel-c.patch +GB-MBC-Remove-unused-SRAM-size.patch +GB-MBC-Force-minimum-SRAM-size-on-rare-MBCs-that-alw.patch +GB-Video-Don-t-rendering-negative-batches.patch +GB-Video-Fix-deserializing-negative-LX-state.patch +GB-Video-Discard-SGB-packets-in-non-SGB-mVLs.patch