Formatting (again)

This commit is contained in:
GearsProgress
2026-10-22 15:04:58 -04:00
parent 1738b2ebdd
commit 0577a450da
61 changed files with 1873 additions and 2673 deletions

View File

@@ -6,8 +6,7 @@
#define HALL_OF_FAME 0x01C000
Gen3CartridgeSaveReader::Gen3CartridgeSaveReader(u8 *sector_buffer)
: sector_start_(0xFFFFFFFF), sector_buffer_(sector_buffer),
cur_(sector_buffer), dirty_(false)
: sector_start_(0xFFFFFFFF), sector_buffer_(sector_buffer), cur_(sector_buffer), dirty_(false)
{
seek(0);
}
@@ -26,27 +25,24 @@ void Gen3CartridgeSaveReader::readUint8(u8 &outByte)
++cur_;
}
void Gen3CartridgeSaveReader::readUint16(
u16 &outWord, Endianness fieldEndianness)
void Gen3CartridgeSaveReader::readUint16(u16 &outWord, Endianness fieldEndianness)
{
// Right now we only support little endian (no need for big endian thus far)
(void)fieldEndianness;
// The read is implemented this way to avoid any issues with unaligned
// reads. see writeUint16 for more details.
// The read is implemented this way to avoid any issues with unaligned reads.
// see writeUint16 for more details.
outWord = static_cast<u16>(cur_[0]) | (static_cast<u16>(cur_[1]) << 8);
cur_ += sizeof(u16);
}
void Gen3CartridgeSaveReader::readUint32(
u32 &outDWord, Endianness fieldEndianness)
void Gen3CartridgeSaveReader::readUint32(u32 &outDWord, Endianness fieldEndianness)
{
// Right now we only support little endian (no need for big endian thus far)
(void)fieldEndianness;
// The read is implemented this way to avoid any issues with unaligned
// reads. see writeUint16 for more details.
// The read is implemented this way to avoid any issues with unaligned reads.
// see writeUint16 for more details.
outDWord = static_cast<u32>(cur_[0]) | (static_cast<u32>(cur_[1]) << 8) |
(static_cast<u32>(cur_[2]) << 16) |
(static_cast<u32>(cur_[3]) << 24);
(static_cast<u32>(cur_[2]) << 16) | (static_cast<u32>(cur_[3]) << 24);
cur_ += sizeof(u32);
}
@@ -68,12 +64,11 @@ void Gen3CartridgeSaveReader::writeUint16(u16 value, Endianness fieldEndianness)
{
// Right now we only support little endian (no need for big endian thus far)
(void)fieldEndianness;
// The write is implemented this way to avoid any issues with unaligned
// writes. I tried
// The write is implemented this way to avoid any issues with unaligned writes.
// I tried
// *((u16*)cur_) = value;
// earlier, but when cur_ was set to 0x0019, this caused undefined
// behaviour. (specifically the word was written 1 byte earlier than it
// should've been)
// earlier, but when cur_ was set to 0x0019, this caused undefined behaviour.
// (specifically the word was written 1 byte earlier than it should've been)
cur_[0] = static_cast<u8>(value & 0xFF);
cur_[1] = static_cast<u8>(value >> 8);
cur_ += sizeof(u16);
@@ -84,8 +79,8 @@ void Gen3CartridgeSaveReader::writeUint32(u32 value, Endianness fieldEndianness)
{
// Right now we only support little endian (no need for big endian thus far)
(void)fieldEndianness;
// The write is implemented this way to avoid any issues with unaligned
// writes. see writeUint16 for more details.
// The write is implemented this way to avoid any issues with unaligned writes.
// see writeUint16 for more details.
cur_[0] = static_cast<u8>(value & 0xFF);
cur_[1] = static_cast<u8>((value >> 8) & 0xFF);
cur_[2] = static_cast<u8>((value >> 16) & 0xFF);
@@ -138,16 +133,11 @@ void Gen3CartridgeSaveReader::flush()
return;
}
update_memory_buffer_checksum(
sector_buffer_, (sector_start_ == HALL_OF_FAME));
// Real flash requires erase before rewriting bytes that may need 0->1
// transitions.
update_memory_buffer_checksum(sector_buffer_, (sector_start_ == HALL_OF_FAME));
// Real flash requires erase before rewriting bytes that may need 0->1 transitions.
erase_sector(sector_start_);
copy_ram_to_save(sector_buffer_, sector_start_, SECTOR_SIZE);
dirty_ = false;
}
bool Gen3CartridgeSaveReader::shouldRecalculateChecksumsOnFinish() const
{
return false;
}
bool Gen3CartridgeSaveReader::shouldRecalculateChecksumsOnFinish() const { return false; }