ça plante au moment de réinsérer la cartouche, on dirait que les fonctions de lecture de l'eeprom ne fonctionnement pas. Le code bloque à ce moment là. J'ai essayé de voir du côté du code Nitrohax, mais sans succès.
Je teste juste en modifiant l'exemple eeprom de devkitpro.
(cpp):
/*---------------------------------------------------------------------------------
Simple eeprom example
-- davr
---------------------------------------------------------------------------------*/
#include <nds.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
//---------------------------------------------------------------------------------
void pause() {
//---------------------------------------------------------------------------------
iprintf("Press start...\n");
while(1) {
scanKeys();
if(keysDown() & KEY_START)
break;
swiWaitForVBlank();
}
scanKeys();
}
//De nitrohax
void getHeader (u32* ndsHeader) {
cardParamCommand (CARD_CMD_DUMMY, 0,
CARD_ACTIVATE | CARD_CLK_SLOW | CARD_BLK_SIZE(1) | CARD_DELAY1(0x1FFF) | CARD_DELAY2(0x3F),
NULL, 0);
cardParamCommand(CARD_CMD_HEADER_READ, 0,
CARD_ACTIVATE | CARD_nRESET | CARD_CLK_SLOW | CARD_BLK_SIZE(1) | CARD_DELAY1(0x1FFF) | CARD_DELAY2(0x3F),
ndsHeader, 512);
}
//
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------
consoleDemoInit();
iprintf("Reading cart info...\n");
static u8 header1[2048];
static u8 header2[2048];
u32 ndsHeader[0x80];
sysSetBusOwners(true, true); // give ARM9 access to the cart
while(1) {
//De nitrohax
do {
swiWaitForVBlank();
getHeader (ndsHeader);
} while (ndsHeader[0] != 0xffffffff);
iprintf("Insert Game\n");
do {
swiWaitForVBlank();
getHeader (ndsHeader);
} while (ndsHeader[0] == 0xffffffff);
iprintf("Game inserted\n");
// Delay half a second for the DS card to stabilise
for (int i = 0; i < 30; i++) {
swiWaitForVBlank();
}
iprintf("Stabilised\n");
getHeader (ndsHeader);
iprintf("Header read\n");
//
//pause();
// Read the header twice to verify.
// If the card is being encrypted, we will get random junk
cardReadHeader(header1);
cardReadHeader(header2);
iprintf("Header read2\n");
// Make sure we got the same data twice
/*while(memcmp(header1, header2, 32) != 0) {
// If not, the card needs ejected and reinserted into the DS
iprintf("Please eject & reinsert DS card.\n");
pause();
cardReadHeader(header1);
cardReadHeader(header2);
}*/
// Add a null char right after the game title, so we can print it
header1[32] = '\0';
// Read some various info about the EEPROM
sysSetBusOwners(true, true); // give ARM9 access to the cart
int type = cardEepromGetType();
int size = cardEepromGetSize();
iprintf("Game ID: %s\n", header1);
iprintf("EEPROM:\n");
iprintf(" Type: %d\n", type);
iprintf(" Size: %d\n", size);
pause();
// Read the first 512 bytes of EEPROM
static u8 data[2048];
cardReadEeprom(0, data, 512, type);
iprintf("First 160 bytes of EEPROM: \n");
// Print 20 rows of 8 bytes each
for(int y=0; y<20; y++) {
// print 8 bytes as hex
for(int x=0; x<8; x++) {
iprintf("%02x ", data[y*8 + x]);
}
// print 8 bytes as characters
for(int x=0; x<8; x++) {
u8 c = data[y*8 + x];
if(isprint(c)) // only display if it's a printable character
iprintf("%c", c);
else
iprintf(".");
}
}
iprintf("Insert a new card to read again\n");
}
return 0;
}