From 6c4ca7724f732bcba1e4f6f5828e1ad7b59e337a Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sun, 18 Jun 2023 15:16:15 -0700 Subject: [PATCH] Qt: Add exporting of SAV + RTC GBA saves from Save Converter to strip RTC data --- CHANGES | 2 ++ src/platform/qt/SaveConverter.cpp | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 6469ca210..1a5b76075 100644 --- a/CHANGES +++ b/CHANGES @@ -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: diff --git a/src/platform/qt/SaveConverter.cpp b/src/platform/qt/SaveConverter.cpp index fd242af98..1aa93f6fb 100644 --- a/src/platform/qt/SaveConverter.cpp +++ b/src/platform/qt/SaveConverter.cpp @@ -198,19 +198,24 @@ void SaveConverter::detectFromSize(std::shared_ptr 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::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(buffer.constData()); uint64_t* out = reinterpret_cast(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