diff --git a/source/game/firm.c b/source/game/firm.c index 1d45f5e..400772c 100644 --- a/source/game/firm.c +++ b/source/game/firm.c @@ -110,7 +110,7 @@ u32 ValidateFirm(void* firm, u32 firm_size, bool installable) { FirmSectionHeader* FindFirmArm9Section(FirmHeader* firm) { for (u32 i = 0; i < 4; i++) { FirmSectionHeader* section = firm->sections + i; - if (section->size && (section->type == 0)) + if (section->size && (section->method == FIRM_NDMA_CPY)) return section; } return NULL; diff --git a/source/game/firm.h b/source/game/firm.h index 9fcb2af..5ceb3e3 100644 --- a/source/game/firm.h +++ b/source/game/firm.h @@ -8,12 +8,16 @@ #define ARM11NCCH_OFFSET 0, 0x2A000, 0x2B000, 0x2C000 #define ARM9BIN_OFFSET 0x800 +#define FIRM_NDMA_CPY 0 +#define FIRM_XDMA_CPY 1 +#define FIRM_CPU_MEMCPY 2 + // see: https://www.3dbrew.org/wiki/FIRM#Firmware_Section_Headers typedef struct { u32 offset; u32 address; u32 size; - u32 type; + u32 method; u8 hash[0x20]; } __attribute__((packed)) FirmSectionHeader; diff --git a/source/virtual/vgame.c b/source/virtual/vgame.c index a160abd..ac2c57a 100644 --- a/source/virtual/vgame.c +++ b/source/virtual/vgame.c @@ -565,13 +565,16 @@ bool BuildVGameFirmDir(void) { for (u32 i = 0; i < 4; i++) { FirmSectionHeader* section = firm->sections + i; if (!section->size) continue; - snprintf(templates[n].name, 32, NAME_FIRM_SECTION, i, (section->type == 0) ? "arm9" : "arm11"); + snprintf(templates[n].name, 32, NAME_FIRM_SECTION, i, + (section->method == FIRM_NDMA_CPY) ? "ndma.arm9" : + (section->method == FIRM_XDMA_CPY) ? "xdma.arm11" : + (section->method == FIRM_CPU_MEMCPY) ? "memcpy" : "unknown"); templates[n].offset = section->offset; templates[n].size = section->size; templates[n].keyslot = 0xFF; templates[n].flags = VFLAG_NO_CRYPTO; n++; - if (section->type == 0) { // ARM9 section, search for Process9 + if (section->method == FIRM_NDMA_CPY) { // ARM9 section, search for Process9 u8* buffer = (u8*) (TEMP_BUFFER + (TEMP_BUFFER_SIZE/2)); u32 buffer_size = TEMP_BUFFER_SIZE/4; NcchHeader* p9_ncch; @@ -600,7 +603,7 @@ bool BuildVGameFirmDir(void) { templates[n].flags |= (VFLAG_NCCH | VFLAG_DIR); n++; } - } else if (section->type == 1) { // ARM11 section, search for modules + } else if (section->method == FIRM_XDMA_CPY) { // ARM11 section, search for modules const u32 arm11_ncch_offset[] = { ARM11NCCH_OFFSET }; NcchHeader firm_ncch; for (u32 v = 0; v < sizeof(arm11_ncch_offset) / sizeof(u32); v++) {