Qt: Add exporting of SAV + RTC GBA saves from Save Converter to strip RTC data

This commit is contained in:
Vicki Pfau 2023-06-18 15:16:15 -07:00
parent 276e911e38
commit 6c4ca7724f
2 changed files with 23 additions and 1 deletions

View File

@ -6,6 +6,8 @@ Emulation fixes:
- GBA BIOS: Fix clobbering registers with word-sized CpuSet
Other fixes:
- mGUI: Fix cases where an older save state screenshot would be shown (fixes mgba.io/i/2183)
Misc:
- Qt: Add exporting of SAV + RTC GBA saves from Save Converter to strip RTC data
0.10.2: (2023-04-23)
Emulation fixes:

View File

@ -198,19 +198,24 @@ void SaveConverter::detectFromSize(std::shared_ptr<VFileDevice> vf) {
#ifdef M_CORE_GBA
switch (vf->size()) {
case SIZE_CART_SRAM:
case SIZE_CART_SRAM + 16:
m_validSaves.append(AnnotatedSave{SAVEDATA_SRAM, vf});
break;
case SIZE_CART_FLASH512:
case SIZE_CART_FLASH512 + 16:
m_validSaves.append(AnnotatedSave{SAVEDATA_FLASH512, vf});
break;
case SIZE_CART_FLASH1M:
case SIZE_CART_FLASH1M + 16:
m_validSaves.append(AnnotatedSave{SAVEDATA_FLASH1M, vf});
break;
case SIZE_CART_EEPROM:
case SIZE_CART_EEPROM + 16:
m_validSaves.append(AnnotatedSave{SAVEDATA_EEPROM, vf, Endian::LITTLE});
m_validSaves.append(AnnotatedSave{SAVEDATA_EEPROM, vf, Endian::BIG});
break;
case SIZE_CART_EEPROM512:
case SIZE_CART_EEPROM512 + 16:
m_validSaves.append(AnnotatedSave{SAVEDATA_EEPROM512, vf, Endian::LITTLE});
m_validSaves.append(AnnotatedSave{SAVEDATA_EEPROM512, vf, Endian::BIG});
break;
@ -478,6 +483,9 @@ SaveConverter::AnnotatedSave::operator QString() const {
default:
break;
}
if ((size & 0xFF) == 0x10) {
typeFormat += QCoreApplication::translate("QGBA::SaveConverter", " + RTC");
}
break;
#endif
#ifdef M_CORE_GB
@ -618,6 +626,15 @@ QList<SaveConverter::AnnotatedSave> SaveConverter::AnnotatedSave::possibleConver
break;
}
break;
#endif
#ifdef M_CORE_GBA
case mPLATFORM_GBA:
if ((size & 0xFF) == 0x10) {
AnnotatedSave noRtc = same;
noRtc.size &= ~0xFF;
possible.append(noRtc);
}
break;
#endif
default:
break;
@ -650,7 +667,7 @@ QByteArray SaveConverter::AnnotatedSave::convertTo(const SaveConverter::Annotate
}
converted.resize(target.size);
buffer = backing->readAll();
for (int i = 0; i < size; i += 8) {
for (int i = 0; i < (size & ~0xFF); i += 8) {
uint64_t word;
const uint64_t* in = reinterpret_cast<const uint64_t*>(buffer.constData());
uint64_t* out = reinterpret_cast<uint64_t*>(converted.data());
@ -661,6 +678,9 @@ QByteArray SaveConverter::AnnotatedSave::convertTo(const SaveConverter::Annotate
default:
break;
}
if (endianness == target.endianness && size > target.size) {
converted = backing->read(target.size);
}
break;
#endif
#ifdef M_CORE_GB