diff --git a/desmume/src/MMU.cpp b/desmume/src/MMU.cpp index dd7ce435c..4c5b5477e 100644 --- a/desmume/src/MMU.cpp +++ b/desmume/src/MMU.cpp @@ -1355,6 +1355,9 @@ void FASTCALL MMU_writeToGCControl(u32 val) } else { + T1WriteLong(MMU.MMU_MEM[0][0x40], 0x1A4, val & 0x7F7FFFFF); + GCLOG("SCUTTLE????\n"); + return; //GCLOG("GC operation terminated or declined. please report, unless you just booted from firmware.\n"); } diff --git a/desmume/src/addons/slot1_retail_nand.cpp b/desmume/src/addons/slot1_retail_nand.cpp index 57efab953..8399c337b 100644 --- a/desmume/src/addons/slot1_retail_nand.cpp +++ b/desmume/src/addons/slot1_retail_nand.cpp @@ -77,6 +77,7 @@ public: switch(operation) { case eSlot1Operation_00_ReadHeader_Unencrypted: + case eSlot1Operation_2x_SecureAreaLoad: case eSlot1Operation_B7_Read: rom.start(operation,protocol.address); return; @@ -113,6 +114,7 @@ public: switch(operation) { case eSlot1Operation_00_ReadHeader_Unencrypted: + case eSlot1Operation_2x_SecureAreaLoad: case eSlot1Operation_B7_Read: return rom.read(); } @@ -142,6 +144,7 @@ public: { case eSlot1Operation_00_ReadHeader_Unencrypted: case eSlot1Operation_B7_Read: + case eSlot1Operation_2x_SecureAreaLoad: return; } diff --git a/desmume/src/addons/slot1comp_protocol.cpp b/desmume/src/addons/slot1comp_protocol.cpp index 61cf2480c..f4793e555 100644 --- a/desmume/src/addons/slot1comp_protocol.cpp +++ b/desmume/src/addons/slot1comp_protocol.cpp @@ -90,7 +90,7 @@ void Slot1Comp_Protocol::write_command_KEY1(GC_Command command) GCLOG("[GC] (key1-decrypted):"); command.print(); //and process it: - int cmd = command.bytes[0]&0xF0; + int cmd = command.bytes[0]; switch(cmd&0xF0) { case 0x10: @@ -99,7 +99,17 @@ void Slot1Comp_Protocol::write_command_KEY1(GC_Command command) //we handle this operation ourselves break; case 0x20: + operation = eSlot1Operation_2x_SecureAreaLoad; delay = 0x910, length = 0x11A8; + + //TODO - more endian-safe way of doing this (theres examples in R4) + { + u64 cmd64 = bswap64(*(u64*)command.bytes); + //todo - parse into blocknumber + address = (u32)((cmd64 >> 32) & 0xF000); + } + client->slot1client_startOperation(operation); + break; case 0x30: break; @@ -130,7 +140,7 @@ void Slot1Comp_Protocol::write_command_NORMAL(GC_Command command) { operation = eSlot1Operation_B7_Read; - //TODO - more endian-safe way of doing this + //TODO - more endian-safe way of doing this (theres examples in R4) u64 cmd64 = bswap64(*(u64*)command.bytes); address = (u32)((cmd64 >> 24)); length = 0x200; @@ -191,11 +201,7 @@ u32 Slot1Comp_Protocol::read_GCDATAIN(u8 PROCNUM) { switch(operation) { - case eSlot1Operation_00_ReadHeader_Unencrypted: - case eSlot1Operation_B7_Read: - return client->slot1client_read_GCDATAIN(operation); - - case eSlot1Operation_Unknown: + default: return client->slot1client_read_GCDATAIN(operation); case eSlot1Operation_90_ChipID: diff --git a/desmume/src/addons/slot1comp_protocol.h b/desmume/src/addons/slot1comp_protocol.h index 001260037..2af4105ad 100644 --- a/desmume/src/addons/slot1comp_protocol.h +++ b/desmume/src/addons/slot1comp_protocol.h @@ -38,8 +38,9 @@ enum eSlot1Operation //---------- //---------- - //KEY2 mode operations + //KEY1 mode operations eSlot1Operation_1x_ChipID, + eSlot1Operation_2x_SecureAreaLoad, //---------- //---------- diff --git a/desmume/src/addons/slot1comp_rom.cpp b/desmume/src/addons/slot1comp_rom.cpp index d1523683b..5a86aaa7c 100644 --- a/desmume/src/addons/slot1comp_rom.cpp +++ b/desmume/src/addons/slot1comp_rom.cpp @@ -38,6 +38,15 @@ u32 Slot1Comp_Rom::read() } break; + case eSlot1Operation_2x_SecureAreaLoad: + { + //see B7 for details + address &= gameInfo.mask; //sanity check + u32 ret = T1ReadLong(MMU.CART_ROM, address); + address = (address&~0xFFF) + ((address+4)&0xFFF); + return ret; + } + case eSlot1Operation_B7_Read: { //is this legitimate? need some way to verify.