From 5d00dee27b6bd8c361c493f02a739550a7a7f4d6 Mon Sep 17 00:00:00 2001 From: RocketRobz Date: Thu, 2 May 2019 20:45:45 -0600 Subject: [PATCH] Revert some commits --- retail/arm9/source/conf_sd.cpp | 9 ------ retail/bootloader/source/arm7/main.arm7.c | 37 +++++++++++------------ 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/retail/arm9/source/conf_sd.cpp b/retail/arm9/source/conf_sd.cpp index d0b8145c7..1028cc69b 100644 --- a/retail/arm9/source/conf_sd.cpp +++ b/retail/arm9/source/conf_sd.cpp @@ -288,14 +288,5 @@ int loadFromSD(configuration* conf, const char *bootstrapPath) { fclose(fatTableFile); } - FILE *fatTableFile = fopen(fatTableFilePath.c_str(), "rb"); - if (fatTableFile) { - fread((void*)0x02700000, 1, 0x400, fatTableFile); - if (*(u32*)(0x2700200) != 0) { - fread((void*)0x02700400, 1, 0x7FE00, fatTableFile); - } - } - fclose(fatTableFile); - return 0; } diff --git a/retail/bootloader/source/arm7/main.arm7.c b/retail/bootloader/source/arm7/main.arm7.c index e1b85550a..0f7d326e6 100644 --- a/retail/bootloader/source/arm7/main.arm7.c +++ b/retail/bootloader/source/arm7/main.arm7.c @@ -162,9 +162,8 @@ static void resetMemory_ARM7(void) { arm7clearRAM(); // clear exclusive IWRAM toncset((u32*)0x02000000, 0, 0x3F4000); // clear most of EWRAM - except before 0x023F4000, which has the arm9 code - toncset((u32*)0x02400000, 0, 0x300000); // clear other part of EWRAM - except before FAT table and ce7 binary - toncset((u32*)0x02780200, 0, 0x5FE00); // clear part of EWRAM - toncset((u32*)0x027F0000, 0, 0x810000); + toncset((u32*)0x02400000, 0, 0x3E0000); // clear other part of EWRAM - except before ce7 binary + toncset((u32*)0x027F0000, 0, 0x810000); // clear part of EWRAM REG_IE = 0; REG_IF = ~0; *(vu32*)(0x04000000 - 4) = 0; // IRQ_HANDLER ARM7 version @@ -646,7 +645,7 @@ int arm7_main(void) { nocashMessage("!FAT_InitFiles"); return -1; } - + if (logging) { enableDebug(getBootFileCluster("NDSBTSRP.LOG", 0)); } @@ -667,6 +666,11 @@ int arm7_main(void) { return -1; } + // FAT table file + aFile fatTableFile = getFileFromCluster(fatTableFileCluster); + if (fatTableFile.firstCluster != CLUSTER_FREE) { + fileRead((char*)0x2700000, fatTableFile, 0, 0x400, -1); + } bool fatTableEmpty = (*(u32*)(0x2700200) == 0); if (*(u32*)(0x2700040) != storedFileCluster @@ -696,24 +700,19 @@ int arm7_main(void) { } if (fatTableEmpty) { - // FAT table file - aFile fatTableFile = getFileFromCluster(fatTableFileCluster); - - if (fatTableFile.firstCluster != CLUSTER_FREE) { - tonccpy((char*)0x2700000, (char*)ROM_FILE_LOCATION, 0x20); - tonccpy((char*)0x2700020, (char*)SAV_FILE_LOCATION, 0x20); - *(vu32*)(0x2700040) = storedFileCluster; - *(vu32*)(0x2700044) = romSize; - *(vu32*)(0x2700048) = saveFileCluster; - *(vu32*)(0x270004C) = saveSize; - fileWrite((char*)0x2700000, fatTableFile, 0, 0x200, -1); - fileWrite((char*)0x3700000, fatTableFile, 0x200, 0x80000, -1); - } + tonccpy((char*)0x2700000, (char*)ROM_FILE_LOCATION, 0x20); + tonccpy((char*)0x2700020, (char*)SAV_FILE_LOCATION, 0x20); + *(vu32*)(0x2700040) = storedFileCluster; + *(vu32*)(0x2700044) = romSize; + *(vu32*)(0x2700048) = saveFileCluster; + *(vu32*)(0x270004C) = saveSize; + fileWrite((char*)0x2700000, fatTableFile, 0, 0x200, -1); + fileWrite((char*)0x3700000, fatTableFile, 0x200, 0x80000, -1); } else { - tonccpy((char*)0x3700000, (char*)0x2700200, 0x80000); + fileRead((char*)0x3700000, fatTableFile, 0x200, 0x80000, 0); } - toncset((u32*)0x02700000, 0, 0x80200); + toncset((u32*)0x02700000, 0, 0x400); // File containing cached patch offsets aFile patchOffsetCacheFile = getFileFromCluster(patchOffsetCacheFileCluster);