diff --git a/desmume/src/addons/slot1_retail_nand.cpp b/desmume/src/addons/slot1_retail_nand.cpp index 0c81daa36..7c9d9426b 100644 --- a/desmume/src/addons/slot1_retail_nand.cpp +++ b/desmume/src/addons/slot1_retail_nand.cpp @@ -93,10 +93,10 @@ public: { case eSlot1Operation_00_ReadHeader_Unencrypted: protocol.address = (protocol.command.bytes[1] << 24) | (protocol.command.bytes[2] << 16) | (protocol.command.bytes[3] << 8) | protocol.command.bytes[4]; + rom.start(operation,protocol.address); break; - //case eSlot1Operation_B7_Read: - //??? + //case eSlot1Operation_B7_Read: //zero 15-sep-2014 - this was removed during epoch of addon re-engineering to fix a bug case eSlot1Operation_2x_SecureAreaLoad: //don't re-generate address here. it was already done, according to different rules, for this operation diff --git a/desmume/src/addons/slot1comp_protocol.cpp b/desmume/src/addons/slot1comp_protocol.cpp index 9ca30418a..80dc67e35 100644 --- a/desmume/src/addons/slot1comp_protocol.cpp +++ b/desmume/src/addons/slot1comp_protocol.cpp @@ -89,6 +89,7 @@ void Slot1Comp_Protocol::write_command_KEY1(GC_Command command) delay = 0x910, length = 4; //we handle this operation ourselves break; + case 0x20: operation = eSlot1Operation_2x_SecureAreaLoad; delay = 0x910, length = 0x11A8; @@ -101,20 +102,25 @@ void Slot1Comp_Protocol::write_command_KEY1(GC_Command command) u64 cmd64 = *(u64*)command.bytes; #endif //todo - parse into blocknumber - address = (u32)((cmd64 >> 32) & 0xF000); + u32 blocknumber = (cmd64>>44)&0xFFFF; + if(blocknumber<4||blocknumber>7) + printf("SLOT1 WARNING: INVALID BLOCKNUMBER FOR \"Get Secure Area Block\": 0x%04X\n",blocknumber); + address = blocknumber*0x1000; } client->slot1client_startOperation(operation); - break; + case 0x40: //switch to KEY2 delay = 0x910, length = 0; //well.. not really... yet. GCLOG("[GC] KEY2 ACTIVATED\n"); break; + case 0x60: //KEY2 disable? any info? break; + case 0xA0: delay = 0x910, length = 0; mode = eCardMode_NORMAL; diff --git a/desmume/src/addons/slot1comp_rom.cpp b/desmume/src/addons/slot1comp_rom.cpp index 50415d9c1..bc72ca804 100644 --- a/desmume/src/addons/slot1comp_rom.cpp +++ b/desmume/src/addons/slot1comp_rom.cpp @@ -41,7 +41,10 @@ u32 Slot1Comp_Rom::read() case eSlot1Operation_2x_SecureAreaLoad: { //see B7 for details - address &= gameInfo.mask; //sanity check + + //zero 15-sep-2014 - this is meaningless. newer mask is actually reasonable + //address &= gameInfo.mask; //sanity check + address &= 0x3FFF; //memory safe sanity test u32 ret = LE_TO_LOCAL_32(*(u32*)(gameInfo.secureArea + (address - 0x4000))); address = (address&~0xFFF) + ((address+4)&0xFFF); return ret;