all repos — mgba @ 4d6b6fb3df0a7bc4083e71816a7c8fde045ed941

mGBA Game Boy Advance Emulator

GBA Cheats: Fix PARv3 slide codes (fixes #919)
Vicki Pfau vi@endrift.com
Mon, 23 Oct 2017 06:46:05 -0700
commit

4d6b6fb3df0a7bc4083e71816a7c8fde045ed941

parent

63d7927b60565c68fc0913d4b67f2c5813027f25

3 files changed, 93 insertions(+), 2 deletions(-)

jump to
M CHANGESCHANGES

@@ -21,6 +21,7 @@ - GBA Video: Force align 256-color tiles

- GBA DMA: ROM reads are forced to increment - GB Video: Fix loading states while in mode 3 - GB Video: Only trigger STAT write IRQs when screen is on (fixes mgba.io/i/912) + - GBA Cheats: Fix PARv3 slide codes (fixes mgba.io/i/919) Misc: - GBA Timer: Use global cycles for timers - GBA: Extend oddly-sized ROMs to full address space (fixes mgba.io/i/722)
M src/gba/cheats/parv3.csrc/gba/cheats/parv3.c

@@ -203,7 +203,7 @@ break;

case PAR3_OTHER_FILL_4: cheat = mCheatListAppend(&cheats->d.list); cheat->address = _parAddr(op2); - cheat->width = 3; + cheat->width = 4; cheats->incompleteCheat = mCheatListIndex(&cheats->d.list, cheat); break; }

@@ -219,7 +219,7 @@ }

if (cheats->incompleteCheat != COMPLETE) { struct mCheat* incompleteCheat = mCheatListGetPointer(&cheats->d.list, cheats->incompleteCheat); incompleteCheat->operand = op1 & (0xFFFFFFFFU >> ((4 - incompleteCheat->width) * 8)); - incompleteCheat->addressOffset = op2 >> 24; + incompleteCheat->operandOffset = op2 >> 24; incompleteCheat->repeat = (op2 >> 16) & 0xFF; incompleteCheat->addressOffset = (op2 & 0xFFFF) * incompleteCheat->width; cheats->incompleteCheat = COMPLETE;
M src/gba/test/cheats.csrc/gba/test/cheats.c

@@ -75,6 +75,93 @@

set->deinit(set); } +M_TEST_DEFINE(doPARv3Slide1) { + struct mCore* core = *state; + struct mCheatDevice* device = core->cheatDevice(core); + assert_non_null(device); + struct mCheatSet* set = device->createSet(device, NULL); + assert_non_null(set); + GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW); + assert_true(set->addLine(set, "00000000 80300000", GBA_CHEAT_PRO_ACTION_REPLAY)); + assert_true(set->addLine(set, "00000001 01020002", GBA_CHEAT_PRO_ACTION_REPLAY)); + + core->reset(core); + assert_int_equal(core->rawRead8(core, 0x03000000, -1), 0); + assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0); + assert_int_equal(core->rawRead8(core, 0x03000002, -1), 0); + assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0); + assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0); + assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0); + + mCheatRefresh(device, set); + assert_int_equal(core->rawRead8(core, 0x03000000, -1), 1); + assert_int_equal(core->rawRead8(core, 0x03000001, -1), 0); + assert_int_equal(core->rawRead8(core, 0x03000002, -1), 2); + assert_int_equal(core->rawRead8(core, 0x03000003, -1), 0); + assert_int_equal(core->rawRead8(core, 0x03000004, -1), 0); + assert_int_equal(core->rawRead8(core, 0x03000005, -1), 0); + + set->deinit(set); +} + +M_TEST_DEFINE(doPARv3Slide2) { + struct mCore* core = *state; + struct mCheatDevice* device = core->cheatDevice(core); + assert_non_null(device); + struct mCheatSet* set = device->createSet(device, NULL); + assert_non_null(set); + GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW); + assert_true(set->addLine(set, "00000000 82300000", GBA_CHEAT_PRO_ACTION_REPLAY)); + assert_true(set->addLine(set, "00000001 01020002", GBA_CHEAT_PRO_ACTION_REPLAY)); + + core->reset(core); + assert_int_equal(core->rawRead16(core, 0x03000000, -1), 0); + assert_int_equal(core->rawRead16(core, 0x03000002, -1), 0); + assert_int_equal(core->rawRead16(core, 0x03000004, -1), 0); + assert_int_equal(core->rawRead16(core, 0x03000006, -1), 0); + assert_int_equal(core->rawRead16(core, 0x03000008, -1), 0); + assert_int_equal(core->rawRead16(core, 0x0300000A, -1), 0); + + mCheatRefresh(device, set); + assert_int_equal(core->rawRead16(core, 0x03000000, -1), 1); + assert_int_equal(core->rawRead16(core, 0x03000002, -1), 0); + assert_int_equal(core->rawRead16(core, 0x03000004, -1), 2); + assert_int_equal(core->rawRead16(core, 0x03000006, -1), 0); + assert_int_equal(core->rawRead16(core, 0x03000008, -1), 0); + assert_int_equal(core->rawRead16(core, 0x0300000A, -1), 0); + + set->deinit(set); +} + +M_TEST_DEFINE(doPARv3Slide4) { + struct mCore* core = *state; + struct mCheatDevice* device = core->cheatDevice(core); + assert_non_null(device); + struct mCheatSet* set = device->createSet(device, NULL); + assert_non_null(set); + GBACheatSetGameSharkVersion((struct GBACheatSet*) set, GBA_GS_PARV3_RAW); + assert_true(set->addLine(set, "00000000 84300000", GBA_CHEAT_PRO_ACTION_REPLAY)); + assert_true(set->addLine(set, "00000001 01020002", GBA_CHEAT_PRO_ACTION_REPLAY)); + + core->reset(core); + assert_int_equal(core->rawRead32(core, 0x03000000, -1), 0); + assert_int_equal(core->rawRead32(core, 0x03000004, -1), 0); + assert_int_equal(core->rawRead32(core, 0x03000008, -1), 0); + assert_int_equal(core->rawRead32(core, 0x0300000C, -1), 0); + assert_int_equal(core->rawRead32(core, 0x03000010, -1), 0); + assert_int_equal(core->rawRead32(core, 0x03000014, -1), 0); + + mCheatRefresh(device, set); + assert_int_equal(core->rawRead16(core, 0x03000000, -1), 1); + assert_int_equal(core->rawRead16(core, 0x03000004, -1), 0); + assert_int_equal(core->rawRead16(core, 0x03000008, -1), 2); + assert_int_equal(core->rawRead16(core, 0x0300000C, -1), 0); + assert_int_equal(core->rawRead16(core, 0x03000010, -1), 0); + assert_int_equal(core->rawRead16(core, 0x03000014, -1), 0); + + set->deinit(set); +} + M_TEST_DEFINE(doPARv3If1) { struct mCore* core = *state; struct mCheatDevice* device = core->cheatDevice(core);

@@ -927,6 +1014,9 @@ M_TEST_SUITE_DEFINE_SETUP_TEARDOWN(GBACheats,

cmocka_unit_test(createSet), cmocka_unit_test(addRawPARv3), cmocka_unit_test(doPARv3Assign), + cmocka_unit_test(doPARv3Slide1), + cmocka_unit_test(doPARv3Slide2), + cmocka_unit_test(doPARv3Slide4), cmocka_unit_test(doPARv3If1), cmocka_unit_test(doPARv3If1x1), cmocka_unit_test(doPARv3If2),