From 3956e8ab91ffa51c1389aa2090fc1d39248cd89b Mon Sep 17 00:00:00 2001 From: d0k3 Date: Mon, 23 Jul 2018 22:20:20 +0200 Subject: [PATCH] Prevent wrong recognition of GW type EmuNANDs --- arm9/source/nand/nand.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arm9/source/nand/nand.c b/arm9/source/nand/nand.c index d3b46bd..e91aaea 100644 --- a/arm9/source/nand/nand.c +++ b/arm9/source/nand/nand.c @@ -569,9 +569,14 @@ u32 AutoEmuNandBase(bool reset) } } - emunand_base_sector = 0x000000; // GW type EmuNAND - if (GetNandPartitionInfo(NULL, NP_TYPE_NCSD, NP_SUBTYPE_CTR, 0, NAND_EMUNAND) != 0) - emunand_base_sector = 0x000001; // RedNAND type EmuNAND + emunand_base_sector = 0x000001; // RedNAND type EmuNAND, default + if (GetNandPartitionInfo(NULL, NP_TYPE_NCSD, NP_SUBTYPE_CTR, 0, NAND_EMUNAND) != 0) { + emunand_base_sector = 0x000000; // GW type EmuNAND + if (!GetNandSizeSectors(NAND_EMUNAND) || // make sure this is no false positive + (GetNandPartitionInfo(NULL, NP_TYPE_NCSD, NP_SUBTYPE_CTR, 0, NAND_EMUNAND) != 0)) + // still nothing found? revert to default (RedNAND offset) + emunand_base_sector = 0x000001; + } return emunand_base_sector; }