From 931d45d0268aef42e97f7caf156d741b4ccf68c1 Mon Sep 17 00:00:00 2001 From: nitsuja Date: Wed, 7 Oct 2009 07:19:46 +0000 Subject: [PATCH] added DTCM and ITCM to ram search --- desmume/src/windows/ram_search.cpp | 58 +++++++++++++++++++++-------- desmume/src/windows/ram_search.h | 4 +- desmume/src/windows/ramwatch.cpp | 2 +- desmume/src/windows/ramwatch.h | 2 +- desmume/src/windows/resources.rc | Bin 445796 -> 445796 bytes 5 files changed, 47 insertions(+), 19 deletions(-) diff --git a/desmume/src/windows/ram_search.cpp b/desmume/src/windows/ram_search.cpp index 5ad75a8af..d622e4712 100644 --- a/desmume/src/windows/ram_search.cpp +++ b/desmume/src/windows/ram_search.cpp @@ -1,5 +1,5 @@ //RamSearch dialog was copied and adapted from GENS11: http://code.google.com/p/gens-rerecording/ -//Authors: Upthorn, Nitsuja, adelikat +//Authors: Nitsuja, Upthorn, adelikat // A few notes about this implementation of a RAM search window: // @@ -61,7 +61,8 @@ struct MemoryRegion unsigned int hardwareAddress; // hardware address of the start of this region unsigned int size; // number of bytes to the end of this region unsigned char* softwareAddress; // pointer to the start of the live emulator source values for this region - BOOL byteSwapped; // true if this is a byte-swapped region of memory + //BOOL byteSwapped; // true if this is a byte-swapped region of memory + BOOL isDtcm; unsigned int virtualIndex; // index into s_prevValues, s_curValues, and s_numChanges, valid after being initialized in ResetMemoryRegions() unsigned int itemIndex; // index into listbox items, valid when s_itemIndicesInvalid is false @@ -77,7 +78,9 @@ static BOOL s_itemIndicesInvalid = true; // if true, the link from listbox items static BOOL s_prevValuesNeedUpdate = true; // if true, the "prev" values should be updated using the "cur" values on the next frame update signaled static unsigned int s_maxItemIndex = 0; // max currently valid item index, the listbox sometimes tries to update things past the end of the list so we need to know this to ignore those attempts -static const MemoryRegion s_prgRegion = { 0x02000000, 0x400000, (unsigned char*)MMU.MAIN_MEM, false}; +static const MemoryRegion s_mainMemRegion = { 0x02000000, 0x400000, (unsigned char*)MMU.MAIN_MEM, false}; +static const MemoryRegion s_dtcmRegion = { 0x027C0000, 0x4000, (unsigned char*)MMU.ARM9_DTCM, true}; +static const MemoryRegion s_itcmRegion = { 0x01000000, 0x8000, (unsigned char*)MMU.ARM9_ITCM, false}; /* static const MemoryRegion s_prgRegion = { 0x020000, SEGACD_RAM_PRG_SIZE, (unsigned char*)Ram_Prg, true}; @@ -112,8 +115,10 @@ void ResetMemoryRegions() // Clear_Sound_Buffer(); s_activeMemoryRegions.clear(); - - s_activeMemoryRegions.push_back(s_prgRegion); + + s_activeMemoryRegions.push_back(s_mainMemRegion); + s_activeMemoryRegions.push_back(s_itcmRegion); + s_activeMemoryRegions.push_back(s_dtcmRegion); /*if(Genesis_Started || _32X_Started || SegaCD_Started) { @@ -135,10 +140,10 @@ void ResetMemoryRegions() { MemoryRegion& region = *iter; region.virtualIndex = nextVirtualIndex; - assert(((intptr_t)region.softwareAddress & 1) == 0 && "somebody need to reimplement ReadValueAtSoftwareAddress()"); + assert(((intptr_t)region.softwareAddress & 1) == 0 && "somebody needs to reimplement ReadValueAtSoftwareAddress()"); nextVirtualIndex = region.virtualIndex + region.size; } -// assert(nextVirtualIndex <= MAX_RAM_SIZE); TODO + assert(nextVirtualIndex <= MAX_RAM_SIZE); } // eliminates a range of hardware addresses from the search results @@ -181,7 +186,7 @@ int DeactivateRegion(MemoryRegion& region, MemoryList::iterator& iter, unsigned { // split region int eraseSize = (hardwareAddress + size) - region.hardwareAddress; - MemoryRegion region2 = {region.hardwareAddress + eraseSize, region.size - eraseSize, region.softwareAddress + eraseSize, region.byteSwapped, region.virtualIndex + eraseSize}; + MemoryRegion region2 = {region.hardwareAddress + eraseSize, region.size - eraseSize, region.softwareAddress + eraseSize, /*region.byteSwapped,*/ region.isDtcm, region.virtualIndex + eraseSize}; region.size = hardwareAddress - region.hardwareAddress; iter = s_activeMemoryRegions.insert(++iter, region2); s_itemIndicesInvalid = TRUE; @@ -298,9 +303,9 @@ void UpdateRegionsT() ++iter; const MemoryRegion* nextRegion = (iter == s_activeMemoryRegions.end()) ? NULL : &*iter; - if(region.byteSwapped) - UpdateRegionT(region, nextRegion); - else + //if(region.byteSwapped) + // UpdateRegionT(region, nextRegion); + //else UpdateRegionT(region, nextRegion); } @@ -359,7 +364,8 @@ void ItemIndexToVirtualRegion(unsigned int itemIndex, MemoryRegion& virtualRegio virtualRegion.hardwareAddress = region.hardwareAddress + bytesWithinRegion; virtualRegion.softwareAddress = region.softwareAddress + bytesWithinRegion; virtualRegion.virtualIndex = region.virtualIndex + bytesWithinRegion; - virtualRegion.byteSwapped = region.byteSwapped; + //virtualRegion.byteSwapped = region.byteSwapped; + virtualRegion.isDtcm = region.isDtcm; virtualRegion.itemIndex = itemIndex; return; } @@ -432,7 +438,10 @@ unsigned int GetHardwareAddressFromItemIndex(unsigned int itemIndex) { MemoryRegion virtualRegion; ItemIndexToVirtualRegion(itemIndex, virtualRegion); - return virtualRegion.hardwareAddress; + unsigned int address = virtualRegion.hardwareAddress; + if(virtualRegion.isDtcm) + address = (address & 0x3FFF) | MMU.DTCMRegion; + return address; } // this one might be unreliable, haven't used it much @@ -442,6 +451,9 @@ unsigned int HardwareAddressToItemIndex(unsigned int hardwareAddress) if(s_itemIndicesInvalid) CalculateItemIndices(sizeof(stepType)); + if((hardwareAddress & ~0x3FFF) == MMU.DTCMRegion) + hardwareAddress = (hardwareAddress & 0x3FFF) | s_dtcmRegion.hardwareAddress; + for(MemoryList::iterator iter = s_activeMemoryRegions.begin(); iter != s_activeMemoryRegions.end(); ++iter) { MemoryRegion& region = *iter; @@ -743,7 +755,7 @@ bool Set_RS_Val() break; case 'a': rs_val = ReadControlInt(IDC_EDIT_COMPAREADDRESS, true, success); - if(!success || rs_val < 0 || rs_val > 0x06040000) + if(!success || rs_val < 0 /*|| rs_val > 0x060400FF*/) return false; break; case 'n': { @@ -1215,8 +1227,13 @@ void Update_RAM_Search() //keeps RAM values up to date in the search and watch w if(RamSearchHWnd) { + static u32 lastDtcmRegion = 0; + bool dtcmChanged = (lastDtcmRegion != MMU.DTCMRegion); + if(dtcmChanged) + lastDtcmRegion = MMU.DTCMRegion; + HWND lv = GetDlgItem(RamSearchHWnd,IDC_RAMLIST); - if(prevValuesNeededUpdate != s_prevValuesNeedUpdate) + if(prevValuesNeededUpdate != s_prevValuesNeedUpdate || dtcmChanged) { // previous values got updated, refresh everything visible ListView_Update(lv, -1); @@ -1438,6 +1455,17 @@ LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPara ListView_SetCallbackMask(GetDlgItem(hDlg,IDC_RAMLIST), LVIS_FOCUSED|LVIS_SELECTED); + // HACK: somehow the listbox disappears the second time the window opens + // unless we do this. obviously some specific part of this is all that matters + // but I haven't felt like tracking it down yet. + { + char typeSize = rs_type_size; + rs_type_size = ((typeSize == 'w') ? 'b' : 'w'); + signal_new_size(); + rs_type_size = typeSize; + signal_new_size(); + } + return true; } break; diff --git a/desmume/src/windows/ram_search.h b/desmume/src/windows/ram_search.h index e349b34dc..2ce4925d1 100644 --- a/desmume/src/windows/ram_search.h +++ b/desmume/src/windows/ram_search.h @@ -1,5 +1,5 @@ //RamSearch dialog was copied and adapted from GENS11: http://code.google.com/p/gens-rerecording/ -//Authors: Upthorn, Nitsuja, adelikat +//Authors: Nitsuja, Upthorn, adelikat #ifndef RAM_SEARCH_H #define RAM_SEARCH_H @@ -25,7 +25,7 @@ //#define MAX_RAM_SIZE (0x112000) //#define MAX_RAM_SIZE (0xD2000) -#define MAX_RAM_SIZE (0x400000) +#define MAX_RAM_SIZE (0x400000 + 0x8000 + 0x4000) extern char rs_type_size; extern int ResultCount; diff --git a/desmume/src/windows/ramwatch.cpp b/desmume/src/windows/ramwatch.cpp index 813d2cbcc..341081f21 100644 --- a/desmume/src/windows/ramwatch.cpp +++ b/desmume/src/windows/ramwatch.cpp @@ -1,5 +1,5 @@ //RamWatch dialog was copied and adapted from GENS11: http://code.google.com/p/gens-rerecording/ -//Authors: Upthorn, Nitsuja, adelikat +//Authors: adelikat, Upthorn, Nitsuja #include "main.h" #include "resource.h" diff --git a/desmume/src/windows/ramwatch.h b/desmume/src/windows/ramwatch.h index 385223b6b..98bda575f 100644 --- a/desmume/src/windows/ramwatch.h +++ b/desmume/src/windows/ramwatch.h @@ -1,5 +1,5 @@ //RamWatch dialog was copied and adapted from GENS11: http://code.google.com/p/gens-rerecording/ -//Authors: Upthorn, Nitsuja, adelikat +//Authors: adelikat, Upthorn, Nitsuja #ifndef RAMWATCH_H #define RAMWATCH_H diff --git a/desmume/src/windows/resources.rc b/desmume/src/windows/resources.rc index 16a1e422dd06b1c92517d1b4d636fa2670f679c6..6453b4877b9c7313eb54825604ba29924b35bdf6 100644 GIT binary patch delta 122 zcmaDdOZv$y>4q(g3)W9wP^B?lK%6ybazi!8WWS$klU@o;PY`2uncR>dHT{?vtJL&> z2h3vA4bC#MZLbq&m1At@+62N(K+L?IYZHq?3W^!i-z{V@1DVi((AW;t2-M8>Y%2ga CuPo;P delta 113 zcmaDdOZv$y>4q(g3)W9BuwgWt9