1.8 Release Commit ...

* Final D2 init command now uses the value from the cart's header (found
at offset 0x8) instead of the hardcoded value found with most 16g and 8g
carts.
This commit is contained in:
ApacheThunder 2024-04-11 23:02:40 -05:00
parent ebfa1b81ab
commit 6fa7430f62
5 changed files with 21 additions and 7 deletions

2
.gitignore vendored
View File

@ -38,6 +38,8 @@
*.cmd *.cmd
*.nds *.nds
*.app *.app
*.tmd
*.zip
*.arm7 *.arm7
*.arm9 *.arm9
*.elf *.elf

View File

@ -24,7 +24,7 @@ DATA :=
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
ARCH := -mthumb -mthumb-interwork ARCH := -mthumb -mthumb-interwork
CFLAGS := -g -Wall -Os \ CFLAGS := -g -Wall -Oz \
-mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer\ -mcpu=arm7tdmi -mtune=arm7tdmi -fomit-frame-pointer\
-ffast-math \ -ffast-math \
$(ARCH) $(ARCH)

View File

@ -155,12 +155,16 @@ void CardInit(bool Silent = true, bool SkipSlotReset = false) {
tonccpy(gameTitle, cartHeader->ndshdr.gameTitle, 12); tonccpy(gameTitle, cartHeader->ndshdr.gameTitle, 12);
tonccpy(gameCode, cartHeader->ndshdr.gameCode, 6); tonccpy(gameCode, cartHeader->ndshdr.gameCode, 6);
ndsHeader = loadHeader(cartHeader); // copy twlHeaderTemp to ndsHeader location ndsHeader = loadHeader(cartHeader); // copy twlHeaderTemp to ndsHeader location
InitCartNandReadMode(); u32 CardType = *(u32*)(DSI_HEADER + 0x08);
InitCartNandReadMode(CardType);
DoWait(); DoWait();
if (!Silent) { if (!Silent) {
if (wasDSi && SCFGUnlocked) { iprintf("SCFG_MC Status: %2x \n\n", REG_SCFG_MC); } if (wasDSi && SCFGUnlocked) { iprintf("SCFG_MC Status: %2x \n\n", REG_SCFG_MC); }
iprintf("Detected Cart Name: %12s \n\n", gameTitle); iprintf("Detected Cart Name: %12s \n\n", gameTitle);
iprintf("Detected Cart Game Id: %6s \n\n", gameCode); iprintf("Detected Cart Game Id: %6s \n\n", gameCode);
iprintf("Detected Cart Type: %8x \n\n", (unsigned int)CardType);
printf("Press any button to continue...");
do { swiWaitForVBlank(); scanKeys(); } while (!keysDown());
} }
} }
@ -790,7 +794,7 @@ void DoUdiskDump() {
}*/ }*/
int UtilityMenu() { int UtilityMenu() {
LoadTopScreenUtilitySplash(); if(!WarningPosted)LoadTopScreenUtilitySplash();
int value = -1; int value = -1;
consoleClear(); consoleClear();
printf("Press [A] to build update file\n"); printf("Press [A] to build update file\n");

View File

@ -43,12 +43,21 @@ void nrioSendCommand(u32 cmdbuffer, u32 cmdData, u8 cmd, u32 cmdflags) {
} }
}*/ }*/
// Final C1 command now reads from 0x08 location of header like origional stage1 main rom does instead of hardcoding.
// Some different capacity cards are known to use different values. 1080 = what most 16g carts use. Some 2G carts also use this value
void InitCartNandReadMode() { void InitCartNandReadMode(u32 CardType) {
// Only bricked carts would present values like these. Hard Code 1083 if this is the case
switch (CardType) {
case 0x00000000: { CardType = 0x10830000; }break;
case 0xFFFFFFFF: { CardType = 0x10830000; }break;
}
cardParamCommand (0x66, 0, CARD_ACTIVATE | CARD_nRESET | CARD_BLK_SIZE(7) | CARD_SEC_CMD | BIT(20) | BIT(19) | BIT(14) | BIT(13), (u32*)INITBUFFER, 128); cardParamCommand (0x66, 0, CARD_ACTIVATE | CARD_nRESET | CARD_BLK_SIZE(7) | CARD_SEC_CMD | BIT(20) | BIT(19) | BIT(14) | BIT(13), (u32*)INITBUFFER, 128);
cardParamCommand (0xC1, 0x0D210000, CARD_ACTIVATE | CARD_nRESET | CARD_BLK_SIZE(7) | BIT(17), (u32*)(INITBUFFER + 0x10), 128); cardParamCommand (0xC1, 0x0D210000, CARD_ACTIVATE | CARD_nRESET | CARD_BLK_SIZE(7) | BIT(17), (u32*)(INITBUFFER + 0x10), 128);
cardParamCommand (0xC1, 0x0FB00000, CARD_ACTIVATE | CARD_nRESET | CARD_BLK_SIZE(7) | BIT(17), (u32*)(INITBUFFER + 0x10), 128); cardParamCommand (0xC1, 0x0FB00000, CARD_ACTIVATE | CARD_nRESET | CARD_BLK_SIZE(7) | BIT(17), (u32*)(INITBUFFER + 0x10), 128);
cardParamCommand (0xC1, 0x10830000, CARD_ACTIVATE | CARD_nRESET | CARD_BLK_SIZE(7) | BIT(17), (u32*)(INITBUFFER + 0x20), 128); cardParamCommand (0xC1, CardType, CARD_ACTIVATE | CARD_nRESET | CARD_BLK_SIZE(7) | BIT(17), (u32*)(INITBUFFER + 0x20), 128);
// cardParamCommand (0xC1, 0x10830000, CARD_ACTIVATE | CARD_nRESET | CARD_BLK_SIZE(7) | BIT(17), (u32*)(INITBUFFER + 0x20), 128);
// DoWait(8); // DoWait(8);
/**(vu32*)INITBUFFER = nrioInit(0x66, 0xAF586000); /**(vu32*)INITBUFFER = nrioInit(0x66, 0xAF586000);
nrioSendCommand((u32)(INITBUFFER + 0x10), 0x0D210000, 0xC1, 0xA7020000); nrioSendCommand((u32)(INITBUFFER + 0x10), 0x0D210000, 0xC1, 0xA7020000);

View File

@ -5,8 +5,7 @@
extern "C" { extern "C" {
#endif #endif
void InitCartNandReadMode(void); void InitCartNandReadMode(u32 CardType);
void InitCartNandReadModeALT(void);
ITCM_CODE void nrio_readSectors(void* destination, u32 rom_offset, u32 num_words); ITCM_CODE void nrio_readSectors(void* destination, u32 rom_offset, u32 num_words);
ITCM_CODE void nrio_readSector(void* destination, u32 rom_offset); ITCM_CODE void nrio_readSector(void* destination, u32 rom_offset);
ITCM_CODE void nrio_readSectorB7(void* destination, u32 rom_offset); ITCM_CODE void nrio_readSectorB7(void* destination, u32 rom_offset);