Refactor FourCC magic uses

- Use new fourcc_t type
- Improves compiler compatibility by removing multi chars
This commit is contained in:
Joel Linn
2021-05-06 18:46:43 +02:00
committed by Rick Gibbed
parent 4daa3f5a52
commit a86d7173e1
25 changed files with 65 additions and 42 deletions

View File

@@ -134,13 +134,15 @@ X_STATUS UserModule::LoadFromFile(const std::string_view path) {
X_STATUS UserModule::LoadFromMemory(const void* addr, const size_t length) {
auto processor = kernel_state()->processor();
auto magic = xe::load_and_swap<uint32_t>(addr);
if (magic == 'XEX2' || magic == 'XEX1') {
be<fourcc_t> magic;
magic.value = xe::load<fourcc_t>(addr);
if (magic == xe::cpu::kXEX2Signature || magic == xe::cpu::kXEX1Signature) {
module_format_ = kModuleFormatXex;
} else if (magic == 0x7F454C46 /* 0x7F 'ELF' */) {
} else if (magic == xe::cpu::kElfSignature) {
module_format_ = kModuleFormatElf;
} else {
auto magic16 = xe::load_and_swap<uint16_t>(addr);
be<uint16_t> magic16;
magic16.value = xe::load<uint16_t>(addr);
if (magic16 == 0x4D5A) {
XELOGE("XNA executables are not yet implemented");
return X_STATUS_NOT_IMPLEMENTED;