From 623a09b5a5d30caf339dd6e66c2531db0bb3cd84 Mon Sep 17 00:00:00 2001 From: ayuanx Date: Tue, 5 Jan 2010 18:07:23 +0000 Subject: [PATCH] It looks like MotionPlus and other Extensions are actually sharing the same register storage space. So maybe we should replace "g_RegMotionPlus" with "g_RegExt" instead. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4788 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugin_Wiimote/Src/EmuSubroutines.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp index aa33ee922a..ac1cfc1104 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuSubroutines.cpp @@ -423,21 +423,23 @@ void WmWriteData(u16 _channelID, wm_write_data* wd) return; } + // Remove for example 0xa40000 from the address + address &= 0xFFFF; + // Check if the address is within bounds - if((address & 0xFFFF) + wd->size > blockSize) { + if(address + wd->size > blockSize) { PanicAlert("WmWriteData: address + size out of bounds!"); return; } // Finally write the registers to the right structure - memcpy(block + (address & 0xFFFF), wd->data, wd->size); - + memcpy(block + address, wd->data, wd->size); + // Generate key for the Wiimote Extension - if(((address >> 16) & 0xfe) == 0xa4) + if(blockSize == WIIMOTE_REG_EXT_SIZE) { - /* Run the key generation on all writes in the key area, it doesn't matter - that we send it parts of a key, only the last full key will have an - effect */ + // Run the key generation on all writes in the key area, it doesn't matter + // that we send it parts of a key, only the last full key will have an effect if(address >= 0x40 && address <= 0x4c) wiimote_gen_key(&g_ExtKey[g_ID], &g_RegExt[g_ID][0x40]); }