- fix boot games without real firmware (tested on Contra 4);
This commit is contained in:
mtabachenko 2013-08-12 16:13:31 +00:00
parent 3a3179a1b3
commit 68be9026c0
4 changed files with 23 additions and 6 deletions

View File

@ -585,6 +585,15 @@ int NDS_LoadROM(const char *filename, const char *physicalName, const char *logi
gameInfo.populate();
gameInfo.crc = crc32(0,(u8*)gameInfo.romdata,gameInfo.romsize);
// 1st byte - Manufacturer (C2h = Macronix)
// 2nd byte - Chip size in megabytes minus 1 (eg. 0Fh = 16MB)
// 3rd byte - Reserved/zero (probably upper bits of chip size)
// 4th byte - Bit7: Secure Area Block transfer mode (8x200h or 1000h)
// It doesnt look like the chip size is important.
gameInfo.chipID = 0x00000000 | 0x00000000 | 0x00000F00 | 0x000000C2;
INFO("\nROM game code: %c%c%c%c\n", gameInfo.header.gameCode[0], gameInfo.header.gameCode[1], gameInfo.header.gameCode[2], gameInfo.header.gameCode[3]);
INFO("ROM crc: %08X\n", gameInfo.crc);
INFO("ROM serial: %s\n", gameInfo.ROMserial);
@ -2657,6 +2666,16 @@ void NDS_Reset()
_MMU_write08<ARMCPU_ARM9>(0x02FFFC40,0x1);
_MMU_write08<ARMCPU_ARM7>(0x02FFFC40,0x1);
//
_MMU_write32<ARMCPU_ARM7>(0x027FF800, gameInfo.chipID); // Chip ID
_MMU_write32<ARMCPU_ARM7>(0x027FF804, gameInfo.chipID); // Secure Chip ID
_MMU_write32<ARMCPU_ARM7>(0x027FFC00, gameInfo.chipID); // 2nd Secure Chip ID
// Write the header checksum to memory
_MMU_write16<ARMCPU_ARM9>(0x027FF808, gameInfo.header.headerCRC16);
// Write the header checksum to memory (the firmware needs it to see the cart)
//_MMU_write16<ARMCPU_ARM9>(0x027FF808, T1ReadWord(MMU.CART_ROM, 0x15E));
// Save touchscreen calibration info in a structure
// so we can easily access it at any time
// TODO - this isn't good. need revising.

View File

@ -319,6 +319,7 @@ struct GameInfo
{
GameInfo() : romdata(NULL),
crc(0),
chipID(0x00000FC2),
romsize(0),
allocatedSize(0),
mask(0)
@ -373,6 +374,7 @@ struct GameInfo
romsize = size;
}
u32 crc;
u32 chipID;
NDS_header header;
char ROMserial[20];
char ROMname[20];

View File

@ -80,8 +80,6 @@ private:
// It doesnt look like the chip size is important.
u32 chipID = 0x00000000 | 0x00000000 | 0x00000F00 | 0x000000C2;
// Note: the BIOS stores the chip ID in main memory
// Most games continuously compare the chip ID with
// the value in memory, probably to know if the card
@ -91,7 +89,7 @@ private:
// zero too.
//staff of kings verifies this (it also uses the arm7 IRQ 20)
return chipID;
return gameInfo.chipID;
}
break;

View File

@ -120,11 +120,9 @@ private:
// ID in main mem is zero and this value needs to be
// zero too.
u32 chipID = 0;
//note that even if desmume was booting from firmware, and reading this chip ID to store in main memory,
//this still works, since it will have read 00 originally and then read 00 to validate.
return chipID;
return gameInfo.chipID;
}
break;