mirror of
https://github.com/rvtr/GodMode9i.git
synced 2025-11-02 00:11:07 -04:00
Detect 3DS console without reading NAND
This commit is contained in:
parent
531e58531b
commit
7750ab47c0
@ -123,6 +123,12 @@ int main() {
|
||||
|
||||
setPowerButtonCB(powerButtonCB);
|
||||
|
||||
// Check for 3DS
|
||||
u8 byteBak = i2cReadRegister(0x4A, 0x71);
|
||||
i2cWriteRegister(0x4A, 0x71, 0xD2);
|
||||
fifoSendValue32(FIFO_USER_05, i2cReadRegister(0x4A, 0x71));
|
||||
i2cWriteRegister(0x4A, 0x71, byteBak);
|
||||
|
||||
if (isDSiMode() /*|| ((REG_SCFG_EXT & BIT(17)) && (REG_SCFG_EXT & BIT(18)))*/) {
|
||||
/*for (int i = 0; i < 8; i++) {
|
||||
*(u8*)(0x2FFFD00+i) = *(u8*)(0x4004D07-i); // Get ConsoleID
|
||||
|
||||
@ -154,6 +154,7 @@ int main(int argc, char **argv) {
|
||||
*(vu32*)(0x0DFFFE0C) = 0x474D3969; // Check for 32MB of RAM
|
||||
if (*(vu32*)(0x0DFFFE0C) == 0x474D3969) {
|
||||
ramdrive2Mount();
|
||||
is3DS = fifoGetValue32(FIFO_USER_05) != 0xD2;
|
||||
}
|
||||
if (!(keysHeld() & KEY_X)) {
|
||||
nandMounted = nandMount();
|
||||
|
||||
@ -11,8 +11,6 @@
|
||||
//#define SECTOR_SIZE 512
|
||||
#define CRYPT_BUF_LEN 64
|
||||
|
||||
extern bool is3DS;
|
||||
|
||||
extern bool nand_Startup();
|
||||
|
||||
static u8* crypt_buf = 0;
|
||||
@ -49,11 +47,11 @@ bool nandio_startup() {
|
||||
if (!nand_Startup()) return false;
|
||||
|
||||
nand_ReadSectors(0, 1, sector_buf);
|
||||
is3DS = parse_ncsd(sector_buf, 0) == 0;
|
||||
//if (is3DS) return false;
|
||||
bool isDSi = parse_ncsd(sector_buf, 0) != 0;
|
||||
//if (!isDSi) return false;
|
||||
|
||||
if (*(u32*)(0x2FFD7BC) == 0) {
|
||||
if (is3DS) {
|
||||
if (!isDSi) {
|
||||
FILE* cidFile = fopen("sd:/gm9/out/nand_cid.mem", "rb");
|
||||
if (!cidFile) return false;
|
||||
fread((void*)0x2FFD7BC, 1, 16, cidFile);
|
||||
@ -75,12 +73,12 @@ bool nandio_startup() {
|
||||
}
|
||||
|
||||
// iprintf("sector 0 is %s\n", is3DS ? "3DS" : "DSi");
|
||||
dsi_crypt_init((const u8*)consoleIDfixed, (const u8*)0x2FFD7BC, is3DS);
|
||||
dsi_crypt_init((const u8*)consoleIDfixed, (const u8*)0x2FFD7BC, !isDSi);
|
||||
dsi_nand_crypt(sector_buf, sector_buf, 0, SECTOR_SIZE / AES_BLOCK_SIZE);
|
||||
parse_mbr(sector_buf, is3DS, 0);
|
||||
parse_mbr(sector_buf, !isDSi, 0);
|
||||
|
||||
mbr_t *mbr = (mbr_t*)sector_buf;
|
||||
nandio_set_fat_sig_fix(is3DS ? 0 : mbr->partitions[0].offset);
|
||||
nandio_set_fat_sig_fix(isDSi ? mbr->partitions[0].offset : 0);
|
||||
|
||||
if (crypt_buf == 0) {
|
||||
crypt_buf = (u8*)memalign(32, SECTOR_SIZE * CRYPT_BUF_LEN);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user