Skip to content

Commit

Permalink
Fixed emunand detection on n3ds
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertoSONIC committed Aug 10, 2015
1 parent bc08b47 commit 3b92f31
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rxtools/source/features/cfw.c
Expand Up @@ -47,7 +47,7 @@ _Noreturn void (* const _softreset)() = (void *)0x080F0000;
// @breif Determine platform of the console.
// @retval PLATFORM_N3DS for New3DS, and PLATFORM_3DS for Old3DS.
// @note Maybe modified to support more platforms
static Platform_UnitType Platform_CheckUnit(void) {
Platform_UnitType Platform_CheckUnit(void) {
return *(u32 *)PLATFORM_REG_ADDR;
}

Expand Down
1 change: 1 addition & 0 deletions rxtools/source/features/cfw.h
Expand Up @@ -36,6 +36,7 @@ typedef enum {
PLATFORM_N3DS=7,
} Platform_UnitType;

Platform_UnitType Platform_CheckUnit(void);
int DevMode();
void FirmLoader();
void rxModeWithSplash(int emu);
Expand Down
12 changes: 8 additions & 4 deletions rxtools/source/lib/nand.c
Expand Up @@ -20,6 +20,7 @@
#include "crypto.h"
#include "fatfs/sdmmc.h"
#include "nand.h"
#include "cfw.h"

u8 NANDCTR[16];
int sysversion = 0;
Expand Down Expand Up @@ -64,13 +65,16 @@ void FSNandInitCrypto(void) {

unsigned int checkEmuNAND() {
u8 *check = (u8 *)0x26000000;
sdmmc_sdcard_readsectors(0x3AF00000 / 0x200, 1, check);
int isn3ds = 0;
if (Platform_CheckUnit() == PLATFORM_N3DS)isn3ds = 1;

sdmmc_sdcard_readsectors(isn3ds ? 0x4D800000 /0x200 : 0x3AF00000 / 0x200, 1, check);
if (*((char *)check + 0x100) == 'N' && *((char *)check + 0x101) == 'C' && *((char *)check + 0x102) == 'S' && *((char *)check + 0x103) == 'D') {
return 0x3AF00000;
return isn3ds ? 0x4D800000 : 0x3AF00000;
} else {
sdmmc_sdcard_readsectors(0x3BA00000 / 0x200, 1, check);
sdmmc_sdcard_readsectors(isn3ds ? 0x76000000 /0x200 : 0x3BA00000 / 0x200, 1, check);
if (*((char *)check + 0x100) == 'N' && *((char *)check + 0x101) == 'C' && *((char *)check + 0x102) == 'S' && *((char *)check + 0x103) == 'D') {
return 0x3BA00000;
return isn3ds ? 0x76000000 : 0x3BA00000;
} else {
return 0;
}
Expand Down

3 comments on commit 3b92f31

@AlbertoSONIC
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It detects n3ds emunand ;)

@AlbertoSONIC
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 :D

@AlbertoSONIC
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still a WIP, but I already have n3ds emunand ready. I'm just waiting @173210 for finding a way of keeping o3ds and n3ds support at the same time ;)

Please sign in to comment.