win32: add tasvideos ramwatch & ramsearch tools.

Note:
- Traditional Cheat Search has been removed from the menu, but its implementation still remains in the source code, to make importing the changes in snes9xgit to snes9x-rr easier.
- It can be compiled in x64 Unicode. At the moment, Unicode version exports wch file in UTF-16 (without BOM). I will probably change the charset to UTF-8 or something 8-bit friendly code for better compatibility.
- LVN_GETDISPINFO handlers of both ramwatch and ramsearch are modified, since it apparently was harmful and caused a crash with Unicode version. Probbably, this change is applicable to all tasvideos emulators.
This commit is contained in:
gocha 2012-07-15 18:41:23 +09:00
parent 7f5878af6a
commit 2e11f01971
9 changed files with 3878 additions and 22 deletions

2118
win32/ram_search.cpp Normal file

File diff suppressed because it is too large Load Diff

120
win32/ram_search.h Normal file
View File

@ -0,0 +1,120 @@
//RamSearch dialog was copied and adapted from GENS11: http://code.google.com/p/gens-rerecording/
//Authors: Upthorn, Nitsuja, adelikat
#ifndef RAM_SEARCH_H
#define RAM_SEARCH_H
extern char rs_type_size;
extern int ResultCount;
typedef unsigned int HWAddressType;
unsigned int sizeConv(unsigned int index,char size, char *prevSize = &rs_type_size, bool usePrev = false);
unsigned int GetRamValue(unsigned int Addr,char Size);
void prune(char Search, char Operater, char Type, int Value, int OperatorParameter);
void CompactAddrs();
void reset_address_info();
void signal_new_frame();
void signal_new_size();
void UpdateRamSearchTitleBar(int percent = 0);
void SetRamSearchUndoType(HWND hDlg, int type);
unsigned int ReadValueAtHardwareAddress(HWAddressType address, unsigned int size);
bool WriteValueAtHardwareAddress(HWAddressType address, unsigned int value, unsigned int size);
bool IsRAMWatchAddressValid(HWAddressType address);
extern int curr_ram_size;
extern bool noMisalign;
extern HWND RamSearchHWnd;
void ResetResults();
void CloseRamWindows(); //Close the Ram Search & Watch windows when rom closes
void ReopenRamWindows(); //Reopen them when a new Rom is loaded
void Update_RAM_Search(); //keeps RAM values up to date in the search and watch windows
#define RW_VIRTUAL_ADDR_SHIFT 24
#define RW_VIRTUAL_ADDR_MASK ((1<<(RW_VIRTUAL_ADDR_SHIFT))-1)
#define RW_VIRTUAL_ADDR_SRAM 1
#define RW_VIRTUAL_ADDR_FILLRAM 2
static inline uint8* RWInternalToSoftwareAddress(HWAddressType address)
{
if(Settings.StopEmulation)
return NULL;
HWAddressType base = address & RW_VIRTUAL_ADDR_MASK;
HWAddressType type = address >> RW_VIRTUAL_ADDR_SHIFT;
switch(type) {
case RW_VIRTUAL_ADDR_SRAM:
if (Memory.SRAM != NULL && base < 0x20000)
return &Memory.SRAM[base];
break;
case RW_VIRTUAL_ADDR_FILLRAM:
if (Memory.FillRAM != NULL && base < 0x8000)
return &Memory.FillRAM[base];
break;
default:
if (Memory.RAM != NULL && address >= 0x7e0000 && address <= 0x7fffff)
return &Memory.RAM[address & 0x1ffff];
}
return NULL;
}
static inline HWAddressType DisplayToRWInternalAddress(const TCHAR* str)
{
HWAddressType base, type = 0;
switch(str[0]) {
case 'S':
case 's':
base = _tcstoul(&str[1], NULL, 16);
type = RW_VIRTUAL_ADDR_SRAM;
break;
case 'I':
case 'i':
base = _tcstoul(&str[1], NULL, 16);
type = RW_VIRTUAL_ADDR_FILLRAM;
break;
default:
base = _tcstoul(str, NULL, 16);
}
return (type << RW_VIRTUAL_ADDR_SHIFT) | (base & RW_VIRTUAL_ADDR_MASK);
}
static inline const TCHAR* RWInternalToDisplayAddress(HWAddressType address)
{
static TCHAR str[11];
HWAddressType base = address & RW_VIRTUAL_ADDR_MASK;
HWAddressType type = address >> RW_VIRTUAL_ADDR_SHIFT;
// must return 6 characters
switch(type) {
case RW_VIRTUAL_ADDR_SRAM:
_stprintf(str, TEXT("s%05X"), base);
break;
case RW_VIRTUAL_ADDR_FILLRAM:
_stprintf(str, TEXT("i%05X"), base);
break;
default:
_stprintf(str, TEXT("%06X"), base);
}
return str;
}
static inline HWAddressType RWInternalToHardwareAddress(HWAddressType address)
{
HWAddressType base = address & RW_VIRTUAL_ADDR_MASK;
HWAddressType type = address >> RW_VIRTUAL_ADDR_SHIFT;
switch(type) {
case RW_VIRTUAL_ADDR_SRAM:
return 0x700000 | (base & 0x1ffff); // FIXME: incorrect, but better than nothing
case RW_VIRTUAL_ADDR_FILLRAM: // FIXME
default:
return base;
}
}
#endif

1282
win32/ramwatch.cpp Normal file

File diff suppressed because it is too large Load Diff

52
win32/ramwatch.h Normal file
View File

@ -0,0 +1,52 @@
//RamWatch dialog was copied and adapted from GENS11: http://code.google.com/p/gens-rerecording/
//Authors: Upthorn, Nitsuja, adelikat
#ifndef RAMWATCH_H
#define RAMWATCH_H
#include <windows.h>
bool ResetWatches();
void OpenRWRecentFile(int memwRFileNumber);
extern bool AutoRWLoad;
extern bool RWSaveWindowPos;
#define MAX_RECENT_WATCHES 5
extern TCHAR rw_recent_files[MAX_RECENT_WATCHES][1024];
extern bool AskSave();
extern int ramw_x;
extern int ramw_y;
extern bool RWfileChanged;
//Constants
//#define AUTORWLOAD "RamWatchAutoLoad"
//#define RWSAVEPOS "RamWatchSaveWindowPos"
//#define RAMWX "RamwX"
//#define RAMWY "RamwY"
// AddressWatcher is self-contained now
struct AddressWatcher
{
unsigned int Address; // hardware address
TCHAR Size;
TCHAR Type;
TCHAR* comment; // NULL means no comment, non-NULL means allocated comment
bool WrongEndian;
unsigned int CurValue;
};
#define MAX_WATCH_COUNT 256
extern AddressWatcher rswatches[MAX_WATCH_COUNT];
extern int WatchCount; // number of valid items in rswatches
extern TCHAR Watch_Dir[1024];
extern HWND RamWatchHWnd;
extern HACCEL RamWatchAccels;
bool InsertWatch(const AddressWatcher& Watch, TCHAR *Comment);
bool InsertWatch(const AddressWatcher& Watch, HWND parent=NULL); // asks user for comment
void Update_RAM_Watch();
bool Load_Watches(bool clear, const TCHAR* filename);
void RWAddRecentFile(const TCHAR *filename);
LRESULT CALLBACK RamWatchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
extern HWND RamWatchHWnd;
#endif

View File

@ -37,6 +37,11 @@
#define IDB_LOCKEDFOLDER 148
#define IDB_HIDDENFOLDER 149
#define IDD_MULTICART 150
#define IDD_RAMSEARCH 500
#define IDD_RAMWATCH 501
#define IDD_EDITWATCH 502
#define IDD_PROMPT 503
#define IDR_RWACCELERATOR 504
#define IDC_DRIVER 1001
#define IDC_BUFLEN 1002
#define IDC_RATE 1003
@ -362,6 +367,46 @@
#define IDC_SHADER_HLSL_BROWSE 3016
#define IDC_SHADER_GROUP 3017
#define IDC_SHADER_GLSL_BROWSE 3018
#define IDC_RAMLIST 5000
//#define IDC_C_SEARCH 5001
#define IDC_C_ADDCHEAT 5002
//#define IDC_C_WATCH 5003
//#define IDC_C_RESET 5004
#define IDC_C_ELIMINATE 5005
#define IDC_LESSTHAN 5006
#define IDC_MORETHAN 5007
#define IDC_NOMORETHAN 5008
#define IDC_NOLESSTHAN 5009
#define IDC_EQUALTO 5010
#define IDC_DIFFERENTFROM 5011
#define IDC_DIFFERENTBY 5012
#define IDC_MODULO 5013
#define IDC_EDIT_DIFFBY 5014
#define IDC_EDIT_MODBY 5015
#define IDC_PREVIOUSVALUE 5016
#define IDC_SPECIFICVALUE 5017
#define IDC_SPECIFICADDRESS 5018
#define IDC_NUMBEROFCHANGES 5019
#define IDC_EDIT_COMPAREVALUE 5020
#define IDC_EDIT_COMPAREADDRESS 5021
#define IDC_EDIT_COMPARECHANGES 5022
#define IDC_C_AUTOSEARCH 5023
#define IDC_2_BYTES 5024
#define IDC_4_BYTES 5025
#define IDC_MISALIGN 5026
#define IDC_C_RESET_CHANGES 5027
#define IDC_C_UNDO 5028
#define IDC_WATCHLIST 5029
#define IDC_C_WATCH_EDIT 5030
#define IDC_C_WATCH_REMOVE 5031
#define IDC_C_WATCH_DUPLICATE 5032
#define ID_WATCHES_UPDOWN 5033
#define IDC_C_WATCH_UP 5034
#define IDC_C_WATCH_DOWN 5035
#define IDC_PROMPT_TEXT 5036
#define IDC_PROMPT_TEXT2 5037
#define IDC_PROMPT_EDIT 5038
#define IDC_WATCHES_GROUP 5039
#define ID_FILE_EXIT 40001
#define ID_WINDOW_HIDEMENUBAR 40004
#define ID_FILE_AVI_RECORDING 40005
@ -495,6 +540,18 @@
#define ID_WINDOW_SIZE_4X 40172
#define ID_DEBUG_APU_TRACE 40173
#define ID_EMULATION_BACKGROUNDINPUT 40174
#define RAMMENU_FILE_AUTOLOAD 45000
#define RAMMENU_FILE_SAVEWINDOW 45001
#define RAMMENU_FILE_SAVE 45002
#define RAMMENU_FILE_SAVEAS 45003
#define RAMMENU_FILE_OPEN 45004
#define RAMMENU_FILE_APPEND 45005
#define RAMMENU_FILE_NEW 45006
#define RAMMENU_FILE_RECENT 45007
#define ID_RAM_SEARCH 45008
#define ID_RAM_WATCH 45009
#define RW_MENU_FIRST_RECENT_FILE 45010
#define RW_MENU_LAST_RECENT_FILE 45011
// Next default values for new objects
//

View File

@ -35,7 +35,7 @@ IDC_CURSOR_SCOPE CURSOR "nodrop.cur"
IDR_SNES9X_ACCELERATORS ACCELERATORS
BEGIN
"G", ID_CHEAT_ENTER, VIRTKEY, ALT, NOINVERT
"A", ID_CHEAT_SEARCH, VIRTKEY, ALT, NOINVERT
"A", ID_RAM_SEARCH, VIRTKEY, ALT, NOINVERT
"O", ID_FILE_LOAD_GAME, VIRTKEY, CONTROL, NOINVERT
VK_F5, ID_OPTIONS_DISPLAY, VIRTKEY, ALT, NOINVERT
VK_F7, ID_OPTIONS_JOYPAD, VIRTKEY, ALT, NOINVERT
@ -49,6 +49,20 @@ BEGIN
VK_BACK, ID_WINDOW_STRETCH, VIRTKEY, ALT, NOINVERT
END
IDR_RWACCELERATOR ACCELERATORS
BEGIN
"N", RAMMENU_FILE_NEW, VIRTKEY, CONTROL
"O", RAMMENU_FILE_OPEN, VIRTKEY, CONTROL
"S", RAMMENU_FILE_SAVE, VIRTKEY, CONTROL
"S", RAMMENU_FILE_SAVEAS, VIRTKEY, SHIFT, CONTROL
"A", IDC_C_WATCH_DUPLICATE, VIRTKEY
"E", IDC_C_WATCH_EDIT, VIRTKEY
"D", IDC_C_WATCH_DOWN, VIRTKEY
"U", IDC_C_WATCH_UP, VIRTKEY
"N", IDC_C_WATCH, VIRTKEY
"R", IDC_C_WATCH_REMOVE, VIRTKEY
END
/////////////////////////////////////////////////////////////////////////////
//
@ -551,6 +565,138 @@ BEGIN
COMBOBOX IDC_HOSTNAME,60,5,110,40,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
END
IDD_RAM_SEARCH DIALOGEX 0, 0, 272, 275
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER | WS_VISIBLE | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU
CAPTION "RAM Search"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "&OK",IDOK,161,253,50,14
PUSHBUTTON "&Cancel",IDCANCEL,218,253,50,14
CONTROL "List1",IDC_ADDYS,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP,7,7,201,152,WS_EX_CLIENTEDGE
PUSHBUTTON "&Search",IDC_C_SEARCH,215,7,52,16
PUSHBUTTON "&Add Cheat",IDC_C_ADD,215,29,52,16,WS_DISABLED
PUSHBUTTON "&Reset",IDC_C_RESET,215,51,52,16
CONTROL "1 byte",IDC_1_BYTE,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,212,172,42,11
CONTROL "2 bytes",IDC_2_BYTE,"Button",BS_AUTORADIOBUTTON,212,185,42,11
CONTROL "3 bytes",IDC_3_BYTE,"Button",BS_AUTORADIOBUTTON,212,198,42,11
CONTROL "4 bytes",IDC_4_BYTE,"Button",BS_AUTORADIOBUTTON,212,211,42,11
GROUPBOX "Data Size",IDC_STATIC,205,162,54,66,0,WS_EX_TRANSPARENT
GROUPBOX "Comparison Type",IDC_STATIC,7,162,114,86,0,WS_EX_TRANSPARENT
CONTROL "< (Less Than)",IDC_LESS_THAN,"Button",BS_AUTORADIOBUTTON | WS_GROUP,13,170,90,11
CONTROL "> (Greater Than)",IDC_GREATER_THAN,"Button",BS_AUTORADIOBUTTON,13,182,90,11
CONTROL "<= (Less Than or Equal to)",IDC_LESS_THAN_EQUAL,"Button",BS_AUTORADIOBUTTON,13,194,106,11
CONTROL ">= (Greater than or Equal To)",IDC_GREATER_THAN_EQUAL,
"Button",BS_AUTORADIOBUTTON,13,206,105,11
CONTROL "= (Equal To)",IDC_EQUAL,"Button",BS_AUTORADIOBUTTON,13,218,90,11
CONTROL "!= (Not Equal To)",IDC_NOT_EQUAL,"Button",BS_AUTORADIOBUTTON,13,230,90,11
GROUPBOX "Data Type",IDC_STATIC,125,206,75,43,0,WS_EX_TRANSPARENT
GROUPBOX "Compare To",IDC_STATIC,125,162,75,42,0,WS_EX_TRANSPARENT
CONTROL "Previous Value",IDC_PREV,"Button",BS_AUTORADIOBUTTON | WS_GROUP,129,171,67,10
CONTROL "Entered Value",IDC_ENTERED,"Button",BS_AUTORADIOBUTTON,129,181,67,10
CONTROL "Entered Address",IDC_ENTEREDADDRESS,"Button",BS_AUTORADIOBUTTON,129,192,67,10
CONTROL "Unsigned (>=0)",IDC_UNSIGNED,"Button",BS_AUTORADIOBUTTON | WS_GROUP,129,216,67,10
CONTROL "Signed (+/-)",IDC_SIGNED,"Button",BS_AUTORADIOBUTTON,129,226,67,10
CONTROL "Hexadecimal",IDC_HEX,"Button",BS_AUTORADIOBUTTON,129,236,67,10
EDITTEXT IDC_VALUE_ENTER,72,253,83,12,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED
RTEXT "Enter a Value:",IDC_ENTER_LABEL,7,253,54,12,SS_CENTERIMAGE | WS_DISABLED
PUSHBUTTON "&Watch",IDC_C_WATCH,215,91,52,16
PUSHBUTTON "&Clear Watches",IDC_C_CLEARWATCH,215,108,52,16
PUSHBUTTON "&Load Watches",IDC_C_LOADWATCH,215,125,52,16
PUSHBUTTON "Sa&ve Watches",IDC_C_SAVEWATCH,215,142,52,16
END
IDD_RAMSEARCH DIALOGEX 0, 0, 287, 292
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION " RAM Search"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL "",IDC_RAMLIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP,9,9,214,151,WS_EX_CLIENTEDGE
PUSHBUTTON "&Search",IDC_C_SEARCH,226,9,52,16
PUSHBUTTON "&Add Cheat",IDC_C_ADDCHEAT,226,145,52,16,WS_DISABLED
PUSHBUTTON "&Watch",IDC_C_WATCH,226,127,52,16
PUSHBUTTON "&Reset",IDC_C_RESET,226,27,52,16
PUSHBUTTON "&Eliminate",IDC_C_ELIMINATE,226,109,52,16
GROUPBOX "Comparison Operator",IDC_STATIC,10,166,102,118,0,WS_EX_TRANSPARENT
CONTROL "Less Than",IDC_LESSTHAN,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,14,178,95,11
CONTROL "Greater Than",IDC_MORETHAN,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,14,191,95,11
CONTROL "Less Than or Equal To",IDC_NOMORETHAN,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,14,204,95,11
CONTROL "Greater Than or Equal To",IDC_NOLESSTHAN,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,14,217,95,11
CONTROL "Equal To",IDC_EQUALTO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,14,230,95,11
CONTROL "Not Equal To",IDC_DIFFERENTFROM,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,14,243,95,11
CONTROL "Different By:",IDC_DIFFERENTBY,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,14,256,52,11
CONTROL "Modulo",IDC_MODULO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,14,269,35,11
EDITTEXT IDC_EDIT_DIFFBY,69,255,38,12,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED
EDITTEXT IDC_EDIT_MODBY,51,267,38,12,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED
GROUPBOX "Compare To / By",IDC_STATIC,118,166,153,58,0,WS_EX_TRANSPARENT
CONTROL "Previous Value",IDC_PREVIOUSVALUE,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,121,176,67,10
CONTROL "Specific Value:",IDC_SPECIFICVALUE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,121,187,67,10
CONTROL "Specific Address:",IDC_SPECIFICADDRESS,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,121,198,67,10
CONTROL "Number of Changes:",IDC_NUMBEROFCHANGES,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,121,209,76,10
EDITTEXT IDC_EDIT_COMPAREVALUE,203,183,63,12,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED
EDITTEXT IDC_EDIT_COMPAREADDRESS,203,195,63,12,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED
EDITTEXT IDC_EDIT_COMPARECHANGES,203,207,63,12,ES_UPPERCASE | ES_AUTOHSCROLL | WS_DISABLED
GROUPBOX "Data Type / Display",IDC_STATIC,196,227,75,44,0,WS_EX_TRANSPARENT
CONTROL "Signed",IDC_SIGNED,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,200,237,67,9
CONTROL "Unsigned",IDC_UNSIGNED,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,200,248,67,9
CONTROL "Hexadecimal",IDC_HEX,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,200,259,67,9
CONTROL "Autosearch",IDC_C_AUTOSEARCH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,200,273,52,11
GROUPBOX "Data Size",IDC_STATIC,117,227,73,57,0,WS_EX_TRANSPARENT
CONTROL "1 byte",IDC_1_BYTE,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,121,237,61,11
CONTROL "2 bytes",IDC_2_BYTES,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,121,248,61,11
CONTROL "4 bytes",IDC_4_BYTES,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,121,259,61,11
CONTROL "Check Misaligned",IDC_MISALIGN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,121,272,65,8
PUSHBUTTON "&Clear Change Counts",IDC_C_RESET_CHANGES,226,46,52,20,BS_MULTILINE
PUSHBUTTON "&Undo",IDC_C_UNDO,226,69,52,16,WS_DISABLED
LTEXT "Is",IDC_STATIC,92,270,12,8
END
IDD_RAMWATCH DIALOGEX 0, 0, 269, 274
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION " RAM Watch"
MENU RAMWATCH_MENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL "",IDC_WATCHLIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP,9,9,210,255,WS_EX_CLIENTEDGE
PUSHBUTTON "Edit",IDC_C_WATCH_EDIT,226,66,34,14
PUSHBUTTON "Remove",IDC_C_WATCH_REMOVE,226,83,34,14
PUSHBUTTON "New",IDC_C_WATCH,226,100,34,14
PUSHBUTTON "Duplicate",IDC_C_WATCH_DUPLICATE,226,117,34,14
PUSHBUTTON "Add Cheat",IDC_C_ADDCHEAT,222,140,42,16,WS_DISABLED
GROUPBOX "Watches",IDC_WATCHES_GROUP,222,11,42,125,0,WS_EX_TRANSPARENT
CONTROL "",ID_WATCHES_UPDOWN,"msctls_updown32",WS_TABSTOP,232,23,19,36
END
IDD_EDITWATCH DIALOGEX 0, 0, 181, 95
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION " Edit Watch"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CTEXT "Address:",IDC_SPECIFICADDRESS,18,12,35,10
EDITTEXT IDC_EDIT_COMPAREADDRESS,55,10,65,12,ES_UPPERCASE | ES_AUTOHSCROLL
CTEXT "Notes:",IDC_PROMPT_TEXT,18,24,45,10
EDITTEXT IDC_PROMPT_EDIT,55,22,65,12,ES_AUTOHSCROLL
GROUPBOX "Data Type",IDC_STATIC,14,37,75,42,0,WS_EX_TRANSPARENT
CONTROL "&Signed",IDC_SIGNED,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,18,47,67,9
CONTROL "&Unsigned",IDC_UNSIGNED,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,18,57,67,9
CONTROL "&Hexadecimal",IDC_HEX,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,18,67,67,9
GROUPBOX "Data Size",IDC_STATIC,94,37,73,42,0,WS_EX_TRANSPARENT
CONTROL "&1 byte",IDC_1_BYTE,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,98,47,61,11
CONTROL "&2 bytes",IDC_2_BYTES,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,98,57,61,11
CONTROL "&4 bytes",IDC_4_BYTES,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,98,67,61,11
DEFPUSHBUTTON "&OK",IDOK,66,80,50,14
PUSHBUTTON "&Cancel",IDCANCEL,120,80,50,14
END
IDD_PROMPT DIALOG 0, 0, 186, 68
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Input Prompt"
FONT 8, "Ms Shell Dlg 2"
BEGIN
DEFPUSHBUTTON "OK",IDOK,100,43,50,14
PUSHBUTTON "Cancel",IDCANCEL,37,42,50,14
EDITTEXT IDC_PROMPT_EDIT,10,15,167,14,ES_AUTOHSCROLL
END
/////////////////////////////////////////////////////////////////////////////
//
@ -633,13 +779,6 @@ BEGIN
HORZGUIDE, 122
END
IDD_CHEAT_SEARCH, DIALOG
BEGIN
LEFTMARGIN, 7
TOPMARGIN, 7
BOTTOMMARGIN, 268
END
IDD_CHEAT_FROM_SEARCH, DIALOG
BEGIN
LEFTMARGIN, 7
@ -934,9 +1073,10 @@ BEGIN
POPUP "&Cheat"
BEGIN
MENUITEM "&Game Genie, Pro-Action Replay Codes\tAlt+G", ID_CHEAT_ENTER
MENUITEM "&Search for New Cheats", ID_CHEAT_SEARCH_MODAL
MENUITEM "Search for New Cheats (active)\tAlt+A", 40064
MENUITEM "&Apply Cheats", ID_CHEAT_APPLY, CHECKED
MENUITEM SEPARATOR
MENUITEM "RAM Watch...", ID_RAM_WATCH, GRAYED
MENUITEM "RAM &Search...\tAlt+A", ID_RAM_SEARCH, GRAYED
END
POPUP "&Netplay"
BEGIN
@ -957,6 +1097,34 @@ BEGIN
END
END
RAMWATCH_MENU MENU
BEGIN
POPUP "File"
BEGIN
MENUITEM "&New list\tCtrl N", RAMMENU_FILE_NEW
MENUITEM "&Open...\tCtrl O", RAMMENU_FILE_OPEN
MENUITEM "&Save\tCtrl S", RAMMENU_FILE_SAVE
MENUITEM "Sa&ve As...\tCtrl Shift S", RAMMENU_FILE_SAVEAS
MENUITEM "&Append file...", RAMMENU_FILE_APPEND
MENUITEM "Recent", RAMMENU_FILE_RECENT
MENUITEM SEPARATOR
MENUITEM "Auto-&load", RAMMENU_FILE_AUTOLOAD
MENUITEM "Save Window Position", RAMMENU_FILE_SAVEWINDOW
MENUITEM SEPARATOR
MENUITEM "&Close\tAlt F4", IDCANCEL
END
POPUP "Watches"
BEGIN
MENUITEM "&New Watch\tN", IDC_C_WATCH
MENUITEM "&Edit Watch\tE", IDC_C_WATCH_EDIT
MENUITEM "&Remove Watch\tR", IDC_C_WATCH_REMOVE
MENUITEM "Duplicate Watch\tA", IDC_C_WATCH_DUPLICATE
MENUITEM SEPARATOR
MENUITEM "Move Up\tU", IDC_C_WATCH_UP
MENUITEM "Move Down\tD", IDC_C_WATCH_DOWN
END
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////

View File

@ -3022,6 +3022,22 @@
RelativePath=".\InputCustom.h"
>
</File>
<File
RelativePath=".\ram_search.cpp"
>
</File>
<File
RelativePath=".\ram_search.h"
>
</File>
<File
RelativePath=".\ramwatch.cpp"
>
</File>
<File
RelativePath=".\ramwatch.h"
>
</File>
<File
RelativePath=".\render.cpp"
>

View File

@ -214,6 +214,8 @@
#include "../statemanager.h"
#include "AVIOutput.h"
#include "InputCustom.h"
#include "ram_search.h"
#include "ramwatch.h"
#include <vector>
#if (((defined(_MSC_VER) && _MSC_VER >= 1300)) || defined(__MINGW32__))
@ -281,6 +283,9 @@ HRESULT CALLBACK EnumModesCallback( LPDDSURFACEDESC lpDDSurfaceDesc, LPVOID lpCo
VOID CALLBACK HotkeyTimer( UINT idEvent, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2);
extern HWND RamSearchHWnd;
extern LRESULT CALLBACK RamSearchProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
#define NOTKNOWN "Unknown Company "
#define HEADER_SIZE 512
#define INFO_LEN (0xFF - 0xC0)
@ -2218,6 +2223,23 @@ LRESULT CALLBACK WinProc(
S9xSaveCheatFile (S9xGetFilename (".cht", CHEAT_DIR));
RestoreSNESDisplay ();
break;
case ID_RAM_SEARCH:
if(!RamSearchHWnd)
{
reset_address_info();
RamSearchHWnd = CreateDialog(GUI.hInstance, MAKEINTRESOURCE(IDD_RAMSEARCH), hWnd, (DLGPROC) RamSearchProc);
}
else
SetForegroundWindow(RamSearchHWnd);
break;
case ID_RAM_WATCH:
if(!RamWatchHWnd)
{
RamWatchHWnd = CreateDialog(GUI.hInstance, MAKEINTRESOURCE(IDD_RAMWATCH), hWnd, (DLGPROC) RamWatchProc);
}
else
SetForegroundWindow(RamWatchHWnd);
break;
case ID_CHEAT_APPLY:
Settings.ApplyCheats = !Settings.ApplyCheats;
if (!Settings.ApplyCheats){
@ -3335,6 +3357,16 @@ int WINAPI WinMain(
if (!GetMessage (&msg, NULL, 0, 0))
goto loop_exit; // got WM_QUIT
// do not process non-modal dialog messages
if (RamSearchHWnd && IsDialogMessage(RamSearchHWnd, &msg))
continue;
if (RamWatchHWnd && IsDialogMessage(RamWatchHWnd, &msg)) {
if(msg.message == WM_KEYDOWN) // send keydown messages to the dialog (for accelerators, and also needed for the Alt key to work)
SendMessage(RamWatchHWnd, msg.message, msg.wParam, msg.lParam);
continue;
}
if (!TranslateAccelerator (GUI.hWnd, GUI.Accelerators, &msg))
{
TranslateMessage (&msg);
@ -3456,6 +3488,7 @@ int WINAPI WinMain(
}
S9xMainLoop();
Update_RAM_Search(); // Update_RAM_Watch() is also called.
GUI.FrameCount++;
}
@ -3652,6 +3685,15 @@ static void CheckMenuStates ()
SetMenuItemInfo (GUI.hMenu, ID_CHEAT_SEARCH_MODAL, FALSE, &mii);
SetMenuItemInfo (GUI.hMenu, IDM_ROM_INFO, FALSE, &mii);
mii.fState = RamWatchHWnd ? MFS_CHECKED : MFS_UNCHECKED;
if (Settings.StopEmulation || GUI.FullScreen)
mii.fState |= MFS_DISABLED;
SetMenuItemInfo (GUI.hMenu, ID_RAM_WATCH, FALSE, &mii);
mii.fState = RamSearchHWnd ? MFS_CHECKED : MFS_UNCHECKED;
if (Settings.StopEmulation || GUI.FullScreen)
mii.fState |= MFS_DISABLED;
SetMenuItemInfo (GUI.hMenu, ID_RAM_SEARCH, FALSE, &mii);
if (GUI.FullScreen)
mii.fState |= MFS_DISABLED;
SetMenuItemInfo (GUI.hMenu, ID_CHEAT_SEARCH, FALSE, &mii);
@ -8964,18 +9006,6 @@ static inline int CheatCount(int byteSub)
}
struct ICheat
{
uint32 address;
uint32 new_val;
uint32 saved_val;
int size;
bool8 enabled;
bool8 saved;
char name [22];
int format;
};
bool TestRange(int val_type, S9xCheatDataSize bytes, uint32 value)
{
if(val_type!=2)

View File

@ -205,6 +205,7 @@
#include <dsound.h>
#endif
#include "rsrc/resource.h"
#include "../port.h"
#define COUNT(a) (sizeof (a) / sizeof (a[0]))
#define GUI_VERSION 1008
@ -549,6 +550,18 @@ enum
SNES_MAX_CONTROLLER_OPTIONS
};
struct ICheat
{
uint32 address;
uint32 new_val;
uint32 saved_val;
int size;
bool8 enabled;
bool8 saved;
char name [22];
int format;
};
/*****************************************************************************/
void SetInfoDlgColor(unsigned char r, unsigned char g, unsigned char b);