Skip to content

Commit

Permalink
Do not rebuild FAT table cache after flashcard ROM boot
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRobz committed Jun 12, 2019
1 parent 4d89ae9 commit 3060015
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
19 changes: 10 additions & 9 deletions retail/bootloader/source/arm7/main.arm7.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,11 +715,12 @@ int arm7_main(void) {
pleaseWaitOutput();
buildFatTableCache(romFile, 0);
} else {
tonccpy((char*)ROM_FILE_LOCATION, (char*)0x27C0000, 0x20);
tonccpy((char*)ROM_FILE_LOCATION, (char*)0x27C0000, sizeof(aFile));
}
/*if (gameOnFlashcard) {
if (gameOnFlashcard) {
romFile->fatTableCache = 0x2700000;
tonccpy((char*)ROM_FILE_LOCATION_MAINMEM, (char*)ROM_FILE_LOCATION, sizeof(aFile));
}*/
}

if (gameOnFlashcard) sdRead = true;

Expand All @@ -731,16 +732,16 @@ int arm7_main(void) {
if (fatTableEmpty) {
buildFatTableCache(savFile, 0); // Bugged, if ROM is being loaded from flashcard
} else {
tonccpy((char*)SAV_FILE_LOCATION, (char*)0x27C0020, 0x20);
tonccpy((char*)SAV_FILE_LOCATION, (char*)0x27C0020, sizeof(aFile));
}
}

if (gameOnFlashcard) sdRead = false;

if (fatTableEmpty) {
tonccpy((char*)0x27C0000, (char*)ROM_FILE_LOCATION, 0x20);
tonccpy((char*)0x27C0000, (char*)ROM_FILE_LOCATION, sizeof(aFile));
if (!gameOnFlashcard) {
tonccpy((char*)0x27C0020, (char*)SAV_FILE_LOCATION, 0x20);
tonccpy((char*)0x27C0020, (char*)SAV_FILE_LOCATION, sizeof(aFile));
}
*(u32*)(0x27C0040) = storedFileCluster;
*(u32*)(0x27C0044) = romSize;
Expand All @@ -753,9 +754,9 @@ int arm7_main(void) {
} else {
fileRead((char*)0x3700000, fatTableFile, 0x200, 0x80000, 0);
}
/*if (gameOnFlashcard) {
tonccpy((char*)0x2700000, (char*)0x3700000, 0x80000);
}*/
if (gameOnFlashcard) {
tonccpy((char*)0x2700000, (char*)0x3700000, 0x7FFE0);
}

toncset((u32*)0x027C0000, 0, 0x400);

Expand Down
9 changes: 3 additions & 6 deletions retail/cardengine/arm9/source/cardengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ vu32* volatile sharedAddr = (vu32*)CARDENGINE_SHARED_ADDRESS;
static tNDSHeader* ndsHeader = (tNDSHeader*)NDS_HEADER;

#ifdef DLDI
//static aFile* romFile = (aFile*)ROM_FILE_LOCATION_MAINMEM;
static aFile romFile;
static aFile* romFile = (aFile*)ROM_FILE_LOCATION_MAINMEM;

bool sdRead = false;
#else
Expand Down Expand Up @@ -188,7 +187,7 @@ static void clearIcache (void) {

static inline int cardReadNormal(vu32* volatile cardStruct, u32* cacheStruct, u8* dst, u32 src, u32 len, u32 page, u8* cacheBuffer, u32* cachePage) {
#ifdef DLDI
fileRead((char*)dst, romFile, src, len, 0);
fileRead((char*)dst, *romFile, src, len, 0);
#else
u32 commandRead;
u32 sector = (src/readSize)*readSize;
Expand Down Expand Up @@ -409,7 +408,7 @@ u32 cardReadDma() {
static int counter=0;
int cardReadPDash(vu32* volatile cardStruct, u32 src, u8* dst, u32 len) {
#ifdef DLDI
fileRead((char*)dst, romFile, src, len, 0);
fileRead((char*)dst, *romFile, src, len, 0);
#else
u32 commandRead;
u32 sector = (src/readSize)*readSize;
Expand Down Expand Up @@ -503,8 +502,6 @@ int cardRead(u32* cacheStruct, u8* dst0, u32 src0, u32 len0) {
//nocashMessage("!FAT_InitFiles");
return -1;
}
romFile = getFileFromCluster(ce9->fileCluster);
buildFatTableCache(&romFile, 0);

const char* romTid = getRomTid(ndsHeader);
if (strncmp(romTid, "UBR", 3) != 0) {
Expand Down
7 changes: 2 additions & 5 deletions retail/cardengine/arm9_sdk5/source/cardengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ vu32* volatile sharedAddr = (vu32*)CARDENGINE_SHARED_ADDRESS;
static tNDSHeader* ndsHeader = (tNDSHeader*)NDS_HEADER_SDK5;

#ifdef DLDI
//static aFile* romFile = (aFile*)ROM_FILE_LOCATION_MAINMEM;
static aFile romFile;
static aFile* romFile = (aFile*)ROM_FILE_LOCATION_MAINMEM;

bool sdRead = false;
#else
Expand Down Expand Up @@ -156,7 +155,7 @@ static void clearIcache (void) {

static inline int cardReadNormal(u8* dst, u32 src, u32 len) {
#ifdef DLDI
fileRead((char*)dst, romFile, src, len, 0);
fileRead((char*)dst, *romFile, src, len, 0);
#else
u32 commandRead;
u32 sector = (src/readSize)*readSize;
Expand Down Expand Up @@ -351,8 +350,6 @@ int cardRead(u32* cacheStruct, u8* dst, u32 src, u32 len) {
//nocashMessage("!FAT_InitFiles");
return -1;
}
romFile = getFileFromCluster(ce9->fileCluster);
buildFatTableCache(&romFile, 0);
#else
//if (isGameLaggy(ndsHeader)) {
if (ce9->consoleModel > 0) {
Expand Down
2 changes: 1 addition & 1 deletion retail/common/include/locations.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define EXCEPTION_STACK_LOCATION 0x23EFFFC

#define ROM_FILE_LOCATION 0x37D5000
#define ROM_FILE_LOCATION_MAINMEM 0x23FFF00
#define ROM_FILE_LOCATION_MAINMEM 0x277FFE0
#define SAV_FILE_LOCATION (ROM_FILE_LOCATION + 32) //+ sizeof(aFile)

#define LOAD_CRT0_LOCATION 0x06860000 // LCDC_BANK_D
Expand Down

0 comments on commit 3060015

Please sign in to comment.