From 96db719b0c73e612f438753be9e06210c15786a0 Mon Sep 17 00:00:00 2001 From: normmatt234 Date: Tue, 15 Sep 2009 12:14:17 +0000 Subject: [PATCH] Support new Backup command required for Pokemon HG/SS to work without triggering an anti-piracy protection. --- desmume/src/MMU.cpp | 4 ++-- desmume/src/mc.cpp | 12 ++++++++---- desmume/src/mc.h | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/desmume/src/MMU.cpp b/desmume/src/MMU.cpp index 056a3158b..a3fbe78af 100644 --- a/desmume/src/MMU.cpp +++ b/desmume/src/MMU.cpp @@ -2245,7 +2245,7 @@ void FASTCALL _MMU_ARM9_write16(u32 adr, u16 val) MMU.AUX_SPI_CMD = val & 0xFF; //T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, bm_transfer(&MMU.bupmem, val)); - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, MMU_new.backupDevice.data_command((u8)val)); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, MMU_new.backupDevice.data_command((u8)val,ARMCPU_ARM9)); return; case REG_DISPA_BG0CNT : @@ -3184,7 +3184,7 @@ void FASTCALL _MMU_ARM7_write16(u32 adr, u16 val) MMU.AUX_SPI_CMD = val & 0xFF; //T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, bm_transfer(&MMU.bupmem, val)); - T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, MMU_new.backupDevice.data_command((u8)val)); + T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM7][(REG_AUXSPIDATA >> 20) & 0xff], REG_AUXSPIDATA & 0xfff, MMU_new.backupDevice.data_command((u8)val,ARMCPU_ARM7)); return; case REG_SPICNT : diff --git a/desmume/src/mc.cpp b/desmume/src/mc.cpp index 7bb6e4b7f..40d734c66 100644 --- a/desmume/src/mc.cpp +++ b/desmume/src/mc.cpp @@ -376,7 +376,7 @@ void BackupDevice::reset_command() com = 0; } -u8 BackupDevice::data_command(u8 val) +u8 BackupDevice::data_command(u8 val, int cpu) { if(com == BM_CMD_READLOW || com == BM_CMD_WRITELOW) { @@ -440,6 +440,10 @@ u8 BackupDevice::data_command(u8 val) switch(val) { case 0: break; //?? + + case 8: + val = 0xAA; + break; case BM_CMD_WRITEDISABLE: write_enable = FALSE; @@ -479,7 +483,7 @@ u8 BackupDevice::data_command(u8 val) break; default: - printf("COMMAND: Unhandled Backup Memory command: %02X\n", val); + printf("COMMAND%c: Unhandled Backup Memory command: %02X FROM %08X\n",(cpu==ARMCPU_ARM9)?'9':'7',val, NDS_ARM9.instruct_adr); break; } } @@ -493,9 +497,9 @@ void BackupDevice::ensure(u32 addr) if(size