From 4baad291dcd98d8d392541b578a66ab1cc941c04 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sat, 31 Aug 2013 18:51:09 +0000 Subject: [PATCH] clarify chipId checks and fake booting --- desmume/src/NDSSystem.cpp | 20 +++++++++----------- desmume/src/addons/slot1comp_protocol.cpp | 10 +++------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index d2adcfa4c..93717369f 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -2647,7 +2647,7 @@ void NDS_Reset() _MMU_write08(0x027FFC80 + fw_index, temp_buffer[fw_index]); } - //firmware copies the whole header to Main RAM 0x27FFE00 on startup. (http://nocash.emubase.de/gbatek.htm#dscartridgeheader) + //something copies the whole header to Main RAM 0x27FFE00 on startup. (http://nocash.emubase.de/gbatek.htm#dscartridgeheader) //once upon a time this copied 0x90 more. this was thought to be wrong, and changed. if(nds.Is_DSI()) { @@ -2669,20 +2669,18 @@ void NDS_Reset() MMU.ARM9_REG[0x300] = 1; MMU.ARM7_REG[0x300] = 1; - //firmware makes system think it's booted from card -- EXTREMELY IMPORTANT!!! Thanks to cReDiAr - _MMU_write08(0x02FFFC40,0x1); - _MMU_write08(0x02FFFC40,0x1); + //firmware makes system think it's booted from card -- EXTREMELY IMPORTANT!!! This is actually checked by some things. (which things?) Thanks to cReDiAr + _MMU_write08(0x02FFFC40,0x1); // removed redundant write to ARM9, this is going to shared main memory. But one has to wonder why r3478 was made which corrected a typo resulting in only ARMCPU_ARM7 getting used. - // - _MMU_write32(0x027FF800, gameInfo.chipID); // Chip ID - _MMU_write32(0x027FF804, gameInfo.chipID); // Secure Chip ID - _MMU_write32(0x027FFC00, gameInfo.chipID); // 2nd Secure Chip ID + //the chipId is read several times + //for some reason, each of those reads get stored here. + _MMU_write32(0x027FF800, gameInfo.chipID); //1st chipId + _MMU_write32(0x027FF804, gameInfo.chipID); //2nd (secure) chipId + _MMU_write32(0x027FFC00, gameInfo.chipID); //3rd (secure) chipId + // Write the header checksum to memory _MMU_write16(0x027FF808, gameInfo.header.headerCRC16); - // Write the header checksum to memory (the firmware needs it to see the cart) - //_MMU_write16(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. diff --git a/desmume/src/addons/slot1comp_protocol.cpp b/desmume/src/addons/slot1comp_protocol.cpp index 8dfa82040..2363e2c8d 100644 --- a/desmume/src/addons/slot1comp_protocol.cpp +++ b/desmume/src/addons/slot1comp_protocol.cpp @@ -209,13 +209,9 @@ u32 Slot1Comp_Protocol::read_GCDATAIN(u8 PROCNUM) case eSlot1Operation_90_ChipID: case eSlot1Operation_B8_ChipID: - // 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 - // was removed. - // As DeSmuME normally boots directly from the game, the chip - // ID in main mem is zero and this value needs to be - // zero too. + + //Most games continuously compare the current chipId with the value in + //stored in memory at boot-up, probably to know if the card was removed. //staff of kings verifies this (it also uses the arm7 IRQ 20 to detect card ejects) return chipId;