diff --git a/CHANGES b/CHANGES index 10d60be18..9a9171beb 100644 --- a/CHANGES +++ b/CHANGES @@ -29,6 +29,7 @@ Features: - Default controller profiles for several common controllers - Libretro now supports BIOS, rumble and solar sensor - Implement BIOS call Stop, for sleep mode + - Automatically load patches, if found Bugfixes: - ARM7: Fix SWI and IRQ timings - GBA Audio: Force audio FIFOs to 32-bit diff --git a/src/gba/supervisor/thread.c b/src/gba/supervisor/thread.c index 08b5b7402..94eff4a61 100644 --- a/src/gba/supervisor/thread.c +++ b/src/gba/supervisor/thread.c @@ -419,6 +419,16 @@ bool GBAThreadStart(struct GBAThread* threadContext) { threadContext->save = VDirOptionalOpenFile(threadContext->stateDir, threadContext->fname, "sram", ".sav", O_CREAT | O_RDWR); + if (!threadContext->patch) { + threadContext->patch = VDirOptionalOpenFile(threadContext->stateDir, threadContext->fname, "patch", ".ups", O_RDONLY); + } + if (!threadContext->patch) { + threadContext->patch = VDirOptionalOpenFile(threadContext->stateDir, threadContext->fname, "patch", ".ips", O_RDONLY); + } + if (!threadContext->patch) { + threadContext->patch = VDirOptionalOpenFile(threadContext->stateDir, threadContext->fname, "patch", ".bps", O_RDONLY); + } + MutexInit(&threadContext->stateMutex); ConditionInit(&threadContext->stateCond);