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 - GBA BIOS: Fix clobbering registers with word-sized CpuSet
Other fixes: Other fixes:
- mGUI: Fix cases where an older save state screenshot would be shown (fixes mgba.io/i/2183) - 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) 0.10.2: (2023-04-23)
Emulation fixes: Emulation fixes:

View File

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