all repos — mgba @ fe3e554b603582dcb0d584d86c1ff4abdd8f3bb4

mGBA Game Boy Advance Emulator

GB Cheats: Fix Game Genie codes
Vicki Pfau vi@endrift.com
Fri, 01 Jan 2021 17:26:42 -0800
commit

fe3e554b603582dcb0d584d86c1ff4abdd8f3bb4

parent

1c69a714c7f383ab2a17fb27ea0aa59048868f67

1 files changed, 6 insertions(+), 3 deletions(-)

jump to
M src/core/cheats.csrc/core/cheats.c

@@ -107,14 +107,17 @@ for (i = 0; i < mCheatPatchListSize(&cheats->romPatches); ++i) {

struct mCheatPatch* patch = mCheatPatchListGetPointer(&cheats->romPatches, i); int segment = -1; if (patch->check && patch->segment < 0) { - int maxSegment = 0; - for (segment = 0; segment < maxSegment; ++segment) { + const struct mCoreMemoryBlock* block = mCoreGetMemoryBlockInfo(device->p, patch->address); + if (!block) { + continue; + } + for (segment = 0; segment < block->maxSegment; ++segment) { uint32_t value = _readMemSegment(device->p, patch->address, segment, patch->width); if (value == patch->checkValue) { break; } } - if (segment == maxSegment) { + if (segment == block->maxSegment) { continue; } }