Run clang-format

This commit is contained in:
wheremyfoodat 2023-09-03 10:40:57 +03:00
parent 414e8cf6c8
commit 53917841bc

View file

@ -7,7 +7,6 @@
#include "memory.hpp" #include "memory.hpp"
namespace { namespace {
struct LoadInfo { struct LoadInfo {
u32 codeSegSizeAligned; u32 codeSegSizeAligned;
u32 rodataSegSizeAligned; u32 rodataSegSizeAligned;
@ -24,8 +23,7 @@ static inline u32 translateAddr(const u32 off, const u32* addrs, const u32* offs
} }
return addrs[2] + off - offsets[2]; return addrs[2] + off - offsets[2];
} }
} // namespace
}
bool Memory::map3DSX(HB3DSX& hb3dsx, const HB3DSX::Header& header) { bool Memory::map3DSX(HB3DSX& hb3dsx, const HB3DSX::Header& header) {
const LoadInfo hbInfo = { const LoadInfo hbInfo = {
@ -164,9 +162,7 @@ bool Memory::map3DSX(HB3DSX& hb3dsx, const HB3DSX::Header& header) {
case 0: // 32-bit signed offset case 0: // 32-bit signed offset
std::memcpy(&sectionData[0], &data, sizeof(u32)); std::memcpy(&sectionData[0], &data, sizeof(u32));
break; break;
default: default: Helpers::panic("Unsupported relative reloc subtype"); return false;
Helpers::panic("Unsupported relative reloc subtype");
return false;
} }
break; break;
} }
@ -262,8 +258,7 @@ std::optional<u32> Memory::load3DSX(const std::filesystem::path& path) {
} }
if (hbHeader.headerSize == 0x20 || hbHeader.headerSize == 0x2C) { if (hbHeader.headerSize == 0x20 || hbHeader.headerSize == 0x2C) {
if (hbHeader.headerSize == 0x2C) if (hbHeader.headerSize == 0x2C) {
{
hb3dsx.file.seek(8, SEEK_CUR); // skip SMDH info hb3dsx.file.seek(8, SEEK_CUR); // skip SMDH info
std::tie(success, bytes) = hb3dsx.file.readBytes(&hb3dsx.romFSOffset, 4); std::tie(success, bytes) = hb3dsx.file.readBytes(&hb3dsx.romFSOffset, 4);
if (!success || bytes != 4) { if (!success || bytes != 4) {
@ -278,8 +273,7 @@ std::optional<u32> Memory::load3DSX(const std::filesystem::path& path) {
} }
hb3dsx.romFSSize = *fileSize - hb3dsx.romFSOffset; hb3dsx.romFSSize = *fileSize - hb3dsx.romFSOffset;
} }
} } else {
else {
printf("Invalid 3DSX header size\n"); printf("Invalid 3DSX header size\n");
return std::nullopt; return std::nullopt;
} }
@ -293,9 +287,7 @@ std::optional<u32> Memory::load3DSX(const std::filesystem::path& path) {
return HB3DSX::entrypoint; return HB3DSX::entrypoint;
} }
bool HB3DSX::hasRomFs() const { bool HB3DSX::hasRomFs() const { return romFSSize != 0 && romFSOffset != 0; }
return romFSSize != 0 && romFSOffset != 0;
}
std::pair<bool, std::size_t> HB3DSX::readRomFSBytes(void* dst, std::size_t offset, std::size_t size) { std::pair<bool, std::size_t> HB3DSX::readRomFSBytes(void* dst, std::size_t offset, std::size_t size) {
if (!hasRomFs()) { if (!hasRomFs()) {