Change MBC7 reported RAM size to 512 bytes
Some MBC7 cartridges use 512 bytes EEPROM rather than 256 bytes. For compatibility with older versions, we keep saving and loading 256 bytes of EEPROM for every MBC7 cartridge. TODOs have been left to figure out how to identify the EEPROM capacity properly.
This commit is contained in:
parent
52c05c7147
commit
75b79d91f1
|
@ -58,6 +58,10 @@ struct VBamIoVec {
|
|||
};
|
||||
std::vector<VBamIoVec> g_vbamIoVecs;
|
||||
|
||||
// TODO: This is set to 256 bytes for compatibility with older versions. We
|
||||
// should figure out how to actually get the MBC7 RAM size.
|
||||
static constexpr size_t kMbc7RamSizeForSaving = k256B;
|
||||
|
||||
void ResetMBC3RTC() {
|
||||
time(&gbDataMBC3.mapperLastTime);
|
||||
struct tm* lt;
|
||||
|
@ -470,10 +474,9 @@ bool gbInitializeRom(size_t romSize) {
|
|||
break;
|
||||
case gbCartData::MapperType::kMbc7:
|
||||
// For MBC7, we don't save the RAM data from the same location.
|
||||
// TODO: Unify handling.
|
||||
// TODO: Unify handling and find how to get the MBC7 RAM size.
|
||||
g_vbamIoVecs.clear();
|
||||
g_vbamIoVecs.push_back({&gbMemory[0xa000],
|
||||
g_gbCartData.ram_size()});
|
||||
g_vbamIoVecs.push_back({&gbMemory[0xa000], kMbc7RamSizeForSaving});
|
||||
break;
|
||||
case gbCartData::MapperType::kNone:
|
||||
case gbCartData::MapperType::kMbc1:
|
||||
|
@ -3183,7 +3186,8 @@ bool gbReadGSASnapshot(const char* fileName)
|
|||
break;
|
||||
case gbCartData::MapperType::kMbc2:
|
||||
case gbCartData::MapperType::kMbc7:
|
||||
FREAD_UNCHECKED(&gbMemory[0xa000], 1, 256, file);
|
||||
// TODO: Figure out how to get the RAM size for MBC7.
|
||||
FREAD_UNCHECKED(&gbMemory[0xa000], 1, kMbc7RamSizeForSaving, file);
|
||||
break;
|
||||
default:
|
||||
systemMessage(MSG_UNSUPPORTED_SNAPSHOT_FILE,
|
||||
|
@ -4951,12 +4955,9 @@ bool gbApplyPatch(const char* patchName) {
|
|||
return false;
|
||||
}
|
||||
|
||||
size_t newSize = size;
|
||||
if (newSize != g_gbCartData.rom_size()) {
|
||||
return gbInitializeRom(newSize);
|
||||
}
|
||||
|
||||
return true;
|
||||
// We should re-parse the header every time in case a patch has changed the
|
||||
// ROM header.
|
||||
return gbInitializeRom(size);
|
||||
}
|
||||
#endif // __LIBRETRO__
|
||||
|
||||
|
|
|
@ -356,8 +356,10 @@ gbCartData::gbCartData(const uint8_t* romData, size_t romDataSize) {
|
|||
break;
|
||||
case 0x22:
|
||||
// MBC7 header does not specify a RAM size so set it here.
|
||||
// TODO: Figure out how to get the RAM size for MBC7. It is either
|
||||
// 256 or 512 Bytes.
|
||||
mapper_type_ = MapperType::kMbc7;
|
||||
ram_size_ = k256B;
|
||||
ram_size_ = k512B;
|
||||
skip_ram = true;
|
||||
has_battery_ = true;
|
||||
has_rumble_ = true;
|
||||
|
|
Loading…
Reference in New Issue