Update ImGui

This commit is contained in:
CocoSimone
2023-02-26 03:34:46 +01:00
parent d813aa0ef2
commit 27516afaca
29 changed files with 4487 additions and 13921 deletions

View File

@@ -3,66 +3,25 @@
#include <MemoryHelpers.hpp>
namespace Util {
enum RomTypes {
Z64 = 0x80371240,
N64 = 0x40123780,
V64 = 0x37804012
};
inline void GetRomCRC(size_t size, u8 *rom, u32 &crc) {
RomTypes endianness;
memcpy(&endianness, rom, 4);
endianness = static_cast<RomTypes>(be32toh(endianness));
#define Z64 0x80371240
#define N64 0x40123780
#define V64 0x37804012
template <bool toBE = false>
inline void SwapN64Rom(size_t size, u8 *rom, u32 endianness) {
switch (endianness) {
case RomTypes::V64: {
case V64:
SwapBuffer16(size, rom);
crc = crc32(0, rom, size);
}
if constexpr(!toBE)
SwapBuffer32(size, rom);
break;
case RomTypes::N64: {
SwapBuffer32(size, rom);
crc = crc32(0, rom, size);
}
case N64:
if constexpr(toBE)
SwapBuffer32(size, rom);
break;
case RomTypes::Z64:
crc = crc32(0, rom, size);
break;
default:
panic("Unrecognized rom format! Make sure this is a valid Nintendo 64 ROM dump!\n");
}
}
inline void SwapN64Rom(size_t size, u8 *rom, u32 &crc, u32 &cicChecksum) {
RomTypes endianness;
memcpy(&endianness, rom, 4);
endianness = static_cast<RomTypes>(be32toh(endianness));
switch (endianness) {
case RomTypes::V64: {
u8 *temp = (u8 *) calloc(size, 1);
memcpy(temp, rom, size);
SwapBuffer16(size, temp);
crc = crc32(0, temp, size);
cicChecksum = crc32(0, &temp[0x40], 0x9c0);
free(temp);
SwapBuffer32(size, rom);
SwapBuffer16(size, rom);
}
break;
case RomTypes::N64: {
u8 *temp = (u8 *) calloc(size, 1);
memcpy(temp, rom, size);
SwapBuffer32(size, temp);
crc = crc32(0, temp, size);
cicChecksum = crc32(0, &temp[0x40], 0x9c0);
free(temp);
}
break;
case RomTypes::Z64:
crc = crc32(0, rom, size);
cicChecksum = crc32(0, &rom[0x40], 0x9c0);
SwapBuffer32(size, rom);
case Z64:
if constexpr(!toBE)
SwapBuffer32(size, rom);
break;
default:
panic("Unrecognized rom format! Make sure this is a valid Nintendo 64 ROM dump!\n");