all repos — mgba @ ecba499b957f687efc597c6d86ebb37019a9982c

mGBA Game Boy Advance Emulator

Merge pull request #453 from tzlion/vfame-mjqb

GBA Memory: Support for Mo Jie Qi Bing by Vast Fame
endrift jeffrey@endrift.com
Thu, 27 Oct 2016 16:57:18 -0700
commit

ecba499b957f687efc597c6d86ebb37019a9982c

parent

5b80b8e4c748e1b3128f645763f141c993827acf

2 files changed, 15 insertions(+), 8 deletions(-)

jump to
M CHANGESCHANGES

@@ -33,6 +33,7 @@ - VFS: Allow truncating memory chunk VFiles

- Debugger: Modularize CLI debugger - Core: Clean up some thread state checks - Debugger: Make building with debugging aspects optional + - GBA Memory: Support for Mo Jie Qi Bing by Vast Fame (taizou) 0.5.1: (2016-10-05) Bugfixes:
M src/gba/vfame.csrc/gba/vfame.c

@@ -58,7 +58,9 @@ if (romSize == 0x2000000) { // the deprotected dumps are 32MB but no real VF games are this size

return; } - if (memcmp(INIT_SEQUENCE, &rom[0x57], sizeof(INIT_SEQUENCE)) == 0) { + // Most games have the same init sequence in the same place + // but LOTR/Mo Jie Qi Bing doesn't, probably because it's based on the Kiki KaiKai engine, so just detect based on its title + if (memcmp(INIT_SEQUENCE, &rom[0x57], sizeof(INIT_SEQUENCE)) == 0 || memcmp("\0LORD\0WORD\0\0AKIJ", &((struct GBACartridge*) rom)->title, 16) == 0) { cart->cartType = VFAME_STANDARD; mLOG(GBA_MEM, INFO, "Vast Fame game detected"); }

@@ -262,14 +264,18 @@ }

} static int8_t _modifySramValue(enum GBAVFameCartType type, uint8_t value, int mode) { - mode = (mode & 0xF) >> 2; - if (mode == 0) { - return value; - } else if (type == VFAME_GEORGE) { - return _reorderBits(value, VALUE_REORDERING_GEORGE[mode - 1], 8); - } else { - return _reorderBits(value, VALUE_REORDERING[mode - 1], 8); + int reorderType = (mode & 0xF) >> 2; + if (reorderType != 0) { + if (type == VFAME_GEORGE) { + value = _reorderBits(value, VALUE_REORDERING_GEORGE[reorderType - 1], 8); + } else { + value = _reorderBits(value, VALUE_REORDERING[reorderType - 1], 8); + } } + if (mode & 0x80) { + value ^= 0xAA; + } + return value; } // Reorder bits in a byte according to the reordering given