diff --git a/src/backend/core/Mem.cpp b/src/backend/core/Mem.cpp index 9717d9e5..ca7e81cc 100644 --- a/src/backend/core/Mem.cpp +++ b/src/backend/core/Mem.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include namespace n64 { diff --git a/src/backend/core/mmio/PIF/MupenMovie.cpp b/src/backend/core/mmio/PIF/MupenMovie.cpp index f4120a42..afe99b20 100644 --- a/src/backend/core/mmio/PIF/MupenMovie.cpp +++ b/src/backend/core/mmio/PIF/MupenMovie.cpp @@ -70,9 +70,7 @@ bool MupenMovie::Load(const fs::path &path) { } MupenMovie::MupenMovie(const fs::path &path) { - if (!Load(path)) { - panic(""); - } + Load(path); } void MupenMovie::Reset() { diff --git a/src/common.hpp b/src/common.hpp index 8e916307..1420bc90 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -1,24 +1,7 @@ #pragma once #include -#include -#ifdef USE_NEON -#include -#else -#include -#include -#endif - -using u8 = uint8_t; -using u16 = uint16_t; -using u32 = uint32_t; -using u64 = uint64_t; -using s8 = int8_t; -using s16 = int16_t; -using s32 = int32_t; -using s64 = int64_t; -using u128 = __uint128_t; -using s128 = __int128_t; -using m128i = __m128i; +#include +#include #define FORCE_INLINE inline __attribute__((always_inline)) diff --git a/src/types.hpp b/src/types.hpp new file mode 100644 index 00000000..bfd6359d --- /dev/null +++ b/src/types.hpp @@ -0,0 +1,20 @@ +#pragma once +#include +#ifdef USE_NEON +#include +#else +#include +#include +#endif + +using u8 = uint8_t; +using u16 = uint16_t; +using u32 = uint32_t; +using u64 = uint64_t; +using s8 = int8_t; +using s16 = int16_t; +using s32 = int32_t; +using s64 = int64_t; +using u128 = __uint128_t; +using s128 = __int128_t; +using m128i = __m128i; diff --git a/src/utils/ErrorData.hpp b/src/utils/ErrorData.hpp new file mode 100644 index 00000000..5baa1624 --- /dev/null +++ b/src/utils/ErrorData.hpp @@ -0,0 +1,79 @@ +#pragma once +#include +#include +#include +#include + +namespace Util { +struct Error { + enum Severity { + NONE, + WARN, + ERROR, + FATAL, + }; + + union MemoryAccess { + struct { + unsigned : 3; + unsigned is_write : 1; + unsigned is_fatal : 1; + unsigned size : 3; + }; + + u8 raw; + }; + + enum Type { + SCHEDULER_EOL, + SCHEDULER_UNKNOWN, + UNHANDLED_EXCEPTION, + UNHANDLED_INSTRUCTION, + INVALID_INSTRUCTION_FORMAT, + TLB_LIMIT_EXCEEDED, + TLB_INVALID_ERROR, + TLB_UNHANDLED_ERROR, + TLB_UNHANDLED_MAPPING, + JIT_BRANCH_INSIDE_DELAY_SLOT, + JIT_INVALID_X86_REG_ADDRESSING, + COULD_NOT_SYNC_SAVE_DATA, + SAVE_DATA_IS_CORRUPT_OR_INVALID_SIZE, + MMAP_MAKE_SINK_ERROR, + MEM_INVALID_ACCESS, + MEM_UNHANDLED_ACCESS, + RDP_LIMIT_EXCEEDED, + FLASH_EXECUTE_COMMAND_ERROR, + PIF_UNHANDLED_CHANNEL, + UNHANDLED_COP0_STATUS_BIT, + COP0_INVALID_ACCESS, + COP0_UNHANDLED_ACCESS, + SYSTEM_DIALOG_ERROR, + TAS_LOAD_ERROR, + ROM_LOAD_ERROR, + SAVE_OPTIONS_ERROR, + }; + + template + std::string Format(Severity severity, + std::optional lastPC, + std::optional memoryAccess, + std::optional type, + const std::format_string fmt, Args... args) { + this->severity = severity; + this->lastPC = lastPC; + this->memoryAccess = memoryAccess; + this->type = type; + return std::format(fmt, std::forward(args)...); + } + + static Error& Get() { + static Error instance; + return instance; + } +private: + Severity severity = NONE; + Type type = {}; + std::optional lastPC = {}; + std::optional memoryAccess = {}; +}; +} \ No newline at end of file diff --git a/src/utils/File.hpp b/src/utils/File.hpp index 874a0d34..e730a51f 100644 --- a/src/utils/File.hpp +++ b/src/utils/File.hpp @@ -2,6 +2,10 @@ #include #include #include +#include +#include + +namespace fs = std::filesystem; namespace Util { FORCE_INLINE std::vector ReadFileBinary(const std::string &path) { @@ -38,13 +42,13 @@ FORCE_INLINE size_t NextPow2(size_t num) { return num + 1; } -FORCE_INLINE std::vector OpenROM(const std::string &, size_t &) { +FORCE_INLINE std::vector OpenROM(const std::string &filename, size_t &sizeAdjusted) { auto buf = Util::ReadFileBinary(filename); sizeAdjusted = Util::NextPow2(buf.size()); return buf; } -FORCE_INLINE std::vector OpenArchive(const std::string &, size_t &) { +FORCE_INLINE std::vector OpenArchive(const std::string &path, size_t &sizeAdjusted) { const auto stream = ar_open_file(fs::path(path).string().c_str()); if (!stream) {