From e96bb6144b08ae3202f897439cd303fb5232a082 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Oct 2015 17:00:06 -0400 Subject: [PATCH 001/213] Be able to control `WINDOWS_UI` programatically. --- Source/Project64/User Interface.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Project64/User Interface.h b/Source/Project64/User Interface.h index 8b17aa2c1..a227f4cfd 100644 --- a/Source/Project64/User Interface.h +++ b/Source/Project64/User Interface.h @@ -44,8 +44,10 @@ struct WINDOWS_PAINTSTRUCT { class CN64System; +#ifndef BYPASS_WINDOWS_GUI #define WINDOWS_UI // Remove this to test compilation outside of the Windows ATL environment. +#endif #ifdef WINDOWS_UI #include From 6f9c7f59076ff73bf050486fe7a2beacfca14126 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Oct 2015 22:38:30 -0400 Subject: [PATCH 002/213] added Xinput.h to 3rd Party DirectX headers --- Source/3rd Party/directx/include/Xinput.h | 145 ++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 Source/3rd Party/directx/include/Xinput.h diff --git a/Source/3rd Party/directx/include/Xinput.h b/Source/3rd Party/directx/include/Xinput.h new file mode 100644 index 000000000..67ee4b08b --- /dev/null +++ b/Source/3rd Party/directx/include/Xinput.h @@ -0,0 +1,145 @@ +/*************************************************************************** +* * +* XInput.h -- This module defines XBOX controller APIs * +* and constansts for the Windows platform. * +* * +* Copyright (c) Microsoft Corp. All rights reserved. * +* * +***************************************************************************/ +#ifndef _XINPUT_H_ +#define _XINPUT_H_ + +#include + +// Current name of the DLL shipped in the same SDK as this header. +// The name reflects the current version +#define XINPUT_DLL_A "xinput9_1_0.dll" +#define XINPUT_DLL_W L"xinput9_1_0.dll" +#ifdef UNICODE + #define XINPUT_DLL XINPUT_DLL_W +#else + #define XINPUT_DLL XINPUT_DLL_A +#endif + +// +// Device types available in XINPUT_CAPABILITIES +// +#define XINPUT_DEVTYPE_GAMEPAD 0x01 + +// +// Device subtypes available in XINPUT_CAPABILITIES +// +#define XINPUT_DEVSUBTYPE_GAMEPAD 0x01 + +// +// Flags for XINPUT_CAPABILITIES +// +#define XINPUT_CAPS_VOICE_SUPPORTED 0x0004 + +// +// Constants for gamepad buttons +// +#define XINPUT_GAMEPAD_DPAD_UP 0x0001 +#define XINPUT_GAMEPAD_DPAD_DOWN 0x0002 +#define XINPUT_GAMEPAD_DPAD_LEFT 0x0004 +#define XINPUT_GAMEPAD_DPAD_RIGHT 0x0008 +#define XINPUT_GAMEPAD_START 0x0010 +#define XINPUT_GAMEPAD_BACK 0x0020 +#define XINPUT_GAMEPAD_LEFT_THUMB 0x0040 +#define XINPUT_GAMEPAD_RIGHT_THUMB 0x0080 +#define XINPUT_GAMEPAD_LEFT_SHOULDER 0x0100 +#define XINPUT_GAMEPAD_RIGHT_SHOULDER 0x0200 +#define XINPUT_GAMEPAD_A 0x1000 +#define XINPUT_GAMEPAD_B 0x2000 +#define XINPUT_GAMEPAD_X 0x4000 +#define XINPUT_GAMEPAD_Y 0x8000 + +// +// Gamepad thresholds +// +#define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE 7849 +#define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE 8689 +#define XINPUT_GAMEPAD_TRIGGER_THRESHOLD 30 + +// +// Flags to pass to XInputGetCapabilities +// +#define XINPUT_FLAG_GAMEPAD 0x00000001 + + +// +// Structures used by XInput APIs +// +typedef struct _XINPUT_GAMEPAD +{ + WORD wButtons; + BYTE bLeftTrigger; + BYTE bRightTrigger; + SHORT sThumbLX; + SHORT sThumbLY; + SHORT sThumbRX; + SHORT sThumbRY; +} XINPUT_GAMEPAD, *PXINPUT_GAMEPAD; + +typedef struct _XINPUT_STATE +{ + DWORD dwPacketNumber; + XINPUT_GAMEPAD Gamepad; +} XINPUT_STATE, *PXINPUT_STATE; + +typedef struct _XINPUT_VIBRATION +{ + WORD wLeftMotorSpeed; + WORD wRightMotorSpeed; +} XINPUT_VIBRATION, *PXINPUT_VIBRATION; + +typedef struct _XINPUT_CAPABILITIES +{ + BYTE Type; + BYTE SubType; + WORD Flags; + XINPUT_GAMEPAD Gamepad; + XINPUT_VIBRATION Vibration; +} XINPUT_CAPABILITIES, *PXINPUT_CAPABILITIES; + + +// +// XInput APIs +// +#ifdef __cplusplus +extern "C" { +#endif + +DWORD WINAPI XInputGetState +( + DWORD dwUserIndex, // [in] Index of the gamer associated with the device + XINPUT_STATE* pState // [out] Receives the current state +); + +DWORD WINAPI XInputSetState +( + DWORD dwUserIndex, // [in] Index of the gamer associated with the device + XINPUT_VIBRATION* pVibration // [in, out] The vibration information to send to the controller +); + +DWORD WINAPI XInputGetCapabilities +( + DWORD dwUserIndex, // [in] Index of the gamer associated with the device + DWORD dwFlags, // [in] Input flags that identify the device type + XINPUT_CAPABILITIES* pCapabilities // [out] Receives the capabilities +); + +DWORD WINAPI XInputGetDSoundAudioDeviceGuids +( + DWORD dwUserIndex, // [in] Index of the gamer associated with the device + GUID* pDSoundRenderGuid, // [out] DSound device ID for render + GUID* pDSoundCaptureGuid // [out] DSound device ID for capture +); + +#ifdef __cplusplus +} +#endif + +#endif //_XINPUT_H_ + + From 3e9fac74022ae86baf4b82597e2a1d3d8084829d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Oct 2015 23:14:43 -0400 Subject: [PATCH 003/213] Disabled broken pre-processor code. I have no idea what this was for.... --- Source/nragev20/settings.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/nragev20/settings.h b/Source/nragev20/settings.h index cac30afe8..6c0ce3e53 100644 --- a/Source/nragev20/settings.h +++ b/Source/nragev20/settings.h @@ -26,7 +26,7 @@ #define DIRECTINPUT_VERSION 0x0800 - // hacks for GNU C compilers +// hacks for GNU C compilers // No thank you.... #ifdef __GNUC__ #ifndef WINVER @@ -37,10 +37,10 @@ #define _WIN32_IE 0x0300 #endif // #ifndef _WIN32_IE -#ifndef _const unsigned char *_DEFINED -#define _const unsigned char *_DEFINED -typedef const unsigned char *const unsigned char *; -#endif // #ifndef _const unsigned char *_DEFINED +//#ifndef _const unsigned char *_DEFINED +//#define _const unsigned char *_DEFINED +//typedef const unsigned char *const unsigned char *; +//#endif #endif // #ifdef __GNUC__ From ba27fc543cd01ce03543cd17a9a0c6cc59471807 Mon Sep 17 00:00:00 2001 From: MELERIX Date: Tue, 27 Oct 2015 02:07:22 -0300 Subject: [PATCH 004/213] increased the size of some elements of the ui to match with some translations. --- .../Project64/User Interface/UI Resources.rc | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/Source/Project64/User Interface/UI Resources.rc b/Source/Project64/User Interface/UI Resources.rc index 1c5069ef4..3c1555d97 100644 --- a/Source/Project64/User Interface/UI Resources.rc +++ b/Source/Project64/User Interface/UI Resources.rc @@ -152,19 +152,16 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - CONTROL "Pause emulation when window is not active?",IDC_AUTOSLEEP, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,9,198,8 - CONTROL "On loading a ROM go to full screen",IDC_LOAD_FULLSCREEN, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,25,198,8 - CONTROL "Disable Screen Saver when running rom",IDC_SCREEN_SAVER, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,41,198,8 - CONTROL "Hide Advanced Settings",IDC_BASIC_MODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,57,198,8 + CONTROL "Pause emulation when window is not active?",IDC_AUTOSLEEP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,9,206,8 + CONTROL "On loading a ROM go to full screen",IDC_LOAD_FULLSCREEN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,25,206,8 + CONTROL "Disable Screen Saver when running rom",IDC_SCREEN_SAVER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,41,206,8 + CONTROL "Hide Advanced Settings",IDC_BASIC_MODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,57,206,8 LTEXT "Max # of Roms Remembered (Max 10):",IDC_MAXROMS_TXT,6,81,145,8 - EDITTEXT IDC_REMEMBER,154,79,26,12,ES_AUTOHSCROLL | ES_NUMBER - LTEXT "roms",IDC_ROMSEL_TEXT2,184,81,31,8 + EDITTEXT IDC_REMEMBER,148,79,26,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "roms",IDC_ROMSEL_TEXT2,178,82,31,8 LTEXT "Max # of Rom Dirs Remembered (Max 10):",IDC_MAXROMDIR_TXT,6,96,145,8 - EDITTEXT IDC_REMEMBERDIR,154,94,26,12,ES_AUTOHSCROLL | ES_NUMBER - LTEXT "dirs",IDC_ROMSEL_TEXT4,184,99,31,8 + EDITTEXT IDC_REMEMBERDIR,148,94,26,12,ES_AUTOHSCROLL | ES_NUMBER + LTEXT "dirs",IDC_ROMSEL_TEXT4,178,98,34,8 CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,4,73,208,1 END @@ -232,8 +229,8 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - LTEXT "CPU State:",IDC_S_CPU_STATE,8,9,42,11 - COMBOBOX IDC_C_CPU_STATE,58,7,156,66,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "CPU State:",IDC_S_CPU_STATE,8,9,52,11 + COMBOBOX IDC_C_CPU_STATE,68,7,144,66,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Menu Item:",IDC_MENU_ITEM_TEXT,8,23,84,10 CONTROL "Tree1",IDC_MENU_ITEMS,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_NOTOOLTIPS | TVS_TRACKSELECT | WS_BORDER | WS_HSCROLL | WS_TABSTOP,8,33,128,78 LTEXT "Current Keys:",IDC_S_CURRENT_KEYS,142,23,52,10 @@ -241,8 +238,8 @@ BEGIN PUSHBUTTON "Remove",IDC_REMOVE,144,97,68,12 GROUPBOX "Create New Shortcut Key:",IDC_S_SELECT_SHORT,8,115,207,57 COMBOBOX IDC_VIRTUALKEY,8,125,91,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Detect Key",IDC_KEY_PROMPT,103,125,44,12 - PUSHBUTTON "Assign to Menu",IDC_ASSIGN,152,125,62,12 + PUSHBUTTON "Detect Key",IDC_KEY_PROMPT,103,125,62,12 + PUSHBUTTON "Assign to Menu",IDC_ASSIGN,170,125,42,12 CONTROL "&Ctrl",IDC_CTL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,142,23,9 CONTROL "A<",IDC_ALT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,39,142,21,9 CONTROL "&Shift",IDC_SHIFT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,69,142,26,10 @@ -582,10 +579,10 @@ BEGIN PUSHBUTTON "Cancel",IDCANCEL,248,186,50,14 CONTROL "Tree1",IDC_PAGELIST,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS | WS_BORDER | WS_HSCROLL | WS_TABSTOP,8,7,116,169 CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,7,180,343,1 - PUSHBUTTON "Reset Page",IDC_RESET_PAGE,7,186,50,14,WS_DISABLED + PUSHBUTTON "Reset Page",IDC_RESET_PAGE,7,186,58,14,WS_DISABLED CONTROL "",IDC_SETTING_INFO,"Static",SS_ETCHEDFRAME,131,7,219,170 PUSHBUTTON "Apply",IDAPPLY,301,186,50,14,WS_DISABLED - PUSHBUTTON "Reset All",IDC_RESET_ALL,63,186,50,14,WS_DISABLED + PUSHBUTTON "Reset All",IDC_RESET_ALL,68,186,52,14,WS_DISABLED END IDD_Settings_GameRecompiler DIALOGEX 0, 0, 230, 156 From 74355d34d8bddc4f93a94bce32bb44482ab0114f Mon Sep 17 00:00:00 2001 From: "Julio C. Rocha" Date: Tue, 27 Oct 2015 00:55:06 -0700 Subject: [PATCH 005/213] Fix string castint making settings menu break --- Source/Project64/Plugins/Plugin List.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Project64/Plugins/Plugin List.cpp b/Source/Project64/Plugins/Plugin List.cpp index 36bfe52e3..1ebd59077 100644 --- a/Source/Project64/Plugins/Plugin List.cpp +++ b/Source/Project64/Plugins/Plugin List.cpp @@ -98,7 +98,7 @@ void CPluginList::AddPluginFromDir ( CPath Dir) } Plugin.FullPath = Dir; - Plugin.FileName = ((stdstr &)Dir).substr(((stdstr &)m_PluginDir).length()); + Plugin.FileName = Dir.GetDirectory().substr(m_PluginDir.GetDirectory().length()); if (GetProcAddress(hLib,"DllAbout") != NULL) { From ab92640cf829cbbc1af4aecebdd596c1cffc04a6 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Oct 2015 13:09:02 -0400 Subject: [PATCH 006/213] [N-Rage] Fix signed overflow warnings in C++ standard. --- Source/nragev20/FileAccess.h | 102 +++++++++++++++++------------------ 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/Source/nragev20/FileAccess.h b/Source/nragev20/FileAccess.h index fbd3e8217..10687ec7f 100644 --- a/Source/nragev20/FileAccess.h +++ b/Source/nragev20/FileAccess.h @@ -126,68 +126,68 @@ unsigned long djbHash(const char *str); // the following are hashes for the string values above // version strings, including the @ in front -#define CHK_PROFILEVERSION20 2278962538 -#define CHK_PROFILEVERSION21 2278962539 -#define CHK_PROFILEVERSION22 2278962540 +#define CHK_PROFILEVERSION20 2278962538UL +#define CHK_PROFILEVERSION21 2278962539UL +#define CHK_PROFILEVERSION22 2278962540UL // categories -#define CHK_GENERAL 63249731 -#define CHK_FOLDERS 3455681620 -#define CHK_LASTBROWSERDIR 2659654652 -#define CHK_CONTROLLER_1 3910856026 -#define CHK_CONTROLLER_2 3910856027 -#define CHK_CONTROLLER_3 3910856028 -#define CHK_CONTROLLER_4 3910856029 -#define CHK_CONTROLS 3459743001 -#define CHK_SHORTCUTS 2945387732 -#define CHK_MODIFIERS 95935975 +#define CHK_GENERAL 63249731UL +#define CHK_FOLDERS 3455681620UL +#define CHK_LASTBROWSERDIR 2659654652UL +#define CHK_CONTROLLER_1 3910856026UL +#define CHK_CONTROLLER_2 3910856027UL +#define CHK_CONTROLLER_3 3910856028UL +#define CHK_CONTROLLER_4 3910856029UL +#define CHK_CONTROLS 3459743001UL +#define CHK_SHORTCUTS 2945387732UL +#define CHK_MODIFIERS 95935975UL // assignments (to the left of the '=' sign) -#define CHK_LANGUAGE 3857633481 -#define CHK_SHOWMESSAGES 638097246 +#define CHK_LANGUAGE 3857633481UL +#define CHK_SHOWMESSAGES 638097246UL -#define CHK_MEMPAK 3230166560 -#define CHK_GBXROM 2992194388 -#define CHK_GBXSAVE 4253155349 +#define CHK_MEMPAK 3230166560UL +#define CHK_GBXROM 2992194388UL +#define CHK_GBXSAVE 4253155349UL -#define CHK_PROFILE 3606499382 -#define CHK_NOTE 2089365563 +#define CHK_PROFILE 3606499382UL +#define CHK_NOTE 2089365563UL -#define CHK_PLUGGED 3378836077 -#define CHK_XINPUT 3665436173 -#define CHK_N64MOUSE 863329606 -#define CHK_RAWDATA 1238573385 -#define CHK_PAKTYPE 2936974691 -#define CHK_REALN64RANGE 1279831790 -#define CHK_RAPIDFIREENABLED 1491009894 -#define CHK_RAPIDFIRERATE 1576165031 -#define CHK_STICKRANGE 4145501776 -#define CHK_MOUSEMOVEX 1825694205 -#define CHK_MOUSEMOVEY 1825694206 -#define CHK_AXISSET 1642523718 -#define CHK_KEYABSOLUTEX 958566277 -#define CHK_KEYABSOLUTEY 958566278 -#define CHK_PADDEADZONE 2913910084 -#define CHK_MOUSESENSITIVITYX 1513071697 -#define CHK_MOUSESENSITIVITYY 1513071698 -#define CHK_RUMBLETYPE 3440038446 -#define CHK_RUMBLESTRENGTH 3038086267 -#define CHK_VISUALRUMBLE 1795686016 -#define CHK_FFDEVICEGUID 2645316746 -#define CHK_MEMPAKFILE 2373591360 -#define CHK_GBROMFILE 2409678172 -#define CHK_GBROMSAVE 2410136971 +#define CHK_PLUGGED 3378836077UL +#define CHK_XINPUT 3665436173UL +#define CHK_N64MOUSE 863329606UL +#define CHK_RAWDATA 1238573385UL +#define CHK_PAKTYPE 2936974691UL +#define CHK_REALN64RANGE 1279831790UL +#define CHK_RAPIDFIREENABLED 1491009894UL +#define CHK_RAPIDFIRERATE 1576165031UL +#define CHK_STICKRANGE 4145501776UL +#define CHK_MOUSEMOVEX 1825694205UL +#define CHK_MOUSEMOVEY 1825694206UL +#define CHK_AXISSET 1642523718UL +#define CHK_KEYABSOLUTEX 958566277UL +#define CHK_KEYABSOLUTEY 958566278UL +#define CHK_PADDEADZONE 2913910084UL +#define CHK_MOUSESENSITIVITYX 1513071697UL +#define CHK_MOUSESENSITIVITYY 1513071698UL +#define CHK_RUMBLETYPE 3440038446UL +#define CHK_RUMBLESTRENGTH 3038086267UL +#define CHK_VISUALRUMBLE 1795686016UL +#define CHK_FFDEVICEGUID 2645316746UL +#define CHK_MEMPAKFILE 2373591360UL +#define CHK_GBROMFILE 2409678172UL +#define CHK_GBROMSAVE 2410136971UL -#define CHK_DINPUTGUID 1452894242 -#define CHK_BUTTON 2818908353 -#define CHK_MODIFIER 4037573396 +#define CHK_DINPUTGUID 1452894242UL +#define CHK_BUTTON 2818908353UL +#define CHK_MODIFIER 4037573396UL // The following are not found in INI files; only profile and shortcuts files -#define CHK_FFDEVICENAME 2645546658 -#define CHK_FFDEVICENR 2037510273 -#define CHK_DINPUTNAME 1453124154 -#define CHK_DINPUTNR 3965009433 +#define CHK_FFDEVICENAME 2645546658UL +#define CHK_FFDEVICENR 2037510273UL +#define CHK_DINPUTNAME 1453124154UL +#define CHK_DINPUTNR 3965009433UL // If any of the following values conflict with djbHash return values (such as a blank string), there will be problems! From d3edbf65fc75c2afef17fb0a82543d0b59f80dc4 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Oct 2015 14:01:09 -0400 Subject: [PATCH 007/213] [N-Rage] undeclared functions min() and max() --- Source/nragev20/PakIO.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Source/nragev20/PakIO.h b/Source/nragev20/PakIO.h index d8bd176dd..720654d24 100644 --- a/Source/nragev20/PakIO.h +++ b/Source/nragev20/PakIO.h @@ -170,4 +170,16 @@ typedef struct _ADAPTOIDPAK bool fRumblePak; } ADAPTOIDPAK, *LPADAPTOIDPAK; +/* + * from under with MSVC defines these macros. + * For some reason, they are unavailable with MinGW's copy of . + */ +#ifndef max +#define max(a, b) (((a) > (b)) ? (a) : (b)) +#endif + +#ifndef min +#define min(a, b) (((a) < (b)) ? (a) : (b)) +#endif + #endif // #ifndef _PAKIO_H_ From eb388b90f7cc450cbc4a330edd2d99d822142b54 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Oct 2015 15:18:58 -0400 Subject: [PATCH 008/213] [N-Rage] fixed broken FormatMemPak in 64-bit --- Source/nragev20/PakIO.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/nragev20/PakIO.cpp b/Source/nragev20/PakIO.cpp index efc621e81..23d15aa40 100644 --- a/Source/nragev20/PakIO.cpp +++ b/Source/nragev20/PakIO.cpp @@ -800,17 +800,19 @@ inline WORD CountBlocks( const unsigned char * bMemPakBinary, LPBYTE aNoteSizes void FormatMemPak( LPBYTE aMemPak ) { - FillMemory( aMemPak, 0x100, 0xFF ); + size_t iRand, n; + FillMemory(aMemPak, 0x100, 0xFF); aMemPak[0] = 0x81; // generate a valid code( i hope i can calculate it one day) BYTE aValidCodes[] = { 0x12, 0xC5, 0x8F, 0x6F, 0xA4, 0x28, 0x5B, 0xCA }; BYTE aCode[8]; - int iRand = (( (ULONG)aMemPak / 4 + (ULONG)g_strEmuInfo.hMainWindow / 4 ) % (sizeof(aValidCodes)/8) ); - for( int n = 0; n <8; n++ ) - aCode[n] = aValidCodes[n+iRand]; + iRand = ((size_t)aMemPak / 4) + ((size_t)g_strEmuInfo.hMainWindow / 4); + iRand %= sizeof(aValidCodes) / 8; + for (n = 0; n < 8; n++) + aCode[n] = aValidCodes[n + iRand]; //---------- From 7f5f64e00f27cb4623ca75c98ab072731bc2ef4c Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Oct 2015 16:51:50 -0400 Subject: [PATCH 009/213] Use the standard library method wscanf(), not wscanf_s(). --- Source/nragev20/XInputController.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/nragev20/XInputController.cpp b/Source/nragev20/XInputController.cpp index 1e2c9daa2..d696e303a 100644 --- a/Source/nragev20/XInputController.cpp +++ b/Source/nragev20/XInputController.cpp @@ -100,10 +100,10 @@ BOOL IsXInputDevice( const GUID* pGuidProductFromDirectInput ) // If it does, then get the VID/PID from var.bstrVal DWORD dwPid = 0, dwVid = 0; WCHAR* strVid = wcsstr( var.bstrVal, L"VID_" ); - if( strVid && wscanf_s( strVid, L"VID_%4X", &dwVid ) != 1 ) + if (strVid && wscanf(strVid, L"VID_%4X", &dwVid) != 1) dwVid = 0; WCHAR* strPid = wcsstr( var.bstrVal, L"PID_" ); - if( strPid && wscanf_s( strPid, L"PID_%4X", &dwPid ) != 1 ) + if (strPid && wscanf(strPid, L"PID_%4X", &dwPid) != 1) dwPid = 0; // Compare the VID/PID to the DInput device From fa8f78028c537e07ffa3a457ca5039280f75c1d3 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Oct 2015 17:03:19 -0400 Subject: [PATCH 010/213] Use the standard library method sscanf(), not sscanf_s(). --- Source/nragev20/XInputController.cpp | 44 ++++++++++++++-------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Source/nragev20/XInputController.cpp b/Source/nragev20/XInputController.cpp index d696e303a..82f2a4bef 100644 --- a/Source/nragev20/XInputController.cpp +++ b/Source/nragev20/XInputController.cpp @@ -738,49 +738,49 @@ void LoadXInputConfigFromFile( FILE *file, LPXCONTROLLER gController ) switch( buffer[0] ) { case 'A': - sscanf_s( buffer, "A=%lu", &gController->stButtons.iA ); break; + sscanf(buffer, "A=%lu", &gController->stButtons.iA); break; case 'B': - sscanf_s( buffer, "B=%lu", &gController->stButtons.iB ); break; + sscanf(buffer, "B=%lu", &gController->stButtons.iB); break; case 'C': switch( buffer[1] ) { case 'U': - sscanf_s( buffer, "CUp=%lu", &gController->stButtons.iCUp ); break; + sscanf(buffer, "CUp=%lu", &gController->stButtons.iCUp); break; case 'D': - sscanf_s( buffer, "CDown=%lu", &gController->stButtons.iCDown ); break; + sscanf(buffer, "CDown=%lu", &gController->stButtons.iCDown); break; case 'L': - sscanf_s( buffer, "CLeft=%lu", &gController->stButtons.iCLeft ); break; + sscanf(buffer, "CLeft=%lu", &gController->stButtons.iCLeft); break; case 'R': - sscanf_s( buffer, "CRight=%lu", &gController->stButtons.iCRight ); break; + sscanf(buffer, "CRight=%lu", &gController->stButtons.iCRight); break; } break; case 'D': switch( buffer[1] ) { case 'U': - sscanf_s( buffer, "DUp=%lu", &gController->stButtons.iDUp ); break; + sscanf(buffer, "DUp=%lu", &gController->stButtons.iDUp); break; case 'D': - sscanf_s( buffer, "DDown=%lu", &gController->stButtons.iDDown ); break; + sscanf(buffer, "DDown=%lu", &gController->stButtons.iDDown); break; case 'L': - sscanf_s( buffer, "DLeft=%lu", &gController->stButtons.iDLeft ); break; + sscanf(buffer, "DLeft=%lu", &gController->stButtons.iDLeft); break; case 'R': - sscanf_s( buffer, "DRight=%lu", &gController->stButtons.iDRight ); break; + sscanf(buffer, "DRight=%lu", &gController->stButtons.iDRight); break; } break; case 'L': switch( buffer[1] ) { case '=': - sscanf_s( buffer, "L=%lu", &gController->stButtons.iL ); break; + sscanf(buffer, "L=%lu", &gController->stButtons.iL); break; case 'e': switch( buffer[4] ) { case 'T': - sscanf_s( buffer, "LeftTrigger=%lu", &gController->stAnalogs.iLeftTrigger ); break; + sscanf(buffer, "LeftTrigger=%lu", &gController->stAnalogs.iLeftTrigger); break; case 'X': - sscanf_s( buffer, "LeftXAxis=%lu", &gController->stAnalogs.iLXAxis ); break; + sscanf(buffer, "LeftXAxis=%lu", &gController->stAnalogs.iLXAxis); break; case 'Y': - sscanf_s( buffer, "LeftYAxis=%lu", &gController->stAnalogs.iLYAxis ); break; + sscanf(buffer, "LeftYAxis=%lu", &gController->stAnalogs.iLYAxis); break; } break; } @@ -789,28 +789,28 @@ void LoadXInputConfigFromFile( FILE *file, LPXCONTROLLER gController ) switch( buffer[1] ) { case '=': - sscanf_s( buffer, "R=%lu", &gController->stButtons.iR ); break; + sscanf(buffer, "R=%lu", &gController->stButtons.iR); break; case 'i': switch( buffer[5] ) { case 'T': - sscanf_s( buffer, "RightTrigger=%lu", &gController->stAnalogs.iRightTrigger ); break; + sscanf(buffer, "RightTrigger=%lu", &gController->stAnalogs.iRightTrigger); break; case 'X': - sscanf_s( buffer, "RightXAxis=%lu", &gController->stAnalogs.iRXAxis ); break; + sscanf(buffer, "RightXAxis=%lu", &gController->stAnalogs.iRXAxis); break; case 'Y': - sscanf_s( buffer, "RightYAxis=%lu", &gController->stAnalogs.iRYAxis ); break; + sscanf(buffer, "RightYAxis=%lu", &gController->stAnalogs.iRYAxis); break; } break; } break; case 'Z': - sscanf_s( buffer, "Z=%lu", &gController->stButtons.iZ ); break; + sscanf(buffer, "Z=%lu", &gController->stButtons.iZ); break; case 'S': - sscanf_s( buffer, "Start=%lu", &gController->stButtons.iStart ); break; + sscanf(buffer, "Start=%lu", &gController->stButtons.iStart); break; case 'X': - sscanf_s( buffer, "XAxis=%lu", &gController->stButtons.iXAxis ); break; + sscanf(buffer, "XAxis=%lu", &gController->stButtons.iXAxis); break; case 'Y': - sscanf_s( buffer, "YAxis=%lu", &gController->stButtons.iYAxis ); break; + sscanf(buffer, "YAxis=%lu", &gController->stButtons.iYAxis); break; } } From 8f2fd3043d9ec016734cffcfd62f5de9e264c776 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Oct 2015 19:09:49 -0400 Subject: [PATCH 011/213] [Glide64] Add missing dependency for GCC. --- Source/3rd Party/wx/include/wx/msw/gccpriv.h | 127 +++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 Source/3rd Party/wx/include/wx/msw/gccpriv.h diff --git a/Source/3rd Party/wx/include/wx/msw/gccpriv.h b/Source/3rd Party/wx/include/wx/msw/gccpriv.h new file mode 100644 index 000000000..db4c72a84 --- /dev/null +++ b/Source/3rd Party/wx/include/wx/msw/gccpriv.h @@ -0,0 +1,127 @@ +/* + Name: wx/msw/gccpriv.h + Purpose: MinGW/Cygwin definitions + Author: Vadim Zeitlin + Modified by: + Created: + RCS-ID: $Id: gccpriv.h 36155 2005-11-10 16:16:05Z ABX $ + Copyright: (c) Vadim Zeitlin + Licence: wxWindows Licence +*/ + +/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */ + +#ifndef _WX_MSW_GCCPRIV_H_ +#define _WX_MSW_GCCPRIV_H_ + +#if defined(__MINGW32__) && !defined(__GNUWIN32__) + #define __GNUWIN32__ +#endif + +#if defined(__MINGW32__) && ( ( __GNUC__ > 2 ) || ( ( __GNUC__ == 2 ) && ( __GNUC_MINOR__ >= 95 ) ) ) + #include <_mingw.h> +#endif + +#if defined( __MINGW32__ ) && !defined(__WINE__) && !defined( HAVE_W32API_H ) + #if __MINGW32_MAJOR_VERSION >= 1 + #define HAVE_W32API_H + #endif +#elif defined( __CYGWIN__ ) && !defined( HAVE_W32API_H ) + #if ( __GNUC__ > 2 ) + #define HAVE_W32API_H + #endif +#endif + +#if wxCHECK_WATCOM_VERSION(1,0) + #define HAVE_W32API_H +#endif + +/* check for MinGW/Cygwin w32api version ( releases >= 0.5, only ) */ +#if defined( HAVE_W32API_H ) +#include +#endif + +/* Watcom can't handle defined(xxx) here: */ +#if defined(__W32API_MAJOR_VERSION) && defined(__W32API_MINOR_VERSION) + #define wxCHECK_W32API_VERSION( major, minor ) \ + ( ( ( __W32API_MAJOR_VERSION > (major) ) \ + || ( __W32API_MAJOR_VERSION == (major) && __W32API_MINOR_VERSION >= (minor) ) ) ) +#else + #define wxCHECK_W32API_VERSION( major, minor ) (0) +#endif + +/* Cygwin / Mingw32 with gcc >= 2.95 use new windows headers which + are more ms-like (header author is Anders Norlander, hence the name) */ +#if (defined(__MINGW32__) || defined(__CYGWIN__) || defined(__WINE__)) && ((__GNUC__>2) || ((__GNUC__==2) && (__GNUC_MINOR__>=95))) + #ifndef wxUSE_NORLANDER_HEADERS + #define wxUSE_NORLANDER_HEADERS 1 + #endif +#else + #ifndef wxUSE_NORLANDER_HEADERS + #define wxUSE_NORLANDER_HEADERS 0 + #endif +#endif + +/* "old" GNUWIN32 is the one without Norlander's headers: it lacks the + standard Win32 headers and we define the used stuff ourselves for it + in wx/msw/gnuwin32/extra.h */ +#if defined(__GNUC__) && !wxUSE_NORLANDER_HEADERS + #define __GNUWIN32_OLD__ +#endif + +/* Cygwin 1.0 */ +#if defined(__CYGWIN__) && ((__GNUC__==2) && (__GNUC_MINOR__==9)) + #define __CYGWIN10__ +#endif + +/* Check for Mingw runtime version: */ +#if defined(__MINGW32_MAJOR_VERSION) && defined(__MINGW32_MINOR_VERSION) + #define wxCHECK_MINGW32_VERSION( major, minor ) \ + ( ( ( __MINGW32_MAJOR_VERSION > (major) ) \ + || ( __MINGW32_MAJOR_VERSION == (major) && __MINGW32_MINOR_VERSION >= (minor) ) ) ) +#else + #define wxCHECK_MINGW32_VERSION( major, minor ) (0) +#endif + +/* Mingw runtime 1.0-20010604 has some missing _tXXXX functions, + so let's define them ourselves: */ +#if defined(__GNUWIN32__) && wxCHECK_W32API_VERSION( 1, 0 ) \ + && !wxCHECK_W32API_VERSION( 1, 1 ) + #ifndef _tsetlocale + #if wxUSE_UNICODE + #define _tsetlocale _wsetlocale + #else + #define _tsetlocale setlocale + #endif + #endif + #ifndef _tgetenv + #if wxUSE_UNICODE + #define _tgetenv _wgetenv + #else + #define _tgetenv getenv + #endif + #endif + #ifndef _tfopen + #if wxUSE_UNICODE + #define _tfopen _wfopen + #else + #define _tfopen fopen + #endif + #endif +#endif + +/* current (= before mingw-runtime 3.3) mingw32 headers forget to + define _puttchar, this will probably be fixed in the next versions but + for now do it ourselves + */ +#if defined( __MINGW32__ ) && \ + !wxCHECK_MINGW32_VERSION(3,3) && !defined( _puttchar ) + #ifdef wxUSE_UNICODE + #define _puttchar putwchar + #else + #define _puttchar puttchar + #endif +#endif + +#endif + /* _WX_MSW_GCCPRIV_H_ */ From f0fcd058da4dcc58ad938dd00e708c72798b2ff7 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Oct 2015 19:28:55 -0400 Subject: [PATCH 012/213] Get rid of in-line assembly in idiv16(). This cannot work with MinGW -masm=intel, only -masm=att. --- Source/Glide64/DepthBufferRender.cpp | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/Source/Glide64/DepthBufferRender.cpp b/Source/Glide64/DepthBufferRender.cpp index ae4f367aa..29b7ee474 100644 --- a/Source/Glide64/DepthBufferRender.cpp +++ b/Source/Glide64/DepthBufferRender.cpp @@ -97,31 +97,7 @@ __inline int imul14(int x, int y) // (x * y) >> 14 __inline int idiv16(int x, int y) // (x << 16) / y { - //x = (((long long)x) << 16) / ((long long)y); - /* - eax = x; - ebx = y; - edx = x; - (x << 16) | () - */ -#if !defined(__GNUC__) && !defined(NO_ASM) - __asm { - mov eax, x - mov ebx, y - mov edx,eax - sar edx,16 - shl eax,16 - idiv ebx - mov x, eax - } -#elif !defined(NO_ASM) - int reminder; - asm ("idivl %[divisor]" - : "=a" (x), "=d" (reminder) - : [divisor] "g" (y), "d" (x >> 16), "a" (x << 16)); -#else - x = (((long long)x) << 16) / ((long long)y); -#endif + x = ((int64_t)x << 16) / (int64_t)y; return x; } From 102a8f650b39b67372d954c8bfa539d8a6badbb3 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Oct 2015 19:30:33 -0400 Subject: [PATCH 013/213] Do not rely on dynamic-width `long long` type; use int64_t. --- Source/Glide64/DepthBufferRender.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Glide64/DepthBufferRender.cpp b/Source/Glide64/DepthBufferRender.cpp index 29b7ee474..2ed36e116 100644 --- a/Source/Glide64/DepthBufferRender.cpp +++ b/Source/Glide64/DepthBufferRender.cpp @@ -87,12 +87,12 @@ static int left_z, left_dzdy; __inline int imul16(int x, int y) // (x * y) >> 16 { - return (((long long)x) * ((long long)y)) >> 16; + return ((int64_t)x * (int64_t)y) >> 16; } __inline int imul14(int x, int y) // (x * y) >> 14 { - return (((long long)x) * ((long long)y)) >> 14; + return ((int64_t)x * (int64_t)y) >> 14; } __inline int idiv16(int x, int y) // (x << 16) / y From 3f15e07562084594597d1fc81005ad55aea33b70 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Oct 2015 22:26:28 -0400 Subject: [PATCH 014/213] [Glide64] fixed a pre-processor macro language collision --- Source/Glide64/Main.cpp | 2 +- Source/Glide64/rdp.h | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Source/Glide64/Main.cpp b/Source/Glide64/Main.cpp index 07a8ecd04..36eef0d3e 100644 --- a/Source/Glide64/Main.cpp +++ b/Source/Glide64/Main.cpp @@ -37,9 +37,9 @@ // //**************************************************************** +#include #include "Gfx_1.3.h" #include "Version.h" -#include #include #include diff --git a/Source/Glide64/rdp.h b/Source/Glide64/rdp.h index 9dfa8d7b0..64d6e7804 100644 --- a/Source/Glide64/rdp.h +++ b/Source/Glide64/rdp.h @@ -830,12 +830,20 @@ extern const char *CIStatus[]; #define FBL_D_1 2 #define FBL_D_0 3 +/* + * taken straight from MSVC in case of other compilers + * + * Careful! These macros can sabotage std::max and std::min from . + * The only solution is to include first, before or + * before defining the below macros (or just don't use ). + */ #ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) +#define max(a, b) (((a) > (b)) ? (a) : (b)) #endif #ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) +#define min(a, b) (((a) < (b)) ? (a) : (b)) #endif + #ifndef TRUE #define TRUE 1 #endif From 8354249a4b292f9e69f9e8f4d1b2404dda3fd542 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Oct 2015 23:11:31 -0400 Subject: [PATCH 015/213] [Glide64] fixed DllMain conflict against prototype --- Source/Glide64/Main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Glide64/Main.cpp b/Source/Glide64/Main.cpp index 36eef0d3e..ab9c4802b 100644 --- a/Source/Glide64/Main.cpp +++ b/Source/Glide64/Main.cpp @@ -1197,7 +1197,7 @@ int DllUnload(void) void wxSetInstance(HINSTANCE hInstance); extern "C" int WINAPI DllMain (HINSTANCE hinst, - wxUint32 fdwReason, + DWORD fdwReason, LPVOID /*lpReserved*/) { sprintf (out_buf, "DllMain (%0p - %d)\n", hinst, fdwReason); From 2d4728d7c2513eb134e86a5d0b5f30eaa788f18a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Oct 2015 00:07:10 -0400 Subject: [PATCH 016/213] added Glide64 MinGW compile script --- Source/Script/MinGW/glide64.cmd | 81 +++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 Source/Script/MinGW/glide64.cmd diff --git a/Source/Script/MinGW/glide64.cmd b/Source/Script/MinGW/glide64.cmd new file mode 100644 index 000000000..ac8133909 --- /dev/null +++ b/Source/Script/MinGW/glide64.cmd @@ -0,0 +1,81 @@ +@ECHO OFF +TITLE MinGW Compiler Suite Invocation + +set src=%CD%\..\..\Glide64 +set obj=%CD%\Glide64 + +if not exist %obj% ( +mkdir %obj% +) + + set MinGW=C:\MinGW +REM set MinGW=C:\msys64\mingw64\x86_64-w64-mingw32\.. + +set FLAGS_x86=^ + -I"%src%\.."^ + -I"%src%\..\3rd Party\wx\include"^ + -I"%src%\..\3rd Party\wx\lib\vc_lib\msw"^ + -I"%src%\..\Glitch64\inc"^ + -S^ + -masm=intel^ + -march=native^ + -Os + +set C_FLAGS=%FLAGS_x86% + +cd %MinGW%\bin +set CC=%MinGW%\bin\g++.exe +set AS=%MinGW%\bin\as.exe + +ECHO Compiling Glide64 plugin sources... +%CC% -o %obj%\Main.asm %src%\Main.cpp %C_FLAGS% +%CC% -o %obj%\FBtoScreen.asm %src%\FBtoScreen.cpp %C_FLAGS% +%CC% -o %obj%\rdp.asm %src%\rdp.cpp %C_FLAGS% +%CC% -o %obj%\Keys.asm %src%\Keys.cpp %C_FLAGS% +%CC% -o %obj%\Config.asm %src%\Config.cpp %C_FLAGS% +%CC% -o %obj%\CRC.asm %src%\CRC.cpp %C_FLAGS% +%CC% -o %obj%\Debugger.asm %src%\Debugger.cpp %C_FLAGS% +%CC% -o %obj%\Util.asm %src%\Util.cpp %C_FLAGS% +%CC% -o %obj%\TexCache.asm %src%\TexCache.cpp %C_FLAGS% +%CC% -o %obj%\3dmath.asm %src%\3dmath.cpp %C_FLAGS% +%CC% -o %obj%\Combine.asm %src%\Combine.cpp %C_FLAGS% +%CC% -o %obj%\DepthBufferRender.asm %src%\DepthBufferRender.cpp %C_FLAGS% +%CC% -o %obj%\Ext_TxFilter.asm %src%\Ext_TxFilter.cpp %C_FLAGS% +%CC% -o %obj%\TexBuffer.asm %src%\TexBuffer.cpp %C_FLAGS% + +ECHO Assembling Glide64 sources... +%AS% -o %obj%\Main.o %obj%\Main.asm +%AS% -o %obj%\FBtoScreen.o %obj%\FBtoScreen.asm +%AS% -o %obj%\rdp.o %obj%\rdp.asm +%AS% -o %obj%\Keys.o %obj%\Keys.asm +%AS% -o %obj%\Config.o %obj%\Config.asm +%AS% -o %obj%\CRC.o %obj%\CRC.asm +%AS% -o %obj%\Debugger.o %obj%\Debugger.asm +%AS% -o %obj%\Util.o %obj%\Util.asm +%AS% -o %obj%\TexCache.o %obj%\TexCache.asm +%AS% -o %obj%\3dmath.o %obj%\3dmath.asm +%AS% -o %obj%\Combine.o %obj%\Combine.asm +%AS% -o %obj%\DepthBufferRender.o %obj%\DepthBufferRender.asm +%AS% -o %obj%\Ext_TxFilter.o %obj%\Ext_TxFilter.asm +%AS% -o %obj%\TexBuffer.o %obj%\TexBuffer.asm +ECHO. + +set OBJ_LIST=^ + %obj%\TexBuffer.o^ + %obj%\Ext_TxFilter.o^ + %obj%\DepthBufferRender.o^ + %obj%\Combine.o^ + %obj%\3dmath.o^ + %obj%\TexCache.o^ + %obj%\Util.o^ + %obj%\Debugger.o^ + %obj%\CRC.o^ + %obj%\Config.o^ + %obj%\Keys.o^ + %obj%\rdp.o^ + %obj%\FBtoScreen.o^ + %obj%\Main.o + +ECHO Linking PJGlide64 objects... +%MinGW%\bin\g++.exe -o %obj%\PJ64Glide64.dll %OBJ_LIST% -shared -shared-libgcc +PAUSE From a4473fca971350ea28cebe2b5cee6484797ba3ea Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Oct 2015 00:08:17 -0400 Subject: [PATCH 017/213] added N-Rage MinGW compile script --- Source/Script/MinGW/nrage.cmd | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Source/Script/MinGW/nrage.cmd diff --git a/Source/Script/MinGW/nrage.cmd b/Source/Script/MinGW/nrage.cmd new file mode 100644 index 000000000..5dcb9f59a --- /dev/null +++ b/Source/Script/MinGW/nrage.cmd @@ -0,0 +1,61 @@ +@ECHO OFF +TITLE MinGW Compiler Suite Invocation + +set src=%CD%\..\..\nragev20 +set obj=%CD%\N-Rage + +if not exist %obj% ( +mkdir %obj% +) + + set MinGW=C:\MinGW +REM set MinGW=C:\msys64\mingw64\x86_64-w64-mingw32\.. + +set FLAGS_x86=^ + -I"%src%\..\3rd Party\directx\include"^ + -Wno-write-strings^ + -S^ + -masm=intel^ + -march=native^ + -Os + +set C_FLAGS=%FLAGS_x86% + +cd %MinGW%\bin +set CC=%MinGW%\bin\g++.exe +set AS=%MinGW%\bin\as.exe + +ECHO Compiling N-Rage plugin sources... +%CC% -o %obj%\NRagePluginV2.asm %src%\NRagePluginV2.cpp %C_FLAGS% +%CC% -o %obj%\Interface.asm %src%\Interface.cpp %C_FLAGS% +%CC% -o %obj%\FileAccess.asm %src%\FileAccess.cpp %C_FLAGS% +%CC% -o %obj%\PakIO.asm %src%\PakIO.cpp %C_FLAGS% +%CC% -o %obj%\GBCart.asm %src%\GBCart.cpp %C_FLAGS% +%CC% -o %obj%\International.asm %src%\International.cpp %C_FLAGS% +%CC% -o %obj%\DirectInput.asm %src%\DirectInput.cpp %C_FLAGS% +%CC% -o %obj%\XInputController.asm %src%\XInputController.cpp %C_FLAGS% + +ECHO Assembling N-Rage sources... +%AS% -o %obj%\NRagePluginV2.o %obj%\NRagePluginV2.asm +%AS% -o %obj%\Interface.o %obj%\Interface.asm +%AS% -o %obj%\FileAccess.o %obj%\FileAccess.asm +%AS% -o %obj%\PakIO.o %obj%\PakIO.asm +%AS% -o %obj%\GBCart.o %obj%\GBCart.asm +%AS% -o %obj%\International.o %obj%\International.asm +%AS% -o %obj%\DirectInput.o %obj%\DirectInput.asm +%AS% -o %obj%\XInputController.o %obj%\XInputController.asm +ECHO. + +set OBJ_LIST=^ + %obj%\XInputController.o^ + %obj%\DirectInput.o^ + %obj%\International.o^ + %obj%\GBCart.o^ + %obj%\PakIO.o^ + %obj%\FileAccess.o^ + %obj%\Interface.o^ + %obj%\NRagePluginV2.o + +ECHO Linking N-Rage objects... +%MinGW%\bin\g++.exe -o %obj%\PJ64_NRage.dll %OBJ_LIST% -shared -shared-libgcc +PAUSE From 3efc6024d0f7c86e2dc53631de2bee8c9fda39ab Mon Sep 17 00:00:00 2001 From: zilmar Date: Wed, 28 Oct 2015 22:20:15 +1100 Subject: [PATCH 018/213] [Project64] try to fix vs 2008 compiling being broken --- Source/3rd Party/wx/wx_core.vcproj | 6 +++--- Source/3rd Party/wx/wx_wxzlib.vcproj | 14 +++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Source/3rd Party/wx/wx_core.vcproj b/Source/3rd Party/wx/wx_core.vcproj index ba8c88e53..787318ae2 100644 --- a/Source/3rd Party/wx/wx_core.vcproj +++ b/Source/3rd Party/wx/wx_core.vcproj @@ -2172,9 +2172,9 @@ > diff --git a/Source/3rd Party/wx/wx_wxzlib.vcproj b/Source/3rd Party/wx/wx_wxzlib.vcproj index fe2485438..ac56a710a 100644 --- a/Source/3rd Party/wx/wx_wxzlib.vcproj +++ b/Source/3rd Party/wx/wx_wxzlib.vcproj @@ -148,7 +148,19 @@ > + + + + + + Date: Thu, 29 Oct 2015 10:24:27 +1100 Subject: [PATCH 019/213] [Project64] Trying to fix build --- Source/3rd Party/wx/wx_core.vcproj | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Source/3rd Party/wx/wx_core.vcproj b/Source/3rd Party/wx/wx_core.vcproj index 787318ae2..3b185d741 100644 --- a/Source/3rd Party/wx/wx_core.vcproj +++ b/Source/3rd Party/wx/wx_core.vcproj @@ -94,7 +94,7 @@ /> @@ -3763,11 +3763,11 @@ > Date: Thu, 29 Oct 2015 19:42:11 -0400 Subject: [PATCH 020/213] Unconditionally include to declare sprintf(). --- Source/RSP/log.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/RSP/log.cpp b/Source/RSP/log.cpp index 3ebcc8fea..5a07ec162 100644 --- a/Source/RSP/log.cpp +++ b/Source/RSP/log.cpp @@ -23,6 +23,8 @@ * should be forwarded to them so if they want them. * */ + +#include #include #include #include @@ -208,7 +210,6 @@ void RDP_LogLoc ( DWORD /*PC*/ ) #ifdef old #include -#include #include "RSP Registers.h" #include "log.h" From 6a3fe2bfb621c04c5cea5edde802e811697e8df6 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Oct 2015 19:42:39 -0400 Subject: [PATCH 021/213] Include to fix one undeclared sprintf(). --- Source/RSP/Profiling.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/RSP/Profiling.cpp b/Source/RSP/Profiling.cpp index 95891554b..648f945f0 100644 --- a/Source/RSP/Profiling.cpp +++ b/Source/RSP/Profiling.cpp @@ -24,6 +24,7 @@ * */ +#include #include #include extern "C" { @@ -168,8 +169,9 @@ public: { char Buffer[255]; float CpuUsage = (float)(((double)ItemList[count]->second / (double)TotalTime) * 100); + if (CpuUsage <= 0.2) { continue; } - sprintf(Buffer,"Func 0x%08X",ItemList[count]->first); + sprintf(Buffer, "Func 0x%08X", ItemList[count]->first); for (int NameID = 0; NameID < (sizeof(TimerNames) / sizeof(TIMER_NAME)); NameID++) { if (ItemList[count]->first == (DWORD)TimerNames[NameID].Timer) From 2ed50708c1837003dcec5e3bfbcea21238ee0db8 Mon Sep 17 00:00:00 2001 From: aschwant Date: Thu, 29 Oct 2015 17:58:26 -0600 Subject: [PATCH 022/213] Fixed incorrect file name causing plugins to fail to load --- Source/Project64/Plugins/Plugin List.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Project64/Plugins/Plugin List.cpp b/Source/Project64/Plugins/Plugin List.cpp index 1ebd59077..dd1412d89 100644 --- a/Source/Project64/Plugins/Plugin List.cpp +++ b/Source/Project64/Plugins/Plugin List.cpp @@ -98,7 +98,9 @@ void CPluginList::AddPluginFromDir ( CPath Dir) } Plugin.FullPath = Dir; - Plugin.FileName = Dir.GetDirectory().substr(m_PluginDir.GetDirectory().length()); + std::string& fullPath = Dir; + std::string& pluginPath = m_PluginDir; + Plugin.FileName = fullPath.substr(pluginPath.length()); if (GetProcAddress(hLib,"DllAbout") != NULL) { From 1e395a94493bb826e4ece4b2fba9c684c1ddc886 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Oct 2015 20:23:36 -0400 Subject: [PATCH 023/213] [RSP] Disable MSVC-specific 32-bit-only code for non-MSVC. --- Source/RSP/Main.cpp | 2 +- Source/RSP/Profiling.cpp | 4 ++-- Source/RSP/Recompiler CPU.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/RSP/Main.cpp b/Source/RSP/Main.cpp index 874394503..25dd4f6d7 100644 --- a/Source/RSP/Main.cpp +++ b/Source/RSP/Main.cpp @@ -273,7 +273,7 @@ void DetectCpuSpecs(void) DWORD AMD_Features = 0; __try { -#ifdef _M_IX86 +#if defined(_M_IX86) && defined(_MSC_VER) _asm { /* Intel features */ mov eax, 1 diff --git a/Source/RSP/Profiling.cpp b/Source/RSP/Profiling.cpp index 95891554b..600ed9107 100644 --- a/Source/RSP/Profiling.cpp +++ b/Source/RSP/Profiling.cpp @@ -59,7 +59,7 @@ public: DWORD OldTimerAddr = StopTimer(); m_CurrentTimerAddr = Address; -#ifdef _M_IX86 +#if defined(_M_IX86) && defined(_MSC_VER) DWORD HiValue, LoValue; _asm { pushad @@ -79,7 +79,7 @@ public: { if (m_CurrentTimerAddr == Timer_None) { return m_CurrentTimerAddr; } -#ifdef _M_IX86 +#if defined(_M_IX86) && defined(_MSC_VER) DWORD HiValue, LoValue; _asm { pushad diff --git a/Source/RSP/Recompiler CPU.c b/Source/RSP/Recompiler CPU.c index ed2a98def..15cc590b3 100644 --- a/Source/RSP/Recompiler CPU.c +++ b/Source/RSP/Recompiler CPU.c @@ -933,7 +933,7 @@ DWORD RunRecompilerCPU ( DWORD Cycles ) { StartTimer(*PrgCount); } -#ifdef _M_IX86 +#if defined(_M_IX86) && defined(_MSC_VER) _asm { pushad call Block @@ -952,7 +952,7 @@ DWORD RunRecompilerCPU ( DWORD Cycles ) { } if (IsMmxEnabled == TRUE) { -#ifdef _M_IX86 +#if defined(_M_IX86) && defined(_MSC_VER) _asm emms #else DebugBreak(); From 1f7ab970e83984d2704d4a4278b3e6fa2e445bea Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Oct 2015 20:48:31 -0400 Subject: [PATCH 024/213] [RSP] Disable __cpuid() detection for non-MSVC compiles. --- Source/RSP/Main.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/RSP/Main.cpp b/Source/RSP/Main.cpp index 25dd4f6d7..82e00ac73 100644 --- a/Source/RSP/Main.cpp +++ b/Source/RSP/Main.cpp @@ -272,8 +272,9 @@ void DetectCpuSpecs(void) DWORD Intel_Features = 0; DWORD AMD_Features = 0; +#if defined(_MSC_VER) __try { -#if defined(_M_IX86) && defined(_MSC_VER) +#ifdef _M_IX86 _asm { /* Intel features */ mov eax, 1 @@ -296,6 +297,13 @@ void DetectCpuSpecs(void) __except (EXCEPTION_EXECUTE_HANDLER) { AMD_Features = Intel_Features = 0; } +#else +/* + * To do: With GCC, there is , but __cpuid() there is a macro and + * needs five arguments, not two. Also, GCC lacks SEH. + */ + AMD_Features = Intel_Features = 0; +#endif if (Intel_Features & 0x02000000) { From 72007f6e9f1180f2c1bf8992a703ac07e35ab6c9 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Oct 2015 20:59:14 -0400 Subject: [PATCH 025/213] [RSP] adjust to unfortunate bug in GCC header --- Source/RSP/Interpreter Ops.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Source/RSP/Interpreter Ops.c b/Source/RSP/Interpreter Ops.c index cdb87cfec..098dd98b4 100644 --- a/Source/RSP/Interpreter Ops.c +++ b/Source/RSP/Interpreter Ops.c @@ -27,7 +27,6 @@ #include #include #include -#include #include "RSP.h" #include "CPU.h" #include "RSP Command.h" @@ -38,6 +37,23 @@ #include "log.h" #include "x86.h" +#include +/* + * Unfortunately, GCC 4.8.2 stable still has a bug with their that + * includes a different copy of from a different directory. + * + * Until that bug is fixed, the below macro definitions can be forced. + * + * It also is possible to emulate the RSP divide op-codes using a hardware- + * accurate LUT instead of any floating-point functions, so that works, too. + */ +#ifndef _MCW_RC +#define _MCW_RC 0x00000300 +#endif +#ifndef _RC_CHOP +#define _RC_CHOP 0x00000300 +#endif + extern UWORD32 Recp, RecpResult, SQroot, SQrootResult; extern BOOL AudioHle, GraphicsHle; From ff904a0f3e8ebef33c3e4c534461767a8172ad96 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Oct 2015 21:51:26 -0400 Subject: [PATCH 026/213] [RSP] This memset() should be able to cause exceptions. --- Source/RSP/Recompiler CPU.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/RSP/Recompiler CPU.c b/Source/RSP/Recompiler CPU.c index 15cc590b3..64fceaf66 100644 --- a/Source/RSP/Recompiler CPU.c +++ b/Source/RSP/Recompiler CPU.c @@ -904,8 +904,8 @@ DWORD RunRecompilerCPU ( DWORD Cycles ) { StartTimer((DWORD)Timer_Compiling); } + memset(&RspCode, 0, sizeof(RspCode)); __try { - memset(&RspCode, 0, sizeof(RspCode)); BuildBranchLabels(); DetectGPRConstants(&RspCode); CompilerRSPBlock(); From 061f69b6f37cdc1ebc6d26825299c4a2ee38096c Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Oct 2015 21:52:48 -0400 Subject: [PATCH 027/213] [RSP] Execute recompiler CPU without SEH for non-MSVC. --- Source/RSP/Recompiler CPU.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/RSP/Recompiler CPU.c b/Source/RSP/Recompiler CPU.c index 64fceaf66..ff69c3ba5 100644 --- a/Source/RSP/Recompiler CPU.c +++ b/Source/RSP/Recompiler CPU.c @@ -905,6 +905,7 @@ DWORD RunRecompilerCPU ( DWORD Cycles ) { } memset(&RspCode, 0, sizeof(RspCode)); +#if defined(_MSC_VER) __try { BuildBranchLabels(); DetectGPRConstants(&RspCode); @@ -914,6 +915,11 @@ DWORD RunRecompilerCPU ( DWORD Cycles ) { ClearAllx86Code(); continue; } +#else + BuildBranchLabels(); + DetectGPRConstants(&RspCode); + CompilerRSPBlock(); +#endif Block = *(JumpTable + (*PrgCount >> 2)); From 17d27633c206f2cca2f65fee0c4653794e309620 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Oct 2015 22:22:07 -0400 Subject: [PATCH 028/213] [RSP] added working MinGW compile script --- Source/Script/MinGW/rsp.cmd | 91 +++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 Source/Script/MinGW/rsp.cmd diff --git a/Source/Script/MinGW/rsp.cmd b/Source/Script/MinGW/rsp.cmd new file mode 100644 index 000000000..24128206a --- /dev/null +++ b/Source/Script/MinGW/rsp.cmd @@ -0,0 +1,91 @@ +@ECHO OFF +TITLE MinGW Compiler Suite Invocation + +set src=%CD%\..\..\RSP +set obj=%CD%\RSP + +if not exist %obj% ( +mkdir %obj% +) + + set MinGW=C:\MinGW +REM set MinGW=C:\msys64\mingw64\x86_64-w64-mingw32\.. + +set FLAGS_x86=^ + -Wno-write-strings^ + -I"%src%\.."^ + -S^ + -masm=intel^ + -march=native^ + -Os + +set C_FLAGS=%FLAGS_x86% + +cd %MinGW%\bin +set CC=%MinGW%\bin\gcc.exe +set AS=%MinGW%\bin\as.exe + +ECHO Compiling RSP plugin sources... +%CC% -o %obj%\Main.asm %src%\Main.cpp %C_FLAGS% +%CC% -o %obj%\Cpu.asm %src%\Cpu.c %C_FLAGS% +%CC% -o %obj%\memory.asm %src%\memory.c %C_FLAGS% +%CC% -o %obj%\dma.asm %src%\dma.c %C_FLAGS% +%CC% -o %obj%\breakpoint.asm %src%\breakpoint.c %C_FLAGS% +%CC% -o %obj%\log.asm %src%\log.cpp %C_FLAGS% +%CC% -o %obj%\InterpreterCPU.asm "%src%\Interpreter CPU.c" %C_FLAGS% +%CC% -o %obj%\RecompilerCPU.asm "%src%\Recompiler CPU.c" %C_FLAGS% +%CC% -o %obj%\InterpreterOps.asm "%src%\Interpreter Ops.c" %C_FLAGS% +%CC% -o %obj%\RecompilerOps.asm "%src%\Recompiler Ops.c" %C_FLAGS% +%CC% -o %obj%\Profiling.asm %src%\Profiling.cpp %C_FLAGS% +%CC% -o %obj%\RSPCommand.asm "%src%\RSP Command.c" %C_FLAGS% +%CC% -o %obj%\RSPRegister.asm "%src%\RSP Register.c" %C_FLAGS% +%CC% -o %obj%\RecompilerSections.asm "%src%\Recompiler Sections.c" %C_FLAGS% +%CC% -o %obj%\RecompilerAnalysis.asm "%src%\Recompiler Analysis.c" %C_FLAGS% +%CC% -o %obj%\X86.asm %src%\X86.c %C_FLAGS% +%CC% -o %obj%\Mmx.asm %src%\Mmx.c %C_FLAGS% +%CC% -o %obj%\Sse.asm %src%\Sse.c %C_FLAGS% + +ECHO Assembling RSP sources... +%AS% -o %obj%\Main.o %obj%\Main.asm +%AS% -o %obj%\Cpu.o %obj%\Cpu.asm +%AS% -o %obj%\memory.o %obj%\memory.asm +%AS% -o %obj%\dma.o %obj%\dma.asm +%AS% -o %obj%\breakpoint.o %obj%\breakpoint.asm +%AS% -o %obj%\log.o %obj%\log.asm +%AS% -o %obj%\InterpreterCPU.o %obj%\InterpreterCPU.asm +%AS% -o %obj%\RecompilerCPU.o %obj%\RecompilerCPU.asm +%AS% -o %obj%\InterpreterOps.o %obj%\InterpreterOps.asm +%AS% -o %obj%\RecompilerOps.o %obj%\RecompilerOps.asm +%AS% -o %obj%\Profiling.o %obj%\Profiling.asm +%AS% -o %obj%\RSPCommand.o %obj%\RSPCommand.asm +%AS% -o %obj%\RSPRegister.o %obj%\RSPRegister.asm +%AS% -o %obj%\RecompilerSections.o %obj%\RecompilerSections.asm +%AS% -o %obj%\RecompilerAnalysis.o %obj%\RecompilerAnalysis.asm +%AS% -o %obj%\X86.o %obj%\X86.asm +%AS% -o %obj%\Mmx.o %obj%\Mmx.asm +%AS% -o %obj%\Sse.o %obj%\Sse.asm +ECHO. + +set OBJ_LIST=^ + %obj%\Sse.o^ + %obj%\Mmx.o^ + %obj%\X86.o^ + %obj%\RecompilerAnalysis.o^ + %obj%\RecompilerSections.o^ + %obj%\RSPRegister.o^ + %obj%\RSPCommand.o^ + %obj%\Profiling.o^ + %obj%\RecompilerOps.o^ + %obj%\InterpreterOps.o^ + %obj%\RecompilerCPU.o^ + %obj%\InterpreterCPU.o^ + %obj%\log.o^ + %obj%\breakpoint.o^ + %obj%\dma.o^ + %obj%\memory.o^ + %obj%\Cpu.o^ + %obj%\Main.o + +ECHO Linking RSP objects... +%MinGW%\bin\g++.exe -o %obj%\RSP_1.7.dll %OBJ_LIST% -lgdi32 -s +PAUSE From 068811dc221547aaa0e295bb543be494a7532476 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Oct 2015 22:54:29 -0400 Subject: [PATCH 029/213] fixed SP DMA for pointer-to-integer casts --- Source/RSP/dma.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/RSP/dma.c b/Source/RSP/dma.c index faad399af..5da046e38 100644 --- a/Source/RSP/dma.c +++ b/Source/RSP/dma.c @@ -71,7 +71,7 @@ void SP_DMA_READ (void) { for (i = 0 ; i < Length; i++) { - *(BYTE *)(((DWORD)Dest + j * Length + i) ^ 3) = *(BYTE *)(((DWORD)Source + j * Skip + i) ^ 3); + *(uint8_t *)(((size_t)Dest + j * Length + i) ^ 3) = *(uint8_t *)(((size_t)Source + j * Skip + i) ^ 3); } } #else @@ -90,7 +90,7 @@ void SP_DMA_READ (void) { for (i = 0 ; i < Length; i++) { - *(BYTE *)(((DWORD)Dest + i) ^ 3) = *(BYTE *)(((DWORD)Source + i) ^ 3); + *(uint8_t *)(((size_t)Dest + i) ^ 3) = *(uint8_t *)(((size_t)Source + i) ^ 3); } Source += Skip; Dest += Length; @@ -138,7 +138,7 @@ void SP_DMA_WRITE (void) { for (i = 0 ; i < Length; i++) { - *(BYTE *)(((DWORD)Dest + j * Skip + i) ^ 3) = *(BYTE *)(((DWORD)Source + j * Length + i) ^ 3); + *(uint8_t *)(((size_t)Dest + j * Skip + i) ^ 3) = *(uint8_t *)(((size_t)Source + j * Length + i) ^ 3); } } #else @@ -157,7 +157,7 @@ void SP_DMA_WRITE (void) { for (i = 0 ; i < Length; i++) { - *(BYTE *)(((DWORD)Dest + i) ^ 3) = *(BYTE *)(((DWORD)Source + i) ^ 3); + *(uint8_t *)(((size_t)Dest + i) ^ 3) = *(uint8_t *)(((size_t)Source + i) ^ 3); } Source += Length; Dest += Skip; From fbc9b8027069a14d9f956aa639ecfdcb05a00423 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Oct 2015 00:02:20 -0400 Subject: [PATCH 030/213] MoveOffsetToX86reg --- Source/RSP/Recompiler Ops.c | 38 ++++++++++++++++++------------------- Source/RSP/X86.c | 2 +- Source/RSP/X86.h | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Source/RSP/Recompiler Ops.c b/Source/RSP/Recompiler Ops.c index 594f3c925..894839d9f 100644 --- a/Source/RSP/Recompiler Ops.c +++ b/Source/RSP/Recompiler Ops.c @@ -2451,14 +2451,14 @@ void Compile_Vector_VMUDM ( void ) { Push(x86_EBP); sprintf(Reg, "RSP_Vect[%i].HW[0]", RSPOpC.rd); - MoveOffsetToX86reg((DWORD)&RSP_Vect[RSPOpC.rd].HW[0], Reg, x86_EBP); + MoveOffsetToX86reg((size_t)&RSP_Vect[RSPOpC.rd].HW[0], Reg, x86_EBP); if (bWriteToDest) { sprintf(Reg, "RSP_Vect[%i].HW[0]", RSPOpC.sa); - MoveOffsetToX86reg((DWORD)&RSP_Vect[RSPOpC.sa].HW[0], Reg, x86_ECX); + MoveOffsetToX86reg((size_t)&RSP_Vect[RSPOpC.sa].HW[0], Reg, x86_ECX); } else if (!bOptimize) { sprintf(Reg, "RSP_Vect[%i].HW[0]", RSPOpC.rt); - MoveOffsetToX86reg((DWORD)&RSP_Vect[RSPOpC.rt].HW[0], Reg, x86_ECX); + MoveOffsetToX86reg((size_t)&RSP_Vect[RSPOpC.rt].HW[0], Reg, x86_ECX); } for (count = 0; count < 8; count++) { @@ -2575,7 +2575,7 @@ void Compile_Vector_VMUDN ( void ) { Push(x86_EBP); sprintf(Reg, "RSP_Vect[%i].HW[0]", RSPOpC.rd); - MoveOffsetToX86reg((DWORD)&RSP_Vect[RSPOpC.rd].HW[0], Reg, x86_EBP); + MoveOffsetToX86reg((size_t)&RSP_Vect[RSPOpC.rd].HW[0], Reg, x86_EBP); for (count = 0; count < 8; count++) { CPU_Message(" Iteration: %i", count); @@ -2719,7 +2719,7 @@ void Compile_Vector_VMUDH ( void ) { */ sprintf(Reg, "RSP_Vect[%i].HW[0]", RSPOpC.rd); - MoveOffsetToX86reg((DWORD)&RSP_Vect[RSPOpC.rd].HW[0], Reg, x86_EBP); + MoveOffsetToX86reg((size_t)&RSP_Vect[RSPOpC.rd].HW[0], Reg, x86_EBP); MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, 0, x86_EAX); MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, 2, x86_ECX); @@ -2732,7 +2732,7 @@ void Compile_Vector_VMUDH ( void ) { ImulX86RegToX86Reg(x86_ESI, x86_EBX); XorX86RegToX86Reg(x86_EDX, x86_EDX); - MoveOffsetToX86reg((DWORD)&RSP_ACCUM[0].W[0], "RSP_ACCUM[0].W[0]", x86_EBP); + MoveOffsetToX86reg((size_t)&RSP_ACCUM[0].W[0], "RSP_ACCUM[0].W[0]", x86_EBP); MoveX86RegToX86regPointerDisp(x86_EDX, x86_EBP, 0); MoveX86RegToX86regPointerDisp(x86_EAX, x86_EBP, 4); @@ -2748,7 +2748,7 @@ void Compile_Vector_VMUDH ( void ) { */ sprintf(Reg, "RSP_Vect[%i].HW[0]", RSPOpC.rd); - MoveOffsetToX86reg((DWORD)&RSP_Vect[RSPOpC.rd].HW[0], Reg, x86_EBP); + MoveOffsetToX86reg((size_t)&RSP_Vect[RSPOpC.rd].HW[0], Reg, x86_EBP); MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, 8, x86_EAX); MoveSxX86RegPtrDispToX86RegHalf(x86_EBP, 10, x86_ECX); @@ -2761,7 +2761,7 @@ void Compile_Vector_VMUDH ( void ) { ImulX86RegToX86Reg(x86_ESI, x86_EBX); XorX86RegToX86Reg(x86_EDX, x86_EDX); - MoveOffsetToX86reg((DWORD)&RSP_ACCUM[0].W[0], "RSP_ACCUM[0].W[0]", x86_EBP); + MoveOffsetToX86reg((size_t)&RSP_ACCUM[0].W[0], "RSP_ACCUM[0].W[0]", x86_EBP); MoveX86RegToX86regPointerDisp(x86_EDX, x86_EBP, 32); MoveX86RegToX86regPointerDisp(x86_EAX, x86_EBP, 36); @@ -2987,14 +2987,14 @@ void Compile_Vector_VMADM ( void ) { Push(x86_EBP); sprintf(Reg, "RSP_Vect[%i].HW[0]", RSPOpC.rd); - MoveOffsetToX86reg((DWORD)&RSP_Vect[RSPOpC.rd].HW[0], Reg, x86_EBP); + MoveOffsetToX86reg((size_t)&RSP_Vect[RSPOpC.rd].HW[0], Reg, x86_EBP); if (bWriteToDest) { sprintf(Reg, "RSP_Vect[%i].HW[0]", RSPOpC.sa); - MoveOffsetToX86reg((DWORD)&RSP_Vect[RSPOpC.sa].HW[0], Reg, x86_ECX); + MoveOffsetToX86reg((size_t)&RSP_Vect[RSPOpC.sa].HW[0], Reg, x86_ECX); } else if (!bOptimize) { sprintf(Reg, "RSP_Vect[%i].HW[0]", RSPOpC.rt); - MoveOffsetToX86reg((DWORD)&RSP_Vect[RSPOpC.rt].HW[0], Reg, x86_ECX); + MoveOffsetToX86reg((size_t)&RSP_Vect[RSPOpC.rt].HW[0], Reg, x86_ECX); } for (count = 0; count < 8; count++) { @@ -3070,7 +3070,7 @@ void Compile_Vector_VMADN ( void ) { Push(x86_EBP); sprintf(Reg, "RSP_Vect[%i].HW[0]", RSPOpC.rd); - MoveOffsetToX86reg((DWORD)&RSP_Vect[RSPOpC.rd].HW[0], Reg, x86_EBP); + MoveOffsetToX86reg((size_t)&RSP_Vect[RSPOpC.rd].HW[0], Reg, x86_EBP); for (count = 0; count < 8; count++) { CPU_Message(" Iteration: %i", count); @@ -3146,7 +3146,7 @@ void Compile_Vector_VMADH ( void ) { if (bWriteToDest == FALSE && bOptimize == TRUE) { Push(x86_EBP); sprintf(Reg, "RSP_Vect[%i].HW[0]", RSPOpC.rd); - MoveOffsetToX86reg((DWORD)&RSP_Vect[RSPOpC.rd].HW[0], Reg, x86_EBP); + MoveOffsetToX86reg((size_t)&RSP_Vect[RSPOpC.rd].HW[0], Reg, x86_EBP); /* * Pipe lined segment 0 @@ -3196,14 +3196,14 @@ void Compile_Vector_VMADH ( void ) { } else { Push(x86_EBP); sprintf(Reg, "RSP_Vect[%i].HW[0]", RSPOpC.rd); - MoveOffsetToX86reg((DWORD)&RSP_Vect[RSPOpC.rd].HW[0], Reg, x86_EBP); + MoveOffsetToX86reg((size_t)&RSP_Vect[RSPOpC.rd].HW[0], Reg, x86_EBP); if (bWriteToDest) { sprintf(Reg, "RSP_Vect[%i].HW[0]", RSPOpC.sa); - MoveOffsetToX86reg((DWORD)&RSP_Vect[RSPOpC.sa].HW[0], Reg, x86_ECX); + MoveOffsetToX86reg((size_t)&RSP_Vect[RSPOpC.sa].HW[0], Reg, x86_ECX); } else if (!bOptimize) { sprintf(Reg, "RSP_Vect[%i].HW[0]", RSPOpC.rt); - MoveOffsetToX86reg((DWORD)&RSP_Vect[RSPOpC.rt].HW[0], Reg, x86_ECX); + MoveOffsetToX86reg((size_t)&RSP_Vect[RSPOpC.rt].HW[0], Reg, x86_ECX); } for (count = 0; count < 8; count++) { @@ -3686,7 +3686,7 @@ void Compile_Vector_VADDC ( void ) { Push(x86_EBP); sprintf(Reg, "RSP_Vect[%i].HW[0]", RSPOpC.rd); - MoveOffsetToX86reg((DWORD)&RSP_Vect[RSPOpC.rd].HW[0], Reg, x86_EBP); + MoveOffsetToX86reg((size_t)&RSP_Vect[RSPOpC.rd].HW[0], Reg, x86_EBP); for (count = 0; count < 8; count++) { CPU_Message(" Iteration: %i", count); @@ -5251,7 +5251,7 @@ void Compile_Opcode_LDV ( void ) { CPU_Message(" Unaligned:"); x86_SetBranch32b(Jump[0], RecompPos); sprintf(Reg, "RSP_Vect[%i].UB[%i]", RSPOpC.rt, 15 - RSPOpC.del); - MoveOffsetToX86reg((DWORD)&RSP_Vect[RSPOpC.rt].UB[15 - RSPOpC.del], Reg, x86_EDI); + MoveOffsetToX86reg((size_t)&RSP_Vect[RSPOpC.rt].UB[15 - RSPOpC.del], Reg, x86_EDI); length = 8; if (RSPOpC.del == 12){ length = 4; @@ -5993,7 +5993,7 @@ void Compile_Opcode_SDV ( void ) { x86_SetBranch32b((DWORD*)Jump[0], (DWORD*)RecompPos); sprintf(Reg, "RSP_Vect[%i].UB[%i]", RSPOpC.rt, 15 - RSPOpC.del); - MoveOffsetToX86reg((DWORD)&RSP_Vect[RSPOpC.rt].UB[15 - RSPOpC.del], Reg, x86_EDI); + MoveOffsetToX86reg((size_t)&RSP_Vect[RSPOpC.rt].UB[15 - RSPOpC.del], Reg, x86_EDI); MoveConstToX86reg(8, x86_ECX); CPU_Message(" Loop:"); diff --git a/Source/RSP/X86.c b/Source/RSP/X86.c index 3abdf6c0e..b28b9cf48 100644 --- a/Source/RSP/X86.c +++ b/Source/RSP/X86.c @@ -1178,7 +1178,7 @@ void MoveConstToX86reg(DWORD Const, int x86reg) { PUTDST32(RecompPos,Const); } -void MoveOffsetToX86reg(DWORD Const, char * VariableName, int x86reg) { +void MoveOffsetToX86reg(size_t Const, char * VariableName, int x86reg) { CPU_Message(" mov %s, offset %s",x86_Name(x86reg),VariableName); switch (x86reg) { case x86_EAX: PUTDST16(RecompPos,0xC0C7); break; diff --git a/Source/RSP/X86.h b/Source/RSP/X86.h index 6723fe11b..c3e003213 100644 --- a/Source/RSP/X86.h +++ b/Source/RSP/X86.h @@ -114,7 +114,7 @@ void MoveConstToN64Mem ( DWORD Const, int AddrReg ); void MoveConstToN64MemDisp ( DWORD Const, int AddrReg, BYTE Disp ); void MoveConstToVariable ( DWORD Const, void *Variable, char *VariableName ); void MoveConstToX86reg ( DWORD Const, int x86reg ); -void MoveOffsetToX86reg ( DWORD Const, char * VariableName, int x86reg ); +void MoveOffsetToX86reg ( size_t Const, char * VariableName, int x86reg ); void MoveX86regByteToX86regPointer ( int Source, int AddrReg ); void MoveX86regHalfToX86regPointer ( int Source, int AddrReg ); void MoveX86regHalfToX86regPointerDisp ( int Source, int AddrReg, BYTE Disp); From 4736a76f8a8a34b7fba39b660e18f9b2d15082d0 Mon Sep 17 00:00:00 2001 From: oddMLan Date: Fri, 30 Oct 2015 00:26:23 -0700 Subject: [PATCH 031/213] Link to Common Controls 6.0 With this we get themed buttons and controls. --- Source/Project64/stdafx.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Project64/stdafx.h b/Source/Project64/stdafx.h index 2c0f1950b..f7f730497 100644 --- a/Source/Project64/stdafx.h +++ b/Source/Project64/stdafx.h @@ -13,6 +13,8 @@ #pragma warning(disable:4247) #pragma warning(disable:4786) +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") + #include #include #include From f2a5b01620d4ba1e5e7eccaa0f6469d205e2d073 Mon Sep 17 00:00:00 2001 From: oddMLan Date: Fri, 30 Oct 2015 00:39:40 -0700 Subject: [PATCH 032/213] Delete statement linking to old manifest file Visual Studio will generate one during compilation. --- Source/Project64/User Interface/UI Resources.rc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Source/Project64/User Interface/UI Resources.rc b/Source/Project64/User Interface/UI Resources.rc index 3c1555d97..a7bee1480 100644 --- a/Source/Project64/User Interface/UI Resources.rc +++ b/Source/Project64/User Interface/UI Resources.rc @@ -19,10 +19,6 @@ ///////////////////////////////////////////////////////////////////////////// // English (U.S.) resources -#ifdef _M_IX86 -CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "..\Project64.exe.manifest" -#endif - #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US From 0b5fa5ba555ade6b4b6c7a08c31242e0865aab24 Mon Sep 17 00:00:00 2001 From: oddMLan Date: Fri, 30 Oct 2015 00:44:44 -0700 Subject: [PATCH 033/213] Delete Project64.exe.manifest Redundant since Visual Studio will generate an intermediate manifest and embed it into the executable. So it should be safe to delete. --- Source/Project64/Project64.exe.manifest | 28 ------------------------- 1 file changed, 28 deletions(-) delete mode 100644 Source/Project64/Project64.exe.manifest diff --git a/Source/Project64/Project64.exe.manifest b/Source/Project64/Project64.exe.manifest deleted file mode 100644 index ab4df5075..000000000 --- a/Source/Project64/Project64.exe.manifest +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - From ba2e5ba9e6eb590b9e4940e13850ab4e5bcf6631 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 30 Oct 2015 22:08:27 +0900 Subject: [PATCH 034/213] Support Dezaemon 3D saves (SRAM 96KB) Support Dezaemon 3D saves (SRAM 96KB) --- Source/Project64/N64 System/Mips/Dma.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Project64/N64 System/Mips/Dma.cpp b/Source/Project64/N64 System/Mips/Dma.cpp index 2ecf4e835..d1a4e71af 100644 --- a/Source/Project64/N64 System/Mips/Dma.cpp +++ b/Source/Project64/N64 System/Mips/Dma.cpp @@ -101,7 +101,7 @@ void CDMA::PI_DMA_READ() return; } - if ( g_Reg->PI_CART_ADDR_REG >= 0x08000000 && g_Reg->PI_CART_ADDR_REG <= 0x08010000) + if ( g_Reg->PI_CART_ADDR_REG >= 0x08000000 && g_Reg->PI_CART_ADDR_REG <= 0x08088000) { if (g_System->m_SaveUsing == SaveChip_Auto) { @@ -169,7 +169,7 @@ void CDMA::PI_DMA_WRITE() return; } - if ( g_Reg->PI_CART_ADDR_REG >= 0x08000000 && g_Reg->PI_CART_ADDR_REG <= 0x08010000) + if ( g_Reg->PI_CART_ADDR_REG >= 0x08000000 && g_Reg->PI_CART_ADDR_REG <= 0x08088000) { if (g_System->m_SaveUsing == SaveChip_Auto) { From cd2f3cf173e88c8c1e18108f9f21405c077352e8 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 30 Oct 2015 22:09:56 +0900 Subject: [PATCH 035/213] Support Dezaemon 3D saves (SRAM 96KB) Support Dezaemon 3D saves (SRAM 96KB) --- Source/Project64/N64 System/Mips/Sram.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Source/Project64/N64 System/Mips/Sram.cpp b/Source/Project64/N64 System/Mips/Sram.cpp index fc70b7f96..d1f588691 100644 --- a/Source/Project64/N64 System/Mips/Sram.cpp +++ b/Source/Project64/N64 System/Mips/Sram.cpp @@ -63,6 +63,10 @@ void CSram::DmaFromSram(BYTE * dest, int StartOffset, int len) return; } } + + // Fix Dezaemon 3D saves + StartOffset = ((StartOffset >> 3) & 0xFFFF8000) | (StartOffset & 0x7FFF); + DWORD Offset = StartOffset & 3; if (Offset == 0) @@ -145,7 +149,12 @@ void CSram::DmaToSram(BYTE * Source, int StartOffset, int len) return; } } + + // Fix Dezaemon 3D saves + StartOffset = ((StartOffset >> 3) & 0xFFFF8000) | (StartOffset & 0x7FFF); + DWORD Offset = StartOffset & 3; + if (Offset == 0) { SetFilePointer(m_hFile, StartOffset, NULL, FILE_BEGIN); From dd587cccea856fb85daac692913702ccf224651b Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 30 Oct 2015 22:11:12 +0900 Subject: [PATCH 036/213] Remove sram size Remove sram size --- Source/Project64/Multilanguage/Language Class.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Project64/Multilanguage/Language Class.cpp b/Source/Project64/Multilanguage/Language Class.cpp index d9ba7ca31..dab71accb 100644 --- a/Source/Project64/Multilanguage/Language Class.cpp +++ b/Source/Project64/Multilanguage/Language Class.cpp @@ -315,7 +315,7 @@ void CLanguage::LoadDefaultStrings (void) DEF_STR(SAVE_FIRST_USED, L"Use first-used save type"); DEF_STR(SAVE_4K_EEPROM, L"4-kbit EEPROM"); DEF_STR(SAVE_16K_EEPROM, L"16-kbit EEPROM"); - DEF_STR(SAVE_SRAM, L"32-kbyte SRAM"); + DEF_STR(SAVE_SRAM, L"SRAM"); DEF_STR(SAVE_FLASHRAM, L"Flash RAM"); //Shell Integration Tab From 9d562abab9661188ece6e2f7a9b51c62d9b7dd8f Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 30 Oct 2015 22:11:57 +0900 Subject: [PATCH 037/213] Update Project64.rdb --- Config/Project64.rdb | 1 + 1 file changed, 1 insertion(+) diff --git a/Config/Project64.rdb b/Config/Project64.rdb index ce2dbb1d9..5966b07e6 100644 --- a/Config/Project64.rdb +++ b/Config/Project64.rdb @@ -1430,6 +1430,7 @@ Plugin Note=[video] unsupported Good Name=Dezaemon 3D (J) Internal Name=DEZAEMON3D Status=Compatible +Save Type=Sram [FD73F775-9724755A-C:50] Good Name=Diddy Kong Racing (E) (M3) (V1.0) From 69ebe1672b0440257b41545027cb254b89a38715 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Oct 2015 13:27:02 -0400 Subject: [PATCH 038/213] LeaSourceAndOffset: pointer-to-int truncation fixed --- Source/RSP/Recompiler Ops.c | 2 +- Source/RSP/X86.c | 5 +++-- Source/RSP/X86.h | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/RSP/Recompiler Ops.c b/Source/RSP/Recompiler Ops.c index 894839d9f..105852e81 100644 --- a/Source/RSP/Recompiler Ops.c +++ b/Source/RSP/Recompiler Ops.c @@ -5444,7 +5444,7 @@ void Compile_Opcode_LRV ( void ) { Jump[0] = RecompPos - 1; /* DecX86reg(x86_EAX); - LeaSourceAndOffset(x86_EAX, x86_EAX, (DWORD) &RSP_Vect[RSPOpC.rt].B[0]); + LeaSourceAndOffset(x86_EAX, x86_EAX, (size_t)&RSP_Vect[RSPOpC.rt].B[0]); DecX86reg(x86_EAX); */ AddConstToX86Reg(x86_EAX, ((DWORD)&RSP_Vect[RSPOpC.rt].UB[0]) - 2); diff --git a/Source/RSP/X86.c b/Source/RSP/X86.c index b28b9cf48..fc31849e2 100644 --- a/Source/RSP/X86.c +++ b/Source/RSP/X86.c @@ -1101,7 +1101,7 @@ void JsLabel32(char *Label, DWORD Value) { ** if we need this rewrite it into 1 function **/ -void LeaSourceAndOffset(int x86DestReg, int x86SourceReg, int offset) { +void LeaSourceAndOffset(int x86DestReg, int x86SourceReg, size_t offset) { WORD x86Command = 0; CPU_Message(" lea %s, [%s + %0Xh]",x86_Name(x86DestReg),x86_Name(x86SourceReg),offset); @@ -1130,7 +1130,8 @@ void LeaSourceAndOffset(int x86DestReg, int x86SourceReg, int offset) { DisplayError("LeaSourceAndOffset\nUnknown x86 Register"); } - if ((offset & 0xFFFFFF80) != 0 && (offset & 0xFFFFFF80) != 0xFFFFFF80) { +// To do: Check high DWORD of offset for 64-bit x86. + if ((offset & 0x00000000FFFFFF80) != 0 && (offset & ~0x7F) != ~0x7F) { PUTDST16(RecompPos,x86Command); PUTDST32(RecompPos,offset); } else { diff --git a/Source/RSP/X86.h b/Source/RSP/X86.h index c3e003213..4075f4684 100644 --- a/Source/RSP/X86.h +++ b/Source/RSP/X86.h @@ -105,7 +105,7 @@ void JneLabel32 ( char * Label, DWORD Value ); void JnsLabel8 ( char * Label, BYTE Value ); void JnsLabel32 ( char * Label, DWORD Value ); void JsLabel32 ( char * Label, DWORD Value ); -void LeaSourceAndOffset ( int x86DestReg, int x86SourceReg, int offset ); +void LeaSourceAndOffset ( int x86DestReg, int x86SourceReg, size_t offset ); void MoveConstByteToN64Mem ( BYTE Const, int AddrReg ); void MoveConstHalfToN64Mem ( WORD Const, int AddrReg ); void MoveConstByteToVariable ( BYTE Const,void *Variable, char *VariableName ); From e7fed940de559d958d2f0c905525f68f79d092c9 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Oct 2015 14:08:19 -0400 Subject: [PATCH 039/213] AddConstToX86Reg: pointer-to-int truncation fixed --- Source/RSP/Recompiler Ops.c | 2 +- Source/RSP/X86.c | 10 ++++++++-- Source/RSP/X86.h | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Source/RSP/Recompiler Ops.c b/Source/RSP/Recompiler Ops.c index 105852e81..3861f482f 100644 --- a/Source/RSP/Recompiler Ops.c +++ b/Source/RSP/Recompiler Ops.c @@ -5447,7 +5447,7 @@ void Compile_Opcode_LRV ( void ) { LeaSourceAndOffset(x86_EAX, x86_EAX, (size_t)&RSP_Vect[RSPOpC.rt].B[0]); DecX86reg(x86_EAX); */ - AddConstToX86Reg(x86_EAX, ((DWORD)&RSP_Vect[RSPOpC.rt].UB[0]) - 2); + AddConstToX86Reg(x86_EAX, ((size_t)&RSP_Vect[RSPOpC.rt].UB[0]) - 2); CPU_Message(" Loop:"); Loop = RecompPos; diff --git a/Source/RSP/X86.c b/Source/RSP/X86.c index fc31849e2..947dfb06c 100644 --- a/Source/RSP/X86.c +++ b/Source/RSP/X86.c @@ -152,9 +152,15 @@ void AddConstToVariable (DWORD Const, void *Variable, char *VariableName) { PUTDST32(RecompPos,Const); } -void AddConstToX86Reg (int x86Reg, DWORD Const) { +void AddConstToX86Reg(int x86Reg, size_t Const) +{ + const size_t zero_extension_mask = 0x00000000000000007F; + const size_t sign_extension_mask = ~(zero_extension_mask); + const size_t extension_from_8bit = Const & sign_extension_mask; + +/* To do: if 64-bit x86, then what if `Const' upper DWORD set? */ CPU_Message(" add %s, %Xh",x86_Name(x86Reg),Const); - if ((Const & 0xFFFFFF80) != 0 && (Const & 0xFFFFFF80) != 0xFFFFFF80) { + if (extension_from_8bit != 0 && extension_from_8bit != sign_extension_mask) { switch (x86Reg) { case x86_EAX: PUTDST16(RecompPos,0xC081); break; case x86_EBX: PUTDST16(RecompPos,0xC381); break; diff --git a/Source/RSP/X86.h b/Source/RSP/X86.h index 4075f4684..6f08aa30a 100644 --- a/Source/RSP/X86.h +++ b/Source/RSP/X86.h @@ -46,7 +46,7 @@ void AdcConstToX86reg ( BYTE Constant, int x86reg ); void AdcConstToVariable ( void *Variable, char *VariableName, BYTE Constant ); void AdcConstHalfToVariable ( void *Variable, char *VariableName, BYTE Constant ); void AddConstToVariable ( DWORD Const, void *Variable, char *VariableName ); -void AddConstToX86Reg ( int x86Reg, DWORD Const ); +void AddConstToX86Reg ( int x86Reg, size_t Const ); void AddVariableToX86reg ( int x86reg, void * Variable, char * VariableName ); void AddX86regToVariable ( int x86reg, void * Variable, char * VariableName ); void AddX86regHalfToVariable ( int x86reg, void * Variable, char * VariableName ); From 354cf1bf5d9bf673e105095a535f0c747a53f514 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Oct 2015 15:48:30 -0400 Subject: [PATCH 040/213] fixed x86 compiler address writes --- Source/RSP/Mmx.c | 20 +++---- Source/RSP/Sse.c | 18 ++++--- Source/RSP/X86.c | 132 ++++++++++++++++++++++++----------------------- 3 files changed, 88 insertions(+), 82 deletions(-) diff --git a/Source/RSP/Mmx.c b/Source/RSP/Mmx.c index 718fd44e7..a21c23c94 100644 --- a/Source/RSP/Mmx.c +++ b/Source/RSP/Mmx.c @@ -35,6 +35,8 @@ #define PUTDST8(dest,value) (*((BYTE *)(dest))=(BYTE)(value)); dest += 1; #define PUTDST16(dest,value) (*((WORD *)(dest))=(WORD)(value)); dest += 2; #define PUTDST32(dest,value) (*((DWORD *)(dest))=(DWORD)(value)); dest += 4; +#define PUTDSTPTR(dest, value) \ + *(void **)(dest) = (void *)(value); dest += sizeof(void *); char * mmx_Strings[8] = { "mm0", "mm1", "mm2", "mm3", @@ -96,7 +98,7 @@ void MmxMoveQwordVariableToReg(int Dest, void *Variable, char *VariableName) { PUTDST16(RecompPos,0x6f0f); PUTDST8(RecompPos, x86Command); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void MmxMoveQwordRegToVariable(int Dest, void *Variable, char *VariableName) { @@ -117,7 +119,7 @@ void MmxMoveQwordRegToVariable(int Dest, void *Variable, char *VariableName) { PUTDST16(RecompPos,0x7f0f); PUTDST8(RecompPos, x86Command); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void MmxPorRegToReg(int Dest, int Source) { @@ -167,7 +169,7 @@ void MmxPorVariableToReg(void * Variable, char * VariableName, int Dest) { PUTDST16(RecompPos,0xeb0f); PUTDST8(RecompPos, x86Command); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void MmxPandRegToReg(int Dest, int Source) { @@ -217,7 +219,7 @@ void MmxPandVariableToReg(void * Variable, char * VariableName, int Dest) { PUTDST16(RecompPos,0xdb0f); PUTDST8(RecompPos, x86Command); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void MmxPandnRegToReg(int Dest, int Source) { @@ -296,7 +298,7 @@ void MmxShuffleMemoryToReg(int Dest, void * Variable, char * VariableName, BYTE PUTDST16(RecompPos,0x700f); PUTDST8(RecompPos, x86Command); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); PUTDST8(RecompPos, Immed); } @@ -375,7 +377,7 @@ void MmxPmullwVariableToReg(int Dest, void * Variable, char * VariableName) { } PUTDST16(RecompPos,0xd50f); PUTDST8(RecompPos, x86Command); - PUTDST32(RecompPos, Variable); + PUTDSTPTR(RecompPos, Variable); } void MmxPmulhuwRegToReg(int Dest, int Source) { @@ -453,7 +455,7 @@ void MmxPmulhwRegToVariable(int Dest, void * Variable, char * VariableName) { } PUTDST16(RecompPos,0xe50f); PUTDST8(RecompPos, x86Command); - PUTDST32(RecompPos, Variable); + PUTDSTPTR(RecompPos, Variable); } @@ -596,7 +598,7 @@ void MmxPaddswVariableToReg(int Dest, void * Variable, char * VariableName) { PUTDST16(RecompPos,0xed0f); PUTDST8(RecompPos, x86Command); - PUTDST32(RecompPos, Variable); + PUTDSTPTR(RecompPos, Variable); } void MmxPsubswVariableToReg(int Dest, void * Variable, char * VariableName) { @@ -617,7 +619,7 @@ void MmxPsubswVariableToReg(int Dest, void * Variable, char * VariableName) { PUTDST16(RecompPos,0xe90f); PUTDST8(RecompPos, x86Command); - PUTDST32(RecompPos, Variable); + PUTDSTPTR(RecompPos, Variable); } void MmxPaddwRegToReg(int Dest, int Source) { diff --git a/Source/RSP/Sse.c b/Source/RSP/Sse.c index 6eddbefba..11729e5fb 100644 --- a/Source/RSP/Sse.c +++ b/Source/RSP/Sse.c @@ -35,6 +35,8 @@ #define PUTDST8(dest,value) (*((BYTE *)(dest))=(BYTE)(value)); dest += 1; #define PUTDST16(dest,value) (*((WORD *)(dest))=(WORD)(value)); dest += 2; #define PUTDST32(dest,value) (*((DWORD *)(dest))=(DWORD)(value)); dest += 4; +#define PUTDSTPTR(dest, value) \ + *(void **)(dest) = (void *)(value); dest += sizeof(void *); char * sse_Strings[8] = { "xmm0", "xmm1", "xmm2", "xmm3", @@ -61,7 +63,7 @@ void SseMoveAlignedVariableToReg(void *Variable, char *VariableName, int sseReg) PUTDST16(RecompPos,0x280f); PUTDST8(RecompPos, x86Command); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void SseMoveAlignedN64MemToReg(int sseReg, int AddrReg) { @@ -92,7 +94,7 @@ void SseMoveAlignedN64MemToReg(int sseReg, int AddrReg) { PUTDST16(RecompPos,0x280f); PUTDST8(RecompPos, x86Command); - PUTDST32(RecompPos,RSPInfo.DMEM); + PUTDSTPTR(RecompPos, RSPInfo.DMEM); } void SseMoveAlignedRegToVariable(int sseReg, void *Variable, char *VariableName) { @@ -113,7 +115,7 @@ void SseMoveAlignedRegToVariable(int sseReg, void *Variable, char *VariableName) PUTDST16(RecompPos,0x290f); PUTDST8(RecompPos, x86Command); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void SseMoveAlignedRegToN64Mem(int sseReg, int AddrReg) { @@ -144,7 +146,7 @@ void SseMoveAlignedRegToN64Mem(int sseReg, int AddrReg) { PUTDST16(RecompPos,0x290f); PUTDST8(RecompPos, x86Command); - PUTDST32(RecompPos,RSPInfo.DMEM); + PUTDSTPTR(RecompPos, RSPInfo.DMEM); } void SseMoveUnalignedVariableToReg(void *Variable, char *VariableName, int sseReg) { @@ -165,7 +167,7 @@ void SseMoveUnalignedVariableToReg(void *Variable, char *VariableName, int sseRe PUTDST16(RecompPos,0x100f); PUTDST8(RecompPos, x86Command); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void SseMoveUnalignedN64MemToReg(int sseReg, int AddrReg) { @@ -196,7 +198,7 @@ void SseMoveUnalignedN64MemToReg(int sseReg, int AddrReg) { PUTDST16(RecompPos,0x100f); PUTDST8(RecompPos, x86Command); - PUTDST32(RecompPos,RSPInfo.DMEM); + PUTDSTPTR(RecompPos, RSPInfo.DMEM); } void SseMoveUnalignedRegToVariable(int sseReg, void *Variable, char *VariableName) { @@ -217,7 +219,7 @@ void SseMoveUnalignedRegToVariable(int sseReg, void *Variable, char *VariableNam PUTDST16(RecompPos,0x110f); PUTDST8(RecompPos, x86Command); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void SseMoveUnalignedRegToN64Mem(int sseReg, int AddrReg) { @@ -248,7 +250,7 @@ void SseMoveUnalignedRegToN64Mem(int sseReg, int AddrReg) { PUTDST16(RecompPos,0x110f); PUTDST8(RecompPos, x86Command); - PUTDST32(RecompPos,RSPInfo.DMEM); + PUTDSTPTR(RecompPos, RSPInfo.DMEM); } void SseMoveRegToReg(int Dest, int Source) { diff --git a/Source/RSP/X86.c b/Source/RSP/X86.c index 947dfb06c..fa20085fa 100644 --- a/Source/RSP/X86.c +++ b/Source/RSP/X86.c @@ -37,6 +37,8 @@ #define PUTDST8(dest,value) (*((BYTE *)(dest))=(BYTE)(value)); dest += 1; #define PUTDST16(dest,value) (*((WORD *)(dest))=(WORD)(value)); dest += 2; #define PUTDST32(dest,value) (*((DWORD *)(dest))=(DWORD)(value)); dest += 4; +#define PUTDSTPTR(dest, value) \ + *(void **)(dest) = (void *)(value); dest += sizeof(void *); char * x86_Strings[8] = { "eax", "ebx", "ecx", "edx", @@ -99,7 +101,7 @@ void AdcX86regToVariable(int x86reg, void * Variable, char * VariableName) { default: DisplayError("AddVariableToX86reg\nUnknown x86 Register"); } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void AdcX86regHalfToVariable(int x86reg, void * Variable, char * VariableName) { @@ -118,13 +120,13 @@ void AdcX86regHalfToVariable(int x86reg, void * Variable, char * VariableName) { default: DisplayError("AdcX86regHalfToVariable\nUnknown x86 Register"); } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void AdcConstToVariable(void *Variable, char *VariableName, BYTE Constant) { CPU_Message(" adc dword ptr [%s], %Xh", VariableName, Constant); PUTDST16(RecompPos,0x1583); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); PUTDST8(RecompPos,Constant); } @@ -148,7 +150,7 @@ void AdcConstToX86reg( BYTE Constant, int x86reg ) { void AddConstToVariable (DWORD Const, void *Variable, char *VariableName) { CPU_Message(" add dword ptr [%s], 0x%X",VariableName, Const); PUTDST16(RecompPos,0x0581); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); PUTDST32(RecompPos,Const); } @@ -194,7 +196,7 @@ void AdcConstHalfToVariable(void *Variable, char *VariableName, BYTE Constant) { PUTDST8(RecompPos,0x83); PUTDST8(RecompPos,0x15); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); PUTDST8(RecompPos,Constant); } @@ -213,7 +215,7 @@ void AddVariableToX86reg(int x86reg, void * Variable, char * VariableName) { default: DisplayError("AddVariableToX86reg\nUnknown x86 Register"); } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void AddX86regToVariable(int x86reg, void * Variable, char * VariableName) { @@ -230,7 +232,7 @@ void AddX86regToVariable(int x86reg, void * Variable, char * VariableName) { default: DisplayError("AddVariableToX86reg\nUnknown x86 Register"); } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void AddX86regHalfToVariable(int x86reg, void * Variable, char * VariableName) { @@ -250,7 +252,7 @@ void AddX86regHalfToVariable(int x86reg, void * Variable, char * VariableName) { default: DisplayError("AddVariableToX86reg\nUnknown x86 Register"); } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void AddX86RegToX86Reg(int Destination, int Source) { @@ -283,7 +285,7 @@ void AddX86RegToX86Reg(int Destination, int Source) { void AndConstToVariable (DWORD Const, void *Variable, char *VariableName) { CPU_Message(" and dword ptr [%s], 0x%X",VariableName, Const); PUTDST16(RecompPos,0x2581); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); PUTDST32(RecompPos,Const); } @@ -328,7 +330,7 @@ void AndVariableToX86Reg(void * Variable, char * VariableName, int x86Reg) { case x86_ESP: PUTDST16(RecompPos,0x2523); break; case x86_EBP: PUTDST16(RecompPos,0x2D23); break; } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void AndVariableToX86regHalf(void * Variable, char * VariableName, int x86Reg) { @@ -344,7 +346,7 @@ void AndVariableToX86regHalf(void * Variable, char * VariableName, int x86Reg) { case x86_ESP: PUTDST16(RecompPos,0x2523); break; case x86_EBP: PUTDST16(RecompPos,0x2D23); break; } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void AndX86RegToVariable(void * Variable, char * VariableName, int x86Reg) { @@ -359,7 +361,7 @@ void AndX86RegToVariable(void * Variable, char * VariableName, int x86Reg) { case x86_ESP: PUTDST16(RecompPos,0x2521); break; case x86_EBP: PUTDST16(RecompPos,0x2D21); break; } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void AndX86RegToX86Reg(int Destination, int Source) { @@ -466,13 +468,13 @@ void BsrX86RegToX86Reg(int Destination, int Source) { void Call_Direct(void * FunctAddress, char * FunctName) { CPU_Message(" call offset %s",FunctName); PUTDST8(RecompPos,0xE8); - PUTDST32(RecompPos,(DWORD)FunctAddress-(DWORD)RecompPos - 4); + PUTDSTPTR(RecompPos, (size_t)FunctAddress - (size_t)RecompPos - sizeof(void *)); } void Call_Indirect(void * FunctAddress, char * FunctName) { CPU_Message(" call [%s]",FunctName); PUTDST16(RecompPos,0x15FF); - PUTDST32(RecompPos,FunctAddress); + PUTDSTPTR(RecompPos, FunctAddress); } void CondMoveEqual(int Destination, int Source) { @@ -730,7 +732,7 @@ void CondMoveLessEqual(int Destination, int Source) { void CompConstToVariable(DWORD Const, void * Variable, char * VariableName) { CPU_Message(" cmp dword ptr [%s], 0x%X",VariableName, Const); PUTDST16(RecompPos,0x3D81); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); PUTDST32(RecompPos,Const); } @@ -740,7 +742,7 @@ void CompConstHalfToVariable(WORD Const, void * Variable, char * VariableName) { PUTDST8(RecompPos,0x81); PUTDST8(RecompPos,0x3D); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); PUTDST16(RecompPos,Const); } @@ -789,7 +791,7 @@ void CompX86regToVariable(int x86Reg, void * Variable, char * VariableName) { default: DisplayError("Unknown x86 Register"); } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void CompVariableToX86reg(int x86Reg, void * Variable, char * VariableName) { @@ -806,7 +808,7 @@ void CompVariableToX86reg(int x86Reg, void * Variable, char * VariableName) { default: DisplayError("Unknown x86 Register"); } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void CompX86RegToX86Reg(int Destination, int Source) { @@ -1149,7 +1151,7 @@ void LeaSourceAndOffset(int x86DestReg, int x86SourceReg, size_t offset) { void MoveConstByteToVariable (BYTE Const,void *Variable, char *VariableName) { CPU_Message(" mov byte ptr [%s], %Xh",VariableName,Const); PUTDST16(RecompPos,0x05C6); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); PUTDST8(RecompPos,Const); } @@ -1157,14 +1159,14 @@ void MoveConstHalfToVariable (WORD Const,void *Variable, char *VariableName) { CPU_Message(" mov word ptr [%s], %Xh",VariableName,Const); PUTDST8(RecompPos,0x66); PUTDST16(RecompPos,0x05C7); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); PUTDST16(RecompPos,Const); } void MoveConstToVariable (DWORD Const,void *Variable, char *VariableName) { CPU_Message(" mov dword ptr [%s], %Xh",VariableName,Const); PUTDST16(RecompPos,0x05C7); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); PUTDST32(RecompPos,Const); } @@ -1481,7 +1483,7 @@ void MoveN64MemDispToX86reg(int x86reg, int AddrReg, BYTE Disp) { case x86_EBP: x86Command += 0xA800; break; } PUTDST16(RecompPos,x86Command); - PUTDST32(RecompPos,RSPInfo.DMEM + Disp); + PUTDSTPTR(RecompPos, RSPInfo.DMEM + Disp); } void MoveN64MemToX86reg(int x86reg, int AddrReg) { @@ -1510,7 +1512,7 @@ void MoveN64MemToX86reg(int x86reg, int AddrReg) { case x86_EBP: x86Command += 0xA800; break; } PUTDST16(RecompPos,x86Command); - PUTDST32(RecompPos,RSPInfo.DMEM); + PUTDSTPTR(RecompPos, RSPInfo.DMEM); } void MoveN64MemToX86regByte(int x86reg, int AddrReg) { @@ -1537,7 +1539,7 @@ void MoveN64MemToX86regByte(int x86reg, int AddrReg) { break; } PUTDST16(RecompPos,x86Command); - PUTDST32(RecompPos,RSPInfo.DMEM); + PUTDSTPTR(RecompPos, RSPInfo.DMEM); } void MoveN64MemToX86regHalf(int x86reg, int AddrReg) { @@ -1567,7 +1569,7 @@ void MoveN64MemToX86regHalf(int x86reg, int AddrReg) { case x86_EBP: x86Command += 0xA800; break; } PUTDST16(RecompPos,x86Command); - PUTDST32(RecompPos,RSPInfo.DMEM); + PUTDSTPTR(RecompPos, RSPInfo.DMEM); } void MoveX86regByteToN64Mem(int x86reg, int AddrReg) { @@ -1590,7 +1592,7 @@ void MoveX86regByteToN64Mem(int x86reg, int AddrReg) { case x86_EDX: x86Command += 0x9000; break; } PUTDST16(RecompPos,x86Command); - PUTDST32(RecompPos,RSPInfo.DMEM); + PUTDSTPTR(RecompPos, RSPInfo.DMEM); } void MoveX86regHalfToN64Mem(int x86reg, int AddrReg) { @@ -1619,7 +1621,7 @@ void MoveX86regHalfToN64Mem(int x86reg, int AddrReg) { case x86_EBP: x86Command += 0xA800; break; } PUTDST16(RecompPos,x86Command); - PUTDST32(RecompPos,RSPInfo.DMEM); + PUTDSTPTR(RecompPos, RSPInfo.DMEM); } void MoveX86regToN64Mem(int x86reg, int AddrReg) { @@ -1647,7 +1649,7 @@ void MoveX86regToN64Mem(int x86reg, int AddrReg) { case x86_EBP: x86Command += 0xA800; break; } PUTDST16(RecompPos,x86Command); - PUTDST32(RecompPos,RSPInfo.DMEM); + PUTDSTPTR(RecompPos, RSPInfo.DMEM); } void MoveX86regToN64MemDisp(int x86reg, int AddrReg, BYTE Disp) { @@ -1675,7 +1677,7 @@ void MoveX86regToN64MemDisp(int x86reg, int AddrReg, BYTE Disp) { case x86_EBP: x86Command += 0xA800; break; } PUTDST16(RecompPos,x86Command); - PUTDST32(RecompPos,RSPInfo.DMEM+Disp); + PUTDSTPTR(RecompPos, RSPInfo.DMEM + Disp); } void MoveVariableToX86reg(void *Variable, char *VariableName, int x86reg) { @@ -1691,7 +1693,7 @@ void MoveVariableToX86reg(void *Variable, char *VariableName, int x86reg) { case x86_EBP: PUTDST16(RecompPos,0x2D8B); break; default: DisplayError("MoveVariableToX86reg\nUnknown x86 Register"); } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void MoveVariableToX86regByte(void *Variable, char *VariableName, int x86reg) { @@ -1703,7 +1705,7 @@ void MoveVariableToX86regByte(void *Variable, char *VariableName, int x86reg) { case x86_EDX: PUTDST16(RecompPos,0x158A); break; default: DisplayError("MoveVariableToX86regByte\nUnknown x86 Register"); } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void MoveVariableToX86regHalf(void *Variable, char *VariableName, int x86reg) { @@ -1720,7 +1722,7 @@ void MoveVariableToX86regHalf(void *Variable, char *VariableName, int x86reg) { case x86_EBP: PUTDST16(RecompPos,0x2D8B); break; default: DisplayError("MoveVariableToX86reg\nUnknown x86 Register"); } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void MoveX86regByteToVariable(int x86reg, void * Variable, char * VariableName) { @@ -1733,7 +1735,7 @@ void MoveX86regByteToVariable(int x86reg, void * Variable, char * VariableName) default: DisplayError("MoveX86regByteToVariable\nUnknown x86 Register"); } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void MoveX86regHalfToVariable(int x86reg, void * Variable, char * VariableName) { @@ -1751,7 +1753,7 @@ void MoveX86regHalfToVariable(int x86reg, void * Variable, char * VariableName) default: DisplayError("MoveX86regHalfToVariable\nUnknown x86 Register"); } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void MoveX86regToVariable(int x86reg, void * Variable, char * VariableName) { @@ -1768,7 +1770,7 @@ void MoveX86regToVariable(int x86reg, void * Variable, char * VariableName) { default: DisplayError("MoveX86regToVariable\nUnknown x86 Register"); } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void MoveX86RegToX86Reg(int Source, int Destination) { @@ -1877,7 +1879,7 @@ void MoveSxVariableToX86regByte(void *Variable, char *VariableName, int x86reg) case x86_EBP: PUTDST8(RecompPos,0x2D); break; default: DisplayError("MoveSxVariableToX86regByte\nUnknown x86 Register"); } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void MoveSxVariableToX86regHalf(void *Variable, char *VariableName, int x86reg) { @@ -1896,7 +1898,7 @@ void MoveSxVariableToX86regHalf(void *Variable, char *VariableName, int x86reg) case x86_EBP: PUTDST8(RecompPos,0x2D); break; default: DisplayError("MoveSxVariableToX86regHalf\nUnknown x86 Register"); } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void MoveSxN64MemToX86regByte(int x86reg, int AddrReg) { @@ -1924,7 +1926,7 @@ void MoveSxN64MemToX86regByte(int x86reg, int AddrReg) { } PUTDST8(RecompPos,0x0f); PUTDST16(RecompPos,x86Command); - PUTDST32(RecompPos,RSPInfo.DMEM); + PUTDSTPTR(RecompPos, RSPInfo.DMEM); } void MoveSxN64MemToX86regHalf(int x86reg, int AddrReg) { @@ -1955,7 +1957,7 @@ void MoveSxN64MemToX86regHalf(int x86reg, int AddrReg) { PUTDST8(RecompPos, 0x0f); PUTDST16(RecompPos,x86Command); - PUTDST32(RecompPos,RSPInfo.DMEM); + PUTDSTPTR(RecompPos, RSPInfo.DMEM); } void MoveZxX86RegHalfToX86Reg(int Source, int Destination) { @@ -2035,7 +2037,7 @@ void MoveZxVariableToX86regByte(void *Variable, char *VariableName, int x86reg) case x86_EBP: PUTDST8(RecompPos,0x2D); break; default: DisplayError("MoveZxVariableToX86regByte\nUnknown x86 Register"); } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void MoveZxVariableToX86regHalf(void *Variable, char *VariableName, int x86reg) { @@ -2054,7 +2056,7 @@ void MoveZxVariableToX86regHalf(void *Variable, char *VariableName, int x86reg) case x86_EBP: PUTDST8(RecompPos,0x2D); break; default: DisplayError("MoveZxVariableToX86regHalf\nUnknown x86 Register"); } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void MoveZxN64MemToX86regByte(int x86reg, int AddrReg) { @@ -2082,7 +2084,7 @@ void MoveZxN64MemToX86regByte(int x86reg, int AddrReg) { } PUTDST8(RecompPos,0x0f); PUTDST16(RecompPos,x86Command); - PUTDST32(RecompPos,RSPInfo.DMEM); + PUTDSTPTR(RecompPos, RSPInfo.DMEM); } void MoveZxN64MemToX86regHalf(int x86reg, int AddrReg) { @@ -2113,7 +2115,7 @@ void MoveZxN64MemToX86regHalf(int x86reg, int AddrReg) { PUTDST8(RecompPos, 0x0f); PUTDST16(RecompPos,x86Command); - PUTDST32(RecompPos,RSPInfo.DMEM); + PUTDSTPTR(RecompPos, RSPInfo.DMEM); } void MulX86reg(int x86reg) { @@ -2167,7 +2169,7 @@ void NotX86reg(int x86reg) { void OrConstToVariable(DWORD Const, void * Variable, char * VariableName) { CPU_Message(" or dword ptr [%s], 0x%X",VariableName, Const); PUTDST16(RecompPos,0x0D81); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); PUTDST32(RecompPos,Const); } @@ -2212,7 +2214,7 @@ void OrVariableToX86Reg(void * Variable, char * VariableName, int x86Reg) { case x86_ESP: PUTDST16(RecompPos,0x250B); break; case x86_EBP: PUTDST16(RecompPos,0x2D0B); break; } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void OrVariableToX86regHalf(void * Variable, char * VariableName, int x86Reg) { @@ -2228,7 +2230,7 @@ void OrVariableToX86regHalf(void * Variable, char * VariableName, int x86Reg) { case x86_ESP: PUTDST16(RecompPos,0x250B); break; case x86_EBP: PUTDST16(RecompPos,0x2D0B); break; } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void OrX86RegToVariable(void * Variable, char * VariableName, int x86Reg) { @@ -2243,7 +2245,7 @@ void OrX86RegToVariable(void * Variable, char * VariableName, int x86Reg) { case x86_ESP: PUTDST16(RecompPos,0x2509); break; case x86_EBP: PUTDST16(RecompPos,0x2D09); break; } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void OrX86RegToX86Reg(int Destination, int Source) { @@ -2341,14 +2343,14 @@ void SetlVariable(void * Variable, char * VariableName) { CPU_Message(" setl byte ptr [%s]",VariableName); PUTDST16(RecompPos,0x9C0F); PUTDST8(RecompPos,0x05); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void SetleVariable(void * Variable, char * VariableName) { CPU_Message(" setle byte ptr [%s]",VariableName); PUTDST16(RecompPos,0x9E0F); PUTDST8(RecompPos,0x05); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void Setb(int x86reg) { @@ -2368,7 +2370,7 @@ void SetbVariable(void * Variable, char * VariableName) { CPU_Message(" setb byte ptr [%s]",VariableName); PUTDST16(RecompPos,0x920F); PUTDST8(RecompPos,0x05); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void Setg(int x86reg) { @@ -2388,14 +2390,14 @@ void SetgVariable(void * Variable, char * VariableName) { CPU_Message(" setg byte ptr [%s]",VariableName); PUTDST16(RecompPos,0x9F0F); PUTDST8(RecompPos,0x05); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void SetgeVariable(void * Variable, char * VariableName) { CPU_Message(" setge byte ptr [%s]",VariableName); PUTDST16(RecompPos,0x9D0F); PUTDST8(RecompPos,0x05); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void Seta(int x86reg) { @@ -2415,7 +2417,7 @@ void SetaVariable(void * Variable, char * VariableName) { CPU_Message(" seta byte ptr [%s]",VariableName); PUTDST16(RecompPos,0x970F); PUTDST8(RecompPos,0x05); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void Setae(int x86reg) { @@ -2448,7 +2450,7 @@ void SetzVariable(void * Variable, char * VariableName) { CPU_Message(" setz byte ptr [%s]",VariableName); PUTDST16(RecompPos,0x940F); PUTDST8(RecompPos,0x05); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void Setnz(int x86reg) { @@ -2468,7 +2470,7 @@ void SetnzVariable(void * Variable, char * VariableName) { CPU_Message(" setnz byte ptr [%s]",VariableName); PUTDST16(RecompPos,0x950F); PUTDST8(RecompPos,0x05); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void ShiftLeftDoubleImmed(int Destination, int Source, BYTE Immediate) { @@ -2568,7 +2570,7 @@ void ShiftLeftSignVariableImmed(void *Variable, char *VariableName, BYTE Immedia CPU_Message(" shl dword ptr [%s], %Xh",VariableName, Immediate); PUTDST16(RecompPos,0x25C1) - PUTDST32(RecompPos, Variable); + PUTDSTPTR(RecompPos, Variable); PUTDST8(RecompPos,Immediate); } @@ -2593,7 +2595,7 @@ void ShiftRightSignVariableImmed(void *Variable, char *VariableName, BYTE Immedi CPU_Message(" sar dword ptr [%s], %Xh",VariableName, Immediate); PUTDST16(RecompPos,0x3DC1) - PUTDST32(RecompPos, Variable); + PUTDSTPTR(RecompPos, Variable); PUTDST8(RecompPos,Immediate); } @@ -2630,14 +2632,14 @@ void ShiftRightUnsignVariableImmed(void *Variable, char *VariableName, BYTE Imme CPU_Message(" shr dword ptr [%s], %Xh",VariableName, Immediate); PUTDST16(RecompPos,0x2DC1) - PUTDST32(RecompPos, Variable); + PUTDSTPTR(RecompPos, Variable); PUTDST8(RecompPos,Immediate); } void SubConstFromVariable (DWORD Const, void *Variable, char *VariableName) { CPU_Message(" sub dword ptr [%s], 0x%X",VariableName, Const);\ PUTDST16(RecompPos,0x2D81); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); PUTDST32(RecompPos,Const); } @@ -2684,7 +2686,7 @@ void SubVariableFromX86reg(int x86reg, void * Variable, char * VariableName) { default: DisplayError("SubVariableFromX86reg\nUnknown x86 Register"); } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void SubX86regFromVariable(int x86reg, void * Variable, char * VariableName) { @@ -2701,7 +2703,7 @@ void SubX86regFromVariable(int x86reg, void * Variable, char * VariableName) { default: DisplayError("SubX86regFromVariable\nUnknown x86 Register"); } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void SubX86RegToX86Reg(int Destination, int Source) { @@ -2759,7 +2761,7 @@ void SbbX86RegToX86Reg(int Destination, int Source) { void TestConstToVariable(DWORD Const, void * Variable, char * VariableName) { CPU_Message(" test dword ptr [%s], 0x%X",VariableName, Const); PUTDST16(RecompPos,0x05F7); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); PUTDST32(RecompPos,Const); } @@ -2840,7 +2842,7 @@ void XorConstToVariable(void *Variable, char *VariableName, DWORD Const) { CPU_Message(" xor dword ptr [%s], 0x%X",VariableName, Const); PUTDST16(RecompPos, 0x3581); - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); PUTDST32(RecompPos, Const); } @@ -2885,7 +2887,7 @@ void XorVariableToX86reg(void *Variable, char *VariableName, int x86reg) { case x86_EBP: PUTDST16(RecompPos,0x2D33); break; default: DisplayError("XorVariableToX86reg\nUnknown x86 Register"); } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } void XorX86RegToVariable(void *Variable, char *VariableName, int x86reg) { @@ -2901,5 +2903,5 @@ void XorX86RegToVariable(void *Variable, char *VariableName, int x86reg) { case x86_EBP: PUTDST16(RecompPos,0x2D31); break; default: DisplayError("XorX86RegToVariable\nUnknown x86 Register"); } - PUTDST32(RecompPos,Variable); + PUTDSTPTR(RecompPos, Variable); } From a53526163be770f78105fc218e0e17c4ff0b7c6d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Oct 2015 16:08:18 -0400 Subject: [PATCH 041/213] fixed a couple remaining 64-bit pointer truncations --- Source/RSP/Recompiler CPU.c | 12 ++++++++---- Source/RSP/X86.c | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Source/RSP/Recompiler CPU.c b/Source/RSP/Recompiler CPU.c index 15cc590b3..f805bd383 100644 --- a/Source/RSP/Recompiler CPU.c +++ b/Source/RSP/Recompiler CPU.c @@ -754,9 +754,10 @@ void CompilerLinkBlocks(void) { x86_SetBranch32b(RecompPos - 4, KnownCode); } -void CompilerRSPBlock ( void ) { - DWORD Count, Padding, X86BaseAddress = (DWORD)RecompPos; +void CompilerRSPBlock(void) +{ BYTE * IMEM_SAVE = (BYTE *)malloc(0x1000); + const size_t X86BaseAddress = (size_t)RecompPos; NextInstruction = NORMAL; CompilePC = *PrgCount; @@ -766,8 +767,11 @@ void CompilerRSPBlock ( void ) { CurrentBlock.CurrPC = CompilePC; /* Align the block to a boundary */ - if (X86BaseAddress & 7) { - Padding = (8 - (X86BaseAddress & 7)) & 7; + if (X86BaseAddress & 7) + { + register size_t Count; + const size_t Padding = (8 - (X86BaseAddress & 7)) & 7; + for (Count = 0; Count < Padding; Count++) { CPU_Message("%08X: nop", RecompPos); *(RecompPos++) = 0x90; diff --git a/Source/RSP/X86.c b/Source/RSP/X86.c index fa20085fa..3fc44a965 100644 --- a/Source/RSP/X86.c +++ b/Source/RSP/X86.c @@ -427,7 +427,11 @@ void BreakPointNotification (const char * const FileName, const int LineNumber) void X86BreakPoint (LPCSTR FileName, int LineNumber) { Pushad(); PushImm32("LineNumber",LineNumber); +#if defined(_M_IX86) PushImm32("FileName",(DWORD)FileName); +#else + DisplayError("PushImm64\nUnimplemented."); +#endif Call_Direct(BreakPointNotification,"BreakPointNotification"); AddConstToX86Reg(x86_ESP, 8); Popad(); From b27532484319cad0b12c037d69adf8380218212e Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Sat, 31 Oct 2015 06:28:49 +0900 Subject: [PATCH 042/213] Update Dma.cpp fix typo --- Source/Project64/N64 System/Mips/Dma.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Project64/N64 System/Mips/Dma.cpp b/Source/Project64/N64 System/Mips/Dma.cpp index d1a4e71af..478e31b78 100644 --- a/Source/Project64/N64 System/Mips/Dma.cpp +++ b/Source/Project64/N64 System/Mips/Dma.cpp @@ -142,7 +142,7 @@ void CDMA::PI_DMA_READ() } if (bHaveDebugger()) { - g_Notify->DisplayError(stdstr_f("PI_DMA_READ where are you dmaing to ? : %08X", g_Reg->PI_CART_ADDR_REG).ToUTF16().c_str()); + g_Notify->DisplayError(stdstr_f("PI_DMA_READ where are you dmaing to ? : %08X", g_Reg->PI_CART_ADDR_REG).ToUTF16().c_str()); } g_Reg->PI_STATUS_REG &= ~PI_STATUS_DMA_BUSY; g_Reg->MI_INTR_REG |= MI_INTR_PI; From d08baf90cf01619c5b78f1c29675c1648920de0b Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 1 Nov 2015 21:51:06 -0500 Subject: [PATCH 043/213] Filter compiled sources and build files from Git view. --- .gitignore | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index 72a128650..77fdc2e0b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,14 @@ *.sdf *.suo *.user + +# compiler-generated sources (MSVC, GCC) +*.asm +*.s + +# assembled linker objects (GCC) +*.o + Thumbs.db /Bin/Debug /Bin/Debug64 From 407128d2d46df5ef8e88296c6307133c16469e49 Mon Sep 17 00:00:00 2001 From: "Julio C. Rocha" Date: Tue, 3 Nov 2015 12:29:13 -0800 Subject: [PATCH 044/213] Set target machine for Static Library projects. --- PropertySheets/Platform.props | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/PropertySheets/Platform.props b/PropertySheets/Platform.props index d7b451c62..3487ef34c 100644 --- a/PropertySheets/Platform.props +++ b/PropertySheets/Platform.props @@ -195,6 +195,9 @@ + + MachineX86 + MachineX86 @@ -212,6 +215,9 @@ + + MachineX64 + MachineX64 From 4b725105d2c024e1c5c0fa0a8f30d0214981c1b0 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:21:50 +0900 Subject: [PATCH 045/213] Update Settings Page - Game Browser.cpp Fixed text when remove fields --- .../Settings/Settings Page - Game Browser.cpp | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/Source/Project64/User Interface/Settings/Settings Page - Game Browser.cpp b/Source/Project64/User Interface/Settings/Settings Page - Game Browser.cpp index 6a9171810..23a90d853 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game Browser.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Game Browser.cpp @@ -123,29 +123,28 @@ void COptionsGameBrowserPage::AddFieldClicked ( UINT /*Code*/, int /*id*/, HWND void COptionsGameBrowserPage::RemoveFieldClicked ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) { - int index = SendMessage(GetDlgItem(IDC_USING),LB_GETCURSEL,0,0); - if (index < 0) - { - return; + int index = m_Using.GetCurSel(); + if (index < 0) + { + return; } - //remove from list - int i = SendMessage(GetDlgItem(IDC_USING),LB_GETITEMDATA,index,0); - SendDlgItemMessage(IDC_USING,LB_DELETESTRING,index,0); + int i = m_Using.GetItemData(index); + m_Using.DeleteString(index); //select next in list - int listCount = SendDlgItemMessage(IDC_USING,LB_GETCOUNT,0,0); - if (index >= listCount) { index -= 1;} - SendDlgItemMessage(IDC_USING,LB_SETCURSEL,index,0); + int listCount = m_Using.GetCount(); + if (index >= listCount) { index -= 1; } + m_Using.SetCurSel(index); //Add to list - index = SendDlgItemMessage(IDC_AVALIABLE,LB_ADDSTRING,0,(LPARAM)GS(m_Fields[i].LangID())); - SendDlgItemMessage(IDC_AVALIABLE,LB_SETITEMDATA,index,i); - SendDlgItemMessage(IDC_AVALIABLE,LB_SETCURSEL,index,0); + index = m_Avaliable.AddStringW(GS(m_Fields[i].LangID())); + m_Avaliable.SetItemData(index, i); + m_Avaliable.SetCurSel(index); m_OrderChanged = true; m_OrderReset = false; - SendMessage(GetParent(),PSM_CHANGED ,(WPARAM)m_hWnd,0); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } void COptionsGameBrowserPage::MoveFieldUpClicked ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) From 5530c7d97c85911492b4c5b1e57cbbf8ab37cfc5 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:30:00 +0900 Subject: [PATCH 046/213] Update English_alternative.pj.Lang --- Lang/English_alternative.pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/English_alternative.pj.Lang b/Lang/English_alternative.pj.Lang index 00f916e40..c9d7d8cf8 100644 --- a/Lang/English_alternative.pj.Lang +++ b/Lang/English_alternative.pj.Lang @@ -277,7 +277,7 @@ no RDB is present, or 'overwrite' option below is unchecked" #620# "* detect first-used type" #621# "4-kbit EEPROM" #622# "16-kbit EEPROM" -#623# "32-kbyte SRAM" +#623# "SRAM" #624# "128-kbyte flash RAM" //Shell Intergration Tab From 4d4911e28d5fc4f25276e6338ea2301925e028fa Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:30:56 +0900 Subject: [PATCH 047/213] Update Japanese.pj.Lang --- Lang/Japanese.pj.Lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lang/Japanese.pj.Lang b/Lang/Japanese.pj.Lang index 779b3c9b8..3358098e9 100644 --- a/Lang/Japanese.pj.Lang +++ b/Lang/Japanese.pj.Lang @@ -5,7 +5,7 @@ #1 # "Japanese" // LANGUAGE ID #2 # "Nekokabu" // Author #3 # "2.2" // Version -#4 # "2015/3/5" // Date +#4 # "2015/11/6" // Date //About DLL Dialog #5 # "現在の言語" @@ -317,7 +317,7 @@ #620# "自動検出" #621# "4-kbit EEPROM" #622# "16-kbit EEPROM" -#623# "32-kbyte SRAM" +#623# "SRAM" #624# "Flash RAM" //Shell Integration Tab From 2aa783662589ebbf1dfa3c4ea4007db9bb8329dd Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:31:29 +0900 Subject: [PATCH 048/213] Update Brazilian Portuguese.pj.Lang --- Lang/Brazilian Portuguese.pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/Brazilian Portuguese.pj.Lang b/Lang/Brazilian Portuguese.pj.Lang index c92e66dd9..45b18603f 100644 --- a/Lang/Brazilian Portuguese.pj.Lang +++ b/Lang/Brazilian Portuguese.pj.Lang @@ -318,7 +318,7 @@ #620# "Usar o Primeiro Tipo de Salvamento Usado" #621# "4-kbit EEPROM" #622# "16-kbit EEPROM" -#623# "32-kbyte SRAM" +#623# "SRAM" #624# "Flash RAM" //Shell Integration Tab From a30faf07a80623c5b3ee5e58fe928fb6ee8e4ff9 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:31:42 +0900 Subject: [PATCH 049/213] Update Bulgarian.pj.Lang --- Lang/Bulgarian.pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/Bulgarian.pj.Lang b/Lang/Bulgarian.pj.Lang index ca053d826..dc93495e8 100644 --- a/Lang/Bulgarian.pj.Lang +++ b/Lang/Bulgarian.pj.Lang @@ -266,7 +266,7 @@ #620# "* открий първият използван тип" #621# "4-kbit EEPROM" #622# "16-kbit EEPROM" -#623# "32-kbyte SRAM" +#623# "SRAM" #624# "128-kbyte flash RAM" //Shell Intergration Tab From c8ef9cc36283f4fbd016908294ab973bb714c2c4 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:32:03 +0900 Subject: [PATCH 050/213] Update Catalan.pj.Lang --- Lang/Catalan.pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/Catalan.pj.Lang b/Lang/Catalan.pj.Lang index 4be6344af..8b32cdbc6 100644 --- a/Lang/Catalan.pj.Lang +++ b/Lang/Catalan.pj.Lang @@ -318,7 +318,7 @@ #620# "Primer tipus de desat usat" #621# "EEPROM de 4 kbits" #622# "EEPROM de 16 kbits" -#623# "SRAM de 32kbytes" +#623# "SRAM" #624# "FlashRAM de 128kbytes" //Shell Integration Tab From 7732dcae2814e3a6bf9ee65f2c5ac8b0454d4dd7 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:32:17 +0900 Subject: [PATCH 051/213] Update Chinese (Simplified).pj.Lang --- Lang/Chinese (Simplified).pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/Chinese (Simplified).pj.Lang b/Lang/Chinese (Simplified).pj.Lang index 38271ce56..3ac06bd97 100644 --- a/Lang/Chinese (Simplified).pj.Lang +++ b/Lang/Chinese (Simplified).pj.Lang @@ -318,7 +318,7 @@ #620# "使用最初的存档类型" #621# "4-kbit EEPROM" #622# "16-kbit EEPROM" -#623# "32-kbyte SRAM" +#623# "SRAM" #624# "Flash RAM" //Shell Integration Tab From 508b1b7c7be8e34711767658c4b11551fb03d7a5 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:32:31 +0900 Subject: [PATCH 052/213] Update Chinese (Traditional).pj.Lang --- Lang/Chinese (Traditional).pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/Chinese (Traditional).pj.Lang b/Lang/Chinese (Traditional).pj.Lang index 2ce4c7b0e..85edac4a8 100644 --- a/Lang/Chinese (Traditional).pj.Lang +++ b/Lang/Chinese (Traditional).pj.Lang @@ -270,7 +270,7 @@ #620# "使用最初使用的存檔類型" #621# "4-Kbit EEPROM" #622# "16-Kbit EEPROM" -#623# "32-KByte SRAM" +#623# "SRAM" #624# "Flash RAM" //Shell Integration Tab From 60cbd679ee54bc57034b398b65454090121557b6 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:32:44 +0900 Subject: [PATCH 053/213] Update Czech.pj.Lang --- Lang/Czech.pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/Czech.pj.Lang b/Lang/Czech.pj.Lang index f43ab53e2..61757ad8e 100644 --- a/Lang/Czech.pj.Lang +++ b/Lang/Czech.pj.Lang @@ -266,7 +266,7 @@ RDB není pøítomno nebo volba dole 'pøepsat' je nezaškrtnutá" #620# "* detek. první užívaný typ" #621# "4-kbit EEPROM" #622# "16-kbit EEPROM" -#623# "32-kbajtù SRAM" +#623# "SRAM" #624# "128-kbajtù flash RAM" //Shell Intergration Tab From 18c1807529e0926166827856fb585c878696d5b6 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:32:58 +0900 Subject: [PATCH 054/213] Update Danish.pj.Lang --- Lang/Danish.pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/Danish.pj.Lang b/Lang/Danish.pj.Lang index 89e55cb11..4fb0a0a52 100644 --- a/Lang/Danish.pj.Lang +++ b/Lang/Danish.pj.Lang @@ -265,7 +265,7 @@ #620# "* Find den først anvendte type" #621# "4kbit EEPROM" #622# "16kbit EEPROM" -#623# "32kbyte SRAM" +#623# "SRAM" #624# "128kbyte FlashRAM" //Shell Intergration Tab From 021076c7cefd94a71b9082cac093c08ece9b8493 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:33:11 +0900 Subject: [PATCH 055/213] Update Dutch.pj.Lang --- Lang/Dutch.pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/Dutch.pj.Lang b/Lang/Dutch.pj.Lang index e53d95210..70cdc9c13 100644 --- a/Lang/Dutch.pj.Lang +++ b/Lang/Dutch.pj.Lang @@ -265,7 +265,7 @@ #620# "Gebruik de eerst gebruikte save" #621# "4kbit EEPROM" #622# "16kbit EEPROM" -#623# "32kbytes SRAM" +#623# "SRAM" #624# "Flashram" //Shell Integration Tab From 911726dc0cfb455607b9535136816fb107859377 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:33:42 +0900 Subject: [PATCH 056/213] Update Finnish.pj.Lang --- Lang/Finnish.pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/Finnish.pj.Lang b/Lang/Finnish.pj.Lang index 18413dd1a..fe84bb875 100644 --- a/Lang/Finnish.pj.Lang +++ b/Lang/Finnish.pj.Lang @@ -269,7 +269,7 @@ #620# "Käytä 1. tallennustyyppiä" #621# "4-kbit EEPROM" #622# "16-kbit EEPROM" -#623# "32-kbyte SRAM" +#623# "SRAM" #624# "Flash RAM" //Shell Integration Tab From 83e0fc31c3d01e8b59d754de464b5c2766599367 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:33:54 +0900 Subject: [PATCH 057/213] Update French.pj.Lang --- Lang/French.pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/French.pj.Lang b/Lang/French.pj.Lang index 4a9ca43fb..cde442eb8 100644 --- a/Lang/French.pj.Lang +++ b/Lang/French.pj.Lang @@ -318,7 +318,7 @@ #620# "Par défaut" #621# "4 kbit EEPROM" #622# "16 kbit EEPROM" -#623# "32 ko SRAM" +#623# "SRAM" #624# "Flash RAM" //Shell Integration Tab From a3707616e08fc9ab208dab3bf64329ab79b39fb6 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:34:05 +0900 Subject: [PATCH 058/213] Update German.pj.Lang --- Lang/German.pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/German.pj.Lang b/Lang/German.pj.Lang index cad611b57..1e96872f4 100644 --- a/Lang/German.pj.Lang +++ b/Lang/German.pj.Lang @@ -269,7 +269,7 @@ #620# "Automatisch" #621# "4-kbit EEPROM" #622# "16-kbit EEPROM" -#623# "32-kbyte SRAM" +#623# "SRAM" #624# "128-kbyte flash RAM" //Shell Intergration Tab From ed0f2ddba4deb0b4c6b5d13e5ecc5e3463136a32 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:34:16 +0900 Subject: [PATCH 059/213] Update German_localised.pj.Lang --- Lang/German_localised.pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/German_localised.pj.Lang b/Lang/German_localised.pj.Lang index b43dc7865..41d9e922a 100644 --- a/Lang/German_localised.pj.Lang +++ b/Lang/German_localised.pj.Lang @@ -265,7 +265,7 @@ #620# "Automatisch" #621# "4-kbit EEPROM" #622# "16-kbit EEPROM" -#623# "32-kbyte SRAM" +#623# "SRAM" #624# "128-kbyte flash RAM" //Shell Intergration Tab From 189a3c583dee549d3f54d223a1e04475780fb490 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:34:28 +0900 Subject: [PATCH 060/213] Update Greek.pj.Lang --- Lang/Greek.pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/Greek.pj.Lang b/Lang/Greek.pj.Lang index 41e84edd2..f48338989 100644 --- a/Lang/Greek.pj.Lang +++ b/Lang/Greek.pj.Lang @@ -266,7 +266,7 @@ #620# "Αυτόματος" #621# "4-kbit EEPROM" #622# "16-kbit EEPROM" -#623# "32-kbyte SRAM" +#623# "SRAM" #624# "128-kbyte flash RAM" //Shell Integration Tab From bcb5ef862fa97a47385d5c0fb62fb26b6fe44a73 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:34:46 +0900 Subject: [PATCH 061/213] Update Hungarian.pj.Lang --- Lang/Hungarian.pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/Hungarian.pj.Lang b/Lang/Hungarian.pj.Lang index eb4c767e5..a73e4c550 100644 --- a/Lang/Hungarian.pj.Lang +++ b/Lang/Hungarian.pj.Lang @@ -269,7 +269,7 @@ #620# "Elõszöri mentés fajta használata" #621# "4-kbit EEPROM" #622# "16-kbit EEPROM" -#623# "32-kbyte SRAM" +#623# "SRAM" #624# "Flash RAM" //Shell Integration Tab From b0ceb2e95f148657cfcb51f0023260502c2a20a8 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:34:58 +0900 Subject: [PATCH 062/213] Update Italian.pj.Lang --- Lang/Italian.pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/Italian.pj.Lang b/Lang/Italian.pj.Lang index c9b1619ea..a1cad2baf 100644 --- a/Lang/Italian.pj.Lang +++ b/Lang/Italian.pj.Lang @@ -269,7 +269,7 @@ #620# "Riconosci automaticamente" #621# "4-kbit EEPROM" #622# "16-kbit EEPROM" -#623# "32-ko SRAM" +#623# "SRAM" #624# "128-ko flash RAM" //Shell Intergration Tab From 08e2a48b358ce70128cabf439508c6ae716dd6eb Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:35:09 +0900 Subject: [PATCH 063/213] Update Italian_alternative.pj.Lang --- Lang/Italian_alternative.pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/Italian_alternative.pj.Lang b/Lang/Italian_alternative.pj.Lang index f8e9acb05..3af6744cb 100644 --- a/Lang/Italian_alternative.pj.Lang +++ b/Lang/Italian_alternative.pj.Lang @@ -265,7 +265,7 @@ #620# "Riconosci il salvataggio automaticamente" #621# "4-kbit EEPROM" #622# "16-kbit EEPROM" -#623# "32-ko SRAM" +#623# "SRAM" #624# "128-ko flash RAM" //Shell Intergration Tab From 78a211ec63a1e3a380b4f827a595b48c2f601068 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:35:20 +0900 Subject: [PATCH 064/213] Update Lithuanian.pj.Lang --- Lang/Lithuanian.pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/Lithuanian.pj.Lang b/Lang/Lithuanian.pj.Lang index 942a8134a..0188fd014 100644 --- a/Lang/Lithuanian.pj.Lang +++ b/Lang/Lithuanian.pj.Lang @@ -269,7 +269,7 @@ #620# "Naudoti pirmà naudotà tipà" #621# "4-kbit EEPROM" #622# "16-kbit EEPROM" -#623# "32-kbyte SRAM" +#623# "SRAM" #624# "128-kbyte flash RAM" //Shell Intergration Tab From 62e3ab029c3ac1006e668d94e11c44046363d6fd Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:35:32 +0900 Subject: [PATCH 065/213] Update Norwegian.pj.Lang --- Lang/Norwegian.pj.Lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lang/Norwegian.pj.Lang b/Lang/Norwegian.pj.Lang index 1a6935333..c74e63fdf 100644 --- a/Lang/Norwegian.pj.Lang +++ b/Lang/Norwegian.pj.Lang @@ -271,7 +271,7 @@ De vil ta effekt når ROM'en er resatt eller en ny er startet." #620# "bruk den første brukte lagrings typen" #621# "4-kbit EEPROM" #622# "16-kbit EEPROM" -#623# "32-kbyte SRAM" +#623# "SRAM" #624# "128-kbyte flash RAM" //Shell Integration Tab @@ -430,4 +430,4 @@ Skift plugin og restart spill nå?" #2043# "Det kode navnet er allerede i bruk" #2044# "Du har nådd det maksimumme antall koder for denne ROM'en" -//The End \ No newline at end of file +//The End From 09bb45422389cd2f3152c65a0c13f4aa48bc61dc Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:35:45 +0900 Subject: [PATCH 066/213] Update Polish.pj.Lang --- Lang/Polish.pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/Polish.pj.Lang b/Lang/Polish.pj.Lang index 42906f7cb..91a27a9f5 100644 --- a/Lang/Polish.pj.Lang +++ b/Lang/Polish.pj.Lang @@ -269,7 +269,7 @@ #620# "Pierwszy u¿yty format" #621# "4-kbit EEPROM" #622# "16-kbit EEPROM" -#623# "32-kbyte SRAM" +#623# "SRAM" #624# "Flash RAM" //Shell Integration Tab From 976cd34acea834d33fe129dd372c1ceae67d2316 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:35:56 +0900 Subject: [PATCH 067/213] Update Russian.pj.Lang --- Lang/Russian.pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/Russian.pj.Lang b/Lang/Russian.pj.Lang index fc77e81a5..9bd8d491d 100644 --- a/Lang/Russian.pj.Lang +++ b/Lang/Russian.pj.Lang @@ -267,7 +267,7 @@ #620# "По умолчанию" #621# "4-kbit EEPROM" #622# "16-kbit EEPROM" -#623# "32-kbyte SRAM" +#623# "SRAM" #624# "128-kbyte flash RAM" //Shell Integration Tab From e9d7395701c938b79c359d6003e8499164a0a703 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:36:07 +0900 Subject: [PATCH 068/213] Update Spanish.pj.Lang --- Lang/Spanish.pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/Spanish.pj.Lang b/Lang/Spanish.pj.Lang index e82095789..3d1013f96 100644 --- a/Lang/Spanish.pj.Lang +++ b/Lang/Spanish.pj.Lang @@ -318,7 +318,7 @@ #620# "Usar primer tipo de guardado usado" #621# "4-kbit EEPROM" #622# "16-kbit EEPROM" -#623# "32-kbyte SRAM" +#623# "SRAM" #624# "Flash RAM" //Shell Integration Tab From cef8adfa9476764b723dcece926a34cd3c0769c1 Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:36:18 +0900 Subject: [PATCH 069/213] Update Swedish.pj.Lang --- Lang/Swedish.pj.Lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lang/Swedish.pj.Lang b/Lang/Swedish.pj.Lang index 6f0f8ab7e..620862644 100644 --- a/Lang/Swedish.pj.Lang +++ b/Lang/Swedish.pj.Lang @@ -269,7 +269,7 @@ #620# "Använd Första sparnings typ" #621# "4-kbit EEPROM" #622# "16-kbit EEPROM" -#623# "32-kbytes SRAM" +#623# "SRAM" #624# "Flash RAM" //Shell Integration Tab @@ -422,5 +422,5 @@ Byta plugin och starta om nu?" #2040# "Kan inte öppna filen på grund av att grafik pluginen inte är helt OK" #2041# "Är du säker på att du vill ta bort det?" #2042# "Borttagna fusk" -#2043# "Fuskets namn används redan" +#2043# "Fuskets namn används redan" #2044# "Du har nåt max antalet av fusk för detta spelet" From e10368d8f4cf9c61d8a572b09bcc23366039bc4c Mon Sep 17 00:00:00 2001 From: Nekokabu Date: Fri, 6 Nov 2015 01:36:29 +0900 Subject: [PATCH 070/213] Update Ukrainian.pj.Lang --- Lang/Ukrainian.pj.Lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lang/Ukrainian.pj.Lang b/Lang/Ukrainian.pj.Lang index 1f1651af7..aea9cd443 100644 --- a/Lang/Ukrainian.pj.Lang +++ b/Lang/Ukrainian.pj.Lang @@ -267,7 +267,7 @@ #620# "Обирає програма" #621# "4-kbit EEPROM" #622# "16-kbit EEPROM" -#623# "32-kbyte SRAM" +#623# "SRAM" #624# "128-kbyte flash RAM" //Shell Integration Tab From a3172b30ab0f489d2a57ee2458d8ceeafc0d4366 Mon Sep 17 00:00:00 2001 From: zilmar Date: Fri, 6 Nov 2015 22:37:21 +1100 Subject: [PATCH 071/213] [Common Code] Clean up some of the code --- Source/Common/File Class.cpp | 7 +- Source/Common/File Class.h | 6 +- Source/Common/Log Class.cpp | 37 +++---- Source/Common/Log Class.h | 28 +++--- Source/Common/Trace.cpp | 131 +++++++++++++----------- Source/Common/Trace.h | 20 ++-- Source/Common/md5.h | 186 +++++++++++++++++------------------ 7 files changed, 209 insertions(+), 206 deletions(-) diff --git a/Source/Common/File Class.cpp b/Source/Common/File Class.cpp index c5035fb97..2e7a25d69 100644 --- a/Source/Common/File Class.cpp +++ b/Source/Common/File Class.cpp @@ -91,8 +91,7 @@ bool CFile::Open(const char * lpszFileName, uint32_t nOpenFlags) dwCreateFlag = OPEN_EXISTING; // attempt file creation - HANDLE hFile = ::CreateFile(lpszFileName, dwAccess, dwShareMode, &sa, - dwCreateFlag, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile = ::CreateFile(lpszFileName, dwAccess, dwShareMode, &sa, dwCreateFlag, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { //#define ERROR_PATH_NOT_FOUND 3L //ULONG err = GetLastError(); @@ -169,12 +168,12 @@ uint32_t CFile::Read(void* lpBuf, uint32_t nCount) return 0; // avoid Win32 "null-read" } - ULONG dwRead = 0; + DWORD dwRead = 0; if (!::ReadFile(m_hFile, lpBuf, nCount, &dwRead, NULL)) { return 0; } - return (UINT)dwRead; + return (uint32_t)dwRead; } long CFile::Seek(long lOff, SeekPosition nFrom) diff --git a/Source/Common/File Class.h b/Source/Common/File Class.h index a491febaf..fc734f633 100644 --- a/Source/Common/File Class.h +++ b/Source/Common/File Class.h @@ -5,7 +5,8 @@ class CFileBase { public: - enum OpenFlags { + enum OpenFlags + { modeRead = 0x0000, modeWrite = 0x0001, modeReadWrite = 0x0002, @@ -19,7 +20,8 @@ public: modeNoTruncate = 0x2000, }; - enum Attribute { + enum Attribute + { normal = 0x00, readOnly = 0x01, hidden = 0x02, diff --git a/Source/Common/Log Class.cpp b/Source/Common/Log Class.cpp index 86fa8e088..95f001dba 100644 --- a/Source/Common/Log Class.cpp +++ b/Source/Common/Log Class.cpp @@ -2,7 +2,6 @@ #include #include #include -#include CLog::CLog (void ) : m_FlushOnWrite(false), @@ -16,7 +15,7 @@ CLog::~CLog (void) { } -bool CLog::Open( LPCTSTR FileName, LOG_OPEN_MODE mode /* = Log_New */) +bool CLog::Open( const char * FileName, LOG_OPEN_MODE mode /* = Log_New */) { if (FileName == NULL) { @@ -34,14 +33,14 @@ bool CLog::Open( LPCTSTR FileName, LOG_OPEN_MODE mode /* = Log_New */) m_hLogFile.Close(); } - ULONG nOpenFlags = CFile::modeReadWrite | CFile::modeCreate; + uint32_t nOpenFlags = CFile::modeReadWrite | CFile::modeCreate; if (mode == Log_Append) { nOpenFlags |= CFile::modeNoTruncate; } if (!m_hLogFile.Open(File, nOpenFlags)) { return false; } - m_FileName = (LPCTSTR)File; + m_FileName = (const char *)File; m_hLogFile.Seek(0,mode == Log_Append ? CFile::end : CFile::begin); #ifdef _UNICODE @@ -64,7 +63,7 @@ void CLog::Close ( void ) } } -void CLog::LogF(LPCTSTR Message, ...) +void CLog::LogF(const char * Message, ...) { va_list ap; va_start( ap, Message ); @@ -72,7 +71,7 @@ void CLog::LogF(LPCTSTR Message, ...) va_end( ap ); } -void CLog::LogArgs(LPCTSTR Message, va_list & args ) +void CLog::LogArgs(const char * Message, va_list & args ) { if (!m_hLogFile.IsOpen()) { return; } @@ -112,14 +111,16 @@ void CLog::LogArgs(LPCTSTR Message, va_list & args ) } if (buffer) + { delete [] buffer; + } #endif } -void CLog::Log( LPCTSTR Message ) +void CLog::Log( const char * Message ) { if (!m_hLogFile.IsOpen()) { return; } - m_hLogFile.Write(Message,(ULONG)_tcslen(Message)*sizeof(TCHAR)); + m_hLogFile.Write(Message,(uint32_t)strlen(Message)*sizeof(TCHAR)); if (m_FlushOnWrite) { m_hLogFile.Flush(); @@ -128,7 +129,7 @@ void CLog::Log( LPCTSTR Message ) if (m_TruncateFileLog) { // check file size - ULONG FileSize = m_hLogFile.GetLength(); + uint32_t FileSize = m_hLogFile.GetLength(); // if larger then max size then if (FileSize > m_MaxFileSize) { @@ -138,16 +139,17 @@ void CLog::Log( LPCTSTR Message ) FileSize = m_hLogFile.GetLength(); } - DWORD end = m_hLogFile.SeekToEnd(); + uint32_t end = m_hLogFile.SeekToEnd(); // move to reduce size m_hLogFile.Seek((end - m_MaxFileSize) + m_FileChangeSize,CFile::begin); // Find next end of line - DWORD NextEnter = 0, dwRead = 0; - do { + uint32_t NextEnter = 0, dwRead = 0; + do + { BYTE Data[300]; - DWORD dwRead; + uint32_t dwRead; dwRead = m_hLogFile.Read(Data,sizeof(Data)); if (dwRead == 0) @@ -168,9 +170,10 @@ void CLog::Log( LPCTSTR Message ) } while(dwRead != 0); // copy content of log to the new file - DWORD ReadPos = (end - m_MaxFileSize) + m_FileChangeSize + NextEnter; - DWORD SizeToRead, WritePos = 0; - do { + uint32_t ReadPos = (end - m_MaxFileSize) + m_FileChangeSize + NextEnter; + uint32_t SizeToRead, WritePos = 0; + do + { enum { fIS_MvSize = 0x5000 }; unsigned char Data[fIS_MvSize + 1]; @@ -179,7 +182,7 @@ void CLog::Log( LPCTSTR Message ) m_hLogFile.Seek(ReadPos,CFile::begin); - DWORD dwRead; + uint32_t dwRead; dwRead = m_hLogFile.Read(Data,SizeToRead); m_hLogFile.Seek(WritePos,CFile::begin); diff --git a/Source/Common/Log Class.h b/Source/Common/Log Class.h index e507ef1a6..69d322cb1 100644 --- a/Source/Common/Log Class.h +++ b/Source/Common/Log Class.h @@ -1,11 +1,13 @@ -#ifndef __LOG_CLASS__H__ -#define __LOG_CLASS__H__ +#pragma once +#include "File Class.h" -enum LOG_OPEN_MODE { +enum LOG_OPEN_MODE +{ Log_New, Log_Append }; -class CLog { +class CLog +{ enum { MB = 1024 * 1024 }; enum { MAX_FILE_SIZE = 10 * MB }; @@ -13,24 +15,24 @@ class CLog { bool m_FlushOnWrite; stdstr m_FileName; bool m_TruncateFileLog; - ULONG m_MaxFileSize; - ULONG m_FileChangeSize; + uint32_t m_MaxFileSize; + uint32_t m_FileChangeSize; public: CLog ( void ); ~CLog ( void ); - bool Open ( LPCTSTR FileName, LOG_OPEN_MODE mode = Log_New ); - void Log ( LPCTSTR Message ); - void LogF ( LPCTSTR Message, ... ); - void LogArgs ( LPCTSTR Message, va_list & args ); + bool Open ( const char * FileName, LOG_OPEN_MODE mode = Log_New ); + void Log ( const char * Message ); + void LogF ( const char * Message, ... ); + void LogArgs ( const char * Message, va_list & args ); bool Empty ( void ); void Close ( void ); - inline void SetMaxFileSize ( ULONG Size ) + inline void SetMaxFileSize ( uint32_t Size ) { m_MaxFileSize = Size; - m_FileChangeSize = (ULONG)(Size * 0.1); + m_FileChangeSize = (uint32_t)(Size * 0.1); } inline void SetTruncateFile( bool Truncate ) { m_TruncateFileLog = Truncate; } inline void SetFlush ( bool Always ) { m_FlushOnWrite = Always; } @@ -38,5 +40,3 @@ public: inline bool Flush ( void ) { return m_hLogFile.Flush(); } inline const stdstr & FileName ( void ) const { return m_FileName; } }; - -#endif diff --git a/Source/Common/Trace.cpp b/Source/Common/Trace.cpp index 15c9c18f5..313d660f2 100644 --- a/Source/Common/Trace.cpp +++ b/Source/Common/Trace.cpp @@ -12,20 +12,20 @@ public: CTraceLog() { } - ~CTraceLog() { CloseTrace (); } + ~CTraceLog() { CloseTrace(); } - CTraceModule * AddTraceModule ( CTraceModule * TraceModule ); - CTraceModule * RemoveTraceModule ( CTraceModule * TraceModule ); - void CloseTrace ( void ); - void WriteTrace ( TraceType Type, LPCTSTR Message ); - void WriteTraceF ( TraceType Type, LPCTSTR strFormat, va_list args); + CTraceModule * AddTraceModule(CTraceModule * TraceModule); + CTraceModule * RemoveTraceModule(CTraceModule * TraceModule); + void CloseTrace(void); + void WriteTrace(TraceType Type, LPCTSTR Message); + void WriteTraceF(TraceType Type, LPCTSTR strFormat, va_list args); }; -CTraceModule * CTraceLog::AddTraceModule ( CTraceModule * TraceModule ) +CTraceModule * CTraceLog::AddTraceModule(CTraceModule * TraceModule) { CGuard Guard(m_CS); - - for (int i = 0; i < (int)m_Modules.size(); i++ ) + + for (int i = 0; i < (int)m_Modules.size(); i++) { if (m_Modules[i] == TraceModule) { @@ -36,7 +36,7 @@ CTraceModule * CTraceLog::AddTraceModule ( CTraceModule * TraceModule ) return TraceModule; } -CTraceModule * CTraceLog::RemoveTraceModule ( CTraceModule * TraceModule ) +CTraceModule * CTraceLog::RemoveTraceModule(CTraceModule * TraceModule) { CGuard Guard(m_CS); @@ -51,38 +51,38 @@ CTraceModule * CTraceLog::RemoveTraceModule ( CTraceModule * TraceModule ) return NULL; } -void CTraceLog::CloseTrace ( void) +void CTraceLog::CloseTrace(void) { CGuard Guard(m_CS); - for (int i = 0; i < (int)m_Modules.size(); i++ ) + for (int i = 0; i < (int)m_Modules.size(); i++) { - if(m_Modules[i]) + if (m_Modules[i]) delete m_Modules[i]; } m_Modules.clear(); } -void CTraceLog::WriteTraceF ( TraceType Type, LPCTSTR strFormat, va_list args) +void CTraceLog::WriteTraceF(TraceType Type, LPCTSTR strFormat, va_list args) { - const int nMaxSize = 32*1024; + const int nMaxSize = 32 * 1024; TCHAR pBuffer[nMaxSize]; - - _vsntprintf(pBuffer,nMaxSize,strFormat,args); + + _vsntprintf(pBuffer, nMaxSize, strFormat, args); pBuffer[nMaxSize - 1] = 0; - WriteTrace(Type,pBuffer); + WriteTrace(Type, pBuffer); } -void CTraceLog::WriteTrace ( TraceType Type, LPCTSTR Message) +void CTraceLog::WriteTrace(TraceType Type, LPCTSTR Message) { CGuard Guard(m_CS); if (Type != TraceNone) { bool WriteToLog = false; - for (int i = 0; i < (int)m_Modules.size(); i++ ) + for (int i = 0; i < (int)m_Modules.size(); i++) { - if ((m_Modules[i]->GetTraceLevel() & Type) != 0) + if ((m_Modules[i]->GetTraceLevel() & Type) != 0) { WriteToLog = true; break; @@ -99,58 +99,57 @@ void CTraceLog::WriteTrace ( TraceType Type, LPCTSTR Message) SYSTEMTIME sysTime; ::GetLocalTime(&sysTime); - nPos = _stprintf( pBuffer, _T("%04d/%02d/%02d %02d:%02d:%02d.%03d %05d: "), sysTime.wYear, - sysTime.wMonth,sysTime.wDay,sysTime.wHour,sysTime.wMinute,sysTime.wSecond,sysTime.wMilliseconds, + nPos = _stprintf(pBuffer, _T("%04d/%02d/%02d %02d:%02d:%02d.%03d %05d: "), sysTime.wYear, + sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond, sysTime.wMilliseconds, ::GetCurrentThreadId() - ); + ); // show the debug level - if (Type == TraceNone) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("None : ")); } - else if ((Type & TraceError) != 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Error : ")); } - else if ((Type & TraceSettings) != 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Setting: ")); } - else if ((Type & TraceGfxPlugin) != 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Gfx : ")); } - else if ((Type & TraceDebug) != 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Debug : ")); } - else if ((Type & TraceRecompiler)!= 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Recomp : ")); } - else if ((Type & TraceRSP )!= 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("RSP : ")); } - else if ((Type & TraceTLB )!= 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("TLB : ")); } - else if ((Type & TraceValidate )!= 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Valid : ")); } - else if ((Type & TraceAudio )!= 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Audio : ")); } - else { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Unknown: ")); } + if (Type == TraceNone) { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("None : ")); } + else if ((Type & TraceError) != 0) { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("Error : ")); } + else if ((Type & TraceSettings) != 0) { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("Setting: ")); } + else if ((Type & TraceGfxPlugin) != 0) { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("Gfx : ")); } + else if ((Type & TraceDebug) != 0) { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("Debug : ")); } + else if ((Type & TraceRecompiler) != 0) { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("Recomp : ")); } + else if ((Type & TraceRSP) != 0) { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("RSP : ")); } + else if ((Type & TraceTLB) != 0) { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("TLB : ")); } + else if ((Type & TraceValidate) != 0) { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("Valid : ")); } + else if ((Type & TraceAudio) != 0) { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("Audio : ")); } + else { nPos += _stprintf(pBuffer + nPos, _T("%s"), _T("Unknown: ")); } - for (int i = 0; i < (int)m_Modules.size(); i++ ) + for (int i = 0; i < (int)m_Modules.size(); i++) { - if ((m_Modules[i]->GetTraceLevel() & Type) != 0) + if ((m_Modules[i]->GetTraceLevel() & Type) != 0) { m_Modules[i]->Write(pBuffer, false); } } } - for (int i = 0; i < (int)m_Modules.size(); i++ ) + for (int i = 0; i < (int)m_Modules.size(); i++) { - if ((m_Modules[i]->GetTraceLevel() & Type) != 0) + if ((m_Modules[i]->GetTraceLevel() & Type) != 0) { m_Modules[i]->Write(Message, true); } } } - -CTraceLog & GetTraceObjet ( void ) +CTraceLog & GetTraceObjet(void) { static CTraceLog TraceLog; return TraceLog; } -void WriteTrace (TraceType Type, LPCTSTR Message ) +void WriteTrace(TraceType Type, LPCTSTR Message) { if (TraceClosed) { return; } - GetTraceObjet().WriteTrace(Type,Message); + GetTraceObjet().WriteTrace(Type, Message); } -void WriteTraceF ( TraceType Type, LPCTSTR strFormat, ... ) +void WriteTraceF(TraceType Type, LPCTSTR strFormat, ...) { if (TraceClosed) { @@ -158,11 +157,11 @@ void WriteTraceF ( TraceType Type, LPCTSTR strFormat, ... ) } va_list args; va_start(args, strFormat); - GetTraceObjet().WriteTraceF(Type,strFormat,args); + GetTraceObjet().WriteTraceF(Type, strFormat, args); va_end(args); } -CTraceModule * AddTraceModule ( CTraceModule * TraceModule ) +CTraceModule * AddTraceModule(CTraceModule * TraceModule) { if (TraceClosed) { @@ -172,52 +171,55 @@ CTraceModule * AddTraceModule ( CTraceModule * TraceModule ) return TraceModule; } -CTraceModule * RemoveTraceModule ( CTraceModule * TraceModule ) +CTraceModule * RemoveTraceModule(CTraceModule * TraceModule) { return GetTraceObjet().RemoveTraceModule(TraceModule); } -void CloseTrace ( void ) +void CloseTrace(void) { TraceClosed = true; GetTraceObjet().CloseTrace(); } -CTraceFileLog::CTraceFileLog(LPCTSTR FileName, bool FlushFile ) : - m_FlushFile(FlushFile) +CTraceFileLog::CTraceFileLog(LPCTSTR FileName, bool FlushFile) : +m_FlushFile(FlushFile) { m_hLogFile.SetFlush(false); m_hLogFile.SetTruncateFile(true); m_hLogFile.SetMaxFileSize(5 * MB); - m_hLogFile.Open(FileName,Log_Append); + m_hLogFile.Open(FileName, Log_Append); } -CTraceFileLog::CTraceFileLog (LPCTSTR FileName, bool FlushFile, LOG_OPEN_MODE eMode, DWORD dwMaxFileSize) : - m_FlushFile(FlushFile) +CTraceFileLog::CTraceFileLog(LPCTSTR FileName, bool FlushFile, LOG_OPEN_MODE eMode, uint32_t dwMaxFileSize) : +m_FlushFile(FlushFile) { - enum { MB = 1024 * 1024 }; + enum { MB = 1024 * 1024 }; m_hLogFile.SetFlush(false); m_hLogFile.SetTruncateFile(true); - if(dwMaxFileSize < 2048 && dwMaxFileSize > 2) + if (dwMaxFileSize < 2048 && dwMaxFileSize > 2) + { m_hLogFile.SetMaxFileSize(dwMaxFileSize * MB); + } else + { m_hLogFile.SetMaxFileSize(5 * MB); + } - m_hLogFile.Open(FileName,eMode); + m_hLogFile.Open(FileName, eMode); } - CTraceFileLog::~CTraceFileLog() { TraceClosed = true; } -void CTraceFileLog::Write(LPCTSTR Message, bool EndOfLine ) +void CTraceFileLog::Write(LPCTSTR Message, bool EndOfLine) { if (!m_hLogFile.IsOpen()) { return; } - + CGuard Section(m_CriticalSection); m_hLogFile.Log(Message); if (EndOfLine) @@ -230,7 +232,16 @@ void CTraceFileLog::Write(LPCTSTR Message, bool EndOfLine ) } } -void CTraceFileLog::SetFlushFile( bool bFlushFile ) +void CTraceFileLog::SetFlushFile(bool bFlushFile) { m_FlushFile = bFlushFile; } + +void CDebugTraceLog::Write(const char * Message, bool EndOfLine) +{ + OutputDebugString(Message); + if (EndOfLine) + { + OutputDebugString("\n"); + } +} diff --git a/Source/Common/Trace.h b/Source/Common/Trace.h index 3bda9afb4..d3b170633 100644 --- a/Source/Common/Trace.h +++ b/Source/Common/Trace.h @@ -1,5 +1,8 @@ #pragma once +#include "CriticalSection.h" +#include "Log Class.h" + class CTraceModule { TraceLevel m_Type; @@ -10,7 +13,7 @@ public: inline void SetTraceLevel ( TraceLevel Type ) { m_Type = Type; } inline TraceLevel GetTraceLevel ( void ) const { return m_Type; } - virtual void Write ( LPCTSTR Message, bool EndOfLine ) = 0; + virtual void Write ( const char * Message, bool EndOfLine ) = 0; }; class CTraceFileLog : public CTraceModule @@ -22,25 +25,18 @@ class CTraceFileLog : public CTraceModule bool m_FlushFile; public: - CTraceFileLog (LPCTSTR FileName, bool FlushFile = true); - CTraceFileLog (LPCTSTR FileName, bool FlushFile, LOG_OPEN_MODE eMode, DWORD dwMaxFileSize = 5); + CTraceFileLog (const char * FileName, bool FlushFile = true); + CTraceFileLog (const char * FileName, bool FlushFile, LOG_OPEN_MODE eMode, uint32_t dwMaxFileSize = 5); virtual ~CTraceFileLog (); - void Write ( LPCTSTR Message, bool EndOfLine ); + void Write ( const char * Message, bool EndOfLine ); void SetFlushFile ( bool bFlushFile ); }; class CDebugTraceLog : public CTraceModule { public: - void Write ( LPCTSTR Message, bool EndOfLine ) - { - OutputDebugString(Message); - if (EndOfLine) - { - OutputDebugString("\n"); - } - } + void Write ( const char * Message, bool EndOfLine ); }; CTraceModule * AddTraceModule ( CTraceModule * TraceModule ); // Must be created with new diff --git a/Source/Common/md5.h b/Source/Common/md5.h index 423b9e0fe..037e8512c 100644 --- a/Source/Common/md5.h +++ b/Source/Common/md5.h @@ -1,22 +1,22 @@ -// MD5.CC - source code for the C++/object oriented translation and +// MD5.CC - source code for the C++/object oriented translation and // modification of MD5. -// Translation and modification (c) 1995 by Mordechai T. Abzug +// Translation and modification (c) 1995 by Mordechai T. Abzug -// This translation/ modification is provided "as is," without express or +// This translation/ modification is provided "as is," without express or // implied warranty of any kind. -// The translator/ modifier does not claim (1) that MD5 will do what you think -// it does; (2) that this translation/ modification is accurate; or (3) that -// this software is "merchantible." (Language for this disclaimer partially +// The translator/ modifier does not claim (1) that MD5 will do what you think +// it does; (2) that this translation/ modification is accurate; or (3) that +// this software is "merchantible." (Language for this disclaimer partially // copied from the disclaimer below). /* based on: - MD5.H - header file for MD5C.C - MDDRIVER.C - test driver for MD2, MD4 and MD5 +MD5.H - header file for MD5C.C +MDDRIVER.C - test driver for MD2, MD4 and MD5 - Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All +Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved. License to copy and use this software is granted provided that it @@ -39,11 +39,7 @@ documentation and/or software. */ -#if !defined(AFX_MD5_H__6DD6923B_E241_40CE_81A3_4C2C88C140E4__INCLUDED_) -#define AFX_MD5_H__6DD6923B_E241_40CE_81A3_4C2C88C140E4__INCLUDED_ - -/* sprintf() */ -#include +#pragma once #include #include @@ -51,106 +47,102 @@ documentation and/or software. struct MD5Digest { - MD5Digest() { Reset(); } - unsigned char digest[16]; + MD5Digest() { Reset(); } + unsigned char digest[16]; - void Reset() { ::memset(digest, 0, sizeof(digest)); } - BOOL IsClear() - { - int isClear = 0; - for (int i=0; i < 16; i++) - isClear += digest[i]; - return (isClear == 0); - } - std::string String ( void ) - { - char s[33]; + void Reset() { ::memset(digest, 0, sizeof(digest)); } + bool IsClear() + { + int isClear = 0; + for (int i=0; i < 16; i++) + { + isClear += digest[i]; + } + return (isClear == 0); + } + std::string String ( void ) + { + char s[33]; - ::memset(s, 0, sizeof(s)); + ::memset(s, 0, sizeof(s)); - for (int i = 0; i < 16; i++) - { - sprintf(s+i*2, "%02X", digest[i]); - } - s[32]='\0'; - - return s; - } + for (int i = 0; i < 16; i++) + { + sprintf(s+i*2, "%02X", digest[i]); + } + s[32]='\0'; + + return s; + } }; -struct MD5Digest_less : std::binary_function +struct MD5Digest_less : std::binary_function { - bool operator()(const MD5Digest& x, const MD5Digest& y) const - { - return (memcmp(x.digest, y.digest, sizeof(x.digest)) < 0); - } + bool operator()(const MD5Digest& x, const MD5Digest& y) const + { + return (memcmp(x.digest, y.digest, sizeof(x.digest)) < 0); + } }; -class MD5 +class MD5 { - public: -// methods for controlled operation: - MD5 (); // simple initializer - ~MD5 (); - void update (const unsigned char *input, unsigned int input_length); - void update (FILE *file); - void finalize (); + // methods for controlled operation: + MD5 (); // simple initializer + ~MD5 (); + void update (const unsigned char *input, unsigned int input_length); + void update (FILE *file); + void finalize (); -// constructors for special circumstances. All these constructors finalize -// the MD5 context. - MD5 (CPath File); // digest File, finalize - MD5 (const unsigned char *string); // digest string, finalize - MD5 (FILE *file); // digest file, close, finalize - MD5 (const unsigned char *input, unsigned int input_length); - MD5 (const stdstr & string); + // constructors for special circumstances. All these constructors finalize + // the MD5 context. + MD5 (CPath File); // digest File, finalize + MD5 (const unsigned char *string); // digest string, finalize + MD5 (FILE *file); // digest file, close, finalize + MD5 (const unsigned char *input, unsigned int input_length); + MD5 (const stdstr & string); -// methods to acquire finalized result - void get_digest(MD5Digest& extdigest); //Digest into a digest structure - const unsigned char *raw_digest (); // digest as a 16-byte binary array - const char * hex_digest (); // digest as a 33-byte ascii-hex string + // methods to acquire finalized result + void get_digest(MD5Digest& extdigest); //Digest into a digest structure + const unsigned char *raw_digest (); // digest as a 16-byte binary array + const char * hex_digest (); // digest as a 33-byte ascii-hex string private: -// first, some types: - typedef unsigned int uint4; // assumes integer is 4 words long - typedef unsigned short int uint2; // assumes short integer is 2 words long - typedef unsigned char uint1; // assumes char is 1 word long + // first, some types: + typedef unsigned int uint4; // assumes integer is 4 words long + typedef unsigned short int uint2; // assumes short integer is 2 words long + typedef unsigned char uint1; // assumes char is 1 word long -// next, the private data: - uint4 state[4]; - uint4 count[2]; // number of *bits*, mod 2^64 - uint1 buffer[64]; // input buffer - uint1 digest[16]; - uint1 finalized; - stdstr m_hex_digest; + // next, the private data: + uint4 state[4]; + uint4 count[2]; // number of *bits*, mod 2^64 + uint1 buffer[64]; // input buffer + uint1 digest[16]; + uint1 finalized; + stdstr m_hex_digest; -// last, the private methods, mostly static: - void init (); // called by all constructors - void transform (uint1 *buffer); // does the real update work. Note - // that length is implied to be 64. + // last, the private methods, mostly static: + void init (); // called by all constructors + void transform (uint1 *buffer); // does the real update work. Note + // that length is implied to be 64. - static void encode (uint1 *dest, uint4 *src, uint4 length); - static void decode (uint4 *dest, uint1 *src, uint4 length); - static void memcpy (uint1 *dest, uint1 *src, uint4 length); - static void memset (uint1 *start, uint1 val, uint4 length); - - static inline uint4 rotate_left (uint4 x, uint4 n); - static inline uint4 F (uint4 x, uint4 y, uint4 z); - static inline uint4 G (uint4 x, uint4 y, uint4 z); - static inline uint4 H (uint4 x, uint4 y, uint4 z); - static inline uint4 I (uint4 x, uint4 y, uint4 z); - static inline void FF (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, - uint4 s, uint4 ac); - static inline void GG (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, - uint4 s, uint4 ac); - static inline void HH (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, - uint4 s, uint4 ac); - static inline void II (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, - uint4 s, uint4 ac); + static void encode (uint1 *dest, uint4 *src, uint4 length); + static void decode (uint4 *dest, uint1 *src, uint4 length); + static void memcpy (uint1 *dest, uint1 *src, uint4 length); + static void memset (uint1 *start, uint1 val, uint4 length); + static inline uint4 rotate_left (uint4 x, uint4 n); + static inline uint4 F (uint4 x, uint4 y, uint4 z); + static inline uint4 G (uint4 x, uint4 y, uint4 z); + static inline uint4 H (uint4 x, uint4 y, uint4 z); + static inline uint4 I (uint4 x, uint4 y, uint4 z); + static inline void FF (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, + uint4 s, uint4 ac); + static inline void GG (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, + uint4 s, uint4 ac); + static inline void HH (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, + uint4 s, uint4 ac); + static inline void II (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, + uint4 s, uint4 ac); }; - - - -#endif // !defined(AFX_MD5_H__6DD6923B_E241_40CE_81A3_4C2C88C140E4__INCLUDED_) From 19bf3e9945c4069b44554e517db5803986765abb Mon Sep 17 00:00:00 2001 From: zilmar Date: Fri, 6 Nov 2015 22:42:27 +1100 Subject: [PATCH 072/213] [Common] Add Sync Event class --- Source/Common/Common.vcproj | 8 +++++++ Source/Common/Common.vcxproj | 2 ++ Source/Common/Common.vcxproj.filters | 6 ++++++ Source/Common/SyncEvent.cpp | 31 ++++++++++++++++++++++++++++ Source/Common/SyncEvent.h | 21 +++++++++++++++++++ Source/Common/stdafx.h | 1 + 6 files changed, 69 insertions(+) create mode 100644 Source/Common/SyncEvent.cpp create mode 100644 Source/Common/SyncEvent.h diff --git a/Source/Common/Common.vcproj b/Source/Common/Common.vcproj index ecce01f61..651bcd98d 100644 --- a/Source/Common/Common.vcproj +++ b/Source/Common/Common.vcproj @@ -177,6 +177,10 @@ /> + + @@ -230,6 +234,10 @@ RelativePath=".\stdtypes.h" > + + diff --git a/Source/Common/Common.vcxproj b/Source/Common/Common.vcxproj index caa307a36..3da6fdc3a 100644 --- a/Source/Common/Common.vcxproj +++ b/Source/Common/Common.vcxproj @@ -43,6 +43,7 @@ Create + @@ -57,6 +58,7 @@ + diff --git a/Source/Common/Common.vcxproj.filters b/Source/Common/Common.vcxproj.filters index 852dc95bd..4c71fc098 100644 --- a/Source/Common/Common.vcxproj.filters +++ b/Source/Common/Common.vcxproj.filters @@ -41,6 +41,9 @@ Source Files + + Source Files + @@ -82,5 +85,8 @@ Header Files + + Header Files + \ No newline at end of file diff --git a/Source/Common/SyncEvent.cpp b/Source/Common/SyncEvent.cpp new file mode 100644 index 000000000..cdf4b4735 --- /dev/null +++ b/Source/Common/SyncEvent.cpp @@ -0,0 +1,31 @@ +#include "stdafx.h" + +SyncEvent::SyncEvent(bool bManualReset) +{ + m_Event = CreateEvent(NULL, bManualReset, FALSE, NULL); +} + +SyncEvent::~SyncEvent() +{ + CloseHandle(m_Event); +} + +void SyncEvent::Trigger() +{ + SetEvent(m_Event); +} + +bool SyncEvent::IsTriggered(int32_t iWaitTime) +{ + return (WAIT_OBJECT_0 == WaitForSingleObject(m_Event,iWaitTime)); +} + +void SyncEvent::Reset() +{ + ResetEvent(m_Event); +} + +void * SyncEvent::GetHandle() +{ + return m_Event; +} \ No newline at end of file diff --git a/Source/Common/SyncEvent.h b/Source/Common/SyncEvent.h new file mode 100644 index 000000000..3b95e8c77 --- /dev/null +++ b/Source/Common/SyncEvent.h @@ -0,0 +1,21 @@ +#pragma once + +class SyncEvent +{ +public: + enum { INFINITE_TIMEOUT = 0xFFFFFFFF }; + + SyncEvent(bool bManualReset = true); + ~SyncEvent(void); + + void Trigger (void); + bool IsTriggered (int32_t iWaitTime = 0); + void Reset(); + void * GetHandle(); + +protected: + SyncEvent(const SyncEvent&); // Disable copy constructor + SyncEvent& operator=(const SyncEvent&); // Disable assignment + + void * m_Event; +}; \ No newline at end of file diff --git a/Source/Common/stdafx.h b/Source/Common/stdafx.h index e601c4074..feed741db 100644 --- a/Source/Common/stdafx.h +++ b/Source/Common/stdafx.h @@ -16,3 +16,4 @@ #include "Trace.h" #include "md5.h" #include "Smart Pointer.h" +#include "SyncEvent.h" From 7c3f24b20d43f510a13fad35fa574d2624a43537 Mon Sep 17 00:00:00 2001 From: zilmar Date: Fri, 6 Nov 2015 22:55:21 +1100 Subject: [PATCH 073/213] [common] Add util class --- Source/Common/Common.vcproj | 8 ++++ Source/Common/Common.vcxproj | 2 + Source/Common/Common.vcxproj.filters | 6 +++ Source/Common/Util.cpp | 61 ++++++++++++++++++++++++++++ Source/Common/Util.h | 14 +++++++ 5 files changed, 91 insertions(+) create mode 100644 Source/Common/Util.cpp create mode 100644 Source/Common/Util.h diff --git a/Source/Common/Common.vcproj b/Source/Common/Common.vcproj index 651bcd98d..a93bb74a9 100644 --- a/Source/Common/Common.vcproj +++ b/Source/Common/Common.vcproj @@ -185,6 +185,10 @@ RelativePath="Trace.cpp" > + + + + diff --git a/Source/Common/Common.vcxproj b/Source/Common/Common.vcxproj index 3da6fdc3a..0a2d5b051 100644 --- a/Source/Common/Common.vcxproj +++ b/Source/Common/Common.vcxproj @@ -45,6 +45,7 @@ + @@ -61,5 +62,6 @@ + \ No newline at end of file diff --git a/Source/Common/Common.vcxproj.filters b/Source/Common/Common.vcxproj.filters index 4c71fc098..1f3aa4e29 100644 --- a/Source/Common/Common.vcxproj.filters +++ b/Source/Common/Common.vcxproj.filters @@ -44,6 +44,9 @@ Source Files + + Source Files + @@ -88,5 +91,8 @@ Header Files + + Header Files + \ No newline at end of file diff --git a/Source/Common/Util.cpp b/Source/Common/Util.cpp new file mode 100644 index 000000000..ab32891a2 --- /dev/null +++ b/Source/Common/Util.cpp @@ -0,0 +1,61 @@ +#include "stdafx.h" +#include "Util.h" +#include + +void pjutil::Sleep(uint32_t timeout) +{ + ::Sleep(timeout); +} + +bool pjutil::TerminatedExistingExe() +{ + bool bTerminated = false; + bool AskedUser = false; + DWORD pid = GetCurrentProcessId(); + + HANDLE nSearch = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + if (nSearch != INVALID_HANDLE_VALUE) + { + PROCESSENTRY32 lppe; + + memset(&lppe, 0, sizeof(PROCESSENTRY32)); + lppe.dwSize = sizeof(PROCESSENTRY32); + stdstr ModuleName = CPath(CPath::MODULE_FILE).GetNameExtension(); + + if (Process32First(nSearch, &lppe)) + { + do + { + if (_stricmp(lppe.szExeFile, ModuleName.c_str()) != 0 || + lppe.th32ProcessID == pid) + { + continue; + } + if (!AskedUser) + { + AskedUser = true; + int res = MessageBox(NULL, stdstr_f("%s currently running\n\nTerminate pid %d now?", ModuleName.c_str(), lppe.th32ProcessID).c_str(), stdstr_f("Terminate %s",ModuleName.c_str()).c_str(), MB_YESNO | MB_ICONEXCLAMATION); + if (res != IDYES) + { + break; + } + } + HANDLE hHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, lppe.th32ProcessID); + if (hHandle != NULL) + { + if (TerminateProcess(hHandle, 0)) + { + bTerminated = true; + } + else + { + MessageBox(NULL, stdstr_f("Failed to terminate pid %d", lppe.th32ProcessID).c_str(), stdstr_f("Terminate %s failed!",ModuleName.c_str()).c_str(), MB_YESNO | MB_ICONEXCLAMATION); + } + CloseHandle(hHandle); + } + } while (Process32Next(nSearch, &lppe)); + } + CloseHandle(nSearch); + } + return bTerminated; +} \ No newline at end of file diff --git a/Source/Common/Util.h b/Source/Common/Util.h new file mode 100644 index 000000000..4dc0a48a1 --- /dev/null +++ b/Source/Common/Util.h @@ -0,0 +1,14 @@ +#pragma once +#include "stdtypes.h" + +class pjutil +{ +public: + static void Sleep(uint32_t timeout); + static bool TerminatedExistingExe(); + +private: + pjutil(void); // Disable default constructor + pjutil(const pjutil&); // Disable copy constructor + pjutil& operator=(const pjutil&); // Disable assignment +}; \ No newline at end of file From 43f175ce704a1ab1a73986d28d2f159afc8a8137 Mon Sep 17 00:00:00 2001 From: zilmar Date: Fri, 6 Nov 2015 22:55:44 +1100 Subject: [PATCH 074/213] [nrage] some code clean up --- .../ControllerSpecs/Controller #1.1.h | 360 +++++++++--------- Source/nragev20/NRagePluginV2.h | 191 +++++----- 2 files changed, 273 insertions(+), 278 deletions(-) diff --git a/Source/nragev20/ControllerSpecs/Controller #1.1.h b/Source/nragev20/ControllerSpecs/Controller #1.1.h index d2fede161..ff305862e 100644 --- a/Source/nragev20/ControllerSpecs/Controller #1.1.h +++ b/Source/nragev20/ControllerSpecs/Controller #1.1.h @@ -1,5 +1,5 @@ /********************************************************************************** -Common Controller plugin spec, version #1.1 maintained by +Common Controller plugin spec, version #1.1 maintained by zilmar (zilmar@emulation64.com) All questions or suggestions should go through the emutalk plugin forum. @@ -12,11 +12,11 @@ http://www.emutalk.net/cgi-bin/ikonboard/ikonboard.cgi?s=3bd272222f66ffff;act=SF extern "C" { #endif -/* Note: BOOL, BYTE, WORD, DWORD, TRUE, FALSE are defined in windows.h */ + /* Note: BOOL, BYTE, WORD, DWORD, TRUE, FALSE are defined in windows.h */ #define PLUGIN_TYPE_CONTROLLER 4 -/*** Conteroller plugin's ****/ + /*** Conteroller plugin's ****/ #define PLUGIN_NONE 1 #define PLUGIN_MEMPAK 2 // not implemeted for non raw data @@ -26,208 +26,212 @@ extern "C" { // the controller plugin is passed in raw data #define PLUGIN_RAW 5 -/********************************************************************************* - Note about Conteroller plugin's: - the rumble pak needs a function for the force feed back joystick and tranfer pak - probaly needs a function for the plugin to be able to select the GB rom and - eeprom... maybe this should be done by the emu instead of the plugin, but I think - it probaly should be done by the plugin. I will see about adding these functions - in the next spec -**********************************************************************************/ + /********************************************************************************* + Note about Conteroller plugin's: + the rumble pak needs a function for the force feed back joystick and tranfer pak + probaly needs a function for the plugin to be able to select the GB rom and + eeprom... maybe this should be done by the emu instead of the plugin, but I think + it probaly should be done by the plugin. I will see about adding these functions + in the next spec + **********************************************************************************/ #define EXPORT __declspec(dllexport) #define CALL _cdecl -/***** Structures *****/ -typedef struct { - WORD Version; /* Should be set to 0x0101 */ - WORD Type; /* Set to PLUGIN_TYPE_CONTROLLER */ - char Name[100]; /* Name of the DLL */ - BOOL Reserved1; - BOOL Reserved2; -} PLUGIN_INFO; + /***** Structures *****/ + typedef struct + { + WORD Version; /* Should be set to 0x0101 */ + WORD Type; /* Set to PLUGIN_TYPE_CONTROLLER */ + char Name[100]; /* Name of the DLL */ + BOOL Reserved1; + BOOL Reserved2; + } PLUGIN_INFO; -typedef struct { - BOOL Present; - BOOL RawData; - int Plugin; -} CONTROL; + typedef struct + { + BOOL Present; + BOOL RawData; + int Plugin; + } CONTROL; -typedef union { - DWORD Value; - struct { - unsigned R_DPAD : 1; - unsigned L_DPAD : 1; - unsigned D_DPAD : 1; - unsigned U_DPAD : 1; - unsigned START_BUTTON : 1; - unsigned Z_TRIG : 1; - unsigned B_BUTTON : 1; - unsigned A_BUTTON : 1; + typedef union + { + DWORD Value; + struct + { + unsigned R_DPAD : 1; + unsigned L_DPAD : 1; + unsigned D_DPAD : 1; + unsigned U_DPAD : 1; + unsigned START_BUTTON : 1; + unsigned Z_TRIG : 1; + unsigned B_BUTTON : 1; + unsigned A_BUTTON : 1; - unsigned R_CBUTTON : 1; - unsigned L_CBUTTON : 1; - unsigned D_CBUTTON : 1; - unsigned U_CBUTTON : 1; - unsigned R_TRIG : 1; - unsigned L_TRIG : 1; - unsigned Reserved1 : 1; - unsigned Reserved2 : 1; + unsigned R_CBUTTON : 1; + unsigned L_CBUTTON : 1; + unsigned D_CBUTTON : 1; + unsigned U_CBUTTON : 1; + unsigned R_TRIG : 1; + unsigned L_TRIG : 1; + unsigned Reserved1 : 1; + unsigned Reserved2 : 1; - signed Y_AXIS : 8; + signed Y_AXIS : 8; - signed X_AXIS : 8; - }; -} BUTTONS; + signed X_AXIS : 8; + }; + } BUTTONS; -typedef struct { - HWND hMainWindow; - HINSTANCE hinst; + typedef struct + { + HWND hMainWindow; + HINSTANCE hinst; - BOOL MemoryBswaped; // If this is set to TRUE, then the memory has been pre - // bswap on a dword (32 bits) boundry, only effects header. - // eg. the first 8 bytes are stored like this: - // 4 3 2 1 8 7 6 5 - BYTE * HEADER; // This is the rom header (first 40h bytes of the rom) - CONTROL *Controls; // A pointer to an array of 4 controllers .. eg: - // CONTROL Controls[4]; -} CONTROL_INFO; + BOOL MemoryBswaped; // If this is set to TRUE, then the memory has been pre + // bswap on a dword (32 bits) boundry, only effects header. + // eg. the first 8 bytes are stored like this: + // 4 3 2 1 8 7 6 5 + BYTE * HEADER; // This is the rom header (first 40h bytes of the rom) + CONTROL *Controls; // A pointer to an array of 4 controllers .. eg: + // CONTROL Controls[4]; + } CONTROL_INFO; -/****************************************************************** - Function: CloseDLL - Purpose: This function is called when the emulator is closing - down allowing the dll to de-initialise. - input: none - output: none -*******************************************************************/ -EXPORT void CALL CloseDLL (void); + /****************************************************************** + Function: CloseDLL + Purpose: This function is called when the emulator is closing + down allowing the dll to de-initialise. + input: none + output: none + *******************************************************************/ + EXPORT void CALL CloseDLL(void); -/****************************************************************** - Function: ControllerCommand - Purpose: To process the raw data that has just been sent to a - specific controller. - input: - Controller Number (0 to 3) and -1 signalling end of - processing the pif ram. - - Pointer of data to be processed. - output: none - - note: This function is only needed if the DLL is allowing raw - data, or the plugin is set to raw + /****************************************************************** + Function: ControllerCommand + Purpose: To process the raw data that has just been sent to a + specific controller. + input: - Controller Number (0 to 3) and -1 signalling end of + processing the pif ram. + - Pointer of data to be processed. + output: none - the data that is being processed looks like this: - initilize controller: 01 03 00 FF FF FF - read controller: 01 04 01 FF FF FF FF -*******************************************************************/ -EXPORT void CALL ControllerCommand ( int Control, BYTE * Command); + note: This function is only needed if the DLL is allowing raw + data, or the plugin is set to raw -/****************************************************************** - Function: DllAbout - Purpose: This function is optional function that is provided - to give further information about the DLL. - input: a handle to the window that calls this function - output: none -*******************************************************************/ -EXPORT void CALL DllAbout ( HWND hParent ); + the data that is being processed looks like this: + initilize controller: 01 03 00 FF FF FF + read controller: 01 04 01 FF FF FF FF + *******************************************************************/ + EXPORT void CALL ControllerCommand(int Control, BYTE * Command); -/****************************************************************** - Function: DllConfig - Purpose: This function is optional function that is provided - to allow the user to configure the dll - input: a handle to the window that calls this function - output: none -*******************************************************************/ -EXPORT void CALL DllConfig ( HWND hParent ); + /****************************************************************** + Function: DllAbout + Purpose: This function is optional function that is provided + to give further information about the DLL. + input: a handle to the window that calls this function + output: none + *******************************************************************/ + EXPORT void CALL DllAbout(HWND hParent); -/****************************************************************** - Function: DllTest - Purpose: This function is optional function that is provided - to allow the user to test the dll - input: a handle to the window that calls this function - output: none -*******************************************************************/ -EXPORT void CALL DllTest ( HWND hParent ); + /****************************************************************** + Function: DllConfig + Purpose: This function is optional function that is provided + to allow the user to configure the dll + input: a handle to the window that calls this function + output: none + *******************************************************************/ + EXPORT void CALL DllConfig(HWND hParent); -/****************************************************************** - Function: GetDllInfo - Purpose: This function allows the emulator to gather information - about the dll by filling in the PluginInfo structure. - input: a pointer to a PLUGIN_INFO stucture that needs to be - filled by the function. (see def above) - output: none -*******************************************************************/ -EXPORT void CALL GetDllInfo ( PLUGIN_INFO * PluginInfo ); + /****************************************************************** + Function: DllTest + Purpose: This function is optional function that is provided + to allow the user to test the dll + input: a handle to the window that calls this function + output: none + *******************************************************************/ + EXPORT void CALL DllTest(HWND hParent); -/****************************************************************** - Function: GetKeys - Purpose: To get the current state of the controllers buttons. - input: - Controller Number (0 to 3) - - A pointer to a BUTTONS structure to be filled with - the controller state. - output: none -*******************************************************************/ -EXPORT void CALL GetKeys(int Control, BUTTONS * Keys ); + /****************************************************************** + Function: GetDllInfo + Purpose: This function allows the emulator to gather information + about the dll by filling in the PluginInfo structure. + input: a pointer to a PLUGIN_INFO stucture that needs to be + filled by the function. (see def above) + output: none + *******************************************************************/ + EXPORT void CALL GetDllInfo(PLUGIN_INFO * PluginInfo); -/****************************************************************** - Function: InitiateControllers - Purpose: This function initialises how each of the controllers - should be handled. - input: - The handle to the main window. - - A controller structure that needs to be filled for - the emulator to know how to handle each controller. - output: none -*******************************************************************/ -EXPORT void CALL InitiateControllers (CONTROL_INFO * ControlInfo); + /****************************************************************** + Function: GetKeys + Purpose: To get the current state of the controllers buttons. + input: - Controller Number (0 to 3) + - A pointer to a BUTTONS structure to be filled with + the controller state. + output: none + *******************************************************************/ + EXPORT void CALL GetKeys(int Control, BUTTONS * Keys); -/****************************************************************** - Function: ReadController - Purpose: To process the raw data in the pif ram that is about to - be read. - input: - Controller Number (0 to 3) and -1 signalling end of - processing the pif ram. - - Pointer of data to be processed. - output: none - note: This function is only needed if the DLL is allowing raw - data. -*******************************************************************/ -EXPORT void CALL ReadController ( int Control, BYTE * Command ); + /****************************************************************** + Function: InitiateControllers + Purpose: This function initialises how each of the controllers + should be handled. + input: - The handle to the main window. + - A controller structure that needs to be filled for + the emulator to know how to handle each controller. + output: none + *******************************************************************/ + EXPORT void CALL InitiateControllers(CONTROL_INFO * ControlInfo); -/****************************************************************** - Function: RomClosed - Purpose: This function is called when a rom is closed. - input: none - output: none -*******************************************************************/ -EXPORT void CALL RomClosed (void); + /****************************************************************** + Function: ReadController + Purpose: To process the raw data in the pif ram that is about to + be read. + input: - Controller Number (0 to 3) and -1 signalling end of + processing the pif ram. + - Pointer of data to be processed. + output: none + note: This function is only needed if the DLL is allowing raw + data. + *******************************************************************/ + EXPORT void CALL ReadController(int Control, BYTE * Command); -/****************************************************************** - Function: RomOpen - Purpose: This function is called when a rom is open. (from the - emulation thread) - input: none - output: none -*******************************************************************/ -EXPORT void CALL RomOpen (void); + /****************************************************************** + Function: RomClosed + Purpose: This function is called when a rom is closed. + input: none + output: none + *******************************************************************/ + EXPORT void CALL RomClosed(void); -/****************************************************************** - Function: WM_KeyDown - Purpose: To pass the WM_KeyDown message from the emulator to the - plugin. - input: wParam and lParam of the WM_KEYDOWN message. - output: none -*******************************************************************/ -EXPORT void CALL WM_KeyDown( WPARAM wParam, LPARAM lParam ); + /****************************************************************** + Function: RomOpen + Purpose: This function is called when a rom is open. (from the + emulation thread) + input: none + output: none + *******************************************************************/ + EXPORT void CALL RomOpen(void); -/****************************************************************** - Function: WM_KeyUp - Purpose: To pass the WM_KEYUP message from the emulator to the - plugin. - input: wParam and lParam of the WM_KEYDOWN message. - output: none -*******************************************************************/ -EXPORT void CALL WM_KeyUp( WPARAM wParam, LPARAM lParam ); + /****************************************************************** + Function: WM_KeyDown + Purpose: To pass the WM_KeyDown message from the emulator to the + plugin. + input: wParam and lParam of the WM_KEYDOWN message. + output: none + *******************************************************************/ + EXPORT void CALL WM_KeyDown(WPARAM wParam, LPARAM lParam); + + /****************************************************************** + Function: WM_KeyUp + Purpose: To pass the WM_KEYUP message from the emulator to the + plugin. + input: wParam and lParam of the WM_KEYDOWN message. + output: none + *******************************************************************/ + EXPORT void CALL WM_KeyUp(WPARAM wParam, LPARAM lParam); #if defined(__cplusplus) } #endif #endif - diff --git a/Source/nragev20/NRagePluginV2.h b/Source/nragev20/NRagePluginV2.h index a8eedefd4..a9d7208de 100644 --- a/Source/nragev20/NRagePluginV2.h +++ b/Source/nragev20/NRagePluginV2.h @@ -1,25 +1,24 @@ -/* +/* N-Rage`s Dinput8 Plugin - (C) 2002, 2006 Norbert Wladyka + (C) 2002, 2006 Norbert Wladyka Author`s Email: norbert.wladyka@chello.at Website: http://go.to/nrage + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the free Software Foundation; either version 2 of the License, or + (at your option) any later version. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ #ifndef _NRAGEPLUGIN_ #define _NRAGEPLUGIN_ @@ -32,9 +31,9 @@ #define TIMER_MESSAGEWINDOW 123 - // maximum number of devices other than SysMouse +// maximum number of devices other than SysMouse #define MAX_DEVICES 32 - // maximum number of modifiers +// maximum number of modifiers #define MAX_MODIFIERS 256 #define DEFAULT_STICKRANGE 66 @@ -52,11 +51,9 @@ #define PAK_VOICE 4 #define PAK_ADAPTOID 7 - // just used to display text in GUI +// just used to display text in GUI #define PAK_NONRAW 16 - - typedef struct _EMULATOR_INFO { bool fInitialisedPlugin; @@ -65,11 +62,11 @@ typedef struct _EMULATOR_INFO LANGID Language; bool fDisplayShortPop; // do we display shortcut message popups? -// BOOL MemoryBswaped; // If this is set to TRUE, then the memory has been pre - // bswap on a dword (32 bits) boundry, only effects header. - // eg. the first 8 bytes are stored like this: - // 4 3 2 1 8 7 6 5 -// BYTE * HEADER; // This is the rom header (first 40h bytes of the rom) + // BOOL MemoryBswaped; // If this is set to TRUE, then the memory has been pre + // bswap on a dword (32 bits) boundry, only effects header. + // eg. the first 8 bytes are stored like this: + // 4 3 2 1 8 7 6 5 + // BYTE * HEADER; // This is the rom header (first 40h bytes of the rom) } EMULATOR_INFO, *LPEMULATOR_INFO; typedef struct _DEVICE @@ -79,8 +76,9 @@ typedef struct _DEVICE BYTE bProductCounter; GUID guidInstance; DWORD dwDevType; // can be DI8DEVTYPE_KEYBOARD, DI8DEVTYPE_MOUSE, etc - BYTE bEffType; // What rumble effects does this device support? - union INPUTSTATE { // the last polled data from this device + BYTE bEffType; // What rumble effects does this device support? + union INPUTSTATE // the last polled data from this device + { DIJOYSTATE joyState; DIMOUSESTATE2 mouseState; BYTE rgbButtons[256]; // keyboard state @@ -99,7 +97,7 @@ typedef struct _BUTTON // Modifiers are a feature built into NRage. Emulator turbo buttons, macros, stuff like that. typedef struct _MODIFIER { - BUTTON btnButton; // button to associate with + BUTTON btnButton; // button to associate with BYTE bModType; // Type of modifier (None, Movement, Macro, Config) BOOL fToggle; // false if you have to hold the button down to activate, true if the modifier toggles on button press BOOL fStatus; // if true, control defaults to ACTIVE, and deactivates on button press @@ -112,14 +110,14 @@ typedef struct _MODIFIER #define MDT_MACRO 2 #define MDT_CONFIG 3 - // buffered +// buffered #define MM_BUFF 0 - // absolute +// absolute #define MM_ABS 1 - // deadpan +// deadpan #define MM_DEAD 2 - - // Number of analog axes. Standard N64 controller has just 2: X and Y joystick. + +// Number of analog axes. Standard N64 controller has just 2: X and Y joystick. #define PF_AXESETS 2 typedef struct _CONTROLLER // AN N64 CONTROLLER @@ -153,7 +151,7 @@ typedef struct _CONTROLLER // AN N64 CONTROLLER BYTE bStickRange; // our "range modifier". long wAxeBuffer[4]; // makes pseudo-relative Movement possible through keyboard or buttons - // also acts as a mouse buffer + // also acts as a mouse buffer WORD wMouseSensitivityX; // set per N64 controller, that's OK WORD wMouseSensitivityY; @@ -165,22 +163,22 @@ typedef struct _CONTROLLER // AN N64 CONTROLLER BYTE bRapidFireRate; BYTE bRapidFireCounter; - TCHAR szMempakFile[MAX_PATH+1]; // MemPak-FileName - TCHAR szTransferRom[MAX_PATH+1]; // GameBoyRom-Filename - TCHAR szTransferSave[MAX_PATH+1]; // GameBoyEEPRom-Filename + TCHAR szMempakFile[MAX_PATH + 1]; // MemPak-FileName + TCHAR szTransferRom[MAX_PATH + 1]; // GameBoyRom-Filename + TCHAR szTransferSave[MAX_PATH + 1]; // GameBoyEEPRom-Filename - BUTTON aButton[14+PF_AXESETS*4]; // Ten buttons, 4 d-pad directions times two (for Config 1 and Config 2) + BUTTON aButton[14 + PF_AXESETS * 4]; // Ten buttons, 4 d-pad directions times two (for Config 1 and Config 2) MODIFIER *pModifiers; // Array of Modifiers void *pPakData; // Pointer to Pak Data (specific): see PakIO.h - // pPakData->bPakType will always be a BYTE indicating what the current pak type is + // pPakData->bPakType will always be a BYTE indicating what the current pak type is XCONTROLLER xiController; // To handle an XInput enabled controller --tecnicors } CONTROLLER, *LPCONTROLLER; // This is the Index of WORD PROFILE.Button[X] - // Buttons: +// Buttons: #define PF_DPADR 0 #define PF_DPADL 1 #define PF_DPADD 2 @@ -188,7 +186,7 @@ typedef struct _CONTROLLER // AN N64 CONTROLLER #define PF_START 4 #define PF_TRIGGERZ 5 #define PF_BBUTTON 6 -#define PF_ABUTTON 7 +#define PF_ABUTTON 7 #define PF_CBUTTONR 8 #define PF_CBUTTONL 9 #define PF_CBUTTOND 10 @@ -196,52 +194,49 @@ typedef struct _CONTROLLER // AN N64 CONTROLLER #define PF_TRIGGERR 12 #define PF_TRIGGERL 13 - // Analog Stick - // cause you can assign Buttons to it, I need 4 of 'em +// Analog Stick +// cause you can assign Buttons to it, I need 4 of 'em #define PF_APADR 14 #define PF_APADL 15 #define PF_APADD 16 #define PF_APADU 17 - // second Set +// second Set // #define PF_APADR 18 // #define PF_APADL 19 // #define PF_APADD 20 // #define PF_APADU 21 - - - // Data Format of DWORD Controller.Button: // - + // BYTE bBtnType : Determines the Device and general Type of Control // BYTE bAxisID : AxeIndentifier, Tells which range of the Axe/POV is important // BYTE bOffset : Offset in the DirectInput data structure // BYTE bBtnType : Determines the Device and general Type of Control #define DT_UNASSIGNED 0 - // Joystick +// Joystick #define DT_JOYBUTTON 1 #define DT_JOYAXE 2 #define DT_JOYPOV 3 #define DT_JOYSLIDER 4 - // Keyboard +// Keyboard #define DT_KEYBUTTON 5 - // Mouse +// Mouse #define DT_MOUSEBUTTON 6 #define DT_MOUSEAXE 7 // BYTE bAxisID : AxeIndentifier, Tells which range of the Axe/POV is important - // Positive Range of an Axe +// Positive Range of an Axe #define AI_AXE_P 0 - // Negative Range +// Negative Range #define AI_AXE_N 1 - // Applies to POVs obviously +// Applies to POVs obviously #define AI_POV_UP 0 #define AI_POV_RIGHT 1 #define AI_POV_DOWN 2 @@ -249,12 +244,11 @@ typedef struct _CONTROLLER // AN N64 CONTROLLER // BYTE bOffset : Offset in the DirectInput data structure - typedef union _MODSPEC_MOVE { DWORD dwValue; struct - { + { short XModification; short YModification; }; @@ -264,36 +258,36 @@ typedef union _MODSPEC_MACRO { DWORD dwValue; struct - { + { unsigned short aButtons; unsigned short aFlags; }; struct { - unsigned fDigitalRight :1; - unsigned fDigitalLeft :1; - unsigned fDigitalDown :1; - unsigned fDigitalUp :1; - unsigned fStart :1; - unsigned fTriggerZ :1; - unsigned fBButton :1; - unsigned fAButton :1; - unsigned fCRight :1; - unsigned fCLeft :1; - unsigned fCDown :1; - unsigned fCUp :1; - unsigned fTriggerR :1; - unsigned fTriggerL :1; - unsigned :2; + unsigned fDigitalRight : 1; + unsigned fDigitalLeft : 1; + unsigned fDigitalDown : 1; + unsigned fDigitalUp : 1; + unsigned fStart : 1; + unsigned fTriggerZ : 1; + unsigned fBButton : 1; + unsigned fAButton : 1; + unsigned fCRight : 1; + unsigned fCLeft : 1; + unsigned fCDown : 1; + unsigned fCUp : 1; + unsigned fTriggerR : 1; + unsigned fTriggerL : 1; + unsigned : 2; - unsigned fAnalogRight :1; - unsigned fAnalogLeft :1; - unsigned fAnalogDown :1; - unsigned fAnalogUp :1; - unsigned fRapidFire :1; - unsigned fRapidFireRate :1; - unsigned fPrevFireState :1; - unsigned fPrevFireState2 :1; + unsigned fAnalogRight : 1; + unsigned fAnalogLeft : 1; + unsigned fAnalogDown : 1; + unsigned fAnalogUp : 1; + unsigned fRapidFire : 1; + unsigned fRapidFireRate : 1; + unsigned fPrevFireState : 1; + unsigned fPrevFireState2 : 1; }; } MODSPEC_MACRO, *LPMODSPEC_MACRO; @@ -301,22 +295,21 @@ typedef union _MODSPEC_CONFIG { DWORD dwValue; struct - { + { BYTE bAnalogStick; BYTE bMouse; BYTE bKeyboard; }; struct { - unsigned fChangeAnalogConfig :1; - unsigned fAnalogStickMode :7; - unsigned fChangeMouseXAxis :1; - unsigned fChangeMouseYAxis :1; - unsigned :6; - unsigned fChangeKeyboardXAxis :1; - unsigned fChangeKeyboardYAxis :1; - unsigned :6; - + unsigned fChangeAnalogConfig : 1; + unsigned fAnalogStickMode : 7; + unsigned fChangeMouseXAxis : 1; + unsigned fChangeMouseYAxis : 1; + unsigned : 6; + unsigned fChangeKeyboardXAxis : 1; + unsigned fChangeKeyboardYAxis : 1; + unsigned : 6; }; } MODSPEC_CONFIG, *LPMODSPEC_CONFIG; @@ -329,8 +322,8 @@ typedef union _MODSPEC_CONFIG #define SC_SWMEMRUMB 6 #define SC_SWMEMADAPT 7 - // total arraysize of aButtons in SHORTCUTSPL; - // make sure you update this if you change the list above +// total arraysize of aButtons in SHORTCUTSPL; +// make sure you update this if you change the list above #define SC_TOTAL 8 typedef struct _SHORTCUTSPL @@ -357,9 +350,7 @@ typedef struct _MSHORTCUT { int iShortcut; } MSHORTCUT, *LPMSHORTCUT; // shortcut message - #define CHECK_WHITESPACES( str ) ( str == '\r' || str == '\n' || str == '\t' ) - extern HANDLE g_hHeap; extern HMODULE g_hDirectInputDLL; @@ -383,12 +374,12 @@ extern bool g_bExclusiveMouse; extern int g_iFirstController; -int WarningMessage( UINT uTextID, UINT uType ); -int FindDeviceinList( const TCHAR *pszProductName, BYTE bProductCounter, bool fFindSimilar ); -int FindDeviceinList( REFGUID rGUID ); -void freePakData( CONTROLLER *pcController ); -void freeModifiers( CONTROLLER *pcController ); +int WarningMessage(UINT uTextID, UINT uType); +int FindDeviceinList(const TCHAR *pszProductName, BYTE bProductCounter, bool fFindSimilar); +int FindDeviceinList(REFGUID rGUID); +void freePakData(CONTROLLER *pcController); +void freeModifiers(CONTROLLER *pcController); void CheckShortcuts(); -bool ErrorMessage( UINT uID, DWORD dwError, bool fUserChoose ); +bool ErrorMessage(UINT uID, DWORD dwError, bool fUserChoose); #endif From dd9bb892cb977b9c7767c646cacb64d7b8f80dc3 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Nov 2015 12:18:44 -0500 Subject: [PATCH 075/213] [Common] MaxFileSize: Use size_t for memory sizes. --- Source/Common/Log Class.h | 12 ++++++------ Source/Common/Trace.cpp | 13 +++++-------- Source/Common/Trace.h | 2 +- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Source/Common/Log Class.h b/Source/Common/Log Class.h index 69d322cb1..1b155da5d 100644 --- a/Source/Common/Log Class.h +++ b/Source/Common/Log Class.h @@ -15,8 +15,8 @@ class CLog bool m_FlushOnWrite; stdstr m_FileName; bool m_TruncateFileLog; - uint32_t m_MaxFileSize; - uint32_t m_FileChangeSize; + size_t m_MaxFileSize; + size_t m_FileChangeSize; public: CLog ( void ); @@ -29,10 +29,10 @@ public: bool Empty ( void ); void Close ( void ); - inline void SetMaxFileSize ( uint32_t Size ) - { - m_MaxFileSize = Size; - m_FileChangeSize = (uint32_t)(Size * 0.1); + inline void SetMaxFileSize(size_t Size) + { + m_MaxFileSize = Size; + m_FileChangeSize = (size_t)(Size * 0.1); } inline void SetTruncateFile( bool Truncate ) { m_TruncateFileLog = Truncate; } inline void SetFlush ( bool Always ) { m_FlushOnWrite = Always; } diff --git a/Source/Common/Trace.cpp b/Source/Common/Trace.cpp index 313d660f2..e74519fe8 100644 --- a/Source/Common/Trace.cpp +++ b/Source/Common/Trace.cpp @@ -191,7 +191,7 @@ m_FlushFile(FlushFile) m_hLogFile.Open(FileName, Log_Append); } -CTraceFileLog::CTraceFileLog(LPCTSTR FileName, bool FlushFile, LOG_OPEN_MODE eMode, uint32_t dwMaxFileSize) : +CTraceFileLog::CTraceFileLog(LPCTSTR FileName, bool FlushFile, LOG_OPEN_MODE eMode, size_t dwMaxFileSize) : m_FlushFile(FlushFile) { enum { MB = 1024 * 1024 }; @@ -199,14 +199,11 @@ m_FlushFile(FlushFile) m_hLogFile.SetFlush(false); m_hLogFile.SetTruncateFile(true); - if (dwMaxFileSize < 2048 && dwMaxFileSize > 2) - { - m_hLogFile.SetMaxFileSize(dwMaxFileSize * MB); - } - else - { - m_hLogFile.SetMaxFileSize(5 * MB); + if (dwMaxFileSize < 3 || dwMaxFileSize > 2047) + { /* Clamp file size to 5 MB if it exceeds 2047 or falls short of 3. */ + dwMaxFileSize = 5; } + m_hLogFile.SetMaxFileSize(dwMaxFileSize * MB); m_hLogFile.Open(FileName, eMode); } diff --git a/Source/Common/Trace.h b/Source/Common/Trace.h index d3b170633..2e8e2f0cd 100644 --- a/Source/Common/Trace.h +++ b/Source/Common/Trace.h @@ -26,7 +26,7 @@ class CTraceFileLog : public CTraceModule public: CTraceFileLog (const char * FileName, bool FlushFile = true); - CTraceFileLog (const char * FileName, bool FlushFile, LOG_OPEN_MODE eMode, uint32_t dwMaxFileSize = 5); + CTraceFileLog(const char * FileName, bool FlushFile, LOG_OPEN_MODE eMode, size_t dwMaxFileSize = 5); virtual ~CTraceFileLog (); void Write ( const char * Message, bool EndOfLine ); From a3cac34c74c5e7dc9b6d89e823bfc41b294214ed Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Nov 2015 13:02:45 -0500 Subject: [PATCH 076/213] [Common] CFile::Write(): Use standard memory size input type. --- Source/Common/File Class.cpp | 10 +++++++--- Source/Common/File Class.h | 4 ++-- Source/Common/Log Class.cpp | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Source/Common/File Class.cpp b/Source/Common/File Class.cpp index 2e7a25d69..39166f792 100644 --- a/Source/Common/File Class.cpp +++ b/Source/Common/File Class.cpp @@ -140,15 +140,19 @@ bool CFile::Flush() return ::FlushFileBuffers(m_hFile) != 0; } -bool CFile::Write(const void* lpBuf, uint32_t nCount) +bool CFile::Write(const void* lpBuf, size_t nCount) { if (nCount == 0) { return true; // avoid Win32 "null-write" option } + if (nCount > ULONG_MAX) + { + nCount = ULONG_MAX; /* Or should we loop WriteFile() every 2 GB? */ + } - ULONG nWritten = 0; - if (!::WriteFile(m_hFile, lpBuf, nCount, &nWritten, NULL)) + DWORD nWritten = 0; + if (!::WriteFile(m_hFile, lpBuf, (DWORD)nCount, &nWritten, NULL)) { return false; } diff --git a/Source/Common/File Class.h b/Source/Common/File Class.h index fc734f633..b47709da0 100644 --- a/Source/Common/File Class.h +++ b/Source/Common/File Class.h @@ -41,7 +41,7 @@ public: virtual uint32_t GetLength() const = 0; virtual uint32_t Read(void* lpBuf, uint32_t nCount) = 0; - virtual bool Write(const void* lpBuf, uint32_t nCount) = 0; + virtual bool Write(const void* lpBuf, size_t nCount) = 0; virtual bool Flush() = 0; virtual bool Close() = 0; @@ -79,7 +79,7 @@ public: virtual uint32_t GetLength() const; virtual uint32_t Read(void* lpBuf, uint32_t nCount); - virtual bool Write(const void* lpBuf, uint32_t nCount); + virtual bool Write(const void* lpBuf, size_t nCount); virtual bool Flush(); virtual bool Close(); diff --git a/Source/Common/Log Class.cpp b/Source/Common/Log Class.cpp index 95f001dba..4eebfc35a 100644 --- a/Source/Common/Log Class.cpp +++ b/Source/Common/Log Class.cpp @@ -120,7 +120,7 @@ void CLog::LogArgs(const char * Message, va_list & args ) void CLog::Log( const char * Message ) { if (!m_hLogFile.IsOpen()) { return; } - m_hLogFile.Write(Message,(uint32_t)strlen(Message)*sizeof(TCHAR)); + m_hLogFile.Write(Message, strlen(Message)*sizeof(TCHAR)); if (m_FlushOnWrite) { m_hLogFile.Flush(); From 258c540543d1de64cf25becc450ae514c54450d0 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Nov 2015 13:23:51 -0500 Subject: [PATCH 077/213] [Common] CFile::Read(): Use standard memory size input type. --- Source/Common/File Class.cpp | 10 +++++++--- Source/Common/File Class.h | 4 ++-- Source/Common/Log Class.cpp | 15 ++++++++------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Source/Common/File Class.cpp b/Source/Common/File Class.cpp index 39166f792..48acd893a 100644 --- a/Source/Common/File Class.cpp +++ b/Source/Common/File Class.cpp @@ -165,19 +165,23 @@ bool CFile::Write(const void* lpBuf, size_t nCount) return true; } -uint32_t CFile::Read(void* lpBuf, uint32_t nCount) +size_t CFile::Read(void* lpBuf, size_t nCount) { if (nCount == 0) { return 0; // avoid Win32 "null-read" } + if (nCount > ULONG_MAX) + { + nCount = ULONG_MAX; /* Or should we loop ReadFile() every 2 GB? */ + } DWORD dwRead = 0; - if (!::ReadFile(m_hFile, lpBuf, nCount, &dwRead, NULL)) + if (!::ReadFile(m_hFile, lpBuf, (DWORD)nCount, &dwRead, NULL)) { return 0; } - return (uint32_t)dwRead; + return (dwRead); } long CFile::Seek(long lOff, SeekPosition nFrom) diff --git a/Source/Common/File Class.h b/Source/Common/File Class.h index b47709da0..c61730450 100644 --- a/Source/Common/File Class.h +++ b/Source/Common/File Class.h @@ -40,7 +40,7 @@ public: virtual bool SetLength(uint32_t dwNewLen) = 0; virtual uint32_t GetLength() const = 0; - virtual uint32_t Read(void* lpBuf, uint32_t nCount) = 0; + virtual size_t Read(void* lpBuf, size_t nCount) = 0; virtual bool Write(const void* lpBuf, size_t nCount) = 0; virtual bool Flush() = 0; @@ -78,7 +78,7 @@ public: virtual bool SetLength(uint32_t dwNewLen); virtual uint32_t GetLength() const; - virtual uint32_t Read(void* lpBuf, uint32_t nCount); + virtual size_t Read(void* lpBuf, size_t nCount); virtual bool Write(const void* lpBuf, size_t nCount); virtual bool Flush(); diff --git a/Source/Common/Log Class.cpp b/Source/Common/Log Class.cpp index 4eebfc35a..a0a9560fd 100644 --- a/Source/Common/Log Class.cpp +++ b/Source/Common/Log Class.cpp @@ -145,13 +145,13 @@ void CLog::Log( const char * Message ) m_hLogFile.Seek((end - m_MaxFileSize) + m_FileChangeSize,CFile::begin); // Find next end of line - uint32_t NextEnter = 0, dwRead = 0; + size_t NextEnter = 0, dwRead = 0; do { BYTE Data[300]; - uint32_t dwRead; + size_t dwRead; - dwRead = m_hLogFile.Read(Data,sizeof(Data)); + dwRead = m_hLogFile.Read(Data, sizeof(Data)); if (dwRead == 0) { break; @@ -170,8 +170,9 @@ void CLog::Log( const char * Message ) } while(dwRead != 0); // copy content of log to the new file - uint32_t ReadPos = (end - m_MaxFileSize) + m_FileChangeSize + NextEnter; - uint32_t SizeToRead, WritePos = 0; + size_t ReadPos = (end - m_MaxFileSize) + m_FileChangeSize + NextEnter; + uint32_t WritePos = 0; + size_t SizeToRead; do { enum { fIS_MvSize = 0x5000 }; @@ -182,8 +183,8 @@ void CLog::Log( const char * Message ) m_hLogFile.Seek(ReadPos,CFile::begin); - uint32_t dwRead; - dwRead = m_hLogFile.Read(Data,SizeToRead); + size_t dwRead; + dwRead = m_hLogFile.Read(Data, SizeToRead); m_hLogFile.Seek(WritePos,CFile::begin); From d56236356a1b3c30c74e1a32143f8d7a18bce9db Mon Sep 17 00:00:00 2001 From: zilmar Date: Sat, 7 Nov 2015 07:51:41 +1100 Subject: [PATCH 078/213] [Project64] Fix showing file name in break point --- Source/Project64/User Interface/Notification Class.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Project64/User Interface/Notification Class.cpp b/Source/Project64/User Interface/Notification Class.cpp index bb758782c..bbeb27394 100644 --- a/Source/Project64/User Interface/Notification Class.cpp +++ b/Source/Project64/User Interface/Notification Class.cpp @@ -317,7 +317,7 @@ void CNotification::BreakPoint ( const wchar_t * FileName, const int LineNumber { if (g_Settings->LoadBool(Debugger_Enabled)) { - DisplayError(stdstr_f("Break point found at\n%s\n%d",FileName, LineNumber).ToUTF16().c_str()); + DisplayError(stdstr_f("Break point found at\n%ws\n%d", FileName, LineNumber).ToUTF16().c_str()); if (IsDebuggerPresent() != 0) { DebugBreak(); From 6585657d05d2c46db3705398633e7e00d54e047d Mon Sep 17 00:00:00 2001 From: zilmar Date: Sat, 7 Nov 2015 08:22:02 +1100 Subject: [PATCH 079/213] [Project64] Change CDebugger to CDebuggerUI --- Source/Project64/Debugger.h | 1 + .../N64 System/Debugger/Debug Dialog.h | 128 +- .../Debugger/Debugger - Memory Dump.cpp | 681 ++------ .../Debugger/Debugger - Memory Dump.h | 36 +- .../Debugger/Debugger - Memory Search.cpp | 1388 ++++++++--------- .../Debugger/Debugger - Memory Search.h | 94 +- .../N64 System/Debugger/Debugger - TLB.cpp | 474 +++--- .../N64 System/Debugger/Debugger - TLB.h | 19 +- .../Debugger/Debugger - View Memory.cpp | 793 +++++----- .../Debugger/Debugger - View Memory.h | 70 +- .../N64 System/Debugger/Debugger UI.h | 39 +- .../N64 System/Debugger/Debugger.cpp | 202 +-- .../Project64/N64 System/Debugger/debugger.h | 44 +- Source/Project64/N64 System/N64 Class.cpp | 16 +- Source/Project64/N64 System/N64 Class.h | 38 +- .../Project64/N64 System/System Globals.cpp | 1 + Source/Project64/N64 System/System Globals.h | 3 + Source/Project64/Project64.vcproj | 4 + Source/Project64/Settings.h | 33 +- Source/Project64/Settings/Settings Class.cpp | 1 + Source/Project64/User Interface/Gui Class.h | 21 +- .../User Interface/Main Menu Class.cpp | 10 +- 22 files changed, 1821 insertions(+), 2275 deletions(-) create mode 100644 Source/Project64/Debugger.h diff --git a/Source/Project64/Debugger.h b/Source/Project64/Debugger.h new file mode 100644 index 000000000..7b9637ef9 --- /dev/null +++ b/Source/Project64/Debugger.h @@ -0,0 +1 @@ +#pragma once \ No newline at end of file diff --git a/Source/Project64/N64 System/Debugger/Debug Dialog.h b/Source/Project64/N64 System/Debugger/Debug Dialog.h index 519b02338..7e058426e 100644 --- a/Source/Project64/N64 System/Debugger/Debug Dialog.h +++ b/Source/Project64/N64 System/Debugger/Debug Dialog.h @@ -1,76 +1,76 @@ template class CDebugDialog : - public CDialogImpl + public CDialogImpl < T > { protected: - CDebugger * m_Debugger; - HANDLE m_CreatedEvent; - HANDLE m_DialogThread; + CDebuggerUI * m_Debugger; + HANDLE m_CreatedEvent; + HANDLE m_DialogThread; - static DWORD CreateDebuggerWindow (CDebugDialog * pThis) - { - pThis->DoModal(NULL); - pThis->WindowCreated(); - return 0; - } + static DWORD CreateDebuggerWindow(CDebugDialog * pThis) + { + pThis->DoModal(NULL); + pThis->WindowCreated(); + return 0; + } - void WindowCreated ( void ) - { - SetEvent(m_CreatedEvent); - } + void WindowCreated(void) + { + SetEvent(m_CreatedEvent); + } public: - CDebugDialog (CDebugger * debugger) : - m_Debugger(debugger), - m_CreatedEvent(CreateEvent(NULL,true,false,NULL)), - m_DialogThread(NULL) - { - } - virtual ~CDebugDialog (void) - { - HideWindow(); - CloseHandle(m_CreatedEvent); - if (m_DialogThread) - { - CloseHandle(m_DialogThread); - m_DialogThread = NULL; - } - } + CDebugDialog(CDebuggerUI * debugger) : + m_Debugger(debugger), + m_CreatedEvent(CreateEvent(NULL, true, false, NULL)), + m_DialogThread(NULL) + { + } + virtual ~CDebugDialog(void) + { + HideWindow(); + CloseHandle(m_CreatedEvent); + if (m_DialogThread) + { + CloseHandle(m_DialogThread); + m_DialogThread = NULL; + } + } - void HideWindow ( void ) - { - if (m_hWnd && ::IsWindow(m_hWnd)) - { - ::EndDialog(m_hWnd, 0); - } - if (m_DialogThread) - { - if (WaitForSingleObject(m_DialogThread, 5000) == WAIT_TIMEOUT) - { - WriteTrace(TraceError,"CDebugDialog - time out on close"); + void HideWindow(void) + { + if (m_hWnd && ::IsWindow(m_hWnd)) + { + ::EndDialog(m_hWnd, 0); + } + if (m_DialogThread) + { + if (WaitForSingleObject(m_DialogThread, 5000) == WAIT_TIMEOUT) + { + WriteTrace(TraceError, "CDebugDialog - time out on close"); - TerminateThread(m_DialogThread, 1); - } - CloseHandle(m_DialogThread); - m_DialogThread = NULL; - } - } + TerminateThread(m_DialogThread, 1); + } + CloseHandle(m_DialogThread); + m_DialogThread = NULL; + } + } - void ShowWindow ( void ) - { - if (m_hWnd) - { - SetForegroundWindow((HWND)m_hWnd); - } - else - { - DWORD ThreadID; - ResetEvent(m_CreatedEvent); - m_DialogThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)CreateDebuggerWindow,(LPVOID)this,0, &ThreadID); - if (WaitForSingleObject(m_CreatedEvent,20000) == WAIT_TIMEOUT) - { - WriteTrace(TraceError,"Failed to get window create notification"); - } - } - } + void ShowWindow(void) + { + if (m_hWnd) + { + SetForegroundWindow((HWND)m_hWnd); + } + else + { + DWORD ThreadID; + ResetEvent(m_CreatedEvent); + m_DialogThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CreateDebuggerWindow, (LPVOID)this, 0, &ThreadID); + if (WaitForSingleObject(m_CreatedEvent, 20000) == WAIT_TIMEOUT) + { + WriteTrace(TraceError, "Failed to get window create notification"); + } + } + } }; diff --git a/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.cpp b/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.cpp index 8d9ec77df..5921c429a 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.cpp @@ -10,11 +10,10 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI #include "Debugger UI.h" -CDumpMemory::CDumpMemory(CDebugger * debugger) : - CDebugDialog(debugger) +CDumpMemory::CDumpMemory(CDebuggerUI * debugger) : + CDebugDialog(debugger) { } @@ -24,575 +23,135 @@ CDumpMemory::~CDumpMemory() LRESULT CDumpMemory::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { - m_StartAddress.Attach(GetDlgItem(IDC_E_START_ADDR)); - m_EndAddress.Attach(GetDlgItem(IDC_E_END_ADDR)); - m_PC.Attach(GetDlgItem(IDC_E_ALT_PC)); + m_StartAddress.Attach(GetDlgItem(IDC_E_START_ADDR)); + m_EndAddress.Attach(GetDlgItem(IDC_E_END_ADDR)); + m_PC.Attach(GetDlgItem(IDC_E_ALT_PC)); - m_StartAddress.SetDisplayType(CEditNumber::DisplayHex); - m_EndAddress.SetDisplayType(CEditNumber::DisplayHex); - m_PC.SetDisplayType(CEditNumber::DisplayHex); + m_StartAddress.SetDisplayType(CEditNumber::DisplayHex); + m_EndAddress.SetDisplayType(CEditNumber::DisplayHex); + m_PC.SetDisplayType(CEditNumber::DisplayHex); - m_StartAddress.SetValue(0x80000000,true,true); - m_EndAddress.SetValue(0x803FFFF0,true,true); - m_PC.SetValue(0x80000000); - HWND hFormatList = GetDlgItem(IDC_FORMAT); - int pos = ::SendMessage(hFormatList,CB_ADDSTRING,(WPARAM)0,(LPARAM)"TEXT - Disassembly + PC"); - ::SendMessage(hFormatList,CB_SETITEMDATA,(WPARAM)pos,(LPARAM)DisassemblyWithPC); - ::SendMessage(hFormatList,CB_SETCURSEL,(WPARAM)0,(LPARAM)0); + m_StartAddress.SetValue(0x80000000, true, true); + m_EndAddress.SetValue(0x803FFFF0, true, true); + m_PC.SetValue(0x80000000); + HWND hFormatList = GetDlgItem(IDC_FORMAT); + int pos = ::SendMessage(hFormatList, CB_ADDSTRING, (WPARAM)0, (LPARAM)"TEXT - Disassembly + PC"); + ::SendMessage(hFormatList, CB_SETITEMDATA, (WPARAM)pos, (LPARAM)DisassemblyWithPC); + ::SendMessage(hFormatList, CB_SETCURSEL, (WPARAM)0, (LPARAM)0); - WindowCreated(); - return TRUE; + WindowCreated(); + return TRUE; } LRESULT CDumpMemory::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { - switch(wID) - { - case IDCANCEL: - EndDialog(0); - break; - case IDC_BTN_CHOOSE_FILE: - { - char FileName[_MAX_PATH],Directory[_MAX_PATH]; - OPENFILENAME openfilename; + switch (wID) + { + case IDCANCEL: + EndDialog(0); + break; + case IDC_BTN_CHOOSE_FILE: + { + char FileName[_MAX_PATH], Directory[_MAX_PATH]; + OPENFILENAME openfilename; - memset(&FileName, 0, sizeof(FileName)); - memset(&openfilename, 0, sizeof(openfilename)); - strcpy(Directory,CPath(CPath::MODULE_DIRECTORY)); - openfilename.lStructSize = sizeof( openfilename ); - openfilename.hwndOwner = m_hWnd; - openfilename.lpstrFilter = "Text file (*.txt)\0*.txt;\0All files (*.*)\0*.*\0"; - openfilename.lpstrFile = FileName; - openfilename.lpstrInitialDir = Directory; - openfilename.nMaxFile = MAX_PATH; - openfilename.Flags = OFN_HIDEREADONLY; - g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory); - if (GetOpenFileName (&openfilename)) - { - char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; - _splitpath( FileName, drive, dir, fname, ext ); - if (strlen(ext) == 0) - { - strcat(FileName,".txt"); - } - SetDlgItemText(IDC_FILENAME,FileName); - } - g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory); - } - break; - case IDOK: - { - TCHAR FileName[MAX_PATH]; - int CurrentFormatSel = SendDlgItemMessage(IDC_FORMAT,CB_GETCURSEL,0,0); - DumpFormat Format = (DumpFormat)SendDlgItemMessage(IDC_FORMAT,CB_GETITEMDATA,CurrentFormatSel,0); - DWORD StartPC =m_StartAddress.GetValue(); - DWORD EndPC = m_EndAddress.GetValue(); - DWORD DumpPC = m_PC.GetValue(); - GetDlgItemText(IDC_FILENAME,FileName,sizeof(FileName)); - if (strlen(FileName) == 0) - { - g_Notify->DisplayError(L"Please Choose target file"); - ::SetFocus(GetDlgItem(IDC_FILENAME)); - return false; - } - if (SendDlgItemMessage(IDC_USE_ALT_PC,BM_GETSTATE, 0,0) != BST_CHECKED) - { - DumpPC = g_Reg->m_PROGRAM_COUNTER; - } - //disable buttons - ::EnableWindow(GetDlgItem(IDC_E_START_ADDR),FALSE); - ::EnableWindow(GetDlgItem(IDC_E_END_ADDR),FALSE); - ::EnableWindow(GetDlgItem(IDC_E_ALT_PC),FALSE); - ::EnableWindow(GetDlgItem(IDC_USE_ALT_PC),FALSE); - ::EnableWindow(GetDlgItem(IDC_FILENAME),FALSE); - ::EnableWindow(GetDlgItem(IDC_BTN_CHOOSE_FILE),FALSE); - ::EnableWindow(GetDlgItem(IDC_FORMAT),FALSE); - ::EnableWindow(GetDlgItem(IDOK),FALSE); - ::EnableWindow(GetDlgItem(IDCANCEL),FALSE); - g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory); - if (!DumpMemory(FileName,Format,StartPC,EndPC,DumpPC)) - { - //enable buttons - g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory); - return false; - } - g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory); - } - EndDialog(0); - break; - } - return FALSE; + memset(&FileName, 0, sizeof(FileName)); + memset(&openfilename, 0, sizeof(openfilename)); + strcpy(Directory, CPath(CPath::MODULE_DIRECTORY)); + openfilename.lStructSize = sizeof(openfilename); + openfilename.hwndOwner = m_hWnd; + openfilename.lpstrFilter = "Text file (*.txt)\0*.txt;\0All files (*.*)\0*.*\0"; + openfilename.lpstrFile = FileName; + openfilename.lpstrInitialDir = Directory; + openfilename.nMaxFile = MAX_PATH; + openfilename.Flags = OFN_HIDEREADONLY; + g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory); + if (GetOpenFileName(&openfilename)) + { + char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; + _splitpath(FileName, drive, dir, fname, ext); + if (strlen(ext) == 0) + { + strcat(FileName, ".txt"); + } + SetDlgItemText(IDC_FILENAME, FileName); + } + g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory); + } + break; + case IDOK: + { + TCHAR FileName[MAX_PATH]; + int CurrentFormatSel = SendDlgItemMessage(IDC_FORMAT, CB_GETCURSEL, 0, 0); + DumpFormat Format = (DumpFormat)SendDlgItemMessage(IDC_FORMAT, CB_GETITEMDATA, CurrentFormatSel, 0); + DWORD StartPC = m_StartAddress.GetValue(); + DWORD EndPC = m_EndAddress.GetValue(); + DWORD DumpPC = m_PC.GetValue(); + GetDlgItemText(IDC_FILENAME, FileName, sizeof(FileName)); + if (strlen(FileName) == 0) + { + g_Notify->DisplayError(L"Please Choose target file"); + ::SetFocus(GetDlgItem(IDC_FILENAME)); + return false; + } + if (SendDlgItemMessage(IDC_USE_ALT_PC, BM_GETSTATE, 0, 0) != BST_CHECKED) + { + DumpPC = g_Reg->m_PROGRAM_COUNTER; + } + //disable buttons + ::EnableWindow(GetDlgItem(IDC_E_START_ADDR), FALSE); + ::EnableWindow(GetDlgItem(IDC_E_END_ADDR), FALSE); + ::EnableWindow(GetDlgItem(IDC_E_ALT_PC), FALSE); + ::EnableWindow(GetDlgItem(IDC_USE_ALT_PC), FALSE); + ::EnableWindow(GetDlgItem(IDC_FILENAME), FALSE); + ::EnableWindow(GetDlgItem(IDC_BTN_CHOOSE_FILE), FALSE); + ::EnableWindow(GetDlgItem(IDC_FORMAT), FALSE); + ::EnableWindow(GetDlgItem(IDOK), FALSE); + ::EnableWindow(GetDlgItem(IDCANCEL), FALSE); + g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_DumpMemory); + if (!DumpMemory(FileName, Format, StartPC, EndPC, DumpPC)) + { + //enable buttons + g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory); + return false; + } + g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_DumpMemory); + } + EndDialog(0); + break; + } + return FALSE; } -//#include "..\\..\\User Interface.h" -//#include "..\\..\\N64 System.h" -//#include -// -//DWORD CDumpMemory::m_StartAddress = 0x80000000; -//DWORD CDumpMemory::m_EndAddress = 0x803FFFF0; -//CDumpMemory::CDumpMemory(CMipsMemory * MMU) : -// m_Window(NULL), g_MMU(MMU) -//{ -//} -//CDumpMemory::~CDumpMemory() -//{ -//} -//void CDumpMemory::DisplayDump(HWND & hParent) -//{ -// DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Cheats_DumpMemory), -// (HWND)hParent, (DLGPROC)WinProc,(LPARAM)this); -//} -//DWORD CDumpMemory::AsciiToHex (const char * HexValue) -//{ -// DWORD Count, Finish, Value = 0; -// Finish = strlen(HexValue); -// if (Finish > 8 ) -// { -// Finish = 8; -// } -// for (Count = 0; Count < Finish; Count++ -// { -// Value = (Value << 4); -// switch ( HexValue[Count] ) -// { -// case '0': break; -// case '1': Value += 1; break; -// case '2': Value += 2; break; -// case '3': Value += 3; break; -// case '4': Value += 4; break; -// case '5': Value += 5; break; -// case '6': Value += 6; break; -// case '7': Value += 7; break; -// case '8': Value += 8; break; -// case '9': Value += 9; break; -// case 'A': Value += 10; break; -// case 'a': Value += 10; break; -// case 'B': Value += 11; break; -// case 'b': Value += 11; break; -// case 'C': Value += 12; break; -// case 'c': Value += 12; break; -// case 'D': Value += 13; break; -// case 'd': Value += 13; break; -// case 'E': Value += 14; break; -// case 'e': Value += 14; break; -// case 'F': Value += 15; break; -// case 'f': Value += 15; break; -// default: -// Value = (Value >> 4); -// Count = Finish; -// } -// } -// return Value; -//} -//int CALLBACK CDumpMemory::WinProc (HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam) -//{ -// switch (uMsg) -// { -// case WM_INITDIALOG: -// { -// CDumpMemory * _this = (CDumpMemory *)lParam; -// SetProp(hDlg,"Class",_this); -// _this->m_Window = hDlg; -// SetDlgItemText(hDlg,IDC_E_START_ADDR,stdstr("0x%X",m_StartAddress).c_str()); -// SetDlgItemText(hDlg,IDC_E_END_ADDR,stdstr("0x%X",m_EndAddress).c_str()); -// SetDlgItemText(hDlg,IDC_E_ALT_PC,"0x80000000"); -// HWND hFormatList = GetDlgItem(hDlg,IDC_FORMAT); -// int pos = SendMessage(hFormatList,CB_ADDSTRING,(WPARAM)0,(LPARAM)"TEXT - Disassembly + PC"); -// SendMessage(hFormatList,CB_SETITEMDATA,(WPARAM)pos,(LPARAM)DisassemblyWithPC); -// SendMessage(hFormatList,CB_SETCURSEL,(WPARAM)0,(LPARAM)0); -// } -// break; -// case WM_COMMAND: -// switch (LOWORD(wParam)) -// { -// case IDC_E_START_ADDR: -// case IDC_E_END_ADDR: -// case IDC_E_ALT_PC: -// if (HIWORD(wParam) == EN_UPDATE) -// { -// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class"); -// TCHAR szTmp[20], szTmp2[20]; -// DWORD Value; -// GetDlgItemText(hDlg,LOWORD(wParam),szTmp,sizeof(szTmp)); -// Value = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp); -// //if (Value > Stop) -// //{ -// // Value = Stop; -// //} -// //if (Value < Start) -// //{ -// // Value = Start; -// //} -// sprintf(szTmp2,"0x%X",Value); -// if (strcmp(szTmp,szTmp2) != 0) -// { -// SetDlgItemText(hDlg,LOWORD(wParam),szTmp2); -// if (_this->SelStop == 0) -// { -// _this->SelStop = strlen(szTmp2); _this->SelStart = _this->SelStop; -// } -// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_SETSEL,(WPARAM)_this->SelStart,(LPARAM)_this->SelStop); -// } -// else -// { -// WORD NewSelStart, NewSelStop; -// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_GETSEL,(WPARAM)&NewSelStart,(LPARAM)&NewSelStop); -// if (NewSelStart != 0) -// { -// _this->SelStart = NewSelStart; _this->SelStop = NewSelStop; -// } -// } -// } -// break; -// case IDC_BTN_CHOOSE_FILE: -// { -// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class"); -// OPENFILENAME openfilename; -// char FileName[_MAX_PATH],Directory[_MAX_PATH]; -// memset(&FileName, 0, sizeof(FileName)); -// memset(&openfilename, 0, sizeof(openfilename)); -// strcpy(Directory,g_Settings->LoadStringVal(ApplicationDir).c_str()); -// openfilename.lStructSize = sizeof( openfilename ); -// openfilename.hwndOwner = hDlg; -// openfilename.lpstrFilter = "Text file (*.txt)\0*.txt;\0All files (*.*)\0*.*\0"; -// openfilename.lpstrFile = FileName; -// openfilename.lpstrInitialDir = Directory; -// openfilename.nMaxFile = MAX_PATH; -// openfilename.Flags = OFN_HIDEREADONLY; -// if (GetOpenFileName (&openfilename)) -// { -// char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; -// _splitpath( FileName, drive, dir, fname, ext ); -// if (strlen(ext) == 0) -// { -// strcat(FileName,".txt"); -// } -// SetDlgItemText(hDlg,IDC_FILENAME,FileName); -// } -// } -// break; -// case IDCANCEL: -// RemoveProp(hDlg,"Class"); -// EndDialog(hDlg,0); -// break; -// case IDOK: -// { -// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class"); -// TCHAR szTmp[20], FileName[MAX_PATH]; -// int CurrentFormatSel = SendDlgItemMessage(hDlg,IDC_FORMAT,CB_GETCURSEL,0,0); -// DumpFormat Format = (DumpFormat)SendDlgItemMessage(hDlg,IDC_FORMAT,CB_GETITEMDATA,CurrentFormatSel,0); -// GetDlgItemText(hDlg,IDC_E_START_ADDR,szTmp,sizeof(szTmp)); -// DWORD StartPC = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp); -// GetDlgItemText(hDlg,IDC_E_END_ADDR,szTmp,sizeof(szTmp)); -// DWORD EndPC = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp); -// GetDlgItemText(hDlg,IDC_E_ALT_PC,szTmp,sizeof(szTmp)); -// DWORD DumpPC = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp); -// GetDlgItemText(hDlg,IDC_FILENAME,FileName,sizeof(FileName)); -// if (strlen(FileName) == 0) -// { -// g_Notify->DisplayError(L"Please Choose target file"); -// SetFocus(GetDlgItem(hDlg,IDC_FILENAME)); -// return false; -// } -// if (SendDlgItemMessage(hDlg,IDC_USE_ALT_PC,BM_GETSTATE, 0,0) != BST_CHECKED) -// { -// DumpPC = _this->g_MMU->SystemRegisters()->PROGRAM_COUNTER; -// } -// //disable buttons -// EnableWindow(GetDlgItem(hDlg,IDC_E_START_ADDR),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_E_END_ADDR),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_E_ALT_PC),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_USE_ALT_PC),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_FILENAME),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_BTN_CHOOSE_FILE),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_FORMAT),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDOK),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDCANCEL),FALSE); -// if (!_this->DumpMemory(FileName,Format,StartPC,EndPC,DumpPC)) -// { -// //enable buttons -// return false; -// } -// } -// RemoveProp(hDlg,"Class"); -// EndDialog(hDlg,0); -// break; -// } -// break; -// default: -// return false; -// } -// return true; -//} - -bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD /*DumpPC*/ ) +bool CDumpMemory::DumpMemory(LPCSTR FileName, DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD /*DumpPC*/) { - switch (Format) - { - case DisassemblyWithPC: - { - CLog LogFile; - if (!LogFile.Open(FileName)) - { - g_Notify->DisplayError(stdstr_f("Failed to open\n%s",FileName).ToUTF16().c_str()); - return false; - } - LogFile.SetFlush(false); - LogFile.SetTruncateFile(false); - g_Notify->BreakPoint(__FILEW__,__LINE__); + switch (Format) + { + case DisassemblyWithPC: + { + CLog LogFile; + if (!LogFile.Open(FileName)) + { + g_Notify->DisplayError(stdstr_f("Failed to open\n%s", FileName).ToUTF16().c_str()); + return false; + } + LogFile.SetFlush(false); + LogFile.SetTruncateFile(false); + g_Notify->BreakPoint(__FILEW__, __LINE__); #ifdef tofix - char Command[200]; - for (COpcode OpCode(StartPC); OpCode.PC() < EndPC; OpCode.Next()) - { - const char * szOpName = OpCode.OpcodeName(); - OpCode.OpcodeParam(Command); - LogFile.LogF("%X: %-15s%s\r\n",OpCode.PC(),szOpName,Command); - } + char Command[200]; + for (COpcode OpCode(StartPC); OpCode.PC() < EndPC; OpCode.Next()) + { + const char * szOpName = OpCode.OpcodeName(); + OpCode.OpcodeParam(Command); + LogFile.LogF("%X: %-15s%s\r\n",OpCode.PC(),szOpName,Command); + } #endif - m_StartAddress.SetValue(StartPC,true,true); - m_EndAddress.SetValue(EndPC,true,true); - return true; - } - break; - } - return false; + m_StartAddress.SetValue(StartPC, true, true); + m_EndAddress.SetValue(EndPC, true, true); + return true; + } + break; + } + return false; } -// -//CDumpMemory::CDumpMemory(CMipsMemory * MMU) : -// m_Window(NULL), g_MMU(MMU) -//{ -//} -// -//CDumpMemory::~CDumpMemory() -//{ -//} -// -//void CDumpMemory::DisplayDump(HWND & hParent) -//{ -// DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Cheats_DumpMemory), -// (HWND)hParent, (DLGPROC)WinProc,(LPARAM)this); -//} -// -//DWORD CDumpMemory::AsciiToHex (const char * HexValue) -//{ -// DWORD Count, Finish, Value = 0; -// -// Finish = strlen(HexValue); -// if (Finish > 8 ) -// { -// Finish = 8; -// } -// -// for (Count = 0; Count < Finish; Count++) -// { -// Value = (Value << 4); -// switch ( HexValue[Count] ) -// { -// case '0': break; -// case '1': Value += 1; break; -// case '2': Value += 2; break; -// case '3': Value += 3; break; -// case '4': Value += 4; break; -// case '5': Value += 5; break; -// case '6': Value += 6; break; -// case '7': Value += 7; break; -// case '8': Value += 8; break; -// case '9': Value += 9; break; -// case 'A': Value += 10; break; -// case 'a': Value += 10; break; -// case 'B': Value += 11; break; -// case 'b': Value += 11; break; -// case 'C': Value += 12; break; -// case 'c': Value += 12; break; -// case 'D': Value += 13; break; -// case 'd': Value += 13; break; -// case 'E': Value += 14; break; -// case 'e': Value += 14; break; -// case 'F': Value += 15; break; -// case 'f': Value += 15; break; -// default: -// Value = (Value >> 4); -// Count = Finish; -// } -// } -// return Value; -//} -// -//int CALLBACK CDumpMemory::WinProc (HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam) -//{ -// switch (uMsg) -// { -// case WM_INITDIALOG: -// { -// CDumpMemory * _this = (CDumpMemory *)lParam; -// SetProp(hDlg,"Class",_this); -// _this->m_Window = hDlg; -// SetDlgItemText(hDlg,IDC_E_START_ADDR,stdstr("0x%X",m_StartAddress).c_str()); -// SetDlgItemText(hDlg,IDC_E_END_ADDR,stdstr("0x%X",m_EndAddress).c_str()); -// SetDlgItemText(hDlg,IDC_E_ALT_PC,"0x80000000"); -// -// HWND hFormatList = GetDlgItem(hDlg,IDC_FORMAT); -// int pos = SendMessage(hFormatList,CB_ADDSTRING,(WPARAM)0,(LPARAM)"TEXT - Disassembly + PC"); -// SendMessage(hFormatList,CB_SETITEMDATA,(WPARAM)pos,(LPARAM)DisassemblyWithPC); -// SendMessage(hFormatList,CB_SETCURSEL,(WPARAM)0,(LPARAM)0); -// -// } -// break; -// case WM_COMMAND: -// switch (LOWORD(wParam)) -// { -// case IDC_E_START_ADDR: -// case IDC_E_END_ADDR: -// case IDC_E_ALT_PC: -// if (HIWORD(wParam) == EN_UPDATE) -// { -// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class"); -// -// TCHAR szTmp[20], szTmp2[20]; -// DWORD Value; -// -// GetDlgItemText(hDlg,LOWORD(wParam),szTmp,sizeof(szTmp)); -// Value = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp); -// //if (Value > Stop) -// //{ -// // Value = Stop; -// //} -// //if (Value < Start) -// //{ -// // Value = Start; -// //} -// sprintf(szTmp2,"0x%X",Value); -// if (strcmp(szTmp,szTmp2) != 0) -// { -// SetDlgItemText(hDlg,LOWORD(wParam),szTmp2); -// if (_this->SelStop == 0) { _this->SelStop = strlen(szTmp2); _this->SelStart = _this->SelStop; } -// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_SETSEL,(WPARAM)_this->SelStart,(LPARAM)_this->SelStop); -// } -// else -// { -// WORD NewSelStart, NewSelStop; -// SendDlgItemMessage(hDlg,LOWORD(wParam),EM_GETSEL,(WPARAM)&NewSelStart,(LPARAM)&NewSelStop); -// if (NewSelStart != 0) -// { -// _this->SelStart = NewSelStart; _this->SelStop = NewSelStop; -// } -// } -// } -// break; -// case IDC_BTN_CHOOSE_FILE: -// { -// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class"); -// -// OPENFILENAME openfilename; -// char FileName[_MAX_PATH],Directory[_MAX_PATH]; -// -// memset(&FileName, 0, sizeof(FileName)); -// memset(&openfilename, 0, sizeof(openfilename)); -// -// strcpy(Directory,g_Settings->LoadStringVal(ApplicationDir).c_str()); -// -// openfilename.lStructSize = sizeof( openfilename ); -// openfilename.hwndOwner = hDlg; -// openfilename.lpstrFilter = "Text file (*.txt)\0*.txt;\0All files (*.*)\0*.*\0"; -// openfilename.lpstrFile = FileName; -// openfilename.lpstrInitialDir = Directory; -// openfilename.nMaxFile = MAX_PATH; -// openfilename.Flags = OFN_HIDEREADONLY; -// -// if (GetOpenFileName (&openfilename)) -// { -// char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; -// -// _splitpath( FileName, drive, dir, fname, ext ); -// if (strlen(ext) == 0) -// { -// strcat(FileName,".txt"); -// } -// SetDlgItemText(hDlg,IDC_FILENAME,FileName); -// } -// } -// break; -// case IDCANCEL: -// RemoveProp(hDlg,"Class"); -// EndDialog(hDlg,0); -// break; -// case IDOK: -// { -// CDumpMemory * _this = (CDumpMemory *)GetProp(hDlg,"Class"); -// TCHAR szTmp[20], FileName[MAX_PATH]; -// -// int CurrentFormatSel = SendDlgItemMessage(hDlg,IDC_FORMAT,CB_GETCURSEL,0,0); -// DumpFormat Format = (DumpFormat)SendDlgItemMessage(hDlg,IDC_FORMAT,CB_GETITEMDATA,CurrentFormatSel,0); -// -// GetDlgItemText(hDlg,IDC_E_START_ADDR,szTmp,sizeof(szTmp)); -// DWORD StartPC = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp); -// GetDlgItemText(hDlg,IDC_E_END_ADDR,szTmp,sizeof(szTmp)); -// DWORD EndPC = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp); -// GetDlgItemText(hDlg,IDC_E_ALT_PC,szTmp,sizeof(szTmp)); -// DWORD DumpPC = szTmp[1] =='x'?AsciiToHex(&szTmp[2]):AsciiToHex(szTmp); -// GetDlgItemText(hDlg,IDC_FILENAME,FileName,sizeof(FileName)); -// -// if (strlen(FileName) == 0) -// { -// g_Notify->DisplayError(L"Please Choose target file"); -// SetFocus(GetDlgItem(hDlg,IDC_FILENAME)); -// return false; -// } -// -// if (SendDlgItemMessage(hDlg,IDC_USE_ALT_PC,BM_GETSTATE, 0,0) != BST_CHECKED) -// { -// DumpPC = _this->g_MMU->SystemRegisters()->PROGRAM_COUNTER; -// } -// //disable buttons -// EnableWindow(GetDlgItem(hDlg,IDC_E_START_ADDR),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_E_END_ADDR),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_E_ALT_PC),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_USE_ALT_PC),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_FILENAME),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_BTN_CHOOSE_FILE),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDC_FORMAT),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDOK),FALSE); -// EnableWindow(GetDlgItem(hDlg,IDCANCEL),FALSE); -// if (!_this->DumpMemory(FileName,Format,StartPC,EndPC,DumpPC)) -// { -// //enable buttons -// return false; -// } -// } -// RemoveProp(hDlg,"Class"); -// EndDialog(hDlg,0); -// break; -// } -// break; -// default: -// return false; -// } -// return true; -//} -// -//bool CDumpMemory::DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD DumpPC ) -//{ -// switch (Format) -// { -// case DisassemblyWithPC: -// { -// CLog LogFile(FileName); -// if (!LogFile.IsOpen()) -// { -// g_Notify->DisplayError(L"Failed to open\n%s",FileName); -// return false; -// } -// -// for (COpcode OpCode(g_MMU,StartPC); OpCode.PC() < EndPC; OpCode.Next()) -// { -// LogFile.Log("%X: %s",OpCode.PC(),OpCode.Name().c_str()); -// } -// m_StartAddress = StartPC; -// m_EndAddress = EndPC; -// return true; -// } -// break; -// } -// return false; -//} -#endif diff --git a/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.h b/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.h index 129aa4474..274b997ce 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.h +++ b/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.h @@ -11,33 +11,33 @@ #pragma once class CDumpMemory : - public CDebugDialog + public CDebugDialog < CDumpMemory > { -public: - enum { IDD = IDD_Cheats_DumpMemory }; +public: + enum { IDD = IDD_Cheats_DumpMemory }; - CDumpMemory(CDebugger * debugger); - virtual ~CDumpMemory(void); + CDumpMemory(CDebuggerUI * debugger); + virtual ~CDumpMemory(void); private: - CDumpMemory(void); // Disable default constructor - CDumpMemory(const CDumpMemory&); // Disable copy constructor - CDumpMemory& operator=(const CDumpMemory&); // Disable assignment + CDumpMemory(void); // Disable default constructor + CDumpMemory(const CDumpMemory&); // Disable copy constructor + CDumpMemory& operator=(const CDumpMemory&); // Disable assignment - enum DumpFormat - { - DisassemblyWithPC - }; + enum DumpFormat + { + DisassemblyWithPC + }; - BEGIN_MSG_MAP_EX(CDumpMemory) - MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) - COMMAND_CODE_HANDLER(BN_CLICKED,OnClicked) - END_MSG_MAP() + BEGIN_MSG_MAP_EX(CDumpMemory) + MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) + COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked) + END_MSG_MAP() - LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled); - bool DumpMemory ( LPCSTR FileName,DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD DumpPC ); + bool DumpMemory(LPCSTR FileName, DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD DumpPC); CEditNumber m_StartAddress, m_EndAddress, m_PC; }; diff --git a/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp b/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp index 9ea8ddc66..763371662 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp @@ -10,783 +10,781 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI #include "Debugger UI.h" -CDebugMemorySearch::CDebugMemorySearch(CDebugger * debugger) : - CDebugDialog(debugger), - m_MemoryState(NULL), - m_MemoryStateSize(0) +CDebugMemorySearch::CDebugMemorySearch(CDebuggerUI * debugger) : + CDebugDialog(debugger), + m_MemoryState(NULL), + m_MemoryStateSize(0) { } CDebugMemorySearch::~CDebugMemorySearch() { - if (m_MemoryState) - { - delete m_MemoryState; - } + if (m_MemoryState) + { + delete m_MemoryState; + } } -void CDebugMemorySearch::AddAlignmentOptions (CComboBox & ctrl) +void CDebugMemorySearch::AddAlignmentOptions(CComboBox & ctrl) { - int Index = ctrl.AddString("32 bits (aligned)"); - ctrl.SetItemData(Index,_32Bit); - Index = ctrl.AddString("16bits (aligned)"); - ctrl.SetItemData(Index,_16Bit); - Index = ctrl.AddString("8bits"); - ctrl.SetCurSel(Index); - ctrl.SetItemData(Index,_8Bit); + int Index = ctrl.AddString("32 bits (aligned)"); + ctrl.SetItemData(Index, _32Bit); + Index = ctrl.AddString("16bits (aligned)"); + ctrl.SetItemData(Index, _16Bit); + Index = ctrl.AddString("8bits"); + ctrl.SetCurSel(Index); + ctrl.SetItemData(Index, _8Bit); } LRESULT CDebugMemorySearch::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { - m_PAddrStart.Attach(GetDlgItem(IDC_PADDR_START)); - m_PAddrStart.SetDisplayType(CEditNumber::DisplayHex); - m_SearchLen.Attach(GetDlgItem(IDC_ADDR_END)); - m_SearchLen.SetDisplayType(CEditNumber::DisplayHex); - m_SearchValue.Attach(GetDlgItem(IDC_SEARCH_VALUE)); - m_SearchValue.SetDisplayType(CEditNumber::DisplayDec); - m_SearchValue.SetValue(0); - m_MaxSearch.Attach(GetDlgItem(IDC_MAX_SEARCH)); - m_MaxSearch.SetDisplayType(CEditNumber::DisplayDec); - m_MaxSearch.SetValue(50000); - m_UnknownSize.Attach(GetDlgItem(IDC_UNKNOWN_ALIGN)); - AddAlignmentOptions(m_UnknownSize); - m_ValueSize.Attach(GetDlgItem(IDC_VALUE_ALIGN)); - AddAlignmentOptions(m_ValueSize); - m_SearchResults.Attach(GetDlgItem(IDC_LST_RESULTS)); - m_SearchResults.AddColumn("ID",0); - m_SearchResults.AddColumn("PAddr",1); - m_SearchResults.AddColumn("Value",2); - m_SearchResults.SetColumnWidth(0,50); - m_SearchResults.SetColumnWidth(1,75); - m_SearchResults.SetColumnWidth(2,75); - m_SearchResults.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT); - m_UnknownOptions.Attach(GetDlgItem(IDC_CMB_UNKNOWN)); - m_HaveResults = false; - FixUnknownOptions(true); + m_PAddrStart.Attach(GetDlgItem(IDC_PADDR_START)); + m_PAddrStart.SetDisplayType(CEditNumber::DisplayHex); + m_SearchLen.Attach(GetDlgItem(IDC_ADDR_END)); + m_SearchLen.SetDisplayType(CEditNumber::DisplayHex); + m_SearchValue.Attach(GetDlgItem(IDC_SEARCH_VALUE)); + m_SearchValue.SetDisplayType(CEditNumber::DisplayDec); + m_SearchValue.SetValue(0); + m_MaxSearch.Attach(GetDlgItem(IDC_MAX_SEARCH)); + m_MaxSearch.SetDisplayType(CEditNumber::DisplayDec); + m_MaxSearch.SetValue(50000); + m_UnknownSize.Attach(GetDlgItem(IDC_UNKNOWN_ALIGN)); + AddAlignmentOptions(m_UnknownSize); + m_ValueSize.Attach(GetDlgItem(IDC_VALUE_ALIGN)); + AddAlignmentOptions(m_ValueSize); + m_SearchResults.Attach(GetDlgItem(IDC_LST_RESULTS)); + m_SearchResults.AddColumn("ID", 0); + m_SearchResults.AddColumn("PAddr", 1); + m_SearchResults.AddColumn("Value", 2); + m_SearchResults.SetColumnWidth(0, 50); + m_SearchResults.SetColumnWidth(1, 75); + m_SearchResults.SetColumnWidth(2, 75); + m_SearchResults.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT); + m_UnknownOptions.Attach(GetDlgItem(IDC_CMB_UNKNOWN)); + m_HaveResults = false; + FixUnknownOptions(true); - SendMessage(GetDlgItem(IDC_RADIO_VALUE),BM_SETCHECK, BST_CHECKED,0); + SendMessage(GetDlgItem(IDC_RADIO_VALUE), BM_SETCHECK, BST_CHECKED, 0); - BOOL bHandled; - OnClicked(0,IDC_BTN_RDRAM,NULL,bHandled); - OnClicked(0,IDC_RADIO_VALUE,NULL,bHandled); - WindowCreated(); - return TRUE; + BOOL bHandled; + OnClicked(0, IDC_BTN_RDRAM, NULL, bHandled); + OnClicked(0, IDC_RADIO_VALUE, NULL, bHandled); + WindowCreated(); + return TRUE; } LRESULT CDebugMemorySearch::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND hWndCtl, BOOL& /*bHandled*/) { - switch(wID) - { - case IDCANCEL: - EndDialog(0); - break; - case IDC_BTN_RDRAM: - m_PAddrStart.SetValue(0,true,true); - m_SearchLen.SetValue(g_MMU->RdramSize(),true,true); - break; - case IDC_BTN_ROM: - m_PAddrStart.SetValue(0x10000000,true,true); - m_SearchLen.SetValue(g_Rom->GetRomSize(),true,true); - break; - case IDC_BTN_SPMEM: - m_PAddrStart.SetValue(0x04000000,true,true); - m_SearchLen.SetValue(0x2000,true,true); - break; - case IDC_SEARCH_HEX: - { - bool bChecked = (SendMessage(hWndCtl, BM_GETSTATE, 0,0) & BST_CHECKED) != 0; - m_SearchValue.SetDisplayType( bChecked ? CEditNumber::DisplayHex : CEditNumber::DisplayDec); - } - break; - case ID_POPUP_SHOWINMEMORYVIEWER: - { - LONG iItem = m_SearchResults.GetNextItem(-1, LVNI_SELECTED); - if (iItem == -1) - { - break; - } + switch (wID) + { + case IDCANCEL: + EndDialog(0); + break; + case IDC_BTN_RDRAM: + m_PAddrStart.SetValue(0, true, true); + m_SearchLen.SetValue(g_MMU->RdramSize(), true, true); + break; + case IDC_BTN_ROM: + m_PAddrStart.SetValue(0x10000000, true, true); + m_SearchLen.SetValue(g_Rom->GetRomSize(), true, true); + break; + case IDC_BTN_SPMEM: + m_PAddrStart.SetValue(0x04000000, true, true); + m_SearchLen.SetValue(0x2000, true, true); + break; + case IDC_SEARCH_HEX: + { + bool bChecked = (SendMessage(hWndCtl, BM_GETSTATE, 0, 0) & BST_CHECKED) != 0; + m_SearchValue.SetDisplayType(bChecked ? CEditNumber::DisplayHex : CEditNumber::DisplayDec); + } + break; + case ID_POPUP_SHOWINMEMORYVIEWER: + { + LONG iItem = m_SearchResults.GetNextItem(-1, LVNI_SELECTED); + if (iItem == -1) + { + break; + } - int ItemId = m_SearchResults.GetItemData(iItem); - SearchResultItem & Result = m_SearchResult[ItemId]; - m_Debugger->Debug_ShowMemoryLocation(Result.PAddr, false); - } - break; - case IDC_RADIO_UNKNOWN: - EnableUnknownOptions(true); - EnableValueOptions(false); - EnableTextOptions(false); - EnableJalOptions(false); - break; - case IDC_RADIO_VALUE: - EnableUnknownOptions(false); - EnableValueOptions(true); - EnableTextOptions(false); - EnableJalOptions(false); - break; - case IDC_RADIO_TEXT: - EnableUnknownOptions(false); - EnableValueOptions(false); - EnableTextOptions(true); - EnableJalOptions(false); - break; - case IDC_RADIO_JAL: - EnableUnknownOptions(false); - EnableValueOptions(false); - EnableTextOptions(false); - EnableJalOptions(true); - break; - case IDC_BTN_SEARCH: - if (SendMessage(GetDlgItem(IDC_RADIO_UNKNOWN),BM_GETSTATE, 0,0) == BST_CHECKED) - { - g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SearchMemory); - SearchForUnknown(); - g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SearchMemory); - break; - } - if (SendMessage(GetDlgItem(IDC_RADIO_VALUE),BM_GETSTATE, 0,0) == BST_CHECKED) - { - g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SearchMemory); - SearchForValue(); - g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SearchMemory); - break; - } - if (SendMessage(GetDlgItem(IDC_RADIO_TEXT),BM_GETSTATE, 0,0) == BST_CHECKED) - { - g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SearchMemory); - SearchForText(); - g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SearchMemory); - break; - } - case IDC_RESET_BUTTON: - Reset(); - break; - } - return FALSE; + int ItemId = m_SearchResults.GetItemData(iItem); + SearchResultItem & Result = m_SearchResult[ItemId]; + m_Debugger->Debug_ShowMemoryLocation(Result.PAddr, false); + } + break; + case IDC_RADIO_UNKNOWN: + EnableUnknownOptions(true); + EnableValueOptions(false); + EnableTextOptions(false); + EnableJalOptions(false); + break; + case IDC_RADIO_VALUE: + EnableUnknownOptions(false); + EnableValueOptions(true); + EnableTextOptions(false); + EnableJalOptions(false); + break; + case IDC_RADIO_TEXT: + EnableUnknownOptions(false); + EnableValueOptions(false); + EnableTextOptions(true); + EnableJalOptions(false); + break; + case IDC_RADIO_JAL: + EnableUnknownOptions(false); + EnableValueOptions(false); + EnableTextOptions(false); + EnableJalOptions(true); + break; + case IDC_BTN_SEARCH: + if (SendMessage(GetDlgItem(IDC_RADIO_UNKNOWN), BM_GETSTATE, 0, 0) == BST_CHECKED) + { + g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SearchMemory); + SearchForUnknown(); + g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SearchMemory); + break; + } + if (SendMessage(GetDlgItem(IDC_RADIO_VALUE), BM_GETSTATE, 0, 0) == BST_CHECKED) + { + g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SearchMemory); + SearchForValue(); + g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SearchMemory); + break; + } + if (SendMessage(GetDlgItem(IDC_RADIO_TEXT), BM_GETSTATE, 0, 0) == BST_CHECKED) + { + g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SearchMemory); + SearchForText(); + g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SearchMemory); + break; + } + case IDC_RESET_BUTTON: + Reset(); + break; + } + return FALSE; } -LRESULT CDebugMemorySearch::OnResultRClick ( LPNMHDR /*lpnmh*/ ) +LRESULT CDebugMemorySearch::OnResultRClick(LPNMHDR /*lpnmh*/) { - LONG iItem = m_SearchResults.GetNextItem(-1, LVNI_SELECTED); - if (iItem == -1) - { - return true; - } + LONG iItem = m_SearchResults.GetNextItem(-1, LVNI_SELECTED); + if (iItem == -1) + { + return true; + } - //Load the menu - HMENU hMenu = LoadMenu(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_MEM_SEARCH)); - HMENU hPopupMenu = GetSubMenu(hMenu,0); + //Load the menu + HMENU hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MEM_SEARCH)); + HMENU hPopupMenu = GetSubMenu(hMenu, 0); - //Get the current Mouse location - POINT Mouse; - GetCursorPos(&Mouse); + //Get the current Mouse location + POINT Mouse; + GetCursorPos(&Mouse); - //Show the menu - TrackPopupMenu(hPopupMenu, 0, Mouse.x, Mouse.y, 0,m_hWnd, NULL); - DestroyMenu(hMenu); - return true; + //Show the menu + TrackPopupMenu(hPopupMenu, 0, Mouse.x, Mouse.y, 0, m_hWnd, NULL); + DestroyMenu(hMenu); + return true; } -void CDebugMemorySearch::EnableValueOptions( bool Enable ) +void CDebugMemorySearch::EnableValueOptions(bool Enable) { - if (Enable) - { - ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),m_HaveResults ? "Search Results" : "Search"); - } - ::EnableWindow(GetDlgItem(IDC_SEARCH_VALUE),Enable); - ::EnableWindow(GetDlgItem(IDC_SEARCH_HEX),Enable); - ::EnableWindow(GetDlgItem(IDC_VALUE_ALIGN),m_HaveResults ? false : Enable ); + if (Enable) + { + ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), m_HaveResults ? "Search Results" : "Search"); + } + ::EnableWindow(GetDlgItem(IDC_SEARCH_VALUE), Enable); + ::EnableWindow(GetDlgItem(IDC_SEARCH_HEX), Enable); + ::EnableWindow(GetDlgItem(IDC_VALUE_ALIGN), m_HaveResults ? false : Enable); } -void CDebugMemorySearch::EnableTextOptions( bool Enable ) +void CDebugMemorySearch::EnableTextOptions(bool Enable) { - if (Enable) - { - ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),m_HaveResults ? "Search Results" : "Search"); - } - ::EnableWindow(GetDlgItem(IDC_SEARCH_TEXT),Enable); - ::EnableWindow(GetDlgItem(IDC_CASE_SENSITIVE),Enable); + if (Enable) + { + ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), m_HaveResults ? "Search Results" : "Search"); + } + ::EnableWindow(GetDlgItem(IDC_SEARCH_TEXT), Enable); + ::EnableWindow(GetDlgItem(IDC_CASE_SENSITIVE), Enable); } -void CDebugMemorySearch::EnableJalOptions( bool Enable ) +void CDebugMemorySearch::EnableJalOptions(bool Enable) { - if (Enable) - { - ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),m_HaveResults ? "Search Results" : "Search"); - } - ::EnableWindow(GetDlgItem(IDC_JAL_ADDR),Enable); + if (Enable) + { + ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), m_HaveResults ? "Search Results" : "Search"); + } + ::EnableWindow(GetDlgItem(IDC_JAL_ADDR), Enable); } -void CDebugMemorySearch::EnableUnknownOptions( bool Enable ) +void CDebugMemorySearch::EnableUnknownOptions(bool Enable) { - if (m_UnknownOptions.GetCount() > 1) - { - ::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN),m_HaveResults ? false : Enable ); - if (Enable) - { - ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), m_HaveResults ? "Search Results" : "Search"); - } - } - else - { - ::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN), false ); - if (Enable) - { - ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), "Create"); - } - } - ::EnableWindow(GetDlgItem(IDC_CMB_UNKNOWN),Enable); + if (m_UnknownOptions.GetCount() > 1) + { + ::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN), m_HaveResults ? false : Enable); + if (Enable) + { + ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), m_HaveResults ? "Search Results" : "Search"); + } + } + else + { + ::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN), false); + if (Enable) + { + ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), "Create"); + } + } + ::EnableWindow(GetDlgItem(IDC_CMB_UNKNOWN), Enable); } -void CDebugMemorySearch::SearchForValue( void ) +void CDebugMemorySearch::SearchForValue(void) { - MemorySize Size = (MemorySize)m_ValueSize.GetItemData(m_ValueSize.GetCurSel()); - DWORD Value = m_SearchValue.GetValue(); - DWORD StartAddress = m_PAddrStart.GetValue(); - DWORD Len = m_SearchLen.GetValue(); - DWORD MaxSearch = m_MaxSearch.GetValue(); - - DWORD MoveSize = (Size == _32Bit ? 4 : (Size == _16Bit ? 2 : 1)); - - m_UnknownSize.SetCurSel(m_ValueSize.GetCurSel()); + MemorySize Size = (MemorySize)m_ValueSize.GetItemData(m_ValueSize.GetCurSel()); + DWORD Value = m_SearchValue.GetValue(); + DWORD StartAddress = m_PAddrStart.GetValue(); + DWORD Len = m_SearchLen.GetValue(); + DWORD MaxSearch = m_MaxSearch.GetValue(); - LPCTSTR DisplayStr = "0x%08X"; - if (Size == _16Bit) - { - DisplayStr = "0x%04X"; - } - else if (Size == _8Bit) - { - DisplayStr = "0x%04X"; - } + DWORD MoveSize = (Size == _32Bit ? 4 : (Size == _16Bit ? 2 : 1)); - if (!m_HaveResults) - { - m_HaveResults = true; + m_UnknownSize.SetCurSel(m_ValueSize.GetCurSel()); - FixUnknownOptions(false); - m_SearchResults.DeleteAllItems(); - DWORD ItemsAdded = 0; + LPCTSTR DisplayStr = "0x%08X"; + if (Size == _16Bit) + { + DisplayStr = "0x%04X"; + } + else if (Size == _8Bit) + { + DisplayStr = "0x%04X"; + } - while (SearchForValue(Value,Size,StartAddress,Len)) - { - SearchResultItem Result; - Result.PAddr = StartAddress; - Result.Value = Value; + if (!m_HaveResults) + { + m_HaveResults = true; - char LocationStr[20]; - sprintf(LocationStr,"%d",ItemsAdded + 1); - int Index = m_SearchResults.AddItem(ItemsAdded,0,LocationStr); - m_SearchResults.SetItemData(Index,m_SearchResult.size()); - m_SearchResult.push_back(Result); - sprintf(LocationStr,"0x%08X",StartAddress); - m_SearchResults.SetItemText(Index,1,LocationStr); - sprintf(LocationStr,DisplayStr,Value); - m_SearchResults.SetItemText(Index,2,LocationStr); - sprintf(LocationStr,DisplayStr,Value); - m_SearchResults.SetItemText(Index,3,LocationStr); - StartAddress += MoveSize; - Len -= MoveSize; - ItemsAdded += 1; - if (ItemsAdded >= MaxSearch) - { - break; - } - } - ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),"Search Results"); - ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON),SW_SHOW); - ::EnableWindow(GetDlgItem(IDC_VALUE_ALIGN),false); - } - else - { - int ItemCount = m_SearchResults.GetItemCount(); - for (int i = ItemCount - 1; i >= 0; i--) - { - int ItemId = m_SearchResults.GetItemData(i); - SearchResultItem & Result = m_SearchResult[ItemId]; - - DWORD NewValue = 0; - bool valid = false; + FixUnknownOptions(false); + m_SearchResults.DeleteAllItems(); + DWORD ItemsAdded = 0; - switch (Size) - { - case _8Bit: - { - BYTE mem = 0; - valid = g_MMU->LB_PAddr(Result.PAddr, mem); - NewValue = mem; - } - break; - case _16Bit: - { - WORD mem = 0; - valid = g_MMU->LH_PAddr(Result.PAddr, mem); - NewValue = mem; - } - break; - case _32Bit: - valid = g_MMU->LW_PAddr(Result.PAddr, NewValue); - break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + while (SearchForValue(Value, Size, StartAddress, Len)) + { + SearchResultItem Result; + Result.PAddr = StartAddress; + Result.Value = Value; - if (Value == NewValue) - { - char LocationStr[20]; - sprintf(LocationStr,DisplayStr,NewValue); - m_SearchResults.SetItemText(i,2,LocationStr); - sprintf(LocationStr,DisplayStr,Result.Value); - m_SearchResults.SetItemText(i,3,LocationStr); - Result.Value = NewValue; - } - else - { - m_SearchResults.DeleteItem(i); - } - } - } - ::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS),stdstr_f("Results (%d)",m_SearchResults.GetItemCount()).c_str()); + char LocationStr[20]; + sprintf(LocationStr, "%d", ItemsAdded + 1); + int Index = m_SearchResults.AddItem(ItemsAdded, 0, LocationStr); + m_SearchResults.SetItemData(Index, m_SearchResult.size()); + m_SearchResult.push_back(Result); + sprintf(LocationStr, "0x%08X", StartAddress); + m_SearchResults.SetItemText(Index, 1, LocationStr); + sprintf(LocationStr, DisplayStr, Value); + m_SearchResults.SetItemText(Index, 2, LocationStr); + sprintf(LocationStr, DisplayStr, Value); + m_SearchResults.SetItemText(Index, 3, LocationStr); + StartAddress += MoveSize; + Len -= MoveSize; + ItemsAdded += 1; + if (ItemsAdded >= MaxSearch) + { + break; + } + } + ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), "Search Results"); + ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON), SW_SHOW); + ::EnableWindow(GetDlgItem(IDC_VALUE_ALIGN), false); + } + else + { + int ItemCount = m_SearchResults.GetItemCount(); + for (int i = ItemCount - 1; i >= 0; i--) + { + int ItemId = m_SearchResults.GetItemData(i); + SearchResultItem & Result = m_SearchResult[ItemId]; + + DWORD NewValue = 0; + bool valid = false; + + switch (Size) + { + case _8Bit: + { + BYTE mem = 0; + valid = g_MMU->LB_PAddr(Result.PAddr, mem); + NewValue = mem; + } + break; + case _16Bit: + { + WORD mem = 0; + valid = g_MMU->LH_PAddr(Result.PAddr, mem); + NewValue = mem; + } + break; + case _32Bit: + valid = g_MMU->LW_PAddr(Result.PAddr, NewValue); + break; + default: + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + + if (Value == NewValue) + { + char LocationStr[20]; + sprintf(LocationStr, DisplayStr, NewValue); + m_SearchResults.SetItemText(i, 2, LocationStr); + sprintf(LocationStr, DisplayStr, Result.Value); + m_SearchResults.SetItemText(i, 3, LocationStr); + Result.Value = NewValue; + } + else + { + m_SearchResults.DeleteItem(i); + } + } + } + ::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS), stdstr_f("Results (%d)", m_SearchResults.GetItemCount()).c_str()); } void CDebugMemorySearch::SearchForUnknown() { - SearchMemChangeState Option = (SearchMemChangeState)m_UnknownOptions.GetItemData(m_UnknownOptions.GetCurSel()); - if (Option == SearchChangeState_Reset) - { - m_SearchResults.DeleteAllItems(); - SearchSetBaseForChanges(); - FixUnknownOptions(false); - ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON),SW_SHOW); - ::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN),true ); - return; - } - MemorySize Size = (MemorySize)m_UnknownSize.GetItemData(m_UnknownSize.GetCurSel()); - m_ValueSize.SetCurSel(m_UnknownSize.GetCurSel()); - LPCTSTR DisplayStr = "0x%08X"; - if (Size == _16Bit) - { - DisplayStr = "0x%04X"; - } - else if (Size == _8Bit) - { - DisplayStr = "0x%04X"; - } - if (!m_HaveResults) - { - m_HaveResults = true; + SearchMemChangeState Option = (SearchMemChangeState)m_UnknownOptions.GetItemData(m_UnknownOptions.GetCurSel()); + if (Option == SearchChangeState_Reset) + { + m_SearchResults.DeleteAllItems(); + SearchSetBaseForChanges(); + FixUnknownOptions(false); + ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON), SW_SHOW); + ::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN), true); + return; + } + MemorySize Size = (MemorySize)m_UnknownSize.GetItemData(m_UnknownSize.GetCurSel()); + m_ValueSize.SetCurSel(m_UnknownSize.GetCurSel()); + LPCTSTR DisplayStr = "0x%08X"; + if (Size == _16Bit) + { + DisplayStr = "0x%04X"; + } + else if (Size == _8Bit) + { + DisplayStr = "0x%04X"; + } + if (!m_HaveResults) + { + m_HaveResults = true; - ::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN),false ); - DWORD StartAddress = m_PAddrStart.GetValue(); - DWORD Len = m_SearchLen.GetValue(); - DWORD MaxSearch = m_MaxSearch.GetValue(); + ::EnableWindow(GetDlgItem(IDC_UNKNOWN_ALIGN), false); + DWORD StartAddress = m_PAddrStart.GetValue(); + DWORD Len = m_SearchLen.GetValue(); + DWORD MaxSearch = m_MaxSearch.GetValue(); - DWORD MoveSize = (Size == _32Bit ? 4 : (Size == _16Bit ? 2 : 1)); - - for (int i = 2; i < 10; i++) - { - if (!m_SearchResults.DeleteColumn(i)) - { - break; - } - } - m_SearchResults.AddColumn("New Value",2); - m_SearchResults.AddColumn("Old Value",3); - m_SearchResults.SetColumnWidth(0,50); - m_SearchResults.SetColumnWidth(1,75); - m_SearchResults.SetColumnWidth(2,75); - m_SearchResults.SetColumnWidth(3,75); + DWORD MoveSize = (Size == _32Bit ? 4 : (Size == _16Bit ? 2 : 1)); - m_SearchResults.DeleteAllItems(); - DWORD ItemsAdded = 0, OldValue, NewValue; - - while (SearchForChanges(Option,Size,StartAddress,Len,OldValue,NewValue)) - { - SearchResultItem Result; - Result.PAddr = StartAddress; - Result.Value = NewValue; + for (int i = 2; i < 10; i++) + { + if (!m_SearchResults.DeleteColumn(i)) + { + break; + } + } + m_SearchResults.AddColumn("New Value", 2); + m_SearchResults.AddColumn("Old Value", 3); + m_SearchResults.SetColumnWidth(0, 50); + m_SearchResults.SetColumnWidth(1, 75); + m_SearchResults.SetColumnWidth(2, 75); + m_SearchResults.SetColumnWidth(3, 75); - //if list size > max, then break - char LocationStr[20]; - sprintf(LocationStr,"%d",ItemsAdded + 1); - int Index = m_SearchResults.AddItem(ItemsAdded,0,LocationStr); - m_SearchResults.SetItemData(Index,m_SearchResult.size()); - m_SearchResult.push_back(Result); - sprintf(LocationStr,"0x%08X",StartAddress); - m_SearchResults.SetItemText(Index,1,LocationStr); - sprintf(LocationStr,DisplayStr,NewValue); - m_SearchResults.SetItemText(Index,2,LocationStr); - sprintf(LocationStr,DisplayStr,OldValue); - m_SearchResults.SetItemText(Index,3,LocationStr); - StartAddress += MoveSize; - Len -= MoveSize; - ItemsAdded += 1; - if (ItemsAdded >= MaxSearch) - { - break; - } - } - ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),"Search Results"); - ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON),SW_SHOW); - ::EnableWindow(GetDlgItem(IDC_RADIO_TEXT),false); - ::EnableWindow(GetDlgItem(IDC_RADIO_JAL),false); - } - else - { - int ItemCount = m_SearchResults.GetItemCount(); - for (int i = ItemCount - 1; i >= 0; i--) - { - int ItemId = m_SearchResults.GetItemData(i); - SearchResultItem & Result = m_SearchResult[ItemId]; - - bool UpdateResult = false; - DWORD NewValue = 0; - bool valid = false; + m_SearchResults.DeleteAllItems(); + DWORD ItemsAdded = 0, OldValue, NewValue; - switch (Size) - { - case _8Bit: - { - BYTE mem = 0; - valid = g_MMU->LB_PAddr(Result.PAddr, mem); - NewValue = mem; - } - break; - case _16Bit: - { - WORD mem = 0; - valid = g_MMU->LH_PAddr(Result.PAddr, mem); - NewValue = mem; - } - break; - case _32Bit: - valid = g_MMU->LW_PAddr(Result.PAddr, NewValue); - break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + while (SearchForChanges(Option, Size, StartAddress, Len, OldValue, NewValue)) + { + SearchResultItem Result; + Result.PAddr = StartAddress; + Result.Value = NewValue; - switch (Option) - { - case SearchChangeState_Changed: - if (Result.Value != NewValue) - { - UpdateResult = true; - } - break; - case SearchChangeState_Unchanged: - if (Result.Value == NewValue) - { - UpdateResult = true; - } - break; - case SearchChangeState_Greater: - if (NewValue > Result.Value) - { - UpdateResult = true; - } - break; - case SearchChangeState_Lessthan: - if (NewValue < Result.Value) - { - UpdateResult = true; - } - break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + //if list size > max, then break + char LocationStr[20]; + sprintf(LocationStr, "%d", ItemsAdded + 1); + int Index = m_SearchResults.AddItem(ItemsAdded, 0, LocationStr); + m_SearchResults.SetItemData(Index, m_SearchResult.size()); + m_SearchResult.push_back(Result); + sprintf(LocationStr, "0x%08X", StartAddress); + m_SearchResults.SetItemText(Index, 1, LocationStr); + sprintf(LocationStr, DisplayStr, NewValue); + m_SearchResults.SetItemText(Index, 2, LocationStr); + sprintf(LocationStr, DisplayStr, OldValue); + m_SearchResults.SetItemText(Index, 3, LocationStr); + StartAddress += MoveSize; + Len -= MoveSize; + ItemsAdded += 1; + if (ItemsAdded >= MaxSearch) + { + break; + } + } + ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), "Search Results"); + ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON), SW_SHOW); + ::EnableWindow(GetDlgItem(IDC_RADIO_TEXT), false); + ::EnableWindow(GetDlgItem(IDC_RADIO_JAL), false); + } + else + { + int ItemCount = m_SearchResults.GetItemCount(); + for (int i = ItemCount - 1; i >= 0; i--) + { + int ItemId = m_SearchResults.GetItemData(i); + SearchResultItem & Result = m_SearchResult[ItemId]; - if (UpdateResult) - { - char LocationStr[20]; - sprintf(LocationStr,DisplayStr,NewValue); - m_SearchResults.SetItemText(i,2,LocationStr); - sprintf(LocationStr,DisplayStr,Result.Value); - m_SearchResults.SetItemText(i,3,LocationStr); - Result.Value = NewValue; - } - else - { - m_SearchResults.DeleteItem(i); - } - } - } - ::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS),stdstr_f("Results (%d)",m_SearchResults.GetItemCount()).c_str()); + bool UpdateResult = false; + DWORD NewValue = 0; + bool valid = false; + + switch (Size) + { + case _8Bit: + { + BYTE mem = 0; + valid = g_MMU->LB_PAddr(Result.PAddr, mem); + NewValue = mem; + } + break; + case _16Bit: + { + WORD mem = 0; + valid = g_MMU->LH_PAddr(Result.PAddr, mem); + NewValue = mem; + } + break; + case _32Bit: + valid = g_MMU->LW_PAddr(Result.PAddr, NewValue); + break; + default: + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + + switch (Option) + { + case SearchChangeState_Changed: + if (Result.Value != NewValue) + { + UpdateResult = true; + } + break; + case SearchChangeState_Unchanged: + if (Result.Value == NewValue) + { + UpdateResult = true; + } + break; + case SearchChangeState_Greater: + if (NewValue > Result.Value) + { + UpdateResult = true; + } + break; + case SearchChangeState_Lessthan: + if (NewValue < Result.Value) + { + UpdateResult = true; + } + break; + default: + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + + if (UpdateResult) + { + char LocationStr[20]; + sprintf(LocationStr, DisplayStr, NewValue); + m_SearchResults.SetItemText(i, 2, LocationStr); + sprintf(LocationStr, DisplayStr, Result.Value); + m_SearchResults.SetItemText(i, 3, LocationStr); + Result.Value = NewValue; + } + else + { + m_SearchResults.DeleteItem(i); + } + } + } + ::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS), stdstr_f("Results (%d)", m_SearchResults.GetItemCount()).c_str()); } void CDebugMemorySearch::SearchForText() { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } -void CDebugMemorySearch::Reset ( void ) +void CDebugMemorySearch::Reset(void) { - m_HaveResults = false; - SendMessage(GetDlgItem(IDC_RADIO_VALUE),BM_SETCHECK, BST_CHECKED,0); - EnableUnknownOptions(false); - EnableValueOptions(true); - EnableTextOptions(false); - EnableJalOptions(false); - ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),"Search"); - ::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS),"Results"); - ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON),SW_HIDE); - ::EnableWindow(GetDlgItem(IDC_RADIO_UNKNOWN),true); - ::EnableWindow(GetDlgItem(IDC_RADIO_VALUE),true); - ::EnableWindow(GetDlgItem(IDC_RADIO_TEXT),false); - ::EnableWindow(GetDlgItem(IDC_RADIO_JAL),false); - for (int i = 1; i < 10; i++) - { - if (!m_SearchResults.DeleteColumn(i)) - { - break; - } - } - m_SearchResults.AddColumn("Value",2); - m_SearchResults.DeleteAllItems(); - m_SearchResults.SetColumnWidth(0,50); - m_SearchResults.SetColumnWidth(1,75); - m_SearchResults.SetColumnWidth(2,75); - m_SearchResults.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT); - FixUnknownOptions(true); + m_HaveResults = false; + SendMessage(GetDlgItem(IDC_RADIO_VALUE), BM_SETCHECK, BST_CHECKED, 0); + EnableUnknownOptions(false); + EnableValueOptions(true); + EnableTextOptions(false); + EnableJalOptions(false); + ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), "Search"); + ::SetWindowText(GetDlgItem(IDC_BORDER_RESULTS), "Results"); + ::ShowWindow(GetDlgItem(IDC_RESET_BUTTON), SW_HIDE); + ::EnableWindow(GetDlgItem(IDC_RADIO_UNKNOWN), true); + ::EnableWindow(GetDlgItem(IDC_RADIO_VALUE), true); + ::EnableWindow(GetDlgItem(IDC_RADIO_TEXT), false); + ::EnableWindow(GetDlgItem(IDC_RADIO_JAL), false); + for (int i = 1; i < 10; i++) + { + if (!m_SearchResults.DeleteColumn(i)) + { + break; + } + } + m_SearchResults.AddColumn("Value", 2); + m_SearchResults.DeleteAllItems(); + m_SearchResults.SetColumnWidth(0, 50); + m_SearchResults.SetColumnWidth(1, 75); + m_SearchResults.SetColumnWidth(2, 75); + m_SearchResults.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT); + FixUnknownOptions(true); } -void CDebugMemorySearch::FixUnknownOptions ( bool Reset ) +void CDebugMemorySearch::FixUnknownOptions(bool Reset) { - CComboBox & cb = m_UnknownOptions ; + CComboBox & cb = m_UnknownOptions; - if (!Reset && cb.GetCount() > 1) - { - return; - } - cb.ResetContent(); - if (Reset) - { - cb.SetItemData(cb.AddString("Create compare base"),SearchChangeState_Reset); - cb.SetCurSel(0); - return; - } - cb.SetItemData(cb.AddString("memory changed"),SearchChangeState_Changed); - cb.SetItemData(cb.AddString("memory unchanged"),SearchChangeState_Unchanged); - cb.SetItemData(cb.AddString("Value has increased"),SearchChangeState_Greater); - cb.SetItemData(cb.AddString("Value has descreased"),SearchChangeState_Lessthan); - cb.SetCurSel(1); - ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH),"Search"); + if (!Reset && cb.GetCount() > 1) + { + return; + } + cb.ResetContent(); + if (Reset) + { + cb.SetItemData(cb.AddString("Create compare base"), SearchChangeState_Reset); + cb.SetCurSel(0); + return; + } + cb.SetItemData(cb.AddString("memory changed"), SearchChangeState_Changed); + cb.SetItemData(cb.AddString("memory unchanged"), SearchChangeState_Unchanged); + cb.SetItemData(cb.AddString("Value has increased"), SearchChangeState_Greater); + cb.SetItemData(cb.AddString("Value has descreased"), SearchChangeState_Lessthan); + cb.SetCurSel(1); + ::SetWindowText(GetDlgItem(IDC_BTN_SEARCH), "Search"); } -bool CDebugMemorySearch::SearchSetBaseForChanges ( void ) +bool CDebugMemorySearch::SearchSetBaseForChanges(void) { - if (m_MemoryState != NULL) - { - delete [] m_MemoryState; - } - m_MemoryStateSize = g_MMU->RdramSize(); - m_MemoryState = new BYTE[m_MemoryStateSize]; - memcpy(m_MemoryState,g_MMU->Rdram(),m_MemoryStateSize); - return true; + if (m_MemoryState != NULL) + { + delete[] m_MemoryState; + } + m_MemoryStateSize = g_MMU->RdramSize(); + m_MemoryState = new BYTE[m_MemoryStateSize]; + memcpy(m_MemoryState, g_MMU->Rdram(), m_MemoryStateSize); + return true; } -bool CDebugMemorySearch::SearchForChanges(SearchMemChangeState SearchType, MemorySize Size, - DWORD &StartAddress, DWORD &Len, - DWORD &OldValue, DWORD &NewValue) +bool CDebugMemorySearch::SearchForChanges(SearchMemChangeState SearchType, MemorySize Size, + DWORD &StartAddress, DWORD &Len, + DWORD &OldValue, DWORD &NewValue) { - if (g_MMU == NULL) - { - return false; - } + if (g_MMU == NULL) + { + return false; + } - if (SearchType == SearchChangeState_Reset) - { - Notify().BreakPoint(__FILEW__,__LINE__); - } - if (Size == _32Bit) { StartAddress = ((StartAddress + 3) & ~3); } - if (Size == _16Bit) { StartAddress = ((StartAddress + 1) & ~1); } + if (SearchType == SearchChangeState_Reset) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + if (Size == _32Bit) { StartAddress = ((StartAddress + 3) & ~3); } + if (Size == _16Bit) { StartAddress = ((StartAddress + 1) & ~1); } - //search memory - if (StartAddress < g_MMU->RdramSize()) - { - DWORD EndMemSearchAddr = StartAddress + Len; - if (EndMemSearchAddr > g_MMU->RdramSize()) - { - EndMemSearchAddr = g_MMU->RdramSize(); - } - - DWORD pos; - switch (Size) - { - case _32Bit: - for (pos = StartAddress; pos < EndMemSearchAddr; pos += 4) - { - OldValue = *(DWORD *)(m_MemoryState + pos); - NewValue = *(DWORD *)(g_MMU->Rdram() + pos); - if ((SearchType == SearchChangeState_Changed && NewValue != OldValue) || - (SearchType == SearchChangeState_Unchanged && NewValue == OldValue) || - (SearchType == SearchChangeState_Greater && NewValue > OldValue) || - (SearchType == SearchChangeState_Lessthan && NewValue < OldValue)) - { - *(DWORD *)(m_MemoryState + pos) = NewValue; - Len -= pos - StartAddress; - StartAddress = pos; - return true; - } - } - break; - case _16Bit: - for (pos = StartAddress; pos < EndMemSearchAddr; pos += 2) - { - OldValue = *(WORD *)(m_MemoryState + (pos ^ 2)); - NewValue = *(WORD *)(g_MMU->Rdram() + (pos ^ 2)); - if ((SearchType == SearchChangeState_Changed && NewValue != OldValue) || - (SearchType == SearchChangeState_Unchanged && NewValue == OldValue) || - (SearchType == SearchChangeState_Greater && NewValue > OldValue) || - (SearchType == SearchChangeState_Lessthan && NewValue < OldValue)) - { - Len -= pos - StartAddress; - StartAddress = pos; - return true; - } - } - break; - case _8Bit: - for (pos = StartAddress; pos < EndMemSearchAddr; pos ++) - { - OldValue = *(BYTE *)(m_MemoryState + (pos ^ 3)); - NewValue = *(BYTE *)(g_MMU->Rdram() + (pos ^ 3)); - if ((SearchType == SearchChangeState_Changed && NewValue != OldValue) || - (SearchType == SearchChangeState_Unchanged && NewValue == OldValue) || - (SearchType == SearchChangeState_Greater && NewValue > OldValue) || - (SearchType == SearchChangeState_Lessthan && NewValue < OldValue)) - { - Len -= pos - StartAddress; - StartAddress = pos; - return true; - } - } - break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } - return false; + //search memory + if (StartAddress < g_MMU->RdramSize()) + { + DWORD EndMemSearchAddr = StartAddress + Len; + if (EndMemSearchAddr > g_MMU->RdramSize()) + { + EndMemSearchAddr = g_MMU->RdramSize(); + } + + DWORD pos; + switch (Size) + { + case _32Bit: + for (pos = StartAddress; pos < EndMemSearchAddr; pos += 4) + { + OldValue = *(DWORD *)(m_MemoryState + pos); + NewValue = *(DWORD *)(g_MMU->Rdram() + pos); + if ((SearchType == SearchChangeState_Changed && NewValue != OldValue) || + (SearchType == SearchChangeState_Unchanged && NewValue == OldValue) || + (SearchType == SearchChangeState_Greater && NewValue > OldValue) || + (SearchType == SearchChangeState_Lessthan && NewValue < OldValue)) + { + *(DWORD *)(m_MemoryState + pos) = NewValue; + Len -= pos - StartAddress; + StartAddress = pos; + return true; + } + } + break; + case _16Bit: + for (pos = StartAddress; pos < EndMemSearchAddr; pos += 2) + { + OldValue = *(WORD *)(m_MemoryState + (pos ^ 2)); + NewValue = *(WORD *)(g_MMU->Rdram() + (pos ^ 2)); + if ((SearchType == SearchChangeState_Changed && NewValue != OldValue) || + (SearchType == SearchChangeState_Unchanged && NewValue == OldValue) || + (SearchType == SearchChangeState_Greater && NewValue > OldValue) || + (SearchType == SearchChangeState_Lessthan && NewValue < OldValue)) + { + Len -= pos - StartAddress; + StartAddress = pos; + return true; + } + } + break; + case _8Bit: + for (pos = StartAddress; pos < EndMemSearchAddr; pos++) + { + OldValue = *(BYTE *)(m_MemoryState + (pos ^ 3)); + NewValue = *(BYTE *)(g_MMU->Rdram() + (pos ^ 3)); + if ((SearchType == SearchChangeState_Changed && NewValue != OldValue) || + (SearchType == SearchChangeState_Unchanged && NewValue == OldValue) || + (SearchType == SearchChangeState_Greater && NewValue > OldValue) || + (SearchType == SearchChangeState_Lessthan && NewValue < OldValue)) + { + Len -= pos - StartAddress; + StartAddress = pos; + return true; + } + } + break; + default: + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } + return false; } -bool CDebugMemorySearch::SearchForValue (DWORD Value, MemorySize Size, DWORD &StartAddress, DWORD &Len ) +bool CDebugMemorySearch::SearchForValue(DWORD Value, MemorySize Size, DWORD &StartAddress, DWORD &Len) { - if (g_MMU == NULL || g_Rom == NULL) - { - return false; - } + if (g_MMU == NULL || g_Rom == NULL) + { + return false; + } - if (Size == _32Bit) - { - StartAddress = ((StartAddress + 3) & ~3); - } - if (Size == _16Bit) - { - StartAddress = ((StartAddress + 1) & ~1); - } + if (Size == _32Bit) + { + StartAddress = ((StartAddress + 3) & ~3); + } + if (Size == _16Bit) + { + StartAddress = ((StartAddress + 1) & ~1); + } - //search memory - if (StartAddress < g_MMU->RdramSize()) - { - DWORD EndMemSearchAddr = StartAddress + Len; - if (EndMemSearchAddr > g_MMU->RdramSize()) - { - EndMemSearchAddr = g_MMU->RdramSize(); - } - - DWORD pos; - BYTE * RDRAM = g_MMU->Rdram(); - switch (Size) - { - case _32Bit: - for (pos = StartAddress; pos < EndMemSearchAddr; pos += 4) - { - if (*(DWORD *)(RDRAM + pos) == Value) - { - Len -= pos - StartAddress; - StartAddress = pos; - return true; - } - } - break; - case _16Bit: - for (pos = StartAddress; pos < EndMemSearchAddr; pos += 2) - { - if (*(WORD *)(RDRAM + (pos ^ 2)) == (WORD)Value) - { - Len -= pos - StartAddress; - StartAddress = pos; - return true; - } - } - break; - case _8Bit: - for (pos = StartAddress; pos < EndMemSearchAddr; pos ++) - { - if (*(BYTE *)(RDRAM + (pos ^ 3)) == (BYTE)Value) - { - Len -= pos - StartAddress; - StartAddress = pos; - return true; - } - } - break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } - if (StartAddress >= 0x10000000) - { - DWORD EndMemSearchAddr = StartAddress + Len - 0x10000000; - if (EndMemSearchAddr > g_Rom->GetRomSize()) - { - EndMemSearchAddr = g_Rom->GetRomSize(); - } - StartAddress -= 0x10000000; - - DWORD pos; - BYTE * ROM = g_Rom->GetRomAddress(); - switch (Size) - { - case _32Bit: - for (pos = StartAddress; pos < EndMemSearchAddr; pos += 4) - { - if (*(DWORD *)(ROM + pos) == Value) - { - Len -= pos - StartAddress; - StartAddress = pos + 0x10000000; - return true; - } - } - break; - case _16Bit: - for (pos = StartAddress; pos < EndMemSearchAddr; pos += 2) - { - if (*(WORD *)(ROM + (pos ^ 2)) == (WORD)Value) - { - Len -= pos - StartAddress; - StartAddress = pos + 0x10000000; - return true; - } - } - break; - case _8Bit: - for (pos = StartAddress; pos < EndMemSearchAddr; pos ++) - { - if (*(BYTE *)(ROM + (pos ^ 3)) == (BYTE)Value) - { - Len -= pos - StartAddress; - StartAddress = pos + 0x10000000; - return true; - } - } - break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } - return false; + //search memory + if (StartAddress < g_MMU->RdramSize()) + { + DWORD EndMemSearchAddr = StartAddress + Len; + if (EndMemSearchAddr > g_MMU->RdramSize()) + { + EndMemSearchAddr = g_MMU->RdramSize(); + } + + DWORD pos; + BYTE * RDRAM = g_MMU->Rdram(); + switch (Size) + { + case _32Bit: + for (pos = StartAddress; pos < EndMemSearchAddr; pos += 4) + { + if (*(DWORD *)(RDRAM + pos) == Value) + { + Len -= pos - StartAddress; + StartAddress = pos; + return true; + } + } + break; + case _16Bit: + for (pos = StartAddress; pos < EndMemSearchAddr; pos += 2) + { + if (*(WORD *)(RDRAM + (pos ^ 2)) == (WORD)Value) + { + Len -= pos - StartAddress; + StartAddress = pos; + return true; + } + } + break; + case _8Bit: + for (pos = StartAddress; pos < EndMemSearchAddr; pos++) + { + if (*(BYTE *)(RDRAM + (pos ^ 3)) == (BYTE)Value) + { + Len -= pos - StartAddress; + StartAddress = pos; + return true; + } + } + break; + default: + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } + if (StartAddress >= 0x10000000) + { + DWORD EndMemSearchAddr = StartAddress + Len - 0x10000000; + if (EndMemSearchAddr > g_Rom->GetRomSize()) + { + EndMemSearchAddr = g_Rom->GetRomSize(); + } + StartAddress -= 0x10000000; + + DWORD pos; + BYTE * ROM = g_Rom->GetRomAddress(); + switch (Size) + { + case _32Bit: + for (pos = StartAddress; pos < EndMemSearchAddr; pos += 4) + { + if (*(DWORD *)(ROM + pos) == Value) + { + Len -= pos - StartAddress; + StartAddress = pos + 0x10000000; + return true; + } + } + break; + case _16Bit: + for (pos = StartAddress; pos < EndMemSearchAddr; pos += 2) + { + if (*(WORD *)(ROM + (pos ^ 2)) == (WORD)Value) + { + Len -= pos - StartAddress; + StartAddress = pos + 0x10000000; + return true; + } + } + break; + case _8Bit: + for (pos = StartAddress; pos < EndMemSearchAddr; pos++) + { + if (*(BYTE *)(ROM + (pos ^ 3)) == (BYTE)Value) + { + Len -= pos - StartAddress; + StartAddress = pos + 0x10000000; + return true; + } + } + break; + default: + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } + return false; } -#endif diff --git a/Source/Project64/N64 System/Debugger/Debugger - Memory Search.h b/Source/Project64/N64 System/Debugger/Debugger - Memory Search.h index 40e67bd76..478684269 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - Memory Search.h +++ b/Source/Project64/N64 System/Debugger/Debugger - Memory Search.h @@ -11,59 +11,59 @@ #pragma once class CDebugMemorySearch : - public CDebugDialog + public CDebugDialog < CDebugMemorySearch > { -public: - enum { IDD = IDD_Debugger_Search }; +public: + enum { IDD = IDD_Debugger_Search }; - CDebugMemorySearch(CDebugger * debugger); - virtual ~CDebugMemorySearch(void); + CDebugMemorySearch(CDebuggerUI * debugger); + virtual ~CDebugMemorySearch(void); private: - CDebugMemorySearch(void); // Disable default constructor - CDebugMemorySearch(const CDebugMemorySearch&); // Disable copy constructor - CDebugMemorySearch& operator=(const CDebugMemorySearch&); // Disable assignment + CDebugMemorySearch(void); // Disable default constructor + CDebugMemorySearch(const CDebugMemorySearch&); // Disable copy constructor + CDebugMemorySearch& operator=(const CDebugMemorySearch&); // Disable assignment - enum MemorySize - { - _8Bit, - _16Bit, - _32Bit, - }; + enum MemorySize + { + _8Bit, + _16Bit, + _32Bit, + }; - //Searching for value - enum SearchMemChangeState - { - SearchChangeState_Reset, - SearchChangeState_Changed, - SearchChangeState_Unchanged, - SearchChangeState_Greater, - SearchChangeState_Lessthan, - }; + //Searching for value + enum SearchMemChangeState + { + SearchChangeState_Reset, + SearchChangeState_Changed, + SearchChangeState_Unchanged, + SearchChangeState_Greater, + SearchChangeState_Lessthan, + }; - struct SearchResultItem - { - DWORD PAddr; - DWORD Value; - }; + struct SearchResultItem + { + DWORD PAddr; + DWORD Value; + }; - typedef std::vector SearchResult; + typedef std::vector SearchResult; - BEGIN_MSG_MAP_EX(CDebugMemorySearch) - MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) - COMMAND_CODE_HANDLER(BN_CLICKED,OnClicked) - NOTIFY_HANDLER_EX(IDC_LST_RESULTS,NM_RCLICK,OnResultRClick) + BEGIN_MSG_MAP_EX(CDebugMemorySearch) + MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) + COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked) + NOTIFY_HANDLER_EX(IDC_LST_RESULTS, NM_RCLICK, OnResultRClick) END_MSG_MAP() LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled); - LRESULT OnResultRClick ( LPNMHDR lpnmh ); + LRESULT OnResultRClick(LPNMHDR lpnmh); - void EnableUnknownOptions ( bool Enable ); - void EnableValueOptions ( bool Enable ); - void EnableTextOptions ( bool Enable ); - void EnableJalOptions ( bool Enable ); - void AddAlignmentOptions ( CComboBox & ctrl ); + void EnableUnknownOptions(bool Enable); + void EnableValueOptions(bool Enable); + void EnableTextOptions(bool Enable); + void EnableJalOptions(bool Enable); + void AddAlignmentOptions(CComboBox & ctrl); CEditNumber m_PAddrStart, m_SearchLen, m_SearchValue, m_MaxSearch; CComboBox m_UnknownOptions, m_ValueSize, m_UnknownSize; @@ -75,12 +75,12 @@ private: BYTE * m_MemoryState; DWORD m_MemoryStateSize; - void FixUnknownOptions ( bool Reset ); - void SearchForUnknown ( void ); - void SearchForValue ( void ); - void SearchForText ( void ); - void Reset ( void ); - bool SearchSetBaseForChanges ( void ); - bool SearchForChanges ( SearchMemChangeState SearchType, MemorySize Size, DWORD &StartAddress, DWORD &Len, DWORD &OldValue, DWORD &NewValue ); - bool SearchForValue ( DWORD Value, MemorySize Size, DWORD &StartAddress, DWORD &Len ); + void FixUnknownOptions(bool Reset); + void SearchForUnknown(void); + void SearchForValue(void); + void SearchForText(void); + void Reset(void); + bool SearchSetBaseForChanges(void); + bool SearchForChanges(SearchMemChangeState SearchType, MemorySize Size, DWORD &StartAddress, DWORD &Len, DWORD &OldValue, DWORD &NewValue); + bool SearchForValue(DWORD Value, MemorySize Size, DWORD &StartAddress, DWORD &Len); }; diff --git a/Source/Project64/N64 System/Debugger/Debugger - TLB.cpp b/Source/Project64/N64 System/Debugger/Debugger - TLB.cpp index 4662fbb4a..d68f704ca 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - TLB.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger - TLB.cpp @@ -10,11 +10,10 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI #include "Debugger UI.h" -CDebugTlb::CDebugTlb(CDebugger * debugger) : - CDebugDialog(debugger) +CDebugTlb::CDebugTlb(CDebuggerUI * debugger) : + CDebugDialog(debugger) { } @@ -24,267 +23,266 @@ CDebugTlb::~CDebugTlb() LRESULT CDebugTlb::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { - LV_COLUMN col; + LV_COLUMN col; - col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; - col.fmt = LVCFMT_LEFT; + col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; + col.fmt = LVCFMT_LEFT; - col.pszText = "Index"; - col.cx = 40; - col.iSubItem = 0; - ListView_InsertColumn ( GetDlgItem(IDC_LIST), 0, &col); + col.pszText = "Index"; + col.cx = 40; + col.iSubItem = 0; + ListView_InsertColumn(GetDlgItem(IDC_LIST), 0, &col); - col.pszText = "Page Mask"; - col.cx = 90; - col.iSubItem = 1; - ListView_InsertColumn ( GetDlgItem(IDC_LIST), 1, &col); + col.pszText = "Page Mask"; + col.cx = 90; + col.iSubItem = 1; + ListView_InsertColumn(GetDlgItem(IDC_LIST), 1, &col); - col.pszText = "Entry Hi"; - col.cx = 90; - col.iSubItem = 2; - ListView_InsertColumn ( GetDlgItem(IDC_LIST), 2, &col); + col.pszText = "Entry Hi"; + col.cx = 90; + col.iSubItem = 2; + ListView_InsertColumn(GetDlgItem(IDC_LIST), 2, &col); - col.pszText = "Entry Lo0"; - col.cx = 90; - col.iSubItem = 3; - ListView_InsertColumn ( GetDlgItem(IDC_LIST), 3, &col); + col.pszText = "Entry Lo0"; + col.cx = 90; + col.iSubItem = 3; + ListView_InsertColumn(GetDlgItem(IDC_LIST), 3, &col); - col.pszText = "Entry Lo1"; - col.cx = 90; - col.iSubItem = 4; - ListView_InsertColumn ( GetDlgItem(IDC_LIST), 4, &col); + col.pszText = "Entry Lo1"; + col.cx = 90; + col.iSubItem = 4; + ListView_InsertColumn(GetDlgItem(IDC_LIST), 4, &col); - col.pszText = "Index"; - col.cx = 40; - col.iSubItem = 0; - ListView_InsertColumn ( GetDlgItem(IDC_LIST2), 0, &col); + col.pszText = "Index"; + col.cx = 40; + col.iSubItem = 0; + ListView_InsertColumn(GetDlgItem(IDC_LIST2), 0, &col); - col.pszText = "Valid"; - col.cx = 40; - col.iSubItem = 1; - ListView_InsertColumn ( GetDlgItem(IDC_LIST2), 1, &col); + col.pszText = "Valid"; + col.cx = 40; + col.iSubItem = 1; + ListView_InsertColumn(GetDlgItem(IDC_LIST2), 1, &col); - col.pszText = "Dirty"; - col.cx = 40; - col.iSubItem = 2; - ListView_InsertColumn ( GetDlgItem(IDC_LIST2), 2, &col); + col.pszText = "Dirty"; + col.cx = 40; + col.iSubItem = 2; + ListView_InsertColumn(GetDlgItem(IDC_LIST2), 2, &col); - col.pszText = "Rule"; - col.cx = 270; - col.iSubItem = 3; - ListView_InsertColumn ( GetDlgItem(IDC_LIST2), 3, &col); + col.pszText = "Rule"; + col.cx = 270; + col.iSubItem = 3; + ListView_InsertColumn(GetDlgItem(IDC_LIST2), 3, &col); - RefreshTLBWindow(); - SendMessage(GetDlgItem(IDC_TLB_ENTRIES),BM_SETCHECK, BST_CHECKED,0); - -// if (Settings().Load(TLBWindowLeft) <= 0) -// { -// SetWindowPos(NULL,Settings().Load(TLBWindowLeft),Settings().Load(TLBWindowTop),0,0, SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW); -// } - WindowCreated(); - return TRUE; + RefreshTLBWindow(); + SendMessage(GetDlgItem(IDC_TLB_ENTRIES), BM_SETCHECK, BST_CHECKED, 0); + + // if (Settings().Load(TLBWindowLeft) <= 0) + // { + // SetWindowPos(NULL,Settings().Load(TLBWindowLeft),Settings().Load(TLBWindowTop),0,0, SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW); + // } + WindowCreated(); + return TRUE; } -LRESULT CDebugTlb::OnClicked (WORD /*wNotifyCode*/, WORD wID, HWND , BOOL& /*bHandled*/) +LRESULT CDebugTlb::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& /*bHandled*/) { - switch(wID) - { - case IDCANCEL: - EndDialog(0); - break; - case IDC_TLB_ENTRIES: - ::ShowWindow(GetDlgItem(IDC_LIST),SW_SHOW); - ::ShowWindow(GetDlgItem(IDC_LIST2),SW_HIDE); - break; - case IDC_TLB_RULES: - ::ShowWindow(GetDlgItem(IDC_LIST),SW_HIDE); - ::ShowWindow(GetDlgItem(IDC_LIST2),SW_SHOW); - break; - } - return FALSE; + switch (wID) + { + case IDCANCEL: + EndDialog(0); + break; + case IDC_TLB_ENTRIES: + ::ShowWindow(GetDlgItem(IDC_LIST), SW_SHOW); + ::ShowWindow(GetDlgItem(IDC_LIST2), SW_HIDE); + break; + case IDC_TLB_RULES: + ::ShowWindow(GetDlgItem(IDC_LIST), SW_HIDE); + ::ShowWindow(GetDlgItem(IDC_LIST2), SW_SHOW); + break; + } + return FALSE; } -void CDebugTlb::RefreshTLBWindow (void) +void CDebugTlb::RefreshTLBWindow(void) { - if (m_hWnd == NULL) - { - return; - } - - HWND hList = GetDlgItem(IDC_LIST); - char Output[100], OldText[100]; - LV_ITEM item, OldItem; - int count; + if (m_hWnd == NULL) + { + return; + } - CTLB::TLB_ENTRY * tlb = g_TLB->m_tlb; - for (count = 0; count < 32; count ++) - { - sprintf(Output,"0x%02X",count); - item.mask = LVIF_TEXT; - item.iItem = count; - item.pszText = Output; - item.iSubItem = 0; + HWND hList = GetDlgItem(IDC_LIST); + char Output[100], OldText[100]; + LV_ITEM item, OldItem; + int count; - OldItem.mask = LVIF_TEXT; - OldItem.iItem = count; - OldItem.pszText = OldText; - OldItem.cchTextMax = sizeof( OldText )-1; - OldItem.iSubItem = 0; + CTLB::TLB_ENTRY * tlb = g_TLB->m_tlb; + for (count = 0; count < 32; count++) + { + sprintf(Output, "0x%02X", count); + item.mask = LVIF_TEXT; + item.iItem = count; + item.pszText = Output; + item.iSubItem = 0; - if (ListView_GetItemCount(hList) <= count) - { - ListView_InsertItem(hList,&item); - } - else - { - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) - { - ListView_SetItem(hList,&item); - } - } - if (tlb[count].EntryDefined) - { - sprintf(Output,"0x%08X",tlb[count].PageMask.Value); - } - else - { - strcpy(Output,"................"); - } - item.iSubItem = 1; - OldItem.iSubItem = 1; - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) - { - ListView_SetItem(hList,&item); - } + OldItem.mask = LVIF_TEXT; + OldItem.iItem = count; + OldItem.pszText = OldText; + OldItem.cchTextMax = sizeof(OldText) - 1; + OldItem.iSubItem = 0; - if (tlb[count].EntryDefined) - { - sprintf(Output,"0x%08X",tlb[count].EntryHi.Value); - } - else - { - strcpy(Output,"................"); - } - item.iSubItem = 2; - OldItem.iSubItem = 2; - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) - { - ListView_SetItem(hList,&item); - } + if (ListView_GetItemCount(hList) <= count) + { + ListView_InsertItem(hList, &item); + } + else + { + ListView_GetItem(hList, &OldItem); + if (strcmp(item.pszText, OldItem.pszText) != 0) + { + ListView_SetItem(hList, &item); + } + } + if (tlb[count].EntryDefined) + { + sprintf(Output, "0x%08X", tlb[count].PageMask.Value); + } + else + { + strcpy(Output, "................"); + } + item.iSubItem = 1; + OldItem.iSubItem = 1; + ListView_GetItem(hList, &OldItem); + if (strcmp(item.pszText, OldItem.pszText) != 0) + { + ListView_SetItem(hList, &item); + } - if (tlb[count].EntryDefined) - { - sprintf(Output,"0x%08X",tlb[count].EntryLo0.Value); - } - else - { - strcpy(Output,"................"); - } - item.iSubItem = 3; - OldItem.iSubItem = 3; - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) - { - ListView_SetItem(hList,&item); - } + if (tlb[count].EntryDefined) + { + sprintf(Output, "0x%08X", tlb[count].EntryHi.Value); + } + else + { + strcpy(Output, "................"); + } + item.iSubItem = 2; + OldItem.iSubItem = 2; + ListView_GetItem(hList, &OldItem); + if (strcmp(item.pszText, OldItem.pszText) != 0) + { + ListView_SetItem(hList, &item); + } - if (tlb[count].EntryDefined) - { - sprintf(Output,"0x%08X",tlb[count].EntryLo1.Value); - } - else - { - strcpy(Output,"................"); - } - item.iSubItem = 4; - OldItem.iSubItem = 4; - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) - { - ListView_SetItem(hList,&item); - } - } - - CTLB::FASTTLB * FastTlb = g_TLB->m_FastTlb; - hList = GetDlgItem(IDC_LIST2); - for (count = 0; count < 64; count ++) - { - sprintf(Output,"0x%02X",count); - item.mask = LVIF_TEXT; - item.iItem = count; - item.pszText = Output; - item.iSubItem = 0; + if (tlb[count].EntryDefined) + { + sprintf(Output, "0x%08X", tlb[count].EntryLo0.Value); + } + else + { + strcpy(Output, "................"); + } + item.iSubItem = 3; + OldItem.iSubItem = 3; + ListView_GetItem(hList, &OldItem); + if (strcmp(item.pszText, OldItem.pszText) != 0) + { + ListView_SetItem(hList, &item); + } - OldItem.mask = LVIF_TEXT; - OldItem.iItem = count; - OldItem.pszText = OldText; - OldItem.cchTextMax = sizeof( OldText )-1; - OldItem.iSubItem = 0; + if (tlb[count].EntryDefined) + { + sprintf(Output, "0x%08X", tlb[count].EntryLo1.Value); + } + else + { + strcpy(Output, "................"); + } + item.iSubItem = 4; + OldItem.iSubItem = 4; + ListView_GetItem(hList, &OldItem); + if (strcmp(item.pszText, OldItem.pszText) != 0) + { + ListView_SetItem(hList, &item); + } + } - if (ListView_GetItemCount(hList) <= count) - { - item.iItem = ListView_InsertItem(hList,&item); - } - else - { - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) - { - ListView_SetItem(hList,&item); - } - } + CTLB::FASTTLB * FastTlb = g_TLB->m_FastTlb; + hList = GetDlgItem(IDC_LIST2); + for (count = 0; count < 64; count++) + { + sprintf(Output, "0x%02X", count); + item.mask = LVIF_TEXT; + item.iItem = count; + item.pszText = Output; + item.iSubItem = 0; - if (FastTlb[count].ValidEntry) - { - sprintf(Output,"%s",FastTlb[count].VALID?"Yes":"No"); - } - else - { - strcpy(Output,"................"); - } - item.iSubItem = 1; - OldItem.iSubItem = 1; - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) - { - ListView_SetItem(hList,&item); - } + OldItem.mask = LVIF_TEXT; + OldItem.iItem = count; + OldItem.pszText = OldText; + OldItem.cchTextMax = sizeof(OldText) - 1; + OldItem.iSubItem = 0; - if (FastTlb[count].ValidEntry && FastTlb[count].VALID) - { - sprintf(Output,"%s",FastTlb[count].DIRTY?"Yes":"No"); - } - else - { - strcpy(Output,"................"); - } - item.iSubItem = 2; - OldItem.iSubItem = 2; - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) - { - ListView_SetItem(hList,&item); - } + if (ListView_GetItemCount(hList) <= count) + { + item.iItem = ListView_InsertItem(hList, &item); + } + else + { + ListView_GetItem(hList, &OldItem); + if (strcmp(item.pszText, OldItem.pszText) != 0) + { + ListView_SetItem(hList, &item); + } + } - if (FastTlb[count].ValidEntry && FastTlb[count].VALID) - { - sprintf(Output,"%08X:%08X -> %08X:%08X",FastTlb[count].VSTART,FastTlb[count].VEND, - FastTlb[count].PHYSSTART,FastTlb[count].PHYSEND); - } - else - { - strcpy(Output,"................"); - } - item.iSubItem = 3; - OldItem.iSubItem = 3; - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) - { - ListView_SetItem(hList,&item); - } - } + if (FastTlb[count].ValidEntry) + { + sprintf(Output, "%s", FastTlb[count].VALID ? "Yes" : "No"); + } + else + { + strcpy(Output, "................"); + } + item.iSubItem = 1; + OldItem.iSubItem = 1; + ListView_GetItem(hList, &OldItem); + if (strcmp(item.pszText, OldItem.pszText) != 0) + { + ListView_SetItem(hList, &item); + } + + if (FastTlb[count].ValidEntry && FastTlb[count].VALID) + { + sprintf(Output, "%s", FastTlb[count].DIRTY ? "Yes" : "No"); + } + else + { + strcpy(Output, "................"); + } + item.iSubItem = 2; + OldItem.iSubItem = 2; + ListView_GetItem(hList, &OldItem); + if (strcmp(item.pszText, OldItem.pszText) != 0) + { + ListView_SetItem(hList, &item); + } + + if (FastTlb[count].ValidEntry && FastTlb[count].VALID) + { + sprintf(Output, "%08X:%08X -> %08X:%08X", FastTlb[count].VSTART, FastTlb[count].VEND, + FastTlb[count].PHYSSTART, FastTlb[count].PHYSEND); + } + else + { + strcpy(Output, "................"); + } + item.iSubItem = 3; + OldItem.iSubItem = 3; + ListView_GetItem(hList, &OldItem); + if (strcmp(item.pszText, OldItem.pszText) != 0) + { + ListView_SetItem(hList, &item); + } + } } -#endif diff --git a/Source/Project64/N64 System/Debugger/Debugger - TLB.h b/Source/Project64/N64 System/Debugger/Debugger - TLB.h index cb818e73e..2588b1f67 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - TLB.h +++ b/Source/Project64/N64 System/Debugger/Debugger - TLB.h @@ -11,22 +11,21 @@ #pragma once class CDebugTlb : - public CDebugDialog + public CDebugDialog < CDebugTlb > { - - BEGIN_MSG_MAP_EX(CDebugTlb) - MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) - COMMAND_CODE_HANDLER(BN_CLICKED,OnClicked) + BEGIN_MSG_MAP_EX(CDebugTlb) + MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) + COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked) END_MSG_MAP() LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled); -public: - enum { IDD = IDD_Debugger_TLB }; +public: + enum { IDD = IDD_Debugger_TLB }; - CDebugTlb(CDebugger * debugger); - virtual ~CDebugTlb(void); + CDebugTlb(CDebuggerUI * debugger); + virtual ~CDebugTlb(void); - void RefreshTLBWindow ( void ); + void RefreshTLBWindow(void); }; diff --git a/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp b/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp index 7973689fb..8c577ab73 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp @@ -10,18 +10,17 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI #include "Debugger UI.h" -CDebugMemoryView::CDebugMemoryView(CDebugger * debugger) : - CDebugDialog(debugger), - m_MemoryList(NULL) +CDebugMemoryView::CDebugMemoryView(CDebuggerUI * debugger) : + CDebugDialog(debugger), + m_MemoryList(NULL) { - if (m_MemoryList== NULL) - { - m_MemoryList = new CListCtrl; - m_MemoryList->RegisterClass(); - } + if (m_MemoryList== NULL) + { + m_MemoryList = new CListCtrl; + m_MemoryList->RegisterClass(); + } } CDebugMemoryView::~CDebugMemoryView() @@ -30,446 +29,444 @@ CDebugMemoryView::~CDebugMemoryView() LRESULT CDebugMemoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { - m_DataStartLoc = (DWORD)-1; - m_CompareStartLoc = (DWORD)-1; - memset(m_CompareData,0,sizeof(m_CompareData)); - memset(m_CompareValid,0,sizeof(m_CompareValid)); + m_DataStartLoc = (DWORD)-1; + m_CompareStartLoc = (DWORD)-1; + memset(m_CompareData, 0, sizeof(m_CompareData)); + memset(m_CompareValid, 0, sizeof(m_CompareValid)); - HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR); - if (hScrlBar) - { - SCROLLINFO si; + HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR); + if (hScrlBar) + { + SCROLLINFO si; - si.cbSize = sizeof(si); - si.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; - si.nMin = 0; - si.nMax = 0xFFFF; - si.nPos = 0x8000; - si.nPage = 100; - ::SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE); - } + si.cbSize = sizeof(si); + si.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; + si.nMin = 0; + si.nMax = 0xFFFF; + si.nPos = 0x8000; + si.nPage = 100; + ::SetScrollInfo(hScrlBar, SB_CTL, &si, TRUE); + } - m_MemAddr.Attach(GetDlgItem(IDC_ADDR_EDIT)); - m_MemAddr.SetDisplayType(CEditNumber::DisplayHex); - m_MemAddr.SetValue(0x80000000,true,true); + m_MemAddr.Attach(GetDlgItem(IDC_ADDR_EDIT)); + m_MemAddr.SetDisplayType(CEditNumber::DisplayHex); + m_MemAddr.SetValue(0x80000000, true, true); - SendDlgItemMessage( IDC_CHK_VADDR, BM_SETCHECK, BST_CHECKED,0); + SendDlgItemMessage(IDC_CHK_VADDR, BM_SETCHECK, BST_CHECKED, 0); - if (m_MemoryList== NULL) - { - m_MemoryList = new CListCtrl; - m_MemoryList->RegisterClass(); - } - m_MemoryList->SubclassWindow( GetDlgItem( IDC_MEM_DETAILS ) ); - m_MemoryList->ShowHeader(false); - m_MemoryList->SetSortEnabled(FALSE); - m_MemoryList->AddColumn( _T( "Address" ), 90 ); - m_MemoryList->AddColumn( _T( "1" ), 20 ); - m_MemoryList->AddColumn( _T( "2" ), 20 ); - m_MemoryList->AddColumn( _T( "3" ), 20 ); - m_MemoryList->AddColumn( _T( "4" ), 20 ); - m_MemoryList->AddColumn( _T( "-" ), 10 ); - m_MemoryList->AddColumn( _T( "5" ), 20 ); - m_MemoryList->AddColumn( _T( "6" ), 20 ); - m_MemoryList->AddColumn( _T( "7" ), 20 ); - m_MemoryList->AddColumn( _T( "8" ), 20 ); - m_MemoryList->AddColumn( _T( "-" ), 10 ); - m_MemoryList->AddColumn( _T( "9" ), 20 ); - m_MemoryList->AddColumn( _T( "10" ), 20 ); - m_MemoryList->AddColumn( _T( "11" ), 20 ); - m_MemoryList->AddColumn( _T( "12" ), 20 ); - m_MemoryList->AddColumn( _T( "-" ), 10 ); - m_MemoryList->AddColumn( _T( "13" ), 20 ); - m_MemoryList->AddColumn( _T( "14" ), 20 ); - m_MemoryList->AddColumn( _T( "15" ), 20 ); - m_MemoryList->AddColumn( _T( "16" ), 35 ); - m_MemoryList->AddColumn( _T( "Memory Ascii" ), 140 ); - ::SetWindowLongPtr(m_MemoryList->m_hWnd, GWL_EXSTYLE, WS_EX_CLIENTEDGE); - RefreshMemory(false); - int height = m_MemoryList->GetTotalHeight(); - - RECT MemoryListRect = {0}; - ::GetClientRect(GetDlgItem( IDC_MEM_DETAILS ), &MemoryListRect); + if (m_MemoryList == NULL) + { + m_MemoryList = new CListCtrl; + m_MemoryList->RegisterClass(); + } + m_MemoryList->SubclassWindow(GetDlgItem(IDC_MEM_DETAILS)); + m_MemoryList->ShowHeader(false); + m_MemoryList->SetSortEnabled(FALSE); + m_MemoryList->AddColumn(_T("Address"), 90); + m_MemoryList->AddColumn(_T("1"), 20); + m_MemoryList->AddColumn(_T("2"), 20); + m_MemoryList->AddColumn(_T("3"), 20); + m_MemoryList->AddColumn(_T("4"), 20); + m_MemoryList->AddColumn(_T("-"), 10); + m_MemoryList->AddColumn(_T("5"), 20); + m_MemoryList->AddColumn(_T("6"), 20); + m_MemoryList->AddColumn(_T("7"), 20); + m_MemoryList->AddColumn(_T("8"), 20); + m_MemoryList->AddColumn(_T("-"), 10); + m_MemoryList->AddColumn(_T("9"), 20); + m_MemoryList->AddColumn(_T("10"), 20); + m_MemoryList->AddColumn(_T("11"), 20); + m_MemoryList->AddColumn(_T("12"), 20); + m_MemoryList->AddColumn(_T("-"), 10); + m_MemoryList->AddColumn(_T("13"), 20); + m_MemoryList->AddColumn(_T("14"), 20); + m_MemoryList->AddColumn(_T("15"), 20); + m_MemoryList->AddColumn(_T("16"), 35); + m_MemoryList->AddColumn(_T("Memory Ascii"), 140); + ::SetWindowLongPtr(m_MemoryList->m_hWnd, GWL_EXSTYLE, WS_EX_CLIENTEDGE); + RefreshMemory(false); + int height = m_MemoryList->GetTotalHeight(); - if (height > MemoryListRect.bottom) - { - RECT MemoryListWindow = {0}; - GetWindowRect(&MemoryListWindow); - SetWindowPos(NULL,0,0,MemoryListWindow.right - MemoryListWindow.left,(MemoryListWindow.bottom - MemoryListWindow.top) + (height - MemoryListRect.bottom), SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOZORDER); + RECT MemoryListRect = { 0 }; + ::GetClientRect(GetDlgItem(IDC_MEM_DETAILS), &MemoryListRect); - RECT DlgItemRect = {0}; - ::GetWindowRect(GetDlgItem( IDC_BORDER ), &DlgItemRect); - ::SetWindowPos(GetDlgItem( IDC_BORDER ), NULL,0,0,DlgItemRect.right - DlgItemRect.left,(DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE); + if (height > MemoryListRect.bottom) + { + RECT MemoryListWindow = { 0 }; + GetWindowRect(&MemoryListWindow); + SetWindowPos(NULL, 0, 0, MemoryListWindow.right - MemoryListWindow.left, (MemoryListWindow.bottom - MemoryListWindow.top) + (height - MemoryListRect.bottom), SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOZORDER); - ::GetWindowRect(GetDlgItem( IDC_MEM_DETAILS ), &DlgItemRect); - ::SetWindowPos(GetDlgItem( IDC_MEM_DETAILS ), NULL,0,0,DlgItemRect.right - DlgItemRect.left,(DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE); + RECT DlgItemRect = { 0 }; + ::GetWindowRect(GetDlgItem(IDC_BORDER), &DlgItemRect); + ::SetWindowPos(GetDlgItem(IDC_BORDER), NULL, 0, 0, DlgItemRect.right - DlgItemRect.left, (DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE); - ::GetWindowRect(GetDlgItem( IDC_SCRL_BAR ), &DlgItemRect); - ::SetWindowPos(GetDlgItem( IDC_SCRL_BAR ), NULL,0,0,DlgItemRect.right - DlgItemRect.left,(DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE); - } - WindowCreated(); - return TRUE; + ::GetWindowRect(GetDlgItem(IDC_MEM_DETAILS), &DlgItemRect); + ::SetWindowPos(GetDlgItem(IDC_MEM_DETAILS), NULL, 0, 0, DlgItemRect.right - DlgItemRect.left, (DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE); + + ::GetWindowRect(GetDlgItem(IDC_SCRL_BAR), &DlgItemRect); + ::SetWindowPos(GetDlgItem(IDC_SCRL_BAR), NULL, 0, 0, DlgItemRect.right - DlgItemRect.left, (DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE); + } + WindowCreated(); + return TRUE; } -LRESULT CDebugMemoryView::OnDestroy ( void ) +LRESULT CDebugMemoryView::OnDestroy(void) { - if (m_MemoryList) - { - m_MemoryList->UnsubclassWindow(); - delete m_MemoryList; - m_MemoryList = NULL; - } - return 0; + if (m_MemoryList) + { + m_MemoryList->UnsubclassWindow(); + delete m_MemoryList; + m_MemoryList = NULL; + } + return 0; } -LRESULT CDebugMemoryView::OnClicked (WORD /*wNotifyCode*/, WORD wID, HWND , BOOL& /*bHandled*/) +LRESULT CDebugMemoryView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& /*bHandled*/) { - switch (wID) - { - case IDC_REFRSH_MEM: - RefreshMemory(true); - break; - case IDC_CHK_VADDR: - RefreshMemory(false); - break; - case IDC_DUMP_MEM: - m_Debugger->Debug_ShowMemoryDump(); - break; - case IDC_SEARCH_MEM: - m_Debugger->Debug_ShowMemorySearch(); - break; - case IDCANCEL: - EndDialog(0); - break; - } - return FALSE; + switch (wID) + { + case IDC_REFRSH_MEM: + RefreshMemory(true); + break; + case IDC_CHK_VADDR: + RefreshMemory(false); + break; + case IDC_DUMP_MEM: + m_Debugger->Debug_ShowMemoryDump(); + break; + case IDC_SEARCH_MEM: + m_Debugger->Debug_ShowMemorySearch(); + break; + case IDCANCEL: + EndDialog(0); + break; + } + return FALSE; } -LRESULT CDebugMemoryView::OnMemoryModified ( LPNMHDR lpNMHDR ) +LRESULT CDebugMemoryView::OnMemoryModified(LPNMHDR lpNMHDR) { - CListNotify *pListNotify = reinterpret_cast( lpNMHDR ); - int LineNumber = pListNotify->m_nItem; - int Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 1)); - if (pListNotify->m_nSubItem >= 6 && pListNotify->m_nSubItem < 10) - { - Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 2)); - } - if (pListNotify->m_nSubItem >= 11 && pListNotify->m_nSubItem < 15) - { - Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 3)); - } - if (pListNotify->m_nSubItem >= 16 && pListNotify->m_nSubItem < 20) - { - Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 4)); - } + CListNotify *pListNotify = reinterpret_cast(lpNMHDR); + int LineNumber = pListNotify->m_nItem; + int Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 1)); + if (pListNotify->m_nSubItem >= 6 && pListNotify->m_nSubItem < 10) + { + Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 2)); + } + if (pListNotify->m_nSubItem >= 11 && pListNotify->m_nSubItem < 15) + { + Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 3)); + } + if (pListNotify->m_nSubItem >= 16 && pListNotify->m_nSubItem < 20) + { + Pos = ((LineNumber << 4) + (pListNotify->m_nSubItem - 4)); + } - LPCSTR strValue = m_MemoryList->GetItemText(pListNotify->m_nItem,pListNotify->m_nSubItem); - int Finish = strlen(strValue); - if (Finish > 8) - { - Finish = 8; - } - DWORD Value = 0; - for (int i = 0; i < Finish; i++) - { - Value = (Value << 4); - if (strValue[i] <= '9' && strValue[i] >= '0') - { - Value |= strValue[i] - '0'; - } - else if (strValue[i] <= 'f' && strValue[i] >= 'a') - { - Value |= strValue[i] - 'a' + 10; - } - else if (strValue[i] <= 'F' && strValue[i] >= 'A') - { - Value |= strValue[i] - 'A' + 10; - } - } + LPCSTR strValue = m_MemoryList->GetItemText(pListNotify->m_nItem, pListNotify->m_nSubItem); + int Finish = strlen(strValue); + if (Finish > 8) + { + Finish = 8; + } + DWORD Value = 0; + for (int i = 0; i < Finish; i++) + { + Value = (Value << 4); + if (strValue[i] <= '9' && strValue[i] >= '0') + { + Value |= strValue[i] - '0'; + } + else if (strValue[i] <= 'f' && strValue[i] >= 'a') + { + Value |= strValue[i] - 'a' + 10; + } + else if (strValue[i] <= 'F' && strValue[i] >= 'A') + { + Value |= strValue[i] - 'A' + 10; + } + } - if (m_CurrentData[Pos] == Value) - { - return 0; - } + if (m_CurrentData[Pos] == Value) + { + return 0; + } - if (m_CompareStartLoc != m_DataStartLoc || - m_CompareVAddrr != m_DataVAddrr) - { - // copy current data for change comparison - m_CompareStartLoc = m_DataStartLoc; - m_CompareVAddrr = m_DataVAddrr; - memcpy(m_CompareData,m_CurrentData,sizeof(m_CurrentData)); - memcpy(m_CompareValid,m_DataValid,sizeof(m_CompareValid)); - } + if (m_CompareStartLoc != m_DataStartLoc || + m_CompareVAddrr != m_DataVAddrr) + { + // copy current data for change comparison + m_CompareStartLoc = m_DataStartLoc; + m_CompareVAddrr = m_DataVAddrr; + memcpy(m_CompareData, m_CurrentData, sizeof(m_CurrentData)); + memcpy(m_CompareValid, m_DataValid, sizeof(m_CompareValid)); + } - m_CompareData[Pos] = m_CurrentData[Pos]; - m_CurrentData[Pos] = (BYTE)Value; + m_CompareData[Pos] = m_CurrentData[Pos]; + m_CurrentData[Pos] = (BYTE)Value; - //sb - if ( m_DataVAddrr ) - { - if (!g_MMU->SB_VAddr(m_DataStartLoc + Pos,(BYTE)Value)) - { - WriteTraceF(TraceError,__FUNCTION__ ": failed to store at %X",m_DataStartLoc + Pos); - } - } - else - { - if (!g_MMU->SB_PAddr(m_DataStartLoc + Pos,(BYTE)Value)) - { - WriteTraceF(TraceError,__FUNCTION__ ": failed to store at %X",m_DataStartLoc + Pos); - } - } - Insert_MemoryLineDump(LineNumber); + //sb + if (m_DataVAddrr) + { + if (!g_MMU->SB_VAddr(m_DataStartLoc + Pos, (BYTE)Value)) + { + WriteTraceF(TraceError, __FUNCTION__ ": failed to store at %X", m_DataStartLoc + Pos); + } + } + else + { + if (!g_MMU->SB_PAddr(m_DataStartLoc + Pos, (BYTE)Value)) + { + WriteTraceF(TraceError, __FUNCTION__ ": failed to store at %X", m_DataStartLoc + Pos); + } + } + Insert_MemoryLineDump(LineNumber); - return 0; + return 0; } void CDebugMemoryView::ShowAddress(DWORD Address, bool VAddr) { - if (m_hWnd == NULL) - { - return; - } + if (m_hWnd == NULL) + { + return; + } - SendDlgItemMessage( IDC_CHK_VADDR, BM_SETCHECK, VAddr ? BST_CHECKED : BST_UNCHECKED,0); - m_MemAddr.SetValue(Address,true,true); - RefreshMemory (true); + SendDlgItemMessage(IDC_CHK_VADDR, BM_SETCHECK, VAddr ? BST_CHECKED : BST_UNCHECKED, 0); + m_MemAddr.SetValue(Address, true, true); + RefreshMemory(true); } -void CDebugMemoryView::Insert_MemoryLineDump ( int LineNumber ) +void CDebugMemoryView::Insert_MemoryLineDump(int LineNumber) { - if (m_MemoryList == NULL || m_MemoryList->GetColumnCount() == 0) - { - return; - } - char Output[20], Hex[60], Ascii[20], AsciiAddOn[15]; - sprintf(Output,"0x%08X",m_DataStartLoc + (LineNumber << 4)); - if (m_MemoryList->GetItemCount() <= LineNumber) - { - HFONT hFont = (HFONT)GetStockObject(ANSI_FIXED_FONT); - m_MemoryList->AddItemAt( LineNumber, Output); - for (int i = 0; i < m_MemoryList->GetColumnCount(); i++) - { - m_MemoryList->SetItemFont( LineNumber, i, hFont ); - if (i == 5 || i == 10 || i == 15) - { - m_MemoryList->SetItemText(LineNumber,i,"-"); - } - } - } - else - { - if ( strcmp( Output, m_MemoryList->GetItemText(LineNumber, 0) ) != 0 ) - { - m_MemoryList->SetItemText(LineNumber,0,Output); - } - } + if (m_MemoryList == NULL || m_MemoryList->GetColumnCount() == 0) + { + return; + } + char Output[20], Hex[60], Ascii[20], AsciiAddOn[15]; + sprintf(Output, "0x%08X", m_DataStartLoc + (LineNumber << 4)); + if (m_MemoryList->GetItemCount() <= LineNumber) + { + HFONT hFont = (HFONT)GetStockObject(ANSI_FIXED_FONT); + m_MemoryList->AddItemAt(LineNumber, Output); + for (int i = 0; i < m_MemoryList->GetColumnCount(); i++) + { + m_MemoryList->SetItemFont(LineNumber, i, hFont); + if (i == 5 || i == 10 || i == 15) + { + m_MemoryList->SetItemText(LineNumber, i, "-"); + } + } + } + else + { + if (strcmp(Output, m_MemoryList->GetItemText(LineNumber, 0)) != 0) + { + m_MemoryList->SetItemText(LineNumber, 0, Output); + } + } - Hex[0] = 0; - Ascii[0] = 0; - int CompareStartPos = m_DataStartLoc - m_CompareStartLoc; + Hex[0] = 0; + Ascii[0] = 0; + int CompareStartPos = m_DataStartLoc - m_CompareStartLoc; - for (int i = 0, col = 1; i < 0x10; i ++, col ++) - { - int Pos = ((LineNumber << 4) + i); - if (m_DataValid[Pos]) - { - int ComparePos = CompareStartPos + Pos; - bool Changed = false; + for (int i = 0, col = 1; i < 0x10; i++, col++) + { + int Pos = ((LineNumber << 4) + i); + if (m_DataValid[Pos]) + { + int ComparePos = CompareStartPos + Pos; + bool Changed = false; - if (ComparePos >= 0 && ComparePos < MemoryToDisplay && - m_DataVAddrr == m_CompareVAddrr && - m_DataValid[ComparePos] && - m_CurrentData[Pos] != m_CompareData[ComparePos]) - { - Changed = true; - } - sprintf(Hex,"%02X",m_CurrentData[Pos]); - m_MemoryList->SetItemText(LineNumber,col,Hex); - m_MemoryList->SetItemFormat( LineNumber,col, ITEM_FORMAT_EDIT, ITEM_FLAGS_EDIT_HEX ); - m_MemoryList->SetItemMaxEditLen( LineNumber,col , 2); - m_MemoryList->SetItemColours( LineNumber, col, GetSysColor( COLOR_WINDOW ), - Changed ? RGB( 255, 0, 0 ) : GetSysColor( COLOR_WINDOWTEXT ) ); - m_MemoryList->SetItemHighlightColours( LineNumber, col, - Changed ? RGB( 255, 0, 0 ) : GetSysColor( COLOR_HIGHLIGHTTEXT ) ); - if (m_CurrentData[Pos] < 30) - { - strcat(Ascii,"."); - } - else - { - sprintf(AsciiAddOn,"%c",m_CurrentData[Pos]); - strcat(Ascii,AsciiAddOn); - } - } - else - { - m_MemoryList->SetItemText(LineNumber,col,"**"); - m_MemoryList->SetItemFormat( LineNumber,col, ITEM_FORMAT_NONE, ITEM_FLAGS_NONE ); - m_MemoryList->SetItemColours( LineNumber, col, GetSysColor( COLOR_WINDOW ), GetSysColor( COLOR_WINDOWTEXT ) ); - strcat(Ascii,"*"); - } - if (i != 0xF) - { - if ((i & 3) == 3) - { - col += 1; - } - } - } - - if ( strcmp( Ascii, m_MemoryList->GetItemText(LineNumber, 20) ) != 0 ) - { - m_MemoryList->SetItemText(LineNumber,20,Ascii); - } + if (ComparePos >= 0 && ComparePos < MemoryToDisplay && + m_DataVAddrr == m_CompareVAddrr && + m_DataValid[ComparePos] && + m_CurrentData[Pos] != m_CompareData[ComparePos]) + { + Changed = true; + } + sprintf(Hex, "%02X", m_CurrentData[Pos]); + m_MemoryList->SetItemText(LineNumber, col, Hex); + m_MemoryList->SetItemFormat(LineNumber, col, ITEM_FORMAT_EDIT, ITEM_FLAGS_EDIT_HEX); + m_MemoryList->SetItemMaxEditLen(LineNumber, col, 2); + m_MemoryList->SetItemColours(LineNumber, col, GetSysColor(COLOR_WINDOW), + Changed ? RGB(255, 0, 0) : GetSysColor(COLOR_WINDOWTEXT)); + m_MemoryList->SetItemHighlightColours(LineNumber, col, + Changed ? RGB(255, 0, 0) : GetSysColor(COLOR_HIGHLIGHTTEXT)); + if (m_CurrentData[Pos] < 30) + { + strcat(Ascii, "."); + } + else + { + sprintf(AsciiAddOn, "%c", m_CurrentData[Pos]); + strcat(Ascii, AsciiAddOn); + } + } + else + { + m_MemoryList->SetItemText(LineNumber, col, "**"); + m_MemoryList->SetItemFormat(LineNumber, col, ITEM_FORMAT_NONE, ITEM_FLAGS_NONE); + m_MemoryList->SetItemColours(LineNumber, col, GetSysColor(COLOR_WINDOW), GetSysColor(COLOR_WINDOWTEXT)); + strcat(Ascii, "*"); + } + if (i != 0xF) + { + if ((i & 3) == 3) + { + col += 1; + } + } + } + + if (strcmp(Ascii, m_MemoryList->GetItemText(LineNumber, 20)) != 0) + { + m_MemoryList->SetItemText(LineNumber, 20, Ascii); + } } -void CDebugMemoryView::OnAddrChanged( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) +void CDebugMemoryView::OnAddrChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { - RefreshMemory(false); + RefreshMemory(false); } -void CDebugMemoryView::OnVScroll(int request, short Pos, HWND ctrl ) +void CDebugMemoryView::OnVScroll(int request, short Pos, HWND ctrl) { - if (ctrl != GetDlgItem(IDC_SCRL_BAR)) - { - return; - } - DWORD Location = m_MemAddr.GetValue(); - switch (request) - { - case SB_LINEDOWN: - m_MemAddr.SetValue(Location < 0xFFFFFFEF ? Location + 0x10 : 0xFFFFFFFF,true,true); - break; - case SB_LINEUP: - m_MemAddr.SetValue(Location > 0x10 ? Location - 0x10 : 0,true,true); - break; - case SB_PAGEDOWN: - m_MemAddr.SetValue(Location < 0xFFFFFEFF ? Location + 0x100 : 0xFFFFFFFF,true,true); - break; - case SB_PAGEUP: - m_MemAddr.SetValue(Location > 0x100 ? Location - 0x100 : 0,true,true); - break; - case SB_THUMBPOSITION: - m_MemAddr.SetValue((DWORD)Pos << 0x10,true,true); - break; - default: - break; - } + if (ctrl != GetDlgItem(IDC_SCRL_BAR)) + { + return; + } + DWORD Location = m_MemAddr.GetValue(); + switch (request) + { + case SB_LINEDOWN: + m_MemAddr.SetValue(Location < 0xFFFFFFEF ? Location + 0x10 : 0xFFFFFFFF, true, true); + break; + case SB_LINEUP: + m_MemAddr.SetValue(Location > 0x10 ? Location - 0x10 : 0, true, true); + break; + case SB_PAGEDOWN: + m_MemAddr.SetValue(Location < 0xFFFFFEFF ? Location + 0x100 : 0xFFFFFFFF, true, true); + break; + case SB_PAGEUP: + m_MemAddr.SetValue(Location > 0x100 ? Location - 0x100 : 0, true, true); + break; + case SB_THUMBPOSITION: + m_MemAddr.SetValue((DWORD)Pos << 0x10, true, true); + break; + default: + break; + } } -void CDebugMemoryView::RefreshMemory ( bool ResetCompare ) +void CDebugMemoryView::RefreshMemory(bool ResetCompare) { - if (m_MemoryList && m_MemoryList->GetHasEditItem()) - { - m_MemoryList->SetFocus(); - } + if (m_MemoryList && m_MemoryList->GetHasEditItem()) + { + m_MemoryList->SetFocus(); + } - DWORD NewAddress = m_MemAddr.GetValue(); - if (NewAddress != m_DataStartLoc) - { - HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR); - if (hScrlBar) - { - SCROLLINFO si; + DWORD NewAddress = m_MemAddr.GetValue(); + if (NewAddress != m_DataStartLoc) + { + HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR); + if (hScrlBar) + { + SCROLLINFO si; - si.cbSize = sizeof(si); - si.fMask = SIF_POS; - si.nPos = NewAddress >> 0x10; - ::SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE); - } - } + si.cbSize = sizeof(si); + si.fMask = SIF_POS; + si.nPos = NewAddress >> 0x10; + ::SetScrollInfo(hScrlBar, SB_CTL, &si, TRUE); + } + } - if (ResetCompare) - { - // copy current data for change comparison - m_CompareStartLoc = m_DataStartLoc; - m_CompareVAddrr = m_DataVAddrr; - memcpy(m_CompareData,m_CurrentData,sizeof(m_CurrentData)); - memcpy(m_CompareValid,m_DataValid,sizeof(m_CompareValid)); - } - - m_DataStartLoc = m_MemAddr.GetValue(); - if (m_DataStartLoc > 0xFFFFFF00) { m_DataStartLoc = 0xFFFFFF00; } - int WritePos = 0; + if (ResetCompare) + { + // copy current data for change comparison + m_CompareStartLoc = m_DataStartLoc; + m_CompareVAddrr = m_DataVAddrr; + memcpy(m_CompareData, m_CurrentData, sizeof(m_CurrentData)); + memcpy(m_CompareValid, m_DataValid, sizeof(m_CompareValid)); + } - m_DataVAddrr = (SendDlgItemMessage( IDC_CHK_VADDR, BM_GETCHECK, 0,0) & BST_CHECKED) != 0; + m_DataStartLoc = m_MemAddr.GetValue(); + if (m_DataStartLoc > 0xFFFFFF00) { m_DataStartLoc = 0xFFFFFF00; } + int WritePos = 0; - if ((m_DataStartLoc & 3) != 0) - { - MIPS_WORD word; - bool ValidData = true; - - if ( m_DataVAddrr ) - { - if (!g_MMU->LW_VAddr(m_DataStartLoc & ~3, word.UW)) - { - ValidData = false; - } - } - else - { - if (!g_MMU->LW_PAddr(m_DataStartLoc & ~3, word.UW)) - { - ValidData = false; - } - } + m_DataVAddrr = (SendDlgItemMessage(IDC_CHK_VADDR, BM_GETCHECK, 0, 0) & BST_CHECKED) != 0; - int Offset = (m_DataStartLoc & 3); - for (int i = 0; i < (4 - Offset); i++) - { - if (WritePos >= MemoryToDisplay) - { - break; - } - m_DataValid[WritePos + i] = ValidData; - if (ValidData) - { - m_CurrentData[WritePos + i] = word.UB[3 - (i + Offset)]; - } - } - WritePos = 4 - Offset; - - } + if ((m_DataStartLoc & 3) != 0) + { + MIPS_WORD word; + bool ValidData = true; - for (DWORD Pos = ((m_DataStartLoc + 3) & ~3); Pos < (m_DataStartLoc + MemoryToDisplay); WritePos += 4, Pos += 4) - { - MIPS_WORD word; - bool ValidData = true; - - if ( m_DataVAddrr ) - { - if (!g_MMU->LW_VAddr(Pos, word.UW)) - { - ValidData = false; - } - } - else - { - if (!g_MMU->LW_PAddr(Pos, word.UW)) - { - ValidData = false; - } - } + if (m_DataVAddrr) + { + if (!g_MMU->LW_VAddr(m_DataStartLoc & ~3, word.UW)) + { + ValidData = false; + } + } + else + { + if (!g_MMU->LW_PAddr(m_DataStartLoc & ~3, word.UW)) + { + ValidData = false; + } + } - for (int i = 0; i < 4; i++) - { - if ((WritePos + i)>= MemoryToDisplay) - { - break; - } - m_DataValid[WritePos + i] = ValidData; - if (ValidData) - { - m_CurrentData[WritePos + i] = word.UB[3 - i]; - } - } - } + int Offset = (m_DataStartLoc & 3); + for (int i = 0; i < (4 - Offset); i++) + { + if (WritePos >= MemoryToDisplay) + { + break; + } + m_DataValid[WritePos + i] = ValidData; + if (ValidData) + { + m_CurrentData[WritePos + i] = word.UB[3 - (i + Offset)]; + } + } + WritePos = 4 - Offset; + } - for (int count = 0 ; count < 16;count ++) - { - Insert_MemoryLineDump ( count ); - } + for (DWORD Pos = ((m_DataStartLoc + 3) & ~3); Pos < (m_DataStartLoc + MemoryToDisplay); WritePos += 4, Pos += 4) + { + MIPS_WORD word; + bool ValidData = true; + + if (m_DataVAddrr) + { + if (!g_MMU->LW_VAddr(Pos, word.UW)) + { + ValidData = false; + } + } + else + { + if (!g_MMU->LW_PAddr(Pos, word.UW)) + { + ValidData = false; + } + } + + for (int i = 0; i < 4; i++) + { + if ((WritePos + i) >= MemoryToDisplay) + { + break; + } + m_DataValid[WritePos + i] = ValidData; + if (ValidData) + { + m_CurrentData[WritePos + i] = word.UB[3 - i]; + } + } + } + + for (int count = 0; count < 16; count++) + { + Insert_MemoryLineDump(count); + } } -#endif diff --git a/Source/Project64/N64 System/Debugger/Debugger - View Memory.h b/Source/Project64/N64 System/Debugger/Debugger - View Memory.h index 03b1f8c29..4c48ad5b6 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - View Memory.h +++ b/Source/Project64/N64 System/Debugger/Debugger - View Memory.h @@ -11,48 +11,48 @@ #pragma once class CDebugMemoryView : - public CDebugDialog + public CDebugDialog < CDebugMemoryView > { +public: + enum { IDD = IDD_Debugger_Memory }; - BEGIN_MSG_MAP_EX(CDebugMemoryView) - MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) - COMMAND_CODE_HANDLER(BN_CLICKED,OnClicked) - COMMAND_HANDLER_EX(IDC_ADDR_EDIT,EN_CHANGE,OnAddrChanged) - NOTIFY_HANDLER_EX(IDC_MEM_DETAILS, LCN_MODIFIED, OnMemoryModified) - MSG_WM_DESTROY(OnDestroy) - MSG_WM_VSCROLL(OnVScroll) - END_MSG_MAP() + CDebugMemoryView(CDebuggerUI * debugger); + virtual ~CDebugMemoryView(void); - LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); - LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled); - void OnAddrChanged( UINT Code, int id, HWND ctl ); - void OnVScroll(int request, short Pos, HWND ctrl ); - LRESULT OnMemoryModified ( LPNMHDR lpNMHDR ); - LRESULT OnDestroy ( void ); + void ShowAddress(DWORD Address, bool VAddr); - void Insert_MemoryLineDump ( int LineNumber ); - void RefreshMemory ( bool ResetCompare ); - - enum { MemoryToDisplay = 0x100}; +private: + BEGIN_MSG_MAP_EX(CDebugMemoryView) + MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) + COMMAND_CODE_HANDLER(BN_CLICKED, OnClicked) + COMMAND_HANDLER_EX(IDC_ADDR_EDIT, EN_CHANGE, OnAddrChanged) + NOTIFY_HANDLER_EX(IDC_MEM_DETAILS, LCN_MODIFIED, OnMemoryModified) + MSG_WM_DESTROY(OnDestroy) + MSG_WM_VSCROLL(OnVScroll) + END_MSG_MAP() - CEditNumber m_MemAddr; - CListCtrl * m_MemoryList; + LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT OnClicked(WORD wNotifyCode, WORD wID, HWND /*hWndCtl*/, BOOL& bHandled); + void OnAddrChanged(UINT Code, int id, HWND ctl); + void OnVScroll(int request, short Pos, HWND ctrl); + LRESULT OnMemoryModified(LPNMHDR lpNMHDR); + LRESULT OnDestroy(void); - DWORD m_DataStartLoc; - bool m_DataVAddrr; - BYTE m_CurrentData[MemoryToDisplay]; - bool m_DataValid[MemoryToDisplay]; + void Insert_MemoryLineDump(int LineNumber); + void RefreshMemory(bool ResetCompare); - DWORD m_CompareStartLoc; - bool m_CompareVAddrr; - BYTE m_CompareData[MemoryToDisplay]; - bool m_CompareValid[MemoryToDisplay]; - -public: - enum { IDD = IDD_Debugger_Memory }; + enum { MemoryToDisplay = 0x100 }; - CDebugMemoryView(CDebugger * debugger); - virtual ~CDebugMemoryView(void); + CEditNumber m_MemAddr; + CListCtrl * m_MemoryList; - void ShowAddress (DWORD Address, bool VAddr); + DWORD m_DataStartLoc; + bool m_DataVAddrr; + BYTE m_CurrentData[MemoryToDisplay]; + bool m_DataValid[MemoryToDisplay]; + + DWORD m_CompareStartLoc; + bool m_CompareVAddrr; + BYTE m_CompareData[MemoryToDisplay]; + bool m_CompareValid[MemoryToDisplay]; }; diff --git a/Source/Project64/N64 System/Debugger/Debugger UI.h b/Source/Project64/N64 System/Debugger/Debugger UI.h index 0884e6cf4..ec2bfaf2b 100644 --- a/Source/Project64/N64 System/Debugger/Debugger UI.h +++ b/Source/Project64/N64 System/Debugger/Debugger UI.h @@ -1,41 +1,4 @@ -////#define _WIN32_WINNT 0x0500 - -//#include -//#include - -////#include -////#include - -//class CPj64Module : -// public CAppModule -//{ -//public: -// CPj64Module(void) -// { -// Init(NULL, GetModuleHandle(NULL)); -// } -// virtual ~CPj64Module(void) -// { -// Term(); -// } -//}; -// -// -//extern CPj64Module _Module; -// -//#define _WTL_NO_CSTRING -// -//#include -//#include -//#include -// -//#include -//#include -//#include -// -//#include "../../Support.h" -//#include "Control/numberctrl.h" -//#include "Control/ClistCtrl/ListCtrl.h" +#pragma once #include "../../WTL App.h" #include "../../N64 System.h" diff --git a/Source/Project64/N64 System/Debugger/Debugger.cpp b/Source/Project64/N64 System/Debugger/Debugger.cpp index ea190aaf3..433b7bf97 100644 --- a/Source/Project64/N64 System/Debugger/Debugger.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger.cpp @@ -9,127 +9,141 @@ * * ****************************************************************************/ #include "stdafx.h" - -#ifdef WINDOWS_UI #include "Debugger UI.h" CPj64Module _Module; -CDebugger::CDebugger () : - m_MemoryDump(NULL), - m_MemoryView(NULL), - m_MemorySearch(NULL), - m_DebugTLB(NULL) +CDebuggerUI::CDebuggerUI () : + m_MemoryDump(NULL), + m_MemoryView(NULL), + m_MemorySearch(NULL), + m_DebugTLB(NULL) { + g_Settings->RegisterChangeCB(GameRunning_InReset,this,(CSettings::SettingChangedFunc)GameReset); + g_Debugger = this; } -CDebugger::~CDebugger (void) +CDebuggerUI::~CDebuggerUI (void) { - Debug_Reset(); + g_Settings->UnregisterChangeCB(GameRunning_InReset,this,(CSettings::SettingChangedFunc)GameReset); + Debug_Reset(); } -void CDebugger::Debug_Reset ( void ) +void CDebuggerUI::GameReset ( CDebuggerUI * _this ) { - if (m_MemoryDump) - { - m_MemoryDump->HideWindow(); - delete m_MemoryDump; - m_MemoryDump = NULL; - } - if (m_MemoryView) - { - m_MemoryView->HideWindow(); - delete m_MemoryView; - m_MemoryView = NULL; - } - if (m_MemorySearch) - { - m_MemorySearch->HideWindow(); - delete m_MemorySearch; - m_MemorySearch = NULL; - } - if (m_DebugTLB) - { - m_DebugTLB->HideWindow(); - delete m_DebugTLB; - m_DebugTLB = NULL; - } -} - -void CDebugger::Debug_ShowMemoryDump() -{ - if (g_MMU == NULL) + if (!g_Settings->LoadBool(GameRunning_InReset)) { return; } - if (m_MemoryDump == NULL) - { - m_MemoryDump = new CDumpMemory(this); - } - if (m_MemoryDump) - { - m_MemoryDump->ShowWindow(); - } + _this->Debug_Reset(); } -void CDebugger::Debug_ShowMemoryWindow ( void ) +void CDebuggerUI::Debug_Reset ( void ) { - if (g_MMU == NULL) - { - return; - } - if (m_MemoryView == NULL) - { - m_MemoryView = new CDebugMemoryView(this); - } - if (m_MemoryView) - { - m_MemoryView->ShowWindow(); - } + if (m_MemoryDump) + { + m_MemoryDump->HideWindow(); + delete m_MemoryDump; + m_MemoryDump = NULL; + } + if (m_MemoryView) + { + m_MemoryView->HideWindow(); + delete m_MemoryView; + m_MemoryView = NULL; + } + if (m_MemorySearch) + { + m_MemorySearch->HideWindow(); + delete m_MemorySearch; + m_MemorySearch = NULL; + } + if (m_DebugTLB) + { + m_DebugTLB->HideWindow(); + delete m_DebugTLB; + m_DebugTLB = NULL; + } } -void CDebugger::Debug_ShowMemoryLocation ( DWORD Address, bool VAddr ) +void CDebuggerUI::Debug_ShowMemoryDump() { - Debug_ShowMemoryWindow(); - if (m_MemoryView) - { - m_MemoryView->ShowAddress(Address,VAddr); - } + if (g_MMU == NULL) + { + return; + } + if (m_MemoryDump == NULL) + { + m_MemoryDump = new CDumpMemory(this); + } + if (m_MemoryDump) + { + m_MemoryDump->ShowWindow(); + } } -void CDebugger::Debug_ShowTLBWindow (void) +void CDebuggerUI::Debug_ShowMemoryWindow ( void ) { - if (g_MMU == NULL) - { - return; - } - if (m_DebugTLB == NULL) - { - m_DebugTLB = new CDebugTlb(this); - } - if (m_DebugTLB) - { - m_DebugTLB->ShowWindow(); - } + if (g_MMU == NULL) + { + return; + } + if (m_MemoryView == NULL) + { + m_MemoryView = new CDebugMemoryView(this); + } + if (m_MemoryView) + { + m_MemoryView->ShowWindow(); + } } -void CDebugger::Debug_RefreshTLBWindow(void) +void CDebuggerUI::Debug_ShowMemoryLocation ( uint32_t Address, bool VAddr ) { - if (m_DebugTLB) - { - m_DebugTLB->RefreshTLBWindow(); - } + Debug_ShowMemoryWindow(); + if (m_MemoryView) + { + m_MemoryView->ShowAddress(Address,VAddr); + } } -void CDebugger::Debug_ShowMemorySearch() +void CDebuggerUI::Debug_ShowTLBWindow (void) { - if (m_MemorySearch == NULL) - { - m_MemorySearch = new CDebugMemorySearch(this); - } - if (m_MemorySearch) - { - m_MemorySearch->ShowWindow(); - } + if (g_MMU == NULL) + { + return; + } + if (m_DebugTLB == NULL) + { + m_DebugTLB = new CDebugTlb(this); + } + if (m_DebugTLB) + { + m_DebugTLB->ShowWindow(); + } } -#endif + +void CDebuggerUI::Debug_RefreshTLBWindow(void) +{ + if (m_DebugTLB) + { + m_DebugTLB->RefreshTLBWindow(); + } +} + +void CDebuggerUI::Debug_ShowMemorySearch() +{ + if (m_MemorySearch == NULL) + { + m_MemorySearch = new CDebugMemorySearch(this); + } + if (m_MemorySearch) + { + m_MemorySearch->ShowWindow(); + } +} + +void CDebuggerUI::TLBChanged() +{ + Debug_RefreshTLBWindow(); +} \ No newline at end of file diff --git a/Source/Project64/N64 System/Debugger/debugger.h b/Source/Project64/N64 System/Debugger/debugger.h index dfa53181a..e8e48f1c0 100644 --- a/Source/Project64/N64 System/Debugger/debugger.h +++ b/Source/Project64/N64 System/Debugger/debugger.h @@ -13,25 +13,35 @@ class CDumpMemory; class CDebugMemoryView; class CDebugMemorySearch; +class CDebugTlb; -class CDebugger +__interface CDebugger { - CDumpMemory * m_MemoryDump; - CDebugMemoryView * m_MemoryView; - CDebugMemorySearch * m_MemorySearch; - CDebugTlb * m_DebugTLB; + virtual void TLBChanged ( void ) = 0; +}; + +class CDebuggerUI : + public CDebugger +{ + CDumpMemory * m_MemoryDump; + CDebugMemoryView * m_MemoryView; + CDebugMemorySearch * m_MemorySearch; + CDebugTlb * m_DebugTLB; protected: - CDebugger(); - virtual ~CDebugger(); - -public: - - void Debug_Reset ( void ); - void Debug_ShowMemoryDump ( void ); - void Debug_ShowMemoryWindow ( void ); - void Debug_ShowMemoryLocation ( DWORD Address, bool VAddr ); - void Debug_ShowMemorySearch ( void ); - void Debug_ShowTLBWindow ( void ); - void Debug_RefreshTLBWindow ( void ); + CDebuggerUI(); + virtual ~CDebuggerUI(); + + void TLBChanged ( void ); + +public: + void Debug_Reset ( void ); + void Debug_ShowMemoryDump ( void ); + void Debug_ShowMemoryWindow ( void ); + void Debug_ShowMemoryLocation ( uint32_t Address, bool VAddr ); + void Debug_ShowMemorySearch ( void ); + void Debug_ShowTLBWindow ( void ); + void Debug_RefreshTLBWindow ( void ); + + static void GameReset ( CDebuggerUI * _this ); }; diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index e4ac22b6c..8ae0ec6ee 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -567,14 +567,10 @@ void CN64System::PluginReset() void CN64System::Reset (bool bInitReg, bool ClearMenory) { + g_Settings->SaveBool(GameRunning_InReset,true); RefreshGameSettings(); m_Audio.Reset(); m_MMU_VM.Reset(ClearMenory); -#if defined(WINDOWS_UI) - Debug_Reset(); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); -#endif Mempak::Close(); m_CyclesToSkip = 0; @@ -617,6 +613,7 @@ void CN64System::Reset (bool bInitReg, bool ClearMenory) { m_SyncCPU->Reset(bInitReg,ClearMenory); } + g_Settings->SaveBool(GameRunning_InReset,true); } bool CN64System::SetActiveSystem( bool bActive ) @@ -2098,9 +2095,8 @@ void CN64System::TLB_Unmaped ( DWORD VAddr, DWORD Len ) void CN64System::TLB_Changed() { -#if defined(WINDOWS_UI) - Debug_RefreshTLBWindow(); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); -#endif + if (g_Debugger) + { + g_Debugger->TLBChanged(); + } } diff --git a/Source/Project64/N64 System/N64 Class.h b/Source/Project64/N64 System/N64 Class.h index f8a99de24..7c6c8700c 100644 --- a/Source/Project64/N64 System/N64 Class.h +++ b/Source/Project64/N64 System/N64 Class.h @@ -16,40 +16,36 @@ typedef std::map FUNC_CALLS; class CPlugins; class CRSP_Plugin; +class CRecompiler; //#define TEST_SP_TRACKING //track the SP to make sure all ops pick it up fine class CN64System : - private CMipsMemory_CallBack, - private CTLB_CB, - private CSystemEvents, - protected CN64SystemSettings, - public CGameSettings, -#if defined(WINDOWS_UI) - protected CDebugSettings, - public CDebugger -#else - protected CDebugSettings -#endif + public CMipsMemory_CallBack, + public CTLB_CB, + private CSystemEvents, + protected CN64SystemSettings, + public CGameSettings, + protected CDebugSettings { public: - CN64System ( CPlugins * Plugins, bool SavesReadOnly ); - virtual ~CN64System ( void ); + CN64System(CPlugins * Plugins, bool SavesReadOnly); + virtual ~CN64System(void); struct ThreadInfo { HANDLE * ThreadHandle; DWORD ThreadID; }; - CProfiling m_Profile; - CCheats m_Cheats; - bool m_EndEmulation; - SAVE_CHIP_TYPE m_SaveUsing; + CProfiling m_Profile; + CCheats m_Cheats; + bool m_EndEmulation; + SAVE_CHIP_TYPE m_SaveUsing; + + //Methods + static bool RunFileImage(const char * FileLoc); + static void CloseSystem(void); - //Methods - static bool RunFileImage ( const char * FileLoc ); - static void CloseSystem ( void ); - void CloseCpu (); void ExternalEvent ( SystemEvent action ); //covers gui interacting and timers etc.. stdstr ChooseFileToOpen ( HWND hParent ); diff --git a/Source/Project64/N64 System/System Globals.cpp b/Source/Project64/N64 System/System Globals.cpp index 83f7ffdb8..ea221e17d 100644 --- a/Source/Project64/N64 System/System Globals.cpp +++ b/Source/Project64/N64 System/System Globals.cpp @@ -26,6 +26,7 @@ CTransVaddr * g_TransVaddr = NULL; CSystemEvents * g_SystemEvents = NULL; DWORD * g_TLBLoadAddress = NULL; DWORD * g_TLBStoreAddress = NULL; +CDebugger * g_Debugger = NULL; int * g_NextTimer; diff --git a/Source/Project64/N64 System/System Globals.h b/Source/Project64/N64 System/System Globals.h index 0c7319b5c..12f993a58 100644 --- a/Source/Project64/N64 System/System Globals.h +++ b/Source/Project64/N64 System/System Globals.h @@ -29,3 +29,6 @@ extern CSystemEvents * g_SystemEvents; extern int * g_NextTimer; extern DWORD * g_TLBLoadAddress; extern DWORD * g_TLBStoreAddress; + +__interface CDebugger; +extern CDebugger * g_Debugger; diff --git a/Source/Project64/Project64.vcproj b/Source/Project64/Project64.vcproj index e76138d2c..75471d983 100644 --- a/Source/Project64/Project64.vcproj +++ b/Source/Project64/Project64.vcproj @@ -1064,6 +1064,10 @@ RelativePath="N64 System\Cheat Class.h" > + + diff --git a/Source/Project64/Settings.h b/Source/Project64/Settings.h index 94b407a72..869efbfa6 100644 --- a/Source/Project64/Settings.h +++ b/Source/Project64/Settings.h @@ -10,19 +10,23 @@ ****************************************************************************/ #pragma once -#define MaxPluginSetting 65535 +enum +{ + MaxPluginSetting = 65535 +}; -enum SettingID { +enum SettingID +{ //Default values Default_None, Default_Constant, - + //information - temp keys Info_ShortCutsChanged, //Support Files - SupportFile_Settings, - SupportFile_SettingsDefault, + SupportFile_Settings, + SupportFile_SettingsDefault, SupportFile_RomDatabase, SupportFile_RomDatabaseDefault, SupportFile_Glide64RDB, @@ -51,7 +55,7 @@ enum SettingID { Setting_AutoFullscreen, Setting_CheckEmuRunning, Setting_EraseGameDefaults, - + Setting_AutoZipInstantSave, Setting_RememberCheats, Setting_LanguageDir, @@ -154,7 +158,8 @@ enum SettingID { GameRunning_InstantSaveFile, GameRunning_LimitFPS, GameRunning_ScreenHertz, - + GameRunning_InReset, + //User Interface UserInterface_BasicMode, UserInterface_ShowCPUPer, @@ -248,14 +253,14 @@ enum SettingID { Cheat_Range, Cheat_RangeNotes, - FirstRSPDefaultSet, LastRSPDefaultSet = FirstRSPDefaultSet + MaxPluginSetting, - FirstRSPSettings, LastRSPSettings = FirstRSPSettings + MaxPluginSetting, - FirstGfxDefaultSet, LastGfxDefaultSet = FirstGfxDefaultSet + MaxPluginSetting, - FirstGfxSettings, LastGfxSettings = FirstGfxSettings + MaxPluginSetting, + FirstRSPDefaultSet, LastRSPDefaultSet = FirstRSPDefaultSet + MaxPluginSetting, + FirstRSPSettings, LastRSPSettings = FirstRSPSettings + MaxPluginSetting, + FirstGfxDefaultSet, LastGfxDefaultSet = FirstGfxDefaultSet + MaxPluginSetting, + FirstGfxSettings, LastGfxSettings = FirstGfxSettings + MaxPluginSetting, FirstAudioDefaultSet, LastAudioDefaultSet = FirstAudioDefaultSet + MaxPluginSetting, - FirstAudioSettings, LastAudioSettings = FirstAudioSettings + MaxPluginSetting, - FirstCtrlDefaultSet, LastCtrlDefaultSet = FirstCtrlDefaultSet + MaxPluginSetting, - FirstCtrlSettings, LastCtrlSettings = FirstCtrlSettings + MaxPluginSetting, + FirstAudioSettings, LastAudioSettings = FirstAudioSettings + MaxPluginSetting, + FirstCtrlDefaultSet, LastCtrlDefaultSet = FirstCtrlDefaultSet + MaxPluginSetting, + FirstCtrlSettings, LastCtrlSettings = FirstCtrlSettings + MaxPluginSetting, }; #include "Support.h" diff --git a/Source/Project64/Settings/Settings Class.cpp b/Source/Project64/Settings/Settings Class.cpp index ac680db6a..c083a3341 100644 --- a/Source/Project64/Settings/Settings Class.cpp +++ b/Source/Project64/Settings/Settings Class.cpp @@ -291,6 +291,7 @@ void CSettings::AddHowToHandleSetting () AddHandler(GameRunning_InstantSaveFile, new CSettingTypeTempString("")); AddHandler(GameRunning_LimitFPS, new CSettingTypeTempBool(true)); AddHandler(GameRunning_ScreenHertz, new CSettingTypeTempNumber(60)); + AddHandler(GameRunning_InReset, new CSettingTypeTempBool(false)); AddHandler(File_RecentGameFileCount, new CSettingTypeApplication("","Remembered Rom Files",(uint32_t)10)); AddHandler(File_RecentGameFileIndex, new CSettingTypeApplicationIndex("Recent File","Recent Rom",Default_None)); diff --git a/Source/Project64/User Interface/Gui Class.h b/Source/Project64/User Interface/Gui Class.h index 30dcca993..52bed2dde 100644 --- a/Source/Project64/User Interface/Gui Class.h +++ b/Source/Project64/User Interface/Gui Class.h @@ -10,24 +10,27 @@ ****************************************************************************/ #pragma once +#include + class CGfxPlugin; //Plugin that controls the rendering class CAudioPlugin; //Plugin for audio, need the hwnd class CControl_Plugin; //Controller needs hwnd to see if it is the focused window class CBaseMenu; //Menu for the gui -class CN64System; -class CNotification; +class CN64System; class CriticalSection; -enum { - WM_HIDE_CUROSR = WM_USER + 10, - WM_MAKE_FOCUS = WM_USER + 17, - WM_RESET_PLUGIN = WM_USER + 18, - WM_BORWSER_TOP = WM_USER + 40, +enum +{ + WM_HIDE_CUROSR = WM_USER + 10, + WM_MAKE_FOCUS = WM_USER + 17, + WM_RESET_PLUGIN = WM_USER + 18, + WM_BORWSER_TOP = WM_USER + 40, }; class CMainGui : - public CRomBrowser, - private CGuiSettings + public CRomBrowser, + public CDebuggerUI, + private CGuiSettings { enum { StatusBarID = 400 }; diff --git a/Source/Project64/User Interface/Main Menu Class.cpp b/Source/Project64/User Interface/Main Menu Class.cpp index 54cacfe09..5430c47b4 100644 --- a/Source/Project64/User Interface/Main Menu Class.cpp +++ b/Source/Project64/User Interface/Main Menu Class.cpp @@ -458,12 +458,10 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI case ID_DEBUGGER_GENERATELOG: g_Settings->SaveBool(Debugger_GenerateDebugLog,!g_Settings->LoadBool(Debugger_GenerateDebugLog)); break; - case ID_DEBUGGER_DUMPMEMORY: - g_BaseSystem->Debug_ShowMemoryDump(); - break; - case ID_DEBUGGER_SEARCHMEMORY: g_BaseSystem->Debug_ShowMemorySearch(); break; - case ID_DEBUGGER_MEMORY: g_BaseSystem->Debug_ShowMemoryWindow(); break; - case ID_DEBUGGER_TLBENTRIES: g_BaseSystem->Debug_ShowTLBWindow(); break; + case ID_DEBUGGER_DUMPMEMORY: _Gui->Debug_ShowMemoryDump(); break; + case ID_DEBUGGER_SEARCHMEMORY: _Gui->Debug_ShowMemorySearch(); break; + case ID_DEBUGGER_MEMORY: _Gui->Debug_ShowMemoryWindow(); break; + case ID_DEBUGGER_TLBENTRIES: _Gui->Debug_ShowTLBWindow(); break; case ID_DEBUGGER_INTERRUPT_SP: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_SP); break; case ID_DEBUGGER_INTERRUPT_SI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_SI); break; case ID_DEBUGGER_INTERRUPT_AI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_AI); break; From a1d9af57a6e70524dd72a9e27863445484e1b315 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sat, 7 Nov 2015 12:11:25 +1100 Subject: [PATCH 080/213] [Project64] remove some of the #ifdef WINDOWS_UI from settings pages --- Project64.sln | Bin 33430 -> 33488 bytes Source/Project64/User Interface.h | 19 +- .../Settings Page - Advanced Options.cpp | 4 +- .../Settings/Settings Page - Directories.cpp | 164 ++++++------ .../Settings Page - Game - General.cpp | 69 +++-- .../Settings/Settings Page - Game - General.h | 51 ++-- .../Settings Page - Game - Plugin.cpp | 156 ++++++------ .../Settings/Settings Page - Game - Plugin.h | 70 ++--- .../Settings Page - Game - Recompiler.cpp | 32 ++- .../Settings Page - Game - Status.cpp | 26 +- .../Settings/Settings Page - Game Browser.cpp | 140 +++++----- .../Settings Page - Keyboard Shortcuts.cpp | 241 +++++++++--------- .../Settings/Settings Page - Options.cpp | 28 +- .../Settings/Settings Page - Plugin.cpp | 146 ++++++----- .../Settings/Settings Page - Plugin.h | 70 ++--- .../User Interface/Settings/Settings Page.cpp | 12 +- .../WTL Controls/ModifiedEditBox.cpp | 55 ++-- .../WTL Controls/PartialGroupBox.cpp | 40 ++- 18 files changed, 645 insertions(+), 678 deletions(-) diff --git a/Project64.sln b/Project64.sln index 55bdfbdfdaec3b6d72bdb297e11b4849ea3a4efb..fbca22ce4743894f2a593ca247131bc2473fff22 100644 GIT binary patch delta 118 zcmbQ%%5mu+pP0!TJS8R{P?MM}qo*|apJ&))1y7#I3-ru3|MNU%G}))rYqDKa#N-1tER)ap gd2QZO`-N%pA5X8ze6=x?@1%K6{?zbq^0X!^0B)!=ng9R* diff --git a/Source/Project64/User Interface.h b/Source/Project64/User Interface.h index a227f4cfd..c239379d6 100644 --- a/Source/Project64/User Interface.h +++ b/Source/Project64/User Interface.h @@ -31,13 +31,14 @@ struct RECT_STRUCT long bottom; }; -struct WINDOWS_PAINTSTRUCT { - HDC hdc; - int fErase; - RECT_STRUCT rcPaint; - int fRestore; - int fIncUpdate; - BYTE rgbReserved[32]; +struct WINDOWS_PAINTSTRUCT +{ + HDC hdc; + int fErase; + RECT_STRUCT rcPaint; + int fRestore; + int fIncUpdate; + BYTE rgbReserved[32]; }; #define CALLBACK __stdcall @@ -49,9 +50,7 @@ class CN64System; // Remove this to test compilation outside of the Windows ATL environment. #endif -#ifdef WINDOWS_UI #include -#endif #include #include ".\\User Interface\\Rom Browser.h" @@ -61,6 +60,4 @@ class CN64System; #include ".\\User Interface\\Notification Class.h" #include ".\\User Interface\\Frame Per Second Class.h" #include ".\\User Interface\\resource.h" -#ifdef WINDOWS_UI #include ".\\User Interface\\Settings Config.h" -#endif diff --git a/Source/Project64/User Interface/Settings/Settings Page - Advanced Options.cpp b/Source/Project64/User Interface/Settings/Settings Page - Advanced Options.cpp index 9e0d7b17a..ca0cb1678 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Advanced Options.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Advanced Options.cpp @@ -10,7 +10,6 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI #include "Settings Page.h" CAdvancedOptionsPage::CAdvancedOptionsPage (HWND hParent, const RECT & rcDispay ) @@ -71,5 +70,4 @@ bool CAdvancedOptionsPage::EnableReset ( void ) void CAdvancedOptionsPage::ResetPage() { CSettingsPageImpl::ResetPage(); -} -#endif +} \ No newline at end of file diff --git a/Source/Project64/User Interface/Settings/Settings Page - Directories.cpp b/Source/Project64/User Interface/Settings/Settings Page - Directories.cpp index d25569b9e..8aa9d0617 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Directories.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Directories.cpp @@ -10,18 +10,17 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI #include "Settings Page.h" -COptionsDirectoriesPage::COptionsDirectoriesPage (HWND hParent, const RECT & rcDispay ) : - m_InUpdateSettings(false) +COptionsDirectoriesPage::COptionsDirectoriesPage(HWND hParent, const RECT & rcDispay) : +m_InUpdateSettings(false) { Create(hParent); if (m_hWnd == NULL) { return; } - SetWindowPos(HWND_TOP,&rcDispay,SWP_HIDEWINDOW); + SetWindowPos(HWND_TOP, &rcDispay, SWP_HIDEWINDOW); m_PluginGroup.Attach(GetDlgItem(IDC_DIR_FRAME1)); m_AutoSaveGroup.Attach(GetDlgItem(IDC_DIR_FRAME3)); @@ -47,7 +46,7 @@ COptionsDirectoriesPage::COptionsDirectoriesPage (HWND hParent, const RECT & rcD m_TextureSelected.Attach(GetDlgItem(IDC_TEXTURE_OTHER)); //Set Text language for the dialog box - ::SetWindowTextW(m_PluginGroup.m_hWnd, GS(DIR_PLUGIN)); + ::SetWindowTextW(m_PluginGroup.m_hWnd, GS(DIR_PLUGIN)); ::SetWindowTextW(m_AutoSaveGroup.m_hWnd, GS(DIR_AUTO_SAVE)); ::SetWindowTextW(m_InstantSaveGroup.m_hWnd, GS(DIR_INSTANT_SAVE)); ::SetWindowTextW(m_ScreenShotGroup.m_hWnd, GS(DIR_SCREEN_SHOT)); @@ -56,25 +55,25 @@ COptionsDirectoriesPage::COptionsDirectoriesPage (HWND hParent, const RECT & rcD UpdatePageSettings(); } -int CALLBACK COptionsDirectoriesPage::SelectDirCallBack (HWND hwnd,DWORD uMsg,DWORD /*lp*/, DWORD lpData) +int CALLBACK COptionsDirectoriesPage::SelectDirCallBack(HWND hwnd, DWORD uMsg, DWORD /*lp*/, DWORD lpData) { - switch(uMsg) + switch (uMsg) { case BFFM_INITIALIZED: // WParam is TRUE since you are passing a path. // It would be FALSE if you were passing a pidl. if (lpData) { - SendMessage(hwnd,BFFM_SETSELECTION,TRUE,lpData); + SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData); } break; - } + } return 0; } -void COptionsDirectoriesPage::SelectDirectory( LanguageStringID Title, CModifiedEditBox & EditBox, CModifiedButton & Default, CModifiedButton & selected ) +void COptionsDirectoriesPage::SelectDirectory(LanguageStringID Title, CModifiedEditBox & EditBox, CModifiedButton & Default, CModifiedButton & selected) { - wchar_t Buffer[MAX_PATH], Directory[MAX_PATH]; + wchar_t Buffer[MAX_PATH], Directory[MAX_PATH]; LPITEMIDLIST pidl; BROWSEINFOW bi; @@ -87,80 +86,80 @@ void COptionsDirectoriesPage::SelectDirectory( LanguageStringID Title, CModified bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; bi.lpfn = (BFFCALLBACK)SelectDirCallBack; bi.lParam = (DWORD)InitialDir.c_str(); - if ((pidl = SHBrowseForFolderW(&bi)) != NULL) + if ((pidl = SHBrowseForFolderW(&bi)) != NULL) { - if (SHGetPathFromIDListW(pidl, Directory)) + if (SHGetPathFromIDListW(pidl, Directory)) { - stdstr path; - CPath SelectedDir(path.FromUTF16(Directory),""); + stdstr path; + CPath SelectedDir(path.FromUTF16(Directory), ""); EditBox.SetChanged(true); EditBox.SetWindowText(SelectedDir); Default.SetChanged(true); Default.SetCheck(BST_UNCHECKED); selected.SetCheck(BM_SETCHECK); - SendMessage(GetParent(),PSM_CHANGED,(WPARAM)m_hWnd,0); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } } } -void COptionsDirectoriesPage::PluginDirChanged ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) +void COptionsDirectoriesPage::PluginDirChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { if (m_InUpdateSettings) { return; } m_PluginDir.SetChanged(true); - SendMessage(GetParent(),PSM_CHANGED,(WPARAM)m_hWnd,0); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } -void COptionsDirectoriesPage::AutoSaveDirChanged ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) +void COptionsDirectoriesPage::AutoSaveDirChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { if (m_InUpdateSettings) { return; } m_AutoSaveDir.SetChanged(true); - SendMessage(GetParent(),PSM_CHANGED,(WPARAM)m_hWnd,0); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } -void COptionsDirectoriesPage::InstantSaveDirChanged ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) +void COptionsDirectoriesPage::InstantSaveDirChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { if (m_InUpdateSettings) { return; } m_InstantSaveDir.SetChanged(true); - SendMessage(GetParent(),PSM_CHANGED,(WPARAM)m_hWnd,0); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } -void COptionsDirectoriesPage::SnapShotDirChanged ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) +void COptionsDirectoriesPage::SnapShotDirChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { if (m_InUpdateSettings) { return; } m_ScreenShotDir.SetChanged(true); - SendMessage(GetParent(),PSM_CHANGED,(WPARAM)m_hWnd,0); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } -void COptionsDirectoriesPage::TextureDirChanged ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) +void COptionsDirectoriesPage::TextureDirChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { if (m_InUpdateSettings) { return; } m_TextureDir.SetChanged(true); - SendMessage(GetParent(),PSM_CHANGED,(WPARAM)m_hWnd,0); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } -void COptionsDirectoriesPage::SelectPluginDir ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) +void COptionsDirectoriesPage::SelectPluginDir(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { - SelectDirectory(DIR_SELECT_PLUGIN,m_PluginDir,m_PluginDefault, m_PluginSelected); + SelectDirectory(DIR_SELECT_PLUGIN, m_PluginDir, m_PluginDefault, m_PluginSelected); } -void COptionsDirectoriesPage::SelectAutoDir ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) +void COptionsDirectoriesPage::SelectAutoDir(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { - SelectDirectory(DIR_SELECT_AUTO,m_AutoSaveDir,m_AutoSaveDefault, m_AutoSaveSelected); + SelectDirectory(DIR_SELECT_AUTO, m_AutoSaveDir, m_AutoSaveDefault, m_AutoSaveSelected); } -void COptionsDirectoriesPage::SelectInstantDir ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) +void COptionsDirectoriesPage::SelectInstantDir(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { - SelectDirectory(DIR_SELECT_INSTANT,m_InstantSaveDir,m_InstantDefault, m_InstantSelected); + SelectDirectory(DIR_SELECT_INSTANT, m_InstantSaveDir, m_InstantDefault, m_InstantSelected); } -void COptionsDirectoriesPage::SelectSnapShotDir ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) +void COptionsDirectoriesPage::SelectSnapShotDir(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { - SelectDirectory(DIR_SELECT_SCREEN,m_ScreenShotDir,m_ScreenShotDefault, m_ScreenShotSelected); + SelectDirectory(DIR_SELECT_SCREEN, m_ScreenShotDir, m_ScreenShotDefault, m_ScreenShotSelected); } -void COptionsDirectoriesPage::SelectTextureDir ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) +void COptionsDirectoriesPage::SelectTextureDir(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { - SelectDirectory(DIR_SELECT_TEXTURE,m_TextureDir,m_TextureDefault, m_TextureSelected); + SelectDirectory(DIR_SELECT_TEXTURE, m_TextureDir, m_TextureDefault, m_TextureSelected); } void COptionsDirectoriesPage::UpdatePageSettings() @@ -168,42 +167,42 @@ void COptionsDirectoriesPage::UpdatePageSettings() stdstr Directory; m_InUpdateSettings = true; - m_PluginDir.SetChanged(g_Settings->LoadStringVal(Directory_PluginSelected,Directory)); + m_PluginDir.SetChanged(g_Settings->LoadStringVal(Directory_PluginSelected, Directory)); m_PluginDir.SetWindowText(Directory.c_str()); - m_AutoSaveDir.SetChanged(g_Settings->LoadStringVal(Directory_NativeSaveSelected,Directory)); + m_AutoSaveDir.SetChanged(g_Settings->LoadStringVal(Directory_NativeSaveSelected, Directory)); m_AutoSaveDir.SetWindowText(Directory.c_str()); - m_InstantSaveDir.SetChanged(g_Settings->LoadStringVal(Directory_InstantSaveSelected,Directory)); + m_InstantSaveDir.SetChanged(g_Settings->LoadStringVal(Directory_InstantSaveSelected, Directory)); m_InstantSaveDir.SetWindowText(Directory.c_str()); - m_ScreenShotDir.SetChanged(g_Settings->LoadStringVal(Directory_SnapShotSelected,Directory)); + m_ScreenShotDir.SetChanged(g_Settings->LoadStringVal(Directory_SnapShotSelected, Directory)); m_ScreenShotDir.SetWindowText(Directory.c_str()); - m_TextureDir.SetChanged(g_Settings->LoadStringVal(Directory_TextureSelected,Directory)); + m_TextureDir.SetChanged(g_Settings->LoadStringVal(Directory_TextureSelected, Directory)); m_TextureDir.SetWindowText(Directory.c_str()); bool UseSelected; - m_PluginDefault.SetChanged(g_Settings->LoadBool(Directory_PluginUseSelected,UseSelected)); + m_PluginDefault.SetChanged(g_Settings->LoadBool(Directory_PluginUseSelected, UseSelected)); m_PluginDefault.SetCheck(!UseSelected); m_PluginSelected.SetCheck(UseSelected); - m_AutoSaveDefault.SetChanged(g_Settings->LoadBool(Directory_NativeSaveUseSelected,UseSelected)); + m_AutoSaveDefault.SetChanged(g_Settings->LoadBool(Directory_NativeSaveUseSelected, UseSelected)); m_AutoSaveDefault.SetCheck(!UseSelected); m_AutoSaveSelected.SetCheck(UseSelected); - m_InstantDefault.SetChanged(g_Settings->LoadBool(Directory_InstantSaveUseSelected,UseSelected)); + m_InstantDefault.SetChanged(g_Settings->LoadBool(Directory_InstantSaveUseSelected, UseSelected)); m_InstantDefault.SetCheck(!UseSelected); m_InstantSelected.SetCheck(UseSelected); - m_ScreenShotDefault.SetChanged(g_Settings->LoadBool(Directory_SnapShotUseSelected,UseSelected)); + m_ScreenShotDefault.SetChanged(g_Settings->LoadBool(Directory_SnapShotUseSelected, UseSelected)); m_ScreenShotDefault.SetCheck(!UseSelected); m_ScreenShotSelected.SetCheck(UseSelected); - m_TextureDefault.SetChanged(g_Settings->LoadBool(Directory_TextureUseSelected,UseSelected)); + m_TextureDefault.SetChanged(g_Settings->LoadBool(Directory_TextureUseSelected, UseSelected)); m_TextureDefault.SetCheck(!UseSelected); m_TextureSelected.SetCheck(UseSelected); m_InUpdateSettings = false; } -void COptionsDirectoriesPage::UseSelectedClicked ( UINT /*Code*/, int id, HWND /*ctl*/ ) +void COptionsDirectoriesPage::UseSelectedClicked(UINT /*Code*/, int id, HWND /*ctl*/) { CModifiedButton * Button = NULL; switch (id) @@ -233,7 +232,7 @@ void COptionsDirectoriesPage::UseSelectedClicked ( UINT /*Code*/, int id, HWND / } } Button->SetChanged(true); - SendMessage(GetParent(),PSM_CHANGED,(WPARAM)m_hWnd,0); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } void COptionsDirectoriesPage::HidePage() @@ -246,37 +245,37 @@ void COptionsDirectoriesPage::ShowPage() ShowWindow(SW_SHOW); } -void COptionsDirectoriesPage::ResetDirectory( CModifiedEditBox & EditBox, SettingID Type ) +void COptionsDirectoriesPage::ResetDirectory(CModifiedEditBox & EditBox, SettingID Type) { if (!EditBox.IsChanged()) { return; } stdstr dir; - g_Settings->LoadDefaultString(Type,dir); + g_Settings->LoadDefaultString(Type, dir); EditBox.SetWindowText(dir.c_str()); EditBox.SetReset(true); } -void COptionsDirectoriesPage::ResetDefaultSelected ( CModifiedButton & ButtonDefault, CModifiedButton & ButtonSelected, SettingID Type ) +void COptionsDirectoriesPage::ResetDefaultSelected(CModifiedButton & ButtonDefault, CModifiedButton & ButtonSelected, SettingID Type) { if (!ButtonDefault.IsChanged()) { return; } bool UseSelected; - g_Settings->LoadDefaultBool(Type,UseSelected); + g_Settings->LoadDefaultBool(Type, UseSelected); ButtonDefault.SetCheck(!UseSelected); ButtonSelected.SetCheck(UseSelected); ButtonDefault.SetReset(true); } -void COptionsDirectoriesPage::UpdateDirectory( CModifiedEditBox & EditBox, SettingID Type ) +void COptionsDirectoriesPage::UpdateDirectory(CModifiedEditBox & EditBox, SettingID Type) { if (EditBox.IsChanged()) { stdstr dir = EditBox.GetWindowText(); - g_Settings->SaveString(Type,dir.c_str()); + g_Settings->SaveString(Type, dir.c_str()); } if (EditBox.IsReset()) { @@ -284,13 +283,13 @@ void COptionsDirectoriesPage::UpdateDirectory( CModifiedEditBox & EditBox, Setti } } -void COptionsDirectoriesPage::UpdateDefaultSelected ( CModifiedButton & Button, SettingID Type ) +void COptionsDirectoriesPage::UpdateDefaultSelected(CModifiedButton & Button, SettingID Type) { if (Button.IsChanged()) { bool bUseSelected = (Button.GetCheck() & BST_CHECKED) == 0; - g_Settings->SaveBool(Type,bUseSelected); - + g_Settings->SaveBool(Type, bUseSelected); + if (Type == Directory_TextureUseSelected && !bUseSelected) { g_Settings->DeleteSetting(Directory_TextureSelected); @@ -302,27 +301,27 @@ void COptionsDirectoriesPage::UpdateDefaultSelected ( CModifiedButton & Button, } } -void COptionsDirectoriesPage::ApplySettings( bool UpdateScreen ) +void COptionsDirectoriesPage::ApplySettings(bool UpdateScreen) { - UpdateDirectory(m_PluginDir,Directory_PluginSelected); - UpdateDirectory(m_AutoSaveDir,Directory_NativeSaveSelected); - UpdateDirectory(m_InstantSaveDir,Directory_InstantSaveSelected); - UpdateDirectory(m_ScreenShotDir,Directory_SnapShotSelected); - UpdateDirectory(m_TextureDir,Directory_TextureSelected); + UpdateDirectory(m_PluginDir, Directory_PluginSelected); + UpdateDirectory(m_AutoSaveDir, Directory_NativeSaveSelected); + UpdateDirectory(m_InstantSaveDir, Directory_InstantSaveSelected); + UpdateDirectory(m_ScreenShotDir, Directory_SnapShotSelected); + UpdateDirectory(m_TextureDir, Directory_TextureSelected); + + UpdateDefaultSelected(m_PluginDefault, Directory_PluginUseSelected); + UpdateDefaultSelected(m_AutoSaveDefault, Directory_NativeSaveUseSelected); + UpdateDefaultSelected(m_InstantDefault, Directory_InstantSaveUseSelected); + UpdateDefaultSelected(m_ScreenShotDefault, Directory_SnapShotUseSelected); + UpdateDefaultSelected(m_TextureDefault, Directory_TextureUseSelected); - UpdateDefaultSelected(m_PluginDefault,Directory_PluginUseSelected); - UpdateDefaultSelected(m_AutoSaveDefault,Directory_NativeSaveUseSelected); - UpdateDefaultSelected(m_InstantDefault,Directory_InstantSaveUseSelected); - UpdateDefaultSelected(m_ScreenShotDefault,Directory_SnapShotUseSelected); - UpdateDefaultSelected(m_TextureDefault,Directory_TextureUseSelected); - if (UpdateScreen) { UpdatePageSettings(); } } -bool COptionsDirectoriesPage::EnableReset ( void ) +bool COptionsDirectoriesPage::EnableReset(void) { if (m_PluginDir.IsChanged()) { return true; } if (m_AutoSaveDir.IsChanged()) { return true; } @@ -339,18 +338,17 @@ bool COptionsDirectoriesPage::EnableReset ( void ) void COptionsDirectoriesPage::ResetPage() { - ResetDirectory(m_PluginDir,Directory_PluginSelected); - ResetDirectory(m_AutoSaveDir,Directory_NativeSaveSelected); - ResetDirectory(m_InstantSaveDir,Directory_InstantSaveSelected); - ResetDirectory(m_ScreenShotDir,Directory_SnapShotSelected); - ResetDirectory(m_TextureDir,Directory_TextureSelected); + ResetDirectory(m_PluginDir, Directory_PluginSelected); + ResetDirectory(m_AutoSaveDir, Directory_NativeSaveSelected); + ResetDirectory(m_InstantSaveDir, Directory_InstantSaveSelected); + ResetDirectory(m_ScreenShotDir, Directory_SnapShotSelected); + ResetDirectory(m_TextureDir, Directory_TextureSelected); - ResetDefaultSelected(m_PluginDefault,m_PluginSelected,Directory_PluginUseSelected); - ResetDefaultSelected(m_AutoSaveDefault,m_AutoSaveSelected,Directory_NativeSaveUseSelected); - ResetDefaultSelected(m_InstantDefault,m_InstantSelected,Directory_InstantSaveUseSelected); - ResetDefaultSelected(m_ScreenShotDefault,m_ScreenShotSelected,Directory_SnapShotUseSelected); - ResetDefaultSelected(m_TextureDefault,m_TextureSelected,Directory_TextureUseSelected); + ResetDefaultSelected(m_PluginDefault, m_PluginSelected, Directory_PluginUseSelected); + ResetDefaultSelected(m_AutoSaveDefault, m_AutoSaveSelected, Directory_NativeSaveUseSelected); + ResetDefaultSelected(m_InstantDefault, m_InstantSelected, Directory_InstantSaveUseSelected); + ResetDefaultSelected(m_ScreenShotDefault, m_ScreenShotSelected, Directory_SnapShotUseSelected); + ResetDefaultSelected(m_TextureDefault, m_TextureSelected, Directory_TextureUseSelected); - SendMessage(GetParent(),PSM_CHANGED,(WPARAM)m_hWnd,0); -} -#endif + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); +} \ No newline at end of file diff --git a/Source/Project64/User Interface/Settings/Settings Page - Game - General.cpp b/Source/Project64/User Interface/Settings/Settings Page - Game - General.cpp index 835742a32..90cff8468 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game - General.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Game - General.cpp @@ -10,13 +10,12 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI #include "Settings Page.h" #include "Settings Page - Game - General.h" -CGameGeneralPage::CGameGeneralPage (HWND hParent, const RECT & rcDispay ) +CGameGeneralPage::CGameGeneralPage(HWND hParent, const RECT & rcDispay) { - if (!Create(hParent,rcDispay)) + if (!Create(hParent, rcDispay)) { return; } @@ -35,55 +34,55 @@ CGameGeneralPage::CGameGeneralPage (HWND hParent, const RECT & rcDispay ) SetDlgItemTextW(m_hWnd, IDC_DELAY_DP, GS(ROM_DELAY_DP)); SetDlgItemTextW(m_hWnd, IDC_SYNC_AUDIO, GS(ROM_SYNC_AUDIO)); SetDlgItemTextW(m_hWnd, IDC_USE_TLB, GS(ROM_USE_TLB)); - SetDlgItemTextW(m_hWnd, IDC_DELAY_SI, GS(ROM_DELAY_SI)); - SetDlgItemTextW(m_hWnd, IDC_AUDIO_SIGNAL, GS(ROM_AUDIO_SIGNAL)); + SetDlgItemTextW(m_hWnd, IDC_DELAY_SI, GS(ROM_DELAY_SI)); + SetDlgItemTextW(m_hWnd, IDC_AUDIO_SIGNAL, GS(ROM_AUDIO_SIGNAL)); - AddModCheckBox(GetDlgItem(IDC_ROM_32BIT),Game_32Bit); - AddModCheckBox(GetDlgItem(IDC_SYNC_AUDIO),Game_SyncViaAudio); - AddModCheckBox(GetDlgItem(IDC_ROM_FIXEDAUDIO),Game_FixedAudio); - AddModCheckBox(GetDlgItem(IDC_USE_TLB),Game_UseTlb); - AddModCheckBox(GetDlgItem(IDC_DELAY_DP),Game_DelayDP); - AddModCheckBox(GetDlgItem(IDC_DELAY_SI),Game_DelaySI); - AddModCheckBox(GetDlgItem(IDC_AUDIO_SIGNAL),Game_RspAudioSignal); + AddModCheckBox(GetDlgItem(IDC_ROM_32BIT), Game_32Bit); + AddModCheckBox(GetDlgItem(IDC_SYNC_AUDIO), Game_SyncViaAudio); + AddModCheckBox(GetDlgItem(IDC_ROM_FIXEDAUDIO), Game_FixedAudio); + AddModCheckBox(GetDlgItem(IDC_USE_TLB), Game_UseTlb); + AddModCheckBox(GetDlgItem(IDC_DELAY_DP), Game_DelayDP); + AddModCheckBox(GetDlgItem(IDC_DELAY_SI), Game_DelaySI); + AddModCheckBox(GetDlgItem(IDC_AUDIO_SIGNAL), Game_RspAudioSignal); CModifiedComboBox * ComboBox; - ComboBox = AddModComboBox(GetDlgItem(IDC_RDRAM_SIZE),Game_RDRamSize); + ComboBox = AddModComboBox(GetDlgItem(IDC_RDRAM_SIZE), Game_RDRamSize); if (ComboBox) { ComboBox->SetTextField(GetDlgItem(IDC_MEMORY_SIZE_TEXT)); - ComboBox->AddItemW(GS(RDRAM_4MB), 0x400000 ); - ComboBox->AddItemW(GS(RDRAM_8MB), 0x800000 ); + ComboBox->AddItemW(GS(RDRAM_4MB), 0x400000); + ComboBox->AddItemW(GS(RDRAM_8MB), 0x800000); } - ComboBox = AddModComboBox(GetDlgItem(IDC_SAVE_TYPE),Game_SaveChip); + ComboBox = AddModComboBox(GetDlgItem(IDC_SAVE_TYPE), Game_SaveChip); if (ComboBox) { ComboBox->SetTextField(GetDlgItem(IDC_SAVE_TYPE_TEXT)); - ComboBox->AddItemW(GS(SAVE_FIRST_USED), (WPARAM)SaveChip_Auto ); - ComboBox->AddItemW(GS(SAVE_4K_EEPROM), SaveChip_Eeprom_4K ); - ComboBox->AddItemW(GS(SAVE_16K_EEPROM), SaveChip_Eeprom_16K ); - ComboBox->AddItemW(GS(SAVE_SRAM), SaveChip_Sram ); - ComboBox->AddItemW(GS(SAVE_FLASHRAM), SaveChip_FlashRam ); + ComboBox->AddItemW(GS(SAVE_FIRST_USED), (WPARAM)SaveChip_Auto); + ComboBox->AddItemW(GS(SAVE_4K_EEPROM), SaveChip_Eeprom_4K); + ComboBox->AddItemW(GS(SAVE_16K_EEPROM), SaveChip_Eeprom_16K); + ComboBox->AddItemW(GS(SAVE_SRAM), SaveChip_Sram); + ComboBox->AddItemW(GS(SAVE_FLASHRAM), SaveChip_FlashRam); } - ComboBox = AddModComboBox(GetDlgItem(IDC_COUNTFACT),Game_CounterFactor); + ComboBox = AddModComboBox(GetDlgItem(IDC_COUNTFACT), Game_CounterFactor); if (ComboBox) { ComboBox->SetTextField(GetDlgItem(IDC_COUNTFACT_TEXT)); - ComboBox->AddItemW(GS(NUMBER_1), 1 ); - ComboBox->AddItemW(GS(NUMBER_2), 2 ); - ComboBox->AddItemW(GS(NUMBER_3), 3 ); - ComboBox->AddItemW(GS(NUMBER_4), 4 ); - ComboBox->AddItemW(GS(NUMBER_5), 5 ); - ComboBox->AddItemW(GS(NUMBER_6), 6 ); + ComboBox->AddItemW(GS(NUMBER_1), 1); + ComboBox->AddItemW(GS(NUMBER_2), 2); + ComboBox->AddItemW(GS(NUMBER_3), 3); + ComboBox->AddItemW(GS(NUMBER_4), 4); + ComboBox->AddItemW(GS(NUMBER_5), 5); + ComboBox->AddItemW(GS(NUMBER_6), 6); } - SetDlgItemText(IDC_GOOD_NAME,g_Settings->LoadStringVal(Game_GoodName).c_str()); + SetDlgItemText(IDC_GOOD_NAME, g_Settings->LoadStringVal(Game_GoodName).c_str()); - CModifiedEditBox * TxtBox = AddModTextBox(GetDlgItem(IDC_VIREFRESH),Game_ViRefreshRate, false); + CModifiedEditBox * TxtBox = AddModTextBox(GetDlgItem(IDC_VIREFRESH), Game_ViRefreshRate, false); TxtBox->SetTextField(GetDlgItem(IDC_VIREFESH_TEXT)); - TxtBox = AddModTextBox(GetDlgItem(IDC_COUNTPERBYTE),Game_AiCountPerBytes, false); + TxtBox = AddModTextBox(GetDlgItem(IDC_COUNTPERBYTE), Game_AiCountPerBytes, false); TxtBox->SetTextField(GetDlgItem(IDC_COUNTPERBYTE_TEXT)); UpdatePageSettings(); @@ -99,20 +98,18 @@ void CGameGeneralPage::HidePage() ShowWindow(SW_HIDE); } -void CGameGeneralPage::ApplySettings( bool UpdateScreen ) +void CGameGeneralPage::ApplySettings(bool UpdateScreen) { CSettingsPageImpl::ApplySettings(UpdateScreen); } -bool CGameGeneralPage::EnableReset ( void ) +bool CGameGeneralPage::EnableReset(void) { if (CSettingsPageImpl::EnableReset()) { return true; } return false; } - void CGameGeneralPage::ResetPage() { CSettingsPageImpl::ResetPage(); -} -#endif +} \ No newline at end of file diff --git a/Source/Project64/User Interface/Settings/Settings Page - Game - General.h b/Source/Project64/User Interface/Settings/Settings Page - Game - General.h index 90f33b7cf..f2d954907 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game - General.h +++ b/Source/Project64/User Interface/Settings/Settings Page - Game - General.h @@ -14,36 +14,33 @@ #include class CGameGeneralPage : - public CSettingsPageImpl, - public CSettingsPage + public CSettingsPageImpl, + public CSettingsPage { + BEGIN_MSG_MAP_EX(CGameGeneralPage) + COMMAND_HANDLER_EX(IDC_RDRAM_SIZE,LBN_SELCHANGE,ComboBoxChanged) + COMMAND_HANDLER_EX(IDC_SAVE_TYPE,LBN_SELCHANGE,ComboBoxChanged) + COMMAND_HANDLER_EX(IDC_COUNTFACT,LBN_SELCHANGE,ComboBoxChanged) + COMMAND_ID_HANDLER_EX(IDC_ROM_32BIT,CheckBoxChanged) + COMMAND_ID_HANDLER_EX(IDC_SYNC_AUDIO,CheckBoxChanged) + COMMAND_ID_HANDLER_EX(IDC_ROM_FIXEDAUDIO,CheckBoxChanged) + COMMAND_ID_HANDLER_EX(IDC_USE_TLB,CheckBoxChanged) + COMMAND_ID_HANDLER_EX(IDC_DELAY_DP,CheckBoxChanged) + COMMAND_ID_HANDLER_EX(IDC_DELAY_SI,CheckBoxChanged) + COMMAND_ID_HANDLER_EX(IDC_AUDIO_SIGNAL,CheckBoxChanged) + COMMAND_HANDLER_EX(IDC_VIREFRESH,EN_UPDATE,EditBoxChanged) + COMMAND_HANDLER_EX(IDC_COUNTPERBYTE,EN_UPDATE,EditBoxChanged) + END_MSG_MAP() - BEGIN_MSG_MAP_EX(CGameGeneralPage) - COMMAND_HANDLER_EX(IDC_RDRAM_SIZE,LBN_SELCHANGE,ComboBoxChanged) - COMMAND_HANDLER_EX(IDC_SAVE_TYPE,LBN_SELCHANGE,ComboBoxChanged) - COMMAND_HANDLER_EX(IDC_COUNTFACT,LBN_SELCHANGE,ComboBoxChanged) - COMMAND_ID_HANDLER_EX(IDC_ROM_32BIT,CheckBoxChanged) - COMMAND_ID_HANDLER_EX(IDC_SYNC_AUDIO,CheckBoxChanged) - COMMAND_ID_HANDLER_EX(IDC_ROM_FIXEDAUDIO,CheckBoxChanged) - COMMAND_ID_HANDLER_EX(IDC_USE_TLB,CheckBoxChanged) - COMMAND_ID_HANDLER_EX(IDC_DELAY_DP,CheckBoxChanged) - COMMAND_ID_HANDLER_EX(IDC_DELAY_SI,CheckBoxChanged) - COMMAND_ID_HANDLER_EX(IDC_AUDIO_SIGNAL,CheckBoxChanged) - COMMAND_HANDLER_EX(IDC_VIREFRESH,EN_UPDATE,EditBoxChanged) - COMMAND_HANDLER_EX(IDC_COUNTPERBYTE,EN_UPDATE,EditBoxChanged) - END_MSG_MAP() - - enum { IDD = IDD_Settings_GameGeneral }; + enum { IDD = IDD_Settings_GameGeneral }; public: - CGameGeneralPage(HWND hParent, const RECT & rcDispay ); + CGameGeneralPage(HWND hParent, const RECT & rcDispay ); - LanguageStringID PageTitle ( void ) { return TAB_ROMSETTINGS; } - void HidePage ( void ); - void ShowPage ( void ); - void ApplySettings ( bool UpdateScreen ); - bool EnableReset ( void ); - void ResetPage ( void ); - -private: + LanguageStringID PageTitle ( void ) { return TAB_ROMSETTINGS; } + void HidePage ( void ); + void ShowPage ( void ); + void ApplySettings ( bool UpdateScreen ); + bool EnableReset ( void ); + void ResetPage ( void ); }; diff --git a/Source/Project64/User Interface/Settings/Settings Page - Game - Plugin.cpp b/Source/Project64/User Interface/Settings/Settings Page - Game - Plugin.cpp index b0f3ff035..5cb478b02 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game - Plugin.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Game - Plugin.cpp @@ -10,61 +10,60 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI #include "Settings Page.h" #include "Settings Page - Game - Plugin.h" -CGamePluginPage::CGamePluginPage (HWND hParent, const RECT & rcDispay ) +CGamePluginPage::CGamePluginPage(HWND hParent, const RECT & rcDispay) { - if (!Create(hParent,rcDispay)) + if (!Create(hParent, rcDispay)) { return; } - - //Set the text for all gui Items - SetDlgItemTextW(m_hWnd, RSP_ABOUT,GS(PLUG_ABOUT)); - SetDlgItemTextW(m_hWnd, GFX_ABOUT,GS(PLUG_ABOUT)); - SetDlgItemTextW(m_hWnd, AUDIO_ABOUT,GS(PLUG_ABOUT)); - SetDlgItemTextW(m_hWnd, CONT_ABOUT,GS(PLUG_ABOUT)); - SetDlgItemTextW(m_hWnd, IDC_RSP_NAME,GS(PLUG_RSP)); - SetDlgItemTextW(m_hWnd, IDC_GFX_NAME,GS(PLUG_GFX)); - SetDlgItemTextW(m_hWnd, IDC_AUDIO_NAME,GS(PLUG_AUDIO)); - SetDlgItemTextW(m_hWnd, IDC_CONT_NAME,GS(PLUG_CTRL)); - - SetDlgItemTextW(m_hWnd, IDC_HLE_GFX,GS(PLUG_HLE_GFX)); - SetDlgItemTextW(m_hWnd, IDC_HLE_AUDIO,GS(PLUG_HLE_AUDIO)); + //Set the text for all gui Items + SetDlgItemTextW(m_hWnd, RSP_ABOUT, GS(PLUG_ABOUT)); + SetDlgItemTextW(m_hWnd, GFX_ABOUT, GS(PLUG_ABOUT)); + SetDlgItemTextW(m_hWnd, AUDIO_ABOUT, GS(PLUG_ABOUT)); + SetDlgItemTextW(m_hWnd, CONT_ABOUT, GS(PLUG_ABOUT)); + + SetDlgItemTextW(m_hWnd, IDC_RSP_NAME, GS(PLUG_RSP)); + SetDlgItemTextW(m_hWnd, IDC_GFX_NAME, GS(PLUG_GFX)); + SetDlgItemTextW(m_hWnd, IDC_AUDIO_NAME, GS(PLUG_AUDIO)); + SetDlgItemTextW(m_hWnd, IDC_CONT_NAME, GS(PLUG_CTRL)); + + SetDlgItemTextW(m_hWnd, IDC_HLE_GFX, GS(PLUG_HLE_GFX)); + SetDlgItemTextW(m_hWnd, IDC_HLE_AUDIO, GS(PLUG_HLE_AUDIO)); m_GfxGroup.Attach(GetDlgItem(IDC_GFX_NAME)); m_AudioGroup.Attach(GetDlgItem(IDC_AUDIO_NAME)); m_ControlGroup.Attach(GetDlgItem(IDC_CONT_NAME)); m_RspGroup.Attach(GetDlgItem(IDC_RSP_NAME)); - AddPlugins(GFX_LIST,Game_EditPlugin_Gfx,PLUGIN_TYPE_GFX); - AddPlugins(AUDIO_LIST,Game_EditPlugin_Audio,PLUGIN_TYPE_AUDIO); - AddPlugins(CONT_LIST,Game_EditPlugin_Contr,PLUGIN_TYPE_CONTROLLER); - AddPlugins(RSP_LIST,Game_EditPlugin_RSP,PLUGIN_TYPE_RSP); + AddPlugins(GFX_LIST, Game_EditPlugin_Gfx, PLUGIN_TYPE_GFX); + AddPlugins(AUDIO_LIST, Game_EditPlugin_Audio, PLUGIN_TYPE_AUDIO); + AddPlugins(CONT_LIST, Game_EditPlugin_Contr, PLUGIN_TYPE_CONTROLLER); + AddPlugins(RSP_LIST, Game_EditPlugin_RSP, PLUGIN_TYPE_RSP); + + AddModCheckBox(GetDlgItem(IDC_HLE_GFX), Game_UseHleGfx); + AddModCheckBox(GetDlgItem(IDC_HLE_AUDIO), Game_UseHleAudio); - AddModCheckBox(GetDlgItem(IDC_HLE_GFX),Game_UseHleGfx); - AddModCheckBox(GetDlgItem(IDC_HLE_AUDIO),Game_UseHleAudio); - UpdatePageSettings(); } -void CGamePluginPage::AddPlugins (int ListId,SettingID Type, PLUGIN_TYPE PluginType ) +void CGamePluginPage::AddPlugins(int ListId, SettingID Type, PLUGIN_TYPE PluginType) { stdstr Default; - bool PluginSelected = g_Settings->LoadStringVal(Type,Default); + bool PluginSelected = g_Settings->LoadStringVal(Type, Default); CModifiedComboBox * ComboBox; - ComboBox = AddModComboBox(GetDlgItem(ListId),Type); + ComboBox = AddModComboBox(GetDlgItem(ListId), Type); if (!PluginSelected) { ComboBox->SetDefault(NULL); } ComboBox->AddItemW(GS(PLUG_DEFAULT), NULL); - - for (int i = 0, n = m_PluginList.GetPluginCount(); i < n; i++ ) + + for (int i = 0, n = m_PluginList.GetPluginCount(); i < n; i++) { const CPluginList::PLUGIN * Plugin = m_PluginList.GetPluginInfo(i); if (Plugin == NULL) @@ -75,7 +74,7 @@ void CGamePluginPage::AddPlugins (int ListId,SettingID Type, PLUGIN_TYPE PluginT { continue; } - if (PluginSelected && _stricmp(Default.c_str(),Plugin->FileName.c_str()) == 0) + if (PluginSelected && _stricmp(Default.c_str(), Plugin->FileName.c_str()) == 0) { ComboBox->SetDefault((WPARAM)Plugin); } @@ -83,10 +82,10 @@ void CGamePluginPage::AddPlugins (int ListId,SettingID Type, PLUGIN_TYPE PluginT } } -void CGamePluginPage::ShowAboutButton ( int id ) +void CGamePluginPage::ShowAboutButton(int id) { CModifiedComboBox * ComboBox = NULL; - for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter ++) + for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter++) { if ((int)(cb_iter->second->GetMenu()) != id) { @@ -100,11 +99,11 @@ void CGamePluginPage::ShowAboutButton ( int id ) return; } int index = ComboBox->GetCurSel(); - if (index == CB_ERR) + if (index == CB_ERR) { - return; + return; } - + const CPluginList::PLUGIN ** PluginPtr = (const CPluginList::PLUGIN **)ComboBox->GetItemDataPtr(index); if (PluginPtr == NULL) { @@ -116,30 +115,30 @@ void CGamePluginPage::ShowAboutButton ( int id ) { return; } - + //Load the plugin - UINT LastErrorMode = SetErrorMode( SEM_FAILCRITICALERRORS ); - HMODULE hLib = LoadLibrary(Plugin->FullPath); + UINT LastErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS); + HMODULE hLib = LoadLibrary(Plugin->FullPath); SetErrorMode(LastErrorMode); if (hLib == NULL) { return; } - + //Get DLL about - void (__cdecl *DllAbout) ( HWND hWnd ); - DllAbout = (void (__cdecl *)(HWND))GetProcAddress( hLib, "DllAbout" ); - + void(__cdecl *DllAbout) (HWND hWnd); + DllAbout = (void(__cdecl *)(HWND))GetProcAddress(hLib, "DllAbout"); + //call the function from the dll DllAbout(m_hWnd); FreeLibrary(hLib); } -void CGamePluginPage::PluginItemChanged ( int id, int AboutID, bool bSetChanged ) +void CGamePluginPage::PluginItemChanged(int id, int AboutID, bool bSetChanged) { CModifiedComboBox * ComboBox = NULL; - for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter ++) + for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter++) { if ((int)(cb_iter->second->GetMenu()) != id) { @@ -154,9 +153,9 @@ void CGamePluginPage::PluginItemChanged ( int id, int AboutID, bool bSetChanged } int index = ComboBox->GetCurSel(); - if (index == CB_ERR) + if (index == CB_ERR) { - return; + return; } const CPluginList::PLUGIN ** PluginPtr = (const CPluginList::PLUGIN **)ComboBox->GetItemDataPtr(index); if (PluginPtr) @@ -164,50 +163,51 @@ void CGamePluginPage::PluginItemChanged ( int id, int AboutID, bool bSetChanged const CPluginList::PLUGIN * Plugin = *PluginPtr; if (Plugin) { - ::EnableWindow(GetDlgItem(AboutID),Plugin->AboutFunction); + ::EnableWindow(GetDlgItem(AboutID), Plugin->AboutFunction); } } if (bSetChanged) { ComboBox->SetChanged(true); - SendMessage(GetParent(),PSM_CHANGED,(WPARAM)m_hWnd,0); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } } -void CGamePluginPage::UpdatePageSettings ( void ) +void CGamePluginPage::UpdatePageSettings(void) { UpdateCheckBoxes(); - for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter ++) + for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter++) { CModifiedComboBox * ComboBox = cb_iter->second; stdstr SelectedValue; - - bool PluginChanged = g_Settings->LoadStringVal(cb_iter->first,SelectedValue); + + bool PluginChanged = g_Settings->LoadStringVal(cb_iter->first, SelectedValue); ComboBox->SetChanged(PluginChanged); if (PluginChanged) { - for (int i = 0, n = m_PluginList.GetPluginCount(); i < n; i++ ) + for (int i = 0, n = m_PluginList.GetPluginCount(); i < n; i++) { const CPluginList::PLUGIN * Plugin = m_PluginList.GetPluginInfo(i); if (Plugin == NULL) { continue; } - if (_stricmp(SelectedValue.c_str(),Plugin->FileName.c_str()) != 0) + if (_stricmp(SelectedValue.c_str(), Plugin->FileName.c_str()) != 0) { continue; } ComboBox->SetDefault((WPARAM)Plugin); } - } else { + } + else { ComboBox->SetDefault(NULL); } } - PluginItemChanged(GFX_LIST,GFX_ABOUT,false); - PluginItemChanged(AUDIO_LIST,AUDIO_ABOUT,false); - PluginItemChanged(CONT_LIST,CONT_ABOUT,false); - PluginItemChanged(RSP_LIST,RSP_ABOUT,false); + PluginItemChanged(GFX_LIST, GFX_ABOUT, false); + PluginItemChanged(AUDIO_LIST, AUDIO_ABOUT, false); + PluginItemChanged(CONT_LIST, CONT_ABOUT, false); + PluginItemChanged(RSP_LIST, RSP_ABOUT, false); } void CGamePluginPage::HidePage() @@ -220,12 +220,12 @@ void CGamePluginPage::ShowPage() ShowWindow(SW_SHOW); } -void CGamePluginPage::ApplySettings( bool UpdateScreen ) +void CGamePluginPage::ApplySettings(bool UpdateScreen) { CSettingsPageImpl::ApplySettings(UpdateScreen); } -bool CGamePluginPage::EnableReset ( void ) +bool CGamePluginPage::EnableReset(void) { if (CSettingsPageImpl::EnableReset()) { return true; } return false; @@ -236,17 +236,17 @@ void CGamePluginPage::ResetPage() CSettingsPageImpl::ResetPage(); } -void CGamePluginPage::ApplyComboBoxes ( void ) +void CGamePluginPage::ApplyComboBoxes(void) { - for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter ++) + for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter++) { CModifiedComboBox * ComboBox = cb_iter->second; if (ComboBox->IsChanged()) { int index = ComboBox->GetCurSel(); - if (index == CB_ERR) + if (index == CB_ERR) { - return; + return; } const CPluginList::PLUGIN ** PluginPtr = (const CPluginList::PLUGIN **)ComboBox->GetItemDataPtr(index); @@ -261,9 +261,10 @@ void CGamePluginPage::ApplyComboBoxes ( void ) { if (g_Settings->LoadStringVal(cb_iter->first) != Plugin->FileName.c_str()) { - g_Settings->SaveString(cb_iter->first,Plugin->FileName.c_str()); + g_Settings->SaveString(cb_iter->first, Plugin->FileName.c_str()); } - } else { + } + else { g_Settings->DeleteSetting(cb_iter->first); } } @@ -275,7 +276,7 @@ void CGamePluginPage::ApplyComboBoxes ( void ) } } -bool CGamePluginPage::ResetComboBox ( CModifiedComboBox & ComboBox, SettingID /*Type*/ ) +bool CGamePluginPage::ResetComboBox(CModifiedComboBox & ComboBox, SettingID /*Type*/) { if (!ComboBox.IsChanged()) { @@ -300,18 +301,18 @@ bool CGamePluginPage::ResetComboBox ( CModifiedComboBox & ComboBox, SettingID /* return false; } -void CGamePluginPage::HleGfxChanged ( UINT /*Code*/, int id, HWND /*ctl*/ ) +void CGamePluginPage::HleGfxChanged(UINT /*Code*/, int id, HWND /*ctl*/) { - for (ButtonList::iterator iter = m_ButtonList.begin(); iter != m_ButtonList.end(); iter ++) + for (ButtonList::iterator iter = m_ButtonList.begin(); iter != m_ButtonList.end(); iter++) { CModifiedButton * Button = iter->second; if ((int)Button->GetMenu() != id) { continue; - } + } if ((Button->GetCheck() & BST_CHECKED) == 0) { - int res = MessageBoxW(m_hWnd, GS(MSG_SET_LLE_GFX_MSG),GS(MSG_SET_LLE_GFX_TITLE),MB_YESNO|MB_ICONWARNING); + int res = MessageBoxW(m_hWnd, GS(MSG_SET_LLE_GFX_MSG), GS(MSG_SET_LLE_GFX_TITLE), MB_YESNO | MB_ICONWARNING); if (res != IDYES) { Button->SetCheck(BST_CHECKED); @@ -319,23 +320,23 @@ void CGamePluginPage::HleGfxChanged ( UINT /*Code*/, int id, HWND /*ctl*/ ) } } Button->SetChanged(true); - SendMessage(GetParent(),PSM_CHANGED,(WPARAM)m_hWnd,0); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); break; } } -void CGamePluginPage::HleAudioChanged ( UINT /*Code*/, int id, HWND /*ctl*/ ) +void CGamePluginPage::HleAudioChanged(UINT /*Code*/, int id, HWND /*ctl*/) { - for (ButtonList::iterator iter = m_ButtonList.begin(); iter != m_ButtonList.end(); iter ++) + for (ButtonList::iterator iter = m_ButtonList.begin(); iter != m_ButtonList.end(); iter++) { CModifiedButton * Button = iter->second; if ((int)Button->GetMenu() != id) { continue; - } + } if ((Button->GetCheck() & BST_CHECKED) != 0) { - int res = MessageBoxW(m_hWnd, GS(MSG_SET_HLE_AUD_MSG),GS(MSG_SET_HLE_AUD_TITLE),MB_ICONWARNING|MB_YESNO); + int res = MessageBoxW(m_hWnd, GS(MSG_SET_HLE_AUD_MSG), GS(MSG_SET_HLE_AUD_TITLE), MB_ICONWARNING | MB_YESNO); if (res != IDYES) { Button->SetCheck(BST_UNCHECKED); @@ -343,8 +344,7 @@ void CGamePluginPage::HleAudioChanged ( UINT /*Code*/, int id, HWND /*ctl*/ ) } } Button->SetChanged(true); - SendMessage(GetParent(),PSM_CHANGED,(WPARAM)m_hWnd,0); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); break; } } -#endif diff --git a/Source/Project64/User Interface/Settings/Settings Page - Game - Plugin.h b/Source/Project64/User Interface/Settings/Settings Page - Game - Plugin.h index e74971957..6d9f0769c 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game - Plugin.h +++ b/Source/Project64/User Interface/Settings/Settings Page - Game - Plugin.h @@ -17,51 +17,51 @@ class CGamePluginPage : public CSettingsPage { BEGIN_MSG_MAP_EX(CGamePluginPage) - COMMAND_HANDLER_EX(GFX_LIST,LBN_SELCHANGE,GfxPluginChanged) - COMMAND_HANDLER_EX(AUDIO_LIST,LBN_SELCHANGE,AudioPluginChanged) - COMMAND_HANDLER_EX(CONT_LIST,LBN_SELCHANGE,ControllerPluginChanged) - COMMAND_HANDLER_EX(RSP_LIST,LBN_SELCHANGE,RspPluginChanged) - COMMAND_ID_HANDLER_EX(GFX_ABOUT,GfxPluginAbout) - COMMAND_ID_HANDLER_EX(AUDIO_ABOUT,AudioPluginAbout) - COMMAND_ID_HANDLER_EX(CONT_ABOUT,ControllerPluginAbout) - COMMAND_ID_HANDLER_EX(RSP_ABOUT,RspPluginAbout) - COMMAND_ID_HANDLER_EX(IDC_HLE_GFX,HleGfxChanged) - COMMAND_ID_HANDLER_EX(IDC_HLE_AUDIO,HleAudioChanged) - END_MSG_MAP() + COMMAND_HANDLER_EX(GFX_LIST, LBN_SELCHANGE, GfxPluginChanged) + COMMAND_HANDLER_EX(AUDIO_LIST, LBN_SELCHANGE, AudioPluginChanged) + COMMAND_HANDLER_EX(CONT_LIST, LBN_SELCHANGE, ControllerPluginChanged) + COMMAND_HANDLER_EX(RSP_LIST, LBN_SELCHANGE, RspPluginChanged) + COMMAND_ID_HANDLER_EX(GFX_ABOUT, GfxPluginAbout) + COMMAND_ID_HANDLER_EX(AUDIO_ABOUT, AudioPluginAbout) + COMMAND_ID_HANDLER_EX(CONT_ABOUT, ControllerPluginAbout) + COMMAND_ID_HANDLER_EX(RSP_ABOUT, RspPluginAbout) + COMMAND_ID_HANDLER_EX(IDC_HLE_GFX, HleGfxChanged) + COMMAND_ID_HANDLER_EX(IDC_HLE_AUDIO, HleAudioChanged) + END_MSG_MAP() - enum { IDD = IDD_Settings_GamePlugin }; + enum { IDD = IDD_Settings_GamePlugin }; public: - CGamePluginPage(HWND hParent, const RECT & rcDispay ); + CGamePluginPage(HWND hParent, const RECT & rcDispay); - LanguageStringID PageTitle ( void ) { return TAB_PLUGIN; } - void HidePage ( void ); - void ShowPage ( void ); - void ApplySettings ( bool UpdateScreen ); - bool EnableReset ( void ); - void ResetPage ( void ); + LanguageStringID PageTitle(void) { return TAB_PLUGIN; } + void HidePage(void); + void ShowPage(void); + void ApplySettings(bool UpdateScreen); + bool EnableReset(void); + void ResetPage(void); private: - void GfxPluginAbout ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) { ShowAboutButton(GFX_LIST); } - void AudioPluginAbout ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) { ShowAboutButton(AUDIO_LIST); } - void ControllerPluginAbout ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) { ShowAboutButton(CONT_LIST); } - void RspPluginAbout ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) { ShowAboutButton(RSP_LIST); } + void GfxPluginAbout(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { ShowAboutButton(GFX_LIST); } + void AudioPluginAbout(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { ShowAboutButton(AUDIO_LIST); } + void ControllerPluginAbout(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { ShowAboutButton(CONT_LIST); } + void RspPluginAbout(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { ShowAboutButton(RSP_LIST); } - void GfxPluginChanged ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) { PluginItemChanged(GFX_LIST,GFX_ABOUT); } - void AudioPluginChanged ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) { PluginItemChanged(AUDIO_LIST,AUDIO_ABOUT); } - void ControllerPluginChanged ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) { PluginItemChanged(CONT_LIST,CONT_ABOUT); } - void RspPluginChanged ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) { PluginItemChanged(RSP_LIST,RSP_ABOUT); } + void GfxPluginChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { PluginItemChanged(GFX_LIST, GFX_ABOUT); } + void AudioPluginChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { PluginItemChanged(AUDIO_LIST, AUDIO_ABOUT); } + void ControllerPluginChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { PluginItemChanged(CONT_LIST, CONT_ABOUT); } + void RspPluginChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { PluginItemChanged(RSP_LIST, RSP_ABOUT); } - void HleGfxChanged ( UINT Code, int id, HWND ctl ); - void HleAudioChanged ( UINT Code, int id, HWND ctl ); + void HleGfxChanged(UINT Code, int id, HWND ctl); + void HleAudioChanged(UINT Code, int id, HWND ctl); - void ShowAboutButton ( int id ); - void PluginItemChanged ( int id, int AboutID, bool bSetChanged = true ); + void ShowAboutButton(int id); + void PluginItemChanged(int id, int AboutID, bool bSetChanged = true); - void AddPlugins (int ListId,SettingID Type, PLUGIN_TYPE PluginType ); - void UpdatePageSettings ( void ); - void ApplyComboBoxes ( void ); - bool ResetComboBox ( CModifiedComboBox & ComboBox, SettingID Type ); + void AddPlugins(int ListId, SettingID Type, PLUGIN_TYPE PluginType); + void UpdatePageSettings(void); + void ApplyComboBoxes(void); + bool ResetComboBox(CModifiedComboBox & ComboBox, SettingID Type); CPartialGroupBox m_GfxGroup, m_AudioGroup, m_ControlGroup, m_RspGroup; CPluginList m_PluginList; diff --git a/Source/Project64/User Interface/Settings/Settings Page - Game - Recompiler.cpp b/Source/Project64/User Interface/Settings/Settings Page - Game - Recompiler.cpp index 648d0edf1..3b72f2860 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game - Recompiler.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Game - Recompiler.cpp @@ -10,13 +10,12 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI #include "Settings Page.h" #include "Settings Page - Game - Recompiler.h" -CGameRecompilePage::CGameRecompilePage (HWND hParent, const RECT & rcDispay ) +CGameRecompilePage::CGameRecompilePage(HWND hParent, const RECT & rcDispay) { - if (!Create(hParent,rcDispay)) + if (!Create(hParent, rcDispay)) { return; } @@ -38,19 +37,19 @@ CGameRecompilePage::CGameRecompilePage (HWND hParent, const RECT & rcDispay ) m_SelfModGroup.Attach(GetDlgItem(IDC_SMM_FRAME)); - AddModCheckBox(GetDlgItem(IDC_ROM_REGCACHE),Game_RegCache); - AddModCheckBox(GetDlgItem(IDC_BLOCK_LINKING),Game_BlockLinking); - AddModCheckBox(GetDlgItem(IDC_SMM_CACHE),Game_SMM_Cache); - AddModCheckBox(GetDlgItem(IDC_SMM_DMA),Game_SMM_PIDMA); - AddModCheckBox(GetDlgItem(IDC_SMM_VALIDATE),Game_SMM_ValidFunc); - AddModCheckBox(GetDlgItem(IDC_SMM_TLB),Game_SMM_TLB); - AddModCheckBox(GetDlgItem(IDC_SMM_PROTECT),Game_SMM_Protect); - ::ShowWindow(GetDlgItem(IDC_SMM_STORE),SW_HIDE); + AddModCheckBox(GetDlgItem(IDC_ROM_REGCACHE), Game_RegCache); + AddModCheckBox(GetDlgItem(IDC_BLOCK_LINKING), Game_BlockLinking); + AddModCheckBox(GetDlgItem(IDC_SMM_CACHE), Game_SMM_Cache); + AddModCheckBox(GetDlgItem(IDC_SMM_DMA), Game_SMM_PIDMA); + AddModCheckBox(GetDlgItem(IDC_SMM_VALIDATE), Game_SMM_ValidFunc); + AddModCheckBox(GetDlgItem(IDC_SMM_TLB), Game_SMM_TLB); + AddModCheckBox(GetDlgItem(IDC_SMM_PROTECT), Game_SMM_Protect); + ::ShowWindow(GetDlgItem(IDC_SMM_STORE), SW_HIDE); //AddModCheckBox(GetDlgItem(IDC_SMM_STORE),Game_SMM_StoreInstruc); - AddModCheckBox(GetDlgItem(IDC_ROM_FASTSP),Game_FastSP); + AddModCheckBox(GetDlgItem(IDC_ROM_FASTSP), Game_FastSP); CModifiedComboBox * ComboBox; - ComboBox = AddModComboBox(GetDlgItem(IDC_CPU_TYPE),Game_CpuType); + ComboBox = AddModComboBox(GetDlgItem(IDC_CPU_TYPE), Game_CpuType); if (ComboBox) { ComboBox->AddItemW(GS(CORE_RECOMPILER), CPU_Recompiler); @@ -61,7 +60,7 @@ CGameRecompilePage::CGameRecompilePage (HWND hParent, const RECT & rcDispay ) } } - ComboBox = AddModComboBox(GetDlgItem(IDC_FUNCFIND),Game_FuncLookupMode); + ComboBox = AddModComboBox(GetDlgItem(IDC_FUNCFIND), Game_FuncLookupMode); if (ComboBox) { ComboBox->AddItemW(GS(FLM_PLOOKUP), FuncFind_PhysicalLookup); @@ -81,12 +80,12 @@ void CGameRecompilePage::HidePage() ShowWindow(SW_HIDE); } -void CGameRecompilePage::ApplySettings( bool UpdateScreen ) +void CGameRecompilePage::ApplySettings(bool UpdateScreen) { CSettingsPageImpl::ApplySettings(UpdateScreen); } -bool CGameRecompilePage::EnableReset ( void ) +bool CGameRecompilePage::EnableReset(void) { if (CSettingsPageImpl::EnableReset()) { return true; } return false; @@ -96,4 +95,3 @@ void CGameRecompilePage::ResetPage() { CSettingsPageImpl::ResetPage(); } -#endif diff --git a/Source/Project64/User Interface/Settings/Settings Page - Game - Status.cpp b/Source/Project64/User Interface/Settings/Settings Page - Game - Status.cpp index 89627b03b..2a2e13a9a 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game - Status.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Game - Status.cpp @@ -10,38 +10,37 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI #include "Settings Page.h" #include "Settings Page - Game - Status.h" -CGameStatusPage::CGameStatusPage (HWND hParent, const RECT & rcDispay ) +CGameStatusPage::CGameStatusPage(HWND hParent, const RECT & rcDispay) { - if (!Create(hParent,rcDispay)) + if (!Create(hParent, rcDispay)) { return; } - CIniFile RomIniFile (g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str()); + CIniFile RomIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str()); strlist Keys; - RomIniFile.GetKeyList("Rom Status",Keys); + RomIniFile.GetKeyList("Rom Status", Keys); stdstr Status = g_Settings->LoadStringVal(Rdb_Status); CModifiedComboBoxTxt * ComboBox; - ComboBox = AddModComboBoxTxt(GetDlgItem(IDC_STATUS_TYPE),Rdb_Status); + ComboBox = AddModComboBoxTxt(GetDlgItem(IDC_STATUS_TYPE), Rdb_Status); if (ComboBox) { - for (strlist::iterator item = Keys.begin(); item != Keys.end(); item++ ) + for (strlist::iterator item = Keys.begin(); item != Keys.end(); item++) { - if (strstr(item->c_str(),".Sel") != NULL) { continue; } - if (strstr(item->c_str(),".Auto") != NULL) { continue; } + if (strstr(item->c_str(), ".Sel") != NULL) { continue; } + if (strstr(item->c_str(), ".Auto") != NULL) { continue; } ComboBox->AddItem(item->c_str(), item->c_str()); } ComboBox->SetTextField(GetDlgItem(IDC_STATUS_TEXT)); } CModifiedEditBox * TxtBox; - TxtBox = AddModTextBox(GetDlgItem(IDC_NOTES_CORE),Rdb_NotesCore,true); + TxtBox = AddModTextBox(GetDlgItem(IDC_NOTES_CORE), Rdb_NotesCore, true); TxtBox->SetTextField(GetDlgItem(IDC_NOTES_CORE_TEXT)); - TxtBox = AddModTextBox(GetDlgItem(IDC_NOTES_PLUGIN),Rdb_NotesPlugin,true); + TxtBox = AddModTextBox(GetDlgItem(IDC_NOTES_PLUGIN), Rdb_NotesPlugin, true); TxtBox->SetTextField(GetDlgItem(IDC_NOTES_PLUGIN_TEXT)); UpdatePageSettings(); @@ -57,12 +56,12 @@ void CGameStatusPage::HidePage() ShowWindow(SW_HIDE); } -void CGameStatusPage::ApplySettings( bool UpdateScreen ) +void CGameStatusPage::ApplySettings(bool UpdateScreen) { CSettingsPageImpl::ApplySettings(UpdateScreen); } -bool CGameStatusPage::EnableReset ( void ) +bool CGameStatusPage::EnableReset(void) { if (CSettingsPageImpl::EnableReset()) { return true; } return false; @@ -72,4 +71,3 @@ void CGameStatusPage::ResetPage() { CSettingsPageImpl::ResetPage(); } -#endif diff --git a/Source/Project64/User Interface/Settings/Settings Page - Game Browser.cpp b/Source/Project64/User Interface/Settings/Settings Page - Game Browser.cpp index 23a90d853..acdc22bc8 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game Browser.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Game Browser.cpp @@ -10,31 +10,30 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI #include "Settings Page.h" -COptionsGameBrowserPage::COptionsGameBrowserPage (HWND hParent, const RECT & rcDispay ) : - m_OrderChanged(false), - m_OrderReset(false) +COptionsGameBrowserPage::COptionsGameBrowserPage(HWND hParent, const RECT & rcDispay) : +m_OrderChanged(false), +m_OrderReset(false) { - if (!Create(hParent,rcDispay)) + if (!Create(hParent, rcDispay)) { return; } - - SetDlgItemTextW(m_hWnd, IDC_ROMSEL_TEXT2,GS(RB_ROMS)); - SetDlgItemTextW(m_hWnd, IDC_ROMSEL_TEXT4,GS(RB_DIRS)); - SetDlgItemTextW(m_hWnd, IDC_USE_ROMBROWSER,GS(RB_USE)); - SetDlgItemTextW(m_hWnd, IDC_RECURSION,GS(RB_DIR_RECURSION)); - SetDlgItemTextW(m_hWnd, IDC_ROMSEL_TEXT5,GS(RB_AVALIABLE_FIELDS)); - SetDlgItemTextW(m_hWnd, IDC_ROMSEL_TEXT6,GS(RB_SHOW_FIELDS)); - SetDlgItemTextW(m_hWnd, IDC_ADD,GS(RB_ADD)); - SetDlgItemTextW(m_hWnd, IDC_REMOVE,GS(RB_REMOVE)); - SetDlgItemTextW(m_hWnd, IDC_UP,GS(RB_UP)); - SetDlgItemTextW(m_hWnd, IDC_DOWN,GS(RB_DOWN)); - AddModCheckBox(GetDlgItem(IDC_USE_ROMBROWSER),RomBrowser_Enabled); - AddModCheckBox(GetDlgItem(IDC_RECURSION),RomBrowser_Recursive); + SetDlgItemTextW(m_hWnd, IDC_ROMSEL_TEXT2, GS(RB_ROMS)); + SetDlgItemTextW(m_hWnd, IDC_ROMSEL_TEXT4, GS(RB_DIRS)); + SetDlgItemTextW(m_hWnd, IDC_USE_ROMBROWSER, GS(RB_USE)); + SetDlgItemTextW(m_hWnd, IDC_RECURSION, GS(RB_DIR_RECURSION)); + SetDlgItemTextW(m_hWnd, IDC_ROMSEL_TEXT5, GS(RB_AVALIABLE_FIELDS)); + SetDlgItemTextW(m_hWnd, IDC_ROMSEL_TEXT6, GS(RB_SHOW_FIELDS)); + SetDlgItemTextW(m_hWnd, IDC_ADD, GS(RB_ADD)); + SetDlgItemTextW(m_hWnd, IDC_REMOVE, GS(RB_REMOVE)); + SetDlgItemTextW(m_hWnd, IDC_UP, GS(RB_UP)); + SetDlgItemTextW(m_hWnd, IDC_DOWN, GS(RB_DOWN)); + + AddModCheckBox(GetDlgItem(IDC_USE_ROMBROWSER), RomBrowser_Enabled); + AddModCheckBox(GetDlgItem(IDC_RECURSION), RomBrowser_Recursive); m_Avaliable.Attach(GetDlgItem(IDC_AVALIABLE)); m_Using.Attach(GetDlgItem(IDC_USING)); @@ -44,63 +43,63 @@ COptionsGameBrowserPage::COptionsGameBrowserPage (HWND hParent, const RECT & rcD UpdatePageSettings(); } -void COptionsGameBrowserPage::UpdateFieldList ( const ROMBROWSER_FIELDS_LIST & Fields ) +void COptionsGameBrowserPage::UpdateFieldList(const ROMBROWSER_FIELDS_LIST & Fields) { m_Avaliable.ResetContent(); m_Using.ResetContent(); m_OrderChanged = false; - for (int i = 0, n = Fields.size(); i < n; i++) + for (int i = 0, n = Fields.size(); i < n; i++) { if (Fields[i].PosChanged()) { m_OrderChanged = true; } int Pos = Fields[i].Pos(); - if (Pos < 0) - { - m_Avaliable.SetItemData(m_Avaliable.AddStringW(GS(Fields[i].LangID())),i); + if (Pos < 0) + { + m_Avaliable.SetItemData(m_Avaliable.AddStringW(GS(Fields[i].LangID())), i); continue; } int listCount = m_Using.GetCount(); if (Pos > listCount) { Pos = listCount; } - m_Using.SetItemData(m_Using.InsertStringW(Pos,GS(Fields[i].LangID())),i); + m_Using.SetItemData(m_Using.InsertStringW(Pos, GS(Fields[i].LangID())), i); } } -void COptionsGameBrowserPage::UpdatePageSettings ( void ) +void COptionsGameBrowserPage::UpdatePageSettings(void) { UpdateFieldList(m_Fields); CSettingsPageImpl::UpdatePageSettings(); FixCtrlState(); } -void COptionsGameBrowserPage::UseRomBrowserChanged ( UINT Code, int id, HWND ctl ) +void COptionsGameBrowserPage::UseRomBrowserChanged(UINT Code, int id, HWND ctl) { - CheckBoxChanged(Code,id,ctl); + CheckBoxChanged(Code, id, ctl); FixCtrlState(); } -void COptionsGameBrowserPage::FixCtrlState ( void ) +void COptionsGameBrowserPage::FixCtrlState(void) { - bool bEnabled = (SendDlgItemMessage(IDC_USE_ROMBROWSER,BM_GETCHECK,0,0) == BST_CHECKED); - ::EnableWindow(GetDlgItem(IDC_ROMSEL_TEXT5),bEnabled); - ::EnableWindow(GetDlgItem(IDC_ROMSEL_TEXT6),bEnabled); - ::EnableWindow(GetDlgItem(IDC_AVALIABLE),bEnabled); - ::EnableWindow(GetDlgItem(IDC_ADD),bEnabled); - ::EnableWindow(GetDlgItem(IDC_REMOVE),bEnabled); - ::EnableWindow(GetDlgItem(IDC_USING),bEnabled); - ::EnableWindow(GetDlgItem(IDC_UP),bEnabled); - ::EnableWindow(GetDlgItem(IDC_DOWN),bEnabled); - ::EnableWindow(GetDlgItem(IDC_RECURSION),bEnabled); + bool bEnabled = (SendDlgItemMessage(IDC_USE_ROMBROWSER, BM_GETCHECK, 0, 0) == BST_CHECKED); + ::EnableWindow(GetDlgItem(IDC_ROMSEL_TEXT5), bEnabled); + ::EnableWindow(GetDlgItem(IDC_ROMSEL_TEXT6), bEnabled); + ::EnableWindow(GetDlgItem(IDC_AVALIABLE), bEnabled); + ::EnableWindow(GetDlgItem(IDC_ADD), bEnabled); + ::EnableWindow(GetDlgItem(IDC_REMOVE), bEnabled); + ::EnableWindow(GetDlgItem(IDC_USING), bEnabled); + ::EnableWindow(GetDlgItem(IDC_UP), bEnabled); + ::EnableWindow(GetDlgItem(IDC_DOWN), bEnabled); + ::EnableWindow(GetDlgItem(IDC_RECURSION), bEnabled); } -void COptionsGameBrowserPage::AddFieldClicked ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) +void COptionsGameBrowserPage::AddFieldClicked(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { int index = m_Avaliable.GetCurSel(); - if (index < 0) + if (index < 0) { - return; + return; } //remove from list int i = m_Avaliable.GetItemData(index); @@ -108,20 +107,20 @@ void COptionsGameBrowserPage::AddFieldClicked ( UINT /*Code*/, int /*id*/, HWND //select next in list int listCount = m_Avaliable.GetCount(); - if (index >= listCount) { index -= 1;} + if (index >= listCount) { index -= 1; } m_Avaliable.SetCurSel(index); //Add to list index = m_Using.AddStringW(GS(m_Fields[i].LangID())); - m_Using.SetItemData(index,i); + m_Using.SetItemData(index, i); m_Using.SetCurSel(index); m_OrderChanged = true; m_OrderReset = false; - SendMessage(GetParent(),PSM_CHANGED ,(WPARAM)m_hWnd,0); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } -void COptionsGameBrowserPage::RemoveFieldClicked ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) +void COptionsGameBrowserPage::RemoveFieldClicked(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { int index = m_Using.GetCurSel(); if (index < 0) @@ -147,42 +146,42 @@ void COptionsGameBrowserPage::RemoveFieldClicked ( UINT /*Code*/, int /*id*/, HW SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } -void COptionsGameBrowserPage::MoveFieldUpClicked ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) +void COptionsGameBrowserPage::MoveFieldUpClicked(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { int index = m_Using.GetCurSel(); - if (index <= 0) - { - return; + if (index <= 0) + { + return; } int i = m_Using.GetItemData(index); m_Using.DeleteString(index); - index = m_Using.InsertStringW(index - 1,GS(m_Fields[i].LangID())); - m_Using.SetItemData(index,i); + index = m_Using.InsertStringW(index - 1, GS(m_Fields[i].LangID())); + m_Using.SetItemData(index, i); m_Using.SetCurSel(index); m_OrderChanged = true; m_OrderReset = false; - SendMessage(GetParent(),PSM_CHANGED ,(WPARAM)m_hWnd,0); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } -void COptionsGameBrowserPage::MoveFieldDownClicked ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) +void COptionsGameBrowserPage::MoveFieldDownClicked(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { int index = m_Using.GetCurSel(); if (index < 0 || index >= (m_Using.GetCount() - 1)) - { - return; + { + return; } int i = m_Using.GetItemData(index); m_Using.DeleteString(index); - index = m_Using.InsertStringW(index + 1,GS(m_Fields[i].LangID())); - m_Using.SetItemData(index,i); + index = m_Using.InsertStringW(index + 1, GS(m_Fields[i].LangID())); + m_Using.SetItemData(index, i); m_Using.SetCurSel(index); m_OrderChanged = true; m_OrderReset = false; - SendMessage(GetParent(),PSM_CHANGED ,(WPARAM)m_hWnd,0); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } void COptionsGameBrowserPage::HidePage() @@ -195,19 +194,21 @@ void COptionsGameBrowserPage::ShowPage() ShowWindow(SW_SHOW); } -void COptionsGameBrowserPage::ApplySettings( bool UpdateScreen ) +void COptionsGameBrowserPage::ApplySettings(bool UpdateScreen) { bool bColChanged = false; if (m_OrderReset) { - for (size_t i = 0; i < m_Fields.size(); i++ ) + for (size_t i = 0; i < m_Fields.size(); i++) { m_Fields[i].ResetPos(); } bColChanged = true; - } else { + } + else + { size_t Item, listCount = m_Using.GetCount(); - for (Item = 0; Item < listCount; Item ++ ) + for (Item = 0; Item < listCount; Item++) { int Pos = m_Using.GetItemData(Item); if (m_OrderReset || m_Fields[Pos].Pos() != Item) @@ -218,7 +219,7 @@ void COptionsGameBrowserPage::ApplySettings( bool UpdateScreen ) } listCount = m_Avaliable.GetCount(); - for (Item = 0; Item < listCount; Item ++ ) + for (Item = 0; Item < listCount; Item++) { int Pos = m_Avaliable.GetItemData(Item); if (m_OrderReset || m_Fields[Pos].Pos() != -1) @@ -230,13 +231,13 @@ void COptionsGameBrowserPage::ApplySettings( bool UpdateScreen ) } if (bColChanged) { - g_Settings->SaveBool(RomBrowser_ColoumnsChanged,!g_Settings->LoadBool(RomBrowser_ColoumnsChanged)); + g_Settings->SaveBool(RomBrowser_ColoumnsChanged, !g_Settings->LoadBool(RomBrowser_ColoumnsChanged)); } CSettingsPageImpl::ApplySettings(UpdateScreen); } -bool COptionsGameBrowserPage::EnableReset ( void ) +bool COptionsGameBrowserPage::EnableReset(void) { if (m_OrderChanged) { return true; } return CSettingsPageImpl::EnableReset(); @@ -244,14 +245,13 @@ bool COptionsGameBrowserPage::EnableReset ( void ) void COptionsGameBrowserPage::ResetPage() { - if (m_OrderChanged) - { + if (m_OrderChanged) + { ROMBROWSER_FIELDS_LIST Fields; - CRomBrowser::GetFieldInfo(Fields,true); + CRomBrowser::GetFieldInfo(Fields, true); UpdateFieldList(Fields); m_OrderReset = true; - SendMessage(GetParent(),PSM_CHANGED,(WPARAM)m_hWnd,0); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } CSettingsPageImpl::ResetPage(); } -#endif diff --git a/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.cpp b/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.cpp index df720dd89..0ff9a07f3 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.cpp @@ -10,58 +10,56 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI #include "Settings Page.h" -COptionsShortCutsPage::COptionsShortCutsPage (HWND hParent, const RECT & rcDispay ) : - m_EnableReset(false) +COptionsShortCutsPage::COptionsShortCutsPage(HWND hParent, const RECT & rcDispay) : +m_EnableReset(false) { - if (!Create(hParent,rcDispay)) + if (!Create(hParent, rcDispay)) { return; } - SetDlgItemTextW(m_hWnd, IDC_S_CPU_STATE,GS(ACCEL_CPUSTATE_TITLE)); - SetDlgItemTextW(m_hWnd, IDC_MENU_ITEM_TEXT,GS(ACCEL_MENUITEM_TITLE)); - SetDlgItemTextW(m_hWnd, IDC_S_CURRENT_KEYS,GS(ACCEL_CURRENTKEYS_TITLE)); - SetDlgItemTextW(m_hWnd, IDC_S_SELECT_SHORT,GS(ACCEL_SELKEY_TITLE)); - SetDlgItemTextW(m_hWnd, IDC_S_CURRENT_ASSIGN,GS(ACCEL_ASSIGNEDTO_TITLE)); - SetDlgItemTextW(m_hWnd, IDC_ASSIGN,GS(ACCEL_ASSIGN_BTN)); - SetDlgItemTextW(m_hWnd, IDC_REMOVE,GS(ACCEL_REMOVE_BTN)); + SetDlgItemTextW(m_hWnd, IDC_S_CPU_STATE, GS(ACCEL_CPUSTATE_TITLE)); + SetDlgItemTextW(m_hWnd, IDC_MENU_ITEM_TEXT, GS(ACCEL_MENUITEM_TITLE)); + SetDlgItemTextW(m_hWnd, IDC_S_CURRENT_KEYS, GS(ACCEL_CURRENTKEYS_TITLE)); + SetDlgItemTextW(m_hWnd, IDC_S_SELECT_SHORT, GS(ACCEL_SELKEY_TITLE)); + SetDlgItemTextW(m_hWnd, IDC_S_CURRENT_ASSIGN, GS(ACCEL_ASSIGNEDTO_TITLE)); + SetDlgItemTextW(m_hWnd, IDC_ASSIGN, GS(ACCEL_ASSIGN_BTN)); + SetDlgItemTextW(m_hWnd, IDC_REMOVE, GS(ACCEL_REMOVE_BTN)); SetDlgItemTextW(m_hWnd, IDC_KEY_PROMPT, GS(ACCEL_DETECTKEY)); - m_CreateNewShortCut.AttachToDlgItem(m_hWnd,IDC_S_SELECT_SHORT); + m_CreateNewShortCut.AttachToDlgItem(m_hWnd, IDC_S_SELECT_SHORT); m_CpuState.Attach(GetDlgItem(IDC_C_CPU_STATE)); m_MenuItems.Attach(GetDlgItem(IDC_MENU_ITEMS)); m_CurrentKeys.Attach(GetDlgItem(IDC_CURRENT_KEYS)); m_VirtualKeyList.Attach(GetDlgItem(IDC_VIRTUALKEY)); - m_MenuItems.ModifyStyle(0,TVS_SHOWSELALWAYS); + m_MenuItems.ModifyStyle(0, TVS_SHOWSELALWAYS); - m_CpuState.SetItemData(m_CpuState.AddStringW(GS(ACCEL_CPUSTATE_1)),CMenuShortCutKey::GAME_NOT_RUNNING); - m_CpuState.SetItemData(m_CpuState.AddStringW(GS(ACCEL_CPUSTATE_3)),CMenuShortCutKey::GAME_RUNNING_WINDOW); - m_CpuState.SetItemData(m_CpuState.AddStringW(GS(ACCEL_CPUSTATE_4)),CMenuShortCutKey::GAME_RUNNING_FULLSCREEN); + m_CpuState.SetItemData(m_CpuState.AddStringW(GS(ACCEL_CPUSTATE_1)), CMenuShortCutKey::GAME_NOT_RUNNING); + m_CpuState.SetItemData(m_CpuState.AddStringW(GS(ACCEL_CPUSTATE_3)), CMenuShortCutKey::GAME_RUNNING_WINDOW); + m_CpuState.SetItemData(m_CpuState.AddStringW(GS(ACCEL_CPUSTATE_4)), CMenuShortCutKey::GAME_RUNNING_FULLSCREEN); m_CpuState.SetCurSel(0); - + int VirtualKeyListSize; VIRTUAL_KEY * VirtualKeyList = CMenuShortCutKey::VirtualKeyList(VirtualKeyListSize); - for (int count = 0; count < VirtualKeyListSize; count++) + for (int count = 0; count < VirtualKeyListSize; count++) { - m_VirtualKeyList.SetItemData(m_VirtualKeyList.AddString(VirtualKeyList[count].Name),VirtualKeyList[count].Key); + m_VirtualKeyList.SetItemData(m_VirtualKeyList.AddString(VirtualKeyList[count].Name), VirtualKeyList[count].Key); } - OnCpuStateChanged(LBN_SELCHANGE,IDC_C_CPU_STATE,GetDlgItem(IDC_C_CPU_STATE)); + OnCpuStateChanged(LBN_SELCHANGE, IDC_C_CPU_STATE, GetDlgItem(IDC_C_CPU_STATE)); CheckResetEnable(); - } -void COptionsShortCutsPage::CheckResetEnable ( void ) +void COptionsShortCutsPage::CheckResetEnable(void) { MSC_MAP & ShortCuts = m_ShortCuts.GetShortCuts(); - for (MSC_MAP::iterator Item = ShortCuts.begin(); Item != ShortCuts.end(); Item++) + for (MSC_MAP::iterator Item = ShortCuts.begin(); Item != ShortCuts.end(); Item++) { const SHORTCUT_KEY_LIST & ShortCutList = Item->second.GetAccelItems(); - for (SHORTCUT_KEY_LIST::const_iterator ShortCut_item = ShortCutList.begin(); ShortCut_item != ShortCutList.end(); ShortCut_item ++) + for (SHORTCUT_KEY_LIST::const_iterator ShortCut_item = ShortCutList.begin(); ShortCut_item != ShortCutList.end(); ShortCut_item++) { if (!ShortCut_item->Inactive() && !ShortCut_item->UserAdded()) { @@ -70,7 +68,6 @@ void COptionsShortCutsPage::CheckResetEnable ( void ) m_EnableReset = true; return; } - } m_EnableReset = false; } @@ -82,16 +79,16 @@ void COptionsShortCutsPage::OnCpuStateChanged(UINT /*Code*/, int /*id*/, HWND /* MSC_MAP & ShortCuts = m_ShortCuts.GetShortCuts(); m_MenuItems.DeleteAllItems(); - for (MSC_MAP::iterator Item = ShortCuts.begin(); Item != ShortCuts.end(); Item++) + for (MSC_MAP::iterator Item = ShortCuts.begin(); Item != ShortCuts.end(); Item++) { ACCESS_MODE ItemMode = Item->second.AccessMode(); - if ((ItemMode & AccessLevel) != AccessLevel ) + if ((ItemMode & AccessLevel) != AccessLevel) { continue; } //find Parent HTREEITEM hParent = m_MenuItems.GetChildItem(TVI_ROOT); - while (hParent) + while (hParent) { if (m_MenuItems.GetItemData(hParent) == (DWORD_PTR)Item->second.Section()) { @@ -102,156 +99,156 @@ void COptionsShortCutsPage::OnCpuStateChanged(UINT /*Code*/, int /*id*/, HWND /* if (hParent == NULL) { - hParent = m_MenuItems.InsertItemW(TVIF_TEXT | TVIF_PARAM,GS(Item->second.Section()),0,0,0,0, Item->second.Section(),TVI_ROOT,TVI_LAST); + hParent = m_MenuItems.InsertItemW(TVIF_TEXT | TVIF_PARAM, GS(Item->second.Section()), 0, 0, 0, 0, Item->second.Section(), TVI_ROOT, TVI_LAST); } wstring str = GS(Item->second.Title()); - std::wstring::size_type pos = str.find( L"&" ); - while ( pos != std::wstring::npos ) + std::wstring::size_type pos = str.find(L"&"); + while (pos != std::wstring::npos) { - str.replace( pos, 1, L"" ); - pos = str.find( L"&", pos ); + str.replace(pos, 1, L""); + pos = str.find(L"&", pos); } - pos = str.find( L"..." ); - while ( pos != std::wstring::npos ) + pos = str.find(L"..."); + while (pos != std::wstring::npos) { - str.replace( pos, 3, L"" ); - pos = str.find( L"...", pos ); + str.replace(pos, 3, L""); + pos = str.find(L"...", pos); } - HTREEITEM hItem = m_MenuItems.InsertItemW(TVIF_TEXT | TVIF_PARAM,str.c_str(),0,0,0,0, (DWORD_PTR)&Item->second,hParent,TVI_LAST); + HTREEITEM hItem = m_MenuItems.InsertItemW(TVIF_TEXT | TVIF_PARAM, str.c_str(), 0, 0, 0, 0, (DWORD_PTR)&Item->second, hParent, TVI_LAST); const SHORTCUT_KEY_LIST & ShortCutList = Item->second.GetAccelItems(); - for (SHORTCUT_KEY_LIST::const_iterator ShortCut_item = ShortCutList.begin(); ShortCut_item != ShortCutList.end(); ShortCut_item ++) + for (SHORTCUT_KEY_LIST::const_iterator ShortCut_item = ShortCutList.begin(); ShortCut_item != ShortCutList.end(); ShortCut_item++) { if (!ShortCut_item->Inactive() && !ShortCut_item->UserAdded()) { continue; } - m_MenuItems.SetItemState(hItem,TVIS_BOLD,TVIS_BOLD); - m_MenuItems.SetItemState(hParent,TVIS_BOLD,TVIS_BOLD); + m_MenuItems.SetItemState(hItem, TVIS_BOLD, TVIS_BOLD); + m_MenuItems.SetItemState(hParent, TVIS_BOLD, TVIS_BOLD); break; } - } } -void COptionsShortCutsPage::OnRemoveClicked ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) +void COptionsShortCutsPage::OnRemoveClicked(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { HTREEITEM hSelectedItem = m_MenuItems.GetSelectedItem(); - if (hSelectedItem == NULL) - { + if (hSelectedItem == NULL) + { g_Notify->DisplayError(GS(MSG_NO_SEL_SHORTCUT)); - return; + return; } HTREEITEM hParent = m_MenuItems.GetParentItem(hSelectedItem); if (hParent == NULL) { - g_Notify->DisplayError(GS(MSG_NO_SEL_SHORTCUT)); - return; + g_Notify->DisplayError(GS(MSG_NO_SEL_SHORTCUT)); + return; } CShortCutItem * ShortCut = (CShortCutItem *)m_MenuItems.GetItemData(hSelectedItem); - + //Make sure an item is selected int index = m_CurrentKeys.GetCurSel(); - if (index < 0) + if (index < 0) { - g_Notify->DisplayError(GS(MSG_NO_SEL_SHORTCUT)); - return; + g_Notify->DisplayError(GS(MSG_NO_SEL_SHORTCUT)); + return; } ShortCut->RemoveItem((CMenuShortCutKey *)m_CurrentKeys.GetItemData(index)); - m_MenuItems.SetItemState(hSelectedItem,TVIS_BOLD,TVIS_BOLD); - m_MenuItems.SetItemState(hParent,TVIS_BOLD,TVIS_BOLD); + m_MenuItems.SetItemState(hSelectedItem, TVIS_BOLD, TVIS_BOLD); + m_MenuItems.SetItemState(hParent, TVIS_BOLD, TVIS_BOLD); m_EnableReset = true; - + RefreshShortCutOptions(hSelectedItem); - SendMessage(GetParent(),PSM_CHANGED ,(WPARAM)m_hWnd,0); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } -void COptionsShortCutsPage::OnDetectKeyClicked ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) +void COptionsShortCutsPage::OnDetectKeyClicked(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { - CloseHandle(CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)stInputGetKeys,this,0,NULL)); + CloseHandle(CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)stInputGetKeys, this, 0, NULL)); } -void COptionsShortCutsPage::OnAssignClicked ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) +void COptionsShortCutsPage::OnAssignClicked(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { //Get the virtual key info int index = m_VirtualKeyList.GetCurSel(); - if (index < 0) - { + if (index < 0) + { g_Notify->DisplayError(GS(MSG_NO_SHORTCUT_SEL)); return; } - WORD key = (WORD)SendDlgItemMessage(IDC_VIRTUALKEY,CB_GETITEMDATA,index,0); - bool bCtrl = (SendDlgItemMessage(IDC_CTL,BM_GETCHECK, 0,0) == BST_CHECKED); - bool bAlt = (SendDlgItemMessage(IDC_ALT,BM_GETCHECK, 0,0) == BST_CHECKED); - bool bShift = (SendDlgItemMessage(IDC_SHIFT,BM_GETCHECK, 0,0) == BST_CHECKED); - + WORD key = (WORD)SendDlgItemMessage(IDC_VIRTUALKEY, CB_GETITEMDATA, index, 0); + bool bCtrl = (SendDlgItemMessage(IDC_CTL, BM_GETCHECK, 0, 0) == BST_CHECKED); + bool bAlt = (SendDlgItemMessage(IDC_ALT, BM_GETCHECK, 0, 0) == BST_CHECKED); + bool bShift = (SendDlgItemMessage(IDC_SHIFT, BM_GETCHECK, 0, 0) == BST_CHECKED); + ACCESS_MODE AccessLevel = (ACCESS_MODE)m_CpuState.GetItemData(m_CpuState.GetCurSel()); - HTREEITEM hSelectedItem = m_MenuItems.GetSelectedItem(); - if (hSelectedItem == NULL) - { - g_Notify->DisplayError(GS(MSG_NO_MENUITEM_SEL)); - return; + if (hSelectedItem == NULL) + { + g_Notify->DisplayError(GS(MSG_NO_MENUITEM_SEL)); + return; } HTREEITEM hParent = m_MenuItems.GetParentItem(hSelectedItem); if (hParent == NULL) { - g_Notify->DisplayError(GS(MSG_NO_MENUITEM_SEL)); - return; + g_Notify->DisplayError(GS(MSG_NO_MENUITEM_SEL)); + return; } CShortCutItem * ShortCut = (CShortCutItem *)m_MenuItems.GetItemData(hSelectedItem); - LanguageStringID strid = m_ShortCuts.GetMenuItemName(key,bCtrl,bAlt,bShift,AccessLevel); - if (strid != EMPTY_STRING) + LanguageStringID strid = m_ShortCuts.GetMenuItemName(key, bCtrl, bAlt, bShift, AccessLevel); + if (strid != EMPTY_STRING) { g_Notify->DisplayError(GS(MSG_MENUITEM_ASSIGNED)); return; } - ShortCut->AddShortCut(key,bCtrl,bAlt,bShift,AccessLevel,true,false); - m_MenuItems.SetItemState(hSelectedItem,TVIS_BOLD,TVIS_BOLD); - m_MenuItems.SetItemState(hParent,TVIS_BOLD,TVIS_BOLD); + ShortCut->AddShortCut(key, bCtrl, bAlt, bShift, AccessLevel, true, false); + m_MenuItems.SetItemState(hSelectedItem, TVIS_BOLD, TVIS_BOLD); + m_MenuItems.SetItemState(hParent, TVIS_BOLD, TVIS_BOLD); m_EnableReset = true; - + RefreshShortCutOptions(hSelectedItem); - SendMessage(GetParent(),PSM_CHANGED ,(WPARAM)m_hWnd,0); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } -void COptionsShortCutsPage::OnShortCutChanged ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) +void COptionsShortCutsPage::OnShortCutChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { //Get the virtual key info int index = m_VirtualKeyList.GetCurSel(); if (index < 0) { return; } - WORD key = (WORD)m_VirtualKeyList.GetItemData(index); - bool bCtrl = (SendDlgItemMessage(IDC_CTL,BM_GETCHECK, 0,0) == BST_CHECKED); - bool bAlt = (SendDlgItemMessage(IDC_ALT,BM_GETCHECK, 0,0) == BST_CHECKED); - bool bShift = (SendDlgItemMessage(IDC_SHIFT,BM_GETCHECK, 0,0) == BST_CHECKED); + WORD key = (WORD)m_VirtualKeyList.GetItemData(index); + bool bCtrl = (SendDlgItemMessage(IDC_CTL, BM_GETCHECK, 0, 0) == BST_CHECKED); + bool bAlt = (SendDlgItemMessage(IDC_ALT, BM_GETCHECK, 0, 0) == BST_CHECKED); + bool bShift = (SendDlgItemMessage(IDC_SHIFT, BM_GETCHECK, 0, 0) == BST_CHECKED); ACCESS_MODE AccessLevel = (ACCESS_MODE)m_CpuState.GetItemData(m_CpuState.GetCurSel()); stdstr str; - str.FromUTF16(GS(m_ShortCuts.GetMenuItemName(key,bCtrl,bAlt,bShift,AccessLevel))); + str.FromUTF16(GS(m_ShortCuts.GetMenuItemName(key, bCtrl, bAlt, bShift, AccessLevel))); if (str.length() > 0) { str.resize(std::remove(str.begin(), str.end(), '&') - str.begin()); - } else { + } + else + { str = "None"; } - SetDlgItemText(IDC_ASSIGNED_MENU_ITEM,str.c_str()); + SetDlgItemText(IDC_ASSIGNED_MENU_ITEM, str.c_str()); } -LRESULT COptionsShortCutsPage::OnMenuItemChanged ( LPNMHDR lpnmh ) +LRESULT COptionsShortCutsPage::OnMenuItemChanged(LPNMHDR lpnmh) { RefreshShortCutOptions(((LPNMTREEVIEW)lpnmh)->itemNew.hItem); return true; } -void COptionsShortCutsPage::RefreshShortCutOptions ( HTREEITEM hItem ) +void COptionsShortCutsPage::RefreshShortCutOptions(HTREEITEM hItem) { HTREEITEM hParent = m_MenuItems.GetParentItem(hItem); if (hParent == NULL) @@ -259,14 +256,13 @@ void COptionsShortCutsPage::RefreshShortCutOptions ( HTREEITEM hItem ) return; } - ACCESS_MODE AccessLevel = (ACCESS_MODE)m_CpuState.GetItemData(m_CpuState.GetCurSel()); CShortCutItem * ShortCut = (CShortCutItem *)m_MenuItems.GetItemData(hItem); m_CurrentKeys.ResetContent(); const SHORTCUT_KEY_LIST & ShortCutList = ShortCut->GetAccelItems(); - for (SHORTCUT_KEY_LIST::const_iterator ShortCut_item = ShortCutList.begin(); ShortCut_item != ShortCutList.end(); ShortCut_item ++) + for (SHORTCUT_KEY_LIST::const_iterator ShortCut_item = ShortCutList.begin(); ShortCut_item != ShortCutList.end(); ShortCut_item++) { if (ShortCut_item->Inactive()) { @@ -274,24 +270,23 @@ void COptionsShortCutsPage::RefreshShortCutOptions ( HTREEITEM hItem ) } ACCESS_MODE ItemMode = ShortCut_item->AccessMode(); - if ((ItemMode & AccessLevel) != AccessLevel ) + if ((ItemMode & AccessLevel) != AccessLevel) { continue; } stdstr Name = ShortCut_item->Name(); - m_CurrentKeys.SetItemData(m_CurrentKeys.AddString(Name.c_str()),(DWORD_PTR)&*ShortCut_item); + m_CurrentKeys.SetItemData(m_CurrentKeys.AddString(Name.c_str()), (DWORD_PTR)&*ShortCut_item); } } - -BOOL CALLBACK KeyPromptDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM /*lParam*/) +BOOL CALLBACK KeyPromptDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM /*lParam*/) { - switch (uMsg) + switch (uMsg) { case WM_INITDIALOG: break; case WM_COMMAND: - switch (LOWORD(wParam)) + switch (LOWORD(wParam)) { case IDCANCEL: SetForegroundWindow(GetParent(hDlg)); @@ -305,49 +300,48 @@ BOOL CALLBACK KeyPromptDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM /*lP return TRUE; } -void COptionsShortCutsPage::InputGetKeys (void) +void COptionsShortCutsPage::InputGetKeys(void) { - HWND hKeyDlg = CreateDialogParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_Key_Prompt),m_hWnd,(DLGPROC)KeyPromptDlgProc,(LPARAM)::GetDlgItem(m_hWnd,IDC_VIRTUALKEY)); - ::EnableWindow(GetParent(),false); + HWND hKeyDlg = CreateDialogParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Key_Prompt), m_hWnd, (DLGPROC)KeyPromptDlgProc, (LPARAM)::GetDlgItem(m_hWnd, IDC_VIRTUALKEY)); + ::EnableWindow(GetParent(), false); MSG msg; - for(bool fDone=false;!fDone;MsgWaitForMultipleObjects(0,NULL,false,45,QS_ALLINPUT)) { - while(PeekMessage(&msg,0,0,0,PM_REMOVE)) { - if(msg.message == WM_QUIT) { + for (bool fDone = false; !fDone; MsgWaitForMultipleObjects(0, NULL, false, 45, QS_ALLINPUT)) { + while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { + if (msg.message == WM_QUIT) { fDone = true; - ::PostMessage(NULL,WM_QUIT,0,0); + ::PostMessage(NULL, WM_QUIT, 0, 0); break; } - if (msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN ) { + if (msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN) { int nVirtKey = (int)msg.wParam; if (nVirtKey == VK_SHIFT) { continue; } if (nVirtKey == VK_CONTROL) { continue; } if (nVirtKey == VK_MENU) { continue; } - SendDlgItemMessage(IDC_VIRTUALKEY,CB_SETCURSEL,(WPARAM)-1,0); - for (int count = 0; count < SendDlgItemMessage(IDC_VIRTUALKEY,CB_GETCOUNT,0,0); count++) { - int Data = (int)SendDlgItemMessage(IDC_VIRTUALKEY,CB_GETITEMDATA,count,0); + SendDlgItemMessage(IDC_VIRTUALKEY, CB_SETCURSEL, (WPARAM)-1, 0); + for (int count = 0; count < SendDlgItemMessage(IDC_VIRTUALKEY, CB_GETCOUNT, 0, 0); count++) { + int Data = (int)SendDlgItemMessage(IDC_VIRTUALKEY, CB_GETITEMDATA, count, 0); if (Data != nVirtKey) { continue; } - SendDlgItemMessage(IDC_VIRTUALKEY,CB_SETCURSEL,count,0); - SendDlgItemMessage(IDC_CTL,BM_SETCHECK, (GetKeyState(VK_CONTROL) & 0x80) != 0 ? BST_CHECKED : BST_UNCHECKED,0); - SendDlgItemMessage(IDC_ALT,BM_SETCHECK, (GetKeyState(VK_MENU) & 0x80) != 0 ? BST_CHECKED : BST_UNCHECKED,0); - SendDlgItemMessage(IDC_SHIFT,BM_SETCHECK, (GetKeyState(VK_SHIFT) & 0x80) != 0 ? BST_CHECKED : BST_UNCHECKED,0); - SendMessage(WM_COMMAND,MAKELPARAM(IDC_VIRTUALKEY,LBN_SELCHANGE),(LPARAM)::GetDlgItem(m_hWnd,IDC_VIRTUALKEY)); + SendDlgItemMessage(IDC_VIRTUALKEY, CB_SETCURSEL, count, 0); + SendDlgItemMessage(IDC_CTL, BM_SETCHECK, (GetKeyState(VK_CONTROL) & 0x80) != 0 ? BST_CHECKED : BST_UNCHECKED, 0); + SendDlgItemMessage(IDC_ALT, BM_SETCHECK, (GetKeyState(VK_MENU) & 0x80) != 0 ? BST_CHECKED : BST_UNCHECKED, 0); + SendDlgItemMessage(IDC_SHIFT, BM_SETCHECK, (GetKeyState(VK_SHIFT) & 0x80) != 0 ? BST_CHECKED : BST_UNCHECKED, 0); + SendMessage(WM_COMMAND, MAKELPARAM(IDC_VIRTUALKEY, LBN_SELCHANGE), (LPARAM)::GetDlgItem(m_hWnd, IDC_VIRTUALKEY)); SetForegroundWindow(GetParent()); ::DestroyWindow(hKeyDlg); } continue; } - if(!::IsDialogMessage(hKeyDlg,&msg)) { + if (!::IsDialogMessage(hKeyDlg, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } - - if(!::IsWindow(hKeyDlg)) { fDone = true; } + if (!::IsWindow(hKeyDlg)) { fDone = true; } } ::SetFocus(GetParent()); - ::EnableWindow(GetParent(),true); + ::EnableWindow(GetParent(), true); } void COptionsShortCutsPage::HidePage() @@ -360,13 +354,13 @@ void COptionsShortCutsPage::ShowPage() ShowWindow(SW_SHOW); } -void COptionsShortCutsPage::ApplySettings( bool /*UpdateScreen*/ ) +void COptionsShortCutsPage::ApplySettings(bool /*UpdateScreen*/) { m_ShortCuts.Save(); - g_Settings->SaveBool(Info_ShortCutsChanged,true); + g_Settings->SaveBool(Info_ShortCutsChanged, true); } -bool COptionsShortCutsPage::EnableReset ( void ) +bool COptionsShortCutsPage::EnableReset(void) { return m_EnableReset; } @@ -375,9 +369,8 @@ void COptionsShortCutsPage::ResetPage() { m_EnableReset = false; m_ShortCuts.Load(true); - OnCpuStateChanged(LBN_SELCHANGE,IDC_C_CPU_STATE,GetDlgItem(IDC_C_CPU_STATE)); - SendMessage(GetParent(),PSM_CHANGED ,(WPARAM)m_hWnd,0); + OnCpuStateChanged(LBN_SELCHANGE, IDC_C_CPU_STATE, GetDlgItem(IDC_C_CPU_STATE)); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); m_CurrentKeys.ResetContent(); CSettingsPageImpl::ResetPage(); } -#endif diff --git a/Source/Project64/User Interface/Settings/Settings Page - Options.cpp b/Source/Project64/User Interface/Settings/Settings Page - Options.cpp index 5187435d8..f60659ea2 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Options.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Options.cpp @@ -10,13 +10,12 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI #include "Settings Page.h" -CGeneralOptionsPage::CGeneralOptionsPage(CSettingConfig * SettingsConfig, HWND hParent, const RECT & rcDispay ) : - m_SettingsConfig(SettingsConfig) +CGeneralOptionsPage::CGeneralOptionsPage(CSettingConfig * SettingsConfig, HWND hParent, const RECT & rcDispay) : +m_SettingsConfig(SettingsConfig) { - if (!Create(hParent,rcDispay)) + if (!Create(hParent, rcDispay)) { return; } @@ -31,15 +30,15 @@ CGeneralOptionsPage::CGeneralOptionsPage(CSettingConfig * SettingsConfig, HWND h SetDlgItemTextW(m_hWnd, IDC_MAXROMDIR_TXT, GS(RB_MAX_DIRS)); SetDlgItemTextW(m_hWnd, IDC_ROMSEL_TEXT4, GS(RB_DIRS)); - AddModCheckBox(GetDlgItem(IDC_AUTOSLEEP),Setting_AutoSleep); - AddModCheckBox(GetDlgItem(IDC_LOAD_FULLSCREEN),Setting_AutoFullscreen); - AddModCheckBox(GetDlgItem(IDC_SCREEN_SAVER),Setting_DisableScrSaver); - AddModCheckBox(GetDlgItem(IDC_BASIC_MODE),UserInterface_BasicMode); + AddModCheckBox(GetDlgItem(IDC_AUTOSLEEP), Setting_AutoSleep); + AddModCheckBox(GetDlgItem(IDC_LOAD_FULLSCREEN), Setting_AutoFullscreen); + AddModCheckBox(GetDlgItem(IDC_SCREEN_SAVER), Setting_DisableScrSaver); + AddModCheckBox(GetDlgItem(IDC_BASIC_MODE), UserInterface_BasicMode); - CModifiedEditBox * TxtBox = AddModTextBox(GetDlgItem(IDC_REMEMBER),File_RecentGameFileCount, false); + CModifiedEditBox * TxtBox = AddModTextBox(GetDlgItem(IDC_REMEMBER), File_RecentGameFileCount, false); TxtBox->SetTextField(GetDlgItem(IDC_MAXROMS_TXT)); - TxtBox = AddModTextBox(GetDlgItem(IDC_REMEMBERDIR),Directory_RecentGameDirCount, false); + TxtBox = AddModTextBox(GetDlgItem(IDC_REMEMBERDIR), Directory_RecentGameDirCount, false); TxtBox->SetTextField(GetDlgItem(IDC_MAXROMDIR_TXT)); UpdatePageSettings(); @@ -55,12 +54,12 @@ void CGeneralOptionsPage::ShowPage() ShowWindow(SW_SHOW); } -void CGeneralOptionsPage::ApplySettings( bool UpdateScreen ) +void CGeneralOptionsPage::ApplySettings(bool UpdateScreen) { CSettingsPageImpl::ApplySettings(UpdateScreen); } -bool CGeneralOptionsPage::EnableReset ( void ) +bool CGeneralOptionsPage::EnableReset(void) { if (CSettingsPageImpl::EnableReset()) { return true; } return false; @@ -72,9 +71,8 @@ void CGeneralOptionsPage::ResetPage() m_SettingsConfig->UpdateAdvanced((int)::SendMessage(GetDlgItem(IDC_BASIC_MODE), BM_GETCHECK, 0, 0) == 0); } -void CGeneralOptionsPage::OnBasicMode ( UINT Code, int id, HWND ctl ) +void CGeneralOptionsPage::OnBasicMode(UINT Code, int id, HWND ctl) { - CheckBoxChanged(Code,id,ctl); + CheckBoxChanged(Code, id, ctl); m_SettingsConfig->UpdateAdvanced((int)::SendMessage(ctl, BM_GETCHECK, 0, 0) == 0); } -#endif diff --git a/Source/Project64/User Interface/Settings/Settings Page - Plugin.cpp b/Source/Project64/User Interface/Settings/Settings Page - Plugin.cpp index c387e5efb..d15e8f2a1 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Plugin.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Plugin.cpp @@ -10,53 +10,52 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI #include "Settings Page.h" -COptionPluginPage::COptionPluginPage (HWND hParent, const RECT & rcDispay ) +COptionPluginPage::COptionPluginPage(HWND hParent, const RECT & rcDispay) { - if (!Create(hParent,rcDispay)) + if (!Create(hParent, rcDispay)) { return; } - - //Set the text for all gui Items - SetDlgItemTextW(m_hWnd, RSP_ABOUT,GS(PLUG_ABOUT)); - SetDlgItemTextW(m_hWnd, GFX_ABOUT,GS(PLUG_ABOUT)); - SetDlgItemTextW(m_hWnd, AUDIO_ABOUT,GS(PLUG_ABOUT)); - SetDlgItemTextW(m_hWnd, CONT_ABOUT,GS(PLUG_ABOUT)); - SetDlgItemTextW(m_hWnd, IDC_RSP_NAME,GS(PLUG_RSP)); - SetDlgItemTextW(m_hWnd, IDC_GFX_NAME,GS(PLUG_GFX)); - SetDlgItemTextW(m_hWnd, IDC_AUDIO_NAME,GS(PLUG_AUDIO)); - SetDlgItemTextW(m_hWnd, IDC_CONT_NAME,GS(PLUG_CTRL)); - - SetDlgItemTextW(m_hWnd, IDC_HLE_GFX,GS(PLUG_HLE_GFX)); - SetDlgItemTextW(m_hWnd, IDC_HLE_AUDIO,GS(PLUG_HLE_AUDIO)); + //Set the text for all gui Items + SetDlgItemTextW(m_hWnd, RSP_ABOUT, GS(PLUG_ABOUT)); + SetDlgItemTextW(m_hWnd, GFX_ABOUT, GS(PLUG_ABOUT)); + SetDlgItemTextW(m_hWnd, AUDIO_ABOUT, GS(PLUG_ABOUT)); + SetDlgItemTextW(m_hWnd, CONT_ABOUT, GS(PLUG_ABOUT)); + + SetDlgItemTextW(m_hWnd, IDC_RSP_NAME, GS(PLUG_RSP)); + SetDlgItemTextW(m_hWnd, IDC_GFX_NAME, GS(PLUG_GFX)); + SetDlgItemTextW(m_hWnd, IDC_AUDIO_NAME, GS(PLUG_AUDIO)); + SetDlgItemTextW(m_hWnd, IDC_CONT_NAME, GS(PLUG_CTRL)); + + SetDlgItemTextW(m_hWnd, IDC_HLE_GFX, GS(PLUG_HLE_GFX)); + SetDlgItemTextW(m_hWnd, IDC_HLE_AUDIO, GS(PLUG_HLE_AUDIO)); m_GfxGroup.Attach(GetDlgItem(IDC_GFX_NAME)); m_AudioGroup.Attach(GetDlgItem(IDC_AUDIO_NAME)); m_ControlGroup.Attach(GetDlgItem(IDC_CONT_NAME)); m_RspGroup.Attach(GetDlgItem(IDC_RSP_NAME)); - AddPlugins(GFX_LIST,Plugin_GFX_Current,PLUGIN_TYPE_GFX); - AddPlugins(AUDIO_LIST,Plugin_AUDIO_Current,PLUGIN_TYPE_AUDIO); - AddPlugins(CONT_LIST,Plugin_CONT_Current,PLUGIN_TYPE_CONTROLLER); - AddPlugins(RSP_LIST,Plugin_RSP_Current,PLUGIN_TYPE_RSP); + AddPlugins(GFX_LIST, Plugin_GFX_Current, PLUGIN_TYPE_GFX); + AddPlugins(AUDIO_LIST, Plugin_AUDIO_Current, PLUGIN_TYPE_AUDIO); + AddPlugins(CONT_LIST, Plugin_CONT_Current, PLUGIN_TYPE_CONTROLLER); + AddPlugins(RSP_LIST, Plugin_RSP_Current, PLUGIN_TYPE_RSP); + + AddModCheckBox(GetDlgItem(IDC_HLE_GFX), Plugin_UseHleGfx); + AddModCheckBox(GetDlgItem(IDC_HLE_AUDIO), Plugin_UseHleAudio); - AddModCheckBox(GetDlgItem(IDC_HLE_GFX),Plugin_UseHleGfx); - AddModCheckBox(GetDlgItem(IDC_HLE_AUDIO),Plugin_UseHleAudio); - UpdatePageSettings(); } -void COptionPluginPage::AddPlugins (int ListId,SettingID Type, PLUGIN_TYPE PluginType ) +void COptionPluginPage::AddPlugins(int ListId, SettingID Type, PLUGIN_TYPE PluginType) { stdstr Default = g_Settings->LoadStringVal(Type); CModifiedComboBox * ComboBox; - ComboBox = AddModComboBox(GetDlgItem(ListId),Type); - for (int i = 0, n = m_PluginList.GetPluginCount(); i < n; i++ ) + ComboBox = AddModComboBox(GetDlgItem(ListId), Type); + for (int i = 0, n = m_PluginList.GetPluginCount(); i < n; i++) { const CPluginList::PLUGIN * Plugin = m_PluginList.GetPluginInfo(i); if (Plugin == NULL) @@ -67,7 +66,7 @@ void COptionPluginPage::AddPlugins (int ListId,SettingID Type, PLUGIN_TYPE Plugi { continue; } - if (_stricmp(Default.c_str(),Plugin->FileName.c_str()) == 0) + if (_stricmp(Default.c_str(), Plugin->FileName.c_str()) == 0) { ComboBox->SetDefault((WPARAM)Plugin); } @@ -75,10 +74,10 @@ void COptionPluginPage::AddPlugins (int ListId,SettingID Type, PLUGIN_TYPE Plugi } } -void COptionPluginPage::ShowAboutButton ( int id ) +void COptionPluginPage::ShowAboutButton(int id) { CModifiedComboBox * ComboBox = NULL; - for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter ++) + for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter++) { if ((int)(cb_iter->second->GetMenu()) != id) { @@ -92,11 +91,11 @@ void COptionPluginPage::ShowAboutButton ( int id ) return; } int index = ComboBox->GetCurSel(); - if (index == CB_ERR) + if (index == CB_ERR) { - return; + return; } - + const CPluginList::PLUGIN ** PluginPtr = (const CPluginList::PLUGIN **)ComboBox->GetItemDataPtr(index); if (PluginPtr == NULL) { @@ -108,30 +107,30 @@ void COptionPluginPage::ShowAboutButton ( int id ) { return; } - + //Load the plugin - UINT LastErrorMode = SetErrorMode( SEM_FAILCRITICALERRORS ); - HMODULE hLib = LoadLibrary(Plugin->FullPath); + UINT LastErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS); + HMODULE hLib = LoadLibrary(Plugin->FullPath); SetErrorMode(LastErrorMode); if (hLib == NULL) { return; } - + //Get DLL about - void (__cdecl *DllAbout) ( HWND hWnd ); - DllAbout = (void (__cdecl *)(HWND))GetProcAddress( hLib, "DllAbout" ); - + void(__cdecl *DllAbout) (HWND hWnd); + DllAbout = (void(__cdecl *)(HWND))GetProcAddress(hLib, "DllAbout"); + //call the function from the dll DllAbout(m_hWnd); FreeLibrary(hLib); } -void COptionPluginPage::PluginItemChanged ( int id, int AboutID, bool bSetChanged ) +void COptionPluginPage::PluginItemChanged(int id, int AboutID, bool bSetChanged) { CModifiedComboBox * ComboBox = NULL; - for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter ++) + for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter++) { if ((int)(cb_iter->second->GetMenu()) != id) { @@ -146,9 +145,9 @@ void COptionPluginPage::PluginItemChanged ( int id, int AboutID, bool bSetChange } int index = ComboBox->GetCurSel(); - if (index == CB_ERR) + if (index == CB_ERR) { - return; + return; } const CPluginList::PLUGIN ** PluginPtr = (const CPluginList::PLUGIN **)ComboBox->GetItemDataPtr(index); if (PluginPtr) @@ -156,27 +155,27 @@ void COptionPluginPage::PluginItemChanged ( int id, int AboutID, bool bSetChange const CPluginList::PLUGIN * Plugin = *PluginPtr; if (Plugin) { - ::EnableWindow(GetDlgItem(AboutID),Plugin->AboutFunction); + ::EnableWindow(GetDlgItem(AboutID), Plugin->AboutFunction); } } if (bSetChanged) { ComboBox->SetChanged(true); - SendMessage(GetParent(),PSM_CHANGED,(WPARAM)m_hWnd,0); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } } -void COptionPluginPage::UpdatePageSettings ( void ) +void COptionPluginPage::UpdatePageSettings(void) { UpdateCheckBoxes(); - for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter ++) + for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter++) { CModifiedComboBox * ComboBox = cb_iter->second; stdstr SelectedValue; - - ComboBox->SetChanged(g_Settings->LoadStringVal(cb_iter->first,SelectedValue)); - for (int i = 0, n = ComboBox->GetCount(); i < n; i++ ) + + ComboBox->SetChanged(g_Settings->LoadStringVal(cb_iter->first, SelectedValue)); + for (int i = 0, n = ComboBox->GetCount(); i < n; i++) { const CPluginList::PLUGIN ** PluginPtr = (const CPluginList::PLUGIN **)ComboBox->GetItemDataPtr(i); if (PluginPtr == NULL) @@ -188,17 +187,17 @@ void COptionPluginPage::UpdatePageSettings ( void ) { continue; } - if (_stricmp(SelectedValue.c_str(),Plugin->FileName.c_str()) != 0) + if (_stricmp(SelectedValue.c_str(), Plugin->FileName.c_str()) != 0) { continue; } ComboBox->SetDefault((WPARAM)Plugin); } } - PluginItemChanged(GFX_LIST,GFX_ABOUT,false); - PluginItemChanged(AUDIO_LIST,AUDIO_ABOUT,false); - PluginItemChanged(CONT_LIST,CONT_ABOUT,false); - PluginItemChanged(RSP_LIST,RSP_ABOUT,false); + PluginItemChanged(GFX_LIST, GFX_ABOUT, false); + PluginItemChanged(AUDIO_LIST, AUDIO_ABOUT, false); + PluginItemChanged(CONT_LIST, CONT_ABOUT, false); + PluginItemChanged(RSP_LIST, RSP_ABOUT, false); } void COptionPluginPage::HidePage() @@ -211,12 +210,12 @@ void COptionPluginPage::ShowPage() ShowWindow(SW_SHOW); } -void COptionPluginPage::ApplySettings( bool UpdateScreen ) +void COptionPluginPage::ApplySettings(bool UpdateScreen) { CSettingsPageImpl::ApplySettings(UpdateScreen); } -bool COptionPluginPage::EnableReset ( void ) +bool COptionPluginPage::EnableReset(void) { if (CSettingsPageImpl::EnableReset()) { return true; } return false; @@ -227,17 +226,17 @@ void COptionPluginPage::ResetPage() CSettingsPageImpl::ResetPage(); } -void COptionPluginPage::ApplyComboBoxes ( void ) +void COptionPluginPage::ApplyComboBoxes(void) { - for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter ++) + for (ComboBoxList::iterator cb_iter = m_ComboBoxList.begin(); cb_iter != m_ComboBoxList.end(); cb_iter++) { CModifiedComboBox * ComboBox = cb_iter->second; if (ComboBox->IsChanged()) { int index = ComboBox->GetCurSel(); - if (index == CB_ERR) + if (index == CB_ERR) { - return; + return; } const CPluginList::PLUGIN ** PluginPtr = (const CPluginList::PLUGIN **)ComboBox->GetItemDataPtr(index); @@ -248,7 +247,7 @@ void COptionPluginPage::ApplyComboBoxes ( void ) const CPluginList::PLUGIN * Plugin = *PluginPtr; - g_Settings->SaveString(cb_iter->first,Plugin->FileName.c_str()); + g_Settings->SaveString(cb_iter->first, Plugin->FileName.c_str()); } if (ComboBox->IsReset()) { @@ -258,7 +257,7 @@ void COptionPluginPage::ApplyComboBoxes ( void ) } } -bool COptionPluginPage::ResetComboBox ( CModifiedComboBox & ComboBox, SettingID Type ) +bool COptionPluginPage::ResetComboBox(CModifiedComboBox & ComboBox, SettingID Type) { if (!ComboBox.IsChanged()) { @@ -286,18 +285,18 @@ bool COptionPluginPage::ResetComboBox ( CModifiedComboBox & ComboBox, SettingID return false; } -void COptionPluginPage::HleGfxChanged ( UINT /*Code*/, int id, HWND /*ctl*/ ) +void COptionPluginPage::HleGfxChanged(UINT /*Code*/, int id, HWND /*ctl*/) { - for (ButtonList::iterator iter = m_ButtonList.begin(); iter != m_ButtonList.end(); iter ++) + for (ButtonList::iterator iter = m_ButtonList.begin(); iter != m_ButtonList.end(); iter++) { CModifiedButton * Button = iter->second; if ((int)Button->GetMenu() != id) { continue; - } + } if ((Button->GetCheck() & BST_CHECKED) == 0) { - int res = MessageBoxW(m_hWnd, GS(MSG_SET_LLE_GFX_MSG),GS(MSG_SET_LLE_GFX_TITLE),MB_YESNO|MB_ICONWARNING); + int res = MessageBoxW(m_hWnd, GS(MSG_SET_LLE_GFX_MSG), GS(MSG_SET_LLE_GFX_TITLE), MB_YESNO | MB_ICONWARNING); if (res != IDYES) { Button->SetCheck(BST_CHECKED); @@ -305,23 +304,23 @@ void COptionPluginPage::HleGfxChanged ( UINT /*Code*/, int id, HWND /*ctl*/ ) } } Button->SetChanged(true); - SendMessage(GetParent(),PSM_CHANGED,(WPARAM)m_hWnd,0); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); break; } } -void COptionPluginPage::HleAudioChanged ( UINT /*Code*/, int id, HWND /*ctl*/ ) +void COptionPluginPage::HleAudioChanged(UINT /*Code*/, int id, HWND /*ctl*/) { - for (ButtonList::iterator iter = m_ButtonList.begin(); iter != m_ButtonList.end(); iter ++) + for (ButtonList::iterator iter = m_ButtonList.begin(); iter != m_ButtonList.end(); iter++) { CModifiedButton * Button = iter->second; if ((int)Button->GetMenu() != id) { continue; - } + } if ((Button->GetCheck() & BST_CHECKED) != 0) { - int res = MessageBoxW(m_hWnd, GS(MSG_SET_HLE_AUD_MSG),GS(MSG_SET_HLE_AUD_TITLE),MB_ICONWARNING|MB_YESNO); + int res = MessageBoxW(m_hWnd, GS(MSG_SET_HLE_AUD_MSG), GS(MSG_SET_HLE_AUD_TITLE), MB_ICONWARNING | MB_YESNO); if (res != IDYES) { Button->SetCheck(BST_UNCHECKED); @@ -329,8 +328,7 @@ void COptionPluginPage::HleAudioChanged ( UINT /*Code*/, int id, HWND /*ctl*/ ) } } Button->SetChanged(true); - SendMessage(GetParent(),PSM_CHANGED,(WPARAM)m_hWnd,0); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); break; } } -#endif diff --git a/Source/Project64/User Interface/Settings/Settings Page - Plugin.h b/Source/Project64/User Interface/Settings/Settings Page - Plugin.h index a6bbffffc..ec6b04eec 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Plugin.h +++ b/Source/Project64/User Interface/Settings/Settings Page - Plugin.h @@ -17,51 +17,51 @@ class COptionPluginPage : public CSettingsPage { BEGIN_MSG_MAP_EX(COptionPluginPage) - COMMAND_HANDLER_EX(GFX_LIST,LBN_SELCHANGE,GfxPluginChanged) - COMMAND_HANDLER_EX(AUDIO_LIST,LBN_SELCHANGE,AudioPluginChanged) - COMMAND_HANDLER_EX(CONT_LIST,LBN_SELCHANGE,ControllerPluginChanged) - COMMAND_HANDLER_EX(RSP_LIST,LBN_SELCHANGE,RspPluginChanged) - COMMAND_ID_HANDLER_EX(GFX_ABOUT,GfxPluginAbout) - COMMAND_ID_HANDLER_EX(AUDIO_ABOUT,AudioPluginAbout) - COMMAND_ID_HANDLER_EX(CONT_ABOUT,ControllerPluginAbout) - COMMAND_ID_HANDLER_EX(RSP_ABOUT,RspPluginAbout) - COMMAND_ID_HANDLER_EX(IDC_HLE_GFX,HleGfxChanged) - COMMAND_ID_HANDLER_EX(IDC_HLE_AUDIO,HleAudioChanged) - END_MSG_MAP() + COMMAND_HANDLER_EX(GFX_LIST, LBN_SELCHANGE, GfxPluginChanged) + COMMAND_HANDLER_EX(AUDIO_LIST, LBN_SELCHANGE, AudioPluginChanged) + COMMAND_HANDLER_EX(CONT_LIST, LBN_SELCHANGE, ControllerPluginChanged) + COMMAND_HANDLER_EX(RSP_LIST, LBN_SELCHANGE, RspPluginChanged) + COMMAND_ID_HANDLER_EX(GFX_ABOUT, GfxPluginAbout) + COMMAND_ID_HANDLER_EX(AUDIO_ABOUT, AudioPluginAbout) + COMMAND_ID_HANDLER_EX(CONT_ABOUT, ControllerPluginAbout) + COMMAND_ID_HANDLER_EX(RSP_ABOUT, RspPluginAbout) + COMMAND_ID_HANDLER_EX(IDC_HLE_GFX, HleGfxChanged) + COMMAND_ID_HANDLER_EX(IDC_HLE_AUDIO, HleAudioChanged) + END_MSG_MAP() - enum { IDD = IDD_Settings_PlugSel }; + enum { IDD = IDD_Settings_PlugSel }; public: - COptionPluginPage(HWND hParent, const RECT & rcDispay ); + COptionPluginPage(HWND hParent, const RECT & rcDispay); - LanguageStringID PageTitle ( void ) { return TAB_PLUGIN; } - void HidePage ( void ); - void ShowPage ( void ); - void ApplySettings ( bool UpdateScreen ); - bool EnableReset ( void ); - void ResetPage ( void ); + LanguageStringID PageTitle(void) { return TAB_PLUGIN; } + void HidePage(void); + void ShowPage(void); + void ApplySettings(bool UpdateScreen); + bool EnableReset(void); + void ResetPage(void); private: - void GfxPluginAbout ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) { ShowAboutButton(GFX_LIST); } - void AudioPluginAbout ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) { ShowAboutButton(AUDIO_LIST); } - void ControllerPluginAbout ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) { ShowAboutButton(CONT_LIST); } - void RspPluginAbout ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) { ShowAboutButton(RSP_LIST); } + void GfxPluginAbout(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { ShowAboutButton(GFX_LIST); } + void AudioPluginAbout(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { ShowAboutButton(AUDIO_LIST); } + void ControllerPluginAbout(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { ShowAboutButton(CONT_LIST); } + void RspPluginAbout(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { ShowAboutButton(RSP_LIST); } - void GfxPluginChanged ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) { PluginItemChanged(GFX_LIST,GFX_ABOUT); } - void AudioPluginChanged ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) { PluginItemChanged(AUDIO_LIST,AUDIO_ABOUT); } - void ControllerPluginChanged ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) { PluginItemChanged(CONT_LIST,CONT_ABOUT); } - void RspPluginChanged ( UINT /*Code*/, int /*id*/, HWND /*ctl*/ ) { PluginItemChanged(RSP_LIST,RSP_ABOUT); } + void GfxPluginChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { PluginItemChanged(GFX_LIST, GFX_ABOUT); } + void AudioPluginChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { PluginItemChanged(AUDIO_LIST, AUDIO_ABOUT); } + void ControllerPluginChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { PluginItemChanged(CONT_LIST, CONT_ABOUT); } + void RspPluginChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { PluginItemChanged(RSP_LIST, RSP_ABOUT); } - void HleGfxChanged ( UINT Code, int id, HWND ctl ); - void HleAudioChanged ( UINT Code, int id, HWND ctl ); + void HleGfxChanged(UINT Code, int id, HWND ctl); + void HleAudioChanged(UINT Code, int id, HWND ctl); - void ShowAboutButton ( int id ); - void PluginItemChanged ( int id, int AboutID, bool bSetChanged = true ); + void ShowAboutButton(int id); + void PluginItemChanged(int id, int AboutID, bool bSetChanged = true); - void AddPlugins (int ListId,SettingID Type, PLUGIN_TYPE PluginType ); - void UpdatePageSettings ( void ); - void ApplyComboBoxes ( void ); - bool ResetComboBox ( CModifiedComboBox & ComboBox, SettingID Type ); + void AddPlugins(int ListId, SettingID Type, PLUGIN_TYPE PluginType); + void UpdatePageSettings(void); + void ApplyComboBoxes(void); + bool ResetComboBox(CModifiedComboBox & ComboBox, SettingID Type); CPartialGroupBox m_GfxGroup, m_AudioGroup, m_ControlGroup, m_RspGroup; CPluginList m_PluginList; diff --git a/Source/Project64/User Interface/Settings/Settings Page.cpp b/Source/Project64/User Interface/Settings/Settings Page.cpp index f7b26d581..5f9e20bd4 100644 --- a/Source/Project64/User Interface/Settings/Settings Page.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page.cpp @@ -10,15 +10,14 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI #include "Settings Page.h" -CConfigSettingSection::CConfigSettingSection( LPCWSTR PageTitle ) : - m_PageTitle(PageTitle) +CConfigSettingSection::CConfigSettingSection(LPCWSTR PageTitle) : +m_PageTitle(PageTitle) { } -CConfigSettingSection::~CConfigSettingSection () +CConfigSettingSection::~CConfigSettingSection() { for (size_t i = 0; i < m_Pages.size(); i++) { @@ -28,12 +27,12 @@ CConfigSettingSection::~CConfigSettingSection () m_Pages.clear(); } -void CConfigSettingSection::AddPage(CSettingsPage * Page ) +void CConfigSettingSection::AddPage(CSettingsPage * Page) { m_Pages.push_back(Page); } -CSettingsPage * CConfigSettingSection::GetPage ( int PageNo ) +CSettingsPage * CConfigSettingSection::GetPage(int PageNo) { if (PageNo < 0 || PageNo >= (int)m_Pages.size()) { @@ -41,4 +40,3 @@ CSettingsPage * CConfigSettingSection::GetPage ( int PageNo ) } return m_Pages[PageNo]; } -#endif diff --git a/Source/Project64/User Interface/WTL Controls/ModifiedEditBox.cpp b/Source/Project64/User Interface/WTL Controls/ModifiedEditBox.cpp index 826655802..d64ba3449 100644 --- a/Source/Project64/User Interface/WTL Controls/ModifiedEditBox.cpp +++ b/Source/Project64/User Interface/WTL Controls/ModifiedEditBox.cpp @@ -10,16 +10,15 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI CModifiedEditBox::CModifiedEditBox(bool bString /* = true */, HWND hWnd /* = NULL */) : - CEdit(hWnd), - m_Changed(false), - m_Reset(false), - m_BoldFont(NULL), - m_OriginalFont(NULL), - m_TextField(NULL), - m_bString(bString) -{ +CEdit(hWnd), +m_Changed(false), +m_Reset(false), +m_BoldFont(NULL), +m_OriginalFont(NULL), +m_TextField(NULL), +m_bString(bString) +{ } CModifiedEditBox::~CModifiedEditBox() @@ -30,7 +29,7 @@ CModifiedEditBox::~CModifiedEditBox() } } -void CModifiedEditBox::SetReset ( bool Reset ) +void CModifiedEditBox::SetReset(bool Reset) { m_Reset = Reset; if (m_Reset) @@ -39,7 +38,7 @@ void CModifiedEditBox::SetReset ( bool Reset ) } } -void CModifiedEditBox::SetChanged (bool Changed) +void CModifiedEditBox::SetChanged(bool Changed) { m_Changed = Changed; if (m_Changed) @@ -47,61 +46,61 @@ void CModifiedEditBox::SetChanged (bool Changed) SetReset(false); if (m_BoldFont == NULL) { - m_OriginalFont = (HFONT)SendMessage(WM_GETFONT); + m_OriginalFont = (HFONT)SendMessage(WM_GETFONT); LOGFONT lfSystemVariableFont; - GetObject ( m_OriginalFont, sizeof(LOGFONT), &lfSystemVariableFont ); + GetObject(m_OriginalFont, sizeof(LOGFONT), &lfSystemVariableFont); lfSystemVariableFont.lfWeight = FW_BOLD; - m_BoldFont = CreateFontIndirect ( &lfSystemVariableFont ); + m_BoldFont = CreateFontIndirect(&lfSystemVariableFont); } - SendMessage(WM_SETFONT,(WPARAM)m_BoldFont); + SendMessage(WM_SETFONT, (WPARAM)m_BoldFont); InvalidateRect(NULL); if (m_TextField) { - ::SendMessage(m_TextField,WM_SETFONT,(WPARAM)m_BoldFont,0); + ::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_BoldFont, 0); ::InvalidateRect(m_TextField, NULL, true); - } - } else { + } + else + { if (m_OriginalFont) { - SendMessage(WM_SETFONT,(WPARAM)m_OriginalFont); + SendMessage(WM_SETFONT, (WPARAM)m_OriginalFont); InvalidateRect(NULL); if (m_TextField) { - ::SendMessage(m_TextField,WM_SETFONT,(WPARAM)m_OriginalFont,0); + ::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_OriginalFont, 0); ::InvalidateRect(m_TextField, NULL, true); } } } } -stdstr CModifiedEditBox::GetWindowText( void ) +stdstr CModifiedEditBox::GetWindowText(void) { stdstr Result; ATLASSERT(::IsWindow(m_hWnd)); int nLen = ::GetWindowTextLength(m_hWnd); - if(nLen == 0) + if (nLen == 0) { return Result; } - Result.resize(nLen+1); - ::GetWindowText(m_hWnd,(char *)Result.c_str(),nLen+1); + Result.resize(nLen + 1); + ::GetWindowText(m_hWnd, (char *)Result.c_str(), nLen + 1); return Result; } -void CModifiedEditBox::SetTextField (HWND hWnd) +void CModifiedEditBox::SetTextField(HWND hWnd) { if (m_TextField && m_OriginalFont) { - ::SendMessage(m_TextField,WM_SETFONT,(WPARAM)m_OriginalFont,0); + ::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_OriginalFont, 0); } m_TextField = hWnd; if (m_Changed && m_BoldFont) { - ::SendMessage(m_TextField,WM_SETFONT,(WPARAM)m_BoldFont,0); + ::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_BoldFont, 0); } } -#endif diff --git a/Source/Project64/User Interface/WTL Controls/PartialGroupBox.cpp b/Source/Project64/User Interface/WTL Controls/PartialGroupBox.cpp index b50b99619..38573ba3c 100644 --- a/Source/Project64/User Interface/WTL Controls/PartialGroupBox.cpp +++ b/Source/Project64/User Interface/WTL Controls/PartialGroupBox.cpp @@ -10,7 +10,6 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI BOOL CPartialGroupBox::Attach(HWND hWnd) { ATLASSUME(m_hWnd == NULL); @@ -34,7 +33,7 @@ BOOL CPartialGroupBox::Attach(HWND hWnd) BOOL CPartialGroupBox::AttachToDlgItem(HWND parent, UINT dlgID) { - return Attach(::GetDlgItem(parent,dlgID)); + return Attach(::GetDlgItem(parent, dlgID)); } void CPartialGroupBox::Draw3dLine(CPaintDC & dc, LPCRECT lpRect, COLORREF clrTopLeft, COLORREF /*clrBottomRight*/) @@ -68,39 +67,39 @@ void CPartialGroupBox::OnPaint(HDC /*hDC*/) wchar_t grptext[500]; GetWindowTextW(m_hWnd, grptext, sizeof(grptext) / sizeof(grptext[0])); - CRect fontsizerect(0,0,0,0); + CRect fontsizerect(0, 0, 0, 0); dc.DrawTextW(grptext, -1, fontsizerect, DT_SINGLELINE | DT_LEFT | DT_CALCRECT); CRect framerect(controlrect); - framerect.top += (fontsizerect.Height())/2; - long Style = GetStyle(); + framerect.top += (fontsizerect.Height()) / 2; + long Style = GetStyle(); - if((Style & 0xF000) == BS_FLAT) + if ((Style & 0xF000) == BS_FLAT) { - dc.Draw3dRect(framerect,RGB(0,0,0),RGB(0,0,0)); - framerect.DeflateRect(1,1); - dc.Draw3dRect(framerect,RGB(255,255,255),RGB(255,255,255)); + dc.Draw3dRect(framerect, RGB(0, 0, 0), RGB(0, 0, 0)); + framerect.DeflateRect(1, 1); + dc.Draw3dRect(framerect, RGB(255, 255, 255), RGB(255, 255, 255)); } else { - Draw3dLine(dc,framerect,GetSysColor(COLOR_3DSHADOW),GetSysColor(COLOR_3DHILIGHT)); - framerect.DeflateRect(1,1); - Draw3dLine(dc,framerect,GetSysColor(COLOR_3DHILIGHT),GetSysColor(COLOR_3DSHADOW)); + Draw3dLine(dc, framerect, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT)); + framerect.DeflateRect(1, 1); + Draw3dLine(dc, framerect, GetSysColor(COLOR_3DHILIGHT), GetSysColor(COLOR_3DSHADOW)); } if (wcslen(grptext)) { CRect fontrect(controlrect); - fontrect.bottom = controlrect.top+fontsizerect.Height(); + fontrect.bottom = controlrect.top + fontsizerect.Height(); - if((Style & 0xF00) == BS_RIGHT) + if ((Style & 0xF00) == BS_RIGHT) { fontrect.right -= 6; fontrect.left = fontrect.right - fontsizerect.Width(); } - else if((Style & 0xF00) == BS_CENTER) + else if ((Style & 0xF00) == BS_CENTER) { - fontrect.left += (controlrect.Width()-fontsizerect.Width())/2; + fontrect.left += (controlrect.Width() - fontsizerect.Width()) / 2; fontrect.right = fontrect.left + fontsizerect.Width(); } else //BS_LEFT or default @@ -109,15 +108,14 @@ void CPartialGroupBox::OnPaint(HDC /*hDC*/) fontrect.right = fontrect.left + fontsizerect.Width(); } - fontrect.InflateRect(2,0); - dc.FillRect(fontrect,GetSysColor(COLOR_BTNFACE)); - fontrect.DeflateRect(2,0); + fontrect.InflateRect(2, 0); + dc.FillRect(fontrect, GetSysColor(COLOR_BTNFACE)); + fontrect.DeflateRect(2, 0); //Draw Caption dc.SetBkMode(OPAQUE); dc.SetBkColor(GetSysColor(COLOR_BTNFACE)); - dc.DrawTextW(grptext,-1,fontrect,DT_SINGLELINE|DT_LEFT); + dc.DrawTextW(grptext, -1, fontrect, DT_SINGLELINE | DT_LEFT); } } -#endif From 6a2e88a25cce1c7aedef22882eca9895ebf24fd8 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sat, 7 Nov 2015 12:45:59 +1100 Subject: [PATCH 081/213] [Project64] change AsciiToHex to std::strtoul in rom browser --- .../User Interface/Rom Browser Class.cpp | 1286 ++++++++--------- Source/Project64/User Interface/Rom Browser.h | 159 +- 2 files changed, 697 insertions(+), 748 deletions(-) diff --git a/Source/Project64/User Interface/Rom Browser Class.cpp b/Source/Project64/User Interface/Rom Browser Class.cpp index 82d810f22..7992d092a 100644 --- a/Source/Project64/User Interface/Rom Browser Class.cpp +++ b/Source/Project64/User Interface/Rom Browser Class.cpp @@ -3,36 +3,36 @@ #include #include -CRomBrowser::CRomBrowser (HWND & MainWindow, HWND & StatusWindow ) : - m_MainWindow(MainWindow), - m_StatusWindow(StatusWindow), - m_ShowingRomBrowser(false), - m_RefreshThread(NULL), - m_RomIniFile(NULL), - m_NotesIniFile(NULL), - m_ExtIniFile(NULL), - m_ZipIniFile(NULL), - m_AllowSelectionLastRom(true), - m_WatchThreadID(0) +CRomBrowser::CRomBrowser(HWND & MainWindow, HWND & StatusWindow) : +m_MainWindow(MainWindow), +m_StatusWindow(StatusWindow), +m_ShowingRomBrowser(false), +m_RefreshThread(NULL), +m_RomIniFile(NULL), +m_NotesIniFile(NULL), +m_ExtIniFile(NULL), +m_ZipIniFile(NULL), +m_AllowSelectionLastRom(true), +m_WatchThreadID(0) { - if (g_Settings) + if (g_Settings) { m_RomIniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str()); m_NotesIniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_Notes).c_str()); m_ExtIniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_ExtInfo).c_str()); m_ZipIniFile = new CIniFile(g_Settings->LoadStringVal(SupportFile_7zipCache).c_str()); } - + m_hRomList = 0; - m_Visible = false; + m_Visible = false; m_WatchThread = NULL; - m_WatchStopEvent = NULL; + m_WatchStopEvent = NULL; GetFieldInfo(m_Fields); - m_FieldType.resize(m_Fields.size()); + m_FieldType.resize(m_Fields.size()); } -CRomBrowser::~CRomBrowser (void) +CRomBrowser::~CRomBrowser(void) { m_StopRefresh = true; WatchThreadStop(); @@ -60,54 +60,54 @@ CRomBrowser::~CRomBrowser (void) } } -void CRomBrowser::AddField (ROMBROWSER_FIELDS_LIST & Fields, LPCSTR Name, int Pos,int ID,int Width,LanguageStringID LangID, bool UseDefault) +void CRomBrowser::AddField(ROMBROWSER_FIELDS_LIST & Fields, LPCSTR Name, int Pos, int ID, int Width, LanguageStringID LangID, bool UseDefault) { - Fields.push_back(ROMBROWSER_FIELDS(Name,Pos,ID,Width,LangID,UseDefault)); + Fields.push_back(ROMBROWSER_FIELDS(Name, Pos, ID, Width, LangID, UseDefault)); } -void CRomBrowser::GetFieldInfo ( ROMBROWSER_FIELDS_LIST & Fields, bool UseDefault /* = false */) -{ +void CRomBrowser::GetFieldInfo(ROMBROWSER_FIELDS_LIST & Fields, bool UseDefault /* = false */) +{ Fields.clear(); - - AddField(Fields,"File Name", -1, RB_FileName, 218,RB_FILENAME, UseDefault); - AddField(Fields,"Internal Name", -1, RB_InternalName, 200,RB_INTERNALNAME, UseDefault); - AddField(Fields,"Good Name", 0, RB_GoodName, 218,RB_GOODNAME, UseDefault); - AddField(Fields,"Status", 1, RB_Status, 92, RB_STATUS, UseDefault); - AddField(Fields,"Rom Size", -1, RB_RomSize, 100,RB_ROMSIZE, UseDefault); - AddField(Fields,"Notes (Core)", 2, RB_CoreNotes, 120,RB_NOTES_CORE, UseDefault); - AddField(Fields,"Notes (default plugins)", 3, RB_PluginNotes, 188,RB_NOTES_PLUGIN, UseDefault); - AddField(Fields,"Notes (User)", -1, RB_UserNotes, 100,RB_NOTES_USER, UseDefault); - AddField(Fields,"Cartridge ID", -1, RB_CartridgeID, 100,RB_CART_ID, UseDefault); - AddField(Fields,"Manufacturer", -1, RB_Manufacturer, 100,RB_MANUFACTUER, UseDefault); - AddField(Fields,"Country", -1, RB_Country, 100,RB_COUNTRY, UseDefault); - AddField(Fields,"Developer", -1, RB_Developer, 100,RB_DEVELOPER, UseDefault); - AddField(Fields,"CRC1", -1, RB_Crc1, 100,RB_CRC1, UseDefault); - AddField(Fields,"CRC2", -1, RB_Crc2, 100,RB_CRC2, UseDefault); - AddField(Fields,"CIC Chip", -1, RB_CICChip, 100,RB_CICCHIP, UseDefault); - AddField(Fields,"Release Date", -1, RB_ReleaseDate, 100,RB_RELEASE_DATE, UseDefault); - AddField(Fields,"Genre", -1, RB_Genre, 100,RB_GENRE, UseDefault); - AddField(Fields,"Players", -1, RB_Players, 100,RB_PLAYERS, UseDefault); - AddField(Fields,"Force Feedback", -1, RB_ForceFeedback, 100,RB_FORCE_FEEDBACK, UseDefault); - AddField(Fields,"File Format", -1, RB_FileFormat, 100,RB_FILE_FORMAT, UseDefault); + + AddField(Fields, "File Name", -1, RB_FileName, 218, RB_FILENAME, UseDefault); + AddField(Fields, "Internal Name", -1, RB_InternalName, 200, RB_INTERNALNAME, UseDefault); + AddField(Fields, "Good Name", 0, RB_GoodName, 218, RB_GOODNAME, UseDefault); + AddField(Fields, "Status", 1, RB_Status, 92, RB_STATUS, UseDefault); + AddField(Fields, "Rom Size", -1, RB_RomSize, 100, RB_ROMSIZE, UseDefault); + AddField(Fields, "Notes (Core)", 2, RB_CoreNotes, 120, RB_NOTES_CORE, UseDefault); + AddField(Fields, "Notes (default plugins)", 3, RB_PluginNotes, 188, RB_NOTES_PLUGIN, UseDefault); + AddField(Fields, "Notes (User)", -1, RB_UserNotes, 100, RB_NOTES_USER, UseDefault); + AddField(Fields, "Cartridge ID", -1, RB_CartridgeID, 100, RB_CART_ID, UseDefault); + AddField(Fields, "Manufacturer", -1, RB_Manufacturer, 100, RB_MANUFACTUER, UseDefault); + AddField(Fields, "Country", -1, RB_Country, 100, RB_COUNTRY, UseDefault); + AddField(Fields, "Developer", -1, RB_Developer, 100, RB_DEVELOPER, UseDefault); + AddField(Fields, "CRC1", -1, RB_Crc1, 100, RB_CRC1, UseDefault); + AddField(Fields, "CRC2", -1, RB_Crc2, 100, RB_CRC2, UseDefault); + AddField(Fields, "CIC Chip", -1, RB_CICChip, 100, RB_CICCHIP, UseDefault); + AddField(Fields, "Release Date", -1, RB_ReleaseDate, 100, RB_RELEASE_DATE, UseDefault); + AddField(Fields, "Genre", -1, RB_Genre, 100, RB_GENRE, UseDefault); + AddField(Fields, "Players", -1, RB_Players, 100, RB_PLAYERS, UseDefault); + AddField(Fields, "Force Feedback", -1, RB_ForceFeedback, 100, RB_FORCE_FEEDBACK, UseDefault); + AddField(Fields, "File Format", -1, RB_FileFormat, 100, RB_FILE_FORMAT, UseDefault); } -int CRomBrowser::CalcSortPosition (DWORD lParam) +int CRomBrowser::CalcSortPosition(DWORD lParam) { int Start = 0; - int End = ListView_GetItemCount((HWND)m_hRomList) - 1; + int End = ListView_GetItemCount((HWND)m_hRomList) - 1; if (End < 0) { return 0; } - for (int SortIndex = NoOfSortKeys; SortIndex >= 0; SortIndex --) + for (int SortIndex = NoOfSortKeys; SortIndex >= 0; SortIndex--) { - stdstr SortFieldName = g_Settings->LoadStringIndex(RomBrowser_SortFieldIndex,SortIndex); + stdstr SortFieldName = g_Settings->LoadStringIndex(RomBrowser_SortFieldIndex, SortIndex); if (SortFieldName.length() == 0) { continue; } - + if (End == Start) { break; @@ -116,13 +116,13 @@ int CRomBrowser::CalcSortPosition (DWORD lParam) size_t index; for (index = 0; index < m_Fields.size(); index++) { - if (_stricmp(m_Fields[index].Name(),SortFieldName.c_str()) == 0) { break; } + if (_stricmp(m_Fields[index].Name(), SortFieldName.c_str()) == 0) { break; } } if (index >= m_Fields.size()) { continue; } SORT_FIELD SortFieldInfo; - SortFieldInfo._this = this; - SortFieldInfo.Key = index; - SortFieldInfo.KeyAscend = g_Settings->LoadBoolIndex(RomBrowser_SortAscendingIndex,SortIndex); + SortFieldInfo._this = this; + SortFieldInfo.Key = index; + SortFieldInfo.KeyAscend = g_Settings->LoadBoolIndex(RomBrowser_SortAscendingIndex, SortIndex); //calc new start and end int LastTestPos = -1; @@ -139,12 +139,12 @@ int CRomBrowser::CalcSortPosition (DWORD lParam) memset(&lvItem, 0, sizeof(LV_ITEM)); lvItem.mask = LVIF_PARAM; lvItem.iItem = TestPos; - if (!ListView_GetItem((HWND)m_hRomList, &lvItem)) - { + if (!ListView_GetItem((HWND)m_hRomList, &lvItem)) + { return End; } - int Result = RomList_CompareItems(lParam,lvItem.lParam,(DWORD)&SortFieldInfo); + int Result = RomList_CompareItems(lParam, lvItem.lParam, (DWORD)&SortFieldInfo); if (Result < 0) { if (End == TestPos) @@ -174,17 +174,17 @@ int CRomBrowser::CalcSortPosition (DWORD lParam) NewTestPos += 1; } LastTestPos = NewTestPos; - + LV_ITEM lvItem; memset(&lvItem, 0, sizeof(LV_ITEM)); lvItem.mask = LVIF_PARAM; lvItem.iItem = NewTestPos; - if (!ListView_GetItem((HWND)m_hRomList, &lvItem)) - { - return End; + if (!ListView_GetItem((HWND)m_hRomList, &lvItem)) + { + return End; } - int Result = RomList_CompareItems(lParam,lvItem.lParam,(DWORD)&SortFieldInfo); + int Result = RomList_CompareItems(lParam, lvItem.lParam, (DWORD)&SortFieldInfo); if (Result <= 0) { if (Right == NewTestPos) @@ -211,14 +211,14 @@ int CRomBrowser::CalcSortPosition (DWORD lParam) NewTestPos -= 1; } LastTestPos = NewTestPos; - + LV_ITEM lvItem; memset(&lvItem, 0, sizeof(LV_ITEM)); lvItem.mask = LVIF_PARAM; lvItem.iItem = NewTestPos; if (!ListView_GetItem((HWND)m_hRomList, &lvItem)) { return End; } - int Result = RomList_CompareItems(lParam,lvItem.lParam,(DWORD)&SortFieldInfo); + int Result = RomList_CompareItems(lParam, lvItem.lParam, (DWORD)&SortFieldInfo); if (Result >= 0) { if (Left == NewTestPos) @@ -231,36 +231,32 @@ int CRomBrowser::CalcSortPosition (DWORD lParam) { Right = (float)NewTestPos; } - } End = (int)Left; break; } - } - - } //Compare end with item to see if we should do it after or before it - for (int SortIndex = 0; SortIndex < NoOfSortKeys; SortIndex ++) + for (int SortIndex = 0; SortIndex < NoOfSortKeys; SortIndex++) { - stdstr SortFieldName = g_Settings->LoadStringIndex(RomBrowser_SortFieldIndex,SortIndex); + stdstr SortFieldName = g_Settings->LoadStringIndex(RomBrowser_SortFieldIndex, SortIndex); if (SortFieldName.length() == 0) { continue; } - + size_t index; - for (index = 0; index < m_Fields.size(); index++) + for (index = 0; index < m_Fields.size(); index++) { - if (_stricmp(m_Fields[index].Name(),SortFieldName.c_str()) == 0) { break; } + if (_stricmp(m_Fields[index].Name(), SortFieldName.c_str()) == 0) { break; } } if (index >= m_Fields.size()) { continue; } SORT_FIELD SortFieldInfo; - SortFieldInfo._this = this; - SortFieldInfo.Key = index; - SortFieldInfo.KeyAscend = g_Settings->LoadBoolIndex(RomBrowser_SortAscendingIndex,SortIndex) != 0; + SortFieldInfo._this = this; + SortFieldInfo.Key = index; + SortFieldInfo.KeyAscend = g_Settings->LoadBoolIndex(RomBrowser_SortAscendingIndex, SortIndex) != 0; LV_ITEM lvItem; memset(&lvItem, 0, sizeof(LV_ITEM)); @@ -268,7 +264,7 @@ int CRomBrowser::CalcSortPosition (DWORD lParam) lvItem.iItem = End; if (!ListView_GetItem((HWND)m_hRomList, &lvItem)) { return End; } - int Result = RomList_CompareItems(lParam, lvItem.lParam ,(DWORD)&SortFieldInfo); + int Result = RomList_CompareItems(lParam, lvItem.lParam, (DWORD)&SortFieldInfo); if (Result < 0) { return End; @@ -281,51 +277,51 @@ int CRomBrowser::CalcSortPosition (DWORD lParam) return End + 1; } -void CRomBrowser::AddRomToList (const char * RomLocation, const char * lpLastRom) +void CRomBrowser::AddRomToList(const char * RomLocation, const char * lpLastRom) { - ROM_INFO RomInfo; - - memset(&RomInfo, 0, sizeof(ROM_INFO)); + ROM_INFO RomInfo; + + memset(&RomInfo, 0, sizeof(ROM_INFO)); strncpy(RomInfo.szFullFileName, RomLocation, sizeof(RomInfo.szFullFileName) - 1); - if (!FillRomInfo(&RomInfo)) { return; } - AddRomInfoToList(RomInfo,lpLastRom); + if (!FillRomInfo(&RomInfo)) { return; } + AddRomInfoToList(RomInfo, lpLastRom); } -void CRomBrowser::AddRomInfoToList (ROM_INFO &RomInfo , const char * lpLastRom) -{ +void CRomBrowser::AddRomInfoToList(ROM_INFO &RomInfo, const char * lpLastRom) +{ int ListPos = m_RomInfo.size(); m_RomInfo.push_back(RomInfo); LV_ITEM lvItem; memset(&lvItem, 0, sizeof(lvItem)); - lvItem.mask = LVIF_TEXT | LVIF_PARAM; - lvItem.iItem = CalcSortPosition(ListPos); - lvItem.lParam = (LPARAM)ListPos; - lvItem.pszText = LPSTR_TEXTCALLBACK; - - int index = ListView_InsertItem((HWND)m_hRomList, &lvItem); - + lvItem.mask = LVIF_TEXT | LVIF_PARAM; + lvItem.iItem = CalcSortPosition(ListPos); + lvItem.lParam = (LPARAM)ListPos; + lvItem.pszText = LPSTR_TEXTCALLBACK; + + int index = ListView_InsertItem((HWND)m_hRomList, &lvItem); + int iItem = ListView_GetNextItem((HWND)m_hRomList, -1, LVNI_SELECTED); //if (iItem == -1) { return; } //if the last rom then highlight the item - if (iItem < 0 && _stricmp(RomInfo.szFullFileName,lpLastRom) == 0) + if (iItem < 0 && _stricmp(RomInfo.szFullFileName, lpLastRom) == 0) { - ListView_SetItemState((HWND)m_hRomList,index,LVIS_SELECTED | LVIS_FOCUSED,LVIS_SELECTED | LVIS_FOCUSED); + ListView_SetItemState((HWND)m_hRomList, index, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); } if (iItem >= 0) { - ListView_EnsureVisible((HWND)m_hRomList,iItem,FALSE); + ListView_EnsureVisible((HWND)m_hRomList, iItem, FALSE); } } -void CRomBrowser::AllocateBrushs (void) +void CRomBrowser::AllocateBrushs(void) { for (size_t count = 0; count < m_RomInfo.size(); count++) { - if (m_RomInfo[count].SelColor == -1) - { + if (m_RomInfo[count].SelColor == -1) + { m_RomInfo[count].SelColorBrush = (DWORD)((HBRUSH)(COLOR_HIGHLIGHT + 1)); } else @@ -335,66 +331,24 @@ void CRomBrowser::AllocateBrushs (void) } } -DWORD CRomBrowser::AsciiToHex (char * HexValue) +void CRomBrowser::CreateRomListControl(void) { - DWORD Count, Finish, Value = 0; - - Finish = strlen(HexValue); - if (Finish > 8 ) { Finish = 8; } - - for (Count = 0; Count < Finish; Count++) - { - Value = (Value << 4); - switch( HexValue[Count] ) { - case '0': break; - case '1': Value += 1; break; - case '2': Value += 2; break; - case '3': Value += 3; break; - case '4': Value += 4; break; - case '5': Value += 5; break; - case '6': Value += 6; break; - case '7': Value += 7; break; - case '8': Value += 8; break; - case '9': Value += 9; break; - case 'A': Value += 10; break; - case 'a': Value += 10; break; - case 'B': Value += 11; break; - case 'b': Value += 11; break; - case 'C': Value += 12; break; - case 'c': Value += 12; break; - case 'D': Value += 13; break; - case 'd': Value += 13; break; - case 'E': Value += 14; break; - case 'e': Value += 14; break; - case 'F': Value += 15; break; - case 'f': Value += 15; break; - default: - Value = (Value >> 4); - Count = Finish; - } - } - return Value; -} - - -void CRomBrowser::CreateRomListControl (void) -{ - m_hRomList = (HWND)CreateWindowEx( WS_EX_CLIENTEDGE,WC_LISTVIEW,NULL, - WS_TABSTOP | WS_VISIBLE | WS_CHILD | LVS_OWNERDRAWFIXED | - LVS_SINGLESEL | LVS_REPORT, - 0,0,0,0,m_MainWindow,(HMENU)IDC_ROMLIST,GetModuleHandle(NULL),NULL); + m_hRomList = (HWND)CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, NULL, + WS_TABSTOP | WS_VISIBLE | WS_CHILD | LVS_OWNERDRAWFIXED | + LVS_SINGLESEL | LVS_REPORT, + 0, 0, 0, 0, m_MainWindow, (HMENU)IDC_ROMLIST, GetModuleHandle(NULL), NULL); ResetRomBrowserColomuns(); LoadRomList(); } -void CRomBrowser::DeallocateBrushs (void) +void CRomBrowser::DeallocateBrushs(void) { - for (size_t count = 0; count < m_RomInfo.size(); count++) + for (size_t count = 0; count < m_RomInfo.size(); count++) { - if (m_RomInfo[count].SelColor == -1) - { + if (m_RomInfo[count].SelColor == -1) + { continue; - } + } if (m_RomInfo[count].SelColorBrush) { DeleteObject((HBRUSH)m_RomInfo[count].SelColorBrush); @@ -405,123 +359,123 @@ void CRomBrowser::DeallocateBrushs (void) void CRomBrowser::FillRomExtensionInfo(ROM_INFO * pRomInfo) { - //Initialize the structure - pRomInfo->UserNotes[0] = 0; - pRomInfo->Developer[0] = 0; + //Initialize the structure + pRomInfo->UserNotes[0] = 0; + pRomInfo->Developer[0] = 0; pRomInfo->ReleaseDate[0] = 0; - pRomInfo->Genre[0] = 0; - pRomInfo->Players = 1; - pRomInfo->CoreNotes[0] = 0; + pRomInfo->Genre[0] = 0; + pRomInfo->Players = 1; + pRomInfo->CoreNotes[0] = 0; pRomInfo->PluginNotes[0] = 0; - strcpy(pRomInfo->GoodName,"#340#"); - strcpy(pRomInfo->Status,"Unknown"); + strcpy(pRomInfo->GoodName, "#340#"); + strcpy(pRomInfo->Status, "Unknown"); //Get File Identifier char Identifier[100]; - sprintf(Identifier,"%08X-%08X-C:%X",pRomInfo->CRC1,pRomInfo->CRC2,pRomInfo->Country); + sprintf(Identifier, "%08X-%08X-C:%X", pRomInfo->CRC1, pRomInfo->CRC2, pRomInfo->Country); //Rom Notes - if (m_Fields[RB_UserNotes].Pos() >= 0) + if (m_Fields[RB_UserNotes].Pos() >= 0) { - m_NotesIniFile->GetString(Identifier,"Note","",pRomInfo->UserNotes,sizeof(pRomInfo->UserNotes)); + m_NotesIniFile->GetString(Identifier, "Note", "", pRomInfo->UserNotes, sizeof(pRomInfo->UserNotes)); } //Rom Extension info if (m_Fields[RB_Developer].Pos() >= 0) { - m_ExtIniFile->GetString(Identifier,"Developer","",pRomInfo->Developer,sizeof(pRomInfo->Developer)); + m_ExtIniFile->GetString(Identifier, "Developer", "", pRomInfo->Developer, sizeof(pRomInfo->Developer)); } - if (m_Fields[RB_ReleaseDate].Pos() >= 0) + if (m_Fields[RB_ReleaseDate].Pos() >= 0) { - m_ExtIniFile->GetString(Identifier,"ReleaseDate","",pRomInfo->ReleaseDate,sizeof(pRomInfo->ReleaseDate)); + m_ExtIniFile->GetString(Identifier, "ReleaseDate", "", pRomInfo->ReleaseDate, sizeof(pRomInfo->ReleaseDate)); } if (m_Fields[RB_Genre].Pos() >= 0) { - m_ExtIniFile->GetString(Identifier,"Genre","",pRomInfo->Genre,sizeof(pRomInfo->Genre)); + m_ExtIniFile->GetString(Identifier, "Genre", "", pRomInfo->Genre, sizeof(pRomInfo->Genre)); } - if (m_Fields[RB_Players].Pos() >= 0) - { - m_ExtIniFile->GetNumber(Identifier,"Players",1,(uint32_t &)pRomInfo->Players); + if (m_Fields[RB_Players].Pos() >= 0) + { + m_ExtIniFile->GetNumber(Identifier, "Players", 1, (uint32_t &)pRomInfo->Players); } if (m_Fields[RB_ForceFeedback].Pos() >= 0) { - m_ExtIniFile->GetString(Identifier,"ForceFeedback","unknown",pRomInfo->ForceFeedback,sizeof(pRomInfo->ForceFeedback)); + m_ExtIniFile->GetString(Identifier, "ForceFeedback", "unknown", pRomInfo->ForceFeedback, sizeof(pRomInfo->ForceFeedback)); } //Rom Settings - if (m_Fields[RB_GoodName].Pos() >= 0) + if (m_Fields[RB_GoodName].Pos() >= 0) { - m_RomIniFile->GetString(Identifier,"Good Name",pRomInfo->GoodName,pRomInfo->GoodName,sizeof(pRomInfo->GoodName)); + m_RomIniFile->GetString(Identifier, "Good Name", pRomInfo->GoodName, pRomInfo->GoodName, sizeof(pRomInfo->GoodName)); } - m_RomIniFile->GetString(Identifier,"Status",pRomInfo->Status,pRomInfo->Status,sizeof(pRomInfo->Status)); + m_RomIniFile->GetString(Identifier, "Status", pRomInfo->Status, pRomInfo->Status, sizeof(pRomInfo->Status)); if (m_Fields[RB_CoreNotes].Pos() >= 0) { - m_RomIniFile->GetString(Identifier,"Core Note","",pRomInfo->CoreNotes,sizeof(pRomInfo->CoreNotes)); + m_RomIniFile->GetString(Identifier, "Core Note", "", pRomInfo->CoreNotes, sizeof(pRomInfo->CoreNotes)); } - if (m_Fields[RB_PluginNotes].Pos() >= 0) + if (m_Fields[RB_PluginNotes].Pos() >= 0) { - m_RomIniFile->GetString(Identifier,"Plugin Note","",pRomInfo->PluginNotes,sizeof(pRomInfo->PluginNotes)); + m_RomIniFile->GetString(Identifier, "Plugin Note", "", pRomInfo->PluginNotes, sizeof(pRomInfo->PluginNotes)); } //Get the text color char String[100]; - m_RomIniFile->GetString("Rom Status",pRomInfo->Status,"000000",String,7); - pRomInfo->TextColor = (AsciiToHex(String) & 0xFFFFFF); + m_RomIniFile->GetString("Rom Status", pRomInfo->Status, "000000", String, 7); + pRomInfo->TextColor = (std::strtoul(String, 0, 16) & 0xFFFFFF); pRomInfo->TextColor = (pRomInfo->TextColor & 0x00FF00) | ((pRomInfo->TextColor >> 0x10) & 0xFF) | ((pRomInfo->TextColor & 0xFF) << 0x10); - + //Get the selected color - sprintf(String,"%s.Sel",pRomInfo->Status); - m_RomIniFile->GetString("Rom Status",String,"FFFFFFFF",String,9); - int selcol = AsciiToHex(String); + sprintf(String, "%s.Sel", pRomInfo->Status); + m_RomIniFile->GetString("Rom Status", String, "FFFFFFFF", String, 9); + int selcol = std::strtoul(String, 0, 16); if (selcol < 0) - { - pRomInfo->SelColor = - 1; + { + pRomInfo->SelColor = -1; } else { - selcol = (AsciiToHex(String) & 0xFFFFFF); + selcol = (std::strtoul(String, 0, 16) & 0xFFFFFF); selcol = (selcol & 0x00FF00) | ((selcol >> 0x10) & 0xFF) | ((selcol & 0xFF) << 0x10); pRomInfo->SelColor = selcol; } //Get the selected text color - sprintf(String,"%s.Seltext",pRomInfo->Status); - m_RomIniFile->GetString("Rom Status",String,"FFFFFF",String,7); - pRomInfo->SelTextColor = (AsciiToHex(String) & 0xFFFFFF); + sprintf(String, "%s.Seltext", pRomInfo->Status); + m_RomIniFile->GetString("Rom Status", String, "FFFFFF", String, 7); + pRomInfo->SelTextColor = (std::strtoul(String, 0, 16) & 0xFFFFFF); pRomInfo->SelTextColor = (pRomInfo->SelTextColor & 0x00FF00) | ((pRomInfo->SelTextColor >> 0x10) & 0xFF) | ((pRomInfo->SelTextColor & 0xFF) << 0x10); } -bool CRomBrowser::FillRomInfo(ROM_INFO * pRomInfo) +bool CRomBrowser::FillRomInfo(ROM_INFO * pRomInfo) { int count; BYTE RomData[0x1000]; - if (!LoadDataFromRomFile(pRomInfo->szFullFileName,RomData,sizeof(RomData),&pRomInfo->RomSize,pRomInfo->FileFormat)) + if (!LoadDataFromRomFile(pRomInfo->szFullFileName, RomData, sizeof(RomData), &pRomInfo->RomSize, pRomInfo->FileFormat)) { return false; } else { - if (strstr(pRomInfo->szFullFileName,"?") != NULL) + if (strstr(pRomInfo->szFullFileName, "?") != NULL) { - strcpy(pRomInfo->FileName,strstr(pRomInfo->szFullFileName,"?") + 1); - } + strcpy(pRomInfo->FileName, strstr(pRomInfo->szFullFileName, "?") + 1); + } else { - char drive[_MAX_DRIVE] ,dir[_MAX_DIR], ext[_MAX_EXT]; - _splitpath( pRomInfo->szFullFileName, drive, dir, pRomInfo->FileName, ext ); + char drive[_MAX_DRIVE], dir[_MAX_DIR], ext[_MAX_EXT]; + _splitpath(pRomInfo->szFullFileName, drive, dir, pRomInfo->FileName, ext); } - if (m_Fields[RB_InternalName].Pos() >= 0) + if (m_Fields[RB_InternalName].Pos() >= 0) { - memcpy(pRomInfo->InternalName,(void *)(RomData + 0x20),20); - for( count = 0 ; count < 20; count += 4 ) + memcpy(pRomInfo->InternalName, (void *)(RomData + 0x20), 20); + for (count = 0; count < 20; count += 4) { - pRomInfo->InternalName[count] ^= pRomInfo->InternalName[count+3]; + pRomInfo->InternalName[count] ^= pRomInfo->InternalName[count + 3]; pRomInfo->InternalName[count + 3] ^= pRomInfo->InternalName[count]; - pRomInfo->InternalName[count] ^= pRomInfo->InternalName[count+3]; + pRomInfo->InternalName[count] ^= pRomInfo->InternalName[count + 3]; pRomInfo->InternalName[count + 1] ^= pRomInfo->InternalName[count + 2]; pRomInfo->InternalName[count + 2] ^= pRomInfo->InternalName[count + 1]; - pRomInfo->InternalName[count + 1] ^= pRomInfo->InternalName[count + 2]; + pRomInfo->InternalName[count + 1] ^= pRomInfo->InternalName[count + 2]; } pRomInfo->InternalName[21] = '\0'; } @@ -533,29 +487,29 @@ bool CRomBrowser::FillRomInfo(ROM_INFO * pRomInfo) pRomInfo->CRC1 = *(DWORD *)(RomData + 0x10); pRomInfo->CRC2 = *(DWORD *)(RomData + 0x14); pRomInfo->CicChip = GetCicChipID(RomData); - + FillRomExtensionInfo(pRomInfo); - + if (pRomInfo->SelColor == -1) - { + { pRomInfo->SelColorBrush = (DWORD)((HBRUSH)(COLOR_HIGHLIGHT + 1)); - } + } else { pRomInfo->SelColorBrush = (DWORD)CreateSolidBrush(pRomInfo->SelColor); } - + return true; } } -bool CRomBrowser::GetRomFileNames( strlist & FileList, const CPath & BaseDirectory, const stdstr & Directory, bool InWatchThread ) +bool CRomBrowser::GetRomFileNames(strlist & FileList, const CPath & BaseDirectory, const stdstr & Directory, bool InWatchThread) { if (!BaseDirectory.DirectoryExists()) { return false; } - CPath SearchPath(BaseDirectory,"*.*"); + CPath SearchPath(BaseDirectory, "*.*"); SearchPath.AppendDirectory(Directory.c_str()); if (!SearchPath.FindFirst(CPath::_A_ALLFILES)) @@ -563,19 +517,19 @@ bool CRomBrowser::GetRomFileNames( strlist & FileList, const CPath & BaseDirecto return false; } - do + do { - if (InWatchThread && WaitForSingleObject(m_WatchStopEvent,0) != WAIT_TIMEOUT) + if (InWatchThread && WaitForSingleObject(m_WatchStopEvent, 0) != WAIT_TIMEOUT) { return false; } if (SearchPath.IsDirectory()) { - if (g_Settings->LoadDword(RomBrowser_Recursive)) + if (g_Settings->LoadDword(RomBrowser_Recursive)) { stdstr CurrentDir = Directory + SearchPath.GetCurrentDirectory() + "\\"; - GetRomFileNames(FileList,BaseDirectory,CurrentDir,InWatchThread); + GetRomFileNames(FileList, BaseDirectory, CurrentDir, InWatchThread); } } else @@ -586,35 +540,34 @@ bool CRomBrowser::GetRomFileNames( strlist & FileList, const CPath & BaseDirecto return true; } -void CRomBrowser::NotificationCB ( LPCWSTR Status, CRomBrowser * /*_this*/ ) +void CRomBrowser::NotificationCB(LPCWSTR Status, CRomBrowser * /*_this*/) { - g_Notify->DisplayMessage(5,Status); + g_Notify->DisplayMessage(5, Status); } - -void CRomBrowser::AddFileNameToList( strlist & FileList, const stdstr & Directory, CPath & File ) +void CRomBrowser::AddFileNameToList(strlist & FileList, const stdstr & Directory, CPath & File) { if (FileList.size() > 3000) { return; } - - stdstr Drive, Dir, Name, Extension; - File.GetComponents(NULL,&Dir,&Name,&Extension); + + stdstr Drive, Dir, Name, Extension; + File.GetComponents(NULL, &Dir, &Name, &Extension); Extension.ToLower(); - if (Extension == "zip" || Extension == "7z" || Extension == "v64" || Extension == "z64" || - Extension == "n64" || Extension == "rom" || Extension == "jap" || Extension == "pal" || + if (Extension == "zip" || Extension == "7z" || Extension == "v64" || Extension == "z64" || + Extension == "n64" || Extension == "rom" || Extension == "jap" || Extension == "pal" || Extension == "usa" || Extension == "eur" || Extension == "bin") { - stdstr FileName = Directory+Name+Extension; + stdstr FileName = Directory + Name + Extension; FileName.ToLower(); FileList.push_back(FileName); } } -void CRomBrowser::FillRomList ( strlist & FileList, const CPath & BaseDirectory, const stdstr & Directory, const char * lpLastRom ) +void CRomBrowser::FillRomList(strlist & FileList, const CPath & BaseDirectory, const stdstr & Directory, const char * lpLastRom) { - CPath SearchPath(BaseDirectory,"*.*"); + CPath SearchPath(BaseDirectory, "*.*"); SearchPath.AppendDirectory(Directory.c_str()); //TODO: Fix exception on Windows XP (Visual Studio 2010+) @@ -624,7 +577,7 @@ void CRomBrowser::FillRomList ( strlist & FileList, const CPath & BaseDirectory, return; } - do + do { //TODO: Fix exception on Windows XP (Visual Studio 2010+) //WriteTraceF(TraceDebug,__FUNCTION__ ": 2 %s m_StopRefresh = %d",(LPCSTR)SearchPath,m_StopRefresh); @@ -632,10 +585,10 @@ void CRomBrowser::FillRomList ( strlist & FileList, const CPath & BaseDirectory, if (SearchPath.IsDirectory()) { - if (g_Settings->LoadDword(RomBrowser_Recursive)) + if (g_Settings->LoadDword(RomBrowser_Recursive)) { stdstr CurrentDir = Directory + SearchPath.GetCurrentDirectory() + "\\"; - FillRomList(FileList,BaseDirectory,CurrentDir,lpLastRom); + FillRomList(FileList, BaseDirectory, CurrentDir, lpLastRom); } continue; } @@ -647,26 +600,25 @@ void CRomBrowser::FillRomList ( strlist & FileList, const CPath & BaseDirectory, if (Extension == "zip" || Extension == "v64" || Extension == "z64" || Extension == "n64" || Extension == "rom" || Extension == "jap" || Extension == "pal" || Extension == "usa" || - Extension == "eur" || Extension == "bin") + Extension == "eur" || Extension == "bin") { - AddRomToList(SearchPath,lpLastRom); - continue; + AddRomToList(SearchPath, lpLastRom); + continue; } - if (Extension == "7z" ) - { + if (Extension == "7z") + { try { - C7zip ZipFile(SearchPath); if (!ZipFile.OpenSuccess()) { continue; } char ZipFileName[260]; - stdstr_f SectionName("%s-%d",ZipFile.FileName(ZipFileName,sizeof(ZipFileName)),ZipFile.FileSize()); + stdstr_f SectionName("%s-%d", ZipFile.FileName(ZipFileName, sizeof(ZipFileName)), ZipFile.FileSize()); SectionName.ToLower(); - WriteTraceF(TraceDebug,__FUNCTION__ ": 4 %s",SectionName.c_str()); + WriteTraceF(TraceDebug, __FUNCTION__ ": 4 %s", SectionName.c_str()); for (int i = 0; i < ZipFile.NumFiles(); i++) { CSzFileItem * f = ZipFile.FileItem(i); @@ -674,8 +626,8 @@ void CRomBrowser::FillRomList ( strlist & FileList, const CPath & BaseDirectory, { continue; } - ROM_INFO RomInfo; - + ROM_INFO RomInfo; + std::wstring FileNameW = ZipFile.FileNameIndex(i); if (FileNameW.length() == 0) { @@ -684,81 +636,81 @@ void CRomBrowser::FillRomList ( strlist & FileList, const CPath & BaseDirectory, stdstr FileName; FileName.FromUTF16(FileNameW.c_str()); - WriteTrace(TraceDebug,__FUNCTION__ ": 5"); - char drive2[_MAX_DRIVE] ,dir2[_MAX_DIR], FileName2[MAX_PATH], ext2[_MAX_EXT]; - _splitpath( FileName.c_str(), drive2, dir2, FileName2, ext2 ); + WriteTrace(TraceDebug, __FUNCTION__ ": 5"); + char drive2[_MAX_DRIVE], dir2[_MAX_DIR], FileName2[MAX_PATH], ext2[_MAX_EXT]; + _splitpath(FileName.c_str(), drive2, dir2, FileName2, ext2); - WriteTraceF(TraceDebug,__FUNCTION__ ": 6 %s",ext2); + WriteTraceF(TraceDebug, __FUNCTION__ ": 6 %s", ext2); if (_stricmp(ext2, ".v64") != 0 && _stricmp(ext2, ".z64") != 0 && _stricmp(ext2, ".n64") != 0 && _stricmp(ext2, ".rom") != 0 && - _stricmp(ext2, ".jap") != 0 && _stricmp(ext2, ".pal") != 0 && + _stricmp(ext2, ".jap") != 0 && _stricmp(ext2, ".pal") != 0 && _stricmp(ext2, ".usa") != 0 && _stricmp(ext2, ".eur") != 0 && _stricmp(ext2, ".bin") == 0) { continue; } - WriteTrace(TraceDebug,__FUNCTION__ ": 7"); + WriteTrace(TraceDebug, __FUNCTION__ ": 7"); memset(&RomInfo, 0, sizeof(ROM_INFO)); - stdstr_f zipFileName("%s?%s",(LPCSTR)SearchPath,FileName.c_str()); - ZipFile.SetNotificationCallback((C7zip::LP7ZNOTIFICATION)NotificationCB,this); + stdstr_f zipFileName("%s?%s", (LPCSTR)SearchPath, FileName.c_str()); + ZipFile.SetNotificationCallback((C7zip::LP7ZNOTIFICATION)NotificationCB, this); strncpy(RomInfo.szFullFileName, zipFileName.c_str(), sizeof(RomInfo.szFullFileName) - 1); RomInfo.szFullFileName[sizeof(RomInfo.szFullFileName) - 1] = 0; - strcpy(RomInfo.FileName,strstr(RomInfo.szFullFileName,"?") + 1); + strcpy(RomInfo.FileName, strstr(RomInfo.szFullFileName, "?") + 1); RomInfo.FileFormat = Format_7zip; - WriteTrace(TraceDebug,__FUNCTION__ ": 8"); + WriteTrace(TraceDebug, __FUNCTION__ ": 8"); char szHeader[0x90]; - if (m_ZipIniFile->GetString(SectionName.c_str(),FileName.c_str(),"",szHeader,sizeof(szHeader)) == 0) + if (m_ZipIniFile->GetString(SectionName.c_str(), FileName.c_str(), "", szHeader, sizeof(szHeader)) == 0) { BYTE RomData[0x1000]; - if (!ZipFile.GetFile(i,RomData,sizeof(RomData))) + if (!ZipFile.GetFile(i, RomData, sizeof(RomData))) { continue; } - WriteTrace(TraceDebug,__FUNCTION__ ": 9"); + WriteTrace(TraceDebug, __FUNCTION__ ": 9"); if (!CN64Rom::IsValidRomImage(RomData)) { continue; } - WriteTrace(TraceDebug,__FUNCTION__ ": 10"); - ByteSwapRomData(RomData,sizeof(RomData)); - WriteTrace(TraceDebug,__FUNCTION__ ": 11"); - + WriteTrace(TraceDebug, __FUNCTION__ ": 10"); + ByteSwapRomData(RomData, sizeof(RomData)); + WriteTrace(TraceDebug, __FUNCTION__ ": 11"); + stdstr RomHeader; for (int x = 0; x < 0x40; x += 4) { - RomHeader += stdstr_f("%08X",*((DWORD *)&RomData[x])); + RomHeader += stdstr_f("%08X", *((DWORD *)&RomData[x])); } - WriteTraceF(TraceDebug,__FUNCTION__ ": 11a %s",RomHeader.c_str()); + WriteTraceF(TraceDebug, __FUNCTION__ ": 11a %s", RomHeader.c_str()); int CicChip = GetCicChipID(RomData); //save this info - WriteTrace(TraceDebug,__FUNCTION__ ": 12"); - m_ZipIniFile->SaveString(SectionName.c_str(),FileName.c_str(),RomHeader.c_str()); - m_ZipIniFile->SaveNumber(SectionName.c_str(),stdstr_f("%s-Cic",FileName.c_str()).c_str(),CicChip); - strcpy(szHeader,RomHeader.c_str()); + WriteTrace(TraceDebug, __FUNCTION__ ": 12"); + m_ZipIniFile->SaveString(SectionName.c_str(), FileName.c_str(), RomHeader.c_str()); + m_ZipIniFile->SaveNumber(SectionName.c_str(), stdstr_f("%s-Cic", FileName.c_str()).c_str(), CicChip); + strcpy(szHeader, RomHeader.c_str()); } - WriteTrace(TraceDebug,__FUNCTION__ ": 13"); + WriteTrace(TraceDebug, __FUNCTION__ ": 13"); BYTE RomData[0x40]; for (int x = 0; x < 0x40; x += 4) { - *((DWORD *)&RomData[x]) = AsciiToHex(&szHeader[x*2]); + *((DWORD *)&RomData[x]) = std::strtoul(&szHeader[x * 2], 0, 16); } - WriteTrace(TraceDebug,__FUNCTION__ ": 14"); - memcpy(RomInfo.InternalName,(void *)(RomData + 0x20),20); - for( int count = 0 ; count < 20; count += 4 ) + WriteTrace(TraceDebug, __FUNCTION__ ": 14"); + memcpy(RomInfo.InternalName, (void *)(RomData + 0x20), 20); + for (int count = 0; count < 20; count += 4) { - RomInfo.InternalName[count] ^= RomInfo.InternalName[count+3]; + RomInfo.InternalName[count] ^= RomInfo.InternalName[count + 3]; RomInfo.InternalName[count + 3] ^= RomInfo.InternalName[count]; - RomInfo.InternalName[count] ^= RomInfo.InternalName[count+3]; + RomInfo.InternalName[count] ^= RomInfo.InternalName[count + 3]; RomInfo.InternalName[count + 1] ^= RomInfo.InternalName[count + 2]; RomInfo.InternalName[count + 2] ^= RomInfo.InternalName[count + 1]; - RomInfo.InternalName[count + 1] ^= RomInfo.InternalName[count + 2]; + RomInfo.InternalName[count + 1] ^= RomInfo.InternalName[count + 2]; } RomInfo.RomSize = (int)f->Size; - WriteTrace(TraceDebug,__FUNCTION__ ": 15"); + WriteTrace(TraceDebug, __FUNCTION__ ": 15"); RomInfo.InternalName[21] = '\0'; RomInfo.CartID[0] = *(RomData + 0x3F); RomInfo.CartID[1] = *(RomData + 0x3E); @@ -767,42 +719,42 @@ void CRomBrowser::FillRomList ( strlist & FileList, const CPath & BaseDirectory, RomInfo.Country = *(RomData + 0x3D); RomInfo.CRC1 = *(DWORD *)(RomData + 0x10); RomInfo.CRC2 = *(DWORD *)(RomData + 0x14); - m_ZipIniFile->GetNumber(SectionName.c_str(),stdstr_f("%s-Cic",FileName.c_str()).c_str(), (ULONG)-1,(uint32_t &)RomInfo.CicChip); - WriteTrace(TraceDebug,__FUNCTION__ ": 16"); + m_ZipIniFile->GetNumber(SectionName.c_str(), stdstr_f("%s-Cic", FileName.c_str()).c_str(), (ULONG)-1, (uint32_t &)RomInfo.CicChip); + WriteTrace(TraceDebug, __FUNCTION__ ": 16"); FillRomExtensionInfo(&RomInfo); if (RomInfo.SelColor == -1) - { + { RomInfo.SelColorBrush = (DWORD)((HBRUSH)(COLOR_HIGHLIGHT + 1)); - } + } else { RomInfo.SelColorBrush = (DWORD)CreateSolidBrush(RomInfo.SelColor); } - WriteTrace(TraceDebug,__FUNCTION__ ": 17"); - AddRomInfoToList(RomInfo,lpLastRom); + WriteTrace(TraceDebug, __FUNCTION__ ": 17"); + AddRomInfoToList(RomInfo, lpLastRom); } } catch (...) { - WriteTraceF(TraceError,__FUNCTION__ "(): execpetion processing %s", (LPCSTR)SearchPath); + WriteTraceF(TraceError, __FUNCTION__ "(): execpetion processing %s", (LPCSTR)SearchPath); } - continue; + continue; } } while (SearchPath.FindNext()); m_ZipIniFile->FlushChanges(); } -int CRomBrowser::GetCicChipID (BYTE * RomData) +int CRomBrowser::GetCicChipID(BYTE * RomData) { __int64 CRC = 0; int count; - for (count = 0x40; count < 0x1000; count += 4) + for (count = 0x40; count < 0x1000; count += 4) { - CRC += *(DWORD *)(RomData+count); + CRC += *(DWORD *)(RomData + count); } - switch (CRC) + switch (CRC) { case 0x000000D0027FDF31: return CIC_NUS_6101; case 0x000000CFFB631223: return CIC_NUS_6101; @@ -815,7 +767,7 @@ int CRomBrowser::GetCicChipID (BYTE * RomData) } } -void CRomBrowser::HighLightLastRom(void) +void CRomBrowser::HighLightLastRom(void) { if (!m_AllowSelectionLastRom) { @@ -825,14 +777,14 @@ void CRomBrowser::HighLightLastRom(void) if (!RomBrowserVisible()) { return; } //Get the string to the last rom - stdstr LastRom = g_Settings->LoadStringIndex(File_RecentGameFileIndex,0); + stdstr LastRom = g_Settings->LoadStringIndex(File_RecentGameFileIndex, 0); LPCSTR lpLastRom = LastRom.c_str(); LV_ITEM lvItem; lvItem.mask = LVIF_PARAM; int ItemCount = ListView_GetItemCount((HWND)m_hRomList); - for (int index = 0; index < ItemCount; index++) + for (int index = 0; index < ItemCount; index++) { //Get The next item lvItem.iItem = index; @@ -844,56 +796,56 @@ void CRomBrowser::HighLightLastRom(void) return; } ROM_INFO * pRomInfo = &m_RomInfo[lvItem.lParam]; - + if (!m_AllowSelectionLastRom) { return; } //if the last rom then highlight the item - if (_stricmp(pRomInfo->szFullFileName,lpLastRom) == 0) + if (_stricmp(pRomInfo->szFullFileName, lpLastRom) == 0) { - ListView_SetItemState((HWND)m_hRomList,index,LVIS_SELECTED | LVIS_FOCUSED,LVIS_SELECTED | LVIS_FOCUSED); - ListView_EnsureVisible((HWND)m_hRomList,index,FALSE); + ListView_SetItemState((HWND)m_hRomList, index, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); + ListView_EnsureVisible((HWND)m_hRomList, index, FALSE); return; } - } + } } -bool CRomBrowser::LoadDataFromRomFile(char * FileName,BYTE * Data,int DataLen, int * RomSize, FILE_FORMAT & FileFormat) +bool CRomBrowser::LoadDataFromRomFile(char * FileName, BYTE * Data, int DataLen, int * RomSize, FILE_FORMAT & FileFormat) { BYTE Test[4]; - if (_strnicmp(&FileName[strlen(FileName)-4], ".ZIP",4) == 0 ) + if (_strnicmp(&FileName[strlen(FileName) - 4], ".ZIP", 4) == 0) { int len, port = 0, FoundRom; - unz_file_info info; + unz_file_info info; char zname[132]; unzFile file; file = unzOpen(FileName); if (file == NULL) { return false; } port = unzGoToFirstFile(file); - FoundRom = FALSE; - while(port == UNZ_OK && FoundRom == FALSE) + FoundRom = FALSE; + while (port == UNZ_OK && FoundRom == FALSE) { - unzGetCurrentFileInfo(file, &info, zname, 128, NULL,0, NULL,0); - if (unzLocateFile(file, zname, 1) != UNZ_OK ) + unzGetCurrentFileInfo(file, &info, zname, 128, NULL, 0, NULL, 0); + if (unzLocateFile(file, zname, 1) != UNZ_OK) { unzClose(file); return true; } - if( unzOpenCurrentFile(file) != UNZ_OK ) + if (unzOpenCurrentFile(file) != UNZ_OK) { unzClose(file); return true; } - unzReadCurrentFile(file,Test,4); - if (CN64Rom::IsValidRomImage(Test)) + unzReadCurrentFile(file, Test, 4); + if (CN64Rom::IsValidRomImage(Test)) { FoundRom = true; - memcpy(Data,Test,4); - len = unzReadCurrentFile(file,&Data[4],DataLen - 4) + 4; + memcpy(Data, Test, 4); + len = unzReadCurrentFile(file, &Data[4], DataLen - 4) + 4; if ((int)DataLen != len) { @@ -902,7 +854,7 @@ bool CRomBrowser::LoadDataFromRomFile(char * FileName,BYTE * Data,int DataLen, i return false; } *RomSize = info.uncompressed_size; - if(unzCloseCurrentFile(file) == UNZ_CRCERROR) + if (unzCloseCurrentFile(file) == UNZ_CRCERROR) { unzClose(file); return false; @@ -914,88 +866,87 @@ bool CRomBrowser::LoadDataFromRomFile(char * FileName,BYTE * Data,int DataLen, i unzCloseCurrentFile(file); port = unzGoToNextFile(file); } - } if (FoundRom == false) { return false; } FileFormat = Format_Zip; - } - else + } + else { DWORD dwRead; HANDLE hFile; - - hFile = CreateFile(FileName,GENERIC_READ,FILE_SHARE_READ,NULL, - OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, - NULL); - - if (hFile == INVALID_HANDLE_VALUE) { return false; } - SetFilePointer(hFile,0,0,FILE_BEGIN); - ReadFile(hFile,Test,4,&dwRead,NULL); - if (!CN64Rom::IsValidRomImage(Test)) { CloseHandle( hFile ); return false; } - SetFilePointer(hFile,0,0,FILE_BEGIN); - if (!ReadFile(hFile,Data,DataLen,&dwRead,NULL)) { CloseHandle( hFile ); return false; } - *RomSize = GetFileSize(hFile,NULL); - CloseHandle( hFile ); + hFile = CreateFile(FileName, GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, + NULL); + + if (hFile == INVALID_HANDLE_VALUE) { return false; } + + SetFilePointer(hFile, 0, 0, FILE_BEGIN); + ReadFile(hFile, Test, 4, &dwRead, NULL); + if (!CN64Rom::IsValidRomImage(Test)) { CloseHandle(hFile); return false; } + SetFilePointer(hFile, 0, 0, FILE_BEGIN); + if (!ReadFile(hFile, Data, DataLen, &dwRead, NULL)) { CloseHandle(hFile); return false; } + *RomSize = GetFileSize(hFile, NULL); + CloseHandle(hFile); FileFormat = Format_Uncompressed; - } - ByteSwapRomData(Data,DataLen); + } + ByteSwapRomData(Data, DataLen); return true; } -void CRomBrowser::ByteSwapRomData (BYTE * Data, int DataLen) +void CRomBrowser::ByteSwapRomData(BYTE * Data, int DataLen) { int count; - switch (*((DWORD *)&Data[0])) + switch (*((DWORD *)&Data[0])) { case 0x12408037: - for( count = 0 ; count < DataLen; count += 4 ) + for (count = 0; count < DataLen; count += 4) { - Data[count] ^= Data[count+2]; + Data[count] ^= Data[count + 2]; Data[count + 2] ^= Data[count]; - Data[count] ^= Data[count+2]; + Data[count] ^= Data[count + 2]; Data[count + 1] ^= Data[count + 3]; Data[count + 3] ^= Data[count + 1]; - Data[count + 1] ^= Data[count + 3]; + Data[count + 1] ^= Data[count + 3]; } break; case 0x40123780: - for( count = 0 ; count < DataLen; count += 4 ) + for (count = 0; count < DataLen; count += 4) { - Data[count] ^= Data[count+3]; + Data[count] ^= Data[count + 3]; Data[count + 3] ^= Data[count]; - Data[count] ^= Data[count+3]; + Data[count] ^= Data[count + 3]; Data[count + 1] ^= Data[count + 2]; Data[count + 2] ^= Data[count + 1]; - Data[count + 1] ^= Data[count + 2]; + Data[count + 1] ^= Data[count + 2]; } break; case 0x80371240: break; } } -void CRomBrowser::LoadRomList (void) { +void CRomBrowser::LoadRomList(void) { stdstr FileName = g_Settings->LoadStringVal(SupportFile_RomListCache); - + //Open the cache file - HANDLE hFile = CreateFile(FileName.c_str(),GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); + HANDLE hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); if (hFile == INVALID_HANDLE_VALUE) { //if file does not exist then refresh the data RefreshRomBrowser(); return; } - + DWORD dwRead; unsigned char md5[16]; - ReadFile(hFile,&md5,sizeof(md5),&dwRead,NULL); + ReadFile(hFile, &md5, sizeof(md5), &dwRead, NULL); //Read the size of ROM_INFO int RomInfoSize = 0; - ReadFile(hFile,&RomInfoSize,sizeof(RomInfoSize),&dwRead,NULL); + ReadFile(hFile, &RomInfoSize, sizeof(RomInfoSize), &dwRead, NULL); if (RomInfoSize != sizeof(ROM_INFO) || dwRead != sizeof(RomInfoSize)) { CloseHandle(hFile); RefreshRomBrowser(); @@ -1004,24 +955,24 @@ void CRomBrowser::LoadRomList (void) { //Read the Number of entries int Entries = 0; - ReadFile(hFile,&Entries,sizeof(Entries),&dwRead,NULL); + ReadFile(hFile, &Entries, sizeof(Entries), &dwRead, NULL); //Read Every Entry DeallocateBrushs(); m_RomInfo.clear(); for (int count = 0; count < Entries; count++) { ROM_INFO RomInfo; - ReadFile(hFile,&RomInfo,RomInfoSize,&dwRead,NULL); + ReadFile(hFile, &RomInfo, RomInfoSize, &dwRead, NULL); RomInfo.SelColorBrush = NULL; - + LV_ITEM lvItem; memset(&lvItem, 0, sizeof(lvItem)); - lvItem.mask = LVIF_TEXT | LVIF_PARAM; - lvItem.iItem = ListView_GetItemCount((HWND)m_hRomList); - lvItem.lParam = (LPARAM)m_RomInfo.size(); - lvItem.pszText = LPSTR_TEXTCALLBACK; - - ListView_InsertItem((HWND)m_hRomList, &lvItem); + lvItem.mask = LVIF_TEXT | LVIF_PARAM; + lvItem.iItem = ListView_GetItemCount((HWND)m_hRomList); + lvItem.lParam = (LPARAM)m_RomInfo.size(); + lvItem.pszText = LPSTR_TEXTCALLBACK; + + ListView_InsertItem((HWND)m_hRomList, &lvItem); m_RomInfo.push_back(RomInfo); } CloseHandle(hFile); @@ -1029,10 +980,10 @@ void CRomBrowser::LoadRomList (void) { RomList_SortList(); } -void CRomBrowser::MenuSetText ( HMENU hMenu, int MenuPos, const wchar_t * Title, char * ShortCut) +void CRomBrowser::MenuSetText(HMENU hMenu, int MenuPos, const wchar_t * Title, char * ShortCut) { MENUITEMINFOW MenuInfo; - wchar_t String[256]; + wchar_t String[256]; if (Title == NULL || wcslen(Title) == 0) { return; } @@ -1044,14 +995,14 @@ void CRomBrowser::MenuSetText ( HMENU hMenu, int MenuPos, const wchar_t * Title, MenuInfo.dwTypeData = String; MenuInfo.cch = 256; - GetMenuItemInfoW(hMenu,MenuPos,TRUE,&MenuInfo); - wcscpy(String,Title); - if (wcschr(String,'\t') != NULL) { *(wcschr(String,'\t')) = '\0'; } - if (ShortCut) { swprintf(String,sizeof(String) / sizeof(String[0]),L"%s\t%s",String,ShortCut); } - SetMenuItemInfoW(hMenu,MenuPos,TRUE,&MenuInfo); + GetMenuItemInfoW(hMenu, MenuPos, TRUE, &MenuInfo); + wcscpy(String, Title); + if (wcschr(String, '\t') != NULL) { *(wcschr(String, '\t')) = '\0'; } + if (ShortCut) { swprintf(String, sizeof(String) / sizeof(String[0]), L"%s\t%s", String, ShortCut); } + SetMenuItemInfoW(hMenu, MenuPos, TRUE, &MenuInfo); } -void CRomBrowser::RefreshRomBrowser (void) +void CRomBrowser::RefreshRomBrowser(void) { DWORD ThreadID; @@ -1059,13 +1010,13 @@ void CRomBrowser::RefreshRomBrowser (void) { return; } - WriteTrace(TraceDebug,__FUNCTION__ ": 1"); + WriteTrace(TraceDebug, __FUNCTION__ ": 1"); m_StopRefresh = false; - m_RefreshThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)RefreshRomBrowserStatic,(LPVOID)this,0,&ThreadID); - WriteTrace(TraceDebug,__FUNCTION__ ": 2"); + m_RefreshThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)RefreshRomBrowserStatic, (LPVOID)this, 0, &ThreadID); + WriteTrace(TraceDebug, __FUNCTION__ ": 2"); } -void CRomBrowser::RefreshRomBrowserStatic (CRomBrowser * _this) +void CRomBrowser::RefreshRomBrowserStatic(CRomBrowser * _this) { try { @@ -1076,45 +1027,45 @@ void CRomBrowser::RefreshRomBrowserStatic (CRomBrowser * _this) DeleteFile(CacheFileName.c_str()); //clear all current items - WriteTrace(TraceDebug,__FUNCTION__ " 1"); + WriteTrace(TraceDebug, __FUNCTION__ " 1"); ListView_DeleteAllItems((HWND)_this->m_hRomList); _this->DeallocateBrushs(); _this->m_RomInfo.clear(); - WriteTrace(TraceDebug,__FUNCTION__ " 2"); - InvalidateRect((HWND)_this->m_hRomList,NULL,TRUE); + WriteTrace(TraceDebug, __FUNCTION__ " 2"); + InvalidateRect((HWND)_this->m_hRomList, NULL, TRUE); Sleep(100); - WriteTrace(TraceDebug,__FUNCTION__ " 3"); + WriteTrace(TraceDebug, __FUNCTION__ " 3"); if (_this->m_WatchRomDir != g_Settings->LoadStringVal(Directory_Game)) { - WriteTrace(TraceDebug,__FUNCTION__ " 4"); + WriteTrace(TraceDebug, __FUNCTION__ " 4"); _this->WatchThreadStop(); - WriteTrace(TraceDebug,__FUNCTION__ " 5"); + WriteTrace(TraceDebug, __FUNCTION__ " 5"); _this->WatchThreadStart(); - WriteTrace(TraceDebug,__FUNCTION__ " 6"); + WriteTrace(TraceDebug, __FUNCTION__ " 6"); } - WriteTrace(TraceDebug,__FUNCTION__ " 7"); - stdstr RomDir = g_Settings->LoadStringVal(Directory_Game); - stdstr LastRom = g_Settings->LoadStringIndex(File_RecentGameFileIndex,0); - WriteTrace(TraceDebug,__FUNCTION__ " 8"); - + WriteTrace(TraceDebug, __FUNCTION__ " 7"); + stdstr RomDir = g_Settings->LoadStringVal(Directory_Game); + stdstr LastRom = g_Settings->LoadStringIndex(File_RecentGameFileIndex, 0); + WriteTrace(TraceDebug, __FUNCTION__ " 8"); + strlist FileNames; - _this->FillRomList (FileNames, CPath(RomDir),stdstr(""), LastRom.c_str()); - WriteTrace(TraceDebug,__FUNCTION__ " 9"); + _this->FillRomList(FileNames, CPath(RomDir), stdstr(""), LastRom.c_str()); + WriteTrace(TraceDebug, __FUNCTION__ " 9"); _this->SaveRomList(FileNames); - WriteTrace(TraceDebug,__FUNCTION__ " 10"); + WriteTrace(TraceDebug, __FUNCTION__ " 10"); CloseHandle(_this->m_RefreshThread); _this->m_RefreshThread = NULL; - WriteTrace(TraceDebug,__FUNCTION__ " 11"); + WriteTrace(TraceDebug, __FUNCTION__ " 11"); } catch (...) { - WriteTrace(TraceError,__FUNCTION__ "(): Unhandled Exception "); + WriteTrace(TraceError, __FUNCTION__ "(): Unhandled Exception "); } } -void CRomBrowser::ResetRomBrowserColomuns (void) +void CRomBrowser::ResetRomBrowserColomuns(void) { size_t Coloumn, index; LV_COLUMNW lvColumn; @@ -1122,12 +1073,12 @@ void CRomBrowser::ResetRomBrowserColomuns (void) GetFieldInfo(m_Fields); - //Remove all current coloumns - memset(&lvColumn,0,sizeof(lvColumn)); + //Remove all current coloumns + memset(&lvColumn, 0, sizeof(lvColumn)); lvColumn.mask = LVCF_FMT; - while (ListView_GetColumn((HWND)m_hRomList,0,&lvColumn)) - { - ListView_DeleteColumn((HWND)m_hRomList,0); + while (ListView_GetColumn((HWND)m_hRomList, 0, &lvColumn)) + { + ListView_DeleteColumn((HWND)m_hRomList, 0); } //Add Colomuns @@ -1135,14 +1086,14 @@ void CRomBrowser::ResetRomBrowserColomuns (void) lvColumn.fmt = LVCFMT_LEFT; lvColumn.pszText = szString; - for (Coloumn = 0; Coloumn < m_Fields.size(); Coloumn ++) - { - for (index = 0; index < m_Fields.size(); index ++) - { + for (Coloumn = 0; Coloumn < m_Fields.size(); Coloumn++) + { + for (index = 0; index < m_Fields.size(); index++) + { if (m_Fields[index].Pos() == Coloumn) { break; } } - if (index == m_Fields.size() || m_Fields[index].Pos() != Coloumn) - { + if (index == m_Fields.size() || m_Fields[index].Pos() != Coloumn) + { m_FieldType[Coloumn] = -1; break; } @@ -1154,23 +1105,23 @@ void CRomBrowser::ResetRomBrowserColomuns (void) } } -void CRomBrowser::ResizeRomList (WORD nWidth, WORD nHeight) +void CRomBrowser::ResizeRomList(WORD nWidth, WORD nHeight) { - if (RomBrowserVisible()) + if (RomBrowserVisible()) { if (g_Settings->LoadDword(RomBrowser_Maximized) == 0 && nHeight != 0) { if (g_Settings->LoadDword(RomBrowser_Width) != nWidth) { - g_Settings->SaveDword(RomBrowser_Width,nWidth); + g_Settings->SaveDword(RomBrowser_Width, nWidth); } if (g_Settings->LoadDword(RomBrowser_Height) != nHeight) { - g_Settings->SaveDword(RomBrowser_Height,nHeight); + g_Settings->SaveDword(RomBrowser_Height, nHeight); } - } - if (IsWindow((HWND)m_StatusWindow)) - { + } + if (IsWindow((HWND)m_StatusWindow)) + { RECT rc; GetWindowRect((HWND)m_StatusWindow, &rc); @@ -1180,7 +1131,7 @@ void CRomBrowser::ResizeRomList (WORD nWidth, WORD nHeight) } } -bool CRomBrowser::RomBrowserVisible (void) +bool CRomBrowser::RomBrowserVisible(void) { if (!IsWindow((HWND)m_hRomList)) { return false; } if (!IsWindowVisible((HWND)m_hRomList)) { return false; } @@ -1196,7 +1147,7 @@ void CRomBrowser::RomBrowserToTop(void) void CRomBrowser::RomBrowserMaximize(bool Mazimize) { - g_Settings->SaveDword(RomBrowser_Maximized,(DWORD)Mazimize); + g_Settings->SaveDword(RomBrowser_Maximized, (DWORD)Mazimize); } bool CRomBrowser::RomListDrawItem(int idCtrl, DWORD lParam) @@ -1208,7 +1159,7 @@ bool CRomBrowser::RomListDrawItem(int idCtrl, DWORD lParam) char String[300]; LV_ITEM lvItem; HBRUSH hBrush; - LV_COLUMN lvc; + LV_COLUMN lvc; int nColumn; lvItem.mask = LVIF_PARAM; @@ -1226,23 +1177,23 @@ bool CRomBrowser::RomListDrawItem(int idCtrl, DWORD lParam) { return true; } - if (bSelected) - { + if (bSelected) + { hBrush = (HBRUSH)pRomInfo->SelColorBrush; - SetTextColor(ditem->hDC,pRomInfo->SelTextColor); + SetTextColor(ditem->hDC, pRomInfo->SelTextColor); } - else - { + else + { hBrush = (HBRUSH)(COLOR_WINDOW + 1); - SetTextColor(ditem->hDC,pRomInfo->TextColor); + SetTextColor(ditem->hDC, pRomInfo->TextColor); } - FillRect( ditem->hDC, &ditem->rcItem,hBrush); - SetBkMode( ditem->hDC, TRANSPARENT ); - + FillRect(ditem->hDC, &ditem->rcItem, hBrush); + SetBkMode(ditem->hDC, TRANSPARENT); + //Draw - ListView_GetItemRect((HWND)m_hRomList,ditem->itemID,&rcItem,LVIR_LABEL); - ListView_GetItemText((HWND)m_hRomList,ditem->itemID, 0, String, sizeof(String)); - memcpy(&rcDraw,&rcItem,sizeof(RECT)); + ListView_GetItemRect((HWND)m_hRomList, ditem->itemID, &rcItem, LVIR_LABEL); + ListView_GetItemText((HWND)m_hRomList, ditem->itemID, 0, String, sizeof(String)); + memcpy(&rcDraw, &rcItem, sizeof(RECT)); rcDraw.right -= 3; std::wstring text = stdstr(String).ToUTF16(); if (wcscmp(L"#340#", text.c_str()) == 0) @@ -1251,16 +1202,16 @@ bool CRomBrowser::RomListDrawItem(int idCtrl, DWORD lParam) } DrawTextW(ditem->hDC, text.c_str(), text.length(), &rcDraw, DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER | DT_WORD_ELLIPSIS); - - memset(&lvc,0,sizeof(lvc)); - lvc.mask = LVCF_FMT | LVCF_WIDTH; - for(nColumn = 1; ListView_GetColumn((HWND)m_hRomList,nColumn,&lvc); nColumn += 1) - { - rcItem.left = rcItem.right; - rcItem.right += lvc.cx; - ListView_GetItemText((HWND)m_hRomList,ditem->itemID, nColumn, String, sizeof(String)); - memcpy(&rcDraw,&rcItem,sizeof(RECT)); + memset(&lvc, 0, sizeof(lvc)); + lvc.mask = LVCF_FMT | LVCF_WIDTH; + for (nColumn = 1; ListView_GetColumn((HWND)m_hRomList, nColumn, &lvc); nColumn += 1) + { + rcItem.left = rcItem.right; + rcItem.right += lvc.cx; + + ListView_GetItemText((HWND)m_hRomList, ditem->itemID, nColumn, String, sizeof(String)); + memcpy(&rcDraw, &rcItem, sizeof(RECT)); rcDraw.right -= 3; std::wstring text = stdstr(String).ToUTF16(); if (wcscmp(L"#340#", text.c_str()) == 0) @@ -1272,63 +1223,63 @@ bool CRomBrowser::RomListDrawItem(int idCtrl, DWORD lParam) return true; } -bool CRomBrowser::RomListNotify(int idCtrl, DWORD pnmh) +bool CRomBrowser::RomListNotify(int idCtrl, DWORD pnmh) { if (idCtrl != IDC_ROMLIST) { return false; } if (!RomBrowserVisible()) { return false; } - switch (((LPNMHDR)pnmh)->code) - { + switch (((LPNMHDR)pnmh)->code) + { case LVN_COLUMNCLICK: RomList_ColoumnSortList(pnmh); break; case NM_RETURN: RomList_OpenRom(pnmh); break; case NM_DBLCLK: RomList_OpenRom(pnmh); break; case LVN_GETDISPINFO: RomList_GetDispInfo(pnmh); break; case NM_RCLICK: RomList_PopupMenu(pnmh); break; case NM_CLICK: + { + LONG iItem = ListView_GetNextItem((HWND)m_hRomList, -1, LVNI_SELECTED); + if (iItem != -1) { - LONG iItem = ListView_GetNextItem((HWND)m_hRomList, -1, LVNI_SELECTED); - if (iItem != -1) - { - m_AllowSelectionLastRom = false; - } + m_AllowSelectionLastRom = false; } - break; + } + break; default: return false; } return true; } -void CRomBrowser::RomList_ColoumnSortList(DWORD pnmh) +void CRomBrowser::RomList_ColoumnSortList(DWORD pnmh) { LPNMLISTVIEW pnmv = (LPNMLISTVIEW)pnmh; size_t index; - for (index = 0; index < m_Fields.size(); index++) - { + for (index = 0; index < m_Fields.size(); index++) + { if (m_Fields[index].Pos() == (size_t)pnmv->iSubItem) { break; } } - if (m_Fields.size() == index) { return; } - if (_stricmp(g_Settings->LoadStringIndex(RomBrowser_SortFieldIndex,0).c_str(),m_Fields[index].Name()) == 0) - { - g_Settings->SaveBoolIndex(RomBrowser_SortAscendingIndex,0,!g_Settings->LoadBoolIndex(RomBrowser_SortAscendingIndex,0)); + if (m_Fields.size() == index) { return; } + if (_stricmp(g_Settings->LoadStringIndex(RomBrowser_SortFieldIndex, 0).c_str(), m_Fields[index].Name()) == 0) + { + g_Settings->SaveBoolIndex(RomBrowser_SortAscendingIndex, 0, !g_Settings->LoadBoolIndex(RomBrowser_SortAscendingIndex, 0)); } - else - { + else + { int count; - for (count = NoOfSortKeys; count > 0; count --) - { - g_Settings->SaveStringIndex(RomBrowser_SortFieldIndex,count,g_Settings->LoadStringIndex(RomBrowser_SortFieldIndex,count - 1).c_str()); - g_Settings->SaveBoolIndex(RomBrowser_SortAscendingIndex,count,g_Settings->LoadBoolIndex(RomBrowser_SortAscendingIndex, count - 1)); + for (count = NoOfSortKeys; count > 0; count--) + { + g_Settings->SaveStringIndex(RomBrowser_SortFieldIndex, count, g_Settings->LoadStringIndex(RomBrowser_SortFieldIndex, count - 1).c_str()); + g_Settings->SaveBoolIndex(RomBrowser_SortAscendingIndex, count, g_Settings->LoadBoolIndex(RomBrowser_SortAscendingIndex, count - 1)); } - g_Settings->SaveStringIndex(RomBrowser_SortFieldIndex,0,m_Fields[index].Name()); - g_Settings->SaveBoolIndex(RomBrowser_SortAscendingIndex,0,true); + g_Settings->SaveStringIndex(RomBrowser_SortFieldIndex, 0, m_Fields[index].Name()); + g_Settings->SaveBoolIndex(RomBrowser_SortAscendingIndex, 0, true); } RomList_SortList(); } -int CALLBACK CRomBrowser::RomList_CompareItems(DWORD lParam1, DWORD lParam2, DWORD lParamSort) +int CALLBACK CRomBrowser::RomList_CompareItems(DWORD lParam1, DWORD lParam2, DWORD lParamSort) { SORT_FIELD * SortFieldInfo = (SORT_FIELD *)lParamSort; CRomBrowser * _this = SortFieldInfo->_this; @@ -1340,38 +1291,38 @@ int CALLBACK CRomBrowser::RomList_CompareItems(DWORD lParam1, DWORD lParam2, DWO { return 0; } - ROM_INFO * pRomInfo1 = &_this->m_RomInfo[SortFieldInfo->KeyAscend?lParam1:lParam2]; - ROM_INFO * pRomInfo2 = &_this->m_RomInfo[SortFieldInfo->KeyAscend?lParam2:lParam1]; + ROM_INFO * pRomInfo1 = &_this->m_RomInfo[SortFieldInfo->KeyAscend ? lParam1 : lParam2]; + ROM_INFO * pRomInfo2 = &_this->m_RomInfo[SortFieldInfo->KeyAscend ? lParam2 : lParam1]; int result; - switch (SortFieldInfo->Key) - { + switch (SortFieldInfo->Key) + { case RB_FileName: result = (int)lstrcmpi(pRomInfo1->FileName, pRomInfo2->FileName); break; - case RB_InternalName: result = (int)lstrcmpi(pRomInfo1->InternalName, pRomInfo2->InternalName); break; - case RB_GoodName: result = (int)lstrcmpi(pRomInfo1->GoodName, pRomInfo2->GoodName); break; - case RB_Status: result = (int)lstrcmpi(pRomInfo1->Status, pRomInfo2->Status); break; - case RB_RomSize: result = (int)pRomInfo1->RomSize - (int)pRomInfo2->RomSize; break; - case RB_CoreNotes: result = (int)lstrcmpi(pRomInfo1->CoreNotes, pRomInfo2->CoreNotes); break; - case RB_PluginNotes: result = (int)lstrcmpi(pRomInfo1->PluginNotes, pRomInfo2->PluginNotes); break; - case RB_UserNotes: result = (int)lstrcmpi(pRomInfo1->UserNotes, pRomInfo2->UserNotes); break; - case RB_CartridgeID: result = (int)lstrcmpi(pRomInfo1->CartID, pRomInfo2->CartID); break; - case RB_Manufacturer: result = (int)pRomInfo1->Manufacturer - (int)pRomInfo2->Manufacturer; break; - case RB_Country: result = (int)pRomInfo1->Country - (int)pRomInfo2->Country; break; - case RB_Developer: result = (int)lstrcmpi(pRomInfo1->Developer, pRomInfo2->Developer); break; - case RB_Crc1: result = (int)pRomInfo1->CRC1 - (int)pRomInfo2->CRC1; break; - case RB_Crc2: result = (int)pRomInfo1->CRC2 - (int)pRomInfo2->CRC2; break; - case RB_CICChip: result = (int)pRomInfo1->CicChip - (int)pRomInfo2->CicChip; break; - case RB_ReleaseDate: result = (int)lstrcmpi(pRomInfo1->ReleaseDate, pRomInfo2->ReleaseDate); break; - case RB_Players: result = (int)pRomInfo1->Players - (int)pRomInfo2->Players; break; + case RB_InternalName: result = (int)lstrcmpi(pRomInfo1->InternalName, pRomInfo2->InternalName); break; + case RB_GoodName: result = (int)lstrcmpi(pRomInfo1->GoodName, pRomInfo2->GoodName); break; + case RB_Status: result = (int)lstrcmpi(pRomInfo1->Status, pRomInfo2->Status); break; + case RB_RomSize: result = (int)pRomInfo1->RomSize - (int)pRomInfo2->RomSize; break; + case RB_CoreNotes: result = (int)lstrcmpi(pRomInfo1->CoreNotes, pRomInfo2->CoreNotes); break; + case RB_PluginNotes: result = (int)lstrcmpi(pRomInfo1->PluginNotes, pRomInfo2->PluginNotes); break; + case RB_UserNotes: result = (int)lstrcmpi(pRomInfo1->UserNotes, pRomInfo2->UserNotes); break; + case RB_CartridgeID: result = (int)lstrcmpi(pRomInfo1->CartID, pRomInfo2->CartID); break; + case RB_Manufacturer: result = (int)pRomInfo1->Manufacturer - (int)pRomInfo2->Manufacturer; break; + case RB_Country: result = (int)pRomInfo1->Country - (int)pRomInfo2->Country; break; + case RB_Developer: result = (int)lstrcmpi(pRomInfo1->Developer, pRomInfo2->Developer); break; + case RB_Crc1: result = (int)pRomInfo1->CRC1 - (int)pRomInfo2->CRC1; break; + case RB_Crc2: result = (int)pRomInfo1->CRC2 - (int)pRomInfo2->CRC2; break; + case RB_CICChip: result = (int)pRomInfo1->CicChip - (int)pRomInfo2->CicChip; break; + case RB_ReleaseDate: result = (int)lstrcmpi(pRomInfo1->ReleaseDate, pRomInfo2->ReleaseDate); break; + case RB_Players: result = (int)pRomInfo1->Players - (int)pRomInfo2->Players; break; case RB_ForceFeedback: result = (int)lstrcmpi(pRomInfo1->ForceFeedback, pRomInfo2->ForceFeedback); break; - case RB_Genre: result = (int)lstrcmpi(pRomInfo1->Genre, pRomInfo2->Genre); break; - case RB_FileFormat: result = (int)pRomInfo1->FileFormat - (int)pRomInfo2->FileFormat; break; + case RB_Genre: result = (int)lstrcmpi(pRomInfo1->Genre, pRomInfo2->Genre); break; + case RB_FileFormat: result = (int)pRomInfo1->FileFormat - (int)pRomInfo2->FileFormat; break; default: result = 0; break; } return result; } -void CRomBrowser::RomList_GetDispInfo(DWORD pnmh) +void CRomBrowser::RomList_GetDispInfo(DWORD pnmh) { LV_DISPINFO * lpdi = (LV_DISPINFO *)pnmh; if (lpdi->item.lParam < 0 || lpdi->item.lParam >= (LPARAM)m_RomInfo.size()) @@ -1381,32 +1332,32 @@ void CRomBrowser::RomList_GetDispInfo(DWORD pnmh) ROM_INFO * pRomInfo = &m_RomInfo[lpdi->item.lParam]; - if (pRomInfo == NULL) + if (pRomInfo == NULL) { - strcpy(lpdi->item.pszText," "); + strcpy(lpdi->item.pszText, " "); return; } - switch(m_FieldType[lpdi->item.iSubItem]) { + switch (m_FieldType[lpdi->item.iSubItem]) { case RB_FileName: strncpy(lpdi->item.pszText, pRomInfo->FileName, lpdi->item.cchTextMax); break; case RB_InternalName: strncpy(lpdi->item.pszText, pRomInfo->InternalName, lpdi->item.cchTextMax); break; case RB_GoodName: strncpy(lpdi->item.pszText, pRomInfo->GoodName, lpdi->item.cchTextMax); break; case RB_CoreNotes: strncpy(lpdi->item.pszText, pRomInfo->CoreNotes, lpdi->item.cchTextMax); break; case RB_PluginNotes: strncpy(lpdi->item.pszText, pRomInfo->PluginNotes, lpdi->item.cchTextMax); break; case RB_Status: strncpy(lpdi->item.pszText, pRomInfo->Status, lpdi->item.cchTextMax); break; - case RB_RomSize: sprintf(lpdi->item.pszText,"%.1f MBit",(float)pRomInfo->RomSize/0x20000); break; + case RB_RomSize: sprintf(lpdi->item.pszText, "%.1f MBit", (float)pRomInfo->RomSize / 0x20000); break; case RB_CartridgeID: strncpy(lpdi->item.pszText, pRomInfo->CartID, lpdi->item.cchTextMax); break; case RB_Manufacturer: - switch (pRomInfo->Manufacturer) - { + switch (pRomInfo->Manufacturer) + { case 'N':strncpy(lpdi->item.pszText, "Nintendo", lpdi->item.cchTextMax); break; case 0: strncpy(lpdi->item.pszText, "None", lpdi->item.cchTextMax); break; - default: sprintf(lpdi->item.pszText, "(Unknown %c (%X))", pRomInfo->Manufacturer,pRomInfo->Manufacturer); break; + default: sprintf(lpdi->item.pszText, "(Unknown %c (%X))", pRomInfo->Manufacturer, pRomInfo->Manufacturer); break; } - break; + break; case RB_Country: - switch (pRomInfo->Country) - { + switch (pRomInfo->Country) + { case '7': strncpy(lpdi->item.pszText, "Beta", lpdi->item.cchTextMax); break; case 'A': strncpy(lpdi->item.pszText, "NTSC", lpdi->item.cchTextMax); break; case 'D': strncpy(lpdi->item.pszText, "Germany", lpdi->item.cchTextMax); break; @@ -1420,42 +1371,42 @@ void CRomBrowser::RomList_GetDispInfo(DWORD pnmh) case 'X': strncpy(lpdi->item.pszText, "PAL", lpdi->item.cchTextMax); break; case 'Y': strncpy(lpdi->item.pszText, "PAL", lpdi->item.cchTextMax); break; case 0: strncpy(lpdi->item.pszText, "None", lpdi->item.cchTextMax); break; - default: sprintf(lpdi->item.pszText, "Unknown %c (%02X)", pRomInfo->Country,pRomInfo->Country); break; + default: sprintf(lpdi->item.pszText, "Unknown %c (%02X)", pRomInfo->Country, pRomInfo->Country); break; } - break; - case RB_Crc1: sprintf(lpdi->item.pszText,"0x%08X",pRomInfo->CRC1); break; - case RB_Crc2: sprintf(lpdi->item.pszText,"0x%08X",pRomInfo->CRC2); break; - case RB_CICChip: - if (pRomInfo->CicChip < 0) - { - sprintf(lpdi->item.pszText,"Unknown CIC Chip"); + break; + case RB_Crc1: sprintf(lpdi->item.pszText, "0x%08X", pRomInfo->CRC1); break; + case RB_Crc2: sprintf(lpdi->item.pszText, "0x%08X", pRomInfo->CRC2); break; + case RB_CICChip: + if (pRomInfo->CicChip < 0) + { + sprintf(lpdi->item.pszText, "Unknown CIC Chip"); } - else - { - sprintf(lpdi->item.pszText,"CIC-NUS-610%d",pRomInfo->CicChip); + else + { + sprintf(lpdi->item.pszText, "CIC-NUS-610%d", pRomInfo->CicChip); } break; case RB_UserNotes: strncpy(lpdi->item.pszText, pRomInfo->UserNotes, lpdi->item.cchTextMax); break; case RB_Developer: strncpy(lpdi->item.pszText, pRomInfo->Developer, lpdi->item.cchTextMax); break; case RB_ReleaseDate: strncpy(lpdi->item.pszText, pRomInfo->ReleaseDate, lpdi->item.cchTextMax); break; case RB_Genre: strncpy(lpdi->item.pszText, pRomInfo->Genre, lpdi->item.cchTextMax); break; - case RB_Players: sprintf(lpdi->item.pszText,"%d",pRomInfo->Players); break; + case RB_Players: sprintf(lpdi->item.pszText, "%d", pRomInfo->Players); break; case RB_ForceFeedback: strncpy(lpdi->item.pszText, pRomInfo->ForceFeedback, lpdi->item.cchTextMax); break; case RB_FileFormat: - switch (pRomInfo->FileFormat) - { + switch (pRomInfo->FileFormat) + { case Format_Uncompressed: strncpy(lpdi->item.pszText, "Uncompressed", lpdi->item.cchTextMax); break; case Format_Zip: strncpy(lpdi->item.pszText, "Zip", lpdi->item.cchTextMax); break; case Format_7zip: strncpy(lpdi->item.pszText, "7zip", lpdi->item.cchTextMax); break; default: sprintf(lpdi->item.pszText, "Unknown (%X)", pRomInfo->FileFormat); break; } - break; + break; default: strncpy(lpdi->item.pszText, " ", lpdi->item.cchTextMax); } if (lpdi->item.pszText == NULL || strlen(lpdi->item.pszText) == 0) { strcpy(lpdi->item.pszText, " "); } } -void CRomBrowser::RomList_OpenRom(DWORD /*pnmh*/) +void CRomBrowser::RomList_OpenRom(DWORD /*pnmh*/) { ROM_INFO * pRomInfo; LV_ITEM lvItem; @@ -1483,8 +1434,8 @@ void CRomBrowser::RomList_PopupMenu(DWORD /*pnmh*/) { LONG iItem = ListView_GetNextItem((HWND)m_hRomList, -1, LVNI_SELECTED); m_SelectedRom = ""; - if (iItem != -1) - { + if (iItem != -1) + { LV_ITEM lvItem; memset(&lvItem, 0, sizeof(LV_ITEM)); lvItem.mask = LVIF_PARAM; @@ -1498,12 +1449,12 @@ void CRomBrowser::RomList_PopupMenu(DWORD /*pnmh*/) if (!pRomInfo) { return; } m_SelectedRom = pRomInfo->szFullFileName; - } - + } + //Load the menu - HMENU hMenu = LoadMenu(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_POPUP)); - HMENU hPopupMenu = (HMENU)GetSubMenu(hMenu,0); - + HMENU hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_POPUP)); + HMENU hPopupMenu = (HMENU)GetSubMenu(hMenu, 0); + //Fix up menu MenuSetText(hPopupMenu, 0, GS(POPUP_PLAY), NULL); MenuSetText(hPopupMenu, 2, GS(MENU_REFRESH), NULL); @@ -1513,125 +1464,124 @@ void CRomBrowser::RomList_PopupMenu(DWORD /*pnmh*/) MenuSetText(hPopupMenu, 8, GS(POPUP_SETTINGS), NULL); MenuSetText(hPopupMenu, 9, GS(POPUP_CHEATS), NULL); - if (m_SelectedRom.size() == 0) - { - DeleteMenu(hPopupMenu,9,MF_BYPOSITION); - DeleteMenu(hPopupMenu,8,MF_BYPOSITION); - DeleteMenu(hPopupMenu,7,MF_BYPOSITION); - DeleteMenu(hPopupMenu,6,MF_BYPOSITION); - DeleteMenu(hPopupMenu,5,MF_BYPOSITION); - DeleteMenu(hPopupMenu,4,MF_BYPOSITION); - DeleteMenu(hPopupMenu,1,MF_BYPOSITION); - DeleteMenu(hPopupMenu,0,MF_BYPOSITION); - } - else - { - bool inBasicMode = g_Settings->LoadDword(UserInterface_BasicMode) != 0; + if (m_SelectedRom.size() == 0) + { + DeleteMenu(hPopupMenu, 9, MF_BYPOSITION); + DeleteMenu(hPopupMenu, 8, MF_BYPOSITION); + DeleteMenu(hPopupMenu, 7, MF_BYPOSITION); + DeleteMenu(hPopupMenu, 6, MF_BYPOSITION); + DeleteMenu(hPopupMenu, 5, MF_BYPOSITION); + DeleteMenu(hPopupMenu, 4, MF_BYPOSITION); + DeleteMenu(hPopupMenu, 1, MF_BYPOSITION); + DeleteMenu(hPopupMenu, 0, MF_BYPOSITION); + } + else + { + bool inBasicMode = g_Settings->LoadDword(UserInterface_BasicMode) != 0; bool CheatsRemembered = g_Settings->LoadDword(Setting_RememberCheats) != 0; - if (!CheatsRemembered) { DeleteMenu(hPopupMenu,9,MF_BYPOSITION); } - if (inBasicMode) { DeleteMenu(hPopupMenu,8,MF_BYPOSITION); } - if (inBasicMode && !CheatsRemembered) { DeleteMenu(hPopupMenu,7,MF_BYPOSITION); } - DeleteMenu(hPopupMenu,6,MF_BYPOSITION); + if (!CheatsRemembered) { DeleteMenu(hPopupMenu, 9, MF_BYPOSITION); } + if (inBasicMode) { DeleteMenu(hPopupMenu, 8, MF_BYPOSITION); } + if (inBasicMode && !CheatsRemembered) { DeleteMenu(hPopupMenu, 7, MF_BYPOSITION); } + DeleteMenu(hPopupMenu, 6, MF_BYPOSITION); if (!inBasicMode && g_Plugins && g_Plugins->Gfx() && g_Plugins->Gfx()->GetRomBrowserMenu != NULL) { HMENU GfxMenu = (HMENU)g_Plugins->Gfx()->GetRomBrowserMenu(); if (GfxMenu) { MENUITEMINFO lpmii; - InsertMenuW(hPopupMenu, 6, MF_POPUP|MF_BYPOSITION, (DWORD)GfxMenu, GS(POPUP_GFX_PLUGIN)); + InsertMenuW(hPopupMenu, 6, MF_POPUP | MF_BYPOSITION, (DWORD)GfxMenu, GS(POPUP_GFX_PLUGIN)); lpmii.cbSize = sizeof(MENUITEMINFO); - lpmii.fMask = MIIM_STATE; + lpmii.fMask = MIIM_STATE; lpmii.fState = 0; - SetMenuItemInfo(hPopupMenu, (DWORD)GfxMenu, MF_BYCOMMAND,&lpmii); + SetMenuItemInfo(hPopupMenu, (DWORD)GfxMenu, MF_BYCOMMAND, &lpmii); } } } - + //Get the current Mouse location POINT Mouse; GetCursorPos(&Mouse); //Show the menu - TrackPopupMenu(hPopupMenu, 0, Mouse.x, Mouse.y, 0,m_MainWindow, NULL); + TrackPopupMenu(hPopupMenu, 0, Mouse.x, Mouse.y, 0, m_MainWindow, NULL); DestroyMenu(hMenu); } -void CRomBrowser::RomList_SortList(void) +void CRomBrowser::RomList_SortList(void) { SORT_FIELD SortFieldInfo; - for (int count = NoOfSortKeys; count >= 0; count --) - { - stdstr SortFieldName = g_Settings->LoadStringIndex(RomBrowser_SortFieldIndex,count); - + for (int count = NoOfSortKeys; count >= 0; count--) + { + stdstr SortFieldName = g_Settings->LoadStringIndex(RomBrowser_SortFieldIndex, count); + size_t index; - for (index = 0; index < m_Fields.size(); index++) - { - if (_stricmp(m_Fields[index].Name(),SortFieldName.c_str()) == 0) { break; } + for (index = 0; index < m_Fields.size(); index++) + { + if (_stricmp(m_Fields[index].Name(), SortFieldName.c_str()) == 0) { break; } } if (index >= m_Fields.size()) { continue; } - SortFieldInfo._this = this; - SortFieldInfo.Key = index; - SortFieldInfo.KeyAscend = g_Settings->LoadBoolIndex(RomBrowser_SortAscendingIndex,count) != 0; - ListView_SortItems((HWND)m_hRomList, RomList_CompareItems, &SortFieldInfo ); + SortFieldInfo._this = this; + SortFieldInfo.Key = index; + SortFieldInfo.KeyAscend = g_Settings->LoadBoolIndex(RomBrowser_SortAscendingIndex, count) != 0; + ListView_SortItems((HWND)m_hRomList, RomList_CompareItems, &SortFieldInfo); } } - /* * SaveRomList - save all the rom information about the current roms in the rom brower * to a cache file, so it is quick to reload the information */ -void CRomBrowser::SaveRomList ( strlist & FileList ) +void CRomBrowser::SaveRomList(strlist & FileList) { MD5 ListHash = RomListHash(FileList); - + stdstr FileName = g_Settings->LoadStringVal(SupportFile_RomListCache); - HANDLE hFile = CreateFile(FileName.c_str(),GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); + HANDLE hFile = CreateFile(FileName.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); DWORD dwWritten; - WriteFile(hFile,ListHash.raw_digest(),16,&dwWritten,NULL); - + WriteFile(hFile, ListHash.raw_digest(), 16, &dwWritten, NULL); + //Write the size of ROM_INFO int RomInfoSize = sizeof(ROM_INFO); - WriteFile(hFile,&RomInfoSize,sizeof(RomInfoSize),&dwWritten,NULL); - + WriteFile(hFile, &RomInfoSize, sizeof(RomInfoSize), &dwWritten, NULL); + //Write the Number of entries int Entries = m_RomInfo.size(); - WriteFile(hFile,&Entries,sizeof(Entries),&dwWritten,NULL); + WriteFile(hFile, &Entries, sizeof(Entries), &dwWritten, NULL); //Write Every Entry - for (int count = 0; count < Entries; count++) - { + for (int count = 0; count < Entries; count++) + { ROM_INFO * RomInfo = &m_RomInfo[count]; - WriteFile(hFile,RomInfo,RomInfoSize,&dwWritten,NULL); + WriteFile(hFile, RomInfo, RomInfoSize, &dwWritten, NULL); } - + //Close the file handle CloseHandle(hFile); } -void CRomBrowser::SaveRomListColoumnInfo(void) +void CRomBrowser::SaveRomListColoumnInfo(void) { - WriteTrace(TraceDebug,__FUNCTION__ ": Start"); + WriteTrace(TraceDebug, __FUNCTION__ ": Start"); // if (!RomBrowserVisible()) { return; } if (g_Settings == NULL) { return; } - LV_COLUMN lvColumn; + LV_COLUMN lvColumn; - memset(&lvColumn,0,sizeof(lvColumn)); + memset(&lvColumn, 0, sizeof(lvColumn)); lvColumn.mask = LVCF_WIDTH; - - for (size_t Coloumn = 0;ListView_GetColumn((HWND)m_hRomList,Coloumn,&lvColumn); Coloumn++) - { + + for (size_t Coloumn = 0; ListView_GetColumn((HWND)m_hRomList, Coloumn, &lvColumn); Coloumn++) + { size_t index; bool bFound = false; for (index = 0; index < m_Fields.size(); index++) { - if (m_Fields[index].Pos() == Coloumn) + if (m_Fields[index].Pos() == Coloumn) { bFound = true; - break; + break; } } if (bFound) @@ -1642,24 +1592,24 @@ void CRomBrowser::SaveRomListColoumnInfo(void) } } } - WriteTrace(TraceDebug,__FUNCTION__ ": Done"); + WriteTrace(TraceDebug, __FUNCTION__ ": Done"); } -int CALLBACK CRomBrowser::SelectRomDirCallBack(HWND hwnd,DWORD uMsg,DWORD /*lp*/, DWORD lpData) +int CALLBACK CRomBrowser::SelectRomDirCallBack(HWND hwnd, DWORD uMsg, DWORD /*lp*/, DWORD lpData) { - switch(uMsg) - { - case BFFM_INITIALIZED: - // WParam is TRUE since you are passing a path. - // It would be FALSE if you were passing a pidl. - if (lpData) - { - SendMessage(hwnd,BFFM_SETSELECTION,TRUE,lpData); - SetWindowTextW(hwnd, GS(DIR_SELECT_ROM)); - } - break; - } - return 0; + switch (uMsg) + { + case BFFM_INITIALIZED: + // WParam is TRUE since you are passing a path. + // It would be FALSE if you were passing a pidl. + if (lpData) + { + SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData); + SetWindowTextW(hwnd, GS(DIR_SELECT_ROM)); + } + break; + } + return 0; } void CRomBrowser::SelectRomDir(void) @@ -1668,7 +1618,7 @@ void CRomBrowser::SelectRomDir(void) LPITEMIDLIST pidl; BROWSEINFOW bi; - WriteTrace(TraceDebug,__FUNCTION__ " 1"); + WriteTrace(TraceDebug, __FUNCTION__ " 1"); stdstr RomDir = g_Settings->LoadStringVal(Directory_Game); bi.hwndOwner = m_MainWindow; bi.pidlRoot = NULL; @@ -1677,37 +1627,37 @@ void CRomBrowser::SelectRomDir(void) bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; bi.lpfn = (BFFCALLBACK)SelectRomDirCallBack; bi.lParam = (DWORD)RomDir.c_str(); - WriteTrace(TraceDebug,__FUNCTION__ " 2"); - if ((pidl = SHBrowseForFolderW(&bi)) != NULL) - { - WriteTrace(TraceDebug,__FUNCTION__ " 3"); + WriteTrace(TraceDebug, __FUNCTION__ " 2"); + if ((pidl = SHBrowseForFolderW(&bi)) != NULL) + { + WriteTrace(TraceDebug, __FUNCTION__ " 3"); char Directory[_MAX_PATH]; - if (SHGetPathFromIDList(pidl, Directory)) - { + if (SHGetPathFromIDList(pidl, Directory)) + { int len = strlen(Directory); - WriteTrace(TraceDebug,__FUNCTION__ " 4"); - if (Directory[len - 1] != '\\') - { - strcat(Directory,"\\"); + WriteTrace(TraceDebug, __FUNCTION__ " 4"); + if (Directory[len - 1] != '\\') + { + strcat(Directory, "\\"); } - WriteTrace(TraceDebug,__FUNCTION__ " 5"); - WriteTrace(TraceDebug,__FUNCTION__ " 6"); - g_Settings->SaveString(Directory_Game,Directory); - WriteTrace(TraceDebug,__FUNCTION__ " 7"); + WriteTrace(TraceDebug, __FUNCTION__ " 5"); + WriteTrace(TraceDebug, __FUNCTION__ " 6"); + g_Settings->SaveString(Directory_Game, Directory); + WriteTrace(TraceDebug, __FUNCTION__ " 7"); Notify().AddRecentDir(Directory); - WriteTrace(TraceDebug,__FUNCTION__ " 8"); + WriteTrace(TraceDebug, __FUNCTION__ " 8"); RefreshRomBrowser(); - WriteTrace(TraceDebug,__FUNCTION__ " 9"); + WriteTrace(TraceDebug, __FUNCTION__ " 9"); } } } -void CRomBrowser::FixRomListWindow (void) +void CRomBrowser::FixRomListWindow(void) { //Change the window Style - long Style = GetWindowLong(m_MainWindow,GWL_STYLE) | WS_SIZEBOX | WS_MAXIMIZEBOX; - SetWindowLong(m_MainWindow,GWL_STYLE,Style); + long Style = GetWindowLong(m_MainWindow, GWL_STYLE) | WS_SIZEBOX | WS_MAXIMIZEBOX; + SetWindowLong(m_MainWindow, GWL_STYLE, Style); //Get the current window size RECT rect; @@ -1716,18 +1666,18 @@ void CRomBrowser::FixRomListWindow (void) //We find the middle position of the screen, we use this if theres no setting int X = (GetSystemMetrics(SM_CXSCREEN) - (rect.right - rect.left)) / 2; int Y = (GetSystemMetrics(SM_CYSCREEN) - (rect.bottom - rect.top)) / 2; - + //Load the value from settings, if none is available, default to above g_Settings->LoadDword(RomBrowser_Top, (uint32_t &)Y); g_Settings->LoadDword(RomBrowser_Left, (uint32_t &)X); - SetWindowPos(m_MainWindow,NULL,X,Y,0,0,SWP_NOZORDER|SWP_NOSIZE); + SetWindowPos(m_MainWindow, NULL, X, Y, 0, 0, SWP_NOZORDER | SWP_NOSIZE); //Fix height and width - int Width = g_Settings->LoadDword(RomBrowser_Width); + int Width = g_Settings->LoadDword(RomBrowser_Width); int Height = g_Settings->LoadDword(RomBrowser_Height); - if (Width < 200) { Width = 200; } + if (Width < 200) { Width = 200; } if (Height < 200) { Height = 200; } RECT rcClient; @@ -1735,119 +1685,119 @@ void CRomBrowser::FixRomListWindow (void) rcClient.bottom = Height; rcClient.left = 0; rcClient.right = Width; - AdjustWindowRect(&rcClient,GetWindowLong(m_MainWindow,GWL_STYLE),true); + AdjustWindowRect(&rcClient, GetWindowLong(m_MainWindow, GWL_STYLE), true); int WindowHeight = rcClient.bottom - rcClient.top; int WindowWidth = rcClient.right - rcClient.left; - SetWindowPos(m_MainWindow,NULL,0,0,WindowWidth,WindowHeight,SWP_NOMOVE|SWP_NOZORDER); + SetWindowPos(m_MainWindow, NULL, 0, 0, WindowWidth, WindowHeight, SWP_NOMOVE | SWP_NOZORDER); } -void CRomBrowser::ShowRomList (void) +void CRomBrowser::ShowRomList(void) { if (m_Visible || g_Settings->LoadBool(GameRunning_CPU_Running)) { return; } m_ShowingRomBrowser = true; WatchThreadStop(); - if (m_hRomList == NULL) { CreateRomListControl(); } - EnableWindow((HWND)m_hRomList,TRUE); - ShowWindow((HWND)m_hRomList,SW_SHOW); + if (m_hRomList == NULL) { CreateRomListControl(); } + EnableWindow((HWND)m_hRomList, TRUE); + ShowWindow((HWND)m_hRomList, SW_SHOW); FixRomListWindow(); m_AllowSelectionLastRom = true; //Make sure selected item is visible int iItem = ListView_GetNextItem((HWND)m_hRomList, -1, LVNI_SELECTED); - ListView_EnsureVisible((HWND)m_hRomList,iItem,FALSE); + ListView_EnsureVisible((HWND)m_hRomList, iItem, FALSE); //Mark the window as visible m_Visible = true; RECT rcWindow; - if (GetClientRect(m_MainWindow,&rcWindow)) + if (GetClientRect(m_MainWindow, &rcWindow)) { - ResizeRomList((WORD)rcWindow.right,(WORD)rcWindow.bottom); + ResizeRomList((WORD)rcWindow.right, (WORD)rcWindow.bottom); } - InvalidateRect((HWND)m_hRomList,NULL,TRUE); + InvalidateRect((HWND)m_hRomList, NULL, TRUE); //Start thread to watch for dir changed WatchThreadStart(); m_ShowingRomBrowser = false; } -void CRomBrowser::HideRomList (void) +void CRomBrowser::HideRomList(void) { if (!RomBrowserVisible()) { return; } - ShowWindow(m_MainWindow,SW_HIDE); + ShowWindow(m_MainWindow, SW_HIDE); SaveRomListColoumnInfo(); WatchThreadStop(); - + //Make sure the window does disappear Sleep(100); - - //Disable the rom list - EnableWindow((HWND)m_hRomList,FALSE); - ShowWindow((HWND)m_hRomList,SW_HIDE); - if (g_Settings->LoadBool(RomBrowser_Maximized)) { ShowWindow(m_MainWindow,SW_RESTORE); } + //Disable the rom list + EnableWindow((HWND)m_hRomList, FALSE); + ShowWindow((HWND)m_hRomList, SW_HIDE); + + if (g_Settings->LoadBool(RomBrowser_Maximized)) { ShowWindow(m_MainWindow, SW_RESTORE); } //Change the window style - long Style = GetWindowLong(m_MainWindow,GWL_STYLE) & ~(WS_SIZEBOX | WS_MAXIMIZEBOX); - SetWindowLong(m_MainWindow,GWL_STYLE,Style); + long Style = GetWindowLong(m_MainWindow, GWL_STYLE) & ~(WS_SIZEBOX | WS_MAXIMIZEBOX); + SetWindowLong(m_MainWindow, GWL_STYLE, Style); //Move window to correct location RECT rect; - GetWindowRect(m_MainWindow,&rect); - int X = (GetSystemMetrics( SM_CXSCREEN ) - (rect.right - rect.left)) / 2; - int Y = (GetSystemMetrics( SM_CYSCREEN ) - (rect.bottom - rect.top)) / 2; - g_Settings->LoadDword(UserInterface_MainWindowTop,(uint32_t &)Y); + GetWindowRect(m_MainWindow, &rect); + int X = (GetSystemMetrics(SM_CXSCREEN) - (rect.right - rect.left)) / 2; + int Y = (GetSystemMetrics(SM_CYSCREEN) - (rect.bottom - rect.top)) / 2; + g_Settings->LoadDword(UserInterface_MainWindowTop, (uint32_t &)Y); g_Settings->LoadDword(UserInterface_MainWindowLeft, (uint32_t &)X); - SetWindowPos(m_MainWindow,NULL,X,Y,0,0,SWP_NOZORDER|SWP_NOSIZE); + SetWindowPos(m_MainWindow, NULL, X, Y, 0, 0, SWP_NOZORDER | SWP_NOSIZE); //Mark the window as not visible m_Visible = false; //Make the main window visible again - ShowWindow(m_MainWindow,SW_SHOW); + ShowWindow(m_MainWindow, SW_SHOW); BringWindowToTop(m_MainWindow); - PostMessage(m_MainWindow, WM_MAKE_FOCUS, 0,0 ); + PostMessage(m_MainWindow, WM_MAKE_FOCUS, 0, 0); } -bool CRomBrowser::RomDirNeedsRefresh ( void ) +bool CRomBrowser::RomDirNeedsRefresh(void) { - bool InWatchThread = (m_WatchThreadID == GetCurrentThreadId()); - + bool InWatchThread = (m_WatchThreadID == GetCurrentThreadId()); + //Get Old MD5 of file names stdstr FileName = g_Settings->LoadStringVal(SupportFile_RomListCache); - HANDLE hFile = CreateFile(FileName.c_str(),GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); - if (hFile == INVALID_HANDLE_VALUE) + HANDLE hFile = CreateFile(FileName.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); + if (hFile == INVALID_HANDLE_VALUE) { //if file does not exist then refresh the data return true; } - + DWORD dwRead; unsigned char CurrentFileMD5[16]; - ReadFile(hFile,&CurrentFileMD5,sizeof(CurrentFileMD5),&dwRead,NULL); + ReadFile(hFile, &CurrentFileMD5, sizeof(CurrentFileMD5), &dwRead, NULL); CloseHandle(hFile); //Get Current MD5 of file names strlist FileNames; - if (!GetRomFileNames(FileNames,CPath(g_Settings->LoadStringVal(Directory_Game)),stdstr(""), InWatchThread )) + if (!GetRomFileNames(FileNames, CPath(g_Settings->LoadStringVal(Directory_Game)), stdstr(""), InWatchThread)) { return false; } FileNames.sort(); - + MD5 NewMd5 = RomListHash(FileNames); - if (memcmp(NewMd5.raw_digest(),CurrentFileMD5,sizeof(CurrentFileMD5)) != 0) + if (memcmp(NewMd5.raw_digest(), CurrentFileMD5, sizeof(CurrentFileMD5)) != 0) { return true; } return false; } -MD5 CRomBrowser::RomListHash ( strlist & FileList ) +MD5 CRomBrowser::RomListHash(strlist & FileList) { stdstr NewFileNames; FileList.sort(); @@ -1857,101 +1807,99 @@ MD5 CRomBrowser::RomListHash ( strlist & FileList ) NewFileNames += ";"; } MD5 md5Hash((const unsigned char *)NewFileNames.c_str(), NewFileNames.length()); - WriteTraceF(TraceDebug,__FUNCTION__ ": %s - %s",md5Hash.hex_digest(),NewFileNames.c_str()); + WriteTraceF(TraceDebug, __FUNCTION__ ": %s - %s", md5Hash.hex_digest(), NewFileNames.c_str()); return md5Hash; } -void CRomBrowser::WatchRomDirChanged ( CRomBrowser * _this ) +void CRomBrowser::WatchRomDirChanged(CRomBrowser * _this) { try { - WriteTrace(TraceDebug,__FUNCTION__ ": 1"); + WriteTrace(TraceDebug, __FUNCTION__ ": 1"); _this->m_WatchRomDir = g_Settings->LoadStringVal(Directory_Game); - WriteTrace(TraceDebug,__FUNCTION__ ": 2"); + WriteTrace(TraceDebug, __FUNCTION__ ": 2"); if (_this->RomDirNeedsRefresh()) { - WriteTrace(TraceDebug,__FUNCTION__ ": 2a"); - PostMessage((HWND)_this->m_MainWindow,WM_COMMAND,ID_FILE_REFRESHROMLIST,0); + WriteTrace(TraceDebug, __FUNCTION__ ": 2a"); + PostMessage((HWND)_this->m_MainWindow, WM_COMMAND, ID_FILE_REFRESHROMLIST, 0); } - WriteTrace(TraceDebug,__FUNCTION__ ": 3"); + WriteTrace(TraceDebug, __FUNCTION__ ": 3"); HANDLE hChange[] = { _this->m_WatchStopEvent, - FindFirstChangeNotification(_this->m_WatchRomDir.c_str(),g_Settings->LoadDword(RomBrowser_Recursive),FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_SIZE), + FindFirstChangeNotification(_this->m_WatchRomDir.c_str(), g_Settings->LoadDword(RomBrowser_Recursive), FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_SIZE), }; - WriteTrace(TraceDebug,__FUNCTION__ ": 4"); + WriteTrace(TraceDebug, __FUNCTION__ ": 4"); for (;;) { - WriteTrace(TraceDebug,__FUNCTION__ ": 5"); - if (WaitForMultipleObjects(sizeof(hChange) / sizeof(hChange[0]),hChange,false,INFINITE) == WAIT_OBJECT_0) + WriteTrace(TraceDebug, __FUNCTION__ ": 5"); + if (WaitForMultipleObjects(sizeof(hChange) / sizeof(hChange[0]), hChange, false, INFINITE) == WAIT_OBJECT_0) { - WriteTrace(TraceDebug,__FUNCTION__ ": 5a"); + WriteTrace(TraceDebug, __FUNCTION__ ": 5a"); FindCloseChangeNotification(hChange[1]); return; } - WriteTrace(TraceDebug,__FUNCTION__ ": 5b"); + WriteTrace(TraceDebug, __FUNCTION__ ": 5b"); if (_this->RomDirNeedsRefresh()) { - PostMessage((HWND)_this->m_MainWindow,WM_COMMAND,ID_FILE_REFRESHROMLIST,0); + PostMessage((HWND)_this->m_MainWindow, WM_COMMAND, ID_FILE_REFRESHROMLIST, 0); } - WriteTrace(TraceDebug,__FUNCTION__ ": 5c"); + WriteTrace(TraceDebug, __FUNCTION__ ": 5c"); if (!FindNextChangeNotification(hChange[1])) { FindCloseChangeNotification(hChange[1]); return; } - WriteTrace(TraceDebug,__FUNCTION__ ": 5d"); + WriteTrace(TraceDebug, __FUNCTION__ ": 5d"); } } catch (...) { - WriteTraceF(TraceError,__FUNCTION__ ": Unhandled Exception"); + WriteTraceF(TraceError, __FUNCTION__ ": Unhandled Exception"); } } -void CRomBrowser::WatchThreadStart (void) +void CRomBrowser::WatchThreadStart(void) { - WriteTrace(TraceDebug,__FUNCTION__ ": 1"); + WriteTrace(TraceDebug, __FUNCTION__ ": 1"); WatchThreadStop(); - WriteTrace(TraceDebug,__FUNCTION__ ": 2"); - m_WatchStopEvent = CreateEvent(NULL,true,false,NULL); - WriteTrace(TraceDebug,__FUNCTION__ ": 3"); - m_WatchThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)WatchRomDirChanged,this,0,&m_WatchThreadID); - WriteTrace(TraceDebug,__FUNCTION__ ": 4"); + WriteTrace(TraceDebug, __FUNCTION__ ": 2"); + m_WatchStopEvent = CreateEvent(NULL, true, false, NULL); + WriteTrace(TraceDebug, __FUNCTION__ ": 3"); + m_WatchThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)WatchRomDirChanged, this, 0, &m_WatchThreadID); + WriteTrace(TraceDebug, __FUNCTION__ ": 4"); } -void CRomBrowser::WatchThreadStop( void ) +void CRomBrowser::WatchThreadStop(void) { if (m_WatchThread == NULL) { return; } - WriteTrace(TraceDebug,__FUNCTION__ ": 1"); + WriteTrace(TraceDebug, __FUNCTION__ ": 1"); SetEvent(m_WatchStopEvent); DWORD ExitCode = 0; - for (int count = 0; count < 20; count ++ ) + for (int count = 0; count < 20; count++) { - WriteTrace(TraceDebug,__FUNCTION__ ": 2"); - GetExitCodeThread(m_WatchThread,&ExitCode); - if (ExitCode != STILL_ACTIVE) + WriteTrace(TraceDebug, __FUNCTION__ ": 2"); + GetExitCodeThread(m_WatchThread, &ExitCode); + if (ExitCode != STILL_ACTIVE) { break; } Sleep(200); } - WriteTrace(TraceDebug,__FUNCTION__ ": 3"); - if (ExitCode == STILL_ACTIVE) + WriteTrace(TraceDebug, __FUNCTION__ ": 3"); + if (ExitCode == STILL_ACTIVE) { - WriteTrace(TraceDebug,__FUNCTION__ ": 3a"); - TerminateThread(m_WatchThread,0); + WriteTrace(TraceDebug, __FUNCTION__ ": 3a"); + TerminateThread(m_WatchThread, 0); } - WriteTrace(TraceDebug,__FUNCTION__ ": 4"); + WriteTrace(TraceDebug, __FUNCTION__ ": 4"); CloseHandle(m_WatchThread); CloseHandle(m_WatchStopEvent); m_WatchStopEvent = NULL; - m_WatchThread = NULL; - m_WatchThreadID = 0; - WriteTrace(TraceDebug,__FUNCTION__ ": 5"); - -} - + m_WatchThread = NULL; + m_WatchThreadID = 0; + WriteTrace(TraceDebug, __FUNCTION__ ": 5"); +} \ No newline at end of file diff --git a/Source/Project64/User Interface/Rom Browser.h b/Source/Project64/User Interface/Rom Browser.h index 4465b5032..5890782fb 100644 --- a/Source/Project64/User Interface/Rom Browser.h +++ b/Source/Project64/User Interface/Rom Browser.h @@ -24,7 +24,7 @@ class ROMBROWSER_FIELDS { bool m_PosChanged; public: - ROMBROWSER_FIELDS (const char * Name, int Pos, int ID, int ColWidth, LanguageStringID LangID, bool UseDefault) : + ROMBROWSER_FIELDS(const char * Name, int Pos, int ID, int ColWidth, LanguageStringID LangID, bool UseDefault) : m_Name(Name), m_Pos(Pos), m_DefaultPos(Pos), @@ -32,36 +32,36 @@ public: m_ColWidth(ColWidth), m_LangID(LangID), m_PosChanged(false) - + { if (!UseDefault) { - m_PosChanged = g_Settings->LoadDwordIndex(RomBrowser_PosIndex,m_ID,(uint32_t &)m_Pos ); - g_Settings->LoadDwordIndex(RomBrowser_WidthIndex,m_ID,m_ColWidth); + m_PosChanged = g_Settings->LoadDwordIndex(RomBrowser_PosIndex, m_ID, (uint32_t &)m_Pos); + g_Settings->LoadDwordIndex(RomBrowser_WidthIndex, m_ID, m_ColWidth); } } - inline LPCSTR Name ( void ) const { return m_Name.c_str(); } - inline size_t Pos ( void ) const { return m_Pos; } - inline bool PosChanged ( void ) const { return m_PosChanged; } - inline int ID ( void ) const { return m_ID; } - inline int ColWidth ( void ) const { return m_ColWidth; } - inline LanguageStringID LangID ( void ) const { return m_LangID; } - - void SetColWidth ( int ColWidth ) + inline LPCSTR Name(void) const { return m_Name.c_str(); } + inline size_t Pos(void) const { return m_Pos; } + inline bool PosChanged(void) const { return m_PosChanged; } + inline int ID(void) const { return m_ID; } + inline int ColWidth(void) const { return m_ColWidth; } + inline LanguageStringID LangID(void) const { return m_LangID; } + + void SetColWidth(int ColWidth) { m_ColWidth = ColWidth; - g_Settings->SaveDwordIndex(RomBrowser_WidthIndex,m_ID,m_ColWidth); + g_Settings->SaveDwordIndex(RomBrowser_WidthIndex, m_ID, m_ColWidth); } - void SetColPos ( int Pos) + void SetColPos(int Pos) { m_Pos = Pos; - g_Settings->SaveDwordIndex(RomBrowser_PosIndex,m_ID,m_Pos); + g_Settings->SaveDwordIndex(RomBrowser_PosIndex, m_ID, m_Pos); m_PosChanged = true; } - void ResetPos ( void ) + void ResetPos(void) { m_Pos = m_DefaultPos; - g_Settings->DeleteSettingIndex(RomBrowser_PosIndex,m_ID); + g_Settings->DeleteSettingIndex(RomBrowser_PosIndex, m_ID); m_PosChanged = false; } }; @@ -77,24 +77,26 @@ struct SORT_FIELD { }; class C7zip; -class CRomBrowser +class CRomBrowser { enum { IDC_ROMLIST = 223 }; - enum { RB_FileName = 0, RB_InternalName = 1, RB_GoodName = 2, - RB_Status = 3, RB_RomSize = 4, RB_CoreNotes = 5, - RB_PluginNotes = 6, RB_UserNotes = 7, RB_CartridgeID = 8, - RB_Manufacturer = 9, RB_Country = 10, RB_Developer = 11, - RB_Crc1 = 12, RB_Crc2 = 13, RB_CICChip = 14, - RB_ReleaseDate = 15, RB_Genre = 16, RB_Players = 17, - RB_ForceFeedback = 18, RB_FileFormat = 19 }; + enum { + RB_FileName = 0, RB_InternalName = 1, RB_GoodName = 2, + RB_Status = 3, RB_RomSize = 4, RB_CoreNotes = 5, + RB_PluginNotes = 6, RB_UserNotes = 7, RB_CartridgeID = 8, + RB_Manufacturer = 9, RB_Country = 10, RB_Developer = 11, + RB_Crc1 = 12, RB_Crc2 = 13, RB_CICChip = 14, + RB_ReleaseDate = 15, RB_Genre = 16, RB_Players = 17, + RB_ForceFeedback = 18, RB_FileFormat = 19 + }; enum FILE_FORMAT { Format_Uncompressed, Format_Zip, Format_7zip, - } ; + }; - enum + enum { NoOfSortKeys = 3 }; @@ -146,67 +148,66 @@ class CRomBrowser CIniFile * m_ZipIniFile; bool m_AllowSelectionLastRom; - void AddFileNameToList ( strlist & FileList, const stdstr & Directory, CPath & File ); - void AddRomToList ( const char * RomLocation, const char * lpLastRom ); - void AddRomInfoToList ( ROM_INFO &RomInfo, const char * lpLastRom ); - void AllocateBrushs ( void ); - DWORD AsciiToHex ( char * HexValue ); - static void ByteSwapRomData ( BYTE * Data, int DataLen ); - int CalcSortPosition ( DWORD lParam ); - void CreateRomListControl ( void ); - void DeallocateBrushs ( void ); - void FillRomExtensionInfo ( ROM_INFO * pRomInfo ); - bool FillRomInfo ( ROM_INFO * pRomInfo ); - void FillRomList ( strlist & FileList, const CPath & BaseDirectory, const stdstr & Directory, const char * lpLastRom ); - void FixRomListWindow ( void ); - static int GetCicChipID ( BYTE * RomData ); - bool LoadDataFromRomFile ( char * FileName, BYTE * Data,int DataLen, int * RomSize, FILE_FORMAT & FileFormat ); - void LoadRomList ( void ); - void MenuSetText ( HMENU hMenu, int MenuPos, const wchar_t * Title, char * ShortCut); - void SaveRomList ( strlist & FileList ); - void RomList_ColoumnSortList ( DWORD pnmh ); - void RomList_GetDispInfo ( DWORD pnmh ); - void RomList_OpenRom ( DWORD pnmh ); - void RomList_PopupMenu ( DWORD pnmh ); - void RomList_SortList ( void ); - bool GetRomFileNames ( strlist & FileList, const CPath & BaseDirectory, const stdstr & Directory, bool InWatchThread ); - MD5 RomListHash ( strlist & FileList ); + void AddFileNameToList(strlist & FileList, const stdstr & Directory, CPath & File); + void AddRomToList(const char * RomLocation, const char * lpLastRom); + void AddRomInfoToList(ROM_INFO &RomInfo, const char * lpLastRom); + void AllocateBrushs(void); + static void ByteSwapRomData(BYTE * Data, int DataLen); + int CalcSortPosition(DWORD lParam); + void CreateRomListControl(void); + void DeallocateBrushs(void); + void FillRomExtensionInfo(ROM_INFO * pRomInfo); + bool FillRomInfo(ROM_INFO * pRomInfo); + void FillRomList(strlist & FileList, const CPath & BaseDirectory, const stdstr & Directory, const char * lpLastRom); + void FixRomListWindow(void); + static int GetCicChipID(BYTE * RomData); + bool LoadDataFromRomFile(char * FileName, BYTE * Data, int DataLen, int * RomSize, FILE_FORMAT & FileFormat); + void LoadRomList(void); + void MenuSetText(HMENU hMenu, int MenuPos, const wchar_t * Title, char * ShortCut); + void SaveRomList(strlist & FileList); + void RomList_ColoumnSortList(DWORD pnmh); + void RomList_GetDispInfo(DWORD pnmh); + void RomList_OpenRom(DWORD pnmh); + void RomList_PopupMenu(DWORD pnmh); + void RomList_SortList(void); + bool GetRomFileNames(strlist & FileList, const CPath & BaseDirectory, const stdstr & Directory, bool InWatchThread); + MD5 RomListHash(strlist & FileList); - static void __stdcall NotificationCB ( LPCWSTR Status, CRomBrowser * _this ); + static void __stdcall NotificationCB(LPCWSTR Status, CRomBrowser * _this); //Watch Directory Changed function HANDLE m_WatchThread, m_WatchStopEvent; DWORD m_WatchThreadID; stdstr m_WatchRomDir; - void WatchThreadStart (void); - void WatchThreadStop (void); - bool RomDirNeedsRefresh ( void ); // Called from watch thread - static void WatchRomDirChanged ( CRomBrowser * _this ); - static void RefreshRomBrowserStatic ( CRomBrowser * _this ); - static void AddField (ROMBROWSER_FIELDS_LIST & Fields, LPCSTR Name, int Pos,int ID,int Width,LanguageStringID LangID, bool UseDefault); + void WatchThreadStart(void); + void WatchThreadStop(void); + bool RomDirNeedsRefresh(void); // Called from watch thread + static void WatchRomDirChanged(CRomBrowser * _this); + static void RefreshRomBrowserStatic(CRomBrowser * _this); + static void AddField(ROMBROWSER_FIELDS_LIST & Fields, LPCSTR Name, int Pos, int ID, int Width, LanguageStringID LangID, bool UseDefault); //Callback - static int CALLBACK SelectRomDirCallBack ( HWND hwnd,DWORD uMsg,DWORD lp, DWORD lpData ); - static int CALLBACK RomList_CompareItems ( DWORD lParam1, DWORD lParam2, DWORD lParamSort ); + static int CALLBACK SelectRomDirCallBack(HWND hwnd, DWORD uMsg, DWORD lp, DWORD lpData); + static int CALLBACK RomList_CompareItems(DWORD lParam1, DWORD lParam2, DWORD lParamSort); public: - CRomBrowser ( HWND & hMainWindow, HWND & StatusWindow ); - ~CRomBrowser ( void ); - void HighLightLastRom ( void ); - void HideRomList ( void ); - void RefreshRomBrowser ( void ); - void ResetRomBrowserColomuns ( void ); - void ResizeRomList ( WORD nWidth, WORD nHeight ); - void RomBrowserToTop ( void ); - void RomBrowserMaximize ( bool Mazimize ) ; - bool RomBrowserVisible ( void ); - bool RomListDrawItem ( int idCtrl, DWORD lParam ); - bool RomListNotify ( int idCtrl, DWORD pnmh ); - void SaveRomListColoumnInfo ( void ); - void SelectRomDir ( void ); - void ShowRomList ( void ); - bool ShowingRomBrowser ( void ) { return m_ShowingRomBrowser; } - LPCSTR CurrentedSelectedRom ( void ) { return m_SelectedRom.c_str(); } + CRomBrowser(HWND & hMainWindow, HWND & StatusWindow); + ~CRomBrowser(void); + void HighLightLastRom(void); + void HideRomList(void); + void RefreshRomBrowser(void); + void ResetRomBrowserColomuns(void); + void ResizeRomList(WORD nWidth, WORD nHeight); + void RomBrowserToTop(void); + void RomBrowserMaximize(bool Mazimize); + bool RomBrowserVisible(void); + bool RomListDrawItem(int idCtrl, DWORD lParam); + bool RomListNotify(int idCtrl, DWORD pnmh); + void SaveRomListColoumnInfo(void); + void SelectRomDir(void); + void ShowRomList(void); + bool ShowingRomBrowser(void) { return m_ShowingRomBrowser; } + LPCSTR CurrentedSelectedRom(void) { return m_SelectedRom.c_str(); } - static void GetFieldInfo ( ROMBROWSER_FIELDS_LIST & Fields, bool UseDefault = false ); + static void GetFieldInfo(ROMBROWSER_FIELDS_LIST & Fields, bool UseDefault = false); }; From 9f87dbf30d55ff7b048d5d5283f9ef60760c515c Mon Sep 17 00:00:00 2001 From: zilmar Date: Sat, 7 Nov 2015 14:32:23 +1100 Subject: [PATCH 082/213] [Project64] Split cheat class between UI and code --- Source/Project64/N64 System/Cheat Class.cpp | 1746 ++--------------- Source/Project64/N64 System/Cheat Class.h | 95 +- .../N64 System/Mips/System Events.cpp | 41 +- .../Project64/N64 System/Mips/System Events.h | 74 +- Source/Project64/N64 System/N64 Class.cpp | 104 +- Source/Project64/N64 System/N64 Class.h | 5 +- Source/Project64/N64 System/N64 Types.h | 72 +- Source/Project64/Project64.vcproj | 8 + Source/Project64/Project64.vcxproj | 2 + Source/Project64/Project64.vcxproj.filters | 6 + Source/Project64/User Interface.h | 1 + .../User Interface/Cheat Class UI.cpp | 1545 +++++++++++++++ .../Project64/User Interface/Cheat Class UI.h | 71 + Source/Project64/User Interface/Gui Class.cpp | 1518 +++++++------- Source/Project64/User Interface/Gui Class.h | 145 +- .../User Interface/Main Menu Class.cpp | 10 +- 16 files changed, 2776 insertions(+), 2667 deletions(-) create mode 100644 Source/Project64/User Interface/Cheat Class UI.cpp create mode 100644 Source/Project64/User Interface/Cheat Class UI.h diff --git a/Source/Project64/N64 System/Cheat Class.cpp b/Source/Project64/N64 System/Cheat Class.cpp index 0ec58f1e0..db795f744 100644 --- a/Source/Project64/N64 System/Cheat Class.cpp +++ b/Source/Project64/N64 System/Cheat Class.cpp @@ -10,34 +10,16 @@ ****************************************************************************/ #include "stdafx.h" -#include -#include -#include "Settings/SettingType/SettingsType-Cheats.h" -enum { WM_EDITCHEAT = WM_USER + 0x120 }; -enum { UM_CHANGECODEEXTENSION = WM_USER + 0x121 }; - -CCheats::CCheats (const CN64Rom * Rom ) : - m_Rom(Rom), - m_rcList(new RECT), - m_rcAdd(new RECT), - m_EditCheat(-1), - m_DeleteingEntries(false), - m_CheatSelectionChanged(false) +CCheats::CCheats() { - m_Window = NULL; - m_hSelectCheat = NULL; - m_AddCheat = NULL; - m_hCheatTree = NULL; } CCheats::~CCheats() { - delete m_rcList; - delete m_rcAdd; } -bool CCheats::LoadCode (int CheatNo, LPCSTR CheatString) +bool CCheats::LoadCode(int CheatNo, const char * CheatString) { if (!IsValid16BitCode(CheatString)) { @@ -51,34 +33,41 @@ bool CCheats::LoadCode (int CheatNo, LPCSTR CheatString) { GAMESHARK_CODE CodeEntry; - CodeEntry.Command = AsciiToHex(ReadPos); - ReadPos = strchr(ReadPos,' '); + CodeEntry.Command = std::strtoul(ReadPos, 0, 16); + ReadPos = strchr(ReadPos, ' '); if (ReadPos == NULL) { break; } - ReadPos +=1; + ReadPos += 1; - if (strncmp(ReadPos,"????",4) == 0) { + if (strncmp(ReadPos, "????", 4) == 0) + { if (CheatNo < 0 || CheatNo > MaxCheats) { return false; } - stdstr CheatExt = g_Settings->LoadStringIndex(Cheat_Extension,CheatNo); + stdstr CheatExt = g_Settings->LoadStringIndex(Cheat_Extension, CheatNo); if (CheatExt.empty()) { return false; } - CodeEntry.Value = CheatExt[0] == '$'?(WORD)AsciiToHex(&CheatExt.c_str()[1]):(WORD)atol(CheatExt.c_str()); - } else if (strncmp(ReadPos,"??",2) == 0) { + CodeEntry.Value = CheatExt[0] == '$' ? (uint16_t)std::strtoul(&CheatExt.c_str()[1], 0, 16) : (uint16_t)atol(CheatExt.c_str()); + } + else if (strncmp(ReadPos, "??", 2) == 0) + { if (CheatNo < 0 || CheatNo > MaxCheats) { return false; } - stdstr CheatExt = g_Settings->LoadStringIndex(Cheat_Extension,CheatNo); + stdstr CheatExt = g_Settings->LoadStringIndex(Cheat_Extension, CheatNo); if (CheatExt.empty()) { return false; } - CodeEntry.Value = (BYTE)(AsciiToHex(ReadPos)); - CodeEntry.Value |= (CheatExt[0] == '$'?(BYTE)AsciiToHex(&CheatExt.c_str()[1]):(BYTE)atol(CheatExt.c_str())) << 16; - } else if (strncmp(&ReadPos[2],"??",2) == 0) { + CodeEntry.Value = (uint8_t)(std::strtoul(ReadPos, 0, 16)); + CodeEntry.Value |= (CheatExt[0] == '$' ? (uint8_t)std::strtoul(&CheatExt.c_str()[1], 0, 16) : (uint8_t)atol(CheatExt.c_str())) << 16; + } + else if (strncmp(&ReadPos[2], "??", 2) == 0) + { if (CheatNo < 0 || CheatNo > MaxCheats) { return false; } - stdstr CheatExt = g_Settings->LoadStringIndex(Cheat_Extension,CheatNo); + stdstr CheatExt = g_Settings->LoadStringIndex(Cheat_Extension, CheatNo); if (CheatExt.empty()) { return false; } - CodeEntry.Value = (WORD)(AsciiToHex(ReadPos) << 16); - CodeEntry.Value |= CheatExt[0] == '$'?(BYTE)AsciiToHex(&CheatExt.c_str()[1]):(BYTE)atol(CheatExt.c_str()); - } else { - CodeEntry.Value = (WORD)AsciiToHex(ReadPos); + CodeEntry.Value = (uint16_t)(std::strtoul(ReadPos, 0, 16) << 16); + CodeEntry.Value |= CheatExt[0] == '$' ? (uint8_t)std::strtoul(&CheatExt.c_str()[1], 0, 16) : (uint8_t)atol(CheatExt.c_str()); + } + else + { + CodeEntry.Value = (uint16_t)std::strtoul(ReadPos, 0, 16); } Code.push_back(CodeEntry); - - ReadPos = strchr(ReadPos,','); + + ReadPos = strchr(ReadPos, ','); if (ReadPos == NULL) { continue; @@ -94,23 +83,23 @@ bool CCheats::LoadCode (int CheatNo, LPCSTR CheatString) return true; } -void CCheats::LoadPermCheats (CPlugins * Plugins) +void CCheats::LoadPermCheats(CPlugins * Plugins) { if (g_Settings->LoadBool(Debugger_DisableGameFixes)) { return; } - for (int CheatNo = 0; CheatNo < MaxCheats; CheatNo ++ ) + for (int CheatNo = 0; CheatNo < MaxCheats; CheatNo++) { stdstr LineEntry; - if (!g_Settings->LoadStringIndex(Rdb_GameCheatFix,CheatNo,LineEntry) || LineEntry.empty()) + if (!g_Settings->LoadStringIndex(Rdb_GameCheatFix, CheatNo, LineEntry) || LineEntry.empty()) { break; } stdstr CheatPlugins; bool LoadEntry = true; - if (g_Settings->LoadStringIndex(Rdb_GameCheatFixPlugin,CheatNo,CheatPlugins) && !CheatPlugins.empty()) + if (g_Settings->LoadStringIndex(Rdb_GameCheatFixPlugin, CheatNo, CheatPlugins) && !CheatPlugins.empty()) { LoadEntry = false; @@ -118,22 +107,22 @@ void CCheats::LoadPermCheats (CPlugins * Plugins) for (size_t i = 0, n = PluginList.size(); i < n; i++) { stdstr PluginName = PluginList[i].Trim(); - if (strstr(Plugins->Gfx()->PluginName(),PluginName.c_str()) != NULL) + if (strstr(Plugins->Gfx()->PluginName(), PluginName.c_str()) != NULL) { LoadEntry = true; break; } - if (strstr(Plugins->Audio()->PluginName(),PluginName.c_str()) != NULL) + if (strstr(Plugins->Audio()->PluginName(), PluginName.c_str()) != NULL) { LoadEntry = true; break; } - if (strstr(Plugins->RSP()->PluginName(),PluginName.c_str()) != NULL) + if (strstr(Plugins->RSP()->PluginName(), PluginName.c_str()) != NULL) { LoadEntry = true; break; } - if (strstr(Plugins->Control()->PluginName(),PluginName.c_str()) != NULL) + if (strstr(Plugins->Control()->PluginName(), PluginName.c_str()) != NULL) { LoadEntry = true; break; @@ -148,47 +137,47 @@ void CCheats::LoadPermCheats (CPlugins * Plugins) } } -void CCheats::LoadCheats(bool DisableSelected, CPlugins * Plugins) +void CCheats::LoadCheats(bool DisableSelected, CPlugins * Plugins) { - m_CheatSelectionChanged = false; m_Codes.clear(); LoadPermCheats(Plugins); - for (int CheatNo = 0; CheatNo < MaxCheats; CheatNo ++ ) + for (int CheatNo = 0; CheatNo < MaxCheats; CheatNo++) { - stdstr LineEntry = g_Settings->LoadStringIndex(Cheat_Entry,CheatNo); + stdstr LineEntry = g_Settings->LoadStringIndex(Cheat_Entry, CheatNo); if (LineEntry.empty()) { break; } - if (!g_Settings->LoadBoolIndex(Cheat_Active,CheatNo)) + if (!g_Settings->LoadBoolIndex(Cheat_Active, CheatNo)) { continue; } if (DisableSelected) { - g_Settings->SaveBoolIndex(Cheat_Active,CheatNo,false); + g_Settings->SaveBoolIndex(Cheat_Active, CheatNo, false); continue; } //Find the start and end of the name which is surrounded in "" int StartOfName = LineEntry.find("\""); if (StartOfName == -1) { continue; } - int EndOfName = LineEntry.find("\"",StartOfName + 1); + int EndOfName = LineEntry.find("\"", StartOfName + 1); if (EndOfName == -1) { continue; } - + LoadCode(CheatNo, &LineEntry.c_str()[EndOfName + 2]); } } /******************************************************************************************** - ConvertXP64Address +ConvertXP64Address - Purpose: Decode encoded XP64 address to physical address - Parameters: - Returns: - Author: Witten +Purpose: Decode encoded XP64 address to physical address +Parameters: +Returns: +Author: Witten ********************************************************************************************/ -DWORD ConvertXP64Address (DWORD Address) { - DWORD tmpAddress; +uint32_t ConvertXP64Address(uint32_t Address) +{ + uint32_t tmpAddress; tmpAddress = (Address ^ 0x68000000) & 0xFF000000; tmpAddress += ((Address + 0x002B0000) ^ 0x00810000) & 0x00FF0000; @@ -198,16 +187,17 @@ DWORD ConvertXP64Address (DWORD Address) { } /******************************************************************************************** - ConvertXP64Value +ConvertXP64Value - Purpose: Decode encoded XP64 value - Parameters: - Returns: - Author: Witten +Purpose: Decode encoded XP64 value +Parameters: +Returns: +Author: Witten ********************************************************************************************/ -WORD ConvertXP64Value (WORD Value) { - WORD tmpValue; +uint16_t ConvertXP64Value(uint16_t Value) +{ + uint16_t tmpValue; tmpValue = ((Value + 0x2B00) ^ 0x8400) & 0xFF00; tmpValue += ((Value + 0x002B) ^ 0x0085) & 0x00FF; @@ -216,49 +206,49 @@ WORD ConvertXP64Value (WORD Value) { void CCheats::ApplyCheats(CMipsMemory * MMU) { - for (size_t CurrentCheat = 0; CurrentCheat < m_Codes.size(); CurrentCheat ++) + for (size_t CurrentCheat = 0; CurrentCheat < m_Codes.size(); CurrentCheat++) { const CODES & CodeEntry = m_Codes[CurrentCheat]; for (size_t CurrentEntry = 0; CurrentEntry < CodeEntry.size();) { - CurrentEntry += ApplyCheatEntry(MMU, CodeEntry,CurrentEntry, true); + CurrentEntry += ApplyCheatEntry(MMU, CodeEntry, CurrentEntry, true); } } } -void CCheats::ApplyGSButton (CMipsMemory * MMU) +void CCheats::ApplyGSButton(CMipsMemory * MMU) { - DWORD Address; - for (size_t CurrentCheat = 0; CurrentCheat < m_Codes.size(); CurrentCheat ++) + uint32_t Address; + for (size_t CurrentCheat = 0; CurrentCheat < m_Codes.size(); CurrentCheat++) { const CODES & CodeEntry = m_Codes[CurrentCheat]; - for (size_t CurrentEntry = 0; CurrentEntry < CodeEntry.size(); CurrentEntry ++) + for (size_t CurrentEntry = 0; CurrentEntry < CodeEntry.size(); CurrentEntry++) { const GAMESHARK_CODE & Code = CodeEntry[CurrentEntry]; switch (Code.Command & 0xFF000000) { case 0x88000000: Address = 0x80000000 | (Code.Command & 0xFFFFFF); - MMU->SB_VAddr(Address,(BYTE)Code.Value); + MMU->SB_VAddr(Address, (uint8_t)Code.Value); break; case 0x89000000: Address = 0x80000000 | (Code.Command & 0xFFFFFF); - MMU->SH_VAddr(Address,Code.Value); + MMU->SH_VAddr(Address, Code.Value); break; - // Xplorer64 + // Xplorer64 case 0xA8000000: Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF); - MMU->SB_VAddr(Address,(BYTE)ConvertXP64Value(Code.Value)); + MMU->SB_VAddr(Address, (uint8_t)ConvertXP64Value(Code.Value)); break; case 0xA9000000: Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF); - MMU->SH_VAddr(Address,ConvertXP64Value(Code.Value)); + MMU->SH_VAddr(Address, ConvertXP64Value(Code.Value)); break; } } } } -bool CCheats::IsValid16BitCode (LPCSTR CheatString) const +bool CCheats::IsValid16BitCode(const char * CheatString) { const char * ReadPos = CheatString; bool GSButtonCheat = false, FirstEntry = true; @@ -267,15 +257,15 @@ bool CCheats::IsValid16BitCode (LPCSTR CheatString) const { GAMESHARK_CODE CodeEntry; - CodeEntry.Command = AsciiToHex(ReadPos); - ReadPos = strchr(ReadPos,' '); + CodeEntry.Command = std::strtoul(ReadPos, 0, 16); + ReadPos = strchr(ReadPos, ' '); if (ReadPos == NULL) { break; } - ReadPos +=1; + ReadPos += 1; //validate Code Entry switch (CodeEntry.Command & 0xFF000000) { case 0x50000000: - case 0x80000000: + case 0x80000000: case 0xA0000000: case 0xD0000000: case 0xD2000000: @@ -294,11 +284,11 @@ bool CCheats::IsValid16BitCode (LPCSTR CheatString) const break; case 0x88000000: case 0xA8000000: - if (FirstEntry) { GSButtonCheat = true; } + if (FirstEntry) { GSButtonCheat = true; } if (!GSButtonCheat) { return false; } break; case 0x89000000: - if (FirstEntry) { GSButtonCheat = true; } + if (FirstEntry) { GSButtonCheat = true; } if (!GSButtonCheat) { return false; } if (((CodeEntry.Command & 0xFFFFFF) & 1) == 1) { @@ -306,7 +296,7 @@ bool CCheats::IsValid16BitCode (LPCSTR CheatString) const } break; case 0xA9000000: - if (FirstEntry) { GSButtonCheat = true; } + if (FirstEntry) { GSButtonCheat = true; } if (!GSButtonCheat) { return false; } if (((ConvertXP64Address(CodeEntry.Command) & 0xFFFFFF) & 1) == 1) { @@ -327,7 +317,7 @@ bool CCheats::IsValid16BitCode (LPCSTR CheatString) const FirstEntry = false; - ReadPos = strchr(ReadPos,','); + ReadPos = strchr(ReadPos, ','); if (ReadPos == NULL) { continue; @@ -337,1585 +327,147 @@ bool CCheats::IsValid16BitCode (LPCSTR CheatString) const return true; } -int CCheats::ApplyCheatEntry (CMipsMemory * MMU, const CODES & CodeEntry, int CurrentEntry, bool Execute ) +int CCheats::ApplyCheatEntry(CMipsMemory * MMU, const CODES & CodeEntry, int CurrentEntry, bool Execute) { if (CurrentEntry < 0 || CurrentEntry >= (int)CodeEntry.size()) { return 0; } const GAMESHARK_CODE & Code = CodeEntry[CurrentEntry]; - DWORD Address; - WORD wMemory; - BYTE bMemory; + uint32_t Address; + uint16_t wMemory; + uint8_t bMemory; - switch (Code.Command & 0xFF000000) { - // Gameshark / AR + switch (Code.Command & 0xFF000000) + { + // Gameshark / AR case 0x50000000: // Added by Witten (witten@pj64cheats.net) + { + if ((CurrentEntry + 1) >= (int)CodeEntry.size()) { - if ((CurrentEntry + 1) >= (int)CodeEntry.size()) - { - return 1; - } - - const GAMESHARK_CODE & NextCodeEntry = CodeEntry[CurrentEntry + 1]; - int numrepeats = (Code.Command & 0x0000FF00) >> 8; - int offset = Code.Command & 0x000000FF; - int incr = Code.Value; - int i; - - switch (NextCodeEntry.Command & 0xFF000000) { - case 0x10000000: // Xplorer64 - case 0x80000000: - Address = 0x80000000 | (NextCodeEntry.Command & 0xFFFFFF); - wMemory = NextCodeEntry.Value; - for (i=0; iSB_VAddr(Address,(BYTE)wMemory); - Address += offset; - wMemory += (WORD)incr; - } - return 2; - case 0x11000000: // Xplorer64 - case 0x81000000: - Address = 0x80000000 | (NextCodeEntry.Command & 0xFFFFFF); - wMemory = NextCodeEntry.Value; - for (i=0; iSH_VAddr(Address,wMemory); - Address += offset; - wMemory += (WORD)incr; - } - return 2; - default: return 1; - } + return 1; } - break; + + const GAMESHARK_CODE & NextCodeEntry = CodeEntry[CurrentEntry + 1]; + int numrepeats = (Code.Command & 0x0000FF00) >> 8; + int offset = Code.Command & 0x000000FF; + int incr = Code.Value; + int i; + + switch (NextCodeEntry.Command & 0xFF000000) { + case 0x10000000: // Xplorer64 + case 0x80000000: + Address = 0x80000000 | (NextCodeEntry.Command & 0xFFFFFF); + wMemory = NextCodeEntry.Value; + for (i = 0; i < numrepeats; i++) + { + MMU->SB_VAddr(Address, (uint8_t)wMemory); + Address += offset; + wMemory += (uint16_t)incr; + } + return 2; + case 0x11000000: // Xplorer64 + case 0x81000000: + Address = 0x80000000 | (NextCodeEntry.Command & 0xFFFFFF); + wMemory = NextCodeEntry.Value; + for (i = 0; i < numrepeats; i++) + { + MMU->SH_VAddr(Address, wMemory); + Address += offset; + wMemory += (uint16_t)incr; + } + return 2; + default: return 1; + } + } + break; case 0x80000000: Address = 0x80000000 | (Code.Command & 0xFFFFFF); - if (Execute) { MMU->SB_VAddr(Address,(BYTE)Code.Value); } + if (Execute) { MMU->SB_VAddr(Address, (uint8_t)Code.Value); } break; case 0x81000000: Address = 0x80000000 | (Code.Command & 0xFFFFFF); - if (Execute) { MMU->SH_VAddr(Address,Code.Value); } + if (Execute) { MMU->SH_VAddr(Address, Code.Value); } break; case 0xA0000000: Address = 0xA0000000 | (Code.Command & 0xFFFFFF); - if (Execute) { MMU->SB_VAddr(Address,(BYTE)Code.Value); } + if (Execute) { MMU->SB_VAddr(Address, (uint8_t)Code.Value); } break; case 0xA1000000: Address = 0xA0000000 | (Code.Command & 0xFFFFFF); - if (Execute) { MMU->SH_VAddr(Address,Code.Value); } + if (Execute) { MMU->SH_VAddr(Address, Code.Value); } break; case 0xD0000000: // Added by Witten (witten@pj64cheats.net) Address = 0x80000000 | (Code.Command & 0xFFFFFF); - MMU->LB_VAddr(Address,bMemory); + MMU->LB_VAddr(Address, bMemory); if (bMemory != Code.Value) { Execute = false; } - return ApplyCheatEntry(MMU,CodeEntry,CurrentEntry + 1,Execute) + 1; + return ApplyCheatEntry(MMU, CodeEntry, CurrentEntry + 1, Execute) + 1; case 0xD1000000: // Added by Witten (witten@pj64cheats.net) Address = 0x80000000 | (Code.Command & 0xFFFFFF); - MMU->LH_VAddr(Address,wMemory); + MMU->LH_VAddr(Address, wMemory); if (wMemory != Code.Value) { Execute = false; } - return ApplyCheatEntry(MMU,CodeEntry,CurrentEntry + 1,Execute) + 1; + return ApplyCheatEntry(MMU, CodeEntry, CurrentEntry + 1, Execute) + 1; case 0xD2000000: // Added by Witten (witten@pj64cheats.net) Address = 0x80000000 | (Code.Command & 0xFFFFFF); - MMU->LB_VAddr(Address,bMemory); + MMU->LB_VAddr(Address, bMemory); if (bMemory == Code.Value) { Execute = false; } - return ApplyCheatEntry(MMU,CodeEntry,CurrentEntry + 1,Execute) + 1; + return ApplyCheatEntry(MMU, CodeEntry, CurrentEntry + 1, Execute) + 1; case 0xD3000000: // Added by Witten (witten@pj64cheats.net) Address = 0x80000000 | (Code.Command & 0xFFFFFF); - MMU->LH_VAddr(Address,wMemory); + MMU->LH_VAddr(Address, wMemory); if (wMemory == Code.Value) { Execute = false; } - return ApplyCheatEntry(MMU,CodeEntry,CurrentEntry + 1,Execute) + 1; + return ApplyCheatEntry(MMU, CodeEntry, CurrentEntry + 1, Execute) + 1; - // Xplorer64 (Author: Witten) + // Xplorer64 (Author: Witten) case 0x30000000: case 0x82000000: case 0x84000000: Address = 0x80000000 | (Code.Command & 0xFFFFFF); - if (Execute) { MMU->SB_VAddr(Address,(BYTE)Code.Value); } + if (Execute) { MMU->SB_VAddr(Address, (uint8_t)Code.Value); } break; case 0x31000000: case 0x83000000: case 0x85000000: Address = 0x80000000 | (Code.Command & 0xFFFFFF); - if (Execute) { MMU->SH_VAddr(Address,Code.Value); } + if (Execute) { MMU->SH_VAddr(Address, Code.Value); } break; case 0xE8000000: Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF); - if (Execute) { MMU->SB_VAddr(Address,(BYTE)ConvertXP64Value(Code.Value)); } + if (Execute) { MMU->SB_VAddr(Address, (uint8_t)ConvertXP64Value(Code.Value)); } break; case 0xE9000000: Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF); - if (Execute) { MMU->SH_VAddr(Address,ConvertXP64Value(Code.Value)); } + if (Execute) { MMU->SH_VAddr(Address, ConvertXP64Value(Code.Value)); } break; case 0xC8000000: Address = 0xA0000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF); - if (Execute) { MMU->SB_VAddr(Address,(BYTE)Code.Value); } + if (Execute) { MMU->SB_VAddr(Address, (uint8_t)Code.Value); } break; case 0xC9000000: Address = 0xA0000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF); - if (Execute) { MMU->SH_VAddr(Address,ConvertXP64Value(Code.Value)); } + if (Execute) { MMU->SH_VAddr(Address, ConvertXP64Value(Code.Value)); } break; case 0xB8000000: Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF); - MMU->LB_VAddr(Address,bMemory); + MMU->LB_VAddr(Address, bMemory); if (bMemory != ConvertXP64Value(Code.Value)) { Execute = false; } - return ApplyCheatEntry(MMU,CodeEntry,CurrentEntry + 1,Execute) + 1; + return ApplyCheatEntry(MMU, CodeEntry, CurrentEntry + 1, Execute) + 1; case 0xB9000000: Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF); - MMU->LH_VAddr(Address,wMemory); + MMU->LH_VAddr(Address, wMemory); if (wMemory != ConvertXP64Value(Code.Value)) { Execute = false; } - return ApplyCheatEntry(MMU,CodeEntry,CurrentEntry + 1,Execute) + 1; + return ApplyCheatEntry(MMU, CodeEntry, CurrentEntry + 1, Execute) + 1; case 0xBA000000: Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF); - MMU->LB_VAddr(Address,bMemory); + MMU->LB_VAddr(Address, bMemory); if (bMemory == ConvertXP64Value(Code.Value)) { Execute = false; } - return ApplyCheatEntry(MMU,CodeEntry,CurrentEntry + 1,Execute) + 1; + return ApplyCheatEntry(MMU, CodeEntry, CurrentEntry + 1, Execute) + 1; case 0xBB000000: Address = 0x80000000 | (ConvertXP64Address(Code.Command) & 0xFFFFFF); - MMU->LH_VAddr(Address,wMemory); + MMU->LH_VAddr(Address, wMemory); if (wMemory == ConvertXP64Value(Code.Value)) { Execute = false; } - return ApplyCheatEntry(MMU,CodeEntry,CurrentEntry + 1,Execute) + 1; + return ApplyCheatEntry(MMU, CodeEntry, CurrentEntry + 1, Execute) + 1; case 0: return MaxGSEntries; break; } return 1; } - - -DWORD CCheats::AsciiToHex (const char * HexValue) { - DWORD Count, Finish, Value = 0; - - Finish = strlen(HexValue); - if (Finish > 8 ) { Finish = 8; } - - for (Count = 0; Count < Finish; Count++){ - Value = (Value << 4); - switch( HexValue[Count] ) { - case '0': break; - case '1': Value += 1; break; - case '2': Value += 2; break; - case '3': Value += 3; break; - case '4': Value += 4; break; - case '5': Value += 5; break; - case '6': Value += 6; break; - case '7': Value += 7; break; - case '8': Value += 8; break; - case '9': Value += 9; break; - case 'A': Value += 10; break; - case 'a': Value += 10; break; - case 'B': Value += 11; break; - case 'b': Value += 11; break; - case 'C': Value += 12; break; - case 'c': Value += 12; break; - case 'D': Value += 13; break; - case 'd': Value += 13; break; - case 'E': Value += 14; break; - case 'e': Value += 14; break; - case 'F': Value += 15; break; - case 'f': Value += 15; break; - default: - Value = (Value >> 4); - Count = Finish; - } - } - return Value; -} - -void CCheats::AddCodeLayers (int CheatNumber, const stdstr &CheatName, HWND hParent, bool CheatActive) { - TV_INSERTSTRUCT tv; - - //Work out text to add - char Text[500], Item[500]; - if (CheatName.length() > (sizeof(Text) - 5)) { g_Notify->BreakPoint(__FILEW__,__LINE__); } - strcpy(Text,CheatName.c_str()); - if (strchr(Text,'\\') > 0) { *strchr(Text,'\\') = 0; } - - //See if text is already added - tv.item.mask = TVIF_TEXT; - tv.item.pszText = Item; - tv.item.cchTextMax = sizeof(Item); - tv.item.hItem = TreeView_GetChild((HWND)m_hCheatTree,hParent); - while (tv.item.hItem) { - TreeView_GetItem((HWND)m_hCheatTree,&tv.item); - if (strcmp(Text,Item) == 0) { - //If already exists then just use existing one - int State = TV_GetCheckState(m_hCheatTree,(HWND)tv.item.hItem); - if ((CheatActive && State == TV_STATE_CLEAR) || (!CheatActive && State == TV_STATE_CHECKED)) { - TV_SetCheckState(m_hCheatTree,(HWND)tv.item.hItem,TV_STATE_INDETERMINATE); - } - size_t StartPos = strlen(Text) + 1; - stdstr TempCheatName; - if (StartPos < CheatName.length()) - { - TempCheatName = CheatName.substr(StartPos); - } - AddCodeLayers(CheatNumber,TempCheatName, (HWND)tv.item.hItem, CheatActive); - return; - } - tv.item.hItem = TreeView_GetNextSibling((HWND)m_hCheatTree,tv.item.hItem); - } - - //Add to dialog - tv.hInsertAfter = TVI_SORT; - tv.item.mask = TVIF_TEXT | TVIF_PARAM; - tv.item.pszText = Text; - tv.item.lParam = CheatNumber; - tv.hParent = (HTREEITEM)hParent; - hParent = (HWND)TreeView_InsertItem((HWND)m_hCheatTree,&tv); - TV_SetCheckState(m_hCheatTree,hParent,CheatActive?TV_STATE_CHECKED:TV_STATE_CLEAR); - - if (strcmp(Text,CheatName.c_str()) == 0) { return; } - AddCodeLayers(CheatNumber,(stdstr)(CheatName.substr(strlen(Text) + 1)), hParent, CheatActive); -} - -stdstr CCheats::GetCheatName(int CheatNo, bool AddExtension) const -{ - if (CheatNo > MaxCheats) { g_Notify->BreakPoint(__FILEW__,__LINE__); } - stdstr LineEntry = g_Settings->LoadStringIndex(Cheat_Entry,CheatNo); - if (LineEntry.length() == 0) { return LineEntry; } - - //Find the start and end of the name which is surrounded in "" - int StartOfName = LineEntry.find("\""); - if (StartOfName == -1) { return stdstr(""); } - int EndOfName = LineEntry.find("\"",StartOfName + 1); - if (EndOfName == -1) { return stdstr(""); } - - stdstr Name = LineEntry.substr(StartOfName + 1, EndOfName - StartOfName - 1 ); - LPCSTR CodeString = &(LineEntry.c_str())[EndOfName + 2]; - if (!IsValid16BitCode(CodeString)) - { - Name.Format("*** %s",Name.c_str()); - Name.Replace("\\","\\*** "); - } - if (AddExtension && CheatUsesCodeExtensions(LineEntry)) { - stdstr CheatValue(g_Settings->LoadStringIndex(Cheat_Extension,CheatNo)); - Name.Format("%s (=>%s)",Name.c_str(),CheatValue.c_str()); - } - - return Name; -} - -bool CCheats::CheatUsesCodeExtensions (const stdstr &LineEntry) { - //Find the start and end of the name which is surronded in "" - if (LineEntry.length() == 0){ return false; } - int StartOfName = LineEntry.find("\""); - if (StartOfName == -1) { return false; } - int EndOfName = LineEntry.find("\"",StartOfName + 1); - if (EndOfName == -1) { return false; } - - //Read through the gameshark entries till you find a ?? - const char *ReadPos = &(LineEntry.c_str())[EndOfName + 2]; - bool CodeExtension = false; - - for (int i = 0; i < MaxGSEntries && CodeExtension == false; i ++) { - if (strchr(ReadPos,' ') == NULL) { break; } - ReadPos = strchr(ReadPos,' ') + 1; - if (ReadPos[0] == '?' && ReadPos[1]== '?') { CodeExtension = true; } - if (ReadPos[2] == '?' && ReadPos[3]== '?') { CodeExtension = true; } - if (strchr(ReadPos,',') == NULL) { continue; } - ReadPos = strchr(ReadPos,',') + 1; - } - return CodeExtension; -} - -void CCheats::RefreshCheatManager() -{ - if (m_Window == NULL) { return; } - - m_DeleteingEntries = true; - TreeView_DeleteAllItems((HWND)m_hCheatTree); - m_DeleteingEntries = false; - for (int i = 0; i < MaxCheats; i ++ ) { - stdstr Name = GetCheatName(i,true); - if (Name.length() == 0) { break; } - - AddCodeLayers(i,Name,(HWND)TVI_ROOT, g_Settings->LoadBoolIndex(Cheat_Active,i) != 0); - } -} - -stdstr CCheats::GetDlgItemStr (HWND hDlg, int nIDDlgItem) -{ - HWND hDlgItem = GetDlgItem(hDlg,nIDDlgItem); - int length = SendMessage(hDlgItem, WM_GETTEXTLENGTH, 0, 0); - if (length == 0) - { - return ""; - } - - stdstr Result; - Result.resize(length + 1); - - GetWindowText(hDlgItem,(char *)Result.c_str(),Result.length()); - - return Result; -} - -void CCheats::SelectCheats(HWND hParent, bool BlockExecution) { - if (m_Window != NULL) { - SetForegroundWindow((HWND)m_Window); - return; - } - if (hParent) - { - if (BlockExecution) - { - DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Cheats_Select), - (HWND)hParent, (DLGPROC)ManageCheatsProc,(LPARAM)this); - } else { - CreateDialogParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Cheats_Select), - (HWND)hParent, (DLGPROC)ManageCheatsProc,(LPARAM)this); - } - } -} - - -bool CCheats::CheatChanged (HWND hDlg) -{ - bool Changed = false; - if (m_EditName != GetDlgItemStr(hDlg,IDC_CODE_NAME) || - m_EditCode != GetDlgItemStr(hDlg,IDC_CHEAT_CODES) || - m_EditOptions != GetDlgItemStr(hDlg,IDC_CHEAT_OPTIONS) || - m_EditNotes != GetDlgItemStr(hDlg,IDC_NOTES)) - { - Changed = true; - } - if (!Changed) - { - return false; - } - int Result = MessageBoxW(hDlg,GS(CHEAT_CHANGED_MSG),GS(CHEAT_CHANGED_TITLE),MB_YESNOCANCEL); - if (Result == IDCANCEL) - { - return true; - } - if (Result == IDYES) - { - SendMessage(hDlg,WM_COMMAND, MAKELPARAM(IDC_ADD, 0), (LPARAM)GetDlgItem(hDlg,IDC_ADD)); - } - return false; -} - -void CCheats::RecordCheatValues ( HWND hDlg ) -{ - m_EditName = GetDlgItemStr(hDlg,IDC_CODE_NAME); - m_EditCode = GetDlgItemStr(hDlg,IDC_CHEAT_CODES); - m_EditOptions = GetDlgItemStr(hDlg,IDC_CHEAT_OPTIONS); - m_EditNotes = GetDlgItemStr(hDlg,IDC_NOTES); -} - -int CALLBACK CCheats::CheatAddProc (HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam) -{ - switch (uMsg) - { - case WM_INITDIALOG: - { - CCheats * _this = (CCheats *)lParam; - SetProp(hDlg,"Class",_this); - - SetWindowTextW(hDlg,GS(CHEAT_ADDCHEAT_FRAME)); - SetWindowTextW(GetDlgItem(hDlg,IDC_NAME),GS(CHEAT_ADDCHEAT_NAME)); - SetWindowTextW(GetDlgItem(hDlg,IDC_CODE),GS(CHEAT_ADDCHEAT_CODE)); - SetWindowTextW(GetDlgItem(hDlg,IDC_LABEL_OPTIONS),GS(CHEAT_ADDCHEAT_OPT)); - SetWindowTextW(GetDlgItem(hDlg,IDC_CODE_DES),GS(CHEAT_ADDCHEAT_CODEDES)); - SetWindowTextW(GetDlgItem(hDlg,IDC_LABEL_OPTIONS_FORMAT),GS(CHEAT_ADDCHEAT_OPTDES)); - SetWindowTextW(GetDlgItem(hDlg,IDC_CHEATNOTES),GS(CHEAT_ADDCHEAT_NOTES)); - SetWindowTextW(GetDlgItem(hDlg,IDC_NEWCHEAT),GS(CHEAT_ADDCHEAT_NEW)); - SetWindowTextW(GetDlgItem(hDlg,IDC_ADD),GS(CHEAT_ADDCHEAT_ADD)); - SetProp(hDlg,"validcodes",false); - _this->RecordCheatValues(hDlg); - } - break; - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDC_CODE_NAME: - if (HIWORD(wParam) == EN_CHANGE) - { - bool validcodes,validoptions, nooptions; - int CodeFormat; - ReadCodeString(hDlg,validcodes,validoptions,nooptions,CodeFormat); - if (!nooptions) - { - ReadOptionsString(hDlg,validcodes,validoptions,nooptions,CodeFormat); - } - - if (validcodes && (validoptions || nooptions) && SendDlgItemMessage(hDlg,IDC_CODE_NAME,EM_LINELENGTH,0,0) > 0) - { - EnableWindow(GetDlgItem(hDlg, IDC_ADD), true); - } - else - { - EnableWindow(GetDlgItem(hDlg, IDC_ADD), false); - } - } - break; - case IDC_CHEAT_CODES: - if (HIWORD(wParam) == EN_CHANGE) - { - bool validcodes,validoptions, nooptions; - int CodeFormat; - ReadCodeString(hDlg,validcodes,validoptions,nooptions,CodeFormat); - - if ((CodeFormat > 0) && !IsWindowEnabled(GetDlgItem(hDlg, IDC_LABEL_OPTIONS)) ) - { - EnableWindow(GetDlgItem(hDlg, IDC_LABEL_OPTIONS), true); - EnableWindow(GetDlgItem(hDlg, IDC_LABEL_OPTIONS_FORMAT), true); - EnableWindow(GetDlgItem(hDlg, IDC_CHEAT_OPTIONS), true); - } - if ((CodeFormat <= 0) && IsWindowEnabled(GetDlgItem(hDlg, IDC_LABEL_OPTIONS)) ) - { - EnableWindow(GetDlgItem(hDlg, IDC_LABEL_OPTIONS), false); - EnableWindow(GetDlgItem(hDlg, IDC_LABEL_OPTIONS_FORMAT), false); - EnableWindow(GetDlgItem(hDlg, IDC_CHEAT_OPTIONS), false); - } - - if (!nooptions) - { - ReadOptionsString(hDlg,validcodes,validoptions,nooptions,CodeFormat); - } - - if (validcodes && (validoptions || nooptions) && SendDlgItemMessage(hDlg,IDC_CODE_NAME,EM_LINELENGTH,0,0) > 0) - { - EnableWindow(GetDlgItem(hDlg, IDC_ADD), true); - } - else - { - EnableWindow(GetDlgItem(hDlg, IDC_ADD), false); - } - } - break; - case IDC_CHEAT_OPTIONS: - if (HIWORD(wParam) == EN_CHANGE) - { - bool validcodes,validoptions, nooptions; - int CodeFormat; - ReadOptionsString(hDlg,validcodes,validoptions,nooptions,CodeFormat); - - if (validcodes && (validoptions || nooptions) && SendDlgItemMessage(hDlg,IDC_CODE_NAME,EM_LINELENGTH,0,0) > 0) - { - EnableWindow(GetDlgItem(hDlg, IDC_ADD), true); - } - else - { - EnableWindow(GetDlgItem(hDlg, IDC_ADD), false); - } - } - break; - case IDC_ADD: - { - CCheats * _this = (CCheats *)GetProp(hDlg,"Class"); - - stdstr NewCheatName = GetDlgItemStr(hDlg,IDC_CODE_NAME); - int i = 0; - for (i = 0; i < MaxCheats; i ++) - { - if (_this->m_EditCheat == i) - { - continue; - } - stdstr CheatName(_this->GetCheatName(i,false)); - if (CheatName.length() == 0) - { - if (_this->m_EditCheat < 0) - { - _this->m_EditCheat = i; - } - break; - } - if (_stricmp(CheatName.c_str(),NewCheatName.c_str()) == 0) - { - g_Notify->DisplayError(GS(MSG_CHEAT_NAME_IN_USE)); - SetFocus(GetDlgItem(hDlg,IDC_CODE_NAME)); - return true; - } - } - if (_this->m_EditCheat < 0 && i == MaxCheats) - { - g_Notify->DisplayError(GS(MSG_MAX_CHEATS)); - return true; - } - - //Update the entries - bool validcodes,validoptions, nooptions; - int CodeFormat; - stdstr_f Cheat("\"%s\"%s",NewCheatName.c_str(),ReadCodeString(hDlg,validcodes,validoptions,nooptions,CodeFormat).c_str()); - stdstr Options = ReadOptionsString(hDlg,validcodes,validoptions,nooptions,CodeFormat); - - g_Settings->SaveStringIndex(Cheat_Entry, _this->m_EditCheat,Cheat.c_str()); - g_Settings->SaveStringIndex(Cheat_Notes, _this->m_EditCheat,GetDlgItemStr(hDlg,IDC_NOTES)); - g_Settings->SaveStringIndex(Cheat_Options, _this->m_EditCheat,Options); - _this->RecordCheatValues(hDlg); - CSettingTypeCheats::FlushChanges(); - _this->RefreshCheatManager(); - } - break; - case IDC_NEWCHEAT: - { - CCheats * _this = (CCheats *)GetProp(hDlg,"Class"); - - if (_this->CheatChanged(hDlg)) - { - break; - } - _this->m_EditCheat = -1; - SetDlgItemText(hDlg,IDC_CODE_NAME,""); - SetDlgItemText(hDlg,IDC_CHEAT_CODES,""); - SetDlgItemText(hDlg,IDC_CHEAT_OPTIONS,""); - SetDlgItemText(hDlg,IDC_NOTES,""); - EnableWindow(GetDlgItem(hDlg, IDC_ADD), false); - EnableWindow(GetDlgItem(hDlg, IDC_CHEAT_OPTIONS), false); - SetDlgItemTextW(hDlg,IDC_ADD,GS(CHEAT_ADDNEW)); - _this->RecordCheatValues(hDlg); - } - break; - } - } - break; - case WM_EDITCHEAT: - { - CCheats * _this = (CCheats *)GetProp(hDlg,"Class"); - _this->m_EditCheat = wParam; - if (_this->m_EditCheat < 0) - { - break; - } - - if (_this->CheatChanged(hDlg)) - { - break; - } - - stdstr CheatEntryStr = g_Settings->LoadStringIndex(Cheat_Entry,_this->m_EditCheat); - LPCSTR String = CheatEntryStr.c_str(); - - //Set Cheat Name - int len = strrchr(String,'"') - strchr(String,'"') - 1; - stdstr CheatName(strchr(String,'"') + 1); - CheatName.resize(len); - SetDlgItemText(hDlg,IDC_CODE_NAME,CheatName.c_str()); - - //Add Gameshark codes to screen - LPCSTR ReadPos = strrchr(String,'"') + 2; - stdstr Buffer; - do - { - char * End = strchr((char *)ReadPos,','); - if (End) - { - Buffer.append(ReadPos,End - ReadPos); - } - else - { - Buffer.append(ReadPos); - } - - ReadPos = strchr(ReadPos,','); - if (ReadPos != NULL) - { - Buffer.append("\r\n"); - ReadPos += 1; - } - } while (ReadPos); - SetDlgItemText(hDlg,IDC_CHEAT_CODES,Buffer.c_str()); - - //Add option values to screen - stdstr CheatOptionStr = g_Settings->LoadStringIndex(Cheat_Options,_this->m_EditCheat); - ReadPos = strchr(CheatOptionStr.c_str(),'$'); - Buffer.erase(); - if (ReadPos) - { - ReadPos += 1; - do - { - char * End = strchr((char *)ReadPos,','); - if (End) - { - Buffer.append(ReadPos,End - ReadPos); - } - else - { - Buffer.append(ReadPos); - } - ReadPos = strchr(ReadPos,'$'); - if (ReadPos != NULL) - { - Buffer.append("\r\n"); - ReadPos += 1; - } - } while (ReadPos); - } - SetDlgItemText(hDlg,IDC_CHEAT_OPTIONS,Buffer.c_str()); - - //Add cheat Notes - stdstr CheatNotesStr = g_Settings->LoadStringIndex(Cheat_Notes,_this->m_EditCheat); - SetDlgItemText(hDlg,IDC_NOTES,CheatNotesStr.c_str()); - - SendMessage(hDlg,WM_COMMAND, MAKELPARAM(IDC_CHEAT_CODES, EN_CHANGE), (LPARAM)GetDlgItem(hDlg,IDC_CHEAT_CODES)); - SetDlgItemTextW(hDlg,IDC_ADD,GS(CHEAT_EDITCHEAT_UPDATE)); - - _this->RecordCheatValues(hDlg); - } - break; - default: - return false; - } - return true; -} - -int CALLBACK CCheats::CheatListProc (HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam) { - switch (uMsg) - { - case WM_INITDIALOG: - { - CCheats * _this = (CCheats *)lParam; - SetProp(hDlg,"Class",_this); - - DWORD Style; - RECT rcList; - RECT rcButton; - - SetWindowTextW(GetDlgItem(hDlg,IDC_CHEATSFRAME),GS(CHEAT_LIST_FRAME)); - SetWindowTextW(GetDlgItem(hDlg,IDC_NOTESFRAME),GS(CHEAT_NOTES_FRAME)); - SetWindowTextW(GetDlgItem(hDlg,IDC_UNMARK),GS(CHEAT_MARK_NONE)); - - GetWindowRect(GetDlgItem(hDlg, IDC_CHEATSFRAME), &rcList); - GetWindowRect(GetDlgItem(hDlg, IDC_UNMARK), &rcButton); - - _this->m_hCheatTree = (HWND)CreateWindowEx(WS_EX_CLIENTEDGE,WC_TREEVIEW,"", - WS_CHILD | WS_VISIBLE | WS_VSCROLL | TVS_HASLINES | - TVS_HASBUTTONS | TVS_LINESATROOT | TVS_DISABLEDRAGDROP |WS_TABSTOP| - TVS_FULLROWSELECT, 8, 15, rcList.right-rcList.left-16, - rcButton.top-rcList.top-22, hDlg, (HMENU)IDC_MYTREE, GetModuleHandle(NULL), NULL); - Style = GetWindowLong((HWND)_this->m_hCheatTree,GWL_STYLE); - SetWindowLong((HWND)_this->m_hCheatTree,GWL_STYLE,TVS_CHECKBOXES |TVS_SHOWSELALWAYS| Style); - -#if defined(WINDOWS_UI) - //Creats an image list from the bitmap in the resource section - HIMAGELIST hImageList; - HBITMAP hBmp; - - hImageList = ImageList_Create( 16,16, ILC_COLOR | ILC_MASK, 40, 40); - hBmp = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_TRI_STATE)); - ImageList_AddMasked(hImageList,hBmp, RGB(255,0,255)); - DeleteObject(hBmp); - - TreeView_SetImageList((HWND)_this->m_hCheatTree,hImageList,TVSIL_STATE); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); -#endif - - _this->m_hSelectedItem = NULL; - - } - break; - case WM_COMMAND: - { - CCheats * _this = (CCheats *)GetProp(hDlg,"Class"); - - switch (LOWORD(wParam)) - { - case ID_POPUP_ADDNEWCHEAT: - //DialogBox(hInst, MAKEINTRESOURCE(IDD_Cheats_Add),hDlg,(DLGPROC)CheatAddProc); - break; - case ID_POPUP_EDIT: - //DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_Cheats_Edit),hDlg,(DLGPROC)CheatEditProc,(LPARAM)hSelectedItem); - break; - case ID_POPUP_DELETE: - { - TVITEM item; - - int Response = MessageBoxW(hDlg,GS(MSG_DEL_SURE),GS(MSG_DEL_TITLE),MB_YESNO|MB_ICONQUESTION); - if (Response != IDYES) { break; } - - //Delete selected cheat - item.hItem = (HTREEITEM)_this->m_hSelectedItem; - item.mask = TVIF_PARAM ; - TreeView_GetItem((HWND)_this->m_hCheatTree,&item); - - _this->ChangeChildrenStatus((HWND)TVI_ROOT,false); - _this->DeleteCheat(item.lParam); - _this->RefreshCheatManager(); - } - break; - case IDC_UNMARK: - _this->ChangeChildrenStatus((HWND)TVI_ROOT,false); - _this->m_CheatSelectionChanged = true; - break; - } - } - break; - case WM_NOTIFY: - { - CCheats * _this = (CCheats *)GetProp(hDlg,"Class"); - - if (_this->m_DeleteingEntries) - { - break; - } - LPNMHDR lpnmh = (LPNMHDR) lParam; - - if ((lpnmh->code == NM_RCLICK) && (lpnmh->idFrom == IDC_MYTREE)) - { - - //Work out what item is selected - TVHITTESTINFO ht = {0}; - DWORD dwpos = GetMessagePos(); - - // include and header files - ht.pt.x = GET_X_LPARAM(dwpos); - ht.pt.y = GET_Y_LPARAM(dwpos); - MapWindowPoints(HWND_DESKTOP, lpnmh->hwndFrom, &ht.pt, 1); - - TreeView_HitTest(lpnmh->hwndFrom, &ht); - _this->m_hSelectedItem = (HWND)ht.hItem; - if (g_Settings->LoadBool(UserInterface_BasicMode)) { return true; } - - //Show Menu - HMENU hMenu = LoadMenu(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_CHEAT_MENU)); - HMENU hPopupMenu = GetSubMenu(hMenu,0); - POINT Mouse; - - GetCursorPos(&Mouse); - - MenuSetText(hPopupMenu, 0, GS(CHEAT_ADDNEW), NULL); - MenuSetText(hPopupMenu, 1, GS(CHEAT_EDIT), NULL); - MenuSetText(hPopupMenu, 3, GS(CHEAT_DELETE), NULL); - - if (_this->m_hSelectedItem == NULL || - TreeView_GetChild((HWND)_this->m_hCheatTree,_this->m_hSelectedItem) != NULL) - { - DeleteMenu(hPopupMenu,3,MF_BYPOSITION); - DeleteMenu(hPopupMenu,2,MF_BYPOSITION); - DeleteMenu(hPopupMenu,1,MF_BYPOSITION); - } - TrackPopupMenu(hPopupMenu, 0, Mouse.x, Mouse.y, 0,hDlg, NULL); - DestroyMenu(hMenu); - } - if ((lpnmh->code == NM_CLICK) && (lpnmh->idFrom == IDC_MYTREE)) - { - TVHITTESTINFO ht = {0}; - DWORD dwpos = GetMessagePos(); - - // include and header files - ht.pt.x = GET_X_LPARAM(dwpos); - ht.pt.y = GET_Y_LPARAM(dwpos); - MapWindowPoints(HWND_DESKTOP, lpnmh->hwndFrom, &ht.pt, 1); - - TreeView_HitTest(lpnmh->hwndFrom, &ht); - - if(TVHT_ONITEMSTATEICON & ht.flags) - { - - switch (TV_GetCheckState(_this->m_hCheatTree,(HWND)ht.hItem)) { - case TV_STATE_CLEAR: - case TV_STATE_INDETERMINATE: - //Make sure that the item has a valid code extenstion selected - if (TreeView_GetChild((HWND)_this->m_hCheatTree, (HWND)ht.hItem) == NULL) { - TVITEM item; - item.mask = TVIF_PARAM ; - item.hItem = (HTREEITEM)ht.hItem; - TreeView_GetItem((HWND)_this->m_hCheatTree,&item); - stdstr LineEntry = g_Settings->LoadStringIndex(Cheat_Entry,item.lParam); - if (CheatUsesCodeExtensions(LineEntry)) - { - stdstr CheatExtension; - if (!g_Settings->LoadStringIndex(Cheat_Extension,item.lParam,CheatExtension)) - { - SendMessage(hDlg, UM_CHANGECODEEXTENSION, 0, (LPARAM)ht.hItem); - TV_SetCheckState(_this->m_hCheatTree,(HWND)ht.hItem,TV_STATE_CLEAR); - break; - } - } - } - TV_SetCheckState(_this->m_hCheatTree,(HWND)ht.hItem,TV_STATE_CHECKED); - _this->ChangeChildrenStatus((HWND)ht.hItem,true); - _this->CheckParentStatus((HWND)TreeView_GetParent((HWND)_this->m_hCheatTree,ht.hItem)); - break; - case TV_STATE_CHECKED: - TV_SetCheckState(_this->m_hCheatTree,(HWND)ht.hItem,TV_STATE_CLEAR); - _this->ChangeChildrenStatus((HWND)ht.hItem,false); - _this->CheckParentStatus((HWND)TreeView_GetParent((HWND)_this->m_hCheatTree,ht.hItem)); - break; - } - switch (TV_GetCheckState(_this->m_hCheatTree,(HWND)ht.hItem)) { - case TV_STATE_CHECKED: TV_SetCheckState(_this->m_hCheatTree,(HWND)ht.hItem,TV_STATE_INDETERMINATE); break; - case TV_STATE_CLEAR: TV_SetCheckState(_this->m_hCheatTree,(HWND)ht.hItem,TV_STATE_CHECKED); break; - case TV_STATE_INDETERMINATE: TV_SetCheckState(_this->m_hCheatTree,(HWND)ht.hItem,TV_STATE_CLEAR); break; - } - - _this->m_CheatSelectionChanged = true; - } - } - if ((lpnmh->code == NM_DBLCLK) && (lpnmh->idFrom == IDC_MYTREE)) - { - TVHITTESTINFO ht = {0}; - DWORD dwpos = GetMessagePos(); - - // include and header files - ht.pt.x = GET_X_LPARAM(dwpos); - ht.pt.y = GET_Y_LPARAM(dwpos); - MapWindowPoints(HWND_DESKTOP, lpnmh->hwndFrom, &ht.pt, 1); - - TreeView_HitTest(lpnmh->hwndFrom, &ht); - - if(TVHT_ONITEMLABEL & ht.flags) - { - PostMessage(hDlg, UM_CHANGECODEEXTENSION, 0, (LPARAM)ht.hItem); - } - } - if ((lpnmh->code == TVN_SELCHANGED) && (lpnmh->idFrom == IDC_MYTREE)) { - HTREEITEM hItem; - - hItem = TreeView_GetSelection((HWND)_this->m_hCheatTree); - if (TreeView_GetChild((HWND)_this->m_hCheatTree,hItem) == NULL) { - TVITEM item; - - item.mask = TVIF_PARAM ; - item.hItem = hItem; - TreeView_GetItem((HWND)_this->m_hCheatTree,&item); - - stdstr Notes(g_Settings->LoadStringIndex(Cheat_Notes,item.lParam)); - SetDlgItemText(hDlg,IDC_NOTES,Notes.c_str()); - if (_this->m_AddCheat) - { - SendMessage((HWND)_this->m_AddCheat,WM_EDITCHEAT,item.lParam,0); //edit cheat - } - } else { - SetDlgItemText(hDlg,IDC_NOTES,""); - } - } - } - break; - case UM_CHANGECODEEXTENSION: - { - CCheats * _this = (CCheats *)GetProp(hDlg,"Class"); -; - //Get the selected item - _this->m_hSelectedItem = (HWND)lParam; - TVITEM item; - item.mask = TVIF_PARAM ; - item.hItem = (HTREEITEM)_this->m_hSelectedItem; - TreeView_GetItem((HWND)_this->m_hCheatTree,&item); - - //Make sure the selected line can use code extensions - stdstr LineEntry = g_Settings->LoadStringIndex(Cheat_Entry,item.lParam); - if (!CheatUsesCodeExtensions(LineEntry)) { break; } - - stdstr Options; - if (g_Settings->LoadStringIndex(Cheat_Options,item.lParam,Options) && Options.length() > 0) - { - DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Cheats_CodeEx),hDlg,(DLGPROC)CheatsCodeExProc,(LPARAM)_this); - } else { - stdstr Range; - if (g_Settings->LoadStringIndex(Cheat_Range,item.lParam,Range) && Range.length() > 0) - { - DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Cheats_Range),hDlg,(DLGPROC)CheatsCodeQuantProc,(LPARAM)_this); - } - } - - //Update cheat listing with new extention - stdstr CheatName(_this->GetCheatName(item.lParam,true)); - char * Cheat = strrchr((char *)CheatName.c_str(),'\\'); - if (Cheat == NULL) { - Cheat = const_cast(CheatName.c_str()); - } else { - Cheat += 1; - } - item.mask = TVIF_TEXT; - item.pszText = Cheat; - item.cchTextMax = CheatName.length(); - TreeView_SetItem((HWND)_this->m_hCheatTree,&item); - } - break; - default: - return false; - } - return true; -} - -int CALLBACK CCheats::CheatsCodeExProc (HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam) { - switch (uMsg) { - case WM_INITDIALOG: - { - CCheats * _this = (CCheats *)lParam; - SetProp(hDlg,"Class",_this); - - //Find the cheat Number of the option being selected - TVITEM item; - item.hItem = (HTREEITEM)_this->m_hSelectedItem; - item.mask = TVIF_PARAM ; - TreeView_GetItem((HWND)_this->m_hCheatTree,&item); - stdstr CheatName = _this->GetCheatName(item.lParam,false); - - //Set up language support for dialog - SetWindowTextW(hDlg, GS(CHEAT_CODE_EXT_TITLE)); - SetDlgItemTextW(hDlg,IDC_NOTE, GS(CHEAT_CODE_EXT_TXT)); - SetDlgItemTextW(hDlg,IDOK, GS(CHEAT_OK)); - SetDlgItemTextW(hDlg,IDCANCEL, GS(CHEAT_CANCEL)); - SetDlgItemText(hDlg,IDC_CHEAT_NAME,CheatName.c_str()); - - //Read through and add all options to the list box - stdstr Options(g_Settings->LoadStringIndex(Cheat_Options,item.lParam)); - stdstr CurrentExt(g_Settings->LoadStringIndex(Cheat_Extension,item.lParam)); - const char * ReadPos = Options.c_str(); - while (*ReadPos != 0) { - const char * NextComma = strchr(ReadPos,','); - int len = NextComma == NULL ? strlen(ReadPos) : NextComma - ReadPos; - stdstr CheatExt(ReadPos); - CheatExt.resize(len); - int index = SendMessage(GetDlgItem(hDlg,IDC_CHEAT_LIST),LB_ADDSTRING,0,(LPARAM)CheatExt.c_str()); - if (CheatExt == CurrentExt) { - SendMessage(GetDlgItem(hDlg,IDC_CHEAT_LIST),LB_SETCURSEL,index,0); - } - //Move to next entry or end - ReadPos = NextComma ? NextComma + 1 : ReadPos + strlen(ReadPos); - } - } - break; - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_CHEAT_LIST: - if (HIWORD(wParam) == LBN_DBLCLK) { PostMessage(hDlg,WM_COMMAND,IDOK,0); break; } - break; - case IDOK: - { - CCheats * _this = (CCheats *)GetProp(hDlg,"Class"); - - //Find the cheat Number of the option being selected - TVITEM item; - item.hItem = (HTREEITEM)_this->m_hSelectedItem; - item.mask = TVIF_PARAM ; - TreeView_GetItem((HWND)_this->m_hCheatTree,&item); - - //Get the selected cheat extension - char CheatExten[300]; - int index = SendMessage(GetDlgItem(hDlg,IDC_CHEAT_LIST),LB_GETCURSEL,0,0); - if (index < 0) { index = 0; } - SendMessage(GetDlgItem(hDlg,IDC_CHEAT_LIST),LB_GETTEXT,index,(LPARAM)CheatExten); - - g_Settings->SaveStringIndex(Cheat_Extension,item.lParam,CheatExten); - _this->m_CheatSelectionChanged = true; - } - RemoveProp(hDlg,"Class"); - EndDialog(hDlg,0); - break; - case IDCANCEL: - RemoveProp(hDlg,"Class"); - EndDialog(hDlg,0); - break; - } - default: - return false; - } - return true; -} - -int CALLBACK CCheats::CheatsCodeQuantProc (HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam) { - static WORD Start, Stop, SelStart, SelStop; - - switch (uMsg) { - case WM_INITDIALOG: - { - CCheats * _this = (CCheats *)lParam; - SetProp(hDlg,"Class",_this); - - //Find the cheat Number of the option being selected - TVITEM item; - item.hItem = (HTREEITEM)_this->m_hSelectedItem; - item.mask = TVIF_PARAM ; - TreeView_GetItem((HWND)_this->m_hCheatTree,&item); - stdstr CheatName = _this->GetCheatName(item.lParam,false); - stdstr RangeNote(g_Settings->LoadStringIndex(Cheat_RangeNotes, item.lParam)); - stdstr Range(g_Settings->LoadStringIndex(Cheat_Range,item.lParam)); - stdstr Value(g_Settings->LoadStringIndex(Cheat_Extension,item.lParam)); - - //Set up language support for dialog - SetWindowTextW(hDlg, GS(CHEAT_CODE_EXT_TITLE)); - SetDlgItemTextW(hDlg, IDC_DIGITAL_TEXT, GS(CHEAT_CHOOSE_VALUE)); - SetDlgItemTextW(hDlg, IDC_VALUE_TEXT, GS(CHEAT_VALUE)); - SetDlgItemTextW(hDlg, IDC_NOTES_TEXT, GS(CHEAT_NOTES)); - SetDlgItemText(hDlg,IDC_NOTES,RangeNote.c_str()); - SetDlgItemText(hDlg,IDC_CHEAT_NAME,CheatName.c_str()); - SetDlgItemText(hDlg,IDC_VALUE,Value.c_str()); - - Start = (WORD)(Range.c_str()[0] == '$'?AsciiToHex(&Range.c_str()[1]):atol(Range.c_str())); - const char * ReadPos = strrchr(Range.c_str(),'-'); - if (ReadPos != NULL) { - Stop = (WORD)(ReadPos[1] == '$'?AsciiToHex(&ReadPos[2]):atol(&ReadPos[1])); - } else { - Stop = 0; - } - - char Text[500]; - sprintf(Text,"%s $%X %s $%X",GS(CHEAT_FROM),Start,GS(CHEAT_TO),Stop); - SetDlgItemText(hDlg,IDC_RANGE,Text); - } - break; - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_VALUE: - if (HIWORD(wParam) == EN_UPDATE) { - TCHAR szTmp[10], szTmp2[10]; - DWORD Value; - GetDlgItemText(hDlg,IDC_VALUE,szTmp,sizeof(szTmp)); - Value = szTmp[0] =='$'?AsciiToHex(&szTmp[1]):AsciiToHex(szTmp); - if (Value > Stop) { Value = Stop; } - if (Value < Start) { Value = Start; } - sprintf(szTmp2,"$%X",Value); - if (strcmp(szTmp,szTmp2) != 0) { - SetDlgItemText(hDlg,IDC_VALUE,szTmp2); - if (SelStop == 0) { SelStop = (WORD)strlen(szTmp2); SelStart = SelStop; } - SendDlgItemMessage(hDlg,IDC_VALUE,EM_SETSEL,(WPARAM)SelStart,(LPARAM)SelStop); - } else { - WORD NewSelStart, NewSelStop; - SendDlgItemMessage(hDlg,IDC_VALUE,EM_GETSEL,(WPARAM)&NewSelStart,(LPARAM)&NewSelStop); - if (NewSelStart != 0) { SelStart = NewSelStart; SelStop = NewSelStop; } - } - } - break; - case IDOK: - { - CCheats * _this = (CCheats *)GetProp(hDlg,"Class"); - - //Find the cheat Number of the option being selected - TVITEM item; - item.hItem = (HTREEITEM)_this->m_hSelectedItem; - item.mask = TVIF_PARAM ; - TreeView_GetItem((HWND)_this->m_hCheatTree,&item); - - //Get the selected cheat extension - TCHAR CheatExten[300], szTmp[10]; - DWORD Value; - - GetDlgItemText(hDlg,IDC_VALUE,szTmp,sizeof(szTmp)); - Value = szTmp[0] =='$'?AsciiToHex(&szTmp[1]):AsciiToHex(szTmp); - if (Value > Stop) { Value = Stop; } - if (Value < Start) { Value = Start; } - sprintf(CheatExten,"$%X",Value); - - g_Settings->SaveStringIndex(Cheat_Extension, item.lParam,CheatExten); - _this->m_CheatSelectionChanged = true; - } - RemoveProp(hDlg,"Class"); - EndDialog(hDlg,0); - break; - case IDCANCEL: - RemoveProp(hDlg,"Class"); - EndDialog(hDlg,0); - break; - } - default: - return false; - } - return true; -} - -bool CCheats::IsCheatMessage( MSG * msg ) -{ - if (m_Window) - { - return IsDialogMessage((HWND)m_Window,msg) != 0; - } - return false; -} - -int CALLBACK CCheats::ManageCheatsProc (HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam) { - switch (uMsg) { - case WM_INITDIALOG: - { - CCheats * _this = (CCheats *)lParam; - SetProp(hDlg,"Class",_this); - _this->m_Window = hDlg; - - WINDOWPLACEMENT WndPlac; - WndPlac.length = sizeof(WndPlac); - GetWindowPlacement(hDlg, &WndPlac); - - LONG_PTR originalWndProc = GetWindowLongPtrW(hDlg, GWLP_WNDPROC); - SetWindowLongPtrW(hDlg, GWLP_WNDPROC, (LONG_PTR) DefWindowProcW); - SetWindowTextW(hDlg, GS(CHEAT_TITLE)); - SetWindowLongPtrW(hDlg, GWLP_WNDPROC, originalWndProc); - _this->m_hSelectCheat = (HWND)CreateDialogParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Cheats_List),hDlg,(DLGPROC)CheatListProc,(LPARAM)_this); - SetWindowPos((HWND)_this->m_hSelectCheat,HWND_TOP, 5, 8, 0, 0, SWP_NOSIZE); - ShowWindow((HWND)_this->m_hSelectCheat,SW_SHOW); - - RECT * rc = &WndPlac.rcNormalPosition; - if (g_Settings->LoadDword(UserInterface_BasicMode)) - { - RECT * rcList = (RECT *)_this->m_rcList; - GetWindowRect(GetDlgItem((HWND)_this->m_hSelectCheat, IDC_CHEATSFRAME), rcList); - _this->m_MinSizeDlg = rcList->right - rcList->left + 16; - _this->m_MaxSizeDlg = _this->m_MinSizeDlg; - - _this->m_DialogState = CONTRACTED; - WndPlac.rcNormalPosition.right = WndPlac.rcNormalPosition.left + _this->m_MinSizeDlg; - SetWindowPlacement(hDlg, &WndPlac); - - ShowWindow(GetDlgItem(hDlg, IDC_STATE),SW_HIDE); - } else { - _this->m_AddCheat = (HWND)CreateDialogParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Cheats_Add),hDlg,(DLGPROC)CheatAddProc,(LPARAM)_this); - SetWindowPos((HWND)_this->m_AddCheat, HWND_TOP, (rc->right - rc->left)/2, 8, 0, 0, SWP_NOSIZE); - ShowWindow((HWND)_this->m_AddCheat,SW_HIDE); - - - RECT * rcAdd = (RECT *)_this->m_rcAdd, * rcList = (RECT *)_this->m_rcList; - GetWindowRect(GetDlgItem((HWND)_this->m_hSelectCheat, IDC_CHEATSFRAME), rcList); - GetWindowRect(GetDlgItem((HWND)_this->m_AddCheat, IDC_ADDCHEATSFRAME), rcAdd); - _this->m_MinSizeDlg = rcList->right - rcList->left + 32; - _this->m_MaxSizeDlg = rcAdd->right - rcList->left + 32; - - _this->m_DialogState = CONTRACTED; - WndPlac.rcNormalPosition.right = WndPlac.rcNormalPosition.left + _this->m_MinSizeDlg; - SetWindowPlacement(hDlg, &WndPlac); - - GetClientRect(hDlg, rc); - HWND hStateButton = GetDlgItem(hDlg, IDC_STATE); - SetWindowPos(hStateButton, HWND_TOP, (rc->right - rc->left) - 16, 0, 16, rc->bottom - rc->top, 0); - HANDLE hIcon = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_RIGHT),IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR ); - SendDlgItemMessage(hDlg, IDC_STATE, BM_SETIMAGE, (WPARAM) IMAGE_ICON, (LPARAM) (HANDLE) hIcon); - } - - //re-center cheat window - RECT rcDlg, rcParent; - GetWindowRect(hDlg, &rcDlg); - GetWindowRect(GetParent(hDlg), &rcParent); - - int DlgWidth = rcDlg.right - rcDlg.left; - int DlgHeight = rcDlg.bottom - rcDlg.top; - - int X = (((rcParent.right - rcParent.left) - DlgWidth) / 2) + rcParent.left; - int Y = (((rcParent.bottom - rcParent.top) - DlgHeight) / 2) + rcParent.top; - - SetWindowPos(hDlg,NULL,X,Y,0,0,SWP_NOZORDER|SWP_NOSIZE); - - _this->RefreshCheatManager(); - } - break; - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDCANCEL: - { - CCheats * _this = (CCheats *)GetProp(hDlg,"Class"); - if (_this->m_AddCheat) { - DestroyWindow((HWND)_this->m_AddCheat); - _this->m_AddCheat = NULL; - } - _this->m_Window = NULL; - } - RemoveProp(hDlg,"Class"); - EndDialog(hDlg,0); - break; - case IDC_STATE: - { - CCheats * _this = (CCheats *)GetProp(hDlg,"Class"); - WINDOWPLACEMENT WndPlac; - WndPlac.length = sizeof(WndPlac); - GetWindowPlacement(hDlg, &WndPlac); - - if (_this->m_DialogState == CONTRACTED) - { - _this->m_DialogState = EXPANDED; - WndPlac.rcNormalPosition.right = WndPlac.rcNormalPosition.left + _this->m_MaxSizeDlg; - SetWindowPlacement(hDlg, &WndPlac); - - RECT clientrect; - GetClientRect(hDlg, &clientrect); - HWND hStateButton = GetDlgItem(hDlg, IDC_STATE); - SetWindowPos(hStateButton, HWND_TOP, (clientrect.right - clientrect.left) - 16, 0, 16, clientrect.bottom - clientrect.top, 0); - - HANDLE hIcon = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_LEFT),IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR ); - SendDlgItemMessage(hDlg, IDC_STATE, BM_SETIMAGE, (WPARAM) IMAGE_ICON, (LPARAM) (HANDLE) hIcon); - - ShowWindow((HWND)_this->m_AddCheat,SW_SHOW); - } - else - { - _this->m_DialogState = CONTRACTED; - WndPlac.rcNormalPosition.right = WndPlac.rcNormalPosition.left + _this->m_MinSizeDlg; - SetWindowPlacement(hDlg, &WndPlac); - - HANDLE hIcon = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_RIGHT),IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR ); - SendDlgItemMessage(hDlg, IDC_STATE, BM_SETIMAGE, (WPARAM) IMAGE_ICON, (LPARAM) (HANDLE) hIcon); - - RECT clientrect; - GetClientRect(hDlg, &clientrect); - HWND hStateButton = GetDlgItem(hDlg, IDC_STATE); - SetWindowPos(hStateButton, HWND_TOP, (clientrect.right - clientrect.left) - 16, 0, 16, clientrect.bottom - clientrect.top, 0); - - ShowWindow((HWND)_this->m_AddCheat,SW_HIDE); - } - } - break; - } - break; - default: - return false; - } - return true; -} - -bool CCheats::TV_SetCheckState(HWND hwndTreeView, HWND hItem, TV_CHECK_STATE state) -{ - TVITEM tvItem; - - tvItem.mask = TVIF_HANDLE | TVIF_STATE; - tvItem.hItem = (HTREEITEM)hItem; - tvItem.stateMask = TVIS_STATEIMAGEMASK; - - /*Image 1 in the tree-view check box image list is the - unchecked box. Image 2 is the checked box.*/ - - switch (state) { - case TV_STATE_CHECKED: tvItem.state = INDEXTOSTATEIMAGEMASK(1); break; - case TV_STATE_CLEAR: tvItem.state = INDEXTOSTATEIMAGEMASK(2); break; - case TV_STATE_INDETERMINATE: tvItem.state = INDEXTOSTATEIMAGEMASK(3); break; - default: tvItem.state = INDEXTOSTATEIMAGEMASK(0); break; - } - return TreeView_SetItem((HWND)hwndTreeView, &tvItem) != 0; -} - -int CCheats::TV_GetCheckState(HWND hwndTreeView, HWND hItem) -{ - TVITEM tvItem; - - // Prepare to receive the desired information. - tvItem.mask = TVIF_HANDLE | TVIF_STATE; - tvItem.hItem = (HTREEITEM)hItem; - tvItem.stateMask = TVIS_STATEIMAGEMASK; - - // Request the information. - TreeView_GetItem((HWND)hwndTreeView, &tvItem); - - // Return zero if it's not checked, or nonzero otherwise. - switch (tvItem.state >> 12) { - case 1: return TV_STATE_CHECKED; - case 2: return TV_STATE_CLEAR; - case 3: return TV_STATE_INDETERMINATE; - } - return ((int)(tvItem.state >> 12) -1); -} - -void CCheats::MenuSetText ( HMENU hMenu, int MenuPos, const wchar_t * Title, const wchar_t * ShortCut) -{ - MENUITEMINFOW MenuInfo; - wchar_t String[256]; - - if (Title == NULL || wcslen(Title) == 0) { return; } - - memset(&MenuInfo, 0, sizeof(MENUITEMINFO)); - MenuInfo.cbSize = sizeof(MENUITEMINFO); - MenuInfo.fMask = MIIM_TYPE; - MenuInfo.fType = MFT_STRING; - MenuInfo.fState = MFS_ENABLED; - MenuInfo.dwTypeData = String; - MenuInfo.cch = 256; - - GetMenuItemInfoW(hMenu,MenuPos,true,&MenuInfo); - wcscpy(String,Title); - if (wcschr(String,'\t') != NULL) { *(wcschr(String,'\t')) = '\0'; } - if (ShortCut) { _swprintf(String,L"%s\t%s",String,ShortCut); } - SetMenuItemInfoW(hMenu,MenuPos,true,&MenuInfo); -} - -void CCheats::DeleteCheat(int Index) -{ - for (int CheatNo = Index; CheatNo < MaxCheats; CheatNo ++ ) - { - stdstr LineEntry = g_Settings->LoadStringIndex(Cheat_Entry,CheatNo + 1); - if (LineEntry.empty()) - { - g_Settings->DeleteSettingIndex(Cheat_RangeNotes,CheatNo); - g_Settings->DeleteSettingIndex(Cheat_Range,CheatNo); - g_Settings->DeleteSettingIndex(Cheat_Options,CheatNo); - g_Settings->DeleteSettingIndex(Cheat_Notes,CheatNo); - g_Settings->DeleteSettingIndex(Cheat_Extension,CheatNo); - g_Settings->DeleteSettingIndex(Cheat_Entry,CheatNo); - g_Settings->DeleteSettingIndex(Cheat_Active,CheatNo); - break; - } - stdstr Value; - if (g_Settings->LoadStringIndex(Cheat_RangeNotes,CheatNo+1,Value)) - { - g_Settings->SaveStringIndex(Cheat_RangeNotes,CheatNo, Value); - } else { - g_Settings->DeleteSettingIndex(Cheat_RangeNotes,CheatNo); - } - - if (g_Settings->LoadStringIndex(Cheat_Range,CheatNo+1,Value)) - { - g_Settings->SaveStringIndex(Cheat_Range,CheatNo, Value); - } else { - g_Settings->DeleteSettingIndex(Cheat_Range,CheatNo); - } - - if (g_Settings->LoadStringIndex(Cheat_Options,CheatNo+1,Value)) - { - g_Settings->SaveStringIndex(Cheat_Options,CheatNo, Value); - } else { - g_Settings->DeleteSettingIndex(Cheat_Options,CheatNo); - } - - if (g_Settings->LoadStringIndex(Cheat_Notes,CheatNo+1,Value)) - { - g_Settings->SaveStringIndex(Cheat_Notes,CheatNo, Value); - } else { - g_Settings->DeleteSettingIndex(Cheat_Notes,CheatNo); - } - - if (g_Settings->LoadStringIndex(Cheat_Extension,CheatNo+1,Value)) - { - g_Settings->SaveStringIndex(Cheat_Extension,CheatNo, Value); - } else { - g_Settings->DeleteSettingIndex(Cheat_Extension,CheatNo); - } - - bool bValue; - if (g_Settings->LoadBoolIndex(Cheat_Active,CheatNo+1,bValue)) - { - g_Settings->SaveBoolIndex(Cheat_Active,CheatNo, bValue); - } else { - g_Settings->DeleteSettingIndex(Cheat_Active,CheatNo); - } - g_Settings->SaveStringIndex(Cheat_Entry,CheatNo, LineEntry); - } - CSettingTypeCheats::FlushChanges(); -} - -void CCheats::ChangeChildrenStatus(HWND hParent, bool Checked) { - HTREEITEM hItem = TreeView_GetChild((HWND)m_hCheatTree, hParent); - if (hItem == NULL) { - if ((HTREEITEM)hParent == TVI_ROOT) { return; } - - TVITEM item; - item.mask = TVIF_PARAM ; - item.hItem = (HTREEITEM)hParent; - TreeView_GetItem((HWND)m_hCheatTree,&item); - - //if cheat uses a extension and it is not set then do not set it - if (Checked) { - stdstr LineEntry = g_Settings->LoadStringIndex(Cheat_Entry,item.lParam); - if (CheatUsesCodeExtensions(LineEntry)) { - stdstr CheatExten; - if (!g_Settings->LoadStringIndex(Cheat_Extension,item.lParam,CheatExten) || CheatExten.empty()) - { - return; - } - } - } - //Save Cheat - TV_SetCheckState(m_hCheatTree,hParent,Checked?TV_STATE_CHECKED:TV_STATE_CLEAR); - g_Settings->SaveBoolIndex(Cheat_Active,item.lParam,Checked); - return; - } - TV_CHECK_STATE state = TV_STATE_UNKNOWN; - while (hItem != NULL) { - TV_CHECK_STATE ChildState = (TV_CHECK_STATE)TV_GetCheckState(m_hCheatTree,(HWND)hItem); - if ((ChildState != TV_STATE_CHECKED || !Checked) && - (ChildState != TV_STATE_CLEAR || Checked)) - { - ChangeChildrenStatus((HWND)hItem,Checked); - } - ChildState = (TV_CHECK_STATE)TV_GetCheckState(m_hCheatTree,(HWND)hItem); - if (state == TV_STATE_UNKNOWN) { state = ChildState; } - if (state != ChildState) { state = TV_STATE_INDETERMINATE; } - hItem = TreeView_GetNextSibling((HWND)m_hCheatTree,hItem); - } - if (state != TV_STATE_UNKNOWN) { - TV_SetCheckState(m_hCheatTree,hParent,state); - } -} - -void CCheats::CheckParentStatus(HWND hParent) { - TV_CHECK_STATE CurrentState, InitialState; - HTREEITEM hItem; - - if (!hParent) { return; } - hItem = TreeView_GetChild((HWND)m_hCheatTree, (HTREEITEM)hParent); - InitialState = (TV_CHECK_STATE)TV_GetCheckState(m_hCheatTree,hParent); - CurrentState = (TV_CHECK_STATE)TV_GetCheckState((HWND)m_hCheatTree,(HWND)hItem); - - while (hItem != NULL) { - if (TV_GetCheckState((HWND)m_hCheatTree,(HWND)hItem) != CurrentState) { - CurrentState = TV_STATE_INDETERMINATE; - break; - } - hItem = TreeView_GetNextSibling((HWND)m_hCheatTree,hItem); - } - TV_SetCheckState((HWND)m_hCheatTree,(HWND)hParent,CurrentState); - if (InitialState != CurrentState) { - CheckParentStatus((HWND)TreeView_GetParent((HWND)m_hCheatTree,(HTREEITEM)hParent)); - } -} - -stdstr CCheats::ReadCodeString (HWND hDlg, bool &validcodes, bool &validoptions, bool &nooptions, int &codeformat ) { - int numlines, linecount, len; - char str[128]; - int i; - char* formatnormal = "XXXXXXXX XXXX"; - char* formatoptionlb = "XXXXXXXX XX??"; - char* formatoptionw = "XXXXXXXX ????"; - char tempformat[128]; - - validcodes = true; - nooptions = true; - codeformat = -1; - int numcodes = 0; - - char codestring[2048]; - memset(codestring, '\0', sizeof(codestring)); - - numlines = SendDlgItemMessage(hDlg, IDC_CHEAT_CODES, EM_GETLINECOUNT, 0, 0); - if (numlines == 0) { validcodes = false; } - - for (linecount=0; linecount 255?255:sizeof(str); - *(LPWORD)str = sizeof(str); - len = SendDlgItemMessage(hDlg, IDC_CHEAT_CODES, EM_GETLINE, (WPARAM)linecount, (LPARAM)(LPCSTR)str); - str[len] = 0; - - if (len <= 0) { continue; } - - for (i=0; i<128; i++) { - if (isxdigit(str[i])) { - tempformat[i] = 'X'; - } - if ((str[i] == ' ') || (str[i] == '?')) { - tempformat[i] = str[i]; - } - if (str[i] == 0) { break; } - } - if (strcmp(tempformat, formatnormal) == 0) { - strcat(codestring, ","); - strcat(codestring, str); - numcodes++; - if (codeformat < 0) codeformat = 0; - } - else if (strcmp(tempformat, formatoptionlb) == 0) { - if (codeformat != 2) { - strcat(codestring, ","); - strcat(codestring, str); - numcodes++; - codeformat = 1; - nooptions = false; - validoptions = false; - } - else validcodes = false; - } - else if (strcmp(tempformat, formatoptionw) == 0) { - if (codeformat != 1) { - strcat(codestring, ","); - strcat(codestring, str); - numcodes++; - codeformat = 2; - nooptions = false; - validoptions = false; - } - else validcodes = false; - } - else { - validcodes = false; - } - } - if (strlen(codestring) == 0) - { - validcodes = false; - } - return codestring; -} - -stdstr CCheats::ReadOptionsString(HWND hDlg, bool &/*validcodes*/, bool &validoptions, bool &/*nooptions*/, int &codeformat) -{ - int numlines, linecount, len; - char str[128]; - int i, j; - - validoptions = true; - int numoptions = 0; - - char optionsstring[2048]; - memset(optionsstring, '\0', sizeof(optionsstring)); - - numlines = SendDlgItemMessage(hDlg, IDC_CHEAT_OPTIONS, EM_GETLINECOUNT, 0, 0); - - for (linecount=0; linecount 255?255:sizeof(str); - *(LPWORD)str = sizeof(str); - len = SendDlgItemMessage(hDlg, IDC_CHEAT_OPTIONS, EM_GETLINE, (WPARAM)linecount, (LPARAM)(LPCSTR)str); - str[len] = 0; - - if (len > 0) { - switch (codeformat) { - case 1: //option = lower byte - if (len >= 2) { - for (i=0; i<2; i++) { - if (!isxdigit(str[i])) { - validoptions = false; - break; - } - } - - if ((str[2] != ' ') && (len > 2)) { - validoptions = false; - break; - } - - for (j=0; j<2; j++) { - str[j] = (char)toupper(str[j]); - } - - if (optionsstring[0] == 0) - { - strcat(optionsstring, "$"); - } else { - strcat(optionsstring, ",$"); - } - strcat(optionsstring, str); - numoptions++; - } - else { - validoptions = false; - break; - } - break; - - case 2: //option = word - if (len >= 4) { - for (i=0; i<4; i++) { - if (!isxdigit(str[i])) { - validoptions = false; - break; - } - } - - if (str[4] != ' ' && (len > 4)) { - validoptions = false; - break; - } - - for (j=0; j<4; j++) { - str[j] = (char)toupper(str[j]); - } - - strcat(optionsstring, ",$"); - strcat(optionsstring, str); - numoptions++; - } - else { - validoptions = false; - break; - } - break; - - default: - break; - } - } - } - - if (numoptions < 1) validoptions = false; - return optionsstring; -} diff --git a/Source/Project64/N64 System/Cheat Class.h b/Source/Project64/N64 System/Cheat Class.h index 9307d5701..a4416fc7c 100644 --- a/Source/Project64/N64 System/Cheat Class.h +++ b/Source/Project64/N64 System/Cheat Class.h @@ -10,82 +10,39 @@ ****************************************************************************/ #pragma once -class CCheats +class CCheats { public: - CCheats ( const CN64Rom * Rom = NULL ); - ~CCheats ( void ); + CCheats(); + ~CCheats(void); - bool IsCheatMessage ( MSG * msg ); - void ApplyCheats ( CMipsMemory * MMU ); - void ApplyGSButton ( CMipsMemory * MMU ); - void LoadCheats ( bool DisableSelected, CPlugins * Plugins ); - void SelectCheats ( HWND hParent, bool BlockExecution ); - inline bool CheatsSlectionChanged ( void ) const { return m_CheatSelectionChanged; } + enum + { + MaxCheats = 50000, + MaxGSEntries = 100, + }; + + void ApplyCheats(CMipsMemory * MMU); + void ApplyGSButton(CMipsMemory * MMU); + void LoadCheats(bool DisableSelected, CPlugins * Plugins); + + static bool IsValid16BitCode(const char * CheatString); private: - struct GAMESHARK_CODE { - DWORD Command; - WORD Value; - }; + struct GAMESHARK_CODE + { + uint32_t Command; + uint16_t Value; + }; - typedef std::vector CODES; - typedef std::vector CODES_ARRAY; + typedef std::vector CODES; + typedef std::vector CODES_ARRAY; - enum { MaxCheats = 50000 }; - void LoadPermCheats ( CPlugins * Plugins ); - - static int CALLBACK CheatAddProc ( HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam ); - static int CALLBACK CheatListProc ( HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam ); - static int CALLBACK ManageCheatsProc ( HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam ); - static int CALLBACK CheatsCodeExProc ( HWND hDlg, DWORD uMsg, DWORD wParam, DWORD lParam); - static int CALLBACK CheatsCodeQuantProc ( HWND hDlg, DWORD uMsg, DWORD wParam, DWORD lParam); - - //information about the gui for selecting cheats - HWND m_Window, m_hSelectCheat, m_AddCheat, m_hCheatTree, m_hSelectedItem; - const CN64Rom * m_Rom; - void * const m_rcList, * const m_rcAdd; - int m_MinSizeDlg, m_MaxSizeDlg; - int m_EditCheat; - bool m_DeleteingEntries; - CODES_ARRAY m_Codes; - bool m_CheatSelectionChanged; - - //Information about the current cheat we are editing - stdstr m_EditName; - stdstr m_EditCode; - stdstr m_EditOptions; - stdstr m_EditNotes; + void LoadPermCheats(CPlugins * Plugins); - enum Dialog_State { CONTRACTED, EXPANDED } m_DialogState; - enum TV_CHECK_STATE { TV_STATE_UNKNOWN, TV_STATE_CLEAR, TV_STATE_CHECKED, TV_STATE_INDETERMINATE }; - enum { MaxGSEntries = 100, IDC_MYTREE = 0x500 }; + const CN64Rom * m_Rom; + CODES_ARRAY m_Codes; - bool LoadCode ( int CheatNo, LPCSTR CheatString ); - void AddCodeLayers ( int CheatNumber, const stdstr &CheatName, HWND hParent, bool CheatActive ); - //Reload the cheats from the ini file to the select gui - void RefreshCheatManager (); - void ChangeChildrenStatus ( HWND hParent, bool Checked ); - void CheckParentStatus ( HWND hParent ); - static stdstr ReadCodeString ( HWND hDlg, bool &validcodes, bool &validoption, bool &nooptions, int &codeformat ); - static stdstr ReadOptionsString( HWND hDlg, bool &validcodes, bool &validoptions, bool &nooptions, int &codeformat ); - int ApplyCheatEntry (CMipsMemory * MMU,const CODES & CodeEntry, int CurrentEntry, bool Execute ); - void RecordCheatValues ( HWND hDlg ); - bool CheatChanged ( HWND hDlg ); - bool IsValid16BitCode ( LPCSTR CheatString ) const; - void DeleteCheat(int Index); - - //Get Information about the Cheat - stdstr GetCheatName ( int CheatNo, bool AddExtension ) const; - static bool CheatUsesCodeExtensions ( const stdstr &LineEntry ); - - //Working with treeview - static bool TV_SetCheckState(HWND hwndTreeView, HWND hItem, TV_CHECK_STATE state); - static int TV_GetCheckState(HWND hwndTreeView, HWND hItem); - static DWORD AsciiToHex ( const char * HexValue ); - static void MenuSetText ( HMENU hMenu, int MenuPos, const wchar_t * Title, const wchar_t * ShortCut ); - - - //UI Functions - static stdstr GetDlgItemStr (HWND hDlg, int nIDDlgItem); + bool LoadCode(int32_t CheatNo, const char * CheatString); + int32_t ApplyCheatEntry(CMipsMemory * MMU, const CODES & CodeEntry, int32_t CurrentEntry, bool Execute); }; diff --git a/Source/Project64/N64 System/Mips/System Events.cpp b/Source/Project64/N64 System/Mips/System Events.cpp index ff8b9a4e5..67e8334e3 100644 --- a/Source/Project64/N64 System/Mips/System Events.cpp +++ b/Source/Project64/N64 System/Mips/System Events.cpp @@ -49,13 +49,13 @@ void CSystemEvents::ExecuteEvents() { return; } - + Events = m_Events; m_Events.clear(); } bool bPause = false, bLoadedSave = false; - for (EventList::const_iterator iter = Events.begin(); !bLoadedSave && iter != Events.end(); iter++ ) + for (EventList::const_iterator iter = Events.begin(); !bLoadedSave && iter != Events.end(); iter++) { switch (*iter) { @@ -66,10 +66,10 @@ void CSystemEvents::ExecuteEvents() m_System->GameReset(); break; case SysEvent_ResetCPU_SoftDone: - m_System->Reset(true,false); + m_System->Reset(true, false); break; case SysEvent_ResetCPU_Hard: - m_System->Reset(true,true); + m_System->Reset(true, true); break; case SysEvent_Profile_GenerateLogs: m_System->m_Profile.GenerateLog(); @@ -106,7 +106,7 @@ void CSystemEvents::ExecuteEvents() g_Reg->DoIntrException(false); break; case SysEvent_SaveMachineState: - if (!m_System->SaveState()) + if (!m_System->SaveState()) { m_Events.push_back(SysEvent_SaveMachineState); m_bDoSomething = true; @@ -125,8 +125,9 @@ void CSystemEvents::ExecuteEvents() Notify().ChangeFullScreen(); break; case SysEvent_GSButtonPressed: - if (m_System->m_Cheats.CheatsSlectionChanged()) + if (m_System->HasCheatsSlectionChanged()) { + m_System->SetCheatsSlectionChanged(false); m_System->m_Cheats.LoadCheats(false, m_Plugins); } m_System->m_Cheats.ApplyGSButton(g_MMU); @@ -134,7 +135,7 @@ void CSystemEvents::ExecuteEvents() case SysEvent_PauseCPU_FromMenu: if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) { - g_Settings->SaveBool(GameRunning_CPU_Paused,true); + g_Settings->SaveBool(GameRunning_CPU_Paused, true); g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_FromMenu); bPause = true; } @@ -142,7 +143,7 @@ void CSystemEvents::ExecuteEvents() case SysEvent_PauseCPU_AppLostFocus: if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) { - g_Settings->SaveBool(GameRunning_CPU_Paused,true); + g_Settings->SaveBool(GameRunning_CPU_Paused, true); g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_AppLostFocus); bPause = true; } @@ -150,7 +151,7 @@ void CSystemEvents::ExecuteEvents() case SysEvent_PauseCPU_AppLostActive: if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) { - g_Settings->SaveBool(GameRunning_CPU_Paused,true); + g_Settings->SaveBool(GameRunning_CPU_Paused, true); g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_AppLostActive); bPause = true; } @@ -158,7 +159,7 @@ void CSystemEvents::ExecuteEvents() case SysEvent_PauseCPU_SaveGame: if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) { - g_Settings->SaveBool(GameRunning_CPU_Paused,true); + g_Settings->SaveBool(GameRunning_CPU_Paused, true); g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_SaveGame); bPause = true; } @@ -166,7 +167,7 @@ void CSystemEvents::ExecuteEvents() case SysEvent_PauseCPU_LoadGame: if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) { - g_Settings->SaveBool(GameRunning_CPU_Paused,true); + g_Settings->SaveBool(GameRunning_CPU_Paused, true); g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_LoadGame); bPause = true; } @@ -174,7 +175,7 @@ void CSystemEvents::ExecuteEvents() case SysEvent_PauseCPU_DumpMemory: if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) { - g_Settings->SaveBool(GameRunning_CPU_Paused,true); + g_Settings->SaveBool(GameRunning_CPU_Paused, true); g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_DumpMemory); bPause = true; } @@ -182,7 +183,7 @@ void CSystemEvents::ExecuteEvents() case SysEvent_PauseCPU_SearchMemory: if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) { - g_Settings->SaveBool(GameRunning_CPU_Paused,true); + g_Settings->SaveBool(GameRunning_CPU_Paused, true); g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_SearchMemory); bPause = true; } @@ -190,13 +191,21 @@ void CSystemEvents::ExecuteEvents() case SysEvent_PauseCPU_Settings: if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) { - g_Settings->SaveBool(GameRunning_CPU_Paused,true); + g_Settings->SaveBool(GameRunning_CPU_Paused, true); g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_Settings); bPause = true; } break; + case SysEvent_PauseCPU_Cheats: + if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) + { + g_Settings->SaveBool(GameRunning_CPU_Paused, true); + g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_Cheats); + bPause = true; + } + break; default: - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); break; } } @@ -209,6 +218,6 @@ void CSystemEvents::ExecuteEvents() void CSystemEvents::ChangePluginFunc() { - g_Notify->DisplayMessage(0,MSG_PLUGIN_INIT); + g_Notify->DisplayMessage(0, MSG_PLUGIN_INIT); m_System->PluginReset(); } diff --git a/Source/Project64/N64 System/Mips/System Events.h b/Source/Project64/N64 System/Mips/System Events.h index 3bb02bbc3..de868c75c 100644 --- a/Source/Project64/N64 System/Mips/System Events.h +++ b/Source/Project64/N64 System/Mips/System Events.h @@ -12,42 +12,44 @@ enum SystemEvent { - SysEvent_ExecuteInterrupt, - SysEvent_GSButtonPressed, - SysEvent_ResetCPU_Soft, - SysEvent_ResetCPU_SoftDone, - SysEvent_ResetCPU_Hard, - SysEvent_CloseCPU, - SysEvent_PauseCPU_FromMenu, - SysEvent_PauseCPU_AppLostActive, - SysEvent_PauseCPU_AppLostActiveDelay, - SysEvent_PauseCPU_AppLostFocus, - SysEvent_PauseCPU_SaveGame, - SysEvent_PauseCPU_LoadGame, - SysEvent_PauseCPU_DumpMemory, - SysEvent_PauseCPU_SearchMemory, - SysEvent_PauseCPU_Settings, - SysEvent_ResumeCPU_FromMenu, - SysEvent_ResumeCPU_AppGainedActive, - SysEvent_ResumeCPU_AppGainedFocus, - SysEvent_ResumeCPU_SaveGame, - SysEvent_ResumeCPU_LoadGame, - SysEvent_ResumeCPU_DumpMemory, - SysEvent_ResumeCPU_SearchMemory, - SysEvent_ResumeCPU_Settings, - SysEvent_ChangingFullScreen, - SysEvent_ChangePlugins, - SysEvent_SaveMachineState, - SysEvent_LoadMachineState, - SysEvent_Interrupt_SP, - SysEvent_Interrupt_SI, - SysEvent_Interrupt_AI, - SysEvent_Interrupt_VI, - SysEvent_Interrupt_PI, - SysEvent_Interrupt_DP, - SysEvent_Profile_StartStop, - SysEvent_Profile_ResetLogs, - SysEvent_Profile_GenerateLogs, + SysEvent_ExecuteInterrupt, + SysEvent_GSButtonPressed, + SysEvent_ResetCPU_Soft, + SysEvent_ResetCPU_SoftDone, + SysEvent_ResetCPU_Hard, + SysEvent_CloseCPU, + SysEvent_PauseCPU_FromMenu, + SysEvent_PauseCPU_AppLostActive, + SysEvent_PauseCPU_AppLostActiveDelay, + SysEvent_PauseCPU_AppLostFocus, + SysEvent_PauseCPU_SaveGame, + SysEvent_PauseCPU_LoadGame, + SysEvent_PauseCPU_DumpMemory, + SysEvent_PauseCPU_SearchMemory, + SysEvent_PauseCPU_Settings, + SysEvent_PauseCPU_Cheats, + SysEvent_ResumeCPU_FromMenu, + SysEvent_ResumeCPU_AppGainedActive, + SysEvent_ResumeCPU_AppGainedFocus, + SysEvent_ResumeCPU_SaveGame, + SysEvent_ResumeCPU_LoadGame, + SysEvent_ResumeCPU_DumpMemory, + SysEvent_ResumeCPU_SearchMemory, + SysEvent_ResumeCPU_Settings, + SysEvent_ResumeCPU_Cheats, + SysEvent_ChangingFullScreen, + SysEvent_ChangePlugins, + SysEvent_SaveMachineState, + SysEvent_LoadMachineState, + SysEvent_Interrupt_SP, + SysEvent_Interrupt_SI, + SysEvent_Interrupt_AI, + SysEvent_Interrupt_VI, + SysEvent_Interrupt_PI, + SysEvent_Interrupt_DP, + SysEvent_Profile_StartStop, + SysEvent_Profile_ResetLogs, + SysEvent_Profile_GenerateLogs, }; class CSystemEvents diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index 8ae0ec6ee..944f0008d 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -15,34 +15,34 @@ #include #include -CN64System::CN64System ( CPlugins * Plugins, bool SavesReadOnly ) : - CSystemEvents(this, Plugins), - m_Cheats(NULL), - m_EndEmulation(false), - m_SaveUsing((SAVE_CHIP_TYPE)g_Settings->LoadDword(Game_SaveChip)), - m_Plugins(Plugins), - m_SyncCPU(NULL), - m_SyncPlugins(NULL), - m_SyncWindow(NULL), - m_MMU_VM(this,SavesReadOnly), - m_TLB(this), - m_Reg(this,this), - m_Recomp(NULL), - m_InReset(false), - m_NextTimer(0), - m_SystemTimer(m_NextTimer), - m_bCleanFrameBox(true), - m_bInitialized(false), - m_RspBroke(true), - m_DMAUsed(false), - m_TestTimer(false), - m_NextInstruction(0), - m_JumpToLocation(0), - m_TLBLoadAddress(0), - m_TLBStoreAddress(0), - m_SyncCount(0), - m_CPU_Handle(NULL), - m_CPU_ThreadID(0) +CN64System::CN64System(CPlugins * Plugins, bool SavesReadOnly) : +CSystemEvents(this, Plugins), +m_EndEmulation(false), +m_SaveUsing((SAVE_CHIP_TYPE)g_Settings->LoadDword(Game_SaveChip)), +m_Plugins(Plugins), +m_SyncCPU(NULL), +m_SyncPlugins(NULL), +m_SyncWindow(NULL), +m_MMU_VM(this, SavesReadOnly), +m_TLB(this), +m_Reg(this, this), +m_Recomp(NULL), +m_InReset(false), +m_NextTimer(0), +m_SystemTimer(m_NextTimer), +m_bCleanFrameBox(true), +m_bInitialized(false), +m_RspBroke(true), +m_DMAUsed(false), +m_TestTimer(false), +m_NextInstruction(0), +m_JumpToLocation(0), +m_TLBLoadAddress(0), +m_TLBStoreAddress(0), +m_SyncCount(0), +m_CPU_Handle(NULL), +m_CPU_ThreadID(0), +m_CheatsSlectionChanged(false) { DWORD gameHertz = g_Settings->LoadDword(Game_ScreenHertz); if (gameHertz == 0) @@ -115,9 +115,10 @@ void CN64System::ExternalEvent ( SystemEvent action ) case SysEvent_PauseCPU_DumpMemory: case SysEvent_PauseCPU_SearchMemory: case SysEvent_PauseCPU_Settings: + case SysEvent_PauseCPU_Cheats: if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) { - QueueEvent(action); + QueueEvent(action); } break; case SysEvent_ResumeCPU_FromMenu: @@ -166,9 +167,15 @@ void CN64System::ExternalEvent ( SystemEvent action ) SetEvent(m_hPauseEvent); } break; + case SysEvent_ResumeCPU_Cheats: + if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_Cheats) + { + SetEvent(m_hPauseEvent); + } + break; default: - WriteTraceF(TraceError,__FUNCTION__ ": Unknown event %d",action); - g_Notify->BreakPoint(__FILEW__,__LINE__); + WriteTraceF(TraceError, __FUNCTION__ ": Unknown event %d", action); + g_Notify->BreakPoint(__FILEW__, __LINE__); } } @@ -453,11 +460,6 @@ void CN64System::CloseCpu() CpuStopped(); } -void CN64System::SelectCheats ( HWND hParent ) -{ - m_Cheats.SelectCheats(hParent,false); -} - void CN64System::DisplayRomInfo ( HWND hParent ) { if (!g_Rom) { return; } @@ -508,15 +510,6 @@ stdstr CN64System::ChooseFileToOpen ( HWND hParent ) return stdstr(""); } -bool CN64System::IsDialogMsg( MSG * msg ) -{ - if (m_Cheats.IsCheatMessage(msg)) - { - return true; - } - return false; -} - void CN64System::GameReset() { m_SystemTimer.SetTimer(CSystemTimer::SoftResetTimer,0x3000000,false); @@ -2051,19 +2044,20 @@ void CN64System::RefreshScreen() m_CPU_Usage.ShowCPU_Usage(); m_CPU_Usage.StartTimer(CPU_UsageAddr != Timer_None ? CPU_UsageAddr : Timer_R4300 ); } - if ((m_Reg.STATUS_REGISTER & STATUS_IE) != 0 ) - { - if (g_BaseSystem == NULL) + if ((m_Reg.STATUS_REGISTER & STATUS_IE) != 0) + { + if (HasCheatsSlectionChanged()) { - return; + if (this == g_BaseSystem && g_SyncSystem != NULL) + { + g_SyncSystem->SetCheatsSlectionChanged(true); + } + SetCheatsSlectionChanged(false); + m_Cheats.LoadCheats(false, g_BaseSystem->m_Plugins); } - if (g_BaseSystem->m_Cheats.CheatsSlectionChanged()) - { - g_BaseSystem->m_Cheats.LoadCheats(false, g_BaseSystem->m_Plugins); - } - g_BaseSystem->m_Cheats.ApplyCheats(g_MMU); + m_Cheats.ApplyCheats(g_MMU); } -// if (bProfiling) { m_Profile.StartTimer(ProfilingAddr != Timer_None ? ProfilingAddr : Timer_R4300); } + // if (bProfiling) { m_Profile.StartTimer(ProfilingAddr != Timer_None ? ProfilingAddr : Timer_R4300); } } bool CN64System::WriteToProtectedMemory (DWORD Address, int length) diff --git a/Source/Project64/N64 System/N64 Class.h b/Source/Project64/N64 System/N64 Class.h index 7c6c8700c..3bf2f2309 100644 --- a/Source/Project64/N64 System/N64 Class.h +++ b/Source/Project64/N64 System/N64 Class.h @@ -50,10 +50,8 @@ public: void ExternalEvent ( SystemEvent action ); //covers gui interacting and timers etc.. stdstr ChooseFileToOpen ( HWND hParent ); void DisplayRomInfo ( HWND hParent ); - void SelectCheats ( HWND hParent ); void StartEmulation ( bool NewThread ); void SyncToAudio (); - bool IsDialogMsg ( MSG * msg ); void IncreaseSpeed () { m_Limitor.IncreaseSpeed(); } void DecreaseSpeed () { m_Limitor.DecreaseSpeed(); } void Reset ( bool bInitReg, bool ClearMenory ); @@ -68,6 +66,8 @@ public: bool DmaUsed() const { return m_DMAUsed; } void SetDmaUsed(bool DMAUsed) { m_DMAUsed = DMAUsed; } + void SetCheatsSlectionChanged(bool changed) { m_CheatsSlectionChanged = changed; } + bool HasCheatsSlectionChanged(void) const { return m_CheatsSlectionChanged; } DWORD GetButtons(int Control) const { return m_Buttons[Control]; } //Variable used to track that the SP is being handled and stays the same as the real SP in sync core @@ -144,6 +144,7 @@ private: DWORD m_TLBLoadAddress; DWORD m_TLBStoreAddress; DWORD m_SyncCount; + bool m_CheatsSlectionChanged; //When Syncing cores this is the PC where it last Sync'ed correctly DWORD m_LastSuccessSyncPC[10]; diff --git a/Source/Project64/N64 System/N64 Types.h b/Source/Project64/N64 System/N64 Types.h index 9855fc7f9..91e1fbe8f 100644 --- a/Source/Project64/N64 System/N64 Types.h +++ b/Source/Project64/N64 System/N64 Types.h @@ -26,61 +26,71 @@ enum PauseType PauseType_DumpMemory, PauseType_SearchMemory, PauseType_Settings, + PauseType_Cheats, }; -enum CPU_TYPE { +enum CPU_TYPE +{ CPU_Default = -1, CPU_Interpreter = 1, CPU_Recompiler = 2, CPU_SyncCores = 3 }; -enum FRAMERATE_TYPE { +enum FRAMERATE_TYPE +{ FR_VIs = 0, FR_DLs = 1, FR_PERCENT = 2, }; -enum SAVE_CHIP_TYPE { - SaveChip_Auto = -1, SaveChip_Eeprom_4K, SaveChip_Eeprom_16K, SaveChip_Sram, SaveChip_FlashRam +enum SAVE_CHIP_TYPE +{ + SaveChip_Auto = -1, SaveChip_Eeprom_4K, SaveChip_Eeprom_16K, SaveChip_Sram, SaveChip_FlashRam }; enum FUNC_LOOKUP_METHOD { - FuncFind_Default = -1, FuncFind_PhysicalLookup = 1, FuncFind_VirtualLookup = 2, FuncFind_ChangeMemory = 3, + FuncFind_Default = -1, FuncFind_PhysicalLookup = 1, FuncFind_VirtualLookup = 2, FuncFind_ChangeMemory = 3, }; -enum SYSTEM_TYPE { +enum SYSTEM_TYPE +{ SYSTEM_NTSC = 0, SYSTEM_PAL = 1, SYSTEM_MPAL = 2 }; -enum CICChip { - CIC_UNKNOWN = -1, CIC_NUS_6101 = 1, CIC_NUS_6102 = 2, CIC_NUS_6103 = 3, - CIC_NUS_6104 = 4, CIC_NUS_6105 = 5, CIC_NUS_6106 = 6, CIC_NUS_5167 = 7, +enum CICChip +{ + CIC_UNKNOWN = -1, CIC_NUS_6101 = 1, CIC_NUS_6102 = 2, CIC_NUS_6103 = 3, + CIC_NUS_6104 = 4, CIC_NUS_6105 = 5, CIC_NUS_6106 = 6, CIC_NUS_5167 = 7, CIC_NUS_8303 = 8 }; -enum Country { - NTSC_BETA = 0x37, X_NTSC = 0x41, Germany = 0x44, USA = 0x45, french = 0x46, Italian = 0x49, - Japan = 0x4A, Europe = 0x50, Spanish = 0x53, Australia = 0x55, X_PAL = 0x58, Y_PAL = 0x59, +enum Country +{ + NTSC_BETA = 0x37, X_NTSC = 0x41, Germany = 0x44, USA = 0x45, french = 0x46, Italian = 0x49, + Japan = 0x4A, Europe = 0x50, Spanish = 0x53, Australia = 0x55, X_PAL = 0x58, Y_PAL = 0x59, UnknownCountry = 0 }; -enum SPECIAL_TIMERS { - Timer_None = 0, Timer_R4300 = -1, Timer_RSP_Dlist = -2, - Timer_RSP_Alist = -3, Timer_RSP_Unknown = -5, Timer_RefreshScreen = -6, - Timer_UpdateScreen = -7, Timer_UpdateFPS = -9, Timer_Idel = -10, - Timer_FuncLookup = -11,Timer_Done = -13,Timer_GetBlockInfo = -14, - Timer_AnalyseBlock = -15,Timer_CompileBlock = -17, Timer_CompileDone = -18, +enum SPECIAL_TIMERS +{ + Timer_None = 0, Timer_R4300 = -1, Timer_RSP_Dlist = -2, + Timer_RSP_Alist = -3, Timer_RSP_Unknown = -5, Timer_RefreshScreen = -6, + Timer_UpdateScreen = -7, Timer_UpdateFPS = -9, Timer_Idel = -10, + Timer_FuncLookup = -11, Timer_Done = -13, Timer_GetBlockInfo = -14, + Timer_AnalyseBlock = -15, Timer_CompileBlock = -17, Timer_CompileDone = -18, Timer_InheritParentInfo = -19, Timer_AddX86Code = -20, }; -enum STEP_TYPE { - NORMAL = 0, - DO_DELAY_SLOT = 1, - DO_END_DELAY_SLOT = 2, - DELAY_SLOT = 3, - END_DELAY_SLOT = 4, - LIKELY_DELAY_SLOT = 5, - JUMP = 6, - DELAY_SLOT_DONE = 7, - LIKELY_DELAY_SLOT_DONE= 8, - END_BLOCK = 9, - PERMLOOP_DO_DELAY = 10, - PERMLOOP_DELAY_DONE = 11, +enum STEP_TYPE +{ + NORMAL = 0, + DO_DELAY_SLOT = 1, + DO_END_DELAY_SLOT = 2, + DELAY_SLOT = 3, + END_DELAY_SLOT = 4, + LIKELY_DELAY_SLOT = 5, + JUMP = 6, + DELAY_SLOT_DONE = 7, + LIKELY_DELAY_SLOT_DONE = 8, + END_BLOCK = 9, + PERMLOOP_DO_DELAY = 10, + PERMLOOP_DELAY_DONE = 11, }; + diff --git a/Source/Project64/Project64.vcproj b/Source/Project64/Project64.vcproj index 75471d983..018e4541d 100644 --- a/Source/Project64/Project64.vcproj +++ b/Source/Project64/Project64.vcproj @@ -284,6 +284,10 @@ + + @@ -936,6 +940,10 @@ + + diff --git a/Source/Project64/Project64.vcxproj b/Source/Project64/Project64.vcxproj index b0f514ca7..53f2f7048 100644 --- a/Source/Project64/Project64.vcxproj +++ b/Source/Project64/Project64.vcxproj @@ -74,6 +74,7 @@ + @@ -186,6 +187,7 @@ + diff --git a/Source/Project64/Project64.vcxproj.filters b/Source/Project64/Project64.vcxproj.filters index 9a2ce8ce0..2ad467552 100644 --- a/Source/Project64/Project64.vcxproj.filters +++ b/Source/Project64/Project64.vcxproj.filters @@ -417,6 +417,9 @@ Source Files\Multilanguage Source + + Source Files\User Interface Source + @@ -842,5 +845,8 @@ Header Files\Multilanguage Headers + + Header Files\User Interface Headers + \ No newline at end of file diff --git a/Source/Project64/User Interface.h b/Source/Project64/User Interface.h index c239379d6..a322eca86 100644 --- a/Source/Project64/User Interface.h +++ b/Source/Project64/User Interface.h @@ -61,3 +61,4 @@ class CN64System; #include ".\\User Interface\\Frame Per Second Class.h" #include ".\\User Interface\\resource.h" #include ".\\User Interface\\Settings Config.h" +#include ".\\User Interface\\Cheat Class UI.h" diff --git a/Source/Project64/User Interface/Cheat Class UI.cpp b/Source/Project64/User Interface/Cheat Class UI.cpp new file mode 100644 index 000000000..b9bdca508 --- /dev/null +++ b/Source/Project64/User Interface/Cheat Class UI.cpp @@ -0,0 +1,1545 @@ +/**************************************************************************** +* * +* Project 64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2012 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +#include "stdafx.h" +#include +#include + +extern CCheatsUI * g_cheatUI = NULL; + +enum +{ + WM_EDITCHEAT = WM_USER + 0x120, + UM_CHANGECODEEXTENSION = WM_USER + 0x121, +}; + +CCheatsUI::CCheatsUI(void) : +m_rcList(new RECT), +m_rcAdd(new RECT), +m_EditCheat(-1), +m_DeleteingEntries(false) +{ + m_Window = NULL; + m_hSelectCheat = NULL; + m_AddCheat = NULL; + m_hCheatTree = NULL; +} + +CCheatsUI::~CCheatsUI() +{ + delete m_rcList; + delete m_rcAdd; +} + +void CCheatsUI::AddCodeLayers(int CheatNumber, const stdstr &CheatName, HWND hParent, bool CheatActive) +{ + TV_INSERTSTRUCT tv; + + //Work out text to add + char Text[500], Item[500]; + if (CheatName.length() > (sizeof(Text) - 5)) { g_Notify->BreakPoint(__FILEW__, __LINE__); } + strcpy(Text, CheatName.c_str()); + if (strchr(Text, '\\') > 0) { *strchr(Text, '\\') = 0; } + + //See if text is already added + tv.item.mask = TVIF_TEXT; + tv.item.pszText = Item; + tv.item.cchTextMax = sizeof(Item); + tv.item.hItem = TreeView_GetChild(m_hCheatTree, hParent); + while (tv.item.hItem) + { + TreeView_GetItem(m_hCheatTree, &tv.item); + if (strcmp(Text, Item) == 0) + { + //If already exists then just use existing one + int State = TV_GetCheckState(m_hCheatTree, (HWND)tv.item.hItem); + if ((CheatActive && State == TV_STATE_CLEAR) || (!CheatActive && State == TV_STATE_CHECKED)) + { + TV_SetCheckState(m_hCheatTree, (HWND)tv.item.hItem, TV_STATE_INDETERMINATE); + } + size_t StartPos = strlen(Text) + 1; + stdstr TempCheatName; + if (StartPos < CheatName.length()) + { + TempCheatName = CheatName.substr(StartPos); + } + AddCodeLayers(CheatNumber, TempCheatName, (HWND)tv.item.hItem, CheatActive); + return; + } + tv.item.hItem = TreeView_GetNextSibling(m_hCheatTree, tv.item.hItem); + } + + //Add to dialog + tv.hInsertAfter = TVI_SORT; + tv.item.mask = TVIF_TEXT | TVIF_PARAM; + tv.item.pszText = Text; + tv.item.lParam = CheatNumber; + tv.hParent = (HTREEITEM)hParent; + hParent = (HWND)TreeView_InsertItem(m_hCheatTree, &tv); + TV_SetCheckState(m_hCheatTree, hParent, CheatActive ? TV_STATE_CHECKED : TV_STATE_CLEAR); + + if (strcmp(Text, CheatName.c_str()) == 0) { return; } + AddCodeLayers(CheatNumber, (stdstr)(CheatName.substr(strlen(Text) + 1)), hParent, CheatActive); +} + +void CCheatsUI::RefreshCheatManager() +{ + if (m_Window == NULL) { return; } + + m_DeleteingEntries = true; + TreeView_DeleteAllItems(m_hCheatTree); + m_DeleteingEntries = false; + for (int i = 0; i < CCheats::MaxCheats; i++) + { + stdstr Name = GetCheatName(i, true); + if (Name.length() == 0) { break; } + + AddCodeLayers(i, Name, (HWND)TVI_ROOT, g_Settings->LoadBoolIndex(Cheat_Active, i) != 0); + } +} + +stdstr CCheatsUI::GetDlgItemStr(HWND hDlg, int nIDDlgItem) +{ + HWND hDlgItem = GetDlgItem(hDlg, nIDDlgItem); + int length = SendMessage(hDlgItem, WM_GETTEXTLENGTH, 0, 0); + if (length == 0) + { + return ""; + } + + stdstr Result; + Result.resize(length + 1); + + GetWindowText(hDlgItem, (char *)Result.c_str(), Result.length()); + return Result; +} + +void CCheatsUI::SelectCheats(HWND hParent, bool BlockExecution) +{ + if (g_BaseSystem) + { + g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_Cheats); + } + if (m_Window != NULL) + { + SetForegroundWindow(m_Window); + return; + } + if (hParent) + { + if (BlockExecution) + { + DialogBoxParamW(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_Cheats_Select), hParent, (DLGPROC)ManageCheatsProc, (LPARAM)this); + } + else + { + CreateDialogParamW(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_Cheats_Select), hParent, (DLGPROC)ManageCheatsProc, (LPARAM)this); + } + } +} + +bool CCheatsUI::CheatChanged(HWND hDlg) +{ + bool Changed = false; + if (m_EditName != GetDlgItemStr(hDlg, IDC_CODE_NAME) || + m_EditCode != GetDlgItemStr(hDlg, IDC_CHEAT_CODES) || + m_EditOptions != GetDlgItemStr(hDlg, IDC_CHEAT_OPTIONS) || + m_EditNotes != GetDlgItemStr(hDlg, IDC_NOTES)) + { + Changed = true; + } + if (!Changed) + { + return false; + } + int Result = MessageBoxW(hDlg, GS(CHEAT_CHANGED_MSG), GS(CHEAT_CHANGED_TITLE), MB_YESNOCANCEL); + if (Result == IDCANCEL) + { + return true; + } + if (Result == IDYES) + { + SendMessage(hDlg, WM_COMMAND, MAKELPARAM(IDC_ADD, 0), (LPARAM)GetDlgItem(hDlg, IDC_ADD)); + } + return false; +} + +void CCheatsUI::RecordCheatValues(HWND hDlg) +{ + m_EditName = GetDlgItemStr(hDlg, IDC_CODE_NAME); + m_EditCode = GetDlgItemStr(hDlg, IDC_CHEAT_CODES); + m_EditOptions = GetDlgItemStr(hDlg, IDC_CHEAT_OPTIONS); + m_EditNotes = GetDlgItemStr(hDlg, IDC_NOTES); +} + +int CALLBACK CCheatsUI::CheatAddProc(HWND hDlg, uint32_t uMsg, uint32_t wParam, uint32_t lParam) +{ + switch (uMsg) + { + case WM_INITDIALOG: + { + CCheatsUI * _this = (CCheatsUI *)lParam; + SetProp(hDlg, "Class", _this); + + SetWindowTextW(hDlg, GS(CHEAT_ADDCHEAT_FRAME)); + SetWindowTextW(GetDlgItem(hDlg, IDC_NAME), GS(CHEAT_ADDCHEAT_NAME)); + SetWindowTextW(GetDlgItem(hDlg, IDC_CODE), GS(CHEAT_ADDCHEAT_CODE)); + SetWindowTextW(GetDlgItem(hDlg, IDC_LABEL_OPTIONS), GS(CHEAT_ADDCHEAT_OPT)); + SetWindowTextW(GetDlgItem(hDlg, IDC_CODE_DES), GS(CHEAT_ADDCHEAT_CODEDES)); + SetWindowTextW(GetDlgItem(hDlg, IDC_LABEL_OPTIONS_FORMAT), GS(CHEAT_ADDCHEAT_OPTDES)); + SetWindowTextW(GetDlgItem(hDlg, IDC_CHEATNOTES), GS(CHEAT_ADDCHEAT_NOTES)); + SetWindowTextW(GetDlgItem(hDlg, IDC_NEWCHEAT), GS(CHEAT_ADDCHEAT_NEW)); + SetWindowTextW(GetDlgItem(hDlg, IDC_ADD), GS(CHEAT_ADDCHEAT_ADD)); + SetProp(hDlg, "validcodes", false); + _this->RecordCheatValues(hDlg); + } + break; + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case IDC_CODE_NAME: + if (HIWORD(wParam) == EN_CHANGE) + { + bool validcodes, validoptions, nooptions; + int CodeFormat; + ReadCodeString(hDlg, validcodes, validoptions, nooptions, CodeFormat); + if (!nooptions) + { + ReadOptionsString(hDlg, validcodes, validoptions, nooptions, CodeFormat); + } + + if (validcodes && (validoptions || nooptions) && SendDlgItemMessage(hDlg, IDC_CODE_NAME, EM_LINELENGTH, 0, 0) > 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_ADD), true); + } + else + { + EnableWindow(GetDlgItem(hDlg, IDC_ADD), false); + } + } + break; + case IDC_CHEAT_CODES: + if (HIWORD(wParam) == EN_CHANGE) + { + bool validcodes, validoptions, nooptions; + int CodeFormat; + ReadCodeString(hDlg, validcodes, validoptions, nooptions, CodeFormat); + + if ((CodeFormat > 0) && !IsWindowEnabled(GetDlgItem(hDlg, IDC_LABEL_OPTIONS))) + { + EnableWindow(GetDlgItem(hDlg, IDC_LABEL_OPTIONS), true); + EnableWindow(GetDlgItem(hDlg, IDC_LABEL_OPTIONS_FORMAT), true); + EnableWindow(GetDlgItem(hDlg, IDC_CHEAT_OPTIONS), true); + } + if ((CodeFormat <= 0) && IsWindowEnabled(GetDlgItem(hDlg, IDC_LABEL_OPTIONS))) + { + EnableWindow(GetDlgItem(hDlg, IDC_LABEL_OPTIONS), false); + EnableWindow(GetDlgItem(hDlg, IDC_LABEL_OPTIONS_FORMAT), false); + EnableWindow(GetDlgItem(hDlg, IDC_CHEAT_OPTIONS), false); + } + + if (!nooptions) + { + ReadOptionsString(hDlg, validcodes, validoptions, nooptions, CodeFormat); + } + + if (validcodes && (validoptions || nooptions) && SendDlgItemMessage(hDlg, IDC_CODE_NAME, EM_LINELENGTH, 0, 0) > 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_ADD), true); + } + else + { + EnableWindow(GetDlgItem(hDlg, IDC_ADD), false); + } + } + break; + case IDC_CHEAT_OPTIONS: + if (HIWORD(wParam) == EN_CHANGE) + { + bool validcodes, validoptions, nooptions; + int CodeFormat; + ReadOptionsString(hDlg, validcodes, validoptions, nooptions, CodeFormat); + + if (validcodes && (validoptions || nooptions) && SendDlgItemMessage(hDlg, IDC_CODE_NAME, EM_LINELENGTH, 0, 0) > 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_ADD), true); + } + else + { + EnableWindow(GetDlgItem(hDlg, IDC_ADD), false); + } + } + break; + case IDC_ADD: + { + CCheatsUI * _this = (CCheatsUI *)GetProp(hDlg, "Class"); + + stdstr NewCheatName = GetDlgItemStr(hDlg, IDC_CODE_NAME); + int i = 0; + for (i = 0; i < CCheats::MaxCheats; i++) + { + if (_this->m_EditCheat == i) + { + continue; + } + stdstr CheatName(_this->GetCheatName(i, false)); + if (CheatName.length() == 0) + { + if (_this->m_EditCheat < 0) + { + _this->m_EditCheat = i; + } + break; + } + if (_stricmp(CheatName.c_str(), NewCheatName.c_str()) == 0) + { + g_Notify->DisplayError(GS(MSG_CHEAT_NAME_IN_USE)); + SetFocus(GetDlgItem(hDlg, IDC_CODE_NAME)); + return true; + } + } + if (_this->m_EditCheat < 0 && i == CCheats::MaxCheats) + { + g_Notify->DisplayError(GS(MSG_MAX_CHEATS)); + return true; + } + + //Update the entries + bool validcodes, validoptions, nooptions; + int CodeFormat; + stdstr_f Cheat("\"%s\"%s", NewCheatName.c_str(), ReadCodeString(hDlg, validcodes, validoptions, nooptions, CodeFormat).c_str()); + stdstr Options = ReadOptionsString(hDlg, validcodes, validoptions, nooptions, CodeFormat); + + g_Settings->SaveStringIndex(Cheat_Entry, _this->m_EditCheat, Cheat.c_str()); + g_Settings->SaveStringIndex(Cheat_Notes, _this->m_EditCheat, GetDlgItemStr(hDlg, IDC_NOTES)); + g_Settings->SaveStringIndex(Cheat_Options, _this->m_EditCheat, Options); + _this->RecordCheatValues(hDlg); + CSettingTypeCheats::FlushChanges(); + _this->RefreshCheatManager(); + } + break; + case IDC_NEWCHEAT: + { + CCheatsUI * _this = (CCheatsUI *)GetProp(hDlg, "Class"); + + if (_this->CheatChanged(hDlg)) + { + break; + } + _this->m_EditCheat = -1; + SetDlgItemText(hDlg, IDC_CODE_NAME, ""); + SetDlgItemText(hDlg, IDC_CHEAT_CODES, ""); + SetDlgItemText(hDlg, IDC_CHEAT_OPTIONS, ""); + SetDlgItemText(hDlg, IDC_NOTES, ""); + EnableWindow(GetDlgItem(hDlg, IDC_ADD), false); + EnableWindow(GetDlgItem(hDlg, IDC_CHEAT_OPTIONS), false); + SetDlgItemTextW(hDlg, IDC_ADD, GS(CHEAT_ADDNEW)); + _this->RecordCheatValues(hDlg); + } + break; + } + } + break; + case WM_EDITCHEAT: + { + CCheatsUI * _this = (CCheatsUI *)GetProp(hDlg, "Class"); + _this->m_EditCheat = wParam; + if (_this->m_EditCheat < 0) + { + break; + } + + if (_this->CheatChanged(hDlg)) + { + break; + } + + stdstr CheatEntryStr = g_Settings->LoadStringIndex(Cheat_Entry, _this->m_EditCheat); + const char * String = CheatEntryStr.c_str(); + + //Set Cheat Name + int len = strrchr(String, '"') - strchr(String, '"') - 1; + stdstr CheatName(strchr(String, '"') + 1); + CheatName.resize(len); + SetDlgItemText(hDlg, IDC_CODE_NAME, CheatName.c_str()); + + //Add Gameshark codes to screen + const char * ReadPos = strrchr(String, '"') + 2; + stdstr Buffer; + do + { + char * End = strchr((char *)ReadPos, ','); + if (End) + { + Buffer.append(ReadPos, End - ReadPos); + } + else + { + Buffer.append(ReadPos); + } + + ReadPos = strchr(ReadPos, ','); + if (ReadPos != NULL) + { + Buffer.append("\r\n"); + ReadPos += 1; + } + } while (ReadPos); + SetDlgItemText(hDlg, IDC_CHEAT_CODES, Buffer.c_str()); + + //Add option values to screen + stdstr CheatOptionStr = g_Settings->LoadStringIndex(Cheat_Options, _this->m_EditCheat); + ReadPos = strchr(CheatOptionStr.c_str(), '$'); + Buffer.erase(); + if (ReadPos) + { + ReadPos += 1; + do + { + char * End = strchr((char *)ReadPos, ','); + if (End) + { + Buffer.append(ReadPos, End - ReadPos); + } + else + { + Buffer.append(ReadPos); + } + ReadPos = strchr(ReadPos, '$'); + if (ReadPos != NULL) + { + Buffer.append("\r\n"); + ReadPos += 1; + } + } while (ReadPos); + } + SetDlgItemText(hDlg, IDC_CHEAT_OPTIONS, Buffer.c_str()); + + //Add cheat Notes + stdstr CheatNotesStr = g_Settings->LoadStringIndex(Cheat_Notes, _this->m_EditCheat); + SetDlgItemText(hDlg, IDC_NOTES, CheatNotesStr.c_str()); + + SendMessage(hDlg, WM_COMMAND, MAKELPARAM(IDC_CHEAT_CODES, EN_CHANGE), (LPARAM)GetDlgItem(hDlg, IDC_CHEAT_CODES)); + SetDlgItemTextW(hDlg, IDC_ADD, GS(CHEAT_EDITCHEAT_UPDATE)); + + _this->RecordCheatValues(hDlg); + } + break; + default: + return false; + } + return true; +} + +int CALLBACK CCheatsUI::CheatListProc(HWND hDlg, uint32_t uMsg, uint32_t wParam, uint32_t lParam) +{ + switch (uMsg) + { + case WM_INITDIALOG: + { + CCheatsUI * _this = (CCheatsUI *)lParam; + SetProp(hDlg, "Class", _this); + + uint32_t Style; + RECT rcList; + RECT rcButton; + + SetWindowTextW(GetDlgItem(hDlg, IDC_CHEATSFRAME), GS(CHEAT_LIST_FRAME)); + SetWindowTextW(GetDlgItem(hDlg, IDC_NOTESFRAME), GS(CHEAT_NOTES_FRAME)); + SetWindowTextW(GetDlgItem(hDlg, IDC_UNMARK), GS(CHEAT_MARK_NONE)); + + GetWindowRect(GetDlgItem(hDlg, IDC_CHEATSFRAME), &rcList); + GetWindowRect(GetDlgItem(hDlg, IDC_UNMARK), &rcButton); + + _this->m_hCheatTree = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "", + WS_CHILD | WS_VISIBLE | WS_VSCROLL | TVS_HASLINES | + TVS_HASBUTTONS | TVS_LINESATROOT | TVS_DISABLEDRAGDROP | WS_TABSTOP | + TVS_FULLROWSELECT, 8, 15, rcList.right - rcList.left - 16, + rcButton.top - rcList.top - 22, hDlg, (HMENU)IDC_MYTREE, GetModuleHandle(NULL), NULL); + Style = GetWindowLong(_this->m_hCheatTree, GWL_STYLE); + SetWindowLong(_this->m_hCheatTree, GWL_STYLE, TVS_CHECKBOXES | TVS_SHOWSELALWAYS | Style); + + //Creats an image list from the bitmap in the resource section + HIMAGELIST hImageList; + HBITMAP hBmp; + + hImageList = ImageList_Create(16, 16, ILC_COLOR | ILC_MASK, 40, 40); + hBmp = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_TRI_STATE)); + ImageList_AddMasked(hImageList, hBmp, RGB(255, 0, 255)); + DeleteObject(hBmp); + + TreeView_SetImageList(_this->m_hCheatTree, hImageList, TVSIL_STATE); + + _this->m_hSelectedItem = NULL; + } + break; + case WM_COMMAND: + { + CCheatsUI * _this = (CCheatsUI *)GetProp(hDlg, "Class"); + + switch (LOWORD(wParam)) + { + case ID_POPUP_DELETE: + { + TVITEM item; + + int Response = MessageBoxW(hDlg, GS(MSG_DEL_SURE), GS(MSG_DEL_TITLE), MB_YESNO | MB_ICONQUESTION); + if (Response != IDYES) { break; } + + //Delete selected cheat + item.hItem = (HTREEITEM)_this->m_hSelectedItem; + item.mask = TVIF_PARAM; + TreeView_GetItem(_this->m_hCheatTree, &item); + + _this->ChangeChildrenStatus((HWND)TVI_ROOT, false); + _this->DeleteCheat(item.lParam); + _this->RefreshCheatManager(); + } + break; + case IDC_UNMARK: + _this->ChangeChildrenStatus((HWND)TVI_ROOT, false); + if (g_BaseSystem) + { + g_BaseSystem->SetCheatsSlectionChanged(true); + } + break; + } + } + break; + case WM_NOTIFY: + { + CCheatsUI * _this = (CCheatsUI *)GetProp(hDlg, "Class"); + + if (_this->m_DeleteingEntries) + { + break; + } + LPNMHDR lpnmh = (LPNMHDR)lParam; + + if ((lpnmh->code == NM_RCLICK) && (lpnmh->idFrom == IDC_MYTREE)) + { + //Work out what item is selected + TVHITTESTINFO ht = { 0 }; + uint32_t dwpos = GetMessagePos(); + + // include and header files + ht.pt.x = GET_X_LPARAM(dwpos); + ht.pt.y = GET_Y_LPARAM(dwpos); + MapWindowPoints(HWND_DESKTOP, lpnmh->hwndFrom, &ht.pt, 1); + + TreeView_HitTest(lpnmh->hwndFrom, &ht); + _this->m_hSelectedItem = (HWND)ht.hItem; + if (g_Settings->LoadBool(UserInterface_BasicMode)) { return true; } + + //Show Menu + HMENU hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_CHEAT_MENU)); + HMENU hPopupMenu = GetSubMenu(hMenu, 0); + POINT Mouse; + + GetCursorPos(&Mouse); + + MenuSetText(hPopupMenu, 0, GS(CHEAT_DELETE), NULL); + + if (_this->m_hSelectedItem != NULL && + TreeView_GetChild(_this->m_hCheatTree, _this->m_hSelectedItem) == NULL) + { + TrackPopupMenu(hPopupMenu, 0, Mouse.x, Mouse.y, 0, hDlg, NULL); + } + DestroyMenu(hMenu); + } + else if ((lpnmh->code == NM_CLICK) && (lpnmh->idFrom == IDC_MYTREE)) + { + TVHITTESTINFO ht = { 0 }; + uint32_t dwpos = GetMessagePos(); + + // include and header files + ht.pt.x = GET_X_LPARAM(dwpos); + ht.pt.y = GET_Y_LPARAM(dwpos); + MapWindowPoints(HWND_DESKTOP, lpnmh->hwndFrom, &ht.pt, 1); + + TreeView_HitTest(lpnmh->hwndFrom, &ht); + + if (TVHT_ONITEMSTATEICON & ht.flags) + { + switch (TV_GetCheckState(_this->m_hCheatTree, (HWND)ht.hItem)) + { + case TV_STATE_CLEAR: + case TV_STATE_INDETERMINATE: + //Make sure that the item has a valid code extenstion selected + if (TreeView_GetChild(_this->m_hCheatTree, ht.hItem) == NULL) + { + TVITEM item; + item.mask = TVIF_PARAM; + item.hItem = (HTREEITEM)ht.hItem; + TreeView_GetItem(_this->m_hCheatTree, &item); + stdstr LineEntry = g_Settings->LoadStringIndex(Cheat_Entry, item.lParam); + if (CheatUsesCodeExtensions(LineEntry)) + { + stdstr CheatExtension; + if (!g_Settings->LoadStringIndex(Cheat_Extension, item.lParam, CheatExtension)) + { + SendMessage(hDlg, UM_CHANGECODEEXTENSION, 0, (LPARAM)ht.hItem); + TV_SetCheckState(_this->m_hCheatTree, (HWND)ht.hItem, TV_STATE_CLEAR); + break; + } + } + } + TV_SetCheckState(_this->m_hCheatTree, (HWND)ht.hItem, TV_STATE_CHECKED); + _this->ChangeChildrenStatus((HWND)ht.hItem, true); + _this->CheckParentStatus((HWND)TreeView_GetParent((HWND)_this->m_hCheatTree, (HWND)ht.hItem)); + break; + case TV_STATE_CHECKED: + TV_SetCheckState(_this->m_hCheatTree, (HWND)ht.hItem, TV_STATE_CLEAR); + _this->ChangeChildrenStatus((HWND)ht.hItem, false); + _this->CheckParentStatus((HWND)TreeView_GetParent((HWND)_this->m_hCheatTree, (HWND)ht.hItem)); + break; + } + switch (TV_GetCheckState(_this->m_hCheatTree, (HWND)ht.hItem)) + { + case TV_STATE_CHECKED: TV_SetCheckState(_this->m_hCheatTree, (HWND)ht.hItem, TV_STATE_INDETERMINATE); break; + case TV_STATE_CLEAR: TV_SetCheckState(_this->m_hCheatTree, (HWND)ht.hItem, TV_STATE_CHECKED); break; + case TV_STATE_INDETERMINATE: TV_SetCheckState(_this->m_hCheatTree, (HWND)ht.hItem, TV_STATE_CLEAR); break; + } + + if (g_BaseSystem) + { + g_BaseSystem->SetCheatsSlectionChanged(true); + } + } + } + else if ((lpnmh->code == NM_DBLCLK) && (lpnmh->idFrom == IDC_MYTREE)) + { + TVHITTESTINFO ht = { 0 }; + uint32_t dwpos = GetMessagePos(); + + // include and header files + ht.pt.x = GET_X_LPARAM(dwpos); + ht.pt.y = GET_Y_LPARAM(dwpos); + MapWindowPoints(HWND_DESKTOP, lpnmh->hwndFrom, &ht.pt, 1); + + TreeView_HitTest(lpnmh->hwndFrom, &ht); + + if (TVHT_ONITEMLABEL & ht.flags) + { + PostMessage(hDlg, UM_CHANGECODEEXTENSION, 0, (LPARAM)ht.hItem); + } + } + else if ((lpnmh->code == TVN_SELCHANGEDW) && (lpnmh->idFrom == IDC_MYTREE)) + { + HTREEITEM hItem; + + hItem = TreeView_GetSelection(_this->m_hCheatTree); + if (TreeView_GetChild(_this->m_hCheatTree, hItem) == NULL) + { + TVITEM item; + + item.mask = TVIF_PARAM; + item.hItem = hItem; + TreeView_GetItem(_this->m_hCheatTree, &item); + + stdstr Notes(g_Settings->LoadStringIndex(Cheat_Notes, item.lParam)); + SetDlgItemText(hDlg, IDC_NOTES, Notes.c_str()); + if (_this->m_AddCheat) + { + SendMessage(_this->m_AddCheat, WM_EDITCHEAT, item.lParam, 0); //edit cheat + } + } + else + { + SetDlgItemText(hDlg, IDC_NOTES, ""); + } + } + } + break; + case UM_CHANGECODEEXTENSION: + { + CCheatsUI * _this = (CCheatsUI *)GetProp(hDlg, "Class"); + ; + //Get the selected item + _this->m_hSelectedItem = (HWND)lParam; + TVITEM item; + item.mask = TVIF_PARAM; + item.hItem = (HTREEITEM)_this->m_hSelectedItem; + if (!TreeView_GetItem(_this->m_hCheatTree, &item)) + { + break; + } + + //Make sure the selected line can use code extensions + stdstr LineEntry = g_Settings->LoadStringIndex(Cheat_Entry, item.lParam); + if (!CheatUsesCodeExtensions(LineEntry)) { break; } + + stdstr Options; + if (g_Settings->LoadStringIndex(Cheat_Options, item.lParam, Options) && Options.length() > 0) + { + DialogBoxParamW(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_Cheats_CodeEx), hDlg, (DLGPROC)CheatsCodeExProc, (LPARAM)_this); + } + else + { + stdstr Range; + if (g_Settings->LoadStringIndex(Cheat_Range, item.lParam, Range) && Range.length() > 0) + { + DialogBoxParamW(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_Cheats_Range), hDlg, (DLGPROC)CheatsCodeQuantProc, (LPARAM)_this); + } + } + + //Update cheat listing with new extention + stdstr CheatName(_this->GetCheatName(item.lParam, true)); + char * Cheat = strrchr((char *)CheatName.c_str(), '\\'); + if (Cheat == NULL) + { + Cheat = const_cast(CheatName.c_str()); + } + else + { + Cheat += 1; + } + item.mask = TVIF_TEXT; + item.pszText = Cheat; + item.cchTextMax = CheatName.length(); + TreeView_SetItem(_this->m_hCheatTree, &item); + } + break; + default: + return false; + } + return true; +} + +int CALLBACK CCheatsUI::CheatsCodeExProc(HWND hDlg, uint32_t uMsg, uint32_t wParam, uint32_t lParam) +{ + switch (uMsg) + { + case WM_INITDIALOG: + { + CCheatsUI * _this = (CCheatsUI *)lParam; + SetProp(hDlg, "Class", _this); + + //Find the cheat Number of the option being selected + TVITEM item; + item.hItem = (HTREEITEM)_this->m_hSelectedItem; + item.mask = TVIF_PARAM; + TreeView_GetItem(_this->m_hCheatTree, &item); + stdstr CheatName = _this->GetCheatName(item.lParam, false); + + //Set up language support for dialog + SetWindowTextW(hDlg, GS(CHEAT_CODE_EXT_TITLE)); + SetDlgItemTextW(hDlg, IDC_NOTE, GS(CHEAT_CODE_EXT_TXT)); + SetDlgItemTextW(hDlg, IDOK, GS(CHEAT_OK)); + SetDlgItemTextW(hDlg, IDCANCEL, GS(CHEAT_CANCEL)); + SetDlgItemText(hDlg, IDC_CHEAT_NAME, CheatName.c_str()); + + //Read through and add all options to the list box + stdstr Options(g_Settings->LoadStringIndex(Cheat_Options, item.lParam)); + stdstr CurrentExt(g_Settings->LoadStringIndex(Cheat_Extension, item.lParam)); + const char * ReadPos = Options.c_str(); + while (*ReadPos != 0) + { + const char * NextComma = strchr(ReadPos, ','); + int len = NextComma == NULL ? strlen(ReadPos) : NextComma - ReadPos; + stdstr CheatExt(ReadPos); + CheatExt.resize(len); + int index = SendMessage(GetDlgItem(hDlg, IDC_CHEAT_LIST), LB_ADDSTRING, 0, (LPARAM)CheatExt.c_str()); + if (CheatExt == CurrentExt) + { + SendMessage(GetDlgItem(hDlg, IDC_CHEAT_LIST), LB_SETCURSEL, index, 0); + } + //Move to next entry or end + ReadPos = NextComma ? NextComma + 1 : ReadPos + strlen(ReadPos); + } + } + break; + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDC_CHEAT_LIST: + if (HIWORD(wParam) == LBN_DBLCLK) { PostMessage(hDlg, WM_COMMAND, IDOK, 0); break; } + break; + case IDOK: + { + CCheatsUI * _this = (CCheatsUI *)GetProp(hDlg, "Class"); + + //Find the cheat Number of the option being selected + TVITEM item; + item.hItem = (HTREEITEM)_this->m_hSelectedItem; + item.mask = TVIF_PARAM; + TreeView_GetItem(_this->m_hCheatTree, &item); + + //Get the selected cheat extension + char CheatExten[300]; + int index = SendMessage(GetDlgItem(hDlg, IDC_CHEAT_LIST), LB_GETCURSEL, 0, 0); + if (index < 0) { index = 0; } + SendMessage(GetDlgItem(hDlg, IDC_CHEAT_LIST), LB_GETTEXT, index, (LPARAM)CheatExten); + + g_Settings->SaveStringIndex(Cheat_Extension, item.lParam, CheatExten); + if (g_BaseSystem) + { + g_BaseSystem->SetCheatsSlectionChanged(true); + } + } + RemoveProp(hDlg, "Class"); + EndDialog(hDlg, 0); + break; + case IDCANCEL: + RemoveProp(hDlg, "Class"); + EndDialog(hDlg, 0); + break; + } + default: + return false; + } + return true; +} + +int CALLBACK CCheatsUI::CheatsCodeQuantProc(HWND hDlg, uint32_t uMsg, uint32_t wParam, uint32_t lParam) +{ + static uint16_t Start, Stop, SelStart, SelStop; + + switch (uMsg) + { + case WM_INITDIALOG: + { + CCheatsUI * _this = (CCheatsUI *)lParam; + SetProp(hDlg, "Class", _this); + + //Find the cheat Number of the option being selected + TVITEM item; + item.hItem = (HTREEITEM)_this->m_hSelectedItem; + item.mask = TVIF_PARAM; + TreeView_GetItem(_this->m_hCheatTree, &item); + stdstr CheatName = _this->GetCheatName(item.lParam, false); + stdstr RangeNote(g_Settings->LoadStringIndex(Cheat_RangeNotes, item.lParam)); + stdstr Range(g_Settings->LoadStringIndex(Cheat_Range, item.lParam)); + stdstr Value(g_Settings->LoadStringIndex(Cheat_Extension, item.lParam)); + + //Set up language support for dialog + SetWindowTextW(hDlg, GS(CHEAT_CODE_EXT_TITLE)); + SetDlgItemTextW(hDlg, IDC_DIGITAL_TEXT, GS(CHEAT_CHOOSE_VALUE)); + SetDlgItemTextW(hDlg, IDC_VALUE_TEXT, GS(CHEAT_VALUE)); + SetDlgItemTextW(hDlg, IDC_NOTES_TEXT, GS(CHEAT_NOTES)); + SetDlgItemText(hDlg, IDC_NOTES, RangeNote.c_str()); + SetDlgItemText(hDlg, IDC_CHEAT_NAME, CheatName.c_str()); + SetDlgItemText(hDlg, IDC_VALUE, Value.c_str()); + + Start = (uint16_t)(Range.c_str()[0] == '$' ? std::strtoul(&Range.c_str()[1], 0, 16) : atol(Range.c_str())); + const char * ReadPos = strrchr(Range.c_str(), '-'); + if (ReadPos != NULL) + { + Stop = (uint16_t)(ReadPos[1] == '$' ? std::strtoul(&ReadPos[2], 0, 16) : atol(&ReadPos[1])); + } + else + { + Stop = 0; + } + + char Text[500]; + sprintf(Text, "%s $%X %s $%X", GS(CHEAT_FROM), Start, GS(CHEAT_TO), Stop); + SetDlgItemText(hDlg, IDC_RANGE, Text); + } + break; + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDC_VALUE: + if (HIWORD(wParam) == EN_UPDATE) + { + TCHAR szTmp[10], szTmp2[10]; + uint32_t Value; + GetDlgItemText(hDlg, IDC_VALUE, szTmp, sizeof(szTmp)); + Value = szTmp[0] == '$' ? std::strtoul(&szTmp[1], 0, 16) : std::strtoul(szTmp, 0, 16); + if (Value > Stop) { Value = Stop; } + if (Value < Start) { Value = Start; } + sprintf(szTmp2, "$%X", Value); + if (strcmp(szTmp, szTmp2) != 0) + { + SetDlgItemText(hDlg, IDC_VALUE, szTmp2); + if (SelStop == 0) { SelStop = (uint16_t)strlen(szTmp2); SelStart = SelStop; } + SendDlgItemMessage(hDlg, IDC_VALUE, EM_SETSEL, (WPARAM)SelStart, (LPARAM)SelStop); + } + else + { + uint16_t NewSelStart, NewSelStop; + SendDlgItemMessage(hDlg, IDC_VALUE, EM_GETSEL, (WPARAM)&NewSelStart, (LPARAM)&NewSelStop); + if (NewSelStart != 0) { SelStart = NewSelStart; SelStop = NewSelStop; } + } + } + break; + case IDOK: + { + CCheatsUI * _this = (CCheatsUI *)GetProp(hDlg, "Class"); + + //Find the cheat Number of the option being selected + TVITEM item; + item.hItem = (HTREEITEM)_this->m_hSelectedItem; + item.mask = TVIF_PARAM; + TreeView_GetItem(_this->m_hCheatTree, &item); + + //Get the selected cheat extension + TCHAR CheatExten[300], szTmp[10]; + uint32_t Value; + + GetDlgItemText(hDlg, IDC_VALUE, szTmp, sizeof(szTmp)); + Value = szTmp[0] == '$' ? std::strtol(&szTmp[1], 0, 16) : std::strtol(szTmp, 0, 16); + if (Value > Stop) { Value = Stop; } + if (Value < Start) { Value = Start; } + sprintf(CheatExten, "$%X", Value); + + g_Settings->SaveStringIndex(Cheat_Extension, item.lParam, CheatExten); + if (g_BaseSystem) + { + g_BaseSystem->SetCheatsSlectionChanged(true); + } + } + RemoveProp(hDlg, "Class"); + EndDialog(hDlg, 0); + break; + case IDCANCEL: + RemoveProp(hDlg, "Class"); + EndDialog(hDlg, 0); + break; + } + default: + return false; + } + return true; +} + +bool CCheatsUI::IsCheatMessage(MSG * msg) +{ + if (m_Window) + { + return IsDialogMessage(m_Window, msg) != 0; + } + return false; +} + +int CALLBACK CCheatsUI::ManageCheatsProc(HWND hDlg, uint32_t uMsg, uint32_t wParam, uint32_t lParam) +{ + switch (uMsg) + { + case WM_INITDIALOG: + { + CCheatsUI * _this = (CCheatsUI *)lParam; + SetProp(hDlg, "Class", _this); + _this->m_Window = hDlg; + + WINDOWPLACEMENT WndPlac; + WndPlac.length = sizeof(WndPlac); + GetWindowPlacement(hDlg, &WndPlac); + + SetWindowTextW(hDlg, GS(CHEAT_TITLE)); + _this->m_hSelectCheat = CreateDialogParamW(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_Cheats_List), hDlg, (DLGPROC)CheatListProc, (LPARAM)_this); + SetWindowPos(_this->m_hSelectCheat, HWND_TOP, 5, 8, 0, 0, SWP_NOSIZE); + ShowWindow(_this->m_hSelectCheat, SW_SHOW); + + RECT * rc = &WndPlac.rcNormalPosition; + if (g_Settings->LoadDword(UserInterface_BasicMode)) + { + RECT * rcList = (RECT *)_this->m_rcList; + GetWindowRect(GetDlgItem(_this->m_hSelectCheat, IDC_CHEATSFRAME), rcList); + _this->m_MinSizeDlg = rcList->right - rcList->left + 16; + _this->m_MaxSizeDlg = _this->m_MinSizeDlg; + + _this->m_DialogState = CONTRACTED; + WndPlac.rcNormalPosition.right = WndPlac.rcNormalPosition.left + _this->m_MinSizeDlg; + SetWindowPlacement(hDlg, &WndPlac); + + ShowWindow(GetDlgItem(hDlg, IDC_STATE), SW_HIDE); + } + else + { + _this->m_AddCheat = CreateDialogParamW(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_Cheats_Add), hDlg, (DLGPROC)CheatAddProc, (LPARAM)_this); + SetWindowPos(_this->m_AddCheat, HWND_TOP, (rc->right - rc->left) / 2, 8, 0, 0, SWP_NOSIZE); + ShowWindow(_this->m_AddCheat, SW_HIDE); + + RECT * rcAdd = (RECT *)_this->m_rcAdd, *rcList = (RECT *)_this->m_rcList; + GetWindowRect(GetDlgItem(_this->m_hSelectCheat, IDC_CHEATSFRAME), rcList); + GetWindowRect(GetDlgItem(_this->m_AddCheat, IDC_ADDCHEATSFRAME), rcAdd); + _this->m_MinSizeDlg = rcList->right - rcList->left + 32; + _this->m_MaxSizeDlg = rcAdd->right - rcList->left + 32; + + _this->m_DialogState = CONTRACTED; + WndPlac.rcNormalPosition.right = WndPlac.rcNormalPosition.left + _this->m_MinSizeDlg; + SetWindowPlacement(hDlg, &WndPlac); + + GetClientRect(hDlg, rc); + HWND hStateButton = GetDlgItem(hDlg, IDC_STATE); + SetWindowPos(hStateButton, HWND_TOP, (rc->right - rc->left) - 16, 0, 16, rc->bottom - rc->top, 0); + HANDLE hIcon = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_RIGHT), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); + SendDlgItemMessage(hDlg, IDC_STATE, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)(HANDLE)hIcon); + } + + //re-center cheat window + RECT rcDlg, rcParent; + GetWindowRect(hDlg, &rcDlg); + GetWindowRect(GetParent(hDlg), &rcParent); + + int DlgWidth = rcDlg.right - rcDlg.left; + int DlgHeight = rcDlg.bottom - rcDlg.top; + + int X = (((rcParent.right - rcParent.left) - DlgWidth) / 2) + rcParent.left; + int Y = (((rcParent.bottom - rcParent.top) - DlgHeight) / 2) + rcParent.top; + + SetWindowPos(hDlg, NULL, X, Y, 0, 0, SWP_NOZORDER | SWP_NOSIZE); + + _this->RefreshCheatManager(); + } + break; + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDCANCEL: + { + CCheatsUI * _this = (CCheatsUI *)GetProp(hDlg, "Class"); + if (_this->m_AddCheat) + { + DestroyWindow(_this->m_AddCheat); + _this->m_AddCheat = NULL; + } + _this->m_Window = NULL; + RemoveProp(hDlg, "Class"); + EndDialog(hDlg, 0); + if (g_BaseSystem) + { + g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_Cheats); + } + if (g_cheatUI == _this) + { + delete g_cheatUI; + g_cheatUI = NULL; + } + } + break; + case IDC_STATE: + { + CCheatsUI * _this = (CCheatsUI *)GetProp(hDlg, "Class"); + WINDOWPLACEMENT WndPlac; + WndPlac.length = sizeof(WndPlac); + GetWindowPlacement(hDlg, &WndPlac); + + if (_this->m_DialogState == CONTRACTED) + { + _this->m_DialogState = EXPANDED; + WndPlac.rcNormalPosition.right = WndPlac.rcNormalPosition.left + _this->m_MaxSizeDlg; + SetWindowPlacement(hDlg, &WndPlac); + + RECT clientrect; + GetClientRect(hDlg, &clientrect); + HWND hStateButton = GetDlgItem(hDlg, IDC_STATE); + SetWindowPos(hStateButton, HWND_TOP, (clientrect.right - clientrect.left) - 16, 0, 16, clientrect.bottom - clientrect.top, 0); + + HANDLE hIcon = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_LEFT), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); + SendDlgItemMessage(hDlg, IDC_STATE, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)(HANDLE)hIcon); + + ShowWindow(_this->m_AddCheat, SW_SHOW); + } + else + { + _this->m_DialogState = CONTRACTED; + WndPlac.rcNormalPosition.right = WndPlac.rcNormalPosition.left + _this->m_MinSizeDlg; + SetWindowPlacement(hDlg, &WndPlac); + + HANDLE hIcon = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_RIGHT), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); + SendDlgItemMessage(hDlg, IDC_STATE, BM_SETIMAGE, (WPARAM)IMAGE_ICON, (LPARAM)(HANDLE)hIcon); + + RECT clientrect; + GetClientRect(hDlg, &clientrect); + HWND hStateButton = GetDlgItem(hDlg, IDC_STATE); + SetWindowPos(hStateButton, HWND_TOP, (clientrect.right - clientrect.left) - 16, 0, 16, clientrect.bottom - clientrect.top, 0); + + ShowWindow(_this->m_AddCheat, SW_HIDE); + } + } + break; + } + break; + default: + return false; + } + return true; +} + +bool CCheatsUI::TV_SetCheckState(HWND hwndTreeView, HWND hItem, TV_CHECK_STATE state) +{ + TVITEM tvItem; + + tvItem.mask = TVIF_HANDLE | TVIF_STATE; + tvItem.hItem = (HTREEITEM)hItem; + tvItem.stateMask = TVIS_STATEIMAGEMASK; + + /*Image 1 in the tree-view check box image list is the + unchecked box. Image 2 is the checked box.*/ + + switch (state) + { + case TV_STATE_CHECKED: tvItem.state = INDEXTOSTATEIMAGEMASK(1); break; + case TV_STATE_CLEAR: tvItem.state = INDEXTOSTATEIMAGEMASK(2); break; + case TV_STATE_INDETERMINATE: tvItem.state = INDEXTOSTATEIMAGEMASK(3); break; + default: tvItem.state = INDEXTOSTATEIMAGEMASK(0); break; + } + return TreeView_SetItem(hwndTreeView, &tvItem) != 0; +} + +int CCheatsUI::TV_GetCheckState(HWND hwndTreeView, HWND hItem) +{ + TVITEM tvItem; + + // Prepare to receive the desired information. + tvItem.mask = TVIF_HANDLE | TVIF_STATE; + tvItem.hItem = (HTREEITEM)hItem; + tvItem.stateMask = TVIS_STATEIMAGEMASK; + + // Request the information. + TreeView_GetItem(hwndTreeView, &tvItem); + + // Return zero if it's not checked, or nonzero otherwise. + switch (tvItem.state >> 12) { + case 1: return TV_STATE_CHECKED; + case 2: return TV_STATE_CLEAR; + case 3: return TV_STATE_INDETERMINATE; + } + return ((int)(tvItem.state >> 12) - 1); +} + +void CCheatsUI::MenuSetText(HMENU hMenu, int MenuPos, const wchar_t * Title, const wchar_t * ShortCut) +{ + MENUITEMINFOW MenuInfo; + wchar_t String[256]; + + if (Title == NULL || wcslen(Title) == 0) { return; } + + memset(&MenuInfo, 0, sizeof(MENUITEMINFO)); + MenuInfo.cbSize = sizeof(MENUITEMINFO); + MenuInfo.fMask = MIIM_TYPE; + MenuInfo.fType = MFT_STRING; + MenuInfo.fState = MFS_ENABLED; + MenuInfo.dwTypeData = String; + MenuInfo.cch = 256; + + GetMenuItemInfoW(hMenu, MenuPos, true, &MenuInfo); + wcscpy(String, Title); + if (wcschr(String, '\t') != NULL) { *(wcschr(String, '\t')) = '\0'; } + if (ShortCut) { _swprintf(String, L"%s\t%s", String, ShortCut); } + SetMenuItemInfoW(hMenu, MenuPos, true, &MenuInfo); +} + +stdstr CCheatsUI::GetCheatName(int CheatNo, bool AddExtension) const +{ + if (CheatNo > CCheats::MaxCheats) { g_Notify->BreakPoint(__FILEW__, __LINE__); } + stdstr LineEntry = g_Settings->LoadStringIndex(Cheat_Entry, CheatNo); + if (LineEntry.length() == 0) { return LineEntry; } + + //Find the start and end of the name which is surrounded in "" + int StartOfName = LineEntry.find("\""); + if (StartOfName == -1) { return stdstr(""); } + int EndOfName = LineEntry.find("\"", StartOfName + 1); + if (EndOfName == -1) { return stdstr(""); } + + stdstr Name = LineEntry.substr(StartOfName + 1, EndOfName - StartOfName - 1); + const char * CodeString = &(LineEntry.c_str())[EndOfName + 2]; + if (!CCheats::IsValid16BitCode(CodeString)) + { + Name.Format("*** %s", Name.c_str()); + Name.Replace("\\", "\\*** "); + } + if (AddExtension && CheatUsesCodeExtensions(LineEntry)) + { + stdstr CheatValue(g_Settings->LoadStringIndex(Cheat_Extension, CheatNo)); + Name.Format("%s (=>%s)", Name.c_str(), CheatValue.c_str()); + } + + return Name; +} + +bool CCheatsUI::CheatUsesCodeExtensions(const stdstr &LineEntry) +{ + //Find the start and end of the name which is surronded in "" + if (LineEntry.length() == 0){ return false; } + int StartOfName = LineEntry.find("\""); + if (StartOfName == -1) { return false; } + int EndOfName = LineEntry.find("\"", StartOfName + 1); + if (EndOfName == -1) { return false; } + + //Read through the gameshark entries till you find a ?? + const char *ReadPos = &(LineEntry.c_str())[EndOfName + 2]; + bool CodeExtension = false; + + for (int i = 0; i < CCheats::MaxGSEntries && CodeExtension == false; i++) + { + if (strchr(ReadPos, ' ') == NULL) { break; } + ReadPos = strchr(ReadPos, ' ') + 1; + if (ReadPos[0] == '?' && ReadPos[1] == '?') { CodeExtension = true; } + if (ReadPos[2] == '?' && ReadPos[3] == '?') { CodeExtension = true; } + if (strchr(ReadPos, ',') == NULL) { continue; } + ReadPos = strchr(ReadPos, ',') + 1; + } + return CodeExtension; +} + +void CCheatsUI::DeleteCheat(int Index) +{ + for (int CheatNo = Index; CheatNo < CCheats::MaxCheats; CheatNo++) + { + stdstr LineEntry = g_Settings->LoadStringIndex(Cheat_Entry, CheatNo + 1); + if (LineEntry.empty()) + { + g_Settings->DeleteSettingIndex(Cheat_RangeNotes, CheatNo); + g_Settings->DeleteSettingIndex(Cheat_Range, CheatNo); + g_Settings->DeleteSettingIndex(Cheat_Options, CheatNo); + g_Settings->DeleteSettingIndex(Cheat_Notes, CheatNo); + g_Settings->DeleteSettingIndex(Cheat_Extension, CheatNo); + g_Settings->DeleteSettingIndex(Cheat_Entry, CheatNo); + g_Settings->DeleteSettingIndex(Cheat_Active, CheatNo); + break; + } + stdstr Value; + if (g_Settings->LoadStringIndex(Cheat_RangeNotes, CheatNo + 1, Value)) + { + g_Settings->SaveStringIndex(Cheat_RangeNotes, CheatNo, Value); + } + else + { + g_Settings->DeleteSettingIndex(Cheat_RangeNotes, CheatNo); + } + + if (g_Settings->LoadStringIndex(Cheat_Range, CheatNo + 1, Value)) + { + g_Settings->SaveStringIndex(Cheat_Range, CheatNo, Value); + } + else + { + g_Settings->DeleteSettingIndex(Cheat_Range, CheatNo); + } + + if (g_Settings->LoadStringIndex(Cheat_Options, CheatNo + 1, Value)) + { + g_Settings->SaveStringIndex(Cheat_Options, CheatNo, Value); + } + else + { + g_Settings->DeleteSettingIndex(Cheat_Options, CheatNo); + } + + if (g_Settings->LoadStringIndex(Cheat_Notes, CheatNo + 1, Value)) + { + g_Settings->SaveStringIndex(Cheat_Notes, CheatNo, Value); + } + else + { + g_Settings->DeleteSettingIndex(Cheat_Notes, CheatNo); + } + + if (g_Settings->LoadStringIndex(Cheat_Extension, CheatNo + 1, Value)) + { + g_Settings->SaveStringIndex(Cheat_Extension, CheatNo, Value); + } + else + { + g_Settings->DeleteSettingIndex(Cheat_Extension, CheatNo); + } + + bool bValue; + if (g_Settings->LoadBoolIndex(Cheat_Active, CheatNo + 1, bValue)) + { + g_Settings->SaveBoolIndex(Cheat_Active, CheatNo, bValue); + } + else + { + g_Settings->DeleteSettingIndex(Cheat_Active, CheatNo); + } + g_Settings->SaveStringIndex(Cheat_Entry, CheatNo, LineEntry); + } + CSettingTypeCheats::FlushChanges(); +} + +void CCheatsUI::ChangeChildrenStatus(HWND hParent, bool Checked) +{ + HTREEITEM hItem = TreeView_GetChild(m_hCheatTree, hParent); + if (hItem == NULL) + { + if ((HTREEITEM)hParent == TVI_ROOT) { return; } + + TVITEM item; + item.mask = TVIF_PARAM; + item.hItem = (HTREEITEM)hParent; + TreeView_GetItem(m_hCheatTree, &item); + + //if cheat uses a extension and it is not set then do not set it + if (Checked) + { + stdstr LineEntry = g_Settings->LoadStringIndex(Cheat_Entry, item.lParam); + if (CheatUsesCodeExtensions(LineEntry)) + { + stdstr CheatExten; + if (!g_Settings->LoadStringIndex(Cheat_Extension, item.lParam, CheatExten) || CheatExten.empty()) + { + return; + } + } + } + + //Save Cheat + TV_SetCheckState(m_hCheatTree, hParent, Checked ? TV_STATE_CHECKED : TV_STATE_CLEAR); + g_Settings->SaveBoolIndex(Cheat_Active, item.lParam, Checked); + return; + } + TV_CHECK_STATE state = TV_STATE_UNKNOWN; + while (hItem != NULL) + { + TV_CHECK_STATE ChildState = (TV_CHECK_STATE)TV_GetCheckState(m_hCheatTree, (HWND)hItem); + if ((ChildState != TV_STATE_CHECKED || !Checked) && + (ChildState != TV_STATE_CLEAR || Checked)) + { + ChangeChildrenStatus((HWND)hItem, Checked); + } + ChildState = (TV_CHECK_STATE)TV_GetCheckState(m_hCheatTree, (HWND)hItem); + if (state == TV_STATE_UNKNOWN) { state = ChildState; } + if (state != ChildState) { state = TV_STATE_INDETERMINATE; } + hItem = TreeView_GetNextSibling(m_hCheatTree, hItem); + } + if (state != TV_STATE_UNKNOWN) + { + TV_SetCheckState(m_hCheatTree, hParent, state); + } +} + +void CCheatsUI::CheckParentStatus(HWND hParent) +{ + TV_CHECK_STATE CurrentState, InitialState; + HTREEITEM hItem; + + if (!hParent) { return; } + hItem = TreeView_GetChild(m_hCheatTree, (HTREEITEM)hParent); + InitialState = (TV_CHECK_STATE)TV_GetCheckState(m_hCheatTree, hParent); + CurrentState = (TV_CHECK_STATE)TV_GetCheckState(m_hCheatTree, (HWND)hItem); + + while (hItem != NULL) + { + if (TV_GetCheckState(m_hCheatTree, (HWND)hItem) != CurrentState) + { + CurrentState = TV_STATE_INDETERMINATE; + break; + } + hItem = TreeView_GetNextSibling(m_hCheatTree, hItem); + } + TV_SetCheckState(m_hCheatTree, hParent, CurrentState); + if (InitialState != CurrentState) + { + CheckParentStatus((HWND)TreeView_GetParent((HWND)m_hCheatTree, (HTREEITEM)hParent)); + } +} + +stdstr CCheatsUI::ReadCodeString(HWND hDlg, bool &validcodes, bool &validoptions, bool &nooptions, int &codeformat) +{ + int numlines, linecount, len; + char str[128]; + int i; + char* formatnormal = "XXXXXXXX XXXX"; + char* formatoptionlb = "XXXXXXXX XX??"; + char* formatoptionw = "XXXXXXXX ????"; + char tempformat[128]; + + validcodes = true; + nooptions = true; + codeformat = -1; + int numcodes = 0; + + char codestring[2048]; + memset(codestring, '\0', sizeof(codestring)); + + numlines = SendDlgItemMessage(hDlg, IDC_CHEAT_CODES, EM_GETLINECOUNT, 0, 0); + if (numlines == 0) { validcodes = false; } + + for (linecount = 0; linecount < numlines; linecount++) //read line after line (bypassing limitation GetDlgItemText) + { + memset(tempformat, 0, sizeof(tempformat)); + + //str[0] = sizeof(str) > 255?255:sizeof(str); + *(LPWORD)str = sizeof(str); + len = SendDlgItemMessage(hDlg, IDC_CHEAT_CODES, EM_GETLINE, (WPARAM)linecount, (LPARAM)(const char *)str); + str[len] = 0; + + if (len <= 0) { continue; } + + for (i = 0; i < 128; i++) + { + if (isxdigit(str[i])) + { + tempformat[i] = 'X'; + } + if ((str[i] == ' ') || (str[i] == '?')) + { + tempformat[i] = str[i]; + } + if (str[i] == 0) { break; } + } + if (strcmp(tempformat, formatnormal) == 0) + { + strcat(codestring, ","); + strcat(codestring, str); + numcodes++; + if (codeformat < 0) codeformat = 0; + } + else if (strcmp(tempformat, formatoptionlb) == 0) + { + if (codeformat != 2) + { + strcat(codestring, ","); + strcat(codestring, str); + numcodes++; + codeformat = 1; + nooptions = false; + validoptions = false; + } + else + { + validcodes = false; + } + } + else if (strcmp(tempformat, formatoptionw) == 0) + { + if (codeformat != 1) + { + strcat(codestring, ","); + strcat(codestring, str); + numcodes++; + codeformat = 2; + nooptions = false; + validoptions = false; + } + else + { + validcodes = false; + } + } + else + { + validcodes = false; + } + } + if (strlen(codestring) == 0) + { + validcodes = false; + } + return codestring; +} + +stdstr CCheatsUI::ReadOptionsString(HWND hDlg, bool &/*validcodes*/, bool &validoptions, bool &/*nooptions*/, int &codeformat) +{ + int numlines, linecount, len; + char str[128]; + int i, j; + + validoptions = true; + int numoptions = 0; + + char optionsstring[2048]; + memset(optionsstring, '\0', sizeof(optionsstring)); + + numlines = SendDlgItemMessage(hDlg, IDC_CHEAT_OPTIONS, EM_GETLINECOUNT, 0, 0); + + for (linecount = 0; linecount < numlines; linecount++) //read line after line (bypassing limitation GetDlgItemText) + { + memset(str, 0, sizeof(str)); + //str[0] = sizeof(str) > 255?255:sizeof(str); + *(LPWORD)str = sizeof(str); + len = SendDlgItemMessage(hDlg, IDC_CHEAT_OPTIONS, EM_GETLINE, (WPARAM)linecount, (LPARAM)(const char *)str); + str[len] = 0; + + if (len > 0) + { + switch (codeformat) + { + case 1: //option = lower byte + if (len >= 2) { + for (i = 0; i < 2; i++) + { + if (!isxdigit(str[i])) + { + validoptions = false; + break; + } + } + + if ((str[2] != ' ') && (len > 2)) + { + validoptions = false; + break; + } + + for (j = 0; j < 2; j++) + { + str[j] = (char)toupper(str[j]); + } + + if (optionsstring[0] == 0) + { + strcat(optionsstring, "$"); + } + else + { + strcat(optionsstring, ",$"); + } + strcat(optionsstring, str); + numoptions++; + } + else + { + validoptions = false; + break; + } + break; + + case 2: //option = word + if (len >= 4) + { + for (i = 0; i < 4; i++) + { + if (!isxdigit(str[i])) + { + validoptions = false; + break; + } + } + + if (str[4] != ' ' && (len > 4)) + { + validoptions = false; + break; + } + + for (j = 0; j < 4; j++) + { + str[j] = (char)toupper(str[j]); + } + + strcat(optionsstring, ",$"); + strcat(optionsstring, str); + numoptions++; + } + else + { + validoptions = false; + break; + } + break; + default: + break; + } + } + } + + if (numoptions < 1) + { + validoptions = false; + } + return optionsstring; +} \ No newline at end of file diff --git a/Source/Project64/User Interface/Cheat Class UI.h b/Source/Project64/User Interface/Cheat Class UI.h new file mode 100644 index 000000000..b72ed6307 --- /dev/null +++ b/Source/Project64/User Interface/Cheat Class UI.h @@ -0,0 +1,71 @@ +/**************************************************************************** +* * +* Project 64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2012 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +#pragma once + +class CCheatsUI +{ +public: + CCheatsUI(void); + ~CCheatsUI(void); + + bool IsCheatMessage(MSG * msg); + void SelectCheats(HWND hParent, bool BlockExecution); + +private: + static int CALLBACK CheatAddProc(HWND hDlg, uint32_t uMsg, uint32_t wParam, uint32_t lParam); + static int CALLBACK CheatListProc(HWND hDlg, uint32_t uMsg, uint32_t wParam, uint32_t lParam); + static int CALLBACK ManageCheatsProc(HWND hDlg, uint32_t uMsg, uint32_t wParam, uint32_t lParam); + static int CALLBACK CheatsCodeExProc(HWND hDlg, uint32_t uMsg, uint32_t wParam, uint32_t lParam); + static int CALLBACK CheatsCodeQuantProc(HWND hDlg, uint32_t uMsg, uint32_t wParam, uint32_t lParam); + + //information about the gui for selecting cheats + HWND m_Window, m_hSelectCheat, m_AddCheat, m_hCheatTree, m_hSelectedItem; + void * const m_rcList, *const m_rcAdd; + int m_MinSizeDlg, m_MaxSizeDlg; + int m_EditCheat; + bool m_DeleteingEntries; + + //Information about the current cheat we are editing + stdstr m_EditName; + stdstr m_EditCode; + stdstr m_EditOptions; + stdstr m_EditNotes; + + enum Dialog_State { CONTRACTED, EXPANDED } m_DialogState; + enum TV_CHECK_STATE { TV_STATE_UNKNOWN, TV_STATE_CLEAR, TV_STATE_CHECKED, TV_STATE_INDETERMINATE }; + enum { IDC_MYTREE = 0x500 }; + + void AddCodeLayers(int CheatNumber, const stdstr &CheatName, HWND hParent, bool CheatActive); + //Reload the cheats from the ini file to the select gui + void RefreshCheatManager(); + void ChangeChildrenStatus(HWND hParent, bool Checked); + void CheckParentStatus(HWND hParent); + static stdstr ReadCodeString(HWND hDlg, bool &validcodes, bool &validoption, bool &nooptions, int &codeformat); + static stdstr ReadOptionsString(HWND hDlg, bool &validcodes, bool &validoptions, bool &nooptions, int &codeformat); + + void RecordCheatValues(HWND hDlg); + bool CheatChanged(HWND hDlg); + void DeleteCheat(int Index); + + //Get Information about the Cheat + stdstr GetCheatName(int CheatNo, bool AddExtension) const; + static bool CheatUsesCodeExtensions(const stdstr &LineEntry); + //Working with treeview + static bool TV_SetCheckState(HWND hwndTreeView, HWND hItem, TV_CHECK_STATE state); + static int TV_GetCheckState(HWND hwndTreeView, HWND hItem); + + static void MenuSetText(HMENU hMenu, int MenuPos, const wchar_t * Title, const wchar_t * ShortCut); + + //UI Functions + static stdstr GetDlgItemStr(HWND hDlg, int nIDDlgItem); +}; + +extern CCheatsUI * g_cheatUI; \ No newline at end of file diff --git a/Source/Project64/User Interface/Gui Class.cpp b/Source/Project64/User Interface/Gui Class.cpp index e917a2a65..53671c945 100644 --- a/Source/Project64/User Interface/Gui Class.cpp +++ b/Source/Project64/User Interface/Gui Class.cpp @@ -10,109 +10,104 @@ ****************************************************************************/ #include "stdafx.h" -#ifdef WINDOWS_UI #include #include "Settings/SettingType/SettingsType-Application.h" -extern "C" +extern "C" { -void EnterLogOptions(HWND hwndOwner); + void EnterLogOptions(HWND hwndOwner); } -#pragma comment(lib, "Comctl32.lib") +#pragma comment(lib, "Comctl32.lib") -DWORD CALLBACK AboutBoxProc (HWND WndHandle, DWORD uMsg, DWORD wParam, DWORD lParam); -LRESULT CALLBACK MainGui_Proc (HWND WndHandle, DWORD uMsg, DWORD wParam, DWORD lParam); +DWORD CALLBACK AboutBoxProc(HWND WndHandle, DWORD uMsg, DWORD wParam, DWORD lParam); +LRESULT CALLBACK MainGui_Proc(HWND WndHandle, DWORD uMsg, DWORD wParam, DWORD lParam); -extern BOOL set_about_field( - HWND hDlg, - int nIDDlgItem, - const wchar_t * config_string, - const wchar_t * language_string -); +extern BOOL set_about_field(HWND hDlg, int nIDDlgItem, const wchar_t * config_string, const wchar_t * language_string); -CMainGui::CMainGui (bool bMainWindow, const char * WindowTitle ) : - CRomBrowser(m_hMainWindow,m_hStatusWnd), - m_ThreadId(GetCurrentThreadId()), - m_bMainWindow(bMainWindow), - m_Created(false), - m_AttachingMenu(false), - m_MakingVisible(false), - m_ResetPlugins(false), - m_ResetInfo(NULL) +CMainGui::CMainGui(bool bMainWindow, const char * WindowTitle) : +CRomBrowser(m_hMainWindow, m_hStatusWnd), +m_ThreadId(GetCurrentThreadId()), +m_bMainWindow(bMainWindow), +m_Created(false), +m_AttachingMenu(false), +m_MakingVisible(false), +m_ResetPlugins(false), +m_ResetInfo(NULL) { m_Menu = NULL; - + m_hMainWindow = 0; - m_hStatusWnd = 0; - m_SaveMainWindowPos = false; - m_SaveMainWindowTop = 0; + m_hStatusWnd = 0; + m_SaveMainWindowPos = false; + m_SaveMainWindowTop = 0; m_SaveMainWindowLeft = 0; - - m_SaveRomBrowserPos = false; - m_SaveRomBrowserTop = 0; + + m_SaveRomBrowserPos = false; + m_SaveRomBrowserTop = 0; m_SaveRomBrowserLeft = 0; if (m_bMainWindow) { - g_Settings->RegisterChangeCB(RomBrowser_Enabled,this,(CSettings::SettingChangedFunc)RomBowserEnabledChanged); - g_Settings->RegisterChangeCB(RomBrowser_ColoumnsChanged,this,(CSettings::SettingChangedFunc)RomBowserColoumnsChanged); - g_Settings->RegisterChangeCB(RomBrowser_Recursive,this,(CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); + g_Settings->RegisterChangeCB(RomBrowser_Enabled, this, (CSettings::SettingChangedFunc)RomBowserEnabledChanged); + g_Settings->RegisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); + g_Settings->RegisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); } //if this fails then it has already been created RegisterWinClass(); Create(WindowTitle); - } -CMainGui::~CMainGui (void) +CMainGui::~CMainGui(void) { - WriteTrace(TraceDebug,__FUNCTION__ ": Start"); + WriteTrace(TraceDebug, __FUNCTION__ ": Start"); if (m_bMainWindow) { - g_Settings->UnregisterChangeCB(RomBrowser_Enabled,this,(CSettings::SettingChangedFunc)RomBowserEnabledChanged); - g_Settings->UnregisterChangeCB(RomBrowser_ColoumnsChanged,this,(CSettings::SettingChangedFunc)RomBowserColoumnsChanged); - g_Settings->UnregisterChangeCB(RomBrowser_Recursive,this,(CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); + g_Settings->UnregisterChangeCB(RomBrowser_Enabled, this, (CSettings::SettingChangedFunc)RomBowserEnabledChanged); + g_Settings->UnregisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); + g_Settings->UnregisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); } if (m_hMainWindow) { DestroyWindow(m_hMainWindow); } - WriteTrace(TraceDebug,__FUNCTION__ ": Done"); + WriteTrace(TraceDebug, __FUNCTION__ ": Done"); } -bool CMainGui::RegisterWinClass ( void ) +bool CMainGui::RegisterWinClass(void) { stdstr_f VersionDisplay("Project64 %s", VER_FILE_VERSION_STR); WNDCLASS wcl; - wcl.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; - wcl.cbClsExtra = 0; - wcl.cbWndExtra = 0; - wcl.hIcon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_PJ64_Icon)); - wcl.hCursor = LoadCursor(NULL,IDC_ARROW); - wcl.hInstance = GetModuleHandle(NULL); + wcl.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; + wcl.cbClsExtra = 0; + wcl.cbWndExtra = 0; + wcl.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_PJ64_Icon)); + wcl.hCursor = LoadCursor(NULL, IDC_ARROW); + wcl.hInstance = GetModuleHandle(NULL); - wcl.lpfnWndProc = (WNDPROC)MainGui_Proc; - wcl.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - wcl.lpszMenuName = NULL; - wcl.lpszClassName = VersionDisplay.c_str(); - if (RegisterClass(&wcl) == 0) return false; + wcl.lpfnWndProc = (WNDPROC)MainGui_Proc; + wcl.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); + wcl.lpszMenuName = NULL; + wcl.lpszClassName = VersionDisplay.c_str(); + if (RegisterClass(&wcl) == 0) return false; return true; } -void RomBowserEnabledChanged (CMainGui * Gui) +void RomBowserEnabledChanged(CMainGui * Gui) { - if (Gui && g_Settings->LoadBool(RomBrowser_Enabled)) + if (Gui && g_Settings->LoadBool(RomBrowser_Enabled)) { - if (!Gui->RomBrowserVisible()) + if (!Gui->RomBrowserVisible()) { Gui->ShowRomList(); } - } else { + } + else + { if (Gui->RomBrowserVisible()) { Gui->HideRomList(); @@ -120,166 +115,162 @@ void RomBowserEnabledChanged (CMainGui * Gui) } } -void RomBowserColoumnsChanged (CMainGui * Gui) +void RomBowserColoumnsChanged(CMainGui * Gui) { - Gui->ResetRomBrowserColomuns(); + Gui->ResetRomBrowserColomuns(); } -void RomBrowserRecursiveChanged (CMainGui * Gui) +void RomBrowserRecursiveChanged(CMainGui * Gui) { - Gui->RefreshRomBrowser(); + Gui->RefreshRomBrowser(); Gui->HighLightLastRom(); } -void CMainGui::ChangeWinSize (long width, long height) +void CMainGui::ChangeWinSize(long width, long height) { CGuard Guard(m_CS); WINDOWPLACEMENT wndpl; - RECT rc1, swrect; + RECT rc1, swrect; wndpl.length = sizeof(wndpl); - GetWindowPlacement( m_hMainWindow, &wndpl); + GetWindowPlacement(m_hMainWindow, &wndpl); - if ( (HWND)m_hStatusWnd != NULL ) - { - GetClientRect( (HWND)m_hStatusWnd, &swrect ); - SetRect( &rc1, 0, 0, width, height + swrect.bottom ); - } - else - { - SetRect( &rc1, 0, 0, width, height ); + if ((HWND)m_hStatusWnd != NULL) + { + GetClientRect((HWND)m_hStatusWnd, &swrect); + SetRect(&rc1, 0, 0, width, height + swrect.bottom); + } + else + { + SetRect(&rc1, 0, 0, width, height); } + AdjustWindowRectEx(&rc1, GetWindowLong(m_hMainWindow, GWL_STYLE), GetMenu(m_hMainWindow) != NULL, GetWindowLong(m_hMainWindow, GWL_EXSTYLE)); - AdjustWindowRectEx( &rc1,GetWindowLong( m_hMainWindow, GWL_STYLE ), - GetMenu( m_hMainWindow ) != NULL, GetWindowLong( m_hMainWindow, GWL_EXSTYLE ) ); - - MoveWindow( m_hMainWindow, wndpl.rcNormalPosition.left, wndpl.rcNormalPosition.top, - rc1.right - rc1.left, rc1.bottom - rc1.top, TRUE ); + MoveWindow(m_hMainWindow, wndpl.rcNormalPosition.left, wndpl.rcNormalPosition.top, rc1.right - rc1.left, rc1.bottom - rc1.top, TRUE); } -void CMainGui::AboutBox (void) +void CMainGui::AboutBox(void) { - DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_About), m_hMainWindow, (DLGPROC)AboutBoxProc,(LPARAM)this); + DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_About), m_hMainWindow, (DLGPROC)AboutBoxProc, (LPARAM)this); } -void CMainGui::AboutIniBox (void) +void CMainGui::AboutIniBox(void) { DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_About_Ini), m_hMainWindow, (DLGPROC)AboutIniBoxProc,(LPARAM)this); } -DWORD CALLBACK AboutIniBoxProc (HWND hDlg, DWORD uMsg, DWORD wParam, DWORD /*lParam*/) +DWORD CALLBACK AboutIniBoxProc(HWND hDlg, DWORD uMsg, DWORD wParam, DWORD /*lParam*/) { static wchar_t RDBHomePage[300], CHTHomePage[300], RDXHomePage[300]; - + switch (uMsg) { case WM_INITDIALOG: + { + wchar_t String[200]; + + //Title + LONG_PTR originalWndProc = GetWindowLongPtrW(hDlg, GWLP_WNDPROC); + SetWindowLongPtrW(hDlg, GWLP_WNDPROC, (LONG_PTR) DefWindowProcW); + SetWindowTextW(hDlg, GS(INI_TITLE)); + SetWindowLongPtrW(hDlg, GWLP_WNDPROC, originalWndProc); + + //Language + SetDlgItemTextW(hDlg, IDC_LAN, GS(INI_CURRENT_LANG)); + set_about_field(hDlg, IDC_LAN_AUTHOR, GS(INI_AUTHOR), GS(LANGUAGE_AUTHOR)); + set_about_field(hDlg, IDC_LAN_VERSION, GS(INI_VERSION), GS(LANGUAGE_VERSION)); + set_about_field(hDlg, IDC_LAN_DATE, GS(INI_DATE), GS(LANGUAGE_DATE)); + if (wcslen(GS(LANGUAGE_NAME)) == 0) { - wchar_t String[200]; - - //Title - LONG_PTR originalWndProc = GetWindowLongPtrW(hDlg, GWLP_WNDPROC); - SetWindowLongPtrW(hDlg, GWLP_WNDPROC, (LONG_PTR) DefWindowProcW); - SetWindowTextW(hDlg, GS(INI_TITLE)); - SetWindowLongPtrW(hDlg, GWLP_WNDPROC, originalWndProc); - - //Language - SetDlgItemTextW(hDlg,IDC_LAN,GS(INI_CURRENT_LANG)); - set_about_field(hDlg, IDC_LAN_AUTHOR, GS(INI_AUTHOR), GS(LANGUAGE_AUTHOR)); - set_about_field(hDlg, IDC_LAN_VERSION, GS(INI_VERSION), GS(LANGUAGE_VERSION)); - set_about_field(hDlg, IDC_LAN_DATE, GS(INI_DATE), GS(LANGUAGE_DATE)); - if (wcslen(GS(LANGUAGE_NAME)) == 0) - { - EnableWindow(GetDlgItem(hDlg,IDC_LAN),FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_LAN_AUTHOR),FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_LAN_VERSION),FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_LAN_DATE),FALSE); - } - - //RDB - CIniFile RdbIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str()); - wcsncpy(String, RdbIniFile.GetString("Meta","Author","").ToUTF16().c_str(),sizeof(String) / sizeof(String[0])); - if (wcslen(String) == 0) - { - EnableWindow(GetDlgItem(hDlg,IDC_RDB),FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_RDB_AUTHOR),FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_RDB_VERSION),FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_RDB_DATE),FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_RDB_HOME),FALSE); - } - - set_about_field(hDlg, IDC_RDB_AUTHOR, GS(INI_AUTHOR), String); - - wcsncpy(String, RdbIniFile.GetString("Meta","Version","").ToUTF16().c_str(),sizeof(String) / sizeof(String[0])); - set_about_field(hDlg, IDC_RDB_VERSION, GS(INI_VERSION), String); - wcsncpy(String, RdbIniFile.GetString("Meta","Date","").ToUTF16().c_str(),sizeof(String) / sizeof(String[0])); - set_about_field(hDlg, IDC_RDB_DATE, GS(INI_DATE), String); - wcsncpy(RDBHomePage, RdbIniFile.GetString("Meta","Homepage","").ToUTF16().c_str(),sizeof(RDBHomePage) / sizeof(RDBHomePage[0])); - SetDlgItemTextW(hDlg, IDC_RDB_HOME, GS(INI_HOMEPAGE)); - if (wcslen(RDBHomePage) == 0) - { - EnableWindow(GetDlgItem(hDlg,IDC_RDB_HOME),FALSE); - } - - //Cheat - SetDlgItemTextW(hDlg,IDC_CHT,GS(INI_CURRENT_CHT)); - CIniFile CheatIniFile(g_Settings->LoadStringVal(SupportFile_Cheats).c_str()); - wcsncpy(String, CheatIniFile.GetString("Meta","Author","").ToUTF16().c_str(),sizeof(String) / sizeof(String[0])); - if (wcslen(String) == 0) - { - EnableWindow(GetDlgItem(hDlg,IDC_CHT),FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_CHT_AUTHOR),FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_CHT_VERSION),FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_CHT_DATE),FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_CHT_HOME),FALSE); - } - set_about_field(hDlg, IDC_CHT_AUTHOR, GS(INI_AUTHOR), String); - wcsncpy(String, CheatIniFile.GetString("Meta","Version","").ToUTF16().c_str(),sizeof(String) / sizeof(String[0])); - set_about_field(hDlg, IDC_CHT_VERSION, GS(INI_VERSION), String); - wcsncpy(String, CheatIniFile.GetString("Meta","Date","").ToUTF16().c_str(),sizeof(String) / sizeof(String[0])); - set_about_field(hDlg, IDC_CHT_DATE, GS(INI_DATE), String); - wcsncpy(CHTHomePage, CheatIniFile.GetString("Meta","Homepage","").ToUTF16().c_str(),sizeof(CHTHomePage) / sizeof(CHTHomePage[0])); - SetDlgItemTextW(hDlg, IDC_CHT_HOME, GS(INI_HOMEPAGE)); - if (wcslen(CHTHomePage) == 0) - { - EnableWindow(GetDlgItem(hDlg,IDC_CHT_HOME),FALSE); - } - - //Extended Info - SetDlgItemTextW(hDlg, IDC_RDX, GS(INI_CURRENT_RDX)); - CIniFile RdxIniFile(g_Settings->LoadStringVal(SupportFile_ExtInfo).c_str()); - wcsncpy(String, RdxIniFile.GetString("Meta","Author","").ToUTF16().c_str(),sizeof(String) / sizeof(String[0])); - if (wcslen(String) == 0) - { - EnableWindow(GetDlgItem(hDlg,IDC_RDX),FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_RDX_AUTHOR),FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_RDX_VERSION),FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_RDX_DATE),FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_RDX_HOME),FALSE); - } - set_about_field(hDlg, IDC_RDX_AUTHOR, GS(INI_AUTHOR), String); - wcsncpy(String, RdxIniFile.GetString("Meta","Version","").ToUTF16().c_str(),sizeof(String) / sizeof(String[0])); - set_about_field(hDlg, IDC_RDX_VERSION, GS(INI_VERSION), String); - wcsncpy(String, RdxIniFile.GetString("Meta","Date","").ToUTF16().c_str(),sizeof(String) / sizeof(String[0])); - set_about_field(hDlg, IDC_RDX_DATE, GS(INI_DATE), String); - wcsncpy(RDXHomePage, RdxIniFile.GetString("Meta","Homepage","").ToUTF16().c_str(),sizeof(RDXHomePage) / sizeof(RDXHomePage[0])); - SetDlgItemTextW(hDlg, IDC_RDX_HOME, GS(INI_HOMEPAGE)); - if (wcslen(RDXHomePage) == 0) - { - EnableWindow(GetDlgItem(hDlg,IDC_RDX_HOME),FALSE); - } - SetDlgItemTextW(hDlg, IDOK, GS(CHEAT_OK)); + EnableWindow(GetDlgItem(hDlg, IDC_LAN), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_LAN_AUTHOR), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_LAN_VERSION), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_LAN_DATE), FALSE); } - break; + //RDB + CIniFile RdbIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str()); + wcsncpy(String, RdbIniFile.GetString("Meta", "Author", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + if (wcslen(String) == 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_RDB), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDB_AUTHOR), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDB_VERSION), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDB_DATE), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDB_HOME), FALSE); + } + + set_about_field(hDlg, IDC_RDB_AUTHOR, GS(INI_AUTHOR), String); + + wcsncpy(String, RdbIniFile.GetString("Meta", "Version", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + set_about_field(hDlg, IDC_RDB_VERSION, GS(INI_VERSION), String); + wcsncpy(String, RdbIniFile.GetString("Meta", "Date", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + set_about_field(hDlg, IDC_RDB_DATE, GS(INI_DATE), String); + wcsncpy(RDBHomePage, RdbIniFile.GetString("Meta", "Homepage", "").ToUTF16().c_str(), sizeof(RDBHomePage) / sizeof(RDBHomePage[0])); + SetDlgItemTextW(hDlg, IDC_RDB_HOME, GS(INI_HOMEPAGE)); + if (wcslen(RDBHomePage) == 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_RDB_HOME), FALSE); + } + + //Cheat + SetDlgItemTextW(hDlg, IDC_CHT, GS(INI_CURRENT_CHT)); + CIniFile CheatIniFile(g_Settings->LoadStringVal(SupportFile_Cheats).c_str()); + wcsncpy(String, CheatIniFile.GetString("Meta", "Author", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + if (wcslen(String) == 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_CHT), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_CHT_AUTHOR), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_CHT_VERSION), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_CHT_DATE), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_CHT_HOME), FALSE); + } + set_about_field(hDlg, IDC_CHT_AUTHOR, GS(INI_AUTHOR), String); + wcsncpy(String, CheatIniFile.GetString("Meta", "Version", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + set_about_field(hDlg, IDC_CHT_VERSION, GS(INI_VERSION), String); + wcsncpy(String, CheatIniFile.GetString("Meta", "Date", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + set_about_field(hDlg, IDC_CHT_DATE, GS(INI_DATE), String); + wcsncpy(CHTHomePage, CheatIniFile.GetString("Meta", "Homepage", "").ToUTF16().c_str(), sizeof(CHTHomePage) / sizeof(CHTHomePage[0])); + SetDlgItemTextW(hDlg, IDC_CHT_HOME, GS(INI_HOMEPAGE)); + if (wcslen(CHTHomePage) == 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_CHT_HOME), FALSE); + } + + //Extended Info + SetDlgItemTextW(hDlg, IDC_RDX, GS(INI_CURRENT_RDX)); + CIniFile RdxIniFile(g_Settings->LoadStringVal(SupportFile_ExtInfo).c_str()); + wcsncpy(String, RdxIniFile.GetString("Meta", "Author", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + if (wcslen(String) == 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_RDX), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDX_AUTHOR), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDX_VERSION), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDX_DATE), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDX_HOME), FALSE); + } + set_about_field(hDlg, IDC_RDX_AUTHOR, GS(INI_AUTHOR), String); + wcsncpy(String, RdxIniFile.GetString("Meta", "Version", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + set_about_field(hDlg, IDC_RDX_VERSION, GS(INI_VERSION), String); + wcsncpy(String, RdxIniFile.GetString("Meta", "Date", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + set_about_field(hDlg, IDC_RDX_DATE, GS(INI_DATE), String); + wcsncpy(RDXHomePage, RdxIniFile.GetString("Meta", "Homepage", "").ToUTF16().c_str(), sizeof(RDXHomePage) / sizeof(RDXHomePage[0])); + SetDlgItemTextW(hDlg, IDC_RDX_HOME, GS(INI_HOMEPAGE)); + if (wcslen(RDXHomePage) == 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_RDX_HOME), FALSE); + } + SetDlgItemTextW(hDlg, IDOK, GS(CHEAT_OK)); + } + break; case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDC_RDB_HOME: ShellExecuteW(NULL,L"open",RDBHomePage,NULL,NULL,SW_SHOWNORMAL); break; - case IDC_CHT_HOME: ShellExecuteW(NULL,L"open",CHTHomePage,NULL,NULL,SW_SHOWNORMAL); break; - case IDC_RDX_HOME: ShellExecuteW(NULL,L"open",RDXHomePage,NULL,NULL,SW_SHOWNORMAL); break; + switch (LOWORD(wParam)) + { + case IDC_RDB_HOME: ShellExecuteW(NULL, L"open", RDBHomePage, NULL, NULL, SW_SHOWNORMAL); break; + case IDC_CHT_HOME: ShellExecuteW(NULL, L"open", CHTHomePage, NULL, NULL, SW_SHOWNORMAL); break; + case IDC_RDX_HOME: ShellExecuteW(NULL, L"open", RDXHomePage, NULL, NULL, SW_SHOWNORMAL); break; case IDOK: case IDCANCEL: - EndDialog(hDlg,0); + EndDialog(hDlg, 0); break; } default: @@ -293,28 +284,28 @@ bool CMainGui::ResetPlugins (CPlugins * plugins, CN64System * System) RESET_PLUGIN info; info.system = System; info.plugins = plugins; - info.hEvent = CreateEvent(NULL,TRUE,FALSE,NULL); + info.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); bool bRes = true; if (info.hEvent) { - PostMessage(m_hMainWindow,WM_RESET_PLUGIN,(WPARAM)&bRes,(LPARAM)&info); + PostMessage(m_hMainWindow, WM_RESET_PLUGIN, (WPARAM)&bRes, (LPARAM)&info); #ifdef _DEBUG - DWORD dwRes = WaitForSingleObject(info.hEvent,INFINITE); + DWORD dwRes = WaitForSingleObject(info.hEvent, INFINITE); #else - DWORD dwRes = WaitForSingleObject(info.hEvent,5000); + DWORD dwRes = WaitForSingleObject(info.hEvent, 5000); #endif dwRes = dwRes; CloseHandle(info.hEvent); } - else - { - WriteTrace(TraceError,__FUNCTION__ ": Failed to create event"); + else + { + WriteTrace(TraceError, __FUNCTION__ ": Failed to create event"); bRes = false; } return bRes; } -void CMainGui::BringToTop (void) +void CMainGui::BringToTop(void) { CGuard Guard(m_CS); SetForegroundWindow(m_hMainWindow); @@ -323,44 +314,45 @@ void CMainGui::BringToTop (void) SetFocus(m_hMainWindow); } -void CMainGui::MakeWindowOnTop (bool OnTop) +void CMainGui::MakeWindowOnTop(bool OnTop) { CGuard Guard(m_CS); - SetWindowPos(m_hMainWindow,OnTop ? HWND_TOPMOST : HWND_NOTOPMOST,0,0,0,0, - SWP_NOMOVE|SWP_NOSIZE|SWP_NOREDRAW); + SetWindowPos(m_hMainWindow, OnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW); } -void CMainGui::Caption (LPCWSTR Caption) +void CMainGui::Caption(LPCWSTR Caption) { CGuard Guard(m_CS); - SetWindowTextW(m_hMainWindow,Caption); + SetWindowTextW(m_hMainWindow, Caption); } -void CMainGui::Create (const char * WindowTitle) +void CMainGui::Create(const char * WindowTitle) { stdstr_f VersionDisplay("Project64 %s", VER_FILE_VERSION_STR); m_hMainWindow = (HWND)CreateWindowEx(WS_EX_ACCEPTFILES, VersionDisplay.c_str(), WindowTitle, WS_OVERLAPPED | WS_CLIPCHILDREN | - WS_CLIPSIBLINGS | WS_SYSMENU | WS_MINIMIZEBOX,5,5,640,480, - NULL,NULL,GetModuleHandle(NULL),this ); + WS_CLIPSIBLINGS | WS_SYSMENU | WS_MINIMIZEBOX, 5, 5, 640, 480, + NULL, NULL, GetModuleHandle(NULL), this); m_Created = m_hMainWindow != NULL; } -void CMainGui::CreateStatusBar (void) +void CMainGui::CreateStatusBar(void) { - m_hStatusWnd = (HWND)CreateStatusWindow( WS_CHILD | WS_VISIBLE, "", m_hMainWindow, StatusBarID ); - SendMessage( (HWND)m_hStatusWnd, SB_SETTEXT, 0, (LPARAM)"" ); + m_hStatusWnd = (HWND)CreateStatusWindow(WS_CHILD | WS_VISIBLE, "", m_hMainWindow, StatusBarID); + SendMessage((HWND)m_hStatusWnd, SB_SETTEXT, 0, (LPARAM)""); } -WPARAM CMainGui::ProcessAllMessages (void) +WPARAM CMainGui::ProcessAllMessages(void) { MSG msg; - while (GetMessage(&msg,NULL,0,0)) + while (GetMessage(&msg, NULL, 0, 0)) { - if (g_BaseSystem && g_BaseSystem->IsDialogMsg(&msg)) + if (g_cheatUI != NULL && g_cheatUI->IsCheatMessage(&msg)) { continue; } + if (m_ResetPlugins) { m_ResetPlugins = false; @@ -368,56 +360,59 @@ WPARAM CMainGui::ProcessAllMessages (void) SetEvent(m_ResetInfo->hEvent); m_ResetInfo = NULL; } - //if (IsDialogMessage( hManageWindow,&msg)) { continue; } - if (m_Menu->ProcessAccelerator(m_hMainWindow,&msg)) { continue; } + if (g_cheatUI && g_cheatUI->IsCheatMessage(&msg)) { continue; } + if (m_Menu->ProcessAccelerator(m_hMainWindow, &msg)) { continue; } TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } -bool CMainGui::ProcessGuiMessages (void) { +bool CMainGui::ProcessGuiMessages(void) +{ MSG msg; - while (PeekMessage(&msg,NULL,0,0,PM_NOREMOVE)) + while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { if (m_ResetPlugins) { m_ResetPlugins = false; } - if (msg.message == WM_QUIT) { + if (msg.message == WM_QUIT) + { return true; } - PeekMessage(&msg,NULL,0,0,PM_REMOVE); - if (m_Menu->ProcessAccelerator(m_hMainWindow,&msg)) { continue; } + PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); + if (m_Menu->ProcessAccelerator(m_hMainWindow, &msg)) { continue; } TranslateMessage(&msg); DispatchMessage(&msg); } return false; } -void CMainGui::Resize (DWORD /*fwSizeType*/, WORD nWidth, WORD nHeight) { +void CMainGui::Resize(DWORD /*fwSizeType*/, WORD nWidth, WORD nHeight) +{ RECT clrect, swrect; - GetClientRect( m_hMainWindow, &clrect ); - GetClientRect( (HWND)m_hStatusWnd, &swrect ); + GetClientRect(m_hMainWindow, &clrect); + GetClientRect((HWND)m_hStatusWnd, &swrect); int Parts[2]; - Parts[0] = (nWidth - (int)( clrect.right * 0.25 )); + Parts[0] = (nWidth - (int)(clrect.right * 0.25)); Parts[1] = nWidth; - SendMessage( (HWND)m_hStatusWnd, SB_SETPARTS, 2, (LPARAM)&Parts[0] ); - MoveWindow ( (HWND)m_hStatusWnd, 0, clrect.bottom - swrect.bottom,nWidth, nHeight, TRUE ); + SendMessage((HWND)m_hStatusWnd, SB_SETPARTS, 2, (LPARAM)&Parts[0]); + MoveWindow((HWND)m_hStatusWnd, 0, clrect.bottom - swrect.bottom, nWidth, nHeight, TRUE); } -void CMainGui::Show (bool Visible) +void CMainGui::Show(bool Visible) { m_MakingVisible = true; CGuard Guard(m_CS); if (m_hMainWindow) { - ShowWindow(m_hMainWindow,Visible?SW_SHOW:SW_HIDE); - if (Visible && RomBrowserVisible()) + ShowWindow(m_hMainWindow, Visible ? SW_SHOW : SW_HIDE); + if (Visible && RomBrowserVisible()) { RomBrowserToTop(); } @@ -431,29 +426,30 @@ void CMainGui::EnterLogOptions (void) ::EnterLogOptions(m_hMainWindow); } -int CMainGui::Height (void) { +int CMainGui::Height(void) +{ if (!m_hMainWindow) { return 0; } - + RECT rect; - GetWindowRect(m_hMainWindow,&rect); + GetWindowRect(m_hMainWindow, &rect); return rect.bottom - rect.top; } -int CMainGui::Width (void) +int CMainGui::Width(void) { if (!m_hMainWindow) { return 0; } RECT rect; - GetWindowRect(m_hMainWindow,&rect); + GetWindowRect(m_hMainWindow, &rect); return rect.right - rect.left; } -void CMainGui::SetPos (int X, int Y) +void CMainGui::SetPos(int X, int Y) { - SetWindowPos(m_hMainWindow,NULL,X,Y,0,0,SWP_NOZORDER|SWP_NOSIZE); + SetWindowPos(m_hMainWindow, NULL, X, Y, 0, 0, SWP_NOZORDER | SWP_NOSIZE); } -void CMainGui::SetWindowMenu (CBaseMenu * Menu) +void CMainGui::SetWindowMenu(CBaseMenu * Menu) { m_AttachingMenu = true; @@ -466,60 +462,61 @@ void CMainGui::SetWindowMenu (CBaseMenu * Menu) if (hMenu) { - SetMenu(m_hMainWindow,hMenu); + SetMenu(m_hMainWindow, hMenu); } m_AttachingMenu = false; } -void CMainGui::RefreshMenu (void) +void CMainGui::RefreshMenu(void) { if (!m_Menu) { return; } m_Menu->ResetMenu(); } -void CMainGui::SetStatusText (int Panel,const wchar_t * Text) +void CMainGui::SetStatusText(int Panel, const wchar_t * Text) { static wchar_t Message[2][500]; if (Panel >= 2) { - Notify().BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); return; } wchar_t * Msg = Message[Panel]; - memset(Msg,0,sizeof(Message[0])); + memset(Msg, 0, sizeof(Message[0])); _snwprintf(Msg, sizeof(Message[0]) / sizeof(Message[0][0]), L"%s", Text); Msg[(sizeof(Message[0]) / sizeof(Message[0][0])) - 1] = 0; if (GetCurrentThreadId() == m_ThreadId) { - SendMessageW( (HWND)m_hStatusWnd, SB_SETTEXTW, Panel, (LPARAM)Msg ); - } else { - PostMessageW( (HWND)m_hStatusWnd, SB_SETTEXTW, Panel, (LPARAM)Msg ); + SendMessageW((HWND)m_hStatusWnd, SB_SETTEXTW, Panel, (LPARAM)Msg); + } + else { + PostMessageW((HWND)m_hStatusWnd, SB_SETTEXTW, Panel, (LPARAM)Msg); } } -void CMainGui::ShowStatusBar ( bool ShowBar ) +void CMainGui::ShowStatusBar(bool ShowBar) { - ShowWindow((HWND)m_hStatusWnd,ShowBar ? SW_SHOW : SW_HIDE ); + ShowWindow((HWND)m_hStatusWnd, ShowBar ? SW_SHOW : SW_HIDE); } -void CMainGui::SaveWindowLoc ( void ) +void CMainGui::SaveWindowLoc(void) { bool flush = false; if (m_SaveMainWindowPos) { m_SaveMainWindowPos = false; - g_Settings->SaveDword(UserInterface_MainWindowTop,m_SaveMainWindowTop); - g_Settings->SaveDword(UserInterface_MainWindowLeft,m_SaveMainWindowLeft); + g_Settings->SaveDword(UserInterface_MainWindowTop, m_SaveMainWindowTop); + g_Settings->SaveDword(UserInterface_MainWindowLeft, m_SaveMainWindowLeft); flush = true; } if (m_SaveRomBrowserPos) { m_SaveRomBrowserPos = false; - g_Settings->SaveDword(RomBrowser_Top,m_SaveRomBrowserTop); - g_Settings->SaveDword(RomBrowser_Left,m_SaveRomBrowserLeft); + g_Settings->SaveDword(RomBrowser_Top, m_SaveRomBrowserTop); + g_Settings->SaveDword(RomBrowser_Left, m_SaveRomBrowserLeft); flush = true; } @@ -529,424 +526,452 @@ void CMainGui::SaveWindowLoc ( void ) } } -LRESULT CALLBACK CMainGui::MainGui_Proc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) +LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) { switch (uMsg) - { + { case WM_CREATE: - { - //record class for future usage - LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam; - CMainGui * _this = (CMainGui *)lpcs->lpCreateParams; - SetProp((HWND)hWnd,"Class",_this); - - _this->m_hMainWindow = hWnd; - _this->CreateStatusBar(); - - //Move the Main window to the location last executed from or center the window - int X = (GetSystemMetrics( SM_CXSCREEN ) - _this->Width()) / 2; - int Y = (GetSystemMetrics( SM_CYSCREEN ) - _this->Height()) / 2; + { + //record class for future usage + LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam; + CMainGui * _this = (CMainGui *)lpcs->lpCreateParams; + SetProp((HWND)hWnd, "Class", _this); - g_Settings->LoadDword(UserInterface_MainWindowTop,(uint32_t &)Y); - g_Settings->LoadDword(UserInterface_MainWindowLeft, (uint32_t &)X); + _this->m_hMainWindow = hWnd; + _this->CreateStatusBar(); - _this->SetPos(X,Y); - - _this->ChangeWinSize(640,480); + //Move the Main window to the location last executed from or center the window + int X = (GetSystemMetrics(SM_CXSCREEN) - _this->Width()) / 2; + int Y = (GetSystemMetrics(SM_CYSCREEN) - _this->Height()) / 2; - } - break; + g_Settings->LoadDword(UserInterface_MainWindowTop, (uint32_t &)Y); + g_Settings->LoadDword(UserInterface_MainWindowLeft, (uint32_t &)X); + + _this->SetPos(X, Y); + + _this->ChangeWinSize(640, 480); + } + break; case WM_SYSCOMMAND: switch (wParam) { case SC_SCREENSAVE: case SC_MONITORPOWER: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); - if (_this && - _this->bCPURunning() && - !g_Settings->LoadBool(GameRunning_CPU_Paused) && - g_Settings->LoadDword(Setting_DisableScrSaver)) - { - return 0; - } - } - break; - case SC_MAXIMIZE: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); - if (_this) { - if (_this->RomBrowserVisible()) { - _this->RomBrowserMaximize(true); - } - } - } - break; - } - return DefWindowProc((HWND)hWnd,uMsg,wParam,lParam); - break; - case WM_MOVE: { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); - - if (!_this->m_bMainWindow || - !_this->m_Created || - _this->m_AttachingMenu || - _this->m_MakingVisible || - IsIconic((HWND)hWnd) || - _this->ShowingRomBrowser()) + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this && + _this->bCPURunning() && + !g_Settings->LoadBool(GameRunning_CPU_Paused) && + g_Settings->LoadDword(Setting_DisableScrSaver)) { - break; + return 0; } - - if (IsZoomed((HWND)hWnd)) + } + break; + case SC_MAXIMIZE: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this) { if (_this->RomBrowserVisible()) { - // save that browser is maximized + _this->RomBrowserMaximize(true); } - break; - } - - //get the current position of the window - RECT WinRect; - GetWindowRect((HWND)hWnd, &WinRect ); - - //save the location of the window - if (_this->RomBrowserVisible()) - { - _this->m_SaveRomBrowserPos = true; - _this->m_SaveRomBrowserTop = WinRect.top; - _this->m_SaveRomBrowserLeft = WinRect.left; - } else { - _this->m_SaveMainWindowPos = true; - _this->m_SaveMainWindowTop = WinRect.top; - _this->m_SaveMainWindowLeft = WinRect.left; - } - KillTimer(hWnd,Timer_SetWindowPos); - SetTimer(hWnd,Timer_SetWindowPos,1000,NULL); - } - if (CGuiSettings::bCPURunning() && g_BaseSystem) - { - if (g_Plugins->Gfx() && g_Plugins->Gfx()->MoveScreen) - { - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Starting"); - g_Plugins->Gfx()->MoveScreen((int)(short) LOWORD(lParam), (int)(short) HIWORD(lParam)); - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Done"); } } break; + } + return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam); + break; + case WM_MOVE: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + + if (!_this->m_bMainWindow || + !_this->m_Created || + _this->m_AttachingMenu || + _this->m_MakingVisible || + IsIconic((HWND)hWnd) || + _this->ShowingRomBrowser()) + { + break; + } + + if (IsZoomed((HWND)hWnd)) + { + if (_this->RomBrowserVisible()) + { + // save that browser is maximized + } + break; + } + + //get the current position of the window + RECT WinRect; + GetWindowRect((HWND)hWnd, &WinRect); + + //save the location of the window + if (_this->RomBrowserVisible()) + { + _this->m_SaveRomBrowserPos = true; + _this->m_SaveRomBrowserTop = WinRect.top; + _this->m_SaveRomBrowserLeft = WinRect.left; + } + else + { + _this->m_SaveMainWindowPos = true; + _this->m_SaveMainWindowTop = WinRect.top; + _this->m_SaveMainWindowLeft = WinRect.left; + } + KillTimer(hWnd, Timer_SetWindowPos); + SetTimer(hWnd, Timer_SetWindowPos, 1000, NULL); + } + if (CGuiSettings::bCPURunning() && g_BaseSystem) + { + if (g_Plugins->Gfx() && g_Plugins->Gfx()->MoveScreen) + { + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Starting"); + g_Plugins->Gfx()->MoveScreen((int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Done"); + } + } + break; case WM_TIMER: if (wParam == Timer_SetWindowPos) { - KillTimer(hWnd,Timer_SetWindowPos); - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); + KillTimer(hWnd, Timer_SetWindowPos); + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); _this->SaveWindowLoc(); break; } break; - case WM_SIZE: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); - if (_this) { _this->Resize(wParam,LOWORD(lParam), HIWORD(lParam)); } - if (_this) - { - if (wParam == SIZE_MAXIMIZED) + case WM_SIZE: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this) { _this->Resize(wParam, LOWORD(lParam), HIWORD(lParam)); } + if (_this) + { + if (wParam == SIZE_MAXIMIZED) + { + if (_this->RomBrowserVisible()) { - if (_this->RomBrowserVisible()) { - _this->RomBrowserMaximize(true); - } + _this->RomBrowserMaximize(true); } - _this->ResizeRomList(LOWORD(lParam), HIWORD(lParam)); } - if (_this) { - if (wParam == SIZE_RESTORED && _this->RomBrowserVisible()) { - _this->RomBrowserMaximize(false); - } + _this->ResizeRomList(LOWORD(lParam), HIWORD(lParam)); + } + if (_this) + { + if (wParam == SIZE_RESTORED && _this->RomBrowserVisible()) + { + _this->RomBrowserMaximize(false); } } - break; + } + break; case WM_NOTIFY: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this) { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); - if (_this) { - if (_this->RomBrowserVisible() && !_this->RomListNotify(wParam,lParam)) { - return DefWindowProc((HWND)hWnd,uMsg,wParam,lParam); - } + if (_this->RomBrowserVisible() && !_this->RomListNotify(wParam, lParam)) + { + return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam); } } - break; + } + break; case WM_DRAWITEM: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this) { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); - if (_this) { - if (!_this->RomListDrawItem(wParam,lParam)) { - return DefWindowProc((HWND)hWnd,uMsg,wParam,lParam); - } + if (!_this->RomListDrawItem(wParam, lParam)) + { + return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam); } } - break; + } + break; case WM_PAINT: - { -// CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); -// CN64System * System = _this->m_System; + { + // CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); + // CN64System * System = _this->m_System; -// if (bCPURunning() && Settings->Load(CPU_Paused)) { -// CPlugins * Plugins = System->Plugins(); -// if (Plugins->Gfx()->DrawScreen) { -// Plugins->Gfx()->DrawScreen(); -// } -// } - ValidateRect((HWND)hWnd,NULL); - } - break; + // if (bCPURunning() && Settings->Load(CPU_Paused)) { + // CPlugins * Plugins = System->Plugins(); + // if (Plugins->Gfx()->DrawScreen) { + // Plugins->Gfx()->DrawScreen(); + // } + // } + ValidateRect((HWND)hWnd, NULL); + } + break; case WM_KEYUP: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this->m_bMainWindow && bCPURunning()) + if (_this->m_bMainWindow && bCPURunning()) + { + if (g_BaseSystem) { - if (g_BaseSystem) - { - if (g_Plugins && g_Plugins->Control()->WM_KeyUp) { - g_Plugins->Control()->WM_KeyUp(wParam, lParam); - } + if (g_Plugins && g_Plugins->Control()->WM_KeyUp) { + g_Plugins->Control()->WM_KeyUp(wParam, lParam); } } } - break; + } + break; case WM_KEYDOWN: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this->m_bMainWindow && bCPURunning()) + if (_this->m_bMainWindow && bCPURunning()) + { + if (g_BaseSystem) { - if (g_BaseSystem) + if (g_Plugins && g_Plugins->Control()->WM_KeyDown) { - if (g_Plugins && g_Plugins->Control()->WM_KeyDown) - { - g_Plugins->Control()->WM_KeyDown(wParam, lParam); - } + g_Plugins->Control()->WM_KeyDown(wParam, lParam); } } } - break; - case WM_SETFOCUS: + } + break; + case WM_SETFOCUS: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this->RomBrowserVisible()) { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); - if (_this->RomBrowserVisible()) - { - PostMessage((HWND)hWnd,WM_BORWSER_TOP,0,0); - break; - } + PostMessage((HWND)hWnd, WM_BORWSER_TOP, 0, 0); + break; + } - if (_this->m_bMainWindow && bCPURunning() && bAutoSleep()) + if (_this->m_bMainWindow && bCPURunning() && bAutoSleep()) + { + if (g_BaseSystem) { - if (g_BaseSystem) - { - g_BaseSystem->ExternalEvent( SysEvent_ResumeCPU_AppGainedFocus ); - } + g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_AppGainedFocus); } } - break; + } + break; case WM_KILLFOCUS: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this->RomBrowserVisible()) { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); - if (_this->RomBrowserVisible()) + break; + } + + if (_this->m_bMainWindow && bCPURunning() && bAutoSleep()) + { + if (g_BaseSystem) { + g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_AppLostFocus); + } + } + } + break; + case WM_ACTIVATEAPP: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + DWORD fActive = (BOOL)wParam; + + if (fActive && _this->RomBrowserVisible()) + { + PostMessage((HWND)hWnd, WM_BORWSER_TOP, 0, 0); + } + if (_this->m_bMainWindow && bCPURunning()) + { + if (!fActive && g_Settings->LoadBool(UserInterface_InFullScreen)) + { + Notify().WindowMode(); + if (bAutoSleep() && g_BaseSystem) + { + //System->ExternalEvent(PauseCPU_AppLostActiveDelayed ); + } break; } - - if (_this->m_bMainWindow && bCPURunning() && bAutoSleep()) - { + if (bAutoSleep() || fActive) + { if (g_BaseSystem) { - g_BaseSystem->ExternalEvent( SysEvent_PauseCPU_AppLostFocus ); + g_BaseSystem->ExternalEvent(fActive ? SysEvent_ResumeCPU_AppGainedActive : SysEvent_PauseCPU_AppLostActive); } } } - break; - case WM_ACTIVATEAPP: + } + break; + case WM_HIDE_CUROSR: + if (!wParam) { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); - DWORD fActive = (BOOL) wParam; - - if (fActive && _this->RomBrowserVisible()) { - PostMessage((HWND)hWnd,WM_BORWSER_TOP,0,0); - } - if (_this->m_bMainWindow && bCPURunning()) - { - if (!fActive && g_Settings->LoadBool(UserInterface_InFullScreen)) - { - Notify().WindowMode(); - if (bAutoSleep() && g_BaseSystem) - { - //System->ExternalEvent(PauseCPU_AppLostActiveDelayed ); - } - break; - } - if (bAutoSleep() || fActive) - { - if (g_BaseSystem) - { - g_BaseSystem->ExternalEvent(fActive ? SysEvent_ResumeCPU_AppGainedActive : SysEvent_PauseCPU_AppLostActive ); - } - } - } - - } - break; - case WM_HIDE_CUROSR: - if (!wParam) { while (ShowCursor(FALSE) >= 0) { Sleep(0); } - } else { + } + else + { while (ShowCursor(TRUE) < 0) { Sleep(0); } } break; case WM_MAKE_FOCUS: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); - _this->BringToTop(); - } - break; + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + _this->BringToTop(); + } + break; case WM_BORWSER_TOP: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); - _this->RomBrowserToTop(); - } - break; + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + _this->RomBrowserToTop(); + } + break; case WM_RESET_PLUGIN: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this->m_ResetInfo != NULL) { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this->m_ResetInfo != NULL) - { - Notify().BreakPoint(__FILEW__, __LINE__); - } - _this->m_ResetInfo = (RESET_PLUGIN *)lParam; - _this->m_ResetPlugins = true; + g_Notify->BreakPoint(__FILEW__, __LINE__); } - break; + _this->m_ResetInfo = (RESET_PLUGIN *)lParam; + _this->m_ResetPlugins = true; + } + break; case WM_COMMAND: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this == NULL) { break; } + + switch (LOWORD(wParam)) { + case ID_POPUPMENU_PLAYGAME: g_BaseSystem->RunFileImage(_this->CurrentedSelectedRom()); break; + case ID_POPUPMENU_ROMDIRECTORY: _this->SelectRomDir(); break; + case ID_POPUPMENU_REFRESHROMLIST: _this->RefreshRomBrowser(); break; + case ID_POPUPMENU_ROMINFORMATION: { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); - if (_this == NULL) { break; } + RomInformation Info(_this->CurrentedSelectedRom()); + Info.DisplayInformation(hWnd); + } + break; + case ID_POPUPMENU_EDITSETTINGS: + case ID_POPUPMENU_EDITCHEATS: + { + CN64Rom Rom; + Rom.LoadN64Image(_this->CurrentedSelectedRom(), true); + Rom.SaveRomSettingID(true); - switch (LOWORD(wParam)) { - case ID_POPUPMENU_PLAYGAME: g_BaseSystem->RunFileImage(_this->CurrentedSelectedRom()); break; - case ID_POPUPMENU_ROMDIRECTORY: _this->SelectRomDir(); break; - case ID_POPUPMENU_REFRESHROMLIST: _this->RefreshRomBrowser(); break; - case ID_POPUPMENU_ROMINFORMATION: + if (LOWORD(wParam) == ID_POPUPMENU_EDITSETTINGS) + { + CSettingConfig SettingConfig(true); + SettingConfig.Display(hWnd); + } + + if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS) + { + CCheatsUI * cheatUI = new CCheatsUI; + g_cheatUI = cheatUI; + cheatUI->SelectCheats(hWnd, true); + if (g_cheatUI == cheatUI) { - RomInformation Info(_this->CurrentedSelectedRom()); - Info.DisplayInformation(hWnd); + g_cheatUI = NULL; } - break; - case ID_POPUPMENU_EDITSETTINGS: - case ID_POPUPMENU_EDITCHEATS: - { - CN64Rom Rom; - Rom.LoadN64Image(_this->CurrentedSelectedRom(),true); - Rom.SaveRomSettingID(true); - /*if (g_Settings->LoadStringVal(ROM_MD5).length() == 0) { - Rom.LoadN64Image(_this->CurrentedSelectedRom(),false); - g_Settings->SaveString(ROM_MD5,Rom.GetRomMD5().c_str()); - g_Settings->SaveString(ROM_InternalName,Rom.GetRomName().c_str()); - }*/ - - if (LOWORD(wParam) == ID_POPUPMENU_EDITSETTINGS) - { - CSettingConfig SettingConfig(true); - SettingConfig.Display(hWnd); - } + } - if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS) { - CCheats RomCheats(&Rom); - RomCheats.SelectCheats(hWnd,true); - } - - if (g_Rom) { - g_Rom->SaveRomSettingID(false); - } else { - Rom.ClearRomSettingID(); - } - } - break; - default: - if (_this->m_Menu) { - if (LOWORD(wParam) > 5000 && LOWORD(wParam) <= 5100 ) { - if (g_Plugins->RSP()) - { - g_Plugins->RSP()->ProcessMenuItem(LOWORD(wParam)); - } - } else if (LOWORD(wParam) > 5100 && LOWORD(wParam) <= 5200 ) { - if (g_Plugins->Gfx()) - { - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Starting"); - g_Plugins->Gfx()->ProcessMenuItem(LOWORD(wParam)); - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Done"); - } - } else if (LOWORD(wParam) > 5200 && LOWORD(wParam) <= 5300 ) { - if (g_Plugins->Gfx() && g_Plugins->Gfx()->OnRomBrowserMenuItem != NULL) - { - CN64Rom Rom; - if (!Rom.LoadN64Image(_this->CurrentedSelectedRom(),true)) - { - break; - } - Rom.SaveRomSettingID(true); - g_Notify->DisplayMessage(0,L""); - BYTE * RomHeader = Rom.GetRomAddress(); - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": OnRomBrowserMenuItem - Starting"); - g_Plugins->Gfx()->OnRomBrowserMenuItem(LOWORD(wParam),hWnd,RomHeader); - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": OnRomBrowserMenuItem - Done"); - if (g_Rom) { - g_Rom->SaveRomSettingID(false); - } else { - g_Settings->SaveString(Game_IniKey,""); - } - } - } else if (_this->m_Menu->ProcessMessage(hWnd,HIWORD(wParam), LOWORD(wParam))) { - return true; - } - } + if (g_Rom) + { + g_Rom->SaveRomSettingID(false); + } + else + { + Rom.ClearRomSettingID(); } } break; - case WM_DROPFILES: - { - char filename[MAX_PATH]; - - HDROP hDrop = (HDROP)wParam; - DragQueryFile(hDrop, 0, filename, sizeof(filename)); - DragFinish(hDrop); - - CN64System::RunFileImage(filename); + default: + if (_this->m_Menu) + { + if (LOWORD(wParam) > 5000 && LOWORD(wParam) <= 5100) + { + if (g_Plugins->RSP()) + { + g_Plugins->RSP()->ProcessMenuItem(LOWORD(wParam)); + } + } + else if (LOWORD(wParam) > 5100 && LOWORD(wParam) <= 5200) + { + if (g_Plugins->Gfx()) + { + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Starting"); + g_Plugins->Gfx()->ProcessMenuItem(LOWORD(wParam)); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Done"); + } + } + else if (LOWORD(wParam) > 5200 && LOWORD(wParam) <= 5300) + { + if (g_Plugins->Gfx() && g_Plugins->Gfx()->OnRomBrowserMenuItem != NULL) + { + CN64Rom Rom; + if (!Rom.LoadN64Image(_this->CurrentedSelectedRom(), true)) + { + break; + } + Rom.SaveRomSettingID(true); + g_Notify->DisplayMessage(0, L""); + BYTE * RomHeader = Rom.GetRomAddress(); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": OnRomBrowserMenuItem - Starting"); + g_Plugins->Gfx()->OnRomBrowserMenuItem(LOWORD(wParam), hWnd, RomHeader); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": OnRomBrowserMenuItem - Done"); + if (g_Rom) + { + g_Rom->SaveRomSettingID(false); + } + else + { + g_Settings->SaveString(Game_IniKey, ""); + } + } + } + else if (_this->m_Menu->ProcessMessage(hWnd, HIWORD(wParam), LOWORD(wParam))) + { + return true; + } + } } - break; + } + break; + case WM_DROPFILES: + { + char filename[MAX_PATH]; + + HDROP hDrop = (HDROP)wParam; + DragQueryFile(hDrop, 0, filename, sizeof(filename)); + DragFinish(hDrop); + + CN64System::RunFileImage(filename); + } + break; case WM_DESTROY: - WriteTrace(TraceDebug,__FUNCTION__ ": WM_DESTROY - start"); + WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - start"); { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); if (_this->m_bMainWindow) { Notify().WindowMode(); } _this->m_hMainWindow = NULL; - WriteTrace(TraceDebug,__FUNCTION__ ": WM_DESTROY - 1"); + WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 1"); if (_this->m_bMainWindow) { _this->SaveRomListColoumnInfo(); - WriteTrace(TraceDebug,__FUNCTION__ ": WM_DESTROY - 2"); + WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 2"); _this->SaveWindowLoc(); } } - WriteTrace(TraceDebug,__FUNCTION__ ": WM_DESTROY - 3"); - RemoveProp((HWND)hWnd,"Class"); - WriteTrace(TraceDebug,__FUNCTION__ ": WM_DESTROY - 4"); + WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 3"); + RemoveProp((HWND)hWnd, "Class"); + WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 4"); PostQuitMessage(0); - WriteTrace(TraceDebug,__FUNCTION__ ": WM_DESTROY - Done"); + WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - Done"); break; default: - return DefWindowProc((HWND)hWnd,uMsg,wParam,lParam); + return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam); } return TRUE; } @@ -954,38 +979,38 @@ LRESULT CALLBACK CMainGui::MainGui_Proc (HWND hWnd, DWORD uMsg, DWORD wParam, DW WNDPROC pfnWndAboutBoxCancelProc = NULL; HBITMAP hCloseButton = NULL; -DWORD CALLBACK AboutBoxCancelProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) -{ +DWORD CALLBACK AboutBoxCancelProc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) +{ switch (uMsg) { case WM_PAINT: + { + PAINTSTRUCT ps; + + if (BeginPaint(hWnd, &ps)) { - PAINTSTRUCT ps; - - if (BeginPaint(hWnd,&ps)) + if (hCloseButton) { - if (hCloseButton) - { - RECT rcClient; - GetClientRect(hWnd, &rcClient); + RECT rcClient; + GetClientRect(hWnd, &rcClient); - BITMAP bmTL1; - GetObject(hCloseButton, sizeof(BITMAP), &bmTL1); - HDC memdc = CreateCompatibleDC(ps.hdc); - HGDIOBJ save = SelectObject(memdc, hCloseButton); - BitBlt(ps.hdc, 0, 0, bmTL1.bmWidth, bmTL1.bmHeight, memdc, 0, 0, SRCCOPY); - SelectObject(memdc, save); - DeleteDC(memdc); - } - EndPaint(hWnd,&ps); + BITMAP bmTL1; + GetObject(hCloseButton, sizeof(BITMAP), &bmTL1); + HDC memdc = CreateCompatibleDC(ps.hdc); + HGDIOBJ save = SelectObject(memdc, hCloseButton); + BitBlt(ps.hdc, 0, 0, bmTL1.bmWidth, bmTL1.bmHeight, memdc, 0, 0, SRCCOPY); + SelectObject(memdc, save); + DeleteDC(memdc); } + EndPaint(hWnd, &ps); } - break; } - + break; + } + return CallWindowProc(pfnWndAboutBoxCancelProc, hWnd, uMsg, wParam, lParam); } -DWORD CALLBACK AboutBoxProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) +DWORD CALLBACK AboutBoxProc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) { static HBITMAP hbmpBackgroundTop = NULL; static HBITMAP hbmpBackgroundBottom = NULL; @@ -996,210 +1021,147 @@ DWORD CALLBACK AboutBoxProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) switch (uMsg) { case WM_INITDIALOG: + { + enum { ROUND_EDGE = 15 }; + + DWORD dwStyle = GetWindowLong(hWnd, GWL_STYLE); + dwStyle &= ~(WS_CAPTION | WS_SIZEBOX); + SetWindowLong(hWnd, GWL_STYLE, dwStyle); + + // Use the size of the image + hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT_TOP)); + hbmpBackgroundBottom = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT_BOTTOM)); + hbmpBackgroundMiddle = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT_MIDDLE)); + + BITMAP bmTL; + GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL); + + hCloseButton = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_CLOSE_NORMAL)); + pfnWndAboutBoxCancelProc = (WNDPROC)::GetWindowLongPtr(GetDlgItem(hWnd, IDCANCEL), GWLP_WNDPROC); + ::SetWindowLongPtr(GetDlgItem(hWnd, IDCANCEL), GWLP_WNDPROC, (LONG_PTR)AboutBoxCancelProc); + + if (hbmpBackgroundTop) { - enum { ROUND_EDGE = 15 }; + // int iHeight = bmTL.bmHeight; + int iWidth = bmTL.bmWidth; - DWORD dwStyle = GetWindowLong(hWnd, GWL_STYLE); - dwStyle &= ~(WS_CAPTION|WS_SIZEBOX); - SetWindowLong(hWnd, GWL_STYLE, dwStyle); + RECT rect; + GetWindowRect(hWnd, &rect); + rect.left -= rect.left; + rect.bottom -= rect.top; + rect.top -= rect.top; - // Use the size of the image - hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_TOP)); - hbmpBackgroundBottom = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_BOTTOM)); - hbmpBackgroundMiddle = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_MIDDLE)); - - BITMAP bmTL; - GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL); - - hCloseButton = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_CLOSE_NORMAL)); - pfnWndAboutBoxCancelProc = (WNDPROC)::GetWindowLongPtr(GetDlgItem(hWnd,IDCANCEL), GWLP_WNDPROC); - ::SetWindowLongPtr(GetDlgItem(hWnd,IDCANCEL), GWLP_WNDPROC,(LONG_PTR)AboutBoxCancelProc); - - - if (hbmpBackgroundTop) + HRGN hWindowRegion = CreateRoundRectRgn(rect.left, rect.top, rect.left + iWidth + GetSystemMetrics(SM_CXEDGE) - 1, rect.bottom + GetSystemMetrics(SM_CYEDGE) - 1, ROUND_EDGE, ROUND_EDGE); + if (hWindowRegion) { -// int iHeight = bmTL.bmHeight; - int iWidth = bmTL.bmWidth; - - RECT rect; - GetWindowRect(hWnd, &rect); - rect.left -= rect.left; - rect.bottom -= rect.top; - rect.top -= rect.top; - - // Tweaked - HRGN hWindowRegion= CreateRoundRectRgn - ( - rect.left, - rect.top, - rect.left+iWidth+GetSystemMetrics(SM_CXEDGE)-1, - rect.bottom+GetSystemMetrics(SM_CYEDGE)-1, - ROUND_EDGE, - ROUND_EDGE - ); - - if (hWindowRegion) - { - SetWindowRgn(hWnd, hWindowRegion, TRUE); - DeleteObject(hWindowRegion); - } + SetWindowRgn(hWnd, hWindowRegion, TRUE); + DeleteObject(hWindowRegion); } - - hTextFont = ::CreateFont - ( - 18, - 0, - 0, - 0, - FW_NORMAL, - 0, - 0, - 0, - DEFAULT_CHARSET, - OUT_DEFAULT_PRECIS, - CLIP_DEFAULT_PRECIS, - PROOF_QUALITY, - DEFAULT_PITCH|FF_DONTCARE, - "Arial" - ); - - hAuthorFont = ::CreateFont - ( - 18, - 0, - 0, - 0, - FW_BOLD, - 0, - 0, - 0, - DEFAULT_CHARSET, - OUT_DEFAULT_PRECIS, - CLIP_DEFAULT_PRECIS, - PROOF_QUALITY, - DEFAULT_PITCH|FF_DONTCARE, - "Arial" - ); - - hPageHeadingFont = ::CreateFont - ( - 24, - 0, - 0, - 0, - FW_BOLD, - 0, - FALSE, //Show underlined? - 0, - DEFAULT_CHARSET, - OUT_DEFAULT_PRECIS, - CLIP_DEFAULT_PRECIS, - PROOF_QUALITY, - DEFAULT_PITCH|FF_DONTCARE, - "Arial Bold" - ); - - SendDlgItemMessage(hWnd,IDC_VERSION,WM_SETFONT,(WPARAM)hTextFont,TRUE); - SendDlgItemMessage(hWnd,IDC_TEAM,WM_SETFONT,(WPARAM)hPageHeadingFont,TRUE); - SendDlgItemMessage(hWnd,IDC_THANKS,WM_SETFONT,(WPARAM)hPageHeadingFont,TRUE); - - SendDlgItemMessage(hWnd,IDC_ZILMAR,WM_SETFONT,(WPARAM)hAuthorFont,TRUE); - SendDlgItemMessage(hWnd,IDC_JABO,WM_SETFONT,(WPARAM)hAuthorFont,TRUE); - SendDlgItemMessage(hWnd,IDC_SMIFF,WM_SETFONT,(WPARAM)hAuthorFont,TRUE); - SendDlgItemMessage(hWnd,IDC_GENT,WM_SETFONT,(WPARAM)hAuthorFont,TRUE); - - SendDlgItemMessage(hWnd,IDC_ZILMAR_DETAILS,WM_SETFONT,(WPARAM)hTextFont,TRUE); - SendDlgItemMessage(hWnd,IDC_JABO_DETAILS,WM_SETFONT,(WPARAM)hTextFont,TRUE); - SendDlgItemMessage(hWnd,IDC_SMIFF_DETAILS,WM_SETFONT,(WPARAM)hTextFont,TRUE); - SendDlgItemMessage(hWnd,IDC_GENT_DETAILS,WM_SETFONT,(WPARAM)hTextFont,TRUE); - - SendDlgItemMessage(hWnd,IDC_THANK_LIST,WM_SETFONT,(WPARAM)hTextFont,TRUE); - - //SetCapture(hWnd); - stdstr_f VersionDisplay("Version: %s", VER_FILE_VERSION_STR); - SetWindowText(GetDlgItem(hWnd,IDC_VERSION),VersionDisplay.c_str()); } - break; + + hTextFont = ::CreateFont(18, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial"); + hAuthorFont = ::CreateFont(18, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial"); + + hPageHeadingFont = ::CreateFont(24, 0, 0, 0, FW_BOLD, 0, FALSE, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial Bold"); + + SendDlgItemMessage(hWnd, IDC_VERSION, WM_SETFONT, (WPARAM)hTextFont, TRUE); + SendDlgItemMessage(hWnd, IDC_TEAM, WM_SETFONT, (WPARAM)hPageHeadingFont, TRUE); + SendDlgItemMessage(hWnd, IDC_THANKS, WM_SETFONT, (WPARAM)hPageHeadingFont, TRUE); + + SendDlgItemMessage(hWnd, IDC_ZILMAR, WM_SETFONT, (WPARAM)hAuthorFont, TRUE); + SendDlgItemMessage(hWnd, IDC_JABO, WM_SETFONT, (WPARAM)hAuthorFont, TRUE); + SendDlgItemMessage(hWnd, IDC_SMIFF, WM_SETFONT, (WPARAM)hAuthorFont, TRUE); + SendDlgItemMessage(hWnd, IDC_GENT, WM_SETFONT, (WPARAM)hAuthorFont, TRUE); + + SendDlgItemMessage(hWnd, IDC_ZILMAR_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE); + SendDlgItemMessage(hWnd, IDC_JABO_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE); + SendDlgItemMessage(hWnd, IDC_SMIFF_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE); + SendDlgItemMessage(hWnd, IDC_GENT_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE); + + SendDlgItemMessage(hWnd, IDC_THANK_LIST, WM_SETFONT, (WPARAM)hTextFont, TRUE); + + stdstr_f VersionDisplay("Version: %s", VER_FILE_VERSION_STR); + SetWindowText(GetDlgItem(hWnd, IDC_VERSION), VersionDisplay.c_str()); + } + break; case WM_NCHITTEST: + { + int xPos = LOWORD(lParam); + int yPos = HIWORD(lParam); + RECT client, a; + GetClientRect(hWnd, &a); + GetClientRect(hWnd, &client); + ClientToScreen(hWnd, (LPPOINT)&client); + client.right += client.left; + client.bottom += client.top; + + int nCaption = GetSystemMetrics(SM_CYCAPTION) * 4; + + LRESULT lResult = HTCLIENT; + + //check caption + if (xPos <= client.right && xPos >= client.left && + (yPos >= client.top + 0) && (yPos <= client.top + 0 + nCaption)) { - int xPos = LOWORD(lParam); - int yPos = HIWORD(lParam); - RECT client, a; - GetClientRect(hWnd,&a); - GetClientRect(hWnd,&client); - ClientToScreen(hWnd,(LPPOINT)&client); - client.right += client.left; - client.bottom += client.top; - - - int nCaption = GetSystemMetrics(SM_CYCAPTION)*4; - - LRESULT lResult = HTCLIENT; - - //check caption - if (xPos <= client.right && xPos >= client.left && - (yPos >= client.top+ 0)&& (yPos <= client.top + 0+nCaption)) - { - lResult = HTCAPTION; - } - SetWindowLong(hWnd, DWLP_MSGRESULT, lResult); - return TRUE; + lResult = HTCAPTION; } - break; + SetWindowLong(hWnd, DWLP_MSGRESULT, lResult); + return TRUE; + } + break; case WM_CTLCOLORSTATIC: - { - HDC hdcStatic = (HDC)wParam; - SetTextColor(hdcStatic, RGB(0, 0, 0)); - SetBkMode(hdcStatic, TRANSPARENT); - return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH)); - } - break; + { + HDC hdcStatic = (HDC)wParam; + SetTextColor(hdcStatic, RGB(0, 0, 0)); + SetBkMode(hdcStatic, TRANSPARENT); + return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH)); + } + break; case WM_PAINT: + { + PAINTSTRUCT ps; + + if (BeginPaint(hWnd, &ps)) { - PAINTSTRUCT ps; + RECT rcClient; + GetClientRect(hWnd, &rcClient); - if (BeginPaint(hWnd,&ps)) + BITMAP bmTL_top, bmTL_bottom, bmTL_Middle; + GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top); + GetObject(hbmpBackgroundBottom, sizeof(BITMAP), &bmTL_bottom); + GetObject(hbmpBackgroundMiddle, sizeof(BITMAP), &bmTL_Middle); + + HDC memdc = CreateCompatibleDC(ps.hdc); + HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop); + BitBlt(ps.hdc, 0, 0, bmTL_top.bmWidth, bmTL_top.bmHeight, memdc, 0, 0, SRCCOPY); + SelectObject(memdc, save); + DeleteDC(memdc); + + memdc = CreateCompatibleDC(ps.hdc); + save = SelectObject(memdc, hbmpBackgroundMiddle); + for (int x = bmTL_top.bmHeight; x < rcClient.bottom; x += bmTL_Middle.bmHeight) { - RECT rcClient; - GetClientRect(hWnd, &rcClient); - - BITMAP bmTL_top, bmTL_bottom, bmTL_Middle; - GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top); - GetObject(hbmpBackgroundBottom, sizeof(BITMAP), &bmTL_bottom); - GetObject(hbmpBackgroundMiddle, sizeof(BITMAP), &bmTL_Middle); - - HDC memdc = CreateCompatibleDC(ps.hdc); - HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop); - BitBlt(ps.hdc, 0, 0, bmTL_top.bmWidth, bmTL_top.bmHeight, memdc, 0, 0, SRCCOPY); - SelectObject(memdc, save); - DeleteDC(memdc); - - - memdc = CreateCompatibleDC(ps.hdc); - save = SelectObject(memdc, hbmpBackgroundMiddle); - for (int x = bmTL_top.bmHeight; x < rcClient.bottom; x += bmTL_Middle.bmHeight) - { - //BitBlt(ps.hdc, 0, bmTL_top.bmHeight, bmTL_Middle.bmWidth, rcClient.bottom - (bmTL_bottom.bmHeight + bmTL_top.bmHeight), memdc, 0, 0, SRCCOPY); - BitBlt(ps.hdc, 0, x, bmTL_Middle.bmWidth, bmTL_Middle.bmHeight, memdc, 0, 0, SRCCOPY); - } - SelectObject(memdc, save); - DeleteDC(memdc); - - BITMAP ; - memdc = CreateCompatibleDC(ps.hdc); - save = SelectObject(memdc, hbmpBackgroundBottom); - BitBlt(ps.hdc, 0, rcClient.bottom - bmTL_bottom.bmHeight, bmTL_bottom.bmWidth, bmTL_bottom.bmHeight, memdc, 0, 0, SRCCOPY); - SelectObject(memdc, save); - DeleteDC(memdc); - - BITMAP ; - - EndPaint(hWnd,&ps); + BitBlt(ps.hdc, 0, x, bmTL_Middle.bmWidth, bmTL_Middle.bmHeight, memdc, 0, 0, SRCCOPY); } + SelectObject(memdc, save); + DeleteDC(memdc); + + BITMAP; + memdc = CreateCompatibleDC(ps.hdc); + save = SelectObject(memdc, hbmpBackgroundBottom); + BitBlt(ps.hdc, 0, rcClient.bottom - bmTL_bottom.bmHeight, bmTL_bottom.bmWidth, bmTL_bottom.bmHeight, memdc, 0, 0, SRCCOPY); + SelectObject(memdc, save); + DeleteDC(memdc); + + BITMAP; + + EndPaint(hWnd, &ps); } - break; + } + break; case WM_COMMAND: - switch (LOWORD(wParam)) { + switch (LOWORD(wParam)) + { case IDOK: case IDCANCEL: if (hbmpBackgroundTop) @@ -1215,15 +1177,19 @@ DWORD CALLBACK AboutBoxProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) DeleteObject(hbmpBackgroundMiddle); } if (hTextFont) + { ::DeleteObject(hTextFont); + } if (hPageHeadingFont) + { ::DeleteObject(hPageHeadingFont); + } if (hAuthorFont) + { ::DeleteObject(hAuthorFont); - - + } //ReleaseCapture(); - EndDialog(hWnd,0); + EndDialog(hWnd, 0); break; } default: @@ -1232,26 +1198,10 @@ DWORD CALLBACK AboutBoxProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) return TRUE; } -BOOL set_about_field( - HWND hDlg, - int nIDDlgItem, - const wchar_t * config_string, - const wchar_t * language_string -) +BOOL set_about_field(HWND hDlg, int nIDDlgItem, const wchar_t * config_string, const wchar_t * language_string) { - wchar_t temp_string[200]; + wchar_t temp_string[200]; - swprintf( - temp_string, - sizeof(temp_string) / sizeof(temp_string[0]), - L"%s: %s", - config_string, - language_string - ); - return SetDlgItemTextW( - hDlg, - nIDDlgItem, - temp_string - ); + swprintf(temp_string, sizeof(temp_string) / sizeof(temp_string[0]), L"%s: %s", config_string, language_string); + return SetDlgItemTextW(hDlg, nIDDlgItem, temp_string); } -#endif diff --git a/Source/Project64/User Interface/Gui Class.h b/Source/Project64/User Interface/Gui Class.h index 52bed2dde..62dc6f9ad 100644 --- a/Source/Project64/User Interface/Gui Class.h +++ b/Source/Project64/User Interface/Gui Class.h @@ -32,102 +32,101 @@ class CMainGui : public CDebuggerUI, private CGuiSettings { - enum { StatusBarID = 400 }; + enum { StatusBarID = 400 }; - enum { Timer_SetWindowPos = 1 }; + enum { Timer_SetWindowPos = 1 }; - struct RESET_PLUGIN - { - CN64System * system; - CPlugins * plugins; - HANDLE hEvent; - bool res; - }; + struct RESET_PLUGIN + { + CN64System * system; + CPlugins * plugins; + HANDLE hEvent; + bool res; + }; public: - CMainGui ( bool bMainWindow, const char * WindowTitle = "" ); - ~CMainGui ( void ); - - //Message Processing - WPARAM ProcessAllMessages ( void ); - bool ProcessGuiMessages ( void ); + CMainGui(bool bMainWindow, const char * WindowTitle = ""); + ~CMainGui(void); - //debugging functions - void EnterLogOptions ( void ); + //Message Processing + WPARAM ProcessAllMessages(void); + bool ProcessGuiMessages(void); - //Get Information about the window - int Height ( void ); //Get the Height of the window - int Width ( void ); //Get the Width of the window + //debugging functions + void EnterLogOptions(void); - //Manipulate the state of the window - void SetPos ( int X, int Y ); //Move the window to this screen location - void Show ( bool ShowWindow ); //Show or Hide the current window - void MakeWindowOnTop ( bool OnTop ); - void BringToTop ( void ); - void Caption ( LPCWSTR Caption ); //Set the caption of the window - void SaveWindowLoc ( void ); + //Get Information about the window + int Height(void); //Get the Height of the window + int Width(void); //Get the Width of the window - //Menu Function - void SetWindowMenu ( CBaseMenu * Menu ); - void RefreshMenu ( void ); - CBaseMenu * GetMenuClass ( void ) { return m_Menu; } + //Manipulate the state of the window + void SetPos(int X, int Y); //Move the window to this screen location + void Show(bool ShowWindow); //Show or Hide the current window + void MakeWindowOnTop(bool OnTop); + void BringToTop(void); + void Caption(LPCWSTR Caption); //Set the caption of the window + void SaveWindowLoc(void); - // Status bar - void SetStatusText ( int Panel,const wchar_t * Text ); - void ShowStatusBar ( bool ShowBar ); + //Menu Function + void SetWindowMenu(CBaseMenu * Menu); + void RefreshMenu(void); + CBaseMenu * GetMenuClass(void) { return m_Menu; } - //About Window - void AboutIniBox ( void ); - void AboutBox ( void ); + // Status bar + void SetStatusText(int Panel, const wchar_t * Text); + void ShowStatusBar(bool ShowBar); - //Plugins + //About Window + void AboutIniBox(void); + void AboutBox(void); + + //Plugins bool ResetPlugins ( CPlugins * plugins, CN64System * System ); - //Get Window Handle + //Get Window Handle inline HWND GetHandle ( void ) const { return m_hMainWindow; } private: - CMainGui(void); // Disable default constructor - CMainGui(const CMainGui&); // Disable copy constructor - CMainGui& operator=(const CMainGui&); // Disable assignment + CMainGui(void); // Disable default constructor + CMainGui(const CMainGui&); // Disable copy constructor + CMainGui& operator=(const CMainGui&); // Disable assignment - friend CGfxPlugin; - friend CAudioPlugin; - friend CControl_Plugin; + friend CGfxPlugin; + friend CAudioPlugin; + friend CControl_Plugin; - bool RegisterWinClass ( void ); - void ChangeWinSize ( long width, long height ); - void Create ( const char * WindowTitle ); - void CreateStatusBar ( void ); - void Resize ( DWORD fwSizeType, WORD nWidth, WORD nHeight ); //responding to WM_SIZE + bool RegisterWinClass(void); + void ChangeWinSize(long width, long height); + void Create(const char * WindowTitle); + void CreateStatusBar(void); + void Resize(DWORD fwSizeType, WORD nWidth, WORD nHeight); //responding to WM_SIZE - friend DWORD CALLBACK AboutBoxProc ( HWND, DWORD, DWORD, DWORD ); - friend DWORD CALLBACK AboutIniBoxProc ( HWND, DWORD, DWORD, DWORD ); - static LRESULT CALLBACK MainGui_Proc ( HWND, DWORD, DWORD, DWORD ); + friend DWORD CALLBACK AboutBoxProc(HWND, DWORD, DWORD, DWORD); + friend DWORD CALLBACK AboutIniBoxProc(HWND, DWORD, DWORD, DWORD); + static LRESULT CALLBACK MainGui_Proc(HWND, DWORD, DWORD, DWORD); - friend void RomBowserEnabledChanged (CMainGui * Gui); - friend void RomBowserColoumnsChanged (CMainGui * Gui); - friend void RomBrowserRecursiveChanged (CMainGui * Gui); + friend void RomBowserEnabledChanged(CMainGui * Gui); + friend void RomBowserColoumnsChanged(CMainGui * Gui); + friend void RomBrowserRecursiveChanged(CMainGui * Gui); - CBaseMenu * m_Menu; + CBaseMenu * m_Menu; - HWND m_hMainWindow, m_hStatusWnd; - DWORD m_ThreadId; + HWND m_hMainWindow, m_hStatusWnd; + DWORD m_ThreadId; - const bool m_bMainWindow; - bool m_Created; - bool m_AttachingMenu; - bool m_MakingVisible; - bool m_ResetPlugins; - RESET_PLUGIN * m_ResetInfo; + const bool m_bMainWindow; + bool m_Created; + bool m_AttachingMenu; + bool m_MakingVisible; + bool m_ResetPlugins; + RESET_PLUGIN * m_ResetInfo; - CriticalSection m_CS; + CriticalSection m_CS; - bool m_SaveMainWindowPos; - LONG m_SaveMainWindowTop; - LONG m_SaveMainWindowLeft; - - bool m_SaveRomBrowserPos; - LONG m_SaveRomBrowserTop; - LONG m_SaveRomBrowserLeft; + bool m_SaveMainWindowPos; + LONG m_SaveMainWindowTop; + LONG m_SaveMainWindowLeft; + bool m_SaveRomBrowserPos; + LONG m_SaveRomBrowserTop; + LONG m_SaveRomBrowserLeft; }; diff --git a/Source/Project64/User Interface/Main Menu Class.cpp b/Source/Project64/User Interface/Main Menu Class.cpp index 5430c47b4..04b09572d 100644 --- a/Source/Project64/User Interface/Main Menu Class.cpp +++ b/Source/Project64/User Interface/Main Menu Class.cpp @@ -214,10 +214,12 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI } break; case ID_SYSTEM_CHEAT: - { - g_BaseSystem->SelectCheats(hWnd); - } - break; + { + CCheatsUI * cheatUI = new CCheatsUI; + g_cheatUI = cheatUI; + cheatUI->SelectCheats(hWnd, false); + } + break; case ID_SYSTEM_GSBUTTON: g_BaseSystem->ExternalEvent(SysEvent_GSButtonPressed); break; From 3b8e03b5700594d1d761f384d857de5c597e7dab Mon Sep 17 00:00:00 2001 From: zilmar Date: Sun, 8 Nov 2015 17:08:15 +1100 Subject: [PATCH 083/213] [Project64] Clean up plugin classes --- Source/Project64/Plugins/Audio Plugin.cpp | 270 ++++++------ Source/Project64/Plugins/Audio Plugin.h | 38 +- .../Project64/Plugins/Controller Plugin.cpp | 248 +++++------ Source/Project64/Plugins/Controller Plugin.h | 147 ++++--- Source/Project64/Plugins/GFX plugin.cpp | 406 +++++++++--------- Source/Project64/Plugins/GFX plugin.h | 128 +++--- Source/Project64/Plugins/Plugin Base.cpp | 347 ++++++++------- Source/Project64/Plugins/Plugin Base.h | 77 ++-- Source/Project64/Plugins/Plugin Class.cpp | 326 +++++++------- Source/Project64/Plugins/Plugin Class.h | 180 ++++---- Source/Project64/Plugins/RSP Plugin.cpp | 306 ++++++------- Source/Project64/Plugins/RSP Plugin.h | 96 ++--- 12 files changed, 1313 insertions(+), 1256 deletions(-) diff --git a/Source/Project64/Plugins/Audio Plugin.cpp b/Source/Project64/Plugins/Audio Plugin.cpp index 8d7c6e52e..5172a3fa4 100644 --- a/Source/Project64/Plugins/Audio Plugin.cpp +++ b/Source/Project64/Plugins/Audio Plugin.cpp @@ -11,177 +11,179 @@ #include "stdafx.h" CAudioPlugin::CAudioPlugin() : - AiLenChanged(NULL), - AiReadLength(NULL), - ProcessAList(NULL), - m_hAudioThread(NULL), - AiUpdate(NULL), - AiDacrateChanged(NULL) + AiLenChanged(NULL), + AiReadLength(NULL), + ProcessAList(NULL), + m_hAudioThread(NULL), + AiUpdate(NULL), + AiDacrateChanged(NULL) { } CAudioPlugin::~CAudioPlugin() { - Close(); - UnloadPlugin(); + Close(); + UnloadPlugin(); } -bool CAudioPlugin::LoadFunctions ( void ) +bool CAudioPlugin::LoadFunctions(void) { - // Find entries for functions in DLL - void (__cdecl *InitiateAudio) ( void ); - LoadFunction(InitiateAudio); - LoadFunction(AiDacrateChanged); - LoadFunction(AiLenChanged); - LoadFunction(AiReadLength); - LoadFunction(AiUpdate); - LoadFunction(ProcessAList); + // Find entries for functions in DLL + void(__cdecl *InitiateAudio) (void); + LoadFunction(InitiateAudio); + LoadFunction(AiDacrateChanged); + LoadFunction(AiLenChanged); + LoadFunction(AiReadLength); + LoadFunction(AiUpdate); + LoadFunction(ProcessAList); - // Make sure dll has all needed functions - if (AiDacrateChanged == NULL) { UnloadPlugin(); return false; } - if (AiLenChanged == NULL) { UnloadPlugin(); return false; } - if (AiReadLength == NULL) { UnloadPlugin(); return false; } - if (InitiateAudio == NULL) { UnloadPlugin(); return false; } - if (ProcessAList == NULL) { UnloadPlugin(); return false; } + // Make sure dll has all needed functions + if (AiDacrateChanged == NULL) { UnloadPlugin(); return false; } + if (AiLenChanged == NULL) { UnloadPlugin(); return false; } + if (AiReadLength == NULL) { UnloadPlugin(); return false; } + if (InitiateAudio == NULL) { UnloadPlugin(); return false; } + if (ProcessAList == NULL) { UnloadPlugin(); return false; } - if (m_PluginInfo.Version >= 0x0102) - { - if (PluginOpened == NULL) { UnloadPlugin(); return false; } - } - return true; + if (m_PluginInfo.Version >= 0x0102) + { + if (PluginOpened == NULL) { UnloadPlugin(); return false; } + } + return true; } bool CAudioPlugin::Initiate(CN64System * System, CMainGui * RenderWindow) { - struct AUDIO_INFO { - HWND hwnd; - HINSTANCE hinst; + struct AUDIO_INFO + { + HWND hwnd; + HINSTANCE hinst; - BOOL MemoryBswaped; // If this is set to TRUE, then the memory has been pre - // bswap on a dword (32 bits) boundry - // eg. the first 8 bytes are stored like this: - // 4 3 2 1 8 7 6 5 - BYTE * HEADER; // This is the rom header (first 40h bytes of the rom - // This will be in the same memory format as the rest of the memory. - BYTE * RDRAM; - BYTE * DMEM; - BYTE * IMEM; + int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre - DWORD * MI__INTR_REG; + // bswap on a dword (32 bits) boundry + // eg. the first 8 bytes are stored like this: + // 4 3 2 1 8 7 6 5 + uint8_t * HEADER; // This is the rom header (first 40h bytes of the rom + // This will be in the same memory format as the rest of the memory. + uint8_t * RDRAM; + uint8_t * DMEM; + uint8_t * IMEM; - DWORD * AI__DRAM_ADDR_REG; - DWORD * AI__LEN_REG; - DWORD * AI__CONTROL_REG; - DWORD * AI__STATUS_REG; - DWORD * AI__DACRATE_REG; - DWORD * AI__BITRATE_REG; + uint32_t * MI__INTR_REG; - void (__cdecl *CheckInterrupts)( void ); - }; + uint32_t * AI__DRAM_ADDR_REG; + uint32_t * AI__LEN_REG; + uint32_t * AI__CONTROL_REG; + uint32_t * AI__STATUS_REG; + uint32_t * AI__DACRATE_REG; + uint32_t * AI__BITRATE_REG; - //Get Function from DLL - BOOL (__cdecl *InitiateAudio)( AUDIO_INFO Audio_Info ); - LoadFunction(InitiateAudio); - if (InitiateAudio == NULL) { return false; } + void(__cdecl *CheckInterrupts)(void); + }; - AUDIO_INFO Info = { 0 }; + //Get Function from DLL + int32_t(__cdecl *InitiateAudio)(AUDIO_INFO Audio_Info); + LoadFunction(InitiateAudio); + if (InitiateAudio == NULL) { return false; } + + AUDIO_INFO Info = { 0 }; Info.hwnd = (HWND)RenderWindow->m_hMainWindow;; - Info.hinst = GetModuleHandle(NULL); - Info.MemoryBswaped = TRUE; - Info.CheckInterrupts = DummyCheckInterrupts; + Info.hinst = GetModuleHandle(NULL); + Info.MemoryBswaped = TRUE; + Info.CheckInterrupts = DummyCheckInterrupts; - // We are initializing the plugin before any rom is loaded so we do not have any correct - // parameters here.. just needed to we can config the DLL. - if (System == NULL) - { - BYTE Buffer[100]; - DWORD Value = 0; + // We are initializing the plugin before any rom is loaded so we do not have any correct + // parameters here.. just needed to we can config the DLL. + if (System == NULL) + { + uint8_t Buffer[100]; + uint32_t Value = 0; - Info.HEADER = Buffer; - Info.RDRAM = Buffer; - Info.DMEM = Buffer; - Info.IMEM = Buffer; - Info.MI__INTR_REG = &Value; - Info.AI__DRAM_ADDR_REG = &Value; - Info.AI__LEN_REG = &Value; - Info.AI__CONTROL_REG = &Value; - Info.AI__STATUS_REG = &Value; - Info.AI__DACRATE_REG = &Value; - Info.AI__BITRATE_REG = &Value; - } - // Send initialization information to the DLL - else - { - Info.HEADER = g_Rom->GetRomAddress(); - Info.RDRAM = g_MMU->Rdram(); - Info.DMEM = g_MMU->Dmem(); - Info.IMEM = g_MMU->Imem(); - Info.MI__INTR_REG = &g_Reg->m_AudioIntrReg; - Info.AI__DRAM_ADDR_REG = &g_Reg->AI_DRAM_ADDR_REG; - Info.AI__LEN_REG = &g_Reg->AI_LEN_REG; - Info.AI__CONTROL_REG = &g_Reg->AI_CONTROL_REG; - Info.AI__STATUS_REG = &g_Reg->AI_STATUS_REG; - Info.AI__DACRATE_REG = &g_Reg->AI_DACRATE_REG; - Info.AI__BITRATE_REG = &g_Reg->AI_BITRATE_REG; - } + Info.HEADER = Buffer; + Info.RDRAM = Buffer; + Info.DMEM = Buffer; + Info.IMEM = Buffer; + Info.MI__INTR_REG = &Value; + Info.AI__DRAM_ADDR_REG = &Value; + Info.AI__LEN_REG = &Value; + Info.AI__CONTROL_REG = &Value; + Info.AI__STATUS_REG = &Value; + Info.AI__DACRATE_REG = &Value; + Info.AI__BITRATE_REG = &Value; + } + // Send initialization information to the DLL + else + { + Info.HEADER = g_Rom->GetRomAddress(); + Info.RDRAM = g_MMU->Rdram(); + Info.DMEM = g_MMU->Dmem(); + Info.IMEM = g_MMU->Imem(); + Info.MI__INTR_REG = (uint32_t *)&g_Reg->m_AudioIntrReg; + Info.AI__DRAM_ADDR_REG = (uint32_t *)&g_Reg->AI_DRAM_ADDR_REG; + Info.AI__LEN_REG = (uint32_t *)&g_Reg->AI_LEN_REG; + Info.AI__CONTROL_REG = (uint32_t *)&g_Reg->AI_CONTROL_REG; + Info.AI__STATUS_REG = (uint32_t *)&g_Reg->AI_STATUS_REG; + Info.AI__DACRATE_REG = (uint32_t *)&g_Reg->AI_DACRATE_REG; + Info.AI__BITRATE_REG = (uint32_t *)&g_Reg->AI_BITRATE_REG; + } - m_Initialized = InitiateAudio(Info) != 0; + m_Initialized = InitiateAudio(Info) != 0; - //jabo had a bug so I call CreateThread so his dllmain gets called again - DWORD ThreadID; - HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID); - CloseHandle(hthread); + //jabo had a bug so I call CreateThread so his dllmain gets called again + DWORD ThreadID; + HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID); + CloseHandle(hthread); - if (System != NULL) - { - if (AiUpdate) - { - if (m_hAudioThread) - { - WriteTraceF(TraceAudio, __FUNCTION__ ": Terminate Audio Thread"); - TerminateThread(m_hAudioThread, 0); - } - m_hAudioThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)AudioThread, (LPVOID)this, 0, &ThreadID); - } - - if (g_Reg->AI_DACRATE_REG != 0) - { - DacrateChanged(System->SystemType()); - } - } - return m_Initialized; + if (System != NULL) + { + if (AiUpdate) + { + if (m_hAudioThread) + { + WriteTraceF(TraceAudio, __FUNCTION__ ": Terminate Audio Thread"); + TerminateThread(m_hAudioThread, 0); + } + m_hAudioThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)AudioThread, (LPVOID)this, 0, &ThreadID); + } + + if (g_Reg->AI_DACRATE_REG != 0) + { + DacrateChanged(System->SystemType()); + } + } + return m_Initialized; } void CAudioPlugin::UnloadPluginDetails(void) { - if (m_hAudioThread) - { - WriteTraceF(TraceAudio, __FUNCTION__ ": Terminate Audio Thread"); - TerminateThread(m_hAudioThread, 0); - m_hAudioThread = NULL; - } - AiDacrateChanged = NULL; - AiLenChanged = NULL; - AiReadLength = NULL; - AiUpdate = NULL; - ProcessAList = NULL; + if (m_hAudioThread) + { + WriteTraceF(TraceAudio, __FUNCTION__ ": Terminate Audio Thread"); + TerminateThread(m_hAudioThread, 0); + m_hAudioThread = NULL; + } + AiDacrateChanged = NULL; + AiLenChanged = NULL; + AiReadLength = NULL; + AiUpdate = NULL; + ProcessAList = NULL; } void CAudioPlugin::DacrateChanged(SYSTEM_TYPE Type) { - if (!Initialized()) { return; } - WriteTraceF(TraceAudio, __FUNCTION__ ": SystemType: %s", Type == SYSTEM_NTSC ? "SYSTEM_NTSC" : "SYSTEM_PAL"); + if (!Initialized()) { return; } + WriteTraceF(TraceAudio, __FUNCTION__ ": SystemType: %s", Type == SYSTEM_NTSC ? "SYSTEM_NTSC" : "SYSTEM_PAL"); - //DWORD Frequency = g_Reg->AI_DACRATE_REG * 30; - //DWORD CountsPerSecond = (g_Reg->VI_V_SYNC_REG != 0 ? (g_Reg->VI_V_SYNC_REG + 1) * g_Settings->LoadDword(Game_ViRefreshRate) : 500000) * 60; - AiDacrateChanged(Type); + //uint32_t Frequency = g_Reg->AI_DACRATE_REG * 30; + //uint32_t CountsPerSecond = (g_Reg->VI_V_SYNC_REG != 0 ? (g_Reg->VI_V_SYNC_REG + 1) * g_Settings->LoadDword(Game_ViRefreshRate) : 500000) * 60; + AiDacrateChanged(Type); } void CAudioPlugin::AudioThread(CAudioPlugin * _this) { - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); - for (;;) - { - _this->AiUpdate(true); - } + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); + for (;;) + { + _this->AiUpdate(true); + } } diff --git a/Source/Project64/Plugins/Audio Plugin.h b/Source/Project64/Plugins/Audio Plugin.h index 181bd415b..a6bd03c66 100644 --- a/Source/Project64/Plugins/Audio Plugin.h +++ b/Source/Project64/Plugins/Audio Plugin.h @@ -13,32 +13,32 @@ class CAudioPlugin : public CPlugin { public: - CAudioPlugin(void); - ~CAudioPlugin(); + CAudioPlugin(void); + ~CAudioPlugin(); - void DacrateChanged(SYSTEM_TYPE Type); + void DacrateChanged(SYSTEM_TYPE Type); bool Initiate(CN64System * System, CMainGui * RenderWindow); - void(__cdecl *AiLenChanged)(void); - DWORD(__cdecl *AiReadLength)(void); - void(__cdecl *ProcessAList)(void); + void(__cdecl *AiLenChanged)(void); + uint32_t(__cdecl *AiReadLength)(void); + void(__cdecl *ProcessAList)(void); private: - CAudioPlugin(const CAudioPlugin&); // Disable copy constructor - CAudioPlugin& operator=(const CAudioPlugin&); // Disable assignment + CAudioPlugin(const CAudioPlugin&); // Disable copy constructor + CAudioPlugin& operator=(const CAudioPlugin&); // Disable assignment - virtual int GetDefaultSettingStartRange() const { return FirstAudioDefaultSet; } - virtual int GetSettingStartRange() const { return FirstAudioSettings; } - PLUGIN_TYPE type() { return PLUGIN_TYPE_AUDIO; } + virtual int32_t GetDefaultSettingStartRange() const { return FirstAudioDefaultSet; } + virtual int32_t GetSettingStartRange() const { return FirstAudioSettings; } + PLUGIN_TYPE type() { return PLUGIN_TYPE_AUDIO; } - void * m_hAudioThread; - - bool LoadFunctions ( void ); - void UnloadPluginDetails ( void ); + void * m_hAudioThread; - void(__cdecl *AiUpdate) (BOOL Wait); - void(__cdecl *AiDacrateChanged)(SYSTEM_TYPE Type); + bool LoadFunctions(void); + void UnloadPluginDetails(void); - // Function used in a thread for using audio - static void AudioThread(CAudioPlugin * _this); + void(__cdecl *AiUpdate) (int32_t Wait); + void(__cdecl *AiDacrateChanged)(SYSTEM_TYPE Type); + + // Function used in a thread for using audio + static void AudioThread(CAudioPlugin * _this); }; diff --git a/Source/Project64/Plugins/Controller Plugin.cpp b/Source/Project64/Plugins/Controller Plugin.cpp index b935a02d9..8b399bace 100644 --- a/Source/Project64/Plugins/Controller Plugin.cpp +++ b/Source/Project64/Plugins/Controller Plugin.cpp @@ -11,164 +11,170 @@ #include "stdafx.h" CControl_Plugin::CControl_Plugin(void) : - WM_KeyDown(NULL), - WM_KeyUp(NULL), - RumbleCommand(NULL), - GetKeys(NULL), - ReadController(NULL), - ControllerCommand(NULL), - m_AllocatedControllers(false) + WM_KeyDown(NULL), + WM_KeyUp(NULL), + RumbleCommand(NULL), + GetKeys(NULL), + ReadController(NULL), + ControllerCommand(NULL), + m_AllocatedControllers(false) { - memset(&m_PluginControllers, 0, sizeof(m_PluginControllers)); - memset(&m_Controllers, 0, sizeof(m_Controllers)); + memset(&m_PluginControllers, 0, sizeof(m_PluginControllers)); + memset(&m_Controllers, 0, sizeof(m_Controllers)); } CControl_Plugin::~CControl_Plugin() { - Close(); - UnloadPlugin(); + Close(); + UnloadPlugin(); } -bool CControl_Plugin::LoadFunctions ( void ) +bool CControl_Plugin::LoadFunctions(void) { - // Find entries for functions in DLL - void (__cdecl *InitiateControllers)( void ); - LoadFunction(InitiateControllers); - LoadFunction(ControllerCommand); - LoadFunction(GetKeys); - LoadFunction(ReadController); - LoadFunction(WM_KeyDown); - LoadFunction(WM_KeyUp); - LoadFunction(RumbleCommand); + // Find entries for functions in DLL + void(__cdecl *InitiateControllers)(void); + LoadFunction(InitiateControllers); + LoadFunction(ControllerCommand); + LoadFunction(GetKeys); + LoadFunction(ReadController); + LoadFunction(WM_KeyDown); + LoadFunction(WM_KeyUp); + LoadFunction(RumbleCommand); - //Make sure dll had all needed functions - if (InitiateControllers == NULL) { UnloadPlugin(); return false; } + //Make sure dll had all needed functions + if (InitiateControllers == NULL) { UnloadPlugin(); return false; } - if (m_PluginInfo.Version >= 0x0102) - { - if (PluginOpened == NULL) { UnloadPlugin(); return false; } - } + if (m_PluginInfo.Version >= 0x0102) + { + if (PluginOpened == NULL) { UnloadPlugin(); return false; } + } - // Allocate our own controller - m_AllocatedControllers = true; - for (int i = 0; i < 4; i++) - { - m_Controllers[i] = new CCONTROL(m_PluginControllers[i].Present, m_PluginControllers[i].RawData, m_PluginControllers[i].Plugin); - } - return true; + // Allocate our own controller + m_AllocatedControllers = true; + for (int32_t i = 0; i < 4; i++) + { + m_Controllers[i] = new CCONTROL(m_PluginControllers[i].Present, m_PluginControllers[i].RawData, m_PluginControllers[i].Plugin); + } + return true; } bool CControl_Plugin::Initiate(CN64System * System, CMainGui * RenderWindow) { - for (int i = 0; i < 4; i++) - { - m_PluginControllers[i].Present = FALSE; - m_PluginControllers[i].RawData = FALSE; - m_PluginControllers[i].Plugin = PLUGIN_NONE; - } + for (int32_t i = 0; i < 4; i++) + { + m_PluginControllers[i].Present = FALSE; + m_PluginControllers[i].RawData = FALSE; + m_PluginControllers[i].Plugin = PLUGIN_NONE; + } - // Test Plugin version - if (m_PluginInfo.Version == 0x0100) - { - //Get Function from DLL - void (__cdecl *InitiateControllers_1_0)( HWND hMainWindow, CONTROL Controls[4] ); - InitiateControllers_1_0 = (void (__cdecl *)(HWND, CONTROL *))GetProcAddress( (HMODULE)m_hDll, "InitiateControllers" ); - if (InitiateControllers_1_0 == NULL) { return false; } + // Test Plugin version + if (m_PluginInfo.Version == 0x0100) + { + //Get Function from DLL + void(__cdecl *InitiateControllers_1_0)(HWND hMainWindow, CONTROL Controls[4]); + InitiateControllers_1_0 = (void(__cdecl *)(HWND, CONTROL *))GetProcAddress((HMODULE)m_hDll, "InitiateControllers"); + if (InitiateControllers_1_0 == NULL) { return false; } InitiateControllers_1_0((HWND)RenderWindow->m_hMainWindow,m_PluginControllers); - m_Initialized = true; - } - else if (m_PluginInfo.Version >= 0x0101) - { - typedef struct { - HWND hMainWindow; - HINSTANCE hinst; + m_Initialized = true; + } + else if (m_PluginInfo.Version >= 0x0101) + { + typedef struct + { + HWND hMainWindow; + HINSTANCE hinst; - BOOL MemoryBswaped; // If this is set to TRUE, then the memory has been pre - // bswap on a dword (32 bits) boundry, only effects header. - // eg. the first 8 bytes are stored like this: - // 4 3 2 1 8 7 6 5 - BYTE * HEADER; // This is the rom header (first 40h bytes of the rom) - CONTROL *Controls; // A pointer to an array of 4 controllers .. eg: - // CONTROL Controls[4]; - } CONTROL_INFO; + int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre + // bswap on a dword (32 bits) boundry, only effects header. + // eg. the first 8 bytes are stored like this: + // 4 3 2 1 8 7 6 5 + uint8_t * HEADER; // This is the rom header (first 40h bytes of the rom) + CONTROL *Controls; // A pointer to an array of 4 controllers .. eg: + // CONTROL Controls[4]; + } CONTROL_INFO; - //Get Function from DLL - void (__cdecl *InitiateControllers_1_1)( CONTROL_INFO * ControlInfo ); - InitiateControllers_1_1 = (void (__cdecl *)(CONTROL_INFO *))GetProcAddress( (HMODULE)m_hDll, "InitiateControllers" ); - if (InitiateControllers_1_1 == NULL) { return false; } - - CONTROL_INFO ControlInfo; - BYTE Buffer[100]; + //Get Function from DLL + void(__cdecl *InitiateControllers_1_1)(CONTROL_INFO * ControlInfo); + InitiateControllers_1_1 = (void(__cdecl *)(CONTROL_INFO *))GetProcAddress((HMODULE)m_hDll, "InitiateControllers"); + if (InitiateControllers_1_1 == NULL) { return false; } - ControlInfo.Controls = m_PluginControllers; - ControlInfo.HEADER = (System == NULL ? Buffer : g_Rom->GetRomAddress()); - ControlInfo.hinst = GetModuleHandle(NULL); + CONTROL_INFO ControlInfo; + uint8_t Buffer[100]; + + ControlInfo.Controls = m_PluginControllers; + ControlInfo.HEADER = (System == NULL ? Buffer : g_Rom->GetRomAddress()); + ControlInfo.hinst = GetModuleHandle(NULL); ControlInfo.hMainWindow = (HWND)RenderWindow->m_hMainWindow; - ControlInfo.MemoryBswaped = TRUE; + ControlInfo.MemoryBswaped = TRUE; - InitiateControllers_1_1(&ControlInfo); - m_Initialized = true; - } + InitiateControllers_1_1(&ControlInfo); + m_Initialized = true; + } - //jabo had a bug so I call CreateThread so his dllmain gets called again - DWORD ThreadID; - HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID); - CloseHandle(hthread); + //jabo had a bug so I call CreateThread so his dllmain gets called again + DWORD ThreadID; + HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID); + CloseHandle(hthread); - return m_Initialized; + return m_Initialized; } void CControl_Plugin::UnloadPluginDetails(void) { + if (m_AllocatedControllers) + { + for (int32_t count = 0; count < sizeof(m_Controllers) / sizeof(m_Controllers[0]); count++) + { + delete m_Controllers[count]; + m_Controllers[count] = NULL; + } + } - if (m_AllocatedControllers) - { - for (int count = 0; count < sizeof(m_Controllers) / sizeof(m_Controllers[0]); count++) - { - delete m_Controllers[count]; - m_Controllers[count] = NULL; - } - } - - m_AllocatedControllers = false; - ControllerCommand = NULL; - GetKeys = NULL; - ReadController = NULL; - WM_KeyDown = NULL; - WM_KeyUp = NULL; + m_AllocatedControllers = false; + ControllerCommand = NULL; + GetKeys = NULL; + ReadController = NULL; + WM_KeyDown = NULL; + WM_KeyUp = NULL; } -void CControl_Plugin::UpdateKeys (void) +void CControl_Plugin::UpdateKeys(void) { - if (!m_AllocatedControllers) { return; } - for (int cont = 0; cont < sizeof(m_Controllers) / sizeof(m_Controllers[0]); cont++) - { - if (!m_Controllers[cont]->m_Present) { continue; } - if (!m_Controllers[cont]->m_RawData) { - GetKeys(cont,&m_Controllers[cont]->m_Buttons); - } else { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } - if (ReadController) { ReadController(-1, NULL); } + if (!m_AllocatedControllers) { return; } + for (int32_t cont = 0; cont < sizeof(m_Controllers) / sizeof(m_Controllers[0]); cont++) + { + if (!m_Controllers[cont]->m_Present) { continue; } + if (!m_Controllers[cont]->m_RawData) + { + GetKeys(cont, &m_Controllers[cont]->m_Buttons); + } + else + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } + if (ReadController) { ReadController(-1, NULL); } } void CControl_Plugin::SetControl(CControl_Plugin const * const Plugin) { - if (m_AllocatedControllers) { - for (int count = 0; count < sizeof(m_Controllers) / sizeof(m_Controllers[0]); count++) { - delete m_Controllers[count]; - m_Controllers[count] = NULL; - } - } - m_AllocatedControllers = false; - for (int count = 0; count < sizeof(m_Controllers) / sizeof(m_Controllers[0]); count++) { - m_Controllers[count] = Plugin->m_Controllers[count]; - } + if (m_AllocatedControllers) + { + for (int32_t count = 0; count < sizeof(m_Controllers) / sizeof(m_Controllers[0]); count++) + { + delete m_Controllers[count]; + m_Controllers[count] = NULL; + } + } + m_AllocatedControllers = false; + for (int32_t count = 0; count < sizeof(m_Controllers) / sizeof(m_Controllers[0]); count++) + { + m_Controllers[count] = Plugin->m_Controllers[count]; + } } -CCONTROL::CCONTROL(DWORD &Present, DWORD &RawData, int &PlugType) : -m_Present(Present), m_RawData(RawData), m_PlugType(PlugType) +CCONTROL::CCONTROL(uint32_t &Present, uint32_t &RawData, int32_t &PlugType) : + m_Present(Present), m_RawData(RawData), m_PlugType(PlugType) { - m_Buttons.Value = 0; + m_Buttons.Value = 0; } diff --git a/Source/Project64/Plugins/Controller Plugin.h b/Source/Project64/Plugins/Controller Plugin.h index 648e99e82..b8cf32595 100644 --- a/Source/Project64/Plugins/Controller Plugin.h +++ b/Source/Project64/Plugins/Controller Plugin.h @@ -10,95 +10,110 @@ ****************************************************************************/ #pragma once -typedef union { - DWORD Value; - struct { - unsigned R_DPAD : 1; - unsigned L_DPAD : 1; - unsigned D_DPAD : 1; - unsigned U_DPAD : 1; - unsigned START_BUTTON : 1; - unsigned Z_TRIG : 1; - unsigned B_BUTTON : 1; - unsigned A_BUTTON : 1; +#pragma warning(push) +#pragma warning(disable : 4201) // warning C4201: nonstandard extension used : nameless struct/union - unsigned R_CBUTTON : 1; - unsigned L_CBUTTON : 1; - unsigned D_CBUTTON : 1; - unsigned U_CBUTTON : 1; - unsigned R_TRIG : 1; - unsigned L_TRIG : 1; - unsigned Reserved1 : 1; - unsigned Reserved2 : 1; +typedef union +{ + uint32_t Value; + struct + { + unsigned R_DPAD : 1; + unsigned L_DPAD : 1; + unsigned D_DPAD : 1; + unsigned U_DPAD : 1; + unsigned START_BUTTON : 1; + unsigned Z_TRIG : 1; + unsigned B_BUTTON : 1; + unsigned A_BUTTON : 1; - signed Y_AXIS : 8; + unsigned R_CBUTTON : 1; + unsigned L_CBUTTON : 1; + unsigned D_CBUTTON : 1; + unsigned U_CBUTTON : 1; + unsigned R_TRIG : 1; + unsigned L_TRIG : 1; + unsigned Reserved1 : 1; + unsigned Reserved2 : 1; - signed X_AXIS : 8; - }; + signed Y_AXIS : 8; + + signed X_AXIS : 8; + }; } BUTTONS; +#pragma warning(pop) -typedef struct { - DWORD Present; - DWORD RawData; - int Plugin; +typedef struct +{ + uint32_t Present; + uint32_t RawData; + int32_t Plugin; } CONTROL; -enum PluginType { - PLUGIN_NONE = 1, - PLUGIN_MEMPAK = 2, - PLUGIN_RUMBLE_PAK = 3, - PLUGIN_TANSFER_PAK = 4, // not implemeted for non raw data - PLUGIN_RAW = 5, // the controller plugin is passed in raw data +enum PluginType +{ + PLUGIN_NONE = 1, + PLUGIN_MEMPAK = 2, + PLUGIN_RUMBLE_PAK = 3, + PLUGIN_TANSFER_PAK = 4, // not implemeted for non raw data + PLUGIN_RAW = 5, // the controller plugin is passed in raw data }; -class CCONTROL { - friend CControl_Plugin; //controller plugin class has full access - - DWORD & m_Present; - DWORD & m_RawData; - int & m_PlugType; - BUTTONS m_Buttons; +class CControl_Plugin; +class CCONTROL +{ public: - CCONTROL(DWORD &Present, DWORD &RawData, int &PlugType); - inline bool Present(void) const { return m_Present != 0; } - inline DWORD Buttons(void) const { return m_Buttons.Value; } - inline PluginType Plugin(void) const { return static_cast(m_PlugType); } + CCONTROL(uint32_t &Present, uint32_t &RawData, int32_t &PlugType); + inline bool Present(void) const { return m_Present != 0; } + inline uint32_t Buttons(void) const { return m_Buttons.Value; } + inline PluginType Plugin(void) const { return static_cast(m_PlugType); } +private: + friend CControl_Plugin; //controller plugin class has full access + + uint32_t & m_Present; + uint32_t & m_RawData; + int32_t & m_PlugType; + BUTTONS m_Buttons; + + CCONTROL(void); // Disable default constructor + CCONTROL(const CCONTROL&); // Disable copy constructor + CCONTROL& operator=(const CCONTROL&); // Disable assignment }; class CControl_Plugin : public CPlugin { public: - CControl_Plugin(void); - ~CControl_Plugin(); + CControl_Plugin(void); + ~CControl_Plugin(); bool Initiate(CN64System * System, CMainGui * RenderWindow); - void SetControl(CControl_Plugin const * const Plugin); - void UpdateKeys(void); + void SetControl(CControl_Plugin const * const Plugin); + void UpdateKeys(void); - void(__cdecl *WM_KeyDown) (DWORD wParam, DWORD lParam); - void(__cdecl *WM_KeyUp) (DWORD wParam, DWORD lParam); - void(__cdecl *RumbleCommand) (int Control, BOOL bRumble); - void(__cdecl *GetKeys) (int Control, BUTTONS * Keys); - void(__cdecl *ReadController) (int Control, BYTE * Command); - void(__cdecl *ControllerCommand)(int Control, BYTE * Command); + void(__cdecl *WM_KeyDown) (uint32_t wParam, uint32_t lParam); + void(__cdecl *WM_KeyUp) (uint32_t wParam, uint32_t lParam); + void(__cdecl *RumbleCommand) (int32_t Control, int32_t bRumble); + void(__cdecl *GetKeys) (int32_t Control, BUTTONS * Keys); + void(__cdecl *ReadController) (int32_t Control, uint8_t * Command); + void(__cdecl *ControllerCommand)(int32_t Control, uint8_t * Command); - inline CCONTROL const * Controller(int control) { return m_Controllers[control]; } - inline CONTROL * PluginControllers(void) { return m_PluginControllers; } + inline CCONTROL const * Controller(int32_t control) { return m_Controllers[control]; } + inline CONTROL * PluginControllers(void) { return m_PluginControllers; } private: - CControl_Plugin(const CControl_Plugin&); // Disable copy constructor - CControl_Plugin& operator=(const CControl_Plugin&); // Disable assignment + CControl_Plugin(const CControl_Plugin&); // Disable copy constructor + CControl_Plugin& operator=(const CControl_Plugin&); // Disable assignment - virtual int GetDefaultSettingStartRange() const { return FirstCtrlDefaultSet; } - virtual int GetSettingStartRange() const { return FirstCtrlSettings; } - PLUGIN_TYPE type() { return PLUGIN_TYPE_CONTROLLER; } - bool LoadFunctions ( void ); - void UnloadPluginDetails ( void ); + virtual int32_t GetDefaultSettingStartRange() const { return FirstCtrlDefaultSet; } + virtual int32_t GetSettingStartRange() const { return FirstCtrlSettings; } + PLUGIN_TYPE type() { return PLUGIN_TYPE_CONTROLLER; } + bool LoadFunctions(void); + void UnloadPluginDetails(void); - bool m_AllocatedControllers; + bool m_AllocatedControllers; - // What the different controls are set up as - CONTROL m_PluginControllers[4]; - CCONTROL * m_Controllers[4]; + // What the different controls are set up as + CONTROL m_PluginControllers[4]; + CCONTROL * m_Controllers[4]; }; diff --git a/Source/Project64/Plugins/GFX plugin.cpp b/Source/Project64/Plugins/GFX plugin.cpp index 771af44ee..4dcd9f148 100644 --- a/Source/Project64/Plugins/GFX plugin.cpp +++ b/Source/Project64/Plugins/GFX plugin.cpp @@ -10,250 +10,254 @@ ****************************************************************************/ #include "stdafx.h" -CGfxPlugin::CGfxPlugin() : - CaptureScreen(NULL), - ChangeWindow(NULL), - DrawScreen(NULL), - DrawStatus(NULL), - MoveScreen(NULL), - ProcessDList(NULL), - ProcessRDPList(NULL), - ShowCFB(NULL), - UpdateScreen(NULL), - ViStatusChanged(NULL), - ViWidthChanged(NULL), - SoftReset(NULL), - GetRomBrowserMenu(NULL), - OnRomBrowserMenuItem(NULL), - GetDebugInfo(NULL), - InitiateDebugger(NULL) +CGfxPlugin::CGfxPlugin() : + CaptureScreen(NULL), + ChangeWindow(NULL), + DrawScreen(NULL), + DrawStatus(NULL), + MoveScreen(NULL), + ProcessDList(NULL), + ProcessRDPList(NULL), + ShowCFB(NULL), + UpdateScreen(NULL), + ViStatusChanged(NULL), + ViWidthChanged(NULL), + SoftReset(NULL), + GetRomBrowserMenu(NULL), + OnRomBrowserMenuItem(NULL), + GetDebugInfo(NULL), + InitiateDebugger(NULL) { - memset(&m_GFXDebug, 0, sizeof(m_GFXDebug)); + memset(&m_GFXDebug, 0, sizeof(m_GFXDebug)); } CGfxPlugin::~CGfxPlugin() { - Close(); - UnloadPlugin(); + Close(); + UnloadPlugin(); } -bool CGfxPlugin::LoadFunctions ( void ) +bool CGfxPlugin::LoadFunctions(void) { - // Find entries for functions in DLL - BOOL (__cdecl *InitiateGFX) ( void * Gfx_Info ); - LoadFunction(InitiateGFX); - LoadFunction(ChangeWindow); - LoadFunction(DrawScreen); - LoadFunction(MoveScreen); - LoadFunction(ProcessDList); - LoadFunction(UpdateScreen); - LoadFunction(ViStatusChanged); - LoadFunction(ViWidthChanged); - LoadFunction(SoftReset); + // Find entries for functions in DLL + int32_t(__cdecl *InitiateGFX) (void * Gfx_Info); + LoadFunction(InitiateGFX); + LoadFunction(ChangeWindow); + LoadFunction(DrawScreen); + LoadFunction(MoveScreen); + LoadFunction(ProcessDList); + LoadFunction(UpdateScreen); + LoadFunction(ViStatusChanged); + LoadFunction(ViWidthChanged); + LoadFunction(SoftReset); - // version 0x104 functions - _LoadFunction("DrawFullScreenStatus", DrawStatus); + // version 0x104 functions + _LoadFunction("DrawFullScreenStatus", DrawStatus); - // Rom Browser - LoadFunction(GetRomBrowserMenu); - LoadFunction(OnRomBrowserMenuItem); + // Rom Browser + LoadFunction(GetRomBrowserMenu); + LoadFunction(OnRomBrowserMenuItem); - //Make sure dll had all needed functions - if (ChangeWindow == NULL) { UnloadPlugin(); return false; } - if (DrawScreen == NULL) { DrawScreen = DummyDrawScreen; } - if (InitiateGFX == NULL) { UnloadPlugin(); return false; } - if (MoveScreen == NULL) { MoveScreen = DummyMoveScreen; } - if (ProcessDList == NULL) { UnloadPlugin(); return false; } - if (UpdateScreen == NULL) { UnloadPlugin(); return false; } - if (ViStatusChanged == NULL) { ViStatusChanged = DummyViStatusChanged; } - if (ViWidthChanged == NULL) { ViWidthChanged = DummyViWidthChanged; } - if (SoftReset == NULL) { SoftReset = DummySoftReset; } + //Make sure dll had all needed functions + if (ChangeWindow == NULL) { UnloadPlugin(); return false; } + if (DrawScreen == NULL) { DrawScreen = DummyDrawScreen; } + if (InitiateGFX == NULL) { UnloadPlugin(); return false; } + if (MoveScreen == NULL) { MoveScreen = DummyMoveScreen; } + if (ProcessDList == NULL) { UnloadPlugin(); return false; } + if (UpdateScreen == NULL) { UnloadPlugin(); return false; } + if (ViStatusChanged == NULL) { ViStatusChanged = DummyViStatusChanged; } + if (ViWidthChanged == NULL) { ViWidthChanged = DummyViWidthChanged; } + if (SoftReset == NULL) { SoftReset = DummySoftReset; } - if (m_PluginInfo.Version >= 0x0103) - { - LoadFunction(ProcessRDPList); - LoadFunction(CaptureScreen); - LoadFunction(ShowCFB); - LoadFunction(GetDebugInfo); - _LoadFunction("InitiateGFXDebugger", InitiateDebugger); + if (m_PluginInfo.Version >= 0x0103) + { + LoadFunction(ProcessRDPList); + LoadFunction(CaptureScreen); + LoadFunction(ShowCFB); + LoadFunction(GetDebugInfo); + _LoadFunction("InitiateGFXDebugger", InitiateDebugger); - if (ProcessRDPList == NULL) { UnloadPlugin(); return false; } - if (CaptureScreen == NULL) { UnloadPlugin(); return false; } - if (ShowCFB == NULL) { UnloadPlugin(); return false; } - } + if (ProcessRDPList == NULL) { UnloadPlugin(); return false; } + if (CaptureScreen == NULL) { UnloadPlugin(); return false; } + if (ShowCFB == NULL) { UnloadPlugin(); return false; } + } - if (m_PluginInfo.Version >= 0x0104) - { - if (PluginOpened == NULL) { UnloadPlugin(); return false; } - } + if (m_PluginInfo.Version >= 0x0104) + { + if (PluginOpened == NULL) { UnloadPlugin(); return false; } + } - if (GetDebugInfo != NULL) - GetDebugInfo(&m_GFXDebug); + if (GetDebugInfo != NULL) + GetDebugInfo(&m_GFXDebug); - return true; + return true; } bool CGfxPlugin::Initiate(CN64System * System, CMainGui * RenderWindow) { - if (m_Initialized) - Close(); + if (m_Initialized) + { + Close(); + } - typedef struct { - HWND hWnd; /* Render window */ - HWND hStatusBar; /* if render window does not have a status bar then this is NULL */ + typedef struct + { + HWND hWnd; /* Render window */ + HWND hStatusBar; /* if render window does not have a status bar then this is NULL */ - BOOL MemoryBswaped; // If this is set to TRUE, then the memory has been pre - // bswap on a dword (32 bits) boundry - // eg. the first 8 bytes are stored like this: - // 4 3 2 1 8 7 6 5 + int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre + // bswap on a dword (32 bits) boundry + // eg. the first 8 bytes are stored like this: + // 4 3 2 1 8 7 6 5 - BYTE * HEADER; // This is the rom header (first 40h bytes of the rom - // This will be in the same memory format as the rest of the memory. - BYTE * RDRAM; - BYTE * DMEM; - BYTE * IMEM; + uint8_t * HEADER; // This is the rom header (first 40h bytes of the rom + // This will be in the same memory format as the rest of the memory. + uint8_t * RDRAM; + uint8_t * DMEM; + uint8_t * IMEM; - DWORD * MI__INTR_REG; + uint32_t * MI__INTR_REG; - DWORD * DPC__START_REG; - DWORD * DPC__END_REG; - DWORD * DPC__CURRENT_REG; - DWORD * DPC__STATUS_REG; - DWORD * DPC__CLOCK_REG; - DWORD * DPC__BUFBUSY_REG; - DWORD * DPC__PIPEBUSY_REG; - DWORD * DPC__TMEM_REG; + uint32_t * DPC__START_REG; + uint32_t * DPC__END_REG; + uint32_t * DPC__CURRENT_REG; + uint32_t * DPC__STATUS_REG; + uint32_t * DPC__CLOCK_REG; + uint32_t * DPC__BUFBUSY_REG; + uint32_t * DPC__PIPEBUSY_REG; + uint32_t * DPC__TMEM_REG; - DWORD * VI__STATUS_REG; - DWORD * VI__ORIGIN_REG; - DWORD * VI__WIDTH_REG; - DWORD * VI__INTR_REG; - DWORD * VI__V_CURRENT_LINE_REG; - DWORD * VI__TIMING_REG; - DWORD * VI__V_SYNC_REG; - DWORD * VI__H_SYNC_REG; - DWORD * VI__LEAP_REG; - DWORD * VI__H_START_REG; - DWORD * VI__V_START_REG; - DWORD * VI__V_BURST_REG; - DWORD * VI__X_SCALE_REG; - DWORD * VI__Y_SCALE_REG; + uint32_t * VI__STATUS_REG; + uint32_t * VI__ORIGIN_REG; + uint32_t * VI__WIDTH_REG; + uint32_t * VI__INTR_REG; + uint32_t * VI__V_CURRENT_LINE_REG; + uint32_t * VI__TIMING_REG; + uint32_t * VI__V_SYNC_REG; + uint32_t * VI__H_SYNC_REG; + uint32_t * VI__LEAP_REG; + uint32_t * VI__H_START_REG; + uint32_t * VI__V_START_REG; + uint32_t * VI__V_BURST_REG; + uint32_t * VI__X_SCALE_REG; + uint32_t * VI__Y_SCALE_REG; - void (__cdecl *CheckInterrupts)( void ); - } GFX_INFO; + void(__cdecl *CheckInterrupts)(void); + } GFX_INFO; - //Get Function from DLL - BOOL (__cdecl *InitiateGFX)( GFX_INFO Gfx_Info ); - InitiateGFX = (BOOL (__cdecl *)(GFX_INFO))GetProcAddress( (HMODULE)m_hDll, "InitiateGFX" ); - if (InitiateGFX == NULL) { return false; } + //Get Function from DLL + int32_t(__cdecl *InitiateGFX)(GFX_INFO Gfx_Info); + InitiateGFX = (int32_t(__cdecl *)(GFX_INFO))GetProcAddress((HMODULE)m_hDll, "InitiateGFX"); + if (InitiateGFX == NULL) { return false; } - GFX_INFO Info = { 0 }; + GFX_INFO Info = { 0 }; - Info.MemoryBswaped = TRUE; + Info.MemoryBswaped = TRUE; Info.hWnd = (HWND)RenderWindow->m_hMainWindow; Info.hStatusBar = (HWND)RenderWindow->m_hStatusWnd; - Info.CheckInterrupts = DummyCheckInterrupts; + Info.CheckInterrupts = DummyCheckInterrupts; - // We are initializing the plugin before any rom is loaded so we do not have any correct - // parameters here.. it's just needed so we can config the DLL. - if (System == NULL) - { - BYTE Buffer[100]; - DWORD Value = 0; + // We are initializing the plugin before any rom is loaded so we do not have any correct + // parameters here.. it's just needed so we can config the DLL. + if (System == NULL) + { + uint8_t Buffer[100]; + uint32_t Value = 0; - Info.HEADER = Buffer; - Info.RDRAM = Buffer; - Info.DMEM = Buffer; - Info.IMEM = Buffer; - Info.MI__INTR_REG = &Value; - Info.VI__STATUS_REG = &Value; - Info.VI__ORIGIN_REG = &Value; - Info.VI__WIDTH_REG = &Value; - Info.VI__INTR_REG = &Value; - Info.VI__V_CURRENT_LINE_REG = &Value; - Info.VI__TIMING_REG = &Value; - Info.VI__V_SYNC_REG = &Value; - Info.VI__H_SYNC_REG = &Value; - Info.VI__LEAP_REG = &Value; - Info.VI__H_START_REG = &Value; - Info.VI__V_START_REG = &Value; - Info.VI__V_BURST_REG = &Value; - Info.VI__X_SCALE_REG = &Value; - Info.VI__Y_SCALE_REG = &Value; - } - // Send initialization information to the DLL - else - { - Info.HEADER = g_Rom->GetRomAddress(); - Info.RDRAM = g_MMU->Rdram(); - Info.DMEM = g_MMU->Dmem(); - Info.IMEM = g_MMU->Imem(); - Info.MI__INTR_REG = &g_Reg->m_GfxIntrReg; - Info.DPC__START_REG = &g_Reg->DPC_START_REG; - Info.DPC__END_REG = &g_Reg->DPC_END_REG; - Info.DPC__CURRENT_REG = &g_Reg->DPC_CURRENT_REG; - Info.DPC__STATUS_REG = &g_Reg->DPC_STATUS_REG; - Info.DPC__CLOCK_REG = &g_Reg->DPC_CLOCK_REG; - Info.DPC__BUFBUSY_REG = &g_Reg->DPC_BUFBUSY_REG; - Info.DPC__PIPEBUSY_REG = &g_Reg->DPC_PIPEBUSY_REG; - Info.DPC__TMEM_REG = &g_Reg->DPC_TMEM_REG; - Info.VI__STATUS_REG = &g_Reg->VI_STATUS_REG; - Info.VI__ORIGIN_REG = &g_Reg->VI_ORIGIN_REG; - Info.VI__WIDTH_REG = &g_Reg->VI_WIDTH_REG; - Info.VI__INTR_REG = &g_Reg->VI_INTR_REG; - Info.VI__V_CURRENT_LINE_REG = &g_Reg->VI_CURRENT_REG; - Info.VI__TIMING_REG = &g_Reg->VI_TIMING_REG; - Info.VI__V_SYNC_REG = &g_Reg->VI_V_SYNC_REG; - Info.VI__H_SYNC_REG = &g_Reg->VI_H_SYNC_REG; - Info.VI__LEAP_REG = &g_Reg->VI_LEAP_REG; - Info.VI__H_START_REG = &g_Reg->VI_H_START_REG; - Info.VI__V_START_REG = &g_Reg->VI_V_START_REG; - Info.VI__V_BURST_REG = &g_Reg->VI_V_BURST_REG; - Info.VI__X_SCALE_REG = &g_Reg->VI_X_SCALE_REG; - Info.VI__Y_SCALE_REG = &g_Reg->VI_Y_SCALE_REG; - } + Info.HEADER = Buffer; + Info.RDRAM = Buffer; + Info.DMEM = Buffer; + Info.IMEM = Buffer; + Info.MI__INTR_REG = &Value; + Info.VI__STATUS_REG = &Value; + Info.VI__ORIGIN_REG = &Value; + Info.VI__WIDTH_REG = &Value; + Info.VI__INTR_REG = &Value; + Info.VI__V_CURRENT_LINE_REG = &Value; + Info.VI__TIMING_REG = &Value; + Info.VI__V_SYNC_REG = &Value; + Info.VI__H_SYNC_REG = &Value; + Info.VI__LEAP_REG = &Value; + Info.VI__H_START_REG = &Value; + Info.VI__V_START_REG = &Value; + Info.VI__V_BURST_REG = &Value; + Info.VI__X_SCALE_REG = &Value; + Info.VI__Y_SCALE_REG = &Value; + } + // Send initialization information to the DLL + else + { + Info.HEADER = g_Rom->GetRomAddress(); + Info.RDRAM = g_MMU->Rdram(); + Info.DMEM = g_MMU->Dmem(); + Info.IMEM = g_MMU->Imem(); + Info.MI__INTR_REG = (uint32_t *)&g_Reg->m_GfxIntrReg; + Info.DPC__START_REG = (uint32_t *)&g_Reg->DPC_START_REG; + Info.DPC__END_REG = (uint32_t *)&g_Reg->DPC_END_REG; + Info.DPC__CURRENT_REG = (uint32_t *)&g_Reg->DPC_CURRENT_REG; + Info.DPC__STATUS_REG = (uint32_t *)&g_Reg->DPC_STATUS_REG; + Info.DPC__CLOCK_REG = (uint32_t *)&g_Reg->DPC_CLOCK_REG; + Info.DPC__BUFBUSY_REG = (uint32_t *)&g_Reg->DPC_BUFBUSY_REG; + Info.DPC__PIPEBUSY_REG = (uint32_t *)&g_Reg->DPC_PIPEBUSY_REG; + Info.DPC__TMEM_REG = (uint32_t *)&g_Reg->DPC_TMEM_REG; + Info.VI__STATUS_REG = (uint32_t *)&g_Reg->VI_STATUS_REG; + Info.VI__ORIGIN_REG = (uint32_t *)&g_Reg->VI_ORIGIN_REG; + Info.VI__WIDTH_REG = (uint32_t *)&g_Reg->VI_WIDTH_REG; + Info.VI__INTR_REG = (uint32_t *)&g_Reg->VI_INTR_REG; + Info.VI__V_CURRENT_LINE_REG = (uint32_t *)&g_Reg->VI_CURRENT_REG; + Info.VI__TIMING_REG = (uint32_t *)&g_Reg->VI_TIMING_REG; + Info.VI__V_SYNC_REG = (uint32_t *)&g_Reg->VI_V_SYNC_REG; + Info.VI__H_SYNC_REG = (uint32_t *)&g_Reg->VI_H_SYNC_REG; + Info.VI__LEAP_REG = (uint32_t *)&g_Reg->VI_LEAP_REG; + Info.VI__H_START_REG = (uint32_t *)&g_Reg->VI_H_START_REG; + Info.VI__V_START_REG = (uint32_t *)&g_Reg->VI_V_START_REG; + Info.VI__V_BURST_REG = (uint32_t *)&g_Reg->VI_V_BURST_REG; + Info.VI__X_SCALE_REG = (uint32_t *)&g_Reg->VI_X_SCALE_REG; + Info.VI__Y_SCALE_REG = (uint32_t *)&g_Reg->VI_Y_SCALE_REG; + } - m_Initialized = InitiateGFX(Info) != 0; + m_Initialized = InitiateGFX(Info) != 0; - //jabo had a bug so I call CreateThread so his dllmain gets called again - DWORD ThreadID; - HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID); - CloseHandle(hthread); + //jabo had a bug so I call CreateThread so his dllmain gets called again + DWORD ThreadID; + HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID); + CloseHandle(hthread); - return m_Initialized; + return m_Initialized; } void CGfxPlugin::UnloadPluginDetails(void) { - if (m_hDll != NULL ) { - FreeLibrary((HMODULE)m_hDll); - m_hDll = NULL; - } - memset(&m_GFXDebug, 0, sizeof(m_GFXDebug)); + if (m_hDll != NULL) + { + FreeLibrary((HMODULE)m_hDll); + m_hDll = NULL; + } + memset(&m_GFXDebug, 0, sizeof(m_GFXDebug)); - // CaptureScreen = NULL; - ChangeWindow = NULL; - GetDebugInfo = NULL; - DrawScreen = NULL; - DrawStatus = NULL; - // FrameBufferRead = NULL; - // FrameBufferWrite = NULL; - InitiateDebugger = NULL; - MoveScreen = NULL; - ProcessDList = NULL; - ProcessRDPList = NULL; - ShowCFB = NULL; - UpdateScreen = NULL; - ViStatusChanged = NULL; - ViWidthChanged = NULL; - GetRomBrowserMenu = NULL; - OnRomBrowserMenuItem = NULL; + // CaptureScreen = NULL; + ChangeWindow = NULL; + GetDebugInfo = NULL; + DrawScreen = NULL; + DrawStatus = NULL; + // FrameBufferRead = NULL; + // FrameBufferWrite = NULL; + InitiateDebugger = NULL; + MoveScreen = NULL; + ProcessDList = NULL; + ProcessRDPList = NULL; + ShowCFB = NULL; + UpdateScreen = NULL; + ViStatusChanged = NULL; + ViWidthChanged = NULL; + GetRomBrowserMenu = NULL; + OnRomBrowserMenuItem = NULL; } -void CGfxPlugin::ProcessMenuItem(int id) +void CGfxPlugin::ProcessMenuItem(int32_t id) { - if (m_GFXDebug.ProcessMenuItem) - { - m_GFXDebug.ProcessMenuItem(id); - } + if (m_GFXDebug.ProcessMenuItem) + { + m_GFXDebug.ProcessMenuItem(id); + } } diff --git a/Source/Project64/Plugins/GFX plugin.h b/Source/Project64/Plugins/GFX plugin.h index 9ef632935..01f3b71c0 100644 --- a/Source/Project64/Plugins/GFX plugin.h +++ b/Source/Project64/Plugins/GFX plugin.h @@ -12,84 +12,86 @@ class CGfxPlugin : public CPlugin { - typedef struct { - /* Menu */ - /* Items should have an ID between 5101 and 5200 */ - HMENU hGFXMenu; - void(__cdecl *ProcessMenuItem) (int ID); + typedef struct + { + /* Menu */ + /* Items should have an ID between 5101 and 5200 */ + void * hGFXMenu; + void(__cdecl *ProcessMenuItem) (int32_t ID); - /* Break Points */ - BOOL UseBPoints; - char BPPanelName[20]; - void(__cdecl *Add_BPoint) (void); - void(__cdecl *CreateBPPanel) (HWND hDlg, RECT_STRUCT rcBox); - void(__cdecl *HideBPPanel) (void); - void(__cdecl *PaintBPPanel) (WINDOWS_PAINTSTRUCT ps); - void(__cdecl *ShowBPPanel) (void); - void(__cdecl *RefreshBpoints) (HWND hList); - void(__cdecl *RemoveBpoint) (HWND hList, int index); - void(__cdecl *RemoveAllBpoint) (void); + /* Break Points */ + int32_t UseBPoints; + char BPPanelName[20]; + void(__cdecl *Add_BPoint) (void); + void(__cdecl *CreateBPPanel) (void * hDlg, void * rcBox); + void(__cdecl *HideBPPanel) (void); + void(__cdecl *PaintBPPanel) (void * ps); + void(__cdecl *ShowBPPanel) (void); + void(__cdecl *RefreshBpoints) (void * hList); + void(__cdecl *RemoveBpoint) (void * hList, int32_t index); + void(__cdecl *RemoveAllBpoint) (void); - /* GFX command Window */ - void(__cdecl *Enter_GFX_Commands_Window) (void); - } GFXDEBUG_INFO; + /* GFX command Window */ + void(__cdecl *Enter_GFX_Commands_Window) (void); + } GFXDEBUG_INFO; - typedef struct { - void(__cdecl *UpdateBreakPoints)(void); - void(__cdecl *UpdateMemory)(void); - void(__cdecl *UpdateR4300iRegisters)(void); - void(__cdecl *Enter_BPoint_Window)(void); - void(__cdecl *Enter_R4300i_Commands_Window)(void); - void(__cdecl *Enter_R4300i_Register_Window)(void); - void(__cdecl *Enter_RSP_Commands_Window) (void); - void(__cdecl *Enter_Memory_Window)(void); - } DEBUG_INFO; + typedef struct + { + void(__cdecl *UpdateBreakPoints)(void); + void(__cdecl *UpdateMemory)(void); + void(__cdecl *UpdateR4300iRegisters)(void); + void(__cdecl *Enter_BPoint_Window)(void); + void(__cdecl *Enter_R4300i_Commands_Window)(void); + void(__cdecl *Enter_R4300i_Register_Window)(void); + void(__cdecl *Enter_RSP_Commands_Window) (void); + void(__cdecl *Enter_Memory_Window)(void); + } DEBUG_INFO; public: - CGfxPlugin(void); - ~CGfxPlugin(); + CGfxPlugin(void); + ~CGfxPlugin(); - bool LoadFunctions ( void ); + bool LoadFunctions(void); bool Initiate(CN64System * System, CMainGui * RenderWindow); - void(__cdecl *CaptureScreen) (const char *); - void(__cdecl *ChangeWindow) (void); - void(__cdecl *DrawScreen) (void); - void(__cdecl *DrawStatus) (const char * lpString, BOOL RightAlign); - void(__cdecl *MoveScreen) (int xpos, int ypos); - void(__cdecl *ProcessDList) (void); - void(__cdecl *ProcessRDPList) (void); - void(__cdecl *ShowCFB) (void); - void(__cdecl *UpdateScreen) (void); - void(__cdecl *ViStatusChanged) (void); - void(__cdecl *ViWidthChanged) (void); - void(__cdecl *SoftReset) (void); + void(__cdecl *CaptureScreen) (const char *); + void(__cdecl *ChangeWindow) (void); + void(__cdecl *DrawScreen) (void); + void(__cdecl *DrawStatus) (const char * lpString, int32_t RightAlign); + void(__cdecl *MoveScreen) (int32_t xpos, int32_t ypos); + void(__cdecl *ProcessDList) (void); + void(__cdecl *ProcessRDPList) (void); + void(__cdecl *ShowCFB) (void); + void(__cdecl *UpdateScreen) (void); + void(__cdecl *ViStatusChanged) (void); + void(__cdecl *ViWidthChanged) (void); + void(__cdecl *SoftReset) (void); - //Rom Browser - HMENU(__cdecl * GetRomBrowserMenu) (void); /* Items should have an ID between 4101 and 4200 */ - void(__cdecl * OnRomBrowserMenuItem) (int MenuID, HWND hParent, BYTE * HEADER); + //Rom Browser + void *(__cdecl * GetRomBrowserMenu) (void); /* Items should have an ID between 4101 and 4200 */ + void(__cdecl * OnRomBrowserMenuItem) (int32_t MenuID, void * hParent, uint8_t * HEADER); - HMENU GetDebugMenu(void) { return m_GFXDebug.hGFXMenu; } - void ProcessMenuItem(int id); + void * GetDebugMenu(void) { return m_GFXDebug.hGFXMenu; } + void ProcessMenuItem(int32_t id); private: - CGfxPlugin(const CGfxPlugin&); // Disable copy constructor - CGfxPlugin& operator=(const CGfxPlugin&); // Disable assignment + CGfxPlugin(const CGfxPlugin&); // Disable copy constructor + CGfxPlugin& operator=(const CGfxPlugin&); // Disable assignment - virtual int GetDefaultSettingStartRange() const { return FirstGfxDefaultSet; } - virtual int GetSettingStartRange() const { return FirstGfxSettings; } - PLUGIN_TYPE type() { return PLUGIN_TYPE_GFX; } + virtual int32_t GetDefaultSettingStartRange() const { return FirstGfxDefaultSet; } + virtual int32_t GetSettingStartRange() const { return FirstGfxSettings; } + PLUGIN_TYPE type() { return PLUGIN_TYPE_GFX; } - void UnloadPluginDetails ( void ); + void UnloadPluginDetails(void); - GFXDEBUG_INFO m_GFXDebug; + GFXDEBUG_INFO m_GFXDebug; - void(__cdecl *GetDebugInfo) (GFXDEBUG_INFO * GFXDebugInfo); - void(__cdecl *InitiateDebugger)(DEBUG_INFO DebugInfo); + void(__cdecl *GetDebugInfo) (GFXDEBUG_INFO * GFXDebugInfo); + void(__cdecl *InitiateDebugger)(DEBUG_INFO DebugInfo); - static void __cdecl DummyDrawScreen(void) {} - static void __cdecl DummyMoveScreen(int /*xpos*/, int /*ypos*/) {} - static void __cdecl DummyViStatusChanged(void) {} - static void __cdecl DummyViWidthChanged(void) {} - static void __cdecl DummySoftReset(void) {} + static void __cdecl DummyDrawScreen(void) {} + static void __cdecl DummyMoveScreen(int32_t /*xpos*/, int32_t /*ypos*/) {} + static void __cdecl DummyViStatusChanged(void) {} + static void __cdecl DummyViWidthChanged(void) {} + static void __cdecl DummySoftReset(void) {} }; \ No newline at end of file diff --git a/Source/Project64/Plugins/Plugin Base.cpp b/Source/Project64/Plugins/Plugin Base.cpp index 49a73dce0..0ff04e27b 100644 --- a/Source/Project64/Plugins/Plugin Base.cpp +++ b/Source/Project64/Plugins/Plugin Base.cpp @@ -11,214 +11,245 @@ #include "stdafx.h" CPlugin::CPlugin() : - DllAbout(NULL), - DllConfig(NULL), - CloseDLL(NULL), - RomOpen(NULL), - RomClosed(NULL), - PluginOpened(NULL), - SetSettingInfo(NULL), - SetSettingInfo2(NULL), - SetSettingInfo3(NULL), - m_hDll(NULL), - m_Initialized(false), - m_RomOpen(false) + DllAbout(NULL), + DllConfig(NULL), + CloseDLL(NULL), + RomOpen(NULL), + RomClosed(NULL), + PluginOpened(NULL), + SetSettingInfo(NULL), + SetSettingInfo2(NULL), + SetSettingInfo3(NULL), + m_hDll(NULL), + m_Initialized(false), + m_RomOpen(false) { - memset(&m_PluginInfo, 0, sizeof(m_PluginInfo)); + memset(&m_PluginInfo, 0, sizeof(m_PluginInfo)); } CPlugin::~CPlugin() { - UnloadPlugin(); + UnloadPlugin(); } bool CPlugin::Load (const char * FileName) { - // Already loaded, so unload first. - if (m_hDll != NULL) - { - UnloadPlugin(); - } + // Already loaded, so unload first. + if (m_hDll != NULL) + { + UnloadPlugin(); + } - // Try to load the plugin DLL - //Try to load the DLL library - if (bHaveDebugger()) - { - m_hDll = LoadLibrary(FileName); - } - else - { - UINT LastErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS); - m_hDll = LoadLibrary(FileName); - SetErrorMode(LastErrorMode); - } + // Try to load the plugin DLL + //Try to load the DLL library + if (bHaveDebugger()) + { + m_hDll = LoadLibrary(FileName); + } + else + { + UINT LastErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS); + m_hDll = LoadLibrary(FileName); + SetErrorMode(LastErrorMode); + } - if (m_hDll == NULL) - { - return false; - } + if (m_hDll == NULL) + { + return false; + } - // Get DLL information - void(__cdecl *GetDllInfo) (PLUGIN_INFO * PluginInfo); - LoadFunction(GetDllInfo); - if (GetDllInfo == NULL) { return false; } + // Get DLL information + void(__cdecl *GetDllInfo) (PLUGIN_INFO * PluginInfo); + LoadFunction(GetDllInfo); + if (GetDllInfo == NULL) { return false; } - GetDllInfo(&m_PluginInfo); - if (!CPluginList::ValidPluginVersion(m_PluginInfo)) { return false; } - if (m_PluginInfo.Type != type()) { return false; } + GetDllInfo(&m_PluginInfo); + if (!ValidPluginVersion(m_PluginInfo)) { return false; } + if (m_PluginInfo.Type != type()) { return false; } - CloseDLL = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "CloseDLL" ); - RomOpen = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "RomOpen" ); - RomClosed = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "RomClosed" ); - PluginOpened = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "PluginLoaded" ); - DllConfig = (void (__cdecl *)(DWORD)) GetProcAddress( (HMODULE)m_hDll, "DllConfig" ); - DllAbout = (void (__cdecl *)(HWND)) GetProcAddress( (HMODULE)m_hDll, "DllAbout" ); + CloseDLL = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "CloseDLL" ); + RomOpen = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "RomOpen" ); + RomClosed = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "RomClosed" ); + PluginOpened = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "PluginLoaded" ); + DllConfig = (void (__cdecl *)(uint32_t)) GetProcAddress( (HMODULE)m_hDll, "DllConfig" ); + DllAbout = (void (__cdecl *)(void *)) GetProcAddress( (HMODULE)m_hDll, "DllAbout" ); - SetSettingInfo3 = (void (__cdecl *)(PLUGIN_SETTINGS3 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo3" ); - if (SetSettingInfo3) - { - PLUGIN_SETTINGS3 info; - info.FlushSettings = (void (*)( void * handle))CSettings::FlushSettings; - SetSettingInfo3(&info); - } + SetSettingInfo3 = (void (__cdecl *)(PLUGIN_SETTINGS3 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo3" ); + if (SetSettingInfo3) + { + PLUGIN_SETTINGS3 info; + info.FlushSettings = (void (*)( void * handle))CSettings::FlushSettings; + SetSettingInfo3(&info); + } - SetSettingInfo2 = (void (__cdecl *)(PLUGIN_SETTINGS2 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo2" ); - if (SetSettingInfo2) - { - PLUGIN_SETTINGS2 info; - info.FindSystemSettingId = (unsigned int (*)( void * handle, const char * ))CSettings::FindSetting; - SetSettingInfo2(&info); - } + SetSettingInfo2 = (void (__cdecl *)(PLUGIN_SETTINGS2 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo2" ); + if (SetSettingInfo2) + { + PLUGIN_SETTINGS2 info; + info.FindSystemSettingId = (uint32_t (*)( void * handle, const char * ))CSettings::FindSetting; + SetSettingInfo2(&info); + } - SetSettingInfo = (void (__cdecl *)(PLUGIN_SETTINGS *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo" ); - if (SetSettingInfo) - { - PLUGIN_SETTINGS info; - info.dwSize = sizeof(PLUGIN_SETTINGS); - info.DefaultStartRange = GetDefaultSettingStartRange(); - info.SettingStartRange = GetSettingStartRange(); - info.MaximumSettings = MaxPluginSetting; - info.NoDefault = Default_None; - info.DefaultLocation = g_Settings->LoadDword(Setting_UseFromRegistry) ? SettingType_Registry : SettingType_CfgFile; - info.handle = g_Settings; - info.RegisterSetting = (void(*)(void *, int, int, SettingDataType, SettingType, const char *, const char *, DWORD))&CSettings::RegisterSetting; - info.GetSetting = (unsigned int(*)(void *, int))&CSettings::GetSetting; - info.GetSettingSz = (const char * (*)(void *, int, char *, int))&CSettings::GetSettingSz; - info.SetSetting = (void(*)(void *, int, unsigned int))&CSettings::SetSetting; - info.SetSettingSz = (void(*)(void *, int, const char *))&CSettings::SetSettingSz; - info.UseUnregisteredSetting = NULL; + SetSettingInfo = (void (__cdecl *)(PLUGIN_SETTINGS *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo" ); + if (SetSettingInfo) + { + PLUGIN_SETTINGS info; + info.dwSize = sizeof(PLUGIN_SETTINGS); + info.DefaultStartRange = GetDefaultSettingStartRange(); + info.SettingStartRange = GetSettingStartRange(); + info.MaximumSettings = MaxPluginSetting; + info.NoDefault = Default_None; + info.DefaultLocation = g_Settings->LoadDword(Setting_UseFromRegistry) ? SettingType_Registry : SettingType_CfgFile; + info.handle = g_Settings; + info.RegisterSetting = (void(*)(void *, int, int, SettingDataType, SettingType, const char *, const char *, uint32_t))&CSettings::RegisterSetting; + info.GetSetting = (uint32_t(*)(void *, int))&CSettings::GetSetting; + info.GetSettingSz = (const char * (*)(void *, int, char *, int))&CSettings::GetSettingSz; + info.SetSetting = (void(*)(void *, int, uint32_t))&CSettings::SetSetting; + info.SetSettingSz = (void(*)(void *, int, const char *))&CSettings::SetSettingSz; + info.UseUnregisteredSetting = NULL; - SetSettingInfo(&info); - } + SetSettingInfo(&info); + } - if (RomClosed == NULL) - return false; + if (RomClosed == NULL) + return false; - if (!LoadFunctions()) - { - return false; - } - WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Functions loaded",PluginType()); + if (!LoadFunctions()) + { + return false; + } + WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Functions loaded",PluginType()); - if (PluginOpened) - { - WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Before Plugin Opened",PluginType()); - PluginOpened(); - WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): After Plugin Opened",PluginType()); - } - return true; + if (PluginOpened) + { + WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Before Plugin Opened",PluginType()); + PluginOpened(); + WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): After Plugin Opened",PluginType()); + } + return true; } void CPlugin::RomOpened() { - if (m_RomOpen) - return; + if (m_RomOpen) + return; - if(RomOpen != NULL){ - WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Before Rom Open",PluginType()); - RomOpen(); - WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): After Rom Open",PluginType()); - } - m_RomOpen = true; + if(RomOpen != NULL){ + WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Before Rom Open",PluginType()); + RomOpen(); + WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): After Rom Open",PluginType()); + } + m_RomOpen = true; } void CPlugin::RomClose() { - if (!m_RomOpen) - return; + if (!m_RomOpen) + return; - WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Before Rom Close",PluginType()); - RomClosed(); - m_RomOpen = false; - WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): After Rom Close",PluginType()); + WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Before Rom Close",PluginType()); + RomClosed(); + m_RomOpen = false; + WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): After Rom Close",PluginType()); } void CPlugin::GameReset() { - if (m_RomOpen) - { - RomClose(); - if (RomOpen) - { - RomOpen(); - } - } + if (m_RomOpen) + { + RomClose(); + if (RomOpen) + { + RomOpen(); + } + } } void CPlugin::Close() { - WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Start",PluginType()); - RomClose(); - if (m_Initialized) - { - CloseDLL(); - m_Initialized = false; - } - WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Done",PluginType()); + WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Start",PluginType()); + RomClose(); + if (m_Initialized) + { + CloseDLL(); + m_Initialized = false; + } + WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): Done",PluginType()); } void CPlugin::UnloadPlugin() { - WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): unloading",PluginType()); - memset(&m_PluginInfo, 0, sizeof(m_PluginInfo)); - if (m_hDll != NULL) - { - UnloadPluginDetails(); - FreeLibrary((HMODULE)m_hDll); - m_hDll = NULL; - } + WriteTraceF(PluginTraceType(),__FUNCTION__ "(%s): unloading",PluginType()); + memset(&m_PluginInfo, 0, sizeof(m_PluginInfo)); + if (m_hDll != NULL) + { + UnloadPluginDetails(); + FreeLibrary((HMODULE)m_hDll); + m_hDll = NULL; + } - DllAbout = NULL; - CloseDLL = NULL; - RomOpen = NULL; - RomClosed = NULL; - PluginOpened = NULL; - DllConfig = NULL; - SetSettingInfo = NULL; - SetSettingInfo2 = NULL; - SetSettingInfo3 = NULL; + DllAbout = NULL; + CloseDLL = NULL; + RomOpen = NULL; + RomClosed = NULL; + PluginOpened = NULL; + DllConfig = NULL; + SetSettingInfo = NULL; + SetSettingInfo2 = NULL; + SetSettingInfo3 = NULL; } const char * CPlugin::PluginType () const { - switch (m_PluginInfo.Type) - { - case PLUGIN_TYPE_RSP: return "RSP"; - case PLUGIN_TYPE_GFX: return "GFX"; - case PLUGIN_TYPE_AUDIO: return "Audio"; - case PLUGIN_TYPE_CONTROLLER: return "Control"; - } - return "Unknown"; + switch (m_PluginInfo.Type) + { + case PLUGIN_TYPE_RSP: return "RSP"; + case PLUGIN_TYPE_GFX: return "GFX"; + case PLUGIN_TYPE_AUDIO: return "Audio"; + case PLUGIN_TYPE_CONTROLLER: return "Control"; + } + return "Unknown"; } TraceType CPlugin::PluginTraceType () const { - switch (m_PluginInfo.Type) - { - case PLUGIN_TYPE_RSP: return TraceRSP; - case PLUGIN_TYPE_GFX: return TraceGfxPlugin; - case PLUGIN_TYPE_AUDIO: return TraceDebug; - case PLUGIN_TYPE_CONTROLLER: return TraceDebug; - } - return TraceDebug; + switch (m_PluginInfo.Type) + { + case PLUGIN_TYPE_RSP: return TraceRSP; + case PLUGIN_TYPE_GFX: return TraceGfxPlugin; + case PLUGIN_TYPE_AUDIO: return TraceDebug; + case PLUGIN_TYPE_CONTROLLER: return TraceDebug; + } + return TraceDebug; +} + +bool CPlugin::ValidPluginVersion ( PLUGIN_INFO & PluginInfo ) +{ + switch (PluginInfo.Type) + { + case PLUGIN_TYPE_RSP: + if (!PluginInfo.MemoryBswaped) { return false; } + if (PluginInfo.Version == 0x0001) { return true; } + if (PluginInfo.Version == 0x0100) { return true; } + if (PluginInfo.Version == 0x0101) { return true; } + if (PluginInfo.Version == 0x0102) { return true; } + break; + case PLUGIN_TYPE_GFX: + if (!PluginInfo.MemoryBswaped) { return false; } + if (PluginInfo.Version == 0x0102) { return true; } + if (PluginInfo.Version == 0x0103) { return true; } + if (PluginInfo.Version == 0x0104) { return true; } + break; + case PLUGIN_TYPE_AUDIO: + if (!PluginInfo.MemoryBswaped) { return false; } + if (PluginInfo.Version == 0x0101) { return true; } + if (PluginInfo.Version == 0x0102) { return true; } + break; + case PLUGIN_TYPE_CONTROLLER: + if (PluginInfo.Version == 0x0100) { return true; } + if (PluginInfo.Version == 0x0101) { return true; } + if (PluginInfo.Version == 0x0102) { return true; } + break; + } + return FALSE; } diff --git a/Source/Project64/Plugins/Plugin Base.h b/Source/Project64/Plugins/Plugin Base.h index 0d5e92d4d..4eb295d4f 100644 --- a/Source/Project64/Plugins/Plugin Base.h +++ b/Source/Project64/Plugins/Plugin Base.h @@ -11,55 +11,56 @@ #pragma once class CPlugin : - private CDebugSettings + private CDebugSettings { public: - CPlugin(); - virtual ~CPlugin(); - inline const char * PluginName() const { return m_PluginInfo.Name; } - inline bool Initialized() { return m_Initialized; } + CPlugin(); + virtual ~CPlugin(); + inline const char * PluginName() const { return m_PluginInfo.Name; } + inline bool Initialized() { return m_Initialized; } - virtual int GetDefaultSettingStartRange() const = 0; - virtual int GetSettingStartRange() const = 0; + virtual int32_t GetDefaultSettingStartRange() const = 0; + virtual int32_t GetSettingStartRange() const = 0; - bool Load ( const char * FileName ); + bool Load(const char * FileName); - void RomOpened(); - void RomClose(); - void GameReset(); - void Close(); + void RomOpened(); + void RomClose(); + void GameReset(); + void Close(); - void(__cdecl *DllAbout) (HWND hWnd); - void(__cdecl *DllConfig) (DWORD hParent); + void(__cdecl *DllAbout) (void * hWnd); + void(__cdecl *DllConfig) (uint32_t hParent); + + static bool ValidPluginVersion ( PLUGIN_INFO & PluginInfo ); protected: + void UnloadPlugin(); + const char * PluginType() const; + TraceType PluginTraceType() const; + virtual void UnloadPluginDetails() = 0; + virtual PLUGIN_TYPE type() = 0; + virtual bool LoadFunctions(void) = 0; - void UnloadPlugin(); - const char * PluginType () const; - TraceType PluginTraceType () const; - virtual void UnloadPluginDetails() = 0; - virtual PLUGIN_TYPE type() = 0; - virtual bool LoadFunctions ( void ) = 0; + void(__cdecl *CloseDLL) (void); + void(__cdecl *RomOpen) (void); + void(__cdecl *RomClosed) (void); + void(__cdecl *PluginOpened)(void); + void(__cdecl *SetSettingInfo) (PLUGIN_SETTINGS *); + void(__cdecl *SetSettingInfo2) (PLUGIN_SETTINGS2 *); + void(__cdecl *SetSettingInfo3) (PLUGIN_SETTINGS3 *); - void(__cdecl *CloseDLL) (void); - void(__cdecl *RomOpen) (void); - void(__cdecl *RomClosed) (void); - void(__cdecl *PluginOpened)(void); - void(__cdecl *SetSettingInfo) (PLUGIN_SETTINGS *); - void(__cdecl *SetSettingInfo2) (PLUGIN_SETTINGS2 *); - void(__cdecl *SetSettingInfo3) (PLUGIN_SETTINGS3 *); + void * m_hDll; + bool m_Initialized, m_RomOpen; + PLUGIN_INFO m_PluginInfo; - void * m_hDll; - bool m_Initialized, m_RomOpen; - PLUGIN_INFO m_PluginInfo; + // Loads a function pointer from the currently loaded DLL + template + void _LoadFunction(const char * szFunctionName, T & functionPointer) { + functionPointer = (T)GetProcAddress((HMODULE)m_hDll, szFunctionName); + } - // Loads a function pointer from the currently loaded DLL - template - void _LoadFunction(const char * szFunctionName, T & functionPointer) { - functionPointer = (T)GetProcAddress((HMODULE)m_hDll, szFunctionName); - } - - // Simple wrapper around _LoadFunction() to avoid having to specify the same two arguments - // i.e. _LoadFunction("CloseDLL", CloseDLL); + // Simple wrapper around _LoadFunction() to avoid having to specify the same two arguments + // i.e. _LoadFunction("CloseDLL", CloseDLL); #define LoadFunction(functionName) _LoadFunction(#functionName, functionName) }; diff --git a/Source/Project64/Plugins/Plugin Class.cpp b/Source/Project64/Plugins/Plugin Class.cpp index e4f08c84a..6dfccc915 100644 --- a/Source/Project64/Plugins/Plugin Class.cpp +++ b/Source/Project64/Plugins/Plugin Class.cpp @@ -10,36 +10,39 @@ ****************************************************************************/ #include "stdafx.h" -CPlugins::CPlugins (const stdstr & PluginDir): +CPlugins::CPlugins(const stdstr & PluginDir) : m_RenderWindow(NULL), m_DummyWindow(NULL), - m_PluginDir(PluginDir), m_Gfx(NULL), m_Audio(NULL), - m_RSP(NULL), m_Control(NULL) +m_PluginDir(PluginDir), +m_Gfx(NULL), +m_Audio(NULL), +m_RSP(NULL), +m_Control(NULL) { CreatePlugins(); - g_Settings->RegisterChangeCB(Plugin_RSP_Current,this,(CSettings::SettingChangedFunc)PluginChanged); - g_Settings->RegisterChangeCB(Plugin_GFX_Current,this,(CSettings::SettingChangedFunc)PluginChanged); - g_Settings->RegisterChangeCB(Plugin_AUDIO_Current,this,(CSettings::SettingChangedFunc)PluginChanged); - g_Settings->RegisterChangeCB(Plugin_CONT_Current,this,(CSettings::SettingChangedFunc)PluginChanged); - g_Settings->RegisterChangeCB(Plugin_UseHleGfx,this,(CSettings::SettingChangedFunc)PluginChanged); - g_Settings->RegisterChangeCB(Plugin_UseHleAudio,this,(CSettings::SettingChangedFunc)PluginChanged); - g_Settings->RegisterChangeCB(Game_EditPlugin_Gfx,this,(CSettings::SettingChangedFunc)PluginChanged); - g_Settings->RegisterChangeCB(Game_EditPlugin_Audio,this,(CSettings::SettingChangedFunc)PluginChanged); - g_Settings->RegisterChangeCB(Game_EditPlugin_Contr,this,(CSettings::SettingChangedFunc)PluginChanged); - g_Settings->RegisterChangeCB(Game_EditPlugin_RSP,this,(CSettings::SettingChangedFunc)PluginChanged); + g_Settings->RegisterChangeCB(Plugin_RSP_Current, this, (CSettings::SettingChangedFunc)PluginChanged); + g_Settings->RegisterChangeCB(Plugin_GFX_Current, this, (CSettings::SettingChangedFunc)PluginChanged); + g_Settings->RegisterChangeCB(Plugin_AUDIO_Current, this, (CSettings::SettingChangedFunc)PluginChanged); + g_Settings->RegisterChangeCB(Plugin_CONT_Current, this, (CSettings::SettingChangedFunc)PluginChanged); + g_Settings->RegisterChangeCB(Plugin_UseHleGfx, this, (CSettings::SettingChangedFunc)PluginChanged); + g_Settings->RegisterChangeCB(Plugin_UseHleAudio, this, (CSettings::SettingChangedFunc)PluginChanged); + g_Settings->RegisterChangeCB(Game_EditPlugin_Gfx, this, (CSettings::SettingChangedFunc)PluginChanged); + g_Settings->RegisterChangeCB(Game_EditPlugin_Audio, this, (CSettings::SettingChangedFunc)PluginChanged); + g_Settings->RegisterChangeCB(Game_EditPlugin_Contr, this, (CSettings::SettingChangedFunc)PluginChanged); + g_Settings->RegisterChangeCB(Game_EditPlugin_RSP, this, (CSettings::SettingChangedFunc)PluginChanged); } -CPlugins::~CPlugins (void) +CPlugins::~CPlugins(void) { - g_Settings->UnregisterChangeCB(Plugin_RSP_Current,this,(CSettings::SettingChangedFunc)PluginChanged); - g_Settings->UnregisterChangeCB(Plugin_GFX_Current,this,(CSettings::SettingChangedFunc)PluginChanged); - g_Settings->UnregisterChangeCB(Plugin_AUDIO_Current,this,(CSettings::SettingChangedFunc)PluginChanged); - g_Settings->UnregisterChangeCB(Plugin_CONT_Current,this,(CSettings::SettingChangedFunc)PluginChanged); - g_Settings->UnregisterChangeCB(Plugin_UseHleGfx,this,(CSettings::SettingChangedFunc)PluginChanged); - g_Settings->UnregisterChangeCB(Plugin_UseHleAudio,this,(CSettings::SettingChangedFunc)PluginChanged); - g_Settings->UnregisterChangeCB(Game_EditPlugin_Gfx,this,(CSettings::SettingChangedFunc)PluginChanged); - g_Settings->UnregisterChangeCB(Game_EditPlugin_Audio,this,(CSettings::SettingChangedFunc)PluginChanged); - g_Settings->UnregisterChangeCB(Game_EditPlugin_Contr,this,(CSettings::SettingChangedFunc)PluginChanged); - g_Settings->UnregisterChangeCB(Game_EditPlugin_RSP,this,(CSettings::SettingChangedFunc)PluginChanged); + g_Settings->UnregisterChangeCB(Plugin_RSP_Current, this, (CSettings::SettingChangedFunc)PluginChanged); + g_Settings->UnregisterChangeCB(Plugin_GFX_Current, this, (CSettings::SettingChangedFunc)PluginChanged); + g_Settings->UnregisterChangeCB(Plugin_AUDIO_Current, this, (CSettings::SettingChangedFunc)PluginChanged); + g_Settings->UnregisterChangeCB(Plugin_CONT_Current, this, (CSettings::SettingChangedFunc)PluginChanged); + g_Settings->UnregisterChangeCB(Plugin_UseHleGfx, this, (CSettings::SettingChangedFunc)PluginChanged); + g_Settings->UnregisterChangeCB(Plugin_UseHleAudio, this, (CSettings::SettingChangedFunc)PluginChanged); + g_Settings->UnregisterChangeCB(Game_EditPlugin_Gfx, this, (CSettings::SettingChangedFunc)PluginChanged); + g_Settings->UnregisterChangeCB(Game_EditPlugin_Audio, this, (CSettings::SettingChangedFunc)PluginChanged); + g_Settings->UnregisterChangeCB(Game_EditPlugin_Contr, this, (CSettings::SettingChangedFunc)PluginChanged); + g_Settings->UnregisterChangeCB(Game_EditPlugin_RSP, this, (CSettings::SettingChangedFunc)PluginChanged); DestroyGfxPlugin(); DestroyAudioPlugin(); @@ -47,18 +50,18 @@ CPlugins::~CPlugins (void) DestroyControlPlugin(); } -void CPlugins::PluginChanged ( CPlugins * _this ) +void CPlugins::PluginChanged(CPlugins * _this) { if (g_Settings->LoadBool(Game_TempLoaded) == true) { return; } - bool bGfxChange = _stricmp(_this->m_GfxFile.c_str(),g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str()) != 0; - bool bAudioChange = _stricmp(_this->m_AudioFile.c_str(),g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()) != 0; - bool bRspChange = _stricmp(_this->m_RSPFile.c_str(),g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()) != 0; - bool bContChange = _stricmp(_this->m_ControlFile.c_str(),g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()) != 0; - - if ( bGfxChange || bAudioChange || bRspChange || bContChange ) + bool bGfxChange = _stricmp(_this->m_GfxFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str()) != 0; + bool bAudioChange = _stricmp(_this->m_AudioFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()) != 0; + bool bRspChange = _stricmp(_this->m_RSPFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()) != 0; + bool bContChange = _stricmp(_this->m_ControlFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()) != 0; + + if (bGfxChange || bAudioChange || bRspChange || bContChange) { if (g_Settings->LoadBool(GameRunning_CPU_Running)) { @@ -77,38 +80,38 @@ void CPlugins::PluginChanged ( CPlugins * _this ) } template -static void LoadPlugin (SettingID PluginSettingID, SettingID PluginVerSettingID, plugin_type * & plugin, const char * PluginDir, stdstr & FileName, TraceType TraceLevel, const char * type) -{ +static void LoadPlugin(SettingID PluginSettingID, SettingID PluginVerSettingID, plugin_type * & plugin, const char * PluginDir, stdstr & FileName, TraceType TraceLevel, const char * type) +{ if (plugin != NULL) { return; } FileName = g_Settings->LoadStringVal(PluginSettingID); - CPath PluginFileName(PluginDir,FileName.c_str()); + CPath PluginFileName(PluginDir, FileName.c_str()); plugin = new plugin_type(); if (plugin) { - WriteTraceF(TraceLevel,__FUNCTION__ ": %s Loading (%s): Starting",type,(LPCTSTR)PluginFileName); + WriteTraceF(TraceLevel, __FUNCTION__ ": %s Loading (%s): Starting", type, (const char *)PluginFileName); if (plugin->Load(PluginFileName)) { - WriteTraceF(TraceLevel,__FUNCTION__ ": %s Current Ver: %s",type,plugin->PluginName()); - g_Settings->SaveString(PluginVerSettingID,plugin->PluginName()); + WriteTraceF(TraceLevel, __FUNCTION__ ": %s Current Ver: %s", type, plugin->PluginName()); + g_Settings->SaveString(PluginVerSettingID, plugin->PluginName()); } else { - WriteTraceF(TraceError,__FUNCTION__ ": Failed to load %s",(LPCTSTR)PluginFileName); + WriteTraceF(TraceError, __FUNCTION__ ": Failed to load %s", (const char *)PluginFileName); delete plugin; plugin = NULL; } - WriteTraceF(TraceLevel,__FUNCTION__ ": %s Loading Done",type); - } + WriteTraceF(TraceLevel, __FUNCTION__ ": %s Loading Done", type); + } else { - WriteTraceF(TraceError,__FUNCTION__ ": Failed to allocate %s plugin",type); + WriteTraceF(TraceError, __FUNCTION__ ": Failed to allocate %s plugin", type); } } -void CPlugins::CreatePlugins( void ) +void CPlugins::CreatePlugins(void) { LoadPlugin(Game_Plugin_Gfx, Plugin_GFX_CurVer, m_Gfx, m_PluginDir.c_str(), m_GfxFile, TraceGfxPlugin, "GFX"); LoadPlugin(Game_Plugin_Audio, Plugin_AUDIO_CurVer, m_Audio, m_PluginDir.c_str(), m_AudioFile, TraceDebug, "Audio"); @@ -118,9 +121,9 @@ void CPlugins::CreatePlugins( void ) //Enable debugger if (m_RSP != NULL && m_RSP->EnableDebugging) { - WriteTrace(TraceRSP,__FUNCTION__ ": EnableDebugging starting"); + WriteTrace(TraceRSP, __FUNCTION__ ": EnableDebugging starting"); m_RSP->EnableDebugging(bHaveDebugger()); - WriteTrace(TraceRSP,__FUNCTION__ ": EnableDebugging done"); + WriteTrace(TraceRSP, __FUNCTION__ ": EnableDebugging done"); } if (bHaveDebugger()) @@ -129,7 +132,7 @@ void CPlugins::CreatePlugins( void ) } } -void CPlugins::GameReset ( void ) +void CPlugins::GameReset(void) { if (m_Gfx) { @@ -149,67 +152,67 @@ void CPlugins::GameReset ( void ) } } -void CPlugins::DestroyGfxPlugin( void ) +void CPlugins::DestroyGfxPlugin(void) { if (m_Gfx == NULL) { return; } - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": before delete m_Gfx"); - delete m_Gfx; - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": after delete m_Gfx"); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": before delete m_Gfx"); + delete m_Gfx; + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": after delete m_Gfx"); m_Gfx = NULL; -// g_Settings->UnknownSetting_GFX = NULL; + // g_Settings->UnknownSetting_GFX = NULL; DestroyRspPlugin(); } -void CPlugins::DestroyAudioPlugin( void ) +void CPlugins::DestroyAudioPlugin(void) { if (m_Audio == NULL) { return; } - WriteTrace(TraceDebug,__FUNCTION__ ": 5"); + WriteTrace(TraceDebug, __FUNCTION__ ": 5"); m_Audio->Close(); - WriteTrace(TraceDebug,__FUNCTION__ ": 6"); - delete m_Audio; - WriteTrace(TraceDebug,__FUNCTION__ ": 7"); + WriteTrace(TraceDebug, __FUNCTION__ ": 6"); + delete m_Audio; + WriteTrace(TraceDebug, __FUNCTION__ ": 7"); m_Audio = NULL; - WriteTrace(TraceDebug,__FUNCTION__ ": 8"); -// g_Settings->UnknownSetting_AUDIO = NULL; + WriteTrace(TraceDebug, __FUNCTION__ ": 8"); + // g_Settings->UnknownSetting_AUDIO = NULL; DestroyRspPlugin(); } -void CPlugins::DestroyRspPlugin( void ) +void CPlugins::DestroyRspPlugin(void) { if (m_RSP == NULL) { return; } - WriteTrace(TraceDebug,__FUNCTION__ ": 9"); + WriteTrace(TraceDebug, __FUNCTION__ ": 9"); m_RSP->Close(); - WriteTrace(TraceDebug,__FUNCTION__ ": 10"); - delete m_RSP; - WriteTrace(TraceDebug,__FUNCTION__ ": 11"); + WriteTrace(TraceDebug, __FUNCTION__ ": 10"); + delete m_RSP; + WriteTrace(TraceDebug, __FUNCTION__ ": 11"); m_RSP = NULL; - WriteTrace(TraceDebug,__FUNCTION__ ": 12"); -// g_Settings->UnknownSetting_RSP = NULL; + WriteTrace(TraceDebug, __FUNCTION__ ": 12"); + // g_Settings->UnknownSetting_RSP = NULL; } -void CPlugins::DestroyControlPlugin( void ) +void CPlugins::DestroyControlPlugin(void) { - if (m_Control == NULL) + if (m_Control == NULL) { return; } - WriteTrace(TraceDebug,__FUNCTION__ ": 13"); + WriteTrace(TraceDebug, __FUNCTION__ ": 13"); m_Control->Close(); - WriteTrace(TraceDebug,__FUNCTION__ ": 14"); + WriteTrace(TraceDebug, __FUNCTION__ ": 14"); delete m_Control; - WriteTrace(TraceDebug,__FUNCTION__ ": 15"); + WriteTrace(TraceDebug, __FUNCTION__ ": 15"); m_Control = NULL; - WriteTrace(TraceDebug,__FUNCTION__ ": 16"); -// g_Settings->UnknownSetting_CTRL = NULL; + WriteTrace(TraceDebug, __FUNCTION__ ": 16"); + // g_Settings->UnknownSetting_CTRL = NULL; } void CPlugins::SetRenderWindows( CMainGui * RenderWindow, CMainGui * DummyWindow ) @@ -218,7 +221,7 @@ void CPlugins::SetRenderWindows( CMainGui * RenderWindow, CMainGui * DummyWindow m_DummyWindow = DummyWindow; } -void CPlugins::RomOpened ( void ) +void CPlugins::RomOpened(void) { m_Gfx->RomOpened(); m_RSP->RomOpened(); @@ -226,7 +229,7 @@ void CPlugins::RomOpened ( void ) m_Control->RomOpened(); } -void CPlugins::RomClosed ( void ) +void CPlugins::RomClosed(void) { m_Gfx->RomClose(); m_RSP->RomClose(); @@ -234,32 +237,32 @@ void CPlugins::RomClosed ( void ) m_Control->RomClose(); } -bool CPlugins::Initiate ( CN64System * System ) +bool CPlugins::Initiate(CN64System * System) { - WriteTrace(TraceDebug,__FUNCTION__ ": Start"); + WriteTrace(TraceDebug, __FUNCTION__ ": Start"); //Check to make sure we have the plugin available to be used - if (m_Gfx == NULL) { return false; } + if (m_Gfx == NULL) { return false; } if (m_Audio == NULL) { return false; } - if (m_RSP == NULL) { return false; } + if (m_RSP == NULL) { return false; } if (m_Control == NULL) { return false; } - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Gfx Initiate Starting"); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Starting"); if (!m_Gfx->Initiate(System,m_RenderWindow)) { return false; } - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Gfx Initiate Done"); - WriteTrace(TraceDebug,__FUNCTION__ ": Audio Initiate Starting"); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Done"); + WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Starting"); if (!m_Audio->Initiate(System,m_RenderWindow)) { return false; } - WriteTrace(TraceDebug,__FUNCTION__ ": Audio Initiate Done"); + WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Done"); WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Starting"); if (!m_Control->Initiate(System,m_RenderWindow)) { return false; } WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Done"); - WriteTrace(TraceRSP,__FUNCTION__ ": RSP Initiate Starting"); - if (!m_RSP->Initiate(this,System)) { return false; } - WriteTrace(TraceRSP,__FUNCTION__ ": RSP Initiate Done"); - WriteTrace(TraceDebug,__FUNCTION__ ": Done"); + WriteTrace(TraceRSP, __FUNCTION__ ": RSP Initiate Starting"); + if (!m_RSP->Initiate(this, System)) { return false; } + WriteTrace(TraceRSP, __FUNCTION__ ": RSP Initiate Done"); + WriteTrace(TraceDebug, __FUNCTION__ ": Done"); return true; } -bool CPlugins::ResetInUiThread ( CN64System * System ) +bool CPlugins::ResetInUiThread(CN64System * System) { #if defined(WINDOWS_UI) return m_RenderWindow->ResetPlugins(this, System); @@ -269,14 +272,14 @@ bool CPlugins::ResetInUiThread ( CN64System * System ) #endif } -bool CPlugins::Reset ( CN64System * System ) +bool CPlugins::Reset(CN64System * System) { - WriteTrace(TraceDebug,__FUNCTION__ ": Start"); + WriteTrace(TraceDebug, __FUNCTION__ ": Start"); - bool bGfxChange = _stricmp(m_GfxFile.c_str(),g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str()) != 0; - bool bAudioChange = _stricmp(m_AudioFile.c_str(),g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()) != 0; - bool bRspChange = _stricmp(m_RSPFile.c_str(),g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()) != 0; - bool bContChange = _stricmp(m_ControlFile.c_str(),g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()) != 0; + bool bGfxChange = _stricmp(m_GfxFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str()) != 0; + bool bAudioChange = _stricmp(m_AudioFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()) != 0; + bool bRspChange = _stricmp(m_RSPFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()) != 0; + bool bContChange = _stricmp(m_ControlFile.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()) != 0; //if GFX and Audio has changed we also need to force reset of RSP if (bGfxChange || bAudioChange) @@ -289,17 +292,17 @@ bool CPlugins::Reset ( CN64System * System ) CreatePlugins(); - if (m_Gfx && bGfxChange) + if (m_Gfx && bGfxChange) { - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Gfx Initiate Starting"); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Starting"); if (!m_Gfx->Initiate(System,m_RenderWindow)) { return false; } - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Gfx Initiate Done"); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Done"); } - if (m_Audio && bAudioChange) + if (m_Audio && bAudioChange) { - WriteTrace(TraceDebug,__FUNCTION__ ": Audio Initiate Starting"); + WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Starting"); if (!m_Audio->Initiate(System,m_RenderWindow)) { return false; } - WriteTrace(TraceDebug,__FUNCTION__ ": Audio Initiate Done"); + WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Done"); } if (m_Control && bContChange) { @@ -307,22 +310,26 @@ bool CPlugins::Reset ( CN64System * System ) if (!m_Control->Initiate(System,m_RenderWindow)) { return false; } WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Done"); } - if (m_RSP && bRspChange) + if (m_RSP && bRspChange) { - WriteTrace(TraceRSP,__FUNCTION__ ": RSP Initiate Starting"); - if (!m_RSP->Initiate(this,System)) { return false; } - WriteTrace(TraceRSP,__FUNCTION__ ": RSP Initiate Done"); + WriteTrace(TraceRSP, __FUNCTION__ ": RSP Initiate Starting"); + if (!m_RSP->Initiate(this, System)) { return false; } + WriteTrace(TraceRSP, __FUNCTION__ ": RSP Initiate Done"); } - WriteTrace(TraceDebug,__FUNCTION__ ": Done"); + WriteTrace(TraceDebug, __FUNCTION__ ": Done"); return true; } -void CPlugins::ConfigPlugin ( DWORD hParent, PLUGIN_TYPE Type ) { - switch (Type) { +void CPlugins::ConfigPlugin(uint32_t hParent, PLUGIN_TYPE Type) +{ + switch (Type) + { case PLUGIN_TYPE_RSP: if (m_RSP == NULL || m_RSP->DllConfig == NULL) { break; } - if (!m_RSP->Initialized()) { - if (!m_RSP->Initiate(NULL,NULL)) { + if (!m_RSP->Initialized()) + { + if (!m_RSP->Initiate(NULL, NULL)) + { break; } } @@ -330,8 +337,10 @@ void CPlugins::ConfigPlugin ( DWORD hParent, PLUGIN_TYPE Type ) { break; case PLUGIN_TYPE_GFX: if (m_Gfx == NULL || m_Gfx->DllConfig == NULL) { break; } - if (!m_Gfx->Initialized()) { - if (!m_Gfx->Initiate(NULL,m_DummyWindow)) { + if (!m_Gfx->Initialized()) + { + if (!m_Gfx->Initiate(NULL, NULL)) + { break; } } @@ -339,8 +348,10 @@ void CPlugins::ConfigPlugin ( DWORD hParent, PLUGIN_TYPE Type ) { break; case PLUGIN_TYPE_AUDIO: if (m_Audio == NULL || m_Audio->DllConfig == NULL) { break; } - if (!m_Audio->Initialized()) { - if (!m_Audio->Initiate(NULL,m_DummyWindow)) { + if (!m_Audio->Initialized()) + { + if (!m_Audio->Initiate(NULL, NULL)) + { break; } } @@ -348,8 +359,10 @@ void CPlugins::ConfigPlugin ( DWORD hParent, PLUGIN_TYPE Type ) { break; case PLUGIN_TYPE_CONTROLLER: if (m_Control == NULL || m_Control->DllConfig == NULL) { break; } - if (!m_Control->Initialized()) { - if (!m_Control->Initiate(NULL,m_DummyWindow)) { + if (!m_Control->Initialized()) + { + if (!m_Control->Initiate(NULL, NULL)) + { break; } } @@ -358,76 +371,63 @@ void CPlugins::ConfigPlugin ( DWORD hParent, PLUGIN_TYPE Type ) { } } -void DummyCheckInterrupts ( void ) { +void DummyCheckInterrupts(void) +{ } -void DummyFunction (void) { +void DummyFunction(void) +{ } -#include - -void CPlugins::CreatePluginDir ( const stdstr & DstDir ) const { - char path_buffer[_MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR], - fname[_MAX_FNAME], ext[_MAX_EXT]; - _splitpath(DstDir.c_str(), drive, dir, fname, ext ); - _makepath(path_buffer, drive, dir, "", "" ); - if (CreateDirectory(path_buffer,NULL) == 0 && GetLastError() == ERROR_PATH_NOT_FOUND) - { - path_buffer[strlen(path_buffer) - 1] = 0; - CreatePluginDir(stdstr(path_buffer)); - CreateDirectory(path_buffer,NULL); - } -} - -bool CPlugins::CopyPlugins ( const stdstr & DstDir ) const -{ +bool CPlugins::CopyPlugins(const stdstr & DstDir) const +{ //Copy GFX Plugin - CPath srcGfxPlugin(m_PluginDir.c_str(),g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str()); - CPath dstGfxPlugin(DstDir.c_str(),g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str()); - - if (CopyFile(srcGfxPlugin,dstGfxPlugin,false) == 0) + CPath srcGfxPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str()); + CPath dstGfxPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str()); + + if (!dstGfxPlugin.DirectoryExists()) { - if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstGfxPlugin.DirectoryCreate(); } - if (!CopyFile(srcGfxPlugin,dstGfxPlugin,false)) - { - return false; - } + dstGfxPlugin.DirectoryCreate(); + } + if (!srcGfxPlugin.CopyTo(dstGfxPlugin)) + { + return false; } //Copy m_Audio Plugin - CPath srcAudioPlugin(m_PluginDir.c_str(),g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()); + CPath srcAudioPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()); CPath dstAudioPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str()); - if (CopyFile(srcAudioPlugin,dstAudioPlugin,false) == 0) { - if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstAudioPlugin.DirectoryCreate(); } - if (!CopyFile(srcAudioPlugin,dstAudioPlugin,false)) - { - return false; - } + if (!dstAudioPlugin.DirectoryExists()) + { + dstAudioPlugin.DirectoryCreate(); + } + if (!srcAudioPlugin.CopyTo(dstAudioPlugin)) + { + return false; } //Copy RSP Plugin CPath srcRSPPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()); - CPath dstRSPPlugin(DstDir.c_str(),g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()); - if (CopyFile(srcRSPPlugin,dstRSPPlugin,false) == 0) { - if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstRSPPlugin.DirectoryCreate(); } - if (!CopyFile(srcRSPPlugin,dstRSPPlugin,false)) - { - return false; - } + CPath dstRSPPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str()); + if (!dstRSPPlugin.DirectoryExists()) + { + dstRSPPlugin.DirectoryCreate(); + } + if (!srcRSPPlugin.CopyTo(dstRSPPlugin)) + { + return false; } //Copy Controller Plugin CPath srcContPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()); - CPath dstContPlugin(DstDir.c_str(),g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()); + CPath dstContPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str()); + if (!dstContPlugin.DirectoryExists()) + { + dstContPlugin.DirectoryCreate(); + } if (!srcContPlugin.CopyTo(dstContPlugin)) { - if (GetLastError() == ERROR_PATH_NOT_FOUND) { dstContPlugin.DirectoryCreate(); } - if (!CopyFile(srcContPlugin,dstContPlugin,false)) - { - DWORD dwError = GetLastError(); - dwError = dwError; - return false; - } + return false; } return true; } diff --git a/Source/Project64/Plugins/Plugin Class.h b/Source/Project64/Plugins/Plugin Class.h index ea6e3b136..51deb2127 100644 --- a/Source/Project64/Plugins/Plugin Class.h +++ b/Source/Project64/Plugins/Plugin Class.h @@ -11,137 +11,133 @@ #pragma once #include -typedef int BOOL; -typedef unsigned char BYTE; -typedef unsigned short WORD; -typedef unsigned long DWORD; -typedef unsigned __int64 QWORD; #ifndef PLUGIN_INFO_STRUCT #define PLUGIN_INFO_STRUCT -typedef struct { - WORD Version; /* Should be set to 1 */ - WORD Type; /* Set to PLUGIN_TYPE_GFX */ - char Name[100]; /* Name of the DLL */ +typedef struct +{ + uint16_t Version; /* Should be set to 1 */ + uint16_t Type; /* Set to PLUGIN_TYPE_GFX */ + char Name[100]; /* Name of the DLL */ - /* If DLL supports memory these memory options then set them to TRUE or FALSE - if it does not support it */ - BOOL NormalMemory; /* a normal BYTE array */ - BOOL MemoryBswaped; /* a normal BYTE array where the memory has been pre - bswap on a dword (32 bits) boundry */ + /* If DLL supports memory these memory options then set them to TRUE or FALSE + if it does not support it */ + int32_t NormalMemory; /* a normal BYTE array */ + int32_t MemoryBswaped; /* a normal BYTE array where the memory has been pre + bswap on a dword (32 bits) boundry */ } PLUGIN_INFO; #endif // enum's -enum SETTING_DATA_TYPE { - Data_DWORD_General = 0, // A unsigned int setting used anywhere - Data_String_General = 1, // A string setting used anywhere - Data_DWORD_Game = 2, // A unsigned int associated with the current game - Data_String_Game = 3, // A string associated with the current game - Data_DWORD_RDB = 4, // A unsigned int associated with the current game in the rom database - Data_String_RDB = 5, // A string associated with the current game in the rom database - Data_DWORD_RDB_Setting = 6, // A unsigned int read from the rom database, with config file - Data_String_RDB_Setting = 7, // A string read from the rom database, with config file +enum SETTING_DATA_TYPE +{ + Data_DWORD_General = 0, // A uint32_t setting used anywhere + Data_String_General = 1, // A string setting used anywhere + Data_DWORD_Game = 2, // A uint32_t associated with the current game + Data_String_Game = 3, // A string associated with the current game + Data_DWORD_RDB = 4, // A uint32_t associated with the current game in the rom database + Data_String_RDB = 5, // A string associated with the current game in the rom database + Data_DWORD_RDB_Setting = 6, // A uint32_t read from the rom database, with config file + Data_String_RDB_Setting = 7, // A string read from the rom database, with config file }; -typedef struct { - DWORD dwSize; - int DefaultStartRange; - int SettingStartRange; - int MaximumSettings; - int NoDefault; - int DefaultLocation; - void * handle; - unsigned int (*GetSetting) ( void * handle, int ID ); - const char * (*GetSettingSz) ( void * handle, int ID, char * Buffer, int BufferLen ); - void (*SetSetting) ( void * handle, int ID, unsigned int Value ); - void (*SetSettingSz) ( void * handle, int ID, const char * Value ); - void (*RegisterSetting) ( void * handle, int ID, int DefaultID, SettingDataType Type, - SettingType Location, const char * Category, const char * DefaultStr, DWORD Value ); - void (*UseUnregisteredSetting) (int ID); +typedef struct +{ + uint32_t dwSize; + int32_t DefaultStartRange; + int32_t SettingStartRange; + int32_t MaximumSettings; + int32_t NoDefault; + int32_t DefaultLocation; + void * handle; + uint32_t(*GetSetting) (void * handle, int32_t ID); + const char * (*GetSettingSz) (void * handle, int32_t ID, char * Buffer, int32_t BufferLen); + void(*SetSetting) (void * handle, int32_t ID, uint32_t Value); + void(*SetSettingSz) (void * handle, int32_t ID, const char * Value); + void(*RegisterSetting) (void * handle, int32_t ID, int32_t DefaultID, SettingDataType Type, + SettingType Location, const char * Category, const char * DefaultStr, uint32_t Value); + void(*UseUnregisteredSetting) (int32_t ID); } PLUGIN_SETTINGS; -typedef struct { - unsigned int (*FindSystemSettingId) ( void * handle, const char * Name ); +typedef struct +{ + uint32_t(*FindSystemSettingId) (void * handle, const char * Name); } PLUGIN_SETTINGS2; -typedef struct { - void (*FlushSettings) ( void * handle ); +typedef struct +{ + void(*FlushSettings) (void * handle); } PLUGIN_SETTINGS3; -enum PLUGIN_TYPE { - PLUGIN_TYPE_NONE = 0, - PLUGIN_TYPE_RSP = 1, - PLUGIN_TYPE_GFX = 2, - PLUGIN_TYPE_AUDIO = 3, - PLUGIN_TYPE_CONTROLLER = 4, +enum PLUGIN_TYPE +{ + PLUGIN_TYPE_NONE = 0, + PLUGIN_TYPE_RSP = 1, + PLUGIN_TYPE_GFX = 2, + PLUGIN_TYPE_AUDIO = 3, + PLUGIN_TYPE_CONTROLLER = 4, }; -class CSettings; +class CSettings; class CMainGui; class CGfxPlugin; class CAudioPlugin; class CRSP_Plugin; class CControl_Plugin; class CPlugins : - private CDebugSettings + private CDebugSettings { public: - //Functions - CPlugins (const stdstr & PluginDir ); - ~CPlugins (); + //Functions + CPlugins(const stdstr & PluginDir); + ~CPlugins(); - bool Initiate ( CN64System * System ); - void RomOpened ( void ); - void RomClosed ( void ); + bool Initiate(CN64System * System); + void RomOpened(void); + void RomClosed(void); void SetRenderWindows ( CMainGui * RenderWindow, CMainGui * DummyWindow ); - void ConfigPlugin ( DWORD hParent, PLUGIN_TYPE Type ); - bool CopyPlugins ( const stdstr & DstDir ) const; - void CreatePlugins ( void ); - bool Reset ( CN64System * System ); - bool ResetInUiThread ( CN64System * System ); - void GameReset ( void ); + void ConfigPlugin(uint32_t hParent, PLUGIN_TYPE Type); + bool CopyPlugins(const stdstr & DstDir) const; + void CreatePlugins(void); + bool Reset(CN64System * System); + bool ResetInUiThread(CN64System * System); + void GameReset(void); + + inline CGfxPlugin * Gfx(void) const { return m_Gfx; } + inline CAudioPlugin * Audio(void) const { return m_Audio; } + inline CRSP_Plugin * RSP(void) const { return m_RSP; } + inline CControl_Plugin * Control(void) const { return m_Control; } - inline CGfxPlugin * Gfx ( void) const { return m_Gfx; }; - inline CAudioPlugin * Audio ( void) const { return m_Audio; }; - inline CRSP_Plugin * RSP ( void) const { return m_RSP; }; - inline CControl_Plugin * Control ( void) const { return m_Control; }; private: - CPlugins(void); // Disable default constructor - CPlugins(const CPlugins&); // Disable copy constructor - CPlugins& operator=(const CPlugins&); // Disable assignment + CPlugins(void); // Disable default constructor + CPlugins(const CPlugins&); // Disable copy constructor + CPlugins& operator=(const CPlugins&); // Disable assignment - // void Reset ( PLUGIN_TYPE Type ); + void DestroyGfxPlugin(void); + void DestroyAudioPlugin(void); + void DestroyRspPlugin(void); + void DestroyControlPlugin(void); - void CreatePluginDir ( const stdstr & DstDir ) const; + static void PluginChanged(CPlugins * _this); - void DestroyGfxPlugin ( void ); - void DestroyAudioPlugin ( void ); - void DestroyRspPlugin ( void ); - void DestroyControlPlugin ( void ); - - static void PluginChanged ( CPlugins * _this ); - - //Common Classes CMainGui * m_RenderWindow; CMainGui * m_DummyWindow; - stdstr const m_PluginDir; + stdstr const m_PluginDir; - //Plugins - CGfxPlugin * m_Gfx; - CAudioPlugin * m_Audio; - CRSP_Plugin * m_RSP; - CControl_Plugin * m_Control; + //Plugins + CGfxPlugin * m_Gfx; + CAudioPlugin * m_Audio; + CRSP_Plugin * m_RSP; + CControl_Plugin * m_Control; - stdstr m_GfxFile; - stdstr m_AudioFile; - stdstr m_RSPFile; - stdstr m_ControlFile; + stdstr m_GfxFile; + stdstr m_AudioFile; + stdstr m_RSPFile; + stdstr m_ControlFile; }; //Dummy Functions -void DummyCheckInterrupts ( void ); -void DummyFunction (void); - +void DummyCheckInterrupts(void); +void DummyFunction(void); diff --git a/Source/Project64/Plugins/RSP Plugin.cpp b/Source/Project64/Plugins/RSP Plugin.cpp index 5239068db..7cac282e9 100644 --- a/Source/Project64/Plugins/RSP Plugin.cpp +++ b/Source/Project64/Plugins/RSP Plugin.cpp @@ -10,202 +10,202 @@ ****************************************************************************/ #include "stdafx.h" -void DummyFunc1(BOOL /*a*/) {} +void DummyFunc1(int a) { a += 1;} CRSP_Plugin::CRSP_Plugin(void) : - DoRspCycles(NULL), - EnableDebugging(NULL), - m_CycleCount(0), - GetDebugInfo(NULL), - InitiateDebugger(NULL) + DoRspCycles(NULL), + EnableDebugging(NULL), + m_CycleCount(0), + GetDebugInfo(NULL), + InitiateDebugger(NULL) { - memset(&m_RSPDebug, 0, sizeof(m_RSPDebug)); + memset(&m_RSPDebug, 0, sizeof(m_RSPDebug)); } CRSP_Plugin::~CRSP_Plugin() { - Close(); - UnloadPlugin(); + Close(); + UnloadPlugin(); } -bool CRSP_Plugin::LoadFunctions ( void ) +bool CRSP_Plugin::LoadFunctions(void) { - // Find entries for functions in DLL - void (__cdecl *InitiateRSP)( void ); - LoadFunction(InitiateRSP); - LoadFunction(DoRspCycles); - _LoadFunction("GetRspDebugInfo", GetDebugInfo); - _LoadFunction("InitiateRSPDebugger", InitiateDebugger); - LoadFunction(EnableDebugging); - if (EnableDebugging == NULL) { EnableDebugging = DummyFunc1; } + // Find entries for functions in DLL + void(__cdecl *InitiateRSP)(void); + LoadFunction(InitiateRSP); + LoadFunction(DoRspCycles); + _LoadFunction("GetRspDebugInfo", GetDebugInfo); + _LoadFunction("InitiateRSPDebugger", InitiateDebugger); + LoadFunction(EnableDebugging); + if (EnableDebugging == NULL) { EnableDebugging = DummyFunc1; } - //Make sure dll had all needed functions - if (DoRspCycles == NULL) { UnloadPlugin(); return false; } - if (InitiateRSP == NULL) { UnloadPlugin(); return false; } - if (RomClosed == NULL) { UnloadPlugin(); return false; } - if (CloseDLL == NULL) { UnloadPlugin(); return false; } + //Make sure dll had all needed functions + if (DoRspCycles == NULL) { UnloadPlugin(); return false; } + if (InitiateRSP == NULL) { UnloadPlugin(); return false; } + if (RomClosed == NULL) { UnloadPlugin(); return false; } + if (CloseDLL == NULL) { UnloadPlugin(); return false; } - if (m_PluginInfo.Version >= 0x0102) - { - if (PluginOpened == NULL) { UnloadPlugin(); return false; } - } + if (m_PluginInfo.Version >= 0x0102) + { + if (PluginOpened == NULL) { UnloadPlugin(); return false; } + } - // Get debug info if able - if (GetDebugInfo != NULL) - GetDebugInfo(&m_RSPDebug); + // Get debug info if able + if (GetDebugInfo != NULL) + GetDebugInfo(&m_RSPDebug); - return true; + return true; } bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System) { - if (m_PluginInfo.Version == 1 || m_PluginInfo.Version == 0x100) - { - return false; - } + if (m_PluginInfo.Version == 1 || m_PluginInfo.Version == 0x100) + { + return false; + } - typedef struct - { - HINSTANCE hInst; - BOOL MemoryBswaped; /* If this is set to TRUE, then the memory has been pre - bswap on a dword (32 bits) boundry */ - BYTE * RDRAM; - BYTE * DMEM; - BYTE * IMEM; + typedef struct + { + HINSTANCE hInst; + int MemoryBswaped; /* If this is set to TRUE, then the memory has been pre + bswap on a dword (32 bits) boundry */ + uint8_t * RDRAM; + uint8_t * DMEM; + uint8_t * IMEM; - DWORD * MI__INTR_REG; + uint32_t * MI__INTR_REG; - DWORD * SP__MEM_ADDR_REG; - DWORD * SP__DRAM_ADDR_REG; - DWORD * SP__RD_LEN_REG; - DWORD * SP__WR_LEN_REG; - DWORD * SP__STATUS_REG; - DWORD * SP__DMA_FULL_REG; - DWORD * SP__DMA_BUSY_REG; - DWORD * SP__PC_REG; - DWORD * SP__SEMAPHORE_REG; + uint32_t * SP__MEM_ADDR_REG; + uint32_t * SP__DRAM_ADDR_REG; + uint32_t * SP__RD_LEN_REG; + uint32_t * SP__WR_LEN_REG; + uint32_t * SP__STATUS_REG; + uint32_t * SP__DMA_FULL_REG; + uint32_t * SP__DMA_BUSY_REG; + uint32_t * SP__PC_REG; + uint32_t * SP__SEMAPHORE_REG; - DWORD * DPC__START_REG; - DWORD * DPC__END_REG; - DWORD * DPC__CURRENT_REG; - DWORD * DPC__STATUS_REG; - DWORD * DPC__CLOCK_REG; - DWORD * DPC__BUFBUSY_REG; - DWORD * DPC__PIPEBUSY_REG; - DWORD * DPC__TMEM_REG; + uint32_t * DPC__START_REG; + uint32_t * DPC__END_REG; + uint32_t * DPC__CURRENT_REG; + uint32_t * DPC__STATUS_REG; + uint32_t * DPC__CLOCK_REG; + uint32_t * DPC__BUFBUSY_REG; + uint32_t * DPC__PIPEBUSY_REG; + uint32_t * DPC__TMEM_REG; - void ( __cdecl *CheckInterrupts)( void ); - void (__cdecl *ProcessDlist)( void ); - void (__cdecl *ProcessAlist)( void ); - void (__cdecl *ProcessRdpList)( void ); - void (__cdecl *ShowCFB)( void ); - } RSP_INFO_1_1; + void(__cdecl *CheckInterrupts)(void); + void(__cdecl *ProcessDlist)(void); + void(__cdecl *ProcessAlist)(void); + void(__cdecl *ProcessRdpList)(void); + void(__cdecl *ShowCFB)(void); + } RSP_INFO_1_1; - RSP_INFO_1_1 Info = { 0 }; + RSP_INFO_1_1 Info = { 0 }; - Info.hInst = GetModuleHandle(NULL); - Info.CheckInterrupts = DummyCheckInterrupts; - Info.MemoryBswaped = (System == NULL); // only true when the system's not yet loaded + Info.hInst = GetModuleHandle(NULL); + Info.CheckInterrupts = DummyCheckInterrupts; + Info.MemoryBswaped = (System == NULL); // only true when the system's not yet loaded - //Get Function from DLL - void (__cdecl *InitiateRSP) ( RSP_INFO_1_1 Audio_Info,DWORD * Cycles ); - LoadFunction(InitiateRSP); - if (InitiateRSP == NULL) { return false; } + //Get Function from DLL + void(__cdecl *InitiateRSP) (RSP_INFO_1_1 Audio_Info, uint32_t * Cycles); + LoadFunction(InitiateRSP); + if (InitiateRSP == NULL) { return false; } - // We are initializing the plugin before any rom is loaded so we do not have any correct - // parameters here.. just needed to we can config the DLL. - if (System == NULL) - { - BYTE Buffer[100]; - DWORD Value = 0; + // We are initializing the plugin before any rom is loaded so we do not have any correct + // parameters here.. just needed to we can config the DLL. + if (System == NULL) + { + uint8_t Buffer[100]; + uint32_t Value = 0; - Info.ProcessDlist = DummyCheckInterrupts; - Info.ProcessRdpList = DummyCheckInterrupts; - Info.ShowCFB = DummyCheckInterrupts; - Info.ProcessAlist = DummyCheckInterrupts; + Info.ProcessDlist = DummyCheckInterrupts; + Info.ProcessRdpList = DummyCheckInterrupts; + Info.ShowCFB = DummyCheckInterrupts; + Info.ProcessAlist = DummyCheckInterrupts; - Info.RDRAM = Buffer; - Info.DMEM = Buffer; - Info.IMEM = Buffer; + Info.RDRAM = Buffer; + Info.DMEM = Buffer; + Info.IMEM = Buffer; - Info.MI__INTR_REG = &Value; + Info.MI__INTR_REG = &Value; - Info.SP__MEM_ADDR_REG = &Value; - Info.SP__DRAM_ADDR_REG = &Value; - Info.SP__RD_LEN_REG = &Value; - Info.SP__WR_LEN_REG = &Value; - Info.SP__STATUS_REG = &Value; - Info.SP__DMA_FULL_REG = &Value; - Info.SP__DMA_BUSY_REG = &Value; - Info.SP__PC_REG = &Value; - Info.SP__SEMAPHORE_REG = &Value; + Info.SP__MEM_ADDR_REG = &Value; + Info.SP__DRAM_ADDR_REG = &Value; + Info.SP__RD_LEN_REG = &Value; + Info.SP__WR_LEN_REG = &Value; + Info.SP__STATUS_REG = &Value; + Info.SP__DMA_FULL_REG = &Value; + Info.SP__DMA_BUSY_REG = &Value; + Info.SP__PC_REG = &Value; + Info.SP__SEMAPHORE_REG = &Value; - Info.DPC__START_REG = &Value; - Info.DPC__END_REG = &Value; - Info.DPC__CURRENT_REG = &Value; - Info.DPC__STATUS_REG = &Value; - Info.DPC__CLOCK_REG = &Value; - Info.DPC__BUFBUSY_REG = &Value; - Info.DPC__PIPEBUSY_REG = &Value; - Info.DPC__TMEM_REG = &Value; - } - // Send initialization information to the DLL - else - { - Info.ProcessDlist = Plugins->Gfx()->ProcessDList; - Info.ProcessRdpList = Plugins->Gfx()->ProcessRDPList; - Info.ShowCFB = Plugins->Gfx()->ShowCFB; - Info.ProcessAlist = Plugins->Audio()->ProcessAList; + Info.DPC__START_REG = &Value; + Info.DPC__END_REG = &Value; + Info.DPC__CURRENT_REG = &Value; + Info.DPC__STATUS_REG = &Value; + Info.DPC__CLOCK_REG = &Value; + Info.DPC__BUFBUSY_REG = &Value; + Info.DPC__PIPEBUSY_REG = &Value; + Info.DPC__TMEM_REG = &Value; + } + // Send initialization information to the DLL + else + { + Info.ProcessDlist = Plugins->Gfx()->ProcessDList; + Info.ProcessRdpList = Plugins->Gfx()->ProcessRDPList; + Info.ShowCFB = Plugins->Gfx()->ShowCFB; + Info.ProcessAlist = Plugins->Audio()->ProcessAList; - Info.RDRAM = g_MMU->Rdram(); - Info.DMEM = g_MMU->Dmem(); - Info.IMEM = g_MMU->Imem(); + Info.RDRAM = g_MMU->Rdram(); + Info.DMEM = g_MMU->Dmem(); + Info.IMEM = g_MMU->Imem(); - Info.MI__INTR_REG = &g_Reg->m_RspIntrReg; + Info.MI__INTR_REG = (uint32_t *)&g_Reg->m_RspIntrReg; - Info.SP__MEM_ADDR_REG = &g_Reg->SP_MEM_ADDR_REG; - Info.SP__DRAM_ADDR_REG = &g_Reg->SP_DRAM_ADDR_REG; - Info.SP__RD_LEN_REG = &g_Reg->SP_RD_LEN_REG; - Info.SP__WR_LEN_REG = &g_Reg->SP_WR_LEN_REG; - Info.SP__STATUS_REG = &g_Reg->SP_STATUS_REG; - Info.SP__DMA_FULL_REG = &g_Reg->SP_DMA_FULL_REG; - Info.SP__DMA_BUSY_REG = &g_Reg->SP_DMA_BUSY_REG; - Info.SP__PC_REG = &g_Reg->SP_PC_REG; - Info.SP__SEMAPHORE_REG = &g_Reg->SP_SEMAPHORE_REG; + Info.SP__MEM_ADDR_REG = (uint32_t *)&g_Reg->SP_MEM_ADDR_REG; + Info.SP__DRAM_ADDR_REG = (uint32_t *)&g_Reg->SP_DRAM_ADDR_REG; + Info.SP__RD_LEN_REG = (uint32_t *)&g_Reg->SP_RD_LEN_REG; + Info.SP__WR_LEN_REG = (uint32_t *)&g_Reg->SP_WR_LEN_REG; + Info.SP__STATUS_REG = (uint32_t *)&g_Reg->SP_STATUS_REG; + Info.SP__DMA_FULL_REG = (uint32_t *)&g_Reg->SP_DMA_FULL_REG; + Info.SP__DMA_BUSY_REG = (uint32_t *)&g_Reg->SP_DMA_BUSY_REG; + Info.SP__PC_REG = (uint32_t *)&g_Reg->SP_PC_REG; + Info.SP__SEMAPHORE_REG = (uint32_t *)&g_Reg->SP_SEMAPHORE_REG; - Info.DPC__START_REG = &g_Reg->DPC_START_REG; - Info.DPC__END_REG = &g_Reg->DPC_END_REG; - Info.DPC__CURRENT_REG = &g_Reg->DPC_CURRENT_REG; - Info.DPC__STATUS_REG = &g_Reg->DPC_STATUS_REG; - Info.DPC__CLOCK_REG = &g_Reg->DPC_CLOCK_REG; - Info.DPC__BUFBUSY_REG = &g_Reg->DPC_BUFBUSY_REG; - Info.DPC__PIPEBUSY_REG = &g_Reg->DPC_PIPEBUSY_REG; - Info.DPC__TMEM_REG = &g_Reg->DPC_TMEM_REG; - } + Info.DPC__START_REG = (uint32_t *)&g_Reg->DPC_START_REG; + Info.DPC__END_REG = (uint32_t *)&g_Reg->DPC_END_REG; + Info.DPC__CURRENT_REG = (uint32_t *)&g_Reg->DPC_CURRENT_REG; + Info.DPC__STATUS_REG = (uint32_t *)&g_Reg->DPC_STATUS_REG; + Info.DPC__CLOCK_REG = (uint32_t *)&g_Reg->DPC_CLOCK_REG; + Info.DPC__BUFBUSY_REG = (uint32_t *)&g_Reg->DPC_BUFBUSY_REG; + Info.DPC__PIPEBUSY_REG = (uint32_t *)&g_Reg->DPC_PIPEBUSY_REG; + Info.DPC__TMEM_REG = (uint32_t *)&g_Reg->DPC_TMEM_REG; + } - InitiateRSP(Info, &m_CycleCount); - m_Initialized = true; + InitiateRSP(Info, &m_CycleCount); + m_Initialized = true; - //jabo had a bug so I call CreateThread so his dllmain gets called again - DWORD ThreadID; - HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID); - CloseHandle(hthread); - return m_Initialized; + //jabo had a bug so I call CreateThread so his dllmain gets called again + DWORD ThreadID; + HANDLE hthread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)DummyFunction, NULL, 0, &ThreadID); + CloseHandle(hthread); + return m_Initialized; } -void CRSP_Plugin::UnloadPluginDetails(void) +void CRSP_Plugin::UnloadPluginDetails(void) { - memset(&m_RSPDebug, 0, sizeof(m_RSPDebug)); - DoRspCycles = NULL; - EnableDebugging = NULL; - GetDebugInfo = NULL; - InitiateDebugger = NULL; + memset(&m_RSPDebug, 0, sizeof(m_RSPDebug)); + DoRspCycles = NULL; + EnableDebugging = NULL; + GetDebugInfo = NULL; + InitiateDebugger = NULL; } void CRSP_Plugin::ProcessMenuItem(int id) { - if (m_RSPDebug.ProcessMenuItem) - { - m_RSPDebug.ProcessMenuItem(id); - } + if (m_RSPDebug.ProcessMenuItem) + { + m_RSPDebug.ProcessMenuItem(id); + } } diff --git a/Source/Project64/Plugins/RSP Plugin.h b/Source/Project64/Plugins/RSP Plugin.h index bdc963807..ef20275bf 100644 --- a/Source/Project64/Plugins/RSP Plugin.h +++ b/Source/Project64/Plugins/RSP Plugin.h @@ -9,68 +9,68 @@ * * ****************************************************************************/ #pragma once +#include "Plugin Base.h" class CRSP_Plugin : public CPlugin { - typedef struct { - /* Menu */ - /* Items should have an ID between 5001 and 5100 */ - HMENU hRSPMenu; - void (__cdecl *ProcessMenuItem) ( int ID ); + typedef struct { + /* Menu */ + /* Items should have an ID between 5001 and 5100 */ + void * hRSPMenu; + void(__cdecl *ProcessMenuItem) (int32_t ID); - /* Break Points */ - BOOL UseBPoints; - char BPPanelName[20]; - void (__cdecl *Add_BPoint) ( void ); - void (__cdecl *CreateBPPanel) ( HMENU hDlg, RECT_STRUCT rcBox ); - void (__cdecl *HideBPPanel) ( void ); - void (__cdecl *PaintBPPanel) ( WINDOWS_PAINTSTRUCT ps ); - void (__cdecl *ShowBPPanel) ( void ); - void (__cdecl *RefreshBpoints) ( HMENU hList ); - void (__cdecl *RemoveBpoint) ( HMENU hList, int index ); - void (__cdecl *RemoveAllBpoint) ( void ); - - /* RSP command Window */ - void (__cdecl *Enter_RSP_Commands_Window) ( void ); - } RSPDEBUG_INFO; + /* Break Points */ + int32_t UseBPoints; + char BPPanelName[20]; + void(__cdecl *Add_BPoint) (void); + void(__cdecl *CreateBPPanel) (void); + void(__cdecl *HideBPPanel) (void); + void(__cdecl *PaintBPPanel) (void); + void(__cdecl *ShowBPPanel) (void); + void(__cdecl *RefreshBpoints) (void * hList); + void(__cdecl *RemoveBpoint) (void * hList, int32_t index); + void(__cdecl *RemoveAllBpoint) (void); + /* RSP command Window */ + void(__cdecl *Enter_RSP_Commands_Window) (void); + } RSPDEBUG_INFO; - typedef struct { - void (__cdecl *UpdateBreakPoints)( void ); - void (__cdecl *UpdateMemory)( void ); - void (__cdecl *UpdateR4300iRegisters)( void ); - void (__cdecl *Enter_BPoint_Window)( void ); - void (__cdecl *Enter_R4300i_Commands_Window)( void ); - void (__cdecl *Enter_R4300i_Register_Window)( void ); - void (__cdecl *Enter_RSP_Commands_Window) ( void ); - void (__cdecl *Enter_Memory_Window)( void ); - } DEBUG_INFO; + typedef struct { + void(__cdecl *UpdateBreakPoints)(void); + void(__cdecl *UpdateMemory)(void); + void(__cdecl *UpdateR4300iRegisters)(void); + void(__cdecl *Enter_BPoint_Window)(void); + void(__cdecl *Enter_R4300i_Commands_Window)(void); + void(__cdecl *Enter_R4300i_Register_Window)(void); + void(__cdecl *Enter_RSP_Commands_Window) (void); + void(__cdecl *Enter_Memory_Window)(void); + } DEBUG_INFO; public: - CRSP_Plugin(void); - ~CRSP_Plugin(); + CRSP_Plugin(void); + ~CRSP_Plugin(); - bool Initiate(CPlugins * Plugins, CN64System * System); + bool Initiate(CPlugins * Plugins, CN64System * System); - DWORD(__cdecl *DoRspCycles) (DWORD); - void(__cdecl *EnableDebugging)(BOOL Enable); + uint32_t(__cdecl *DoRspCycles) (uint32_t); + void(__cdecl *EnableDebugging)(int32_t Enable); - HMENU GetDebugMenu (void ) { return m_RSPDebug.hRSPMenu; } - void ProcessMenuItem(int id); + void * GetDebugMenu(void) { return m_RSPDebug.hRSPMenu; } + void ProcessMenuItem(int32_t id); private: - CRSP_Plugin(const CRSP_Plugin&); // Disable copy constructor - CRSP_Plugin& operator=(const CRSP_Plugin&); // Disable assignment + CRSP_Plugin(const CRSP_Plugin&); // Disable copy constructor + CRSP_Plugin& operator=(const CRSP_Plugin&); // Disable assignment - PLUGIN_TYPE type() { return PLUGIN_TYPE_RSP; } - virtual int GetDefaultSettingStartRange() const { return FirstRSPDefaultSet; } - virtual int GetSettingStartRange() const { return FirstRSPSettings; } + PLUGIN_TYPE type() { return PLUGIN_TYPE_RSP; } + virtual int32_t GetDefaultSettingStartRange() const { return FirstRSPDefaultSet; } + virtual int32_t GetSettingStartRange() const { return FirstRSPSettings; } - bool LoadFunctions ( void ); - void UnloadPluginDetails ( void ); + bool LoadFunctions(void); + void UnloadPluginDetails(void); - RSPDEBUG_INFO m_RSPDebug; - DWORD m_CycleCount; + RSPDEBUG_INFO m_RSPDebug; + uint32_t m_CycleCount; - void(__cdecl *GetDebugInfo) (RSPDEBUG_INFO * GFXDebugInfo); - void(__cdecl *InitiateDebugger) (DEBUG_INFO DebugInfo); + void(__cdecl *GetDebugInfo) (RSPDEBUG_INFO * GFXDebugInfo); + void(__cdecl *InitiateDebugger) (DEBUG_INFO DebugInfo); }; From 568226d5ffbea20c56776824236d8151f4dd5721 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sun, 8 Nov 2015 17:20:04 +1100 Subject: [PATCH 084/213] [Project64] Remove Delay Slot Map Class.h and Exit Info.cpp --- Source/Project64/N64 System.h | 1 - .../Recompiler/Delay Slot Map Class.h | 29 ------------------- .../N64 System/Recompiler/Exit Info.cpp | 0 3 files changed, 30 deletions(-) delete mode 100644 Source/Project64/N64 System/Recompiler/Delay Slot Map Class.h delete mode 100644 Source/Project64/N64 System/Recompiler/Exit Info.cpp diff --git a/Source/Project64/N64 System.h b/Source/Project64/N64 System.h index 2b37e1ca3..db180e08f 100644 --- a/Source/Project64/N64 System.h +++ b/Source/Project64/N64 System.h @@ -65,7 +65,6 @@ class CNotification; #include "N64 System/Recompiler/Section Info.h" #include "N64 System/Recompiler/Function Info.h" #include "N64 System/Recompiler/Function Map Class.h" -#include "N64 System/Recompiler/Delay Slot Map Class.h" #include "N64 System/Recompiler/Recompiler Class.h" #include "N64 System/Recompiler/x86CodeLog.h" diff --git a/Source/Project64/N64 System/Recompiler/Delay Slot Map Class.h b/Source/Project64/N64 System/Recompiler/Delay Slot Map Class.h deleted file mode 100644 index d68152166..000000000 --- a/Source/Project64/N64 System/Recompiler/Delay Slot Map Class.h +++ /dev/null @@ -1,29 +0,0 @@ -/**************************************************************************** -* * -* Project 64 - A Nintendo 64 emulator. * -* http://www.pj64-emu.com/ * -* Copyright (C) 2012 Project64. All rights reserved. * -* * -* License: * -* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * -* * -****************************************************************************/ -#pragma once - -class CDelaySlotFunctionMap -{ - typedef std::map FUNCTION_MAP; - - FUNCTION_MAP FunctionMap; - -public: - CDelaySlotFunctionMap(); - ~CDelaySlotFunctionMap(); - - CCompiledFunc* AddFunctionInfo(DWORD vAddr, DWORD pAddr); - CCompiledFunc* FindFunction(DWORD vAddr, int Length); - CCompiledFunc* FindFunction(DWORD vAddr) const; - - void Remove(CCompiledFunc* info); - void Reset(); -}; diff --git a/Source/Project64/N64 System/Recompiler/Exit Info.cpp b/Source/Project64/N64 System/Recompiler/Exit Info.cpp deleted file mode 100644 index e69de29bb..000000000 From 786be5b0621a1348022720ba151f9a3923a1fccb Mon Sep 17 00:00:00 2001 From: zilmar Date: Sun, 8 Nov 2015 17:45:43 +1100 Subject: [PATCH 085/213] [Project64] Move Logging.cpp/h out of c core folder --- .../{N64 System/C Core => }/Logging.cpp | 0 .../Project64/{N64 System/C Core => }/Logging.h | 0 Source/Project64/N64 System.h | 2 -- .../N64 System/Interpreter/Interpreter Ops.cpp | 1 - Source/Project64/Project64.vcproj | 16 ++++++++-------- Source/Project64/User Interface/Gui Class.cpp | 5 +---- Source/Project64/stdafx.h | 1 + 7 files changed, 10 insertions(+), 15 deletions(-) rename Source/Project64/{N64 System/C Core => }/Logging.cpp (100%) rename Source/Project64/{N64 System/C Core => }/Logging.h (100%) diff --git a/Source/Project64/N64 System/C Core/Logging.cpp b/Source/Project64/Logging.cpp similarity index 100% rename from Source/Project64/N64 System/C Core/Logging.cpp rename to Source/Project64/Logging.cpp diff --git a/Source/Project64/N64 System/C Core/Logging.h b/Source/Project64/Logging.h similarity index 100% rename from Source/Project64/N64 System/C Core/Logging.h rename to Source/Project64/Logging.h diff --git a/Source/Project64/N64 System.h b/Source/Project64/N64 System.h index db180e08f..613213a57 100644 --- a/Source/Project64/N64 System.h +++ b/Source/Project64/N64 System.h @@ -45,7 +45,6 @@ class CNotification; //C Core - to be upgrdaded and removed #include "N64 System/C Core/r4300i Commands.h" -#include "N64 System/C Core/Logging.h" //Interpter #include "N64 System/Interpreter/Interpreter Ops.h" @@ -77,4 +76,3 @@ class CNotification; //Main Files #include "N64 System/N64 Class.h" #include "N64 System/System Globals.h" - diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp index cbdce8121..e7cc0d817 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp @@ -9,7 +9,6 @@ * * ****************************************************************************/ #include "stdafx.h" -#include "../C Core/Logging.h" void InPermLoop(); void TestInterpreterJump(DWORD PC, DWORD TargetPC, int Reg1, int Reg2); diff --git a/Source/Project64/Project64.vcproj b/Source/Project64/Project64.vcproj index 018e4541d..7be04938f 100644 --- a/Source/Project64/Project64.vcproj +++ b/Source/Project64/Project64.vcproj @@ -145,6 +145,10 @@ Name="Source Files" Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" > + + @@ -511,10 +515,6 @@ - - @@ -789,6 +789,10 @@ Name="Header Files" Filter="h;hpp;hxx;hm;inl" > + + @@ -1183,10 +1187,6 @@ - - diff --git a/Source/Project64/User Interface/Gui Class.cpp b/Source/Project64/User Interface/Gui Class.cpp index 53671c945..e60f3754c 100644 --- a/Source/Project64/User Interface/Gui Class.cpp +++ b/Source/Project64/User Interface/Gui Class.cpp @@ -13,10 +13,7 @@ #include #include "Settings/SettingType/SettingsType-Application.h" -extern "C" -{ - void EnterLogOptions(HWND hwndOwner); -} +void EnterLogOptions(HWND hwndOwner); #pragma comment(lib, "Comctl32.lib") diff --git a/Source/Project64/stdafx.h b/Source/Project64/stdafx.h index 2c0f1950b..85725f863 100644 --- a/Source/Project64/stdafx.h +++ b/Source/Project64/stdafx.h @@ -20,6 +20,7 @@ #include #include "Multilanguage.h" #include "User Interface.h" +#include "Logging.h" #include "N64 System.h" #include "Plugin.h" #include "Support.h" From 4ac266bd9425f6e16f28c13b9d6f290154f16e7e Mon Sep 17 00:00:00 2001 From: zilmar Date: Sun, 8 Nov 2015 20:17:13 +1100 Subject: [PATCH 086/213] [Projet64] Move logging class and clean up code --- PropertySheets/Platform.props | 2 +- Source/Project64/Logging.cpp | 1297 ++++++++--------- Source/Project64/Logging.h | 77 +- .../Interpreter/Interpreter Ops 32.cpp | 6 +- .../Interpreter/Interpreter Ops.cpp | 10 +- Source/Project64/N64 System/Mips/Pif Ram.cpp | 12 +- .../N64 System/Mips/Register Class.cpp | 2 +- Source/Project64/N64 System/N64 Class.cpp | 4 +- Source/Project64/Project64.vcxproj | 4 +- Source/Project64/Project64.vcxproj.filters | 12 +- 10 files changed, 709 insertions(+), 717 deletions(-) diff --git a/PropertySheets/Platform.props b/PropertySheets/Platform.props index 3487ef34c..b905993fe 100644 --- a/PropertySheets/Platform.props +++ b/PropertySheets/Platform.props @@ -2,7 +2,7 @@ - v140_xp + v120_xp diff --git a/Source/Project64/Logging.cpp b/Source/Project64/Logging.cpp index 3247ccca5..1f4180560 100644 --- a/Source/Project64/Logging.cpp +++ b/Source/Project64/Logging.cpp @@ -12,15 +12,15 @@ #include -void LoadLogSetting (HKEY hKey,char * String, BOOL * Value); +void LoadLogSetting (HKEY hKey,char * String, bool * Value); void SaveLogOptions (void); LRESULT CALLBACK LogGeneralProc ( HWND, UINT, WPARAM, LPARAM ); LRESULT CALLBACK LogPifProc ( HWND, UINT, WPARAM, LPARAM ); LRESULT CALLBACK LogRegProc ( HWND, UINT, WPARAM, LPARAM ); -LOG_OPTIONS LogOptions,TempOptions; -HANDLE hLogFile = NULL; +static HANDLE g_hLogFile = NULL; +LOG_OPTIONS g_LogOptions, TempOptions; void EnterLogOptions(HWND hwndOwner) { @@ -71,96 +71,96 @@ void EnterLogOptions(HWND hwndOwner) g_Notify -> BreakPoint(__FILEW__, __LINE__); #endif SaveLogOptions(); - LoadLogOptions(&LogOptions, FALSE); + LoadLogOptions(&g_LogOptions, FALSE); return; } -void LoadLogOptions (LOG_OPTIONS * LogOptions, BOOL AlwaysFill) +void LoadLogOptions (LOG_OPTIONS * LogOptions, bool AlwaysFill) { - long lResult; - HKEY hKeyResults = 0; - char String[200]; + int32_t lResult; + HKEY hKeyResults = 0; + char String[200]; - sprintf(String,"Software\\N64 Emulation\\%s\\Logging",g_Settings->LoadStringVal(Setting_ApplicationName).c_str()); - lResult = RegOpenKeyEx( HKEY_CURRENT_USER,String,0,KEY_ALL_ACCESS, - &hKeyResults); - - if (lResult == ERROR_SUCCESS) - { - //LoadLogSetting(hKeyResults,"Generate Log File",&LogOptions->GenerateLog); - if (LogOptions->GenerateLog || AlwaysFill) - { - LoadLogSetting(hKeyResults,"Log RDRAM",&LogOptions->LogRDRamRegisters); - LoadLogSetting(hKeyResults,"Log SP",&LogOptions->LogSPRegisters); - LoadLogSetting(hKeyResults,"Log DP Command",&LogOptions->LogDPCRegisters); - LoadLogSetting(hKeyResults,"Log DP Span",&LogOptions->LogDPSRegisters); - LoadLogSetting(hKeyResults,"Log MIPS Interface (MI)",&LogOptions->LogMIPSInterface); - LoadLogSetting(hKeyResults,"Log Video Interface (VI)",&LogOptions->LogVideoInterface); - LoadLogSetting(hKeyResults,"Log Audio Interface (AI)",&LogOptions->LogAudioInterface); - LoadLogSetting(hKeyResults,"Log Peripheral Interface (PI)",&LogOptions->LogPerInterface); - LoadLogSetting(hKeyResults,"Log RDRAM Interface (RI)",&LogOptions->LogRDRAMInterface); - LoadLogSetting(hKeyResults,"Log Serial Interface (SI)",&LogOptions->LogSerialInterface); - LoadLogSetting(hKeyResults,"Log PifRam DMA Operations",&LogOptions->LogPRDMAOperations); - LoadLogSetting(hKeyResults,"Log PifRam Direct Memory Loads",&LogOptions->LogPRDirectMemLoads); - LoadLogSetting(hKeyResults,"Log PifRam DMA Memory Loads",&LogOptions->LogPRDMAMemLoads); - LoadLogSetting(hKeyResults,"Log PifRam Direct Memory Stores",&LogOptions->LogPRDirectMemStores); - LoadLogSetting(hKeyResults,"Log PifRam DMA Memory Stores",&LogOptions->LogPRDMAMemStores); - LoadLogSetting(hKeyResults,"Log Controller Pak",&LogOptions->LogControllerPak); - LoadLogSetting(hKeyResults,"Log CP0 changes",&LogOptions->LogCP0changes); - LoadLogSetting(hKeyResults,"Log CP0 reads",&LogOptions->LogCP0reads); - LoadLogSetting(hKeyResults,"Log Exceptions",&LogOptions->LogExceptions); - LoadLogSetting(hKeyResults,"No Interrupts",&LogOptions->NoInterrupts); - LoadLogSetting(hKeyResults,"Log TLB",&LogOptions->LogTLB); - LoadLogSetting(hKeyResults,"Log Cache Operations",&LogOptions->LogCache); - LoadLogSetting(hKeyResults,"Log Rom Header",&LogOptions->LogRomHeader); - LoadLogSetting(hKeyResults,"Log Unknown access",&LogOptions->LogUnknown); - return; - } - } + sprintf(String,"Software\\N64 Emulation\\%s\\Logging",g_Settings->LoadStringVal(Setting_ApplicationName).c_str()); + lResult = RegOpenKeyEx( HKEY_CURRENT_USER,String,0,KEY_ALL_ACCESS, + &hKeyResults); - LogOptions->GenerateLog = FALSE; - LogOptions->LogRDRamRegisters = FALSE; - LogOptions->LogSPRegisters = FALSE; - LogOptions->LogDPCRegisters = FALSE; - LogOptions->LogDPSRegisters = FALSE; - LogOptions->LogMIPSInterface = FALSE; - LogOptions->LogVideoInterface = FALSE; - LogOptions->LogAudioInterface = FALSE; - LogOptions->LogPerInterface = FALSE; - LogOptions->LogRDRAMInterface = FALSE; - LogOptions->LogSerialInterface = FALSE; - - LogOptions->LogPRDMAOperations = FALSE; - LogOptions->LogPRDirectMemLoads = FALSE; - LogOptions->LogPRDMAMemLoads = FALSE; - LogOptions->LogPRDirectMemStores = FALSE; - LogOptions->LogPRDMAMemStores = FALSE; - LogOptions->LogControllerPak = FALSE; - - LogOptions->LogCP0changes = FALSE; - LogOptions->LogCP0reads = FALSE; - LogOptions->LogCache = FALSE; - LogOptions->LogExceptions = FALSE; - LogOptions->NoInterrupts = FALSE; - LogOptions->LogTLB = FALSE; - LogOptions->LogRomHeader = FALSE; - LogOptions->LogUnknown = FALSE; + if (lResult == ERROR_SUCCESS) + { + //LoadLogSetting(hKeyResults,"Generate Log File",&LogOptions->GenerateLog); + if (LogOptions->GenerateLog || AlwaysFill) + { + LoadLogSetting(hKeyResults,"Log RDRAM",&LogOptions->LogRDRamRegisters); + LoadLogSetting(hKeyResults,"Log SP",&LogOptions->LogSPRegisters); + LoadLogSetting(hKeyResults,"Log DP Command",&LogOptions->LogDPCRegisters); + LoadLogSetting(hKeyResults,"Log DP Span",&LogOptions->LogDPSRegisters); + LoadLogSetting(hKeyResults,"Log MIPS Interface (MI)",&LogOptions->LogMIPSInterface); + LoadLogSetting(hKeyResults,"Log Video Interface (VI)",&LogOptions->LogVideoInterface); + LoadLogSetting(hKeyResults,"Log Audio Interface (AI)",&LogOptions->LogAudioInterface); + LoadLogSetting(hKeyResults,"Log Peripheral Interface (PI)",&LogOptions->LogPerInterface); + LoadLogSetting(hKeyResults,"Log RDRAM Interface (RI)",&LogOptions->LogRDRAMInterface); + LoadLogSetting(hKeyResults,"Log Serial Interface (SI)",&LogOptions->LogSerialInterface); + LoadLogSetting(hKeyResults,"Log PifRam DMA Operations",&LogOptions->LogPRDMAOperations); + LoadLogSetting(hKeyResults,"Log PifRam Direct Memory Loads",&LogOptions->LogPRDirectMemLoads); + LoadLogSetting(hKeyResults,"Log PifRam DMA Memory Loads",&LogOptions->LogPRDMAMemLoads); + LoadLogSetting(hKeyResults,"Log PifRam Direct Memory Stores",&LogOptions->LogPRDirectMemStores); + LoadLogSetting(hKeyResults,"Log PifRam DMA Memory Stores",&LogOptions->LogPRDMAMemStores); + LoadLogSetting(hKeyResults,"Log Controller Pak",&LogOptions->LogControllerPak); + LoadLogSetting(hKeyResults,"Log CP0 changes",&LogOptions->LogCP0changes); + LoadLogSetting(hKeyResults,"Log CP0 reads",&LogOptions->LogCP0reads); + LoadLogSetting(hKeyResults,"Log Exceptions",&LogOptions->LogExceptions); + LoadLogSetting(hKeyResults,"No Interrupts",&LogOptions->NoInterrupts); + LoadLogSetting(hKeyResults,"Log TLB",&LogOptions->LogTLB); + LoadLogSetting(hKeyResults,"Log Cache Operations",&LogOptions->LogCache); + LoadLogSetting(hKeyResults,"Log Rom Header",&LogOptions->LogRomHeader); + LoadLogSetting(hKeyResults,"Log Unknown access",&LogOptions->LogUnknown); + return; + } + } + + LogOptions->GenerateLog = FALSE; + LogOptions->LogRDRamRegisters = FALSE; + LogOptions->LogSPRegisters = FALSE; + LogOptions->LogDPCRegisters = FALSE; + LogOptions->LogDPSRegisters = FALSE; + LogOptions->LogMIPSInterface = FALSE; + LogOptions->LogVideoInterface = FALSE; + LogOptions->LogAudioInterface = FALSE; + LogOptions->LogPerInterface = FALSE; + LogOptions->LogRDRAMInterface = FALSE; + LogOptions->LogSerialInterface = FALSE; + + LogOptions->LogPRDMAOperations = FALSE; + LogOptions->LogPRDirectMemLoads = FALSE; + LogOptions->LogPRDMAMemLoads = FALSE; + LogOptions->LogPRDirectMemStores = FALSE; + LogOptions->LogPRDMAMemStores = FALSE; + LogOptions->LogControllerPak = FALSE; + + LogOptions->LogCP0changes = FALSE; + LogOptions->LogCP0reads = FALSE; + LogOptions->LogCache = FALSE; + LogOptions->LogExceptions = FALSE; + LogOptions->NoInterrupts = FALSE; + LogOptions->LogTLB = FALSE; + LogOptions->LogRomHeader = FALSE; + LogOptions->LogUnknown = FALSE; } -void LoadLogSetting (HKEY hKey,char * String, BOOL * Value) +void LoadLogSetting (HKEY hKey,char * String, bool * Value) { - DWORD Type, dwResult, Bytes = 4; - long lResult; + DWORD Type, dwResult, Bytes = 4; + int32_t lResult; - lResult = RegQueryValueEx(hKey,String,0,&Type,(LPBYTE)(&dwResult),&Bytes); - if (Type == REG_DWORD && lResult == ERROR_SUCCESS) - { - *Value = (BOOL)dwResult; - } - else - { - *Value = FALSE; - } + lResult = RegQueryValueEx(hKey,String,0,&Type,(LPBYTE)(&dwResult),&Bytes); + if (Type == REG_DWORD && lResult == ERROR_SUCCESS) + { + *Value = dwResult != 0; + } + else + { + *Value = FALSE; + } } LRESULT CALLBACK LogGeneralProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam) @@ -194,586 +194,562 @@ LRESULT CALLBACK LogGeneralProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM return TRUE; } -void Log_LW (DWORD PC, DWORD VAddr) +void Log_LW (uint32_t PC, uint32_t VAddr) { - if (!LogOptions.GenerateLog) - { - return; - } + if (!g_LogOptions.GenerateLog) + { + return; + } - if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 ) - { - DWORD PAddr; - if (!g_TransVaddr->TranslateVaddr(VAddr,PAddr)) - { - if (LogOptions.LogUnknown) - { - LogMessage("%08X: read from unknown ??? (%08X)",PC,VAddr); - } - return; - } - VAddr = PAddr + 0xA0000000; - } - - DWORD Value; - if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize())) - { - return; - } - if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) - { - if (!LogOptions.LogRDRamRegisters) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); + if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 ) + { + uint32_t PAddr; + if (!g_TransVaddr->TranslateVaddr(VAddr,(DWORD &)PAddr)) + { + if (g_LogOptions.LogUnknown) + { + LogMessage("%08X: read from unknown ??? (%08X)",PC,VAddr); + } + return; + } + VAddr = PAddr + 0xA0000000; + } - switch (VAddr) - { - case 0xA3F00000: LogMessage("%08X: read from RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG (%08X)",PC, Value); return; - case 0xA3F00004: LogMessage("%08X: read from RDRAM_DEVICE_ID_REG (%08X)",PC, Value); return; - case 0xA3F00008: LogMessage("%08X: read from RDRAM_DELAY_REG (%08X)",PC, Value); return; - case 0xA3F0000C: LogMessage("%08X: read from RDRAM_MODE_REG (%08X)",PC, Value); return; - case 0xA3F00010: LogMessage("%08X: read from RDRAM_REF_INTERVAL_REG (%08X)",PC, Value); return; - case 0xA3F00014: LogMessage("%08X: read from RDRAM_REF_ROW_REG (%08X)",PC, Value); return; - case 0xA3F00018: LogMessage("%08X: read from RDRAM_RAS_INTERVAL_REG (%08X)",PC, Value); return; - case 0xA3F0001C: LogMessage("%08X: read from RDRAM_MIN_INTERVAL_REG (%08X)",PC, Value); return; - case 0xA3F00020: LogMessage("%08X: read from RDRAM_ADDR_SELECT_REG (%08X)",PC, Value); return; - case 0xA3F00024: LogMessage("%08X: read from RDRAM_DEVICE_MANUF_REG (%08X)",PC, Value); return; - } - } + uint32_t Value; + if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize())) + { + return; + } + if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) + { + if (!g_LogOptions.LogRDRamRegisters) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); - if ( VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC ) - { - return; - } - if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C ) - { - if (!LogOptions.LogSPRegisters) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); + switch (VAddr) + { + case 0xA3F00000: LogMessage("%08X: read from RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG (%08X)",PC, Value); return; + case 0xA3F00004: LogMessage("%08X: read from RDRAM_DEVICE_ID_REG (%08X)",PC, Value); return; + case 0xA3F00008: LogMessage("%08X: read from RDRAM_DELAY_REG (%08X)",PC, Value); return; + case 0xA3F0000C: LogMessage("%08X: read from RDRAM_MODE_REG (%08X)",PC, Value); return; + case 0xA3F00010: LogMessage("%08X: read from RDRAM_REF_INTERVAL_REG (%08X)",PC, Value); return; + case 0xA3F00014: LogMessage("%08X: read from RDRAM_REF_ROW_REG (%08X)",PC, Value); return; + case 0xA3F00018: LogMessage("%08X: read from RDRAM_RAS_INTERVAL_REG (%08X)",PC, Value); return; + case 0xA3F0001C: LogMessage("%08X: read from RDRAM_MIN_INTERVAL_REG (%08X)",PC, Value); return; + case 0xA3F00020: LogMessage("%08X: read from RDRAM_ADDR_SELECT_REG (%08X)",PC, Value); return; + case 0xA3F00024: LogMessage("%08X: read from RDRAM_DEVICE_MANUF_REG (%08X)",PC, Value); return; + } + } - switch (VAddr) - { - case 0xA4040000: LogMessage("%08X: read from SP_MEM_ADDR_REG (%08X)",PC, Value); break; - case 0xA4040004: LogMessage("%08X: read from SP_DRAM_ADDR_REG (%08X)",PC, Value); break; - case 0xA4040008: LogMessage("%08X: read from SP_RD_LEN_REG (%08X)",PC, Value); break; - case 0xA404000C: LogMessage("%08X: read from SP_WR_LEN_REG (%08X)",PC, Value); break; - case 0xA4040010: LogMessage("%08X: read from SP_STATUS_REG (%08X)",PC, Value); break; - case 0xA4040014: LogMessage("%08X: read from SP_DMA_FULL_REG (%08X)",PC, Value); break; - case 0xA4040018: LogMessage("%08X: read from SP_DMA_BUSY_REG (%08X)",PC, Value); break; - case 0xA404001C: LogMessage("%08X: read from SP_SEMAPHORE_REG (%08X)",PC, Value); break; - } - return; - } - if ( VAddr == 0xA4080000) - { - if (!LogOptions.LogSPRegisters) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - LogMessage("%08X: read from SP_PC (%08X)",PC, Value); - return; - } - if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C) - { - if (!LogOptions.LogDPCRegisters) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); + if ( VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC ) + { + return; + } + if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C ) + { + if (!g_LogOptions.LogSPRegisters) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); - switch (VAddr) - { - case 0xA4100000: LogMessage("%08X: read from DPC_START_REG (%08X)",PC, Value); return; - case 0xA4100004: LogMessage("%08X: read from DPC_END_REG (%08X)",PC, Value); return; - case 0xA4100008: LogMessage("%08X: read from DPC_CURRENT_REG (%08X)",PC, Value); return; - case 0xA410000C: LogMessage("%08X: read from DPC_STATUS_REG (%08X)",PC, Value); return; - case 0xA4100010: LogMessage("%08X: read from DPC_CLOCK_REG (%08X)",PC, Value); return; - case 0xA4100014: LogMessage("%08X: read from DPC_BUFBUSY_REG (%08X)",PC, Value); return; - case 0xA4100018: LogMessage("%08X: read from DPC_PIPEBUSY_REG (%08X)",PC, Value); return; - case 0xA410001C: LogMessage("%08X: read from DPC_TMEM_REG (%08X)",PC, Value); return; - } - } - if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C) - { - if (!LogOptions.LogMIPSInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); + switch (VAddr) + { + case 0xA4040000: LogMessage("%08X: read from SP_MEM_ADDR_REG (%08X)",PC, Value); break; + case 0xA4040004: LogMessage("%08X: read from SP_DRAM_ADDR_REG (%08X)",PC, Value); break; + case 0xA4040008: LogMessage("%08X: read from SP_RD_LEN_REG (%08X)",PC, Value); break; + case 0xA404000C: LogMessage("%08X: read from SP_WR_LEN_REG (%08X)",PC, Value); break; + case 0xA4040010: LogMessage("%08X: read from SP_STATUS_REG (%08X)",PC, Value); break; + case 0xA4040014: LogMessage("%08X: read from SP_DMA_FULL_REG (%08X)",PC, Value); break; + case 0xA4040018: LogMessage("%08X: read from SP_DMA_BUSY_REG (%08X)",PC, Value); break; + case 0xA404001C: LogMessage("%08X: read from SP_SEMAPHORE_REG (%08X)",PC, Value); break; + } + return; + } + if ( VAddr == 0xA4080000) + { + if (!g_LogOptions.LogSPRegisters) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + LogMessage("%08X: read from SP_PC (%08X)",PC, Value); + return; + } + if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C) + { + if (!g_LogOptions.LogDPCRegisters) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); - switch (VAddr) - { - case 0xA4300000: LogMessage("%08X: read from MI_INIT_MODE_REG/MI_MODE_REG (%08X)",PC, Value); return; - case 0xA4300004: LogMessage("%08X: read from MI_VERSION_REG/MI_NOOP_REG (%08X)",PC, Value); return; - case 0xA4300008: LogMessage("%08X: read from MI_INTR_REG (%08X)",PC, Value); return; - case 0xA430000C: LogMessage("%08X: read from MI_INTR_MASK_REG (%08X)",PC, Value); return; - } - } - if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034) - { - if (!LogOptions.LogVideoInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); + switch (VAddr) + { + case 0xA4100000: LogMessage("%08X: read from DPC_START_REG (%08X)",PC, Value); return; + case 0xA4100004: LogMessage("%08X: read from DPC_END_REG (%08X)",PC, Value); return; + case 0xA4100008: LogMessage("%08X: read from DPC_CURRENT_REG (%08X)",PC, Value); return; + case 0xA410000C: LogMessage("%08X: read from DPC_STATUS_REG (%08X)",PC, Value); return; + case 0xA4100010: LogMessage("%08X: read from DPC_CLOCK_REG (%08X)",PC, Value); return; + case 0xA4100014: LogMessage("%08X: read from DPC_BUFBUSY_REG (%08X)",PC, Value); return; + case 0xA4100018: LogMessage("%08X: read from DPC_PIPEBUSY_REG (%08X)",PC, Value); return; + case 0xA410001C: LogMessage("%08X: read from DPC_TMEM_REG (%08X)",PC, Value); return; + } + } + if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C) + { + if (!g_LogOptions.LogMIPSInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); - switch (VAddr) - { - case 0xA4400000: LogMessage("%08X: read from VI_STATUS_REG/VI_CONTROL_REG (%08X)",PC, Value); return; - case 0xA4400004: LogMessage("%08X: read from VI_ORIGIN_REG/VI_DRAM_ADDR_REG (%08X)",PC, Value); return; - case 0xA4400008: LogMessage("%08X: read from VI_WIDTH_REG/VI_H_WIDTH_REG (%08X)",PC, Value); return; - case 0xA440000C: LogMessage("%08X: read from VI_INTR_REG/VI_V_INTR_REG (%08X)",PC, Value); return; - case 0xA4400010: LogMessage("%08X: read from VI_CURRENT_REG/VI_V_CURRENT_LINE_REG (%08X)",PC, Value); return; - case 0xA4400014: LogMessage("%08X: read from VI_BURST_REG/VI_TIMING_REG (%08X)",PC, Value); return; - case 0xA4400018: LogMessage("%08X: read from VI_V_SYNC_REG (%08X)",PC, Value); return; - case 0xA440001C: LogMessage("%08X: read from VI_H_SYNC_REG (%08X)",PC, Value); return; - case 0xA4400020: LogMessage("%08X: read from VI_LEAP_REG/VI_H_SYNC_LEAP_REG (%08X)",PC, Value); return; - case 0xA4400024: LogMessage("%08X: read from VI_H_START_REG/VI_H_VIDEO_REG (%08X)",PC, Value); return; - case 0xA4400028: LogMessage("%08X: read from VI_V_START_REG/VI_V_VIDEO_REG (%08X)",PC, Value); return; - case 0xA440002C: LogMessage("%08X: read from VI_V_BURST_REG (%08X)",PC, Value); return; - case 0xA4400030: LogMessage("%08X: read from VI_X_SCALE_REG (%08X)",PC, Value); return; - case 0xA4400034: LogMessage("%08X: read from VI_Y_SCALE_REG (%08X)",PC, Value); return; - } - } - if (VAddr >= 0xA4500000 && VAddr <= 0xA4500014) - { - if (!LogOptions.LogAudioInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); + switch (VAddr) + { + case 0xA4300000: LogMessage("%08X: read from MI_INIT_MODE_REG/MI_MODE_REG (%08X)",PC, Value); return; + case 0xA4300004: LogMessage("%08X: read from MI_VERSION_REG/MI_NOOP_REG (%08X)",PC, Value); return; + case 0xA4300008: LogMessage("%08X: read from MI_INTR_REG (%08X)",PC, Value); return; + case 0xA430000C: LogMessage("%08X: read from MI_INTR_MASK_REG (%08X)",PC, Value); return; + } + } + if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034) + { + if (!g_LogOptions.LogVideoInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); - switch (VAddr) - { - case 0xA4500000: LogMessage("%08X: read from AI_DRAM_ADDR_REG (%08X)",PC, Value); return; - case 0xA4500004: LogMessage("%08X: read from AI_LEN_REG (%08X)",PC, Value); return; - case 0xA4500008: LogMessage("%08X: read from AI_CONTROL_REG (%08X)",PC, Value); return; - case 0xA450000C: LogMessage("%08X: read from AI_STATUS_REG (%08X)",PC, Value); return; - case 0xA4500010: LogMessage("%08X: read from AI_DACRATE_REG (%08X)",PC, Value); return; - case 0xA4500014: LogMessage("%08X: read from AI_BITRATE_REG (%08X)",PC, Value); return; - } - } - if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030) - { - if (!LogOptions.LogPerInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); + switch (VAddr) + { + case 0xA4400000: LogMessage("%08X: read from VI_STATUS_REG/VI_CONTROL_REG (%08X)",PC, Value); return; + case 0xA4400004: LogMessage("%08X: read from VI_ORIGIN_REG/VI_DRAM_ADDR_REG (%08X)",PC, Value); return; + case 0xA4400008: LogMessage("%08X: read from VI_WIDTH_REG/VI_H_WIDTH_REG (%08X)",PC, Value); return; + case 0xA440000C: LogMessage("%08X: read from VI_INTR_REG/VI_V_INTR_REG (%08X)",PC, Value); return; + case 0xA4400010: LogMessage("%08X: read from VI_CURRENT_REG/VI_V_CURRENT_LINE_REG (%08X)",PC, Value); return; + case 0xA4400014: LogMessage("%08X: read from VI_BURST_REG/VI_TIMING_REG (%08X)",PC, Value); return; + case 0xA4400018: LogMessage("%08X: read from VI_V_SYNC_REG (%08X)",PC, Value); return; + case 0xA440001C: LogMessage("%08X: read from VI_H_SYNC_REG (%08X)",PC, Value); return; + case 0xA4400020: LogMessage("%08X: read from VI_LEAP_REG/VI_H_SYNC_LEAP_REG (%08X)",PC, Value); return; + case 0xA4400024: LogMessage("%08X: read from VI_H_START_REG/VI_H_VIDEO_REG (%08X)",PC, Value); return; + case 0xA4400028: LogMessage("%08X: read from VI_V_START_REG/VI_V_VIDEO_REG (%08X)",PC, Value); return; + case 0xA440002C: LogMessage("%08X: read from VI_V_BURST_REG (%08X)",PC, Value); return; + case 0xA4400030: LogMessage("%08X: read from VI_X_SCALE_REG (%08X)",PC, Value); return; + case 0xA4400034: LogMessage("%08X: read from VI_Y_SCALE_REG (%08X)",PC, Value); return; + } + } + if (VAddr >= 0xA4500000 && VAddr <= 0xA4500014) + { + if (!g_LogOptions.LogAudioInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); - switch (VAddr) - { - case 0xA4600000: LogMessage("%08X: read from PI_DRAM_ADDR_REG (%08X)",PC, Value); return; - case 0xA4600004: LogMessage("%08X: read from PI_CART_ADDR_REG (%08X)",PC, Value); return; - case 0xA4600008: LogMessage("%08X: read from PI_RD_LEN_REG (%08X)",PC, Value); return; - case 0xA460000C: LogMessage("%08X: read from PI_WR_LEN_REG (%08X)",PC, Value); return; - case 0xA4600010: LogMessage("%08X: read from PI_STATUS_REG (%08X)",PC, Value); return; - case 0xA4600014: LogMessage("%08X: read from PI_BSD_DOM1_LAT_REG/PI_DOMAIN1_REG (%08X)",PC, Value); return; - case 0xA4600018: LogMessage("%08X: read from PI_BSD_DOM1_PWD_REG (%08X)",PC, Value); return; - case 0xA460001C: LogMessage("%08X: read from PI_BSD_DOM1_PGS_REG (%08X)",PC, Value); return; - case 0xA4600020: LogMessage("%08X: read from PI_BSD_DOM1_RLS_REG (%08X)",PC, Value); return; - case 0xA4600024: LogMessage("%08X: read from PI_BSD_DOM2_LAT_REG/PI_DOMAIN2_REG (%08X)",PC, Value); return; - case 0xA4600028: LogMessage("%08X: read from PI_BSD_DOM2_PWD_REG (%08X)",PC, Value); return; - case 0xA460002C: LogMessage("%08X: read from PI_BSD_DOM2_PGS_REG (%08X)",PC, Value); return; - case 0xA4600030: LogMessage("%08X: read from PI_BSD_DOM2_RLS_REG (%08X)",PC, Value); return; - } - } - if (VAddr >= 0xA4700000 && VAddr <= 0xA470001C) - { - if (!LogOptions.LogRDRAMInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); + switch (VAddr) + { + case 0xA4500000: LogMessage("%08X: read from AI_DRAM_ADDR_REG (%08X)",PC, Value); return; + case 0xA4500004: LogMessage("%08X: read from AI_LEN_REG (%08X)",PC, Value); return; + case 0xA4500008: LogMessage("%08X: read from AI_CONTROL_REG (%08X)",PC, Value); return; + case 0xA450000C: LogMessage("%08X: read from AI_STATUS_REG (%08X)",PC, Value); return; + case 0xA4500010: LogMessage("%08X: read from AI_DACRATE_REG (%08X)",PC, Value); return; + case 0xA4500014: LogMessage("%08X: read from AI_BITRATE_REG (%08X)",PC, Value); return; + } + } + if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030) + { + if (!g_LogOptions.LogPerInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); - switch (VAddr) - { - case 0xA4700000: LogMessage("%08X: read from RI_MODE_REG (%08X)",PC, Value); return; - case 0xA4700004: LogMessage("%08X: read from RI_CONFIG_REG (%08X)",PC, Value); return; - case 0xA4700008: LogMessage("%08X: read from RI_CURRENT_LOAD_REG (%08X)",PC, Value); return; - case 0xA470000C: LogMessage("%08X: read from RI_SELECT_REG (%08X)",PC, Value); return; - case 0xA4700010: LogMessage("%08X: read from RI_REFRESH_REG/RI_COUNT_REG (%08X)",PC, Value); return; - case 0xA4700014: LogMessage("%08X: read from RI_LATENCY_REG (%08X)",PC, Value); return; - case 0xA4700018: LogMessage("%08X: read from RI_RERROR_REG (%08X)",PC, Value); return; - case 0xA470001C: LogMessage("%08X: read from RI_WERROR_REG (%08X)",PC, Value); return; - } - } - if ( VAddr == 0xA4800000) - { - if (!LogOptions.LogSerialInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - LogMessage("%08X: read from SI_DRAM_ADDR_REG (%08X)",PC, Value); - return; - } - if ( VAddr == 0xA4800004) - { - if (!LogOptions.LogSerialInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - LogMessage("%08X: read from SI_PIF_ADDR_RD64B_REG (%08X)",PC, Value); - return; - } - if ( VAddr == 0xA4800010) - { - if (!LogOptions.LogSerialInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - LogMessage("%08X: read from SI_PIF_ADDR_WR64B_REG (%08X)",PC, Value); - return; - } - if ( VAddr == 0xA4800018) - { - if (!LogOptions.LogSerialInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - LogMessage("%08X: read from SI_STATUS_REG (%08X)",PC, Value); - return; - } - if ( VAddr >= 0xBFC00000 && VAddr <= 0xBFC007C0 ) - { - return; - } - if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC ) - { - if (!LogOptions.LogPRDirectMemLoads) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - LogMessage("%08X: read word from Pif Ram at 0x%X (%08X)",PC,VAddr - 0xBFC007C0, Value); - return; - } - if ( VAddr >= 0xB0000040 && ((VAddr - 0xB0000000) < g_Rom->GetRomSize())) - { - return; - } - if ( VAddr >= 0xB0000000 && VAddr < 0xB0000040) - { - if (!LogOptions.LogRomHeader) - { - return; - } + switch (VAddr) + { + case 0xA4600000: LogMessage("%08X: read from PI_DRAM_ADDR_REG (%08X)",PC, Value); return; + case 0xA4600004: LogMessage("%08X: read from PI_CART_ADDR_REG (%08X)",PC, Value); return; + case 0xA4600008: LogMessage("%08X: read from PI_RD_LEN_REG (%08X)",PC, Value); return; + case 0xA460000C: LogMessage("%08X: read from PI_WR_LEN_REG (%08X)",PC, Value); return; + case 0xA4600010: LogMessage("%08X: read from PI_STATUS_REG (%08X)",PC, Value); return; + case 0xA4600014: LogMessage("%08X: read from PI_BSD_DOM1_LAT_REG/PI_DOMAIN1_REG (%08X)",PC, Value); return; + case 0xA4600018: LogMessage("%08X: read from PI_BSD_DOM1_PWD_REG (%08X)",PC, Value); return; + case 0xA460001C: LogMessage("%08X: read from PI_BSD_DOM1_PGS_REG (%08X)",PC, Value); return; + case 0xA4600020: LogMessage("%08X: read from PI_BSD_DOM1_RLS_REG (%08X)",PC, Value); return; + case 0xA4600024: LogMessage("%08X: read from PI_BSD_DOM2_LAT_REG/PI_DOMAIN2_REG (%08X)",PC, Value); return; + case 0xA4600028: LogMessage("%08X: read from PI_BSD_DOM2_PWD_REG (%08X)",PC, Value); return; + case 0xA460002C: LogMessage("%08X: read from PI_BSD_DOM2_PGS_REG (%08X)",PC, Value); return; + case 0xA4600030: LogMessage("%08X: read from PI_BSD_DOM2_RLS_REG (%08X)",PC, Value); return; + } + } + if (VAddr >= 0xA4700000 && VAddr <= 0xA470001C) + { + if (!g_LogOptions.LogRDRAMInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); - g_MMU->LW_VAddr(VAddr,Value); - switch (VAddr) - { - case 0xB0000004: LogMessage("%08X: read from Rom Clock Rate (%08X)",PC, Value); break; - case 0xB0000008: LogMessage("%08X: read from Rom Boot address offset (%08X)",PC, Value); break; - case 0xB000000C: LogMessage("%08X: read from Rom Release offset (%08X)",PC, Value); break; - case 0xB0000010: LogMessage("%08X: read from Rom CRC1 (%08X)",PC, Value); break; - case 0xB0000014: LogMessage("%08X: read from Rom CRC2 (%08X)",PC, Value); break; - default: LogMessage("%08X: read from Rom header 0x%X (%08X)",PC, VAddr & 0xFF,Value); break; - } - return; - } - if (!LogOptions.LogUnknown) - { - return; - } - LogMessage("%08X: read from unknown ??? (%08X)",PC,VAddr); + switch (VAddr) + { + case 0xA4700000: LogMessage("%08X: read from RI_MODE_REG (%08X)",PC, Value); return; + case 0xA4700004: LogMessage("%08X: read from RI_CONFIG_REG (%08X)",PC, Value); return; + case 0xA4700008: LogMessage("%08X: read from RI_CURRENT_LOAD_REG (%08X)",PC, Value); return; + case 0xA470000C: LogMessage("%08X: read from RI_SELECT_REG (%08X)",PC, Value); return; + case 0xA4700010: LogMessage("%08X: read from RI_REFRESH_REG/RI_COUNT_REG (%08X)",PC, Value); return; + case 0xA4700014: LogMessage("%08X: read from RI_LATENCY_REG (%08X)",PC, Value); return; + case 0xA4700018: LogMessage("%08X: read from RI_RERROR_REG (%08X)",PC, Value); return; + case 0xA470001C: LogMessage("%08X: read from RI_WERROR_REG (%08X)",PC, Value); return; + } + } + if ( VAddr == 0xA4800000) + { + if (!g_LogOptions.LogSerialInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + LogMessage("%08X: read from SI_DRAM_ADDR_REG (%08X)",PC, Value); + return; + } + if ( VAddr == 0xA4800004) + { + if (!g_LogOptions.LogSerialInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + LogMessage("%08X: read from SI_PIF_ADDR_RD64B_REG (%08X)",PC, Value); + return; + } + if ( VAddr == 0xA4800010) + { + if (!g_LogOptions.LogSerialInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + LogMessage("%08X: read from SI_PIF_ADDR_WR64B_REG (%08X)",PC, Value); + return; + } + if ( VAddr == 0xA4800018) + { + if (!g_LogOptions.LogSerialInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + LogMessage("%08X: read from SI_STATUS_REG (%08X)",PC, Value); + return; + } + if ( VAddr >= 0xBFC00000 && VAddr <= 0xBFC007C0 ) + { + return; + } + if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC ) + { + if (!g_LogOptions.LogPRDirectMemLoads) + { + return; + } + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + LogMessage("%08X: read word from Pif Ram at 0x%X (%08X)",PC,VAddr - 0xBFC007C0, Value); + return; + } + if ( VAddr >= 0xB0000040 && ((VAddr - 0xB0000000) < g_Rom->GetRomSize())) + { + return; + } + if ( VAddr >= 0xB0000000 && VAddr < 0xB0000040) + { + if (!g_LogOptions.LogRomHeader) + { + return; + } + + g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + switch (VAddr) + { + case 0xB0000004: LogMessage("%08X: read from Rom Clock Rate (%08X)",PC, Value); break; + case 0xB0000008: LogMessage("%08X: read from Rom Boot address offset (%08X)",PC, Value); break; + case 0xB000000C: LogMessage("%08X: read from Rom Release offset (%08X)",PC, Value); break; + case 0xB0000010: LogMessage("%08X: read from Rom CRC1 (%08X)",PC, Value); break; + case 0xB0000014: LogMessage("%08X: read from Rom CRC2 (%08X)",PC, Value); break; + default: LogMessage("%08X: read from Rom header 0x%X (%08X)",PC, VAddr & 0xFF,Value); break; + } + return; + } + if (!g_LogOptions.LogUnknown) + { + return; + } + LogMessage("%08X: read from unknown ??? (%08X)",PC,VAddr); } -void __cdecl LogMessage (char * Message, ...) +void Log_SW (uint32_t PC, uint32_t VAddr, uint32_t Value) { - DWORD dwWritten; - char Msg[400]; - va_list ap; + if (!g_LogOptions.GenerateLog) + { + return; + } - if (!g_Settings->LoadBool(Debugger_Enabled)) - { - return; - } - if (hLogFile == NULL) - { - return; - } + if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 ) + { + uint32_t PAddr; + if (!g_TransVaddr->TranslateVaddr(VAddr,(DWORD &)PAddr)) + { + if (g_LogOptions.LogUnknown) + { + LogMessage("%08X: Writing 0x%08X to %08X",PC, Value, VAddr ); + } + return; + } + VAddr = PAddr + 0xA0000000; + } - va_start( ap, Message ); - vsprintf( Msg, Message, ap ); - va_end( ap ); - - strcat(Msg,"\r\n"); - - WriteFile( hLogFile,Msg,strlen(Msg),&dwWritten,NULL ); -} - -void Log_SW (DWORD PC, DWORD VAddr, DWORD Value) -{ - if (!LogOptions.GenerateLog) - { - return; - } - - if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 ) - { - DWORD PAddr; - if (!g_TransVaddr->TranslateVaddr(VAddr,PAddr)) - { - if (LogOptions.LogUnknown) - { - LogMessage("%08X: Writing 0x%08X to %08X",PC, Value, VAddr ); - } - return; - } - VAddr = PAddr + 0xA0000000; - } - - if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize())) - { - return; - } - if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) - { - if (!LogOptions.LogRDRamRegisters) - { - return; - } - switch (VAddr) - { - case 0xA3F00000: LogMessage("%08X: Writing 0x%08X to RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG",PC, Value ); return; - case 0xA3F00004: LogMessage("%08X: Writing 0x%08X to RDRAM_DEVICE_ID_REG",PC, Value ); return; - case 0xA3F00008: LogMessage("%08X: Writing 0x%08X to RDRAM_DELAY_REG",PC, Value ); return; - case 0xA3F0000C: LogMessage("%08X: Writing 0x%08X to RDRAM_MODE_REG",PC, Value ); return; - case 0xA3F00010: LogMessage("%08X: Writing 0x%08X to RDRAM_REF_INTERVAL_REG",PC, Value ); return; - case 0xA3F00014: LogMessage("%08X: Writing 0x%08X to RDRAM_REF_ROW_REG",PC, Value ); return; - case 0xA3F00018: LogMessage("%08X: Writing 0x%08X to RDRAM_RAS_INTERVAL_REG",PC, Value ); return; - case 0xA3F0001C: LogMessage("%08X: Writing 0x%08X to RDRAM_MIN_INTERVAL_REG",PC, Value ); return; - case 0xA3F00020: LogMessage("%08X: Writing 0x%08X to RDRAM_ADDR_SELECT_REG",PC, Value ); return; - case 0xA3F00024: LogMessage("%08X: Writing 0x%08X to RDRAM_DEVICE_MANUF_REG",PC, Value ); return; - } - } - if ( VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC ) - { - return; - } + if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize())) + { + return; + } + if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) + { + if (!g_LogOptions.LogRDRamRegisters) + { + return; + } + switch (VAddr) + { + case 0xA3F00000: LogMessage("%08X: Writing 0x%08X to RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG",PC, Value ); return; + case 0xA3F00004: LogMessage("%08X: Writing 0x%08X to RDRAM_DEVICE_ID_REG",PC, Value ); return; + case 0xA3F00008: LogMessage("%08X: Writing 0x%08X to RDRAM_DELAY_REG",PC, Value ); return; + case 0xA3F0000C: LogMessage("%08X: Writing 0x%08X to RDRAM_MODE_REG",PC, Value ); return; + case 0xA3F00010: LogMessage("%08X: Writing 0x%08X to RDRAM_REF_INTERVAL_REG",PC, Value ); return; + case 0xA3F00014: LogMessage("%08X: Writing 0x%08X to RDRAM_REF_ROW_REG",PC, Value ); return; + case 0xA3F00018: LogMessage("%08X: Writing 0x%08X to RDRAM_RAS_INTERVAL_REG",PC, Value ); return; + case 0xA3F0001C: LogMessage("%08X: Writing 0x%08X to RDRAM_MIN_INTERVAL_REG",PC, Value ); return; + case 0xA3F00020: LogMessage("%08X: Writing 0x%08X to RDRAM_ADDR_SELECT_REG",PC, Value ); return; + case 0xA3F00024: LogMessage("%08X: Writing 0x%08X to RDRAM_DEVICE_MANUF_REG",PC, Value ); return; + } + } + if ( VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC ) + { + return; + } if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C) - { - if (!LogOptions.LogSPRegisters) - { - return; - } - switch (VAddr) - { - case 0xA4040000: LogMessage("%08X: Writing 0x%08X to SP_MEM_ADDR_REG",PC, Value ); return; - case 0xA4040004: LogMessage("%08X: Writing 0x%08X to SP_DRAM_ADDR_REG",PC, Value ); return; - case 0xA4040008: LogMessage("%08X: Writing 0x%08X to SP_RD_LEN_REG",PC, Value ); return; - case 0xA404000C: LogMessage("%08X: Writing 0x%08X to SP_WR_LEN_REG",PC, Value ); return; - case 0xA4040010: LogMessage("%08X: Writing 0x%08X to SP_STATUS_REG",PC, Value ); return; - case 0xA4040014: LogMessage("%08X: Writing 0x%08X to SP_DMA_FULL_REG",PC, Value ); return; - case 0xA4040018: LogMessage("%08X: Writing 0x%08X to SP_DMA_BUSY_REG",PC, Value ); return; - case 0xA404001C: LogMessage("%08X: Writing 0x%08X to SP_SEMAPHORE_REG",PC, Value ); return; - } - } + { + if (!g_LogOptions.LogSPRegisters) + { + return; + } + switch (VAddr) + { + case 0xA4040000: LogMessage("%08X: Writing 0x%08X to SP_MEM_ADDR_REG",PC, Value ); return; + case 0xA4040004: LogMessage("%08X: Writing 0x%08X to SP_DRAM_ADDR_REG",PC, Value ); return; + case 0xA4040008: LogMessage("%08X: Writing 0x%08X to SP_RD_LEN_REG",PC, Value ); return; + case 0xA404000C: LogMessage("%08X: Writing 0x%08X to SP_WR_LEN_REG",PC, Value ); return; + case 0xA4040010: LogMessage("%08X: Writing 0x%08X to SP_STATUS_REG",PC, Value ); return; + case 0xA4040014: LogMessage("%08X: Writing 0x%08X to SP_DMA_FULL_REG",PC, Value ); return; + case 0xA4040018: LogMessage("%08X: Writing 0x%08X to SP_DMA_BUSY_REG",PC, Value ); return; + case 0xA404001C: LogMessage("%08X: Writing 0x%08X to SP_SEMAPHORE_REG",PC, Value ); return; + } + } if ( VAddr == 0xA4080000) - { - if (!LogOptions.LogSPRegisters) - { - return; - } - LogMessage("%08X: Writing 0x%08X to SP_PC",PC, Value ); return; - } - + { + if (!g_LogOptions.LogSPRegisters) + { + return; + } + LogMessage("%08X: Writing 0x%08X to SP_PC",PC, Value ); return; + } + if ( VAddr >= 0xA4100000 && VAddr <= 0xA410001C) - { - if (!LogOptions.LogDPCRegisters) - { - return; - } - switch (VAddr) - { - case 0xA4100000: LogMessage("%08X: Writing 0x%08X to DPC_START_REG",PC, Value ); return; - case 0xA4100004: LogMessage("%08X: Writing 0x%08X to DPC_END_REG",PC, Value ); return; - case 0xA4100008: LogMessage("%08X: Writing 0x%08X to DPC_CURRENT_REG",PC, Value ); return; - case 0xA410000C: LogMessage("%08X: Writing 0x%08X to DPC_STATUS_REG",PC, Value ); return; - case 0xA4100010: LogMessage("%08X: Writing 0x%08X to DPC_CLOCK_REG",PC, Value ); return; - case 0xA4100014: LogMessage("%08X: Writing 0x%08X to DPC_BUFBUSY_REG",PC, Value ); return; - case 0xA4100018: LogMessage("%08X: Writing 0x%08X to DPC_PIPEBUSY_REG",PC, Value ); return; - case 0xA410001C: LogMessage("%08X: Writing 0x%08X to DPC_TMEM_REG",PC, Value ); return; - } - } + { + if (!g_LogOptions.LogDPCRegisters) + { + return; + } + switch (VAddr) + { + case 0xA4100000: LogMessage("%08X: Writing 0x%08X to DPC_START_REG",PC, Value ); return; + case 0xA4100004: LogMessage("%08X: Writing 0x%08X to DPC_END_REG",PC, Value ); return; + case 0xA4100008: LogMessage("%08X: Writing 0x%08X to DPC_CURRENT_REG",PC, Value ); return; + case 0xA410000C: LogMessage("%08X: Writing 0x%08X to DPC_STATUS_REG",PC, Value ); return; + case 0xA4100010: LogMessage("%08X: Writing 0x%08X to DPC_CLOCK_REG",PC, Value ); return; + case 0xA4100014: LogMessage("%08X: Writing 0x%08X to DPC_BUFBUSY_REG",PC, Value ); return; + case 0xA4100018: LogMessage("%08X: Writing 0x%08X to DPC_PIPEBUSY_REG",PC, Value ); return; + case 0xA410001C: LogMessage("%08X: Writing 0x%08X to DPC_TMEM_REG",PC, Value ); return; + } + } if ( VAddr >= 0xA4200000 && VAddr <= 0xA420000C) - { - if (!LogOptions.LogDPSRegisters) - { - return; - } - switch (VAddr) - { - case 0xA4200000: LogMessage("%08X: Writing 0x%08X to DPS_TBIST_REG",PC, Value ); return; - case 0xA4200004: LogMessage("%08X: Writing 0x%08X to DPS_TEST_MODE_REG",PC, Value ); return; - case 0xA4200008: LogMessage("%08X: Writing 0x%08X to DPS_BUFTEST_ADDR_REG",PC, Value ); return; - case 0xA420000C: LogMessage("%08X: Writing 0x%08X to DPS_BUFTEST_DATA_REG",PC, Value ); return; - } - } + { + if (!g_LogOptions.LogDPSRegisters) + { + return; + } + switch (VAddr) + { + case 0xA4200000: LogMessage("%08X: Writing 0x%08X to DPS_TBIST_REG",PC, Value ); return; + case 0xA4200004: LogMessage("%08X: Writing 0x%08X to DPS_TEST_MODE_REG",PC, Value ); return; + case 0xA4200008: LogMessage("%08X: Writing 0x%08X to DPS_BUFTEST_ADDR_REG",PC, Value ); return; + case 0xA420000C: LogMessage("%08X: Writing 0x%08X to DPS_BUFTEST_DATA_REG",PC, Value ); return; + } + } if ( VAddr >= 0xA4300000 && VAddr <= 0xA430000C) - { - if (!LogOptions.LogMIPSInterface) - { - return; - } - switch (VAddr) - { - case 0xA4300000: LogMessage("%08X: Writing 0x%08X to MI_INIT_MODE_REG/MI_MODE_REG",PC, Value ); return; - case 0xA4300004: LogMessage("%08X: Writing 0x%08X to MI_VERSION_REG/MI_NOOP_REG",PC, Value ); return; - case 0xA4300008: LogMessage("%08X: Writing 0x%08X to MI_INTR_REG",PC, Value ); return; - case 0xA430000C: LogMessage("%08X: Writing 0x%08X to MI_INTR_MASK_REG",PC, Value ); return; - } - } + { + if (!g_LogOptions.LogMIPSInterface) + { + return; + } + switch (VAddr) + { + case 0xA4300000: LogMessage("%08X: Writing 0x%08X to MI_INIT_MODE_REG/MI_MODE_REG",PC, Value ); return; + case 0xA4300004: LogMessage("%08X: Writing 0x%08X to MI_VERSION_REG/MI_NOOP_REG",PC, Value ); return; + case 0xA4300008: LogMessage("%08X: Writing 0x%08X to MI_INTR_REG",PC, Value ); return; + case 0xA430000C: LogMessage("%08X: Writing 0x%08X to MI_INTR_MASK_REG",PC, Value ); return; + } + } if ( VAddr >= 0xA4400000 && VAddr <= 0xA4400034) - { - if (!LogOptions.LogVideoInterface) - { - return; - } - switch (VAddr) - { - case 0xA4400000: LogMessage("%08X: Writing 0x%08X to VI_STATUS_REG/VI_CONTROL_REG",PC, Value ); return; - case 0xA4400004: LogMessage("%08X: Writing 0x%08X to VI_ORIGIN_REG/VI_DRAM_ADDR_REG",PC, Value ); return; - case 0xA4400008: LogMessage("%08X: Writing 0x%08X to VI_WIDTH_REG/VI_H_WIDTH_REG",PC, Value ); return; - case 0xA440000C: LogMessage("%08X: Writing 0x%08X to VI_INTR_REG/VI_V_INTR_REG",PC, Value ); return; - case 0xA4400010: LogMessage("%08X: Writing 0x%08X to VI_CURRENT_REG/VI_V_CURRENT_LINE_REG",PC, Value ); return; - case 0xA4400014: LogMessage("%08X: Writing 0x%08X to VI_BURST_REG/VI_TIMING_REG",PC, Value ); return; - case 0xA4400018: LogMessage("%08X: Writing 0x%08X to VI_V_SYNC_REG",PC, Value ); return; - case 0xA440001C: LogMessage("%08X: Writing 0x%08X to VI_H_SYNC_REG",PC, Value ); return; - case 0xA4400020: LogMessage("%08X: Writing 0x%08X to VI_LEAP_REG/VI_H_SYNC_LEAP_REG",PC, Value ); return; - case 0xA4400024: LogMessage("%08X: Writing 0x%08X to VI_H_START_REG/VI_H_VIDEO_REG",PC, Value ); return; - case 0xA4400028: LogMessage("%08X: Writing 0x%08X to VI_V_START_REG/VI_V_VIDEO_REG",PC, Value ); return; - case 0xA440002C: LogMessage("%08X: Writing 0x%08X to VI_V_BURST_REG",PC, Value ); return; - case 0xA4400030: LogMessage("%08X: Writing 0x%08X to VI_X_SCALE_REG",PC, Value ); return; - case 0xA4400034: LogMessage("%08X: Writing 0x%08X to VI_Y_SCALE_REG",PC, Value ); return; - } - } + { + if (!g_LogOptions.LogVideoInterface) + { + return; + } + switch (VAddr) + { + case 0xA4400000: LogMessage("%08X: Writing 0x%08X to VI_STATUS_REG/VI_CONTROL_REG",PC, Value ); return; + case 0xA4400004: LogMessage("%08X: Writing 0x%08X to VI_ORIGIN_REG/VI_DRAM_ADDR_REG",PC, Value ); return; + case 0xA4400008: LogMessage("%08X: Writing 0x%08X to VI_WIDTH_REG/VI_H_WIDTH_REG",PC, Value ); return; + case 0xA440000C: LogMessage("%08X: Writing 0x%08X to VI_INTR_REG/VI_V_INTR_REG",PC, Value ); return; + case 0xA4400010: LogMessage("%08X: Writing 0x%08X to VI_CURRENT_REG/VI_V_CURRENT_LINE_REG",PC, Value ); return; + case 0xA4400014: LogMessage("%08X: Writing 0x%08X to VI_BURST_REG/VI_TIMING_REG",PC, Value ); return; + case 0xA4400018: LogMessage("%08X: Writing 0x%08X to VI_V_SYNC_REG",PC, Value ); return; + case 0xA440001C: LogMessage("%08X: Writing 0x%08X to VI_H_SYNC_REG",PC, Value ); return; + case 0xA4400020: LogMessage("%08X: Writing 0x%08X to VI_LEAP_REG/VI_H_SYNC_LEAP_REG",PC, Value ); return; + case 0xA4400024: LogMessage("%08X: Writing 0x%08X to VI_H_START_REG/VI_H_VIDEO_REG",PC, Value ); return; + case 0xA4400028: LogMessage("%08X: Writing 0x%08X to VI_V_START_REG/VI_V_VIDEO_REG",PC, Value ); return; + case 0xA440002C: LogMessage("%08X: Writing 0x%08X to VI_V_BURST_REG",PC, Value ); return; + case 0xA4400030: LogMessage("%08X: Writing 0x%08X to VI_X_SCALE_REG",PC, Value ); return; + case 0xA4400034: LogMessage("%08X: Writing 0x%08X to VI_Y_SCALE_REG",PC, Value ); return; + } + } if ( VAddr >= 0xA4500000 && VAddr <= 0xA4500014) - { - if (!LogOptions.LogAudioInterface) - { - return; - } - switch (VAddr) - { - case 0xA4500000: LogMessage("%08X: Writing 0x%08X to AI_DRAM_ADDR_REG",PC, Value ); return; - case 0xA4500004: LogMessage("%08X: Writing 0x%08X to AI_LEN_REG",PC, Value ); return; - case 0xA4500008: LogMessage("%08X: Writing 0x%08X to AI_CONTROL_REG",PC, Value ); return; - case 0xA450000C: LogMessage("%08X: Writing 0x%08X to AI_STATUS_REG",PC, Value ); return; - case 0xA4500010: LogMessage("%08X: Writing 0x%08X to AI_DACRATE_REG",PC, Value ); return; - case 0xA4500014: LogMessage("%08X: Writing 0x%08X to AI_BITRATE_REG",PC, Value ); return; - } - } + { + if (!g_LogOptions.LogAudioInterface) + { + return; + } + switch (VAddr) + { + case 0xA4500000: LogMessage("%08X: Writing 0x%08X to AI_DRAM_ADDR_REG",PC, Value ); return; + case 0xA4500004: LogMessage("%08X: Writing 0x%08X to AI_LEN_REG",PC, Value ); return; + case 0xA4500008: LogMessage("%08X: Writing 0x%08X to AI_CONTROL_REG",PC, Value ); return; + case 0xA450000C: LogMessage("%08X: Writing 0x%08X to AI_STATUS_REG",PC, Value ); return; + case 0xA4500010: LogMessage("%08X: Writing 0x%08X to AI_DACRATE_REG",PC, Value ); return; + case 0xA4500014: LogMessage("%08X: Writing 0x%08X to AI_BITRATE_REG",PC, Value ); return; + } + } if ( VAddr >= 0xA4600000 && VAddr <= 0xA4600030) - { - if (!LogOptions.LogPerInterface) - { - return; - } - switch (VAddr) - { - case 0xA4600000: LogMessage("%08X: Writing 0x%08X to PI_DRAM_ADDR_REG",PC, Value ); return; - case 0xA4600004: LogMessage("%08X: Writing 0x%08X to PI_CART_ADDR_REG",PC, Value ); return; - case 0xA4600008: LogMessage("%08X: Writing 0x%08X to PI_RD_LEN_REG",PC, Value ); return; - case 0xA460000C: LogMessage("%08X: Writing 0x%08X to PI_WR_LEN_REG",PC, Value ); return; - case 0xA4600010: LogMessage("%08X: Writing 0x%08X to PI_STATUS_REG",PC, Value ); return; - case 0xA4600014: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_LAT_REG/PI_DOMAIN1_REG",PC, Value ); return; - case 0xA4600018: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_PWD_REG",PC, Value ); return; - case 0xA460001C: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_PGS_REG",PC, Value ); return; - case 0xA4600020: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_RLS_REG",PC, Value ); return; - case 0xA4600024: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_LAT_REG/PI_DOMAIN2_REG",PC, Value ); return; - case 0xA4600028: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_PWD_REG",PC, Value ); return; - case 0xA460002C: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_PGS_REG",PC, Value ); return; - case 0xA4600030: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_RLS_REG",PC, Value ); return; - } - } + { + if (!g_LogOptions.LogPerInterface) + { + return; + } + switch (VAddr) + { + case 0xA4600000: LogMessage("%08X: Writing 0x%08X to PI_DRAM_ADDR_REG",PC, Value ); return; + case 0xA4600004: LogMessage("%08X: Writing 0x%08X to PI_CART_ADDR_REG",PC, Value ); return; + case 0xA4600008: LogMessage("%08X: Writing 0x%08X to PI_RD_LEN_REG",PC, Value ); return; + case 0xA460000C: LogMessage("%08X: Writing 0x%08X to PI_WR_LEN_REG",PC, Value ); return; + case 0xA4600010: LogMessage("%08X: Writing 0x%08X to PI_STATUS_REG",PC, Value ); return; + case 0xA4600014: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_LAT_REG/PI_DOMAIN1_REG",PC, Value ); return; + case 0xA4600018: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_PWD_REG",PC, Value ); return; + case 0xA460001C: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_PGS_REG",PC, Value ); return; + case 0xA4600020: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_RLS_REG",PC, Value ); return; + case 0xA4600024: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_LAT_REG/PI_DOMAIN2_REG",PC, Value ); return; + case 0xA4600028: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_PWD_REG",PC, Value ); return; + case 0xA460002C: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_PGS_REG",PC, Value ); return; + case 0xA4600030: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_RLS_REG",PC, Value ); return; + } + } if ( VAddr >= 0xA4700000 && VAddr <= 0xA470001C) - { - if (!LogOptions.LogRDRAMInterface) - { - return; - } - switch (VAddr) - { - case 0xA4700000: LogMessage("%08X: Writing 0x%08X to RI_MODE_REG",PC, Value ); return; - case 0xA4700004: LogMessage("%08X: Writing 0x%08X to RI_CONFIG_REG",PC, Value ); return; - case 0xA4700008: LogMessage("%08X: Writing 0x%08X to RI_CURRENT_LOAD_REG",PC, Value ); return; - case 0xA470000C: LogMessage("%08X: Writing 0x%08X to RI_SELECT_REG",PC, Value ); return; - case 0xA4700010: LogMessage("%08X: Writing 0x%08X to RI_REFRESH_REG/RI_COUNT_REG",PC, Value ); return; - case 0xA4700014: LogMessage("%08X: Writing 0x%08X to RI_LATENCY_REG",PC, Value ); return; - case 0xA4700018: LogMessage("%08X: Writing 0x%08X to RI_RERROR_REG",PC, Value ); return; - case 0xA470001C: LogMessage("%08X: Writing 0x%08X to RI_WERROR_REG",PC, Value ); return; - } - } + { + if (!g_LogOptions.LogRDRAMInterface) + { + return; + } + switch (VAddr) + { + case 0xA4700000: LogMessage("%08X: Writing 0x%08X to RI_MODE_REG",PC, Value ); return; + case 0xA4700004: LogMessage("%08X: Writing 0x%08X to RI_CONFIG_REG",PC, Value ); return; + case 0xA4700008: LogMessage("%08X: Writing 0x%08X to RI_CURRENT_LOAD_REG",PC, Value ); return; + case 0xA470000C: LogMessage("%08X: Writing 0x%08X to RI_SELECT_REG",PC, Value ); return; + case 0xA4700010: LogMessage("%08X: Writing 0x%08X to RI_REFRESH_REG/RI_COUNT_REG",PC, Value ); return; + case 0xA4700014: LogMessage("%08X: Writing 0x%08X to RI_LATENCY_REG",PC, Value ); return; + case 0xA4700018: LogMessage("%08X: Writing 0x%08X to RI_RERROR_REG",PC, Value ); return; + case 0xA470001C: LogMessage("%08X: Writing 0x%08X to RI_WERROR_REG",PC, Value ); return; + } + } if ( VAddr == 0xA4800000) - { - if (!LogOptions.LogSerialInterface) - { - return; - } - LogMessage("%08X: Writing 0x%08X to SI_DRAM_ADDR_REG",PC, Value ); return; - } + { + if (!g_LogOptions.LogSerialInterface) + { + return; + } + LogMessage("%08X: Writing 0x%08X to SI_DRAM_ADDR_REG",PC, Value ); return; + } if ( VAddr == 0xA4800004) - { - if (LogOptions.LogPRDMAOperations) - { - LogMessage("%08X: A DMA transfer from the PIF ram has occured",PC ); - } - if (!LogOptions.LogSerialInterface) - { - return; - } - LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_RD64B_REG",PC, Value ); return; - } + { + if (g_LogOptions.LogPRDMAOperations) + { + LogMessage("%08X: A DMA transfer from the PIF ram has occured",PC ); + } + if (!g_LogOptions.LogSerialInterface) + { + return; + } + LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_RD64B_REG",PC, Value ); return; + } if ( VAddr == 0xA4800010) - { - if (LogOptions.LogPRDMAOperations) - { - LogMessage("%08X: A DMA transfer to the PIF ram has occured",PC ); - } - if (!LogOptions.LogSerialInterface) - { - return; - } - LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_WR64B_REG",PC, Value ); return; - } + { + if (g_LogOptions.LogPRDMAOperations) + { + LogMessage("%08X: A DMA transfer to the PIF ram has occured",PC ); + } + if (!g_LogOptions.LogSerialInterface) + { + return; + } + LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_WR64B_REG",PC, Value ); return; + } if ( VAddr == 0xA4800018) - { - if (!LogOptions.LogSerialInterface) - { - return; - } - LogMessage("%08X: Writing 0x%08X to SI_STATUS_REG",PC, Value ); return; - } + { + if (!g_LogOptions.LogSerialInterface) + { + return; + } + LogMessage("%08X: Writing 0x%08X to SI_STATUS_REG",PC, Value ); return; + } - if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC ) - { - if (!LogOptions.LogPRDirectMemStores) - { - return; - } - LogMessage("%08X: Writing 0x%08X to Pif Ram at 0x%X",PC,Value, VAddr - 0xBFC007C0); - return; - } - if (!LogOptions.LogUnknown) - { - return; - } - LogMessage("%08X: Writing 0x%08X to %08X ????",PC, Value, VAddr ); + if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC ) + { + if (!g_LogOptions.LogPRDirectMemStores) + { + return; + } + LogMessage("%08X: Writing 0x%08X to Pif Ram at 0x%X",PC,Value, VAddr - 0xBFC007C0); + return; + } + if (!g_LogOptions.LogUnknown) + { + return; + } + LogMessage("%08X: Writing 0x%08X to %08X ????",PC, Value, VAddr ); } LRESULT CALLBACK LogPifProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam) @@ -889,32 +865,55 @@ void SaveLogOptions (void) RegCloseKey(hKeyResults); } -void StartLog (void) +void LogMessage (const char * Message, ...) { - if (!LogOptions.GenerateLog) - { - StopLog(); - return; - } - if (hLogFile) - { - return; - } + DWORD dwWritten; + char Msg[400]; + va_list ap; - CPath LogFile(CPath::MODULE_DIRECTORY); - LogFile.AppendDirectory("Logs"); - LogFile.SetNameExtension("cpudebug.log"); - - hLogFile = CreateFile(LogFile,GENERIC_WRITE, FILE_SHARE_READ,NULL,CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); - SetFilePointer(hLogFile,0,NULL,FILE_BEGIN); + if (!g_Settings->LoadBool(Debugger_Enabled)) + { + return; + } + if (g_hLogFile == NULL) + { + return; + } + + va_start( ap, Message ); + vsprintf( Msg, Message, ap ); + va_end( ap ); + + strcat(Msg,"\r\n"); + + WriteFile( g_hLogFile,Msg,strlen(Msg),&dwWritten,NULL ); +} + +void StartLog (void) +{ + if (!g_LogOptions.GenerateLog) + { + StopLog(); + return; + } + if (g_hLogFile) + { + return; + } + + CPath LogFile(CPath::MODULE_DIRECTORY); + LogFile.AppendDirectory("Logs"); + LogFile.SetNameExtension("cpudebug.log"); + + g_hLogFile = CreateFile(LogFile,GENERIC_WRITE, FILE_SHARE_READ,NULL,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); + SetFilePointer(g_hLogFile,0,NULL,FILE_BEGIN); } void StopLog (void) { - if (hLogFile) - { - CloseHandle(hLogFile); - } - hLogFile = NULL; + if (g_hLogFile) + { + CloseHandle(g_hLogFile); + } + g_hLogFile = NULL; } diff --git a/Source/Project64/Logging.h b/Source/Project64/Logging.h index 844fcdf04..c36aba4d4 100644 --- a/Source/Project64/Logging.h +++ b/Source/Project64/Logging.h @@ -9,55 +9,48 @@ * * ****************************************************************************/ #pragma once -#ifdef __cplusplus -extern "C" { -#endif typedef struct { - BOOL GenerateLog; + bool GenerateLog; - /* Registers Log */ - BOOL LogRDRamRegisters; - BOOL LogSPRegisters; - BOOL LogDPCRegisters; - BOOL LogDPSRegisters; - BOOL LogMIPSInterface; - BOOL LogVideoInterface; - BOOL LogAudioInterface; - BOOL LogPerInterface; - BOOL LogRDRAMInterface; - BOOL LogSerialInterface; + /* Registers Log */ + bool LogRDRamRegisters; + bool LogSPRegisters; + bool LogDPCRegisters; + bool LogDPSRegisters; + bool LogMIPSInterface; + bool LogVideoInterface; + bool LogAudioInterface; + bool LogPerInterface; + bool LogRDRAMInterface; + bool LogSerialInterface; - /* Pif Ram Log */ - BOOL LogPRDMAOperations; - BOOL LogPRDirectMemLoads; - BOOL LogPRDMAMemLoads; - BOOL LogPRDirectMemStores; - BOOL LogPRDMAMemStores; - BOOL LogControllerPak; + /* Pif Ram Log */ + bool LogPRDMAOperations; + bool LogPRDirectMemLoads; + bool LogPRDMAMemLoads; + bool LogPRDirectMemStores; + bool LogPRDMAMemStores; + bool LogControllerPak; - /* Special Log */ - BOOL LogCP0changes; - BOOL LogCP0reads; - BOOL LogTLB; - BOOL LogExceptions; - BOOL NoInterrupts; - BOOL LogCache; - BOOL LogRomHeader; - BOOL LogUnknown; + /* Special Log */ + bool LogCP0changes; + bool LogCP0reads; + bool LogTLB; + bool LogExceptions; + bool NoInterrupts; + bool LogCache; + bool LogRomHeader; + bool LogUnknown; } LOG_OPTIONS; -extern LOG_OPTIONS LogOptions; +extern LOG_OPTIONS g_LogOptions; void EnterLogOptions ( HWND hwndOwner ); -void LoadLogOptions ( LOG_OPTIONS * LogOptions, BOOL AlwaysFill ); -void Log_LW ( DWORD PC, DWORD VAddr ); -void __cdecl LogMessage ( char * Message, ... ); -void Log_SW ( DWORD PC, DWORD VAddr, DWORD Value ); -void StartLog ( void ); -void StopLog ( void ); - -#ifdef __cplusplus -} -#endif +void StartLog ( void ); +void StopLog ( void ); +void LoadLogOptions ( LOG_OPTIONS * LogOptions, bool AlwaysFill ); +void Log_LW ( uint32_t PC, uint32_t VAddr ); +void Log_SW ( uint32_t PC, uint32_t VAddr, uint32_t Value ); +void LogMessage ( const char * Message, ... ); diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp index ee5934aac..c29282520 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp @@ -951,7 +951,7 @@ void R4300iOp32::LW() ADDRESS_ERROR_EXCEPTION(Address, true); } - if (LogOptions.GenerateLog) + if (g_LogOptions.GenerateLog) { Log_LW((*_PROGRAM_COUNTER),Address); } @@ -1323,7 +1323,7 @@ void R4300iOp32::REGIMM_BGEZAL() } /************************** COP0 functions **************************/ void R4300iOp32::COP0_MF() { - if (LogOptions.LogCP0reads) + if (g_LogOptions.LogCP0reads) { LogMessage("%08X: R4300i Read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); } @@ -1337,7 +1337,7 @@ void R4300iOp32::COP0_MF() { void R4300iOp32::COP0_MT() { - if (LogOptions.LogCP0changes) + if (g_LogOptions.LogCP0changes) { LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)",(*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0],CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); if (m_Opcode.rd == 11) //Compare diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp index e7cc0d817..c3c6c14e4 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp @@ -1115,7 +1115,7 @@ void R4300iOp::LW() ADDRESS_ERROR_EXCEPTION(Address, true); } - if (LogOptions.GenerateLog) + if (g_LogOptions.GenerateLog) { Log_LW((*_PROGRAM_COUNTER),Address); } @@ -1295,7 +1295,7 @@ void R4300iOp::SW() { ADDRESS_ERROR_EXCEPTION(Address, false); } - if (LogOptions.GenerateLog) + if (g_LogOptions.GenerateLog) { Log_SW((*_PROGRAM_COUNTER),Address,_GPR[m_Opcode.rt].UW[0]); } @@ -1445,7 +1445,7 @@ void R4300iOp::SWR() void R4300iOp::CACHE() { - if (!LogOptions.LogCache) + if (!g_LogOptions.LogCache) { return; } @@ -2094,7 +2094,7 @@ void R4300iOp::REGIMM_BGEZAL() /************************** COP0 functions **************************/ void R4300iOp::COP0_MF() { - if (LogOptions.LogCP0reads) + if (g_LogOptions.LogCP0reads) { LogMessage("%08X: R4300i Read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); } @@ -2108,7 +2108,7 @@ void R4300iOp::COP0_MF() void R4300iOp::COP0_MT() { - if (LogOptions.LogCP0changes) + if (g_LogOptions.LogCP0changes) { LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)",(*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0],CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); if (m_Opcode.rd == 11) //Compare diff --git a/Source/Project64/N64 System/Mips/Pif Ram.cpp b/Source/Project64/N64 System/Mips/Pif Ram.cpp index abf709b00..b477922ec 100644 --- a/Source/Project64/N64 System/Mips/Pif Ram.cpp +++ b/Source/Project64/N64 System/Mips/Pif Ram.cpp @@ -308,7 +308,7 @@ void CPifRam::SI_DMA_READ() } } - if (LogOptions.LogPRDMAMemStores) + if (g_LogOptions.LogPRDMAMemStores) { int count; char HexData[100], AsciiData[100], Addon[20]; @@ -394,7 +394,7 @@ void CPifRam::SI_DMA_WRITE() } } - if (LogOptions.LogPRDMAMemLoads) + if (g_LogOptions.LogPRDMAMemLoads) { int count; char HexData[100], AsciiData[100], Addon[20]; @@ -505,7 +505,7 @@ void CPifRam::ProcessControllerCommand ( int Control, BYTE * Command) } break; case 0x02: //read from controller pack - if (LogOptions.LogControllerPak) + if (g_LogOptions.LogControllerPak) { LogControllerPakData("Read: Before Gettting Results"); } @@ -541,13 +541,13 @@ void CPifRam::ProcessControllerCommand ( int Control, BYTE * Command) { Command[1] |= 0x80; } - if (LogOptions.LogControllerPak) + if (g_LogOptions.LogControllerPak) { LogControllerPakData("Read: After Gettting Results"); } break; case 0x03: //write controller pak - if (LogOptions.LogControllerPak) + if (g_LogOptions.LogControllerPak) { LogControllerPakData("Write: Before Processing"); } @@ -581,7 +581,7 @@ void CPifRam::ProcessControllerCommand ( int Control, BYTE * Command) { Command[1] |= 0x80; } - if (LogOptions.LogControllerPak) + if (g_LogOptions.LogControllerPak) { LogControllerPakData("Write: After Processing"); } diff --git a/Source/Project64/N64 System/Mips/Register Class.cpp b/Source/Project64/N64 System/Mips/Register Class.cpp index f3bc474d5..1cb8fd13f 100644 --- a/Source/Project64/N64 System/Mips/Register Class.cpp +++ b/Source/Project64/N64 System/Mips/Register Class.cpp @@ -463,7 +463,7 @@ bool CRegisters::DoIntrException(bool DelaySlot) return false; } - if (LogOptions.GenerateLog && LogOptions.LogExceptions && !LogOptions.NoInterrupts) + if (g_LogOptions.GenerateLog && g_LogOptions.LogExceptions && !g_LogOptions.NoInterrupts) { LogMessage("%08X: Interrupt Generated", m_PROGRAM_COUNTER); } diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index 944f0008d..1f3d363ae 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -296,8 +296,8 @@ void CN64System::StartEmulation2 ( bool NewThread ) if (bHaveDebugger()) { - LogOptions.GenerateLog = g_Settings->LoadDword(Debugger_GenerateDebugLog); - LoadLogOptions(&LogOptions, FALSE); + g_LogOptions.GenerateLog = g_Settings->LoadBool(Debugger_GenerateDebugLog); + LoadLogOptions(&g_LogOptions, FALSE); StartLog(); } diff --git a/Source/Project64/Project64.vcxproj b/Source/Project64/Project64.vcxproj index 53f2f7048..c0fc9b536 100644 --- a/Source/Project64/Project64.vcxproj +++ b/Source/Project64/Project64.vcxproj @@ -41,6 +41,7 @@ + @@ -122,7 +123,6 @@ - @@ -178,6 +178,7 @@ + @@ -267,7 +268,6 @@ - diff --git a/Source/Project64/Project64.vcxproj.filters b/Source/Project64/Project64.vcxproj.filters index 2ad467552..e831f9869 100644 --- a/Source/Project64/Project64.vcxproj.filters +++ b/Source/Project64/Project64.vcxproj.filters @@ -330,9 +330,6 @@ Source Files\N64 System Source\Mips Source - - Source Files\N64 System Source\C Core Source - Source Files\N64 System Source\C Core Source @@ -420,6 +417,9 @@ Source Files\User Interface Source + + Source Files + @@ -722,9 +722,6 @@ Header Files\N64 System Headers\Mips Headers - - Header Files\N64 System Headers\C Core Headers - Header Files\N64 System Headers\C Core Headers @@ -848,5 +845,8 @@ Header Files\User Interface Headers + + Header Files + \ No newline at end of file From 08cc72f6edb55e086178f2cd0886e79d9d0dcf8c Mon Sep 17 00:00:00 2001 From: zilmar Date: Sun, 8 Nov 2015 20:37:29 +1100 Subject: [PATCH 087/213] [Project64] Update OpCode.h --- .../Interpreter/Interpreter CPU.cpp | 6 +- Source/Project64/N64 System/Mips/OpCode.h | 202 +++++++++--------- .../N64 System/Recompiler/Code Block.cpp | 2 +- .../N64 System/Recompiler/Code Section.cpp | 6 +- .../N64 System/Recompiler/Loop Analysis.cpp | 2 +- .../N64 System/Recompiler/Recompiler Ops.cpp | 2 +- 6 files changed, 112 insertions(+), 108 deletions(-) diff --git a/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp b/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp index 62596c765..34e184cd3 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp @@ -21,7 +21,7 @@ bool DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2) { OPCODE Command; - if (!g_MMU->LW_VAddr(PC + 4, Command.Hex)) + if (!g_MMU->LW_VAddr(PC + 4, (DWORD &)Command.Hex)) { //g_Notify->DisplayError(L"Failed to load word 2"); //ExitThread(0); @@ -276,7 +276,7 @@ void CInterpreterCPU::ExecuteCPU() { while (!Done) { - if (g_MMU->LW_VAddr(PROGRAM_COUNTER, Opcode.Hex)) + if (g_MMU->LW_VAddr(PROGRAM_COUNTER, (DWORD &)Opcode.Hex)) { /*if (PROGRAM_COUNTER > 0x80000300 && PROGRAM_COUNTER< 0x80380000) { @@ -367,7 +367,7 @@ void CInterpreterCPU::ExecuteOps(int Cycles) return; } - if (g_MMU->LW_VAddr(PROGRAM_COUNTER, Opcode.Hex)) + if (g_MMU->LW_VAddr(PROGRAM_COUNTER, (DWORD &)Opcode.Hex)) { /*if (PROGRAM_COUNTER > 0x80000300 && PROGRAM_COUNTER< 0x80380000) { diff --git a/Source/Project64/N64 System/Mips/OpCode.h b/Source/Project64/N64 System/Mips/OpCode.h index cc3b0a19d..f764cfcf3 100644 --- a/Source/Project64/N64 System/Mips/OpCode.h +++ b/Source/Project64/N64 System/Mips/OpCode.h @@ -10,138 +10,142 @@ ****************************************************************************/ #pragma once +#pragma warning(push) +#pragma warning(disable : 4201) // warning C4201: nonstandard extension used : nameless struct/union + union OPCODE { - unsigned long Hex; - unsigned char Ascii[4]; - - struct - { - unsigned offset : 16; - unsigned rt : 5; - unsigned rs : 5; - unsigned op : 6; - }; + uint32_t Hex; + uint8_t Ascii[4]; - struct - { - unsigned immediate : 16; - unsigned : 5; - unsigned base : 5; - unsigned : 6; - }; - - struct - { - unsigned target : 26; - unsigned : 6; - }; - - struct - { - unsigned funct : 6; - unsigned sa : 5; - unsigned rd : 5; - unsigned : 5; - unsigned : 5; - unsigned : 6; - }; + struct + { + unsigned offset : 16; + unsigned rt : 5; + unsigned rs : 5; + unsigned op : 6; + }; - struct - { - unsigned : 6; - unsigned fd : 5; - unsigned fs : 5; - unsigned ft : 5; - unsigned fmt : 5; - unsigned : 6; - }; + struct + { + unsigned immediate : 16; + unsigned : 5; + unsigned base : 5; + unsigned : 6; + }; + + struct + { + unsigned target : 26; + unsigned : 6; + }; + + struct + { + unsigned funct : 6; + unsigned sa : 5; + unsigned rd : 5; + unsigned : 5; + unsigned : 5; + unsigned : 6; + }; + + struct + { + unsigned : 6; + unsigned fd : 5; + unsigned fs : 5; + unsigned ft : 5; + unsigned fmt : 5; + unsigned : 6; + }; }; +#pragma warning(pop) enum R4300iOpCodes { - R4300i_SPECIAL = 0, R4300i_REGIMM = 1, R4300i_J = 2, R4300i_JAL = 3, - R4300i_BEQ = 4, R4300i_BNE = 5, R4300i_BLEZ = 6, R4300i_BGTZ = 7, - R4300i_ADDI = 8, R4300i_ADDIU = 9, R4300i_SLTI = 10, R4300i_SLTIU = 11, - R4300i_ANDI = 12, R4300i_ORI = 13, R4300i_XORI = 14, R4300i_LUI = 15, - R4300i_CP0 = 16, R4300i_CP1 = 17, R4300i_BEQL = 20, R4300i_BNEL = 21, - R4300i_BLEZL = 22, R4300i_BGTZL = 23, R4300i_DADDI = 24, R4300i_DADDIU = 25, - R4300i_LDL = 26, R4300i_LDR = 27, R4300i_LB = 32, R4300i_LH = 33, - R4300i_LWL = 34, R4300i_LW = 35, R4300i_LBU = 36, R4300i_LHU = 37, - R4300i_LWR = 38, R4300i_LWU = 39, R4300i_SB = 40, R4300i_SH = 41, - R4300i_SWL = 42, R4300i_SW = 43, R4300i_SDL = 44, R4300i_SDR = 45, - R4300i_SWR = 46, R4300i_CACHE = 47, R4300i_LL = 48, R4300i_LWC1 = 49, - R4300i_LDC1 = 53, R4300i_LD = 55, R4300i_SC = 56, R4300i_SWC1 = 57, - R4300i_SDC1 = 61, R4300i_SDC2 = 62, R4300i_SD = 63 + R4300i_SPECIAL = 0, R4300i_REGIMM = 1, R4300i_J = 2, R4300i_JAL = 3, + R4300i_BEQ = 4, R4300i_BNE = 5, R4300i_BLEZ = 6, R4300i_BGTZ = 7, + R4300i_ADDI = 8, R4300i_ADDIU = 9, R4300i_SLTI = 10, R4300i_SLTIU = 11, + R4300i_ANDI = 12, R4300i_ORI = 13, R4300i_XORI = 14, R4300i_LUI = 15, + R4300i_CP0 = 16, R4300i_CP1 = 17, R4300i_BEQL = 20, R4300i_BNEL = 21, + R4300i_BLEZL = 22, R4300i_BGTZL = 23, R4300i_DADDI = 24, R4300i_DADDIU = 25, + R4300i_LDL = 26, R4300i_LDR = 27, R4300i_LB = 32, R4300i_LH = 33, + R4300i_LWL = 34, R4300i_LW = 35, R4300i_LBU = 36, R4300i_LHU = 37, + R4300i_LWR = 38, R4300i_LWU = 39, R4300i_SB = 40, R4300i_SH = 41, + R4300i_SWL = 42, R4300i_SW = 43, R4300i_SDL = 44, R4300i_SDR = 45, + R4300i_SWR = 46, R4300i_CACHE = 47, R4300i_LL = 48, R4300i_LWC1 = 49, + R4300i_LDC1 = 53, R4300i_LD = 55, R4300i_SC = 56, R4300i_SWC1 = 57, + R4300i_SDC1 = 61, R4300i_SDC2 = 62, R4300i_SD = 63 }; enum R4300iSpecialOpCodes { - R4300i_SPECIAL_SLL = 0, R4300i_SPECIAL_SRL = 2, R4300i_SPECIAL_SRA = 3, - R4300i_SPECIAL_SLLV = 4, R4300i_SPECIAL_SRLV = 6, R4300i_SPECIAL_SRAV = 7, - R4300i_SPECIAL_JR = 8, R4300i_SPECIAL_JALR = 9, R4300i_SPECIAL_SYSCALL = 12, - R4300i_SPECIAL_BREAK = 13, R4300i_SPECIAL_SYNC = 15, R4300i_SPECIAL_MFHI = 16, - R4300i_SPECIAL_MTHI = 17, R4300i_SPECIAL_MFLO = 18, R4300i_SPECIAL_MTLO = 19, - R4300i_SPECIAL_DSLLV = 20, R4300i_SPECIAL_DSRLV = 22, R4300i_SPECIAL_DSRAV = 23, - R4300i_SPECIAL_MULT = 24, R4300i_SPECIAL_MULTU = 25, R4300i_SPECIAL_DIV = 26, - R4300i_SPECIAL_DIVU = 27, R4300i_SPECIAL_DMULT = 28, R4300i_SPECIAL_DMULTU = 29, - R4300i_SPECIAL_DDIV = 30, R4300i_SPECIAL_DDIVU = 31, R4300i_SPECIAL_ADD = 32, - R4300i_SPECIAL_ADDU = 33, R4300i_SPECIAL_SUB = 34, R4300i_SPECIAL_SUBU = 35, - R4300i_SPECIAL_AND = 36, R4300i_SPECIAL_OR = 37, R4300i_SPECIAL_XOR = 38, - R4300i_SPECIAL_NOR = 39, R4300i_SPECIAL_SLT = 42, R4300i_SPECIAL_SLTU = 43, - R4300i_SPECIAL_DADD = 44, R4300i_SPECIAL_DADDU = 45, R4300i_SPECIAL_DSUB = 46, - R4300i_SPECIAL_DSUBU = 47, R4300i_SPECIAL_TGE = 48, R4300i_SPECIAL_TGEU = 49, - R4300i_SPECIAL_TLT = 50, R4300i_SPECIAL_TLTU = 51, R4300i_SPECIAL_TEQ = 52, - R4300i_SPECIAL_TNE = 54, R4300i_SPECIAL_DSLL = 56, R4300i_SPECIAL_DSRL = 58, - R4300i_SPECIAL_DSRA = 59, R4300i_SPECIAL_DSLL32 = 60, R4300i_SPECIAL_DSRL32 = 62, - R4300i_SPECIAL_DSRA32 = 63 + R4300i_SPECIAL_SLL = 0, R4300i_SPECIAL_SRL = 2, R4300i_SPECIAL_SRA = 3, + R4300i_SPECIAL_SLLV = 4, R4300i_SPECIAL_SRLV = 6, R4300i_SPECIAL_SRAV = 7, + R4300i_SPECIAL_JR = 8, R4300i_SPECIAL_JALR = 9, R4300i_SPECIAL_SYSCALL = 12, + R4300i_SPECIAL_BREAK = 13, R4300i_SPECIAL_SYNC = 15, R4300i_SPECIAL_MFHI = 16, + R4300i_SPECIAL_MTHI = 17, R4300i_SPECIAL_MFLO = 18, R4300i_SPECIAL_MTLO = 19, + R4300i_SPECIAL_DSLLV = 20, R4300i_SPECIAL_DSRLV = 22, R4300i_SPECIAL_DSRAV = 23, + R4300i_SPECIAL_MULT = 24, R4300i_SPECIAL_MULTU = 25, R4300i_SPECIAL_DIV = 26, + R4300i_SPECIAL_DIVU = 27, R4300i_SPECIAL_DMULT = 28, R4300i_SPECIAL_DMULTU = 29, + R4300i_SPECIAL_DDIV = 30, R4300i_SPECIAL_DDIVU = 31, R4300i_SPECIAL_ADD = 32, + R4300i_SPECIAL_ADDU = 33, R4300i_SPECIAL_SUB = 34, R4300i_SPECIAL_SUBU = 35, + R4300i_SPECIAL_AND = 36, R4300i_SPECIAL_OR = 37, R4300i_SPECIAL_XOR = 38, + R4300i_SPECIAL_NOR = 39, R4300i_SPECIAL_SLT = 42, R4300i_SPECIAL_SLTU = 43, + R4300i_SPECIAL_DADD = 44, R4300i_SPECIAL_DADDU = 45, R4300i_SPECIAL_DSUB = 46, + R4300i_SPECIAL_DSUBU = 47, R4300i_SPECIAL_TGE = 48, R4300i_SPECIAL_TGEU = 49, + R4300i_SPECIAL_TLT = 50, R4300i_SPECIAL_TLTU = 51, R4300i_SPECIAL_TEQ = 52, + R4300i_SPECIAL_TNE = 54, R4300i_SPECIAL_DSLL = 56, R4300i_SPECIAL_DSRL = 58, + R4300i_SPECIAL_DSRA = 59, R4300i_SPECIAL_DSLL32 = 60, R4300i_SPECIAL_DSRL32 = 62, + R4300i_SPECIAL_DSRA32 = 63 }; -enum R4300iRegImmOpCodes +enum R4300iRegImmOpCodes { - R4300i_REGIMM_BLTZ = 0, R4300i_REGIMM_BGEZ = 1, R4300i_REGIMM_BLTZL = 2, - R4300i_REGIMM_BGEZL = 3, R4300i_REGIMM_TGEI = 8, R4300i_REGIMM_TGEIU = 9, - R4300i_REGIMM_TLTI = 10, R4300i_REGIMM_TLTIU = 11, R4300i_REGIMM_TEQI = 12, - R4300i_REGIMM_TNEI = 14, R4300i_REGIMM_BLTZAL = 16, R4300i_REGIMM_BGEZAL = 17, - R4300i_REGIMM_BLTZALL = 18, R4300i_REGIMM_BGEZALL = 19, + R4300i_REGIMM_BLTZ = 0, R4300i_REGIMM_BGEZ = 1, R4300i_REGIMM_BLTZL = 2, + R4300i_REGIMM_BGEZL = 3, R4300i_REGIMM_TGEI = 8, R4300i_REGIMM_TGEIU = 9, + R4300i_REGIMM_TLTI = 10, R4300i_REGIMM_TLTIU = 11, R4300i_REGIMM_TEQI = 12, + R4300i_REGIMM_TNEI = 14, R4300i_REGIMM_BLTZAL = 16, R4300i_REGIMM_BGEZAL = 17, + R4300i_REGIMM_BLTZALL = 18, R4300i_REGIMM_BGEZALL = 19, }; enum R4300iCOP0OpCodes { - R4300i_COP0_MF = 0, R4300i_COP0_MT = 4 + R4300i_COP0_MF = 0, R4300i_COP0_MT = 4 }; enum R4300iCOP0C0OpCodes { - R4300i_COP0_CO_TLBR = 1, R4300i_COP0_CO_TLBWI = 2, R4300i_COP0_CO_TLBWR = 6, - R4300i_COP0_CO_TLBP = 8, R4300i_COP0_CO_ERET = 24, + R4300i_COP0_CO_TLBR = 1, R4300i_COP0_CO_TLBWI = 2, R4300i_COP0_CO_TLBWR = 6, + R4300i_COP0_CO_TLBP = 8, R4300i_COP0_CO_ERET = 24, }; enum R4300iCOP1OpCodes { - R4300i_COP1_MF = 0, R4300i_COP1_DMF = 1, R4300i_COP1_CF = 2, R4300i_COP1_MT = 4, - R4300i_COP1_DMT = 5, R4300i_COP1_CT = 6, R4300i_COP1_BC = 8, R4300i_COP1_S = 16, - R4300i_COP1_D = 17, R4300i_COP1_W = 20, R4300i_COP1_L = 21, + R4300i_COP1_MF = 0, R4300i_COP1_DMF = 1, R4300i_COP1_CF = 2, R4300i_COP1_MT = 4, + R4300i_COP1_DMT = 5, R4300i_COP1_CT = 6, R4300i_COP1_BC = 8, R4300i_COP1_S = 16, + R4300i_COP1_D = 17, R4300i_COP1_W = 20, R4300i_COP1_L = 21, }; enum R4300iCOP1BcOpCodes { - R4300i_COP1_BC_BCF = 0, R4300i_COP1_BC_BCT = 1, R4300i_COP1_BC_BCFL = 2, - R4300i_COP1_BC_BCTL = 3, + R4300i_COP1_BC_BCF = 0, R4300i_COP1_BC_BCT = 1, R4300i_COP1_BC_BCFL = 2, + R4300i_COP1_BC_BCTL = 3, }; enum R4300iCOP1FuntOpCodes { - R4300i_COP1_FUNCT_ADD = 0, R4300i_COP1_FUNCT_SUB = 1, R4300i_COP1_FUNCT_MUL = 2, - R4300i_COP1_FUNCT_DIV = 3, R4300i_COP1_FUNCT_SQRT = 4, R4300i_COP1_FUNCT_ABS = 5, - R4300i_COP1_FUNCT_MOV = 6, R4300i_COP1_FUNCT_NEG = 7, R4300i_COP1_FUNCT_ROUND_L = 8, - R4300i_COP1_FUNCT_TRUNC_L = 9, R4300i_COP1_FUNCT_CEIL_L = 10,R4300i_COP1_FUNCT_FLOOR_L = 11, - R4300i_COP1_FUNCT_ROUND_W = 12,R4300i_COP1_FUNCT_TRUNC_W = 13,R4300i_COP1_FUNCT_CEIL_W = 14, - R4300i_COP1_FUNCT_FLOOR_W = 15,R4300i_COP1_FUNCT_CVT_S = 32,R4300i_COP1_FUNCT_CVT_D = 33, - R4300i_COP1_FUNCT_CVT_W = 36,R4300i_COP1_FUNCT_CVT_L = 37,R4300i_COP1_FUNCT_C_F = 48, - R4300i_COP1_FUNCT_C_UN = 49,R4300i_COP1_FUNCT_C_EQ = 50,R4300i_COP1_FUNCT_C_UEQ = 51, - R4300i_COP1_FUNCT_C_OLT = 52,R4300i_COP1_FUNCT_C_ULT = 53,R4300i_COP1_FUNCT_C_OLE = 54, - R4300i_COP1_FUNCT_C_ULE = 55,R4300i_COP1_FUNCT_C_SF = 56,R4300i_COP1_FUNCT_C_NGLE = 57, - R4300i_COP1_FUNCT_C_SEQ = 58,R4300i_COP1_FUNCT_C_NGL = 59,R4300i_COP1_FUNCT_C_LT = 60, - R4300i_COP1_FUNCT_C_NGE = 61,R4300i_COP1_FUNCT_C_LE = 62,R4300i_COP1_FUNCT_C_NGT = 63, + R4300i_COP1_FUNCT_ADD = 0, R4300i_COP1_FUNCT_SUB = 1, R4300i_COP1_FUNCT_MUL = 2, + R4300i_COP1_FUNCT_DIV = 3, R4300i_COP1_FUNCT_SQRT = 4, R4300i_COP1_FUNCT_ABS = 5, + R4300i_COP1_FUNCT_MOV = 6, R4300i_COP1_FUNCT_NEG = 7, R4300i_COP1_FUNCT_ROUND_L = 8, + R4300i_COP1_FUNCT_TRUNC_L = 9, R4300i_COP1_FUNCT_CEIL_L = 10, R4300i_COP1_FUNCT_FLOOR_L = 11, + R4300i_COP1_FUNCT_ROUND_W = 12, R4300i_COP1_FUNCT_TRUNC_W = 13, R4300i_COP1_FUNCT_CEIL_W = 14, + R4300i_COP1_FUNCT_FLOOR_W = 15, R4300i_COP1_FUNCT_CVT_S = 32, R4300i_COP1_FUNCT_CVT_D = 33, + R4300i_COP1_FUNCT_CVT_W = 36, R4300i_COP1_FUNCT_CVT_L = 37, R4300i_COP1_FUNCT_C_F = 48, + R4300i_COP1_FUNCT_C_UN = 49, R4300i_COP1_FUNCT_C_EQ = 50, R4300i_COP1_FUNCT_C_UEQ = 51, + R4300i_COP1_FUNCT_C_OLT = 52, R4300i_COP1_FUNCT_C_ULT = 53, R4300i_COP1_FUNCT_C_OLE = 54, + R4300i_COP1_FUNCT_C_ULE = 55, R4300i_COP1_FUNCT_C_SF = 56, R4300i_COP1_FUNCT_C_NGLE = 57, + R4300i_COP1_FUNCT_C_SEQ = 58, R4300i_COP1_FUNCT_C_NGL = 59, R4300i_COP1_FUNCT_C_LT = 60, + R4300i_COP1_FUNCT_C_NGE = 61, R4300i_COP1_FUNCT_C_LE = 62, R4300i_COP1_FUNCT_C_NGT = 63, }; diff --git a/Source/Project64/N64 System/Recompiler/Code Block.cpp b/Source/Project64/N64 System/Recompiler/Code Block.cpp index adcae84cd..c67100814 100644 --- a/Source/Project64/N64 System/Recompiler/Code Block.cpp +++ b/Source/Project64/N64 System/Recompiler/Code Block.cpp @@ -397,7 +397,7 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin PermLoop = false; OPCODE Command; - if (!g_MMU->LW_VAddr(PC, Command.Hex)) + if (!g_MMU->LW_VAddr(PC, (DWORD &)Command.Hex)) { g_Notify->BreakPoint(__FILEW__,__LINE__); return false; diff --git a/Source/Project64/N64 System/Recompiler/Code Section.cpp b/Source/Project64/N64 System/Recompiler/Code Section.cpp index 6da875477..4e7c72d4a 100644 --- a/Source/Project64/N64 System/Recompiler/Code Section.cpp +++ b/Source/Project64/N64 System/Recompiler/Code Section.cpp @@ -17,7 +17,7 @@ bool DelaySlotEffectsCompare(DWORD PC, DWORD Reg1, DWORD Reg2); static bool DelaySlotEffectsJump(DWORD JumpPC) { OPCODE Command; - if (!g_MMU->LW_VAddr(JumpPC, Command.Hex)) + if (!g_MMU->LW_VAddr(JumpPC, (DWORD &)Command.Hex)) return true; switch (Command.op) { @@ -58,7 +58,7 @@ static bool DelaySlotEffectsJump(DWORD JumpPC) { bool EffectDelaySlot = false; OPCODE NewCommand; - if (!g_MMU->LW_VAddr(JumpPC + 4, NewCommand.Hex)) { + if (!g_MMU->LW_VAddr(JumpPC + 4, (DWORD &)NewCommand.Hex)) { return true; } @@ -932,7 +932,7 @@ bool CCodeSection::GenerateX86Code ( DWORD Test ) do { __try { - if (!g_MMU->LW_VAddr(m_CompilePC,m_Opcode.Hex)) + if (!g_MMU->LW_VAddr(m_CompilePC,(DWORD &)m_Opcode.Hex)) { g_Notify->DisplayError(GS(MSG_FAIL_LOAD_WORD)); ExitThread(0); diff --git a/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp b/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp index e8ebe7760..a9b3a2e05 100644 --- a/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp +++ b/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp @@ -167,7 +167,7 @@ bool LoopAnalysis::CheckLoopRegisterUsage( CCodeSection * Section) CPU_Message("ContinueSectionPC = %08X",ContinueSectionPC); do { - if (!g_MMU->LW_VAddr(m_PC, m_Command.Hex)) + if (!g_MMU->LW_VAddr(m_PC, (DWORD &)m_Command.Hex)) { g_Notify->BreakPoint(__FILEW__,__LINE__); return false; diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp index eb9ecb840..7a81c111d 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp @@ -61,7 +61,7 @@ void CRecompilerOps::Compile_Branch (CRecompilerOps::BranchFunction CompareFunc, { OPCODE Command; - if (!g_MMU->LW_VAddr(m_CompilePC + 4, Command.Hex)) { + if (!g_MMU->LW_VAddr(m_CompilePC + 4, (DWORD &)Command.Hex)) { g_Notify->DisplayError(GS(MSG_FAIL_LOAD_WORD)); ExitThread(0); } From f6160e3d68c03df17232953157c2dbe82b2ab424 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 9 Nov 2015 05:04:32 +1100 Subject: [PATCH 088/213] [Project64] Get Memory Virtual Mem.cpp cleanup and use standard types --- Source/Project64/Logging.cpp | 34 +- .../Debugger/Debugger - Memory Search.cpp | 4 +- .../Debugger/Debugger - View Memory.cpp | 8 +- .../Interpreter/Interpreter CPU.cpp | 6 +- .../Interpreter/Interpreter Ops 32.cpp | 10 +- .../Interpreter/Interpreter Ops.cpp | 16 +- .../Project64/N64 System/Mips/Memory Class.h | 123 +- .../N64 System/Mips/Memory Virtual Mem.cpp | 10173 ++++++++-------- .../N64 System/Mips/Memory Virtual Mem.h | 272 +- .../N64 System/Mips/TranslateVaddr.h | 9 +- Source/Project64/N64 System/N64 Class.cpp | 8 +- Source/Project64/N64 System/N64 Class.h | 2 +- .../N64 System/Recompiler/Code Block.cpp | 4 +- .../N64 System/Recompiler/Code Section.cpp | 6 +- .../N64 System/Recompiler/Loop Analysis.cpp | 2 +- .../Recompiler/Recompiler Class.cpp | 24 +- .../N64 System/Recompiler/Recompiler Ops.cpp | 4 +- 17 files changed, 5349 insertions(+), 5356 deletions(-) diff --git a/Source/Project64/Logging.cpp b/Source/Project64/Logging.cpp index 1f4180560..5f22e34ee 100644 --- a/Source/Project64/Logging.cpp +++ b/Source/Project64/Logging.cpp @@ -204,7 +204,7 @@ void Log_LW (uint32_t PC, uint32_t VAddr) if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 ) { uint32_t PAddr; - if (!g_TransVaddr->TranslateVaddr(VAddr,(DWORD &)PAddr)) + if (!g_TransVaddr->TranslateVaddr(VAddr,PAddr)) { if (g_LogOptions.LogUnknown) { @@ -226,7 +226,7 @@ void Log_LW (uint32_t PC, uint32_t VAddr) { return; } - g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + g_MMU->LW_VAddr(VAddr,Value); switch (VAddr) { @@ -253,7 +253,7 @@ void Log_LW (uint32_t PC, uint32_t VAddr) { return; } - g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + g_MMU->LW_VAddr(VAddr,Value); switch (VAddr) { @@ -274,7 +274,7 @@ void Log_LW (uint32_t PC, uint32_t VAddr) { return; } - g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + g_MMU->LW_VAddr(VAddr,Value); LogMessage("%08X: read from SP_PC (%08X)",PC, Value); return; } @@ -284,7 +284,7 @@ void Log_LW (uint32_t PC, uint32_t VAddr) { return; } - g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + g_MMU->LW_VAddr(VAddr,Value); switch (VAddr) { @@ -304,7 +304,7 @@ void Log_LW (uint32_t PC, uint32_t VAddr) { return; } - g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + g_MMU->LW_VAddr(VAddr,Value); switch (VAddr) { @@ -320,7 +320,7 @@ void Log_LW (uint32_t PC, uint32_t VAddr) { return; } - g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + g_MMU->LW_VAddr(VAddr,Value); switch (VAddr) { @@ -346,7 +346,7 @@ void Log_LW (uint32_t PC, uint32_t VAddr) { return; } - g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + g_MMU->LW_VAddr(VAddr,Value); switch (VAddr) { @@ -364,7 +364,7 @@ void Log_LW (uint32_t PC, uint32_t VAddr) { return; } - g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + g_MMU->LW_VAddr(VAddr,Value); switch (VAddr) { @@ -389,7 +389,7 @@ void Log_LW (uint32_t PC, uint32_t VAddr) { return; } - g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + g_MMU->LW_VAddr(VAddr,Value); switch (VAddr) { @@ -409,7 +409,7 @@ void Log_LW (uint32_t PC, uint32_t VAddr) { return; } - g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + g_MMU->LW_VAddr(VAddr,Value); LogMessage("%08X: read from SI_DRAM_ADDR_REG (%08X)",PC, Value); return; } @@ -419,7 +419,7 @@ void Log_LW (uint32_t PC, uint32_t VAddr) { return; } - g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + g_MMU->LW_VAddr(VAddr,Value); LogMessage("%08X: read from SI_PIF_ADDR_RD64B_REG (%08X)",PC, Value); return; } @@ -429,7 +429,7 @@ void Log_LW (uint32_t PC, uint32_t VAddr) { return; } - g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + g_MMU->LW_VAddr(VAddr,Value); LogMessage("%08X: read from SI_PIF_ADDR_WR64B_REG (%08X)",PC, Value); return; } @@ -439,7 +439,7 @@ void Log_LW (uint32_t PC, uint32_t VAddr) { return; } - g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + g_MMU->LW_VAddr(VAddr,Value); LogMessage("%08X: read from SI_STATUS_REG (%08X)",PC, Value); return; } @@ -453,7 +453,7 @@ void Log_LW (uint32_t PC, uint32_t VAddr) { return; } - g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + g_MMU->LW_VAddr(VAddr,Value); LogMessage("%08X: read word from Pif Ram at 0x%X (%08X)",PC,VAddr - 0xBFC007C0, Value); return; } @@ -468,7 +468,7 @@ void Log_LW (uint32_t PC, uint32_t VAddr) return; } - g_MMU->LW_VAddr(VAddr,(DWORD &)Value); + g_MMU->LW_VAddr(VAddr,Value); switch (VAddr) { case 0xB0000004: LogMessage("%08X: read from Rom Clock Rate (%08X)",PC, Value); break; @@ -497,7 +497,7 @@ void Log_SW (uint32_t PC, uint32_t VAddr, uint32_t Value) if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 ) { uint32_t PAddr; - if (!g_TransVaddr->TranslateVaddr(VAddr,(DWORD &)PAddr)) + if (!g_TransVaddr->TranslateVaddr(VAddr,PAddr)) { if (g_LogOptions.LogUnknown) { diff --git a/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp b/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp index 763371662..4fdc325ec 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp @@ -326,7 +326,7 @@ void CDebugMemorySearch::SearchForValue(void) } break; case _32Bit: - valid = g_MMU->LW_PAddr(Result.PAddr, NewValue); + valid = g_MMU->LW_PAddr(Result.PAddr, (uint32_t &)NewValue); break; default: g_Notify->BreakPoint(__FILEW__, __LINE__); @@ -461,7 +461,7 @@ void CDebugMemorySearch::SearchForUnknown() } break; case _32Bit: - valid = g_MMU->LW_PAddr(Result.PAddr, NewValue); + valid = g_MMU->LW_PAddr(Result.PAddr, (uint32_t &)NewValue); break; default: g_Notify->BreakPoint(__FILEW__, __LINE__); diff --git a/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp b/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp index 8c577ab73..87c217812 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp @@ -402,14 +402,14 @@ void CDebugMemoryView::RefreshMemory(bool ResetCompare) if (m_DataVAddrr) { - if (!g_MMU->LW_VAddr(m_DataStartLoc & ~3, word.UW)) + if (!g_MMU->LW_VAddr(m_DataStartLoc & ~3, (uint32_t &)word.UW)) { ValidData = false; } } else { - if (!g_MMU->LW_PAddr(m_DataStartLoc & ~3, word.UW)) + if (!g_MMU->LW_PAddr(m_DataStartLoc & ~3, (uint32_t &)word.UW)) { ValidData = false; } @@ -438,14 +438,14 @@ void CDebugMemoryView::RefreshMemory(bool ResetCompare) if (m_DataVAddrr) { - if (!g_MMU->LW_VAddr(Pos, word.UW)) + if (!g_MMU->LW_VAddr(Pos, (uint32_t &)word.UW)) { ValidData = false; } } else { - if (!g_MMU->LW_PAddr(Pos, word.UW)) + if (!g_MMU->LW_PAddr(Pos, (uint32_t &)word.UW)) { ValidData = false; } diff --git a/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp b/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp index 34e184cd3..62596c765 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp @@ -21,7 +21,7 @@ bool DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2) { OPCODE Command; - if (!g_MMU->LW_VAddr(PC + 4, (DWORD &)Command.Hex)) + if (!g_MMU->LW_VAddr(PC + 4, Command.Hex)) { //g_Notify->DisplayError(L"Failed to load word 2"); //ExitThread(0); @@ -276,7 +276,7 @@ void CInterpreterCPU::ExecuteCPU() { while (!Done) { - if (g_MMU->LW_VAddr(PROGRAM_COUNTER, (DWORD &)Opcode.Hex)) + if (g_MMU->LW_VAddr(PROGRAM_COUNTER, Opcode.Hex)) { /*if (PROGRAM_COUNTER > 0x80000300 && PROGRAM_COUNTER< 0x80380000) { @@ -367,7 +367,7 @@ void CInterpreterCPU::ExecuteOps(int Cycles) return; } - if (g_MMU->LW_VAddr(PROGRAM_COUNTER, (DWORD &)Opcode.Hex)) + if (g_MMU->LW_VAddr(PROGRAM_COUNTER, Opcode.Hex)) { /*if (PROGRAM_COUNTER > 0x80000300 && PROGRAM_COUNTER< 0x80380000) { diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp index c29282520..391c5f389 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp @@ -929,7 +929,7 @@ void R4300iOp32::LWL() Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; Offset = Address & 3; - if (!g_MMU->LW_VAddr((Address & ~3),Value)) + if (!g_MMU->LW_VAddr((Address & ~3),(uint32_t &)Value)) { if (bShowTLBMisses()) { @@ -956,7 +956,7 @@ void R4300iOp32::LW() Log_LW((*_PROGRAM_COUNTER),Address); } - if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + if (!g_MMU->LW_VAddr(Address,(uint32_t &)_GPR[m_Opcode.rt].UW[0])) { if (bShowTLBMisses()) { @@ -1015,7 +1015,7 @@ void R4300iOp32::LWR() Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; Offset = Address & 3; - if (!g_MMU->LW_VAddr((Address & ~3),Value)) + if (!g_MMU->LW_VAddr((Address & ~3),(uint32_t &)Value)) { g_Notify->BreakPoint(__FILEW__,__LINE__); if (bShowTLBMisses()) @@ -1037,7 +1037,7 @@ void R4300iOp32::LWU() ADDRESS_ERROR_EXCEPTION(Address, true); } - if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + if (!g_MMU->LW_VAddr(Address,(uint32_t &)_GPR[m_Opcode.rt].UW[0])) { if (bShowTLBMisses()) { @@ -1060,7 +1060,7 @@ void R4300iOp32::LL() ADDRESS_ERROR_EXCEPTION(Address, true); } - if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + if (!g_MMU->LW_VAddr(Address,(uint32_t &)_GPR[m_Opcode.rt].UW[0])) { if (bShowTLBMisses()) { diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp index c3c6c14e4..be46680a5 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp @@ -1093,7 +1093,7 @@ void R4300iOp::LWL() Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; Offset = Address & 3; - if (!g_MMU->LW_VAddr((Address & ~3),Value)) + if (!g_MMU->LW_VAddr((Address & ~3),(uint32_t &)Value)) { g_Notify->BreakPoint(__FILEW__,__LINE__); if (bShowTLBMisses()) @@ -1120,7 +1120,7 @@ void R4300iOp::LW() Log_LW((*_PROGRAM_COUNTER),Address); } - if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + if (!g_MMU->LW_VAddr(Address,(uint32_t &)_GPR[m_Opcode.rt].UW[0])) { if (bShowTLBMisses()) { @@ -1179,7 +1179,7 @@ void R4300iOp::LWR() Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; Offset = Address & 3; - if (!g_MMU->LW_VAddr((Address & ~3),Value)) + if (!g_MMU->LW_VAddr((Address & ~3),(uint32_t &)Value)) { g_Notify->BreakPoint(__FILEW__,__LINE__); if (bShowTLBMisses()) @@ -1201,7 +1201,7 @@ void R4300iOp::LWU() ADDRESS_ERROR_EXCEPTION(Address, true); } - if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + if (!g_MMU->LW_VAddr(Address,(uint32_t &)_GPR[m_Opcode.rt].UW[0])) { if (bShowTLBMisses()) { @@ -1258,7 +1258,7 @@ void R4300iOp::SWL() Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; Offset = Address & 3; - if (!g_MMU->LW_VAddr((Address & ~3),Value)) + if (!g_MMU->LW_VAddr((Address & ~3),(uint32_t &)Value)) { if (bHaveDebugger()) { @@ -1414,7 +1414,7 @@ void R4300iOp::SWR() Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; Offset = Address & 3; - if (!g_MMU->LW_VAddr((Address & ~3),Value)) + if (!g_MMU->LW_VAddr((Address & ~3),(uint32_t &)Value)) { if (bHaveDebugger()) { @@ -1461,7 +1461,7 @@ void R4300iOp::LL() ADDRESS_ERROR_EXCEPTION(Address, true); } - if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + if (!g_MMU->LW_VAddr(Address,(uint32_t &)_GPR[m_Opcode.rt].UW[0])) { if (bShowTLBMisses()) { @@ -1484,7 +1484,7 @@ void R4300iOp::LWC1() { ADDRESS_ERROR_EXCEPTION(Address, true); } - if (!g_MMU->LW_VAddr(Address,*(DWORD *)_FPR_S[m_Opcode.ft])) + if (!g_MMU->LW_VAddr(Address,*(uint32_t *)_FPR_S[m_Opcode.ft])) { if (bShowTLBMisses()) { diff --git a/Source/Project64/N64 System/Mips/Memory Class.h b/Source/Project64/N64 System/Mips/Memory Class.h index a35049058..73579140a 100644 --- a/Source/Project64/N64 System/Mips/Memory Class.h +++ b/Source/Project64/N64 System/Mips/Memory Class.h @@ -10,78 +10,75 @@ ****************************************************************************/ #pragma once -#include - -interface CMipsMemory_CallBack +__interface CMipsMemory_CallBack { - //Protected memory has been written to, returns true if that memory has been unprotected - virtual bool WriteToProtectedMemory (DWORD Address, int length) = 0; + //Protected memory has been written to, returns true if that memory has been unprotected + virtual bool WriteToProtectedMemory (uint32_t Address, int32_t length) = 0; }; -class CMipsMemory +__interface CMipsMemory { -public: - virtual BYTE * Rdram () = 0; - virtual DWORD RdramSize() = 0; - virtual BYTE * Dmem () = 0; - virtual BYTE * Imem () = 0; - virtual BYTE * PifRam () = 0; - - virtual bool LB_VAddr ( DWORD VAddr, BYTE & Value ) = 0; - virtual bool LH_VAddr ( DWORD VAddr, WORD & Value ) = 0; - virtual bool LW_VAddr ( DWORD VAddr, DWORD & Value ) = 0; - virtual bool LD_VAddr ( DWORD VAddr, QWORD & Value ) = 0; + virtual uint8_t * Rdram () = 0; + virtual uint32_t RdramSize() = 0; + virtual uint8_t * Dmem () = 0; + virtual uint8_t * Imem () = 0; + virtual uint8_t * PifRam () = 0; - virtual bool LB_PAddr ( DWORD PAddr, BYTE & Value ) = 0; - virtual bool LH_PAddr ( DWORD PAddr, WORD & Value ) = 0; - virtual bool LW_PAddr ( DWORD PAddr, DWORD & Value ) = 0; - virtual bool LD_PAddr ( DWORD PAddr, QWORD & Value ) = 0; + virtual bool LB_VAddr ( uint32_t VAddr, uint8_t & Value ) = 0; + virtual bool LH_VAddr ( uint32_t VAddr, uint16_t & Value ) = 0; + virtual bool LW_VAddr ( uint32_t VAddr, uint32_t & Value ) = 0; + virtual bool LD_VAddr ( uint32_t VAddr, uint64_t & Value ) = 0; - virtual bool SB_VAddr ( DWORD VAddr, BYTE Value ) = 0; - virtual bool SH_VAddr ( DWORD VAddr, WORD Value ) = 0; - virtual bool SW_VAddr ( DWORD VAddr, DWORD Value ) = 0; - virtual bool SD_VAddr ( DWORD VAddr, QWORD Value ) = 0; + virtual bool LB_PAddr ( uint32_t PAddr, uint8_t & Value ) = 0; + virtual bool LH_PAddr ( uint32_t PAddr, uint16_t & Value ) = 0; + virtual bool LW_PAddr ( uint32_t PAddr, uint32_t & Value ) = 0; + virtual bool LD_PAddr ( uint32_t PAddr, uint64_t & Value ) = 0; - virtual bool SB_PAddr ( DWORD PAddr, BYTE Value ) = 0; - virtual bool SH_PAddr ( DWORD PAddr, WORD Value ) = 0; - virtual bool SW_PAddr ( DWORD PAddr, DWORD Value ) = 0; - virtual bool SD_PAddr ( DWORD PAddr, QWORD Value ) = 0; + virtual bool SB_VAddr ( uint32_t VAddr, uint8_t Value ) = 0; + virtual bool SH_VAddr ( uint32_t VAddr, uint16_t Value ) = 0; + virtual bool SW_VAddr ( uint32_t VAddr, uint32_t Value ) = 0; + virtual bool SD_VAddr ( uint32_t VAddr, uint64_t Value ) = 0; - virtual bool ValidVaddr ( DWORD VAddr ) const = 0; + virtual bool SB_PAddr ( uint32_t PAddr, uint8_t Value ) = 0; + virtual bool SH_PAddr ( uint32_t PAddr, uint16_t Value ) = 0; + virtual bool SW_PAddr ( uint32_t PAddr, uint32_t Value ) = 0; + virtual bool SD_PAddr ( uint32_t PAddr, uint64_t Value ) = 0; - virtual int MemoryFilter ( DWORD dwExptCode, void * lpExceptionPointer ) = 0; - virtual void UpdateFieldSerration ( unsigned int interlaced ) = 0; + virtual bool ValidVaddr ( uint32_t VAddr ) const = 0; - //Protect the Memory from being written to - virtual void ProtectMemory ( DWORD StartVaddr, DWORD EndVaddr ) = 0; - virtual void UnProtectMemory ( DWORD StartVaddr, DWORD EndVaddr ) = 0; + virtual int32_t MemoryFilter ( uint32_t dwExptCode, void * lpExceptionPointer ) = 0; + virtual void UpdateFieldSerration ( uint32_t interlaced ) = 0; - //Compilation Functions - virtual void ResetMemoryStack () = 0; - - virtual void Compile_LB () = 0; - virtual void Compile_LBU () = 0; - virtual void Compile_LH () = 0; - virtual void Compile_LHU () = 0; - virtual void Compile_LW () = 0; - virtual void Compile_LL () = 0; - virtual void Compile_LWC1 () = 0; - virtual void Compile_LWU () = 0; - virtual void Compile_LWL () = 0; - virtual void Compile_LWR () = 0; - virtual void Compile_LD () = 0; - virtual void Compile_LDC1 () = 0; - virtual void Compile_LDL () = 0; - virtual void Compile_LDR () = 0; - virtual void Compile_SB () = 0; - virtual void Compile_SH () = 0; - virtual void Compile_SW () = 0; - virtual void Compile_SWL () = 0; - virtual void Compile_SWR () = 0; - virtual void Compile_SD () = 0; - virtual void Compile_SDL () = 0; - virtual void Compile_SDR () = 0; - virtual void Compile_SC () = 0; - virtual void Compile_SWC1 () = 0; - virtual void Compile_SDC1 () = 0; + //Protect the Memory from being written to + virtual void ProtectMemory ( uint32_t StartVaddr, uint32_t EndVaddr ) = 0; + virtual void UnProtectMemory ( uint32_t StartVaddr, uint32_t EndVaddr ) = 0; + + //Compilation Functions + virtual void ResetMemoryStack () = 0; + + virtual void Compile_LB () = 0; + virtual void Compile_LBU () = 0; + virtual void Compile_LH () = 0; + virtual void Compile_LHU () = 0; + virtual void Compile_LW () = 0; + virtual void Compile_LL () = 0; + virtual void Compile_LWC1 () = 0; + virtual void Compile_LWU () = 0; + virtual void Compile_LWL () = 0; + virtual void Compile_LWR () = 0; + virtual void Compile_LD () = 0; + virtual void Compile_LDC1 () = 0; + virtual void Compile_LDL () = 0; + virtual void Compile_LDR () = 0; + virtual void Compile_SB () = 0; + virtual void Compile_SH () = 0; + virtual void Compile_SW () = 0; + virtual void Compile_SWL () = 0; + virtual void Compile_SWR () = 0; + virtual void Compile_SD () = 0; + virtual void Compile_SDL () = 0; + virtual void Compile_SDR () = 0; + virtual void Compile_SC () = 0; + virtual void Compile_SWC1 () = 0; + virtual void Compile_SDC1 () = 0; }; diff --git a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp index d311d8f44..1d5b05df3 100644 --- a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp +++ b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp @@ -10,37 +10,37 @@ ****************************************************************************/ #include "stdafx.h" -DWORD RegModValue; +uint32_t RegModValue; -BYTE * CMipsMemoryVM::m_Reserve1 = NULL; -BYTE * CMipsMemoryVM::m_Reserve2 = NULL; +uint8_t * CMipsMemoryVM::m_Reserve1 = NULL; +uint8_t * CMipsMemoryVM::m_Reserve2 = NULL; -CMipsMemoryVM::CMipsMemoryVM( CMipsMemory_CallBack * CallBack, bool SavesReadOnly ) : +CMipsMemoryVM::CMipsMemoryVM(CMipsMemory_CallBack * CallBack, bool SavesReadOnly) : - CPifRam(SavesReadOnly), - CFlashram(SavesReadOnly), - CSram(SavesReadOnly), - CDMA(*this,*this), - m_CBClass(CallBack), - m_RomMapped(false), - m_Rom(NULL), - m_RomSize(0), - m_RomWrittenTo(false), - m_RomWroteValue(0), - m_HalfLine(0), - m_HalfLineCheck(false), - m_FieldSerration(0), - m_TempValue(0), - m_TLB_ReadMap(NULL), - m_TLB_WriteMap(NULL) -{ - g_Settings->RegisterChangeCB(Game_RDRamSize,this,(CSettings::SettingChangedFunc)RdramChanged); - m_RDRAM = NULL; - m_DMEM = NULL; - m_IMEM = NULL; + CPifRam(SavesReadOnly), + CFlashram(SavesReadOnly), + CSram(SavesReadOnly), + CDMA(*this, *this), + m_CBClass(CallBack), + m_RomMapped(false), + m_Rom(NULL), + m_RomSize(0), + m_RomWrittenTo(false), + m_RomWroteValue(0), + m_HalfLine(0), + m_HalfLineCheck(false), + m_FieldSerration(0), + m_TempValue(0), + m_TLB_ReadMap(NULL), + m_TLB_WriteMap(NULL) +{ + g_Settings->RegisterChangeCB(Game_RDRamSize, this, (CSettings::SettingChangedFunc)RdramChanged); + m_RDRAM = NULL; + m_DMEM = NULL; + m_IMEM = NULL; } -static uint32_t swap32by8(uint32_t word) +uint32_t swap32by8(uint32_t word) { const uint32_t swapped = #if defined(_MSC_VER) @@ -49,5572 +49,5569 @@ static uint32_t swap32by8(uint32_t word) __builtin_bswap32(word) #else (word & 0x000000FFul) << 24 - | (word & 0x0000FF00ul) << 8 - | (word & 0x00FF0000ul) >> 8 - | (word & 0xFF000000ul) >> 24 + | (word & 0x0000FF00ul) << 8 + | (word & 0x00FF0000ul) >> 8 + | (word & 0xFF000000ul) >> 24 #endif - ; + ; return (swapped & 0xFFFFFFFFul); } CMipsMemoryVM::~CMipsMemoryVM() { - g_Settings->UnregisterChangeCB(Game_RDRamSize,this,(CSettings::SettingChangedFunc)RdramChanged); - FreeMemory(); + g_Settings->UnregisterChangeCB(Game_RDRamSize, this, (CSettings::SettingChangedFunc)RdramChanged); + FreeMemory(); } -void CMipsMemoryVM::Reset( bool /*EraseMemory*/ ) +void CMipsMemoryVM::Reset(bool /*EraseMemory*/) { - if (m_TLB_ReadMap) - { - size_t address; + if (m_TLB_ReadMap) + { + size_t address; - memset(m_TLB_ReadMap , 0, 0xFFFFF * sizeof(size_t)); - memset(m_TLB_WriteMap, 0, 0xFFFFF * sizeof(size_t)); - for (address = 0x80000000; address < 0xC0000000; address += 0x1000) - { - m_TLB_ReadMap[address >> 12] = ((size_t)m_RDRAM + (address & 0x1FFFFFFF)) - address; - m_TLB_WriteMap[address >> 12] = ((size_t)m_RDRAM + (address & 0x1FFFFFFF)) - address; - } - - if (g_Settings->LoadDword(Rdb_TLB_VAddrStart) != 0) - { - size_t Start = g_Settings->LoadDword(Rdb_TLB_VAddrStart); //0x7F000000; - size_t Len = g_Settings->LoadDword(Rdb_TLB_VAddrLen); //0x01000000; - size_t PAddr = g_Settings->LoadDword(Rdb_TLB_PAddrStart); //0x10034b30; - size_t End = Start + Len; - for (address = Start; address < End; address += 0x1000) - { - m_TLB_ReadMap[address >> 12] = ((size_t)m_RDRAM + (address - Start + PAddr)) - address; - m_TLB_WriteMap[address >> 12] = ((size_t)m_RDRAM + (address - Start + PAddr)) - address; - } - } - } + memset(m_TLB_ReadMap, 0, 0xFFFFF * sizeof(size_t)); + memset(m_TLB_WriteMap, 0, 0xFFFFF * sizeof(size_t)); + for (address = 0x80000000; address < 0xC0000000; address += 0x1000) + { + m_TLB_ReadMap[address >> 12] = ((size_t)m_RDRAM + (address & 0x1FFFFFFF)) - address; + m_TLB_WriteMap[address >> 12] = ((size_t)m_RDRAM + (address & 0x1FFFFFFF)) - address; + } + + if (g_Settings->LoadDword(Rdb_TLB_VAddrStart) != 0) + { + size_t Start = g_Settings->LoadDword(Rdb_TLB_VAddrStart); //0x7F000000; + size_t Len = g_Settings->LoadDword(Rdb_TLB_VAddrLen); //0x01000000; + size_t PAddr = g_Settings->LoadDword(Rdb_TLB_PAddrStart); //0x10034b30; + size_t End = Start + Len; + for (address = Start; address < End; address += 0x1000) + { + m_TLB_ReadMap[address >> 12] = ((size_t)m_RDRAM + (address - Start + PAddr)) - address; + m_TLB_WriteMap[address >> 12] = ((size_t)m_RDRAM + (address - Start + PAddr)) - address; + } + } + } } void CMipsMemoryVM::ReserveMemory() { - m_Reserve1 = (unsigned char *) VirtualAlloc( NULL, 0x20000000, MEM_RESERVE | MEM_TOP_DOWN, PAGE_READWRITE ); - if (g_Settings->LoadBool(Debugger_Enabled)) - { - m_Reserve2 = (unsigned char *) VirtualAlloc( NULL, 0x20000000, MEM_RESERVE | MEM_TOP_DOWN, PAGE_READWRITE ); - } + m_Reserve1 = (uint8_t *)VirtualAlloc(NULL, 0x20000000, MEM_RESERVE | MEM_TOP_DOWN, PAGE_READWRITE); + if (g_Settings->LoadBool(Debugger_Enabled)) + { + m_Reserve2 = (uint8_t *)VirtualAlloc(NULL, 0x20000000, MEM_RESERVE | MEM_TOP_DOWN, PAGE_READWRITE); + } } void CMipsMemoryVM::FreeReservedMemory() { - if (m_Reserve1) - { - VirtualFree( m_Reserve1, 0 , MEM_RELEASE); - m_Reserve1 = NULL; - } - if (m_Reserve2) - { - VirtualFree( m_Reserve2, 0 , MEM_RELEASE); - m_Reserve2 = NULL; - } + if (m_Reserve1) + { + VirtualFree(m_Reserve1, 0, MEM_RELEASE); + m_Reserve1 = NULL; + } + if (m_Reserve2) + { + VirtualFree(m_Reserve2, 0, MEM_RELEASE); + m_Reserve2 = NULL; + } } bool CMipsMemoryVM::Initialize() { - if (m_RDRAM != NULL) - { - return true; - } + if (m_RDRAM != NULL) + { + return true; + } - if (m_Reserve1) - { - m_RDRAM = m_Reserve1; m_Reserve1 = NULL; - } - if (m_RDRAM == NULL && m_Reserve2) - { - m_RDRAM = m_Reserve2; m_Reserve2 = NULL; - } - if (m_RDRAM == NULL) - { - m_RDRAM = (unsigned char *) VirtualAlloc( NULL, 0x20000000, MEM_RESERVE | MEM_TOP_DOWN, PAGE_READWRITE ); - } - if ( m_RDRAM == NULL ) - { - WriteTraceF(TraceError,__FUNCTION__ ": Failed to Reserve RDRAM (Size: 0x%X)",0x20000000); - FreeMemory(); - return false; - } - - m_AllocatedRdramSize = g_Settings->LoadDword(Game_RDRamSize); - if (VirtualAlloc(m_RDRAM, m_AllocatedRdramSize, MEM_COMMIT, PAGE_READWRITE)==NULL) - { - WriteTraceF(TraceError,__FUNCTION__ ": Failed to Allocate RDRAM (Size: 0x%X)",m_AllocatedRdramSize); - FreeMemory(); - return false; - } + if (m_Reserve1) + { + m_RDRAM = m_Reserve1; m_Reserve1 = NULL; + } + if (m_RDRAM == NULL && m_Reserve2) + { + m_RDRAM = m_Reserve2; m_Reserve2 = NULL; + } + if (m_RDRAM == NULL) + { + m_RDRAM = (uint8_t *)VirtualAlloc(NULL, 0x20000000, MEM_RESERVE | MEM_TOP_DOWN, PAGE_READWRITE); + } + if (m_RDRAM == NULL) + { + WriteTraceF(TraceError, __FUNCTION__ ": Failed to Reserve RDRAM (Size: 0x%X)", 0x20000000); + FreeMemory(); + return false; + } - if (VirtualAlloc(m_RDRAM + 0x04000000, 0x2000, MEM_COMMIT, PAGE_READWRITE)==NULL) - { - WriteTraceF(TraceError,__FUNCTION__ ": Failed to Allocate DMEM/IMEM (Size: 0x%X)",0x2000); - FreeMemory(); - return false; - } + m_AllocatedRdramSize = g_Settings->LoadDword(Game_RDRamSize); + if (VirtualAlloc(m_RDRAM, m_AllocatedRdramSize, MEM_COMMIT, PAGE_READWRITE) == NULL) + { + WriteTraceF(TraceError, __FUNCTION__ ": Failed to Allocate RDRAM (Size: 0x%X)", m_AllocatedRdramSize); + FreeMemory(); + return false; + } - m_DMEM = (unsigned char *)(m_RDRAM+0x04000000); - m_IMEM = (unsigned char *)(m_RDRAM+0x04001000); + if (VirtualAlloc(m_RDRAM + 0x04000000, 0x2000, MEM_COMMIT, PAGE_READWRITE) == NULL) + { + WriteTraceF(TraceError, __FUNCTION__ ": Failed to Allocate DMEM/IMEM (Size: 0x%X)", 0x2000); + FreeMemory(); + return false; + } - if (g_Settings->LoadBool(Game_LoadRomToMemory)) - { - m_RomMapped = true; - m_Rom = m_RDRAM + 0x10000000; - m_RomSize = g_Rom->GetRomSize(); - if (VirtualAlloc(m_Rom, g_Rom->GetRomSize(), MEM_COMMIT, PAGE_READWRITE)==NULL) - { - WriteTraceF(TraceError,__FUNCTION__ ": Failed to Allocate Rom (Size: 0x%X)",g_Rom->GetRomSize()); - FreeMemory(); - return false; - } - memcpy(m_Rom,g_Rom->GetRomAddress(),g_Rom->GetRomSize()); - - DWORD OldProtect; - VirtualProtect(m_Rom,g_Rom->GetRomSize(),PAGE_READONLY, &OldProtect); - } - else - { - m_RomMapped = false; - m_Rom = g_Rom->GetRomAddress(); - m_RomSize = g_Rom->GetRomSize(); - } - CPifRam::Reset(); + m_DMEM = (uint8_t *)(m_RDRAM + 0x04000000); + m_IMEM = (uint8_t *)(m_RDRAM + 0x04001000); - m_TLB_ReadMap = (size_t *)VirtualAlloc( - NULL, - 0xFFFFF * sizeof(size_t), - MEM_RESERVE | MEM_COMMIT, - PAGE_READWRITE - ); - if (m_TLB_ReadMap == NULL) - { - WriteTraceF(TraceError,__FUNCTION__": Failed to Allocate m_TLB_ReadMap (Size: 0x%X)",0xFFFFF * sizeof(size_t)); - FreeMemory(); - return false; - } + if (g_Settings->LoadBool(Game_LoadRomToMemory)) + { + m_RomMapped = true; + m_Rom = m_RDRAM + 0x10000000; + m_RomSize = g_Rom->GetRomSize(); + if (VirtualAlloc(m_Rom, g_Rom->GetRomSize(), MEM_COMMIT, PAGE_READWRITE) == NULL) + { + WriteTraceF(TraceError, __FUNCTION__ ": Failed to Allocate Rom (Size: 0x%X)", g_Rom->GetRomSize()); + FreeMemory(); + return false; + } + memcpy(m_Rom, g_Rom->GetRomAddress(), g_Rom->GetRomSize()); - m_TLB_WriteMap = (size_t *)VirtualAlloc( - NULL, - 0xFFFFF * sizeof(size_t), - MEM_RESERVE | MEM_COMMIT, - PAGE_READWRITE - ); - if (m_TLB_WriteMap == NULL) - { - WriteTraceF(TraceError,__FUNCTION__": Failed to Allocate m_TLB_WriteMap (Size: 0x%X)",0xFFFFF * sizeof(size_t)); - FreeMemory(); - return false; - } - Reset(false); - return true; + DWORD OldProtect; + VirtualProtect(m_Rom, g_Rom->GetRomSize(), PAGE_READONLY, &OldProtect); + } + else + { + m_RomMapped = false; + m_Rom = g_Rom->GetRomAddress(); + m_RomSize = g_Rom->GetRomSize(); + } + CPifRam::Reset(); + + m_TLB_ReadMap = (size_t *)VirtualAlloc( + NULL, + 0xFFFFF * sizeof(size_t), + MEM_RESERVE | MEM_COMMIT, + PAGE_READWRITE + ); + if (m_TLB_ReadMap == NULL) + { + WriteTraceF(TraceError, __FUNCTION__": Failed to Allocate m_TLB_ReadMap (Size: 0x%X)", 0xFFFFF * sizeof(size_t)); + FreeMemory(); + return false; + } + + m_TLB_WriteMap = (size_t *)VirtualAlloc( + NULL, + 0xFFFFF * sizeof(size_t), + MEM_RESERVE | MEM_COMMIT, + PAGE_READWRITE + ); + if (m_TLB_WriteMap == NULL) + { + WriteTraceF(TraceError, __FUNCTION__": Failed to Allocate m_TLB_WriteMap (Size: 0x%X)", 0xFFFFF * sizeof(size_t)); + FreeMemory(); + return false; + } + Reset(false); + return true; } void CMipsMemoryVM::FreeMemory() { - if (m_RDRAM) - { - if (VirtualFree( m_RDRAM, 0x20000000,MEM_DECOMMIT) != 0) - { - if (m_Reserve1 == NULL) - { - m_Reserve1 = m_RDRAM; - } - else if (m_Reserve2 == NULL) - { - m_Reserve2 = m_RDRAM; - } - else - { - VirtualFree( m_RDRAM, 0 , MEM_RELEASE); - } - } else { - VirtualFree( m_RDRAM, 0 , MEM_RELEASE); - } - m_RDRAM = NULL; - m_IMEM = NULL; - m_DMEM = NULL; - } - if (m_TLB_ReadMap) - { - VirtualFree( m_TLB_ReadMap, 0 , MEM_RELEASE); - m_TLB_ReadMap = NULL; - } - if (m_TLB_WriteMap) - { - VirtualFree( m_TLB_WriteMap, 0 , MEM_RELEASE); - m_TLB_WriteMap = NULL; - } - CPifRam::Reset(); + if (m_RDRAM) + { + if (VirtualFree(m_RDRAM, 0x20000000, MEM_DECOMMIT) != 0) + { + if (m_Reserve1 == NULL) + { + m_Reserve1 = m_RDRAM; + } + else if (m_Reserve2 == NULL) + { + m_Reserve2 = m_RDRAM; + } + else + { + VirtualFree(m_RDRAM, 0, MEM_RELEASE); + } + } + else + { + VirtualFree(m_RDRAM, 0, MEM_RELEASE); + } + m_RDRAM = NULL; + m_IMEM = NULL; + m_DMEM = NULL; + } + if (m_TLB_ReadMap) + { + VirtualFree(m_TLB_ReadMap, 0, MEM_RELEASE); + m_TLB_ReadMap = NULL; + } + if (m_TLB_WriteMap) + { + VirtualFree(m_TLB_WriteMap, 0, MEM_RELEASE); + m_TLB_WriteMap = NULL; + } + CPifRam::Reset(); } -BYTE * CMipsMemoryVM::Rdram() +uint8_t * CMipsMemoryVM::Rdram() { - return m_RDRAM; + return m_RDRAM; } -DWORD CMipsMemoryVM::RdramSize() +uint32_t CMipsMemoryVM::RdramSize() { - return m_AllocatedRdramSize; + return m_AllocatedRdramSize; } -BYTE * CMipsMemoryVM::Dmem() +uint8_t * CMipsMemoryVM::Dmem() { - return m_DMEM; + return m_DMEM; } -BYTE * CMipsMemoryVM::Imem() +uint8_t * CMipsMemoryVM::Imem() { - return m_IMEM; + return m_IMEM; } -BYTE * CMipsMemoryVM::PifRam() +uint8_t * CMipsMemoryVM::PifRam() { - return m_PifRam; + return m_PifRam; } -bool CMipsMemoryVM::LB_VAddr(DWORD VAddr, BYTE& Value) +bool CMipsMemoryVM::LB_VAddr(uint32_t VAddr, uint8_t& Value) { - if (m_TLB_ReadMap[VAddr >> 12] == 0) - { - return false; - } + if (m_TLB_ReadMap[VAddr >> 12] == 0) + { + return false; + } - Value = *(uint8_t *)(m_TLB_ReadMap[VAddr >> 12] + (VAddr ^ 3)); - return true; + Value = *(uint8_t*)(m_TLB_ReadMap[VAddr >> 12] + (VAddr ^ 3)); + return true; } -bool CMipsMemoryVM::LH_VAddr(DWORD VAddr, WORD& Value) +bool CMipsMemoryVM::LH_VAddr(uint32_t VAddr, uint16_t& Value) { - if (m_TLB_ReadMap[VAddr >> 12] == 0) - { - return false; - } + if (m_TLB_ReadMap[VAddr >> 12] == 0) + { + return false; + } - Value = *(uint16_t *)(m_TLB_ReadMap[VAddr >> 12] + (VAddr ^ 2)); - return true; + Value = *(uint16_t*)(m_TLB_ReadMap[VAddr >> 12] + (VAddr ^ 2)); + return true; } -bool CMipsMemoryVM::LW_VAddr(DWORD VAddr, DWORD& Value) +bool CMipsMemoryVM::LW_VAddr(uint32_t VAddr, uint32_t& Value) { - if (VAddr >= 0xA3F00000 && VAddr < 0xC0000000) - { - if (VAddr < 0xA4000000 || VAddr >= 0xA4002000) - { - VAddr &= 0x1FFFFFFF; - LW_NonMemory(VAddr,&Value); - return true; - } - } + if (VAddr >= 0xA3F00000 && VAddr < 0xC0000000) + { + if (VAddr < 0xA4000000 || VAddr >= 0xA4002000) + { + VAddr &= 0x1FFFFFFF; + LW_NonMemory(VAddr, &Value); + return true; + } + } - BYTE* BaseAddress = (BYTE*)m_TLB_ReadMap[VAddr >> 12]; - if (BaseAddress == NULL) - { - return false; - } + uint8_t* BaseAddress = (uint8_t*)m_TLB_ReadMap[VAddr >> 12]; + if (BaseAddress == NULL) + { + return false; + } - Value = *(DWORD*)(BaseAddress + VAddr); + Value = *(uint32_t*)(BaseAddress + VAddr); -// if (LookUpMode == FuncFind_ChangeMemory) -// { -// g_Notify->BreakPoint(__FILEW__,__LINE__); -// if ( (Command.Hex >> 16) == 0x7C7C) -// { -// Command.Hex = OrigMem[(Command.Hex & 0xFFFF)].OriginalValue; -// } -// } - return true; + // if (LookUpMode == FuncFind_ChangeMemory) + // { + // g_Notify->BreakPoint(__FILEW__,__LINE__); + // if ( (Command.Hex >> 16) == 0x7C7C) + // { + // Command.Hex = OrigMem[(Command.Hex & 0xFFFF)].OriginalValue; + // } + // } + return true; } -bool CMipsMemoryVM::LD_VAddr(DWORD VAddr, QWORD& Value) +bool CMipsMemoryVM::LD_VAddr(uint32_t VAddr, uint64_t& Value) { - if (m_TLB_ReadMap[VAddr >> 12] == 0) - { - return false; - } + if (m_TLB_ReadMap[VAddr >> 12] == 0) + { + return false; + } - *((DWORD*)(&Value) + 1) = *(DWORD*)(m_TLB_ReadMap[VAddr >> 12] + VAddr); - *((DWORD*)(&Value) + 0) = *(DWORD*)(m_TLB_ReadMap[VAddr >> 12] + VAddr + 4); - return true; + *((uint32_t*)(&Value) + 1) = *(uint32_t*)(m_TLB_ReadMap[VAddr >> 12] + VAddr); + *((uint32_t*)(&Value) + 0) = *(uint32_t*)(m_TLB_ReadMap[VAddr >> 12] + VAddr + 4); + return true; } -bool CMipsMemoryVM::LB_PAddr(DWORD PAddr, BYTE& Value) +bool CMipsMemoryVM::LB_PAddr(uint32_t PAddr, uint8_t& Value) { - if (PAddr < RdramSize()) - { - Value = *(uint8_t *)(m_RDRAM + (PAddr ^ 3)); - return true; - } + if (PAddr < RdramSize()) + { + Value = *(uint8_t*)(m_RDRAM + (PAddr ^ 3)); + return true; + } - if (PAddr > 0x18000000) - { - return false; - } + if (PAddr > 0x18000000) + { + return false; + } - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; + g_Notify->BreakPoint(__FILEW__, __LINE__); + return false; } -bool CMipsMemoryVM::LH_PAddr(DWORD PAddr, WORD& Value) +bool CMipsMemoryVM::LH_PAddr(uint32_t PAddr, uint16_t& Value) { - if (PAddr < RdramSize()) - { - Value = *(uint16_t *)(m_RDRAM + (PAddr ^ 2)); - return true; - } + if (PAddr < RdramSize()) + { + Value = *(uint16_t*)(m_RDRAM + (PAddr ^ 2)); + return true; + } - if (PAddr > 0x18000000) - { - return false; - } + if (PAddr > 0x18000000) + { + return false; + } - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; + g_Notify->BreakPoint(__FILEW__, __LINE__); + return false; } -bool CMipsMemoryVM::LW_PAddr(DWORD PAddr, DWORD& Value) +bool CMipsMemoryVM::LW_PAddr(uint32_t PAddr, uint32_t& Value) { - if (PAddr < RdramSize()) - { - Value = *(DWORD*)(m_RDRAM + PAddr); - return true; - } + if (PAddr < RdramSize()) + { + Value = *(uint32_t*)(m_RDRAM + PAddr); + return true; + } - if (PAddr > 0x18000000) - { - return false; - } + if (PAddr > 0x18000000) + { + return false; + } - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; + g_Notify->BreakPoint(__FILEW__, __LINE__); + return false; } -bool CMipsMemoryVM::LD_PAddr(DWORD PAddr, QWORD& Value) +bool CMipsMemoryVM::LD_PAddr(uint32_t PAddr, uint64_t& Value) { - if (PAddr < RdramSize()) - { - *((DWORD*)(&Value) + 1) = *(DWORD*)(m_RDRAM + PAddr); - *((DWORD*)(&Value) + 0) = *(DWORD*)(m_RDRAM + PAddr + 4); - return true; - } + if (PAddr < RdramSize()) + { + *((uint32_t*)(&Value) + 1) = *(uint32_t*)(m_RDRAM + PAddr); + *((uint32_t*)(&Value) + 0) = *(uint32_t*)(m_RDRAM + PAddr + 4); + return true; + } - if (PAddr > 0x18000000) - { - return false; - } + if (PAddr > 0x18000000) + { + return false; + } - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; + g_Notify->BreakPoint(__FILEW__, __LINE__); + return false; } -bool CMipsMemoryVM::SB_VAddr(DWORD VAddr, BYTE Value) +bool CMipsMemoryVM::SB_VAddr(uint32_t VAddr, uint8_t Value) { - if (m_TLB_WriteMap[VAddr >> 12] == 0) - { - return false; - } + if (m_TLB_WriteMap[VAddr >> 12] == 0) + { + return false; + } - *(uint8_t *)(m_TLB_WriteMap[VAddr >> 12] + (VAddr ^ 3)) = Value; - return true; + *(uint8_t*)(m_TLB_WriteMap[VAddr >> 12] + (VAddr ^ 3)) = Value; + return true; } -bool CMipsMemoryVM::SH_VAddr(DWORD VAddr, WORD Value) +bool CMipsMemoryVM::SH_VAddr(uint32_t VAddr, uint16_t Value) { - if (m_TLB_WriteMap[VAddr >> 12] == 0) - { - return false; - } + if (m_TLB_WriteMap[VAddr >> 12] == 0) + { + return false; + } - *(uint16_t *)(m_TLB_WriteMap[VAddr >> 12] + (VAddr ^ 2)) = Value; - return true; + *(uint16_t*)(m_TLB_WriteMap[VAddr >> 12] + (VAddr ^ 2)) = Value; + return true; } -bool CMipsMemoryVM::SW_VAddr(DWORD VAddr, DWORD Value) +bool CMipsMemoryVM::SW_VAddr(uint32_t VAddr, uint32_t Value) { - if (VAddr >= 0xA3F00000 && VAddr < 0xC0000000) - { - if (VAddr < 0xA4000000 || VAddr >= 0xA4002000) - { - VAddr &= 0x1FFFFFFF; - SW_NonMemory(VAddr,Value); - return true; - } - } + if (VAddr >= 0xA3F00000 && VAddr < 0xC0000000) + { + if (VAddr < 0xA4000000 || VAddr >= 0xA4002000) + { + VAddr &= 0x1FFFFFFF; + SW_NonMemory(VAddr, Value); + return true; + } + } - if (m_TLB_WriteMap[VAddr >> 12] == 0) - { - return false; - } + if (m_TLB_WriteMap[VAddr >> 12] == 0) + { + return false; + } - *(DWORD*)(m_TLB_WriteMap[VAddr >> 12] + VAddr) = Value; - return true; + *(uint32_t*)(m_TLB_WriteMap[VAddr >> 12] + VAddr) = Value; + return true; } - -bool CMipsMemoryVM::SD_VAddr(DWORD VAddr, QWORD Value) +bool CMipsMemoryVM::SD_VAddr(uint32_t VAddr, uint64_t Value) { - if (m_TLB_WriteMap[VAddr >> 12] == 0) - { - return false; - } + if (m_TLB_WriteMap[VAddr >> 12] == 0) + { + return false; + } - *(DWORD*)(m_TLB_WriteMap[VAddr >> 12] + VAddr + 0) = *((DWORD*)(&Value) + 1); - *(DWORD*)(m_TLB_WriteMap[VAddr >> 12] + VAddr + 4) = *((DWORD*)(&Value)); - return true; + *(uint32_t*)(m_TLB_WriteMap[VAddr >> 12] + VAddr + 0) = *((uint32_t*)(&Value) + 1); + *(uint32_t*)(m_TLB_WriteMap[VAddr >> 12] + VAddr + 4) = *((uint32_t*)(&Value)); + return true; } -bool CMipsMemoryVM::SB_PAddr(DWORD PAddr, BYTE Value) +bool CMipsMemoryVM::SB_PAddr(uint32_t PAddr, uint8_t Value) { - if (PAddr < RdramSize()) - { - *(uint8_t *)(m_RDRAM + (PAddr ^ 3)) = Value; - return true; - } + if (PAddr < RdramSize()) + { + *(uint8_t*)(m_RDRAM + (PAddr ^ 3)) = Value; + return true; + } - if (PAddr > 0x18000000) - { - return false; - } + if (PAddr > 0x18000000) + { + return false; + } - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; + g_Notify->BreakPoint(__FILEW__, __LINE__); + return false; } -bool CMipsMemoryVM::SH_PAddr(DWORD PAddr, WORD Value) +bool CMipsMemoryVM::SH_PAddr(uint32_t PAddr, uint16_t Value) { - if (PAddr < RdramSize()) - { - *(uint16_t *)(m_RDRAM + (PAddr ^ 2)) = Value; - return true; - } + if (PAddr < RdramSize()) + { + *(uint16_t*)(m_RDRAM + (PAddr ^ 2)) = Value; + return true; + } - if (PAddr > 0x18000000) - { - return false; - } + if (PAddr > 0x18000000) + { + return false; + } - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; + g_Notify->BreakPoint(__FILEW__, __LINE__); + return false; } -bool CMipsMemoryVM::SW_PAddr(DWORD PAddr, DWORD Value) +bool CMipsMemoryVM::SW_PAddr(uint32_t PAddr, uint32_t Value) { - if (PAddr < RdramSize()) - { - *(DWORD*)(m_RDRAM + PAddr) = Value; - return true; - } + if (PAddr < RdramSize()) + { + *(uint32_t*)(m_RDRAM + PAddr) = Value; + return true; + } - if (PAddr > 0x18000000) - { - return false; - } + if (PAddr > 0x18000000) + { + return false; + } - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; + g_Notify->BreakPoint(__FILEW__, __LINE__); + return false; } - -bool CMipsMemoryVM::SD_PAddr(DWORD PAddr, QWORD Value) +bool CMipsMemoryVM::SD_PAddr(uint32_t PAddr, uint64_t Value) { - if (PAddr < RdramSize()) - { - *(DWORD*)(m_RDRAM + PAddr + 0) = *((DWORD*)(&Value) + 1); - *(DWORD*)(m_RDRAM + PAddr + 4) = *((DWORD*)(&Value)); - return true; - } + if (PAddr < RdramSize()) + { + *(uint32_t*)(m_RDRAM + PAddr + 0) = *((uint32_t*)(&Value) + 1); + *(uint32_t*)(m_RDRAM + PAddr + 4) = *((uint32_t*)(&Value)); + return true; + } - if (PAddr > 0x18000000) - { - return false; - } + if (PAddr > 0x18000000) + { + return false; + } - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; + g_Notify->BreakPoint(__FILEW__, __LINE__); + return false; } -bool CMipsMemoryVM::ValidVaddr ( DWORD VAddr ) const +bool CMipsMemoryVM::ValidVaddr(uint32_t VAddr) const { - return m_TLB_ReadMap[VAddr >> 12] != 0; + return m_TLB_ReadMap[VAddr >> 12] != 0; } -bool CMipsMemoryVM::VAddrToRealAddr ( DWORD VAddr, void * &RealAddress ) const +bool CMipsMemoryVM::VAddrToRealAddr(uint32_t VAddr, void * &RealAddress) const { - if (m_TLB_ReadMap[VAddr >> 12] == 0) - { - return false; - } - RealAddress = (BYTE *)(m_TLB_ReadMap[VAddr >> 12] + VAddr); - return true; + if (m_TLB_ReadMap[VAddr >> 12] == 0) + { + return false; + } + RealAddress = (uint8_t *)(m_TLB_ReadMap[VAddr >> 12] + VAddr); + return true; } -bool CMipsMemoryVM::TranslateVaddr ( DWORD VAddr, DWORD &PAddr) const +bool CMipsMemoryVM::TranslateVaddr(uint32_t VAddr, uint32_t &PAddr) const { - //Change the Virtual address to a Physical Address - if (m_TLB_ReadMap[VAddr >> 12] == 0) - { - return false; - } - PAddr = (DWORD)((BYTE *)(m_TLB_ReadMap[VAddr >> 12] + VAddr) - m_RDRAM); - return true; + //Change the Virtual address to a Physical Address + if (m_TLB_ReadMap[VAddr >> 12] == 0) + { + return false; + } + PAddr = (uint32_t)((uint8_t *)(m_TLB_ReadMap[VAddr >> 12] + VAddr) - m_RDRAM); + return true; } -void CMipsMemoryVM::Compile_LB(x86Reg Reg, DWORD VAddr, bool SignExtend) +void CMipsMemoryVM::Compile_LB(x86Reg Reg, uint32_t VAddr, bool SignExtend) { - DWORD PAddr; - char VarName[100]; + uint32_t PAddr; + char VarName[100]; - if (VAddr < 0x80000000 || VAddr >= 0xC0000000) - { - if (!g_System->bUseTlb()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - return; - } + if (VAddr < 0x80000000 || VAddr >= 0xC0000000) + { + if (!g_System->bUseTlb()) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + return; + } - x86Reg TlbMappReg = Map_TempReg(x86_Any, -1, false); - MoveConstToX86reg(VAddr >> 12,TlbMappReg); - x86Reg AddrReg = Map_TempReg(x86_Any, -1, false); - MoveConstToX86reg(VAddr,AddrReg); - MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TlbMappReg,TlbMappReg,4); - CompileReadTLBMiss(AddrReg,TlbMappReg); - if (SignExtend) - { - MoveSxByteX86regPointerToX86reg(AddrReg, TlbMappReg,Reg); - } - else - { - MoveZxByteX86regPointerToX86reg(AddrReg, TlbMappReg,Reg); - } - return; - } + x86Reg TlbMappReg = Map_TempReg(x86_Any, -1, false); + MoveConstToX86reg(VAddr >> 12, TlbMappReg); + x86Reg AddrReg = Map_TempReg(x86_Any, -1, false); + MoveConstToX86reg(VAddr, AddrReg); + MoveVariableDispToX86Reg(m_TLB_ReadMap, "m_TLB_ReadMap", TlbMappReg, TlbMappReg, 4); + CompileReadTLBMiss(AddrReg, TlbMappReg); + if (SignExtend) + { + MoveSxByteX86regPointerToX86reg(AddrReg, TlbMappReg, Reg); + } + else + { + MoveZxByteX86regPointerToX86reg(AddrReg, TlbMappReg, Reg); + } + return; + } - if (!TranslateVaddr(VAddr,PAddr)) - { - MoveConstToX86reg(0,Reg); - CPU_Message("Compile_LB\nFailed to translate address %08X",VAddr); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address %08X",VAddr).ToUTF16().c_str()); - } - return; - } + if (!TranslateVaddr(VAddr, PAddr)) + { + MoveConstToX86reg(0, Reg); + CPU_Message("Compile_LB\nFailed to translate address %08X", VAddr); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address %08X", VAddr).ToUTF16().c_str()); + } + return; + } - switch (PAddr & 0xFFF00000) - { - case 0x00000000: - case 0x00100000: - case 0x00200000: - case 0x00300000: - case 0x00400000: - case 0x00500000: - case 0x00600000: - case 0x00700000: - case 0x10000000: - sprintf(VarName,"m_RDRAM + %X",PAddr); - if (SignExtend) - { - MoveSxVariableToX86regByte(PAddr + m_RDRAM,VarName,Reg); - } - else - { - MoveZxVariableToX86regByte(PAddr + m_RDRAM,VarName,Reg); - } - break; - default: - MoveConstToX86reg(0,Reg); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to compile address: %08X",VAddr).ToUTF16().c_str()); - } - } + switch (PAddr & 0xFFF00000) + { + case 0x00000000: + case 0x00100000: + case 0x00200000: + case 0x00300000: + case 0x00400000: + case 0x00500000: + case 0x00600000: + case 0x00700000: + case 0x10000000: + sprintf(VarName, "m_RDRAM + %X", PAddr); + if (SignExtend) + { + MoveSxVariableToX86regByte(PAddr + m_RDRAM, VarName, Reg); + } + else + { + MoveZxVariableToX86regByte(PAddr + m_RDRAM, VarName, Reg); + } + break; + default: + MoveConstToX86reg(0, Reg); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to compile address: %08X", VAddr).ToUTF16().c_str()); + } + } } -void CMipsMemoryVM::Compile_LH(x86Reg Reg, DWORD VAddr, bool SignExtend) +void CMipsMemoryVM::Compile_LH(x86Reg Reg, uint32_t VAddr, bool SignExtend) { - char VarName[100]; - DWORD PAddr; + char VarName[100]; + uint32_t PAddr; - if (VAddr < 0x80000000 || VAddr >= 0xC0000000) - { - if (!g_System->bUseTlb()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - return; - } + if (VAddr < 0x80000000 || VAddr >= 0xC0000000) + { + if (!g_System->bUseTlb()) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + return; + } - x86Reg TlbMappReg = Map_TempReg(x86_Any, -1, false); - MoveConstToX86reg(VAddr >> 12,TlbMappReg); - x86Reg AddrReg = Map_TempReg(x86_Any, -1, false); - MoveConstToX86reg(VAddr,AddrReg); - MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TlbMappReg,TlbMappReg,4); - CompileReadTLBMiss(AddrReg,TlbMappReg); - if (SignExtend) - { - MoveSxHalfX86regPointerToX86reg(AddrReg, TlbMappReg,Reg); - } - else - { - MoveZxHalfX86regPointerToX86reg(AddrReg, TlbMappReg,Reg); - } - return; - } + x86Reg TlbMappReg = Map_TempReg(x86_Any, -1, false); + MoveConstToX86reg(VAddr >> 12, TlbMappReg); + x86Reg AddrReg = Map_TempReg(x86_Any, -1, false); + MoveConstToX86reg(VAddr, AddrReg); + MoveVariableDispToX86Reg(m_TLB_ReadMap, "m_TLB_ReadMap", TlbMappReg, TlbMappReg, 4); + CompileReadTLBMiss(AddrReg, TlbMappReg); + if (SignExtend) + { + MoveSxHalfX86regPointerToX86reg(AddrReg, TlbMappReg, Reg); + } + else + { + MoveZxHalfX86regPointerToX86reg(AddrReg, TlbMappReg, Reg); + } + return; + } - if (!TranslateVaddr(VAddr, PAddr)) - { - MoveConstToX86reg(0,Reg); - CPU_Message("Compile_LH\nFailed to translate address %08X",VAddr); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address %08X",VAddr).ToUTF16().c_str()); - } - return; - } + if (!TranslateVaddr(VAddr, PAddr)) + { + MoveConstToX86reg(0, Reg); + CPU_Message("Compile_LH\nFailed to translate address %08X", VAddr); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address %08X", VAddr).ToUTF16().c_str()); + } + return; + } - switch (PAddr & 0xFFF00000) - { - case 0x00000000: - case 0x00100000: - case 0x00200000: - case 0x00300000: - case 0x00400000: - case 0x00500000: - case 0x00600000: - case 0x00700000: - case 0x10000000: - sprintf(VarName,"m_RDRAM + %X",PAddr); - if (SignExtend) - { - MoveSxVariableToX86regHalf(PAddr + m_RDRAM,VarName,Reg); - } - else - { - MoveZxVariableToX86regHalf(PAddr + m_RDRAM,VarName,Reg); - } - break; - default: - MoveConstToX86reg(0,Reg); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to compile address: %08X", VAddr).ToUTF16().c_str()); - } - } + switch (PAddr & 0xFFF00000) + { + case 0x00000000: + case 0x00100000: + case 0x00200000: + case 0x00300000: + case 0x00400000: + case 0x00500000: + case 0x00600000: + case 0x00700000: + case 0x10000000: + sprintf(VarName, "m_RDRAM + %X", PAddr); + if (SignExtend) + { + MoveSxVariableToX86regHalf(PAddr + m_RDRAM, VarName, Reg); + } + else + { + MoveZxVariableToX86regHalf(PAddr + m_RDRAM, VarName, Reg); + } + break; + default: + MoveConstToX86reg(0, Reg); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to compile address: %08X", VAddr).ToUTF16().c_str()); + } + } } -void CMipsMemoryVM::Compile_LW (x86Reg Reg, DWORD VAddr ) +void CMipsMemoryVM::Compile_LW(x86Reg Reg, uint32_t VAddr) { - char VarName[100]; - DWORD PAddr; + char VarName[100]; + uint32_t PAddr; - m_RegWorkingSet.SetX86Protected(Reg,true); - if (VAddr < 0x80000000 || VAddr >= 0xC0000000) - { - if (!g_System->bUseTlb()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - return; - } + m_RegWorkingSet.SetX86Protected(Reg, true); + if (VAddr < 0x80000000 || VAddr >= 0xC0000000) + { + if (!g_System->bUseTlb()) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + return; + } - x86Reg TlbMappReg = Map_TempReg(x86_Any, -1, false); - MoveConstToX86reg(VAddr >> 12,TlbMappReg); - MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TlbMappReg,TlbMappReg,4); - CompileReadTLBMiss(VAddr,TlbMappReg); - AddConstToX86Reg(TlbMappReg,VAddr); - MoveX86PointerToX86reg(Reg,TlbMappReg); - } - else - { - if (!TranslateVaddr(VAddr, PAddr)) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + x86Reg TlbMappReg = Map_TempReg(x86_Any, -1, false); + MoveConstToX86reg(VAddr >> 12, TlbMappReg); + MoveVariableDispToX86Reg(m_TLB_ReadMap, "m_TLB_ReadMap", TlbMappReg, TlbMappReg, 4); + CompileReadTLBMiss(VAddr, TlbMappReg); + AddConstToX86Reg(TlbMappReg, VAddr); + MoveX86PointerToX86reg(Reg, TlbMappReg); + } + else + { + if (!TranslateVaddr(VAddr, PAddr)) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } - switch (PAddr & 0xFFF00000) - { - case 0x00000000: - case 0x00100000: - case 0x00200000: - case 0x00300000: - case 0x00400000: - case 0x00500000: - case 0x00600000: - case 0x00700000: - sprintf(VarName,"m_RDRAM + %X",PAddr); - MoveVariableToX86reg(PAddr + m_RDRAM,VarName,Reg); - break; - case 0x04000000: - if (PAddr < 0x04002000) - { - sprintf(VarName,"m_RDRAM + %X",PAddr); - MoveVariableToX86reg(PAddr + m_RDRAM,VarName,Reg); - break; - } - switch (PAddr) - { - case 0x04040010: MoveVariableToX86reg(&g_Reg->SP_STATUS_REG,"SP_STATUS_REG",Reg); break; - case 0x04040014: MoveVariableToX86reg(&g_Reg->SP_DMA_FULL_REG,"SP_DMA_FULL_REG",Reg); break; - case 0x04040018: MoveVariableToX86reg(&g_Reg->SP_DMA_BUSY_REG,"SP_DMA_BUSY_REG",Reg); break; - case 0x0404001C: - MoveVariableToX86reg(&g_Reg->SP_SEMAPHORE_REG,"SP_SEMAPHORE_REG",Reg); - MoveConstToVariable(1,&g_Reg->SP_SEMAPHORE_REG,"SP_SEMAPHORE_REG"); - break; - case 0x04080000: MoveVariableToX86reg(&g_Reg->SP_PC_REG,"SP_PC_REG",Reg); break; - default: - MoveConstToX86reg(0,Reg); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X",VAddr).ToUTF16().c_str()); - } - } - break; - case 0x04100000: - { - static DWORD TempValue = 0; - BeforeCallDirect(m_RegWorkingSet); - PushImm32("TempValue",(DWORD)&TempValue); - PushImm32(PAddr); - MoveConstToX86reg((ULONG)((CMipsMemoryVM *)this),x86_ECX); - Call_Direct(AddressOf(&CMipsMemoryVM::LW_NonMemory),"CMipsMemoryVM::LW_NonMemory"); - AfterCallDirect(m_RegWorkingSet); - MoveVariableToX86reg(&TempValue,"TempValue",Reg); - } - break; - case 0x04300000: - switch (PAddr) - { - case 0x04300000: MoveVariableToX86reg(&g_Reg->MI_MODE_REG,"MI_MODE_REG",Reg); break; - case 0x04300004: MoveVariableToX86reg(&g_Reg->MI_VERSION_REG,"MI_VERSION_REG",Reg); break; - case 0x04300008: MoveVariableToX86reg(&g_Reg->MI_INTR_REG,"MI_INTR_REG",Reg); break; - case 0x0430000C: MoveVariableToX86reg(&g_Reg->MI_INTR_MASK_REG,"MI_INTR_MASK_REG",Reg); break; - default: - MoveConstToX86reg(0,Reg); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X",VAddr).ToUTF16().c_str()); } - } - break; - case 0x04400000: - switch (PAddr) - { - case 0x04400010: - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); - UpdateCounters(m_RegWorkingSet,false, true); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)this,x86_ECX); - Call_Direct(AddressOf(&CMipsMemoryVM::UpdateHalfLine),"CMipsMemoryVM::UpdateHalfLine"); - AfterCallDirect(m_RegWorkingSet); - MoveVariableToX86reg(&m_HalfLine,"m_HalfLine",Reg); - break; - default: - MoveConstToX86reg(0,Reg); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X",VAddr).ToUTF16().c_str()); - } - } - break; - case 0x04500000: /* AI registers */ - switch (PAddr) - { - case 0x04500004: - if (g_System->bFixedAudio()) - { - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); - UpdateCounters(m_RegWorkingSet,false, true); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_Audio,x86_ECX); - Call_Direct(AddressOf(&CAudio::GetLength),"CAudio::GetLength"); - MoveX86regToVariable(x86_EAX,&m_TempValue,"m_TempValue"); - AfterCallDirect(m_RegWorkingSet); - MoveVariableToX86reg(&m_TempValue,"m_TempValue",Reg); - } - else - { - if (g_Plugins->Audio()->AiReadLength != NULL) - { - BeforeCallDirect(m_RegWorkingSet); - Call_Direct(g_Plugins->Audio()->AiReadLength, "AiReadLength"); - MoveX86regToVariable(x86_EAX,&m_TempValue,"m_TempValue"); - AfterCallDirect(m_RegWorkingSet); - MoveVariableToX86reg(&m_TempValue,"m_TempValue",Reg); - } - else - { - MoveConstToX86reg(0,Reg); - } - } - break; - case 0x0450000C: - if (g_System->bFixedAudio()) - { - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_Audio,x86_ECX); - Call_Direct(AddressOf(&CAudio::GetStatus),"GetStatus"); - MoveX86regToVariable(x86_EAX,&m_TempValue,"m_TempValue"); - AfterCallDirect(m_RegWorkingSet); - MoveVariableToX86reg(&m_TempValue,"m_TempValue",Reg); - } - else - { - MoveVariableToX86reg(&g_Reg->AI_STATUS_REG,"AI_STATUS_REG",Reg); - } - break; - default: - MoveConstToX86reg(0,Reg); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X",VAddr).ToUTF16().c_str()); - } - } - break; - case 0x04600000: - switch (PAddr) - { - case 0x04600010: MoveVariableToX86reg(&g_Reg->PI_STATUS_REG,"PI_STATUS_REG",Reg); break; - case 0x04600014: MoveVariableToX86reg(&g_Reg->PI_DOMAIN1_REG,"PI_DOMAIN1_REG",Reg); break; - case 0x04600018: MoveVariableToX86reg(&g_Reg->PI_BSD_DOM1_PWD_REG,"PI_BSD_DOM1_PWD_REG",Reg); break; - case 0x0460001C: MoveVariableToX86reg(&g_Reg->PI_BSD_DOM1_PGS_REG,"PI_BSD_DOM1_PGS_REG",Reg); break; - case 0x04600020: MoveVariableToX86reg(&g_Reg->PI_BSD_DOM1_RLS_REG,"PI_BSD_DOM1_RLS_REG",Reg); break; - case 0x04600024: MoveVariableToX86reg(&g_Reg->PI_DOMAIN2_REG,"PI_DOMAIN2_REG",Reg); break; - case 0x04600028: MoveVariableToX86reg(&g_Reg->PI_BSD_DOM2_PWD_REG,"PI_BSD_DOM2_PWD_REG",Reg); break; - case 0x0460002C: MoveVariableToX86reg(&g_Reg->PI_BSD_DOM2_PGS_REG,"PI_BSD_DOM2_PGS_REG",Reg); break; - case 0x04600030: MoveVariableToX86reg(&g_Reg->PI_BSD_DOM2_RLS_REG,"PI_BSD_DOM2_RLS_REG",Reg); break; - default: - MoveConstToX86reg(0,Reg); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X",VAddr).ToUTF16().c_str()); - } - } - break; - case 0x04700000: - switch (PAddr) - { - case 0x0470000C: MoveVariableToX86reg(&g_Reg->RI_SELECT_REG,"RI_SELECT_REG",Reg); break; - case 0x04700010: MoveVariableToX86reg(&g_Reg->RI_REFRESH_REG,"RI_REFRESH_REG",Reg); break; - default: - MoveConstToX86reg(0,Reg); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X",VAddr).ToUTF16().c_str()); - } - } - break; - case 0x04800000: - switch (PAddr) - { - case 0x04800018: MoveVariableToX86reg(&g_Reg->SI_STATUS_REG,"SI_STATUS_REG",Reg); break; - default: - MoveConstToX86reg(0,Reg); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X",VAddr).ToUTF16().c_str()); - } - } - break; - case 0x1FC00000: - sprintf(VarName,"m_RDRAM + %X",PAddr); - MoveVariableToX86reg(PAddr + m_RDRAM,VarName,Reg); - break; - default: - if ((PAddr & 0xF0000000) == 0x10000000 && (PAddr - 0x10000000) < m_RomSize) - { - // read from rom - sprintf(VarName,"m_RDRAM + %X",PAddr); - MoveVariableToX86reg(PAddr + m_RDRAM,VarName,Reg); - } - else - { - MoveConstToX86reg(((PAddr & 0xFFFF) << 16) | (PAddr & 0xFFFF),Reg); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - CPU_Message(__FUNCTION__ "\nFailed to translate address: %08X",VAddr); - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X",VAddr).ToUTF16().c_str()); - } - } - } - } + switch (PAddr & 0xFFF00000) + { + case 0x00000000: + case 0x00100000: + case 0x00200000: + case 0x00300000: + case 0x00400000: + case 0x00500000: + case 0x00600000: + case 0x00700000: + sprintf(VarName, "m_RDRAM + %X", PAddr); + MoveVariableToX86reg(PAddr + m_RDRAM, VarName, Reg); + break; + case 0x04000000: + if (PAddr < 0x04002000) + { + sprintf(VarName, "m_RDRAM + %X", PAddr); + MoveVariableToX86reg(PAddr + m_RDRAM, VarName, Reg); + break; + } + switch (PAddr) + { + case 0x04040010: MoveVariableToX86reg(&g_Reg->SP_STATUS_REG, "SP_STATUS_REG", Reg); break; + case 0x04040014: MoveVariableToX86reg(&g_Reg->SP_DMA_FULL_REG, "SP_DMA_FULL_REG", Reg); break; + case 0x04040018: MoveVariableToX86reg(&g_Reg->SP_DMA_BUSY_REG, "SP_DMA_BUSY_REG", Reg); break; + case 0x0404001C: + MoveVariableToX86reg(&g_Reg->SP_SEMAPHORE_REG, "SP_SEMAPHORE_REG", Reg); + MoveConstToVariable(1, &g_Reg->SP_SEMAPHORE_REG, "SP_SEMAPHORE_REG"); + break; + case 0x04080000: MoveVariableToX86reg(&g_Reg->SP_PC_REG, "SP_PC_REG", Reg); break; + default: + MoveConstToX86reg(0, Reg); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).ToUTF16().c_str()); + } + } + break; + case 0x04100000: + { + static uint32_t TempValue = 0; + BeforeCallDirect(m_RegWorkingSet); + PushImm32("TempValue", (uint32_t)&TempValue); + PushImm32(PAddr); + MoveConstToX86reg((ULONG)((CMipsMemoryVM *)this), x86_ECX); + Call_Direct(AddressOf(&CMipsMemoryVM::LW_NonMemory), "CMipsMemoryVM::LW_NonMemory"); + AfterCallDirect(m_RegWorkingSet); + MoveVariableToX86reg(&TempValue, "TempValue", Reg); + } + break; + case 0x04300000: + switch (PAddr) + { + case 0x04300000: MoveVariableToX86reg(&g_Reg->MI_MODE_REG, "MI_MODE_REG", Reg); break; + case 0x04300004: MoveVariableToX86reg(&g_Reg->MI_VERSION_REG, "MI_VERSION_REG", Reg); break; + case 0x04300008: MoveVariableToX86reg(&g_Reg->MI_INTR_REG, "MI_INTR_REG", Reg); break; + case 0x0430000C: MoveVariableToX86reg(&g_Reg->MI_INTR_MASK_REG, "MI_INTR_MASK_REG", Reg); break; + default: + MoveConstToX86reg(0, Reg); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).ToUTF16().c_str()); } + } + break; + case 0x04400000: + switch (PAddr) + { + case 0x04400010: + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); + UpdateCounters(m_RegWorkingSet, false, true); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)this, x86_ECX); + Call_Direct(AddressOf(&CMipsMemoryVM::UpdateHalfLine), "CMipsMemoryVM::UpdateHalfLine"); + AfterCallDirect(m_RegWorkingSet); + MoveVariableToX86reg(&m_HalfLine, "m_HalfLine", Reg); + break; + default: + MoveConstToX86reg(0, Reg); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).ToUTF16().c_str()); + } + } + break; + case 0x04500000: /* AI registers */ + switch (PAddr) + { + case 0x04500004: + if (g_System->bFixedAudio()) + { + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); + UpdateCounters(m_RegWorkingSet, false, true); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_Audio, x86_ECX); + Call_Direct(AddressOf(&CAudio::GetLength), "CAudio::GetLength"); + MoveX86regToVariable(x86_EAX, &m_TempValue, "m_TempValue"); + AfterCallDirect(m_RegWorkingSet); + MoveVariableToX86reg(&m_TempValue, "m_TempValue", Reg); + } + else + { + if (g_Plugins->Audio()->AiReadLength != NULL) + { + BeforeCallDirect(m_RegWorkingSet); + Call_Direct(g_Plugins->Audio()->AiReadLength, "AiReadLength"); + MoveX86regToVariable(x86_EAX, &m_TempValue, "m_TempValue"); + AfterCallDirect(m_RegWorkingSet); + MoveVariableToX86reg(&m_TempValue, "m_TempValue", Reg); + } + else + { + MoveConstToX86reg(0, Reg); + } + } + break; + case 0x0450000C: + if (g_System->bFixedAudio()) + { + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_Audio, x86_ECX); + Call_Direct(AddressOf(&CAudio::GetStatus), "GetStatus"); + MoveX86regToVariable(x86_EAX, &m_TempValue, "m_TempValue"); + AfterCallDirect(m_RegWorkingSet); + MoveVariableToX86reg(&m_TempValue, "m_TempValue", Reg); + } + else + { + MoveVariableToX86reg(&g_Reg->AI_STATUS_REG, "AI_STATUS_REG", Reg); + } + break; + default: + MoveConstToX86reg(0, Reg); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).ToUTF16().c_str()); + } + } + break; + case 0x04600000: + switch (PAddr) + { + case 0x04600010: MoveVariableToX86reg(&g_Reg->PI_STATUS_REG, "PI_STATUS_REG", Reg); break; + case 0x04600014: MoveVariableToX86reg(&g_Reg->PI_DOMAIN1_REG, "PI_DOMAIN1_REG", Reg); break; + case 0x04600018: MoveVariableToX86reg(&g_Reg->PI_BSD_DOM1_PWD_REG, "PI_BSD_DOM1_PWD_REG", Reg); break; + case 0x0460001C: MoveVariableToX86reg(&g_Reg->PI_BSD_DOM1_PGS_REG, "PI_BSD_DOM1_PGS_REG", Reg); break; + case 0x04600020: MoveVariableToX86reg(&g_Reg->PI_BSD_DOM1_RLS_REG, "PI_BSD_DOM1_RLS_REG", Reg); break; + case 0x04600024: MoveVariableToX86reg(&g_Reg->PI_DOMAIN2_REG, "PI_DOMAIN2_REG", Reg); break; + case 0x04600028: MoveVariableToX86reg(&g_Reg->PI_BSD_DOM2_PWD_REG, "PI_BSD_DOM2_PWD_REG", Reg); break; + case 0x0460002C: MoveVariableToX86reg(&g_Reg->PI_BSD_DOM2_PGS_REG, "PI_BSD_DOM2_PGS_REG", Reg); break; + case 0x04600030: MoveVariableToX86reg(&g_Reg->PI_BSD_DOM2_RLS_REG, "PI_BSD_DOM2_RLS_REG", Reg); break; + default: + MoveConstToX86reg(0, Reg); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).ToUTF16().c_str()); + } + } + break; + case 0x04700000: + switch (PAddr) + { + case 0x0470000C: MoveVariableToX86reg(&g_Reg->RI_SELECT_REG, "RI_SELECT_REG", Reg); break; + case 0x04700010: MoveVariableToX86reg(&g_Reg->RI_REFRESH_REG, "RI_REFRESH_REG", Reg); break; + default: + MoveConstToX86reg(0, Reg); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).ToUTF16().c_str()); + } + } + break; + case 0x04800000: + switch (PAddr) + { + case 0x04800018: MoveVariableToX86reg(&g_Reg->SI_STATUS_REG, "SI_STATUS_REG", Reg); break; + default: + MoveConstToX86reg(0, Reg); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).ToUTF16().c_str()); + } + } + break; + case 0x1FC00000: + sprintf(VarName, "m_RDRAM + %X", PAddr); + MoveVariableToX86reg(PAddr + m_RDRAM, VarName, Reg); + break; + default: + if ((PAddr & 0xF0000000) == 0x10000000 && (PAddr - 0x10000000) < m_RomSize) + { + // read from rom + sprintf(VarName, "m_RDRAM + %X", PAddr); + MoveVariableToX86reg(PAddr + m_RDRAM, VarName, Reg); + } + else + { + MoveConstToX86reg(((PAddr & 0xFFFF) << 16) | (PAddr & 0xFFFF), Reg); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + CPU_Message(__FUNCTION__ "\nFailed to translate address: %08X", VAddr); + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).ToUTF16().c_str()); + } + } + } + } } -void CMipsMemoryVM::Compile_SB_Const ( BYTE Value, DWORD VAddr ) +void CMipsMemoryVM::Compile_SB_Const(uint8_t Value, uint32_t VAddr) { - char VarName[100]; - DWORD PAddr; + char VarName[100]; + uint32_t PAddr; - if (VAddr < 0x80000000 || VAddr >= 0xC0000000) - { - x86Reg TempReg1 = Map_TempReg(x86_Any, -1, false); - x86Reg TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveConstToX86reg(VAddr, TempReg1); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_WriteMap,"m_TLB_WriteMap",TempReg2,TempReg2,4); - CompileWriteTLBMiss(TempReg1,TempReg2); - MoveConstByteToX86regPointer(Value,TempReg1, TempReg2); - return; - } + if (VAddr < 0x80000000 || VAddr >= 0xC0000000) + { + x86Reg TempReg1 = Map_TempReg(x86_Any, -1, false); + x86Reg TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveConstToX86reg(VAddr, TempReg1); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_WriteMap, "m_TLB_WriteMap", TempReg2, TempReg2, 4); + CompileWriteTLBMiss(TempReg1, TempReg2); + MoveConstByteToX86regPointer(Value, TempReg1, TempReg2); + return; + } - if (!TranslateVaddr(VAddr, PAddr)) - { - CPU_Message("Compile_SB\nFailed to translate address: %08X",VAddr); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X",VAddr).ToUTF16().c_str()); } - return; - } + if (!TranslateVaddr(VAddr, PAddr)) + { + CPU_Message("Compile_SB\nFailed to translate address: %08X", VAddr); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).ToUTF16().c_str()); } + return; + } - switch (PAddr & 0xFFF00000) - { - case 0x00000000: - case 0x00100000: - case 0x00200000: - case 0x00300000: - case 0x00400000: - case 0x00500000: - case 0x00600000: - case 0x00700000: - sprintf(VarName,"m_RDRAM + %X",PAddr); - MoveConstByteToVariable(Value,PAddr + m_RDRAM,VarName); - break; - default: - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %02X in %08X?",Value,VAddr).ToUTF16().c_str()); - } - } + switch (PAddr & 0xFFF00000) + { + case 0x00000000: + case 0x00100000: + case 0x00200000: + case 0x00300000: + case 0x00400000: + case 0x00500000: + case 0x00600000: + case 0x00700000: + sprintf(VarName, "m_RDRAM + %X", PAddr); + MoveConstByteToVariable(Value, PAddr + m_RDRAM, VarName); + break; + default: + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %02X in %08X?", Value, VAddr).ToUTF16().c_str()); + } + } } -void CMipsMemoryVM::Compile_SB_Register ( x86Reg Reg, DWORD VAddr ) +void CMipsMemoryVM::Compile_SB_Register(x86Reg Reg, uint32_t VAddr) { - char VarName[100]; - DWORD PAddr; + char VarName[100]; + uint32_t PAddr; - if (VAddr < 0x80000000 || VAddr >= 0xC0000000) - { - m_RegWorkingSet.SetX86Protected(Reg,true); + if (VAddr < 0x80000000 || VAddr >= 0xC0000000) + { + m_RegWorkingSet.SetX86Protected(Reg, true); - x86Reg TempReg1 = Map_TempReg(x86_Any, -1, false); - x86Reg TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveConstToX86reg(VAddr, TempReg1); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_WriteMap,"m_TLB_WriteMap",TempReg2,TempReg2,4); - CompileWriteTLBMiss(TempReg1,TempReg2); - MoveX86regByteToX86regPointer(Reg,TempReg1, TempReg2); - return; - } + x86Reg TempReg1 = Map_TempReg(x86_Any, -1, false); + x86Reg TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveConstToX86reg(VAddr, TempReg1); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_WriteMap, "m_TLB_WriteMap", TempReg2, TempReg2, 4); + CompileWriteTLBMiss(TempReg1, TempReg2); + MoveX86regByteToX86regPointer(Reg, TempReg1, TempReg2); + return; + } - if (!TranslateVaddr(VAddr, PAddr)) - { - CPU_Message("Compile_SB\nFailed to translate address: %08X",VAddr); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).ToUTF16().c_str()); - } - return; - } + if (!TranslateVaddr(VAddr, PAddr)) + { + CPU_Message("Compile_SB\nFailed to translate address: %08X", VAddr); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).ToUTF16().c_str()); + } + return; + } - switch (PAddr & 0xFFF00000) - { - case 0x00000000: - case 0x00100000: - case 0x00200000: - case 0x00300000: - case 0x00400000: - case 0x00500000: - case 0x00600000: - case 0x00700000: - sprintf(VarName,"m_RDRAM + %X",PAddr); - MoveX86regByteToVariable(Reg,PAddr + m_RDRAM,VarName); - break; - default: - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).ToUTF16().c_str()); - } - } + switch (PAddr & 0xFFF00000) + { + case 0x00000000: + case 0x00100000: + case 0x00200000: + case 0x00300000: + case 0x00400000: + case 0x00500000: + case 0x00600000: + case 0x00700000: + sprintf(VarName, "m_RDRAM + %X", PAddr); + MoveX86regByteToVariable(Reg, PAddr + m_RDRAM, VarName); + break; + default: + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).ToUTF16().c_str()); + } + } } -void CMipsMemoryVM::Compile_SH_Const ( WORD Value, DWORD VAddr ) +void CMipsMemoryVM::Compile_SH_Const(uint16_t Value, uint32_t VAddr) { - char VarName[100]; - DWORD PAddr; + char VarName[100]; + uint32_t PAddr; - if (VAddr < 0x80000000 || VAddr >= 0xC0000000) - { - x86Reg TempReg1 = Map_TempReg(x86_Any, -1, false); - x86Reg TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveConstToX86reg(VAddr, TempReg1); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_WriteMap,"m_TLB_WriteMap",TempReg2,TempReg2,4); - CompileWriteTLBMiss(TempReg1,TempReg2); - MoveConstHalfToX86regPointer(Value,TempReg1, TempReg2); - return; - } + if (VAddr < 0x80000000 || VAddr >= 0xC0000000) + { + x86Reg TempReg1 = Map_TempReg(x86_Any, -1, false); + x86Reg TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveConstToX86reg(VAddr, TempReg1); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_WriteMap, "m_TLB_WriteMap", TempReg2, TempReg2, 4); + CompileWriteTLBMiss(TempReg1, TempReg2); + MoveConstHalfToX86regPointer(Value, TempReg1, TempReg2); + return; + } - if (!TranslateVaddr(VAddr, PAddr)) { - CPU_Message("Compile_SH\nFailed to translate address: %08X",VAddr); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).ToUTF16().c_str()); - } - return; - } + if (!TranslateVaddr(VAddr, PAddr)) { + CPU_Message("Compile_SH\nFailed to translate address: %08X", VAddr); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).ToUTF16().c_str()); + } + return; + } - switch (PAddr & 0xFFF00000) - { - case 0x00000000: - case 0x00100000: - case 0x00200000: - case 0x00300000: - case 0x00400000: - case 0x00500000: - case 0x00600000: - case 0x00700000: - sprintf(VarName,"m_RDRAM + %X",PAddr); - MoveConstHalfToVariable(Value,PAddr + m_RDRAM,VarName); - break; - default: - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %04X in %08X?",Value,VAddr).ToUTF16().c_str()); - } - } + switch (PAddr & 0xFFF00000) + { + case 0x00000000: + case 0x00100000: + case 0x00200000: + case 0x00300000: + case 0x00400000: + case 0x00500000: + case 0x00600000: + case 0x00700000: + sprintf(VarName, "m_RDRAM + %X", PAddr); + MoveConstHalfToVariable(Value, PAddr + m_RDRAM, VarName); + break; + default: + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %04X in %08X?", Value, VAddr).ToUTF16().c_str()); + } + } } -void CMipsMemoryVM::Compile_SH_Register ( x86Reg Reg, DWORD VAddr ) +void CMipsMemoryVM::Compile_SH_Register(x86Reg Reg, uint32_t VAddr) { - char VarName[100]; - DWORD PAddr; + char VarName[100]; + uint32_t PAddr; - if (VAddr < 0x80000000 || VAddr >= 0xC0000000) - { - m_RegWorkingSet.SetX86Protected(Reg,true); + if (VAddr < 0x80000000 || VAddr >= 0xC0000000) + { + m_RegWorkingSet.SetX86Protected(Reg, true); - x86Reg TempReg1 = Map_TempReg(x86_Any, -1, false); - x86Reg TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveConstToX86reg(VAddr, TempReg1); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_WriteMap,"m_TLB_WriteMap",TempReg2,TempReg2,4); - CompileWriteTLBMiss(TempReg1,TempReg2); - MoveX86regHalfToX86regPointer(Reg,TempReg1, TempReg2); - return; - } + x86Reg TempReg1 = Map_TempReg(x86_Any, -1, false); + x86Reg TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveConstToX86reg(VAddr, TempReg1); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_WriteMap, "m_TLB_WriteMap", TempReg2, TempReg2, 4); + CompileWriteTLBMiss(TempReg1, TempReg2); + MoveX86regHalfToX86regPointer(Reg, TempReg1, TempReg2); + return; + } - if (!TranslateVaddr(VAddr, PAddr)) { - CPU_Message("Compile_SH\nFailed to translate address: %08X",VAddr); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).ToUTF16().c_str()); - } - return; - } + if (!TranslateVaddr(VAddr, PAddr)) { + CPU_Message("Compile_SH\nFailed to translate address: %08X", VAddr); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).ToUTF16().c_str()); + } + return; + } - switch (PAddr & 0xFFF00000) - { - case 0x00000000: - case 0x00100000: - case 0x00200000: - case 0x00300000: - case 0x00400000: - case 0x00500000: - case 0x00600000: - case 0x00700000: - sprintf(VarName,"m_RDRAM + %X",PAddr); - MoveX86regHalfToVariable(Reg,PAddr + m_RDRAM,VarName); - break; - default: - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", PAddr).ToUTF16().c_str()); - } - } + switch (PAddr & 0xFFF00000) + { + case 0x00000000: + case 0x00100000: + case 0x00200000: + case 0x00300000: + case 0x00400000: + case 0x00500000: + case 0x00600000: + case 0x00700000: + sprintf(VarName, "m_RDRAM + %X", PAddr); + MoveX86regHalfToVariable(Reg, PAddr + m_RDRAM, VarName); + break; + default: + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", PAddr).ToUTF16().c_str()); + } + } } -void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) +void CMipsMemoryVM::Compile_SW_Const(uint32_t Value, uint32_t VAddr) { - char VarName[100]; - BYTE * Jump; - DWORD PAddr; + char VarName[100]; + uint8_t * Jump; + uint32_t PAddr; - if (VAddr < 0x80000000 || VAddr >= 0xC0000000) - { - x86Reg TempReg1 = Map_TempReg(x86_Any, -1, false); - x86Reg TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveConstToX86reg(VAddr, TempReg1); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_WriteMap,"m_TLB_WriteMap",TempReg2,TempReg2,4); - CompileWriteTLBMiss(TempReg1,TempReg2); - MoveConstToX86regPointer(Value,TempReg1, TempReg2); - return; - } + if (VAddr < 0x80000000 || VAddr >= 0xC0000000) + { + x86Reg TempReg1 = Map_TempReg(x86_Any, -1, false); + x86Reg TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveConstToX86reg(VAddr, TempReg1); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_WriteMap, "m_TLB_WriteMap", TempReg2, TempReg2, 4); + CompileWriteTLBMiss(TempReg1, TempReg2); + MoveConstToX86regPointer(Value, TempReg1, TempReg2); + return; + } - if (!TranslateVaddr(VAddr, PAddr)) - { - CPU_Message("Compile_SW\nFailed to translate address: %08X",VAddr); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).ToUTF16().c_str()); - } - return; - } + if (!TranslateVaddr(VAddr, PAddr)) + { + CPU_Message("Compile_SW\nFailed to translate address: %08X", VAddr); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).ToUTF16().c_str()); + } + return; + } - switch (PAddr & 0xFFF00000) - { - case 0x00000000: - case 0x00100000: - case 0x00200000: - case 0x00300000: - case 0x00400000: - case 0x00500000: - case 0x00600000: - case 0x00700000: - sprintf(VarName,"m_RDRAM + %X",PAddr); - MoveConstToVariable(Value,PAddr + m_RDRAM,VarName); - break; - case 0x03F00000: - switch (PAddr) - { - case 0x03F00000: MoveConstToVariable(Value,&g_Reg->RDRAM_CONFIG_REG,"RDRAM_CONFIG_REG"); break; - case 0x03F00004: MoveConstToVariable(Value,&g_Reg->RDRAM_DEVICE_ID_REG,"RDRAM_DEVICE_ID_REG"); break; - case 0x03F00008: MoveConstToVariable(Value,&g_Reg->RDRAM_DELAY_REG,"RDRAM_DELAY_REG"); break; - case 0x03F0000C: MoveConstToVariable(Value,&g_Reg->RDRAM_MODE_REG,"RDRAM_MODE_REG"); break; - case 0x03F00010: MoveConstToVariable(Value,&g_Reg->RDRAM_REF_INTERVAL_REG,"RDRAM_REF_INTERVAL_REG"); break; - case 0x03F00014: MoveConstToVariable(Value,&g_Reg->RDRAM_REF_ROW_REG,"RDRAM_REF_ROW_REG"); break; - case 0x03F00018: MoveConstToVariable(Value,&g_Reg->RDRAM_RAS_INTERVAL_REG,"RDRAM_RAS_INTERVAL_REG"); break; - case 0x03F0001C: MoveConstToVariable(Value,&g_Reg->RDRAM_MIN_INTERVAL_REG,"RDRAM_MIN_INTERVAL_REG"); break; - case 0x03F00020: MoveConstToVariable(Value,&g_Reg->RDRAM_ADDR_SELECT_REG,"RDRAM_ADDR_SELECT_REG"); break; - case 0x03F00024: MoveConstToVariable(Value,&g_Reg->RDRAM_DEVICE_MANUF_REG,"RDRAM_DEVICE_MANUF_REG"); break; - case 0x03F04004: break; - case 0x03F08004: break; - case 0x03F80004: break; - case 0x03F80008: break; - case 0x03F8000C: break; - case 0x03F80014: break; - default: - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).ToUTF16().c_str()); - } - } - break; - case 0x04000000: - if (PAddr < 0x04002000) - { - sprintf(VarName,"m_RDRAM + %X",PAddr); - MoveConstToVariable(Value,PAddr + m_RDRAM,VarName); - break; - } - switch (PAddr) - { - case 0x04040000: MoveConstToVariable(Value,&g_Reg->SP_MEM_ADDR_REG,"SP_MEM_ADDR_REG"); break; - case 0x04040004: MoveConstToVariable(Value,&g_Reg->SP_DRAM_ADDR_REG,"SP_DRAM_ADDR_REG"); break; - case 0x04040008: - MoveConstToVariable(Value,&g_Reg->SP_RD_LEN_REG,"SP_RD_LEN_REG"); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((ULONG)((CDMA *)this),x86_ECX); - Call_Direct(AddressOf(&CDMA::SP_DMA_READ),"CDMA::SP_DMA_READ"); - AfterCallDirect(m_RegWorkingSet); - break; - case 0x04040010: - { - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount()-g_System->CountPerOp()); - UpdateCounters(m_RegWorkingSet,false,true); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount()+g_System->CountPerOp()); + switch (PAddr & 0xFFF00000) + { + case 0x00000000: + case 0x00100000: + case 0x00200000: + case 0x00300000: + case 0x00400000: + case 0x00500000: + case 0x00600000: + case 0x00700000: + sprintf(VarName, "m_RDRAM + %X", PAddr); + MoveConstToVariable(Value, PAddr + m_RDRAM, VarName); + break; + case 0x03F00000: + switch (PAddr) + { + case 0x03F00000: MoveConstToVariable(Value, &g_Reg->RDRAM_CONFIG_REG, "RDRAM_CONFIG_REG"); break; + case 0x03F00004: MoveConstToVariable(Value, &g_Reg->RDRAM_DEVICE_ID_REG, "RDRAM_DEVICE_ID_REG"); break; + case 0x03F00008: MoveConstToVariable(Value, &g_Reg->RDRAM_DELAY_REG, "RDRAM_DELAY_REG"); break; + case 0x03F0000C: MoveConstToVariable(Value, &g_Reg->RDRAM_MODE_REG, "RDRAM_MODE_REG"); break; + case 0x03F00010: MoveConstToVariable(Value, &g_Reg->RDRAM_REF_INTERVAL_REG, "RDRAM_REF_INTERVAL_REG"); break; + case 0x03F00014: MoveConstToVariable(Value, &g_Reg->RDRAM_REF_ROW_REG, "RDRAM_REF_ROW_REG"); break; + case 0x03F00018: MoveConstToVariable(Value, &g_Reg->RDRAM_RAS_INTERVAL_REG, "RDRAM_RAS_INTERVAL_REG"); break; + case 0x03F0001C: MoveConstToVariable(Value, &g_Reg->RDRAM_MIN_INTERVAL_REG, "RDRAM_MIN_INTERVAL_REG"); break; + case 0x03F00020: MoveConstToVariable(Value, &g_Reg->RDRAM_ADDR_SELECT_REG, "RDRAM_ADDR_SELECT_REG"); break; + case 0x03F00024: MoveConstToVariable(Value, &g_Reg->RDRAM_DEVICE_MANUF_REG, "RDRAM_DEVICE_MANUF_REG"); break; + case 0x03F04004: break; + case 0x03F08004: break; + case 0x03F80004: break; + case 0x03F80008: break; + case 0x03F8000C: break; + case 0x03F80014: break; + default: + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).ToUTF16().c_str()); + } + } + break; + case 0x04000000: + if (PAddr < 0x04002000) + { + sprintf(VarName, "m_RDRAM + %X", PAddr); + MoveConstToVariable(Value, PAddr + m_RDRAM, VarName); + break; + } + switch (PAddr) + { + case 0x04040000: MoveConstToVariable(Value, &g_Reg->SP_MEM_ADDR_REG, "SP_MEM_ADDR_REG"); break; + case 0x04040004: MoveConstToVariable(Value, &g_Reg->SP_DRAM_ADDR_REG, "SP_DRAM_ADDR_REG"); break; + case 0x04040008: + MoveConstToVariable(Value, &g_Reg->SP_RD_LEN_REG, "SP_RD_LEN_REG"); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((ULONG)((CDMA *)this), x86_ECX); + Call_Direct(AddressOf(&CDMA::SP_DMA_READ), "CDMA::SP_DMA_READ"); + AfterCallDirect(m_RegWorkingSet); + break; + case 0x04040010: + { + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); + UpdateCounters(m_RegWorkingSet, false, true); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); - BeforeCallDirect(m_RegWorkingSet); - PushImm32(Value); - PushImm32(PAddr); - MoveConstToX86reg((ULONG)((CMipsMemoryVM *)this),x86_ECX); - Call_Direct(AddressOf(&CMipsMemoryVM::SW_NonMemory),"CMipsMemoryVM::SW_NonMemory"); - AfterCallDirect(m_RegWorkingSet); - } - break; - case 0x0404001C: MoveConstToVariable(0,&g_Reg->SP_SEMAPHORE_REG,"SP_SEMAPHORE_REG"); break; - case 0x04080000: MoveConstToVariable(Value & 0xFFC,&g_Reg->SP_PC_REG,"SP_PC_REG"); break; - default: - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).ToUTF16().c_str()); - } - } - break; - case 0x04100000: - switch (PAddr) - { - case 0x0410000C: - BeforeCallDirect(m_RegWorkingSet); - PushImm32(Value); - PushImm32(PAddr); - MoveConstToX86reg((ULONG)((CMipsMemoryVM *)this),x86_ECX); - Call_Direct(AddressOf(&CMipsMemoryVM::SW_NonMemory),"CMipsMemoryVM::SW_NonMemory"); - AfterCallDirect(m_RegWorkingSet); - break; - default: - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).ToUTF16().c_str()); - } - } - break; - case 0x04300000: - switch (PAddr) - { - case 0x04300000: - { - DWORD ModValue; - ModValue = 0x7F; - if ( ( Value & MI_CLR_INIT ) != 0 ) - { - ModValue |= MI_MODE_INIT; - } - if ( ( Value & MI_CLR_EBUS ) != 0 ) - { - ModValue |= MI_MODE_EBUS; - } - if ( ( Value & MI_CLR_RDRAM ) != 0 ) - { - ModValue |= MI_MODE_RDRAM; - } - if (ModValue != 0) - { - AndConstToVariable(~ModValue,&g_Reg->MI_MODE_REG,"MI_MODE_REG"); - } + BeforeCallDirect(m_RegWorkingSet); + PushImm32(Value); + PushImm32(PAddr); + MoveConstToX86reg((ULONG)((CMipsMemoryVM *)this), x86_ECX); + Call_Direct(AddressOf(&CMipsMemoryVM::SW_NonMemory), "CMipsMemoryVM::SW_NonMemory"); + AfterCallDirect(m_RegWorkingSet); + } + break; + case 0x0404001C: MoveConstToVariable(0, &g_Reg->SP_SEMAPHORE_REG, "SP_SEMAPHORE_REG"); break; + case 0x04080000: MoveConstToVariable(Value & 0xFFC, &g_Reg->SP_PC_REG, "SP_PC_REG"); break; + default: + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).ToUTF16().c_str()); + } + } + break; + case 0x04100000: + switch (PAddr) + { + case 0x0410000C: + BeforeCallDirect(m_RegWorkingSet); + PushImm32(Value); + PushImm32(PAddr); + MoveConstToX86reg((ULONG)((CMipsMemoryVM *)this), x86_ECX); + Call_Direct(AddressOf(&CMipsMemoryVM::SW_NonMemory), "CMipsMemoryVM::SW_NonMemory"); + AfterCallDirect(m_RegWorkingSet); + break; + default: + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).ToUTF16().c_str()); + } + } + break; + case 0x04300000: + switch (PAddr) + { + case 0x04300000: + { + uint32_t ModValue; + ModValue = 0x7F; + if ((Value & MI_CLR_INIT) != 0) + { + ModValue |= MI_MODE_INIT; + } + if ((Value & MI_CLR_EBUS) != 0) + { + ModValue |= MI_MODE_EBUS; + } + if ((Value & MI_CLR_RDRAM) != 0) + { + ModValue |= MI_MODE_RDRAM; + } + if (ModValue != 0) + { + AndConstToVariable(~ModValue, &g_Reg->MI_MODE_REG, "MI_MODE_REG"); + } - ModValue = (Value & 0x7F); - if ( ( Value & MI_SET_INIT ) != 0 ) - { - ModValue |= MI_MODE_INIT; - } - if ( ( Value & MI_SET_EBUS ) != 0 ) - { - ModValue |= MI_MODE_EBUS; - } - if ( ( Value & MI_SET_RDRAM ) != 0 ) - { - ModValue |= MI_MODE_RDRAM; - } - if (ModValue != 0) { - OrConstToVariable(ModValue,&g_Reg->MI_MODE_REG,"MI_MODE_REG"); - } - if ( ( Value & MI_CLR_DP_INTR ) != 0 ) - { - AndConstToVariable((DWORD)~MI_INTR_DP,&g_Reg->MI_INTR_REG,"MI_INTR_REG"); - AndConstToVariable((DWORD)~MI_INTR_DP,&g_Reg->m_GfxIntrReg,"m_GfxIntrReg"); - } - } - break; - case 0x0430000C: - { - DWORD ModValue; - ModValue = 0; - if ( ( Value & MI_INTR_MASK_CLR_SP ) != 0 ) - { - ModValue |= MI_INTR_MASK_SP; - } - if ( ( Value & MI_INTR_MASK_CLR_SI ) != 0 ) - { - ModValue |= MI_INTR_MASK_SI; - } - if ( ( Value & MI_INTR_MASK_CLR_AI ) != 0 ) - { - ModValue |= MI_INTR_MASK_AI; - } - if ( ( Value & MI_INTR_MASK_CLR_VI ) != 0 ) - { - ModValue |= MI_INTR_MASK_VI; - } - if ( ( Value & MI_INTR_MASK_CLR_PI ) != 0 ) - { - ModValue |= MI_INTR_MASK_PI; - } - if ( ( Value & MI_INTR_MASK_CLR_DP ) != 0 ) - { - ModValue |= MI_INTR_MASK_DP; - } - if (ModValue != 0) - { - AndConstToVariable(~ModValue,&g_Reg->MI_INTR_MASK_REG,"MI_INTR_MASK_REG"); - } + ModValue = (Value & 0x7F); + if ((Value & MI_SET_INIT) != 0) + { + ModValue |= MI_MODE_INIT; + } + if ((Value & MI_SET_EBUS) != 0) + { + ModValue |= MI_MODE_EBUS; + } + if ((Value & MI_SET_RDRAM) != 0) + { + ModValue |= MI_MODE_RDRAM; + } + if (ModValue != 0) { + OrConstToVariable(ModValue, &g_Reg->MI_MODE_REG, "MI_MODE_REG"); + } + if ((Value & MI_CLR_DP_INTR) != 0) + { + AndConstToVariable((uint32_t)~MI_INTR_DP, &g_Reg->MI_INTR_REG, "MI_INTR_REG"); + AndConstToVariable((uint32_t)~MI_INTR_DP, &g_Reg->m_GfxIntrReg, "m_GfxIntrReg"); + } + } + break; + case 0x0430000C: + { + uint32_t ModValue; + ModValue = 0; + if ((Value & MI_INTR_MASK_CLR_SP) != 0) + { + ModValue |= MI_INTR_MASK_SP; + } + if ((Value & MI_INTR_MASK_CLR_SI) != 0) + { + ModValue |= MI_INTR_MASK_SI; + } + if ((Value & MI_INTR_MASK_CLR_AI) != 0) + { + ModValue |= MI_INTR_MASK_AI; + } + if ((Value & MI_INTR_MASK_CLR_VI) != 0) + { + ModValue |= MI_INTR_MASK_VI; + } + if ((Value & MI_INTR_MASK_CLR_PI) != 0) + { + ModValue |= MI_INTR_MASK_PI; + } + if ((Value & MI_INTR_MASK_CLR_DP) != 0) + { + ModValue |= MI_INTR_MASK_DP; + } + if (ModValue != 0) + { + AndConstToVariable(~ModValue, &g_Reg->MI_INTR_MASK_REG, "MI_INTR_MASK_REG"); + } - ModValue = 0; - if ( ( Value & MI_INTR_MASK_SET_SP ) != 0 ) - { - ModValue |= MI_INTR_MASK_SP; - } - if ( ( Value & MI_INTR_MASK_SET_SI ) != 0 ) - { - ModValue |= MI_INTR_MASK_SI; - } - if ( ( Value & MI_INTR_MASK_SET_AI ) != 0 ) - { - ModValue |= MI_INTR_MASK_AI; - } - if ( ( Value & MI_INTR_MASK_SET_VI ) != 0 ) - { - ModValue |= MI_INTR_MASK_VI; - } - if ( ( Value & MI_INTR_MASK_SET_PI ) != 0 ) - { - ModValue |= MI_INTR_MASK_PI; - } - if ( ( Value & MI_INTR_MASK_SET_DP ) != 0 ) - { - ModValue |= MI_INTR_MASK_DP; - } - if (ModValue != 0) - { - OrConstToVariable(ModValue,&g_Reg->MI_INTR_MASK_REG,"MI_INTR_MASK_REG"); - } - } - break; - default: - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).ToUTF16().c_str()); - } - } - break; - case 0x04400000: - switch (PAddr) - { - case 0x04400000: - if (g_Plugins->Gfx()->ViStatusChanged != NULL) - { - CompConstToVariable(Value,&g_Reg->VI_STATUS_REG,"VI_STATUS_REG"); - JeLabel8("Continue",0); - Jump = m_RecompPos - 1; - MoveConstToVariable(Value,&g_Reg->VI_STATUS_REG,"VI_STATUS_REG"); - BeforeCallDirect(m_RegWorkingSet); - Call_Direct(g_Plugins->Gfx()->ViStatusChanged,"ViStatusChanged"); - AfterCallDirect(m_RegWorkingSet); - CPU_Message(""); - CPU_Message(" Continue:"); - SetJump8(Jump,m_RecompPos); - } - break; - case 0x04400004: MoveConstToVariable((Value & 0xFFFFFF),&g_Reg->VI_ORIGIN_REG,"VI_ORIGIN_REG"); break; - case 0x04400008: - if (g_Plugins->Gfx()->ViWidthChanged != NULL) - { - CompConstToVariable(Value,&g_Reg->VI_WIDTH_REG,"VI_WIDTH_REG"); - JeLabel8("Continue",0); - Jump = m_RecompPos - 1; - MoveConstToVariable(Value,&g_Reg->VI_WIDTH_REG,"VI_WIDTH_REG"); - BeforeCallDirect(m_RegWorkingSet); - Call_Direct(g_Plugins->Gfx()->ViWidthChanged,"ViWidthChanged"); - AfterCallDirect(m_RegWorkingSet); - CPU_Message(""); - CPU_Message(" Continue:"); - SetJump8(Jump,m_RecompPos); - } - break; - case 0x0440000C: MoveConstToVariable(Value,&g_Reg->VI_INTR_REG,"VI_INTR_REG"); break; - case 0x04400010: - AndConstToVariable((DWORD)~MI_INTR_VI,&g_Reg->MI_INTR_REG,"MI_INTR_REG"); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_Reg,x86_ECX); - Call_Direct(AddressOf(&CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - AfterCallDirect(m_RegWorkingSet); - break; - case 0x04400014: MoveConstToVariable(Value,&g_Reg->VI_BURST_REG,"VI_BURST_REG"); break; - case 0x04400018: MoveConstToVariable(Value,&g_Reg->VI_V_SYNC_REG,"VI_V_SYNC_REG"); break; - case 0x0440001C: MoveConstToVariable(Value,&g_Reg->VI_H_SYNC_REG,"VI_H_SYNC_REG"); break; - case 0x04400020: MoveConstToVariable(Value,&g_Reg->VI_LEAP_REG,"VI_LEAP_REG"); break; - case 0x04400024: MoveConstToVariable(Value,&g_Reg->VI_H_START_REG,"VI_H_START_REG"); break; - case 0x04400028: MoveConstToVariable(Value,&g_Reg->VI_V_START_REG,"VI_V_START_REG"); break; - case 0x0440002C: MoveConstToVariable(Value,&g_Reg->VI_V_BURST_REG,"VI_V_BURST_REG"); break; - case 0x04400030: MoveConstToVariable(Value,&g_Reg->VI_X_SCALE_REG,"VI_X_SCALE_REG"); break; - case 0x04400034: MoveConstToVariable(Value,&g_Reg->VI_Y_SCALE_REG,"VI_Y_SCALE_REG"); break; - default: - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).ToUTF16().c_str()); - } - } - break; - case 0x04500000: /* AI registers */ - switch (PAddr) - { - case 0x04500000: MoveConstToVariable(Value,&g_Reg->AI_DRAM_ADDR_REG,"AI_DRAM_ADDR_REG"); break; - case 0x04500004: - MoveConstToVariable(Value,&g_Reg->AI_LEN_REG,"AI_LEN_REG"); - BeforeCallDirect(m_RegWorkingSet); - if (g_System->bFixedAudio()) - { - X86BreakPoint(__FILEW__,__LINE__); - MoveConstToX86reg((DWORD)g_Audio,x86_ECX); - Call_Direct(AddressOf(&CAudio::LenChanged),"LenChanged"); - } - else - { - Call_Direct(g_Plugins->Audio()->AiLenChanged,"AiLenChanged"); - } - AfterCallDirect(m_RegWorkingSet); - break; - case 0x04500008: MoveConstToVariable((Value & 1),&g_Reg->AI_CONTROL_REG,"AI_CONTROL_REG"); break; - case 0x0450000C: - /* Clear Interrupt */; - AndConstToVariable((DWORD)~MI_INTR_AI,&g_Reg->MI_INTR_REG,"MI_INTR_REG"); - AndConstToVariable((DWORD)~MI_INTR_AI,&g_Reg->m_AudioIntrReg,"m_AudioIntrReg"); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_Reg,x86_ECX); - Call_Direct(AddressOf(&CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - AfterCallDirect(m_RegWorkingSet); - break; - case 0x04500010: - sprintf(VarName,"m_RDRAM + %X",PAddr); - MoveConstToVariable(Value,PAddr + m_RDRAM,VarName); - break; - case 0x04500014: MoveConstToVariable(Value,&g_Reg->AI_BITRATE_REG,"AI_BITRATE_REG"); break; - default: - sprintf(VarName,"m_RDRAM + %X",PAddr); - MoveConstToVariable(Value,PAddr + m_RDRAM,VarName); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).ToUTF16().c_str()); - } - } - break; - case 0x04600000: - switch (PAddr) - { - case 0x04600000: MoveConstToVariable(Value,&g_Reg->PI_DRAM_ADDR_REG,"PI_DRAM_ADDR_REG"); break; - case 0x04600004: MoveConstToVariable(Value,&g_Reg->PI_CART_ADDR_REG,"PI_CART_ADDR_REG"); break; - case 0x04600008: - MoveConstToVariable(Value,&g_Reg->PI_RD_LEN_REG,"PI_RD_LEN_REG"); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((ULONG)((CDMA *)this),x86_ECX); - Call_Direct(AddressOf(&CDMA::PI_DMA_READ),"CDMA::PI_DMA_READ"); - AfterCallDirect(m_RegWorkingSet); - break; - case 0x0460000C: - MoveConstToVariable(Value,&g_Reg->PI_WR_LEN_REG,"PI_WR_LEN_REG"); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((ULONG)((CDMA *)this),x86_ECX); - Call_Direct(AddressOf(&CDMA::PI_DMA_WRITE),"CDMA::PI_DMA_WRITE"); - AfterCallDirect(m_RegWorkingSet); - break; - case 0x04600010: - if ((Value & PI_CLR_INTR) != 0 ) - { - AndConstToVariable((DWORD)~MI_INTR_PI,&g_Reg->MI_INTR_REG,"MI_INTR_REG"); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_Reg,x86_ECX); - Call_Direct(AddressOf(&CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - AfterCallDirect(m_RegWorkingSet); - } - break; - case 0x04600014: MoveConstToVariable((Value & 0xFF),&g_Reg->PI_DOMAIN1_REG,"PI_DOMAIN1_REG"); break; - case 0x04600018: MoveConstToVariable((Value & 0xFF),&g_Reg->PI_BSD_DOM1_PWD_REG,"PI_BSD_DOM1_PWD_REG"); break; - case 0x0460001C: MoveConstToVariable((Value & 0xFF),&g_Reg->PI_BSD_DOM1_PGS_REG,"PI_BSD_DOM1_PGS_REG"); break; - case 0x04600020: MoveConstToVariable((Value & 0xFF),&g_Reg->PI_BSD_DOM1_RLS_REG,"PI_BSD_DOM1_RLS_REG"); break; - default: - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).ToUTF16().c_str()); - } - } - break; - case 0x04700000: - switch (PAddr) - { - case 0x04700000: MoveConstToVariable(Value,&g_Reg->RI_MODE_REG,"RI_MODE_REG"); break; - case 0x04700004: MoveConstToVariable(Value,&g_Reg->RI_CONFIG_REG,"RI_CONFIG_REG"); break; - case 0x04700008: MoveConstToVariable(Value,&g_Reg->RI_CURRENT_LOAD_REG,"RI_CURRENT_LOAD_REG"); break; - case 0x0470000C: MoveConstToVariable(Value,&g_Reg->RI_SELECT_REG,"RI_SELECT_REG"); break; - default: - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).ToUTF16().c_str()); - } - } - break; - case 0x04800000: - switch (PAddr) - { - case 0x04800000: MoveConstToVariable(Value,&g_Reg->SI_DRAM_ADDR_REG,"SI_DRAM_ADDR_REG"); break; - case 0x04800004: - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); - UpdateCounters(m_RegWorkingSet,false, true); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); - MoveConstToVariable(Value,&g_Reg->SI_PIF_ADDR_RD64B_REG,"SI_PIF_ADDR_RD64B_REG"); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)((CPifRam *)this),x86_ECX); - Call_Direct(AddressOf(&CPifRam::SI_DMA_READ),"CPifRam::SI_DMA_READ"); - AfterCallDirect(m_RegWorkingSet); - break; - case 0x04800010: - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); - UpdateCounters(m_RegWorkingSet,false, true); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); - MoveConstToVariable(Value,&g_Reg->SI_PIF_ADDR_WR64B_REG,"SI_PIF_ADDR_WR64B_REG"); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)((CPifRam *)this),x86_ECX); - Call_Direct(AddressOf(&CPifRam::SI_DMA_WRITE),"CPifRam::SI_DMA_WRITE"); - AfterCallDirect(m_RegWorkingSet); - break; - case 0x04800018: - AndConstToVariable((DWORD)~MI_INTR_SI,&g_Reg->MI_INTR_REG,"MI_INTR_REG"); - AndConstToVariable((DWORD)~SI_STATUS_INTERRUPT,&g_Reg->SI_STATUS_REG,"SI_STATUS_REG"); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_Reg,x86_ECX); - Call_Direct(AddressOf(&CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - AfterCallDirect(m_RegWorkingSet); - break; - default: - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).ToUTF16().c_str()); - } - } - break; - case 0x1fc00000: - { - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount()-g_System->CountPerOp()); - UpdateCounters(m_RegWorkingSet,false,true); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount()+g_System->CountPerOp()); + ModValue = 0; + if ((Value & MI_INTR_MASK_SET_SP) != 0) + { + ModValue |= MI_INTR_MASK_SP; + } + if ((Value & MI_INTR_MASK_SET_SI) != 0) + { + ModValue |= MI_INTR_MASK_SI; + } + if ((Value & MI_INTR_MASK_SET_AI) != 0) + { + ModValue |= MI_INTR_MASK_AI; + } + if ((Value & MI_INTR_MASK_SET_VI) != 0) + { + ModValue |= MI_INTR_MASK_VI; + } + if ((Value & MI_INTR_MASK_SET_PI) != 0) + { + ModValue |= MI_INTR_MASK_PI; + } + if ((Value & MI_INTR_MASK_SET_DP) != 0) + { + ModValue |= MI_INTR_MASK_DP; + } + if (ModValue != 0) + { + OrConstToVariable(ModValue, &g_Reg->MI_INTR_MASK_REG, "MI_INTR_MASK_REG"); + } + } + break; + default: + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).ToUTF16().c_str()); + } + } + break; + case 0x04400000: + switch (PAddr) + { + case 0x04400000: + if (g_Plugins->Gfx()->ViStatusChanged != NULL) + { + CompConstToVariable(Value, &g_Reg->VI_STATUS_REG, "VI_STATUS_REG"); + JeLabel8("Continue", 0); + Jump = m_RecompPos - 1; + MoveConstToVariable(Value, &g_Reg->VI_STATUS_REG, "VI_STATUS_REG"); + BeforeCallDirect(m_RegWorkingSet); + Call_Direct(g_Plugins->Gfx()->ViStatusChanged, "ViStatusChanged"); + AfterCallDirect(m_RegWorkingSet); + CPU_Message(""); + CPU_Message(" Continue:"); + SetJump8(Jump, m_RecompPos); + } + break; + case 0x04400004: MoveConstToVariable((Value & 0xFFFFFF), &g_Reg->VI_ORIGIN_REG, "VI_ORIGIN_REG"); break; + case 0x04400008: + if (g_Plugins->Gfx()->ViWidthChanged != NULL) + { + CompConstToVariable(Value, &g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG"); + JeLabel8("Continue", 0); + Jump = m_RecompPos - 1; + MoveConstToVariable(Value, &g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG"); + BeforeCallDirect(m_RegWorkingSet); + Call_Direct(g_Plugins->Gfx()->ViWidthChanged, "ViWidthChanged"); + AfterCallDirect(m_RegWorkingSet); + CPU_Message(""); + CPU_Message(" Continue:"); + SetJump8(Jump, m_RecompPos); + } + break; + case 0x0440000C: MoveConstToVariable(Value, &g_Reg->VI_INTR_REG, "VI_INTR_REG"); break; + case 0x04400010: + AndConstToVariable((uint32_t)~MI_INTR_VI, &g_Reg->MI_INTR_REG, "MI_INTR_REG"); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); + Call_Direct(AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts"); + AfterCallDirect(m_RegWorkingSet); + break; + case 0x04400014: MoveConstToVariable(Value, &g_Reg->VI_BURST_REG, "VI_BURST_REG"); break; + case 0x04400018: MoveConstToVariable(Value, &g_Reg->VI_V_SYNC_REG, "VI_V_SYNC_REG"); break; + case 0x0440001C: MoveConstToVariable(Value, &g_Reg->VI_H_SYNC_REG, "VI_H_SYNC_REG"); break; + case 0x04400020: MoveConstToVariable(Value, &g_Reg->VI_LEAP_REG, "VI_LEAP_REG"); break; + case 0x04400024: MoveConstToVariable(Value, &g_Reg->VI_H_START_REG, "VI_H_START_REG"); break; + case 0x04400028: MoveConstToVariable(Value, &g_Reg->VI_V_START_REG, "VI_V_START_REG"); break; + case 0x0440002C: MoveConstToVariable(Value, &g_Reg->VI_V_BURST_REG, "VI_V_BURST_REG"); break; + case 0x04400030: MoveConstToVariable(Value, &g_Reg->VI_X_SCALE_REG, "VI_X_SCALE_REG"); break; + case 0x04400034: MoveConstToVariable(Value, &g_Reg->VI_Y_SCALE_REG, "VI_Y_SCALE_REG"); break; + default: + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).ToUTF16().c_str()); + } + } + break; + case 0x04500000: /* AI registers */ + switch (PAddr) + { + case 0x04500000: MoveConstToVariable(Value, &g_Reg->AI_DRAM_ADDR_REG, "AI_DRAM_ADDR_REG"); break; + case 0x04500004: + MoveConstToVariable(Value, &g_Reg->AI_LEN_REG, "AI_LEN_REG"); + BeforeCallDirect(m_RegWorkingSet); + if (g_System->bFixedAudio()) + { + X86BreakPoint(__FILEW__, __LINE__); + MoveConstToX86reg((uint32_t)g_Audio, x86_ECX); + Call_Direct(AddressOf(&CAudio::LenChanged), "LenChanged"); + } + else + { + Call_Direct(g_Plugins->Audio()->AiLenChanged, "AiLenChanged"); + } + AfterCallDirect(m_RegWorkingSet); + break; + case 0x04500008: MoveConstToVariable((Value & 1), &g_Reg->AI_CONTROL_REG, "AI_CONTROL_REG"); break; + case 0x0450000C: + /* Clear Interrupt */; + AndConstToVariable((uint32_t)~MI_INTR_AI, &g_Reg->MI_INTR_REG, "MI_INTR_REG"); + AndConstToVariable((uint32_t)~MI_INTR_AI, &g_Reg->m_AudioIntrReg, "m_AudioIntrReg"); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); + Call_Direct(AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts"); + AfterCallDirect(m_RegWorkingSet); + break; + case 0x04500010: + sprintf(VarName, "m_RDRAM + %X", PAddr); + MoveConstToVariable(Value, PAddr + m_RDRAM, VarName); + break; + case 0x04500014: MoveConstToVariable(Value, &g_Reg->AI_BITRATE_REG, "AI_BITRATE_REG"); break; + default: + sprintf(VarName, "m_RDRAM + %X", PAddr); + MoveConstToVariable(Value, PAddr + m_RDRAM, VarName); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).ToUTF16().c_str()); + } + } + break; + case 0x04600000: + switch (PAddr) + { + case 0x04600000: MoveConstToVariable(Value, &g_Reg->PI_DRAM_ADDR_REG, "PI_DRAM_ADDR_REG"); break; + case 0x04600004: MoveConstToVariable(Value, &g_Reg->PI_CART_ADDR_REG, "PI_CART_ADDR_REG"); break; + case 0x04600008: + MoveConstToVariable(Value, &g_Reg->PI_RD_LEN_REG, "PI_RD_LEN_REG"); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((ULONG)((CDMA *)this), x86_ECX); + Call_Direct(AddressOf(&CDMA::PI_DMA_READ), "CDMA::PI_DMA_READ"); + AfterCallDirect(m_RegWorkingSet); + break; + case 0x0460000C: + MoveConstToVariable(Value, &g_Reg->PI_WR_LEN_REG, "PI_WR_LEN_REG"); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((ULONG)((CDMA *)this), x86_ECX); + Call_Direct(AddressOf(&CDMA::PI_DMA_WRITE), "CDMA::PI_DMA_WRITE"); + AfterCallDirect(m_RegWorkingSet); + break; + case 0x04600010: + if ((Value & PI_CLR_INTR) != 0) + { + AndConstToVariable((uint32_t)~MI_INTR_PI, &g_Reg->MI_INTR_REG, "MI_INTR_REG"); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); + Call_Direct(AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts"); + AfterCallDirect(m_RegWorkingSet); + } + break; + case 0x04600014: MoveConstToVariable((Value & 0xFF), &g_Reg->PI_DOMAIN1_REG, "PI_DOMAIN1_REG"); break; + case 0x04600018: MoveConstToVariable((Value & 0xFF), &g_Reg->PI_BSD_DOM1_PWD_REG, "PI_BSD_DOM1_PWD_REG"); break; + case 0x0460001C: MoveConstToVariable((Value & 0xFF), &g_Reg->PI_BSD_DOM1_PGS_REG, "PI_BSD_DOM1_PGS_REG"); break; + case 0x04600020: MoveConstToVariable((Value & 0xFF), &g_Reg->PI_BSD_DOM1_RLS_REG, "PI_BSD_DOM1_RLS_REG"); break; + default: + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).ToUTF16().c_str()); + } + } + break; + case 0x04700000: + switch (PAddr) + { + case 0x04700000: MoveConstToVariable(Value, &g_Reg->RI_MODE_REG, "RI_MODE_REG"); break; + case 0x04700004: MoveConstToVariable(Value, &g_Reg->RI_CONFIG_REG, "RI_CONFIG_REG"); break; + case 0x04700008: MoveConstToVariable(Value, &g_Reg->RI_CURRENT_LOAD_REG, "RI_CURRENT_LOAD_REG"); break; + case 0x0470000C: MoveConstToVariable(Value, &g_Reg->RI_SELECT_REG, "RI_SELECT_REG"); break; + default: + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).ToUTF16().c_str()); + } + } + break; + case 0x04800000: + switch (PAddr) + { + case 0x04800000: MoveConstToVariable(Value, &g_Reg->SI_DRAM_ADDR_REG, "SI_DRAM_ADDR_REG"); break; + case 0x04800004: + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); + UpdateCounters(m_RegWorkingSet, false, true); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); + MoveConstToVariable(Value, &g_Reg->SI_PIF_ADDR_RD64B_REG, "SI_PIF_ADDR_RD64B_REG"); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)((CPifRam *)this), x86_ECX); + Call_Direct(AddressOf(&CPifRam::SI_DMA_READ), "CPifRam::SI_DMA_READ"); + AfterCallDirect(m_RegWorkingSet); + break; + case 0x04800010: + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); + UpdateCounters(m_RegWorkingSet, false, true); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); + MoveConstToVariable(Value, &g_Reg->SI_PIF_ADDR_WR64B_REG, "SI_PIF_ADDR_WR64B_REG"); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)((CPifRam *)this), x86_ECX); + Call_Direct(AddressOf(&CPifRam::SI_DMA_WRITE), "CPifRam::SI_DMA_WRITE"); + AfterCallDirect(m_RegWorkingSet); + break; + case 0x04800018: + AndConstToVariable((uint32_t)~MI_INTR_SI, &g_Reg->MI_INTR_REG, "MI_INTR_REG"); + AndConstToVariable((uint32_t)~SI_STATUS_INTERRUPT, &g_Reg->SI_STATUS_REG, "SI_STATUS_REG"); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); + Call_Direct(AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts"); + AfterCallDirect(m_RegWorkingSet); + break; + default: + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).ToUTF16().c_str()); + } + } + break; + case 0x1fc00000: + { + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); + UpdateCounters(m_RegWorkingSet, false, true); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); - BeforeCallDirect(m_RegWorkingSet); - PushImm32(Value); - PushImm32(PAddr); - MoveConstToX86reg((ULONG)((CMipsMemoryVM *)this),x86_ECX); - Call_Direct(AddressOf(&CMipsMemoryVM::SW_NonMemory),"CMipsMemoryVM::SW_NonMemory"); - AfterCallDirect(m_RegWorkingSet); - } - break; - default: - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).ToUTF16().c_str()); - } - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount()-g_System->CountPerOp()); - UpdateCounters(m_RegWorkingSet,false,true); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount()+g_System->CountPerOp()); + BeforeCallDirect(m_RegWorkingSet); + PushImm32(Value); + PushImm32(PAddr); + MoveConstToX86reg((ULONG)((CMipsMemoryVM *)this), x86_ECX); + Call_Direct(AddressOf(&CMipsMemoryVM::SW_NonMemory), "CMipsMemoryVM::SW_NonMemory"); + AfterCallDirect(m_RegWorkingSet); + } + break; + default: + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store %08X in %08X?", Value, VAddr).ToUTF16().c_str()); + } + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); + UpdateCounters(m_RegWorkingSet, false, true); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); - BeforeCallDirect(m_RegWorkingSet); - PushImm32(Value); - PushImm32(PAddr); - MoveConstToX86reg((ULONG)((CMipsMemoryVM *)this),x86_ECX); - Call_Direct(AddressOf(&CMipsMemoryVM::SW_NonMemory),"CMipsMemoryVM::SW_NonMemory"); - AfterCallDirect(m_RegWorkingSet); - } + BeforeCallDirect(m_RegWorkingSet); + PushImm32(Value); + PushImm32(PAddr); + MoveConstToX86reg((ULONG)((CMipsMemoryVM *)this), x86_ECX); + Call_Direct(AddressOf(&CMipsMemoryVM::SW_NonMemory), "CMipsMemoryVM::SW_NonMemory"); + AfterCallDirect(m_RegWorkingSet); + } } -void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr ) +void CMipsMemoryVM::Compile_SW_Register(x86Reg Reg, uint32_t VAddr) { - if (VAddr < 0x80000000 || VAddr >= 0xC0000000) - { - m_RegWorkingSet.SetX86Protected(Reg,true); + if (VAddr < 0x80000000 || VAddr >= 0xC0000000) + { + m_RegWorkingSet.SetX86Protected(Reg, true); - x86Reg TempReg1 = Map_TempReg(x86_Any, -1, false); - x86Reg TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveConstToX86reg(VAddr, TempReg1); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_WriteMap,"m_TLB_WriteMap",TempReg2,TempReg2,4); - CompileWriteTLBMiss(TempReg1,TempReg2); - MoveX86regToX86regPointer(Reg,TempReg1, TempReg2); - return; - } + x86Reg TempReg1 = Map_TempReg(x86_Any, -1, false); + x86Reg TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveConstToX86reg(VAddr, TempReg1); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_WriteMap, "m_TLB_WriteMap", TempReg2, TempReg2, 4); + CompileWriteTLBMiss(TempReg1, TempReg2); + MoveX86regToX86regPointer(Reg, TempReg1, TempReg2); + return; + } - char VarName[100]; - BYTE * Jump; - DWORD PAddr; + char VarName[100]; + uint8_t * Jump; + uint32_t PAddr; - if (!TranslateVaddr(VAddr, PAddr)) - { - CPU_Message("Compile_SW_Register\nFailed to translate address: %08X",VAddr); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).ToUTF16().c_str()); - } - return; - } + if (!TranslateVaddr(VAddr, PAddr)) + { + CPU_Message("Compile_SW_Register\nFailed to translate address: %08X", VAddr); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nFailed to translate address: %08X", VAddr).ToUTF16().c_str()); + } + return; + } - switch (PAddr & 0xFFF00000) - { - case 0x00000000: - case 0x00100000: - case 0x00200000: - case 0x00300000: - case 0x00400000: - case 0x00500000: - case 0x00600000: - case 0x00700000: - sprintf(VarName,"m_RDRAM + %X",PAddr); - MoveX86regToVariable(Reg,PAddr + m_RDRAM,VarName); - break; - case 0x04000000: - switch (PAddr) - { - case 0x04040000: MoveX86regToVariable(Reg,&g_Reg->SP_MEM_ADDR_REG,"SP_MEM_ADDR_REG"); break; - case 0x04040004: MoveX86regToVariable(Reg,&g_Reg->SP_DRAM_ADDR_REG,"SP_DRAM_ADDR_REG"); break; - case 0x04040008: - MoveX86regToVariable(Reg,&g_Reg->SP_RD_LEN_REG,"SP_RD_LEN_REG"); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((ULONG)((CDMA *)this),x86_ECX); - Call_Direct(AddressOf(&CDMA::SP_DMA_READ),"CDMA::SP_DMA_READ"); - AfterCallDirect(m_RegWorkingSet); - break; - case 0x0404000C: - MoveX86regToVariable(Reg,&g_Reg->SP_WR_LEN_REG,"SP_WR_LEN_REG"); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((ULONG)((CDMA *)this),x86_ECX); - Call_Direct(AddressOf(&CDMA::SP_DMA_WRITE),"CDMA::SP_DMA_WRITE"); - AfterCallDirect(m_RegWorkingSet); - break; - case 0x04040010: - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); - UpdateCounters(m_RegWorkingSet,false, true); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); - MoveX86regToVariable(Reg,&RegModValue,"RegModValue"); - BeforeCallDirect(m_RegWorkingSet); - Call_Direct(ChangeSpStatus,"ChangeSpStatus"); - AfterCallDirect(m_RegWorkingSet); - break; - case 0x0404001C: MoveConstToVariable(0,&g_Reg->SP_SEMAPHORE_REG,"SP_SEMAPHORE_REG"); break; - case 0x04080000: - MoveX86regToVariable(Reg,&g_Reg->SP_PC_REG,"SP_PC_REG"); - AndConstToVariable(0xFFC,&g_Reg->SP_PC_REG,"SP_PC_REG"); - break; - default: - if (PAddr < 0x04002000) - { - sprintf(VarName,"m_RDRAM + %X",PAddr); - MoveX86regToVariable(Reg,PAddr + m_RDRAM,VarName); - } - else - { - CPU_Message(" Should be moving %s in to %08X ?!?",x86_Name(Reg),VAddr); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).ToUTF16().c_str()); - } - } - } - break; - case 0x04100000: - if (PAddr == 0x0410000C) - { - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount()-g_System->CountPerOp()); - UpdateCounters(m_RegWorkingSet,false,true); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount()+g_System->CountPerOp()); - } - BeforeCallDirect(m_RegWorkingSet); - Push(Reg); - PushImm32(PAddr); - MoveConstToX86reg((ULONG)((CMipsMemoryVM *)this),x86_ECX); - Call_Direct(AddressOf(&CMipsMemoryVM::SW_NonMemory),"CMipsMemoryVM::SW_NonMemory"); - AfterCallDirect(m_RegWorkingSet); - break; - case 0x04300000: - switch (PAddr) - { - case 0x04300000: - MoveX86regToVariable(Reg,&RegModValue,"RegModValue"); - BeforeCallDirect(m_RegWorkingSet); - Call_Direct(ChangeMiIntrMask,"ChangeMiModeReg"); - AfterCallDirect(m_RegWorkingSet); - break; - case 0x0430000C: - MoveX86regToVariable(Reg,&RegModValue,"RegModValue"); - BeforeCallDirect(m_RegWorkingSet); - Call_Direct(ChangeMiIntrMask,"ChangeMiIntrMask"); - AfterCallDirect(m_RegWorkingSet); - break; - default: - CPU_Message(" Should be moving %s in to %08X ?!?",x86_Name(Reg),VAddr); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).ToUTF16().c_str()); - } - } - break; - case 0x04400000: - switch (PAddr) { - case 0x04400000: - if (g_Plugins->Gfx()->ViStatusChanged != NULL) - { - CompX86regToVariable(Reg,&g_Reg->VI_STATUS_REG,"VI_STATUS_REG"); - JeLabel8("Continue",0); - Jump = m_RecompPos - 1; - MoveX86regToVariable(Reg,&g_Reg->VI_STATUS_REG,"VI_STATUS_REG"); - BeforeCallDirect(m_RegWorkingSet); - Call_Direct(g_Plugins->Gfx()->ViStatusChanged,"ViStatusChanged"); - AfterCallDirect(m_RegWorkingSet); - CPU_Message(""); - CPU_Message(" Continue:"); - SetJump8(Jump,m_RecompPos); - } - break; - case 0x04400004: - MoveX86regToVariable(Reg,&g_Reg->VI_ORIGIN_REG,"VI_ORIGIN_REG"); - AndConstToVariable(0xFFFFFF,&g_Reg->VI_ORIGIN_REG,"VI_ORIGIN_REG"); - break; - case 0x04400008: - if (g_Plugins->Gfx()->ViWidthChanged != NULL) - { - CompX86regToVariable(Reg,&g_Reg->VI_WIDTH_REG,"VI_WIDTH_REG"); - JeLabel8("Continue",0); - Jump = m_RecompPos - 1; - MoveX86regToVariable(Reg,&g_Reg->VI_WIDTH_REG,"VI_WIDTH_REG"); - BeforeCallDirect(m_RegWorkingSet); - Call_Direct(g_Plugins->Gfx()->ViWidthChanged,"ViWidthChanged"); - AfterCallDirect(m_RegWorkingSet); - CPU_Message(""); - CPU_Message(" Continue:"); - SetJump8(Jump,m_RecompPos); - } - break; - case 0x0440000C: MoveX86regToVariable(Reg,&g_Reg->VI_INTR_REG,"VI_INTR_REG"); break; - case 0x04400010: - AndConstToVariable((DWORD)~MI_INTR_VI,&g_Reg->MI_INTR_REG,"MI_INTR_REG"); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_Reg,x86_ECX); - Call_Direct(AddressOf(&CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - AfterCallDirect(m_RegWorkingSet); - break; - case 0x04400014: MoveX86regToVariable(Reg,&g_Reg->VI_BURST_REG,"VI_BURST_REG"); break; - case 0x04400018: MoveX86regToVariable(Reg,&g_Reg->VI_V_SYNC_REG,"VI_V_SYNC_REG"); break; - case 0x0440001C: MoveX86regToVariable(Reg,&g_Reg->VI_H_SYNC_REG,"VI_H_SYNC_REG"); break; - case 0x04400020: MoveX86regToVariable(Reg,&g_Reg->VI_LEAP_REG,"VI_LEAP_REG"); break; - case 0x04400024: MoveX86regToVariable(Reg,&g_Reg->VI_H_START_REG,"VI_H_START_REG"); break; - case 0x04400028: MoveX86regToVariable(Reg,&g_Reg->VI_V_START_REG,"VI_V_START_REG"); break; - case 0x0440002C: MoveX86regToVariable(Reg,&g_Reg->VI_V_BURST_REG,"VI_V_BURST_REG"); break; - case 0x04400030: MoveX86regToVariable(Reg,&g_Reg->VI_X_SCALE_REG,"VI_X_SCALE_REG"); break; - case 0x04400034: MoveX86regToVariable(Reg,&g_Reg->VI_Y_SCALE_REG,"VI_Y_SCALE_REG"); break; - default: - CPU_Message(" Should be moving %s in to %08X ?!?",x86_Name(Reg),VAddr); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).ToUTF16().c_str()); - } - } - break; - case 0x04500000: /* AI registers */ - switch (PAddr) { - case 0x04500000: MoveX86regToVariable(Reg,&g_Reg->AI_DRAM_ADDR_REG,"AI_DRAM_ADDR_REG"); break; - case 0x04500004: - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); - UpdateCounters(m_RegWorkingSet,false, true); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); - MoveX86regToVariable(Reg,&g_Reg->AI_LEN_REG,"AI_LEN_REG"); - BeforeCallDirect(m_RegWorkingSet); - if (g_System->bFixedAudio()) - { - MoveConstToX86reg((DWORD)g_Audio,x86_ECX); - Call_Direct(AddressOf(&CAudio::LenChanged),"LenChanged"); - } - else - { - Call_Direct(g_Plugins->Audio()->AiLenChanged, "g_Plugins->Audio()->LenChanged"); - } - AfterCallDirect(m_RegWorkingSet); - break; - case 0x04500008: - MoveX86regToVariable(Reg,&g_Reg->AI_CONTROL_REG,"AI_CONTROL_REG"); - AndConstToVariable(1,&g_Reg->AI_CONTROL_REG,"AI_CONTROL_REG"); - case 0x0450000C: - /* Clear Interrupt */; - AndConstToVariable((DWORD)~MI_INTR_AI,&g_Reg->MI_INTR_REG,"MI_INTR_REG"); - AndConstToVariable((DWORD)~MI_INTR_AI,&g_Reg->m_AudioIntrReg,"m_AudioIntrReg"); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_Reg,x86_ECX); - Call_Direct(AddressOf(&CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - AfterCallDirect(m_RegWorkingSet); - break; - case 0x04500010: - sprintf(VarName,"m_RDRAM + %X",PAddr); - MoveX86regToVariable(Reg,PAddr + m_RDRAM,VarName); - break; - case 0x04500014: MoveX86regToVariable(Reg,&g_Reg->AI_BITRATE_REG,"AI_BITRATE_REG"); break; - default: - sprintf(VarName,"m_RDRAM + %X",PAddr); - MoveX86regToVariable(Reg,PAddr + m_RDRAM,VarName); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).ToUTF16().c_str()); - } - } - break; - case 0x04600000: - switch (PAddr) - { - case 0x04600000: MoveX86regToVariable(Reg,&g_Reg->PI_DRAM_ADDR_REG,"PI_DRAM_ADDR_REG"); break; - case 0x04600004: MoveX86regToVariable(Reg,&g_Reg->PI_CART_ADDR_REG,"PI_CART_ADDR_REG"); break; - case 0x04600008: - MoveX86regToVariable(Reg,&g_Reg->PI_RD_LEN_REG,"PI_RD_LEN_REG"); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((ULONG)((CDMA *)this),x86_ECX); - Call_Direct(AddressOf(&CDMA::PI_DMA_READ),"CDMA::PI_DMA_READ"); - AfterCallDirect(m_RegWorkingSet); - break; - case 0x0460000C: - MoveX86regToVariable(Reg,&g_Reg->PI_WR_LEN_REG,"PI_WR_LEN_REG"); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((ULONG)((CDMA *)this),x86_ECX); - Call_Direct(AddressOf(&CDMA::PI_DMA_WRITE),"CDMA::PI_DMA_WRITE"); - AfterCallDirect(m_RegWorkingSet); - break; - case 0x04600010: - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).ToUTF16().c_str()); - } - AndConstToVariable((DWORD)~MI_INTR_PI,&g_Reg->MI_INTR_REG,"MI_INTR_REG"); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_Reg,x86_ECX); - Call_Direct(AddressOf(&CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - AfterCallDirect(m_RegWorkingSet); - break; - case 0x04600014: - MoveX86regToVariable(Reg,&g_Reg->PI_DOMAIN1_REG,"PI_DOMAIN1_REG"); - AndConstToVariable(0xFF,&g_Reg->PI_DOMAIN1_REG,"PI_DOMAIN1_REG"); - break; - case 0x04600018: - MoveX86regToVariable(Reg,&g_Reg->PI_BSD_DOM1_PWD_REG,"PI_BSD_DOM1_PWD_REG"); - AndConstToVariable(0xFF,&g_Reg->PI_BSD_DOM1_PWD_REG,"PI_BSD_DOM1_PWD_REG"); - break; - case 0x0460001C: - MoveX86regToVariable(Reg,&g_Reg->PI_BSD_DOM1_PGS_REG,"PI_BSD_DOM1_PGS_REG"); - AndConstToVariable(0xFF,&g_Reg->PI_BSD_DOM1_PGS_REG,"PI_BSD_DOM1_PGS_REG"); - break; - case 0x04600020: - MoveX86regToVariable(Reg,&g_Reg->PI_BSD_DOM1_RLS_REG,"PI_BSD_DOM1_RLS_REG"); - AndConstToVariable(0xFF,&g_Reg->PI_BSD_DOM1_RLS_REG,"PI_BSD_DOM1_RLS_REG"); - break; - default: - CPU_Message(" Should be moving %s in to %08X ?!?",x86_Name(Reg),VAddr); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).ToUTF16().c_str()); - } - } - break; - case 0x04700000: - switch (PAddr) - { - case 0x04700010: MoveX86regToVariable(Reg,&g_Reg->RI_REFRESH_REG,"RI_REFRESH_REG"); break; - default: - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).ToUTF16().c_str()); - } - } - break; - case 0x04800000: - switch (PAddr) - { - case 0x04800000: MoveX86regToVariable(Reg,&g_Reg->SI_DRAM_ADDR_REG,"SI_DRAM_ADDR_REG"); break; - case 0x04800004: - MoveX86regToVariable(Reg,&g_Reg->SI_PIF_ADDR_RD64B_REG,"SI_PIF_ADDR_RD64B_REG"); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)((CPifRam *)this),x86_ECX); - Call_Direct(AddressOf(&CPifRam::SI_DMA_READ),"CPifRam::SI_DMA_READ"); - AfterCallDirect(m_RegWorkingSet); - break; - case 0x04800010: - MoveX86regToVariable(Reg,&g_Reg->SI_PIF_ADDR_WR64B_REG,"SI_PIF_ADDR_WR64B_REG"); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)((CPifRam *)this),x86_ECX); - Call_Direct(AddressOf(&CPifRam::SI_DMA_WRITE),"CPifRam::SI_DMA_WRITE"); - AfterCallDirect(m_RegWorkingSet); - break; - case 0x04800018: - AndConstToVariable((DWORD)~MI_INTR_SI,&g_Reg->MI_INTR_REG,"MI_INTR_REG"); - AndConstToVariable((DWORD)~SI_STATUS_INTERRUPT,&g_Reg->SI_STATUS_REG,"SI_STATUS_REG"); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_Reg,x86_ECX); - Call_Direct(AddressOf(&CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - AfterCallDirect(m_RegWorkingSet); - break; - default: - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).ToUTF16().c_str()); - } - } - break; - case 0x1FC00000: - sprintf(VarName,"m_RDRAM + %X",PAddr); - MoveX86regToVariable(Reg,PAddr + m_RDRAM,VarName); - break; - default: - CPU_Message(" Should be moving %s in to %08X ?!?",x86_Name(Reg),VAddr); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).ToUTF16().c_str()); - } - } + switch (PAddr & 0xFFF00000) + { + case 0x00000000: + case 0x00100000: + case 0x00200000: + case 0x00300000: + case 0x00400000: + case 0x00500000: + case 0x00600000: + case 0x00700000: + sprintf(VarName, "m_RDRAM + %X", PAddr); + MoveX86regToVariable(Reg, PAddr + m_RDRAM, VarName); + break; + case 0x04000000: + switch (PAddr) + { + case 0x04040000: MoveX86regToVariable(Reg, &g_Reg->SP_MEM_ADDR_REG, "SP_MEM_ADDR_REG"); break; + case 0x04040004: MoveX86regToVariable(Reg, &g_Reg->SP_DRAM_ADDR_REG, "SP_DRAM_ADDR_REG"); break; + case 0x04040008: + MoveX86regToVariable(Reg, &g_Reg->SP_RD_LEN_REG, "SP_RD_LEN_REG"); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((ULONG)((CDMA *)this), x86_ECX); + Call_Direct(AddressOf(&CDMA::SP_DMA_READ), "CDMA::SP_DMA_READ"); + AfterCallDirect(m_RegWorkingSet); + break; + case 0x0404000C: + MoveX86regToVariable(Reg, &g_Reg->SP_WR_LEN_REG, "SP_WR_LEN_REG"); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((ULONG)((CDMA *)this), x86_ECX); + Call_Direct(AddressOf(&CDMA::SP_DMA_WRITE), "CDMA::SP_DMA_WRITE"); + AfterCallDirect(m_RegWorkingSet); + break; + case 0x04040010: + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); + UpdateCounters(m_RegWorkingSet, false, true); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); + MoveX86regToVariable(Reg, &RegModValue, "RegModValue"); + BeforeCallDirect(m_RegWorkingSet); + Call_Direct(ChangeSpStatus, "ChangeSpStatus"); + AfterCallDirect(m_RegWorkingSet); + break; + case 0x0404001C: MoveConstToVariable(0, &g_Reg->SP_SEMAPHORE_REG, "SP_SEMAPHORE_REG"); break; + case 0x04080000: + MoveX86regToVariable(Reg, &g_Reg->SP_PC_REG, "SP_PC_REG"); + AndConstToVariable(0xFFC, &g_Reg->SP_PC_REG, "SP_PC_REG"); + break; + default: + if (PAddr < 0x04002000) + { + sprintf(VarName, "m_RDRAM + %X", PAddr); + MoveX86regToVariable(Reg, PAddr + m_RDRAM, VarName); + } + else + { + CPU_Message(" Should be moving %s in to %08X ?!?", x86_Name(Reg), VAddr); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).ToUTF16().c_str()); + } + } + } + break; + case 0x04100000: + if (PAddr == 0x0410000C) + { + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); + UpdateCounters(m_RegWorkingSet, false, true); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); + } + BeforeCallDirect(m_RegWorkingSet); + Push(Reg); + PushImm32(PAddr); + MoveConstToX86reg((ULONG)((CMipsMemoryVM *)this), x86_ECX); + Call_Direct(AddressOf(&CMipsMemoryVM::SW_NonMemory), "CMipsMemoryVM::SW_NonMemory"); + AfterCallDirect(m_RegWorkingSet); + break; + case 0x04300000: + switch (PAddr) + { + case 0x04300000: + MoveX86regToVariable(Reg, &RegModValue, "RegModValue"); + BeforeCallDirect(m_RegWorkingSet); + Call_Direct(ChangeMiIntrMask, "ChangeMiModeReg"); + AfterCallDirect(m_RegWorkingSet); + break; + case 0x0430000C: + MoveX86regToVariable(Reg, &RegModValue, "RegModValue"); + BeforeCallDirect(m_RegWorkingSet); + Call_Direct(ChangeMiIntrMask, "ChangeMiIntrMask"); + AfterCallDirect(m_RegWorkingSet); + break; + default: + CPU_Message(" Should be moving %s in to %08X ?!?", x86_Name(Reg), VAddr); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).ToUTF16().c_str()); + } + } + break; + case 0x04400000: + switch (PAddr) { + case 0x04400000: + if (g_Plugins->Gfx()->ViStatusChanged != NULL) + { + CompX86regToVariable(Reg, &g_Reg->VI_STATUS_REG, "VI_STATUS_REG"); + JeLabel8("Continue", 0); + Jump = m_RecompPos - 1; + MoveX86regToVariable(Reg, &g_Reg->VI_STATUS_REG, "VI_STATUS_REG"); + BeforeCallDirect(m_RegWorkingSet); + Call_Direct(g_Plugins->Gfx()->ViStatusChanged, "ViStatusChanged"); + AfterCallDirect(m_RegWorkingSet); + CPU_Message(""); + CPU_Message(" Continue:"); + SetJump8(Jump, m_RecompPos); + } + break; + case 0x04400004: + MoveX86regToVariable(Reg, &g_Reg->VI_ORIGIN_REG, "VI_ORIGIN_REG"); + AndConstToVariable(0xFFFFFF, &g_Reg->VI_ORIGIN_REG, "VI_ORIGIN_REG"); + break; + case 0x04400008: + if (g_Plugins->Gfx()->ViWidthChanged != NULL) + { + CompX86regToVariable(Reg, &g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG"); + JeLabel8("Continue", 0); + Jump = m_RecompPos - 1; + MoveX86regToVariable(Reg, &g_Reg->VI_WIDTH_REG, "VI_WIDTH_REG"); + BeforeCallDirect(m_RegWorkingSet); + Call_Direct(g_Plugins->Gfx()->ViWidthChanged, "ViWidthChanged"); + AfterCallDirect(m_RegWorkingSet); + CPU_Message(""); + CPU_Message(" Continue:"); + SetJump8(Jump, m_RecompPos); + } + break; + case 0x0440000C: MoveX86regToVariable(Reg, &g_Reg->VI_INTR_REG, "VI_INTR_REG"); break; + case 0x04400010: + AndConstToVariable((uint32_t)~MI_INTR_VI, &g_Reg->MI_INTR_REG, "MI_INTR_REG"); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); + Call_Direct(AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts"); + AfterCallDirect(m_RegWorkingSet); + break; + case 0x04400014: MoveX86regToVariable(Reg, &g_Reg->VI_BURST_REG, "VI_BURST_REG"); break; + case 0x04400018: MoveX86regToVariable(Reg, &g_Reg->VI_V_SYNC_REG, "VI_V_SYNC_REG"); break; + case 0x0440001C: MoveX86regToVariable(Reg, &g_Reg->VI_H_SYNC_REG, "VI_H_SYNC_REG"); break; + case 0x04400020: MoveX86regToVariable(Reg, &g_Reg->VI_LEAP_REG, "VI_LEAP_REG"); break; + case 0x04400024: MoveX86regToVariable(Reg, &g_Reg->VI_H_START_REG, "VI_H_START_REG"); break; + case 0x04400028: MoveX86regToVariable(Reg, &g_Reg->VI_V_START_REG, "VI_V_START_REG"); break; + case 0x0440002C: MoveX86regToVariable(Reg, &g_Reg->VI_V_BURST_REG, "VI_V_BURST_REG"); break; + case 0x04400030: MoveX86regToVariable(Reg, &g_Reg->VI_X_SCALE_REG, "VI_X_SCALE_REG"); break; + case 0x04400034: MoveX86regToVariable(Reg, &g_Reg->VI_Y_SCALE_REG, "VI_Y_SCALE_REG"); break; + default: + CPU_Message(" Should be moving %s in to %08X ?!?", x86_Name(Reg), VAddr); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).ToUTF16().c_str()); + } + } + break; + case 0x04500000: /* AI registers */ + switch (PAddr) { + case 0x04500000: MoveX86regToVariable(Reg, &g_Reg->AI_DRAM_ADDR_REG, "AI_DRAM_ADDR_REG"); break; + case 0x04500004: + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); + UpdateCounters(m_RegWorkingSet, false, true); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); + MoveX86regToVariable(Reg, &g_Reg->AI_LEN_REG, "AI_LEN_REG"); + BeforeCallDirect(m_RegWorkingSet); + if (g_System->bFixedAudio()) + { + MoveConstToX86reg((uint32_t)g_Audio, x86_ECX); + Call_Direct(AddressOf(&CAudio::LenChanged), "LenChanged"); + } + else + { + Call_Direct(g_Plugins->Audio()->AiLenChanged, "g_Plugins->Audio()->LenChanged"); + } + AfterCallDirect(m_RegWorkingSet); + break; + case 0x04500008: + MoveX86regToVariable(Reg, &g_Reg->AI_CONTROL_REG, "AI_CONTROL_REG"); + AndConstToVariable(1, &g_Reg->AI_CONTROL_REG, "AI_CONTROL_REG"); + case 0x0450000C: + /* Clear Interrupt */; + AndConstToVariable((uint32_t)~MI_INTR_AI, &g_Reg->MI_INTR_REG, "MI_INTR_REG"); + AndConstToVariable((uint32_t)~MI_INTR_AI, &g_Reg->m_AudioIntrReg, "m_AudioIntrReg"); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); + Call_Direct(AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts"); + AfterCallDirect(m_RegWorkingSet); + break; + case 0x04500010: + sprintf(VarName, "m_RDRAM + %X", PAddr); + MoveX86regToVariable(Reg, PAddr + m_RDRAM, VarName); + break; + case 0x04500014: MoveX86regToVariable(Reg, &g_Reg->AI_BITRATE_REG, "AI_BITRATE_REG"); break; + default: + sprintf(VarName, "m_RDRAM + %X", PAddr); + MoveX86regToVariable(Reg, PAddr + m_RDRAM, VarName); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).ToUTF16().c_str()); + } + } + break; + case 0x04600000: + switch (PAddr) + { + case 0x04600000: MoveX86regToVariable(Reg, &g_Reg->PI_DRAM_ADDR_REG, "PI_DRAM_ADDR_REG"); break; + case 0x04600004: MoveX86regToVariable(Reg, &g_Reg->PI_CART_ADDR_REG, "PI_CART_ADDR_REG"); break; + case 0x04600008: + MoveX86regToVariable(Reg, &g_Reg->PI_RD_LEN_REG, "PI_RD_LEN_REG"); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((ULONG)((CDMA *)this), x86_ECX); + Call_Direct(AddressOf(&CDMA::PI_DMA_READ), "CDMA::PI_DMA_READ"); + AfterCallDirect(m_RegWorkingSet); + break; + case 0x0460000C: + MoveX86regToVariable(Reg, &g_Reg->PI_WR_LEN_REG, "PI_WR_LEN_REG"); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((ULONG)((CDMA *)this), x86_ECX); + Call_Direct(AddressOf(&CDMA::PI_DMA_WRITE), "CDMA::PI_DMA_WRITE"); + AfterCallDirect(m_RegWorkingSet); + break; + case 0x04600010: + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).ToUTF16().c_str()); + } + AndConstToVariable((uint32_t)~MI_INTR_PI, &g_Reg->MI_INTR_REG, "MI_INTR_REG"); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); + Call_Direct(AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts"); + AfterCallDirect(m_RegWorkingSet); + break; + case 0x04600014: + MoveX86regToVariable(Reg, &g_Reg->PI_DOMAIN1_REG, "PI_DOMAIN1_REG"); + AndConstToVariable(0xFF, &g_Reg->PI_DOMAIN1_REG, "PI_DOMAIN1_REG"); + break; + case 0x04600018: + MoveX86regToVariable(Reg, &g_Reg->PI_BSD_DOM1_PWD_REG, "PI_BSD_DOM1_PWD_REG"); + AndConstToVariable(0xFF, &g_Reg->PI_BSD_DOM1_PWD_REG, "PI_BSD_DOM1_PWD_REG"); + break; + case 0x0460001C: + MoveX86regToVariable(Reg, &g_Reg->PI_BSD_DOM1_PGS_REG, "PI_BSD_DOM1_PGS_REG"); + AndConstToVariable(0xFF, &g_Reg->PI_BSD_DOM1_PGS_REG, "PI_BSD_DOM1_PGS_REG"); + break; + case 0x04600020: + MoveX86regToVariable(Reg, &g_Reg->PI_BSD_DOM1_RLS_REG, "PI_BSD_DOM1_RLS_REG"); + AndConstToVariable(0xFF, &g_Reg->PI_BSD_DOM1_RLS_REG, "PI_BSD_DOM1_RLS_REG"); + break; + default: + CPU_Message(" Should be moving %s in to %08X ?!?", x86_Name(Reg), VAddr); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).ToUTF16().c_str()); + } + } + break; + case 0x04700000: + switch (PAddr) + { + case 0x04700010: MoveX86regToVariable(Reg, &g_Reg->RI_REFRESH_REG, "RI_REFRESH_REG"); break; + default: + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).ToUTF16().c_str()); + } + } + break; + case 0x04800000: + switch (PAddr) + { + case 0x04800000: MoveX86regToVariable(Reg, &g_Reg->SI_DRAM_ADDR_REG, "SI_DRAM_ADDR_REG"); break; + case 0x04800004: + MoveX86regToVariable(Reg, &g_Reg->SI_PIF_ADDR_RD64B_REG, "SI_PIF_ADDR_RD64B_REG"); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)((CPifRam *)this), x86_ECX); + Call_Direct(AddressOf(&CPifRam::SI_DMA_READ), "CPifRam::SI_DMA_READ"); + AfterCallDirect(m_RegWorkingSet); + break; + case 0x04800010: + MoveX86regToVariable(Reg, &g_Reg->SI_PIF_ADDR_WR64B_REG, "SI_PIF_ADDR_WR64B_REG"); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)((CPifRam *)this), x86_ECX); + Call_Direct(AddressOf(&CPifRam::SI_DMA_WRITE), "CPifRam::SI_DMA_WRITE"); + AfterCallDirect(m_RegWorkingSet); + break; + case 0x04800018: + AndConstToVariable((uint32_t)~MI_INTR_SI, &g_Reg->MI_INTR_REG, "MI_INTR_REG"); + AndConstToVariable((uint32_t)~SI_STATUS_INTERRUPT, &g_Reg->SI_STATUS_REG, "SI_STATUS_REG"); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); + Call_Direct(AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts"); + AfterCallDirect(m_RegWorkingSet); + break; + default: + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).ToUTF16().c_str()); + } + } + break; + case 0x1FC00000: + sprintf(VarName, "m_RDRAM + %X", PAddr); + MoveX86regToVariable(Reg, PAddr + m_RDRAM, VarName); + break; + default: + CPU_Message(" Should be moving %s in to %08X ?!?", x86_Name(Reg), VAddr); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\ntrying to store in %08X?", VAddr).ToUTF16().c_str()); + } + } } void CMipsMemoryVM::ResetMemoryStack() { - x86Reg Reg, TempReg; + x86Reg Reg, TempReg; - int MipsReg = 29; - CPU_Message(" ResetMemoryStack"); - Reg = Get_MemoryStack(); - if (Reg == x86_Unknown) - { - Reg = Map_TempReg(x86_Any, MipsReg, false); - } - else - { - if (IsUnknown(MipsReg)) - { - MoveVariableToX86reg(&_GPR[MipsReg].UW[0],CRegName::GPR_Lo[MipsReg],Reg); - } - else if (IsMapped(MipsReg)) - { - MoveX86RegToX86Reg(GetMipsRegMapLo(MipsReg),Reg); - } - else - { - MoveConstToX86reg(GetMipsRegLo(MipsReg),Reg); - } - } + int32_t MipsReg = 29; + CPU_Message(" ResetMemoryStack"); + Reg = Get_MemoryStack(); + if (Reg == x86_Unknown) + { + Reg = Map_TempReg(x86_Any, MipsReg, false); + } + else + { + if (IsUnknown(MipsReg)) + { + MoveVariableToX86reg(&_GPR[MipsReg].UW[0], CRegName::GPR_Lo[MipsReg], Reg); + } + else if (IsMapped(MipsReg)) + { + MoveX86RegToX86Reg(GetMipsRegMapLo(MipsReg), Reg); + } + else + { + MoveConstToX86reg(GetMipsRegLo(MipsReg), Reg); + } + } - if (g_System->bUseTlb()) - { - TempReg = Map_TempReg(x86_Any, -1, false); - MoveX86RegToX86Reg(Reg,TempReg); - ShiftRightUnsignImmed(TempReg,12); - MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg,TempReg,4); - AddX86RegToX86Reg(Reg,TempReg); - } - else - { - AndConstToX86Reg(Reg,0x1FFFFFFF); - AddConstToX86Reg(Reg,(DWORD)m_RDRAM); - } - MoveX86regToVariable(Reg,&(g_Recompiler->MemoryStackPos()), "MemoryStack"); + if (g_System->bUseTlb()) + { + TempReg = Map_TempReg(x86_Any, -1, false); + MoveX86RegToX86Reg(Reg, TempReg); + ShiftRightUnsignImmed(TempReg, 12); + MoveVariableDispToX86Reg(m_TLB_ReadMap, "m_TLB_ReadMap", TempReg, TempReg, 4); + AddX86RegToX86Reg(Reg, TempReg); + } + else + { + AndConstToX86Reg(Reg, 0x1FFFFFFF); + AddConstToX86Reg(Reg, (uint32_t)m_RDRAM); + } + MoveX86regToVariable(Reg, &(g_Recompiler->MemoryStackPos()), "MemoryStack"); } -int CMipsMemoryVM::MemoryFilter( DWORD dwExptCode, void * lpExceptionPointer ) +int32_t CMipsMemoryVM::MemoryFilter(uint32_t dwExptCode, void * lpExceptionPointer) { #if defined(_M_IX86) && defined(_WIN32) -// to do: Remove the _M_IX86 criteria. This can compile on 64-bit Windows. + // to do: Remove the _M_IX86 criteria. This can compile on 64-bit Windows. #ifndef _WIN64 - DWORD * Reg; -// We need this to fix 32-bit Windows builds, -// because Project64 currently uses DWORD all the time instead of int32_t. + DWORD * Reg; + // We need this to fix 32-bit Windows builds, + // because Project64 currently uses uint32_t all the time instead of int32_t. #else - size_t * Reg; + size_t * Reg; #endif - if (dwExptCode != EXCEPTION_ACCESS_VIOLATION) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - return EXCEPTION_EXECUTE_HANDLER; - } + if (dwExptCode != EXCEPTION_ACCESS_VIOLATION) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + return EXCEPTION_EXECUTE_HANDLER; + } - //convert the pointer since we are not having win32 structures in headers - LPEXCEPTION_POINTERS lpEP = (LPEXCEPTION_POINTERS)lpExceptionPointer; + //convert the pointer since we are not having win32 structures in headers + LPEXCEPTION_POINTERS lpEP = (LPEXCEPTION_POINTERS)lpExceptionPointer; - DWORD MemAddress = (char *)lpEP->ExceptionRecord->ExceptionInformation[1] - (char *)g_MMU->Rdram(); - if ((int)(MemAddress) < 0 || MemAddress > 0x1FFFFFFF) - { -// if (bHaveDebugger()) -// { -// g_Notify->BreakPoint(__FILEW__,__LINE__); -// } - return EXCEPTION_EXECUTE_HANDLER; - } - - BYTE * TypePos = (unsigned char *)lpEP->ContextRecord->Eip; - EXCEPTION_RECORD exRec = *lpEP->ExceptionRecord; + uint32_t MemAddress = (char *)lpEP->ExceptionRecord->ExceptionInformation[1] - (char *)g_MMU->Rdram(); + if ((int32_t)(MemAddress) < 0 || MemAddress > 0x1FFFFFFF) + { + // if (bHaveDebugger()) + // { + // g_Notify->BreakPoint(__FILEW__,__LINE__); + // } + return EXCEPTION_EXECUTE_HANDLER; + } - Reg = NULL; - if (*TypePos == 0xF3 && (*(TypePos + 1) == 0xA4 || *(TypePos + 1) == 0xA5)) - { - DWORD Start = (lpEP->ContextRecord->Edi - (DWORD)m_RDRAM); - DWORD End = Start + lpEP->ContextRecord->Ecx; - if ((int)Start < 0) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - return EXCEPTION_EXECUTE_HANDLER; - } + uint8_t * TypePos = (uint8_t *)lpEP->ContextRecord->Eip; + EXCEPTION_RECORD exRec = *lpEP->ExceptionRecord; + + Reg = NULL; + if (*TypePos == 0xF3 && (*(TypePos + 1) == 0xA4 || *(TypePos + 1) == 0xA5)) + { + uint32_t Start = (lpEP->ContextRecord->Edi - (uint32_t)m_RDRAM); + uint32_t End = Start + lpEP->ContextRecord->Ecx; + if ((int32_t)Start < 0) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + return EXCEPTION_EXECUTE_HANDLER; + } #ifdef CFB_READ - DWORD count, OldProtect; - if (Start >= CFBStart && End < CFBEnd) - { - for ( count = Start; count < End; count += 0x1000 ) - { - VirtualProtect(m_RDRAM+count,4,PAGE_READONLY, &OldProtect); - if (FrameBufferRead) - { - FrameBufferRead(count & ~0xFFF); - } - } - return EXCEPTION_CONTINUE_EXECUTION; - } + uint32_t count, OldProtect; + if (Start >= CFBStart && End < CFBEnd) + { + for ( count = Start; count < End; count += 0x1000 ) + { + VirtualProtect(m_RDRAM+count,4,PAGE_READONLY, &OldProtect); + if (FrameBufferRead) + { + FrameBufferRead(count & ~0xFFF); + } + } + return EXCEPTION_CONTINUE_EXECUTION; + } #endif - if (End < RdramSize()) - { - for (DWORD count = (Start & ~0xFFF); count < End; count += 0x1000 ) - { - g_Recompiler->ClearRecompCode_Phys(count,0x1000,CRecompiler::Remove_ProtectedMem); - } - return EXCEPTION_CONTINUE_EXECUTION; - } - if (Start >= 0x04000000 && End < 0x04002000) - { - g_Recompiler->ClearRecompCode_Phys(Start & ~0xFFF,0x1000,CRecompiler::Remove_ProtectedMem); - return EXCEPTION_CONTINUE_EXECUTION; - } - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - return EXCEPTION_EXECUTE_HANDLER; - } + if (End < RdramSize()) + { + for (uint32_t count = (Start & ~0xFFF); count < End; count += 0x1000) + { + g_Recompiler->ClearRecompCode_Phys(count, 0x1000, CRecompiler::Remove_ProtectedMem); + } + return EXCEPTION_CONTINUE_EXECUTION; + } + if (Start >= 0x04000000 && End < 0x04002000) + { + g_Recompiler->ClearRecompCode_Phys(Start & ~0xFFF, 0x1000, CRecompiler::Remove_ProtectedMem); + return EXCEPTION_CONTINUE_EXECUTION; + } + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + return EXCEPTION_EXECUTE_HANDLER; + } - BYTE * ReadPos; - if (*TypePos == 0x0F && *(TypePos + 1) == 0xB6) - { - ReadPos = TypePos + 2; - } - else if (*TypePos == 0x0F && *(TypePos + 1) == 0xB7) - { - ReadPos = TypePos + 2; - } - else if (*TypePos == 0x0F && *(TypePos + 1) == 0xBE) - { - ReadPos = TypePos + 2; - } - else if (*TypePos == 0x0F && *(TypePos + 1) == 0xBF) - { - ReadPos = TypePos + 2; - } - else if (*TypePos == 0x66) - { - ReadPos = TypePos + 2; - } - else - { - ReadPos = TypePos + 1; - } + uint8_t * ReadPos; + if (*TypePos == 0x0F && *(TypePos + 1) == 0xB6) + { + ReadPos = TypePos + 2; + } + else if (*TypePos == 0x0F && *(TypePos + 1) == 0xB7) + { + ReadPos = TypePos + 2; + } + else if (*TypePos == 0x0F && *(TypePos + 1) == 0xBE) + { + ReadPos = TypePos + 2; + } + else if (*TypePos == 0x0F && *(TypePos + 1) == 0xBF) + { + ReadPos = TypePos + 2; + } + else if (*TypePos == 0x66) + { + ReadPos = TypePos + 2; + } + else + { + ReadPos = TypePos + 1; + } - switch (*ReadPos & 0x38) - { - case 0x00: Reg = &(lpEP->ContextRecord->Eax); break; - case 0x08: Reg = &(lpEP->ContextRecord->Ecx); break; - case 0x10: Reg = &(lpEP->ContextRecord->Edx); break; - case 0x18: Reg = &(lpEP->ContextRecord->Ebx); break; - case 0x20: Reg = &(lpEP->ContextRecord->Esp); break; - case 0x28: Reg = &(lpEP->ContextRecord->Ebp); break; - case 0x30: Reg = &(lpEP->ContextRecord->Esi); break; - case 0x38: Reg = &(lpEP->ContextRecord->Edi); break; - } + switch (*ReadPos & 0x38) + { + case 0x00: Reg = &(lpEP->ContextRecord->Eax); break; + case 0x08: Reg = &(lpEP->ContextRecord->Ecx); break; + case 0x10: Reg = &(lpEP->ContextRecord->Edx); break; + case 0x18: Reg = &(lpEP->ContextRecord->Ebx); break; + case 0x20: Reg = &(lpEP->ContextRecord->Esp); break; + case 0x28: Reg = &(lpEP->ContextRecord->Ebp); break; + case 0x30: Reg = &(lpEP->ContextRecord->Esi); break; + case 0x38: Reg = &(lpEP->ContextRecord->Edi); break; + } - switch ((*ReadPos & 0xC7)) - { - case 0: ReadPos += 1; break; - case 1: ReadPos += 1; break; - case 2: ReadPos += 1; break; - case 3: ReadPos += 1; break; - case 4: - ReadPos += 1; - switch ((*ReadPos & 0xC7)) - { - case 0: ReadPos += 1; break; - case 1: ReadPos += 1; break; - case 2: ReadPos += 1; break; - case 3: ReadPos += 1; break; - case 6: ReadPos += 1; break; - case 7: ReadPos += 1; break; - case 0x80: ReadPos += 1; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - break; - case 5: ReadPos += 5; break; - case 6: ReadPos += 1; break; - case 7: ReadPos += 1; break; - case 0x40: ReadPos += 2; break; - case 0x41: ReadPos += 2; break; - case 0x42: ReadPos += 2; break; - case 0x43: ReadPos += 2; break; - case 0x44: ReadPos += 3; break; - case 0x46: ReadPos += 2; break; - case 0x47: ReadPos += 2; break; - case 0x80: ReadPos += 5; break; - case 0x81: ReadPos += 5; break; - case 0x82: ReadPos += 5; break; - case 0x83: ReadPos += 5; break; - case 0x86: ReadPos += 5; break; - case 0x87: ReadPos += 5; break; - default: - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - return EXCEPTION_EXECUTE_HANDLER; - } + switch ((*ReadPos & 0xC7)) + { + case 0: ReadPos += 1; break; + case 1: ReadPos += 1; break; + case 2: ReadPos += 1; break; + case 3: ReadPos += 1; break; + case 4: + ReadPos += 1; + switch ((*ReadPos & 0xC7)) + { + case 0: ReadPos += 1; break; + case 1: ReadPos += 1; break; + case 2: ReadPos += 1; break; + case 3: ReadPos += 1; break; + case 6: ReadPos += 1; break; + case 7: ReadPos += 1; break; + case 0x80: ReadPos += 1; break; + default: + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + break; + case 5: ReadPos += 5; break; + case 6: ReadPos += 1; break; + case 7: ReadPos += 1; break; + case 0x40: ReadPos += 2; break; + case 0x41: ReadPos += 2; break; + case 0x42: ReadPos += 2; break; + case 0x43: ReadPos += 2; break; + case 0x44: ReadPos += 3; break; + case 0x46: ReadPos += 2; break; + case 0x47: ReadPos += 2; break; + case 0x80: ReadPos += 5; break; + case 0x81: ReadPos += 5; break; + case 0x82: ReadPos += 5; break; + case 0x83: ReadPos += 5; break; + case 0x86: ReadPos += 5; break; + case 0x87: ReadPos += 5; break; + default: + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + return EXCEPTION_EXECUTE_HANDLER; + } - if (Reg == NULL) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - return EXCEPTION_EXECUTE_HANDLER; - } + if (Reg == NULL) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + return EXCEPTION_EXECUTE_HANDLER; + } - switch (*TypePos) - { - case 0x0F: - switch (*(TypePos + 1)) - { - case 0xB6: - if (!LB_NonMemory(MemAddress, (DWORD *)Reg, false)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to load byte\n\nMIPS Address: %08X\nX86 Address: %08X", - (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, - (unsigned char *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); - } - } - lpEP->ContextRecord->Eip = (DWORD)ReadPos; - return EXCEPTION_CONTINUE_EXECUTION; - case 0xB7: - if (!LH_NonMemory(MemAddress, (DWORD *)Reg, false)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to load half word\n\nMIPS Address: %08X\nX86 Address: %08X", - (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, - (unsigned char *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); - } - } - lpEP->ContextRecord->Eip = (DWORD)ReadPos; - return EXCEPTION_CONTINUE_EXECUTION; - case 0xBE: - if (!LB_NonMemory(MemAddress, Reg, true)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to load byte\n\nMIPS Address: %08X\nX86 Address: %08X", - (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, - (unsigned char *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); - } - } - lpEP->ContextRecord->Eip = (DWORD)ReadPos; - return EXCEPTION_CONTINUE_EXECUTION; - case 0xBF: - if (!LH_NonMemory(MemAddress, Reg, true)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to load half word\n\nMIPS Address: %08X\nX86 Address: %08X", - (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, - (unsigned char *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); - } - } - lpEP->ContextRecord->Eip = (DWORD)ReadPos; - return EXCEPTION_CONTINUE_EXECUTION; - default: - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - return EXCEPTION_EXECUTE_HANDLER; - } - break; - case 0x66: - switch (*(TypePos + 1)) - { - case 0x8B: - if (!LH_NonMemory(MemAddress, Reg, false)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to half word\n\nMIPS Address: %08X\nX86 Address: %08X", - (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, - (unsigned char *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); - } - } - lpEP->ContextRecord->Eip = (DWORD)ReadPos; - return EXCEPTION_CONTINUE_EXECUTION; - case 0x89: - if (!SH_NonMemory(MemAddress,*(WORD *)Reg)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to store half word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, - (unsigned char *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); - } - } - lpEP->ContextRecord->Eip = (DWORD)ReadPos; - return EXCEPTION_CONTINUE_EXECUTION; - case 0xC7: - if (Reg != &lpEP->ContextRecord->Eax) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - return EXCEPTION_EXECUTE_HANDLER; - } - if (!SH_NonMemory(MemAddress,*(WORD *)ReadPos)) { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to store half word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, - (unsigned char *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); - } - } - lpEP->ContextRecord->Eip = (DWORD)(ReadPos + 2); - return EXCEPTION_CONTINUE_EXECUTION; - default: - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - return EXCEPTION_EXECUTE_HANDLER; - } - break; - case 0x88: - if (!SB_NonMemory(MemAddress,*(BYTE *)Reg)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to store byte\n\nMIPS Address: %08X\nX86 Address: %08X", - (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, - (unsigned char *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); - } - } - lpEP->ContextRecord->Eip = (DWORD)ReadPos; - return EXCEPTION_CONTINUE_EXECUTION; - case 0x8A: - if (!LB_NonMemory(MemAddress, Reg, false)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to load byte\n\nMIPS Address: %08X\nX86 Address: %08X", - (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, - (unsigned char *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); - } - } - lpEP->ContextRecord->Eip = (DWORD)ReadPos; - return EXCEPTION_CONTINUE_EXECUTION; - case 0x8B: - if (!LW_NonMemory(MemAddress,Reg)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to load word\n\nMIPS Address: %08X\nX86 Address: %08X", - (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, - (unsigned char *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); - } - } - lpEP->ContextRecord->Eip = (DWORD)ReadPos; - return EXCEPTION_CONTINUE_EXECUTION; - case 0x89: - if (!SW_NonMemory(MemAddress,*(DWORD *)Reg)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, - (unsigned char *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); - } - } - lpEP->ContextRecord->Eip = (DWORD)ReadPos; - return EXCEPTION_CONTINUE_EXECUTION; - case 0xC6: - if (Reg != &lpEP->ContextRecord->Eax) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - return EXCEPTION_EXECUTE_HANDLER; - } - if (!SB_NonMemory(MemAddress,*(BYTE *)ReadPos)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to store byte\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, - (unsigned char *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); - } - } - lpEP->ContextRecord->Eip = (DWORD)(ReadPos + 1); - return EXCEPTION_CONTINUE_EXECUTION; - case 0xC7: - if (Reg != &lpEP->ContextRecord->Eax) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - return EXCEPTION_EXECUTE_HANDLER; - } - if (!SW_NonMemory(MemAddress,*(DWORD *)ReadPos)) - { - if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) - { - g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, - (unsigned char *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); - } - } - lpEP->ContextRecord->Eip = (DWORD)(ReadPos + 4); - return EXCEPTION_CONTINUE_EXECUTION; - } - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + switch (*TypePos) + { + case 0x0F: + switch (*(TypePos + 1)) + { + case 0xB6: + if (!LB_NonMemory(MemAddress, (uint32_t *)Reg, false)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to load byte\n\nMIPS Address: %08X\nX86 Address: %08X", + (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, + (uint8_t *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)ReadPos; + return EXCEPTION_CONTINUE_EXECUTION; + case 0xB7: + if (!LH_NonMemory(MemAddress, (uint32_t *)Reg, false)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to load half word\n\nMIPS Address: %08X\nX86 Address: %08X", + (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, + (uint8_t *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)ReadPos; + return EXCEPTION_CONTINUE_EXECUTION; + case 0xBE: + if (!LB_NonMemory(MemAddress, (uint32_t *)Reg, true)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to load byte\n\nMIPS Address: %08X\nX86 Address: %08X", + (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, + (uint8_t *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)ReadPos; + return EXCEPTION_CONTINUE_EXECUTION; + case 0xBF: + if (!LH_NonMemory(MemAddress, (uint32_t *)Reg, true)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to load half word\n\nMIPS Address: %08X\nX86 Address: %08X", + (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, + (uint8_t *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)ReadPos; + return EXCEPTION_CONTINUE_EXECUTION; + default: + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + return EXCEPTION_EXECUTE_HANDLER; + } + break; + case 0x66: + switch (*(TypePos + 1)) + { + case 0x8B: + if (!LH_NonMemory(MemAddress, (uint32_t *)Reg, false)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to half word\n\nMIPS Address: %08X\nX86 Address: %08X", + (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, + (uint8_t *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)ReadPos; + return EXCEPTION_CONTINUE_EXECUTION; + case 0x89: + if (!SH_NonMemory(MemAddress, *(uint16_t *)Reg)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to store half word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, + (uint8_t *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)ReadPos; + return EXCEPTION_CONTINUE_EXECUTION; + case 0xC7: + if (Reg != &lpEP->ContextRecord->Eax) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + return EXCEPTION_EXECUTE_HANDLER; + } + if (!SH_NonMemory(MemAddress, *(uint16_t *)ReadPos)) { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to store half word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, + (uint8_t *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)(ReadPos + 2); + return EXCEPTION_CONTINUE_EXECUTION; + default: + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + return EXCEPTION_EXECUTE_HANDLER; + } + break; + case 0x88: + if (!SB_NonMemory(MemAddress, *(uint8_t *)Reg)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to store byte\n\nMIPS Address: %08X\nX86 Address: %08X", + (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, + (uint8_t *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)ReadPos; + return EXCEPTION_CONTINUE_EXECUTION; + case 0x8A: + if (!LB_NonMemory(MemAddress, (uint32_t *)Reg, false)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to load byte\n\nMIPS Address: %08X\nX86 Address: %08X", + (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, + (uint8_t *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)ReadPos; + return EXCEPTION_CONTINUE_EXECUTION; + case 0x8B: + if (!LW_NonMemory(MemAddress, (uint32_t *)Reg)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to load word\n\nMIPS Address: %08X\nX86 Address: %08X", + (char *)exRec.ExceptionInformation[1] - (char *)m_RDRAM, + (uint8_t *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)ReadPos; + return EXCEPTION_CONTINUE_EXECUTION; + case 0x89: + if (!SW_NonMemory(MemAddress, *(uint32_t *)Reg)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, + (uint8_t *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)ReadPos; + return EXCEPTION_CONTINUE_EXECUTION; + case 0xC6: + if (Reg != &lpEP->ContextRecord->Eax) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + return EXCEPTION_EXECUTE_HANDLER; + } + if (!SB_NonMemory(MemAddress, *(uint8_t *)ReadPos)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to store byte\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, + (uint8_t *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)(ReadPos + 1); + return EXCEPTION_CONTINUE_EXECUTION; + case 0xC7: + if (Reg != &lpEP->ContextRecord->Eax) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + return EXCEPTION_EXECUTE_HANDLER; + } + if (!SW_NonMemory(MemAddress, *(uint32_t *)ReadPos)) + { + if (g_Settings->LoadDword(Debugger_ShowUnhandledMemory)) + { + g_Notify->DisplayError(stdstr_f("Failed to store word\n\nMIPS Address: %08X\nX86 Address: %08X", MemAddress, + (uint8_t *)lpEP->ContextRecord->Eip).ToUTF16().c_str()); + } + } + lpEP->ContextRecord->Eip = (uint32_t)(ReadPos + 4); + return EXCEPTION_CONTINUE_EXECUTION; + } + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } #else - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__,__LINE__); #endif - return EXCEPTION_EXECUTE_HANDLER; + return EXCEPTION_EXECUTE_HANDLER; } -bool CMipsMemoryVM::LB_NonMemory(DWORD PAddr, DWORD* Value, bool /*SignExtend*/) +bool CMipsMemoryVM::LB_NonMemory(uint32_t PAddr, uint32_t* Value, bool /*SignExtend*/) { - if (PAddr < 0x800000) - { - *Value = 0; - return true; - } + if (PAddr < 0x800000) + { + *Value = 0; + return true; + } - if (PAddr >= 0x10000000 && PAddr < 0x16000000) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); + if (PAddr >= 0x10000000 && PAddr < 0x16000000) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); #ifdef tofix - if (WrittenToRom) - { - return false; - } + if (WrittenToRom) + { + return false; + } - if ((PAddr & 2) == 0) - { - PAddr = (PAddr + 4) ^ 2; - } + if ((PAddr & 2) == 0) + { + PAddr = (PAddr + 4) ^ 2; + } - if ((PAddr - 0x10000000) < RomFileSize) - { - if (SignExtend) - { - *Value = (int)((char)ROM[PAddr - 0x10000000]); - } - else - { - *Value = ROM[PAddr - 0x10000000]; - } + if ((PAddr - 0x10000000) < RomFileSize) + { + if (SignExtend) + { + *Value = (int32_t)((char)ROM[PAddr - 0x10000000]); + } + else + { + *Value = ROM[PAddr - 0x10000000]; + } - return true; - } - else - { - *Value = 0; - return false; - } + return true; + } + else + { + *Value = 0; + return false; + } #endif - } -// switch (PAddr & 0xFFF00000) -//{ -// default: - *Value = 0; -// return false; -// break; -// } - return true; + } + // switch (PAddr & 0xFFF00000) + //{ + // default: + *Value = 0; + // return false; + // break; + // } + return true; } -bool CMipsMemoryVM::LH_NonMemory(DWORD PAddr, DWORD* Value, bool/* SignExtend*/) +bool CMipsMemoryVM::LH_NonMemory(uint32_t PAddr, uint32_t* Value, bool/* SignExtend*/) { - if (PAddr < 0x800000) - { - *Value = 0; - return true; - } + if (PAddr < 0x800000) + { + *Value = 0; + return true; + } - if (PAddr >= 0x10000000 && PAddr < 0x16000000) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -// switch (PAddr & 0xFFF00000) -// { -// default: - *Value = 0; - return false; -// } -// return true; + if (PAddr >= 0x10000000 && PAddr < 0x16000000) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + // switch (PAddr & 0xFFF00000) + // { + // default: + *Value = 0; + return false; + // } + // return true; } -bool CMipsMemoryVM::LW_NonMemory(DWORD PAddr, DWORD* Value) +bool CMipsMemoryVM::LW_NonMemory(uint32_t PAddr, uint32_t* Value) { #ifdef CFB_READ - if (PAddr >= CFBStart && PAddr < CFBEnd) - { - DWORD OldProtect; - VirtualProtect(m_RDRAM+(PAddr & ~0xFFF),0xFFC,PAGE_READONLY, &OldProtect); - if (FrameBufferRead) - { - FrameBufferRead(PAddr & ~0xFFF); - } - *Value = *(DWORD *)(m_RDRAM+PAddr); - return true; - } + if (PAddr >= CFBStart && PAddr < CFBEnd) + { + uint32_t OldProtect; + VirtualProtect(m_RDRAM+(PAddr & ~0xFFF),0xFFC,PAGE_READONLY, &OldProtect); + if (FrameBufferRead) + { + FrameBufferRead(PAddr & ~0xFFF); + } + *Value = *(uint32_t *)(m_RDRAM+PAddr); + return true; + } #endif - if (PAddr >= 0x10000000 && PAddr < 0x16000000) - { - if (m_RomWrittenTo) - { - *Value = m_RomWroteValue; - //LogMessage("%X: Read crap from Rom %08X from %08X",PROGRAM_COUNTER,*Value,PAddr); - m_RomWrittenTo = false; + if (PAddr >= 0x10000000 && PAddr < 0x16000000) + { + if (m_RomWrittenTo) + { + *Value = m_RomWroteValue; + //LogMessage("%X: Read crap from Rom %08X from %08X",PROGRAM_COUNTER,*Value,PAddr); + m_RomWrittenTo = false; #ifdef ROM_IN_MAPSPACE - { - DWORD OldProtect; - VirtualProtect(ROM,RomFileSize,PAGE_READONLY, &OldProtect); - } + { + uint32_t OldProtect; + VirtualProtect(ROM,RomFileSize,PAGE_READONLY, &OldProtect); + } #endif - return true; - } - if ((PAddr - 0x10000000) < m_RomSize) - { - *Value = *(DWORD *)&m_Rom[PAddr - 0x10000000]; - return true; - } - else - { - *Value = PAddr & 0xFFFF; - *Value = (*Value << 16) | *Value; - return false; - } - } + return true; + } + if ((PAddr - 0x10000000) < m_RomSize) + { + *Value = *(uint32_t *)&m_Rom[PAddr - 0x10000000]; + return true; + } + else + { + *Value = PAddr & 0xFFFF; + *Value = (*Value << 16) | *Value; + return false; + } + } - switch (PAddr & 0xFFF00000) - { - case 0x03F00000: - switch (PAddr) - { - case 0x03F00000: * Value = g_Reg->RDRAM_CONFIG_REG; break; - case 0x03F00004: * Value = g_Reg->RDRAM_DEVICE_ID_REG; break; - case 0x03F00008: * Value = g_Reg->RDRAM_DELAY_REG; break; - case 0x03F0000C: * Value = g_Reg->RDRAM_MODE_REG; break; - case 0x03F00010: * Value = g_Reg->RDRAM_REF_INTERVAL_REG; break; - case 0x03F00014: * Value = g_Reg->RDRAM_REF_ROW_REG; break; - case 0x03F00018: * Value = g_Reg->RDRAM_RAS_INTERVAL_REG; break; - case 0x03F0001C: * Value = g_Reg->RDRAM_MIN_INTERVAL_REG; break; - case 0x03F00020: * Value = g_Reg->RDRAM_ADDR_SELECT_REG; break; - case 0x03F00024: * Value = g_Reg->RDRAM_DEVICE_MANUF_REG; break; - default: - *Value = 0; - return false; - } - break; - case 0x04000000: - switch (PAddr) - { - case 0x04040010: *Value = g_Reg->SP_STATUS_REG; break; - case 0x04040014: *Value = g_Reg->SP_DMA_FULL_REG; break; - case 0x04040018: *Value = g_Reg->SP_DMA_BUSY_REG; break; - case 0x0404001C: - *Value = g_Reg->SP_SEMAPHORE_REG; - g_Reg->SP_SEMAPHORE_REG = 1; - break; - case 0x04080000: *Value = g_Reg->SP_PC_REG; break; - default: - * Value = 0; - return false; - } - break; - case 0x04100000: - switch (PAddr) - { - case 0x0410000C: *Value = g_Reg->DPC_STATUS_REG; break; - case 0x04100010: *Value = g_Reg->DPC_CLOCK_REG; break; - case 0x04100014: *Value = g_Reg->DPC_BUFBUSY_REG; break; - case 0x04100018: *Value = g_Reg->DPC_PIPEBUSY_REG; break; - case 0x0410001C: *Value = g_Reg->DPC_TMEM_REG; break; - default: - *Value = 0; - return false; - } - break; - case 0x04300000: - switch (PAddr) - { - case 0x04300000: *Value = g_Reg->MI_MODE_REG; break; - case 0x04300004: *Value = g_Reg->MI_VERSION_REG; break; - case 0x04300008: *Value = g_Reg->MI_INTR_REG; break; - case 0x0430000C: *Value = g_Reg->MI_INTR_MASK_REG; break; - default: - *Value = 0; - return false; - } - break; - case 0x04400000: - switch (PAddr) - { - case 0x04400000: *Value = g_Reg->VI_STATUS_REG; break; - case 0x04400004: *Value = g_Reg->VI_ORIGIN_REG; break; - case 0x04400008: *Value = g_Reg->VI_WIDTH_REG; break; - case 0x0440000C: *Value = g_Reg->VI_INTR_REG; break; - case 0x04400010: - UpdateHalfLine(); - *Value = m_HalfLine; - break; - case 0x04400014: *Value = g_Reg->VI_BURST_REG; break; - case 0x04400018: *Value = g_Reg->VI_V_SYNC_REG; break; - case 0x0440001C: *Value = g_Reg->VI_H_SYNC_REG; break; - case 0x04400020: *Value = g_Reg->VI_LEAP_REG; break; - case 0x04400024: *Value = g_Reg->VI_H_START_REG; break; - case 0x04400028: *Value = g_Reg->VI_V_START_REG ; break; - case 0x0440002C: *Value = g_Reg->VI_V_BURST_REG; break; - case 0x04400030: *Value = g_Reg->VI_X_SCALE_REG; break; - case 0x04400034: *Value = g_Reg->VI_Y_SCALE_REG; break; - default: - *Value = 0; - return false; - } - break; - case 0x04500000: - switch (PAddr) - { - case 0x04500004: - if (g_System->bFixedAudio()) - { - *Value = g_Audio->GetLength(); - } - else - { - if (g_Plugins->Audio()->AiReadLength != NULL) - { - *Value = g_Plugins->Audio()->AiReadLength(); - } - else - { - *Value = 0; - } - } - break; - case 0x0450000C: - if (g_System->bFixedAudio()) - { - *Value = g_Audio->GetStatus(); - } - else - { - *Value = g_Reg->AI_STATUS_REG; - } - break; - default: - *Value = 0; - return false; - } - break; - case 0x04600000: - switch (PAddr) - { - case 0x04600010: *Value = g_Reg->PI_STATUS_REG; break; - case 0x04600014: *Value = g_Reg->PI_DOMAIN1_REG; break; - case 0x04600018: *Value = g_Reg->PI_BSD_DOM1_PWD_REG; break; - case 0x0460001C: *Value = g_Reg->PI_BSD_DOM1_PGS_REG; break; - case 0x04600020: *Value = g_Reg->PI_BSD_DOM1_RLS_REG; break; - case 0x04600024: *Value = g_Reg->PI_DOMAIN2_REG; break; - case 0x04600028: *Value = g_Reg->PI_BSD_DOM2_PWD_REG; break; - case 0x0460002C: *Value = g_Reg->PI_BSD_DOM2_PGS_REG; break; - case 0x04600030: *Value = g_Reg->PI_BSD_DOM2_RLS_REG; break; - default: - *Value = 0; - return false; - } - break; - case 0x04700000: - switch (PAddr) - { - case 0x04700000: *Value = g_Reg->RI_MODE_REG; break; - case 0x04700004: *Value = g_Reg->RI_CONFIG_REG; break; - case 0x04700008: *Value = g_Reg->RI_CURRENT_LOAD_REG; break; - case 0x0470000C: *Value = g_Reg->RI_SELECT_REG; break; - case 0x04700010: *Value = g_Reg->RI_REFRESH_REG; break; - case 0x04700014: *Value = g_Reg->RI_LATENCY_REG; break; - case 0x04700018: *Value = g_Reg->RI_RERROR_REG; break; - case 0x0470001C: *Value = g_Reg->RI_WERROR_REG; break; - default: - *Value = 0; - return false; - } - break; - case 0x04800000: - switch (PAddr) - { - case 0x04800018: *Value = g_Reg->SI_STATUS_REG; break; - default: - *Value = 0; - return false; - } - break; - case 0x05000000: - *Value = PAddr & 0xFFFF; - *Value = (*Value << 16) | *Value; - return false; - case 0x08000000: - if (g_System->m_SaveUsing == SaveChip_Auto) - { - g_System->m_SaveUsing = SaveChip_FlashRam; - } - if (g_System->m_SaveUsing == SaveChip_Sram) - { - //Load Sram - BYTE tmp[4] = ""; - DmaFromSram(tmp, PAddr - 0x08000000, 4); - *Value = tmp[3] << 24 | tmp[2] << 16 | tmp[1] << 8 | tmp[0]; - return true; - } - else if (g_System->m_SaveUsing != SaveChip_FlashRam) - { - *Value = PAddr & 0xFFFF; - *Value = (*Value << 16) | *Value; - return false; - } - *Value = ReadFromFlashStatus(PAddr); - break; - case 0x1FC00000: - if (PAddr < 0x1FC007C0) - { -/* *Value = *(DWORD *)(&PifRom[PAddr - 0x1FC00000]); - *Value = swap32by8(*Value); */ - g_Notify->BreakPoint(__FILEW__,__LINE__); - return true; - } - else if (PAddr < 0x1FC00800) - { - BYTE * PIF_Ram = g_MMU->PifRam(); - *Value = *(DWORD *)(&PIF_Ram[PAddr - 0x1FC007C0]); - *Value = swap32by8(*Value); - return true; - } - else - { - *Value = 0; - return false; - } - break; - default: - *Value = PAddr & 0xFFFF; - *Value = (*Value << 16) | *Value; - return false; - break; - } + switch (PAddr & 0xFFF00000) + { + case 0x03F00000: + switch (PAddr) + { + case 0x03F00000: *Value = g_Reg->RDRAM_CONFIG_REG; break; + case 0x03F00004: *Value = g_Reg->RDRAM_DEVICE_ID_REG; break; + case 0x03F00008: *Value = g_Reg->RDRAM_DELAY_REG; break; + case 0x03F0000C: *Value = g_Reg->RDRAM_MODE_REG; break; + case 0x03F00010: *Value = g_Reg->RDRAM_REF_INTERVAL_REG; break; + case 0x03F00014: *Value = g_Reg->RDRAM_REF_ROW_REG; break; + case 0x03F00018: *Value = g_Reg->RDRAM_RAS_INTERVAL_REG; break; + case 0x03F0001C: *Value = g_Reg->RDRAM_MIN_INTERVAL_REG; break; + case 0x03F00020: *Value = g_Reg->RDRAM_ADDR_SELECT_REG; break; + case 0x03F00024: *Value = g_Reg->RDRAM_DEVICE_MANUF_REG; break; + default: + *Value = 0; + return false; + } + break; + case 0x04000000: + switch (PAddr) + { + case 0x04040010: *Value = g_Reg->SP_STATUS_REG; break; + case 0x04040014: *Value = g_Reg->SP_DMA_FULL_REG; break; + case 0x04040018: *Value = g_Reg->SP_DMA_BUSY_REG; break; + case 0x0404001C: + *Value = g_Reg->SP_SEMAPHORE_REG; + g_Reg->SP_SEMAPHORE_REG = 1; + break; + case 0x04080000: *Value = g_Reg->SP_PC_REG; break; + default: + *Value = 0; + return false; + } + break; + case 0x04100000: + switch (PAddr) + { + case 0x0410000C: *Value = g_Reg->DPC_STATUS_REG; break; + case 0x04100010: *Value = g_Reg->DPC_CLOCK_REG; break; + case 0x04100014: *Value = g_Reg->DPC_BUFBUSY_REG; break; + case 0x04100018: *Value = g_Reg->DPC_PIPEBUSY_REG; break; + case 0x0410001C: *Value = g_Reg->DPC_TMEM_REG; break; + default: + *Value = 0; + return false; + } + break; + case 0x04300000: + switch (PAddr) + { + case 0x04300000: *Value = g_Reg->MI_MODE_REG; break; + case 0x04300004: *Value = g_Reg->MI_VERSION_REG; break; + case 0x04300008: *Value = g_Reg->MI_INTR_REG; break; + case 0x0430000C: *Value = g_Reg->MI_INTR_MASK_REG; break; + default: + *Value = 0; + return false; + } + break; + case 0x04400000: + switch (PAddr) + { + case 0x04400000: *Value = g_Reg->VI_STATUS_REG; break; + case 0x04400004: *Value = g_Reg->VI_ORIGIN_REG; break; + case 0x04400008: *Value = g_Reg->VI_WIDTH_REG; break; + case 0x0440000C: *Value = g_Reg->VI_INTR_REG; break; + case 0x04400010: + UpdateHalfLine(); + *Value = m_HalfLine; + break; + case 0x04400014: *Value = g_Reg->VI_BURST_REG; break; + case 0x04400018: *Value = g_Reg->VI_V_SYNC_REG; break; + case 0x0440001C: *Value = g_Reg->VI_H_SYNC_REG; break; + case 0x04400020: *Value = g_Reg->VI_LEAP_REG; break; + case 0x04400024: *Value = g_Reg->VI_H_START_REG; break; + case 0x04400028: *Value = g_Reg->VI_V_START_REG; break; + case 0x0440002C: *Value = g_Reg->VI_V_BURST_REG; break; + case 0x04400030: *Value = g_Reg->VI_X_SCALE_REG; break; + case 0x04400034: *Value = g_Reg->VI_Y_SCALE_REG; break; + default: + *Value = 0; + return false; + } + break; + case 0x04500000: + switch (PAddr) + { + case 0x04500004: + if (g_System->bFixedAudio()) + { + *Value = g_Audio->GetLength(); + } + else + { + if (g_Plugins->Audio()->AiReadLength != NULL) + { + *Value = g_Plugins->Audio()->AiReadLength(); + } + else + { + *Value = 0; + } + } + break; + case 0x0450000C: + if (g_System->bFixedAudio()) + { + *Value = g_Audio->GetStatus(); + } + else + { + *Value = g_Reg->AI_STATUS_REG; + } + break; + default: + *Value = 0; + return false; + } + break; + case 0x04600000: + switch (PAddr) + { + case 0x04600010: *Value = g_Reg->PI_STATUS_REG; break; + case 0x04600014: *Value = g_Reg->PI_DOMAIN1_REG; break; + case 0x04600018: *Value = g_Reg->PI_BSD_DOM1_PWD_REG; break; + case 0x0460001C: *Value = g_Reg->PI_BSD_DOM1_PGS_REG; break; + case 0x04600020: *Value = g_Reg->PI_BSD_DOM1_RLS_REG; break; + case 0x04600024: *Value = g_Reg->PI_DOMAIN2_REG; break; + case 0x04600028: *Value = g_Reg->PI_BSD_DOM2_PWD_REG; break; + case 0x0460002C: *Value = g_Reg->PI_BSD_DOM2_PGS_REG; break; + case 0x04600030: *Value = g_Reg->PI_BSD_DOM2_RLS_REG; break; + default: + *Value = 0; + return false; + } + break; + case 0x04700000: + switch (PAddr) + { + case 0x04700000: *Value = g_Reg->RI_MODE_REG; break; + case 0x04700004: *Value = g_Reg->RI_CONFIG_REG; break; + case 0x04700008: *Value = g_Reg->RI_CURRENT_LOAD_REG; break; + case 0x0470000C: *Value = g_Reg->RI_SELECT_REG; break; + case 0x04700010: *Value = g_Reg->RI_REFRESH_REG; break; + case 0x04700014: *Value = g_Reg->RI_LATENCY_REG; break; + case 0x04700018: *Value = g_Reg->RI_RERROR_REG; break; + case 0x0470001C: *Value = g_Reg->RI_WERROR_REG; break; + default: + *Value = 0; + return false; + } + break; + case 0x04800000: + switch (PAddr) + { + case 0x04800018: *Value = g_Reg->SI_STATUS_REG; break; + default: + *Value = 0; + return false; + } + break; + case 0x05000000: + *Value = PAddr & 0xFFFF; + *Value = (*Value << 16) | *Value; + return false; + case 0x08000000: + if (g_System->m_SaveUsing == SaveChip_Auto) + { + g_System->m_SaveUsing = SaveChip_FlashRam; + } + if (g_System->m_SaveUsing == SaveChip_Sram) + { + //Load Sram + uint8_t tmp[4] = ""; + DmaFromSram(tmp, PAddr - 0x08000000, 4); + *Value = tmp[3] << 24 | tmp[2] << 16 | tmp[1] << 8 | tmp[0]; + return true; + } + else if (g_System->m_SaveUsing != SaveChip_FlashRam) + { + *Value = PAddr & 0xFFFF; + *Value = (*Value << 16) | *Value; + return false; + } + *Value = ReadFromFlashStatus(PAddr); + break; + case 0x1FC00000: + if (PAddr < 0x1FC007C0) + { + /* *Value = *(uint32_t *)(&PifRom[PAddr - 0x1FC00000]); + *Value = swap32by8(*Value); */ + g_Notify->BreakPoint(__FILEW__, __LINE__); + return true; + } + else if (PAddr < 0x1FC00800) + { + uint8_t * PIF_Ram = g_MMU->PifRam(); + *Value = *(uint32_t *)(&PIF_Ram[PAddr - 0x1FC007C0]); + *Value = swap32by8(*Value); + return true; + } + else + { + *Value = 0; + return false; + } + break; + default: + *Value = PAddr & 0xFFFF; + *Value = (*Value << 16) | *Value; + return false; + break; + } - return true; + return true; } -bool CMipsMemoryVM::SB_NonMemory(DWORD PAddr, BYTE Value) +bool CMipsMemoryVM::SB_NonMemory(uint32_t PAddr, uint8_t Value) { - switch (PAddr & 0xFFF00000) - { - case 0x00000000: - case 0x00100000: - case 0x00200000: - case 0x00300000: - case 0x00400000: - case 0x00500000: - case 0x00600000: - case 0x00700000: + switch (PAddr & 0xFFF00000) + { + case 0x00000000: + case 0x00100000: + case 0x00200000: + case 0x00300000: + case 0x00400000: + case 0x00500000: + case 0x00600000: + case 0x00700000: #ifdef CFB_READ - if (PAddr >= CFBStart && PAddr < CFBEnd) - { - DWORD OldProtect; - VirtualProtect(m_RDRAM+(PAddr & ~0xFFF),0xFFC,PAGE_READWRITE, &OldProtect); - *(BYTE *)(m_RDRAM+PAddr) = Value; - VirtualProtect(m_RDRAM+(PAddr & ~0xFFF),0xFFC,OldProtect, &OldProtect); - g_Notify->DisplayError(L"FrameBufferWrite"); - if (FrameBufferWrite) { FrameBufferWrite(PAddr,1); } - break; - } + if (PAddr >= CFBStart && PAddr < CFBEnd) + { + uint32_t OldProtect; + VirtualProtect(m_RDRAM+(PAddr & ~0xFFF),0xFFC,PAGE_READWRITE, &OldProtect); + *(uint8_t *)(m_RDRAM+PAddr) = Value; + VirtualProtect(m_RDRAM+(PAddr & ~0xFFF),0xFFC,OldProtect, &OldProtect); + g_Notify->DisplayError(L"FrameBufferWrite"); + if (FrameBufferWrite) { FrameBufferWrite(PAddr,1); } + break; + } #endif - if (PAddr < RdramSize()) - { - DWORD OldProtect; - g_Recompiler->ClearRecompCode_Phys(PAddr & ~0xFFF,0xFFC,CRecompiler::Remove_ProtectedMem); - VirtualProtect(m_RDRAM+(PAddr & ~0xFFF),0xFFC,PAGE_READWRITE, &OldProtect); - *(BYTE *)(m_RDRAM+PAddr) = Value; - } - break; - default: - return false; - } + if (PAddr < RdramSize()) + { + DWORD OldProtect; + g_Recompiler->ClearRecompCode_Phys(PAddr & ~0xFFF, 0xFFC, CRecompiler::Remove_ProtectedMem); + VirtualProtect(m_RDRAM + (PAddr & ~0xFFF), 0xFFC, PAGE_READWRITE, &OldProtect); + *(uint8_t *)(m_RDRAM + PAddr) = Value; + } + break; + default: + return false; + } - return true; + return true; } -bool CMipsMemoryVM::SH_NonMemory(DWORD PAddr, WORD Value) +bool CMipsMemoryVM::SH_NonMemory(uint32_t PAddr, uint16_t Value) { - switch (PAddr & 0xFFF00000) - { - case 0x00000000: - case 0x00100000: - case 0x00200000: - case 0x00300000: - case 0x00400000: - case 0x00500000: - case 0x00600000: - case 0x00700000: + switch (PAddr & 0xFFF00000) + { + case 0x00000000: + case 0x00100000: + case 0x00200000: + case 0x00300000: + case 0x00400000: + case 0x00500000: + case 0x00600000: + case 0x00700000: #ifdef CFB_READ - if (PAddr >= CFBStart && PAddr < CFBEnd) - { - DWORD OldProtect; - VirtualProtect(m_RDRAM+(PAddr & ~0xFFF),0xFFC,PAGE_READWRITE, &OldProtect); - *(WORD *)(m_RDRAM+PAddr) = Value; - if (FrameBufferWrite) { FrameBufferWrite(PAddr & ~0xFFF,2); } - //*(WORD *)(m_RDRAM+PAddr) = 0xFFFF; - //VirtualProtect(m_RDRAM+(PAddr & ~0xFFF),0xFFC,PAGE_NOACCESS, &OldProtect); - g_Notify->DisplayError(L"PAddr = %x",PAddr); - break; - } + if (PAddr >= CFBStart && PAddr < CFBEnd) + { + uint32_t OldProtect; + VirtualProtect(m_RDRAM+(PAddr & ~0xFFF),0xFFC,PAGE_READWRITE, &OldProtect); + *(uint16_t *)(m_RDRAM+PAddr) = Value; + if (FrameBufferWrite) { FrameBufferWrite(PAddr & ~0xFFF,2); } + //*(uint16_t *)(m_RDRAM+PAddr) = 0xFFFF; + //VirtualProtect(m_RDRAM+(PAddr & ~0xFFF),0xFFC,PAGE_NOACCESS, &OldProtect); + g_Notify->DisplayError(L"PAddr = %x",PAddr); + break; + } #endif - if (PAddr < RdramSize()) - { - DWORD OldProtect; - g_Recompiler->ClearRecompCode_Phys(PAddr & ~0xFFF,0x1000,CRecompiler::Remove_ProtectedMem); - VirtualProtect(m_RDRAM+(PAddr & ~0xFFF),0xFFC,PAGE_READWRITE, &OldProtect); - *(WORD *)(m_RDRAM+PAddr) = Value; - } - break; - default: - return false; - } + if (PAddr < RdramSize()) + { + DWORD OldProtect; + g_Recompiler->ClearRecompCode_Phys(PAddr & ~0xFFF, 0x1000, CRecompiler::Remove_ProtectedMem); + VirtualProtect(m_RDRAM + (PAddr & ~0xFFF), 0xFFC, PAGE_READWRITE, &OldProtect); + *(uint16_t *)(m_RDRAM + PAddr) = Value; + } + break; + default: + return false; + } - return true; + return true; } -bool CMipsMemoryVM::SW_NonMemory(DWORD PAddr, DWORD Value) +bool CMipsMemoryVM::SW_NonMemory(uint32_t PAddr, uint32_t Value) { - if (PAddr >= 0x10000000 && PAddr < 0x16000000) - { - if ((PAddr - 0x10000000) < g_Rom->GetRomSize()) - { - m_RomWrittenTo = true; - m_RomWroteValue = Value; + if (PAddr >= 0x10000000 && PAddr < 0x16000000) + { + if ((PAddr - 0x10000000) < g_Rom->GetRomSize()) + { + m_RomWrittenTo = true; + m_RomWroteValue = Value; #ifdef ROM_IN_MAPSPACE - { - DWORD OldProtect; - VirtualProtect(ROM,RomFileSize,PAGE_NOACCESS, &OldProtect); - } + { + uint32_t OldProtect; + VirtualProtect(ROM,RomFileSize,PAGE_NOACCESS, &OldProtect); + } #endif - //LogMessage("%X: Wrote To Rom %08X from %08X",PROGRAM_COUNTER,Value,PAddr); - } - else - { - return false; - } - } + //LogMessage("%X: Wrote To Rom %08X from %08X",PROGRAM_COUNTER,Value,PAddr); + } + else + { + return false; + } + } - switch (PAddr & 0xFFF00000) - { - case 0x00000000: - case 0x00100000: - case 0x00200000: - case 0x00300000: - case 0x00400000: - case 0x00500000: - case 0x00600000: - case 0x00700000: + switch (PAddr & 0xFFF00000) + { + case 0x00000000: + case 0x00100000: + case 0x00200000: + case 0x00300000: + case 0x00400000: + case 0x00500000: + case 0x00600000: + case 0x00700000: #ifdef CFB_READ - if (PAddr >= CFBStart && PAddr < CFBEnd) - { - DWORD OldProtect; - VirtualProtect(m_RDRAM+(PAddr & ~0xFFF),0xFFC,PAGE_READWRITE, &OldProtect); - *(DWORD *)(m_RDRAM+PAddr) = Value; - VirtualProtect(m_RDRAM+(PAddr & ~0xFFF),0xFFC,OldProtect, &OldProtect); - g_Notify->DisplayError(L"FrameBufferWrite %X",PAddr); - if (FrameBufferWrite) { FrameBufferWrite(PAddr,4); } - break; - } + if (PAddr >= CFBStart && PAddr < CFBEnd) + { + uint32_t OldProtect; + VirtualProtect(m_RDRAM+(PAddr & ~0xFFF),0xFFC,PAGE_READWRITE, &OldProtect); + *(uint32_t *)(m_RDRAM+PAddr) = Value; + VirtualProtect(m_RDRAM+(PAddr & ~0xFFF),0xFFC,OldProtect, &OldProtect); + g_Notify->DisplayError(L"FrameBufferWrite %X",PAddr); + if (FrameBufferWrite) { FrameBufferWrite(PAddr,4); } + break; + } #endif - if (PAddr < RdramSize()) - { - DWORD OldProtect; - g_Recompiler->ClearRecompCode_Phys(PAddr & ~0xFFF,0x1000,CRecompiler::Remove_ProtectedMem); - VirtualProtect(m_RDRAM+(PAddr & ~0xFFF),0xFFC,PAGE_READWRITE, &OldProtect); - *(DWORD *)(m_RDRAM+PAddr) = Value; - } - break; - case 0x03F00000: - switch (PAddr) - { - case 0x03F00000: g_Reg->RDRAM_CONFIG_REG = Value; break; - case 0x03F00004: g_Reg->RDRAM_DEVICE_ID_REG = Value; break; - case 0x03F00008: g_Reg->RDRAM_DELAY_REG = Value; break; - case 0x03F0000C: g_Reg->RDRAM_MODE_REG = Value; break; - case 0x03F00010: g_Reg->RDRAM_REF_INTERVAL_REG = Value; break; - case 0x03F00014: g_Reg->RDRAM_REF_ROW_REG = Value; break; - case 0x03F00018: g_Reg->RDRAM_RAS_INTERVAL_REG = Value; break; - case 0x03F0001C: g_Reg->RDRAM_MIN_INTERVAL_REG = Value; break; - case 0x03F00020: g_Reg->RDRAM_ADDR_SELECT_REG = Value; break; - case 0x03F00024: g_Reg->RDRAM_DEVICE_MANUF_REG = Value; break; - case 0x03F04004: break; - case 0x03F08004: break; - case 0x03F80004: break; - case 0x03F80008: break; - case 0x03F8000C: break; - case 0x03F80014: break; - default: - return false; - } - break; - case 0x04000000: - if (PAddr < 0x04002000) - { - g_Recompiler->ClearRecompCode_Phys(PAddr & ~0xFFF,0xFFF,CRecompiler::Remove_ProtectedMem); - *(DWORD *)(m_RDRAM+PAddr) = Value; - } - else - { - switch (PAddr) - { - case 0x04040000: g_Reg->SP_MEM_ADDR_REG = Value; break; - case 0x04040004: g_Reg->SP_DRAM_ADDR_REG = Value; break; - case 0x04040008: - g_Reg->SP_RD_LEN_REG = Value; - SP_DMA_READ(); - break; - case 0x0404000C: - g_Reg->SP_WR_LEN_REG = Value; - SP_DMA_WRITE(); - break; - case 0x04040010: - if ( ( Value & SP_CLR_HALT ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_HALT; - } - if ( ( Value & SP_SET_HALT ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_HALT; - } - if ( ( Value & SP_CLR_BROKE ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_BROKE; - } - if ( ( Value & SP_CLR_INTR ) != 0) - { - g_Reg->MI_INTR_REG &= ~MI_INTR_SP; - g_Reg->m_RspIntrReg &= ~MI_INTR_SP; - g_Reg->CheckInterrupts(); - } - if ( ( Value & SP_SET_INTR ) != 0) - { - g_Notify->DisplayError(L"SP_SET_INTR"); - } - if ( ( Value & SP_CLR_SSTEP ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SSTEP; - } - if ( ( Value & SP_SET_SSTEP ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SSTEP; - } - if ( ( Value & SP_CLR_INTR_BREAK ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_INTR_BREAK; - } - if ( ( Value & SP_SET_INTR_BREAK ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_INTR_BREAK; - } - if ( ( Value & SP_CLR_SIG0 ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG0; - } - if ( ( Value & SP_SET_SIG0 ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG0; - } - if ( ( Value & SP_CLR_SIG1 ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG1; - } - if ( ( Value & SP_SET_SIG1 ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG1; - } - if ( ( Value & SP_CLR_SIG2 ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG2; - } - if ( ( Value & SP_SET_SIG2 ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG2; - } - if ( ( Value & SP_CLR_SIG3 ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG3; - } - if ( ( Value & SP_SET_SIG3 ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG3; - } - if ( ( Value & SP_CLR_SIG4 ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG4; - } - if ( ( Value & SP_SET_SIG4 ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG4; - } - if ( ( Value & SP_CLR_SIG5 ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG5; - } - if ( ( Value & SP_SET_SIG5 ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG5; - } - if ( ( Value & SP_CLR_SIG6 ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG6; - } - if ( ( Value & SP_SET_SIG6 ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG6; - } - if ( ( Value & SP_CLR_SIG7 ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG7; - } - if ( ( Value & SP_SET_SIG7 ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG7; - } - if ( ( Value & SP_SET_SIG0 ) != 0 && g_System->RspAudioSignal()) - { - g_Reg->MI_INTR_REG |= MI_INTR_SP; - g_Reg->CheckInterrupts(); - } - //if (*( DWORD *)(DMEM + 0xFC0) == 1) - //{ - // ChangeTimer(RspTimer,0x30000); - //} - //else - //{ - try - { - g_System->RunRSP(); - } - catch (...) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - //} - break; - case 0x0404001C: g_Reg->SP_SEMAPHORE_REG = 0; break; - case 0x04080000: g_Reg->SP_PC_REG = Value & 0xFFC; break; - default: - return false; - } - } - break; - case 0x04100000: - switch (PAddr) - { - case 0x04100000: - g_Reg->DPC_START_REG = Value; - g_Reg->DPC_CURRENT_REG = Value; - break; - case 0x04100004: - g_Reg->DPC_END_REG = Value; - if (g_Plugins->Gfx()->ProcessRDPList) - { - g_Plugins->Gfx()->ProcessRDPList(); - } - break; - //case 0x04100008: g_Reg->DPC_CURRENT_REG = Value; break; - case 0x0410000C: - if ( ( Value & DPC_CLR_XBUS_DMEM_DMA ) != 0) - { - g_Reg->DPC_STATUS_REG &= ~DPC_STATUS_XBUS_DMEM_DMA; - } - if ( ( Value & DPC_SET_XBUS_DMEM_DMA ) != 0) - { - g_Reg->DPC_STATUS_REG |= DPC_STATUS_XBUS_DMEM_DMA; - } - if ( ( Value & DPC_CLR_FREEZE ) != 0) - { - g_Reg->DPC_STATUS_REG &= ~DPC_STATUS_FREEZE; - } - if ( ( Value & DPC_SET_FREEZE ) != 0) - { - g_Reg->DPC_STATUS_REG |= DPC_STATUS_FREEZE; - } - if ( ( Value & DPC_CLR_FLUSH ) != 0) - { - g_Reg->DPC_STATUS_REG &= ~DPC_STATUS_FLUSH; - } - if ( ( Value & DPC_SET_FLUSH ) != 0) - { - g_Reg->DPC_STATUS_REG |= DPC_STATUS_FLUSH; - } - if ( ( Value & DPC_CLR_FREEZE ) != 0) - { - if ( ( g_Reg->SP_STATUS_REG & SP_STATUS_HALT ) == 0) - { - if ( ( g_Reg->SP_STATUS_REG & SP_STATUS_BROKE ) == 0 ) - { - try - { - g_System->RunRSP(); - } - catch (...) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } - } - } + if (PAddr < RdramSize()) + { + DWORD OldProtect; + g_Recompiler->ClearRecompCode_Phys(PAddr & ~0xFFF, 0x1000, CRecompiler::Remove_ProtectedMem); + VirtualProtect(m_RDRAM + (PAddr & ~0xFFF), 0xFFC, PAGE_READWRITE, &OldProtect); + *(uint32_t *)(m_RDRAM + PAddr) = Value; + } + break; + case 0x03F00000: + switch (PAddr) + { + case 0x03F00000: g_Reg->RDRAM_CONFIG_REG = Value; break; + case 0x03F00004: g_Reg->RDRAM_DEVICE_ID_REG = Value; break; + case 0x03F00008: g_Reg->RDRAM_DELAY_REG = Value; break; + case 0x03F0000C: g_Reg->RDRAM_MODE_REG = Value; break; + case 0x03F00010: g_Reg->RDRAM_REF_INTERVAL_REG = Value; break; + case 0x03F00014: g_Reg->RDRAM_REF_ROW_REG = Value; break; + case 0x03F00018: g_Reg->RDRAM_RAS_INTERVAL_REG = Value; break; + case 0x03F0001C: g_Reg->RDRAM_MIN_INTERVAL_REG = Value; break; + case 0x03F00020: g_Reg->RDRAM_ADDR_SELECT_REG = Value; break; + case 0x03F00024: g_Reg->RDRAM_DEVICE_MANUF_REG = Value; break; + case 0x03F04004: break; + case 0x03F08004: break; + case 0x03F80004: break; + case 0x03F80008: break; + case 0x03F8000C: break; + case 0x03F80014: break; + default: + return false; + } + break; + case 0x04000000: + if (PAddr < 0x04002000) + { + g_Recompiler->ClearRecompCode_Phys(PAddr & ~0xFFF, 0xFFF, CRecompiler::Remove_ProtectedMem); + *(uint32_t *)(m_RDRAM + PAddr) = Value; + } + else + { + switch (PAddr) + { + case 0x04040000: g_Reg->SP_MEM_ADDR_REG = Value; break; + case 0x04040004: g_Reg->SP_DRAM_ADDR_REG = Value; break; + case 0x04040008: + g_Reg->SP_RD_LEN_REG = Value; + SP_DMA_READ(); + break; + case 0x0404000C: + g_Reg->SP_WR_LEN_REG = Value; + SP_DMA_WRITE(); + break; + case 0x04040010: + if ((Value & SP_CLR_HALT) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_HALT; + } + if ((Value & SP_SET_HALT) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_HALT; + } + if ((Value & SP_CLR_BROKE) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_BROKE; + } + if ((Value & SP_CLR_INTR) != 0) + { + g_Reg->MI_INTR_REG &= ~MI_INTR_SP; + g_Reg->m_RspIntrReg &= ~MI_INTR_SP; + g_Reg->CheckInterrupts(); + } + if ((Value & SP_SET_INTR) != 0) + { + g_Notify->DisplayError(L"SP_SET_INTR"); + } + if ((Value & SP_CLR_SSTEP) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SSTEP; + } + if ((Value & SP_SET_SSTEP) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SSTEP; + } + if ((Value & SP_CLR_INTR_BREAK) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_INTR_BREAK; + } + if ((Value & SP_SET_INTR_BREAK) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_INTR_BREAK; + } + if ((Value & SP_CLR_SIG0) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG0; + } + if ((Value & SP_SET_SIG0) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG0; + } + if ((Value & SP_CLR_SIG1) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG1; + } + if ((Value & SP_SET_SIG1) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG1; + } + if ((Value & SP_CLR_SIG2) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG2; + } + if ((Value & SP_SET_SIG2) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG2; + } + if ((Value & SP_CLR_SIG3) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG3; + } + if ((Value & SP_SET_SIG3) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG3; + } + if ((Value & SP_CLR_SIG4) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG4; + } + if ((Value & SP_SET_SIG4) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG4; + } + if ((Value & SP_CLR_SIG5) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG5; + } + if ((Value & SP_SET_SIG5) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG5; + } + if ((Value & SP_CLR_SIG6) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG6; + } + if ((Value & SP_SET_SIG6) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG6; + } + if ((Value & SP_CLR_SIG7) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG7; + } + if ((Value & SP_SET_SIG7) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG7; + } + if ((Value & SP_SET_SIG0) != 0 && g_System->RspAudioSignal()) + { + g_Reg->MI_INTR_REG |= MI_INTR_SP; + g_Reg->CheckInterrupts(); + } + //if (*( uint32_t *)(DMEM + 0xFC0) == 1) + //{ + // ChangeTimer(RspTimer,0x30000); + //} + //else + //{ + try + { + g_System->RunRSP(); + } + catch (...) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + //} + break; + case 0x0404001C: g_Reg->SP_SEMAPHORE_REG = 0; break; + case 0x04080000: g_Reg->SP_PC_REG = Value & 0xFFC; break; + default: + return false; + } + } + break; + case 0x04100000: + switch (PAddr) + { + case 0x04100000: + g_Reg->DPC_START_REG = Value; + g_Reg->DPC_CURRENT_REG = Value; + break; + case 0x04100004: + g_Reg->DPC_END_REG = Value; + if (g_Plugins->Gfx()->ProcessRDPList) + { + g_Plugins->Gfx()->ProcessRDPList(); + } + break; + //case 0x04100008: g_Reg->DPC_CURRENT_REG = Value; break; + case 0x0410000C: + if ((Value & DPC_CLR_XBUS_DMEM_DMA) != 0) + { + g_Reg->DPC_STATUS_REG &= ~DPC_STATUS_XBUS_DMEM_DMA; + } + if ((Value & DPC_SET_XBUS_DMEM_DMA) != 0) + { + g_Reg->DPC_STATUS_REG |= DPC_STATUS_XBUS_DMEM_DMA; + } + if ((Value & DPC_CLR_FREEZE) != 0) + { + g_Reg->DPC_STATUS_REG &= ~DPC_STATUS_FREEZE; + } + if ((Value & DPC_SET_FREEZE) != 0) + { + g_Reg->DPC_STATUS_REG |= DPC_STATUS_FREEZE; + } + if ((Value & DPC_CLR_FLUSH) != 0) + { + g_Reg->DPC_STATUS_REG &= ~DPC_STATUS_FLUSH; + } + if ((Value & DPC_SET_FLUSH) != 0) + { + g_Reg->DPC_STATUS_REG |= DPC_STATUS_FLUSH; + } + if ((Value & DPC_CLR_FREEZE) != 0) + { + if ((g_Reg->SP_STATUS_REG & SP_STATUS_HALT) == 0) + { + if ((g_Reg->SP_STATUS_REG & SP_STATUS_BROKE) == 0) + { + try + { + g_System->RunRSP(); + } + catch (...) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } + } + } #ifdef tofix - if (ShowUnhandledMemory) - { - //if ( ( Value & DPC_CLR_TMEM_CTR ) != 0) - //{ - // g_Notify->DisplayError(L"RSP: DPC_STATUS_REG: DPC_CLR_TMEM_CTR"); - //} - //if ( ( Value & DPC_CLR_PIPE_CTR ) != 0) - //{ - // g_Notify->DisplayError(L"RSP: DPC_STATUS_REG: DPC_CLR_PIPE_CTR"); - //} - //if ( ( Value & DPC_CLR_CMD_CTR ) != 0) - //{ - // g_Notify->DisplayError(L"RSP: DPC_STATUS_REG: DPC_CLR_CMD_CTR"); - //} - //if ( ( Value & DPC_CLR_CLOCK_CTR ) != 0) - //{ - // g_Notify->DisplayError(L"RSP: DPC_STATUS_REG: DPC_CLR_CLOCK_CTR"); - //} - } + if (ShowUnhandledMemory) + { + //if ( ( Value & DPC_CLR_TMEM_CTR ) != 0) + //{ + // g_Notify->DisplayError(L"RSP: DPC_STATUS_REG: DPC_CLR_TMEM_CTR"); + //} + //if ( ( Value & DPC_CLR_PIPE_CTR ) != 0) + //{ + // g_Notify->DisplayError(L"RSP: DPC_STATUS_REG: DPC_CLR_PIPE_CTR"); + //} + //if ( ( Value & DPC_CLR_CMD_CTR ) != 0) + //{ + // g_Notify->DisplayError(L"RSP: DPC_STATUS_REG: DPC_CLR_CMD_CTR"); + //} + //if ( ( Value & DPC_CLR_CLOCK_CTR ) != 0) + //{ + // g_Notify->DisplayError(L"RSP: DPC_STATUS_REG: DPC_CLR_CLOCK_CTR"); + //} + } #endif - break; - default: - return false; - } - break; - case 0x04300000: - switch (PAddr) - { - case 0x04300000: - g_Reg->MI_MODE_REG &= ~0x7F; - g_Reg->MI_MODE_REG |= (Value & 0x7F); - if ( ( Value & MI_CLR_INIT ) != 0 ) - { - g_Reg->MI_MODE_REG &= ~MI_MODE_INIT; - } - if ( ( Value & MI_SET_INIT ) != 0 ) - { - g_Reg->MI_MODE_REG |= MI_MODE_INIT; - } - if ( ( Value & MI_CLR_EBUS ) != 0 ) - { - g_Reg->MI_MODE_REG &= ~MI_MODE_EBUS; - } - if ( ( Value & MI_SET_EBUS ) != 0 ) - { - g_Reg->MI_MODE_REG |= MI_MODE_EBUS; - } - if ( ( Value & MI_CLR_DP_INTR ) != 0 ) - { - g_Reg->MI_INTR_REG &= ~MI_INTR_DP; - g_Reg->m_GfxIntrReg &= ~MI_INTR_DP; - g_Reg->CheckInterrupts(); - } - if ( ( Value & MI_CLR_RDRAM ) != 0 ) - { - g_Reg->MI_MODE_REG &= ~MI_MODE_RDRAM; - } - if ( ( Value & MI_SET_RDRAM ) != 0 ) - { - g_Reg->MI_MODE_REG |= MI_MODE_RDRAM; - } - break; - case 0x0430000C: - if ( ( Value & MI_INTR_MASK_CLR_SP ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_SP; - } - if ( ( Value & MI_INTR_MASK_SET_SP ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_SP; - } - if ( ( Value & MI_INTR_MASK_CLR_SI ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_SI; - } - if ( ( Value & MI_INTR_MASK_SET_SI ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_SI; - } - if ( ( Value & MI_INTR_MASK_CLR_AI ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_AI; - } - if ( ( Value & MI_INTR_MASK_SET_AI ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_AI; - } - if ( ( Value & MI_INTR_MASK_CLR_VI ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_VI; - } - if ( ( Value & MI_INTR_MASK_SET_VI ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_VI; - } - if ( ( Value & MI_INTR_MASK_CLR_PI ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_PI; - } - if ( ( Value & MI_INTR_MASK_SET_PI ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_PI; - } - if ( ( Value & MI_INTR_MASK_CLR_DP ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_DP; - } - if ( ( Value & MI_INTR_MASK_SET_DP ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_DP; - } - break; - default: - return false; - } - break; - case 0x04400000: - switch (PAddr) - { - case 0x04400000: - if (g_Reg->VI_STATUS_REG != Value) - { - g_Reg->VI_STATUS_REG = Value; - if (g_Plugins->Gfx()->ViStatusChanged != NULL ) - { - g_Plugins->Gfx()->ViStatusChanged(); - } - } - break; - case 0x04400004: + break; + default: + return false; + } + break; + case 0x04300000: + switch (PAddr) + { + case 0x04300000: + g_Reg->MI_MODE_REG &= ~0x7F; + g_Reg->MI_MODE_REG |= (Value & 0x7F); + if ((Value & MI_CLR_INIT) != 0) + { + g_Reg->MI_MODE_REG &= ~MI_MODE_INIT; + } + if ((Value & MI_SET_INIT) != 0) + { + g_Reg->MI_MODE_REG |= MI_MODE_INIT; + } + if ((Value & MI_CLR_EBUS) != 0) + { + g_Reg->MI_MODE_REG &= ~MI_MODE_EBUS; + } + if ((Value & MI_SET_EBUS) != 0) + { + g_Reg->MI_MODE_REG |= MI_MODE_EBUS; + } + if ((Value & MI_CLR_DP_INTR) != 0) + { + g_Reg->MI_INTR_REG &= ~MI_INTR_DP; + g_Reg->m_GfxIntrReg &= ~MI_INTR_DP; + g_Reg->CheckInterrupts(); + } + if ((Value & MI_CLR_RDRAM) != 0) + { + g_Reg->MI_MODE_REG &= ~MI_MODE_RDRAM; + } + if ((Value & MI_SET_RDRAM) != 0) + { + g_Reg->MI_MODE_REG |= MI_MODE_RDRAM; + } + break; + case 0x0430000C: + if ((Value & MI_INTR_MASK_CLR_SP) != 0) + { + g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_SP; + } + if ((Value & MI_INTR_MASK_SET_SP) != 0) + { + g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_SP; + } + if ((Value & MI_INTR_MASK_CLR_SI) != 0) + { + g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_SI; + } + if ((Value & MI_INTR_MASK_SET_SI) != 0) + { + g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_SI; + } + if ((Value & MI_INTR_MASK_CLR_AI) != 0) + { + g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_AI; + } + if ((Value & MI_INTR_MASK_SET_AI) != 0) + { + g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_AI; + } + if ((Value & MI_INTR_MASK_CLR_VI) != 0) + { + g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_VI; + } + if ((Value & MI_INTR_MASK_SET_VI) != 0) + { + g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_VI; + } + if ((Value & MI_INTR_MASK_CLR_PI) != 0) + { + g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_PI; + } + if ((Value & MI_INTR_MASK_SET_PI) != 0) + { + g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_PI; + } + if ((Value & MI_INTR_MASK_CLR_DP) != 0) + { + g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_DP; + } + if ((Value & MI_INTR_MASK_SET_DP) != 0) + { + g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_DP; + } + break; + default: + return false; + } + break; + case 0x04400000: + switch (PAddr) + { + case 0x04400000: + if (g_Reg->VI_STATUS_REG != Value) + { + g_Reg->VI_STATUS_REG = Value; + if (g_Plugins->Gfx()->ViStatusChanged != NULL) + { + g_Plugins->Gfx()->ViStatusChanged(); + } + } + break; + case 0x04400004: #ifdef CFB_READ - if (g_Reg->VI_ORIGIN_REG > 0x280) - { - SetFrameBuffer(g_Reg->VI_ORIGIN_REG, (DWORD)(VI_WIDTH_REG * (VI_WIDTH_REG *.75))); - } + if (g_Reg->VI_ORIGIN_REG > 0x280) + { + SetFrameBuffer(g_Reg->VI_ORIGIN_REG, (uint32_t)(VI_WIDTH_REG * (VI_WIDTH_REG *.75))); + } #endif - g_Reg->VI_ORIGIN_REG = (Value & 0xFFFFFF); - //if (UpdateScreen != NULL ) - //{ - // UpdateScreen(); - //} - break; - case 0x04400008: - if (g_Reg->VI_WIDTH_REG != Value) - { - g_Reg->VI_WIDTH_REG = Value; - if (g_Plugins->Gfx()->ViWidthChanged != NULL ) - { - g_Plugins->Gfx()->ViWidthChanged(); - } - } - break; - case 0x0440000C: g_Reg->VI_INTR_REG = Value; break; - case 0x04400010: - g_Reg->MI_INTR_REG &= ~MI_INTR_VI; - g_Reg->CheckInterrupts(); - break; - case 0x04400014: g_Reg->VI_BURST_REG = Value; break; - case 0x04400018: g_Reg->VI_V_SYNC_REG = Value; break; - case 0x0440001C: g_Reg->VI_H_SYNC_REG = Value; break; - case 0x04400020: g_Reg->VI_LEAP_REG = Value; break; - case 0x04400024: g_Reg->VI_H_START_REG = Value; break; - case 0x04400028: g_Reg->VI_V_START_REG = Value; break; - case 0x0440002C: g_Reg->VI_V_BURST_REG = Value; break; - case 0x04400030: g_Reg->VI_X_SCALE_REG = Value; break; - case 0x04400034: g_Reg->VI_Y_SCALE_REG = Value; break; - default: - return false; - } - break; - case 0x04500000: - switch (PAddr) - { - case 0x04500000: g_Reg->AI_DRAM_ADDR_REG = Value; break; - case 0x04500004: - g_Reg->AI_LEN_REG = Value; - if (g_System->bFixedAudio()) - { - g_Audio->LenChanged(); - } - else - { - if (g_Plugins->Audio()->AiLenChanged != NULL) - { - g_Plugins->Audio()->AiLenChanged(); - } - } - break; - case 0x04500008: g_Reg->AI_CONTROL_REG = (Value & 1); break; - case 0x0450000C: - /* Clear Interrupt */; - g_Reg->MI_INTR_REG &= ~MI_INTR_AI; - g_Reg->m_AudioIntrReg &= ~MI_INTR_AI; - g_Reg->CheckInterrupts(); - break; - case 0x04500010: - g_Reg->AI_DACRATE_REG = Value; - g_Plugins->Audio()->DacrateChanged(g_System->SystemType()); - if (g_System->bFixedAudio()) - { - g_Audio->SetFrequency(Value,g_System->SystemType()); - } - break; - case 0x04500014: g_Reg->AI_BITRATE_REG = Value; break; - default: - return false; - } - break; - case 0x04600000: - switch (PAddr) - { - case 0x04600000: g_Reg->PI_DRAM_ADDR_REG = Value; break; - case 0x04600004: g_Reg->PI_CART_ADDR_REG = Value; break; - case 0x04600008: - g_Reg->PI_RD_LEN_REG = Value; - PI_DMA_READ(); - break; - case 0x0460000C: - g_Reg->PI_WR_LEN_REG = Value; - PI_DMA_WRITE(); - break; - case 0x04600010: - //if ((Value & PI_SET_RESET) != 0 ) - //{ - // g_Notify->DisplayError(L"reset Controller"); - //} - if ((Value & PI_CLR_INTR) != 0 ) - { - g_Reg->MI_INTR_REG &= ~MI_INTR_PI; - g_Reg->CheckInterrupts(); - } - break; - case 0x04600014: g_Reg->PI_DOMAIN1_REG = (Value & 0xFF); break; - case 0x04600018: g_Reg->PI_BSD_DOM1_PWD_REG = (Value & 0xFF); break; - case 0x0460001C: g_Reg->PI_BSD_DOM1_PGS_REG = (Value & 0xFF); break; - case 0x04600020: g_Reg->PI_BSD_DOM1_RLS_REG = (Value & 0xFF); break; - case 0x04600024: g_Reg->PI_DOMAIN2_REG = (Value & 0xFF); break; - case 0x04600028: g_Reg->PI_BSD_DOM2_PWD_REG = (Value & 0xFF); break; - case 0x0460002C: g_Reg->PI_BSD_DOM2_PGS_REG = (Value & 0xFF); break; - case 0x04600030: g_Reg->PI_BSD_DOM2_RLS_REG = (Value & 0xFF); break; - default: - return false; - } - break; - case 0x04700000: - switch (PAddr) - { - case 0x04700000: g_Reg->RI_MODE_REG = Value; break; - case 0x04700004: g_Reg->RI_CONFIG_REG = Value; break; - case 0x04700008: g_Reg->RI_CURRENT_LOAD_REG = Value; break; - case 0x0470000C: g_Reg->RI_SELECT_REG = Value; break; - case 0x04700010: g_Reg->RI_REFRESH_REG = Value; break; - case 0x04700014: g_Reg->RI_LATENCY_REG = Value; break; - case 0x04700018: g_Reg->RI_RERROR_REG = Value; break; - case 0x0470001C: g_Reg->RI_WERROR_REG = Value; break; - default: - return false; - } - break; - case 0x04800000: - switch (PAddr) - { - case 0x04800000: g_Reg->SI_DRAM_ADDR_REG = Value; break; - case 0x04800004: - g_Reg->SI_PIF_ADDR_RD64B_REG = Value; - SI_DMA_READ (); - break; - case 0x04800010: - g_Reg->SI_PIF_ADDR_WR64B_REG = Value; - SI_DMA_WRITE(); - break; - case 0x04800018: - g_Reg->MI_INTR_REG &= ~MI_INTR_SI; - g_Reg->SI_STATUS_REG &= ~SI_STATUS_INTERRUPT; - g_Reg->CheckInterrupts(); - break; - default: - return false; - } - break; - case 0x08000000: - if (g_System->m_SaveUsing == SaveChip_Sram) - { - //Store Sram - BYTE tmp[4] = ""; - tmp[0] = 0xFF & (Value); - tmp[1] = 0xFF & (Value >> 8); - tmp[2] = 0xFF & (Value >> 16); - tmp[3] = 0xFF & (Value >> 24); - DmaFromSram(tmp, PAddr - 0x08000000, 4); - return true; - } - if (PAddr != 0x08010000) - { - return false; - } - if (g_System->m_SaveUsing == SaveChip_Auto) - { - g_System->m_SaveUsing = SaveChip_FlashRam; - } - if (g_System->m_SaveUsing != SaveChip_FlashRam) - { - return true; - } - - WriteToFlashCommand(Value); - return true; - break; - case 0x1FC00000: - if (PAddr < 0x1FC007C0) - { - return false; - } - else if (PAddr < 0x1FC00800) - { - Value = swap32by8(Value); - *(DWORD *)(&m_PifRam[PAddr - 0x1FC007C0]) = Value; - if (PAddr == 0x1FC007FC) - { - PifRamWrite(); - } - return true; - } - return false; - break; - default: - return false; - break; - } + g_Reg->VI_ORIGIN_REG = (Value & 0xFFFFFF); + //if (UpdateScreen != NULL ) + //{ + // UpdateScreen(); + //} + break; + case 0x04400008: + if (g_Reg->VI_WIDTH_REG != Value) + { + g_Reg->VI_WIDTH_REG = Value; + if (g_Plugins->Gfx()->ViWidthChanged != NULL) + { + g_Plugins->Gfx()->ViWidthChanged(); + } + } + break; + case 0x0440000C: g_Reg->VI_INTR_REG = Value; break; + case 0x04400010: + g_Reg->MI_INTR_REG &= ~MI_INTR_VI; + g_Reg->CheckInterrupts(); + break; + case 0x04400014: g_Reg->VI_BURST_REG = Value; break; + case 0x04400018: g_Reg->VI_V_SYNC_REG = Value; break; + case 0x0440001C: g_Reg->VI_H_SYNC_REG = Value; break; + case 0x04400020: g_Reg->VI_LEAP_REG = Value; break; + case 0x04400024: g_Reg->VI_H_START_REG = Value; break; + case 0x04400028: g_Reg->VI_V_START_REG = Value; break; + case 0x0440002C: g_Reg->VI_V_BURST_REG = Value; break; + case 0x04400030: g_Reg->VI_X_SCALE_REG = Value; break; + case 0x04400034: g_Reg->VI_Y_SCALE_REG = Value; break; + default: + return false; + } + break; + case 0x04500000: + switch (PAddr) + { + case 0x04500000: g_Reg->AI_DRAM_ADDR_REG = Value; break; + case 0x04500004: + g_Reg->AI_LEN_REG = Value; + if (g_System->bFixedAudio()) + { + g_Audio->LenChanged(); + } + else + { + if (g_Plugins->Audio()->AiLenChanged != NULL) + { + g_Plugins->Audio()->AiLenChanged(); + } + } + break; + case 0x04500008: g_Reg->AI_CONTROL_REG = (Value & 1); break; + case 0x0450000C: + /* Clear Interrupt */; + g_Reg->MI_INTR_REG &= ~MI_INTR_AI; + g_Reg->m_AudioIntrReg &= ~MI_INTR_AI; + g_Reg->CheckInterrupts(); + break; + case 0x04500010: + g_Reg->AI_DACRATE_REG = Value; + g_Plugins->Audio()->DacrateChanged(g_System->SystemType()); + if (g_System->bFixedAudio()) + { + g_Audio->SetFrequency(Value, g_System->SystemType()); + } + break; + case 0x04500014: g_Reg->AI_BITRATE_REG = Value; break; + default: + return false; + } + break; + case 0x04600000: + switch (PAddr) + { + case 0x04600000: g_Reg->PI_DRAM_ADDR_REG = Value; break; + case 0x04600004: g_Reg->PI_CART_ADDR_REG = Value; break; + case 0x04600008: + g_Reg->PI_RD_LEN_REG = Value; + PI_DMA_READ(); + break; + case 0x0460000C: + g_Reg->PI_WR_LEN_REG = Value; + PI_DMA_WRITE(); + break; + case 0x04600010: + //if ((Value & PI_SET_RESET) != 0 ) + //{ + // g_Notify->DisplayError(L"reset Controller"); + //} + if ((Value & PI_CLR_INTR) != 0) + { + g_Reg->MI_INTR_REG &= ~MI_INTR_PI; + g_Reg->CheckInterrupts(); + } + break; + case 0x04600014: g_Reg->PI_DOMAIN1_REG = (Value & 0xFF); break; + case 0x04600018: g_Reg->PI_BSD_DOM1_PWD_REG = (Value & 0xFF); break; + case 0x0460001C: g_Reg->PI_BSD_DOM1_PGS_REG = (Value & 0xFF); break; + case 0x04600020: g_Reg->PI_BSD_DOM1_RLS_REG = (Value & 0xFF); break; + case 0x04600024: g_Reg->PI_DOMAIN2_REG = (Value & 0xFF); break; + case 0x04600028: g_Reg->PI_BSD_DOM2_PWD_REG = (Value & 0xFF); break; + case 0x0460002C: g_Reg->PI_BSD_DOM2_PGS_REG = (Value & 0xFF); break; + case 0x04600030: g_Reg->PI_BSD_DOM2_RLS_REG = (Value & 0xFF); break; + default: + return false; + } + break; + case 0x04700000: + switch (PAddr) + { + case 0x04700000: g_Reg->RI_MODE_REG = Value; break; + case 0x04700004: g_Reg->RI_CONFIG_REG = Value; break; + case 0x04700008: g_Reg->RI_CURRENT_LOAD_REG = Value; break; + case 0x0470000C: g_Reg->RI_SELECT_REG = Value; break; + case 0x04700010: g_Reg->RI_REFRESH_REG = Value; break; + case 0x04700014: g_Reg->RI_LATENCY_REG = Value; break; + case 0x04700018: g_Reg->RI_RERROR_REG = Value; break; + case 0x0470001C: g_Reg->RI_WERROR_REG = Value; break; + default: + return false; + } + break; + case 0x04800000: + switch (PAddr) + { + case 0x04800000: g_Reg->SI_DRAM_ADDR_REG = Value; break; + case 0x04800004: + g_Reg->SI_PIF_ADDR_RD64B_REG = Value; + SI_DMA_READ(); + break; + case 0x04800010: + g_Reg->SI_PIF_ADDR_WR64B_REG = Value; + SI_DMA_WRITE(); + break; + case 0x04800018: + g_Reg->MI_INTR_REG &= ~MI_INTR_SI; + g_Reg->SI_STATUS_REG &= ~SI_STATUS_INTERRUPT; + g_Reg->CheckInterrupts(); + break; + default: + return false; + } + break; + case 0x08000000: + if (g_System->m_SaveUsing == SaveChip_Sram) + { + //Store Sram + uint8_t tmp[4] = ""; + tmp[0] = 0xFF & (Value); + tmp[1] = 0xFF & (Value >> 8); + tmp[2] = 0xFF & (Value >> 16); + tmp[3] = 0xFF & (Value >> 24); + DmaFromSram(tmp, PAddr - 0x08000000, 4); + return true; + } + if (PAddr != 0x08010000) + { + return false; + } + if (g_System->m_SaveUsing == SaveChip_Auto) + { + g_System->m_SaveUsing = SaveChip_FlashRam; + } + if (g_System->m_SaveUsing != SaveChip_FlashRam) + { + return true; + } - return true; + WriteToFlashCommand(Value); + return true; + break; + case 0x1FC00000: + if (PAddr < 0x1FC007C0) + { + return false; + } + else if (PAddr < 0x1FC00800) + { + Value = swap32by8(Value); + *(uint32_t *)(&m_PifRam[PAddr - 0x1FC007C0]) = Value; + if (PAddr == 0x1FC007FC) + { + PifRamWrite(); + } + return true; + } + return false; + break; + default: + return false; + break; + } + + return true; } void CMipsMemoryVM::UpdateHalfLine() { - DWORD NextViTimer = g_SystemTimer->GetTimer(CSystemTimer::ViTimer); + uint32_t NextViTimer = g_SystemTimer->GetTimer(CSystemTimer::ViTimer); - if (*g_NextTimer < 0) - { - m_HalfLine = 0; - return; - } + if (*g_NextTimer < 0) + { + m_HalfLine = 0; + return; + } - int check_value = (int)(m_HalfLineCheck - NextViTimer); - if (check_value > 0 && check_value < 40) - { - *g_NextTimer -= g_System->ViRefreshRate(); - if (*g_NextTimer < 0) - { - *g_NextTimer = 0 - g_System->CountPerOp(); - } - g_SystemTimer->UpdateTimers(); - NextViTimer = g_SystemTimer->GetTimer(CSystemTimer::ViTimer); - } - m_HalfLine = (DWORD)(*g_NextTimer / g_System->ViRefreshRate()); - m_HalfLine &= ~1; - m_HalfLine |= m_FieldSerration; - g_Reg->VI_V_CURRENT_LINE_REG = m_HalfLine; - m_HalfLineCheck = NextViTimer; + int32_t check_value = (int32_t)(m_HalfLineCheck - NextViTimer); + if (check_value > 0 && check_value < 40) + { + *g_NextTimer -= g_System->ViRefreshRate(); + if (*g_NextTimer < 0) + { + *g_NextTimer = 0 - g_System->CountPerOp(); + } + g_SystemTimer->UpdateTimers(); + NextViTimer = g_SystemTimer->GetTimer(CSystemTimer::ViTimer); + } + m_HalfLine = (uint32_t)(*g_NextTimer / g_System->ViRefreshRate()); + m_HalfLine &= ~1; + m_HalfLine |= m_FieldSerration; + g_Reg->VI_V_CURRENT_LINE_REG = m_HalfLine; + m_HalfLineCheck = NextViTimer; } -void CMipsMemoryVM::UpdateFieldSerration (unsigned int interlaced) +void CMipsMemoryVM::UpdateFieldSerration(uint32_t interlaced) { - m_FieldSerration ^= 1; - m_FieldSerration &= interlaced; + m_FieldSerration ^= 1; + m_FieldSerration &= interlaced; } -void CMipsMemoryVM::ProtectMemory( DWORD StartVaddr, DWORD EndVaddr ) +void CMipsMemoryVM::ProtectMemory(uint32_t StartVaddr, uint32_t EndVaddr) { - WriteTraceF(TraceProtectedMem,__FUNCTION__ ": StartVaddr: %08X EndVaddr: %08X",StartVaddr,EndVaddr); - if (!ValidVaddr(StartVaddr) || !ValidVaddr(EndVaddr)) - { - return; - } + WriteTraceF(TraceProtectedMem, __FUNCTION__ ": StartVaddr: %08X EndVaddr: %08X", StartVaddr, EndVaddr); + if (!ValidVaddr(StartVaddr) || !ValidVaddr(EndVaddr)) + { + return; + } - //Get Physical Addresses passed - DWORD StartPAddr, EndPAddr; - if (!TranslateVaddr(StartVaddr,StartPAddr)) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (!TranslateVaddr(EndVaddr,EndPAddr)) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - //Get Length of memory being protected - int Length = ((EndPAddr + 3) - StartPAddr) & ~3; - if (Length < 0) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + //Get Physical Addresses passed + uint32_t StartPAddr, EndPAddr; + if (!TranslateVaddr(StartVaddr, StartPAddr)) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + if (!TranslateVaddr(EndVaddr, EndPAddr)) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } - //Protect that memory address space - DWORD OldProtect; - BYTE * MemLoc = Rdram() + StartPAddr; - WriteTraceF(TraceProtectedMem, __FUNCTION__ ": Paddr: %08X Length: %X",StartPAddr,Length); - - VirtualProtect(MemLoc, Length, PAGE_READONLY, &OldProtect); + //Get Length of memory being protected + int32_t Length = ((EndPAddr + 3) - StartPAddr) & ~3; + if (Length < 0) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + + //Protect that memory address space + DWORD OldProtect; + uint8_t * MemLoc = Rdram() + StartPAddr; + WriteTraceF(TraceProtectedMem, __FUNCTION__ ": Paddr: %08X Length: %X", StartPAddr, Length); + + VirtualProtect(MemLoc, Length, PAGE_READONLY, &OldProtect); } -void CMipsMemoryVM::UnProtectMemory( DWORD StartVaddr, DWORD EndVaddr ) +void CMipsMemoryVM::UnProtectMemory(uint32_t StartVaddr, uint32_t EndVaddr) { - WriteTraceF(TraceProtectedMem,__FUNCTION__ ": StartVaddr: %08X EndVaddr: %08X",StartVaddr,EndVaddr); - if (!ValidVaddr(StartVaddr) || !ValidVaddr(EndVaddr)) { return; } + WriteTraceF(TraceProtectedMem, __FUNCTION__ ": StartVaddr: %08X EndVaddr: %08X", StartVaddr, EndVaddr); + if (!ValidVaddr(StartVaddr) || !ValidVaddr(EndVaddr)) { return; } - //Get Physical Addresses passed - DWORD StartPAddr, EndPAddr; - if (!TranslateVaddr(StartVaddr,StartPAddr)) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (!TranslateVaddr(EndVaddr,EndPAddr)) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - //Get Length of memory being protected - int Length = ((EndPAddr + 3) - StartPAddr) & ~3; - if (Length < 0) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + //Get Physical Addresses passed + uint32_t StartPAddr, EndPAddr; + if (!TranslateVaddr(StartVaddr, StartPAddr)) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + if (!TranslateVaddr(EndVaddr, EndPAddr)) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } - //Protect that memory address space - DWORD OldProtect; - BYTE * MemLoc = Rdram() + StartPAddr; - - VirtualProtect(MemLoc, Length, PAGE_READWRITE, &OldProtect); + //Get Length of memory being protected + int32_t Length = ((EndPAddr + 3) - StartPAddr) & ~3; + if (Length < 0) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + + //Protect that memory address space + DWORD OldProtect; + uint8_t * MemLoc = Rdram() + StartPAddr; + + VirtualProtect(MemLoc, Length, PAGE_READWRITE, &OldProtect); } -void CMipsMemoryVM::Compile_LB() +void CMipsMemoryVM::Compile_LB() { - OPCODE & Opcode = CRecompilerOps::m_Opcode; - x86Reg TempReg1, TempReg2; + OPCODE & Opcode = CRecompilerOps::m_Opcode; + x86Reg TempReg1, TempReg2; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - if (Opcode.rt == 0) - { - return; - } + if (Opcode.rt == 0) + { + return; + } - if (IsConst(Opcode.base)) - { - DWORD Address = (GetMipsRegLo(Opcode.base) + (short)Opcode.offset) ^ 3; - Map_GPR_32bit(Opcode.rt, true, -1); - Compile_LB(GetMipsRegMapLo(Opcode.rt), Address, true); - return; - } - if (IsMapped(Opcode.rt)) - { - ProtectGPR(Opcode.rt); - } - if (IsMapped(Opcode.base)) - { - ProtectGPR(Opcode.base); - if (Opcode.offset != 0) - { - TempReg1 = Map_TempReg(x86_Any, -1, false); - LeaSourceAndOffset(TempReg1,GetMipsRegMapLo(Opcode.base),(short)Opcode.offset); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - } - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - AddConstToX86Reg(TempReg1,(short)Opcode.immediate); - } - if (g_System->bUseTlb()) - { - TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); - CompileReadTLBMiss(TempReg1,TempReg2); - XorConstToX86Reg(TempReg1,3); - Map_GPR_32bit(Opcode.rt, true, -1); - MoveSxByteX86regPointerToX86reg(TempReg1, TempReg2,GetMipsRegMapLo(Opcode.rt)); - } - else - { - AndConstToX86Reg(TempReg1,0x1FFFFFFF); - XorConstToX86Reg(TempReg1,3); - Map_GPR_32bit(Opcode.rt, true, -1); - MoveSxN64MemToX86regByte(GetMipsRegMapLo(Opcode.rt), TempReg1); - } + if (IsConst(Opcode.base)) + { + uint32_t Address = (GetMipsRegLo(Opcode.base) + (int16_t)Opcode.offset) ^ 3; + Map_GPR_32bit(Opcode.rt, true, -1); + Compile_LB(GetMipsRegMapLo(Opcode.rt), Address, true); + return; + } + if (IsMapped(Opcode.rt)) + { + ProtectGPR(Opcode.rt); + } + if (IsMapped(Opcode.base)) + { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) + { + TempReg1 = Map_TempReg(x86_Any, -1, false); + LeaSourceAndOffset(TempReg1, GetMipsRegMapLo(Opcode.base), (int16_t)Opcode.offset); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + } + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + AddConstToX86Reg(TempReg1, (int16_t)Opcode.immediate); + } + if (g_System->bUseTlb()) + { + TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_ReadMap, "m_TLB_ReadMap", TempReg2, TempReg2, 4); + CompileReadTLBMiss(TempReg1, TempReg2); + XorConstToX86Reg(TempReg1, 3); + Map_GPR_32bit(Opcode.rt, true, -1); + MoveSxByteX86regPointerToX86reg(TempReg1, TempReg2, GetMipsRegMapLo(Opcode.rt)); + } + else + { + AndConstToX86Reg(TempReg1, 0x1FFFFFFF); + XorConstToX86Reg(TempReg1, 3); + Map_GPR_32bit(Opcode.rt, true, -1); + MoveSxN64MemToX86regByte(GetMipsRegMapLo(Opcode.rt), TempReg1); + } } -void CMipsMemoryVM::Compile_LBU() +void CMipsMemoryVM::Compile_LBU() { - OPCODE & Opcode = CRecompilerOps::m_Opcode; - x86Reg TempReg1, TempReg2; + OPCODE & Opcode = CRecompilerOps::m_Opcode; + x86Reg TempReg1, TempReg2; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - if (Opcode.rt == 0) - { - return; - } + if (Opcode.rt == 0) + { + return; + } - if (IsConst(Opcode.base)) - { - DWORD Address = (GetMipsRegLo(Opcode.base) + (short)Opcode.offset) ^ 3; - Map_GPR_32bit(Opcode.rt, false, -1); - Compile_LB(GetMipsRegMapLo(Opcode.rt), Address, false); - return; - } - if (IsMapped(Opcode.rt)) - { - ProtectGPR(Opcode.rt); - } - if (IsMapped(Opcode.base)) - { - ProtectGPR(Opcode.base); - if (Opcode.offset != 0) - { - TempReg1 = Map_TempReg(x86_Any, -1, false); - LeaSourceAndOffset(TempReg1,GetMipsRegMapLo(Opcode.base),(short)Opcode.offset); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - } - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - AddConstToX86Reg(TempReg1,(short)Opcode.immediate); - } - if (g_System->bUseTlb()) - { - TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); - CompileReadTLBMiss(TempReg1,TempReg2); - XorConstToX86Reg(TempReg1,3); - Map_GPR_32bit(Opcode.rt, false, -1); - MoveZxByteX86regPointerToX86reg(TempReg1, TempReg2,GetMipsRegMapLo(Opcode.rt)); - } - else - { - AndConstToX86Reg(TempReg1,0x1FFFFFFF); - XorConstToX86Reg(TempReg1,3); - Map_GPR_32bit(Opcode.rt, false, -1); - MoveZxN64MemToX86regByte(GetMipsRegMapLo(Opcode.rt), TempReg1); - } + if (IsConst(Opcode.base)) + { + uint32_t Address = (GetMipsRegLo(Opcode.base) + (int16_t)Opcode.offset) ^ 3; + Map_GPR_32bit(Opcode.rt, false, -1); + Compile_LB(GetMipsRegMapLo(Opcode.rt), Address, false); + return; + } + if (IsMapped(Opcode.rt)) + { + ProtectGPR(Opcode.rt); + } + if (IsMapped(Opcode.base)) + { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) + { + TempReg1 = Map_TempReg(x86_Any, -1, false); + LeaSourceAndOffset(TempReg1, GetMipsRegMapLo(Opcode.base), (int16_t)Opcode.offset); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + } + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + AddConstToX86Reg(TempReg1, (int16_t)Opcode.immediate); + } + if (g_System->bUseTlb()) + { + TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_ReadMap, "m_TLB_ReadMap", TempReg2, TempReg2, 4); + CompileReadTLBMiss(TempReg1, TempReg2); + XorConstToX86Reg(TempReg1, 3); + Map_GPR_32bit(Opcode.rt, false, -1); + MoveZxByteX86regPointerToX86reg(TempReg1, TempReg2, GetMipsRegMapLo(Opcode.rt)); + } + else + { + AndConstToX86Reg(TempReg1, 0x1FFFFFFF); + XorConstToX86Reg(TempReg1, 3); + Map_GPR_32bit(Opcode.rt, false, -1); + MoveZxN64MemToX86regByte(GetMipsRegMapLo(Opcode.rt), TempReg1); + } } void CMipsMemoryVM::Compile_LH() { - OPCODE & Opcode = CRecompilerOps::m_Opcode; - x86Reg TempReg1, TempReg2; + OPCODE & Opcode = CRecompilerOps::m_Opcode; + x86Reg TempReg1, TempReg2; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - if (Opcode.rt == 0) return; + if (Opcode.rt == 0) return; - if (IsConst(Opcode.base)) - { - DWORD Address = (GetMipsRegLo(Opcode.base) + (short)Opcode.offset) ^ 2; - Map_GPR_32bit(Opcode.rt, true, -1); - Compile_LH(GetMipsRegMapLo(Opcode.rt), Address, true); - return; - } - if (IsMapped(Opcode.rt)) - { - ProtectGPR(Opcode.rt); - } - if (IsMapped(Opcode.base)) - { - ProtectGPR(Opcode.base); - if (Opcode.offset != 0) - { - TempReg1 = Map_TempReg(x86_Any, -1, false); - LeaSourceAndOffset(TempReg1,GetMipsRegMapLo(Opcode.base),(short)Opcode.offset); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - } - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - AddConstToX86Reg(TempReg1,(short)Opcode.immediate); - } - if (g_System->bUseTlb()) - { - TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); - CompileReadTLBMiss(TempReg1,TempReg2); - XorConstToX86Reg(TempReg1,2); - Map_GPR_32bit(Opcode.rt, true, -1); - MoveSxHalfX86regPointerToX86reg(TempReg1, TempReg2,GetMipsRegMapLo(Opcode.rt)); - } - else - { - AndConstToX86Reg(TempReg1,0x1FFFFFFF); - XorConstToX86Reg(TempReg1,2); - Map_GPR_32bit(Opcode.rt, true, -1); - MoveSxN64MemToX86regHalf(GetMipsRegMapLo(Opcode.rt), TempReg1); - } + if (IsConst(Opcode.base)) + { + uint32_t Address = (GetMipsRegLo(Opcode.base) + (int16_t)Opcode.offset) ^ 2; + Map_GPR_32bit(Opcode.rt, true, -1); + Compile_LH(GetMipsRegMapLo(Opcode.rt), Address, true); + return; + } + if (IsMapped(Opcode.rt)) + { + ProtectGPR(Opcode.rt); + } + if (IsMapped(Opcode.base)) + { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) + { + TempReg1 = Map_TempReg(x86_Any, -1, false); + LeaSourceAndOffset(TempReg1, GetMipsRegMapLo(Opcode.base), (int16_t)Opcode.offset); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + } + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + AddConstToX86Reg(TempReg1, (int16_t)Opcode.immediate); + } + if (g_System->bUseTlb()) + { + TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_ReadMap, "m_TLB_ReadMap", TempReg2, TempReg2, 4); + CompileReadTLBMiss(TempReg1, TempReg2); + XorConstToX86Reg(TempReg1, 2); + Map_GPR_32bit(Opcode.rt, true, -1); + MoveSxHalfX86regPointerToX86reg(TempReg1, TempReg2, GetMipsRegMapLo(Opcode.rt)); + } + else + { + AndConstToX86Reg(TempReg1, 0x1FFFFFFF); + XorConstToX86Reg(TempReg1, 2); + Map_GPR_32bit(Opcode.rt, true, -1); + MoveSxN64MemToX86regHalf(GetMipsRegMapLo(Opcode.rt), TempReg1); + } } -void CMipsMemoryVM::Compile_LHU() +void CMipsMemoryVM::Compile_LHU() { - OPCODE & Opcode = CRecompilerOps::m_Opcode; - x86Reg TempReg1, TempReg2; + OPCODE & Opcode = CRecompilerOps::m_Opcode; + x86Reg TempReg1, TempReg2; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - if (Opcode.rt == 0) - { - return; - } + if (Opcode.rt == 0) + { + return; + } - if (IsConst(Opcode.base)) - { - DWORD Address = (GetMipsRegLo(Opcode.base) + (short)Opcode.offset) ^ 2; - Map_GPR_32bit(Opcode.rt, false, -1); - Compile_LH(GetMipsRegMapLo(Opcode.rt), Address, false); - return; - } - if (IsMapped(Opcode.rt)) - { - ProtectGPR(Opcode.rt); - } - if (IsMapped(Opcode.base)) - { - ProtectGPR(Opcode.base); - if (Opcode.offset != 0) - { - TempReg1 = Map_TempReg(x86_Any, -1, false); - LeaSourceAndOffset(TempReg1,GetMipsRegMapLo(Opcode.base),(short)Opcode.offset); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - } - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - AddConstToX86Reg(TempReg1,(short)Opcode.immediate); - } - if (g_System->bUseTlb()) - { - TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); - CompileReadTLBMiss(TempReg1,TempReg2); - XorConstToX86Reg(TempReg1,2); - Map_GPR_32bit(Opcode.rt, false, -1); - MoveZxHalfX86regPointerToX86reg(TempReg1, TempReg2,GetMipsRegMapLo(Opcode.rt)); - } - else - { - AndConstToX86Reg(TempReg1,0x1FFFFFFF); - XorConstToX86Reg(TempReg1,2); - Map_GPR_32bit(Opcode.rt, true, -1); - MoveZxN64MemToX86regHalf(GetMipsRegMapLo(Opcode.rt), TempReg1); - } + if (IsConst(Opcode.base)) + { + uint32_t Address = (GetMipsRegLo(Opcode.base) + (int16_t)Opcode.offset) ^ 2; + Map_GPR_32bit(Opcode.rt, false, -1); + Compile_LH(GetMipsRegMapLo(Opcode.rt), Address, false); + return; + } + if (IsMapped(Opcode.rt)) + { + ProtectGPR(Opcode.rt); + } + if (IsMapped(Opcode.base)) + { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) + { + TempReg1 = Map_TempReg(x86_Any, -1, false); + LeaSourceAndOffset(TempReg1, GetMipsRegMapLo(Opcode.base), (int16_t)Opcode.offset); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + } + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + AddConstToX86Reg(TempReg1, (int16_t)Opcode.immediate); + } + if (g_System->bUseTlb()) + { + TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_ReadMap, "m_TLB_ReadMap", TempReg2, TempReg2, 4); + CompileReadTLBMiss(TempReg1, TempReg2); + XorConstToX86Reg(TempReg1, 2); + Map_GPR_32bit(Opcode.rt, false, -1); + MoveZxHalfX86regPointerToX86reg(TempReg1, TempReg2, GetMipsRegMapLo(Opcode.rt)); + } + else + { + AndConstToX86Reg(TempReg1, 0x1FFFFFFF); + XorConstToX86Reg(TempReg1, 2); + Map_GPR_32bit(Opcode.rt, true, -1); + MoveZxN64MemToX86regHalf(GetMipsRegMapLo(Opcode.rt), TempReg1); + } } -void CMipsMemoryVM::Compile_LW() +void CMipsMemoryVM::Compile_LW() { - Compile_LW(true,false); + Compile_LW(true, false); } -void CMipsMemoryVM::Compile_LL() +void CMipsMemoryVM::Compile_LL() { - Compile_LW(true,true); + Compile_LW(true, true); } -void CMipsMemoryVM::Compile_LW (bool ResultSigned, bool bRecordLLBit) +void CMipsMemoryVM::Compile_LW(bool ResultSigned, bool bRecordLLBit) { - OPCODE & Opcode = CRecompilerOps::m_Opcode; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + OPCODE & Opcode = CRecompilerOps::m_Opcode; + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - if (Opcode.rt == 0) return; + if (Opcode.rt == 0) return; - x86Reg TempReg1, TempReg2; - if (Opcode.base == 29 && g_System->bFastSP()) - { - char String[100]; + x86Reg TempReg1, TempReg2; + if (Opcode.base == 29 && g_System->bFastSP()) + { + char String[100]; - Map_GPR_32bit(Opcode.rt,ResultSigned,-1); - TempReg1 = Map_MemoryStack(x86_Any,true); - sprintf(String,"%Xh",(short)Opcode.offset); - MoveVariableDispToX86Reg((void *)((DWORD)(short)Opcode.offset),String,GetMipsRegMapLo(Opcode.rt),TempReg1,1); - if (bRecordLLBit) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } - else - { - if (IsConst(Opcode.base)) - { - DWORD Address = GetMipsRegLo(Opcode.base) + (short)Opcode.offset; - Map_GPR_32bit(Opcode.rt,ResultSigned,-1); - Compile_LW(GetMipsRegMapLo(Opcode.rt),Address); - if (bRecordLLBit) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } - else - { - if (g_System->bUseTlb()) - { - if (IsMapped(Opcode.rt)) - { - ProtectGPR(Opcode.rt); - } - if (IsMapped(Opcode.base) && Opcode.offset == 0) - { - ProtectGPR(Opcode.base); - TempReg1 = GetMipsRegMapLo(Opcode.base); - } - else - { - if (IsMapped(Opcode.base)) - { - ProtectGPR(Opcode.base); - if (Opcode.offset != 0) { - TempReg1 = Map_TempReg(x86_Any, -1, false); - LeaSourceAndOffset(TempReg1,GetMipsRegMapLo(Opcode.base),(short)Opcode.offset); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - } - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - AddConstToX86Reg(TempReg1,(short)Opcode.immediate); - } - } - TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); - CompileReadTLBMiss(TempReg1,TempReg2); - Map_GPR_32bit(Opcode.rt,ResultSigned,-1); - MoveX86regPointerToX86reg(TempReg1, TempReg2,GetMipsRegMapLo(Opcode.rt)); - if (bRecordLLBit) - { - MoveConstToVariable(1,_LLBit,"LLBit"); - } - } - else - { - if (IsMapped(Opcode.base)) - { - ProtectGPR(Opcode.base); - if (Opcode.offset != 0) - { - Map_GPR_32bit(Opcode.rt,ResultSigned,-1); - LeaSourceAndOffset(GetMipsRegMapLo(Opcode.rt),GetMipsRegMapLo(Opcode.base),(short)Opcode.offset); - } - else - { - Map_GPR_32bit(Opcode.rt,ResultSigned,Opcode.base); - } - } - else - { - Map_GPR_32bit(Opcode.rt,ResultSigned,Opcode.base); - AddConstToX86Reg(GetMipsRegMapLo(Opcode.rt),(short)Opcode.immediate); - } - AndConstToX86Reg(GetMipsRegMapLo(Opcode.rt),0x1FFFFFFF); - MoveN64MemToX86reg(GetMipsRegMapLo(Opcode.rt),GetMipsRegMapLo(Opcode.rt)); - if (bRecordLLBit) - { - MoveConstToVariable(1,_LLBit,"LLBit"); - } - } - } - } - if (g_System->bFastSP() && Opcode.rt == 29) - { - ResetX86Protection(); - ResetMemoryStack(); - } + Map_GPR_32bit(Opcode.rt, ResultSigned, -1); + TempReg1 = Map_MemoryStack(x86_Any, true); + sprintf(String, "%Xh", (int16_t)Opcode.offset); + MoveVariableDispToX86Reg((void *)((uint32_t)(int16_t)Opcode.offset), String, GetMipsRegMapLo(Opcode.rt), TempReg1, 1); + if (bRecordLLBit) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } + else + { + if (IsConst(Opcode.base)) + { + uint32_t Address = GetMipsRegLo(Opcode.base) + (int16_t)Opcode.offset; + Map_GPR_32bit(Opcode.rt, ResultSigned, -1); + Compile_LW(GetMipsRegMapLo(Opcode.rt), Address); + if (bRecordLLBit) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } + else + { + if (g_System->bUseTlb()) + { + if (IsMapped(Opcode.rt)) + { + ProtectGPR(Opcode.rt); + } + if (IsMapped(Opcode.base) && Opcode.offset == 0) + { + ProtectGPR(Opcode.base); + TempReg1 = GetMipsRegMapLo(Opcode.base); + } + else + { + if (IsMapped(Opcode.base)) + { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) { + TempReg1 = Map_TempReg(x86_Any, -1, false); + LeaSourceAndOffset(TempReg1, GetMipsRegMapLo(Opcode.base), (int16_t)Opcode.offset); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + } + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + AddConstToX86Reg(TempReg1, (int16_t)Opcode.immediate); + } + } + TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_ReadMap, "m_TLB_ReadMap", TempReg2, TempReg2, 4); + CompileReadTLBMiss(TempReg1, TempReg2); + Map_GPR_32bit(Opcode.rt, ResultSigned, -1); + MoveX86regPointerToX86reg(TempReg1, TempReg2, GetMipsRegMapLo(Opcode.rt)); + if (bRecordLLBit) + { + MoveConstToVariable(1, _LLBit, "LLBit"); + } + } + else + { + if (IsMapped(Opcode.base)) + { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) + { + Map_GPR_32bit(Opcode.rt, ResultSigned, -1); + LeaSourceAndOffset(GetMipsRegMapLo(Opcode.rt), GetMipsRegMapLo(Opcode.base), (int16_t)Opcode.offset); + } + else + { + Map_GPR_32bit(Opcode.rt, ResultSigned, Opcode.base); + } + } + else + { + Map_GPR_32bit(Opcode.rt, ResultSigned, Opcode.base); + AddConstToX86Reg(GetMipsRegMapLo(Opcode.rt), (int16_t)Opcode.immediate); + } + AndConstToX86Reg(GetMipsRegMapLo(Opcode.rt), 0x1FFFFFFF); + MoveN64MemToX86reg(GetMipsRegMapLo(Opcode.rt), GetMipsRegMapLo(Opcode.rt)); + if (bRecordLLBit) + { + MoveConstToVariable(1, _LLBit, "LLBit"); + } + } + } + } + if (g_System->bFastSP() && Opcode.rt == 29) + { + ResetX86Protection(); + ResetMemoryStack(); + } } -void CMipsMemoryVM::Compile_LWC1() +void CMipsMemoryVM::Compile_LWC1() { - OPCODE & Opcode = CRecompilerOps::m_Opcode; - x86Reg TempReg1, TempReg2, TempReg3; - char Name[50]; + OPCODE & Opcode = CRecompilerOps::m_Opcode; + x86Reg TempReg1, TempReg2, TempReg3; + char Name[50]; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - m_Section->CompileCop1Test(); - if ((Opcode.ft & 1) != 0) - { - if (RegInStack(Opcode.ft-1,CRegInfo::FPU_Double) || RegInStack(Opcode.ft-1,CRegInfo::FPU_Qword)) - { - UnMap_FPR(Opcode.ft - 1, true); - } - } - if (RegInStack(Opcode.ft,CRegInfo::FPU_Double) || RegInStack(Opcode.ft,CRegInfo::FPU_Qword)) - { - UnMap_FPR(Opcode.ft, true); - } - else - { - UnMap_FPR(Opcode.ft, false); - } - if (IsConst(Opcode.base)) - { - DWORD Address = GetMipsRegLo(Opcode.base) + (short)Opcode.offset; + m_Section->CompileCop1Test(); + if ((Opcode.ft & 1) != 0) + { + if (RegInStack(Opcode.ft - 1, CRegInfo::FPU_Double) || RegInStack(Opcode.ft - 1, CRegInfo::FPU_Qword)) + { + UnMap_FPR(Opcode.ft - 1, true); + } + } + if (RegInStack(Opcode.ft, CRegInfo::FPU_Double) || RegInStack(Opcode.ft, CRegInfo::FPU_Qword)) + { + UnMap_FPR(Opcode.ft, true); + } + else + { + UnMap_FPR(Opcode.ft, false); + } + if (IsConst(Opcode.base)) + { + uint32_t Address = GetMipsRegLo(Opcode.base) + (int16_t)Opcode.offset; - TempReg1 = Map_TempReg(x86_Any, -1, false); - Compile_LW(TempReg1,Address); + TempReg1 = Map_TempReg(x86_Any, -1, false); + Compile_LW(TempReg1, Address); - TempReg2 = Map_TempReg(x86_Any, -1, false); - sprintf(Name,"_FPR_S[%d]",Opcode.ft); - MoveVariableToX86reg(&_FPR_S[Opcode.ft],Name,TempReg2); - MoveX86regToX86Pointer(TempReg1,TempReg2); - return; - } - if (IsMapped(Opcode.base) && Opcode.offset == 0) - { - if (g_System->bUseTlb()) - { - ProtectGPR(Opcode.base); - TempReg1 = GetMipsRegMapLo(Opcode.base); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - } - } - else - { - if (IsMapped(Opcode.base)) - { - ProtectGPR(Opcode.base); - if (Opcode.offset != 0) - { - TempReg1 = Map_TempReg(x86_Any, -1, false); - LeaSourceAndOffset(TempReg1,GetMipsRegMapLo(Opcode.base),(short)Opcode.offset); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - } - UnProtectGPR(Opcode.base); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - if (Opcode.immediate == 0) - { - - } - else if (Opcode.immediate == 1) - { - IncX86reg(TempReg1); - } - else if (Opcode.immediate == 0xFFFF) - { - DecX86reg(TempReg1); - } - else - { - AddConstToX86Reg(TempReg1,(short)Opcode.immediate); - } - } - } - TempReg2 = Map_TempReg(x86_Any, -1, false); - if (g_System->bUseTlb()) - { - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); - CompileReadTLBMiss(TempReg1,TempReg2); - - TempReg3 = Map_TempReg(x86_Any, -1, false); - MoveX86regPointerToX86reg(TempReg1, TempReg2,TempReg3); - } - else - { - AndConstToX86Reg(TempReg1,0x1FFFFFFF); - TempReg3 = Map_TempReg(x86_Any, -1, false); - MoveN64MemToX86reg(TempReg3,TempReg1); - } - sprintf(Name,"_FPR_S[%d]",Opcode.ft); - MoveVariableToX86reg(&_FPR_S[Opcode.ft],Name,TempReg2); - MoveX86regToX86Pointer(TempReg3,TempReg2); + TempReg2 = Map_TempReg(x86_Any, -1, false); + sprintf(Name, "_FPR_S[%d]", Opcode.ft); + MoveVariableToX86reg(&_FPR_S[Opcode.ft], Name, TempReg2); + MoveX86regToX86Pointer(TempReg1, TempReg2); + return; + } + if (IsMapped(Opcode.base) && Opcode.offset == 0) + { + if (g_System->bUseTlb()) + { + ProtectGPR(Opcode.base); + TempReg1 = GetMipsRegMapLo(Opcode.base); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + } + } + else + { + if (IsMapped(Opcode.base)) + { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) + { + TempReg1 = Map_TempReg(x86_Any, -1, false); + LeaSourceAndOffset(TempReg1, GetMipsRegMapLo(Opcode.base), (int16_t)Opcode.offset); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + } + UnProtectGPR(Opcode.base); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + if (Opcode.immediate == 0) + { + } + else if (Opcode.immediate == 1) + { + IncX86reg(TempReg1); + } + else if (Opcode.immediate == 0xFFFF) + { + DecX86reg(TempReg1); + } + else + { + AddConstToX86Reg(TempReg1, (int16_t)Opcode.immediate); + } + } + } + TempReg2 = Map_TempReg(x86_Any, -1, false); + if (g_System->bUseTlb()) + { + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_ReadMap, "m_TLB_ReadMap", TempReg2, TempReg2, 4); + CompileReadTLBMiss(TempReg1, TempReg2); + + TempReg3 = Map_TempReg(x86_Any, -1, false); + MoveX86regPointerToX86reg(TempReg1, TempReg2, TempReg3); + } + else + { + AndConstToX86Reg(TempReg1, 0x1FFFFFFF); + TempReg3 = Map_TempReg(x86_Any, -1, false); + MoveN64MemToX86reg(TempReg3, TempReg1); + } + sprintf(Name, "_FPR_S[%d]", Opcode.ft); + MoveVariableToX86reg(&_FPR_S[Opcode.ft], Name, TempReg2); + MoveX86regToX86Pointer(TempReg3, TempReg2); } -void CMipsMemoryVM::Compile_LWL() +void CMipsMemoryVM::Compile_LWL() { - OPCODE & Opcode = CRecompilerOps::m_Opcode; - x86Reg TempReg1 = x86_Unknown, TempReg2 = x86_Unknown, OffsetReg = x86_Unknown, shift = x86_Unknown; + OPCODE & Opcode = CRecompilerOps::m_Opcode; + x86Reg TempReg1 = x86_Unknown, TempReg2 = x86_Unknown, OffsetReg = x86_Unknown, shift = x86_Unknown; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - if (Opcode.rt == 0) - { - return; - } + if (Opcode.rt == 0) + { + return; + } - if (IsConst(Opcode.base)) - { - DWORD Address = GetMipsRegLo(Opcode.base) + (short)Opcode.offset; - DWORD Offset = Address & 3; + if (IsConst(Opcode.base)) + { + uint32_t Address = GetMipsRegLo(Opcode.base) + (int16_t)Opcode.offset; + uint32_t Offset = Address & 3; - Map_GPR_32bit(Opcode.rt, true, Opcode.rt); - x86Reg Value = Map_TempReg(x86_Any, -1, false); - Compile_LW(Value,(Address & ~3)); - AndConstToX86Reg(GetMipsRegMapLo(Opcode.rt),LWL_MASK[Offset]); - ShiftLeftSignImmed(Value,(BYTE)LWL_SHIFT[Offset]); - AddX86RegToX86Reg(GetMipsRegMapLo(Opcode.rt),Value); - return; - } + Map_GPR_32bit(Opcode.rt, true, Opcode.rt); + x86Reg Value = Map_TempReg(x86_Any, -1, false); + Compile_LW(Value, (Address & ~3)); + AndConstToX86Reg(GetMipsRegMapLo(Opcode.rt), LWL_MASK[Offset]); + ShiftLeftSignImmed(Value, (uint8_t)LWL_SHIFT[Offset]); + AddX86RegToX86Reg(GetMipsRegMapLo(Opcode.rt), Value); + return; + } - shift = Map_TempReg(x86_ECX, -1, false); - if (IsMapped(Opcode.rt)) - { - ProtectGPR(Opcode.rt); - } - if (IsMapped(Opcode.base)) - { - ProtectGPR(Opcode.base); - if (Opcode.offset != 0) - { - TempReg1 = Map_TempReg(x86_Any, -1, false); - LeaSourceAndOffset(TempReg1,GetMipsRegMapLo(Opcode.base),(short)Opcode.offset); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - } - UnProtectGPR(Opcode.base); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - AddConstToX86Reg(TempReg1,(short)Opcode.immediate); - } - if (g_System->bUseTlb()) - { - TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); - - CompileReadTLBMiss(TempReg1,TempReg2); - } - OffsetReg = Map_TempReg(x86_Any, -1, false); - MoveX86RegToX86Reg(TempReg1, OffsetReg); - AndConstToX86Reg(OffsetReg,3); - AndConstToX86Reg(TempReg1,(DWORD)~3); + shift = Map_TempReg(x86_ECX, -1, false); + if (IsMapped(Opcode.rt)) + { + ProtectGPR(Opcode.rt); + } + if (IsMapped(Opcode.base)) + { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) + { + TempReg1 = Map_TempReg(x86_Any, -1, false); + LeaSourceAndOffset(TempReg1, GetMipsRegMapLo(Opcode.base), (int16_t)Opcode.offset); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + } + UnProtectGPR(Opcode.base); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + AddConstToX86Reg(TempReg1, (int16_t)Opcode.immediate); + } + if (g_System->bUseTlb()) + { + TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_ReadMap, "m_TLB_ReadMap", TempReg2, TempReg2, 4); - Map_GPR_32bit(Opcode.rt, true, Opcode.rt); - AndVariableDispToX86Reg((void *)LWL_MASK,"LWL_MASK",GetMipsRegMapLo(Opcode.rt),OffsetReg,Multip_x4); - MoveVariableDispToX86Reg((void *)LWL_SHIFT,"LWL_SHIFT",shift,OffsetReg,4); - if (g_System->bUseTlb()) - { - MoveX86regPointerToX86reg(TempReg1, TempReg2,TempReg1); - } - else - { - AndConstToX86Reg(TempReg1,0x1FFFFFFF); - MoveN64MemToX86reg(TempReg1,TempReg1); - } - ShiftLeftSign(TempReg1); - AddX86RegToX86Reg(GetMipsRegMapLo(Opcode.rt),TempReg1); + CompileReadTLBMiss(TempReg1, TempReg2); + } + OffsetReg = Map_TempReg(x86_Any, -1, false); + MoveX86RegToX86Reg(TempReg1, OffsetReg); + AndConstToX86Reg(OffsetReg, 3); + AndConstToX86Reg(TempReg1, (uint32_t)~3); + + Map_GPR_32bit(Opcode.rt, true, Opcode.rt); + AndVariableDispToX86Reg((void *)LWL_MASK, "LWL_MASK", GetMipsRegMapLo(Opcode.rt), OffsetReg, Multip_x4); + MoveVariableDispToX86Reg((void *)LWL_SHIFT, "LWL_SHIFT", shift, OffsetReg, 4); + if (g_System->bUseTlb()) + { + MoveX86regPointerToX86reg(TempReg1, TempReg2, TempReg1); + } + else + { + AndConstToX86Reg(TempReg1, 0x1FFFFFFF); + MoveN64MemToX86reg(TempReg1, TempReg1); + } + ShiftLeftSign(TempReg1); + AddX86RegToX86Reg(GetMipsRegMapLo(Opcode.rt), TempReg1); } -void CMipsMemoryVM::Compile_LWR() +void CMipsMemoryVM::Compile_LWR() { - OPCODE & Opcode = CRecompilerOps::m_Opcode; - x86Reg TempReg1 = x86_Unknown, TempReg2 = x86_Unknown, OffsetReg = x86_Unknown, shift = x86_Unknown; + OPCODE & Opcode = CRecompilerOps::m_Opcode; + x86Reg TempReg1 = x86_Unknown, TempReg2 = x86_Unknown, OffsetReg = x86_Unknown, shift = x86_Unknown; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - if (Opcode.rt == 0) - { - return; - } + if (Opcode.rt == 0) + { + return; + } - if (IsConst(Opcode.base)) - { - DWORD Address = GetMipsRegLo(Opcode.base) + (short)Opcode.offset; - DWORD Offset = Address & 3; + if (IsConst(Opcode.base)) + { + uint32_t Address = GetMipsRegLo(Opcode.base) + (int16_t)Opcode.offset; + uint32_t Offset = Address & 3; - Map_GPR_32bit(Opcode.rt, true, Opcode.rt); - x86Reg Value = Map_TempReg(x86_Any, -1, false); - Compile_LW(Value,(Address & ~3)); - AndConstToX86Reg(GetMipsRegMapLo(Opcode.rt),LWR_MASK[Offset]); - ShiftRightUnsignImmed(Value,(BYTE)LWR_SHIFT[Offset]); - AddX86RegToX86Reg(GetMipsRegMapLo(Opcode.rt),Value); - return; - } + Map_GPR_32bit(Opcode.rt, true, Opcode.rt); + x86Reg Value = Map_TempReg(x86_Any, -1, false); + Compile_LW(Value, (Address & ~3)); + AndConstToX86Reg(GetMipsRegMapLo(Opcode.rt), LWR_MASK[Offset]); + ShiftRightUnsignImmed(Value, (uint8_t)LWR_SHIFT[Offset]); + AddX86RegToX86Reg(GetMipsRegMapLo(Opcode.rt), Value); + return; + } - shift = Map_TempReg(x86_ECX, -1, false); - if (IsMapped(Opcode.rt)) - { - ProtectGPR(Opcode.rt); - } - if (IsMapped(Opcode.base)) - { - ProtectGPR(Opcode.base); - if (Opcode.offset != 0) - { - TempReg1 = Map_TempReg(x86_Any, -1, false); - LeaSourceAndOffset(TempReg1,GetMipsRegMapLo(Opcode.base),(short)Opcode.offset); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - } - UnProtectGPR(Opcode.base); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - AddConstToX86Reg(TempReg1,(short)Opcode.immediate); - } - - if (g_System->bUseTlb()) - { - TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); - - CompileReadTLBMiss(TempReg1,TempReg2); - } - OffsetReg = Map_TempReg(x86_Any, -1, false); - MoveX86RegToX86Reg(TempReg1, OffsetReg); - AndConstToX86Reg(OffsetReg,3); - AndConstToX86Reg(TempReg1,(DWORD)~3); + shift = Map_TempReg(x86_ECX, -1, false); + if (IsMapped(Opcode.rt)) + { + ProtectGPR(Opcode.rt); + } + if (IsMapped(Opcode.base)) + { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) + { + TempReg1 = Map_TempReg(x86_Any, -1, false); + LeaSourceAndOffset(TempReg1, GetMipsRegMapLo(Opcode.base), (int16_t)Opcode.offset); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + } + UnProtectGPR(Opcode.base); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + AddConstToX86Reg(TempReg1, (int16_t)Opcode.immediate); + } - Map_GPR_32bit(Opcode.rt, true, Opcode.rt); - AndVariableDispToX86Reg((void *)LWR_MASK,"LWR_MASK",GetMipsRegMapLo(Opcode.rt),OffsetReg,Multip_x4); - MoveVariableDispToX86Reg((void *)LWR_SHIFT,"LWR_SHIFT",shift,OffsetReg,4); - if (g_System->bUseTlb()) - { - MoveX86regPointerToX86reg(TempReg1, TempReg2,TempReg1); - } - else - { - AndConstToX86Reg(TempReg1,0x1FFFFFFF); - MoveN64MemToX86reg(TempReg1,TempReg1); - } - ShiftRightUnsign(TempReg1); - AddX86RegToX86Reg(GetMipsRegMapLo(Opcode.rt),TempReg1); + if (g_System->bUseTlb()) + { + TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_ReadMap, "m_TLB_ReadMap", TempReg2, TempReg2, 4); + + CompileReadTLBMiss(TempReg1, TempReg2); + } + OffsetReg = Map_TempReg(x86_Any, -1, false); + MoveX86RegToX86Reg(TempReg1, OffsetReg); + AndConstToX86Reg(OffsetReg, 3); + AndConstToX86Reg(TempReg1, (uint32_t)~3); + + Map_GPR_32bit(Opcode.rt, true, Opcode.rt); + AndVariableDispToX86Reg((void *)LWR_MASK, "LWR_MASK", GetMipsRegMapLo(Opcode.rt), OffsetReg, Multip_x4); + MoveVariableDispToX86Reg((void *)LWR_SHIFT, "LWR_SHIFT", shift, OffsetReg, 4); + if (g_System->bUseTlb()) + { + MoveX86regPointerToX86reg(TempReg1, TempReg2, TempReg1); + } + else + { + AndConstToX86Reg(TempReg1, 0x1FFFFFFF); + MoveN64MemToX86reg(TempReg1, TempReg1); + } + ShiftRightUnsign(TempReg1); + AddX86RegToX86Reg(GetMipsRegMapLo(Opcode.rt), TempReg1); } void CMipsMemoryVM::Compile_LWU() { - Compile_LW(false,false); + Compile_LW(false, false); } -void CMipsMemoryVM::Compile_LD() +void CMipsMemoryVM::Compile_LD() { - OPCODE & Opcode = CRecompilerOps::m_Opcode; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + OPCODE & Opcode = CRecompilerOps::m_Opcode; + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - if (Opcode.rt == 0) - { - return; - } - - x86Reg TempReg1, TempReg2; + if (Opcode.rt == 0) + { + return; + } - if (IsConst(Opcode.base)) - { - DWORD Address = GetMipsRegLo(Opcode.base) + (short)Opcode.offset; - Map_GPR_64bit(Opcode.rt,-1); - Compile_LW(GetMipsRegMapHi(Opcode.rt),Address); - Compile_LW(GetMipsRegMapLo(Opcode.rt),Address + 4); - if (g_System->bFastSP() && Opcode.rt == 29) - { - ResetMemoryStack(); - } - return; - } - if (IsMapped(Opcode.rt)) - { - ProtectGPR(Opcode.rt); - } - if (IsMapped(Opcode.base) && Opcode.offset == 0) - { - if (g_System->bUseTlb()) - { - ProtectGPR(Opcode.base); - TempReg1 = GetMipsRegMapLo(Opcode.base); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - } - } - else - { - if (IsMapped(Opcode.base)) - { - ProtectGPR(Opcode.base); - if (Opcode.offset != 0) - { - TempReg1 = Map_TempReg(x86_Any, -1, false); - LeaSourceAndOffset(TempReg1,GetMipsRegMapLo(Opcode.base),(short)Opcode.offset); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - } - } - else - { - TempReg1 = Map_TempReg(x86_Any,Opcode.base,false); - AddConstToX86Reg(TempReg1,(short)Opcode.immediate); - } - } - if (g_System->bUseTlb()) - { - TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); - CompileReadTLBMiss(TempReg1,TempReg2); - Map_GPR_64bit(Opcode.rt,-1); - MoveX86regPointerToX86reg(TempReg1, TempReg2,GetMipsRegMapHi(Opcode.rt)); - MoveX86regPointerToX86regDisp8(TempReg1, TempReg2,GetMipsRegMapLo(Opcode.rt),4); - } - else - { - AndConstToX86Reg(TempReg1,0x1FFFFFFF); - Map_GPR_64bit(Opcode.rt,-1); - MoveN64MemToX86reg(GetMipsRegMapHi(Opcode.rt),TempReg1); - MoveN64MemDispToX86reg(GetMipsRegMapLo(Opcode.rt),TempReg1,4); - } - if (g_System->bFastSP() && Opcode.rt == 29) - { - ResetX86Protection(); - g_MMU->ResetMemoryStack(); - } + x86Reg TempReg1, TempReg2; + + if (IsConst(Opcode.base)) + { + uint32_t Address = GetMipsRegLo(Opcode.base) + (int16_t)Opcode.offset; + Map_GPR_64bit(Opcode.rt, -1); + Compile_LW(GetMipsRegMapHi(Opcode.rt), Address); + Compile_LW(GetMipsRegMapLo(Opcode.rt), Address + 4); + if (g_System->bFastSP() && Opcode.rt == 29) + { + ResetMemoryStack(); + } + return; + } + if (IsMapped(Opcode.rt)) + { + ProtectGPR(Opcode.rt); + } + if (IsMapped(Opcode.base) && Opcode.offset == 0) + { + if (g_System->bUseTlb()) + { + ProtectGPR(Opcode.base); + TempReg1 = GetMipsRegMapLo(Opcode.base); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + } + } + else + { + if (IsMapped(Opcode.base)) + { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) + { + TempReg1 = Map_TempReg(x86_Any, -1, false); + LeaSourceAndOffset(TempReg1, GetMipsRegMapLo(Opcode.base), (int16_t)Opcode.offset); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + } + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + AddConstToX86Reg(TempReg1, (int16_t)Opcode.immediate); + } + } + if (g_System->bUseTlb()) + { + TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_ReadMap, "m_TLB_ReadMap", TempReg2, TempReg2, 4); + CompileReadTLBMiss(TempReg1, TempReg2); + Map_GPR_64bit(Opcode.rt, -1); + MoveX86regPointerToX86reg(TempReg1, TempReg2, GetMipsRegMapHi(Opcode.rt)); + MoveX86regPointerToX86regDisp8(TempReg1, TempReg2, GetMipsRegMapLo(Opcode.rt), 4); + } + else + { + AndConstToX86Reg(TempReg1, 0x1FFFFFFF); + Map_GPR_64bit(Opcode.rt, -1); + MoveN64MemToX86reg(GetMipsRegMapHi(Opcode.rt), TempReg1); + MoveN64MemDispToX86reg(GetMipsRegMapLo(Opcode.rt), TempReg1, 4); + } + if (g_System->bFastSP() && Opcode.rt == 29) + { + ResetX86Protection(); + g_MMU->ResetMemoryStack(); + } } -void CMipsMemoryVM::Compile_LDC1() +void CMipsMemoryVM::Compile_LDC1() { - OPCODE & Opcode = CRecompilerOps::m_Opcode; - x86Reg TempReg1, TempReg2, TempReg3; - char Name[50]; - - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + OPCODE & Opcode = CRecompilerOps::m_Opcode; + x86Reg TempReg1, TempReg2, TempReg3; + char Name[50]; - m_Section->CompileCop1Test(); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - UnMap_FPR(Opcode.ft, false); - if (IsConst(Opcode.base)) - { - DWORD Address = GetMipsRegLo(Opcode.base) + (short)Opcode.offset; - TempReg1 = Map_TempReg(x86_Any, -1, false); - Compile_LW(TempReg1,Address); + m_Section->CompileCop1Test(); - TempReg2 = Map_TempReg(x86_Any, -1, false); - sprintf(Name,"_FPR_D[%d]",Opcode.ft); - MoveVariableToX86reg(&_FPR_D[Opcode.ft],Name,TempReg2); - AddConstToX86Reg(TempReg2,4); - MoveX86regToX86Pointer(TempReg1,TempReg2); + UnMap_FPR(Opcode.ft, false); + if (IsConst(Opcode.base)) + { + uint32_t Address = GetMipsRegLo(Opcode.base) + (int16_t)Opcode.offset; + TempReg1 = Map_TempReg(x86_Any, -1, false); + Compile_LW(TempReg1, Address); - Compile_LW(TempReg1,Address + 4); - sprintf(Name,"_FPR_S[%d]",Opcode.ft); - MoveVariableToX86reg(&_FPR_D[Opcode.ft],Name,TempReg2); - MoveX86regToX86Pointer(TempReg1,TempReg2); - return; - } - if (IsMapped(Opcode.base) && Opcode.offset == 0) - { - if (g_System->bUseTlb()) - { - ProtectGPR(Opcode.base); - TempReg1 = GetMipsRegMapLo(Opcode.base); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - } - } - else - { - if (IsMapped(Opcode.base)) - { - ProtectGPR(Opcode.base); - if (Opcode.offset != 0) - { - TempReg1 = Map_TempReg(x86_Any, -1, false); - LeaSourceAndOffset(TempReg1,GetMipsRegMapLo(Opcode.base),(short)Opcode.offset); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - } - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - if (Opcode.immediate == 0) - { - - } - else if (Opcode.immediate == 1) - { - IncX86reg(TempReg1); - } - else if (Opcode.immediate == 0xFFFF) - { - DecX86reg(TempReg1); - } - else - { - AddConstToX86Reg(TempReg1,(short)Opcode.immediate); - } - } - } + TempReg2 = Map_TempReg(x86_Any, -1, false); + sprintf(Name, "_FPR_D[%d]", Opcode.ft); + MoveVariableToX86reg(&_FPR_D[Opcode.ft], Name, TempReg2); + AddConstToX86Reg(TempReg2, 4); + MoveX86regToX86Pointer(TempReg1, TempReg2); - TempReg2 = Map_TempReg(x86_Any, -1, false); - if (g_System->bUseTlb()) - { - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); - CompileReadTLBMiss(TempReg1,TempReg2); - TempReg3 = Map_TempReg(x86_Any, -1, false); - MoveX86regPointerToX86reg(TempReg1, TempReg2,TempReg3); - Push(TempReg2); - sprintf(Name,"_FPR_S[%d]",Opcode.ft); - MoveVariableToX86reg(&_FPR_D[Opcode.ft],Name,TempReg2); - AddConstToX86Reg(TempReg2,4); - MoveX86regToX86Pointer(TempReg3,TempReg2); - Pop(TempReg2); - MoveX86regPointerToX86regDisp8(TempReg1, TempReg2,TempReg3,4); - sprintf(Name,"_FPR_S[%d]",Opcode.ft); - MoveVariableToX86reg(&_FPR_D[Opcode.ft],Name,TempReg2); - MoveX86regToX86Pointer(TempReg3,TempReg2); - } - else - { - AndConstToX86Reg(TempReg1,0x1FFFFFFF); - TempReg3 = Map_TempReg(x86_Any, -1, false); - MoveN64MemToX86reg(TempReg3,TempReg1); + Compile_LW(TempReg1, Address + 4); + sprintf(Name, "_FPR_S[%d]", Opcode.ft); + MoveVariableToX86reg(&_FPR_D[Opcode.ft], Name, TempReg2); + MoveX86regToX86Pointer(TempReg1, TempReg2); + return; + } + if (IsMapped(Opcode.base) && Opcode.offset == 0) + { + if (g_System->bUseTlb()) + { + ProtectGPR(Opcode.base); + TempReg1 = GetMipsRegMapLo(Opcode.base); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + } + } + else + { + if (IsMapped(Opcode.base)) + { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) + { + TempReg1 = Map_TempReg(x86_Any, -1, false); + LeaSourceAndOffset(TempReg1, GetMipsRegMapLo(Opcode.base), (int16_t)Opcode.offset); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + } + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + if (Opcode.immediate == 0) + { + } + else if (Opcode.immediate == 1) + { + IncX86reg(TempReg1); + } + else if (Opcode.immediate == 0xFFFF) + { + DecX86reg(TempReg1); + } + else + { + AddConstToX86Reg(TempReg1, (int16_t)Opcode.immediate); + } + } + } - sprintf(Name,"_FPR_S[%d]",Opcode.ft); - MoveVariableToX86reg(&_FPR_D[Opcode.ft],Name,TempReg2); - AddConstToX86Reg(TempReg2,4); - MoveX86regToX86Pointer(TempReg3,TempReg2); + TempReg2 = Map_TempReg(x86_Any, -1, false); + if (g_System->bUseTlb()) + { + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_ReadMap, "m_TLB_ReadMap", TempReg2, TempReg2, 4); + CompileReadTLBMiss(TempReg1, TempReg2); + TempReg3 = Map_TempReg(x86_Any, -1, false); + MoveX86regPointerToX86reg(TempReg1, TempReg2, TempReg3); + Push(TempReg2); + sprintf(Name, "_FPR_S[%d]", Opcode.ft); + MoveVariableToX86reg(&_FPR_D[Opcode.ft], Name, TempReg2); + AddConstToX86Reg(TempReg2, 4); + MoveX86regToX86Pointer(TempReg3, TempReg2); + Pop(TempReg2); + MoveX86regPointerToX86regDisp8(TempReg1, TempReg2, TempReg3, 4); + sprintf(Name, "_FPR_S[%d]", Opcode.ft); + MoveVariableToX86reg(&_FPR_D[Opcode.ft], Name, TempReg2); + MoveX86regToX86Pointer(TempReg3, TempReg2); + } + else + { + AndConstToX86Reg(TempReg1, 0x1FFFFFFF); + TempReg3 = Map_TempReg(x86_Any, -1, false); + MoveN64MemToX86reg(TempReg3, TempReg1); - MoveN64MemDispToX86reg(TempReg3,TempReg1,4); - sprintf(Name,"_FPR_S[%d]",Opcode.ft); - MoveVariableToX86reg(&_FPR_D[Opcode.ft],Name,TempReg2); - MoveX86regToX86Pointer(TempReg3,TempReg2); - } + sprintf(Name, "_FPR_S[%d]", Opcode.ft); + MoveVariableToX86reg(&_FPR_D[Opcode.ft], Name, TempReg2); + AddConstToX86Reg(TempReg2, 4); + MoveX86regToX86Pointer(TempReg3, TempReg2); + + MoveN64MemDispToX86reg(TempReg3, TempReg1, 4); + sprintf(Name, "_FPR_S[%d]", Opcode.ft); + MoveVariableToX86reg(&_FPR_D[Opcode.ft], Name, TempReg2); + MoveX86regToX86Pointer(TempReg3, TempReg2); + } } -void CMipsMemoryVM::Compile_LDL() +void CMipsMemoryVM::Compile_LDL() { - OPCODE & Opcode = CRecompilerOps::m_Opcode; + OPCODE & Opcode = CRecompilerOps::m_Opcode; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - if (Opcode.base != 0) - { - UnMap_GPR(Opcode.base, true); - } + if (Opcode.base != 0) + { + UnMap_GPR(Opcode.base, true); + } - if (Opcode.rt != 0) - { - UnMap_GPR(Opcode.rt, true); - } + if (Opcode.rt != 0) + { + UnMap_GPR(Opcode.rt, true); + } - BeforeCallDirect(m_RegWorkingSet); - MoveConstToVariable(Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); - Call_Direct(R4300iOp::LDL, "R4300iOp::LDL"); - AfterCallDirect(m_RegWorkingSet); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToVariable(Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); + Call_Direct(R4300iOp::LDL, "R4300iOp::LDL"); + AfterCallDirect(m_RegWorkingSet); } -void CMipsMemoryVM::Compile_LDR() +void CMipsMemoryVM::Compile_LDR() { - OPCODE & Opcode = CRecompilerOps::m_Opcode; + OPCODE & Opcode = CRecompilerOps::m_Opcode; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - if (Opcode.base != 0) - { - UnMap_GPR(Opcode.base, true); - } + if (Opcode.base != 0) + { + UnMap_GPR(Opcode.base, true); + } - if (Opcode.rt != 0) - { - UnMap_GPR(Opcode.rt, true); - } + if (Opcode.rt != 0) + { + UnMap_GPR(Opcode.rt, true); + } - BeforeCallDirect(m_RegWorkingSet); - MoveConstToVariable(Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); - Call_Direct(R4300iOp::LDR, "R4300iOp::LDR"); - AfterCallDirect(m_RegWorkingSet); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToVariable(Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); + Call_Direct(R4300iOp::LDR, "R4300iOp::LDR"); + AfterCallDirect(m_RegWorkingSet); } void CMipsMemoryVM::Compile_SB() { - OPCODE & Opcode = CRecompilerOps::m_Opcode; - x86Reg TempReg1, TempReg2; + OPCODE & Opcode = CRecompilerOps::m_Opcode; + x86Reg TempReg1, TempReg2; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); - - if (IsConst(Opcode.base)) - { - DWORD Address = (GetMipsRegLo(Opcode.base) + (short)Opcode.offset) ^ 3; - - if (IsConst(Opcode.rt)) - { - Compile_SB_Const((BYTE)(GetMipsRegLo(Opcode.rt) & 0xFF), Address); - } - else if (IsMapped(Opcode.rt) && Is8BitReg(GetMipsRegMapLo(Opcode.rt))) - { - Compile_SB_Register(GetMipsRegMapLo(Opcode.rt), Address); - } - else - { - Compile_SB_Register(Map_TempReg(x86_Any8Bit, Opcode.rt, false), Address); - } + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - return; - } + if (IsConst(Opcode.base)) + { + uint32_t Address = (GetMipsRegLo(Opcode.base) + (int16_t)Opcode.offset) ^ 3; - if (IsMapped(Opcode.rt)) - { - ProtectGPR(Opcode.rt); - } + if (IsConst(Opcode.rt)) + { + Compile_SB_Const((uint8_t)(GetMipsRegLo(Opcode.rt) & 0xFF), Address); + } + else if (IsMapped(Opcode.rt) && Is8BitReg(GetMipsRegMapLo(Opcode.rt))) + { + Compile_SB_Register(GetMipsRegMapLo(Opcode.rt), Address); + } + else + { + Compile_SB_Register(Map_TempReg(x86_Any8Bit, Opcode.rt, false), Address); + } - if (IsMapped(Opcode.base)) - { - ProtectGPR(Opcode.base); - if (Opcode.offset != 0) - { - TempReg1 = Map_TempReg(x86_Any, -1, false); - LeaSourceAndOffset(TempReg1,GetMipsRegMapLo(Opcode.base),(short)Opcode.offset); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - } - UnProtectGPR(Opcode.base); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - AddConstToX86Reg(TempReg1,(short)Opcode.immediate); - } - Compile_StoreInstructClean(TempReg1,4); - if (g_System->bUseTlb()) - { - TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_WriteMap,"m_TLB_WriteMap",TempReg2,TempReg2,4); - CompileWriteTLBMiss(TempReg1,TempReg2); - XorConstToX86Reg(TempReg1,3); - if (IsConst(Opcode.rt)) - { - MoveConstByteToX86regPointer((BYTE)(GetMipsRegLo(Opcode.rt) & 0xFF),TempReg1, TempReg2); - } - else if (IsMapped(Opcode.rt) && Is8BitReg(GetMipsRegMapLo(Opcode.rt))) - { - MoveX86regByteToX86regPointer(GetMipsRegMapLo(Opcode.rt),TempReg1, TempReg2); - } - else - { - UnProtectGPR(Opcode.rt); - MoveX86regByteToX86regPointer(Map_TempReg(x86_Any8Bit, Opcode.rt, false), TempReg1, TempReg2); - } - } - else - { - AndConstToX86Reg(TempReg1,0x1FFFFFFF); - XorConstToX86Reg(TempReg1,3); - if (IsConst(Opcode.rt)) - { - MoveConstByteToN64Mem((BYTE)(GetMipsRegLo(Opcode.rt) & 0xFF),TempReg1); - } - else if (IsMapped(Opcode.rt) && Is8BitReg(GetMipsRegMapLo(Opcode.rt))) - { - MoveX86regByteToN64Mem(GetMipsRegMapLo(Opcode.rt),TempReg1); - } - else - { - UnProtectGPR(Opcode.rt); - MoveX86regByteToN64Mem(Map_TempReg(x86_Any8Bit, Opcode.rt, false), TempReg1); - } - } + return; + } + + if (IsMapped(Opcode.rt)) + { + ProtectGPR(Opcode.rt); + } + + if (IsMapped(Opcode.base)) + { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) + { + TempReg1 = Map_TempReg(x86_Any, -1, false); + LeaSourceAndOffset(TempReg1, GetMipsRegMapLo(Opcode.base), (int16_t)Opcode.offset); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + } + UnProtectGPR(Opcode.base); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + AddConstToX86Reg(TempReg1, (int16_t)Opcode.immediate); + } + Compile_StoreInstructClean(TempReg1, 4); + if (g_System->bUseTlb()) + { + TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_WriteMap, "m_TLB_WriteMap", TempReg2, TempReg2, 4); + CompileWriteTLBMiss(TempReg1, TempReg2); + XorConstToX86Reg(TempReg1, 3); + if (IsConst(Opcode.rt)) + { + MoveConstByteToX86regPointer((uint8_t)(GetMipsRegLo(Opcode.rt) & 0xFF), TempReg1, TempReg2); + } + else if (IsMapped(Opcode.rt) && Is8BitReg(GetMipsRegMapLo(Opcode.rt))) + { + MoveX86regByteToX86regPointer(GetMipsRegMapLo(Opcode.rt), TempReg1, TempReg2); + } + else + { + UnProtectGPR(Opcode.rt); + MoveX86regByteToX86regPointer(Map_TempReg(x86_Any8Bit, Opcode.rt, false), TempReg1, TempReg2); + } + } + else + { + AndConstToX86Reg(TempReg1, 0x1FFFFFFF); + XorConstToX86Reg(TempReg1, 3); + if (IsConst(Opcode.rt)) + { + MoveConstByteToN64Mem((uint8_t)(GetMipsRegLo(Opcode.rt) & 0xFF), TempReg1); + } + else if (IsMapped(Opcode.rt) && Is8BitReg(GetMipsRegMapLo(Opcode.rt))) + { + MoveX86regByteToN64Mem(GetMipsRegMapLo(Opcode.rt), TempReg1); + } + else + { + UnProtectGPR(Opcode.rt); + MoveX86regByteToN64Mem(Map_TempReg(x86_Any8Bit, Opcode.rt, false), TempReg1); + } + } } void CMipsMemoryVM::Compile_SH() { - OPCODE & Opcode = CRecompilerOps::m_Opcode; - x86Reg TempReg1, TempReg2; + OPCODE & Opcode = CRecompilerOps::m_Opcode; + x86Reg TempReg1, TempReg2; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); - - if (IsConst(Opcode.base)) - { - DWORD Address = (GetMipsRegLo(Opcode.base) + (short)Opcode.offset) ^ 2; - - if (IsConst(Opcode.rt)) - { - Compile_SH_Const((WORD)(GetMipsRegLo(Opcode.rt) & 0xFFFF), Address); - } - else if (IsMapped(Opcode.rt)) - { - Compile_SH_Register(GetMipsRegMapLo(Opcode.rt), Address); - } - else - { - Compile_SH_Register(Map_TempReg(x86_Any, Opcode.rt, false), Address); - } + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - return; - } + if (IsConst(Opcode.base)) + { + uint32_t Address = (GetMipsRegLo(Opcode.base) + (int16_t)Opcode.offset) ^ 2; - if (IsMapped(Opcode.rt)) - { - ProtectGPR(Opcode.rt); - } + if (IsConst(Opcode.rt)) + { + Compile_SH_Const((uint16_t)(GetMipsRegLo(Opcode.rt) & 0xFFFF), Address); + } + else if (IsMapped(Opcode.rt)) + { + Compile_SH_Register(GetMipsRegMapLo(Opcode.rt), Address); + } + else + { + Compile_SH_Register(Map_TempReg(x86_Any, Opcode.rt, false), Address); + } - if (IsMapped(Opcode.base)) - { - ProtectGPR(Opcode.base); - if (Opcode.offset != 0) - { - TempReg1 = Map_TempReg(x86_Any, -1, false); - LeaSourceAndOffset(TempReg1,GetMipsRegMapLo(Opcode.base),(short)Opcode.offset); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - } - UnProtectGPR(Opcode.base); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - AddConstToX86Reg(TempReg1,(short)Opcode.immediate); - } + return; + } - if (g_System->bUseTlb()) - { - TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_WriteMap,"m_TLB_WriteMap",TempReg2,TempReg2,4); - CompileWriteTLBMiss(TempReg1,TempReg2); - XorConstToX86Reg(TempReg1,2); - if (IsConst(Opcode.rt)) - { - MoveConstHalfToX86regPointer((WORD)(GetMipsRegLo(Opcode.rt) & 0xFFFF),TempReg1, TempReg2); - } - else if (IsMapped(Opcode.rt)) - { - MoveX86regHalfToX86regPointer(GetMipsRegMapLo(Opcode.rt),TempReg1, TempReg2); - } - else - { - MoveX86regHalfToX86regPointer(Map_TempReg(x86_Any, Opcode.rt, false), TempReg1, TempReg2); - } - } - else - { - AndConstToX86Reg(TempReg1,0x1FFFFFFF); - XorConstToX86Reg(TempReg1,2); - if (IsConst(Opcode.rt)) - { - MoveConstHalfToN64Mem((WORD)(GetMipsRegLo(Opcode.rt) & 0xFFFF),TempReg1); - } - else if (IsMapped(Opcode.rt)) - { - MoveX86regHalfToN64Mem(GetMipsRegMapLo(Opcode.rt),TempReg1); - } - else - { - MoveX86regHalfToN64Mem(Map_TempReg(x86_Any, Opcode.rt, false), TempReg1); - } - } + if (IsMapped(Opcode.rt)) + { + ProtectGPR(Opcode.rt); + } + + if (IsMapped(Opcode.base)) + { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) + { + TempReg1 = Map_TempReg(x86_Any, -1, false); + LeaSourceAndOffset(TempReg1, GetMipsRegMapLo(Opcode.base), (int16_t)Opcode.offset); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + } + UnProtectGPR(Opcode.base); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + AddConstToX86Reg(TempReg1, (int16_t)Opcode.immediate); + } + + if (g_System->bUseTlb()) + { + TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_WriteMap, "m_TLB_WriteMap", TempReg2, TempReg2, 4); + CompileWriteTLBMiss(TempReg1, TempReg2); + XorConstToX86Reg(TempReg1, 2); + if (IsConst(Opcode.rt)) + { + MoveConstHalfToX86regPointer((uint16_t)(GetMipsRegLo(Opcode.rt) & 0xFFFF), TempReg1, TempReg2); + } + else if (IsMapped(Opcode.rt)) + { + MoveX86regHalfToX86regPointer(GetMipsRegMapLo(Opcode.rt), TempReg1, TempReg2); + } + else + { + MoveX86regHalfToX86regPointer(Map_TempReg(x86_Any, Opcode.rt, false), TempReg1, TempReg2); + } + } + else + { + AndConstToX86Reg(TempReg1, 0x1FFFFFFF); + XorConstToX86Reg(TempReg1, 2); + if (IsConst(Opcode.rt)) + { + MoveConstHalfToN64Mem((uint16_t)(GetMipsRegLo(Opcode.rt) & 0xFFFF), TempReg1); + } + else if (IsMapped(Opcode.rt)) + { + MoveX86regHalfToN64Mem(GetMipsRegMapLo(Opcode.rt), TempReg1); + } + else + { + MoveX86regHalfToN64Mem(Map_TempReg(x86_Any, Opcode.rt, false), TempReg1); + } + } } void CMipsMemoryVM::Compile_SW() { - Compile_SW(false); + Compile_SW(false); } void CMipsMemoryVM::Compile_SC() { - Compile_SW(true); + Compile_SW(true); } -void CMipsMemoryVM::Compile_SW (bool bCheckLLbit) +void CMipsMemoryVM::Compile_SW(bool bCheckLLbit) { - OPCODE & Opcode = CRecompilerOps::m_Opcode; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); - - x86Reg TempReg1, TempReg2; - if (Opcode.base == 29 && g_System->bFastSP()) - { - if (bCheckLLbit) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (IsMapped(Opcode.rt)) - { - ProtectGPR(Opcode.rt); - } - TempReg1 = Map_MemoryStack(x86_Any, true); + OPCODE & Opcode = CRecompilerOps::m_Opcode; + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - if (IsConst(Opcode.rt)) - { - MoveConstToMemoryDisp (GetMipsRegLo(Opcode.rt),TempReg1, (DWORD)((short)Opcode.offset)); - } - else if (IsMapped(Opcode.rt)) - { - MoveX86regToMemory(GetMipsRegMapLo(Opcode.rt),TempReg1,(DWORD)((short)Opcode.offset)); - } - else - { - TempReg2 = Map_TempReg(x86_Any, Opcode.rt, false); - MoveX86regToMemory(TempReg2,TempReg1,(DWORD)((short)Opcode.offset)); - } - } - else - { - if (IsConst(Opcode.base)) - { - DWORD Address = GetMipsRegLo(Opcode.base) + (short)Opcode.offset; - - if (bCheckLLbit) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (IsConst(Opcode.rt)) - { - Compile_SW_Const(GetMipsRegLo(Opcode.rt), Address); - } - else if (IsMapped(Opcode.rt)) - { - Compile_SW_Register(GetMipsRegMapLo(Opcode.rt), Address); - } - else - { - Compile_SW_Register(Map_TempReg(x86_Any, Opcode.rt, false), Address); - } + x86Reg TempReg1, TempReg2; + if (Opcode.base == 29 && g_System->bFastSP()) + { + if (bCheckLLbit) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + if (IsMapped(Opcode.rt)) + { + ProtectGPR(Opcode.rt); + } + TempReg1 = Map_MemoryStack(x86_Any, true); - return; - } + if (IsConst(Opcode.rt)) + { + MoveConstToMemoryDisp(GetMipsRegLo(Opcode.rt), TempReg1, (uint32_t)((int16_t)Opcode.offset)); + } + else if (IsMapped(Opcode.rt)) + { + MoveX86regToMemory(GetMipsRegMapLo(Opcode.rt), TempReg1, (uint32_t)((int16_t)Opcode.offset)); + } + else + { + TempReg2 = Map_TempReg(x86_Any, Opcode.rt, false); + MoveX86regToMemory(TempReg2, TempReg1, (uint32_t)((int16_t)Opcode.offset)); + } + } + else + { + if (IsConst(Opcode.base)) + { + uint32_t Address = GetMipsRegLo(Opcode.base) + (int16_t)Opcode.offset; - if (IsMapped(Opcode.rt)) - ProtectGPR(Opcode.rt); + if (bCheckLLbit) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + if (IsConst(Opcode.rt)) + { + Compile_SW_Const(GetMipsRegLo(Opcode.rt), Address); + } + else if (IsMapped(Opcode.rt)) + { + Compile_SW_Register(GetMipsRegMapLo(Opcode.rt), Address); + } + else + { + Compile_SW_Register(Map_TempReg(x86_Any, Opcode.rt, false), Address); + } - if (IsMapped(Opcode.base)) - { - ProtectGPR(Opcode.base); - if (g_System->bDelaySI() || g_System->bDelayDP()) - { - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); - UpdateCounters(m_RegWorkingSet,false, true); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); - } - if (Opcode.offset != 0) - { - TempReg1 = Map_TempReg(x86_Any, -1, false); - LeaSourceAndOffset(TempReg1,GetMipsRegMapLo(Opcode.base),(short)Opcode.offset); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - } - UnProtectGPR(Opcode.base); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - AddConstToX86Reg(TempReg1,(short)Opcode.immediate); - } - Compile_StoreInstructClean(TempReg1,4); - if (g_System->bUseTlb()) - { - TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_WriteMap,"m_TLB_WriteMap",TempReg2,TempReg2,4); - CompileWriteTLBMiss(TempReg1,TempReg2); - BYTE * Jump = NULL; - if (bCheckLLbit) - { - CompConstToVariable(1,_LLBit,"_LLBit"); - JneLabel8("LLBit_Continue",0); - Jump = m_RecompPos - 1; - } - if (IsConst(Opcode.rt)) - { - MoveConstToX86regPointer(GetMipsRegLo(Opcode.rt),TempReg1, TempReg2); - } else if (IsMapped(Opcode.rt)) - { - MoveX86regToX86regPointer(GetMipsRegMapLo(Opcode.rt),TempReg1, TempReg2); - } - else - { - MoveX86regToX86regPointer(Map_TempReg(x86_Any, Opcode.rt, false), TempReg1, TempReg2); - } - if (bCheckLLbit) - { - CPU_Message(" "); - CPU_Message(" LLBit_Continue:"); - SetJump8(Jump,m_RecompPos); - Map_GPR_32bit(Opcode.rt,false,-1); - MoveVariableToX86reg(_LLBit,"_LLBit",GetMipsRegMapLo(Opcode.rt)); - } - } - else - { - if (bCheckLLbit) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - AndConstToX86Reg(TempReg1,0x1FFFFFFF); - if (IsConst(Opcode.rt)) - { - MoveConstToN64Mem(GetMipsRegLo(Opcode.rt),TempReg1); - } - else if (IsMapped(Opcode.rt)) - { - MoveX86regToN64Mem(GetMipsRegMapLo(Opcode.rt),TempReg1); - } - else - { - MoveX86regToN64Mem(Map_TempReg(x86_Any, Opcode.rt, false), TempReg1); - } - } - } + return; + } + + if (IsMapped(Opcode.rt)) + ProtectGPR(Opcode.rt); + + if (IsMapped(Opcode.base)) + { + ProtectGPR(Opcode.base); + if (g_System->bDelaySI() || g_System->bDelayDP()) + { + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); + UpdateCounters(m_RegWorkingSet, false, true); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); + } + if (Opcode.offset != 0) + { + TempReg1 = Map_TempReg(x86_Any, -1, false); + LeaSourceAndOffset(TempReg1, GetMipsRegMapLo(Opcode.base), (int16_t)Opcode.offset); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + } + UnProtectGPR(Opcode.base); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + AddConstToX86Reg(TempReg1, (int16_t)Opcode.immediate); + } + Compile_StoreInstructClean(TempReg1, 4); + if (g_System->bUseTlb()) + { + TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_WriteMap, "m_TLB_WriteMap", TempReg2, TempReg2, 4); + CompileWriteTLBMiss(TempReg1, TempReg2); + uint8_t * Jump = NULL; + if (bCheckLLbit) + { + CompConstToVariable(1, _LLBit, "_LLBit"); + JneLabel8("LLBit_Continue", 0); + Jump = m_RecompPos - 1; + } + if (IsConst(Opcode.rt)) + { + MoveConstToX86regPointer(GetMipsRegLo(Opcode.rt), TempReg1, TempReg2); + } + else if (IsMapped(Opcode.rt)) + { + MoveX86regToX86regPointer(GetMipsRegMapLo(Opcode.rt), TempReg1, TempReg2); + } + else + { + MoveX86regToX86regPointer(Map_TempReg(x86_Any, Opcode.rt, false), TempReg1, TempReg2); + } + if (bCheckLLbit) + { + CPU_Message(" "); + CPU_Message(" LLBit_Continue:"); + SetJump8(Jump, m_RecompPos); + Map_GPR_32bit(Opcode.rt, false, -1); + MoveVariableToX86reg(_LLBit, "_LLBit", GetMipsRegMapLo(Opcode.rt)); + } + } + else + { + if (bCheckLLbit) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + AndConstToX86Reg(TempReg1, 0x1FFFFFFF); + if (IsConst(Opcode.rt)) + { + MoveConstToN64Mem(GetMipsRegLo(Opcode.rt), TempReg1); + } + else if (IsMapped(Opcode.rt)) + { + MoveX86regToN64Mem(GetMipsRegMapLo(Opcode.rt), TempReg1); + } + else + { + MoveX86regToN64Mem(Map_TempReg(x86_Any, Opcode.rt, false), TempReg1); + } + } + } } void CMipsMemoryVM::Compile_SWC1() { - OPCODE & Opcode = CRecompilerOps::m_Opcode; - x86Reg TempReg1, TempReg2, TempReg3; - char Name[50]; + OPCODE & Opcode = CRecompilerOps::m_Opcode; + x86Reg TempReg1, TempReg2, TempReg3; + char Name[50]; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - m_Section->CompileCop1Test(); - - if (IsConst(Opcode.base)) - { - DWORD Address = GetMipsRegLo(Opcode.base) + (short)Opcode.offset; - - UnMap_FPR(Opcode.ft, true); - TempReg1 = Map_TempReg(x86_Any, -1, false); + m_Section->CompileCop1Test(); - sprintf(Name,"_FPR_S[%d]",Opcode.ft); - MoveVariableToX86reg(&_FPR_S[Opcode.ft],Name,TempReg1); - MoveX86PointerToX86reg(TempReg1,TempReg1); - Compile_SW_Register(TempReg1, Address); - return; - } - if (IsMapped(Opcode.base)) - { - ProtectGPR(Opcode.base); - if (Opcode.offset != 0) - { - TempReg1 = Map_TempReg(x86_Any, -1, false); - LeaSourceAndOffset(TempReg1,GetMipsRegMapLo(Opcode.base),(short)Opcode.offset); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - } - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - if (Opcode.immediate == 0) - { - - } - else if (Opcode.immediate == 1) - { - IncX86reg(TempReg1); - } - else if (Opcode.immediate == 0xFFFF) - { - DecX86reg(TempReg1); - } - else - { - AddConstToX86Reg(TempReg1,(short)Opcode.immediate); - } - } - if (g_System->bUseTlb()) - { - TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_WriteMap,"m_TLB_WriteMap",TempReg2,TempReg2,4); - CompileWriteTLBMiss(TempReg1,TempReg2); + if (IsConst(Opcode.base)) + { + uint32_t Address = GetMipsRegLo(Opcode.base) + (int16_t)Opcode.offset; - UnMap_FPR(Opcode.ft, true); - TempReg3 = Map_TempReg(x86_Any, -1, false); - sprintf(Name,"_FPR_S[%d]",Opcode.ft); - MoveVariableToX86reg(&_FPR_S[Opcode.ft],Name,TempReg3); - MoveX86PointerToX86reg(TempReg3,TempReg3); - MoveX86regToX86regPointer(TempReg3,TempReg1, TempReg2); - } - else - { - TempReg2 = Map_TempReg(x86_Any, -1, false); - UnMap_FPR(Opcode.ft, true); - sprintf(Name,"_FPR_S[%d]",Opcode.ft); - MoveVariableToX86reg(&_FPR_S[Opcode.ft],Name,TempReg2); - MoveX86PointerToX86reg(TempReg2,TempReg2); - AndConstToX86Reg(TempReg1,0x1FFFFFFF); - MoveX86regToN64Mem(TempReg2, TempReg1); - } + UnMap_FPR(Opcode.ft, true); + TempReg1 = Map_TempReg(x86_Any, -1, false); + + sprintf(Name, "_FPR_S[%d]", Opcode.ft); + MoveVariableToX86reg(&_FPR_S[Opcode.ft], Name, TempReg1); + MoveX86PointerToX86reg(TempReg1, TempReg1); + Compile_SW_Register(TempReg1, Address); + return; + } + if (IsMapped(Opcode.base)) + { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) + { + TempReg1 = Map_TempReg(x86_Any, -1, false); + LeaSourceAndOffset(TempReg1, GetMipsRegMapLo(Opcode.base), (int16_t)Opcode.offset); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + } + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + if (Opcode.immediate == 0) + { + } + else if (Opcode.immediate == 1) + { + IncX86reg(TempReg1); + } + else if (Opcode.immediate == 0xFFFF) + { + DecX86reg(TempReg1); + } + else + { + AddConstToX86Reg(TempReg1, (int16_t)Opcode.immediate); + } + } + if (g_System->bUseTlb()) + { + TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_WriteMap, "m_TLB_WriteMap", TempReg2, TempReg2, 4); + CompileWriteTLBMiss(TempReg1, TempReg2); + + UnMap_FPR(Opcode.ft, true); + TempReg3 = Map_TempReg(x86_Any, -1, false); + sprintf(Name, "_FPR_S[%d]", Opcode.ft); + MoveVariableToX86reg(&_FPR_S[Opcode.ft], Name, TempReg3); + MoveX86PointerToX86reg(TempReg3, TempReg3); + MoveX86regToX86regPointer(TempReg3, TempReg1, TempReg2); + } + else + { + TempReg2 = Map_TempReg(x86_Any, -1, false); + UnMap_FPR(Opcode.ft, true); + sprintf(Name, "_FPR_S[%d]", Opcode.ft); + MoveVariableToX86reg(&_FPR_S[Opcode.ft], Name, TempReg2); + MoveX86PointerToX86reg(TempReg2, TempReg2); + AndConstToX86Reg(TempReg1, 0x1FFFFFFF); + MoveX86regToN64Mem(TempReg2, TempReg1); + } } -void CMipsMemoryVM::Compile_SWL() +void CMipsMemoryVM::Compile_SWL() { - OPCODE & Opcode = CRecompilerOps::m_Opcode; - x86Reg TempReg1 = x86_Unknown, TempReg2 = x86_Unknown, Value = x86_Unknown, - shift = x86_Unknown, OffsetReg = x86_Unknown; + OPCODE & Opcode = CRecompilerOps::m_Opcode; + x86Reg TempReg1 = x86_Unknown, TempReg2 = x86_Unknown, Value = x86_Unknown, + shift = x86_Unknown, OffsetReg = x86_Unknown; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - if (IsConst(Opcode.base)) - { - DWORD Address; - - Address = GetMipsRegLo(Opcode.base) + (short)Opcode.offset; - DWORD Offset = Address & 3; - - Value = Map_TempReg(x86_Any, -1, false); - Compile_LW(Value,(Address & ~3)); - AndConstToX86Reg(Value,R4300iOp::SWL_MASK[Offset]); - TempReg1 = Map_TempReg(x86_Any, Opcode.rt, false); - ShiftRightUnsignImmed(TempReg1,(BYTE)SWL_SHIFT[Offset]); - AddX86RegToX86Reg(Value,TempReg1); - Compile_SW_Register(Value, (Address & ~3)); - return; - } - shift = Map_TempReg(x86_ECX, -1, false); - if (IsMapped(Opcode.base)) - { - ProtectGPR(Opcode.base); - if (Opcode.offset != 0) - { - TempReg1 = Map_TempReg(x86_Any, -1, false); - LeaSourceAndOffset(TempReg1,GetMipsRegMapLo(Opcode.base),(short)Opcode.offset); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - } - UnProtectGPR(Opcode.base); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - AddConstToX86Reg(TempReg1,(short)Opcode.immediate); - } - if (g_System->bUseTlb()) - { - TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); - CompileReadTLBMiss(TempReg1,TempReg2); - } - - OffsetReg = Map_TempReg(x86_Any, -1, false); - MoveX86RegToX86Reg(TempReg1, OffsetReg); - AndConstToX86Reg(OffsetReg,3); - AndConstToX86Reg(TempReg1,(DWORD)~3); + if (IsConst(Opcode.base)) + { + uint32_t Address; - Value = Map_TempReg(x86_Any, -1, false); - if (g_System->bUseTlb()) - { - MoveX86regPointerToX86reg(TempReg1, TempReg2,Value); - } - else - { - AndConstToX86Reg(TempReg1,0x1FFFFFFF); - MoveN64MemToX86reg(Value,TempReg1); - } + Address = GetMipsRegLo(Opcode.base) + (int16_t)Opcode.offset; + uint32_t Offset = Address & 3; - AndVariableDispToX86Reg((void *)SWL_MASK,"SWL_MASK",Value,OffsetReg,Multip_x4); - if (!IsConst(Opcode.rt) || GetMipsRegLo(Opcode.rt) != 0) - { - MoveVariableDispToX86Reg((void *)SWL_SHIFT,"SWL_SHIFT",shift,OffsetReg,4); - if (IsConst(Opcode.rt)) - { - MoveConstToX86reg(GetMipsRegLo(Opcode.rt),OffsetReg); - } - else if (IsMapped(Opcode.rt)) - { - MoveX86RegToX86Reg(GetMipsRegMapLo(Opcode.rt),OffsetReg); - } - else - { - MoveVariableToX86reg(&_GPR[Opcode.rt].UW[0],CRegName::GPR_Lo[Opcode.rt],OffsetReg); - } - ShiftRightUnsign(OffsetReg); - AddX86RegToX86Reg(Value,OffsetReg); - } + Value = Map_TempReg(x86_Any, -1, false); + Compile_LW(Value, (Address & ~3)); + AndConstToX86Reg(Value, R4300iOp::SWL_MASK[Offset]); + TempReg1 = Map_TempReg(x86_Any, Opcode.rt, false); + ShiftRightUnsignImmed(TempReg1, (uint8_t)SWL_SHIFT[Offset]); + AddX86RegToX86Reg(Value, TempReg1); + Compile_SW_Register(Value, (Address & ~3)); + return; + } + shift = Map_TempReg(x86_ECX, -1, false); + if (IsMapped(Opcode.base)) + { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) + { + TempReg1 = Map_TempReg(x86_Any, -1, false); + LeaSourceAndOffset(TempReg1, GetMipsRegMapLo(Opcode.base), (int16_t)Opcode.offset); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + } + UnProtectGPR(Opcode.base); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + AddConstToX86Reg(TempReg1, (int16_t)Opcode.immediate); + } + if (g_System->bUseTlb()) + { + TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_ReadMap, "m_TLB_ReadMap", TempReg2, TempReg2, 4); + CompileReadTLBMiss(TempReg1, TempReg2); + } - if (g_System->bUseTlb()) - { - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_WriteMap,"m_TLB_WriteMap",TempReg2,TempReg2,4); + OffsetReg = Map_TempReg(x86_Any, -1, false); + MoveX86RegToX86Reg(TempReg1, OffsetReg); + AndConstToX86Reg(OffsetReg, 3); + AndConstToX86Reg(TempReg1, (uint32_t)~3); - MoveX86regToX86regPointer(Value,TempReg1, TempReg2); - } - else - { - MoveX86regToN64Mem(Value,TempReg1); - } + Value = Map_TempReg(x86_Any, -1, false); + if (g_System->bUseTlb()) + { + MoveX86regPointerToX86reg(TempReg1, TempReg2, Value); + } + else + { + AndConstToX86Reg(TempReg1, 0x1FFFFFFF); + MoveN64MemToX86reg(Value, TempReg1); + } + + AndVariableDispToX86Reg((void *)SWL_MASK, "SWL_MASK", Value, OffsetReg, Multip_x4); + if (!IsConst(Opcode.rt) || GetMipsRegLo(Opcode.rt) != 0) + { + MoveVariableDispToX86Reg((void *)SWL_SHIFT, "SWL_SHIFT", shift, OffsetReg, 4); + if (IsConst(Opcode.rt)) + { + MoveConstToX86reg(GetMipsRegLo(Opcode.rt), OffsetReg); + } + else if (IsMapped(Opcode.rt)) + { + MoveX86RegToX86Reg(GetMipsRegMapLo(Opcode.rt), OffsetReg); + } + else + { + MoveVariableToX86reg(&_GPR[Opcode.rt].UW[0], CRegName::GPR_Lo[Opcode.rt], OffsetReg); + } + ShiftRightUnsign(OffsetReg); + AddX86RegToX86Reg(Value, OffsetReg); + } + + if (g_System->bUseTlb()) + { + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_WriteMap, "m_TLB_WriteMap", TempReg2, TempReg2, 4); + + MoveX86regToX86regPointer(Value, TempReg1, TempReg2); + } + else + { + MoveX86regToN64Mem(Value, TempReg1); + } } -void CMipsMemoryVM::Compile_SWR() +void CMipsMemoryVM::Compile_SWR() { - OPCODE & Opcode = CRecompilerOps::m_Opcode; - x86Reg TempReg1 = x86_Unknown, TempReg2 = x86_Unknown, Value = x86_Unknown, - OffsetReg = x86_Unknown, shift = x86_Unknown; + OPCODE & Opcode = CRecompilerOps::m_Opcode; + x86Reg TempReg1 = x86_Unknown, TempReg2 = x86_Unknown, Value = x86_Unknown, + OffsetReg = x86_Unknown, shift = x86_Unknown; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - if (IsConst(Opcode.base)) - { - DWORD Address = GetMipsRegLo(Opcode.base) + (short)Opcode.offset; - DWORD Offset = Address & 3; - - Value = Map_TempReg(x86_Any, -1, false); - Compile_LW(Value,(Address & ~3)); - AndConstToX86Reg(Value,SWR_MASK[Offset]); - TempReg1 = Map_TempReg(x86_Any, Opcode.rt, false); - ShiftLeftSignImmed(TempReg1,(BYTE)SWR_SHIFT[Offset]); - AddX86RegToX86Reg(Value,TempReg1); - Compile_SW_Register(Value, (Address & ~3)); - return; - } - shift = Map_TempReg(x86_ECX, -1, false); - if (IsMapped(Opcode.base)) - { - ProtectGPR(Opcode.base); - if (Opcode.offset != 0) - { - TempReg1 = Map_TempReg(x86_Any, -1, false); - LeaSourceAndOffset(TempReg1,GetMipsRegMapLo(Opcode.base),(short)Opcode.offset); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - } - UnProtectGPR(Opcode.base); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - AddConstToX86Reg(TempReg1,(short)Opcode.immediate); - } - if (g_System->bUseTlb()) - { - TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); - CompileReadTLBMiss(TempReg1,TempReg2); - } - - OffsetReg = Map_TempReg(x86_Any, -1, false); - MoveX86RegToX86Reg(TempReg1, OffsetReg); - AndConstToX86Reg(OffsetReg,3); - AndConstToX86Reg(TempReg1,(DWORD)~3); + if (IsConst(Opcode.base)) + { + uint32_t Address = GetMipsRegLo(Opcode.base) + (int16_t)Opcode.offset; + uint32_t Offset = Address & 3; - Value = Map_TempReg(x86_Any, -1, false); - if (g_System->bUseTlb()) - { - MoveX86regPointerToX86reg(TempReg1, TempReg2,Value); - } - else - { - AndConstToX86Reg(TempReg1,0x1FFFFFFF); - MoveN64MemToX86reg(Value,TempReg1); - } + Value = Map_TempReg(x86_Any, -1, false); + Compile_LW(Value, (Address & ~3)); + AndConstToX86Reg(Value, SWR_MASK[Offset]); + TempReg1 = Map_TempReg(x86_Any, Opcode.rt, false); + ShiftLeftSignImmed(TempReg1, (uint8_t)SWR_SHIFT[Offset]); + AddX86RegToX86Reg(Value, TempReg1); + Compile_SW_Register(Value, (Address & ~3)); + return; + } + shift = Map_TempReg(x86_ECX, -1, false); + if (IsMapped(Opcode.base)) + { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) + { + TempReg1 = Map_TempReg(x86_Any, -1, false); + LeaSourceAndOffset(TempReg1, GetMipsRegMapLo(Opcode.base), (int16_t)Opcode.offset); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + } + UnProtectGPR(Opcode.base); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + AddConstToX86Reg(TempReg1, (int16_t)Opcode.immediate); + } + if (g_System->bUseTlb()) + { + TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_ReadMap, "m_TLB_ReadMap", TempReg2, TempReg2, 4); + CompileReadTLBMiss(TempReg1, TempReg2); + } - AndVariableDispToX86Reg((void *)SWR_MASK,"SWR_MASK",Value,OffsetReg,Multip_x4); - if (!IsConst(Opcode.rt) || GetMipsRegLo(Opcode.rt) != 0) - { - MoveVariableDispToX86Reg((void *)SWR_SHIFT,"SWR_SHIFT",shift,OffsetReg,4); - if (IsConst(Opcode.rt)) - { - MoveConstToX86reg(GetMipsRegLo(Opcode.rt),OffsetReg); - } - else if (IsMapped(Opcode.rt)) - { - MoveX86RegToX86Reg(GetMipsRegMapLo(Opcode.rt),OffsetReg); - } - else - { - MoveVariableToX86reg(&_GPR[Opcode.rt].UW[0],CRegName::GPR_Lo[Opcode.rt],OffsetReg); - } - ShiftLeftSign(OffsetReg); - AddX86RegToX86Reg(Value,OffsetReg); - } + OffsetReg = Map_TempReg(x86_Any, -1, false); + MoveX86RegToX86Reg(TempReg1, OffsetReg); + AndConstToX86Reg(OffsetReg, 3); + AndConstToX86Reg(TempReg1, (uint32_t)~3); - if (g_System->bUseTlb()) - { - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_WriteMap,"m_TLB_WriteMap",TempReg2,TempReg2,4); + Value = Map_TempReg(x86_Any, -1, false); + if (g_System->bUseTlb()) + { + MoveX86regPointerToX86reg(TempReg1, TempReg2, Value); + } + else + { + AndConstToX86Reg(TempReg1, 0x1FFFFFFF); + MoveN64MemToX86reg(Value, TempReg1); + } - MoveX86regToX86regPointer(Value,TempReg1, TempReg2); - } - else - { - MoveX86regToN64Mem(Value,TempReg1); - } + AndVariableDispToX86Reg((void *)SWR_MASK, "SWR_MASK", Value, OffsetReg, Multip_x4); + if (!IsConst(Opcode.rt) || GetMipsRegLo(Opcode.rt) != 0) + { + MoveVariableDispToX86Reg((void *)SWR_SHIFT, "SWR_SHIFT", shift, OffsetReg, 4); + if (IsConst(Opcode.rt)) + { + MoveConstToX86reg(GetMipsRegLo(Opcode.rt), OffsetReg); + } + else if (IsMapped(Opcode.rt)) + { + MoveX86RegToX86Reg(GetMipsRegMapLo(Opcode.rt), OffsetReg); + } + else + { + MoveVariableToX86reg(&_GPR[Opcode.rt].UW[0], CRegName::GPR_Lo[Opcode.rt], OffsetReg); + } + ShiftLeftSign(OffsetReg); + AddX86RegToX86Reg(Value, OffsetReg); + } + + if (g_System->bUseTlb()) + { + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_WriteMap, "m_TLB_WriteMap", TempReg2, TempReg2, 4); + + MoveX86regToX86regPointer(Value, TempReg1, TempReg2); + } + else + { + MoveX86regToN64Mem(Value, TempReg1); + } } -void CMipsMemoryVM::Compile_StoreInstructClean (x86Reg AddressReg, int Length ) +void CMipsMemoryVM::Compile_StoreInstructClean(x86Reg AddressReg, int32_t Length) { - if (!g_System->bSMM_StoreInstruc()) - { - return; - } - g_Notify->BreakPoint(__FILEW__,__LINE__); + if (!g_System->bSMM_StoreInstruc()) + { + return; + } + g_Notify->BreakPoint(__FILEW__, __LINE__); - /* - stdstr_f strLen("%d",Length); - UnMap_AllFPRs(); - - /*x86Reg StoreTemp1 = Map_TempReg(x86_Any,-1,false); - MoveX86RegToX86Reg(AddressReg, StoreTemp1); - AndConstToX86Reg(StoreTemp1,0xFFC);*/ - BeforeCallDirect(m_RegWorkingSet); - PushImm32("CRecompiler::Remove_StoreInstruc",CRecompiler::Remove_StoreInstruc); - PushImm32(Length); - Push(AddressReg); - MoveConstToX86reg((DWORD)g_Recompiler,x86_ECX); - Call_Direct(AddressOf(&CRecompiler::ClearRecompCode_Virt), "CRecompiler::ClearRecompCode_Virt"); - AfterCallDirect(m_RegWorkingSet); - /*JmpLabel8("MemCheckDone",0); - BYTE * MemCheckDone = m_RecompPos - 1; - - CPU_Message(" "); - CPU_Message(" NotDelaySlot:"); - SetJump8(NotDelaySlotJump,m_RecompPos); + /* + stdstr_f strLen("%d",Length); + UnMap_AllFPRs(); - MoveX86RegToX86Reg(AddressReg, StoreTemp1); - ShiftRightUnsignImmed(StoreTemp1,12); - LeaRegReg(StoreTemp1,StoreTemp1,(ULONG)&(g_Recompiler->FunctionTable()[0]),Multip_x4); - CompConstToX86regPointer(StoreTemp1,0); - JeLabel8("MemCheckDone",0); - BYTE * MemCheckDone2 = m_RecompPos - 1; + /*x86Reg StoreTemp1 = Map_TempReg(x86_Any,-1,false); + MoveX86RegToX86Reg(AddressReg, StoreTemp1); + AndConstToX86Reg(StoreTemp1,0xFFC);*/ + BeforeCallDirect(m_RegWorkingSet); + PushImm32("CRecompiler::Remove_StoreInstruc", CRecompiler::Remove_StoreInstruc); + PushImm32(Length); + Push(AddressReg); + MoveConstToX86reg((uint32_t)g_Recompiler, x86_ECX); + Call_Direct(AddressOf(&CRecompiler::ClearRecompCode_Virt), "CRecompiler::ClearRecompCode_Virt"); + AfterCallDirect(m_RegWorkingSet); + /*JmpLabel8("MemCheckDone",0); + uint8_t * MemCheckDone = m_RecompPos - 1; - BeforeCallDirect(m_RegWorkingSet); - PushImm32("CRecompiler::Remove_StoreInstruc",CRecompiler::Remove_StoreInstruc); - PushImm32(strLen.c_str(),Length); - Push(AddressReg); - MoveConstToX86reg((DWORD)g_Recompiler,x86_ECX); - Call_Direct(AddressOf(&CRecompiler::ClearRecompCode_Virt), "CRecompiler::ClearRecompCode_Virt"); - AfterCallDirect(m_RegWorkingSet); - - CPU_Message(" "); - CPU_Message(" MemCheckDone:"); - SetJump8(MemCheckDone,m_RecompPos); - SetJump8(MemCheckDone2,m_RecompPos); + CPU_Message(" "); + CPU_Message(" NotDelaySlot:"); + SetJump8(NotDelaySlotJump,m_RecompPos); - X86Protected(StoreTemp1) = false;*/ + MoveX86RegToX86Reg(AddressReg, StoreTemp1); + ShiftRightUnsignImmed(StoreTemp1,12); + LeaRegReg(StoreTemp1,StoreTemp1,(ULONG)&(g_Recompiler->FunctionTable()[0]),Multip_x4); + CompConstToX86regPointer(StoreTemp1,0); + JeLabel8("MemCheckDone",0); + uint8_t * MemCheckDone2 = m_RecompPos - 1; + + BeforeCallDirect(m_RegWorkingSet); + PushImm32("CRecompiler::Remove_StoreInstruc",CRecompiler::Remove_StoreInstruc); + PushImm32(strLen.c_str(),Length); + Push(AddressReg); + MoveConstToX86reg((uint32_t)g_Recompiler,x86_ECX); + Call_Direct(AddressOf(&CRecompiler::ClearRecompCode_Virt), "CRecompiler::ClearRecompCode_Virt"); + AfterCallDirect(m_RegWorkingSet); + + CPU_Message(" "); + CPU_Message(" MemCheckDone:"); + SetJump8(MemCheckDone,m_RecompPos); + SetJump8(MemCheckDone2,m_RecompPos); + + X86Protected(StoreTemp1) = false;*/ } void CMipsMemoryVM::Compile_SD() { - OPCODE & Opcode = CRecompilerOps::m_Opcode; - x86Reg TempReg1, TempReg2; + OPCODE & Opcode = CRecompilerOps::m_Opcode; + x86Reg TempReg1, TempReg2; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - if (IsConst(Opcode.base)) - { - DWORD Address = GetMipsRegLo(Opcode.base) + (short)Opcode.offset; - - if (IsConst(Opcode.rt)) - { - Compile_SW_Const(Is64Bit(Opcode.rt) ? GetMipsRegHi(Opcode.rt) : (GetMipsRegLo_S(Opcode.rt) >> 31), Address); - Compile_SW_Const(GetMipsRegLo(Opcode.rt), Address + 4); - } - else if (IsMapped(Opcode.rt)) - { - Compile_SW_Register(Is64Bit(Opcode.rt) ? GetMipsRegMapHi(Opcode.rt) : Map_TempReg(x86_Any, Opcode.rt, true), Address); - Compile_SW_Register(GetMipsRegMapLo(Opcode.rt), Address + 4); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.rt, true); - Compile_SW_Register(TempReg1, Address); - Compile_SW_Register(Map_TempReg(TempReg1,Opcode.rt,false), Address + 4); - } - } - else - { - if (IsMapped(Opcode.rt)) - { - ProtectGPR(Opcode.rt); - } - if (IsMapped(Opcode.base)) - { - ProtectGPR(Opcode.base); - if (Opcode.offset != 0) - { - TempReg1 = Map_TempReg(x86_Any, -1, false); - LeaSourceAndOffset(TempReg1,GetMipsRegMapLo(Opcode.base),(short)Opcode.offset); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - } - UnProtectGPR(Opcode.base); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - AddConstToX86Reg(TempReg1,(short)Opcode.immediate); - } - - Compile_StoreInstructClean(TempReg1,8); - - if (g_System->bUseTlb()) - { - TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_WriteMap,"m_TLB_WriteMap",TempReg2,TempReg2,4); - CompileWriteTLBMiss(TempReg1,TempReg2); + if (IsConst(Opcode.base)) + { + uint32_t Address = GetMipsRegLo(Opcode.base) + (int16_t)Opcode.offset; - if (IsConst(Opcode.rt)) - { - if (Is64Bit(Opcode.rt)) - { - MoveConstToX86regPointer(GetMipsRegHi(Opcode.rt),TempReg1, TempReg2); - } - else - { - MoveConstToX86regPointer((GetMipsRegLo_S(Opcode.rt) >> 31),TempReg1, TempReg2); - } - AddConstToX86Reg(TempReg1,4); - MoveConstToX86regPointer(GetMipsRegLo(Opcode.rt),TempReg1, TempReg2); - } - else if (IsMapped(Opcode.rt)) - { - if (Is64Bit(Opcode.rt)) - { - MoveX86regToX86regPointer(GetMipsRegMapHi(Opcode.rt),TempReg1, TempReg2); - } - else - { - MoveX86regToX86regPointer(Map_TempReg(x86_Any, Opcode.rt, true), TempReg1, TempReg2); - } - AddConstToX86Reg(TempReg1,4); - MoveX86regToX86regPointer(GetMipsRegMapLo(Opcode.rt),TempReg1, TempReg2); - } - else - { - x86Reg Reg = Map_TempReg(x86_Any, Opcode.rt, true); - MoveX86regToX86regPointer(Reg,TempReg1, TempReg2); - AddConstToX86Reg(TempReg1,4); - MoveX86regToX86regPointer(Map_TempReg(Reg, Opcode.rt, false), TempReg1, TempReg2); - } - } - else - { - AndConstToX86Reg(TempReg1,0x1FFFFFFF); - if (IsConst(Opcode.rt)) - { - if (Is64Bit(Opcode.rt)) - { - MoveConstToN64Mem(GetMipsRegHi(Opcode.rt),TempReg1); - } - else if (IsSigned(Opcode.rt)) - { - MoveConstToN64Mem((GetMipsRegLo_S(Opcode.rt) >> 31),TempReg1); - } - else - { - MoveConstToN64Mem(0,TempReg1); - } - MoveConstToN64MemDisp(GetMipsRegLo(Opcode.rt),TempReg1,4); - } - else if (IsKnown(Opcode.rt) && IsMapped(Opcode.rt)) - { - if (Is64Bit(Opcode.rt)) - { - MoveX86regToN64Mem(GetMipsRegMapHi(Opcode.rt),TempReg1); - } - else if (IsSigned(Opcode.rt)) - { - MoveX86regToN64Mem(Map_TempReg(x86_Any, Opcode.rt, true), TempReg1); - } - else - { - MoveConstToN64Mem(0,TempReg1); - } - MoveX86regToN64MemDisp(GetMipsRegMapLo(Opcode.rt),TempReg1, 4); - } - else - { - x86Reg Reg; - MoveX86regToN64Mem(Reg = Map_TempReg(x86_Any, Opcode.rt, true), TempReg1); - MoveX86regToN64MemDisp(Map_TempReg(Reg, Opcode.rt, false), TempReg1, 4); - } - } - } + if (IsConst(Opcode.rt)) + { + Compile_SW_Const(Is64Bit(Opcode.rt) ? GetMipsRegHi(Opcode.rt) : (GetMipsRegLo_S(Opcode.rt) >> 31), Address); + Compile_SW_Const(GetMipsRegLo(Opcode.rt), Address + 4); + } + else if (IsMapped(Opcode.rt)) + { + Compile_SW_Register(Is64Bit(Opcode.rt) ? GetMipsRegMapHi(Opcode.rt) : Map_TempReg(x86_Any, Opcode.rt, true), Address); + Compile_SW_Register(GetMipsRegMapLo(Opcode.rt), Address + 4); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.rt, true); + Compile_SW_Register(TempReg1, Address); + Compile_SW_Register(Map_TempReg(TempReg1, Opcode.rt, false), Address + 4); + } + } + else + { + if (IsMapped(Opcode.rt)) + { + ProtectGPR(Opcode.rt); + } + if (IsMapped(Opcode.base)) + { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) + { + TempReg1 = Map_TempReg(x86_Any, -1, false); + LeaSourceAndOffset(TempReg1, GetMipsRegMapLo(Opcode.base), (int16_t)Opcode.offset); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + } + UnProtectGPR(Opcode.base); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + AddConstToX86Reg(TempReg1, (int16_t)Opcode.immediate); + } + + Compile_StoreInstructClean(TempReg1, 8); + + if (g_System->bUseTlb()) + { + TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_WriteMap, "m_TLB_WriteMap", TempReg2, TempReg2, 4); + CompileWriteTLBMiss(TempReg1, TempReg2); + + if (IsConst(Opcode.rt)) + { + if (Is64Bit(Opcode.rt)) + { + MoveConstToX86regPointer(GetMipsRegHi(Opcode.rt), TempReg1, TempReg2); + } + else + { + MoveConstToX86regPointer((GetMipsRegLo_S(Opcode.rt) >> 31), TempReg1, TempReg2); + } + AddConstToX86Reg(TempReg1, 4); + MoveConstToX86regPointer(GetMipsRegLo(Opcode.rt), TempReg1, TempReg2); + } + else if (IsMapped(Opcode.rt)) + { + if (Is64Bit(Opcode.rt)) + { + MoveX86regToX86regPointer(GetMipsRegMapHi(Opcode.rt), TempReg1, TempReg2); + } + else + { + MoveX86regToX86regPointer(Map_TempReg(x86_Any, Opcode.rt, true), TempReg1, TempReg2); + } + AddConstToX86Reg(TempReg1, 4); + MoveX86regToX86regPointer(GetMipsRegMapLo(Opcode.rt), TempReg1, TempReg2); + } + else + { + x86Reg Reg = Map_TempReg(x86_Any, Opcode.rt, true); + MoveX86regToX86regPointer(Reg, TempReg1, TempReg2); + AddConstToX86Reg(TempReg1, 4); + MoveX86regToX86regPointer(Map_TempReg(Reg, Opcode.rt, false), TempReg1, TempReg2); + } + } + else + { + AndConstToX86Reg(TempReg1, 0x1FFFFFFF); + if (IsConst(Opcode.rt)) + { + if (Is64Bit(Opcode.rt)) + { + MoveConstToN64Mem(GetMipsRegHi(Opcode.rt), TempReg1); + } + else if (IsSigned(Opcode.rt)) + { + MoveConstToN64Mem((GetMipsRegLo_S(Opcode.rt) >> 31), TempReg1); + } + else + { + MoveConstToN64Mem(0, TempReg1); + } + MoveConstToN64MemDisp(GetMipsRegLo(Opcode.rt), TempReg1, 4); + } + else if (IsKnown(Opcode.rt) && IsMapped(Opcode.rt)) + { + if (Is64Bit(Opcode.rt)) + { + MoveX86regToN64Mem(GetMipsRegMapHi(Opcode.rt), TempReg1); + } + else if (IsSigned(Opcode.rt)) + { + MoveX86regToN64Mem(Map_TempReg(x86_Any, Opcode.rt, true), TempReg1); + } + else + { + MoveConstToN64Mem(0, TempReg1); + } + MoveX86regToN64MemDisp(GetMipsRegMapLo(Opcode.rt), TempReg1, 4); + } + else + { + x86Reg Reg; + MoveX86regToN64Mem(Reg = Map_TempReg(x86_Any, Opcode.rt, true), TempReg1); + MoveX86regToN64MemDisp(Map_TempReg(Reg, Opcode.rt, false), TempReg1, 4); + } + } + } } void CMipsMemoryVM::Compile_SDC1() { - OPCODE & Opcode = CRecompilerOps::m_Opcode; - x86Reg TempReg1, TempReg2, TempReg3; - char Name[50]; + OPCODE & Opcode = CRecompilerOps::m_Opcode; + x86Reg TempReg1, TempReg2, TempReg3; + char Name[50]; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - m_Section->CompileCop1Test(); - - if (IsConst(Opcode.base)) - { - DWORD Address = GetMipsRegLo(Opcode.base) + (short)Opcode.offset; + m_Section->CompileCop1Test(); - TempReg1 = Map_TempReg(x86_Any, -1, false); - sprintf(Name,"_FPR_D[%d]",Opcode.ft); - MoveVariableToX86reg((BYTE *)&_FPR_D[Opcode.ft],Name,TempReg1); - AddConstToX86Reg(TempReg1,4); - MoveX86PointerToX86reg(TempReg1,TempReg1); - Compile_SW_Register(TempReg1, Address); + if (IsConst(Opcode.base)) + { + uint32_t Address = GetMipsRegLo(Opcode.base) + (int16_t)Opcode.offset; - sprintf(Name,"_FPR_D[%d]",Opcode.ft); - MoveVariableToX86reg(&_FPR_D[Opcode.ft],Name,TempReg1); - MoveX86PointerToX86reg(TempReg1,TempReg1); - Compile_SW_Register(TempReg1, Address + 4); - return; - } - if (IsMapped(Opcode.base)) - { - ProtectGPR(Opcode.base); - if (Opcode.offset != 0) - { - TempReg1 = Map_TempReg(x86_Any, -1, false); - LeaSourceAndOffset(TempReg1,GetMipsRegMapLo(Opcode.base),(short)Opcode.offset); - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - } - } - else - { - TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); - if (Opcode.immediate == 0) - { - - } - else if (Opcode.immediate == 1) - { - IncX86reg(TempReg1); - } - else if (Opcode.immediate == 0xFFFF) - { - DecX86reg(TempReg1); - } - else - { - AddConstToX86Reg(TempReg1,(short)Opcode.immediate); - } - } - if (g_System->bUseTlb()) - { - TempReg2 = Map_TempReg(x86_Any, -1, false); - MoveX86RegToX86Reg(TempReg1, TempReg2); - ShiftRightUnsignImmed(TempReg2,12); - MoveVariableDispToX86Reg(m_TLB_WriteMap,"m_TLB_WriteMap",TempReg2,TempReg2,4); - CompileWriteTLBMiss(TempReg1,TempReg2); + TempReg1 = Map_TempReg(x86_Any, -1, false); + sprintf(Name, "_FPR_D[%d]", Opcode.ft); + MoveVariableToX86reg((uint8_t *)&_FPR_D[Opcode.ft], Name, TempReg1); + AddConstToX86Reg(TempReg1, 4); + MoveX86PointerToX86reg(TempReg1, TempReg1); + Compile_SW_Register(TempReg1, Address); - TempReg3 = Map_TempReg(x86_Any, -1, false); - sprintf(Name,"_FPR_D[%d]",Opcode.ft); - MoveVariableToX86reg((BYTE *)&_FPR_D[Opcode.ft],Name,TempReg3); - AddConstToX86Reg(TempReg3,4); - MoveX86PointerToX86reg(TempReg3,TempReg3); - MoveX86regToX86regPointer(TempReg3,TempReg1, TempReg2); - AddConstToX86Reg(TempReg1,4); + sprintf(Name, "_FPR_D[%d]", Opcode.ft); + MoveVariableToX86reg(&_FPR_D[Opcode.ft], Name, TempReg1); + MoveX86PointerToX86reg(TempReg1, TempReg1); + Compile_SW_Register(TempReg1, Address + 4); + return; + } + if (IsMapped(Opcode.base)) + { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) + { + TempReg1 = Map_TempReg(x86_Any, -1, false); + LeaSourceAndOffset(TempReg1, GetMipsRegMapLo(Opcode.base), (int16_t)Opcode.offset); + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + } + } + else + { + TempReg1 = Map_TempReg(x86_Any, Opcode.base, false); + if (Opcode.immediate == 0) + { + } + else if (Opcode.immediate == 1) + { + IncX86reg(TempReg1); + } + else if (Opcode.immediate == 0xFFFF) + { + DecX86reg(TempReg1); + } + else + { + AddConstToX86Reg(TempReg1, (int16_t)Opcode.immediate); + } + } + if (g_System->bUseTlb()) + { + TempReg2 = Map_TempReg(x86_Any, -1, false); + MoveX86RegToX86Reg(TempReg1, TempReg2); + ShiftRightUnsignImmed(TempReg2, 12); + MoveVariableDispToX86Reg(m_TLB_WriteMap, "m_TLB_WriteMap", TempReg2, TempReg2, 4); + CompileWriteTLBMiss(TempReg1, TempReg2); - sprintf(Name,"_FPR_D[%d]",Opcode.ft); - MoveVariableToX86reg((BYTE *)&_FPR_D[Opcode.ft],Name,TempReg3); - MoveX86PointerToX86reg(TempReg3,TempReg3); - MoveX86regToX86regPointer(TempReg3,TempReg1, TempReg2); - } - else - { - AndConstToX86Reg(TempReg1,0x1FFFFFFF); - TempReg3 = Map_TempReg(x86_Any, -1, false); - sprintf(Name,"_FPR_D[%d]",Opcode.ft); - MoveVariableToX86reg((BYTE *)&_FPR_D[Opcode.ft],Name,TempReg3); - AddConstToX86Reg(TempReg3,4); - MoveX86PointerToX86reg(TempReg3,TempReg3); - MoveX86regToN64Mem(TempReg3, TempReg1); - sprintf(Name,"_FPR_D[%d]",Opcode.ft); - MoveVariableToX86reg((BYTE *)&_FPR_D[Opcode.ft],Name,TempReg3); - MoveX86PointerToX86reg(TempReg3,TempReg3); - MoveX86regToN64MemDisp(TempReg3, TempReg1,4); - } + TempReg3 = Map_TempReg(x86_Any, -1, false); + sprintf(Name, "_FPR_D[%d]", Opcode.ft); + MoveVariableToX86reg((uint8_t *)&_FPR_D[Opcode.ft], Name, TempReg3); + AddConstToX86Reg(TempReg3, 4); + MoveX86PointerToX86reg(TempReg3, TempReg3); + MoveX86regToX86regPointer(TempReg3, TempReg1, TempReg2); + AddConstToX86Reg(TempReg1, 4); + + sprintf(Name, "_FPR_D[%d]", Opcode.ft); + MoveVariableToX86reg((uint8_t *)&_FPR_D[Opcode.ft], Name, TempReg3); + MoveX86PointerToX86reg(TempReg3, TempReg3); + MoveX86regToX86regPointer(TempReg3, TempReg1, TempReg2); + } + else + { + AndConstToX86Reg(TempReg1, 0x1FFFFFFF); + TempReg3 = Map_TempReg(x86_Any, -1, false); + sprintf(Name, "_FPR_D[%d]", Opcode.ft); + MoveVariableToX86reg((uint8_t *)&_FPR_D[Opcode.ft], Name, TempReg3); + AddConstToX86Reg(TempReg3, 4); + MoveX86PointerToX86reg(TempReg3, TempReg3); + MoveX86regToN64Mem(TempReg3, TempReg1); + sprintf(Name, "_FPR_D[%d]", Opcode.ft); + MoveVariableToX86reg((uint8_t *)&_FPR_D[Opcode.ft], Name, TempReg3); + MoveX86PointerToX86reg(TempReg3, TempReg3); + MoveX86regToN64MemDisp(TempReg3, TempReg1, 4); + } } void CMipsMemoryVM::Compile_SDL() { - OPCODE & Opcode = CRecompilerOps::m_Opcode; + OPCODE & Opcode = CRecompilerOps::m_Opcode; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - if (Opcode.base != 0) - { - UnMap_GPR(Opcode.base, true); - } + if (Opcode.base != 0) + { + UnMap_GPR(Opcode.base, true); + } - if (Opcode.rt != 0) - { - UnMap_GPR(Opcode.rt, true); - } + if (Opcode.rt != 0) + { + UnMap_GPR(Opcode.rt, true); + } - BeforeCallDirect(m_RegWorkingSet); - MoveConstToVariable(Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); - Call_Direct(R4300iOp::SDL, "R4300iOp::SDL"); - AfterCallDirect(m_RegWorkingSet); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToVariable(Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); + Call_Direct(R4300iOp::SDL, "R4300iOp::SDL"); + AfterCallDirect(m_RegWorkingSet); } void CMipsMemoryVM::Compile_SDR() { - OPCODE & Opcode = CRecompilerOps::m_Opcode; + OPCODE & Opcode = CRecompilerOps::m_Opcode; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(Opcode.Hex, m_CompilePC)); - if (Opcode.base != 0) - { - UnMap_GPR(Opcode.base, true); - } + if (Opcode.base != 0) + { + UnMap_GPR(Opcode.base, true); + } - if (Opcode.rt != 0) - { - UnMap_GPR(Opcode.rt, true); - } + if (Opcode.rt != 0) + { + UnMap_GPR(Opcode.rt, true); + } - BeforeCallDirect(m_RegWorkingSet); - MoveConstToVariable(Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); - Call_Direct(R4300iOp::SDR, "R4300iOp::SDR"); - AfterCallDirect(m_RegWorkingSet); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToVariable(Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); + Call_Direct(R4300iOp::SDR, "R4300iOp::SDR"); + AfterCallDirect(m_RegWorkingSet); } -LPCTSTR CMipsMemoryVM::LabelName ( DWORD Address ) const +LPCTSTR CMipsMemoryVM::LabelName(uint32_t Address) const { - //StringMap::iterator theIterator = m_LabelList.find(Address); - //if (theIterator != m_LabelList.end()) - //{ - // return (*theIterator).second; - //} - - sprintf(m_strLabelName,"0x%08X",Address); - return m_strLabelName; + //StringMap::iterator theIterator = m_LabelList.find(Address); + //if (theIterator != m_LabelList.end()) + //{ + // return (*theIterator).second; + //} + + sprintf(m_strLabelName, "0x%08X", Address); + return m_strLabelName; } -void CMipsMemoryVM::TLB_Mapped( DWORD VAddr, DWORD Len, DWORD PAddr, bool bReadOnly ) +void CMipsMemoryVM::TLB_Mapped(uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly) { - size_t count, VEnd; + size_t count, VEnd; - VEnd = VAddr + Len; - for (count = VAddr; count < VEnd; count += 0x1000) - { - size_t Index = count >> 12; - m_TLB_ReadMap[Index] = ((size_t)m_RDRAM + (count - VAddr + PAddr)) - count; - if (!bReadOnly) - { - m_TLB_WriteMap[Index] = ((size_t)m_RDRAM + (count - VAddr + PAddr)) - count; - } - } + VEnd = VAddr + Len; + for (count = VAddr; count < VEnd; count += 0x1000) + { + size_t Index = count >> 12; + m_TLB_ReadMap[Index] = ((size_t)m_RDRAM + (count - VAddr + PAddr)) - count; + if (!bReadOnly) + { + m_TLB_WriteMap[Index] = ((size_t)m_RDRAM + (count - VAddr + PAddr)) - count; + } + } } -void CMipsMemoryVM::TLB_Unmaped( DWORD Vaddr, DWORD Len ) +void CMipsMemoryVM::TLB_Unmaped(uint32_t Vaddr, uint32_t Len) { - size_t count, End; + size_t count, End; - End = Vaddr + Len; - for (count = Vaddr; count < End; count += 0x1000) - { - size_t Index = count >> 12; - m_TLB_ReadMap[Index] = NULL; - m_TLB_WriteMap[Index] = NULL; - } + End = Vaddr + Len; + for (count = Vaddr; count < End; count += 0x1000) + { + size_t Index = count >> 12; + m_TLB_ReadMap[Index] = NULL; + m_TLB_WriteMap[Index] = NULL; + } } -void CMipsMemoryVM::RdramChanged ( CMipsMemoryVM * _this ) +void CMipsMemoryVM::RdramChanged(CMipsMemoryVM * _this) { - const size_t new_size = g_Settings -> LoadDword(Game_RDRamSize); - const size_t old_size = _this -> m_AllocatedRdramSize; + const size_t new_size = g_Settings->LoadDword(Game_RDRamSize); + const size_t old_size = _this->m_AllocatedRdramSize; - if (old_size == new_size) - { - return; - } - if (old_size > new_size) - { - VirtualFree( - _this->m_RDRAM + new_size, - old_size - new_size, - MEM_DECOMMIT - ); - } - else - { - void * result; + if (old_size == new_size) + { + return; + } + if (old_size > new_size) + { + VirtualFree( + _this->m_RDRAM + new_size, + old_size - new_size, + MEM_DECOMMIT + ); + } + else + { + void * result; - result = VirtualAlloc( - _this->m_RDRAM + old_size, - new_size - old_size, - MEM_COMMIT, - PAGE_READWRITE - ); - if (result == NULL) - { - WriteTrace(TraceError, __FUNCTION__": failed to allocate extended memory"); - g_Notify -> FatalError(GS(MSG_MEM_ALLOC_ERROR)); - } - } + result = VirtualAlloc( + _this->m_RDRAM + old_size, + new_size - old_size, + MEM_COMMIT, + PAGE_READWRITE + ); + if (result == NULL) + { + WriteTrace(TraceError, __FUNCTION__": failed to allocate extended memory"); + g_Notify->FatalError(GS(MSG_MEM_ALLOC_ERROR)); + } + } - if (new_size > 0xFFFFFFFFul) - { // should be unreachable because: size_t new_size = g_Settings->(DWORD) - g_Notify -> BreakPoint(__FILEW__, __LINE__); - } // ...However, FFFFFFFF also is a limit to RCP addressing, so we care. - _this->m_AllocatedRdramSize = (uint32_t)new_size; + if (new_size > 0xFFFFFFFFul) + { // should be unreachable because: size_t new_size = g_Settings->(uint32_t) + g_Notify->BreakPoint(__FILEW__, __LINE__); + } // ...However, FFFFFFFF also is a limit to RCP addressing, so we care. + _this->m_AllocatedRdramSize = (uint32_t)new_size; } void CMipsMemoryVM::ChangeSpStatus() { - if ( ( RegModValue & SP_CLR_HALT ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_HALT; - } - if ( ( RegModValue & SP_SET_HALT ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_HALT; - } - if ( ( RegModValue & SP_CLR_BROKE ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_BROKE; - } - if ( ( RegModValue & SP_CLR_INTR ) != 0) - { - g_Reg->MI_INTR_REG &= ~MI_INTR_SP; - g_Reg->m_RspIntrReg &= ~MI_INTR_SP; - g_Reg->CheckInterrupts(); - } - if ( ( RegModValue & SP_SET_INTR ) != 0 && bHaveDebugger()) - { - g_Notify->DisplayError(L"SP_SET_INTR"); - } - if ( ( RegModValue & SP_CLR_SSTEP ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SSTEP; - } - if ( ( RegModValue & SP_SET_SSTEP ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SSTEP; - } - if ( ( RegModValue & SP_CLR_INTR_BREAK ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_INTR_BREAK; - } - if ( ( RegModValue & SP_SET_INTR_BREAK ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_INTR_BREAK; - } - if ( ( RegModValue & SP_CLR_SIG0 ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG0; - } - if ( ( RegModValue & SP_SET_SIG0 ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG0; - } - if ( ( RegModValue & SP_CLR_SIG1 ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG1; - } - if ( ( RegModValue & SP_SET_SIG1 ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG1; - } - if ( ( RegModValue & SP_CLR_SIG2 ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG2; - } - if ( ( RegModValue & SP_SET_SIG2 ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG2; - } - if ( ( RegModValue & SP_CLR_SIG3 ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG3; - } - if ( ( RegModValue & SP_SET_SIG3 ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG3; - } - if ( ( RegModValue & SP_CLR_SIG4 ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG4; - } - if ( ( RegModValue & SP_SET_SIG4 ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG4; - } - if ( ( RegModValue & SP_CLR_SIG5 ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG5; - } - if ( ( RegModValue & SP_SET_SIG5 ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG5; - } - if ( ( RegModValue & SP_CLR_SIG6 ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG6; - } - if ( ( RegModValue & SP_SET_SIG6 ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG6; - } - if ( ( RegModValue & SP_CLR_SIG7 ) != 0) - { - g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG7; - } - if ( ( RegModValue & SP_SET_SIG7 ) != 0) - { - g_Reg->SP_STATUS_REG |= SP_STATUS_SIG7; - } + if ((RegModValue & SP_CLR_HALT) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_HALT; + } + if ((RegModValue & SP_SET_HALT) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_HALT; + } + if ((RegModValue & SP_CLR_BROKE) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_BROKE; + } + if ((RegModValue & SP_CLR_INTR) != 0) + { + g_Reg->MI_INTR_REG &= ~MI_INTR_SP; + g_Reg->m_RspIntrReg &= ~MI_INTR_SP; + g_Reg->CheckInterrupts(); + } + if ((RegModValue & SP_SET_INTR) != 0 && bHaveDebugger()) + { + g_Notify->DisplayError(L"SP_SET_INTR"); + } + if ((RegModValue & SP_CLR_SSTEP) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SSTEP; + } + if ((RegModValue & SP_SET_SSTEP) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SSTEP; + } + if ((RegModValue & SP_CLR_INTR_BREAK) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_INTR_BREAK; + } + if ((RegModValue & SP_SET_INTR_BREAK) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_INTR_BREAK; + } + if ((RegModValue & SP_CLR_SIG0) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG0; + } + if ((RegModValue & SP_SET_SIG0) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG0; + } + if ((RegModValue & SP_CLR_SIG1) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG1; + } + if ((RegModValue & SP_SET_SIG1) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG1; + } + if ((RegModValue & SP_CLR_SIG2) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG2; + } + if ((RegModValue & SP_SET_SIG2) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG2; + } + if ((RegModValue & SP_CLR_SIG3) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG3; + } + if ((RegModValue & SP_SET_SIG3) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG3; + } + if ((RegModValue & SP_CLR_SIG4) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG4; + } + if ((RegModValue & SP_SET_SIG4) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG4; + } + if ((RegModValue & SP_CLR_SIG5) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG5; + } + if ((RegModValue & SP_SET_SIG5) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG5; + } + if ((RegModValue & SP_CLR_SIG6) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG6; + } + if ((RegModValue & SP_SET_SIG6) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG6; + } + if ((RegModValue & SP_CLR_SIG7) != 0) + { + g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG7; + } + if ((RegModValue & SP_SET_SIG7) != 0) + { + g_Reg->SP_STATUS_REG |= SP_STATUS_SIG7; + } - if ( ( RegModValue & SP_SET_SIG0 ) != 0 && g_System->RspAudioSignal()) - { - g_Reg->MI_INTR_REG |= MI_INTR_SP; - g_Reg->CheckInterrupts(); - } - //if (*( DWORD *)(DMEM + 0xFC0) == 1) - //{ - // ChangeTimer(RspTimer,0x40000); - //} - //else - //{ - try - { - g_System->RunRSP(); - } - catch (...) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - //} + if ((RegModValue & SP_SET_SIG0) != 0 && g_System->RspAudioSignal()) + { + g_Reg->MI_INTR_REG |= MI_INTR_SP; + g_Reg->CheckInterrupts(); + } + //if (*( uint32_t *)(DMEM + 0xFC0) == 1) + //{ + // ChangeTimer(RspTimer,0x40000); + //} + //else + //{ + try + { + g_System->RunRSP(); + } + catch (...) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + //} } void CMipsMemoryVM::ChangeMiIntrMask() { - if ( ( RegModValue & MI_INTR_MASK_CLR_SP ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_SP; - } - if ( ( RegModValue & MI_INTR_MASK_SET_SP ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_SP; - } - if ( ( RegModValue & MI_INTR_MASK_CLR_SI ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_SI; - } - if ( ( RegModValue & MI_INTR_MASK_SET_SI ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_SI; - } - if ( ( RegModValue & MI_INTR_MASK_CLR_AI ) != 0) - { - g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_AI; - } - if ( ( RegModValue & MI_INTR_MASK_SET_AI ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_AI; - } - if ( ( RegModValue & MI_INTR_MASK_CLR_VI ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_VI; - } - if ( ( RegModValue & MI_INTR_MASK_SET_VI ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_VI; - } - if ( ( RegModValue & MI_INTR_MASK_CLR_PI ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_PI; - } - if ( ( RegModValue & MI_INTR_MASK_SET_PI ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_PI; - } - if ( ( RegModValue & MI_INTR_MASK_CLR_DP ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_DP; - } - if ( ( RegModValue & MI_INTR_MASK_SET_DP ) != 0 ) - { - g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_DP; - } + if ((RegModValue & MI_INTR_MASK_CLR_SP) != 0) + { + g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_SP; + } + if ((RegModValue & MI_INTR_MASK_SET_SP) != 0) + { + g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_SP; + } + if ((RegModValue & MI_INTR_MASK_CLR_SI) != 0) + { + g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_SI; + } + if ((RegModValue & MI_INTR_MASK_SET_SI) != 0) + { + g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_SI; + } + if ((RegModValue & MI_INTR_MASK_CLR_AI) != 0) + { + g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_AI; + } + if ((RegModValue & MI_INTR_MASK_SET_AI) != 0) + { + g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_AI; + } + if ((RegModValue & MI_INTR_MASK_CLR_VI) != 0) + { + g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_VI; + } + if ((RegModValue & MI_INTR_MASK_SET_VI) != 0) + { + g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_VI; + } + if ((RegModValue & MI_INTR_MASK_CLR_PI) != 0) + { + g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_PI; + } + if ((RegModValue & MI_INTR_MASK_SET_PI) != 0) + { + g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_PI; + } + if ((RegModValue & MI_INTR_MASK_CLR_DP) != 0) + { + g_Reg->MI_INTR_MASK_REG &= ~MI_INTR_MASK_DP; + } + if ((RegModValue & MI_INTR_MASK_SET_DP) != 0) + { + g_Reg->MI_INTR_MASK_REG |= MI_INTR_MASK_DP; + } } diff --git a/Source/Project64/N64 System/Mips/Memory Virtual Mem.h b/Source/Project64/N64 System/Mips/Memory Virtual Mem.h index 53fca048e..000056827 100644 --- a/Source/Project64/N64 System/Mips/Memory Virtual Mem.h +++ b/Source/Project64/N64 System/Mips/Memory Virtual Mem.h @@ -11,12 +11,12 @@ #pragma once /* - * 64-bit Windows exception recovery facilities will expect to interact with - * the 64-bit registers of the Intel architecture (e.g., rax instead of eax). - * - * Attempting to read the 32-bit subsets seems to be erroneous and forbidden. - * Refer to "MemoryFilter" in `Memory Virtual Mem.cpp`. - */ +* 64-bit Windows exception recovery facilities will expect to interact with +* the 64-bit registers of the Intel architecture (e.g., rax instead of eax). +* +* Attempting to read the 32-bit subsets seems to be erroneous and forbidden. +* Refer to "MemoryFilter" in `Memory Virtual Mem.cpp`. +*/ #ifdef _WIN64 #define Eax Rax #define Ebx Rbx @@ -42,160 +42,160 @@ */ class CMipsMemoryVM : - public CMipsMemory, - public CTransVaddr, - private CRecompilerOps, - private R4300iOp, - private CPifRam, - private CFlashram, - private CSram, - private CDMA + public CMipsMemory, + public CTransVaddr, + private CRecompilerOps, + private R4300iOp, + private CPifRam, + private CFlashram, + private CSram, + private CDMA { public: - CMipsMemoryVM(CMipsMemory_CallBack * CallBack, bool SavesReadOnly); - ~CMipsMemoryVM(); - - static void ReserveMemory(); - static void FreeReservedMemory(); + CMipsMemoryVM(CMipsMemory_CallBack * CallBack, bool SavesReadOnly); + ~CMipsMemoryVM(); - bool Initialize (); - void Reset ( bool EraseMemory ); - - BYTE * Rdram (); - DWORD RdramSize (); - BYTE * Dmem (); - BYTE * Imem (); - BYTE * PifRam (); + static void ReserveMemory(); + static void FreeReservedMemory(); - bool LB_VAddr ( DWORD VAddr, BYTE & Value ); - bool LH_VAddr ( DWORD VAddr, WORD & Value ); - bool LW_VAddr ( DWORD VAddr, DWORD & Value ); - bool LD_VAddr ( DWORD VAddr, QWORD & Value ); + bool Initialize (); + void Reset ( bool EraseMemory ); - bool LB_PAddr ( DWORD PAddr, BYTE & Value ); - bool LH_PAddr ( DWORD PAddr, WORD & Value ); - bool LW_PAddr ( DWORD PAddr, DWORD & Value ); - bool LD_PAddr ( DWORD PAddr, QWORD & Value ); + uint8_t * Rdram (); + uint32_t RdramSize (); + uint8_t * Dmem (); + uint8_t * Imem (); + uint8_t * PifRam (); - bool SB_VAddr ( DWORD VAddr, BYTE Value ); - bool SH_VAddr ( DWORD VAddr, WORD Value ); - bool SW_VAddr ( DWORD VAddr, DWORD Value ); - bool SD_VAddr ( DWORD VAddr, QWORD Value ); + bool LB_VAddr ( uint32_t VAddr, uint8_t & Value ); + bool LH_VAddr ( uint32_t VAddr, uint16_t & Value ); + bool LW_VAddr ( uint32_t VAddr, uint32_t & Value ); + bool LD_VAddr ( uint32_t VAddr, uint64_t & Value ); - bool SB_PAddr ( DWORD PAddr, BYTE Value ); - bool SH_PAddr ( DWORD PAddr, WORD Value ); - bool SW_PAddr ( DWORD PAddr, DWORD Value ); - bool SD_PAddr ( DWORD PAddr, QWORD Value ); + bool LB_PAddr ( uint32_t PAddr, uint8_t & Value ); + bool LH_PAddr ( uint32_t PAddr, uint16_t & Value ); + bool LW_PAddr ( uint32_t PAddr, uint32_t & Value ); + bool LD_PAddr ( uint32_t PAddr, uint64_t & Value ); - int MemoryFilter(DWORD dwExptCode, void * lpExceptionPointer); - void UpdateFieldSerration(unsigned int interlaced); - - //Protect the Memory from being written to - void ProtectMemory(DWORD StartVaddr, DWORD EndVaddr); - void UnProtectMemory(DWORD StartVaddr, DWORD EndVaddr); + bool SB_VAddr ( uint32_t VAddr, uint8_t Value ); + bool SH_VAddr ( uint32_t VAddr, uint16_t Value ); + bool SW_VAddr ( uint32_t VAddr, uint32_t Value ); + bool SD_VAddr ( uint32_t VAddr, uint64_t Value ); - //Compilation Functions - void ResetMemoryStack(); + bool SB_PAddr ( uint32_t PAddr, uint8_t Value ); + bool SH_PAddr ( uint32_t PAddr, uint16_t Value ); + bool SW_PAddr ( uint32_t PAddr, uint32_t Value ); + bool SD_PAddr ( uint32_t PAddr, uint64_t Value ); - void Compile_LB(); - void Compile_LBU(); - void Compile_LH(); - void Compile_LHU(); - void Compile_LW(); - void Compile_LL(); - void Compile_LWC1(); - void Compile_LWU(); - void Compile_LWL(); - void Compile_LWR(); - void Compile_LD(); - void Compile_LDC1(); - void Compile_LDL(); - void Compile_LDR(); - void Compile_SB(); - void Compile_SH(); - void Compile_SW(); - void Compile_SWL(); - void Compile_SWR(); - void Compile_SD(); - void Compile_SDL(); - void Compile_SDR(); - void Compile_SC(); - void Compile_SWC1(); - void Compile_SDC1(); + int32_t MemoryFilter(uint32_t dwExptCode, void * lpExceptionPointer); + void UpdateFieldSerration(uint32_t interlaced); - void ResetMemoryStack ( CRegInfo& RegInfo ); - void Compile_LB ( CX86Ops::x86Reg Reg, DWORD Addr, bool SignExtend ); - void Compile_LH ( CX86Ops::x86Reg Reg, DWORD Addr, bool SignExtend ); - void Compile_LW ( CX86Ops::x86Reg Reg, DWORD Addr ); - void Compile_SB_Const ( BYTE Value, DWORD Addr ); - void Compile_SB_Register ( CX86Ops::x86Reg Reg, DWORD Addr ); - void Compile_SH_Const ( WORD Value, DWORD Addr ); - void Compile_SH_Register ( CX86Ops::x86Reg Reg, DWORD Addr ); - void Compile_SW_Const ( DWORD Value, DWORD Addr ); + //Protect the Memory from being written to + void ProtectMemory(uint32_t StartVaddr, uint32_t EndVaddr); + void UnProtectMemory(uint32_t StartVaddr, uint32_t EndVaddr); - void Compile_SW_Register ( CX86Ops::x86Reg Reg, DWORD Addr ); - - //Functions for TLB notification - void TLB_Mapped(DWORD VAddr, DWORD Len, DWORD PAddr, bool bReadOnly); - void TLB_Unmaped(DWORD Vaddr, DWORD Len); - - // CTransVaddr interface - bool TranslateVaddr(DWORD VAddr, DWORD &PAddr) const; - bool ValidVaddr(DWORD VAddr) const; - bool VAddrToRealAddr(DWORD VAddr, void * &RealAddress) const; - - // Labels - LPCTSTR LabelName(DWORD Address) const; + //Compilation Functions + void ResetMemoryStack(); + + void Compile_LB(); + void Compile_LBU(); + void Compile_LH(); + void Compile_LHU(); + void Compile_LW(); + void Compile_LL(); + void Compile_LWC1(); + void Compile_LWU(); + void Compile_LWL(); + void Compile_LWR(); + void Compile_LD(); + void Compile_LDC1(); + void Compile_LDL(); + void Compile_LDR(); + void Compile_SB(); + void Compile_SH(); + void Compile_SW(); + void Compile_SWL(); + void Compile_SWR(); + void Compile_SD(); + void Compile_SDL(); + void Compile_SDR(); + void Compile_SC(); + void Compile_SWC1(); + void Compile_SDC1(); + + void ResetMemoryStack ( CRegInfo& RegInfo ); + void Compile_LB ( CX86Ops::x86Reg Reg, uint32_t Addr, bool SignExtend ); + void Compile_LH ( CX86Ops::x86Reg Reg, uint32_t Addr, bool SignExtend ); + void Compile_LW ( CX86Ops::x86Reg Reg, uint32_t Addr ); + void Compile_SB_Const ( uint8_t Value, uint32_t Addr ); + void Compile_SB_Register ( CX86Ops::x86Reg Reg, uint32_t Addr ); + void Compile_SH_Const ( uint16_t Value, uint32_t Addr ); + void Compile_SH_Register ( CX86Ops::x86Reg Reg, uint32_t Addr ); + void Compile_SW_Const ( uint32_t Value, uint32_t Addr ); + + void Compile_SW_Register ( CX86Ops::x86Reg Reg, uint32_t Addr ); + + //Functions for TLB notification + void TLB_Mapped(uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly); + void TLB_Unmaped(uint32_t Vaddr, uint32_t Len); + + // CTransVaddr interface + bool TranslateVaddr(uint32_t VAddr, uint32_t &PAddr) const; + bool ValidVaddr(uint32_t VAddr) const; + bool VAddrToRealAddr(uint32_t VAddr, void * &RealAddress) const; + + // Labels + const char * LabelName(uint32_t Address) const; private: - CMipsMemoryVM(); // Disable default constructor - CMipsMemoryVM(const CMipsMemoryVM&); // Disable copy constructor - CMipsMemoryVM& operator=(const CMipsMemoryVM&); // Disable assignment + CMipsMemoryVM(); // Disable default constructor + CMipsMemoryVM(const CMipsMemoryVM&); // Disable copy constructor + CMipsMemoryVM& operator=(const CMipsMemoryVM&); // Disable assignment - void Compile_LW ( bool ResultSigned, bool bRecordLLbit ); - void Compile_SW ( bool bCheckLLbit ); + void Compile_LW ( bool ResultSigned, bool bRecordLLbit ); + void Compile_SW ( bool bCheckLLbit ); - static void RdramChanged ( CMipsMemoryVM * _this ); - static void ChangeSpStatus (); - static void ChangeMiIntrMask(); + static void RdramChanged ( CMipsMemoryVM * _this ); + static void ChangeSpStatus (); + static void ChangeMiIntrMask(); - bool LB_NonMemory ( DWORD PAddr, DWORD * Value, bool SignExtend ); - bool LH_NonMemory ( DWORD PAddr, DWORD * Value, bool SignExtend ); - bool LW_NonMemory ( DWORD PAddr, DWORD * Value ); + bool LB_NonMemory ( uint32_t PAddr, uint32_t * Value, bool SignExtend ); + bool LH_NonMemory ( uint32_t PAddr, uint32_t * Value, bool SignExtend ); + bool LW_NonMemory ( uint32_t PAddr, uint32_t * Value ); - bool SB_NonMemory ( DWORD PAddr, BYTE Value ); - bool SH_NonMemory ( DWORD PAddr, WORD Value ); - bool SW_NonMemory ( DWORD PAddr, DWORD Value ); + bool SB_NonMemory ( uint32_t PAddr, uint8_t Value ); + bool SH_NonMemory ( uint32_t PAddr, uint16_t Value ); + bool SW_NonMemory ( uint32_t PAddr, uint32_t Value ); - void Compile_StoreInstructClean (x86Reg AddressReg, int Length ); + void Compile_StoreInstructClean (x86Reg AddressReg, int32_t Length ); - CMipsMemory_CallBack * const m_CBClass; + CMipsMemory_CallBack * const m_CBClass; - //Memory Locations - static BYTE * m_Reserve1, * m_Reserve2; - BYTE * m_RDRAM, * m_DMEM, * m_IMEM; - DWORD m_AllocatedRdramSize; + //Memory Locations + static uint8_t * m_Reserve1, * m_Reserve2; + uint8_t * m_RDRAM, * m_DMEM, * m_IMEM; + uint32_t m_AllocatedRdramSize; - //Rom Information - bool m_RomMapped; - BYTE * m_Rom; - DWORD m_RomSize; - bool m_RomWrittenTo; - DWORD m_RomWroteValue; + //Rom Information + bool m_RomMapped; + uint8_t * m_Rom; + uint32_t m_RomSize; + bool m_RomWrittenTo; + uint32_t m_RomWroteValue; - //Current Half line - void UpdateHalfLine(); - DWORD m_HalfLine; - DWORD m_HalfLineCheck; - DWORD m_FieldSerration; - DWORD m_TempValue; + //Current Half line + void UpdateHalfLine(); + uint32_t m_HalfLine; + uint32_t m_HalfLineCheck; + uint32_t m_FieldSerration; + uint32_t m_TempValue; - //Initializing and resetting information about the memory system - void FreeMemory(); + //Initializing and resetting information about the memory system + void FreeMemory(); - mutable char m_strLabelName[100]; + mutable char m_strLabelName[100]; - //BIG look up table to quickly translate the tlb to real mem address - size_t * m_TLB_ReadMap; - size_t * m_TLB_WriteMap; + //BIG look up table to quickly translate the tlb to real mem address + size_t * m_TLB_ReadMap; + size_t * m_TLB_WriteMap; }; diff --git a/Source/Project64/N64 System/Mips/TranslateVaddr.h b/Source/Project64/N64 System/Mips/TranslateVaddr.h index 8d0efdbb8..679158c4e 100644 --- a/Source/Project64/N64 System/Mips/TranslateVaddr.h +++ b/Source/Project64/N64 System/Mips/TranslateVaddr.h @@ -10,10 +10,9 @@ ****************************************************************************/ #pragma once -class CTransVaddr +__interface CTransVaddr { -public: - virtual bool TranslateVaddr ( DWORD VAddr, DWORD &PAddr) const = 0; - virtual bool ValidVaddr ( DWORD VAddr ) const = 0; - virtual bool VAddrToRealAddr ( DWORD VAddr, void * &RealAddress ) const = 0; + virtual bool TranslateVaddr ( uint32_t VAddr, uint32_t &PAddr) const = 0; + virtual bool ValidVaddr ( uint32_t VAddr ) const = 0; + virtual bool VAddrToRealAddr ( uint32_t VAddr, void * &RealAddress ) const = 0; }; diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index 1f3d363ae..1478963f7 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -1364,7 +1364,7 @@ void CN64System::DumpSyncErrors (CN64System * SecondCPU) for (count = -10; count < 10; count++) { DWORD OpcodeValue, Addr = m_Reg.m_PROGRAM_COUNTER + (count << 2); - if (g_MMU->LW_VAddr(Addr,OpcodeValue)) + if (g_MMU->LW_VAddr(Addr,(uint32_t &)OpcodeValue)) { Error.LogF("%X: %s\r\n",Addr,R4300iOpcodeName(OpcodeValue,Addr)); } @@ -1375,7 +1375,7 @@ void CN64System::DumpSyncErrors (CN64System * SecondCPU) for (count = 0; count < 50; count++) { DWORD OpcodeValue, Addr = m_LastSuccessSyncPC[0] + (count << 2); - if (g_MMU->LW_VAddr(Addr,OpcodeValue)) + if (g_MMU->LW_VAddr(Addr,(uint32_t &)OpcodeValue)) { Error.LogF("%X: %s\r\n",Addr,R4300iOpcodeName(OpcodeValue,Addr)); } @@ -1857,7 +1857,7 @@ void CN64System::RunRSP() DWORD Task = 0; if (m_RspBroke) { - g_MMU->LW_VAddr(0xA4000FC0,Task); + g_MMU->LW_VAddr(0xA4000FC0,(uint32_t &)Task); if (Task == 1 && (m_Reg.DPC_STATUS_REG & DPC_STATUS_FREEZE) != 0) { WriteTrace(TraceRSP, __FUNCTION__ ": Dlist that is frozen"); @@ -2060,7 +2060,7 @@ void CN64System::RefreshScreen() // if (bProfiling) { m_Profile.StartTimer(ProfilingAddr != Timer_None ? ProfilingAddr : Timer_R4300); } } -bool CN64System::WriteToProtectedMemory (DWORD Address, int length) +bool CN64System::WriteToProtectedMemory (uint32_t Address, int length) { WriteTraceF(TraceDebug,__FUNCTION__ ": Address: %X Len: %d",Address,length); if (m_Recomp) diff --git a/Source/Project64/N64 System/N64 Class.h b/Source/Project64/N64 System/N64 Class.h index 3bf2f2309..9f3ff3693 100644 --- a/Source/Project64/N64 System/N64 Class.h +++ b/Source/Project64/N64 System/N64 Class.h @@ -111,7 +111,7 @@ private: void CpuStopped(); //Function in CMipsMemory_CallBack - virtual bool WriteToProtectedMemory(DWORD Address, int length); + virtual bool WriteToProtectedMemory(uint32_t Address, int length); //Functions in CTLB_CB void TLB_Mapped(DWORD VAddr, DWORD Len, DWORD PAddr, bool bReadOnly); diff --git a/Source/Project64/N64 System/Recompiler/Code Block.cpp b/Source/Project64/N64 System/Recompiler/Code Block.cpp index c67100814..860f47f45 100644 --- a/Source/Project64/N64 System/Recompiler/Code Block.cpp +++ b/Source/Project64/N64 System/Recompiler/Code Block.cpp @@ -397,7 +397,7 @@ bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & Contin PermLoop = false; OPCODE Command; - if (!g_MMU->LW_VAddr(PC, (DWORD &)Command.Hex)) + if (!g_MMU->LW_VAddr(PC, Command.Hex)) { g_Notify->BreakPoint(__FILEW__,__LINE__); return false; @@ -730,7 +730,7 @@ bool CCodeBlock::Compile() } CompileExitCode(); - DWORD PAddr; + uint32_t PAddr; g_TransVaddr->TranslateVaddr(VAddrFirst(),PAddr); MD5(g_MMU->Rdram() + PAddr,(VAddrLast() - VAddrFirst()) + 4).get_digest(m_Hash); diff --git a/Source/Project64/N64 System/Recompiler/Code Section.cpp b/Source/Project64/N64 System/Recompiler/Code Section.cpp index 4e7c72d4a..6da875477 100644 --- a/Source/Project64/N64 System/Recompiler/Code Section.cpp +++ b/Source/Project64/N64 System/Recompiler/Code Section.cpp @@ -17,7 +17,7 @@ bool DelaySlotEffectsCompare(DWORD PC, DWORD Reg1, DWORD Reg2); static bool DelaySlotEffectsJump(DWORD JumpPC) { OPCODE Command; - if (!g_MMU->LW_VAddr(JumpPC, (DWORD &)Command.Hex)) + if (!g_MMU->LW_VAddr(JumpPC, Command.Hex)) return true; switch (Command.op) { @@ -58,7 +58,7 @@ static bool DelaySlotEffectsJump(DWORD JumpPC) { bool EffectDelaySlot = false; OPCODE NewCommand; - if (!g_MMU->LW_VAddr(JumpPC + 4, (DWORD &)NewCommand.Hex)) { + if (!g_MMU->LW_VAddr(JumpPC + 4, NewCommand.Hex)) { return true; } @@ -932,7 +932,7 @@ bool CCodeSection::GenerateX86Code ( DWORD Test ) do { __try { - if (!g_MMU->LW_VAddr(m_CompilePC,(DWORD &)m_Opcode.Hex)) + if (!g_MMU->LW_VAddr(m_CompilePC,m_Opcode.Hex)) { g_Notify->DisplayError(GS(MSG_FAIL_LOAD_WORD)); ExitThread(0); diff --git a/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp b/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp index a9b3a2e05..e8ebe7760 100644 --- a/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp +++ b/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp @@ -167,7 +167,7 @@ bool LoopAnalysis::CheckLoopRegisterUsage( CCodeSection * Section) CPU_Message("ContinueSectionPC = %08X",ContinueSectionPC); do { - if (!g_MMU->LW_VAddr(m_PC, (DWORD &)m_Command.Hex)) + if (!g_MMU->LW_VAddr(m_PC, m_Command.Hex)) { g_Notify->BreakPoint(__FILEW__,__LINE__); return false; diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp index 0a5aa6993..e2a879423 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp @@ -345,7 +345,7 @@ void CRecompiler::RecompilerMain_Lookup() } else { DWORD opsExecuted = 0; - while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= g_System->RdramSize()) + while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr) && PhysicalAddr >= g_System->RdramSize()) { CInterpreterCPU::ExecuteOps(g_System->CountPerOp()); opsExecuted += g_System->CountPerOp(); @@ -516,10 +516,10 @@ void CRecompiler::RecompilerMain_Lookup_TLB() while(!m_EndEmulation) { - if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr)) + if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr)) { m_Registers.DoTLBReadMiss(false,PROGRAM_COUNTER); - if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr)) + if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr)) { g_Notify->DisplayError(stdstr_f("Failed to translate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER).ToUTF16().c_str()); m_EndEmulation = true; @@ -549,7 +549,7 @@ void CRecompiler::RecompilerMain_Lookup_TLB() { DWORD opsExecuted = 0; - while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= g_System->RdramSize()) + while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr) && PhysicalAddr >= g_System->RdramSize()) { CInterpreterCPU::ExecuteOps(g_System->CountPerOp()); opsExecuted += g_System->CountPerOp(); @@ -597,7 +597,7 @@ void CRecompiler::RecompilerMain_Lookup_validate() } else { DWORD opsExecuted = 0; - while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= g_System->RdramSize()) + while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr) && PhysicalAddr >= g_System->RdramSize()) { CInterpreterCPU::ExecuteOps(g_System->CountPerOp()); opsExecuted += g_System->CountPerOp(); @@ -618,10 +618,10 @@ void CRecompiler::RecompilerMain_Lookup_validate_TLB() while(!m_EndEmulation) { - if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr)) + if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr)) { m_Registers.DoTLBReadMiss(false,PROGRAM_COUNTER); - if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr)) + if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr)) { g_Notify->DisplayError(stdstr_f("Failed to translate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER).ToUTF16().c_str()); m_EndEmulation = true; @@ -667,7 +667,7 @@ void CRecompiler::RecompilerMain_Lookup_validate_TLB() } else { DWORD opsExecuted = 0; - while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= g_System->RdramSize()) + while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr) && PhysicalAddr >= g_System->RdramSize()) { CInterpreterCPU::ExecuteOps(g_System->CountPerOp()); opsExecuted += g_System->CountPerOp(); @@ -847,7 +847,7 @@ void CRecompiler::RecompilerMain_ChangeMemory() CCompiledFunc * CRecompiler::CompilerCode() { DWORD pAddr = 0; - if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER,pAddr)) + if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER,(uint32_t &)pAddr)) { WriteTraceF(TraceError,__FUNCTION__ ": Failed to translate %X",PROGRAM_COUNTER); return NULL; @@ -859,7 +859,7 @@ CCompiledFunc * CRecompiler::CompilerCode() for (CCompiledFunc * Func = iter->second; Func != NULL; Func = Func->Next()) { DWORD PAddr; - if (g_TransVaddr->TranslateVaddr(Func->MinPC(),PAddr)) + if (g_TransVaddr->TranslateVaddr(Func->MinPC(),(uint32_t &)PAddr)) { MD5Digest Hash; MD5(g_MMU->Rdram() + PAddr,(Func->MaxPC() - Func->MinPC())+ 4).get_digest(Hash); @@ -970,7 +970,7 @@ void CRecompiler::ClearRecompCode_Virt(DWORD Address, int length,REMOVE_REASON R case FuncFind_PhysicalLookup: { DWORD pAddr = 0; - if (g_TransVaddr->TranslateVaddr(Address,pAddr)) + if (g_TransVaddr->TranslateVaddr(Address,(uint32_t &)pAddr)) { ClearRecompCode_Phys(pAddr,length,Reason); } @@ -995,7 +995,7 @@ void CRecompiler::ResetMemoryStackPos() } DWORD pAddr = 0; - if (g_TransVaddr->TranslateVaddr(m_Registers.m_GPR[29].UW[0],pAddr)) + if (g_TransVaddr->TranslateVaddr(m_Registers.m_GPR[29].UW[0],(uint32_t &)pAddr)) { m_MemoryStack = (DWORD)(g_MMU->Rdram() + pAddr); } else { diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp index 7a81c111d..0c19ffd12 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp @@ -61,7 +61,7 @@ void CRecompilerOps::Compile_Branch (CRecompilerOps::BranchFunction CompareFunc, { OPCODE Command; - if (!g_MMU->LW_VAddr(m_CompilePC + 4, (DWORD &)Command.Hex)) { + if (!g_MMU->LW_VAddr(m_CompilePC + 4, Command.Hex)) { g_Notify->DisplayError(GS(MSG_FAIL_LOAD_WORD)); ExitThread(0); } @@ -1694,7 +1694,7 @@ void CRecompilerOps::LUI() { x86Reg Reg = Map_MemoryStack(x86_Any, true, false); DWORD Address; - g_TransVaddr->TranslateVaddr(((short)m_Opcode.offset << 16), Address); + g_TransVaddr->TranslateVaddr(((short)m_Opcode.offset << 16), (uint32_t &)Address); if (Reg < 0) { MoveConstToVariable((DWORD)(Address + g_MMU->Rdram()), &(g_Recompiler->MemoryStackPos()), "MemoryStack"); } else { From c5fb02431a5ef6c7e00b56ee6d80ad13b116a69f Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 9 Nov 2015 05:30:20 +1100 Subject: [PATCH 089/213] [Project64] Remove N64 System/Types.h --- Source/Project64/N64 System.h | 1 - .../Debugger/Debugger - Memory Search.cpp | 8 +-- Source/Project64/N64 System/N64 Types.h | 26 ++++++++++ Source/Project64/N64 System/Types.h | 49 ------------------- 4 files changed, 30 insertions(+), 54 deletions(-) delete mode 100644 Source/Project64/N64 System/Types.h diff --git a/Source/Project64/N64 System.h b/Source/Project64/N64 System.h index 613213a57..017ff868c 100644 --- a/Source/Project64/N64 System.h +++ b/Source/Project64/N64 System.h @@ -16,7 +16,6 @@ #include #include "User Interface.h" -#include "N64 System/Types.h" class CNotification; #include "N64 System/Profiling Class.h" diff --git a/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp b/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp index 4fdc325ec..0672dfb9f 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp @@ -306,7 +306,7 @@ void CDebugMemorySearch::SearchForValue(void) int ItemId = m_SearchResults.GetItemData(i); SearchResultItem & Result = m_SearchResult[ItemId]; - DWORD NewValue = 0; + uint32_t NewValue = 0; bool valid = false; switch (Size) @@ -326,7 +326,7 @@ void CDebugMemorySearch::SearchForValue(void) } break; case _32Bit: - valid = g_MMU->LW_PAddr(Result.PAddr, (uint32_t &)NewValue); + valid = g_MMU->LW_PAddr(Result.PAddr, NewValue); break; default: g_Notify->BreakPoint(__FILEW__, __LINE__); @@ -441,7 +441,7 @@ void CDebugMemorySearch::SearchForUnknown() SearchResultItem & Result = m_SearchResult[ItemId]; bool UpdateResult = false; - DWORD NewValue = 0; + uint32_t NewValue = 0; bool valid = false; switch (Size) @@ -461,7 +461,7 @@ void CDebugMemorySearch::SearchForUnknown() } break; case _32Bit: - valid = g_MMU->LW_PAddr(Result.PAddr, (uint32_t &)NewValue); + valid = g_MMU->LW_PAddr(Result.PAddr, NewValue); break; default: g_Notify->BreakPoint(__FILEW__, __LINE__); diff --git a/Source/Project64/N64 System/N64 Types.h b/Source/Project64/N64 System/N64 Types.h index 91e1fbe8f..c6f3d8238 100644 --- a/Source/Project64/N64 System/N64 Types.h +++ b/Source/Project64/N64 System/N64 Types.h @@ -94,3 +94,29 @@ enum STEP_TYPE PERMLOOP_DELAY_DONE = 11, }; +union MIPS_WORD +{ + long W; + unsigned long UW; + short HW[2]; + unsigned short UHW[2]; + char B[4]; + unsigned char UB[4]; + + float F; +}; + +union MIPS_DWORD +{ + __int64 DW; + unsigned __int64 UDW; + long W[2]; + unsigned long UW[2]; + short HW[4]; + unsigned short UHW[4]; + char B[8]; + unsigned char UB[8]; + + double D; + float F[2]; +}; diff --git a/Source/Project64/N64 System/Types.h b/Source/Project64/N64 System/Types.h deleted file mode 100644 index 4627d6b2f..000000000 --- a/Source/Project64/N64 System/Types.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -* * -* Project 64 - A Nintendo 64 emulator. * -* http://www.pj64-emu.com/ * -* Copyright (C) 2012 Project64. All rights reserved. * -* * -* License: * -* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * -* * -****************************************************************************/ -#pragma once - -#include - -/* - * To do: Use fixed-size types for MIPS union members, not WINAPI types. - * On Win32 x86, `unsigned long DWORD` versus `int32_t` is the only conflict. - */ -typedef unsigned char BYTE; -typedef unsigned short WORD; -typedef unsigned long DWORD; -typedef unsigned __int64 QWORD; -typedef void * HANDLE; -typedef int BOOL; - -union MIPS_WORD { - long W; - unsigned long UW; - short HW[2]; - unsigned short UHW[2]; - char B[4]; - unsigned char UB[4]; - - float F; -}; - -union MIPS_DWORD { - __int64 DW; - unsigned __int64 UDW; - long W[2]; - unsigned long UW[2]; - short HW[4]; - unsigned short UHW[4]; - char B[8]; - unsigned char UB[8]; - - double D; - float F[2]; -}; From 2d16f87c7fff10bca17b10514ff750b179e06616 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 9 Nov 2015 05:49:30 +1100 Subject: [PATCH 090/213] [Project64] change MIPS_WORD and MIPS_DWORD to use standard types --- Source/Project64/N64 System/N64 Types.h | 42 +++++++++++-------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/Source/Project64/N64 System/N64 Types.h b/Source/Project64/N64 System/N64 Types.h index c6f3d8238..791cd9e3e 100644 --- a/Source/Project64/N64 System/N64 Types.h +++ b/Source/Project64/N64 System/N64 Types.h @@ -10,12 +10,6 @@ ****************************************************************************/ #pragma once -typedef unsigned char BYTE; -typedef unsigned short WORD; -typedef unsigned long DWORD; -typedef unsigned __int64 QWORD; -typedef void * HANDLE; - enum PauseType { PauseType_FromMenu, @@ -94,29 +88,29 @@ enum STEP_TYPE PERMLOOP_DELAY_DONE = 11, }; -union MIPS_WORD +union MIPS_WORD { - long W; - unsigned long UW; - short HW[2]; - unsigned short UHW[2]; - char B[4]; - unsigned char UB[4]; + int32_t W; + uint32_t UW; + int16_t HW[2]; + uint16_t UHW[2]; + int8_t B[4]; + uint8_t UB[4]; - float F; + float F; }; union MIPS_DWORD { - __int64 DW; - unsigned __int64 UDW; - long W[2]; - unsigned long UW[2]; - short HW[4]; - unsigned short UHW[4]; - char B[8]; - unsigned char UB[8]; + int64_t DW; + uint64_t UDW; + int32_t W[2]; + uint32_t UW[2]; + int16_t HW[4]; + uint16_t UHW[4]; + int8_t B[8]; + uint8_t UB[8]; - double D; - float F[2]; + double D; + float F[2]; }; From dc2a4683da55cb8954fd3e99d50fe00bbc1e11e1 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 9 Nov 2015 05:53:05 +1100 Subject: [PATCH 091/213] [Project64] Change Speed Limitor Class to use standard types --- Source/Project64/N64 System/N64 Class.cpp | 10 +- .../N64 System/Speed Limitor Class.cpp | 156 ++++++++++-------- .../N64 System/Speed Limitor Class.h | 26 +-- 3 files changed, 102 insertions(+), 90 deletions(-) diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index 1478963f7..a3768b691 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -2014,18 +2014,18 @@ void CN64System::RefreshScreen() } g_MMU->UpdateFieldSerration((m_Reg.VI_STATUS_REG & 0x40) != 0); - - if ((bBasicMode() || bLimitFPS() ) && !bSyncToAudio()) + + if ((bBasicMode() || bLimitFPS()) && !bSyncToAudio()) { if (bShowCPUPer()) { m_CPU_Usage.StartTimer(Timer_Idel); } - DWORD FrameRate; - if (m_Limitor.Timer_Process(&FrameRate) && bDisplayFrameRate()) + uint32_t FrameRate; + if (m_Limitor.Timer_Process(&FrameRate) && bDisplayFrameRate()) { m_FPS.DisplayViCounter(FrameRate); m_bCleanFrameBox = true; } } - else if (bDisplayFrameRate()) + else if (bDisplayFrameRate()) { if (bShowCPUPer()) { m_CPU_Usage.StartTimer(Timer_UpdateFPS); } m_FPS.UpdateViCounter(); diff --git a/Source/Project64/N64 System/Speed Limitor Class.cpp b/Source/Project64/N64 System/Speed Limitor Class.cpp index 5d61147dd..03b7fa13b 100644 --- a/Source/Project64/N64 System/Speed Limitor Class.cpp +++ b/Source/Project64/N64 System/Speed Limitor Class.cpp @@ -9,104 +9,116 @@ * * ****************************************************************************/ #include "stdafx.h" -#pragma comment(lib, "winmm.lib") +#include "Speed Limitor Class.h" +#include +#include +#include + +#pragma comment(lib, "winmm.lib") CSpeedLimitor::CSpeedLimitor() { - m_Frames = 0; - m_LastTime = 0; - m_Speed = 60; - m_BaseSpeed = 60; - m_Ratio = 1000.0F / (float)m_Speed; + m_Frames = 0; + m_LastTime = 0; + m_Speed = 60; + m_BaseSpeed = 60; + m_Ratio = 1000.0F / (float)m_Speed; - TIMECAPS Caps; - timeGetDevCaps(&Caps, sizeof(Caps)); - if (timeBeginPeriod(Caps.wPeriodMin) == TIMERR_NOCANDO) { - g_Notify->DisplayError(L"Error during timer begin"); - } + TIMECAPS Caps; + timeGetDevCaps(&Caps, sizeof(Caps)); + if (timeBeginPeriod(Caps.wPeriodMin) == TIMERR_NOCANDO) + { + g_Notify->DisplayError(L"Error during timer begin"); + } } CSpeedLimitor::~CSpeedLimitor() { - TIMECAPS Caps; - timeGetDevCaps(&Caps, sizeof(Caps)); - timeEndPeriod(Caps.wPeriodMin); + TIMECAPS Caps; + timeGetDevCaps(&Caps, sizeof(Caps)); + timeEndPeriod(Caps.wPeriodMin); } -void CSpeedLimitor::SetHertz(DWORD Hertz) +void CSpeedLimitor::SetHertz(uint32_t Hertz) { - m_Speed = Hertz; - m_BaseSpeed = Hertz; - FixSpeedRatio(); + m_Speed = Hertz; + m_BaseSpeed = Hertz; + FixSpeedRatio(); } void CSpeedLimitor::FixSpeedRatio() { - m_Ratio = 1000.0f / static_cast(m_Speed); - m_Frames = 0; - m_LastTime = timeGetTime(); + m_Ratio = 1000.0f / static_cast(m_Speed); + m_Frames = 0; + m_LastTime = timeGetTime(); } -bool CSpeedLimitor::Timer_Process (DWORD * FrameRate ) { - m_Frames += 1; - DWORD CurrentTime = timeGetTime(); - - /* Calculate time that should of elapsed for this frame */ - double CalculatedTime = (double)m_LastTime + (m_Ratio * (double)m_Frames); - if ((double)CurrentTime < CalculatedTime) { - long time = (int)(CalculatedTime - (double)CurrentTime); - if (time > 0) { - Sleep(time); - } +bool CSpeedLimitor::Timer_Process(uint32_t * FrameRate) +{ + m_Frames += 1; + uint32_t CurrentTime = timeGetTime(); - /* Refresh current time */ - CurrentTime = timeGetTime(); - } + /* Calculate time that should of elapsed for this frame */ + double CalculatedTime = (double)m_LastTime + (m_Ratio * (double)m_Frames); + if ((double)CurrentTime < CalculatedTime) + { + int32_t time = (int)(CalculatedTime - (double)CurrentTime); + if (time > 0) + { + pjutil::Sleep(time); + } - if (CurrentTime - m_LastTime >= 1000) { - /* Output FPS */ - if (FrameRate != NULL) { *FrameRate = m_Frames; } - m_Frames = 0; - m_LastTime = CurrentTime; + /* Refresh current time */ + CurrentTime = timeGetTime(); + } - return true; - } else { - return false; - } + if (CurrentTime - m_LastTime >= 1000) + { + /* Output FPS */ + if (FrameRate != NULL) { *FrameRate = m_Frames; } + m_Frames = 0; + m_LastTime = CurrentTime; + + return true; + } + else + { + return false; + } } void CSpeedLimitor::IncreaseSpeed() { - if (m_Speed >= 60) - { - m_Speed += 10; - } - else if (m_Speed >= 15) - { - m_Speed += 5; - } - else - { - m_Speed += 1; - } - SpeedChanged(m_Speed); - FixSpeedRatio(); + if (m_Speed >= 60) + { + m_Speed += 10; + } + else if (m_Speed >= 15) + { + m_Speed += 5; + } + else + { + m_Speed += 1; + } + SpeedChanged(m_Speed); + FixSpeedRatio(); } void CSpeedLimitor::DecreaseSpeed() { - if (m_Speed > 60) - { - m_Speed -= 10; - } - else if (m_Speed > 15) - { - m_Speed -= 5; - } - else if (m_Speed > 1) - { - m_Speed -= 1; - } - SpeedChanged(m_Speed); - FixSpeedRatio(); + if (m_Speed > 60) + { + m_Speed -= 10; + } + else if (m_Speed > 15) + { + m_Speed -= 5; + } + else if (m_Speed > 1) + { + m_Speed -= 1; + } + SpeedChanged(m_Speed); + FixSpeedRatio(); } diff --git a/Source/Project64/N64 System/Speed Limitor Class.h b/Source/Project64/N64 System/Speed Limitor Class.h index 42cd3fd21..301d8221f 100644 --- a/Source/Project64/N64 System/Speed Limitor Class.h +++ b/Source/Project64/N64 System/Speed Limitor Class.h @@ -11,23 +11,23 @@ #pragma once class CSpeedLimitor : - private CGameSettings -{ + private CGameSettings +{ public: - CSpeedLimitor(); - ~CSpeedLimitor(); + CSpeedLimitor(); + ~CSpeedLimitor(); - void SetHertz(const DWORD Hertz); - bool Timer_Process(DWORD* const FrameRate); - void IncreaseSpeed(); - void DecreaseSpeed(); + void SetHertz(const uint32_t Hertz); + bool Timer_Process(uint32_t* const FrameRate); + void IncreaseSpeed(); + void DecreaseSpeed(); private: - CSpeedLimitor(const CSpeedLimitor&); // Disable copy constructor - CSpeedLimitor& operator=(const CSpeedLimitor&); // Disable assignment + CSpeedLimitor(const CSpeedLimitor&); // Disable copy constructor + CSpeedLimitor& operator=(const CSpeedLimitor&); // Disable assignment - void FixSpeedRatio(); + void FixSpeedRatio(); - DWORD m_Speed, m_BaseSpeed, m_Frames, m_LastTime; - double m_Ratio; + uint32_t m_Speed, m_BaseSpeed, m_Frames, m_LastTime; + double m_Ratio; }; From 21b80c240f7a91da185ae04dbc535c40b6282ab9 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 9 Nov 2015 07:21:28 +1100 Subject: [PATCH 092/213] [Project64] Change Pif Ram.cpp to use stdtypes --- Source/Project64/N64 System/Mips/Pif Ram.cpp | 310 +++++++++---------- 1 file changed, 155 insertions(+), 155 deletions(-) diff --git a/Source/Project64/N64 System/Mips/Pif Ram.cpp b/Source/Project64/N64 System/Mips/Pif Ram.cpp index b477922ec..7a4bfa37b 100644 --- a/Source/Project64/N64 System/Mips/Pif Ram.cpp +++ b/Source/Project64/N64 System/Mips/Pif Ram.cpp @@ -274,175 +274,175 @@ void CPifRam::SI_DMA_READ() BYTE * PifRamPos = m_PifRam; BYTE * RDRAM = g_MMU->Rdram(); - DWORD & SI_DRAM_ADDR_REG = g_Reg->SI_DRAM_ADDR_REG; - if ((int)SI_DRAM_ADDR_REG > (int)g_System->RdramSize()) - { - if (bShowPifRamErrors()) - { - g_Notify->DisplayError(L"SI DMA\nSI_DRAM_ADDR_REG not in RDRam space"); - } - return; - } - - PifRamRead(); - SI_DRAM_ADDR_REG &= 0xFFFFFFF8; - if ((int)SI_DRAM_ADDR_REG < 0) - { - int count, RdramPos; + uint32_t & SI_DRAM_ADDR_REG = (uint32_t &)g_Reg->SI_DRAM_ADDR_REG; + if ((int32_t)SI_DRAM_ADDR_REG > (int32_t)g_System->RdramSize()) + { + if (bShowPifRamErrors()) + { + g_Notify->DisplayError(__FUNCTIONW__ L"\nSI_DRAM_ADDR_REG not in RDRam space"); + } + return; + } - RdramPos = (int)SI_DRAM_ADDR_REG; - for (count = 0; count < 0x40; count++, RdramPos++) - { - if (RdramPos < 0) - { - continue; - } - RDRAM[RdramPos ^ 3] = m_PifRam[count]; - } - } - else - { + PifRamRead(); + SI_DRAM_ADDR_REG &= 0xFFFFFFF8; + if ((int32_t)SI_DRAM_ADDR_REG < 0) + { + int32_t count, RdramPos; + + RdramPos = (int32_t)SI_DRAM_ADDR_REG; + for (count = 0; count < 0x40; count++, RdramPos++) + { + if (RdramPos < 0) + { + continue; + } + RDRAM[RdramPos ^ 3] = m_PifRam[count]; + } + } + else + { for (size_t i = 0; i < 64; i++) { RDRAM[(SI_DRAM_ADDR_REG + i) ^ 3] = PifRamPos[i]; - } - } - - if (g_LogOptions.LogPRDMAMemStores) - { - int count; - char HexData[100], AsciiData[100], Addon[20]; - LogMessage("\tData DMAed to RDRAM:"); - LogMessage("\t--------------------"); - for (count = 0; count < 16; count ++ ) - { - if ((count % 4) == 0) - { - sprintf(HexData,"\0"); - sprintf(AsciiData,"\0"); - } - sprintf(Addon,"%02X %02X %02X %02X", - m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1], - m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] ); - strcat(HexData,Addon); - if (((count + 1) % 4) != 0) - { - sprintf(Addon,"-"); - strcat(HexData,Addon); - } - - sprintf(Addon,"%c%c%c%c", - m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1], - m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] ); - strcat(AsciiData,Addon); - - if (((count + 1) % 4) == 0) - { - LogMessage("\t%s %s",HexData, AsciiData); - } - } - LogMessage(""); - } + } + } - if (g_System->bDelaySI()) - { - g_SystemTimer->SetTimer(CSystemTimer::SiTimer,0x900,false); - } - else - { - g_Reg->MI_INTR_REG |= MI_INTR_SI; - g_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT; - g_Reg->CheckInterrupts(); - } + if (g_LogOptions.LogPRDMAMemStores) + { + int32_t count; + char HexData[100], AsciiData[100], Addon[20]; + LogMessage("\tData DMAed to RDRAM:"); + LogMessage("\t--------------------"); + for (count = 0; count < 16; count ++ ) + { + if ((count % 4) == 0) + { + sprintf(HexData,"\0"); + sprintf(AsciiData,"\0"); + } + sprintf(Addon,"%02X %02X %02X %02X", + m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1], + m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] ); + strcat(HexData,Addon); + if (((count + 1) % 4) != 0) + { + sprintf(Addon,"-"); + strcat(HexData,Addon); + } + + sprintf(Addon,"%c%c%c%c", + m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1], + m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] ); + strcat(AsciiData,Addon); + + if (((count + 1) % 4) == 0) + { + LogMessage("\t%s %s",HexData, AsciiData); + } + } + LogMessage(""); + } + + if (g_System->bDelaySI()) + { + g_SystemTimer->SetTimer(CSystemTimer::SiTimer, 0x900, false); + } + else + { + g_Reg->MI_INTR_REG |= MI_INTR_SI; + g_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT; + g_Reg->CheckInterrupts(); + } } void CPifRam::SI_DMA_WRITE() { - BYTE * PifRamPos = m_PifRam; - - DWORD & SI_DRAM_ADDR_REG = g_Reg->SI_DRAM_ADDR_REG; - if ((int)SI_DRAM_ADDR_REG > (int)g_System->RdramSize()) - { - if (bShowPifRamErrors()) - { - g_Notify->DisplayError(L"SI DMA\nSI_DRAM_ADDR_REG not in RDRam space"); - } - return; - } - - SI_DRAM_ADDR_REG &= 0xFFFFFFF8; - BYTE * RDRAM = g_MMU->Rdram(); + uint8_t * PifRamPos = m_PifRam; - if ((int)SI_DRAM_ADDR_REG < 0) - { - int RdramPos = (int)SI_DRAM_ADDR_REG; + uint32_t & SI_DRAM_ADDR_REG = (uint32_t &)g_Reg->SI_DRAM_ADDR_REG; + if ((int32_t)SI_DRAM_ADDR_REG > (int32_t)g_System->RdramSize()) + { + if (bShowPifRamErrors()) + { + g_Notify->DisplayError(L"SI DMA\nSI_DRAM_ADDR_REG not in RDRam space"); + } + return; + } - for (int count = 0; count < 0x40; count++, RdramPos++) - { - if (RdramPos < 0) - { - m_PifRam[count] = 0; continue; - } - m_PifRam[count] = RDRAM[RdramPos ^3]; - } - } - else - { + SI_DRAM_ADDR_REG &= 0xFFFFFFF8; + uint8_t * RDRAM = g_MMU->Rdram(); + + if ((int32_t)SI_DRAM_ADDR_REG < 0) + { + int32_t RdramPos = (int32_t)SI_DRAM_ADDR_REG; + + for (int32_t count = 0; count < 0x40; count++, RdramPos++) + { + if (RdramPos < 0) + { + m_PifRam[count] = 0; continue; + } + m_PifRam[count] = RDRAM[RdramPos ^ 3]; + } + } + else + { for (size_t i = 0; i < 64; i++) - { + { PifRamPos[i] = RDRAM[(SI_DRAM_ADDR_REG + i) ^ 3]; - } - } - - if (g_LogOptions.LogPRDMAMemLoads) - { - int count; - char HexData[100], AsciiData[100], Addon[20]; - LogMessage(""); - LogMessage("\tData DMAed to the Pif Ram:"); - LogMessage("\t--------------------------"); - for (count = 0; count < 16; count ++ ) - { - if ((count % 4) == 0) - { - sprintf(HexData,"\0"); - sprintf(AsciiData,"\0"); - } - sprintf(Addon,"%02X %02X %02X %02X", - m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1], - m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] ); - strcat(HexData,Addon); - if (((count + 1) % 4) != 0) - { - sprintf(Addon,"-"); - strcat(HexData,Addon); - } - - sprintf(Addon,"%c%c%c%c", - m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1], - m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] ); - strcat(AsciiData,Addon); - - if (((count + 1) % 4) == 0) - { - LogMessage("\t%s %s",HexData, AsciiData); - } - } - LogMessage(""); - } + } + } - PifRamWrite(); - - if (g_System->bDelaySI()) - { - g_SystemTimer->SetTimer(CSystemTimer::SiTimer,0x900,false); - } - else - { - g_Reg->MI_INTR_REG |= MI_INTR_SI; - g_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT; - g_Reg->CheckInterrupts(); - } + if (g_LogOptions.LogPRDMAMemLoads) + { + int32_t count; + char HexData[100], AsciiData[100], Addon[20]; + LogMessage(""); + LogMessage("\tData DMAed to the Pif Ram:"); + LogMessage("\t--------------------------"); + for (count = 0; count < 16; count ++ ) + { + if ((count % 4) == 0) + { + sprintf(HexData,"\0"); + sprintf(AsciiData,"\0"); + } + sprintf(Addon,"%02X %02X %02X %02X", + m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1], + m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] ); + strcat(HexData,Addon); + if (((count + 1) % 4) != 0) + { + sprintf(Addon,"-"); + strcat(HexData,Addon); + } + + sprintf(Addon,"%c%c%c%c", + m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1], + m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] ); + strcat(AsciiData,Addon); + + if (((count + 1) % 4) == 0) + { + LogMessage("\t%s %s",HexData, AsciiData); + } + } + LogMessage(""); + } + + PifRamWrite(); + + if (g_System->bDelaySI()) + { + g_SystemTimer->SetTimer(CSystemTimer::SiTimer, 0x900, false); + } + else + { + g_Reg->MI_INTR_REG |= MI_INTR_SI; + g_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT; + g_Reg->CheckInterrupts(); + } } void CPifRam::ProcessControllerCommand ( int Control, BYTE * Command) From 1a09c2baeadd11178ee335b305bb75193c7fa02e Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 9 Nov 2015 07:45:41 +1100 Subject: [PATCH 093/213] [Project64] Get Register class to use standard type --- .../Interpreter/Interpreter CPU.cpp | 4 +- .../N64 System/Mips/Register Class.cpp | 870 +++++++++--------- .../N64 System/Mips/Register Class.h | 808 ++++++++-------- .../Recompiler/Recompiler Class.cpp | 2 +- .../N64 System/Recompiler/Recompiler Class.h | 2 +- 5 files changed, 852 insertions(+), 834 deletions(-) diff --git a/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp b/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp index 62596c765..24c7afe18 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp @@ -264,7 +264,7 @@ void CInterpreterCPU::InPermLoop() void CInterpreterCPU::ExecuteCPU() { bool & Done = g_System->m_EndEmulation; - DWORD & PROGRAM_COUNTER = *_PROGRAM_COUNTER; + uint32_t & PROGRAM_COUNTER = *_PROGRAM_COUNTER; OPCODE & Opcode = R4300iOp::m_Opcode; DWORD & JumpToLocation = R4300iOp::m_JumpToLocation; bool & TestTimer = R4300iOp::m_TestTimer; @@ -350,7 +350,7 @@ void CInterpreterCPU::ExecuteCPU() void CInterpreterCPU::ExecuteOps(int Cycles) { bool & Done = g_System->m_EndEmulation; - DWORD & PROGRAM_COUNTER = *_PROGRAM_COUNTER; + uint32_t & PROGRAM_COUNTER = *_PROGRAM_COUNTER; OPCODE & Opcode = R4300iOp::m_Opcode; DWORD & JumpToLocation = R4300iOp::m_JumpToLocation; bool & TestTimer = R4300iOp::m_TestTimer; diff --git a/Source/Project64/N64 System/Mips/Register Class.cpp b/Source/Project64/N64 System/Mips/Register Class.cpp index 1cb8fd13f..6d12cc6cc 100644 --- a/Source/Project64/N64 System/Mips/Register Class.cpp +++ b/Source/Project64/N64 System/Mips/Register Class.cpp @@ -11,543 +11,531 @@ #include "stdafx.h" const char * CRegName::GPR[32] = {"r0","at","v0","v1","a0","a1","a2","a3", - "t0","t1","t2","t3","t4","t5","t6","t7", - "s0","s1","s2","s3","s4","s5","s6","s7", - "t8","t9","k0","k1","gp","sp","s8","ra"}; + "t0","t1","t2","t3","t4","t5","t6","t7", + "s0","s1","s2","s3","s4","s5","s6","s7", + "t8","t9","k0","k1","gp","sp","s8","ra"}; const char *CRegName::GPR_Hi[32] = {"r0.HI","at.HI","v0.HI","v1.HI","a0.HI","a1.HI", - "a2.HI","a3.HI","t0.HI","t1.HI","t2.HI","t3.HI", - "t4.HI","t5.HI","t6.HI","t7.HI","s0.HI","s1.HI", - "s2.HI","s3.HI","s4.HI","s5.HI","s6.HI","s7.HI", - "t8.HI","t9.HI","k0.HI","k1.HI","gp.HI","sp.HI", - "s8.HI","ra.HI"}; + "a2.HI","a3.HI","t0.HI","t1.HI","t2.HI","t3.HI", + "t4.HI","t5.HI","t6.HI","t7.HI","s0.HI","s1.HI", + "s2.HI","s3.HI","s4.HI","s5.HI","s6.HI","s7.HI", + "t8.HI","t9.HI","k0.HI","k1.HI","gp.HI","sp.HI", + "s8.HI","ra.HI"}; const char *CRegName::GPR_Lo[32] = {"r0.LO","at.LO","v0.LO","v1.LO","a0.LO","a1.LO", - "a2.LO","a3.LO","t0.LO","t1.LO","t2.LO","t3.LO", - "t4.LO","t5.LO","t6.LO","t7.LO","s0.LO","s1.LO", - "s2.LO","s3.LO","s4.LO","s5.LO","s6.LO","s7.LO", - "t8.LO","t9.LO","k0.LO","k1.LO","gp.LO","sp.LO", - "s8.LO","ra.LO"}; + "a2.LO","a3.LO","t0.LO","t1.LO","t2.LO","t3.LO", + "t4.LO","t5.LO","t6.LO","t7.LO","s0.LO","s1.LO", + "s2.LO","s3.LO","s4.LO","s5.LO","s6.LO","s7.LO", + "t8.LO","t9.LO","k0.LO","k1.LO","gp.LO","sp.LO", + "s8.LO","ra.LO"}; const char * CRegName::Cop0[32] = {"Index","Random","EntryLo0","EntryLo1","Context","PageMask","Wired","", - "BadVAddr","Count","EntryHi","Compare","Status","Cause","EPC","PRId", - "Config","LLAddr","WatchLo","WatchHi","XContext","","","", - "","","ECC","CacheErr","TagLo","TagHi","ErrEPC",""}; + "BadVAddr","Count","EntryHi","Compare","Status","Cause","EPC","PRId", + "Config","LLAddr","WatchLo","WatchHi","XContext","","","", + "","","ECC","CacheErr","TagLo","TagHi","ErrEPC",""}; const char * CRegName::FPR[32] = {"f0","f1","f2","f3","f4","f5","f6","f7", - "f8","f9","f10","f11","f12","f13","f14","f15", - "f16","f17","f18","f19","f20","f21","f22","f23", - "f24","f25","f26","f27","f28","f29","f30","f31"}; + "f8","f9","f10","f11","f12","f13","f14","f15", + "f16","f17","f18","f19","f20","f21","f22","f23", + "f24","f25","f26","f27","f28","f29","f30","f31"}; const char * CRegName::FPR_Ctrl[32] = {"Revision","Unknown","Unknown","Unknown","Unknown", - "Unknown","Unknown","Unknown","Unknown","Unknown","Unknown", - "Unknown","Unknown","Unknown","Unknown","Unknown","Unknown", - "Unknown","Unknown","Unknown","Unknown","Unknown","Unknown", - "Unknown","Unknown","Unknown","Unknown","Unknown","Unknown", - "Unknown","Unknown","FCSR"}; + "Unknown","Unknown","Unknown","Unknown","Unknown","Unknown", + "Unknown","Unknown","Unknown","Unknown","Unknown","Unknown", + "Unknown","Unknown","Unknown","Unknown","Unknown","Unknown", + "Unknown","Unknown","Unknown","Unknown","Unknown","Unknown", + "Unknown","Unknown","FCSR"}; -DWORD * CSystemRegisters::_PROGRAM_COUNTER = NULL; +uint32_t * CSystemRegisters::_PROGRAM_COUNTER = NULL; MIPS_DWORD * CSystemRegisters::_GPR = NULL; MIPS_DWORD * CSystemRegisters::_FPR = NULL; -DWORD * CSystemRegisters::_CP0 = NULL; +uint32_t * CSystemRegisters::_CP0 = NULL; MIPS_DWORD * CSystemRegisters::_RegHI = NULL; MIPS_DWORD * CSystemRegisters::_RegLO = NULL; -float ** CSystemRegisters::_FPR_S; +float ** CSystemRegisters::_FPR_S; double ** CSystemRegisters::_FPR_D; -DWORD * CSystemRegisters::_FPCR = NULL; -DWORD * CSystemRegisters::_LLBit = NULL; +uint32_t * CSystemRegisters::_FPCR = NULL; +uint32_t * CSystemRegisters::_LLBit = NULL; ROUNDING_MODE * CSystemRegisters::_RoundingModel = NULL; - -CP0registers::CP0registers(DWORD * _CP0) : - INDEX_REGISTER(_CP0[0]), - RANDOM_REGISTER(_CP0[1]), - ENTRYLO0_REGISTER(_CP0[2]), - ENTRYLO1_REGISTER(_CP0[3]), - CONTEXT_REGISTER(_CP0[4]), - PAGE_MASK_REGISTER(_CP0[5]), - WIRED_REGISTER(_CP0[6]), - BAD_VADDR_REGISTER(_CP0[8]), - COUNT_REGISTER(_CP0[9]), - ENTRYHI_REGISTER(_CP0[10]), - COMPARE_REGISTER(_CP0[11]), - STATUS_REGISTER(_CP0[12]), - CAUSE_REGISTER(_CP0[13]), - EPC_REGISTER(_CP0[14]), - CONFIG_REGISTER(_CP0[16]), - TAGLO_REGISTER(_CP0[28]), - TAGHI_REGISTER(_CP0[29]), - ERROREPC_REGISTER(_CP0[30]), - FAKE_CAUSE_REGISTER(_CP0[32]) +CP0registers::CP0registers(uint32_t * _CP0) : + INDEX_REGISTER(_CP0[0]), + RANDOM_REGISTER(_CP0[1]), + ENTRYLO0_REGISTER(_CP0[2]), + ENTRYLO1_REGISTER(_CP0[3]), + CONTEXT_REGISTER(_CP0[4]), + PAGE_MASK_REGISTER(_CP0[5]), + WIRED_REGISTER(_CP0[6]), + BAD_VADDR_REGISTER(_CP0[8]), + COUNT_REGISTER(_CP0[9]), + ENTRYHI_REGISTER(_CP0[10]), + COMPARE_REGISTER(_CP0[11]), + STATUS_REGISTER(_CP0[12]), + CAUSE_REGISTER(_CP0[13]), + EPC_REGISTER(_CP0[14]), + CONFIG_REGISTER(_CP0[16]), + TAGLO_REGISTER(_CP0[28]), + TAGHI_REGISTER(_CP0[29]), + ERROREPC_REGISTER(_CP0[30]), + FAKE_CAUSE_REGISTER(_CP0[32]) { - } -Rdram_InterfaceReg::Rdram_InterfaceReg(DWORD * _RdramInterface) : - RDRAM_CONFIG_REG(_RdramInterface[0]), - RDRAM_DEVICE_TYPE_REG(_RdramInterface[0]), - RDRAM_DEVICE_ID_REG(_RdramInterface[1]), - RDRAM_DELAY_REG(_RdramInterface[2]), - RDRAM_MODE_REG(_RdramInterface[3]), - RDRAM_REF_INTERVAL_REG(_RdramInterface[4]), - RDRAM_REF_ROW_REG(_RdramInterface[5]), - RDRAM_RAS_INTERVAL_REG(_RdramInterface[6]), - RDRAM_MIN_INTERVAL_REG(_RdramInterface[7]), - RDRAM_ADDR_SELECT_REG(_RdramInterface[8]), - RDRAM_DEVICE_MANUF_REG(_RdramInterface[9]) +Rdram_InterfaceReg::Rdram_InterfaceReg(uint32_t * _RdramInterface) : + RDRAM_CONFIG_REG(_RdramInterface[0]), + RDRAM_DEVICE_TYPE_REG(_RdramInterface[0]), + RDRAM_DEVICE_ID_REG(_RdramInterface[1]), + RDRAM_DELAY_REG(_RdramInterface[2]), + RDRAM_MODE_REG(_RdramInterface[3]), + RDRAM_REF_INTERVAL_REG(_RdramInterface[4]), + RDRAM_REF_ROW_REG(_RdramInterface[5]), + RDRAM_RAS_INTERVAL_REG(_RdramInterface[6]), + RDRAM_MIN_INTERVAL_REG(_RdramInterface[7]), + RDRAM_ADDR_SELECT_REG(_RdramInterface[8]), + RDRAM_DEVICE_MANUF_REG(_RdramInterface[9]) { - } -Mips_InterfaceReg::Mips_InterfaceReg(DWORD * _MipsInterface) : - MI_INIT_MODE_REG(_MipsInterface[0]), - MI_MODE_REG(_MipsInterface[0]), - MI_VERSION_REG(_MipsInterface[1]), - MI_NOOP_REG(_MipsInterface[1]), - MI_INTR_REG(_MipsInterface[2]), - MI_INTR_MASK_REG(_MipsInterface[3]) +Mips_InterfaceReg::Mips_InterfaceReg(uint32_t * _MipsInterface) : + MI_INIT_MODE_REG(_MipsInterface[0]), + MI_MODE_REG(_MipsInterface[0]), + MI_VERSION_REG(_MipsInterface[1]), + MI_NOOP_REG(_MipsInterface[1]), + MI_INTR_REG(_MipsInterface[2]), + MI_INTR_MASK_REG(_MipsInterface[3]) { - } -Video_InterfaceReg::Video_InterfaceReg(DWORD * _VideoInterface) : - VI_STATUS_REG(_VideoInterface[0]), - VI_CONTROL_REG(_VideoInterface[0]), - VI_ORIGIN_REG(_VideoInterface[1]), - VI_DRAM_ADDR_REG(_VideoInterface[1]), - VI_WIDTH_REG(_VideoInterface[2]), - VI_H_WIDTH_REG(_VideoInterface[2]), - VI_INTR_REG(_VideoInterface[3]), - VI_V_INTR_REG(_VideoInterface[3]), - VI_CURRENT_REG(_VideoInterface[4]), - VI_V_CURRENT_LINE_REG(_VideoInterface[4]), - VI_BURST_REG(_VideoInterface[5]), - VI_TIMING_REG(_VideoInterface[5]), - VI_V_SYNC_REG(_VideoInterface[6]), - VI_H_SYNC_REG(_VideoInterface[7]), - VI_LEAP_REG(_VideoInterface[8]), - VI_H_SYNC_LEAP_REG(_VideoInterface[8]), - VI_H_START_REG(_VideoInterface[9]), - VI_H_VIDEO_REG(_VideoInterface[9]), - VI_V_START_REG(_VideoInterface[10]), - VI_V_VIDEO_REG(_VideoInterface[10]), - VI_V_BURST_REG(_VideoInterface[11]), - VI_X_SCALE_REG(_VideoInterface[12]), - VI_Y_SCALE_REG(_VideoInterface[13]) +Video_InterfaceReg::Video_InterfaceReg(uint32_t * _VideoInterface) : + VI_STATUS_REG(_VideoInterface[0]), + VI_CONTROL_REG(_VideoInterface[0]), + VI_ORIGIN_REG(_VideoInterface[1]), + VI_DRAM_ADDR_REG(_VideoInterface[1]), + VI_WIDTH_REG(_VideoInterface[2]), + VI_H_WIDTH_REG(_VideoInterface[2]), + VI_INTR_REG(_VideoInterface[3]), + VI_V_INTR_REG(_VideoInterface[3]), + VI_CURRENT_REG(_VideoInterface[4]), + VI_V_CURRENT_LINE_REG(_VideoInterface[4]), + VI_BURST_REG(_VideoInterface[5]), + VI_TIMING_REG(_VideoInterface[5]), + VI_V_SYNC_REG(_VideoInterface[6]), + VI_H_SYNC_REG(_VideoInterface[7]), + VI_LEAP_REG(_VideoInterface[8]), + VI_H_SYNC_LEAP_REG(_VideoInterface[8]), + VI_H_START_REG(_VideoInterface[9]), + VI_H_VIDEO_REG(_VideoInterface[9]), + VI_V_START_REG(_VideoInterface[10]), + VI_V_VIDEO_REG(_VideoInterface[10]), + VI_V_BURST_REG(_VideoInterface[11]), + VI_X_SCALE_REG(_VideoInterface[12]), + VI_Y_SCALE_REG(_VideoInterface[13]) { - } -AudioInterfaceReg::AudioInterfaceReg(DWORD * _AudioInterface) : - AI_DRAM_ADDR_REG(_AudioInterface[0]), - AI_LEN_REG(_AudioInterface[1]), - AI_CONTROL_REG(_AudioInterface[2]), - AI_STATUS_REG(_AudioInterface[3]), - AI_DACRATE_REG(_AudioInterface[4]), - AI_BITRATE_REG(_AudioInterface[5]) +AudioInterfaceReg::AudioInterfaceReg(uint32_t * _AudioInterface) : + AI_DRAM_ADDR_REG(_AudioInterface[0]), + AI_LEN_REG(_AudioInterface[1]), + AI_CONTROL_REG(_AudioInterface[2]), + AI_STATUS_REG(_AudioInterface[3]), + AI_DACRATE_REG(_AudioInterface[4]), + AI_BITRATE_REG(_AudioInterface[5]) { - -} - -PeripheralInterfaceReg::PeripheralInterfaceReg(DWORD * PeripheralInterface) : - PI_DRAM_ADDR_REG(PeripheralInterface[0]), - PI_CART_ADDR_REG(PeripheralInterface[1]), - PI_RD_LEN_REG(PeripheralInterface[2]), - PI_WR_LEN_REG(PeripheralInterface[3]), - PI_STATUS_REG(PeripheralInterface[4]), - PI_BSD_DOM1_LAT_REG(PeripheralInterface[5]), - PI_DOMAIN1_REG(PeripheralInterface[5]), - PI_BSD_DOM1_PWD_REG(PeripheralInterface[6]), - PI_BSD_DOM1_PGS_REG(PeripheralInterface[7]), - PI_BSD_DOM1_RLS_REG(PeripheralInterface[8]), - PI_BSD_DOM2_LAT_REG(PeripheralInterface[9]), - PI_DOMAIN2_REG(PeripheralInterface[9]), - PI_BSD_DOM2_PWD_REG(PeripheralInterface[10]), - PI_BSD_DOM2_PGS_REG(PeripheralInterface[11]), - PI_BSD_DOM2_RLS_REG(PeripheralInterface[12]) -{ - } -RDRAMInt_InterfaceReg::RDRAMInt_InterfaceReg(DWORD * RdramInterface) : - RI_MODE_REG(RdramInterface[0]), - RI_CONFIG_REG(RdramInterface[1]), - RI_CURRENT_LOAD_REG(RdramInterface[2]), - RI_SELECT_REG(RdramInterface[3]), - RI_COUNT_REG(RdramInterface[4]), - RI_REFRESH_REG(RdramInterface[4]), - RI_LATENCY_REG(RdramInterface[5]), - RI_RERROR_REG(RdramInterface[6]), - RI_WERROR_REG(RdramInterface[7]) +PeripheralInterfaceReg::PeripheralInterfaceReg(uint32_t * PeripheralInterface) : + PI_DRAM_ADDR_REG(PeripheralInterface[0]), + PI_CART_ADDR_REG(PeripheralInterface[1]), + PI_RD_LEN_REG(PeripheralInterface[2]), + PI_WR_LEN_REG(PeripheralInterface[3]), + PI_STATUS_REG(PeripheralInterface[4]), + PI_BSD_DOM1_LAT_REG(PeripheralInterface[5]), + PI_DOMAIN1_REG(PeripheralInterface[5]), + PI_BSD_DOM1_PWD_REG(PeripheralInterface[6]), + PI_BSD_DOM1_PGS_REG(PeripheralInterface[7]), + PI_BSD_DOM1_RLS_REG(PeripheralInterface[8]), + PI_BSD_DOM2_LAT_REG(PeripheralInterface[9]), + PI_DOMAIN2_REG(PeripheralInterface[9]), + PI_BSD_DOM2_PWD_REG(PeripheralInterface[10]), + PI_BSD_DOM2_PGS_REG(PeripheralInterface[11]), + PI_BSD_DOM2_RLS_REG(PeripheralInterface[12]) { - } -DisplayControlReg::DisplayControlReg(DWORD * _DisplayProcessor) : - DPC_START_REG(_DisplayProcessor[0]), - DPC_END_REG(_DisplayProcessor[1]), - DPC_CURRENT_REG(_DisplayProcessor[2]), - DPC_STATUS_REG(_DisplayProcessor[3]), - DPC_CLOCK_REG(_DisplayProcessor[4]), - DPC_BUFBUSY_REG(_DisplayProcessor[5]), - DPC_PIPEBUSY_REG(_DisplayProcessor[6]), - DPC_TMEM_REG(_DisplayProcessor[7]) +RDRAMInt_InterfaceReg::RDRAMInt_InterfaceReg(uint32_t * RdramInterface) : + RI_MODE_REG(RdramInterface[0]), + RI_CONFIG_REG(RdramInterface[1]), + RI_CURRENT_LOAD_REG(RdramInterface[2]), + RI_SELECT_REG(RdramInterface[3]), + RI_COUNT_REG(RdramInterface[4]), + RI_REFRESH_REG(RdramInterface[4]), + RI_LATENCY_REG(RdramInterface[5]), + RI_RERROR_REG(RdramInterface[6]), + RI_WERROR_REG(RdramInterface[7]) { - } -SigProcessor_InterfaceReg::SigProcessor_InterfaceReg(DWORD * _SignalProcessorInterface) : - SP_MEM_ADDR_REG(_SignalProcessorInterface[0]), - SP_DRAM_ADDR_REG(_SignalProcessorInterface[1]), - SP_RD_LEN_REG(_SignalProcessorInterface[2]), - SP_WR_LEN_REG(_SignalProcessorInterface[3]), - SP_STATUS_REG(_SignalProcessorInterface[4]), - SP_DMA_FULL_REG(_SignalProcessorInterface[5]), - SP_DMA_BUSY_REG(_SignalProcessorInterface[6]), - SP_SEMAPHORE_REG(_SignalProcessorInterface[7]), - SP_PC_REG(_SignalProcessorInterface[8]), - SP_IBIST_REG(_SignalProcessorInterface[9]) +DisplayControlReg::DisplayControlReg(uint32_t * _DisplayProcessor) : + DPC_START_REG(_DisplayProcessor[0]), + DPC_END_REG(_DisplayProcessor[1]), + DPC_CURRENT_REG(_DisplayProcessor[2]), + DPC_STATUS_REG(_DisplayProcessor[3]), + DPC_CLOCK_REG(_DisplayProcessor[4]), + DPC_BUFBUSY_REG(_DisplayProcessor[5]), + DPC_PIPEBUSY_REG(_DisplayProcessor[6]), + DPC_TMEM_REG(_DisplayProcessor[7]) { - } -Serial_InterfaceReg::Serial_InterfaceReg(DWORD * SerialInterface) : - SI_DRAM_ADDR_REG(SerialInterface[0]), - SI_PIF_ADDR_RD64B_REG(SerialInterface[1]), - SI_PIF_ADDR_WR64B_REG(SerialInterface[2]), - SI_STATUS_REG(SerialInterface[3]) +SigProcessor_InterfaceReg::SigProcessor_InterfaceReg(uint32_t * _SignalProcessorInterface) : + SP_MEM_ADDR_REG(_SignalProcessorInterface[0]), + SP_DRAM_ADDR_REG(_SignalProcessorInterface[1]), + SP_RD_LEN_REG(_SignalProcessorInterface[2]), + SP_WR_LEN_REG(_SignalProcessorInterface[3]), + SP_STATUS_REG(_SignalProcessorInterface[4]), + SP_DMA_FULL_REG(_SignalProcessorInterface[5]), + SP_DMA_BUSY_REG(_SignalProcessorInterface[6]), + SP_SEMAPHORE_REG(_SignalProcessorInterface[7]), + SP_PC_REG(_SignalProcessorInterface[8]), + SP_IBIST_REG(_SignalProcessorInterface[9]) +{ +} + +Serial_InterfaceReg::Serial_InterfaceReg(uint32_t * SerialInterface) : + SI_DRAM_ADDR_REG(SerialInterface[0]), + SI_PIF_ADDR_RD64B_REG(SerialInterface[1]), + SI_PIF_ADDR_WR64B_REG(SerialInterface[2]), + SI_STATUS_REG(SerialInterface[3]) { - } CRegisters::CRegisters(CN64System * System, CSystemEvents * SystemEvents) : - CP0registers(m_CP0), - Rdram_InterfaceReg(m_RDRAM_Registers), - Mips_InterfaceReg(m_Mips_Interface), - Video_InterfaceReg(m_Video_Interface), - AudioInterfaceReg(m_Audio_Interface), - PeripheralInterfaceReg(m_Peripheral_Interface), - RDRAMInt_InterfaceReg(m_RDRAM_Interface), - SigProcessor_InterfaceReg(m_SigProcessor_Interface), - DisplayControlReg(m_Display_ControlReg), - Serial_InterfaceReg(m_SerialInterface), - m_System(System), - m_SystemEvents(SystemEvents) -{ - Reset(); + CP0registers(m_CP0), + Rdram_InterfaceReg(m_RDRAM_Registers), + Mips_InterfaceReg(m_Mips_Interface), + Video_InterfaceReg(m_Video_Interface), + AudioInterfaceReg(m_Audio_Interface), + PeripheralInterfaceReg(m_Peripheral_Interface), + RDRAMInt_InterfaceReg(m_RDRAM_Interface), + SigProcessor_InterfaceReg(m_SigProcessor_Interface), + DisplayControlReg(m_Display_ControlReg), + Serial_InterfaceReg(m_SerialInterface), + m_System(System), + m_SystemEvents(SystemEvents) +{ + Reset(); } void CRegisters::Reset() { - m_FirstInterupt = true; + m_FirstInterupt = true; - memset(m_GPR,0,sizeof(m_GPR)); - memset(m_CP0,0,sizeof(m_CP0)); - memset(m_FPR,0,sizeof(m_FPR)); - memset(m_FPCR,0,sizeof(m_FPCR)); - m_HI.DW = 0; - m_LO.DW = 0; - m_RoundingModel = ROUND_NEAR; - - m_LLBit = 0; + memset(m_GPR,0,sizeof(m_GPR)); + memset(m_CP0,0,sizeof(m_CP0)); + memset(m_FPR,0,sizeof(m_FPR)); + memset(m_FPCR,0,sizeof(m_FPCR)); + m_HI.DW = 0; + m_LO.DW = 0; + m_RoundingModel = ROUND_NEAR; - //Reset System Registers - memset(m_RDRAM_Interface,0,sizeof(m_RDRAM_Interface)); - memset(m_RDRAM_Registers,0,sizeof(m_RDRAM_Registers)); - memset(m_Mips_Interface,0,sizeof(m_Mips_Interface)); - memset(m_Video_Interface,0,sizeof(m_Video_Interface)); - memset(m_Display_ControlReg,0,sizeof(m_Display_ControlReg)); - memset(m_Audio_Interface,0,sizeof(m_Audio_Interface)); - memset(m_SigProcessor_Interface,0,sizeof(m_SigProcessor_Interface)); - memset(m_Peripheral_Interface,0,sizeof(m_Peripheral_Interface)); - memset(m_SerialInterface,0,sizeof(m_SerialInterface)); + m_LLBit = 0; - m_AudioIntrReg = 0; - m_GfxIntrReg = 0; - m_RspIntrReg = 0; - - FixFpuLocations(); + //Reset System Registers + memset(m_RDRAM_Interface,0,sizeof(m_RDRAM_Interface)); + memset(m_RDRAM_Registers,0,sizeof(m_RDRAM_Registers)); + memset(m_Mips_Interface,0,sizeof(m_Mips_Interface)); + memset(m_Video_Interface,0,sizeof(m_Video_Interface)); + memset(m_Display_ControlReg,0,sizeof(m_Display_ControlReg)); + memset(m_Audio_Interface,0,sizeof(m_Audio_Interface)); + memset(m_SigProcessor_Interface,0,sizeof(m_SigProcessor_Interface)); + memset(m_Peripheral_Interface,0,sizeof(m_Peripheral_Interface)); + memset(m_SerialInterface,0,sizeof(m_SerialInterface)); + + m_AudioIntrReg = 0; + m_GfxIntrReg = 0; + m_RspIntrReg = 0; + + FixFpuLocations(); } void CRegisters::SetAsCurrentSystem() { - _PROGRAM_COUNTER = &m_PROGRAM_COUNTER; - _GPR = m_GPR; - _FPR = m_FPR; - _CP0 = m_CP0; - _RegHI = &m_HI; - _RegLO = &m_LO; - _FPR_S = m_FPR_S; - _FPR_D = m_FPR_D; - _FPCR = m_FPCR; - _LLBit = &m_LLBit; - _RoundingModel = &m_RoundingModel; + _PROGRAM_COUNTER = &m_PROGRAM_COUNTER; + _GPR = m_GPR; + _FPR = m_FPR; + _CP0 = m_CP0; + _RegHI = &m_HI; + _RegLO = &m_LO; + _FPR_S = m_FPR_S; + _FPR_D = m_FPR_D; + _FPCR = m_FPCR; + _LLBit = &m_LLBit; + _RoundingModel = &m_RoundingModel; } void CRegisters::CheckInterrupts() { - if (!m_System->bFixedAudio() && CpuType() != CPU_SyncCores) - { - MI_INTR_REG &= ~MI_INTR_AI; - MI_INTR_REG |= (m_AudioIntrReg & MI_INTR_AI); - } - MI_INTR_REG |= (m_RspIntrReg & MI_INTR_SP); - MI_INTR_REG |= (m_GfxIntrReg & MI_INTR_DP); - if ((MI_INTR_MASK_REG & MI_INTR_REG) != 0) - { - FAKE_CAUSE_REGISTER |= CAUSE_IP2; - } - else - { - FAKE_CAUSE_REGISTER &= ~CAUSE_IP2; - } + if (!m_System->bFixedAudio() && CpuType() != CPU_SyncCores) + { + MI_INTR_REG &= ~MI_INTR_AI; + MI_INTR_REG |= (m_AudioIntrReg & MI_INTR_AI); + } + MI_INTR_REG |= (m_RspIntrReg & MI_INTR_SP); + MI_INTR_REG |= (m_GfxIntrReg & MI_INTR_DP); + if ((MI_INTR_MASK_REG & MI_INTR_REG) != 0) + { + FAKE_CAUSE_REGISTER |= CAUSE_IP2; + } + else + { + FAKE_CAUSE_REGISTER &= ~CAUSE_IP2; + } - if (( STATUS_REGISTER & STATUS_IE ) == 0 ) - { - return; - } - if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) - { - return; - } - if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) - { - return; - } + if (( STATUS_REGISTER & STATUS_IE ) == 0 ) + { + return; + } + if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) + { + return; + } + if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) + { + return; + } - if (( STATUS_REGISTER & FAKE_CAUSE_REGISTER & 0xFF00) != 0) - { - if (m_FirstInterupt) - { - m_FirstInterupt = false; - if (g_Recompiler) - { - g_Recompiler->ClearRecompCode_Virt(0x80000000,0x200,CRecompiler::Remove_InitialCode); - } - } - m_SystemEvents->QueueEvent(SysEvent_ExecuteInterrupt); - } + if (( STATUS_REGISTER & FAKE_CAUSE_REGISTER & 0xFF00) != 0) + { + if (m_FirstInterupt) + { + m_FirstInterupt = false; + if (g_Recompiler) + { + g_Recompiler->ClearRecompCode_Virt(0x80000000,0x200,CRecompiler::Remove_InitialCode); + } + } + m_SystemEvents->QueueEvent(SysEvent_ExecuteInterrupt); + } } -void CRegisters::DoAddressError(bool DelaySlot, DWORD BadVaddr, bool FromRead) +void CRegisters::DoAddressError(bool DelaySlot, uint32_t BadVaddr, bool FromRead) { - if (bHaveDebugger()) - { - g_Notify->DisplayError(L"AddressError"); - if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) - { - g_Notify->DisplayError(L"EXL set in AddressError Exception"); - } - if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) - { - g_Notify->DisplayError(L"ERL set in AddressError Exception"); - } - } + if (bHaveDebugger()) + { + g_Notify->DisplayError(L"AddressError"); + if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) + { + g_Notify->DisplayError(L"EXL set in AddressError Exception"); + } + if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) + { + g_Notify->DisplayError(L"ERL set in AddressError Exception"); + } + } - if (FromRead) - { - CAUSE_REGISTER = EXC_RADE; - } - else - { - CAUSE_REGISTER = EXC_WADE; - } - BAD_VADDR_REGISTER = BadVaddr; - if (DelaySlot) - { - CAUSE_REGISTER |= CAUSE_BD; - EPC_REGISTER = m_PROGRAM_COUNTER - 4; - } - else - { - EPC_REGISTER = m_PROGRAM_COUNTER; - } - STATUS_REGISTER |= STATUS_EXL; - m_PROGRAM_COUNTER = 0x80000180; + if (FromRead) + { + CAUSE_REGISTER = EXC_RADE; + } + else + { + CAUSE_REGISTER = EXC_WADE; + } + BAD_VADDR_REGISTER = BadVaddr; + if (DelaySlot) + { + CAUSE_REGISTER |= CAUSE_BD; + EPC_REGISTER = m_PROGRAM_COUNTER - 4; + } + else + { + EPC_REGISTER = m_PROGRAM_COUNTER; + } + STATUS_REGISTER |= STATUS_EXL; + m_PROGRAM_COUNTER = 0x80000180; } void CRegisters::FixFpuLocations() -{ - if ((STATUS_REGISTER & STATUS_FR) == 0) - { - for (int count = 0; count < 32; count ++) - { - m_FPR_S[count] = &m_FPR[count >> 1].F[count & 1]; - m_FPR_D[count] = &m_FPR[count >> 1].D; - } - } - else - { - for (int count = 0; count < 32; count ++) { - m_FPR_S[count] = &m_FPR[count].F[1]; - m_FPR_D[count] = &m_FPR[count].D; - } - } +{ + if ((STATUS_REGISTER & STATUS_FR) == 0) + { + for (int count = 0; count < 32; count ++) + { + m_FPR_S[count] = &m_FPR[count >> 1].F[count & 1]; + m_FPR_D[count] = &m_FPR[count >> 1].D; + } + } + else + { + for (int count = 0; count < 32; count ++) { + m_FPR_S[count] = &m_FPR[count].F[1]; + m_FPR_D[count] = &m_FPR[count].D; + } + } } void CRegisters::DoBreakException(bool DelaySlot) { - if (bHaveDebugger()) - { - if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) - { - g_Notify->DisplayError(L"EXL set in Break Exception"); - } - if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) - { - g_Notify->DisplayError(L"ERL set in Break Exception"); - } - } + if (bHaveDebugger()) + { + if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) + { + g_Notify->DisplayError(L"EXL set in Break Exception"); + } + if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) + { + g_Notify->DisplayError(L"ERL set in Break Exception"); + } + } - CAUSE_REGISTER = EXC_BREAK; - if (DelaySlot) - { - CAUSE_REGISTER |= CAUSE_BD; - EPC_REGISTER = m_PROGRAM_COUNTER - 4; - } - else - { - EPC_REGISTER = m_PROGRAM_COUNTER; - } - STATUS_REGISTER |= STATUS_EXL; - m_PROGRAM_COUNTER = 0x80000180; + CAUSE_REGISTER = EXC_BREAK; + if (DelaySlot) + { + CAUSE_REGISTER |= CAUSE_BD; + EPC_REGISTER = m_PROGRAM_COUNTER - 4; + } + else + { + EPC_REGISTER = m_PROGRAM_COUNTER; + } + STATUS_REGISTER |= STATUS_EXL; + m_PROGRAM_COUNTER = 0x80000180; } void CRegisters::DoCopUnusableException(bool DelaySlot, int Coprocessor) { - if (bHaveDebugger()) - { - if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) - { - g_Notify->DisplayError(L"EXL set in Break Exception"); - } - if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) - { - g_Notify->DisplayError(L"ERL set in Break Exception"); - } - } + if (bHaveDebugger()) + { + if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) + { + g_Notify->DisplayError(L"EXL set in Break Exception"); + } + if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) + { + g_Notify->DisplayError(L"ERL set in Break Exception"); + } + } - CAUSE_REGISTER = EXC_CPU; - if (Coprocessor == 1) - { - CAUSE_REGISTER |= 0x10000000; - } - if (DelaySlot) - { - CAUSE_REGISTER |= CAUSE_BD; - EPC_REGISTER = m_PROGRAM_COUNTER - 4; - } - else - { - EPC_REGISTER = m_PROGRAM_COUNTER; - } - STATUS_REGISTER |= STATUS_EXL; - m_PROGRAM_COUNTER = 0x80000180; + CAUSE_REGISTER = EXC_CPU; + if (Coprocessor == 1) + { + CAUSE_REGISTER |= 0x10000000; + } + if (DelaySlot) + { + CAUSE_REGISTER |= CAUSE_BD; + EPC_REGISTER = m_PROGRAM_COUNTER - 4; + } + else + { + EPC_REGISTER = m_PROGRAM_COUNTER; + } + STATUS_REGISTER |= STATUS_EXL; + m_PROGRAM_COUNTER = 0x80000180; } - bool CRegisters::DoIntrException(bool DelaySlot) { - if ((STATUS_REGISTER & STATUS_IE) == 0) - { - return false; - } + if ((STATUS_REGISTER & STATUS_IE) == 0) + { + return false; + } - if ((STATUS_REGISTER & STATUS_EXL) != 0) - { - return false; - } + if ((STATUS_REGISTER & STATUS_EXL) != 0) + { + return false; + } - if ((STATUS_REGISTER & STATUS_ERL) != 0) - { - return false; - } + if ((STATUS_REGISTER & STATUS_ERL) != 0) + { + return false; + } - if (g_LogOptions.GenerateLog && g_LogOptions.LogExceptions && !g_LogOptions.NoInterrupts) - { - LogMessage("%08X: Interrupt Generated", m_PROGRAM_COUNTER); - } + if (g_LogOptions.GenerateLog && g_LogOptions.LogExceptions && !g_LogOptions.NoInterrupts) + { + LogMessage("%08X: Interrupt Generated", m_PROGRAM_COUNTER); + } - CAUSE_REGISTER = FAKE_CAUSE_REGISTER; - CAUSE_REGISTER |= EXC_INT; + CAUSE_REGISTER = FAKE_CAUSE_REGISTER; + CAUSE_REGISTER |= EXC_INT; - if (DelaySlot) - { - CAUSE_REGISTER |= CAUSE_BD; - EPC_REGISTER = m_PROGRAM_COUNTER - 4; - } - else - { - EPC_REGISTER = m_PROGRAM_COUNTER; - } + if (DelaySlot) + { + CAUSE_REGISTER |= CAUSE_BD; + EPC_REGISTER = m_PROGRAM_COUNTER - 4; + } + else + { + EPC_REGISTER = m_PROGRAM_COUNTER; + } - STATUS_REGISTER |= STATUS_EXL; - m_PROGRAM_COUNTER = 0x80000180; - return true; + STATUS_REGISTER |= STATUS_EXL; + m_PROGRAM_COUNTER = 0x80000180; + return true; } -void CRegisters::DoTLBReadMiss(bool DelaySlot, DWORD BadVaddr) +void CRegisters::DoTLBReadMiss(bool DelaySlot, uint32_t BadVaddr) { - CAUSE_REGISTER = EXC_RMISS; - BAD_VADDR_REGISTER = BadVaddr; - CONTEXT_REGISTER &= 0xFF80000F; - CONTEXT_REGISTER |= (BadVaddr >> 9) & 0x007FFFF0; - ENTRYHI_REGISTER = (BadVaddr & 0xFFFFE000); - if ((STATUS_REGISTER & STATUS_EXL) == 0) - { - if (DelaySlot) - { - CAUSE_REGISTER |= CAUSE_BD; - EPC_REGISTER = m_PROGRAM_COUNTER - 4; - } - else - { - EPC_REGISTER = m_PROGRAM_COUNTER; - } - if (g_TLB->AddressDefined(BadVaddr)) - { - m_PROGRAM_COUNTER = 0x80000180; - } - else - { - m_PROGRAM_COUNTER = 0x80000000; - } - STATUS_REGISTER |= STATUS_EXL; - } - else - { - if (bHaveDebugger()) - { - g_Notify->DisplayError(stdstr_f("TLBMiss - EXL Set\nBadVaddr = %X\nAddress Defined: %s",BadVaddr,g_TLB->AddressDefined(BadVaddr)?"TRUE":"FALSE").ToUTF16().c_str()); - } - m_PROGRAM_COUNTER = 0x80000180; - } + CAUSE_REGISTER = EXC_RMISS; + BAD_VADDR_REGISTER = BadVaddr; + CONTEXT_REGISTER &= 0xFF80000F; + CONTEXT_REGISTER |= (BadVaddr >> 9) & 0x007FFFF0; + ENTRYHI_REGISTER = (BadVaddr & 0xFFFFE000); + if ((STATUS_REGISTER & STATUS_EXL) == 0) + { + if (DelaySlot) + { + CAUSE_REGISTER |= CAUSE_BD; + EPC_REGISTER = m_PROGRAM_COUNTER - 4; + } + else + { + EPC_REGISTER = m_PROGRAM_COUNTER; + } + if (g_TLB->AddressDefined(BadVaddr)) + { + m_PROGRAM_COUNTER = 0x80000180; + } + else + { + m_PROGRAM_COUNTER = 0x80000000; + } + STATUS_REGISTER |= STATUS_EXL; + } + else + { + if (bHaveDebugger()) + { + g_Notify->DisplayError(stdstr_f("TLBMiss - EXL Set\nBadVaddr = %X\nAddress Defined: %s",BadVaddr,g_TLB->AddressDefined(BadVaddr)?"TRUE":"FALSE").ToUTF16().c_str()); + } + m_PROGRAM_COUNTER = 0x80000180; + } } void CRegisters::DoSysCallException(bool DelaySlot) { - if (bHaveDebugger()) - { - if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) - { - g_Notify->DisplayError(L"EXL set in SysCall Exception"); - } - if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) - { - g_Notify->DisplayError(L"ERL set in SysCall Exception"); - } - } + if (bHaveDebugger()) + { + if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) + { + g_Notify->DisplayError(L"EXL set in SysCall Exception"); + } + if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) + { + g_Notify->DisplayError(L"ERL set in SysCall Exception"); + } + } - CAUSE_REGISTER = EXC_SYSCALL; - if (DelaySlot) - { - CAUSE_REGISTER |= CAUSE_BD; - EPC_REGISTER = m_PROGRAM_COUNTER - 4; - } - else - { - EPC_REGISTER = m_PROGRAM_COUNTER; - } - STATUS_REGISTER |= STATUS_EXL; - m_PROGRAM_COUNTER = 0x80000180; + CAUSE_REGISTER = EXC_SYSCALL; + if (DelaySlot) + { + CAUSE_REGISTER |= CAUSE_BD; + EPC_REGISTER = m_PROGRAM_COUNTER - 4; + } + else + { + EPC_REGISTER = m_PROGRAM_COUNTER; + } + STATUS_REGISTER |= STATUS_EXL; + m_PROGRAM_COUNTER = 0x80000180; } diff --git a/Source/Project64/N64 System/Mips/Register Class.h b/Source/Project64/N64 System/Mips/Register Class.h index 9699d4e97..7e66deaae 100644 --- a/Source/Project64/N64 System/Mips/Register Class.h +++ b/Source/Project64/N64 System/Mips/Register Class.h @@ -13,265 +13,280 @@ //CPO registers by name class CP0registers { - CP0registers(); - protected: - CP0registers (DWORD * _CP0); + CP0registers (uint32_t * _CP0); public: - DWORD & INDEX_REGISTER; - DWORD & RANDOM_REGISTER; - DWORD & ENTRYLO0_REGISTER; - DWORD & ENTRYLO1_REGISTER; - DWORD & CONTEXT_REGISTER; - DWORD & PAGE_MASK_REGISTER; - DWORD & WIRED_REGISTER; - DWORD & BAD_VADDR_REGISTER; - DWORD & COUNT_REGISTER; - DWORD & ENTRYHI_REGISTER; - DWORD & COMPARE_REGISTER; - DWORD & STATUS_REGISTER; - DWORD & CAUSE_REGISTER; - DWORD & EPC_REGISTER; - DWORD & CONFIG_REGISTER; - DWORD & TAGLO_REGISTER; - DWORD & TAGHI_REGISTER; - DWORD & ERROREPC_REGISTER; - DWORD & FAKE_CAUSE_REGISTER; + uint32_t & INDEX_REGISTER; + uint32_t & RANDOM_REGISTER; + uint32_t & ENTRYLO0_REGISTER; + uint32_t & ENTRYLO1_REGISTER; + uint32_t & CONTEXT_REGISTER; + uint32_t & PAGE_MASK_REGISTER; + uint32_t & WIRED_REGISTER; + uint32_t & BAD_VADDR_REGISTER; + uint32_t & COUNT_REGISTER; + uint32_t & ENTRYHI_REGISTER; + uint32_t & COMPARE_REGISTER; + uint32_t & STATUS_REGISTER; + uint32_t & CAUSE_REGISTER; + uint32_t & EPC_REGISTER; + uint32_t & CONFIG_REGISTER; + uint32_t & TAGLO_REGISTER; + uint32_t & TAGHI_REGISTER; + uint32_t & ERROREPC_REGISTER; + uint32_t & FAKE_CAUSE_REGISTER; + +private: + CP0registers(); // Disable default constructor + CP0registers(const CP0registers&); // Disable copy constructor + CP0registers& operator=(const CP0registers&); // Disable assignment }; //CPO register flags enum { - //Status Register - STATUS_IE = 0x00000001, STATUS_EXL = 0x00000002, STATUS_ERL = 0x00000004, - STATUS_IP0 = 0x00000100, STATUS_IP1 = 0x00000200, STATUS_IP2 = 0x00000400, - STATUS_IP3 = 0x00000800, STATUS_IP4 = 0x00001000, STATUS_IP5 = 0x00002000, - STATUS_IP6 = 0x00004000, STATUS_IP7 = 0x00008000, STATUS_BEV = 0x00400000, - STATUS_FR = 0x04000000, STATUS_CU0 = 0x10000000, STATUS_CU1 = 0x20000000, + //Status Register + STATUS_IE = 0x00000001, STATUS_EXL = 0x00000002, STATUS_ERL = 0x00000004, + STATUS_IP0 = 0x00000100, STATUS_IP1 = 0x00000200, STATUS_IP2 = 0x00000400, + STATUS_IP3 = 0x00000800, STATUS_IP4 = 0x00001000, STATUS_IP5 = 0x00002000, + STATUS_IP6 = 0x00004000, STATUS_IP7 = 0x00008000, STATUS_BEV = 0x00400000, + STATUS_FR = 0x04000000, STATUS_CU0 = 0x10000000, STATUS_CU1 = 0x20000000, - //Cause Flags - CAUSE_EXC_CODE = 0xFF, - CAUSE_IP0 = 0x100, - CAUSE_IP1 = 0x200, - CAUSE_IP2 = 0x400, - CAUSE_IP3 = 0x800, - CAUSE_IP4 = 0x1000, - CAUSE_IP5 = 0x2000, - CAUSE_IP6 = 0x4000, - CAUSE_IP7 = 0x8000, - CAUSE_BD = 0x80000000, + //Cause Flags + CAUSE_EXC_CODE = 0xFF, + CAUSE_IP0 = 0x100, + CAUSE_IP1 = 0x200, + CAUSE_IP2 = 0x400, + CAUSE_IP3 = 0x800, + CAUSE_IP4 = 0x1000, + CAUSE_IP5 = 0x2000, + CAUSE_IP6 = 0x4000, + CAUSE_IP7 = 0x8000, + CAUSE_BD = 0x80000000, - //Cause exception ID's - EXC_INT = 0, /* interrupt */ - EXC_MOD = 4, /* TLB mod */ - EXC_RMISS = 8, /* Read TLB Miss */ - EXC_WMISS = 12, /* Write TLB Miss */ - EXC_RADE = 16, /* Read Address Error */ - EXC_WADE = 20, /* Write Address Error */ - EXC_IBE = 24, /* Instruction Bus Error */ - EXC_DBE = 28, /* Data Bus Error */ - EXC_SYSCALL = 32, /* SYSCALL */ - EXC_BREAK = 36, /* BREAKpoint */ - EXC_II = 40, /* Illegal Instruction */ - EXC_CPU = 44, /* CoProcessor Unusable */ - EXC_OV = 48, /* OVerflow */ - EXC_TRAP = 52, /* Trap exception */ - EXC_VCEI = 56, /* Virt. Coherency on Inst. fetch */ - EXC_FPE = 60, /* Floating Point Exception */ - EXC_WATCH = 92, /* Watchpoint reference */ - EXC_VCED = 124,/* Virt. Coherency on data read */ + //Cause exception ID's + EXC_INT = 0, /* interrupt */ + EXC_MOD = 4, /* TLB mod */ + EXC_RMISS = 8, /* Read TLB Miss */ + EXC_WMISS = 12, /* Write TLB Miss */ + EXC_RADE = 16, /* Read Address Error */ + EXC_WADE = 20, /* Write Address Error */ + EXC_IBE = 24, /* Instruction Bus Error */ + EXC_DBE = 28, /* Data Bus Error */ + EXC_SYSCALL = 32, /* SYSCALL */ + EXC_BREAK = 36, /* BREAKpoint */ + EXC_II = 40, /* Illegal Instruction */ + EXC_CPU = 44, /* CoProcessor Unusable */ + EXC_OV = 48, /* OVerflow */ + EXC_TRAP = 52, /* Trap exception */ + EXC_VCEI = 56, /* Virt. Coherency on Inst. fetch */ + EXC_FPE = 60, /* Floating Point Exception */ + EXC_WATCH = 92, /* Watchpoint reference */ + EXC_VCED = 124,/* Virt. Coherency on data read */ }; //Float point control status register flags enum { - FPCSR_FS = 0x01000000, /* flush denorm to zero */ - FPCSR_C = 0x00800000, /* condition bit */ - FPCSR_CE = 0x00020000, /* cause: unimplemented operation */ - FPCSR_CV = 0x00010000, /* cause: invalid operation */ - FPCSR_CZ = 0x00008000, /* cause: division by zero */ - FPCSR_CO = 0x00004000, /* cause: overflow */ - FPCSR_CU = 0x00002000, /* cause: underflow */ - FPCSR_CI = 0x00001000, /* cause: inexact operation */ - FPCSR_EV = 0x00000800, /* enable: invalid operation */ - FPCSR_EZ = 0x00000400, /* enable: division by zero */ - FPCSR_EO = 0x00000200, /* enable: overflow */ - FPCSR_EU = 0x00000100, /* enable: underflow */ - FPCSR_EI = 0x00000080, /* enable: inexact operation */ - FPCSR_FV = 0x00000040, /* flag: invalid operation */ - FPCSR_FZ = 0x00000020, /* flag: division by zero */ - FPCSR_FO = 0x00000010, /* flag: overflow */ - FPCSR_FU = 0x00000008, /* flag: underflow */ - FPCSR_FI = 0x00000004, /* flag: inexact operation */ - FPCSR_RM_MASK = 0x00000003, /* rounding mode mask */ - FPCSR_RM_RN = 0x00000000, /* round to nearest */ - FPCSR_RM_RZ = 0x00000001, /* round to zero */ - FPCSR_RM_RP = 0x00000002, /* round to positive infinity */ - FPCSR_RM_RM = 0x00000003, /* round to negative infinity */ + FPCSR_FS = 0x01000000, /* flush denorm to zero */ + FPCSR_C = 0x00800000, /* condition bit */ + FPCSR_CE = 0x00020000, /* cause: unimplemented operation */ + FPCSR_CV = 0x00010000, /* cause: invalid operation */ + FPCSR_CZ = 0x00008000, /* cause: division by zero */ + FPCSR_CO = 0x00004000, /* cause: overflow */ + FPCSR_CU = 0x00002000, /* cause: underflow */ + FPCSR_CI = 0x00001000, /* cause: inexact operation */ + FPCSR_EV = 0x00000800, /* enable: invalid operation */ + FPCSR_EZ = 0x00000400, /* enable: division by zero */ + FPCSR_EO = 0x00000200, /* enable: overflow */ + FPCSR_EU = 0x00000100, /* enable: underflow */ + FPCSR_EI = 0x00000080, /* enable: inexact operation */ + FPCSR_FV = 0x00000040, /* flag: invalid operation */ + FPCSR_FZ = 0x00000020, /* flag: division by zero */ + FPCSR_FO = 0x00000010, /* flag: overflow */ + FPCSR_FU = 0x00000008, /* flag: underflow */ + FPCSR_FI = 0x00000004, /* flag: inexact operation */ + FPCSR_RM_MASK = 0x00000003, /* rounding mode mask */ + FPCSR_RM_RN = 0x00000000, /* round to nearest */ + FPCSR_RM_RZ = 0x00000001, /* round to zero */ + FPCSR_RM_RP = 0x00000002, /* round to positive infinity */ + FPCSR_RM_RM = 0x00000003, /* round to negative infinity */ }; //Rdram Registers class Rdram_InterfaceReg { - Rdram_InterfaceReg(); - protected: - Rdram_InterfaceReg (DWORD * _RdramInterface); + Rdram_InterfaceReg (uint32_t * _RdramInterface); public: - DWORD & RDRAM_CONFIG_REG; - DWORD & RDRAM_DEVICE_TYPE_REG; - DWORD & RDRAM_DEVICE_ID_REG; - DWORD & RDRAM_DELAY_REG; - DWORD & RDRAM_MODE_REG; - DWORD & RDRAM_REF_INTERVAL_REG; - DWORD & RDRAM_REF_ROW_REG; - DWORD & RDRAM_RAS_INTERVAL_REG; - DWORD & RDRAM_MIN_INTERVAL_REG; - DWORD & RDRAM_ADDR_SELECT_REG; - DWORD & RDRAM_DEVICE_MANUF_REG; + uint32_t & RDRAM_CONFIG_REG; + uint32_t & RDRAM_DEVICE_TYPE_REG; + uint32_t & RDRAM_DEVICE_ID_REG; + uint32_t & RDRAM_DELAY_REG; + uint32_t & RDRAM_MODE_REG; + uint32_t & RDRAM_REF_INTERVAL_REG; + uint32_t & RDRAM_REF_ROW_REG; + uint32_t & RDRAM_RAS_INTERVAL_REG; + uint32_t & RDRAM_MIN_INTERVAL_REG; + uint32_t & RDRAM_ADDR_SELECT_REG; + uint32_t & RDRAM_DEVICE_MANUF_REG; + +private: + Rdram_InterfaceReg(); // Disable default constructor + Rdram_InterfaceReg(const Rdram_InterfaceReg&); // Disable copy constructor + Rdram_InterfaceReg& operator=(const Rdram_InterfaceReg&); // Disable assignment }; //Mips interface registers class Mips_InterfaceReg { - Mips_InterfaceReg (); - protected: - Mips_InterfaceReg (DWORD * _MipsInterface); + Mips_InterfaceReg (uint32_t * _MipsInterface); public: - DWORD & MI_INIT_MODE_REG; - DWORD & MI_MODE_REG; - DWORD & MI_VERSION_REG; - DWORD & MI_NOOP_REG; - DWORD & MI_INTR_REG; - DWORD & MI_INTR_MASK_REG; + uint32_t & MI_INIT_MODE_REG; + uint32_t & MI_MODE_REG; + uint32_t & MI_VERSION_REG; + uint32_t & MI_NOOP_REG; + uint32_t & MI_INTR_REG; + uint32_t & MI_INTR_MASK_REG; + +private: + Mips_InterfaceReg(); // Disable default constructor + Mips_InterfaceReg(const Mips_InterfaceReg&); // Disable copy constructor + Mips_InterfaceReg& operator=(const Mips_InterfaceReg&); // Disable assignment }; //Mips interface flags enum { - MI_MODE_INIT = 0x0080, /* Bit 7: init mode */ - MI_MODE_EBUS = 0x0100, /* Bit 8: ebus test mode */ - MI_MODE_RDRAM = 0x0200, /* Bit 9: RDRAM reg mode */ + MI_MODE_INIT = 0x0080, /* Bit 7: init mode */ + MI_MODE_EBUS = 0x0100, /* Bit 8: ebus test mode */ + MI_MODE_RDRAM = 0x0200, /* Bit 9: RDRAM reg mode */ - MI_CLR_INIT = 0x0080, /* Bit 7: clear init mode */ - MI_SET_INIT = 0x0100, /* Bit 8: set init mode */ - MI_CLR_EBUS = 0x0200, /* Bit 9: clear ebus test */ - MI_SET_EBUS = 0x0400, /* Bit 10: set ebus test mode */ - MI_CLR_DP_INTR = 0x0800, /* Bit 11: clear dp interrupt */ - MI_CLR_RDRAM = 0x1000, /* Bit 12: clear RDRAM reg */ - MI_SET_RDRAM = 0x2000, /* Bit 13: set RDRAM reg mode */ + MI_CLR_INIT = 0x0080, /* Bit 7: clear init mode */ + MI_SET_INIT = 0x0100, /* Bit 8: set init mode */ + MI_CLR_EBUS = 0x0200, /* Bit 9: clear ebus test */ + MI_SET_EBUS = 0x0400, /* Bit 10: set ebus test mode */ + MI_CLR_DP_INTR = 0x0800, /* Bit 11: clear dp interrupt */ + MI_CLR_RDRAM = 0x1000, /* Bit 12: clear RDRAM reg */ + MI_SET_RDRAM = 0x2000, /* Bit 13: set RDRAM reg mode */ - //Flags for writing to MI_INTR_MASK_REG - MI_INTR_MASK_CLR_SP = 0x0001, /* Bit 0: clear SP mask */ - MI_INTR_MASK_SET_SP = 0x0002, /* Bit 1: set SP mask */ - MI_INTR_MASK_CLR_SI = 0x0004, /* Bit 2: clear SI mask */ - MI_INTR_MASK_SET_SI = 0x0008, /* Bit 3: set SI mask */ - MI_INTR_MASK_CLR_AI = 0x0010, /* Bit 4: clear AI mask */ - MI_INTR_MASK_SET_AI = 0x0020, /* Bit 5: set AI mask */ - MI_INTR_MASK_CLR_VI = 0x0040, /* Bit 6: clear VI mask */ - MI_INTR_MASK_SET_VI = 0x0080, /* Bit 7: set VI mask */ - MI_INTR_MASK_CLR_PI = 0x0100, /* Bit 8: clear PI mask */ - MI_INTR_MASK_SET_PI = 0x0200, /* Bit 9: set PI mask */ - MI_INTR_MASK_CLR_DP = 0x0400, /* Bit 10: clear DP mask */ - MI_INTR_MASK_SET_DP = 0x0800, /* Bit 11: set DP mask */ + //Flags for writing to MI_INTR_MASK_REG + MI_INTR_MASK_CLR_SP = 0x0001, /* Bit 0: clear SP mask */ + MI_INTR_MASK_SET_SP = 0x0002, /* Bit 1: set SP mask */ + MI_INTR_MASK_CLR_SI = 0x0004, /* Bit 2: clear SI mask */ + MI_INTR_MASK_SET_SI = 0x0008, /* Bit 3: set SI mask */ + MI_INTR_MASK_CLR_AI = 0x0010, /* Bit 4: clear AI mask */ + MI_INTR_MASK_SET_AI = 0x0020, /* Bit 5: set AI mask */ + MI_INTR_MASK_CLR_VI = 0x0040, /* Bit 6: clear VI mask */ + MI_INTR_MASK_SET_VI = 0x0080, /* Bit 7: set VI mask */ + MI_INTR_MASK_CLR_PI = 0x0100, /* Bit 8: clear PI mask */ + MI_INTR_MASK_SET_PI = 0x0200, /* Bit 9: set PI mask */ + MI_INTR_MASK_CLR_DP = 0x0400, /* Bit 10: clear DP mask */ + MI_INTR_MASK_SET_DP = 0x0800, /* Bit 11: set DP mask */ - //Flags for reading from MI_INTR_MASK_REG - MI_INTR_MASK_SP = 0x01, /* Bit 0: SP intr mask */ - MI_INTR_MASK_SI = 0x02, /* Bit 1: SI intr mask */ - MI_INTR_MASK_AI = 0x04, /* Bit 2: AI intr mask */ - MI_INTR_MASK_VI = 0x08, /* Bit 3: VI intr mask */ - MI_INTR_MASK_PI = 0x10, /* Bit 4: PI intr mask */ - MI_INTR_MASK_DP = 0x20, /* Bit 5: DP intr mask */ + //Flags for reading from MI_INTR_MASK_REG + MI_INTR_MASK_SP = 0x01, /* Bit 0: SP intr mask */ + MI_INTR_MASK_SI = 0x02, /* Bit 1: SI intr mask */ + MI_INTR_MASK_AI = 0x04, /* Bit 2: AI intr mask */ + MI_INTR_MASK_VI = 0x08, /* Bit 3: VI intr mask */ + MI_INTR_MASK_PI = 0x10, /* Bit 4: PI intr mask */ + MI_INTR_MASK_DP = 0x20, /* Bit 5: DP intr mask */ - MI_INTR_SP = 0x01, /* Bit 0: SP intr */ - MI_INTR_SI = 0x02, /* Bit 1: SI intr */ - MI_INTR_AI = 0x04, /* Bit 2: AI intr */ - MI_INTR_VI = 0x08, /* Bit 3: VI intr */ - MI_INTR_PI = 0x10, /* Bit 4: PI intr */ - MI_INTR_DP = 0x20, /* Bit 5: DP intr */ + MI_INTR_SP = 0x01, /* Bit 0: SP intr */ + MI_INTR_SI = 0x02, /* Bit 1: SI intr */ + MI_INTR_AI = 0x04, /* Bit 2: AI intr */ + MI_INTR_VI = 0x08, /* Bit 3: VI intr */ + MI_INTR_PI = 0x10, /* Bit 4: PI intr */ + MI_INTR_DP = 0x20, /* Bit 5: DP intr */ }; //Mips interface registers class Video_InterfaceReg { - Video_InterfaceReg(); - protected: - Video_InterfaceReg (DWORD * _VideoInterface); + Video_InterfaceReg (uint32_t * _VideoInterface); public: - DWORD & VI_STATUS_REG; - DWORD & VI_CONTROL_REG; - DWORD & VI_ORIGIN_REG; - DWORD & VI_DRAM_ADDR_REG; - DWORD & VI_WIDTH_REG; - DWORD & VI_H_WIDTH_REG; - DWORD & VI_INTR_REG; - DWORD & VI_V_INTR_REG; - DWORD & VI_CURRENT_REG; - DWORD & VI_V_CURRENT_LINE_REG; - DWORD & VI_BURST_REG; - DWORD & VI_TIMING_REG; - DWORD & VI_V_SYNC_REG; - DWORD & VI_H_SYNC_REG; - DWORD & VI_LEAP_REG; - DWORD & VI_H_SYNC_LEAP_REG; - DWORD & VI_H_START_REG; - DWORD & VI_H_VIDEO_REG; - DWORD & VI_V_START_REG; - DWORD & VI_V_VIDEO_REG; - DWORD & VI_V_BURST_REG; - DWORD & VI_X_SCALE_REG; - DWORD & VI_Y_SCALE_REG; + uint32_t & VI_STATUS_REG; + uint32_t & VI_CONTROL_REG; + uint32_t & VI_ORIGIN_REG; + uint32_t & VI_DRAM_ADDR_REG; + uint32_t & VI_WIDTH_REG; + uint32_t & VI_H_WIDTH_REG; + uint32_t & VI_INTR_REG; + uint32_t & VI_V_INTR_REG; + uint32_t & VI_CURRENT_REG; + uint32_t & VI_V_CURRENT_LINE_REG; + uint32_t & VI_BURST_REG; + uint32_t & VI_TIMING_REG; + uint32_t & VI_V_SYNC_REG; + uint32_t & VI_H_SYNC_REG; + uint32_t & VI_LEAP_REG; + uint32_t & VI_H_SYNC_LEAP_REG; + uint32_t & VI_H_START_REG; + uint32_t & VI_H_VIDEO_REG; + uint32_t & VI_V_START_REG; + uint32_t & VI_V_VIDEO_REG; + uint32_t & VI_V_BURST_REG; + uint32_t & VI_X_SCALE_REG; + uint32_t & VI_Y_SCALE_REG; + +private: + Video_InterfaceReg(); // Disable default constructor + Video_InterfaceReg(const Video_InterfaceReg&); // Disable copy constructor + Video_InterfaceReg& operator=(const Video_InterfaceReg&); // Disable assignment }; //Display Processor Control Registers class DisplayControlReg { - DisplayControlReg(); - protected: - DisplayControlReg (DWORD * _DisplayProcessor); + DisplayControlReg (uint32_t * _DisplayProcessor); public: - DWORD & DPC_START_REG; - DWORD & DPC_END_REG; - DWORD & DPC_CURRENT_REG; - DWORD & DPC_STATUS_REG; - DWORD & DPC_CLOCK_REG; - DWORD & DPC_BUFBUSY_REG; - DWORD & DPC_PIPEBUSY_REG; - DWORD & DPC_TMEM_REG; + uint32_t & DPC_START_REG; + uint32_t & DPC_END_REG; + uint32_t & DPC_CURRENT_REG; + uint32_t & DPC_STATUS_REG; + uint32_t & DPC_CLOCK_REG; + uint32_t & DPC_BUFBUSY_REG; + uint32_t & DPC_PIPEBUSY_REG; + uint32_t & DPC_TMEM_REG; + +private: + DisplayControlReg(); // Disable default constructor + DisplayControlReg(const DisplayControlReg&); // Disable copy constructor + DisplayControlReg& operator=(const DisplayControlReg&); // Disable assignment }; enum { - DPC_CLR_XBUS_DMEM_DMA = 0x0001, /* Bit 0: clear xbus_dmem_dma */ - DPC_SET_XBUS_DMEM_DMA = 0x0002, /* Bit 1: set xbus_dmem_dma */ - DPC_CLR_FREEZE = 0x0004, /* Bit 2: clear freeze */ - DPC_SET_FREEZE = 0x0008, /* Bit 3: set freeze */ - DPC_CLR_FLUSH = 0x0010, /* Bit 4: clear flush */ - DPC_SET_FLUSH = 0x0020, /* Bit 5: set flush */ - DPC_CLR_TMEM_CTR = 0x0040, /* Bit 6: clear tmem ctr */ - DPC_CLR_PIPE_CTR = 0x0080, /* Bit 7: clear pipe ctr */ - DPC_CLR_CMD_CTR = 0x0100, /* Bit 8: clear cmd ctr */ - DPC_CLR_CLOCK_CTR = 0x0200, /* Bit 9: clear clock ctr */ - - DPC_STATUS_XBUS_DMEM_DMA = 0x001, /* Bit 0: xbus_dmem_dma */ - DPC_STATUS_FREEZE = 0x002, /* Bit 1: freeze */ - DPC_STATUS_FLUSH = 0x004, /* Bit 2: flush */ - DPC_STATUS_START_GCLK = 0x008, /* Bit 3: start gclk */ - DPC_STATUS_TMEM_BUSY = 0x010, /* Bit 4: tmem busy */ - DPC_STATUS_PIPE_BUSY = 0x020, /* Bit 5: pipe busy */ - DPC_STATUS_CMD_BUSY = 0x040, /* Bit 6: cmd busy */ - DPC_STATUS_CBUF_READY = 0x080, /* Bit 7: cbuf ready */ - DPC_STATUS_DMA_BUSY = 0x100, /* Bit 8: dma busy */ - DPC_STATUS_END_VALID = 0x200, /* Bit 9: end valid */ - DPC_STATUS_START_VALID = 0x400, /* Bit 10: start valid */ + DPC_CLR_XBUS_DMEM_DMA = 0x0001, /* Bit 0: clear xbus_dmem_dma */ + DPC_SET_XBUS_DMEM_DMA = 0x0002, /* Bit 1: set xbus_dmem_dma */ + DPC_CLR_FREEZE = 0x0004, /* Bit 2: clear freeze */ + DPC_SET_FREEZE = 0x0008, /* Bit 3: set freeze */ + DPC_CLR_FLUSH = 0x0010, /* Bit 4: clear flush */ + DPC_SET_FLUSH = 0x0020, /* Bit 5: set flush */ + DPC_CLR_TMEM_CTR = 0x0040, /* Bit 6: clear tmem ctr */ + DPC_CLR_PIPE_CTR = 0x0080, /* Bit 7: clear pipe ctr */ + DPC_CLR_CMD_CTR = 0x0100, /* Bit 8: clear cmd ctr */ + DPC_CLR_CLOCK_CTR = 0x0200, /* Bit 9: clear clock ctr */ + + DPC_STATUS_XBUS_DMEM_DMA = 0x001, /* Bit 0: xbus_dmem_dma */ + DPC_STATUS_FREEZE = 0x002, /* Bit 1: freeze */ + DPC_STATUS_FLUSH = 0x004, /* Bit 2: flush */ + DPC_STATUS_START_GCLK = 0x008, /* Bit 3: start gclk */ + DPC_STATUS_TMEM_BUSY = 0x010, /* Bit 4: tmem busy */ + DPC_STATUS_PIPE_BUSY = 0x020, /* Bit 5: pipe busy */ + DPC_STATUS_CMD_BUSY = 0x040, /* Bit 6: cmd busy */ + DPC_STATUS_CBUF_READY = 0x080, /* Bit 7: cbuf ready */ + DPC_STATUS_DMA_BUSY = 0x100, /* Bit 8: dma busy */ + DPC_STATUS_END_VALID = 0x200, /* Bit 9: end valid */ + DPC_STATUS_START_VALID = 0x400, /* Bit 10: start valid */ }; /* @@ -279,275 +294,290 @@ enum */ class AudioInterfaceReg { - AudioInterfaceReg(); - protected: - AudioInterfaceReg (DWORD * _AudioInterface); + AudioInterfaceReg (uint32_t * _AudioInterface); public: - DWORD & AI_DRAM_ADDR_REG; - DWORD & AI_LEN_REG; - DWORD & AI_CONTROL_REG; - DWORD & AI_STATUS_REG; - DWORD & AI_DACRATE_REG; - DWORD & AI_BITRATE_REG; + uint32_t & AI_DRAM_ADDR_REG; + uint32_t & AI_LEN_REG; + uint32_t & AI_CONTROL_REG; + uint32_t & AI_STATUS_REG; + uint32_t & AI_DACRATE_REG; + uint32_t & AI_BITRATE_REG; + +private: + AudioInterfaceReg(); // Disable default constructor + AudioInterfaceReg(const AudioInterfaceReg&); // Disable copy constructor + AudioInterfaceReg& operator=(const AudioInterfaceReg&); // Disable assignment }; enum { - AI_STATUS_FIFO_FULL = 0x80000000, /* Bit 31: full */ - AI_STATUS_DMA_BUSY = 0x40000000, /* Bit 30: busy */ + AI_STATUS_FIFO_FULL = 0x80000000, /* Bit 31: full */ + AI_STATUS_DMA_BUSY = 0x40000000, /* Bit 30: busy */ }; //Audio Interface registers; class PeripheralInterfaceReg { - PeripheralInterfaceReg(); - protected: - PeripheralInterfaceReg (DWORD * PeripheralInterface); + PeripheralInterfaceReg (uint32_t * PeripheralInterface); public: - DWORD & PI_DRAM_ADDR_REG; - DWORD & PI_CART_ADDR_REG; - DWORD & PI_RD_LEN_REG; - DWORD & PI_WR_LEN_REG; - DWORD & PI_STATUS_REG; - DWORD & PI_BSD_DOM1_LAT_REG; - DWORD & PI_DOMAIN1_REG; - DWORD & PI_BSD_DOM1_PWD_REG; - DWORD & PI_BSD_DOM1_PGS_REG; - DWORD & PI_BSD_DOM1_RLS_REG; - DWORD & PI_BSD_DOM2_LAT_REG; - DWORD & PI_DOMAIN2_REG; - DWORD & PI_BSD_DOM2_PWD_REG; - DWORD & PI_BSD_DOM2_PGS_REG; - DWORD & PI_BSD_DOM2_RLS_REG; + uint32_t & PI_DRAM_ADDR_REG; + uint32_t & PI_CART_ADDR_REG; + uint32_t & PI_RD_LEN_REG; + uint32_t & PI_WR_LEN_REG; + uint32_t & PI_STATUS_REG; + uint32_t & PI_BSD_DOM1_LAT_REG; + uint32_t & PI_DOMAIN1_REG; + uint32_t & PI_BSD_DOM1_PWD_REG; + uint32_t & PI_BSD_DOM1_PGS_REG; + uint32_t & PI_BSD_DOM1_RLS_REG; + uint32_t & PI_BSD_DOM2_LAT_REG; + uint32_t & PI_DOMAIN2_REG; + uint32_t & PI_BSD_DOM2_PWD_REG; + uint32_t & PI_BSD_DOM2_PGS_REG; + uint32_t & PI_BSD_DOM2_RLS_REG; + +private: + PeripheralInterfaceReg(); // Disable default constructor + PeripheralInterfaceReg(const PeripheralInterfaceReg&); // Disable copy constructor + PeripheralInterfaceReg& operator=(const PeripheralInterfaceReg&); // Disable assignment }; class RDRAMInt_InterfaceReg { - RDRAMInt_InterfaceReg(); - protected: - RDRAMInt_InterfaceReg (DWORD * RdramInterface); + RDRAMInt_InterfaceReg (uint32_t * RdramInterface); public: - DWORD & RI_MODE_REG; - DWORD & RI_CONFIG_REG; - DWORD & RI_CURRENT_LOAD_REG; - DWORD & RI_SELECT_REG; - DWORD & RI_COUNT_REG; - DWORD & RI_REFRESH_REG; - DWORD & RI_LATENCY_REG; - DWORD & RI_RERROR_REG; - DWORD & RI_WERROR_REG; + uint32_t & RI_MODE_REG; + uint32_t & RI_CONFIG_REG; + uint32_t & RI_CURRENT_LOAD_REG; + uint32_t & RI_SELECT_REG; + uint32_t & RI_COUNT_REG; + uint32_t & RI_REFRESH_REG; + uint32_t & RI_LATENCY_REG; + uint32_t & RI_RERROR_REG; + uint32_t & RI_WERROR_REG; + +private: + RDRAMInt_InterfaceReg(); // Disable default constructor + RDRAMInt_InterfaceReg(const RDRAMInt_InterfaceReg&); // Disable copy constructor + RDRAMInt_InterfaceReg& operator=(const RDRAMInt_InterfaceReg&); // Disable assignment }; //Signal Processor Interface; class SigProcessor_InterfaceReg { protected: - SigProcessor_InterfaceReg (DWORD * _SignalProcessorInterface); + SigProcessor_InterfaceReg (uint32_t * _SignalProcessorInterface); public: - DWORD & SP_MEM_ADDR_REG; - DWORD & SP_DRAM_ADDR_REG; - DWORD & SP_RD_LEN_REG; - DWORD & SP_WR_LEN_REG; - DWORD & SP_STATUS_REG; - DWORD & SP_DMA_FULL_REG; - DWORD & SP_DMA_BUSY_REG; - DWORD & SP_SEMAPHORE_REG; - DWORD & SP_PC_REG; - DWORD & SP_IBIST_REG; + uint32_t & SP_MEM_ADDR_REG; + uint32_t & SP_DRAM_ADDR_REG; + uint32_t & SP_RD_LEN_REG; + uint32_t & SP_WR_LEN_REG; + uint32_t & SP_STATUS_REG; + uint32_t & SP_DMA_FULL_REG; + uint32_t & SP_DMA_BUSY_REG; + uint32_t & SP_SEMAPHORE_REG; + uint32_t & SP_PC_REG; + uint32_t & SP_IBIST_REG; + +private: + SigProcessor_InterfaceReg(); // Disable default constructor + SigProcessor_InterfaceReg(const SigProcessor_InterfaceReg&); // Disable copy constructor + SigProcessor_InterfaceReg& operator=(const SigProcessor_InterfaceReg&); // Disable assignment }; //Signal Processor interface flags enum { - SP_CLR_HALT = 0x00001, /* Bit 0: clear halt */ - SP_SET_HALT = 0x00002, /* Bit 1: set halt */ - SP_CLR_BROKE = 0x00004, /* Bit 2: clear broke */ - SP_CLR_INTR = 0x00008, /* Bit 3: clear intr */ - SP_SET_INTR = 0x00010, /* Bit 4: set intr */ - SP_CLR_SSTEP = 0x00020, /* Bit 5: clear sstep */ - SP_SET_SSTEP = 0x00040, /* Bit 6: set sstep */ - SP_CLR_INTR_BREAK = 0x00080, /* Bit 7: clear intr on break */ - SP_SET_INTR_BREAK = 0x00100, /* Bit 8: set intr on break */ - SP_CLR_SIG0 = 0x00200, /* Bit 9: clear signal 0 */ - SP_SET_SIG0 = 0x00400, /* Bit 10: set signal 0 */ - SP_CLR_SIG1 = 0x00800, /* Bit 11: clear signal 1 */ - SP_SET_SIG1 = 0x01000, /* Bit 12: set signal 1 */ - SP_CLR_SIG2 = 0x02000, /* Bit 13: clear signal 2 */ - SP_SET_SIG2 = 0x04000, /* Bit 14: set signal 2 */ - SP_CLR_SIG3 = 0x08000, /* Bit 15: clear signal 3 */ - SP_SET_SIG3 = 0x10000, /* Bit 16: set signal 3 */ - SP_CLR_SIG4 = 0x20000, /* Bit 17: clear signal 4 */ - SP_SET_SIG4 = 0x40000, /* Bit 18: set signal 4 */ - SP_CLR_SIG5 = 0x80000, /* Bit 19: clear signal 5 */ - SP_SET_SIG5 = 0x100000, /* Bit 20: set signal 5 */ - SP_CLR_SIG6 = 0x200000, /* Bit 21: clear signal 6 */ - SP_SET_SIG6 = 0x400000, /* Bit 22: set signal 6 */ - SP_CLR_SIG7 = 0x800000, /* Bit 23: clear signal 7 */ - SP_SET_SIG7 = 0x1000000, /* Bit 24: set signal 7 */ + SP_CLR_HALT = 0x00001, /* Bit 0: clear halt */ + SP_SET_HALT = 0x00002, /* Bit 1: set halt */ + SP_CLR_BROKE = 0x00004, /* Bit 2: clear broke */ + SP_CLR_INTR = 0x00008, /* Bit 3: clear intr */ + SP_SET_INTR = 0x00010, /* Bit 4: set intr */ + SP_CLR_SSTEP = 0x00020, /* Bit 5: clear sstep */ + SP_SET_SSTEP = 0x00040, /* Bit 6: set sstep */ + SP_CLR_INTR_BREAK = 0x00080, /* Bit 7: clear intr on break */ + SP_SET_INTR_BREAK = 0x00100, /* Bit 8: set intr on break */ + SP_CLR_SIG0 = 0x00200, /* Bit 9: clear signal 0 */ + SP_SET_SIG0 = 0x00400, /* Bit 10: set signal 0 */ + SP_CLR_SIG1 = 0x00800, /* Bit 11: clear signal 1 */ + SP_SET_SIG1 = 0x01000, /* Bit 12: set signal 1 */ + SP_CLR_SIG2 = 0x02000, /* Bit 13: clear signal 2 */ + SP_SET_SIG2 = 0x04000, /* Bit 14: set signal 2 */ + SP_CLR_SIG3 = 0x08000, /* Bit 15: clear signal 3 */ + SP_SET_SIG3 = 0x10000, /* Bit 16: set signal 3 */ + SP_CLR_SIG4 = 0x20000, /* Bit 17: clear signal 4 */ + SP_SET_SIG4 = 0x40000, /* Bit 18: set signal 4 */ + SP_CLR_SIG5 = 0x80000, /* Bit 19: clear signal 5 */ + SP_SET_SIG5 = 0x100000, /* Bit 20: set signal 5 */ + SP_CLR_SIG6 = 0x200000, /* Bit 21: clear signal 6 */ + SP_SET_SIG6 = 0x400000, /* Bit 22: set signal 6 */ + SP_CLR_SIG7 = 0x800000, /* Bit 23: clear signal 7 */ + SP_SET_SIG7 = 0x1000000, /* Bit 24: set signal 7 */ - SP_STATUS_HALT = 0x001, /* Bit 0: halt */ - SP_STATUS_BROKE = 0x002, /* Bit 1: broke */ - SP_STATUS_DMA_BUSY = 0x004, /* Bit 2: dma busy */ - SP_STATUS_DMA_FULL = 0x008, /* Bit 3: dma full */ - SP_STATUS_IO_FULL = 0x010, /* Bit 4: io full */ - SP_STATUS_SSTEP = 0x020, /* Bit 5: single step */ - SP_STATUS_INTR_BREAK = 0x040, /* Bit 6: interrupt on break */ - SP_STATUS_SIG0 = 0x080, /* Bit 7: signal 0 set */ - SP_STATUS_SIG1 = 0x100, /* Bit 8: signal 1 set */ - SP_STATUS_SIG2 = 0x200, /* Bit 9: signal 2 set */ - SP_STATUS_SIG3 = 0x400, /* Bit 10: signal 3 set */ - SP_STATUS_SIG4 = 0x800, /* Bit 11: signal 4 set */ - SP_STATUS_SIG5 = 0x1000, /* Bit 12: signal 5 set */ - SP_STATUS_SIG6 = 0x2000, /* Bit 13: signal 6 set */ - SP_STATUS_SIG7 = 0x4000, /* Bit 14: signal 7 set */ + SP_STATUS_HALT = 0x001, /* Bit 0: halt */ + SP_STATUS_BROKE = 0x002, /* Bit 1: broke */ + SP_STATUS_DMA_BUSY = 0x004, /* Bit 2: dma busy */ + SP_STATUS_DMA_FULL = 0x008, /* Bit 3: dma full */ + SP_STATUS_IO_FULL = 0x010, /* Bit 4: io full */ + SP_STATUS_SSTEP = 0x020, /* Bit 5: single step */ + SP_STATUS_INTR_BREAK = 0x040, /* Bit 6: interrupt on break */ + SP_STATUS_SIG0 = 0x080, /* Bit 7: signal 0 set */ + SP_STATUS_SIG1 = 0x100, /* Bit 8: signal 1 set */ + SP_STATUS_SIG2 = 0x200, /* Bit 9: signal 2 set */ + SP_STATUS_SIG3 = 0x400, /* Bit 10: signal 3 set */ + SP_STATUS_SIG4 = 0x800, /* Bit 11: signal 4 set */ + SP_STATUS_SIG5 = 0x1000, /* Bit 12: signal 5 set */ + SP_STATUS_SIG6 = 0x2000, /* Bit 13: signal 6 set */ + SP_STATUS_SIG7 = 0x4000, /* Bit 14: signal 7 set */ }; //Peripheral Interface flags enum { - PI_STATUS_DMA_BUSY = 0x01, - PI_STATUS_IO_BUSY = 0x02, - PI_STATUS_ERROR = 0x04, + PI_STATUS_DMA_BUSY = 0x01, + PI_STATUS_IO_BUSY = 0x02, + PI_STATUS_ERROR = 0x04, - PI_SET_RESET = 0x01, - PI_CLR_INTR = 0x02, + PI_SET_RESET = 0x01, + PI_CLR_INTR = 0x02, }; - class Serial_InterfaceReg { - Serial_InterfaceReg(); - protected: - Serial_InterfaceReg (DWORD * SerialInterface); + Serial_InterfaceReg (uint32_t * SerialInterface); public: - DWORD & SI_DRAM_ADDR_REG; - DWORD & SI_PIF_ADDR_RD64B_REG; - DWORD & SI_PIF_ADDR_WR64B_REG; - DWORD & SI_STATUS_REG; + uint32_t & SI_DRAM_ADDR_REG; + uint32_t & SI_PIF_ADDR_RD64B_REG; + uint32_t & SI_PIF_ADDR_WR64B_REG; + uint32_t & SI_STATUS_REG; + +private: + Serial_InterfaceReg(); // Disable default constructor + Serial_InterfaceReg(const Serial_InterfaceReg&); // Disable copy constructor + Serial_InterfaceReg& operator=(const Serial_InterfaceReg&); // Disable assignment }; //Serial Interface flags enum { - SI_STATUS_DMA_BUSY = 0x0001, - SI_STATUS_RD_BUSY = 0x0002, - SI_STATUS_DMA_ERROR = 0x0008, - SI_STATUS_INTERRUPT = 0x1000, + SI_STATUS_DMA_BUSY = 0x0001, + SI_STATUS_RD_BUSY = 0x0002, + SI_STATUS_DMA_ERROR = 0x0008, + SI_STATUS_INTERRUPT = 0x1000, }; - enum ROUNDING_MODE { - ROUND_NEAR = _RC_NEAR, - ROUND_DOWN = _RC_DOWN, - ROUND_UP = _RC_UP, - ROUND_CHOP = _RC_CHOP, + ROUND_NEAR = 0x00000000, // _RC_NEAR + ROUND_DOWN = 0x00000100, // _RC_DOWN + ROUND_UP = 0x00000200, // _RC_UP + ROUND_CHOP = 0x00000300, // _RC_CHOP }; -class CRegName { +class CRegName +{ public: - static const char *GPR[32]; - static const char *GPR_Hi[32]; - static const char *GPR_Lo[32]; - static const char *Cop0[32]; - static const char *FPR[32]; - static const char *FPR_Ctrl[32]; + static const char *GPR[32]; + static const char *GPR_Hi[32]; + static const char *GPR_Lo[32]; + static const char *Cop0[32]; + static const char *FPR[32]; + static const char *FPR_Ctrl[32]; }; class CSystemRegisters { protected: - static DWORD * _PROGRAM_COUNTER; - static MIPS_DWORD * _GPR; - static MIPS_DWORD * _FPR; - static DWORD * _CP0; - static MIPS_DWORD * _RegHI; - static MIPS_DWORD * _RegLO; - static float ** _FPR_S; - static double ** _FPR_D; - static DWORD * _FPCR; - static DWORD * _LLBit; - static ROUNDING_MODE * _RoundingModel; + static uint32_t * _PROGRAM_COUNTER; + static MIPS_DWORD * _GPR; + static MIPS_DWORD * _FPR; + static uint32_t * _CP0; + static MIPS_DWORD * _RegHI; + static MIPS_DWORD * _RegLO; + static float ** _FPR_S; + static double ** _FPR_D; + static uint32_t * _FPCR; + static uint32_t * _LLBit; + static ROUNDING_MODE * _RoundingModel; }; class CN64System; class CSystemEvents; -class CRegisters : - private CDebugSettings, - private CGameSettings, - protected CSystemRegisters, - public CP0registers, - public Rdram_InterfaceReg, - public Mips_InterfaceReg, - public Video_InterfaceReg, - public AudioInterfaceReg, - public PeripheralInterfaceReg, - public RDRAMInt_InterfaceReg, - public SigProcessor_InterfaceReg, - public DisplayControlReg, - public Serial_InterfaceReg +class CRegisters : + private CDebugSettings, + private CGameSettings, + protected CSystemRegisters, + public CP0registers, + public Rdram_InterfaceReg, + public Mips_InterfaceReg, + public Video_InterfaceReg, + public AudioInterfaceReg, + public PeripheralInterfaceReg, + public RDRAMInt_InterfaceReg, + public SigProcessor_InterfaceReg, + public DisplayControlReg, + public Serial_InterfaceReg { public: - CRegisters(CN64System * System, CSystemEvents * SystemEvents); + CRegisters(CN64System * System, CSystemEvents * SystemEvents); - //General Registers - DWORD m_PROGRAM_COUNTER; - MIPS_DWORD m_GPR[32]; - DWORD m_CP0[33]; - MIPS_DWORD m_HI; - MIPS_DWORD m_LO; - DWORD m_LLBit; - - //Floating point registers/information - DWORD m_FPCR[32]; - ROUNDING_MODE m_RoundingModel; - MIPS_DWORD m_FPR[32]; - float * m_FPR_S[32]; - double * m_FPR_D[32]; + //General Registers + uint32_t m_PROGRAM_COUNTER; + MIPS_DWORD m_GPR[32]; + uint32_t m_CP0[33]; + MIPS_DWORD m_HI; + MIPS_DWORD m_LO; + uint32_t m_LLBit; - //Memory Mapped N64 registers - DWORD m_RDRAM_Registers[10]; - DWORD m_SigProcessor_Interface[10]; - DWORD m_Display_ControlReg[10]; - DWORD m_Mips_Interface[4]; - DWORD m_Video_Interface[14]; - DWORD m_Audio_Interface[6]; - DWORD m_Peripheral_Interface[13]; - DWORD m_RDRAM_Interface[8]; - DWORD m_SerialInterface[4]; - DWORD m_AudioIntrReg; - DWORD m_GfxIntrReg; - DWORD m_RspIntrReg; + //Floating point registers/information + uint32_t m_FPCR[32]; + ROUNDING_MODE m_RoundingModel; + MIPS_DWORD m_FPR[32]; + float * m_FPR_S[32]; + double * m_FPR_D[32]; + //Memory Mapped N64 registers + uint32_t m_RDRAM_Registers[10]; + uint32_t m_SigProcessor_Interface[10]; + uint32_t m_Display_ControlReg[10]; + uint32_t m_Mips_Interface[4]; + uint32_t m_Video_Interface[14]; + uint32_t m_Audio_Interface[6]; + uint32_t m_Peripheral_Interface[13]; + uint32_t m_RDRAM_Interface[8]; + uint32_t m_SerialInterface[4]; + uint32_t m_AudioIntrReg; + uint32_t m_GfxIntrReg; + uint32_t m_RspIntrReg; - void CheckInterrupts (); - void DoAddressError ( bool DelaySlot, DWORD BadVaddr, bool FromRead ); - void DoBreakException ( bool DelaySlot ); - void DoCopUnusableException ( bool DelaySlot, int Coprocessor ); - bool DoIntrException ( bool DelaySlot ); - void DoTLBReadMiss ( bool DelaySlot, DWORD BadVaddr ); - void DoSysCallException ( bool DelaySlot); - void FixFpuLocations (); - void Reset (); - void SetAsCurrentSystem (); + void CheckInterrupts (); + void DoAddressError ( bool DelaySlot, uint32_t BadVaddr, bool FromRead ); + void DoBreakException ( bool DelaySlot ); + void DoCopUnusableException ( bool DelaySlot, int32_t Coprocessor ); + bool DoIntrException ( bool DelaySlot ); + void DoTLBReadMiss ( bool DelaySlot, uint32_t BadVaddr ); + void DoSysCallException ( bool DelaySlot); + void FixFpuLocations (); + void Reset (); + void SetAsCurrentSystem (); private: - CRegisters(); // Disable default constructor - CRegisters(const CRegisters&); // Disable copy constructor - CRegisters& operator=(const CRegisters&); // Disable assignment + CRegisters(); // Disable default constructor + CRegisters(const CRegisters&); // Disable copy constructor + CRegisters& operator=(const CRegisters&); // Disable assignment - bool m_FirstInterupt; - CN64System * m_System; - CSystemEvents * m_SystemEvents; + bool m_FirstInterupt; + CN64System * m_System; + CSystemEvents * m_SystemEvents; }; diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp index e2a879423..6a89fb767 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp @@ -93,7 +93,7 @@ void CRecompiler::Run() void CRecompiler::RecompilerMain_VirtualTable() { bool & Done = m_EndEmulation; - DWORD & PC = PROGRAM_COUNTER; + uint32_t & PC = PROGRAM_COUNTER; while(!Done) { diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Class.h b/Source/Project64/N64 System/Recompiler/Recompiler Class.h index 0f17d71b9..5081a7a92 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Class.h +++ b/Source/Project64/N64 System/Recompiler/Recompiler Class.h @@ -70,5 +70,5 @@ private: DWORD m_MemoryStack; //Quick access to registers - DWORD & PROGRAM_COUNTER; + uint32_t & PROGRAM_COUNTER; }; From 1ace31216d17bd5ab28c060de6e829d85a574614 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 9 Nov 2015 07:48:46 +1100 Subject: [PATCH 094/213] [Projet64] remove typecasting in Debugger - View Memory.cpp --- .../N64 System/Debugger/Debugger - View Memory.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp b/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp index 87c217812..8c577ab73 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp @@ -402,14 +402,14 @@ void CDebugMemoryView::RefreshMemory(bool ResetCompare) if (m_DataVAddrr) { - if (!g_MMU->LW_VAddr(m_DataStartLoc & ~3, (uint32_t &)word.UW)) + if (!g_MMU->LW_VAddr(m_DataStartLoc & ~3, word.UW)) { ValidData = false; } } else { - if (!g_MMU->LW_PAddr(m_DataStartLoc & ~3, (uint32_t &)word.UW)) + if (!g_MMU->LW_PAddr(m_DataStartLoc & ~3, word.UW)) { ValidData = false; } @@ -438,14 +438,14 @@ void CDebugMemoryView::RefreshMemory(bool ResetCompare) if (m_DataVAddrr) { - if (!g_MMU->LW_VAddr(Pos, (uint32_t &)word.UW)) + if (!g_MMU->LW_VAddr(Pos, word.UW)) { ValidData = false; } } else { - if (!g_MMU->LW_PAddr(Pos, (uint32_t &)word.UW)) + if (!g_MMU->LW_PAddr(Pos, word.UW)) { ValidData = false; } From e85c1665b1d2794688f5dbf92678cab63139dde7 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 9 Nov 2015 07:55:32 +1100 Subject: [PATCH 095/213] [Project64] Get Interpreter Ops to use standard types --- .../Interpreter/Interpreter CPU.cpp | 836 ++-- .../Interpreter/Interpreter Ops 32.cpp | 2315 +++++----- .../Interpreter/Interpreter Ops.cpp | 4036 ++++++++--------- .../N64 System/Interpreter/Interpreter Ops.h | 405 +- .../N64 System/Recompiler/Code Block.cpp | 2 +- .../N64 System/Recompiler/Code Section.cpp | 2 +- .../N64 System/Recompiler/Loop Analysis.cpp | 2 +- .../N64 System/Recompiler/Recompiler Ops.cpp | 2 +- 8 files changed, 3791 insertions(+), 3809 deletions(-) diff --git a/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp b/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp index 24c7afe18..0bd568b59 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp @@ -12,446 +12,444 @@ R4300iOp::Func * CInterpreterCPU::m_R4300i_Opcode = NULL; -void ExecuteInterpreterOps (DWORD /*Cycles*/) +void ExecuteInterpreterOps(uint32_t /*Cycles*/) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } -bool DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2) +bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2) { - OPCODE Command; + OPCODE Command; - if (!g_MMU->LW_VAddr(PC + 4, Command.Hex)) - { - //g_Notify->DisplayError(L"Failed to load word 2"); - //ExitThread(0); - return true; - } + if (!g_MMU->LW_VAddr(PC + 4, Command.Hex)) + { + //g_Notify->DisplayError(L"Failed to load word 2"); + //ExitThread(0); + return true; + } - switch (Command.op) - { - case R4300i_SPECIAL: - switch (Command.funct) - { - case R4300i_SPECIAL_SLL: - case R4300i_SPECIAL_SRL: - case R4300i_SPECIAL_SRA: - case R4300i_SPECIAL_SLLV: - case R4300i_SPECIAL_SRLV: - case R4300i_SPECIAL_SRAV: - case R4300i_SPECIAL_MFHI: - case R4300i_SPECIAL_MTHI: - case R4300i_SPECIAL_MFLO: - case R4300i_SPECIAL_MTLO: - case R4300i_SPECIAL_DSLLV: - case R4300i_SPECIAL_DSRLV: - case R4300i_SPECIAL_DSRAV: - case R4300i_SPECIAL_ADD: - case R4300i_SPECIAL_ADDU: - case R4300i_SPECIAL_SUB: - case R4300i_SPECIAL_SUBU: - case R4300i_SPECIAL_AND: - case R4300i_SPECIAL_OR: - case R4300i_SPECIAL_XOR: - case R4300i_SPECIAL_NOR: - case R4300i_SPECIAL_SLT: - case R4300i_SPECIAL_SLTU: - case R4300i_SPECIAL_DADD: - case R4300i_SPECIAL_DADDU: - case R4300i_SPECIAL_DSUB: - case R4300i_SPECIAL_DSUBU: - case R4300i_SPECIAL_DSLL: - case R4300i_SPECIAL_DSRL: - case R4300i_SPECIAL_DSRA: - case R4300i_SPECIAL_DSLL32: - case R4300i_SPECIAL_DSRL32: - case R4300i_SPECIAL_DSRA32: - if (Command.rd == 0) - { - return false; - } - if (Command.rd == Reg1 || Command.rd == Reg2) - { - return true; - } - break; - case R4300i_SPECIAL_MULT: - case R4300i_SPECIAL_MULTU: - case R4300i_SPECIAL_DIV: - case R4300i_SPECIAL_DIVU: - case R4300i_SPECIAL_DMULT: - case R4300i_SPECIAL_DMULTU: - case R4300i_SPECIAL_DDIV: - case R4300i_SPECIAL_DDIVU: - break; - default: - if (g_Settings->LoadBool(Debugger_Enabled)) - { - g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?",R4300iOpcodeName(Command.Hex,PC+4), PC).ToUTF16().c_str()); - } - return true; - } - break; - case R4300i_CP0: - switch (Command.rs) - { - case R4300i_COP0_MT: break; - case R4300i_COP0_MF: - if (Command.rt == 0) - { - return false; - } - if (Command.rt == Reg1 || Command.rt == Reg2) - { - return true; - } - break; - default: - if ( (Command.rs & 0x10 ) != 0 ) - { - switch (Command.funct) - { - case R4300i_COP0_CO_TLBR: break; - case R4300i_COP0_CO_TLBWI: break; - case R4300i_COP0_CO_TLBWR: break; - case R4300i_COP0_CO_TLBP: break; - default: - if (g_Settings->LoadBool(Debugger_Enabled)) - { - g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?\n6",R4300iOpcodeName(Command.Hex,PC+4), PC).ToUTF16().c_str()); - } - return true; - } - } - else - { - if (g_Settings->LoadBool(Debugger_Enabled)) - { - g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?\n7",R4300iOpcodeName(Command.Hex,PC+4), PC).ToUTF16().c_str()); - } - return true; - } - } - break; - case R4300i_CP1: - switch (Command.fmt) - { - case R4300i_COP1_MF: - if (Command.rt == 0) - { - return false; - } - if (Command.rt == Reg1 || Command.rt == Reg2) - { - return true; - } - break; - case R4300i_COP1_CF: break; - case R4300i_COP1_MT: break; - case R4300i_COP1_CT: break; - case R4300i_COP1_S: break; - case R4300i_COP1_D: break; - case R4300i_COP1_W: break; - case R4300i_COP1_L: break; - default: - if (g_Settings->LoadBool(Debugger_Enabled)) - { - g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?",R4300iOpcodeName(Command.Hex,PC+4), PC).ToUTF16().c_str()); - } - return true; - } - break; - case R4300i_ANDI: - case R4300i_ORI: - case R4300i_XORI: - case R4300i_LUI: - case R4300i_ADDI: - case R4300i_ADDIU: - case R4300i_SLTI: - case R4300i_SLTIU: - case R4300i_DADDI: - case R4300i_DADDIU: - case R4300i_LB: - case R4300i_LH: - case R4300i_LW: - case R4300i_LWL: - case R4300i_LWR: - case R4300i_LDL: - case R4300i_LDR: - case R4300i_LBU: - case R4300i_LHU: - case R4300i_LD: - case R4300i_LWC1: - case R4300i_LDC1: - if (Command.rt == 0) - { - return false; - } - if (Command.rt == Reg1 || Command.rt == Reg2) - { - return true; - } - break; - case R4300i_CACHE: break; - case R4300i_SB: break; - case R4300i_SH: break; - case R4300i_SW: break; - case R4300i_SWR: break; - case R4300i_SWL: break; - case R4300i_SWC1: break; - case R4300i_SDC1: break; - case R4300i_SD: break; - default: - if (g_Settings->LoadBool(Debugger_Enabled)) - { - g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?",R4300iOpcodeName(Command.Hex,PC+4), PC).ToUTF16().c_str()); - } - return true; - } - return false; + switch (Command.op) + { + case R4300i_SPECIAL: + switch (Command.funct) + { + case R4300i_SPECIAL_SLL: + case R4300i_SPECIAL_SRL: + case R4300i_SPECIAL_SRA: + case R4300i_SPECIAL_SLLV: + case R4300i_SPECIAL_SRLV: + case R4300i_SPECIAL_SRAV: + case R4300i_SPECIAL_MFHI: + case R4300i_SPECIAL_MTHI: + case R4300i_SPECIAL_MFLO: + case R4300i_SPECIAL_MTLO: + case R4300i_SPECIAL_DSLLV: + case R4300i_SPECIAL_DSRLV: + case R4300i_SPECIAL_DSRAV: + case R4300i_SPECIAL_ADD: + case R4300i_SPECIAL_ADDU: + case R4300i_SPECIAL_SUB: + case R4300i_SPECIAL_SUBU: + case R4300i_SPECIAL_AND: + case R4300i_SPECIAL_OR: + case R4300i_SPECIAL_XOR: + case R4300i_SPECIAL_NOR: + case R4300i_SPECIAL_SLT: + case R4300i_SPECIAL_SLTU: + case R4300i_SPECIAL_DADD: + case R4300i_SPECIAL_DADDU: + case R4300i_SPECIAL_DSUB: + case R4300i_SPECIAL_DSUBU: + case R4300i_SPECIAL_DSLL: + case R4300i_SPECIAL_DSRL: + case R4300i_SPECIAL_DSRA: + case R4300i_SPECIAL_DSLL32: + case R4300i_SPECIAL_DSRL32: + case R4300i_SPECIAL_DSRA32: + if (Command.rd == 0) + { + return false; + } + if (Command.rd == Reg1 || Command.rd == Reg2) + { + return true; + } + break; + case R4300i_SPECIAL_MULT: + case R4300i_SPECIAL_MULTU: + case R4300i_SPECIAL_DIV: + case R4300i_SPECIAL_DIVU: + case R4300i_SPECIAL_DMULT: + case R4300i_SPECIAL_DMULTU: + case R4300i_SPECIAL_DDIV: + case R4300i_SPECIAL_DDIVU: + break; + default: + if (g_Settings->LoadBool(Debugger_Enabled)) + { + g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?", R4300iOpcodeName(Command.Hex, PC + 4), PC).ToUTF16().c_str()); + } + return true; + } + break; + case R4300i_CP0: + switch (Command.rs) + { + case R4300i_COP0_MT: break; + case R4300i_COP0_MF: + if (Command.rt == 0) + { + return false; + } + if (Command.rt == Reg1 || Command.rt == Reg2) + { + return true; + } + break; + default: + if ((Command.rs & 0x10) != 0) + { + switch (Command.funct) + { + case R4300i_COP0_CO_TLBR: break; + case R4300i_COP0_CO_TLBWI: break; + case R4300i_COP0_CO_TLBWR: break; + case R4300i_COP0_CO_TLBP: break; + default: + if (g_Settings->LoadBool(Debugger_Enabled)) + { + g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?\n6", R4300iOpcodeName(Command.Hex, PC + 4), PC).ToUTF16().c_str()); + } + return true; + } + } + else + { + if (g_Settings->LoadBool(Debugger_Enabled)) + { + g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?\n7", R4300iOpcodeName(Command.Hex, PC + 4), PC).ToUTF16().c_str()); + } + return true; + } + } + break; + case R4300i_CP1: + switch (Command.fmt) + { + case R4300i_COP1_MF: + if (Command.rt == 0) + { + return false; + } + if (Command.rt == Reg1 || Command.rt == Reg2) + { + return true; + } + break; + case R4300i_COP1_CF: break; + case R4300i_COP1_MT: break; + case R4300i_COP1_CT: break; + case R4300i_COP1_S: break; + case R4300i_COP1_D: break; + case R4300i_COP1_W: break; + case R4300i_COP1_L: break; + default: + if (g_Settings->LoadBool(Debugger_Enabled)) + { + g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?", R4300iOpcodeName(Command.Hex, PC + 4), PC).ToUTF16().c_str()); + } + return true; + } + break; + case R4300i_ANDI: + case R4300i_ORI: + case R4300i_XORI: + case R4300i_LUI: + case R4300i_ADDI: + case R4300i_ADDIU: + case R4300i_SLTI: + case R4300i_SLTIU: + case R4300i_DADDI: + case R4300i_DADDIU: + case R4300i_LB: + case R4300i_LH: + case R4300i_LW: + case R4300i_LWL: + case R4300i_LWR: + case R4300i_LDL: + case R4300i_LDR: + case R4300i_LBU: + case R4300i_LHU: + case R4300i_LD: + case R4300i_LWC1: + case R4300i_LDC1: + if (Command.rt == 0) + { + return false; + } + if (Command.rt == Reg1 || Command.rt == Reg2) + { + return true; + } + break; + case R4300i_CACHE: break; + case R4300i_SB: break; + case R4300i_SH: break; + case R4300i_SW: break; + case R4300i_SWR: break; + case R4300i_SWL: break; + case R4300i_SWC1: break; + case R4300i_SDC1: break; + case R4300i_SD: break; + default: + if (g_Settings->LoadBool(Debugger_Enabled)) + { + g_Notify->DisplayError(stdstr_f("Does %s effect Delay slot at %X?", R4300iOpcodeName(Command.Hex, PC + 4), PC).ToUTF16().c_str()); + } + return true; + } + return false; } void CInterpreterCPU::BuildCPU() -{ - R4300iOp::m_TestTimer = false; - R4300iOp::m_NextInstruction = NORMAL; - R4300iOp::m_JumpToLocation = 0; - - if (g_Settings->LoadBool(Game_32Bit)) - { - m_R4300i_Opcode = R4300iOp32::BuildInterpreter(); - } - else - { - m_R4300i_Opcode = R4300iOp::BuildInterpreter(); - } +{ + R4300iOp::m_TestTimer = false; + R4300iOp::m_NextInstruction = NORMAL; + R4300iOp::m_JumpToLocation = 0; + + if (g_Settings->LoadBool(Game_32Bit)) + { + m_R4300i_Opcode = R4300iOp32::BuildInterpreter(); + } + else + { + m_R4300i_Opcode = R4300iOp::BuildInterpreter(); + } } void CInterpreterCPU::InPermLoop() { - // *** Changed ***/ - //if (CPU_Type == CPU_SyncCores) - //{ - // SyncRegisters.CP0[9] +=5; - //} + // *** Changed ***/ + //if (CPU_Type == CPU_SyncCores) + //{ + // SyncRegisters.CP0[9] +=5; + //} - /* Interrupts enabled */ - if (( g_Reg->STATUS_REGISTER & STATUS_IE ) == 0 || - ( g_Reg->STATUS_REGISTER & STATUS_EXL ) != 0 || - ( g_Reg->STATUS_REGISTER & STATUS_ERL ) != 0 || - ( g_Reg->STATUS_REGISTER & 0xFF00) == 0) - { - if (g_Plugins->Gfx()->UpdateScreen != NULL) - { - g_Plugins->Gfx()->UpdateScreen(); - } - //CurrentFrame = 0; - //CurrentPercent = 0; - //DisplayFPS(); - g_Notify->DisplayError(GS(MSG_PERM_LOOP)); - g_System->CloseCpu(); - } - else - { - if (*g_NextTimer > 0) - { - *g_NextTimer = 0 - g_System->CountPerOp(); - g_SystemTimer->UpdateTimers(); - } - } + /* Interrupts enabled */ + if ((g_Reg->STATUS_REGISTER & STATUS_IE) == 0 || + (g_Reg->STATUS_REGISTER & STATUS_EXL) != 0 || + (g_Reg->STATUS_REGISTER & STATUS_ERL) != 0 || + (g_Reg->STATUS_REGISTER & 0xFF00) == 0) + { + if (g_Plugins->Gfx()->UpdateScreen != NULL) + { + g_Plugins->Gfx()->UpdateScreen(); + } + //CurrentFrame = 0; + //CurrentPercent = 0; + //DisplayFPS(); + g_Notify->DisplayError(GS(MSG_PERM_LOOP)); + g_System->CloseCpu(); + } + else + { + if (*g_NextTimer > 0) + { + *g_NextTimer = 0 - g_System->CountPerOp(); + g_SystemTimer->UpdateTimers(); + } + } } void CInterpreterCPU::ExecuteCPU() -{ - bool & Done = g_System->m_EndEmulation; - uint32_t & PROGRAM_COUNTER = *_PROGRAM_COUNTER; - OPCODE & Opcode = R4300iOp::m_Opcode; - DWORD & JumpToLocation = R4300iOp::m_JumpToLocation; - bool & TestTimer = R4300iOp::m_TestTimer; - const BOOL & bDoSomething= g_SystemEvents->DoSomething(); - DWORD CountPerOp = g_System->CountPerOp(); - int & NextTimer = *g_NextTimer; - - __try - { - while (!Done) - { - if (g_MMU->LW_VAddr(PROGRAM_COUNTER, Opcode.Hex)) - { - /*if (PROGRAM_COUNTER > 0x80000300 && PROGRAM_COUNTER< 0x80380000) - { - WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER)); - //WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s t9: %08X v1: %08X",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER),_GPR[0x19].UW[0],_GPR[0x03].UW[0]); - //WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %d %d",*_PROGRAM_COUNTER,*g_NextTimer,g_SystemTimer->CurrentType()); - }*/ - m_R4300i_Opcode[ Opcode.op ](); - NextTimer -= CountPerOp; - - switch (R4300iOp::m_NextInstruction) - { - case NORMAL: - PROGRAM_COUNTER += 4; - break; - case DELAY_SLOT: - R4300iOp::m_NextInstruction = JUMP; - PROGRAM_COUNTER += 4; - break; - case PERMLOOP_DO_DELAY: - R4300iOp::m_NextInstruction = PERMLOOP_DELAY_DONE; - PROGRAM_COUNTER += 4; - break; - case JUMP: - { - BOOL CheckTimer = (JumpToLocation < PROGRAM_COUNTER || TestTimer); - PROGRAM_COUNTER = JumpToLocation; - R4300iOp::m_NextInstruction = NORMAL; - if (CheckTimer) - { - TestTimer = false; - if (NextTimer < 0) - { - g_SystemTimer->TimerDone(); - } - if (bDoSomething) - { - g_SystemEvents->ExecuteEvents(); - } - } - } - break; - case PERMLOOP_DELAY_DONE: - PROGRAM_COUNTER = JumpToLocation; - R4300iOp::m_NextInstruction = NORMAL; - CInterpreterCPU::InPermLoop(); - g_SystemTimer->TimerDone(); - if (bDoSomething) - { - g_SystemEvents->ExecuteEvents(); - } - break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } - else - { - g_Reg->DoTLBReadMiss(R4300iOp::m_NextInstruction == JUMP,PROGRAM_COUNTER); - R4300iOp::m_NextInstruction = NORMAL; - } - } - } __except( g_MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) - { - g_Notify->DisplayError(GS(MSG_UNKNOWN_MEM_ACTION)); - ExitThread(0); - } -} - - -void CInterpreterCPU::ExecuteOps(int Cycles) { - bool & Done = g_System->m_EndEmulation; + bool & Done = g_System->m_EndEmulation; uint32_t & PROGRAM_COUNTER = *_PROGRAM_COUNTER; - OPCODE & Opcode = R4300iOp::m_Opcode; - DWORD & JumpToLocation = R4300iOp::m_JumpToLocation; - bool & TestTimer = R4300iOp::m_TestTimer; - const BOOL & DoSomething = g_SystemEvents->DoSomething(); - DWORD CountPerOp = g_System->CountPerOp(); + OPCODE & Opcode = R4300iOp::m_Opcode; + uint32_t & JumpToLocation = R4300iOp::m_JumpToLocation; + bool & TestTimer = R4300iOp::m_TestTimer; + const int32_t & bDoSomething = g_SystemEvents->DoSomething(); + uint32_t CountPerOp = g_System->CountPerOp(); + int32_t & NextTimer = *g_NextTimer; __try - { - while (!Done) - { - if (Cycles <= 0) - { - g_SystemTimer->UpdateTimers(); - return; - } - - if (g_MMU->LW_VAddr(PROGRAM_COUNTER, Opcode.Hex)) - { - /*if (PROGRAM_COUNTER > 0x80000300 && PROGRAM_COUNTER< 0x80380000) - { - WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER)); - //WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s t9: %08X v1: %08X",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER),_GPR[0x19].UW[0],_GPR[0x03].UW[0]); - //WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %d %d",*_PROGRAM_COUNTER,*g_NextTimer,g_SystemTimer->CurrentType()); - }*/ - /*if (PROGRAM_COUNTER > 0x80323000 && PROGRAM_COUNTER< 0x80380000) - { - WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER)); - //WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s t9: %08X v1: %08X",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER),_GPR[0x19].UW[0],_GPR[0x03].UW[0]); - //WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %d %d",*_PROGRAM_COUNTER,*g_NextTimer,g_SystemTimer->CurrentType()); - }*/ - m_R4300i_Opcode[ Opcode.op ](); - _GPR[0].DW = 0; /* MIPS $zero hard-wired to 0 */ + { + while (!Done) + { + if (g_MMU->LW_VAddr(PROGRAM_COUNTER, Opcode.Hex)) + { + /*if (PROGRAM_COUNTER > 0x80000300 && PROGRAM_COUNTER< 0x80380000) + { + WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER)); + //WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s t9: %08X v1: %08X",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER),_GPR[0x19].UW[0],_GPR[0x03].UW[0]); + //WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %d %d",*_PROGRAM_COUNTER,*g_NextTimer,g_SystemTimer->CurrentType()); + }*/ + m_R4300i_Opcode[Opcode.op](); + NextTimer -= CountPerOp; - Cycles -= CountPerOp; - *g_NextTimer -= CountPerOp; - - /*static DWORD TestAddress = 0x80077B0C, TestValue = 0, CurrentValue = 0; - if (g_MMU->LW_VAddr(TestAddress, TestValue)) - { - if (TestValue != CurrentValue) - { - WriteTraceF(TraceError,"%X: %X changed (%s)",PROGRAM_COUNTER,TestAddress,R4300iOpcodeName(m_Opcode.Hex,PROGRAM_COUNTER) ); - CurrentValue = TestValue; - } - }*/ - - switch (R4300iOp::m_NextInstruction) - { - case NORMAL: - PROGRAM_COUNTER += 4; - break; - case DELAY_SLOT: - R4300iOp::m_NextInstruction = JUMP; - PROGRAM_COUNTER += 4; - break; - case PERMLOOP_DO_DELAY: - R4300iOp::m_NextInstruction = PERMLOOP_DELAY_DONE; - PROGRAM_COUNTER += 4; - break; - case JUMP: - { - BOOL CheckTimer = (JumpToLocation < PROGRAM_COUNTER || TestTimer); - PROGRAM_COUNTER = JumpToLocation; - R4300iOp::m_NextInstruction = NORMAL; - if (CheckTimer) - { - TestTimer = false; - if (*g_NextTimer < 0) - { - g_SystemTimer->TimerDone(); - } - if (DoSomething) - { - g_SystemEvents->ExecuteEvents(); - } - } - } - break; - case PERMLOOP_DELAY_DONE: - PROGRAM_COUNTER = JumpToLocation; - R4300iOp::m_NextInstruction = NORMAL; - CInterpreterCPU::InPermLoop(); - g_SystemTimer->TimerDone(); - if (DoSomething) - { - g_SystemEvents->ExecuteEvents(); - } - break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } - else - { - g_Reg->DoTLBReadMiss(R4300iOp::m_NextInstruction == JUMP,PROGRAM_COUNTER); - R4300iOp::m_NextInstruction = NORMAL; - } - } + switch (R4300iOp::m_NextInstruction) + { + case NORMAL: + PROGRAM_COUNTER += 4; + break; + case DELAY_SLOT: + R4300iOp::m_NextInstruction = JUMP; + PROGRAM_COUNTER += 4; + break; + case PERMLOOP_DO_DELAY: + R4300iOp::m_NextInstruction = PERMLOOP_DELAY_DONE; + PROGRAM_COUNTER += 4; + break; + case JUMP: + { + bool CheckTimer = (JumpToLocation < PROGRAM_COUNTER || TestTimer); + PROGRAM_COUNTER = JumpToLocation; + R4300iOp::m_NextInstruction = NORMAL; + if (CheckTimer) + { + TestTimer = false; + if (NextTimer < 0) + { + g_SystemTimer->TimerDone(); + } + if (bDoSomething) + { + g_SystemEvents->ExecuteEvents(); + } + } + } + break; + case PERMLOOP_DELAY_DONE: + PROGRAM_COUNTER = JumpToLocation; + R4300iOp::m_NextInstruction = NORMAL; + CInterpreterCPU::InPermLoop(); + g_SystemTimer->TimerDone(); + if (bDoSomething) + { + g_SystemEvents->ExecuteEvents(); + } + break; + default: + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } + else + { + g_Reg->DoTLBReadMiss(R4300iOp::m_NextInstruction == JUMP, PROGRAM_COUNTER); + R4300iOp::m_NextInstruction = NORMAL; + } + } } __except( g_MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) - { - g_Notify->DisplayError(GS(MSG_UNKNOWN_MEM_ACTION)); - ExitThread(0); - } + { + g_Notify->FatalError(GS(MSG_UNKNOWN_MEM_ACTION)); + } +} + +void CInterpreterCPU::ExecuteOps(int32_t Cycles) +{ + bool & Done = g_System->m_EndEmulation; + uint32_t & PROGRAM_COUNTER = *_PROGRAM_COUNTER; + OPCODE & Opcode = R4300iOp::m_Opcode; + uint32_t & JumpToLocation = R4300iOp::m_JumpToLocation; + bool & TestTimer = R4300iOp::m_TestTimer; + const int32_t & DoSomething = g_SystemEvents->DoSomething(); + uint32_t CountPerOp = g_System->CountPerOp(); + + __try + { + while (!Done) + { + if (Cycles <= 0) + { + g_SystemTimer->UpdateTimers(); + return; + } + + if (g_MMU->LW_VAddr(PROGRAM_COUNTER, Opcode.Hex)) + { + /*if (PROGRAM_COUNTER > 0x80000300 && PROGRAM_COUNTER< 0x80380000) + { + WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER)); + //WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s t9: %08X v1: %08X",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER),_GPR[0x19].UW[0],_GPR[0x03].UW[0]); + //WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %d %d",*_PROGRAM_COUNTER,*g_NextTimer,g_SystemTimer->CurrentType()); + }*/ + /*if (PROGRAM_COUNTER > 0x80323000 && PROGRAM_COUNTER< 0x80380000) + { + WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER)); + //WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s t9: %08X v1: %08X",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER),_GPR[0x19].UW[0],_GPR[0x03].UW[0]); + //WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %d %d",*_PROGRAM_COUNTER,*g_NextTimer,g_SystemTimer->CurrentType()); + }*/ + m_R4300i_Opcode[Opcode.op](); + _GPR[0].DW = 0; /* MIPS $zero hard-wired to 0 */ + + Cycles -= CountPerOp; + *g_NextTimer -= CountPerOp; + + /*static uint32_t TestAddress = 0x80077B0C, TestValue = 0, CurrentValue = 0; + if (g_MMU->LW_VAddr(TestAddress, TestValue)) + { + if (TestValue != CurrentValue) + { + WriteTraceF(TraceError,"%X: %X changed (%s)",PROGRAM_COUNTER,TestAddress,R4300iOpcodeName(m_Opcode.Hex,PROGRAM_COUNTER) ); + CurrentValue = TestValue; + } + }*/ + + switch (R4300iOp::m_NextInstruction) + { + case NORMAL: + PROGRAM_COUNTER += 4; + break; + case DELAY_SLOT: + R4300iOp::m_NextInstruction = JUMP; + PROGRAM_COUNTER += 4; + break; + case PERMLOOP_DO_DELAY: + R4300iOp::m_NextInstruction = PERMLOOP_DELAY_DONE; + PROGRAM_COUNTER += 4; + break; + case JUMP: + { + bool CheckTimer = (JumpToLocation < PROGRAM_COUNTER || TestTimer); + PROGRAM_COUNTER = JumpToLocation; + R4300iOp::m_NextInstruction = NORMAL; + if (CheckTimer) + { + TestTimer = false; + if (*g_NextTimer < 0) + { + g_SystemTimer->TimerDone(); + } + if (DoSomething) + { + g_SystemEvents->ExecuteEvents(); + } + } + } + break; + case PERMLOOP_DELAY_DONE: + PROGRAM_COUNTER = JumpToLocation; + R4300iOp::m_NextInstruction = NORMAL; + CInterpreterCPU::InPermLoop(); + g_SystemTimer->TimerDone(); + if (DoSomething) + { + g_SystemEvents->ExecuteEvents(); + } + break; + default: + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } + else + { + g_Reg->DoTLBReadMiss(R4300iOp::m_NextInstruction == JUMP, PROGRAM_COUNTER); + R4300iOp::m_NextInstruction = NORMAL; + } + } + } + __except( g_MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) + { + g_Notify->FatalError(GS(MSG_UNKNOWN_MEM_ACTION)); + } } diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp index 391c5f389..f168b946d 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp @@ -9,1425 +9,1424 @@ * * ****************************************************************************/ #include "stdafx.h" -//#include "../C Core/Logging.h" -bool DelaySlotEffectsCompare ( DWORD PC, DWORD Reg1, DWORD Reg2 ); +bool DelaySlotEffectsCompare ( uint32_t PC, uint32_t Reg1, uint32_t Reg2 ); #define ADDRESS_ERROR_EXCEPTION(Address,FromRead) \ - g_Reg->DoAddressError(m_NextInstruction == JUMP,Address,FromRead);\ - m_NextInstruction = JUMP;\ - m_JumpToLocation = (*_PROGRAM_COUNTER);\ - return; + g_Reg->DoAddressError(m_NextInstruction == JUMP,Address,FromRead);\ + m_NextInstruction = JUMP;\ + m_JumpToLocation = (*_PROGRAM_COUNTER);\ + return; //#define TEST_COP1_USABLE_EXCEPTION #define TEST_COP1_USABLE_EXCEPTION \ - if ((g_Reg->STATUS_REGISTER & STATUS_CU1) == 0) {\ - g_Reg->DoCopUnusableException(m_NextInstruction == JUMP,1);\ - m_NextInstruction = JUMP;\ - m_JumpToLocation = (*_PROGRAM_COUNTER);\ - return;\ - } + if ((g_Reg->STATUS_REGISTER & STATUS_CU1) == 0) {\ + g_Reg->DoCopUnusableException(m_NextInstruction == JUMP,1);\ + m_NextInstruction = JUMP;\ + m_JumpToLocation = (*_PROGRAM_COUNTER);\ + return;\ + } #define TLB_READ_EXCEPTION(Address) \ - g_Reg->DoTLBReadMiss(m_NextInstruction == JUMP,Address);\ - m_NextInstruction = JUMP;\ - m_JumpToLocation = (*_PROGRAM_COUNTER);\ - return; + g_Reg->DoTLBReadMiss(m_NextInstruction == JUMP,Address);\ + m_NextInstruction = JUMP;\ + m_JumpToLocation = (*_PROGRAM_COUNTER);\ + return; R4300iOp32::Func * R4300iOp32::BuildInterpreter() -{ - Jump_Opcode[ 0] = SPECIAL; - Jump_Opcode[ 1] = REGIMM; - Jump_Opcode[ 2] = R4300iOp::J; - Jump_Opcode[ 3] = JAL; - Jump_Opcode[ 4] = BEQ; - Jump_Opcode[ 5] = BNE; - Jump_Opcode[ 6] = BLEZ; - Jump_Opcode[ 7] = BGTZ; - Jump_Opcode[ 8] = ADDI; - Jump_Opcode[ 9] = ADDIU; - Jump_Opcode[10] = SLTI; - Jump_Opcode[11] = SLTIU; - Jump_Opcode[12] = ANDI; - Jump_Opcode[13] = ORI; - Jump_Opcode[14] = XORI; - Jump_Opcode[15] = LUI; - Jump_Opcode[16] = COP0; - Jump_Opcode[17] = COP1; - Jump_Opcode[18] = R4300iOp::UnknownOpcode; - Jump_Opcode[19] = R4300iOp::UnknownOpcode; - Jump_Opcode[20] = BEQL; - Jump_Opcode[21] = BNEL; - Jump_Opcode[22] = BLEZL; - Jump_Opcode[23] = BGTZL; - Jump_Opcode[24] = R4300iOp::UnknownOpcode; - Jump_Opcode[25] = R4300iOp::DADDIU; - Jump_Opcode[26] = R4300iOp::LDL; - Jump_Opcode[27] = R4300iOp::LDR; - Jump_Opcode[28] = R4300iOp::UnknownOpcode; - Jump_Opcode[29] = R4300iOp::UnknownOpcode; - Jump_Opcode[30] = R4300iOp::UnknownOpcode; - Jump_Opcode[31] = R4300iOp::UnknownOpcode; - Jump_Opcode[32] = LB; - Jump_Opcode[33] = LH; - Jump_Opcode[34] = LWL; - Jump_Opcode[35] = LW; - Jump_Opcode[36] = LBU; - Jump_Opcode[37] = LHU; - Jump_Opcode[38] = LWR; - Jump_Opcode[39] = LWU; - Jump_Opcode[40] = R4300iOp::SB; - Jump_Opcode[41] = R4300iOp::SH; - Jump_Opcode[42] = R4300iOp::SWL; - Jump_Opcode[43] = R4300iOp::SW; - Jump_Opcode[44] = R4300iOp::SDL; - Jump_Opcode[45] = R4300iOp::SDR; - Jump_Opcode[46] = R4300iOp::SWR; - Jump_Opcode[47] = R4300iOp::CACHE; - Jump_Opcode[48] = R4300iOp::LL; - Jump_Opcode[49] = R4300iOp::LWC1; - Jump_Opcode[50] = R4300iOp::UnknownOpcode; - Jump_Opcode[51] = R4300iOp::UnknownOpcode; - Jump_Opcode[52] = R4300iOp::UnknownOpcode; - Jump_Opcode[53] = R4300iOp::LDC1; - Jump_Opcode[54] = R4300iOp::UnknownOpcode; - Jump_Opcode[55] = R4300iOp::LD; - Jump_Opcode[56] = R4300iOp::SC; - Jump_Opcode[57] = R4300iOp::SWC1; - Jump_Opcode[58] = R4300iOp::UnknownOpcode; - Jump_Opcode[59] = R4300iOp::UnknownOpcode; - Jump_Opcode[60] = R4300iOp::UnknownOpcode; - Jump_Opcode[61] = R4300iOp::SDC1; - Jump_Opcode[62] = R4300iOp::UnknownOpcode; - Jump_Opcode[63] = R4300iOp::SD; +{ + Jump_Opcode[ 0] = SPECIAL; + Jump_Opcode[ 1] = REGIMM; + Jump_Opcode[ 2] = R4300iOp::J; + Jump_Opcode[ 3] = JAL; + Jump_Opcode[ 4] = BEQ; + Jump_Opcode[ 5] = BNE; + Jump_Opcode[ 6] = BLEZ; + Jump_Opcode[ 7] = BGTZ; + Jump_Opcode[ 8] = ADDI; + Jump_Opcode[ 9] = ADDIU; + Jump_Opcode[10] = SLTI; + Jump_Opcode[11] = SLTIU; + Jump_Opcode[12] = ANDI; + Jump_Opcode[13] = ORI; + Jump_Opcode[14] = XORI; + Jump_Opcode[15] = LUI; + Jump_Opcode[16] = COP0; + Jump_Opcode[17] = COP1; + Jump_Opcode[18] = R4300iOp::UnknownOpcode; + Jump_Opcode[19] = R4300iOp::UnknownOpcode; + Jump_Opcode[20] = BEQL; + Jump_Opcode[21] = BNEL; + Jump_Opcode[22] = BLEZL; + Jump_Opcode[23] = BGTZL; + Jump_Opcode[24] = R4300iOp::UnknownOpcode; + Jump_Opcode[25] = R4300iOp::DADDIU; + Jump_Opcode[26] = R4300iOp::LDL; + Jump_Opcode[27] = R4300iOp::LDR; + Jump_Opcode[28] = R4300iOp::UnknownOpcode; + Jump_Opcode[29] = R4300iOp::UnknownOpcode; + Jump_Opcode[30] = R4300iOp::UnknownOpcode; + Jump_Opcode[31] = R4300iOp::UnknownOpcode; + Jump_Opcode[32] = LB; + Jump_Opcode[33] = LH; + Jump_Opcode[34] = LWL; + Jump_Opcode[35] = LW; + Jump_Opcode[36] = LBU; + Jump_Opcode[37] = LHU; + Jump_Opcode[38] = LWR; + Jump_Opcode[39] = LWU; + Jump_Opcode[40] = R4300iOp::SB; + Jump_Opcode[41] = R4300iOp::SH; + Jump_Opcode[42] = R4300iOp::SWL; + Jump_Opcode[43] = R4300iOp::SW; + Jump_Opcode[44] = R4300iOp::SDL; + Jump_Opcode[45] = R4300iOp::SDR; + Jump_Opcode[46] = R4300iOp::SWR; + Jump_Opcode[47] = R4300iOp::CACHE; + Jump_Opcode[48] = R4300iOp::LL; + Jump_Opcode[49] = R4300iOp::LWC1; + Jump_Opcode[50] = R4300iOp::UnknownOpcode; + Jump_Opcode[51] = R4300iOp::UnknownOpcode; + Jump_Opcode[52] = R4300iOp::UnknownOpcode; + Jump_Opcode[53] = R4300iOp::LDC1; + Jump_Opcode[54] = R4300iOp::UnknownOpcode; + Jump_Opcode[55] = R4300iOp::LD; + Jump_Opcode[56] = R4300iOp::SC; + Jump_Opcode[57] = R4300iOp::SWC1; + Jump_Opcode[58] = R4300iOp::UnknownOpcode; + Jump_Opcode[59] = R4300iOp::UnknownOpcode; + Jump_Opcode[60] = R4300iOp::UnknownOpcode; + Jump_Opcode[61] = R4300iOp::SDC1; + Jump_Opcode[62] = R4300iOp::UnknownOpcode; + Jump_Opcode[63] = R4300iOp::SD; - Jump_Special[ 0] = SPECIAL_SLL; - Jump_Special[ 1] = R4300iOp::UnknownOpcode; - Jump_Special[ 2] = SPECIAL_SRL; - Jump_Special[ 3] = SPECIAL_SRA; - Jump_Special[ 4] = SPECIAL_SLLV; - Jump_Special[ 5] = R4300iOp::UnknownOpcode; - Jump_Special[ 6] = SPECIAL_SRLV; - Jump_Special[ 7] = SPECIAL_SRAV; - Jump_Special[ 8] = SPECIAL_JR; - Jump_Special[ 9] = SPECIAL_JALR; - Jump_Special[10] = R4300iOp::UnknownOpcode; - Jump_Special[11] = R4300iOp::UnknownOpcode; - Jump_Special[12] = R4300iOp::SPECIAL_SYSCALL; - Jump_Special[13] = R4300iOp::UnknownOpcode; - Jump_Special[14] = R4300iOp::UnknownOpcode; - Jump_Special[15] = R4300iOp::SPECIAL_SYNC; - Jump_Special[16] = R4300iOp::SPECIAL_MFHI; - Jump_Special[17] = R4300iOp::SPECIAL_MTHI; - Jump_Special[18] = R4300iOp::SPECIAL_MFLO; - Jump_Special[19] = R4300iOp::SPECIAL_MTLO; - Jump_Special[20] = R4300iOp::SPECIAL_DSLLV; - Jump_Special[21] = R4300iOp::UnknownOpcode; - Jump_Special[22] = R4300iOp::SPECIAL_DSRLV; - Jump_Special[23] = R4300iOp::SPECIAL_DSRAV; - Jump_Special[24] = R4300iOp::SPECIAL_MULT; - Jump_Special[25] = R4300iOp::SPECIAL_MULTU; - Jump_Special[26] = R4300iOp::SPECIAL_DIV; - Jump_Special[27] = R4300iOp::SPECIAL_DIVU; - Jump_Special[28] = R4300iOp::SPECIAL_DMULT; - Jump_Special[29] = R4300iOp::SPECIAL_DMULTU; - Jump_Special[30] = R4300iOp::SPECIAL_DDIV; - Jump_Special[31] = R4300iOp::SPECIAL_DDIVU; - Jump_Special[32] = SPECIAL_ADD; - Jump_Special[33] = SPECIAL_ADDU; - Jump_Special[34] = SPECIAL_SUB; - Jump_Special[35] = SPECIAL_SUBU; - Jump_Special[36] = SPECIAL_AND; - Jump_Special[37] = SPECIAL_OR; - Jump_Special[38] = SPECIAL_XOR; - Jump_Special[39] = SPECIAL_NOR; - Jump_Special[40] = R4300iOp::UnknownOpcode; - Jump_Special[41] = R4300iOp::UnknownOpcode; - Jump_Special[42] = SPECIAL_SLT; - Jump_Special[43] = SPECIAL_SLTU; - Jump_Special[44] = R4300iOp::SPECIAL_DADD; - Jump_Special[45] = R4300iOp::SPECIAL_DADDU; - Jump_Special[46] = R4300iOp::SPECIAL_DSUB; - Jump_Special[47] = R4300iOp::SPECIAL_DSUBU; - Jump_Special[48] = R4300iOp::UnknownOpcode; - Jump_Special[49] = R4300iOp::UnknownOpcode; - Jump_Special[50] = R4300iOp::UnknownOpcode; - Jump_Special[51] = R4300iOp::UnknownOpcode; - Jump_Special[52] = R4300iOp::SPECIAL_TEQ; - Jump_Special[53] = R4300iOp::UnknownOpcode; - Jump_Special[54] = R4300iOp::UnknownOpcode; - Jump_Special[55] = R4300iOp::UnknownOpcode; - Jump_Special[56] = R4300iOp::SPECIAL_DSLL; - Jump_Special[57] = R4300iOp::UnknownOpcode; - Jump_Special[58] = R4300iOp::SPECIAL_DSRL; - Jump_Special[59] = R4300iOp::SPECIAL_DSRA; - Jump_Special[60] = R4300iOp::SPECIAL_DSLL32; - Jump_Special[61] = R4300iOp::UnknownOpcode; - Jump_Special[62] = R4300iOp::SPECIAL_DSRL32; - Jump_Special[63] = R4300iOp::SPECIAL_DSRA32; + Jump_Special[ 0] = SPECIAL_SLL; + Jump_Special[ 1] = R4300iOp::UnknownOpcode; + Jump_Special[ 2] = SPECIAL_SRL; + Jump_Special[ 3] = SPECIAL_SRA; + Jump_Special[ 4] = SPECIAL_SLLV; + Jump_Special[ 5] = R4300iOp::UnknownOpcode; + Jump_Special[ 6] = SPECIAL_SRLV; + Jump_Special[ 7] = SPECIAL_SRAV; + Jump_Special[ 8] = SPECIAL_JR; + Jump_Special[ 9] = SPECIAL_JALR; + Jump_Special[10] = R4300iOp::UnknownOpcode; + Jump_Special[11] = R4300iOp::UnknownOpcode; + Jump_Special[12] = R4300iOp::SPECIAL_SYSCALL; + Jump_Special[13] = R4300iOp::UnknownOpcode; + Jump_Special[14] = R4300iOp::UnknownOpcode; + Jump_Special[15] = R4300iOp::SPECIAL_SYNC; + Jump_Special[16] = R4300iOp::SPECIAL_MFHI; + Jump_Special[17] = R4300iOp::SPECIAL_MTHI; + Jump_Special[18] = R4300iOp::SPECIAL_MFLO; + Jump_Special[19] = R4300iOp::SPECIAL_MTLO; + Jump_Special[20] = R4300iOp::SPECIAL_DSLLV; + Jump_Special[21] = R4300iOp::UnknownOpcode; + Jump_Special[22] = R4300iOp::SPECIAL_DSRLV; + Jump_Special[23] = R4300iOp::SPECIAL_DSRAV; + Jump_Special[24] = R4300iOp::SPECIAL_MULT; + Jump_Special[25] = R4300iOp::SPECIAL_MULTU; + Jump_Special[26] = R4300iOp::SPECIAL_DIV; + Jump_Special[27] = R4300iOp::SPECIAL_DIVU; + Jump_Special[28] = R4300iOp::SPECIAL_DMULT; + Jump_Special[29] = R4300iOp::SPECIAL_DMULTU; + Jump_Special[30] = R4300iOp::SPECIAL_DDIV; + Jump_Special[31] = R4300iOp::SPECIAL_DDIVU; + Jump_Special[32] = SPECIAL_ADD; + Jump_Special[33] = SPECIAL_ADDU; + Jump_Special[34] = SPECIAL_SUB; + Jump_Special[35] = SPECIAL_SUBU; + Jump_Special[36] = SPECIAL_AND; + Jump_Special[37] = SPECIAL_OR; + Jump_Special[38] = SPECIAL_XOR; + Jump_Special[39] = SPECIAL_NOR; + Jump_Special[40] = R4300iOp::UnknownOpcode; + Jump_Special[41] = R4300iOp::UnknownOpcode; + Jump_Special[42] = SPECIAL_SLT; + Jump_Special[43] = SPECIAL_SLTU; + Jump_Special[44] = R4300iOp::SPECIAL_DADD; + Jump_Special[45] = R4300iOp::SPECIAL_DADDU; + Jump_Special[46] = R4300iOp::SPECIAL_DSUB; + Jump_Special[47] = R4300iOp::SPECIAL_DSUBU; + Jump_Special[48] = R4300iOp::UnknownOpcode; + Jump_Special[49] = R4300iOp::UnknownOpcode; + Jump_Special[50] = R4300iOp::UnknownOpcode; + Jump_Special[51] = R4300iOp::UnknownOpcode; + Jump_Special[52] = R4300iOp::SPECIAL_TEQ; + Jump_Special[53] = R4300iOp::UnknownOpcode; + Jump_Special[54] = R4300iOp::UnknownOpcode; + Jump_Special[55] = R4300iOp::UnknownOpcode; + Jump_Special[56] = R4300iOp::SPECIAL_DSLL; + Jump_Special[57] = R4300iOp::UnknownOpcode; + Jump_Special[58] = R4300iOp::SPECIAL_DSRL; + Jump_Special[59] = R4300iOp::SPECIAL_DSRA; + Jump_Special[60] = R4300iOp::SPECIAL_DSLL32; + Jump_Special[61] = R4300iOp::UnknownOpcode; + Jump_Special[62] = R4300iOp::SPECIAL_DSRL32; + Jump_Special[63] = R4300iOp::SPECIAL_DSRA32; - Jump_Regimm[ 0] = REGIMM_BLTZ; - Jump_Regimm[ 1] = REGIMM_BGEZ; - Jump_Regimm[ 2] = REGIMM_BLTZL; - Jump_Regimm[ 3] = REGIMM_BGEZL; - Jump_Regimm[ 4] = R4300iOp::UnknownOpcode; - Jump_Regimm[ 5] = R4300iOp::UnknownOpcode; - Jump_Regimm[ 6] = R4300iOp::UnknownOpcode; - Jump_Regimm[ 7] = R4300iOp::UnknownOpcode; - Jump_Regimm[ 8] = R4300iOp::UnknownOpcode; - Jump_Regimm[ 9] = R4300iOp::UnknownOpcode; - Jump_Regimm[10] = R4300iOp::UnknownOpcode; - Jump_Regimm[11] = R4300iOp::UnknownOpcode; - Jump_Regimm[12] = R4300iOp::UnknownOpcode; - Jump_Regimm[13] = R4300iOp::UnknownOpcode; - Jump_Regimm[14] = R4300iOp::UnknownOpcode; - Jump_Regimm[15] = R4300iOp::UnknownOpcode; - Jump_Regimm[16] = REGIMM_BLTZAL; - Jump_Regimm[17] = REGIMM_BGEZAL; - Jump_Regimm[18] = R4300iOp::UnknownOpcode; - Jump_Regimm[19] = R4300iOp::UnknownOpcode; - Jump_Regimm[20] = R4300iOp::UnknownOpcode; - Jump_Regimm[21] = R4300iOp::UnknownOpcode; - Jump_Regimm[22] = R4300iOp::UnknownOpcode; - Jump_Regimm[23] = R4300iOp::UnknownOpcode; - Jump_Regimm[24] = R4300iOp::UnknownOpcode; - Jump_Regimm[25] = R4300iOp::UnknownOpcode; - Jump_Regimm[26] = R4300iOp::UnknownOpcode; - Jump_Regimm[27] = R4300iOp::UnknownOpcode; - Jump_Regimm[28] = R4300iOp::UnknownOpcode; - Jump_Regimm[29] = R4300iOp::UnknownOpcode; - Jump_Regimm[30] = R4300iOp::UnknownOpcode; - Jump_Regimm[31] = R4300iOp::UnknownOpcode; - - Jump_CoP0[ 0] = COP0_MF; - Jump_CoP0[ 1] = R4300iOp::UnknownOpcode; - Jump_CoP0[ 2] = R4300iOp::UnknownOpcode; - Jump_CoP0[ 3] = R4300iOp::UnknownOpcode; - Jump_CoP0[ 4] = COP0_MT; - Jump_CoP0[ 5] = R4300iOp::UnknownOpcode; - Jump_CoP0[ 6] = R4300iOp::UnknownOpcode; - Jump_CoP0[ 7] = R4300iOp::UnknownOpcode; - Jump_CoP0[ 8] = R4300iOp::UnknownOpcode; - Jump_CoP0[ 9] = R4300iOp::UnknownOpcode; - Jump_CoP0[10] = R4300iOp::UnknownOpcode; - Jump_CoP0[11] = R4300iOp::UnknownOpcode; - Jump_CoP0[12] = R4300iOp::UnknownOpcode; - Jump_CoP0[13] = R4300iOp::UnknownOpcode; - Jump_CoP0[14] = R4300iOp::UnknownOpcode; - Jump_CoP0[15] = R4300iOp::UnknownOpcode; - Jump_CoP0[16] = R4300iOp::COP0_CO; - Jump_CoP0[17] = R4300iOp::COP0_CO; - Jump_CoP0[18] = R4300iOp::COP0_CO; - Jump_CoP0[19] = R4300iOp::COP0_CO; - Jump_CoP0[20] = R4300iOp::COP0_CO; - Jump_CoP0[21] = R4300iOp::COP0_CO; - Jump_CoP0[22] = R4300iOp::COP0_CO; - Jump_CoP0[23] = R4300iOp::COP0_CO; - Jump_CoP0[24] = R4300iOp::COP0_CO; - Jump_CoP0[25] = R4300iOp::COP0_CO; - Jump_CoP0[26] = R4300iOp::COP0_CO; - Jump_CoP0[27] = R4300iOp::COP0_CO; - Jump_CoP0[28] = R4300iOp::COP0_CO; - Jump_CoP0[29] = R4300iOp::COP0_CO; - Jump_CoP0[30] = R4300iOp::COP0_CO; - Jump_CoP0[31] = R4300iOp::COP0_CO; + Jump_Regimm[ 0] = REGIMM_BLTZ; + Jump_Regimm[ 1] = REGIMM_BGEZ; + Jump_Regimm[ 2] = REGIMM_BLTZL; + Jump_Regimm[ 3] = REGIMM_BGEZL; + Jump_Regimm[ 4] = R4300iOp::UnknownOpcode; + Jump_Regimm[ 5] = R4300iOp::UnknownOpcode; + Jump_Regimm[ 6] = R4300iOp::UnknownOpcode; + Jump_Regimm[ 7] = R4300iOp::UnknownOpcode; + Jump_Regimm[ 8] = R4300iOp::UnknownOpcode; + Jump_Regimm[ 9] = R4300iOp::UnknownOpcode; + Jump_Regimm[10] = R4300iOp::UnknownOpcode; + Jump_Regimm[11] = R4300iOp::UnknownOpcode; + Jump_Regimm[12] = R4300iOp::UnknownOpcode; + Jump_Regimm[13] = R4300iOp::UnknownOpcode; + Jump_Regimm[14] = R4300iOp::UnknownOpcode; + Jump_Regimm[15] = R4300iOp::UnknownOpcode; + Jump_Regimm[16] = REGIMM_BLTZAL; + Jump_Regimm[17] = REGIMM_BGEZAL; + Jump_Regimm[18] = R4300iOp::UnknownOpcode; + Jump_Regimm[19] = R4300iOp::UnknownOpcode; + Jump_Regimm[20] = R4300iOp::UnknownOpcode; + Jump_Regimm[21] = R4300iOp::UnknownOpcode; + Jump_Regimm[22] = R4300iOp::UnknownOpcode; + Jump_Regimm[23] = R4300iOp::UnknownOpcode; + Jump_Regimm[24] = R4300iOp::UnknownOpcode; + Jump_Regimm[25] = R4300iOp::UnknownOpcode; + Jump_Regimm[26] = R4300iOp::UnknownOpcode; + Jump_Regimm[27] = R4300iOp::UnknownOpcode; + Jump_Regimm[28] = R4300iOp::UnknownOpcode; + Jump_Regimm[29] = R4300iOp::UnknownOpcode; + Jump_Regimm[30] = R4300iOp::UnknownOpcode; + Jump_Regimm[31] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[ 0] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[ 1] = R4300iOp::COP0_CO_TLBR; - Jump_CoP0_Function[ 2] = R4300iOp::COP0_CO_TLBWI; - Jump_CoP0_Function[ 3] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[ 4] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[ 5] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[ 6] = R4300iOp::COP0_CO_TLBWR; - Jump_CoP0_Function[ 7] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[ 8] = R4300iOp::COP0_CO_TLBP; - Jump_CoP0_Function[ 9] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[10] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[11] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[12] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[13] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[14] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[15] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[16] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[17] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[18] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[19] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[20] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[21] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[22] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[23] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[24] = R4300iOp::COP0_CO_ERET; - Jump_CoP0_Function[25] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[26] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[27] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[28] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[29] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[30] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[31] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[32] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[33] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[34] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[35] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[36] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[37] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[38] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[39] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[40] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[41] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[42] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[43] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[44] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[45] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[46] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[47] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[48] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[49] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[50] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[51] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[52] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[53] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[54] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[55] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[56] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[57] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[58] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[59] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[60] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[61] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[62] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[63] = R4300iOp::UnknownOpcode; - - Jump_CoP1[ 0] = COP1_MF; - Jump_CoP1[ 1] = R4300iOp::COP1_DMF; - Jump_CoP1[ 2] = COP1_CF; - Jump_CoP1[ 3] = R4300iOp::UnknownOpcode; - Jump_CoP1[ 4] = R4300iOp::COP1_MT; - Jump_CoP1[ 5] = COP1_DMT; - Jump_CoP1[ 6] = R4300iOp::COP1_CT; - Jump_CoP1[ 7] = R4300iOp::UnknownOpcode; - Jump_CoP1[ 8] = R4300iOp::COP1_BC; - Jump_CoP1[ 9] = R4300iOp::UnknownOpcode; - Jump_CoP1[10] = R4300iOp::UnknownOpcode; - Jump_CoP1[11] = R4300iOp::UnknownOpcode; - Jump_CoP1[12] = R4300iOp::UnknownOpcode; - Jump_CoP1[13] = R4300iOp::UnknownOpcode; - Jump_CoP1[14] = R4300iOp::UnknownOpcode; - Jump_CoP1[15] = R4300iOp::UnknownOpcode; - Jump_CoP1[16] = R4300iOp::COP1_S; - Jump_CoP1[17] = R4300iOp::COP1_D; - Jump_CoP1[18] = R4300iOp::UnknownOpcode; - Jump_CoP1[19] = R4300iOp::UnknownOpcode; - Jump_CoP1[20] = R4300iOp::COP1_W; - Jump_CoP1[21] = R4300iOp::COP1_L; - Jump_CoP1[22] = R4300iOp::UnknownOpcode; - Jump_CoP1[23] = R4300iOp::UnknownOpcode; - Jump_CoP1[24] = R4300iOp::UnknownOpcode; - Jump_CoP1[25] = R4300iOp::UnknownOpcode; - Jump_CoP1[26] = R4300iOp::UnknownOpcode; - Jump_CoP1[27] = R4300iOp::UnknownOpcode; - Jump_CoP1[28] = R4300iOp::UnknownOpcode; - Jump_CoP1[29] = R4300iOp::UnknownOpcode; - Jump_CoP1[30] = R4300iOp::UnknownOpcode; - Jump_CoP1[31] = R4300iOp::UnknownOpcode; + Jump_CoP0[ 0] = COP0_MF; + Jump_CoP0[ 1] = R4300iOp::UnknownOpcode; + Jump_CoP0[ 2] = R4300iOp::UnknownOpcode; + Jump_CoP0[ 3] = R4300iOp::UnknownOpcode; + Jump_CoP0[ 4] = COP0_MT; + Jump_CoP0[ 5] = R4300iOp::UnknownOpcode; + Jump_CoP0[ 6] = R4300iOp::UnknownOpcode; + Jump_CoP0[ 7] = R4300iOp::UnknownOpcode; + Jump_CoP0[ 8] = R4300iOp::UnknownOpcode; + Jump_CoP0[ 9] = R4300iOp::UnknownOpcode; + Jump_CoP0[10] = R4300iOp::UnknownOpcode; + Jump_CoP0[11] = R4300iOp::UnknownOpcode; + Jump_CoP0[12] = R4300iOp::UnknownOpcode; + Jump_CoP0[13] = R4300iOp::UnknownOpcode; + Jump_CoP0[14] = R4300iOp::UnknownOpcode; + Jump_CoP0[15] = R4300iOp::UnknownOpcode; + Jump_CoP0[16] = R4300iOp::COP0_CO; + Jump_CoP0[17] = R4300iOp::COP0_CO; + Jump_CoP0[18] = R4300iOp::COP0_CO; + Jump_CoP0[19] = R4300iOp::COP0_CO; + Jump_CoP0[20] = R4300iOp::COP0_CO; + Jump_CoP0[21] = R4300iOp::COP0_CO; + Jump_CoP0[22] = R4300iOp::COP0_CO; + Jump_CoP0[23] = R4300iOp::COP0_CO; + Jump_CoP0[24] = R4300iOp::COP0_CO; + Jump_CoP0[25] = R4300iOp::COP0_CO; + Jump_CoP0[26] = R4300iOp::COP0_CO; + Jump_CoP0[27] = R4300iOp::COP0_CO; + Jump_CoP0[28] = R4300iOp::COP0_CO; + Jump_CoP0[29] = R4300iOp::COP0_CO; + Jump_CoP0[30] = R4300iOp::COP0_CO; + Jump_CoP0[31] = R4300iOp::COP0_CO; - Jump_CoP1_BC[ 0] = R4300iOp::COP1_BCF; - Jump_CoP1_BC[ 1] = R4300iOp::COP1_BCT; - Jump_CoP1_BC[ 2] = R4300iOp::COP1_BCFL; - Jump_CoP1_BC[ 3] = R4300iOp::COP1_BCTL; - Jump_CoP1_BC[ 4] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[ 5] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[ 6] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[ 7] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[ 8] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[ 9] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[10] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[11] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[12] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[13] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[14] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[15] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[16] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[17] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[18] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[19] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[20] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[21] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[22] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[23] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[24] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[25] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[26] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[27] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[28] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[29] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[30] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[31] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[ 0] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[ 1] = R4300iOp::COP0_CO_TLBR; + Jump_CoP0_Function[ 2] = R4300iOp::COP0_CO_TLBWI; + Jump_CoP0_Function[ 3] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[ 4] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[ 5] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[ 6] = R4300iOp::COP0_CO_TLBWR; + Jump_CoP0_Function[ 7] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[ 8] = R4300iOp::COP0_CO_TLBP; + Jump_CoP0_Function[ 9] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[10] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[11] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[12] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[13] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[14] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[15] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[16] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[17] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[18] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[19] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[20] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[21] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[22] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[23] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[24] = R4300iOp::COP0_CO_ERET; + Jump_CoP0_Function[25] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[26] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[27] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[28] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[29] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[30] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[31] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[32] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[33] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[34] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[35] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[36] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[37] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[38] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[39] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[40] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[41] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[42] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[43] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[44] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[45] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[46] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[47] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[48] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[49] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[50] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[51] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[52] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[53] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[54] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[55] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[56] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[57] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[58] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[59] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[60] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[61] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[62] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[63] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[ 0] = R4300iOp::COP1_S_ADD; - Jump_CoP1_S[ 1] = R4300iOp::COP1_S_SUB; - Jump_CoP1_S[ 2] = R4300iOp::COP1_S_MUL; - Jump_CoP1_S[ 3] = R4300iOp::COP1_S_DIV; - Jump_CoP1_S[ 4] = R4300iOp::COP1_S_SQRT; - Jump_CoP1_S[ 5] = R4300iOp::COP1_S_ABS; - Jump_CoP1_S[ 6] = R4300iOp::COP1_S_MOV; - Jump_CoP1_S[ 7] = R4300iOp::COP1_S_NEG; - Jump_CoP1_S[ 8] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[ 9] = R4300iOp::COP1_S_TRUNC_L; - Jump_CoP1_S[10] = R4300iOp::COP1_S_CEIL_L; //added by Witten - Jump_CoP1_S[11] = R4300iOp::COP1_S_FLOOR_L; //added by Witten - Jump_CoP1_S[12] = R4300iOp::COP1_S_ROUND_W; - Jump_CoP1_S[13] = R4300iOp::COP1_S_TRUNC_W; - Jump_CoP1_S[14] = R4300iOp::COP1_S_CEIL_W; //added by Witten - Jump_CoP1_S[15] = R4300iOp::COP1_S_FLOOR_W; - Jump_CoP1_S[16] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[17] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[18] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[19] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[20] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[21] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[22] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[23] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[24] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[25] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[26] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[27] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[28] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[29] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[30] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[31] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[32] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[33] = R4300iOp::COP1_S_CVT_D; - Jump_CoP1_S[34] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[35] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[36] = R4300iOp::COP1_S_CVT_W; - Jump_CoP1_S[37] = R4300iOp::COP1_S_CVT_L; - Jump_CoP1_S[38] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[39] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[40] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[41] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[42] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[43] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[44] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[45] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[46] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[47] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[48] = R4300iOp::COP1_S_CMP; - Jump_CoP1_S[49] = R4300iOp::COP1_S_CMP; - Jump_CoP1_S[50] = R4300iOp::COP1_S_CMP; - Jump_CoP1_S[51] = R4300iOp::COP1_S_CMP; - Jump_CoP1_S[52] = R4300iOp::COP1_S_CMP; - Jump_CoP1_S[53] = R4300iOp::COP1_S_CMP; - Jump_CoP1_S[54] = R4300iOp::COP1_S_CMP; - Jump_CoP1_S[55] = R4300iOp::COP1_S_CMP; - Jump_CoP1_S[56] = R4300iOp::COP1_S_CMP; - Jump_CoP1_S[57] = R4300iOp::COP1_S_CMP; - Jump_CoP1_S[58] = R4300iOp::COP1_S_CMP; - Jump_CoP1_S[59] = R4300iOp::COP1_S_CMP; - Jump_CoP1_S[60] = R4300iOp::COP1_S_CMP; - Jump_CoP1_S[61] = R4300iOp::COP1_S_CMP; - Jump_CoP1_S[62] = R4300iOp::COP1_S_CMP; - Jump_CoP1_S[63] = R4300iOp::COP1_S_CMP; + Jump_CoP1[ 0] = COP1_MF; + Jump_CoP1[ 1] = R4300iOp::COP1_DMF; + Jump_CoP1[ 2] = COP1_CF; + Jump_CoP1[ 3] = R4300iOp::UnknownOpcode; + Jump_CoP1[ 4] = R4300iOp::COP1_MT; + Jump_CoP1[ 5] = COP1_DMT; + Jump_CoP1[ 6] = R4300iOp::COP1_CT; + Jump_CoP1[ 7] = R4300iOp::UnknownOpcode; + Jump_CoP1[ 8] = R4300iOp::COP1_BC; + Jump_CoP1[ 9] = R4300iOp::UnknownOpcode; + Jump_CoP1[10] = R4300iOp::UnknownOpcode; + Jump_CoP1[11] = R4300iOp::UnknownOpcode; + Jump_CoP1[12] = R4300iOp::UnknownOpcode; + Jump_CoP1[13] = R4300iOp::UnknownOpcode; + Jump_CoP1[14] = R4300iOp::UnknownOpcode; + Jump_CoP1[15] = R4300iOp::UnknownOpcode; + Jump_CoP1[16] = R4300iOp::COP1_S; + Jump_CoP1[17] = R4300iOp::COP1_D; + Jump_CoP1[18] = R4300iOp::UnknownOpcode; + Jump_CoP1[19] = R4300iOp::UnknownOpcode; + Jump_CoP1[20] = R4300iOp::COP1_W; + Jump_CoP1[21] = R4300iOp::COP1_L; + Jump_CoP1[22] = R4300iOp::UnknownOpcode; + Jump_CoP1[23] = R4300iOp::UnknownOpcode; + Jump_CoP1[24] = R4300iOp::UnknownOpcode; + Jump_CoP1[25] = R4300iOp::UnknownOpcode; + Jump_CoP1[26] = R4300iOp::UnknownOpcode; + Jump_CoP1[27] = R4300iOp::UnknownOpcode; + Jump_CoP1[28] = R4300iOp::UnknownOpcode; + Jump_CoP1[29] = R4300iOp::UnknownOpcode; + Jump_CoP1[30] = R4300iOp::UnknownOpcode; + Jump_CoP1[31] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[ 0] = R4300iOp::COP1_D_ADD; - Jump_CoP1_D[ 1] = R4300iOp::COP1_D_SUB; - Jump_CoP1_D[ 2] = R4300iOp::COP1_D_MUL; - Jump_CoP1_D[ 3] = R4300iOp::COP1_D_DIV; - Jump_CoP1_D[ 4] = R4300iOp::COP1_D_SQRT; - Jump_CoP1_D[ 5] = R4300iOp::COP1_D_ABS; - Jump_CoP1_D[ 6] = R4300iOp::COP1_D_MOV; - Jump_CoP1_D[ 7] = R4300iOp::COP1_D_NEG; - Jump_CoP1_D[ 8] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[ 9] = R4300iOp::COP1_D_TRUNC_L; //added by Witten - Jump_CoP1_D[10] = R4300iOp::COP1_D_CEIL_L; //added by Witten - Jump_CoP1_D[11] = R4300iOp::COP1_D_FLOOR_L; //added by Witten - Jump_CoP1_D[12] = R4300iOp::COP1_D_ROUND_W; - Jump_CoP1_D[13] = R4300iOp::COP1_D_TRUNC_W; - Jump_CoP1_D[14] = R4300iOp::COP1_D_CEIL_W; //added by Witten - Jump_CoP1_D[15] = R4300iOp::COP1_D_FLOOR_W; //added by Witten - Jump_CoP1_D[16] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[17] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[18] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[19] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[20] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[21] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[22] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[23] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[24] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[25] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[26] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[27] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[28] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[29] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[30] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[31] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[32] = R4300iOp::COP1_D_CVT_S; - Jump_CoP1_D[33] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[34] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[35] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[36] = R4300iOp::COP1_D_CVT_W; - Jump_CoP1_D[37] = R4300iOp::COP1_D_CVT_L; - Jump_CoP1_D[38] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[39] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[40] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[41] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[42] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[43] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[44] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[45] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[46] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[47] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[48] = R4300iOp::COP1_D_CMP; - Jump_CoP1_D[49] = R4300iOp::COP1_D_CMP; - Jump_CoP1_D[50] = R4300iOp::COP1_D_CMP; - Jump_CoP1_D[51] = R4300iOp::COP1_D_CMP; - Jump_CoP1_D[52] = R4300iOp::COP1_D_CMP; - Jump_CoP1_D[53] = R4300iOp::COP1_D_CMP; - Jump_CoP1_D[54] = R4300iOp::COP1_D_CMP; - Jump_CoP1_D[55] = R4300iOp::COP1_D_CMP; - Jump_CoP1_D[56] = R4300iOp::COP1_D_CMP; - Jump_CoP1_D[57] = R4300iOp::COP1_D_CMP; - Jump_CoP1_D[58] = R4300iOp::COP1_D_CMP; - Jump_CoP1_D[59] = R4300iOp::COP1_D_CMP; - Jump_CoP1_D[60] = R4300iOp::COP1_D_CMP; - Jump_CoP1_D[61] = R4300iOp::COP1_D_CMP; - Jump_CoP1_D[62] = R4300iOp::COP1_D_CMP; - Jump_CoP1_D[63] = R4300iOp::COP1_D_CMP; + Jump_CoP1_BC[ 0] = R4300iOp::COP1_BCF; + Jump_CoP1_BC[ 1] = R4300iOp::COP1_BCT; + Jump_CoP1_BC[ 2] = R4300iOp::COP1_BCFL; + Jump_CoP1_BC[ 3] = R4300iOp::COP1_BCTL; + Jump_CoP1_BC[ 4] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[ 5] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[ 6] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[ 7] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[ 8] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[ 9] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[10] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[11] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[12] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[13] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[14] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[15] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[16] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[17] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[18] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[19] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[20] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[21] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[22] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[23] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[24] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[25] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[26] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[27] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[28] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[29] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[30] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[31] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[ 0] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[ 1] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[ 2] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[ 3] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[ 4] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[ 5] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[ 6] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[ 7] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[ 8] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[ 9] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[10] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[11] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[12] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[13] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[14] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[15] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[16] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[17] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[18] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[19] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[20] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[21] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[22] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[23] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[24] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[25] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[26] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[27] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[28] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[29] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[30] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[31] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[32] = R4300iOp::COP1_W_CVT_S; - Jump_CoP1_W[33] = R4300iOp::COP1_W_CVT_D; - Jump_CoP1_W[34] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[35] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[36] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[37] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[38] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[39] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[40] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[41] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[42] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[43] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[44] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[45] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[46] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[47] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[48] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[49] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[50] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[51] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[52] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[53] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[54] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[55] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[56] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[57] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[58] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[59] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[60] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[61] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[62] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[63] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[ 0] = R4300iOp::COP1_S_ADD; + Jump_CoP1_S[ 1] = R4300iOp::COP1_S_SUB; + Jump_CoP1_S[ 2] = R4300iOp::COP1_S_MUL; + Jump_CoP1_S[ 3] = R4300iOp::COP1_S_DIV; + Jump_CoP1_S[ 4] = R4300iOp::COP1_S_SQRT; + Jump_CoP1_S[ 5] = R4300iOp::COP1_S_ABS; + Jump_CoP1_S[ 6] = R4300iOp::COP1_S_MOV; + Jump_CoP1_S[ 7] = R4300iOp::COP1_S_NEG; + Jump_CoP1_S[ 8] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[ 9] = R4300iOp::COP1_S_TRUNC_L; + Jump_CoP1_S[10] = R4300iOp::COP1_S_CEIL_L; //added by Witten + Jump_CoP1_S[11] = R4300iOp::COP1_S_FLOOR_L; //added by Witten + Jump_CoP1_S[12] = R4300iOp::COP1_S_ROUND_W; + Jump_CoP1_S[13] = R4300iOp::COP1_S_TRUNC_W; + Jump_CoP1_S[14] = R4300iOp::COP1_S_CEIL_W; //added by Witten + Jump_CoP1_S[15] = R4300iOp::COP1_S_FLOOR_W; + Jump_CoP1_S[16] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[17] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[18] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[19] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[20] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[21] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[22] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[23] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[24] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[25] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[26] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[27] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[28] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[29] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[30] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[31] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[32] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[33] = R4300iOp::COP1_S_CVT_D; + Jump_CoP1_S[34] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[35] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[36] = R4300iOp::COP1_S_CVT_W; + Jump_CoP1_S[37] = R4300iOp::COP1_S_CVT_L; + Jump_CoP1_S[38] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[39] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[40] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[41] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[42] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[43] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[44] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[45] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[46] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[47] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[48] = R4300iOp::COP1_S_CMP; + Jump_CoP1_S[49] = R4300iOp::COP1_S_CMP; + Jump_CoP1_S[50] = R4300iOp::COP1_S_CMP; + Jump_CoP1_S[51] = R4300iOp::COP1_S_CMP; + Jump_CoP1_S[52] = R4300iOp::COP1_S_CMP; + Jump_CoP1_S[53] = R4300iOp::COP1_S_CMP; + Jump_CoP1_S[54] = R4300iOp::COP1_S_CMP; + Jump_CoP1_S[55] = R4300iOp::COP1_S_CMP; + Jump_CoP1_S[56] = R4300iOp::COP1_S_CMP; + Jump_CoP1_S[57] = R4300iOp::COP1_S_CMP; + Jump_CoP1_S[58] = R4300iOp::COP1_S_CMP; + Jump_CoP1_S[59] = R4300iOp::COP1_S_CMP; + Jump_CoP1_S[60] = R4300iOp::COP1_S_CMP; + Jump_CoP1_S[61] = R4300iOp::COP1_S_CMP; + Jump_CoP1_S[62] = R4300iOp::COP1_S_CMP; + Jump_CoP1_S[63] = R4300iOp::COP1_S_CMP; - Jump_CoP1_L[ 0] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[ 1] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[ 2] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[ 3] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[ 4] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[ 5] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[ 6] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[ 7] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[ 8] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[ 9] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[10] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[11] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[12] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[13] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[14] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[15] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[16] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[17] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[18] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[19] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[20] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[21] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[22] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[23] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[24] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[25] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[26] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[27] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[28] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[29] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[30] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[31] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[32] = R4300iOp::COP1_L_CVT_S; - Jump_CoP1_L[33] = R4300iOp::COP1_L_CVT_D; - Jump_CoP1_L[34] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[35] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[36] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[37] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[38] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[39] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[40] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[41] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[42] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[43] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[44] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[45] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[46] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[47] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[48] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[49] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[50] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[51] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[52] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[53] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[54] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[55] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[56] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[57] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[58] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[59] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[60] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[61] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[62] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[63] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[ 0] = R4300iOp::COP1_D_ADD; + Jump_CoP1_D[ 1] = R4300iOp::COP1_D_SUB; + Jump_CoP1_D[ 2] = R4300iOp::COP1_D_MUL; + Jump_CoP1_D[ 3] = R4300iOp::COP1_D_DIV; + Jump_CoP1_D[ 4] = R4300iOp::COP1_D_SQRT; + Jump_CoP1_D[ 5] = R4300iOp::COP1_D_ABS; + Jump_CoP1_D[ 6] = R4300iOp::COP1_D_MOV; + Jump_CoP1_D[ 7] = R4300iOp::COP1_D_NEG; + Jump_CoP1_D[ 8] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[ 9] = R4300iOp::COP1_D_TRUNC_L; //added by Witten + Jump_CoP1_D[10] = R4300iOp::COP1_D_CEIL_L; //added by Witten + Jump_CoP1_D[11] = R4300iOp::COP1_D_FLOOR_L; //added by Witten + Jump_CoP1_D[12] = R4300iOp::COP1_D_ROUND_W; + Jump_CoP1_D[13] = R4300iOp::COP1_D_TRUNC_W; + Jump_CoP1_D[14] = R4300iOp::COP1_D_CEIL_W; //added by Witten + Jump_CoP1_D[15] = R4300iOp::COP1_D_FLOOR_W; //added by Witten + Jump_CoP1_D[16] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[17] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[18] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[19] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[20] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[21] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[22] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[23] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[24] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[25] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[26] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[27] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[28] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[29] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[30] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[31] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[32] = R4300iOp::COP1_D_CVT_S; + Jump_CoP1_D[33] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[34] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[35] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[36] = R4300iOp::COP1_D_CVT_W; + Jump_CoP1_D[37] = R4300iOp::COP1_D_CVT_L; + Jump_CoP1_D[38] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[39] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[40] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[41] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[42] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[43] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[44] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[45] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[46] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[47] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[48] = R4300iOp::COP1_D_CMP; + Jump_CoP1_D[49] = R4300iOp::COP1_D_CMP; + Jump_CoP1_D[50] = R4300iOp::COP1_D_CMP; + Jump_CoP1_D[51] = R4300iOp::COP1_D_CMP; + Jump_CoP1_D[52] = R4300iOp::COP1_D_CMP; + Jump_CoP1_D[53] = R4300iOp::COP1_D_CMP; + Jump_CoP1_D[54] = R4300iOp::COP1_D_CMP; + Jump_CoP1_D[55] = R4300iOp::COP1_D_CMP; + Jump_CoP1_D[56] = R4300iOp::COP1_D_CMP; + Jump_CoP1_D[57] = R4300iOp::COP1_D_CMP; + Jump_CoP1_D[58] = R4300iOp::COP1_D_CMP; + Jump_CoP1_D[59] = R4300iOp::COP1_D_CMP; + Jump_CoP1_D[60] = R4300iOp::COP1_D_CMP; + Jump_CoP1_D[61] = R4300iOp::COP1_D_CMP; + Jump_CoP1_D[62] = R4300iOp::COP1_D_CMP; + Jump_CoP1_D[63] = R4300iOp::COP1_D_CMP; - return Jump_Opcode; + Jump_CoP1_W[ 0] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[ 1] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[ 2] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[ 3] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[ 4] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[ 5] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[ 6] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[ 7] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[ 8] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[ 9] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[10] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[11] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[12] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[13] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[14] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[15] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[16] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[17] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[18] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[19] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[20] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[21] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[22] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[23] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[24] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[25] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[26] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[27] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[28] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[29] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[30] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[31] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[32] = R4300iOp::COP1_W_CVT_S; + Jump_CoP1_W[33] = R4300iOp::COP1_W_CVT_D; + Jump_CoP1_W[34] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[35] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[36] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[37] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[38] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[39] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[40] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[41] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[42] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[43] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[44] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[45] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[46] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[47] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[48] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[49] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[50] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[51] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[52] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[53] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[54] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[55] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[56] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[57] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[58] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[59] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[60] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[61] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[62] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[63] = R4300iOp::UnknownOpcode; + + Jump_CoP1_L[ 0] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[ 1] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[ 2] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[ 3] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[ 4] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[ 5] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[ 6] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[ 7] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[ 8] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[ 9] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[10] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[11] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[12] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[13] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[14] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[15] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[16] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[17] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[18] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[19] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[20] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[21] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[22] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[23] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[24] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[25] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[26] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[27] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[28] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[29] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[30] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[31] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[32] = R4300iOp::COP1_L_CVT_S; + Jump_CoP1_L[33] = R4300iOp::COP1_L_CVT_D; + Jump_CoP1_L[34] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[35] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[36] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[37] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[38] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[39] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[40] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[41] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[42] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[43] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[44] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[45] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[46] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[47] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[48] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[49] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[50] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[51] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[52] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[53] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[54] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[55] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[56] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[57] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[58] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[59] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[60] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[61] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[62] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[63] = R4300iOp::UnknownOpcode; + + return Jump_Opcode; } - /************************* Opcode functions *************************/ void R4300iOp32::JAL() { - m_NextInstruction = DELAY_SLOT; - m_JumpToLocation = ((*_PROGRAM_COUNTER) & 0xF0000000) + (m_Opcode.target << 2); - _GPR[31].UW[0] = (*_PROGRAM_COUNTER) + 8; + m_NextInstruction = DELAY_SLOT; + m_JumpToLocation = ((*_PROGRAM_COUNTER) & 0xF0000000) + (m_Opcode.target << 2); + _GPR[31].UW[0] = (*_PROGRAM_COUNTER) + 8; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - m_NextInstruction = PERMLOOP_DO_DELAY; - } + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + m_NextInstruction = PERMLOOP_DO_DELAY; + } } void R4300iOp32::BEQ() { - m_NextInstruction = DELAY_SLOT; - if (_GPR[m_Opcode.rs].W[0] == _GPR[m_Opcode.rt].W[0]) - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) - { - m_NextInstruction = PERMLOOP_DO_DELAY; - } - } - } - else - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + m_NextInstruction = DELAY_SLOT; + if (_GPR[m_Opcode.rs].W[0] == _GPR[m_Opcode.rt].W[0]) + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) + { + m_NextInstruction = PERMLOOP_DO_DELAY; + } + } + } + else + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp32::BNE() { - m_NextInstruction = DELAY_SLOT; - if (_GPR[m_Opcode.rs].W[0] != _GPR[m_Opcode.rt].W[0]) - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) - { - m_NextInstruction = PERMLOOP_DO_DELAY; - } - } - } - else - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + m_NextInstruction = DELAY_SLOT; + if (_GPR[m_Opcode.rs].W[0] != _GPR[m_Opcode.rt].W[0]) + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) + { + m_NextInstruction = PERMLOOP_DO_DELAY; + } + } + } + else + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp32::BLEZ() { - m_NextInstruction = DELAY_SLOT; - if (_GPR[m_Opcode.rs].W[0] <= 0) - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) - { - m_NextInstruction = PERMLOOP_DO_DELAY; - } - } - } - else - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + m_NextInstruction = DELAY_SLOT; + if (_GPR[m_Opcode.rs].W[0] <= 0) + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) + { + m_NextInstruction = PERMLOOP_DO_DELAY; + } + } + } + else + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp32::BGTZ() { - m_NextInstruction = DELAY_SLOT; - if (_GPR[m_Opcode.rs].W[0] > 0) - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) - { - m_NextInstruction = PERMLOOP_DO_DELAY; - } - } - } - else - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + m_NextInstruction = DELAY_SLOT; + if (_GPR[m_Opcode.rs].W[0] > 0) + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) + { + m_NextInstruction = PERMLOOP_DO_DELAY; + } + } + } + else + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp32::ADDI() { #ifdef Interpreter_StackTest - if (m_Opcode.rs == 29 && m_Opcode.rt == 29) - { - StackValue += (short)m_Opcode.immediate; - } + if (m_Opcode.rs == 29 && m_Opcode.rt == 29) + { + StackValue += (int16_t)m_Opcode.immediate; + } #endif - _GPR[m_Opcode.rt].W[0] = (_GPR[m_Opcode.rs].W[0] + ((short)m_Opcode.immediate)); + _GPR[m_Opcode.rt].W[0] = (_GPR[m_Opcode.rs].W[0] + ((int16_t)m_Opcode.immediate)); #ifdef Interpreter_StackTest - if (m_Opcode.rt == 29 && m_Opcode.rs != 29) - { - StackValue = _GPR[m_Opcode.rt].W[0]; - } + if (m_Opcode.rt == 29 && m_Opcode.rs != 29) + { + StackValue = _GPR[m_Opcode.rt].W[0]; + } #endif } void R4300iOp32::ADDIU() { #ifdef Interpreter_StackTest - if (m_Opcode.rs == 29 && m_Opcode.rt == 29) - { - StackValue += (short)m_Opcode.immediate; - } + if (m_Opcode.rs == 29 && m_Opcode.rt == 29) + { + StackValue += (int16_t)m_Opcode.immediate; + } #endif - _GPR[m_Opcode.rt].W[0] = (_GPR[m_Opcode.rs].W[0] + ((short)m_Opcode.immediate)); + _GPR[m_Opcode.rt].W[0] = (_GPR[m_Opcode.rs].W[0] + ((int16_t)m_Opcode.immediate)); #ifdef Interpreter_StackTest - if (m_Opcode.rt == 29 && m_Opcode.rs != 29) - { - StackValue = _GPR[m_Opcode.rt].W[0]; - } + if (m_Opcode.rt == 29 && m_Opcode.rs != 29) + { + StackValue = _GPR[m_Opcode.rt].W[0]; + } #endif } void R4300iOp32::SLTI() { - if (_GPR[m_Opcode.rs].W[0] < (__int64)((short)m_Opcode.immediate)) - { - _GPR[m_Opcode.rt].W[0] = 1; - } - else - { - _GPR[m_Opcode.rt].W[0] = 0; - } + if (_GPR[m_Opcode.rs].W[0] < (int64_t)((int16_t)m_Opcode.immediate)) + { + _GPR[m_Opcode.rt].W[0] = 1; + } + else + { + _GPR[m_Opcode.rt].W[0] = 0; + } } void R4300iOp32::SLTIU() { - int imm32 = (short)m_Opcode.immediate; - __int64 imm64; + int32_t imm32 = (int16_t)m_Opcode.immediate; + int64_t imm64; - imm64 = imm32; - _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rs].UW[0] < (unsigned __int64)imm64?1:0; + imm64 = imm32; + _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rs].UW[0] < (uint64_t)imm64?1:0; } void R4300iOp32::ANDI() { - _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rs].W[0] & m_Opcode.immediate; + _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rs].W[0] & m_Opcode.immediate; } void R4300iOp32::ORI() { - _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rs].W[0] | m_Opcode.immediate; + _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rs].W[0] | m_Opcode.immediate; } void R4300iOp32::XORI() { - _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rs].W[0] ^ m_Opcode.immediate; + _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rs].W[0] ^ m_Opcode.immediate; } void R4300iOp32::LUI() { - _GPR[m_Opcode.rt].W[0] = (long)((short)m_Opcode.offset << 16); + _GPR[m_Opcode.rt].W[0] = (int32_t)((int16_t)m_Opcode.offset << 16); #ifdef Interpreter_StackTest - if (m_Opcode.rt == 29) - { - StackValue = _GPR[m_Opcode.rt].W[0]; - } + if (m_Opcode.rt == 29) + { + StackValue = _GPR[m_Opcode.rt].W[0]; + } #endif } void R4300iOp32::BEQL() { - if (_GPR[m_Opcode.rs].W[0] == _GPR[m_Opcode.rt].W[0]) - { - m_NextInstruction = DELAY_SLOT; - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) - { - m_NextInstruction = PERMLOOP_DO_DELAY; - } - } - } - else - { - m_NextInstruction = JUMP; - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + if (_GPR[m_Opcode.rs].W[0] == _GPR[m_Opcode.rt].W[0]) + { + m_NextInstruction = DELAY_SLOT; + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) + { + m_NextInstruction = PERMLOOP_DO_DELAY; + } + } + } + else + { + m_NextInstruction = JUMP; + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp32::BNEL() { - if (_GPR[m_Opcode.rs].W[0] != _GPR[m_Opcode.rt].W[0]) - { - m_NextInstruction = DELAY_SLOT; - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) - { - m_NextInstruction = PERMLOOP_DO_DELAY; - } - } - } - else - { - m_NextInstruction = JUMP; - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + if (_GPR[m_Opcode.rs].W[0] != _GPR[m_Opcode.rt].W[0]) + { + m_NextInstruction = DELAY_SLOT; + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) + { + m_NextInstruction = PERMLOOP_DO_DELAY; + } + } + } + else + { + m_NextInstruction = JUMP; + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp32::BLEZL() { - if (_GPR[m_Opcode.rs].W[0] <= 0) - { - m_NextInstruction = DELAY_SLOT; - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) - { - m_NextInstruction = PERMLOOP_DO_DELAY; - } - } - } - else - { - m_NextInstruction = JUMP; - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + if (_GPR[m_Opcode.rs].W[0] <= 0) + { + m_NextInstruction = DELAY_SLOT; + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) + { + m_NextInstruction = PERMLOOP_DO_DELAY; + } + } + } + else + { + m_NextInstruction = JUMP; + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp32::BGTZL() { - if (_GPR[m_Opcode.rs].W[0] > 0) - { - m_NextInstruction = DELAY_SLOT; - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) - { - m_NextInstruction = PERMLOOP_DO_DELAY; - } - } - } - else - { - m_NextInstruction = JUMP; - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + if (_GPR[m_Opcode.rs].W[0] > 0) + { + m_NextInstruction = DELAY_SLOT; + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) + { + m_NextInstruction = PERMLOOP_DO_DELAY; + } + } + } + else + { + m_NextInstruction = JUMP; + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp32::LB() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - if (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0])) - { - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - TLB_READ_EXCEPTION(Address); - } - else - { - _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rt].B[0]; - } + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0])) + { + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + TLB_READ_EXCEPTION(Address); + } + else + { + _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rt].B[0]; + } } void R4300iOp32::LH() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - if ((Address & 1) != 0) - { - ADDRESS_ERROR_EXCEPTION(Address, true); - } - if (!g_MMU->LH_VAddr(Address,_GPR[m_Opcode.rt].UHW[0])) - { - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - TLB_READ_EXCEPTION(Address); - } - else - { - _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rt].HW[0]; - } + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if ((Address & 1) != 0) + { + ADDRESS_ERROR_EXCEPTION(Address, true); + } + if (!g_MMU->LH_VAddr(Address,_GPR[m_Opcode.rt].UHW[0])) + { + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + TLB_READ_EXCEPTION(Address); + } + else + { + _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rt].HW[0]; + } } void R4300iOp32::LWL() { - DWORD Offset, Address, Value; - - Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - Offset = Address & 3; + uint32_t Offset, Address, Value; - if (!g_MMU->LW_VAddr((Address & ~3),(uint32_t &)Value)) - { - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - TLB_READ_EXCEPTION(Address); - return; - } - - _GPR[m_Opcode.rt].W[0] = (int)(_GPR[m_Opcode.rt].W[0] & LWL_MASK[Offset]); - _GPR[m_Opcode.rt].W[0] += (int)(Value << LWL_SHIFT[Offset]); + Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + Offset = Address & 3; + + if (!g_MMU->LW_VAddr((Address & ~3),Value)) + { + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + TLB_READ_EXCEPTION(Address); + return; + } + + _GPR[m_Opcode.rt].W[0] = (int32_t)(_GPR[m_Opcode.rt].W[0] & LWL_MASK[Offset]); + _GPR[m_Opcode.rt].W[0] += (int32_t)(Value << LWL_SHIFT[Offset]); } void R4300iOp32::LW() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - if ((Address & 3) != 0) - { - ADDRESS_ERROR_EXCEPTION(Address, true); - } + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if ((Address & 3) != 0) + { + ADDRESS_ERROR_EXCEPTION(Address, true); + } - if (g_LogOptions.GenerateLog) - { - Log_LW((*_PROGRAM_COUNTER),Address); - } + if (g_LogOptions.GenerateLog) + { + Log_LW((*_PROGRAM_COUNTER),Address); + } - if (!g_MMU->LW_VAddr(Address,(uint32_t &)_GPR[m_Opcode.rt].UW[0])) - { - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - TLB_READ_EXCEPTION(Address); - } - else - { - _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rt].W[0]; - } + if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + { + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + TLB_READ_EXCEPTION(Address); + } + else + { + _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rt].W[0]; + } } void R4300iOp32::LBU() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - if (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0])) - { - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - TLB_READ_EXCEPTION(Address); - } - else - { - _GPR[m_Opcode.rt].UW[0] = _GPR[m_Opcode.rt].UB[0]; - } + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0])) + { + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + TLB_READ_EXCEPTION(Address); + } + else + { + _GPR[m_Opcode.rt].UW[0] = _GPR[m_Opcode.rt].UB[0]; + } } void R4300iOp32::LHU() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - if ((Address & 1) != 0) - { - ADDRESS_ERROR_EXCEPTION(Address, true); - } - if (!g_MMU->LH_VAddr(Address,_GPR[m_Opcode.rt].UHW[0])) - { - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - TLB_READ_EXCEPTION(Address); - } - else - { - _GPR[m_Opcode.rt].UW[0] = _GPR[m_Opcode.rt].UHW[0]; - } + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if ((Address & 1) != 0) + { + ADDRESS_ERROR_EXCEPTION(Address, true); + } + if (!g_MMU->LH_VAddr(Address,_GPR[m_Opcode.rt].UHW[0])) + { + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + TLB_READ_EXCEPTION(Address); + } + else + { + _GPR[m_Opcode.rt].UW[0] = _GPR[m_Opcode.rt].UHW[0]; + } } void R4300iOp32::LWR() { - DWORD Offset, Address, Value; - - Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - Offset = Address & 3; + uint32_t Offset, Address, Value; - if (!g_MMU->LW_VAddr((Address & ~3),(uint32_t &)Value)) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - return; - } - - _GPR[m_Opcode.rt].W[0] = (int)(_GPR[m_Opcode.rt].W[0] & LWR_MASK[Offset]); - _GPR[m_Opcode.rt].W[0] += (int)(Value >> LWR_SHIFT[Offset]); + Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + Offset = Address & 3; + + if (!g_MMU->LW_VAddr((Address & ~3),Value)) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + return; + } + + _GPR[m_Opcode.rt].W[0] = (int32_t)(_GPR[m_Opcode.rt].W[0] & LWR_MASK[Offset]); + _GPR[m_Opcode.rt].W[0] += (int32_t)(Value >> LWR_SHIFT[Offset]); } void R4300iOp32::LWU() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - if ((Address & 3) != 0) - { - ADDRESS_ERROR_EXCEPTION(Address, true); - } + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if ((Address & 3) != 0) + { + ADDRESS_ERROR_EXCEPTION(Address, true); + } - if (!g_MMU->LW_VAddr(Address,(uint32_t &)_GPR[m_Opcode.rt].UW[0])) - { - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - TLB_READ_EXCEPTION(Address); - } - else - { - _GPR[m_Opcode.rt].UW[0] = _GPR[m_Opcode.rt].UW[0]; - } + if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + { + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + TLB_READ_EXCEPTION(Address); + } + else + { + _GPR[m_Opcode.rt].UW[0] = _GPR[m_Opcode.rt].UW[0]; + } } - void R4300iOp32::LL() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - if ((Address & 3) != 0) - { - ADDRESS_ERROR_EXCEPTION(Address, true); - } + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if ((Address & 3) != 0) + { + ADDRESS_ERROR_EXCEPTION(Address, true); + } - if (!g_MMU->LW_VAddr(Address,(uint32_t &)_GPR[m_Opcode.rt].UW[0])) - { - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - TLB_READ_EXCEPTION(Address); - } - else - { - _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rt].W[0]; - (*_LLBit) = 1; - } + if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + { + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + TLB_READ_EXCEPTION(Address); + } + else + { + _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rt].W[0]; + (*_LLBit) = 1; + } } /********************** R4300i OpCodes: Special **********************/ void R4300iOp32::SPECIAL_SLL() { - _GPR[m_Opcode.rd].W[0] = (_GPR[m_Opcode.rt].W[0] << m_Opcode.sa); + _GPR[m_Opcode.rd].W[0] = (_GPR[m_Opcode.rt].W[0] << m_Opcode.sa); } void R4300iOp32::SPECIAL_SRL() { - _GPR[m_Opcode.rd].W[0] = (int)(_GPR[m_Opcode.rt].UW[0] >> m_Opcode.sa); + _GPR[m_Opcode.rd].W[0] = (int32_t)(_GPR[m_Opcode.rt].UW[0] >> m_Opcode.sa); } void R4300iOp32::SPECIAL_SRA() { - _GPR[m_Opcode.rd].W[0] = (_GPR[m_Opcode.rt].W[0] >> m_Opcode.sa); + _GPR[m_Opcode.rd].W[0] = (_GPR[m_Opcode.rt].W[0] >> m_Opcode.sa); } void R4300iOp32::SPECIAL_SLLV() { - _GPR[m_Opcode.rd].W[0] = (_GPR[m_Opcode.rt].W[0] << (_GPR[m_Opcode.rs].UW[0] & 0x1F)); + _GPR[m_Opcode.rd].W[0] = (_GPR[m_Opcode.rt].W[0] << (_GPR[m_Opcode.rs].UW[0] & 0x1F)); } void R4300iOp32::SPECIAL_SRLV() { - _GPR[m_Opcode.rd].W[0] = (int)(_GPR[m_Opcode.rt].UW[0] >> (_GPR[m_Opcode.rs].UW[0] & 0x1F)); + _GPR[m_Opcode.rd].W[0] = (int32_t)(_GPR[m_Opcode.rt].UW[0] >> (_GPR[m_Opcode.rs].UW[0] & 0x1F)); } void R4300iOp32::SPECIAL_SRAV() { - _GPR[m_Opcode.rd].W[0] = (_GPR[m_Opcode.rt].W[0] >> (_GPR[m_Opcode.rs].UW[0] & 0x1F)); + _GPR[m_Opcode.rd].W[0] = (_GPR[m_Opcode.rt].W[0] >> (_GPR[m_Opcode.rs].UW[0] & 0x1F)); } void R4300iOp32::SPECIAL_JALR() { - m_NextInstruction = DELAY_SLOT; - m_JumpToLocation = _GPR[m_Opcode.rs].UW[0]; - _GPR[m_Opcode.rd].W[0] = (long)((*_PROGRAM_COUNTER) + 8); - m_TestTimer = true; + m_NextInstruction = DELAY_SLOT; + m_JumpToLocation = _GPR[m_Opcode.rs].UW[0]; + _GPR[m_Opcode.rd].W[0] = (int32_t)((*_PROGRAM_COUNTER) + 8); + m_TestTimer = true; } void R4300iOp32::SPECIAL_ADD() { - _GPR[m_Opcode.rd].W[0] = _GPR[m_Opcode.rs].W[0] + _GPR[m_Opcode.rt].W[0]; + _GPR[m_Opcode.rd].W[0] = _GPR[m_Opcode.rs].W[0] + _GPR[m_Opcode.rt].W[0]; } void R4300iOp32::SPECIAL_ADDU() { - _GPR[m_Opcode.rd].W[0] = _GPR[m_Opcode.rs].W[0] + _GPR[m_Opcode.rt].W[0]; + _GPR[m_Opcode.rd].W[0] = _GPR[m_Opcode.rs].W[0] + _GPR[m_Opcode.rt].W[0]; } void R4300iOp32::SPECIAL_SUB() { - _GPR[m_Opcode.rd].W[0] = _GPR[m_Opcode.rs].W[0] - _GPR[m_Opcode.rt].W[0]; + _GPR[m_Opcode.rd].W[0] = _GPR[m_Opcode.rs].W[0] - _GPR[m_Opcode.rt].W[0]; } void R4300iOp32::SPECIAL_SUBU() { - _GPR[m_Opcode.rd].W[0] = _GPR[m_Opcode.rs].W[0] - _GPR[m_Opcode.rt].W[0]; + _GPR[m_Opcode.rd].W[0] = _GPR[m_Opcode.rs].W[0] - _GPR[m_Opcode.rt].W[0]; } void R4300iOp32::SPECIAL_AND() { - _GPR[m_Opcode.rd].W[0] = _GPR[m_Opcode.rs].W[0] & _GPR[m_Opcode.rt].W[0]; + _GPR[m_Opcode.rd].W[0] = _GPR[m_Opcode.rs].W[0] & _GPR[m_Opcode.rt].W[0]; } void R4300iOp32::SPECIAL_OR() { - _GPR[m_Opcode.rd].W[0] = _GPR[m_Opcode.rs].W[0] | _GPR[m_Opcode.rt].W[0]; + _GPR[m_Opcode.rd].W[0] = _GPR[m_Opcode.rs].W[0] | _GPR[m_Opcode.rt].W[0]; #ifdef Interpreter_StackTest - if (m_Opcode.rd == 29) - { - StackValue = _GPR[m_Opcode.rd].W[0]; - } + if (m_Opcode.rd == 29) + { + StackValue = _GPR[m_Opcode.rd].W[0]; + } #endif } void R4300iOp32::SPECIAL_NOR() { - _GPR[m_Opcode.rd].W[0] = ~(_GPR[m_Opcode.rs].W[0] | _GPR[m_Opcode.rt].W[0]); + _GPR[m_Opcode.rd].W[0] = ~(_GPR[m_Opcode.rs].W[0] | _GPR[m_Opcode.rt].W[0]); } void R4300iOp32::SPECIAL_SLT() { - if (_GPR[m_Opcode.rs].W[0] < _GPR[m_Opcode.rt].W[0]) - { - _GPR[m_Opcode.rd].W[0] = 1; - } - else - { - _GPR[m_Opcode.rd].W[0] = 0; - } + if (_GPR[m_Opcode.rs].W[0] < _GPR[m_Opcode.rt].W[0]) + { + _GPR[m_Opcode.rd].W[0] = 1; + } + else + { + _GPR[m_Opcode.rd].W[0] = 0; + } } void R4300iOp32::SPECIAL_SLTU() { - if (_GPR[m_Opcode.rs].UW[0] < _GPR[m_Opcode.rt].UW[0]) - { - _GPR[m_Opcode.rd].W[0] = 1; - } - else - { - _GPR[m_Opcode.rd].W[0] = 0; - } + if (_GPR[m_Opcode.rs].UW[0] < _GPR[m_Opcode.rt].UW[0]) + { + _GPR[m_Opcode.rd].W[0] = 1; + } + else + { + _GPR[m_Opcode.rd].W[0] = 0; + } } void R4300iOp32::SPECIAL_TEQ() { - if (_GPR[m_Opcode.rs].W[0] == _GPR[m_Opcode.rt].W[0] && g_Settings->LoadBool(Debugger_Enabled)) - { - g_Notify->DisplayError(L"Should trap this ???"); - } + if (_GPR[m_Opcode.rs].W[0] == _GPR[m_Opcode.rt].W[0] && g_Settings->LoadBool(Debugger_Enabled)) + { + g_Notify->DisplayError(L"Should trap this ???"); + } } -void R4300iOp32::SPECIAL_DSRL32() +void R4300iOp32::SPECIAL_DSRL32() { - _GPR[m_Opcode.rd].UW[0] = (DWORD)(_GPR[m_Opcode.rt].UDW >> (m_Opcode.sa + 32)); + _GPR[m_Opcode.rd].UW[0] = (uint32_t)(_GPR[m_Opcode.rt].UDW >> (m_Opcode.sa + 32)); } -void R4300iOp32::SPECIAL_DSRA32() +void R4300iOp32::SPECIAL_DSRA32() { - _GPR[m_Opcode.rd].W[0] = (long)(_GPR[m_Opcode.rt].DW >> (m_Opcode.sa + 32)); + _GPR[m_Opcode.rd].W[0] = (int32_t)(_GPR[m_Opcode.rt].DW >> (m_Opcode.sa + 32)); } /********************** R4300i OpCodes: RegImm **********************/ void R4300iOp32::REGIMM_BLTZ() { - m_NextInstruction = DELAY_SLOT; - if (_GPR[m_Opcode.rs].W[0] < 0) - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) - { - CInterpreterCPU::InPermLoop(); - } - } - } - else - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + m_NextInstruction = DELAY_SLOT; + if (_GPR[m_Opcode.rs].W[0] < 0) + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + { + CInterpreterCPU::InPermLoop(); + } + } + } + else + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp32::REGIMM_BGEZ() { - m_NextInstruction = DELAY_SLOT; - if (_GPR[m_Opcode.rs].W[0] >= 0) - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) - { - CInterpreterCPU::InPermLoop(); - } - } - } - else - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + m_NextInstruction = DELAY_SLOT; + if (_GPR[m_Opcode.rs].W[0] >= 0) + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + { + CInterpreterCPU::InPermLoop(); + } + } + } + else + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp32::REGIMM_BLTZL() { - if (_GPR[m_Opcode.rs].W[0] < 0) - { - m_NextInstruction = DELAY_SLOT; - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) - { - CInterpreterCPU::InPermLoop(); - } - } - } - else - { - m_NextInstruction = JUMP; - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + if (_GPR[m_Opcode.rs].W[0] < 0) + { + m_NextInstruction = DELAY_SLOT; + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + { + CInterpreterCPU::InPermLoop(); + } + } + } + else + { + m_NextInstruction = JUMP; + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp32::REGIMM_BGEZL() { - if (_GPR[m_Opcode.rs].W[0] >= 0) - { - m_NextInstruction = DELAY_SLOT; - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) - { - CInterpreterCPU::InPermLoop(); - } - } - } - else - { - m_NextInstruction = JUMP; - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + if (_GPR[m_Opcode.rs].W[0] >= 0) + { + m_NextInstruction = DELAY_SLOT; + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + { + CInterpreterCPU::InPermLoop(); + } + } + } + else + { + m_NextInstruction = JUMP; + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp32::REGIMM_BLTZAL() { - m_NextInstruction = DELAY_SLOT; - if (_GPR[m_Opcode.rs].W[0] < 0) - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) - { - CInterpreterCPU::InPermLoop(); - } - } - } - else - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } - _GPR[31].W[0]= (long)((*_PROGRAM_COUNTER) + 8); + m_NextInstruction = DELAY_SLOT; + if (_GPR[m_Opcode.rs].W[0] < 0) + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + { + CInterpreterCPU::InPermLoop(); + } + } + } + else + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } + _GPR[31].W[0]= (int32_t)((*_PROGRAM_COUNTER) + 8); } void R4300iOp32::REGIMM_BGEZAL() { - m_NextInstruction = DELAY_SLOT; - if (_GPR[m_Opcode.rs].W[0] >= 0) - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) - { - CInterpreterCPU::InPermLoop(); - } - } - } - else - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } - _GPR[31].W[0] = (long)((*_PROGRAM_COUNTER) + 8); + m_NextInstruction = DELAY_SLOT; + if (_GPR[m_Opcode.rs].W[0] >= 0) + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + { + CInterpreterCPU::InPermLoop(); + } + } + } + else + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } + _GPR[31].W[0] = (int32_t)((*_PROGRAM_COUNTER) + 8); } -/************************** COP0 functions **************************/ -void R4300iOp32::COP0_MF() { - if (g_LogOptions.LogCP0reads) - { - LogMessage("%08X: R4300i Read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); - } - if (m_Opcode.rd == 9) - { - g_SystemTimer->UpdateTimers(); - } - _GPR[m_Opcode.rt].W[0] = (int)_CP0[m_Opcode.rd]; +/************************** COP0 functions **************************/ +void R4300iOp32::COP0_MF() +{ + if (g_LogOptions.LogCP0reads) + { + LogMessage("%08X: R4300i Read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); + } + + if (m_Opcode.rd == 9) + { + g_SystemTimer->UpdateTimers(); + } + _GPR[m_Opcode.rt].W[0] = (int32_t)_CP0[m_Opcode.rd]; } void R4300iOp32::COP0_MT() { - if (g_LogOptions.LogCP0changes) - { - LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)",(*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0],CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); - if (m_Opcode.rd == 11) //Compare - { - LogMessage("%08X: Cause register changed from %08X to %08X",(*_PROGRAM_COUNTER), g_Reg->CAUSE_REGISTER, (g_Reg->CAUSE_REGISTER & ~CAUSE_IP7)); - } - } + if (g_LogOptions.LogCP0changes) + { + LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)",(*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0],CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); + if (m_Opcode.rd == 11) //Compare + { + LogMessage("%08X: Cause register changed from %08X to %08X",(*_PROGRAM_COUNTER), g_Reg->CAUSE_REGISTER, (g_Reg->CAUSE_REGISTER & ~CAUSE_IP7)); + } + } - switch (m_Opcode.rd) - { - case 0: //Index - case 2: //EntryLo0 - case 3: //EntryLo1 - case 5: //PageMask - case 10: //Entry Hi - case 14: //EPC - case 16: //Config - case 18: //WatchLo - case 19: //WatchHi - case 28: //Tag lo - case 29: //Tag Hi - case 30: //ErrEPC - _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; - break; - case 6: //Wired - g_SystemTimer->UpdateTimers(); - _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; - break; - case 4: //Context - _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0] & 0xFF800000; - break; - case 9: //Count - g_SystemTimer->UpdateTimers(); - _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; - g_SystemTimer->UpdateCompareTimer(); - break; - case 11: //Compare - g_SystemTimer->UpdateTimers(); - _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; - g_Reg->FAKE_CAUSE_REGISTER &= ~CAUSE_IP7; - g_SystemTimer->UpdateCompareTimer(); - break; - case 12: //Status - if ((_CP0[m_Opcode.rd] & STATUS_FR) != (_GPR[m_Opcode.rt].UW[0] & STATUS_FR)) - { - _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; - g_Reg->FixFpuLocations(); - } - else - { - _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; - } - if ((_CP0[m_Opcode.rd] & 0x18) != 0 && g_Settings->LoadBool(Debugger_Enabled)) - { - g_Notify->DisplayError(L"Left kernel mode ??"); - } - g_Reg->CheckInterrupts(); - break; - case 13: //cause - _CP0[m_Opcode.rd] &= 0xFFFFCFF; - if ((_GPR[m_Opcode.rt].UW[0] & 0x300) != 0 && g_Settings->LoadBool(Debugger_Enabled) ) - { - g_Notify->DisplayError(L"Set IP0 or IP1"); - } - break; - default: - UnknownOpcode(); - } + switch (m_Opcode.rd) + { + case 0: //Index + case 2: //EntryLo0 + case 3: //EntryLo1 + case 5: //PageMask + case 10: //Entry Hi + case 14: //EPC + case 16: //Config + case 18: //WatchLo + case 19: //WatchHi + case 28: //Tag lo + case 29: //Tag Hi + case 30: //ErrEPC + _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; + break; + case 6: //Wired + g_SystemTimer->UpdateTimers(); + _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; + break; + case 4: //Context + _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0] & 0xFF800000; + break; + case 9: //Count + g_SystemTimer->UpdateTimers(); + _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; + g_SystemTimer->UpdateCompareTimer(); + break; + case 11: //Compare + g_SystemTimer->UpdateTimers(); + _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; + g_Reg->FAKE_CAUSE_REGISTER &= ~CAUSE_IP7; + g_SystemTimer->UpdateCompareTimer(); + break; + case 12: //Status + if ((_CP0[m_Opcode.rd] & STATUS_FR) != (_GPR[m_Opcode.rt].UW[0] & STATUS_FR)) + { + _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; + g_Reg->FixFpuLocations(); + } + else + { + _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; + } + if ((_CP0[m_Opcode.rd] & 0x18) != 0 && g_Settings->LoadBool(Debugger_Enabled)) + { + g_Notify->DisplayError(L"Left kernel mode ??"); + } + g_Reg->CheckInterrupts(); + break; + case 13: //cause + _CP0[m_Opcode.rd] &= 0xFFFFCFF; + if ((_GPR[m_Opcode.rt].UW[0] & 0x300) != 0 && g_Settings->LoadBool(Debugger_Enabled) ) + { + g_Notify->DisplayError(L"Set IP0 or IP1"); + } + break; + default: + UnknownOpcode(); + } } /************************** COP1 functions **************************/ void R4300iOp32::COP1_MF() { - TEST_COP1_USABLE_EXCEPTION - _GPR[m_Opcode.rt].W[0] = *(int *)_FPR_S[m_Opcode.fs]; + TEST_COP1_USABLE_EXCEPTION + _GPR[m_Opcode.rt].W[0] = *(int32_t *)_FPR_S[m_Opcode.fs]; } void R4300iOp32::COP1_CF() { - TEST_COP1_USABLE_EXCEPTION - if (m_Opcode.fs != 31 && m_Opcode.fs != 0) - { - if (g_Settings->LoadBool(Debugger_Enabled)) { g_Notify->DisplayError(L"CFC1 what register are you writing to ?"); } - return; - } - _GPR[m_Opcode.rt].W[0] = (int)_FPCR[m_Opcode.fs]; + TEST_COP1_USABLE_EXCEPTION + if (m_Opcode.fs != 31 && m_Opcode.fs != 0) + { + if (g_Settings->LoadBool(Debugger_Enabled)) { g_Notify->DisplayError(L"CFC1 what register are you writing to ?"); } + return; + } + _GPR[m_Opcode.rt].W[0] = (int32_t)_FPCR[m_Opcode.fs]; } void R4300iOp32::COP1_DMT() { - TEST_COP1_USABLE_EXCEPTION - *(__int64 *)_FPR_D[m_Opcode.fs] = _GPR[m_Opcode.rt].W[0]; + TEST_COP1_USABLE_EXCEPTION + *(int64_t *)_FPR_D[m_Opcode.fs] = _GPR[m_Opcode.rt].W[0]; } diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp index be46680a5..250893e37 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp @@ -11,12 +11,12 @@ #include "stdafx.h" void InPermLoop(); -void TestInterpreterJump(DWORD PC, DWORD TargetPC, int Reg1, int Reg2); +void TestInterpreterJump(uint32_t PC, uint32_t TargetPC, int32_t Reg1, int32_t Reg2); bool R4300iOp::m_TestTimer = false; -DWORD R4300iOp::m_NextInstruction; +uint32_t R4300iOp::m_NextInstruction; OPCODE R4300iOp::m_Opcode; -DWORD R4300iOp::m_JumpToLocation; +uint32_t R4300iOp::m_JumpToLocation; R4300iOp::Func R4300iOp::Jump_Opcode[64]; R4300iOp::Func R4300iOp::Jump_Special[64]; @@ -30,2338 +30,2332 @@ R4300iOp::Func R4300iOp::Jump_CoP1_D[64]; R4300iOp::Func R4300iOp::Jump_CoP1_W[64]; R4300iOp::Func R4300iOp::Jump_CoP1_L[64]; -const DWORD R4300iOp::SWL_MASK[4] = { 0x00000000, 0xFF000000,0xFFFF0000,0xFFFFFF00 }; -const DWORD R4300iOp::SWR_MASK[4] = { 0x00FFFFFF, 0x0000FFFF,0x000000FF,0x00000000 }; -const DWORD R4300iOp::LWL_MASK[4] = { 0x00000000, 0x000000FF,0x0000FFFF,0x00FFFFFF }; -const DWORD R4300iOp::LWR_MASK[4] = { 0xFFFFFF00, 0xFFFF0000,0xFF000000,0x0000000 }; +const uint32_t R4300iOp::SWL_MASK[4] = { 0x00000000, 0xFF000000,0xFFFF0000,0xFFFFFF00 }; +const uint32_t R4300iOp::SWR_MASK[4] = { 0x00FFFFFF, 0x0000FFFF,0x000000FF,0x00000000 }; +const uint32_t R4300iOp::LWL_MASK[4] = { 0x00000000, 0x000000FF,0x0000FFFF,0x00FFFFFF }; +const uint32_t R4300iOp::LWR_MASK[4] = { 0xFFFFFF00, 0xFFFF0000,0xFF000000,0x0000000 }; -const int R4300iOp::SWL_SHIFT[4] = { 0, 8, 16, 24 }; -const int R4300iOp::SWR_SHIFT[4] = { 24, 16 , 8, 0 }; -const int R4300iOp::LWL_SHIFT[4] = { 0, 8, 16, 24}; -const int R4300iOp::LWR_SHIFT[4] = { 24, 16 ,8, 0 }; +const int32_t R4300iOp::SWL_SHIFT[4] = { 0, 8, 16, 24 }; +const int32_t R4300iOp::SWR_SHIFT[4] = { 24, 16 , 8, 0 }; +const int32_t R4300iOp::LWL_SHIFT[4] = { 0, 8, 16, 24}; +const int32_t R4300iOp::LWR_SHIFT[4] = { 24, 16 ,8, 0 }; #define ADDRESS_ERROR_EXCEPTION(Address,FromRead) \ - g_Reg->DoAddressError(m_NextInstruction == JUMP,Address,FromRead);\ - m_NextInstruction = JUMP;\ - m_JumpToLocation = (*_PROGRAM_COUNTER);\ - return; + g_Reg->DoAddressError(m_NextInstruction == JUMP,Address,FromRead);\ + m_NextInstruction = JUMP;\ + m_JumpToLocation = (*_PROGRAM_COUNTER);\ + return; //#define TEST_COP1_USABLE_EXCEPTION #define TEST_COP1_USABLE_EXCEPTION \ - if ((g_Reg->STATUS_REGISTER & STATUS_CU1) == 0) {\ - g_Reg->DoCopUnusableException(m_NextInstruction == JUMP,1);\ - m_NextInstruction = JUMP;\ - m_JumpToLocation = (*_PROGRAM_COUNTER);\ - return;\ - } + if ((g_Reg->STATUS_REGISTER & STATUS_CU1) == 0) {\ + g_Reg->DoCopUnusableException(m_NextInstruction == JUMP,1);\ + m_NextInstruction = JUMP;\ + m_JumpToLocation = (*_PROGRAM_COUNTER);\ + return;\ + } #define TLB_READ_EXCEPTION(Address) \ - g_Reg->DoTLBReadMiss(m_NextInstruction == JUMP,Address);\ - m_NextInstruction = JUMP;\ - m_JumpToLocation = (*_PROGRAM_COUNTER);\ - return; + g_Reg->DoTLBReadMiss(m_NextInstruction == JUMP,Address);\ + m_NextInstruction = JUMP;\ + m_JumpToLocation = (*_PROGRAM_COUNTER);\ + return; void R4300iOp::SPECIAL() { - Jump_Special[ m_Opcode.funct ](); + Jump_Special[ m_Opcode.funct ](); } void R4300iOp::REGIMM() { - Jump_Regimm[ m_Opcode.rt ](); + Jump_Regimm[ m_Opcode.rt ](); } void R4300iOp::COP0() { - Jump_CoP0[ m_Opcode.rs ](); + Jump_CoP0[ m_Opcode.rs ](); } void R4300iOp::COP0_CO() { - Jump_CoP0_Function[ m_Opcode.funct ](); + Jump_CoP0_Function[ m_Opcode.funct ](); } void R4300iOp::COP1() { - Jump_CoP1[ m_Opcode.fmt ](); + Jump_CoP1[ m_Opcode.fmt ](); } void R4300iOp::COP1_BC() { - Jump_CoP1_BC[ m_Opcode.ft ](); + Jump_CoP1_BC[ m_Opcode.ft ](); } void R4300iOp::COP1_S() { - _controlfp(*_RoundingModel,_MCW_RC); - Jump_CoP1_S[ m_Opcode.funct ](); + _controlfp(*_RoundingModel,_MCW_RC); + Jump_CoP1_S[ m_Opcode.funct ](); } void R4300iOp::COP1_D() { - _controlfp(*_RoundingModel,_MCW_RC); - Jump_CoP1_D[ m_Opcode.funct ](); + _controlfp(*_RoundingModel,_MCW_RC); + Jump_CoP1_D[ m_Opcode.funct ](); } void R4300iOp::COP1_W() { - Jump_CoP1_W[ m_Opcode.funct ](); + Jump_CoP1_W[ m_Opcode.funct ](); } void R4300iOp::COP1_L() { - Jump_CoP1_L[ m_Opcode.funct ](); + Jump_CoP1_L[ m_Opcode.funct ](); } R4300iOp::Func * R4300iOp::BuildInterpreter() -{ - Jump_Opcode[ 0] = SPECIAL; - Jump_Opcode[ 1] = REGIMM; - Jump_Opcode[ 2] = J; - Jump_Opcode[ 3] = JAL; - Jump_Opcode[ 4] = BEQ; - Jump_Opcode[ 5] = BNE; - Jump_Opcode[ 6] = BLEZ; - Jump_Opcode[ 7] = BGTZ; - Jump_Opcode[ 8] = ADDI; - Jump_Opcode[ 9] = ADDIU; - Jump_Opcode[10] = SLTI; - Jump_Opcode[11] = SLTIU; - Jump_Opcode[12] = ANDI; - Jump_Opcode[13] = ORI; - Jump_Opcode[14] = XORI; - Jump_Opcode[15] = LUI; - Jump_Opcode[16] = COP0; - Jump_Opcode[17] = COP1; - Jump_Opcode[18] = UnknownOpcode; - Jump_Opcode[19] = UnknownOpcode; - Jump_Opcode[20] = BEQL; - Jump_Opcode[21] = BNEL; - Jump_Opcode[22] = BLEZL; - Jump_Opcode[23] = BGTZL; - Jump_Opcode[24] = UnknownOpcode; - Jump_Opcode[25] = DADDIU; - Jump_Opcode[26] = LDL; - Jump_Opcode[27] = LDR; - Jump_Opcode[28] = UnknownOpcode; - Jump_Opcode[29] = UnknownOpcode; - Jump_Opcode[30] = UnknownOpcode; - Jump_Opcode[31] = UnknownOpcode; - Jump_Opcode[32] = LB; - Jump_Opcode[33] = LH; - Jump_Opcode[34] = LWL; - Jump_Opcode[35] = LW; - Jump_Opcode[36] = LBU; - Jump_Opcode[37] = LHU; - Jump_Opcode[38] = LWR; - Jump_Opcode[39] = LWU; - Jump_Opcode[40] = SB; - Jump_Opcode[41] = SH; - Jump_Opcode[42] = SWL; - Jump_Opcode[43] = SW; - Jump_Opcode[44] = SDL; - Jump_Opcode[45] = SDR; - Jump_Opcode[46] = SWR; - Jump_Opcode[47] = CACHE; - Jump_Opcode[48] = LL; - Jump_Opcode[49] = LWC1; - Jump_Opcode[50] = UnknownOpcode; - Jump_Opcode[51] = UnknownOpcode; - Jump_Opcode[52] = UnknownOpcode; - Jump_Opcode[53] = LDC1; - Jump_Opcode[54] = UnknownOpcode; - Jump_Opcode[55] = LD; - Jump_Opcode[56] = SC; - Jump_Opcode[57] = SWC1; - Jump_Opcode[58] = UnknownOpcode; - Jump_Opcode[59] = UnknownOpcode; - Jump_Opcode[60] = UnknownOpcode; - Jump_Opcode[61] = SDC1; - Jump_Opcode[62] = UnknownOpcode; - Jump_Opcode[63] = SD; +{ + Jump_Opcode[ 0] = SPECIAL; + Jump_Opcode[ 1] = REGIMM; + Jump_Opcode[ 2] = J; + Jump_Opcode[ 3] = JAL; + Jump_Opcode[ 4] = BEQ; + Jump_Opcode[ 5] = BNE; + Jump_Opcode[ 6] = BLEZ; + Jump_Opcode[ 7] = BGTZ; + Jump_Opcode[ 8] = ADDI; + Jump_Opcode[ 9] = ADDIU; + Jump_Opcode[10] = SLTI; + Jump_Opcode[11] = SLTIU; + Jump_Opcode[12] = ANDI; + Jump_Opcode[13] = ORI; + Jump_Opcode[14] = XORI; + Jump_Opcode[15] = LUI; + Jump_Opcode[16] = COP0; + Jump_Opcode[17] = COP1; + Jump_Opcode[18] = UnknownOpcode; + Jump_Opcode[19] = UnknownOpcode; + Jump_Opcode[20] = BEQL; + Jump_Opcode[21] = BNEL; + Jump_Opcode[22] = BLEZL; + Jump_Opcode[23] = BGTZL; + Jump_Opcode[24] = UnknownOpcode; + Jump_Opcode[25] = DADDIU; + Jump_Opcode[26] = LDL; + Jump_Opcode[27] = LDR; + Jump_Opcode[28] = UnknownOpcode; + Jump_Opcode[29] = UnknownOpcode; + Jump_Opcode[30] = UnknownOpcode; + Jump_Opcode[31] = UnknownOpcode; + Jump_Opcode[32] = LB; + Jump_Opcode[33] = LH; + Jump_Opcode[34] = LWL; + Jump_Opcode[35] = LW; + Jump_Opcode[36] = LBU; + Jump_Opcode[37] = LHU; + Jump_Opcode[38] = LWR; + Jump_Opcode[39] = LWU; + Jump_Opcode[40] = SB; + Jump_Opcode[41] = SH; + Jump_Opcode[42] = SWL; + Jump_Opcode[43] = SW; + Jump_Opcode[44] = SDL; + Jump_Opcode[45] = SDR; + Jump_Opcode[46] = SWR; + Jump_Opcode[47] = CACHE; + Jump_Opcode[48] = LL; + Jump_Opcode[49] = LWC1; + Jump_Opcode[50] = UnknownOpcode; + Jump_Opcode[51] = UnknownOpcode; + Jump_Opcode[52] = UnknownOpcode; + Jump_Opcode[53] = LDC1; + Jump_Opcode[54] = UnknownOpcode; + Jump_Opcode[55] = LD; + Jump_Opcode[56] = SC; + Jump_Opcode[57] = SWC1; + Jump_Opcode[58] = UnknownOpcode; + Jump_Opcode[59] = UnknownOpcode; + Jump_Opcode[60] = UnknownOpcode; + Jump_Opcode[61] = SDC1; + Jump_Opcode[62] = UnknownOpcode; + Jump_Opcode[63] = SD; - Jump_Special[ 0] = SPECIAL_SLL; - Jump_Special[ 1] = UnknownOpcode; - Jump_Special[ 2] = SPECIAL_SRL; - Jump_Special[ 3] = SPECIAL_SRA; - Jump_Special[ 4] = SPECIAL_SLLV; - Jump_Special[ 5] = UnknownOpcode; - Jump_Special[ 6] = SPECIAL_SRLV; - Jump_Special[ 7] = SPECIAL_SRAV; - Jump_Special[ 8] = SPECIAL_JR; - Jump_Special[ 9] = SPECIAL_JALR; - Jump_Special[10] = UnknownOpcode; - Jump_Special[11] = UnknownOpcode; - Jump_Special[12] = SPECIAL_SYSCALL; - Jump_Special[13] = UnknownOpcode; - Jump_Special[14] = UnknownOpcode; - Jump_Special[15] = SPECIAL_SYNC; - Jump_Special[16] = SPECIAL_MFHI; - Jump_Special[17] = SPECIAL_MTHI; - Jump_Special[18] = SPECIAL_MFLO; - Jump_Special[19] = SPECIAL_MTLO; - Jump_Special[20] = SPECIAL_DSLLV; - Jump_Special[21] = UnknownOpcode; - Jump_Special[22] = SPECIAL_DSRLV; - Jump_Special[23] = SPECIAL_DSRAV; - Jump_Special[24] = SPECIAL_MULT; - Jump_Special[25] = SPECIAL_MULTU; - Jump_Special[26] = SPECIAL_DIV; - Jump_Special[27] = SPECIAL_DIVU; - Jump_Special[28] = SPECIAL_DMULT; - Jump_Special[29] = SPECIAL_DMULTU; - Jump_Special[30] = SPECIAL_DDIV; - Jump_Special[31] = SPECIAL_DDIVU; - Jump_Special[32] = SPECIAL_ADD; - Jump_Special[33] = SPECIAL_ADDU; - Jump_Special[34] = SPECIAL_SUB; - Jump_Special[35] = SPECIAL_SUBU; - Jump_Special[36] = SPECIAL_AND; - Jump_Special[37] = SPECIAL_OR; - Jump_Special[38] = SPECIAL_XOR; - Jump_Special[39] = SPECIAL_NOR; - Jump_Special[40] = UnknownOpcode; - Jump_Special[41] = UnknownOpcode; - Jump_Special[42] = SPECIAL_SLT; - Jump_Special[43] = SPECIAL_SLTU; - Jump_Special[44] = SPECIAL_DADD; - Jump_Special[45] = SPECIAL_DADDU; - Jump_Special[46] = SPECIAL_DSUB; - Jump_Special[47] = SPECIAL_DSUBU; - Jump_Special[48] = UnknownOpcode; - Jump_Special[49] = UnknownOpcode; - Jump_Special[50] = UnknownOpcode; - Jump_Special[51] = UnknownOpcode; - Jump_Special[52] = SPECIAL_TEQ; - Jump_Special[53] = UnknownOpcode; - Jump_Special[54] = UnknownOpcode; - Jump_Special[55] = UnknownOpcode; - Jump_Special[56] = SPECIAL_DSLL; - Jump_Special[57] = UnknownOpcode; - Jump_Special[58] = SPECIAL_DSRL; - Jump_Special[59] = SPECIAL_DSRA; - Jump_Special[60] = SPECIAL_DSLL32; - Jump_Special[61] = UnknownOpcode; - Jump_Special[62] = SPECIAL_DSRL32; - Jump_Special[63] = SPECIAL_DSRA32; + Jump_Special[ 0] = SPECIAL_SLL; + Jump_Special[ 1] = UnknownOpcode; + Jump_Special[ 2] = SPECIAL_SRL; + Jump_Special[ 3] = SPECIAL_SRA; + Jump_Special[ 4] = SPECIAL_SLLV; + Jump_Special[ 5] = UnknownOpcode; + Jump_Special[ 6] = SPECIAL_SRLV; + Jump_Special[ 7] = SPECIAL_SRAV; + Jump_Special[ 8] = SPECIAL_JR; + Jump_Special[ 9] = SPECIAL_JALR; + Jump_Special[10] = UnknownOpcode; + Jump_Special[11] = UnknownOpcode; + Jump_Special[12] = SPECIAL_SYSCALL; + Jump_Special[13] = UnknownOpcode; + Jump_Special[14] = UnknownOpcode; + Jump_Special[15] = SPECIAL_SYNC; + Jump_Special[16] = SPECIAL_MFHI; + Jump_Special[17] = SPECIAL_MTHI; + Jump_Special[18] = SPECIAL_MFLO; + Jump_Special[19] = SPECIAL_MTLO; + Jump_Special[20] = SPECIAL_DSLLV; + Jump_Special[21] = UnknownOpcode; + Jump_Special[22] = SPECIAL_DSRLV; + Jump_Special[23] = SPECIAL_DSRAV; + Jump_Special[24] = SPECIAL_MULT; + Jump_Special[25] = SPECIAL_MULTU; + Jump_Special[26] = SPECIAL_DIV; + Jump_Special[27] = SPECIAL_DIVU; + Jump_Special[28] = SPECIAL_DMULT; + Jump_Special[29] = SPECIAL_DMULTU; + Jump_Special[30] = SPECIAL_DDIV; + Jump_Special[31] = SPECIAL_DDIVU; + Jump_Special[32] = SPECIAL_ADD; + Jump_Special[33] = SPECIAL_ADDU; + Jump_Special[34] = SPECIAL_SUB; + Jump_Special[35] = SPECIAL_SUBU; + Jump_Special[36] = SPECIAL_AND; + Jump_Special[37] = SPECIAL_OR; + Jump_Special[38] = SPECIAL_XOR; + Jump_Special[39] = SPECIAL_NOR; + Jump_Special[40] = UnknownOpcode; + Jump_Special[41] = UnknownOpcode; + Jump_Special[42] = SPECIAL_SLT; + Jump_Special[43] = SPECIAL_SLTU; + Jump_Special[44] = SPECIAL_DADD; + Jump_Special[45] = SPECIAL_DADDU; + Jump_Special[46] = SPECIAL_DSUB; + Jump_Special[47] = SPECIAL_DSUBU; + Jump_Special[48] = UnknownOpcode; + Jump_Special[49] = UnknownOpcode; + Jump_Special[50] = UnknownOpcode; + Jump_Special[51] = UnknownOpcode; + Jump_Special[52] = SPECIAL_TEQ; + Jump_Special[53] = UnknownOpcode; + Jump_Special[54] = UnknownOpcode; + Jump_Special[55] = UnknownOpcode; + Jump_Special[56] = SPECIAL_DSLL; + Jump_Special[57] = UnknownOpcode; + Jump_Special[58] = SPECIAL_DSRL; + Jump_Special[59] = SPECIAL_DSRA; + Jump_Special[60] = SPECIAL_DSLL32; + Jump_Special[61] = UnknownOpcode; + Jump_Special[62] = SPECIAL_DSRL32; + Jump_Special[63] = SPECIAL_DSRA32; - Jump_Regimm[ 0] = REGIMM_BLTZ; - Jump_Regimm[ 1] = REGIMM_BGEZ; - Jump_Regimm[ 2] = REGIMM_BLTZL; - Jump_Regimm[ 3] = REGIMM_BGEZL; - Jump_Regimm[ 4] = UnknownOpcode; - Jump_Regimm[ 5] = UnknownOpcode; - Jump_Regimm[ 6] = UnknownOpcode; - Jump_Regimm[ 7] = UnknownOpcode; - Jump_Regimm[ 8] = UnknownOpcode; - Jump_Regimm[ 9] = UnknownOpcode; - Jump_Regimm[10] = UnknownOpcode; - Jump_Regimm[11] = UnknownOpcode; - Jump_Regimm[12] = UnknownOpcode; - Jump_Regimm[13] = UnknownOpcode; - Jump_Regimm[14] = UnknownOpcode; - Jump_Regimm[15] = UnknownOpcode; - Jump_Regimm[16] = REGIMM_BLTZAL; - Jump_Regimm[17] = REGIMM_BGEZAL; - Jump_Regimm[18] = UnknownOpcode; - Jump_Regimm[19] = UnknownOpcode; - Jump_Regimm[20] = UnknownOpcode; - Jump_Regimm[21] = UnknownOpcode; - Jump_Regimm[22] = UnknownOpcode; - Jump_Regimm[23] = UnknownOpcode; - Jump_Regimm[24] = UnknownOpcode; - Jump_Regimm[25] = UnknownOpcode; - Jump_Regimm[26] = UnknownOpcode; - Jump_Regimm[27] = UnknownOpcode; - Jump_Regimm[28] = UnknownOpcode; - Jump_Regimm[29] = UnknownOpcode; - Jump_Regimm[30] = UnknownOpcode; - Jump_Regimm[31] = UnknownOpcode; - - Jump_CoP0[ 0] = COP0_MF; - Jump_CoP0[ 1] = UnknownOpcode; - Jump_CoP0[ 2] = UnknownOpcode; - Jump_CoP0[ 3] = UnknownOpcode; - Jump_CoP0[ 4] = COP0_MT; - Jump_CoP0[ 5] = UnknownOpcode; - Jump_CoP0[ 6] = UnknownOpcode; - Jump_CoP0[ 7] = UnknownOpcode; - Jump_CoP0[ 8] = UnknownOpcode; - Jump_CoP0[ 9] = UnknownOpcode; - Jump_CoP0[10] = UnknownOpcode; - Jump_CoP0[11] = UnknownOpcode; - Jump_CoP0[12] = UnknownOpcode; - Jump_CoP0[13] = UnknownOpcode; - Jump_CoP0[14] = UnknownOpcode; - Jump_CoP0[15] = UnknownOpcode; - Jump_CoP0[16] = COP0_CO; - Jump_CoP0[17] = COP0_CO; - Jump_CoP0[18] = COP0_CO; - Jump_CoP0[19] = COP0_CO; - Jump_CoP0[20] = COP0_CO; - Jump_CoP0[21] = COP0_CO; - Jump_CoP0[22] = COP0_CO; - Jump_CoP0[23] = COP0_CO; - Jump_CoP0[24] = COP0_CO; - Jump_CoP0[25] = COP0_CO; - Jump_CoP0[26] = COP0_CO; - Jump_CoP0[27] = COP0_CO; - Jump_CoP0[28] = COP0_CO; - Jump_CoP0[29] = COP0_CO; - Jump_CoP0[30] = COP0_CO; - Jump_CoP0[31] = COP0_CO; + Jump_Regimm[ 0] = REGIMM_BLTZ; + Jump_Regimm[ 1] = REGIMM_BGEZ; + Jump_Regimm[ 2] = REGIMM_BLTZL; + Jump_Regimm[ 3] = REGIMM_BGEZL; + Jump_Regimm[ 4] = UnknownOpcode; + Jump_Regimm[ 5] = UnknownOpcode; + Jump_Regimm[ 6] = UnknownOpcode; + Jump_Regimm[ 7] = UnknownOpcode; + Jump_Regimm[ 8] = UnknownOpcode; + Jump_Regimm[ 9] = UnknownOpcode; + Jump_Regimm[10] = UnknownOpcode; + Jump_Regimm[11] = UnknownOpcode; + Jump_Regimm[12] = UnknownOpcode; + Jump_Regimm[13] = UnknownOpcode; + Jump_Regimm[14] = UnknownOpcode; + Jump_Regimm[15] = UnknownOpcode; + Jump_Regimm[16] = REGIMM_BLTZAL; + Jump_Regimm[17] = REGIMM_BGEZAL; + Jump_Regimm[18] = UnknownOpcode; + Jump_Regimm[19] = UnknownOpcode; + Jump_Regimm[20] = UnknownOpcode; + Jump_Regimm[21] = UnknownOpcode; + Jump_Regimm[22] = UnknownOpcode; + Jump_Regimm[23] = UnknownOpcode; + Jump_Regimm[24] = UnknownOpcode; + Jump_Regimm[25] = UnknownOpcode; + Jump_Regimm[26] = UnknownOpcode; + Jump_Regimm[27] = UnknownOpcode; + Jump_Regimm[28] = UnknownOpcode; + Jump_Regimm[29] = UnknownOpcode; + Jump_Regimm[30] = UnknownOpcode; + Jump_Regimm[31] = UnknownOpcode; - Jump_CoP0_Function[ 0] = UnknownOpcode; - Jump_CoP0_Function[ 1] = COP0_CO_TLBR; - Jump_CoP0_Function[ 2] = COP0_CO_TLBWI; - Jump_CoP0_Function[ 3] = UnknownOpcode; - Jump_CoP0_Function[ 4] = UnknownOpcode; - Jump_CoP0_Function[ 5] = UnknownOpcode; - Jump_CoP0_Function[ 6] = COP0_CO_TLBWR; - Jump_CoP0_Function[ 7] = UnknownOpcode; - Jump_CoP0_Function[ 8] = COP0_CO_TLBP; - Jump_CoP0_Function[ 9] = UnknownOpcode; - Jump_CoP0_Function[10] = UnknownOpcode; - Jump_CoP0_Function[11] = UnknownOpcode; - Jump_CoP0_Function[12] = UnknownOpcode; - Jump_CoP0_Function[13] = UnknownOpcode; - Jump_CoP0_Function[14] = UnknownOpcode; - Jump_CoP0_Function[15] = UnknownOpcode; - Jump_CoP0_Function[16] = UnknownOpcode; - Jump_CoP0_Function[17] = UnknownOpcode; - Jump_CoP0_Function[18] = UnknownOpcode; - Jump_CoP0_Function[19] = UnknownOpcode; - Jump_CoP0_Function[20] = UnknownOpcode; - Jump_CoP0_Function[21] = UnknownOpcode; - Jump_CoP0_Function[22] = UnknownOpcode; - Jump_CoP0_Function[23] = UnknownOpcode; - Jump_CoP0_Function[24] = COP0_CO_ERET; - Jump_CoP0_Function[25] = UnknownOpcode; - Jump_CoP0_Function[26] = UnknownOpcode; - Jump_CoP0_Function[27] = UnknownOpcode; - Jump_CoP0_Function[28] = UnknownOpcode; - Jump_CoP0_Function[29] = UnknownOpcode; - Jump_CoP0_Function[30] = UnknownOpcode; - Jump_CoP0_Function[31] = UnknownOpcode; - Jump_CoP0_Function[32] = UnknownOpcode; - Jump_CoP0_Function[33] = UnknownOpcode; - Jump_CoP0_Function[34] = UnknownOpcode; - Jump_CoP0_Function[35] = UnknownOpcode; - Jump_CoP0_Function[36] = UnknownOpcode; - Jump_CoP0_Function[37] = UnknownOpcode; - Jump_CoP0_Function[38] = UnknownOpcode; - Jump_CoP0_Function[39] = UnknownOpcode; - Jump_CoP0_Function[40] = UnknownOpcode; - Jump_CoP0_Function[41] = UnknownOpcode; - Jump_CoP0_Function[42] = UnknownOpcode; - Jump_CoP0_Function[43] = UnknownOpcode; - Jump_CoP0_Function[44] = UnknownOpcode; - Jump_CoP0_Function[45] = UnknownOpcode; - Jump_CoP0_Function[46] = UnknownOpcode; - Jump_CoP0_Function[47] = UnknownOpcode; - Jump_CoP0_Function[48] = UnknownOpcode; - Jump_CoP0_Function[49] = UnknownOpcode; - Jump_CoP0_Function[50] = UnknownOpcode; - Jump_CoP0_Function[51] = UnknownOpcode; - Jump_CoP0_Function[52] = UnknownOpcode; - Jump_CoP0_Function[53] = UnknownOpcode; - Jump_CoP0_Function[54] = UnknownOpcode; - Jump_CoP0_Function[55] = UnknownOpcode; - Jump_CoP0_Function[56] = UnknownOpcode; - Jump_CoP0_Function[57] = UnknownOpcode; - Jump_CoP0_Function[58] = UnknownOpcode; - Jump_CoP0_Function[59] = UnknownOpcode; - Jump_CoP0_Function[60] = UnknownOpcode; - Jump_CoP0_Function[61] = UnknownOpcode; - Jump_CoP0_Function[62] = UnknownOpcode; - Jump_CoP0_Function[63] = UnknownOpcode; - - Jump_CoP1[ 0] = COP1_MF; - Jump_CoP1[ 1] = COP1_DMF; - Jump_CoP1[ 2] = COP1_CF; - Jump_CoP1[ 3] = UnknownOpcode; - Jump_CoP1[ 4] = COP1_MT; - Jump_CoP1[ 5] = COP1_DMT; - Jump_CoP1[ 6] = COP1_CT; - Jump_CoP1[ 7] = UnknownOpcode; - Jump_CoP1[ 8] = COP1_BC; - Jump_CoP1[ 9] = UnknownOpcode; - Jump_CoP1[10] = UnknownOpcode; - Jump_CoP1[11] = UnknownOpcode; - Jump_CoP1[12] = UnknownOpcode; - Jump_CoP1[13] = UnknownOpcode; - Jump_CoP1[14] = UnknownOpcode; - Jump_CoP1[15] = UnknownOpcode; - Jump_CoP1[16] = COP1_S; - Jump_CoP1[17] = COP1_D; - Jump_CoP1[18] = UnknownOpcode; - Jump_CoP1[19] = UnknownOpcode; - Jump_CoP1[20] = COP1_W; - Jump_CoP1[21] = COP1_L; - Jump_CoP1[22] = UnknownOpcode; - Jump_CoP1[23] = UnknownOpcode; - Jump_CoP1[24] = UnknownOpcode; - Jump_CoP1[25] = UnknownOpcode; - Jump_CoP1[26] = UnknownOpcode; - Jump_CoP1[27] = UnknownOpcode; - Jump_CoP1[28] = UnknownOpcode; - Jump_CoP1[29] = UnknownOpcode; - Jump_CoP1[30] = UnknownOpcode; - Jump_CoP1[31] = UnknownOpcode; + Jump_CoP0[ 0] = COP0_MF; + Jump_CoP0[ 1] = UnknownOpcode; + Jump_CoP0[ 2] = UnknownOpcode; + Jump_CoP0[ 3] = UnknownOpcode; + Jump_CoP0[ 4] = COP0_MT; + Jump_CoP0[ 5] = UnknownOpcode; + Jump_CoP0[ 6] = UnknownOpcode; + Jump_CoP0[ 7] = UnknownOpcode; + Jump_CoP0[ 8] = UnknownOpcode; + Jump_CoP0[ 9] = UnknownOpcode; + Jump_CoP0[10] = UnknownOpcode; + Jump_CoP0[11] = UnknownOpcode; + Jump_CoP0[12] = UnknownOpcode; + Jump_CoP0[13] = UnknownOpcode; + Jump_CoP0[14] = UnknownOpcode; + Jump_CoP0[15] = UnknownOpcode; + Jump_CoP0[16] = COP0_CO; + Jump_CoP0[17] = COP0_CO; + Jump_CoP0[18] = COP0_CO; + Jump_CoP0[19] = COP0_CO; + Jump_CoP0[20] = COP0_CO; + Jump_CoP0[21] = COP0_CO; + Jump_CoP0[22] = COP0_CO; + Jump_CoP0[23] = COP0_CO; + Jump_CoP0[24] = COP0_CO; + Jump_CoP0[25] = COP0_CO; + Jump_CoP0[26] = COP0_CO; + Jump_CoP0[27] = COP0_CO; + Jump_CoP0[28] = COP0_CO; + Jump_CoP0[29] = COP0_CO; + Jump_CoP0[30] = COP0_CO; + Jump_CoP0[31] = COP0_CO; - Jump_CoP1_BC[ 0] = COP1_BCF; - Jump_CoP1_BC[ 1] = COP1_BCT; - Jump_CoP1_BC[ 2] = COP1_BCFL; - Jump_CoP1_BC[ 3] = COP1_BCTL; - Jump_CoP1_BC[ 4] = UnknownOpcode; - Jump_CoP1_BC[ 5] = UnknownOpcode; - Jump_CoP1_BC[ 6] = UnknownOpcode; - Jump_CoP1_BC[ 7] = UnknownOpcode; - Jump_CoP1_BC[ 8] = UnknownOpcode; - Jump_CoP1_BC[ 9] = UnknownOpcode; - Jump_CoP1_BC[10] = UnknownOpcode; - Jump_CoP1_BC[11] = UnknownOpcode; - Jump_CoP1_BC[12] = UnknownOpcode; - Jump_CoP1_BC[13] = UnknownOpcode; - Jump_CoP1_BC[14] = UnknownOpcode; - Jump_CoP1_BC[15] = UnknownOpcode; - Jump_CoP1_BC[16] = UnknownOpcode; - Jump_CoP1_BC[17] = UnknownOpcode; - Jump_CoP1_BC[18] = UnknownOpcode; - Jump_CoP1_BC[19] = UnknownOpcode; - Jump_CoP1_BC[20] = UnknownOpcode; - Jump_CoP1_BC[21] = UnknownOpcode; - Jump_CoP1_BC[22] = UnknownOpcode; - Jump_CoP1_BC[23] = UnknownOpcode; - Jump_CoP1_BC[24] = UnknownOpcode; - Jump_CoP1_BC[25] = UnknownOpcode; - Jump_CoP1_BC[26] = UnknownOpcode; - Jump_CoP1_BC[27] = UnknownOpcode; - Jump_CoP1_BC[28] = UnknownOpcode; - Jump_CoP1_BC[29] = UnknownOpcode; - Jump_CoP1_BC[30] = UnknownOpcode; - Jump_CoP1_BC[31] = UnknownOpcode; + Jump_CoP0_Function[ 0] = UnknownOpcode; + Jump_CoP0_Function[ 1] = COP0_CO_TLBR; + Jump_CoP0_Function[ 2] = COP0_CO_TLBWI; + Jump_CoP0_Function[ 3] = UnknownOpcode; + Jump_CoP0_Function[ 4] = UnknownOpcode; + Jump_CoP0_Function[ 5] = UnknownOpcode; + Jump_CoP0_Function[ 6] = COP0_CO_TLBWR; + Jump_CoP0_Function[ 7] = UnknownOpcode; + Jump_CoP0_Function[ 8] = COP0_CO_TLBP; + Jump_CoP0_Function[ 9] = UnknownOpcode; + Jump_CoP0_Function[10] = UnknownOpcode; + Jump_CoP0_Function[11] = UnknownOpcode; + Jump_CoP0_Function[12] = UnknownOpcode; + Jump_CoP0_Function[13] = UnknownOpcode; + Jump_CoP0_Function[14] = UnknownOpcode; + Jump_CoP0_Function[15] = UnknownOpcode; + Jump_CoP0_Function[16] = UnknownOpcode; + Jump_CoP0_Function[17] = UnknownOpcode; + Jump_CoP0_Function[18] = UnknownOpcode; + Jump_CoP0_Function[19] = UnknownOpcode; + Jump_CoP0_Function[20] = UnknownOpcode; + Jump_CoP0_Function[21] = UnknownOpcode; + Jump_CoP0_Function[22] = UnknownOpcode; + Jump_CoP0_Function[23] = UnknownOpcode; + Jump_CoP0_Function[24] = COP0_CO_ERET; + Jump_CoP0_Function[25] = UnknownOpcode; + Jump_CoP0_Function[26] = UnknownOpcode; + Jump_CoP0_Function[27] = UnknownOpcode; + Jump_CoP0_Function[28] = UnknownOpcode; + Jump_CoP0_Function[29] = UnknownOpcode; + Jump_CoP0_Function[30] = UnknownOpcode; + Jump_CoP0_Function[31] = UnknownOpcode; + Jump_CoP0_Function[32] = UnknownOpcode; + Jump_CoP0_Function[33] = UnknownOpcode; + Jump_CoP0_Function[34] = UnknownOpcode; + Jump_CoP0_Function[35] = UnknownOpcode; + Jump_CoP0_Function[36] = UnknownOpcode; + Jump_CoP0_Function[37] = UnknownOpcode; + Jump_CoP0_Function[38] = UnknownOpcode; + Jump_CoP0_Function[39] = UnknownOpcode; + Jump_CoP0_Function[40] = UnknownOpcode; + Jump_CoP0_Function[41] = UnknownOpcode; + Jump_CoP0_Function[42] = UnknownOpcode; + Jump_CoP0_Function[43] = UnknownOpcode; + Jump_CoP0_Function[44] = UnknownOpcode; + Jump_CoP0_Function[45] = UnknownOpcode; + Jump_CoP0_Function[46] = UnknownOpcode; + Jump_CoP0_Function[47] = UnknownOpcode; + Jump_CoP0_Function[48] = UnknownOpcode; + Jump_CoP0_Function[49] = UnknownOpcode; + Jump_CoP0_Function[50] = UnknownOpcode; + Jump_CoP0_Function[51] = UnknownOpcode; + Jump_CoP0_Function[52] = UnknownOpcode; + Jump_CoP0_Function[53] = UnknownOpcode; + Jump_CoP0_Function[54] = UnknownOpcode; + Jump_CoP0_Function[55] = UnknownOpcode; + Jump_CoP0_Function[56] = UnknownOpcode; + Jump_CoP0_Function[57] = UnknownOpcode; + Jump_CoP0_Function[58] = UnknownOpcode; + Jump_CoP0_Function[59] = UnknownOpcode; + Jump_CoP0_Function[60] = UnknownOpcode; + Jump_CoP0_Function[61] = UnknownOpcode; + Jump_CoP0_Function[62] = UnknownOpcode; + Jump_CoP0_Function[63] = UnknownOpcode; - Jump_CoP1_S[ 0] = COP1_S_ADD; - Jump_CoP1_S[ 1] = COP1_S_SUB; - Jump_CoP1_S[ 2] = COP1_S_MUL; - Jump_CoP1_S[ 3] = COP1_S_DIV; - Jump_CoP1_S[ 4] = COP1_S_SQRT; - Jump_CoP1_S[ 5] = COP1_S_ABS; - Jump_CoP1_S[ 6] = COP1_S_MOV; - Jump_CoP1_S[ 7] = COP1_S_NEG; - Jump_CoP1_S[ 8] = UnknownOpcode; - Jump_CoP1_S[ 9] = COP1_S_TRUNC_L; - Jump_CoP1_S[10] = COP1_S_CEIL_L; //added by Witten - Jump_CoP1_S[11] = COP1_S_FLOOR_L; //added by Witten - Jump_CoP1_S[12] = COP1_S_ROUND_W; - Jump_CoP1_S[13] = COP1_S_TRUNC_W; - Jump_CoP1_S[14] = COP1_S_CEIL_W; //added by Witten - Jump_CoP1_S[15] = COP1_S_FLOOR_W; - Jump_CoP1_S[16] = UnknownOpcode; - Jump_CoP1_S[17] = UnknownOpcode; - Jump_CoP1_S[18] = UnknownOpcode; - Jump_CoP1_S[19] = UnknownOpcode; - Jump_CoP1_S[20] = UnknownOpcode; - Jump_CoP1_S[21] = UnknownOpcode; - Jump_CoP1_S[22] = UnknownOpcode; - Jump_CoP1_S[23] = UnknownOpcode; - Jump_CoP1_S[24] = UnknownOpcode; - Jump_CoP1_S[25] = UnknownOpcode; - Jump_CoP1_S[26] = UnknownOpcode; - Jump_CoP1_S[27] = UnknownOpcode; - Jump_CoP1_S[28] = UnknownOpcode; - Jump_CoP1_S[29] = UnknownOpcode; - Jump_CoP1_S[30] = UnknownOpcode; - Jump_CoP1_S[31] = UnknownOpcode; - Jump_CoP1_S[32] = UnknownOpcode; - Jump_CoP1_S[33] = COP1_S_CVT_D; - Jump_CoP1_S[34] = UnknownOpcode; - Jump_CoP1_S[35] = UnknownOpcode; - Jump_CoP1_S[36] = COP1_S_CVT_W; - Jump_CoP1_S[37] = COP1_S_CVT_L; - Jump_CoP1_S[38] = UnknownOpcode; - Jump_CoP1_S[39] = UnknownOpcode; - Jump_CoP1_S[40] = UnknownOpcode; - Jump_CoP1_S[41] = UnknownOpcode; - Jump_CoP1_S[42] = UnknownOpcode; - Jump_CoP1_S[43] = UnknownOpcode; - Jump_CoP1_S[44] = UnknownOpcode; - Jump_CoP1_S[45] = UnknownOpcode; - Jump_CoP1_S[46] = UnknownOpcode; - Jump_CoP1_S[47] = UnknownOpcode; - Jump_CoP1_S[48] = COP1_S_CMP; - Jump_CoP1_S[49] = COP1_S_CMP; - Jump_CoP1_S[50] = COP1_S_CMP; - Jump_CoP1_S[51] = COP1_S_CMP; - Jump_CoP1_S[52] = COP1_S_CMP; - Jump_CoP1_S[53] = COP1_S_CMP; - Jump_CoP1_S[54] = COP1_S_CMP; - Jump_CoP1_S[55] = COP1_S_CMP; - Jump_CoP1_S[56] = COP1_S_CMP; - Jump_CoP1_S[57] = COP1_S_CMP; - Jump_CoP1_S[58] = COP1_S_CMP; - Jump_CoP1_S[59] = COP1_S_CMP; - Jump_CoP1_S[60] = COP1_S_CMP; - Jump_CoP1_S[61] = COP1_S_CMP; - Jump_CoP1_S[62] = COP1_S_CMP; - Jump_CoP1_S[63] = COP1_S_CMP; + Jump_CoP1[ 0] = COP1_MF; + Jump_CoP1[ 1] = COP1_DMF; + Jump_CoP1[ 2] = COP1_CF; + Jump_CoP1[ 3] = UnknownOpcode; + Jump_CoP1[ 4] = COP1_MT; + Jump_CoP1[ 5] = COP1_DMT; + Jump_CoP1[ 6] = COP1_CT; + Jump_CoP1[ 7] = UnknownOpcode; + Jump_CoP1[ 8] = COP1_BC; + Jump_CoP1[ 9] = UnknownOpcode; + Jump_CoP1[10] = UnknownOpcode; + Jump_CoP1[11] = UnknownOpcode; + Jump_CoP1[12] = UnknownOpcode; + Jump_CoP1[13] = UnknownOpcode; + Jump_CoP1[14] = UnknownOpcode; + Jump_CoP1[15] = UnknownOpcode; + Jump_CoP1[16] = COP1_S; + Jump_CoP1[17] = COP1_D; + Jump_CoP1[18] = UnknownOpcode; + Jump_CoP1[19] = UnknownOpcode; + Jump_CoP1[20] = COP1_W; + Jump_CoP1[21] = COP1_L; + Jump_CoP1[22] = UnknownOpcode; + Jump_CoP1[23] = UnknownOpcode; + Jump_CoP1[24] = UnknownOpcode; + Jump_CoP1[25] = UnknownOpcode; + Jump_CoP1[26] = UnknownOpcode; + Jump_CoP1[27] = UnknownOpcode; + Jump_CoP1[28] = UnknownOpcode; + Jump_CoP1[29] = UnknownOpcode; + Jump_CoP1[30] = UnknownOpcode; + Jump_CoP1[31] = UnknownOpcode; - Jump_CoP1_D[ 0] = COP1_D_ADD; - Jump_CoP1_D[ 1] = COP1_D_SUB; - Jump_CoP1_D[ 2] = COP1_D_MUL; - Jump_CoP1_D[ 3] = COP1_D_DIV; - Jump_CoP1_D[ 4] = COP1_D_SQRT; - Jump_CoP1_D[ 5] = COP1_D_ABS; - Jump_CoP1_D[ 6] = COP1_D_MOV; - Jump_CoP1_D[ 7] = COP1_D_NEG; - Jump_CoP1_D[ 8] = UnknownOpcode; - Jump_CoP1_D[ 9] = COP1_D_TRUNC_L; //added by Witten - Jump_CoP1_D[10] = COP1_D_CEIL_L; //added by Witten - Jump_CoP1_D[11] = COP1_D_FLOOR_L; //added by Witten - Jump_CoP1_D[12] = COP1_D_ROUND_W; - Jump_CoP1_D[13] = COP1_D_TRUNC_W; - Jump_CoP1_D[14] = COP1_D_CEIL_W; //added by Witten - Jump_CoP1_D[15] = COP1_D_FLOOR_W; //added by Witten - Jump_CoP1_D[16] = UnknownOpcode; - Jump_CoP1_D[17] = UnknownOpcode; - Jump_CoP1_D[18] = UnknownOpcode; - Jump_CoP1_D[19] = UnknownOpcode; - Jump_CoP1_D[20] = UnknownOpcode; - Jump_CoP1_D[21] = UnknownOpcode; - Jump_CoP1_D[22] = UnknownOpcode; - Jump_CoP1_D[23] = UnknownOpcode; - Jump_CoP1_D[24] = UnknownOpcode; - Jump_CoP1_D[25] = UnknownOpcode; - Jump_CoP1_D[26] = UnknownOpcode; - Jump_CoP1_D[27] = UnknownOpcode; - Jump_CoP1_D[28] = UnknownOpcode; - Jump_CoP1_D[29] = UnknownOpcode; - Jump_CoP1_D[30] = UnknownOpcode; - Jump_CoP1_D[31] = UnknownOpcode; - Jump_CoP1_D[32] = COP1_D_CVT_S; - Jump_CoP1_D[33] = UnknownOpcode; - Jump_CoP1_D[34] = UnknownOpcode; - Jump_CoP1_D[35] = UnknownOpcode; - Jump_CoP1_D[36] = COP1_D_CVT_W; - Jump_CoP1_D[37] = COP1_D_CVT_L; - Jump_CoP1_D[38] = UnknownOpcode; - Jump_CoP1_D[39] = UnknownOpcode; - Jump_CoP1_D[40] = UnknownOpcode; - Jump_CoP1_D[41] = UnknownOpcode; - Jump_CoP1_D[42] = UnknownOpcode; - Jump_CoP1_D[43] = UnknownOpcode; - Jump_CoP1_D[44] = UnknownOpcode; - Jump_CoP1_D[45] = UnknownOpcode; - Jump_CoP1_D[46] = UnknownOpcode; - Jump_CoP1_D[47] = UnknownOpcode; - Jump_CoP1_D[48] = COP1_D_CMP; - Jump_CoP1_D[49] = COP1_D_CMP; - Jump_CoP1_D[50] = COP1_D_CMP; - Jump_CoP1_D[51] = COP1_D_CMP; - Jump_CoP1_D[52] = COP1_D_CMP; - Jump_CoP1_D[53] = COP1_D_CMP; - Jump_CoP1_D[54] = COP1_D_CMP; - Jump_CoP1_D[55] = COP1_D_CMP; - Jump_CoP1_D[56] = COP1_D_CMP; - Jump_CoP1_D[57] = COP1_D_CMP; - Jump_CoP1_D[58] = COP1_D_CMP; - Jump_CoP1_D[59] = COP1_D_CMP; - Jump_CoP1_D[60] = COP1_D_CMP; - Jump_CoP1_D[61] = COP1_D_CMP; - Jump_CoP1_D[62] = COP1_D_CMP; - Jump_CoP1_D[63] = COP1_D_CMP; + Jump_CoP1_BC[ 0] = COP1_BCF; + Jump_CoP1_BC[ 1] = COP1_BCT; + Jump_CoP1_BC[ 2] = COP1_BCFL; + Jump_CoP1_BC[ 3] = COP1_BCTL; + Jump_CoP1_BC[ 4] = UnknownOpcode; + Jump_CoP1_BC[ 5] = UnknownOpcode; + Jump_CoP1_BC[ 6] = UnknownOpcode; + Jump_CoP1_BC[ 7] = UnknownOpcode; + Jump_CoP1_BC[ 8] = UnknownOpcode; + Jump_CoP1_BC[ 9] = UnknownOpcode; + Jump_CoP1_BC[10] = UnknownOpcode; + Jump_CoP1_BC[11] = UnknownOpcode; + Jump_CoP1_BC[12] = UnknownOpcode; + Jump_CoP1_BC[13] = UnknownOpcode; + Jump_CoP1_BC[14] = UnknownOpcode; + Jump_CoP1_BC[15] = UnknownOpcode; + Jump_CoP1_BC[16] = UnknownOpcode; + Jump_CoP1_BC[17] = UnknownOpcode; + Jump_CoP1_BC[18] = UnknownOpcode; + Jump_CoP1_BC[19] = UnknownOpcode; + Jump_CoP1_BC[20] = UnknownOpcode; + Jump_CoP1_BC[21] = UnknownOpcode; + Jump_CoP1_BC[22] = UnknownOpcode; + Jump_CoP1_BC[23] = UnknownOpcode; + Jump_CoP1_BC[24] = UnknownOpcode; + Jump_CoP1_BC[25] = UnknownOpcode; + Jump_CoP1_BC[26] = UnknownOpcode; + Jump_CoP1_BC[27] = UnknownOpcode; + Jump_CoP1_BC[28] = UnknownOpcode; + Jump_CoP1_BC[29] = UnknownOpcode; + Jump_CoP1_BC[30] = UnknownOpcode; + Jump_CoP1_BC[31] = UnknownOpcode; - Jump_CoP1_W[ 0] = UnknownOpcode; - Jump_CoP1_W[ 1] = UnknownOpcode; - Jump_CoP1_W[ 2] = UnknownOpcode; - Jump_CoP1_W[ 3] = UnknownOpcode; - Jump_CoP1_W[ 4] = UnknownOpcode; - Jump_CoP1_W[ 5] = UnknownOpcode; - Jump_CoP1_W[ 6] = UnknownOpcode; - Jump_CoP1_W[ 7] = UnknownOpcode; - Jump_CoP1_W[ 8] = UnknownOpcode; - Jump_CoP1_W[ 9] = UnknownOpcode; - Jump_CoP1_W[10] = UnknownOpcode; - Jump_CoP1_W[11] = UnknownOpcode; - Jump_CoP1_W[12] = UnknownOpcode; - Jump_CoP1_W[13] = UnknownOpcode; - Jump_CoP1_W[14] = UnknownOpcode; - Jump_CoP1_W[15] = UnknownOpcode; - Jump_CoP1_W[16] = UnknownOpcode; - Jump_CoP1_W[17] = UnknownOpcode; - Jump_CoP1_W[18] = UnknownOpcode; - Jump_CoP1_W[19] = UnknownOpcode; - Jump_CoP1_W[20] = UnknownOpcode; - Jump_CoP1_W[21] = UnknownOpcode; - Jump_CoP1_W[22] = UnknownOpcode; - Jump_CoP1_W[23] = UnknownOpcode; - Jump_CoP1_W[24] = UnknownOpcode; - Jump_CoP1_W[25] = UnknownOpcode; - Jump_CoP1_W[26] = UnknownOpcode; - Jump_CoP1_W[27] = UnknownOpcode; - Jump_CoP1_W[28] = UnknownOpcode; - Jump_CoP1_W[29] = UnknownOpcode; - Jump_CoP1_W[30] = UnknownOpcode; - Jump_CoP1_W[31] = UnknownOpcode; - Jump_CoP1_W[32] = COP1_W_CVT_S; - Jump_CoP1_W[33] = COP1_W_CVT_D; - Jump_CoP1_W[34] = UnknownOpcode; - Jump_CoP1_W[35] = UnknownOpcode; - Jump_CoP1_W[36] = UnknownOpcode; - Jump_CoP1_W[37] = UnknownOpcode; - Jump_CoP1_W[38] = UnknownOpcode; - Jump_CoP1_W[39] = UnknownOpcode; - Jump_CoP1_W[40] = UnknownOpcode; - Jump_CoP1_W[41] = UnknownOpcode; - Jump_CoP1_W[42] = UnknownOpcode; - Jump_CoP1_W[43] = UnknownOpcode; - Jump_CoP1_W[44] = UnknownOpcode; - Jump_CoP1_W[45] = UnknownOpcode; - Jump_CoP1_W[46] = UnknownOpcode; - Jump_CoP1_W[47] = UnknownOpcode; - Jump_CoP1_W[48] = UnknownOpcode; - Jump_CoP1_W[49] = UnknownOpcode; - Jump_CoP1_W[50] = UnknownOpcode; - Jump_CoP1_W[51] = UnknownOpcode; - Jump_CoP1_W[52] = UnknownOpcode; - Jump_CoP1_W[53] = UnknownOpcode; - Jump_CoP1_W[54] = UnknownOpcode; - Jump_CoP1_W[55] = UnknownOpcode; - Jump_CoP1_W[56] = UnknownOpcode; - Jump_CoP1_W[57] = UnknownOpcode; - Jump_CoP1_W[58] = UnknownOpcode; - Jump_CoP1_W[59] = UnknownOpcode; - Jump_CoP1_W[60] = UnknownOpcode; - Jump_CoP1_W[61] = UnknownOpcode; - Jump_CoP1_W[62] = UnknownOpcode; - Jump_CoP1_W[63] = UnknownOpcode; + Jump_CoP1_S[ 0] = COP1_S_ADD; + Jump_CoP1_S[ 1] = COP1_S_SUB; + Jump_CoP1_S[ 2] = COP1_S_MUL; + Jump_CoP1_S[ 3] = COP1_S_DIV; + Jump_CoP1_S[ 4] = COP1_S_SQRT; + Jump_CoP1_S[ 5] = COP1_S_ABS; + Jump_CoP1_S[ 6] = COP1_S_MOV; + Jump_CoP1_S[ 7] = COP1_S_NEG; + Jump_CoP1_S[ 8] = UnknownOpcode; + Jump_CoP1_S[ 9] = COP1_S_TRUNC_L; + Jump_CoP1_S[10] = COP1_S_CEIL_L; //added by Witten + Jump_CoP1_S[11] = COP1_S_FLOOR_L; //added by Witten + Jump_CoP1_S[12] = COP1_S_ROUND_W; + Jump_CoP1_S[13] = COP1_S_TRUNC_W; + Jump_CoP1_S[14] = COP1_S_CEIL_W; //added by Witten + Jump_CoP1_S[15] = COP1_S_FLOOR_W; + Jump_CoP1_S[16] = UnknownOpcode; + Jump_CoP1_S[17] = UnknownOpcode; + Jump_CoP1_S[18] = UnknownOpcode; + Jump_CoP1_S[19] = UnknownOpcode; + Jump_CoP1_S[20] = UnknownOpcode; + Jump_CoP1_S[21] = UnknownOpcode; + Jump_CoP1_S[22] = UnknownOpcode; + Jump_CoP1_S[23] = UnknownOpcode; + Jump_CoP1_S[24] = UnknownOpcode; + Jump_CoP1_S[25] = UnknownOpcode; + Jump_CoP1_S[26] = UnknownOpcode; + Jump_CoP1_S[27] = UnknownOpcode; + Jump_CoP1_S[28] = UnknownOpcode; + Jump_CoP1_S[29] = UnknownOpcode; + Jump_CoP1_S[30] = UnknownOpcode; + Jump_CoP1_S[31] = UnknownOpcode; + Jump_CoP1_S[32] = UnknownOpcode; + Jump_CoP1_S[33] = COP1_S_CVT_D; + Jump_CoP1_S[34] = UnknownOpcode; + Jump_CoP1_S[35] = UnknownOpcode; + Jump_CoP1_S[36] = COP1_S_CVT_W; + Jump_CoP1_S[37] = COP1_S_CVT_L; + Jump_CoP1_S[38] = UnknownOpcode; + Jump_CoP1_S[39] = UnknownOpcode; + Jump_CoP1_S[40] = UnknownOpcode; + Jump_CoP1_S[41] = UnknownOpcode; + Jump_CoP1_S[42] = UnknownOpcode; + Jump_CoP1_S[43] = UnknownOpcode; + Jump_CoP1_S[44] = UnknownOpcode; + Jump_CoP1_S[45] = UnknownOpcode; + Jump_CoP1_S[46] = UnknownOpcode; + Jump_CoP1_S[47] = UnknownOpcode; + Jump_CoP1_S[48] = COP1_S_CMP; + Jump_CoP1_S[49] = COP1_S_CMP; + Jump_CoP1_S[50] = COP1_S_CMP; + Jump_CoP1_S[51] = COP1_S_CMP; + Jump_CoP1_S[52] = COP1_S_CMP; + Jump_CoP1_S[53] = COP1_S_CMP; + Jump_CoP1_S[54] = COP1_S_CMP; + Jump_CoP1_S[55] = COP1_S_CMP; + Jump_CoP1_S[56] = COP1_S_CMP; + Jump_CoP1_S[57] = COP1_S_CMP; + Jump_CoP1_S[58] = COP1_S_CMP; + Jump_CoP1_S[59] = COP1_S_CMP; + Jump_CoP1_S[60] = COP1_S_CMP; + Jump_CoP1_S[61] = COP1_S_CMP; + Jump_CoP1_S[62] = COP1_S_CMP; + Jump_CoP1_S[63] = COP1_S_CMP; - Jump_CoP1_L[ 0] = UnknownOpcode; - Jump_CoP1_L[ 1] = UnknownOpcode; - Jump_CoP1_L[ 2] = UnknownOpcode; - Jump_CoP1_L[ 3] = UnknownOpcode; - Jump_CoP1_L[ 4] = UnknownOpcode; - Jump_CoP1_L[ 5] = UnknownOpcode; - Jump_CoP1_L[ 6] = UnknownOpcode; - Jump_CoP1_L[ 7] = UnknownOpcode; - Jump_CoP1_L[ 8] = UnknownOpcode; - Jump_CoP1_L[ 9] = UnknownOpcode; - Jump_CoP1_L[10] = UnknownOpcode; - Jump_CoP1_L[11] = UnknownOpcode; - Jump_CoP1_L[12] = UnknownOpcode; - Jump_CoP1_L[13] = UnknownOpcode; - Jump_CoP1_L[14] = UnknownOpcode; - Jump_CoP1_L[15] = UnknownOpcode; - Jump_CoP1_L[16] = UnknownOpcode; - Jump_CoP1_L[17] = UnknownOpcode; - Jump_CoP1_L[18] = UnknownOpcode; - Jump_CoP1_L[19] = UnknownOpcode; - Jump_CoP1_L[20] = UnknownOpcode; - Jump_CoP1_L[21] = UnknownOpcode; - Jump_CoP1_L[22] = UnknownOpcode; - Jump_CoP1_L[23] = UnknownOpcode; - Jump_CoP1_L[24] = UnknownOpcode; - Jump_CoP1_L[25] = UnknownOpcode; - Jump_CoP1_L[26] = UnknownOpcode; - Jump_CoP1_L[27] = UnknownOpcode; - Jump_CoP1_L[28] = UnknownOpcode; - Jump_CoP1_L[29] = UnknownOpcode; - Jump_CoP1_L[30] = UnknownOpcode; - Jump_CoP1_L[31] = UnknownOpcode; - Jump_CoP1_L[32] = COP1_L_CVT_S; - Jump_CoP1_L[33] = COP1_L_CVT_D; - Jump_CoP1_L[34] = UnknownOpcode; - Jump_CoP1_L[35] = UnknownOpcode; - Jump_CoP1_L[36] = UnknownOpcode; - Jump_CoP1_L[37] = UnknownOpcode; - Jump_CoP1_L[38] = UnknownOpcode; - Jump_CoP1_L[39] = UnknownOpcode; - Jump_CoP1_L[40] = UnknownOpcode; - Jump_CoP1_L[41] = UnknownOpcode; - Jump_CoP1_L[42] = UnknownOpcode; - Jump_CoP1_L[43] = UnknownOpcode; - Jump_CoP1_L[44] = UnknownOpcode; - Jump_CoP1_L[45] = UnknownOpcode; - Jump_CoP1_L[46] = UnknownOpcode; - Jump_CoP1_L[47] = UnknownOpcode; - Jump_CoP1_L[48] = UnknownOpcode; - Jump_CoP1_L[49] = UnknownOpcode; - Jump_CoP1_L[50] = UnknownOpcode; - Jump_CoP1_L[51] = UnknownOpcode; - Jump_CoP1_L[52] = UnknownOpcode; - Jump_CoP1_L[53] = UnknownOpcode; - Jump_CoP1_L[54] = UnknownOpcode; - Jump_CoP1_L[55] = UnknownOpcode; - Jump_CoP1_L[56] = UnknownOpcode; - Jump_CoP1_L[57] = UnknownOpcode; - Jump_CoP1_L[58] = UnknownOpcode; - Jump_CoP1_L[59] = UnknownOpcode; - Jump_CoP1_L[60] = UnknownOpcode; - Jump_CoP1_L[61] = UnknownOpcode; - Jump_CoP1_L[62] = UnknownOpcode; - Jump_CoP1_L[63] = UnknownOpcode; + Jump_CoP1_D[ 0] = COP1_D_ADD; + Jump_CoP1_D[ 1] = COP1_D_SUB; + Jump_CoP1_D[ 2] = COP1_D_MUL; + Jump_CoP1_D[ 3] = COP1_D_DIV; + Jump_CoP1_D[ 4] = COP1_D_SQRT; + Jump_CoP1_D[ 5] = COP1_D_ABS; + Jump_CoP1_D[ 6] = COP1_D_MOV; + Jump_CoP1_D[ 7] = COP1_D_NEG; + Jump_CoP1_D[ 8] = UnknownOpcode; + Jump_CoP1_D[ 9] = COP1_D_TRUNC_L; //added by Witten + Jump_CoP1_D[10] = COP1_D_CEIL_L; //added by Witten + Jump_CoP1_D[11] = COP1_D_FLOOR_L; //added by Witten + Jump_CoP1_D[12] = COP1_D_ROUND_W; + Jump_CoP1_D[13] = COP1_D_TRUNC_W; + Jump_CoP1_D[14] = COP1_D_CEIL_W; //added by Witten + Jump_CoP1_D[15] = COP1_D_FLOOR_W; //added by Witten + Jump_CoP1_D[16] = UnknownOpcode; + Jump_CoP1_D[17] = UnknownOpcode; + Jump_CoP1_D[18] = UnknownOpcode; + Jump_CoP1_D[19] = UnknownOpcode; + Jump_CoP1_D[20] = UnknownOpcode; + Jump_CoP1_D[21] = UnknownOpcode; + Jump_CoP1_D[22] = UnknownOpcode; + Jump_CoP1_D[23] = UnknownOpcode; + Jump_CoP1_D[24] = UnknownOpcode; + Jump_CoP1_D[25] = UnknownOpcode; + Jump_CoP1_D[26] = UnknownOpcode; + Jump_CoP1_D[27] = UnknownOpcode; + Jump_CoP1_D[28] = UnknownOpcode; + Jump_CoP1_D[29] = UnknownOpcode; + Jump_CoP1_D[30] = UnknownOpcode; + Jump_CoP1_D[31] = UnknownOpcode; + Jump_CoP1_D[32] = COP1_D_CVT_S; + Jump_CoP1_D[33] = UnknownOpcode; + Jump_CoP1_D[34] = UnknownOpcode; + Jump_CoP1_D[35] = UnknownOpcode; + Jump_CoP1_D[36] = COP1_D_CVT_W; + Jump_CoP1_D[37] = COP1_D_CVT_L; + Jump_CoP1_D[38] = UnknownOpcode; + Jump_CoP1_D[39] = UnknownOpcode; + Jump_CoP1_D[40] = UnknownOpcode; + Jump_CoP1_D[41] = UnknownOpcode; + Jump_CoP1_D[42] = UnknownOpcode; + Jump_CoP1_D[43] = UnknownOpcode; + Jump_CoP1_D[44] = UnknownOpcode; + Jump_CoP1_D[45] = UnknownOpcode; + Jump_CoP1_D[46] = UnknownOpcode; + Jump_CoP1_D[47] = UnknownOpcode; + Jump_CoP1_D[48] = COP1_D_CMP; + Jump_CoP1_D[49] = COP1_D_CMP; + Jump_CoP1_D[50] = COP1_D_CMP; + Jump_CoP1_D[51] = COP1_D_CMP; + Jump_CoP1_D[52] = COP1_D_CMP; + Jump_CoP1_D[53] = COP1_D_CMP; + Jump_CoP1_D[54] = COP1_D_CMP; + Jump_CoP1_D[55] = COP1_D_CMP; + Jump_CoP1_D[56] = COP1_D_CMP; + Jump_CoP1_D[57] = COP1_D_CMP; + Jump_CoP1_D[58] = COP1_D_CMP; + Jump_CoP1_D[59] = COP1_D_CMP; + Jump_CoP1_D[60] = COP1_D_CMP; + Jump_CoP1_D[61] = COP1_D_CMP; + Jump_CoP1_D[62] = COP1_D_CMP; + Jump_CoP1_D[63] = COP1_D_CMP; - return Jump_Opcode; + Jump_CoP1_W[ 0] = UnknownOpcode; + Jump_CoP1_W[ 1] = UnknownOpcode; + Jump_CoP1_W[ 2] = UnknownOpcode; + Jump_CoP1_W[ 3] = UnknownOpcode; + Jump_CoP1_W[ 4] = UnknownOpcode; + Jump_CoP1_W[ 5] = UnknownOpcode; + Jump_CoP1_W[ 6] = UnknownOpcode; + Jump_CoP1_W[ 7] = UnknownOpcode; + Jump_CoP1_W[ 8] = UnknownOpcode; + Jump_CoP1_W[ 9] = UnknownOpcode; + Jump_CoP1_W[10] = UnknownOpcode; + Jump_CoP1_W[11] = UnknownOpcode; + Jump_CoP1_W[12] = UnknownOpcode; + Jump_CoP1_W[13] = UnknownOpcode; + Jump_CoP1_W[14] = UnknownOpcode; + Jump_CoP1_W[15] = UnknownOpcode; + Jump_CoP1_W[16] = UnknownOpcode; + Jump_CoP1_W[17] = UnknownOpcode; + Jump_CoP1_W[18] = UnknownOpcode; + Jump_CoP1_W[19] = UnknownOpcode; + Jump_CoP1_W[20] = UnknownOpcode; + Jump_CoP1_W[21] = UnknownOpcode; + Jump_CoP1_W[22] = UnknownOpcode; + Jump_CoP1_W[23] = UnknownOpcode; + Jump_CoP1_W[24] = UnknownOpcode; + Jump_CoP1_W[25] = UnknownOpcode; + Jump_CoP1_W[26] = UnknownOpcode; + Jump_CoP1_W[27] = UnknownOpcode; + Jump_CoP1_W[28] = UnknownOpcode; + Jump_CoP1_W[29] = UnknownOpcode; + Jump_CoP1_W[30] = UnknownOpcode; + Jump_CoP1_W[31] = UnknownOpcode; + Jump_CoP1_W[32] = COP1_W_CVT_S; + Jump_CoP1_W[33] = COP1_W_CVT_D; + Jump_CoP1_W[34] = UnknownOpcode; + Jump_CoP1_W[35] = UnknownOpcode; + Jump_CoP1_W[36] = UnknownOpcode; + Jump_CoP1_W[37] = UnknownOpcode; + Jump_CoP1_W[38] = UnknownOpcode; + Jump_CoP1_W[39] = UnknownOpcode; + Jump_CoP1_W[40] = UnknownOpcode; + Jump_CoP1_W[41] = UnknownOpcode; + Jump_CoP1_W[42] = UnknownOpcode; + Jump_CoP1_W[43] = UnknownOpcode; + Jump_CoP1_W[44] = UnknownOpcode; + Jump_CoP1_W[45] = UnknownOpcode; + Jump_CoP1_W[46] = UnknownOpcode; + Jump_CoP1_W[47] = UnknownOpcode; + Jump_CoP1_W[48] = UnknownOpcode; + Jump_CoP1_W[49] = UnknownOpcode; + Jump_CoP1_W[50] = UnknownOpcode; + Jump_CoP1_W[51] = UnknownOpcode; + Jump_CoP1_W[52] = UnknownOpcode; + Jump_CoP1_W[53] = UnknownOpcode; + Jump_CoP1_W[54] = UnknownOpcode; + Jump_CoP1_W[55] = UnknownOpcode; + Jump_CoP1_W[56] = UnknownOpcode; + Jump_CoP1_W[57] = UnknownOpcode; + Jump_CoP1_W[58] = UnknownOpcode; + Jump_CoP1_W[59] = UnknownOpcode; + Jump_CoP1_W[60] = UnknownOpcode; + Jump_CoP1_W[61] = UnknownOpcode; + Jump_CoP1_W[62] = UnknownOpcode; + Jump_CoP1_W[63] = UnknownOpcode; + + Jump_CoP1_L[ 0] = UnknownOpcode; + Jump_CoP1_L[ 1] = UnknownOpcode; + Jump_CoP1_L[ 2] = UnknownOpcode; + Jump_CoP1_L[ 3] = UnknownOpcode; + Jump_CoP1_L[ 4] = UnknownOpcode; + Jump_CoP1_L[ 5] = UnknownOpcode; + Jump_CoP1_L[ 6] = UnknownOpcode; + Jump_CoP1_L[ 7] = UnknownOpcode; + Jump_CoP1_L[ 8] = UnknownOpcode; + Jump_CoP1_L[ 9] = UnknownOpcode; + Jump_CoP1_L[10] = UnknownOpcode; + Jump_CoP1_L[11] = UnknownOpcode; + Jump_CoP1_L[12] = UnknownOpcode; + Jump_CoP1_L[13] = UnknownOpcode; + Jump_CoP1_L[14] = UnknownOpcode; + Jump_CoP1_L[15] = UnknownOpcode; + Jump_CoP1_L[16] = UnknownOpcode; + Jump_CoP1_L[17] = UnknownOpcode; + Jump_CoP1_L[18] = UnknownOpcode; + Jump_CoP1_L[19] = UnknownOpcode; + Jump_CoP1_L[20] = UnknownOpcode; + Jump_CoP1_L[21] = UnknownOpcode; + Jump_CoP1_L[22] = UnknownOpcode; + Jump_CoP1_L[23] = UnknownOpcode; + Jump_CoP1_L[24] = UnknownOpcode; + Jump_CoP1_L[25] = UnknownOpcode; + Jump_CoP1_L[26] = UnknownOpcode; + Jump_CoP1_L[27] = UnknownOpcode; + Jump_CoP1_L[28] = UnknownOpcode; + Jump_CoP1_L[29] = UnknownOpcode; + Jump_CoP1_L[30] = UnknownOpcode; + Jump_CoP1_L[31] = UnknownOpcode; + Jump_CoP1_L[32] = COP1_L_CVT_S; + Jump_CoP1_L[33] = COP1_L_CVT_D; + Jump_CoP1_L[34] = UnknownOpcode; + Jump_CoP1_L[35] = UnknownOpcode; + Jump_CoP1_L[36] = UnknownOpcode; + Jump_CoP1_L[37] = UnknownOpcode; + Jump_CoP1_L[38] = UnknownOpcode; + Jump_CoP1_L[39] = UnknownOpcode; + Jump_CoP1_L[40] = UnknownOpcode; + Jump_CoP1_L[41] = UnknownOpcode; + Jump_CoP1_L[42] = UnknownOpcode; + Jump_CoP1_L[43] = UnknownOpcode; + Jump_CoP1_L[44] = UnknownOpcode; + Jump_CoP1_L[45] = UnknownOpcode; + Jump_CoP1_L[46] = UnknownOpcode; + Jump_CoP1_L[47] = UnknownOpcode; + Jump_CoP1_L[48] = UnknownOpcode; + Jump_CoP1_L[49] = UnknownOpcode; + Jump_CoP1_L[50] = UnknownOpcode; + Jump_CoP1_L[51] = UnknownOpcode; + Jump_CoP1_L[52] = UnknownOpcode; + Jump_CoP1_L[53] = UnknownOpcode; + Jump_CoP1_L[54] = UnknownOpcode; + Jump_CoP1_L[55] = UnknownOpcode; + Jump_CoP1_L[56] = UnknownOpcode; + Jump_CoP1_L[57] = UnknownOpcode; + Jump_CoP1_L[58] = UnknownOpcode; + Jump_CoP1_L[59] = UnknownOpcode; + Jump_CoP1_L[60] = UnknownOpcode; + Jump_CoP1_L[61] = UnknownOpcode; + Jump_CoP1_L[62] = UnknownOpcode; + Jump_CoP1_L[63] = UnknownOpcode; + + return Jump_Opcode; } -bool DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2); +bool DelaySlotEffectsCompare (uint32_t PC, uint32_t Reg1, uint32_t Reg2); -void TestInterpreterJump (DWORD PC, DWORD TargetPC, int Reg1, int Reg2) +void TestInterpreterJump (uint32_t PC, uint32_t TargetPC, int32_t Reg1, int32_t Reg2) { - if (PC != TargetPC) - { - return; - } - if (DelaySlotEffectsCompare(PC,Reg1,Reg2)) - { - return; - } - R4300iOp::m_NextInstruction = PERMLOOP_DO_DELAY; - R4300iOp::m_TestTimer = true; + if (PC != TargetPC) + { + return; + } + if (DelaySlotEffectsCompare(PC,Reg1,Reg2)) + { + return; + } + R4300iOp::m_NextInstruction = PERMLOOP_DO_DELAY; + R4300iOp::m_TestTimer = true; } /************************* Opcode functions *************************/ void R4300iOp::J() { - m_NextInstruction = DELAY_SLOT; - m_JumpToLocation = ((*_PROGRAM_COUNTER) & 0xF0000000) + (m_Opcode.target << 2); - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - m_NextInstruction = PERMLOOP_DO_DELAY; - } + m_NextInstruction = DELAY_SLOT; + m_JumpToLocation = ((*_PROGRAM_COUNTER) & 0xF0000000) + (m_Opcode.target << 2); + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + m_NextInstruction = PERMLOOP_DO_DELAY; + } } void R4300iOp::JAL() { - m_NextInstruction = DELAY_SLOT; - m_JumpToLocation = ((*_PROGRAM_COUNTER) & 0xF0000000) + (m_Opcode.target << 2); - _GPR[31].DW= (long)((*_PROGRAM_COUNTER) + 8); + m_NextInstruction = DELAY_SLOT; + m_JumpToLocation = ((*_PROGRAM_COUNTER) & 0xF0000000) + (m_Opcode.target << 2); + _GPR[31].DW= (int32_t)((*_PROGRAM_COUNTER) + 8); - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - m_NextInstruction = PERMLOOP_DO_DELAY; - } + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + m_NextInstruction = PERMLOOP_DO_DELAY; + } } void R4300iOp::BEQ() { - m_NextInstruction = DELAY_SLOT; - if (_GPR[m_Opcode.rs].DW == _GPR[m_Opcode.rt].DW) - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) - { - m_NextInstruction = PERMLOOP_DO_DELAY; - } - } - } - else - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + m_NextInstruction = DELAY_SLOT; + if (_GPR[m_Opcode.rs].DW == _GPR[m_Opcode.rt].DW) + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) + { + m_NextInstruction = PERMLOOP_DO_DELAY; + } + } + } + else + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp::BNE() { - m_NextInstruction = DELAY_SLOT; - if (_GPR[m_Opcode.rs].DW != _GPR[m_Opcode.rt].DW) - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) - { - m_NextInstruction = PERMLOOP_DO_DELAY; - } - } - } - else - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + m_NextInstruction = DELAY_SLOT; + if (_GPR[m_Opcode.rs].DW != _GPR[m_Opcode.rt].DW) + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) + { + m_NextInstruction = PERMLOOP_DO_DELAY; + } + } + } + else + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp::BLEZ() { - m_NextInstruction = DELAY_SLOT; - if (_GPR[m_Opcode.rs].DW <= 0) - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) - { - m_NextInstruction = PERMLOOP_DO_DELAY; - } - } - } - else - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + m_NextInstruction = DELAY_SLOT; + if (_GPR[m_Opcode.rs].DW <= 0) + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) + { + m_NextInstruction = PERMLOOP_DO_DELAY; + } + } + } + else + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp::BGTZ() { - m_NextInstruction = DELAY_SLOT; - if (_GPR[m_Opcode.rs].DW > 0) - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) - { - m_NextInstruction = PERMLOOP_DO_DELAY; - } - } - } - else - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + m_NextInstruction = DELAY_SLOT; + if (_GPR[m_Opcode.rs].DW > 0) + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) + { + m_NextInstruction = PERMLOOP_DO_DELAY; + } + } + } + else + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp::ADDI() { #ifdef Interpreter_StackTest - if (m_Opcode.rs == 29 && m_Opcode.rt == 29) - { - StackValue += (short)m_Opcode.immediate; - } + if (m_Opcode.rs == 29 && m_Opcode.rt == 29) + { + StackValue += (int16_t)m_Opcode.immediate; + } #endif - _GPR[m_Opcode.rt].DW = (_GPR[m_Opcode.rs].W[0] + ((short)m_Opcode.immediate)); + _GPR[m_Opcode.rt].DW = (_GPR[m_Opcode.rs].W[0] + ((int16_t)m_Opcode.immediate)); #ifdef Interpreter_StackTest - if (m_Opcode.rt == 29 && m_Opcode.rs != 29) - { - StackValue = _GPR[m_Opcode.rt].W[0]; - } + if (m_Opcode.rt == 29 && m_Opcode.rs != 29) + { + StackValue = _GPR[m_Opcode.rt].W[0]; + } #endif } void R4300iOp::ADDIU() { #ifdef Interpreter_StackTest - if (m_Opcode.rs == 29 && m_Opcode.rt == 29) - { - StackValue += (short)m_Opcode.immediate; - } + if (m_Opcode.rs == 29 && m_Opcode.rt == 29) + { + StackValue += (int16_t)m_Opcode.immediate; + } #endif - _GPR[m_Opcode.rt].DW = (_GPR[m_Opcode.rs].W[0] + ((short)m_Opcode.immediate)); + _GPR[m_Opcode.rt].DW = (_GPR[m_Opcode.rs].W[0] + ((int16_t)m_Opcode.immediate)); #ifdef Interpreter_StackTest - if (m_Opcode.rt == 29 && m_Opcode.rs != 29) - { - StackValue = _GPR[m_Opcode.rt].W[0]; - } + if (m_Opcode.rt == 29 && m_Opcode.rs != 29) + { + StackValue = _GPR[m_Opcode.rt].W[0]; + } #endif } void R4300iOp::SLTI() { - if (_GPR[m_Opcode.rs].DW < (__int64)((short)m_Opcode.immediate)) - { - _GPR[m_Opcode.rt].DW = 1; - } - else - { - _GPR[m_Opcode.rt].DW = 0; - } + if (_GPR[m_Opcode.rs].DW < (int64_t)((int16_t)m_Opcode.immediate)) + { + _GPR[m_Opcode.rt].DW = 1; + } + else + { + _GPR[m_Opcode.rt].DW = 0; + } } void R4300iOp::SLTIU() { - int imm32 = (short)m_Opcode.immediate; - __int64 imm64; + int32_t imm32 = (int16_t)m_Opcode.immediate; + int64_t imm64; - imm64 = imm32; - _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rs].UDW < (unsigned __int64)imm64?1:0; + imm64 = imm32; + _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rs].UDW < (uint64_t)imm64?1:0; } void R4300iOp::ANDI() { - _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rs].DW & m_Opcode.immediate; + _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rs].DW & m_Opcode.immediate; } void R4300iOp::ORI() { - _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rs].DW | m_Opcode.immediate; + _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rs].DW | m_Opcode.immediate; } void R4300iOp::XORI() { - _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rs].DW ^ m_Opcode.immediate; + _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rs].DW ^ m_Opcode.immediate; } void R4300iOp::LUI() { - _GPR[m_Opcode.rt].DW = (long)((short)m_Opcode.offset << 16); + _GPR[m_Opcode.rt].DW = (int32_t)((int16_t)m_Opcode.offset << 16); #ifdef Interpreter_StackTest - if (m_Opcode.rt == 29) - { - StackValue = _GPR[m_Opcode.rt].W[0]; - } + if (m_Opcode.rt == 29) + { + StackValue = _GPR[m_Opcode.rt].W[0]; + } #endif } void R4300iOp::BEQL() { - if (_GPR[m_Opcode.rs].DW == _GPR[m_Opcode.rt].DW) - { - m_NextInstruction = DELAY_SLOT; - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) - { - m_NextInstruction = PERMLOOP_DO_DELAY; - } - } - } - else - { - m_NextInstruction = JUMP; - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + if (_GPR[m_Opcode.rs].DW == _GPR[m_Opcode.rt].DW) + { + m_NextInstruction = DELAY_SLOT; + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) + { + m_NextInstruction = PERMLOOP_DO_DELAY; + } + } + } + else + { + m_NextInstruction = JUMP; + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp::BNEL() { - if (_GPR[m_Opcode.rs].DW != _GPR[m_Opcode.rt].DW) - { - m_NextInstruction = DELAY_SLOT; - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) - { - m_NextInstruction = PERMLOOP_DO_DELAY; - } - } - } - else - { - m_NextInstruction = JUMP; - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + if (_GPR[m_Opcode.rs].DW != _GPR[m_Opcode.rt].DW) + { + m_NextInstruction = DELAY_SLOT; + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) + { + m_NextInstruction = PERMLOOP_DO_DELAY; + } + } + } + else + { + m_NextInstruction = JUMP; + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp::BLEZL() { - if (_GPR[m_Opcode.rs].DW <= 0) - { - m_NextInstruction = DELAY_SLOT; - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) - { - m_NextInstruction = PERMLOOP_DO_DELAY; - } - } - } - else - { - m_NextInstruction = JUMP; - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + if (_GPR[m_Opcode.rs].DW <= 0) + { + m_NextInstruction = DELAY_SLOT; + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) + { + m_NextInstruction = PERMLOOP_DO_DELAY; + } + } + } + else + { + m_NextInstruction = JUMP; + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp::BGTZL() { - if (_GPR[m_Opcode.rs].DW > 0) - { - m_NextInstruction = DELAY_SLOT; - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) - { - m_NextInstruction = PERMLOOP_DO_DELAY; - } - } - } - else - { - m_NextInstruction = JUMP; - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + if (_GPR[m_Opcode.rs].DW > 0) + { + m_NextInstruction = DELAY_SLOT; + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) + { + m_NextInstruction = PERMLOOP_DO_DELAY; + } + } + } + else + { + m_NextInstruction = JUMP; + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp::DADDIU() { - _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rs].DW + (__int64)((short)m_Opcode.immediate); + _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rs].DW + (int64_t)((int16_t)m_Opcode.immediate); } -QWORD LDL_MASK[8] = { 0,0xFF,0xFFFF,0xFFFFFF,0xFFFFFFFF,0xFFFFFFFFFF, - 0xFFFFFFFFFFFF, 0xFFFFFFFFFFFFFF }; -int LDL_SHIFT[8] = { 0, 8, 16, 24, 32, 40, 48, 56 }; +uint64_t LDL_MASK[8] = { 0,0xFF,0xFFFF,0xFFFFFF,0xFFFFFFFF,0xFFFFFFFFFF, 0xFFFFFFFFFFFF, 0xFFFFFFFFFFFFFF }; +int32_t LDL_SHIFT[8] = { 0, 8, 16, 24, 32, 40, 48, 56 }; void R4300iOp::LDL() { - DWORD Offset, Address; - QWORD Value; - - Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - Offset = Address & 7; + uint32_t Offset, Address; + uint64_t Value; - if (!g_MMU->LD_VAddr((Address & ~7),Value)) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - return; - } - _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rt].DW & LDL_MASK[Offset]; - _GPR[m_Opcode.rt].DW += Value << LDL_SHIFT[Offset]; + Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + Offset = Address & 7; + + if (!g_MMU->LD_VAddr((Address & ~7),Value)) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + return; + } + _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rt].DW & LDL_MASK[Offset]; + _GPR[m_Opcode.rt].DW += Value << LDL_SHIFT[Offset]; } -QWORD LDR_MASK[8] = { 0xFFFFFFFFFFFFFF00, 0xFFFFFFFFFFFF0000, - 0xFFFFFFFFFF000000, 0xFFFFFFFF00000000, - 0xFFFFFF0000000000, 0xFFFF000000000000, - 0xFF00000000000000, 0 }; -int LDR_SHIFT[8] = { 56, 48, 40, 32, 24, 16, 8, 0 }; +uint64_t LDR_MASK[8] = { 0xFFFFFFFFFFFFFF00, 0xFFFFFFFFFFFF0000, + 0xFFFFFFFFFF000000, 0xFFFFFFFF00000000, + 0xFFFFFF0000000000, 0xFFFF000000000000, + 0xFF00000000000000, 0 }; +int32_t LDR_SHIFT[8] = { 56, 48, 40, 32, 24, 16, 8, 0 }; void R4300iOp::LDR() { - DWORD Offset, Address; - QWORD Value; - - Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - Offset = Address & 7; + uint32_t Offset, Address; + uint64_t Value; - if (!g_MMU->LD_VAddr((Address & ~7),Value)) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - return; - } + Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + Offset = Address & 7; - _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rt].DW & LDR_MASK[Offset]; - _GPR[m_Opcode.rt].DW += Value >> LDR_SHIFT[Offset]; + if (!g_MMU->LD_VAddr((Address & ~7),Value)) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + return; + } + _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rt].DW & LDR_MASK[Offset]; + _GPR[m_Opcode.rt].DW += Value >> LDR_SHIFT[Offset]; } void R4300iOp::LB() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - if (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0])) - { - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - TLB_READ_EXCEPTION(Address); - } - else - { - _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rt].B[0]; - } + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0])) + { + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + TLB_READ_EXCEPTION(Address); + } + else + { + _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rt].B[0]; + } } void R4300iOp::LH() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - if ((Address & 1) != 0) - { - ADDRESS_ERROR_EXCEPTION(Address, true); - } - if (!g_MMU->LH_VAddr(Address,_GPR[m_Opcode.rt].UHW[0])) - { - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - TLB_READ_EXCEPTION(Address); - } - else - { - _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rt].HW[0]; - } + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if ((Address & 1) != 0) + { + ADDRESS_ERROR_EXCEPTION(Address, true); + } + if (!g_MMU->LH_VAddr(Address,_GPR[m_Opcode.rt].UHW[0])) + { + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + TLB_READ_EXCEPTION(Address); + } + else + { + _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rt].HW[0]; + } } void R4300iOp::LWL() { - DWORD Offset, Address, Value; - - Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - Offset = Address & 3; + uint32_t Offset, Address, Value; - if (!g_MMU->LW_VAddr((Address & ~3),(uint32_t &)Value)) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - return; - } - - _GPR[m_Opcode.rt].DW = (int)(_GPR[m_Opcode.rt].W[0] & LWL_MASK[Offset]); - _GPR[m_Opcode.rt].DW += (int)(Value << LWL_SHIFT[Offset]); + Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + Offset = Address & 3; + + if (!g_MMU->LW_VAddr((Address & ~3),Value)) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + return; + } + + _GPR[m_Opcode.rt].DW = (int32_t)(_GPR[m_Opcode.rt].W[0] & LWL_MASK[Offset]); + _GPR[m_Opcode.rt].DW += (int32_t)(Value << LWL_SHIFT[Offset]); } void R4300iOp::LW() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - if ((Address & 3) != 0) - { - ADDRESS_ERROR_EXCEPTION(Address, true); - } + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if ((Address & 3) != 0) + { + ADDRESS_ERROR_EXCEPTION(Address, true); + } - if (g_LogOptions.GenerateLog) - { - Log_LW((*_PROGRAM_COUNTER),Address); - } + if (g_LogOptions.GenerateLog) + { + Log_LW((*_PROGRAM_COUNTER),Address); + } - if (!g_MMU->LW_VAddr(Address,(uint32_t &)_GPR[m_Opcode.rt].UW[0])) - { - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - TLB_READ_EXCEPTION(Address); - } - else - { - _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rt].W[0]; - } + if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + { + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + TLB_READ_EXCEPTION(Address); + } + else + { + _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rt].W[0]; + } } void R4300iOp::LBU() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - if (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0])) - { - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - TLB_READ_EXCEPTION(Address); - } - else - { - _GPR[m_Opcode.rt].UDW = _GPR[m_Opcode.rt].UB[0]; - } + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0])) + { + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + TLB_READ_EXCEPTION(Address); + } + else + { + _GPR[m_Opcode.rt].UDW = _GPR[m_Opcode.rt].UB[0]; + } } void R4300iOp::LHU() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - if ((Address & 1) != 0) - { - ADDRESS_ERROR_EXCEPTION(Address, true); - } - if (!g_MMU->LH_VAddr(Address,_GPR[m_Opcode.rt].UHW[0])) - { - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - TLB_READ_EXCEPTION(Address); - } - else - { - _GPR[m_Opcode.rt].UDW = _GPR[m_Opcode.rt].UHW[0]; - } + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if ((Address & 1) != 0) + { + ADDRESS_ERROR_EXCEPTION(Address, true); + } + if (!g_MMU->LH_VAddr(Address,_GPR[m_Opcode.rt].UHW[0])) + { + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + TLB_READ_EXCEPTION(Address); + } + else + { + _GPR[m_Opcode.rt].UDW = _GPR[m_Opcode.rt].UHW[0]; + } } void R4300iOp::LWR() { - DWORD Offset, Address, Value; - - Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - Offset = Address & 3; + uint32_t Offset, Address, Value; - if (!g_MMU->LW_VAddr((Address & ~3),(uint32_t &)Value)) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - return; - } - - _GPR[m_Opcode.rt].DW = (int)(_GPR[m_Opcode.rt].W[0] & LWR_MASK[Offset]); - _GPR[m_Opcode.rt].DW += (int)(Value >> LWR_SHIFT[Offset]); + Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + Offset = Address & 3; + + if (!g_MMU->LW_VAddr((Address & ~3),Value)) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + return; + } + + _GPR[m_Opcode.rt].DW = (int32_t)(_GPR[m_Opcode.rt].W[0] & LWR_MASK[Offset]); + _GPR[m_Opcode.rt].DW += (int32_t)(Value >> LWR_SHIFT[Offset]); } void R4300iOp::LWU() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - if ((Address & 3) != 0) - { - ADDRESS_ERROR_EXCEPTION(Address, true); - } + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if ((Address & 3) != 0) + { + ADDRESS_ERROR_EXCEPTION(Address, true); + } - if (!g_MMU->LW_VAddr(Address,(uint32_t &)_GPR[m_Opcode.rt].UW[0])) - { - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - TLB_READ_EXCEPTION(Address); - } - else - { - _GPR[m_Opcode.rt].UDW = _GPR[m_Opcode.rt].UW[0]; - } + if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + { + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + TLB_READ_EXCEPTION(Address); + } + else + { + _GPR[m_Opcode.rt].UDW = _GPR[m_Opcode.rt].UW[0]; + } } -void R4300iOp::SB() +void R4300iOp::SB() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - if (!g_MMU->SB_VAddr(Address,_GPR[m_Opcode.rt].UB[0])) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - } + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if (!g_MMU->SB_VAddr(Address,_GPR[m_Opcode.rt].UB[0])) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + } } void R4300iOp::SH() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - if ((Address & 1) != 0) - { - ADDRESS_ERROR_EXCEPTION(Address, false); - } - if (!g_MMU->SH_VAddr(Address,_GPR[m_Opcode.rt].UHW[0])) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - } + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if ((Address & 1) != 0) + { + ADDRESS_ERROR_EXCEPTION(Address, false); + } + if (!g_MMU->SH_VAddr(Address,_GPR[m_Opcode.rt].UHW[0])) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + } } void R4300iOp::SWL() { - DWORD Offset, Address, Value; - - Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - Offset = Address & 3; + uint32_t Offset, Address, Value; - if (!g_MMU->LW_VAddr((Address & ~3),(uint32_t &)Value)) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - return; - } - - Value &= SWL_MASK[Offset]; - Value += _GPR[m_Opcode.rt].UW[0] >> SWL_SHIFT[Offset]; + Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + Offset = Address & 3; - if (!g_MMU->SW_VAddr((Address & ~0x03),Value)) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - } + if (!g_MMU->LW_VAddr((Address & ~3),Value)) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + return; + } + + Value &= SWL_MASK[Offset]; + Value += _GPR[m_Opcode.rt].UW[0] >> SWL_SHIFT[Offset]; + + if (!g_MMU->SW_VAddr((Address & ~0x03),Value)) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + } } - void R4300iOp::SW() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - if ((Address & 3) != 0) - { - ADDRESS_ERROR_EXCEPTION(Address, false); - } - if (g_LogOptions.GenerateLog) - { - Log_SW((*_PROGRAM_COUNTER),Address,_GPR[m_Opcode.rt].UW[0]); - } - if (!g_MMU->SW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - } + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if ((Address & 3) != 0) + { + ADDRESS_ERROR_EXCEPTION(Address, false); + } + if (g_LogOptions.GenerateLog) + { + Log_SW((*_PROGRAM_COUNTER),Address,_GPR[m_Opcode.rt].UW[0]); + } + if (!g_MMU->SW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + } } -QWORD SDL_MASK[8] = { 0,0xFF00000000000000, - 0xFFFF000000000000, - 0xFFFFFF0000000000, - 0xFFFFFFFF00000000, - 0xFFFFFFFFFF000000, - 0xFFFFFFFFFFFF0000, - 0xFFFFFFFFFFFFFF00 }; +uint64_t SDL_MASK[8] = { 0,0xFF00000000000000, + 0xFFFF000000000000, + 0xFFFFFF0000000000, + 0xFFFFFFFF00000000, + 0xFFFFFFFFFF000000, + 0xFFFFFFFFFFFF0000, + 0xFFFFFFFFFFFFFF00 }; -int SDL_SHIFT[8] = { 0, 8, 16, 24, 32, 40, 48, 56 }; +int32_t SDL_SHIFT[8] = { 0, 8, 16, 24, 32, 40, 48, 56 }; void R4300iOp::SDL() { - DWORD Offset, Address; - QWORD Value; - - Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - Offset = Address & 7; + uint32_t Offset, Address; + uint64_t Value; - if (!g_MMU->LD_VAddr((Address & ~7),Value)) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - return; - } - - Value &= SDL_MASK[Offset]; - Value += _GPR[m_Opcode.rt].UDW >> SDL_SHIFT[Offset]; + Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + Offset = Address & 7; - if (!g_MMU->SD_VAddr((Address & ~7),Value)) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - } + if (!g_MMU->LD_VAddr((Address & ~7),Value)) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + return; + } + + Value &= SDL_MASK[Offset]; + Value += _GPR[m_Opcode.rt].UDW >> SDL_SHIFT[Offset]; + + if (!g_MMU->SD_VAddr((Address & ~7),Value)) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + } } -QWORD SDR_MASK[8] = { 0x00FFFFFFFFFFFFFF, - 0x0000FFFFFFFFFFFF, - 0x000000FFFFFFFFFF, - 0x00000000FFFFFFFF, - 0x0000000000FFFFFF, - 0x000000000000FFFF, - 0x00000000000000FF, - 0x0000000000000000 }; +uint64_t SDR_MASK[8] = { 0x00FFFFFFFFFFFFFF, + 0x0000FFFFFFFFFFFF, + 0x000000FFFFFFFFFF, + 0x00000000FFFFFFFF, + 0x0000000000FFFFFF, + 0x000000000000FFFF, + 0x00000000000000FF, + 0x0000000000000000 }; -int SDR_SHIFT[8] = { 56,48,40,32,24,16,8,0 }; +int32_t SDR_SHIFT[8] = { 56,48,40,32,24,16,8,0 }; void R4300iOp::SDR() { - DWORD Offset, Address; - QWORD Value; - - Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - Offset = Address & 7; + uint32_t Offset, Address; + uint64_t Value; - if (!g_MMU->LD_VAddr((Address & ~7),Value)) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - return; - } - - Value &= SDR_MASK[Offset]; - Value += _GPR[m_Opcode.rt].UDW << SDR_SHIFT[Offset]; + Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + Offset = Address & 7; - if (!g_MMU->SD_VAddr((Address & ~7),Value)) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - } + if (!g_MMU->LD_VAddr((Address & ~7),Value)) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + return; + } + + Value &= SDR_MASK[Offset]; + Value += _GPR[m_Opcode.rt].UDW << SDR_SHIFT[Offset]; + + if (!g_MMU->SD_VAddr((Address & ~7),Value)) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + } } void R4300iOp::SWR() { - DWORD Offset, Address, Value; - - Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - Offset = Address & 3; + uint32_t Offset, Address, Value; - if (!g_MMU->LW_VAddr((Address & ~3),(uint32_t &)Value)) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - return; - } - - Value &= SWR_MASK[Offset]; - Value += _GPR[m_Opcode.rt].UW[0] << SWR_SHIFT[Offset]; + Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + Offset = Address & 3; - if (!g_MMU->SW_VAddr((Address & ~0x03),Value)) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - } + if (!g_MMU->LW_VAddr((Address & ~3),Value)) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + return; + } + + Value &= SWR_MASK[Offset]; + Value += _GPR[m_Opcode.rt].UW[0] << SWR_SHIFT[Offset]; + + if (!g_MMU->SW_VAddr((Address & ~0x03),Value)) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + } } -void R4300iOp::CACHE() +void R4300iOp::CACHE() { - if (!g_LogOptions.LogCache) - { - return; - } - LogMessage("%08X: Cache operation %d, 0x%08X", (*_PROGRAM_COUNTER), m_Opcode.rt, - _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset ); + if (!g_LogOptions.LogCache) + { + return; + } + LogMessage("%08X: Cache operation %d, 0x%08X", (*_PROGRAM_COUNTER), m_Opcode.rt, _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset ); } -void R4300iOp::LL() +void R4300iOp::LL() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - if ((Address & 3) != 0) - { - ADDRESS_ERROR_EXCEPTION(Address, true); - } + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if ((Address & 3) != 0) + { + ADDRESS_ERROR_EXCEPTION(Address, true); + } - if (!g_MMU->LW_VAddr(Address,(uint32_t &)_GPR[m_Opcode.rt].UW[0])) - { - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - TLB_READ_EXCEPTION(Address); - } - else - { - _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rt].W[0]; - (*_LLBit) = 1; - } + if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + { + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + TLB_READ_EXCEPTION(Address); + } + else + { + _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rt].W[0]; + (*_LLBit) = 1; + } } -void R4300iOp::LWC1() +void R4300iOp::LWC1() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (DWORD)((short)m_Opcode.offset); - TEST_COP1_USABLE_EXCEPTION - if ((Address & 3) != 0) - { - ADDRESS_ERROR_EXCEPTION(Address, true); - } - if (!g_MMU->LW_VAddr(Address,*(uint32_t *)_FPR_S[m_Opcode.ft])) - { - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - TLB_READ_EXCEPTION(Address); - } + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (uint32_t)((int16_t)m_Opcode.offset); + TEST_COP1_USABLE_EXCEPTION + if ((Address & 3) != 0) + { + ADDRESS_ERROR_EXCEPTION(Address, true); + } + if (!g_MMU->LW_VAddr(Address,*(uint32_t *)_FPR_S[m_Opcode.ft])) + { + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + TLB_READ_EXCEPTION(Address); + } } void R4300iOp::SC() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - if ((Address & 3) != 0) - { - ADDRESS_ERROR_EXCEPTION(Address, false); - } - Log_SW((*_PROGRAM_COUNTER),Address,_GPR[m_Opcode.rt].UW[0]); - if ((*_LLBit) == 1) - { - if (!g_MMU->SW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - } - } - _GPR[m_Opcode.rt].UW[0] = (*_LLBit); + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if ((Address & 3) != 0) + { + ADDRESS_ERROR_EXCEPTION(Address, false); + } + Log_SW((*_PROGRAM_COUNTER),Address,_GPR[m_Opcode.rt].UW[0]); + if ((*_LLBit) == 1) + { + if (!g_MMU->SW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + } + } + _GPR[m_Opcode.rt].UW[0] = (*_LLBit); } void R4300iOp::LD() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - if ((Address & 7) != 0) - { - ADDRESS_ERROR_EXCEPTION(Address, true); - } - if (!g_MMU->LD_VAddr(Address,_GPR[m_Opcode.rt].UDW)) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - return; - } + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if ((Address & 7) != 0) + { + ADDRESS_ERROR_EXCEPTION(Address, true); + } + if (!g_MMU->LD_VAddr(Address,_GPR[m_Opcode.rt].UDW)) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + return; + } #ifdef Interpreter_StackTest - if (m_Opcode.rt == 29) - { - StackValue = _GPR[m_Opcode.rt].W[0]; - } + if (m_Opcode.rt == 29) + { + StackValue = _GPR[m_Opcode.rt].W[0]; + } #endif } - void R4300iOp::LDC1() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; - TEST_COP1_USABLE_EXCEPTION - if ((Address & 7) != 0) - { - ADDRESS_ERROR_EXCEPTION(Address, true); - } - if (!g_MMU->LD_VAddr(Address,*(unsigned __int64 *)_FPR_D[m_Opcode.ft])) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - } + TEST_COP1_USABLE_EXCEPTION + if ((Address & 7) != 0) + { + ADDRESS_ERROR_EXCEPTION(Address, true); + } + if (!g_MMU->LD_VAddr(Address,*(uint64_t *)_FPR_D[m_Opcode.ft])) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + } } void R4300iOp::SWC1() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - TEST_COP1_USABLE_EXCEPTION - if ((Address & 3) != 0) - { - ADDRESS_ERROR_EXCEPTION(Address, false); - } + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + TEST_COP1_USABLE_EXCEPTION + if ((Address & 3) != 0) + { + ADDRESS_ERROR_EXCEPTION(Address, false); + } - if (!g_MMU->SW_VAddr(Address,*(DWORD *)_FPR_S[m_Opcode.ft])) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - } + if (!g_MMU->SW_VAddr(Address,*(uint32_t *)_FPR_S[m_Opcode.ft])) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + } } void R4300iOp::SDC1() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; - TEST_COP1_USABLE_EXCEPTION - if ((Address & 7) != 0) - { - ADDRESS_ERROR_EXCEPTION(Address, false); - } - if (!g_MMU->SD_VAddr(Address,*(__int64 *)_FPR_D[m_Opcode.ft])) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - } + TEST_COP1_USABLE_EXCEPTION + if ((Address & 7) != 0) + { + ADDRESS_ERROR_EXCEPTION(Address, false); + } + if (!g_MMU->SD_VAddr(Address,*(int64_t *)_FPR_D[m_Opcode.ft])) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + } } -void R4300iOp::SD() +void R4300iOp::SD() { - DWORD Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset; - if ((Address & 7) != 0) - { - ADDRESS_ERROR_EXCEPTION(Address, false); - } - if (!g_MMU->SD_VAddr(Address,_GPR[m_Opcode.rt].UDW)) - { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - } + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if ((Address & 7) != 0) + { + ADDRESS_ERROR_EXCEPTION(Address, false); + } + if (!g_MMU->SD_VAddr(Address,_GPR[m_Opcode.rt].UDW)) + { + if (bHaveDebugger()) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + } } /********************** R4300i OpCodes: Special **********************/ void R4300iOp::SPECIAL_SLL() { - _GPR[m_Opcode.rd].DW = (_GPR[m_Opcode.rt].W[0] << m_Opcode.sa); + _GPR[m_Opcode.rd].DW = (_GPR[m_Opcode.rt].W[0] << m_Opcode.sa); } void R4300iOp::SPECIAL_SRL() { - _GPR[m_Opcode.rd].DW = (int)(_GPR[m_Opcode.rt].UW[0] >> m_Opcode.sa); + _GPR[m_Opcode.rd].DW = (int32_t)(_GPR[m_Opcode.rt].UW[0] >> m_Opcode.sa); } void R4300iOp::SPECIAL_SRA() { - _GPR[m_Opcode.rd].DW = (_GPR[m_Opcode.rt].W[0] >> m_Opcode.sa); + _GPR[m_Opcode.rd].DW = (_GPR[m_Opcode.rt].W[0] >> m_Opcode.sa); } void R4300iOp::SPECIAL_SLLV() { - _GPR[m_Opcode.rd].DW = (_GPR[m_Opcode.rt].W[0] << (_GPR[m_Opcode.rs].UW[0] & 0x1F)); + _GPR[m_Opcode.rd].DW = (_GPR[m_Opcode.rt].W[0] << (_GPR[m_Opcode.rs].UW[0] & 0x1F)); } void R4300iOp::SPECIAL_SRLV() { - _GPR[m_Opcode.rd].DW = (int)(_GPR[m_Opcode.rt].UW[0] >> (_GPR[m_Opcode.rs].UW[0] & 0x1F)); + _GPR[m_Opcode.rd].DW = (int32_t)(_GPR[m_Opcode.rt].UW[0] >> (_GPR[m_Opcode.rs].UW[0] & 0x1F)); } void R4300iOp::SPECIAL_SRAV() { - _GPR[m_Opcode.rd].DW = (_GPR[m_Opcode.rt].W[0] >> (_GPR[m_Opcode.rs].UW[0] & 0x1F)); + _GPR[m_Opcode.rd].DW = (_GPR[m_Opcode.rt].W[0] >> (_GPR[m_Opcode.rs].UW[0] & 0x1F)); } void R4300iOp::SPECIAL_JR() { - m_NextInstruction = DELAY_SLOT; - m_JumpToLocation = _GPR[m_Opcode.rs].UW[0]; - m_TestTimer = true; + m_NextInstruction = DELAY_SLOT; + m_JumpToLocation = _GPR[m_Opcode.rs].UW[0]; + m_TestTimer = true; } void R4300iOp::SPECIAL_JALR() { - m_NextInstruction = DELAY_SLOT; - m_JumpToLocation = _GPR[m_Opcode.rs].UW[0]; - _GPR[m_Opcode.rd].DW = (long)((*_PROGRAM_COUNTER) + 8); - m_TestTimer = true; + m_NextInstruction = DELAY_SLOT; + m_JumpToLocation = _GPR[m_Opcode.rs].UW[0]; + _GPR[m_Opcode.rd].DW = (int32_t)((*_PROGRAM_COUNTER) + 8); + m_TestTimer = true; } void R4300iOp::SPECIAL_SYSCALL() { - g_Reg->DoSysCallException(m_NextInstruction == JUMP); - m_NextInstruction = JUMP; - m_JumpToLocation = (*_PROGRAM_COUNTER); + g_Reg->DoSysCallException(m_NextInstruction == JUMP); + m_NextInstruction = JUMP; + m_JumpToLocation = (*_PROGRAM_COUNTER); } void R4300iOp::SPECIAL_BREAK() { - g_Reg->DoBreakException(m_NextInstruction == JUMP); - m_NextInstruction = JUMP; - m_JumpToLocation = (*_PROGRAM_COUNTER); + g_Reg->DoBreakException(m_NextInstruction == JUMP); + m_NextInstruction = JUMP; + m_JumpToLocation = (*_PROGRAM_COUNTER); } void R4300iOp::SPECIAL_SYNC() { - } void R4300iOp::SPECIAL_MFHI() { - _GPR[m_Opcode.rd].DW = _RegHI->DW; + _GPR[m_Opcode.rd].DW = _RegHI->DW; } void R4300iOp::SPECIAL_MTHI() { - _RegHI->DW = _GPR[m_Opcode.rs].DW; + _RegHI->DW = _GPR[m_Opcode.rs].DW; } void R4300iOp::SPECIAL_MFLO() { - _GPR[m_Opcode.rd].DW = _RegLO->DW; + _GPR[m_Opcode.rd].DW = _RegLO->DW; } void R4300iOp::SPECIAL_MTLO() { - _RegLO->DW = _GPR[m_Opcode.rs].DW; + _RegLO->DW = _GPR[m_Opcode.rs].DW; } void R4300iOp::SPECIAL_DSLLV() { - _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rt].DW << (_GPR[m_Opcode.rs].UW[0] & 0x3F); + _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rt].DW << (_GPR[m_Opcode.rs].UW[0] & 0x3F); } void R4300iOp::SPECIAL_DSRLV() { - _GPR[m_Opcode.rd].UDW = _GPR[m_Opcode.rt].UDW >> (_GPR[m_Opcode.rs].UW[0] & 0x3F); + _GPR[m_Opcode.rd].UDW = _GPR[m_Opcode.rt].UDW >> (_GPR[m_Opcode.rs].UW[0] & 0x3F); } void R4300iOp::SPECIAL_DSRAV() { - _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rt].DW >> (_GPR[m_Opcode.rs].UW[0] & 0x3F); + _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rt].DW >> (_GPR[m_Opcode.rs].UW[0] & 0x3F); } void R4300iOp::SPECIAL_MULT() { - _RegHI->DW = (__int64)(_GPR[m_Opcode.rs].W[0]) * (__int64)(_GPR[m_Opcode.rt].W[0]); - _RegLO->DW = _RegHI->W[0]; - _RegHI->DW = _RegHI->W[1]; + _RegHI->DW = (int64_t)(_GPR[m_Opcode.rs].W[0]) * (int64_t)(_GPR[m_Opcode.rt].W[0]); + _RegLO->DW = _RegHI->W[0]; + _RegHI->DW = _RegHI->W[1]; } void R4300iOp::SPECIAL_MULTU() { - _RegHI->DW = (unsigned __int64)(_GPR[m_Opcode.rs].UW[0]) * (unsigned __int64)(_GPR[m_Opcode.rt].UW[0]); - _RegLO->DW = _RegHI->W[0]; - _RegHI->DW = _RegHI->W[1]; + _RegHI->DW = (uint64_t)(_GPR[m_Opcode.rs].UW[0]) * (uint64_t)(_GPR[m_Opcode.rt].UW[0]); + _RegLO->DW = _RegHI->W[0]; + _RegHI->DW = _RegHI->W[1]; } void R4300iOp::SPECIAL_DIV() { - if ( _GPR[m_Opcode.rt].UDW != 0 ) - { - _RegLO->DW = _GPR[m_Opcode.rs].W[0] / _GPR[m_Opcode.rt].W[0]; - _RegHI->DW = _GPR[m_Opcode.rs].W[0] % _GPR[m_Opcode.rt].W[0]; - } - else - { - if (bShowDivByZero()) - { - g_Notify->DisplayError(L"DIV by 0 ???"); - } - _RegLO->DW = 0; - _RegHI->DW = 0; - } + if ( _GPR[m_Opcode.rt].UDW != 0 ) + { + _RegLO->DW = _GPR[m_Opcode.rs].W[0] / _GPR[m_Opcode.rt].W[0]; + _RegHI->DW = _GPR[m_Opcode.rs].W[0] % _GPR[m_Opcode.rt].W[0]; + } + else + { + if (bShowDivByZero()) + { + g_Notify->DisplayError(L"DIV by 0 ???"); + } + _RegLO->DW = 0; + _RegHI->DW = 0; + } } void R4300iOp::SPECIAL_DIVU() { - if (_GPR[m_Opcode.rt].UW[0] != 0) - { - _RegLO->DW = (int)(_GPR[m_Opcode.rs].UW[0] / _GPR[m_Opcode.rt].UW[0]); - _RegHI->DW = (int)(_GPR[m_Opcode.rs].UW[0] % _GPR[m_Opcode.rt].UW[0]); - } - else - { - if (bShowDivByZero()) - { - g_Notify->DisplayError(L"DIVU by 0 ???"); - } - _RegLO->DW = 0; - _RegHI->DW = 0; - } + if (_GPR[m_Opcode.rt].UW[0] != 0) + { + _RegLO->DW = (int32_t)(_GPR[m_Opcode.rs].UW[0] / _GPR[m_Opcode.rt].UW[0]); + _RegHI->DW = (int32_t)(_GPR[m_Opcode.rs].UW[0] % _GPR[m_Opcode.rt].UW[0]); + } + else + { + if (bShowDivByZero()) + { + g_Notify->DisplayError(L"DIVU by 0 ???"); + } + _RegLO->DW = 0; + _RegHI->DW = 0; + } } void R4300iOp::SPECIAL_DMULT() { - MIPS_DWORD Tmp[3]; - - _RegLO->UDW = (QWORD)_GPR[m_Opcode.rs].UW[0] * (QWORD)_GPR[m_Opcode.rt].UW[0]; - Tmp[0].UDW = (__int64)_GPR[m_Opcode.rs].W[1] * (__int64)(QWORD)_GPR[m_Opcode.rt].UW[0]; - Tmp[1].UDW = (__int64)(QWORD)_GPR[m_Opcode.rs].UW[0] * (__int64)_GPR[m_Opcode.rt].W[1]; - _RegHI->UDW = (__int64)_GPR[m_Opcode.rs].W[1] * (__int64)_GPR[m_Opcode.rt].W[1]; - - Tmp[2].UDW = (QWORD)_RegLO->UW[1] + (QWORD)Tmp[0].UW[0] + (QWORD)Tmp[1].UW[0]; - _RegLO->UDW += ((QWORD)Tmp[0].UW[0] + (QWORD)Tmp[1].UW[0]) << 32; - _RegHI->UDW += (QWORD)Tmp[0].W[1] + (QWORD)Tmp[1].W[1] + Tmp[2].UW[1]; + MIPS_DWORD Tmp[3]; + + _RegLO->UDW = (uint64_t)_GPR[m_Opcode.rs].UW[0] * (uint64_t)_GPR[m_Opcode.rt].UW[0]; + Tmp[0].UDW = (int64_t)_GPR[m_Opcode.rs].W[1] * (int64_t)(uint64_t)_GPR[m_Opcode.rt].UW[0]; + Tmp[1].UDW = (int64_t)(uint64_t)_GPR[m_Opcode.rs].UW[0] * (int64_t)_GPR[m_Opcode.rt].W[1]; + _RegHI->UDW = (int64_t)_GPR[m_Opcode.rs].W[1] * (int64_t)_GPR[m_Opcode.rt].W[1]; + + Tmp[2].UDW = (uint64_t)_RegLO->UW[1] + (uint64_t)Tmp[0].UW[0] + (uint64_t)Tmp[1].UW[0]; + _RegLO->UDW += ((uint64_t)Tmp[0].UW[0] + (uint64_t)Tmp[1].UW[0]) << 32; + _RegHI->UDW += (uint64_t)Tmp[0].W[1] + (uint64_t)Tmp[1].W[1] + Tmp[2].UW[1]; } -void R4300iOp::SPECIAL_DMULTU() +void R4300iOp::SPECIAL_DMULTU() { - MIPS_DWORD Tmp[3]; - - _RegLO->UDW = (QWORD)_GPR[m_Opcode.rs].UW[0] * (QWORD)_GPR[m_Opcode.rt].UW[0]; - Tmp[0].UDW = (QWORD)_GPR[m_Opcode.rs].UW[1] * (QWORD)_GPR[m_Opcode.rt].UW[0]; - Tmp[1].UDW = (QWORD)_GPR[m_Opcode.rs].UW[0] * (QWORD)_GPR[m_Opcode.rt].UW[1]; - _RegHI->UDW = (QWORD)_GPR[m_Opcode.rs].UW[1] * (QWORD)_GPR[m_Opcode.rt].UW[1]; - - Tmp[2].UDW = (QWORD)_RegLO->UW[1] + (QWORD)Tmp[0].UW[0] + (QWORD)Tmp[1].UW[0]; - _RegLO->UDW += ((QWORD)Tmp[0].UW[0] + (QWORD)Tmp[1].UW[0]) << 32; - _RegHI->UDW += (QWORD)Tmp[0].UW[1] + (QWORD)Tmp[1].UW[1] + Tmp[2].UW[1]; + MIPS_DWORD Tmp[3]; + + _RegLO->UDW = (uint64_t)_GPR[m_Opcode.rs].UW[0] * (uint64_t)_GPR[m_Opcode.rt].UW[0]; + Tmp[0].UDW = (uint64_t)_GPR[m_Opcode.rs].UW[1] * (uint64_t)_GPR[m_Opcode.rt].UW[0]; + Tmp[1].UDW = (uint64_t)_GPR[m_Opcode.rs].UW[0] * (uint64_t)_GPR[m_Opcode.rt].UW[1]; + _RegHI->UDW = (uint64_t)_GPR[m_Opcode.rs].UW[1] * (uint64_t)_GPR[m_Opcode.rt].UW[1]; + + Tmp[2].UDW = (uint64_t)_RegLO->UW[1] + (uint64_t)Tmp[0].UW[0] + (uint64_t)Tmp[1].UW[0]; + _RegLO->UDW += ((uint64_t)Tmp[0].UW[0] + (uint64_t)Tmp[1].UW[0]) << 32; + _RegHI->UDW += (uint64_t)Tmp[0].UW[1] + (uint64_t)Tmp[1].UW[1] + Tmp[2].UW[1]; } void R4300iOp::SPECIAL_DDIV() { - if ( _GPR[m_Opcode.rt].UDW != 0 ) - { - _RegLO->DW = _GPR[m_Opcode.rs].DW / _GPR[m_Opcode.rt].DW; - _RegHI->DW = _GPR[m_Opcode.rs].DW % _GPR[m_Opcode.rt].DW; - } - else - { - if (bHaveDebugger()) - { - g_Notify->DisplayError(L"DDIV by 0 ???"); - } - } + if ( _GPR[m_Opcode.rt].UDW != 0 ) + { + _RegLO->DW = _GPR[m_Opcode.rs].DW / _GPR[m_Opcode.rt].DW; + _RegHI->DW = _GPR[m_Opcode.rs].DW % _GPR[m_Opcode.rt].DW; + } + else + { + if (bHaveDebugger()) + { + g_Notify->DisplayError(L"DDIV by 0 ???"); + } + } } void R4300iOp::SPECIAL_DDIVU() { - if ( _GPR[m_Opcode.rt].UDW != 0 ) - { - _RegLO->UDW = _GPR[m_Opcode.rs].UDW / _GPR[m_Opcode.rt].UDW; - _RegHI->UDW = _GPR[m_Opcode.rs].UDW % _GPR[m_Opcode.rt].UDW; - } - else - { - if (bHaveDebugger()) - { - g_Notify->DisplayError(L"DDIVU by 0 ???"); - } - } + if ( _GPR[m_Opcode.rt].UDW != 0 ) + { + _RegLO->UDW = _GPR[m_Opcode.rs].UDW / _GPR[m_Opcode.rt].UDW; + _RegHI->UDW = _GPR[m_Opcode.rs].UDW % _GPR[m_Opcode.rt].UDW; + } + else + { + if (bHaveDebugger()) + { + g_Notify->DisplayError(L"DDIVU by 0 ???"); + } + } } void R4300iOp::SPECIAL_ADD() { - _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].W[0] + _GPR[m_Opcode.rt].W[0]; + _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].W[0] + _GPR[m_Opcode.rt].W[0]; } void R4300iOp::SPECIAL_ADDU() { - _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].W[0] + _GPR[m_Opcode.rt].W[0]; + _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].W[0] + _GPR[m_Opcode.rt].W[0]; } void R4300iOp::SPECIAL_SUB() { - _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].W[0] - _GPR[m_Opcode.rt].W[0]; + _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].W[0] - _GPR[m_Opcode.rt].W[0]; } void R4300iOp::SPECIAL_SUBU() { - _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].W[0] - _GPR[m_Opcode.rt].W[0]; + _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].W[0] - _GPR[m_Opcode.rt].W[0]; } void R4300iOp::SPECIAL_AND() { - _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].DW & _GPR[m_Opcode.rt].DW; + _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].DW & _GPR[m_Opcode.rt].DW; } void R4300iOp::SPECIAL_OR() { - _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].DW | _GPR[m_Opcode.rt].DW; + _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].DW | _GPR[m_Opcode.rt].DW; #ifdef Interpreter_StackTest - if (m_Opcode.rd == 29) - { - StackValue = _GPR[m_Opcode.rd].W[0]; - } + if (m_Opcode.rd == 29) + { + StackValue = _GPR[m_Opcode.rd].W[0]; + } #endif } void R4300iOp::SPECIAL_XOR() { - _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].DW ^ _GPR[m_Opcode.rt].DW; + _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].DW ^ _GPR[m_Opcode.rt].DW; } void R4300iOp::SPECIAL_NOR() { - _GPR[m_Opcode.rd].DW = ~(_GPR[m_Opcode.rs].DW | _GPR[m_Opcode.rt].DW); + _GPR[m_Opcode.rd].DW = ~(_GPR[m_Opcode.rs].DW | _GPR[m_Opcode.rt].DW); } void R4300iOp::SPECIAL_SLT() { - if (_GPR[m_Opcode.rs].DW < _GPR[m_Opcode.rt].DW) - { - _GPR[m_Opcode.rd].DW = 1; - } - else - { - _GPR[m_Opcode.rd].DW = 0; - } + if (_GPR[m_Opcode.rs].DW < _GPR[m_Opcode.rt].DW) + { + _GPR[m_Opcode.rd].DW = 1; + } + else + { + _GPR[m_Opcode.rd].DW = 0; + } } void R4300iOp::SPECIAL_SLTU() { - if (_GPR[m_Opcode.rs].UDW < _GPR[m_Opcode.rt].UDW) - { - _GPR[m_Opcode.rd].DW = 1; - } - else - { - _GPR[m_Opcode.rd].DW = 0; - } + if (_GPR[m_Opcode.rs].UDW < _GPR[m_Opcode.rt].UDW) + { + _GPR[m_Opcode.rd].DW = 1; + } + else + { + _GPR[m_Opcode.rd].DW = 0; + } } void R4300iOp::SPECIAL_DADD() { - _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].DW + _GPR[m_Opcode.rt].DW; + _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].DW + _GPR[m_Opcode.rt].DW; } void R4300iOp::SPECIAL_DADDU() { - _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].DW + _GPR[m_Opcode.rt].DW; + _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].DW + _GPR[m_Opcode.rt].DW; } void R4300iOp::SPECIAL_DSUB() { - _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].DW - _GPR[m_Opcode.rt].DW; + _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].DW - _GPR[m_Opcode.rt].DW; } void R4300iOp::SPECIAL_DSUBU() { - _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].DW - _GPR[m_Opcode.rt].DW; + _GPR[m_Opcode.rd].DW = _GPR[m_Opcode.rs].DW - _GPR[m_Opcode.rt].DW; } void R4300iOp::SPECIAL_TEQ() { - if (_GPR[m_Opcode.rs].DW == _GPR[m_Opcode.rt].DW && bHaveDebugger()) - { - g_Notify->DisplayError(L"Should trap this ???"); - } + if (_GPR[m_Opcode.rs].DW == _GPR[m_Opcode.rt].DW && bHaveDebugger()) + { + g_Notify->DisplayError(L"Should trap this ???"); + } } void R4300iOp::SPECIAL_DSLL() { - _GPR[m_Opcode.rd].DW = (_GPR[m_Opcode.rt].DW << m_Opcode.sa); + _GPR[m_Opcode.rd].DW = (_GPR[m_Opcode.rt].DW << m_Opcode.sa); } void R4300iOp::SPECIAL_DSRL() { - _GPR[m_Opcode.rd].UDW = (_GPR[m_Opcode.rt].UDW >> m_Opcode.sa); + _GPR[m_Opcode.rd].UDW = (_GPR[m_Opcode.rt].UDW >> m_Opcode.sa); } void R4300iOp::SPECIAL_DSRA() { - _GPR[m_Opcode.rd].DW = (_GPR[m_Opcode.rt].DW >> m_Opcode.sa); + _GPR[m_Opcode.rd].DW = (_GPR[m_Opcode.rt].DW >> m_Opcode.sa); } void R4300iOp::SPECIAL_DSLL32() { - _GPR[m_Opcode.rd].DW = (_GPR[m_Opcode.rt].DW << (m_Opcode.sa + 32)); + _GPR[m_Opcode.rd].DW = (_GPR[m_Opcode.rt].DW << (m_Opcode.sa + 32)); } void R4300iOp::SPECIAL_DSRL32() { - _GPR[m_Opcode.rd].UDW = (_GPR[m_Opcode.rt].UDW >> (m_Opcode.sa + 32)); + _GPR[m_Opcode.rd].UDW = (_GPR[m_Opcode.rt].UDW >> (m_Opcode.sa + 32)); } void R4300iOp::SPECIAL_DSRA32() { - _GPR[m_Opcode.rd].DW = (_GPR[m_Opcode.rt].DW >> (m_Opcode.sa + 32)); + _GPR[m_Opcode.rd].DW = (_GPR[m_Opcode.rt].DW >> (m_Opcode.sa + 32)); } /********************** R4300i OpCodes: RegImm **********************/ void R4300iOp::REGIMM_BLTZ() { - m_NextInstruction = DELAY_SLOT; - if (_GPR[m_Opcode.rs].DW < 0) - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) - { - CInterpreterCPU::InPermLoop(); - } - } - } - else - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + m_NextInstruction = DELAY_SLOT; + if (_GPR[m_Opcode.rs].DW < 0) + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + { + CInterpreterCPU::InPermLoop(); + } + } + } + else + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp::REGIMM_BGEZ() { - m_NextInstruction = DELAY_SLOT; - if (_GPR[m_Opcode.rs].DW >= 0) - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) - { - CInterpreterCPU::InPermLoop(); - } - } - } - else - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + m_NextInstruction = DELAY_SLOT; + if (_GPR[m_Opcode.rs].DW >= 0) + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + { + CInterpreterCPU::InPermLoop(); + } + } + } + else + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp::REGIMM_BLTZL() { - if (_GPR[m_Opcode.rs].DW < 0) - { - m_NextInstruction = DELAY_SLOT; - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) - { - CInterpreterCPU::InPermLoop(); - } - } - } - else - { - m_NextInstruction = JUMP; - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + if (_GPR[m_Opcode.rs].DW < 0) + { + m_NextInstruction = DELAY_SLOT; + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + { + CInterpreterCPU::InPermLoop(); + } + } + } + else + { + m_NextInstruction = JUMP; + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp::REGIMM_BGEZL() { - if (_GPR[m_Opcode.rs].DW >= 0) - { - m_NextInstruction = DELAY_SLOT; - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) - { - CInterpreterCPU::InPermLoop(); - } - } - } - else - { - m_NextInstruction = JUMP; - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + if (_GPR[m_Opcode.rs].DW >= 0) + { + m_NextInstruction = DELAY_SLOT; + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + { + CInterpreterCPU::InPermLoop(); + } + } + } + else + { + m_NextInstruction = JUMP; + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp::REGIMM_BLTZAL() { - m_NextInstruction = DELAY_SLOT; - if (_GPR[m_Opcode.rs].DW < 0) - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) - { - CInterpreterCPU::InPermLoop(); - } - } - } - else - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } - _GPR[31].DW= (long)((*_PROGRAM_COUNTER) + 8); + m_NextInstruction = DELAY_SLOT; + if (_GPR[m_Opcode.rs].DW < 0) + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + { + CInterpreterCPU::InPermLoop(); + } + } + } + else + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } + _GPR[31].DW= (int32_t)((*_PROGRAM_COUNTER) + 8); } void R4300iOp::REGIMM_BGEZAL() { - m_NextInstruction = DELAY_SLOT; - if (_GPR[m_Opcode.rs].DW >= 0) - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - if ((*_PROGRAM_COUNTER) == m_JumpToLocation) - { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) - { - CInterpreterCPU::InPermLoop(); - } - } - } - else - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } - _GPR[31].DW = (long)((*_PROGRAM_COUNTER) + 8); + m_NextInstruction = DELAY_SLOT; + if (_GPR[m_Opcode.rs].DW >= 0) + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + if ((*_PROGRAM_COUNTER) == m_JumpToLocation) + { + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + { + CInterpreterCPU::InPermLoop(); + } + } + } + else + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } + _GPR[31].DW = (int32_t)((*_PROGRAM_COUNTER) + 8); } /************************** COP0 functions **************************/ -void R4300iOp::COP0_MF() +void R4300iOp::COP0_MF() { - if (g_LogOptions.LogCP0reads) - { - LogMessage("%08X: R4300i Read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); - } + if (g_LogOptions.LogCP0reads) + { + LogMessage("%08X: R4300i Read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); + } - if (m_Opcode.rd == 9) - { - g_SystemTimer->UpdateTimers(); - } - _GPR[m_Opcode.rt].DW = (int)_CP0[m_Opcode.rd]; + if (m_Opcode.rd == 9) + { + g_SystemTimer->UpdateTimers(); + } + _GPR[m_Opcode.rt].DW = (int32_t)_CP0[m_Opcode.rd]; } void R4300iOp::COP0_MT() { - if (g_LogOptions.LogCP0changes) - { - LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)",(*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0],CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); - if (m_Opcode.rd == 11) //Compare - { - LogMessage("%08X: Cause register changed from %08X to %08X",(*_PROGRAM_COUNTER), g_Reg->CAUSE_REGISTER, (g_Reg->CAUSE_REGISTER & ~CAUSE_IP7)); - } - } + if (g_LogOptions.LogCP0changes) + { + LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)",(*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0],CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); + if (m_Opcode.rd == 11) //Compare + { + LogMessage("%08X: Cause register changed from %08X to %08X",(*_PROGRAM_COUNTER), g_Reg->CAUSE_REGISTER, (g_Reg->CAUSE_REGISTER & ~CAUSE_IP7)); + } + } - switch (m_Opcode.rd) - { - case 0: //Index - case 2: //EntryLo0 - case 3: //EntryLo1 - case 5: //PageMask - case 10: //Entry Hi - case 14: //EPC - case 16: //Config - case 18: //WatchLo - case 19: //WatchHi - case 28: //Tag lo - case 29: //Tag Hi - case 30: //ErrEPC - _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; - break; - case 6: //Wired - g_SystemTimer->UpdateTimers(); - _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; - break; - case 4: //Context - _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0] & 0xFF800000; - break; - case 9: //Count - g_SystemTimer->UpdateTimers(); - _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; - g_SystemTimer->UpdateCompareTimer(); - break; - case 11: //Compare - g_SystemTimer->UpdateTimers(); - _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; - g_Reg->FAKE_CAUSE_REGISTER &= ~CAUSE_IP7; - g_SystemTimer->UpdateCompareTimer(); - break; - case 12: //Status - if ((_CP0[m_Opcode.rd] & STATUS_FR) != (_GPR[m_Opcode.rt].UW[0] & STATUS_FR)) - { - _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; - g_Reg->FixFpuLocations(); - } - else - { - _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; - } - if ((_CP0[m_Opcode.rd] & 0x18) != 0 && bHaveDebugger()) - { - g_Notify->DisplayError(L"Left kernel mode ??"); - } - g_Reg->CheckInterrupts(); - break; - case 13: //cause - _CP0[m_Opcode.rd] &= 0xFFFFCFF; - if ((_GPR[m_Opcode.rt].UW[0] & 0x300) != 0 && bHaveDebugger()) - { - g_Notify->DisplayError(L"Set IP0 or IP1"); - } - break; - default: - UnknownOpcode(); - } + switch (m_Opcode.rd) + { + case 0: //Index + case 2: //EntryLo0 + case 3: //EntryLo1 + case 5: //PageMask + case 10: //Entry Hi + case 14: //EPC + case 16: //Config + case 18: //WatchLo + case 19: //WatchHi + case 28: //Tag lo + case 29: //Tag Hi + case 30: //ErrEPC + _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; + break; + case 6: //Wired + g_SystemTimer->UpdateTimers(); + _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; + break; + case 4: //Context + _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0] & 0xFF800000; + break; + case 9: //Count + g_SystemTimer->UpdateTimers(); + _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; + g_SystemTimer->UpdateCompareTimer(); + break; + case 11: //Compare + g_SystemTimer->UpdateTimers(); + _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; + g_Reg->FAKE_CAUSE_REGISTER &= ~CAUSE_IP7; + g_SystemTimer->UpdateCompareTimer(); + break; + case 12: //Status + if ((_CP0[m_Opcode.rd] & STATUS_FR) != (_GPR[m_Opcode.rt].UW[0] & STATUS_FR)) + { + _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; + g_Reg->FixFpuLocations(); + } + else + { + _CP0[m_Opcode.rd] = _GPR[m_Opcode.rt].UW[0]; + } + if ((_CP0[m_Opcode.rd] & 0x18) != 0 && bHaveDebugger()) + { + g_Notify->DisplayError(L"Left kernel mode ??"); + } + g_Reg->CheckInterrupts(); + break; + case 13: //cause + _CP0[m_Opcode.rd] &= 0xFFFFCFF; + if ((_GPR[m_Opcode.rt].UW[0] & 0x300) != 0 && bHaveDebugger()) + { + g_Notify->DisplayError(L"Set IP0 or IP1"); + } + break; + default: + UnknownOpcode(); + } } /************************** COP0 CO functions ***********************/ void R4300iOp::COP0_CO_TLBR() { - if (!g_System->bUseTlb()) - { - return; - } - g_TLB->ReadEntry(); + if (!g_System->bUseTlb()) + { + return; + } + g_TLB->ReadEntry(); } void R4300iOp::COP0_CO_TLBWI() { - if (!g_System->bUseTlb()) - { - return; - } - g_TLB->WriteEntry(g_Reg->INDEX_REGISTER & 0x1F, false); + if (!g_System->bUseTlb()) + { + return; + } + g_TLB->WriteEntry(g_Reg->INDEX_REGISTER & 0x1F, false); } void R4300iOp::COP0_CO_TLBWR() { - if (!g_System->bUseTlb()) - { - return; - } - g_TLB->WriteEntry(g_Reg->RANDOM_REGISTER & 0x1F,true); + if (!g_System->bUseTlb()) + { + return; + } + g_TLB->WriteEntry(g_Reg->RANDOM_REGISTER & 0x1F,true); } void R4300iOp::COP0_CO_TLBP() { - if (!g_System->bUseTlb()) - { - return; - } - g_TLB->Probe(); + if (!g_System->bUseTlb()) + { + return; + } + g_TLB->Probe(); } void R4300iOp::COP0_CO_ERET() { - m_NextInstruction = JUMP; - if ((g_Reg->STATUS_REGISTER & STATUS_ERL) != 0) - { - m_JumpToLocation = g_Reg->ERROREPC_REGISTER; - g_Reg->STATUS_REGISTER &= ~STATUS_ERL; - } - else - { - m_JumpToLocation = g_Reg->EPC_REGISTER; - g_Reg->STATUS_REGISTER &= ~STATUS_EXL; - } - (*_LLBit) = 0; - g_Reg->CheckInterrupts(); - m_TestTimer = true; + m_NextInstruction = JUMP; + if ((g_Reg->STATUS_REGISTER & STATUS_ERL) != 0) + { + m_JumpToLocation = g_Reg->ERROREPC_REGISTER; + g_Reg->STATUS_REGISTER &= ~STATUS_ERL; + } + else + { + m_JumpToLocation = g_Reg->EPC_REGISTER; + g_Reg->STATUS_REGISTER &= ~STATUS_EXL; + } + (*_LLBit) = 0; + g_Reg->CheckInterrupts(); + m_TestTimer = true; } /************************** COP1 functions **************************/ void R4300iOp::COP1_MF() { - TEST_COP1_USABLE_EXCEPTION - _GPR[m_Opcode.rt].DW = *(int *)_FPR_S[m_Opcode.fs]; + TEST_COP1_USABLE_EXCEPTION + _GPR[m_Opcode.rt].DW = *(int32_t *)_FPR_S[m_Opcode.fs]; } void R4300iOp::COP1_DMF() { - TEST_COP1_USABLE_EXCEPTION - _GPR[m_Opcode.rt].DW = *(__int64 *)_FPR_D[m_Opcode.fs]; + TEST_COP1_USABLE_EXCEPTION + _GPR[m_Opcode.rt].DW = *(int64_t *)_FPR_D[m_Opcode.fs]; } void R4300iOp::COP1_CF() { - TEST_COP1_USABLE_EXCEPTION - if (m_Opcode.fs != 31 && m_Opcode.fs != 0) - { - if (bHaveDebugger()) - { - g_Notify->DisplayError(L"CFC1 what register are you writing to ?"); - } - return; - } - _GPR[m_Opcode.rt].DW = (int)_FPCR[m_Opcode.fs]; + TEST_COP1_USABLE_EXCEPTION + if (m_Opcode.fs != 31 && m_Opcode.fs != 0) + { + if (bHaveDebugger()) + { + g_Notify->DisplayError(L"CFC1 what register are you writing to ?"); + } + return; + } + _GPR[m_Opcode.rt].DW = (int32_t)_FPCR[m_Opcode.fs]; } void R4300iOp::COP1_MT() { - TEST_COP1_USABLE_EXCEPTION - *(int *)_FPR_S[m_Opcode.fs] = _GPR[m_Opcode.rt].W[0]; + TEST_COP1_USABLE_EXCEPTION + *(int32_t *)_FPR_S[m_Opcode.fs] = _GPR[m_Opcode.rt].W[0]; } void R4300iOp::COP1_DMT() { - TEST_COP1_USABLE_EXCEPTION - *(__int64 *)_FPR_D[m_Opcode.fs] = _GPR[m_Opcode.rt].DW; + TEST_COP1_USABLE_EXCEPTION + *(int64_t *)_FPR_D[m_Opcode.fs] = _GPR[m_Opcode.rt].DW; } void R4300iOp::COP1_CT() { - TEST_COP1_USABLE_EXCEPTION - if (m_Opcode.fs == 31) { - _FPCR[m_Opcode.fs] = _GPR[m_Opcode.rt].W[0]; - switch ((_FPCR[m_Opcode.fs] & 3)) - { - case 0: *_RoundingModel = ROUND_NEAR; break; - case 1: *_RoundingModel = ROUND_CHOP; break; - case 2: *_RoundingModel = ROUND_UP; break; - case 3: *_RoundingModel = ROUND_DOWN; break; - } - return; - } - if (bHaveDebugger()) - { - g_Notify->DisplayError(L"CTC1 what register are you writing to ?"); - } + TEST_COP1_USABLE_EXCEPTION + if (m_Opcode.fs == 31) { + _FPCR[m_Opcode.fs] = _GPR[m_Opcode.rt].W[0]; + switch ((_FPCR[m_Opcode.fs] & 3)) + { + case 0: *_RoundingModel = ROUND_NEAR; break; + case 1: *_RoundingModel = ROUND_CHOP; break; + case 2: *_RoundingModel = ROUND_UP; break; + case 3: *_RoundingModel = ROUND_DOWN; break; + } + return; + } + if (bHaveDebugger()) + { + g_Notify->DisplayError(L"CTC1 what register are you writing to ?"); + } } /************************* COP1: BC1 functions ***********************/ void R4300iOp::COP1_BCF() { - TEST_COP1_USABLE_EXCEPTION - m_NextInstruction = DELAY_SLOT; - if ((_FPCR[31] & FPCSR_C) == 0) - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - } - else - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + TEST_COP1_USABLE_EXCEPTION + m_NextInstruction = DELAY_SLOT; + if ((_FPCR[31] & FPCSR_C) == 0) + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + } + else + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp::COP1_BCT() { - TEST_COP1_USABLE_EXCEPTION - m_NextInstruction = DELAY_SLOT; - if ((_FPCR[31] & FPCSR_C) != 0) - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - } - else - { - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + TEST_COP1_USABLE_EXCEPTION + m_NextInstruction = DELAY_SLOT; + if ((_FPCR[31] & FPCSR_C) != 0) + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + } + else + { + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp::COP1_BCFL() { - TEST_COP1_USABLE_EXCEPTION - if ((_FPCR[31] & FPCSR_C) == 0) - { - m_NextInstruction = DELAY_SLOT; - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - } - else - { - m_NextInstruction = JUMP; - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + TEST_COP1_USABLE_EXCEPTION + if ((_FPCR[31] & FPCSR_C) == 0) + { + m_NextInstruction = DELAY_SLOT; + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + } + else + { + m_NextInstruction = JUMP; + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } void R4300iOp::COP1_BCTL() { - TEST_COP1_USABLE_EXCEPTION - if ((_FPCR[31] & FPCSR_C) != 0) - { - m_NextInstruction = DELAY_SLOT; - m_JumpToLocation = (*_PROGRAM_COUNTER) + ((short)m_Opcode.offset << 2) + 4; - } - else - { - m_NextInstruction = JUMP; - m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; - } + TEST_COP1_USABLE_EXCEPTION + if ((_FPCR[31] & FPCSR_C) != 0) + { + m_NextInstruction = DELAY_SLOT; + m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; + } + else + { + m_NextInstruction = JUMP; + m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; + } } /************************** COP1: S functions ************************/ -__inline void Float_RoundToInteger32( int * Dest, float * Source ) +__inline void Float_RoundToInteger32( int32_t * Dest, float * Source ) { #ifdef _M_IX86 - _asm - { - mov esi, [Source] - mov edi, [Dest] - fld dword ptr [esi] - fistp dword ptr [edi] - } + _asm + { + mov esi, [Source] + mov edi, [Dest] + fld dword ptr [esi] + fistp dword ptr [edi] + } #else __m128 xmm; @@ -2370,16 +2364,16 @@ __inline void Float_RoundToInteger32( int * Dest, float * Source ) #endif } -__inline void Float_RoundToInteger64( __int64 * Dest, float * Source ) +__inline void Float_RoundToInteger64( int64_t * Dest, float * Source ) { #ifdef _M_IX86 - _asm - { - mov esi, [Source] - mov edi, [Dest] - fld dword ptr [esi] - fistp qword ptr [edi] - } + _asm + { + mov esi, [Source] + mov edi, [Dest] + fld dword ptr [esi] + fistp qword ptr [edi] + } #else __m128 xmm; @@ -2390,30 +2384,30 @@ __inline void Float_RoundToInteger64( __int64 * Dest, float * Source ) void R4300iOp::COP1_S_ADD() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - *(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] + *(float *)_FPR_S[m_Opcode.ft]); + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + *(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] + *(float *)_FPR_S[m_Opcode.ft]); } void R4300iOp::COP1_S_SUB() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - *(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] - *(float *)_FPR_S[m_Opcode.ft]); + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + *(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] - *(float *)_FPR_S[m_Opcode.ft]); } void R4300iOp::COP1_S_MUL() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - *(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] * *(float *)_FPR_S[m_Opcode.ft]); + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + *(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] * *(float *)_FPR_S[m_Opcode.ft]); } void R4300iOp::COP1_S_DIV() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - *(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] / *(float *)_FPR_S[m_Opcode.ft]); + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + *(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] / *(float *)_FPR_S[m_Opcode.ft]); } void R4300iOp::COP1_S_SQRT() @@ -2421,19 +2415,19 @@ void R4300iOp::COP1_S_SQRT() float * Dest = (float *)(_FPR_S[m_Opcode.fd]); float * Source = (float *)(_FPR_S[m_Opcode.fs]); - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); #ifdef _M_IX86 - _asm - { - push esi - mov esi, dword ptr [Source] - fld dword ptr [esi] - fsqrt - mov esi, dword ptr [Dest] - fstp dword ptr [esi] - pop esi - } + _asm + { + push esi + mov esi, dword ptr [Source] + fld dword ptr [esi] + fsqrt + mov esi, dword ptr [Dest] + fstp dword ptr [esi] + pop esi + } #else __m128 xmm; @@ -2445,155 +2439,154 @@ void R4300iOp::COP1_S_SQRT() void R4300iOp::COP1_S_ABS() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - *(float *)_FPR_S[m_Opcode.fd] = (float)fabs(*(float *)_FPR_S[m_Opcode.fs]); + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + *(float *)_FPR_S[m_Opcode.fd] = (float)fabs(*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_MOV() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - *(float *)_FPR_S[m_Opcode.fd] = *(float *)_FPR_S[m_Opcode.fs]; + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + *(float *)_FPR_S[m_Opcode.fd] = *(float *)_FPR_S[m_Opcode.fs]; } void R4300iOp::COP1_S_NEG() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - *(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] * -1.0f); + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + *(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] * -1.0f); } void R4300iOp::COP1_S_TRUNC_L() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(_RC_CHOP,_MCW_RC); - Float_RoundToInteger64(&*(__int64 *)_FPR_D[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); + TEST_COP1_USABLE_EXCEPTION + _controlfp(_RC_CHOP,_MCW_RC); + Float_RoundToInteger64(&*(int64_t *)_FPR_D[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_CEIL_L() { //added by Witten - TEST_COP1_USABLE_EXCEPTION - _controlfp(_RC_UP,_MCW_RC); - Float_RoundToInteger64(&*(__int64 *)_FPR_D[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); + TEST_COP1_USABLE_EXCEPTION + _controlfp(_RC_UP,_MCW_RC); + Float_RoundToInteger64(&*(int64_t *)_FPR_D[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_FLOOR_L() { //added by Witten - TEST_COP1_USABLE_EXCEPTION - _controlfp(_RC_DOWN,_MCW_RC); - Float_RoundToInteger64(&*(__int64 *)_FPR_D[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); + TEST_COP1_USABLE_EXCEPTION + _controlfp(_RC_DOWN,_MCW_RC); + Float_RoundToInteger64(&*(int64_t *)_FPR_D[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_ROUND_W() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(_RC_NEAR,_MCW_RC); - Float_RoundToInteger32(&*(int *)_FPR_S[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); + TEST_COP1_USABLE_EXCEPTION + _controlfp(_RC_NEAR,_MCW_RC); + Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_TRUNC_W() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(_RC_CHOP,_MCW_RC); - Float_RoundToInteger32(&*(int *)_FPR_S[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); + TEST_COP1_USABLE_EXCEPTION + _controlfp(_RC_CHOP,_MCW_RC); + Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_CEIL_W() { //added by Witten - TEST_COP1_USABLE_EXCEPTION - _controlfp(_RC_UP,_MCW_RC); - Float_RoundToInteger32(&*(int *)_FPR_S[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); + TEST_COP1_USABLE_EXCEPTION + _controlfp(_RC_UP,_MCW_RC); + Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_FLOOR_W() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(_RC_DOWN,_MCW_RC); - Float_RoundToInteger32(&*(int *)_FPR_S[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); + TEST_COP1_USABLE_EXCEPTION + _controlfp(_RC_DOWN,_MCW_RC); + Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_CVT_D() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - *(double *)_FPR_D[m_Opcode.fd] = (double)(*(float *)_FPR_S[m_Opcode.fs]); + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + *(double *)_FPR_D[m_Opcode.fd] = (double)(*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_CVT_W() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - Float_RoundToInteger32(&*(int *)_FPR_S[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_CVT_L() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - Float_RoundToInteger64(&*(__int64 *)_FPR_D[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + Float_RoundToInteger64(&*(int64_t *)_FPR_D[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_CMP() { - bool less, equal, unorded; - int condition; - float Temp0, Temp1; + bool less, equal, unorded; + int32_t condition; + float Temp0, Temp1; - TEST_COP1_USABLE_EXCEPTION + TEST_COP1_USABLE_EXCEPTION - Temp0 = *(float *)_FPR_S[m_Opcode.fs]; - Temp1 = *(float *)_FPR_S[m_Opcode.ft]; + Temp0 = *(float *)_FPR_S[m_Opcode.fs]; + Temp1 = *(float *)_FPR_S[m_Opcode.ft]; - if (_isnan(Temp0) || _isnan(Temp1)) - { - if (bHaveDebugger()) - { - g_Notify->DisplayError(__FUNCTIONW__ L": Nan ?"); - } - less = false; - equal = false; - unorded = true; - if ((m_Opcode.funct & 8) != 0) - { - if (bHaveDebugger()) - { - g_Notify->DisplayError(stdstr_f("Signal InvalidOperationException\nin r4300i_COP1_S_CMP\n%X %ff\n%X %ff", Temp0,Temp0,Temp1,Temp1).ToUTF16().c_str()); - } - } - } - else - { - less = Temp0 < Temp1; - equal = Temp0 == Temp1; - unorded = false; - } - - condition = ((m_Opcode.funct & 4) && less) | ((m_Opcode.funct & 2) && equal) | - ((m_Opcode.funct & 1) && unorded); + if (_isnan(Temp0) || _isnan(Temp1)) + { + if (bHaveDebugger()) + { + g_Notify->DisplayError(__FUNCTIONW__ L": Nan ?"); + } + less = false; + equal = false; + unorded = true; + if ((m_Opcode.funct & 8) != 0) + { + if (bHaveDebugger()) + { + g_Notify->DisplayError(stdstr_f("Signal InvalidOperationException\nin r4300i_COP1_S_CMP\n%X %ff\n%X %ff", Temp0,Temp0,Temp1,Temp1).ToUTF16().c_str()); + } + } + } + else + { + less = Temp0 < Temp1; + equal = Temp0 == Temp1; + unorded = false; + } - if (condition) - { - _FPCR[31] |= FPCSR_C; - } - else - { - _FPCR[31] &= ~FPCSR_C; - } - + condition = ((m_Opcode.funct & 4) && less) | ((m_Opcode.funct & 2) && equal) | + ((m_Opcode.funct & 1) && unorded); + + if (condition) + { + _FPCR[31] |= FPCSR_C; + } + else + { + _FPCR[31] &= ~FPCSR_C; + } } /************************** COP1: D functions ************************/ -__inline void Double_RoundToInteger32( DWORD * Dest, double * Source ) +__inline void Double_RoundToInteger32( uint32_t * Dest, double * Source ) { #ifdef _M_IX86 - _asm - { - mov esi, [Source] - mov edi, [Dest] - fld qword ptr [esi] - fistp dword ptr [edi] - } + _asm + { + mov esi, [Source] + mov edi, [Dest] + fld qword ptr [esi] + fistp dword ptr [edi] + } #else __m128d xmm; @@ -2602,16 +2595,16 @@ __inline void Double_RoundToInteger32( DWORD * Dest, double * Source ) #endif } -__inline void Double_RoundToInteger64( unsigned __int64 * Dest, double * Source ) +__inline void Double_RoundToInteger64( uint64_t * Dest, double * Source ) { #ifdef _M_IX86 - _asm - { - mov esi, [Source] - mov edi, [Dest] - fld qword ptr [esi] - fistp qword ptr [edi] - } + _asm + { + mov esi, [Source] + mov edi, [Dest] + fld qword ptr [esi] + fistp qword ptr [edi] + } #else __m128d xmm; @@ -2622,234 +2615,229 @@ __inline void Double_RoundToInteger64( unsigned __int64 * Dest, double * Source void R4300iOp::COP1_D_ADD() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - *(double *)_FPR_D[m_Opcode.fd] = *(double *)_FPR_D[m_Opcode.fs] + *(double *)_FPR_D[m_Opcode.ft]; + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + *(double *)_FPR_D[m_Opcode.fd] = *(double *)_FPR_D[m_Opcode.fs] + *(double *)_FPR_D[m_Opcode.ft]; } void R4300iOp::COP1_D_SUB() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - *(double *)_FPR_D[m_Opcode.fd] = *(double *)_FPR_D[m_Opcode.fs] - *(double *)_FPR_D[m_Opcode.ft]; + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + *(double *)_FPR_D[m_Opcode.fd] = *(double *)_FPR_D[m_Opcode.fs] - *(double *)_FPR_D[m_Opcode.ft]; } void R4300iOp::COP1_D_MUL() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - *(double *)_FPR_D[m_Opcode.fd] = *(double *)_FPR_D[m_Opcode.fs] * *(double *)_FPR_D[m_Opcode.ft]; + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + *(double *)_FPR_D[m_Opcode.fd] = *(double *)_FPR_D[m_Opcode.fs] * *(double *)_FPR_D[m_Opcode.ft]; } void R4300iOp::COP1_D_DIV() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - *(double *)_FPR_D[m_Opcode.fd] = *(double *)_FPR_D[m_Opcode.fs] / *(double *)_FPR_D[m_Opcode.ft]; + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + *(double *)_FPR_D[m_Opcode.fd] = *(double *)_FPR_D[m_Opcode.fs] / *(double *)_FPR_D[m_Opcode.ft]; } void R4300iOp::COP1_D_SQRT() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - *(double *)_FPR_D[m_Opcode.fd] = (double)sqrt(*(double *)_FPR_D[m_Opcode.fs]); + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + *(double *)_FPR_D[m_Opcode.fd] = (double)sqrt(*(double *)_FPR_D[m_Opcode.fs]); } void R4300iOp::COP1_D_ABS() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - *(double *)_FPR_D[m_Opcode.fd] = fabs(*(double *)_FPR_D[m_Opcode.fs]); + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + *(double *)_FPR_D[m_Opcode.fd] = fabs(*(double *)_FPR_D[m_Opcode.fs]); } void R4300iOp::COP1_D_MOV() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - *(__int64 *)_FPR_D[m_Opcode.fd] = *(__int64 *)_FPR_D[m_Opcode.fs]; + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + *(int64_t *)_FPR_D[m_Opcode.fd] = *(int64_t *)_FPR_D[m_Opcode.fs]; } void R4300iOp::COP1_D_NEG() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - *(double *)_FPR_D[m_Opcode.fd] = (*(double *)_FPR_D[m_Opcode.fs] * -1.0); + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + *(double *)_FPR_D[m_Opcode.fd] = (*(double *)_FPR_D[m_Opcode.fs] * -1.0); } void R4300iOp::COP1_D_TRUNC_L() { //added by Witten - TEST_COP1_USABLE_EXCEPTION - _controlfp(RC_CHOP,_MCW_RC); - Double_RoundToInteger64(&*(QWORD *)_FPR_S[m_Opcode.fd],&*(double *)_FPR_D[m_Opcode.fs] ); + TEST_COP1_USABLE_EXCEPTION + _controlfp(RC_CHOP,_MCW_RC); + Double_RoundToInteger64(&*(uint64_t *)_FPR_S[m_Opcode.fd],&*(double *)_FPR_D[m_Opcode.fs] ); } void R4300iOp::COP1_D_CEIL_L() { //added by Witten - TEST_COP1_USABLE_EXCEPTION - _controlfp(RC_UP,_MCW_RC); - Double_RoundToInteger64(&*(QWORD *)_FPR_S[m_Opcode.fd],&*(double *)_FPR_D[m_Opcode.fs] ); + TEST_COP1_USABLE_EXCEPTION + _controlfp(RC_UP,_MCW_RC); + Double_RoundToInteger64(&*(uint64_t *)_FPR_S[m_Opcode.fd],&*(double *)_FPR_D[m_Opcode.fs] ); } void R4300iOp::COP1_D_FLOOR_L() { //added by Witten - TEST_COP1_USABLE_EXCEPTION - _controlfp(_RC_DOWN,_MCW_RC); - Double_RoundToInteger64(&*(QWORD *)_FPR_D[m_Opcode.fd],&*(double *)_FPR_S[m_Opcode.fs]); + TEST_COP1_USABLE_EXCEPTION + _controlfp(_RC_DOWN,_MCW_RC); + Double_RoundToInteger64(&*(uint64_t *)_FPR_D[m_Opcode.fd],&*(double *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_D_ROUND_W() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(_RC_NEAR,_MCW_RC); - Double_RoundToInteger32(&*(DWORD *)_FPR_S[m_Opcode.fd],&*(double *)_FPR_D[m_Opcode.fs] ); + TEST_COP1_USABLE_EXCEPTION + _controlfp(_RC_NEAR,_MCW_RC); + Double_RoundToInteger32(&*(uint32_t *)_FPR_S[m_Opcode.fd],&*(double *)_FPR_D[m_Opcode.fs] ); } void R4300iOp::COP1_D_TRUNC_W() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(RC_CHOP,_MCW_RC); - Double_RoundToInteger32(&*(DWORD *)_FPR_S[m_Opcode.fd],&*(double *)_FPR_D[m_Opcode.fs] ); + TEST_COP1_USABLE_EXCEPTION + _controlfp(RC_CHOP,_MCW_RC); + Double_RoundToInteger32(&*(uint32_t *)_FPR_S[m_Opcode.fd],&*(double *)_FPR_D[m_Opcode.fs] ); } void R4300iOp::COP1_D_CEIL_W() { //added by Witten - TEST_COP1_USABLE_EXCEPTION - _controlfp(RC_UP,_MCW_RC); - Double_RoundToInteger32(&*(DWORD *)_FPR_S[m_Opcode.fd],&*(double *)_FPR_D[m_Opcode.fs] ); + TEST_COP1_USABLE_EXCEPTION + _controlfp(RC_UP,_MCW_RC); + Double_RoundToInteger32(&*(uint32_t *)_FPR_S[m_Opcode.fd],&*(double *)_FPR_D[m_Opcode.fs] ); } void R4300iOp::COP1_D_FLOOR_W() { //added by Witten - TEST_COP1_USABLE_EXCEPTION - _controlfp(_RC_DOWN,_MCW_RC); - Double_RoundToInteger32(&*(DWORD *)_FPR_D[m_Opcode.fd],&*(double *)_FPR_S[m_Opcode.fs]); + TEST_COP1_USABLE_EXCEPTION + _controlfp(_RC_DOWN,_MCW_RC); + Double_RoundToInteger32(&*(uint32_t *)_FPR_D[m_Opcode.fd],&*(double *)_FPR_S[m_Opcode.fs]); } -void R4300iOp::COP1_D_CVT_S() +void R4300iOp::COP1_D_CVT_S() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - *(float *)_FPR_S[m_Opcode.fd] = (float)*(double *)_FPR_D[m_Opcode.fs]; + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + *(float *)_FPR_S[m_Opcode.fd] = (float)*(double *)_FPR_D[m_Opcode.fs]; } -void R4300iOp::COP1_D_CVT_W() +void R4300iOp::COP1_D_CVT_W() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - Double_RoundToInteger32(&*(DWORD *)_FPR_S[m_Opcode.fd],&*(double *)_FPR_D[m_Opcode.fs] ); + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + Double_RoundToInteger32(&*(uint32_t *)_FPR_S[m_Opcode.fd],&*(double *)_FPR_D[m_Opcode.fs] ); } -void R4300iOp::COP1_D_CVT_L() +void R4300iOp::COP1_D_CVT_L() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - Double_RoundToInteger64(&*(unsigned __int64 *)_FPR_D[m_Opcode.fd],&*(double *)_FPR_D[m_Opcode.fs]); + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + Double_RoundToInteger64(&*(uint64_t *)_FPR_D[m_Opcode.fd],&*(double *)_FPR_D[m_Opcode.fs]); } void R4300iOp::COP1_D_CMP() { - bool less, equal, unorded; - int condition; - MIPS_DWORD Temp0, Temp1; + bool less, equal, unorded; + int32_t condition; + MIPS_DWORD Temp0, Temp1; - TEST_COP1_USABLE_EXCEPTION + TEST_COP1_USABLE_EXCEPTION - Temp0.DW = *(__int64 *)_FPR_D[m_Opcode.fs]; - Temp1.DW = *(__int64 *)_FPR_D[m_Opcode.ft]; + Temp0.DW = *(int64_t *)_FPR_D[m_Opcode.fs]; + Temp1.DW = *(int64_t *)_FPR_D[m_Opcode.ft]; - if (_isnan(Temp0.D) || _isnan(Temp1.D)) - { - if (bHaveDebugger()) - { - g_Notify->DisplayError(__FUNCTIONW__ L": Nan ?"); - } - less = false; - equal = false; - unorded = true; - if ((m_Opcode.funct & 8) != 0) - { - if (bHaveDebugger()) - { - g_Notify->DisplayError(L"Signal InvalidOperationException\nin " __FUNCTIONW__); - } - } - } - else - { - less = Temp0.D < Temp1.D; - equal = Temp0.D == Temp1.D; - unorded = false; - } - - condition = ((m_Opcode.funct & 4) && less) | ((m_Opcode.funct & 2) && equal) | - ((m_Opcode.funct & 1) && unorded); + if (_isnan(Temp0.D) || _isnan(Temp1.D)) + { + if (bHaveDebugger()) + { + g_Notify->DisplayError(__FUNCTIONW__ L": Nan ?"); + } + less = false; + equal = false; + unorded = true; + if ((m_Opcode.funct & 8) != 0) + { + if (bHaveDebugger()) + { + g_Notify->DisplayError(L"Signal InvalidOperationException\nin " __FUNCTIONW__); + } + } + } + else + { + less = Temp0.D < Temp1.D; + equal = Temp0.D == Temp1.D; + unorded = false; + } - if (condition) - { - _FPCR[31] |= FPCSR_C; - } - else - { - _FPCR[31] &= ~FPCSR_C; - } + condition = ((m_Opcode.funct & 4) && less) | ((m_Opcode.funct & 2) && equal) | + ((m_Opcode.funct & 1) && unorded); + + if (condition) + { + _FPCR[31] |= FPCSR_C; + } + else + { + _FPCR[31] &= ~FPCSR_C; + } } /************************** COP1: W functions ************************/ void R4300iOp::COP1_W_CVT_S() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - *(float *)_FPR_S[m_Opcode.fd] = (float)*(int *)_FPR_S[m_Opcode.fs]; + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + *(float *)_FPR_S[m_Opcode.fd] = (float)*(int32_t *)_FPR_S[m_Opcode.fs]; } void R4300iOp::COP1_W_CVT_D() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - *(double *)_FPR_D[m_Opcode.fd] = (double)*(int *)_FPR_S[m_Opcode.fs]; + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + *(double *)_FPR_D[m_Opcode.fd] = (double)*(int32_t *)_FPR_S[m_Opcode.fs]; } /************************** COP1: L functions ************************/ void R4300iOp::COP1_L_CVT_S() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - *(float *)_FPR_S[m_Opcode.fd] = (float)*(__int64 *)_FPR_D[m_Opcode.fs]; + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + *(float *)_FPR_S[m_Opcode.fd] = (float)*(int64_t *)_FPR_D[m_Opcode.fs]; } void R4300iOp::COP1_L_CVT_D() { - TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - *(double *)_FPR_D[m_Opcode.fd] = (double)*(__int64 *)_FPR_D[m_Opcode.fs]; + TEST_COP1_USABLE_EXCEPTION + _controlfp(*_RoundingModel,_MCW_RC); + *(double *)_FPR_D[m_Opcode.fd] = (double)*(int64_t *)_FPR_D[m_Opcode.fs]; } /************************** Other functions **************************/ -void R4300iOp::UnknownOpcode() +void R4300iOp::UnknownOpcode() { - g_Notify->DisplayError(stdstr_f("%s: %08X\n%s\n\nStopping Emulation !", GS(MSG_UNHANDLED_OP), (*_PROGRAM_COUNTER), - R4300iOpcodeName(m_Opcode.Hex,(*_PROGRAM_COUNTER))).ToUTF16().c_str()); - g_System->m_EndEmulation = true; - + g_Notify->DisplayError(stdstr_f("%s: %08X\n%s\n\nStopping Emulation !", GS(MSG_UNHANDLED_OP), (*_PROGRAM_COUNTER), + R4300iOpcodeName(m_Opcode.Hex,(*_PROGRAM_COUNTER))).ToUTF16().c_str()); + g_System->m_EndEmulation = true; + g_Notify->BreakPoint(__FILEW__,__LINE__); #ifdef tofix - if (HaveDebugger && !inFullScreen) - { - int response; + if (HaveDebugger && !inFullScreen) + { + int32_t response; - strcat(Message,"\n\nDo you wish to enter the debugger ?"); - - response = MessageBox(NULL,Message,GS(MSG_MSGBOX_TITLE), MB_YESNO | MB_ICONERROR ); - if (response == IDYES) - { - Enter_R4300i_Commands_Window (); - } - ExitThread(0); - } - else - { - g_Notify->DisplayError(Message); - ExitThread(0); - } + strcat(Message,"\n\nDo you wish to enter the debugger ?"); + + response = MessageBox(NULL,Message,GS(MSG_MSGBOX_TITLE), MB_YESNO | MB_ICONERROR ); + if (response == IDYES) + { + Enter_R4300i_Commands_Window (); + } + ExitThread(0); + } #endif } diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops.h b/Source/Project64/N64 System/Interpreter/Interpreter Ops.h index 3c2153aba..909a0acad 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops.h +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops.h @@ -11,228 +11,225 @@ #pragma once class R4300iOp : - protected CDebugSettings, - protected CSystemRegisters + protected CDebugSettings, + protected CSystemRegisters { public: - typedef void(*Func)(); + typedef void(*Func)(); - /************************* OpCode functions *************************/ - static void J(); - static void JAL(); - static void BNE(); - static void BEQ(); - static void BLEZ(); - static void BGTZ(); - static void ADDI(); - static void ADDIU(); - static void SLTI(); - static void SLTIU(); - static void ANDI(); - static void ORI(); - static void XORI(); - static void LUI(); - static void BEQL(); - static void BNEL(); - static void BLEZL(); - static void BGTZL(); - static void DADDIU(); - static void LDL(); - static void LDR(); - static void LB(); - static void LH(); - static void LWL(); - static void LW(); - static void LBU(); - static void LHU(); - static void LWR(); - static void LWU(); - static void SB(); - static void SH(); - static void SWL(); - static void SW(); - static void SDL(); - static void SDR(); - static void SWR(); - static void CACHE(); - static void LL(); - static void LWC1(); - static void LDC1(); - static void LD(); - static void SC(); - static void SWC1(); - static void SDC1(); - static void SD(); + /************************* OpCode functions *************************/ + static void J(); + static void JAL(); + static void BNE(); + static void BEQ(); + static void BLEZ(); + static void BGTZ(); + static void ADDI(); + static void ADDIU(); + static void SLTI(); + static void SLTIU(); + static void ANDI(); + static void ORI(); + static void XORI(); + static void LUI(); + static void BEQL(); + static void BNEL(); + static void BLEZL(); + static void BGTZL(); + static void DADDIU(); + static void LDL(); + static void LDR(); + static void LB(); + static void LH(); + static void LWL(); + static void LW(); + static void LBU(); + static void LHU(); + static void LWR(); + static void LWU(); + static void SB(); + static void SH(); + static void SWL(); + static void SW(); + static void SDL(); + static void SDR(); + static void SWR(); + static void CACHE(); + static void LL(); + static void LWC1(); + static void LDC1(); + static void LD(); + static void SC(); + static void SWC1(); + static void SDC1(); + static void SD(); + /********************** R4300i OpCodes: Special **********************/ + static void SPECIAL_SLL(); + static void SPECIAL_SRL(); + static void SPECIAL_SRA(); + static void SPECIAL_SLLV(); + static void SPECIAL_SRLV(); + static void SPECIAL_SRAV(); + static void SPECIAL_JR(); + static void SPECIAL_JALR(); + static void SPECIAL_SYSCALL(); + static void SPECIAL_BREAK(); + static void SPECIAL_SYNC(); + static void SPECIAL_MFHI(); + static void SPECIAL_MTHI(); + static void SPECIAL_MFLO(); + static void SPECIAL_MTLO(); + static void SPECIAL_DSLLV(); + static void SPECIAL_DSRLV(); + static void SPECIAL_DSRAV(); + static void SPECIAL_MULT(); + static void SPECIAL_MULTU(); + static void SPECIAL_DIV(); + static void SPECIAL_DIVU(); + static void SPECIAL_DMULT(); + static void SPECIAL_DMULTU(); + static void SPECIAL_DDIV(); + static void SPECIAL_DDIVU(); + static void SPECIAL_ADD(); + static void SPECIAL_ADDU(); + static void SPECIAL_SUB(); + static void SPECIAL_SUBU(); + static void SPECIAL_AND(); + static void SPECIAL_OR(); + static void SPECIAL_XOR(); + static void SPECIAL_NOR(); + static void SPECIAL_SLT(); + static void SPECIAL_SLTU(); + static void SPECIAL_DADD(); + static void SPECIAL_DADDU(); + static void SPECIAL_DSUB(); + static void SPECIAL_DSUBU(); + static void SPECIAL_TEQ(); + static void SPECIAL_DSLL(); + static void SPECIAL_DSRL(); + static void SPECIAL_DSRA(); + static void SPECIAL_DSLL32(); + static void SPECIAL_DSRL32(); + static void SPECIAL_DSRA32(); - /********************** R4300i OpCodes: Special **********************/ - static void SPECIAL_SLL(); - static void SPECIAL_SRL(); - static void SPECIAL_SRA(); - static void SPECIAL_SLLV(); - static void SPECIAL_SRLV(); - static void SPECIAL_SRAV(); - static void SPECIAL_JR(); - static void SPECIAL_JALR(); - static void SPECIAL_SYSCALL(); - static void SPECIAL_BREAK(); - static void SPECIAL_SYNC(); - static void SPECIAL_MFHI(); - static void SPECIAL_MTHI(); - static void SPECIAL_MFLO(); - static void SPECIAL_MTLO(); - static void SPECIAL_DSLLV(); - static void SPECIAL_DSRLV(); - static void SPECIAL_DSRAV(); - static void SPECIAL_MULT(); - static void SPECIAL_MULTU(); - static void SPECIAL_DIV(); - static void SPECIAL_DIVU(); - static void SPECIAL_DMULT(); - static void SPECIAL_DMULTU(); - static void SPECIAL_DDIV(); - static void SPECIAL_DDIVU(); - static void SPECIAL_ADD(); - static void SPECIAL_ADDU(); - static void SPECIAL_SUB(); - static void SPECIAL_SUBU(); - static void SPECIAL_AND(); - static void SPECIAL_OR(); - static void SPECIAL_XOR(); - static void SPECIAL_NOR(); - static void SPECIAL_SLT(); - static void SPECIAL_SLTU(); - static void SPECIAL_DADD(); - static void SPECIAL_DADDU(); - static void SPECIAL_DSUB(); - static void SPECIAL_DSUBU(); - static void SPECIAL_TEQ(); - static void SPECIAL_DSLL(); - static void SPECIAL_DSRL(); - static void SPECIAL_DSRA(); - static void SPECIAL_DSLL32(); - static void SPECIAL_DSRL32(); - static void SPECIAL_DSRA32(); + /********************** R4300i OpCodes: RegImm **********************/ + static void REGIMM_BLTZ(); + static void REGIMM_BGEZ(); + static void REGIMM_BLTZL(); + static void REGIMM_BGEZL(); + static void REGIMM_BLTZAL(); + static void REGIMM_BGEZAL(); - /********************** R4300i OpCodes: RegImm **********************/ - static void REGIMM_BLTZ(); - static void REGIMM_BGEZ(); - static void REGIMM_BLTZL(); - static void REGIMM_BGEZL(); - static void REGIMM_BLTZAL(); - static void REGIMM_BGEZAL(); + /************************** COP0 functions **************************/ + static void COP0_MF(); + static void COP0_MT(); - /************************** COP0 functions **************************/ - static void COP0_MF(); - static void COP0_MT(); + /************************** COP0 CO functions ***********************/ + static void COP0_CO_TLBR(); + static void COP0_CO_TLBWI(); + static void COP0_CO_TLBWR(); + static void COP0_CO_TLBP(); + static void COP0_CO_ERET(); - /************************** COP0 CO functions ***********************/ - static void COP0_CO_TLBR(); - static void COP0_CO_TLBWI(); - static void COP0_CO_TLBWR(); - static void COP0_CO_TLBP(); - static void COP0_CO_ERET(); + /************************** COP1 functions **************************/ + static void COP1_MF(); + static void COP1_DMF(); + static void COP1_CF(); + static void COP1_MT(); + static void COP1_DMT(); + static void COP1_CT(); - /************************** COP1 functions **************************/ - static void COP1_MF(); - static void COP1_DMF(); - static void COP1_CF(); - static void COP1_MT(); - static void COP1_DMT(); - static void COP1_CT(); + /************************* COP1: BC1 functions ***********************/ + static void COP1_BCF(); + static void COP1_BCT(); + static void COP1_BCFL(); + static void COP1_BCTL(); - /************************* COP1: BC1 functions ***********************/ - static void COP1_BCF(); - static void COP1_BCT(); - static void COP1_BCFL(); - static void COP1_BCTL(); + /************************** COP1: S functions ************************/ + static void COP1_S_ADD(); + static void COP1_S_SUB(); + static void COP1_S_MUL(); + static void COP1_S_DIV(); + static void COP1_S_SQRT(); + static void COP1_S_ABS(); + static void COP1_S_MOV(); + static void COP1_S_NEG(); + static void COP1_S_TRUNC_L(); + static void COP1_S_CEIL_L(); //added by Witten + static void COP1_S_FLOOR_L(); //added by Witten + static void COP1_S_ROUND_W(); + static void COP1_S_TRUNC_W(); + static void COP1_S_CEIL_W(); //added by Witten + static void COP1_S_FLOOR_W(); + static void COP1_S_CVT_D(); + static void COP1_S_CVT_W(); + static void COP1_S_CVT_L(); + static void COP1_S_CMP(); - /************************** COP1: S functions ************************/ - static void COP1_S_ADD(); - static void COP1_S_SUB(); - static void COP1_S_MUL(); - static void COP1_S_DIV(); - static void COP1_S_SQRT(); - static void COP1_S_ABS(); - static void COP1_S_MOV(); - static void COP1_S_NEG(); - static void COP1_S_TRUNC_L(); - static void COP1_S_CEIL_L(); //added by Witten - static void COP1_S_FLOOR_L(); //added by Witten - static void COP1_S_ROUND_W(); - static void COP1_S_TRUNC_W(); - static void COP1_S_CEIL_W(); //added by Witten - static void COP1_S_FLOOR_W(); - static void COP1_S_CVT_D(); - static void COP1_S_CVT_W(); - static void COP1_S_CVT_L(); - static void COP1_S_CMP(); + /************************** COP1: D functions ************************/ + static void COP1_D_ADD(); + static void COP1_D_SUB(); + static void COP1_D_MUL(); + static void COP1_D_DIV(); + static void COP1_D_SQRT(); + static void COP1_D_ABS(); + static void COP1_D_MOV(); + static void COP1_D_NEG(); + static void COP1_D_TRUNC_L(); //added by Witten + static void COP1_D_CEIL_L(); //added by Witten + static void COP1_D_FLOOR_L(); //added by Witten + static void COP1_D_ROUND_W(); + static void COP1_D_TRUNC_W(); + static void COP1_D_CEIL_W(); //added by Witten + static void COP1_D_FLOOR_W(); //added by Witten + static void COP1_D_CVT_S(); + static void COP1_D_CVT_W(); + static void COP1_D_CVT_L(); + static void COP1_D_CMP(); - /************************** COP1: D functions ************************/ - static void COP1_D_ADD(); - static void COP1_D_SUB(); - static void COP1_D_MUL(); - static void COP1_D_DIV(); - static void COP1_D_SQRT(); - static void COP1_D_ABS(); - static void COP1_D_MOV(); - static void COP1_D_NEG(); - static void COP1_D_TRUNC_L(); //added by Witten - static void COP1_D_CEIL_L(); //added by Witten - static void COP1_D_FLOOR_L(); //added by Witten - static void COP1_D_ROUND_W(); - static void COP1_D_TRUNC_W(); - static void COP1_D_CEIL_W(); //added by Witten - static void COP1_D_FLOOR_W(); //added by Witten - static void COP1_D_CVT_S(); - static void COP1_D_CVT_W(); - static void COP1_D_CVT_L(); - static void COP1_D_CMP(); + /************************** COP1: W functions ************************/ + static void COP1_W_CVT_S(); + static void COP1_W_CVT_D(); - /************************** COP1: W functions ************************/ - static void COP1_W_CVT_S(); - static void COP1_W_CVT_D(); + /************************** COP1: L functions ************************/ + static void COP1_L_CVT_S(); + static void COP1_L_CVT_D(); - /************************** COP1: L functions ************************/ - static void COP1_L_CVT_S(); - static void COP1_L_CVT_D(); + /************************** Other functions **************************/ + static void UnknownOpcode(); - /************************** Other functions **************************/ - static void UnknownOpcode(); + static Func* BuildInterpreter(); - - static Func* BuildInterpreter(); - - static bool m_TestTimer; - static DWORD m_NextInstruction; - static OPCODE m_Opcode; - static DWORD m_JumpToLocation; + static bool m_TestTimer; + static uint32_t m_NextInstruction; + static OPCODE m_Opcode; + static uint32_t m_JumpToLocation; protected: - static void SPECIAL(); - static void REGIMM(); - static void COP0(); - static void COP0_CO(); - static void COP1(); - static void COP1_BC(); - static void COP1_S(); - static void COP1_D(); - static void COP1_W(); - static void COP1_L(); + static void SPECIAL(); + static void REGIMM(); + static void COP0(); + static void COP0_CO(); + static void COP1(); + static void COP1_BC(); + static void COP1_S(); + static void COP1_D(); + static void COP1_W(); + static void COP1_L(); - static Func Jump_Opcode[64]; - static Func Jump_Special[64]; - static Func Jump_Regimm[32]; - static Func Jump_CoP0[32]; - static Func Jump_CoP0_Function[64]; - static Func Jump_CoP1[32]; - static Func Jump_CoP1_BC[32]; - static Func Jump_CoP1_S[64]; - static Func Jump_CoP1_D[64]; - static Func Jump_CoP1_W[64]; - static Func Jump_CoP1_L[64]; - - static const DWORD SWL_MASK[4], SWR_MASK[4], LWL_MASK[4], LWR_MASK[4]; - static const int SWL_SHIFT[4], SWR_SHIFT[4], LWL_SHIFT[4], LWR_SHIFT[4]; + static Func Jump_Opcode[64]; + static Func Jump_Special[64]; + static Func Jump_Regimm[32]; + static Func Jump_CoP0[32]; + static Func Jump_CoP0_Function[64]; + static Func Jump_CoP1[32]; + static Func Jump_CoP1_BC[32]; + static Func Jump_CoP1_S[64]; + static Func Jump_CoP1_D[64]; + static Func Jump_CoP1_W[64]; + static Func Jump_CoP1_L[64]; + static const uint32_t SWL_MASK[4], SWR_MASK[4], LWL_MASK[4], LWR_MASK[4]; + static const int32_t SWL_SHIFT[4], SWR_SHIFT[4], LWL_SHIFT[4], LWR_SHIFT[4]; }; diff --git a/Source/Project64/N64 System/Recompiler/Code Block.cpp b/Source/Project64/N64 System/Recompiler/Code Block.cpp index 860f47f45..c201cfadc 100644 --- a/Source/Project64/N64 System/Recompiler/Code Block.cpp +++ b/Source/Project64/N64 System/Recompiler/Code Block.cpp @@ -10,7 +10,7 @@ ****************************************************************************/ #include "stdafx.h" -bool DelaySlotEffectsCompare (DWORD PC, DWORD Reg1, DWORD Reg2); +bool DelaySlotEffectsCompare (uint32_t PC, uint32_t Reg1, uint32_t Reg2); CCodeBlock::CCodeBlock(DWORD VAddrEnter, BYTE * RecompPos) : m_VAddrEnter(VAddrEnter), diff --git a/Source/Project64/N64 System/Recompiler/Code Section.cpp b/Source/Project64/N64 System/Recompiler/Code Section.cpp index 6da875477..3caf8fd4e 100644 --- a/Source/Project64/N64 System/Recompiler/Code Section.cpp +++ b/Source/Project64/N64 System/Recompiler/Code Section.cpp @@ -12,7 +12,7 @@ void InPermLoop(); -bool DelaySlotEffectsCompare(DWORD PC, DWORD Reg1, DWORD Reg2); +bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2); static bool DelaySlotEffectsJump(DWORD JumpPC) { OPCODE Command; diff --git a/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp b/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp index e8ebe7760..c07be8800 100644 --- a/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp +++ b/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp @@ -14,7 +14,7 @@ #define CHECKED_BUILD 1 #endif -bool DelaySlotEffectsCompare ( DWORD PC, DWORD Reg1, DWORD Reg2 ); +bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2); LoopAnalysis::LoopAnalysis(CCodeBlock * CodeBlock, CCodeSection * Section) : m_EnterSection(Section), diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp index 0c19ffd12..383e72c4b 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp @@ -38,7 +38,7 @@ void CRecompilerOps::CompileWriteTLBMiss (x86Reg AddressReg, x86Reg LookUpReg ) m_Section->CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, CExitInfo::TLBWriteMiss, false, JeLabel32); } -bool DelaySlotEffectsCompare ( DWORD PC, DWORD Reg1, DWORD Reg2 ); +bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2); /************************** Branch functions ************************/ void CRecompilerOps::Compile_Branch (CRecompilerOps::BranchFunction CompareFunc, BRANCH_TYPE BranchType, bool Link) From a6d172212245b79b95bb7e7b175592b0642f8689 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 9 Nov 2015 08:00:16 +1100 Subject: [PATCH 096/213] [Project64] get Code Block.cpp to use standard types --- .../N64 System/Recompiler/Code Block.cpp | 1349 +++++++++-------- .../N64 System/Recompiler/Code Block.h | 88 +- 2 files changed, 719 insertions(+), 718 deletions(-) diff --git a/Source/Project64/N64 System/Recompiler/Code Block.cpp b/Source/Project64/N64 System/Recompiler/Code Block.cpp index c201cfadc..859a6b1b1 100644 --- a/Source/Project64/N64 System/Recompiler/Code Block.cpp +++ b/Source/Project64/N64 System/Recompiler/Code Block.cpp @@ -12,745 +12,746 @@ bool DelaySlotEffectsCompare (uint32_t PC, uint32_t Reg1, uint32_t Reg2); -CCodeBlock::CCodeBlock(DWORD VAddrEnter, BYTE * RecompPos) : - m_VAddrEnter(VAddrEnter), - m_VAddrFirst(VAddrEnter), - m_VAddrLast(VAddrEnter), - m_CompiledLocation(RecompPos), - m_EnterSection(NULL), - m_Test(1) +CCodeBlock::CCodeBlock(uint32_t VAddrEnter, uint8_t * RecompPos) : + m_VAddrEnter(VAddrEnter), + m_VAddrFirst(VAddrEnter), + m_VAddrLast(VAddrEnter), + m_CompiledLocation(RecompPos), + m_EnterSection(NULL), + m_Test(1) { - CCodeSection * baseSection = new CCodeSection(this, VAddrEnter, 0, false); - if (baseSection == NULL) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - m_Sections.push_back(baseSection); - baseSection->AddParent(NULL); - baseSection->m_CompiledLocation = (BYTE *)-1; - baseSection->m_Cont.JumpPC = VAddrEnter; - baseSection->m_Cont.FallThrough = true; - baseSection->m_Cont.RegSet = baseSection->m_RegEnter; + CCodeSection * baseSection = new CCodeSection(this, VAddrEnter, 0, false); + if (baseSection == NULL) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + m_Sections.push_back(baseSection); + baseSection->AddParent(NULL); + baseSection->m_CompiledLocation = (uint8_t *)-1; + baseSection->m_Cont.JumpPC = VAddrEnter; + baseSection->m_Cont.FallThrough = true; + baseSection->m_Cont.RegSet = baseSection->m_RegEnter; - m_EnterSection = new CCodeSection(this, VAddrEnter, 1, true); - if (m_EnterSection == NULL) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - baseSection->m_ContinueSection = m_EnterSection; + m_EnterSection = new CCodeSection(this, VAddrEnter, 1, true); + if (m_EnterSection == NULL) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + baseSection->m_ContinueSection = m_EnterSection; - m_EnterSection->AddParent(baseSection); - m_Sections.push_back(m_EnterSection); - m_SectionMap.insert(SectionMap::value_type(VAddrEnter,m_EnterSection)); + m_EnterSection->AddParent(baseSection); + m_Sections.push_back(m_EnterSection); + m_SectionMap.insert(SectionMap::value_type(VAddrEnter,m_EnterSection)); - if (g_TransVaddr->VAddrToRealAddr(VAddrEnter,*(reinterpret_cast(&m_MemLocation[0])))) - { - m_MemLocation[1] = m_MemLocation[0] + 1; - m_MemContents[0] = *m_MemLocation[0]; - m_MemContents[1] = *m_MemLocation[1]; - } - else - { - memset(m_MemLocation,0,sizeof(m_MemLocation)); - memset(m_MemContents,0,sizeof(m_MemContents)); - } - AnalyseBlock(); + if (g_TransVaddr->VAddrToRealAddr(VAddrEnter,*(reinterpret_cast(&m_MemLocation[0])))) + { + m_MemLocation[1] = m_MemLocation[0] + 1; + m_MemContents[0] = *m_MemLocation[0]; + m_MemContents[1] = *m_MemLocation[1]; + } + else + { + memset(m_MemLocation,0,sizeof(m_MemLocation)); + memset(m_MemContents,0,sizeof(m_MemContents)); + } + AnalyseBlock(); } CCodeBlock::~CCodeBlock() { - for (SectionList::iterator itr = m_Sections.begin(); itr != m_Sections.end(); itr++) - { - CCodeSection * Section = *itr; - delete Section; - } - m_Sections.clear(); + for (SectionList::iterator itr = m_Sections.begin(); itr != m_Sections.end(); itr++) + { + CCodeSection * Section = *itr; + delete Section; + } + m_Sections.clear(); } -bool CCodeBlock::SetSection ( CCodeSection * & Section, CCodeSection * CurrentSection, DWORD TargetPC, bool LinkAllowed, DWORD CurrentPC ) +bool CCodeBlock::SetSection ( CCodeSection * & Section, CCodeSection * CurrentSection, uint32_t TargetPC, bool LinkAllowed, uint32_t CurrentPC ) { - if (Section != NULL) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - if (TargetPC >= ((CurrentPC + 0x1000) & 0xFFFFF000)) - { - return false; - } + if (Section != NULL) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } - if (TargetPC < m_EnterSection->m_EnterPC) - { - return false; - } + if (TargetPC >= ((CurrentPC + 0x1000) & 0xFFFFF000)) + { + return false; + } - if (LinkAllowed) - { - if (Section != NULL) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - SectionMap::const_iterator itr = m_SectionMap.find(TargetPC); - if (itr != m_SectionMap.end()) - { - Section = itr->second; - Section->AddParent(CurrentSection); - } - } + if (TargetPC < m_EnterSection->m_EnterPC) + { + return false; + } - if (Section == NULL) - { - Section = new CCodeSection(this,TargetPC,m_Sections.size(),LinkAllowed); - if (Section == NULL) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; - } - m_Sections.push_back(Section); - if (LinkAllowed) - { - m_SectionMap.insert(SectionMap::value_type(TargetPC,Section)); - } - Section->AddParent(CurrentSection); - if (TargetPC <= CurrentPC && TargetPC != m_VAddrEnter) - { - CCodeSection * SplitSection = NULL; - for (SectionMap::const_iterator itr = m_SectionMap.begin(); itr != m_SectionMap.end(); itr++) - { - if (itr->first >= TargetPC) - { - break; - } - SplitSection = itr->second; - } - if (SplitSection == NULL) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (SplitSection->m_EndPC == (DWORD)-1) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (SplitSection->m_EndPC >= TargetPC) - { - CPU_Message(__FUNCTION__ ": Split Section: %d with section: %d",SplitSection->m_SectionID, Section->m_SectionID); - CCodeSection * BaseSection = Section; - BaseSection->m_EndPC = SplitSection->m_EndPC; - BaseSection->SetJumpAddress(SplitSection->m_Jump.JumpPC, SplitSection->m_Jump.TargetPC,SplitSection->m_Jump.PermLoop); - BaseSection->m_JumpSection = SplitSection->m_JumpSection; - BaseSection->SetContinueAddress(SplitSection->m_Cont.JumpPC,SplitSection->m_Cont.TargetPC); - BaseSection->m_ContinueSection = SplitSection->m_ContinueSection; - BaseSection->m_JumpSection->SwitchParent(SplitSection,BaseSection); - BaseSection->m_ContinueSection->SwitchParent(SplitSection,BaseSection); - BaseSection->AddParent(SplitSection); + if (LinkAllowed) + { + if (Section != NULL) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + SectionMap::const_iterator itr = m_SectionMap.find(TargetPC); + if (itr != m_SectionMap.end()) + { + Section = itr->second; + Section->AddParent(CurrentSection); + } + } - SplitSection->m_EndPC = TargetPC - 4; - SplitSection->m_JumpSection = NULL; - SplitSection->m_ContinueSection = BaseSection; - SplitSection->SetContinueAddress(TargetPC - 4, TargetPC); - SplitSection->SetJumpAddress((DWORD)-1,(DWORD)-1,false); - } - } - } - return true; + if (Section == NULL) + { + Section = new CCodeSection(this,TargetPC,m_Sections.size(),LinkAllowed); + if (Section == NULL) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + return false; + } + m_Sections.push_back(Section); + if (LinkAllowed) + { + m_SectionMap.insert(SectionMap::value_type(TargetPC,Section)); + } + Section->AddParent(CurrentSection); + if (TargetPC <= CurrentPC && TargetPC != m_VAddrEnter) + { + CCodeSection * SplitSection = NULL; + for (SectionMap::const_iterator itr = m_SectionMap.begin(); itr != m_SectionMap.end(); itr++) + { + if (itr->first >= TargetPC) + { + break; + } + SplitSection = itr->second; + } + if (SplitSection == NULL) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + if (SplitSection->m_EndPC == (uint32_t)-1) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + if (SplitSection->m_EndPC >= TargetPC) + { + CPU_Message(__FUNCTION__ ": Split Section: %d with section: %d",SplitSection->m_SectionID, Section->m_SectionID); + CCodeSection * BaseSection = Section; + BaseSection->m_EndPC = SplitSection->m_EndPC; + BaseSection->SetJumpAddress(SplitSection->m_Jump.JumpPC, SplitSection->m_Jump.TargetPC,SplitSection->m_Jump.PermLoop); + BaseSection->m_JumpSection = SplitSection->m_JumpSection; + BaseSection->SetContinueAddress(SplitSection->m_Cont.JumpPC,SplitSection->m_Cont.TargetPC); + BaseSection->m_ContinueSection = SplitSection->m_ContinueSection; + BaseSection->m_JumpSection->SwitchParent(SplitSection,BaseSection); + BaseSection->m_ContinueSection->SwitchParent(SplitSection,BaseSection); + BaseSection->AddParent(SplitSection); + + SplitSection->m_EndPC = TargetPC - 4; + SplitSection->m_JumpSection = NULL; + SplitSection->m_ContinueSection = BaseSection; + SplitSection->SetContinueAddress(TargetPC - 4, TargetPC); + SplitSection->SetJumpAddress((uint32_t)-1,(uint32_t)-1,false); + } + } + } + return true; } -bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection ) +bool CCodeBlock::CreateBlockLinkage ( CCodeSection * EnterSection ) { - CCodeSection * CurrentSection = EnterSection; + CCodeSection * CurrentSection = EnterSection; - CPU_Message("Section %d",CurrentSection->m_SectionID); - for (DWORD TestPC = EnterSection->m_EnterPC, EndPC = ((EnterSection->m_EnterPC + 0x1000) & 0xFFFFF000); TestPC <= EndPC; TestPC += 4) - { - if (TestPC != EndPC) - { - SectionMap::const_iterator itr = m_SectionMap.find(TestPC); - if (itr != m_SectionMap.end() && CurrentSection != itr->second) - { - if (CurrentSection->m_ContinueSection != NULL && - CurrentSection->m_ContinueSection != itr->second) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (CurrentSection->m_ContinueSection == NULL) - { - SetSection(CurrentSection->m_ContinueSection, CurrentSection, TestPC,true,TestPC); - CurrentSection->SetContinueAddress(TestPC - 4, TestPC); - } - CurrentSection->m_EndPC = TestPC - 4; - CurrentSection = itr->second; - - CPU_Message("Section %d",CurrentSection->m_SectionID); - if (EnterSection != m_EnterSection) - { - if (CurrentSection->m_JumpSection != NULL || - CurrentSection->m_ContinueSection != NULL || - CurrentSection->m_EndSection) - { - break; - } - } - } - } - else - { - CurrentSection->m_EndSection = true; - break; - } + CPU_Message("Section %d",CurrentSection->m_SectionID); + for (uint32_t TestPC = EnterSection->m_EnterPC, EndPC = ((EnterSection->m_EnterPC + 0x1000) & 0xFFFFF000); TestPC <= EndPC; TestPC += 4) + { + if (TestPC != EndPC) + { + SectionMap::const_iterator itr = m_SectionMap.find(TestPC); + if (itr != m_SectionMap.end() && CurrentSection != itr->second) + { + if (CurrentSection->m_ContinueSection != NULL && + CurrentSection->m_ContinueSection != itr->second) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + if (CurrentSection->m_ContinueSection == NULL) + { + SetSection(CurrentSection->m_ContinueSection, CurrentSection, TestPC,true,TestPC); + CurrentSection->SetContinueAddress(TestPC - 4, TestPC); + } + CurrentSection->m_EndPC = TestPC - 4; + CurrentSection = itr->second; - bool LikelyBranch, EndBlock, IncludeDelaySlot, PermLoop; - DWORD TargetPC, ContinuePC; + CPU_Message("Section %d",CurrentSection->m_SectionID); + if (EnterSection != m_EnterSection) + { + if (CurrentSection->m_JumpSection != NULL || + CurrentSection->m_ContinueSection != NULL || + CurrentSection->m_EndSection) + { + break; + } + } + } + } + else + { + CurrentSection->m_EndSection = true; + break; + } - CurrentSection->m_EndPC = TestPC; - if (!AnalyzeInstruction(TestPC, TargetPC, ContinuePC, LikelyBranch, IncludeDelaySlot, EndBlock, PermLoop)) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; - } + bool LikelyBranch, EndBlock, IncludeDelaySlot, PermLoop; + uint32_t TargetPC, ContinuePC; - if (TestPC + 4 == EndPC && IncludeDelaySlot) - { - TargetPC = (DWORD)-1; - ContinuePC = (DWORD)-1; - EndBlock = true; - } - if (TargetPC == (DWORD)-1 && !EndBlock) - { - if (ContinuePC != (DWORD)-1) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - continue; - } + CurrentSection->m_EndPC = TestPC; + if (!AnalyzeInstruction(TestPC, TargetPC, ContinuePC, LikelyBranch, IncludeDelaySlot, EndBlock, PermLoop)) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + return false; + } - if (EndBlock) - { - CPU_Message(__FUNCTION__ ": End Block"); - CurrentSection->m_EndSection = true; - // find other sections that need compiling - break; - } + if (TestPC + 4 == EndPC && IncludeDelaySlot) + { + TargetPC = (uint32_t)-1; + ContinuePC = (uint32_t)-1; + EndBlock = true; + } + if (TargetPC == (uint32_t)-1 && !EndBlock) + { + if (ContinuePC != (uint32_t)-1) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + continue; + } - if (ContinuePC != (DWORD)-1) - { - CPU_Message(__FUNCTION__ ": SetContinueAddress TestPC = %X ContinuePC = %X",TestPC,ContinuePC); - CurrentSection->SetContinueAddress(TestPC, ContinuePC); - if (!SetSection(CurrentSection->m_ContinueSection, CurrentSection, ContinuePC,true,TestPC)) - { - ContinuePC = (DWORD)-1; - } - } + if (EndBlock) + { + CPU_Message(__FUNCTION__ ": End Block"); + CurrentSection->m_EndSection = true; + // find other sections that need compiling + break; + } - if (LikelyBranch) - { - CPU_Message(__FUNCTION__ ": SetJumpAddress TestPC = %X Target = %X",TestPC,TestPC + 4); - CurrentSection->SetJumpAddress(TestPC, TestPC + 4,false); - if (SetSection(CurrentSection->m_JumpSection, CurrentSection, TestPC + 4,false,TestPC)) - { - bool BranchLikelyBranch, BranchEndBlock, BranchIncludeDelaySlot, BranchPermLoop; - DWORD BranchTargetPC, BranchContinuePC; + if (ContinuePC != (uint32_t)-1) + { + CPU_Message(__FUNCTION__ ": SetContinueAddress TestPC = %X ContinuePC = %X",TestPC,ContinuePC); + CurrentSection->SetContinueAddress(TestPC, ContinuePC); + if (!SetSection(CurrentSection->m_ContinueSection, CurrentSection, ContinuePC,true,TestPC)) + { + ContinuePC = (uint32_t)-1; + } + } - CCodeSection * JumpSection = CurrentSection->m_JumpSection; - if (!AnalyzeInstruction(JumpSection->m_EnterPC, BranchTargetPC, BranchContinuePC, BranchLikelyBranch, BranchIncludeDelaySlot, BranchEndBlock, BranchPermLoop)) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; - } + if (LikelyBranch) + { + CPU_Message(__FUNCTION__ ": SetJumpAddress TestPC = %X Target = %X",TestPC,TestPC + 4); + CurrentSection->SetJumpAddress(TestPC, TestPC + 4,false); + if (SetSection(CurrentSection->m_JumpSection, CurrentSection, TestPC + 4,false,TestPC)) + { + bool BranchLikelyBranch, BranchEndBlock, BranchIncludeDelaySlot, BranchPermLoop; + uint32_t BranchTargetPC, BranchContinuePC; - if (BranchLikelyBranch || BranchIncludeDelaySlot || BranchPermLoop) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; - } - - JumpSection->m_EndPC = TestPC + 4; - if (BranchEndBlock) - { - CPU_Message(__FUNCTION__ ": Jump End Block"); - JumpSection->m_EndSection = true; - TargetPC = (DWORD)-1; - } - else - { - JumpSection->SetJumpAddress(TestPC, TargetPC,false); - } - JumpSection->SetDelaySlot(); - SetSection(JumpSection->m_JumpSection,JumpSection,TargetPC,true,TestPC); - } - else - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } - else if (TargetPC != ((DWORD)-1)) - { - CPU_Message(__FUNCTION__ ": SetJumpAddress TestPC = %X Target = %X",TestPC,TargetPC); - CurrentSection->SetJumpAddress(TestPC, TargetPC,PermLoop); - if (PermLoop || !SetSection(CurrentSection->m_JumpSection, CurrentSection, TargetPC,true,TestPC)) - { - if (ContinuePC == (DWORD)-1) - { - CurrentSection->m_EndSection = true; - } - } - } + CCodeSection * JumpSection = CurrentSection->m_JumpSection; + if (!AnalyzeInstruction(JumpSection->m_EnterPC, BranchTargetPC, BranchContinuePC, BranchLikelyBranch, BranchIncludeDelaySlot, BranchEndBlock, BranchPermLoop)) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + return false; + } - TestPC += IncludeDelaySlot ? 8 : 4; + if (BranchLikelyBranch || BranchIncludeDelaySlot || BranchPermLoop) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + return false; + } - //Find the next section - CCodeSection * NewSection = NULL; - for (SectionMap::const_iterator itr = m_SectionMap.begin(); itr != m_SectionMap.end(); itr++) - { - if (CurrentSection->m_JumpSection != NULL || - CurrentSection->m_ContinueSection != NULL || - CurrentSection->m_EndSection) - { - continue; - } - NewSection = itr->second; - break; - } - if (NewSection == NULL) - { - break; - } - if (CurrentSection == NewSection) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - CurrentSection = NewSection; - if (CurrentSection->m_JumpSection != NULL || - CurrentSection->m_ContinueSection != NULL || - CurrentSection->m_EndSection) - { - break; - } - TestPC = CurrentSection->m_EnterPC; - CPU_Message("a. Section %d",CurrentSection->m_SectionID); - TestPC -= 4; - } + JumpSection->m_EndPC = TestPC + 4; + if (BranchEndBlock) + { + CPU_Message(__FUNCTION__ ": Jump End Block"); + JumpSection->m_EndSection = true; + TargetPC = (uint32_t)-1; + } + else + { + JumpSection->SetJumpAddress(TestPC, TargetPC,false); + } + JumpSection->SetDelaySlot(); + SetSection(JumpSection->m_JumpSection,JumpSection,TargetPC,true,TestPC); + } + else + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + } + else if (TargetPC != ((uint32_t)-1)) + { + CPU_Message(__FUNCTION__ ": SetJumpAddress TestPC = %X Target = %X",TestPC,TargetPC); + CurrentSection->SetJumpAddress(TestPC, TargetPC,PermLoop); + if (PermLoop || !SetSection(CurrentSection->m_JumpSection, CurrentSection, TargetPC,true,TestPC)) + { + if (ContinuePC == (uint32_t)-1) + { + CurrentSection->m_EndSection = true; + } + } + } - for (SectionMap::iterator itr = m_SectionMap.begin(); itr != m_SectionMap.end(); itr++) - { - CCodeSection * Section = itr->second; - if (Section->m_JumpSection != NULL || - Section->m_ContinueSection != NULL || - Section->m_EndSection) - { - continue; - } - if (!CreateBlockLinkage(Section)) - { - return false; - } - break; - } - if (CurrentSection->m_EndPC == (DWORD)-1) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - return true; + TestPC += IncludeDelaySlot ? 8 : 4; + + //Find the next section + CCodeSection * NewSection = NULL; + for (SectionMap::const_iterator itr = m_SectionMap.begin(); itr != m_SectionMap.end(); itr++) + { + if (CurrentSection->m_JumpSection != NULL || + CurrentSection->m_ContinueSection != NULL || + CurrentSection->m_EndSection) + { + continue; + } + NewSection = itr->second; + break; + } + if (NewSection == NULL) + { + break; + } + if (CurrentSection == NewSection) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + CurrentSection = NewSection; + if (CurrentSection->m_JumpSection != NULL || + CurrentSection->m_ContinueSection != NULL || + CurrentSection->m_EndSection) + { + break; + } + TestPC = CurrentSection->m_EnterPC; + CPU_Message("a. Section %d",CurrentSection->m_SectionID); + TestPC -= 4; + } + + for (SectionMap::iterator itr = m_SectionMap.begin(); itr != m_SectionMap.end(); itr++) + { + CCodeSection * Section = itr->second; + if (Section->m_JumpSection != NULL || + Section->m_ContinueSection != NULL || + Section->m_EndSection) + { + continue; + } + if (!CreateBlockLinkage(Section)) + { + return false; + } + break; + } + if (CurrentSection->m_EndPC == (uint32_t)-1) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + return true; } void CCodeBlock::DetermineLoops() { - for (SectionMap::iterator itr = m_SectionMap.begin(); itr != m_SectionMap.end(); itr++) - { - CCodeSection * Section = itr->second; + for (SectionMap::iterator itr = m_SectionMap.begin(); itr != m_SectionMap.end(); itr++) + { + CCodeSection * Section = itr->second; - DWORD Test = NextTest(); - Section->DetermineLoop(Test,Test,Section->m_SectionID); - } + uint32_t Test = NextTest(); + Section->DetermineLoop(Test,Test,Section->m_SectionID); + } } void CCodeBlock::LogSectionInfo() { - for (SectionList::iterator itr = m_Sections.begin(); itr != m_Sections.end(); itr++) - { - CCodeSection * Section = *itr; - Section->DisplaySectionInformation(); - } + for (SectionList::iterator itr = m_Sections.begin(); itr != m_Sections.end(); itr++) + { + CCodeSection * Section = *itr; + Section->DisplaySectionInformation(); + } } bool CCodeBlock::AnalyseBlock() { - if (!g_System->bLinkBlocks()) - { - return true; - } - if (!CreateBlockLinkage(m_EnterSection)) - { - return false; - } - DetermineLoops(); - LogSectionInfo(); - return true; + if (!g_System->bLinkBlocks()) + { + return true; + } + if (!CreateBlockLinkage(m_EnterSection)) + { + return false; + } + DetermineLoops(); + LogSectionInfo(); + return true; } -bool CCodeBlock::AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & ContinuePC, bool & LikelyBranch, bool & IncludeDelaySlot, bool & EndBlock, bool & PermLoop ) +bool CCodeBlock::AnalyzeInstruction ( uint32_t PC, uint32_t & TargetPC, uint32_t & ContinuePC, bool & LikelyBranch, bool & IncludeDelaySlot, bool & EndBlock, bool & PermLoop ) { - TargetPC = (DWORD)-1; - ContinuePC = (DWORD)-1; - LikelyBranch = false; - IncludeDelaySlot = false; - EndBlock = false; - PermLoop = false; + TargetPC = (uint32_t)-1; + ContinuePC = (uint32_t)-1; + LikelyBranch = false; + IncludeDelaySlot = false; + EndBlock = false; + PermLoop = false; - OPCODE Command; - if (!g_MMU->LW_VAddr(PC, Command.Hex)) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; - } + OPCODE Command; + if (!g_MMU->LW_VAddr(PC, Command.Hex)) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + return false; + } #ifdef _DEBUG - char * Name = R4300iOpcodeName(Command.Hex,PC); - CPU_Message(" 0x%08X %s",PC,Name); + const char * Name = R4300iOpcodeName(Command.Hex,PC); + CPU_Message(" 0x%08X %s",PC,Name); #endif - switch (Command.op) - { - case R4300i_SPECIAL: - switch (Command.funct) - { - case R4300i_SPECIAL_SLL: case R4300i_SPECIAL_SRL: case R4300i_SPECIAL_SRA: - case R4300i_SPECIAL_SLLV: case R4300i_SPECIAL_SRLV: case R4300i_SPECIAL_SRAV: - case R4300i_SPECIAL_MFHI: case R4300i_SPECIAL_MTHI: case R4300i_SPECIAL_MFLO: - case R4300i_SPECIAL_MTLO: case R4300i_SPECIAL_DSLLV: case R4300i_SPECIAL_DSRLV: - case R4300i_SPECIAL_DSRAV: case R4300i_SPECIAL_ADD: case R4300i_SPECIAL_ADDU: - case R4300i_SPECIAL_SUB: case R4300i_SPECIAL_SUBU: case R4300i_SPECIAL_AND: - case R4300i_SPECIAL_OR: case R4300i_SPECIAL_XOR: case R4300i_SPECIAL_NOR: - case R4300i_SPECIAL_SLT: case R4300i_SPECIAL_SLTU: case R4300i_SPECIAL_DADD: - case R4300i_SPECIAL_DADDU: case R4300i_SPECIAL_DSUB: case R4300i_SPECIAL_DSUBU: - case R4300i_SPECIAL_DSLL: case R4300i_SPECIAL_DSRL: case R4300i_SPECIAL_DSRA: - case R4300i_SPECIAL_DSLL32: case R4300i_SPECIAL_DSRL32: case R4300i_SPECIAL_DSRA32: - case R4300i_SPECIAL_MULT: case R4300i_SPECIAL_MULTU: case R4300i_SPECIAL_DIV: - case R4300i_SPECIAL_DIVU: case R4300i_SPECIAL_DMULT: case R4300i_SPECIAL_DMULTU: - case R4300i_SPECIAL_DDIV: case R4300i_SPECIAL_DDIVU: - break; - case R4300i_SPECIAL_JALR: - case R4300i_SPECIAL_JR: - EndBlock = true; - IncludeDelaySlot = true; - break; - case R4300i_SPECIAL_SYSCALL: - case R4300i_SPECIAL_BREAK: - EndBlock = true; - break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; - } - break; - case R4300i_REGIMM: - switch (Command.rt) - { - case R4300i_REGIMM_BLTZ: - case R4300i_REGIMM_BLTZAL: - TargetPC = PC + ((short)Command.offset << 2) + 4; - if (TargetPC == PC + 8) - { - TargetPC = (DWORD)-1; - } - else - { - if (TargetPC == PC && !DelaySlotEffectsCompare(PC,Command.rs,0)) - { - PermLoop = true; - } - ContinuePC = PC + 8; - IncludeDelaySlot = true; - } - break; - case R4300i_REGIMM_BGEZ: - case R4300i_REGIMM_BGEZAL: - TargetPC = PC + ((short)Command.offset << 2) + 4; - if (TargetPC == PC + 8) - { - TargetPC = (DWORD)-1; - } - else - { - if (TargetPC == PC) - { - if (Command.rs == 0) - { - TargetPC = (DWORD)-1; - EndBlock = true; - } - else - { - if (!DelaySlotEffectsCompare(PC,Command.rs,Command.rt)) - { - PermLoop = true; - } - } - } - if (Command.rs != 0) - { - ContinuePC = PC + 8; - } - IncludeDelaySlot = true; - } - break; - case R4300i_REGIMM_BLTZL: - case R4300i_REGIMM_BGEZL: - TargetPC = PC + ((short)Command.offset << 2) + 4; - if (TargetPC == PC) - { - if (!DelaySlotEffectsCompare(PC,Command.rs,0)) - { - PermLoop = true; - } - } - ContinuePC = PC + 8; - LikelyBranch = true; - IncludeDelaySlot = true; - break; - default: - if (Command.Hex == 0x0407000D) - { - EndBlock = true; - break; - } - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; - } - break; - case R4300i_J: - TargetPC = (PC & 0xF0000000) + (Command.target << 2); - if (TargetPC == PC) - { - PermLoop = true; - } - IncludeDelaySlot = true; - break; - case R4300i_JAL: - EndBlock = true; - IncludeDelaySlot = true; - break; - case R4300i_BEQ: - TargetPC = PC + ((short)Command.offset << 2) + 4; - if (TargetPC == PC + 8) - { - TargetPC = (DWORD)-1; - } - else - { - if (Command.rs != 0 || Command.rt != 0) - { - ContinuePC = PC + 8; - } + switch (Command.op) + { + case R4300i_SPECIAL: + switch (Command.funct) + { + case R4300i_SPECIAL_SLL: case R4300i_SPECIAL_SRL: case R4300i_SPECIAL_SRA: + case R4300i_SPECIAL_SLLV: case R4300i_SPECIAL_SRLV: case R4300i_SPECIAL_SRAV: + case R4300i_SPECIAL_MFHI: case R4300i_SPECIAL_MTHI: case R4300i_SPECIAL_MFLO: + case R4300i_SPECIAL_MTLO: case R4300i_SPECIAL_DSLLV: case R4300i_SPECIAL_DSRLV: + case R4300i_SPECIAL_DSRAV: case R4300i_SPECIAL_ADD: case R4300i_SPECIAL_ADDU: + case R4300i_SPECIAL_SUB: case R4300i_SPECIAL_SUBU: case R4300i_SPECIAL_AND: + case R4300i_SPECIAL_OR: case R4300i_SPECIAL_XOR: case R4300i_SPECIAL_NOR: + case R4300i_SPECIAL_SLT: case R4300i_SPECIAL_SLTU: case R4300i_SPECIAL_DADD: + case R4300i_SPECIAL_DADDU: case R4300i_SPECIAL_DSUB: case R4300i_SPECIAL_DSUBU: + case R4300i_SPECIAL_DSLL: case R4300i_SPECIAL_DSRL: case R4300i_SPECIAL_DSRA: + case R4300i_SPECIAL_DSLL32: case R4300i_SPECIAL_DSRL32: case R4300i_SPECIAL_DSRA32: + case R4300i_SPECIAL_MULT: case R4300i_SPECIAL_MULTU: case R4300i_SPECIAL_DIV: + case R4300i_SPECIAL_DIVU: case R4300i_SPECIAL_DMULT: case R4300i_SPECIAL_DMULTU: + case R4300i_SPECIAL_DDIV: case R4300i_SPECIAL_DDIVU: + break; + case R4300i_SPECIAL_JALR: + case R4300i_SPECIAL_JR: + EndBlock = true; + IncludeDelaySlot = true; + break; + case R4300i_SPECIAL_SYSCALL: + case R4300i_SPECIAL_BREAK: + EndBlock = true; + break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + return false; + } + break; + case R4300i_REGIMM: + switch (Command.rt) + { + case R4300i_REGIMM_BLTZ: + case R4300i_REGIMM_BLTZAL: + TargetPC = PC + ((int16_t)Command.offset << 2) + 4; + if (TargetPC == PC + 8) + { + TargetPC = (uint32_t)-1; + } + else + { + if (TargetPC == PC && !DelaySlotEffectsCompare(PC,Command.rs,0)) + { + PermLoop = true; + } + ContinuePC = PC + 8; + IncludeDelaySlot = true; + } + break; + case R4300i_REGIMM_BGEZ: + case R4300i_REGIMM_BGEZAL: + TargetPC = PC + ((int16_t)Command.offset << 2) + 4; + if (TargetPC == PC + 8) + { + TargetPC = (uint32_t)-1; + } + else + { + if (TargetPC == PC) + { + if (Command.rs == 0) + { + TargetPC = (uint32_t)-1; + EndBlock = true; + } + else + { + if (!DelaySlotEffectsCompare(PC,Command.rs,Command.rt)) + { + PermLoop = true; + } + } + } + if (Command.rs != 0) + { + ContinuePC = PC + 8; + } + IncludeDelaySlot = true; + } + break; + case R4300i_REGIMM_BLTZL: + case R4300i_REGIMM_BGEZL: + TargetPC = PC + ((int16_t)Command.offset << 2) + 4; + if (TargetPC == PC) + { + if (!DelaySlotEffectsCompare(PC,Command.rs,0)) + { + PermLoop = true; + } + } + ContinuePC = PC + 8; + LikelyBranch = true; + IncludeDelaySlot = true; + break; + default: + if (Command.Hex == 0x0407000D) + { + EndBlock = true; + break; + } + g_Notify->BreakPoint(__FILEW__,__LINE__); + return false; + } + break; + case R4300i_J: + TargetPC = (PC & 0xF0000000) + (Command.target << 2); + if (TargetPC == PC) + { + PermLoop = true; + } + IncludeDelaySlot = true; + break; + case R4300i_JAL: + EndBlock = true; + IncludeDelaySlot = true; + break; + case R4300i_BEQ: + TargetPC = PC + ((int16_t)Command.offset << 2) + 4; + if (TargetPC == PC + 8) + { + TargetPC = (uint32_t)-1; + } + else + { + if (Command.rs != 0 || Command.rt != 0) + { + ContinuePC = PC + 8; + } - if (TargetPC == PC && !DelaySlotEffectsCompare(PC,Command.rs,Command.rt)) - { - PermLoop = true; - } - IncludeDelaySlot = true; - } - break; - case R4300i_BNE: - case R4300i_BLEZ: - case R4300i_BGTZ: - TargetPC = PC + ((short)Command.offset << 2) + 4; - if (TargetPC == PC + 8) - { - TargetPC = (DWORD)-1; - } - else - { - if (TargetPC == PC) - { - if (!DelaySlotEffectsCompare(PC,Command.rs,Command.rt)) - { - PermLoop = true; - } - } - ContinuePC = PC + 8; - IncludeDelaySlot = true; - } - break; - case R4300i_CP0: - switch (Command.rs) - { - case R4300i_COP0_MT: case R4300i_COP0_MF: - break; - default: - if ( (Command.rs & 0x10 ) != 0 ) - { - switch ( Command.funct ) - { - case R4300i_COP0_CO_TLBR: case R4300i_COP0_CO_TLBWI: - case R4300i_COP0_CO_TLBWR: case R4300i_COP0_CO_TLBP: - break; - case R4300i_COP0_CO_ERET: - EndBlock = true; - break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; - } - } - else - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; - } - break; - } - break; - case R4300i_CP1: - switch (Command.fmt) - { - case R4300i_COP1_MF: case R4300i_COP1_DMF: case R4300i_COP1_CF: case R4300i_COP1_MT: - case R4300i_COP1_DMT: case R4300i_COP1_CT: case R4300i_COP1_S: case R4300i_COP1_D: - case R4300i_COP1_W: case R4300i_COP1_L: - break; - case R4300i_COP1_BC: - switch (Command.ft) { - case R4300i_COP1_BC_BCF: - case R4300i_COP1_BC_BCT: - TargetPC = PC + ((short)Command.offset << 2) + 4; - if (TargetPC == PC + 8) - { - TargetPC = (DWORD)-1; - } - else - { - if (TargetPC == PC) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - ContinuePC = PC + 8; - IncludeDelaySlot = true; - } - break; - case R4300i_COP1_BC_BCFL: - case R4300i_COP1_BC_BCTL: - TargetPC = PC + ((short)Command.offset << 2) + 4; - if (TargetPC == PC) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - ContinuePC = PC + 8; - LikelyBranch = true; - IncludeDelaySlot = true; - break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; - } - break; - case R4300i_ANDI: case R4300i_ORI: case R4300i_XORI: case R4300i_LUI: - case R4300i_ADDI: case R4300i_ADDIU: case R4300i_SLTI: case R4300i_SLTIU: - case R4300i_DADDI: case R4300i_DADDIU: case R4300i_LDL: case R4300i_LDR: - case R4300i_LB: case R4300i_LH: case R4300i_LWL: case R4300i_LW: - case R4300i_LBU: case R4300i_LHU: case R4300i_LWR: case R4300i_LWU: - case R4300i_SB: case R4300i_SH: case R4300i_SWL: case R4300i_SW: - case R4300i_SDL: case R4300i_SDR: case R4300i_SWR: case R4300i_CACHE: - case R4300i_LL: case R4300i_LWC1: case R4300i_LDC1: case R4300i_LD: - case R4300i_SC: case R4300i_SWC1: case R4300i_SDC1: case R4300i_SD: - break; - case R4300i_BEQL: - TargetPC = PC + ((short)Command.offset << 2) + 4; - if (TargetPC == PC) - { - if (!DelaySlotEffectsCompare(PC,Command.rs,Command.rt)) - { - PermLoop = true; - } - } - if (Command.rs != 0 || Command.rt != 0) - { - ContinuePC = PC + 8; - } - IncludeDelaySlot = true; - LikelyBranch = true; - break; - case R4300i_BNEL: - case R4300i_BLEZL: - case R4300i_BGTZL: - TargetPC = PC + ((short)Command.offset << 2) + 4; - ContinuePC = PC + 8; - if (TargetPC == PC) - { - if (!DelaySlotEffectsCompare(PC,Command.rs,Command.rt)) - { - PermLoop = true; - } - } - LikelyBranch = true; - IncludeDelaySlot = true; - break; - default: - if (Command.Hex == 0x7C1C97C0 || - Command.Hex == 0xF1F3F5F7) - { - EndBlock = true; - break; - } - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; - } - return true; + if (TargetPC == PC && !DelaySlotEffectsCompare(PC,Command.rs,Command.rt)) + { + PermLoop = true; + } + IncludeDelaySlot = true; + } + break; + case R4300i_BNE: + case R4300i_BLEZ: + case R4300i_BGTZ: + TargetPC = PC + ((int16_t)Command.offset << 2) + 4; + if (TargetPC == PC + 8) + { + TargetPC = (uint32_t)-1; + } + else + { + if (TargetPC == PC) + { + if (!DelaySlotEffectsCompare(PC,Command.rs,Command.rt)) + { + PermLoop = true; + } + } + ContinuePC = PC + 8; + IncludeDelaySlot = true; + } + break; + case R4300i_CP0: + switch (Command.rs) + { + case R4300i_COP0_MT: case R4300i_COP0_MF: + break; + default: + if ( (Command.rs & 0x10 ) != 0 ) + { + switch ( Command.funct ) + { + case R4300i_COP0_CO_TLBR: case R4300i_COP0_CO_TLBWI: + case R4300i_COP0_CO_TLBWR: case R4300i_COP0_CO_TLBP: + break; + case R4300i_COP0_CO_ERET: + EndBlock = true; + break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + return false; + } + } + else + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + return false; + } + break; + } + break; + case R4300i_CP1: + switch (Command.fmt) + { + case R4300i_COP1_MF: case R4300i_COP1_DMF: case R4300i_COP1_CF: case R4300i_COP1_MT: + case R4300i_COP1_DMT: case R4300i_COP1_CT: case R4300i_COP1_S: case R4300i_COP1_D: + case R4300i_COP1_W: case R4300i_COP1_L: + break; + case R4300i_COP1_BC: + switch (Command.ft) { + case R4300i_COP1_BC_BCF: + case R4300i_COP1_BC_BCT: + TargetPC = PC + ((int16_t)Command.offset << 2) + 4; + if (TargetPC == PC + 8) + { + TargetPC = (uint32_t)-1; + } + else + { + if (TargetPC == PC) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + ContinuePC = PC + 8; + IncludeDelaySlot = true; + } + break; + case R4300i_COP1_BC_BCFL: + case R4300i_COP1_BC_BCTL: + TargetPC = PC + ((int16_t)Command.offset << 2) + 4; + if (TargetPC == PC) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + ContinuePC = PC + 8; + LikelyBranch = true; + IncludeDelaySlot = true; + break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + return false; + } + break; + case R4300i_ANDI: case R4300i_ORI: case R4300i_XORI: case R4300i_LUI: + case R4300i_ADDI: case R4300i_ADDIU: case R4300i_SLTI: case R4300i_SLTIU: + case R4300i_DADDI: case R4300i_DADDIU: case R4300i_LDL: case R4300i_LDR: + case R4300i_LB: case R4300i_LH: case R4300i_LWL: case R4300i_LW: + case R4300i_LBU: case R4300i_LHU: case R4300i_LWR: case R4300i_LWU: + case R4300i_SB: case R4300i_SH: case R4300i_SWL: case R4300i_SW: + case R4300i_SDL: case R4300i_SDR: case R4300i_SWR: case R4300i_CACHE: + case R4300i_LL: case R4300i_LWC1: case R4300i_LDC1: case R4300i_LD: + case R4300i_SC: case R4300i_SWC1: case R4300i_SDC1: case R4300i_SD: + break; + case R4300i_BEQL: + TargetPC = PC + ((int16_t)Command.offset << 2) + 4; + if (TargetPC == PC) + { + if (!DelaySlotEffectsCompare(PC,Command.rs,Command.rt)) + { + PermLoop = true; + } + } + if (Command.rs != 0 || Command.rt != 0) + { + ContinuePC = PC + 8; + } + IncludeDelaySlot = true; + LikelyBranch = true; + break; + case R4300i_BNEL: + case R4300i_BLEZL: + case R4300i_BGTZL: + TargetPC = PC + ((int16_t)Command.offset << 2) + 4; + ContinuePC = PC + 8; + if (TargetPC == PC) + { + if (!DelaySlotEffectsCompare(PC,Command.rs,Command.rt)) + { + PermLoop = true; + } + } + LikelyBranch = true; + IncludeDelaySlot = true; + break; + default: + if (Command.Hex == 0x7C1C97C0 || + Command.Hex == 0xF1F3F5F7) + { + EndBlock = true; + break; + } + g_Notify->BreakPoint(__FILEW__,__LINE__); + return false; + } + return true; } bool CCodeBlock::Compile() { - CPU_Message("====== Code Block ======"); - CPU_Message("x86 code at: %X",CompiledLocation()); - CPU_Message("Start of Block: %X",VAddrEnter() ); - CPU_Message("No of Sections: %d",NoOfSections() ); - CPU_Message("====== recompiled code ======"); + CPU_Message("====== Code Block ======"); + CPU_Message("x86 code at: %X",CompiledLocation()); + CPU_Message("Start of Block: %X",VAddrEnter() ); + CPU_Message("No of Sections: %d",NoOfSections() ); + CPU_Message("====== recompiled code ======"); - EnterCodeBlock(); + EnterCodeBlock(); - if (g_SyncSystem) - { - //if ((DWORD)BlockInfo.CompiledLocation == 0x60A7B73B) - //{ - // X86BreakPoint(__FILEW__,__LINE__); - //} - //MoveConstToVariable((DWORD)BlockInfo.CompiledLocation,&CurrentBlock,"CurrentBlock"); - } + if (g_SyncSystem) + { + //if ((uint32_t)BlockInfo.CompiledLocation == 0x60A7B73B) + //{ + // X86BreakPoint(__FILEW__,__LINE__); + //} + //MoveConstToVariable((uint32_t)BlockInfo.CompiledLocation,&CurrentBlock,"CurrentBlock"); + } - if (g_System->bLinkBlocks()) - { - while (m_EnterSection->GenerateX86Code(NextTest())); - } - else - { - if (!m_EnterSection->GenerateX86Code(NextTest())) - { - return false; - } - } - CompileExitCode(); + if (g_System->bLinkBlocks()) + { + while (m_EnterSection->GenerateX86Code(NextTest())); + } + else + { + if (!m_EnterSection->GenerateX86Code(NextTest())) + { + return false; + } + } + CompileExitCode(); - uint32_t PAddr; - g_TransVaddr->TranslateVaddr(VAddrFirst(),PAddr); - MD5(g_MMU->Rdram() + PAddr,(VAddrLast() - VAddrFirst()) + 4).get_digest(m_Hash); + uint32_t PAddr; + g_TransVaddr->TranslateVaddr(VAddrFirst(),PAddr); + MD5(g_MMU->Rdram() + PAddr,(VAddrLast() - VAddrFirst()) + 4).get_digest(m_Hash); - return true; + return true; } - void CCodeBlock::CompileExitCode() { - for (EXIT_LIST::iterator ExitIter = m_ExitInfo.begin(); ExitIter != m_ExitInfo.end(); ExitIter++) - { - CPU_Message(""); - CPU_Message(" $Exit_%d",ExitIter->ID); - SetJump32(ExitIter->JumpLoc,(DWORD *)m_RecompPos); - m_NextInstruction = ExitIter->NextInstruction; - m_EnterSection->CompileExit((DWORD)-1, ExitIter->TargetPC,ExitIter->ExitRegSet,ExitIter->reason,true,NULL); - } + for (EXIT_LIST::iterator ExitIter = m_ExitInfo.begin(); ExitIter != m_ExitInfo.end(); ExitIter++) + { + CPU_Message(""); + CPU_Message(" $Exit_%d",ExitIter->ID); + SetJump32(ExitIter->JumpLoc,(DWORD *)m_RecompPos); + m_NextInstruction = ExitIter->NextInstruction; + m_EnterSection->CompileExit((uint32_t)-1, ExitIter->TargetPC,ExitIter->ExitRegSet,ExitIter->reason,true,NULL); + } } -DWORD CCodeBlock::NextTest() +uint32_t CCodeBlock::NextTest() { - return InterlockedIncrement(&m_Test); + uint32_t next_test = m_Test; + m_Test += 1; + return next_test; } diff --git a/Source/Project64/N64 System/Recompiler/Code Block.h b/Source/Project64/N64 System/Recompiler/Code Block.h index fe80196e9..7999b7691 100644 --- a/Source/Project64/N64 System/Recompiler/Code Block.h +++ b/Source/Project64/N64 System/Recompiler/Code Block.h @@ -11,63 +11,63 @@ #pragma once class CCodeBlock : - private CRecompilerOps + private CRecompilerOps { public: - CCodeBlock(DWORD VAddrEnter, BYTE * RecompPos ); - ~CCodeBlock(); + CCodeBlock(uint32_t VAddrEnter, uint8_t * RecompPos ); + ~CCodeBlock(); - bool Compile(); + bool Compile(); - DWORD VAddrEnter() const { return m_VAddrEnter; } - DWORD VAddrFirst() const { return m_VAddrFirst; } - DWORD VAddrLast() const { return m_VAddrLast; } - BYTE * CompiledLocation() const { return m_CompiledLocation; } - int NoOfSections() const { return m_Sections.size(); } - const CCodeSection & EnterSection() const { return *m_EnterSection; } - const MD5Digest & Hash() const { return m_Hash; } + uint32_t VAddrEnter() const { return m_VAddrEnter; } + uint32_t VAddrFirst() const { return m_VAddrFirst; } + uint32_t VAddrLast() const { return m_VAddrLast; } + uint8_t * CompiledLocation() const { return m_CompiledLocation; } + int32_t NoOfSections() const { return m_Sections.size(); } + const CCodeSection & EnterSection() const { return *m_EnterSection; } + const MD5Digest & Hash() const { return m_Hash; } - void SetVAddrFirst(DWORD VAddr) { m_VAddrFirst = VAddr; } - void SetVAddrLast(DWORD VAddr) { m_VAddrLast = VAddr; } + void SetVAddrFirst(uint32_t VAddr) { m_VAddrFirst = VAddr; } + void SetVAddrLast(uint32_t VAddr) { m_VAddrLast = VAddr; } - CCodeSection * ExistingSection(DWORD Addr) { return m_EnterSection->ExistingSection(Addr, NextTest()); } - bool SectionAccessible(DWORD m_SectionID) { return m_EnterSection->SectionAccessible(m_SectionID, NextTest()); } + CCodeSection * ExistingSection(uint32_t Addr) { return m_EnterSection->ExistingSection(Addr, NextTest()); } + bool SectionAccessible(uint32_t m_SectionID) { return m_EnterSection->SectionAccessible(m_SectionID, NextTest()); } - QWORD MemContents(int i) const { return m_MemContents[i]; } - QWORD * MemLocation(int i) const { return m_MemLocation[i]; } + uint64_t MemContents(int32_t i) const { return m_MemContents[i]; } + uint64_t * MemLocation(int32_t i) const { return m_MemLocation[i]; } - DWORD NextTest(); + uint32_t NextTest(); - EXIT_LIST m_ExitInfo; + EXIT_LIST m_ExitInfo; private: - CCodeBlock(); // Disable default constructor - CCodeBlock(const CCodeBlock&); // Disable copy constructor - CCodeBlock& operator=(const CCodeBlock&); // Disable assignment + CCodeBlock(); // Disable default constructor + CCodeBlock(const CCodeBlock&); // Disable copy constructor + CCodeBlock& operator=(const CCodeBlock&); // Disable assignment - bool AnalyseBlock(); - void CompileExitCode(); + bool AnalyseBlock(); + void CompileExitCode(); - bool CreateBlockLinkage ( CCodeSection * EnterSection ); - void DetermineLoops (); - void LogSectionInfo (); - bool SetSection ( CCodeSection * & Section, CCodeSection * CurrentSection, DWORD TargetPC, bool LinkAllowed, DWORD CurrentPC ); - bool AnalyzeInstruction ( DWORD PC, DWORD & TargetPC, DWORD & ContinuePC, bool & LikelyBranch, bool & IncludeDelaySlot, - bool & EndBlock, bool & PermLoop ); + bool CreateBlockLinkage ( CCodeSection * EnterSection ); + void DetermineLoops (); + void LogSectionInfo (); + bool SetSection ( CCodeSection * & Section, CCodeSection * CurrentSection, uint32_t TargetPC, bool LinkAllowed, uint32_t CurrentPC ); + bool AnalyzeInstruction ( uint32_t PC, uint32_t & TargetPC, uint32_t & ContinuePC, bool & LikelyBranch, bool & IncludeDelaySlot, + bool & EndBlock, bool & PermLoop ); - DWORD m_VAddrEnter; - DWORD m_VAddrFirst; // the address of the first opcode in the block - DWORD m_VAddrLast; // the address of the first opcode in the block - BYTE* m_CompiledLocation; // What address is this compiled at - - typedef std::map SectionMap; - typedef std::list SectionList; + uint32_t m_VAddrEnter; + uint32_t m_VAddrFirst; // the address of the first opcode in the block + uint32_t m_VAddrLast; // the address of the first opcode in the block + uint8_t* m_CompiledLocation; // What address is this compiled at - SectionMap m_SectionMap; - SectionList m_Sections; - CCodeSection * m_EnterSection; - long m_Test; - MD5Digest m_Hash; - QWORD m_MemContents[2]; - QWORD * m_MemLocation[2]; + typedef std::map SectionMap; + typedef std::list SectionList; + + SectionMap m_SectionMap; + SectionList m_Sections; + CCodeSection * m_EnterSection; + int32_t m_Test; + MD5Digest m_Hash; + uint64_t m_MemContents[2]; + uint64_t * m_MemLocation[2]; }; From cfdb5dc8d011839a99e862d976b84672c7833e49 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 9 Nov 2015 08:11:57 +1100 Subject: [PATCH 097/213] [Project64] Update X86ops.cpp to use standard types --- .../N64 System/Recompiler/Code Block.cpp | 2 +- .../N64 System/Recompiler/Code Section.cpp | 44 +- .../N64 System/Recompiler/Code Section.h | 2 +- .../N64 System/Recompiler/Exit Info.h | 2 +- .../N64 System/Recompiler/Recompiler Ops.cpp | 30 +- .../N64 System/Recompiler/X86ops.cpp | 7820 +++++++++-------- .../Project64/N64 System/Recompiler/X86ops.h | 549 +- 7 files changed, 4448 insertions(+), 4001 deletions(-) diff --git a/Source/Project64/N64 System/Recompiler/Code Block.cpp b/Source/Project64/N64 System/Recompiler/Code Block.cpp index 859a6b1b1..c618bf89d 100644 --- a/Source/Project64/N64 System/Recompiler/Code Block.cpp +++ b/Source/Project64/N64 System/Recompiler/Code Block.cpp @@ -743,7 +743,7 @@ void CCodeBlock::CompileExitCode() { CPU_Message(""); CPU_Message(" $Exit_%d",ExitIter->ID); - SetJump32(ExitIter->JumpLoc,(DWORD *)m_RecompPos); + SetJump32(ExitIter->JumpLoc,(uint32_t *)m_RecompPos); m_NextInstruction = ExitIter->NextInstruction; m_EnterSection->CompileExit((uint32_t)-1, ExitIter->TargetPC,ExitIter->ExitRegSet,ExitIter->reason,true,NULL); } diff --git a/Source/Project64/N64 System/Recompiler/Code Section.cpp b/Source/Project64/N64 System/Recompiler/Code Section.cpp index 3caf8fd4e..0567ad138 100644 --- a/Source/Project64/N64 System/Recompiler/Code Section.cpp +++ b/Source/Project64/N64 System/Recompiler/Code Section.cpp @@ -108,7 +108,7 @@ CCodeSection::~CCodeSection() { } -void CCodeSection::CompileExit(DWORD JumpPC, DWORD TargetPC, CRegInfo &ExitRegSet, CExitInfo::EXIT_REASON reason, bool CompileNow, void(*x86Jmp)(const char * Label, DWORD Value)) +void CCodeSection::CompileExit(DWORD JumpPC, DWORD TargetPC, CRegInfo &ExitRegSet, CExitInfo::EXIT_REASON reason, bool CompileNow, void(*x86Jmp)(const char * Label, uint32_t Value)) { if (!CompileNow) { @@ -127,7 +127,7 @@ void CCodeSection::CompileExit(DWORD JumpPC, DWORD TargetPC, CRegInfo &ExitRegSe ExitInfo.ExitRegSet = ExitRegSet; ExitInfo.reason = reason; ExitInfo.NextInstruction = m_NextInstruction; - ExitInfo.JumpLoc = (DWORD *)(m_RecompPos - 4); + ExitInfo.JumpLoc = (uint32_t *)(m_RecompPos - 4); m_BlockInfo->m_ExitInfo.push_back(ExitInfo); return; } @@ -444,10 +444,10 @@ void CCodeSection::GenerateSectionLinkage() } } else if (TargetSection[i] == NULL && JumpInfo[i]->FallThrough) { if (JumpInfo[i]->LinkLocation != NULL) { - SetJump32(JumpInfo[i]->LinkLocation,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo[i]->LinkLocation,(uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation = NULL; if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32(JumpInfo[i]->LinkLocation2,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2,(uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; } } @@ -457,10 +457,10 @@ void CCodeSection::GenerateSectionLinkage() if (!JumpInfo[i]->FallThrough) { continue; } if (JumpInfo[i]->TargetPC == TargetSection[i]->m_EnterPC) { continue; } if (JumpInfo[i]->LinkLocation != NULL) { - SetJump32(JumpInfo[i]->LinkLocation,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo[i]->LinkLocation,(uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation = NULL; if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32(JumpInfo[i]->LinkLocation2,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2,(uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; } } @@ -488,10 +488,10 @@ void CCodeSection::GenerateSectionLinkage() sprintf(Label,"Section_%d",TargetSection[i]->m_SectionID); JumpInfo[i]->FallThrough = false; if (JumpInfo[i]->LinkLocation != NULL) { - SetJump32(JumpInfo[i]->LinkLocation,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo[i]->LinkLocation,(uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation = NULL; if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32(JumpInfo[i]->LinkLocation2,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2,(uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; } } @@ -524,7 +524,7 @@ void CCodeSection::GenerateSectionLinkage() m_RegWorkingSet = JumpInfo[i]->RegSet; SyncRegState(TargetSection[i]->m_RegEnter); JmpLabel32(Label,0); - SetJump32((DWORD *)m_RecompPos - 1,(DWORD *)(TargetSection[i]->m_CompiledLocation)); + SetJump32((uint32_t *)m_RecompPos - 1,(uint32_t *)(TargetSection[i]->m_CompiledLocation)); } } @@ -582,10 +582,10 @@ void CCodeSection::GenerateSectionLinkage() if (JumpInfo[i]->LinkLocation == NULL) { continue; } if (TargetSection[i] == NULL) { CPU_Message("ExitBlock (from %d):",m_SectionID); - SetJump32(JumpInfo[i]->LinkLocation,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo[i]->LinkLocation,(uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation = NULL; if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32(JumpInfo[i]->LinkLocation2,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2,(uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; } CompileExit (JumpInfo[i]->JumpPC,JumpInfo[i]->TargetPC,JumpInfo[i]->RegSet,JumpInfo[i]->ExitReason,true,NULL); @@ -602,10 +602,10 @@ void CCodeSection::GenerateSectionLinkage() stdstr_f Label("Section_%d (from %d):",TargetSection[i]->m_SectionID,m_SectionID); CPU_Message(Label.c_str()); - SetJump32(JumpInfo[i]->LinkLocation,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo[i]->LinkLocation,(uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation = NULL; if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32(JumpInfo[i]->LinkLocation2,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2,(uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; } m_RegWorkingSet = JumpInfo[i]->RegSet; @@ -627,7 +627,7 @@ void CCodeSection::GenerateSectionLinkage() m_RegWorkingSet = JumpInfo[i]->RegSet; SyncRegState(TargetSection[i]->m_RegEnter); JmpLabel32(Label.c_str(),0); - SetJump32((DWORD *)m_RecompPos - 1,(DWORD *)(TargetSection[i]->m_CompiledLocation)); + SetJump32((uint32_t *)m_RecompPos - 1,(uint32_t *)(TargetSection[i]->m_CompiledLocation)); } } } @@ -1658,9 +1658,9 @@ bool CCodeSection::InheritParentInfo() m_RegEnter = JumpInfo->RegSet; if (JumpInfo->LinkLocation != NULL) { CPU_Message(" Section_%d:",m_SectionID); - SetJump32(JumpInfo->LinkLocation,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo->LinkLocation,(uint32_t *)m_RecompPos); if (JumpInfo->LinkLocation2 != NULL) { - SetJump32(JumpInfo->LinkLocation2,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo->LinkLocation2,(uint32_t *)m_RecompPos); } } m_RegWorkingSet = m_RegEnter; @@ -1743,10 +1743,10 @@ bool CCodeSection::InheritParentInfo() if (JumpInfo->LinkLocation != NULL) { CPU_Message(" Section_%d (from %d):",m_SectionID,Parent->m_SectionID); - SetJump32(JumpInfo->LinkLocation,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo->LinkLocation,(uint32_t *)m_RecompPos); JumpInfo->LinkLocation = NULL; if (JumpInfo->LinkLocation2 != NULL) { - SetJump32(JumpInfo->LinkLocation2,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo->LinkLocation2,(uint32_t *)m_RecompPos); JumpInfo->LinkLocation2 = NULL; } } @@ -1981,10 +1981,10 @@ bool CCodeSection::InheritParentInfo() JumpInfo = ParentList[CurrentParent].JumpInfo; CPU_Message(" Section_%d (from %d):",m_SectionID,Parent->m_SectionID); if (JumpInfo->LinkLocation != NULL) { - SetJump32(JumpInfo->LinkLocation,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo->LinkLocation,(uint32_t *)m_RecompPos); JumpInfo->LinkLocation = NULL; if (JumpInfo->LinkLocation2 != NULL) { - SetJump32(JumpInfo->LinkLocation2,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo->LinkLocation2,(uint32_t *)m_RecompPos); JumpInfo->LinkLocation2 = NULL; } } @@ -2010,10 +2010,10 @@ bool CCodeSection::InheritParentInfo() JumpInfo = ParentList[i].JumpInfo; if (JumpInfo->LinkLocation != NULL) { - SetJump32(JumpInfo->LinkLocation,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo->LinkLocation,(uint32_t *)m_RecompPos); JumpInfo->LinkLocation = NULL; if (JumpInfo->LinkLocation2 != NULL) { - SetJump32(JumpInfo->LinkLocation2,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo->LinkLocation2,(uint32_t *)m_RecompPos); JumpInfo->LinkLocation2 = NULL; } } diff --git a/Source/Project64/N64 System/Recompiler/Code Section.h b/Source/Project64/N64 System/Recompiler/Code Section.h index 979aafd9d..f767d8317 100644 --- a/Source/Project64/N64 System/Recompiler/Code Section.h +++ b/Source/Project64/N64 System/Recompiler/Code Section.h @@ -27,7 +27,7 @@ public: void CompileCop1Test (); bool GenerateX86Code ( DWORD Test ); void GenerateSectionLinkage (); - void CompileExit ( DWORD JumpPC, DWORD TargetPC, CRegInfo &ExitRegSet, CExitInfo::EXIT_REASON reason, bool CompileNow, void (*x86Jmp)(const char * Label, DWORD Value)); + void CompileExit ( DWORD JumpPC, DWORD TargetPC, CRegInfo &ExitRegSet, CExitInfo::EXIT_REASON reason, bool CompileNow, void (*x86Jmp)(const char * Label, uint32_t Value)); void DetermineLoop ( DWORD Test, DWORD Test2, DWORD TestID ); bool FixConstants ( DWORD Test ); CCodeSection * ExistingSection ( DWORD Addr, DWORD Test ); diff --git a/Source/Project64/N64 System/Recompiler/Exit Info.h b/Source/Project64/N64 System/Recompiler/Exit Info.h index 9997771dc..b5d7247a5 100644 --- a/Source/Project64/N64 System/Recompiler/Exit Info.h +++ b/Source/Project64/N64 System/Recompiler/Exit Info.h @@ -31,7 +31,7 @@ public: CRegInfo ExitRegSet; EXIT_REASON reason; STEP_TYPE NextInstruction; - DWORD * JumpLoc; //32bit jump + uint32_t * JumpLoc; //32bit jump }; typedef std::list EXIT_LIST; diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp index 383e72c4b..2fa6da89a 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp @@ -132,20 +132,20 @@ void CRecompilerOps::Compile_Branch (CRecompilerOps::BranchFunction CompareFunc, if (m_Section->m_Jump.LinkLocation != NULL) { CPU_Message(""); CPU_Message(" %s:",m_Section->m_Jump.BranchLabel.c_str()); - SetJump32((DWORD *)m_Section->m_Jump.LinkLocation,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)m_Section->m_Jump.LinkLocation,(uint32_t *)m_RecompPos); m_Section->m_Jump.LinkLocation = NULL; if (m_Section->m_Jump.LinkLocation2 != NULL) { - SetJump32((DWORD *)m_Section->m_Jump.LinkLocation2,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)m_Section->m_Jump.LinkLocation2,(uint32_t *)m_RecompPos); m_Section->m_Jump.LinkLocation2 = NULL; } m_Section->m_Jump.FallThrough = true; } else if (m_Section->m_Cont.LinkLocation != NULL){ CPU_Message(""); CPU_Message(" %s:",m_Section->m_Cont.BranchLabel.c_str()); - SetJump32((DWORD *)m_Section->m_Cont.LinkLocation,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)m_Section->m_Cont.LinkLocation,(uint32_t *)m_RecompPos); m_Section->m_Cont.LinkLocation = NULL; if (m_Section->m_Cont.LinkLocation2 != NULL) { - SetJump32((DWORD *)m_Section->m_Cont.LinkLocation2,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)m_Section->m_Cont.LinkLocation2,(uint32_t *)m_RecompPos); m_Section->m_Cont.LinkLocation2 = NULL; } m_Section->m_Cont.FallThrough = true; @@ -179,10 +179,10 @@ void CRecompilerOps::Compile_Branch (CRecompilerOps::BranchFunction CompareFunc, CPU_Message(" "); CPU_Message(" %s:",m_Section->m_Jump.BranchLabel.c_str()); - SetJump32(m_Section->m_Jump.LinkLocation,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)m_Section->m_Jump.LinkLocation,(uint32_t *)m_RecompPos); m_Section->m_Jump.LinkLocation = NULL; if (m_Section->m_Jump.LinkLocation2 != NULL) { - SetJump32(m_Section->m_Jump.LinkLocation2,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)m_Section->m_Jump.LinkLocation2,(uint32_t *)m_RecompPos); m_Section->m_Jump.LinkLocation2 = NULL; } MoveConstToVariable(m_Section->m_Jump.TargetPC,&R4300iOp::m_JumpToLocation,"R4300iOp::m_JumpToLocation"); @@ -195,10 +195,10 @@ void CRecompilerOps::Compile_Branch (CRecompilerOps::BranchFunction CompareFunc, CPU_Message(" "); CPU_Message(" %s:",m_Section->m_Cont.BranchLabel.c_str()); - SetJump32(m_Section->m_Cont.LinkLocation,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)m_Section->m_Cont.LinkLocation,(uint32_t *)m_RecompPos); m_Section->m_Cont.LinkLocation = NULL; if (m_Section->m_Cont.LinkLocation2 != NULL) { - SetJump32(m_Section->m_Cont.LinkLocation2,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)m_Section->m_Cont.LinkLocation2,(uint32_t *)m_RecompPos); m_Section->m_Cont.LinkLocation2 = NULL; } MoveConstToVariable(m_Section->m_Cont.TargetPC,&R4300iOp::m_JumpToLocation,"R4300iOp::m_JumpToLocation"); @@ -254,10 +254,10 @@ void CRecompilerOps::Compile_Branch (CRecompilerOps::BranchFunction CompareFunc, if (JumpInfo->LinkLocation != NULL) { CPU_Message(" %s:",JumpInfo->BranchLabel.c_str()); - SetJump32((DWORD *)JumpInfo->LinkLocation,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo->LinkLocation,(uint32_t *)m_RecompPos); JumpInfo->LinkLocation = NULL; if (JumpInfo->LinkLocation2 != NULL) { - SetJump32((DWORD *)JumpInfo->LinkLocation2,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo->LinkLocation2,(uint32_t *)m_RecompPos); JumpInfo->LinkLocation2 = NULL; } JumpInfo->FallThrough = true; @@ -363,10 +363,10 @@ void CRecompilerOps::Compile_BranchLikely (BranchFunction CompareFunc, bool Link if (m_Section->m_Jump.LinkLocation != NULL || m_Section->m_Jump.FallThrough) { if (m_Section->m_Jump.LinkLocation != NULL) { - SetJump32(m_Section->m_Jump.LinkLocation,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)m_Section->m_Jump.LinkLocation,(uint32_t *)m_RecompPos); m_Section->m_Jump.LinkLocation = NULL; if (m_Section->m_Jump.LinkLocation2 != NULL) { - SetJump32(m_Section->m_Jump.LinkLocation2,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)m_Section->m_Jump.LinkLocation2,(uint32_t *)m_RecompPos); m_Section->m_Jump.LinkLocation2 = NULL; } } @@ -380,10 +380,10 @@ void CRecompilerOps::Compile_BranchLikely (BranchFunction CompareFunc, bool Link } if (m_Section->m_Cont.LinkLocation != NULL) { - SetJump32(m_Section->m_Cont.LinkLocation,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)m_Section->m_Cont.LinkLocation,(uint32_t *)m_RecompPos); m_Section->m_Cont.LinkLocation = NULL; if (m_Section->m_Cont.LinkLocation2 != NULL) { - SetJump32(m_Section->m_Cont.LinkLocation2,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)m_Section->m_Cont.LinkLocation2,(uint32_t *)m_RecompPos); m_Section->m_Cont.LinkLocation2 = NULL; } } @@ -5242,7 +5242,7 @@ void CRecompilerOps::CompileSystemCheck (DWORD TargetPC, const CRegInfo & RegSet ExitCodeBlock(); CPU_Message(""); CPU_Message(" $Continue_From_Interrupt_Test:"); - SetJump32(Jump,(DWORD *)m_RecompPos); + SetJump32((uint32_t *)Jump,(uint32_t *)m_RecompPos); } void CRecompilerOps::OverflowDelaySlot(bool TestTimer) diff --git a/Source/Project64/N64 System/Recompiler/X86ops.cpp b/Source/Project64/N64 System/Recompiler/X86ops.cpp index 9bf6c0df1..cdc2a8c95 100644 --- a/Source/Project64/N64 System/Recompiler/X86ops.cpp +++ b/Source/Project64/N64 System/Recompiler/X86ops.cpp @@ -10,3833 +10,4279 @@ ****************************************************************************/ #include "stdafx.h" -#define PUTDST8(dest,value) (*((BYTE *)(dest))=(BYTE)(value)); dest += 1; -#define PUTDST16(dest,value) (*((WORD *)(dest))=(WORD)(value)); dest += 2; -#define PUTDST32(dest,value) (*((DWORD *)(dest))=(DWORD)(value)); dest += 4; +#define PUTDST8(dest,value) (*((uint8_t *)(dest))=(uint8_t)(value)); dest += 1; +#define PUTDST16(dest,value) (*((uint16_t *)(dest))=(uint16_t)(value)); dest += 2; +#define PUTDST32(dest,value) (*((uint32_t *)(dest))=(uint32_t)(value)); dest += 4; -BYTE * CX86Ops::m_RecompPos; +uint8_t * CX86Ops::m_RecompPos; -char CX86Ops::m_fpupop[2][2] = { - "", "p" +char CX86Ops::m_fpupop[2][2] = +{ + "", "p" }; CX86Ops::x86Reg CX86Ops::x86_Registers[8] = { - x86_ESI, - x86_EDI, - x86_EBX, - x86_ECX, - x86_EDX, - x86_EAX, - x86_EBP, - x86_ESP + x86_ESI, + x86_EDI, + x86_EBX, + x86_ECX, + x86_EDX, + x86_EAX, + x86_EBP, + x86_ESP }; /************************************************************************** * Logging Functions * **************************************************************************/ -void CX86Ops::WriteX86Comment ( LPCSTR Comment ) +void CX86Ops::WriteX86Comment ( const char * Comment ) { - CPU_Message(""); - CPU_Message(" // %s",Comment); + CPU_Message(""); + CPU_Message(" // %s",Comment); } -void CX86Ops::WriteX86Label ( LPCSTR Label ) +void CX86Ops::WriteX86Label ( const char * Label ) { - CPU_Message(""); - CPU_Message(" %s:",Label); + CPU_Message(""); + CPU_Message(" %s:",Label); } -void CX86Ops::AdcX86regToVariable(x86Reg reg, void * Variable, const char * VariableName) { - CPU_Message(" adc dword ptr [%s], %s",VariableName, x86_Name(reg)); - PUTDST16(m_RecompPos,0x0511 + (reg * 0x100)); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::AdcConstToVariable(void *Variable, const char * VariableName, BYTE Constant) { - CPU_Message(" adc dword ptr [%s], %Xh", VariableName, Constant); - PUTDST16(m_RecompPos,0x1583); +void CX86Ops::AdcX86regToVariable(x86Reg reg, void * Variable, const char * VariableName) +{ + CPU_Message(" adc dword ptr [%s], %s",VariableName, x86_Name(reg)); + PUTDST16(m_RecompPos,0x0511 + (reg * 0x100)); PUTDST32(m_RecompPos,Variable); - PUTDST8(m_RecompPos,Constant); } -void CX86Ops::AdcConstToX86Reg (x86Reg reg, DWORD Const) { - CPU_Message(" adc %s, %Xh",x86_Name(reg),Const); - if ((Const & 0xFFFFFF80) != 0 && (Const & 0xFFFFFF80) != 0xFFFFFF80) { - PUTDST16(m_RecompPos,0xD081 + (reg * 0x100)); - PUTDST32(m_RecompPos, Const); - } else { - PUTDST16(m_RecompPos,0xD083 + (reg * 0x100)); - PUTDST8(m_RecompPos, Const); - } -} - -void CX86Ops::AdcVariableToX86reg(x86Reg reg, void * Variable, const char * VariableName) { - CPU_Message(" adc %s, dword ptr [%s]",x86_Name(reg),VariableName); - PUTDST16(m_RecompPos,0x0513 + (reg * 0x800)); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::AdcX86RegToX86Reg(x86Reg Destination, x86Reg Source) { - CPU_Message(" adc %s, %s",x86_Name(Destination),x86_Name(Source)); - PUTDST16(m_RecompPos,0xC013 + (Source * 0x100) + (Destination * 0x800)); -} - -void CX86Ops::AddConstToVariable (DWORD Const, void *Variable, const char * VariableName) { - CPU_Message(" add dword ptr [%s], 0x%X",VariableName, Const);\ - PUTDST16(m_RecompPos,0x0581); - PUTDST32(m_RecompPos,Variable); - PUTDST32(m_RecompPos,Const); -} - -void CX86Ops::AddConstToX86Reg (x86Reg reg, DWORD Const) { - if (Const == 0) - { - } else if (Const == 1) { - IncX86reg(reg); - } else if (Const == 0xFFFFFFFF) { - DecX86reg(reg); - } else if ((Const & 0xFFFFFF80) != 0 && (Const & 0xFFFFFF80) != 0xFFFFFF80) { - CPU_Message(" add %s, %Xh",x86_Name(reg),Const); - PUTDST16(m_RecompPos,0xC081 + (reg * 0x100)); - PUTDST32(m_RecompPos, Const); - } else { - CPU_Message(" add %s, %Xh",x86_Name(reg),Const); - PUTDST16(m_RecompPos,0xC083 + (reg * 0x100)); - PUTDST8(m_RecompPos, Const); - } -} - -void CX86Ops::AddVariableToX86reg(x86Reg reg, void * Variable, const char * VariableName) { - CPU_Message(" add %s, dword ptr [%s]",x86_Name(reg),VariableName); - PUTDST16(m_RecompPos,0x0503 + (reg * 0x800)); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::AddX86regToVariable(x86Reg reg, void * Variable, const char * VariableName) { - CPU_Message(" add dword ptr [%s], %s",VariableName, x86_Name(reg)); - PUTDST16(m_RecompPos,0x0501 + (reg * 0x800)); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::AddX86RegToX86Reg(x86Reg Destination, x86Reg Source) { - CPU_Message(" add %s, %s",x86_Name(Destination),x86_Name(Source)); - PUTDST16(m_RecompPos,0xC003 + (Source * 0x100) + (Destination * 0x800)); -} - -void CX86Ops::AndConstToVariable (DWORD Const, void *Variable, const char * VariableName) +void CX86Ops::AdcConstToVariable(void *Variable, const char * VariableName, uint8_t Constant) { - CPU_Message(" and dword ptr [%s], 0x%X",VariableName, Const); - PUTDST16(m_RecompPos,0x2581); - PUTDST32(m_RecompPos,Variable); - PUTDST32(m_RecompPos,Const); + CPU_Message(" adc dword ptr [%s], %Xh", VariableName, Constant); + PUTDST16(m_RecompPos,0x1583); + PUTDST32(m_RecompPos,Variable); + PUTDST8(m_RecompPos,Constant); } -void CX86Ops::AndConstToX86Reg(x86Reg reg, DWORD Const) { - CPU_Message(" and %s, %Xh",x86_Name(reg),Const); - if ((Const & 0xFFFFFF80) != 0 && (Const & 0xFFFFFF80) != 0xFFFFFF80) { - PUTDST16(m_RecompPos,0xE081 + (reg * 0x100)); - PUTDST32(m_RecompPos, Const); - } else { - PUTDST16(m_RecompPos,0xE083 + (reg * 0x100)); - PUTDST8(m_RecompPos, Const); - } +void CX86Ops::AdcConstToX86Reg (x86Reg reg, uint32_t Const) +{ + CPU_Message(" adc %s, %Xh",x86_Name(reg),Const); + if ((Const & 0xFFFFFF80) != 0 && (Const & 0xFFFFFF80) != 0xFFFFFF80) + { + PUTDST16(m_RecompPos,0xD081 + (reg * 0x100)); + PUTDST32(m_RecompPos, Const); + } + else + { + PUTDST16(m_RecompPos,0xD083 + (reg * 0x100)); + PUTDST8(m_RecompPos, Const); + } +} + +void CX86Ops::AdcVariableToX86reg(x86Reg reg, void * Variable, const char * VariableName) +{ + CPU_Message(" adc %s, dword ptr [%s]",x86_Name(reg),VariableName); + PUTDST16(m_RecompPos,0x0513 + (reg * 0x800)); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::AdcX86RegToX86Reg(x86Reg Destination, x86Reg Source) +{ + CPU_Message(" adc %s, %s",x86_Name(Destination),x86_Name(Source)); + PUTDST16(m_RecompPos,0xC013 + (Source * 0x100) + (Destination * 0x800)); +} + +void CX86Ops::AddConstToVariable (uint32_t Const, void *Variable, const char * VariableName) +{ + CPU_Message(" add dword ptr [%s], 0x%X",VariableName, Const); + PUTDST16(m_RecompPos,0x0581); + PUTDST32(m_RecompPos,Variable); + PUTDST32(m_RecompPos,Const); +} + +void CX86Ops::AddConstToX86Reg (x86Reg reg, uint32_t Const) +{ + if (Const == 0) + { + } + else if (Const == 1) + { + IncX86reg(reg); + } + else if (Const == 0xFFFFFFFF) + { + DecX86reg(reg); + } + else if ((Const & 0xFFFFFF80) != 0 && (Const & 0xFFFFFF80) != 0xFFFFFF80) + { + CPU_Message(" add %s, %Xh",x86_Name(reg),Const); + PUTDST16(m_RecompPos,0xC081 + (reg * 0x100)); + PUTDST32(m_RecompPos, Const); + } + else + { + CPU_Message(" add %s, %Xh",x86_Name(reg),Const); + PUTDST16(m_RecompPos,0xC083 + (reg * 0x100)); + PUTDST8(m_RecompPos, Const); + } +} + +void CX86Ops::AddVariableToX86reg(x86Reg reg, void * Variable, const char * VariableName) +{ + CPU_Message(" add %s, dword ptr [%s]",x86_Name(reg),VariableName); + PUTDST16(m_RecompPos,0x0503 + (reg * 0x800)); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::AddX86regToVariable(x86Reg reg, void * Variable, const char * VariableName) +{ + CPU_Message(" add dword ptr [%s], %s",VariableName, x86_Name(reg)); + PUTDST16(m_RecompPos,0x0501 + (reg * 0x800)); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::AddX86RegToX86Reg(x86Reg Destination, x86Reg Source) +{ + CPU_Message(" add %s, %s",x86_Name(Destination),x86_Name(Source)); + PUTDST16(m_RecompPos,0xC003 + (Source * 0x100) + (Destination * 0x800)); +} + +void CX86Ops::AndConstToVariable (uint32_t Const, void *Variable, const char * VariableName) +{ + CPU_Message(" and dword ptr [%s], 0x%X",VariableName, Const); + PUTDST16(m_RecompPos,0x2581); + PUTDST32(m_RecompPos,Variable); + PUTDST32(m_RecompPos,Const); +} + +void CX86Ops::AndConstToX86Reg(x86Reg reg, uint32_t Const) +{ + CPU_Message(" and %s, %Xh",x86_Name(reg),Const); + if ((Const & 0xFFFFFF80) != 0 && (Const & 0xFFFFFF80) != 0xFFFFFF80) + { + PUTDST16(m_RecompPos,0xE081 + (reg * 0x100)); + PUTDST32(m_RecompPos, Const); + } + else + { + PUTDST16(m_RecompPos,0xE083 + (reg * 0x100)); + PUTDST8(m_RecompPos, Const); + } } void CX86Ops::AndVariableDispToX86Reg(void *Variable, const char * VariableName, x86Reg reg, x86Reg AddrReg, Multipler Multiply) { - CPU_Message(" and %s, dword ptr [%s+%s*%i]",x86_Name(reg),VariableName, x86_Name(AddrReg), Multiply); - - PUTDST16(m_RecompPos,0x0423 + (reg * 0x800)); - PUTDST8(m_RecompPos,0x05 + CalcMultiplyCode(Multiply) + (AddrReg * 0x8)); - PUTDST32(m_RecompPos,Variable); + CPU_Message(" and %s, dword ptr [%s+%s*%i]",x86_Name(reg),VariableName, x86_Name(AddrReg), Multiply); + + PUTDST16(m_RecompPos,0x0423 + (reg * 0x800)); + PUTDST8(m_RecompPos,0x05 + CalcMultiplyCode(Multiply) + (AddrReg * 0x8)); + PUTDST32(m_RecompPos,Variable); } -void CX86Ops::AndVariableToX86Reg(void * Variable, const char * VariableName, x86Reg reg) { - CPU_Message(" and %s, dword ptr [%s]",x86_Name(reg),VariableName); - PUTDST16(m_RecompPos,0x0523 + (reg * 0x800)); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::AndX86RegToX86Reg(x86Reg Destination, x86Reg Source) { - CPU_Message(" and %s, %s",x86_Name(Destination),x86_Name(Source)); - PUTDST16(m_RecompPos,0xC021 + (Destination * 0x100) + (Source * 0x800)); -} - -void CX86Ops::BreakPointNotification (const wchar_t * const FileName, const int LineNumber) +void CX86Ops::AndVariableToX86Reg(void * Variable, const char * VariableName, x86Reg reg) { - g_Notify->BreakPoint(FileName,LineNumber); + CPU_Message(" and %s, dword ptr [%s]",x86_Name(reg),VariableName); + PUTDST16(m_RecompPos,0x0523 + (reg * 0x800)); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::AndX86RegToX86Reg(x86Reg Destination, x86Reg Source) +{ + CPU_Message(" and %s, %s",x86_Name(Destination),x86_Name(Source)); + PUTDST16(m_RecompPos,0xC021 + (Destination * 0x100) + (Source * 0x800)); +} + +void CX86Ops::BreakPointNotification (const wchar_t * const FileName, const int LineNumber) +{ + g_Notify->BreakPoint(FileName,LineNumber); } void CX86Ops::X86HardBreakPoint() { - CPU_Message(" int 3"); - PUTDST8(m_RecompPos,0xCC); + CPU_Message(" int 3"); + PUTDST8(m_RecompPos,0xCC); } void CX86Ops::X86BreakPoint (const wchar_t * FileName, int LineNumber) { - stdstr file_name; - file_name.FromUTF16(FileName); + stdstr file_name; + file_name.FromUTF16(FileName); - Pushad(); - PushImm32(stdstr_f("%d",LineNumber).c_str(),LineNumber); - PushImm32(file_name.c_str(),(DWORD)FileName); - Call_Direct(BreakPointNotification,"BreakPointNotification"); - AddConstToX86Reg(x86_ESP, 8); - Popad(); + Pushad(); + PushImm32(stdstr_f("%d",LineNumber).c_str(),LineNumber); + PushImm32(file_name.c_str(),(uint32_t)FileName); + Call_Direct(BreakPointNotification,"BreakPointNotification"); + AddConstToX86Reg(x86_ESP, 8); + Popad(); } void CX86Ops::Call_Direct(void * FunctAddress, const char * FunctName) { - CPU_Message(" call offset %s",FunctName); - PUTDST8(m_RecompPos,0xE8); - PUTDST32(m_RecompPos,(DWORD)FunctAddress-(DWORD)m_RecompPos - 4); + CPU_Message(" call offset %s",FunctName); + PUTDST8(m_RecompPos,0xE8); + PUTDST32(m_RecompPos,(uint32_t)FunctAddress-(uint32_t)m_RecompPos - 4); } void CX86Ops::Call_Indirect(void * FunctAddress, const char * FunctName) { - CPU_Message(" call [%s]",FunctName); - PUTDST16(m_RecompPos,0x15FF); - PUTDST32(m_RecompPos,FunctAddress); + CPU_Message(" call [%s]",FunctName); + PUTDST16(m_RecompPos,0x15FF); + PUTDST32(m_RecompPos,FunctAddress); } -void CX86Ops::CompConstToVariable(DWORD Const, void * Variable, const char * VariableName) { - CPU_Message(" cmp dword ptr [%s], 0x%X",VariableName, Const); - PUTDST16(m_RecompPos,0x3D81); - PUTDST32(m_RecompPos,Variable); - PUTDST32(m_RecompPos,Const); -} - -void CX86Ops::CompConstToX86reg(x86Reg reg, DWORD Const) { - if (Const == 0) - { - OrX86RegToX86Reg(reg,reg); - } else { - CPU_Message(" cmp %s, %Xh",x86_Name(reg),Const); - if ((Const & 0xFFFFFF80) != 0 && (Const & 0xFFFFFF80) != 0xFFFFFF80) - { - PUTDST16(m_RecompPos,0xF881 + (reg * 0x100)); - PUTDST32(m_RecompPos,Const); - } else { - PUTDST16(m_RecompPos,0xF883 + (reg * 0x100)); - PUTDST8(m_RecompPos, Const); - } - } -} - -void CX86Ops::CompConstToX86regPointer(x86Reg reg, DWORD Const) { - if ((Const & 0xFFFFFF80) != 0 && (Const & 0xFFFFFF80) != 0xFFFFFF80) - { - CPU_Message(" cmp dword ptr [%s], %Xh",x86_Name(reg),Const); - PUTDST16(m_RecompPos,0x3881 + (reg * 0x100)); - PUTDST32(m_RecompPos,Const); - } else { - CPU_Message(" cmp byte ptr [%s], %Xh",x86_Name(reg),Const); - PUTDST16(m_RecompPos,0x3883 + (reg * 0x100)); - PUTDST8(m_RecompPos, Const); - } -} - -void CX86Ops::CompX86regToVariable(x86Reg reg, void * Variable, const char * VariableName) { - CPU_Message(" cmp %s, dword ptr [%s]",x86_Name(reg),VariableName); - PUTDST16(m_RecompPos,0x053B + (reg * 0x800)); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::CompVariableToX86reg(x86Reg reg, void * Variable, const char * VariableName) { - CPU_Message(" cmp dword ptr [%s], %s",VariableName, x86_Name(reg)); - PUTDST16(m_RecompPos,0x0539 + (reg * 0x800)); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::CompX86RegToX86Reg(x86Reg Destination, x86Reg Source) { - WORD x86Command = 0; - - CPU_Message(" cmp %s, %s",x86_Name(Destination),x86_Name(Source)); - - switch (Source) { - case x86_EAX: x86Command = 0x003B; break; - case x86_EBX: x86Command = 0x033B; break; - case x86_ECX: x86Command = 0x013B; break; - case x86_EDX: x86Command = 0x023B; break; - case x86_ESI: x86Command = 0x063B; break; - case x86_EDI: x86Command = 0x073B; break; - case x86_ESP: x86Command = 0x043B; break; - case x86_EBP: x86Command = 0x053B; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - switch (Destination) { - case x86_EAX: x86Command += 0xC000; break; - case x86_EBX: x86Command += 0xD800; break; - case x86_ECX: x86Command += 0xC800; break; - case x86_EDX: x86Command += 0xD000; break; - case x86_ESI: x86Command += 0xF000; break; - case x86_EDI: x86Command += 0xF800; break; - case x86_ESP: x86Command += 0xE000; break; - case x86_EBP: x86Command += 0xE800; break; - } - PUTDST16(m_RecompPos,x86Command); -} - -void CX86Ops::DecX86reg(x86Reg reg) { - CPU_Message(" dec %s",x86_Name(reg)); - - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0xC8FF); break; - case x86_EBX: PUTDST16(m_RecompPos,0xCBFF); break; - case x86_ECX: PUTDST16(m_RecompPos,0xC9FF); break; - case x86_EDX: PUTDST16(m_RecompPos,0xCAFF); break; - case x86_ESI: PUTDST16(m_RecompPos,0xCEFF); break; - case x86_EDI: PUTDST16(m_RecompPos,0xCFFF); break; - case x86_ESP: PUTDST8 (m_RecompPos,0x4C); break; - case x86_EBP: PUTDST8 (m_RecompPos,0x4D); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::DivX86reg(x86Reg reg) { - CPU_Message(" div %s",x86_Name(reg)); - switch (reg) { - case x86_EBX: PUTDST16(m_RecompPos,0xf3F7); break; - case x86_ECX: PUTDST16(m_RecompPos,0xf1F7); break; - case x86_EDX: PUTDST16(m_RecompPos,0xf2F7); break; - case x86_ESI: PUTDST16(m_RecompPos,0xf6F7); break; - case x86_EDI: PUTDST16(m_RecompPos,0xf7F7); break; - case x86_ESP: PUTDST16(m_RecompPos,0xf4F7); break; - case x86_EBP: PUTDST16(m_RecompPos,0xf5F7); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::idivX86reg(x86Reg reg) { - CPU_Message(" idiv %s",x86_Name(reg));\ - switch (reg) { - case x86_EBX: PUTDST16(m_RecompPos,0xfbF7); break; - case x86_ECX: PUTDST16(m_RecompPos,0xf9F7); break; - case x86_EDX: PUTDST16(m_RecompPos,0xfaF7); break; - case x86_ESI: PUTDST16(m_RecompPos,0xfeF7); break; - case x86_EDI: PUTDST16(m_RecompPos,0xffF7); break; - case x86_ESP: PUTDST16(m_RecompPos,0xfcF7); break; - case x86_EBP: PUTDST16(m_RecompPos,0xfdF7); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::imulX86reg(x86Reg reg) { - CPU_Message(" imul %s",x86_Name(reg)); - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0xE8F7); break; - case x86_EBX: PUTDST16(m_RecompPos,0xEBF7); break; - case x86_ECX: PUTDST16(m_RecompPos,0xE9F7); break; - case x86_EDX: PUTDST16(m_RecompPos,0xEAF7); break; - case x86_ESI: PUTDST16(m_RecompPos,0xEEF7); break; - case x86_EDI: PUTDST16(m_RecompPos,0xEFF7); break; - case x86_ESP: PUTDST16(m_RecompPos,0xECF7); break; - case x86_EBP: PUTDST16(m_RecompPos,0xEDF7); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::IncX86reg(x86Reg reg) { - CPU_Message(" inc %s",x86_Name(reg)); - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0xC0FF); break; - case x86_EBX: PUTDST16(m_RecompPos,0xC3FF); break; - case x86_ECX: PUTDST16(m_RecompPos,0xC1FF); break; - case x86_EDX: PUTDST16(m_RecompPos,0xC2FF); break; - case x86_ESI: PUTDST16(m_RecompPos,0xC6FF); break; - case x86_EDI: PUTDST16(m_RecompPos,0xC7FF); break; - case x86_ESP: PUTDST8 (m_RecompPos,0x44); break; - case x86_EBP: PUTDST8 (m_RecompPos,0x45); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::JaeLabel8(const char * Label, BYTE Value) { - CPU_Message(" jae $%s",Label); - PUTDST8(m_RecompPos,0x73); - PUTDST8(m_RecompPos,Value); -} - -void CX86Ops::JaeLabel32(const char * Label,DWORD Value) { - CPU_Message(" jae $%s",Label); - PUTDST16(m_RecompPos,0x830F); - PUTDST32(m_RecompPos,Value); -} - -void CX86Ops::JaLabel8(const char * Label, BYTE Value) { - CPU_Message(" ja $%s",Label); - PUTDST8(m_RecompPos,0x77); - PUTDST8(m_RecompPos,Value); -} - -void CX86Ops::JaLabel32(const char * Label,DWORD Value) { - CPU_Message(" ja $%s",Label); - PUTDST16(m_RecompPos,0x870F); - PUTDST32(m_RecompPos,Value); -} - -void CX86Ops::JbLabel8(const char * Label, BYTE Value) { - CPU_Message(" jb $%s",Label); - PUTDST8(m_RecompPos,0x72); - PUTDST8(m_RecompPos,Value); -} - -void CX86Ops::JbLabel32(const char * Label,DWORD Value) { - CPU_Message(" jb $%s",Label); - PUTDST16(m_RecompPos,0x820F); - PUTDST32(m_RecompPos,Value); -} - -void CX86Ops::JecxzLabel8(const char * Label, BYTE Value) { - CPU_Message(" jecxz $%s",Label); - PUTDST8(m_RecompPos,0xE3); - PUTDST8(m_RecompPos,Value); -} - -void CX86Ops::JeLabel8(const char * Label, BYTE Value) { - CPU_Message(" je $%s",Label); - PUTDST8(m_RecompPos,0x74); - PUTDST8(m_RecompPos,Value); -} - -void CX86Ops::JeLabel32(const char * Label,DWORD Value) { - CPU_Message(" je $%s",Label); - PUTDST16(m_RecompPos,0x840F); - PUTDST32(m_RecompPos,Value); -} - -void CX86Ops::JgeLabel32(const char * Label,DWORD Value) { - CPU_Message(" jge $%s",Label); - PUTDST16(m_RecompPos,0x8D0F); - PUTDST32(m_RecompPos,Value); -} - -void CX86Ops::JgLabel8(const char * Label, BYTE Value) { - CPU_Message(" jg $%s",Label); - PUTDST8(m_RecompPos,0x7F); - PUTDST8(m_RecompPos,Value); -} - -void CX86Ops::JgLabel32(const char * Label,DWORD Value) { - CPU_Message(" jg $%s",Label); - PUTDST16(m_RecompPos,0x8F0F); - PUTDST32(m_RecompPos,Value); -} - -void CX86Ops::JleLabel8(const char * Label, BYTE Value) { - CPU_Message(" jle $%s",Label); - PUTDST8(m_RecompPos,0x7E); - PUTDST8(m_RecompPos,Value); -} - -void CX86Ops::JleLabel32(const char * Label,DWORD Value) { - CPU_Message(" jle $%s",Label); - PUTDST16(m_RecompPos,0x8E0F); - PUTDST32(m_RecompPos,Value); -} - -void CX86Ops::JlLabel8(const char * Label, BYTE Value) { - CPU_Message(" jl $%s",Label); - PUTDST8(m_RecompPos,0x7C); - PUTDST8(m_RecompPos,Value); -} - -void CX86Ops::JlLabel32(const char * Label,DWORD Value) { - CPU_Message(" jl $%s",Label); - PUTDST16(m_RecompPos,0x8C0F); - PUTDST32(m_RecompPos,Value); -} - -void CX86Ops::JmpDirectReg( x86Reg reg ) { - CPU_Message(" jmp %s",x86_Name(reg)); - - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0xE0ff); break; - case x86_EBX: PUTDST16(m_RecompPos,0xE3ff); break; - case x86_ECX: PUTDST16(m_RecompPos,0xE1ff); break; - case x86_EDX: PUTDST16(m_RecompPos,0xE2ff); break; - case x86_ESI: PUTDST16(m_RecompPos,0xE6ff); break; - case x86_EDI: PUTDST16(m_RecompPos,0xE7ff); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::JmpIndirectLabel32(const char * Label,DWORD location) { - CPU_Message(" jmp dword ptr [%s]", Label); - PUTDST16(m_RecompPos, 0x25ff); - PUTDST32(m_RecompPos, location); -} - -void CX86Ops::JmpIndirectReg( x86Reg reg ) { - CPU_Message(" jmp dword ptr [%s]",x86_Name(reg)); - - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0x20ff); break; - case x86_EBX: PUTDST16(m_RecompPos,0x23ff); break; - case x86_ECX: PUTDST16(m_RecompPos,0x21ff); break; - case x86_EDX: PUTDST16(m_RecompPos,0x22ff); break; - case x86_ESI: PUTDST16(m_RecompPos,0x26ff); break; - case x86_EDI: PUTDST16(m_RecompPos,0x27ff); break; - case x86_ESP: - PUTDST8(m_RecompPos,0xff); - PUTDST16(m_RecompPos,0x2434); - /* g_Notify->BreakPoint(__FILEW__,__LINE__); */ - break; - case x86_EBP: - PUTDST8(m_RecompPos,0xff); - PUTDST16(m_RecompPos,0x0065); - /* g_Notify->BreakPoint(__FILEW__,__LINE__); */ - break; - } -} - -void CX86Ops::JmpLabel8(const char * Label, BYTE Value) { - CPU_Message(" jmp $%s",Label); - PUTDST8(m_RecompPos,0xEB); - PUTDST8(m_RecompPos,Value); -} - -void CX86Ops::JmpLabel32(const char * Label, DWORD Value) { - CPU_Message(" jmp $%s",Label); - PUTDST8(m_RecompPos,0xE9); - PUTDST32(m_RecompPos,Value); -} - -void CX86Ops::JneLabel8(const char * Label, BYTE Value) { - CPU_Message(" jne $%s",Label); - PUTDST8(m_RecompPos,0x75); - PUTDST8(m_RecompPos,Value); -} - -void CX86Ops::JneLabel32(const char *Label, DWORD Value) { - CPU_Message(" jne $%s",Label); - PUTDST16(m_RecompPos,0x850F); - PUTDST32(m_RecompPos,Value); -} - -void CX86Ops::JnsLabel8(const char * Label, BYTE Value) { - CPU_Message(" jns $%s",Label); - PUTDST8(m_RecompPos,0x79); - PUTDST8(m_RecompPos,Value); -} - -void CX86Ops::JnsLabel32(const char *Label, DWORD Value) { - CPU_Message(" jns $%s",Label); - PUTDST16(m_RecompPos,0x890F); - PUTDST32(m_RecompPos,Value); -} - -void CX86Ops::JnzLabel8(const char *Label, BYTE Value) +void CX86Ops::CompConstToVariable(uint32_t Const, void * Variable, const char * VariableName) { - CPU_Message(" jnz $%s",Label); - PUTDST8(m_RecompPos,0x75); - PUTDST8(m_RecompPos,Value); + CPU_Message(" cmp dword ptr [%s], 0x%X",VariableName, Const); + PUTDST16(m_RecompPos,0x3D81); + PUTDST32(m_RecompPos,Variable); + PUTDST32(m_RecompPos,Const); } -void CX86Ops::JnzLabel32(const char *Label, DWORD Value) { - CPU_Message(" jnz $%s",Label); - PUTDST16(m_RecompPos,0x850F); - PUTDST32(m_RecompPos,Value); -} - -void CX86Ops::JsLabel32(const char *Label, DWORD Value) { - CPU_Message(" js $%s",Label); - PUTDST16(m_RecompPos,0x880F); - PUTDST32(m_RecompPos,Value); -} - -void CX86Ops::JzLabel8(const char *Label, BYTE Value) +void CX86Ops::CompConstToX86reg(x86Reg reg, uint32_t Const) { - CPU_Message(" jz $%s",Label); - PUTDST8(m_RecompPos,0x74); - PUTDST8(m_RecompPos,Value); + if (Const == 0) + { + OrX86RegToX86Reg(reg,reg); + } + else + { + CPU_Message(" cmp %s, %Xh",x86_Name(reg),Const); + if ((Const & 0xFFFFFF80) != 0 && (Const & 0xFFFFFF80) != 0xFFFFFF80) + { + PUTDST16(m_RecompPos,0xF881 + (reg * 0x100)); + PUTDST32(m_RecompPos,Const); + } + else + { + PUTDST16(m_RecompPos,0xF883 + (reg * 0x100)); + PUTDST8(m_RecompPos, Const); + } + } } -void CX86Ops::JzLabel32(const char *Label, DWORD Value) { - CPU_Message(" jz $%s",Label); - PUTDST16(m_RecompPos,0x840F); - PUTDST32(m_RecompPos,Value); -} - -void CX86Ops::LeaRegReg(x86Reg RegDest, x86Reg RegSrc, DWORD Const, Multipler multiplier) +void CX86Ops::CompConstToX86regPointer(x86Reg reg, uint32_t Const) { - if (Const != 0) - { - CPU_Message(" lea %s, [%s*%i+%X]", x86_Name(RegDest), x86_Name(RegSrc), multiplier,Const); - } else { - CPU_Message(" lea %s, [%s*%i]", x86_Name(RegDest), x86_Name(RegSrc), multiplier); - } + if ((Const & 0xFFFFFF80) != 0 && (Const & 0xFFFFFF80) != 0xFFFFFF80) + { + CPU_Message(" cmp dword ptr [%s], %Xh",x86_Name(reg),Const); + PUTDST16(m_RecompPos,0x3881 + (reg * 0x100)); + PUTDST32(m_RecompPos,Const); + } + else + { + CPU_Message(" cmp byte ptr [%s], %Xh",x86_Name(reg),Const); + PUTDST16(m_RecompPos,0x3883 + (reg * 0x100)); + PUTDST8(m_RecompPos, Const); + } +} - PUTDST8(m_RecompPos,0x8D); - PUTDST8(m_RecompPos,0x04 + (RegDest * 8)); - PUTDST8(m_RecompPos,0x05 + (RegSrc * 8) + CalcMultiplyCode(multiplier)); - PUTDST32(m_RecompPos,Const); +void CX86Ops::CompX86regToVariable(x86Reg reg, void * Variable, const char * VariableName) +{ + CPU_Message(" cmp %s, dword ptr [%s]",x86_Name(reg),VariableName); + PUTDST16(m_RecompPos,0x053B + (reg * 0x800)); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::CompVariableToX86reg(x86Reg reg, void * Variable, const char * VariableName) +{ + CPU_Message(" cmp dword ptr [%s], %s",VariableName, x86_Name(reg)); + PUTDST16(m_RecompPos,0x0539 + (reg * 0x800)); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::CompX86RegToX86Reg(x86Reg Destination, x86Reg Source) +{ + uint16_t x86Command = 0; + + CPU_Message(" cmp %s, %s",x86_Name(Destination),x86_Name(Source)); + + switch (Source) + { + case x86_EAX: x86Command = 0x003B; break; + case x86_EBX: x86Command = 0x033B; break; + case x86_ECX: x86Command = 0x013B; break; + case x86_EDX: x86Command = 0x023B; break; + case x86_ESI: x86Command = 0x063B; break; + case x86_EDI: x86Command = 0x073B; break; + case x86_ESP: x86Command = 0x043B; break; + case x86_EBP: x86Command = 0x053B; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + switch (Destination) + { + case x86_EAX: x86Command += 0xC000; break; + case x86_EBX: x86Command += 0xD800; break; + case x86_ECX: x86Command += 0xC800; break; + case x86_EDX: x86Command += 0xD000; break; + case x86_ESI: x86Command += 0xF000; break; + case x86_EDI: x86Command += 0xF800; break; + case x86_ESP: x86Command += 0xE000; break; + case x86_EBP: x86Command += 0xE800; break; + } + PUTDST16(m_RecompPos,x86Command); +} + +void CX86Ops::DecX86reg(x86Reg reg) +{ + CPU_Message(" dec %s",x86_Name(reg)); + + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0xC8FF); break; + case x86_EBX: PUTDST16(m_RecompPos,0xCBFF); break; + case x86_ECX: PUTDST16(m_RecompPos,0xC9FF); break; + case x86_EDX: PUTDST16(m_RecompPos,0xCAFF); break; + case x86_ESI: PUTDST16(m_RecompPos,0xCEFF); break; + case x86_EDI: PUTDST16(m_RecompPos,0xCFFF); break; + case x86_ESP: PUTDST8 (m_RecompPos,0x4C); break; + case x86_EBP: PUTDST8 (m_RecompPos,0x4D); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::DivX86reg(x86Reg reg) +{ + CPU_Message(" div %s",x86_Name(reg)); + switch (reg) + { + case x86_EBX: PUTDST16(m_RecompPos,0xf3F7); break; + case x86_ECX: PUTDST16(m_RecompPos,0xf1F7); break; + case x86_EDX: PUTDST16(m_RecompPos,0xf2F7); break; + case x86_ESI: PUTDST16(m_RecompPos,0xf6F7); break; + case x86_EDI: PUTDST16(m_RecompPos,0xf7F7); break; + case x86_ESP: PUTDST16(m_RecompPos,0xf4F7); break; + case x86_EBP: PUTDST16(m_RecompPos,0xf5F7); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::idivX86reg(x86Reg reg) +{ + CPU_Message(" idiv %s",x86_Name(reg)); + + switch (reg) + { + case x86_EBX: PUTDST16(m_RecompPos,0xfbF7); break; + case x86_ECX: PUTDST16(m_RecompPos,0xf9F7); break; + case x86_EDX: PUTDST16(m_RecompPos,0xfaF7); break; + case x86_ESI: PUTDST16(m_RecompPos,0xfeF7); break; + case x86_EDI: PUTDST16(m_RecompPos,0xffF7); break; + case x86_ESP: PUTDST16(m_RecompPos,0xfcF7); break; + case x86_EBP: PUTDST16(m_RecompPos,0xfdF7); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::imulX86reg(x86Reg reg) +{ + CPU_Message(" imul %s",x86_Name(reg)); + + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0xE8F7); break; + case x86_EBX: PUTDST16(m_RecompPos,0xEBF7); break; + case x86_ECX: PUTDST16(m_RecompPos,0xE9F7); break; + case x86_EDX: PUTDST16(m_RecompPos,0xEAF7); break; + case x86_ESI: PUTDST16(m_RecompPos,0xEEF7); break; + case x86_EDI: PUTDST16(m_RecompPos,0xEFF7); break; + case x86_ESP: PUTDST16(m_RecompPos,0xECF7); break; + case x86_EBP: PUTDST16(m_RecompPos,0xEDF7); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::IncX86reg(x86Reg reg) +{ + CPU_Message(" inc %s",x86_Name(reg)); + + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0xC0FF); break; + case x86_EBX: PUTDST16(m_RecompPos,0xC3FF); break; + case x86_ECX: PUTDST16(m_RecompPos,0xC1FF); break; + case x86_EDX: PUTDST16(m_RecompPos,0xC2FF); break; + case x86_ESI: PUTDST16(m_RecompPos,0xC6FF); break; + case x86_EDI: PUTDST16(m_RecompPos,0xC7FF); break; + case x86_ESP: PUTDST8 (m_RecompPos,0x44); break; + case x86_EBP: PUTDST8 (m_RecompPos,0x45); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::JaeLabel8(const char * Label, uint8_t Value) +{ + CPU_Message(" jae $%s",Label); + PUTDST8(m_RecompPos,0x73); + PUTDST8(m_RecompPos,Value); +} + +void CX86Ops::JaeLabel32(const char * Label,uint32_t Value) +{ + CPU_Message(" jae $%s",Label); + PUTDST16(m_RecompPos,0x830F); + PUTDST32(m_RecompPos,Value); +} + +void CX86Ops::JaLabel8(const char * Label, uint8_t Value) +{ + CPU_Message(" ja $%s",Label); + PUTDST8(m_RecompPos,0x77); + PUTDST8(m_RecompPos,Value); +} + +void CX86Ops::JaLabel32(const char * Label,uint32_t Value) +{ + CPU_Message(" ja $%s",Label); + PUTDST16(m_RecompPos,0x870F); + PUTDST32(m_RecompPos,Value); +} + +void CX86Ops::JbLabel8(const char * Label, uint8_t Value) +{ + CPU_Message(" jb $%s",Label); + PUTDST8(m_RecompPos,0x72); + PUTDST8(m_RecompPos,Value); +} + +void CX86Ops::JbLabel32(const char * Label,uint32_t Value) +{ + CPU_Message(" jb $%s",Label); + PUTDST16(m_RecompPos,0x820F); + PUTDST32(m_RecompPos,Value); +} + +void CX86Ops::JecxzLabel8(const char * Label, uint8_t Value) +{ + CPU_Message(" jecxz $%s",Label); + PUTDST8(m_RecompPos,0xE3); + PUTDST8(m_RecompPos,Value); +} + +void CX86Ops::JeLabel8(const char * Label, uint8_t Value) +{ + CPU_Message(" je $%s",Label); + PUTDST8(m_RecompPos,0x74); + PUTDST8(m_RecompPos,Value); +} + +void CX86Ops::JeLabel32(const char * Label,uint32_t Value) +{ + CPU_Message(" je $%s",Label); + PUTDST16(m_RecompPos,0x840F); + PUTDST32(m_RecompPos,Value); +} + +void CX86Ops::JgeLabel32(const char * Label,uint32_t Value) +{ + CPU_Message(" jge $%s",Label); + PUTDST16(m_RecompPos,0x8D0F); + PUTDST32(m_RecompPos,Value); +} + +void CX86Ops::JgLabel8(const char * Label, uint8_t Value) +{ + CPU_Message(" jg $%s",Label); + PUTDST8(m_RecompPos,0x7F); + PUTDST8(m_RecompPos,Value); +} + +void CX86Ops::JgLabel32(const char * Label,uint32_t Value) +{ + CPU_Message(" jg $%s",Label); + PUTDST16(m_RecompPos,0x8F0F); + PUTDST32(m_RecompPos,Value); +} + +void CX86Ops::JleLabel8(const char * Label, uint8_t Value) +{ + CPU_Message(" jle $%s",Label); + PUTDST8(m_RecompPos,0x7E); + PUTDST8(m_RecompPos,Value); +} + +void CX86Ops::JleLabel32(const char * Label,uint32_t Value) +{ + CPU_Message(" jle $%s",Label); + PUTDST16(m_RecompPos,0x8E0F); + PUTDST32(m_RecompPos,Value); +} + +void CX86Ops::JlLabel8(const char * Label, uint8_t Value) +{ + CPU_Message(" jl $%s",Label); + PUTDST8(m_RecompPos,0x7C); + PUTDST8(m_RecompPos,Value); +} + +void CX86Ops::JlLabel32(const char * Label,uint32_t Value) +{ + CPU_Message(" jl $%s",Label); + PUTDST16(m_RecompPos,0x8C0F); + PUTDST32(m_RecompPos,Value); +} + +void CX86Ops::JmpDirectReg( x86Reg reg ) +{ + CPU_Message(" jmp %s",x86_Name(reg)); + + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0xE0ff); break; + case x86_EBX: PUTDST16(m_RecompPos,0xE3ff); break; + case x86_ECX: PUTDST16(m_RecompPos,0xE1ff); break; + case x86_EDX: PUTDST16(m_RecompPos,0xE2ff); break; + case x86_ESI: PUTDST16(m_RecompPos,0xE6ff); break; + case x86_EDI: PUTDST16(m_RecompPos,0xE7ff); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::JmpIndirectLabel32(const char * Label,uint32_t location) +{ + CPU_Message(" jmp dword ptr [%s]", Label); + PUTDST16(m_RecompPos, 0x25ff); + PUTDST32(m_RecompPos, location); +} + +void CX86Ops::JmpIndirectReg( x86Reg reg ) +{ + CPU_Message(" jmp dword ptr [%s]",x86_Name(reg)); + + switch (reg) { + case x86_EAX: PUTDST16(m_RecompPos,0x20ff); break; + case x86_EBX: PUTDST16(m_RecompPos,0x23ff); break; + case x86_ECX: PUTDST16(m_RecompPos,0x21ff); break; + case x86_EDX: PUTDST16(m_RecompPos,0x22ff); break; + case x86_ESI: PUTDST16(m_RecompPos,0x26ff); break; + case x86_EDI: PUTDST16(m_RecompPos,0x27ff); break; + case x86_ESP: + PUTDST8(m_RecompPos,0xff); + PUTDST16(m_RecompPos,0x2434); + /* g_Notify->BreakPoint(__FILEW__,__LINE__); */ + break; + case x86_EBP: + PUTDST8(m_RecompPos,0xff); + PUTDST16(m_RecompPos,0x0065); + /* g_Notify->BreakPoint(__FILEW__,__LINE__); */ + break; + } +} + +void CX86Ops::JmpLabel8(const char * Label, uint8_t Value) +{ + CPU_Message(" jmp $%s",Label); + PUTDST8(m_RecompPos,0xEB); + PUTDST8(m_RecompPos,Value); +} + +void CX86Ops::JmpLabel32(const char * Label, uint32_t Value) +{ + CPU_Message(" jmp $%s",Label); + PUTDST8(m_RecompPos,0xE9); + PUTDST32(m_RecompPos,Value); +} + +void CX86Ops::JneLabel8(const char * Label, uint8_t Value) +{ + CPU_Message(" jne $%s",Label); + PUTDST8(m_RecompPos,0x75); + PUTDST8(m_RecompPos,Value); +} + +void CX86Ops::JneLabel32(const char *Label, uint32_t Value) +{ + CPU_Message(" jne $%s",Label); + PUTDST16(m_RecompPos,0x850F); + PUTDST32(m_RecompPos,Value); +} + +void CX86Ops::JnsLabel8(const char * Label, uint8_t Value) +{ + CPU_Message(" jns $%s",Label); + PUTDST8(m_RecompPos,0x79); + PUTDST8(m_RecompPos,Value); +} + +void CX86Ops::JnsLabel32(const char *Label, uint32_t Value) +{ + CPU_Message(" jns $%s",Label); + PUTDST16(m_RecompPos,0x890F); + PUTDST32(m_RecompPos,Value); +} + +void CX86Ops::JnzLabel8(const char *Label, uint8_t Value) +{ + CPU_Message(" jnz $%s",Label); + PUTDST8(m_RecompPos,0x75); + PUTDST8(m_RecompPos,Value); +} + +void CX86Ops::JnzLabel32(const char *Label, uint32_t Value) +{ + CPU_Message(" jnz $%s",Label); + PUTDST16(m_RecompPos,0x850F); + PUTDST32(m_RecompPos,Value); +} + +void CX86Ops::JsLabel32(const char *Label, uint32_t Value) +{ + CPU_Message(" js $%s",Label); + PUTDST16(m_RecompPos,0x880F); + PUTDST32(m_RecompPos,Value); +} + +void CX86Ops::JzLabel8(const char *Label, uint8_t Value) +{ + CPU_Message(" jz $%s",Label); + PUTDST8(m_RecompPos,0x74); + PUTDST8(m_RecompPos,Value); +} + +void CX86Ops::JzLabel32(const char *Label, uint32_t Value) +{ + CPU_Message(" jz $%s",Label); + PUTDST16(m_RecompPos,0x840F); + PUTDST32(m_RecompPos,Value); +} + +void CX86Ops::LeaRegReg(x86Reg RegDest, x86Reg RegSrc, uint32_t Const, Multipler multiplier) +{ + if (Const != 0) + { + CPU_Message(" lea %s, [%s*%i+%X]", x86_Name(RegDest), x86_Name(RegSrc), multiplier,Const); + } else { + CPU_Message(" lea %s, [%s*%i]", x86_Name(RegDest), x86_Name(RegSrc), multiplier); + } + + PUTDST8(m_RecompPos,0x8D); + PUTDST8(m_RecompPos,0x04 + (RegDest * 8)); + PUTDST8(m_RecompPos,0x05 + (RegSrc * 8) + CalcMultiplyCode(multiplier)); + PUTDST32(m_RecompPos,Const); } void CX86Ops::LeaRegReg2(x86Reg RegDest, x86Reg RegSrc, x86Reg RegSrc2, Multipler multiplier) { - CPU_Message(" lea %s, [%s+%s*%i]", x86_Name(RegDest), x86_Name(RegSrc), x86_Name(RegSrc2), multiplier); + CPU_Message(" lea %s, [%s+%s*%i]", x86_Name(RegDest), x86_Name(RegSrc), x86_Name(RegSrc2), multiplier); - if (RegSrc2 == x86_ESP || RegSrc2 == x86_EBP) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - return; - } - PUTDST8(m_RecompPos,0x8D); - PUTDST8(m_RecompPos,0x04 + (RegDest * 0x8)); - PUTDST8(m_RecompPos,0x05 + (RegSrc * 0x8) + RegSrc2+ CalcMultiplyCode(multiplier)); + if (RegSrc2 == x86_ESP || RegSrc2 == x86_EBP) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + return; + } + PUTDST8(m_RecompPos,0x8D); + PUTDST8(m_RecompPos,0x04 + (RegDest * 0x8)); + PUTDST8(m_RecompPos,0x05 + (RegSrc * 0x8) + RegSrc2+ CalcMultiplyCode(multiplier)); } -void CX86Ops::LeaSourceAndOffset(x86Reg x86DestReg, x86Reg x86SourceReg, int offset) { - WORD x86Command = 0; +void CX86Ops::LeaSourceAndOffset(x86Reg x86DestReg, x86Reg x86SourceReg, int offset) +{ + uint16_t x86Command = 0; - CPU_Message(" lea %s, [%s + %0Xh]",x86_Name(x86DestReg),x86_Name(x86SourceReg),offset); + CPU_Message(" lea %s, [%s + %0Xh]",x86_Name(x86DestReg),x86_Name(x86SourceReg),offset); -// if ((offset & 0xFFFFFF80) != 0 && (offset & 0xFFFFFF80) != 0xFFFFFF80) { - if (1) { - switch (x86DestReg) { - case x86_EAX: x86Command = 0x808D; break; - case x86_EBX: x86Command = 0x988D; break; - case x86_ECX: x86Command = 0x888D; break; - case x86_EDX: x86Command = 0x908D; break; - case x86_ESI: x86Command = 0xB08D; break; - case x86_EDI: x86Command = 0xB88D; break; - case x86_ESP: x86Command = 0xA08D; break; - case x86_EBP: x86Command = 0xA88D; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - switch (x86SourceReg) { - case x86_EAX: x86Command += 0x0000; break; - case x86_EBX: x86Command += 0x0300; break; - case x86_ECX: x86Command += 0x0100; break; - case x86_EDX: x86Command += 0x0200; break; - case x86_ESI: x86Command += 0x0600; break; - case x86_EDI: x86Command += 0x0700; break; - case x86_ESP: x86Command += 0x0400; break; - case x86_EBP: x86Command += 0x0500; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST16(m_RecompPos,x86Command); - PUTDST32(m_RecompPos,offset); - } else { - switch (x86DestReg) { - case x86_EAX: x86Command = 0x408D; break; - case x86_EBX: x86Command = 0x588D; break; - case x86_ECX: x86Command = 0x488D; break; - case x86_EDX: x86Command = 0x508D; break; - case x86_ESI: x86Command = 0x708D; break; - case x86_EDI: x86Command = 0x788D; break; - case x86_ESP: x86Command = 0x608D; break; - case x86_EBP: x86Command = 0x688D; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - switch (x86SourceReg) { - case x86_EAX: x86Command += 0x0000; break; - case x86_EBX: x86Command += 0x0300; break; - case x86_ECX: x86Command += 0x0100; break; - case x86_EDX: x86Command += 0x0200; break; - case x86_ESI: x86Command += 0x0600; break; - case x86_EDI: x86Command += 0x0700; break; - case x86_ESP: x86Command += 0x0400; break; - case x86_EBP: x86Command += 0x0500; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST16(m_RecompPos,x86Command); - PUTDST8(m_RecompPos,offset); - } + // if ((offset & 0xFFFFFF80) != 0 && (offset & 0xFFFFFF80) != 0xFFFFFF80) { + if (1) + { + switch (x86DestReg) + { + case x86_EAX: x86Command = 0x808D; break; + case x86_EBX: x86Command = 0x988D; break; + case x86_ECX: x86Command = 0x888D; break; + case x86_EDX: x86Command = 0x908D; break; + case x86_ESI: x86Command = 0xB08D; break; + case x86_EDI: x86Command = 0xB88D; break; + case x86_ESP: x86Command = 0xA08D; break; + case x86_EBP: x86Command = 0xA88D; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + switch (x86SourceReg) + { + case x86_EAX: x86Command += 0x0000; break; + case x86_EBX: x86Command += 0x0300; break; + case x86_ECX: x86Command += 0x0100; break; + case x86_EDX: x86Command += 0x0200; break; + case x86_ESI: x86Command += 0x0600; break; + case x86_EDI: x86Command += 0x0700; break; + case x86_ESP: x86Command += 0x0400; break; + case x86_EBP: x86Command += 0x0500; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST16(m_RecompPos,x86Command); + PUTDST32(m_RecompPos,offset); + } + else + { + switch (x86DestReg) + { + case x86_EAX: x86Command = 0x408D; break; + case x86_EBX: x86Command = 0x588D; break; + case x86_ECX: x86Command = 0x488D; break; + case x86_EDX: x86Command = 0x508D; break; + case x86_ESI: x86Command = 0x708D; break; + case x86_EDI: x86Command = 0x788D; break; + case x86_ESP: x86Command = 0x608D; break; + case x86_EBP: x86Command = 0x688D; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + switch (x86SourceReg) + { + case x86_EAX: x86Command += 0x0000; break; + case x86_EBX: x86Command += 0x0300; break; + case x86_ECX: x86Command += 0x0100; break; + case x86_EDX: x86Command += 0x0200; break; + case x86_ESI: x86Command += 0x0600; break; + case x86_EDI: x86Command += 0x0700; break; + case x86_ESP: x86Command += 0x0400; break; + case x86_EBP: x86Command += 0x0500; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST16(m_RecompPos,x86Command); + PUTDST8(m_RecompPos,offset); + } } -void CX86Ops::MoveConstByteToN64Mem(BYTE Const, x86Reg AddrReg) { - CPU_Message(" mov byte ptr [%s+N64mem], %Xh",x86_Name(AddrReg),Const); - switch (AddrReg) { - case x86_EAX: PUTDST16(m_RecompPos,0x80C6); break; - case x86_EBX: PUTDST16(m_RecompPos,0x83C6); break; - case x86_ECX: PUTDST16(m_RecompPos,0x81C6); break; - case x86_EDX: PUTDST16(m_RecompPos,0x82C6); break; - case x86_ESI: PUTDST16(m_RecompPos,0x86C6); break; - case x86_EDI: PUTDST16(m_RecompPos,0x87C6); break; - case x86_ESP: PUTDST16(m_RecompPos,0x84C6); break; - case x86_EBP: PUTDST16(m_RecompPos,0x85C6); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,g_MMU->Rdram()); - PUTDST8(m_RecompPos,Const); +void CX86Ops::MoveConstByteToN64Mem(uint8_t Const, x86Reg AddrReg) +{ + CPU_Message(" mov byte ptr [%s+N64mem], %Xh",x86_Name(AddrReg),Const); + switch (AddrReg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x80C6); break; + case x86_EBX: PUTDST16(m_RecompPos,0x83C6); break; + case x86_ECX: PUTDST16(m_RecompPos,0x81C6); break; + case x86_EDX: PUTDST16(m_RecompPos,0x82C6); break; + case x86_ESI: PUTDST16(m_RecompPos,0x86C6); break; + case x86_EDI: PUTDST16(m_RecompPos,0x87C6); break; + case x86_ESP: PUTDST16(m_RecompPos,0x84C6); break; + case x86_EBP: PUTDST16(m_RecompPos,0x85C6); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,g_MMU->Rdram()); + PUTDST8(m_RecompPos,Const); } -void CX86Ops::MoveConstByteToVariable (BYTE Const,void *Variable, const char * VariableName) { - CPU_Message(" mov byte ptr [%s], %Xh",VariableName,Const); - PUTDST16(m_RecompPos,0x05C6); +void CX86Ops::MoveConstByteToVariable (uint8_t Const,void *Variable, const char * VariableName) +{ + CPU_Message(" mov byte ptr [%s], %Xh",VariableName,Const); + PUTDST16(m_RecompPos,0x05C6); PUTDST32(m_RecompPos,Variable); PUTDST8(m_RecompPos,Const); } -void CX86Ops::MoveConstHalfToN64Mem(WORD Const, x86Reg AddrReg) { - CPU_Message(" mov word ptr [%s+N64mem], %Xh",x86_Name(AddrReg),Const); - PUTDST8(m_RecompPos,0x66); - switch (AddrReg) { - case x86_EAX: PUTDST16(m_RecompPos,0x80C7); break; - case x86_EBX: PUTDST16(m_RecompPos,0x83C7); break; - case x86_ECX: PUTDST16(m_RecompPos,0x81C7); break; - case x86_EDX: PUTDST16(m_RecompPos,0x82C7); break; - case x86_ESI: PUTDST16(m_RecompPos,0x86C7); break; - case x86_EDI: PUTDST16(m_RecompPos,0x87C7); break; - case x86_ESP: PUTDST16(m_RecompPos,0x84C7); break; - case x86_EBP: PUTDST16(m_RecompPos,0x85C7); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,g_MMU->Rdram()); - PUTDST16(m_RecompPos,Const); +void CX86Ops::MoveConstHalfToN64Mem(uint16_t Const, x86Reg AddrReg) +{ + CPU_Message(" mov word ptr [%s+N64mem], %Xh",x86_Name(AddrReg),Const); + PUTDST8(m_RecompPos,0x66); + switch (AddrReg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x80C7); break; + case x86_EBX: PUTDST16(m_RecompPos,0x83C7); break; + case x86_ECX: PUTDST16(m_RecompPos,0x81C7); break; + case x86_EDX: PUTDST16(m_RecompPos,0x82C7); break; + case x86_ESI: PUTDST16(m_RecompPos,0x86C7); break; + case x86_EDI: PUTDST16(m_RecompPos,0x87C7); break; + case x86_ESP: PUTDST16(m_RecompPos,0x84C7); break; + case x86_EBP: PUTDST16(m_RecompPos,0x85C7); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,g_MMU->Rdram()); + PUTDST16(m_RecompPos,Const); } -void CX86Ops::MoveConstHalfToVariable (WORD Const,void *Variable, const char * VariableName) { - CPU_Message(" mov word ptr [%s], %Xh",VariableName,Const); - PUTDST8(m_RecompPos,0x66); - PUTDST16(m_RecompPos,0x05C7); +void CX86Ops::MoveConstHalfToVariable (uint16_t Const,void *Variable, const char * VariableName) +{ + CPU_Message(" mov word ptr [%s], %Xh",VariableName,Const); + PUTDST8(m_RecompPos,0x66); + PUTDST16(m_RecompPos,0x05C7); PUTDST32(m_RecompPos,Variable); PUTDST16(m_RecompPos,Const); } -void CX86Ops::MoveConstHalfToX86regPointer(WORD Const, x86Reg AddrReg1, x86Reg AddrReg2) { - BYTE Param = 0; +void CX86Ops::MoveConstHalfToX86regPointer(uint16_t Const, x86Reg AddrReg1, x86Reg AddrReg2) +{ + uint8_t Param = 0; - CPU_Message(" mov word ptr [%s+%s],%Xh",x86_Name(AddrReg1), x86_Name(AddrReg2), Const); + CPU_Message(" mov word ptr [%s+%s],%Xh",x86_Name(AddrReg1), x86_Name(AddrReg2), Const); - PUTDST8(m_RecompPos,0x66); - PUTDST16(m_RecompPos,0x04C7); + PUTDST8(m_RecompPos,0x66); + PUTDST16(m_RecompPos,0x04C7); - switch (AddrReg1) { - case x86_EAX: Param = 0x00; break; - case x86_EBX: Param = 0x03; break; - case x86_ECX: Param = 0x01; break; - case x86_EDX: Param = 0x02; break; - case x86_ESI: Param = 0x06; break; - case x86_EDI: Param = 0x07; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + switch (AddrReg1) + { + case x86_EAX: Param = 0x00; break; + case x86_EBX: Param = 0x03; break; + case x86_ECX: Param = 0x01; break; + case x86_EDX: Param = 0x02; break; + case x86_ESI: Param = 0x06; break; + case x86_EDI: Param = 0x07; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } - switch (AddrReg2) { - case x86_EAX: Param += 0x00; break; - case x86_EBX: Param += 0x18; break; - case x86_ECX: Param += 0x08; break; - case x86_EDX: Param += 0x10; break; - case x86_ESI: Param += 0x30; break; - case x86_EDI: Param += 0x38; break; - case x86_ESP: Param += 0x20; break; - case x86_EBP: Param += 0x28; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST8(m_RecompPos,Param); - PUTDST16(m_RecompPos,Const); + switch (AddrReg2) + { + case x86_EAX: Param += 0x00; break; + case x86_EBX: Param += 0x18; break; + case x86_ECX: Param += 0x08; break; + case x86_EDX: Param += 0x10; break; + case x86_ESI: Param += 0x30; break; + case x86_EDI: Param += 0x38; break; + case x86_ESP: Param += 0x20; break; + case x86_EBP: Param += 0x28; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST8(m_RecompPos,Param); + PUTDST16(m_RecompPos,Const); } -void CX86Ops::MoveConstToMemoryDisp (DWORD Const, x86Reg AddrReg, DWORD Disp) { - CPU_Message(" mov dword ptr [%s+%Xh], %Xh",x86_Name(AddrReg),Disp,Const); - switch (AddrReg) { - case x86_EAX: PUTDST16(m_RecompPos,0x80C7); break; - case x86_EBX: PUTDST16(m_RecompPos,0x83C7); break; - case x86_ECX: PUTDST16(m_RecompPos,0x81C7); break; - case x86_EDX: PUTDST16(m_RecompPos,0x82C7); break; - case x86_ESI: PUTDST16(m_RecompPos,0x86C7); break; - case x86_EDI: PUTDST16(m_RecompPos,0x87C7); break; - case x86_ESP: PUTDST16(m_RecompPos,0x84C7); break; - case x86_EBP: PUTDST16(m_RecompPos,0x85C7); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,Disp); - PUTDST32(m_RecompPos,Const); +void CX86Ops::MoveConstToMemoryDisp (uint32_t Const, x86Reg AddrReg, uint32_t Disp) +{ + CPU_Message(" mov dword ptr [%s+%Xh], %Xh",x86_Name(AddrReg),Disp,Const); + switch (AddrReg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x80C7); break; + case x86_EBX: PUTDST16(m_RecompPos,0x83C7); break; + case x86_ECX: PUTDST16(m_RecompPos,0x81C7); break; + case x86_EDX: PUTDST16(m_RecompPos,0x82C7); break; + case x86_ESI: PUTDST16(m_RecompPos,0x86C7); break; + case x86_EDI: PUTDST16(m_RecompPos,0x87C7); break; + case x86_ESP: PUTDST16(m_RecompPos,0x84C7); break; + case x86_EBP: PUTDST16(m_RecompPos,0x85C7); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,Disp); + PUTDST32(m_RecompPos,Const); } -void CX86Ops::MoveConstToN64Mem(DWORD Const, x86Reg AddrReg) { - CPU_Message(" mov dword ptr [%s+N64mem], %Xh",x86_Name(AddrReg),Const); - switch (AddrReg) { - case x86_EAX: PUTDST16(m_RecompPos,0x80C7); break; - case x86_EBX: PUTDST16(m_RecompPos,0x83C7); break; - case x86_ECX: PUTDST16(m_RecompPos,0x81C7); break; - case x86_EDX: PUTDST16(m_RecompPos,0x82C7); break; - case x86_ESI: PUTDST16(m_RecompPos,0x86C7); break; - case x86_EDI: PUTDST16(m_RecompPos,0x87C7); break; - case x86_ESP: PUTDST16(m_RecompPos,0x84C7); break; - case x86_EBP: PUTDST16(m_RecompPos,0x85C7); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,g_MMU->Rdram()); - PUTDST32(m_RecompPos,Const); +void CX86Ops::MoveConstToN64Mem(uint32_t Const, x86Reg AddrReg) +{ + CPU_Message(" mov dword ptr [%s+N64mem], %Xh",x86_Name(AddrReg),Const); + switch (AddrReg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x80C7); break; + case x86_EBX: PUTDST16(m_RecompPos,0x83C7); break; + case x86_ECX: PUTDST16(m_RecompPos,0x81C7); break; + case x86_EDX: PUTDST16(m_RecompPos,0x82C7); break; + case x86_ESI: PUTDST16(m_RecompPos,0x86C7); break; + case x86_EDI: PUTDST16(m_RecompPos,0x87C7); break; + case x86_ESP: PUTDST16(m_RecompPos,0x84C7); break; + case x86_EBP: PUTDST16(m_RecompPos,0x85C7); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,g_MMU->Rdram()); + PUTDST32(m_RecompPos,Const); } -void CX86Ops::MoveConstToN64MemDisp (DWORD Const, x86Reg AddrReg, BYTE Disp) { - CPU_Message(" mov dword ptr [%s+N64mem+%Xh], %Xh",x86_Name(AddrReg),Const,Disp); - switch (AddrReg) { - case x86_EAX: PUTDST16(m_RecompPos,0x80C7); break; - case x86_EBX: PUTDST16(m_RecompPos,0x83C7); break; - case x86_ECX: PUTDST16(m_RecompPos,0x81C7); break; - case x86_EDX: PUTDST16(m_RecompPos,0x82C7); break; - case x86_ESI: PUTDST16(m_RecompPos,0x86C7); break; - case x86_EDI: PUTDST16(m_RecompPos,0x87C7); break; - case x86_ESP: PUTDST16(m_RecompPos,0x84C7); break; - case x86_EBP: PUTDST16(m_RecompPos,0x85C7); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,g_MMU->Rdram() + Disp); - PUTDST32(m_RecompPos,Const); +void CX86Ops::MoveConstToN64MemDisp (uint32_t Const, x86Reg AddrReg, uint8_t Disp) +{ + CPU_Message(" mov dword ptr [%s+N64mem+%Xh], %Xh",x86_Name(AddrReg),Const,Disp); + switch (AddrReg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x80C7); break; + case x86_EBX: PUTDST16(m_RecompPos,0x83C7); break; + case x86_ECX: PUTDST16(m_RecompPos,0x81C7); break; + case x86_EDX: PUTDST16(m_RecompPos,0x82C7); break; + case x86_ESI: PUTDST16(m_RecompPos,0x86C7); break; + case x86_EDI: PUTDST16(m_RecompPos,0x87C7); break; + case x86_ESP: PUTDST16(m_RecompPos,0x84C7); break; + case x86_EBP: PUTDST16(m_RecompPos,0x85C7); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,g_MMU->Rdram() + Disp); + PUTDST32(m_RecompPos,Const); } -void CX86Ops::MoveConstToVariable (DWORD Const,void *Variable, const char * VariableName) { - CPU_Message(" mov dword ptr [%s], %Xh",VariableName,Const); - PUTDST16(m_RecompPos,0x05C7); +void CX86Ops::MoveConstToVariable (uint32_t Const,void *Variable, const char * VariableName) +{ + CPU_Message(" mov dword ptr [%s], %Xh",VariableName,Const); + PUTDST16(m_RecompPos,0x05C7); PUTDST32(m_RecompPos,Variable); PUTDST32(m_RecompPos,Const); } -void CX86Ops::MoveConstToX86Pointer(DWORD Const, x86Reg X86Pointer) +void CX86Ops::MoveConstToX86Pointer(uint32_t Const, x86Reg X86Pointer) { - CPU_Message(" mov dword ptr [%s], %Xh",x86_Name(X86Pointer),Const); - PUTDST16(m_RecompPos,0x00C7 + (X86Pointer * 0x100)); + CPU_Message(" mov dword ptr [%s], %Xh",x86_Name(X86Pointer),Const); + PUTDST16(m_RecompPos,0x00C7 + (X86Pointer * 0x100)); PUTDST32(m_RecompPos,Const); } - -void CX86Ops::MoveConstToX86reg(DWORD Const, x86Reg reg) { - if (Const == 0) - { - XorX86RegToX86Reg(reg,reg); - } else { - CPU_Message(" mov %s, %Xh",x86_Name(reg),Const); - PUTDST16(m_RecompPos,0xC0C7 + (reg * 0x100)); - PUTDST32(m_RecompPos,Const); - } -} - -void CX86Ops::MoveConstByteToX86regPointer(BYTE Const, x86Reg AddrReg1, x86Reg AddrReg2) { - BYTE Param = 0; - - CPU_Message(" mov byte ptr [%s+%s],%Xh",x86_Name(AddrReg1), x86_Name(AddrReg2), Const); - - PUTDST16(m_RecompPos,0x04C6); - - switch (AddrReg1) { - case x86_EAX: Param = 0x00; break; - case x86_EBX: Param = 0x03; break; - case x86_ECX: Param = 0x01; break; - case x86_EDX: Param = 0x02; break; - case x86_ESI: Param = 0x06; break; - case x86_EDI: Param = 0x07; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (AddrReg2) { - case x86_EAX: Param += 0x00; break; - case x86_EBX: Param += 0x18; break; - case x86_ECX: Param += 0x08; break; - case x86_EDX: Param += 0x10; break; - case x86_ESI: Param += 0x30; break; - case x86_EDI: Param += 0x38; break; - case x86_ESP: Param += 0x20; break; - case x86_EBP: Param += 0x28; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST8(m_RecompPos,Param); - PUTDST8(m_RecompPos,Const); -} - -void CX86Ops::MoveConstToX86regPointer(DWORD Const, x86Reg AddrReg1, x86Reg AddrReg2) { - BYTE Param = 0; - - CPU_Message(" mov dword ptr [%s+%s],%Xh",x86_Name(AddrReg1), x86_Name(AddrReg2), Const); - - PUTDST16(m_RecompPos,0x04C7); - - switch (AddrReg1) { - case x86_EAX: Param = 0x00; break; - case x86_EBX: Param = 0x03; break; - case x86_ECX: Param = 0x01; break; - case x86_EDX: Param = 0x02; break; - case x86_ESI: Param = 0x06; break; - case x86_EDI: Param = 0x07; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (AddrReg2) { - case x86_EAX: Param += 0x00; break; - case x86_EBX: Param += 0x18; break; - case x86_ECX: Param += 0x08; break; - case x86_EDX: Param += 0x10; break; - case x86_ESI: Param += 0x30; break; - case x86_EDI: Param += 0x38; break; - case x86_ESP: Param += 0x20; break; - case x86_EBP: Param += 0x28; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST8(m_RecompPos,Param); - PUTDST32(m_RecompPos,Const); -} - -void CX86Ops::MoveN64MemDispToX86reg(x86Reg reg, x86Reg AddrReg, BYTE Disp) { - WORD x86Command = 0; - - CPU_Message(" mov %s, dword ptr [%s+N64mem+%Xh]",x86_Name(reg),x86_Name(AddrReg),Disp); - switch (AddrReg) { - case x86_EAX: x86Command = 0x008B; break; - case x86_EBX: x86Command = 0x038B; break; - case x86_ECX: x86Command = 0x018B; break; - case x86_EDX: x86Command = 0x028B; break; - case x86_ESI: x86Command = 0x068B; break; - case x86_EDI: x86Command = 0x078B; break; - case x86_ESP: x86Command = 0x048B; break; - case x86_EBP: x86Command = 0x058B; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - switch (reg) { - case x86_EAX: x86Command += 0x8000; break; - case x86_EBX: x86Command += 0x9800; break; - case x86_ECX: x86Command += 0x8800; break; - case x86_EDX: x86Command += 0x9000; break; - case x86_ESI: x86Command += 0xB000; break; - case x86_EDI: x86Command += 0xB800; break; - case x86_ESP: x86Command += 0xA000; break; - case x86_EBP: x86Command += 0xA800; break; - } - PUTDST16(m_RecompPos,x86Command); - PUTDST32(m_RecompPos,g_MMU->Rdram() + Disp); -} - -void CX86Ops::MoveN64MemToX86reg(x86Reg reg, x86Reg AddrReg) { - WORD x86Command = 0; - - CPU_Message(" mov %s, dword ptr [%s+N64mem]",x86_Name(reg),x86_Name(AddrReg)); - - switch (AddrReg) { - case x86_EAX: x86Command = 0x008B; break; - case x86_EBX: x86Command = 0x038B; break; - case x86_ECX: x86Command = 0x018B; break; - case x86_EDX: x86Command = 0x028B; break; - case x86_ESI: x86Command = 0x068B; break; - case x86_EDI: x86Command = 0x078B; break; - case x86_ESP: x86Command = 0x048B; break; - case x86_EBP: x86Command = 0x058B; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - switch (reg) { - case x86_EAX: x86Command += 0x8000; break; - case x86_EBX: x86Command += 0x9800; break; - case x86_ECX: x86Command += 0x8800; break; - case x86_EDX: x86Command += 0x9000; break; - case x86_ESI: x86Command += 0xB000; break; - case x86_EDI: x86Command += 0xB800; break; - case x86_ESP: x86Command += 0xA000; break; - case x86_EBP: x86Command += 0xA800; break; - } - PUTDST16(m_RecompPos,x86Command); - PUTDST32(m_RecompPos,g_MMU->Rdram()); -} - -void CX86Ops::MoveN64MemToX86regByte(x86Reg reg, x86Reg AddrReg) { - WORD x86Command = 0; - - CPU_Message(" mov %s, byte ptr [%s+N64mem]",x86_ByteName(reg),x86_Name(AddrReg)); - switch (AddrReg) { - case x86_EAX: x86Command = 0x008A; break; - case x86_EBX: x86Command = 0x038A; break; - case x86_ECX: x86Command = 0x018A; break; - case x86_EDX: x86Command = 0x028A; break; - case x86_ESI: x86Command = 0x068A; break; - case x86_EDI: x86Command = 0x078A; break; - case x86_ESP: x86Command = 0x048A; break; - case x86_EBP: x86Command = 0x058A; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - switch (reg) { - case x86_EAX: x86Command += 0x8000; break; - case x86_EBX: x86Command += 0x9800; break; - case x86_ECX: x86Command += 0x8800; break; - case x86_EDX: x86Command += 0x9000; break; -/* case x86_ESI: x86Command += 0xB000; break; */ -/* case x86_EDI: x86Command += 0xB800; break; */ -/* case x86_ESP: case x86_EBP: */ - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } - PUTDST16(m_RecompPos,x86Command); - PUTDST32(m_RecompPos,g_MMU->Rdram()); -} - -void CX86Ops::MoveN64MemToX86regHalf(x86Reg reg, x86Reg AddrReg) { - WORD x86Command = 0; - - CPU_Message(" mov %s, word ptr [%s+N64mem]",x86_HalfName(reg),x86_Name(AddrReg)); - - PUTDST8(m_RecompPos,0x66); - switch (AddrReg) { - case x86_EAX: x86Command = 0x008B; break; - case x86_EBX: x86Command = 0x038B; break; - case x86_ECX: x86Command = 0x018B; break; - case x86_EDX: x86Command = 0x028B; break; - case x86_ESI: x86Command = 0x068B; break; - case x86_EDI: x86Command = 0x078B; break; - case x86_ESP: x86Command = 0x048B; break; - case x86_EBP: x86Command = 0x058B; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - switch (reg) { - case x86_EAX: x86Command += 0x8000; break; - case x86_EBX: x86Command += 0x9800; break; - case x86_ECX: x86Command += 0x8800; break; - case x86_EDX: x86Command += 0x9000; break; - case x86_ESI: x86Command += 0xB000; break; - case x86_EDI: x86Command += 0xB800; break; - case x86_ESP: x86Command += 0xA000; break; - case x86_EBP: x86Command += 0xA800; break; - } - PUTDST16(m_RecompPos,x86Command); - PUTDST32(m_RecompPos,g_MMU->Rdram()); -} - -void CX86Ops::MoveSxByteX86regPointerToX86reg(x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg) { - BYTE Param = 0; - - CPU_Message(" movsx %s, byte ptr [%s+%s]",x86_Name(reg),x86_Name(AddrReg1), x86_Name(AddrReg2)); - - PUTDST16(m_RecompPos,0xBE0F); - switch (reg) { - case x86_EAX: PUTDST8(m_RecompPos,0x04); break; - case x86_EBX: PUTDST8(m_RecompPos,0x1C); break; - case x86_ECX: PUTDST8(m_RecompPos,0x0C); break; - case x86_EDX: PUTDST8(m_RecompPos,0x14); break; - case x86_ESI: PUTDST8(m_RecompPos,0x34); break; - case x86_EDI: PUTDST8(m_RecompPos,0x3C); break; - case x86_ESP: PUTDST8(m_RecompPos,0x24); break; - case x86_EBP: PUTDST8(m_RecompPos,0x2C); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (AddrReg1) { - case x86_EAX: Param = 0x00; break; - case x86_EBX: Param = 0x03; break; - case x86_ECX: Param = 0x01; break; - case x86_EDX: Param = 0x02; break; - case x86_ESI: Param = 0x06; break; - case x86_EDI: Param = 0x07; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (AddrReg2) { - case x86_EAX: Param += 0x00; break; - case x86_EBX: Param += 0x18; break; - case x86_ECX: Param += 0x08; break; - case x86_EDX: Param += 0x10; break; - case x86_ESI: Param += 0x30; break; - case x86_EDI: Param += 0x38; break; - case x86_ESP: Param += 0x20; break; - case x86_EBP: Param += 0x28; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST8(m_RecompPos,Param); -} - -void CX86Ops::MoveSxHalfX86regPointerToX86reg(x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg) { - BYTE Param = 0; - - CPU_Message(" movsx %s, word ptr [%s+%s]",x86_Name(reg),x86_Name(AddrReg1), x86_Name(AddrReg2)); - - PUTDST16(m_RecompPos,0xBF0F); - switch (reg) { - case x86_EAX: PUTDST8(m_RecompPos,0x04); break; - case x86_EBX: PUTDST8(m_RecompPos,0x1C); break; - case x86_ECX: PUTDST8(m_RecompPos,0x0C); break; - case x86_EDX: PUTDST8(m_RecompPos,0x14); break; - case x86_ESI: PUTDST8(m_RecompPos,0x34); break; - case x86_EDI: PUTDST8(m_RecompPos,0x3C); break; - case x86_ESP: PUTDST8(m_RecompPos,0x24); break; - case x86_EBP: PUTDST8(m_RecompPos,0x2C); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (AddrReg1) { - case x86_EAX: Param = 0x00; break; - case x86_EBX: Param = 0x03; break; - case x86_ECX: Param = 0x01; break; - case x86_EDX: Param = 0x02; break; - case x86_ESI: Param = 0x06; break; - case x86_EDI: Param = 0x07; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (AddrReg2) { - case x86_EAX: Param += 0x00; break; - case x86_EBX: Param += 0x18; break; - case x86_ECX: Param += 0x08; break; - case x86_EDX: Param += 0x10; break; - case x86_ESI: Param += 0x30; break; - case x86_EDI: Param += 0x38; break; - case x86_ESP: Param += 0x20; break; - case x86_EBP: Param += 0x28; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST8(m_RecompPos,Param); -} - -void CX86Ops::MoveSxN64MemToX86regByte(x86Reg reg, x86Reg AddrReg) { - WORD x86Command = 0; - - CPU_Message(" movsx %s, byte ptr [%s+Dmem]",x86_Name(reg),x86_Name(AddrReg)); - switch (AddrReg) { - case x86_EAX: x86Command = 0x00BE; break; - case x86_EBX: x86Command = 0x03BE; break; - case x86_ECX: x86Command = 0x01BE; break; - case x86_EDX: x86Command = 0x02BE; break; - case x86_ESI: x86Command = 0x06BE; break; - case x86_EDI: x86Command = 0x07BE; break; - case x86_ESP: x86Command = 0x04BE; break; - case x86_EBP: x86Command = 0x05BE; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - switch (reg) { - case x86_EAX: x86Command += 0x8000; break; - case x86_EBX: x86Command += 0x9800; break; - case x86_ECX: x86Command += 0x8800; break; - case x86_EDX: x86Command += 0x9000; break; - case x86_ESI: x86Command += 0xB000; break; - case x86_EDI: x86Command += 0xB800; break; - case x86_ESP: x86Command += 0xA000; break; - case x86_EBP: x86Command += 0xA800; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } - PUTDST8(m_RecompPos,0x0f); - PUTDST16(m_RecompPos,x86Command); - PUTDST32(m_RecompPos,g_MMU->Rdram()); -} - -void CX86Ops::MoveSxN64MemToX86regHalf(x86Reg reg, x86Reg AddrReg) { - WORD x86Command = 0; - - CPU_Message(" movsx %s, word ptr [%s+Dmem]",x86_Name(reg),x86_Name(AddrReg)); - - switch (AddrReg) { - case x86_EAX: x86Command = 0x00BF; break; - case x86_EBX: x86Command = 0x03BF; break; - case x86_ECX: x86Command = 0x01BF; break; - case x86_EDX: x86Command = 0x02BF; break; - case x86_ESI: x86Command = 0x06BF; break; - case x86_EDI: x86Command = 0x07BF; break; - case x86_ESP: x86Command = 0x04BF; break; - case x86_EBP: x86Command = 0x05BF; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - switch (reg) { - case x86_EAX: x86Command += 0x8000; break; - case x86_EBX: x86Command += 0x9800; break; - case x86_ECX: x86Command += 0x8800; break; - case x86_EDX: x86Command += 0x9000; break; - case x86_ESI: x86Command += 0xB000; break; - case x86_EDI: x86Command += 0xB800; break; - case x86_ESP: x86Command += 0xA000; break; - case x86_EBP: x86Command += 0xA800; break; - } - - PUTDST8(m_RecompPos, 0x0f); - PUTDST16(m_RecompPos,x86Command); - PUTDST32(m_RecompPos,g_MMU->Rdram()); -} - -void CX86Ops::MoveSxVariableToX86regByte(void *Variable, const char * VariableName, x86Reg reg) { - CPU_Message(" movsx %s, byte ptr [%s]",x86_Name(reg),VariableName); - - PUTDST16(m_RecompPos, 0xbe0f); - - switch (reg) { - case x86_EAX: PUTDST8(m_RecompPos,0x05); break; - case x86_EBX: PUTDST8(m_RecompPos,0x1D); break; - case x86_ECX: PUTDST8(m_RecompPos,0x0D); break; - case x86_EDX: PUTDST8(m_RecompPos,0x15); break; - case x86_ESI: PUTDST8(m_RecompPos,0x35); break; - case x86_EDI: PUTDST8(m_RecompPos,0x3D); break; - case x86_ESP: PUTDST8(m_RecompPos,0x25); break; - case x86_EBP: PUTDST8(m_RecompPos,0x2D); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::MoveSxVariableToX86regHalf(void *Variable, const char * VariableName, x86Reg reg) { - CPU_Message(" movsx %s, word ptr [%s]",x86_Name(reg),VariableName); - - PUTDST16(m_RecompPos, 0xbf0f); - - switch (reg) { - case x86_EAX: PUTDST8(m_RecompPos,0x05); break; - case x86_EBX: PUTDST8(m_RecompPos,0x1D); break; - case x86_ECX: PUTDST8(m_RecompPos,0x0D); break; - case x86_EDX: PUTDST8(m_RecompPos,0x15); break; - case x86_ESI: PUTDST8(m_RecompPos,0x35); break; - case x86_EDI: PUTDST8(m_RecompPos,0x3D); break; - case x86_ESP: PUTDST8(m_RecompPos,0x25); break; - case x86_EBP: PUTDST8(m_RecompPos,0x2D); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::MoveVariableToX86reg(void *Variable, const char * VariableName, x86Reg reg) { - CPU_Message(" mov %s, dword ptr [%s]",x86_Name(reg),VariableName); - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0x058B); break; - case x86_EBX: PUTDST16(m_RecompPos,0x1D8B); break; - case x86_ECX: PUTDST16(m_RecompPos,0x0D8B); break; - case x86_EDX: PUTDST16(m_RecompPos,0x158B); break; - case x86_ESI: PUTDST16(m_RecompPos,0x358B); break; - case x86_EDI: PUTDST16(m_RecompPos,0x3D8B); break; - case x86_ESP: PUTDST16(m_RecompPos,0x258B); break; - case x86_EBP: PUTDST16(m_RecompPos,0x2D8B); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::MoveVariableDispToX86Reg(void *Variable, const char * VariableName, x86Reg reg, x86Reg AddrReg, int Multiplier) { - int x = 0; - CPU_Message(" mov %s, dword ptr [%s+%s*%i]",x86_Name(reg),VariableName, x86_Name(AddrReg), Multiplier); - - PUTDST8(m_RecompPos,0x8B); - - switch (reg) { - case x86_EAX: PUTDST8(m_RecompPos,0x04); break; - case x86_EBX: PUTDST8(m_RecompPos,0x1C); break; - case x86_ECX: PUTDST8(m_RecompPos,0x0C); break; - case x86_EDX: PUTDST8(m_RecompPos,0x14); break; - case x86_ESI: PUTDST8(m_RecompPos,0x34); break; - case x86_EDI: PUTDST8(m_RecompPos,0x3C); break; - case x86_ESP: PUTDST8(m_RecompPos,0x24); break; - case x86_EBP: PUTDST8(m_RecompPos,0x2C); break; - } - - /* put in shifter 2(01), 4(10), 8(11) */ - switch (Multiplier) { - case 1: x = 0; break; - case 2: x = 0x40; break; - case 4: x = 0x80; break; - case 8: x = 0xC0; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - /* format xx|000000 */ - switch (AddrReg) { - case x86_EAX: PUTDST8(m_RecompPos,0x05|x); break; - case x86_EBX: PUTDST8(m_RecompPos,0x1D|x); break; - case x86_ECX: PUTDST8(m_RecompPos,0x0D|x); break; - case x86_EDX: PUTDST8(m_RecompPos,0x15|x); break; - case x86_ESI: PUTDST8(m_RecompPos,0x35|x); break; - case x86_EDI: PUTDST8(m_RecompPos,0x3D|x); break; - case x86_ESP: PUTDST8(m_RecompPos,0x25|x); break; - case x86_EBP: PUTDST8(m_RecompPos,0x2D|x); break; - } - - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::MoveVariableToX86regByte(void *Variable, const char * VariableName, x86Reg reg) { - CPU_Message(" mov %s, byte ptr [%s]",x86_ByteName(reg),VariableName); - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0x058A); break; - case x86_EBX: PUTDST16(m_RecompPos,0x1D8A); break; - case x86_ECX: PUTDST16(m_RecompPos,0x0D8A); break; - case x86_EDX: PUTDST16(m_RecompPos,0x158A); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::MoveVariableToX86regHalf(void *Variable, const char * VariableName, x86Reg reg) { - CPU_Message(" mov %s, word ptr [%s]",x86_HalfName(reg),VariableName); - PUTDST8(m_RecompPos,0x66); - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0x058B); break; - case x86_EBX: PUTDST16(m_RecompPos,0x1D8B); break; - case x86_ECX: PUTDST16(m_RecompPos,0x0D8B); break; - case x86_EDX: PUTDST16(m_RecompPos,0x158B); break; - case x86_ESI: PUTDST16(m_RecompPos,0x358B); break; - case x86_EDI: PUTDST16(m_RecompPos,0x3D8B); break; - case x86_ESP: PUTDST16(m_RecompPos,0x258B); break; - case x86_EBP: PUTDST16(m_RecompPos,0x2D8B); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::MoveX86regByteToN64Mem(x86Reg reg, x86Reg AddrReg) { - WORD x86Command = 0; - - CPU_Message(" mov byte ptr [%s+N64mem], %s",x86_Name(AddrReg),x86_ByteName(reg)); - - switch (AddrReg) { - case x86_EAX: x86Command = 0x0088; break; - case x86_EBX: x86Command = 0x0388; break; - case x86_ECX: x86Command = 0x0188; break; - case x86_EDX: x86Command = 0x0288; break; - case x86_ESI: x86Command = 0x0688; break; - case x86_EDI: x86Command = 0x0788; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - switch (reg) { - case x86_EAX: x86Command += 0x8000; break; - case x86_EBX: x86Command += 0x9800; break; - case x86_ECX: x86Command += 0x8800; break; - case x86_EDX: x86Command += 0x9000; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST16(m_RecompPos,x86Command); - PUTDST32(m_RecompPos,g_MMU->Rdram()); -} - -void CX86Ops::MoveX86regByteToVariable(x86Reg reg, void * Variable, const char * VariableName) { - CPU_Message(" mov byte ptr [%s], %s",VariableName,x86_ByteName(reg)); - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0x0588); break; - case x86_EBX: PUTDST16(m_RecompPos,0x1D88); break; - case x86_ECX: PUTDST16(m_RecompPos,0x0D88); break; - case x86_EDX: PUTDST16(m_RecompPos,0x1588); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::MoveX86regByteToX86regPointer(x86Reg reg, x86Reg AddrReg1, x86Reg AddrReg2) { - BYTE Param = 0; - - CPU_Message(" mov byte ptr [%s+%s],%s",x86_Name(AddrReg1), x86_Name(AddrReg2), x86_ByteName(reg)); - - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0x0488); break; - case x86_EBX: PUTDST16(m_RecompPos,0x1C88); break; - case x86_ECX: PUTDST16(m_RecompPos,0x0C88); break; - case x86_EDX: PUTDST16(m_RecompPos,0x1488); break; - case x86_ESI: PUTDST16(m_RecompPos,0x3488); break; - case x86_EDI: PUTDST16(m_RecompPos,0x3C88); break; - case x86_ESP: PUTDST16(m_RecompPos,0x2488); break; - case x86_EBP: PUTDST16(m_RecompPos,0x2C88); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (AddrReg1) { - case x86_EAX: Param = 0x00; break; - case x86_EBX: Param = 0x03; break; - case x86_ECX: Param = 0x01; break; - case x86_EDX: Param = 0x02; break; - case x86_ESI: Param = 0x06; break; - case x86_EDI: Param = 0x07; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (AddrReg2) { - case x86_EAX: Param += 0x00; break; - case x86_EBX: Param += 0x18; break; - case x86_ECX: Param += 0x08; break; - case x86_EDX: Param += 0x10; break; - case x86_ESI: Param += 0x30; break; - case x86_EDI: Param += 0x38; break; - case x86_ESP: Param += 0x20; break; - case x86_EBP: Param += 0x28; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST8(m_RecompPos,Param); -} - -void CX86Ops::MoveX86regHalfToN64Mem(x86Reg reg, x86Reg AddrReg) { - WORD x86Command = 0; - - CPU_Message(" mov word ptr [%s+N64mem], %s",x86_Name(AddrReg),x86_HalfName(reg)); - - PUTDST8(m_RecompPos,0x66); - switch (AddrReg) { - case x86_EAX: x86Command = 0x0089; break; - case x86_EBX: x86Command = 0x0389; break; - case x86_ECX: x86Command = 0x0189; break; - case x86_EDX: x86Command = 0x0289; break; - case x86_ESI: x86Command = 0x0689; break; - case x86_EDI: x86Command = 0x0789; break; - case x86_ESP: x86Command = 0x0489; break; - case x86_EBP: x86Command = 0x0589; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - switch (reg) { - case x86_EAX: x86Command += 0x8000; break; - case x86_EBX: x86Command += 0x9800; break; - case x86_ECX: x86Command += 0x8800; break; - case x86_EDX: x86Command += 0x9000; break; - case x86_ESI: x86Command += 0xB000; break; - case x86_EDI: x86Command += 0xB800; break; - case x86_ESP: x86Command += 0xA000; break; - case x86_EBP: x86Command += 0xA800; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST16(m_RecompPos,x86Command); - PUTDST32(m_RecompPos,g_MMU->Rdram()); -} - -void CX86Ops::MoveX86regHalfToVariable(x86Reg reg, void * Variable, const char * VariableName) { - CPU_Message(" mov word ptr [%s], %s",VariableName,x86_HalfName(reg)); - PUTDST8(m_RecompPos,0x66); - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0x0589); break; - case x86_EBX: PUTDST16(m_RecompPos,0x1D89); break; - case x86_ECX: PUTDST16(m_RecompPos,0x0D89); break; - case x86_EDX: PUTDST16(m_RecompPos,0x1589); break; - case x86_ESI: PUTDST16(m_RecompPos,0x3589); break; - case x86_EDI: PUTDST16(m_RecompPos,0x3D89); break; - case x86_ESP: PUTDST16(m_RecompPos,0x2589); break; - case x86_EBP: PUTDST16(m_RecompPos,0x2D89); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::MoveX86regHalfToX86regPointer(x86Reg reg, x86Reg AddrReg1, x86Reg AddrReg2) { - BYTE Param = 0; - - CPU_Message(" mov word ptr [%s+%s],%s",x86_Name(AddrReg1), x86_Name(AddrReg2), x86_HalfName(reg)); - - PUTDST8(m_RecompPos,0x66); - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0x0489); break; - case x86_EBX: PUTDST16(m_RecompPos,0x1C89); break; - case x86_ECX: PUTDST16(m_RecompPos,0x0C89); break; - case x86_EDX: PUTDST16(m_RecompPos,0x1489); break; - case x86_ESI: PUTDST16(m_RecompPos,0x3489); break; - case x86_EDI: PUTDST16(m_RecompPos,0x3C89); break; - case x86_ESP: PUTDST16(m_RecompPos,0x2489); break; - case x86_EBP: PUTDST16(m_RecompPos,0x2C89); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (AddrReg1) { - case x86_EAX: Param = 0x00; break; - case x86_EBX: Param = 0x03; break; - case x86_ECX: Param = 0x01; break; - case x86_EDX: Param = 0x02; break; - case x86_ESI: Param = 0x06; break; - case x86_EDI: Param = 0x07; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (AddrReg2) { - case x86_EAX: Param += 0x00; break; - case x86_EBX: Param += 0x18; break; - case x86_ECX: Param += 0x08; break; - case x86_EDX: Param += 0x10; break; - case x86_ESI: Param += 0x30; break; - case x86_EDI: Param += 0x38; break; - case x86_ESP: Param += 0x20; break; - case x86_EBP: Param += 0x28; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST8(m_RecompPos,Param); -} - -void CX86Ops::MoveX86PointerToX86reg(x86Reg reg, x86Reg X86Pointer) { - WORD x86Command = 0; - - CPU_Message(" mov %s, dword ptr [%s]",x86_Name(reg),x86_Name(X86Pointer)); - - switch (X86Pointer) { - case x86_EAX: x86Command = 0x008B; break; - case x86_EBX: x86Command = 0x038B; break; - case x86_ECX: x86Command = 0x018B; break; - case x86_EDX: x86Command = 0x028B; break; - case x86_ESI: x86Command = 0x068B; break; - case x86_EDI: x86Command = 0x078B; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (reg) { - case x86_EAX: x86Command += 0x0000; break; - case x86_EBX: x86Command += 0x1800; break; - case x86_ECX: x86Command += 0x0800; break; - case x86_EDX: x86Command += 0x1000; break; - case x86_ESI: x86Command += 0x3000; break; - case x86_EDI: x86Command += 0x3800; break; - case x86_ESP: x86Command += 0x2000; break; - case x86_EBP: x86Command += 0x2800; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST16(m_RecompPos,x86Command); -} - -void CX86Ops::MoveX86PointerToX86regDisp(x86Reg reg, x86Reg X86Pointer, BYTE Disp) { - WORD x86Command = 0; - - CPU_Message(" mov %s, dword ptr [%s] + %d",x86_Name(reg),x86_Name(X86Pointer),Disp); - - switch (X86Pointer) { - case x86_EAX: x86Command = 0x408B; break; - case x86_EBX: x86Command = 0x438B; break; - case x86_ECX: x86Command = 0x418B; break; - case x86_EDX: x86Command = 0x428B; break; - case x86_ESI: x86Command = 0x468B; break; - case x86_EDI: x86Command = 0x478B; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (reg) { - case x86_EAX: x86Command += 0x0000; break; - case x86_EBX: x86Command += 0x1800; break; - case x86_ECX: x86Command += 0x0800; break; - case x86_EDX: x86Command += 0x1000; break; - case x86_ESI: x86Command += 0x3000; break; - case x86_EDI: x86Command += 0x3800; break; - case x86_ESP: x86Command += 0x2000; break; - case x86_EBP: x86Command += 0x2800; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST16(m_RecompPos,x86Command); - PUTDST8(m_RecompPos,Disp); -} - -void CX86Ops::MoveX86regPointerToX86reg(x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg) { - BYTE Param = 0; - - CPU_Message(" mov %s, dword ptr [%s+%s]",x86_Name(reg),x86_Name(AddrReg1), x86_Name(AddrReg2)); - - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0x048B); break; - case x86_EBX: PUTDST16(m_RecompPos,0x1C8B); break; - case x86_ECX: PUTDST16(m_RecompPos,0x0C8B); break; - case x86_EDX: PUTDST16(m_RecompPos,0x148B); break; - case x86_ESI: PUTDST16(m_RecompPos,0x348B); break; - case x86_EDI: PUTDST16(m_RecompPos,0x3C8B); break; - case x86_ESP: PUTDST16(m_RecompPos,0x248B); break; - case x86_EBP: PUTDST16(m_RecompPos,0x2C8B); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (AddrReg1) { - case x86_EAX: Param = 0x00; break; - case x86_EBX: Param = 0x03; break; - case x86_ECX: Param = 0x01; break; - case x86_EDX: Param = 0x02; break; - case x86_ESI: Param = 0x06; break; - case x86_EDI: Param = 0x07; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (AddrReg2) { - case x86_EAX: Param += 0x00; break; - case x86_EBX: Param += 0x18; break; - case x86_ECX: Param += 0x08; break; - case x86_EDX: Param += 0x10; break; - case x86_ESI: Param += 0x30; break; - case x86_EDI: Param += 0x38; break; - case x86_ESP: Param += 0x20; break; - case x86_EBP: Param += 0x28; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST8(m_RecompPos,Param); -} - -void CX86Ops::MoveX86regPointerToX86regDisp8(x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg, BYTE offset) { - BYTE Param = 0; - - CPU_Message(" mov %s, dword ptr [%s+%s]",x86_Name(reg),x86_Name(AddrReg1), x86_Name(AddrReg2)); - - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0x448B); break; - case x86_EBX: PUTDST16(m_RecompPos,0x5C8B); break; - case x86_ECX: PUTDST16(m_RecompPos,0x4C8B); break; - case x86_EDX: PUTDST16(m_RecompPos,0x548B); break; - case x86_ESI: PUTDST16(m_RecompPos,0x748B); break; - case x86_EDI: PUTDST16(m_RecompPos,0x7C8B); break; - case x86_ESP: PUTDST16(m_RecompPos,0x648B); break; - case x86_EBP: PUTDST16(m_RecompPos,0x6C8B); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (AddrReg1) { - case x86_EAX: Param = 0x00; break; - case x86_EBX: Param = 0x03; break; - case x86_ECX: Param = 0x01; break; - case x86_EDX: Param = 0x02; break; - case x86_ESI: Param = 0x06; break; - case x86_EDI: Param = 0x07; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (AddrReg2) { - case x86_EAX: Param += 0x00; break; - case x86_EBX: Param += 0x18; break; - case x86_ECX: Param += 0x08; break; - case x86_EDX: Param += 0x10; break; - case x86_ESI: Param += 0x30; break; - case x86_EDI: Param += 0x38; break; - case x86_ESP: Param += 0x20; break; - case x86_EBP: Param += 0x28; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST8(m_RecompPos,Param); - PUTDST8(m_RecompPos,offset); -} - -void CX86Ops::MoveX86regToMemory(x86Reg reg, x86Reg AddrReg, DWORD Disp) { - WORD x86Command = 0; - - CPU_Message(" mov dword ptr [%s+%X], %s",x86_Name(AddrReg),Disp,x86_Name(reg)); - switch (AddrReg) { - case x86_EAX: x86Command = 0x0089; break; - case x86_EBX: x86Command = 0x0389; break; - case x86_ECX: x86Command = 0x0189; break; - case x86_EDX: x86Command = 0x0289; break; - case x86_ESI: x86Command = 0x0689; break; - case x86_EDI: x86Command = 0x0789; break; - case x86_ESP: x86Command = 0x0489; break; - case x86_EBP: x86Command = 0x0589; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - switch (reg) { - case x86_EAX: x86Command += 0x8000; break; - case x86_EBX: x86Command += 0x9800; break; - case x86_ECX: x86Command += 0x8800; break; - case x86_EDX: x86Command += 0x9000; break; - case x86_ESI: x86Command += 0xB000; break; - case x86_EDI: x86Command += 0xB800; break; - case x86_ESP: x86Command += 0xA000; break; - case x86_EBP: x86Command += 0xA800; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST16(m_RecompPos,x86Command); - PUTDST32(m_RecompPos,Disp); -} - -void CX86Ops::MoveX86regToN64Mem(x86Reg reg, x86Reg AddrReg) { - WORD x86Command = 0; - - CPU_Message(" mov dword ptr [%s+N64mem], %s",x86_Name(AddrReg),x86_Name(reg));\ - switch (AddrReg) { - case x86_EAX: x86Command = 0x0089; break; - case x86_EBX: x86Command = 0x0389; break; - case x86_ECX: x86Command = 0x0189; break; - case x86_EDX: x86Command = 0x0289; break; - case x86_ESI: x86Command = 0x0689; break; - case x86_EDI: x86Command = 0x0789; break; - case x86_ESP: x86Command = 0x0489; break; - case x86_EBP: x86Command = 0x0589; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - switch (reg) { - case x86_EAX: x86Command += 0x8000; break; - case x86_EBX: x86Command += 0x9800; break; - case x86_ECX: x86Command += 0x8800; break; - case x86_EDX: x86Command += 0x9000; break; - case x86_ESI: x86Command += 0xB000; break; - case x86_EDI: x86Command += 0xB800; break; - case x86_ESP: x86Command += 0xA000; break; - case x86_EBP: x86Command += 0xA800; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST16(m_RecompPos,x86Command); - PUTDST32(m_RecompPos,g_MMU->Rdram()); -} - -void CX86Ops::MoveX86regToN64MemDisp(x86Reg reg, x86Reg AddrReg, BYTE Disp) { - WORD x86Command = 0; - - CPU_Message(" mov dword ptr [%s+N64mem+%d], %s",x86_Name(AddrReg),Disp,x86_Name(reg));\ - switch (AddrReg) { - case x86_EAX: x86Command = 0x0089; break; - case x86_EBX: x86Command = 0x0389; break; - case x86_ECX: x86Command = 0x0189; break; - case x86_EDX: x86Command = 0x0289; break; - case x86_ESI: x86Command = 0x0689; break; - case x86_EDI: x86Command = 0x0789; break; - case x86_ESP: x86Command = 0x0489; break; - case x86_EBP: x86Command = 0x0589; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - switch (reg) { - case x86_EAX: x86Command += 0x8000; break; - case x86_EBX: x86Command += 0x9800; break; - case x86_ECX: x86Command += 0x8800; break; - case x86_EDX: x86Command += 0x9000; break; - case x86_ESI: x86Command += 0xB000; break; - case x86_EDI: x86Command += 0xB800; break; - case x86_ESP: x86Command += 0xA000; break; - case x86_EBP: x86Command += 0xA800; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST16(m_RecompPos,x86Command); - PUTDST32(m_RecompPos,g_MMU->Rdram()+Disp); -} - -void CX86Ops::MoveX86regToVariable(x86Reg reg, void * Variable, const char * VariableName) { - CPU_Message(" mov dword ptr [%s], %s",VariableName,x86_Name(reg)); - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0x0589); break; - case x86_EBX: PUTDST16(m_RecompPos,0x1D89); break; - case x86_ECX: PUTDST16(m_RecompPos,0x0D89); break; - case x86_EDX: PUTDST16(m_RecompPos,0x1589); break; - case x86_ESI: PUTDST16(m_RecompPos,0x3589); break; - case x86_EDI: PUTDST16(m_RecompPos,0x3D89); break; - case x86_ESP: PUTDST16(m_RecompPos,0x2589); break; - case x86_EBP: PUTDST16(m_RecompPos,0x2D89); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::MoveX86RegToX86Reg(x86Reg Source, x86Reg Destination) { - WORD x86Command = 0; - - if (Source == Destination) - { - return; - } - CPU_Message(" mov %s, %s",x86_Name(Destination),x86_Name(Source)); - - switch (Destination) {\ - case x86_EAX: x86Command = 0x0089; break; - case x86_EBX: x86Command = 0x0389; break; - case x86_ECX: x86Command = 0x0189; break; - case x86_EDX: x86Command = 0x0289; break; - case x86_ESI: x86Command = 0x0689; break; - case x86_EDI: x86Command = 0x0789; break; - case x86_ESP: x86Command = 0x0489; break; - case x86_EBP: x86Command = 0x0589; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (Source) { - case x86_EAX: x86Command += 0xC000; break; - case x86_EBX: x86Command += 0xD800; break; - case x86_ECX: x86Command += 0xC800; break; - case x86_EDX: x86Command += 0xD000; break; - case x86_ESI: x86Command += 0xF000; break; - case x86_EDI: x86Command += 0xF800; break; - case x86_ESP: x86Command += 0xE000; break; - case x86_EBP: x86Command += 0xE800; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST16(m_RecompPos,x86Command); -} - -void CX86Ops::MoveX86regToX86Pointer(x86Reg reg, x86Reg X86Pointer) { - WORD x86Command = 0; - - CPU_Message(" mov dword ptr [%s], %s",x86_Name(X86Pointer),x86_Name(reg)); - - switch (X86Pointer) { - case x86_EAX: x86Command = 0x0089; break; - case x86_EBX: x86Command = 0x0389; break; - case x86_ECX: x86Command = 0x0189; break; - case x86_EDX: x86Command = 0x0289; break; - case x86_ESI: x86Command = 0x0689; break; - case x86_EDI: x86Command = 0x0789; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (reg) { - case x86_EAX: x86Command += 0x0000; break; - case x86_EBX: x86Command += 0x1800; break; - case x86_ECX: x86Command += 0x0800; break; - case x86_EDX: x86Command += 0x1000; break; - case x86_ESI: x86Command += 0x3000; break; - case x86_EDI: x86Command += 0x3800; break; - case x86_ESP: x86Command += 0x2000; break; - case x86_EBP: x86Command += 0x2800; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST16(m_RecompPos,x86Command); -} - -void CX86Ops::MoveX86regToX86regPointer(x86Reg reg, x86Reg AddrReg1, x86Reg AddrReg2) { - BYTE Param = 0; - - CPU_Message(" mov dword ptr [%s+%s],%s",x86_Name(AddrReg1), x86_Name(AddrReg2), x86_Name(reg)); - - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0x0489); break; - case x86_EBX: PUTDST16(m_RecompPos,0x1C89); break; - case x86_ECX: PUTDST16(m_RecompPos,0x0C89); break; - case x86_EDX: PUTDST16(m_RecompPos,0x1489); break; - case x86_ESI: PUTDST16(m_RecompPos,0x3489); break; - case x86_EDI: PUTDST16(m_RecompPos,0x3C89); break; - case x86_ESP: PUTDST16(m_RecompPos,0x2489); break; - case x86_EBP: PUTDST16(m_RecompPos,0x2C89); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (AddrReg1) { - case x86_EAX: Param = 0x00; break; - case x86_EBX: Param = 0x03; break; - case x86_ECX: Param = 0x01; break; - case x86_EDX: Param = 0x02; break; - case x86_ESI: Param = 0x06; break; - case x86_EDI: Param = 0x07; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (AddrReg2) { - case x86_EAX: Param += 0x00; break; - case x86_EBX: Param += 0x18; break; - case x86_ECX: Param += 0x08; break; - case x86_EDX: Param += 0x10; break; - case x86_ESI: Param += 0x30; break; - case x86_EDI: Param += 0x38; break; - case x86_ESP: Param += 0x20; break; - case x86_EBP: Param += 0x28; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST8(m_RecompPos,Param); -} - -void CX86Ops::MoveZxByteX86regPointerToX86reg(x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg) { - BYTE Param = 0; - - CPU_Message(" movzx %s, byte ptr [%s+%s]",x86_Name(reg),x86_Name(AddrReg1), x86_Name(AddrReg2)); - - PUTDST16(m_RecompPos,0xB60F); - switch (reg) { - case x86_EAX: PUTDST8(m_RecompPos,0x04); break; - case x86_EBX: PUTDST8(m_RecompPos,0x1C); break; - case x86_ECX: PUTDST8(m_RecompPos,0x0C); break; - case x86_EDX: PUTDST8(m_RecompPos,0x14); break; - case x86_ESI: PUTDST8(m_RecompPos,0x34); break; - case x86_EDI: PUTDST8(m_RecompPos,0x3C); break; - case x86_ESP: PUTDST8(m_RecompPos,0x24); break; - case x86_EBP: PUTDST8(m_RecompPos,0x2C); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (AddrReg1) { - case x86_EAX: Param = 0x00; break; - case x86_EBX: Param = 0x03; break; - case x86_ECX: Param = 0x01; break; - case x86_EDX: Param = 0x02; break; - case x86_ESI: Param = 0x06; break; - case x86_EDI: Param = 0x07; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (AddrReg2) { - case x86_EAX: Param += 0x00; break; - case x86_EBX: Param += 0x18; break; - case x86_ECX: Param += 0x08; break; - case x86_EDX: Param += 0x10; break; - case x86_ESI: Param += 0x30; break; - case x86_EDI: Param += 0x38; break; - case x86_ESP: Param += 0x20; break; - case x86_EBP: Param += 0x28; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST8(m_RecompPos,Param); -} - -void CX86Ops::MoveZxHalfX86regPointerToX86reg(x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg) { - BYTE Param = 0; - - CPU_Message(" movzx %s, word ptr [%s+%s]",x86_Name(reg),x86_Name(AddrReg1), x86_Name(AddrReg2)); - - PUTDST16(m_RecompPos,0xB70F); - switch (reg) { - case x86_EAX: PUTDST8(m_RecompPos,0x04); break; - case x86_EBX: PUTDST8(m_RecompPos,0x1C); break; - case x86_ECX: PUTDST8(m_RecompPos,0x0C); break; - case x86_EDX: PUTDST8(m_RecompPos,0x14); break; - case x86_ESI: PUTDST8(m_RecompPos,0x34); break; - case x86_EDI: PUTDST8(m_RecompPos,0x3C); break; - case x86_ESP: PUTDST8(m_RecompPos,0x24); break; - case x86_EBP: PUTDST8(m_RecompPos,0x2C); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (AddrReg1) { - case x86_EAX: Param = 0x00; break; - case x86_EBX: Param = 0x03; break; - case x86_ECX: Param = 0x01; break; - case x86_EDX: Param = 0x02; break; - case x86_ESI: Param = 0x06; break; - case x86_EDI: Param = 0x07; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (AddrReg2) { - case x86_EAX: Param += 0x00; break; - case x86_EBX: Param += 0x18; break; - case x86_ECX: Param += 0x08; break; - case x86_EDX: Param += 0x10; break; - case x86_ESI: Param += 0x30; break; - case x86_EDI: Param += 0x38; break; - case x86_ESP: Param += 0x20; break; - case x86_EBP: Param += 0x28; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST8(m_RecompPos,Param); -} - -void CX86Ops::MoveZxN64MemToX86regByte(x86Reg reg, x86Reg AddrReg) { - WORD x86Command = 0; - - CPU_Message(" movzx %s, byte ptr [%s+g_MMU->Rdram()]",x86_Name(reg),x86_Name(AddrReg)); - switch (AddrReg) { - case x86_EAX: x86Command = 0x00B6; break; - case x86_EBX: x86Command = 0x03B6; break; - case x86_ECX: x86Command = 0x01B6; break; - case x86_EDX: x86Command = 0x02B6; break; - case x86_ESI: x86Command = 0x06B6; break; - case x86_EDI: x86Command = 0x07B6; break; - case x86_ESP: x86Command = 0x04B6; break; - case x86_EBP: x86Command = 0x05B6; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - switch (reg) { - case x86_EAX: x86Command += 0x8000; break; - case x86_EBX: x86Command += 0x9800; break; - case x86_ECX: x86Command += 0x8800; break; - case x86_EDX: x86Command += 0x9000; break; - case x86_ESI: x86Command += 0xB000; break; - case x86_EDI: x86Command += 0xB800; break; - case x86_ESP: x86Command += 0xA000; break; - case x86_EBP: x86Command += 0xA800; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } - PUTDST8(m_RecompPos,0x0f); - PUTDST16(m_RecompPos,x86Command); - PUTDST32(m_RecompPos,g_MMU->Rdram()); -} - -void CX86Ops::MoveZxN64MemToX86regHalf(x86Reg reg, x86Reg AddrReg) { - WORD x86Command = 0; - - CPU_Message(" movzx %s, word ptr [%s+g_MMU->Rdram()]",x86_Name(reg),x86_Name(AddrReg)); - - switch (AddrReg) { - case x86_EAX: x86Command = 0x00B7; break; - case x86_EBX: x86Command = 0x03B7; break; - case x86_ECX: x86Command = 0x01B7; break; - case x86_EDX: x86Command = 0x02B7; break; - case x86_ESI: x86Command = 0x06B7; break; - case x86_EDI: x86Command = 0x07B7; break; - case x86_ESP: x86Command = 0x04B7; break; - case x86_EBP: x86Command = 0x05B7; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - switch (reg) { - case x86_EAX: x86Command += 0x8000; break; - case x86_EBX: x86Command += 0x9800; break; - case x86_ECX: x86Command += 0x8800; break; - case x86_EDX: x86Command += 0x9000; break; - case x86_ESI: x86Command += 0xB000; break; - case x86_EDI: x86Command += 0xB800; break; - case x86_ESP: x86Command += 0xA000; break; - case x86_EBP: x86Command += 0xA800; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - PUTDST8(m_RecompPos, 0x0f); - PUTDST16(m_RecompPos,x86Command); - PUTDST32(m_RecompPos,g_MMU->Rdram()); -} - -void CX86Ops::MoveZxVariableToX86regByte(void *Variable, const char * VariableName, x86Reg reg) { - CPU_Message(" movzx %s, byte ptr [%s]",x86_Name(reg),VariableName); - - PUTDST16(m_RecompPos, 0xb60f); - - switch (reg) { - case x86_EAX: PUTDST8(m_RecompPos,0x05); break; - case x86_EBX: PUTDST8(m_RecompPos,0x1D); break; - case x86_ECX: PUTDST8(m_RecompPos,0x0D); break; - case x86_EDX: PUTDST8(m_RecompPos,0x15); break; - case x86_ESI: PUTDST8(m_RecompPos,0x35); break; - case x86_EDI: PUTDST8(m_RecompPos,0x3D); break; - case x86_ESP: PUTDST8(m_RecompPos,0x25); break; - case x86_EBP: PUTDST8(m_RecompPos,0x2D); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::MoveZxVariableToX86regHalf(void *Variable, const char * VariableName, x86Reg reg) { - CPU_Message(" movzx %s, word ptr [%s]",x86_Name(reg),VariableName); - - PUTDST16(m_RecompPos, 0xb70f); - - switch (reg) { - case x86_EAX: PUTDST8(m_RecompPos,0x05); break; - case x86_EBX: PUTDST8(m_RecompPos,0x1D); break; - case x86_ECX: PUTDST8(m_RecompPos,0x0D); break; - case x86_EDX: PUTDST8(m_RecompPos,0x15); break; - case x86_ESI: PUTDST8(m_RecompPos,0x35); break; - case x86_EDI: PUTDST8(m_RecompPos,0x3D); break; - case x86_ESP: PUTDST8(m_RecompPos,0x25); break; - case x86_EBP: PUTDST8(m_RecompPos,0x2D); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::MulX86reg(x86Reg reg) { - CPU_Message(" mul %s",x86_Name(reg));\ - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0xE0F7); break; - case x86_EBX: PUTDST16(m_RecompPos,0xE3F7); break; - case x86_ECX: PUTDST16(m_RecompPos,0xE1F7); break; - case x86_EDX: PUTDST16(m_RecompPos,0xE2F7); break; - case x86_ESI: PUTDST16(m_RecompPos,0xE6F7); break; - case x86_EDI: PUTDST16(m_RecompPos,0xE7F7); break; - case x86_ESP: PUTDST16(m_RecompPos,0xE4F7); break; - case x86_EBP: PUTDST16(m_RecompPos,0xE5F7); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::NotX86Reg(x86Reg reg) { - CPU_Message(" not %s",x86_Name(reg)); - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0xD0F7); break; - case x86_EBX: PUTDST16(m_RecompPos,0xD3F7); break; - case x86_ECX: PUTDST16(m_RecompPos,0xD1F7); break; - case x86_EDX: PUTDST16(m_RecompPos,0xD2F7); break; - case x86_ESI: PUTDST16(m_RecompPos,0xD6F7); break; - case x86_EDI: PUTDST16(m_RecompPos,0xD7F7); break; - case x86_ESP: PUTDST16(m_RecompPos,0xD4F7); break; - case x86_EBP: PUTDST16(m_RecompPos,0xD5F7); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::OrConstToVariable(DWORD Const, void * Variable, const char * VariableName) { - CPU_Message(" or dword ptr [%s], 0x%X",VariableName, Const); - PUTDST16(m_RecompPos,0x0D81); - PUTDST32(m_RecompPos,Variable); - PUTDST32(m_RecompPos,Const); -} - -void CX86Ops::OrConstToX86Reg(DWORD Const, x86Reg reg) { - CPU_Message(" or %s, %Xh",x86_Name(reg),Const); - if ((Const & 0xFFFFFF80) != 0 && (Const & 0xFFFFFF80) != 0xFFFFFF80) { - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0xC881); break; - case x86_EBX: PUTDST16(m_RecompPos,0xCB81); break; - case x86_ECX: PUTDST16(m_RecompPos,0xC981); break; - case x86_EDX: PUTDST16(m_RecompPos,0xCA81); break; - case x86_ESI: PUTDST16(m_RecompPos,0xCE81); break; - case x86_EDI: PUTDST16(m_RecompPos,0xCF81); break; - case x86_ESP: PUTDST16(m_RecompPos,0xCC81); break; - case x86_EBP: PUTDST16(m_RecompPos,0xCD81); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos, Const); - } else { - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0xC883); break; - case x86_EBX: PUTDST16(m_RecompPos,0xCB83); break; - case x86_ECX: PUTDST16(m_RecompPos,0xC983); break; - case x86_EDX: PUTDST16(m_RecompPos,0xCA83); break; - case x86_ESI: PUTDST16(m_RecompPos,0xCE83); break; - case x86_EDI: PUTDST16(m_RecompPos,0xCF83); break; - case x86_ESP: PUTDST16(m_RecompPos,0xCC83); break; - case x86_EBP: PUTDST16(m_RecompPos,0xCD83); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST8(m_RecompPos, Const); - } -} - -void CX86Ops::OrVariableToX86Reg(void * Variable, const char * VariableName, x86Reg reg) { - CPU_Message(" or %s, dword ptr [%s]",x86_Name(reg),VariableName); - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0x050B); break; - case x86_EBX: PUTDST16(m_RecompPos,0x1D0B); break; - case x86_ECX: PUTDST16(m_RecompPos,0x0D0B); break; - case x86_EDX: PUTDST16(m_RecompPos,0x150B); break; - case x86_ESI: PUTDST16(m_RecompPos,0x350B); break; - case x86_EDI: PUTDST16(m_RecompPos,0x3D0B); break; - case x86_ESP: PUTDST16(m_RecompPos,0x250B); break; - case x86_EBP: PUTDST16(m_RecompPos,0x2D0B); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::OrX86RegToVariable(void * Variable, const char * VariableName, x86Reg reg) { - CPU_Message(" or dword ptr [%s], %s",VariableName, x86_Name(reg)); - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0x0509); break; - case x86_EBX: PUTDST16(m_RecompPos,0x1D09); break; - case x86_ECX: PUTDST16(m_RecompPos,0x0D09); break; - case x86_EDX: PUTDST16(m_RecompPos,0x1509); break; - case x86_ESI: PUTDST16(m_RecompPos,0x3509); break; - case x86_EDI: PUTDST16(m_RecompPos,0x3D09); break; - case x86_ESP: PUTDST16(m_RecompPos,0x2509); break; - case x86_EBP: PUTDST16(m_RecompPos,0x2D09); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::OrX86RegToX86Reg(x86Reg Destination, x86Reg Source) { - WORD x86Command = 0; - - CPU_Message(" or %s, %s",x86_Name(Destination),x86_Name(Source)); - switch (Source) { - case x86_EAX: x86Command = 0x000B; break; - case x86_EBX: x86Command = 0x030B; break; - case x86_ECX: x86Command = 0x010B; break; - case x86_EDX: x86Command = 0x020B; break; - case x86_ESI: x86Command = 0x060B; break; - case x86_EDI: x86Command = 0x070B; break; - case x86_ESP: x86Command = 0x040B; break; - case x86_EBP: x86Command = 0x050B; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - switch (Destination) { - case x86_EAX: x86Command += 0xC000; break; - case x86_EBX: x86Command += 0xD800; break; - case x86_ECX: x86Command += 0xC800; break; - case x86_EDX: x86Command += 0xD000; break; - case x86_ESI: x86Command += 0xF000; break; - case x86_EDI: x86Command += 0xF800; break; - case x86_ESP: x86Command += 0xE000; break; - case x86_EBP: x86Command += 0xE800; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST16(m_RecompPos,x86Command); -} - -void CX86Ops::Popad(void) { - CPU_Message(" popad"); - PUTDST8(m_RecompPos,0x61); -} - -void CX86Ops::Pushad(void) { - CPU_Message(" pushad"); - PUTDST8(m_RecompPos,0x60); -} - -void CX86Ops::Push(x86Reg reg) { - CPU_Message(" push %s", x86_Name(reg)); - - switch(reg) { - case x86_EAX: PUTDST8(m_RecompPos, 0x50); break; - case x86_EBX: PUTDST8(m_RecompPos, 0x53); break; - case x86_ECX: PUTDST8(m_RecompPos, 0x51); break; - case x86_EDX: PUTDST8(m_RecompPos, 0x52); break; - case x86_ESI: PUTDST8(m_RecompPos, 0x56); break; - case x86_EDI: PUTDST8(m_RecompPos, 0x57); break; - case x86_ESP: PUTDST8(m_RecompPos, 0x54); break; - case x86_EBP: PUTDST8(m_RecompPos, 0x55); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::Pop(x86Reg reg) { - CPU_Message(" pop %s", x86_Name(reg)); - - switch(reg) { - case x86_EAX: PUTDST8(m_RecompPos, 0x58); break; - case x86_EBX: PUTDST8(m_RecompPos, 0x5B); break; - case x86_ECX: PUTDST8(m_RecompPos, 0x59); break; - case x86_EDX: PUTDST8(m_RecompPos, 0x5A); break; - case x86_ESI: PUTDST8(m_RecompPos, 0x5E); break; - case x86_EDI: PUTDST8(m_RecompPos, 0x5F); break; - case x86_ESP: PUTDST8(m_RecompPos, 0x5C); break; - case x86_EBP: PUTDST8(m_RecompPos, 0x5D); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::PushImm32(DWORD Value) +void CX86Ops::MoveConstToX86reg(uint32_t Const, x86Reg reg) { - PushImm32(stdstr_f("%d",Value).c_str(),Value); + if (Const == 0) + { + XorX86RegToX86Reg(reg,reg); + } + else + { + CPU_Message(" mov %s, %Xh",x86_Name(reg),Const); + PUTDST16(m_RecompPos,0xC0C7 + (reg * 0x100)); + PUTDST32(m_RecompPos,Const); + } } -void CX86Ops::PushImm32(const char * String, DWORD Value) { - CPU_Message(" push %s",String); - PUTDST8(m_RecompPos,0x68); - PUTDST32(m_RecompPos,Value); +void CX86Ops::MoveConstByteToX86regPointer(uint8_t Const, x86Reg AddrReg1, x86Reg AddrReg2) +{ + uint8_t Param = 0; + + CPU_Message(" mov byte ptr [%s+%s],%Xh",x86_Name(AddrReg1), x86_Name(AddrReg2), Const); + + PUTDST16(m_RecompPos,0x04C6); + + switch (AddrReg1) + { + case x86_EAX: Param = 0x00; break; + case x86_EBX: Param = 0x03; break; + case x86_ECX: Param = 0x01; break; + case x86_EDX: Param = 0x02; break; + case x86_ESI: Param = 0x06; break; + case x86_EDI: Param = 0x07; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (AddrReg2) + { + case x86_EAX: Param += 0x00; break; + case x86_EBX: Param += 0x18; break; + case x86_ECX: Param += 0x08; break; + case x86_EDX: Param += 0x10; break; + case x86_ESI: Param += 0x30; break; + case x86_EDI: Param += 0x38; break; + case x86_ESP: Param += 0x20; break; + case x86_EBP: Param += 0x28; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST8(m_RecompPos,Param); + PUTDST8(m_RecompPos,Const); +} + +void CX86Ops::MoveConstToX86regPointer(uint32_t Const, x86Reg AddrReg1, x86Reg AddrReg2) +{ + uint8_t Param = 0; + + CPU_Message(" mov dword ptr [%s+%s],%Xh",x86_Name(AddrReg1), x86_Name(AddrReg2), Const); + + PUTDST16(m_RecompPos,0x04C7); + + switch (AddrReg1) { + case x86_EAX: Param = 0x00; break; + case x86_EBX: Param = 0x03; break; + case x86_ECX: Param = 0x01; break; + case x86_EDX: Param = 0x02; break; + case x86_ESI: Param = 0x06; break; + case x86_EDI: Param = 0x07; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (AddrReg2) { + case x86_EAX: Param += 0x00; break; + case x86_EBX: Param += 0x18; break; + case x86_ECX: Param += 0x08; break; + case x86_EDX: Param += 0x10; break; + case x86_ESI: Param += 0x30; break; + case x86_EDI: Param += 0x38; break; + case x86_ESP: Param += 0x20; break; + case x86_EBP: Param += 0x28; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST8(m_RecompPos,Param); + PUTDST32(m_RecompPos,Const); +} + +void CX86Ops::MoveN64MemDispToX86reg(x86Reg reg, x86Reg AddrReg, uint8_t Disp) +{ + uint16_t x86Command = 0; + + CPU_Message(" mov %s, dword ptr [%s+N64mem+%Xh]",x86_Name(reg),x86_Name(AddrReg),Disp); + switch (AddrReg) + { + case x86_EAX: x86Command = 0x008B; break; + case x86_EBX: x86Command = 0x038B; break; + case x86_ECX: x86Command = 0x018B; break; + case x86_EDX: x86Command = 0x028B; break; + case x86_ESI: x86Command = 0x068B; break; + case x86_EDI: x86Command = 0x078B; break; + case x86_ESP: x86Command = 0x048B; break; + case x86_EBP: x86Command = 0x058B; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + switch (reg) + { + case x86_EAX: x86Command += 0x8000; break; + case x86_EBX: x86Command += 0x9800; break; + case x86_ECX: x86Command += 0x8800; break; + case x86_EDX: x86Command += 0x9000; break; + case x86_ESI: x86Command += 0xB000; break; + case x86_EDI: x86Command += 0xB800; break; + case x86_ESP: x86Command += 0xA000; break; + case x86_EBP: x86Command += 0xA800; break; + } + PUTDST16(m_RecompPos,x86Command); + PUTDST32(m_RecompPos,g_MMU->Rdram() + Disp); +} + +void CX86Ops::MoveN64MemToX86reg(x86Reg reg, x86Reg AddrReg) +{ + uint16_t x86Command = 0; + + CPU_Message(" mov %s, dword ptr [%s+N64mem]",x86_Name(reg),x86_Name(AddrReg)); + + switch (AddrReg) + { + case x86_EAX: x86Command = 0x008B; break; + case x86_EBX: x86Command = 0x038B; break; + case x86_ECX: x86Command = 0x018B; break; + case x86_EDX: x86Command = 0x028B; break; + case x86_ESI: x86Command = 0x068B; break; + case x86_EDI: x86Command = 0x078B; break; + case x86_ESP: x86Command = 0x048B; break; + case x86_EBP: x86Command = 0x058B; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + switch (reg) + { + case x86_EAX: x86Command += 0x8000; break; + case x86_EBX: x86Command += 0x9800; break; + case x86_ECX: x86Command += 0x8800; break; + case x86_EDX: x86Command += 0x9000; break; + case x86_ESI: x86Command += 0xB000; break; + case x86_EDI: x86Command += 0xB800; break; + case x86_ESP: x86Command += 0xA000; break; + case x86_EBP: x86Command += 0xA800; break; + } + PUTDST16(m_RecompPos,x86Command); + PUTDST32(m_RecompPos,g_MMU->Rdram()); +} + +void CX86Ops::MoveN64MemToX86regByte(x86Reg reg, x86Reg AddrReg) +{ + uint16_t x86Command = 0; + + CPU_Message(" mov %s, byte ptr [%s+N64mem]",x86_ByteName(reg),x86_Name(AddrReg)); + switch (AddrReg) + { + case x86_EAX: x86Command = 0x008A; break; + case x86_EBX: x86Command = 0x038A; break; + case x86_ECX: x86Command = 0x018A; break; + case x86_EDX: x86Command = 0x028A; break; + case x86_ESI: x86Command = 0x068A; break; + case x86_EDI: x86Command = 0x078A; break; + case x86_ESP: x86Command = 0x048A; break; + case x86_EBP: x86Command = 0x058A; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + switch (reg) + { + case x86_EAX: x86Command += 0x8000; break; + case x86_EBX: x86Command += 0x9800; break; + case x86_ECX: x86Command += 0x8800; break; + case x86_EDX: x86Command += 0x9000; break; + /* case x86_ESI: x86Command += 0xB000; break; */ + /* case x86_EDI: x86Command += 0xB800; break; */ + /* case x86_ESP: case x86_EBP: */ + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } + PUTDST16(m_RecompPos,x86Command); + PUTDST32(m_RecompPos,g_MMU->Rdram()); +} + +void CX86Ops::MoveN64MemToX86regHalf(x86Reg reg, x86Reg AddrReg) +{ + uint16_t x86Command = 0; + + CPU_Message(" mov %s, word ptr [%s+N64mem]",x86_HalfName(reg),x86_Name(AddrReg)); + + PUTDST8(m_RecompPos,0x66); + switch (AddrReg) + { + case x86_EAX: x86Command = 0x008B; break; + case x86_EBX: x86Command = 0x038B; break; + case x86_ECX: x86Command = 0x018B; break; + case x86_EDX: x86Command = 0x028B; break; + case x86_ESI: x86Command = 0x068B; break; + case x86_EDI: x86Command = 0x078B; break; + case x86_ESP: x86Command = 0x048B; break; + case x86_EBP: x86Command = 0x058B; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + switch (reg) + { + case x86_EAX: x86Command += 0x8000; break; + case x86_EBX: x86Command += 0x9800; break; + case x86_ECX: x86Command += 0x8800; break; + case x86_EDX: x86Command += 0x9000; break; + case x86_ESI: x86Command += 0xB000; break; + case x86_EDI: x86Command += 0xB800; break; + case x86_ESP: x86Command += 0xA000; break; + case x86_EBP: x86Command += 0xA800; break; + } + PUTDST16(m_RecompPos,x86Command); + PUTDST32(m_RecompPos,g_MMU->Rdram()); +} + +void CX86Ops::MoveSxByteX86regPointerToX86reg(x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg) +{ + uint8_t Param = 0; + + CPU_Message(" movsx %s, byte ptr [%s+%s]",x86_Name(reg),x86_Name(AddrReg1), x86_Name(AddrReg2)); + + PUTDST16(m_RecompPos,0xBE0F); + switch (reg) + { + case x86_EAX: PUTDST8(m_RecompPos,0x04); break; + case x86_EBX: PUTDST8(m_RecompPos,0x1C); break; + case x86_ECX: PUTDST8(m_RecompPos,0x0C); break; + case x86_EDX: PUTDST8(m_RecompPos,0x14); break; + case x86_ESI: PUTDST8(m_RecompPos,0x34); break; + case x86_EDI: PUTDST8(m_RecompPos,0x3C); break; + case x86_ESP: PUTDST8(m_RecompPos,0x24); break; + case x86_EBP: PUTDST8(m_RecompPos,0x2C); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (AddrReg1) + { + case x86_EAX: Param = 0x00; break; + case x86_EBX: Param = 0x03; break; + case x86_ECX: Param = 0x01; break; + case x86_EDX: Param = 0x02; break; + case x86_ESI: Param = 0x06; break; + case x86_EDI: Param = 0x07; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (AddrReg2) + { + case x86_EAX: Param += 0x00; break; + case x86_EBX: Param += 0x18; break; + case x86_ECX: Param += 0x08; break; + case x86_EDX: Param += 0x10; break; + case x86_ESI: Param += 0x30; break; + case x86_EDI: Param += 0x38; break; + case x86_ESP: Param += 0x20; break; + case x86_EBP: Param += 0x28; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST8(m_RecompPos,Param); +} + +void CX86Ops::MoveSxHalfX86regPointerToX86reg(x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg) +{ + uint8_t Param = 0; + + CPU_Message(" movsx %s, word ptr [%s+%s]",x86_Name(reg),x86_Name(AddrReg1), x86_Name(AddrReg2)); + + PUTDST16(m_RecompPos,0xBF0F); + switch (reg) + { + case x86_EAX: PUTDST8(m_RecompPos,0x04); break; + case x86_EBX: PUTDST8(m_RecompPos,0x1C); break; + case x86_ECX: PUTDST8(m_RecompPos,0x0C); break; + case x86_EDX: PUTDST8(m_RecompPos,0x14); break; + case x86_ESI: PUTDST8(m_RecompPos,0x34); break; + case x86_EDI: PUTDST8(m_RecompPos,0x3C); break; + case x86_ESP: PUTDST8(m_RecompPos,0x24); break; + case x86_EBP: PUTDST8(m_RecompPos,0x2C); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (AddrReg1) + { + case x86_EAX: Param = 0x00; break; + case x86_EBX: Param = 0x03; break; + case x86_ECX: Param = 0x01; break; + case x86_EDX: Param = 0x02; break; + case x86_ESI: Param = 0x06; break; + case x86_EDI: Param = 0x07; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (AddrReg2) + { + case x86_EAX: Param += 0x00; break; + case x86_EBX: Param += 0x18; break; + case x86_ECX: Param += 0x08; break; + case x86_EDX: Param += 0x10; break; + case x86_ESI: Param += 0x30; break; + case x86_EDI: Param += 0x38; break; + case x86_ESP: Param += 0x20; break; + case x86_EBP: Param += 0x28; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST8(m_RecompPos,Param); +} + +void CX86Ops::MoveSxN64MemToX86regByte(x86Reg reg, x86Reg AddrReg) +{ + uint16_t x86Command = 0; + + CPU_Message(" movsx %s, byte ptr [%s+Dmem]",x86_Name(reg),x86_Name(AddrReg)); + switch (AddrReg) + { + case x86_EAX: x86Command = 0x00BE; break; + case x86_EBX: x86Command = 0x03BE; break; + case x86_ECX: x86Command = 0x01BE; break; + case x86_EDX: x86Command = 0x02BE; break; + case x86_ESI: x86Command = 0x06BE; break; + case x86_EDI: x86Command = 0x07BE; break; + case x86_ESP: x86Command = 0x04BE; break; + case x86_EBP: x86Command = 0x05BE; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + switch (reg) + { + case x86_EAX: x86Command += 0x8000; break; + case x86_EBX: x86Command += 0x9800; break; + case x86_ECX: x86Command += 0x8800; break; + case x86_EDX: x86Command += 0x9000; break; + case x86_ESI: x86Command += 0xB000; break; + case x86_EDI: x86Command += 0xB800; break; + case x86_ESP: x86Command += 0xA000; break; + case x86_EBP: x86Command += 0xA800; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } + PUTDST8(m_RecompPos,0x0f); + PUTDST16(m_RecompPos,x86Command); + PUTDST32(m_RecompPos,g_MMU->Rdram()); +} + +void CX86Ops::MoveSxN64MemToX86regHalf(x86Reg reg, x86Reg AddrReg) +{ + uint16_t x86Command = 0; + + CPU_Message(" movsx %s, word ptr [%s+Dmem]",x86_Name(reg),x86_Name(AddrReg)); + + switch (AddrReg) + { + case x86_EAX: x86Command = 0x00BF; break; + case x86_EBX: x86Command = 0x03BF; break; + case x86_ECX: x86Command = 0x01BF; break; + case x86_EDX: x86Command = 0x02BF; break; + case x86_ESI: x86Command = 0x06BF; break; + case x86_EDI: x86Command = 0x07BF; break; + case x86_ESP: x86Command = 0x04BF; break; + case x86_EBP: x86Command = 0x05BF; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + switch (reg) + { + case x86_EAX: x86Command += 0x8000; break; + case x86_EBX: x86Command += 0x9800; break; + case x86_ECX: x86Command += 0x8800; break; + case x86_EDX: x86Command += 0x9000; break; + case x86_ESI: x86Command += 0xB000; break; + case x86_EDI: x86Command += 0xB800; break; + case x86_ESP: x86Command += 0xA000; break; + case x86_EBP: x86Command += 0xA800; break; + } + + PUTDST8(m_RecompPos, 0x0f); + PUTDST16(m_RecompPos,x86Command); + PUTDST32(m_RecompPos,g_MMU->Rdram()); +} + +void CX86Ops::MoveSxVariableToX86regByte(void *Variable, const char * VariableName, x86Reg reg) +{ + CPU_Message(" movsx %s, byte ptr [%s]",x86_Name(reg),VariableName); + + PUTDST16(m_RecompPos, 0xbe0f); + + switch (reg) + { + case x86_EAX: PUTDST8(m_RecompPos,0x05); break; + case x86_EBX: PUTDST8(m_RecompPos,0x1D); break; + case x86_ECX: PUTDST8(m_RecompPos,0x0D); break; + case x86_EDX: PUTDST8(m_RecompPos,0x15); break; + case x86_ESI: PUTDST8(m_RecompPos,0x35); break; + case x86_EDI: PUTDST8(m_RecompPos,0x3D); break; + case x86_ESP: PUTDST8(m_RecompPos,0x25); break; + case x86_EBP: PUTDST8(m_RecompPos,0x2D); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::MoveSxVariableToX86regHalf(void *Variable, const char * VariableName, x86Reg reg) +{ + CPU_Message(" movsx %s, word ptr [%s]",x86_Name(reg),VariableName); + + PUTDST16(m_RecompPos, 0xbf0f); + + switch (reg) + { + case x86_EAX: PUTDST8(m_RecompPos,0x05); break; + case x86_EBX: PUTDST8(m_RecompPos,0x1D); break; + case x86_ECX: PUTDST8(m_RecompPos,0x0D); break; + case x86_EDX: PUTDST8(m_RecompPos,0x15); break; + case x86_ESI: PUTDST8(m_RecompPos,0x35); break; + case x86_EDI: PUTDST8(m_RecompPos,0x3D); break; + case x86_ESP: PUTDST8(m_RecompPos,0x25); break; + case x86_EBP: PUTDST8(m_RecompPos,0x2D); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::MoveVariableToX86reg(void *Variable, const char * VariableName, x86Reg reg) +{ + CPU_Message(" mov %s, dword ptr [%s]",x86_Name(reg),VariableName); + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x058B); break; + case x86_EBX: PUTDST16(m_RecompPos,0x1D8B); break; + case x86_ECX: PUTDST16(m_RecompPos,0x0D8B); break; + case x86_EDX: PUTDST16(m_RecompPos,0x158B); break; + case x86_ESI: PUTDST16(m_RecompPos,0x358B); break; + case x86_EDI: PUTDST16(m_RecompPos,0x3D8B); break; + case x86_ESP: PUTDST16(m_RecompPos,0x258B); break; + case x86_EBP: PUTDST16(m_RecompPos,0x2D8B); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::MoveVariableDispToX86Reg(void *Variable, const char * VariableName, x86Reg reg, x86Reg AddrReg, int Multiplier) +{ + int x = 0; + CPU_Message(" mov %s, dword ptr [%s+%s*%i]",x86_Name(reg),VariableName, x86_Name(AddrReg), Multiplier); + + PUTDST8(m_RecompPos,0x8B); + + switch (reg) + { + case x86_EAX: PUTDST8(m_RecompPos,0x04); break; + case x86_EBX: PUTDST8(m_RecompPos,0x1C); break; + case x86_ECX: PUTDST8(m_RecompPos,0x0C); break; + case x86_EDX: PUTDST8(m_RecompPos,0x14); break; + case x86_ESI: PUTDST8(m_RecompPos,0x34); break; + case x86_EDI: PUTDST8(m_RecompPos,0x3C); break; + case x86_ESP: PUTDST8(m_RecompPos,0x24); break; + case x86_EBP: PUTDST8(m_RecompPos,0x2C); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + /* put in shifter 2(01), 4(10), 8(11) */ + switch (Multiplier) + { + case 1: x = 0; break; + case 2: x = 0x40; break; + case 4: x = 0x80; break; + case 8: x = 0xC0; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + /* format xx|000000 */ + switch (AddrReg) + { + case x86_EAX: PUTDST8(m_RecompPos,0x05|x); break; + case x86_EBX: PUTDST8(m_RecompPos,0x1D|x); break; + case x86_ECX: PUTDST8(m_RecompPos,0x0D|x); break; + case x86_EDX: PUTDST8(m_RecompPos,0x15|x); break; + case x86_ESI: PUTDST8(m_RecompPos,0x35|x); break; + case x86_EDI: PUTDST8(m_RecompPos,0x3D|x); break; + case x86_ESP: PUTDST8(m_RecompPos,0x25|x); break; + case x86_EBP: PUTDST8(m_RecompPos,0x2D|x); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::MoveVariableToX86regByte(void *Variable, const char * VariableName, x86Reg reg) +{ + CPU_Message(" mov %s, byte ptr [%s]",x86_ByteName(reg),VariableName); + + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x058A); break; + case x86_EBX: PUTDST16(m_RecompPos,0x1D8A); break; + case x86_ECX: PUTDST16(m_RecompPos,0x0D8A); break; + case x86_EDX: PUTDST16(m_RecompPos,0x158A); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::MoveVariableToX86regHalf(void *Variable, const char * VariableName, x86Reg reg) +{ + CPU_Message(" mov %s, word ptr [%s]",x86_HalfName(reg),VariableName); + + PUTDST8(m_RecompPos,0x66); + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x058B); break; + case x86_EBX: PUTDST16(m_RecompPos,0x1D8B); break; + case x86_ECX: PUTDST16(m_RecompPos,0x0D8B); break; + case x86_EDX: PUTDST16(m_RecompPos,0x158B); break; + case x86_ESI: PUTDST16(m_RecompPos,0x358B); break; + case x86_EDI: PUTDST16(m_RecompPos,0x3D8B); break; + case x86_ESP: PUTDST16(m_RecompPos,0x258B); break; + case x86_EBP: PUTDST16(m_RecompPos,0x2D8B); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::MoveX86regByteToN64Mem(x86Reg reg, x86Reg AddrReg) +{ + uint16_t x86Command = 0; + + CPU_Message(" mov byte ptr [%s+N64mem], %s",x86_Name(AddrReg),x86_ByteName(reg)); + + switch (AddrReg) + { + case x86_EAX: x86Command = 0x0088; break; + case x86_EBX: x86Command = 0x0388; break; + case x86_ECX: x86Command = 0x0188; break; + case x86_EDX: x86Command = 0x0288; break; + case x86_ESI: x86Command = 0x0688; break; + case x86_EDI: x86Command = 0x0788; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (reg) + { + case x86_EAX: x86Command += 0x8000; break; + case x86_EBX: x86Command += 0x9800; break; + case x86_ECX: x86Command += 0x8800; break; + case x86_EDX: x86Command += 0x9000; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST16(m_RecompPos,x86Command); + PUTDST32(m_RecompPos,g_MMU->Rdram()); +} + +void CX86Ops::MoveX86regByteToVariable(x86Reg reg, void * Variable, const char * VariableName) +{ + CPU_Message(" mov byte ptr [%s], %s",VariableName,x86_ByteName(reg)); + + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x0588); break; + case x86_EBX: PUTDST16(m_RecompPos,0x1D88); break; + case x86_ECX: PUTDST16(m_RecompPos,0x0D88); break; + case x86_EDX: PUTDST16(m_RecompPos,0x1588); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::MoveX86regByteToX86regPointer(x86Reg reg, x86Reg AddrReg1, x86Reg AddrReg2) +{ + uint8_t Param = 0; + + CPU_Message(" mov byte ptr [%s+%s],%s",x86_Name(AddrReg1), x86_Name(AddrReg2), x86_ByteName(reg)); + + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x0488); break; + case x86_EBX: PUTDST16(m_RecompPos,0x1C88); break; + case x86_ECX: PUTDST16(m_RecompPos,0x0C88); break; + case x86_EDX: PUTDST16(m_RecompPos,0x1488); break; + case x86_ESI: PUTDST16(m_RecompPos,0x3488); break; + case x86_EDI: PUTDST16(m_RecompPos,0x3C88); break; + case x86_ESP: PUTDST16(m_RecompPos,0x2488); break; + case x86_EBP: PUTDST16(m_RecompPos,0x2C88); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (AddrReg1) + { + case x86_EAX: Param = 0x00; break; + case x86_EBX: Param = 0x03; break; + case x86_ECX: Param = 0x01; break; + case x86_EDX: Param = 0x02; break; + case x86_ESI: Param = 0x06; break; + case x86_EDI: Param = 0x07; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (AddrReg2) + { + case x86_EAX: Param += 0x00; break; + case x86_EBX: Param += 0x18; break; + case x86_ECX: Param += 0x08; break; + case x86_EDX: Param += 0x10; break; + case x86_ESI: Param += 0x30; break; + case x86_EDI: Param += 0x38; break; + case x86_ESP: Param += 0x20; break; + case x86_EBP: Param += 0x28; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST8(m_RecompPos,Param); +} + +void CX86Ops::MoveX86regHalfToN64Mem(x86Reg reg, x86Reg AddrReg) +{ + uint16_t x86Command = 0; + + CPU_Message(" mov word ptr [%s+N64mem], %s",x86_Name(AddrReg),x86_HalfName(reg)); + + PUTDST8(m_RecompPos,0x66); + switch (AddrReg) + { + case x86_EAX: x86Command = 0x0089; break; + case x86_EBX: x86Command = 0x0389; break; + case x86_ECX: x86Command = 0x0189; break; + case x86_EDX: x86Command = 0x0289; break; + case x86_ESI: x86Command = 0x0689; break; + case x86_EDI: x86Command = 0x0789; break; + case x86_ESP: x86Command = 0x0489; break; + case x86_EBP: x86Command = 0x0589; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + switch (reg) + { + case x86_EAX: x86Command += 0x8000; break; + case x86_EBX: x86Command += 0x9800; break; + case x86_ECX: x86Command += 0x8800; break; + case x86_EDX: x86Command += 0x9000; break; + case x86_ESI: x86Command += 0xB000; break; + case x86_EDI: x86Command += 0xB800; break; + case x86_ESP: x86Command += 0xA000; break; + case x86_EBP: x86Command += 0xA800; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST16(m_RecompPos,x86Command); + PUTDST32(m_RecompPos,g_MMU->Rdram()); +} + +void CX86Ops::MoveX86regHalfToVariable(x86Reg reg, void * Variable, const char * VariableName) +{ + CPU_Message(" mov word ptr [%s], %s",VariableName,x86_HalfName(reg)); + PUTDST8(m_RecompPos,0x66); + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x0589); break; + case x86_EBX: PUTDST16(m_RecompPos,0x1D89); break; + case x86_ECX: PUTDST16(m_RecompPos,0x0D89); break; + case x86_EDX: PUTDST16(m_RecompPos,0x1589); break; + case x86_ESI: PUTDST16(m_RecompPos,0x3589); break; + case x86_EDI: PUTDST16(m_RecompPos,0x3D89); break; + case x86_ESP: PUTDST16(m_RecompPos,0x2589); break; + case x86_EBP: PUTDST16(m_RecompPos,0x2D89); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::MoveX86regHalfToX86regPointer(x86Reg reg, x86Reg AddrReg1, x86Reg AddrReg2) +{ + uint8_t Param = 0; + + CPU_Message(" mov word ptr [%s+%s],%s",x86_Name(AddrReg1), x86_Name(AddrReg2), x86_HalfName(reg)); + + PUTDST8(m_RecompPos,0x66); + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x0489); break; + case x86_EBX: PUTDST16(m_RecompPos,0x1C89); break; + case x86_ECX: PUTDST16(m_RecompPos,0x0C89); break; + case x86_EDX: PUTDST16(m_RecompPos,0x1489); break; + case x86_ESI: PUTDST16(m_RecompPos,0x3489); break; + case x86_EDI: PUTDST16(m_RecompPos,0x3C89); break; + case x86_ESP: PUTDST16(m_RecompPos,0x2489); break; + case x86_EBP: PUTDST16(m_RecompPos,0x2C89); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (AddrReg1) + { + case x86_EAX: Param = 0x00; break; + case x86_EBX: Param = 0x03; break; + case x86_ECX: Param = 0x01; break; + case x86_EDX: Param = 0x02; break; + case x86_ESI: Param = 0x06; break; + case x86_EDI: Param = 0x07; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (AddrReg2) + { + case x86_EAX: Param += 0x00; break; + case x86_EBX: Param += 0x18; break; + case x86_ECX: Param += 0x08; break; + case x86_EDX: Param += 0x10; break; + case x86_ESI: Param += 0x30; break; + case x86_EDI: Param += 0x38; break; + case x86_ESP: Param += 0x20; break; + case x86_EBP: Param += 0x28; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST8(m_RecompPos,Param); +} + +void CX86Ops::MoveX86PointerToX86reg(x86Reg reg, x86Reg X86Pointer) +{ + uint16_t x86Command = 0; + + CPU_Message(" mov %s, dword ptr [%s]",x86_Name(reg),x86_Name(X86Pointer)); + + switch (X86Pointer) + { + case x86_EAX: x86Command = 0x008B; break; + case x86_EBX: x86Command = 0x038B; break; + case x86_ECX: x86Command = 0x018B; break; + case x86_EDX: x86Command = 0x028B; break; + case x86_ESI: x86Command = 0x068B; break; + case x86_EDI: x86Command = 0x078B; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (reg) + { + case x86_EAX: x86Command += 0x0000; break; + case x86_EBX: x86Command += 0x1800; break; + case x86_ECX: x86Command += 0x0800; break; + case x86_EDX: x86Command += 0x1000; break; + case x86_ESI: x86Command += 0x3000; break; + case x86_EDI: x86Command += 0x3800; break; + case x86_ESP: x86Command += 0x2000; break; + case x86_EBP: x86Command += 0x2800; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST16(m_RecompPos,x86Command); +} + +void CX86Ops::MoveX86PointerToX86regDisp(x86Reg reg, x86Reg X86Pointer, uint8_t Disp) +{ + uint16_t x86Command = 0; + + CPU_Message(" mov %s, dword ptr [%s] + %d",x86_Name(reg),x86_Name(X86Pointer),Disp); + + switch (X86Pointer) + { + case x86_EAX: x86Command = 0x408B; break; + case x86_EBX: x86Command = 0x438B; break; + case x86_ECX: x86Command = 0x418B; break; + case x86_EDX: x86Command = 0x428B; break; + case x86_ESI: x86Command = 0x468B; break; + case x86_EDI: x86Command = 0x478B; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (reg) + { + case x86_EAX: x86Command += 0x0000; break; + case x86_EBX: x86Command += 0x1800; break; + case x86_ECX: x86Command += 0x0800; break; + case x86_EDX: x86Command += 0x1000; break; + case x86_ESI: x86Command += 0x3000; break; + case x86_EDI: x86Command += 0x3800; break; + case x86_ESP: x86Command += 0x2000; break; + case x86_EBP: x86Command += 0x2800; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST16(m_RecompPos,x86Command); + PUTDST8(m_RecompPos,Disp); +} + +void CX86Ops::MoveX86regPointerToX86reg(x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg) +{ + uint8_t Param = 0; + + CPU_Message(" mov %s, dword ptr [%s+%s]",x86_Name(reg),x86_Name(AddrReg1), x86_Name(AddrReg2)); + + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x048B); break; + case x86_EBX: PUTDST16(m_RecompPos,0x1C8B); break; + case x86_ECX: PUTDST16(m_RecompPos,0x0C8B); break; + case x86_EDX: PUTDST16(m_RecompPos,0x148B); break; + case x86_ESI: PUTDST16(m_RecompPos,0x348B); break; + case x86_EDI: PUTDST16(m_RecompPos,0x3C8B); break; + case x86_ESP: PUTDST16(m_RecompPos,0x248B); break; + case x86_EBP: PUTDST16(m_RecompPos,0x2C8B); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (AddrReg1) + { + case x86_EAX: Param = 0x00; break; + case x86_EBX: Param = 0x03; break; + case x86_ECX: Param = 0x01; break; + case x86_EDX: Param = 0x02; break; + case x86_ESI: Param = 0x06; break; + case x86_EDI: Param = 0x07; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (AddrReg2) + { + case x86_EAX: Param += 0x00; break; + case x86_EBX: Param += 0x18; break; + case x86_ECX: Param += 0x08; break; + case x86_EDX: Param += 0x10; break; + case x86_ESI: Param += 0x30; break; + case x86_EDI: Param += 0x38; break; + case x86_ESP: Param += 0x20; break; + case x86_EBP: Param += 0x28; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST8(m_RecompPos,Param); +} + +void CX86Ops::MoveX86regPointerToX86regDisp8(x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg, uint8_t offset) +{ + uint8_t Param = 0; + + CPU_Message(" mov %s, dword ptr [%s+%s]",x86_Name(reg),x86_Name(AddrReg1), x86_Name(AddrReg2)); + + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x448B); break; + case x86_EBX: PUTDST16(m_RecompPos,0x5C8B); break; + case x86_ECX: PUTDST16(m_RecompPos,0x4C8B); break; + case x86_EDX: PUTDST16(m_RecompPos,0x548B); break; + case x86_ESI: PUTDST16(m_RecompPos,0x748B); break; + case x86_EDI: PUTDST16(m_RecompPos,0x7C8B); break; + case x86_ESP: PUTDST16(m_RecompPos,0x648B); break; + case x86_EBP: PUTDST16(m_RecompPos,0x6C8B); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (AddrReg1) + { + case x86_EAX: Param = 0x00; break; + case x86_EBX: Param = 0x03; break; + case x86_ECX: Param = 0x01; break; + case x86_EDX: Param = 0x02; break; + case x86_ESI: Param = 0x06; break; + case x86_EDI: Param = 0x07; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (AddrReg2) + { + case x86_EAX: Param += 0x00; break; + case x86_EBX: Param += 0x18; break; + case x86_ECX: Param += 0x08; break; + case x86_EDX: Param += 0x10; break; + case x86_ESI: Param += 0x30; break; + case x86_EDI: Param += 0x38; break; + case x86_ESP: Param += 0x20; break; + case x86_EBP: Param += 0x28; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST8(m_RecompPos,Param); + PUTDST8(m_RecompPos,offset); +} + +void CX86Ops::MoveX86regToMemory(x86Reg reg, x86Reg AddrReg, uint32_t Disp) +{ + uint16_t x86Command = 0; + + CPU_Message(" mov dword ptr [%s+%X], %s",x86_Name(AddrReg),Disp,x86_Name(reg)); + switch (AddrReg) + { + case x86_EAX: x86Command = 0x0089; break; + case x86_EBX: x86Command = 0x0389; break; + case x86_ECX: x86Command = 0x0189; break; + case x86_EDX: x86Command = 0x0289; break; + case x86_ESI: x86Command = 0x0689; break; + case x86_EDI: x86Command = 0x0789; break; + case x86_ESP: x86Command = 0x0489; break; + case x86_EBP: x86Command = 0x0589; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + switch (reg) + { + case x86_EAX: x86Command += 0x8000; break; + case x86_EBX: x86Command += 0x9800; break; + case x86_ECX: x86Command += 0x8800; break; + case x86_EDX: x86Command += 0x9000; break; + case x86_ESI: x86Command += 0xB000; break; + case x86_EDI: x86Command += 0xB800; break; + case x86_ESP: x86Command += 0xA000; break; + case x86_EBP: x86Command += 0xA800; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST16(m_RecompPos,x86Command); + PUTDST32(m_RecompPos,Disp); +} + +void CX86Ops::MoveX86regToN64Mem(x86Reg reg, x86Reg AddrReg) +{ + uint16_t x86Command = 0; + + CPU_Message(" mov dword ptr [%s+N64mem], %s",x86_Name(AddrReg),x86_Name(reg)); + switch (AddrReg) + { + case x86_EAX: x86Command = 0x0089; break; + case x86_EBX: x86Command = 0x0389; break; + case x86_ECX: x86Command = 0x0189; break; + case x86_EDX: x86Command = 0x0289; break; + case x86_ESI: x86Command = 0x0689; break; + case x86_EDI: x86Command = 0x0789; break; + case x86_ESP: x86Command = 0x0489; break; + case x86_EBP: x86Command = 0x0589; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + switch (reg) + { + case x86_EAX: x86Command += 0x8000; break; + case x86_EBX: x86Command += 0x9800; break; + case x86_ECX: x86Command += 0x8800; break; + case x86_EDX: x86Command += 0x9000; break; + case x86_ESI: x86Command += 0xB000; break; + case x86_EDI: x86Command += 0xB800; break; + case x86_ESP: x86Command += 0xA000; break; + case x86_EBP: x86Command += 0xA800; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST16(m_RecompPos,x86Command); + PUTDST32(m_RecompPos,g_MMU->Rdram()); +} + +void CX86Ops::MoveX86regToN64MemDisp(x86Reg reg, x86Reg AddrReg, uint8_t Disp) +{ + CPU_Message(" mov dword ptr [%s+N64mem+%d], %s",x86_Name(AddrReg),Disp,x86_Name(reg)); + uint16_t x86Command = 0; + + switch (AddrReg) + { + case x86_EAX: x86Command = 0x0089; break; + case x86_EBX: x86Command = 0x0389; break; + case x86_ECX: x86Command = 0x0189; break; + case x86_EDX: x86Command = 0x0289; break; + case x86_ESI: x86Command = 0x0689; break; + case x86_EDI: x86Command = 0x0789; break; + case x86_ESP: x86Command = 0x0489; break; + case x86_EBP: x86Command = 0x0589; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + switch (reg) + { + case x86_EAX: x86Command += 0x8000; break; + case x86_EBX: x86Command += 0x9800; break; + case x86_ECX: x86Command += 0x8800; break; + case x86_EDX: x86Command += 0x9000; break; + case x86_ESI: x86Command += 0xB000; break; + case x86_EDI: x86Command += 0xB800; break; + case x86_ESP: x86Command += 0xA000; break; + case x86_EBP: x86Command += 0xA800; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST16(m_RecompPos,x86Command); + PUTDST32(m_RecompPos,g_MMU->Rdram()+Disp); +} + +void CX86Ops::MoveX86regToVariable(x86Reg reg, void * Variable, const char * VariableName) +{ + CPU_Message(" mov dword ptr [%s], %s",VariableName,x86_Name(reg)); + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x0589); break; + case x86_EBX: PUTDST16(m_RecompPos,0x1D89); break; + case x86_ECX: PUTDST16(m_RecompPos,0x0D89); break; + case x86_EDX: PUTDST16(m_RecompPos,0x1589); break; + case x86_ESI: PUTDST16(m_RecompPos,0x3589); break; + case x86_EDI: PUTDST16(m_RecompPos,0x3D89); break; + case x86_ESP: PUTDST16(m_RecompPos,0x2589); break; + case x86_EBP: PUTDST16(m_RecompPos,0x2D89); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::MoveX86RegToX86Reg(x86Reg Source, x86Reg Destination) +{ + uint16_t x86Command = 0; + + if (Source == Destination) + { + return; + } + CPU_Message(" mov %s, %s",x86_Name(Destination),x86_Name(Source)); + + switch (Destination) + { + case x86_EAX: x86Command = 0x0089; break; + case x86_EBX: x86Command = 0x0389; break; + case x86_ECX: x86Command = 0x0189; break; + case x86_EDX: x86Command = 0x0289; break; + case x86_ESI: x86Command = 0x0689; break; + case x86_EDI: x86Command = 0x0789; break; + case x86_ESP: x86Command = 0x0489; break; + case x86_EBP: x86Command = 0x0589; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (Source) + { + case x86_EAX: x86Command += 0xC000; break; + case x86_EBX: x86Command += 0xD800; break; + case x86_ECX: x86Command += 0xC800; break; + case x86_EDX: x86Command += 0xD000; break; + case x86_ESI: x86Command += 0xF000; break; + case x86_EDI: x86Command += 0xF800; break; + case x86_ESP: x86Command += 0xE000; break; + case x86_EBP: x86Command += 0xE800; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST16(m_RecompPos,x86Command); +} + +void CX86Ops::MoveX86regToX86Pointer(x86Reg reg, x86Reg X86Pointer) +{ + uint16_t x86Command = 0; + + CPU_Message(" mov dword ptr [%s], %s",x86_Name(X86Pointer),x86_Name(reg)); + + switch (X86Pointer) + { + case x86_EAX: x86Command = 0x0089; break; + case x86_EBX: x86Command = 0x0389; break; + case x86_ECX: x86Command = 0x0189; break; + case x86_EDX: x86Command = 0x0289; break; + case x86_ESI: x86Command = 0x0689; break; + case x86_EDI: x86Command = 0x0789; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (reg) + { + case x86_EAX: x86Command += 0x0000; break; + case x86_EBX: x86Command += 0x1800; break; + case x86_ECX: x86Command += 0x0800; break; + case x86_EDX: x86Command += 0x1000; break; + case x86_ESI: x86Command += 0x3000; break; + case x86_EDI: x86Command += 0x3800; break; + case x86_ESP: x86Command += 0x2000; break; + case x86_EBP: x86Command += 0x2800; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST16(m_RecompPos,x86Command); +} + +void CX86Ops::MoveX86regToX86regPointer(x86Reg reg, x86Reg AddrReg1, x86Reg AddrReg2) +{ + uint8_t Param = 0; + + CPU_Message(" mov dword ptr [%s+%s],%s",x86_Name(AddrReg1), x86_Name(AddrReg2), x86_Name(reg)); + + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x0489); break; + case x86_EBX: PUTDST16(m_RecompPos,0x1C89); break; + case x86_ECX: PUTDST16(m_RecompPos,0x0C89); break; + case x86_EDX: PUTDST16(m_RecompPos,0x1489); break; + case x86_ESI: PUTDST16(m_RecompPos,0x3489); break; + case x86_EDI: PUTDST16(m_RecompPos,0x3C89); break; + case x86_ESP: PUTDST16(m_RecompPos,0x2489); break; + case x86_EBP: PUTDST16(m_RecompPos,0x2C89); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (AddrReg1) + { + case x86_EAX: Param = 0x00; break; + case x86_EBX: Param = 0x03; break; + case x86_ECX: Param = 0x01; break; + case x86_EDX: Param = 0x02; break; + case x86_ESI: Param = 0x06; break; + case x86_EDI: Param = 0x07; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (AddrReg2) + { + case x86_EAX: Param += 0x00; break; + case x86_EBX: Param += 0x18; break; + case x86_ECX: Param += 0x08; break; + case x86_EDX: Param += 0x10; break; + case x86_ESI: Param += 0x30; break; + case x86_EDI: Param += 0x38; break; + case x86_ESP: Param += 0x20; break; + case x86_EBP: Param += 0x28; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST8(m_RecompPos,Param); +} + +void CX86Ops::MoveZxByteX86regPointerToX86reg(x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg) +{ + uint8_t Param = 0; + + CPU_Message(" movzx %s, byte ptr [%s+%s]",x86_Name(reg),x86_Name(AddrReg1), x86_Name(AddrReg2)); + + PUTDST16(m_RecompPos,0xB60F); + switch (reg) + { + case x86_EAX: PUTDST8(m_RecompPos,0x04); break; + case x86_EBX: PUTDST8(m_RecompPos,0x1C); break; + case x86_ECX: PUTDST8(m_RecompPos,0x0C); break; + case x86_EDX: PUTDST8(m_RecompPos,0x14); break; + case x86_ESI: PUTDST8(m_RecompPos,0x34); break; + case x86_EDI: PUTDST8(m_RecompPos,0x3C); break; + case x86_ESP: PUTDST8(m_RecompPos,0x24); break; + case x86_EBP: PUTDST8(m_RecompPos,0x2C); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (AddrReg1) + { + case x86_EAX: Param = 0x00; break; + case x86_EBX: Param = 0x03; break; + case x86_ECX: Param = 0x01; break; + case x86_EDX: Param = 0x02; break; + case x86_ESI: Param = 0x06; break; + case x86_EDI: Param = 0x07; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (AddrReg2) + { + case x86_EAX: Param += 0x00; break; + case x86_EBX: Param += 0x18; break; + case x86_ECX: Param += 0x08; break; + case x86_EDX: Param += 0x10; break; + case x86_ESI: Param += 0x30; break; + case x86_EDI: Param += 0x38; break; + case x86_ESP: Param += 0x20; break; + case x86_EBP: Param += 0x28; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST8(m_RecompPos,Param); +} + +void CX86Ops::MoveZxHalfX86regPointerToX86reg(x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg) +{ + uint8_t Param = 0; + + CPU_Message(" movzx %s, word ptr [%s+%s]",x86_Name(reg),x86_Name(AddrReg1), x86_Name(AddrReg2)); + + PUTDST16(m_RecompPos,0xB70F); + switch (reg) + { + case x86_EAX: PUTDST8(m_RecompPos,0x04); break; + case x86_EBX: PUTDST8(m_RecompPos,0x1C); break; + case x86_ECX: PUTDST8(m_RecompPos,0x0C); break; + case x86_EDX: PUTDST8(m_RecompPos,0x14); break; + case x86_ESI: PUTDST8(m_RecompPos,0x34); break; + case x86_EDI: PUTDST8(m_RecompPos,0x3C); break; + case x86_ESP: PUTDST8(m_RecompPos,0x24); break; + case x86_EBP: PUTDST8(m_RecompPos,0x2C); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (AddrReg1) + { + case x86_EAX: Param = 0x00; break; + case x86_EBX: Param = 0x03; break; + case x86_ECX: Param = 0x01; break; + case x86_EDX: Param = 0x02; break; + case x86_ESI: Param = 0x06; break; + case x86_EDI: Param = 0x07; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (AddrReg2) + { + case x86_EAX: Param += 0x00; break; + case x86_EBX: Param += 0x18; break; + case x86_ECX: Param += 0x08; break; + case x86_EDX: Param += 0x10; break; + case x86_ESI: Param += 0x30; break; + case x86_EDI: Param += 0x38; break; + case x86_ESP: Param += 0x20; break; + case x86_EBP: Param += 0x28; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST8(m_RecompPos,Param); +} + +void CX86Ops::MoveZxN64MemToX86regByte(x86Reg reg, x86Reg AddrReg) +{ + uint16_t x86Command = 0; + + CPU_Message(" movzx %s, byte ptr [%s+g_MMU->Rdram()]",x86_Name(reg),x86_Name(AddrReg)); + switch (AddrReg) + { + case x86_EAX: x86Command = 0x00B6; break; + case x86_EBX: x86Command = 0x03B6; break; + case x86_ECX: x86Command = 0x01B6; break; + case x86_EDX: x86Command = 0x02B6; break; + case x86_ESI: x86Command = 0x06B6; break; + case x86_EDI: x86Command = 0x07B6; break; + case x86_ESP: x86Command = 0x04B6; break; + case x86_EBP: x86Command = 0x05B6; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + switch (reg) + { + case x86_EAX: x86Command += 0x8000; break; + case x86_EBX: x86Command += 0x9800; break; + case x86_ECX: x86Command += 0x8800; break; + case x86_EDX: x86Command += 0x9000; break; + case x86_ESI: x86Command += 0xB000; break; + case x86_EDI: x86Command += 0xB800; break; + case x86_ESP: x86Command += 0xA000; break; + case x86_EBP: x86Command += 0xA800; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } + PUTDST8(m_RecompPos,0x0f); + PUTDST16(m_RecompPos,x86Command); + PUTDST32(m_RecompPos,g_MMU->Rdram()); +} + +void CX86Ops::MoveZxN64MemToX86regHalf(x86Reg reg, x86Reg AddrReg) +{ + uint16_t x86Command = 0; + + CPU_Message(" movzx %s, word ptr [%s+g_MMU->Rdram()]",x86_Name(reg),x86_Name(AddrReg)); + + switch (AddrReg) + { + case x86_EAX: x86Command = 0x00B7; break; + case x86_EBX: x86Command = 0x03B7; break; + case x86_ECX: x86Command = 0x01B7; break; + case x86_EDX: x86Command = 0x02B7; break; + case x86_ESI: x86Command = 0x06B7; break; + case x86_EDI: x86Command = 0x07B7; break; + case x86_ESP: x86Command = 0x04B7; break; + case x86_EBP: x86Command = 0x05B7; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + switch (reg) + { + case x86_EAX: x86Command += 0x8000; break; + case x86_EBX: x86Command += 0x9800; break; + case x86_ECX: x86Command += 0x8800; break; + case x86_EDX: x86Command += 0x9000; break; + case x86_ESI: x86Command += 0xB000; break; + case x86_EDI: x86Command += 0xB800; break; + case x86_ESP: x86Command += 0xA000; break; + case x86_EBP: x86Command += 0xA800; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + PUTDST8(m_RecompPos, 0x0f); + PUTDST16(m_RecompPos,x86Command); + PUTDST32(m_RecompPos,g_MMU->Rdram()); +} + +void CX86Ops::MoveZxVariableToX86regByte(void *Variable, const char * VariableName, x86Reg reg) +{ + CPU_Message(" movzx %s, byte ptr [%s]",x86_Name(reg),VariableName); + + PUTDST16(m_RecompPos, 0xb60f); + + switch (reg) + { + case x86_EAX: PUTDST8(m_RecompPos,0x05); break; + case x86_EBX: PUTDST8(m_RecompPos,0x1D); break; + case x86_ECX: PUTDST8(m_RecompPos,0x0D); break; + case x86_EDX: PUTDST8(m_RecompPos,0x15); break; + case x86_ESI: PUTDST8(m_RecompPos,0x35); break; + case x86_EDI: PUTDST8(m_RecompPos,0x3D); break; + case x86_ESP: PUTDST8(m_RecompPos,0x25); break; + case x86_EBP: PUTDST8(m_RecompPos,0x2D); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::MoveZxVariableToX86regHalf(void *Variable, const char * VariableName, x86Reg reg) +{ + CPU_Message(" movzx %s, word ptr [%s]",x86_Name(reg),VariableName); + + PUTDST16(m_RecompPos, 0xb70f); + + switch (reg) + { + case x86_EAX: PUTDST8(m_RecompPos,0x05); break; + case x86_EBX: PUTDST8(m_RecompPos,0x1D); break; + case x86_ECX: PUTDST8(m_RecompPos,0x0D); break; + case x86_EDX: PUTDST8(m_RecompPos,0x15); break; + case x86_ESI: PUTDST8(m_RecompPos,0x35); break; + case x86_EDI: PUTDST8(m_RecompPos,0x3D); break; + case x86_ESP: PUTDST8(m_RecompPos,0x25); break; + case x86_EBP: PUTDST8(m_RecompPos,0x2D); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::MulX86reg(x86Reg reg) +{ + CPU_Message(" mul %s",x86_Name(reg)); + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0xE0F7); break; + case x86_EBX: PUTDST16(m_RecompPos,0xE3F7); break; + case x86_ECX: PUTDST16(m_RecompPos,0xE1F7); break; + case x86_EDX: PUTDST16(m_RecompPos,0xE2F7); break; + case x86_ESI: PUTDST16(m_RecompPos,0xE6F7); break; + case x86_EDI: PUTDST16(m_RecompPos,0xE7F7); break; + case x86_ESP: PUTDST16(m_RecompPos,0xE4F7); break; + case x86_EBP: PUTDST16(m_RecompPos,0xE5F7); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::NotX86Reg(x86Reg reg) +{ + CPU_Message(" not %s",x86_Name(reg)); + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0xD0F7); break; + case x86_EBX: PUTDST16(m_RecompPos,0xD3F7); break; + case x86_ECX: PUTDST16(m_RecompPos,0xD1F7); break; + case x86_EDX: PUTDST16(m_RecompPos,0xD2F7); break; + case x86_ESI: PUTDST16(m_RecompPos,0xD6F7); break; + case x86_EDI: PUTDST16(m_RecompPos,0xD7F7); break; + case x86_ESP: PUTDST16(m_RecompPos,0xD4F7); break; + case x86_EBP: PUTDST16(m_RecompPos,0xD5F7); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::OrConstToVariable(uint32_t Const, void * Variable, const char * VariableName) +{ + CPU_Message(" or dword ptr [%s], 0x%X",VariableName, Const); + PUTDST16(m_RecompPos,0x0D81); + PUTDST32(m_RecompPos,Variable); + PUTDST32(m_RecompPos,Const); +} + +void CX86Ops::OrConstToX86Reg(uint32_t Const, x86Reg reg) +{ + CPU_Message(" or %s, %Xh",x86_Name(reg),Const); + if ((Const & 0xFFFFFF80) != 0 && (Const & 0xFFFFFF80) != 0xFFFFFF80) + { + switch (reg) { + case x86_EAX: PUTDST16(m_RecompPos,0xC881); break; + case x86_EBX: PUTDST16(m_RecompPos,0xCB81); break; + case x86_ECX: PUTDST16(m_RecompPos,0xC981); break; + case x86_EDX: PUTDST16(m_RecompPos,0xCA81); break; + case x86_ESI: PUTDST16(m_RecompPos,0xCE81); break; + case x86_EDI: PUTDST16(m_RecompPos,0xCF81); break; + case x86_ESP: PUTDST16(m_RecompPos,0xCC81); break; + case x86_EBP: PUTDST16(m_RecompPos,0xCD81); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos, Const); + } + else + { + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0xC883); break; + case x86_EBX: PUTDST16(m_RecompPos,0xCB83); break; + case x86_ECX: PUTDST16(m_RecompPos,0xC983); break; + case x86_EDX: PUTDST16(m_RecompPos,0xCA83); break; + case x86_ESI: PUTDST16(m_RecompPos,0xCE83); break; + case x86_EDI: PUTDST16(m_RecompPos,0xCF83); break; + case x86_ESP: PUTDST16(m_RecompPos,0xCC83); break; + case x86_EBP: PUTDST16(m_RecompPos,0xCD83); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST8(m_RecompPos, Const); + } +} + +void CX86Ops::OrVariableToX86Reg(void * Variable, const char * VariableName, x86Reg reg) +{ + CPU_Message(" or %s, dword ptr [%s]",x86_Name(reg),VariableName); + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x050B); break; + case x86_EBX: PUTDST16(m_RecompPos,0x1D0B); break; + case x86_ECX: PUTDST16(m_RecompPos,0x0D0B); break; + case x86_EDX: PUTDST16(m_RecompPos,0x150B); break; + case x86_ESI: PUTDST16(m_RecompPos,0x350B); break; + case x86_EDI: PUTDST16(m_RecompPos,0x3D0B); break; + case x86_ESP: PUTDST16(m_RecompPos,0x250B); break; + case x86_EBP: PUTDST16(m_RecompPos,0x2D0B); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::OrX86RegToVariable(void * Variable, const char * VariableName, x86Reg reg) +{ + CPU_Message(" or dword ptr [%s], %s",VariableName, x86_Name(reg)); + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x0509); break; + case x86_EBX: PUTDST16(m_RecompPos,0x1D09); break; + case x86_ECX: PUTDST16(m_RecompPos,0x0D09); break; + case x86_EDX: PUTDST16(m_RecompPos,0x1509); break; + case x86_ESI: PUTDST16(m_RecompPos,0x3509); break; + case x86_EDI: PUTDST16(m_RecompPos,0x3D09); break; + case x86_ESP: PUTDST16(m_RecompPos,0x2509); break; + case x86_EBP: PUTDST16(m_RecompPos,0x2D09); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::OrX86RegToX86Reg(x86Reg Destination, x86Reg Source) +{ + uint16_t x86Command = 0; + + CPU_Message(" or %s, %s",x86_Name(Destination),x86_Name(Source)); + switch (Source) + { + case x86_EAX: x86Command = 0x000B; break; + case x86_EBX: x86Command = 0x030B; break; + case x86_ECX: x86Command = 0x010B; break; + case x86_EDX: x86Command = 0x020B; break; + case x86_ESI: x86Command = 0x060B; break; + case x86_EDI: x86Command = 0x070B; break; + case x86_ESP: x86Command = 0x040B; break; + case x86_EBP: x86Command = 0x050B; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + switch (Destination) + { + case x86_EAX: x86Command += 0xC000; break; + case x86_EBX: x86Command += 0xD800; break; + case x86_ECX: x86Command += 0xC800; break; + case x86_EDX: x86Command += 0xD000; break; + case x86_ESI: x86Command += 0xF000; break; + case x86_EDI: x86Command += 0xF800; break; + case x86_ESP: x86Command += 0xE000; break; + case x86_EBP: x86Command += 0xE800; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST16(m_RecompPos,x86Command); +} + +void CX86Ops::Popad(void) +{ + CPU_Message(" popad"); + PUTDST8(m_RecompPos,0x61); +} + +void CX86Ops::Pushad(void) +{ + CPU_Message(" pushad"); + PUTDST8(m_RecompPos,0x60); +} + +void CX86Ops::Push(x86Reg reg) +{ + CPU_Message(" push %s", x86_Name(reg)); + + switch(reg) + { + case x86_EAX: PUTDST8(m_RecompPos, 0x50); break; + case x86_EBX: PUTDST8(m_RecompPos, 0x53); break; + case x86_ECX: PUTDST8(m_RecompPos, 0x51); break; + case x86_EDX: PUTDST8(m_RecompPos, 0x52); break; + case x86_ESI: PUTDST8(m_RecompPos, 0x56); break; + case x86_EDI: PUTDST8(m_RecompPos, 0x57); break; + case x86_ESP: PUTDST8(m_RecompPos, 0x54); break; + case x86_EBP: PUTDST8(m_RecompPos, 0x55); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::Pop(x86Reg reg) +{ + CPU_Message(" pop %s", x86_Name(reg)); + + switch(reg) + { + case x86_EAX: PUTDST8(m_RecompPos, 0x58); break; + case x86_EBX: PUTDST8(m_RecompPos, 0x5B); break; + case x86_ECX: PUTDST8(m_RecompPos, 0x59); break; + case x86_EDX: PUTDST8(m_RecompPos, 0x5A); break; + case x86_ESI: PUTDST8(m_RecompPos, 0x5E); break; + case x86_EDI: PUTDST8(m_RecompPos, 0x5F); break; + case x86_ESP: PUTDST8(m_RecompPos, 0x5C); break; + case x86_EBP: PUTDST8(m_RecompPos, 0x5D); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::PushImm32(uint32_t Value) +{ + PushImm32(stdstr_f("%d",Value).c_str(),Value); +} + +void CX86Ops::PushImm32(const char * String, uint32_t Value) +{ + CPU_Message(" push %s",String); + PUTDST8(m_RecompPos,0x68); + PUTDST32(m_RecompPos,Value); } void CX86Ops::Ret(void) { - CPU_Message(" ret"); - PUTDST8(m_RecompPos,0xC3); + CPU_Message(" ret"); + PUTDST8(m_RecompPos,0xC3); } -void CX86Ops::Seta(x86Reg reg) { - CPU_Message(" seta %s",x86_ByteName(reg)); - PUTDST16(m_RecompPos,0x970F); - switch (reg) { - case x86_EAX: PUTDST8(m_RecompPos,0xC0); break; - case x86_EBX: PUTDST8(m_RecompPos,0xC3); break; - case x86_ECX: PUTDST8(m_RecompPos,0xC1); break; - case x86_EDX: PUTDST8(m_RecompPos,0xC2); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } +void CX86Ops::Seta(x86Reg reg) +{ + CPU_Message(" seta %s",x86_ByteName(reg)); + PUTDST16(m_RecompPos,0x970F); + switch (reg) + { + case x86_EAX: PUTDST8(m_RecompPos,0xC0); break; + case x86_EBX: PUTDST8(m_RecompPos,0xC3); break; + case x86_ECX: PUTDST8(m_RecompPos,0xC1); break; + case x86_EDX: PUTDST8(m_RecompPos,0xC2); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } } -void CX86Ops::SetaVariable(void * Variable, const char * VariableName) { - CPU_Message(" seta byte ptr [%s]",VariableName); - PUTDST16(m_RecompPos,0x970F); - PUTDST8(m_RecompPos,0x05); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::Setae(x86Reg reg) { - CPU_Message(" setae %s",x86_ByteName(reg)); - PUTDST16(m_RecompPos,0x930F); - switch (reg) { - case x86_EAX: PUTDST8(m_RecompPos,0xC0); break; - case x86_EBX: PUTDST8(m_RecompPos,0xC3); break; - case x86_ECX: PUTDST8(m_RecompPos,0xC1); break; - case x86_EDX: PUTDST8(m_RecompPos,0xC2); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::Setb(x86Reg reg) { - CPU_Message(" setb %s",x86_ByteName(reg)); - PUTDST16(m_RecompPos,0x920F); - switch (reg) { - case x86_EAX: PUTDST8(m_RecompPos,0xC0); break; - case x86_EBX: PUTDST8(m_RecompPos,0xC3); break; - case x86_ECX: PUTDST8(m_RecompPos,0xC1); break; - case x86_EDX: PUTDST8(m_RecompPos,0xC2); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::SetbVariable(void * Variable, const char * VariableName) { - CPU_Message(" setb byte ptr [%s]",VariableName); - PUTDST16(m_RecompPos,0x920F); - PUTDST8(m_RecompPos,0x05); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::Setg(x86Reg reg) { - CPU_Message(" setg %s",x86_ByteName(reg)); - PUTDST16(m_RecompPos,0x9F0F); - switch (reg) { - case x86_EAX: PUTDST8(m_RecompPos,0xC0); break; - case x86_EBX: PUTDST8(m_RecompPos,0xC3); break; - case x86_ECX: PUTDST8(m_RecompPos,0xC1); break; - case x86_EDX: PUTDST8(m_RecompPos,0xC2); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::SetgVariable(void * Variable, const char * VariableName) { - CPU_Message(" setg byte ptr [%s]",VariableName); - PUTDST16(m_RecompPos,0x9F0F); - PUTDST8(m_RecompPos,0x05); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::Setl(x86Reg reg) { - CPU_Message(" setl %s",x86_ByteName(reg)); - PUTDST16(m_RecompPos,0x9C0F); - switch (reg) { - case x86_EAX: PUTDST8(m_RecompPos,0xC0); break; - case x86_EBX: PUTDST8(m_RecompPos,0xC3); break; - case x86_ECX: PUTDST8(m_RecompPos,0xC1); break; - case x86_EDX: PUTDST8(m_RecompPos,0xC2); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::SetlVariable(void * Variable, const char * VariableName) { - CPU_Message(" setl byte ptr [%s]",VariableName); - PUTDST16(m_RecompPos,0x9C0F); - PUTDST8(m_RecompPos,0x05); - PUTDST32(m_RecompPos,Variable); -} - - -void CX86Ops::Setz(x86Reg reg) { - CPU_Message(" setz %s",x86_ByteName(reg)); - PUTDST16(m_RecompPos,0x940F); - switch (reg) { - case x86_EAX: PUTDST8(m_RecompPos,0xC0); break; - case x86_EBX: PUTDST8(m_RecompPos,0xC3); break; - case x86_ECX: PUTDST8(m_RecompPos,0xC1); break; - case x86_EDX: PUTDST8(m_RecompPos,0xC2); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::Setnz(x86Reg reg) { - CPU_Message(" setnz %s",x86_ByteName(reg)); - PUTDST16(m_RecompPos,0x950F); - switch (reg) { - case x86_EAX: PUTDST8(m_RecompPos,0xC0); break; - case x86_EBX: PUTDST8(m_RecompPos,0xC3); break; - case x86_ECX: PUTDST8(m_RecompPos,0xC1); break; - case x86_EDX: PUTDST8(m_RecompPos,0xC2); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::ShiftLeftDouble(x86Reg Destination, x86Reg Source) { - unsigned char s = 0xC0; - - CPU_Message(" shld %s, %s, cl", x86_Name(Destination),x86_Name(Source)); - PUTDST16(m_RecompPos,0xA50F); - - switch (Destination) { - case x86_EAX: s |= 0x00; break; - case x86_EBX: s |= 0x03; break; - case x86_ECX: s |= 0x01; break; - case x86_EDX: s |= 0x02; break; - case x86_ESI: s |= 0x06; break; - case x86_EDI: s |= 0x07; break; - case x86_ESP: s |= 0x04; break; - case x86_EBP: s |= 0x05; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (Source) { - case x86_EAX: s |= 0x00 << 3; break; - case x86_EBX: s |= 0x03 << 3; break; - case x86_ECX: s |= 0x01 << 3; break; - case x86_EDX: s |= 0x02 << 3; break; - case x86_ESI: s |= 0x06 << 3; break; - case x86_EDI: s |= 0x07 << 3; break; - case x86_ESP: s |= 0x04 << 3; break; - case x86_EBP: s |= 0x05 << 3; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - PUTDST8(m_RecompPos,s); -} - -void CX86Ops::ShiftLeftDoubleImmed(x86Reg Destination, x86Reg Source, BYTE Immediate) { - unsigned char s = 0xC0; - - CPU_Message(" shld %s, %s, %Xh", x86_Name(Destination),x86_Name(Source), Immediate); - PUTDST16(m_RecompPos,0xA40F); - - switch (Destination) { - case x86_EAX: s |= 0x00; break; - case x86_EBX: s |= 0x03; break; - case x86_ECX: s |= 0x01; break; - case x86_EDX: s |= 0x02; break; - case x86_ESI: s |= 0x06; break; - case x86_EDI: s |= 0x07; break; - case x86_ESP: s |= 0x04; break; - case x86_EBP: s |= 0x05; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (Source) { - case x86_EAX: s |= 0x00 << 3; break; - case x86_EBX: s |= 0x03 << 3; break; - case x86_ECX: s |= 0x01 << 3; break; - case x86_EDX: s |= 0x02 << 3; break; - case x86_ESI: s |= 0x06 << 3; break; - case x86_EDI: s |= 0x07 << 3; break; - case x86_ESP: s |= 0x04 << 3; break; - case x86_EBP: s |= 0x05 << 3; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - PUTDST8(m_RecompPos,s); - PUTDST8(m_RecompPos,Immediate); -} - -void CX86Ops::ShiftLeftSign(x86Reg reg) { - CPU_Message(" shl %s, cl",x86_Name(reg)); - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0xE0D3); break; - case x86_EBX: PUTDST16(m_RecompPos,0xE3D3); break; - case x86_ECX: PUTDST16(m_RecompPos,0xE1D3); break; - case x86_EDX: PUTDST16(m_RecompPos,0xE2D3); break; - case x86_ESI: PUTDST16(m_RecompPos,0xE6D3); break; - case x86_EDI: PUTDST16(m_RecompPos,0xE7D3); break; - case x86_ESP: PUTDST16(m_RecompPos,0xE4D3); break; - case x86_EBP: PUTDST16(m_RecompPos,0xE5D3); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::ShiftLeftSignImmed(x86Reg reg, BYTE Immediate) { - CPU_Message(" shl %s, %Xh",x86_Name(reg),Immediate); - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0xE0C1); break; - case x86_EBX: PUTDST16(m_RecompPos,0xE3C1); break; - case x86_ECX: PUTDST16(m_RecompPos,0xE1C1); break; - case x86_EDX: PUTDST16(m_RecompPos,0xE2C1); break; - case x86_ESI: PUTDST16(m_RecompPos,0xE6C1); break; - case x86_EDI: PUTDST16(m_RecompPos,0xE7C1); break; - case x86_ESP: PUTDST16(m_RecompPos,0xE4C1); break; - case x86_EBP: PUTDST16(m_RecompPos,0xE5C1); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST8(m_RecompPos,Immediate); -} - -void CX86Ops::ShiftRightSign(x86Reg reg) { - CPU_Message(" sar %s, cl",x86_Name(reg)); - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0xF8D3); break; - case x86_EBX: PUTDST16(m_RecompPos,0xFBD3); break; - case x86_ECX: PUTDST16(m_RecompPos,0xF9D3); break; - case x86_EDX: PUTDST16(m_RecompPos,0xFAD3); break; - case x86_ESI: PUTDST16(m_RecompPos,0xFED3); break; - case x86_EDI: PUTDST16(m_RecompPos,0xFFD3); break; - case x86_ESP: PUTDST16(m_RecompPos,0xFCD3); break; - case x86_EBP: PUTDST16(m_RecompPos,0xFDD3); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::ShiftRightSignImmed(x86Reg reg, BYTE Immediate) { - CPU_Message(" sar %s, %Xh",x86_Name(reg),Immediate); - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0xF8C1); break; - case x86_EBX: PUTDST16(m_RecompPos,0xFBC1); break; - case x86_ECX: PUTDST16(m_RecompPos,0xF9C1); break; - case x86_EDX: PUTDST16(m_RecompPos,0xFAC1); break; - case x86_ESI: PUTDST16(m_RecompPos,0xFEC1); break; - case x86_EDI: PUTDST16(m_RecompPos,0xFFC1); break; - case x86_ESP: PUTDST16(m_RecompPos,0xFCC1); break; - case x86_EBP: PUTDST16(m_RecompPos,0xFDC1); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST8(m_RecompPos,Immediate); -} - -void CX86Ops::ShiftRightUnsign(x86Reg reg) { - CPU_Message(" shr %s, cl",x86_Name(reg)); - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0xE8D3); break; - case x86_EBX: PUTDST16(m_RecompPos,0xEBD3); break; - case x86_ECX: PUTDST16(m_RecompPos,0xE9D3); break; - case x86_EDX: PUTDST16(m_RecompPos,0xEAD3); break; - case x86_ESI: PUTDST16(m_RecompPos,0xEED3); break; - case x86_EDI: PUTDST16(m_RecompPos,0xEFD3); break; - case x86_ESP: PUTDST16(m_RecompPos,0xECD3); break; - case x86_EBP: PUTDST16(m_RecompPos,0xEDD3); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::ShiftRightDouble(x86Reg Destination, x86Reg Source) { - unsigned char s = 0xC0; - - CPU_Message(" shrd %s, %s, cl", x86_Name(Destination),x86_Name(Source)); - PUTDST16(m_RecompPos,0xAD0F); - - switch (Destination) { - case x86_EAX: s |= 0x00; break; - case x86_EBX: s |= 0x03; break; - case x86_ECX: s |= 0x01; break; - case x86_EDX: s |= 0x02; break; - case x86_ESI: s |= 0x06; break; - case x86_EDI: s |= 0x07; break; - case x86_ESP: s |= 0x04; break; - case x86_EBP: s |= 0x05; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (Source) { - case x86_EAX: s |= 0x00 << 3; break; - case x86_EBX: s |= 0x03 << 3; break; - case x86_ECX: s |= 0x01 << 3; break; - case x86_EDX: s |= 0x02 << 3; break; - case x86_ESI: s |= 0x06 << 3; break; - case x86_EDI: s |= 0x07 << 3; break; - case x86_ESP: s |= 0x04 << 3; break; - case x86_EBP: s |= 0x05 << 3; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - PUTDST8(m_RecompPos,s); -} - -void CX86Ops::ShiftRightDoubleImmed(x86Reg Destination, x86Reg Source, BYTE Immediate) { - unsigned char s = 0xC0; - - CPU_Message(" shrd %s, %s, %Xh", x86_Name(Destination),x86_Name(Source), Immediate); - PUTDST16(m_RecompPos,0xAC0F); - - switch (Destination) { - case x86_EAX: s |= 0x00; break; - case x86_EBX: s |= 0x03; break; - case x86_ECX: s |= 0x01; break; - case x86_EDX: s |= 0x02; break; - case x86_ESI: s |= 0x06; break; - case x86_EDI: s |= 0x07; break; - case x86_ESP: s |= 0x04; break; - case x86_EBP: s |= 0x05; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - switch (Source) { - case x86_EAX: s |= 0x00 << 3; break; - case x86_EBX: s |= 0x03 << 3; break; - case x86_ECX: s |= 0x01 << 3; break; - case x86_EDX: s |= 0x02 << 3; break; - case x86_ESI: s |= 0x06 << 3; break; - case x86_EDI: s |= 0x07 << 3; break; - case x86_ESP: s |= 0x04 << 3; break; - case x86_EBP: s |= 0x05 << 3; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - PUTDST8(m_RecompPos,s); - PUTDST8(m_RecompPos,Immediate); -} - -void CX86Ops::ShiftRightUnsignImmed(x86Reg reg, BYTE Immediate) { - CPU_Message(" shr %s, %Xh",x86_Name(reg),Immediate); - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0xE8C1); break; - case x86_EBX: PUTDST16(m_RecompPos,0xEBC1); break; - case x86_ECX: PUTDST16(m_RecompPos,0xE9C1); break; - case x86_EDX: PUTDST16(m_RecompPos,0xEAC1); break; - case x86_ESI: PUTDST16(m_RecompPos,0xEEC1); break; - case x86_EDI: PUTDST16(m_RecompPos,0xEFC1); break; - case x86_ESP: PUTDST16(m_RecompPos,0xECC1); break; - case x86_EBP: PUTDST16(m_RecompPos,0xEDC1); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST8(m_RecompPos,Immediate); -} - -void CX86Ops::SbbConstFromX86Reg (x86Reg reg, DWORD Const) { - CPU_Message(" sbb %s, %Xh",x86_Name(reg),Const); - if ((Const & 0xFFFFFF80) != 0 && (Const & 0xFFFFFF80) != 0xFFFFFF80) { - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0xD881); break; - case x86_EBX: PUTDST16(m_RecompPos,0xDB81); break; - case x86_ECX: PUTDST16(m_RecompPos,0xD981); break; - case x86_EDX: PUTDST16(m_RecompPos,0xDA81); break; - case x86_ESI: PUTDST16(m_RecompPos,0xDE81); break; - case x86_EDI: PUTDST16(m_RecompPos,0xDF81); break; - case x86_ESP: PUTDST16(m_RecompPos,0xDC81); break; - case x86_EBP: PUTDST16(m_RecompPos,0xDD81); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos, Const); - } else { - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0xD883); break; - case x86_EBX: PUTDST16(m_RecompPos,0xDB83); break; - case x86_ECX: PUTDST16(m_RecompPos,0xD983); break; - case x86_EDX: PUTDST16(m_RecompPos,0xDA83); break; - case x86_ESI: PUTDST16(m_RecompPos,0xDE83); break; - case x86_EDI: PUTDST16(m_RecompPos,0xDF83); break; - case x86_ESP: PUTDST16(m_RecompPos,0xDC83); break; - case x86_EBP: PUTDST16(m_RecompPos,0xDD83); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST8(m_RecompPos, Const); - } -} - -void CX86Ops::SbbVariableFromX86reg(x86Reg reg, void * Variable, const char * VariableName) { - CPU_Message(" sbb %s, dword ptr [%s]",x86_Name(reg),VariableName); - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0x051B); break; - case x86_EBX: PUTDST16(m_RecompPos,0x1D1B); break; - case x86_ECX: PUTDST16(m_RecompPos,0x0D1B); break; - case x86_EDX: PUTDST16(m_RecompPos,0x151B); break; - case x86_ESI: PUTDST16(m_RecompPos,0x351B); break; - case x86_EDI: PUTDST16(m_RecompPos,0x3D1B); break; - case x86_ESP: PUTDST16(m_RecompPos,0x251B); break; - case x86_EBP: PUTDST16(m_RecompPos,0x2D1B); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::SbbX86RegToX86Reg(x86Reg Destination, x86Reg Source) { - WORD x86Command = 0; - CPU_Message(" sbb %s, %s",x86_Name(Destination),x86_Name(Source)); - switch (Source) { - case x86_EAX: x86Command = 0x001B; break; - case x86_EBX: x86Command = 0x031B; break; - case x86_ECX: x86Command = 0x011B; break; - case x86_EDX: x86Command = 0x021B; break; - case x86_ESI: x86Command = 0x061B; break; - case x86_EDI: x86Command = 0x071B; break; - case x86_ESP: x86Command = 0x041B; break; - case x86_EBP: x86Command = 0x051B; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - switch (Destination) { - case x86_EAX: x86Command += 0xC000; break; - case x86_EBX: x86Command += 0xD800; break; - case x86_ECX: x86Command += 0xC800; break; - case x86_EDX: x86Command += 0xD000; break; - case x86_ESI: x86Command += 0xF000; break; - case x86_EDI: x86Command += 0xF800; break; - case x86_ESP: x86Command += 0xE000; break; - case x86_EBP: x86Command += 0xE800; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST16(m_RecompPos,x86Command); -} - -void CX86Ops::SubConstFromVariable (DWORD Const, void *Variable, const char * VariableName) { - CPU_Message(" sub dword ptr [%s], 0x%X",VariableName, Const);\ - PUTDST16(m_RecompPos,0x2D81); - PUTDST32(m_RecompPos,Variable); - PUTDST32(m_RecompPos,Const); -} - -void CX86Ops::SubConstFromX86Reg (x86Reg reg, DWORD Const) { - CPU_Message(" sub %s, %Xh",x86_Name(reg),Const); - if ((Const & 0xFFFFFF80) != 0 && (Const & 0xFFFFFF80) != 0xFFFFFF80) { - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0xE881); break; - case x86_EBX: PUTDST16(m_RecompPos,0xEB81); break; - case x86_ECX: PUTDST16(m_RecompPos,0xE981); break; - case x86_EDX: PUTDST16(m_RecompPos,0xEA81); break; - case x86_ESI: PUTDST16(m_RecompPos,0xEE81); break; - case x86_EDI: PUTDST16(m_RecompPos,0xEF81); break; - case x86_ESP: PUTDST16(m_RecompPos,0xEC81); break; - case x86_EBP: PUTDST16(m_RecompPos,0xED81); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos, Const); - } else { - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0xE883); break; - case x86_EBX: PUTDST16(m_RecompPos,0xEB83); break; - case x86_ECX: PUTDST16(m_RecompPos,0xE983); break; - case x86_EDX: PUTDST16(m_RecompPos,0xEA83); break; - case x86_ESI: PUTDST16(m_RecompPos,0xEE83); break; - case x86_EDI: PUTDST16(m_RecompPos,0xEF83); break; - case x86_ESP: PUTDST16(m_RecompPos,0xEC83); break; - case x86_EBP: PUTDST16(m_RecompPos,0xED83); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST8(m_RecompPos, Const); - } -} - -void CX86Ops::SubVariableFromX86reg(x86Reg reg, void * Variable, const char * VariableName) { - CPU_Message(" sub %s, dword ptr [%s]",x86_Name(reg),VariableName); - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0x052B); break; - case x86_EBX: PUTDST16(m_RecompPos,0x1D2B); break; - case x86_ECX: PUTDST16(m_RecompPos,0x0D2B); break; - case x86_EDX: PUTDST16(m_RecompPos,0x152B); break; - case x86_ESI: PUTDST16(m_RecompPos,0x352B); break; - case x86_EDI: PUTDST16(m_RecompPos,0x3D2B); break; - case x86_ESP: PUTDST16(m_RecompPos,0x252B); break; - case x86_EBP: PUTDST16(m_RecompPos,0x2D2B); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::SubX86RegToX86Reg(x86Reg Destination, x86Reg Source) { - WORD x86Command = 0; - CPU_Message(" sub %s, %s",x86_Name(Destination),x86_Name(Source)); - switch (Source) { - case x86_EAX: x86Command = 0x002B; break; - case x86_EBX: x86Command = 0x032B; break; - case x86_ECX: x86Command = 0x012B; break; - case x86_EDX: x86Command = 0x022B; break; - case x86_ESI: x86Command = 0x062B; break; - case x86_EDI: x86Command = 0x072B; break; - case x86_ESP: x86Command = 0x042B; break; - case x86_EBP: x86Command = 0x052B; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - switch (Destination) { - case x86_EAX: x86Command += 0xC000; break; - case x86_EBX: x86Command += 0xD800; break; - case x86_ECX: x86Command += 0xC800; break; - case x86_EDX: x86Command += 0xD000; break; - case x86_ESI: x86Command += 0xF000; break; - case x86_EDI: x86Command += 0xF800; break; - case x86_ESP: x86Command += 0xE000; break; - case x86_EBP: x86Command += 0xE800; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST16(m_RecompPos,x86Command); -} - -void CX86Ops::TestConstToX86Reg(DWORD Const, x86Reg reg) { - CPU_Message(" test %s, 0x%X",x86_Name(reg), Const); - - switch (reg) { - case x86_EAX: PUTDST8 (m_RecompPos,0xA9); break; - case x86_EBX: PUTDST16(m_RecompPos,0xC3F7); break; - case x86_ECX: PUTDST16(m_RecompPos,0xC1F7); break; - case x86_EDX: PUTDST16(m_RecompPos,0xC2F7); break; - case x86_ESI: PUTDST16(m_RecompPos,0xC6F7); break; - case x86_EDI: PUTDST16(m_RecompPos,0xC7F7); break; - case x86_ESP: PUTDST16(m_RecompPos,0xC4F7); break; - case x86_EBP: PUTDST16(m_RecompPos,0xC5F7); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,Const); -} - -void CX86Ops::TestVariable(DWORD Const, void * Variable, const char * VariableName) { - CPU_Message(" test dword ptr ds:[%s], 0x%X",VariableName, Const); - PUTDST16(m_RecompPos,0x05F7); - PUTDST32(m_RecompPos,Variable); - PUTDST32(m_RecompPos,Const); -} - -void CX86Ops::TestX86RegToX86Reg(x86Reg Destination, x86Reg Source) { - WORD x86Command = 0; - CPU_Message(" test %s, %s",x86_Name(Destination),x86_Name(Source)); - switch (Source) { - case x86_EAX: x86Command = 0x0085; break; - case x86_EBX: x86Command = 0x0385; break; - case x86_ECX: x86Command = 0x0185; break; - case x86_EDX: x86Command = 0x0285; break; - case x86_ESI: x86Command = 0x0685; break; - case x86_EDI: x86Command = 0x0785; break; - case x86_ESP: x86Command = 0x0485; break; - case x86_EBP: x86Command = 0x0585; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - switch (Destination) { - case x86_EAX: x86Command += 0xC000; break; - case x86_EBX: x86Command += 0xD800; break; - case x86_ECX: x86Command += 0xC800; break; - case x86_EDX: x86Command += 0xD000; break; - case x86_ESI: x86Command += 0xF000; break; - case x86_EDI: x86Command += 0xF800; break; - case x86_ESP: x86Command += 0xE000; break; - case x86_EBP: x86Command += 0xE800; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST16(m_RecompPos,x86Command); -} - -void CX86Ops::XorConstToX86Reg(x86Reg reg, DWORD Const) { - CPU_Message(" xor %s, %Xh",x86_Name(reg),Const); - if ((Const & 0xFFFFFF80) != 0 && (Const & 0xFFFFFF80) != 0xFFFFFF80) { - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0xF081); break; - case x86_EBX: PUTDST16(m_RecompPos,0xF381); break; - case x86_ECX: PUTDST16(m_RecompPos,0xF181); break; - case x86_EDX: PUTDST16(m_RecompPos,0xF281); break; - case x86_ESI: PUTDST16(m_RecompPos,0xF681); break; - case x86_EDI: PUTDST16(m_RecompPos,0xF781); break; - case x86_ESP: PUTDST16(m_RecompPos,0xF481); break; - case x86_EBP: PUTDST16(m_RecompPos,0xF581); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos, Const); - } else { - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0xF083); break; - case x86_EBX: PUTDST16(m_RecompPos,0xF383); break; - case x86_ECX: PUTDST16(m_RecompPos,0xF183); break; - case x86_EDX: PUTDST16(m_RecompPos,0xF283); break; - case x86_ESI: PUTDST16(m_RecompPos,0xF683); break; - case x86_EDI: PUTDST16(m_RecompPos,0xF783); break; - case x86_ESP: PUTDST16(m_RecompPos,0xF483); break; - case x86_EBP: PUTDST16(m_RecompPos,0xF583); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST8(m_RecompPos, Const); - } -} - -void CX86Ops::XorX86RegToX86Reg(x86Reg Source, x86Reg Destination) { - WORD x86Command = 0; - - CPU_Message(" xor %s, %s",x86_Name(Source),x86_Name(Destination)); - - switch (Source) { - case x86_EAX: x86Command = 0x0031; break; - case x86_EBX: x86Command = 0x0331; break; - case x86_ECX: x86Command = 0x0131; break; - case x86_EDX: x86Command = 0x0231; break; - case x86_ESI: x86Command = 0x0631; break; - case x86_EDI: x86Command = 0x0731; break; - case x86_ESP: x86Command = 0x0431; break; - case x86_EBP: x86Command = 0x0531; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - switch (Destination) { - case x86_EAX: x86Command += 0xC000; break; - case x86_EBX: x86Command += 0xD800; break; - case x86_ECX: x86Command += 0xC800; break; - case x86_EDX: x86Command += 0xD000; break; - case x86_ESI: x86Command += 0xF000; break; - case x86_EDI: x86Command += 0xF800; break; - case x86_ESP: x86Command += 0xE000; break; - case x86_EBP: x86Command += 0xE800; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST16(m_RecompPos,x86Command); -} - -void CX86Ops::XorVariableToX86reg(void *Variable, const char * VariableName, x86Reg reg) { - CPU_Message(" Xor %s, dword ptr [%s]",x86_Name(reg),VariableName); - switch (reg) { - case x86_EAX: PUTDST16(m_RecompPos,0x0533); break; - case x86_EBX: PUTDST16(m_RecompPos,0x1D33); break; - case x86_ECX: PUTDST16(m_RecompPos,0x0D33); break; - case x86_EDX: PUTDST16(m_RecompPos,0x1533); break; - case x86_ESI: PUTDST16(m_RecompPos,0x3533); break; - case x86_EDI: PUTDST16(m_RecompPos,0x3D33); break; - case x86_ESP: PUTDST16(m_RecompPos,0x2533); break; - case x86_EBP: PUTDST16(m_RecompPos,0x2D33); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } +void CX86Ops::SetaVariable(void * Variable, const char * VariableName) +{ + CPU_Message(" seta byte ptr [%s]",VariableName); + PUTDST16(m_RecompPos,0x970F); + PUTDST8(m_RecompPos,0x05); PUTDST32(m_RecompPos,Variable); } -void CX86Ops::fpuAbs(void) { - CPU_Message(" fabs ST(0)"); - PUTDST16(m_RecompPos,0xE1D9); -} - -void CX86Ops::fpuAddDword(void *Variable, const char * VariableName) { - CPU_Message(" fadd ST(0), dword ptr [%s]", VariableName); - PUTDST16(m_RecompPos,0x05D8); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::fpuAddDwordRegPointer(x86Reg x86Pointer) { - CPU_Message(" fadd ST(0), dword ptr [%s]",x86_Name(x86Pointer)); - switch (x86Pointer) { - case x86_EAX: PUTDST16(m_RecompPos,0x00D8); break; - case x86_EBX: PUTDST16(m_RecompPos,0x03D8); break; - case x86_ECX: PUTDST16(m_RecompPos,0x01D8); break; - case x86_EDX: PUTDST16(m_RecompPos,0x02D8); break; - case x86_ESI: PUTDST16(m_RecompPos,0x06D8); break; - case x86_EDI: PUTDST16(m_RecompPos,0x07D8); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } -} - -void CX86Ops::fpuAddQword(void *Variable, const char * VariableName) { - CPU_Message(" fadd ST(0), qword ptr [%s]", VariableName); - PUTDST16(m_RecompPos,0x05DC); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::fpuAddQwordRegPointer(x86Reg x86Pointer) { - CPU_Message(" fadd ST(0), qword ptr [%s]",x86_Name(x86Pointer)); - switch (x86Pointer) { - case x86_EAX: PUTDST16(m_RecompPos,0x00DC); break; - case x86_EBX: PUTDST16(m_RecompPos,0x03DC); break; - case x86_ECX: PUTDST16(m_RecompPos,0x01DC); break; - case x86_EDX: PUTDST16(m_RecompPos,0x02DC); break; - case x86_ESI: PUTDST16(m_RecompPos,0x06DC); break; - case x86_EDI: PUTDST16(m_RecompPos,0x07DC); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } -} - -void CX86Ops::fpuAddReg(x86FpuValues x86reg) { - CPU_Message(" fadd ST(0), %s",fpu_Name(x86reg)); - switch (x86reg) { - case x86_ST0: PUTDST16(m_RecompPos,0xC0D8); break; - case x86_ST1: PUTDST16(m_RecompPos,0xC1D8); break; - case x86_ST2: PUTDST16(m_RecompPos,0xC2D8); break; - case x86_ST3: PUTDST16(m_RecompPos,0xC3D8); break; - case x86_ST4: PUTDST16(m_RecompPos,0xC4D8); break; - case x86_ST5: PUTDST16(m_RecompPos,0xC5D8); break; - case x86_ST6: PUTDST16(m_RecompPos,0xC6D8); break; - case x86_ST7: PUTDST16(m_RecompPos,0xC7D8); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } -} - -void CX86Ops::fpuAddRegPop(int * StackPos, x86FpuValues reg) { - CPU_Message(" faddp ST(0), %s",fpu_Name(reg)); - *StackPos = (*StackPos + 1) & 7; - switch (reg) { - case x86_ST0: PUTDST16(m_RecompPos,0xC0DE); break; - case x86_ST1: PUTDST16(m_RecompPos,0xC1DE); break; - case x86_ST2: PUTDST16(m_RecompPos,0xC2DE); break; - case x86_ST3: PUTDST16(m_RecompPos,0xC3DE); break; - case x86_ST4: PUTDST16(m_RecompPos,0xC4DE); break; - case x86_ST5: PUTDST16(m_RecompPos,0xC5DE); break; - case x86_ST6: PUTDST16(m_RecompPos,0xC6DE); break; - case x86_ST7: PUTDST16(m_RecompPos,0xC7DE); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } -} - -void CX86Ops::fpuComDword(void *Variable, const char * VariableName, bool Pop) { - CPU_Message(" fcom%s ST(0), dword ptr [%s]", m_fpupop[Pop], VariableName); - PUTDST16(m_RecompPos, Pop ? 0x1DD8 : 0x15D8); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::fpuComDwordRegPointer(x86Reg x86Pointer, bool Pop) { - WORD x86Command; - - CPU_Message(" fcom%s ST(0), dword ptr [%s]",m_fpupop[Pop],x86_Name(x86Pointer)); - switch (x86Pointer) { - case x86_EAX: x86Command = 0x10D8; break; - case x86_EBX: x86Command = 0x13D8; break; - case x86_ECX: x86Command = 0x11D8; break; - case x86_EDX: x86Command = 0x12D8; break; - case x86_ESI: x86Command = 0x16D8; break; - case x86_EDI: x86Command = 0x17D8; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - if (Pop) - { - x86Command |= 0x0800; - } - - PUTDST16(m_RecompPos,x86Command); -} - -void CX86Ops::fpuComQword(void *Variable, const char * VariableName, bool Pop) { - CPU_Message(" fcom%s ST(0), qword ptr [%s]", m_fpupop[Pop], VariableName); - PUTDST16(m_RecompPos, Pop ? 0x1DDC : 0x15DC); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::fpuComQwordRegPointer(x86Reg x86Pointer, bool Pop) { - WORD x86Command; - - CPU_Message(" fcom%s ST(0), qword ptr [%s]",m_fpupop[Pop],x86_Name(x86Pointer)); - switch (x86Pointer) { - case x86_EAX: x86Command = 0x10DC; break; - case x86_EBX: x86Command = 0x13DC; break; - case x86_ECX: x86Command = 0x11DC; break; - case x86_EDX: x86Command = 0x12DC; break; - case x86_ESI: x86Command = 0x16DC; break; - case x86_EDI: x86Command = 0x17DC; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - if (Pop) - { - x86Command |= 0x0800; - } - - PUTDST16(m_RecompPos,x86Command); -} - -void CX86Ops::fpuComReg(x86FpuValues x86reg, bool Pop) { - int s = Pop ? 0x0800 : 0x0000; - CPU_Message(" fcom%s ST(0), %s", m_fpupop[Pop], fpu_Name(x86reg)); - - switch (x86reg) { - case x86_ST0: PUTDST16(m_RecompPos,0xD0D8|s); break; - case x86_ST1: PUTDST16(m_RecompPos,0xD1D8|s); break; - case x86_ST2: PUTDST16(m_RecompPos,0xD2D8|s); break; - case x86_ST3: PUTDST16(m_RecompPos,0xD3D8|s); break; - case x86_ST4: PUTDST16(m_RecompPos,0xD4D8|s); break; - case x86_ST5: PUTDST16(m_RecompPos,0xD5D8|s); break; - case x86_ST6: PUTDST16(m_RecompPos,0xD6D8|s); break; - case x86_ST7: PUTDST16(m_RecompPos,0xD7D8|s); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } -} - -void CX86Ops::fpuDivDword(void *Variable, const char * VariableName) { - CPU_Message(" fdiv ST(0), dword ptr [%s]", VariableName); - PUTDST16(m_RecompPos,0x35D8); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::fpuDivDwordRegPointer(x86Reg x86Pointer) { - CPU_Message(" fdiv ST(0), dword ptr [%s]",x86_Name(x86Pointer)); - switch (x86Pointer) { - case x86_EAX: PUTDST16(m_RecompPos,0x30D8); break; - case x86_EBX: PUTDST16(m_RecompPos,0x33D8); break; - case x86_ECX: PUTDST16(m_RecompPos,0x31D8); break; - case x86_EDX: PUTDST16(m_RecompPos,0x32D8); break; - case x86_ESI: PUTDST16(m_RecompPos,0x36D8); break; - case x86_EDI: PUTDST16(m_RecompPos,0x37D8); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } -} - -void CX86Ops::fpuDivQword(void *Variable, const char * VariableName) { - CPU_Message(" fdiv ST(0), qword ptr [%s]", VariableName); - PUTDST16(m_RecompPos,0x35DC); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::fpuDivQwordRegPointer(x86Reg x86Pointer) { - CPU_Message(" fdiv ST(0), qword ptr [%s]",x86_Name(x86Pointer)); - switch (x86Pointer) { - case x86_EAX: PUTDST16(m_RecompPos,0x30DC); break; - case x86_EBX: PUTDST16(m_RecompPos,0x33DC); break; - case x86_ECX: PUTDST16(m_RecompPos,0x31DC); break; - case x86_EDX: PUTDST16(m_RecompPos,0x32DC); break; - case x86_ESI: PUTDST16(m_RecompPos,0x36DC); break; - case x86_EDI: PUTDST16(m_RecompPos,0x37DC); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } -} - -void CX86Ops::fpuDivReg(x86FpuValues Reg) { - CPU_Message(" fdiv ST(0), %s", fpu_Name(Reg)); - switch (Reg) { - case x86_ST0: PUTDST16(m_RecompPos,0xF0D8); break; - case x86_ST1: PUTDST16(m_RecompPos,0xF1D8); break; - case x86_ST2: PUTDST16(m_RecompPos,0xF2D8); break; - case x86_ST3: PUTDST16(m_RecompPos,0xF3D8); break; - case x86_ST4: PUTDST16(m_RecompPos,0xF4D8); break; - case x86_ST5: PUTDST16(m_RecompPos,0xF5D8); break; - case x86_ST6: PUTDST16(m_RecompPos,0xF6D8); break; - case x86_ST7: PUTDST16(m_RecompPos,0xF7D8); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } -} - -void CX86Ops::fpuDivRegPop(x86FpuValues reg) { - CPU_Message(" fdivp ST(0), %s",fpu_Name(reg)); - switch (reg) { - case x86_ST0: PUTDST16(m_RecompPos,0xF8DE); break; - case x86_ST1: PUTDST16(m_RecompPos,0xF9DE); break; - case x86_ST2: PUTDST16(m_RecompPos,0xFADE); break; - case x86_ST3: PUTDST16(m_RecompPos,0xFBDE); break; - case x86_ST4: PUTDST16(m_RecompPos,0xFCDE); break; - case x86_ST5: PUTDST16(m_RecompPos,0xFDDE); break; - case x86_ST6: PUTDST16(m_RecompPos,0xFEDE); break; - case x86_ST7: PUTDST16(m_RecompPos,0xFFDE); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } -} - -void CX86Ops::fpuExchange(x86FpuValues Reg) { - CPU_Message(" fxch ST(0), %s",fpu_Name(Reg)); - switch (Reg) { - case x86_ST0: PUTDST16(m_RecompPos,0xC8D9); break; - case x86_ST1: PUTDST16(m_RecompPos,0xC9D9); break; - case x86_ST2: PUTDST16(m_RecompPos,0xCAD9); break; - case x86_ST3: PUTDST16(m_RecompPos,0xCBD9); break; - case x86_ST4: PUTDST16(m_RecompPos,0xCCD9); break; - case x86_ST5: PUTDST16(m_RecompPos,0xCDD9); break; - case x86_ST6: PUTDST16(m_RecompPos,0xCED9); break; - case x86_ST7: PUTDST16(m_RecompPos,0xCFD9); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } -} - -void CX86Ops::fpuFree(x86FpuValues Reg) { - CPU_Message(" ffree %s",fpu_Name(Reg)); - switch (Reg) { - case x86_ST0: PUTDST16(m_RecompPos,0xC0DD); break; - case x86_ST1: PUTDST16(m_RecompPos,0xC1DD); break; - case x86_ST2: PUTDST16(m_RecompPos,0xC2DD); break; - case x86_ST3: PUTDST16(m_RecompPos,0xC3DD); break; - case x86_ST4: PUTDST16(m_RecompPos,0xC4DD); break; - case x86_ST5: PUTDST16(m_RecompPos,0xC5DD); break; - case x86_ST6: PUTDST16(m_RecompPos,0xC6DD); break; - case x86_ST7: PUTDST16(m_RecompPos,0xC7DD); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } -} - -void CX86Ops::fpuDecStack(int * StackPos) { - CPU_Message(" fdecstp"); - *StackPos = (*StackPos - 1) & 7; - PUTDST16(m_RecompPos,0xF6D9); -} - -void CX86Ops::fpuIncStack(int * StackPos) { - CPU_Message(" fincstp"); - *StackPos = (*StackPos + 1) & 7; - PUTDST16(m_RecompPos,0xF7D9); -} - -void CX86Ops::fpuLoadControl(void *Variable, const char * VariableName) { - CPU_Message(" fldcw [%s]",VariableName); - PUTDST16(m_RecompPos,0x2DD9); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::fpuLoadDword(int * StackPos,void *Variable, const char * VariableName) { - CPU_Message(" fld dword ptr [%s]",VariableName); - *StackPos = (*StackPos - 1) & 7; - PUTDST16(m_RecompPos,0x05D9); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::fpuLoadDwordFromX86Reg(int * StackPos, x86Reg x86reg) { - CPU_Message(" fld dword ptr [%s]",x86_Name(x86reg)); - *StackPos = (*StackPos - 1) & 7; - PUTDST8(m_RecompPos,0xD9); - switch (x86reg) { - case x86_EAX: PUTDST8(m_RecompPos,0x00); break; - case x86_EBX: PUTDST8(m_RecompPos,0x03); break; - case x86_ECX: PUTDST8(m_RecompPos,0x01); break; - case x86_EDX: PUTDST8(m_RecompPos,0x02); break; - case x86_ESI: PUTDST8(m_RecompPos,0x06); break; - case x86_EDI: PUTDST8(m_RecompPos,0x07); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::fpuLoadDwordFromN64Mem(int * StackPos,x86Reg x86reg) { - CPU_Message(" fld dword ptr [%s+N64mem]",x86_Name(x86reg)); - *StackPos = (*StackPos - 1) & 7; - switch (x86reg) { - case x86_EAX: PUTDST16(m_RecompPos,0x80D9); break; - case x86_EBX: PUTDST16(m_RecompPos,0x83D9); break; - case x86_ECX: PUTDST16(m_RecompPos,0x81D9); break; - case x86_EDX: PUTDST16(m_RecompPos,0x82D9); break; - case x86_ESI: PUTDST16(m_RecompPos,0x86D9); break; - case x86_EDI: PUTDST16(m_RecompPos,0x87D9); break; - case x86_EBP: PUTDST16(m_RecompPos,0x85D9); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,g_MMU->Rdram()); -} - -void CX86Ops::fpuLoadInt32bFromN64Mem(int * StackPos,x86Reg x86reg) { - CPU_Message(" fild dword ptr [%s+N64mem]",x86_Name(x86reg)); - *StackPos = (*StackPos - 1) & 7; - switch (x86reg) { - case x86_EAX: PUTDST16(m_RecompPos,0x80DB); break; - case x86_EBX: PUTDST16(m_RecompPos,0x83DB); break; - case x86_ECX: PUTDST16(m_RecompPos,0x81DB); break; - case x86_EDX: PUTDST16(m_RecompPos,0x82DB); break; - case x86_ESI: PUTDST16(m_RecompPos,0x86DB); break; - case x86_EDI: PUTDST16(m_RecompPos,0x87DB); break; - case x86_EBP: PUTDST16(m_RecompPos,0x85DB); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,g_MMU->Rdram()); -} - -void CX86Ops::fpuLoadIntegerDword(int * StackPos,void *Variable, const char * VariableName) { - CPU_Message(" fild dword ptr [%s]",VariableName); - *StackPos = (*StackPos - 1) & 7; - PUTDST16(m_RecompPos,0x05DB); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::fpuLoadIntegerDwordFromX86Reg(int * StackPos,x86Reg x86reg) { - CPU_Message(" fild dword ptr [%s]",x86_Name(x86reg)); - *StackPos = (*StackPos - 1) & 7; - PUTDST8(m_RecompPos,0xDB); - switch (x86reg) { - case x86_EAX: PUTDST8(m_RecompPos,0x00); break; - case x86_EBX: PUTDST8(m_RecompPos,0x03); break; - case x86_ECX: PUTDST8(m_RecompPos,0x01); break; - case x86_EDX: PUTDST8(m_RecompPos,0x02); break; - case x86_ESI: PUTDST8(m_RecompPos,0x06); break; - case x86_EDI: PUTDST8(m_RecompPos,0x07); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::fpuLoadIntegerQword(int * StackPos,void *Variable, const char * VariableName) { - CPU_Message(" fild qword ptr [%s]",VariableName); - *StackPos = (*StackPos - 1) & 7; - PUTDST16(m_RecompPos,0x2DDF); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::fpuLoadIntegerQwordFromX86Reg(int * StackPos,x86Reg x86reg) { - CPU_Message(" fild qword ptr [%s]",x86_Name(x86reg)); - *StackPos = (*StackPos - 1) & 7; - PUTDST8(m_RecompPos,0xDF); - switch (x86reg) { - case x86_EAX: PUTDST8(m_RecompPos,0x28); break; - case x86_EBX: PUTDST8(m_RecompPos,0x2B); break; - case x86_ECX: PUTDST8(m_RecompPos,0x29); break; - case x86_EDX: PUTDST8(m_RecompPos,0x2A); break; - case x86_ESI: PUTDST8(m_RecompPos,0x2E); break; - case x86_EDI: PUTDST8(m_RecompPos,0x2F); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::fpuLoadQword(int * StackPos,void *Variable, const char * VariableName) { - CPU_Message(" fld qword ptr [%s]",VariableName); - *StackPos = (*StackPos - 1) & 7; - PUTDST16(m_RecompPos,0x05DD); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::fpuLoadQwordFromX86Reg(int * StackPos, x86Reg x86reg) { - CPU_Message(" fld qword ptr [%s]",x86_Name(x86reg)); - *StackPos = (*StackPos - 1) & 7; - PUTDST8(m_RecompPos,0xDD); - switch (x86reg) { - case x86_EAX: PUTDST8(m_RecompPos,0x00); break; - case x86_EBX: PUTDST8(m_RecompPos,0x03); break; - case x86_ECX: PUTDST8(m_RecompPos,0x01); break; - case x86_EDX: PUTDST8(m_RecompPos,0x02); break; - case x86_ESI: PUTDST8(m_RecompPos,0x06); break; - case x86_EDI: PUTDST8(m_RecompPos,0x07); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } -} - -void CX86Ops::fpuLoadQwordFromN64Mem(int * StackPos,x86Reg x86reg) { - CPU_Message(" fld qword ptr [%s+N64mem]",x86_Name(x86reg)); - *StackPos = (*StackPos - 1) & 7; - switch (x86reg) { - case x86_EAX: PUTDST16(m_RecompPos,0x80DD); break; - case x86_EBX: PUTDST16(m_RecompPos,0x83DD); break; - case x86_ECX: PUTDST16(m_RecompPos,0x81DD); break; - case x86_EDX: PUTDST16(m_RecompPos,0x82DD); break; - case x86_ESI: PUTDST16(m_RecompPos,0x86DD); break; - case x86_EDI: PUTDST16(m_RecompPos,0x87DD); break; - case x86_EBP: PUTDST16(m_RecompPos,0x85DD); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - PUTDST32(m_RecompPos,g_MMU->Rdram()); -} - -void CX86Ops::fpuLoadReg(int * StackPos,x86FpuValues Reg) { - CPU_Message(" fld ST(0), %s",fpu_Name(Reg)); - *StackPos = (*StackPos - 1) & 7; - switch (Reg) { - case x86_ST0: PUTDST16(m_RecompPos,0xC0D9); break; - case x86_ST1: PUTDST16(m_RecompPos,0xC1D9); break; - case x86_ST2: PUTDST16(m_RecompPos,0xC2D9); break; - case x86_ST3: PUTDST16(m_RecompPos,0xC3D9); break; - case x86_ST4: PUTDST16(m_RecompPos,0xC4D9); break; - case x86_ST5: PUTDST16(m_RecompPos,0xC5D9); break; - case x86_ST6: PUTDST16(m_RecompPos,0xC6D9); break; - case x86_ST7: PUTDST16(m_RecompPos,0xC7D9); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } -} - -void CX86Ops::fpuMulDword(void *Variable, const char * VariableName) { - CPU_Message(" fmul ST(0), dword ptr [%s]", VariableName); - PUTDST16(m_RecompPos,0x0DD8); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::fpuMulDwordRegPointer(x86Reg x86Pointer) { - CPU_Message(" fmul ST(0), dword ptr [%s]",x86_Name(x86Pointer)); - switch (x86Pointer) { - case x86_EAX: PUTDST16(m_RecompPos,0x08D8); break; - case x86_EBX: PUTDST16(m_RecompPos,0x0BD8); break; - case x86_ECX: PUTDST16(m_RecompPos,0x09D8); break; - case x86_EDX: PUTDST16(m_RecompPos,0x0AD8); break; - case x86_ESI: PUTDST16(m_RecompPos,0x0ED8); break; - case x86_EDI: PUTDST16(m_RecompPos,0x0FD8); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } -} - -void CX86Ops::fpuMulQword(void *Variable, const char * VariableName) { - CPU_Message(" fmul ST(0), qword ptr [%s]", VariableName); - PUTDST16(m_RecompPos,0x0DDC); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::fpuMulQwordRegPointer(x86Reg x86Pointer) { - CPU_Message(" fmul ST(0), qword ptr [%s]",x86_Name(x86Pointer)); - switch (x86Pointer) { - case x86_EAX: PUTDST16(m_RecompPos,0x08DC); break; - case x86_EBX: PUTDST16(m_RecompPos,0x0BDC); break; - case x86_ECX: PUTDST16(m_RecompPos,0x09DC); break; - case x86_EDX: PUTDST16(m_RecompPos,0x0ADC); break; - case x86_ESI: PUTDST16(m_RecompPos,0x0EDC); break; - case x86_EDI: PUTDST16(m_RecompPos,0x0FDC); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } -} - -void CX86Ops::fpuMulReg(x86FpuValues x86reg) { - CPU_Message(" fmul ST(0), %s",fpu_Name(x86reg)); - switch (x86reg) { - case x86_ST0: PUTDST16(m_RecompPos,0xC8D8); break; - case x86_ST1: PUTDST16(m_RecompPos,0xC9D8); break; - case x86_ST2: PUTDST16(m_RecompPos,0xCAD8); break; - case x86_ST3: PUTDST16(m_RecompPos,0xCBD8); break; - case x86_ST4: PUTDST16(m_RecompPos,0xCCD8); break; - case x86_ST5: PUTDST16(m_RecompPos,0xCDD8); break; - case x86_ST6: PUTDST16(m_RecompPos,0xCED8); break; - case x86_ST7: PUTDST16(m_RecompPos,0xCFD8); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } -} - -void CX86Ops::fpuMulRegPop(x86FpuValues x86reg) { - CPU_Message(" fmulp ST(0), %s",fpu_Name(x86reg)); - switch (x86reg) { - case x86_ST0: PUTDST16(m_RecompPos,0xC8DE); break; - case x86_ST1: PUTDST16(m_RecompPos,0xC9DE); break; - case x86_ST2: PUTDST16(m_RecompPos,0xCADE); break; - case x86_ST3: PUTDST16(m_RecompPos,0xCBDE); break; - case x86_ST4: PUTDST16(m_RecompPos,0xCCDE); break; - case x86_ST5: PUTDST16(m_RecompPos,0xCDDE); break; - case x86_ST6: PUTDST16(m_RecompPos,0xCEDE); break; - case x86_ST7: PUTDST16(m_RecompPos,0xCFDE); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } -} - -void CX86Ops::fpuNeg(void) { - CPU_Message(" fchs ST(0)"); - PUTDST16(m_RecompPos,0xE0D9); -} - -void CX86Ops::fpuRound(void) { - CPU_Message(" frndint ST(0)"); - PUTDST16(m_RecompPos,0xFCD9); -} - -void CX86Ops::fpuSqrt(void) { - CPU_Message(" fsqrt ST(0)"); - PUTDST16(m_RecompPos,0xFAD9); -} - -void CX86Ops::fpuStoreControl(void *Variable, const char * VariableName) { - CPU_Message(" fnstcw [%s]",VariableName); - PUTDST16(m_RecompPos,0x3DD9); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::fpuStoreDword(int * StackPos,void *Variable, const char * VariableName, bool pop) { - CPU_Message(" fst%s dword ptr [%s]", m_fpupop[pop], VariableName); - - if (pop) - *StackPos = (*StackPos + 1) & 7; - - PUTDST16(m_RecompPos, pop ? 0x1DD9 : 0x15D9); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::fpuStoreDwordFromX86Reg(int * StackPos,x86Reg x86reg, bool pop) { - BYTE Command = 0; - - CPU_Message(" fst%s dword ptr [%s]", m_fpupop[pop], x86_Name(x86reg)); - - if (pop) - *StackPos = (*StackPos + 1) & 7; - - PUTDST8(m_RecompPos,0xD9); - - switch (x86reg) { - case x86_EAX: Command = 0x10; break; - case x86_EBX: Command = 0x13; break; - case x86_ECX: Command = 0x11; break; - case x86_EDX: Command = 0x12; break; - case x86_ESI: Command = 0x16; break; - case x86_EDI: Command = 0x17; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - PUTDST8(m_RecompPos, pop ? (Command + 0x8) : Command); -} - -void CX86Ops::fpuStoreDwordToN64Mem(int * StackPos,x86Reg x86reg, bool Pop) { - int s = Pop ? 0x0800 : 0; - - CPU_Message(" fst%s dword ptr [%s+N64mem]", m_fpupop[Pop], x86_Name(x86reg)); +void CX86Ops::Setae(x86Reg reg) +{ + CPU_Message(" setae %s",x86_ByteName(reg)); + PUTDST16(m_RecompPos,0x930F); + switch (reg) + { + case x86_EAX: PUTDST8(m_RecompPos,0xC0); break; + case x86_EBX: PUTDST8(m_RecompPos,0xC3); break; + case x86_ECX: PUTDST8(m_RecompPos,0xC1); break; + case x86_EDX: PUTDST8(m_RecompPos,0xC2); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::Setb(x86Reg reg) +{ + CPU_Message(" setb %s",x86_ByteName(reg)); + PUTDST16(m_RecompPos,0x920F); + switch (reg) + { + case x86_EAX: PUTDST8(m_RecompPos,0xC0); break; + case x86_EBX: PUTDST8(m_RecompPos,0xC3); break; + case x86_ECX: PUTDST8(m_RecompPos,0xC1); break; + case x86_EDX: PUTDST8(m_RecompPos,0xC2); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::SetbVariable(void * Variable, const char * VariableName) +{ + CPU_Message(" setb byte ptr [%s]",VariableName); + PUTDST16(m_RecompPos,0x920F); + PUTDST8(m_RecompPos,0x05); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::Setg(x86Reg reg) +{ + CPU_Message(" setg %s",x86_ByteName(reg)); + PUTDST16(m_RecompPos,0x9F0F); + switch (reg) + { + case x86_EAX: PUTDST8(m_RecompPos,0xC0); break; + case x86_EBX: PUTDST8(m_RecompPos,0xC3); break; + case x86_ECX: PUTDST8(m_RecompPos,0xC1); break; + case x86_EDX: PUTDST8(m_RecompPos,0xC2); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::SetgVariable(void * Variable, const char * VariableName) +{ + CPU_Message(" setg byte ptr [%s]",VariableName); + PUTDST16(m_RecompPos,0x9F0F); + PUTDST8(m_RecompPos,0x05); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::Setl(x86Reg reg) +{ + CPU_Message(" setl %s",x86_ByteName(reg)); + PUTDST16(m_RecompPos,0x9C0F); + switch (reg) + { + case x86_EAX: PUTDST8(m_RecompPos,0xC0); break; + case x86_EBX: PUTDST8(m_RecompPos,0xC3); break; + case x86_ECX: PUTDST8(m_RecompPos,0xC1); break; + case x86_EDX: PUTDST8(m_RecompPos,0xC2); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::SetlVariable(void * Variable, const char * VariableName) +{ + CPU_Message(" setl byte ptr [%s]",VariableName); + PUTDST16(m_RecompPos,0x9C0F); + PUTDST8(m_RecompPos,0x05); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::Setz(x86Reg reg) +{ + CPU_Message(" setz %s",x86_ByteName(reg)); + PUTDST16(m_RecompPos,0x940F); + switch (reg) + { + case x86_EAX: PUTDST8(m_RecompPos,0xC0); break; + case x86_EBX: PUTDST8(m_RecompPos,0xC3); break; + case x86_ECX: PUTDST8(m_RecompPos,0xC1); break; + case x86_EDX: PUTDST8(m_RecompPos,0xC2); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::Setnz(x86Reg reg) +{ + CPU_Message(" setnz %s",x86_ByteName(reg)); + PUTDST16(m_RecompPos,0x950F); + switch (reg) + { + case x86_EAX: PUTDST8(m_RecompPos,0xC0); break; + case x86_EBX: PUTDST8(m_RecompPos,0xC3); break; + case x86_ECX: PUTDST8(m_RecompPos,0xC1); break; + case x86_EDX: PUTDST8(m_RecompPos,0xC2); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::ShiftLeftDouble(x86Reg Destination, x86Reg Source) +{ + uint8_t s = 0xC0; + + CPU_Message(" shld %s, %s, cl", x86_Name(Destination),x86_Name(Source)); + PUTDST16(m_RecompPos,0xA50F); + + switch (Destination) + { + case x86_EAX: s |= 0x00; break; + case x86_EBX: s |= 0x03; break; + case x86_ECX: s |= 0x01; break; + case x86_EDX: s |= 0x02; break; + case x86_ESI: s |= 0x06; break; + case x86_EDI: s |= 0x07; break; + case x86_ESP: s |= 0x04; break; + case x86_EBP: s |= 0x05; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (Source) + { + case x86_EAX: s |= 0x00 << 3; break; + case x86_EBX: s |= 0x03 << 3; break; + case x86_ECX: s |= 0x01 << 3; break; + case x86_EDX: s |= 0x02 << 3; break; + case x86_ESI: s |= 0x06 << 3; break; + case x86_EDI: s |= 0x07 << 3; break; + case x86_ESP: s |= 0x04 << 3; break; + case x86_EBP: s |= 0x05 << 3; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + PUTDST8(m_RecompPos,s); +} + +void CX86Ops::ShiftLeftDoubleImmed(x86Reg Destination, x86Reg Source, uint8_t Immediate) +{ + uint8_t s = 0xC0; + + CPU_Message(" shld %s, %s, %Xh", x86_Name(Destination),x86_Name(Source), Immediate); + PUTDST16(m_RecompPos,0xA40F); + + switch (Destination) + { + case x86_EAX: s |= 0x00; break; + case x86_EBX: s |= 0x03; break; + case x86_ECX: s |= 0x01; break; + case x86_EDX: s |= 0x02; break; + case x86_ESI: s |= 0x06; break; + case x86_EDI: s |= 0x07; break; + case x86_ESP: s |= 0x04; break; + case x86_EBP: s |= 0x05; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (Source) + { + case x86_EAX: s |= 0x00 << 3; break; + case x86_EBX: s |= 0x03 << 3; break; + case x86_ECX: s |= 0x01 << 3; break; + case x86_EDX: s |= 0x02 << 3; break; + case x86_ESI: s |= 0x06 << 3; break; + case x86_EDI: s |= 0x07 << 3; break; + case x86_ESP: s |= 0x04 << 3; break; + case x86_EBP: s |= 0x05 << 3; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + PUTDST8(m_RecompPos,s); + PUTDST8(m_RecompPos,Immediate); +} + +void CX86Ops::ShiftLeftSign(x86Reg reg) +{ + CPU_Message(" shl %s, cl",x86_Name(reg)); + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0xE0D3); break; + case x86_EBX: PUTDST16(m_RecompPos,0xE3D3); break; + case x86_ECX: PUTDST16(m_RecompPos,0xE1D3); break; + case x86_EDX: PUTDST16(m_RecompPos,0xE2D3); break; + case x86_ESI: PUTDST16(m_RecompPos,0xE6D3); break; + case x86_EDI: PUTDST16(m_RecompPos,0xE7D3); break; + case x86_ESP: PUTDST16(m_RecompPos,0xE4D3); break; + case x86_EBP: PUTDST16(m_RecompPos,0xE5D3); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::ShiftLeftSignImmed(x86Reg reg, uint8_t Immediate) +{ + CPU_Message(" shl %s, %Xh",x86_Name(reg),Immediate); + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0xE0C1); break; + case x86_EBX: PUTDST16(m_RecompPos,0xE3C1); break; + case x86_ECX: PUTDST16(m_RecompPos,0xE1C1); break; + case x86_EDX: PUTDST16(m_RecompPos,0xE2C1); break; + case x86_ESI: PUTDST16(m_RecompPos,0xE6C1); break; + case x86_EDI: PUTDST16(m_RecompPos,0xE7C1); break; + case x86_ESP: PUTDST16(m_RecompPos,0xE4C1); break; + case x86_EBP: PUTDST16(m_RecompPos,0xE5C1); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST8(m_RecompPos,Immediate); +} + +void CX86Ops::ShiftRightSign(x86Reg reg) +{ + CPU_Message(" sar %s, cl",x86_Name(reg)); + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0xF8D3); break; + case x86_EBX: PUTDST16(m_RecompPos,0xFBD3); break; + case x86_ECX: PUTDST16(m_RecompPos,0xF9D3); break; + case x86_EDX: PUTDST16(m_RecompPos,0xFAD3); break; + case x86_ESI: PUTDST16(m_RecompPos,0xFED3); break; + case x86_EDI: PUTDST16(m_RecompPos,0xFFD3); break; + case x86_ESP: PUTDST16(m_RecompPos,0xFCD3); break; + case x86_EBP: PUTDST16(m_RecompPos,0xFDD3); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::ShiftRightSignImmed(x86Reg reg, uint8_t Immediate) +{ + CPU_Message(" sar %s, %Xh",x86_Name(reg),Immediate); + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0xF8C1); break; + case x86_EBX: PUTDST16(m_RecompPos,0xFBC1); break; + case x86_ECX: PUTDST16(m_RecompPos,0xF9C1); break; + case x86_EDX: PUTDST16(m_RecompPos,0xFAC1); break; + case x86_ESI: PUTDST16(m_RecompPos,0xFEC1); break; + case x86_EDI: PUTDST16(m_RecompPos,0xFFC1); break; + case x86_ESP: PUTDST16(m_RecompPos,0xFCC1); break; + case x86_EBP: PUTDST16(m_RecompPos,0xFDC1); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST8(m_RecompPos,Immediate); +} + +void CX86Ops::ShiftRightUnsign(x86Reg reg) +{ + CPU_Message(" shr %s, cl",x86_Name(reg)); + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0xE8D3); break; + case x86_EBX: PUTDST16(m_RecompPos,0xEBD3); break; + case x86_ECX: PUTDST16(m_RecompPos,0xE9D3); break; + case x86_EDX: PUTDST16(m_RecompPos,0xEAD3); break; + case x86_ESI: PUTDST16(m_RecompPos,0xEED3); break; + case x86_EDI: PUTDST16(m_RecompPos,0xEFD3); break; + case x86_ESP: PUTDST16(m_RecompPos,0xECD3); break; + case x86_EBP: PUTDST16(m_RecompPos,0xEDD3); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::ShiftRightDouble(x86Reg Destination, x86Reg Source) +{ + uint8_t s = 0xC0; + + CPU_Message(" shrd %s, %s, cl", x86_Name(Destination),x86_Name(Source)); + PUTDST16(m_RecompPos,0xAD0F); + + switch (Destination) + { + case x86_EAX: s |= 0x00; break; + case x86_EBX: s |= 0x03; break; + case x86_ECX: s |= 0x01; break; + case x86_EDX: s |= 0x02; break; + case x86_ESI: s |= 0x06; break; + case x86_EDI: s |= 0x07; break; + case x86_ESP: s |= 0x04; break; + case x86_EBP: s |= 0x05; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (Source) + { + case x86_EAX: s |= 0x00 << 3; break; + case x86_EBX: s |= 0x03 << 3; break; + case x86_ECX: s |= 0x01 << 3; break; + case x86_EDX: s |= 0x02 << 3; break; + case x86_ESI: s |= 0x06 << 3; break; + case x86_EDI: s |= 0x07 << 3; break; + case x86_ESP: s |= 0x04 << 3; break; + case x86_EBP: s |= 0x05 << 3; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + PUTDST8(m_RecompPos,s); +} + +void CX86Ops::ShiftRightDoubleImmed(x86Reg Destination, x86Reg Source, uint8_t Immediate) +{ + uint8_t s = 0xC0; + + CPU_Message(" shrd %s, %s, %Xh", x86_Name(Destination),x86_Name(Source), Immediate); + PUTDST16(m_RecompPos,0xAC0F); + + switch (Destination) + { + case x86_EAX: s |= 0x00; break; + case x86_EBX: s |= 0x03; break; + case x86_ECX: s |= 0x01; break; + case x86_EDX: s |= 0x02; break; + case x86_ESI: s |= 0x06; break; + case x86_EDI: s |= 0x07; break; + case x86_ESP: s |= 0x04; break; + case x86_EBP: s |= 0x05; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (Source) + { + case x86_EAX: s |= 0x00 << 3; break; + case x86_EBX: s |= 0x03 << 3; break; + case x86_ECX: s |= 0x01 << 3; break; + case x86_EDX: s |= 0x02 << 3; break; + case x86_ESI: s |= 0x06 << 3; break; + case x86_EDI: s |= 0x07 << 3; break; + case x86_ESP: s |= 0x04 << 3; break; + case x86_EBP: s |= 0x05 << 3; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + PUTDST8(m_RecompPos,s); + PUTDST8(m_RecompPos,Immediate); +} + +void CX86Ops::ShiftRightUnsignImmed(x86Reg reg, uint8_t Immediate) +{ + CPU_Message(" shr %s, %Xh",x86_Name(reg),Immediate); + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0xE8C1); break; + case x86_EBX: PUTDST16(m_RecompPos,0xEBC1); break; + case x86_ECX: PUTDST16(m_RecompPos,0xE9C1); break; + case x86_EDX: PUTDST16(m_RecompPos,0xEAC1); break; + case x86_ESI: PUTDST16(m_RecompPos,0xEEC1); break; + case x86_EDI: PUTDST16(m_RecompPos,0xEFC1); break; + case x86_ESP: PUTDST16(m_RecompPos,0xECC1); break; + case x86_EBP: PUTDST16(m_RecompPos,0xEDC1); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST8(m_RecompPos,Immediate); +} + +void CX86Ops::SbbConstFromX86Reg (x86Reg reg, uint32_t Const) +{ + CPU_Message(" sbb %s, %Xh",x86_Name(reg),Const); + if ((Const & 0xFFFFFF80) != 0 && (Const & 0xFFFFFF80) != 0xFFFFFF80) + { + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0xD881); break; + case x86_EBX: PUTDST16(m_RecompPos,0xDB81); break; + case x86_ECX: PUTDST16(m_RecompPos,0xD981); break; + case x86_EDX: PUTDST16(m_RecompPos,0xDA81); break; + case x86_ESI: PUTDST16(m_RecompPos,0xDE81); break; + case x86_EDI: PUTDST16(m_RecompPos,0xDF81); break; + case x86_ESP: PUTDST16(m_RecompPos,0xDC81); break; + case x86_EBP: PUTDST16(m_RecompPos,0xDD81); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos, Const); + } + else + { + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0xD883); break; + case x86_EBX: PUTDST16(m_RecompPos,0xDB83); break; + case x86_ECX: PUTDST16(m_RecompPos,0xD983); break; + case x86_EDX: PUTDST16(m_RecompPos,0xDA83); break; + case x86_ESI: PUTDST16(m_RecompPos,0xDE83); break; + case x86_EDI: PUTDST16(m_RecompPos,0xDF83); break; + case x86_ESP: PUTDST16(m_RecompPos,0xDC83); break; + case x86_EBP: PUTDST16(m_RecompPos,0xDD83); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST8(m_RecompPos, Const); + } +} + +void CX86Ops::SbbVariableFromX86reg(x86Reg reg, void * Variable, const char * VariableName) +{ + CPU_Message(" sbb %s, dword ptr [%s]",x86_Name(reg),VariableName); + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x051B); break; + case x86_EBX: PUTDST16(m_RecompPos,0x1D1B); break; + case x86_ECX: PUTDST16(m_RecompPos,0x0D1B); break; + case x86_EDX: PUTDST16(m_RecompPos,0x151B); break; + case x86_ESI: PUTDST16(m_RecompPos,0x351B); break; + case x86_EDI: PUTDST16(m_RecompPos,0x3D1B); break; + case x86_ESP: PUTDST16(m_RecompPos,0x251B); break; + case x86_EBP: PUTDST16(m_RecompPos,0x2D1B); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::SbbX86RegToX86Reg(x86Reg Destination, x86Reg Source) +{ + uint16_t x86Command = 0; + CPU_Message(" sbb %s, %s",x86_Name(Destination),x86_Name(Source)); + switch (Source) + { + case x86_EAX: x86Command = 0x001B; break; + case x86_EBX: x86Command = 0x031B; break; + case x86_ECX: x86Command = 0x011B; break; + case x86_EDX: x86Command = 0x021B; break; + case x86_ESI: x86Command = 0x061B; break; + case x86_EDI: x86Command = 0x071B; break; + case x86_ESP: x86Command = 0x041B; break; + case x86_EBP: x86Command = 0x051B; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + switch (Destination) + { + case x86_EAX: x86Command += 0xC000; break; + case x86_EBX: x86Command += 0xD800; break; + case x86_ECX: x86Command += 0xC800; break; + case x86_EDX: x86Command += 0xD000; break; + case x86_ESI: x86Command += 0xF000; break; + case x86_EDI: x86Command += 0xF800; break; + case x86_ESP: x86Command += 0xE000; break; + case x86_EBP: x86Command += 0xE800; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST16(m_RecompPos,x86Command); +} + +void CX86Ops::SubConstFromVariable (uint32_t Const, void *Variable, const char * VariableName) +{ + CPU_Message(" sub dword ptr [%s], 0x%X",VariableName, Const); + + PUTDST16(m_RecompPos,0x2D81); + PUTDST32(m_RecompPos,Variable); + PUTDST32(m_RecompPos,Const); +} + +void CX86Ops::SubConstFromX86Reg (x86Reg reg, uint32_t Const) +{ + CPU_Message(" sub %s, %Xh",x86_Name(reg),Const); + if ((Const & 0xFFFFFF80) != 0 && (Const & 0xFFFFFF80) != 0xFFFFFF80) + { + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0xE881); break; + case x86_EBX: PUTDST16(m_RecompPos,0xEB81); break; + case x86_ECX: PUTDST16(m_RecompPos,0xE981); break; + case x86_EDX: PUTDST16(m_RecompPos,0xEA81); break; + case x86_ESI: PUTDST16(m_RecompPos,0xEE81); break; + case x86_EDI: PUTDST16(m_RecompPos,0xEF81); break; + case x86_ESP: PUTDST16(m_RecompPos,0xEC81); break; + case x86_EBP: PUTDST16(m_RecompPos,0xED81); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos, Const); + } + else + { + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0xE883); break; + case x86_EBX: PUTDST16(m_RecompPos,0xEB83); break; + case x86_ECX: PUTDST16(m_RecompPos,0xE983); break; + case x86_EDX: PUTDST16(m_RecompPos,0xEA83); break; + case x86_ESI: PUTDST16(m_RecompPos,0xEE83); break; + case x86_EDI: PUTDST16(m_RecompPos,0xEF83); break; + case x86_ESP: PUTDST16(m_RecompPos,0xEC83); break; + case x86_EBP: PUTDST16(m_RecompPos,0xED83); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST8(m_RecompPos, Const); + } +} + +void CX86Ops::SubVariableFromX86reg(x86Reg reg, void * Variable, const char * VariableName) +{ + CPU_Message(" sub %s, dword ptr [%s]",x86_Name(reg),VariableName); + + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x052B); break; + case x86_EBX: PUTDST16(m_RecompPos,0x1D2B); break; + case x86_ECX: PUTDST16(m_RecompPos,0x0D2B); break; + case x86_EDX: PUTDST16(m_RecompPos,0x152B); break; + case x86_ESI: PUTDST16(m_RecompPos,0x352B); break; + case x86_EDI: PUTDST16(m_RecompPos,0x3D2B); break; + case x86_ESP: PUTDST16(m_RecompPos,0x252B); break; + case x86_EBP: PUTDST16(m_RecompPos,0x2D2B); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::SubX86RegToX86Reg(x86Reg Destination, x86Reg Source) +{ + uint16_t x86Command = 0; + CPU_Message(" sub %s, %s",x86_Name(Destination),x86_Name(Source)); + + switch (Source) + { + case x86_EAX: x86Command = 0x002B; break; + case x86_EBX: x86Command = 0x032B; break; + case x86_ECX: x86Command = 0x012B; break; + case x86_EDX: x86Command = 0x022B; break; + case x86_ESI: x86Command = 0x062B; break; + case x86_EDI: x86Command = 0x072B; break; + case x86_ESP: x86Command = 0x042B; break; + case x86_EBP: x86Command = 0x052B; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + switch (Destination) + { + case x86_EAX: x86Command += 0xC000; break; + case x86_EBX: x86Command += 0xD800; break; + case x86_ECX: x86Command += 0xC800; break; + case x86_EDX: x86Command += 0xD000; break; + case x86_ESI: x86Command += 0xF000; break; + case x86_EDI: x86Command += 0xF800; break; + case x86_ESP: x86Command += 0xE000; break; + case x86_EBP: x86Command += 0xE800; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST16(m_RecompPos,x86Command); +} + +void CX86Ops::TestConstToX86Reg(uint32_t Const, x86Reg reg) +{ + CPU_Message(" test %s, 0x%X",x86_Name(reg), Const); + + switch (reg) + { + case x86_EAX: PUTDST8 (m_RecompPos,0xA9); break; + case x86_EBX: PUTDST16(m_RecompPos,0xC3F7); break; + case x86_ECX: PUTDST16(m_RecompPos,0xC1F7); break; + case x86_EDX: PUTDST16(m_RecompPos,0xC2F7); break; + case x86_ESI: PUTDST16(m_RecompPos,0xC6F7); break; + case x86_EDI: PUTDST16(m_RecompPos,0xC7F7); break; + case x86_ESP: PUTDST16(m_RecompPos,0xC4F7); break; + case x86_EBP: PUTDST16(m_RecompPos,0xC5F7); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,Const); +} + +void CX86Ops::TestVariable(uint32_t Const, void * Variable, const char * VariableName) +{ + CPU_Message(" test dword ptr ds:[%s], 0x%X",VariableName, Const); + PUTDST16(m_RecompPos,0x05F7); + PUTDST32(m_RecompPos,Variable); + PUTDST32(m_RecompPos,Const); +} + +void CX86Ops::TestX86RegToX86Reg(x86Reg Destination, x86Reg Source) +{ + uint16_t x86Command = 0; + CPU_Message(" test %s, %s",x86_Name(Destination),x86_Name(Source)); + switch (Source) + { + case x86_EAX: x86Command = 0x0085; break; + case x86_EBX: x86Command = 0x0385; break; + case x86_ECX: x86Command = 0x0185; break; + case x86_EDX: x86Command = 0x0285; break; + case x86_ESI: x86Command = 0x0685; break; + case x86_EDI: x86Command = 0x0785; break; + case x86_ESP: x86Command = 0x0485; break; + case x86_EBP: x86Command = 0x0585; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + switch (Destination) + { + case x86_EAX: x86Command += 0xC000; break; + case x86_EBX: x86Command += 0xD800; break; + case x86_ECX: x86Command += 0xC800; break; + case x86_EDX: x86Command += 0xD000; break; + case x86_ESI: x86Command += 0xF000; break; + case x86_EDI: x86Command += 0xF800; break; + case x86_ESP: x86Command += 0xE000; break; + case x86_EBP: x86Command += 0xE800; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST16(m_RecompPos,x86Command); +} + +void CX86Ops::XorConstToX86Reg(x86Reg reg, uint32_t Const) +{ + CPU_Message(" xor %s, %Xh",x86_Name(reg),Const); + if ((Const & 0xFFFFFF80) != 0 && (Const & 0xFFFFFF80) != 0xFFFFFF80) + { + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0xF081); break; + case x86_EBX: PUTDST16(m_RecompPos,0xF381); break; + case x86_ECX: PUTDST16(m_RecompPos,0xF181); break; + case x86_EDX: PUTDST16(m_RecompPos,0xF281); break; + case x86_ESI: PUTDST16(m_RecompPos,0xF681); break; + case x86_EDI: PUTDST16(m_RecompPos,0xF781); break; + case x86_ESP: PUTDST16(m_RecompPos,0xF481); break; + case x86_EBP: PUTDST16(m_RecompPos,0xF581); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos, Const); + } + else + { + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0xF083); break; + case x86_EBX: PUTDST16(m_RecompPos,0xF383); break; + case x86_ECX: PUTDST16(m_RecompPos,0xF183); break; + case x86_EDX: PUTDST16(m_RecompPos,0xF283); break; + case x86_ESI: PUTDST16(m_RecompPos,0xF683); break; + case x86_EDI: PUTDST16(m_RecompPos,0xF783); break; + case x86_ESP: PUTDST16(m_RecompPos,0xF483); break; + case x86_EBP: PUTDST16(m_RecompPos,0xF583); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST8(m_RecompPos, Const); + } +} + +void CX86Ops::XorX86RegToX86Reg(x86Reg Source, x86Reg Destination) +{ + uint16_t x86Command = 0; + + CPU_Message(" xor %s, %s",x86_Name(Source),x86_Name(Destination)); + + switch (Source) + { + case x86_EAX: x86Command = 0x0031; break; + case x86_EBX: x86Command = 0x0331; break; + case x86_ECX: x86Command = 0x0131; break; + case x86_EDX: x86Command = 0x0231; break; + case x86_ESI: x86Command = 0x0631; break; + case x86_EDI: x86Command = 0x0731; break; + case x86_ESP: x86Command = 0x0431; break; + case x86_EBP: x86Command = 0x0531; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + switch (Destination) + { + case x86_EAX: x86Command += 0xC000; break; + case x86_EBX: x86Command += 0xD800; break; + case x86_ECX: x86Command += 0xC800; break; + case x86_EDX: x86Command += 0xD000; break; + case x86_ESI: x86Command += 0xF000; break; + case x86_EDI: x86Command += 0xF800; break; + case x86_ESP: x86Command += 0xE000; break; + case x86_EBP: x86Command += 0xE800; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST16(m_RecompPos,x86Command); +} + +void CX86Ops::XorVariableToX86reg(void *Variable, const char * VariableName, x86Reg reg) +{ + CPU_Message(" Xor %s, dword ptr [%s]",x86_Name(reg),VariableName); + + switch (reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x0533); break; + case x86_EBX: PUTDST16(m_RecompPos,0x1D33); break; + case x86_ECX: PUTDST16(m_RecompPos,0x0D33); break; + case x86_EDX: PUTDST16(m_RecompPos,0x1533); break; + case x86_ESI: PUTDST16(m_RecompPos,0x3533); break; + case x86_EDI: PUTDST16(m_RecompPos,0x3D33); break; + case x86_ESP: PUTDST16(m_RecompPos,0x2533); break; + case x86_EBP: PUTDST16(m_RecompPos,0x2D33); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::fpuAbs(void) +{ + CPU_Message(" fabs ST(0)"); + PUTDST16(m_RecompPos,0xE1D9); +} + +void CX86Ops::fpuAddDword(void *Variable, const char * VariableName) +{ + CPU_Message(" fadd ST(0), dword ptr [%s]", VariableName); + PUTDST16(m_RecompPos,0x05D8); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::fpuAddDwordRegPointer(x86Reg x86Pointer) +{ + CPU_Message(" fadd ST(0), dword ptr [%s]",x86_Name(x86Pointer)); + switch (x86Pointer) + { + case x86_EAX: PUTDST16(m_RecompPos,0x00D8); break; + case x86_EBX: PUTDST16(m_RecompPos,0x03D8); break; + case x86_ECX: PUTDST16(m_RecompPos,0x01D8); break; + case x86_EDX: PUTDST16(m_RecompPos,0x02D8); break; + case x86_ESI: PUTDST16(m_RecompPos,0x06D8); break; + case x86_EDI: PUTDST16(m_RecompPos,0x07D8); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } +} + +void CX86Ops::fpuAddQword(void *Variable, const char * VariableName) +{ + CPU_Message(" fadd ST(0), qword ptr [%s]", VariableName); + PUTDST16(m_RecompPos,0x05DC); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::fpuAddQwordRegPointer(x86Reg x86Pointer) +{ + CPU_Message(" fadd ST(0), qword ptr [%s]",x86_Name(x86Pointer)); + switch (x86Pointer) + { + case x86_EAX: PUTDST16(m_RecompPos,0x00DC); break; + case x86_EBX: PUTDST16(m_RecompPos,0x03DC); break; + case x86_ECX: PUTDST16(m_RecompPos,0x01DC); break; + case x86_EDX: PUTDST16(m_RecompPos,0x02DC); break; + case x86_ESI: PUTDST16(m_RecompPos,0x06DC); break; + case x86_EDI: PUTDST16(m_RecompPos,0x07DC); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } +} + +void CX86Ops::fpuAddReg(x86FpuValues x86reg) +{ + CPU_Message(" fadd ST(0), %s",fpu_Name(x86reg)); + switch (x86reg) { + case x86_ST0: PUTDST16(m_RecompPos,0xC0D8); break; + case x86_ST1: PUTDST16(m_RecompPos,0xC1D8); break; + case x86_ST2: PUTDST16(m_RecompPos,0xC2D8); break; + case x86_ST3: PUTDST16(m_RecompPos,0xC3D8); break; + case x86_ST4: PUTDST16(m_RecompPos,0xC4D8); break; + case x86_ST5: PUTDST16(m_RecompPos,0xC5D8); break; + case x86_ST6: PUTDST16(m_RecompPos,0xC6D8); break; + case x86_ST7: PUTDST16(m_RecompPos,0xC7D8); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } +} + +void CX86Ops::fpuAddRegPop(int * StackPos, x86FpuValues reg) +{ + CPU_Message(" faddp ST(0), %s",fpu_Name(reg)); + *StackPos = (*StackPos + 1) & 7; + switch (reg) + { + case x86_ST0: PUTDST16(m_RecompPos,0xC0DE); break; + case x86_ST1: PUTDST16(m_RecompPos,0xC1DE); break; + case x86_ST2: PUTDST16(m_RecompPos,0xC2DE); break; + case x86_ST3: PUTDST16(m_RecompPos,0xC3DE); break; + case x86_ST4: PUTDST16(m_RecompPos,0xC4DE); break; + case x86_ST5: PUTDST16(m_RecompPos,0xC5DE); break; + case x86_ST6: PUTDST16(m_RecompPos,0xC6DE); break; + case x86_ST7: PUTDST16(m_RecompPos,0xC7DE); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } +} + +void CX86Ops::fpuComDword(void *Variable, const char * VariableName, bool Pop) +{ + CPU_Message(" fcom%s ST(0), dword ptr [%s]", m_fpupop[Pop], VariableName); + PUTDST16(m_RecompPos, Pop ? 0x1DD8 : 0x15D8); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::fpuComDwordRegPointer(x86Reg x86Pointer, bool Pop) +{ + uint16_t x86Command; + + CPU_Message(" fcom%s ST(0), dword ptr [%s]",m_fpupop[Pop],x86_Name(x86Pointer)); + switch (x86Pointer) + { + case x86_EAX: x86Command = 0x10D8; break; + case x86_EBX: x86Command = 0x13D8; break; + case x86_ECX: x86Command = 0x11D8; break; + case x86_EDX: x86Command = 0x12D8; break; + case x86_ESI: x86Command = 0x16D8; break; + case x86_EDI: x86Command = 0x17D8; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + if (Pop) + { + x86Command |= 0x0800; + } + + PUTDST16(m_RecompPos,x86Command); +} + +void CX86Ops::fpuComQword(void *Variable, const char * VariableName, bool Pop) +{ + CPU_Message(" fcom%s ST(0), qword ptr [%s]", m_fpupop[Pop], VariableName); + PUTDST16(m_RecompPos, Pop ? 0x1DDC : 0x15DC); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::fpuComQwordRegPointer(x86Reg x86Pointer, bool Pop) +{ + uint16_t x86Command; + + CPU_Message(" fcom%s ST(0), qword ptr [%s]",m_fpupop[Pop],x86_Name(x86Pointer)); + switch (x86Pointer) + { + case x86_EAX: x86Command = 0x10DC; break; + case x86_EBX: x86Command = 0x13DC; break; + case x86_ECX: x86Command = 0x11DC; break; + case x86_EDX: x86Command = 0x12DC; break; + case x86_ESI: x86Command = 0x16DC; break; + case x86_EDI: x86Command = 0x17DC; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + if (Pop) + { + x86Command |= 0x0800; + } + + PUTDST16(m_RecompPos,x86Command); +} + +void CX86Ops::fpuComReg(x86FpuValues x86reg, bool Pop) +{ + int s = Pop ? 0x0800 : 0x0000; + CPU_Message(" fcom%s ST(0), %s", m_fpupop[Pop], fpu_Name(x86reg)); + + switch (x86reg) + { + case x86_ST0: PUTDST16(m_RecompPos,0xD0D8|s); break; + case x86_ST1: PUTDST16(m_RecompPos,0xD1D8|s); break; + case x86_ST2: PUTDST16(m_RecompPos,0xD2D8|s); break; + case x86_ST3: PUTDST16(m_RecompPos,0xD3D8|s); break; + case x86_ST4: PUTDST16(m_RecompPos,0xD4D8|s); break; + case x86_ST5: PUTDST16(m_RecompPos,0xD5D8|s); break; + case x86_ST6: PUTDST16(m_RecompPos,0xD6D8|s); break; + case x86_ST7: PUTDST16(m_RecompPos,0xD7D8|s); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } +} + +void CX86Ops::fpuDivDword(void *Variable, const char * VariableName) +{ + CPU_Message(" fdiv ST(0), dword ptr [%s]", VariableName); + PUTDST16(m_RecompPos,0x35D8); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::fpuDivDwordRegPointer(x86Reg x86Pointer) +{ + CPU_Message(" fdiv ST(0), dword ptr [%s]",x86_Name(x86Pointer)); + switch (x86Pointer) + { + case x86_EAX: PUTDST16(m_RecompPos,0x30D8); break; + case x86_EBX: PUTDST16(m_RecompPos,0x33D8); break; + case x86_ECX: PUTDST16(m_RecompPos,0x31D8); break; + case x86_EDX: PUTDST16(m_RecompPos,0x32D8); break; + case x86_ESI: PUTDST16(m_RecompPos,0x36D8); break; + case x86_EDI: PUTDST16(m_RecompPos,0x37D8); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } +} + +void CX86Ops::fpuDivQword(void *Variable, const char * VariableName) +{ + CPU_Message(" fdiv ST(0), qword ptr [%s]", VariableName); + PUTDST16(m_RecompPos,0x35DC); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::fpuDivQwordRegPointer(x86Reg x86Pointer) +{ + CPU_Message(" fdiv ST(0), qword ptr [%s]",x86_Name(x86Pointer)); + switch (x86Pointer) + { + case x86_EAX: PUTDST16(m_RecompPos,0x30DC); break; + case x86_EBX: PUTDST16(m_RecompPos,0x33DC); break; + case x86_ECX: PUTDST16(m_RecompPos,0x31DC); break; + case x86_EDX: PUTDST16(m_RecompPos,0x32DC); break; + case x86_ESI: PUTDST16(m_RecompPos,0x36DC); break; + case x86_EDI: PUTDST16(m_RecompPos,0x37DC); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } +} + +void CX86Ops::fpuDivReg(x86FpuValues Reg) +{ + CPU_Message(" fdiv ST(0), %s", fpu_Name(Reg)); + switch (Reg) + { + case x86_ST0: PUTDST16(m_RecompPos,0xF0D8); break; + case x86_ST1: PUTDST16(m_RecompPos,0xF1D8); break; + case x86_ST2: PUTDST16(m_RecompPos,0xF2D8); break; + case x86_ST3: PUTDST16(m_RecompPos,0xF3D8); break; + case x86_ST4: PUTDST16(m_RecompPos,0xF4D8); break; + case x86_ST5: PUTDST16(m_RecompPos,0xF5D8); break; + case x86_ST6: PUTDST16(m_RecompPos,0xF6D8); break; + case x86_ST7: PUTDST16(m_RecompPos,0xF7D8); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } +} + +void CX86Ops::fpuDivRegPop(x86FpuValues reg) +{ + CPU_Message(" fdivp ST(0), %s",fpu_Name(reg)); + switch (reg) + { + case x86_ST0: PUTDST16(m_RecompPos,0xF8DE); break; + case x86_ST1: PUTDST16(m_RecompPos,0xF9DE); break; + case x86_ST2: PUTDST16(m_RecompPos,0xFADE); break; + case x86_ST3: PUTDST16(m_RecompPos,0xFBDE); break; + case x86_ST4: PUTDST16(m_RecompPos,0xFCDE); break; + case x86_ST5: PUTDST16(m_RecompPos,0xFDDE); break; + case x86_ST6: PUTDST16(m_RecompPos,0xFEDE); break; + case x86_ST7: PUTDST16(m_RecompPos,0xFFDE); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } +} + +void CX86Ops::fpuExchange(x86FpuValues Reg) +{ + CPU_Message(" fxch ST(0), %s",fpu_Name(Reg)); + switch (Reg) + { + case x86_ST0: PUTDST16(m_RecompPos,0xC8D9); break; + case x86_ST1: PUTDST16(m_RecompPos,0xC9D9); break; + case x86_ST2: PUTDST16(m_RecompPos,0xCAD9); break; + case x86_ST3: PUTDST16(m_RecompPos,0xCBD9); break; + case x86_ST4: PUTDST16(m_RecompPos,0xCCD9); break; + case x86_ST5: PUTDST16(m_RecompPos,0xCDD9); break; + case x86_ST6: PUTDST16(m_RecompPos,0xCED9); break; + case x86_ST7: PUTDST16(m_RecompPos,0xCFD9); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } +} + +void CX86Ops::fpuFree(x86FpuValues Reg) +{ + CPU_Message(" ffree %s",fpu_Name(Reg)); + switch (Reg) + { + case x86_ST0: PUTDST16(m_RecompPos,0xC0DD); break; + case x86_ST1: PUTDST16(m_RecompPos,0xC1DD); break; + case x86_ST2: PUTDST16(m_RecompPos,0xC2DD); break; + case x86_ST3: PUTDST16(m_RecompPos,0xC3DD); break; + case x86_ST4: PUTDST16(m_RecompPos,0xC4DD); break; + case x86_ST5: PUTDST16(m_RecompPos,0xC5DD); break; + case x86_ST6: PUTDST16(m_RecompPos,0xC6DD); break; + case x86_ST7: PUTDST16(m_RecompPos,0xC7DD); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } +} + +void CX86Ops::fpuDecStack(int * StackPos) +{ + CPU_Message(" fdecstp"); + *StackPos = (*StackPos - 1) & 7; + PUTDST16(m_RecompPos,0xF6D9); +} + +void CX86Ops::fpuIncStack(int * StackPos) +{ + CPU_Message(" fincstp"); + *StackPos = (*StackPos + 1) & 7; + PUTDST16(m_RecompPos,0xF7D9); +} + +void CX86Ops::fpuLoadControl(void *Variable, const char * VariableName) +{ + CPU_Message(" fldcw [%s]",VariableName); + PUTDST16(m_RecompPos,0x2DD9); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::fpuLoadDword(int * StackPos,void *Variable, const char * VariableName) +{ + CPU_Message(" fld dword ptr [%s]",VariableName); + *StackPos = (*StackPos - 1) & 7; + PUTDST16(m_RecompPos,0x05D9); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::fpuLoadDwordFromX86Reg(int * StackPos, x86Reg x86reg) +{ + CPU_Message(" fld dword ptr [%s]",x86_Name(x86reg)); + *StackPos = (*StackPos - 1) & 7; + PUTDST8(m_RecompPos,0xD9); + switch (x86reg) + { + case x86_EAX: PUTDST8(m_RecompPos,0x00); break; + case x86_EBX: PUTDST8(m_RecompPos,0x03); break; + case x86_ECX: PUTDST8(m_RecompPos,0x01); break; + case x86_EDX: PUTDST8(m_RecompPos,0x02); break; + case x86_ESI: PUTDST8(m_RecompPos,0x06); break; + case x86_EDI: PUTDST8(m_RecompPos,0x07); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::fpuLoadDwordFromN64Mem(int * StackPos,x86Reg x86reg) +{ + CPU_Message(" fld dword ptr [%s+N64mem]",x86_Name(x86reg)); + *StackPos = (*StackPos - 1) & 7; + switch (x86reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x80D9); break; + case x86_EBX: PUTDST16(m_RecompPos,0x83D9); break; + case x86_ECX: PUTDST16(m_RecompPos,0x81D9); break; + case x86_EDX: PUTDST16(m_RecompPos,0x82D9); break; + case x86_ESI: PUTDST16(m_RecompPos,0x86D9); break; + case x86_EDI: PUTDST16(m_RecompPos,0x87D9); break; + case x86_EBP: PUTDST16(m_RecompPos,0x85D9); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,g_MMU->Rdram()); +} + +void CX86Ops::fpuLoadInt32bFromN64Mem(int * StackPos,x86Reg x86reg) +{ + CPU_Message(" fild dword ptr [%s+N64mem]",x86_Name(x86reg)); + *StackPos = (*StackPos - 1) & 7; + switch (x86reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x80DB); break; + case x86_EBX: PUTDST16(m_RecompPos,0x83DB); break; + case x86_ECX: PUTDST16(m_RecompPos,0x81DB); break; + case x86_EDX: PUTDST16(m_RecompPos,0x82DB); break; + case x86_ESI: PUTDST16(m_RecompPos,0x86DB); break; + case x86_EDI: PUTDST16(m_RecompPos,0x87DB); break; + case x86_EBP: PUTDST16(m_RecompPos,0x85DB); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,g_MMU->Rdram()); +} + +void CX86Ops::fpuLoadIntegerDword(int * StackPos,void *Variable, const char * VariableName) +{ + CPU_Message(" fild dword ptr [%s]",VariableName); + *StackPos = (*StackPos - 1) & 7; + PUTDST16(m_RecompPos,0x05DB); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::fpuLoadIntegerDwordFromX86Reg(int * StackPos,x86Reg x86reg) +{ + CPU_Message(" fild dword ptr [%s]",x86_Name(x86reg)); + *StackPos = (*StackPos - 1) & 7; + PUTDST8(m_RecompPos,0xDB); + switch (x86reg) + { + case x86_EAX: PUTDST8(m_RecompPos,0x00); break; + case x86_EBX: PUTDST8(m_RecompPos,0x03); break; + case x86_ECX: PUTDST8(m_RecompPos,0x01); break; + case x86_EDX: PUTDST8(m_RecompPos,0x02); break; + case x86_ESI: PUTDST8(m_RecompPos,0x06); break; + case x86_EDI: PUTDST8(m_RecompPos,0x07); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::fpuLoadIntegerQword(int * StackPos,void *Variable, const char * VariableName) +{ + CPU_Message(" fild qword ptr [%s]",VariableName); + *StackPos = (*StackPos - 1) & 7; + PUTDST16(m_RecompPos,0x2DDF); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::fpuLoadIntegerQwordFromX86Reg(int * StackPos,x86Reg x86reg) +{ + CPU_Message(" fild qword ptr [%s]",x86_Name(x86reg)); + *StackPos = (*StackPos - 1) & 7; + PUTDST8(m_RecompPos,0xDF); + switch (x86reg) + { + case x86_EAX: PUTDST8(m_RecompPos,0x28); break; + case x86_EBX: PUTDST8(m_RecompPos,0x2B); break; + case x86_ECX: PUTDST8(m_RecompPos,0x29); break; + case x86_EDX: PUTDST8(m_RecompPos,0x2A); break; + case x86_ESI: PUTDST8(m_RecompPos,0x2E); break; + case x86_EDI: PUTDST8(m_RecompPos,0x2F); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::fpuLoadQword(int * StackPos,void *Variable, const char * VariableName) +{ + CPU_Message(" fld qword ptr [%s]",VariableName); + *StackPos = (*StackPos - 1) & 7; + PUTDST16(m_RecompPos,0x05DD); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::fpuLoadQwordFromX86Reg(int * StackPos, x86Reg x86reg) +{ + CPU_Message(" fld qword ptr [%s]",x86_Name(x86reg)); + *StackPos = (*StackPos - 1) & 7; + PUTDST8(m_RecompPos,0xDD); + switch (x86reg) + { + case x86_EAX: PUTDST8(m_RecompPos,0x00); break; + case x86_EBX: PUTDST8(m_RecompPos,0x03); break; + case x86_ECX: PUTDST8(m_RecompPos,0x01); break; + case x86_EDX: PUTDST8(m_RecompPos,0x02); break; + case x86_ESI: PUTDST8(m_RecompPos,0x06); break; + case x86_EDI: PUTDST8(m_RecompPos,0x07); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::fpuLoadQwordFromN64Mem(int * StackPos,x86Reg x86reg) +{ + CPU_Message(" fld qword ptr [%s+N64mem]",x86_Name(x86reg)); + *StackPos = (*StackPos - 1) & 7; + switch (x86reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x80DD); break; + case x86_EBX: PUTDST16(m_RecompPos,0x83DD); break; + case x86_ECX: PUTDST16(m_RecompPos,0x81DD); break; + case x86_EDX: PUTDST16(m_RecompPos,0x82DD); break; + case x86_ESI: PUTDST16(m_RecompPos,0x86DD); break; + case x86_EDI: PUTDST16(m_RecompPos,0x87DD); break; + case x86_EBP: PUTDST16(m_RecompPos,0x85DD); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + PUTDST32(m_RecompPos,g_MMU->Rdram()); +} + +void CX86Ops::fpuLoadReg(int * StackPos,x86FpuValues Reg) +{ + CPU_Message(" fld ST(0), %s",fpu_Name(Reg)); + *StackPos = (*StackPos - 1) & 7; + switch (Reg) + { + case x86_ST0: PUTDST16(m_RecompPos,0xC0D9); break; + case x86_ST1: PUTDST16(m_RecompPos,0xC1D9); break; + case x86_ST2: PUTDST16(m_RecompPos,0xC2D9); break; + case x86_ST3: PUTDST16(m_RecompPos,0xC3D9); break; + case x86_ST4: PUTDST16(m_RecompPos,0xC4D9); break; + case x86_ST5: PUTDST16(m_RecompPos,0xC5D9); break; + case x86_ST6: PUTDST16(m_RecompPos,0xC6D9); break; + case x86_ST7: PUTDST16(m_RecompPos,0xC7D9); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } +} + +void CX86Ops::fpuMulDword(void *Variable, const char * VariableName) +{ + CPU_Message(" fmul ST(0), dword ptr [%s]", VariableName); + PUTDST16(m_RecompPos,0x0DD8); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::fpuMulDwordRegPointer(x86Reg x86Pointer) +{ + CPU_Message(" fmul ST(0), dword ptr [%s]",x86_Name(x86Pointer)); + switch (x86Pointer) + { + case x86_EAX: PUTDST16(m_RecompPos,0x08D8); break; + case x86_EBX: PUTDST16(m_RecompPos,0x0BD8); break; + case x86_ECX: PUTDST16(m_RecompPos,0x09D8); break; + case x86_EDX: PUTDST16(m_RecompPos,0x0AD8); break; + case x86_ESI: PUTDST16(m_RecompPos,0x0ED8); break; + case x86_EDI: PUTDST16(m_RecompPos,0x0FD8); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } +} + +void CX86Ops::fpuMulQword(void *Variable, const char * VariableName) +{ + CPU_Message(" fmul ST(0), qword ptr [%s]", VariableName); + PUTDST16(m_RecompPos,0x0DDC); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::fpuMulQwordRegPointer(x86Reg x86Pointer) +{ + CPU_Message(" fmul ST(0), qword ptr [%s]",x86_Name(x86Pointer)); + switch (x86Pointer) + { + case x86_EAX: PUTDST16(m_RecompPos,0x08DC); break; + case x86_EBX: PUTDST16(m_RecompPos,0x0BDC); break; + case x86_ECX: PUTDST16(m_RecompPos,0x09DC); break; + case x86_EDX: PUTDST16(m_RecompPos,0x0ADC); break; + case x86_ESI: PUTDST16(m_RecompPos,0x0EDC); break; + case x86_EDI: PUTDST16(m_RecompPos,0x0FDC); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } +} + +void CX86Ops::fpuMulReg(x86FpuValues x86reg) +{ + CPU_Message(" fmul ST(0), %s",fpu_Name(x86reg)); + switch (x86reg) + { + case x86_ST0: PUTDST16(m_RecompPos,0xC8D8); break; + case x86_ST1: PUTDST16(m_RecompPos,0xC9D8); break; + case x86_ST2: PUTDST16(m_RecompPos,0xCAD8); break; + case x86_ST3: PUTDST16(m_RecompPos,0xCBD8); break; + case x86_ST4: PUTDST16(m_RecompPos,0xCCD8); break; + case x86_ST5: PUTDST16(m_RecompPos,0xCDD8); break; + case x86_ST6: PUTDST16(m_RecompPos,0xCED8); break; + case x86_ST7: PUTDST16(m_RecompPos,0xCFD8); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } +} + +void CX86Ops::fpuMulRegPop(x86FpuValues x86reg) +{ + CPU_Message(" fmulp ST(0), %s",fpu_Name(x86reg)); + switch (x86reg) + { + case x86_ST0: PUTDST16(m_RecompPos,0xC8DE); break; + case x86_ST1: PUTDST16(m_RecompPos,0xC9DE); break; + case x86_ST2: PUTDST16(m_RecompPos,0xCADE); break; + case x86_ST3: PUTDST16(m_RecompPos,0xCBDE); break; + case x86_ST4: PUTDST16(m_RecompPos,0xCCDE); break; + case x86_ST5: PUTDST16(m_RecompPos,0xCDDE); break; + case x86_ST6: PUTDST16(m_RecompPos,0xCEDE); break; + case x86_ST7: PUTDST16(m_RecompPos,0xCFDE); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } +} + +void CX86Ops::fpuNeg(void) +{ + CPU_Message(" fchs ST(0)"); + PUTDST16(m_RecompPos,0xE0D9); +} + +void CX86Ops::fpuRound(void) +{ + CPU_Message(" frndint ST(0)"); + PUTDST16(m_RecompPos,0xFCD9); +} + +void CX86Ops::fpuSqrt(void) +{ + CPU_Message(" fsqrt ST(0)"); + PUTDST16(m_RecompPos,0xFAD9); +} + +void CX86Ops::fpuStoreControl(void *Variable, const char * VariableName) +{ + CPU_Message(" fnstcw [%s]",VariableName); + PUTDST16(m_RecompPos,0x3DD9); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::fpuStoreDword(int * StackPos,void *Variable, const char * VariableName, bool pop) +{ + CPU_Message(" fst%s dword ptr [%s]", m_fpupop[pop], VariableName); + + if (pop) + { + *StackPos = (*StackPos + 1) & 7; + } + + PUTDST16(m_RecompPos, pop ? 0x1DD9 : 0x15D9); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::fpuStoreDwordFromX86Reg(int * StackPos,x86Reg x86reg, bool pop) +{ + uint8_t Command = 0; + + CPU_Message(" fst%s dword ptr [%s]", m_fpupop[pop], x86_Name(x86reg)); + + if (pop) + { + *StackPos = (*StackPos + 1) & 7; + } + + PUTDST8(m_RecompPos,0xD9); + + switch (x86reg) + { + case x86_EAX: Command = 0x10; break; + case x86_EBX: Command = 0x13; break; + case x86_ECX: Command = 0x11; break; + case x86_EDX: Command = 0x12; break; + case x86_ESI: Command = 0x16; break; + case x86_EDI: Command = 0x17; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + PUTDST8(m_RecompPos, pop ? (Command + 0x8) : Command); +} + +void CX86Ops::fpuStoreDwordToN64Mem(int * StackPos,x86Reg x86reg, bool Pop) +{ + int s = Pop ? 0x0800 : 0; + + CPU_Message(" fst%s dword ptr [%s+N64mem]", m_fpupop[Pop], x86_Name(x86reg)); + + if (Pop) + { + *StackPos = (*StackPos + 1) & 7; + } - if (Pop) - *StackPos = (*StackPos + 1) & 7; + switch (x86reg) + { + case x86_EAX: PUTDST16(m_RecompPos,0x90D9|s); break; + case x86_EBX: PUTDST16(m_RecompPos,0x93D9|s); break; + case x86_ECX: PUTDST16(m_RecompPos,0x91D9|s); break; + case x86_EDX: PUTDST16(m_RecompPos,0x92D9|s); break; + case x86_ESI: PUTDST16(m_RecompPos,0x96D9|s); break; + case x86_EDI: PUTDST16(m_RecompPos,0x97D9|s); break; + case x86_EBP: PUTDST16(m_RecompPos,0x95D9|s); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } - switch (x86reg) { - case x86_EAX: PUTDST16(m_RecompPos,0x90D9|s); break; - case x86_EBX: PUTDST16(m_RecompPos,0x93D9|s); break; - case x86_ECX: PUTDST16(m_RecompPos,0x91D9|s); break; - case x86_EDX: PUTDST16(m_RecompPos,0x92D9|s); break; - case x86_ESI: PUTDST16(m_RecompPos,0x96D9|s); break; - case x86_EDI: PUTDST16(m_RecompPos,0x97D9|s); break; - case x86_EBP: PUTDST16(m_RecompPos,0x95D9|s); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - PUTDST32(m_RecompPos,g_MMU->Rdram()); -} - -void CX86Ops::fpuStoreIntegerDword(int * StackPos,void *Variable, const char * VariableName, bool pop) { - CPU_Message(" fist%s dword ptr [%s]", m_fpupop[pop], VariableName); - - if (pop) - *StackPos = (*StackPos + 1) & 7; - - PUTDST16(m_RecompPos, pop ? 0x1DDB : 0x15DB); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::fpuStoreIntegerDwordFromX86Reg(int * StackPos,x86Reg x86reg, bool pop) { - BYTE Command = 0; - - CPU_Message(" fist%s dword ptr [%s]", m_fpupop[pop], x86_Name(x86reg)); - - if (pop) - { - *StackPos = (*StackPos + 1) & 7; - } - - PUTDST8(m_RecompPos,0xDB); - - switch (x86reg) { - case x86_EAX: Command = 0x10; break; - case x86_EBX: Command = 0x13; break; - case x86_ECX: Command = 0x11; break; - case x86_EDX: Command = 0x12; break; - case x86_ESI: Command = 0x16; break; - case x86_EDI: Command = 0x17; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - PUTDST8(m_RecompPos, pop ? (Command + 0x8) : Command); + PUTDST32(m_RecompPos,g_MMU->Rdram()); } -void CX86Ops::fpuStoreIntegerQword(int * StackPos,void *Variable, const char * VariableName, bool pop) { - CPU_Message(" fist%s qword ptr [%s]", m_fpupop[pop], VariableName); +void CX86Ops::fpuStoreIntegerDword(int * StackPos,void *Variable, const char * VariableName, bool pop) +{ + CPU_Message(" fist%s dword ptr [%s]", m_fpupop[pop], VariableName); - if (pop) - { - *StackPos = (*StackPos + 1) & 7; - } - - PUTDST16(m_RecompPos, pop ? 0x3DDF : 0x35DF); - PUTDST32(m_RecompPos,Variable); - - if (!pop) - { - X86BreakPoint(__FILEW__,__LINE__); - } + if (pop) + { + *StackPos = (*StackPos + 1) & 7; + } + PUTDST16(m_RecompPos, pop ? 0x1DDB : 0x15DB); + PUTDST32(m_RecompPos,Variable); } -void CX86Ops::fpuStoreIntegerQwordFromX86Reg(int * StackPos, x86Reg x86reg, bool pop) { - BYTE Command = 0; - - CPU_Message(" fist%s qword ptr [%s]", m_fpupop[pop], x86_Name(x86reg)); +void CX86Ops::fpuStoreIntegerDwordFromX86Reg(int * StackPos,x86Reg x86reg, bool pop) +{ + uint8_t Command = 0; - if (pop) - { - *StackPos = (*StackPos + 1) & 7; - } + CPU_Message(" fist%s dword ptr [%s]", m_fpupop[pop], x86_Name(x86reg)); - PUTDST8(m_RecompPos,0xDF); + if (pop) + { + *StackPos = (*StackPos + 1) & 7; + } - switch (x86reg) { - case x86_EAX: Command = 0x30; break; - case x86_EBX: Command = 0x33; break; - case x86_ECX: Command = 0x31; break; - case x86_EDX: Command = 0x32; break; - case x86_ESI: Command = 0x36; break; - case x86_EDI: Command = 0x37; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + PUTDST8(m_RecompPos,0xDB); - PUTDST8(m_RecompPos, pop ? (Command + 0x8) : Command); -} - -void CX86Ops::fpuStoreQwordFromX86Reg(int * StackPos, x86Reg x86reg, bool pop) { - BYTE Command = 0; + switch (x86reg) + { + case x86_EAX: Command = 0x10; break; + case x86_EBX: Command = 0x13; break; + case x86_ECX: Command = 0x11; break; + case x86_EDX: Command = 0x12; break; + case x86_ESI: Command = 0x16; break; + case x86_EDI: Command = 0x17; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + PUTDST8(m_RecompPos, pop ? (Command + 0x8) : Command); +} + +void CX86Ops::fpuStoreIntegerQword(int * StackPos,void *Variable, const char * VariableName, bool pop) +{ + CPU_Message(" fist%s qword ptr [%s]", m_fpupop[pop], VariableName); - CPU_Message(" fst%s qword ptr [%s]", m_fpupop[pop], x86_Name(x86reg)); - - if (pop) - { - *StackPos = (*StackPos + 1) & 7; - } - - PUTDST8(m_RecompPos,0xDD); - - switch (x86reg) { - case x86_EAX: Command = 0x10; break; - case x86_EBX: Command = 0x13; break; - case x86_ECX: Command = 0x11; break; - case x86_EDX: Command = 0x12; break; - case x86_ESI: Command = 0x16; break; - case x86_EDI: Command = 0x17; break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - - PUTDST8(m_RecompPos, pop ? (Command + 0x8) : Command); -} - -void CX86Ops::fpuStoreStatus(void) { - CPU_Message(" fnstsw ax"); - PUTDST16(m_RecompPos,0xE0DF); -} - -void CX86Ops::fpuSubDword(void *Variable, const char * VariableName) { - CPU_Message(" fsub ST(0), dword ptr [%s]", VariableName); - PUTDST16(m_RecompPos,0x25D8); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::fpuSubDwordRegPointer(x86Reg x86Pointer) { - CPU_Message(" fsub ST(0), dword ptr [%s]",x86_Name(x86Pointer)); - switch (x86Pointer) { - case x86_EAX: PUTDST16(m_RecompPos,0x20D8); break; - case x86_EBX: PUTDST16(m_RecompPos,0x23D8); break; - case x86_ECX: PUTDST16(m_RecompPos,0x21D8); break; - case x86_EDX: PUTDST16(m_RecompPos,0x22D8); break; - case x86_ESI: PUTDST16(m_RecompPos,0x26D8); break; - case x86_EDI: PUTDST16(m_RecompPos,0x27D8); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } -} - -void CX86Ops::fpuSubDwordReverse(void *Variable, const char * VariableName) { - CPU_Message(" fsubr ST(0), dword ptr [%s]", VariableName); - PUTDST16(m_RecompPos,0x2DD8); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::fpuSubQword(void *Variable, const char * VariableName) { - CPU_Message(" fsub ST(0), qword ptr [%s]", VariableName); - PUTDST16(m_RecompPos,0x25DC); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::fpuSubQwordRegPointer(x86Reg x86Pointer) { - CPU_Message(" fsub ST(0), qword ptr [%s]",x86_Name(x86Pointer)); - switch (x86Pointer) { - case x86_EAX: PUTDST16(m_RecompPos,0x20DC); break; - case x86_EBX: PUTDST16(m_RecompPos,0x23DC); break; - case x86_ECX: PUTDST16(m_RecompPos,0x21DC); break; - case x86_EDX: PUTDST16(m_RecompPos,0x22DC); break; - case x86_ESI: PUTDST16(m_RecompPos,0x26DC); break; - case x86_EDI: PUTDST16(m_RecompPos,0x27DC); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } -} - -void CX86Ops::fpuSubQwordReverse(void *Variable, const char * VariableName) { - CPU_Message(" fsubr ST(0), qword ptr [%s]", VariableName); - PUTDST16(m_RecompPos,0x2DDC); - PUTDST32(m_RecompPos,Variable); -} - -void CX86Ops::fpuSubReg(x86FpuValues x86reg) { - CPU_Message(" fsub ST(0), %s",fpu_Name(x86reg)); - switch (x86reg) { - case x86_ST0: PUTDST16(m_RecompPos,0xE0D8); break; - case x86_ST1: PUTDST16(m_RecompPos,0xE1D8); break; - case x86_ST2: PUTDST16(m_RecompPos,0xE2D8); break; - case x86_ST3: PUTDST16(m_RecompPos,0xE3D8); break; - case x86_ST4: PUTDST16(m_RecompPos,0xE4D8); break; - case x86_ST5: PUTDST16(m_RecompPos,0xE5D8); break; - case x86_ST6: PUTDST16(m_RecompPos,0xE6D8); break; - case x86_ST7: PUTDST16(m_RecompPos,0xE7D8); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } -} - -void CX86Ops::fpuSubRegPop(x86FpuValues x86reg) { - CPU_Message(" fsubp ST(0), %s",fpu_Name(x86reg)); - switch (x86reg) { - case x86_ST0: PUTDST16(m_RecompPos,0xE8DE); break; - case x86_ST1: PUTDST16(m_RecompPos,0xE9DE); break; - case x86_ST2: PUTDST16(m_RecompPos,0xEADE); break; - case x86_ST3: PUTDST16(m_RecompPos,0xEBDE); break; - case x86_ST4: PUTDST16(m_RecompPos,0xECDE); break; - case x86_ST5: PUTDST16(m_RecompPos,0xEDDE); break; - case x86_ST6: PUTDST16(m_RecompPos,0xEEDE); break; - case x86_ST7: PUTDST16(m_RecompPos,0xEFDE); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - break; - } -} - -const char * CX86Ops::x86_Name ( x86Reg Reg ) { - switch (Reg) { - case x86_EAX: return "eax"; - case x86_EBX: return "ebx"; - case x86_ECX: return "ecx"; - case x86_EDX: return "edx"; - case x86_ESI: return "esi"; - case x86_EDI: return "edi"; - case x86_EBP: return "ebp"; - case x86_ESP: return "esp"; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - return "???"; -} - -const char * CX86Ops::x86_ByteName ( x86Reg Reg ) { - switch (Reg) { - case x86_AL: return "al"; - case x86_BL: return "bl"; - case x86_CL: return "cl"; - case x86_DL: return "dl"; - case x86_AH: return "ah"; - case x86_BH: return "bh"; - case x86_CH: return "ch"; - case x86_DH: return "dh"; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - return "???"; -} - -const char * CX86Ops::x86_HalfName ( x86Reg Reg ) { - switch (Reg) { - case x86_EAX: return "ax"; - case x86_EBX: return "bx"; - case x86_ECX: return "cx"; - case x86_EDX: return "dx"; - case x86_ESI: return "si"; - case x86_EDI: return "di"; - case x86_EBP: return "bp"; - case x86_ESP: return "sp"; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - return "???"; -} - -const char * CX86Ops::fpu_Name ( x86FpuValues Reg ) { - switch (Reg) { - case x86_ST0: return "ST(0)"; - case x86_ST1: return "ST(1)"; - case x86_ST2: return "ST(2)"; - case x86_ST3: return "ST(3)"; - case x86_ST4: return "ST(4)"; - case x86_ST5: return "ST(5)"; - case x86_ST6: return "ST(6)"; - case x86_ST7: return "ST(7)"; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - return "???"; + if (pop) + { + *StackPos = (*StackPos + 1) & 7; + } + + PUTDST16(m_RecompPos, pop ? 0x3DDF : 0x35DF); + PUTDST32(m_RecompPos,Variable); + + if (!pop) + { + X86BreakPoint(__FILEW__,__LINE__); + } +} + +void CX86Ops::fpuStoreIntegerQwordFromX86Reg(int * StackPos, x86Reg x86reg, bool pop) +{ + uint8_t Command = 0; + + CPU_Message(" fist%s qword ptr [%s]", m_fpupop[pop], x86_Name(x86reg)); + + if (pop) + { + *StackPos = (*StackPos + 1) & 7; + } + + PUTDST8(m_RecompPos,0xDF); + + switch (x86reg) { + case x86_EAX: Command = 0x30; break; + case x86_EBX: Command = 0x33; break; + case x86_ECX: Command = 0x31; break; + case x86_EDX: Command = 0x32; break; + case x86_ESI: Command = 0x36; break; + case x86_EDI: Command = 0x37; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + PUTDST8(m_RecompPos, pop ? (Command + 0x8) : Command); +} + +void CX86Ops::fpuStoreQwordFromX86Reg(int * StackPos, x86Reg x86reg, bool pop) +{ + uint8_t Command = 0; + + CPU_Message(" fst%s qword ptr [%s]", m_fpupop[pop], x86_Name(x86reg)); + + if (pop) + { + *StackPos = (*StackPos + 1) & 7; + } + + PUTDST8(m_RecompPos,0xDD); + + switch (x86reg) + { + case x86_EAX: Command = 0x10; break; + case x86_EBX: Command = 0x13; break; + case x86_ECX: Command = 0x11; break; + case x86_EDX: Command = 0x12; break; + case x86_ESI: Command = 0x16; break; + case x86_EDI: Command = 0x17; break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + + PUTDST8(m_RecompPos, pop ? (Command + 0x8) : Command); +} + +void CX86Ops::fpuStoreStatus(void) +{ + CPU_Message(" fnstsw ax"); + PUTDST16(m_RecompPos,0xE0DF); +} + +void CX86Ops::fpuSubDword(void *Variable, const char * VariableName) +{ + CPU_Message(" fsub ST(0), dword ptr [%s]", VariableName); + PUTDST16(m_RecompPos,0x25D8); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::fpuSubDwordRegPointer(x86Reg x86Pointer) +{ + CPU_Message(" fsub ST(0), dword ptr [%s]",x86_Name(x86Pointer)); + switch (x86Pointer) + { + case x86_EAX: PUTDST16(m_RecompPos,0x20D8); break; + case x86_EBX: PUTDST16(m_RecompPos,0x23D8); break; + case x86_ECX: PUTDST16(m_RecompPos,0x21D8); break; + case x86_EDX: PUTDST16(m_RecompPos,0x22D8); break; + case x86_ESI: PUTDST16(m_RecompPos,0x26D8); break; + case x86_EDI: PUTDST16(m_RecompPos,0x27D8); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } +} + +void CX86Ops::fpuSubDwordReverse(void *Variable, const char * VariableName) +{ + CPU_Message(" fsubr ST(0), dword ptr [%s]", VariableName); + PUTDST16(m_RecompPos,0x2DD8); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::fpuSubQword(void *Variable, const char * VariableName) +{ + CPU_Message(" fsub ST(0), qword ptr [%s]", VariableName); + PUTDST16(m_RecompPos,0x25DC); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::fpuSubQwordRegPointer(x86Reg x86Pointer) +{ + CPU_Message(" fsub ST(0), qword ptr [%s]",x86_Name(x86Pointer)); + switch (x86Pointer) { + case x86_EAX: PUTDST16(m_RecompPos,0x20DC); break; + case x86_EBX: PUTDST16(m_RecompPos,0x23DC); break; + case x86_ECX: PUTDST16(m_RecompPos,0x21DC); break; + case x86_EDX: PUTDST16(m_RecompPos,0x22DC); break; + case x86_ESI: PUTDST16(m_RecompPos,0x26DC); break; + case x86_EDI: PUTDST16(m_RecompPos,0x27DC); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } +} + +void CX86Ops::fpuSubQwordReverse(void *Variable, const char * VariableName) +{ + CPU_Message(" fsubr ST(0), qword ptr [%s]", VariableName); + PUTDST16(m_RecompPos,0x2DDC); + PUTDST32(m_RecompPos,Variable); +} + +void CX86Ops::fpuSubReg(x86FpuValues x86reg) +{ + CPU_Message(" fsub ST(0), %s",fpu_Name(x86reg)); + switch (x86reg) { + case x86_ST0: PUTDST16(m_RecompPos,0xE0D8); break; + case x86_ST1: PUTDST16(m_RecompPos,0xE1D8); break; + case x86_ST2: PUTDST16(m_RecompPos,0xE2D8); break; + case x86_ST3: PUTDST16(m_RecompPos,0xE3D8); break; + case x86_ST4: PUTDST16(m_RecompPos,0xE4D8); break; + case x86_ST5: PUTDST16(m_RecompPos,0xE5D8); break; + case x86_ST6: PUTDST16(m_RecompPos,0xE6D8); break; + case x86_ST7: PUTDST16(m_RecompPos,0xE7D8); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } +} + +void CX86Ops::fpuSubRegPop(x86FpuValues x86reg) +{ + CPU_Message(" fsubp ST(0), %s",fpu_Name(x86reg)); + switch (x86reg) { + case x86_ST0: PUTDST16(m_RecompPos,0xE8DE); break; + case x86_ST1: PUTDST16(m_RecompPos,0xE9DE); break; + case x86_ST2: PUTDST16(m_RecompPos,0xEADE); break; + case x86_ST3: PUTDST16(m_RecompPos,0xEBDE); break; + case x86_ST4: PUTDST16(m_RecompPos,0xECDE); break; + case x86_ST5: PUTDST16(m_RecompPos,0xEDDE); break; + case x86_ST6: PUTDST16(m_RecompPos,0xEEDE); break; + case x86_ST7: PUTDST16(m_RecompPos,0xEFDE); break; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + } +} + +const char * CX86Ops::x86_Name ( x86Reg Reg ) +{ + switch (Reg) { + case x86_EAX: return "eax"; + case x86_EBX: return "ebx"; + case x86_ECX: return "ecx"; + case x86_EDX: return "edx"; + case x86_ESI: return "esi"; + case x86_EDI: return "edi"; + case x86_EBP: return "ebp"; + case x86_ESP: return "esp"; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + return "???"; +} + +const char * CX86Ops::x86_ByteName ( x86Reg Reg ) +{ + switch (Reg) { + case x86_AL: return "al"; + case x86_BL: return "bl"; + case x86_CL: return "cl"; + case x86_DL: return "dl"; + case x86_AH: return "ah"; + case x86_BH: return "bh"; + case x86_CH: return "ch"; + case x86_DH: return "dh"; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + return "???"; +} + +const char * CX86Ops::x86_HalfName ( x86Reg Reg ) +{ + switch (Reg) + { + case x86_EAX: return "ax"; + case x86_EBX: return "bx"; + case x86_ECX: return "cx"; + case x86_EDX: return "dx"; + case x86_ESI: return "si"; + case x86_EDI: return "di"; + case x86_EBP: return "bp"; + case x86_ESP: return "sp"; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + return "???"; +} + +const char * CX86Ops::fpu_Name ( x86FpuValues Reg ) +{ + switch (Reg) + { + case x86_ST0: return "ST(0)"; + case x86_ST1: return "ST(1)"; + case x86_ST2: return "ST(2)"; + case x86_ST3: return "ST(3)"; + case x86_ST4: return "ST(4)"; + case x86_ST5: return "ST(5)"; + case x86_ST6: return "ST(6)"; + case x86_ST7: return "ST(7)"; + default: + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + return "???"; } bool CX86Ops::Is8BitReg(x86Reg Reg) { - return (Reg == x86_EAX) || - (Reg == x86_EBX) || - (Reg == x86_ECX) || - (Reg == x86_EDX); - + return (Reg == x86_EAX) || + (Reg == x86_EBX) || + (Reg == x86_ECX) || + (Reg == x86_EDX); } -BYTE CX86Ops::CalcMultiplyCode (Multipler Multiply) +uint8_t CX86Ops::CalcMultiplyCode (Multipler Multiply) { - switch (Multiply) { - case Multip_x2: return 0x40; - case Multip_x4: return 0x80; - case Multip_x8: return 0xC0; - default: return 0; - } + switch (Multiply) + { + case Multip_x2: return 0x40; + case Multip_x4: return 0x80; + case Multip_x8: return 0xC0; + default: return 0; + } } -void CX86Ops::SetJump32(DWORD * Loc, DWORD * JumpLoc) +void CX86Ops::SetJump32(uint32_t * Loc, uint32_t * JumpLoc) { - *Loc = (DWORD)(((DWORD)JumpLoc) - (((DWORD)(Loc)) + 4)); + *Loc = (uint32_t)(((uint32_t)JumpLoc) - (((uint32_t)(Loc)) + 4)); } -void CX86Ops::SetJump8(BYTE * Loc, BYTE * JumpLoc) +void CX86Ops::SetJump8(uint8_t * Loc, uint8_t * JumpLoc) { - if (Loc == NULL || JumpLoc == NULL) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - return; - } - DWORD diffrence = (DWORD)(((DWORD)JumpLoc) - (((DWORD)(Loc)) + 1)); - if (diffrence > 255) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - *Loc = (BYTE )diffrence; + if (Loc == NULL || JumpLoc == NULL) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + return; + } + uint32_t diffrence = (uint32_t)(((uint32_t)JumpLoc) - (((uint32_t)(Loc)) + 1)); + if (diffrence > 255) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + *Loc = (uint8_t )diffrence; } +void * CX86Ops::GetAddressOf(int value, ...) +{ + void * Address; -void * CX86Ops::GetAddressOf(int value, ...) { - void * Address; + va_list ap; + va_start( ap, value ); + Address = va_arg(ap,void *); + va_end( ap ); - va_list ap; - va_start( ap, value ); - Address = va_arg(ap,void *); - va_end( ap ); - - return Address; + return Address; } - diff --git a/Source/Project64/N64 System/Recompiler/X86ops.h b/Source/Project64/N64 System/Recompiler/X86ops.h index e2614d26f..937e53f9d 100644 --- a/Source/Project64/N64 System/Recompiler/X86ops.h +++ b/Source/Project64/N64 System/Recompiler/X86ops.h @@ -13,291 +13,292 @@ class CX86Ops { public: - enum x86Reg { - x86_EAX = 0, - x86_EBX = 3, - x86_ECX = 1, - x86_EDX = 2, - x86_ESI = 6, - x86_EDI = 7, - x86_EBP = 5, - x86_ESP = 4, - x86_Any8Bit = -3, - x86_Any = -2, - x86_Unknown = -1, - - x86_AL = 0, x86_BL = 3, x86_CL = 1, x86_DL = 2, - x86_AH = 4, x86_BH = 7, x86_CH = 5, x86_DH = 6 - }; + enum x86Reg + { + x86_EAX = 0, + x86_EBX = 3, + x86_ECX = 1, + x86_EDX = 2, + x86_ESI = 6, + x86_EDI = 7, + x86_EBP = 5, + x86_ESP = 4, + x86_Any8Bit = -3, + x86_Any = -2, + x86_Unknown = -1, - enum x86FpuValues { - x86_ST_Unknown = -1, - x86_ST0 = 0, - x86_ST1 = 1, - x86_ST2 = 2, - x86_ST3 = 3, - x86_ST4 = 4, - x86_ST5 = 5, - x86_ST6 = 6, - x86_ST7 = 7 - }; + x86_AL = 0, x86_BL = 3, x86_CL = 1, x86_DL = 2, + x86_AH = 4, x86_BH = 7, x86_CH = 5, x86_DH = 6 + }; - enum Multipler - { - Multip_x1 = 1, - Multip_x2 = 2, - Multip_x4 = 4, - Multip_x8 = 8 - }; + enum x86FpuValues + { + x86_ST_Unknown = -1, + x86_ST0 = 0, + x86_ST1 = 1, + x86_ST2 = 2, + x86_ST3 = 3, + x86_ST4 = 4, + x86_ST5 = 5, + x86_ST6 = 6, + x86_ST7 = 7 + }; - static x86Reg x86_Registers[8]; - static const char * x86_Name ( x86Reg Reg ); - static const char * x86_ByteName ( x86Reg Reg ); - static const char * x86_HalfName ( x86Reg Reg ); - static const char * fpu_Name ( x86FpuValues Reg ); + enum Multipler + { + Multip_x1 = 1, + Multip_x2 = 2, + Multip_x4 = 4, + Multip_x8 = 8 + }; + + static x86Reg x86_Registers[8]; + static const char * x86_Name ( x86Reg Reg ); + static const char * x86_ByteName ( x86Reg Reg ); + static const char * x86_HalfName ( x86Reg Reg ); + static const char * fpu_Name ( x86FpuValues Reg ); protected: - //Logging Functions - static void WriteX86Comment ( LPCSTR Comment ); - static void WriteX86Label ( LPCSTR Label ); + //Logging Functions + static void WriteX86Comment ( const char * Comment ); + static void WriteX86Label ( const char * Label ); - static void AdcX86regToVariable ( x86Reg reg, void * Variable, const char * VariableName ); - static void AdcConstToVariable ( void *Variable, const char * VariableName, BYTE Constant ); - static void AdcConstToX86Reg ( x86Reg Reg, DWORD Const ); - static void AdcVariableToX86reg ( x86Reg reg, void * Variable, const char * VariableName ); - static void AdcX86RegToX86Reg ( x86Reg Destination, x86Reg Source ); - static void AddConstToVariable ( DWORD Const, void *Variable, const char * VariableName ); - static void AddConstToX86Reg ( x86Reg Reg, DWORD Const ); - static void AddVariableToX86reg ( x86Reg reg, void * Variable, const char * VariableName ); - static void AddX86regToVariable ( x86Reg reg, void * Variable, const char * VariableName ); - static void AddX86RegToX86Reg ( x86Reg Destination, x86Reg Source ); - static void AndConstToVariable ( DWORD Const, void *Variable, const char * VariableName ); - static void AndConstToX86Reg ( x86Reg Reg, DWORD Const ); - static void AndVariableToX86Reg ( void * Variable, const char * VariableName, x86Reg Reg ); - static void AndVariableDispToX86Reg ( void * Variable, const char * VariableName, x86Reg Reg, x86Reg AddrReg, Multipler Multiply); - static void AndX86RegToX86Reg ( x86Reg Destination, x86Reg Source ); - static void X86HardBreakPoint (); - static void X86BreakPoint ( const wchar_t * FileName, int LineNumber ); - static void Call_Direct ( void * FunctAddress, const char * FunctName ); - static void Call_Indirect ( void * FunctAddress, const char * FunctName ); - static void CompConstToVariable ( DWORD Const, void * Variable, const char * VariableName ); - static void CompConstToX86reg ( x86Reg Reg, DWORD Const ); - static void CompConstToX86regPointer ( x86Reg Reg, DWORD Const ); - static void CompX86regToVariable ( x86Reg Reg, void * Variable, const char * VariableName ); - static void CompVariableToX86reg ( x86Reg Reg, void * Variable, const char * VariableName ); - static void CompX86RegToX86Reg ( x86Reg Destination, x86Reg Source ); - static void DecX86reg ( x86Reg Reg ); - static void DivX86reg ( x86Reg reg ); - static void idivX86reg ( x86Reg reg ); - static void imulX86reg ( x86Reg reg ); - static void IncX86reg ( x86Reg Reg ); - static void JaeLabel8 ( const char * Label, BYTE Value ); - static void JaeLabel32 ( const char * Label, DWORD Value ); - static void JaLabel8 ( const char * Label, BYTE Value ); - static void JaLabel32 ( const char * Label, DWORD Value ); - static void JbLabel8 ( const char * Label, BYTE Value ); - static void JbLabel32 ( const char * Label, DWORD Value ); - static void JecxzLabel8 ( const char * Label, BYTE Value ); - static void JeLabel8 ( const char * Label, BYTE Value ); - static void JeLabel32 ( const char * Label, DWORD Value ); - static void JgeLabel32 ( const char * Label, DWORD Value ); - static void JgLabel8 ( const char * Label, BYTE Value ); - static void JgLabel32 ( const char * Label, DWORD Value ); - static void JleLabel8 ( const char * Label, BYTE Value ); - static void JleLabel32 ( const char * Label, DWORD Value ); - static void JlLabel8 ( const char * Label, BYTE Value ); - static void JlLabel32 ( const char * Label, DWORD Value ); - static void JmpDirectReg ( x86Reg reg ); - static void JmpIndirectLabel32 ( const char * Label, DWORD location ); - static void JmpIndirectReg ( x86Reg reg ); - static void JmpLabel8 ( const char * Label, BYTE Value ); - static void JmpLabel32 ( const char * Label, DWORD Value ); - static void JneLabel8 ( const char * Label, BYTE Value ); - static void JneLabel32 ( const char * Label, DWORD Value ); - static void JnsLabel8 ( const char * Label, BYTE Value ); - static void JnsLabel32 ( const char * Label, DWORD Value ); - static void JnzLabel8 ( const char * Label, BYTE Value ); - static void JnzLabel32 ( const char * Label, DWORD Value ); - static void JsLabel32 ( const char * Label, DWORD Value ); - static void JzLabel8 ( const char * Label, BYTE Value ); - static void JzLabel32 ( const char * Label, DWORD Value ); - static void LeaRegReg ( x86Reg RegDest, x86Reg RegSrc, DWORD Const, Multipler multiplier ); - static void LeaRegReg2 ( x86Reg RegDest, x86Reg RegSrc, x86Reg RegSrc2, Multipler multiplier ); - static void LeaSourceAndOffset ( x86Reg x86DestReg, x86Reg x86SourceReg, int offset ); - static void MoveConstByteToN64Mem ( BYTE Const, x86Reg AddrReg ); - static void MoveConstHalfToN64Mem ( WORD Const, x86Reg AddrReg ); - static void MoveConstByteToVariable ( BYTE Const, void * Variable, const char * VariableName ); - static void MoveConstByteToX86regPointer ( BYTE Const, x86Reg AddrReg1, x86Reg AddrReg2 ); - static void MoveConstHalfToVariable ( WORD Const, void * Variable, const char * VariableName ); - static void MoveConstHalfToX86regPointer ( WORD Const, x86Reg AddrReg1, x86Reg AddrReg2 ); - static void MoveConstToMemoryDisp ( DWORD Const, x86Reg AddrReg, DWORD Disp ); - static void MoveConstToN64Mem ( DWORD Const, x86Reg AddrReg ); - static void MoveConstToN64MemDisp ( DWORD Const, x86Reg AddrReg, BYTE Disp ); - static void MoveConstToVariable ( DWORD Const, void * Variable, const char * VariableName ); - static void MoveConstToX86Pointer ( DWORD Const, x86Reg X86Pointer ); - static void MoveConstToX86reg ( DWORD Const, x86Reg reg ); - static void MoveConstToX86regPointer ( DWORD Const, x86Reg AddrReg1, x86Reg AddrReg2 ); - static void MoveN64MemDispToX86reg ( x86Reg reg, x86Reg AddrReg, BYTE Disp ); - static void MoveN64MemToX86reg ( x86Reg reg, x86Reg AddrReg ); - static void MoveN64MemToX86regByte ( x86Reg reg, x86Reg AddrReg ); - static void MoveN64MemToX86regHalf ( x86Reg reg, x86Reg AddrReg ); - static void MoveSxByteX86regPointerToX86reg ( x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg ); - static void MoveSxHalfX86regPointerToX86reg ( x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg ); - static void MoveSxN64MemToX86regByte ( x86Reg reg, x86Reg AddrReg ); - static void MoveSxN64MemToX86regHalf ( x86Reg reg, x86Reg AddrReg ); - static void MoveSxVariableToX86regByte ( void * Variable, const char * VariableName, x86Reg reg ); - static void MoveSxVariableToX86regHalf ( void * Variable, const char * VariableName, x86Reg reg ); - static void MoveVariableDispToX86Reg ( void * Variable, const char * VariableName, x86Reg Reg, x86Reg AddrReg, int Multiplier ); - static void MoveVariableToX86reg ( void * Variable, const char * VariableName, x86Reg reg ); - static void MoveVariableToX86regByte ( void * Variable, const char * VariableName, x86Reg reg ); - static void MoveVariableToX86regHalf ( void * Variable, const char * VariableName, x86Reg reg ); - static void MoveX86PointerToX86reg ( x86Reg reg, x86Reg X86Pointer ); - static void MoveX86PointerToX86regDisp ( x86Reg reg, x86Reg X86Pointer, BYTE Disp ); - static void MoveX86regByteToN64Mem ( x86Reg reg, x86Reg AddrReg ); - static void MoveX86regByteToVariable ( x86Reg reg, void * Variable, const char * VariableName ); - static void MoveX86regByteToX86regPointer ( x86Reg reg, x86Reg AddrReg1, x86Reg AddrReg2 ); - static void MoveX86regHalfToN64Mem ( x86Reg reg, x86Reg AddrReg ); - static void MoveX86regHalfToVariable ( x86Reg reg, void * Variable, const char * VariableName ); - static void MoveX86regHalfToX86regPointer ( x86Reg reg, x86Reg AddrReg1, x86Reg AddrReg2 ); - static void MoveX86regPointerToX86reg ( x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg ); - static void MoveX86regPointerToX86regDisp8 ( x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg, BYTE offset ); - static void MoveX86regToMemory ( x86Reg reg, x86Reg AddrReg, DWORD Disp ); - static void MoveX86regToN64Mem ( x86Reg reg, x86Reg AddrReg ); - static void MoveX86regToN64MemDisp ( x86Reg reg, x86Reg AddrReg, BYTE Disp ); - static void MoveX86regToVariable ( x86Reg reg, void * Variable, const char * VariableName ); - static void MoveX86RegToX86Reg ( x86Reg Source, x86Reg Destination ); - static void MoveX86regToX86Pointer ( x86Reg reg, x86Reg X86Pointer ); - static void MoveX86regToX86regPointer ( x86Reg reg, x86Reg AddrReg1, x86Reg AddrReg2 ); - static void MoveZxByteX86regPointerToX86reg ( x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg ); - static void MoveZxHalfX86regPointerToX86reg ( x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg ); - static void MoveZxN64MemToX86regByte ( x86Reg reg, x86Reg AddrReg ); - static void MoveZxN64MemToX86regHalf ( x86Reg reg, x86Reg AddrReg ); - static void MoveZxVariableToX86regByte ( void * Variable, const char * VariableName, x86Reg reg ); - static void MoveZxVariableToX86regHalf ( void * Variable, const char * VariableName, x86Reg reg ); - static void MulX86reg ( x86Reg reg ); - static void NotX86Reg ( x86Reg Reg ); - static void OrConstToVariable ( DWORD Const, void * Variable, const char * VariableName ); - static void OrConstToX86Reg ( DWORD Const, x86Reg reg ); - static void OrVariableToX86Reg ( void * Variable, const char * VariableName, x86Reg Reg ); - static void OrX86RegToVariable ( void * Variable, const char * VariableName, x86Reg Reg ); - static void OrX86RegToX86Reg ( x86Reg Destination, x86Reg Source ); - static void Push ( x86Reg reg ); - static void Pushad (); - static void PushImm32 ( DWORD Value ); - static void PushImm32 ( const char * String, DWORD Value ); - static void Pop ( x86Reg reg ); - static void Popad (); - static void Ret (); - static void Seta ( x86Reg reg ); - static void Setae ( x86Reg reg ); - static void SetaVariable ( void * Variable, const char * VariableName ); - static void Setb ( x86Reg reg ); - static void SetbVariable ( void * Variable, const char * VariableName ); - static void Setg ( x86Reg reg ); - static void SetgVariable ( void * Variable, const char * VariableName ); - static void Setl ( x86Reg reg ); - static void SetlVariable ( void * Variable, const char * VariableName ); - static void Setz ( x86Reg reg ); - static void Setnz ( x86Reg reg ); - static void ShiftLeftDouble ( x86Reg Destination, x86Reg Source ); - static void ShiftLeftDoubleImmed ( x86Reg Destination, x86Reg Source, BYTE Immediate ); - static void ShiftLeftSign ( x86Reg reg ); - static void ShiftLeftSignImmed ( x86Reg reg, BYTE Immediate ); - static void ShiftRightDouble ( x86Reg Destination, x86Reg Source ); - static void ShiftRightDoubleImmed ( x86Reg Destination, x86Reg Source, BYTE Immediate ); - static void ShiftRightSign ( x86Reg reg ); - static void ShiftRightSignImmed ( x86Reg reg, BYTE Immediate ); - static void ShiftRightUnsign ( x86Reg reg ); - static void ShiftRightUnsignImmed ( x86Reg reg, BYTE Immediate ); - static void SbbConstFromX86Reg ( x86Reg Reg, DWORD Const ); - static void SbbVariableFromX86reg ( x86Reg reg, void * Variable, const char * VariableName ); - static void SbbX86RegToX86Reg ( x86Reg Destination, x86Reg Source ); - static void SubConstFromVariable ( DWORD Const, void * Variable, const char * VariableName ); - static void SubConstFromX86Reg ( x86Reg Reg, DWORD Const ); - static void SubVariableFromX86reg ( x86Reg reg, void * Variable, const char * VariableName ); - static void SubX86RegToX86Reg ( x86Reg Destination, x86Reg Source ); - static void TestConstToX86Reg ( DWORD Const, x86Reg reg ); - static void TestVariable ( DWORD Const, void * Variable, const char * VariableName ); - static void TestX86RegToX86Reg ( x86Reg Destination, x86Reg Source ); - static void XorConstToX86Reg ( x86Reg Reg, DWORD Const ); - static void XorX86RegToX86Reg ( x86Reg Source, x86Reg Destination ); - static void XorVariableToX86reg ( void * Variable, const char * VariableName, x86Reg reg ); + static void AdcX86regToVariable ( x86Reg reg, void * Variable, const char * VariableName ); + static void AdcConstToVariable ( void *Variable, const char * VariableName, uint8_t Constant ); + static void AdcConstToX86Reg ( x86Reg Reg, uint32_t Const ); + static void AdcVariableToX86reg ( x86Reg reg, void * Variable, const char * VariableName ); + static void AdcX86RegToX86Reg ( x86Reg Destination, x86Reg Source ); + static void AddConstToVariable ( uint32_t Const, void *Variable, const char * VariableName ); + static void AddConstToX86Reg ( x86Reg Reg, uint32_t Const ); + static void AddVariableToX86reg ( x86Reg reg, void * Variable, const char * VariableName ); + static void AddX86regToVariable ( x86Reg reg, void * Variable, const char * VariableName ); + static void AddX86RegToX86Reg ( x86Reg Destination, x86Reg Source ); + static void AndConstToVariable ( uint32_t Const, void *Variable, const char * VariableName ); + static void AndConstToX86Reg ( x86Reg Reg, uint32_t Const ); + static void AndVariableToX86Reg ( void * Variable, const char * VariableName, x86Reg Reg ); + static void AndVariableDispToX86Reg ( void * Variable, const char * VariableName, x86Reg Reg, x86Reg AddrReg, Multipler Multiply); + static void AndX86RegToX86Reg ( x86Reg Destination, x86Reg Source ); + static void X86HardBreakPoint (); + static void X86BreakPoint ( const wchar_t * FileName, int32_t LineNumber ); + static void Call_Direct ( void * FunctAddress, const char * FunctName ); + static void Call_Indirect ( void * FunctAddress, const char * FunctName ); + static void CompConstToVariable ( uint32_t Const, void * Variable, const char * VariableName ); + static void CompConstToX86reg ( x86Reg Reg, uint32_t Const ); + static void CompConstToX86regPointer ( x86Reg Reg, uint32_t Const ); + static void CompX86regToVariable ( x86Reg Reg, void * Variable, const char * VariableName ); + static void CompVariableToX86reg ( x86Reg Reg, void * Variable, const char * VariableName ); + static void CompX86RegToX86Reg ( x86Reg Destination, x86Reg Source ); + static void DecX86reg ( x86Reg Reg ); + static void DivX86reg ( x86Reg reg ); + static void idivX86reg ( x86Reg reg ); + static void imulX86reg ( x86Reg reg ); + static void IncX86reg ( x86Reg Reg ); + static void JaeLabel8 ( const char * Label, uint8_t Value ); + static void JaeLabel32 ( const char * Label, uint32_t Value ); + static void JaLabel8 ( const char * Label, uint8_t Value ); + static void JaLabel32 ( const char * Label, uint32_t Value ); + static void JbLabel8 ( const char * Label, uint8_t Value ); + static void JbLabel32 ( const char * Label, uint32_t Value ); + static void JecxzLabel8 ( const char * Label, uint8_t Value ); + static void JeLabel8 ( const char * Label, uint8_t Value ); + static void JeLabel32 ( const char * Label, uint32_t Value ); + static void JgeLabel32 ( const char * Label, uint32_t Value ); + static void JgLabel8 ( const char * Label, uint8_t Value ); + static void JgLabel32 ( const char * Label, uint32_t Value ); + static void JleLabel8 ( const char * Label, uint8_t Value ); + static void JleLabel32 ( const char * Label, uint32_t Value ); + static void JlLabel8 ( const char * Label, uint8_t Value ); + static void JlLabel32 ( const char * Label, uint32_t Value ); + static void JmpDirectReg ( x86Reg reg ); + static void JmpIndirectLabel32 ( const char * Label, uint32_t location ); + static void JmpIndirectReg ( x86Reg reg ); + static void JmpLabel8 ( const char * Label, uint8_t Value ); + static void JmpLabel32 ( const char * Label, uint32_t Value ); + static void JneLabel8 ( const char * Label, uint8_t Value ); + static void JneLabel32 ( const char * Label, uint32_t Value ); + static void JnsLabel8 ( const char * Label, uint8_t Value ); + static void JnsLabel32 ( const char * Label, uint32_t Value ); + static void JnzLabel8 ( const char * Label, uint8_t Value ); + static void JnzLabel32 ( const char * Label, uint32_t Value ); + static void JsLabel32 ( const char * Label, uint32_t Value ); + static void JzLabel8 ( const char * Label, uint8_t Value ); + static void JzLabel32 ( const char * Label, uint32_t Value ); + static void LeaRegReg ( x86Reg RegDest, x86Reg RegSrc, uint32_t Const, Multipler multiplier ); + static void LeaRegReg2 ( x86Reg RegDest, x86Reg RegSrc, x86Reg RegSrc2, Multipler multiplier ); + static void LeaSourceAndOffset ( x86Reg x86DestReg, x86Reg x86SourceReg, int32_t offset ); + static void MoveConstByteToN64Mem ( uint8_t Const, x86Reg AddrReg ); + static void MoveConstHalfToN64Mem ( uint16_t Const, x86Reg AddrReg ); + static void MoveConstByteToVariable ( uint8_t Const, void * Variable, const char * VariableName ); + static void MoveConstByteToX86regPointer ( uint8_t Const, x86Reg AddrReg1, x86Reg AddrReg2 ); + static void MoveConstHalfToVariable ( uint16_t Const, void * Variable, const char * VariableName ); + static void MoveConstHalfToX86regPointer ( uint16_t Const, x86Reg AddrReg1, x86Reg AddrReg2 ); + static void MoveConstToMemoryDisp ( uint32_t Const, x86Reg AddrReg, uint32_t Disp ); + static void MoveConstToN64Mem ( uint32_t Const, x86Reg AddrReg ); + static void MoveConstToN64MemDisp ( uint32_t Const, x86Reg AddrReg, uint8_t Disp ); + static void MoveConstToVariable ( uint32_t Const, void * Variable, const char * VariableName ); + static void MoveConstToX86Pointer ( uint32_t Const, x86Reg X86Pointer ); + static void MoveConstToX86reg ( uint32_t Const, x86Reg reg ); + static void MoveConstToX86regPointer ( uint32_t Const, x86Reg AddrReg1, x86Reg AddrReg2 ); + static void MoveN64MemDispToX86reg ( x86Reg reg, x86Reg AddrReg, uint8_t Disp ); + static void MoveN64MemToX86reg ( x86Reg reg, x86Reg AddrReg ); + static void MoveN64MemToX86regByte ( x86Reg reg, x86Reg AddrReg ); + static void MoveN64MemToX86regHalf ( x86Reg reg, x86Reg AddrReg ); + static void MoveSxByteX86regPointerToX86reg ( x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg ); + static void MoveSxHalfX86regPointerToX86reg ( x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg ); + static void MoveSxN64MemToX86regByte ( x86Reg reg, x86Reg AddrReg ); + static void MoveSxN64MemToX86regHalf ( x86Reg reg, x86Reg AddrReg ); + static void MoveSxVariableToX86regByte ( void * Variable, const char * VariableName, x86Reg reg ); + static void MoveSxVariableToX86regHalf ( void * Variable, const char * VariableName, x86Reg reg ); + static void MoveVariableDispToX86Reg ( void * Variable, const char * VariableName, x86Reg Reg, x86Reg AddrReg, int32_t Multiplier ); + static void MoveVariableToX86reg ( void * Variable, const char * VariableName, x86Reg reg ); + static void MoveVariableToX86regByte ( void * Variable, const char * VariableName, x86Reg reg ); + static void MoveVariableToX86regHalf ( void * Variable, const char * VariableName, x86Reg reg ); + static void MoveX86PointerToX86reg ( x86Reg reg, x86Reg X86Pointer ); + static void MoveX86PointerToX86regDisp ( x86Reg reg, x86Reg X86Pointer, uint8_t Disp ); + static void MoveX86regByteToN64Mem ( x86Reg reg, x86Reg AddrReg ); + static void MoveX86regByteToVariable ( x86Reg reg, void * Variable, const char * VariableName ); + static void MoveX86regByteToX86regPointer ( x86Reg reg, x86Reg AddrReg1, x86Reg AddrReg2 ); + static void MoveX86regHalfToN64Mem ( x86Reg reg, x86Reg AddrReg ); + static void MoveX86regHalfToVariable ( x86Reg reg, void * Variable, const char * VariableName ); + static void MoveX86regHalfToX86regPointer ( x86Reg reg, x86Reg AddrReg1, x86Reg AddrReg2 ); + static void MoveX86regPointerToX86reg ( x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg ); + static void MoveX86regPointerToX86regDisp8 ( x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg, uint8_t offset ); + static void MoveX86regToMemory ( x86Reg reg, x86Reg AddrReg, uint32_t Disp ); + static void MoveX86regToN64Mem ( x86Reg reg, x86Reg AddrReg ); + static void MoveX86regToN64MemDisp ( x86Reg reg, x86Reg AddrReg, uint8_t Disp ); + static void MoveX86regToVariable ( x86Reg reg, void * Variable, const char * VariableName ); + static void MoveX86RegToX86Reg ( x86Reg Source, x86Reg Destination ); + static void MoveX86regToX86Pointer ( x86Reg reg, x86Reg X86Pointer ); + static void MoveX86regToX86regPointer ( x86Reg reg, x86Reg AddrReg1, x86Reg AddrReg2 ); + static void MoveZxByteX86regPointerToX86reg ( x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg ); + static void MoveZxHalfX86regPointerToX86reg ( x86Reg AddrReg1, x86Reg AddrReg2, x86Reg reg ); + static void MoveZxN64MemToX86regByte ( x86Reg reg, x86Reg AddrReg ); + static void MoveZxN64MemToX86regHalf ( x86Reg reg, x86Reg AddrReg ); + static void MoveZxVariableToX86regByte ( void * Variable, const char * VariableName, x86Reg reg ); + static void MoveZxVariableToX86regHalf ( void * Variable, const char * VariableName, x86Reg reg ); + static void MulX86reg ( x86Reg reg ); + static void NotX86Reg ( x86Reg Reg ); + static void OrConstToVariable ( uint32_t Const, void * Variable, const char * VariableName ); + static void OrConstToX86Reg ( uint32_t Const, x86Reg reg ); + static void OrVariableToX86Reg ( void * Variable, const char * VariableName, x86Reg Reg ); + static void OrX86RegToVariable ( void * Variable, const char * VariableName, x86Reg Reg ); + static void OrX86RegToX86Reg ( x86Reg Destination, x86Reg Source ); + static void Push ( x86Reg reg ); + static void Pushad (); + static void PushImm32 ( uint32_t Value ); + static void PushImm32 ( const char * String, uint32_t Value ); + static void Pop ( x86Reg reg ); + static void Popad (); + static void Ret (); + static void Seta ( x86Reg reg ); + static void Setae ( x86Reg reg ); + static void SetaVariable ( void * Variable, const char * VariableName ); + static void Setb ( x86Reg reg ); + static void SetbVariable ( void * Variable, const char * VariableName ); + static void Setg ( x86Reg reg ); + static void SetgVariable ( void * Variable, const char * VariableName ); + static void Setl ( x86Reg reg ); + static void SetlVariable ( void * Variable, const char * VariableName ); + static void Setz ( x86Reg reg ); + static void Setnz ( x86Reg reg ); + static void ShiftLeftDouble ( x86Reg Destination, x86Reg Source ); + static void ShiftLeftDoubleImmed ( x86Reg Destination, x86Reg Source, uint8_t Immediate ); + static void ShiftLeftSign ( x86Reg reg ); + static void ShiftLeftSignImmed ( x86Reg reg, uint8_t Immediate ); + static void ShiftRightDouble ( x86Reg Destination, x86Reg Source ); + static void ShiftRightDoubleImmed ( x86Reg Destination, x86Reg Source, uint8_t Immediate ); + static void ShiftRightSign ( x86Reg reg ); + static void ShiftRightSignImmed ( x86Reg reg, uint8_t Immediate ); + static void ShiftRightUnsign ( x86Reg reg ); + static void ShiftRightUnsignImmed ( x86Reg reg, uint8_t Immediate ); + static void SbbConstFromX86Reg ( x86Reg Reg, uint32_t Const ); + static void SbbVariableFromX86reg ( x86Reg reg, void * Variable, const char * VariableName ); + static void SbbX86RegToX86Reg ( x86Reg Destination, x86Reg Source ); + static void SubConstFromVariable ( uint32_t Const, void * Variable, const char * VariableName ); + static void SubConstFromX86Reg ( x86Reg Reg, uint32_t Const ); + static void SubVariableFromX86reg ( x86Reg reg, void * Variable, const char * VariableName ); + static void SubX86RegToX86Reg ( x86Reg Destination, x86Reg Source ); + static void TestConstToX86Reg ( uint32_t Const, x86Reg reg ); + static void TestVariable ( uint32_t Const, void * Variable, const char * VariableName ); + static void TestX86RegToX86Reg ( x86Reg Destination, x86Reg Source ); + static void XorConstToX86Reg ( x86Reg Reg, uint32_t Const ); + static void XorX86RegToX86Reg ( x86Reg Source, x86Reg Destination ); + static void XorVariableToX86reg ( void * Variable, const char * VariableName, x86Reg reg ); + static void fpuAbs (); + static void fpuAddDword ( void * Variable, const char * VariableName ); + static void fpuAddDwordRegPointer ( x86Reg x86Pointer ); + static void fpuAddQword ( void * Variable, const char * VariableName ); + static void fpuAddQwordRegPointer ( x86Reg X86Pointer ); + static void fpuAddReg ( x86FpuValues reg ); + static void fpuAddRegPop ( int32_t * StackPos, x86FpuValues reg ); + static void fpuComDword ( void * Variable, const char * VariableName, bool Pop ); + static void fpuComDwordRegPointer ( x86Reg X86Pointer, bool Pop ); + static void fpuComQword ( void * Variable, const char * VariableName, bool Pop ); + static void fpuComQwordRegPointer ( x86Reg X86Pointer, bool Pop ); + static void fpuComReg ( x86FpuValues reg, bool Pop ); + static void fpuDivDword ( void * Variable, const char * VariableName ); + static void fpuDivDwordRegPointer ( x86Reg X86Pointer ); + static void fpuDivQword ( void * Variable, const char * VariableName ); + static void fpuDivQwordRegPointer ( x86Reg X86Pointer ); + static void fpuDivReg ( x86FpuValues Reg ); + static void fpuDivRegPop ( x86FpuValues reg ); + static void fpuExchange ( x86FpuValues Reg ); + static void fpuFree ( x86FpuValues Reg ); + static void fpuDecStack ( int32_t * StackPos ); + static void fpuIncStack ( int32_t * StackPos ); + static void fpuLoadControl ( void * Variable, const char * VariableName ); + static void fpuLoadDword ( int32_t * StackPos, void * Variable, const char * VariableName ); + static void fpuLoadDwordFromX86Reg ( int32_t * StackPos, x86Reg reg ); + static void fpuLoadDwordFromN64Mem ( int32_t * StackPos, x86Reg reg ); + static void fpuLoadInt32bFromN64Mem ( int32_t * StackPos, x86Reg reg ); + static void fpuLoadIntegerDword ( int32_t * StackPos, void * Variable, const char * VariableName ); + static void fpuLoadIntegerDwordFromX86Reg ( int32_t * StackPos,x86Reg Reg ); + static void fpuLoadIntegerQword ( int32_t * StackPos, void * Variable, const char * VariableName ); + static void fpuLoadIntegerQwordFromX86Reg ( int32_t * StackPos,x86Reg Reg ); + static void fpuLoadQword ( int32_t * StackPos, void * Variable, const char * VariableName ); + static void fpuLoadQwordFromX86Reg ( int32_t * StackPos, x86Reg Reg ); + static void fpuLoadQwordFromN64Mem ( int32_t * StackPos, x86Reg reg ); + static void fpuLoadReg ( int32_t * StackPos, x86FpuValues Reg ); + static void fpuMulDword ( void * Variable, const char * VariableName); + static void fpuMulDwordRegPointer ( x86Reg X86Pointer ); + static void fpuMulQword ( void * Variable, const char * VariableName); + static void fpuMulQwordRegPointer ( x86Reg X86Pointer ); + static void fpuMulReg ( x86FpuValues reg ); + static void fpuMulRegPop ( x86FpuValues reg ); + static void fpuNeg (); + static void fpuRound (); + static void fpuSqrt (); + static void fpuStoreControl ( void * Variable, const char * VariableName ); + static void fpuStoreDword ( int32_t * StackPos, void * Variable, const char * VariableName, bool pop ); + static void fpuStoreDwordFromX86Reg ( int32_t * StackPos,x86Reg Reg, bool pop ); + static void fpuStoreDwordToN64Mem ( int32_t * StackPos, x86Reg reg, bool Pop ); + static void fpuStoreIntegerDword ( int32_t * StackPos, void * Variable, const char * VariableName, bool pop ); + static void fpuStoreIntegerDwordFromX86Reg ( int32_t * StackPos,x86Reg Reg, bool pop ); + static void fpuStoreIntegerQword ( int32_t * StackPos, void * Variable, const char * VariableName, bool pop ); + static void fpuStoreIntegerQwordFromX86Reg ( int32_t * StackPos, x86Reg Reg, bool pop ); + static void fpuStoreQwordFromX86Reg ( int32_t * StackPos, x86Reg Reg, bool pop ); + static void fpuStoreStatus (); + static void fpuSubDword ( void * Variable, const char * VariableName ); + static void fpuSubDwordRegPointer ( x86Reg X86Pointer ); + static void fpuSubDwordReverse ( void * Variable, const char * VariableName ); + static void fpuSubQword ( void * Variable, const char * VariableName ); + static void fpuSubQwordRegPointer ( x86Reg X86Pointer ); + static void fpuSubQwordReverse ( void * Variable, const char * VariableName ); + static void fpuSubReg ( x86FpuValues reg ); + static void fpuSubRegPop ( x86FpuValues reg ); - static void fpuAbs (); - static void fpuAddDword ( void * Variable, const char * VariableName ); - static void fpuAddDwordRegPointer ( x86Reg x86Pointer ); - static void fpuAddQword ( void * Variable, const char * VariableName ); - static void fpuAddQwordRegPointer ( x86Reg X86Pointer ); - static void fpuAddReg ( x86FpuValues reg ); - static void fpuAddRegPop ( int * StackPos, x86FpuValues reg ); - static void fpuComDword ( void * Variable, const char * VariableName, bool Pop ); - static void fpuComDwordRegPointer ( x86Reg X86Pointer, bool Pop ); - static void fpuComQword ( void * Variable, const char * VariableName, bool Pop ); - static void fpuComQwordRegPointer ( x86Reg X86Pointer, bool Pop ); - static void fpuComReg ( x86FpuValues reg, bool Pop ); - static void fpuDivDword ( void * Variable, const char * VariableName ); - static void fpuDivDwordRegPointer ( x86Reg X86Pointer ); - static void fpuDivQword ( void * Variable, const char * VariableName ); - static void fpuDivQwordRegPointer ( x86Reg X86Pointer ); - static void fpuDivReg ( x86FpuValues Reg ); - static void fpuDivRegPop ( x86FpuValues reg ); - static void fpuExchange ( x86FpuValues Reg ); - static void fpuFree ( x86FpuValues Reg ); - static void fpuDecStack ( int * StackPos ); - static void fpuIncStack ( int * StackPos ); - static void fpuLoadControl ( void * Variable, const char * VariableName ); - static void fpuLoadDword ( int * StackPos, void * Variable, const char * VariableName ); - static void fpuLoadDwordFromX86Reg ( int * StackPos, x86Reg reg ); - static void fpuLoadDwordFromN64Mem ( int * StackPos, x86Reg reg ); - static void fpuLoadInt32bFromN64Mem ( int * StackPos, x86Reg reg ); - static void fpuLoadIntegerDword ( int * StackPos, void * Variable, const char * VariableName ); - static void fpuLoadIntegerDwordFromX86Reg ( int * StackPos,x86Reg Reg ); - static void fpuLoadIntegerQword ( int * StackPos, void * Variable, const char * VariableName ); - static void fpuLoadIntegerQwordFromX86Reg ( int * StackPos,x86Reg Reg ); - static void fpuLoadQword ( int * StackPos, void * Variable, const char * VariableName ); - static void fpuLoadQwordFromX86Reg ( int * StackPos, x86Reg Reg ); - static void fpuLoadQwordFromN64Mem ( int * StackPos, x86Reg reg ); - static void fpuLoadReg ( int * StackPos, x86FpuValues Reg ); - static void fpuMulDword ( void * Variable, const char * VariableName); - static void fpuMulDwordRegPointer ( x86Reg X86Pointer ); - static void fpuMulQword ( void * Variable, const char * VariableName); - static void fpuMulQwordRegPointer ( x86Reg X86Pointer ); - static void fpuMulReg ( x86FpuValues reg ); - static void fpuMulRegPop ( x86FpuValues reg ); - static void fpuNeg (); - static void fpuRound (); - static void fpuSqrt (); - static void fpuStoreControl ( void * Variable, const char * VariableName ); - static void fpuStoreDword ( int * StackPos, void * Variable, const char * VariableName, bool pop ); - static void fpuStoreDwordFromX86Reg ( int * StackPos,x86Reg Reg, bool pop ); - static void fpuStoreDwordToN64Mem ( int * StackPos, x86Reg reg, bool Pop ); - static void fpuStoreIntegerDword ( int * StackPos, void * Variable, const char * VariableName, bool pop ); - static void fpuStoreIntegerDwordFromX86Reg ( int * StackPos,x86Reg Reg, bool pop ); - static void fpuStoreIntegerQword ( int * StackPos, void * Variable, const char * VariableName, bool pop ); - static void fpuStoreIntegerQwordFromX86Reg ( int * StackPos, x86Reg Reg, bool pop ); - static void fpuStoreQwordFromX86Reg ( int * StackPos, x86Reg Reg, bool pop ); - static void fpuStoreStatus (); - static void fpuSubDword ( void * Variable, const char * VariableName ); - static void fpuSubDwordRegPointer ( x86Reg X86Pointer ); - static void fpuSubDwordReverse ( void * Variable, const char * VariableName ); - static void fpuSubQword ( void * Variable, const char * VariableName ); - static void fpuSubQwordRegPointer ( x86Reg X86Pointer ); - static void fpuSubQwordReverse ( void * Variable, const char * VariableName ); - static void fpuSubReg ( x86FpuValues reg ); - static void fpuSubRegPop ( x86FpuValues reg ); - - static bool Is8BitReg ( x86Reg Reg ); - static BYTE CalcMultiplyCode ( Multipler Multiply ); - static BYTE * m_RecompPos; + static bool Is8BitReg ( x86Reg Reg ); + static uint8_t CalcMultiplyCode ( Multipler Multiply ); + static uint8_t * m_RecompPos; - static void * GetAddressOf(int value, ...); - static void SetJump32(DWORD * Loc, DWORD * JumpLoc ); - static void SetJump8(BYTE * Loc, BYTE * JumpLoc); + static void * GetAddressOf(int32_t value, ...); + static void SetJump32(uint32_t * Loc, uint32_t * JumpLoc ); + static void SetJump8(uint8_t * Loc, uint8_t * JumpLoc); private: - static void BreakPointNotification (const wchar_t * const FileName, const int LineNumber); - static char m_fpupop[2][2]; + static void BreakPointNotification (const wchar_t * const FileName, const int32_t LineNumber); + static char m_fpupop[2][2]; }; #define AddressOf(Addr) CX86Ops::GetAddressOf(5,(Addr)) From 898f1da74d1c3b62046aacbe874e3baa7b620b60 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 9 Nov 2015 17:21:32 +1100 Subject: [PATCH 098/213] [Project64] Get TLB class to use standard types --- Source/Project64/N64 System/Mips/TLB Class.h | 225 ++++---- .../Project64/N64 System/Mips/TLB class.cpp | 526 +++++++++--------- Source/Project64/N64 System/N64 Class.cpp | 4 +- Source/Project64/N64 System/N64 Class.h | 4 +- .../Recompiler/Recompiler Class.cpp | 2 +- 5 files changed, 382 insertions(+), 379 deletions(-) diff --git a/Source/Project64/N64 System/Mips/TLB Class.h b/Source/Project64/N64 System/Mips/TLB Class.h index 1a373b2a1..d1a535fc8 100644 --- a/Source/Project64/N64 System/Mips/TLB Class.h +++ b/Source/Project64/N64 System/Mips/TLB Class.h @@ -12,133 +12,138 @@ class CDebugTlb; -class CTLB_CB +__interface CTLB_CB { -public: - virtual void TLB_Mapped(DWORD VAddr, DWORD Len, DWORD PAddr, bool bReadOnly) = 0; - virtual void TLB_Unmaped(DWORD VAddr, DWORD Len) = 0; - virtual void TLB_Changed() = 0; + virtual void TLB_Mapped(uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly) = 0; + virtual void TLB_Unmaped(uint32_t VAddr, uint32_t Len) = 0; + virtual void TLB_Changed() = 0; }; +#pragma warning(push) +#pragma warning(disable : 4201) // warning C4201: nonstandard extension used : nameless struct/union + class CTLB : - protected CSystemRegisters + protected CSystemRegisters { public: - struct TLB_ENTRY - { - bool EntryDefined; - union - { - unsigned long Value; - unsigned char A[4]; - - struct - { - unsigned zero : 13; - unsigned Mask : 12; - unsigned zero2 : 7; - } ; - - } PageMask; - - union - { - unsigned long Value; - unsigned char A[4]; - - struct - { - unsigned ASID : 8; - unsigned Zero : 4; - unsigned G : 1; - unsigned VPN2 : 19; - }; - - } EntryHi; + struct TLB_ENTRY + { + bool EntryDefined; + union + { + uint32_t Value; + uint8_t A[4]; + + struct + { + unsigned zero : 13; + unsigned Mask : 12; + unsigned zero2 : 7; + } ; + } PageMask; + + union + { + uint32_t Value; + uint8_t A[4]; + + struct + { + unsigned ASID : 8; + unsigned Zero : 4; + unsigned G : 1; + unsigned VPN2 : 19; + }; + } EntryHi; + + union + { + uint32_t Value; + uint8_t A[4]; + + struct + { + unsigned GLOBAL: 1; + unsigned V : 1; + unsigned D : 1; + unsigned C : 3; + unsigned PFN : 20; + unsigned ZERO: 6; + } ; + } EntryLo0; + + union + { + uint32_t Value; + uint8_t A[4]; + + struct + { + unsigned GLOBAL: 1; + unsigned V : 1; + unsigned D : 1; + unsigned C : 3; + unsigned PFN : 20; + unsigned ZERO: 6; + } ; + } EntryLo1; + }; - union - { - unsigned long Value; - unsigned char A[4]; - - struct - { - unsigned GLOBAL: 1; - unsigned V : 1; - unsigned D : 1; - unsigned C : 3; - unsigned PFN : 20; - unsigned ZERO: 6; - } ; - - } EntryLo0; - - union - { - unsigned long Value; - unsigned char A[4]; - - struct - { - unsigned GLOBAL: 1; - unsigned V : 1; - unsigned D : 1; - unsigned C : 3; - unsigned PFN : 20; - unsigned ZERO: 6; - } ; - - } EntryLo1; - }; - public: - CTLB(CTLB_CB * CallBack); - ~CTLB(); + CTLB(CTLB_CB * CallBack); + ~CTLB(); - void Reset(bool InvalidateTLB); - - //Used by opcodes of the same name to manipulate the tlb (reads the registers) - void Probe(); - void ReadEntry(); - void WriteEntry(int index, bool Random); + void Reset(bool InvalidateTLB); - //See if a VAddr has an entry to translate to a PAddr - bool AddressDefined(DWORD VAddr); - - const TLB_ENTRY & TlbEntry(int Entry) const - { - return m_tlb[Entry]; - } + //Used by opcodes of the same name to manipulate the tlb (reads the registers) + void Probe(); + void ReadEntry(); + void WriteEntry(int32_t index, bool Random); - bool PAddrToVAddr(DWORD PAddr, DWORD & VAddr, DWORD & Index); + //See if a VAddr has an entry to translate to a PAddr + bool AddressDefined(uint32_t VAddr); - void RecordDifference(CLog &LogFile, const CTLB& rTLB); + const TLB_ENTRY & TlbEntry(int32_t Entry) const + { + return m_tlb[Entry]; + } - bool operator == (const CTLB& rTLB) const; - bool operator != (const CTLB& rTLB) const; + bool PAddrToVAddr(uint32_t PAddr, uint32_t & VAddr, uint32_t & Index); + + void RecordDifference(CLog &LogFile, const CTLB& rTLB); + + bool operator == (const CTLB& rTLB) const; + bool operator != (const CTLB& rTLB) const; private: - struct FASTTLB - { - DWORD VSTART; - DWORD VEND; - DWORD PHYSSTART; - DWORD PHYSEND; - DWORD Length; - bool VALID; - bool DIRTY; - bool GLOBAL; - bool ValidEntry; - bool Random; - bool Probed; - }; + struct FASTTLB + { + uint32_t VSTART; + uint32_t VEND; + uint32_t PHYSSTART; + uint32_t PHYSEND; + uint32_t Length; + bool VALID; + bool DIRTY; + bool GLOBAL; + bool ValidEntry; + bool Random; + bool Probed; + }; - friend CDebugTlb; // enable debug window to read class + friend CDebugTlb; // enable debug window to read class - CTLB_CB * const m_CB; + CTLB_CB * const m_CB; - TLB_ENTRY m_tlb[32]; - FASTTLB m_FastTlb[64]; + TLB_ENTRY m_tlb[32]; + FASTTLB m_FastTlb[64]; - void SetupTLB_Entry(int index, bool Random); + void SetupTLB_Entry(int32_t index, bool Random); + +private: + CTLB(); // Disable default constructor + CTLB(const CTLB&); // Disable copy constructor + CTLB& operator=(const CTLB&); // Disable assignment }; + +#pragma warning(pop) diff --git a/Source/Project64/N64 System/Mips/TLB class.cpp b/Source/Project64/N64 System/Mips/TLB class.cpp index 71b7d05eb..c9b095870 100644 --- a/Source/Project64/N64 System/Mips/TLB class.cpp +++ b/Source/Project64/N64 System/Mips/TLB class.cpp @@ -10,323 +10,321 @@ ****************************************************************************/ #include "stdafx.h" -CTLB::CTLB(CTLB_CB * CallBack ): - m_CB(CallBack) +CTLB::CTLB(CTLB_CB * CallBack ): + m_CB(CallBack) { - WriteTrace(TraceTLB,__FUNCTION__ ": Start"); - memset(m_tlb,0,sizeof(m_tlb)); - memset(m_FastTlb,0,sizeof(m_FastTlb)); - Reset(true); - WriteTrace(TraceTLB,__FUNCTION__ ": Done"); + WriteTrace(TraceTLB,__FUNCTION__ ": Start"); + memset(m_tlb,0,sizeof(m_tlb)); + memset(m_FastTlb,0,sizeof(m_FastTlb)); + Reset(true); + WriteTrace(TraceTLB,__FUNCTION__ ": Done"); } CTLB::~CTLB() { - WriteTrace(TraceTLB,__FUNCTION__ ": Start"); - WriteTrace(TraceTLB,__FUNCTION__ ": Done"); + WriteTrace(TraceTLB,__FUNCTION__ ": Start"); + WriteTrace(TraceTLB,__FUNCTION__ ": Done"); } void CTLB::Reset (bool InvalidateTLB) { - DWORD count; + uint32_t count; - for (count = 0; count < 64; count++) - { - m_FastTlb[count].ValidEntry = false; - } - - if (InvalidateTLB) - { - for (count = 0; count < 32; count++) - { - m_tlb[count].EntryDefined = false; - } - } - else - { - for (count = 0; count < 32; count ++) - { - SetupTLB_Entry(count,false); - } - } + for (count = 0; count < 64; count++) + { + m_FastTlb[count].ValidEntry = false; + } + + if (InvalidateTLB) + { + for (count = 0; count < 32; count++) + { + m_tlb[count].EntryDefined = false; + } + } + else + { + for (count = 0; count < 32; count ++) + { + SetupTLB_Entry(count,false); + } + } } -bool CTLB::AddressDefined ( DWORD VAddr) +bool CTLB::AddressDefined ( uint32_t VAddr) { - DWORD i; + uint32_t i; - if (VAddr >= 0x80000000 && VAddr <= 0xBFFFFFFF) - { - return true; - } + if (VAddr >= 0x80000000 && VAddr <= 0xBFFFFFFF) + { + return true; + } - for (i = 0; i < 64; i++) - { - if (m_FastTlb[i].ValidEntry && - VAddr >= m_FastTlb[i].VSTART && - VAddr <= m_FastTlb[i].VEND) - { - return true; - } - } - return false; + for (i = 0; i < 64; i++) + { + if (m_FastTlb[i].ValidEntry && + VAddr >= m_FastTlb[i].VSTART && + VAddr <= m_FastTlb[i].VEND) + { + return true; + } + } + return false; } void CTLB::Probe() { - int Counter; - - WriteTrace(TraceTLB,__FUNCTION__ ": Start"); - g_Reg->INDEX_REGISTER |= 0x80000000; - for (Counter = 0; Counter < 32; Counter ++) - { - if (!m_tlb[Counter].EntryDefined) - { - continue; - } - - DWORD & TlbEntryHiValue = m_tlb[Counter].EntryHi.Value; - DWORD Mask = ~m_tlb[Counter].PageMask.Mask << 13; - DWORD TlbValueMasked = TlbEntryHiValue & Mask; - DWORD EntryHiMasked = g_Reg->ENTRYHI_REGISTER & Mask; + int Counter; - if (TlbValueMasked == EntryHiMasked) - { - if ((TlbEntryHiValue & 0x100) != 0 || //Global - ((TlbEntryHiValue & 0xFF) == (g_Reg->ENTRYHI_REGISTER & 0xFF))) //SameAsid - { - g_Reg->INDEX_REGISTER = Counter; - int FastIndx = Counter << 1; - m_FastTlb[FastIndx].Probed = true; - m_FastTlb[FastIndx + 1].Probed = true; - return; - } - } - } - WriteTrace(TraceTLB,__FUNCTION__ ": Done"); + WriteTrace(TraceTLB,__FUNCTION__ ": Start"); + g_Reg->INDEX_REGISTER |= 0x80000000; + for (Counter = 0; Counter < 32; Counter ++) + { + if (!m_tlb[Counter].EntryDefined) + { + continue; + } + + uint32_t & TlbEntryHiValue = m_tlb[Counter].EntryHi.Value; + uint32_t Mask = ~m_tlb[Counter].PageMask.Mask << 13; + uint32_t TlbValueMasked = TlbEntryHiValue & Mask; + uint32_t EntryHiMasked = g_Reg->ENTRYHI_REGISTER & Mask; + + if (TlbValueMasked == EntryHiMasked) + { + if ((TlbEntryHiValue & 0x100) != 0 || //Global + ((TlbEntryHiValue & 0xFF) == (g_Reg->ENTRYHI_REGISTER & 0xFF))) //SameAsid + { + g_Reg->INDEX_REGISTER = Counter; + int FastIndx = Counter << 1; + m_FastTlb[FastIndx].Probed = true; + m_FastTlb[FastIndx + 1].Probed = true; + return; + } + } + } + WriteTrace(TraceTLB,__FUNCTION__ ": Done"); } void CTLB::ReadEntry() { - DWORD index = g_Reg->INDEX_REGISTER & 0x1F; + uint32_t index = g_Reg->INDEX_REGISTER & 0x1F; - g_Reg->PAGE_MASK_REGISTER = m_tlb[index].PageMask.Value ; - g_Reg->ENTRYHI_REGISTER = (m_tlb[index].EntryHi.Value & ~m_tlb[index].PageMask.Value) ; - g_Reg->ENTRYLO0_REGISTER = m_tlb[index].EntryLo0.Value; - g_Reg->ENTRYLO1_REGISTER = m_tlb[index].EntryLo1.Value; + g_Reg->PAGE_MASK_REGISTER = m_tlb[index].PageMask.Value ; + g_Reg->ENTRYHI_REGISTER = (m_tlb[index].EntryHi.Value & ~m_tlb[index].PageMask.Value) ; + g_Reg->ENTRYLO0_REGISTER = m_tlb[index].EntryLo0.Value; + g_Reg->ENTRYLO1_REGISTER = m_tlb[index].EntryLo1.Value; } void CTLB::WriteEntry (int index, bool Random) { - int FastIndx; + int FastIndx; - WriteTraceF(TraceTLB,__FUNCTION__ ": %02d %d %08X %08X %08X %08X ",index,Random,g_Reg->PAGE_MASK_REGISTER,g_Reg->ENTRYHI_REGISTER,g_Reg->ENTRYLO0_REGISTER,g_Reg->ENTRYLO1_REGISTER); + WriteTraceF(TraceTLB,__FUNCTION__ ": %02d %d %08X %08X %08X %08X ",index,Random,g_Reg->PAGE_MASK_REGISTER,g_Reg->ENTRYHI_REGISTER,g_Reg->ENTRYLO0_REGISTER,g_Reg->ENTRYLO1_REGISTER); - //Check to see if entry is unmapping it self - if (m_tlb[index].EntryDefined) - { - FastIndx = index << 1; - if (*_PROGRAM_COUNTER >= m_FastTlb[FastIndx].VSTART && - *_PROGRAM_COUNTER < m_FastTlb[FastIndx].VEND && - m_FastTlb[FastIndx].ValidEntry && m_FastTlb[FastIndx].VALID) - { - WriteTraceF(TraceTLB,__FUNCTION__ ": Ignored PC: %X VAddr Start: %X VEND: %X",*_PROGRAM_COUNTER,m_FastTlb[FastIndx].VSTART,m_FastTlb[FastIndx].VEND); - return; - } - if (*_PROGRAM_COUNTER >= m_FastTlb[FastIndx + 1].VSTART && - *_PROGRAM_COUNTER < m_FastTlb[FastIndx + 1].VEND && - m_FastTlb[FastIndx + 1].ValidEntry && m_FastTlb[FastIndx + 1].VALID) - { - WriteTraceF(TraceTLB,__FUNCTION__ ": Ignored PC: %X VAddr Start: %X VEND: %X",*_PROGRAM_COUNTER,m_FastTlb[FastIndx + 1].VSTART,m_FastTlb[FastIndx + 1].VEND); - return; - } - } + //Check to see if entry is unmapping it self + if (m_tlb[index].EntryDefined) + { + FastIndx = index << 1; + if (*_PROGRAM_COUNTER >= m_FastTlb[FastIndx].VSTART && + *_PROGRAM_COUNTER < m_FastTlb[FastIndx].VEND && + m_FastTlb[FastIndx].ValidEntry && m_FastTlb[FastIndx].VALID) + { + WriteTraceF(TraceTLB,__FUNCTION__ ": Ignored PC: %X VAddr Start: %X VEND: %X",*_PROGRAM_COUNTER,m_FastTlb[FastIndx].VSTART,m_FastTlb[FastIndx].VEND); + return; + } + if (*_PROGRAM_COUNTER >= m_FastTlb[FastIndx + 1].VSTART && + *_PROGRAM_COUNTER < m_FastTlb[FastIndx + 1].VEND && + m_FastTlb[FastIndx + 1].ValidEntry && m_FastTlb[FastIndx + 1].VALID) + { + WriteTraceF(TraceTLB,__FUNCTION__ ": Ignored PC: %X VAddr Start: %X VEND: %X",*_PROGRAM_COUNTER,m_FastTlb[FastIndx + 1].VSTART,m_FastTlb[FastIndx + 1].VEND); + return; + } + } - //Reset old addresses - if (m_tlb[index].EntryDefined) - { - for ( FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++) - { - if (!m_FastTlb[FastIndx].ValidEntry) - { - continue; - } - if (!m_FastTlb[FastIndx].VALID) - { - continue; - } - if (m_tlb[index].PageMask.Value == g_Reg->PAGE_MASK_REGISTER && - m_tlb[index].EntryHi.Value == g_Reg->ENTRYHI_REGISTER) - { - if (FastIndx == (index << 1) && m_tlb[index].EntryLo0.Value == g_Reg->ENTRYLO0_REGISTER) - { - continue; - } - if (FastIndx != (index << 1) && m_tlb[index].EntryLo1.Value == g_Reg->ENTRYLO1_REGISTER) - { - continue; - } - } - m_CB->TLB_Unmaped(m_FastTlb[FastIndx].VSTART,m_FastTlb[FastIndx].Length); - } - } - - //fill in m_tlb entry - m_tlb[index].PageMask.Value = g_Reg->PAGE_MASK_REGISTER; - m_tlb[index].EntryHi.Value = g_Reg->ENTRYHI_REGISTER; - m_tlb[index].EntryLo0.Value = g_Reg->ENTRYLO0_REGISTER; - m_tlb[index].EntryLo1.Value = g_Reg->ENTRYLO1_REGISTER; - m_tlb[index].EntryDefined = true; - SetupTLB_Entry(index,Random); - m_CB->TLB_Changed(); + //Reset old addresses + if (m_tlb[index].EntryDefined) + { + for ( FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++) + { + if (!m_FastTlb[FastIndx].ValidEntry) + { + continue; + } + if (!m_FastTlb[FastIndx].VALID) + { + continue; + } + if (m_tlb[index].PageMask.Value == g_Reg->PAGE_MASK_REGISTER && + m_tlb[index].EntryHi.Value == g_Reg->ENTRYHI_REGISTER) + { + if (FastIndx == (index << 1) && m_tlb[index].EntryLo0.Value == g_Reg->ENTRYLO0_REGISTER) + { + continue; + } + if (FastIndx != (index << 1) && m_tlb[index].EntryLo1.Value == g_Reg->ENTRYLO1_REGISTER) + { + continue; + } + } + m_CB->TLB_Unmaped(m_FastTlb[FastIndx].VSTART,m_FastTlb[FastIndx].Length); + } + } + + //fill in m_tlb entry + m_tlb[index].PageMask.Value = g_Reg->PAGE_MASK_REGISTER; + m_tlb[index].EntryHi.Value = g_Reg->ENTRYHI_REGISTER; + m_tlb[index].EntryLo0.Value = g_Reg->ENTRYLO0_REGISTER; + m_tlb[index].EntryLo1.Value = g_Reg->ENTRYLO1_REGISTER; + m_tlb[index].EntryDefined = true; + SetupTLB_Entry(index,Random); + m_CB->TLB_Changed(); } void CTLB::SetupTLB_Entry (int index, bool Random) { - //Fix up Fast TLB entries - if (!m_tlb[index].EntryDefined) - { - return; - } + //Fix up Fast TLB entries + if (!m_tlb[index].EntryDefined) + { + return; + } - int FastIndx = index << 1; - if (m_FastTlb[FastIndx].VALID) - { - m_CB->TLB_Unmaped(m_FastTlb[FastIndx].VSTART,m_FastTlb[FastIndx].Length); - } - m_FastTlb[FastIndx].Length = (m_tlb[index].PageMask.Mask << 12) + 0xFFF; - m_FastTlb[FastIndx].VSTART=m_tlb[index].EntryHi.VPN2 << 13; - m_FastTlb[FastIndx].VEND = m_FastTlb[FastIndx].VSTART + m_FastTlb[FastIndx].Length; - m_FastTlb[FastIndx].PHYSSTART = m_tlb[index].EntryLo0.PFN << 12; - m_FastTlb[FastIndx].PHYSEND = m_FastTlb[FastIndx].PHYSSTART + m_FastTlb[FastIndx].Length; - m_FastTlb[FastIndx].VALID = m_tlb[index].EntryLo0.V; - m_FastTlb[FastIndx].DIRTY = m_tlb[index].EntryLo0.D; - m_FastTlb[FastIndx].GLOBAL = m_tlb[index].EntryLo0.GLOBAL & m_tlb[index].EntryLo1.GLOBAL; - m_FastTlb[FastIndx].ValidEntry = false; - m_FastTlb[FastIndx].Random = Random; - m_FastTlb[FastIndx].Probed = false; + int FastIndx = index << 1; + if (m_FastTlb[FastIndx].VALID) + { + m_CB->TLB_Unmaped(m_FastTlb[FastIndx].VSTART,m_FastTlb[FastIndx].Length); + } + m_FastTlb[FastIndx].Length = (m_tlb[index].PageMask.Mask << 12) + 0xFFF; + m_FastTlb[FastIndx].VSTART=m_tlb[index].EntryHi.VPN2 << 13; + m_FastTlb[FastIndx].VEND = m_FastTlb[FastIndx].VSTART + m_FastTlb[FastIndx].Length; + m_FastTlb[FastIndx].PHYSSTART = m_tlb[index].EntryLo0.PFN << 12; + m_FastTlb[FastIndx].PHYSEND = m_FastTlb[FastIndx].PHYSSTART + m_FastTlb[FastIndx].Length; + m_FastTlb[FastIndx].VALID = m_tlb[index].EntryLo0.V; + m_FastTlb[FastIndx].DIRTY = m_tlb[index].EntryLo0.D; + m_FastTlb[FastIndx].GLOBAL = m_tlb[index].EntryLo0.GLOBAL & m_tlb[index].EntryLo1.GLOBAL; + m_FastTlb[FastIndx].ValidEntry = false; + m_FastTlb[FastIndx].Random = Random; + m_FastTlb[FastIndx].Probed = false; + FastIndx = (index << 1) + 1; + if (m_FastTlb[FastIndx].VALID) + { + m_CB->TLB_Unmaped(m_FastTlb[FastIndx].VSTART,m_FastTlb[FastIndx].Length); + } + m_FastTlb[FastIndx].Length = (m_tlb[index].PageMask.Mask << 12) + 0xFFF; + m_FastTlb[FastIndx].VSTART=(m_tlb[index].EntryHi.VPN2 << 13) + (m_FastTlb[FastIndx].Length + 1); + m_FastTlb[FastIndx].VEND = m_FastTlb[FastIndx].VSTART + m_FastTlb[FastIndx].Length; + m_FastTlb[FastIndx].PHYSSTART = m_tlb[index].EntryLo1.PFN << 12; + m_FastTlb[FastIndx].PHYSEND = m_FastTlb[FastIndx].PHYSSTART + m_FastTlb[FastIndx].Length; + m_FastTlb[FastIndx].VALID = m_tlb[index].EntryLo1.V; + m_FastTlb[FastIndx].DIRTY = m_tlb[index].EntryLo1.D; + m_FastTlb[FastIndx].GLOBAL = m_tlb[index].EntryLo0.GLOBAL & m_tlb[index].EntryLo1.GLOBAL; + m_FastTlb[FastIndx].ValidEntry = false; + m_FastTlb[FastIndx].Random = Random; + m_FastTlb[FastIndx].Probed = false; - FastIndx = (index << 1) + 1; - if (m_FastTlb[FastIndx].VALID) - { - m_CB->TLB_Unmaped(m_FastTlb[FastIndx].VSTART,m_FastTlb[FastIndx].Length); - } - m_FastTlb[FastIndx].Length = (m_tlb[index].PageMask.Mask << 12) + 0xFFF; - m_FastTlb[FastIndx].VSTART=(m_tlb[index].EntryHi.VPN2 << 13) + (m_FastTlb[FastIndx].Length + 1); - m_FastTlb[FastIndx].VEND = m_FastTlb[FastIndx].VSTART + m_FastTlb[FastIndx].Length; - m_FastTlb[FastIndx].PHYSSTART = m_tlb[index].EntryLo1.PFN << 12; - m_FastTlb[FastIndx].PHYSEND = m_FastTlb[FastIndx].PHYSSTART + m_FastTlb[FastIndx].Length; - m_FastTlb[FastIndx].VALID = m_tlb[index].EntryLo1.V; - m_FastTlb[FastIndx].DIRTY = m_tlb[index].EntryLo1.D; - m_FastTlb[FastIndx].GLOBAL = m_tlb[index].EntryLo0.GLOBAL & m_tlb[index].EntryLo1.GLOBAL; - m_FastTlb[FastIndx].ValidEntry = false; - m_FastTlb[FastIndx].Random = Random; - m_FastTlb[FastIndx].Probed = false; + //Test both entries to see if they are valid + for ( FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++) + { + if (!m_FastTlb[FastIndx].VALID) + { + m_FastTlb[FastIndx].ValidEntry = true; + continue; + } - //Test both entries to see if they are valid - for ( FastIndx = index << 1; FastIndx <= (index << 1) + 1; FastIndx++) - { - if (!m_FastTlb[FastIndx].VALID) - { - m_FastTlb[FastIndx].ValidEntry = true; - continue; - } - - if (m_FastTlb[FastIndx].VEND <= m_FastTlb[FastIndx].VSTART) - { - continue; - } - if (m_FastTlb[FastIndx].VSTART >= 0x80000000 && m_FastTlb[FastIndx].VEND <= 0xBFFFFFFF) - { - continue; - } - if (m_FastTlb[FastIndx].PHYSSTART > 0x1FFFFFFF) - { - continue; - } - - //MAP the new m_tlb entry for reading and writing - m_FastTlb[FastIndx].ValidEntry = true; - m_CB->TLB_Mapped(m_FastTlb[FastIndx].VSTART,m_FastTlb[FastIndx].Length,m_FastTlb[FastIndx].PHYSSTART, !m_FastTlb[FastIndx].DIRTY); - } + if (m_FastTlb[FastIndx].VEND <= m_FastTlb[FastIndx].VSTART) + { + continue; + } + if (m_FastTlb[FastIndx].VSTART >= 0x80000000 && m_FastTlb[FastIndx].VEND <= 0xBFFFFFFF) + { + continue; + } + if (m_FastTlb[FastIndx].PHYSSTART > 0x1FFFFFFF) + { + continue; + } + + //MAP the new m_tlb entry for reading and writing + m_FastTlb[FastIndx].ValidEntry = true; + m_CB->TLB_Mapped(m_FastTlb[FastIndx].VSTART,m_FastTlb[FastIndx].Length,m_FastTlb[FastIndx].PHYSSTART, !m_FastTlb[FastIndx].DIRTY); + } } -bool CTLB::PAddrToVAddr(DWORD PAddr, DWORD & VAddr, DWORD & Index ) +bool CTLB::PAddrToVAddr(uint32_t PAddr, uint32_t & VAddr, uint32_t & Index ) { - for (int i = Index; i < 64; i++) - { - if (m_FastTlb[i].ValidEntry == false) - { - continue; - } - if (PAddr >= m_FastTlb[i].PHYSSTART && PAddr < m_FastTlb[i].PHYSEND) - { - VAddr = m_FastTlb[i].VSTART + (PAddr - m_FastTlb[i].PHYSSTART); - Index = i + 1; - return true; - } - - } - return false; + for (int i = Index; i < 64; i++) + { + if (m_FastTlb[i].ValidEntry == false) + { + continue; + } + if (PAddr >= m_FastTlb[i].PHYSSTART && PAddr < m_FastTlb[i].PHYSEND) + { + VAddr = m_FastTlb[i].VSTART + (PAddr - m_FastTlb[i].PHYSSTART); + Index = i + 1; + return true; + } + } + return false; } void CTLB::RecordDifference( CLog &LogFile, const CTLB& rTLB) { - for (int i = 0, n = sizeof(m_tlb)/sizeof(m_tlb[0]); i < n; i++) - { - if (m_tlb[i].EntryDefined != rTLB.m_tlb[i].EntryDefined) - { - LogFile.LogF("TLB[%d] Defined: %s %s\r\n",i,m_tlb[i].EntryDefined ? "Yes" : "No",rTLB.m_tlb[i].EntryDefined ? "Yes" : "No"); - continue; - } - if (!m_tlb[i].EntryDefined) - { - continue; - } - if (m_tlb[i].PageMask.Value != rTLB.m_tlb[i].PageMask.Value) - { - LogFile.LogF("TLB[%d] PageMask: %X %X\r\n",i,m_tlb[i].PageMask.Value,rTLB.m_tlb[i].PageMask.Value); - } - if (m_tlb[i].EntryHi.Value != rTLB.m_tlb[i].EntryHi.Value) - { - LogFile.LogF("TLB[%d] EntryHi: %X %X\r\n",i,m_tlb[i].EntryHi.Value,rTLB.m_tlb[i].EntryHi.Value); - } - if (m_tlb[i].EntryLo0.Value != rTLB.m_tlb[i].EntryLo0.Value) - { - LogFile.LogF("TLB[%d] EntryLo0: %X %X\r\n",i,m_tlb[i].EntryLo0.Value,rTLB.m_tlb[i].EntryLo0.Value); - } - if (m_tlb[i].EntryLo1.Value != rTLB.m_tlb[i].EntryLo1.Value) - { - LogFile.LogF("TLB[%d] EntryLo1: %X %X\r\n",i,m_tlb[i].EntryLo1.Value,rTLB.m_tlb[i].EntryLo1.Value); - } - } + for (int i = 0, n = sizeof(m_tlb)/sizeof(m_tlb[0]); i < n; i++) + { + if (m_tlb[i].EntryDefined != rTLB.m_tlb[i].EntryDefined) + { + LogFile.LogF("TLB[%d] Defined: %s %s\r\n",i,m_tlb[i].EntryDefined ? "Yes" : "No",rTLB.m_tlb[i].EntryDefined ? "Yes" : "No"); + continue; + } + if (!m_tlb[i].EntryDefined) + { + continue; + } + if (m_tlb[i].PageMask.Value != rTLB.m_tlb[i].PageMask.Value) + { + LogFile.LogF("TLB[%d] PageMask: %X %X\r\n",i,m_tlb[i].PageMask.Value,rTLB.m_tlb[i].PageMask.Value); + } + if (m_tlb[i].EntryHi.Value != rTLB.m_tlb[i].EntryHi.Value) + { + LogFile.LogF("TLB[%d] EntryHi: %X %X\r\n",i,m_tlb[i].EntryHi.Value,rTLB.m_tlb[i].EntryHi.Value); + } + if (m_tlb[i].EntryLo0.Value != rTLB.m_tlb[i].EntryLo0.Value) + { + LogFile.LogF("TLB[%d] EntryLo0: %X %X\r\n",i,m_tlb[i].EntryLo0.Value,rTLB.m_tlb[i].EntryLo0.Value); + } + if (m_tlb[i].EntryLo1.Value != rTLB.m_tlb[i].EntryLo1.Value) + { + LogFile.LogF("TLB[%d] EntryLo1: %X %X\r\n",i,m_tlb[i].EntryLo1.Value,rTLB.m_tlb[i].EntryLo1.Value); + } + } } bool CTLB::operator == (const CTLB& rTLB) const { - for (int i = 0, n = sizeof(m_tlb)/sizeof(m_tlb[0]); i < n; i++) - { - if (m_tlb[i].EntryDefined != rTLB.m_tlb[i].EntryDefined) - { - return false; - } - if (!m_tlb[i].EntryDefined) - { - continue; - } - if (m_tlb[i].PageMask.Value != rTLB.m_tlb[i].PageMask.Value || - m_tlb[i].EntryHi.Value != rTLB.m_tlb[i].EntryHi.Value || - m_tlb[i].EntryLo0.Value != rTLB.m_tlb[i].EntryLo0.Value || - m_tlb[i].EntryLo1.Value != rTLB.m_tlb[i].EntryLo1.Value) - { - return false; - } - } - return true; + for (int i = 0, n = sizeof(m_tlb)/sizeof(m_tlb[0]); i < n; i++) + { + if (m_tlb[i].EntryDefined != rTLB.m_tlb[i].EntryDefined) + { + return false; + } + if (!m_tlb[i].EntryDefined) + { + continue; + } + if (m_tlb[i].PageMask.Value != rTLB.m_tlb[i].PageMask.Value || + m_tlb[i].EntryHi.Value != rTLB.m_tlb[i].EntryHi.Value || + m_tlb[i].EntryLo0.Value != rTLB.m_tlb[i].EntryLo0.Value || + m_tlb[i].EntryLo1.Value != rTLB.m_tlb[i].EntryLo1.Value) + { + return false; + } + } + return true; } bool CTLB::operator != (const CTLB& rTLB) const { - return !(*this == rTLB); + return !(*this == rTLB); } diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index a3768b691..e8539ae97 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -2073,12 +2073,12 @@ bool CN64System::WriteToProtectedMemory (uint32_t Address, int length) return false; } -void CN64System::TLB_Mapped ( DWORD VAddr, DWORD Len, DWORD PAddr, bool bReadOnly ) +void CN64System::TLB_Mapped ( uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly ) { m_MMU_VM.TLB_Mapped(VAddr,Len,PAddr,bReadOnly); } -void CN64System::TLB_Unmaped ( DWORD VAddr, DWORD Len ) +void CN64System::TLB_Unmaped ( uint32_t VAddr, uint32_t Len ) { m_MMU_VM.TLB_Unmaped(VAddr,Len); if (m_Recomp && bSMM_TLB()) diff --git a/Source/Project64/N64 System/N64 Class.h b/Source/Project64/N64 System/N64 Class.h index 9f3ff3693..d7fb18411 100644 --- a/Source/Project64/N64 System/N64 Class.h +++ b/Source/Project64/N64 System/N64 Class.h @@ -114,8 +114,8 @@ private: virtual bool WriteToProtectedMemory(uint32_t Address, int length); //Functions in CTLB_CB - void TLB_Mapped(DWORD VAddr, DWORD Len, DWORD PAddr, bool bReadOnly); - void TLB_Unmaped(DWORD VAddr, DWORD Len); + void TLB_Mapped(uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly); + void TLB_Unmaped(uint32_t VAddr, uint32_t Len); void TLB_Changed(); CPlugins * const m_Plugins; //The plugin container diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp index 6a89fb767..41f88d0e5 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp @@ -908,7 +908,7 @@ void CRecompiler::ClearRecompCode_Phys(DWORD Address, int length, REMOVE_REASON if (g_System->bUseTlb()) { - DWORD VAddr, Index = 0; + uint32_t VAddr, Index = 0; while (g_TLB->PAddrToVAddr(Address,VAddr,Index)) { WriteTraceF(TraceRecompiler,__FUNCTION__ ": ClearRecompCode Vaddr %X len: %d",VAddr,length); From 0f4be7ffa60e501552f170a2228f07dbf9428881 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 9 Nov 2015 17:55:16 +1100 Subject: [PATCH 099/213] [Project64] update Code Section to use standard types --- .../N64 System/Recompiler/Code Section.cpp | 1877 +++++++++-------- .../N64 System/Recompiler/Code Section.h | 65 +- 2 files changed, 1063 insertions(+), 879 deletions(-) diff --git a/Source/Project64/N64 System/Recompiler/Code Section.cpp b/Source/Project64/N64 System/Recompiler/Code Section.cpp index 0567ad138..523edd003 100644 --- a/Source/Project64/N64 System/Recompiler/Code Section.cpp +++ b/Source/Project64/N64 System/Recompiler/Code Section.cpp @@ -14,112 +14,122 @@ void InPermLoop(); bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2); -static bool DelaySlotEffectsJump(DWORD JumpPC) { +static bool DelaySlotEffectsJump(uint32_t JumpPC) +{ OPCODE Command; if (!g_MMU->LW_VAddr(JumpPC, Command.Hex)) return true; - switch (Command.op) { + switch (Command.op) + { case R4300i_SPECIAL: - switch (Command.funct) { - case R4300i_SPECIAL_JR: return DelaySlotEffectsCompare(JumpPC,Command.rs,0); - case R4300i_SPECIAL_JALR: return DelaySlotEffectsCompare(JumpPC,Command.rs,31); + switch (Command.funct) + { + case R4300i_SPECIAL_JR: return DelaySlotEffectsCompare(JumpPC, Command.rs, 0); + case R4300i_SPECIAL_JALR: return DelaySlotEffectsCompare(JumpPC, Command.rs, 31); } break; case R4300i_REGIMM: - switch (Command.rt) { + switch (Command.rt) + { case R4300i_REGIMM_BLTZ: case R4300i_REGIMM_BGEZ: case R4300i_REGIMM_BLTZL: case R4300i_REGIMM_BGEZL: case R4300i_REGIMM_BLTZAL: case R4300i_REGIMM_BGEZAL: - return DelaySlotEffectsCompare(JumpPC,Command.rs,0); + return DelaySlotEffectsCompare(JumpPC, Command.rs, 0); } break; - case R4300i_JAL: - case R4300i_SPECIAL_JALR: return DelaySlotEffectsCompare(JumpPC,31,0); break; + case R4300i_JAL: + case R4300i_SPECIAL_JALR: return DelaySlotEffectsCompare(JumpPC, 31, 0); break; case R4300i_J: return false; - case R4300i_BEQ: - case R4300i_BNE: - case R4300i_BLEZ: - case R4300i_BGTZ: - return DelaySlotEffectsCompare(JumpPC,Command.rs,Command.rt); + case R4300i_BEQ: + case R4300i_BNE: + case R4300i_BLEZ: + case R4300i_BGTZ: + return DelaySlotEffectsCompare(JumpPC, Command.rs, Command.rt); case R4300i_CP1: - switch (Command.fmt) { + switch (Command.fmt) + { case R4300i_COP1_BC: - switch (Command.ft) { + switch (Command.ft) + { case R4300i_COP1_BC_BCF: case R4300i_COP1_BC_BCT: case R4300i_COP1_BC_BCFL: case R4300i_COP1_BC_BCTL: + { + bool EffectDelaySlot = false; + OPCODE NewCommand; + + if (!g_MMU->LW_VAddr(JumpPC + 4, NewCommand.Hex)) { - bool EffectDelaySlot = false; - OPCODE NewCommand; + return true; + } - if (!g_MMU->LW_VAddr(JumpPC + 4, NewCommand.Hex)) { - return true; + if (NewCommand.op == R4300i_CP1) + { + if (NewCommand.fmt == R4300i_COP1_S && (NewCommand.funct & 0x30) == 0x30) + { + EffectDelaySlot = true; } - - if (NewCommand.op == R4300i_CP1) { - if (NewCommand.fmt == R4300i_COP1_S && (NewCommand.funct & 0x30) == 0x30) { - EffectDelaySlot = true; - } - if (NewCommand.fmt == R4300i_COP1_D && (NewCommand.funct & 0x30) == 0x30) { - EffectDelaySlot = true; - } + if (NewCommand.fmt == R4300i_COP1_D && (NewCommand.funct & 0x30) == 0x30) + { + EffectDelaySlot = true; } - return EffectDelaySlot; - } - break; + } + return EffectDelaySlot; + } + break; } break; } break; - case R4300i_BEQL: - case R4300i_BNEL: - case R4300i_BLEZL: - case R4300i_BGTZL: - return DelaySlotEffectsCompare(JumpPC,Command.rs,Command.rt); + case R4300i_BEQL: + case R4300i_BNEL: + case R4300i_BLEZL: + case R4300i_BGTZL: + return DelaySlotEffectsCompare(JumpPC, Command.rs, Command.rt); } return true; } -CCodeSection::CCodeSection( CCodeBlock * CodeBlock, DWORD EnterPC, DWORD ID, bool LinkAllowed) : - m_BlockInfo(CodeBlock), - m_SectionID(ID), - m_EnterPC(EnterPC), - m_EndPC((DWORD)-1), - m_ContinueSection(NULL), - m_JumpSection(NULL), - m_EndSection(false), - m_LinkAllowed(LinkAllowed), - m_Test(0), - m_Test2(0), - m_CompiledLocation(NULL), - m_InLoop(false), - m_DelaySlot(false) +CCodeSection::CCodeSection(CCodeBlock * CodeBlock, uint32_t EnterPC, uint32_t ID, bool LinkAllowed) : +m_BlockInfo(CodeBlock), +m_SectionID(ID), +m_EnterPC(EnterPC), +m_EndPC((uint32_t)-1), +m_ContinueSection(NULL), +m_JumpSection(NULL), +m_EndSection(false), +m_LinkAllowed(LinkAllowed), +m_Test(0), +m_Test2(0), +m_CompiledLocation(NULL), +m_InLoop(false), +m_DelaySlot(false) { - CPU_Message(__FUNCTION__ ": ID %d EnterPC 0x%08X",ID,EnterPC); + CPU_Message(__FUNCTION__ ": ID %d EnterPC 0x%08X", ID, EnterPC); } CCodeSection::~CCodeSection() { } -void CCodeSection::CompileExit(DWORD JumpPC, DWORD TargetPC, CRegInfo &ExitRegSet, CExitInfo::EXIT_REASON reason, bool CompileNow, void(*x86Jmp)(const char * Label, uint32_t Value)) +void CCodeSection::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, CExitInfo::EXIT_REASON reason, bool CompileNow, void(*x86Jmp)(const char * Label, uint32_t Value)) { - if (!CompileNow) + if (!CompileNow) { char String[100]; - sprintf(String,"Exit_%d",m_BlockInfo->m_ExitInfo.size()); - if (x86Jmp == NULL) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); + sprintf(String, "Exit_%d", m_BlockInfo->m_ExitInfo.size()); + if (x86Jmp == NULL) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); return; } - x86Jmp(String,0); + x86Jmp(String, 0); CExitInfo ExitInfo; ExitInfo.ID = m_BlockInfo->m_ExitInfo.size(); @@ -135,211 +145,229 @@ void CCodeSection::CompileExit(DWORD JumpPC, DWORD TargetPC, CRegInfo &ExitRegSe //CPU_Message("CompileExit: %d",reason); ExitRegSet.WriteBackRegisters(); - if (TargetPC != (DWORD)-1) + if (TargetPC != (uint32_t)-1) { - MoveConstToVariable(TargetPC,&g_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER"); - UpdateCounters(ExitRegSet,TargetPC <= JumpPC && JumpPC != -1, reason == CExitInfo::Normal); - } else { - UpdateCounters(ExitRegSet,false,reason == CExitInfo::Normal); + MoveConstToVariable(TargetPC, &g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER"); + UpdateCounters(ExitRegSet, TargetPC <= JumpPC && JumpPC != -1, reason == CExitInfo::Normal); + } + else + { + UpdateCounters(ExitRegSet, false, reason == CExitInfo::Normal); } - switch (reason) { + switch (reason) + { case CExitInfo::Normal: case CExitInfo::Normal_NoSysCheck: ExitRegSet.SetBlockCycleCount(0); - if (TargetPC != (DWORD)-1) + if (TargetPC != (uint32_t)-1) { if (TargetPC <= JumpPC && reason == CExitInfo::Normal) { CPU_Message("CompileSystemCheck 1"); - CompileSystemCheck((DWORD)-1,ExitRegSet); + CompileSystemCheck((uint32_t)-1, ExitRegSet); } - } else { - if (reason == CExitInfo::Normal) + } + else + { + if (reason == CExitInfo::Normal) { CPU_Message("CompileSystemCheck 2"); - CompileSystemCheck((DWORD)-1,ExitRegSet); + CompileSystemCheck((uint32_t)-1, ExitRegSet); } } if (g_SyncSystem) { - MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); + MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); } - #ifdef LinkBlocks +#ifdef LinkBlocks if (bSMM_ValidFunc == false) { - if (LookUpMode() == FuncFind_ChangeMemory) + if (LookUpMode() == FuncFind_ChangeMemory) { g_Notify->BreakPoint(__FILEW__,__LINE__); - // BYTE * Jump, * Jump2; - // if (TargetPC >= 0x80000000 && TargetPC < 0xC0000000) { - // DWORD pAddr = TargetPC & 0x1FFFFFFF; - // - // MoveVariableToX86reg((BYTE *)RDRAM + pAddr,"RDRAM + pAddr",x86_EAX); - // Jump2 = NULL; - // } else { - // MoveConstToX86reg((TargetPC >> 12),x86_ECX); - // MoveConstToX86reg(TargetPC,x86_EBX); - // MoveVariableDispToX86Reg(TLB_ReadMap,"TLB_ReadMap",x86_ECX,x86_ECX,4); - // TestX86RegToX86Reg(x86_ECX,x86_ECX); - // JeLabel8("NoTlbEntry",0); - // Jump2 = m_RecompPos - 1; - // MoveX86regPointerToX86reg(x86_ECX, x86_EBX,x86_EAX); - // } - // MoveX86RegToX86Reg(x86_EAX,x86_ECX); - // AndConstToX86Reg(x86_ECX,0xFFFF0000); - // CompConstToX86reg(x86_ECX,0x7C7C0000); - // JneLabel8("NoCode",0); - // Jump = m_RecompPos - 1; - // AndConstToX86Reg(x86_EAX,0xFFFF); - // ShiftLeftSignImmed(x86_EAX,4); - // AddConstToX86Reg(x86_EAX,0xC); - // MoveVariableDispToX86Reg(OrigMem,"OrigMem",x86_ECX,x86_EAX,1); - // JmpDirectReg(x86_ECX); - // CPU_Message(" NoCode:"); - // *((BYTE *)(Jump))=(BYTE)(m_RecompPos - Jump - 1); - // if (Jump2 != NULL) { - // CPU_Message(" NoTlbEntry:"); - // *((BYTE *)(Jump2))=(BYTE)(m_RecompPos - Jump2 - 1); - // } - } + // uint8_t * Jump, * Jump2; + // if (TargetPC >= 0x80000000 && TargetPC < 0xC0000000) { + // uint32_t pAddr = TargetPC & 0x1FFFFFFF; + // + // MoveVariableToX86reg((uint8_t *)RDRAM + pAddr,"RDRAM + pAddr",x86_EAX); + // Jump2 = NULL; + // } else { + // MoveConstToX86reg((TargetPC >> 12),x86_ECX); + // MoveConstToX86reg(TargetPC,x86_EBX); + // MoveVariableDispToX86Reg(TLB_ReadMap,"TLB_ReadMap",x86_ECX,x86_ECX,4); + // TestX86RegToX86Reg(x86_ECX,x86_ECX); + // JeLabel8("NoTlbEntry",0); + // Jump2 = m_RecompPos - 1; + // MoveX86regPointerToX86reg(x86_ECX, x86_EBX,x86_EAX); + // } + // MoveX86RegToX86Reg(x86_EAX,x86_ECX); + // AndConstToX86Reg(x86_ECX,0xFFFF0000); + // CompConstToX86reg(x86_ECX,0x7C7C0000); + // JneLabel8("NoCode",0); + // Jump = m_RecompPos - 1; + // AndConstToX86Reg(x86_EAX,0xFFFF); + // ShiftLeftSignImmed(x86_EAX,4); + // AddConstToX86Reg(x86_EAX,0xC); + // MoveVariableDispToX86Reg(OrigMem,"OrigMem",x86_ECX,x86_EAX,1); + // JmpDirectReg(x86_ECX); + // CPU_Message(" NoCode:"); + // *((uint8_t *)(Jump))=(uint8_t)(m_RecompPos - Jump - 1); + // if (Jump2 != NULL) { + // CPU_Message(" NoTlbEntry:"); + // *((uint8_t *)(Jump2))=(uint8_t)(m_RecompPos - Jump2 - 1); + // } + } else if (LookUpMode() == FuncFind_VirtualLookup) - { + { MoveConstToX86reg(TargetPC,x86_EDX); - MoveConstToX86reg((DWORD)&m_Functions,x86_ECX); + MoveConstToX86reg((uint32_t)&m_Functions,x86_ECX); Call_Direct(AddressOf(&CFunctionMap::CompilerFindFunction), "CFunctionMap::CompilerFindFunction"); MoveX86RegToX86Reg(x86_EAX,x86_ECX); JecxzLabel8("NullPointer",0); - BYTE * Jump = m_RecompPos - 1; - MoveX86PointerToX86regDisp(x86_EBX,x86_ECX,0xC); + uint8_t * Jump = m_RecompPos - 1; + MoveX86PointerToX86regDisp(x86_EBX,x86_ECX,0xC); JmpDirectReg(x86_EBX); CPU_Message(" NullPointer:"); - *((BYTE *)(Jump))=(BYTE)(m_RecompPos - Jump - 1); + *((uint8_t *)(Jump))=(uint8_t)(m_RecompPos - Jump - 1); } - else if (LookUpMode() == FuncFind_PhysicalLookup) + else if (LookUpMode() == FuncFind_PhysicalLookup) { - BYTE * Jump2 = NULL; - if (TargetPC >= 0x80000000 && TargetPC < 0x90000000) { - DWORD pAddr = TargetPC & 0x1FFFFFFF; - MoveVariableToX86reg((BYTE *)JumpTable + pAddr,"JumpTable + pAddr",x86_ECX); - } else if (TargetPC >= 0x90000000 && TargetPC < 0xC0000000) { - } else { + uint8_t * Jump2 = NULL; + if (TargetPC >= 0x80000000 && TargetPC < 0x90000000) + { + uint32_t pAddr = TargetPC & 0x1FFFFFFF; + MoveVariableToX86reg((uint8_t *)JumpTable + pAddr,"JumpTable + pAddr",x86_ECX); + } + else if (TargetPC >= 0x90000000 && TargetPC < 0xC0000000) + { + } + else + { MoveConstToX86reg((TargetPC >> 12),x86_ECX); MoveConstToX86reg(TargetPC,x86_EBX); MoveVariableDispToX86Reg(TLB_ReadMap,"TLB_ReadMap",x86_ECX,x86_ECX,4); TestX86RegToX86Reg(x86_ECX,x86_ECX); JeLabel8("NoTlbEntry",0); Jump2 = m_RecompPos - 1; - AddConstToX86Reg(x86_ECX,(DWORD)JumpTable - (DWORD)RDRAM); + AddConstToX86Reg(x86_ECX,(uint32_t)JumpTable - (uint32_t)RDRAM); MoveX86regPointerToX86reg(x86_ECX, x86_EBX,x86_ECX); } if (TargetPC < 0x90000000 || TargetPC >= 0xC0000000) { JecxzLabel8("NullPointer",0); - BYTE * Jump = m_RecompPos - 1; - MoveX86PointerToX86regDisp(x86_EAX,x86_ECX,0xC); + uint8_t * Jump = m_RecompPos - 1; + MoveX86PointerToX86regDisp(x86_EAX,x86_ECX,0xC); JmpDirectReg(x86_EAX); CPU_Message(" NullPointer:"); - *((BYTE *)(Jump))=(BYTE)(m_RecompPos - Jump - 1); - if (Jump2 != NULL) { + *((uint8_t *)(Jump))=(uint8_t)(m_RecompPos - Jump - 1); + if (Jump2 != NULL) + { CPU_Message(" NoTlbEntry:"); - *((BYTE *)(Jump2))=(BYTE)(m_RecompPos - Jump2 - 1); + *((uint8_t *)(Jump2))=(uint8_t)(m_RecompPos - Jump2 - 1); } } } } ExitCodeBlock(); - #else +#else ExitCodeBlock(); - #endif +#endif break; case CExitInfo::DoCPU_Action: - MoveConstToX86reg((DWORD)g_SystemEvents,x86_ECX); - Call_Direct(AddressOf(&CSystemEvents::ExecuteEvents),"CSystemEvents::ExecuteEvents"); - if (g_SyncSystem) { - MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); + MoveConstToX86reg((uint32_t)g_SystemEvents, x86_ECX); + Call_Direct(AddressOf(&CSystemEvents::ExecuteEvents), "CSystemEvents::ExecuteEvents"); + if (g_SyncSystem) + { + MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); } //g_System->SyncCPU(g_SyncSystem); ExitCodeBlock(); break; case CExitInfo::DoSysCall: + { + bool bDelay = m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT; + PushImm32(bDelay ? "true" : "false", bDelay); + MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); + Call_Direct(AddressOf(&CRegisters::DoSysCallException), "CRegisters::DoSysCallException"); + if (g_SyncSystem) { - bool bDelay = m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT; - PushImm32(bDelay ? "true" : "false", bDelay); - MoveConstToX86reg((DWORD)g_Reg,x86_ECX); - Call_Direct(AddressOf(&CRegisters::DoSysCallException), "CRegisters::DoSysCallException"); - if (g_SyncSystem) { - MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); - } - ExitCodeBlock(); + MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); } - break; + ExitCodeBlock(); + } + break; case CExitInfo::COP1_Unuseable: + { + bool bDelay = m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT; + PushImm32("1", 1); + PushImm32(bDelay ? "true" : "false", bDelay); + MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); + Call_Direct(AddressOf(&CRegisters::DoCopUnusableException), "CRegisters::DoCopUnusableException"); + if (g_SyncSystem) { - bool bDelay = m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT; - PushImm32("1",1); - PushImm32(bDelay ? "true" : "false", bDelay); - MoveConstToX86reg((DWORD)g_Reg,x86_ECX); - Call_Direct(AddressOf(&CRegisters::DoCopUnusableException), "CRegisters::DoCopUnusableException"); - if (g_SyncSystem) { - MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); - } - ExitCodeBlock(); + MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); } - break; + ExitCodeBlock(); + } + break; case CExitInfo::ExitResetRecompCode: - g_Notify->BreakPoint(__FILEW__,__LINE__); - #ifdef tofix - if (m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT) { + g_Notify->BreakPoint(__FILEW__, __LINE__); +#ifdef tofix + if (m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT) + { X86BreakPoint(__FILEW__,__LINE__); } - if (g_SyncSystem) { - MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); + if (g_SyncSystem) + { + MoveConstToX86reg((uint32_t)g_BaseSystem,x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); } X86BreakPoint(__FILEW__,__LINE__); - MoveVariableToX86reg(this,"this",x86_ECX); + MoveVariableToX86reg(this,"this",x86_ECX); Call_Direct(AddressOf(ResetRecompCode), "ResetRecompCode"); - #endif +#endif ExitCodeBlock(); break; case CExitInfo::TLBReadMiss: - MoveVariableToX86reg(g_TLBLoadAddress,"g_TLBLoadAddress",x86_EDX); + MoveVariableToX86reg(g_TLBLoadAddress, "g_TLBLoadAddress", x86_EDX); Push(x86_EDX); PushImm32(m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT); - MoveConstToX86reg((DWORD)g_Reg,x86_ECX); - Call_Direct(AddressOf(&CRegisters::DoTLBReadMiss),"CRegisters::DoTLBReadMiss"); - if (g_SyncSystem) { - MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); + MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); + Call_Direct(AddressOf(&CRegisters::DoTLBReadMiss), "CRegisters::DoTLBReadMiss"); + if (g_SyncSystem) + { + MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); } ExitCodeBlock(); break; case CExitInfo::TLBWriteMiss: - X86BreakPoint(__FILEW__,__LINE__); + X86BreakPoint(__FILEW__, __LINE__); ExitCodeBlock(); break; case CExitInfo::DivByZero: - AddConstToVariable(4,_PROGRAM_COUNTER,"PROGRAM_COUNTER"); + AddConstToVariable(4, _PROGRAM_COUNTER, "PROGRAM_COUNTER"); if (!g_System->b32BitCore()) { - MoveConstToVariable(0,&_RegHI->UW[1],"_RegHI->UW[1]"); - MoveConstToVariable(0,&_RegLO->UW[1],"_RegLO->UW[1]"); + MoveConstToVariable(0, &_RegHI->UW[1], "_RegHI->UW[1]"); + MoveConstToVariable(0, &_RegLO->UW[1], "_RegLO->UW[1]"); } - MoveConstToVariable(0,&_RegHI->UW[0],"_RegHI->UW[0]"); - MoveConstToVariable(0,&_RegLO->UW[0],"_RegLO->UW[0]"); - if (g_SyncSystem) { - MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); + MoveConstToVariable(0, &_RegHI->UW[0], "_RegHI->UW[0]"); + MoveConstToVariable(0, &_RegLO->UW[0], "_RegLO->UW[0]"); + if (g_SyncSystem) + { + MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); } ExitCodeBlock(); break; default: - WriteTraceF(TraceError,__FUNCTION__ ": how did you want to exit on reason (%d) ???",reason); - g_Notify->BreakPoint(__FILEW__,__LINE__); + WriteTraceF(TraceError, __FUNCTION__ ": how did you want to exit on reason (%d) ???", reason); + g_Notify->BreakPoint(__FILEW__, __LINE__); } } @@ -349,45 +377,32 @@ void CCodeSection::GenerateSectionLinkage() CJumpInfo * JumpInfo[] = { &m_Cont, &m_Jump }; int i; - for (i = 0; i < 2; i ++) + for (i = 0; i < 2; i++) { - if (JumpInfo[i]->LinkLocation == NULL && - JumpInfo[i]->FallThrough == false) + if (JumpInfo[i]->LinkLocation == NULL && + JumpInfo[i]->FallThrough == false) { - JumpInfo[i]->TargetPC = (DWORD)-1; + JumpInfo[i]->TargetPC = (uint32_t)-1; } } - if ((CompilePC() & 0xFFC) == 0xFFC) + if ((CompilePC() & 0xFFC) == 0xFFC) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); #ifdef tofix //Handle Fall througth - BYTE * Jump = NULL; - for (i = 0; i < 2; i ++) { + uint8_t * Jump = NULL; + for (i = 0; i < 2; i ++) + { if (!JumpInfo[i]->FallThrough) { continue; } JumpInfo[i]->FallThrough = false; - if (JumpInfo[i]->LinkLocation != NULL) { - SetJump32(JumpInfo[i]->LinkLocation,(DWORD *)m_RecompPos); + if (JumpInfo[i]->LinkLocation != NULL) + { + SetJump32(JumpInfo[i]->LinkLocation,(uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation = NULL; - if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32(JumpInfo[i]->LinkLocation2,(DWORD *)m_RecompPos); - JumpInfo[i]->LinkLocation2 = NULL; - } - } - PushImm32(stdstr_f("0x%08X",JumpInfo[i]->TargetPC).c_str(),JumpInfo[i]->TargetPC); - if (JumpInfo[(i + 1) & 1]->LinkLocation == NULL) { break; } - JmpLabel8("FinishBlock",0); - Jump = m_RecompPos - 1; - } - for (i = 0; i < 2; i ++) { - if (JumpInfo[i]->LinkLocation == NULL) { continue; } - JumpInfo[i]->FallThrough = false; - if (JumpInfo[i]->LinkLocation != NULL) { - SetJump32(JumpInfo[i]->LinkLocation,(DWORD *)m_RecompPos); - JumpInfo[i]->LinkLocation = NULL; - if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32(JumpInfo[i]->LinkLocation2,(DWORD *)m_RecompPos); + if (JumpInfo[i]->LinkLocation2 != NULL) + { + SetJump32(JumpInfo[i]->LinkLocation2,(uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; } } @@ -396,24 +411,43 @@ void CCodeSection::GenerateSectionLinkage() JmpLabel8("FinishBlock",0); Jump = m_RecompPos - 1; } - if (Jump != NULL) { + for (i = 0; i < 2; i ++) + { + if (JumpInfo[i]->LinkLocation == NULL) { continue; } + JumpInfo[i]->FallThrough = false; + if (JumpInfo[i]->LinkLocation != NULL) + { + SetJump32(JumpInfo[i]->LinkLocation,(uint32_t *)m_RecompPos); + JumpInfo[i]->LinkLocation = NULL; + if (JumpInfo[i]->LinkLocation2 != NULL) + { + SetJump32(JumpInfo[i]->LinkLocation2,(uint32_t *)m_RecompPos); + JumpInfo[i]->LinkLocation2 = NULL; + } + } + PushImm32(stdstr_f("0x%08X",JumpInfo[i]->TargetPC).c_str(),JumpInfo[i]->TargetPC); + if (JumpInfo[(i + 1) & 1]->LinkLocation == NULL) { break; } + JmpLabel8("FinishBlock",0); + Jump = m_RecompPos - 1; + } + if (Jump != NULL) + { CPU_Message(" $FinishBlock:"); SetJump8(Jump,m_RecompPos); } //MoveConstToVariable(CompilePC() + 4,_PROGRAM_COUNTER,"PROGRAM_COUNTER"); m_RegWorkingSet.WriteBackRegisters(); UpdateCounters(m_RegWorkingSet,false,true); - // WriteBackRegisters(Section); - // if (g_SyncSystem) { - MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); - } - // MoveConstToVariable(DELAY_SLOT,&m_NextInstruction,"m_NextInstruction"); + // WriteBackRegisters(Section); + // if (g_SyncSystem) { + MoveConstToX86reg((uint32_t)g_BaseSystem,x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); + // MoveConstToVariable(DELAY_SLOT,&m_NextInstruction,"m_NextInstruction"); PushImm32(stdstr_f("0x%08X",CompilePC() + 4).c_str(),CompilePC() + 4); - + // check if there is an existing section - MoveConstToX86reg((DWORD)g_Recompiler,x86_ECX); + MoveConstToX86reg((uint32_t)g_Recompiler,x86_ECX); Call_Direct(AddressOf(&CRecompiler::CompileDelaySlot), "CRecompiler::CompileDelaySlot"); JmpDirectReg(x86_EAX); ExitCodeBlock(); @@ -422,113 +456,140 @@ void CCodeSection::GenerateSectionLinkage() } // Handle Perm Loop - if (CRecompilerOps::m_CompilePC == m_Jump.TargetPC && (m_Cont.FallThrough == false)) { - if (!DelaySlotEffectsJump(CompilePC())) { - MoveConstToVariable(CompilePC(),_PROGRAM_COUNTER,"PROGRAM_COUNTER"); + if (CRecompilerOps::m_CompilePC == m_Jump.TargetPC && (m_Cont.FallThrough == false)) + { + if (!DelaySlotEffectsJump(CompilePC())) + { + MoveConstToVariable(CompilePC(), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); m_Jump.RegSet.WriteBackRegisters(); - UpdateCounters(m_Jump.RegSet,false, true); - Call_Direct(AddressOf(CInterpreterCPU::InPermLoop),"CInterpreterCPU::InPermLoop"); - MoveConstToX86reg((DWORD)g_SystemTimer,x86_ECX); - Call_Direct(AddressOf(&CSystemTimer::TimerDone),"CSystemTimer::TimerDone"); + UpdateCounters(m_Jump.RegSet, false, true); + Call_Direct(AddressOf(CInterpreterCPU::InPermLoop), "CInterpreterCPU::InPermLoop"); + MoveConstToX86reg((uint32_t)g_SystemTimer, x86_ECX); + Call_Direct(AddressOf(&CSystemTimer::TimerDone), "CSystemTimer::TimerDone"); CPU_Message("CompileSystemCheck 3"); - CompileSystemCheck((DWORD)-1,m_Jump.RegSet); + CompileSystemCheck((uint32_t)-1, m_Jump.RegSet); } } - if (TargetSection[0] != TargetSection[1] || TargetSection[0] == NULL) { - for (i = 0; i < 2; i ++) { - if (JumpInfo[i]->LinkLocation == NULL && JumpInfo[i]->FallThrough == false) { + if (TargetSection[0] != TargetSection[1] || TargetSection[0] == NULL) + { + for (i = 0; i < 2; i++) + { + if (JumpInfo[i]->LinkLocation == NULL && JumpInfo[i]->FallThrough == false) + { if (TargetSection[i]) { TargetSection[i]->UnlinkParent(this, i == 0); TargetSection[i] = NULL; } - } else if (TargetSection[i] == NULL && JumpInfo[i]->FallThrough) { - if (JumpInfo[i]->LinkLocation != NULL) { - SetJump32((uint32_t *)JumpInfo[i]->LinkLocation,(uint32_t *)m_RecompPos); + } + else if (TargetSection[i] == NULL && JumpInfo[i]->FallThrough) + { + if (JumpInfo[i]->LinkLocation != NULL) + { + SetJump32((uint32_t *)JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation = NULL; - if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2,(uint32_t *)m_RecompPos); + if (JumpInfo[i]->LinkLocation2 != NULL) + { + SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; - } + } } - CompileExit (JumpInfo[i]->JumpPC, JumpInfo[i]->TargetPC,JumpInfo[i]->RegSet,JumpInfo[i]->ExitReason,true,NULL); + CompileExit(JumpInfo[i]->JumpPC, JumpInfo[i]->TargetPC, JumpInfo[i]->RegSet, JumpInfo[i]->ExitReason, true, NULL); JumpInfo[i]->FallThrough = false; - } else if (TargetSection[i] != NULL && JumpInfo[i] != NULL) { + } + else if (TargetSection[i] != NULL && JumpInfo[i] != NULL) + { if (!JumpInfo[i]->FallThrough) { continue; } if (JumpInfo[i]->TargetPC == TargetSection[i]->m_EnterPC) { continue; } - if (JumpInfo[i]->LinkLocation != NULL) { - SetJump32((uint32_t *)JumpInfo[i]->LinkLocation,(uint32_t *)m_RecompPos); + if (JumpInfo[i]->LinkLocation != NULL) + { + SetJump32((uint32_t *)JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation = NULL; - if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2,(uint32_t *)m_RecompPos); + if (JumpInfo[i]->LinkLocation2 != NULL) + { + SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; - } + } } - CompileExit (JumpInfo[i]->JumpPC, JumpInfo[i]->TargetPC,JumpInfo[i]->RegSet,JumpInfo[i]->ExitReason,true,NULL); + CompileExit(JumpInfo[i]->JumpPC, JumpInfo[i]->TargetPC, JumpInfo[i]->RegSet, JumpInfo[i]->ExitReason, true, NULL); //FreeSection(TargetSection[i],Section); } } - } else { + } + else + { if (m_Cont.LinkLocation == NULL && m_Cont.FallThrough == false) { m_ContinueSection = NULL; } if (m_Jump.LinkLocation == NULL && m_Jump.FallThrough == false) { m_JumpSection = NULL; } - if (m_JumpSection == NULL && m_ContinueSection == NULL) { + if (m_JumpSection == NULL && m_ContinueSection == NULL) + { //FreeSection(TargetSection[0],Section); } } TargetSection[0] = m_ContinueSection; - TargetSection[1] = m_JumpSection; + TargetSection[1] = m_JumpSection; - for (i = 0; i < 2; i ++) { + for (i = 0; i < 2; i++) { if (TargetSection[i] == NULL) { continue; } if (!JumpInfo[i]->FallThrough) { continue; } - - if (TargetSection[i]->m_CompiledLocation != NULL) { + + if (TargetSection[i]->m_CompiledLocation != NULL) + { char Label[100]; - sprintf(Label,"Section_%d",TargetSection[i]->m_SectionID); + sprintf(Label, "Section_%d", TargetSection[i]->m_SectionID); JumpInfo[i]->FallThrough = false; - if (JumpInfo[i]->LinkLocation != NULL) { - SetJump32((uint32_t *)JumpInfo[i]->LinkLocation,(uint32_t *)m_RecompPos); + if (JumpInfo[i]->LinkLocation != NULL) + { + SetJump32((uint32_t *)JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation = NULL; - if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2,(uint32_t *)m_RecompPos); + if (JumpInfo[i]->LinkLocation2 != NULL) + { + SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; } } - if (JumpInfo[i]->TargetPC <= CompilePC()) { - if (JumpInfo[i]->PermLoop) { + if (JumpInfo[i]->TargetPC <= CompilePC()) + { + if (JumpInfo[i]->PermLoop) + { CPU_Message("PermLoop *** 1"); - MoveConstToVariable(JumpInfo[i]->TargetPC,_PROGRAM_COUNTER,"PROGRAM_COUNTER"); - UpdateCounters(JumpInfo[i]->RegSet,false, true); - if (g_SyncSystem) { - MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); + MoveConstToVariable(JumpInfo[i]->TargetPC, _PROGRAM_COUNTER, "PROGRAM_COUNTER"); + UpdateCounters(JumpInfo[i]->RegSet, false, true); + if (g_SyncSystem) + { + MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); } //JumpInfo[i]->RegSet.BlockCycleCount() -= g_System->CountPerOp(); - Call_Direct(AddressOf(CInterpreterCPU::InPermLoop),"CInterpreterCPU::InPermLoop"); + Call_Direct(AddressOf(CInterpreterCPU::InPermLoop), "CInterpreterCPU::InPermLoop"); //JumpInfo[i]->RegSet.BlockCycleCount() += g_System->CountPerOp(); - UpdateCounters(JumpInfo[i]->RegSet,true,true); + UpdateCounters(JumpInfo[i]->RegSet, true, true); CPU_Message("CompileSystemCheck 4"); - CompileSystemCheck((DWORD)-1,JumpInfo[i]->RegSet); - } else { - UpdateCounters(JumpInfo[i]->RegSet,true,true); - CPU_Message("CompileSystemCheck 5"); - CompileSystemCheck(JumpInfo[i]->TargetPC,JumpInfo[i]->RegSet); + CompileSystemCheck((uint32_t)-1, JumpInfo[i]->RegSet); + } + else + { + UpdateCounters(JumpInfo[i]->RegSet, true, true); + CPU_Message("CompileSystemCheck 5"); + CompileSystemCheck(JumpInfo[i]->TargetPC, JumpInfo[i]->RegSet); } - } else { - UpdateCounters(JumpInfo[i]->RegSet,false,true); } - + else + { + UpdateCounters(JumpInfo[i]->RegSet, false, true); + } + JumpInfo[i]->RegSet.SetBlockCycleCount(0); m_RegWorkingSet = JumpInfo[i]->RegSet; - SyncRegState(TargetSection[i]->m_RegEnter); - JmpLabel32(Label,0); - SetJump32((uint32_t *)m_RecompPos - 1,(uint32_t *)(TargetSection[i]->m_CompiledLocation)); + SyncRegState(TargetSection[i]->m_RegEnter); + JmpLabel32(Label, 0); + SetJump32((uint32_t *)m_RecompPos - 1, (uint32_t *)(TargetSection[i]->m_CompiledLocation)); } } - for (i = 0; i < 2; i ++) { + for (i = 0; i < 2; i++) + { if (TargetSection[i] == NULL) { continue; } if (TargetSection[i]->m_ParentSection.empty()) { continue; } for (SECTION_LIST::iterator iter = TargetSection[i]->m_ParentSection.begin(); iter != TargetSection[i]->m_ParentSection.end(); iter++) @@ -537,103 +598,119 @@ void CCodeSection::GenerateSectionLinkage() if (Parent->m_CompiledLocation != NULL) { continue; } if (Parent->m_InLoop) { continue; } - if (JumpInfo[i]->PermLoop) + if (JumpInfo[i]->PermLoop) { CPU_Message("PermLoop *** 2"); - MoveConstToVariable(JumpInfo[i]->TargetPC,_PROGRAM_COUNTER,"PROGRAM_COUNTER"); - UpdateCounters(JumpInfo[i]->RegSet,false, true); - Call_Direct(AddressOf(CInterpreterCPU::InPermLoop),"CInterpreterCPU::InPermLoop"); - UpdateCounters(JumpInfo[i]->RegSet,true,true); + MoveConstToVariable(JumpInfo[i]->TargetPC, _PROGRAM_COUNTER, "PROGRAM_COUNTER"); + UpdateCounters(JumpInfo[i]->RegSet, false, true); + Call_Direct(AddressOf(CInterpreterCPU::InPermLoop), "CInterpreterCPU::InPermLoop"); + UpdateCounters(JumpInfo[i]->RegSet, true, true); CPU_Message("CompileSystemCheck 6"); - CompileSystemCheck((DWORD)-1,JumpInfo[i]->RegSet); + CompileSystemCheck((uint32_t)-1, JumpInfo[i]->RegSet); } - if (JumpInfo[i]->FallThrough) { + if (JumpInfo[i]->FallThrough) + { JumpInfo[i]->FallThrough = false; - JmpLabel32(JumpInfo[i]->BranchLabel.c_str(),0); + JmpLabel32(JumpInfo[i]->BranchLabel.c_str(), 0); JumpInfo[i]->LinkLocation = (DWORD*)(m_RecompPos - 4); } } } - for (i = 0; i < 2; i ++) { - if (JumpInfo[i]->FallThrough) { - if (JumpInfo[i]->TargetPC < CompilePC()) { - UpdateCounters(JumpInfo[i]->RegSet,true,true); + for (i = 0; i < 2; i++) + { + if (JumpInfo[i]->FallThrough) + { + if (JumpInfo[i]->TargetPC < CompilePC()) + { + UpdateCounters(JumpInfo[i]->RegSet, true, true); CPU_Message("CompileSystemCheck 7"); - CompileSystemCheck(JumpInfo[i]->TargetPC,JumpInfo[i]->RegSet); + CompileSystemCheck(JumpInfo[i]->TargetPC, JumpInfo[i]->RegSet); } } } - CPU_Message("====== End of Section %d ======",m_SectionID); + CPU_Message("====== End of Section %d ======", m_SectionID); - for (i = 0; i < 2; i ++) + for (i = 0; i < 2; i++) { - if (JumpInfo[i]->FallThrough && !TargetSection[i]->GenerateX86Code(m_BlockInfo->NextTest())) - { + if (JumpInfo[i]->FallThrough && !TargetSection[i]->GenerateX86Code(m_BlockInfo->NextTest())) + { JumpInfo[i]->FallThrough = false; - JmpLabel32(JumpInfo[i]->BranchLabel.c_str(),0); + JmpLabel32(JumpInfo[i]->BranchLabel.c_str(), 0); JumpInfo[i]->LinkLocation = (DWORD *)(m_RecompPos - 4); } } //CPU_Message("Section %d",m_SectionID); - for (i = 0; i < 2; i ++) { + for (i = 0; i < 2; i++) + { if (JumpInfo[i]->LinkLocation == NULL) { continue; } - if (TargetSection[i] == NULL) { - CPU_Message("ExitBlock (from %d):",m_SectionID); - SetJump32((uint32_t *)JumpInfo[i]->LinkLocation,(uint32_t *)m_RecompPos); + if (TargetSection[i] == NULL) + { + CPU_Message("ExitBlock (from %d):", m_SectionID); + SetJump32((uint32_t *)JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation = NULL; - if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2,(uint32_t *)m_RecompPos); + if (JumpInfo[i]->LinkLocation2 != NULL) + { + SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; - } - CompileExit (JumpInfo[i]->JumpPC,JumpInfo[i]->TargetPC,JumpInfo[i]->RegSet,JumpInfo[i]->ExitReason,true,NULL); + } + CompileExit(JumpInfo[i]->JumpPC, JumpInfo[i]->TargetPC, JumpInfo[i]->RegSet, JumpInfo[i]->ExitReason, true, NULL); continue; } - if (JumpInfo[i]->TargetPC != TargetSection[i]->m_EnterPC) + if (JumpInfo[i]->TargetPC != TargetSection[i]->m_EnterPC) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } - if (TargetSection[i]->m_CompiledLocation == NULL) + if (TargetSection[i]->m_CompiledLocation == NULL) { TargetSection[i]->GenerateX86Code(m_BlockInfo->NextTest()); - } else { - stdstr_f Label("Section_%d (from %d):",TargetSection[i]->m_SectionID,m_SectionID); + } + else + { + stdstr_f Label("Section_%d (from %d):", TargetSection[i]->m_SectionID, m_SectionID); CPU_Message(Label.c_str()); - SetJump32((uint32_t *)JumpInfo[i]->LinkLocation,(uint32_t *)m_RecompPos); + SetJump32((uint32_t *)JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation = NULL; - if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2,(uint32_t *)m_RecompPos); + if (JumpInfo[i]->LinkLocation2 != NULL) + { + SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; - } - m_RegWorkingSet = JumpInfo[i]->RegSet; - if (JumpInfo[i]->TargetPC <= JumpInfo[i]->JumpPC) { - UpdateCounters(JumpInfo[i]->RegSet,true,true); - if (JumpInfo[i]->PermLoop) { - CPU_Message("PermLoop *** 3"); - MoveConstToVariable(JumpInfo[i]->TargetPC,_PROGRAM_COUNTER,"PROGRAM_COUNTER"); - Call_Direct(AddressOf(CInterpreterCPU::InPermLoop),"CInterpreterCPU::InPermLoop"); - CPU_Message("CompileSystemCheck 8"); - CompileSystemCheck((DWORD)-1,JumpInfo[i]->RegSet); - } else { - CPU_Message("CompileSystemCheck 9"); - CompileSystemCheck(JumpInfo[i]->TargetPC,JumpInfo[i]->RegSet); - } - } else{ - UpdateCounters(m_RegWorkingSet,false,true); } m_RegWorkingSet = JumpInfo[i]->RegSet; - SyncRegState(TargetSection[i]->m_RegEnter); - JmpLabel32(Label.c_str(),0); - SetJump32((uint32_t *)m_RecompPos - 1,(uint32_t *)(TargetSection[i]->m_CompiledLocation)); + if (JumpInfo[i]->TargetPC <= JumpInfo[i]->JumpPC) + { + UpdateCounters(JumpInfo[i]->RegSet, true, true); + if (JumpInfo[i]->PermLoop) + { + CPU_Message("PermLoop *** 3"); + MoveConstToVariable(JumpInfo[i]->TargetPC, _PROGRAM_COUNTER, "PROGRAM_COUNTER"); + Call_Direct(AddressOf(CInterpreterCPU::InPermLoop), "CInterpreterCPU::InPermLoop"); + CPU_Message("CompileSystemCheck 8"); + CompileSystemCheck((uint32_t)-1, JumpInfo[i]->RegSet); + } + else + { + CPU_Message("CompileSystemCheck 9"); + CompileSystemCheck(JumpInfo[i]->TargetPC, JumpInfo[i]->RegSet); + } + } + else + { + UpdateCounters(m_RegWorkingSet, false, true); + } + m_RegWorkingSet = JumpInfo[i]->RegSet; + SyncRegState(TargetSection[i]->m_RegEnter); + JmpLabel32(Label.c_str(), 0); + SetJump32((uint32_t *)m_RecompPos - 1, (uint32_t *)(TargetSection[i]->m_CompiledLocation)); } } } -void CCodeSection::SyncRegState ( const CRegInfo & SyncTo ) -{ +void CCodeSection::SyncRegState(const CRegInfo & SyncTo) +{ ResetX86Protection(); bool changed = false; @@ -648,23 +725,27 @@ void CCodeSection::SyncRegState ( const CRegInfo & SyncTo ) if (TargetStackReg == x86_Unknown) { UnMap_X86reg(MemStackReg); - } else if (MemStackReg == x86_Unknown) { + } + else if (MemStackReg == x86_Unknown) + { UnMap_X86reg(TargetStackReg); - CPU_Message(" regcache: allocate %s as Memory Stack",x86_Name(TargetStackReg)); - m_RegWorkingSet.SetX86Mapped(TargetStackReg,CRegInfo::Stack_Mapped); - MoveVariableToX86reg(&g_Recompiler->MemoryStackPos(),"MemoryStack",TargetStackReg); - } else { - UnMap_X86reg(TargetStackReg); - CPU_Message(" regcache: change allocation of Memory Stack from %s to %s",x86_Name(MemStackReg),x86_Name(TargetStackReg)); + CPU_Message(" regcache: allocate %s as Memory Stack", x86_Name(TargetStackReg)); m_RegWorkingSet.SetX86Mapped(TargetStackReg, CRegInfo::Stack_Mapped); - m_RegWorkingSet.SetX86Mapped(MemStackReg,CRegInfo::NotMapped); - MoveX86RegToX86Reg(MemStackReg,TargetStackReg); + MoveVariableToX86reg(&g_Recompiler->MemoryStackPos(), "MemoryStack", TargetStackReg); + } + else + { + UnMap_X86reg(TargetStackReg); + CPU_Message(" regcache: change allocation of Memory Stack from %s to %s", x86_Name(MemStackReg), x86_Name(TargetStackReg)); + m_RegWorkingSet.SetX86Mapped(TargetStackReg, CRegInfo::Stack_Mapped); + m_RegWorkingSet.SetX86Mapped(MemStackReg, CRegInfo::NotMapped); + MoveX86RegToX86Reg(MemStackReg, TargetStackReg); } } - - for (int i = 1; i < 32; i ++) + + for (int i = 1; i < 32; i++) { - if (GetMipsRegState(i) == SyncTo.GetMipsRegState(i) || + if (GetMipsRegState(i) == SyncTo.GetMipsRegState(i) || (g_System->b32BitCore() && GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_ZERO && SyncTo.GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_SIGN) || (g_System->b32BitCore() && GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_SIGN && SyncTo.GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_ZERO)) { @@ -679,161 +760,169 @@ void CCodeSection::SyncRegState ( const CRegInfo & SyncTo ) break; case CRegInfo::STATE_MAPPED_32_ZERO: case CRegInfo::STATE_MAPPED_32_SIGN: - if (GetMipsRegMapLo(i) == SyncTo.GetMipsRegMapLo(i)) { + if (GetMipsRegMapLo(i) == SyncTo.GetMipsRegMapLo(i)) + { continue; } break; case CRegInfo::STATE_CONST_64: - if (GetMipsReg(i) != SyncTo.GetMipsReg(i)) + if (GetMipsReg(i) != SyncTo.GetMipsReg(i)) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } continue; case CRegInfo::STATE_CONST_32_SIGN: - if (GetMipsRegLo(i) != SyncTo.GetMipsRegLo(i)) + if (GetMipsRegLo(i) != SyncTo.GetMipsRegLo(i)) { - CPU_Message("Value of const is different Reg %d (%s) Value: 0x%08X to 0x%08X",i,CRegName::GPR[i],GetMipsRegLo(i),SyncTo.GetMipsRegLo(i)); - g_Notify->BreakPoint(__FILEW__,__LINE__); + CPU_Message("Value of const is different Reg %d (%s) Value: 0x%08X to 0x%08X", i, CRegName::GPR[i], GetMipsRegLo(i), SyncTo.GetMipsRegLo(i)); + g_Notify->BreakPoint(__FILEW__, __LINE__); } continue; default: - CPU_Message("Unhandled Reg state %d\nin SyncRegState",GetMipsRegState(i)); - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + CPU_Message("Unhandled Reg state %d\nin SyncRegState", GetMipsRegState(i)); + g_Notify->BreakPoint(__FILEW__, __LINE__); + } } changed = true; - switch (SyncTo.GetMipsRegState(i)) { - case CRegInfo::STATE_UNKNOWN: UnMap_GPR(i,true); break; + switch (SyncTo.GetMipsRegState(i)) + { + case CRegInfo::STATE_UNKNOWN: UnMap_GPR(i, true); break; case CRegInfo::STATE_MAPPED_64: + { + x86Reg Reg = SyncTo.GetMipsRegMapLo(i); + x86Reg x86RegHi = SyncTo.GetMipsRegMapHi(i); + UnMap_X86reg(Reg); + UnMap_X86reg(x86RegHi); + switch (GetMipsRegState(i)) { - x86Reg Reg = SyncTo.GetMipsRegMapLo(i); - x86Reg x86RegHi = SyncTo.GetMipsRegMapHi(i); - UnMap_X86reg(Reg); - UnMap_X86reg(x86RegHi); - switch (GetMipsRegState(i)) { - case CRegInfo::STATE_UNKNOWN: - MoveVariableToX86reg(&_GPR[i].UW[0],CRegName::GPR_Lo[i],Reg); - MoveVariableToX86reg(&_GPR[i].UW[1],CRegName::GPR_Hi[i],x86RegHi); - break; - case CRegInfo::STATE_MAPPED_64: - MoveX86RegToX86Reg(GetMipsRegMapLo(i),Reg); - m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i),CRegInfo::NotMapped); - MoveX86RegToX86Reg(GetMipsRegMapHi(i),x86RegHi); - m_RegWorkingSet.SetX86Mapped(GetMipsRegMapHi(i),CRegInfo::NotMapped); - break; - case CRegInfo::STATE_MAPPED_32_SIGN: - MoveX86RegToX86Reg(GetMipsRegMapLo(i),x86RegHi); - ShiftRightSignImmed(x86RegHi,31); - MoveX86RegToX86Reg(GetMipsRegMapLo(i),Reg); - m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i),CRegInfo::NotMapped); - break; - case CRegInfo::STATE_MAPPED_32_ZERO: - XorX86RegToX86Reg(x86RegHi,x86RegHi); - MoveX86RegToX86Reg(GetMipsRegMapLo(i),Reg); - m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped); - break; - case CRegInfo::STATE_CONST_64: - MoveConstToX86reg(GetMipsRegHi(i),x86RegHi); - MoveConstToX86reg(GetMipsRegLo(i),Reg); - break; - case CRegInfo::STATE_CONST_32_SIGN: - MoveConstToX86reg(GetMipsRegLo_S(i) >> 31,x86RegHi); - MoveConstToX86reg(GetMipsRegLo(i),Reg); - break; - default: - CPU_Message("Do something with states in SyncRegState\nSTATE_MAPPED_64\n%d",GetMipsRegState(i)); - g_Notify->BreakPoint(__FILEW__,__LINE__); - continue; - } - m_RegWorkingSet.SetMipsRegMapLo(i,Reg); - m_RegWorkingSet.SetMipsRegMapHi(i,x86RegHi); - m_RegWorkingSet.SetMipsRegState(i,CRegInfo::STATE_MAPPED_64); - m_RegWorkingSet.SetX86Mapped(Reg,CRegInfo::GPR_Mapped); - m_RegWorkingSet.SetX86Mapped(x86RegHi,CRegInfo::GPR_Mapped); - m_RegWorkingSet.SetX86MapOrder(Reg,1); - m_RegWorkingSet.SetX86MapOrder(x86RegHi,1); + case CRegInfo::STATE_UNKNOWN: + MoveVariableToX86reg(&_GPR[i].UW[0], CRegName::GPR_Lo[i], Reg); + MoveVariableToX86reg(&_GPR[i].UW[1], CRegName::GPR_Hi[i], x86RegHi); + break; + case CRegInfo::STATE_MAPPED_64: + MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); + m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped); + MoveX86RegToX86Reg(GetMipsRegMapHi(i), x86RegHi); + m_RegWorkingSet.SetX86Mapped(GetMipsRegMapHi(i), CRegInfo::NotMapped); + break; + case CRegInfo::STATE_MAPPED_32_SIGN: + MoveX86RegToX86Reg(GetMipsRegMapLo(i), x86RegHi); + ShiftRightSignImmed(x86RegHi, 31); + MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); + m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped); + break; + case CRegInfo::STATE_MAPPED_32_ZERO: + XorX86RegToX86Reg(x86RegHi, x86RegHi); + MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); + m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped); + break; + case CRegInfo::STATE_CONST_64: + MoveConstToX86reg(GetMipsRegHi(i), x86RegHi); + MoveConstToX86reg(GetMipsRegLo(i), Reg); + break; + case CRegInfo::STATE_CONST_32_SIGN: + MoveConstToX86reg(GetMipsRegLo_S(i) >> 31, x86RegHi); + MoveConstToX86reg(GetMipsRegLo(i), Reg); + break; + default: + CPU_Message("Do something with states in SyncRegState\nSTATE_MAPPED_64\n%d", GetMipsRegState(i)); + g_Notify->BreakPoint(__FILEW__, __LINE__); + continue; } - break; + m_RegWorkingSet.SetMipsRegMapLo(i, Reg); + m_RegWorkingSet.SetMipsRegMapHi(i, x86RegHi); + m_RegWorkingSet.SetMipsRegState(i, CRegInfo::STATE_MAPPED_64); + m_RegWorkingSet.SetX86Mapped(Reg, CRegInfo::GPR_Mapped); + m_RegWorkingSet.SetX86Mapped(x86RegHi, CRegInfo::GPR_Mapped); + m_RegWorkingSet.SetX86MapOrder(Reg, 1); + m_RegWorkingSet.SetX86MapOrder(x86RegHi, 1); + } + break; case CRegInfo::STATE_MAPPED_32_SIGN: + { + x86Reg Reg = SyncTo.GetMipsRegMapLo(i); + UnMap_X86reg(Reg); + switch (GetMipsRegState(i)) { - x86Reg Reg = SyncTo.GetMipsRegMapLo(i); - UnMap_X86reg(Reg); - switch (GetMipsRegState(i)) { - case CRegInfo::STATE_UNKNOWN: MoveVariableToX86reg(&_GPR[i].UW[0],CRegName::GPR_Lo[i],Reg); break; - case CRegInfo::STATE_CONST_32_SIGN: MoveConstToX86reg(GetMipsRegLo(i),Reg); break; - case CRegInfo::STATE_MAPPED_32_SIGN: - MoveX86RegToX86Reg(GetMipsRegMapLo(i),Reg); - m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i),CRegInfo::NotMapped); - break; - case CRegInfo::STATE_MAPPED_32_ZERO: - if (GetMipsRegMapLo(i) != Reg) { - MoveX86RegToX86Reg(GetMipsRegMapLo(i),Reg); - m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i),CRegInfo::NotMapped); - } - break; - case CRegInfo::STATE_MAPPED_64: - MoveX86RegToX86Reg(GetMipsRegMapLo(i),Reg); - m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i),CRegInfo::NotMapped) ; - m_RegWorkingSet.SetX86Mapped(GetMipsRegMapHi(i),CRegInfo::NotMapped); - break; - case CRegInfo::STATE_CONST_64: - CPU_Message("hi %X\nLo %X",GetMipsRegHi(i),GetMipsRegLo(i)); - default: - CPU_Message("Do something with states in SyncRegState\nSTATE_MAPPED_32_SIGN\n%d",GetMipsRegState(i)); - g_Notify->BreakPoint(__FILEW__,__LINE__); + case CRegInfo::STATE_UNKNOWN: MoveVariableToX86reg(&_GPR[i].UW[0], CRegName::GPR_Lo[i], Reg); break; + case CRegInfo::STATE_CONST_32_SIGN: MoveConstToX86reg(GetMipsRegLo(i), Reg); break; + case CRegInfo::STATE_MAPPED_32_SIGN: + MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); + m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped); + break; + case CRegInfo::STATE_MAPPED_32_ZERO: + if (GetMipsRegMapLo(i) != Reg) + { + MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); + m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped); } - m_RegWorkingSet.SetMipsRegMapLo(i,Reg); - m_RegWorkingSet.SetMipsRegState(i, CRegInfo::STATE_MAPPED_32_SIGN); - m_RegWorkingSet.SetX86Mapped(Reg,CRegInfo::GPR_Mapped); - m_RegWorkingSet.SetX86MapOrder(Reg,1); + break; + case CRegInfo::STATE_MAPPED_64: + MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); + m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped); + m_RegWorkingSet.SetX86Mapped(GetMipsRegMapHi(i), CRegInfo::NotMapped); + break; + case CRegInfo::STATE_CONST_64: + CPU_Message("hi %X\nLo %X", GetMipsRegHi(i), GetMipsRegLo(i)); + default: + CPU_Message("Do something with states in SyncRegState\nSTATE_MAPPED_32_SIGN\n%d", GetMipsRegState(i)); + g_Notify->BreakPoint(__FILEW__, __LINE__); } - break; + m_RegWorkingSet.SetMipsRegMapLo(i, Reg); + m_RegWorkingSet.SetMipsRegState(i, CRegInfo::STATE_MAPPED_32_SIGN); + m_RegWorkingSet.SetX86Mapped(Reg, CRegInfo::GPR_Mapped); + m_RegWorkingSet.SetX86MapOrder(Reg, 1); + } + break; case CRegInfo::STATE_MAPPED_32_ZERO: + { + x86Reg Reg = SyncTo.GetMipsRegMapLo(i); + UnMap_X86reg(Reg); + switch (GetMipsRegState(i)) { - x86Reg Reg = SyncTo.GetMipsRegMapLo(i); - UnMap_X86reg(Reg); - switch (GetMipsRegState(i)) { - case CRegInfo::STATE_MAPPED_64: - case CRegInfo::STATE_UNKNOWN: - MoveVariableToX86reg(&_GPR[i].UW[0],CRegName::GPR_Lo[i],Reg); - break; - case CRegInfo::STATE_MAPPED_32_ZERO: - MoveX86RegToX86Reg(GetMipsRegMapLo(i),Reg); - m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i),CRegInfo::NotMapped); - break; - case CRegInfo::STATE_MAPPED_32_SIGN: - if (g_System->b32BitCore()) - { - MoveX86RegToX86Reg(GetMipsRegMapLo(i),Reg); - m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i),CRegInfo::NotMapped); - } else { - CPU_Message("Do something with states in SyncRegState\nSTATE_MAPPED_32_ZERO\n%d",GetMipsRegState(i)); - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - break; - case CRegInfo::STATE_CONST_32_SIGN: - if (!g_System->b32BitCore() && GetMipsRegLo_S(i) < 0) - { - CPU_Message("Sign Problems in SyncRegState\nSTATE_MAPPED_32_ZERO"); - CPU_Message("%s: %X",CRegName::GPR[i],GetMipsRegLo_S(i)); - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - MoveConstToX86reg(GetMipsRegLo(i),Reg); - break; - default: - CPU_Message("Do something with states in SyncRegState\nSTATE_MAPPED_32_ZERO\n%d",GetMipsRegState(i)); - g_Notify->BreakPoint(__FILEW__,__LINE__); + case CRegInfo::STATE_MAPPED_64: + case CRegInfo::STATE_UNKNOWN: + MoveVariableToX86reg(&_GPR[i].UW[0], CRegName::GPR_Lo[i], Reg); + break; + case CRegInfo::STATE_MAPPED_32_ZERO: + MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); + m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped); + break; + case CRegInfo::STATE_MAPPED_32_SIGN: + if (g_System->b32BitCore()) + { + MoveX86RegToX86Reg(GetMipsRegMapLo(i), Reg); + m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i), CRegInfo::NotMapped); } - m_RegWorkingSet.SetMipsRegMapLo(i,Reg); - m_RegWorkingSet.SetMipsRegState(i, SyncTo.GetMipsRegState(i)); - m_RegWorkingSet.SetX86Mapped(Reg,CRegInfo::GPR_Mapped); - m_RegWorkingSet.SetX86MapOrder(Reg,1); + else + { + CPU_Message("Do something with states in SyncRegState\nSTATE_MAPPED_32_ZERO\n%d", GetMipsRegState(i)); + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + break; + case CRegInfo::STATE_CONST_32_SIGN: + if (!g_System->b32BitCore() && GetMipsRegLo_S(i) < 0) + { + CPU_Message("Sign Problems in SyncRegState\nSTATE_MAPPED_32_ZERO"); + CPU_Message("%s: %X", CRegName::GPR[i], GetMipsRegLo_S(i)); + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + MoveConstToX86reg(GetMipsRegLo(i), Reg); + break; + default: + CPU_Message("Do something with states in SyncRegState\nSTATE_MAPPED_32_ZERO\n%d", GetMipsRegState(i)); + g_Notify->BreakPoint(__FILEW__, __LINE__); } - break; + m_RegWorkingSet.SetMipsRegMapLo(i, Reg); + m_RegWorkingSet.SetMipsRegState(i, SyncTo.GetMipsRegState(i)); + m_RegWorkingSet.SetX86Mapped(Reg, CRegInfo::GPR_Mapped); + m_RegWorkingSet.SetX86MapOrder(Reg, 1); + } + break; default: - CPU_Message("%d - %d reg: %s (%d)",SyncTo.GetMipsRegState(i),GetMipsRegState(i),CRegName::GPR[i],i); - g_Notify->BreakPoint(__FILEW__,__LINE__); + CPU_Message("%d - %d reg: %s (%d)", SyncTo.GetMipsRegState(i), GetMipsRegState(i), CRegName::GPR[i], i); + g_Notify->BreakPoint(__FILEW__, __LINE__); changed = false; } } @@ -844,19 +933,19 @@ void CCodeSection::SetDelaySlot() m_DelaySlot = true; } -void CCodeSection::SetJumpAddress (DWORD JumpPC, DWORD TargetPC, bool PermLoop) +void CCodeSection::SetJumpAddress(uint32_t JumpPC, uint32_t TargetPC, bool PermLoop) { m_Jump.JumpPC = JumpPC; m_Jump.TargetPC = TargetPC; - m_Jump.BranchLabel.Format("0x%08X",TargetPC); + m_Jump.BranchLabel.Format("0x%08X", TargetPC); m_Jump.PermLoop = PermLoop; } -void CCodeSection::SetContinueAddress (DWORD JumpPC, DWORD TargetPC) +void CCodeSection::SetContinueAddress(uint32_t JumpPC, uint32_t TargetPC) { m_Cont.JumpPC = JumpPC; m_Cont.TargetPC = TargetPC; - m_Cont.BranchLabel.Format("0x%08X",TargetPC); + m_Cont.BranchLabel.Format("0x%08X", TargetPC); } void CCodeSection::CompileCop1Test() @@ -864,8 +953,8 @@ void CCodeSection::CompileCop1Test() if (m_RegWorkingSet.FpuBeenUsed()) return; - TestVariable(STATUS_CU1,&g_Reg->STATUS_REGISTER,"STATUS_REGISTER"); - CompileExit(m_CompilePC,m_CompilePC,m_RegWorkingSet,CExitInfo::COP1_Unuseable,false,JeLabel32); + TestVariable(STATUS_CU1, &g_Reg->STATUS_REGISTER, "STATUS_REGISTER"); + CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, CExitInfo::COP1_Unuseable, false, JeLabel32); m_RegWorkingSet.FpuBeenUsed() = true; } @@ -877,7 +966,7 @@ bool CCodeSection::ParentContinue() { CCodeSection * Parent = *iter; if (Parent->m_CompiledLocation != NULL) { continue; } - if (IsAllParentLoops(Parent,true,m_BlockInfo->NextTest())) { continue; } + if (IsAllParentLoops(Parent, true, m_BlockInfo->NextTest())) { continue; } return false; } if (!InheritParentInfo()) @@ -891,55 +980,58 @@ bool CCodeSection::ParentContinue() /*int TestValue = 0; void TestFunc() { - TestValue += 1; - if (TestValue >= 4) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } +TestValue += 1; +if (TestValue >= 4) +{ +g_Notify->BreakPoint(__FILEW__,__LINE__); +} }*/ -bool CCodeSection::GenerateX86Code ( DWORD Test ) +bool CCodeSection::GenerateX86Code(uint32_t Test) { if (this == NULL) { return false; } - if (m_CompiledLocation != NULL) { - if (m_Test == Test) + if (m_CompiledLocation != NULL) + { + if (m_Test == Test) { - return false; + return false; } m_Test = Test; if (m_ContinueSection->GenerateX86Code(Test)) { return true; } if (m_JumpSection->GenerateX86Code(Test)) { return true; } - return false; + return false; } - if (!ParentContinue()) - { - return false; + if (!ParentContinue()) + { + return false; } m_CompiledLocation = m_RecompPos; - m_RegWorkingSet = m_RegEnter; - m_CompilePC = m_EnterPC; - m_NextInstruction = m_DelaySlot ? JUMP : NORMAL; - m_Section = this; + m_RegWorkingSet = m_RegEnter; + m_CompilePC = m_EnterPC; + m_NextInstruction = m_DelaySlot ? JUMP : NORMAL; + m_Section = this; if (m_CompilePC < m_BlockInfo->VAddrFirst()) { m_BlockInfo->SetVAddrFirst(m_CompilePC); } - DWORD ContinueSectionPC = m_ContinueSection ? m_ContinueSection->m_EnterPC : (DWORD)-1; + uint32_t ContinueSectionPC = m_ContinueSection ? m_ContinueSection->m_EnterPC : (uint32_t)-1; - do { - __try { - if (!g_MMU->LW_VAddr(m_CompilePC,m_Opcode.Hex)) + do + { + __try + { + if (!g_MMU->LW_VAddr(m_CompilePC, m_Opcode.Hex)) { - g_Notify->DisplayError(GS(MSG_FAIL_LOAD_WORD)); - ExitThread(0); + g_Notify->FatalError(GS(MSG_FAIL_LOAD_WORD)); } - } __except( g_MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) { - g_Notify->DisplayError(GS(MSG_UNKNOWN_MEM_ACTION)); - ExitThread(0); + } + __except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation())) + { + g_Notify->FatalError(GS(MSG_UNKNOWN_MEM_ACTION)); } if (m_CompilePC > m_BlockInfo->VAddrLast()) @@ -948,112 +1040,114 @@ bool CCodeSection::GenerateX86Code ( DWORD Test ) } /*if (m_CompilePC == 0x803245C4) { - X86BreakPoint(__FILEW__,__LINE__); - //m_RegWorkingSet.UnMap_AllFPRs(); - }*/ - - /*if (m_CompilePC >= 0x80000000 && m_CompilePC <= 0x80400000 && m_NextInstruction == NORMAL) - { - m_RegWorkingSet.WriteBackRegisters(); - UpdateCounters(m_RegWorkingSet,false,true); - MoveConstToVariable(m_CompilePC,&g_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER"); - if (g_SyncSystem) { - MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); - } + X86BreakPoint(__FILEW__,__LINE__); + //m_RegWorkingSet.UnMap_AllFPRs(); }*/ - /*if ((m_CompilePC == 0x8031C0E4 || m_CompilePC == 0x8031C118 || - m_CompilePC == 0x8031CD88 || m_CompilePC == 0x8031CE24 || - m_CompilePC == 0x8031CE30 || m_CompilePC == 0x8031CE40) && m_NextInstruction == NORMAL) + /*if (m_CompilePC >= 0x80000000 && m_CompilePC <= 0x80400000 && m_NextInstruction == NORMAL) { - m_RegWorkingSet.WriteBackRegisters(); - UpdateCounters(m_RegWorkingSet,false,true); - MoveConstToVariable(m_CompilePC,&g_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER"); - if (g_SyncSystem) { - MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); - } + m_RegWorkingSet.WriteBackRegisters(); + UpdateCounters(m_RegWorkingSet,false,true); + MoveConstToVariable(m_CompilePC,&g_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER"); + if (g_SyncSystem) { + MoveConstToX86reg((uint32_t)g_BaseSystem,x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); + } + }*/ + + /*if ((m_CompilePC == 0x8031C0E4 || m_CompilePC == 0x8031C118 || + m_CompilePC == 0x8031CD88 || m_CompilePC == 0x8031CE24 || + m_CompilePC == 0x8031CE30 || m_CompilePC == 0x8031CE40) && m_NextInstruction == NORMAL) + { + m_RegWorkingSet.WriteBackRegisters(); + UpdateCounters(m_RegWorkingSet,false,true); + MoveConstToVariable(m_CompilePC,&g_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER"); + if (g_SyncSystem) { + MoveConstToX86reg((uint32_t)g_BaseSystem,x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); + } }*/ /*if (m_CompilePC == 0x801C1B88) { - BeforeCallDirect(m_RegWorkingSet); - Call_Direct(AddressOf(TestFunc), "TestFunc"); - AfterCallDirect(m_RegWorkingSet); + BeforeCallDirect(m_RegWorkingSet); + Call_Direct(AddressOf(TestFunc), "TestFunc"); + AfterCallDirect(m_RegWorkingSet); }*/ /*if (m_CompilePC >= 0x801C1AF8 && m_CompilePC <= 0x801C1C00 && m_NextInstruction == NORMAL) { - UpdateCounters(m_RegWorkingSet,false,true); - MoveConstToVariable(m_CompilePC,&g_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER"); - if (g_SyncSystem) { - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystemPC), "CN64System::SyncSystemPC"); - AfterCallDirect(m_RegWorkingSet); - } + UpdateCounters(m_RegWorkingSet,false,true); + MoveConstToVariable(m_CompilePC,&g_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER"); + if (g_SyncSystem) { + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_BaseSystem,x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystemPC), "CN64System::SyncSystemPC"); + AfterCallDirect(m_RegWorkingSet); + } }*/ /*if ((m_CompilePC == 0x80263900) && m_NextInstruction == NORMAL) { - X86BreakPoint(__FILEW__,__LINE__); + X86BreakPoint(__FILEW__,__LINE__); }*/ - + /*if ((m_CompilePC >= 0x80325D80 && m_CompilePC <= 0x80325DF0) && m_NextInstruction == NORMAL) { - m_RegWorkingSet.WriteBackRegisters(); - UpdateCounters(m_RegWorkingSet,false,true); - MoveConstToVariable(m_CompilePC,&g_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER"); - if (g_SyncSystem) { - MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); - } + m_RegWorkingSet.WriteBackRegisters(); + UpdateCounters(m_RegWorkingSet,false,true); + MoveConstToVariable(m_CompilePC,&g_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER"); + if (g_SyncSystem) { + MoveConstToX86reg((uint32_t)g_BaseSystem,x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); + } }*/ /*if ((m_CompilePC == 0x80324E14) && m_NextInstruction == NORMAL) { - X86BreakPoint(__FILEW__,__LINE__); + X86BreakPoint(__FILEW__,__LINE__); }*/ - + /*if (m_CompilePC == 0x80324E18 && m_NextInstruction == NORMAL) { - m_RegWorkingSet.WriteBackRegisters(); - UpdateCounters(m_RegWorkingSet,false,true); - MoveConstToVariable(m_CompilePC,&g_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER"); - if (g_SyncSystem) { - MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); - } + m_RegWorkingSet.WriteBackRegisters(); + UpdateCounters(m_RegWorkingSet,false,true); + MoveConstToVariable(m_CompilePC,&g_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER"); + if (g_SyncSystem) { + MoveConstToX86reg((uint32_t)g_BaseSystem,x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); + } }*/ /*if (m_CompilePC >= 0x80324E00 && m_CompilePC <= 0x80324E18 && m_NextInstruction == NORMAL) { - m_RegWorkingSet.WriteBackRegisters(); - UpdateCounters(m_RegWorkingSet,false,true); - MoveConstToVariable(m_CompilePC,&g_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER"); - if (g_SyncSystem) { - MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); - } + m_RegWorkingSet.WriteBackRegisters(); + UpdateCounters(m_RegWorkingSet,false,true); + MoveConstToVariable(m_CompilePC,&g_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER"); + if (g_SyncSystem) { + MoveConstToX86reg((uint32_t)g_BaseSystem,x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); + } }*/ -/* if (m_CompilePC == 0x803245CC && m_NextInstruction == NORMAL) + /* if (m_CompilePC == 0x803245CC && m_NextInstruction == NORMAL) { - //m_RegWorkingSet.UnMap_AllFPRs(); - g_Notify->BreakPoint(__FILEW__,__LINE__); - //X86HardBreakPoint(); - //X86BreakPoint(__FILEW__,__LINE__); - //m_RegWorkingSet.UnMap_AllFPRs(); + //m_RegWorkingSet.UnMap_AllFPRs(); + g_Notify->BreakPoint(__FILEW__,__LINE__); + //X86HardBreakPoint(); + //X86BreakPoint(__FILEW__,__LINE__); + //m_RegWorkingSet.UnMap_AllFPRs(); }*/ /*if (m_CompilePC >= 0x80179DC4 && m_CompilePC <= 0x80179DF0 && m_NextInstruction == NORMAL) { - m_RegWorkingSet.UnMap_AllFPRs(); + m_RegWorkingSet.UnMap_AllFPRs(); }*/ m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); m_RegWorkingSet.ResetX86Protection(); - switch (m_Opcode.op) { + switch (m_Opcode.op) + { case R4300i_SPECIAL: - switch (m_Opcode.funct) { + switch (m_Opcode.funct) + { case R4300i_SPECIAL_SLL: SPECIAL_SLL(); break; case R4300i_SPECIAL_SRL: SPECIAL_SRL(); break; case R4300i_SPECIAL_SRA: SPECIAL_SRA(); break; @@ -1102,22 +1196,23 @@ bool CCodeSection::GenerateX86Code ( DWORD Test ) UnknownOpcode(); break; } break; - case R4300i_REGIMM: - switch (m_Opcode.rt) { - case R4300i_REGIMM_BLTZ:Compile_Branch(BLTZ_Compare,BranchTypeRs, false); break; - case R4300i_REGIMM_BGEZ:Compile_Branch(BGEZ_Compare,BranchTypeRs, false); break; + case R4300i_REGIMM: + switch (m_Opcode.rt) + { + case R4300i_REGIMM_BLTZ:Compile_Branch(BLTZ_Compare, BranchTypeRs, false); break; + case R4300i_REGIMM_BGEZ:Compile_Branch(BGEZ_Compare, BranchTypeRs, false); break; case R4300i_REGIMM_BLTZL:Compile_BranchLikely(BLTZ_Compare, false); break; case R4300i_REGIMM_BGEZL:Compile_BranchLikely(BGEZ_Compare, false); break; - case R4300i_REGIMM_BLTZAL:Compile_Branch(BLTZ_Compare,BranchTypeRs, true); break; - case R4300i_REGIMM_BGEZAL:Compile_Branch(BGEZ_Compare,BranchTypeRs, true); break; + case R4300i_REGIMM_BLTZAL:Compile_Branch(BLTZ_Compare, BranchTypeRs, true); break; + case R4300i_REGIMM_BGEZAL:Compile_Branch(BGEZ_Compare, BranchTypeRs, true); break; default: UnknownOpcode(); break; } break; - case R4300i_BEQ: Compile_Branch(BEQ_Compare,BranchTypeRsRt,false); break; - case R4300i_BNE: Compile_Branch(BNE_Compare,BranchTypeRsRt,false); break; - case R4300i_BGTZ:Compile_Branch(BGTZ_Compare,BranchTypeRs,false); break; - case R4300i_BLEZ:Compile_Branch(BLEZ_Compare,BranchTypeRs,false); break; + case R4300i_BEQ: Compile_Branch(BEQ_Compare, BranchTypeRsRt, false); break; + case R4300i_BNE: Compile_Branch(BNE_Compare, BranchTypeRsRt, false); break; + case R4300i_BGTZ:Compile_Branch(BGTZ_Compare, BranchTypeRs, false); break; + case R4300i_BLEZ:Compile_Branch(BLEZ_Compare, BranchTypeRs, false); break; case R4300i_J: J(); break; case R4300i_JAL: JAL(); break; case R4300i_ADDI: ADDI(); break; @@ -1129,12 +1224,15 @@ bool CCodeSection::GenerateX86Code ( DWORD Test ) case R4300i_XORI: XORI(); break; case R4300i_LUI: LUI(); break; case R4300i_CP0: - switch (m_Opcode.rs) { + switch (m_Opcode.rs) + { case R4300i_COP0_MF: COP0_MF(); break; case R4300i_COP0_MT: COP0_MT(); break; default: - if ( (m_Opcode.rs & 0x10 ) != 0 ) { - switch( m_Opcode.funct ) { + if ((m_Opcode.rs & 0x10) != 0) + { + switch (m_Opcode.funct) + { case R4300i_COP0_CO_TLBR: COP0_CO_TLBR(); break; case R4300i_COP0_CO_TLBWI: COP0_CO_TLBWI(); break; case R4300i_COP0_CO_TLBWR: COP0_CO_TLBWR(); break; @@ -1142,13 +1240,16 @@ bool CCodeSection::GenerateX86Code ( DWORD Test ) case R4300i_COP0_CO_ERET: COP0_CO_ERET(); break; default: UnknownOpcode(); break; } - } else { + } + else + { UnknownOpcode(); } } break; case R4300i_CP1: - switch (m_Opcode.rs) { + switch (m_Opcode.rs) + { case R4300i_COP1_MF: COP1_MF(); break; case R4300i_COP1_DMF: COP1_DMF(); break; case R4300i_COP1_CF: COP1_CF(); break; @@ -1156,17 +1257,19 @@ bool CCodeSection::GenerateX86Code ( DWORD Test ) case R4300i_COP1_DMT: COP1_DMT(); break; case R4300i_COP1_CT: COP1_CT(); break; case R4300i_COP1_BC: - switch (m_Opcode.ft) { - case R4300i_COP1_BC_BCF: Compile_Branch(COP1_BCF_Compare,BranchTypeCop1,false); break; - case R4300i_COP1_BC_BCT: Compile_Branch(COP1_BCT_Compare,BranchTypeCop1,false); break; - case R4300i_COP1_BC_BCFL: Compile_BranchLikely(COP1_BCF_Compare,false); break; - case R4300i_COP1_BC_BCTL: Compile_BranchLikely(COP1_BCT_Compare,false); break; + switch (m_Opcode.ft) + { + case R4300i_COP1_BC_BCF: Compile_Branch(COP1_BCF_Compare, BranchTypeCop1, false); break; + case R4300i_COP1_BC_BCT: Compile_Branch(COP1_BCT_Compare, BranchTypeCop1, false); break; + case R4300i_COP1_BC_BCFL: Compile_BranchLikely(COP1_BCF_Compare, false); break; + case R4300i_COP1_BC_BCTL: Compile_BranchLikely(COP1_BCT_Compare, false); break; default: UnknownOpcode(); break; } break; - case R4300i_COP1_S: - switch (m_Opcode.funct) { + case R4300i_COP1_S: + switch (m_Opcode.funct) + { case R4300i_COP1_FUNCT_ADD: COP1_S_ADD(); break; case R4300i_COP1_FUNCT_SUB: COP1_S_SUB(); break; case R4300i_COP1_FUNCT_MUL: COP1_S_MUL(); break; @@ -1198,8 +1301,9 @@ bool CCodeSection::GenerateX86Code ( DWORD Test ) UnknownOpcode(); break; } break; - case R4300i_COP1_D: - switch (m_Opcode.funct) { + case R4300i_COP1_D: + switch (m_Opcode.funct) + { case R4300i_COP1_FUNCT_ADD: COP1_D_ADD(); break; case R4300i_COP1_FUNCT_SUB: COP1_D_SUB(); break; case R4300i_COP1_FUNCT_MUL: COP1_D_MUL(); break; @@ -1231,16 +1335,18 @@ bool CCodeSection::GenerateX86Code ( DWORD Test ) UnknownOpcode(); break; } break; - case R4300i_COP1_W: - switch (m_Opcode.funct) { + case R4300i_COP1_W: + switch (m_Opcode.funct) + { case R4300i_COP1_FUNCT_CVT_S: COP1_W_CVT_S(); break; case R4300i_COP1_FUNCT_CVT_D: COP1_W_CVT_D(); break; default: UnknownOpcode(); break; } break; - case R4300i_COP1_L: - switch (m_Opcode.funct) { + case R4300i_COP1_L: + switch (m_Opcode.funct) + { case R4300i_COP1_FUNCT_CVT_S: COP1_L_CVT_S(); break; case R4300i_COP1_FUNCT_CVT_D: COP1_L_CVT_D(); break; default: @@ -1251,10 +1357,10 @@ bool CCodeSection::GenerateX86Code ( DWORD Test ) UnknownOpcode(); break; } break; - case R4300i_BEQL: Compile_BranchLikely(BEQ_Compare,false); break; - case R4300i_BNEL: Compile_BranchLikely(BNE_Compare,false); break; - case R4300i_BGTZL:Compile_BranchLikely(BGTZ_Compare,false); break; - case R4300i_BLEZL:Compile_BranchLikely(BLEZ_Compare,false); break; + case R4300i_BEQL: Compile_BranchLikely(BEQ_Compare, false); break; + case R4300i_BNEL: Compile_BranchLikely(BNE_Compare, false); break; + case R4300i_BGTZL:Compile_BranchLikely(BGTZ_Compare, false); break; + case R4300i_BLEZL:Compile_BranchLikely(BLEZ_Compare, false); break; case R4300i_DADDIU: DADDIU(); break; case R4300i_LDL: g_MMU->Compile_LDL(); break; case R4300i_LDR: g_MMU->Compile_LDR(); break; @@ -1285,61 +1391,66 @@ bool CCodeSection::GenerateX86Code ( DWORD Test ) default: UnknownOpcode(); break; } - + if (!g_System->bRegCaching()) { m_RegWorkingSet.WriteBackRegisters(); } m_RegWorkingSet.UnMap_AllFPRs(); - if ((m_CompilePC &0xFFC) == 0xFFC) + if ((m_CompilePC & 0xFFC) == 0xFFC) { - if (m_NextInstruction == DO_DELAY_SLOT) + if (m_NextInstruction == DO_DELAY_SLOT) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } - if (m_NextInstruction == NORMAL) + if (m_NextInstruction == NORMAL) { if (m_DelaySlot) { - CompileExit (m_CompilePC, m_Jump.TargetPC,m_RegWorkingSet,CExitInfo::Normal,true,NULL); - } else { - CompileExit (m_CompilePC, m_CompilePC + 4,m_RegWorkingSet,CExitInfo::Normal,true,NULL); + CompileExit(m_CompilePC, m_Jump.TargetPC, m_RegWorkingSet, CExitInfo::Normal, true, NULL); + } + else + { + CompileExit(m_CompilePC, m_CompilePC + 4, m_RegWorkingSet, CExitInfo::Normal, true, NULL); } m_NextInstruction = END_BLOCK; } } - switch (m_NextInstruction) { - case NORMAL: - m_CompilePC += 4; + switch (m_NextInstruction) + { + case NORMAL: + m_CompilePC += 4; break; case DO_DELAY_SLOT: m_NextInstruction = DELAY_SLOT; - m_CompilePC += 4; + m_CompilePC += 4; break; case DELAY_SLOT: m_NextInstruction = DELAY_SLOT_DONE; m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); - m_CompilePC -= 4; + m_CompilePC -= 4; break; } if (m_DelaySlot) { - if ((CompilePC() & 0xFFC) != 0xFFC && m_Jump.JumpPC != (DWORD)-1) + if ((CompilePC() & 0xFFC) != 0xFFC && m_Jump.JumpPC != (uint32_t)-1) { m_CompilePC = m_Jump.JumpPC; m_Jump.RegSet = m_RegWorkingSet; m_Jump.FallThrough = true; GenerateSectionLinkage(); - } else { - CompileExit (m_Jump.JumpPC, m_Jump.TargetPC,m_RegWorkingSet,CExitInfo::Normal,true,NULL); + } + else + { + CompileExit(m_Jump.JumpPC, m_Jump.TargetPC, m_RegWorkingSet, CExitInfo::Normal, true, NULL); } m_NextInstruction = END_BLOCK; } - else if (m_NextInstruction != END_BLOCK && m_CompilePC == ContinueSectionPC) + else if (m_NextInstruction != END_BLOCK && m_CompilePC == ContinueSectionPC) { - if (m_NextInstruction != NORMAL) + if (m_NextInstruction != NORMAL) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } m_CompilePC -= 4; m_Cont.RegSet = m_RegWorkingSet; @@ -1352,10 +1463,10 @@ bool CCodeSection::GenerateX86Code ( DWORD Test ) return true; } -void CCodeSection::AddParent(CCodeSection * Parent ) +void CCodeSection::AddParent(CCodeSection * Parent) { if (this == NULL) { return; } - if (Parent == NULL) + if (Parent == NULL) { m_RegWorkingSet = m_RegEnter; return; @@ -1373,26 +1484,34 @@ void CCodeSection::AddParent(CCodeSection * Parent ) if (m_ParentSection.size() == 1) { - if (Parent->m_ContinueSection == this) { + if (Parent->m_ContinueSection == this) + { m_RegEnter = Parent->m_Cont.RegSet; - } else if (Parent->m_JumpSection == this) { + } + else if (Parent->m_JumpSection == this) + { m_RegEnter = Parent->m_Jump.RegSet; - } else { + } + else + { g_Notify->DisplayError(L"How are these sections joined?????"); } m_RegWorkingSet = m_RegEnter; - } else { - if (Parent->m_ContinueSection == this) { - TestRegConstantStates(Parent->m_Cont.RegSet,m_RegEnter); + } + else { + if (Parent->m_ContinueSection == this) + { + TestRegConstantStates(Parent->m_Cont.RegSet, m_RegEnter); } - if (Parent->m_JumpSection == this) { - TestRegConstantStates(Parent->m_Jump.RegSet,m_RegEnter); + if (Parent->m_JumpSection == this) + { + TestRegConstantStates(Parent->m_Jump.RegSet, m_RegEnter); } m_RegWorkingSet = m_RegEnter; } } -void CCodeSection::SwitchParent(CCodeSection * OldParent, CCodeSection * NewParent ) +void CCodeSection::SwitchParent(CCodeSection * OldParent, CCodeSection * NewParent) { if (this == NULL) { return; } @@ -1410,17 +1529,18 @@ void CCodeSection::SwitchParent(CCodeSection * OldParent, CCodeSection * NewPare if (!bFoundOldParent) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } m_ParentSection.push_back(NewParent); } -void CCodeSection::TestRegConstantStates( CRegInfo & Base, CRegInfo & Reg ) +void CCodeSection::TestRegConstantStates(CRegInfo & Base, CRegInfo & Reg) { - for (int i = 0; i < 32; i++) { + for (int i = 0; i < 32; i++) + { if (Reg.GetMipsRegState(i) != Base.GetMipsRegState(i)) { - Reg.SetMipsRegState(i,CRegInfo::STATE_UNKNOWN); + Reg.SetMipsRegState(i, CRegInfo::STATE_UNKNOWN); } if (Reg.IsConst(i)) { @@ -1430,112 +1550,119 @@ void CCodeSection::TestRegConstantStates( CRegInfo & Base, CRegInfo & Reg ) { Reg.SetMipsRegState(i, CRegInfo::STATE_UNKNOWN); } - } else { - if (Reg.GetMipsReg(i) != Base.GetMipsReg(i)) + } + else + { + if (Reg.GetMipsReg(i) != Base.GetMipsReg(i)) { Reg.SetMipsRegState(i, CRegInfo::STATE_UNKNOWN); } } - } } } -void CCodeSection::DetermineLoop(DWORD Test, DWORD Test2, DWORD TestID) +void CCodeSection::DetermineLoop(uint32_t Test, uint32_t Test2, uint32_t TestID) { if (this == NULL) { return; } - - if (m_SectionID == TestID) + + if (m_SectionID == TestID) { - if (m_Test2 != Test2) - { - m_Test2 = Test2; - m_ContinueSection->DetermineLoop(Test,Test2,TestID); - m_JumpSection->DetermineLoop(Test,Test2,TestID); - - if (m_Test != Test) - { - m_Test = Test; - if (m_ContinueSection != NULL) - { - m_ContinueSection->DetermineLoop(Test,m_BlockInfo->NextTest(),m_ContinueSection->m_SectionID); - } - if (m_JumpSection != NULL) - { - m_JumpSection->DetermineLoop(Test,m_BlockInfo->NextTest(),m_JumpSection->m_SectionID); - } - } - } else { - m_InLoop = true; - } - } else { - if (m_Test2 != Test2) + if (m_Test2 != Test2) { m_Test2 = Test2; - m_ContinueSection->DetermineLoop(Test,Test2,TestID); - m_JumpSection->DetermineLoop(Test,Test2,TestID); + m_ContinueSection->DetermineLoop(Test, Test2, TestID); + m_JumpSection->DetermineLoop(Test, Test2, TestID); + + if (m_Test != Test) + { + m_Test = Test; + if (m_ContinueSection != NULL) + { + m_ContinueSection->DetermineLoop(Test, m_BlockInfo->NextTest(), m_ContinueSection->m_SectionID); + } + if (m_JumpSection != NULL) + { + m_JumpSection->DetermineLoop(Test, m_BlockInfo->NextTest(), m_JumpSection->m_SectionID); + } + } + } + else + { + m_InLoop = true; + } + } + else + { + if (m_Test2 != Test2) + { + m_Test2 = Test2; + m_ContinueSection->DetermineLoop(Test, Test2, TestID); + m_JumpSection->DetermineLoop(Test, Test2, TestID); } } } -CCodeSection * CCodeSection::ExistingSection(DWORD Addr, DWORD Test) +CCodeSection * CCodeSection::ExistingSection(uint32_t Addr, uint32_t Test) { if (this == NULL) { return NULL; } - if (m_EnterPC == Addr && m_LinkAllowed) - { - return this; + if (m_EnterPC == Addr && m_LinkAllowed) + { + return this; } if (m_Test == Test) { return NULL; } m_Test = Test; - CCodeSection * Section = m_JumpSection->ExistingSection(Addr,Test); + CCodeSection * Section = m_JumpSection->ExistingSection(Addr, Test); if (Section != NULL) { return Section; } - Section = m_ContinueSection->ExistingSection(Addr,Test); + Section = m_ContinueSection->ExistingSection(Addr, Test); if (Section != NULL) { return Section; } return NULL; } -bool CCodeSection::SectionAccessible ( DWORD SectionId, DWORD Test ) +bool CCodeSection::SectionAccessible(uint32_t SectionId, uint32_t Test) { if (this == NULL) { return false; } if (m_SectionID == SectionId) { return true; } - + if (m_Test == Test) { return false; } m_Test = Test; - if (m_ContinueSection->SectionAccessible(SectionId,Test)) + if (m_ContinueSection->SectionAccessible(SectionId, Test)) { return true; } - return m_JumpSection->SectionAccessible(SectionId,Test); + return m_JumpSection->SectionAccessible(SectionId, Test); } -void CCodeSection::UnlinkParent( CCodeSection * Parent, bool ContinueSection ) +void CCodeSection::UnlinkParent(CCodeSection * Parent, bool ContinueSection) { - if (this == NULL) + if (this == NULL) { return; } - CPU_Message(__FUNCTION__ ": Section %d Parent: %d ContinueSection = %s",m_SectionID,Parent->m_SectionID,ContinueSection?"Yes" :"No"); + CPU_Message(__FUNCTION__ ": Section %d Parent: %d ContinueSection = %s", m_SectionID, Parent->m_SectionID, ContinueSection ? "Yes" : "No"); if (Parent->m_ContinueSection == this && Parent->m_JumpSection == this) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } - + SECTION_LIST::iterator iter = m_ParentSection.begin(); - while ( iter != m_ParentSection.end()) + while (iter != m_ParentSection.end()) { CCodeSection * ParentIter = *iter; if (ParentIter == Parent && (Parent->m_ContinueSection != this || Parent->m_JumpSection != this)) { m_ParentSection.erase(iter); iter = m_ParentSection.begin(); - } else { + } + else + { iter++; } } @@ -1555,59 +1682,61 @@ void CCodeSection::UnlinkParent( CCodeSection * Parent, bool ContinueSection ) { if (!m_BlockInfo->SectionAccessible(m_SectionID)) { - for (SECTION_LIST::iterator iter = m_ParentSection.begin(); iter != m_ParentSection.end(); iter++) + for (SECTION_LIST::iterator iter = m_ParentSection.begin(); iter != m_ParentSection.end(); iter++) { CCodeSection * ParentIter = *iter; if (ParentIter->m_ContinueSection == this) - { + { if (ParentIter->m_CompiledLocation) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } ParentIter->m_ContinueSection = NULL; } - + if (ParentIter->m_JumpSection == this) { if (ParentIter->m_CompiledLocation) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } ParentIter->m_JumpSection = NULL; } } bRemove = true; } - } else { + } + else + { bRemove = true; } if (bRemove) { if (m_JumpSection != NULL) { - m_JumpSection->UnlinkParent(this,false); + m_JumpSection->UnlinkParent(this, false); } if (m_ContinueSection != NULL) { - m_ContinueSection->UnlinkParent(this,true); + m_ContinueSection->UnlinkParent(this, true); } - } + } } -bool CCodeSection::IsAllParentLoops(CCodeSection * Parent, bool IgnoreIfCompiled, DWORD Test) -{ +bool CCodeSection::IsAllParentLoops(CCodeSection * Parent, bool IgnoreIfCompiled, uint32_t Test) +{ if (IgnoreIfCompiled && Parent->m_CompiledLocation != NULL) { return true; } if (!m_InLoop) { return false; } if (!Parent->m_InLoop) { return false; } if (Parent->m_ParentSection.empty()) { return false; } - if (this == Parent) { return true; } + if (this == Parent) { return true; } if (Parent->m_Test == Test) { return true; } Parent->m_Test = Test; for (SECTION_LIST::iterator iter = Parent->m_ParentSection.begin(); iter != Parent->m_ParentSection.end(); iter++) { CCodeSection * ParentSection = *iter; - if (!IsAllParentLoops(ParentSection,IgnoreIfCompiled,Test)) { return false; } + if (!IsAllParentLoops(ParentSection, IgnoreIfCompiled, Test)) { return false; } } return true; } @@ -1623,44 +1752,48 @@ bool CCodeSection::SetupRegisterForLoop() { if (OriginalReg.GetMipsRegState(i) != m_RegEnter.GetMipsRegState(i)) { - UnMap_GPR(i,true); + UnMap_GPR(i, true); } } return true; } bool CCodeSection::InheritParentInfo() -{ +{ if (m_CompiledLocation == NULL) { m_CompiledLocation = m_RecompPos; DisplaySectionInformation(); m_CompiledLocation = NULL; - } else { + } + else + { DisplaySectionInformation(); } - if (m_ParentSection.empty()) + if (m_ParentSection.empty()) { - m_RegWorkingSet = m_RegEnter; + m_RegWorkingSet = m_RegEnter; return true; - } - - if (m_ParentSection.size() == 1) - { + } + + if (m_ParentSection.size() == 1) + { CCodeSection * Parent = *(m_ParentSection.begin()); if (Parent->m_CompiledLocation == NULL) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } CJumpInfo * JumpInfo = this == Parent->m_ContinueSection ? &Parent->m_Cont : &Parent->m_Jump; m_RegEnter = JumpInfo->RegSet; - if (JumpInfo->LinkLocation != NULL) { - CPU_Message(" Section_%d:",m_SectionID); - SetJump32((uint32_t *)JumpInfo->LinkLocation,(uint32_t *)m_RecompPos); - if (JumpInfo->LinkLocation2 != NULL) { - SetJump32((uint32_t *)JumpInfo->LinkLocation2,(uint32_t *)m_RecompPos); + if (JumpInfo->LinkLocation != NULL) + { + CPU_Message(" Section_%d:", m_SectionID); + SetJump32((uint32_t *)JumpInfo->LinkLocation, (uint32_t *)m_RecompPos); + if (JumpInfo->LinkLocation2 != NULL) + { + SetJump32((uint32_t *)JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos); } } m_RegWorkingSet = m_RegEnter; @@ -1676,11 +1809,14 @@ bool CCodeSection::InheritParentInfo() BLOCK_PARENT BlockParent; if (Parent->m_CompiledLocation == NULL) { continue; } - if (Parent->m_JumpSection != Parent->m_ContinueSection) { + if (Parent->m_JumpSection != Parent->m_ContinueSection) + { BlockParent.Parent = Parent; - BlockParent.JumpInfo = this == Parent->m_ContinueSection?&Parent->m_Cont:&Parent->m_Jump; + BlockParent.JumpInfo = this == Parent->m_ContinueSection ? &Parent->m_Cont : &Parent->m_Jump; ParentList.push_back(BlockParent); - } else { + } + else + { BlockParent.Parent = Parent; BlockParent.JumpInfo = &Parent->m_Cont; ParentList.push_back(BlockParent); @@ -1692,9 +1828,9 @@ bool CCodeSection::InheritParentInfo() size_t NoOfCompiledParents = ParentList.size(); if (NoOfCompiledParents == 0) { - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; - } + g_Notify->BreakPoint(__FILEW__, __LINE__); + return false; + } // Add all the uncompiled blocks to the end of the list for (iter = m_ParentSection.begin(); iter != m_ParentSection.end(); iter++) @@ -1703,11 +1839,14 @@ bool CCodeSection::InheritParentInfo() BLOCK_PARENT BlockParent; if (Parent->m_CompiledLocation != NULL) { continue; } - if (Parent->m_JumpSection != Parent->m_ContinueSection) { + if (Parent->m_JumpSection != Parent->m_ContinueSection) + { BlockParent.Parent = Parent; - BlockParent.JumpInfo = this == Parent->m_ContinueSection?&Parent->m_Cont:&Parent->m_Jump; + BlockParent.JumpInfo = this == Parent->m_ContinueSection ? &Parent->m_Cont : &Parent->m_Jump; ParentList.push_back(BlockParent); - } else { + } + else + { BlockParent.Parent = Parent; BlockParent.JumpInfo = &Parent->m_Cont; ParentList.push_back(BlockParent); @@ -1717,15 +1856,15 @@ bool CCodeSection::InheritParentInfo() } } int FirstParent = -1; - for (size_t i = 0; i < NoOfCompiledParents;i++) + for (size_t i = 0; i < NoOfCompiledParents; i++) { - if (!ParentList[i].JumpInfo->FallThrough) + if (!ParentList[i].JumpInfo->FallThrough) { continue; } if (FirstParent != -1) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } FirstParent = i; } @@ -1741,39 +1880,43 @@ bool CCodeSection::InheritParentInfo() m_RegWorkingSet = JumpInfo->RegSet; m_RegWorkingSet.ResetX86Protection(); - if (JumpInfo->LinkLocation != NULL) { - CPU_Message(" Section_%d (from %d):",m_SectionID,Parent->m_SectionID); - SetJump32((uint32_t *)JumpInfo->LinkLocation,(uint32_t *)m_RecompPos); - JumpInfo->LinkLocation = NULL; - if (JumpInfo->LinkLocation2 != NULL) { - SetJump32((uint32_t *)JumpInfo->LinkLocation2,(uint32_t *)m_RecompPos); - JumpInfo->LinkLocation2 = NULL; + if (JumpInfo->LinkLocation != NULL) + { + CPU_Message(" Section_%d (from %d):", m_SectionID, Parent->m_SectionID); + SetJump32((uint32_t *)JumpInfo->LinkLocation, (uint32_t *)m_RecompPos); + JumpInfo->LinkLocation = NULL; + if (JumpInfo->LinkLocation2 != NULL) + { + SetJump32((uint32_t *)JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos); + JumpInfo->LinkLocation2 = NULL; } } if (JumpInfo->ExitReason == CExitInfo::Normal_NoSysCheck) { - if (JumpInfo->RegSet.GetBlockCycleCount() != 0) + if (JumpInfo->RegSet.GetBlockCycleCount() != 0) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } - if (JumpInfo->JumpPC != (DWORD)-1) + if (JumpInfo->JumpPC != (uint32_t)-1) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } - } else { - UpdateCounters(m_RegWorkingSet,m_EnterPC < JumpInfo->JumpPC,true); - if (JumpInfo->JumpPC == (DWORD)-1) + } + else + { + UpdateCounters(m_RegWorkingSet, m_EnterPC < JumpInfo->JumpPC, true); + if (JumpInfo->JumpPC == (uint32_t)-1) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } if (m_EnterPC <= JumpInfo->JumpPC) { CPU_Message("CompileSystemCheck 10"); - CompileSystemCheck(m_EnterPC,m_RegWorkingSet); + CompileSystemCheck(m_EnterPC, m_RegWorkingSet); } } - JumpInfo->FallThrough = false; + JumpInfo->FallThrough = false; //Fix up initial state UnMap_AllFPRs(); @@ -1782,116 +1925,133 @@ bool CCodeSection::InheritParentInfo() if (m_InLoop && ParentList.size() > 1) { if (!SetupRegisterForLoop()) { return false; } - m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown); + m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown); } - + for (size_t i = 0; i < ParentList.size(); i++) { x86Reg MemoryStackPos; int i2; - if (i == (size_t)FirstParent) { continue; } + if (i == (size_t)FirstParent) { continue; } Parent = ParentList[i].Parent; if (Parent->m_CompiledLocation == NULL) { continue; } CRegInfo * RegSet = &ParentList[i].JumpInfo->RegSet; - + if (m_RegWorkingSet.GetRoundingModel() != RegSet->GetRoundingModel()) { m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown); } //Find Parent MapRegState MemoryStackPos = x86_Unknown; - for (i2 = 0; i2 < sizeof(x86_Registers)/ sizeof(x86_Registers[0]); i2++) + for (i2 = 0; i2 < sizeof(x86_Registers) / sizeof(x86_Registers[0]); i2++) { - if (RegSet->GetX86Mapped(x86_Registers[i2]) == CRegInfo::Stack_Mapped) + if (RegSet->GetX86Mapped(x86_Registers[i2]) == CRegInfo::Stack_Mapped) { MemoryStackPos = x86_Registers[i2]; break; } } - if (MemoryStackPos == x86_Unknown) + if (MemoryStackPos == x86_Unknown) { // if the memory stack position is not mapped then unmap it - x86Reg MemStackReg = Get_MemoryStack(); - if (MemStackReg != x86_Unknown) + x86Reg MemStackReg = Get_MemoryStack(); + if (MemStackReg != x86_Unknown) { UnMap_X86reg(MemStackReg); } } - - for (i2 = 1; i2 < 32; i2++) { - if (Is32BitMapped(i2)) { - switch (RegSet->GetMipsRegState(i2)) { - case CRegInfo::STATE_MAPPED_64: Map_GPR_64bit(i2,i2); break; + for (i2 = 1; i2 < 32; i2++) + { + if (Is32BitMapped(i2)) + { + switch (RegSet->GetMipsRegState(i2)) + { + case CRegInfo::STATE_MAPPED_64: Map_GPR_64bit(i2, i2); break; case CRegInfo::STATE_MAPPED_32_ZERO: break; case CRegInfo::STATE_MAPPED_32_SIGN: - if (IsUnsigned(i2)) { - m_RegWorkingSet.SetMipsRegState(i2,CRegInfo::STATE_MAPPED_32_SIGN); + if (IsUnsigned(i2)) + { + m_RegWorkingSet.SetMipsRegState(i2, CRegInfo::STATE_MAPPED_32_SIGN); } break; - case CRegInfo::STATE_CONST_64: Map_GPR_64bit(i2,i2); break; - case CRegInfo::STATE_CONST_32_SIGN: - if ((RegSet->GetMipsRegLo_S(i2) < 0) && IsUnsigned(i2)) { - m_RegWorkingSet.SetMipsRegState(i2,CRegInfo::STATE_MAPPED_32_SIGN); + case CRegInfo::STATE_CONST_64: Map_GPR_64bit(i2, i2); break; + case CRegInfo::STATE_CONST_32_SIGN: + if ((RegSet->GetMipsRegLo_S(i2) < 0) && IsUnsigned(i2)) + { + m_RegWorkingSet.SetMipsRegState(i2, CRegInfo::STATE_MAPPED_32_SIGN); } break; case CRegInfo::STATE_UNKNOWN: if (g_System->b32BitCore()) { - Map_GPR_32bit(i2,true,i2); - } else { + Map_GPR_32bit(i2, true, i2); + } + else + { //Map_GPR_32bit(i2,true,i2); - Map_GPR_64bit(i2,i2); //?? + Map_GPR_64bit(i2, i2); //?? //UnMap_GPR(Section,i2,true); ?? } break; default: - CPU_Message("Unknown CPU State(%d) in InheritParentInfo",GetMipsRegState(i2)); - g_Notify->BreakPoint(__FILEW__,__LINE__); + CPU_Message("Unknown CPU State(%d) in InheritParentInfo", GetMipsRegState(i2)); + g_Notify->BreakPoint(__FILEW__, __LINE__); } } if (IsConst(i2)) { if (GetMipsRegState(i2) != RegSet->GetMipsRegState(i2)) { - switch (RegSet->GetMipsRegState(i2)) { + switch (RegSet->GetMipsRegState(i2)) + { case CRegInfo::STATE_MAPPED_64: - Map_GPR_64bit(i2,i2); + Map_GPR_64bit(i2, i2); break; case CRegInfo::STATE_MAPPED_32_ZERO: if (Is32Bit(i2)) { - Map_GPR_32bit(i2,(GetMipsRegLo(i2) & 0x80000000) != 0,i2); - } else { - g_Notify->BreakPoint(__FILEW__,__LINE__); + Map_GPR_32bit(i2, (GetMipsRegLo(i2) & 0x80000000) != 0, i2); + } + else + { + g_Notify->BreakPoint(__FILEW__, __LINE__); } break; case CRegInfo::STATE_MAPPED_32_SIGN: if (Is32Bit(i2)) { - Map_GPR_32bit(i2,true,i2); - } else { - g_Notify->BreakPoint(__FILEW__,__LINE__); + Map_GPR_32bit(i2, true, i2); + } + else + { + g_Notify->BreakPoint(__FILEW__, __LINE__); } break; case CRegInfo::STATE_UNKNOWN: if (g_System->b32BitCore()) { - Map_GPR_32bit(i2,true,i2); - } else { - Map_GPR_64bit(i2,i2); + Map_GPR_32bit(i2, true, i2); + } + else + { + Map_GPR_64bit(i2, i2); } break; default: - CPU_Message("Unknown CPU State(%d) in InheritParentInfo",RegSet->GetMipsRegState(i2)); - g_Notify->BreakPoint(__FILEW__,__LINE__); + CPU_Message("Unknown CPU State(%d) in InheritParentInfo", RegSet->GetMipsRegState(i2)); + g_Notify->BreakPoint(__FILEW__, __LINE__); break; } - } else if (Is32Bit(i2) && GetMipsRegLo(i2) != RegSet->GetMipsRegLo(i2)) { - Map_GPR_32bit(i2,true,i2); - } else if (Is64Bit(i2) && GetMipsReg(i2) != RegSet->GetMipsReg(i2)) { - Map_GPR_32bit(i2,true,i2); + } + else if (Is32Bit(i2) && GetMipsRegLo(i2) != RegSet->GetMipsRegLo(i2)) + { + Map_GPR_32bit(i2, true, i2); + } + else if (Is64Bit(i2) && GetMipsReg(i2) != RegSet->GetMipsReg(i2)) + { + Map_GPR_32bit(i2, true, i2); } } ResetX86Protection(); @@ -1899,13 +2059,13 @@ bool CCodeSection::InheritParentInfo() if (MemoryStackPos > 0) { - Map_MemoryStack(MemoryStackPos,true); + Map_MemoryStack(MemoryStackPos, true); } } m_RegEnter = m_RegWorkingSet; //Sync registers for different blocks - stdstr_f Label("Section_%d",m_SectionID); + stdstr_f Label("Section_%d", m_SectionID); int CurrentParent = FirstParent; bool NeedSync = false; for (size_t i = 0; i < NoOfCompiledParents; i++) @@ -1913,46 +2073,54 @@ bool CCodeSection::InheritParentInfo() CRegInfo * RegSet; int i2; - if (i == (size_t)FirstParent) { continue; } - Parent = ParentList[i].Parent; - JumpInfo = ParentList[i].JumpInfo; - RegSet = &ParentList[i].JumpInfo->RegSet; - + if (i == (size_t)FirstParent) { continue; } + Parent = ParentList[i].Parent; + JumpInfo = ParentList[i].JumpInfo; + RegSet = &ParentList[i].JumpInfo->RegSet; + if (JumpInfo->RegSet.GetBlockCycleCount() != 0) { NeedSync = true; } - - for (i2 = 0; !NeedSync && i2 < 8; i2++) { - if (m_RegWorkingSet.FpuMappedTo(i2) == (DWORD)-1) { + + for (i2 = 0; !NeedSync && i2 < 8; i2++) + { + if (m_RegWorkingSet.FpuMappedTo(i2) == (uint32_t)-1) + { NeedSync = true; } } - for (i2 = 0; !NeedSync && i2 < sizeof(x86_Registers)/ sizeof(x86_Registers[0]); i2++) + for (i2 = 0; !NeedSync && i2 < sizeof(x86_Registers) / sizeof(x86_Registers[0]); i2++) { - if (m_RegWorkingSet.GetX86Mapped(x86_Registers[i2]) == CRegInfo::Stack_Mapped) { - if (m_RegWorkingSet.GetX86Mapped(x86_Registers[i2]) != RegSet->GetX86Mapped(x86_Registers[i2])) { + if (m_RegWorkingSet.GetX86Mapped(x86_Registers[i2]) == CRegInfo::Stack_Mapped) + { + if (m_RegWorkingSet.GetX86Mapped(x86_Registers[i2]) != RegSet->GetX86Mapped(x86_Registers[i2])) + { NeedSync = true; } break; } } - for (i2 = 0; !NeedSync && i2 < 32; i2++) { + for (i2 = 0; !NeedSync && i2 < 32; i2++) + { if (NeedSync == true) { break; } - if (m_RegWorkingSet.GetMipsRegState(i2) != RegSet->GetMipsRegState(i2)) { + if (m_RegWorkingSet.GetMipsRegState(i2) != RegSet->GetMipsRegState(i2)) + { NeedSync = true; continue; } - switch (m_RegWorkingSet.GetMipsRegState(i2)) { + switch (m_RegWorkingSet.GetMipsRegState(i2)) + { case CRegInfo::STATE_UNKNOWN: break; case CRegInfo::STATE_MAPPED_64: - if (GetMipsRegMapHi(i2) != RegSet->GetMipsRegMapHi(i2) || - GetMipsRegMapLo(i2) != RegSet->GetMipsRegMapLo(i2)) + if (GetMipsRegMapHi(i2) != RegSet->GetMipsRegMapHi(i2) || + GetMipsRegMapLo(i2) != RegSet->GetMipsRegMapLo(i2)) { NeedSync = true; } break; case CRegInfo::STATE_MAPPED_32_ZERO: case CRegInfo::STATE_MAPPED_32_SIGN: - if (GetMipsRegMapLo(i2) != RegSet->GetMipsRegMapLo(i2)) { + if (GetMipsRegMapLo(i2) != RegSet->GetMipsRegMapLo(i2)) + { //DisplayError(L"Parent: %d",Parent->SectionID); NeedSync = true; } @@ -1960,31 +2128,33 @@ bool CCodeSection::InheritParentInfo() case CRegInfo::STATE_CONST_32_SIGN: if (GetMipsRegLo(i2) != RegSet->GetMipsRegLo(i2)) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); NeedSync = true; } break; - default: - WriteTraceF(TraceError,__FUNCTION__ ": Unhandled Reg state %d\nin InheritParentInfo",GetMipsRegState(i2)); - g_Notify->BreakPoint(__FILEW__,__LINE__); + default: + WriteTraceF(TraceError, __FUNCTION__ ": Unhandled Reg state %d\nin InheritParentInfo", GetMipsRegState(i2)); + g_Notify->BreakPoint(__FILEW__, __LINE__); } } if (NeedSync == false) { continue; } - Parent = ParentList[CurrentParent].Parent; - JumpInfo = ParentList[CurrentParent].JumpInfo; - JmpLabel32(Label.c_str(),0); - JumpInfo->LinkLocation = (DWORD *)(m_RecompPos - 4); + Parent = ParentList[CurrentParent].Parent; + JumpInfo = ParentList[CurrentParent].JumpInfo; + JmpLabel32(Label.c_str(), 0); + JumpInfo->LinkLocation = (DWORD *)(m_RecompPos - 4); JumpInfo->LinkLocation2 = NULL; - CurrentParent = i; - Parent = ParentList[CurrentParent].Parent; - JumpInfo = ParentList[CurrentParent].JumpInfo; - CPU_Message(" Section_%d (from %d):",m_SectionID,Parent->m_SectionID); - if (JumpInfo->LinkLocation != NULL) { - SetJump32((uint32_t *)JumpInfo->LinkLocation,(uint32_t *)m_RecompPos); + CurrentParent = i; + Parent = ParentList[CurrentParent].Parent; + JumpInfo = ParentList[CurrentParent].JumpInfo; + CPU_Message(" Section_%d (from %d):", m_SectionID, Parent->m_SectionID); + if (JumpInfo->LinkLocation != NULL) + { + SetJump32((uint32_t *)JumpInfo->LinkLocation, (uint32_t *)m_RecompPos); JumpInfo->LinkLocation = NULL; - if (JumpInfo->LinkLocation2 != NULL) { - SetJump32((uint32_t *)JumpInfo->LinkLocation2,(uint32_t *)m_RecompPos); + if (JumpInfo->LinkLocation2 != NULL) + { + SetJump32((uint32_t *)JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos); JumpInfo->LinkLocation2 = NULL; } } @@ -1993,38 +2163,43 @@ bool CCodeSection::InheritParentInfo() // g_Notify->BreakPoint(__FILEW__,__LINE__); //} m_RegWorkingSet = JumpInfo->RegSet; - if (m_EnterPC < JumpInfo->JumpPC ) + if (m_EnterPC < JumpInfo->JumpPC) { - UpdateCounters(m_RegWorkingSet,true,true); + UpdateCounters(m_RegWorkingSet, true, true); CPU_Message("CompileSystemCheck 11"); - CompileSystemCheck(m_EnterPC,m_RegWorkingSet); - } else { - UpdateCounters(m_RegWorkingSet,false,true); + CompileSystemCheck(m_EnterPC, m_RegWorkingSet); } - SyncRegState(m_RegEnter); //Sync + else + { + UpdateCounters(m_RegWorkingSet, false, true); + } + SyncRegState(m_RegEnter); //Sync m_RegEnter = m_RegWorkingSet; } - for (size_t i = 0; i < NoOfCompiledParents;i++) { - Parent = ParentList[i].Parent; - JumpInfo = ParentList[i].JumpInfo; + for (size_t i = 0; i < NoOfCompiledParents; i++) + { + Parent = ParentList[i].Parent; + JumpInfo = ParentList[i].JumpInfo; - if (JumpInfo->LinkLocation != NULL) { - SetJump32((uint32_t *)JumpInfo->LinkLocation,(uint32_t *)m_RecompPos); + if (JumpInfo->LinkLocation != NULL) + { + SetJump32((uint32_t *)JumpInfo->LinkLocation, (uint32_t *)m_RecompPos); JumpInfo->LinkLocation = NULL; - if (JumpInfo->LinkLocation2 != NULL) { - SetJump32((uint32_t *)JumpInfo->LinkLocation2,(uint32_t *)m_RecompPos); + if (JumpInfo->LinkLocation2 != NULL) + { + SetJump32((uint32_t *)JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos); JumpInfo->LinkLocation2 = NULL; } } } - CPU_Message(" Section_%d:",m_SectionID); + CPU_Message(" Section_%d:", m_SectionID); m_RegWorkingSet.SetBlockCycleCount(0); return true; } -bool CCodeSection::DisplaySectionInformation (DWORD ID, DWORD Test) +bool CCodeSection::DisplaySectionInformation(uint32_t ID, uint32_t Test) { if (!bX86Logging) { @@ -2033,9 +2208,10 @@ bool CCodeSection::DisplaySectionInformation (DWORD ID, DWORD Test) if (this == NULL) { return false; } if (m_Test == Test) { return false; } m_Test = Test; - if (m_SectionID != ID) { - if (m_ContinueSection->DisplaySectionInformation(ID,Test)) { return true; } - if (m_JumpSection->DisplaySectionInformation(ID,Test)) { return true; } + if (m_SectionID != ID) + { + if (m_ContinueSection->DisplaySectionInformation(ID, Test)) { return true; } + if (m_JumpSection->DisplaySectionInformation(ID, Test)) { return true; } return false; } DisplaySectionInformation(); @@ -2049,11 +2225,11 @@ void CCodeSection::DisplaySectionInformation() return; } - CPU_Message("====== Section %d ======",m_SectionID); - CPU_Message("Start PC: %X",m_EnterPC); - CPU_Message("End PC: %X",m_EndPC); - CPU_Message("CompiledLocation: %X",m_CompiledLocation); - if (!m_ParentSection.empty()) + CPU_Message("====== Section %d ======", m_SectionID); + CPU_Message("Start PC: %X", m_EnterPC); + CPU_Message("End PC: %X", m_EndPC); + CPU_Message("CompiledLocation: %X", m_CompiledLocation); + if (!m_ParentSection.empty()) { stdstr ParentList; for (SECTION_LIST::iterator iter = m_ParentSection.begin(); iter != m_ParentSection.end(); iter++) @@ -2063,25 +2239,30 @@ void CCodeSection::DisplaySectionInformation() { ParentList += ", "; } - ParentList += stdstr_f("%d",Parent->m_SectionID); + ParentList += stdstr_f("%d", Parent->m_SectionID); } - CPU_Message("Number of parents: %d (%s)",m_ParentSection.size(),ParentList.c_str()); + CPU_Message("Number of parents: %d (%s)", m_ParentSection.size(), ParentList.c_str()); } - CPU_Message("Jump Address: 0x%08X",m_Jump.JumpPC); - CPU_Message("Jump Target Address: 0x%08X",m_Jump.TargetPC); - if (m_JumpSection != NULL) { - CPU_Message("Jump Section: %d",m_JumpSection->m_SectionID); - } else { + CPU_Message("Jump Address: 0x%08X", m_Jump.JumpPC); + CPU_Message("Jump Target Address: 0x%08X", m_Jump.TargetPC); + if (m_JumpSection != NULL) + { + CPU_Message("Jump Section: %d", m_JumpSection->m_SectionID); + } + else + { CPU_Message("Jump Section: None"); } - CPU_Message("Continue Address: 0x%08X",m_Cont.JumpPC); - CPU_Message("Continue Target Address: 0x%08X",m_Cont.TargetPC); + CPU_Message("Continue Address: 0x%08X", m_Cont.JumpPC); + CPU_Message("Continue Target Address: 0x%08X", m_Cont.TargetPC); if (m_ContinueSection != NULL) { - CPU_Message("Continue Section: %d",m_ContinueSection->m_SectionID); - } else { + CPU_Message("Continue Section: %d", m_ContinueSection->m_SectionID); + } + else + { CPU_Message("Continue Section: None"); } - CPU_Message("In Loop: %s",m_InLoop ? "Yes" : "No"); + CPU_Message("In Loop: %s", m_InLoop ? "Yes" : "No"); CPU_Message("======================="); -} +} \ No newline at end of file diff --git a/Source/Project64/N64 System/Recompiler/Code Section.h b/Source/Project64/N64 System/Recompiler/Code Section.h index f767d8317..236a78e7d 100644 --- a/Source/Project64/N64 System/Recompiler/Code Section.h +++ b/Source/Project64/N64 System/Recompiler/Code Section.h @@ -18,38 +18,38 @@ class CCodeSection : public: typedef std::list SECTION_LIST; - CCodeSection( CCodeBlock * CodeBlock, DWORD EnterPC, DWORD ID, bool LinkAllowed); + CCodeSection(CCodeBlock * CodeBlock, uint32_t EnterPC, uint32_t ID, bool LinkAllowed); ~CCodeSection(); - void SetDelaySlot (); - void SetJumpAddress ( DWORD JumpPC, DWORD TargetPC, bool PermLoop ); - void SetContinueAddress ( DWORD JumpPC, DWORD TargetPC ); - void CompileCop1Test (); - bool GenerateX86Code ( DWORD Test ); - void GenerateSectionLinkage (); - void CompileExit ( DWORD JumpPC, DWORD TargetPC, CRegInfo &ExitRegSet, CExitInfo::EXIT_REASON reason, bool CompileNow, void (*x86Jmp)(const char * Label, uint32_t Value)); - void DetermineLoop ( DWORD Test, DWORD Test2, DWORD TestID ); - bool FixConstants ( DWORD Test ); - CCodeSection * ExistingSection ( DWORD Addr, DWORD Test ); - bool SectionAccessible ( DWORD SectionId, DWORD Test ); - bool DisplaySectionInformation ( DWORD ID, DWORD Test ); - void DisplaySectionInformation (); - void AddParent ( CCodeSection * Parent ); - void SwitchParent ( CCodeSection * OldParent, CCodeSection * NewParent ); + void SetDelaySlot(); + void SetJumpAddress(uint32_t JumpPC, uint32_t TargetPC, bool PermLoop); + void SetContinueAddress(uint32_t JumpPC, uint32_t TargetPC); + void CompileCop1Test(); + bool GenerateX86Code(uint32_t Test); + void GenerateSectionLinkage(); + void CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo &ExitRegSet, CExitInfo::EXIT_REASON reason, bool CompileNow, void(*x86Jmp)(const char * Label, uint32_t Value)); + void DetermineLoop(uint32_t Test, uint32_t Test2, uint32_t TestID); + bool FixConstants(uint32_t Test); + CCodeSection * ExistingSection(uint32_t Addr, uint32_t Test); + bool SectionAccessible(uint32_t SectionId, uint32_t Test); + bool DisplaySectionInformation(uint32_t ID, uint32_t Test); + void DisplaySectionInformation(); + void AddParent(CCodeSection * Parent); + void SwitchParent(CCodeSection * OldParent, CCodeSection * NewParent); /* Block Connection info */ SECTION_LIST m_ParentSection; CCodeBlock * const m_BlockInfo; - const DWORD m_SectionID; - const DWORD m_EnterPC; - DWORD m_EndPC; + const uint32_t m_SectionID; + const uint32_t m_EnterPC; + uint32_t m_EndPC; CCodeSection * m_ContinueSection; CCodeSection * m_JumpSection; bool m_EndSection; // if this section does not link bool m_LinkAllowed; // are other sections allowed to find block to link to it - DWORD m_Test; - DWORD m_Test2; - BYTE * m_CompiledLocation; + uint32_t m_Test; + uint32_t m_Test2; + uint8_t * m_CompiledLocation; bool m_InLoop; bool m_DelaySlot; @@ -61,13 +61,16 @@ public: CJumpInfo m_Cont; private: - void UnlinkParent ( CCodeSection * Parent, bool ContinueSection ); - void InheritConstants (); - void TestRegConstantStates ( CRegInfo & Base, CRegInfo & Reg ); - void SyncRegState ( const CRegInfo & SyncTo ); - bool IsAllParentLoops ( CCodeSection * Parent, bool IgnoreIfCompiled, DWORD Test ); - bool ParentContinue (); - bool InheritParentInfo (); - bool SetupRegisterForLoop (); -}; + CCodeSection(void); // Disable default constructor + CCodeSection(const CCodeSection&); // Disable copy constructor + CCodeSection& operator=(const CCodeSection&); // Disable assignment + void UnlinkParent(CCodeSection * Parent, bool ContinueSection); + void InheritConstants(); + void TestRegConstantStates(CRegInfo & Base, CRegInfo & Reg); + void SyncRegState(const CRegInfo & SyncTo); + bool IsAllParentLoops(CCodeSection * Parent, bool IgnoreIfCompiled, uint32_t Test); + bool ParentContinue(); + bool InheritParentInfo(); + bool SetupRegisterForLoop(); +}; From f8683083943edc8ed45d17ffc59a5a578c051ad2 Mon Sep 17 00:00:00 2001 From: "Julio C. Rocha" Date: Mon, 9 Nov 2015 00:22:57 -0800 Subject: [PATCH 100/213] Fix default tooset --- Project64.sln | Bin 33488 -> 33434 bytes PropertySheets/Platform.props | 8 ++++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Project64.sln b/Project64.sln index fbca22ce4743894f2a593ca247131bc2473fff22..3c73f1127d8bdef38b89f9ec501fb7f6cf077a5d 100644 GIT binary patch delta 37 rcmcc6$~3E$X+jC3;lxryVFLyQhJ1!1AeqCE$WX$N%22fN{li88&~gi8 delta 48 ycmbQ$%5 - v120_xp + v140_xp - + $(SolutionDir)bin\$(Configuration)\ @@ -192,7 +192,7 @@ - + @@ -203,7 +203,7 @@ - + $(SolutionDir)bin\$(Configuration)64\ From d6db9362d71e8ee9ac6b5e5f339eec3c35aeb607 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 9 Nov 2015 19:32:13 +1100 Subject: [PATCH 101/213] [Project64] change exit info to a struct instead of a class --- .../N64 System/Recompiler/Exit Info.h | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Source/Project64/N64 System/Recompiler/Exit Info.h b/Source/Project64/N64 System/Recompiler/Exit Info.h index b5d7247a5..bf7dbfdc0 100644 --- a/Source/Project64/N64 System/Recompiler/Exit Info.h +++ b/Source/Project64/N64 System/Recompiler/Exit Info.h @@ -10,24 +10,23 @@ ****************************************************************************/ #pragma once -class CExitInfo +struct CExitInfo { -public: enum EXIT_REASON { - Normal = 0, - Normal_NoSysCheck = 1, - DoCPU_Action = 2, - COP1_Unuseable = 3, - DoSysCall = 4, - TLBReadMiss = 5, - TLBWriteMiss = 6, - DivByZero = 7, - ExitResetRecompCode = 8, + Normal = 0, + Normal_NoSysCheck = 1, + DoCPU_Action = 2, + COP1_Unuseable = 3, + DoSysCall = 4, + TLBReadMiss = 5, + TLBWriteMiss = 6, + DivByZero = 7, + ExitResetRecompCode = 8, }; - DWORD ID; - DWORD TargetPC; + uint32_t ID; + uint32_t TargetPC; CRegInfo ExitRegSet; EXIT_REASON reason; STEP_TYPE NextInstruction; From 695ebfa9ad69b452142505b6737dfdcf5bf22855 Mon Sep 17 00:00:00 2001 From: toehead2001 Date: Mon, 9 Nov 2015 04:39:36 -0700 Subject: [PATCH 102/213] Use a standard window for the About Dialog --- Source/Project64/Project64.vcxproj | 2 +- Source/Project64/Project64.vcxproj.filters | 6 +- .../Bitmaps/AboutScreenLogo.bmp | Bin 0 -> 126294 bytes Source/Project64/User Interface/Gui Class.cpp | 107 ++++-------------- .../Project64/User Interface/UI Resources.rc | 8 +- Source/Project64/User Interface/resource.h | 2 +- 6 files changed, 31 insertions(+), 94 deletions(-) create mode 100644 Source/Project64/User Interface/Bitmaps/AboutScreenLogo.bmp diff --git a/Source/Project64/Project64.vcxproj b/Source/Project64/Project64.vcxproj index c0fc9b536..45a6e4904 100644 --- a/Source/Project64/Project64.vcxproj +++ b/Source/Project64/Project64.vcxproj @@ -157,9 +157,9 @@ + - diff --git a/Source/Project64/Project64.vcxproj.filters b/Source/Project64/Project64.vcxproj.filters index e831f9869..9805e41ad 100644 --- a/Source/Project64/Project64.vcxproj.filters +++ b/Source/Project64/Project64.vcxproj.filters @@ -431,9 +431,6 @@ Resource Files - - Resource Files - Resource Files @@ -455,6 +452,9 @@ Resource Files + + Resource Files + diff --git a/Source/Project64/User Interface/Bitmaps/AboutScreenLogo.bmp b/Source/Project64/User Interface/Bitmaps/AboutScreenLogo.bmp new file mode 100644 index 0000000000000000000000000000000000000000..9d8822f82d90f91ddad521a694793d577dcd0945 GIT binary patch literal 126294 zcmeHQ2V4}#_dg_>m}sIP7F4kJt{^I1>;((OigXnOX(EEy1r<3! zfYlv$>bm+ni^cx;=S7%{(Ey_XMgxon7!5EQU^KvJfYAV>0Y(F@*1*PA=VUT68elZ= zZ`Oe7zqxWu-53op8elZQXn@fGqX9+(j0PADFdASqz-WNc0HcAwMFVI5mQtBQ84WNR z_|Y|>^`i^O$j4}a(ZGL0135W4_V)Ju`}gnGt(&>I`G2F*Of4A=FdE>afuf=!PfyRG zLx*!km%F39Sm`Rf+0Tuf6>7%Z$Ze(P%Y15`9 zOP18u*8baT&(x36z&}z0)4sdZK!vGOr~dKBAEKh7s;a6RH*S=Xk!jz)y`G+)uC8u% zb@g|bfGL2{0Hc8)O9KxdK2%dv6A}^<78V9PY}>X?UthmhuU^;z+NMpLb?erxUcI`e zrsl^InvsUl0HcBLsDYG}lnom;^zGYML_}ob#EBLb7FJePl9G~u1OS5oOQ2obb|xk! z1_lO9pW-|I3=C^V13!=k%FD|!;5cH$h^}3`4j3?C?b@|2E-vaz)PMW!H@3ULY9siQ zV4E(2KX?4a!rTI`!w)1nBMPGdMgtrgkmZPfb@b!MkIR=Y7ZVff*|X=2=`)=6J6UhG z?mwhIb&QN)o1cCXYWwrJU)#$4{EKjVOAAYkNPcyh3`PH1H#8ATu*lT3UMc?Abea?!0i}!reP}=PsKgGG64@ksW@K z`}L2-orTmygjLzVAfzht^VIf#bo+g?&1Pm@Yii#C0R$$cv zrXCy}9pNYEx$qW z3=2jBj0S#C4FC_Mq$XnRg4HJL{rmUdxN+m!m1}d27AhQA+-LECPAbAe%S8ScmW#BV z@r!VOVJvsR(#RjQN{m>H2LAIJV12Cyu3fu^6$~p^uC(2Z%0Hc8)Q3E9Fpn*Ve6D zf5cibGBFxpG(gCxuTsLkefy?Oo3`G}e3QBP$+g4$Hq3Q)_eoApK7H!cT`i! z^@1}w84WNRXj%hrnA=iut<+8A>tozVcJfq$$90s{l36%;4@ z(bieAjfY$t-x)t`HCz^cBswD_BP1e3)osO+NZr0``}eWz*LUN9`Y^Dc)qsB113Iby zF-29v(ZK;bHXEz`^XJc>JbBXCTPFQqrUC5I!_}NhH6&}8(vZ)~`U~mz?%ku`BJJ#1 zeh00Cm_Gr{>gyvYh^h#rYRHXKY`kq)Wn|}>u_3F!B*nwSLt=`|q(6Rg7~RHcVjEZ4 zcAM8}MaLy%zRL6u^;7fGP!HE0Xgp}3?chPSLlFj3Ve8N?%Y>&clW}x##Lf$zl14;C z;4By{oACDb=1IUL{&O{eCOp3W;%v(pc{*~0y|)K#9J_WYQ$U2SCgPNt;^;6XB_-;s zf-}Ux36Hp_EQnBK$cQ*KpoKfga0fjS!2xfnIQ5F>Hwu)X!7D^4*(hNkHaK+d+?mT> zsd_<9Y1q{I)5!?Y1 zpu}5nz*~q)!3MkduO7_%iVnZCv-5bV$g8*^LOsTh=*{Kxj4kmOinhzpuJN?sAVZKyZoJ?rI zpzNEuBEubIbS^3pDU^}Xj}#3OsS7+2q4?8$P%qB1 z=yViEV+IPM%c21ftf(sBjzlUWvVb9{sGPN<$&eQ`bXgDpxqxJ}8tGRpjr`ARYiUk` z)d?d;kCFS8Wi2jf-B-YN#IH7%=BLk|eUtUZ#m{AFxc2fW-7(w7j@vJRFn+%zJ2**> zKPV}t)k}TtqJ4WE;^X6~Qgd^2aXb|I5pr^JW@ct*PoF#N=P`Kd;5Gx>Oq@PZb+IZZ zYPVQWCc}@X0kmjJC^Td=bNs$EHqeH`X`rwt$`C{j-MbfMqx*&Lk;$X5=8wLm3YEdY~1k7p9 zcuUET8sRNnP4K}ZEhkMzYlf1677Qiwl#mv+$w+Il0cXH&wzVBPe5Cx(EX$sP7Ci+l zhjg^vwDH2FOK-E@IQcp)J)*rdQfq>}GPH62lxlvym8aWdX3P;U%M_4o?s_A(P?tWX&pr* zy3Cw6bKl;5t*9T9$gTP|RrAJLY%$_FtLVWylm z0Yd~C+BGgNdd^46WI0n>6bBkLho19$%t=q#F@%Tlai&voRDoxDL&_#oAOIg$cuRv& zldM`t(AqvlX=&-|HEa9z?K}Thma&MSL1&iX5K((OyLiS9W80*y;KC`MP>~;=OyTbzm6*8#=KJhKuiWaCnrQ{O0wWt)5%8&KWKWQkU~p zPzaf-5KIRp`H-o=hV@$vy$*W=7#tiN?%%ub>~&zooPoU;iAwC9s1T&27&uKKP)Q+x z9TX7>QW|VN=nsjXXQ(J)ToTKo_({gR`;O|0lW%;&`tsQU3&dvrl^y=PS zqZ4a=S3yHy!{`A{2M(m9JjEQQjpt^a%f<@>RpbK|6~dJM3{w%23k5cao7k>Py7vH1 zz|)je7cb|b^ZO3b7%1f^O#z8~@KkmPqJpAAkfOA|T(4E#MW=LLuw?!^10#4X-&PF_ zx3AX#e{A@gFa6ic_7CO2iJgCa6;fJRWO{nKmX3~CmoEBUSf)J$jnJnUKg89|JuNLg zD*9c9Z96&#{y9>EowsH|a~6 zOD*sJv{Xl5FHub^tI$PMsVs*H6EDIqeG1Er-8%gP^8#DwRhped7rr{FFXGG)ZUkzJ;Bm^6Qas;XLWaPSYM5JnhU z0~lSPM(?32Gt7NA z=-o1z9z1JOxa^c8iU^Y<5fl(4!=?M^_1x~bIpf7EI3KA`QZ4Pw7Y8g`c3emD@I;AF zsR@1)rQ9dai(0C4+E~^}Zmj!+@qv=#gC-)336bcxy?+nI&hwVfR99EW!iay0n*S+s z;%CLTAO1f~ndgPxGYD|;sSz^LkU&R}$R`WsbAUO|LLm=I1Pvb!T(9^uL@D)^__Do; zD=(i%=!d6rz^(cI|Hs0LbC)ysy56A!9$#h_@+tRkdF9s1QgMXrQjJxke*byrur^x; z3tIJJnNOeS9}@QV&D$5xUYPiq>D@KKn8Ac_X^AKWi6ipt5Gg<5h}@X)N#eSqcFsF8 zGcwVqc$V_aa<7GI@CvoWRioXH4Ge(+ z(^aE?>h8od43zW*S^zn?if;08jm23mhA61XTulu z6x`B}WidxO^hosk_wUo6rmYV!(SKk%C0KS;#N;v2vZJG9Mjt_t#(ik0q_|!W2e&=1 zUuEH!OiNAQxX%JBA(Z2m409YY`LO)Nt&{sHi%F_UE(*|CpSojVxcWf*L4$mT4GtPJ zC~(Z6pfO^;LqxPhM$8zXsk_SD)V#8?lDCL|N9sQj8+e*Be4vSaUJH}uYdCA8ic&;uJa$H;rlhV5Ua$MWXnc_5&`8N)(b7Ys zrVNdmJmknE-1~=&71QnE?B$gG`b|d0tMq5jtsE_vL}{ufuEIRUaKjOO6np8L=tP7? z=x)N<1!C?CTi<9`Lbh_yeO8(Ncvp^d9)Q3tVPR zJ+{cW?>)@nVzO!Hm4+2*X-aFy8)D<)lxECP5n~0-XyYo~#&Lpx^@_RC@y7}Z3Z5iC zF$_1>yuWr>;OPEQ68)nmA@qxy*#F2x+q#PG^|I+&_53J z>Nd0UJdK&!TH0ZuVJ)rqccTAiVFL`h`TjhA``|SFCb8jLl}mr2zZFBcBMln{&!JWR z+Tg-1_yJtDOFhCx0A?T{(vYA<@X%$j8z%?wY*>+&rnGi_Ls)pYg1nN>AXd~uL2o5C zJlJS2PB?zDsIcfkQj%emvBrbd{rrdYj+!7ABPA9i**iv}ceF(BmF6dUwpk_KJ6L z>)tJRaM$2r-GYY+g$(Lw+g(hl>+&_~x;lD4$hhP`3md-vTT7b=TnD=8HHi)1s$ANX zzZFANr=jaW*Re$rPCgCC17OEdN7HDHA%cDZmwkh#`JD@{4hvXuGH+dcLu<0t)z$g= z`^!&~u^7WTzCti$o`Bc%pKR7FKXLl(r{YieyH-YVCaa#T>FM9EN6h#hu@XIEC-jJ! z&^>m1_qYk2Lx+m377dQ{|M30;MiMh$y|%D3ov?W1=AAZApFDm0_U$X28-?rD>(`lC zX{l*DoOUkp(>8s+TRBl(WRHlDcTeHap~9iVx`Yku5Zu4xdXb^C`sf;Jtut7M?o4Yc z^G);ov#_B>-RLGQgSLhyu>orgd2)k1P#|ab1V0Yg!mG!Zm}eI1*K3R+&n)~CQ5I*5 zz#v3p^ngQ1)tFa7`!wLzutUMqCqUPL3m)K4a0Y#jMuDRZ<=&Hsrhr%()QM7 zh8HehsVJ|wdi{#gX;ZZa8l8fA3muaXJ|-!A6hT4=;h02+h@t(~h{YT`l9!tgFaSK@ zp7TBjkbrgAA96lmD073osrc+JLl=r4Nr=eLEx=#pUbE9c=aQLu#%{^r$-lb_3q=eS zju|5yGa8|NzyRST!ZVjE7#SJ+`}u#PDz=hMV@(N-w3QrrWoy#-cxB>|#`Bv;JL)_# z)F(AoN7`JP6pv@QG_*8UF8G5p*Tn}L`0KneumOKg0eDsx=*UTfc*7cT@@a?-d_L-2 zu7l+C5U#Qsd*t#PzR7T8V`Vj-{^`@F-S&It3?CM|w97;5zE=!|6SReFEX}Upyj59I zdH(V_HCQup|{JX#5*_3#GpZF)Dt)Xe-BhBUFQWZeEYnYw0F*dWF4VfUN zNgD<8hNggwv;a+t$FtmK%FL6DCqtg9{W>AOcJS&E%p*VoqC z^6vel>d)0D&L20vW~P#|{P!aRgwMzbpQeJe@F^MLGqN3`M-N>$;MCdU9}5bx7y{S3 z_wRCYa`JNWV-ku1cky&tNg4hOHwF;Vk3h%5?})dg z)<{uZp-zW;bv`|@>sfh`bFv-6$B3@zX1&kiZT36NYC5<(F7?&Mz=PTijqYBeBC#X7 zo|H!Dc1otxiHUz~79Y1@sOd%%3-b+md3k&q#rJ!~vne%fT&+lzAH9eo|aqjI-qm3O*hVbf3I-jDnrCOpKgJNKcXD z5?wDScDpcD=#oN5ui=B#dwT}E736(v42GtbQv3GCJFxMcUU3O&xs zcR#PtDN(A6ZjY(UCRI)G=PUkr!1?x@ta#v(me(WpNNw4&ZKFhwQs0@C zLGubdf+Ocy-TKaQfL)ghsqeo_n_vdy#BiZ%F?5;OvvBPzQnO$$r?s#I-1oKgM z@81p&4L^C3eIy+w7ZMT^l#OOMY@_N}Uc29k+DI zsq-g`J{BiGOg45j)xBtDk!?5Wm~_|hzM^MkMK4Y3d2zbv<>{ScrMfNezCdTDxrIeg zP!KQKzi--i#Rhotl=M7}54~reb>rzd^Kr#_GT}<(DF9`rpydA+1g(Psp1G((dA{P3 zxpj{`f6!L=4Hz@vImn1r4uB0Rpx3}fLm4-{!-DfIh9Bs3x@ug$1zZsNRVyOyt;j>3 zJV~*&wzXI6Sr@HFqL)+$&A#cNylb~zM#d{rO#+Vln?AFUdpKM8qHMQ2%H8kG>wbHF z4}@FudfZX&bXrErV(i05Ns$qe_+hC-oG^kJ8WFN||5D@UHs(1yCY+G$c65a3)tNo7 z&+U10uF#cf!khak8z?+0OzSLcY{ zm@O14*?VDk?e#0nO)aioz1o`UeMKIgO^IjAZABsm9w^ax8ed}#mM1af1S_60G}%o@ zMxH#8$VWW-ZDZx~6sE~UiY-sFCM&`dHCs2{KvkUoy`k%X6l7`GiD>M5&$R%ep(}vt z56--NdM^A$rQSBnh2&=R@X;gdjhkE-h?BFr(p?u$f|R63uPm)z=UBv&Q9ueOS$*$g}v@B5JQWe$4+E5*f18WtCaRZoM?q z!LdVoo|Y27sVsIwxzEi7qPOP>yNwyKXuyWe<`(7_7&hgW{(C-uS8RX4$-S0o@yV+@x)hjYF&UIyk+5p95?-e8R&t(_;L6r5<5xj`{3$#Xl0nb<(s`LpXd!dHcI@;w7z##`rcLPcTctFy@g%351Xty#>#f% z-aUIifBwv)4&Nu~dt(FD-eC}pnODPV@w8)#4^Jj^&!r(NDg~cgo*5}K1r1N}=(ix? zxq6BoO=+xLo)w{HaCpK-W1TFDKTx(gxp@Adjk#!zNlvFXbRDQ~KbOT**nn3^r}NSg zB+}r42p2qXc_CaYvuP&ZEpq+F%?-wek!EAblP%=d26D~t(&5#PPA>WR1$Ce64xMzd zcxO5G-n5<%7Kx>5h&^2?o`SFfcf`A1oHk>NTzcBGi13I*hYtDs`vV>l6BDT=jjvw3 z+IYZ9^W18SobA(}Ef>GHuy68;zRAn`C$H$8vaGxRq#^3Pf@1^9ODeKnWm!4dtU6|3 z^I`v@B=x?>$MnCgJmBGSgn^Hj_rA5T`?`M9HDs)*uc}uIVWOxwp^a& zQibwl$fqLE3{P%U7L*RQ)Wx$d$ouDe-v84-LBoo`;yEoFajItli${bC7&hQ?7r6Lv zjVs`hCg6e}iaGtZMUm#N*ZzM@FJ8KAW}uU>OO|BpBM-Nb`y0-98#^6zD=I3gsjNA8 z+G#_+)wqXq#2zo{lcwD#O^XVB5lPqTc4_9^9ZD}=JP!^E-o1PG&Ye4P2EDGXE);~pKK#Jyor6=-yF^dXhKq-Y73Ee~|RR zz`;oWs<~y3ozl%21J6$x{BYTjCz?YauNwSRv-bsMF->vJ^~=o7EmBfa{$B;Y+XI>k zPg`t0Hc+DRZ@D}hEYETqOQcF^3^}M=__{-E`f5xhx(M1Jc#6k~4LrdQ#nBuZ{ysc; zqG$@kcrv5~gMUER0uef$XM}<%p0Apph*BC>fl7hVbGiM12Wlpwu`E2(8-oY1;>4bY zV-h^M@l0&hc*DulXH3_uIO{fxymuwf>`Cg@L~k?aLtZ%kxvIQs|2YTq!j0peEa;oI zs{hM1{a@<$f4O=9JLva+wOaJ@oJD(Pz0S;Zayl?~?pzrenXzNXN=r+-xw@sNrEm4L zlC~H%##gp)lKOx&ogwM^L(=tzr0L>5G)-^lbNxP#SN7U8XtBx6XKByM%gV1^yQ=M| zZu_;i(|j6FWX<(9*s(yR1CiJ$TmsnlX-LE z6h1YFk`E0ZY=8#1%o?WLa9p7|Et886)d9f(11B~h-W*muX<9zsfP+*LjwY_xSG^jn zLJECI<^htiC+6@54=;cGv8&IepB*plH7nXU?y1Uv4E;e_MuW4~vBPV27?f??``Y{^ zPRehy-`LyP%|5}$n}4wH8j(3*ek-t?$6W8u(vUg2hZXOm;#T|=Zby&~r)h^?=R+85hMm$g(mA-b=bA!<@ z41p!REQi<~-0J4){@08;d@F2#W$CMu%&r<($iqW^KJ7J`C|i=&~T9>&pAm-U3~7Gd;l;MJaDb9 zrV{xu`F5|cS}7_f&RAFZc7i4;4JPm1$eRN}ZdShj!FW|(Qoiq+y~QW%@oCG3WEl>B zXFB|?2^EIDF&XyWO#H@zmCmX;Z{K5ilD4+Cz5Sl2$*Gs`UR=Cw+VCv{2Ax+%t`Toc zM`oF@!)udKSyWh0MMh_t4$m^|7d~b1vL1)S-Aal}ia!>+1-h?1qHmV9bJZ*T@%NQS zKQ|bgX@W57m66z%Q9B&1y*#|i%F3Fr15~7SXG#5y*wB1~<8<8{b5NRZ2cU$ZbB-kP zgf32Ozz@Nb=9?GVB8DKQ*QU2LBNu&>*Z>VQ9C&D*|Ic|i1m%BlroeCbnjwegn@l|= zoP)6NXk(pOk1nhuRT1Q)56N-&blDUV8d+OYTT)bFe{-j0xvj)Y%@OZR$9}LJlY_8< z3ZwHj_P@DU+jVJS{>L+C&Lkd7#A4{MvjK{m#}0QHJuGR(s2q!N?=8o^vl#oaRSjXP9BF_-w_vmxdB= zHXw|9Yu;zqxXtz!huu933kz{x%)^Hdal8aJT;Ld6p7q9J>vQMMVelh7JiHZuU+-_k z22=-4o2!vFe5Aj%boKdn)*Eu*N@+Mwz|-!zumPoiO}QwPw&QPA5zfI-t~$2#u{qel zbLx_7(t)lT{|M*Y1e^x0;mEIC0mZ-Q|Nj=7AVNZq80jdb-?1dMQKU4eF5k!1aZ^-u z9H}Ek1x0rEc5JBJBKcZ>Z0<(M{LPa2Hj;VlFfrdo;-l^0TdJ!)Gyoys`ab9V)*wp> zoBpFB@dS*CO+^r zH8t3YWo)-*-l5srN$Y36(3W~_Iyq%HhBoJbHVxDRF^v*REX`E?l4qniKg}*wEN0A!T7ajgJx!K0#xh z3pmUT4V20SvuLbO&)+Oy-<%!;#f_(UJd18!xlj(L>%;lGw3;D)I8HwNYu)7A=3oPg zgSX#sT(TAL0GQ$IM{x1PBWKmVXB;2kpx{U&9r@QOTM3CJm0?vyf&1(?B_t%G*pGPy zcFEft^m#)V^ml@AX=lw;SbicPQlTkT2Rb$XVLhR@dLhAAf_}+1bU-&GqE**lSnLBp!|N z^77ceeH-Rcu?rL@S7IADXaWKP;56WV;>3yg_;?!|8*CzPzB<1NHlX1*)*a_*VGYHD zz2dV9V)|;#m^kxt=7Rm9fj7JW1{6;&W8&n~(l}(JrEORul>&DM<$|ms6g4ak3;`0L zM=qWWQ9HU8)J#W1CR7T~9~3+rqi<$yXwPk`7-;_ z_m-LYt%*DnGS5kRg7;X7C;BpS%vm9 z%N>S!PF-uQ;pW127fzly_UhH^Bd04)Uav{XsD77Q_WZ@mQ>RYY+S=~lzdtlIG$bSh zzC~bQAUYJOsi{~~i4-i*YFruIZ+JE(d}gR`Hq{>a+^M$Q7%+g(H?&A@(V1sn8sPbZ zenV_PnOxHi6jZbV9(Z~o6gL#Xt8(8w4JR)6_y(@mmMD6Akc|x_wxT%H!eafIv*%FO zo40T5(zkD{wwKPcoL;_fR)qsQlz#~`KkuLXP-l+o6s7&6rDEh|-ff&wxqoi?{yAk1 z^}%sYnd98DFLy)`W|uf9ecU?p`D!T_2{|39Q>Ra$=K>iL6XTB^JBF`2HicG{S8hFI zJOUO`G9hjGdp~CUQi#DYYr(q(wFlXCVOGww8C8rs$Ca-c3D{I zOoc`D5!~y8%i>BG<%)x|i+9dRUp>)z{CuMsckkXs5ja!w#EDoxzhf&_+>MPr`|jPF znyOkm&mFV&E9xhktjym$zi^LgnX77>{F|Nv7+Q z*#<<}1RznPsD9?^^#{qxNf?B{FauBl2oW0_i(UpsU0=R@6&0PZbLaME?#tlWl$vk) zO;R@UoBUYGaEuyO1c^VEl+BZd=MVbLu>rCG9x#T;6LLT{S7LHxj4~O&uzbRzQc1NMd2KRPr*iJfquFoXUA=nQ-rgRYJ7QvD;E@0V ztExUfOM7L#BRncP#@QK8QqvdDrqs|-T9@)Ynq<>eYB>di4K3H%zas~Hc;|x$wyzm{ z?~H}fYE>20WvZ&`Dk>`YD|o12+N)>VpKl2wkp?9@XMD5)9;_tZoMCB|`*Py5iuh{O zd27`9{CP*jXVw3L@3NZ1i_7=Tf2b+3Ww^PWaY1eYm_K`#diHGm?%n4_MB-U2|KEQP z3ko`sm-imM43}W1xd)WA9~kI<+O?$2MXTCZyV^&G1j?P)QQJ5_KNq_(OU<^Y|2m>t zXjH~>-N5jeM|RGs1~#wcS5=Q+_;IyKcyZCk$jAu50|p||t-#;-1~%m7f7IS^)7CB~ zIMDafrAtlzg5MPzFuvBL06zl3zX=;K^oi(-~} zvLoy`?!XDPatGyyD<^Lox5s^VMJf9)UOs)Af~kbfn=k+Vdn|x~#R}-yF%0twY-}I| zyD;WED`_RIU0t$gWu?1*U7&tlz#0-d?YiNjjk7VyNyul*9Zy)I?^!)=7@0ZaNEt%P zva(*wsC^tcpNNk>c;n`++}s=w4>uQ=gZmvFPMkPiSy^6On7_lLaGJ(l53eX!mxI`s zfvHYDD*t}ifW^do%Kf2U!IBy}Mo9djgk*&I4jOp&?Ad_>2bL~fuD)d1f&~i{6ch#w z7%+PD=qp#QP^IDQXuI2cyy|?t>LQkx>`?pcqEA9#rU+~Qyd%;u7}O_f5&z{C4s)+B zmfkcjEH;?b5}0Fha&mlpq^hcupddVkFhRj!7AvqrhfrVNlN2@t#`!9{PSbv5U{K+x zS>cfXTsRdcxCz0+$ z-AS?jpFhnJVgjjM&%Xlm0_U7cx z!6e+VHegBF?p3wk>qvw#i8TIlM}!JUqyqcVh(zd;pp~B;=iOK|%|`mf8TNt+EN#Ny zv%7lrimU5>7HbZRl^`e>EhreyVg>*9Td0rEsr-EQ`h)PqkOhaP>n0l*RUOc&@i8Xh z2qq+IVY=;XE2TF$bcPUT=VTV^8cX2Bw3*hQKbO|k)f5#LOq}<)?ZC1QVlMFsC*VnJ zam-RSAjZ4N)b;xgDk zw}<~&1Q=jtWi@r`)M3MhVcLH2;>G@celOC~acVUEXQk?D>Y{JNY=6BYg2e8q@m^Z# zxVkRHjKrAo3T7nQv_7mRp{uI)&Av2y&NhWxcWyziV0i7?wS%X9^0~eTtaVM;0BLq4&gaeT}njt-lF5VnQOpRxNAyj7{>dU%vv4 zx7TB=5MZ&6jvH@ST8eLfT}643+`OAC;cNln{YRp4xL&2E>GSp@YDK3Iad|Re8bNns z%5scXl8GwsZTDQgmy~=wF%hE?;KuXf**%4=wDdxc7BKS<@)bC>0m&QI7m1uSO#H{! zz=sx#c>n%=?2+ozr;mh$gr%kB>60hlVYvZTJrPn~Rz|}^d1;0BRqy@9PLU+uy4q8t z`p|k3wSmNQ1`85zLE<)$I5QHvhJuie zuI;Z#hRq~n7Z6ERBD<1IS4%i|{*t%%KVwX=#Xl{RfziNMY2d+w2N-6+e44kXXUd~T z1!ZMV3BgbUzVn53brq$h^bW>?{Exe@?((Se2qy_9H6EI^-sU83BROjM{{s*L9)srR z?K9%!%$?Wez6Z(>oDz5W@@0%|AdZ!oDJf69ybiZ*r!DaNEy4B|01pDJqwU(od3s)? zu;I*=lPZU2tw~#FQs=5$7eF~8W+ZN9v8%%7DK9e8!6z~CrGUUW0oJ*W9b?qhQ?<39 zuU`FP(7@XQtXnLW70#dnjqBlLR>wzedcFL)e@2@=uiEte&|ze`m`v?}sbu&Z(qnXD zKu~OOZ~$-%#LUHLfYAVl1~7+-17MFtMm~G_@bZT7m>Vg0aR^-^m`hbW9NdPctR9H`sp0d-|w(L_mio)Nm05D)> zB2_G~AvN`>pRaG*pA7^=9td{6A^7VB0l|~)+9rBbr}Ak^Vky6$#reTE^pf69Tyh`kto@iJEH+c1Al4&`!Lhf z(sJLu(+>*Lx_kFHdu=2+Qx6Z9G1G{i1^$$7Iorgk>%^@SThca%lgI-kLZjAoEeW?G ziBvEr37EoISz$Hji0r`-hsyHL$byX$*d@)m4iWpN)6$;#`vtUZZz0h8nV@KrVCU-s zzg%eh^BH%yYac(d#~W_kzqZ7CzQK!i>*@|_kpL4CYswDsniXEMyQe&P#_puty7#V~ z=p$CA$ATU2u-aZ?vCh>a1bP{(V`CFQKzRdhZueQNi|v2gb@3wm2>S;QGkz9(+(zte zJF(Ns%YuSKkDonz1^|gy%*AMc(ZK)L0LB-J^7D82`L#1K*^`%tF+2qPiCQe0#_}Mz z?-k|c^f^nl)wQ9QLw05FI6`9W>q3_iS7Q=wMUI=0cpc)uqS#P5MDghPILuYz!luXD zw{L&=@c)KEfDiN9a5c`nuyY8M3ZESBYUmm)1CpNLx zp|3=BVTy~2MvXdw36TjCY|6_%WoG7f6uHLg@RZeVUuf77OmN`jiOkGQwz$m2Xn@hc z|I+|Q6tc6ja^AdAva;&o;NVwPg)LV{>*3*iJv_Xvt*tCA#q=YUt*p50;3X%gaz~6y zT4DJD@mxcqw29BMJZ;s08E3BoR@fIH2a79l=p^+>-{DETdi63aB%<9PyMGyz|I>)q zg8fqkdOQ#mzU}IMm%@hRl!q&Q7aC=*TSuH%k%09i4#9*ZXjl2k9+18J=q9+m&MxdP zU-H|qf{ggBet%>S`;_ojZ$d+SqalVTy`A4H|^m&Xa=&TVtX2*s$vjORLm>LzcEjfl%K;%`Laj7hvPu%R|s z)=S~)efTq^u&{KYLGk#-r2km^w6s);`@8p_yh3yDCs&k}*FpgF7v8;N|DCP<2kx;1 zFl6byeS7qrIT)|J%wl=z>Fqs#{tS+Gpz<nlHfatI1ytzB!Ll?7}- zK>q^pfPMnjNtWZ}>B`D4x$8*6wfJ=p^_JeByE)XNe*Y8OV*oH66=-s>Q z=%`~Iy7>=OCVgg;Zu0OR3fc^R>*$$U`iVU_k(K>gFL;^hdtig>65_Xx#38V;p)OR` zU+Kba_%o!mv`ovYV5%M&As2c5`aP5^ITxVAvNM_$i{|vBXU%mgv*9ZKXrpW4N+TL zwcq#cT;p0LouX9+;pJt;NX&j)IC)9!0HxYNl{H4-dE6S}Z6ALI55x zw+VQ7TUW<9E?HAuLrqCw)DOcI+4Vae_!oh7P#-?LKN^2ZxKF?oJtC<|MgSh>5Mh}r z=fF4RrR=2!fGFb#9gBS9b;M;c@m)*e3`zVtHa0}c9hr6PYSiaS_UK_zQL)wjcWPE- z&g%C&JqiO8$-&U-*=y^hmy^-b_SsplA3jXNLJ)%MujJV0BLF zKh!KK>26$HEPsKSw~PiD4b*D@R$fwE3|Cx4M@KRt!IzMrdU(JZWK3S*q_~2bn$H{q z56FZ?67U#sOiXiBh?xRxj69Zbw(G!vX(mM8fJm+)Bh*Om8RSs#yNa?rFe%6{FpFBV zp@2OWxrq3#A#nyI!H^tVMIvR6&P}))k@?~^H3O3II$vjNvBox{Zbg($$^7+1)soCy zT|Hu=MdquF2M?04VT7JU^$X7w8e7t3eEILAirV&j(|v%|{rmSKB7l9&#b|)hKyx&J zPdl80*fVE-)zO)C?V1lE0fdBN3sn8^111SdYHF%Kf2PJILHzvr^XC6C8DLLgVg89@ z=eiH`Q??;o17E)YTY!z!{`O(OTI4>Z+tJ!|T(KY1gf;!I$ zVUwdS2ERyqiGD|YUFyzWd$(*;=~5fAVhdTh6(CVNPU&z!P!tYx!4bs(EqF83z-Vdd zrv(GijHRQak(TC9 zh#w*7Ur=+K$BT-xb8>31E}*Iklr35xfaQwC#UIa{ywr1y-!glmwvEiSB#P_E*cIe( zWZvhB0!WX=*0x72tcr|Gh^sR3(I@e1$+0CQT<-A-8QW2J9^J~!$mDQSs*j$1z03Wz ztxL9rLm(mkgzQX7Ie6j(mIai2`UGIW+(h&EeW3z2 zl#~>mJ#|G~!e7^!Xzn9wTge)g8WUpeXEUnyee3MnNkvTb}Onmi7!U_^I zt#H#6=TX54epMCKIO7dHh5zrYe6Fdks3@=a_^|+IIpD8UfClTY5P_)q1^Lvjklef? zHIo8aO(L_B^plJ{mUu2cKDM#x))v)^A!ao2pV0uuCDC6fEi9aAW7EmO!M417M?rzb z`SYjfpZCZ{OYIBVQCD4uCC=z3V0|UdsD|A`65vfOd)elf)fYfD zcohH-_PA;;{>a9M+`QaB0iZTA@vXd8h0B7yyay}bFh`BEt9yA?@vMmWX z_Oa$Odn&T_bFI_4-8P?$tcm9=;ytT&zx-J_Q+K_}^2*!~x!4*7Y`~5QETq87N1O_K z{l@i&4<2IJ126!n05;$Pcwq0wmn$!iT0afuC8gzI39s$kUoO-<;_DxC`}Pgw;x9Av zmeByCfd(4DXTGwcA}c%l>h0U*#l@v1B}iyM)q(_I16=>BSMCg->ANkOU{5FD!Qc>C zYDYp&eypvk9~h`6ZkP7kd@{BrUX#dPxkvL>xhSK9fWM1}(_!$(adCbWwo3pQ01r2B z-n@7B?t{n4FJ8SWEc^&30Pui2b)nY-oTwiZ!FjWsS9N7YX+=dPxWWJ6e8I#S4KNyL zo(ABtmz9>{7$|&t>9ZV~mz4(<6C4RF~o;|Lvs>WZZ-~0!;sA{>uYz@y=#1b`Zo=)r042N%_UJ@K1s)OSAt;l?Xn@f`(;E1CNTACA zHdI%AzJBBWI2E6R=ZWJfvMY|*Mi3)!5`DS2uDXmpYEValZ+TmM(l;v6n;$NB;THRJ z!lzH4-nn}R>m1RWz{fr#BLmh?v!x<6wKXO67zP-Fe^ZN5h?*KW4VbV1qF{Rksi~@~#h@hn0vRSL;9KC-DU3;=>p{61 zSicEh;VXMaR1wUb(Ey`?Z>IrlyQrx_)7?5w9xQ*Yn814zI{9rc27Nj|vJO#TcR zqX9+(-$w%!Hrz={o~-Q?m_!2Z60hrQ?_tjgl6b$eu7-V*9ImiSfm^~il$TY&QNXYx zmDv0{O2If|$)^&`RWL3>^YzA1G8*{%G=ML6ZEf|v2T!DRy+V^o=)*7YfU$>@kE&{` zzZ}7o{wgi6AP)l%=t{J1A;sTUMW$p%1B?b*p#k>TUtR6P$EmXVUg1wj#1j%y4-X#K z$mtaJPy{DW3>Ts!z?s6t84WNR_?K#c!iGnWpULWbM?NJ{sU-X{2}>qH56PKS%r$<& z29N<5n3V_r(pJD!i_t(s4b)GE);)UiOh(TOz!3j}#J?oocRm|>B)J{ATfg*~eXty+ z5^y!l&ZICJU^MVA)d1UXAa#$QrpxI2gryMY^Eu|8*H`Zd^9YQ`lp|GXU;`chm#TrO z7NY@116&%QW)ah0X7-)2WyR(&C*OoSNsr4)OK37oF<=b@{m4WZ4KNz`Z)gD6fSHP- z;*#jZORryZZ)CuHBQxdr-)IO-Eg21PX#jnSKetQ&?+p?G2}rN+ar`fxi7^^rH1MC% z0LBt%&j8&A-~k>H`OheTsVJiXMgxs$0J|Rn2^dshyoAP7#H2GCU^KvJfYAV>0Y(Fi z1{e)68elZQXn@fGqX9+(j0PADFdASqz-WNc0HXm$1B?b34KNyDG{9(p(Ey_XMgxon f7!5EQU^KvJfYAV>0Y(Fi1{e)68elZQTLb?GMV10c literal 0 HcmV?d00001 diff --git a/Source/Project64/User Interface/Gui Class.cpp b/Source/Project64/User Interface/Gui Class.cpp index e60f3754c..8b46abed9 100644 --- a/Source/Project64/User Interface/Gui Class.cpp +++ b/Source/Project64/User Interface/Gui Class.cpp @@ -973,45 +973,9 @@ LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWO return TRUE; } -WNDPROC pfnWndAboutBoxCancelProc = NULL; -HBITMAP hCloseButton = NULL; - -DWORD CALLBACK AboutBoxCancelProc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) -{ - switch (uMsg) { - case WM_PAINT: - { - PAINTSTRUCT ps; - - if (BeginPaint(hWnd, &ps)) - { - if (hCloseButton) - { - RECT rcClient; - GetClientRect(hWnd, &rcClient); - - BITMAP bmTL1; - GetObject(hCloseButton, sizeof(BITMAP), &bmTL1); - HDC memdc = CreateCompatibleDC(ps.hdc); - HGDIOBJ save = SelectObject(memdc, hCloseButton); - BitBlt(ps.hdc, 0, 0, bmTL1.bmWidth, bmTL1.bmHeight, memdc, 0, 0, SRCCOPY); - SelectObject(memdc, save); - DeleteDC(memdc); - } - EndPaint(hWnd, &ps); - } - } - break; - } - - return CallWindowProc(pfnWndAboutBoxCancelProc, hWnd, uMsg, wParam, lParam); -} - DWORD CALLBACK AboutBoxProc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) { static HBITMAP hbmpBackgroundTop = NULL; - static HBITMAP hbmpBackgroundBottom = NULL; - static HBITMAP hbmpBackgroundMiddle = NULL; static HFONT hPageHeadingFont = NULL; static HFONT hTextFont = NULL; static HFONT hAuthorFont = NULL; @@ -1019,24 +983,18 @@ DWORD CALLBACK AboutBoxProc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) switch (uMsg) { case WM_INITDIALOG: { - enum { ROUND_EDGE = 15 }; - - DWORD dwStyle = GetWindowLong(hWnd, GWL_STYLE); - dwStyle &= ~(WS_CAPTION | WS_SIZEBOX); - SetWindowLong(hWnd, GWL_STYLE, dwStyle); + //Title + LONG_PTR originalWndProc = GetWindowLongPtrW(hWnd, GWLP_WNDPROC); + SetWindowLongPtrW(hWnd, GWLP_WNDPROC, (LONG_PTR)DefWindowProcW); + SetWindowTextW(hWnd, GS(PLUG_ABOUT)); + SetWindowLongPtrW(hWnd, GWLP_WNDPROC, originalWndProc); // Use the size of the image - hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT_TOP)); - hbmpBackgroundBottom = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT_BOTTOM)); - hbmpBackgroundMiddle = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT_MIDDLE)); + hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT_LOGO)); BITMAP bmTL; GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL); - hCloseButton = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_CLOSE_NORMAL)); - pfnWndAboutBoxCancelProc = (WNDPROC)::GetWindowLongPtr(GetDlgItem(hWnd, IDCANCEL), GWLP_WNDPROC); - ::SetWindowLongPtr(GetDlgItem(hWnd, IDCANCEL), GWLP_WNDPROC, (LONG_PTR)AboutBoxCancelProc); - if (hbmpBackgroundTop) { // int iHeight = bmTL.bmHeight; @@ -1047,13 +1005,6 @@ DWORD CALLBACK AboutBoxProc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) rect.left -= rect.left; rect.bottom -= rect.top; rect.top -= rect.top; - - HRGN hWindowRegion = CreateRoundRectRgn(rect.left, rect.top, rect.left + iWidth + GetSystemMetrics(SM_CXEDGE) - 1, rect.bottom + GetSystemMetrics(SM_CYEDGE) - 1, ROUND_EDGE, ROUND_EDGE); - if (hWindowRegion) - { - SetWindowRgn(hWnd, hWindowRegion, TRUE); - DeleteObject(hWindowRegion); - } } hTextFont = ::CreateFont(18, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial"); @@ -1114,6 +1065,22 @@ DWORD CALLBACK AboutBoxProc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH)); } break; + case WM_ERASEBKGND: + { + HPEN outline; + HBRUSH fill; + RECT rect; + + outline = CreatePen(PS_SOLID, 1, 0x00FFFFFF); + fill = CreateSolidBrush(0x00FFFFFF); + SelectObject((HDC)wParam, outline); + SelectObject((HDC)wParam, fill); + + GetClientRect(hWnd, &rect); + + Rectangle((HDC)wParam, rect.left, rect.top, rect.right, rect.bottom); + } + break; case WM_PAINT: { PAINTSTRUCT ps; @@ -1123,10 +1090,8 @@ DWORD CALLBACK AboutBoxProc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) RECT rcClient; GetClientRect(hWnd, &rcClient); - BITMAP bmTL_top, bmTL_bottom, bmTL_Middle; + BITMAP bmTL_top; GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top); - GetObject(hbmpBackgroundBottom, sizeof(BITMAP), &bmTL_bottom); - GetObject(hbmpBackgroundMiddle, sizeof(BITMAP), &bmTL_Middle); HDC memdc = CreateCompatibleDC(ps.hdc); HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop); @@ -1134,24 +1099,6 @@ DWORD CALLBACK AboutBoxProc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) SelectObject(memdc, save); DeleteDC(memdc); - memdc = CreateCompatibleDC(ps.hdc); - save = SelectObject(memdc, hbmpBackgroundMiddle); - for (int x = bmTL_top.bmHeight; x < rcClient.bottom; x += bmTL_Middle.bmHeight) - { - BitBlt(ps.hdc, 0, x, bmTL_Middle.bmWidth, bmTL_Middle.bmHeight, memdc, 0, 0, SRCCOPY); - } - SelectObject(memdc, save); - DeleteDC(memdc); - - BITMAP; - memdc = CreateCompatibleDC(ps.hdc); - save = SelectObject(memdc, hbmpBackgroundBottom); - BitBlt(ps.hdc, 0, rcClient.bottom - bmTL_bottom.bmHeight, bmTL_bottom.bmWidth, bmTL_bottom.bmHeight, memdc, 0, 0, SRCCOPY); - SelectObject(memdc, save); - DeleteDC(memdc); - - BITMAP; - EndPaint(hWnd, &ps); } } @@ -1165,14 +1112,6 @@ DWORD CALLBACK AboutBoxProc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) { DeleteObject(hbmpBackgroundTop); } - if (hbmpBackgroundBottom) - { - DeleteObject(hbmpBackgroundBottom); - } - if (hbmpBackgroundMiddle) - { - DeleteObject(hbmpBackgroundMiddle); - } if (hTextFont) { ::DeleteObject(hTextFont); diff --git a/Source/Project64/User Interface/UI Resources.rc b/Source/Project64/User Interface/UI Resources.rc index 3c1555d97..27a521eb3 100644 --- a/Source/Project64/User Interface/UI Resources.rc +++ b/Source/Project64/User Interface/UI Resources.rc @@ -383,12 +383,10 @@ BEGIN PUSHBUTTON "OK",IDOK,134,230,47,13 END -IDD_About DIALOGEX 0, 0, 254, 258 -STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME -EXSTYLE WS_EX_RIGHT | WS_EX_RTLREADING | WS_EX_LEFTSCROLLBAR +IDD_About DIALOGEX 0, 0, 233, 265 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - PUSHBUTTON "X",IDCANCEL,211,8,14,13,BS_LEFT,WS_EX_RIGHT | WS_EX_RTLREADING LTEXT "Core Project 64 Team:",IDC_TEAM,15,87,168,17 LTEXT "Zilmar",IDC_ZILMAR,15,108,49,11 LTEXT "founder. Core and application programmer. Web site.",IDC_ZILMAR_DETAILS,69,107,151,24 @@ -889,7 +887,7 @@ END IDB_TRI_STATE BITMAP "Bitmaps\\tri-state.bmp" IDB_LISTITEMS BITMAP "Bitmaps\\ListItems.bmp" -IDB_CLOSE_NORMAL BITMAP "Bitmaps\\CloseNormal.bmp" +IDB_ABOUT_LOGO BITMAP "Bitmaps\\AboutScreenLogo.bmp" IDB_ABOUT_TOP BITMAP "Bitmaps\\AboutScreenTop.bmp" IDB_ABOUT_BOTTOM BITMAP "Bitmaps\\AboutScreenBottom.bmp" IDB_ABOUT_MIDDLE BITMAP "Bitmaps\\AboutScreenMiddle.bmp" diff --git a/Source/Project64/User Interface/resource.h b/Source/Project64/User Interface/resource.h index 42c1d2172..ed3fe6642 100644 --- a/Source/Project64/User Interface/resource.h +++ b/Source/Project64/User Interface/resource.h @@ -34,7 +34,7 @@ #define IDD_Settings_RomBrowser 140 #define IDD_About_UserInfo 141 #define IDD_About_Ini 143 -#define IDB_CLOSE_NORMAL 143 +#define IDB_ABOUT_LOGO 143 #define IDD_Settings_General 144 #define IDB_ABOUT_TOP 144 #define IDD_Settings_Accelerator 145 From d461ff34d98a34478e7e1e20a8a667b15cf4765f Mon Sep 17 00:00:00 2001 From: zilmar Date: Tue, 10 Nov 2015 05:19:39 +1100 Subject: [PATCH 103/213] [Project64] change m_TLBLoadAddress and m_TLBStoreAddress to uint32_t --- Source/Project64/N64 System/N64 Class.h | 4 ++-- Source/Project64/N64 System/System Globals.cpp | 6 ++---- Source/Project64/N64 System/System Globals.h | 7 ++++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Source/Project64/N64 System/N64 Class.h b/Source/Project64/N64 System/N64 Class.h index d7fb18411..bad891662 100644 --- a/Source/Project64/N64 System/N64 Class.h +++ b/Source/Project64/N64 System/N64 Class.h @@ -141,8 +141,8 @@ private: bool m_TestTimer; DWORD m_NextInstruction; DWORD m_JumpToLocation; - DWORD m_TLBLoadAddress; - DWORD m_TLBStoreAddress; + uint32_t m_TLBLoadAddress; + uint32_t m_TLBStoreAddress; DWORD m_SyncCount; bool m_CheatsSlectionChanged; diff --git a/Source/Project64/N64 System/System Globals.cpp b/Source/Project64/N64 System/System Globals.cpp index ea221e17d..0d88ceb51 100644 --- a/Source/Project64/N64 System/System Globals.cpp +++ b/Source/Project64/N64 System/System Globals.cpp @@ -24,10 +24,8 @@ CAudio * g_Audio = NULL; CSystemTimer * g_SystemTimer = NULL; CTransVaddr * g_TransVaddr = NULL; CSystemEvents * g_SystemEvents = NULL; -DWORD * g_TLBLoadAddress = NULL; -DWORD * g_TLBStoreAddress = NULL; +uint32_t * g_TLBLoadAddress = NULL; +uint32_t * g_TLBStoreAddress = NULL; CDebugger * g_Debugger = NULL; int * g_NextTimer; - - diff --git a/Source/Project64/N64 System/System Globals.h b/Source/Project64/N64 System/System Globals.h index 12f993a58..803f8d401 100644 --- a/Source/Project64/N64 System/System Globals.h +++ b/Source/Project64/N64 System/System Globals.h @@ -26,9 +26,10 @@ extern CAudio * g_Audio; extern CSystemTimer * g_SystemTimer; extern CTransVaddr * g_TransVaddr; extern CSystemEvents * g_SystemEvents; -extern int * g_NextTimer; -extern DWORD * g_TLBLoadAddress; -extern DWORD * g_TLBStoreAddress; + +extern int32_t * g_NextTimer; +extern uint32_t * g_TLBLoadAddress; +extern uint32_t * g_TLBStoreAddress; __interface CDebugger; extern CDebugger * g_Debugger; From c33e7e79580ef3b8e17c2aef180481b72c327d91 Mon Sep 17 00:00:00 2001 From: zilmar Date: Tue, 10 Nov 2015 05:39:57 +1100 Subject: [PATCH 104/213] [Project64] Get Reg Info.cpp to use standard types --- .../N64 System/Recompiler/Reg Info.cpp | 2376 +++++++++-------- .../N64 System/Recompiler/Reg Info.h | 272 +- 2 files changed, 1408 insertions(+), 1240 deletions(-) diff --git a/Source/Project64/N64 System/Recompiler/Reg Info.cpp b/Source/Project64/N64 System/Recompiler/Reg Info.cpp index 672e864b9..071e5b530 100644 --- a/Source/Project64/N64 System/Recompiler/Reg Info.cpp +++ b/Source/Project64/N64 System/Recompiler/Reg Info.cpp @@ -15,41 +15,41 @@ unsigned int CRegInfo::m_fpuControl = 0; char *Format_Name[] = {"Unknown","dword","qword","float","double"}; CRegInfo::CRegInfo() : - m_CycleCount(0), - m_Stack_TopPos(0), - m_Fpu_Used(false), - m_RoundingModel(RoundUnknown) + m_CycleCount(0), + m_Stack_TopPos(0), + m_Fpu_Used(false), + m_RoundingModel(RoundUnknown) { - m_MIPS_RegState[0] = STATE_CONST_32_SIGN; - m_MIPS_RegVal[0].DW = 0; - m_RegMapLo[0] = x86_Unknown; - m_RegMapHi[0] = x86_Unknown; - - for (int i = 1; i < 32; i++ ) - { - m_MIPS_RegState[i] = STATE_UNKNOWN; - m_MIPS_RegVal[i].DW = 0; - m_RegMapLo[i] = x86_Unknown; - m_RegMapHi[i] = x86_Unknown; - } - for (int i = 0, n = sizeof(m_x86reg_MappedTo) / sizeof(m_x86reg_MappedTo[0]); i < n; i++ ) - { - m_x86reg_MappedTo[i] = NotMapped; - m_x86reg_Protected[i] = false; - m_x86reg_MapOrder[i] = 0; - } - for (int i = 0, n = sizeof(x86fpu_MappedTo) / sizeof(x86fpu_MappedTo[0]); i < n; i++ ) - { - x86fpu_MappedTo[i] = -1; - x86fpu_State[i] = FPU_Unknown; - x86fpu_StateChanged[i] = false; - x86fpu_RoundingModel[i] = RoundDefault; - } + m_MIPS_RegState[0] = STATE_CONST_32_SIGN; + m_MIPS_RegVal[0].DW = 0; + m_RegMapLo[0] = x86_Unknown; + m_RegMapHi[0] = x86_Unknown; + + for (int32_t i = 1; i < 32; i++ ) + { + m_MIPS_RegState[i] = STATE_UNKNOWN; + m_MIPS_RegVal[i].DW = 0; + m_RegMapLo[i] = x86_Unknown; + m_RegMapHi[i] = x86_Unknown; + } + for (int32_t i = 0, n = sizeof(m_x86reg_MappedTo) / sizeof(m_x86reg_MappedTo[0]); i < n; i++ ) + { + m_x86reg_MappedTo[i] = NotMapped; + m_x86reg_Protected[i] = false; + m_x86reg_MapOrder[i] = 0; + } + for (int32_t i = 0, n = sizeof(m_x86fpu_MappedTo) / sizeof(m_x86fpu_MappedTo[0]); i < n; i++ ) + { + m_x86fpu_MappedTo[i] = -1; + m_x86fpu_State[i] = FPU_Unknown; + m_x86fpu_StateChanged[i] = false; + m_x86fpu_RoundingModel[i] = RoundDefault; + } } CRegInfo::CRegInfo(const CRegInfo& rhs) { - *this = rhs; + *this = rhs; } CRegInfo::~CRegInfo() @@ -58,1233 +58,1397 @@ CRegInfo::~CRegInfo() CRegInfo& CRegInfo::operator=(const CRegInfo& right) { - m_CycleCount = right.m_CycleCount; - m_Stack_TopPos = right.m_Stack_TopPos; - m_Fpu_Used = right.m_Fpu_Used; - m_RoundingModel = right.m_RoundingModel; + m_CycleCount = right.m_CycleCount; + m_Stack_TopPos = right.m_Stack_TopPos; + m_Fpu_Used = right.m_Fpu_Used; + m_RoundingModel = right.m_RoundingModel; - memcpy(&m_MIPS_RegState,&right.m_MIPS_RegState,sizeof(m_MIPS_RegState)); - memcpy(&m_MIPS_RegVal,&right.m_MIPS_RegVal,sizeof(m_MIPS_RegVal)); - memcpy(&m_RegMapLo,&right.m_RegMapLo,sizeof(m_RegMapLo)); - memcpy(&m_RegMapHi,&right.m_RegMapHi,sizeof(m_RegMapHi)); - memcpy(&m_x86reg_MappedTo,&right.m_x86reg_MappedTo,sizeof(m_x86reg_MappedTo)); - memcpy(&m_x86reg_Protected,&right.m_x86reg_Protected,sizeof(m_x86reg_Protected)); - memcpy(&m_x86reg_MapOrder,&right.m_x86reg_MapOrder,sizeof(m_x86reg_MapOrder)); + memcpy(&m_MIPS_RegState,&right.m_MIPS_RegState,sizeof(m_MIPS_RegState)); + memcpy(&m_MIPS_RegVal,&right.m_MIPS_RegVal,sizeof(m_MIPS_RegVal)); + memcpy(&m_RegMapLo,&right.m_RegMapLo,sizeof(m_RegMapLo)); + memcpy(&m_RegMapHi,&right.m_RegMapHi,sizeof(m_RegMapHi)); + memcpy(&m_x86reg_MappedTo,&right.m_x86reg_MappedTo,sizeof(m_x86reg_MappedTo)); + memcpy(&m_x86reg_Protected,&right.m_x86reg_Protected,sizeof(m_x86reg_Protected)); + memcpy(&m_x86reg_MapOrder,&right.m_x86reg_MapOrder,sizeof(m_x86reg_MapOrder)); - memcpy(&x86fpu_MappedTo,&right.x86fpu_MappedTo,sizeof(x86fpu_MappedTo)); - memcpy(&x86fpu_State,&right.x86fpu_State,sizeof(x86fpu_State)); - memcpy(&x86fpu_StateChanged,&right.x86fpu_StateChanged,sizeof(x86fpu_StateChanged)); - memcpy(&x86fpu_RoundingModel,&right.x86fpu_RoundingModel,sizeof(x86fpu_RoundingModel)); + memcpy(&m_x86fpu_MappedTo,&right.m_x86fpu_MappedTo,sizeof(m_x86fpu_MappedTo)); + memcpy(&m_x86fpu_State,&right.m_x86fpu_State,sizeof(m_x86fpu_State)); + memcpy(&m_x86fpu_StateChanged,&right.m_x86fpu_StateChanged,sizeof(m_x86fpu_StateChanged)); + memcpy(&m_x86fpu_RoundingModel,&right.m_x86fpu_RoundingModel,sizeof(m_x86fpu_RoundingModel)); #ifdef _DEBUG - if (*this != right) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + if (*this != right) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } #endif - return *this; + return *this; } bool CRegInfo::operator==(const CRegInfo& right) const { - int count; + int32_t count; - for (count = 0; count < 32; count ++ ) { - if (m_MIPS_RegState[count] != right.m_MIPS_RegState[count]) - { - return false; - } - if (m_MIPS_RegState[count] == STATE_UNKNOWN) - { - continue; - } - if (m_MIPS_RegVal[count].DW != right.m_MIPS_RegVal[count].DW) - { - return false; - } - } - for (count = 0; count < 10; count ++ ) { - if (m_x86reg_MappedTo[count] != right.m_x86reg_MappedTo[count]) { return false; } - if (m_x86reg_Protected[count] != right.m_x86reg_Protected[count]) { return false; } - if (m_x86reg_MapOrder[count] != right.m_x86reg_MapOrder[count]) { return false; } - } - if (m_CycleCount != right.m_CycleCount) { return false; } - if (m_Stack_TopPos != right.m_Stack_TopPos) { return false; } + for (count = 0; count < 32; count ++ ) + { + if (m_MIPS_RegState[count] != right.m_MIPS_RegState[count]) + { + return false; + } + if (m_MIPS_RegState[count] == STATE_UNKNOWN) + { + continue; + } + if (m_MIPS_RegVal[count].DW != right.m_MIPS_RegVal[count].DW) + { + return false; + } + } + for (count = 0; count < 10; count ++ ) + { + if (m_x86reg_MappedTo[count] != right.m_x86reg_MappedTo[count]) { return false; } + if (m_x86reg_Protected[count] != right.m_x86reg_Protected[count]) { return false; } + if (m_x86reg_MapOrder[count] != right.m_x86reg_MapOrder[count]) { return false; } + } + if (m_CycleCount != right.m_CycleCount) { return false; } + if (m_Stack_TopPos != right.m_Stack_TopPos) { return false; } - for (count = 0; count < 8; count ++ ) { - if (x86fpu_MappedTo[count] != right.x86fpu_MappedTo[count]) { return false; } - if (x86fpu_State[count] != right.x86fpu_State[count]) { return false; } - if (x86fpu_RoundingModel[count] != right.x86fpu_RoundingModel[count]) { return false; } - } - if (m_Fpu_Used != right.m_Fpu_Used) { return false; } - if (GetRoundingModel() != right.GetRoundingModel()) { return false; } - return true; + for (count = 0; count < 8; count ++ ) + { + if (m_x86fpu_MappedTo[count] != right.m_x86fpu_MappedTo[count]) { return false; } + if (m_x86fpu_State[count] != right.m_x86fpu_State[count]) { return false; } + if (m_x86fpu_RoundingModel[count] != right.m_x86fpu_RoundingModel[count]) { return false; } + } + if (m_Fpu_Used != right.m_Fpu_Used) { return false; } + if (GetRoundingModel() != right.GetRoundingModel()) { return false; } + return true; } bool CRegInfo::operator!=(const CRegInfo& right) const { - return !(right == *this); + return !(right == *this); } -CRegInfo::REG_STATE CRegInfo::ConstantsType (__int64 Value) +CRegInfo::REG_STATE CRegInfo::ConstantsType (int64_t Value) { - if (((Value >> 32) == -1) && ((Value & 0x80000000) != 0)) { return STATE_CONST_32_SIGN; } - if (((Value >> 32) == 0) && ((Value & 0x80000000) == 0)) { return STATE_CONST_32_SIGN; } - return STATE_CONST_64; + if (((Value >> 32) == -1) && ((Value & 0x80000000) != 0)) { return STATE_CONST_32_SIGN; } + if (((Value >> 32) == 0) && ((Value & 0x80000000) == 0)) { return STATE_CONST_32_SIGN; } + return STATE_CONST_64; } void CRegInfo::FixRoundModel(FPU_ROUND RoundMethod ) { - if (GetRoundingModel() == RoundMethod) - { - return; - } - CPU_Message(" FixRoundModel: CurrentRoundingModel: %s targetRoundModel: %s",RoundingModelName(GetRoundingModel()),RoundingModelName(RoundMethod)); + if (GetRoundingModel() == RoundMethod) + { + return; + } + CPU_Message(" FixRoundModel: CurrentRoundingModel: %s targetRoundModel: %s",RoundingModelName(GetRoundingModel()),RoundingModelName(RoundMethod)); - m_fpuControl = 0; - fpuStoreControl(&m_fpuControl, "m_fpuControl"); - x86Reg reg = Map_TempReg(x86_Any, -1, false); - MoveVariableToX86reg(&m_fpuControl, "m_fpuControl", reg); - AndConstToX86Reg(reg, 0xF3FF); + m_fpuControl = 0; + fpuStoreControl(&m_fpuControl, "m_fpuControl"); + x86Reg reg = Map_TempReg(x86_Any, -1, false); + MoveVariableToX86reg(&m_fpuControl, "m_fpuControl", reg); + AndConstToX86Reg(reg, 0xF3FF); - if (RoundMethod == RoundDefault) + if (RoundMethod == RoundDefault) + { + x86Reg RoundReg = Map_TempReg(x86_Any, -1, false); + MoveVariableToX86reg(&g_Reg->m_RoundingModel,"m_RoundingModel", RoundReg); + ShiftLeftSignImmed(RoundReg,2); + OrX86RegToX86Reg(reg,RoundReg); + SetX86Protected(RoundReg,false); + } + else { - x86Reg RoundReg = Map_TempReg(x86_Any, -1, false); - MoveVariableToX86reg(&g_Reg->m_RoundingModel,"m_RoundingModel", RoundReg); - ShiftLeftSignImmed(RoundReg,2); - OrX86RegToX86Reg(reg,RoundReg); - SetX86Protected(RoundReg,false); - } else { - switch (RoundMethod) { - case RoundTruncate: OrConstToX86Reg(0x0C00, reg); break; - case RoundNearest: /*OrConstToX86Reg(0x0000, reg);*/ break; - case RoundDown: OrConstToX86Reg(0x0400, reg); break; - case RoundUp: OrConstToX86Reg(0x0800, reg); break; - default: - g_Notify->DisplayError(L"Unknown Rounding model"); - } - } - MoveX86regToVariable(reg, &m_fpuControl, "m_fpuControl"); - SetX86Protected(reg,false); - fpuLoadControl(&m_fpuControl, "m_fpuControl"); - SetRoundingModel(RoundMethod); + switch (RoundMethod) + { + case RoundTruncate: OrConstToX86Reg(0x0C00, reg); break; + case RoundNearest: /*OrConstToX86Reg(0x0000, reg);*/ break; + case RoundDown: OrConstToX86Reg(0x0400, reg); break; + case RoundUp: OrConstToX86Reg(0x0800, reg); break; + default: + g_Notify->DisplayError(L"Unknown Rounding model"); + } + } + MoveX86regToVariable(reg, &m_fpuControl, "m_fpuControl"); + SetX86Protected(reg,false); + fpuLoadControl(&m_fpuControl, "m_fpuControl"); + SetRoundingModel(RoundMethod); } -void CRegInfo::ChangeFPURegFormat (int Reg, FPU_STATE OldFormat, FPU_STATE NewFormat, FPU_ROUND RoundingModel) +void CRegInfo::ChangeFPURegFormat (int32_t Reg, FPU_STATE OldFormat, FPU_STATE NewFormat, FPU_ROUND RoundingModel) { - for (DWORD i = 0; i < 8; i++) - { - if (x86fpu_MappedTo[i] != Reg) + for (uint32_t i = 0; i < 8; i++) + { + if (m_x86fpu_MappedTo[i] != Reg) + { + continue; + } + if (m_x86fpu_State[i] != OldFormat || m_x86fpu_StateChanged[i]) + { + UnMap_FPR(Reg, true); + Load_FPR_ToTop(Reg,Reg,OldFormat); + } + else { - continue; - } - if (x86fpu_State[i] != OldFormat || x86fpu_StateChanged[i]) - { - UnMap_FPR(Reg, true); - Load_FPR_ToTop(Reg,Reg,OldFormat); - } else { - CPU_Message(" regcache: Changed format of ST(%d) from %s to %s", (i - StackTopPos() + 8) & 7,Format_Name[OldFormat],Format_Name[NewFormat]); - } - FpuRoundingModel(i) = RoundingModel; - x86fpu_State[i] = NewFormat; - x86fpu_StateChanged[i] = true; - return; - } + CPU_Message(" regcache: Changed format of ST(%d) from %s to %s", (i - StackTopPos() + 8) & 7,Format_Name[OldFormat],Format_Name[NewFormat]); + } + FpuRoundingModel(i) = RoundingModel; + m_x86fpu_State[i] = NewFormat; + m_x86fpu_StateChanged[i] = true; + return; + } - if (bHaveDebugger()) - { - g_Notify->DisplayError(L"ChangeFormat: Register not on stack!!"); - } + if (bHaveDebugger()) + { + g_Notify->DisplayError(L"ChangeFormat: Register not on stack!!"); + } } -void CRegInfo::Load_FPR_ToTop ( int Reg, int RegToLoad, FPU_STATE Format) +void CRegInfo::Load_FPR_ToTop ( int32_t Reg, int32_t RegToLoad, FPU_STATE Format) { - if (GetRoundingModel() != RoundDefault) - { - FixRoundModel(RoundDefault); - } - CPU_Message("CurrentRoundingModel: %s FpuRoundingModel(StackTopPos()): %s",RoundingModelName(GetRoundingModel()),RoundingModelName(FpuRoundingModel(StackTopPos()))); - int i; + if (GetRoundingModel() != RoundDefault) + { + FixRoundModel(RoundDefault); + } + CPU_Message("CurrentRoundingModel: %s FpuRoundingModel(StackTopPos()): %s",RoundingModelName(GetRoundingModel()),RoundingModelName(FpuRoundingModel(StackTopPos()))); + int32_t i; - if (RegToLoad < 0) { g_Notify->DisplayError(L"Load_FPR_ToTop\nRegToLoad < 0 ???"); return; } - if (Reg < 0) { g_Notify->DisplayError(L"Load_FPR_ToTop\nReg < 0 ???"); return; } + if (RegToLoad < 0) { g_Notify->DisplayError(L"Load_FPR_ToTop\nRegToLoad < 0 ???"); return; } + if (Reg < 0) { g_Notify->DisplayError(L"Load_FPR_ToTop\nReg < 0 ???"); return; } - if (Format == FPU_Double || Format == FPU_Qword) { - UnMap_FPR(Reg + 1, true); - UnMap_FPR(RegToLoad + 1, true); - } else { - if ((Reg & 1) != 0) { - for (i = 0; i < 8; i++) { - if (x86fpu_MappedTo[i] == (Reg - 1)) { - if (x86fpu_State[i] == FPU_Double || x86fpu_State[i] == FPU_Qword) { - UnMap_FPR(Reg, true); - } - i = 8; - } - } - } - if ((RegToLoad & 1) != 0) { - for (i = 0; i < 8; i++) { - if (x86fpu_MappedTo[i] == (RegToLoad - 1)) { - if (x86fpu_State[i] == FPU_Double || x86fpu_State[i] == FPU_Qword) { - UnMap_FPR(RegToLoad, true); - } - i = 8; - } - } - } - } + if (Format == FPU_Double || Format == FPU_Qword) + { + UnMap_FPR(Reg + 1, true); + UnMap_FPR(RegToLoad + 1, true); + } + else + { + if ((Reg & 1) != 0) + { + for (i = 0; i < 8; i++) + { + if (m_x86fpu_MappedTo[i] == (Reg - 1)) + { + if (m_x86fpu_State[i] == FPU_Double || m_x86fpu_State[i] == FPU_Qword) + { + UnMap_FPR(Reg, true); + } + i = 8; + } + } + } + if ((RegToLoad & 1) != 0) + { + for (i = 0; i < 8; i++) + { + if (m_x86fpu_MappedTo[i] == (RegToLoad - 1)) + { + if (m_x86fpu_State[i] == FPU_Double || m_x86fpu_State[i] == FPU_Qword) + { + UnMap_FPR(RegToLoad, true); + } + i = 8; + } + } + } + } - if (Reg == RegToLoad) { - //if different format then unmap original reg from stack - for (i = 0; i < 8; i++) { - if (x86fpu_MappedTo[i] != Reg) - { - continue; - } - if (x86fpu_State[i] != Format) { - UnMap_FPR(Reg, true); - } - break; - } - } else { - //if different format then unmap original reg from stack - for (i = 0; i < 8; i++) - { - if (x86fpu_MappedTo[i] != Reg) - { - continue; - } - UnMap_FPR(Reg,x86fpu_State[i] != Format); - break; - } - } + if (Reg == RegToLoad) + { + //if different format then unmap original reg from stack + for (i = 0; i < 8; i++) + { + if (m_x86fpu_MappedTo[i] != Reg) + { + continue; + } + if (m_x86fpu_State[i] != Format) + { + UnMap_FPR(Reg, true); + } + break; + } + } + else + { + //if different format then unmap original reg from stack + for (i = 0; i < 8; i++) + { + if (m_x86fpu_MappedTo[i] != Reg) + { + continue; + } + UnMap_FPR(Reg,m_x86fpu_State[i] != Format); + break; + } + } - if (RegInStack(RegToLoad,Format)) { - if (Reg != RegToLoad) { - if (x86fpu_MappedTo[(StackTopPos() - 1) & 7] != RegToLoad) { - UnMap_FPR(x86fpu_MappedTo[(StackTopPos() - 1) & 7], true); - CPU_Message(" regcache: allocate ST(0) to %s", CRegName::FPR[Reg]); - fpuLoadReg(&StackTopPos(),StackPosition(RegToLoad)); - FpuRoundingModel(StackTopPos()) = RoundDefault; - x86fpu_MappedTo[StackTopPos()] = Reg; - x86fpu_State[StackTopPos()] = Format; - x86fpu_StateChanged[StackTopPos()] = false; - } else { - UnMap_FPR(x86fpu_MappedTo[(StackTopPos() - 1) & 7], true); - Load_FPR_ToTop (Reg, RegToLoad, Format); - } - } else { - x86FpuValues RegPos = x86_ST_Unknown; - for (DWORD i = 0; i < 8; i++) { - if (x86fpu_MappedTo[i] == Reg) { - RegPos = (x86FpuValues)i; - i = 8; - } - } + if (RegInStack(RegToLoad,Format)) + { + if (Reg != RegToLoad) + { + if (m_x86fpu_MappedTo[(StackTopPos() - 1) & 7] != RegToLoad) + { + UnMap_FPR(m_x86fpu_MappedTo[(StackTopPos() - 1) & 7], true); + CPU_Message(" regcache: allocate ST(0) to %s", CRegName::FPR[Reg]); + fpuLoadReg(&StackTopPos(),StackPosition(RegToLoad)); + FpuRoundingModel(StackTopPos()) = RoundDefault; + m_x86fpu_MappedTo[StackTopPos()] = Reg; + m_x86fpu_State[StackTopPos()] = Format; + m_x86fpu_StateChanged[StackTopPos()] = false; + } + else + { + UnMap_FPR(m_x86fpu_MappedTo[(StackTopPos() - 1) & 7], true); + Load_FPR_ToTop (Reg, RegToLoad, Format); + } + } + else + { + x86FpuValues RegPos = x86_ST_Unknown; + for (uint32_t i = 0; i < 8; i++) + { + if (m_x86fpu_MappedTo[i] == Reg) + { + RegPos = (x86FpuValues)i; + i = 8; + } + } - if (RegPos == StackTopPos()) { - return; - } - x86FpuValues StackPos = StackPosition(Reg); + if (RegPos == StackTopPos()) + { + return; + } + x86FpuValues StackPos = StackPosition(Reg); - FpuRoundingModel(RegPos) = FpuRoundingModel(StackTopPos()); - x86fpu_MappedTo[RegPos] = x86fpu_MappedTo[StackTopPos()]; - x86fpu_State[RegPos] = x86fpu_State[StackTopPos()]; - x86fpu_StateChanged[RegPos] = x86fpu_StateChanged[StackTopPos()]; - CPU_Message(" regcache: allocate ST(%d) to %s", StackPos,CRegName::FPR[x86fpu_MappedTo[RegPos]]); - CPU_Message(" regcache: allocate ST(0) to %s", CRegName::FPR[Reg]); + FpuRoundingModel(RegPos) = FpuRoundingModel(StackTopPos()); + m_x86fpu_MappedTo[RegPos] = m_x86fpu_MappedTo[StackTopPos()]; + m_x86fpu_State[RegPos] = m_x86fpu_State[StackTopPos()]; + m_x86fpu_StateChanged[RegPos] = m_x86fpu_StateChanged[StackTopPos()]; + CPU_Message(" regcache: allocate ST(%d) to %s", StackPos,CRegName::FPR[m_x86fpu_MappedTo[RegPos]]); + CPU_Message(" regcache: allocate ST(0) to %s", CRegName::FPR[Reg]); - fpuExchange(StackPos); + fpuExchange(StackPos); - FpuRoundingModel(StackTopPos()) = RoundDefault; - x86fpu_MappedTo[StackTopPos()] = Reg; - x86fpu_State[StackTopPos()] = Format; - x86fpu_StateChanged[StackTopPos()] = false; - } - } else { - char Name[50]; - x86Reg TempReg; + FpuRoundingModel(StackTopPos()) = RoundDefault; + m_x86fpu_MappedTo[StackTopPos()] = Reg; + m_x86fpu_State[StackTopPos()] = Format; + m_x86fpu_StateChanged[StackTopPos()] = false; + } + } + else + { + char Name[50]; + x86Reg TempReg; - UnMap_FPR(x86fpu_MappedTo[(StackTopPos() - 1) & 7], true); - for (i = 0; i < 8; i++) { - if (x86fpu_MappedTo[i] == RegToLoad) { - UnMap_FPR(RegToLoad, true); - i = 8; - } - } - CPU_Message(" regcache: allocate ST(0) to %s", CRegName::FPR[Reg]); - TempReg = Map_TempReg(x86_Any, -1, false); - switch (Format) { - case FPU_Dword: - sprintf(Name,"m_FPR_S[%d]",RegToLoad); - MoveVariableToX86reg(&g_Reg->m_FPR_S[RegToLoad],Name,TempReg); - fpuLoadIntegerDwordFromX86Reg(&StackTopPos(),TempReg); - break; - case FPU_Qword: - sprintf(Name,"m_FPR_D[%d]",RegToLoad); - MoveVariableToX86reg(&g_Reg->m_FPR_D[RegToLoad],Name,TempReg); - fpuLoadIntegerQwordFromX86Reg(&StackTopPos(),TempReg); - break; - case FPU_Float: - sprintf(Name,"m_FPR_S[%d]",RegToLoad); - MoveVariableToX86reg(&g_Reg->m_FPR_S[RegToLoad],Name,TempReg); - fpuLoadDwordFromX86Reg(&StackTopPos(),TempReg); - break; - case FPU_Double: - sprintf(Name,"m_FPR_D[%d]",RegToLoad); - MoveVariableToX86reg(&g_Reg->m_FPR_D[RegToLoad],Name,TempReg); - fpuLoadQwordFromX86Reg(&StackTopPos(),TempReg); - break; - default: - if (bHaveDebugger()) { g_Notify->DisplayError(stdstr_f("Load_FPR_ToTop\nUnkown format to load %d",Format).ToUTF16().c_str()); } - } - SetX86Protected(TempReg, false); - FpuRoundingModel(StackTopPos()) = RoundDefault; - x86fpu_MappedTo[StackTopPos()] = Reg; - x86fpu_State[StackTopPos()] = Format; - x86fpu_StateChanged[StackTopPos()] = false; - } + UnMap_FPR(m_x86fpu_MappedTo[(StackTopPos() - 1) & 7], true); + for (i = 0; i < 8; i++) + { + if (m_x86fpu_MappedTo[i] == RegToLoad) + { + UnMap_FPR(RegToLoad, true); + i = 8; + } + } + CPU_Message(" regcache: allocate ST(0) to %s", CRegName::FPR[Reg]); + TempReg = Map_TempReg(x86_Any, -1, false); + switch (Format) + { + case FPU_Dword: + sprintf(Name,"m_FPR_S[%d]",RegToLoad); + MoveVariableToX86reg(&g_Reg->m_FPR_S[RegToLoad],Name,TempReg); + fpuLoadIntegerDwordFromX86Reg(&StackTopPos(),TempReg); + break; + case FPU_Qword: + sprintf(Name,"m_FPR_D[%d]",RegToLoad); + MoveVariableToX86reg(&g_Reg->m_FPR_D[RegToLoad],Name,TempReg); + fpuLoadIntegerQwordFromX86Reg(&StackTopPos(),TempReg); + break; + case FPU_Float: + sprintf(Name,"m_FPR_S[%d]",RegToLoad); + MoveVariableToX86reg(&g_Reg->m_FPR_S[RegToLoad],Name,TempReg); + fpuLoadDwordFromX86Reg(&StackTopPos(),TempReg); + break; + case FPU_Double: + sprintf(Name,"m_FPR_D[%d]",RegToLoad); + MoveVariableToX86reg(&g_Reg->m_FPR_D[RegToLoad],Name,TempReg); + fpuLoadQwordFromX86Reg(&StackTopPos(),TempReg); + break; + default: + if (bHaveDebugger()) { g_Notify->DisplayError(stdstr_f("Load_FPR_ToTop\nUnkown format to load %d",Format).ToUTF16().c_str()); } + } + SetX86Protected(TempReg, false); + FpuRoundingModel(StackTopPos()) = RoundDefault; + m_x86fpu_MappedTo[StackTopPos()] = Reg; + m_x86fpu_State[StackTopPos()] = Format; + m_x86fpu_StateChanged[StackTopPos()] = false; + } } -CRegInfo::x86FpuValues CRegInfo::StackPosition (int Reg) +CRegInfo::x86FpuValues CRegInfo::StackPosition (int32_t Reg) { - int i; + int32_t i; - for (i = 0; i < 8; i++) { - if (x86fpu_MappedTo[i] == Reg) { - return (x86FpuValues)((i - StackTopPos()) & 7); - } - } - return x86_ST_Unknown; + for (i = 0; i < 8; i++) + { + if (m_x86fpu_MappedTo[i] == Reg) + { + return (x86FpuValues)((i - StackTopPos()) & 7); + } + } + return x86_ST_Unknown; } CX86Ops::x86Reg CRegInfo::FreeX86Reg() { - if (GetX86Mapped(x86_EDI) == NotMapped && !GetX86Protected(x86_EDI)) { return x86_EDI; } - if (GetX86Mapped(x86_ESI) == NotMapped && !GetX86Protected(x86_ESI)) { return x86_ESI; } - if (GetX86Mapped(x86_EBX) == NotMapped && !GetX86Protected(x86_EBX)) { return x86_EBX; } - if (GetX86Mapped(x86_EAX) == NotMapped && !GetX86Protected(x86_EAX)) { return x86_EAX; } - if (GetX86Mapped(x86_EDX) == NotMapped && !GetX86Protected(x86_EDX)) { return x86_EDX; } - if (GetX86Mapped(x86_ECX) == NotMapped && !GetX86Protected(x86_ECX)) { return x86_ECX; } + if (GetX86Mapped(x86_EDI) == NotMapped && !GetX86Protected(x86_EDI)) { return x86_EDI; } + if (GetX86Mapped(x86_ESI) == NotMapped && !GetX86Protected(x86_ESI)) { return x86_ESI; } + if (GetX86Mapped(x86_EBX) == NotMapped && !GetX86Protected(x86_EBX)) { return x86_EBX; } + if (GetX86Mapped(x86_EAX) == NotMapped && !GetX86Protected(x86_EAX)) { return x86_EAX; } + if (GetX86Mapped(x86_EDX) == NotMapped && !GetX86Protected(x86_EDX)) { return x86_EDX; } + if (GetX86Mapped(x86_ECX) == NotMapped && !GetX86Protected(x86_ECX)) { return x86_ECX; } - x86Reg Reg = UnMap_TempReg(); - if (Reg != x86_Unknown) { return Reg; } + x86Reg Reg = UnMap_TempReg(); + if (Reg != x86_Unknown) { return Reg; } - int count, MapCount[10]; - x86Reg MapReg[10]; + int32_t count, MapCount[10]; + x86Reg MapReg[10]; - for (count = 0; count < 10; count ++) - { - MapCount[count] = GetX86MapOrder((x86Reg)count); - MapReg[count] = (x86Reg)count; - } - for (count = 0; count < 10; count ++) { - int i; - - for (i = 0; i < 9; i ++) { - x86Reg tempReg; - DWORD temp; + for (count = 0; count < 10; count ++) + { + MapCount[count] = GetX86MapOrder((x86Reg)count); + MapReg[count] = (x86Reg)count; + } + for (count = 0; count < 10; count ++) + { + int32_t i; - if (MapCount[i] < MapCount[i+1]) { - temp = MapCount[i]; - MapCount[i] = MapCount[i+1]; - MapCount[i+1] = temp; - tempReg = MapReg[i]; - MapReg[i] = MapReg[i+1]; - MapReg[i+1] = tempReg; - } - } + for (i = 0; i < 9; i ++) + { + x86Reg tempReg; + uint32_t temp; - } + if (MapCount[i] < MapCount[i+1]) + { + temp = MapCount[i]; + MapCount[i] = MapCount[i+1]; + MapCount[i+1] = temp; + tempReg = MapReg[i]; + MapReg[i] = MapReg[i+1]; + MapReg[i+1] = tempReg; + } + } + } - x86Reg StackReg = x86_Unknown; - for (count = 0; count < 10; count ++) - { - if (MapCount[count] > 0 && GetX86Mapped(MapReg[count]) != Stack_Mapped) - { - if (UnMap_X86reg((x86Reg)MapReg[count])) - { - return (x86Reg)MapReg[count]; - } - } - if (GetX86Mapped(MapReg[count]) == Stack_Mapped) { StackReg = MapReg[count]; } - } - if (StackReg != x86_Unknown) { - UnMap_X86reg(StackReg); - return StackReg; - } + x86Reg StackReg = x86_Unknown; + for (count = 0; count < 10; count ++) + { + if (MapCount[count] > 0 && GetX86Mapped(MapReg[count]) != Stack_Mapped) + { + if (UnMap_X86reg((x86Reg)MapReg[count])) + { + return (x86Reg)MapReg[count]; + } + } + if (GetX86Mapped(MapReg[count]) == Stack_Mapped) { StackReg = MapReg[count]; } + } + if (StackReg != x86_Unknown) + { + UnMap_X86reg(StackReg); + return StackReg; + } - return x86_Unknown; + return x86_Unknown; } CX86Ops::x86Reg CRegInfo::Free8BitX86Reg() { - - if (GetX86Mapped(x86_EBX) == NotMapped && !GetX86Protected(x86_EBX)) {return x86_EBX; } - if (GetX86Mapped(x86_EAX) == NotMapped && !GetX86Protected(x86_EAX)) {return x86_EAX; } - if (GetX86Mapped(x86_EDX) == NotMapped && !GetX86Protected(x86_EDX)) {return x86_EDX; } - if (GetX86Mapped(x86_ECX) == NotMapped && !GetX86Protected(x86_ECX)) {return x86_ECX; } + if (GetX86Mapped(x86_EBX) == NotMapped && !GetX86Protected(x86_EBX)) {return x86_EBX; } + if (GetX86Mapped(x86_EAX) == NotMapped && !GetX86Protected(x86_EAX)) {return x86_EAX; } + if (GetX86Mapped(x86_EDX) == NotMapped && !GetX86Protected(x86_EDX)) {return x86_EDX; } + if (GetX86Mapped(x86_ECX) == NotMapped && !GetX86Protected(x86_ECX)) {return x86_ECX; } - - x86Reg Reg = UnMap_8BitTempReg(); - if (Reg > 0) { return Reg; } - - int count, MapCount[10], MapReg[10]; - for (count = 0; count < 10; count ++) { - MapCount[count] = GetX86MapOrder((x86Reg)count); - MapReg[count] = count; + x86Reg Reg = UnMap_8BitTempReg(); + if (Reg > 0) + { + return Reg; } - for (count = 0; count < 10; count ++) { - int i; - - for (i = 0; i < 9; i ++) { - int temp; - if (MapCount[i] < MapCount[i+1]) { - temp = MapCount[i]; - MapCount[i] = MapCount[i+1]; - MapCount[i+1] = temp; - temp = MapReg[i]; - MapReg[i] = MapReg[i+1]; - MapReg[i+1] = temp; - } - } + int32_t count, MapCount[10], MapReg[10]; + for (count = 0; count < 10; count ++) + { + MapCount[count] = GetX86MapOrder((x86Reg)count); + MapReg[count] = count; + } + for (count = 0; count < 10; count ++) + { + int32_t i; - } - for (count = 0; count < 10; count ++) { - if (MapCount[count] > 0) { - if (!Is8BitReg((x86Reg)count)) { continue; } - if (UnMap_X86reg((x86Reg)count)) { - return (x86Reg)count; - } - } - } - return x86_Unknown; + for (i = 0; i < 9; i ++) + { + int32_t temp; + + if (MapCount[i] < MapCount[i+1]) + { + temp = MapCount[i]; + MapCount[i] = MapCount[i+1]; + MapCount[i+1] = temp; + temp = MapReg[i]; + MapReg[i] = MapReg[i+1]; + MapReg[i+1] = temp; + } + } + } + for (count = 0; count < 10; count ++) + { + if (MapCount[count] > 0) + { + if (!Is8BitReg((x86Reg)count)) { continue; } + if (UnMap_X86reg((x86Reg)count)) + { + return (x86Reg)count; + } + } + } + return x86_Unknown; } CX86Ops::x86Reg CRegInfo::UnMap_8BitTempReg() { - int count; + int32_t count; - for (count = 0; count < 10; count ++) { - if (!Is8BitReg((x86Reg)count)) { continue; } - if (GetMipsRegState((x86Reg)count) == Temp_Mapped) { - if (GetX86Protected((x86Reg)count) == false) { - CPU_Message(" regcache: unallocate %s from temp storage",x86_Name((x86Reg)count)); - SetX86Mapped((x86Reg)count, CRegInfo::NotMapped); - return (x86Reg)count; - } - } - } - return x86_Unknown; + for (count = 0; count < 10; count ++) + { + if (!Is8BitReg((x86Reg)count)) { continue; } + if (GetMipsRegState((x86Reg)count) == Temp_Mapped) + { + if (GetX86Protected((x86Reg)count) == false) + { + CPU_Message(" regcache: unallocate %s from temp storage",x86_Name((x86Reg)count)); + SetX86Mapped((x86Reg)count, CRegInfo::NotMapped); + return (x86Reg)count; + } + } + } + return x86_Unknown; } CRegInfo::x86Reg CRegInfo::Get_MemoryStack() const { - for (int i = 0, n = sizeof(x86_Registers)/ sizeof(x86_Registers[0]); i < n; i++) - { - if (GetX86Mapped(x86_Registers[i]) == Stack_Mapped) - { - return x86_Registers[i]; - } - } - return x86_Unknown; + for (int32_t i = 0, n = sizeof(x86_Registers)/ sizeof(x86_Registers[0]); i < n; i++) + { + if (GetX86Mapped(x86_Registers[i]) == Stack_Mapped) + { + return x86_Registers[i]; + } + } + return x86_Unknown; } CRegInfo::x86Reg CRegInfo::Map_MemoryStack ( x86Reg Reg, bool bMapRegister, bool LoadValue) { - x86Reg CurrentMap = Get_MemoryStack(); - if (!bMapRegister) - { - //if not mapping then just return what the current mapping is - return CurrentMap; - } - - if (CurrentMap != x86_Unknown && CurrentMap == Reg) - { - //already mapped to correct reg - return CurrentMap; - } - // map a register - if (Reg == x86_Any) - { - if (CurrentMap != x86_Unknown) - { - return CurrentMap; - } - Reg = FreeX86Reg(); - if (Reg == x86_Unknown) - { - g_Notify->DisplayError(L"Map_MemoryStack\n\nOut of registers"); - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - SetX86Mapped(Reg,CRegInfo::Stack_Mapped); - CPU_Message(" regcache: allocate %s as Memory Stack",x86_Name(Reg)); - if (LoadValue) - { - MoveVariableToX86reg(&g_Recompiler->MemoryStackPos(),"MemoryStack",Reg); - } - return Reg; - } + x86Reg CurrentMap = Get_MemoryStack(); + if (!bMapRegister) + { + //if not mapping then just return what the current mapping is + return CurrentMap; + } - //move to a register/allocate register - UnMap_X86reg(Reg); - if (CurrentMap != x86_Unknown) + if (CurrentMap != x86_Unknown && CurrentMap == Reg) + { + //already mapped to correct reg + return CurrentMap; + } + // map a register + if (Reg == x86_Any) + { + if (CurrentMap != x86_Unknown) + { + return CurrentMap; + } + Reg = FreeX86Reg(); + if (Reg == x86_Unknown) + { + g_Notify->DisplayError(L"Map_MemoryStack\n\nOut of registers"); + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + SetX86Mapped(Reg,CRegInfo::Stack_Mapped); + CPU_Message(" regcache: allocate %s as Memory Stack",x86_Name(Reg)); + if (LoadValue) + { + MoveVariableToX86reg(&g_Recompiler->MemoryStackPos(),"MemoryStack",Reg); + } + return Reg; + } + + //move to a register/allocate register + UnMap_X86reg(Reg); + if (CurrentMap != x86_Unknown) + { + CPU_Message(" regcache: change allocation of Memory Stack from %s to %s",x86_Name(CurrentMap),x86_Name(Reg)); + SetX86Mapped(Reg, CRegInfo::Stack_Mapped); + SetX86Mapped(CurrentMap,CRegInfo::NotMapped); + MoveX86RegToX86Reg(CurrentMap,Reg); + } + else { - CPU_Message(" regcache: change allocation of Memory Stack from %s to %s",x86_Name(CurrentMap),x86_Name(Reg)); - SetX86Mapped(Reg, CRegInfo::Stack_Mapped); - SetX86Mapped(CurrentMap,CRegInfo::NotMapped); - MoveX86RegToX86Reg(CurrentMap,Reg); - } else { - SetX86Mapped(Reg,CRegInfo::Stack_Mapped); - CPU_Message(" regcache: allocate %s as Memory Stack",x86_Name(Reg)); - if (LoadValue) - { - MoveVariableToX86reg(&g_Recompiler->MemoryStackPos(),"MemoryStack",Reg); - } - } - return Reg; + SetX86Mapped(Reg,CRegInfo::Stack_Mapped); + CPU_Message(" regcache: allocate %s as Memory Stack",x86_Name(Reg)); + if (LoadValue) + { + MoveVariableToX86reg(&g_Recompiler->MemoryStackPos(),"MemoryStack",Reg); + } + } + return Reg; } -void CRegInfo::Map_GPR_32bit (int MipsReg, bool SignValue, int MipsRegToLoad) +void CRegInfo::Map_GPR_32bit (int32_t MipsReg, bool SignValue, int32_t MipsRegToLoad) { - int count; + int32_t count; - x86Reg Reg; - if (MipsReg == 0) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - return; - } + x86Reg Reg; + if (MipsReg == 0) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + return; + } - if (IsUnknown(MipsReg) || IsConst(MipsReg)) - { - Reg = FreeX86Reg(); - if (Reg < 0) { - if (bHaveDebugger()) { g_Notify->DisplayError(L"Map_GPR_32bit\n\nOut of registers"); } - g_Notify->BreakPoint(__FILEW__,__LINE__); - return; - } - CPU_Message(" regcache: allocate %s to %s",x86_Name(Reg),CRegName::GPR[MipsReg]); - } else { - if (Is64Bit(MipsReg)) + if (IsUnknown(MipsReg) || IsConst(MipsReg)) + { + Reg = FreeX86Reg(); + if (Reg < 0) + { + if (bHaveDebugger()) { g_Notify->DisplayError(L"Map_GPR_32bit\n\nOut of registers"); } + g_Notify->BreakPoint(__FILEW__,__LINE__); + return; + } + CPU_Message(" regcache: allocate %s to %s",x86_Name(Reg),CRegName::GPR[MipsReg]); + } + else + { + if (Is64Bit(MipsReg)) + { + CPU_Message(" regcache: unallocate %s from high 32bit of %s",x86_Name(GetMipsRegMapHi(MipsReg)),CRegName::GPR_Hi[MipsReg]); + SetX86MapOrder(GetMipsRegMapHi(MipsReg),0); + SetX86Mapped(GetMipsRegMapHi(MipsReg),NotMapped); + SetX86Protected(GetMipsRegMapHi(MipsReg), false); + SetMipsRegHi(MipsReg,0); + } + Reg = GetMipsRegMapLo(MipsReg); + } + for (count = 0; count < 10; count ++) + { + uint32_t Count = GetX86MapOrder((x86Reg)count); + if ( Count > 0) + { + SetX86MapOrder((x86Reg)count,Count + 1); + } + } + SetX86MapOrder(Reg,1); + + if (MipsRegToLoad > 0) + { + if (IsUnknown(MipsRegToLoad)) + { + MoveVariableToX86reg(&_GPR[MipsRegToLoad].UW[0],CRegName::GPR_Lo[MipsRegToLoad],Reg); + } + else if (IsMapped(MipsRegToLoad)) + { + if (MipsReg != MipsRegToLoad) + { + MoveX86RegToX86Reg(GetMipsRegMapLo(MipsRegToLoad),Reg); + } + } + else { - CPU_Message(" regcache: unallocate %s from high 32bit of %s",x86_Name(GetMipsRegMapHi(MipsReg)),CRegName::GPR_Hi[MipsReg]); - SetX86MapOrder(GetMipsRegMapHi(MipsReg),0); - SetX86Mapped(GetMipsRegMapHi(MipsReg),NotMapped); - SetX86Protected(GetMipsRegMapHi(MipsReg), false); - SetMipsRegHi(MipsReg,0); - } - Reg = GetMipsRegMapLo(MipsReg); - } - for (count = 0; count < 10; count ++) - { - DWORD Count = GetX86MapOrder((x86Reg)count); - if ( Count > 0) - { - SetX86MapOrder((x86Reg)count,Count + 1); - } - } - SetX86MapOrder(Reg,1); - - if (MipsRegToLoad > 0) - { - if (IsUnknown(MipsRegToLoad)) - { - MoveVariableToX86reg(&_GPR[MipsRegToLoad].UW[0],CRegName::GPR_Lo[MipsRegToLoad],Reg); - } else if (IsMapped(MipsRegToLoad)) { - if (MipsReg != MipsRegToLoad) - { - MoveX86RegToX86Reg(GetMipsRegMapLo(MipsRegToLoad),Reg); - } - } else { - MoveConstToX86reg(GetMipsRegLo(MipsRegToLoad),Reg); - } - } else if (MipsRegToLoad == 0) { - XorX86RegToX86Reg(Reg,Reg); - } - SetX86Mapped(Reg,GPR_Mapped); - SetX86Protected(Reg, true); - SetMipsRegMapLo(MipsReg,Reg); - SetMipsRegState(MipsReg,SignValue ? STATE_MAPPED_32_SIGN : STATE_MAPPED_32_ZERO); + MoveConstToX86reg(GetMipsRegLo(MipsRegToLoad),Reg); + } + } + else if (MipsRegToLoad == 0) + { + XorX86RegToX86Reg(Reg,Reg); + } + SetX86Mapped(Reg,GPR_Mapped); + SetX86Protected(Reg, true); + SetMipsRegMapLo(MipsReg,Reg); + SetMipsRegState(MipsReg,SignValue ? STATE_MAPPED_32_SIGN : STATE_MAPPED_32_ZERO); } -void CRegInfo::Map_GPR_64bit ( int MipsReg, int MipsRegToLoad) +void CRegInfo::Map_GPR_64bit ( int32_t MipsReg, int32_t MipsRegToLoad) { - x86Reg x86Hi, x86lo; - int count; + x86Reg x86Hi, x86lo; + int32_t count; - if (MipsReg == 0) { - if (bHaveDebugger()) { g_Notify->DisplayError(L"Map_GPR_32bit\n\nWhy are you trying to map reg 0"); } - return; - } + if (MipsReg == 0) + { + if (bHaveDebugger()) { g_Notify->DisplayError(L"Map_GPR_32bit\n\nWhy are you trying to map reg 0"); } + return; + } - ProtectGPR(MipsReg); - if (IsUnknown(MipsReg) || IsConst(MipsReg)) { - x86Hi = FreeX86Reg(); - if (x86Hi < 0) - { - if (bHaveDebugger()) { g_Notify->DisplayError(L"Map_GPR_64bit\n\nOut of registers"); } - return; - } - SetX86Protected(x86Hi, true); + ProtectGPR(MipsReg); + if (IsUnknown(MipsReg) || IsConst(MipsReg)) + { + x86Hi = FreeX86Reg(); + if (x86Hi < 0) + { + if (bHaveDebugger()) { g_Notify->DisplayError(L"Map_GPR_64bit\n\nOut of registers"); } + return; + } + SetX86Protected(x86Hi, true); - x86lo = FreeX86Reg(); - if (x86lo < 0) { g_Notify->DisplayError(L"Map_GPR_64bit\n\nOut of registers"); return; } - SetX86Protected(x86lo, true); - - CPU_Message(" regcache: allocate %s to hi word of %s",x86_Name(x86Hi),CRegName::GPR[MipsReg]); - CPU_Message(" regcache: allocate %s to low word of %s",x86_Name(x86lo),CRegName::GPR[MipsReg]); - } else { - x86lo = GetMipsRegMapLo(MipsReg); - if (Is32Bit(MipsReg)) { - SetX86Protected(x86lo, true); - x86Hi = FreeX86Reg(); - if (x86Hi == x86_Unknown) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - return; - } - SetX86Protected(x86Hi, true); + x86lo = FreeX86Reg(); + if (x86lo < 0) { g_Notify->DisplayError(L"Map_GPR_64bit\n\nOut of registers"); return; } + SetX86Protected(x86lo, true); - CPU_Message(" regcache: allocate %s to hi word of %s",x86_Name(x86Hi),CRegName::GPR[MipsReg]); - } else { - x86Hi = GetMipsRegMapHi(MipsReg); - } - } - - for (count = 0; count < 10; count ++) - { - int MapOrder = GetX86MapOrder((x86Reg)count); - if (MapOrder > 0) - { - SetX86MapOrder((x86Reg)count,MapOrder + 1); - } - } - - SetX86MapOrder(x86Hi,1); - SetX86MapOrder(x86lo,1); - if (MipsRegToLoad > 0) { - if (IsUnknown(MipsRegToLoad)) { - MoveVariableToX86reg(&_GPR[MipsRegToLoad].UW[1],CRegName::GPR_Hi[MipsRegToLoad],x86Hi); - MoveVariableToX86reg(&_GPR[MipsRegToLoad].UW[0],CRegName::GPR_Lo[MipsRegToLoad],x86lo); - } else if (IsMapped(MipsRegToLoad)) { - if (Is32Bit(MipsRegToLoad)) { - if (IsSigned(MipsRegToLoad)) { - MoveX86RegToX86Reg(GetMipsRegMapLo(MipsRegToLoad),x86Hi); - ShiftRightSignImmed(x86Hi,31); - } else { - XorX86RegToX86Reg(x86Hi,x86Hi); - } - if (MipsReg != MipsRegToLoad) { - MoveX86RegToX86Reg(GetMipsRegMapLo(MipsRegToLoad),x86lo); - } - } else { - if (MipsReg != MipsRegToLoad) { - MoveX86RegToX86Reg(GetMipsRegMapHi(MipsRegToLoad),x86Hi); - MoveX86RegToX86Reg(GetMipsRegMapLo(MipsRegToLoad),x86lo); - } - } - } else { -CPU_Message("Map_GPR_64bit 11"); - if (Is32Bit(MipsRegToLoad)) { - if (IsSigned(MipsRegToLoad)) { - MoveConstToX86reg(GetMipsRegLo_S(MipsRegToLoad) >> 31,x86Hi); - } else { - MoveConstToX86reg(0,x86Hi); - } - } else { - MoveConstToX86reg(GetMipsRegHi(MipsRegToLoad),x86Hi); - } - MoveConstToX86reg(GetMipsRegLo(MipsRegToLoad),x86lo); - } - } else if (MipsRegToLoad == 0) { - XorX86RegToX86Reg(x86Hi,x86Hi); - XorX86RegToX86Reg(x86lo,x86lo); - } - SetX86Mapped(x86Hi,GPR_Mapped); - SetX86Mapped(x86lo,GPR_Mapped); - SetMipsRegMapHi(MipsReg,x86Hi); - SetMipsRegMapLo(MipsReg,x86lo); - SetMipsRegState(MipsReg,STATE_MAPPED_64); + CPU_Message(" regcache: allocate %s to hi word of %s",x86_Name(x86Hi),CRegName::GPR[MipsReg]); + CPU_Message(" regcache: allocate %s to low word of %s",x86_Name(x86lo),CRegName::GPR[MipsReg]); + } + else + { + x86lo = GetMipsRegMapLo(MipsReg); + if (Is32Bit(MipsReg)) + { + SetX86Protected(x86lo, true); + x86Hi = FreeX86Reg(); + if (x86Hi == x86_Unknown) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + return; + } + SetX86Protected(x86Hi, true); + + CPU_Message(" regcache: allocate %s to hi word of %s",x86_Name(x86Hi),CRegName::GPR[MipsReg]); + } + else + { + x86Hi = GetMipsRegMapHi(MipsReg); + } + } + + for (count = 0; count < 10; count ++) + { + int32_t MapOrder = GetX86MapOrder((x86Reg)count); + if (MapOrder > 0) + { + SetX86MapOrder((x86Reg)count,MapOrder + 1); + } + } + + SetX86MapOrder(x86Hi,1); + SetX86MapOrder(x86lo,1); + if (MipsRegToLoad > 0) + { + if (IsUnknown(MipsRegToLoad)) + { + MoveVariableToX86reg(&_GPR[MipsRegToLoad].UW[1],CRegName::GPR_Hi[MipsRegToLoad],x86Hi); + MoveVariableToX86reg(&_GPR[MipsRegToLoad].UW[0],CRegName::GPR_Lo[MipsRegToLoad],x86lo); + } + else if (IsMapped(MipsRegToLoad)) + { + if (Is32Bit(MipsRegToLoad)) + { + if (IsSigned(MipsRegToLoad)) + { + MoveX86RegToX86Reg(GetMipsRegMapLo(MipsRegToLoad),x86Hi); + ShiftRightSignImmed(x86Hi,31); + } + else + { + XorX86RegToX86Reg(x86Hi,x86Hi); + } + if (MipsReg != MipsRegToLoad) + { + MoveX86RegToX86Reg(GetMipsRegMapLo(MipsRegToLoad),x86lo); + } + } + else + { + if (MipsReg != MipsRegToLoad) + { + MoveX86RegToX86Reg(GetMipsRegMapHi(MipsRegToLoad),x86Hi); + MoveX86RegToX86Reg(GetMipsRegMapLo(MipsRegToLoad),x86lo); + } + } + } + else + { + CPU_Message("Map_GPR_64bit 11"); + if (Is32Bit(MipsRegToLoad)) + { + if (IsSigned(MipsRegToLoad)) + { + MoveConstToX86reg(GetMipsRegLo_S(MipsRegToLoad) >> 31,x86Hi); + } + else + { + MoveConstToX86reg(0,x86Hi); + } + } + else + { + MoveConstToX86reg(GetMipsRegHi(MipsRegToLoad),x86Hi); + } + MoveConstToX86reg(GetMipsRegLo(MipsRegToLoad),x86lo); + } + } + else if (MipsRegToLoad == 0) + { + XorX86RegToX86Reg(x86Hi,x86Hi); + XorX86RegToX86Reg(x86lo,x86lo); + } + SetX86Mapped(x86Hi,GPR_Mapped); + SetX86Mapped(x86lo,GPR_Mapped); + SetMipsRegMapHi(MipsReg,x86Hi); + SetMipsRegMapLo(MipsReg,x86lo); + SetMipsRegState(MipsReg,STATE_MAPPED_64); } -CX86Ops::x86Reg CRegInfo::Map_TempReg (CX86Ops::x86Reg Reg, int MipsReg, bool LoadHiWord) +CX86Ops::x86Reg CRegInfo::Map_TempReg (CX86Ops::x86Reg Reg, int32_t MipsReg, bool LoadHiWord) { - int count; + int32_t count; - if (Reg == x86_Any) - { - if (GetX86Mapped(x86_EAX) == Temp_Mapped && !GetX86Protected(x86_EAX)) { Reg = x86_EAX; } - else if (GetX86Mapped(x86_EBX) == Temp_Mapped && !GetX86Protected(x86_EBX)) { Reg = x86_EBX; } - else if (GetX86Mapped(x86_ECX) == Temp_Mapped && !GetX86Protected(x86_ECX)) { Reg = x86_ECX; } - else if (GetX86Mapped(x86_EDX) == Temp_Mapped && !GetX86Protected(x86_EDX)) { Reg = x86_EDX; } - else if (GetX86Mapped(x86_ESI) == Temp_Mapped && !GetX86Protected(x86_ESI)) { Reg = x86_ESI; } - else if (GetX86Mapped(x86_EDI) == Temp_Mapped && !GetX86Protected(x86_EDI)) { Reg = x86_EDI; } - else if (GetX86Mapped(x86_EBP) == Temp_Mapped && !GetX86Protected(x86_EBP)) { Reg = x86_EBP; } - else if (GetX86Mapped(x86_ESP) == Temp_Mapped && !GetX86Protected(x86_ESP)) { Reg = x86_ESP; } + if (Reg == x86_Any) + { + if (GetX86Mapped(x86_EAX) == Temp_Mapped && !GetX86Protected(x86_EAX)) { Reg = x86_EAX; } + else if (GetX86Mapped(x86_EBX) == Temp_Mapped && !GetX86Protected(x86_EBX)) { Reg = x86_EBX; } + else if (GetX86Mapped(x86_ECX) == Temp_Mapped && !GetX86Protected(x86_ECX)) { Reg = x86_ECX; } + else if (GetX86Mapped(x86_EDX) == Temp_Mapped && !GetX86Protected(x86_EDX)) { Reg = x86_EDX; } + else if (GetX86Mapped(x86_ESI) == Temp_Mapped && !GetX86Protected(x86_ESI)) { Reg = x86_ESI; } + else if (GetX86Mapped(x86_EDI) == Temp_Mapped && !GetX86Protected(x86_EDI)) { Reg = x86_EDI; } + else if (GetX86Mapped(x86_EBP) == Temp_Mapped && !GetX86Protected(x86_EBP)) { Reg = x86_EBP; } + else if (GetX86Mapped(x86_ESP) == Temp_Mapped && !GetX86Protected(x86_ESP)) { Reg = x86_ESP; } - if (Reg == x86_Any) { - Reg = FreeX86Reg(); - if (Reg == x86_Unknown) - { - WriteTrace(TraceError,__FUNCTION__ ": Failed to find a free register"); - g_Notify->BreakPoint(__FILEW__,__LINE__); - return x86_Unknown; - } - } - } - else if (Reg == x86_Any8Bit) - { - if (GetX86Mapped(x86_EAX) == Temp_Mapped && !GetX86Protected(x86_EAX)) { Reg = x86_EAX; } - else if (GetX86Mapped(x86_EBX) == Temp_Mapped && !GetX86Protected(x86_EBX)) { Reg = x86_EBX; } - else if (GetX86Mapped(x86_ECX) == Temp_Mapped && !GetX86Protected(x86_ECX)) { Reg = x86_ECX; } - else if (GetX86Mapped(x86_EDX) == Temp_Mapped && !GetX86Protected(x86_EDX)) { Reg = x86_EDX; } - - if (Reg == x86_Any8Bit) - { - Reg = Free8BitX86Reg(); - if (Reg < 0) { - WriteTrace(TraceError,__FUNCTION__ ": Failed to find a free 8 bit register"); - g_Notify->BreakPoint(__FILEW__,__LINE__); - return x86_Unknown; - } - } - } else if (GetX86Mapped(Reg) == GPR_Mapped) { - if (GetX86Protected(Reg)) - { - WriteTrace(TraceError,__FUNCTION__ ": Register is protected"); - g_Notify->BreakPoint(__FILEW__,__LINE__); - return x86_Unknown; - } - - SetX86Protected(Reg,true); - x86Reg NewReg = FreeX86Reg(); - for (count = 1; count < 32; count ++) - { - if (!IsMapped(count)) - { - continue; - } - if (GetMipsRegMapLo(count) == Reg) - { - if (NewReg == x86_Unknown) - { - UnMap_GPR(count, true); - break; - } - CPU_Message(" regcache: change allocation of %s from %s to %s",CRegName::GPR[count],x86_Name(Reg),x86_Name(NewReg)); - SetX86Mapped(NewReg,GPR_Mapped); - SetX86MapOrder(NewReg,GetX86MapOrder(Reg)); - SetMipsRegMapLo(count,NewReg); - MoveX86RegToX86Reg(Reg,NewReg); - if (MipsReg == count && !LoadHiWord) - MipsReg = -1; - break; - } - if (Is64Bit(count) && GetMipsRegMapHi(count) == Reg) - { - if (NewReg == x86_Unknown) - { - UnMap_GPR(count, true); - break; - } - CPU_Message(" regcache: change allocation of %s from %s to %s",CRegName::GPR_Hi[count],x86_Name(Reg),x86_Name(NewReg)); - SetX86Mapped(NewReg,GPR_Mapped); - SetX86MapOrder(NewReg,GetX86MapOrder(Reg)); - SetMipsRegMapHi(count,NewReg); - MoveX86RegToX86Reg(Reg,NewReg); - if (MipsReg == count && LoadHiWord) - MipsReg = -1; - break; - } - } - } - else if (GetX86Mapped(Reg) == Stack_Mapped) - { - UnMap_X86reg(Reg); - } - CPU_Message(" regcache: allocate %s as temp storage",x86_Name(Reg)); + if (Reg == x86_Any) + { + Reg = FreeX86Reg(); + if (Reg == x86_Unknown) + { + WriteTrace(TraceError,__FUNCTION__ ": Failed to find a free register"); + g_Notify->BreakPoint(__FILEW__,__LINE__); + return x86_Unknown; + } + } + } + else if (Reg == x86_Any8Bit) + { + if (GetX86Mapped(x86_EAX) == Temp_Mapped && !GetX86Protected(x86_EAX)) { Reg = x86_EAX; } + else if (GetX86Mapped(x86_EBX) == Temp_Mapped && !GetX86Protected(x86_EBX)) { Reg = x86_EBX; } + else if (GetX86Mapped(x86_ECX) == Temp_Mapped && !GetX86Protected(x86_ECX)) { Reg = x86_ECX; } + else if (GetX86Mapped(x86_EDX) == Temp_Mapped && !GetX86Protected(x86_EDX)) { Reg = x86_EDX; } - if (MipsReg >= 0) { - if (LoadHiWord) { - if (IsUnknown(MipsReg)) - { - MoveVariableToX86reg(&_GPR[MipsReg].UW[1],CRegName::GPR_Hi[MipsReg],Reg); - } - else if (IsMapped(MipsReg)) - { - if (Is64Bit(MipsReg)) { - MoveX86RegToX86Reg(GetMipsRegMapHi(MipsReg),Reg); - } else if (IsSigned(MipsReg)){ - MoveX86RegToX86Reg(GetMipsRegMapLo(MipsReg),Reg); - ShiftRightSignImmed(Reg,31); - } else { - MoveConstToX86reg(0,Reg); - } - } else { - if (Is64Bit(MipsReg)) + if (Reg == x86_Any8Bit) + { + Reg = Free8BitX86Reg(); + if (Reg < 0) + { + WriteTrace(TraceError,__FUNCTION__ ": Failed to find a free 8 bit register"); + g_Notify->BreakPoint(__FILEW__,__LINE__); + return x86_Unknown; + } + } + } + else if (GetX86Mapped(Reg) == GPR_Mapped) + { + if (GetX86Protected(Reg)) + { + WriteTrace(TraceError,__FUNCTION__ ": Register is protected"); + g_Notify->BreakPoint(__FILEW__,__LINE__); + return x86_Unknown; + } + + SetX86Protected(Reg,true); + x86Reg NewReg = FreeX86Reg(); + for (count = 1; count < 32; count ++) + { + if (!IsMapped(count)) + { + continue; + } + if (GetMipsRegMapLo(count) == Reg) + { + if (NewReg == x86_Unknown) + { + UnMap_GPR(count, true); + break; + } + CPU_Message(" regcache: change allocation of %s from %s to %s",CRegName::GPR[count],x86_Name(Reg),x86_Name(NewReg)); + SetX86Mapped(NewReg,GPR_Mapped); + SetX86MapOrder(NewReg,GetX86MapOrder(Reg)); + SetMipsRegMapLo(count,NewReg); + MoveX86RegToX86Reg(Reg,NewReg); + if (MipsReg == count && !LoadHiWord) + { + MipsReg = -1; + } + break; + } + if (Is64Bit(count) && GetMipsRegMapHi(count) == Reg) + { + if (NewReg == x86_Unknown) + { + UnMap_GPR(count, true); + break; + } + CPU_Message(" regcache: change allocation of %s from %s to %s",CRegName::GPR_Hi[count],x86_Name(Reg),x86_Name(NewReg)); + SetX86Mapped(NewReg,GPR_Mapped); + SetX86MapOrder(NewReg,GetX86MapOrder(Reg)); + SetMipsRegMapHi(count,NewReg); + MoveX86RegToX86Reg(Reg,NewReg); + if (MipsReg == count && LoadHiWord) { - MoveConstToX86reg(GetMipsRegHi(MipsReg),Reg); - } else { - MoveConstToX86reg(GetMipsRegLo_S(MipsReg) >> 31,Reg); + MipsReg = -1; } - } - } else { - if (IsUnknown(MipsReg)) { - MoveVariableToX86reg(&_GPR[MipsReg].UW[0],CRegName::GPR_Lo[MipsReg],Reg); - } else if (IsMapped(MipsReg)) { - MoveX86RegToX86Reg(GetMipsRegMapLo(MipsReg),Reg); - } else { - MoveConstToX86reg(GetMipsRegLo(MipsReg),Reg); - } - } - } - SetX86Mapped(Reg,Temp_Mapped); - SetX86Protected(Reg, true); - for (count = 0; count < 10; count++) - { - int MapOrder = GetX86MapOrder((x86Reg)count); - if (MapOrder > 0) { - SetX86MapOrder((x86Reg)count,MapOrder + 1); - } - } - SetX86MapOrder(Reg,1); - return Reg; + break; + } + } + } + else if (GetX86Mapped(Reg) == Stack_Mapped) + { + UnMap_X86reg(Reg); + } + CPU_Message(" regcache: allocate %s as temp storage",x86_Name(Reg)); + + if (MipsReg >= 0) + { + if (LoadHiWord) + { + if (IsUnknown(MipsReg)) + { + MoveVariableToX86reg(&_GPR[MipsReg].UW[1],CRegName::GPR_Hi[MipsReg],Reg); + } + else if (IsMapped(MipsReg)) + { + if (Is64Bit(MipsReg)) + { + MoveX86RegToX86Reg(GetMipsRegMapHi(MipsReg),Reg); + } + else if (IsSigned(MipsReg)) + { + MoveX86RegToX86Reg(GetMipsRegMapLo(MipsReg),Reg); + ShiftRightSignImmed(Reg,31); + } + else + { + MoveConstToX86reg(0,Reg); + } + } + else + { + if (Is64Bit(MipsReg)) + { + MoveConstToX86reg(GetMipsRegHi(MipsReg),Reg); + } + else + { + MoveConstToX86reg(GetMipsRegLo_S(MipsReg) >> 31,Reg); + } + } + } + else + { + if (IsUnknown(MipsReg)) + { + MoveVariableToX86reg(&_GPR[MipsReg].UW[0],CRegName::GPR_Lo[MipsReg],Reg); + } + else if (IsMapped(MipsReg)) + { + MoveX86RegToX86Reg(GetMipsRegMapLo(MipsReg),Reg); + } + else + { + MoveConstToX86reg(GetMipsRegLo(MipsReg),Reg); + } + } + } + SetX86Mapped(Reg,Temp_Mapped); + SetX86Protected(Reg, true); + for (count = 0; count < 10; count++) + { + int32_t MapOrder = GetX86MapOrder((x86Reg)count); + if (MapOrder > 0) + { + SetX86MapOrder((x86Reg)count,MapOrder + 1); + } + } + SetX86MapOrder(Reg,1); + return Reg; } -void CRegInfo::ProtectGPR(DWORD Reg) { - if (IsUnknown(Reg) || IsConst(Reg)) { - return; - } - if (Is64Bit(Reg)) { - SetX86Protected(GetMipsRegMapHi(Reg), true); - } - - SetX86Protected(GetMipsRegMapLo(Reg), true); +void CRegInfo::ProtectGPR(uint32_t Reg) +{ + if (IsUnknown(Reg) || IsConst(Reg)) + { + return; + } + if (Is64Bit(Reg)) + { + SetX86Protected(GetMipsRegMapHi(Reg), true); + } + SetX86Protected(GetMipsRegMapLo(Reg), true); } -void CRegInfo::UnProtectGPR(DWORD Reg) { - if (IsUnknown(Reg) || IsConst(Reg)) { - return; - } - if (Is64Bit(Reg)) { - SetX86Protected(GetMipsRegMapHi(Reg), false); - } - - SetX86Protected(GetMipsRegMapLo(Reg),false); +void CRegInfo::UnProtectGPR(uint32_t Reg) +{ + if (IsUnknown(Reg) || IsConst(Reg)) + { + return; + } + if (Is64Bit(Reg)) + { + SetX86Protected(GetMipsRegMapHi(Reg), false); + } + SetX86Protected(GetMipsRegMapLo(Reg),false); } void CRegInfo::ResetX86Protection() { - for (int count = 0; count < 10; count ++) - { - SetX86Protected((x86Reg)count, false); - } + for (int32_t count = 0; count < 10; count ++) + { + SetX86Protected((x86Reg)count, false); + } } -bool CRegInfo::RegInStack( int Reg, FPU_STATE Format) { - for (int i = 0; i < 8; i++) - { - if (x86fpu_MappedTo[i] == Reg) - { - if (x86fpu_State[i] == Format || Format == FPU_Any) - { - return true; - } - - return false; - } - } - - return false; +bool CRegInfo::RegInStack( int32_t Reg, FPU_STATE Format) +{ + for (int32_t i = 0; i < 8; i++) + { + if (m_x86fpu_MappedTo[i] == Reg) + { + if (m_x86fpu_State[i] == Format || Format == FPU_Any) + { + return true; + } + return false; + } + } + return false; } void CRegInfo::UnMap_AllFPRs() { - for (;;) { - int StackPos = StackTopPos(); - if (x86fpu_MappedTo[StackPos] != -1 ) { - UnMap_FPR(x86fpu_MappedTo[StackPos], true); - continue; - } - //see if any more registers mapped - int StartPos = StackTopPos(); - for (int i = 0; i < 8; i++) { - if (x86fpu_MappedTo[(StartPos + i) & 7] != -1 ) { fpuIncStack(&StackTopPos()); } - } - if (StackPos != StackTopPos()) { continue; } - return; - } + for (;;) + { + int32_t StackPos = StackTopPos(); + if (m_x86fpu_MappedTo[StackPos] != -1 ) + { + UnMap_FPR(m_x86fpu_MappedTo[StackPos], true); + continue; + } + //see if any more registers mapped + int32_t StartPos = StackTopPos(); + for (int32_t i = 0; i < 8; i++) + { + if (m_x86fpu_MappedTo[(StartPos + i) & 7] != -1 ) { fpuIncStack(&StackTopPos()); } + } + if (StackPos != StackTopPos()) { continue; } + return; + } } -void CRegInfo::UnMap_FPR (int Reg, int WriteBackValue ) +void CRegInfo::UnMap_FPR (int32_t Reg, bool WriteBackValue ) { - char Name[50]; - int i; + char Name[50]; + int32_t i; - if (Reg < 0) { return; } - for (i = 0; i < 8; i++) { - if (x86fpu_MappedTo[i] != Reg) { continue; } - CPU_Message(" regcache: unallocate %s from ST(%d)",CRegName::FPR[Reg],(i - StackTopPos() + 8) & 7); - if (WriteBackValue) { - int RegPos; - - if (((i - StackTopPos() + 8) & 7) != 0) - { - if (x86fpu_MappedTo[StackTopPos()] == -1 && x86fpu_MappedTo[(StackTopPos() + 1) & 7] == Reg) - { - fpuIncStack(&StackTopPos()); - } else { - CRegInfo::FPU_ROUND RoundingModel = FpuRoundingModel(StackTopPos()); - FPU_STATE RegState = x86fpu_State[StackTopPos()]; - bool Changed = x86fpu_StateChanged[StackTopPos()]; - DWORD MappedTo = x86fpu_MappedTo[StackTopPos()]; - FpuRoundingModel(StackTopPos()) = FpuRoundingModel(i); - x86fpu_MappedTo[StackTopPos()] = x86fpu_MappedTo[i]; - x86fpu_State[StackTopPos()] = x86fpu_State[i]; - x86fpu_StateChanged[StackTopPos()] = x86fpu_StateChanged[i]; - FpuRoundingModel(i) = RoundingModel; - x86fpu_MappedTo[i] = MappedTo; - x86fpu_State[i] = RegState; - x86fpu_StateChanged[i] = Changed; - fpuExchange((x86FpuValues)((i - StackTopPos()) & 7)); - } - } - - FixRoundModel(FpuRoundingModel(i)); + if (Reg < 0) { return; } + for (i = 0; i < 8; i++) + { + if (m_x86fpu_MappedTo[i] != Reg) { continue; } + CPU_Message(" regcache: unallocate %s from ST(%d)",CRegName::FPR[Reg],(i - StackTopPos() + 8) & 7); + if (WriteBackValue) + { + int32_t RegPos; - RegPos = StackTopPos(); - x86Reg TempReg = Map_TempReg(x86_Any, -1, false); - switch (x86fpu_State[StackTopPos()]) { - case FPU_Dword: - sprintf(Name,"_FPR_S[%d]",x86fpu_MappedTo[StackTopPos()]); - MoveVariableToX86reg(&_FPR_S[x86fpu_MappedTo[StackTopPos()]],Name,TempReg); - fpuStoreIntegerDwordFromX86Reg(&StackTopPos(),TempReg, true); - break; - case FPU_Qword: - sprintf(Name,"_FPR_D[%d]",x86fpu_MappedTo[StackTopPos()]); - MoveVariableToX86reg(&_FPR_D[x86fpu_MappedTo[StackTopPos()]],Name,TempReg); - fpuStoreIntegerQwordFromX86Reg(&StackTopPos(),TempReg, true); - break; - case FPU_Float: - sprintf(Name,"_FPR_S[%d]",x86fpu_MappedTo[StackTopPos()]); - MoveVariableToX86reg(&_FPR_S[x86fpu_MappedTo[StackTopPos()]],Name,TempReg); - fpuStoreDwordFromX86Reg(&StackTopPos(),TempReg, true); - break; - case FPU_Double: - sprintf(Name,"_FPR_D[%d]",x86fpu_MappedTo[StackTopPos()]); - MoveVariableToX86reg(&_FPR_D[x86fpu_MappedTo[StackTopPos()]],Name,TempReg); - fpuStoreQwordFromX86Reg(&StackTopPos(),TempReg, true); - break; - default: - if (bHaveDebugger()) { g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nUnknown format to load %d",x86fpu_State[StackTopPos()]).ToUTF16().c_str()); } - } - SetX86Protected(TempReg, false); - FpuRoundingModel(RegPos) = RoundDefault; - x86fpu_MappedTo[RegPos] = -1; - x86fpu_State[RegPos] = FPU_Unknown; - x86fpu_StateChanged[RegPos] = false; - } else { - fpuFree((x86FpuValues)((i - StackTopPos()) & 7)); - FpuRoundingModel(i) = RoundDefault; - x86fpu_MappedTo[i] = -1; - x86fpu_State[i] = FPU_Unknown; - x86fpu_StateChanged[i] = false; - } - return; - } + if (((i - StackTopPos() + 8) & 7) != 0) + { + if (m_x86fpu_MappedTo[StackTopPos()] == -1 && m_x86fpu_MappedTo[(StackTopPos() + 1) & 7] == Reg) + { + fpuIncStack(&StackTopPos()); + } + else + { + CRegInfo::FPU_ROUND RoundingModel = FpuRoundingModel(StackTopPos()); + FPU_STATE RegState = m_x86fpu_State[StackTopPos()]; + bool Changed = m_x86fpu_StateChanged[StackTopPos()]; + uint32_t MappedTo = m_x86fpu_MappedTo[StackTopPos()]; + FpuRoundingModel(StackTopPos()) = FpuRoundingModel(i); + m_x86fpu_MappedTo[StackTopPos()] = m_x86fpu_MappedTo[i]; + m_x86fpu_State[StackTopPos()] = m_x86fpu_State[i]; + m_x86fpu_StateChanged[StackTopPos()] = m_x86fpu_StateChanged[i]; + FpuRoundingModel(i) = RoundingModel; + m_x86fpu_MappedTo[i] = MappedTo; + m_x86fpu_State[i] = RegState; + m_x86fpu_StateChanged[i] = Changed; + fpuExchange((x86FpuValues)((i - StackTopPos()) & 7)); + } + } + + FixRoundModel(FpuRoundingModel(i)); + + RegPos = StackTopPos(); + x86Reg TempReg = Map_TempReg(x86_Any, -1, false); + switch (m_x86fpu_State[StackTopPos()]) + { + case FPU_Dword: + sprintf(Name,"_FPR_S[%d]",m_x86fpu_MappedTo[StackTopPos()]); + MoveVariableToX86reg(&_FPR_S[m_x86fpu_MappedTo[StackTopPos()]],Name,TempReg); + fpuStoreIntegerDwordFromX86Reg(&StackTopPos(),TempReg, true); + break; + case FPU_Qword: + sprintf(Name,"_FPR_D[%d]",m_x86fpu_MappedTo[StackTopPos()]); + MoveVariableToX86reg(&_FPR_D[m_x86fpu_MappedTo[StackTopPos()]],Name,TempReg); + fpuStoreIntegerQwordFromX86Reg(&StackTopPos(),TempReg, true); + break; + case FPU_Float: + sprintf(Name,"_FPR_S[%d]",m_x86fpu_MappedTo[StackTopPos()]); + MoveVariableToX86reg(&_FPR_S[m_x86fpu_MappedTo[StackTopPos()]],Name,TempReg); + fpuStoreDwordFromX86Reg(&StackTopPos(),TempReg, true); + break; + case FPU_Double: + sprintf(Name,"_FPR_D[%d]",m_x86fpu_MappedTo[StackTopPos()]); + MoveVariableToX86reg(&_FPR_D[m_x86fpu_MappedTo[StackTopPos()]],Name,TempReg); + fpuStoreQwordFromX86Reg(&StackTopPos(),TempReg, true); + break; + default: + if (bHaveDebugger()) { g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nUnknown format to load %d",m_x86fpu_State[StackTopPos()]).ToUTF16().c_str()); } + } + SetX86Protected(TempReg, false); + FpuRoundingModel(RegPos) = RoundDefault; + m_x86fpu_MappedTo[RegPos] = -1; + m_x86fpu_State[RegPos] = FPU_Unknown; + m_x86fpu_StateChanged[RegPos] = false; + } + else + { + fpuFree((x86FpuValues)((i - StackTopPos()) & 7)); + FpuRoundingModel(i) = RoundDefault; + m_x86fpu_MappedTo[i] = -1; + m_x86fpu_State[i] = FPU_Unknown; + m_x86fpu_StateChanged[i] = false; + } + return; + } } -void CRegInfo::UnMap_GPR (DWORD Reg, bool WriteBackValue) +void CRegInfo::UnMap_GPR (uint32_t Reg, bool WriteBackValue) { - if (Reg == 0) - { - if (bHaveDebugger()) { g_Notify->DisplayError(__FUNCTIONW__ L"\n\nWhy are you trying to unmap reg 0"); } - return; - } + if (Reg == 0) + { + if (bHaveDebugger()) { g_Notify->DisplayError(__FUNCTIONW__ L"\n\nWhy are you trying to unmap reg 0"); } + return; + } - if (IsUnknown(Reg)) { return; } - //CPU_Message("UnMap_GPR: State: %X\tReg: %s\tWriteBack: %s",State,CRegName::GPR[Reg],WriteBackValue?"TRUE":"FALSE"); - if (IsConst(Reg)) { - if (!WriteBackValue) { - SetMipsRegState(Reg,STATE_UNKNOWN); - return; - } - if (Is64Bit(Reg)) { - MoveConstToVariable(GetMipsRegHi(Reg),&_GPR[Reg].UW[1],CRegName::GPR_Hi[Reg]); - MoveConstToVariable(GetMipsRegLo(Reg),&_GPR[Reg].UW[0],CRegName::GPR_Lo[Reg]); - SetMipsRegState(Reg,STATE_UNKNOWN); - return; - } - if ((GetMipsRegLo(Reg) & 0x80000000) != 0) { - MoveConstToVariable(0xFFFFFFFF,&_GPR[Reg].UW[1],CRegName::GPR_Hi[Reg]); - } else { - MoveConstToVariable(0,&_GPR[Reg].UW[1],CRegName::GPR_Hi[Reg]); - } - MoveConstToVariable(GetMipsRegLo(Reg),&_GPR[Reg].UW[0],CRegName::GPR_Lo[Reg]); - SetMipsRegState(Reg,STATE_UNKNOWN); - return; - } - if (Is64Bit(Reg)) { - CPU_Message(" regcache: unallocate %s from %s",x86_Name(GetMipsRegMapHi(Reg)),CRegName::GPR_Hi[Reg]); - SetX86Mapped(GetMipsRegMapHi(Reg),NotMapped); - SetX86Protected(GetMipsRegMapHi(Reg), false); - } - CPU_Message(" regcache: unallocate %s from %s",x86_Name(GetMipsRegMapLo(Reg)),CRegName::GPR_Lo[Reg]); - SetX86Mapped(GetMipsRegMapLo(Reg),NotMapped); - SetX86Protected(GetMipsRegMapLo(Reg), false); - if (!WriteBackValue) - { - SetMipsRegState(Reg,STATE_UNKNOWN); - return; - } - MoveX86regToVariable(GetMipsRegMapLo(Reg),&_GPR[Reg].UW[0],CRegName::GPR_Lo[Reg]); - if (Is64Bit(Reg)) { - SetMipsRegMapLo(Reg, x86_Unknown); - MoveX86regToVariable(GetMipsRegMapHi(Reg),&_GPR[Reg].UW[1],CRegName::GPR_Hi[Reg]); - SetMipsRegMapHi(Reg,x86_Unknown); - } else { - if (!g_System->b32BitCore()) { - if (IsSigned(Reg)) { - ShiftRightSignImmed(GetMipsRegMapLo(Reg),31); - MoveX86regToVariable(GetMipsRegMapLo(Reg),&_GPR[Reg].UW[1],CRegName::GPR_Hi[Reg]); - } else { - MoveConstToVariable(0,&_GPR[Reg].UW[1],CRegName::GPR_Hi[Reg]); - } - } - SetMipsRegMapLo(Reg, x86_Unknown); - } - SetMipsRegState(Reg,STATE_UNKNOWN); + if (IsUnknown(Reg)) { return; } + //CPU_Message("UnMap_GPR: State: %X\tReg: %s\tWriteBack: %s",State,CRegName::GPR[Reg],WriteBackValue?"TRUE":"FALSE"); + if (IsConst(Reg)) + { + if (!WriteBackValue) + { + SetMipsRegState(Reg,STATE_UNKNOWN); + return; + } + if (Is64Bit(Reg)) + { + MoveConstToVariable(GetMipsRegHi(Reg),&_GPR[Reg].UW[1],CRegName::GPR_Hi[Reg]); + MoveConstToVariable(GetMipsRegLo(Reg),&_GPR[Reg].UW[0],CRegName::GPR_Lo[Reg]); + SetMipsRegState(Reg,STATE_UNKNOWN); + return; + } + if ((GetMipsRegLo(Reg) & 0x80000000) != 0) + { + MoveConstToVariable(0xFFFFFFFF,&_GPR[Reg].UW[1],CRegName::GPR_Hi[Reg]); + } + else + { + MoveConstToVariable(0,&_GPR[Reg].UW[1],CRegName::GPR_Hi[Reg]); + } + MoveConstToVariable(GetMipsRegLo(Reg),&_GPR[Reg].UW[0],CRegName::GPR_Lo[Reg]); + SetMipsRegState(Reg,STATE_UNKNOWN); + return; + } + if (Is64Bit(Reg)) + { + CPU_Message(" regcache: unallocate %s from %s",x86_Name(GetMipsRegMapHi(Reg)),CRegName::GPR_Hi[Reg]); + SetX86Mapped(GetMipsRegMapHi(Reg),NotMapped); + SetX86Protected(GetMipsRegMapHi(Reg), false); + } + CPU_Message(" regcache: unallocate %s from %s",x86_Name(GetMipsRegMapLo(Reg)),CRegName::GPR_Lo[Reg]); + SetX86Mapped(GetMipsRegMapLo(Reg),NotMapped); + SetX86Protected(GetMipsRegMapLo(Reg), false); + if (!WriteBackValue) + { + SetMipsRegState(Reg,STATE_UNKNOWN); + return; + } + MoveX86regToVariable(GetMipsRegMapLo(Reg),&_GPR[Reg].UW[0],CRegName::GPR_Lo[Reg]); + if (Is64Bit(Reg)) + { + SetMipsRegMapLo(Reg, x86_Unknown); + MoveX86regToVariable(GetMipsRegMapHi(Reg),&_GPR[Reg].UW[1],CRegName::GPR_Hi[Reg]); + SetMipsRegMapHi(Reg,x86_Unknown); + } + else + { + if (!g_System->b32BitCore()) + { + if (IsSigned(Reg)) + { + ShiftRightSignImmed(GetMipsRegMapLo(Reg),31); + MoveX86regToVariable(GetMipsRegMapLo(Reg),&_GPR[Reg].UW[1],CRegName::GPR_Hi[Reg]); + } + else + { + MoveConstToVariable(0,&_GPR[Reg].UW[1],CRegName::GPR_Hi[Reg]); + } + } + SetMipsRegMapLo(Reg, x86_Unknown); + } + SetMipsRegState(Reg,STATE_UNKNOWN); } CX86Ops::x86Reg CRegInfo::UnMap_TempReg() { - CX86Ops::x86Reg Reg = x86_Unknown; + CX86Ops::x86Reg Reg = x86_Unknown; - if (GetX86Mapped(x86_EAX) == Temp_Mapped && !GetX86Protected(x86_EAX)) { Reg = x86_EAX; } - else if (GetX86Mapped(x86_EBX) == Temp_Mapped && !GetX86Protected(x86_EBX)) { Reg = x86_EBX; } - else if (GetX86Mapped(x86_ECX) == Temp_Mapped && !GetX86Protected(x86_ECX)) { Reg = x86_ECX; } - else if (GetX86Mapped(x86_EDX) == Temp_Mapped && !GetX86Protected(x86_EDX)) { Reg = x86_EDX; } - else if (GetX86Mapped(x86_ESI) == Temp_Mapped && !GetX86Protected(x86_ESI)) { Reg = x86_ESI; } - else if (GetX86Mapped(x86_EDI) == Temp_Mapped && !GetX86Protected(x86_EDI)) { Reg = x86_EDI; } - else if (GetX86Mapped(x86_EBP) == Temp_Mapped && !GetX86Protected(x86_EBP)) { Reg = x86_EBP; } - else if (GetX86Mapped(x86_ESP) == Temp_Mapped && !GetX86Protected(x86_ESP)) { Reg = x86_ESP; } + if (GetX86Mapped(x86_EAX) == Temp_Mapped && !GetX86Protected(x86_EAX)) { Reg = x86_EAX; } + else if (GetX86Mapped(x86_EBX) == Temp_Mapped && !GetX86Protected(x86_EBX)) { Reg = x86_EBX; } + else if (GetX86Mapped(x86_ECX) == Temp_Mapped && !GetX86Protected(x86_ECX)) { Reg = x86_ECX; } + else if (GetX86Mapped(x86_EDX) == Temp_Mapped && !GetX86Protected(x86_EDX)) { Reg = x86_EDX; } + else if (GetX86Mapped(x86_ESI) == Temp_Mapped && !GetX86Protected(x86_ESI)) { Reg = x86_ESI; } + else if (GetX86Mapped(x86_EDI) == Temp_Mapped && !GetX86Protected(x86_EDI)) { Reg = x86_EDI; } + else if (GetX86Mapped(x86_EBP) == Temp_Mapped && !GetX86Protected(x86_EBP)) { Reg = x86_EBP; } + else if (GetX86Mapped(x86_ESP) == Temp_Mapped && !GetX86Protected(x86_ESP)) { Reg = x86_ESP; } - if (Reg != x86_Unknown) - { - if (GetX86Mapped(Reg) == Temp_Mapped) - { - CPU_Message(" regcache: unallocate %s from temp storage",x86_Name(Reg)); - } - SetX86Mapped(Reg,NotMapped); - } - return Reg; + if (Reg != x86_Unknown) + { + if (GetX86Mapped(Reg) == Temp_Mapped) + { + CPU_Message(" regcache: unallocate %s from temp storage",x86_Name(Reg)); + } + SetX86Mapped(Reg,NotMapped); + } + return Reg; } bool CRegInfo::UnMap_X86reg(CX86Ops::x86Reg Reg) { - int count; + int32_t count; - if (GetX86Mapped(Reg) == NotMapped) - { - if (!GetX86Protected(Reg)) - { - return true; - } - } - else if (GetX86Mapped(Reg) == CRegInfo::GPR_Mapped) - { - for (count = 1; count < 32; count ++) - { - if (!IsMapped(count)) - continue; + if (GetX86Mapped(Reg) == NotMapped) + { + if (!GetX86Protected(Reg)) + { + return true; + } + } + else if (GetX86Mapped(Reg) == CRegInfo::GPR_Mapped) + { + for (count = 1; count < 32; count ++) + { + if (!IsMapped(count)) + { + continue; + } - if (Is64Bit(count) && GetMipsRegMapHi(count) == Reg) - { - if (!GetX86Protected(Reg)) - { - UnMap_GPR(count, true); - return true; - } - break; - } - if (GetMipsRegMapLo(count) == Reg) - { - if (!GetX86Protected(Reg)) - { - UnMap_GPR(count, true); - return true; - } - break; - } - } - } - else if (GetX86Mapped(Reg) == CRegInfo::Temp_Mapped) - { - if (!GetX86Protected(Reg)) { - CPU_Message(" regcache: unallocate %s from temp storage",x86_Name(Reg)); - SetX86Mapped(Reg,NotMapped); - return true; - } - } - else if (GetX86Mapped(Reg) == CRegInfo::Stack_Mapped) - { - CPU_Message(" regcache: unallocate %s from Memory Stack",x86_Name(Reg)); - MoveX86regToVariable(Reg,&(g_Recompiler->MemoryStackPos()),"MemoryStack"); - SetX86Mapped(Reg,NotMapped); - return true; - } + if (Is64Bit(count) && GetMipsRegMapHi(count) == Reg) + { + if (!GetX86Protected(Reg)) + { + UnMap_GPR(count, true); + return true; + } + break; + } + if (GetMipsRegMapLo(count) == Reg) + { + if (!GetX86Protected(Reg)) + { + UnMap_GPR(count, true); + return true; + } + break; + } + } + } + else if (GetX86Mapped(Reg) == CRegInfo::Temp_Mapped) + { + if (!GetX86Protected(Reg)) + { + CPU_Message(" regcache: unallocate %s from temp storage",x86_Name(Reg)); + SetX86Mapped(Reg,NotMapped); + return true; + } + } + else if (GetX86Mapped(Reg) == CRegInfo::Stack_Mapped) + { + CPU_Message(" regcache: unallocate %s from Memory Stack",x86_Name(Reg)); + MoveX86regToVariable(Reg,&(g_Recompiler->MemoryStackPos()),"MemoryStack"); + SetX86Mapped(Reg,NotMapped); + return true; + } - return false; + return false; } void CRegInfo::WriteBackRegisters() { - UnMap_AllFPRs(); + UnMap_AllFPRs(); - int count; - bool bEdiZero = false; - bool bEsiSign = false; + int32_t count; + bool bEdiZero = false; + bool bEsiSign = false; - int X86RegCount = sizeof(x86_Registers)/ sizeof(x86_Registers[0]); - for (int i = 0; i < X86RegCount; i++) { SetX86Protected(x86_Registers[i], false); } - for (int i = 0; i < X86RegCount; i++) { UnMap_X86reg(x86_Registers[i]); } + int32_t X86RegCount = sizeof(x86_Registers)/ sizeof(x86_Registers[0]); + for (int32_t i = 0; i < X86RegCount; i++) { SetX86Protected(x86_Registers[i], false); } + for (int32_t i = 0; i < X86RegCount; i++) { UnMap_X86reg(x86_Registers[i]); } - /*************************************/ - - for (count = 1; count < 32; count ++) { - switch (GetMipsRegState(count)) { - case CRegInfo::STATE_UNKNOWN: break; - case CRegInfo::STATE_CONST_32_SIGN: - if (!g_System->b32BitCore()) - { - if (!bEdiZero && (!GetMipsRegLo(count) || !(GetMipsRegLo(count) & 0x80000000))) - { - XorX86RegToX86Reg(x86_EDI, x86_EDI); - bEdiZero = true; - } - if (!bEsiSign && (GetMipsRegLo(count) & 0x80000000)) - { - MoveConstToX86reg(0xFFFFFFFF, x86_ESI); - bEsiSign = true; - } - if ((GetMipsRegLo(count) & 0x80000000) != 0) - { - MoveX86regToVariable(x86_ESI,&_GPR[count].UW[1],CRegName::GPR_Hi[count]); - } - else - { - MoveX86regToVariable(x86_EDI,&_GPR[count].UW[1],CRegName::GPR_Hi[count]); - } - } + /*************************************/ - if (GetMipsRegLo(count) == 0) - { - if (g_System->b32BitCore()) - { - if (!bEdiZero) - { - XorX86RegToX86Reg(x86_EDI, x86_EDI); - bEdiZero = true; - } - } - MoveX86regToVariable(x86_EDI,&_GPR[count].UW[0],CRegName::GPR_Lo[count]); - } - else if (GetMipsRegLo(count) == 0xFFFFFFFF) - { - if (g_System->b32BitCore()) - { - if (!bEsiSign) - { - MoveConstToX86reg(0xFFFFFFFF, x86_ESI); - bEsiSign = true; - } - } - MoveX86regToVariable(x86_ESI,&_GPR[count].UW[0],CRegName::GPR_Lo[count]); - } - else - { - MoveConstToVariable(GetMipsRegLo(count),&_GPR[count].UW[0],CRegName::GPR_Lo[count]); - } + for (count = 1; count < 32; count ++) + { + switch (GetMipsRegState(count)) + { + case CRegInfo::STATE_UNKNOWN: break; + case CRegInfo::STATE_CONST_32_SIGN: + if (!g_System->b32BitCore()) + { + if (!bEdiZero && (!GetMipsRegLo(count) || !(GetMipsRegLo(count) & 0x80000000))) + { + XorX86RegToX86Reg(x86_EDI, x86_EDI); + bEdiZero = true; + } + if (!bEsiSign && (GetMipsRegLo(count) & 0x80000000)) + { + MoveConstToX86reg(0xFFFFFFFF, x86_ESI); + bEsiSign = true; + } + if ((GetMipsRegLo(count) & 0x80000000) != 0) + { + MoveX86regToVariable(x86_ESI,&_GPR[count].UW[1],CRegName::GPR_Hi[count]); + } + else + { + MoveX86regToVariable(x86_EDI,&_GPR[count].UW[1],CRegName::GPR_Hi[count]); + } + } - SetMipsRegState(count, CRegInfo::STATE_UNKNOWN); - break; - case CRegInfo::STATE_CONST_32_ZERO: - if (!g_System->b32BitCore()) - { - if (!bEdiZero) - { - XorX86RegToX86Reg(x86_EDI, x86_EDI); - bEdiZero = true; - } - MoveX86regToVariable(x86_EDI,&_GPR[count].UW[1],CRegName::GPR_Hi[count]); - } + if (GetMipsRegLo(count) == 0) + { + if (g_System->b32BitCore()) + { + if (!bEdiZero) + { + XorX86RegToX86Reg(x86_EDI, x86_EDI); + bEdiZero = true; + } + } + MoveX86regToVariable(x86_EDI,&_GPR[count].UW[0],CRegName::GPR_Lo[count]); + } + else if (GetMipsRegLo(count) == 0xFFFFFFFF) + { + if (g_System->b32BitCore()) + { + if (!bEsiSign) + { + MoveConstToX86reg(0xFFFFFFFF, x86_ESI); + bEsiSign = true; + } + } + MoveX86regToVariable(x86_ESI,&_GPR[count].UW[0],CRegName::GPR_Lo[count]); + } + else + { + MoveConstToVariable(GetMipsRegLo(count),&_GPR[count].UW[0],CRegName::GPR_Lo[count]); + } - if (GetMipsRegLo(count) == 0) - { - if (g_System->b32BitCore()) - { - if (!bEdiZero) - { - XorX86RegToX86Reg(x86_EDI, x86_EDI); - bEdiZero = true; - } - } - MoveX86regToVariable(x86_EDI,&_GPR[count].UW[0],CRegName::GPR_Lo[count]); - } - else - { - MoveConstToVariable(GetMipsRegLo(count),&_GPR[count].UW[0],CRegName::GPR_Lo[count]); - } + SetMipsRegState(count, CRegInfo::STATE_UNKNOWN); + break; + case CRegInfo::STATE_CONST_32_ZERO: + if (!g_System->b32BitCore()) + { + if (!bEdiZero) + { + XorX86RegToX86Reg(x86_EDI, x86_EDI); + bEdiZero = true; + } + MoveX86regToVariable(x86_EDI,&_GPR[count].UW[1],CRegName::GPR_Hi[count]); + } - SetMipsRegState(count, CRegInfo::STATE_UNKNOWN); - break; - case CRegInfo::STATE_CONST_64: - if (GetMipsRegLo(count) == 0 || GetMipsRegHi(count) == 0) { - XorX86RegToX86Reg(x86_EDI, x86_EDI); - bEdiZero = true; - } - if (GetMipsRegLo(count) == 0xFFFFFFFF || GetMipsRegHi(count) == 0xFFFFFFFF) { - MoveConstToX86reg(0xFFFFFFFF, x86_ESI); - bEsiSign = true; - } + if (GetMipsRegLo(count) == 0) + { + if (g_System->b32BitCore()) + { + if (!bEdiZero) + { + XorX86RegToX86Reg(x86_EDI, x86_EDI); + bEdiZero = true; + } + } + MoveX86regToVariable(x86_EDI,&_GPR[count].UW[0],CRegName::GPR_Lo[count]); + } + else + { + MoveConstToVariable(GetMipsRegLo(count),&_GPR[count].UW[0],CRegName::GPR_Lo[count]); + } + SetMipsRegState(count, CRegInfo::STATE_UNKNOWN); + break; + case CRegInfo::STATE_CONST_64: + if (GetMipsRegLo(count) == 0 || GetMipsRegHi(count) == 0) + { + XorX86RegToX86Reg(x86_EDI, x86_EDI); + bEdiZero = true; + } + if (GetMipsRegLo(count) == 0xFFFFFFFF || GetMipsRegHi(count) == 0xFFFFFFFF) + { + MoveConstToX86reg(0xFFFFFFFF, x86_ESI); + bEsiSign = true; + } - if (GetMipsRegHi(count) == 0) { - MoveX86regToVariable(x86_EDI,&_GPR[count].UW[1],CRegName::GPR_Hi[count]); - } else if (GetMipsRegLo(count) == 0xFFFFFFFF) { - MoveX86regToVariable(x86_ESI,&_GPR[count].UW[1],CRegName::GPR_Hi[count]); - } else { - MoveConstToVariable(GetMipsRegHi(count),&_GPR[count].UW[1],CRegName::GPR_Hi[count]); - } + if (GetMipsRegHi(count) == 0) + { + MoveX86regToVariable(x86_EDI,&_GPR[count].UW[1],CRegName::GPR_Hi[count]); + } + else if (GetMipsRegLo(count) == 0xFFFFFFFF) + { + MoveX86regToVariable(x86_ESI,&_GPR[count].UW[1],CRegName::GPR_Hi[count]); + } + else + { + MoveConstToVariable(GetMipsRegHi(count),&_GPR[count].UW[1],CRegName::GPR_Hi[count]); + } - if (GetMipsRegLo(count) == 0) { - MoveX86regToVariable(x86_EDI,&_GPR[count].UW[0],CRegName::GPR_Lo[count]); - } else if (GetMipsRegLo(count) == 0xFFFFFFFF) { - MoveX86regToVariable(x86_ESI,&_GPR[count].UW[0],CRegName::GPR_Lo[count]); - } else { - MoveConstToVariable(GetMipsRegLo(count),&_GPR[count].UW[0],CRegName::GPR_Lo[count]); - } - SetMipsRegState(count, CRegInfo::STATE_UNKNOWN); - break; - default: - CPU_Message(__FUNCTION__ ": Unknown State: %d reg %d (%s)",GetMipsRegState(count),count,CRegName::GPR[count]) - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } + if (GetMipsRegLo(count) == 0) + { + MoveX86regToVariable(x86_EDI,&_GPR[count].UW[0],CRegName::GPR_Lo[count]); + } + else if (GetMipsRegLo(count) == 0xFFFFFFFF) + { + MoveX86regToVariable(x86_ESI,&_GPR[count].UW[0],CRegName::GPR_Lo[count]); + } + else + { + MoveConstToVariable(GetMipsRegLo(count),&_GPR[count].UW[0],CRegName::GPR_Lo[count]); + } + SetMipsRegState(count, CRegInfo::STATE_UNKNOWN); + break; + default: + CPU_Message(__FUNCTION__ ": Unknown State: %d reg %d (%s)",GetMipsRegState(count),count,CRegName::GPR[count]); + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + } } const char * CRegInfo::RoundingModelName ( FPU_ROUND RoundType ) { - switch (RoundType) - { - case RoundUnknown: return "RoundUnknown"; - case RoundDefault: return "RoundDefault"; - case RoundTruncate: return "RoundTruncate"; - case RoundNearest: return "RoundNearest"; - case RoundDown: return "RoundDown"; - case RoundUp: return "RoundUp"; - } - return "** Invalid **"; -} + switch (RoundType) + { + case RoundUnknown: return "RoundUnknown"; + case RoundDefault: return "RoundDefault"; + case RoundTruncate: return "RoundTruncate"; + case RoundNearest: return "RoundNearest"; + case RoundDown: return "RoundDown"; + case RoundUp: return "RoundUp"; + } + return "** Invalid **"; +} \ No newline at end of file diff --git a/Source/Project64/N64 System/Recompiler/Reg Info.h b/Source/Project64/N64 System/Recompiler/Reg Info.h index e3f3c50e9..d9ae33d63 100644 --- a/Source/Project64/N64 System/Recompiler/Reg Info.h +++ b/Source/Project64/N64 System/Recompiler/Reg Info.h @@ -11,169 +11,173 @@ #pragma once class CRegInfo : - private CDebugSettings, - private CX86Ops, - private CSystemRegisters + private CDebugSettings, + private CX86Ops, + private CSystemRegisters { public: - //enums - enum REG_STATE { - STATE_UNKNOWN = 0x00, - STATE_KNOWN_VALUE = 0x01, - STATE_X86_MAPPED = 0x02, - STATE_SIGN = 0x04, - STATE_32BIT = 0x08, - STATE_MODIFIED = 0x10, + //enums + enum REG_STATE + { + STATE_UNKNOWN = 0x00, + STATE_KNOWN_VALUE = 0x01, + STATE_X86_MAPPED = 0x02, + STATE_SIGN = 0x04, + STATE_32BIT = 0x08, + STATE_MODIFIED = 0x10, - STATE_MAPPED_64 = (STATE_KNOWN_VALUE | STATE_X86_MAPPED), // = 3 - STATE_MAPPED_32_ZERO = (STATE_KNOWN_VALUE | STATE_X86_MAPPED | STATE_32BIT), // = 11 - STATE_MAPPED_32_SIGN = (STATE_KNOWN_VALUE | STATE_X86_MAPPED | STATE_32BIT | STATE_SIGN), // = 15 + STATE_MAPPED_64 = (STATE_KNOWN_VALUE | STATE_X86_MAPPED), // = 3 + STATE_MAPPED_32_ZERO = (STATE_KNOWN_VALUE | STATE_X86_MAPPED | STATE_32BIT), // = 11 + STATE_MAPPED_32_SIGN = (STATE_KNOWN_VALUE | STATE_X86_MAPPED | STATE_32BIT | STATE_SIGN), // = 15 - STATE_CONST_32_ZERO = (STATE_KNOWN_VALUE | STATE_32BIT), // = 9 - STATE_CONST_32_SIGN = (STATE_KNOWN_VALUE | STATE_32BIT | STATE_SIGN), // = 13 - STATE_CONST_64 = (STATE_KNOWN_VALUE), // = 1 - }; + STATE_CONST_32_ZERO = (STATE_KNOWN_VALUE | STATE_32BIT), // = 9 + STATE_CONST_32_SIGN = (STATE_KNOWN_VALUE | STATE_32BIT | STATE_SIGN), // = 13 + STATE_CONST_64 = (STATE_KNOWN_VALUE), // = 1 + }; - enum REG_MAPPED { - NotMapped = 0, - GPR_Mapped = 1, - Temp_Mapped = 2, - Stack_Mapped = 3, - }; + enum REG_MAPPED + { + NotMapped = 0, + GPR_Mapped = 1, + Temp_Mapped = 2, + Stack_Mapped = 3, + }; - enum FPU_STATE { - FPU_Any = -1, - FPU_Unknown = 0, - FPU_Dword = 1, - FPU_Qword = 2, - FPU_Float = 3, - FPU_Double = 4, - }; + enum FPU_STATE + { + FPU_Any = -1, + FPU_Unknown = 0, + FPU_Dword = 1, + FPU_Qword = 2, + FPU_Float = 3, + FPU_Double = 4, + }; + + enum FPU_ROUND + { + RoundUnknown = -1, + RoundDefault = 0, + RoundTruncate = 1, + RoundNearest = 2, + RoundDown = 3, + RoundUp = 4, + }; - enum FPU_ROUND { - RoundUnknown = -1, - RoundDefault = 0, - RoundTruncate = 1, - RoundNearest = 2, - RoundDown = 3, - RoundUp = 4, - }; public: - CRegInfo(); - CRegInfo(const CRegInfo&); - ~CRegInfo(); + CRegInfo(); + CRegInfo(const CRegInfo&); + ~CRegInfo(); - CRegInfo& operator=(const CRegInfo&); + CRegInfo& operator=(const CRegInfo&); - bool operator==(const CRegInfo& right) const; - bool operator!=(const CRegInfo& right) const; + bool operator==(const CRegInfo& right) const; + bool operator!=(const CRegInfo& right) const; - static REG_STATE ConstantsType ( __int64 Value ); + static REG_STATE ConstantsType ( int64_t Value ); - void FixRoundModel ( FPU_ROUND RoundMethod ); - void ChangeFPURegFormat ( int Reg, FPU_STATE OldFormat, FPU_STATE NewFormat, FPU_ROUND RoundingModel ); - void Load_FPR_ToTop ( int Reg, int RegToLoad, FPU_STATE Format); - bool RegInStack ( int Reg, FPU_STATE Format ); - void UnMap_AllFPRs (); - void UnMap_FPR ( int Reg, int WriteBackValue ); - x86FpuValues StackPosition( int Reg ); + void FixRoundModel ( FPU_ROUND RoundMethod ); + void ChangeFPURegFormat ( int32_t Reg, FPU_STATE OldFormat, FPU_STATE NewFormat, FPU_ROUND RoundingModel ); + void Load_FPR_ToTop ( int32_t Reg, int32_t RegToLoad, FPU_STATE Format); + bool RegInStack ( int32_t Reg, FPU_STATE Format ); + void UnMap_AllFPRs (); + void UnMap_FPR ( int32_t Reg, bool WriteBackValue ); + x86FpuValues StackPosition( int32_t Reg ); - x86Reg FreeX86Reg (); - x86Reg Free8BitX86Reg (); - void Map_GPR_32bit ( int MipsReg, bool SignValue, int MipsRegToLoad ); - void Map_GPR_64bit ( int MipsReg, int MipsRegToLoad ); - x86Reg Get_MemoryStack () const; - x86Reg Map_MemoryStack ( x86Reg Reg, bool bMapRegister, bool LoadValue = true ); - x86Reg Map_TempReg ( x86Reg Reg, int MipsReg, bool LoadHiWord ); - void ProtectGPR ( DWORD Reg ); - void UnProtectGPR ( DWORD Reg ); - void ResetX86Protection (); - x86Reg UnMap_TempReg (); - void UnMap_GPR ( DWORD Reg, bool WriteBackValue ); - bool UnMap_X86reg ( x86Reg Reg ); - void WriteBackRegisters (); + x86Reg FreeX86Reg (); + x86Reg Free8BitX86Reg (); + void Map_GPR_32bit ( int32_t MipsReg, bool SignValue, int32_t MipsRegToLoad ); + void Map_GPR_64bit ( int32_t MipsReg, int32_t MipsRegToLoad ); + x86Reg Get_MemoryStack () const; + x86Reg Map_MemoryStack ( x86Reg Reg, bool bMapRegister, bool LoadValue = true ); + x86Reg Map_TempReg ( x86Reg Reg, int32_t MipsReg, bool LoadHiWord ); + void ProtectGPR ( uint32_t Reg ); + void UnProtectGPR ( uint32_t Reg ); + void ResetX86Protection (); + x86Reg UnMap_TempReg (); + void UnMap_GPR ( uint32_t Reg, bool WriteBackValue ); + bool UnMap_X86reg ( x86Reg Reg ); + void WriteBackRegisters (); - bool IsKnown(int Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) != 0); } - bool IsUnknown(int Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) == 0); } - bool IsModified(int Reg) const { return ((GetMipsRegState(Reg) & STATE_MODIFIED) != 0); } + bool IsKnown(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) != 0); } + bool IsUnknown(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_KNOWN_VALUE) == 0); } + bool IsModified(int32_t Reg) const { return ((GetMipsRegState(Reg) & STATE_MODIFIED) != 0); } - bool IsMapped(int Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); } - bool IsConst(int Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == STATE_KNOWN_VALUE); } + bool IsMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); } + bool IsConst(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_X86_MAPPED)) == STATE_KNOWN_VALUE); } - bool IsSigned(int Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == (STATE_KNOWN_VALUE | STATE_SIGN)); } - bool IsUnsigned(int Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == STATE_KNOWN_VALUE); } + bool IsSigned(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == (STATE_KNOWN_VALUE | STATE_SIGN)); } + bool IsUnsigned(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_SIGN)) == STATE_KNOWN_VALUE); } - bool Is32Bit(int Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == (STATE_KNOWN_VALUE | STATE_32BIT)); } - bool Is64Bit(int Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == STATE_KNOWN_VALUE); } + bool Is32Bit(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == (STATE_KNOWN_VALUE | STATE_32BIT)); } + bool Is64Bit(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT)) == STATE_KNOWN_VALUE); } - bool Is32BitMapped(int Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)); } - bool Is64BitMapped(int Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); } + bool Is32BitMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)); } + bool Is64BitMapped(int32_t Reg) const { return ((GetMipsRegState(Reg) & (STATE_KNOWN_VALUE | STATE_32BIT | STATE_X86_MAPPED)) == (STATE_KNOWN_VALUE | STATE_X86_MAPPED)); } - REG_STATE GetMipsRegState ( int Reg ) const { return m_MIPS_RegState[Reg]; } - unsigned __int64 GetMipsReg ( int Reg ) const { return m_MIPS_RegVal[Reg].UDW; } - __int64 GetMipsReg_S ( int Reg ) const { return m_MIPS_RegVal[Reg].DW; } - DWORD GetMipsRegLo ( int Reg ) const { return m_MIPS_RegVal[Reg].UW[0]; } - long GetMipsRegLo_S ( int Reg ) const { return m_MIPS_RegVal[Reg].W[0]; } - DWORD GetMipsRegHi ( int Reg ) const { return m_MIPS_RegVal[Reg].UW[1]; } - long GetMipsRegHi_S ( int Reg ) const { return m_MIPS_RegVal[Reg].W[1]; } - CX86Ops::x86Reg GetMipsRegMapLo ( int Reg ) const { return m_RegMapLo[Reg]; } - CX86Ops::x86Reg GetMipsRegMapHi ( int Reg ) const { return m_RegMapHi[Reg]; } + REG_STATE GetMipsRegState ( int32_t Reg ) const { return m_MIPS_RegState[Reg]; } + uint64_t GetMipsReg ( int32_t Reg ) const { return m_MIPS_RegVal[Reg].UDW; } + int64_t GetMipsReg_S ( int32_t Reg ) const { return m_MIPS_RegVal[Reg].DW; } + uint32_t GetMipsRegLo ( int32_t Reg ) const { return m_MIPS_RegVal[Reg].UW[0]; } + int32_t GetMipsRegLo_S ( int32_t Reg ) const { return m_MIPS_RegVal[Reg].W[0]; } + uint32_t GetMipsRegHi ( int32_t Reg ) const { return m_MIPS_RegVal[Reg].UW[1]; } + int32_t GetMipsRegHi_S ( int32_t Reg ) const { return m_MIPS_RegVal[Reg].W[1]; } + CX86Ops::x86Reg GetMipsRegMapLo ( int32_t Reg ) const { return m_RegMapLo[Reg]; } + CX86Ops::x86Reg GetMipsRegMapHi ( int32_t Reg ) const { return m_RegMapHi[Reg]; } - DWORD GetX86MapOrder ( x86Reg Reg ) const { return m_x86reg_MapOrder[Reg]; } - bool GetX86Protected ( x86Reg Reg ) const { return m_x86reg_Protected[Reg]; } - REG_MAPPED GetX86Mapped ( x86Reg Reg ) const { return m_x86reg_MappedTo[Reg]; } + uint32_t GetX86MapOrder ( x86Reg Reg ) const { return m_x86reg_MapOrder[Reg]; } + bool GetX86Protected ( x86Reg Reg ) const { return m_x86reg_Protected[Reg]; } + REG_MAPPED GetX86Mapped ( x86Reg Reg ) const { return m_x86reg_MappedTo[Reg]; } - DWORD GetBlockCycleCount() const { return m_CycleCount; } + uint32_t GetBlockCycleCount() const { return m_CycleCount; } - void SetMipsReg ( int Reg, unsigned __int64 Value ) { m_MIPS_RegVal[Reg].UDW = Value; } - void SetMipsReg_S ( int Reg, __int64 Value) { m_MIPS_RegVal[Reg].DW = Value; } - void SetMipsRegLo ( int Reg, DWORD Value ) { m_MIPS_RegVal[Reg].UW[0] = Value; } - void SetMipsRegHi ( int Reg, DWORD Value ) { m_MIPS_RegVal[Reg].UW[1] = Value; } - void SetMipsRegMapLo ( int GetMipsReg, x86Reg Reg ) { m_RegMapLo[GetMipsReg] = Reg; } - void SetMipsRegMapHi ( int GetMipsReg, x86Reg Reg ) { m_RegMapHi[GetMipsReg] = Reg; } - void SetMipsRegState ( int GetMipsReg, REG_STATE State ) { m_MIPS_RegState[GetMipsReg] = State; } + void SetMipsReg ( int32_t Reg, uint64_t Value ) { m_MIPS_RegVal[Reg].UDW = Value; } + void SetMipsReg_S ( int32_t Reg, int64_t Value) { m_MIPS_RegVal[Reg].DW = Value; } + void SetMipsRegLo ( int32_t Reg, uint32_t Value ) { m_MIPS_RegVal[Reg].UW[0] = Value; } + void SetMipsRegHi ( int32_t Reg, uint32_t Value ) { m_MIPS_RegVal[Reg].UW[1] = Value; } + void SetMipsRegMapLo ( int32_t GetMipsReg, x86Reg Reg ) { m_RegMapLo[GetMipsReg] = Reg; } + void SetMipsRegMapHi ( int32_t GetMipsReg, x86Reg Reg ) { m_RegMapHi[GetMipsReg] = Reg; } + void SetMipsRegState ( int32_t GetMipsReg, REG_STATE State ) { m_MIPS_RegState[GetMipsReg] = State; } - void SetX86MapOrder ( x86Reg Reg, DWORD Order ) { m_x86reg_MapOrder[Reg] = Order; } - void SetX86Protected ( x86Reg Reg, bool Protected ) { m_x86reg_Protected[Reg] = Protected; } - void SetX86Mapped ( x86Reg Reg, REG_MAPPED Mapping ) { m_x86reg_MappedTo[Reg] = Mapping; } + void SetX86MapOrder ( x86Reg Reg, uint32_t Order ) { m_x86reg_MapOrder[Reg] = Order; } + void SetX86Protected ( x86Reg Reg, bool Protected ) { m_x86reg_Protected[Reg] = Protected; } + void SetX86Mapped ( x86Reg Reg, REG_MAPPED Mapping ) { m_x86reg_MappedTo[Reg] = Mapping; } + void SetBlockCycleCount(uint32_t CyleCount) { m_CycleCount = CyleCount; } - void SetBlockCycleCount(DWORD CyleCount) { m_CycleCount = CyleCount; } + int32_t & StackTopPos() { return m_Stack_TopPos; } + int32_t & FpuMappedTo(int32_t Reg) { return m_x86fpu_MappedTo[Reg]; } + FPU_STATE & FpuState(int32_t Reg) { return m_x86fpu_State[Reg]; } + FPU_ROUND & FpuRoundingModel(int32_t Reg) { return m_x86fpu_RoundingModel[Reg]; } + bool & FpuBeenUsed() { return m_Fpu_Used; } - int & StackTopPos() { return m_Stack_TopPos; } - int & FpuMappedTo(int Reg) { return x86fpu_MappedTo[Reg]; } - FPU_STATE & FpuState(int Reg) { return x86fpu_State[Reg]; } - FPU_ROUND & FpuRoundingModel(int Reg) { return x86fpu_RoundingModel[Reg]; } - bool & FpuBeenUsed() { return m_Fpu_Used; } - - FPU_ROUND GetRoundingModel() const { return m_RoundingModel; } - void SetRoundingModel(FPU_ROUND RoundingModel) { m_RoundingModel = RoundingModel; } + FPU_ROUND GetRoundingModel() const { return m_RoundingModel; } + void SetRoundingModel(FPU_ROUND RoundingModel) { m_RoundingModel = RoundingModel; } private: - const char * RoundingModelName(FPU_ROUND RoundType); - x86Reg UnMap_8BitTempReg(); + const char * RoundingModelName(FPU_ROUND RoundType); + x86Reg UnMap_8BitTempReg(); - //r4k - REG_STATE m_MIPS_RegState[32]; - MIPS_DWORD m_MIPS_RegVal[32]; - x86Reg m_RegMapHi[32]; - x86Reg m_RegMapLo[32]; + //r4k + REG_STATE m_MIPS_RegState[32]; + MIPS_DWORD m_MIPS_RegVal[32]; + x86Reg m_RegMapHi[32]; + x86Reg m_RegMapLo[32]; - REG_MAPPED m_x86reg_MappedTo[10]; - DWORD m_x86reg_MapOrder[10]; - bool m_x86reg_Protected[10]; - - DWORD m_CycleCount; + REG_MAPPED m_x86reg_MappedTo[10]; + uint32_t m_x86reg_MapOrder[10]; + bool m_x86reg_Protected[10]; - //FPU - int m_Stack_TopPos; - int x86fpu_MappedTo[8]; - FPU_STATE x86fpu_State[8]; - bool x86fpu_StateChanged[8]; - FPU_ROUND x86fpu_RoundingModel[8]; - - bool m_Fpu_Used; - FPU_ROUND m_RoundingModel; - - static unsigned int m_fpuControl; + uint32_t m_CycleCount; + + //FPU + int32_t m_Stack_TopPos; + int32_t m_x86fpu_MappedTo[8]; + FPU_STATE m_x86fpu_State[8]; + bool m_x86fpu_StateChanged[8]; + FPU_ROUND m_x86fpu_RoundingModel[8]; + + bool m_Fpu_Used; + FPU_ROUND m_RoundingModel; + + static uint32_t m_fpuControl; }; From 8168dcc42ba24c241e150046a39e47da996bae01 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 Nov 2015 14:41:27 -0500 Subject: [PATCH 105/213] Match the type of `n' to source data type `size_t'. --- Source/Project64/N64 System/Mips/TLB class.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Project64/N64 System/Mips/TLB class.cpp b/Source/Project64/N64 System/Mips/TLB class.cpp index c9b095870..9b18ba001 100644 --- a/Source/Project64/N64 System/Mips/TLB class.cpp +++ b/Source/Project64/N64 System/Mips/TLB class.cpp @@ -303,7 +303,7 @@ void CTLB::RecordDifference( CLog &LogFile, const CTLB& rTLB) bool CTLB::operator == (const CTLB& rTLB) const { - for (int i = 0, n = sizeof(m_tlb)/sizeof(m_tlb[0]); i < n; i++) + for (size_t i = 0, n = sizeof(m_tlb)/sizeof(m_tlb[0]); i < n; i++) { if (m_tlb[i].EntryDefined != rTLB.m_tlb[i].EntryDefined) { From 9cc0465a102b586c457bd4fc9c1f6634aae7f974 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 Nov 2015 14:50:16 -0500 Subject: [PATCH 106/213] Re-express `/ sizeof(array[0])' as `/ sizeof(array_type)'. --- Source/Project64/N64 System/Mips/TLB class.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Project64/N64 System/Mips/TLB class.cpp b/Source/Project64/N64 System/Mips/TLB class.cpp index 9b18ba001..949f3fccc 100644 --- a/Source/Project64/N64 System/Mips/TLB class.cpp +++ b/Source/Project64/N64 System/Mips/TLB class.cpp @@ -303,7 +303,8 @@ void CTLB::RecordDifference( CLog &LogFile, const CTLB& rTLB) bool CTLB::operator == (const CTLB& rTLB) const { - for (size_t i = 0, n = sizeof(m_tlb)/sizeof(m_tlb[0]); i < n; i++) + const size_t n = sizeof(m_tlb) / sizeof(TLB_ENTRY); + for (size_t i = 0; i < n; i++) { if (m_tlb[i].EntryDefined != rTLB.m_tlb[i].EntryDefined) { From 23210e759a5fc625095a6b6fc9d3996a87e54cd2 Mon Sep 17 00:00:00 2001 From: zilmar Date: Tue, 10 Nov 2015 06:56:28 +1100 Subject: [PATCH 107/213] [Project64] Update Recompiler Ops.cpp to use standard types --- .../N64 System/Recompiler/Code Section.cpp | 6 +- .../N64 System/Recompiler/Jump Info.h | 27 +- .../N64 System/Recompiler/Recompiler Ops.cpp | 10968 +++++++++------- .../N64 System/Recompiler/Recompiler Ops.h | 580 +- 4 files changed, 6508 insertions(+), 5073 deletions(-) diff --git a/Source/Project64/N64 System/Recompiler/Code Section.cpp b/Source/Project64/N64 System/Recompiler/Code Section.cpp index 523edd003..aca74d90b 100644 --- a/Source/Project64/N64 System/Recompiler/Code Section.cpp +++ b/Source/Project64/N64 System/Recompiler/Code Section.cpp @@ -612,7 +612,7 @@ void CCodeSection::GenerateSectionLinkage() { JumpInfo[i]->FallThrough = false; JmpLabel32(JumpInfo[i]->BranchLabel.c_str(), 0); - JumpInfo[i]->LinkLocation = (DWORD*)(m_RecompPos - 4); + JumpInfo[i]->LinkLocation = (uint32_t*)(m_RecompPos - 4); } } } @@ -638,7 +638,7 @@ void CCodeSection::GenerateSectionLinkage() { JumpInfo[i]->FallThrough = false; JmpLabel32(JumpInfo[i]->BranchLabel.c_str(), 0); - JumpInfo[i]->LinkLocation = (DWORD *)(m_RecompPos - 4); + JumpInfo[i]->LinkLocation = (uint32_t *)(m_RecompPos - 4); } } @@ -2141,7 +2141,7 @@ bool CCodeSection::InheritParentInfo() Parent = ParentList[CurrentParent].Parent; JumpInfo = ParentList[CurrentParent].JumpInfo; JmpLabel32(Label.c_str(), 0); - JumpInfo->LinkLocation = (DWORD *)(m_RecompPos - 4); + JumpInfo->LinkLocation = (uint32_t *)(m_RecompPos - 4); JumpInfo->LinkLocation2 = NULL; CurrentParent = i; diff --git a/Source/Project64/N64 System/Recompiler/Jump Info.h b/Source/Project64/N64 System/Recompiler/Jump Info.h index 82f26c10c..9effed90e 100644 --- a/Source/Project64/N64 System/Recompiler/Jump Info.h +++ b/Source/Project64/N64 System/Recompiler/Jump Info.h @@ -10,20 +10,19 @@ ****************************************************************************/ #pragma once -class CJumpInfo +struct CJumpInfo { - typedef CExitInfo::EXIT_REASON EXIT_REASON; -public: - CJumpInfo(); + typedef CExitInfo::EXIT_REASON EXIT_REASON; + CJumpInfo(); - DWORD TargetPC; - DWORD JumpPC; - stdstr BranchLabel; - DWORD * LinkLocation; - DWORD * LinkLocation2; - bool FallThrough; - bool PermLoop; - bool DoneDelaySlot; //maybe deletable - CRegInfo RegSet; - EXIT_REASON ExitReason; + uint32_t TargetPC; + uint32_t JumpPC; + stdstr BranchLabel; + uint32_t * LinkLocation; + uint32_t * LinkLocation2; + bool FallThrough; + bool PermLoop; + bool DoneDelaySlot; //maybe deletable + CRegInfo RegSet; + EXIT_REASON ExitReason; }; diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp index 2fa6da89a..cfe6d5e67 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp @@ -13,5272 +13,6710 @@ CCodeSection * CRecompilerOps::m_Section = NULL; CRegInfo CRecompilerOps::m_RegWorkingSet; STEP_TYPE CRecompilerOps::m_NextInstruction; -DWORD CRecompilerOps::m_CompilePC; +uint32_t CRecompilerOps::m_CompilePC; OPCODE CRecompilerOps::m_Opcode; -DWORD CRecompilerOps::m_BranchCompare = 0; +uint32_t CRecompilerOps::m_BranchCompare = 0; -void CRecompilerOps::CompileReadTLBMiss (DWORD VirtualAddress, x86Reg LookUpReg ) +void CRecompilerOps::CompileReadTLBMiss(uint32_t VirtualAddress, x86Reg LookUpReg) { - MoveConstToVariable(VirtualAddress,g_TLBLoadAddress,"TLBLoadAddress"); - TestX86RegToX86Reg(LookUpReg,LookUpReg); - m_Section->CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, CExitInfo::TLBReadMiss, false, JeLabel32); + MoveConstToVariable(VirtualAddress, g_TLBLoadAddress, "TLBLoadAddress"); + TestX86RegToX86Reg(LookUpReg, LookUpReg); + m_Section->CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, CExitInfo::TLBReadMiss, false, JeLabel32); } -void CRecompilerOps::CompileReadTLBMiss (x86Reg AddressReg, x86Reg LookUpReg ) +void CRecompilerOps::CompileReadTLBMiss(x86Reg AddressReg, x86Reg LookUpReg) { - MoveX86regToVariable(AddressReg,g_TLBLoadAddress,"TLBLoadAddress"); - TestX86RegToX86Reg(LookUpReg,LookUpReg); - m_Section->CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, CExitInfo::TLBReadMiss, false, JeLabel32); + MoveX86regToVariable(AddressReg, g_TLBLoadAddress, "TLBLoadAddress"); + TestX86RegToX86Reg(LookUpReg, LookUpReg); + m_Section->CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, CExitInfo::TLBReadMiss, false, JeLabel32); } -void CRecompilerOps::CompileWriteTLBMiss (x86Reg AddressReg, x86Reg LookUpReg ) +void CRecompilerOps::CompileWriteTLBMiss(x86Reg AddressReg, x86Reg LookUpReg) { - MoveX86regToVariable(AddressReg,&g_TLBStoreAddress,"g_TLBStoreAddress"); - TestX86RegToX86Reg(LookUpReg,LookUpReg); - m_Section->CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, CExitInfo::TLBWriteMiss, false, JeLabel32); + MoveX86regToVariable(AddressReg, &g_TLBStoreAddress, "g_TLBStoreAddress"); + TestX86RegToX86Reg(LookUpReg, LookUpReg); + m_Section->CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, CExitInfo::TLBWriteMiss, false, JeLabel32); } bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2); /************************** Branch functions ************************/ -void CRecompilerOps::Compile_Branch (CRecompilerOps::BranchFunction CompareFunc, BRANCH_TYPE BranchType, bool Link) +void CRecompilerOps::Compile_Branch(CRecompilerOps::BranchFunction CompareFunc, BRANCH_TYPE BranchType, bool Link) { - static CRegInfo RegBeforeDelay; - static bool EffectDelaySlot; + static CRegInfo RegBeforeDelay; + static bool EffectDelaySlot; - if (m_NextInstruction == NORMAL) { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - if (m_CompilePC + ((short)m_Opcode.offset << 2) + 4 == m_CompilePC + 8) - return; + if (m_NextInstruction == NORMAL) + { + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - if ((m_CompilePC & 0xFFC) != 0xFFC) - { - switch (BranchType) { - case BranchTypeRs: EffectDelaySlot = DelaySlotEffectsCompare(m_CompilePC,m_Opcode.rs,0); break; - case BranchTypeRsRt: EffectDelaySlot = DelaySlotEffectsCompare(m_CompilePC,m_Opcode.rs,m_Opcode.rt); break; - case BranchTypeCop1: - { - OPCODE Command; + if (m_CompilePC + ((int16_t)m_Opcode.offset << 2) + 4 == m_CompilePC + 8) + { + return; + } - if (!g_MMU->LW_VAddr(m_CompilePC + 4, Command.Hex)) { - g_Notify->DisplayError(GS(MSG_FAIL_LOAD_WORD)); - ExitThread(0); - } - - EffectDelaySlot = false; - if (Command.op == R4300i_CP1) { - if (Command.fmt == R4300i_COP1_S && (Command.funct & 0x30) == 0x30) - EffectDelaySlot = true; + if ((m_CompilePC & 0xFFC) != 0xFFC) + { + switch (BranchType) + { + case BranchTypeRs: EffectDelaySlot = DelaySlotEffectsCompare(m_CompilePC, m_Opcode.rs, 0); break; + case BranchTypeRsRt: EffectDelaySlot = DelaySlotEffectsCompare(m_CompilePC, m_Opcode.rs, m_Opcode.rt); break; + case BranchTypeCop1: + { + OPCODE Command; - if (Command.fmt == R4300i_COP1_D && (Command.funct & 0x30) == 0x30) - EffectDelaySlot = true; - } - } - break; - default: - if (bHaveDebugger()) { g_Notify->DisplayError(L"Unknown branch type"); } - } - } else { - EffectDelaySlot = true; - } - m_Section->m_Jump.JumpPC = m_CompilePC; - m_Section->m_Jump.TargetPC = m_CompilePC + ((short)m_Opcode.offset << 2) + 4; - if (m_Section->m_JumpSection != NULL) { - m_Section->m_Jump.BranchLabel.Format("Section_%d",m_Section->m_JumpSection->m_SectionID); - } else { - m_Section->m_Jump.BranchLabel.Format("Exit_%X_jump_%X",m_Section->m_EnterPC,m_Section->m_Jump.TargetPC); - } - m_Section->m_Jump.LinkLocation = NULL; - m_Section->m_Jump.LinkLocation2 = NULL; - m_Section->m_Jump.DoneDelaySlot = false; - m_Section->m_Cont.JumpPC = m_CompilePC; - m_Section->m_Cont.TargetPC = m_CompilePC + 8; - if (m_Section->m_ContinueSection != NULL) { - m_Section->m_Cont.BranchLabel.Format("Section_%d",m_Section->m_ContinueSection->m_SectionID); - } else { - m_Section->m_Cont.BranchLabel.Format("Exit_%X_continue_%X",m_Section->m_EnterPC,m_Section->m_Cont.TargetPC); - } - m_Section->m_Cont.LinkLocation = NULL; - m_Section->m_Cont.LinkLocation2 = NULL; - m_Section->m_Cont.DoneDelaySlot = false; - if (m_Section->m_Jump.TargetPC < m_Section->m_Cont.TargetPC) { - m_Section->m_Cont.FallThrough = false; - m_Section->m_Jump.FallThrough = true; - } else { - m_Section->m_Cont.FallThrough = true; - m_Section->m_Jump.FallThrough = false; - } + if (!g_MMU->LW_VAddr(m_CompilePC + 4, Command.Hex)) + { + g_Notify->FatalError(GS(MSG_FAIL_LOAD_WORD)); + } - if (Link) { - UnMap_GPR(31, false); - m_RegWorkingSet.SetMipsRegLo(31,m_CompilePC + 8); - m_RegWorkingSet.SetMipsRegState(31,CRegInfo::STATE_CONST_32_SIGN); - } - if (EffectDelaySlot) { - if ((m_CompilePC & 0xFFC) != 0xFFC) - { - m_Section->m_Cont.BranchLabel = m_Section->m_ContinueSection != NULL ? "Continue" : "ExitBlock"; - m_Section->m_Jump.BranchLabel = m_Section->m_JumpSection != NULL ? "Jump" : "ExitBlock"; - } else { - m_Section->m_Cont.BranchLabel = "Continue"; - m_Section->m_Jump.BranchLabel = "Jump"; - } - if (m_Section->m_Jump.TargetPC != m_Section->m_Cont.TargetPC) - { - CompareFunc(); - } - if (!m_Section->m_Jump.FallThrough && !m_Section->m_Cont.FallThrough) { - if (m_Section->m_Jump.LinkLocation != NULL) { - CPU_Message(""); - CPU_Message(" %s:",m_Section->m_Jump.BranchLabel.c_str()); - SetJump32((uint32_t *)m_Section->m_Jump.LinkLocation,(uint32_t *)m_RecompPos); - m_Section->m_Jump.LinkLocation = NULL; - if (m_Section->m_Jump.LinkLocation2 != NULL) { - SetJump32((uint32_t *)m_Section->m_Jump.LinkLocation2,(uint32_t *)m_RecompPos); - m_Section->m_Jump.LinkLocation2 = NULL; - } - m_Section->m_Jump.FallThrough = true; - } else if (m_Section->m_Cont.LinkLocation != NULL){ - CPU_Message(""); - CPU_Message(" %s:",m_Section->m_Cont.BranchLabel.c_str()); - SetJump32((uint32_t *)m_Section->m_Cont.LinkLocation,(uint32_t *)m_RecompPos); - m_Section->m_Cont.LinkLocation = NULL; - if (m_Section->m_Cont.LinkLocation2 != NULL) { - SetJump32((uint32_t *)m_Section->m_Cont.LinkLocation2,(uint32_t *)m_RecompPos); - m_Section->m_Cont.LinkLocation2 = NULL; - } - m_Section->m_Cont.FallThrough = true; - } - } - if ((m_CompilePC & 0xFFC) == 0xFFC) - { - BYTE * DelayLinkLocation = NULL; - if (m_Section->m_Jump.FallThrough) - { - if (m_Section->m_Jump.LinkLocation != NULL || m_Section->m_Jump.LinkLocation2 != NULL) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - MoveConstToVariable(m_Section->m_Jump.TargetPC,&R4300iOp::m_JumpToLocation,"R4300iOp::m_JumpToLocation"); - } - else if (m_Section->m_Cont.FallThrough) - { - if (m_Section->m_Cont.LinkLocation != NULL || m_Section->m_Cont.LinkLocation2 != NULL) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - MoveConstToVariable(m_Section->m_Cont.TargetPC,&R4300iOp::m_JumpToLocation,"R4300iOp::m_JumpToLocation"); - } - - if (m_Section->m_Jump.LinkLocation != NULL || m_Section->m_Jump.LinkLocation2 != NULL) - { - JmpLabel8("DoDelaySlot",0); - if (DelayLinkLocation != NULL) { g_Notify->BreakPoint(__FILEW__,__LINE__); } - DelayLinkLocation = (BYTE *)(m_RecompPos - 1); + EffectDelaySlot = false; + if (Command.op == R4300i_CP1) + { + if ((Command.fmt == R4300i_COP1_S && (Command.funct & 0x30) == 0x30) || + (Command.fmt == R4300i_COP1_D && (Command.funct & 0x30) == 0x30)) + { + EffectDelaySlot = true; + } + } + } + break; + default: + if (bHaveDebugger()) { g_Notify->DisplayError(L"Unknown branch type"); } + } + } + else + { + EffectDelaySlot = true; + } + m_Section->m_Jump.JumpPC = m_CompilePC; + m_Section->m_Jump.TargetPC = m_CompilePC + ((int16_t)m_Opcode.offset << 2) + 4; + if (m_Section->m_JumpSection != NULL) + { + m_Section->m_Jump.BranchLabel.Format("Section_%d", m_Section->m_JumpSection->m_SectionID); + } + else + { + m_Section->m_Jump.BranchLabel.Format("Exit_%X_jump_%X", m_Section->m_EnterPC, m_Section->m_Jump.TargetPC); + } + m_Section->m_Jump.LinkLocation = NULL; + m_Section->m_Jump.LinkLocation2 = NULL; + m_Section->m_Jump.DoneDelaySlot = false; + m_Section->m_Cont.JumpPC = m_CompilePC; + m_Section->m_Cont.TargetPC = m_CompilePC + 8; + if (m_Section->m_ContinueSection != NULL) + { + m_Section->m_Cont.BranchLabel.Format("Section_%d", m_Section->m_ContinueSection->m_SectionID); + } + else + { + m_Section->m_Cont.BranchLabel.Format("Exit_%X_continue_%X", m_Section->m_EnterPC, m_Section->m_Cont.TargetPC); + } + m_Section->m_Cont.LinkLocation = NULL; + m_Section->m_Cont.LinkLocation2 = NULL; + m_Section->m_Cont.DoneDelaySlot = false; + if (m_Section->m_Jump.TargetPC < m_Section->m_Cont.TargetPC) + { + m_Section->m_Cont.FallThrough = false; + m_Section->m_Jump.FallThrough = true; + } + else + { + m_Section->m_Cont.FallThrough = true; + m_Section->m_Jump.FallThrough = false; + } - CPU_Message(" "); - CPU_Message(" %s:",m_Section->m_Jump.BranchLabel.c_str()); - SetJump32((uint32_t *)m_Section->m_Jump.LinkLocation,(uint32_t *)m_RecompPos); - m_Section->m_Jump.LinkLocation = NULL; - if (m_Section->m_Jump.LinkLocation2 != NULL) { - SetJump32((uint32_t *)m_Section->m_Jump.LinkLocation2,(uint32_t *)m_RecompPos); - m_Section->m_Jump.LinkLocation2 = NULL; - } - MoveConstToVariable(m_Section->m_Jump.TargetPC,&R4300iOp::m_JumpToLocation,"R4300iOp::m_JumpToLocation"); - } - if (m_Section->m_Cont.LinkLocation != NULL || m_Section->m_Cont.LinkLocation2 != NULL) - { - JmpLabel8("DoDelaySlot",0); - if (DelayLinkLocation != NULL) { g_Notify->BreakPoint(__FILEW__,__LINE__); } - DelayLinkLocation = (BYTE *)(m_RecompPos - 1); + if (Link) + { + UnMap_GPR(31, false); + m_RegWorkingSet.SetMipsRegLo(31, m_CompilePC + 8); + m_RegWorkingSet.SetMipsRegState(31, CRegInfo::STATE_CONST_32_SIGN); + } + if (EffectDelaySlot) + { + if ((m_CompilePC & 0xFFC) != 0xFFC) + { + m_Section->m_Cont.BranchLabel = m_Section->m_ContinueSection != NULL ? "Continue" : "ExitBlock"; + m_Section->m_Jump.BranchLabel = m_Section->m_JumpSection != NULL ? "Jump" : "ExitBlock"; + } + else + { + m_Section->m_Cont.BranchLabel = "Continue"; + m_Section->m_Jump.BranchLabel = "Jump"; + } + if (m_Section->m_Jump.TargetPC != m_Section->m_Cont.TargetPC) + { + CompareFunc(); + } + if (!m_Section->m_Jump.FallThrough && !m_Section->m_Cont.FallThrough) + { + if (m_Section->m_Jump.LinkLocation != NULL) + { + CPU_Message(""); + CPU_Message(" %s:", m_Section->m_Jump.BranchLabel.c_str()); + SetJump32((uint32_t *)m_Section->m_Jump.LinkLocation, (uint32_t *)m_RecompPos); + m_Section->m_Jump.LinkLocation = NULL; + if (m_Section->m_Jump.LinkLocation2 != NULL) + { + SetJump32((uint32_t *)m_Section->m_Jump.LinkLocation2, (uint32_t *)m_RecompPos); + m_Section->m_Jump.LinkLocation2 = NULL; + } + m_Section->m_Jump.FallThrough = true; + } + else if (m_Section->m_Cont.LinkLocation != NULL) + { + CPU_Message(""); + CPU_Message(" %s:", m_Section->m_Cont.BranchLabel.c_str()); + SetJump32((uint32_t *)m_Section->m_Cont.LinkLocation, (uint32_t *)m_RecompPos); + m_Section->m_Cont.LinkLocation = NULL; + if (m_Section->m_Cont.LinkLocation2 != NULL) + { + SetJump32((uint32_t *)m_Section->m_Cont.LinkLocation2, (uint32_t *)m_RecompPos); + m_Section->m_Cont.LinkLocation2 = NULL; + } + m_Section->m_Cont.FallThrough = true; + } + } + if ((m_CompilePC & 0xFFC) == 0xFFC) + { + uint8_t * DelayLinkLocation = NULL; + if (m_Section->m_Jump.FallThrough) + { + if (m_Section->m_Jump.LinkLocation != NULL || m_Section->m_Jump.LinkLocation2 != NULL) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + MoveConstToVariable(m_Section->m_Jump.TargetPC, &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); + } + else if (m_Section->m_Cont.FallThrough) + { + if (m_Section->m_Cont.LinkLocation != NULL || m_Section->m_Cont.LinkLocation2 != NULL) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + MoveConstToVariable(m_Section->m_Cont.TargetPC, &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); + } - CPU_Message(" "); - CPU_Message(" %s:",m_Section->m_Cont.BranchLabel.c_str()); - SetJump32((uint32_t *)m_Section->m_Cont.LinkLocation,(uint32_t *)m_RecompPos); - m_Section->m_Cont.LinkLocation = NULL; - if (m_Section->m_Cont.LinkLocation2 != NULL) { - SetJump32((uint32_t *)m_Section->m_Cont.LinkLocation2,(uint32_t *)m_RecompPos); - m_Section->m_Cont.LinkLocation2 = NULL; - } - MoveConstToVariable(m_Section->m_Cont.TargetPC,&R4300iOp::m_JumpToLocation,"R4300iOp::m_JumpToLocation"); - } - if (DelayLinkLocation) - { - CPU_Message(""); - CPU_Message(" DoDelaySlot:"); - SetJump8(DelayLinkLocation,m_RecompPos); - } - OverflowDelaySlot(false); - return; - } - ResetX86Protection(); - RegBeforeDelay = m_RegWorkingSet; - } - m_NextInstruction = DO_DELAY_SLOT; - } else if (m_NextInstruction == DELAY_SLOT_DONE ) { - if (EffectDelaySlot) { - CJumpInfo * FallInfo = m_Section->m_Jump.FallThrough?&m_Section->m_Jump:&m_Section->m_Cont; - CJumpInfo * JumpInfo = m_Section->m_Jump.FallThrough?&m_Section->m_Cont:&m_Section->m_Jump; + if (m_Section->m_Jump.LinkLocation != NULL || m_Section->m_Jump.LinkLocation2 != NULL) + { + JmpLabel8("DoDelaySlot", 0); + if (DelayLinkLocation != NULL) { g_Notify->BreakPoint(__FILEW__, __LINE__); } + DelayLinkLocation = (uint8_t *)(m_RecompPos - 1); - if (FallInfo->FallThrough && !FallInfo->DoneDelaySlot) { - ResetX86Protection(); - FallInfo->RegSet = m_RegWorkingSet; - if (FallInfo == &m_Section->m_Jump) { - if (m_Section->m_JumpSection != NULL) { - m_Section->m_Jump.BranchLabel.Format("Section_%d",m_Section->m_JumpSection->m_SectionID); - } else { - m_Section->m_Jump.BranchLabel = "ExitBlock"; - } - if (FallInfo->TargetPC <= m_CompilePC) - { - UpdateCounters(m_Section->m_Jump.RegSet,true,true); - CPU_Message("CompileSystemCheck 12"); - CompileSystemCheck(FallInfo->TargetPC,m_Section->m_Jump.RegSet); - ResetX86Protection(); - FallInfo->ExitReason = CExitInfo::Normal_NoSysCheck; - FallInfo->JumpPC = (DWORD)-1; - } - } else { - if (m_Section->m_ContinueSection != NULL) { - m_Section->m_Cont.BranchLabel.Format("Section_%d",m_Section->m_ContinueSection->m_SectionID); - } else { - m_Section->m_Cont.BranchLabel = "ExitBlock"; - } - } - FallInfo->DoneDelaySlot = true; - if (!JumpInfo->DoneDelaySlot) { - FallInfo->FallThrough = false; - JmpLabel32(FallInfo->BranchLabel.c_str(),0); - FallInfo->LinkLocation = (DWORD *)(m_RecompPos - 4); - - if (JumpInfo->LinkLocation != NULL) { - CPU_Message(" %s:",JumpInfo->BranchLabel.c_str()); - SetJump32((uint32_t *)JumpInfo->LinkLocation,(uint32_t *)m_RecompPos); - JumpInfo->LinkLocation = NULL; - if (JumpInfo->LinkLocation2 != NULL) { - SetJump32((uint32_t *)JumpInfo->LinkLocation2,(uint32_t *)m_RecompPos); - JumpInfo->LinkLocation2 = NULL; - } - JumpInfo->FallThrough = true; - m_NextInstruction = DO_DELAY_SLOT; - m_RegWorkingSet = RegBeforeDelay; - return; - } - } - } - } else { - if (m_Section->m_Jump.TargetPC != m_Section->m_Cont.TargetPC) - { - CompareFunc(); - ResetX86Protection(); - m_Section->m_Cont.RegSet = m_RegWorkingSet; - m_Section->m_Jump.RegSet = m_RegWorkingSet; - } else { - m_Section->m_Jump.FallThrough = false; - m_Section->m_Cont.FallThrough = true; - m_Section->m_Cont.RegSet = m_RegWorkingSet; - if (m_Section->m_ContinueSection == NULL && m_Section->m_JumpSection != NULL) - { - m_Section->m_ContinueSection = m_Section->m_JumpSection; - m_Section->m_JumpSection = NULL; - } - if (m_Section->m_ContinueSection != NULL) { - m_Section->m_Cont.BranchLabel.Format("Section_%d",m_Section->m_ContinueSection->m_SectionID); - } else { - m_Section->m_Cont.BranchLabel = "ExitBlock"; - } - } - } - m_Section->GenerateSectionLinkage(); - m_NextInstruction = END_BLOCK; - } else { - if (bHaveDebugger()) - { - g_Notify->DisplayError(stdstr_f("WTF\n\nBranch\nNextInstruction = %X", m_NextInstruction).ToUTF16().c_str()); - } - } + CPU_Message(" "); + CPU_Message(" %s:", m_Section->m_Jump.BranchLabel.c_str()); + SetJump32(m_Section->m_Jump.LinkLocation, (uint32_t *)m_RecompPos); + m_Section->m_Jump.LinkLocation = NULL; + if (m_Section->m_Jump.LinkLocation2 != NULL) + { + SetJump32(m_Section->m_Jump.LinkLocation2, (uint32_t *)m_RecompPos); + m_Section->m_Jump.LinkLocation2 = NULL; + } + MoveConstToVariable(m_Section->m_Jump.TargetPC, &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); + } + if (m_Section->m_Cont.LinkLocation != NULL || m_Section->m_Cont.LinkLocation2 != NULL) + { + JmpLabel8("DoDelaySlot", 0); + if (DelayLinkLocation != NULL) { g_Notify->BreakPoint(__FILEW__, __LINE__); } + DelayLinkLocation = (uint8_t *)(m_RecompPos - 1); + + CPU_Message(" "); + CPU_Message(" %s:", m_Section->m_Cont.BranchLabel.c_str()); + SetJump32(m_Section->m_Cont.LinkLocation, (uint32_t *)m_RecompPos); + m_Section->m_Cont.LinkLocation = NULL; + if (m_Section->m_Cont.LinkLocation2 != NULL) + { + SetJump32(m_Section->m_Cont.LinkLocation2, (uint32_t *)m_RecompPos); + m_Section->m_Cont.LinkLocation2 = NULL; + } + MoveConstToVariable(m_Section->m_Cont.TargetPC, &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); + } + if (DelayLinkLocation) + { + CPU_Message(""); + CPU_Message(" DoDelaySlot:"); + SetJump8(DelayLinkLocation, m_RecompPos); + } + OverflowDelaySlot(false); + return; + } + ResetX86Protection(); + RegBeforeDelay = m_RegWorkingSet; + } + m_NextInstruction = DO_DELAY_SLOT; + } + else if (m_NextInstruction == DELAY_SLOT_DONE) + { + if (EffectDelaySlot) + { + CJumpInfo * FallInfo = m_Section->m_Jump.FallThrough ? &m_Section->m_Jump : &m_Section->m_Cont; + CJumpInfo * JumpInfo = m_Section->m_Jump.FallThrough ? &m_Section->m_Cont : &m_Section->m_Jump; + + if (FallInfo->FallThrough && !FallInfo->DoneDelaySlot) + { + ResetX86Protection(); + FallInfo->RegSet = m_RegWorkingSet; + if (FallInfo == &m_Section->m_Jump) + { + if (m_Section->m_JumpSection != NULL) + { + m_Section->m_Jump.BranchLabel.Format("Section_%d", m_Section->m_JumpSection->m_SectionID); + } + else + { + m_Section->m_Jump.BranchLabel = "ExitBlock"; + } + if (FallInfo->TargetPC <= m_CompilePC) + { + UpdateCounters(m_Section->m_Jump.RegSet, true, true); + CPU_Message("CompileSystemCheck 12"); + CompileSystemCheck(FallInfo->TargetPC, m_Section->m_Jump.RegSet); + ResetX86Protection(); + FallInfo->ExitReason = CExitInfo::Normal_NoSysCheck; + FallInfo->JumpPC = (uint32_t)-1; + } + } + else + { + if (m_Section->m_ContinueSection != NULL) + { + m_Section->m_Cont.BranchLabel.Format("Section_%d", m_Section->m_ContinueSection->m_SectionID); + } + else + { + m_Section->m_Cont.BranchLabel = "ExitBlock"; + } + } + FallInfo->DoneDelaySlot = true; + if (!JumpInfo->DoneDelaySlot) + { + FallInfo->FallThrough = false; + JmpLabel32(FallInfo->BranchLabel.c_str(), 0); + FallInfo->LinkLocation = (uint32_t *)(m_RecompPos - 4); + + if (JumpInfo->LinkLocation != NULL) + { + CPU_Message(" %s:", JumpInfo->BranchLabel.c_str()); + SetJump32((uint32_t *)JumpInfo->LinkLocation, (uint32_t *)m_RecompPos); + JumpInfo->LinkLocation = NULL; + if (JumpInfo->LinkLocation2 != NULL) + { + SetJump32((uint32_t *)JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos); + JumpInfo->LinkLocation2 = NULL; + } + JumpInfo->FallThrough = true; + m_NextInstruction = DO_DELAY_SLOT; + m_RegWorkingSet = RegBeforeDelay; + return; + } + } + } + } + else + { + if (m_Section->m_Jump.TargetPC != m_Section->m_Cont.TargetPC) + { + CompareFunc(); + ResetX86Protection(); + m_Section->m_Cont.RegSet = m_RegWorkingSet; + m_Section->m_Jump.RegSet = m_RegWorkingSet; + } + else + { + m_Section->m_Jump.FallThrough = false; + m_Section->m_Cont.FallThrough = true; + m_Section->m_Cont.RegSet = m_RegWorkingSet; + if (m_Section->m_ContinueSection == NULL && m_Section->m_JumpSection != NULL) + { + m_Section->m_ContinueSection = m_Section->m_JumpSection; + m_Section->m_JumpSection = NULL; + } + if (m_Section->m_ContinueSection != NULL) + { + m_Section->m_Cont.BranchLabel.Format("Section_%d", m_Section->m_ContinueSection->m_SectionID); + } + else + { + m_Section->m_Cont.BranchLabel = "ExitBlock"; + } + } + } + m_Section->GenerateSectionLinkage(); + m_NextInstruction = END_BLOCK; + } + else + { + if (bHaveDebugger()) + { + g_Notify->DisplayError(stdstr_f("WTF\n\nBranch\nNextInstruction = %X", m_NextInstruction).ToUTF16().c_str()); + } + } } -void CRecompilerOps::Compile_BranchLikely (BranchFunction CompareFunc, bool Link) +void CRecompilerOps::Compile_BranchLikely(BranchFunction CompareFunc, bool Link) { - if (m_NextInstruction == NORMAL) { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - if (!g_System->bLinkBlocks() || (m_CompilePC & 0xFFC) == 0xFFC) - { - m_Section->m_Jump.JumpPC = m_CompilePC; - m_Section->m_Jump.TargetPC = m_CompilePC + ((short)m_Opcode.offset << 2) + 4; - m_Section->m_Cont.JumpPC = m_CompilePC; - m_Section->m_Cont.TargetPC = m_CompilePC + 8; - } - else - { - if (m_Section->m_Jump.JumpPC != m_CompilePC) - g_Notify->BreakPoint(__FILEW__,__LINE__); + if (m_NextInstruction == NORMAL) + { + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - if (m_Section->m_Cont.JumpPC != m_CompilePC) - g_Notify->BreakPoint(__FILEW__,__LINE__); + if (!g_System->bLinkBlocks() || (m_CompilePC & 0xFFC) == 0xFFC) + { + m_Section->m_Jump.JumpPC = m_CompilePC; + m_Section->m_Jump.TargetPC = m_CompilePC + ((int16_t)m_Opcode.offset << 2) + 4; + m_Section->m_Cont.JumpPC = m_CompilePC; + m_Section->m_Cont.TargetPC = m_CompilePC + 8; + } + else + { + if (m_Section->m_Jump.JumpPC != m_CompilePC) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + if (m_Section->m_Cont.JumpPC != m_CompilePC) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + if (m_Section->m_Cont.TargetPC != m_CompilePC + 8) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } - if (m_Section->m_Cont.TargetPC != m_CompilePC + 8) - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + if (m_Section->m_JumpSection != NULL) + { + m_Section->m_Jump.BranchLabel.Format("Section_%d", ((CCodeSection *)m_Section->m_JumpSection)->m_SectionID); + } + else + { + m_Section->m_Jump.BranchLabel = "ExitBlock"; + } - if (m_Section->m_JumpSection != NULL) - m_Section->m_Jump.BranchLabel.Format("Section_%d",((CCodeSection *)m_Section->m_JumpSection)->m_SectionID); - else - m_Section->m_Jump.BranchLabel = "ExitBlock"; + if (m_Section->m_ContinueSection != NULL) + { + m_Section->m_Cont.BranchLabel.Format("Section_%d", ((CCodeSection *)m_Section->m_ContinueSection)->m_SectionID); + } + else + { + m_Section->m_Cont.BranchLabel = "ExitBlock"; + } - if (m_Section->m_ContinueSection != NULL) - m_Section->m_Cont.BranchLabel.Format("Section_%d",((CCodeSection *)m_Section->m_ContinueSection)->m_SectionID); - else - m_Section->m_Cont.BranchLabel = "ExitBlock"; + m_Section->m_Jump.FallThrough = true; + m_Section->m_Jump.LinkLocation = NULL; + m_Section->m_Jump.LinkLocation2 = NULL; + m_Section->m_Cont.FallThrough = false; + m_Section->m_Cont.LinkLocation = NULL; + m_Section->m_Cont.LinkLocation2 = NULL; - m_Section->m_Jump.FallThrough = true; - m_Section->m_Jump.LinkLocation = NULL; - m_Section->m_Jump.LinkLocation2 = NULL; - m_Section->m_Cont.FallThrough = false; - m_Section->m_Cont.LinkLocation = NULL; - m_Section->m_Cont.LinkLocation2 = NULL; + if (Link) + { + UnMap_GPR(31, false); + m_RegWorkingSet.SetMipsRegLo(31, m_CompilePC + 8); + m_RegWorkingSet.SetMipsRegState(31, CRegInfo::STATE_CONST_32_SIGN); + } - if (Link) - { - UnMap_GPR(31, false); - m_RegWorkingSet.SetMipsRegLo(31, m_CompilePC + 8); - m_RegWorkingSet.SetMipsRegState(31,CRegInfo::STATE_CONST_32_SIGN); - } + CompareFunc(); + ResetX86Protection(); - CompareFunc(); - ResetX86Protection(); + m_Section->m_Cont.RegSet = m_RegWorkingSet; + if ((m_CompilePC & 0xFFC) == 0xFFC) + { + if (m_Section->m_Cont.FallThrough) + { + if (m_Section->m_Jump.LinkLocation != NULL) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } - m_Section->m_Cont.RegSet = m_RegWorkingSet; - if ((m_CompilePC & 0xFFC) == 0xFFC) - { - if (m_Section->m_Cont.FallThrough) - { - if (m_Section->m_Jump.LinkLocation != NULL) - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + if (m_Section->m_Jump.LinkLocation != NULL || m_Section->m_Jump.FallThrough) + { + if (m_Section->m_Jump.LinkLocation != NULL) + { + SetJump32(m_Section->m_Jump.LinkLocation, (uint32_t *)m_RecompPos); + m_Section->m_Jump.LinkLocation = NULL; + if (m_Section->m_Jump.LinkLocation2 != NULL) + { + SetJump32(m_Section->m_Jump.LinkLocation2, (uint32_t *)m_RecompPos); + m_Section->m_Jump.LinkLocation2 = NULL; + } + } - if (m_Section->m_Jump.LinkLocation != NULL || m_Section->m_Jump.FallThrough) - { - if (m_Section->m_Jump.LinkLocation != NULL) { - SetJump32((uint32_t *)m_Section->m_Jump.LinkLocation,(uint32_t *)m_RecompPos); - m_Section->m_Jump.LinkLocation = NULL; - if (m_Section->m_Jump.LinkLocation2 != NULL) { - SetJump32((uint32_t *)m_Section->m_Jump.LinkLocation2,(uint32_t *)m_RecompPos); - m_Section->m_Jump.LinkLocation2 = NULL; - } - } - - MoveConstToVariable(m_Section->m_Jump.TargetPC,&R4300iOp::m_JumpToLocation,"R4300iOp::m_JumpToLocation"); - OverflowDelaySlot(false); - CPU_Message(" "); - CPU_Message(" %s:",m_Section->m_Cont.BranchLabel.c_str()); - } else if (!m_Section->m_Cont.FallThrough) { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + MoveConstToVariable(m_Section->m_Jump.TargetPC, &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); + OverflowDelaySlot(false); + CPU_Message(" "); + CPU_Message(" %s:", m_Section->m_Cont.BranchLabel.c_str()); + } + else if (!m_Section->m_Cont.FallThrough) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } - if (m_Section->m_Cont.LinkLocation != NULL) { - SetJump32((uint32_t *)m_Section->m_Cont.LinkLocation,(uint32_t *)m_RecompPos); - m_Section->m_Cont.LinkLocation = NULL; - if (m_Section->m_Cont.LinkLocation2 != NULL) { - SetJump32((uint32_t *)m_Section->m_Cont.LinkLocation2,(uint32_t *)m_RecompPos); - m_Section->m_Cont.LinkLocation2 = NULL; - } - } - m_Section->CompileExit(m_CompilePC, m_CompilePC + 8, m_Section->m_Cont.RegSet, CExitInfo::Normal, true, NULL); - return; - } else { - m_NextInstruction = DO_DELAY_SLOT; - } + if (m_Section->m_Cont.LinkLocation != NULL) + { + SetJump32(m_Section->m_Cont.LinkLocation, (uint32_t *)m_RecompPos); + m_Section->m_Cont.LinkLocation = NULL; + if (m_Section->m_Cont.LinkLocation2 != NULL) + { + SetJump32(m_Section->m_Cont.LinkLocation2, (uint32_t *)m_RecompPos); + m_Section->m_Cont.LinkLocation2 = NULL; + } + } + m_Section->CompileExit(m_CompilePC, m_CompilePC + 8, m_Section->m_Cont.RegSet, CExitInfo::Normal, true, NULL); + return; + } + else + { + m_NextInstruction = DO_DELAY_SLOT; + } - if (g_System->bLinkBlocks()) - { - m_Section->m_Jump.RegSet = m_RegWorkingSet; - m_Section->GenerateSectionLinkage(); - m_NextInstruction = END_BLOCK; - } else { - if (m_Section->m_Cont.FallThrough) - { - if (m_Section->m_Jump.LinkLocation != NULL) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - m_Section->GenerateSectionLinkage(); - m_NextInstruction = END_BLOCK; - } - } - } else if (m_NextInstruction == DELAY_SLOT_DONE ) { - ResetX86Protection(); - m_Section->m_Jump.RegSet = m_RegWorkingSet; - m_Section->GenerateSectionLinkage(); - m_NextInstruction = END_BLOCK; - } else if (bHaveDebugger()) { - g_Notify->DisplayError(stdstr_f("WTF\n\nBranchLikely\nNextInstruction = %X", m_NextInstruction).ToUTF16().c_str()); - } + if (g_System->bLinkBlocks()) + { + m_Section->m_Jump.RegSet = m_RegWorkingSet; + m_Section->GenerateSectionLinkage(); + m_NextInstruction = END_BLOCK; + } + else + { + if (m_Section->m_Cont.FallThrough) + { + if (m_Section->m_Jump.LinkLocation != NULL) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + m_Section->GenerateSectionLinkage(); + m_NextInstruction = END_BLOCK; + } + } + } + else if (m_NextInstruction == DELAY_SLOT_DONE) + { + ResetX86Protection(); + m_Section->m_Jump.RegSet = m_RegWorkingSet; + m_Section->GenerateSectionLinkage(); + m_NextInstruction = END_BLOCK; + } + else if (bHaveDebugger()) + { + g_Notify->DisplayError(stdstr_f("WTF\n\nBranchLikely\nNextInstruction = %X", m_NextInstruction).ToUTF16().c_str()); + } } void CRecompilerOps::BNE_Compare() { - BYTE *Jump = NULL; + uint8_t *Jump = NULL; - if (IsKnown(m_Opcode.rs) && IsKnown(m_Opcode.rt)) { - if (IsConst(m_Opcode.rs) && IsConst(m_Opcode.rt)) { - if (Is64Bit(m_Opcode.rs) || Is64Bit(m_Opcode.rt)) { - CRecompilerOps::UnknownOpcode(); - } else if (GetMipsRegLo(m_Opcode.rs) != GetMipsRegLo(m_Opcode.rt)) { - m_Section->m_Jump.FallThrough = true; - m_Section->m_Cont.FallThrough = false; - } else { - m_Section->m_Jump.FallThrough = false; - m_Section->m_Cont.FallThrough = true; - } - } else if (IsMapped(m_Opcode.rs) && IsMapped(m_Opcode.rt)) { - ProtectGPR(m_Opcode.rs); - ProtectGPR(m_Opcode.rt); - if (Is64Bit(m_Opcode.rs) || Is64Bit(m_Opcode.rt)) - { - CompX86RegToX86Reg( - Is32Bit(m_Opcode.rs) ? Map_TempReg(x86_Any, m_Opcode.rs, true) : GetMipsRegMapHi(m_Opcode.rs), - Is32Bit(m_Opcode.rt) ? Map_TempReg(x86_Any, m_Opcode.rt, true) : GetMipsRegMapHi(m_Opcode.rt) - ); - - if (m_Section->m_Jump.FallThrough) { - JneLabel8("continue",0); - Jump = m_RecompPos - 1; - } else { - JneLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - CompX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rs),GetMipsRegMapLo(m_Opcode.rt)); - if (m_Section->m_Cont.FallThrough) { - JneLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); - m_Section->m_Jump.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - } else if (m_Section->m_Jump.FallThrough) { - JeLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - CPU_Message(" "); - CPU_Message(" continue:"); - SetJump8(Jump,m_RecompPos); - } else { - JeLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - } - } else { - CompX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rs),GetMipsRegMapLo(m_Opcode.rt)); - if (m_Section->m_Cont.FallThrough) { - JneLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else if (m_Section->m_Jump.FallThrough) { - JeLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - JeLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } - } else { - DWORD ConstReg = IsConst(m_Opcode.rt)?m_Opcode.rt:m_Opcode.rs; - DWORD MappedReg = IsConst(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; + if (IsKnown(m_Opcode.rs) && IsKnown(m_Opcode.rt)) + { + if (IsConst(m_Opcode.rs) && IsConst(m_Opcode.rt)) + { + if (Is64Bit(m_Opcode.rs) || Is64Bit(m_Opcode.rt)) + { + CRecompilerOps::UnknownOpcode(); + } + else if (GetMipsRegLo(m_Opcode.rs) != GetMipsRegLo(m_Opcode.rt)) + { + m_Section->m_Jump.FallThrough = true; + m_Section->m_Cont.FallThrough = false; + } + else + { + m_Section->m_Jump.FallThrough = false; + m_Section->m_Cont.FallThrough = true; + } + } + else if (IsMapped(m_Opcode.rs) && IsMapped(m_Opcode.rt)) + { + ProtectGPR(m_Opcode.rs); + ProtectGPR(m_Opcode.rt); + if (Is64Bit(m_Opcode.rs) || Is64Bit(m_Opcode.rt)) + { + CompX86RegToX86Reg( + Is32Bit(m_Opcode.rs) ? Map_TempReg(x86_Any, m_Opcode.rs, true) : GetMipsRegMapHi(m_Opcode.rs), + Is32Bit(m_Opcode.rt) ? Map_TempReg(x86_Any, m_Opcode.rt, true) : GetMipsRegMapHi(m_Opcode.rt) + ); - if (Is64Bit(ConstReg) || Is64Bit(MappedReg)) { - if (Is32Bit(ConstReg) || Is32Bit(MappedReg)) { - ProtectGPR(MappedReg); - if (Is32Bit(MappedReg)) { - CompConstToX86reg(Map_TempReg(x86_Any, MappedReg, true), GetMipsRegHi(ConstReg)); - } else { - CompConstToX86reg(GetMipsRegMapHi(MappedReg),GetMipsRegLo_S(ConstReg) >> 31); - } - } else { - CompConstToX86reg(GetMipsRegMapHi(MappedReg),GetMipsRegHi(ConstReg)); - } - if (m_Section->m_Jump.FallThrough) { - JneLabel8("continue",0); - Jump = m_RecompPos - 1; - } else { - JneLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - CompConstToX86reg(GetMipsRegMapLo(MappedReg),GetMipsRegLo(ConstReg)); - if (m_Section->m_Cont.FallThrough) { - JneLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); - m_Section->m_Jump.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - } else if (m_Section->m_Jump.FallThrough) { - JeLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - CPU_Message(" "); - CPU_Message(" continue:"); - SetJump8(Jump,m_RecompPos); - } else { - JeLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - } - } else { - CompConstToX86reg(GetMipsRegMapLo(MappedReg),GetMipsRegLo(ConstReg)); - if (m_Section->m_Cont.FallThrough) { - JneLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else if (m_Section->m_Jump.FallThrough) { - JeLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - JeLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } - } - } else if (IsKnown(m_Opcode.rs) || IsKnown(m_Opcode.rt)) { - DWORD KnownReg = IsKnown(m_Opcode.rt)?m_Opcode.rt:m_Opcode.rs; - DWORD UnknownReg = IsKnown(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; + if (m_Section->m_Jump.FallThrough) + { + JneLabel8("continue", 0); + Jump = m_RecompPos - 1; + } + else + { + JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + CompX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); + if (m_Section->m_Cont.FallThrough) + { + JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + } + else if (m_Section->m_Jump.FallThrough) + { + JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + CPU_Message(" "); + CPU_Message(" continue:"); + SetJump8(Jump, m_RecompPos); + } + else + { + JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + } + } + else + { + CompX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); + if (m_Section->m_Cont.FallThrough) + { + JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else if (m_Section->m_Jump.FallThrough) + { + JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } + } + else + { + uint32_t ConstReg = IsConst(m_Opcode.rt) ? m_Opcode.rt : m_Opcode.rs; + uint32_t MappedReg = IsConst(m_Opcode.rt) ? m_Opcode.rs : m_Opcode.rt; - if (!g_System->b32BitCore()) - { - if (IsConst(KnownReg)) { - if (Is64Bit(KnownReg)) { - CompConstToVariable(GetMipsRegHi(KnownReg),&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg]); - } else if (IsSigned(KnownReg)) { - CompConstToVariable((GetMipsRegLo_S(KnownReg) >> 31),&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg]); - } else { - CompConstToVariable(0,&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg]); - } - } else { - if (Is64Bit(KnownReg)) { - CompX86regToVariable(GetMipsRegMapHi(KnownReg),&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg]); - } else if (IsSigned(KnownReg)) { - ProtectGPR(KnownReg); - CompX86regToVariable(Map_TempReg(x86_Any,KnownReg,true),&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg]); - } else { - CompConstToVariable(0,&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg]); - } - } - if (m_Section->m_Jump.FallThrough) { - JneLabel8("continue",0); - Jump = m_RecompPos - 1; - } else { - JneLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } - if (IsConst(KnownReg)) { - CompConstToVariable(GetMipsRegLo(KnownReg),&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg]); - } else { - CompX86regToVariable(GetMipsRegMapLo(KnownReg),&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg]); - } - if (m_Section->m_Cont.FallThrough) { - JneLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); - if (g_System->b32BitCore()) - { - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - m_Section->m_Jump.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - } - } else if (m_Section->m_Jump.FallThrough) { - JeLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - - if (Jump) - { - CPU_Message(" "); - CPU_Message(" continue:"); + if (Is64Bit(ConstReg) || Is64Bit(MappedReg)) + { + if (Is32Bit(ConstReg) || Is32Bit(MappedReg)) + { + ProtectGPR(MappedReg); + if (Is32Bit(MappedReg)) + { + CompConstToX86reg(Map_TempReg(x86_Any, MappedReg, true), GetMipsRegHi(ConstReg)); + } + else + { + CompConstToX86reg(GetMipsRegMapHi(MappedReg), GetMipsRegLo_S(ConstReg) >> 31); + } + } + else + { + CompConstToX86reg(GetMipsRegMapHi(MappedReg), GetMipsRegHi(ConstReg)); + } + if (m_Section->m_Jump.FallThrough) + { + JneLabel8("continue", 0); + Jump = m_RecompPos - 1; + } + else + { + JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + CompConstToX86reg(GetMipsRegMapLo(MappedReg), GetMipsRegLo(ConstReg)); + if (m_Section->m_Cont.FallThrough) + { + JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + } + else if (m_Section->m_Jump.FallThrough) + { + JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + CPU_Message(" "); + CPU_Message(" continue:"); + SetJump8(Jump, m_RecompPos); + } + else + { + JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + } + } + else + { + CompConstToX86reg(GetMipsRegMapLo(MappedReg), GetMipsRegLo(ConstReg)); + if (m_Section->m_Cont.FallThrough) + { + JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else if (m_Section->m_Jump.FallThrough) + { + JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } + } + } + else if (IsKnown(m_Opcode.rs) || IsKnown(m_Opcode.rt)) + { + uint32_t KnownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rt : m_Opcode.rs; + uint32_t UnknownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rs : m_Opcode.rt; - SetJump8(Jump,m_RecompPos); - } - } else { - JeLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - if (g_System->b32BitCore()) - { - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - m_Section->m_Jump.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - } - } - } else { - x86Reg Reg = x86_Any; + if (!g_System->b32BitCore()) + { + if (IsConst(KnownReg)) + { + if (Is64Bit(KnownReg)) + { + CompConstToVariable(GetMipsRegHi(KnownReg), &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); + } + else if (IsSigned(KnownReg)) + { + CompConstToVariable((GetMipsRegLo_S(KnownReg) >> 31), &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); + } + else + { + CompConstToVariable(0, &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); + } + } + else + { + if (Is64Bit(KnownReg)) + { + CompX86regToVariable(GetMipsRegMapHi(KnownReg), &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); + } + else if (IsSigned(KnownReg)) + { + ProtectGPR(KnownReg); + CompX86regToVariable(Map_TempReg(x86_Any, KnownReg, true), &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); + } + else + { + CompConstToVariable(0, &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); + } + } + if (m_Section->m_Jump.FallThrough) + { + JneLabel8("continue", 0); + Jump = m_RecompPos - 1; + } + else + { + JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } + if (IsConst(KnownReg)) + { + CompConstToVariable(GetMipsRegLo(KnownReg), &_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg]); + } + else + { + CompX86regToVariable(GetMipsRegMapLo(KnownReg), &_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg]); + } + if (m_Section->m_Cont.FallThrough) + { + JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + if (g_System->b32BitCore()) + { + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + } + } + else if (m_Section->m_Jump.FallThrough) + { + JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); - if (!g_System->b32BitCore()) - { - Reg = Map_TempReg(x86_Any, m_Opcode.rt, true); - CompX86regToVariable(Reg,&_GPR[m_Opcode.rs].W[1],CRegName::GPR_Hi[m_Opcode.rs]); - if (m_Section->m_Jump.FallThrough) { - JneLabel8("continue",0); - Jump = m_RecompPos - 1; - } else { - JneLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } + if (Jump) + { + CPU_Message(" "); + CPU_Message(" continue:"); - Reg = Map_TempReg(Reg, m_Opcode.rt, false); - CompX86regToVariable(Reg,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]); - if (m_Section->m_Cont.FallThrough) { - JneLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); - if (g_System->b32BitCore()) - { - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - m_Section->m_Jump.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - } - } else if (m_Section->m_Jump.FallThrough) { - JeLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - if (Jump) - { - CPU_Message(" "); - CPU_Message(" continue:"); - SetJump8(Jump,m_RecompPos); - } - } else { - JeLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - if (g_System->b32BitCore()) - { - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - m_Section->m_Jump.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - } - } - } + SetJump8(Jump, m_RecompPos); + } + } + else + { + JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + if (g_System->b32BitCore()) + { + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + } + } + } + else + { + x86Reg Reg = x86_Any; + + if (!g_System->b32BitCore()) + { + Reg = Map_TempReg(x86_Any, m_Opcode.rt, true); + CompX86regToVariable(Reg, &_GPR[m_Opcode.rs].W[1], CRegName::GPR_Hi[m_Opcode.rs]); + if (m_Section->m_Jump.FallThrough) + { + JneLabel8("continue", 0); + Jump = m_RecompPos - 1; + } + else + { + JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } + + Reg = Map_TempReg(Reg, m_Opcode.rt, false); + CompX86regToVariable(Reg, &_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs]); + if (m_Section->m_Cont.FallThrough) + { + JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + if (g_System->b32BitCore()) + { + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + } + } + else if (m_Section->m_Jump.FallThrough) + { + JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + if (Jump) + { + CPU_Message(" "); + CPU_Message(" continue:"); + SetJump8(Jump, m_RecompPos); + } + } + else + { + JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + if (g_System->b32BitCore()) + { + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + } + } + } } -void CRecompilerOps::BEQ_Compare() { - BYTE *Jump = NULL; +void CRecompilerOps::BEQ_Compare() +{ + uint8_t *Jump = NULL; - if (IsKnown(m_Opcode.rs) && IsKnown(m_Opcode.rt)) { - if (IsConst(m_Opcode.rs) && IsConst(m_Opcode.rt)) { - if (Is64Bit(m_Opcode.rs) || Is64Bit(m_Opcode.rt)) { - CRecompilerOps::UnknownOpcode(); - } else if (GetMipsRegLo(m_Opcode.rs) == GetMipsRegLo(m_Opcode.rt)) { - m_Section->m_Jump.FallThrough = true; - m_Section->m_Cont.FallThrough = false; - } else { - m_Section->m_Jump.FallThrough = false; - m_Section->m_Cont.FallThrough = true; - } - } - else if (IsMapped(m_Opcode.rs) && IsMapped(m_Opcode.rt)) - { - if ((Is64Bit(m_Opcode.rs) || Is64Bit(m_Opcode.rt)) && !g_System->b32BitCore()) - { - ProtectGPR(m_Opcode.rs); - ProtectGPR(m_Opcode.rt); + if (IsKnown(m_Opcode.rs) && IsKnown(m_Opcode.rt)) + { + if (IsConst(m_Opcode.rs) && IsConst(m_Opcode.rt)) + { + if (Is64Bit(m_Opcode.rs) || Is64Bit(m_Opcode.rt)) + { + CRecompilerOps::UnknownOpcode(); + } + else if (GetMipsRegLo(m_Opcode.rs) == GetMipsRegLo(m_Opcode.rt)) + { + m_Section->m_Jump.FallThrough = true; + m_Section->m_Cont.FallThrough = false; + } + else + { + m_Section->m_Jump.FallThrough = false; + m_Section->m_Cont.FallThrough = true; + } + } + else if (IsMapped(m_Opcode.rs) && IsMapped(m_Opcode.rt)) + { + if ((Is64Bit(m_Opcode.rs) || Is64Bit(m_Opcode.rt)) && !g_System->b32BitCore()) + { + ProtectGPR(m_Opcode.rs); + ProtectGPR(m_Opcode.rt); - CompX86RegToX86Reg( - Is32Bit(m_Opcode.rs) ? Map_TempReg(x86_Any, m_Opcode.rs, true) : GetMipsRegMapHi(m_Opcode.rs), - Is32Bit(m_Opcode.rt) ? Map_TempReg(x86_Any, m_Opcode.rt, true) : GetMipsRegMapHi(m_Opcode.rt) - ); - if (m_Section->m_Cont.FallThrough) { - JneLabel8("continue",0); - Jump = m_RecompPos - 1; - } else { - JneLabel32(m_Section->m_Cont.BranchLabel.c_str(),0); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - CompX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rs),GetMipsRegMapLo(m_Opcode.rt)); - if (m_Section->m_Cont.FallThrough) { - JeLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - CPU_Message(" "); - CPU_Message(" continue:"); - SetJump8(Jump,m_RecompPos); - } else if (m_Section->m_Jump.FallThrough) { - JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - } else { - JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } else { - CompX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rs),GetMipsRegMapLo(m_Opcode.rt)); - if (m_Section->m_Cont.FallThrough) { - JeLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else if (m_Section->m_Jump.FallThrough) { - JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } - } else { - DWORD ConstReg = IsConst(m_Opcode.rt)?m_Opcode.rt:m_Opcode.rs; - DWORD MappedReg = IsConst(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; + CompX86RegToX86Reg( + Is32Bit(m_Opcode.rs) ? Map_TempReg(x86_Any, m_Opcode.rs, true) : GetMipsRegMapHi(m_Opcode.rs), + Is32Bit(m_Opcode.rt) ? Map_TempReg(x86_Any, m_Opcode.rt, true) : GetMipsRegMapHi(m_Opcode.rt) + ); + if (m_Section->m_Cont.FallThrough) + { + JneLabel8("continue", 0); + Jump = m_RecompPos - 1; + } + else + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + CompX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); + if (m_Section->m_Cont.FallThrough) + { + JeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + CPU_Message(" "); + CPU_Message(" continue:"); + SetJump8(Jump, m_RecompPos); + } + else if (m_Section->m_Jump.FallThrough) + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + } + else + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } + else + { + CompX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); + if (m_Section->m_Cont.FallThrough) + { + JeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else if (m_Section->m_Jump.FallThrough) + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } + } + else + { + uint32_t ConstReg = IsConst(m_Opcode.rt) ? m_Opcode.rt : m_Opcode.rs; + uint32_t MappedReg = IsConst(m_Opcode.rt) ? m_Opcode.rs : m_Opcode.rt; - if (Is64Bit(ConstReg) || Is64Bit(MappedReg)) { - if (Is32Bit(ConstReg) || Is32Bit(MappedReg)) { - if (Is32Bit(MappedReg)) { - ProtectGPR(MappedReg); - CompConstToX86reg(Map_TempReg(x86_Any, MappedReg, true), GetMipsRegHi(ConstReg)); - } else { - CompConstToX86reg(GetMipsRegMapHi(MappedReg),GetMipsRegLo_S(ConstReg) >> 31); - } - } else { - CompConstToX86reg(GetMipsRegMapHi(MappedReg),GetMipsRegHi(ConstReg)); - } - if (m_Section->m_Cont.FallThrough) { - JneLabel8("continue",0); - Jump = m_RecompPos - 1; - } else { - JneLabel32(m_Section->m_Cont.BranchLabel.c_str(),0); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - CompConstToX86reg(GetMipsRegMapLo(MappedReg),GetMipsRegLo(ConstReg)); - if (m_Section->m_Cont.FallThrough) { - JeLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - CPU_Message(" "); - CPU_Message(" continue:"); - SetJump8(Jump,m_RecompPos); - } else if (m_Section->m_Jump.FallThrough) { - JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - } else { - JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } else { - CompConstToX86reg(GetMipsRegMapLo(MappedReg),GetMipsRegLo(ConstReg)); - if (m_Section->m_Cont.FallThrough) { - JeLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else if (m_Section->m_Jump.FallThrough) { - JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } - } - } else if (IsKnown(m_Opcode.rs) || IsKnown(m_Opcode.rt)) { - DWORD KnownReg = IsKnown(m_Opcode.rt)?m_Opcode.rt:m_Opcode.rs; - DWORD UnknownReg = IsKnown(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; + if (Is64Bit(ConstReg) || Is64Bit(MappedReg)) + { + if (Is32Bit(ConstReg) || Is32Bit(MappedReg)) + { + if (Is32Bit(MappedReg)) + { + ProtectGPR(MappedReg); + CompConstToX86reg(Map_TempReg(x86_Any, MappedReg, true), GetMipsRegHi(ConstReg)); + } + else + { + CompConstToX86reg(GetMipsRegMapHi(MappedReg), GetMipsRegLo_S(ConstReg) >> 31); + } + } + else + { + CompConstToX86reg(GetMipsRegMapHi(MappedReg), GetMipsRegHi(ConstReg)); + } + if (m_Section->m_Cont.FallThrough) { + JneLabel8("continue", 0); + Jump = m_RecompPos - 1; + } + else + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + CompConstToX86reg(GetMipsRegMapLo(MappedReg), GetMipsRegLo(ConstReg)); + if (m_Section->m_Cont.FallThrough) + { + JeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + CPU_Message(" "); + CPU_Message(" continue:"); + SetJump8(Jump, m_RecompPos); + } + else if (m_Section->m_Jump.FallThrough) + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + } + else + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } + else + { + CompConstToX86reg(GetMipsRegMapLo(MappedReg), GetMipsRegLo(ConstReg)); + if (m_Section->m_Cont.FallThrough) + { + JeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else if (m_Section->m_Jump.FallThrough) + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } + } + } + else if (IsKnown(m_Opcode.rs) || IsKnown(m_Opcode.rt)) + { + uint32_t KnownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rt : m_Opcode.rs; + uint32_t UnknownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rs : m_Opcode.rt; - if (!g_System->b32BitCore()) - { - if (IsConst(KnownReg)) { - if (Is64Bit(KnownReg)) { - CompConstToVariable(GetMipsRegHi(KnownReg),&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg]); - } else if (IsSigned(KnownReg)) { - CompConstToVariable(GetMipsRegLo_S(KnownReg) >> 31,&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg]); - } else { - CompConstToVariable(0,&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg]); - } - } else { - ProtectGPR(KnownReg); - if (Is64Bit(KnownReg)) { - CompX86regToVariable(GetMipsRegMapHi(KnownReg),&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg]); - } else if (IsSigned(KnownReg)) { - CompX86regToVariable(Map_TempReg(x86_Any,KnownReg,true),&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg]); - } else { - CompConstToVariable(0,&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg]); - } - } - if (m_Section->m_Cont.FallThrough) { - JneLabel8("continue",0); - Jump = m_RecompPos - 1; - } else { - JneLabel32(m_Section->m_Cont.BranchLabel.c_str(),0); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } - if (IsConst(KnownReg)) { - CompConstToVariable(GetMipsRegLo(KnownReg),&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg]); - } else { - CompX86regToVariable(GetMipsRegMapLo(KnownReg),&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg]); - } - if (m_Section->m_Cont.FallThrough) { - JeLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - if (Jump) - { - CPU_Message(" "); - CPU_Message(" continue:"); - SetJump8(Jump,m_RecompPos); - } - } else if (m_Section->m_Jump.FallThrough) { - JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - if (g_System->b32BitCore()) - { - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - m_Section->m_Cont.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - } - } else { - JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } else { - x86Reg Reg = x86_Any; - if (!g_System->b32BitCore()) - { - Reg = Map_TempReg(x86_Any, m_Opcode.rs, true); - CompX86regToVariable(Reg,&_GPR[m_Opcode.rt].W[1],CRegName::GPR_Hi[m_Opcode.rt]); - if (m_Section->m_Cont.FallThrough) { - JneLabel8("continue",0); - Jump = m_RecompPos - 1; - } else { - JneLabel32(m_Section->m_Cont.BranchLabel.c_str(),0); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } - CompX86regToVariable(Map_TempReg(Reg, m_Opcode.rs, false), &_GPR[m_Opcode.rt].W[0], CRegName::GPR_Lo[m_Opcode.rt]); - if (m_Section->m_Cont.FallThrough) { - JeLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - if (Jump) - { - CPU_Message(" "); - CPU_Message(" continue:"); - SetJump8(Jump,m_RecompPos); - } - } else if (m_Section->m_Jump.FallThrough) { - JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - if (g_System->b32BitCore()) - { - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - m_Section->m_Cont.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - } - } else { - JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - if (g_System->b32BitCore()) - { - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - m_Section->m_Cont.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - } - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } + if (!g_System->b32BitCore()) + { + if (IsConst(KnownReg)) + { + if (Is64Bit(KnownReg)) + { + CompConstToVariable(GetMipsRegHi(KnownReg), &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); + } + else if (IsSigned(KnownReg)) + { + CompConstToVariable(GetMipsRegLo_S(KnownReg) >> 31, &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); + } + else + { + CompConstToVariable(0, &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); + } + } + else + { + ProtectGPR(KnownReg); + if (Is64Bit(KnownReg)) + { + CompX86regToVariable(GetMipsRegMapHi(KnownReg), &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); + } + else if (IsSigned(KnownReg)) + { + CompX86regToVariable(Map_TempReg(x86_Any, KnownReg, true), &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); + } + else + { + CompConstToVariable(0, &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); + } + } + if (m_Section->m_Cont.FallThrough) + { + JneLabel8("continue", 0); + Jump = m_RecompPos - 1; + } + else + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } + if (IsConst(KnownReg)) + { + CompConstToVariable(GetMipsRegLo(KnownReg), &_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg]); + } + else + { + CompX86regToVariable(GetMipsRegMapLo(KnownReg), &_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg]); + } + if (m_Section->m_Cont.FallThrough) + { + JeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + if (Jump) + { + CPU_Message(" "); + CPU_Message(" continue:"); + SetJump8(Jump, m_RecompPos); + } + } + else if (m_Section->m_Jump.FallThrough) + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + if (g_System->b32BitCore()) + { + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + } + } + else + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } + else + { + x86Reg Reg = x86_Any; + if (!g_System->b32BitCore()) + { + Reg = Map_TempReg(x86_Any, m_Opcode.rs, true); + CompX86regToVariable(Reg, &_GPR[m_Opcode.rt].W[1], CRegName::GPR_Hi[m_Opcode.rt]); + if (m_Section->m_Cont.FallThrough) + { + JneLabel8("continue", 0); + Jump = m_RecompPos - 1; + } + else + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } + CompX86regToVariable(Map_TempReg(Reg, m_Opcode.rs, false), &_GPR[m_Opcode.rt].W[0], CRegName::GPR_Lo[m_Opcode.rt]); + if (m_Section->m_Cont.FallThrough) + { + JeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + if (Jump) + { + CPU_Message(" "); + CPU_Message(" continue:"); + SetJump8(Jump, m_RecompPos); + } + } + else if (m_Section->m_Jump.FallThrough) + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + if (g_System->b32BitCore()) + { + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + } + } + else + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + if (g_System->b32BitCore()) + { + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + } + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } } -void CRecompilerOps::BGTZ_Compare() { - if (IsConst(m_Opcode.rs)) { - if (Is64Bit(m_Opcode.rs)) { - if (GetMipsReg_S(m_Opcode.rs) > 0) { - m_Section->m_Jump.FallThrough = true; - m_Section->m_Cont.FallThrough = false; - } else { - m_Section->m_Jump.FallThrough = false; - m_Section->m_Cont.FallThrough = true; - } - } else { - if (GetMipsRegLo_S(m_Opcode.rs) > 0) { - m_Section->m_Jump.FallThrough = true; - m_Section->m_Cont.FallThrough = false; - } else { - m_Section->m_Jump.FallThrough = false; - m_Section->m_Cont.FallThrough = true; - } - } - } else if (IsMapped(m_Opcode.rs) && Is32Bit(m_Opcode.rs)) { - CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs),0); - if (m_Section->m_Jump.FallThrough) { - JleLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else if (m_Section->m_Cont.FallThrough) { - JgLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - JleLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } else if (IsUnknown(m_Opcode.rs) && g_System->b32BitCore()) { - CompConstToVariable(0,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]); - if (m_Section->m_Jump.FallThrough) { - JleLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else if (m_Section->m_Cont.FallThrough) { - JgLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - JleLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } else { - BYTE *Jump = NULL; +void CRecompilerOps::BGTZ_Compare() +{ + if (IsConst(m_Opcode.rs)) + { + if (Is64Bit(m_Opcode.rs)) + { + if (GetMipsReg_S(m_Opcode.rs) > 0) + { + m_Section->m_Jump.FallThrough = true; + m_Section->m_Cont.FallThrough = false; + } + else + { + m_Section->m_Jump.FallThrough = false; + m_Section->m_Cont.FallThrough = true; + } + } + else + { + if (GetMipsRegLo_S(m_Opcode.rs) > 0) + { + m_Section->m_Jump.FallThrough = true; + m_Section->m_Cont.FallThrough = false; + } + else + { + m_Section->m_Jump.FallThrough = false; + m_Section->m_Cont.FallThrough = true; + } + } + } + else if (IsMapped(m_Opcode.rs) && Is32Bit(m_Opcode.rs)) + { + CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs), 0); + if (m_Section->m_Jump.FallThrough) + { + JleLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else if (m_Section->m_Cont.FallThrough) + { + JgLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + JleLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } + else if (IsUnknown(m_Opcode.rs) && g_System->b32BitCore()) + { + CompConstToVariable(0, &_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs]); + if (m_Section->m_Jump.FallThrough) + { + JleLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else if (m_Section->m_Cont.FallThrough) + { + JgLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + JleLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } + else + { + uint8_t *Jump = NULL; - if (IsMapped(m_Opcode.rs)) { - CompConstToX86reg(GetMipsRegMapHi(m_Opcode.rs),0); - } else { - CompConstToVariable(0,&_GPR[m_Opcode.rs].W[1],CRegName::GPR_Hi[m_Opcode.rs]); - } - if (m_Section->m_Jump.FallThrough) { - JlLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JgLabel8("continue",0); - Jump = m_RecompPos - 1; - } else if (m_Section->m_Cont.FallThrough) { - JlLabel8("continue",0); - Jump = m_RecompPos - 1; - JgLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - JlLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JgLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } + if (IsMapped(m_Opcode.rs)) + { + CompConstToX86reg(GetMipsRegMapHi(m_Opcode.rs), 0); + } + else + { + CompConstToVariable(0, &_GPR[m_Opcode.rs].W[1], CRegName::GPR_Hi[m_Opcode.rs]); + } + if (m_Section->m_Jump.FallThrough) + { + JlLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JgLabel8("continue", 0); + Jump = m_RecompPos - 1; + } + else if (m_Section->m_Cont.FallThrough) + { + JlLabel8("continue", 0); + Jump = m_RecompPos - 1; + JgLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + JlLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JgLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } - if (IsMapped(m_Opcode.rs)) { - CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs),0); - } else { - CompConstToVariable(0,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]); - } - if (m_Section->m_Jump.FallThrough) { - JeLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - CPU_Message(" continue:"); - SetJump8(Jump,m_RecompPos); - } else if (m_Section->m_Cont.FallThrough) { - JneLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - CPU_Message(" continue:"); - SetJump8(Jump,m_RecompPos); - } else { - JneLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - JmpLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - } - } + if (IsMapped(m_Opcode.rs)) + { + CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs), 0); + } + else + { + CompConstToVariable(0, &_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs]); + } + if (m_Section->m_Jump.FallThrough) + { + JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + CPU_Message(" continue:"); + SetJump8(Jump, m_RecompPos); + } + else if (m_Section->m_Cont.FallThrough) + { + JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + CPU_Message(" continue:"); + SetJump8(Jump, m_RecompPos); + } + else + { + JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + } + } } -void CRecompilerOps::BLEZ_Compare() { - if (IsConst(m_Opcode.rs)) { - if (Is64Bit(m_Opcode.rs)) { - if (GetMipsReg_S(m_Opcode.rs) <= 0) { - m_Section->m_Jump.FallThrough = true; - m_Section->m_Cont.FallThrough = false; - } else { - m_Section->m_Jump.FallThrough = false; - m_Section->m_Cont.FallThrough = true; - } - } else if (IsSigned(m_Opcode.rs)) { - if (GetMipsRegLo_S(m_Opcode.rs) <= 0) { - m_Section->m_Jump.FallThrough = true; - m_Section->m_Cont.FallThrough = false; - } else { - m_Section->m_Jump.FallThrough = false; - m_Section->m_Cont.FallThrough = true; - } - } else { - if (GetMipsRegLo(m_Opcode.rs) == 0) { - m_Section->m_Jump.FallThrough = true; - m_Section->m_Cont.FallThrough = false; - } else { - m_Section->m_Jump.FallThrough = false; - m_Section->m_Cont.FallThrough = true; - } - } - } else if (IsMapped(m_Opcode.rs)) { - if (Is32Bit(m_Opcode.rs)) - { - CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs),0); - if (m_Section->m_Jump.FallThrough) { - JgLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else if (m_Section->m_Cont.FallThrough) { - JleLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - JgLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } else { - BYTE *Jump = NULL; +void CRecompilerOps::BLEZ_Compare() +{ + if (IsConst(m_Opcode.rs)) + { + if (Is64Bit(m_Opcode.rs)) + { + if (GetMipsReg_S(m_Opcode.rs) <= 0) + { + m_Section->m_Jump.FallThrough = true; + m_Section->m_Cont.FallThrough = false; + } + else + { + m_Section->m_Jump.FallThrough = false; + m_Section->m_Cont.FallThrough = true; + } + } + else if (IsSigned(m_Opcode.rs)) + { + if (GetMipsRegLo_S(m_Opcode.rs) <= 0) + { + m_Section->m_Jump.FallThrough = true; + m_Section->m_Cont.FallThrough = false; + } + else + { + m_Section->m_Jump.FallThrough = false; + m_Section->m_Cont.FallThrough = true; + } + } + else + { + if (GetMipsRegLo(m_Opcode.rs) == 0) + { + m_Section->m_Jump.FallThrough = true; + m_Section->m_Cont.FallThrough = false; + } + else + { + m_Section->m_Jump.FallThrough = false; + m_Section->m_Cont.FallThrough = true; + } + } + } + else if (IsMapped(m_Opcode.rs)) + { + if (Is32Bit(m_Opcode.rs)) + { + CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs), 0); + if (m_Section->m_Jump.FallThrough) + { + JgLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else if (m_Section->m_Cont.FallThrough) + { + JleLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + JgLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } + else + { + uint8_t *Jump = NULL; - if (IsMapped(m_Opcode.rs)) { - CompConstToX86reg(GetMipsRegMapHi(m_Opcode.rs),0); - } else { - CompConstToVariable(0,&_GPR[m_Opcode.rs].W[1],CRegName::GPR_Hi[m_Opcode.rs]); - } - if (m_Section->m_Jump.FallThrough) { - JgLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JlLabel8("Continue",0); - Jump = m_RecompPos - 1; - } else if (m_Section->m_Cont.FallThrough) { - JgLabel8("Continue",0); - Jump = m_RecompPos - 1; - JlLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - JgLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JlLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } + if (IsMapped(m_Opcode.rs)) + { + CompConstToX86reg(GetMipsRegMapHi(m_Opcode.rs), 0); + } + else + { + CompConstToVariable(0, &_GPR[m_Opcode.rs].W[1], CRegName::GPR_Hi[m_Opcode.rs]); + } + if (m_Section->m_Jump.FallThrough) + { + JgLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JlLabel8("Continue", 0); + Jump = m_RecompPos - 1; + } + else if (m_Section->m_Cont.FallThrough) + { + JgLabel8("Continue", 0); + Jump = m_RecompPos - 1; + JlLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + JgLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JlLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } - if (IsMapped(m_Opcode.rs)) { - CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs),0); - } else { - CompConstToVariable(0,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]); - } - if (m_Section->m_Jump.FallThrough) { - JneLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - CPU_Message(" continue:"); - SetJump8(Jump,m_RecompPos); - } else if (m_Section->m_Cont.FallThrough) { - JeLabel32 (m_Section->m_Jump.BranchLabel.c_str(), 0 ); - m_Section->m_Jump.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - CPU_Message(" continue:"); - SetJump8(Jump,m_RecompPos); - } else { - JneLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - JmpLabel32("BranchToJump",0); - m_Section->m_Jump.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - } - } - } else { - BYTE *Jump = NULL; + if (IsMapped(m_Opcode.rs)) + { + CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs), 0); + } + else + { + CompConstToVariable(0, &_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs]); + } + if (m_Section->m_Jump.FallThrough) + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + CPU_Message(" continue:"); + SetJump8(Jump, m_RecompPos); + } + else if (m_Section->m_Cont.FallThrough) + { + JeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + CPU_Message(" continue:"); + SetJump8(Jump, m_RecompPos); + } + else + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + JmpLabel32("BranchToJump", 0); + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + } + } + } + else { + uint8_t *Jump = NULL; - if (!g_System->b32BitCore()) - { - CompConstToVariable(0,&_GPR[m_Opcode.rs].W[1],CRegName::GPR_Hi[m_Opcode.rs]); - if (m_Section->m_Jump.FallThrough) { - JgLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JlLabel8("Continue",0); - Jump = m_RecompPos - 1; - } else if (m_Section->m_Cont.FallThrough) { - JgLabel8("Continue",0); - Jump = m_RecompPos - 1; - JlLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - JgLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JlLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - CompConstToVariable(0,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]); - if (m_Section->m_Jump.FallThrough) { - JneLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - if (g_System->b32BitCore()) - { - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - m_Section->m_Cont.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - } - if (Jump) - { - CPU_Message(" continue:"); - SetJump8(Jump,m_RecompPos); - } - } else if (m_Section->m_Cont.FallThrough) { - JeLabel32 (m_Section->m_Jump.BranchLabel.c_str(), 0 ); - m_Section->m_Jump.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - if (Jump) - { - CPU_Message(" continue:"); - SetJump8(Jump,m_RecompPos); - } - } else { - JneLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - JmpLabel32("BranchToJump",0); - m_Section->m_Jump.LinkLocation2 = (DWORD *)(m_RecompPos - 4); - } - } else { - CompConstToVariable(0,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]); - if (m_Section->m_Jump.FallThrough) { - JgLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else if (m_Section->m_Cont.FallThrough) { - JleLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - JgLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } - } + if (!g_System->b32BitCore()) + { + CompConstToVariable(0, &_GPR[m_Opcode.rs].W[1], CRegName::GPR_Hi[m_Opcode.rs]); + if (m_Section->m_Jump.FallThrough) + { + JgLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JlLabel8("Continue", 0); + Jump = m_RecompPos - 1; + } + else if (m_Section->m_Cont.FallThrough) + { + JgLabel8("Continue", 0); + Jump = m_RecompPos - 1; + JlLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + JgLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JlLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + CompConstToVariable(0, &_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs]); + if (m_Section->m_Jump.FallThrough) + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + if (g_System->b32BitCore()) + { + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + } + if (Jump) + { + CPU_Message(" continue:"); + SetJump8(Jump, m_RecompPos); + } + } + else if (m_Section->m_Cont.FallThrough) + { + JeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + if (Jump) + { + CPU_Message(" continue:"); + SetJump8(Jump, m_RecompPos); + } + } + else + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + JmpLabel32("BranchToJump", 0); + m_Section->m_Jump.LinkLocation2 = (uint32_t *)(m_RecompPos - 4); + } + } + else + { + CompConstToVariable(0, &_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs]); + if (m_Section->m_Jump.FallThrough) + { + JgLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else if (m_Section->m_Cont.FallThrough) + { + JleLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + JgLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } + } } -void CRecompilerOps::BLTZ_Compare() { - if (IsConst(m_Opcode.rs)) { - if (Is64Bit(m_Opcode.rs)) { - if (GetMipsReg_S(m_Opcode.rs) < 0) { - m_Section->m_Jump.FallThrough = true; - m_Section->m_Cont.FallThrough = false; - } else { - m_Section->m_Jump.FallThrough = false; - m_Section->m_Cont.FallThrough = true; - } - } else if (IsSigned(m_Opcode.rs)) { - if (GetMipsRegLo_S(m_Opcode.rs) < 0) { - m_Section->m_Jump.FallThrough = true; - m_Section->m_Cont.FallThrough = false; - } else { - m_Section->m_Jump.FallThrough = false; - m_Section->m_Cont.FallThrough = true; - } - } else { - m_Section->m_Jump.FallThrough = false; - m_Section->m_Cont.FallThrough = true; - } - } else if (IsMapped(m_Opcode.rs)) { - if (Is64Bit(m_Opcode.rs)) { - CompConstToX86reg(GetMipsRegMapHi(m_Opcode.rs),0); - if (m_Section->m_Jump.FallThrough) { - JgeLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else if (m_Section->m_Cont.FallThrough) { - JlLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - JgeLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } else if (IsSigned(m_Opcode.rs)) { - CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs),0); - if (m_Section->m_Jump.FallThrough) { - JgeLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else if (m_Section->m_Cont.FallThrough) { - JlLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - JgeLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } else { - m_Section->m_Jump.FallThrough = false; - m_Section->m_Cont.FallThrough = true; - } - } else if (IsUnknown(m_Opcode.rs)) { - if (g_System->b32BitCore()) - { - CompConstToVariable(0,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]); - } else { - CompConstToVariable(0,&_GPR[m_Opcode.rs].W[1],CRegName::GPR_Hi[m_Opcode.rs]); - } - if (m_Section->m_Jump.FallThrough) { - JgeLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else if (m_Section->m_Cont.FallThrough) { - JlLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - JlLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - JmpLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } +void CRecompilerOps::BLTZ_Compare() +{ + if (IsConst(m_Opcode.rs)) + { + if (Is64Bit(m_Opcode.rs)) + { + if (GetMipsReg_S(m_Opcode.rs) < 0) + { + m_Section->m_Jump.FallThrough = true; + m_Section->m_Cont.FallThrough = false; + } + else + { + m_Section->m_Jump.FallThrough = false; + m_Section->m_Cont.FallThrough = true; + } + } + else if (IsSigned(m_Opcode.rs)) + { + if (GetMipsRegLo_S(m_Opcode.rs) < 0) + { + m_Section->m_Jump.FallThrough = true; + m_Section->m_Cont.FallThrough = false; + } + else + { + m_Section->m_Jump.FallThrough = false; + m_Section->m_Cont.FallThrough = true; + } + } + else + { + m_Section->m_Jump.FallThrough = false; + m_Section->m_Cont.FallThrough = true; + } + } + else if (IsMapped(m_Opcode.rs)) + { + if (Is64Bit(m_Opcode.rs)) + { + CompConstToX86reg(GetMipsRegMapHi(m_Opcode.rs), 0); + if (m_Section->m_Jump.FallThrough) + { + JgeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else if (m_Section->m_Cont.FallThrough) + { + JlLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + JgeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } + else if (IsSigned(m_Opcode.rs)) + { + CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs), 0); + if (m_Section->m_Jump.FallThrough) + { + JgeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else if (m_Section->m_Cont.FallThrough) + { + JlLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + JgeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } + else + { + m_Section->m_Jump.FallThrough = false; + m_Section->m_Cont.FallThrough = true; + } + } + else if (IsUnknown(m_Opcode.rs)) + { + if (g_System->b32BitCore()) + { + CompConstToVariable(0, &_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs]); + } + else + { + CompConstToVariable(0, &_GPR[m_Opcode.rs].W[1], CRegName::GPR_Hi[m_Opcode.rs]); + } + if (m_Section->m_Jump.FallThrough) + { + JgeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else if (m_Section->m_Cont.FallThrough) + { + JlLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + JlLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } } -void CRecompilerOps::BGEZ_Compare() { - if (IsConst(m_Opcode.rs)) { - if (Is64Bit(m_Opcode.rs)) { - g_Notify->BreakPoint(__FILEW__,__LINE__); - CRecompilerOps::UnknownOpcode(); - } else if (IsSigned(m_Opcode.rs)) { - if (GetMipsRegLo_S(m_Opcode.rs) >= 0) { - m_Section->m_Jump.FallThrough = true; - m_Section->m_Cont.FallThrough = false; - } else { - m_Section->m_Jump.FallThrough = false; - m_Section->m_Cont.FallThrough = true; - } - } else { - m_Section->m_Jump.FallThrough = true; - m_Section->m_Cont.FallThrough = false; - } - } else if (IsMapped(m_Opcode.rs)) { - if (Is64Bit(m_Opcode.rs)) { - CompConstToX86reg(GetMipsRegMapHi(m_Opcode.rs),0); - if (m_Section->m_Cont.FallThrough) { - JgeLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else if (m_Section->m_Jump.FallThrough) { - JlLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - JlLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } else if (IsSigned(m_Opcode.rs)) { - CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs),0); - if (m_Section->m_Cont.FallThrough) { - JgeLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else if (m_Section->m_Jump.FallThrough) { - JlLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - JlLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } else { - m_Section->m_Jump.FallThrough = true; - m_Section->m_Cont.FallThrough = false; - } - } else { - if (g_System->b32BitCore()) - { - CompConstToVariable(0,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]); - } else { - CompConstToVariable(0,&_GPR[m_Opcode.rs].W[1],CRegName::GPR_Hi[m_Opcode.rs]); - } - if (m_Section->m_Cont.FallThrough) { - JgeLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else if (m_Section->m_Jump.FallThrough) { - JlLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - JlLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } - } +void CRecompilerOps::BGEZ_Compare() +{ + if (IsConst(m_Opcode.rs)) + { + if (Is64Bit(m_Opcode.rs)) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + CRecompilerOps::UnknownOpcode(); + } + else if (IsSigned(m_Opcode.rs)) + { + if (GetMipsRegLo_S(m_Opcode.rs) >= 0) + { + m_Section->m_Jump.FallThrough = true; + m_Section->m_Cont.FallThrough = false; + } + else + { + m_Section->m_Jump.FallThrough = false; + m_Section->m_Cont.FallThrough = true; + } + } + else + { + m_Section->m_Jump.FallThrough = true; + m_Section->m_Cont.FallThrough = false; + } + } + else if (IsMapped(m_Opcode.rs)) + { + if (Is64Bit(m_Opcode.rs)) + { + CompConstToX86reg(GetMipsRegMapHi(m_Opcode.rs), 0); + if (m_Section->m_Cont.FallThrough) + { + JgeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else if (m_Section->m_Jump.FallThrough) + { + JlLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + JlLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } + else if (IsSigned(m_Opcode.rs)) + { + CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs), 0); + if (m_Section->m_Cont.FallThrough) + { + JgeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else if (m_Section->m_Jump.FallThrough) + { + JlLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + JlLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } + else + { + m_Section->m_Jump.FallThrough = true; + m_Section->m_Cont.FallThrough = false; + } + } + else + { + if (g_System->b32BitCore()) + { + CompConstToVariable(0, &_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs]); + } + else + { + CompConstToVariable(0, &_GPR[m_Opcode.rs].W[1], CRegName::GPR_Hi[m_Opcode.rs]); + } + if (m_Section->m_Cont.FallThrough) + { + JgeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else if (m_Section->m_Jump.FallThrough) + { + JlLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + JlLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + } } -void CRecompilerOps::COP1_BCF_Compare() { - TestVariable(FPCSR_C,&_FPCR[31],"_FPCR[31]"); - if (m_Section->m_Cont.FallThrough) { - JeLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else if (m_Section->m_Jump.FallThrough) { - JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } +void CRecompilerOps::COP1_BCF_Compare() +{ + TestVariable(FPCSR_C, &_FPCR[31], "_FPCR[31]"); + if (m_Section->m_Cont.FallThrough) + { + JeLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else if (m_Section->m_Jump.FallThrough) + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + JneLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } } -void CRecompilerOps::COP1_BCT_Compare() { - TestVariable(FPCSR_C,&_FPCR[31],"_FPCR[31]"); - if (m_Section->m_Cont.FallThrough) { - JneLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else if (m_Section->m_Jump.FallThrough) { - JeLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - } else { - JeLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); - JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); - } +void CRecompilerOps::COP1_BCT_Compare() +{ + TestVariable(FPCSR_C, &_FPCR[31], "_FPCR[31]"); + if (m_Section->m_Cont.FallThrough) + { + JneLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else if (m_Section->m_Jump.FallThrough) + { + JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } + else + { + JeLabel32(m_Section->m_Cont.BranchLabel.c_str(), 0); + m_Section->m_Cont.LinkLocation = (uint32_t *)(m_RecompPos - 4); + JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(), 0); + m_Section->m_Jump.LinkLocation = (uint32_t *)(m_RecompPos - 4); + } } /************************* OpCode functions *************************/ -void CRecompilerOps::J() { - if ( m_NextInstruction == NORMAL ) { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if ((m_CompilePC & 0xFFC) == 0xFFC) - { - MoveConstToVariable((m_CompilePC & 0xF0000000) + (m_Opcode.target << 2),&R4300iOp::m_JumpToLocation,"R4300iOp::m_JumpToLocation"); - OverflowDelaySlot(false); - return; - } - - m_Section->m_Jump.TargetPC = (m_CompilePC & 0xF0000000) + (m_Opcode.target << 2);; - m_Section->m_Jump.JumpPC = m_CompilePC; - if (m_Section->m_JumpSection != NULL) { - m_Section->m_Jump.BranchLabel.Format("Section_%d",((CCodeSection *)m_Section->m_JumpSection)->m_SectionID); - } else { - m_Section->m_Jump.BranchLabel = "ExitBlock"; - } - m_Section->m_Jump.FallThrough = true; - m_Section->m_Jump.LinkLocation = NULL; - m_Section->m_Jump.LinkLocation2 = NULL; - m_NextInstruction = DO_DELAY_SLOT; - } else if (m_NextInstruction == DELAY_SLOT_DONE ) { - m_Section->m_Jump.RegSet = m_RegWorkingSet; - m_Section->GenerateSectionLinkage(); - m_NextInstruction = END_BLOCK; - } else if (bHaveDebugger()) { - g_Notify->DisplayError(stdstr_f("WTF\n\nJ\nNextInstruction = %X", m_NextInstruction).ToUTF16().c_str()); - } -} - -void CRecompilerOps::JAL() +void CRecompilerOps::J() { - if ( m_NextInstruction == NORMAL ) - { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - Map_GPR_32bit(31,true,-1); - MoveVariableToX86reg(_PROGRAM_COUNTER,"_PROGRAM_COUNTER",GetMipsRegMapLo(31)); - AndConstToX86Reg(GetMipsRegMapLo(31), 0xF0000000); - AddConstToX86Reg(GetMipsRegMapLo(31),(m_CompilePC + 8) & ~0xF0000000); - if ((m_CompilePC & 0xFFC) == 0xFFC) - { - MoveConstToVariable((m_CompilePC & 0xF0000000) + (m_Opcode.target << 2),&R4300iOp::m_JumpToLocation,"R4300iOp::m_JumpToLocation"); - OverflowDelaySlot(false); - return; - } - m_Section->m_Jump.TargetPC = (m_CompilePC & 0xF0000000) + (m_Opcode.target << 2); - m_Section->m_Jump.JumpPC = m_CompilePC; - if (m_Section->m_JumpSection != NULL) { - m_Section->m_Jump.BranchLabel.Format("Section_%d",((CCodeSection *)m_Section->m_JumpSection)->m_SectionID); - } else { - m_Section->m_Jump.BranchLabel = "ExitBlock"; - } - m_Section->m_Jump.FallThrough = true; - m_Section->m_Jump.LinkLocation = NULL; - m_Section->m_Jump.LinkLocation2 = NULL; - m_NextInstruction = DO_DELAY_SLOT; - } else if (m_NextInstruction == DELAY_SLOT_DONE ) { - if (m_Section->m_JumpSection) - { - m_Section->m_Jump.RegSet = m_RegWorkingSet; - m_Section->GenerateSectionLinkage(); - } else { - m_RegWorkingSet.WriteBackRegisters(); + if (m_NextInstruction == NORMAL) + { + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if ((m_CompilePC & 0xFFC) == 0xFFC) + { + MoveConstToVariable((m_CompilePC & 0xF0000000) + (m_Opcode.target << 2), &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); + OverflowDelaySlot(false); + return; + } - x86Reg pc_reg = Map_TempReg(x86_Any,-1,false); - MoveVariableToX86reg(_PROGRAM_COUNTER,"_PROGRAM_COUNTER",pc_reg); - AndConstToX86Reg(pc_reg, 0xF0000000); - AddConstToX86Reg(pc_reg,(m_Opcode.target << 2)); - MoveX86regToVariable(pc_reg,_PROGRAM_COUNTER,"_PROGRAM_COUNTER"); - - DWORD TargetPC = (m_CompilePC & 0xF0000000) + (m_Opcode.target << 2); - bool bCheck = TargetPC <= m_CompilePC; - UpdateCounters(m_RegWorkingSet,bCheck, true); - - m_Section->CompileExit((DWORD)-1, (DWORD)-1, m_RegWorkingSet, bCheck ? CExitInfo::Normal : CExitInfo::Normal_NoSysCheck, true, NULL); - } - m_NextInstruction = END_BLOCK; - } else { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - return; + m_Section->m_Jump.TargetPC = (m_CompilePC & 0xF0000000) + (m_Opcode.target << 2);; + m_Section->m_Jump.JumpPC = m_CompilePC; + if (m_Section->m_JumpSection != NULL) + { + m_Section->m_Jump.BranchLabel.Format("Section_%d", ((CCodeSection *)m_Section->m_JumpSection)->m_SectionID); + } + else + { + m_Section->m_Jump.BranchLabel = "ExitBlock"; + } + m_Section->m_Jump.FallThrough = true; + m_Section->m_Jump.LinkLocation = NULL; + m_Section->m_Jump.LinkLocation2 = NULL; + m_NextInstruction = DO_DELAY_SLOT; + } + else if (m_NextInstruction == DELAY_SLOT_DONE) + { + m_Section->m_Jump.RegSet = m_RegWorkingSet; + m_Section->GenerateSectionLinkage(); + m_NextInstruction = END_BLOCK; + } + else if (bHaveDebugger()) + { + g_Notify->DisplayError(stdstr_f("WTF\n\nJ\nNextInstruction = %X", m_NextInstruction).ToUTF16().c_str()); + } } -void CRecompilerOps::ADDI() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::JAL() +{ + if (m_NextInstruction == NORMAL) + { + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + Map_GPR_32bit(31, true, -1); + MoveVariableToX86reg(_PROGRAM_COUNTER, "_PROGRAM_COUNTER", GetMipsRegMapLo(31)); + AndConstToX86Reg(GetMipsRegMapLo(31), 0xF0000000); + AddConstToX86Reg(GetMipsRegMapLo(31), (m_CompilePC + 8) & ~0xF0000000); + if ((m_CompilePC & 0xFFC) == 0xFFC) + { + MoveConstToVariable((m_CompilePC & 0xF0000000) + (m_Opcode.target << 2), &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); + OverflowDelaySlot(false); + return; + } + m_Section->m_Jump.TargetPC = (m_CompilePC & 0xF0000000) + (m_Opcode.target << 2); + m_Section->m_Jump.JumpPC = m_CompilePC; + if (m_Section->m_JumpSection != NULL) + { + m_Section->m_Jump.BranchLabel.Format("Section_%d", ((CCodeSection *)m_Section->m_JumpSection)->m_SectionID); + } + else + { + m_Section->m_Jump.BranchLabel = "ExitBlock"; + } + m_Section->m_Jump.FallThrough = true; + m_Section->m_Jump.LinkLocation = NULL; + m_Section->m_Jump.LinkLocation2 = NULL; + m_NextInstruction = DO_DELAY_SLOT; + } + else if (m_NextInstruction == DELAY_SLOT_DONE) + { + if (m_Section->m_JumpSection) + { + m_Section->m_Jump.RegSet = m_RegWorkingSet; + m_Section->GenerateSectionLinkage(); + } + else + { + m_RegWorkingSet.WriteBackRegisters(); - if (m_Opcode.rt == 0) { return; } + x86Reg pc_reg = Map_TempReg(x86_Any, -1, false); + MoveVariableToX86reg(_PROGRAM_COUNTER, "_PROGRAM_COUNTER", pc_reg); + AndConstToX86Reg(pc_reg, 0xF0000000); + AddConstToX86Reg(pc_reg, (m_Opcode.target << 2)); + MoveX86regToVariable(pc_reg, _PROGRAM_COUNTER, "_PROGRAM_COUNTER"); - if (g_System->bFastSP() && m_Opcode.rs == 29 && m_Opcode.rt == 29) { - AddConstToX86Reg(Map_MemoryStack(x86_Any, true),(short)m_Opcode.immediate); - } + uint32_t TargetPC = (m_CompilePC & 0xF0000000) + (m_Opcode.target << 2); + bool bCheck = TargetPC <= m_CompilePC; + UpdateCounters(m_RegWorkingSet, bCheck, true); - if (IsConst(m_Opcode.rs)) { - if (IsMapped(m_Opcode.rt)) - UnMap_GPR(m_Opcode.rt, false); - - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rt, GetMipsRegLo(m_Opcode.rs) + (short)m_Opcode.immediate); - m_RegWorkingSet.SetMipsRegState(m_Opcode.rt,CRegInfo::STATE_CONST_32_SIGN); - } else { - Map_GPR_32bit(m_Opcode.rt, true, m_Opcode.rs); - AddConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt),(short)m_Opcode.immediate); - } - if (g_System->bFastSP() && m_Opcode.rt == 29 && m_Opcode.rs != 29) { - ResetX86Protection(); - g_MMU->ResetMemoryStack(); - } + m_Section->CompileExit((uint32_t)-1, (uint32_t)-1, m_RegWorkingSet, bCheck ? CExitInfo::Normal : CExitInfo::Normal_NoSysCheck, true, NULL); + } + m_NextInstruction = END_BLOCK; + } + else + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + return; } -void CRecompilerOps::ADDIU() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::ADDI() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - if (m_Opcode.rt == 0 || (m_Opcode.immediate == 0 && m_Opcode.rs == m_Opcode.rt)) - return; + if (m_Opcode.rt == 0) { return; } - if (g_System->bFastSP()) - { - if (m_Opcode.rs == 29 && m_Opcode.rt == 29) - { - AddConstToX86Reg(Map_MemoryStack(x86_Any, true),(short)m_Opcode.immediate); - } - } + if (g_System->bFastSP() && m_Opcode.rs == 29 && m_Opcode.rt == 29) + { + AddConstToX86Reg(Map_MemoryStack(x86_Any, true), (int16_t)m_Opcode.immediate); + } - if (IsConst(m_Opcode.rs)) { - if (IsMapped(m_Opcode.rt)) - UnMap_GPR(m_Opcode.rt, false); - - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rt, GetMipsRegLo(m_Opcode.rs) + (short)m_Opcode.immediate); - m_RegWorkingSet.SetMipsRegState(m_Opcode.rt,CRegInfo::STATE_CONST_32_SIGN); - } else { - Map_GPR_32bit(m_Opcode.rt, true, m_Opcode.rs); - AddConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt),(short)m_Opcode.immediate); - } - - if (g_System->bFastSP() && m_Opcode.rt == 29 && m_Opcode.rs != 29) { - ResetX86Protection(); - g_MMU->ResetMemoryStack(); - } + if (IsConst(m_Opcode.rs)) + { + if (IsMapped(m_Opcode.rt)) + { + UnMap_GPR(m_Opcode.rt, false); + } + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rt, GetMipsRegLo(m_Opcode.rs) + (int16_t)m_Opcode.immediate); + m_RegWorkingSet.SetMipsRegState(m_Opcode.rt, CRegInfo::STATE_CONST_32_SIGN); + } + else + { + Map_GPR_32bit(m_Opcode.rt, true, m_Opcode.rs); + AddConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt), (int16_t)m_Opcode.immediate); + } + if (g_System->bFastSP() && m_Opcode.rt == 29 && m_Opcode.rs != 29) + { + ResetX86Protection(); + g_MMU->ResetMemoryStack(); + } } -void CRecompilerOps::SLTIU() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rt == 0) - return; +void CRecompilerOps::ADDIU() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - if (IsConst(m_Opcode.rs)) - { - DWORD Result = Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) < ((unsigned)((__int64)((short)m_Opcode.immediate)))?1:0 : - GetMipsRegLo(m_Opcode.rs) < ((unsigned)((short)m_Opcode.immediate))?1:0; - UnMap_GPR(m_Opcode.rt, false); - m_RegWorkingSet.SetMipsRegState(m_Opcode.rt,CRegInfo::STATE_CONST_32_SIGN); - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rt,Result); - } else if (IsMapped(m_Opcode.rs)) { - if (Is64Bit(m_Opcode.rs)) { - BYTE * Jump[2]; + if (m_Opcode.rt == 0 || (m_Opcode.immediate == 0 && m_Opcode.rs == m_Opcode.rt)) + { + return; + } - CompConstToX86reg(GetMipsRegMapHi(m_Opcode.rs),((short)m_Opcode.immediate >> 31)); - JeLabel8("Low Compare",0); - Jump[0] = m_RecompPos - 1; - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - JmpLabel8("Continue",0); - Jump[1] = m_RecompPos - 1; - CPU_Message(""); - CPU_Message(" Low Compare:"); - SetJump8(Jump[0],m_RecompPos); - CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs),(short)m_Opcode.immediate); - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - CPU_Message(""); - CPU_Message(" Continue:"); - SetJump8(Jump[1],m_RecompPos); - Map_GPR_32bit(m_Opcode.rt, false, -1); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rt)); - } else { - CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs),(short)m_Opcode.immediate); - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - Map_GPR_32bit(m_Opcode.rt, false, -1); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rt)); - } - } else if (g_System->b32BitCore()) { - CompConstToVariable((short)m_Opcode.immediate,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]); - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - Map_GPR_32bit(m_Opcode.rt, false, -1); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rt)); - } else { - BYTE * Jump = NULL; + if (g_System->bFastSP()) + { + if (m_Opcode.rs == 29 && m_Opcode.rt == 29) + { + AddConstToX86Reg(Map_MemoryStack(x86_Any, true), (int16_t)m_Opcode.immediate); + } + } - CompConstToVariable(((short)m_Opcode.immediate >> 31),&_GPR[m_Opcode.rs].W[1],CRegName::GPR_Hi[m_Opcode.rs]); - JneLabel8("CompareSet",0); - Jump = m_RecompPos - 1; - CompConstToVariable((short)m_Opcode.immediate,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]); - CPU_Message(""); - CPU_Message(" CompareSet:"); - SetJump8(Jump,m_RecompPos); - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - Map_GPR_32bit(m_Opcode.rt, false, -1); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rt)); - } + if (IsConst(m_Opcode.rs)) + { + if (IsMapped(m_Opcode.rt)) + { + UnMap_GPR(m_Opcode.rt, false); + } + + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rt, GetMipsRegLo(m_Opcode.rs) + (int16_t)m_Opcode.immediate); + m_RegWorkingSet.SetMipsRegState(m_Opcode.rt, CRegInfo::STATE_CONST_32_SIGN); + } + else + { + Map_GPR_32bit(m_Opcode.rt, true, m_Opcode.rs); + AddConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt), (int16_t)m_Opcode.immediate); + } + + if (g_System->bFastSP() && m_Opcode.rt == 29 && m_Opcode.rs != 29) + { + ResetX86Protection(); + g_MMU->ResetMemoryStack(); + } +} + +void CRecompilerOps::SLTIU() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rt == 0) + { + return; + } + + if (IsConst(m_Opcode.rs)) + { + uint32_t Result = Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) < ((unsigned)((int64_t)((int16_t)m_Opcode.immediate))) ? 1 : 0 : + GetMipsRegLo(m_Opcode.rs) < ((unsigned)((int16_t)m_Opcode.immediate)) ? 1 : 0; + UnMap_GPR(m_Opcode.rt, false); + m_RegWorkingSet.SetMipsRegState(m_Opcode.rt, CRegInfo::STATE_CONST_32_SIGN); + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rt, Result); + } + else if (IsMapped(m_Opcode.rs)) + { + if (Is64Bit(m_Opcode.rs)) + { + uint8_t * Jump[2]; + + CompConstToX86reg(GetMipsRegMapHi(m_Opcode.rs), ((int16_t)m_Opcode.immediate >> 31)); + JeLabel8("Low Compare", 0); + Jump[0] = m_RecompPos - 1; + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + JmpLabel8("Continue", 0); + Jump[1] = m_RecompPos - 1; + CPU_Message(""); + CPU_Message(" Low Compare:"); + SetJump8(Jump[0], m_RecompPos); + CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs), (int16_t)m_Opcode.immediate); + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + CPU_Message(""); + CPU_Message(" Continue:"); + SetJump8(Jump[1], m_RecompPos); + Map_GPR_32bit(m_Opcode.rt, false, -1); + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rt)); + } + else + { + CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs), (int16_t)m_Opcode.immediate); + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + Map_GPR_32bit(m_Opcode.rt, false, -1); + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rt)); + } + } + else if (g_System->b32BitCore()) + { + CompConstToVariable((int16_t)m_Opcode.immediate, &_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs]); + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + Map_GPR_32bit(m_Opcode.rt, false, -1); + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rt)); + } + else + { + uint8_t * Jump = NULL; + + CompConstToVariable(((int16_t)m_Opcode.immediate >> 31), &_GPR[m_Opcode.rs].W[1], CRegName::GPR_Hi[m_Opcode.rs]); + JneLabel8("CompareSet", 0); + Jump = m_RecompPos - 1; + CompConstToVariable((int16_t)m_Opcode.immediate, &_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs]); + CPU_Message(""); + CPU_Message(" CompareSet:"); + SetJump8(Jump, m_RecompPos); + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + Map_GPR_32bit(m_Opcode.rt, false, -1); + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rt)); + } } void CRecompilerOps::SLTI() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rt == 0) - return; + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rt == 0) + { + return; + } - if (IsConst(m_Opcode.rs)) { - DWORD Result = Is64Bit(m_Opcode.rs) ? - ((__int64)GetMipsReg(m_Opcode.rs) < (__int64)((short)m_Opcode.immediate) ? 1:0) : - ( GetMipsRegLo_S(m_Opcode.rs) < (short)m_Opcode.immediate?1:0); + if (IsConst(m_Opcode.rs)) + { + uint32_t Result = Is64Bit(m_Opcode.rs) ? + ((int64_t)GetMipsReg(m_Opcode.rs) < (int64_t)((int16_t)m_Opcode.immediate) ? 1 : 0) : + (GetMipsRegLo_S(m_Opcode.rs) < (int16_t)m_Opcode.immediate ? 1 : 0); - UnMap_GPR(m_Opcode.rt, false); - m_RegWorkingSet.SetMipsRegState(m_Opcode.rt,CRegInfo::STATE_CONST_32_SIGN); - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rt,Result); - } else if (IsMapped(m_Opcode.rs)) { - if (Is64Bit(m_Opcode.rs)) { - BYTE * Jump[2]; + UnMap_GPR(m_Opcode.rt, false); + m_RegWorkingSet.SetMipsRegState(m_Opcode.rt, CRegInfo::STATE_CONST_32_SIGN); + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rt, Result); + } + else if (IsMapped(m_Opcode.rs)) + { + if (Is64Bit(m_Opcode.rs)) + { + uint8_t * Jump[2]; - CompConstToX86reg(GetMipsRegMapHi(m_Opcode.rs),((short)m_Opcode.immediate >> 31)); - JeLabel8("Low Compare",0); - Jump[0] = m_RecompPos - 1; - SetlVariable(&m_BranchCompare,"m_BranchCompare"); - JmpLabel8("Continue",0); - Jump[1] = m_RecompPos - 1; - CPU_Message(""); - CPU_Message(" Low Compare:"); - SetJump8(Jump[0],m_RecompPos); - CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs),(short)m_Opcode.immediate); - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - CPU_Message(""); - CPU_Message(" Continue:"); - SetJump8(Jump[1],m_RecompPos); - Map_GPR_32bit(m_Opcode.rt, false, -1); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rt)); - } else { - /* CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs),(short)m_Opcode.immediate); - SetlVariable(&m_BranchCompare,"m_BranchCompare"); - Map_GPR_32bit(m_Opcode.rt, false, -1); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rt)); - */ - ProtectGPR( m_Opcode.rs); - Map_GPR_32bit(m_Opcode.rt, false, -1); - CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs),(short)m_Opcode.immediate); - - if (GetMipsRegMapLo(m_Opcode.rt) > x86_EBX) { - SetlVariable(&m_BranchCompare,"m_BranchCompare"); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rt)); - } else { - Setl(GetMipsRegMapLo(m_Opcode.rt)); - AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt), 1); - } - } - } else if (g_System->b32BitCore()) { - Map_GPR_32bit(m_Opcode.rt, false, -1); - CompConstToVariable((short)m_Opcode.immediate,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]); + CompConstToX86reg(GetMipsRegMapHi(m_Opcode.rs), ((int16_t)m_Opcode.immediate >> 31)); + JeLabel8("Low Compare", 0); + Jump[0] = m_RecompPos - 1; + SetlVariable(&m_BranchCompare, "m_BranchCompare"); + JmpLabel8("Continue", 0); + Jump[1] = m_RecompPos - 1; + CPU_Message(""); + CPU_Message(" Low Compare:"); + SetJump8(Jump[0], m_RecompPos); + CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs), (int16_t)m_Opcode.immediate); + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + CPU_Message(""); + CPU_Message(" Continue:"); + SetJump8(Jump[1], m_RecompPos); + Map_GPR_32bit(m_Opcode.rt, false, -1); + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rt)); + } + else + { + /* CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs),(int16_t)m_Opcode.immediate); + SetlVariable(&m_BranchCompare,"m_BranchCompare"); + Map_GPR_32bit(m_Opcode.rt, false, -1); + MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rt)); + */ + ProtectGPR(m_Opcode.rs); + Map_GPR_32bit(m_Opcode.rt, false, -1); + CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rs), (int16_t)m_Opcode.immediate); - if (GetMipsRegMapLo(m_Opcode.rt) > x86_EBX) { - SetlVariable(&m_BranchCompare,"m_BranchCompare"); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rt)); - } else { - Setl(GetMipsRegMapLo(m_Opcode.rt)); - AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt), 1); - } - } else { - BYTE * Jump[2] = { NULL, NULL }; - CompConstToVariable(((short)m_Opcode.immediate >> 31),&_GPR[m_Opcode.rs].W[1],CRegName::GPR_Hi[m_Opcode.rs]); - JeLabel8("Low Compare",0); - Jump[0] = m_RecompPos - 1; - SetlVariable(&m_BranchCompare,"m_BranchCompare"); - JmpLabel8("Continue",0); - Jump[1] = m_RecompPos - 1; - CPU_Message(""); - CPU_Message(" Low Compare:"); - SetJump8(Jump[0], m_RecompPos); - CompConstToVariable((short)m_Opcode.immediate,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]); - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - if (Jump[1]) - { - CPU_Message(""); - CPU_Message(" Continue:"); - SetJump8(Jump[1],m_RecompPos); - } - Map_GPR_32bit(m_Opcode.rt, false, -1); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rt)); - } + if (GetMipsRegMapLo(m_Opcode.rt) > x86_EBX) + { + SetlVariable(&m_BranchCompare, "m_BranchCompare"); + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rt)); + } + else + { + Setl(GetMipsRegMapLo(m_Opcode.rt)); + AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt), 1); + } + } + } + else if (g_System->b32BitCore()) + { + Map_GPR_32bit(m_Opcode.rt, false, -1); + CompConstToVariable((int16_t)m_Opcode.immediate, &_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs]); + + if (GetMipsRegMapLo(m_Opcode.rt) > x86_EBX) + { + SetlVariable(&m_BranchCompare, "m_BranchCompare"); + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rt)); + } + else + { + Setl(GetMipsRegMapLo(m_Opcode.rt)); + AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt), 1); + } + } + else + { + uint8_t * Jump[2] = { NULL, NULL }; + CompConstToVariable(((int16_t)m_Opcode.immediate >> 31), &_GPR[m_Opcode.rs].W[1], CRegName::GPR_Hi[m_Opcode.rs]); + JeLabel8("Low Compare", 0); + Jump[0] = m_RecompPos - 1; + SetlVariable(&m_BranchCompare, "m_BranchCompare"); + JmpLabel8("Continue", 0); + Jump[1] = m_RecompPos - 1; + CPU_Message(""); + CPU_Message(" Low Compare:"); + SetJump8(Jump[0], m_RecompPos); + CompConstToVariable((int16_t)m_Opcode.immediate, &_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs]); + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + if (Jump[1]) + { + CPU_Message(""); + CPU_Message(" Continue:"); + SetJump8(Jump[1], m_RecompPos); + } + Map_GPR_32bit(m_Opcode.rt, false, -1); + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rt)); + } } -void CRecompilerOps::ANDI() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::ANDI() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - if (m_Opcode.rt == 0) - return; + if (m_Opcode.rt == 0) + { + return; + } - if (IsConst(m_Opcode.rs)) { - if (IsMapped(m_Opcode.rt)) - UnMap_GPR(m_Opcode.rt, false); + if (IsConst(m_Opcode.rs)) + { + if (IsMapped(m_Opcode.rt)) + { + UnMap_GPR(m_Opcode.rt, false); + } - m_RegWorkingSet.SetMipsRegState(m_Opcode.rt,CRegInfo::STATE_CONST_32_SIGN); - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rt, GetMipsRegLo(m_Opcode.rs) & m_Opcode.immediate); - } else if (m_Opcode.immediate != 0) { - Map_GPR_32bit(m_Opcode.rt, false, m_Opcode.rs); - AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt),m_Opcode.immediate); - } else { - Map_GPR_32bit(m_Opcode.rt, false, 0); - } + m_RegWorkingSet.SetMipsRegState(m_Opcode.rt, CRegInfo::STATE_CONST_32_SIGN); + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rt, GetMipsRegLo(m_Opcode.rs) & m_Opcode.immediate); + } + else if (m_Opcode.immediate != 0) + { + Map_GPR_32bit(m_Opcode.rt, false, m_Opcode.rs); + AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt), m_Opcode.immediate); + } + else + { + Map_GPR_32bit(m_Opcode.rt, false, 0); + } } -void CRecompilerOps::ORI() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rt == 0) - return; +void CRecompilerOps::ORI() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rt == 0) + { + return; + } - if (g_System->bFastSP() && m_Opcode.rs == 29 && m_Opcode.rt == 29) { - OrConstToX86Reg(m_Opcode.immediate,Map_MemoryStack(x86_Any, true)); - } + if (g_System->bFastSP() && m_Opcode.rs == 29 && m_Opcode.rt == 29) + { + OrConstToX86Reg(m_Opcode.immediate, Map_MemoryStack(x86_Any, true)); + } - if (IsConst(m_Opcode.rs)) { - if (IsMapped(m_Opcode.rt)) - UnMap_GPR(m_Opcode.rt, false); + if (IsConst(m_Opcode.rs)) + { + if (IsMapped(m_Opcode.rt)) + { + UnMap_GPR(m_Opcode.rt, false); + } - m_RegWorkingSet.SetMipsRegState(m_Opcode.rt,GetMipsRegState(m_Opcode.rs)); - m_RegWorkingSet.SetMipsRegHi(m_Opcode.rt,GetMipsRegHi(m_Opcode.rs)); - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rt,GetMipsRegLo(m_Opcode.rs) | m_Opcode.immediate); - } else if (IsMapped(m_Opcode.rs)) { - if (g_System->b32BitCore()) - { - Map_GPR_32bit(m_Opcode.rt,true,m_Opcode.rs); - } else { - if (Is64Bit(m_Opcode.rs)) { - Map_GPR_64bit(m_Opcode.rt,m_Opcode.rs); - } else { - Map_GPR_32bit(m_Opcode.rt,IsSigned(m_Opcode.rs),m_Opcode.rs); - } - } - OrConstToX86Reg(m_Opcode.immediate,GetMipsRegMapLo(m_Opcode.rt)); - } else { - if (g_System->b32BitCore()) - { - Map_GPR_32bit(m_Opcode.rt,true,m_Opcode.rs); - } else { - Map_GPR_64bit(m_Opcode.rt,m_Opcode.rs); - } - OrConstToX86Reg(m_Opcode.immediate,GetMipsRegMapLo(m_Opcode.rt)); - } + m_RegWorkingSet.SetMipsRegState(m_Opcode.rt, GetMipsRegState(m_Opcode.rs)); + m_RegWorkingSet.SetMipsRegHi(m_Opcode.rt, GetMipsRegHi(m_Opcode.rs)); + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rt, GetMipsRegLo(m_Opcode.rs) | m_Opcode.immediate); + } + else if (IsMapped(m_Opcode.rs)) + { + if (g_System->b32BitCore()) + { + Map_GPR_32bit(m_Opcode.rt, true, m_Opcode.rs); + } + else + { + if (Is64Bit(m_Opcode.rs)) + { + Map_GPR_64bit(m_Opcode.rt, m_Opcode.rs); + } + else + { + Map_GPR_32bit(m_Opcode.rt, IsSigned(m_Opcode.rs), m_Opcode.rs); + } + } + OrConstToX86Reg(m_Opcode.immediate, GetMipsRegMapLo(m_Opcode.rt)); + } + else + { + if (g_System->b32BitCore()) + { + Map_GPR_32bit(m_Opcode.rt, true, m_Opcode.rs); + } + else + { + Map_GPR_64bit(m_Opcode.rt, m_Opcode.rs); + } + OrConstToX86Reg(m_Opcode.immediate, GetMipsRegMapLo(m_Opcode.rt)); + } - if (g_System->bFastSP() && m_Opcode.rt == 29 && m_Opcode.rs != 29) { - ResetX86Protection(); - g_MMU->ResetMemoryStack(); - } + if (g_System->bFastSP() && m_Opcode.rt == 29 && m_Opcode.rs != 29) + { + ResetX86Protection(); + g_MMU->ResetMemoryStack(); + } } -void CRecompilerOps::XORI() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rt == 0) - return; +void CRecompilerOps::XORI() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rt == 0) + { + return; + } - if (IsConst(m_Opcode.rs)) { - if (m_Opcode.rs != m_Opcode.rt) - UnMap_GPR(m_Opcode.rt, false); + if (IsConst(m_Opcode.rs)) + { + if (m_Opcode.rs != m_Opcode.rt) + { + UnMap_GPR(m_Opcode.rt, false); + } - m_RegWorkingSet.SetMipsRegState(m_Opcode.rt,GetMipsRegState(m_Opcode.rs)); - m_RegWorkingSet.SetMipsRegHi(m_Opcode.rt,GetMipsRegHi(m_Opcode.rs)); - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rt,GetMipsRegLo(m_Opcode.rs) ^ m_Opcode.immediate); - } else { - if (IsMapped(m_Opcode.rs) && Is32Bit(m_Opcode.rs)) { - Map_GPR_32bit(m_Opcode.rt,IsSigned(m_Opcode.rs),m_Opcode.rs); - } else if (g_System->b32BitCore()) { - Map_GPR_32bit(m_Opcode.rt,true,m_Opcode.rs); - } else { - Map_GPR_64bit(m_Opcode.rt,m_Opcode.rs); - } - if (m_Opcode.immediate != 0) { XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt),m_Opcode.immediate); } - } + m_RegWorkingSet.SetMipsRegState(m_Opcode.rt, GetMipsRegState(m_Opcode.rs)); + m_RegWorkingSet.SetMipsRegHi(m_Opcode.rt, GetMipsRegHi(m_Opcode.rs)); + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rt, GetMipsRegLo(m_Opcode.rs) ^ m_Opcode.immediate); + } + else + { + if (IsMapped(m_Opcode.rs) && Is32Bit(m_Opcode.rs)) + { + Map_GPR_32bit(m_Opcode.rt, IsSigned(m_Opcode.rs), m_Opcode.rs); + } + else if (g_System->b32BitCore()) + { + Map_GPR_32bit(m_Opcode.rt, true, m_Opcode.rs); + } + else + { + Map_GPR_64bit(m_Opcode.rt, m_Opcode.rs); + } + if (m_Opcode.immediate != 0) { XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt), m_Opcode.immediate); } + } } -void CRecompilerOps::LUI() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rt == 0) - return; +void CRecompilerOps::LUI() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rt == 0) + { + return; + } - if (g_System->bFastSP() && m_Opcode.rt == 29) { - x86Reg Reg = Map_MemoryStack(x86_Any, true, false); - DWORD Address; + if (g_System->bFastSP() && m_Opcode.rt == 29) + { + x86Reg Reg = Map_MemoryStack(x86_Any, true, false); + uint32_t Address; - g_TransVaddr->TranslateVaddr(((short)m_Opcode.offset << 16), (uint32_t &)Address); - if (Reg < 0) { - MoveConstToVariable((DWORD)(Address + g_MMU->Rdram()), &(g_Recompiler->MemoryStackPos()), "MemoryStack"); - } else { - MoveConstToX86reg((DWORD)(Address + g_MMU->Rdram()), Reg); - } - } + g_TransVaddr->TranslateVaddr(((int16_t)m_Opcode.offset << 16), Address); + if (Reg < 0) + { + MoveConstToVariable((uint32_t)(Address + g_MMU->Rdram()), &(g_Recompiler->MemoryStackPos()), "MemoryStack"); + } + else + { + MoveConstToX86reg((uint32_t)(Address + g_MMU->Rdram()), Reg); + } + } - UnMap_GPR(m_Opcode.rt, false); - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rt, ((short)m_Opcode.offset << 16)); - m_RegWorkingSet.SetMipsRegState(m_Opcode.rt,CRegInfo::STATE_CONST_32_SIGN); + UnMap_GPR(m_Opcode.rt, false); + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rt, ((int16_t)m_Opcode.offset << 16)); + m_RegWorkingSet.SetMipsRegState(m_Opcode.rt, CRegInfo::STATE_CONST_32_SIGN); } -void CRecompilerOps::DADDIU() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::DADDIU() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - if (m_Opcode.rs != 0) - UnMap_GPR(m_Opcode.rs, true); + if (m_Opcode.rs != 0) + { + UnMap_GPR(m_Opcode.rs, true); + } - if (m_Opcode.rs != 0) - UnMap_GPR(m_Opcode.rt, true); + if (m_Opcode.rs != 0) + { + UnMap_GPR(m_Opcode.rt, true); + } - BeforeCallDirect(m_RegWorkingSet); - MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); - Call_Direct(R4300iOp::DADDIU, "R4300iOp::DADDIU"); - AfterCallDirect(m_RegWorkingSet); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); + Call_Direct(R4300iOp::DADDIU, "R4300iOp::DADDIU"); + AfterCallDirect(m_RegWorkingSet); } -void CRecompilerOps::CACHE(){ - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::CACHE() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - if (g_Settings->LoadDword(Game_SMM_Cache) == 0) - { - return; - } + if (g_Settings->LoadDword(Game_SMM_Cache) == 0) + { + return; + } - switch(m_Opcode.rt) { - case 0: - case 16: - BeforeCallDirect(m_RegWorkingSet); - PushImm32("CRecompiler::Remove_Cache",CRecompiler::Remove_Cache); - PushImm32("0x20",0x20); - if (IsConst(m_Opcode.base)) { - DWORD Address = GetMipsRegLo(m_Opcode.base) + (short)m_Opcode.offset; - PushImm32("Address",Address); - } else if (IsMapped(m_Opcode.base)) { - AddConstToX86Reg(GetMipsRegMapLo(m_Opcode.base),(short)m_Opcode.offset); - Push(GetMipsRegMapLo(m_Opcode.base)); - } else { - MoveVariableToX86reg(&_GPR[m_Opcode.base].UW[0],CRegName::GPR_Lo[m_Opcode.base],x86_EAX); - AddConstToX86Reg(x86_EAX,(short)m_Opcode.offset); - Push(x86_EAX); - } - MoveConstToX86reg((DWORD)g_Recompiler,x86_ECX); - Call_Direct(AddressOf(&CRecompiler::ClearRecompCode_Virt), "CRecompiler::ClearRecompCode_Virt"); - AfterCallDirect(m_RegWorkingSet); - break; - case 1: - case 3: - case 13: - case 5: - case 8: - case 9: - case 17: - case 21: - case 25: - break; - default: - if (bHaveDebugger()) - { - g_Notify->DisplayError(stdstr_f("cache: %d",m_Opcode.rt).ToUTF16().c_str()); - } - } + switch (m_Opcode.rt) + { + case 0: + case 16: + BeforeCallDirect(m_RegWorkingSet); + PushImm32("CRecompiler::Remove_Cache", CRecompiler::Remove_Cache); + PushImm32("0x20", 0x20); + if (IsConst(m_Opcode.base)) + { + uint32_t Address = GetMipsRegLo(m_Opcode.base) + (int16_t)m_Opcode.offset; + PushImm32("Address", Address); + } + else if (IsMapped(m_Opcode.base)) + { + AddConstToX86Reg(GetMipsRegMapLo(m_Opcode.base), (int16_t)m_Opcode.offset); + Push(GetMipsRegMapLo(m_Opcode.base)); + } + else + { + MoveVariableToX86reg(&_GPR[m_Opcode.base].UW[0], CRegName::GPR_Lo[m_Opcode.base], x86_EAX); + AddConstToX86Reg(x86_EAX, (int16_t)m_Opcode.offset); + Push(x86_EAX); + } + MoveConstToX86reg((uint32_t)g_Recompiler, x86_ECX); + Call_Direct(AddressOf(&CRecompiler::ClearRecompCode_Virt), "CRecompiler::ClearRecompCode_Virt"); + AfterCallDirect(m_RegWorkingSet); + break; + case 1: + case 3: + case 13: + case 5: + case 8: + case 9: + case 17: + case 21: + case 25: + break; + default: + if (bHaveDebugger()) + { + g_Notify->DisplayError(stdstr_f("cache: %d", m_Opcode.rt).ToUTF16().c_str()); + } + } } /********************** R4300i OpCodes: Special **********************/ -void CRecompilerOps::SPECIAL_SLL() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::SPECIAL_SLL() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - if (m_Opcode.rd == 0) - return; + if (m_Opcode.rd == 0) + { + return; + } + if (IsConst(m_Opcode.rt)) + { + if (IsMapped(m_Opcode.rd)) + { + UnMap_GPR(m_Opcode.rd, false); + } - if (IsConst(m_Opcode.rt)) { - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); - - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, GetMipsRegLo(m_Opcode.rt) << m_Opcode.sa); - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - return; - } - if (m_Opcode.rd != m_Opcode.rt && IsMapped(m_Opcode.rt)) { - switch (m_Opcode.sa) { - case 0: - Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); - break; - case 1: - ProtectGPR(m_Opcode.rt); - Map_GPR_32bit(m_Opcode.rd, true, -1); - LeaRegReg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(m_Opcode.rt), 0, Multip_x2); - break; - case 2: - ProtectGPR(m_Opcode.rt); - Map_GPR_32bit(m_Opcode.rd, true, -1); - LeaRegReg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(m_Opcode.rt), 0, Multip_x4); - break; - case 3: - ProtectGPR(m_Opcode.rt); - Map_GPR_32bit(m_Opcode.rd, true, -1); - LeaRegReg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(m_Opcode.rt), 0, Multip_x8); - break; - default: - Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); - ShiftLeftSignImmed(GetMipsRegMapLo(m_Opcode.rd),(BYTE)m_Opcode.sa); - } - } else { - Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); - ShiftLeftSignImmed(GetMipsRegMapLo(m_Opcode.rd),(BYTE)m_Opcode.sa); - } + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, GetMipsRegLo(m_Opcode.rt) << m_Opcode.sa); + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + return; + } + if (m_Opcode.rd != m_Opcode.rt && IsMapped(m_Opcode.rt)) + { + switch (m_Opcode.sa) + { + case 0: + Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); + break; + case 1: + ProtectGPR(m_Opcode.rt); + Map_GPR_32bit(m_Opcode.rd, true, -1); + LeaRegReg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rt), 0, Multip_x2); + break; + case 2: + ProtectGPR(m_Opcode.rt); + Map_GPR_32bit(m_Opcode.rd, true, -1); + LeaRegReg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rt), 0, Multip_x4); + break; + case 3: + ProtectGPR(m_Opcode.rt); + Map_GPR_32bit(m_Opcode.rd, true, -1); + LeaRegReg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rt), 0, Multip_x8); + break; + default: + Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); + ShiftLeftSignImmed(GetMipsRegMapLo(m_Opcode.rd), (uint8_t)m_Opcode.sa); + } + } + else + { + Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); + ShiftLeftSignImmed(GetMipsRegMapLo(m_Opcode.rd), (uint8_t)m_Opcode.sa); + } } -void CRecompilerOps::SPECIAL_SRL() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rd == 0) - return; +void CRecompilerOps::SPECIAL_SRL() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rd == 0) + { + return; + } - if (IsConst(m_Opcode.rt)) { - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); + if (IsConst(m_Opcode.rt)) + { + if (IsMapped(m_Opcode.rd)) + { + UnMap_GPR(m_Opcode.rd, false); + } - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, GetMipsRegLo(m_Opcode.rt) >> m_Opcode.sa); - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - return; - } - Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); - ShiftRightUnsignImmed(GetMipsRegMapLo(m_Opcode.rd),(BYTE)m_Opcode.sa); + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, GetMipsRegLo(m_Opcode.rt) >> m_Opcode.sa); + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + return; + } + Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); + ShiftRightUnsignImmed(GetMipsRegMapLo(m_Opcode.rd), (uint8_t)m_Opcode.sa); } -void CRecompilerOps::SPECIAL_SRA() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rd == 0) - return; - - if (IsConst(m_Opcode.rt)) { - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); +void CRecompilerOps::SPECIAL_SRA() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rd == 0) + { + return; + } - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, GetMipsRegLo_S(m_Opcode.rt) >> m_Opcode.sa); - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - return; - } - Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); - ShiftRightSignImmed(GetMipsRegMapLo(m_Opcode.rd),(BYTE)m_Opcode.sa); + if (IsConst(m_Opcode.rt)) + { + if (IsMapped(m_Opcode.rd)) + { + UnMap_GPR(m_Opcode.rd, false); + } + + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, GetMipsRegLo_S(m_Opcode.rt) >> m_Opcode.sa); + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + return; + } + Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); + ShiftRightSignImmed(GetMipsRegMapLo(m_Opcode.rd), (uint8_t)m_Opcode.sa); } -void CRecompilerOps::SPECIAL_SLLV() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rd == 0) - return; - - if (IsConst(m_Opcode.rs)) { - DWORD Shift = (GetMipsRegLo(m_Opcode.rs) & 0x1F); - if (IsConst(m_Opcode.rt)) { - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); +void CRecompilerOps::SPECIAL_SLLV() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rd == 0) + { + return; + } - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, GetMipsRegLo(m_Opcode.rt) << Shift); - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else { - Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); - ShiftLeftSignImmed(GetMipsRegMapLo(m_Opcode.rd),(BYTE)Shift); - } - return; - } - Map_TempReg(x86_ECX, m_Opcode.rs, false); - AndConstToX86Reg(x86_ECX, 0x1F); - Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); - ShiftLeftSign(GetMipsRegMapLo(m_Opcode.rd)); + if (IsConst(m_Opcode.rs)) + { + uint32_t Shift = (GetMipsRegLo(m_Opcode.rs) & 0x1F); + if (IsConst(m_Opcode.rt)) + { + if (IsMapped(m_Opcode.rd)) + { + UnMap_GPR(m_Opcode.rd, false); + } + + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, GetMipsRegLo(m_Opcode.rt) << Shift); + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else + { + Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); + ShiftLeftSignImmed(GetMipsRegMapLo(m_Opcode.rd), (uint8_t)Shift); + } + return; + } + Map_TempReg(x86_ECX, m_Opcode.rs, false); + AndConstToX86Reg(x86_ECX, 0x1F); + Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); + ShiftLeftSign(GetMipsRegMapLo(m_Opcode.rd)); } -void CRecompilerOps::SPECIAL_SRLV() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rd == 0) - return; +void CRecompilerOps::SPECIAL_SRLV() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rd == 0) + { + return; + } - if (IsKnown(m_Opcode.rs) && IsConst(m_Opcode.rs)) { - DWORD Shift = (GetMipsRegLo(m_Opcode.rs) & 0x1F); - if (IsConst(m_Opcode.rt)) { - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); + if (IsKnown(m_Opcode.rs) && IsConst(m_Opcode.rs)) + { + uint32_t Shift = (GetMipsRegLo(m_Opcode.rs) & 0x1F); + if (IsConst(m_Opcode.rt)) + { + if (IsMapped(m_Opcode.rd)) + { + UnMap_GPR(m_Opcode.rd, false); + } + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, GetMipsRegLo(m_Opcode.rt) >> Shift); + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + return; + } + Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); + ShiftRightUnsignImmed(GetMipsRegMapLo(m_Opcode.rd), (uint8_t)Shift); + return; + } - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, GetMipsRegLo(m_Opcode.rt) >> Shift); - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - return; - } - Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); - ShiftRightUnsignImmed(GetMipsRegMapLo(m_Opcode.rd),(BYTE)Shift); - return; - } - - Map_TempReg(x86_ECX, m_Opcode.rs, false); - AndConstToX86Reg(x86_ECX, 0x1F); - Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); - ShiftRightUnsign(GetMipsRegMapLo(m_Opcode.rd)); + Map_TempReg(x86_ECX, m_Opcode.rs, false); + AndConstToX86Reg(x86_ECX, 0x1F); + Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); + ShiftRightUnsign(GetMipsRegMapLo(m_Opcode.rd)); } -void CRecompilerOps::SPECIAL_SRAV() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rd == 0) - return; - - if (IsKnown(m_Opcode.rs) && IsConst(m_Opcode.rs)) { - DWORD Shift = (GetMipsRegLo(m_Opcode.rs) & 0x1F); - if (IsConst(m_Opcode.rt)) { - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); +void CRecompilerOps::SPECIAL_SRAV() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rd == 0) + { + return; + } - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, GetMipsRegLo_S(m_Opcode.rt) >> Shift); - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - return; - } - Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); - ShiftRightSignImmed(GetMipsRegMapLo(m_Opcode.rd),(BYTE)Shift); - return; - } - Map_TempReg(x86_ECX, m_Opcode.rs, false); - AndConstToX86Reg(x86_ECX,0x1F); - Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); - ShiftRightSign(GetMipsRegMapLo(m_Opcode.rd)); + if (IsKnown(m_Opcode.rs) && IsConst(m_Opcode.rs)) + { + uint32_t Shift = (GetMipsRegLo(m_Opcode.rs) & 0x1F); + if (IsConst(m_Opcode.rt)) + { + if (IsMapped(m_Opcode.rd)) + { + UnMap_GPR(m_Opcode.rd, false); + } + + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, GetMipsRegLo_S(m_Opcode.rt) >> Shift); + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + return; + } + Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); + ShiftRightSignImmed(GetMipsRegMapLo(m_Opcode.rd), (uint8_t)Shift); + return; + } + Map_TempReg(x86_ECX, m_Opcode.rs, false); + AndConstToX86Reg(x86_ECX, 0x1F); + Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); + ShiftRightSign(GetMipsRegMapLo(m_Opcode.rd)); } -void CRecompilerOps::SPECIAL_JR() { - if (m_NextInstruction == NORMAL) - { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if ((m_CompilePC & 0xFFC) == 0xFFC) - { - if (IsMapped(m_Opcode.rs)) { - MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rs), &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); - m_RegWorkingSet.WriteBackRegisters(); - } else { - m_RegWorkingSet.WriteBackRegisters(); - MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rs, false), &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); - } - OverflowDelaySlot(true); - return; - } +void CRecompilerOps::SPECIAL_JR() +{ + if (m_NextInstruction == NORMAL) + { + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if ((m_CompilePC & 0xFFC) == 0xFFC) + { + if (IsMapped(m_Opcode.rs)) + { + MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rs), &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); + m_RegWorkingSet.WriteBackRegisters(); + } + else + { + m_RegWorkingSet.WriteBackRegisters(); + MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rs, false), &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); + } + OverflowDelaySlot(true); + return; + } - m_Section->m_Jump.FallThrough = false; - m_Section->m_Jump.LinkLocation = NULL; - m_Section->m_Jump.LinkLocation2 = NULL; - m_Section->m_Cont.FallThrough = false; - m_Section->m_Cont.LinkLocation = NULL; - m_Section->m_Cont.LinkLocation2 = NULL; + m_Section->m_Jump.FallThrough = false; + m_Section->m_Jump.LinkLocation = NULL; + m_Section->m_Jump.LinkLocation2 = NULL; + m_Section->m_Cont.FallThrough = false; + m_Section->m_Cont.LinkLocation = NULL; + m_Section->m_Cont.LinkLocation2 = NULL; - if (DelaySlotEffectsCompare(m_CompilePC,m_Opcode.rs,0)) { - if (IsConst(m_Opcode.rs)) { - MoveConstToVariable(GetMipsRegLo(m_Opcode.rs), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); - } else if (IsMapped(m_Opcode.rs)) { - MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rs), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); - } else { - MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rs, false), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); - } - } - m_NextInstruction = DO_DELAY_SLOT; - } - else if (m_NextInstruction == DELAY_SLOT_DONE) - { - if (DelaySlotEffectsCompare(m_CompilePC,m_Opcode.rs,0)) - { - m_Section->CompileExit(m_CompilePC, (DWORD)-1, m_RegWorkingSet, CExitInfo::Normal, true, NULL); - } - else - { - UpdateCounters(m_RegWorkingSet,true,true); - if (IsConst(m_Opcode.rs)) - { - MoveConstToVariable(GetMipsRegLo(m_Opcode.rs), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); - } - else if (IsMapped(m_Opcode.rs)) - { - MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rs), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); - } - else - { - MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rs, false), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); - } - m_Section->CompileExit((DWORD)-1, (DWORD)-1, m_RegWorkingSet, CExitInfo::Normal, true, NULL); - if (m_Section->m_JumpSection) - { - m_Section->GenerateSectionLinkage(); - } - } - m_NextInstruction = END_BLOCK; - } - else if (bHaveDebugger()) - { - g_Notify->DisplayError(stdstr_f("WTF\n\nBranch\nNextInstruction = %X", m_NextInstruction).ToUTF16().c_str()); - } + if (DelaySlotEffectsCompare(m_CompilePC, m_Opcode.rs, 0)) + { + if (IsConst(m_Opcode.rs)) + { + MoveConstToVariable(GetMipsRegLo(m_Opcode.rs), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); + } + else if (IsMapped(m_Opcode.rs)) + { + MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rs), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); + } + else + { + MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rs, false), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); + } + } + m_NextInstruction = DO_DELAY_SLOT; + } + else if (m_NextInstruction == DELAY_SLOT_DONE) + { + if (DelaySlotEffectsCompare(m_CompilePC, m_Opcode.rs, 0)) + { + m_Section->CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal, true, NULL); + } + else + { + UpdateCounters(m_RegWorkingSet, true, true); + if (IsConst(m_Opcode.rs)) + { + MoveConstToVariable(GetMipsRegLo(m_Opcode.rs), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); + } + else if (IsMapped(m_Opcode.rs)) + { + MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rs), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); + } + else + { + MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rs, false), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); + } + m_Section->CompileExit((uint32_t)-1, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal, true, NULL); + if (m_Section->m_JumpSection) + { + m_Section->GenerateSectionLinkage(); + } + } + m_NextInstruction = END_BLOCK; + } + else if (bHaveDebugger()) + { + g_Notify->DisplayError(stdstr_f("WTF\n\nBranch\nNextInstruction = %X", m_NextInstruction).ToUTF16().c_str()); + } } void CRecompilerOps::SPECIAL_JALR() { - if (m_NextInstruction == NORMAL) - { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (DelaySlotEffectsCompare(m_CompilePC,m_Opcode.rs,0) && (m_CompilePC & 0xFFC) != 0xFFC) - { - if (IsConst(m_Opcode.rs)) - { - MoveConstToVariable(GetMipsRegLo(m_Opcode.rs), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); - } - else if (IsMapped(m_Opcode.rs)) - { - MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rs), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); - } - else - { - MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rs, false), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); - } - } - UnMap_GPR(m_Opcode.rd, false); - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd,m_CompilePC + 8); - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - if ((m_CompilePC & 0xFFC) == 0xFFC) - { - if (IsMapped(m_Opcode.rs)) - { - MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rs), &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); - m_RegWorkingSet.WriteBackRegisters(); - } - else - { - m_RegWorkingSet.WriteBackRegisters(); - MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rs, false), &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); - } - OverflowDelaySlot(true); - return; - } + if (m_NextInstruction == NORMAL) + { + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (DelaySlotEffectsCompare(m_CompilePC, m_Opcode.rs, 0) && (m_CompilePC & 0xFFC) != 0xFFC) + { + if (IsConst(m_Opcode.rs)) + { + MoveConstToVariable(GetMipsRegLo(m_Opcode.rs), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); + } + else if (IsMapped(m_Opcode.rs)) + { + MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rs), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); + } + else + { + MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rs, false), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); + } + } + UnMap_GPR(m_Opcode.rd, false); + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, m_CompilePC + 8); + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + if ((m_CompilePC & 0xFFC) == 0xFFC) + { + if (IsMapped(m_Opcode.rs)) + { + MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rs), &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); + m_RegWorkingSet.WriteBackRegisters(); + } + else + { + m_RegWorkingSet.WriteBackRegisters(); + MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rs, false), &R4300iOp::m_JumpToLocation, "R4300iOp::m_JumpToLocation"); + } + OverflowDelaySlot(true); + return; + } - m_Section->m_Jump.FallThrough = false; - m_Section->m_Jump.LinkLocation = NULL; - m_Section->m_Jump.LinkLocation2 = NULL; - m_Section->m_Cont.FallThrough = false; - m_Section->m_Cont.LinkLocation = NULL; - m_Section->m_Cont.LinkLocation2 = NULL; + m_Section->m_Jump.FallThrough = false; + m_Section->m_Jump.LinkLocation = NULL; + m_Section->m_Jump.LinkLocation2 = NULL; + m_Section->m_Cont.FallThrough = false; + m_Section->m_Cont.LinkLocation = NULL; + m_Section->m_Cont.LinkLocation2 = NULL; - m_NextInstruction = DO_DELAY_SLOT; - } - else if (m_NextInstruction == DELAY_SLOT_DONE ) - { - if (DelaySlotEffectsCompare(m_CompilePC,m_Opcode.rs,0)) - { - m_Section->CompileExit(m_CompilePC, (DWORD)-1, m_RegWorkingSet, CExitInfo::Normal, true, NULL); - } - else - { - UpdateCounters(m_RegWorkingSet,true,true); - if (IsConst(m_Opcode.rs)) - { - MoveConstToVariable(GetMipsRegLo(m_Opcode.rs), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); - } - else if (IsMapped(m_Opcode.rs)) - { - MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rs), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); - } - else - { - MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rs, false), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); - } - m_Section->CompileExit((DWORD)-1, (DWORD)-1, m_RegWorkingSet, CExitInfo::Normal, true, NULL); - if (m_Section->m_JumpSection) - { - m_Section->GenerateSectionLinkage(); - } - } - m_NextInstruction = END_BLOCK; - } - else if (bHaveDebugger()) - { - g_Notify->DisplayError(stdstr_f("WTF\n\nBranch\nNextInstruction = %X", m_NextInstruction).ToUTF16().c_str()); - } + m_NextInstruction = DO_DELAY_SLOT; + } + else if (m_NextInstruction == DELAY_SLOT_DONE) + { + if (DelaySlotEffectsCompare(m_CompilePC, m_Opcode.rs, 0)) + { + m_Section->CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal, true, NULL); + } + else + { + UpdateCounters(m_RegWorkingSet, true, true); + if (IsConst(m_Opcode.rs)) + { + MoveConstToVariable(GetMipsRegLo(m_Opcode.rs), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); + } + else if (IsMapped(m_Opcode.rs)) + { + MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rs), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); + } + else + { + MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rs, false), _PROGRAM_COUNTER, "PROGRAM_COUNTER"); + } + m_Section->CompileExit((uint32_t)-1, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal, true, NULL); + if (m_Section->m_JumpSection) + { + m_Section->GenerateSectionLinkage(); + } + } + m_NextInstruction = END_BLOCK; + } + else if (bHaveDebugger()) + { + g_Notify->DisplayError(stdstr_f("WTF\n\nBranch\nNextInstruction = %X", m_NextInstruction).ToUTF16().c_str()); + } } void CRecompilerOps::SPECIAL_SYSCALL() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - m_Section->CompileExit(m_CompilePC, (DWORD)-1, m_RegWorkingSet, CExitInfo::DoSysCall, true, NULL); - m_NextInstruction = END_BLOCK; + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + m_Section->CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::DoSysCall, true, NULL); + m_NextInstruction = END_BLOCK; } -void CRecompilerOps::SPECIAL_MFLO() +void CRecompilerOps::SPECIAL_MFLO() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rd == 0) { return; } + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rd == 0) { return; } - Map_GPR_64bit(m_Opcode.rd,-1); - MoveVariableToX86reg(&_RegLO->UW[0],"_RegLO->UW[0]",GetMipsRegMapLo(m_Opcode.rd)); - MoveVariableToX86reg(&_RegLO->UW[1],"_RegLO->UW[1]",GetMipsRegMapHi(m_Opcode.rd)); + Map_GPR_64bit(m_Opcode.rd, -1); + MoveVariableToX86reg(&_RegLO->UW[0], "_RegLO->UW[0]", GetMipsRegMapLo(m_Opcode.rd)); + MoveVariableToX86reg(&_RegLO->UW[1], "_RegLO->UW[1]", GetMipsRegMapHi(m_Opcode.rd)); } -void CRecompilerOps::SPECIAL_MTLO() +void CRecompilerOps::SPECIAL_MTLO() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - if (IsKnown(m_Opcode.rs) && IsConst(m_Opcode.rs)) - { - if (Is64Bit(m_Opcode.rs)) - { - MoveConstToVariable(GetMipsRegHi(m_Opcode.rs),&_RegLO->UW[1],"_RegLO->UW[1]"); - } - else if (IsSigned(m_Opcode.rs) && ((GetMipsRegLo(m_Opcode.rs) & 0x80000000) != 0)) - { - MoveConstToVariable(0xFFFFFFFF,&_RegLO->UW[1],"_RegLO->UW[1]"); - } - else - { - MoveConstToVariable(0,&_RegLO->UW[1],"_RegLO->UW[1]"); - } - MoveConstToVariable(GetMipsRegLo(m_Opcode.rs), &_RegLO->UW[0],"_RegLO->UW[0]"); - } - else if (IsKnown(m_Opcode.rs) && IsMapped(m_Opcode.rs)) - { - if (Is64Bit(m_Opcode.rs)) - { - MoveX86regToVariable(GetMipsRegMapHi(m_Opcode.rs),&_RegLO->UW[1],"_RegLO->UW[1]"); - } - else if (IsSigned(m_Opcode.rs)) - { - MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rs, true), &_RegLO->UW[1], "_RegLO->UW[1]"); - } - else - { - MoveConstToVariable(0,&_RegLO->UW[1],"_RegLO->UW[1]"); - } - MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rs), &_RegLO->UW[0],"_RegLO->UW[0]"); - } - else - { - x86Reg reg = Map_TempReg(x86_Any, m_Opcode.rs, true); - MoveX86regToVariable(reg,&_RegLO->UW[1],"_RegLO->UW[1]"); - MoveX86regToVariable(Map_TempReg(reg, m_Opcode.rs, false), &_RegLO->UW[0], "_RegLO->UW[0]"); - } + if (IsKnown(m_Opcode.rs) && IsConst(m_Opcode.rs)) + { + if (Is64Bit(m_Opcode.rs)) + { + MoveConstToVariable(GetMipsRegHi(m_Opcode.rs), &_RegLO->UW[1], "_RegLO->UW[1]"); + } + else if (IsSigned(m_Opcode.rs) && ((GetMipsRegLo(m_Opcode.rs) & 0x80000000) != 0)) + { + MoveConstToVariable(0xFFFFFFFF, &_RegLO->UW[1], "_RegLO->UW[1]"); + } + else + { + MoveConstToVariable(0, &_RegLO->UW[1], "_RegLO->UW[1]"); + } + MoveConstToVariable(GetMipsRegLo(m_Opcode.rs), &_RegLO->UW[0], "_RegLO->UW[0]"); + } + else if (IsKnown(m_Opcode.rs) && IsMapped(m_Opcode.rs)) + { + if (Is64Bit(m_Opcode.rs)) + { + MoveX86regToVariable(GetMipsRegMapHi(m_Opcode.rs), &_RegLO->UW[1], "_RegLO->UW[1]"); + } + else if (IsSigned(m_Opcode.rs)) + { + MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rs, true), &_RegLO->UW[1], "_RegLO->UW[1]"); + } + else + { + MoveConstToVariable(0, &_RegLO->UW[1], "_RegLO->UW[1]"); + } + MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rs), &_RegLO->UW[0], "_RegLO->UW[0]"); + } + else + { + x86Reg reg = Map_TempReg(x86_Any, m_Opcode.rs, true); + MoveX86regToVariable(reg, &_RegLO->UW[1], "_RegLO->UW[1]"); + MoveX86regToVariable(Map_TempReg(reg, m_Opcode.rs, false), &_RegLO->UW[0], "_RegLO->UW[0]"); + } } -void CRecompilerOps::SPECIAL_MFHI() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rd == 0) { return; } - - Map_GPR_64bit(m_Opcode.rd,-1); - MoveVariableToX86reg(&_RegHI->UW[0],"_RegHI->UW[0]",GetMipsRegMapLo(m_Opcode.rd)); - MoveVariableToX86reg(&_RegHI->UW[1],"_RegHI->UW[1]",GetMipsRegMapHi(m_Opcode.rd)); -} - -void CRecompilerOps::SPECIAL_MTHI() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - if (IsKnown(m_Opcode.rs) && IsConst(m_Opcode.rs)) { - if (Is64Bit(m_Opcode.rs)) { - MoveConstToVariable(GetMipsRegHi(m_Opcode.rs),&_RegHI->UW[1],"_RegHI->UW[1]"); - } else if (IsSigned(m_Opcode.rs) && ((GetMipsRegLo(m_Opcode.rs) & 0x80000000) != 0)) { - MoveConstToVariable(0xFFFFFFFF,&_RegHI->UW[1],"_RegHI->UW[1]"); - } else { - MoveConstToVariable(0,&_RegHI->UW[1],"_RegHI->UW[1]"); - } - MoveConstToVariable(GetMipsRegLo(m_Opcode.rs), &_RegHI->UW[0],"_RegHI->UW[0]"); - } else if (IsKnown(m_Opcode.rs) && IsMapped(m_Opcode.rs)) { - if (Is64Bit(m_Opcode.rs)) { - MoveX86regToVariable(GetMipsRegMapHi(m_Opcode.rs),&_RegHI->UW[1],"_RegHI->UW[1]"); - } else if (IsSigned(m_Opcode.rs)) { - MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rs, true), &_RegHI->UW[1], "_RegHI->UW[1]"); - } else { - MoveConstToVariable(0,&_RegHI->UW[1],"_RegHI->UW[1]"); - } - MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rs), &_RegHI->UW[0],"_RegHI->UW[0]"); - } else { - x86Reg reg = Map_TempReg(x86_Any, m_Opcode.rs, true); - MoveX86regToVariable(reg, &_RegHI->UW[1], "_RegHI->UW[1]"); - MoveX86regToVariable(Map_TempReg(reg, m_Opcode.rs, false), &_RegHI->UW[0], "_RegHI->UW[0]"); - } -} - -void CRecompilerOps::SPECIAL_DSLLV() { - BYTE * Jump[2]; - - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rd == 0) - return; - - if (IsConst(m_Opcode.rs)) - { - //DWORD Shift = (GetMipsRegLo(m_Opcode.rs) & 0x3F); - CRecompilerOps::UnknownOpcode(); - return; - } - Map_TempReg(x86_ECX, m_Opcode.rs, false); - AndConstToX86Reg(x86_ECX,0x3F); - Map_GPR_64bit(m_Opcode.rd,m_Opcode.rt); - CompConstToX86reg(x86_ECX,0x20); - JaeLabel8("MORE32", 0); - Jump[0] = m_RecompPos - 1; - ShiftLeftDouble(GetMipsRegMapHi(m_Opcode.rd),GetMipsRegMapLo(m_Opcode.rd)); - ShiftLeftSign(GetMipsRegMapLo(m_Opcode.rd)); - JmpLabel8("continue", 0); - Jump[1] = m_RecompPos - 1; - - //MORE32: - CPU_Message(""); - CPU_Message(" MORE32:"); - SetJump8(Jump[0],m_RecompPos); - MoveX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapHi(m_Opcode.rd)); - XorX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(m_Opcode.rd)); - AndConstToX86Reg(x86_ECX,0x1F); - ShiftLeftSign(GetMipsRegMapHi(m_Opcode.rd)); - - //continue: - CPU_Message(""); - CPU_Message(" continue:"); - SetJump8(Jump[1],m_RecompPos); -} - -void CRecompilerOps::SPECIAL_DSRLV() { - BYTE * Jump[2]; - - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rd == 0) - return; - - if (IsConst(m_Opcode.rs)) { - DWORD Shift = (GetMipsRegLo(m_Opcode.rs) & 0x3F); - if (IsConst(m_Opcode.rt)) { - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); - - m_RegWorkingSet.SetMipsReg(m_Opcode.rd, Is64Bit(m_Opcode.rt)?GetMipsReg(m_Opcode.rt):(__int64)GetMipsRegLo_S(m_Opcode.rt)); - m_RegWorkingSet.SetMipsReg(m_Opcode.rd, GetMipsReg(m_Opcode.rd) >> Shift); - if ((GetMipsRegHi(m_Opcode.rd) == 0) && (GetMipsRegLo(m_Opcode.rd) & 0x80000000) == 0) { - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else if ((GetMipsRegHi(m_Opcode.rd) == 0xFFFFFFFF) && (GetMipsRegLo(m_Opcode.rd) & 0x80000000) != 0) { - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else { - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_64); - } - return; - } - if (m_Opcode.rd == m_Opcode.rt) - { - CRecompilerOps::UnknownOpcode(); - return; - } - - Map_TempReg(x86_ECX, -1, false); - MoveConstToX86reg(Shift, x86_ECX); - Map_GPR_64bit(m_Opcode.rd,m_Opcode.rt); - if ((Shift & 0x20) == 0x20) - { - MoveX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd),GetMipsRegMapLo(m_Opcode.rd)); - XorX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd),GetMipsRegMapHi(m_Opcode.rd)); - AndConstToX86Reg(x86_ECX,0x1F); - ShiftRightUnsign(GetMipsRegMapLo(m_Opcode.rd)); - } else { - ShiftRightDouble(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapHi(m_Opcode.rd)); - ShiftRightUnsign(GetMipsRegMapHi(m_Opcode.rd)); - } - } else { - Map_TempReg(x86_ECX, m_Opcode.rs, false); - AndConstToX86Reg(x86_ECX,0x3F); - Map_GPR_64bit(m_Opcode.rd,m_Opcode.rt); - CompConstToX86reg(x86_ECX,0x20); - JaeLabel8("MORE32", 0); - Jump[0] = m_RecompPos - 1; - ShiftRightDouble(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapHi(m_Opcode.rd)); - ShiftRightUnsign(GetMipsRegMapHi(m_Opcode.rd)); - JmpLabel8("continue", 0); - Jump[1] = m_RecompPos - 1; - - //MORE32: - CPU_Message(""); - CPU_Message(" MORE32:"); - SetJump8(Jump[0],m_RecompPos); - MoveX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd),GetMipsRegMapLo(m_Opcode.rd)); - XorX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd),GetMipsRegMapHi(m_Opcode.rd)); - AndConstToX86Reg(x86_ECX,0x1F); - ShiftRightUnsign(GetMipsRegMapLo(m_Opcode.rd)); - - //continue: - CPU_Message(""); - CPU_Message(" continue:"); - SetJump8(Jump[1],m_RecompPos); - } -} - -void CRecompilerOps::SPECIAL_DSRAV() +void CRecompilerOps::SPECIAL_MFHI() { - BYTE * Jump[2]; + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rd == 0) { return; } - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rd == 0) - return; - - if (IsConst(m_Opcode.rs)) - { - //DWORD Shift = (GetMipsRegLo(m_Opcode.rs) & 0x3F); - CRecompilerOps::UnknownOpcode(); - return; - } - Map_TempReg(x86_ECX, m_Opcode.rs, false); - AndConstToX86Reg(x86_ECX,0x3F); - Map_GPR_64bit(m_Opcode.rd,m_Opcode.rt); - CompConstToX86reg(x86_ECX,0x20); - JaeLabel8("MORE32", 0); - Jump[0] = m_RecompPos - 1; - ShiftRightDouble(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapHi(m_Opcode.rd)); - ShiftRightSign(GetMipsRegMapHi(m_Opcode.rd)); - JmpLabel8("continue", 0); - Jump[1] = m_RecompPos - 1; - - //MORE32: - CPU_Message(""); - CPU_Message(" MORE32:"); - SetJump8(Jump[0],m_RecompPos); - MoveX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd),GetMipsRegMapLo(m_Opcode.rd)); - ShiftRightSignImmed(GetMipsRegMapHi(m_Opcode.rd),0x1F); - AndConstToX86Reg(x86_ECX,0x1F); - ShiftRightSign(GetMipsRegMapLo(m_Opcode.rd)); - - //continue: - CPU_Message(""); - CPU_Message(" continue:"); - SetJump8(Jump[1],m_RecompPos); + Map_GPR_64bit(m_Opcode.rd, -1); + MoveVariableToX86reg(&_RegHI->UW[0], "_RegHI->UW[0]", GetMipsRegMapLo(m_Opcode.rd)); + MoveVariableToX86reg(&_RegHI->UW[1], "_RegHI->UW[1]", GetMipsRegMapHi(m_Opcode.rd)); } -void CRecompilerOps::SPECIAL_MULT() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::SPECIAL_MTHI() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - m_RegWorkingSet.SetX86Protected(x86_EDX, true); - Map_TempReg(x86_EAX, m_Opcode.rs, false); - m_RegWorkingSet.SetX86Protected(x86_EDX, false); - Map_TempReg(x86_EDX, m_Opcode.rt, false); - - imulX86reg(x86_EDX); - - MoveX86regToVariable(x86_EAX,&_RegLO->UW[0],"_RegLO->UW[0]"); - MoveX86regToVariable(x86_EDX,&_RegHI->UW[0],"_RegHI->UW[0]"); - ShiftRightSignImmed(x86_EAX,31); /* paired */ - ShiftRightSignImmed(x86_EDX,31); - MoveX86regToVariable(x86_EAX,&_RegLO->UW[1],"_RegLO->UW[1]"); - MoveX86regToVariable(x86_EDX,&_RegHI->UW[1],"_RegHI->UW[1]"); + if (IsKnown(m_Opcode.rs) && IsConst(m_Opcode.rs)) + { + if (Is64Bit(m_Opcode.rs)) + { + MoveConstToVariable(GetMipsRegHi(m_Opcode.rs), &_RegHI->UW[1], "_RegHI->UW[1]"); + } + else if (IsSigned(m_Opcode.rs) && ((GetMipsRegLo(m_Opcode.rs) & 0x80000000) != 0)) + { + MoveConstToVariable(0xFFFFFFFF, &_RegHI->UW[1], "_RegHI->UW[1]"); + } + else + { + MoveConstToVariable(0, &_RegHI->UW[1], "_RegHI->UW[1]"); + } + MoveConstToVariable(GetMipsRegLo(m_Opcode.rs), &_RegHI->UW[0], "_RegHI->UW[0]"); + } + else if (IsKnown(m_Opcode.rs) && IsMapped(m_Opcode.rs)) + { + if (Is64Bit(m_Opcode.rs)) + { + MoveX86regToVariable(GetMipsRegMapHi(m_Opcode.rs), &_RegHI->UW[1], "_RegHI->UW[1]"); + } + else if (IsSigned(m_Opcode.rs)) + { + MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rs, true), &_RegHI->UW[1], "_RegHI->UW[1]"); + } + else + { + MoveConstToVariable(0, &_RegHI->UW[1], "_RegHI->UW[1]"); + } + MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rs), &_RegHI->UW[0], "_RegHI->UW[0]"); + } + else + { + x86Reg reg = Map_TempReg(x86_Any, m_Opcode.rs, true); + MoveX86regToVariable(reg, &_RegHI->UW[1], "_RegHI->UW[1]"); + MoveX86regToVariable(Map_TempReg(reg, m_Opcode.rs, false), &_RegHI->UW[0], "_RegHI->UW[0]"); + } } -void CRecompilerOps::SPECIAL_MULTU() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::SPECIAL_DSLLV() +{ + uint8_t * Jump[2]; - m_RegWorkingSet.SetX86Protected(x86_EDX, true); - Map_TempReg(x86_EAX, m_Opcode.rs, false); - m_RegWorkingSet.SetX86Protected(x86_EDX, false); - Map_TempReg(x86_EDX, m_Opcode.rt, false); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rd == 0) + { + return; + } - MulX86reg(x86_EDX); + if (IsConst(m_Opcode.rs)) + { + //uint32_t Shift = (GetMipsRegLo(m_Opcode.rs) & 0x3F); + CRecompilerOps::UnknownOpcode(); + return; + } + Map_TempReg(x86_ECX, m_Opcode.rs, false); + AndConstToX86Reg(x86_ECX, 0x3F); + Map_GPR_64bit(m_Opcode.rd, m_Opcode.rt); + CompConstToX86reg(x86_ECX, 0x20); + JaeLabel8("MORE32", 0); + Jump[0] = m_RecompPos - 1; + ShiftLeftDouble(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rd)); + ShiftLeftSign(GetMipsRegMapLo(m_Opcode.rd)); + JmpLabel8("continue", 0); + Jump[1] = m_RecompPos - 1; - MoveX86regToVariable(x86_EAX,&_RegLO->UW[0],"_RegLO->UW[0]"); - MoveX86regToVariable(x86_EDX,&_RegHI->UW[0],"_RegHI->UW[0]"); - ShiftRightSignImmed(x86_EAX,31); /* paired */ - ShiftRightSignImmed(x86_EDX,31); - MoveX86regToVariable(x86_EAX,&_RegLO->UW[1],"_RegLO->UW[1]"); - MoveX86regToVariable(x86_EDX,&_RegHI->UW[1],"_RegHI->UW[1]"); + //MORE32: + CPU_Message(""); + CPU_Message(" MORE32:"); + SetJump8(Jump[0], m_RecompPos); + MoveX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapHi(m_Opcode.rd)); + XorX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rd)); + AndConstToX86Reg(x86_ECX, 0x1F); + ShiftLeftSign(GetMipsRegMapHi(m_Opcode.rd)); + + //continue: + CPU_Message(""); + CPU_Message(" continue:"); + SetJump8(Jump[1], m_RecompPos); +} + +void CRecompilerOps::SPECIAL_DSRLV() +{ + uint8_t * Jump[2]; + + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rd == 0) + { + return; + } + + if (IsConst(m_Opcode.rs)) + { + uint32_t Shift = (GetMipsRegLo(m_Opcode.rs) & 0x3F); + if (IsConst(m_Opcode.rt)) + { + if (IsMapped(m_Opcode.rd)) + { + UnMap_GPR(m_Opcode.rd, false); + } + + m_RegWorkingSet.SetMipsReg(m_Opcode.rd, Is64Bit(m_Opcode.rt) ? GetMipsReg(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt)); + m_RegWorkingSet.SetMipsReg(m_Opcode.rd, GetMipsReg(m_Opcode.rd) >> Shift); + if ((GetMipsRegHi(m_Opcode.rd) == 0) && (GetMipsRegLo(m_Opcode.rd) & 0x80000000) == 0) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else if ((GetMipsRegHi(m_Opcode.rd) == 0xFFFFFFFF) && (GetMipsRegLo(m_Opcode.rd) & 0x80000000) != 0) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_64); + } + return; + } + if (m_Opcode.rd == m_Opcode.rt) + { + CRecompilerOps::UnknownOpcode(); + return; + } + + Map_TempReg(x86_ECX, -1, false); + MoveConstToX86reg(Shift, x86_ECX); + Map_GPR_64bit(m_Opcode.rd, m_Opcode.rt); + if ((Shift & 0x20) == 0x20) + { + MoveX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rd)); + XorX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegMapHi(m_Opcode.rd)); + AndConstToX86Reg(x86_ECX, 0x1F); + ShiftRightUnsign(GetMipsRegMapLo(m_Opcode.rd)); + } + else + { + ShiftRightDouble(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapHi(m_Opcode.rd)); + ShiftRightUnsign(GetMipsRegMapHi(m_Opcode.rd)); + } + } + else + { + Map_TempReg(x86_ECX, m_Opcode.rs, false); + AndConstToX86Reg(x86_ECX, 0x3F); + Map_GPR_64bit(m_Opcode.rd, m_Opcode.rt); + CompConstToX86reg(x86_ECX, 0x20); + JaeLabel8("MORE32", 0); + Jump[0] = m_RecompPos - 1; + ShiftRightDouble(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapHi(m_Opcode.rd)); + ShiftRightUnsign(GetMipsRegMapHi(m_Opcode.rd)); + JmpLabel8("continue", 0); + Jump[1] = m_RecompPos - 1; + + //MORE32: + CPU_Message(""); + CPU_Message(" MORE32:"); + SetJump8(Jump[0], m_RecompPos); + MoveX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rd)); + XorX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegMapHi(m_Opcode.rd)); + AndConstToX86Reg(x86_ECX, 0x1F); + ShiftRightUnsign(GetMipsRegMapLo(m_Opcode.rd)); + + //continue: + CPU_Message(""); + CPU_Message(" continue:"); + SetJump8(Jump[1], m_RecompPos); + } +} + +void CRecompilerOps::SPECIAL_DSRAV() +{ + uint8_t * Jump[2]; + + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rd == 0) + { + return; + } + + if (IsConst(m_Opcode.rs)) + { + //uint32_t Shift = (GetMipsRegLo(m_Opcode.rs) & 0x3F); + CRecompilerOps::UnknownOpcode(); + return; + } + Map_TempReg(x86_ECX, m_Opcode.rs, false); + AndConstToX86Reg(x86_ECX, 0x3F); + Map_GPR_64bit(m_Opcode.rd, m_Opcode.rt); + CompConstToX86reg(x86_ECX, 0x20); + JaeLabel8("MORE32", 0); + Jump[0] = m_RecompPos - 1; + ShiftRightDouble(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapHi(m_Opcode.rd)); + ShiftRightSign(GetMipsRegMapHi(m_Opcode.rd)); + JmpLabel8("continue", 0); + Jump[1] = m_RecompPos - 1; + + //MORE32: + CPU_Message(""); + CPU_Message(" MORE32:"); + SetJump8(Jump[0], m_RecompPos); + MoveX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rd)); + ShiftRightSignImmed(GetMipsRegMapHi(m_Opcode.rd), 0x1F); + AndConstToX86Reg(x86_ECX, 0x1F); + ShiftRightSign(GetMipsRegMapLo(m_Opcode.rd)); + + //continue: + CPU_Message(""); + CPU_Message(" continue:"); + SetJump8(Jump[1], m_RecompPos); +} + +void CRecompilerOps::SPECIAL_MULT() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_RegWorkingSet.SetX86Protected(x86_EDX, true); + Map_TempReg(x86_EAX, m_Opcode.rs, false); + m_RegWorkingSet.SetX86Protected(x86_EDX, false); + Map_TempReg(x86_EDX, m_Opcode.rt, false); + + imulX86reg(x86_EDX); + + MoveX86regToVariable(x86_EAX, &_RegLO->UW[0], "_RegLO->UW[0]"); + MoveX86regToVariable(x86_EDX, &_RegHI->UW[0], "_RegHI->UW[0]"); + ShiftRightSignImmed(x86_EAX, 31); /* paired */ + ShiftRightSignImmed(x86_EDX, 31); + MoveX86regToVariable(x86_EAX, &_RegLO->UW[1], "_RegLO->UW[1]"); + MoveX86regToVariable(x86_EDX, &_RegHI->UW[1], "_RegHI->UW[1]"); +} + +void CRecompilerOps::SPECIAL_MULTU() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_RegWorkingSet.SetX86Protected(x86_EDX, true); + Map_TempReg(x86_EAX, m_Opcode.rs, false); + m_RegWorkingSet.SetX86Protected(x86_EDX, false); + Map_TempReg(x86_EDX, m_Opcode.rt, false); + + MulX86reg(x86_EDX); + + MoveX86regToVariable(x86_EAX, &_RegLO->UW[0], "_RegLO->UW[0]"); + MoveX86regToVariable(x86_EDX, &_RegHI->UW[0], "_RegHI->UW[0]"); + ShiftRightSignImmed(x86_EAX, 31); /* paired */ + ShiftRightSignImmed(x86_EDX, 31); + MoveX86regToVariable(x86_EAX, &_RegLO->UW[1], "_RegLO->UW[1]"); + MoveX86regToVariable(x86_EDX, &_RegHI->UW[1], "_RegHI->UW[1]"); } void CRecompilerOps::SPECIAL_DIV() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - if (IsConst(m_Opcode.rt)) { - if (GetMipsRegLo(m_Opcode.rt) == 0) { - MoveConstToVariable(0, &_RegLO->UW[0], "_RegLO->UW[0]"); - MoveConstToVariable(0, &_RegLO->UW[1], "_RegLO->UW[1]"); - MoveConstToVariable(0, &_RegHI->UW[0], "_RegHI->UW[0]"); - MoveConstToVariable(0, &_RegHI->UW[1], "_RegHI->UW[1]"); - return; - } - } else { - if (IsMapped(m_Opcode.rt)) { - CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rt),0); - } else { - CompConstToVariable(0, &_GPR[m_Opcode.rt].W[0], CRegName::GPR_Lo[m_Opcode.rt]); - } - m_Section->CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, CExitInfo::DivByZero, false, JeLabel32); - } - /* lo = (SD)rs / (SD)rt; - hi = (SD)rs % (SD)rt; */ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - m_RegWorkingSet.SetX86Protected(x86_EDX, true); - Map_TempReg(x86_EAX, m_Opcode.rs, false); + if (IsConst(m_Opcode.rt)) + { + if (GetMipsRegLo(m_Opcode.rt) == 0) + { + MoveConstToVariable(0, &_RegLO->UW[0], "_RegLO->UW[0]"); + MoveConstToVariable(0, &_RegLO->UW[1], "_RegLO->UW[1]"); + MoveConstToVariable(0, &_RegHI->UW[0], "_RegHI->UW[0]"); + MoveConstToVariable(0, &_RegHI->UW[1], "_RegHI->UW[1]"); + return; + } + } + else + { + if (IsMapped(m_Opcode.rt)) + { + CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rt), 0); + } + else + { + CompConstToVariable(0, &_GPR[m_Opcode.rt].W[0], CRegName::GPR_Lo[m_Opcode.rt]); + } + m_Section->CompileExit(m_CompilePC, m_CompilePC, m_RegWorkingSet, CExitInfo::DivByZero, false, JeLabel32); + } + /* lo = (SD)rs / (SD)rt; + hi = (SD)rs % (SD)rt; */ - /* edx is the signed portion to eax */ - m_RegWorkingSet.SetX86Protected(x86_EDX, false); - Map_TempReg(x86_EDX, -1, false); + m_RegWorkingSet.SetX86Protected(x86_EDX, true); + Map_TempReg(x86_EAX, m_Opcode.rs, false); - MoveX86RegToX86Reg(x86_EAX, x86_EDX); - ShiftRightSignImmed(x86_EDX,31); + /* edx is the signed portion to eax */ + m_RegWorkingSet.SetX86Protected(x86_EDX, false); + Map_TempReg(x86_EDX, -1, false); - if (IsMapped(m_Opcode.rt)) { - idivX86reg(GetMipsRegMapLo(m_Opcode.rt)); - } else { - idivX86reg(Map_TempReg(x86_Any, m_Opcode.rt, false)); - } - + MoveX86RegToX86Reg(x86_EAX, x86_EDX); + ShiftRightSignImmed(x86_EDX, 31); - MoveX86regToVariable(x86_EAX,&_RegLO->UW[0],"_RegLO->UW[0]"); - MoveX86regToVariable(x86_EDX,&_RegHI->UW[0],"_RegHI->UW[0]"); - ShiftRightSignImmed(x86_EAX,31); /* paired */ - ShiftRightSignImmed(x86_EDX,31); - MoveX86regToVariable(x86_EAX,&_RegLO->UW[1],"_RegLO->UW[1]"); - MoveX86regToVariable(x86_EDX,&_RegHI->UW[1],"_RegHI->UW[1]"); + if (IsMapped(m_Opcode.rt)) + { + idivX86reg(GetMipsRegMapLo(m_Opcode.rt)); + } + else + { + idivX86reg(Map_TempReg(x86_Any, m_Opcode.rt, false)); + } + + MoveX86regToVariable(x86_EAX, &_RegLO->UW[0], "_RegLO->UW[0]"); + MoveX86regToVariable(x86_EDX, &_RegHI->UW[0], "_RegHI->UW[0]"); + ShiftRightSignImmed(x86_EAX, 31); /* paired */ + ShiftRightSignImmed(x86_EDX, 31); + MoveX86regToVariable(x86_EAX, &_RegLO->UW[1], "_RegLO->UW[1]"); + MoveX86regToVariable(x86_EDX, &_RegHI->UW[1], "_RegHI->UW[1]"); } -void CRecompilerOps::SPECIAL_DIVU() { - BYTE *Jump[2]; - x86Reg Reg; +void CRecompilerOps::SPECIAL_DIVU() +{ + uint8_t *Jump[2]; + x86Reg Reg; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - if (IsConst(m_Opcode.rt)) { - if (GetMipsRegLo(m_Opcode.rt) == 0) { - MoveConstToVariable(0, &_RegLO->UW[0], "_RegLO->UW[0]"); - MoveConstToVariable(0, &_RegLO->UW[1], "_RegLO->UW[1]"); - MoveConstToVariable(0, &_RegHI->UW[0], "_RegHI->UW[0]"); - MoveConstToVariable(0, &_RegHI->UW[1], "_RegHI->UW[1]"); - return; - } - Jump[1] = NULL; - } else { - if (IsMapped(m_Opcode.rt)) { - CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rt),0); - } else { - CompConstToVariable(0, &_GPR[m_Opcode.rt].W[0], CRegName::GPR_Lo[m_Opcode.rt]); - } - JneLabel8("NoExcept", 0); - Jump[0] = m_RecompPos - 1; + if (IsConst(m_Opcode.rt)) + { + if (GetMipsRegLo(m_Opcode.rt) == 0) + { + MoveConstToVariable(0, &_RegLO->UW[0], "_RegLO->UW[0]"); + MoveConstToVariable(0, &_RegLO->UW[1], "_RegLO->UW[1]"); + MoveConstToVariable(0, &_RegHI->UW[0], "_RegHI->UW[0]"); + MoveConstToVariable(0, &_RegHI->UW[1], "_RegHI->UW[1]"); + return; + } + Jump[1] = NULL; + } + else + { + if (IsMapped(m_Opcode.rt)) + { + CompConstToX86reg(GetMipsRegMapLo(m_Opcode.rt), 0); + } + else + { + CompConstToVariable(0, &_GPR[m_Opcode.rt].W[0], CRegName::GPR_Lo[m_Opcode.rt]); + } + JneLabel8("NoExcept", 0); + Jump[0] = m_RecompPos - 1; - MoveConstToVariable(0, &_RegLO->UW[0], "_RegLO->UW[0]"); - MoveConstToVariable(0, &_RegLO->UW[1], "_RegLO->UW[1]"); - MoveConstToVariable(0, &_RegHI->UW[0], "_RegHI->UW[0]"); - MoveConstToVariable(0, &_RegHI->UW[1], "_RegHI->UW[1]"); + MoveConstToVariable(0, &_RegLO->UW[0], "_RegLO->UW[0]"); + MoveConstToVariable(0, &_RegLO->UW[1], "_RegLO->UW[1]"); + MoveConstToVariable(0, &_RegHI->UW[0], "_RegHI->UW[0]"); + MoveConstToVariable(0, &_RegHI->UW[1], "_RegHI->UW[1]"); - JmpLabel8("EndDivu", 0); - Jump[1] = m_RecompPos - 1; - - CPU_Message(""); - CPU_Message(" NoExcept:"); - SetJump8(Jump[0],m_RecompPos); - } + JmpLabel8("EndDivu", 0); + Jump[1] = m_RecompPos - 1; + CPU_Message(""); + CPU_Message(" NoExcept:"); + SetJump8(Jump[0], m_RecompPos); + } - /* lo = (UD)rs / (UD)rt; - hi = (UD)rs % (UD)rt; */ + /* lo = (UD)rs / (UD)rt; + hi = (UD)rs % (UD)rt; */ - m_RegWorkingSet.SetX86Protected(x86_EAX, true); - Map_TempReg(x86_EDX, 0, false); - m_RegWorkingSet.SetX86Protected(x86_EAX, false); + m_RegWorkingSet.SetX86Protected(x86_EAX, true); + Map_TempReg(x86_EDX, 0, false); + m_RegWorkingSet.SetX86Protected(x86_EAX, false); - Map_TempReg(x86_EAX, m_Opcode.rs, false); - Reg = Map_TempReg(x86_Any, m_Opcode.rt, false); + Map_TempReg(x86_EAX, m_Opcode.rs, false); + Reg = Map_TempReg(x86_Any, m_Opcode.rt, false); - DivX86reg(Reg); + DivX86reg(Reg); - MoveX86regToVariable(x86_EAX,&_RegLO->UW[0],"_RegLO->UW[0]"); - MoveX86regToVariable(x86_EDX,&_RegHI->UW[0],"_RegHI->UW[0]"); + MoveX86regToVariable(x86_EAX, &_RegLO->UW[0], "_RegLO->UW[0]"); + MoveX86regToVariable(x86_EDX, &_RegHI->UW[0], "_RegHI->UW[0]"); - /* wouldnt these be zero (???) */ + /* wouldnt these be zero (???) */ - ShiftRightSignImmed(x86_EAX,31); /* paired */ - ShiftRightSignImmed(x86_EDX,31); - MoveX86regToVariable(x86_EAX,&_RegLO->UW[1],"_RegLO->UW[1]"); - MoveX86regToVariable(x86_EDX,&_RegHI->UW[1],"_RegHI->UW[1]"); + ShiftRightSignImmed(x86_EAX, 31); /* paired */ + ShiftRightSignImmed(x86_EDX, 31); + MoveX86regToVariable(x86_EAX, &_RegLO->UW[1], "_RegLO->UW[1]"); + MoveX86regToVariable(x86_EDX, &_RegHI->UW[1], "_RegHI->UW[1]"); - if( Jump[1] != NULL ) { - CPU_Message(""); - CPU_Message(" EndDivu:"); - SetJump8(Jump[1],m_RecompPos); - } + if (Jump[1] != NULL) + { + CPU_Message(""); + CPU_Message(" EndDivu:"); + SetJump8(Jump[1], m_RecompPos); + } } void CRecompilerOps::SPECIAL_DMULT() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - if (m_Opcode.rs != 0) - UnMap_GPR(m_Opcode.rs, true); + if (m_Opcode.rs != 0) + { + UnMap_GPR(m_Opcode.rs, true); + } - if (m_Opcode.rs != 0) - UnMap_GPR(m_Opcode.rt, true); + if (m_Opcode.rs != 0) + { + UnMap_GPR(m_Opcode.rt, true); + } - BeforeCallDirect(m_RegWorkingSet); - MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); - Call_Direct(R4300iOp::SPECIAL_DMULT, "R4300iOp::SPECIAL_DMULT"); - AfterCallDirect(m_RegWorkingSet); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); + Call_Direct(R4300iOp::SPECIAL_DMULT, "R4300iOp::SPECIAL_DMULT"); + AfterCallDirect(m_RegWorkingSet); } -void CRecompilerOps::SPECIAL_DMULTU() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::SPECIAL_DMULTU() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - UnMap_GPR(m_Opcode.rs, true); - UnMap_GPR(m_Opcode.rt, true); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); - Call_Direct(R4300iOp::SPECIAL_DMULTU, "R4300iOp::SPECIAL_DMULTU"); - AfterCallDirect(m_RegWorkingSet); + UnMap_GPR(m_Opcode.rs, true); + UnMap_GPR(m_Opcode.rt, true); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); + Call_Direct(R4300iOp::SPECIAL_DMULTU, "R4300iOp::SPECIAL_DMULTU"); + AfterCallDirect(m_RegWorkingSet); #ifdef toremove - /* _RegLO->UDW = (uint64)_GPR[m_Opcode.rs].UW[0] * (uint64)_GPR[m_Opcode.rt].UW[0]; */ - X86Protected(x86_EDX) = true; - Map_TempReg(x86_EAX,m_Opcode.rs,false); - X86Protected(x86_EDX) = false; - Map_TempReg(x86_EDX,m_Opcode.rt,false); + /* _RegLO->UDW = (uint64)_GPR[m_Opcode.rs].UW[0] * (uint64)_GPR[m_Opcode.rt].UW[0]; */ + X86Protected(x86_EDX) = true; + Map_TempReg(x86_EAX,m_Opcode.rs,false); + X86Protected(x86_EDX) = false; + Map_TempReg(x86_EDX,m_Opcode.rt,false); - MulX86reg(x86_EDX); - MoveX86regToVariable(x86_EAX, &_RegLO->UW[0], "_RegLO->UW[0]"); - MoveX86regToVariable(x86_EDX, &_RegLO->UW[1], "_RegLO->UW[1]"); + MulX86reg(x86_EDX); + MoveX86regToVariable(x86_EAX, &_RegLO->UW[0], "_RegLO->UW[0]"); + MoveX86regToVariable(x86_EDX, &_RegLO->UW[1], "_RegLO->UW[1]"); - /* _RegHI->UDW = (uint64)_GPR[m_Opcode.rs].UW[1] * (uint64)_GPR[m_Opcode.rt].UW[1]; */ - Map_TempReg(x86_EAX,m_Opcode.rs,true); - Map_TempReg(x86_EDX,m_Opcode.rt,true); + /* _RegHI->UDW = (uint64)_GPR[m_Opcode.rs].UW[1] * (uint64)_GPR[m_Opcode.rt].UW[1]; */ + Map_TempReg(x86_EAX,m_Opcode.rs,true); + Map_TempReg(x86_EDX,m_Opcode.rt,true); - MulX86reg(x86_EDX); - MoveX86regToVariable(x86_EAX, &_RegHI->UW[0], "_RegHI->UW[0]"); - MoveX86regToVariable(x86_EDX, &_RegHI->UW[1], "_RegHI->UW[1]"); + MulX86reg(x86_EDX); + MoveX86regToVariable(x86_EAX, &_RegHI->UW[0], "_RegHI->UW[0]"); + MoveX86regToVariable(x86_EDX, &_RegHI->UW[1], "_RegHI->UW[1]"); - /* Tmp[0].UDW = (uint64)_GPR[m_Opcode.rs].UW[1] * (uint64)_GPR[m_Opcode.rt].UW[0]; */ - Map_TempReg(x86_EAX,m_Opcode.rs,true); - Map_TempReg(x86_EDX,m_Opcode.rt,false); + /* Tmp[0].UDW = (uint64)_GPR[m_Opcode.rs].UW[1] * (uint64)_GPR[m_Opcode.rt].UW[0]; */ + Map_TempReg(x86_EAX,m_Opcode.rs,true); + Map_TempReg(x86_EDX,m_Opcode.rt,false); - Map_TempReg(x86_EBX,-1,false); - Map_TempReg(x86_ECX,-1,false); + Map_TempReg(x86_EBX,-1,false); + Map_TempReg(x86_ECX,-1,false); - MulX86reg(x86_EDX); - MoveX86RegToX86Reg(x86_EAX, x86_EBX); /* EDX:EAX -> ECX:EBX */ - MoveX86RegToX86Reg(x86_EDX, x86_ECX); + MulX86reg(x86_EDX); + MoveX86RegToX86Reg(x86_EAX, x86_EBX); /* EDX:EAX -> ECX:EBX */ + MoveX86RegToX86Reg(x86_EDX, x86_ECX); - /* Tmp[1].UDW = (uint64)_GPR[m_Opcode.rs].UW[0] * (uint64)_GPR[m_Opcode.rt].UW[1]; */ - Map_TempReg(x86_EAX,m_Opcode.rs,false); - Map_TempReg(x86_EDX,m_Opcode.rt,true); + /* Tmp[1].UDW = (uint64)_GPR[m_Opcode.rs].UW[0] * (uint64)_GPR[m_Opcode.rt].UW[1]; */ + Map_TempReg(x86_EAX,m_Opcode.rs,false); + Map_TempReg(x86_EDX,m_Opcode.rt,true); - MulX86reg(x86_EDX); - Map_TempReg(x86_ESI,-1,false); - Map_TempReg(x86_EDI,-1,false); - MoveX86RegToX86Reg(x86_EAX, x86_ESI); /* EDX:EAX -> EDI:ESI */ - MoveX86RegToX86Reg(x86_EDX, x86_EDI); + MulX86reg(x86_EDX); + Map_TempReg(x86_ESI,-1,false); + Map_TempReg(x86_EDI,-1,false); + MoveX86RegToX86Reg(x86_EAX, x86_ESI); /* EDX:EAX -> EDI:ESI */ + MoveX86RegToX86Reg(x86_EDX, x86_EDI); - /* Tmp[2].UDW = (uint64)_RegLO->UW[1] + (uint64)Tmp[0].UW[0] + (uint64)Tmp[1].UW[0]; */ - XorX86RegToX86Reg(x86_EDX, x86_EDX); - MoveVariableToX86reg(&_RegLO->UW[1], "_RegLO->UW[1]", x86_EAX); - AddX86RegToX86Reg(x86_EAX, x86_EBX); - AddConstToX86Reg(x86_EDX, 0); - AddX86RegToX86Reg(x86_EAX, x86_ESI); - AddConstToX86Reg(x86_EDX, 0); /* EDX:EAX */ + /* Tmp[2].UDW = (uint64)_RegLO->UW[1] + (uint64)Tmp[0].UW[0] + (uint64)Tmp[1].UW[0]; */ + XorX86RegToX86Reg(x86_EDX, x86_EDX); + MoveVariableToX86reg(&_RegLO->UW[1], "_RegLO->UW[1]", x86_EAX); + AddX86RegToX86Reg(x86_EAX, x86_EBX); + AddConstToX86Reg(x86_EDX, 0); + AddX86RegToX86Reg(x86_EAX, x86_ESI); + AddConstToX86Reg(x86_EDX, 0); /* EDX:EAX */ - /* _RegLO->UDW += ((uint64)Tmp[0].UW[0] + (uint64)Tmp[1].UW[0]) << 32; */ - /* [low+4] += ebx + esi */ + /* _RegLO->UDW += ((uint64)Tmp[0].UW[0] + (uint64)Tmp[1].UW[0]) << 32; */ + /* [low+4] += ebx + esi */ - AddX86regToVariable(x86_EBX, &_RegLO->UW[1], "_RegLO->UW[1]"); - AddX86regToVariable(x86_ESI, &_RegLO->UW[1], "_RegLO->UW[1]"); + AddX86regToVariable(x86_EBX, &_RegLO->UW[1], "_RegLO->UW[1]"); + AddX86regToVariable(x86_ESI, &_RegLO->UW[1], "_RegLO->UW[1]"); - /* _RegHI->UDW += (uint64)Tmp[0].UW[1] + (uint64)Tmp[1].UW[1] + Tmp[2].UW[1]; */ - /* [hi] += ecx + edi + edx */ - - AddX86regToVariable(x86_ECX, &_RegHI->UW[0], "_RegHI->UW[0]"); - AdcConstToVariable(&_RegHI->UW[1], "_RegHI->UW[1]", 0); + /* _RegHI->UDW += (uint64)Tmp[0].UW[1] + (uint64)Tmp[1].UW[1] + Tmp[2].UW[1]; */ + /* [hi] += ecx + edi + edx */ - AddX86regToVariable(x86_EDI, &_RegHI->UW[0], "_RegHI->UW[0]"); - AdcConstToVariable(&_RegHI->UW[1], "_RegHI->UW[1]", 0); + AddX86regToVariable(x86_ECX, &_RegHI->UW[0], "_RegHI->UW[0]"); + AdcConstToVariable(&_RegHI->UW[1], "_RegHI->UW[1]", 0); - AddX86regToVariable(x86_EDX, &_RegHI->UW[0], "_RegHI->UW[0]"); - AdcConstToVariable(&_RegHI->UW[1], "_RegHI->UW[1]", 0); + AddX86regToVariable(x86_EDI, &_RegHI->UW[0], "_RegHI->UW[0]"); + AdcConstToVariable(&_RegHI->UW[1], "_RegHI->UW[1]", 0); + + AddX86regToVariable(x86_EDX, &_RegHI->UW[0], "_RegHI->UW[0]"); + AdcConstToVariable(&_RegHI->UW[1], "_RegHI->UW[1]", 0); #endif } -void CRecompilerOps::SPECIAL_DDIV() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::SPECIAL_DDIV() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - UnMap_GPR(m_Opcode.rs, true); - UnMap_GPR(m_Opcode.rt, true); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); - Call_Direct(R4300iOp::SPECIAL_DDIV, "R4300iOp::SPECIAL_DDIV"); - AfterCallDirect(m_RegWorkingSet); + UnMap_GPR(m_Opcode.rs, true); + UnMap_GPR(m_Opcode.rt, true); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); + Call_Direct(R4300iOp::SPECIAL_DDIV, "R4300iOp::SPECIAL_DDIV"); + AfterCallDirect(m_RegWorkingSet); } void CRecompilerOps::SPECIAL_DDIVU() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - UnMap_GPR(m_Opcode.rs, true); - UnMap_GPR(m_Opcode.rt, true); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); - Call_Direct(R4300iOp::SPECIAL_DDIVU, "R4300iOp::SPECIAL_DDIVU"); - AfterCallDirect(m_RegWorkingSet); + UnMap_GPR(m_Opcode.rs, true); + UnMap_GPR(m_Opcode.rt, true); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); + Call_Direct(R4300iOp::SPECIAL_DDIVU, "R4300iOp::SPECIAL_DDIVU"); + AfterCallDirect(m_RegWorkingSet); } -void CRecompilerOps::SPECIAL_ADD() { - int source1 = m_Opcode.rd == m_Opcode.rt?m_Opcode.rt:m_Opcode.rs; - int source2 = m_Opcode.rd == m_Opcode.rt?m_Opcode.rs:m_Opcode.rt; - - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rd == 0) - return; - - if (IsConst(source1) && IsConst(source2)) { - DWORD temp = GetMipsRegLo(source1) + GetMipsRegLo(source2); - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); - - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd,temp); - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - return; - } - - Map_GPR_32bit(m_Opcode.rd, true, source1); - if (IsConst(source2)) { - AddConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegLo(source2)); - } else if (IsKnown(source2) && IsMapped(source2)) { - AddX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(source2)); - } else { - AddVariableToX86reg(GetMipsRegMapLo(m_Opcode.rd),&_GPR[source2].W[0],CRegName::GPR_Lo[source2]); - } - if (g_System->bFastSP() && m_Opcode.rd == 29) - { - g_MMU->ResetMemoryStack(); - } -} - -void CRecompilerOps::SPECIAL_ADDU() { - int source1 = m_Opcode.rd == m_Opcode.rt?m_Opcode.rt:m_Opcode.rs; - int source2 = m_Opcode.rd == m_Opcode.rt?m_Opcode.rs:m_Opcode.rt; - - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rd == 0) - return; - - if (IsConst(source1) && IsConst(source2)) { - DWORD temp = GetMipsRegLo(source1) + GetMipsRegLo(source2); - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); - - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd,temp); - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - return; - } - - Map_GPR_32bit(m_Opcode.rd, true, source1); - if (IsConst(source2)) { - AddConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegLo(source2)); - } else if (IsKnown(source2) && IsMapped(source2)) { - AddX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(source2)); - } else { - AddVariableToX86reg(GetMipsRegMapLo(m_Opcode.rd),&_GPR[source2].W[0],CRegName::GPR_Lo[source2]); - } - if (g_System->bFastSP() && m_Opcode.rd == 29) - { - g_MMU->ResetMemoryStack(); - } -} - -void CRecompilerOps::SPECIAL_SUB() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rd == 0) - return; - - if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) { - DWORD temp = GetMipsRegLo(m_Opcode.rs) - GetMipsRegLo(m_Opcode.rt); - - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); - - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd,temp); - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else { - if (m_Opcode.rd == m_Opcode.rt) { - x86Reg Reg = Map_TempReg(x86_Any, m_Opcode.rt, false); - Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rs); - SubX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),Reg); - return; - } - Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rs); - if (IsConst(m_Opcode.rt)) { - SubConstFromX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegLo(m_Opcode.rt)); - } else if (IsMapped(m_Opcode.rt)) { - SubX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(m_Opcode.rt)); - } else { - SubVariableFromX86reg(GetMipsRegMapLo(m_Opcode.rd),&_GPR[m_Opcode.rt].W[0],CRegName::GPR_Lo[m_Opcode.rt]); - } - } - if (g_System->bFastSP() && m_Opcode.rd == 29) - { - g_MMU->ResetMemoryStack(); - } -} - -void CRecompilerOps::SPECIAL_SUBU() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rd == 0) - return; - - if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) { - DWORD temp = GetMipsRegLo(m_Opcode.rs) - GetMipsRegLo(m_Opcode.rt); - - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); - - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd,temp); - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else { - if (m_Opcode.rd == m_Opcode.rt) { - x86Reg Reg = Map_TempReg(x86_Any, m_Opcode.rt, false); - Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rs); - SubX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),Reg); - return; - } - Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rs); - if (IsConst(m_Opcode.rt)) { - SubConstFromX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegLo(m_Opcode.rt)); - } else if (IsMapped(m_Opcode.rt)) { - SubX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(m_Opcode.rt)); - } else { - SubVariableFromX86reg(GetMipsRegMapLo(m_Opcode.rd),&_GPR[m_Opcode.rt].W[0],CRegName::GPR_Lo[m_Opcode.rt]); - } - } - - if (g_System->bFastSP() && m_Opcode.rd == 29) - { - g_MMU->ResetMemoryStack(); - } -} - -void CRecompilerOps::SPECIAL_AND() +void CRecompilerOps::SPECIAL_ADD() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + int source1 = m_Opcode.rd == m_Opcode.rt ? m_Opcode.rt : m_Opcode.rs; + int source2 = m_Opcode.rd == m_Opcode.rt ? m_Opcode.rs : m_Opcode.rt; - if (IsKnown(m_Opcode.rt) && IsKnown(m_Opcode.rs)) { - if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) { - if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) { - m_RegWorkingSet.SetMipsReg(m_Opcode.rd, - (Is64Bit(m_Opcode.rt)?GetMipsReg(m_Opcode.rt):(__int64)GetMipsRegLo_S(m_Opcode.rt)) & - (Is64Bit(m_Opcode.rs)?GetMipsReg(m_Opcode.rs):(__int64)GetMipsRegLo_S(m_Opcode.rs)) - ); - - if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1){ - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else if (GetMipsRegLo_S(m_Opcode.rd) >= 0 && GetMipsRegHi_S(m_Opcode.rd) == 0){ - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else { - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_64); - } - } else { - m_RegWorkingSet.SetMipsReg(m_Opcode.rd, GetMipsRegLo(m_Opcode.rt) & GetMipsReg(m_Opcode.rs)); - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } - } else if (IsMapped(m_Opcode.rt) && IsMapped(m_Opcode.rs)) { - int source1 = m_Opcode.rd == m_Opcode.rt?m_Opcode.rt:m_Opcode.rs; - int source2 = m_Opcode.rd == m_Opcode.rt?m_Opcode.rs:m_Opcode.rt; - - ProtectGPR(source1); - ProtectGPR(source2); - if (Is32Bit(source1) && Is32Bit(source2)) { - bool Sign = (IsSigned(m_Opcode.rt) && IsSigned(m_Opcode.rs)); - Map_GPR_32bit(m_Opcode.rd, Sign, source1); - AndX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(source2)); - } else if (Is32Bit(source1) || Is32Bit(source2)) { - if (IsUnsigned(Is32Bit(source1)?source1:source2)) { - Map_GPR_32bit(m_Opcode.rd, false, source1); - AndX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(source2)); - } else { - Map_GPR_64bit(m_Opcode.rd,source1); - if (Is32Bit(source2)) { - AndX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd),Map_TempReg(x86_Any,source2,true)); - } else { - AndX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd),GetMipsRegMapHi(source2)); - } - AndX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(source2)); - } - } else { - Map_GPR_64bit(m_Opcode.rd,source1); - AndX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd),GetMipsRegMapHi(source2)); - AndX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(source2)); - } - } else { - int ConstReg = IsConst(m_Opcode.rt)?m_Opcode.rt:m_Opcode.rs; - int MappedReg = IsConst(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rd == 0) + { + return; + } - if (Is64Bit(ConstReg)) { - if (Is32Bit(MappedReg) && IsUnsigned(MappedReg)) { - if (GetMipsRegLo(ConstReg) == 0) { - Map_GPR_32bit(m_Opcode.rd, false, 0); - } else { - DWORD Value = GetMipsRegLo(ConstReg); - Map_GPR_32bit(m_Opcode.rd, false, MappedReg); - AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd),Value); - } - } else { - __int64 Value = GetMipsReg(ConstReg); - Map_GPR_64bit(m_Opcode.rd,MappedReg); - AndConstToX86Reg(GetMipsRegMapHi(m_Opcode.rd),(DWORD)(Value >> 32)); - AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd),(DWORD)(Value & 0xFFFFFFFF)); - } - } else if (Is64Bit(MappedReg)) { - DWORD Value = GetMipsRegLo(ConstReg); - if (Value != 0) { - Map_GPR_32bit(m_Opcode.rd, IsSigned(ConstReg), MappedReg); - AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd),Value); - } else { - Map_GPR_32bit(m_Opcode.rd, IsSigned(ConstReg), 0); - } - } else { - DWORD Value = GetMipsRegLo(ConstReg); - bool Sign = false; + if (IsConst(source1) && IsConst(source2)) + { + uint32_t temp = GetMipsRegLo(source1) + GetMipsRegLo(source2); + if (IsMapped(m_Opcode.rd)) + { + UnMap_GPR(m_Opcode.rd, false); + } - if (IsSigned(ConstReg) && IsSigned(MappedReg)) - Sign = true; + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, temp); + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + return; + } - if (Value != 0) { - Map_GPR_32bit(m_Opcode.rd,Sign,MappedReg); - AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd),Value); - } else { - Map_GPR_32bit(m_Opcode.rd, false, 0); - } - } - } - } else if (IsKnown(m_Opcode.rt) || IsKnown(m_Opcode.rs)) { - DWORD KnownReg = IsKnown(m_Opcode.rt)?m_Opcode.rt:m_Opcode.rs; - DWORD UnknownReg = IsKnown(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; - - if (IsConst(KnownReg)) { - if (Is64Bit(KnownReg)) { - unsigned __int64 Value = GetMipsReg(KnownReg); - Map_GPR_64bit(m_Opcode.rd,UnknownReg); - AndConstToX86Reg(GetMipsRegMapHi(m_Opcode.rd),(DWORD)(Value >> 32)); - AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd),(DWORD)(Value & 0xFFFFFFFF)); - } else { - DWORD Value = GetMipsRegLo(KnownReg); - Map_GPR_32bit(m_Opcode.rd,IsSigned(KnownReg),UnknownReg); - AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd),Value); - } - } else { - ProtectGPR(KnownReg); - if (KnownReg == m_Opcode.rd) { - if (Is64Bit(KnownReg) || !g_System->b32BitCore()) { - Map_GPR_64bit(m_Opcode.rd,KnownReg); - AndVariableToX86Reg(&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg],GetMipsRegMapHi(m_Opcode.rd)); - AndVariableToX86Reg(&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg],GetMipsRegMapLo(m_Opcode.rd)); - } else { - Map_GPR_32bit(m_Opcode.rd,IsSigned(KnownReg),KnownReg); - AndVariableToX86Reg(&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg],GetMipsRegMapLo(m_Opcode.rd)); - } - } else { - if (Is64Bit(KnownReg)) { - Map_GPR_64bit(m_Opcode.rd,UnknownReg); - AndX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd),GetMipsRegMapHi(KnownReg)); - AndX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(KnownReg)); - } else { - Map_GPR_32bit(m_Opcode.rd,IsSigned(KnownReg),UnknownReg); - AndX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(KnownReg)); - } - } - } - } else { - if (g_System->b32BitCore()) - { - Map_GPR_32bit(m_Opcode.rd,true,m_Opcode.rt); - } else { - Map_GPR_64bit(m_Opcode.rd,m_Opcode.rt); - AndVariableToX86Reg(&_GPR[m_Opcode.rs].W[1],CRegName::GPR_Hi[m_Opcode.rs],GetMipsRegMapHi(m_Opcode.rd)); - } - AndVariableToX86Reg(&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs],GetMipsRegMapLo(m_Opcode.rd)); - } + Map_GPR_32bit(m_Opcode.rd, true, source1); + if (IsConst(source2)) + { + AddConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegLo(source2)); + } + else if (IsKnown(source2) && IsMapped(source2)) + { + AddX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(source2)); + } + else + { + AddVariableToX86reg(GetMipsRegMapLo(m_Opcode.rd), &_GPR[source2].W[0], CRegName::GPR_Lo[source2]); + } + if (g_System->bFastSP() && m_Opcode.rd == 29) + { + g_MMU->ResetMemoryStack(); + } } -void CRecompilerOps::SPECIAL_OR() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::SPECIAL_ADDU() +{ + int source1 = m_Opcode.rd == m_Opcode.rt ? m_Opcode.rt : m_Opcode.rs; + int source2 = m_Opcode.rd == m_Opcode.rt ? m_Opcode.rs : m_Opcode.rt; - if (IsKnown(m_Opcode.rt) && IsKnown(m_Opcode.rs)) { - if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) { + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rd == 0) + { + return; + } - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); + if (IsConst(source1) && IsConst(source2)) + { + uint32_t temp = GetMipsRegLo(source1) + GetMipsRegLo(source2); + if (IsMapped(m_Opcode.rd)) + { + UnMap_GPR(m_Opcode.rd, false); + } + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, temp); + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + return; + } - if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) { - m_RegWorkingSet.SetMipsReg(m_Opcode.rd, - (Is64Bit(m_Opcode.rt)?GetMipsReg(m_Opcode.rt):(__int64)GetMipsRegLo_S(m_Opcode.rt)) | - (Is64Bit(m_Opcode.rs)?GetMipsReg(m_Opcode.rs):(__int64)GetMipsRegLo_S(m_Opcode.rs)) - ); - if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1){ - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else if (GetMipsRegLo_S(m_Opcode.rd) >= 0 && GetMipsRegHi_S(m_Opcode.rd) == 0){ - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else { - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_64); - } - } else { - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, GetMipsRegLo(m_Opcode.rt) | GetMipsRegLo(m_Opcode.rs)); - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } - } else if (IsMapped(m_Opcode.rt) && IsMapped(m_Opcode.rs)) { - int source1 = m_Opcode.rd == m_Opcode.rt?m_Opcode.rt:m_Opcode.rs; - int source2 = m_Opcode.rd == m_Opcode.rt?m_Opcode.rs:m_Opcode.rt; - - ProtectGPR(m_Opcode.rt); - ProtectGPR(m_Opcode.rs); - if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) { - Map_GPR_64bit(m_Opcode.rd,source1); - if (Is64Bit(source2)) { - OrX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd),GetMipsRegMapHi(source2)); - } else { - OrX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), Map_TempReg(x86_Any, source2, true)); - } - } else { - ProtectGPR(source2); - Map_GPR_32bit(m_Opcode.rd, true, source1); - } - OrX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(source2)); - } else { - DWORD ConstReg = IsConst(m_Opcode.rt)?m_Opcode.rt:m_Opcode.rs; - DWORD MappedReg = IsConst(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; - - if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) { - unsigned __int64 Value; - - if (Is64Bit(ConstReg)) { - Value = GetMipsReg(ConstReg); - } else { - Value = IsSigned(ConstReg)?(__int64)GetMipsRegLo_S(ConstReg):GetMipsRegLo(ConstReg); - } - Map_GPR_64bit(m_Opcode.rd,MappedReg); - if ((Value >> 32) != 0) { - OrConstToX86Reg((DWORD)(Value >> 32),GetMipsRegMapHi(m_Opcode.rd)); - } - DWORD dwValue = (DWORD)(Value & 0xFFFFFFFF); - if (dwValue != 0) { - OrConstToX86Reg(dwValue,GetMipsRegMapLo(m_Opcode.rd)); - } - } else { - int Value = GetMipsRegLo(ConstReg); - Map_GPR_32bit(m_Opcode.rd, true, MappedReg); - if (Value != 0) { OrConstToX86Reg(Value,GetMipsRegMapLo(m_Opcode.rd)); } - } - } - } else if (IsKnown(m_Opcode.rt) || IsKnown(m_Opcode.rs)) { - int KnownReg = IsKnown(m_Opcode.rt)?m_Opcode.rt:m_Opcode.rs; - int UnknownReg = IsKnown(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; - - if (IsConst(KnownReg)) - { - unsigned __int64 Value = Is64Bit(KnownReg)?GetMipsReg(KnownReg):GetMipsRegLo_S(KnownReg); - DWORD dwValue = (DWORD)(Value & 0xFFFFFFFF); - - if (g_System->b32BitCore() && Is32Bit(KnownReg)) - { - Map_GPR_32bit(m_Opcode.rd,true,UnknownReg); - if (dwValue != 0) { - OrConstToX86Reg(dwValue,GetMipsRegMapLo(m_Opcode.rd)); - } - } else { - Map_GPR_64bit(m_Opcode.rd,UnknownReg); - if ((Value >> 32) != 0) { - OrConstToX86Reg((DWORD)(Value >> 32),GetMipsRegMapHi(m_Opcode.rd)); - } - if (dwValue != 0) { - OrConstToX86Reg(dwValue,GetMipsRegMapLo(m_Opcode.rd)); - } - } - } else { - if (g_System->b32BitCore()) - { - Map_GPR_32bit(m_Opcode.rd,true,KnownReg); - OrVariableToX86Reg(&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg],GetMipsRegMapLo(m_Opcode.rd)); - } else { - Map_GPR_64bit(m_Opcode.rd,KnownReg); - OrVariableToX86Reg(&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg],GetMipsRegMapHi(m_Opcode.rd)); - OrVariableToX86Reg(&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg],GetMipsRegMapLo(m_Opcode.rd)); - } - } - } else { - if (g_System->b32BitCore()) - { - Map_GPR_32bit(m_Opcode.rd,true,m_Opcode.rt); - OrVariableToX86Reg(&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs],GetMipsRegMapLo(m_Opcode.rd)); - } else { - Map_GPR_64bit(m_Opcode.rd,m_Opcode.rt); - OrVariableToX86Reg(&_GPR[m_Opcode.rs].W[1],CRegName::GPR_Hi[m_Opcode.rs],GetMipsRegMapHi(m_Opcode.rd)); - OrVariableToX86Reg(&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs],GetMipsRegMapLo(m_Opcode.rd)); - } - } - if (g_System->bFastSP() && m_Opcode.rd == 29) { - ResetX86Protection(); - g_MMU->ResetMemoryStack(); - } + Map_GPR_32bit(m_Opcode.rd, true, source1); + if (IsConst(source2)) + { + AddConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegLo(source2)); + } + else if (IsKnown(source2) && IsMapped(source2)) + { + AddX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(source2)); + } + else + { + AddVariableToX86reg(GetMipsRegMapLo(m_Opcode.rd), &_GPR[source2].W[0], CRegName::GPR_Lo[source2]); + } + if (g_System->bFastSP() && m_Opcode.rd == 29) + { + g_MMU->ResetMemoryStack(); + } } -void CRecompilerOps::SPECIAL_XOR() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rd == 0) - return; +void CRecompilerOps::SPECIAL_SUB() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rd == 0) + { + return; + } - if (m_Opcode.rt == m_Opcode.rs) { - UnMap_GPR(m_Opcode.rd, false); - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, 0); - return; - } - if (IsKnown(m_Opcode.rt) && IsKnown(m_Opcode.rs)) { - if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) { - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); + if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) + { + uint32_t temp = GetMipsRegLo(m_Opcode.rs) - GetMipsRegLo(m_Opcode.rt); - if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) { - if (bHaveDebugger()) { g_Notify->DisplayError(L"XOR 1"); } - CRecompilerOps::UnknownOpcode(); - } else { - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, GetMipsRegLo(m_Opcode.rt) ^ GetMipsRegLo(m_Opcode.rs)); - } - } else if (IsMapped(m_Opcode.rt) && IsMapped(m_Opcode.rs)) { - int source1 = m_Opcode.rd == m_Opcode.rt?m_Opcode.rt:m_Opcode.rs; - int source2 = m_Opcode.rd == m_Opcode.rt?m_Opcode.rs:m_Opcode.rt; - - ProtectGPR(source1); - ProtectGPR(source2); - if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) { - Map_GPR_64bit(m_Opcode.rd,source1); - if (Is64Bit(source2)) { - XorX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd),GetMipsRegMapHi(source2)); - } else if (IsSigned(source2)) { - XorX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), Map_TempReg(x86_Any, source2, true)); - } - XorX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(source2)); - } else { - if (IsSigned(m_Opcode.rt) != IsSigned(m_Opcode.rs)) { - Map_GPR_32bit(m_Opcode.rd, true, source1); - } else { - Map_GPR_32bit(m_Opcode.rd,IsSigned(m_Opcode.rt),source1); - } - XorX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(source2)); - } - } else { - DWORD ConstReg = IsConst(m_Opcode.rt)?m_Opcode.rt:m_Opcode.rs; - DWORD MappedReg = IsConst(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; + if (IsMapped(m_Opcode.rd)) + { + UnMap_GPR(m_Opcode.rd, false); + } - if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) { - DWORD ConstHi, ConstLo; - - ConstHi = Is32Bit(ConstReg)?(DWORD)(GetMipsRegLo_S(ConstReg) >> 31):GetMipsRegHi(ConstReg); - ConstLo = GetMipsRegLo(ConstReg); - Map_GPR_64bit(m_Opcode.rd,MappedReg); - if (ConstHi != 0) { XorConstToX86Reg(GetMipsRegMapHi(m_Opcode.rd),ConstHi); } - if (ConstLo != 0) { XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd),ConstLo); } - } else { - int Value = GetMipsRegLo(ConstReg); - if (IsSigned(m_Opcode.rt) != IsSigned(m_Opcode.rs)) { - Map_GPR_32bit(m_Opcode.rd, true, MappedReg); - } else { - Map_GPR_32bit(m_Opcode.rd, IsSigned(MappedReg), MappedReg); - } - if (Value != 0) { XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd),Value); } - } - } - } else if (IsKnown(m_Opcode.rt) || IsKnown(m_Opcode.rs)) { - int KnownReg = IsKnown(m_Opcode.rt)?m_Opcode.rt:m_Opcode.rs; - int UnknownReg = IsKnown(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; - - if (IsConst(KnownReg)) { - unsigned __int64 Value; - - if (Is64Bit(KnownReg)) { - Value = GetMipsReg(KnownReg); - Map_GPR_64bit(m_Opcode.rd,UnknownReg); - if ((Value >> 32) != 0) { - XorConstToX86Reg(GetMipsRegMapHi(m_Opcode.rd),(DWORD)(Value >> 32)); - } - } else { - Map_GPR_32bit(m_Opcode.rd,true,UnknownReg); - if (IsSigned(KnownReg)) { - Value = (int)GetMipsRegLo(KnownReg); - } else { - Value = GetMipsRegLo(KnownReg); - } - } - DWORD dwValue = (DWORD)(Value & 0xFFFFFFFF); - if (dwValue != 0) { - XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd),dwValue); - } - } else { - if (g_System->b32BitCore()) - { - Map_GPR_32bit(m_Opcode.rd,true,KnownReg); - XorVariableToX86reg(&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg],GetMipsRegMapLo(m_Opcode.rd)); - } else { - Map_GPR_64bit(m_Opcode.rd,KnownReg); - XorVariableToX86reg(&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg],GetMipsRegMapHi(m_Opcode.rd)); - XorVariableToX86reg(&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg],GetMipsRegMapLo(m_Opcode.rd)); - } - } - } else if (g_System->b32BitCore()) { - Map_GPR_32bit(m_Opcode.rd,true,m_Opcode.rt); - XorVariableToX86reg(&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs],GetMipsRegMapLo(m_Opcode.rd)); - } else { - Map_GPR_64bit(m_Opcode.rd,m_Opcode.rt); - XorVariableToX86reg(&_GPR[m_Opcode.rs].W[1],CRegName::GPR_Hi[m_Opcode.rs],GetMipsRegMapHi(m_Opcode.rd)); - XorVariableToX86reg(&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs],GetMipsRegMapLo(m_Opcode.rd)); - } + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, temp); + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else + { + if (m_Opcode.rd == m_Opcode.rt) + { + x86Reg Reg = Map_TempReg(x86_Any, m_Opcode.rt, false); + Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rs); + SubX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), Reg); + return; + } + Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rs); + if (IsConst(m_Opcode.rt)) + { + SubConstFromX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegLo(m_Opcode.rt)); + } + else if (IsMapped(m_Opcode.rt)) + { + SubX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rt)); + } + else + { + SubVariableFromX86reg(GetMipsRegMapLo(m_Opcode.rd), &_GPR[m_Opcode.rt].W[0], CRegName::GPR_Lo[m_Opcode.rt]); + } + } + if (g_System->bFastSP() && m_Opcode.rd == 29) + { + g_MMU->ResetMemoryStack(); + } } -void CRecompilerOps::SPECIAL_NOR() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::SPECIAL_SUBU() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rd == 0) + { + return; + } - if (IsKnown(m_Opcode.rt) && IsKnown(m_Opcode.rs)) { - if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) { - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); + if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) + { + uint32_t temp = GetMipsRegLo(m_Opcode.rs) - GetMipsRegLo(m_Opcode.rt); - if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) { - m_RegWorkingSet.SetMipsReg(m_Opcode.rd, - ~((Is64Bit(m_Opcode.rt)?GetMipsReg(m_Opcode.rt):(__int64)GetMipsRegLo_S(m_Opcode.rt)) | - (Is64Bit(m_Opcode.rs)?GetMipsReg(m_Opcode.rs):(__int64)GetMipsRegLo_S(m_Opcode.rs))) - ); - if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1){ - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else if (GetMipsRegLo_S(m_Opcode.rd) >= 0 && GetMipsRegHi_S(m_Opcode.rd) == 0){ - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else { - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_64); - } - } else { - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd,~(GetMipsRegLo(m_Opcode.rt) | GetMipsRegLo(m_Opcode.rs))); - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } - } else if (IsMapped(m_Opcode.rt) && IsMapped(m_Opcode.rs)) { - int source1 = m_Opcode.rd == m_Opcode.rt?m_Opcode.rt:m_Opcode.rs; - int source2 = m_Opcode.rd == m_Opcode.rt?m_Opcode.rs:m_Opcode.rt; + if (IsMapped(m_Opcode.rd)) + { + UnMap_GPR(m_Opcode.rd, false); + } - ProtectGPR(m_Opcode.rt); - ProtectGPR(m_Opcode.rs); - if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) { - Map_GPR_64bit(m_Opcode.rd,source1); - if (Is64Bit(source2)) { - OrX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd),GetMipsRegMapHi(source2)); - } else { - OrX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), Map_TempReg(x86_Any, source2, true)); - } - } else { - ProtectGPR(source2); - Map_GPR_32bit(m_Opcode.rd, true, source1); - } - OrX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(source2)); - } else { - DWORD ConstReg = IsConst(m_Opcode.rt)?m_Opcode.rt:m_Opcode.rs; - DWORD MappedReg = IsConst(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, temp); + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else + { + if (m_Opcode.rd == m_Opcode.rt) + { + x86Reg Reg = Map_TempReg(x86_Any, m_Opcode.rt, false); + Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rs); + SubX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), Reg); + return; + } + Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rs); + if (IsConst(m_Opcode.rt)) + { + SubConstFromX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegLo(m_Opcode.rt)); + } + else if (IsMapped(m_Opcode.rt)) + { + SubX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rt)); + } + else + { + SubVariableFromX86reg(GetMipsRegMapLo(m_Opcode.rd), &_GPR[m_Opcode.rt].W[0], CRegName::GPR_Lo[m_Opcode.rt]); + } + } - if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) { - unsigned __int64 Value; - - if (Is64Bit(ConstReg)) { - Value = GetMipsReg(ConstReg); - } else { - Value = IsSigned(ConstReg)?(__int64)GetMipsRegLo_S(ConstReg):GetMipsRegLo(ConstReg); - } - Map_GPR_64bit(m_Opcode.rd,MappedReg); - if ((Value >> 32) != 0) { - OrConstToX86Reg((DWORD)(Value >> 32),GetMipsRegMapHi(m_Opcode.rd)); - } - DWORD dwValue = (DWORD)(Value & 0xFFFFFFFF); - if (dwValue != 0) { - OrConstToX86Reg(dwValue,GetMipsRegMapLo(m_Opcode.rd)); - } - } else { - int Value = GetMipsRegLo(ConstReg); - Map_GPR_32bit(m_Opcode.rd, true, MappedReg); - if (Value != 0) { OrConstToX86Reg(Value,GetMipsRegMapLo(m_Opcode.rd)); } - } - } - } else if (IsKnown(m_Opcode.rt) || IsKnown(m_Opcode.rs)) { - int KnownReg = IsKnown(m_Opcode.rt)?m_Opcode.rt:m_Opcode.rs; - int UnknownReg = IsKnown(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; - - if (IsConst(KnownReg)) { - unsigned __int64 Value = Is64Bit(KnownReg)?GetMipsReg(KnownReg):GetMipsRegLo_S(KnownReg); - DWORD dwValue = (DWORD)(Value & 0xFFFFFFFF); - - if (g_System->b32BitCore() && Is32Bit(KnownReg)) - { - Map_GPR_32bit(m_Opcode.rd,true,UnknownReg); - if (dwValue != 0) { - OrConstToX86Reg(dwValue,GetMipsRegMapLo(m_Opcode.rd)); - } - } else { - Map_GPR_64bit(m_Opcode.rd,UnknownReg); - if ((Value >> 32) != 0) { - OrConstToX86Reg((DWORD)(Value >> 32),GetMipsRegMapHi(m_Opcode.rd)); - } - if (dwValue != 0) { - OrConstToX86Reg(dwValue,GetMipsRegMapLo(m_Opcode.rd)); - } - } - } else { - if (g_System->b32BitCore()) - { - Map_GPR_32bit(m_Opcode.rd,true,KnownReg); - OrVariableToX86Reg(&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg],GetMipsRegMapLo(m_Opcode.rd)); - } else { - Map_GPR_64bit(m_Opcode.rd,KnownReg); - OrVariableToX86Reg(&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg],GetMipsRegMapHi(m_Opcode.rd)); - OrVariableToX86Reg(&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg],GetMipsRegMapLo(m_Opcode.rd)); - } - } - } else { - if (g_System->b32BitCore()) - { - Map_GPR_32bit(m_Opcode.rd,true,m_Opcode.rt); - OrVariableToX86Reg(&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs],GetMipsRegMapLo(m_Opcode.rd)); - } else { - Map_GPR_64bit(m_Opcode.rd,m_Opcode.rt); - OrVariableToX86Reg(&_GPR[m_Opcode.rs].W[1],CRegName::GPR_Hi[m_Opcode.rs],GetMipsRegMapHi(m_Opcode.rd)); - OrVariableToX86Reg(&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs],GetMipsRegMapLo(m_Opcode.rd)); - } - } - - if (IsMapped(m_Opcode.rd)) - { - if (Is64Bit(m_Opcode.rd)) - { - NotX86Reg(GetMipsRegMapHi(m_Opcode.rd)); - } - NotX86Reg(GetMipsRegMapLo(m_Opcode.rd)); - } + if (g_System->bFastSP() && m_Opcode.rd == 29) + { + g_MMU->ResetMemoryStack(); + } } -void CRecompilerOps::SPECIAL_SLT() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rd == 0) - return; +void CRecompilerOps::SPECIAL_AND() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - if (IsKnown(m_Opcode.rt) && IsKnown(m_Opcode.rs)) { - if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) { - if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) { - g_Notify->DisplayError(L"1"); - CRecompilerOps::UnknownOpcode(); - } else { - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); + if (IsKnown(m_Opcode.rt) && IsKnown(m_Opcode.rs)) + { + if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) + { + if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) + { + m_RegWorkingSet.SetMipsReg(m_Opcode.rd, + (Is64Bit(m_Opcode.rt) ? GetMipsReg(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt)) & + (Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs)) + ); - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - if (GetMipsRegLo_S(m_Opcode.rs) < GetMipsRegLo_S(m_Opcode.rt)) { - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd,1); - } else { - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd,0); - } - } - } else if (IsMapped(m_Opcode.rt) && IsMapped(m_Opcode.rs)) { - ProtectGPR(m_Opcode.rt); - ProtectGPR(m_Opcode.rs); - if ((Is64Bit(m_Opcode.rt) && Is64Bit(m_Opcode.rs)) || - (!g_System->b32BitCore() && (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)))) - { - BYTE *Jump[2]; + if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else if (GetMipsRegLo_S(m_Opcode.rd) >= 0 && GetMipsRegHi_S(m_Opcode.rd) == 0) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_64); + } + } + else + { + m_RegWorkingSet.SetMipsReg(m_Opcode.rd, GetMipsRegLo(m_Opcode.rt) & GetMipsReg(m_Opcode.rs)); + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + } + else if (IsMapped(m_Opcode.rt) && IsMapped(m_Opcode.rs)) + { + int source1 = m_Opcode.rd == m_Opcode.rt ? m_Opcode.rt : m_Opcode.rs; + int source2 = m_Opcode.rd == m_Opcode.rt ? m_Opcode.rs : m_Opcode.rt; - CompX86RegToX86Reg( - Is64Bit(m_Opcode.rs) ? GetMipsRegMapHi(m_Opcode.rs) : Map_TempReg(x86_Any, m_Opcode.rs, true), - Is64Bit(m_Opcode.rt) ? GetMipsRegMapHi(m_Opcode.rt) : Map_TempReg(x86_Any, m_Opcode.rt, true) - ); - JeLabel8("Low Compare",0); - Jump[0] = m_RecompPos - 1; - SetlVariable(&m_BranchCompare,"m_BranchCompare"); - JmpLabel8("Continue",0); - Jump[1] = m_RecompPos - 1; + ProtectGPR(source1); + ProtectGPR(source2); + if (Is32Bit(source1) && Is32Bit(source2)) + { + bool Sign = (IsSigned(m_Opcode.rt) && IsSigned(m_Opcode.rs)); + Map_GPR_32bit(m_Opcode.rd, Sign, source1); + AndX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(source2)); + } + else if (Is32Bit(source1) || Is32Bit(source2)) + { + if (IsUnsigned(Is32Bit(source1) ? source1 : source2)) + { + Map_GPR_32bit(m_Opcode.rd, false, source1); + AndX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(source2)); + } + else + { + Map_GPR_64bit(m_Opcode.rd, source1); + if (Is32Bit(source2)) + { + AndX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), Map_TempReg(x86_Any, source2, true)); + } + else + { + AndX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegMapHi(source2)); + } + AndX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(source2)); + } + } + else + { + Map_GPR_64bit(m_Opcode.rd, source1); + AndX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegMapHi(source2)); + AndX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(source2)); + } + } + else + { + int ConstReg = IsConst(m_Opcode.rt) ? m_Opcode.rt : m_Opcode.rs; + int MappedReg = IsConst(m_Opcode.rt) ? m_Opcode.rs : m_Opcode.rt; - CPU_Message(""); - CPU_Message(" Low Compare:"); - SetJump8(Jump[0],m_RecompPos); - CompX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - CPU_Message(""); - CPU_Message(" Continue:"); - SetJump8(Jump[1],m_RecompPos); - Map_GPR_32bit(m_Opcode.rd, true, -1); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rd)); - } else { - Map_GPR_32bit(m_Opcode.rd, true, -1); - CompX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); + if (Is64Bit(ConstReg)) + { + if (Is32Bit(MappedReg) && IsUnsigned(MappedReg)) + { + if (GetMipsRegLo(ConstReg) == 0) + { + Map_GPR_32bit(m_Opcode.rd, false, 0); + } + else + { + uint32_t Value = GetMipsRegLo(ConstReg); + Map_GPR_32bit(m_Opcode.rd, false, MappedReg); + AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), Value); + } + } + else + { + int64_t Value = GetMipsReg(ConstReg); + Map_GPR_64bit(m_Opcode.rd, MappedReg); + AndConstToX86Reg(GetMipsRegMapHi(m_Opcode.rd), (uint32_t)(Value >> 32)); + AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), (uint32_t)(Value & 0xFFFFFFFF)); + } + } + else if (Is64Bit(MappedReg)) + { + uint32_t Value = GetMipsRegLo(ConstReg); + if (Value != 0) + { + Map_GPR_32bit(m_Opcode.rd, IsSigned(ConstReg), MappedReg); + AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), Value); + } + else + { + Map_GPR_32bit(m_Opcode.rd, IsSigned(ConstReg), 0); + } + } + else + { + uint32_t Value = GetMipsRegLo(ConstReg); + bool Sign = false; - if (GetMipsRegMapLo(m_Opcode.rd) > x86_EBX) { - SetlVariable(&m_BranchCompare,"m_BranchCompare"); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rd)); - } else { - Setl(GetMipsRegMapLo(m_Opcode.rd)); - AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), 1); - } - } - } else { - DWORD ConstReg = IsConst(m_Opcode.rs)?m_Opcode.rs:m_Opcode.rt; - DWORD MappedReg = IsConst(m_Opcode.rs)?m_Opcode.rt:m_Opcode.rs; + if (IsSigned(ConstReg) && IsSigned(MappedReg)) + { + Sign = true; + } - ProtectGPR(MappedReg); - if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) { - BYTE *Jump[2]; + if (Value != 0) + { + Map_GPR_32bit(m_Opcode.rd, Sign, MappedReg); + AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), Value); + } + else + { + Map_GPR_32bit(m_Opcode.rd, false, 0); + } + } + } + } + else if (IsKnown(m_Opcode.rt) || IsKnown(m_Opcode.rs)) + { + uint32_t KnownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rt : m_Opcode.rs; + uint32_t UnknownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rs : m_Opcode.rt; - CompConstToX86reg( - Is64Bit(MappedReg) ? GetMipsRegMapHi(MappedReg) : Map_TempReg(x86_Any, MappedReg, true), - Is64Bit(ConstReg) ? GetMipsRegHi(ConstReg) : (GetMipsRegLo_S(ConstReg) >> 31) - ); - JeLabel8("Low Compare",0); - Jump[0] = m_RecompPos - 1; - if (MappedReg == m_Opcode.rs) { - SetlVariable(&m_BranchCompare,"m_BranchCompare"); - } else { - SetgVariable(&m_BranchCompare,"m_BranchCompare"); - } - JmpLabel8("Continue",0); - Jump[1] = m_RecompPos - 1; - - CPU_Message(""); - CPU_Message(" Low Compare:"); - SetJump8(Jump[0],m_RecompPos); - CompConstToX86reg(GetMipsRegMapLo(MappedReg), GetMipsRegLo(ConstReg)); - if (MappedReg == m_Opcode.rs) { - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - } else { - SetaVariable(&m_BranchCompare,"m_BranchCompare"); - } - CPU_Message(""); - CPU_Message(" Continue:"); - SetJump8(Jump[1],m_RecompPos); - Map_GPR_32bit(m_Opcode.rd, true, -1); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rd)); - } else { - DWORD Constant = GetMipsRegLo(ConstReg); - Map_GPR_32bit(m_Opcode.rd, true, -1); - CompConstToX86reg(GetMipsRegMapLo(MappedReg), Constant); - - if (GetMipsRegMapLo(m_Opcode.rd) > x86_EBX) { - if (MappedReg == m_Opcode.rs) { - SetlVariable(&m_BranchCompare,"m_BranchCompare"); - } else { - SetgVariable(&m_BranchCompare,"m_BranchCompare"); - } - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rd)); - } else { - if (MappedReg == m_Opcode.rs) { - Setl(GetMipsRegMapLo(m_Opcode.rd)); - } else { - Setg(GetMipsRegMapLo(m_Opcode.rd)); - } - AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), 1); - } - } - } - } else if (IsKnown(m_Opcode.rt) || IsKnown(m_Opcode.rs)) { - DWORD KnownReg = IsKnown(m_Opcode.rt)?m_Opcode.rt:m_Opcode.rs; - DWORD UnknownReg = IsKnown(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; - BYTE *Jump[2]; - - if (!g_System->b32BitCore()) - { - if (Is64Bit(KnownReg)) { - if (IsConst(KnownReg)) { - CompConstToVariable(GetMipsRegHi(KnownReg),&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg]); - } else { - CompX86regToVariable(GetMipsRegMapHi(KnownReg),&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg]); - } - } else { - if (IsConst(KnownReg)) { - CompConstToVariable((GetMipsRegLo_S(KnownReg) >> 31),&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg]); - } else { - ProtectGPR(KnownReg); - CompX86regToVariable(Map_TempReg(x86_Any, KnownReg, true), &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); - } - } - JeLabel8("Low Compare",0); - Jump[0] = m_RecompPos - 1; - if (KnownReg == (IsConst(KnownReg)?m_Opcode.rs:m_Opcode.rt)) { - SetgVariable(&m_BranchCompare,"m_BranchCompare"); - } else { - SetlVariable(&m_BranchCompare,"m_BranchCompare"); - } - JmpLabel8("Continue",0); - Jump[1] = m_RecompPos - 1; - - CPU_Message(""); - CPU_Message(" Low Compare:"); - SetJump8(Jump[0],m_RecompPos); - if (IsConst(KnownReg)) { - CompConstToVariable(GetMipsRegLo(KnownReg),&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg]); - } else { - CompX86regToVariable(GetMipsRegMapLo(KnownReg),&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg]); - } - if (KnownReg == (IsConst(KnownReg)?m_Opcode.rs:m_Opcode.rt)) { - SetaVariable(&m_BranchCompare,"m_BranchCompare"); - } else { - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - } - CPU_Message(""); - CPU_Message(" Continue:"); - SetJump8(Jump[1],m_RecompPos); - Map_GPR_32bit(m_Opcode.rd, true, -1); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rd)); - } else { - if (IsMapped(KnownReg)) - { - ProtectGPR(KnownReg); - } - bool bConstant = IsConst(KnownReg); - DWORD Value = IsConst(KnownReg) ? GetMipsRegLo(KnownReg) : 0; - - Map_GPR_32bit(m_Opcode.rd, true, -1); - if (bConstant) { - CompConstToVariable(Value,&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg]); - } else { - CompX86regToVariable(GetMipsRegMapLo(KnownReg),&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg]); - } - if (GetMipsRegMapLo(m_Opcode.rd) > x86_EBX) { - if (KnownReg == (bConstant?m_Opcode.rs:m_Opcode.rt)) { - SetgVariable(&m_BranchCompare,"m_BranchCompare"); - } else { - SetlVariable(&m_BranchCompare,"m_BranchCompare"); - } - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rd)); - } else { - if (KnownReg == (bConstant?m_Opcode.rs:m_Opcode.rt)) { - Setg(GetMipsRegMapLo(m_Opcode.rd)); - } else { - Setl(GetMipsRegMapLo(m_Opcode.rd)); - } - AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), 1); - } - } - } else if (g_System->b32BitCore()) { - x86Reg Reg = Map_TempReg(x86_Any,m_Opcode.rs,false); - Map_GPR_32bit(m_Opcode.rd,false, -1); - CompX86regToVariable(Reg,&_GPR[m_Opcode.rt].W[0],CRegName::GPR_Lo[m_Opcode.rt]); - if (GetMipsRegMapLo(m_Opcode.rd) > x86_EBX) { - SetlVariable(&m_BranchCompare,"m_BranchCompare"); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rd)); - } else { - Setl(GetMipsRegMapLo(m_Opcode.rd)); - AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), 1); - } - } else { - BYTE *Jump[2] = { NULL, NULL }; - - x86Reg Reg = Map_TempReg(x86_Any, m_Opcode.rs, true); - CompX86regToVariable(Reg,&_GPR[m_Opcode.rt].W[1],CRegName::GPR_Hi[m_Opcode.rt]); - JeLabel8("Low Compare",0); - Jump[0] = m_RecompPos - 1; - SetlVariable(&m_BranchCompare,"m_BranchCompare"); - JmpLabel8("Continue",0); - Jump[1] = m_RecompPos - 1; - - CPU_Message(""); - CPU_Message(" Low Compare:"); - SetJump8(Jump[0],m_RecompPos); - CompX86regToVariable(Map_TempReg(Reg, m_Opcode.rs, false), &_GPR[m_Opcode.rt].W[0], CRegName::GPR_Lo[m_Opcode.rt]); - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - if (Jump[1]) - { - CPU_Message(""); - CPU_Message(" Continue:"); - SetJump8(Jump[1],m_RecompPos); - } - Map_GPR_32bit(m_Opcode.rd, true, -1); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rd)); - } + if (IsConst(KnownReg)) + { + if (Is64Bit(KnownReg)) + { + uint64_t Value = GetMipsReg(KnownReg); + Map_GPR_64bit(m_Opcode.rd, UnknownReg); + AndConstToX86Reg(GetMipsRegMapHi(m_Opcode.rd), (uint32_t)(Value >> 32)); + AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), (uint32_t)(Value & 0xFFFFFFFF)); + } + else + { + uint32_t Value = GetMipsRegLo(KnownReg); + Map_GPR_32bit(m_Opcode.rd, IsSigned(KnownReg), UnknownReg); + AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), Value); + } + } + else + { + ProtectGPR(KnownReg); + if (KnownReg == m_Opcode.rd) + { + if (Is64Bit(KnownReg) || !g_System->b32BitCore()) + { + Map_GPR_64bit(m_Opcode.rd, KnownReg); + AndVariableToX86Reg(&_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg], GetMipsRegMapHi(m_Opcode.rd)); + AndVariableToX86Reg(&_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg], GetMipsRegMapLo(m_Opcode.rd)); + } + else + { + Map_GPR_32bit(m_Opcode.rd, IsSigned(KnownReg), KnownReg); + AndVariableToX86Reg(&_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg], GetMipsRegMapLo(m_Opcode.rd)); + } + } + else + { + if (Is64Bit(KnownReg)) + { + Map_GPR_64bit(m_Opcode.rd, UnknownReg); + AndX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegMapHi(KnownReg)); + AndX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(KnownReg)); + } + else + { + Map_GPR_32bit(m_Opcode.rd, IsSigned(KnownReg), UnknownReg); + AndX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(KnownReg)); + } + } + } + } + else + { + if (g_System->b32BitCore()) + { + Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); + } + else + { + Map_GPR_64bit(m_Opcode.rd, m_Opcode.rt); + AndVariableToX86Reg(&_GPR[m_Opcode.rs].W[1], CRegName::GPR_Hi[m_Opcode.rs], GetMipsRegMapHi(m_Opcode.rd)); + } + AndVariableToX86Reg(&_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs], GetMipsRegMapLo(m_Opcode.rd)); + } } -void CRecompilerOps::SPECIAL_SLTU() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rd == 0) - return; +void CRecompilerOps::SPECIAL_OR() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - if (IsKnown(m_Opcode.rt) && IsKnown(m_Opcode.rs)) { - if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) { - if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) { - g_Notify->DisplayError(L"1"); - CRecompilerOps::UnknownOpcode(); - } else { - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); + if (IsKnown(m_Opcode.rt) && IsKnown(m_Opcode.rs)) + { + if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) + { + if (IsMapped(m_Opcode.rd)) + { + UnMap_GPR(m_Opcode.rd, false); + } - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - if (GetMipsRegLo(m_Opcode.rs) < GetMipsRegLo(m_Opcode.rt)) { - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd,1); - } else { - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd,0); - } - } - } else if (IsMapped(m_Opcode.rt) && IsMapped(m_Opcode.rs)) { - ProtectGPR(m_Opcode.rt); - ProtectGPR(m_Opcode.rs); - if ((Is64Bit(m_Opcode.rt) && Is64Bit(m_Opcode.rs)) || - (!g_System->b32BitCore() && (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)))) - { - BYTE *Jump[2]; + if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) + { + m_RegWorkingSet.SetMipsReg(m_Opcode.rd, + (Is64Bit(m_Opcode.rt) ? GetMipsReg(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt)) | + (Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs)) + ); + if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else if (GetMipsRegLo_S(m_Opcode.rd) >= 0 && GetMipsRegHi_S(m_Opcode.rd) == 0) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_64); + } + } + else + { + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, GetMipsRegLo(m_Opcode.rt) | GetMipsRegLo(m_Opcode.rs)); + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + } + else if (IsMapped(m_Opcode.rt) && IsMapped(m_Opcode.rs)) + { + int source1 = m_Opcode.rd == m_Opcode.rt ? m_Opcode.rt : m_Opcode.rs; + int source2 = m_Opcode.rd == m_Opcode.rt ? m_Opcode.rs : m_Opcode.rt; - CompX86RegToX86Reg( - Is64Bit(m_Opcode.rs) ? GetMipsRegMapHi(m_Opcode.rs) : Map_TempReg(x86_Any, m_Opcode.rs, true), - Is64Bit(m_Opcode.rt) ? GetMipsRegMapHi(m_Opcode.rt) : Map_TempReg(x86_Any, m_Opcode.rt, true) - ); - JeLabel8("Low Compare",0); - Jump[0] = m_RecompPos - 1; - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - JmpLabel8("Continue",0); - Jump[1] = m_RecompPos - 1; + ProtectGPR(m_Opcode.rt); + ProtectGPR(m_Opcode.rs); + if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) + { + Map_GPR_64bit(m_Opcode.rd, source1); + if (Is64Bit(source2)) + { + OrX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegMapHi(source2)); + } + else + { + OrX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), Map_TempReg(x86_Any, source2, true)); + } + } + else + { + ProtectGPR(source2); + Map_GPR_32bit(m_Opcode.rd, true, source1); + } + OrX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(source2)); + } + else + { + uint32_t ConstReg = IsConst(m_Opcode.rt) ? m_Opcode.rt : m_Opcode.rs; + uint32_t MappedReg = IsConst(m_Opcode.rt) ? m_Opcode.rs : m_Opcode.rt; - CPU_Message(""); - CPU_Message(" Low Compare:"); - SetJump8(Jump[0],m_RecompPos); - CompX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - CPU_Message(""); - CPU_Message(" Continue:"); - SetJump8(Jump[1],m_RecompPos); - Map_GPR_32bit(m_Opcode.rd, true, -1); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rd)); - } else { - CompX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - Map_GPR_32bit(m_Opcode.rd, true, -1); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rd)); - } - } else { - if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) { - DWORD ConstHi, ConstLo, ConstReg, MappedReg; - x86Reg MappedRegHi, MappedRegLo; - BYTE *Jump[2]; + if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) + { + uint64_t Value; - ConstReg = IsConst(m_Opcode.rt)?m_Opcode.rt:m_Opcode.rs; - MappedReg = IsConst(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; + if (Is64Bit(ConstReg)) + { + Value = GetMipsReg(ConstReg); + } + else + { + Value = IsSigned(ConstReg) ? (int64_t)GetMipsRegLo_S(ConstReg) : GetMipsRegLo(ConstReg); + } + Map_GPR_64bit(m_Opcode.rd, MappedReg); + if ((Value >> 32) != 0) + { + OrConstToX86Reg((uint32_t)(Value >> 32), GetMipsRegMapHi(m_Opcode.rd)); + } + uint32_t dwValue = (uint32_t)(Value & 0xFFFFFFFF); + if (dwValue != 0) + { + OrConstToX86Reg(dwValue, GetMipsRegMapLo(m_Opcode.rd)); + } + } + else + { + int Value = GetMipsRegLo(ConstReg); + Map_GPR_32bit(m_Opcode.rd, true, MappedReg); + if (Value != 0) { OrConstToX86Reg(Value, GetMipsRegMapLo(m_Opcode.rd)); } + } + } + } + else if (IsKnown(m_Opcode.rt) || IsKnown(m_Opcode.rs)) + { + int KnownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rt : m_Opcode.rs; + int UnknownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rs : m_Opcode.rt; - ConstLo = GetMipsRegLo_S(ConstReg); - ConstHi = GetMipsRegLo_S(ConstReg) >> 31; - if (Is64Bit(ConstReg)) { ConstHi = GetMipsRegHi(ConstReg); } + if (IsConst(KnownReg)) + { + uint64_t Value = Is64Bit(KnownReg) ? GetMipsReg(KnownReg) : GetMipsRegLo_S(KnownReg); + uint32_t dwValue = (uint32_t)(Value & 0xFFFFFFFF); - ProtectGPR(MappedReg); - MappedRegLo = GetMipsRegMapLo(MappedReg); - MappedRegHi = GetMipsRegMapHi(MappedReg); - if (Is32Bit(MappedReg)) { - MappedRegHi = Map_TempReg(x86_Any, MappedReg, true); - } - - - Map_GPR_32bit(m_Opcode.rd, true, -1); - CompConstToX86reg(MappedRegHi, ConstHi); - JeLabel8("Low Compare",0); - Jump[0] = m_RecompPos - 1; - if (MappedReg == m_Opcode.rs) { - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - } else { - SetaVariable(&m_BranchCompare,"m_BranchCompare"); - } - JmpLabel8("Continue",0); - Jump[1] = m_RecompPos - 1; - - CPU_Message(""); - CPU_Message(" Low Compare:"); - SetJump8(Jump[0],m_RecompPos); - CompConstToX86reg(MappedRegLo, ConstLo); - if (MappedReg == m_Opcode.rs) { - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - } else { - SetaVariable(&m_BranchCompare,"m_BranchCompare"); - } - CPU_Message(""); - CPU_Message(" Continue:"); - SetJump8(Jump[1],m_RecompPos); - Map_GPR_32bit(m_Opcode.rd, true, -1); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rd)); - } else { - DWORD Const = IsConst(m_Opcode.rs)?GetMipsRegLo(m_Opcode.rs):GetMipsRegLo(m_Opcode.rt); - DWORD MappedReg = IsConst(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; - - CompConstToX86reg(GetMipsRegMapLo(MappedReg), Const); - if (MappedReg == m_Opcode.rs) { - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - } else { - SetaVariable(&m_BranchCompare,"m_BranchCompare"); - } - Map_GPR_32bit(m_Opcode.rd, true, -1); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rd)); - } - } - } else if (IsKnown(m_Opcode.rt) || IsKnown(m_Opcode.rs)) { - DWORD KnownReg = IsKnown(m_Opcode.rt)?m_Opcode.rt:m_Opcode.rs; - DWORD UnknownReg = IsKnown(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; - BYTE *Jump[2] = { NULL, NULL }; - - ProtectGPR(KnownReg); - if (g_System->b32BitCore()) - { - DWORD TestReg = IsConst(KnownReg)?m_Opcode.rs:m_Opcode.rt; - if (IsConst(KnownReg)) { - DWORD Value = GetMipsRegLo(KnownReg); - Map_GPR_32bit(m_Opcode.rd, true, -1); - CompConstToVariable(Value,&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg]); - } else { - CompX86regToVariable(GetMipsRegMapLo(KnownReg),&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg]); - } - if (KnownReg == TestReg) - { - SetaVariable(&m_BranchCompare,"m_BranchCompare"); - } else { - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - } - } else { - if (IsConst(KnownReg)) { - if (Is64Bit(KnownReg)) { - CompConstToVariable(GetMipsRegHi(KnownReg),&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg]); - } else { - CompConstToVariable((GetMipsRegLo_S(KnownReg) >> 31),&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg]); - } - } else { - if (Is64Bit(KnownReg)) { - CompX86regToVariable(GetMipsRegMapHi(KnownReg),&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg]); - } else { - ProtectGPR(KnownReg); - CompX86regToVariable(Map_TempReg(x86_Any, KnownReg, true), &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); - } - } - JeLabel8("Low Compare",0); - Jump[0] = m_RecompPos - 1; - - if (KnownReg == (IsConst(KnownReg)?m_Opcode.rs:m_Opcode.rt)) { - SetaVariable(&m_BranchCompare,"m_BranchCompare"); - } else { - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - } - JmpLabel8("Continue",0); - Jump[1] = m_RecompPos - 1; - - CPU_Message(""); - CPU_Message(" Low Compare:"); - SetJump8(Jump[0],m_RecompPos); - if (IsConst(KnownReg)) { - CompConstToVariable(GetMipsRegLo(KnownReg),&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg]); - } else { - CompX86regToVariable(GetMipsRegMapLo(KnownReg),&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg]); - } - if (KnownReg == (IsConst(KnownReg)?m_Opcode.rs:m_Opcode.rt)) { - SetaVariable(&m_BranchCompare,"m_BranchCompare"); - } else { - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - } - if (Jump[1]) - { - CPU_Message(""); - CPU_Message(" Continue:"); - SetJump8(Jump[1],m_RecompPos); - } - } - Map_GPR_32bit(m_Opcode.rd, true, -1); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rd)); - } else if (g_System->b32BitCore()) { - x86Reg Reg = Map_TempReg(x86_Any,m_Opcode.rs,false); - Map_GPR_32bit(m_Opcode.rd,false, -1); - CompX86regToVariable(Reg,&_GPR[m_Opcode.rt].W[0],CRegName::GPR_Lo[m_Opcode.rt]); - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rd)); - } else { - BYTE *Jump[2] = { NULL, NULL }; - - x86Reg Reg = Map_TempReg(x86_Any, m_Opcode.rs, true); - CompX86regToVariable(Reg,&_GPR[m_Opcode.rt].W[1],CRegName::GPR_Hi[m_Opcode.rt]); - JeLabel8("Low Compare",0); - Jump[0] = m_RecompPos - 1; - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - JmpLabel8("Continue",0); - Jump[1] = m_RecompPos - 1; - - CPU_Message(""); - CPU_Message(" Low Compare:"); - SetJump8(Jump[0],m_RecompPos); - CompX86regToVariable(Map_TempReg(Reg, m_Opcode.rs, false), &_GPR[m_Opcode.rt].W[0], CRegName::GPR_Lo[m_Opcode.rt]); - SetbVariable(&m_BranchCompare,"m_BranchCompare"); - if (Jump[1]) - { - CPU_Message(""); - CPU_Message(" Continue:"); - SetJump8(Jump[1],m_RecompPos); - } - Map_GPR_32bit(m_Opcode.rd, true, -1); - MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rd)); - } + if (g_System->b32BitCore() && Is32Bit(KnownReg)) + { + Map_GPR_32bit(m_Opcode.rd, true, UnknownReg); + if (dwValue != 0) + { + OrConstToX86Reg(dwValue, GetMipsRegMapLo(m_Opcode.rd)); + } + } + else + { + Map_GPR_64bit(m_Opcode.rd, UnknownReg); + if ((Value >> 32) != 0) + { + OrConstToX86Reg((uint32_t)(Value >> 32), GetMipsRegMapHi(m_Opcode.rd)); + } + if (dwValue != 0) + { + OrConstToX86Reg(dwValue, GetMipsRegMapLo(m_Opcode.rd)); + } + } + } + else + { + if (g_System->b32BitCore()) + { + Map_GPR_32bit(m_Opcode.rd, true, KnownReg); + OrVariableToX86Reg(&_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg], GetMipsRegMapLo(m_Opcode.rd)); + } + else + { + Map_GPR_64bit(m_Opcode.rd, KnownReg); + OrVariableToX86Reg(&_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg], GetMipsRegMapHi(m_Opcode.rd)); + OrVariableToX86Reg(&_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg], GetMipsRegMapLo(m_Opcode.rd)); + } + } + } + else + { + if (g_System->b32BitCore()) + { + Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); + OrVariableToX86Reg(&_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs], GetMipsRegMapLo(m_Opcode.rd)); + } + else + { + Map_GPR_64bit(m_Opcode.rd, m_Opcode.rt); + OrVariableToX86Reg(&_GPR[m_Opcode.rs].W[1], CRegName::GPR_Hi[m_Opcode.rs], GetMipsRegMapHi(m_Opcode.rd)); + OrVariableToX86Reg(&_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs], GetMipsRegMapLo(m_Opcode.rd)); + } + } + if (g_System->bFastSP() && m_Opcode.rd == 29) + { + ResetX86Protection(); + g_MMU->ResetMemoryStack(); + } } -void CRecompilerOps::SPECIAL_DADD() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rd == 0) - return; +void CRecompilerOps::SPECIAL_XOR() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rd == 0) + return; - if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) { - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); + if (m_Opcode.rt == m_Opcode.rs) + { + UnMap_GPR(m_Opcode.rd, false); + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, 0); + return; + } + if (IsKnown(m_Opcode.rt) && IsKnown(m_Opcode.rs)) + { + if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) + { + if (IsMapped(m_Opcode.rd)) + { + UnMap_GPR(m_Opcode.rd, false); + } - m_RegWorkingSet.SetMipsReg(m_Opcode.rd, - Is64Bit(m_Opcode.rs)?GetMipsReg(m_Opcode.rs):(__int64)GetMipsRegLo_S(m_Opcode.rs) + - Is64Bit(m_Opcode.rt)?GetMipsReg(m_Opcode.rt):(__int64)GetMipsRegLo_S(m_Opcode.rt) - ); - if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1){ - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else if (GetMipsRegLo_S(m_Opcode.rd) >= 0 && GetMipsRegHi_S(m_Opcode.rd) == 0){ - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else { - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_64); - } - } else { - int source1 = m_Opcode.rd == m_Opcode.rt?m_Opcode.rt:m_Opcode.rs; - int source2 = m_Opcode.rd == m_Opcode.rt?m_Opcode.rs:m_Opcode.rt; + if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) + { + if (bHaveDebugger()) { g_Notify->DisplayError(L"XOR 1"); } + CRecompilerOps::UnknownOpcode(); + } + else + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, GetMipsRegLo(m_Opcode.rt) ^ GetMipsRegLo(m_Opcode.rs)); + } + } + else if (IsMapped(m_Opcode.rt) && IsMapped(m_Opcode.rs)) + { + int source1 = m_Opcode.rd == m_Opcode.rt ? m_Opcode.rt : m_Opcode.rs; + int source2 = m_Opcode.rd == m_Opcode.rt ? m_Opcode.rs : m_Opcode.rt; - if (IsMapped(source2)) { ProtectGPR(source2); } - Map_GPR_64bit(m_Opcode.rd,source1); - if (IsConst(source2)) { - AddConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegLo(source2)); - AddConstToX86Reg(GetMipsRegMapHi(m_Opcode.rd),GetMipsRegHi(source2)); - } else if (IsMapped(source2)) { - x86Reg HiReg = Is64Bit(source2) ? GetMipsRegMapHi(source2) : Map_TempReg(x86_Any, source2, true); - AddX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(source2)); - AdcX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd),HiReg); - } else { - AddVariableToX86reg(GetMipsRegMapLo(m_Opcode.rd),&_GPR[source2].W[0],CRegName::GPR_Lo[source2]); - AdcVariableToX86reg(GetMipsRegMapHi(m_Opcode.rd),&_GPR[source2].W[1],CRegName::GPR_Hi[source2]); - } - } + ProtectGPR(source1); + ProtectGPR(source2); + if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) + { + Map_GPR_64bit(m_Opcode.rd, source1); + if (Is64Bit(source2)) + { + XorX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegMapHi(source2)); + } + else if (IsSigned(source2)) + { + XorX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), Map_TempReg(x86_Any, source2, true)); + } + XorX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(source2)); + } + else + { + if (IsSigned(m_Opcode.rt) != IsSigned(m_Opcode.rs)) + { + Map_GPR_32bit(m_Opcode.rd, true, source1); + } + else + { + Map_GPR_32bit(m_Opcode.rd, IsSigned(m_Opcode.rt), source1); + } + XorX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(source2)); + } + } + else + { + uint32_t ConstReg = IsConst(m_Opcode.rt) ? m_Opcode.rt : m_Opcode.rs; + uint32_t MappedReg = IsConst(m_Opcode.rt) ? m_Opcode.rs : m_Opcode.rt; + + if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) + { + uint32_t ConstHi, ConstLo; + + ConstHi = Is32Bit(ConstReg) ? (uint32_t)(GetMipsRegLo_S(ConstReg) >> 31) : GetMipsRegHi(ConstReg); + ConstLo = GetMipsRegLo(ConstReg); + Map_GPR_64bit(m_Opcode.rd, MappedReg); + if (ConstHi != 0) { XorConstToX86Reg(GetMipsRegMapHi(m_Opcode.rd), ConstHi); } + if (ConstLo != 0) { XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), ConstLo); } + } + else + { + int Value = GetMipsRegLo(ConstReg); + if (IsSigned(m_Opcode.rt) != IsSigned(m_Opcode.rs)) + { + Map_GPR_32bit(m_Opcode.rd, true, MappedReg); + } + else + { + Map_GPR_32bit(m_Opcode.rd, IsSigned(MappedReg), MappedReg); + } + if (Value != 0) { XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), Value); } + } + } + } + else if (IsKnown(m_Opcode.rt) || IsKnown(m_Opcode.rs)) + { + int KnownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rt : m_Opcode.rs; + int UnknownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rs : m_Opcode.rt; + + if (IsConst(KnownReg)) + { + uint64_t Value; + + if (Is64Bit(KnownReg)) + { + Value = GetMipsReg(KnownReg); + Map_GPR_64bit(m_Opcode.rd, UnknownReg); + if ((Value >> 32) != 0) + { + XorConstToX86Reg(GetMipsRegMapHi(m_Opcode.rd), (uint32_t)(Value >> 32)); + } + } + else + { + Map_GPR_32bit(m_Opcode.rd, true, UnknownReg); + if (IsSigned(KnownReg)) + { + Value = (int)GetMipsRegLo(KnownReg); + } + else + { + Value = GetMipsRegLo(KnownReg); + } + } + uint32_t dwValue = (uint32_t)(Value & 0xFFFFFFFF); + if (dwValue != 0) + { + XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), dwValue); + } + } + else + { + if (g_System->b32BitCore()) + { + Map_GPR_32bit(m_Opcode.rd, true, KnownReg); + XorVariableToX86reg(&_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg], GetMipsRegMapLo(m_Opcode.rd)); + } + else + { + Map_GPR_64bit(m_Opcode.rd, KnownReg); + XorVariableToX86reg(&_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg], GetMipsRegMapHi(m_Opcode.rd)); + XorVariableToX86reg(&_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg], GetMipsRegMapLo(m_Opcode.rd)); + } + } + } + else if (g_System->b32BitCore()) + { + Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); + XorVariableToX86reg(&_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs], GetMipsRegMapLo(m_Opcode.rd)); + } + else + { + Map_GPR_64bit(m_Opcode.rd, m_Opcode.rt); + XorVariableToX86reg(&_GPR[m_Opcode.rs].W[1], CRegName::GPR_Hi[m_Opcode.rs], GetMipsRegMapHi(m_Opcode.rd)); + XorVariableToX86reg(&_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs], GetMipsRegMapLo(m_Opcode.rd)); + } } -void CRecompilerOps::SPECIAL_DADDU() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rd == 0) - return; +void CRecompilerOps::SPECIAL_NOR() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) { - __int64 ValRs = Is64Bit(m_Opcode.rs)?GetMipsReg(m_Opcode.rs):(__int64)GetMipsRegLo_S(m_Opcode.rs); - __int64 ValRt = Is64Bit(m_Opcode.rt)?GetMipsReg(m_Opcode.rt):(__int64)GetMipsRegLo_S(m_Opcode.rt); - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); + if (IsKnown(m_Opcode.rt) && IsKnown(m_Opcode.rs)) + { + if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) + { + if (IsMapped(m_Opcode.rd)) + UnMap_GPR(m_Opcode.rd, false); - m_RegWorkingSet.SetMipsReg(m_Opcode.rd, ValRs + ValRt); - if ((GetMipsRegHi(m_Opcode.rd) == 0) && (GetMipsRegLo(m_Opcode.rd) & 0x80000000) == 0) { - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else if ((GetMipsRegHi(m_Opcode.rd) == 0xFFFFFFFF) && (GetMipsRegLo(m_Opcode.rd) & 0x80000000) != 0) { - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else { - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_64); - } - } else { - int source1 = m_Opcode.rd == m_Opcode.rt?m_Opcode.rt:m_Opcode.rs; - int source2 = m_Opcode.rd == m_Opcode.rt?m_Opcode.rs:m_Opcode.rt; + if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) + { + m_RegWorkingSet.SetMipsReg(m_Opcode.rd, + ~((Is64Bit(m_Opcode.rt) ? GetMipsReg(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt)) | + (Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs))) + ); + if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else if (GetMipsRegLo_S(m_Opcode.rd) >= 0 && GetMipsRegHi_S(m_Opcode.rd) == 0) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_64); + } + } + else + { + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, ~(GetMipsRegLo(m_Opcode.rt) | GetMipsRegLo(m_Opcode.rs))); + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + } + else if (IsMapped(m_Opcode.rt) && IsMapped(m_Opcode.rs)) + { + int source1 = m_Opcode.rd == m_Opcode.rt ? m_Opcode.rt : m_Opcode.rs; + int source2 = m_Opcode.rd == m_Opcode.rt ? m_Opcode.rs : m_Opcode.rt; - if (IsMapped(source2)) { ProtectGPR(source2); } - Map_GPR_64bit(m_Opcode.rd,source1); - if (IsConst(source2)) { - AddConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegLo(source2)); - AddConstToX86Reg(GetMipsRegMapHi(m_Opcode.rd),GetMipsRegHi(source2)); - } else if (IsMapped(source2)) { - x86Reg HiReg = Is64Bit(source2) ? GetMipsRegMapHi(source2) : Map_TempReg(x86_Any, source2, true); - AddX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(source2)); - AdcX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd),HiReg); - } else { - AddVariableToX86reg(GetMipsRegMapLo(m_Opcode.rd),&_GPR[source2].W[0],CRegName::GPR_Lo[source2]); - AdcVariableToX86reg(GetMipsRegMapHi(m_Opcode.rd),&_GPR[source2].W[1],CRegName::GPR_Hi[source2]); - } - } + ProtectGPR(m_Opcode.rt); + ProtectGPR(m_Opcode.rs); + if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) + { + Map_GPR_64bit(m_Opcode.rd, source1); + if (Is64Bit(source2)) + { + OrX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegMapHi(source2)); + } + else + { + OrX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), Map_TempReg(x86_Any, source2, true)); + } + } + else + { + ProtectGPR(source2); + Map_GPR_32bit(m_Opcode.rd, true, source1); + } + OrX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(source2)); + } + else + { + uint32_t ConstReg = IsConst(m_Opcode.rt) ? m_Opcode.rt : m_Opcode.rs; + uint32_t MappedReg = IsConst(m_Opcode.rt) ? m_Opcode.rs : m_Opcode.rt; + + if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) + { + uint64_t Value; + + if (Is64Bit(ConstReg)) + { + Value = GetMipsReg(ConstReg); + } + else + { + Value = IsSigned(ConstReg) ? (int64_t)GetMipsRegLo_S(ConstReg) : GetMipsRegLo(ConstReg); + } + Map_GPR_64bit(m_Opcode.rd, MappedReg); + if ((Value >> 32) != 0) + { + OrConstToX86Reg((uint32_t)(Value >> 32), GetMipsRegMapHi(m_Opcode.rd)); + } + uint32_t dwValue = (uint32_t)(Value & 0xFFFFFFFF); + if (dwValue != 0) { + OrConstToX86Reg(dwValue, GetMipsRegMapLo(m_Opcode.rd)); + } + } + else + { + int Value = GetMipsRegLo(ConstReg); + Map_GPR_32bit(m_Opcode.rd, true, MappedReg); + if (Value != 0) { OrConstToX86Reg(Value, GetMipsRegMapLo(m_Opcode.rd)); } + } + } + } + else if (IsKnown(m_Opcode.rt) || IsKnown(m_Opcode.rs)) + { + int KnownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rt : m_Opcode.rs; + int UnknownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rs : m_Opcode.rt; + + if (IsConst(KnownReg)) + { + uint64_t Value = Is64Bit(KnownReg) ? GetMipsReg(KnownReg) : GetMipsRegLo_S(KnownReg); + uint32_t dwValue = (uint32_t)(Value & 0xFFFFFFFF); + + if (g_System->b32BitCore() && Is32Bit(KnownReg)) + { + Map_GPR_32bit(m_Opcode.rd, true, UnknownReg); + if (dwValue != 0) + { + OrConstToX86Reg(dwValue, GetMipsRegMapLo(m_Opcode.rd)); + } + } + else + { + Map_GPR_64bit(m_Opcode.rd, UnknownReg); + if ((Value >> 32) != 0) + { + OrConstToX86Reg((uint32_t)(Value >> 32), GetMipsRegMapHi(m_Opcode.rd)); + } + if (dwValue != 0) + { + OrConstToX86Reg(dwValue, GetMipsRegMapLo(m_Opcode.rd)); + } + } + } + else + { + if (g_System->b32BitCore()) + { + Map_GPR_32bit(m_Opcode.rd, true, KnownReg); + OrVariableToX86Reg(&_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg], GetMipsRegMapLo(m_Opcode.rd)); + } + else + { + Map_GPR_64bit(m_Opcode.rd, KnownReg); + OrVariableToX86Reg(&_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg], GetMipsRegMapHi(m_Opcode.rd)); + OrVariableToX86Reg(&_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg], GetMipsRegMapLo(m_Opcode.rd)); + } + } + } + else + { + if (g_System->b32BitCore()) + { + Map_GPR_32bit(m_Opcode.rd, true, m_Opcode.rt); + OrVariableToX86Reg(&_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs], GetMipsRegMapLo(m_Opcode.rd)); + } + else + { + Map_GPR_64bit(m_Opcode.rd, m_Opcode.rt); + OrVariableToX86Reg(&_GPR[m_Opcode.rs].W[1], CRegName::GPR_Hi[m_Opcode.rs], GetMipsRegMapHi(m_Opcode.rd)); + OrVariableToX86Reg(&_GPR[m_Opcode.rs].W[0], CRegName::GPR_Lo[m_Opcode.rs], GetMipsRegMapLo(m_Opcode.rd)); + } + } + + if (IsMapped(m_Opcode.rd)) + { + if (Is64Bit(m_Opcode.rd)) + { + NotX86Reg(GetMipsRegMapHi(m_Opcode.rd)); + } + NotX86Reg(GetMipsRegMapLo(m_Opcode.rd)); + } } -void CRecompilerOps::SPECIAL_DSUB() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rd == 0) - return; +void CRecompilerOps::SPECIAL_SLT() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rd == 0) + { + return; + } - if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) { - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); + if (IsKnown(m_Opcode.rt) && IsKnown(m_Opcode.rs)) + { + if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) + { + if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) + { + g_Notify->DisplayError(L"1"); + CRecompilerOps::UnknownOpcode(); + } + else + { + if (IsMapped(m_Opcode.rd)) + { + UnMap_GPR(m_Opcode.rd, false); + } - m_RegWorkingSet.SetMipsReg(m_Opcode.rd, - Is64Bit(m_Opcode.rs)?GetMipsReg(m_Opcode.rs):(__int64)GetMipsRegLo_S(m_Opcode.rs) - - Is64Bit(m_Opcode.rt)?GetMipsReg(m_Opcode.rt):(__int64)GetMipsRegLo_S(m_Opcode.rt) - ); - if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1){ - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else if (GetMipsRegLo_S(m_Opcode.rd) >= 0 && GetMipsRegHi_S(m_Opcode.rd) == 0){ - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else { - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_64); - } - } else { - if (m_Opcode.rd == m_Opcode.rt) { - x86Reg HiReg = Map_TempReg(x86_Any, m_Opcode.rt, true); - x86Reg LoReg = Map_TempReg(x86_Any, m_Opcode.rt, false); - Map_GPR_64bit(m_Opcode.rd,m_Opcode.rs); - SubX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),LoReg); - SbbX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd),HiReg); - return; - } - - if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } - Map_GPR_64bit(m_Opcode.rd,m_Opcode.rs); - if (IsConst(m_Opcode.rt)) { - SubConstFromX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegLo(m_Opcode.rt)); - SbbConstFromX86Reg(GetMipsRegMapHi(m_Opcode.rd),GetMipsRegHi(m_Opcode.rt)); - } else if (IsMapped(m_Opcode.rt)) { - x86Reg HiReg = Is64Bit(m_Opcode.rt) ? GetMipsRegMapHi(m_Opcode.rt) : Map_TempReg(x86_Any, m_Opcode.rt, true); - SubX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(m_Opcode.rt)); - SbbX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd),HiReg); - } else { - SubVariableFromX86reg(GetMipsRegMapLo(m_Opcode.rd),&_GPR[m_Opcode.rt].W[0],CRegName::GPR_Lo[m_Opcode.rt]); - SbbVariableFromX86reg(GetMipsRegMapHi(m_Opcode.rd),&_GPR[m_Opcode.rt].W[1],CRegName::GPR_Hi[m_Opcode.rt]); - } - } + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + if (GetMipsRegLo_S(m_Opcode.rs) < GetMipsRegLo_S(m_Opcode.rt)) + { + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, 1); + } + else + { + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, 0); + } + } + } + else if (IsMapped(m_Opcode.rt) && IsMapped(m_Opcode.rs)) + { + ProtectGPR(m_Opcode.rt); + ProtectGPR(m_Opcode.rs); + if ((Is64Bit(m_Opcode.rt) && Is64Bit(m_Opcode.rs)) || + (!g_System->b32BitCore() && (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)))) + { + uint8_t *Jump[2]; + + CompX86RegToX86Reg( + Is64Bit(m_Opcode.rs) ? GetMipsRegMapHi(m_Opcode.rs) : Map_TempReg(x86_Any, m_Opcode.rs, true), + Is64Bit(m_Opcode.rt) ? GetMipsRegMapHi(m_Opcode.rt) : Map_TempReg(x86_Any, m_Opcode.rt, true) + ); + JeLabel8("Low Compare", 0); + Jump[0] = m_RecompPos - 1; + SetlVariable(&m_BranchCompare, "m_BranchCompare"); + JmpLabel8("Continue", 0); + Jump[1] = m_RecompPos - 1; + + CPU_Message(""); + CPU_Message(" Low Compare:"); + SetJump8(Jump[0], m_RecompPos); + CompX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + CPU_Message(""); + CPU_Message(" Continue:"); + SetJump8(Jump[1], m_RecompPos); + Map_GPR_32bit(m_Opcode.rd, true, -1); + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); + } + else + { + Map_GPR_32bit(m_Opcode.rd, true, -1); + CompX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); + + if (GetMipsRegMapLo(m_Opcode.rd) > x86_EBX) + { + SetlVariable(&m_BranchCompare, "m_BranchCompare"); + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); + } + else + { + Setl(GetMipsRegMapLo(m_Opcode.rd)); + AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), 1); + } + } + } + else + { + uint32_t ConstReg = IsConst(m_Opcode.rs) ? m_Opcode.rs : m_Opcode.rt; + uint32_t MappedReg = IsConst(m_Opcode.rs) ? m_Opcode.rt : m_Opcode.rs; + + ProtectGPR(MappedReg); + if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) + { + uint8_t *Jump[2]; + + CompConstToX86reg( + Is64Bit(MappedReg) ? GetMipsRegMapHi(MappedReg) : Map_TempReg(x86_Any, MappedReg, true), + Is64Bit(ConstReg) ? GetMipsRegHi(ConstReg) : (GetMipsRegLo_S(ConstReg) >> 31) + ); + JeLabel8("Low Compare", 0); + Jump[0] = m_RecompPos - 1; + if (MappedReg == m_Opcode.rs) + { + SetlVariable(&m_BranchCompare, "m_BranchCompare"); + } + else + { + SetgVariable(&m_BranchCompare, "m_BranchCompare"); + } + JmpLabel8("Continue", 0); + Jump[1] = m_RecompPos - 1; + + CPU_Message(""); + CPU_Message(" Low Compare:"); + SetJump8(Jump[0], m_RecompPos); + CompConstToX86reg(GetMipsRegMapLo(MappedReg), GetMipsRegLo(ConstReg)); + if (MappedReg == m_Opcode.rs) + { + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + } + else + { + SetaVariable(&m_BranchCompare, "m_BranchCompare"); + } + CPU_Message(""); + CPU_Message(" Continue:"); + SetJump8(Jump[1], m_RecompPos); + Map_GPR_32bit(m_Opcode.rd, true, -1); + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); + } + else + { + uint32_t Constant = GetMipsRegLo(ConstReg); + Map_GPR_32bit(m_Opcode.rd, true, -1); + CompConstToX86reg(GetMipsRegMapLo(MappedReg), Constant); + + if (GetMipsRegMapLo(m_Opcode.rd) > x86_EBX) + { + if (MappedReg == m_Opcode.rs) + { + SetlVariable(&m_BranchCompare, "m_BranchCompare"); + } + else + { + SetgVariable(&m_BranchCompare, "m_BranchCompare"); + } + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); + } + else + { + if (MappedReg == m_Opcode.rs) + { + Setl(GetMipsRegMapLo(m_Opcode.rd)); + } + else + { + Setg(GetMipsRegMapLo(m_Opcode.rd)); + } + AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), 1); + } + } + } + } + else if (IsKnown(m_Opcode.rt) || IsKnown(m_Opcode.rs)) + { + uint32_t KnownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rt : m_Opcode.rs; + uint32_t UnknownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rs : m_Opcode.rt; + uint8_t *Jump[2]; + + if (!g_System->b32BitCore()) + { + if (Is64Bit(KnownReg)) + { + if (IsConst(KnownReg)) + { + CompConstToVariable(GetMipsRegHi(KnownReg), &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); + } + else + { + CompX86regToVariable(GetMipsRegMapHi(KnownReg), &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); + } + } + else + { + if (IsConst(KnownReg)) + { + CompConstToVariable((GetMipsRegLo_S(KnownReg) >> 31), &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); + } + else + { + ProtectGPR(KnownReg); + CompX86regToVariable(Map_TempReg(x86_Any, KnownReg, true), &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); + } + } + JeLabel8("Low Compare", 0); + Jump[0] = m_RecompPos - 1; + if (KnownReg == (IsConst(KnownReg) ? m_Opcode.rs : m_Opcode.rt)) + { + SetgVariable(&m_BranchCompare, "m_BranchCompare"); + } + else + { + SetlVariable(&m_BranchCompare, "m_BranchCompare"); + } + JmpLabel8("Continue", 0); + Jump[1] = m_RecompPos - 1; + + CPU_Message(""); + CPU_Message(" Low Compare:"); + SetJump8(Jump[0], m_RecompPos); + if (IsConst(KnownReg)) + { + CompConstToVariable(GetMipsRegLo(KnownReg), &_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg]); + } + else + { + CompX86regToVariable(GetMipsRegMapLo(KnownReg), &_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg]); + } + if (KnownReg == (IsConst(KnownReg) ? m_Opcode.rs : m_Opcode.rt)) { + SetaVariable(&m_BranchCompare, "m_BranchCompare"); + } + else + { + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + } + CPU_Message(""); + CPU_Message(" Continue:"); + SetJump8(Jump[1], m_RecompPos); + Map_GPR_32bit(m_Opcode.rd, true, -1); + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); + } + else + { + if (IsMapped(KnownReg)) + { + ProtectGPR(KnownReg); + } + bool bConstant = IsConst(KnownReg); + uint32_t Value = IsConst(KnownReg) ? GetMipsRegLo(KnownReg) : 0; + + Map_GPR_32bit(m_Opcode.rd, true, -1); + if (bConstant) + { + CompConstToVariable(Value, &_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg]); + } + else + { + CompX86regToVariable(GetMipsRegMapLo(KnownReg), &_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg]); + } + if (GetMipsRegMapLo(m_Opcode.rd) > x86_EBX) + { + if (KnownReg == (bConstant ? m_Opcode.rs : m_Opcode.rt)) + { + SetgVariable(&m_BranchCompare, "m_BranchCompare"); + } + else + { + SetlVariable(&m_BranchCompare, "m_BranchCompare"); + } + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); + } + else + { + if (KnownReg == (bConstant ? m_Opcode.rs : m_Opcode.rt)) + { + Setg(GetMipsRegMapLo(m_Opcode.rd)); + } + else + { + Setl(GetMipsRegMapLo(m_Opcode.rd)); + } + AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), 1); + } + } + } + else if (g_System->b32BitCore()) + { + x86Reg Reg = Map_TempReg(x86_Any, m_Opcode.rs, false); + Map_GPR_32bit(m_Opcode.rd, false, -1); + CompX86regToVariable(Reg, &_GPR[m_Opcode.rt].W[0], CRegName::GPR_Lo[m_Opcode.rt]); + if (GetMipsRegMapLo(m_Opcode.rd) > x86_EBX) + { + SetlVariable(&m_BranchCompare, "m_BranchCompare"); + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); + } + else + { + Setl(GetMipsRegMapLo(m_Opcode.rd)); + AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), 1); + } + } + else + { + uint8_t *Jump[2] = { NULL, NULL }; + + x86Reg Reg = Map_TempReg(x86_Any, m_Opcode.rs, true); + CompX86regToVariable(Reg, &_GPR[m_Opcode.rt].W[1], CRegName::GPR_Hi[m_Opcode.rt]); + JeLabel8("Low Compare", 0); + Jump[0] = m_RecompPos - 1; + SetlVariable(&m_BranchCompare, "m_BranchCompare"); + JmpLabel8("Continue", 0); + Jump[1] = m_RecompPos - 1; + + CPU_Message(""); + CPU_Message(" Low Compare:"); + SetJump8(Jump[0], m_RecompPos); + CompX86regToVariable(Map_TempReg(Reg, m_Opcode.rs, false), &_GPR[m_Opcode.rt].W[0], CRegName::GPR_Lo[m_Opcode.rt]); + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + if (Jump[1]) + { + CPU_Message(""); + CPU_Message(" Continue:"); + SetJump8(Jump[1], m_RecompPos); + } + Map_GPR_32bit(m_Opcode.rd, true, -1); + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); + } } -void CRecompilerOps::SPECIAL_DSUBU() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.rd == 0) - return; +void CRecompilerOps::SPECIAL_SLTU() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rd == 0) + { + return; + } - if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) { - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); + if (IsKnown(m_Opcode.rt) && IsKnown(m_Opcode.rs)) + { + if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) + { + if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) + { + g_Notify->DisplayError(L"1"); + CRecompilerOps::UnknownOpcode(); + } + else + { + if (IsMapped(m_Opcode.rd)) + { + UnMap_GPR(m_Opcode.rd, false); + } - m_RegWorkingSet.SetMipsReg(m_Opcode.rd, - Is64Bit(m_Opcode.rs)?GetMipsReg(m_Opcode.rs):(__int64)GetMipsRegLo_S(m_Opcode.rs) - - Is64Bit(m_Opcode.rt)?GetMipsReg(m_Opcode.rt):(__int64)GetMipsRegLo_S(m_Opcode.rt) - ); - if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1){ - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else if (GetMipsRegLo_S(m_Opcode.rd) >= 0 && GetMipsRegHi_S(m_Opcode.rd) == 0){ - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else { - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_64); - } - } else { - if (m_Opcode.rd == m_Opcode.rt) { - x86Reg HiReg = Map_TempReg(x86_Any, m_Opcode.rt, true); - x86Reg LoReg = Map_TempReg(x86_Any, m_Opcode.rt, false); - Map_GPR_64bit(m_Opcode.rd,m_Opcode.rs); - SubX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),LoReg); - SbbX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd),HiReg); - return; - } - if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } - Map_GPR_64bit(m_Opcode.rd,m_Opcode.rs); - if (IsConst(m_Opcode.rt)) { - SubConstFromX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegLo(m_Opcode.rt)); - SbbConstFromX86Reg(GetMipsRegMapHi(m_Opcode.rd),GetMipsRegHi(m_Opcode.rt)); - } else if (IsMapped(m_Opcode.rt)) { - x86Reg HiReg = Is64Bit(m_Opcode.rt) ? GetMipsRegMapHi(m_Opcode.rt) : Map_TempReg(x86_Any, m_Opcode.rt, true); - SubX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(m_Opcode.rt)); - SbbX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd),HiReg); - } else { - SubVariableFromX86reg(GetMipsRegMapLo(m_Opcode.rd),&_GPR[m_Opcode.rt].W[0],CRegName::GPR_Lo[m_Opcode.rt]); - SbbVariableFromX86reg(GetMipsRegMapHi(m_Opcode.rd),&_GPR[m_Opcode.rt].W[1],CRegName::GPR_Hi[m_Opcode.rt]); - } - } + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + if (GetMipsRegLo(m_Opcode.rs) < GetMipsRegLo(m_Opcode.rt)) + { + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, 1); + } + else + { + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, 0); + } + } + } + else if (IsMapped(m_Opcode.rt) && IsMapped(m_Opcode.rs)) + { + ProtectGPR(m_Opcode.rt); + ProtectGPR(m_Opcode.rs); + if ((Is64Bit(m_Opcode.rt) && Is64Bit(m_Opcode.rs)) || + (!g_System->b32BitCore() && (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)))) + { + uint8_t *Jump[2]; + + CompX86RegToX86Reg( + Is64Bit(m_Opcode.rs) ? GetMipsRegMapHi(m_Opcode.rs) : Map_TempReg(x86_Any, m_Opcode.rs, true), + Is64Bit(m_Opcode.rt) ? GetMipsRegMapHi(m_Opcode.rt) : Map_TempReg(x86_Any, m_Opcode.rt, true) + ); + JeLabel8("Low Compare", 0); + Jump[0] = m_RecompPos - 1; + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + JmpLabel8("Continue", 0); + Jump[1] = m_RecompPos - 1; + + CPU_Message(""); + CPU_Message(" Low Compare:"); + SetJump8(Jump[0], m_RecompPos); + CompX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + CPU_Message(""); + CPU_Message(" Continue:"); + SetJump8(Jump[1], m_RecompPos); + Map_GPR_32bit(m_Opcode.rd, true, -1); + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); + } + else + { + CompX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rs), GetMipsRegMapLo(m_Opcode.rt)); + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + Map_GPR_32bit(m_Opcode.rd, true, -1); + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); + } + } + else + { + if (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)) + { + uint32_t ConstHi, ConstLo, ConstReg, MappedReg; + x86Reg MappedRegHi, MappedRegLo; + uint8_t *Jump[2]; + + ConstReg = IsConst(m_Opcode.rt) ? m_Opcode.rt : m_Opcode.rs; + MappedReg = IsConst(m_Opcode.rt) ? m_Opcode.rs : m_Opcode.rt; + + ConstLo = GetMipsRegLo_S(ConstReg); + ConstHi = GetMipsRegLo_S(ConstReg) >> 31; + if (Is64Bit(ConstReg)) { ConstHi = GetMipsRegHi(ConstReg); } + + ProtectGPR(MappedReg); + MappedRegLo = GetMipsRegMapLo(MappedReg); + MappedRegHi = GetMipsRegMapHi(MappedReg); + if (Is32Bit(MappedReg)) + { + MappedRegHi = Map_TempReg(x86_Any, MappedReg, true); + } + + Map_GPR_32bit(m_Opcode.rd, true, -1); + CompConstToX86reg(MappedRegHi, ConstHi); + JeLabel8("Low Compare", 0); + Jump[0] = m_RecompPos - 1; + if (MappedReg == m_Opcode.rs) + { + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + } + else + { + SetaVariable(&m_BranchCompare, "m_BranchCompare"); + } + JmpLabel8("Continue", 0); + Jump[1] = m_RecompPos - 1; + + CPU_Message(""); + CPU_Message(" Low Compare:"); + SetJump8(Jump[0], m_RecompPos); + CompConstToX86reg(MappedRegLo, ConstLo); + if (MappedReg == m_Opcode.rs) + { + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + } + else + { + SetaVariable(&m_BranchCompare, "m_BranchCompare"); + } + CPU_Message(""); + CPU_Message(" Continue:"); + SetJump8(Jump[1], m_RecompPos); + Map_GPR_32bit(m_Opcode.rd, true, -1); + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); + } + else + { + uint32_t Const = IsConst(m_Opcode.rs) ? GetMipsRegLo(m_Opcode.rs) : GetMipsRegLo(m_Opcode.rt); + uint32_t MappedReg = IsConst(m_Opcode.rt) ? m_Opcode.rs : m_Opcode.rt; + + CompConstToX86reg(GetMipsRegMapLo(MappedReg), Const); + if (MappedReg == m_Opcode.rs) + { + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + } + else + { + SetaVariable(&m_BranchCompare, "m_BranchCompare"); + } + Map_GPR_32bit(m_Opcode.rd, true, -1); + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); + } + } + } + else if (IsKnown(m_Opcode.rt) || IsKnown(m_Opcode.rs)) + { + uint32_t KnownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rt : m_Opcode.rs; + uint32_t UnknownReg = IsKnown(m_Opcode.rt) ? m_Opcode.rs : m_Opcode.rt; + uint8_t *Jump[2] = { NULL, NULL }; + + ProtectGPR(KnownReg); + if (g_System->b32BitCore()) + { + uint32_t TestReg = IsConst(KnownReg) ? m_Opcode.rs : m_Opcode.rt; + if (IsConst(KnownReg)) + { + uint32_t Value = GetMipsRegLo(KnownReg); + Map_GPR_32bit(m_Opcode.rd, true, -1); + CompConstToVariable(Value, &_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg]); + } + else + { + CompX86regToVariable(GetMipsRegMapLo(KnownReg), &_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg]); + } + if (KnownReg == TestReg) + { + SetaVariable(&m_BranchCompare, "m_BranchCompare"); + } + else + { + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + } + } + else + { + if (IsConst(KnownReg)) + { + if (Is64Bit(KnownReg)) + { + CompConstToVariable(GetMipsRegHi(KnownReg), &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); + } + else + { + CompConstToVariable((GetMipsRegLo_S(KnownReg) >> 31), &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); + } + } + else + { + if (Is64Bit(KnownReg)) + { + CompX86regToVariable(GetMipsRegMapHi(KnownReg), &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); + } + else + { + ProtectGPR(KnownReg); + CompX86regToVariable(Map_TempReg(x86_Any, KnownReg, true), &_GPR[UnknownReg].W[1], CRegName::GPR_Hi[UnknownReg]); + } + } + JeLabel8("Low Compare", 0); + Jump[0] = m_RecompPos - 1; + + if (KnownReg == (IsConst(KnownReg) ? m_Opcode.rs : m_Opcode.rt)) + { + SetaVariable(&m_BranchCompare, "m_BranchCompare"); + } + else + { + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + } + JmpLabel8("Continue", 0); + Jump[1] = m_RecompPos - 1; + + CPU_Message(""); + CPU_Message(" Low Compare:"); + SetJump8(Jump[0], m_RecompPos); + if (IsConst(KnownReg)) + { + CompConstToVariable(GetMipsRegLo(KnownReg), &_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg]); + } + else + { + CompX86regToVariable(GetMipsRegMapLo(KnownReg), &_GPR[UnknownReg].W[0], CRegName::GPR_Lo[UnknownReg]); + } + if (KnownReg == (IsConst(KnownReg) ? m_Opcode.rs : m_Opcode.rt)) + { + SetaVariable(&m_BranchCompare, "m_BranchCompare"); + } + else + { + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + } + if (Jump[1]) + { + CPU_Message(""); + CPU_Message(" Continue:"); + SetJump8(Jump[1], m_RecompPos); + } + } + Map_GPR_32bit(m_Opcode.rd, true, -1); + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); + } + else if (g_System->b32BitCore()) + { + x86Reg Reg = Map_TempReg(x86_Any, m_Opcode.rs, false); + Map_GPR_32bit(m_Opcode.rd, false, -1); + CompX86regToVariable(Reg, &_GPR[m_Opcode.rt].W[0], CRegName::GPR_Lo[m_Opcode.rt]); + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); + } + else + { + uint8_t *Jump[2] = { NULL, NULL }; + + x86Reg Reg = Map_TempReg(x86_Any, m_Opcode.rs, true); + CompX86regToVariable(Reg, &_GPR[m_Opcode.rt].W[1], CRegName::GPR_Hi[m_Opcode.rt]); + JeLabel8("Low Compare", 0); + Jump[0] = m_RecompPos - 1; + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + JmpLabel8("Continue", 0); + Jump[1] = m_RecompPos - 1; + + CPU_Message(""); + CPU_Message(" Low Compare:"); + SetJump8(Jump[0], m_RecompPos); + CompX86regToVariable(Map_TempReg(Reg, m_Opcode.rs, false), &_GPR[m_Opcode.rt].W[0], CRegName::GPR_Lo[m_Opcode.rt]); + SetbVariable(&m_BranchCompare, "m_BranchCompare"); + if (Jump[1]) + { + CPU_Message(""); + CPU_Message(" Continue:"); + SetJump8(Jump[1], m_RecompPos); + } + Map_GPR_32bit(m_Opcode.rd, true, -1); + MoveVariableToX86reg(&m_BranchCompare, "m_BranchCompare", GetMipsRegMapLo(m_Opcode.rd)); + } } -void CRecompilerOps::SPECIAL_DSLL() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::SPECIAL_DADD() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rd == 0) + { + return; + } - if (m_Opcode.rd == 0) - return; + if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) + { + if (IsMapped(m_Opcode.rd)) + { + UnMap_GPR(m_Opcode.rd, false); + } - if (IsConst(m_Opcode.rt)) - { - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); + m_RegWorkingSet.SetMipsReg(m_Opcode.rd, + Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs) + + Is64Bit(m_Opcode.rt) ? GetMipsReg(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt) + ); + if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else if (GetMipsRegLo_S(m_Opcode.rd) >= 0 && GetMipsRegHi_S(m_Opcode.rd) == 0) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_64); + } + } + else + { + int source1 = m_Opcode.rd == m_Opcode.rt ? m_Opcode.rt : m_Opcode.rs; + int source2 = m_Opcode.rd == m_Opcode.rt ? m_Opcode.rs : m_Opcode.rt; - __int64 Value = Is64Bit(m_Opcode.rt)?GetMipsReg_S(m_Opcode.rt):(__int64)GetMipsRegLo_S(m_Opcode.rt); - m_RegWorkingSet.SetMipsReg(m_Opcode.rd, Value << m_Opcode.sa); - if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1){ - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else if (GetMipsRegLo_S(m_Opcode.rd) >= 0 && GetMipsRegHi_S(m_Opcode.rd) == 0){ - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else { - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_64); - } - return; - } - - Map_GPR_64bit(m_Opcode.rd,m_Opcode.rt); - ShiftLeftDoubleImmed(GetMipsRegMapHi(m_Opcode.rd),GetMipsRegMapLo(m_Opcode.rd),(BYTE)m_Opcode.sa); - ShiftLeftSignImmed(GetMipsRegMapLo(m_Opcode.rd),(BYTE)m_Opcode.sa); + if (IsMapped(source2)) { ProtectGPR(source2); } + Map_GPR_64bit(m_Opcode.rd, source1); + if (IsConst(source2)) + { + AddConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegLo(source2)); + AddConstToX86Reg(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegHi(source2)); + } + else if (IsMapped(source2)) + { + x86Reg HiReg = Is64Bit(source2) ? GetMipsRegMapHi(source2) : Map_TempReg(x86_Any, source2, true); + AddX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(source2)); + AdcX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), HiReg); + } + else + { + AddVariableToX86reg(GetMipsRegMapLo(m_Opcode.rd), &_GPR[source2].W[0], CRegName::GPR_Lo[source2]); + AdcVariableToX86reg(GetMipsRegMapHi(m_Opcode.rd), &_GPR[source2].W[1], CRegName::GPR_Hi[source2]); + } + } } -void CRecompilerOps::SPECIAL_DSRL() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::SPECIAL_DADDU() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rd == 0) + return; - if (m_Opcode.rd == 0) - return; + if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) + { + int64_t ValRs = Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs); + int64_t ValRt = Is64Bit(m_Opcode.rt) ? GetMipsReg(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt); + if (IsMapped(m_Opcode.rd)) + UnMap_GPR(m_Opcode.rd, false); - if (IsConst(m_Opcode.rt)) { - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); + m_RegWorkingSet.SetMipsReg(m_Opcode.rd, ValRs + ValRt); + if ((GetMipsRegHi(m_Opcode.rd) == 0) && (GetMipsRegLo(m_Opcode.rd) & 0x80000000) == 0) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else if ((GetMipsRegHi(m_Opcode.rd) == 0xFFFFFFFF) && (GetMipsRegLo(m_Opcode.rd) & 0x80000000) != 0) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_64); + } + } + else + { + int source1 = m_Opcode.rd == m_Opcode.rt ? m_Opcode.rt : m_Opcode.rs; + int source2 = m_Opcode.rd == m_Opcode.rt ? m_Opcode.rs : m_Opcode.rt; - __int64 Value = Is64Bit(m_Opcode.rt)?GetMipsReg_S(m_Opcode.rt):(__int64)GetMipsRegLo_S(m_Opcode.rt); - m_RegWorkingSet.SetMipsReg(m_Opcode.rd,Value >> m_Opcode.sa); - if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1){ - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else if (GetMipsRegLo_S(m_Opcode.rd) >= 0 && GetMipsRegHi_S(m_Opcode.rd) == 0){ - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else { - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_64); - } - return; - } - Map_GPR_64bit(m_Opcode.rd,m_Opcode.rt); - ShiftRightDoubleImmed(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapHi(m_Opcode.rd),(BYTE)m_Opcode.sa); - ShiftRightUnsignImmed(GetMipsRegMapHi(m_Opcode.rd),(BYTE)m_Opcode.sa); + if (IsMapped(source2)) { ProtectGPR(source2); } + Map_GPR_64bit(m_Opcode.rd, source1); + if (IsConst(source2)) + { + AddConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegLo(source2)); + AddConstToX86Reg(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegHi(source2)); + } + else if (IsMapped(source2)) + { + x86Reg HiReg = Is64Bit(source2) ? GetMipsRegMapHi(source2) : Map_TempReg(x86_Any, source2, true); + AddX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(source2)); + AdcX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), HiReg); + } + else + { + AddVariableToX86reg(GetMipsRegMapLo(m_Opcode.rd), &_GPR[source2].W[0], CRegName::GPR_Lo[source2]); + AdcVariableToX86reg(GetMipsRegMapHi(m_Opcode.rd), &_GPR[source2].W[1], CRegName::GPR_Hi[source2]); + } + } } -void CRecompilerOps::SPECIAL_DSRA() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::SPECIAL_DSUB() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rd == 0) + { + return; + } - if (m_Opcode.rd == 0) - return; + if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) + { + if (IsMapped(m_Opcode.rd)) + { + UnMap_GPR(m_Opcode.rd, false); + } - if (IsConst(m_Opcode.rt)) { - if (IsMapped(m_Opcode.rd)) - UnMap_GPR(m_Opcode.rd, false); + m_RegWorkingSet.SetMipsReg(m_Opcode.rd, + Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs) - + Is64Bit(m_Opcode.rt) ? GetMipsReg(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt) + ); + if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else if (GetMipsRegLo_S(m_Opcode.rd) >= 0 && GetMipsRegHi_S(m_Opcode.rd) == 0) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_64); + } + } + else + { + if (m_Opcode.rd == m_Opcode.rt) + { + x86Reg HiReg = Map_TempReg(x86_Any, m_Opcode.rt, true); + x86Reg LoReg = Map_TempReg(x86_Any, m_Opcode.rt, false); + Map_GPR_64bit(m_Opcode.rd, m_Opcode.rs); + SubX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), LoReg); + SbbX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), HiReg); + return; + } - __int64 Value = Is64Bit(m_Opcode.rt)?GetMipsReg_S(m_Opcode.rt):(__int64)GetMipsRegLo_S(m_Opcode.rt); - m_RegWorkingSet.SetMipsReg_S(m_Opcode.rd, Value >> m_Opcode.sa); - if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1){ - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else if (GetMipsRegLo_S(m_Opcode.rd) >= 0 && GetMipsRegHi_S(m_Opcode.rd) == 0){ - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else { - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_64); - } - return; - } - - Map_GPR_64bit(m_Opcode.rd,m_Opcode.rt); - ShiftRightDoubleImmed(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapHi(m_Opcode.rd),(BYTE)m_Opcode.sa); - ShiftRightSignImmed(GetMipsRegMapHi(m_Opcode.rd),(BYTE)m_Opcode.sa); + if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } + Map_GPR_64bit(m_Opcode.rd, m_Opcode.rs); + if (IsConst(m_Opcode.rt)) + { + SubConstFromX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegLo(m_Opcode.rt)); + SbbConstFromX86Reg(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegHi(m_Opcode.rt)); + } + else if (IsMapped(m_Opcode.rt)) + { + x86Reg HiReg = Is64Bit(m_Opcode.rt) ? GetMipsRegMapHi(m_Opcode.rt) : Map_TempReg(x86_Any, m_Opcode.rt, true); + SubX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rt)); + SbbX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), HiReg); + } + else + { + SubVariableFromX86reg(GetMipsRegMapLo(m_Opcode.rd), &_GPR[m_Opcode.rt].W[0], CRegName::GPR_Lo[m_Opcode.rt]); + SbbVariableFromX86reg(GetMipsRegMapHi(m_Opcode.rd), &_GPR[m_Opcode.rt].W[1], CRegName::GPR_Hi[m_Opcode.rt]); + } + } } -void CRecompilerOps::SPECIAL_DSLL32() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::SPECIAL_DSUBU() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (m_Opcode.rd == 0) + { + return; + } - if (m_Opcode.rd == 0) - return; + if (IsConst(m_Opcode.rt) && IsConst(m_Opcode.rs)) + { + if (IsMapped(m_Opcode.rd)) + { + UnMap_GPR(m_Opcode.rd, false); + } - if (IsConst(m_Opcode.rt)) { - if (m_Opcode.rt != m_Opcode.rd) - UnMap_GPR(m_Opcode.rd, false); - - m_RegWorkingSet.SetMipsRegHi(m_Opcode.rd,GetMipsRegLo(m_Opcode.rt) << m_Opcode.sa); - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd,0); - if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1){ - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else if (GetMipsRegLo_S(m_Opcode.rd) >= 0 && GetMipsRegHi_S(m_Opcode.rd) == 0){ - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - } else { - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_64); - } - } else if (IsMapped(m_Opcode.rt)) { - ProtectGPR(m_Opcode.rt); - Map_GPR_64bit(m_Opcode.rd,-1); - if (m_Opcode.rt != m_Opcode.rd) { - MoveX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rt),GetMipsRegMapHi(m_Opcode.rd)); - } else { - CPU_Message(" regcache: switch hi (%s) with lo (%s) for %s",x86_Name(GetMipsRegMapHi(m_Opcode.rt)),x86_Name(GetMipsRegMapLo(m_Opcode.rt)),CRegName::GPR[m_Opcode.rt]); - x86Reg HiReg = GetMipsRegMapHi(m_Opcode.rt); - m_RegWorkingSet.SetMipsRegMapHi(m_Opcode.rt,GetMipsRegMapLo(m_Opcode.rt)); - m_RegWorkingSet.SetMipsRegMapLo(m_Opcode.rt,HiReg); - } - if ((BYTE)m_Opcode.sa != 0) { - ShiftLeftSignImmed(GetMipsRegMapHi(m_Opcode.rd),(BYTE)m_Opcode.sa); - } - XorX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(m_Opcode.rd)); - } else { - Map_GPR_64bit(m_Opcode.rd,-1); - MoveVariableToX86reg(&_GPR[m_Opcode.rt],CRegName::GPR_Hi[m_Opcode.rt],GetMipsRegMapHi(m_Opcode.rd)); - if ((BYTE)m_Opcode.sa != 0) { - ShiftLeftSignImmed(GetMipsRegMapHi(m_Opcode.rd),(BYTE)m_Opcode.sa); - } - XorX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd),GetMipsRegMapLo(m_Opcode.rd)); - } + m_RegWorkingSet.SetMipsReg(m_Opcode.rd, + Is64Bit(m_Opcode.rs) ? GetMipsReg(m_Opcode.rs) : (int64_t)GetMipsRegLo_S(m_Opcode.rs) - + Is64Bit(m_Opcode.rt) ? GetMipsReg(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt) + ); + if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else if (GetMipsRegLo_S(m_Opcode.rd) >= 0 && GetMipsRegHi_S(m_Opcode.rd) == 0) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_64); + } + } + else + { + if (m_Opcode.rd == m_Opcode.rt) + { + x86Reg HiReg = Map_TempReg(x86_Any, m_Opcode.rt, true); + x86Reg LoReg = Map_TempReg(x86_Any, m_Opcode.rt, false); + Map_GPR_64bit(m_Opcode.rd, m_Opcode.rs); + SubX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), LoReg); + SbbX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), HiReg); + return; + } + if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } + Map_GPR_64bit(m_Opcode.rd, m_Opcode.rs); + if (IsConst(m_Opcode.rt)) + { + SubConstFromX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegLo(m_Opcode.rt)); + SbbConstFromX86Reg(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegHi(m_Opcode.rt)); + } + else if (IsMapped(m_Opcode.rt)) + { + x86Reg HiReg = Is64Bit(m_Opcode.rt) ? GetMipsRegMapHi(m_Opcode.rt) : Map_TempReg(x86_Any, m_Opcode.rt, true); + SubX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rt)); + SbbX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rd), HiReg); + } + else + { + SubVariableFromX86reg(GetMipsRegMapLo(m_Opcode.rd), &_GPR[m_Opcode.rt].W[0], CRegName::GPR_Lo[m_Opcode.rt]); + SbbVariableFromX86reg(GetMipsRegMapHi(m_Opcode.rd), &_GPR[m_Opcode.rt].W[1], CRegName::GPR_Hi[m_Opcode.rt]); + } + } } -void CRecompilerOps::SPECIAL_DSRL32() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::SPECIAL_DSLL() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - if (IsConst(m_Opcode.rt)) { - if (m_Opcode.rt != m_Opcode.rd) - UnMap_GPR(m_Opcode.rd, false); - - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_64); - m_RegWorkingSet.SetMipsReg(m_Opcode.rd, (DWORD)(GetMipsRegHi(m_Opcode.rt) >> m_Opcode.sa)); - } else if (IsMapped(m_Opcode.rt)) { - ProtectGPR(m_Opcode.rt); - if (Is64Bit(m_Opcode.rt)) { - if (m_Opcode.rt == m_Opcode.rd) { - CPU_Message(" regcache: switch hi (%s) with lo (%s) for %s",x86_Name(GetMipsRegMapHi(m_Opcode.rt)),x86_Name(GetMipsRegMapLo(m_Opcode.rt)),CRegName::GPR[m_Opcode.rt]); - x86Reg HiReg = GetMipsRegMapHi(m_Opcode.rt); - m_RegWorkingSet.SetMipsRegMapHi(m_Opcode.rt,GetMipsRegMapLo(m_Opcode.rt)); - m_RegWorkingSet.SetMipsRegMapLo(m_Opcode.rt,HiReg); - Map_GPR_32bit(m_Opcode.rd, false, -1); - } else { - Map_GPR_32bit(m_Opcode.rd, false, -1); - MoveX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rt),GetMipsRegMapLo(m_Opcode.rd)); - } - if ((BYTE)m_Opcode.sa != 0) { - ShiftRightUnsignImmed(GetMipsRegMapLo(m_Opcode.rd),(BYTE)m_Opcode.sa); - } - } else { - CRecompilerOps::UnknownOpcode(); - } - } else { - Map_GPR_32bit(m_Opcode.rd, false, -1); - MoveVariableToX86reg(&_GPR[m_Opcode.rt].UW[1],CRegName::GPR_Hi[m_Opcode.rt],GetMipsRegMapLo(m_Opcode.rd)); - if ((BYTE)m_Opcode.sa != 0) { - ShiftRightUnsignImmed(GetMipsRegMapLo(m_Opcode.rd),(BYTE)m_Opcode.sa); - } - } + if (m_Opcode.rd == 0) + { + return; + } + + if (IsConst(m_Opcode.rt)) + { + if (IsMapped(m_Opcode.rd)) + { + UnMap_GPR(m_Opcode.rd, false); + } + + int64_t Value = Is64Bit(m_Opcode.rt) ? GetMipsReg_S(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt); + m_RegWorkingSet.SetMipsReg(m_Opcode.rd, Value << m_Opcode.sa); + if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else if (GetMipsRegLo_S(m_Opcode.rd) >= 0 && GetMipsRegHi_S(m_Opcode.rd) == 0) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_64); + } + return; + } + + Map_GPR_64bit(m_Opcode.rd, m_Opcode.rt); + ShiftLeftDoubleImmed(GetMipsRegMapHi(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rd), (uint8_t)m_Opcode.sa); + ShiftLeftSignImmed(GetMipsRegMapLo(m_Opcode.rd), (uint8_t)m_Opcode.sa); } -void CRecompilerOps::SPECIAL_DSRA32() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::SPECIAL_DSRL() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - if (IsConst(m_Opcode.rt)) { - if (m_Opcode.rt != m_Opcode.rd) - UnMap_GPR(m_Opcode.rd, false); + if (m_Opcode.rd == 0) + { + return; + } - m_RegWorkingSet.SetMipsRegState(m_Opcode.rd,CRegInfo::STATE_CONST_32_SIGN); - m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd,(DWORD)(GetMipsReg_S(m_Opcode.rt) >> (m_Opcode.sa + 32))); - } else if (IsMapped(m_Opcode.rt)) { - ProtectGPR(m_Opcode.rt); - if (Is64Bit(m_Opcode.rt)) { - if (m_Opcode.rt == m_Opcode.rd) { - CPU_Message(" regcache: switch hi (%s) with lo (%s) for %s",x86_Name(GetMipsRegMapHi(m_Opcode.rt)),x86_Name(GetMipsRegMapLo(m_Opcode.rt)),CRegName::GPR[m_Opcode.rt]); - x86Reg HiReg = GetMipsRegMapHi(m_Opcode.rt); - m_RegWorkingSet.SetMipsRegMapHi(m_Opcode.rt,GetMipsRegMapLo(m_Opcode.rt)); - m_RegWorkingSet.SetMipsRegMapLo(m_Opcode.rt,HiReg); - Map_GPR_32bit(m_Opcode.rd, true, -1); - } else { - Map_GPR_32bit(m_Opcode.rd, true, -1); - MoveX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rt),GetMipsRegMapLo(m_Opcode.rd)); - } - if ((BYTE)m_Opcode.sa != 0) { - ShiftRightSignImmed(GetMipsRegMapLo(m_Opcode.rd),(BYTE)m_Opcode.sa); - } - } else { - CRecompilerOps::UnknownOpcode(); - } - } else { - Map_GPR_32bit(m_Opcode.rd, true, -1); - MoveVariableToX86reg(&_GPR[m_Opcode.rt].UW[1],CRegName::GPR_Lo[m_Opcode.rt],GetMipsRegMapLo(m_Opcode.rd)); - if ((BYTE)m_Opcode.sa != 0) { - ShiftRightSignImmed(GetMipsRegMapLo(m_Opcode.rd),(BYTE)m_Opcode.sa); - } - } + if (IsConst(m_Opcode.rt)) + { + if (IsMapped(m_Opcode.rd)) + { + UnMap_GPR(m_Opcode.rd, false); + } + int64_t Value = Is64Bit(m_Opcode.rt) ? GetMipsReg_S(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt); + m_RegWorkingSet.SetMipsReg(m_Opcode.rd, Value >> m_Opcode.sa); + if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else if (GetMipsRegLo_S(m_Opcode.rd) >= 0 && GetMipsRegHi_S(m_Opcode.rd) == 0) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_64); + } + return; + } + Map_GPR_64bit(m_Opcode.rd, m_Opcode.rt); + ShiftRightDoubleImmed(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapHi(m_Opcode.rd), (uint8_t)m_Opcode.sa); + ShiftRightUnsignImmed(GetMipsRegMapHi(m_Opcode.rd), (uint8_t)m_Opcode.sa); +} + +void CRecompilerOps::SPECIAL_DSRA() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + if (m_Opcode.rd == 0) + { + return; + } + + if (IsConst(m_Opcode.rt)) + { + if (IsMapped(m_Opcode.rd)) + { + UnMap_GPR(m_Opcode.rd, false); + } + + int64_t Value = Is64Bit(m_Opcode.rt) ? GetMipsReg_S(m_Opcode.rt) : (int64_t)GetMipsRegLo_S(m_Opcode.rt); + m_RegWorkingSet.SetMipsReg_S(m_Opcode.rd, Value >> m_Opcode.sa); + if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else if (GetMipsRegLo_S(m_Opcode.rd) >= 0 && GetMipsRegHi_S(m_Opcode.rd) == 0) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_64); + } + return; + } + + Map_GPR_64bit(m_Opcode.rd, m_Opcode.rt); + ShiftRightDoubleImmed(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapHi(m_Opcode.rd), (uint8_t)m_Opcode.sa); + ShiftRightSignImmed(GetMipsRegMapHi(m_Opcode.rd), (uint8_t)m_Opcode.sa); +} + +void CRecompilerOps::SPECIAL_DSLL32() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + if (m_Opcode.rd == 0) + { + return; + } + + if (IsConst(m_Opcode.rt)) + { + if (m_Opcode.rt != m_Opcode.rd) + { + UnMap_GPR(m_Opcode.rd, false); + } + m_RegWorkingSet.SetMipsRegHi(m_Opcode.rd, GetMipsRegLo(m_Opcode.rt) << m_Opcode.sa); + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, 0); + if (GetMipsRegLo_S(m_Opcode.rd) < 0 && GetMipsRegHi_S(m_Opcode.rd) == -1) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else if (GetMipsRegLo_S(m_Opcode.rd) >= 0 && GetMipsRegHi_S(m_Opcode.rd) == 0) + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + } + else + { + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_64); + } + } + else if (IsMapped(m_Opcode.rt)) + { + ProtectGPR(m_Opcode.rt); + Map_GPR_64bit(m_Opcode.rd, -1); + if (m_Opcode.rt != m_Opcode.rd) + { + MoveX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rt), GetMipsRegMapHi(m_Opcode.rd)); + } + else + { + CPU_Message(" regcache: switch hi (%s) with lo (%s) for %s", x86_Name(GetMipsRegMapHi(m_Opcode.rt)), x86_Name(GetMipsRegMapLo(m_Opcode.rt)), CRegName::GPR[m_Opcode.rt]); + x86Reg HiReg = GetMipsRegMapHi(m_Opcode.rt); + m_RegWorkingSet.SetMipsRegMapHi(m_Opcode.rt, GetMipsRegMapLo(m_Opcode.rt)); + m_RegWorkingSet.SetMipsRegMapLo(m_Opcode.rt, HiReg); + } + if ((uint8_t)m_Opcode.sa != 0) + { + ShiftLeftSignImmed(GetMipsRegMapHi(m_Opcode.rd), (uint8_t)m_Opcode.sa); + } + XorX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rd)); + } + else + { + Map_GPR_64bit(m_Opcode.rd, -1); + MoveVariableToX86reg(&_GPR[m_Opcode.rt], CRegName::GPR_Hi[m_Opcode.rt], GetMipsRegMapHi(m_Opcode.rd)); + if ((uint8_t)m_Opcode.sa != 0) + { + ShiftLeftSignImmed(GetMipsRegMapHi(m_Opcode.rd), (uint8_t)m_Opcode.sa); + } + XorX86RegToX86Reg(GetMipsRegMapLo(m_Opcode.rd), GetMipsRegMapLo(m_Opcode.rd)); + } +} + +void CRecompilerOps::SPECIAL_DSRL32() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + if (IsConst(m_Opcode.rt)) + { + if (m_Opcode.rt != m_Opcode.rd) + { + UnMap_GPR(m_Opcode.rd, false); + } + + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_64); + m_RegWorkingSet.SetMipsReg(m_Opcode.rd, (uint32_t)(GetMipsRegHi(m_Opcode.rt) >> m_Opcode.sa)); + } + else if (IsMapped(m_Opcode.rt)) + { + ProtectGPR(m_Opcode.rt); + if (Is64Bit(m_Opcode.rt)) + { + if (m_Opcode.rt == m_Opcode.rd) + { + CPU_Message(" regcache: switch hi (%s) with lo (%s) for %s", x86_Name(GetMipsRegMapHi(m_Opcode.rt)), x86_Name(GetMipsRegMapLo(m_Opcode.rt)), CRegName::GPR[m_Opcode.rt]); + x86Reg HiReg = GetMipsRegMapHi(m_Opcode.rt); + m_RegWorkingSet.SetMipsRegMapHi(m_Opcode.rt, GetMipsRegMapLo(m_Opcode.rt)); + m_RegWorkingSet.SetMipsRegMapLo(m_Opcode.rt, HiReg); + Map_GPR_32bit(m_Opcode.rd, false, -1); + } + else + { + Map_GPR_32bit(m_Opcode.rd, false, -1); + MoveX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rt), GetMipsRegMapLo(m_Opcode.rd)); + } + if ((uint8_t)m_Opcode.sa != 0) + { + ShiftRightUnsignImmed(GetMipsRegMapLo(m_Opcode.rd), (uint8_t)m_Opcode.sa); + } + } + else + { + CRecompilerOps::UnknownOpcode(); + } + } + else { + Map_GPR_32bit(m_Opcode.rd, false, -1); + MoveVariableToX86reg(&_GPR[m_Opcode.rt].UW[1], CRegName::GPR_Hi[m_Opcode.rt], GetMipsRegMapLo(m_Opcode.rd)); + if ((uint8_t)m_Opcode.sa != 0) + { + ShiftRightUnsignImmed(GetMipsRegMapLo(m_Opcode.rd), (uint8_t)m_Opcode.sa); + } + } +} + +void CRecompilerOps::SPECIAL_DSRA32() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + if (IsConst(m_Opcode.rt)) + { + if (m_Opcode.rt != m_Opcode.rd) + { + UnMap_GPR(m_Opcode.rd, false); + } + + m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); + m_RegWorkingSet.SetMipsRegLo(m_Opcode.rd, (uint32_t)(GetMipsReg_S(m_Opcode.rt) >> (m_Opcode.sa + 32))); + } + else if (IsMapped(m_Opcode.rt)) + { + ProtectGPR(m_Opcode.rt); + if (Is64Bit(m_Opcode.rt)) + { + if (m_Opcode.rt == m_Opcode.rd) + { + CPU_Message(" regcache: switch hi (%s) with lo (%s) for %s", x86_Name(GetMipsRegMapHi(m_Opcode.rt)), x86_Name(GetMipsRegMapLo(m_Opcode.rt)), CRegName::GPR[m_Opcode.rt]); + x86Reg HiReg = GetMipsRegMapHi(m_Opcode.rt); + m_RegWorkingSet.SetMipsRegMapHi(m_Opcode.rt, GetMipsRegMapLo(m_Opcode.rt)); + m_RegWorkingSet.SetMipsRegMapLo(m_Opcode.rt, HiReg); + Map_GPR_32bit(m_Opcode.rd, true, -1); + } + else + { + Map_GPR_32bit(m_Opcode.rd, true, -1); + MoveX86RegToX86Reg(GetMipsRegMapHi(m_Opcode.rt), GetMipsRegMapLo(m_Opcode.rd)); + } + if ((uint8_t)m_Opcode.sa != 0) + { + ShiftRightSignImmed(GetMipsRegMapLo(m_Opcode.rd), (uint8_t)m_Opcode.sa); + } + } + else + { + CRecompilerOps::UnknownOpcode(); + } + } + else { + Map_GPR_32bit(m_Opcode.rd, true, -1); + MoveVariableToX86reg(&_GPR[m_Opcode.rt].UW[1], CRegName::GPR_Lo[m_Opcode.rt], GetMipsRegMapLo(m_Opcode.rd)); + if ((uint8_t)m_Opcode.sa != 0) + { + ShiftRightSignImmed(GetMipsRegMapLo(m_Opcode.rd), (uint8_t)m_Opcode.sa); + } + } } /************************** COP0 functions **************************/ -void CRecompilerOps::COP0_MF() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::COP0_MF() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - switch (m_Opcode.rd) { - case 9: //Count - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); - UpdateCounters(m_RegWorkingSet,false, true); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_SystemTimer,x86_ECX); - Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); - AfterCallDirect(m_RegWorkingSet); - } - Map_GPR_32bit(m_Opcode.rt, true, -1); - MoveVariableToX86reg(&_CP0[m_Opcode.rd],CRegName::Cop0[m_Opcode.rd],GetMipsRegMapLo(m_Opcode.rt)); + switch (m_Opcode.rd) + { + case 9: //Count + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); + UpdateCounters(m_RegWorkingSet, false, true); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_SystemTimer, x86_ECX); + Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); + AfterCallDirect(m_RegWorkingSet); + } + Map_GPR_32bit(m_Opcode.rt, true, -1); + MoveVariableToX86reg(&_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd], GetMipsRegMapLo(m_Opcode.rt)); } -void CRecompilerOps::COP0_MT() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::COP0_MT() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - BYTE *Jump; + uint8_t *Jump; - switch (m_Opcode.rd) { - case 0: //Index - case 2: //EntryLo0 - case 3: //EntryLo1 - case 4: //Context - case 5: //PageMask - case 10: //Entry Hi - case 14: //EPC - case 16: //Config - case 18: //WatchLo - case 19: //WatchHi - case 28: //Tag lo - case 29: //Tag Hi - case 30: //ErrEPC - if (IsConst(m_Opcode.rt)) { - MoveConstToVariable(GetMipsRegLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); - } else if (IsMapped(m_Opcode.rt)) { - MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); - } else { - MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rt, false), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); - } - if (m_Opcode.rd == 4) //Context - { - AndConstToVariable(0xFF800000,&_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); - } - break; - case 11: //Compare - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()) ; - UpdateCounters(m_RegWorkingSet,false, true); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()) ; - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_SystemTimer,x86_ECX); - Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); - AfterCallDirect(m_RegWorkingSet); - if (IsConst(m_Opcode.rt)) { - MoveConstToVariable(GetMipsRegLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); - } else if (IsMapped(m_Opcode.rt)) { - MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); - } else { - MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rt, false), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); - } - AndConstToVariable((DWORD)~CAUSE_IP7,&g_Reg->FAKE_CAUSE_REGISTER,"FAKE_CAUSE_REGISTER"); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_SystemTimer,x86_ECX); - Call_Direct(AddressOf(&CSystemTimer::UpdateCompareTimer), "CSystemTimer::UpdateCompareTimer"); - AfterCallDirect(m_RegWorkingSet); - break; - case 9: //Count - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()) ; - UpdateCounters(m_RegWorkingSet,false, true); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()) ; - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_SystemTimer,x86_ECX); - Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); - AfterCallDirect(m_RegWorkingSet); - if (IsConst(m_Opcode.rt)) { - MoveConstToVariable(GetMipsRegLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); - } else if (IsMapped(m_Opcode.rt)) { - MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); - } else { - MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rt, false), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); - } - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_SystemTimer,x86_ECX); - Call_Direct(AddressOf(&CSystemTimer::UpdateCompareTimer), "CSystemTimer::UpdateCompareTimer"); - AfterCallDirect(m_RegWorkingSet); - break; - case 12: //Status - { - x86Reg OldStatusReg = Map_TempReg(x86_Any, -1, false); - MoveVariableToX86reg(&_CP0[m_Opcode.rd],CRegName::Cop0[m_Opcode.rd],OldStatusReg); - if (IsConst(m_Opcode.rt)) { - MoveConstToVariable(GetMipsRegLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); - } else if (IsMapped(m_Opcode.rt)) { - MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); - } else { - MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rt, false), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); - } - XorVariableToX86reg(&_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd],OldStatusReg); - TestConstToX86Reg(STATUS_FR,OldStatusReg); - JeLabel8("FpuFlagFine",0); - Jump = m_RecompPos - 1; - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_Reg,x86_ECX); - Call_Direct(AddressOf(&CRegisters::FixFpuLocations),"CRegisters::FixFpuLocations"); + switch (m_Opcode.rd) + { + case 0: //Index + case 2: //EntryLo0 + case 3: //EntryLo1 + case 4: //Context + case 5: //PageMask + case 10: //Entry Hi + case 14: //EPC + case 16: //Config + case 18: //WatchLo + case 19: //WatchHi + case 28: //Tag lo + case 29: //Tag Hi + case 30: //ErrEPC + if (IsConst(m_Opcode.rt)) + { + MoveConstToVariable(GetMipsRegLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); + } + else if (IsMapped(m_Opcode.rt)) + { + MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); + } + else + { + MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rt, false), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); + } + if (m_Opcode.rd == 4) //Context + { + AndConstToVariable(0xFF800000, &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); + } + break; + case 11: //Compare + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); + UpdateCounters(m_RegWorkingSet, false, true); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_SystemTimer, x86_ECX); + Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); + AfterCallDirect(m_RegWorkingSet); + if (IsConst(m_Opcode.rt)) + { + MoveConstToVariable(GetMipsRegLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); + } + else if (IsMapped(m_Opcode.rt)) + { + MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); + } + else + { + MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rt, false), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); + } + AndConstToVariable((uint32_t)~CAUSE_IP7, &g_Reg->FAKE_CAUSE_REGISTER, "FAKE_CAUSE_REGISTER"); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_SystemTimer, x86_ECX); + Call_Direct(AddressOf(&CSystemTimer::UpdateCompareTimer), "CSystemTimer::UpdateCompareTimer"); + AfterCallDirect(m_RegWorkingSet); + break; + case 9: //Count + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); + UpdateCounters(m_RegWorkingSet, false, true); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_SystemTimer, x86_ECX); + Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); + AfterCallDirect(m_RegWorkingSet); + if (IsConst(m_Opcode.rt)) + { + MoveConstToVariable(GetMipsRegLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); + } + else if (IsMapped(m_Opcode.rt)) + { + MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); + } + else + { + MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rt, false), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); + } + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_SystemTimer, x86_ECX); + Call_Direct(AddressOf(&CSystemTimer::UpdateCompareTimer), "CSystemTimer::UpdateCompareTimer"); + AfterCallDirect(m_RegWorkingSet); + break; + case 12: //Status + { + x86Reg OldStatusReg = Map_TempReg(x86_Any, -1, false); + MoveVariableToX86reg(&_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd], OldStatusReg); + if (IsConst(m_Opcode.rt)) + { + MoveConstToVariable(GetMipsRegLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); + } + else if (IsMapped(m_Opcode.rt)) + { + MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); + } + else { + MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rt, false), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); + } + XorVariableToX86reg(&_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd], OldStatusReg); + TestConstToX86Reg(STATUS_FR, OldStatusReg); + JeLabel8("FpuFlagFine", 0); + Jump = m_RecompPos - 1; + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); + Call_Direct(AddressOf(&CRegisters::FixFpuLocations), "CRegisters::FixFpuLocations"); - AfterCallDirect(m_RegWorkingSet); - SetJump8(Jump,m_RecompPos); + AfterCallDirect(m_RegWorkingSet); + SetJump8(Jump, m_RecompPos); - //TestConstToX86Reg(STATUS_FR,OldStatusReg); - //BreakPoint(__FILEW__,__LINE__); //m_Section->CompileExit(m_CompilePC+4,m_RegWorkingSet,ExitResetRecompCode,false,JneLabel32); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_Reg,x86_ECX); - Call_Direct(AddressOf(&CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - AfterCallDirect(m_RegWorkingSet); - } - break; - case 6: //Wired - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); - UpdateCounters(m_RegWorkingSet,false, true); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); + //TestConstToX86Reg(STATUS_FR,OldStatusReg); + //BreakPoint(__FILEW__,__LINE__); //m_Section->CompileExit(m_CompilePC+4,m_RegWorkingSet,ExitResetRecompCode,false,JneLabel32); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); + Call_Direct(AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts"); + AfterCallDirect(m_RegWorkingSet); + } + break; + case 6: //Wired + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); + UpdateCounters(m_RegWorkingSet, false, true); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_SystemTimer,x86_ECX); - Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); - AfterCallDirect(m_RegWorkingSet); - if (IsConst(m_Opcode.rt)) { - MoveConstToVariable(GetMipsRegLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); - } else if (IsMapped(m_Opcode.rt)) { - MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); - } else { - MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rt, false), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); - } - break; - case 13: //cause - if (IsConst(m_Opcode.rt)) { - AndConstToVariable(0xFFFFCFF,&_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); - if ((GetMipsRegLo(m_Opcode.rt) & 0x300) != 0 && bHaveDebugger() ){ g_Notify->DisplayError(L"Set IP0 or IP1"); } - } else { - UnknownOpcode(); - return; - } - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_Reg,x86_ECX); - Call_Direct(AddressOf(&CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - AfterCallDirect(m_RegWorkingSet); - break; - default: - UnknownOpcode(); - } + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_SystemTimer, x86_ECX); + Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); + AfterCallDirect(m_RegWorkingSet); + if (IsConst(m_Opcode.rt)) + { + MoveConstToVariable(GetMipsRegLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); + } + else if (IsMapped(m_Opcode.rt)) + { + MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); + } + else + { + MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rt, false), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); + } + break; + case 13: //cause + if (IsConst(m_Opcode.rt)) + { + AndConstToVariable(0xFFFFCFF, &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); + if ((GetMipsRegLo(m_Opcode.rt) & 0x300) != 0 && bHaveDebugger()){ g_Notify->DisplayError(L"Set IP0 or IP1"); } + } + else + { + UnknownOpcode(); + return; + } + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_Reg, x86_ECX); + Call_Direct(AddressOf(&CRegisters::CheckInterrupts), "CRegisters::CheckInterrupts"); + AfterCallDirect(m_RegWorkingSet); + break; + default: + UnknownOpcode(); + } } /************************** COP0 CO functions ***********************/ -void CRecompilerOps::COP0_CO_TLBR( void) { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (!g_System->bUseTlb()) { return; } - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_TLB,x86_ECX); - Call_Direct(AddressOf(&CTLB::ReadEntry),"CTLB::ReadEntry"); - AfterCallDirect(m_RegWorkingSet); +void CRecompilerOps::COP0_CO_TLBR(void) +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (!g_System->bUseTlb()) { return; } + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_TLB, x86_ECX); + Call_Direct(AddressOf(&CTLB::ReadEntry), "CTLB::ReadEntry"); + AfterCallDirect(m_RegWorkingSet); } -void CRecompilerOps::COP0_CO_TLBWI( void) { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (!g_System->bUseTlb()) { return; } - BeforeCallDirect(m_RegWorkingSet); - PushImm32("FALSE", 0); - MoveVariableToX86reg(&g_Reg->INDEX_REGISTER,"INDEX_REGISTER",x86_ECX); - AndConstToX86Reg(x86_ECX,0x1F); - Push(x86_ECX); - MoveConstToX86reg((DWORD)g_TLB,x86_ECX); - Call_Direct(AddressOf(&CTLB::WriteEntry),"CTLB::WriteEntry"); - AfterCallDirect(m_RegWorkingSet); +void CRecompilerOps::COP0_CO_TLBWI(void) +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (!g_System->bUseTlb()) { return; } + BeforeCallDirect(m_RegWorkingSet); + PushImm32("FALSE", 0); + MoveVariableToX86reg(&g_Reg->INDEX_REGISTER, "INDEX_REGISTER", x86_ECX); + AndConstToX86Reg(x86_ECX, 0x1F); + Push(x86_ECX); + MoveConstToX86reg((uint32_t)g_TLB, x86_ECX); + Call_Direct(AddressOf(&CTLB::WriteEntry), "CTLB::WriteEntry"); + AfterCallDirect(m_RegWorkingSet); } -void CRecompilerOps::COP0_CO_TLBWR( void) { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (!g_System->bUseTlb()) { return; } +void CRecompilerOps::COP0_CO_TLBWR(void) +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + if (!g_System->bUseTlb()) { return; } - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()) ; - UpdateCounters(m_RegWorkingSet,false, true); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()) ; - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_SystemTimer,x86_ECX); - Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); + UpdateCounters(m_RegWorkingSet, false, true); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_SystemTimer, x86_ECX); + Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); - PushImm32("true",true); - MoveVariableToX86reg(&g_Reg->RANDOM_REGISTER,"RANDOM_REGISTER",x86_ECX); - AndConstToX86Reg(x86_ECX,0x1F); - Push(x86_ECX); - MoveConstToX86reg((DWORD)g_TLB,x86_ECX); - Call_Direct(AddressOf(&CTLB::WriteEntry),"CTLB::WriteEntry"); - AfterCallDirect(m_RegWorkingSet); + PushImm32("true", true); + MoveVariableToX86reg(&g_Reg->RANDOM_REGISTER, "RANDOM_REGISTER", x86_ECX); + AndConstToX86Reg(x86_ECX, 0x1F); + Push(x86_ECX); + MoveConstToX86reg((uint32_t)g_TLB, x86_ECX); + Call_Direct(AddressOf(&CTLB::WriteEntry), "CTLB::WriteEntry"); + AfterCallDirect(m_RegWorkingSet); } -void CRecompilerOps::COP0_CO_TLBP( void) { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - if (!g_System->bUseTlb()) { return; } - BeforeCallDirect(m_RegWorkingSet); - MoveConstToX86reg((DWORD)g_TLB,x86_ECX); - Call_Direct(AddressOf(&CTLB::Probe), "CTLB::TLB_Probe"); - AfterCallDirect(m_RegWorkingSet); +void CRecompilerOps::COP0_CO_TLBP(void) +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + if (!g_System->bUseTlb()) { return; } + BeforeCallDirect(m_RegWorkingSet); + MoveConstToX86reg((uint32_t)g_TLB, x86_ECX); + Call_Direct(AddressOf(&CTLB::Probe), "CTLB::TLB_Probe"); + AfterCallDirect(m_RegWorkingSet); } -void compiler_COP0_CO_ERET() { - if ((g_Reg->STATUS_REGISTER & STATUS_ERL) != 0) { - g_Reg->m_PROGRAM_COUNTER = g_Reg->ERROREPC_REGISTER; - g_Reg->STATUS_REGISTER &= ~STATUS_ERL; - } else { - g_Reg->m_PROGRAM_COUNTER = g_Reg->EPC_REGISTER; - g_Reg->STATUS_REGISTER &= ~STATUS_EXL; - } - g_Reg->m_LLBit = 0; - g_Reg->CheckInterrupts(); +void compiler_COP0_CO_ERET() +{ + if ((g_Reg->STATUS_REGISTER & STATUS_ERL) != 0) { + g_Reg->m_PROGRAM_COUNTER = g_Reg->ERROREPC_REGISTER; + g_Reg->STATUS_REGISTER &= ~STATUS_ERL; + } + else + { + g_Reg->m_PROGRAM_COUNTER = g_Reg->EPC_REGISTER; + g_Reg->STATUS_REGISTER &= ~STATUS_EXL; + } + g_Reg->m_LLBit = 0; + g_Reg->CheckInterrupts(); } -void CRecompilerOps::COP0_CO_ERET( void) { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::COP0_CO_ERET(void) +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - m_RegWorkingSet.WriteBackRegisters(); - Call_Direct(compiler_COP0_CO_ERET,"compiler_COP0_CO_ERET"); + m_RegWorkingSet.WriteBackRegisters(); + Call_Direct(compiler_COP0_CO_ERET, "compiler_COP0_CO_ERET"); - UpdateCounters(m_RegWorkingSet,true,true); - m_Section->CompileExit(m_CompilePC, (DWORD)-1, m_RegWorkingSet, CExitInfo::Normal, true, NULL); - m_NextInstruction = END_BLOCK; + UpdateCounters(m_RegWorkingSet, true, true); + m_Section->CompileExit(m_CompilePC, (uint32_t)-1, m_RegWorkingSet, CExitInfo::Normal, true, NULL); + m_NextInstruction = END_BLOCK; } /************************** FPU Options **************************/ -void CRecompilerOps::ChangeDefaultRoundingModel() { - switch((_FPCR[31] & 3)) { - case 0: *_RoundingModel = ROUND_NEAR; break; - case 1: *_RoundingModel = ROUND_CHOP; break; - case 2: *_RoundingModel = ROUND_UP; break; - case 3: *_RoundingModel = ROUND_DOWN; break; - } +void CRecompilerOps::ChangeDefaultRoundingModel() +{ + switch ((_FPCR[31] & 3)) { + case 0: *_RoundingModel = ROUND_NEAR; break; + case 1: *_RoundingModel = ROUND_CHOP; break; + case 2: *_RoundingModel = ROUND_UP; break; + case 3: *_RoundingModel = ROUND_DOWN; break; + } } /************************** COP1 functions **************************/ -void CRecompilerOps::COP1_MF() { - x86Reg TempReg; +void CRecompilerOps::COP1_MF() +{ + x86Reg TempReg; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - m_Section->CompileCop1Test(); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + m_Section->CompileCop1Test(); - UnMap_FPR(m_Opcode.fs, true); - Map_GPR_32bit(m_Opcode.rt, true, -1); - TempReg = Map_TempReg(x86_Any, -1, false); - char Name[100]; - sprintf(Name,"_FPR_S[%d]",m_Opcode.fs); - MoveVariableToX86reg((BYTE *)&_FPR_S[m_Opcode.fs],Name,TempReg); - MoveX86PointerToX86reg(GetMipsRegMapLo(m_Opcode.rt),TempReg); + UnMap_FPR(m_Opcode.fs, true); + Map_GPR_32bit(m_Opcode.rt, true, -1); + TempReg = Map_TempReg(x86_Any, -1, false); + char Name[100]; + sprintf(Name, "_FPR_S[%d]", m_Opcode.fs); + MoveVariableToX86reg((uint8_t *)&_FPR_S[m_Opcode.fs], Name, TempReg); + MoveX86PointerToX86reg(GetMipsRegMapLo(m_Opcode.rt), TempReg); } -void CRecompilerOps::COP1_DMF() { - x86Reg TempReg; - char Name[50]; +void CRecompilerOps::COP1_DMF() +{ + x86Reg TempReg; + char Name[50]; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - m_Section->CompileCop1Test(); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + m_Section->CompileCop1Test(); - UnMap_FPR(m_Opcode.fs, true); - Map_GPR_64bit(m_Opcode.rt, -1); - TempReg = Map_TempReg(x86_Any, -1, false); - sprintf(Name,"_FPR_D[%d]",m_Opcode.fs); - MoveVariableToX86reg((BYTE *)&_FPR_D[m_Opcode.fs],Name,TempReg); - AddConstToX86Reg(TempReg,4); - MoveX86PointerToX86reg(GetMipsRegMapHi(m_Opcode.rt),TempReg); - sprintf(Name,"_FPR_D[%d]",m_Opcode.fs); - MoveVariableToX86reg((BYTE *)&_FPR_D[m_Opcode.fs],Name,TempReg); - MoveX86PointerToX86reg(GetMipsRegMapLo(m_Opcode.rt),TempReg); + UnMap_FPR(m_Opcode.fs, true); + Map_GPR_64bit(m_Opcode.rt, -1); + TempReg = Map_TempReg(x86_Any, -1, false); + sprintf(Name, "_FPR_D[%d]", m_Opcode.fs); + MoveVariableToX86reg((uint8_t *)&_FPR_D[m_Opcode.fs], Name, TempReg); + AddConstToX86Reg(TempReg, 4); + MoveX86PointerToX86reg(GetMipsRegMapHi(m_Opcode.rt), TempReg); + sprintf(Name, "_FPR_D[%d]", m_Opcode.fs); + MoveVariableToX86reg((uint8_t *)&_FPR_D[m_Opcode.fs], Name, TempReg); + MoveX86PointerToX86reg(GetMipsRegMapLo(m_Opcode.rt), TempReg); } -void CRecompilerOps::COP1_CF() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::COP1_CF() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - m_Section->CompileCop1Test(); - - if (m_Opcode.fs != 31 && m_Opcode.fs != 0) - { - UnknownOpcode(); - return; - } + m_Section->CompileCop1Test(); - Map_GPR_32bit(m_Opcode.rt, true, -1); - MoveVariableToX86reg(&_FPCR[m_Opcode.fs],CRegName::FPR_Ctrl[m_Opcode.fs],GetMipsRegMapLo(m_Opcode.rt)); + if (m_Opcode.fs != 31 && m_Opcode.fs != 0) + { + UnknownOpcode(); + return; + } + + Map_GPR_32bit(m_Opcode.rt, true, -1); + MoveVariableToX86reg(&_FPCR[m_Opcode.fs], CRegName::FPR_Ctrl[m_Opcode.fs], GetMipsRegMapLo(m_Opcode.rt)); } -void CRecompilerOps::COP1_MT() { - x86Reg TempReg; +void CRecompilerOps::COP1_MT() +{ + x86Reg TempReg; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - m_Section->CompileCop1Test(); - - if ((m_Opcode.fs & 1) != 0) { - if (RegInStack(m_Opcode.fs-1,CRegInfo::FPU_Double) || RegInStack(m_Opcode.fs-1,CRegInfo::FPU_Qword)) { - UnMap_FPR(m_Opcode.fs - 1, true); - } - } - UnMap_FPR(m_Opcode.fs, true); - TempReg = Map_TempReg(x86_Any, -1, false); - char Name[50]; - sprintf(Name,"_FPR_S[%d]",m_Opcode.fs); - MoveVariableToX86reg((BYTE *)&_FPR_S[m_Opcode.fs],Name,TempReg); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + m_Section->CompileCop1Test(); - if (IsConst(m_Opcode.rt)) { - MoveConstToX86Pointer(GetMipsRegLo(m_Opcode.rt),TempReg); - } else if (IsMapped(m_Opcode.rt)) { - MoveX86regToX86Pointer(GetMipsRegMapLo(m_Opcode.rt),TempReg); - } else { - MoveX86regToX86Pointer(Map_TempReg(x86_Any, m_Opcode.rt, false), TempReg); - } + if ((m_Opcode.fs & 1) != 0) + { + if (RegInStack(m_Opcode.fs - 1, CRegInfo::FPU_Double) || RegInStack(m_Opcode.fs - 1, CRegInfo::FPU_Qword)) + { + UnMap_FPR(m_Opcode.fs - 1, true); + } + } + UnMap_FPR(m_Opcode.fs, true); + TempReg = Map_TempReg(x86_Any, -1, false); + char Name[50]; + sprintf(Name, "_FPR_S[%d]", m_Opcode.fs); + MoveVariableToX86reg((uint8_t *)&_FPR_S[m_Opcode.fs], Name, TempReg); + + if (IsConst(m_Opcode.rt)) + { + MoveConstToX86Pointer(GetMipsRegLo(m_Opcode.rt), TempReg); + } + else if (IsMapped(m_Opcode.rt)) + { + MoveX86regToX86Pointer(GetMipsRegMapLo(m_Opcode.rt), TempReg); + } + else + { + MoveX86regToX86Pointer(Map_TempReg(x86_Any, m_Opcode.rt, false), TempReg); + } } -void CRecompilerOps::COP1_DMT() { - x86Reg TempReg; +void CRecompilerOps::COP1_DMT() +{ + x86Reg TempReg; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - m_Section->CompileCop1Test(); - - if ((m_Opcode.fs & 1) == 0) { - if (RegInStack(m_Opcode.fs+1,CRegInfo::FPU_Float) || RegInStack(m_Opcode.fs+1,CRegInfo::FPU_Dword)) { - UnMap_FPR(m_Opcode.fs+1, true); - } - } - UnMap_FPR(m_Opcode.fs, true); - TempReg = Map_TempReg(x86_Any, -1, false); - char Name[50]; - sprintf(Name,"_FPR_D[%d]",m_Opcode.fs); - MoveVariableToX86reg((BYTE *)&_FPR_D[m_Opcode.fs],Name,TempReg); - - if (IsConst(m_Opcode.rt)) { - MoveConstToX86Pointer(GetMipsRegLo(m_Opcode.rt),TempReg); - AddConstToX86Reg(TempReg,4); - if (Is64Bit(m_Opcode.rt)) { - MoveConstToX86Pointer(GetMipsRegHi(m_Opcode.rt),TempReg); - } else { - MoveConstToX86Pointer(GetMipsRegLo_S(m_Opcode.rt) >> 31,TempReg); - } - } else if (IsMapped(m_Opcode.rt)) { - MoveX86regToX86Pointer(GetMipsRegMapLo(m_Opcode.rt),TempReg); - AddConstToX86Reg(TempReg,4); - if (Is64Bit(m_Opcode.rt)) { - MoveX86regToX86Pointer(GetMipsRegMapHi(m_Opcode.rt),TempReg); - } else { - MoveX86regToX86Pointer(Map_TempReg(x86_Any, m_Opcode.rt, true), TempReg); - } - } else { - x86Reg Reg = Map_TempReg(x86_Any, m_Opcode.rt, false); - MoveX86regToX86Pointer(Reg,TempReg); - AddConstToX86Reg(TempReg,4); - MoveX86regToX86Pointer(Map_TempReg(Reg, m_Opcode.rt, true), TempReg); - } + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + m_Section->CompileCop1Test(); + + if ((m_Opcode.fs & 1) == 0) + { + if (RegInStack(m_Opcode.fs + 1, CRegInfo::FPU_Float) || RegInStack(m_Opcode.fs + 1, CRegInfo::FPU_Dword)) { + UnMap_FPR(m_Opcode.fs + 1, true); + } + } + UnMap_FPR(m_Opcode.fs, true); + TempReg = Map_TempReg(x86_Any, -1, false); + char Name[50]; + sprintf(Name, "_FPR_D[%d]", m_Opcode.fs); + MoveVariableToX86reg((uint8_t *)&_FPR_D[m_Opcode.fs], Name, TempReg); + + if (IsConst(m_Opcode.rt)) + { + MoveConstToX86Pointer(GetMipsRegLo(m_Opcode.rt), TempReg); + AddConstToX86Reg(TempReg, 4); + if (Is64Bit(m_Opcode.rt)) + { + MoveConstToX86Pointer(GetMipsRegHi(m_Opcode.rt), TempReg); + } + else + { + MoveConstToX86Pointer(GetMipsRegLo_S(m_Opcode.rt) >> 31, TempReg); + } + } + else if (IsMapped(m_Opcode.rt)) + { + MoveX86regToX86Pointer(GetMipsRegMapLo(m_Opcode.rt), TempReg); + AddConstToX86Reg(TempReg, 4); + if (Is64Bit(m_Opcode.rt)) + { + MoveX86regToX86Pointer(GetMipsRegMapHi(m_Opcode.rt), TempReg); + } + else + { + MoveX86regToX86Pointer(Map_TempReg(x86_Any, m_Opcode.rt, true), TempReg); + } + } + else + { + x86Reg Reg = Map_TempReg(x86_Any, m_Opcode.rt, false); + MoveX86regToX86Pointer(Reg, TempReg); + AddConstToX86Reg(TempReg, 4); + MoveX86regToX86Pointer(Map_TempReg(Reg, m_Opcode.rt, true), TempReg); + } } +void CRecompilerOps::COP1_CT() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + m_Section->CompileCop1Test(); -void CRecompilerOps::COP1_CT() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - m_Section->CompileCop1Test(); + if (m_Opcode.fs != 31) + { + UnknownOpcode(); + return; + } - if (m_Opcode.fs != 31) { - UnknownOpcode(); - return; - } - - if (IsConst(m_Opcode.rt)) { - MoveConstToVariable(GetMipsRegLo(m_Opcode.rt),&_FPCR[m_Opcode.fs],CRegName::FPR_Ctrl[m_Opcode.fs]); - } else if (IsMapped(m_Opcode.rt)) { - MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rt),&_FPCR[m_Opcode.fs],CRegName::FPR_Ctrl[m_Opcode.fs]); - } else { - MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rt, false), &_FPCR[m_Opcode.fs], CRegName::FPR_Ctrl[m_Opcode.fs]); - } - BeforeCallDirect(m_RegWorkingSet); - Call_Direct(ChangeDefaultRoundingModel, "ChangeDefaultRoundingModel"); - AfterCallDirect(m_RegWorkingSet); - m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown); + if (IsConst(m_Opcode.rt)) + { + MoveConstToVariable(GetMipsRegLo(m_Opcode.rt), &_FPCR[m_Opcode.fs], CRegName::FPR_Ctrl[m_Opcode.fs]); + } + else if (IsMapped(m_Opcode.rt)) + { + MoveX86regToVariable(GetMipsRegMapLo(m_Opcode.rt), &_FPCR[m_Opcode.fs], CRegName::FPR_Ctrl[m_Opcode.fs]); + } + else + { + MoveX86regToVariable(Map_TempReg(x86_Any, m_Opcode.rt, false), &_FPCR[m_Opcode.fs], CRegName::FPR_Ctrl[m_Opcode.fs]); + } + BeforeCallDirect(m_RegWorkingSet); + Call_Direct(ChangeDefaultRoundingModel, "ChangeDefaultRoundingModel"); + AfterCallDirect(m_RegWorkingSet); + m_RegWorkingSet.SetRoundingModel(CRegInfo::RoundUnknown); } /************************** COP1: S functions ************************/ -void CRecompilerOps::COP1_S_ADD() { - DWORD Reg1 = m_Opcode.ft == m_Opcode.fd?m_Opcode.ft:m_Opcode.fs; - DWORD Reg2 = m_Opcode.ft == m_Opcode.fd?m_Opcode.fs:m_Opcode.ft; - - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - FixRoundModel(CRegInfo::RoundDefault); - - Load_FPR_ToTop(m_Opcode.fd,Reg1, CRegInfo::FPU_Float); - if (RegInStack(Reg2, CRegInfo::FPU_Float)) { - fpuAddReg(StackPosition(Reg2)); - } else { - x86Reg TempReg; - - UnMap_FPR(Reg2, true); - TempReg = Map_TempReg(x86_Any, -1, false); - char Name[50]; - sprintf(Name,"_FPR_S[%d]",Reg2); - MoveVariableToX86reg((BYTE *)&_FPR_S[Reg2],Name,TempReg); - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fd, CRegInfo::FPU_Float); - fpuAddDwordRegPointer(TempReg); - } - UnMap_FPR(m_Opcode.fd, true); -} - -void CRecompilerOps::COP1_S_SUB() { - DWORD Reg1 = m_Opcode.ft == m_Opcode.fd?m_Opcode.ft:m_Opcode.fs; - DWORD Reg2 = m_Opcode.ft == m_Opcode.fd?m_Opcode.fs:m_Opcode.ft; - x86Reg TempReg; - char Name[50]; - - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - FixRoundModel(CRegInfo::RoundDefault); - - if (m_Opcode.fd == m_Opcode.ft) { - UnMap_FPR(m_Opcode.fd, true); - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float); - - TempReg = Map_TempReg(x86_Any, -1, false); - sprintf(Name,"_FPR_S[%d]",m_Opcode.ft); - MoveVariableToX86reg((BYTE *)&_FPR_S[m_Opcode.ft],Name,TempReg); - fpuSubDwordRegPointer(TempReg); - } else { - Load_FPR_ToTop(m_Opcode.fd,Reg1, CRegInfo::FPU_Float); - if (RegInStack(Reg2, CRegInfo::FPU_Float)) { - fpuSubReg(StackPosition(Reg2)); - } else { - UnMap_FPR(Reg2, true); - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fd, CRegInfo::FPU_Float); - - TempReg = Map_TempReg(x86_Any, -1, false); - sprintf(Name,"_FPR_S[%d]",Reg2); - MoveVariableToX86reg((BYTE *)&_FPR_S[Reg2],Name,TempReg); - fpuSubDwordRegPointer(TempReg); - } - } - UnMap_FPR(m_Opcode.fd, true); -} - -void CRecompilerOps::COP1_S_MUL() { - DWORD Reg1 = m_Opcode.ft == m_Opcode.fd?m_Opcode.ft:m_Opcode.fs; - DWORD Reg2 = m_Opcode.ft == m_Opcode.fd?m_Opcode.fs:m_Opcode.ft; - x86Reg TempReg; - - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - FixRoundModel(CRegInfo::RoundDefault); - - Load_FPR_ToTop(m_Opcode.fd,Reg1, CRegInfo::FPU_Float); - if (RegInStack(Reg2, CRegInfo::FPU_Float)) { - fpuMulReg(StackPosition(Reg2)); - } else { - UnMap_FPR(Reg2, true); - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fd, CRegInfo::FPU_Float); - - TempReg = Map_TempReg(x86_Any, -1, false); - char Name[50]; - sprintf(Name,"_FPR_S[%d]",Reg2); - MoveVariableToX86reg((BYTE *)&_FPR_S[Reg2],Name,TempReg); - fpuMulDwordRegPointer(TempReg); - } - UnMap_FPR(m_Opcode.fd, true); -} - -void CRecompilerOps::COP1_S_DIV() { - DWORD Reg1 = m_Opcode.ft == m_Opcode.fd?m_Opcode.ft:m_Opcode.fs; - DWORD Reg2 = m_Opcode.ft == m_Opcode.fd?m_Opcode.fs:m_Opcode.ft; - x86Reg TempReg; - char Name[50]; - - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - FixRoundModel(CRegInfo::RoundDefault); - - if (m_Opcode.fd == m_Opcode.ft) { - UnMap_FPR(m_Opcode.fd, true); - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float); - - TempReg = Map_TempReg(x86_Any, -1, false); - sprintf(Name,"_FPR_S[%d]",m_Opcode.ft); - MoveVariableToX86reg((BYTE *)&_FPR_S[m_Opcode.ft],Name,TempReg); - fpuDivDwordRegPointer(TempReg); - } else { - Load_FPR_ToTop(m_Opcode.fd,Reg1, CRegInfo::FPU_Float); - if (RegInStack(Reg2, CRegInfo::FPU_Float)) { - fpuDivReg(StackPosition(Reg2)); - } else { - UnMap_FPR(Reg2, true); - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fd, CRegInfo::FPU_Float); - - TempReg = Map_TempReg(x86_Any, -1, false); - sprintf(Name,"_FPR_S[%d]",Reg2); - MoveVariableToX86reg((BYTE *)&_FPR_S[Reg2],Name,TempReg); - fpuDivDwordRegPointer(TempReg); - } - } - - UnMap_FPR(m_Opcode.fd, true); -} - -void CRecompilerOps::COP1_S_ABS() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - m_Section->CompileCop1Test(); - FixRoundModel(CRegInfo::RoundDefault); - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float); - fpuAbs(); - UnMap_FPR(m_Opcode.fd, true); -} - -void CRecompilerOps::COP1_S_NEG() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - m_Section->CompileCop1Test(); - FixRoundModel(CRegInfo::RoundDefault); - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float); - fpuNeg(); - UnMap_FPR(m_Opcode.fd, true); -} - -void CRecompilerOps::COP1_S_SQRT() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - m_Section->CompileCop1Test(); - FixRoundModel(CRegInfo::RoundDefault); - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float); - fpuSqrt(); - UnMap_FPR(m_Opcode.fd, true); -} - -void CRecompilerOps::COP1_S_MOV() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - m_Section->CompileCop1Test(); - FixRoundModel(CRegInfo::RoundDefault); - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float); -} - -void CRecompilerOps::COP1_S_TRUNC_L() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Float)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Float,CRegInfo::FPU_Qword,CRegInfo::RoundTruncate); -} - -void CRecompilerOps::COP1_S_CEIL_L() { //added by Witten - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Float)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Float,CRegInfo::FPU_Qword,CRegInfo::RoundUp); -} - -void CRecompilerOps::COP1_S_FLOOR_L() { //added by Witten - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Float)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Float,CRegInfo::FPU_Qword,CRegInfo::RoundDown); -} - -void CRecompilerOps::COP1_S_ROUND_W() +void CRecompilerOps::COP1_S_ADD() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Float)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Float,CRegInfo::FPU_Dword,CRegInfo::RoundNearest); + uint32_t Reg1 = m_Opcode.ft == m_Opcode.fd ? m_Opcode.ft : m_Opcode.fs; + uint32_t Reg2 = m_Opcode.ft == m_Opcode.fd ? m_Opcode.fs : m_Opcode.ft; + + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + FixRoundModel(CRegInfo::RoundDefault); + + Load_FPR_ToTop(m_Opcode.fd, Reg1, CRegInfo::FPU_Float); + if (RegInStack(Reg2, CRegInfo::FPU_Float)) + { + fpuAddReg(StackPosition(Reg2)); + } + else + { + x86Reg TempReg; + + UnMap_FPR(Reg2, true); + TempReg = Map_TempReg(x86_Any, -1, false); + char Name[50]; + sprintf(Name, "_FPR_S[%d]", Reg2); + MoveVariableToX86reg((uint8_t *)&_FPR_S[Reg2], Name, TempReg); + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fd, CRegInfo::FPU_Float); + fpuAddDwordRegPointer(TempReg); + } + UnMap_FPR(m_Opcode.fd, true); } -void CRecompilerOps::COP1_S_TRUNC_W() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Float)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Float,CRegInfo::FPU_Dword,CRegInfo::RoundTruncate); -} - -void CRecompilerOps::COP1_S_CEIL_W() { // added by Witten - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Float)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Float,CRegInfo::FPU_Dword,CRegInfo::RoundUp); -} - -void CRecompilerOps::COP1_S_FLOOR_W() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Float)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Float,CRegInfo::FPU_Dword,CRegInfo::RoundDown); -} - -void CRecompilerOps::COP1_S_CVT_D() +void CRecompilerOps::COP1_S_SUB() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Float)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Float,CRegInfo::FPU_Double,CRegInfo::RoundDefault); + uint32_t Reg1 = m_Opcode.ft == m_Opcode.fd ? m_Opcode.ft : m_Opcode.fs; + uint32_t Reg2 = m_Opcode.ft == m_Opcode.fd ? m_Opcode.fs : m_Opcode.ft; + x86Reg TempReg; + char Name[50]; + + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + FixRoundModel(CRegInfo::RoundDefault); + + if (m_Opcode.fd == m_Opcode.ft) + { + UnMap_FPR(m_Opcode.fd, true); + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Float); + + TempReg = Map_TempReg(x86_Any, -1, false); + sprintf(Name, "_FPR_S[%d]", m_Opcode.ft); + MoveVariableToX86reg((uint8_t *)&_FPR_S[m_Opcode.ft], Name, TempReg); + fpuSubDwordRegPointer(TempReg); + } + else + { + Load_FPR_ToTop(m_Opcode.fd, Reg1, CRegInfo::FPU_Float); + if (RegInStack(Reg2, CRegInfo::FPU_Float)) + { + fpuSubReg(StackPosition(Reg2)); + } + else + { + UnMap_FPR(Reg2, true); + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fd, CRegInfo::FPU_Float); + + TempReg = Map_TempReg(x86_Any, -1, false); + sprintf(Name, "_FPR_S[%d]", Reg2); + MoveVariableToX86reg((uint8_t *)&_FPR_S[Reg2], Name, TempReg); + fpuSubDwordRegPointer(TempReg); + } + } + UnMap_FPR(m_Opcode.fd, true); } -void CRecompilerOps::COP1_S_CVT_W() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Float)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Float,CRegInfo::FPU_Dword,CRegInfo::RoundDefault); +void CRecompilerOps::COP1_S_MUL() +{ + uint32_t Reg1 = m_Opcode.ft == m_Opcode.fd ? m_Opcode.ft : m_Opcode.fs; + uint32_t Reg2 = m_Opcode.ft == m_Opcode.fd ? m_Opcode.fs : m_Opcode.ft; + x86Reg TempReg; + + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + FixRoundModel(CRegInfo::RoundDefault); + + Load_FPR_ToTop(m_Opcode.fd, Reg1, CRegInfo::FPU_Float); + if (RegInStack(Reg2, CRegInfo::FPU_Float)) + { + fpuMulReg(StackPosition(Reg2)); + } + else + { + UnMap_FPR(Reg2, true); + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fd, CRegInfo::FPU_Float); + + TempReg = Map_TempReg(x86_Any, -1, false); + char Name[50]; + sprintf(Name, "_FPR_S[%d]", Reg2); + MoveVariableToX86reg((uint8_t *)&_FPR_S[Reg2], Name, TempReg); + fpuMulDwordRegPointer(TempReg); + } + UnMap_FPR(m_Opcode.fd, true); } -void CRecompilerOps::COP1_S_CVT_L() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Float)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Float,CRegInfo::FPU_Qword,CRegInfo::RoundDefault); +void CRecompilerOps::COP1_S_DIV() +{ + uint32_t Reg1 = m_Opcode.ft == m_Opcode.fd ? m_Opcode.ft : m_Opcode.fs; + uint32_t Reg2 = m_Opcode.ft == m_Opcode.fd ? m_Opcode.fs : m_Opcode.ft; + x86Reg TempReg; + char Name[50]; + + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + FixRoundModel(CRegInfo::RoundDefault); + + if (m_Opcode.fd == m_Opcode.ft) + { + UnMap_FPR(m_Opcode.fd, true); + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Float); + + TempReg = Map_TempReg(x86_Any, -1, false); + sprintf(Name, "_FPR_S[%d]", m_Opcode.ft); + MoveVariableToX86reg((uint8_t *)&_FPR_S[m_Opcode.ft], Name, TempReg); + fpuDivDwordRegPointer(TempReg); + } + else + { + Load_FPR_ToTop(m_Opcode.fd, Reg1, CRegInfo::FPU_Float); + if (RegInStack(Reg2, CRegInfo::FPU_Float)) + { + fpuDivReg(StackPosition(Reg2)); + } + else + { + UnMap_FPR(Reg2, true); + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fd, CRegInfo::FPU_Float); + + TempReg = Map_TempReg(x86_Any, -1, false); + sprintf(Name, "_FPR_S[%d]", Reg2); + MoveVariableToX86reg((uint8_t *)&_FPR_S[Reg2], Name, TempReg); + fpuDivDwordRegPointer(TempReg); + } + } + + UnMap_FPR(m_Opcode.fd, true); } -void CRecompilerOps::COP1_S_CMP() { - DWORD Reg1 = m_Opcode.fs; - DWORD Reg2 = m_Opcode.ft; - DWORD cmp = 0; +void CRecompilerOps::COP1_S_ABS() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + m_Section->CompileCop1Test(); + FixRoundModel(CRegInfo::RoundDefault); + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Float); + fpuAbs(); + UnMap_FPR(m_Opcode.fd, true); +} - if ((m_Opcode.funct & 4) == 0) - { - Reg1 = RegInStack(m_Opcode.ft, CRegInfo::FPU_Float)?m_Opcode.ft:m_Opcode.fs; - Reg2 = RegInStack(m_Opcode.ft, CRegInfo::FPU_Float)?m_Opcode.fs:m_Opcode.ft; - } - - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if ((m_Opcode.funct & 7) == 0) { CRecompilerOps::UnknownOpcode(); } - if ((m_Opcode.funct & 2) != 0) { cmp |= 0x4000; } - if ((m_Opcode.funct & 4) != 0) { cmp |= 0x0100; } - - Load_FPR_ToTop(Reg1,Reg1, CRegInfo::FPU_Float); - Map_TempReg(x86_EAX, 0, false); - if (RegInStack(Reg2, CRegInfo::FPU_Float)) { - fpuComReg(StackPosition(Reg2), false); - } else { - UnMap_FPR(Reg2, true); - Load_FPR_ToTop(Reg1,Reg1, CRegInfo::FPU_Float); +void CRecompilerOps::COP1_S_NEG() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + m_Section->CompileCop1Test(); + FixRoundModel(CRegInfo::RoundDefault); + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Float); + fpuNeg(); + UnMap_FPR(m_Opcode.fd, true); +} - x86Reg TempReg = Map_TempReg(x86_Any, -1, false); - char Name[50]; - sprintf(Name,"_FPR_S[%d]",Reg2); - MoveVariableToX86reg((BYTE *)&_FPR_S[Reg2],Name,TempReg); - fpuComDwordRegPointer(TempReg, false); - } - AndConstToVariable((DWORD)~FPCSR_C, &_FPCR[31], "_FPCR[31]"); - fpuStoreStatus(); - x86Reg Reg = Map_TempReg(x86_Any8Bit, 0, false); - TestConstToX86Reg(cmp,x86_EAX); - Setnz(Reg); - - if (cmp != 0) { - TestConstToX86Reg(cmp,x86_EAX); - Setnz(Reg); - - if ((m_Opcode.funct & 1) != 0) { - x86Reg Reg2 = Map_TempReg(x86_Any8Bit, 0, false); - AndConstToX86Reg(x86_EAX, 0x4300); - CompConstToX86reg(x86_EAX, 0x4300); - Setz(Reg2); - - OrX86RegToX86Reg(Reg, Reg2); - } - } else if ((m_Opcode.funct & 1) != 0) { - AndConstToX86Reg(x86_EAX, 0x4300); - CompConstToX86reg(x86_EAX, 0x4300); - Setz(Reg); - } - ShiftLeftSignImmed(Reg, 23); - OrX86RegToVariable(&_FPCR[31], "_FPCR[31]", Reg); +void CRecompilerOps::COP1_S_SQRT() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + m_Section->CompileCop1Test(); + FixRoundModel(CRegInfo::RoundDefault); + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Float); + fpuSqrt(); + UnMap_FPR(m_Opcode.fd, true); +} + +void CRecompilerOps::COP1_S_MOV() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + m_Section->CompileCop1Test(); + FixRoundModel(CRegInfo::RoundDefault); + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Float); +} + +void CRecompilerOps::COP1_S_TRUNC_L() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Float)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Float); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Float, CRegInfo::FPU_Qword, CRegInfo::RoundTruncate); +} + +void CRecompilerOps::COP1_S_CEIL_L() //added by Witten +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Float)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Float); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Float, CRegInfo::FPU_Qword, CRegInfo::RoundUp); +} + +void CRecompilerOps::COP1_S_FLOOR_L() //added by Witten +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Float)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Float); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Float, CRegInfo::FPU_Qword, CRegInfo::RoundDown); +} + +void CRecompilerOps::COP1_S_ROUND_W() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Float)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Float); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Float, CRegInfo::FPU_Dword, CRegInfo::RoundNearest); +} + +void CRecompilerOps::COP1_S_TRUNC_W() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Float)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Float); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Float, CRegInfo::FPU_Dword, CRegInfo::RoundTruncate); +} + +void CRecompilerOps::COP1_S_CEIL_W() // added by Witten +{ // added by Witten + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Float)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Float); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Float, CRegInfo::FPU_Dword, CRegInfo::RoundUp); +} + +void CRecompilerOps::COP1_S_FLOOR_W() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Float)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Float); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Float, CRegInfo::FPU_Dword, CRegInfo::RoundDown); +} + +void CRecompilerOps::COP1_S_CVT_D() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Float)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Float); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Float, CRegInfo::FPU_Double, CRegInfo::RoundDefault); +} + +void CRecompilerOps::COP1_S_CVT_W() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Float)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Float); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Float, CRegInfo::FPU_Dword, CRegInfo::RoundDefault); +} + +void CRecompilerOps::COP1_S_CVT_L() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Float)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Float); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Float, CRegInfo::FPU_Qword, CRegInfo::RoundDefault); +} + +void CRecompilerOps::COP1_S_CMP() +{ + uint32_t Reg1 = m_Opcode.fs; + uint32_t Reg2 = m_Opcode.ft; + uint32_t cmp = 0; + + if ((m_Opcode.funct & 4) == 0) + { + Reg1 = RegInStack(m_Opcode.ft, CRegInfo::FPU_Float) ? m_Opcode.ft : m_Opcode.fs; + Reg2 = RegInStack(m_Opcode.ft, CRegInfo::FPU_Float) ? m_Opcode.fs : m_Opcode.ft; + } + + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if ((m_Opcode.funct & 7) == 0) { CRecompilerOps::UnknownOpcode(); } + if ((m_Opcode.funct & 2) != 0) { cmp |= 0x4000; } + if ((m_Opcode.funct & 4) != 0) { cmp |= 0x0100; } + + Load_FPR_ToTop(Reg1, Reg1, CRegInfo::FPU_Float); + Map_TempReg(x86_EAX, 0, false); + if (RegInStack(Reg2, CRegInfo::FPU_Float)) + { + fpuComReg(StackPosition(Reg2), false); + } + else + { + UnMap_FPR(Reg2, true); + Load_FPR_ToTop(Reg1, Reg1, CRegInfo::FPU_Float); + + x86Reg TempReg = Map_TempReg(x86_Any, -1, false); + char Name[50]; + sprintf(Name, "_FPR_S[%d]", Reg2); + MoveVariableToX86reg((uint8_t *)&_FPR_S[Reg2], Name, TempReg); + fpuComDwordRegPointer(TempReg, false); + } + AndConstToVariable((uint32_t)~FPCSR_C, &_FPCR[31], "_FPCR[31]"); + fpuStoreStatus(); + x86Reg Reg = Map_TempReg(x86_Any8Bit, 0, false); + TestConstToX86Reg(cmp, x86_EAX); + Setnz(Reg); + + if (cmp != 0) + { + TestConstToX86Reg(cmp, x86_EAX); + Setnz(Reg); + + if ((m_Opcode.funct & 1) != 0) + { + x86Reg Reg2 = Map_TempReg(x86_Any8Bit, 0, false); + AndConstToX86Reg(x86_EAX, 0x4300); + CompConstToX86reg(x86_EAX, 0x4300); + Setz(Reg2); + + OrX86RegToX86Reg(Reg, Reg2); + } + } + else if ((m_Opcode.funct & 1) != 0) + { + AndConstToX86Reg(x86_EAX, 0x4300); + CompConstToX86reg(x86_EAX, 0x4300); + Setz(Reg); + } + ShiftLeftSignImmed(Reg, 23); + OrX86RegToVariable(&_FPCR[31], "_FPCR[31]", Reg); } /************************** COP1: D functions ************************/ -void CRecompilerOps::COP1_D_ADD() { - DWORD Reg1 = m_Opcode.ft == m_Opcode.fd?m_Opcode.ft:m_Opcode.fs; - DWORD Reg2 = m_Opcode.ft == m_Opcode.fd?m_Opcode.fs:m_Opcode.ft; - char Name[50]; - - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); +void CRecompilerOps::COP1_D_ADD() +{ + uint32_t Reg1 = m_Opcode.ft == m_Opcode.fd ? m_Opcode.ft : m_Opcode.fs; + uint32_t Reg2 = m_Opcode.ft == m_Opcode.fd ? m_Opcode.fs : m_Opcode.ft; + char Name[50]; - Load_FPR_ToTop(m_Opcode.fd,Reg1, CRegInfo::FPU_Double); - if (RegInStack(Reg2, CRegInfo::FPU_Double)) { - fpuAddReg(StackPosition(Reg2)); - } else { - x86Reg TempReg; + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - UnMap_FPR(Reg2, true); - TempReg = Map_TempReg(x86_Any, -1, false); - sprintf(Name,"_FPR_D[%d]",Reg2); - MoveVariableToX86reg((BYTE *)&_FPR_D[Reg2],Name,TempReg); - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fd, CRegInfo::FPU_Double); - fpuAddQwordRegPointer(TempReg); - } + m_Section->CompileCop1Test(); + + Load_FPR_ToTop(m_Opcode.fd, Reg1, CRegInfo::FPU_Double); + if (RegInStack(Reg2, CRegInfo::FPU_Double)) + { + fpuAddReg(StackPosition(Reg2)); + } + else + { + x86Reg TempReg; + + UnMap_FPR(Reg2, true); + TempReg = Map_TempReg(x86_Any, -1, false); + sprintf(Name, "_FPR_D[%d]", Reg2); + MoveVariableToX86reg((uint8_t *)&_FPR_D[Reg2], Name, TempReg); + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fd, CRegInfo::FPU_Double); + fpuAddQwordRegPointer(TempReg); + } } -void CRecompilerOps::COP1_D_SUB() { - DWORD Reg1 = m_Opcode.ft == m_Opcode.fd?m_Opcode.ft:m_Opcode.fs; - DWORD Reg2 = m_Opcode.ft == m_Opcode.fd?m_Opcode.fs:m_Opcode.ft; - x86Reg TempReg; - char Name[50]; - - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); +void CRecompilerOps::COP1_D_SUB() +{ + uint32_t Reg1 = m_Opcode.ft == m_Opcode.fd ? m_Opcode.ft : m_Opcode.fs; + uint32_t Reg2 = m_Opcode.ft == m_Opcode.fd ? m_Opcode.fs : m_Opcode.ft; + x86Reg TempReg; + char Name[50]; - if (m_Opcode.fd == m_Opcode.ft) { - UnMap_FPR(m_Opcode.fd, true); - TempReg = Map_TempReg(x86_Any, -1, false); - sprintf(Name,"_FPR_D[%d]",m_Opcode.ft); - MoveVariableToX86reg((BYTE *)&_FPR_D[m_Opcode.ft],Name,TempReg); - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double); - fpuSubQwordRegPointer(TempReg); - } else { - Load_FPR_ToTop(m_Opcode.fd,Reg1, CRegInfo::FPU_Double); - if (RegInStack(Reg2, CRegInfo::FPU_Double)) { - fpuSubReg(StackPosition(Reg2)); - } else { - UnMap_FPR(Reg2, true); + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - TempReg = Map_TempReg(x86_Any, -1, false); - sprintf(Name,"_FPR_D[%d]",Reg2); - MoveVariableToX86reg((BYTE *)&_FPR_D[Reg2],Name,TempReg); - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fd, CRegInfo::FPU_Double); - fpuSubQwordRegPointer(TempReg); - } - } + m_Section->CompileCop1Test(); + + if (m_Opcode.fd == m_Opcode.ft) + { + UnMap_FPR(m_Opcode.fd, true); + TempReg = Map_TempReg(x86_Any, -1, false); + sprintf(Name, "_FPR_D[%d]", m_Opcode.ft); + MoveVariableToX86reg((uint8_t *)&_FPR_D[m_Opcode.ft], Name, TempReg); + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Double); + fpuSubQwordRegPointer(TempReg); + } + else + { + Load_FPR_ToTop(m_Opcode.fd, Reg1, CRegInfo::FPU_Double); + if (RegInStack(Reg2, CRegInfo::FPU_Double)) + { + fpuSubReg(StackPosition(Reg2)); + } + else + { + UnMap_FPR(Reg2, true); + + TempReg = Map_TempReg(x86_Any, -1, false); + sprintf(Name, "_FPR_D[%d]", Reg2); + MoveVariableToX86reg((uint8_t *)&_FPR_D[Reg2], Name, TempReg); + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fd, CRegInfo::FPU_Double); + fpuSubQwordRegPointer(TempReg); + } + } } -void CRecompilerOps::COP1_D_MUL() { - DWORD Reg1 = m_Opcode.ft == m_Opcode.fd?m_Opcode.ft:m_Opcode.fs; - DWORD Reg2 = m_Opcode.ft == m_Opcode.fd?m_Opcode.fs:m_Opcode.ft; - x86Reg TempReg; - char Name[50]; - - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - FixRoundModel(CRegInfo::RoundDefault); +void CRecompilerOps::COP1_D_MUL() +{ + uint32_t Reg1 = m_Opcode.ft == m_Opcode.fd ? m_Opcode.ft : m_Opcode.fs; + uint32_t Reg2 = m_Opcode.ft == m_Opcode.fd ? m_Opcode.fs : m_Opcode.ft; + x86Reg TempReg; + char Name[50]; - Load_FPR_ToTop(m_Opcode.fd,Reg1, CRegInfo::FPU_Double); - if (RegInStack(Reg2, CRegInfo::FPU_Double)) { - fpuMulReg(StackPosition(Reg2)); - } else { - UnMap_FPR(Reg2, true); - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fd, CRegInfo::FPU_Double); - TempReg = Map_TempReg(x86_Any, -1, false); - sprintf(Name,"_FPR_D[%d]",Reg2); - MoveVariableToX86reg((BYTE *)&_FPR_D[Reg2],Name,TempReg); - fpuMulQwordRegPointer(TempReg); - } + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + FixRoundModel(CRegInfo::RoundDefault); + + Load_FPR_ToTop(m_Opcode.fd, Reg1, CRegInfo::FPU_Double); + if (RegInStack(Reg2, CRegInfo::FPU_Double)) + { + fpuMulReg(StackPosition(Reg2)); + } + else + { + UnMap_FPR(Reg2, true); + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fd, CRegInfo::FPU_Double); + TempReg = Map_TempReg(x86_Any, -1, false); + sprintf(Name, "_FPR_D[%d]", Reg2); + MoveVariableToX86reg((uint8_t *)&_FPR_D[Reg2], Name, TempReg); + fpuMulQwordRegPointer(TempReg); + } } -void CRecompilerOps::COP1_D_DIV() { - DWORD Reg1 = m_Opcode.ft == m_Opcode.fd?m_Opcode.ft:m_Opcode.fs; - DWORD Reg2 = m_Opcode.ft == m_Opcode.fd?m_Opcode.fs:m_Opcode.ft; - x86Reg TempReg; - char Name[50]; - - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); +void CRecompilerOps::COP1_D_DIV() +{ + uint32_t Reg1 = m_Opcode.ft == m_Opcode.fd ? m_Opcode.ft : m_Opcode.fs; + uint32_t Reg2 = m_Opcode.ft == m_Opcode.fd ? m_Opcode.fs : m_Opcode.ft; + x86Reg TempReg; + char Name[50]; - if (m_Opcode.fd == m_Opcode.ft) { - UnMap_FPR(m_Opcode.fd, true); - TempReg = Map_TempReg(x86_Any, -1, false); - sprintf(Name,"_FPR_D[%d]",m_Opcode.ft); - MoveVariableToX86reg((BYTE *)&_FPR_D[m_Opcode.ft],Name,TempReg); - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double); - fpuDivQwordRegPointer(TempReg); - } else { - Load_FPR_ToTop(m_Opcode.fd,Reg1, CRegInfo::FPU_Double); - if (RegInStack(Reg2, CRegInfo::FPU_Double)) { - fpuDivReg(StackPosition(Reg2)); - } else { - UnMap_FPR(Reg2, true); - TempReg = Map_TempReg(x86_Any, -1, false); - sprintf(Name,"_FPR_D[%d]",Reg2); - MoveVariableToX86reg((BYTE *)&_FPR_D[Reg2],Name,TempReg); - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fd, CRegInfo::FPU_Double); - fpuDivQwordRegPointer(TempReg); - } - } + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + + if (m_Opcode.fd == m_Opcode.ft) + { + UnMap_FPR(m_Opcode.fd, true); + TempReg = Map_TempReg(x86_Any, -1, false); + sprintf(Name, "_FPR_D[%d]", m_Opcode.ft); + MoveVariableToX86reg((uint8_t *)&_FPR_D[m_Opcode.ft], Name, TempReg); + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Double); + fpuDivQwordRegPointer(TempReg); + } + else + { + Load_FPR_ToTop(m_Opcode.fd, Reg1, CRegInfo::FPU_Double); + if (RegInStack(Reg2, CRegInfo::FPU_Double)) + { + fpuDivReg(StackPosition(Reg2)); + } + else + { + UnMap_FPR(Reg2, true); + TempReg = Map_TempReg(x86_Any, -1, false); + sprintf(Name, "_FPR_D[%d]", Reg2); + MoveVariableToX86reg((uint8_t *)&_FPR_D[Reg2], Name, TempReg); + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fd, CRegInfo::FPU_Double); + fpuDivQwordRegPointer(TempReg); + } + } } -void CRecompilerOps::COP1_D_ABS() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double); - fpuAbs(); +void CRecompilerOps::COP1_D_ABS() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Double); + fpuAbs(); } -void CRecompilerOps::COP1_D_NEG() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double); - fpuNeg(); +void CRecompilerOps::COP1_D_NEG() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Double); + fpuNeg(); } -void CRecompilerOps::COP1_D_SQRT() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double); - fpuSqrt(); +void CRecompilerOps::COP1_D_SQRT() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Double); + fpuSqrt(); } -void CRecompilerOps::COP1_D_MOV() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double); +void CRecompilerOps::COP1_D_MOV() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Double); } -void CRecompilerOps::COP1_D_TRUNC_L() { //added by Witten - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (RegInStack(m_Opcode.fs,CRegInfo::FPU_Double) || RegInStack(m_Opcode.fs,CRegInfo::FPU_Qword)) { - UnMap_FPR(m_Opcode.fs, true); - } - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Double)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Double,CRegInfo::FPU_Qword,CRegInfo::RoundTruncate); +void CRecompilerOps::COP1_D_TRUNC_L() //added by Witten +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (RegInStack(m_Opcode.fs, CRegInfo::FPU_Double) || RegInStack(m_Opcode.fs, CRegInfo::FPU_Qword)) + { + UnMap_FPR(m_Opcode.fs, true); + } + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Double)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Double); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Double, CRegInfo::FPU_Qword, CRegInfo::RoundTruncate); } -void CRecompilerOps::COP1_D_CEIL_L() { //added by Witten - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (RegInStack(m_Opcode.fs,CRegInfo::FPU_Double) || RegInStack(m_Opcode.fs,CRegInfo::FPU_Qword)) { - UnMap_FPR(m_Opcode.fs, true); - } - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Double)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Double,CRegInfo::FPU_Qword,CRegInfo::RoundUp); +void CRecompilerOps::COP1_D_CEIL_L() //added by Witten +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (RegInStack(m_Opcode.fs, CRegInfo::FPU_Double) || RegInStack(m_Opcode.fs, CRegInfo::FPU_Qword)) + { + UnMap_FPR(m_Opcode.fs, true); + } + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Double)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Double); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Double, CRegInfo::FPU_Qword, CRegInfo::RoundUp); } -void CRecompilerOps::COP1_D_FLOOR_L() { //added by Witten - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (RegInStack(m_Opcode.fs,CRegInfo::FPU_Double) || RegInStack(m_Opcode.fs,CRegInfo::FPU_Qword)) { - UnMap_FPR(m_Opcode.fs, true); - } - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Double)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Double,CRegInfo::FPU_Qword,CRegInfo::RoundDown); +void CRecompilerOps::COP1_D_FLOOR_L() //added by Witten +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (RegInStack(m_Opcode.fs, CRegInfo::FPU_Double) || RegInStack(m_Opcode.fs, CRegInfo::FPU_Qword)) + { + UnMap_FPR(m_Opcode.fs, true); + } + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Double)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Double); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Double, CRegInfo::FPU_Qword, CRegInfo::RoundDown); } -void CRecompilerOps::COP1_D_ROUND_W() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (RegInStack(m_Opcode.fs,CRegInfo::FPU_Double) || RegInStack(m_Opcode.fs,CRegInfo::FPU_Qword)) { - UnMap_FPR(m_Opcode.fs, true); - } - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Double)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Double,CRegInfo::FPU_Dword,CRegInfo::RoundNearest); +void CRecompilerOps::COP1_D_ROUND_W() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (RegInStack(m_Opcode.fs, CRegInfo::FPU_Double) || RegInStack(m_Opcode.fs, CRegInfo::FPU_Qword)) + { + UnMap_FPR(m_Opcode.fs, true); + } + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Double)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Double); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Double, CRegInfo::FPU_Dword, CRegInfo::RoundNearest); } -void CRecompilerOps::COP1_D_TRUNC_W() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (RegInStack(m_Opcode.fd,CRegInfo::FPU_Double) || RegInStack(m_Opcode.fd,CRegInfo::FPU_Qword)) { - UnMap_FPR(m_Opcode.fd, true); - } - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Double)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Double,CRegInfo::FPU_Dword,CRegInfo::RoundTruncate); +void CRecompilerOps::COP1_D_TRUNC_W() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (RegInStack(m_Opcode.fd, CRegInfo::FPU_Double) || RegInStack(m_Opcode.fd, CRegInfo::FPU_Qword)) + { + UnMap_FPR(m_Opcode.fd, true); + } + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Double)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Double); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Double, CRegInfo::FPU_Dword, CRegInfo::RoundTruncate); } -void CRecompilerOps::COP1_D_CEIL_W() { // added by Witten - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (RegInStack(m_Opcode.fs,CRegInfo::FPU_Double) || RegInStack(m_Opcode.fs,CRegInfo::FPU_Qword)) { - UnMap_FPR(m_Opcode.fs, true); - } - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Double)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Double,CRegInfo::FPU_Dword,CRegInfo::RoundUp); +void CRecompilerOps::COP1_D_CEIL_W() // added by Witten +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (RegInStack(m_Opcode.fs, CRegInfo::FPU_Double) || RegInStack(m_Opcode.fs, CRegInfo::FPU_Qword)) + { + UnMap_FPR(m_Opcode.fs, true); + } + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Double)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Double); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Double, CRegInfo::FPU_Dword, CRegInfo::RoundUp); } -void CRecompilerOps::COP1_D_FLOOR_W() { //added by Witten - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (RegInStack(m_Opcode.fs,CRegInfo::FPU_Double) || RegInStack(m_Opcode.fs,CRegInfo::FPU_Qword)) { - UnMap_FPR(m_Opcode.fs, true); - } - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Double)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Double,CRegInfo::FPU_Dword,CRegInfo::RoundDown); +void CRecompilerOps::COP1_D_FLOOR_W() //added by Witten +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (RegInStack(m_Opcode.fs, CRegInfo::FPU_Double) || RegInStack(m_Opcode.fs, CRegInfo::FPU_Qword)) + { + UnMap_FPR(m_Opcode.fs, true); + } + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Double)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Double); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Double, CRegInfo::FPU_Dword, CRegInfo::RoundDown); } -void CRecompilerOps::COP1_D_CVT_S() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (RegInStack(m_Opcode.fd,CRegInfo::FPU_Double) || RegInStack(m_Opcode.fd,CRegInfo::FPU_Qword)) { - UnMap_FPR(m_Opcode.fd, true); - } - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Double)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Double,CRegInfo::FPU_Float,CRegInfo::RoundDefault); +void CRecompilerOps::COP1_D_CVT_S() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (RegInStack(m_Opcode.fd, CRegInfo::FPU_Double) || RegInStack(m_Opcode.fd, CRegInfo::FPU_Qword)) + { + UnMap_FPR(m_Opcode.fd, true); + } + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Double)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Double); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Double, CRegInfo::FPU_Float, CRegInfo::RoundDefault); } -void CRecompilerOps::COP1_D_CVT_W() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (RegInStack(m_Opcode.fs,CRegInfo::FPU_Double) || RegInStack(m_Opcode.fs,CRegInfo::FPU_Qword)) { - UnMap_FPR(m_Opcode.fs, true); - } - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Double)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Double,CRegInfo::FPU_Dword,CRegInfo::RoundDefault); +void CRecompilerOps::COP1_D_CVT_W() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (RegInStack(m_Opcode.fs, CRegInfo::FPU_Double) || RegInStack(m_Opcode.fs, CRegInfo::FPU_Qword)) + { + UnMap_FPR(m_Opcode.fs, true); + } + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Double)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Double); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Double, CRegInfo::FPU_Dword, CRegInfo::RoundDefault); } -void CRecompilerOps::COP1_D_CVT_L() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (RegInStack(m_Opcode.fs,CRegInfo::FPU_Double) || RegInStack(m_Opcode.fs,CRegInfo::FPU_Qword)) { - UnMap_FPR(m_Opcode.fs, true); - } - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Double)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Double,CRegInfo::FPU_Qword,CRegInfo::RoundDefault); +void CRecompilerOps::COP1_D_CVT_L() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (RegInStack(m_Opcode.fs, CRegInfo::FPU_Double) || RegInStack(m_Opcode.fs, CRegInfo::FPU_Qword)) + { + UnMap_FPR(m_Opcode.fs, true); + } + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Double)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Double); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Double, CRegInfo::FPU_Qword, CRegInfo::RoundDefault); } -void CRecompilerOps::COP1_D_CMP() { - DWORD Reg1 = m_Opcode.fs; - DWORD Reg2 = m_Opcode.ft; - DWORD cmp = 0; +void CRecompilerOps::COP1_D_CMP() +{ + uint32_t Reg1 = m_Opcode.fs; + uint32_t Reg2 = m_Opcode.ft; + uint32_t cmp = 0; - if ((m_Opcode.funct & 4) == 0) - { - Reg1 = RegInStack(m_Opcode.ft, CRegInfo::FPU_Double)?m_Opcode.ft:m_Opcode.fs; - Reg2 = RegInStack(m_Opcode.ft, CRegInfo::FPU_Double)?m_Opcode.fs:m_Opcode.ft; - } - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if ((m_Opcode.funct & 7) == 0) { CRecompilerOps::UnknownOpcode(); } - if ((m_Opcode.funct & 2) != 0) { cmp |= 0x4000; } - if ((m_Opcode.funct & 4) != 0) { cmp |= 0x0100; } - - Load_FPR_ToTop(Reg1,Reg1, CRegInfo::FPU_Double); - Map_TempReg(x86_EAX, 0, false); - if (RegInStack(Reg2, CRegInfo::FPU_Double)) { - fpuComReg(StackPosition(Reg2), false); - } else { - char Name[50]; + if ((m_Opcode.funct & 4) == 0) + { + Reg1 = RegInStack(m_Opcode.ft, CRegInfo::FPU_Double) ? m_Opcode.ft : m_Opcode.fs; + Reg2 = RegInStack(m_Opcode.ft, CRegInfo::FPU_Double) ? m_Opcode.fs : m_Opcode.ft; + } + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - UnMap_FPR(Reg2, true); - x86Reg TempReg = Map_TempReg(x86_Any, -1, false); - sprintf(Name,"_FPR_D[%d]",Reg2); - MoveVariableToX86reg((BYTE *)&_FPR_D[Reg2],Name,TempReg); - Load_FPR_ToTop(Reg1,Reg1, CRegInfo::FPU_Double); - fpuComQwordRegPointer(TempReg, false); - } - AndConstToVariable((DWORD)~FPCSR_C, &_FPCR[31], "_FPCR[31]"); - fpuStoreStatus(); - x86Reg Reg = Map_TempReg(x86_Any8Bit, 0, false); - TestConstToX86Reg(cmp,x86_EAX); - Setnz(Reg); - if (cmp != 0) { - TestConstToX86Reg(cmp,x86_EAX); - Setnz(Reg); - - if ((m_Opcode.funct & 1) != 0) { - x86Reg Reg2 = Map_TempReg(x86_Any8Bit, 0, false); - AndConstToX86Reg(x86_EAX, 0x4300); - CompConstToX86reg(x86_EAX, 0x4300); - Setz(Reg2); - - OrX86RegToX86Reg(Reg, Reg2); - } - } else if ((m_Opcode.funct & 1) != 0) { - AndConstToX86Reg(x86_EAX, 0x4300); - CompConstToX86reg(x86_EAX, 0x4300); - Setz(Reg); - } - ShiftLeftSignImmed(Reg, 23); - OrX86RegToVariable(&_FPCR[31], "_FPCR[31]", Reg); + m_Section->CompileCop1Test(); + if ((m_Opcode.funct & 7) == 0) { CRecompilerOps::UnknownOpcode(); } + if ((m_Opcode.funct & 2) != 0) { cmp |= 0x4000; } + if ((m_Opcode.funct & 4) != 0) { cmp |= 0x0100; } + + Load_FPR_ToTop(Reg1, Reg1, CRegInfo::FPU_Double); + Map_TempReg(x86_EAX, 0, false); + if (RegInStack(Reg2, CRegInfo::FPU_Double)) + { + fpuComReg(StackPosition(Reg2), false); + } + else + { + char Name[50]; + + UnMap_FPR(Reg2, true); + x86Reg TempReg = Map_TempReg(x86_Any, -1, false); + sprintf(Name, "_FPR_D[%d]", Reg2); + MoveVariableToX86reg((uint8_t *)&_FPR_D[Reg2], Name, TempReg); + Load_FPR_ToTop(Reg1, Reg1, CRegInfo::FPU_Double); + fpuComQwordRegPointer(TempReg, false); + } + AndConstToVariable((uint32_t)~FPCSR_C, &_FPCR[31], "_FPCR[31]"); + fpuStoreStatus(); + x86Reg Reg = Map_TempReg(x86_Any8Bit, 0, false); + TestConstToX86Reg(cmp, x86_EAX); + Setnz(Reg); + if (cmp != 0) + { + TestConstToX86Reg(cmp, x86_EAX); + Setnz(Reg); + + if ((m_Opcode.funct & 1) != 0) + { + x86Reg Reg2 = Map_TempReg(x86_Any8Bit, 0, false); + AndConstToX86Reg(x86_EAX, 0x4300); + CompConstToX86reg(x86_EAX, 0x4300); + Setz(Reg2); + + OrX86RegToX86Reg(Reg, Reg2); + } + } + else if ((m_Opcode.funct & 1) != 0) + { + AndConstToX86Reg(x86_EAX, 0x4300); + CompConstToX86reg(x86_EAX, 0x4300); + Setz(Reg); + } + ShiftLeftSignImmed(Reg, 23); + OrX86RegToVariable(&_FPCR[31], "_FPCR[31]", Reg); } /************************** COP1: W functions ************************/ -void CRecompilerOps::COP1_W_CVT_S() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Dword)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Dword); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Dword,CRegInfo::FPU_Float,CRegInfo::RoundDefault); +void CRecompilerOps::COP1_W_CVT_S() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Dword)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Dword); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Dword, CRegInfo::FPU_Float, CRegInfo::RoundDefault); } -void CRecompilerOps::COP1_W_CVT_D() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Dword)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Dword); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Dword,CRegInfo::FPU_Double,CRegInfo::RoundDefault); +void CRecompilerOps::COP1_W_CVT_D() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Dword)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Dword); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Dword, CRegInfo::FPU_Double, CRegInfo::RoundDefault); } /************************** COP1: L functions ************************/ -void CRecompilerOps::COP1_L_CVT_S() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Qword)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Qword); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Qword,CRegInfo::FPU_Float,CRegInfo::RoundDefault); +void CRecompilerOps::COP1_L_CVT_S() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Qword)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Qword); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Qword, CRegInfo::FPU_Float, CRegInfo::RoundDefault); } -void CRecompilerOps::COP1_L_CVT_D() { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - - m_Section->CompileCop1Test(); - if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd,CRegInfo::FPU_Qword)) { - Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Qword); - } - ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Qword,CRegInfo::FPU_Double,CRegInfo::RoundDefault); +void CRecompilerOps::COP1_L_CVT_D() +{ + CPU_Message(" %X %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); + + m_Section->CompileCop1Test(); + if (m_Opcode.fd != m_Opcode.fs || !RegInStack(m_Opcode.fd, CRegInfo::FPU_Qword)) + { + Load_FPR_ToTop(m_Opcode.fd, m_Opcode.fs, CRegInfo::FPU_Qword); + } + ChangeFPURegFormat(m_Opcode.fd, CRegInfo::FPU_Qword, CRegInfo::FPU_Double, CRegInfo::RoundDefault); } /************************** Other functions **************************/ -void CRecompilerOps::UnknownOpcode() { - CPU_Message(" %X Unhandled Opcode: %s",m_CompilePC, R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CRecompilerOps::UnknownOpcode() +{ + CPU_Message(" %X Unhandled Opcode: %s", m_CompilePC, R4300iOpcodeName(m_Opcode.Hex, m_CompilePC)); - m_RegWorkingSet.WriteBackRegisters(); - UpdateCounters(m_RegWorkingSet,false,true); - MoveConstToVariable(m_CompilePC,&g_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER"); - if (g_SyncSystem) { - MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); - } - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); + m_RegWorkingSet.WriteBackRegisters(); + UpdateCounters(m_RegWorkingSet, false, true); + MoveConstToVariable(m_CompilePC, &g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER"); + if (g_SyncSystem) + { + MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); + } + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); - MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); - Call_Direct(R4300iOp::UnknownOpcode, "R4300iOp::UnknownOpcode"); - Ret(); - if (m_NextInstruction == NORMAL) { m_NextInstruction = END_BLOCK; } + MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); + Call_Direct(R4300iOp::UnknownOpcode, "R4300iOp::UnknownOpcode"); + Ret(); + if (m_NextInstruction == NORMAL) { m_NextInstruction = END_BLOCK; } } -void CRecompilerOps::BeforeCallDirect ( CRegInfo & RegSet ) +void CRecompilerOps::BeforeCallDirect(CRegInfo & RegSet) { - RegSet.UnMap_AllFPRs(); - Pushad(); + RegSet.UnMap_AllFPRs(); + Pushad(); } -void CRecompilerOps::AfterCallDirect ( CRegInfo & RegSet ) +void CRecompilerOps::AfterCallDirect(CRegInfo & RegSet) { - Popad(); - RegSet.SetRoundingModel(CRegInfo::RoundUnknown); + Popad(); + RegSet.SetRoundingModel(CRegInfo::RoundUnknown); } void CRecompilerOps::EnterCodeBlock() { #ifdef _DEBUG - Push(x86_ESI); + Push(x86_ESI); #else - Push(x86_EDI); - Push(x86_ESI); - Push(x86_EBX); + Push(x86_EDI); + Push(x86_ESI); + Push(x86_EBX); #endif } void CRecompilerOps::ExitCodeBlock() { #ifdef _DEBUG - Pop(x86_ESI); + Pop(x86_ESI); #else - Pop(x86_EBX); - Pop(x86_ESI); - Pop(x86_EDI); + Pop(x86_EBX); + Pop(x86_ESI); + Pop(x86_EDI); #endif - Ret(); + Ret(); } -void CRecompilerOps::UpdateSyncCPU ( CRegInfo & RegSet, DWORD Cycles ) +void CRecompilerOps::UpdateSyncCPU(CRegInfo & RegSet, uint32_t Cycles) { - if (!g_SyncSystem) - { - return; - } + if (!g_SyncSystem) + { + return; + } - WriteX86Comment("Updating Sync CPU"); - BeforeCallDirect(RegSet); - PushImm32(stdstr_f("%d",Cycles).c_str(),Cycles); - PushImm32("g_SyncSystem",(DWORD)g_SyncSystem); - MoveConstToX86reg((DWORD)g_System,x86_ECX); - Call_Direct(AddressOf(&CN64System::UpdateSyncCPU),"CN64System::UpdateSyncCPU"); - AfterCallDirect(RegSet); + WriteX86Comment("Updating Sync CPU"); + BeforeCallDirect(RegSet); + PushImm32(stdstr_f("%d", Cycles).c_str(), Cycles); + PushImm32("g_SyncSystem", (uint32_t)g_SyncSystem); + MoveConstToX86reg((uint32_t)g_System, x86_ECX); + Call_Direct(AddressOf(&CN64System::UpdateSyncCPU), "CN64System::UpdateSyncCPU"); + AfterCallDirect(RegSet); } -void CRecompilerOps::UpdateCounters ( CRegInfo & RegSet, bool CheckTimer, bool ClearValues ) +void CRecompilerOps::UpdateCounters(CRegInfo & RegSet, bool CheckTimer, bool ClearValues) { - if (RegSet.GetBlockCycleCount() != 0) - { - UpdateSyncCPU(RegSet,RegSet.GetBlockCycleCount()); - WriteX86Comment("Update Counter"); - SubConstFromVariable(RegSet.GetBlockCycleCount(),g_NextTimer,"g_NextTimer"); // updates compare flag - if (ClearValues) - { - RegSet.SetBlockCycleCount(0); - } - } else if (CheckTimer) { - CompConstToVariable(0,g_NextTimer,"g_NextTimer"); - } + if (RegSet.GetBlockCycleCount() != 0) + { + UpdateSyncCPU(RegSet, RegSet.GetBlockCycleCount()); + WriteX86Comment("Update Counter"); + SubConstFromVariable(RegSet.GetBlockCycleCount(), g_NextTimer, "g_NextTimer"); // updates compare flag + if (ClearValues) + { + RegSet.SetBlockCycleCount(0); + } + } + else if (CheckTimer) + { + CompConstToVariable(0, g_NextTimer, "g_NextTimer"); + } - if (CheckTimer) - { - JnsLabel8("Continue_From_Timer_Test",0); - BYTE * Jump = m_RecompPos - 1; - Pushad(); - MoveConstToX86reg((DWORD)g_SystemTimer,x86_ECX); - Call_Direct(AddressOf(&CSystemTimer::TimerDone),"CSystemTimer::TimerDone"); - Popad(); - - CPU_Message(""); - CPU_Message(" $Continue_From_Timer_Test:"); - SetJump8(Jump,m_RecompPos); - } + if (CheckTimer) + { + JnsLabel8("Continue_From_Timer_Test", 0); + uint8_t * Jump = m_RecompPos - 1; + Pushad(); + MoveConstToX86reg((uint32_t)g_SystemTimer, x86_ECX); + Call_Direct(AddressOf(&CSystemTimer::TimerDone), "CSystemTimer::TimerDone"); + Popad(); + + CPU_Message(""); + CPU_Message(" $Continue_From_Timer_Test:"); + SetJump8(Jump, m_RecompPos); + } } -void CRecompilerOps::CompileSystemCheck (DWORD TargetPC, const CRegInfo & RegSet) +void CRecompilerOps::CompileSystemCheck(uint32_t TargetPC, const CRegInfo & RegSet) { - CompConstToVariable(0,(void *)&g_SystemEvents->DoSomething(),"g_SystemEvents->DoSomething()"); - JeLabel32("Continue_From_Interrupt_Test",0); - DWORD * Jump = (DWORD *)(m_RecompPos - 4); - if (TargetPC != (DWORD)-1) - { - MoveConstToVariable(TargetPC,&g_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER"); - } + CompConstToVariable(0, (void *)&g_SystemEvents->DoSomething(), "g_SystemEvents->DoSomething()"); + JeLabel32("Continue_From_Interrupt_Test", 0); + uint32_t * Jump = (uint32_t *)(m_RecompPos - 4); + if (TargetPC != (uint32_t)-1) + { + MoveConstToVariable(TargetPC, &g_Reg->m_PROGRAM_COUNTER, "PROGRAM_COUNTER"); + } - CRegInfo RegSetCopy(RegSet); - RegSetCopy.WriteBackRegisters(); + CRegInfo RegSetCopy(RegSet); + RegSetCopy.WriteBackRegisters(); - MoveConstToX86reg((DWORD)g_SystemEvents,x86_ECX); - Call_Direct(AddressOf(&CSystemEvents::ExecuteEvents),"CSystemEvents::ExecuteEvents"); - if (g_SyncSystem) { - MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); - } - ExitCodeBlock(); - CPU_Message(""); - CPU_Message(" $Continue_From_Interrupt_Test:"); - SetJump32((uint32_t *)Jump,(uint32_t *)m_RecompPos); + MoveConstToX86reg((uint32_t)g_SystemEvents, x86_ECX); + Call_Direct(AddressOf(&CSystemEvents::ExecuteEvents), "CSystemEvents::ExecuteEvents"); + if (g_SyncSystem) + { + MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); + } + ExitCodeBlock(); + CPU_Message(""); + CPU_Message(" $Continue_From_Interrupt_Test:"); + SetJump32(Jump, (uint32_t *)m_RecompPos); } void CRecompilerOps::OverflowDelaySlot(bool TestTimer) { - m_RegWorkingSet.WriteBackRegisters(); - UpdateCounters(m_RegWorkingSet,false,true); - MoveConstToVariable(CompilePC() + 4,_PROGRAM_COUNTER,"PROGRAM_COUNTER"); + m_RegWorkingSet.WriteBackRegisters(); + UpdateCounters(m_RegWorkingSet, false, true); + MoveConstToVariable(CompilePC() + 4, _PROGRAM_COUNTER, "PROGRAM_COUNTER"); - if (g_SyncSystem) - { - MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); - } + if (g_SyncSystem) + { + MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); + } - MoveConstToVariable(JUMP,&R4300iOp::m_NextInstruction,"R4300iOp::m_NextInstruction"); + MoveConstToVariable(JUMP, &R4300iOp::m_NextInstruction, "R4300iOp::m_NextInstruction"); - if (TestTimer) - MoveConstToVariable(TestTimer,&R4300iOp::m_TestTimer,"R4300iOp::m_TestTimer"); + if (TestTimer) + { + MoveConstToVariable(TestTimer, &R4300iOp::m_TestTimer, "R4300iOp::m_TestTimer"); + } - PushImm32("g_System->CountPerOp()",g_System->CountPerOp()); - Call_Direct(CInterpreterCPU::ExecuteOps, "CInterpreterCPU::ExecuteOps"); - AddConstToX86Reg(x86_ESP,4); + PushImm32("g_System->CountPerOp()", g_System->CountPerOp()); + Call_Direct(CInterpreterCPU::ExecuteOps, "CInterpreterCPU::ExecuteOps"); + AddConstToX86Reg(x86_ESP, 4); - if (g_System->bFastSP() && g_Recompiler) - { - MoveConstToX86reg((DWORD)g_Recompiler,x86_ECX); - Call_Direct(AddressOf(&CRecompiler::ResetMemoryStackPos), "CRecompiler::ResetMemoryStackPos"); - } + if (g_System->bFastSP() && g_Recompiler) + { + MoveConstToX86reg((uint32_t)g_Recompiler, x86_ECX); + Call_Direct(AddressOf(&CRecompiler::ResetMemoryStackPos), "CRecompiler::ResetMemoryStackPos"); + } - if (g_SyncSystem) - { - UpdateSyncCPU(m_RegWorkingSet,g_System->CountPerOp()); - MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); - Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); - } + if (g_SyncSystem) + { + UpdateSyncCPU(m_RegWorkingSet, g_System->CountPerOp()); + MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX); + Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); + } - ExitCodeBlock(); - m_NextInstruction = END_BLOCK; + ExitCodeBlock(); + m_NextInstruction = END_BLOCK; } diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Ops.h b/Source/Project64/N64 System/Recompiler/Recompiler Ops.h index 6ce00179c..594097211 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Ops.h +++ b/Source/Project64/N64 System/Recompiler/Recompiler Ops.h @@ -10,321 +10,319 @@ ****************************************************************************/ #pragma once + class CCodeSection; class CRecompilerOps : - protected CDebugSettings, - protected CX86Ops, - protected CSystemRegisters, - protected CN64SystemSettings, - protected CRecompilerSettings + protected CDebugSettings, + protected CX86Ops, + protected CSystemRegisters, + protected CN64SystemSettings, + protected CRecompilerSettings { protected: - enum BRANCH_TYPE - { - BranchTypeCop1, BranchTypeRs, BranchTypeRsRt - }; + enum BRANCH_TYPE + { + BranchTypeCop1, BranchTypeRs, BranchTypeRsRt + }; - typedef void ( * BranchFunction )(); - - /************************** Branch functions ************************/ - static void Compile_Branch ( BranchFunction CompareFunc, BRANCH_TYPE BranchType, bool Link); - static void Compile_BranchLikely ( BranchFunction CompareFunc, bool Link); - static void BNE_Compare(); - static void BEQ_Compare(); - static void BGTZ_Compare(); - static void BLEZ_Compare(); - static void BLTZ_Compare(); - static void BGEZ_Compare(); - static void COP1_BCF_Compare(); - static void COP1_BCT_Compare(); + typedef void ( * BranchFunction )(); - /************************* OpCode functions *************************/ - static void J (); - static void JAL (); - static void ADDI (); - static void ADDIU (); - static void SLTI (); - static void SLTIU (); - static void ANDI (); - static void ORI (); - static void XORI (); - static void LUI (); - static void DADDIU (); -// static void LDL (); -// static void LDR (); -// static void LB (); -// static void LH (); -// static void LWL (); -// static void LW (); -// static void LBU (); -// static void LHU (); -// static void LWR (); -// static void LWU (); //added by Witten -// static void SB (); -// static void SH (); -// static void SWL (); -// static void SW (); -// static void SWR (); -// static void SDL (); -// static void SDR (); - static void CACHE (); -// static void LL (); -// static void LWC1 (); -// static void LDC1 (); -// static void LD (); -// static void SC (); -// static void SWC1 (); -// static void SDC1 (); -// static void SD (); + /************************** Branch functions ************************/ + static void Compile_Branch ( BranchFunction CompareFunc, BRANCH_TYPE BranchType, bool Link); + static void Compile_BranchLikely ( BranchFunction CompareFunc, bool Link); + static void BNE_Compare(); + static void BEQ_Compare(); + static void BGTZ_Compare(); + static void BLEZ_Compare(); + static void BLTZ_Compare(); + static void BGEZ_Compare(); + static void COP1_BCF_Compare(); + static void COP1_BCT_Compare(); - /********************** R4300i OpCodes: Special **********************/ - static void SPECIAL_SLL (); - static void SPECIAL_SRL (); - static void SPECIAL_SRA (); - static void SPECIAL_SLLV (); - static void SPECIAL_SRLV (); - static void SPECIAL_SRAV (); - static void SPECIAL_JR (); - static void SPECIAL_JALR (); - static void SPECIAL_SYSCALL(); - static void SPECIAL_MFLO (); - static void SPECIAL_MTLO (); - static void SPECIAL_MFHI (); - static void SPECIAL_MTHI (); - static void SPECIAL_DSLLV (); - static void SPECIAL_DSRLV (); - static void SPECIAL_DSRAV (); - static void SPECIAL_MULT (); - static void SPECIAL_MULTU (); - static void SPECIAL_DIV (); - static void SPECIAL_DIVU (); - static void SPECIAL_DMULT (); - static void SPECIAL_DMULTU (); - static void SPECIAL_DDIV (); - static void SPECIAL_DDIVU (); - static void SPECIAL_ADD (); - static void SPECIAL_ADDU (); - static void SPECIAL_SUB (); - static void SPECIAL_SUBU (); - static void SPECIAL_AND (); - static void SPECIAL_OR (); - static void SPECIAL_XOR (); - static void SPECIAL_NOR (); - static void SPECIAL_SLT (); - static void SPECIAL_SLTU (); - static void SPECIAL_DADD (); - static void SPECIAL_DADDU (); - static void SPECIAL_DSUB (); - static void SPECIAL_DSUBU (); - static void SPECIAL_DSLL (); - static void SPECIAL_DSRL (); - static void SPECIAL_DSRA (); - static void SPECIAL_DSLL32 (); - static void SPECIAL_DSRL32 (); - static void SPECIAL_DSRA32 (); + /************************* OpCode functions *************************/ + static void J (); + static void JAL (); + static void ADDI (); + static void ADDIU (); + static void SLTI (); + static void SLTIU (); + static void ANDI (); + static void ORI (); + static void XORI (); + static void LUI (); + static void DADDIU (); + // static void LDL (); + // static void LDR (); + // static void LB (); + // static void LH (); + // static void LWL (); + // static void LW (); + // static void LBU (); + // static void LHU (); + // static void LWR (); + // static void LWU (); //added by Witten + // static void SB (); + // static void SH (); + // static void SWL (); + // static void SW (); + // static void SWR (); + // static void SDL (); + // static void SDR (); + static void CACHE (); + // static void LL (); + // static void LWC1 (); + // static void LDC1 (); + // static void LD (); + // static void SC (); + // static void SWC1 (); + // static void SDC1 (); + // static void SD (); - /************************** COP0 functions **************************/ - static void COP0_MF (); - static void COP0_MT (); + /********************** R4300i OpCodes: Special **********************/ + static void SPECIAL_SLL (); + static void SPECIAL_SRL (); + static void SPECIAL_SRA (); + static void SPECIAL_SLLV (); + static void SPECIAL_SRLV (); + static void SPECIAL_SRAV (); + static void SPECIAL_JR (); + static void SPECIAL_JALR (); + static void SPECIAL_SYSCALL(); + static void SPECIAL_MFLO (); + static void SPECIAL_MTLO (); + static void SPECIAL_MFHI (); + static void SPECIAL_MTHI (); + static void SPECIAL_DSLLV (); + static void SPECIAL_DSRLV (); + static void SPECIAL_DSRAV (); + static void SPECIAL_MULT (); + static void SPECIAL_MULTU (); + static void SPECIAL_DIV (); + static void SPECIAL_DIVU (); + static void SPECIAL_DMULT (); + static void SPECIAL_DMULTU (); + static void SPECIAL_DDIV (); + static void SPECIAL_DDIVU (); + static void SPECIAL_ADD (); + static void SPECIAL_ADDU (); + static void SPECIAL_SUB (); + static void SPECIAL_SUBU (); + static void SPECIAL_AND (); + static void SPECIAL_OR (); + static void SPECIAL_XOR (); + static void SPECIAL_NOR (); + static void SPECIAL_SLT (); + static void SPECIAL_SLTU (); + static void SPECIAL_DADD (); + static void SPECIAL_DADDU (); + static void SPECIAL_DSUB (); + static void SPECIAL_DSUBU (); + static void SPECIAL_DSLL (); + static void SPECIAL_DSRL (); + static void SPECIAL_DSRA (); + static void SPECIAL_DSLL32 (); + static void SPECIAL_DSRL32 (); + static void SPECIAL_DSRA32 (); - /************************** COP0 CO functions ***********************/ - static void COP0_CO_TLBR (); - static void COP0_CO_TLBWI (); - static void COP0_CO_TLBWR (); - static void COP0_CO_TLBP (); - static void COP0_CO_ERET (); + /************************** COP0 functions **************************/ + static void COP0_MF (); + static void COP0_MT (); - /************************** COP1 functions **************************/ - static void COP1_MF (); - static void COP1_DMF (); - static void COP1_CF (); - static void COP1_MT (); - static void COP1_DMT (); - static void COP1_CT (); + /************************** COP0 CO functions ***********************/ + static void COP0_CO_TLBR (); + static void COP0_CO_TLBWI (); + static void COP0_CO_TLBWR (); + static void COP0_CO_TLBP (); + static void COP0_CO_ERET (); - /************************** COP1: S functions ************************/ - static void COP1_S_ADD (); - static void COP1_S_SUB (); - static void COP1_S_MUL (); - static void COP1_S_DIV (); - static void COP1_S_ABS (); - static void COP1_S_NEG (); - static void COP1_S_SQRT (); - static void COP1_S_MOV (); - static void COP1_S_TRUNC_L (); - static void COP1_S_CEIL_L (); //added by Witten - static void COP1_S_FLOOR_L (); //added by Witten - static void COP1_S_ROUND_W (); - static void COP1_S_TRUNC_W (); - static void COP1_S_CEIL_W (); //added by Witten - static void COP1_S_FLOOR_W (); - static void COP1_S_CVT_D (); - static void COP1_S_CVT_W (); - static void COP1_S_CVT_L (); - static void COP1_S_CMP (); + /************************** COP1 functions **************************/ + static void COP1_MF (); + static void COP1_DMF (); + static void COP1_CF (); + static void COP1_MT (); + static void COP1_DMT (); + static void COP1_CT (); - /************************** COP1: D functions ************************/ - static void COP1_D_ADD (); - static void COP1_D_SUB (); - static void COP1_D_MUL (); - static void COP1_D_DIV (); - static void COP1_D_ABS (); - static void COP1_D_NEG (); - static void COP1_D_SQRT (); - static void COP1_D_MOV (); - static void COP1_D_TRUNC_L (); //added by Witten - static void COP1_D_CEIL_L (); //added by Witten - static void COP1_D_FLOOR_L (); //added by Witten - static void COP1_D_ROUND_W (); - static void COP1_D_TRUNC_W (); - static void COP1_D_CEIL_W (); //added by Witten - static void COP1_D_FLOOR_W (); //added by Witten - static void COP1_D_CVT_S (); - static void COP1_D_CVT_W (); - static void COP1_D_CVT_L (); - static void COP1_D_CMP (); + /************************** COP1: S functions ************************/ + static void COP1_S_ADD (); + static void COP1_S_SUB (); + static void COP1_S_MUL (); + static void COP1_S_DIV (); + static void COP1_S_ABS (); + static void COP1_S_NEG (); + static void COP1_S_SQRT (); + static void COP1_S_MOV (); + static void COP1_S_TRUNC_L (); + static void COP1_S_CEIL_L (); //added by Witten + static void COP1_S_FLOOR_L (); //added by Witten + static void COP1_S_ROUND_W (); + static void COP1_S_TRUNC_W (); + static void COP1_S_CEIL_W (); //added by Witten + static void COP1_S_FLOOR_W (); + static void COP1_S_CVT_D (); + static void COP1_S_CVT_W (); + static void COP1_S_CVT_L (); + static void COP1_S_CMP (); - /************************** COP1: W functions ************************/ - static void COP1_W_CVT_S (); - static void COP1_W_CVT_D (); + /************************** COP1: D functions ************************/ + static void COP1_D_ADD (); + static void COP1_D_SUB (); + static void COP1_D_MUL (); + static void COP1_D_DIV (); + static void COP1_D_ABS (); + static void COP1_D_NEG (); + static void COP1_D_SQRT (); + static void COP1_D_MOV (); + static void COP1_D_TRUNC_L (); //added by Witten + static void COP1_D_CEIL_L (); //added by Witten + static void COP1_D_FLOOR_L (); //added by Witten + static void COP1_D_ROUND_W (); + static void COP1_D_TRUNC_W (); + static void COP1_D_CEIL_W (); //added by Witten + static void COP1_D_FLOOR_W (); //added by Witten + static void COP1_D_CVT_S (); + static void COP1_D_CVT_W (); + static void COP1_D_CVT_L (); + static void COP1_D_CMP (); - /************************** COP1: L functions ************************/ - static void COP1_L_CVT_S (); - static void COP1_L_CVT_D (); + /************************** COP1: W functions ************************/ + static void COP1_W_CVT_S (); + static void COP1_W_CVT_D (); - /************************** Other functions **************************/ - static void UnknownOpcode (); - - - static void BeforeCallDirect(CRegInfo & RegSet); - static void AfterCallDirect(CRegInfo & RegSet); - static void EnterCodeBlock(); - static void ExitCodeBlock(); - static void CompileReadTLBMiss(DWORD VirtualAddress, x86Reg LookUpReg); - static void CompileReadTLBMiss(x86Reg AddressReg, x86Reg LookUpReg); - static void CompileWriteTLBMiss(x86Reg AddressReg, x86Reg LookUpReg); - static void UpdateSyncCPU(CRegInfo & RegSet, DWORD Cycles); - static void UpdateCounters(CRegInfo & RegSet, bool CheckTimer, bool ClearValues = false); - static void CompileSystemCheck(DWORD TargetPC, const CRegInfo & RegSet); - static void ChangeDefaultRoundingModel(); - static void OverflowDelaySlot(bool TestTimer); + /************************** COP1: L functions ************************/ + static void COP1_L_CVT_S (); + static void COP1_L_CVT_D (); + /************************** Other functions **************************/ + static void UnknownOpcode (); + static void BeforeCallDirect(CRegInfo & RegSet); + static void AfterCallDirect(CRegInfo & RegSet); + static void EnterCodeBlock(); + static void ExitCodeBlock(); + static void CompileReadTLBMiss(uint32_t VirtualAddress, x86Reg LookUpReg); + static void CompileReadTLBMiss(x86Reg AddressReg, x86Reg LookUpReg); + static void CompileWriteTLBMiss(x86Reg AddressReg, x86Reg LookUpReg); + static void UpdateSyncCPU(CRegInfo & RegSet, uint32_t Cycles); + static void UpdateCounters(CRegInfo & RegSet, bool CheckTimer, bool ClearValues = false); + static void CompileSystemCheck(uint32_t TargetPC, const CRegInfo & RegSet); + static void ChangeDefaultRoundingModel(); + static void OverflowDelaySlot(bool TestTimer); - static STEP_TYPE m_NextInstruction; - static DWORD m_CompilePC; - static OPCODE m_Opcode; - static CRegInfo m_RegWorkingSet; - static DWORD m_BranchCompare; - static CCodeSection * m_Section; + static STEP_TYPE m_NextInstruction; + static uint32_t m_CompilePC; + static OPCODE m_Opcode; + static CRegInfo m_RegWorkingSet; + static uint32_t m_BranchCompare; + static CCodeSection * m_Section; - /********* Helper Functions *********/ - typedef CRegInfo::REG_STATE REG_STATE; + /********* Helper Functions *********/ + typedef CRegInfo::REG_STATE REG_STATE; - static REG_STATE GetMipsRegState ( int Reg ) { return m_RegWorkingSet.GetMipsRegState(Reg); } - static unsigned __int64 GetMipsReg ( int Reg ) { return m_RegWorkingSet.GetMipsReg(Reg); } - static __int64 GetMipsReg_S ( int Reg ) { return m_RegWorkingSet.GetMipsReg_S(Reg); } - static DWORD GetMipsRegLo ( int Reg ) { return m_RegWorkingSet.GetMipsRegLo(Reg); } - static long GetMipsRegLo_S ( int Reg ) { return m_RegWorkingSet.GetMipsRegLo_S(Reg); } - static DWORD GetMipsRegHi ( int Reg ) { return m_RegWorkingSet.GetMipsRegHi(Reg); } - static long GetMipsRegHi_S ( int Reg ) { return m_RegWorkingSet.GetMipsRegHi_S(Reg); } - static CX86Ops::x86Reg GetMipsRegMapLo ( int Reg ) { return m_RegWorkingSet.GetMipsRegMapLo(Reg); } - static CX86Ops::x86Reg GetMipsRegMapHi ( int Reg ) { return m_RegWorkingSet.GetMipsRegMapHi(Reg); } + static REG_STATE GetMipsRegState ( int32_t Reg ) { return m_RegWorkingSet.GetMipsRegState(Reg); } + static uint64_t GetMipsReg ( int32_t Reg ) { return m_RegWorkingSet.GetMipsReg(Reg); } + static int64_t GetMipsReg_S ( int32_t Reg ) { return m_RegWorkingSet.GetMipsReg_S(Reg); } + static uint32_t GetMipsRegLo ( int32_t Reg ) { return m_RegWorkingSet.GetMipsRegLo(Reg); } + static int32_t GetMipsRegLo_S ( int32_t Reg ) { return m_RegWorkingSet.GetMipsRegLo_S(Reg); } + static uint32_t GetMipsRegHi ( int32_t Reg ) { return m_RegWorkingSet.GetMipsRegHi(Reg); } + static int32_t GetMipsRegHi_S ( int32_t Reg ) { return m_RegWorkingSet.GetMipsRegHi_S(Reg); } + static CX86Ops::x86Reg GetMipsRegMapLo ( int32_t Reg ) { return m_RegWorkingSet.GetMipsRegMapLo(Reg); } + static CX86Ops::x86Reg GetMipsRegMapHi ( int32_t Reg ) { return m_RegWorkingSet.GetMipsRegMapHi(Reg); } - static bool IsKnown ( int Reg ) { return m_RegWorkingSet.IsKnown(Reg); } - static bool IsUnknown ( int Reg ) { return m_RegWorkingSet.IsUnknown(Reg); } - static bool IsMapped ( int Reg ) { return m_RegWorkingSet.IsMapped(Reg); } - static bool IsConst ( int Reg ) { return m_RegWorkingSet.IsConst(Reg); } - static bool IsSigned ( int Reg ) { return m_RegWorkingSet.IsSigned(Reg); } - static bool IsUnsigned ( int Reg ) { return m_RegWorkingSet.IsUnsigned(Reg); } - static bool Is32Bit ( int Reg ) { return m_RegWorkingSet.Is32Bit(Reg); } - static bool Is64Bit ( int Reg ) { return m_RegWorkingSet.Is64Bit(Reg); } - static bool Is32BitMapped ( int Reg ) { return m_RegWorkingSet.Is32BitMapped(Reg); } - static bool Is64BitMapped ( int Reg ) { return m_RegWorkingSet.Is64BitMapped(Reg); } + static bool IsKnown ( int32_t Reg ) { return m_RegWorkingSet.IsKnown(Reg); } + static bool IsUnknown ( int32_t Reg ) { return m_RegWorkingSet.IsUnknown(Reg); } + static bool IsMapped ( int32_t Reg ) { return m_RegWorkingSet.IsMapped(Reg); } + static bool IsConst ( int32_t Reg ) { return m_RegWorkingSet.IsConst(Reg); } + static bool IsSigned ( int32_t Reg ) { return m_RegWorkingSet.IsSigned(Reg); } + static bool IsUnsigned ( int32_t Reg ) { return m_RegWorkingSet.IsUnsigned(Reg); } + static bool Is32Bit ( int32_t Reg ) { return m_RegWorkingSet.Is32Bit(Reg); } + static bool Is64Bit ( int32_t Reg ) { return m_RegWorkingSet.Is64Bit(Reg); } + static bool Is32BitMapped ( int32_t Reg ) { return m_RegWorkingSet.Is32BitMapped(Reg); } + static bool Is64BitMapped ( int32_t Reg ) { return m_RegWorkingSet.Is64BitMapped(Reg); } - static void FixRoundModel ( CRegInfo::FPU_ROUND RoundMethod ) - { - m_RegWorkingSet.FixRoundModel(RoundMethod); - } - static void ChangeFPURegFormat ( int Reg, CRegInfo::FPU_STATE OldFormat, CRegInfo::FPU_STATE NewFormat, CRegInfo::FPU_ROUND RoundingModel ) - { - m_RegWorkingSet.ChangeFPURegFormat(Reg,OldFormat,NewFormat,RoundingModel); - } - static void Load_FPR_ToTop ( int Reg, int RegToLoad, CRegInfo::FPU_STATE Format) - { - m_RegWorkingSet.Load_FPR_ToTop(Reg,RegToLoad,Format); - } - static bool RegInStack ( int Reg, CRegInfo::FPU_STATE Format ) - { - return m_RegWorkingSet.RegInStack(Reg,Format); - } - static x86FpuValues StackPosition ( int Reg ) - { - return m_RegWorkingSet.StackPosition(Reg); - } - static void UnMap_AllFPRs() - { - m_RegWorkingSet.UnMap_AllFPRs(); - } - static void UnMap_FPR ( DWORD Reg, bool WriteBackValue ) - { - m_RegWorkingSet.UnMap_FPR(Reg,WriteBackValue); - } + static void FixRoundModel ( CRegInfo::FPU_ROUND RoundMethod ) + { + m_RegWorkingSet.FixRoundModel(RoundMethod); + } + static void ChangeFPURegFormat ( int32_t Reg, CRegInfo::FPU_STATE OldFormat, CRegInfo::FPU_STATE NewFormat, CRegInfo::FPU_ROUND RoundingModel ) + { + m_RegWorkingSet.ChangeFPURegFormat(Reg,OldFormat,NewFormat,RoundingModel); + } + static void Load_FPR_ToTop ( int32_t Reg, int32_t RegToLoad, CRegInfo::FPU_STATE Format) + { + m_RegWorkingSet.Load_FPR_ToTop(Reg,RegToLoad,Format); + } + static bool RegInStack ( int32_t Reg, CRegInfo::FPU_STATE Format ) + { + return m_RegWorkingSet.RegInStack(Reg,Format); + } + static x86FpuValues StackPosition ( int32_t Reg ) + { + return m_RegWorkingSet.StackPosition(Reg); + } + static void UnMap_AllFPRs() + { + m_RegWorkingSet.UnMap_AllFPRs(); + } + static void UnMap_FPR ( uint32_t Reg, bool WriteBackValue ) + { + m_RegWorkingSet.UnMap_FPR(Reg,WriteBackValue); + } - static x86Reg FreeX86Reg() - { - return m_RegWorkingSet.FreeX86Reg(); - } - static x86Reg Free8BitX86Reg() - { - return m_RegWorkingSet.Free8BitX86Reg(); - } - static void Map_GPR_32bit ( int Reg, bool SignValue, int MipsRegToLoad ) - { - m_RegWorkingSet.Map_GPR_32bit(Reg,SignValue,MipsRegToLoad); - } - static void Map_GPR_64bit ( int Reg, int MipsRegToLoad ) - { - m_RegWorkingSet.Map_GPR_64bit(Reg,MipsRegToLoad); - } - static x86Reg Get_MemoryStack() - { - return m_RegWorkingSet.Get_MemoryStack(); - } - static x86Reg Map_MemoryStack ( x86Reg Reg, bool bMapRegister, bool LoadValue = true ) - { - return m_RegWorkingSet.Map_MemoryStack(Reg,bMapRegister,LoadValue); - } - static x86Reg Map_TempReg ( x86Reg Reg, int MipsReg, bool LoadHiWord ) - { - return m_RegWorkingSet.Map_TempReg(Reg,MipsReg,LoadHiWord); - } - static void ProtectGPR ( DWORD Reg ) - { - m_RegWorkingSet.ProtectGPR(Reg); - } - static void UnProtectGPR ( DWORD Reg ) - { - m_RegWorkingSet.UnProtectGPR(Reg); - } - static void ResetX86Protection() - { - m_RegWorkingSet.ResetX86Protection(); - } - static x86Reg UnMap_TempReg() - { - return m_RegWorkingSet.UnMap_TempReg(); - } - static void UnMap_GPR ( DWORD Reg, bool WriteBackValue ) - { - m_RegWorkingSet.UnMap_GPR(Reg,WriteBackValue); - } - static bool UnMap_X86reg ( x86Reg Reg ) - { - return m_RegWorkingSet.UnMap_X86reg(Reg); - } + static x86Reg FreeX86Reg() + { + return m_RegWorkingSet.FreeX86Reg(); + } + static x86Reg Free8BitX86Reg() + { + return m_RegWorkingSet.Free8BitX86Reg(); + } + static void Map_GPR_32bit ( int32_t Reg, bool SignValue, int32_t MipsRegToLoad ) + { + m_RegWorkingSet.Map_GPR_32bit(Reg,SignValue,MipsRegToLoad); + } + static void Map_GPR_64bit ( int32_t Reg, int32_t MipsRegToLoad ) + { + m_RegWorkingSet.Map_GPR_64bit(Reg,MipsRegToLoad); + } + static x86Reg Get_MemoryStack() + { + return m_RegWorkingSet.Get_MemoryStack(); + } + static x86Reg Map_MemoryStack ( x86Reg Reg, bool bMapRegister, bool LoadValue = true ) + { + return m_RegWorkingSet.Map_MemoryStack(Reg,bMapRegister,LoadValue); + } + static x86Reg Map_TempReg ( x86Reg Reg, int32_t MipsReg, bool LoadHiWord ) + { + return m_RegWorkingSet.Map_TempReg(Reg,MipsReg,LoadHiWord); + } + static void ProtectGPR ( uint32_t Reg ) + { + m_RegWorkingSet.ProtectGPR(Reg); + } + static void UnProtectGPR ( uint32_t Reg ) + { + m_RegWorkingSet.UnProtectGPR(Reg); + } + static void ResetX86Protection() + { + m_RegWorkingSet.ResetX86Protection(); + } + static x86Reg UnMap_TempReg() + { + return m_RegWorkingSet.UnMap_TempReg(); + } + static void UnMap_GPR ( uint32_t Reg, bool WriteBackValue ) + { + m_RegWorkingSet.UnMap_GPR(Reg,WriteBackValue); + } + static bool UnMap_X86reg ( x86Reg Reg ) + { + return m_RegWorkingSet.UnMap_X86reg(Reg); + } public: - static DWORD CompilePC() { return m_CompilePC; } + static uint32_t CompilePC() { return m_CompilePC; } }; From 8f694e157f8c7116b3fa5cfbbcdceb08efb61117 Mon Sep 17 00:00:00 2001 From: zilmar Date: Tue, 10 Nov 2015 07:07:54 +1100 Subject: [PATCH 108/213] [Project64] update Function Info to use standard types --- .../N64 System/Recompiler/Code Section.cpp | 36 +++---- .../N64 System/Recompiler/Function Info.cpp | 21 ++-- .../N64 System/Recompiler/Function Info.h | 55 +++++------ .../Recompiler/Function Map Class.cpp | 97 ++++++++++--------- .../Recompiler/Function Map Class.h | 22 ++--- 5 files changed, 116 insertions(+), 115 deletions(-) diff --git a/Source/Project64/N64 System/Recompiler/Code Section.cpp b/Source/Project64/N64 System/Recompiler/Code Section.cpp index aca74d90b..d176ff6b3 100644 --- a/Source/Project64/N64 System/Recompiler/Code Section.cpp +++ b/Source/Project64/N64 System/Recompiler/Code Section.cpp @@ -486,11 +486,11 @@ void CCodeSection::GenerateSectionLinkage() { if (JumpInfo[i]->LinkLocation != NULL) { - SetJump32((uint32_t *)JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation = NULL; if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; } } @@ -503,11 +503,11 @@ void CCodeSection::GenerateSectionLinkage() if (JumpInfo[i]->TargetPC == TargetSection[i]->m_EnterPC) { continue; } if (JumpInfo[i]->LinkLocation != NULL) { - SetJump32((uint32_t *)JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation = NULL; if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; } } @@ -540,11 +540,11 @@ void CCodeSection::GenerateSectionLinkage() JumpInfo[i]->FallThrough = false; if (JumpInfo[i]->LinkLocation != NULL) { - SetJump32((uint32_t *)JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation = NULL; if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; } } @@ -649,11 +649,11 @@ void CCodeSection::GenerateSectionLinkage() if (TargetSection[i] == NULL) { CPU_Message("ExitBlock (from %d):", m_SectionID); - SetJump32((uint32_t *)JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation = NULL; if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; } CompileExit(JumpInfo[i]->JumpPC, JumpInfo[i]->TargetPC, JumpInfo[i]->RegSet, JumpInfo[i]->ExitReason, true, NULL); @@ -672,11 +672,11 @@ void CCodeSection::GenerateSectionLinkage() stdstr_f Label("Section_%d (from %d):", TargetSection[i]->m_SectionID, m_SectionID); CPU_Message(Label.c_str()); - SetJump32((uint32_t *)JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation, (uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation = NULL; if (JumpInfo[i]->LinkLocation2 != NULL) { - SetJump32((uint32_t *)JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo[i]->LinkLocation2, (uint32_t *)m_RecompPos); JumpInfo[i]->LinkLocation2 = NULL; } m_RegWorkingSet = JumpInfo[i]->RegSet; @@ -1790,10 +1790,10 @@ bool CCodeSection::InheritParentInfo() if (JumpInfo->LinkLocation != NULL) { CPU_Message(" Section_%d:", m_SectionID); - SetJump32((uint32_t *)JumpInfo->LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo->LinkLocation, (uint32_t *)m_RecompPos); if (JumpInfo->LinkLocation2 != NULL) { - SetJump32((uint32_t *)JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos); } } m_RegWorkingSet = m_RegEnter; @@ -1883,11 +1883,11 @@ bool CCodeSection::InheritParentInfo() if (JumpInfo->LinkLocation != NULL) { CPU_Message(" Section_%d (from %d):", m_SectionID, Parent->m_SectionID); - SetJump32((uint32_t *)JumpInfo->LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo->LinkLocation, (uint32_t *)m_RecompPos); JumpInfo->LinkLocation = NULL; if (JumpInfo->LinkLocation2 != NULL) { - SetJump32((uint32_t *)JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos); JumpInfo->LinkLocation2 = NULL; } } @@ -2150,11 +2150,11 @@ bool CCodeSection::InheritParentInfo() CPU_Message(" Section_%d (from %d):", m_SectionID, Parent->m_SectionID); if (JumpInfo->LinkLocation != NULL) { - SetJump32((uint32_t *)JumpInfo->LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo->LinkLocation, (uint32_t *)m_RecompPos); JumpInfo->LinkLocation = NULL; if (JumpInfo->LinkLocation2 != NULL) { - SetJump32((uint32_t *)JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos); JumpInfo->LinkLocation2 = NULL; } } @@ -2184,11 +2184,11 @@ bool CCodeSection::InheritParentInfo() if (JumpInfo->LinkLocation != NULL) { - SetJump32((uint32_t *)JumpInfo->LinkLocation, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo->LinkLocation, (uint32_t *)m_RecompPos); JumpInfo->LinkLocation = NULL; if (JumpInfo->LinkLocation2 != NULL) { - SetJump32((uint32_t *)JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos); + SetJump32(JumpInfo->LinkLocation2, (uint32_t *)m_RecompPos); JumpInfo->LinkLocation2 = NULL; } } diff --git a/Source/Project64/N64 System/Recompiler/Function Info.cpp b/Source/Project64/N64 System/Recompiler/Function Info.cpp index 38b694ff1..2721ec1aa 100644 --- a/Source/Project64/N64 System/Recompiler/Function Info.cpp +++ b/Source/Project64/N64 System/Recompiler/Function Info.cpp @@ -11,16 +11,15 @@ #include "stdafx.h" CCompiledFunc::CCompiledFunc( const CCodeBlock & CodeBlock ) : - m_EnterPC(CodeBlock.VAddrEnter()), - m_MinPC(CodeBlock.VAddrFirst()), - m_MaxPC(CodeBlock.VAddrLast()), - m_Hash(CodeBlock.Hash()), - m_Function((Func)CodeBlock.CompiledLocation()), - m_Next(NULL) + m_EnterPC(CodeBlock.VAddrEnter()), + m_MinPC(CodeBlock.VAddrFirst()), + m_MaxPC(CodeBlock.VAddrLast()), + m_Hash(CodeBlock.Hash()), + m_Function((Func)CodeBlock.CompiledLocation()), + m_Next(NULL) { - m_MemContents[0] = CodeBlock.MemContents(0); - m_MemContents[1] = CodeBlock.MemContents(1); - m_MemLocation[0] = CodeBlock.MemLocation(0); - m_MemLocation[1] = CodeBlock.MemLocation(1); + m_MemContents[0] = CodeBlock.MemContents(0); + m_MemContents[1] = CodeBlock.MemContents(1); + m_MemLocation[0] = CodeBlock.MemLocation(0); + m_MemLocation[1] = CodeBlock.MemLocation(1); } - diff --git a/Source/Project64/N64 System/Recompiler/Function Info.h b/Source/Project64/N64 System/Recompiler/Function Info.h index 1b3840372..0aaa2d960 100644 --- a/Source/Project64/N64 System/Recompiler/Function Info.h +++ b/Source/Project64/N64 System/Recompiler/Function Info.h @@ -12,41 +12,42 @@ class CCompiledFunc { - //constructor - CCompiledFunc(); // not implemented - public: - CCompiledFunc(const CCodeBlock & CodeBlock); + CCompiledFunc(const CCodeBlock & CodeBlock); - typedef void (*Func)(); + typedef void (*Func)(); - //Get Private Information - const DWORD EnterPC () const { return m_EnterPC; } - const DWORD MinPC () const { return m_MinPC; } - const DWORD MaxPC () const { return m_MaxPC; } - const Func Function () const { return m_Function; } - const MD5Digest& Hash () const { return m_Hash; } + //Get Private Information + const uint32_t EnterPC () const { return m_EnterPC; } + const uint32_t MinPC () const { return m_MinPC; } + const uint32_t MaxPC () const { return m_MaxPC; } + const Func Function () const { return m_Function; } + const MD5Digest& Hash () const { return m_Hash; } - CCompiledFunc* Next () const { return m_Next; } - void SetNext(CCompiledFunc* Next) { m_Next = Next; } + CCompiledFunc* Next () const { return m_Next; } + void SetNext(CCompiledFunc* Next) { m_Next = Next; } - QWORD MemContents(int i) { return m_MemContents[i]; } - QWORD* MemLocation(int i) { return m_MemLocation[i]; } + uint64_t MemContents(int32_t i) { return m_MemContents[i]; } + uint64_t* MemLocation(int32_t i) { return m_MemLocation[i]; } private: - //Information - DWORD m_EnterPC; // The Entry PC - DWORD m_MinPC; // The Lowest PC in the function - DWORD m_MaxPC; // The Highest PC in the function + CCompiledFunc(void); // Disable default constructor + CCompiledFunc(const CCompiledFunc&); // Disable copy constructor + CCompiledFunc& operator=(const CCompiledFunc&); // Disable assignment - MD5Digest m_Hash; - //From querying the recompiler get information about the function - Func m_Function; + //Information + uint32_t m_EnterPC; // The Entry PC + uint32_t m_MinPC; // The Lowest PC in the function + uint32_t m_MaxPC; // The Highest PC in the function - CCompiledFunc* m_Next; - - //Validation - QWORD m_MemContents[2], * m_MemLocation[2]; + MD5Digest m_Hash; + //From querying the recompiler get information about the function + Func m_Function; + + CCompiledFunc* m_Next; + + //Validation + uint64_t m_MemContents[2], * m_MemLocation[2]; }; -typedef std::map CCompiledFuncList; +typedef std::map CCompiledFuncList; diff --git a/Source/Project64/N64 System/Recompiler/Function Map Class.cpp b/Source/Project64/N64 System/Recompiler/Function Map Class.cpp index 4c20dbe08..a76fc1901 100644 --- a/Source/Project64/N64 System/Recompiler/Function Map Class.cpp +++ b/Source/Project64/N64 System/Recompiler/Function Map Class.cpp @@ -11,68 +11,69 @@ #include "stdafx.h" CFunctionMap::CFunctionMap() : - m_JumpTable(NULL), - m_FunctionTable(NULL) + m_JumpTable(NULL), + m_FunctionTable(NULL) { } CFunctionMap::~CFunctionMap() { - CleanBuffers(); + CleanBuffers(); } bool CFunctionMap::AllocateMemory() { - if (g_System->LookUpMode() == FuncFind_VirtualLookup && m_FunctionTable == NULL) - { - m_FunctionTable = (PCCompiledFunc_TABLE *)VirtualAlloc(NULL,0xFFFFF * sizeof(CCompiledFunc *),MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE); - if (m_FunctionTable == NULL) { - WriteTrace(TraceError,__FUNCTION__ ": failed to allocate function table"); - g_Notify->FatalError(MSG_MEM_ALLOC_ERROR); - return false; - } - memset(m_FunctionTable,0,0xFFFFF * sizeof(CCompiledFunc *)); - } - if (g_System->LookUpMode() == FuncFind_PhysicalLookup && m_JumpTable == NULL) - { - m_JumpTable = new PCCompiledFunc[g_MMU->RdramSize() >> 2]; - if (m_JumpTable == NULL) - { - WriteTrace(TraceError,__FUNCTION__ ": failed to allocate jump table"); - g_Notify->FatalError(MSG_MEM_ALLOC_ERROR); - return false; - } - memset(m_JumpTable,0,(g_MMU->RdramSize() >> 2) * sizeof(PCCompiledFunc)); - } - return true; + if (g_System->LookUpMode() == FuncFind_VirtualLookup && m_FunctionTable == NULL) + { + m_FunctionTable = (PCCompiledFunc_TABLE *)VirtualAlloc(NULL, 0xFFFFF * sizeof(CCompiledFunc *), MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); + if (m_FunctionTable == NULL) + { + WriteTrace(TraceError, __FUNCTION__ ": failed to allocate function table"); + g_Notify->FatalError(MSG_MEM_ALLOC_ERROR); + return false; + } + memset(m_FunctionTable, 0, 0xFFFFF * sizeof(CCompiledFunc *)); + } + if (g_System->LookUpMode() == FuncFind_PhysicalLookup && m_JumpTable == NULL) + { + m_JumpTable = new PCCompiledFunc[g_MMU->RdramSize() >> 2]; + if (m_JumpTable == NULL) + { + WriteTrace(TraceError, __FUNCTION__ ": failed to allocate jump table"); + g_Notify->FatalError(MSG_MEM_ALLOC_ERROR); + return false; + } + memset(m_JumpTable, 0, (g_MMU->RdramSize() >> 2) * sizeof(PCCompiledFunc)); + } + return true; } void CFunctionMap::CleanBuffers() { - if (m_FunctionTable) - { - for (int i = 0, n = 0x100000; i < n; i++) - { - if (m_FunctionTable[i] != NULL) - { - delete m_FunctionTable[i]; - } - } - VirtualFree( m_FunctionTable, 0 , MEM_RELEASE); - m_FunctionTable = NULL; - } - if (m_JumpTable) - { - delete [] m_JumpTable; - m_JumpTable = NULL; - } + if (m_FunctionTable) + { + for (int i = 0, n = 0x100000; i < n; i++) + { + if (m_FunctionTable[i] != NULL) + { + delete m_FunctionTable[i]; + } + } + VirtualFree(m_FunctionTable, 0, MEM_RELEASE); + m_FunctionTable = NULL; + } + if (m_JumpTable) + { + delete[] m_JumpTable; + m_JumpTable = NULL; + } } -void CFunctionMap::Reset ( bool bAllocate ) +void CFunctionMap::Reset(bool bAllocate) { - CleanBuffers(); - if (bAllocate && (g_System->LookUpMode() == FuncFind_VirtualLookup || g_System->LookUpMode() == FuncFind_PhysicalLookup)) - { - AllocateMemory(); - } + CleanBuffers(); + if (bAllocate && (g_System->LookUpMode() == FuncFind_VirtualLookup || g_System->LookUpMode() == FuncFind_PhysicalLookup)) + { + AllocateMemory(); + } } diff --git a/Source/Project64/N64 System/Recompiler/Function Map Class.h b/Source/Project64/N64 System/Recompiler/Function Map Class.h index b79673895..49ad9c679 100644 --- a/Source/Project64/N64 System/Recompiler/Function Map Class.h +++ b/Source/Project64/N64 System/Recompiler/Function Map Class.h @@ -13,22 +13,22 @@ class CFunctionMap { protected: - typedef CCompiledFunc * PCCompiledFunc; - typedef PCCompiledFunc * PCCompiledFunc_TABLE; + typedef CCompiledFunc * PCCompiledFunc; + typedef PCCompiledFunc * PCCompiledFunc_TABLE; - CFunctionMap(); - ~CFunctionMap(); + CFunctionMap(); + ~CFunctionMap(); - bool AllocateMemory(); - void Reset(bool bAllocate); + bool AllocateMemory(); + void Reset(bool bAllocate); public: - PCCompiledFunc_TABLE * FunctionTable() const { return m_FunctionTable; } - PCCompiledFunc * JumpTable() const { return m_JumpTable; } + PCCompiledFunc_TABLE * FunctionTable() const { return m_FunctionTable; } + PCCompiledFunc * JumpTable() const { return m_JumpTable; } private: - void CleanBuffers(); + void CleanBuffers(); - PCCompiledFunc * m_JumpTable; - PCCompiledFunc_TABLE * m_FunctionTable; + PCCompiledFunc * m_JumpTable; + PCCompiledFunc_TABLE * m_FunctionTable; }; From 0c00b9033441766cb7e27cb3ae944304ca717647 Mon Sep 17 00:00:00 2001 From: zilmar Date: Tue, 10 Nov 2015 07:10:34 +1100 Subject: [PATCH 109/213] [Project64] Change Loop Analysis.cpp to use standard types --- .../N64 System/Recompiler/Loop Analysis.cpp | 2046 +++++++++-------- .../N64 System/Recompiler/Loop Analysis.h | 120 +- 2 files changed, 1129 insertions(+), 1037 deletions(-) diff --git a/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp b/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp index c07be8800..bdf61c8e8 100644 --- a/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp +++ b/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp @@ -17,1212 +17,1304 @@ bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2); LoopAnalysis::LoopAnalysis(CCodeBlock * CodeBlock, CCodeSection * Section) : - m_EnterSection(Section), - m_BlockInfo(CodeBlock), - m_PC((DWORD)-1), - m_NextInstruction(NORMAL), - m_Test(m_BlockInfo->NextTest()) + m_EnterSection(Section), + m_BlockInfo(CodeBlock), + m_PC((uint32_t)-1), + m_NextInstruction(NORMAL), + m_Test(m_BlockInfo->NextTest()) { - memset(&m_Command,0,sizeof(m_Command)); + memset(&m_Command, 0, sizeof(m_Command)); } LoopAnalysis::~LoopAnalysis() { - for (RegisterMap::iterator itr = m_EnterRegisters.begin(); itr != m_EnterRegisters.end(); itr++) - { - delete itr->second; - } - m_EnterRegisters.clear(); + for (RegisterMap::iterator itr = m_EnterRegisters.begin(); itr != m_EnterRegisters.end(); itr++) + { + delete itr->second; + } + m_EnterRegisters.clear(); - for (RegisterMap::iterator itr = m_ContinueRegisters.begin(); itr != m_ContinueRegisters.end(); itr++) - { - delete itr->second; - } - m_ContinueRegisters.clear(); + for (RegisterMap::iterator itr = m_ContinueRegisters.begin(); itr != m_ContinueRegisters.end(); itr++) + { + delete itr->second; + } + m_ContinueRegisters.clear(); - for (RegisterMap::iterator itr = m_JumpRegisters.begin(); itr != m_JumpRegisters.end(); itr++) - { - delete itr->second; - } - m_JumpRegisters.clear(); + for (RegisterMap::iterator itr = m_JumpRegisters.begin(); itr != m_JumpRegisters.end(); itr++) + { + delete itr->second; + } + m_JumpRegisters.clear(); } bool LoopAnalysis::SetupRegisterForLoop() { - if (!m_EnterSection->m_InLoop) - { - return false; - } - CPU_Message(__FUNCTION__ ": Section ID: %d Test: %X",m_EnterSection->m_SectionID,m_Test); - if (!CheckLoopRegisterUsage(m_EnterSection)) - { - return false; - } + if (!m_EnterSection->m_InLoop) + { + return false; + } + CPU_Message(__FUNCTION__ ": Section ID: %d Test: %X", m_EnterSection->m_SectionID, m_Test); + if (!CheckLoopRegisterUsage(m_EnterSection)) + { + return false; + } - RegisterMap::iterator itr = m_EnterRegisters.find(m_EnterSection->m_SectionID); - if (itr == m_EnterRegisters.end()) - { - return false; - } - m_EnterSection->m_RegEnter = *(itr->second); - return true; + RegisterMap::iterator itr = m_EnterRegisters.find(m_EnterSection->m_SectionID); + if (itr == m_EnterRegisters.end()) + { + return false; + } + m_EnterSection->m_RegEnter = *(itr->second); + return true; } -bool LoopAnalysis::SetupEnterSection ( CCodeSection * Section, bool & bChanged, bool & bSkipedSection ) +bool LoopAnalysis::SetupEnterSection(CCodeSection * Section, bool & bChanged, bool & bSkipedSection) { - bChanged = false; - bSkipedSection = false; - if (Section->m_ParentSection.empty()) { g_Notify->BreakPoint(__FILEW__,__LINE__); return true; } + bChanged = false; + bSkipedSection = false; + if (Section->m_ParentSection.empty()) { g_Notify->BreakPoint(__FILEW__, __LINE__); return true; } - CPU_Message(__FUNCTION__ ": Block EnterPC: %X Section ID %d Test: %X Section Test: %X CompiledLocation: %X",m_BlockInfo->VAddrEnter(),Section->m_SectionID,m_Test,Section->m_Test, Section->m_CompiledLocation); + CPU_Message(__FUNCTION__ ": Block EnterPC: %X Section ID %d Test: %X Section Test: %X CompiledLocation: %X", m_BlockInfo->VAddrEnter(), Section->m_SectionID, m_Test, Section->m_Test, Section->m_CompiledLocation); - bool bFirstParent = true; - CRegInfo RegEnter; - for (CCodeSection::SECTION_LIST::iterator iter = Section->m_ParentSection.begin(); iter != Section->m_ParentSection.end(); iter++) - { - CCodeSection * Parent = *iter; + bool bFirstParent = true; + CRegInfo RegEnter; + for (CCodeSection::SECTION_LIST::iterator iter = Section->m_ParentSection.begin(); iter != Section->m_ParentSection.end(); iter++) + { + CCodeSection * Parent = *iter; - CPU_Message(__FUNCTION__ ": Parent Section ID %d Test: %X Section Test: %X CompiledLocation: %X",Parent->m_SectionID,m_Test,Parent->m_Test, Parent->m_CompiledLocation); - if (Parent->m_Test != m_Test && (m_EnterSection != Section || Parent->m_CompiledLocation == NULL) && Parent->m_InLoop) - { - CPU_Message(__FUNCTION__ ": Ignore Parent Section ID %d Test: %X Section Test: %X CompiledLocation: %X",Parent->m_SectionID,m_Test,Parent->m_Test, Parent->m_CompiledLocation); - bSkipedSection = true; - continue; - } - RegisterMap::iterator Continue_itr = m_ContinueRegisters.find(Parent->m_SectionID); - RegisterMap::iterator Jump_itr = m_JumpRegisters.find(Parent->m_SectionID); + CPU_Message(__FUNCTION__ ": Parent Section ID %d Test: %X Section Test: %X CompiledLocation: %X", Parent->m_SectionID, m_Test, Parent->m_Test, Parent->m_CompiledLocation); + if (Parent->m_Test != m_Test && (m_EnterSection != Section || Parent->m_CompiledLocation == NULL) && Parent->m_InLoop) + { + CPU_Message(__FUNCTION__ ": Ignore Parent Section ID %d Test: %X Section Test: %X CompiledLocation: %X", Parent->m_SectionID, m_Test, Parent->m_Test, Parent->m_CompiledLocation); + bSkipedSection = true; + continue; + } + RegisterMap::iterator Continue_itr = m_ContinueRegisters.find(Parent->m_SectionID); + RegisterMap::iterator Jump_itr = m_JumpRegisters.find(Parent->m_SectionID); - CCodeSection * TargetSection[] = { Parent->m_ContinueSection, Parent->m_JumpSection }; - CRegInfo * JumpRegInfo[] = { - Continue_itr == m_ContinueRegisters.end() ? &Parent->m_Cont.RegSet : Continue_itr->second, - Jump_itr == m_JumpRegisters.end() ? &Parent->m_Jump.RegSet : Jump_itr->second - }; + CCodeSection * TargetSection[] = { Parent->m_ContinueSection, Parent->m_JumpSection }; + CRegInfo * JumpRegInfo[] = + { + Continue_itr == m_ContinueRegisters.end() ? &Parent->m_Cont.RegSet : Continue_itr->second, + Jump_itr == m_JumpRegisters.end() ? &Parent->m_Jump.RegSet : Jump_itr->second + }; - for (int i = 0; i < 2; i++) - { - if (TargetSection[i] != Section) { continue; } - if (bFirstParent) - { - bFirstParent = false; - RegEnter = *JumpRegInfo[i]; - } else { - if (*JumpRegInfo[i] == RegEnter) - { - continue; - } + for (int i = 0; i < 2; i++) + { + if (TargetSection[i] != Section) { continue; } + if (bFirstParent) + { + bFirstParent = false; + RegEnter = *JumpRegInfo[i]; + } + else + { + if (*JumpRegInfo[i] == RegEnter) + { + continue; + } - SyncRegState(RegEnter,*JumpRegInfo[i]); - } - } - } + SyncRegState(RegEnter, *JumpRegInfo[i]); + } + } + } - if (bFirstParent) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + if (bFirstParent) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } - RegisterMap::iterator itr = m_EnterRegisters.find(Section->m_SectionID); - if (itr != m_EnterRegisters.end()) - { - if (SyncRegState(*(itr->second),RegEnter)) - { - bChanged = true; - } - } else { - m_EnterRegisters.insert(RegisterMap::value_type(Section->m_SectionID,new CRegInfo(RegEnter))); - } - return true; + RegisterMap::iterator itr = m_EnterRegisters.find(Section->m_SectionID); + if (itr != m_EnterRegisters.end()) + { + if (SyncRegState(*(itr->second), RegEnter)) + { + bChanged = true; + } + } + else + { + m_EnterRegisters.insert(RegisterMap::value_type(Section->m_SectionID, new CRegInfo(RegEnter))); + } + return true; } -bool LoopAnalysis::CheckLoopRegisterUsage( CCodeSection * Section) +bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section) { - if (Section == NULL) { return true; } - if (!Section->m_InLoop) { return true; } + if (Section == NULL) { return true; } + if (!Section->m_InLoop) { return true; } - CPU_Message(__FUNCTION__ ": Section %d Block PC: 0x%X",Section->m_SectionID,m_BlockInfo->VAddrEnter()); + CPU_Message(__FUNCTION__ ": Section %d Block PC: 0x%X", Section->m_SectionID, m_BlockInfo->VAddrEnter()); - bool bChanged = false, bSkipedSection = false; - if (Section == m_EnterSection && Section->m_Test == m_Test) - { - if (!SetupEnterSection(Section,bChanged,bSkipedSection)) { return false; } - return true; - } + bool bChanged = false, bSkipedSection = false; + if (Section == m_EnterSection && Section->m_Test == m_Test) + { + if (!SetupEnterSection(Section, bChanged, bSkipedSection)) { return false; } + return true; + } - if (!SetupEnterSection(Section,bChanged,bSkipedSection)) { return false; } - - if (Section->m_Test == m_Test && !bChanged) - { - return true; - } + if (!SetupEnterSection(Section, bChanged, bSkipedSection)) { return false; } - CPU_Message(__FUNCTION__ ": Set Section %d test to %X from %X",Section->m_SectionID,m_Test,Section->m_Test); - Section->m_Test = m_Test; - m_PC = Section->m_EnterPC; + if (Section->m_Test == m_Test && !bChanged) + { + return true; + } - RegisterMap::iterator itr = m_EnterRegisters.find(Section->m_SectionID); - m_Reg = itr != m_EnterRegisters.end() ? *(itr->second) : Section->m_RegEnter; + CPU_Message(__FUNCTION__ ": Set Section %d test to %X from %X", Section->m_SectionID, m_Test, Section->m_Test); + Section->m_Test = m_Test; + m_PC = Section->m_EnterPC; - m_NextInstruction = NORMAL; - DWORD ContinueSectionPC = Section->m_ContinueSection ? Section->m_ContinueSection->m_EnterPC : (DWORD)-1; - CPU_Message("ContinueSectionPC = %08X",ContinueSectionPC); + RegisterMap::iterator itr = m_EnterRegisters.find(Section->m_SectionID); + m_Reg = itr != m_EnterRegisters.end() ? *(itr->second) : Section->m_RegEnter; - do { - if (!g_MMU->LW_VAddr(m_PC, m_Command.Hex)) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - return false; - } - CPU_Message(" %08X: %s",m_PC,R4300iOpcodeName(m_Command.Hex,m_PC)); - CPU_Message(" %s state: %X value: %X",CRegName::GPR[3],m_Reg.GetMipsRegState(3),m_Reg.GetMipsRegLo(3)); - switch (m_Command.op) { - case R4300i_SPECIAL: - switch (m_Command.funct) { - case R4300i_SPECIAL_SLL: SPECIAL_SLL(); break; - case R4300i_SPECIAL_SRL: SPECIAL_SRL(); break; - case R4300i_SPECIAL_SRA: SPECIAL_SRA(); break; - case R4300i_SPECIAL_SLLV: SPECIAL_SLLV(); break; - case R4300i_SPECIAL_SRLV: SPECIAL_SRLV(); break; - case R4300i_SPECIAL_SRAV: SPECIAL_SRAV(); break; - case R4300i_SPECIAL_JR: SPECIAL_JR(); break; - case R4300i_SPECIAL_JALR: SPECIAL_JALR(); break; - case R4300i_SPECIAL_SYSCALL: SPECIAL_SYSCALL(Section); break; - case R4300i_SPECIAL_BREAK: SPECIAL_BREAK(Section); break; - case R4300i_SPECIAL_MFHI: SPECIAL_MFHI(); break; - case R4300i_SPECIAL_MTHI: SPECIAL_MTHI(); break; - case R4300i_SPECIAL_MFLO: SPECIAL_MFLO(); break; - case R4300i_SPECIAL_MTLO: SPECIAL_MTLO(); break; - case R4300i_SPECIAL_DSLLV: SPECIAL_DSLLV(); break; - case R4300i_SPECIAL_DSRLV: SPECIAL_DSRLV(); break; - case R4300i_SPECIAL_DSRAV: SPECIAL_DSRAV(); break; - case R4300i_SPECIAL_MULT: break; - case R4300i_SPECIAL_MULTU: break; - case R4300i_SPECIAL_DIV: break; - case R4300i_SPECIAL_DIVU: break; - case R4300i_SPECIAL_DMULT: break; - case R4300i_SPECIAL_DMULTU: break; - case R4300i_SPECIAL_DDIV: break; - case R4300i_SPECIAL_DDIVU: break; - case R4300i_SPECIAL_ADD: SPECIAL_ADD(); break; - case R4300i_SPECIAL_ADDU: SPECIAL_ADDU(); break; - case R4300i_SPECIAL_SUB: SPECIAL_SUB(); break; - case R4300i_SPECIAL_SUBU: SPECIAL_SUBU(); break; - case R4300i_SPECIAL_AND: SPECIAL_AND(); break; - case R4300i_SPECIAL_OR: SPECIAL_OR(); break; - case R4300i_SPECIAL_XOR: SPECIAL_XOR(); break; - case R4300i_SPECIAL_NOR: SPECIAL_NOR(); break; - case R4300i_SPECIAL_SLT: SPECIAL_SLT(); break; - case R4300i_SPECIAL_SLTU: SPECIAL_SLTU(); break; - case R4300i_SPECIAL_DADD: SPECIAL_DADD(); break; - case R4300i_SPECIAL_DADDU: SPECIAL_DADDU(); break; - case R4300i_SPECIAL_DSUB: SPECIAL_DSUB(); break; - case R4300i_SPECIAL_DSUBU: SPECIAL_DSUBU(); break; - case R4300i_SPECIAL_DSLL: SPECIAL_DSLL(); break; - case R4300i_SPECIAL_DSRL: SPECIAL_DSRL(); break; - case R4300i_SPECIAL_DSRA: SPECIAL_DSRA(); break; - case R4300i_SPECIAL_DSLL32: SPECIAL_DSLL32(); break; - case R4300i_SPECIAL_DSRL32: SPECIAL_DSRL32(); break; - case R4300i_SPECIAL_DSRA32: SPECIAL_DSRA32(); break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); + m_NextInstruction = NORMAL; + uint32_t ContinueSectionPC = Section->m_ContinueSection ? Section->m_ContinueSection->m_EnterPC : (uint32_t)-1; + CPU_Message("ContinueSectionPC = %08X", ContinueSectionPC); + + do + { + if (!g_MMU->LW_VAddr(m_PC, m_Command.Hex)) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + return false; + } + CPU_Message(" %08X: %s", m_PC, R4300iOpcodeName(m_Command.Hex, m_PC)); + CPU_Message(" %s state: %X value: %X", CRegName::GPR[3], m_Reg.GetMipsRegState(3), m_Reg.GetMipsRegLo(3)); + switch (m_Command.op) + { + case R4300i_SPECIAL: + switch (m_Command.funct) + { + case R4300i_SPECIAL_SLL: SPECIAL_SLL(); break; + case R4300i_SPECIAL_SRL: SPECIAL_SRL(); break; + case R4300i_SPECIAL_SRA: SPECIAL_SRA(); break; + case R4300i_SPECIAL_SLLV: SPECIAL_SLLV(); break; + case R4300i_SPECIAL_SRLV: SPECIAL_SRLV(); break; + case R4300i_SPECIAL_SRAV: SPECIAL_SRAV(); break; + case R4300i_SPECIAL_JR: SPECIAL_JR(); break; + case R4300i_SPECIAL_JALR: SPECIAL_JALR(); break; + case R4300i_SPECIAL_SYSCALL: SPECIAL_SYSCALL(Section); break; + case R4300i_SPECIAL_BREAK: SPECIAL_BREAK(Section); break; + case R4300i_SPECIAL_MFHI: SPECIAL_MFHI(); break; + case R4300i_SPECIAL_MTHI: SPECIAL_MTHI(); break; + case R4300i_SPECIAL_MFLO: SPECIAL_MFLO(); break; + case R4300i_SPECIAL_MTLO: SPECIAL_MTLO(); break; + case R4300i_SPECIAL_DSLLV: SPECIAL_DSLLV(); break; + case R4300i_SPECIAL_DSRLV: SPECIAL_DSRLV(); break; + case R4300i_SPECIAL_DSRAV: SPECIAL_DSRAV(); break; + case R4300i_SPECIAL_MULT: break; + case R4300i_SPECIAL_MULTU: break; + case R4300i_SPECIAL_DIV: break; + case R4300i_SPECIAL_DIVU: break; + case R4300i_SPECIAL_DMULT: break; + case R4300i_SPECIAL_DMULTU: break; + case R4300i_SPECIAL_DDIV: break; + case R4300i_SPECIAL_DDIVU: break; + case R4300i_SPECIAL_ADD: SPECIAL_ADD(); break; + case R4300i_SPECIAL_ADDU: SPECIAL_ADDU(); break; + case R4300i_SPECIAL_SUB: SPECIAL_SUB(); break; + case R4300i_SPECIAL_SUBU: SPECIAL_SUBU(); break; + case R4300i_SPECIAL_AND: SPECIAL_AND(); break; + case R4300i_SPECIAL_OR: SPECIAL_OR(); break; + case R4300i_SPECIAL_XOR: SPECIAL_XOR(); break; + case R4300i_SPECIAL_NOR: SPECIAL_NOR(); break; + case R4300i_SPECIAL_SLT: SPECIAL_SLT(); break; + case R4300i_SPECIAL_SLTU: SPECIAL_SLTU(); break; + case R4300i_SPECIAL_DADD: SPECIAL_DADD(); break; + case R4300i_SPECIAL_DADDU: SPECIAL_DADDU(); break; + case R4300i_SPECIAL_DSUB: SPECIAL_DSUB(); break; + case R4300i_SPECIAL_DSUBU: SPECIAL_DSUBU(); break; + case R4300i_SPECIAL_DSLL: SPECIAL_DSLL(); break; + case R4300i_SPECIAL_DSRL: SPECIAL_DSRL(); break; + case R4300i_SPECIAL_DSRA: SPECIAL_DSRA(); break; + case R4300i_SPECIAL_DSLL32: SPECIAL_DSLL32(); break; + case R4300i_SPECIAL_DSRL32: SPECIAL_DSRL32(); break; + case R4300i_SPECIAL_DSRA32: SPECIAL_DSRA32(); break; + default: + g_Notify->BreakPoint(__FILEW__, __LINE__); #ifdef tofix - if (m_Command.Hex == 0x00000001) { break; } - g_Notify->DisplayError(L"Unhandled R4300i OpCode in FillSectionInfo 5\n%s", - R4300iOpcodeName(m_Command.Hex,m_PC)); + if (m_Command.Hex == 0x00000001) { break; } + g_Notify->DisplayError(L"Unhandled R4300i OpCode in FillSectionInfo 5\n%s", + R4300iOpcodeName(m_Command.Hex,m_PC)); #endif - m_NextInstruction = END_BLOCK; - m_PC -= 4; - } - break; - case R4300i_REGIMM: - switch (m_Command.rt) { - case R4300i_REGIMM_BLTZ: - case R4300i_REGIMM_BGEZ: - m_NextInstruction = DELAY_SLOT; + m_NextInstruction = END_BLOCK; + m_PC -= 4; + } + break; + case R4300i_REGIMM: + switch (m_Command.rt) + { + case R4300i_REGIMM_BLTZ: + case R4300i_REGIMM_BGEZ: + m_NextInstruction = DELAY_SLOT; #ifdef CHECKED_BUILD - if (Section->m_Cont.TargetPC != m_PC + 8 && - Section->m_ContinueSection != NULL && - Section->m_Cont.TargetPC != (DWORD)-1) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (Section->m_Jump.TargetPC != m_PC + ((short)m_Command.offset << 2) + 4 && - Section->m_JumpSection != NULL && - Section->m_Jump.TargetPC != (DWORD)-1) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (m_PC == Section->m_Jump.TargetPC) - { - if (!DelaySlotEffectsCompare(m_PC,m_Command.rs,0) && !Section->m_Jump.PermLoop) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } + if (Section->m_Cont.TargetPC != m_PC + 8 && + Section->m_ContinueSection != NULL && + Section->m_Cont.TargetPC != (uint32_t)-1) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + if (Section->m_Jump.TargetPC != m_PC + ((int16_t)m_Command.offset << 2) + 4 && + Section->m_JumpSection != NULL && + Section->m_Jump.TargetPC != (uint32_t)-1) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + if (m_PC == Section->m_Jump.TargetPC) + { + if (!DelaySlotEffectsCompare(m_PC, m_Command.rs, 0) && !Section->m_Jump.PermLoop) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } #endif - break; - case R4300i_REGIMM_BLTZL: - case R4300i_REGIMM_BGEZL: - m_NextInstruction = LIKELY_DELAY_SLOT; + break; + case R4300i_REGIMM_BLTZL: + case R4300i_REGIMM_BGEZL: + m_NextInstruction = LIKELY_DELAY_SLOT; #ifdef CHECKED_BUILD - if (Section->m_Cont.TargetPC != m_PC + 8 && - Section->m_ContinueSection != NULL && - Section->m_Cont.TargetPC != (DWORD)-1) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (Section->m_Jump.TargetPC != m_PC + 4 && - Section->m_JumpSection != NULL && - Section->m_Jump.TargetPC != (DWORD)-1) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + if (Section->m_Cont.TargetPC != m_PC + 8 && + Section->m_ContinueSection != NULL && + Section->m_Cont.TargetPC != (uint32_t)-1) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + if (Section->m_Jump.TargetPC != m_PC + 4 && + Section->m_JumpSection != NULL && + Section->m_Jump.TargetPC != (uint32_t)-1) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } - /*if (Section->m_Jump.TargetPC != m_PC + ((short)m_Command.offset << 2) + 4) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - }*/ - if (m_PC == m_PC + ((short)m_Command.offset << 2) + 4) - { - if (!DelaySlotEffectsCompare(m_PC,m_Command.rs,0) && !Section->m_Jump.PermLoop) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } + /*if (Section->m_Jump.TargetPC != m_PC + ((int16_t)m_Command.offset << 2) + 4) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + }*/ + if (m_PC == m_PC + ((int16_t)m_Command.offset << 2) + 4) + { + if (!DelaySlotEffectsCompare(m_PC, m_Command.rs, 0) && !Section->m_Jump.PermLoop) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } #endif - break; - case R4300i_REGIMM_BLTZAL: - g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + case R4300i_REGIMM_BLTZAL: + g_Notify->BreakPoint(__FILEW__, __LINE__); #ifdef tofix - m_Reg.GetMipsRegLo(31) = m_PC + 8; - m_Reg.SetMipsRegState(31,CRegInfo::STATE_CONST_32_SIGN); - Section->m_Cont.TargetPC = m_PC + 8; - Section->m_Jump.TargetPC = m_PC + ((short)m_Command.offset << 2) + 4; - if (m_PC == Section->m_Jump.TargetPC) { - if (!DelaySlotEffectsCompare(m_PC,m_Command.rs,0)) { - Section->m_Jump.PermLoop = true; - } - } + m_Reg.GetMipsRegLo(31) = m_PC + 8; + m_Reg.SetMipsRegState(31,CRegInfo::STATE_CONST_32_SIGN); + Section->m_Cont.TargetPC = m_PC + 8; + Section->m_Jump.TargetPC = m_PC + ((int16_t)m_Command.offset << 2) + 4; + if (m_PC == Section->m_Jump.TargetPC) + { + if (!DelaySlotEffectsCompare(m_PC,m_Command.rs,0)) + { + Section->m_Jump.PermLoop = true; + } + } #endif - break; - case R4300i_REGIMM_BGEZAL: - g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + case R4300i_REGIMM_BGEZAL: + g_Notify->BreakPoint(__FILEW__, __LINE__); #ifdef tofix - m_NextInstruction = DELAY_SLOT; - if (m_Reg.IsConst(m_Command.rs)) - { - __int64 Value; - if (m_Reg.Is32Bit(m_Command.rs)) - { - Value = m_Reg.GetMipsRegLo_S(m_Command.rs); - } else { - Value = m_Reg.GetMipsReg_S(m_Command.rs); - } - if (Value >= 0) { - m_Reg.GetMipsRegLo(31) = m_PC + 8; - m_Reg.SetMipsRegState(31,CRegInfo::STATE_CONST_32_SIGN); - Section->m_Jump.TargetPC = m_PC + ((short)m_Command.offset << 2) + 4; - if (m_PC == Section->m_Jump.TargetPC) { - if (!DelaySlotEffectsCompare(m_PC,31,0)) { - Section->m_Jump.PermLoop = true; - } - } - break; - } - } + m_NextInstruction = DELAY_SLOT; + if (m_Reg.IsConst(m_Command.rs)) + { + int64_t Value; + if (m_Reg.Is32Bit(m_Command.rs)) + { + Value = m_Reg.GetMipsRegLo_S(m_Command.rs); + } else { + Value = m_Reg.GetMipsReg_S(m_Command.rs); + } + if (Value >= 0) + { + m_Reg.GetMipsRegLo(31) = m_PC + 8; + m_Reg.SetMipsRegState(31,CRegInfo::STATE_CONST_32_SIGN); + Section->m_Jump.TargetPC = m_PC + ((int16_t)m_Command.offset << 2) + 4; + if (m_PC == Section->m_Jump.TargetPC) + { + if (!DelaySlotEffectsCompare(m_PC,31,0)) + { + Section->m_Jump.PermLoop = true; + } + } + break; + } + } - - m_Reg.GetMipsRegLo(31) = m_PC + 8; - m_Reg.SetMipsRegState(31,CRegInfo::STATE_CONST_32_SIGN); - Section->m_Cont.TargetPC = m_PC + 8; - Section->m_Jump.TargetPC = m_PC + ((short)m_Command.offset << 2) + 4; - if (m_PC == Section->m_Jump.TargetPC) { - if (!DelaySlotEffectsCompare(m_PC,m_Command.rs,0)) { - Section->m_Jump.PermLoop = true; - } - } + m_Reg.GetMipsRegLo(31) = m_PC + 8; + m_Reg.SetMipsRegState(31,CRegInfo::STATE_CONST_32_SIGN); + Section->m_Cont.TargetPC = m_PC + 8; + Section->m_Jump.TargetPC = m_PC + ((int16_t)m_Command.offset << 2) + 4; + if (m_PC == Section->m_Jump.TargetPC) + { + if (!DelaySlotEffectsCompare(m_PC,m_Command.rs,0)) + { + Section->m_Jump.PermLoop = true; + } + } #endif - break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); + break; + default: + g_Notify->BreakPoint(__FILEW__, __LINE__); #ifdef tofix - if (m_Command.Hex == 0x0407000D) { break; } - g_Notify->DisplayError(L"Unhandled R4300i OpCode in FillSectionInfo 4\n%s", - R4300iOpcodeName(m_Command.Hex,m_PC)); - m_NextInstruction = END_BLOCK; - m_PC -= 4; + if (m_Command.Hex == 0x0407000D) { break; } + g_Notify->DisplayError(L"Unhandled R4300i OpCode in FillSectionInfo 4\n%s", + R4300iOpcodeName(m_Command.Hex,m_PC)); + m_NextInstruction = END_BLOCK; + m_PC -= 4; #endif - } - break; - case R4300i_JAL: - g_Notify->BreakPoint(__FILEW__,__LINE__); + } + break; + case R4300i_JAL: + g_Notify->BreakPoint(__FILEW__, __LINE__); #ifdef tofix - m_NextInstruction = DELAY_SLOT; - m_Reg.GetMipsRegLo(31) = m_PC + 8; - m_Reg.SetMipsRegState(31,CRegInfo::STATE_CONST_32_SIGN); - Section->m_Jump.TargetPC = (m_PC & 0xF0000000) + (m_Command.target << 2); - if (m_PC == Section->m_Jump.TargetPC) { - if (!DelaySlotEffectsCompare(m_PC,31,0)) { - Section->m_Jump.PermLoop = true; - } - } + m_NextInstruction = DELAY_SLOT; + m_Reg.GetMipsRegLo(31) = m_PC + 8; + m_Reg.SetMipsRegState(31,CRegInfo::STATE_CONST_32_SIGN); + Section->m_Jump.TargetPC = (m_PC & 0xF0000000) + (m_Command.target << 2); + if (m_PC == Section->m_Jump.TargetPC) + { + if (!DelaySlotEffectsCompare(m_PC,31,0)) + { + Section->m_Jump.PermLoop = true; + } + } #endif - break; - case R4300i_J: - m_NextInstruction = DELAY_SLOT; + break; + case R4300i_J: + m_NextInstruction = DELAY_SLOT; #ifdef CHECKED_BUILD - if (Section->m_Jump.TargetPC != (m_PC & 0xF0000000) + (m_Command.target << 2)) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (m_PC == Section->m_Jump.TargetPC && !Section->m_Jump.PermLoop) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + if (Section->m_Jump.TargetPC != (m_PC & 0xF0000000) + (m_Command.target << 2)) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + if (m_PC == Section->m_Jump.TargetPC && !Section->m_Jump.PermLoop) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } #endif - break; - case R4300i_BEQ: - if (m_PC + ((short)m_Command.offset << 2) + 4 != m_PC + 8) - { - m_NextInstruction = DELAY_SLOT; + break; + case R4300i_BEQ: + if (m_PC + ((int16_t)m_Command.offset << 2) + 4 != m_PC + 8) + { + m_NextInstruction = DELAY_SLOT; #ifdef CHECKED_BUILD - if (m_Command.rs != 0 || m_Command.rt != 0) - { - if (Section->m_Cont.TargetPC != m_PC + 8 && - Section->m_ContinueSection != NULL && - Section->m_Cont.TargetPC != (DWORD)-1) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } else { - if (Section->m_Cont.TargetPC != (DWORD)-1) - { - //g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } - if (Section->m_Jump.TargetPC != m_PC + ((short)m_Command.offset << 2) + 4) - { - //g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (m_PC == Section->m_Jump.TargetPC) - { - if (!DelaySlotEffectsCompare(m_PC,m_Command.rs,m_Command.rt) && !Section->m_Jump.PermLoop) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } + if (m_Command.rs != 0 || m_Command.rt != 0) + { + if (Section->m_Cont.TargetPC != m_PC + 8 && + Section->m_ContinueSection != NULL && + Section->m_Cont.TargetPC != (uint32_t)-1) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } + else + { + if (Section->m_Cont.TargetPC != (uint32_t)-1) + { + //g_Notify->BreakPoint(__FILEW__,__LINE__); + } + } + if (Section->m_Jump.TargetPC != m_PC + ((int16_t)m_Command.offset << 2) + 4) + { + //g_Notify->BreakPoint(__FILEW__,__LINE__); + } + if (m_PC == Section->m_Jump.TargetPC) + { + if (!DelaySlotEffectsCompare(m_PC, m_Command.rs, m_Command.rt) && !Section->m_Jump.PermLoop) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } #endif - } - break; - case R4300i_BNE: - case R4300i_BLEZ: - case R4300i_BGTZ: - if (m_PC + ((short)m_Command.offset << 2) + 4 != m_PC + 8) - { - m_NextInstruction = DELAY_SLOT; + } + break; + case R4300i_BNE: + case R4300i_BLEZ: + case R4300i_BGTZ: + if (m_PC + ((int16_t)m_Command.offset << 2) + 4 != m_PC + 8) + { + m_NextInstruction = DELAY_SLOT; #ifdef CHECKED_BUILD - if (Section->m_Cont.TargetPC != m_PC + 8 && - Section->m_ContinueSection != NULL && - Section->m_Cont.TargetPC != (DWORD)-1) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (Section->m_Jump.TargetPC != m_PC + ((short)m_Command.offset << 2) + 4 && - Section->m_JumpSection != NULL && - Section->m_Jump.TargetPC != (DWORD)-1) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (m_PC == Section->m_Jump.TargetPC) - { - if (!DelaySlotEffectsCompare(m_PC,m_Command.rs,m_Command.rt) && !Section->m_Jump.PermLoop) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } + if (Section->m_Cont.TargetPC != m_PC + 8 && + Section->m_ContinueSection != NULL && + Section->m_Cont.TargetPC != (uint32_t)-1) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + if (Section->m_Jump.TargetPC != m_PC + ((int16_t)m_Command.offset << 2) + 4 && + Section->m_JumpSection != NULL && + Section->m_Jump.TargetPC != (uint32_t)-1) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + if (m_PC == Section->m_Jump.TargetPC) + { + if (!DelaySlotEffectsCompare(m_PC, m_Command.rs, m_Command.rt) && !Section->m_Jump.PermLoop) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } #endif - } - break; - case R4300i_ADDI: - case R4300i_ADDIU: - if (m_Command.rt == 0) { break; } - /*if (m_Command.rs == 0) { - m_Reg.GetMipsRegLo(m_Command.rt) = (short)m_Command.immediate; - m_Reg.SetMipsRegState(m_Command.rt,CRegInfo::STATE_CONST_32_SIGN); - } else {*/ - m_Reg.SetMipsRegState(m_Command.rt,CRegInfo::STATE_MODIFIED); - //} - break; - case R4300i_SLTI: - case R4300i_SLTIU: - if (m_Command.rt == 0) { break; } - m_Reg.SetMipsRegState(m_Command.rt,CRegInfo::STATE_MODIFIED); - break; - case R4300i_LUI: - if (m_Command.rt == 0) { break; } - if (!m_Reg.IsModified(m_Command.rt)) - { - m_Reg.SetMipsRegLo(m_Command.rt,((short)m_Command.offset << 16)); - m_Reg.SetMipsRegState(m_Command.rt,CRegInfo::STATE_CONST_32_SIGN); - } - break; - case R4300i_ANDI: - if (m_Command.rt == 0) { break; } - m_Reg.SetMipsRegState(m_Command.rt,CRegInfo::STATE_MODIFIED); - break; - case R4300i_ORI: - if (m_Command.rt == 0) { break; } - if (m_Command.rs == m_Command.rt) - { - m_Reg.SetMipsRegState(m_Command.rt,CRegInfo::STATE_MODIFIED); - } - if (m_Reg.IsConst(m_Command.rs)) { - m_Reg.SetMipsRegState(m_Command.rt,CRegInfo::STATE_CONST_32_SIGN); - m_Reg.SetMipsRegLo(m_Command.rt,m_Reg.GetMipsRegLo(m_Command.rs) | m_Command.immediate); - } else { - m_Reg.SetMipsRegState(m_Command.rt,CRegInfo::STATE_MODIFIED); - } - break; - case R4300i_XORI: - if (m_Command.rt == 0) { break; } - if (m_Command.rs == m_Command.rt) - { - m_Reg.SetMipsRegState(m_Command.rt,CRegInfo::STATE_MODIFIED); - } - if (m_Reg.IsConst(m_Command.rs)) { - m_Reg.SetMipsRegState(m_Command.rt,CRegInfo::STATE_CONST_32_SIGN); - m_Reg.SetMipsRegLo(m_Command.rt, m_Reg.GetMipsRegLo(m_Command.rs) ^ m_Command.immediate); - } else { - m_Reg.SetMipsRegState(m_Command.rt,CRegInfo::STATE_MODIFIED); - } - break; - case R4300i_CP0: - switch (m_Command.rs) { - case R4300i_COP0_MF: - if (m_Command.rt == 0) { break; } - m_Reg.SetMipsRegState(m_Command.rt,CRegInfo::STATE_MODIFIED); - break; - case R4300i_COP0_MT: break; - default: - if ( (m_Command.rs & 0x10 ) != 0 ) - { - switch( m_Command.funct ) - { - case R4300i_COP0_CO_TLBR: break; - case R4300i_COP0_CO_TLBWI: break; - case R4300i_COP0_CO_TLBWR: break; - case R4300i_COP0_CO_TLBP: break; - case R4300i_COP0_CO_ERET: m_NextInstruction = END_BLOCK; break; - default: - g_Notify->DisplayError(stdstr_f("Unhandled R4300i OpCode in FillSectionInfo\n%s",R4300iOpcodeName(m_Command.Hex,m_PC)).ToUTF16().c_str()); - m_NextInstruction = END_BLOCK; - m_PC -= 4; - } - } - else - { - g_Notify->DisplayError(stdstr_f("Unhandled R4300i OpCode in FillSectionInfo 3\n%s",R4300iOpcodeName(m_Command.Hex,m_PC)).ToUTF16().c_str()); - m_NextInstruction = END_BLOCK; - m_PC -= 4; - } - } - break; - case R4300i_CP1: - switch (m_Command.fmt) - { - case R4300i_COP1_CF: - case R4300i_COP1_MF: - case R4300i_COP1_DMF: - if (m_Command.rt == 0) { break; } - m_Reg.SetMipsRegState(m_Command.rt,CRegInfo::STATE_MODIFIED); - break; - case R4300i_COP1_BC: - switch (m_Command.ft) { - case R4300i_COP1_BC_BCFL: - case R4300i_COP1_BC_BCTL: - m_NextInstruction = LIKELY_DELAY_SLOT; + } + break; + case R4300i_ADDI: + case R4300i_ADDIU: + if (m_Command.rt == 0) { break; } + /*if (m_Command.rs == 0) { + m_Reg.GetMipsRegLo(m_Command.rt) = (int16_t)m_Command.immediate; + m_Reg.SetMipsRegState(m_Command.rt,CRegInfo::STATE_CONST_32_SIGN); + } else {*/ + m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); + //} + break; + case R4300i_SLTI: + case R4300i_SLTIU: + if (m_Command.rt == 0) { break; } + m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); + break; + case R4300i_LUI: + if (m_Command.rt == 0) { break; } + if (!m_Reg.IsModified(m_Command.rt)) + { + m_Reg.SetMipsRegLo(m_Command.rt, ((int16_t)m_Command.offset << 16)); + m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_CONST_32_SIGN); + } + break; + case R4300i_ANDI: + if (m_Command.rt == 0) { break; } + m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); + break; + case R4300i_ORI: + if (m_Command.rt == 0) { break; } + if (m_Command.rs == m_Command.rt) + { + m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); + } + if (m_Reg.IsConst(m_Command.rs)) { + m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_CONST_32_SIGN); + m_Reg.SetMipsRegLo(m_Command.rt, m_Reg.GetMipsRegLo(m_Command.rs) | m_Command.immediate); + } + else { + m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); + } + break; + case R4300i_XORI: + if (m_Command.rt == 0) { break; } + if (m_Command.rs == m_Command.rt) + { + m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); + } + if (m_Reg.IsConst(m_Command.rs)) + { + m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_CONST_32_SIGN); + m_Reg.SetMipsRegLo(m_Command.rt, m_Reg.GetMipsRegLo(m_Command.rs) ^ m_Command.immediate); + } + else + { + m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); + } + break; + case R4300i_CP0: + switch (m_Command.rs) + { + case R4300i_COP0_MF: + if (m_Command.rt == 0) { break; } + m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); + break; + case R4300i_COP0_MT: break; + default: + if ((m_Command.rs & 0x10) != 0) + { + switch (m_Command.funct) + { + case R4300i_COP0_CO_TLBR: break; + case R4300i_COP0_CO_TLBWI: break; + case R4300i_COP0_CO_TLBWR: break; + case R4300i_COP0_CO_TLBP: break; + case R4300i_COP0_CO_ERET: m_NextInstruction = END_BLOCK; break; + default: + g_Notify->DisplayError(stdstr_f("Unhandled R4300i OpCode in FillSectionInfo\n%s", R4300iOpcodeName(m_Command.Hex, m_PC)).ToUTF16().c_str()); + m_NextInstruction = END_BLOCK; + m_PC -= 4; + } + } + else + { + g_Notify->DisplayError(stdstr_f("Unhandled R4300i OpCode in FillSectionInfo 3\n%s", R4300iOpcodeName(m_Command.Hex, m_PC)).ToUTF16().c_str()); + m_NextInstruction = END_BLOCK; + m_PC -= 4; + } + } + break; + case R4300i_CP1: + switch (m_Command.fmt) + { + case R4300i_COP1_CF: + case R4300i_COP1_MF: + case R4300i_COP1_DMF: + if (m_Command.rt == 0) { break; } + m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); + break; + case R4300i_COP1_BC: + switch (m_Command.ft) + { + case R4300i_COP1_BC_BCFL: + case R4300i_COP1_BC_BCTL: + m_NextInstruction = LIKELY_DELAY_SLOT; #ifdef CHECKED_BUILD - if (Section->m_Cont.TargetPC != m_PC + 8 && - Section->m_ContinueSection != NULL && - Section->m_Cont.TargetPC != (DWORD)-1) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (m_PC == m_PC + ((short)m_Command.offset << 2) + 4) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); -#ifdef tofix - if (!DelaySlotEffectsCompare(m_PC,m_Command.rs,m_Command.rt)) - { - if (!Section->m_Jump.PermLoop) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } -#endif - } -#endif - break; - case R4300i_COP1_BC_BCF: - case R4300i_COP1_BC_BCT: - m_NextInstruction = DELAY_SLOT; -#ifdef CHECKED_BUILD - if (Section->m_Cont.TargetPC != m_PC + 8 && - Section->m_ContinueSection != NULL && - Section->m_Cont.TargetPC != (DWORD)-1) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (Section->m_Jump.TargetPC != m_PC + ((short)m_Command.offset << 2) + 4) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (m_PC == Section->m_Jump.TargetPC) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); + if (Section->m_Cont.TargetPC != m_PC + 8 && + Section->m_ContinueSection != NULL && + Section->m_Cont.TargetPC != (uint32_t)-1) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + if (m_PC == m_PC + ((int16_t)m_Command.offset << 2) + 4) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); #ifdef tofix - if (!DelaySlotEffectsCompare(m_PC,m_Command.rs,m_Command.rt)) { - Section->m_Jump.PermLoop = true; - } + if (!DelaySlotEffectsCompare(m_PC,m_Command.rs,m_Command.rt)) + { + if (!Section->m_Jump.PermLoop) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + } + } #endif - } + } #endif - break; - } - break; - case R4300i_COP1_MT: break; - case R4300i_COP1_DMT: break; - case R4300i_COP1_CT: break; - case R4300i_COP1_S: break; - case R4300i_COP1_D: break; - case R4300i_COP1_W: break; - case R4300i_COP1_L: break; - default: - g_Notify->DisplayError(stdstr_f("Unhandled R4300i OpCode in FillSectionInfo 2\n%s",R4300iOpcodeName(m_Command.Hex,m_PC)).ToUTF16().c_str()); - m_NextInstruction = END_BLOCK; - m_PC -= 4; - } - break; - case R4300i_BEQL: - case R4300i_BNEL: - case R4300i_BLEZL: - case R4300i_BGTZL: - m_NextInstruction = LIKELY_DELAY_SLOT; + break; + case R4300i_COP1_BC_BCF: + case R4300i_COP1_BC_BCT: + m_NextInstruction = DELAY_SLOT; #ifdef CHECKED_BUILD - if (Section->m_Cont.TargetPC != m_PC + 8 && - Section->m_ContinueSection != NULL && - Section->m_Cont.TargetPC != (DWORD)-1) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (Section->m_Jump.TargetPC != m_PC + 4) - { - //g_Notify->BreakPoint(__FILEW__,__LINE__); - } - /*if (Section->m_Jump.TargetPC != m_PC + ((short)m_Command.offset << 2) + 4) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - }*/ - if (m_PC == m_PC + ((short)m_Command.offset << 2) + 4) - { - if (!DelaySlotEffectsCompare(m_PC,m_Command.rs,m_Command.rt) && !Section->m_Jump.PermLoop) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } + if (Section->m_Cont.TargetPC != m_PC + 8 && + Section->m_ContinueSection != NULL && + Section->m_Cont.TargetPC != (uint32_t)-1) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + if (Section->m_Jump.TargetPC != m_PC + ((int16_t)m_Command.offset << 2) + 4) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + if (m_PC == Section->m_Jump.TargetPC) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); +#ifdef tofix + if (!DelaySlotEffectsCompare(m_PC,m_Command.rs,m_Command.rt)) { + Section->m_Jump.PermLoop = true; + } #endif - break; - case R4300i_DADDI: - case R4300i_DADDIU: - if (m_Command.rt == 0) { break; } - if (m_Command.rs == m_Command.rt) - { - m_Reg.SetMipsRegState(m_Command.rt,CRegInfo::STATE_MODIFIED); - } - if (m_Reg.IsConst(m_Command.rs)) { - if (m_Reg.Is64Bit(m_Command.rs)) { - int imm32 = (short)m_Command.immediate; - __int64 imm64 = imm32; - m_Reg.SetMipsReg_S(m_Command.rt, m_Reg.GetMipsRegLo_S(m_Command.rs) + imm64); - } else { - m_Reg.SetMipsReg_S(m_Command.rt, m_Reg.GetMipsRegLo_S(m_Command.rs) + (short)m_Command.immediate); - } - m_Reg.SetMipsRegState(m_Command.rt,CRegInfo::STATE_CONST_64); - } else { - m_Reg.SetMipsRegState(m_Command.rt,CRegInfo::STATE_MODIFIED); - } - break; - case R4300i_LDR: - case R4300i_LDL: - case R4300i_LB: - case R4300i_LH: - case R4300i_LWL: - case R4300i_LW: - case R4300i_LWU: - case R4300i_LL: - case R4300i_LBU: - case R4300i_LHU: - case R4300i_LWR: - case R4300i_SC: - if (m_Command.rt == 0) { break; } - m_Reg.SetMipsRegState(m_Command.rt,CRegInfo::STATE_MODIFIED); - break; - case R4300i_SB: break; - case R4300i_SH: break; - case R4300i_SWL: break; - case R4300i_SW: break; - case R4300i_SWR: break; - case R4300i_SDL: break; - case R4300i_SDR: break; - case R4300i_CACHE: break; - case R4300i_LWC1: break; - case R4300i_SWC1: break; - case R4300i_LDC1: break; - case R4300i_LD: - if (m_Command.rt == 0) { break; } - m_Reg.SetMipsRegState(m_Command.rt,CRegInfo::STATE_MODIFIED); - break; - case R4300i_SDC1: break; - case R4300i_SD: break; - default: - m_NextInstruction = END_BLOCK; - m_PC -= 4; - if (m_Command.Hex == 0x7C1C97C0) { break; } - if (m_Command.Hex == 0x7FFFFFFF) { break; } - if (m_Command.Hex == 0xF1F3F5F7) { break; } - if (m_Command.Hex == 0xC1200000) { break; } - if (m_Command.Hex == 0x4C5A5353) { break; } - g_Notify->DisplayError(stdstr_f("Unhandled R4300i OpCode in FillSectionInfo 1\n%s\n%X",R4300iOpcodeName(m_Command.Hex,m_PC),m_Command.Hex).ToUTF16().c_str()); - } + } +#endif + break; + } + break; + case R4300i_COP1_MT: break; + case R4300i_COP1_DMT: break; + case R4300i_COP1_CT: break; + case R4300i_COP1_S: break; + case R4300i_COP1_D: break; + case R4300i_COP1_W: break; + case R4300i_COP1_L: break; + default: + g_Notify->DisplayError(stdstr_f("Unhandled R4300i OpCode in FillSectionInfo 2\n%s", R4300iOpcodeName(m_Command.Hex, m_PC)).ToUTF16().c_str()); + m_NextInstruction = END_BLOCK; + m_PC -= 4; + } + break; + case R4300i_BEQL: + case R4300i_BNEL: + case R4300i_BLEZL: + case R4300i_BGTZL: + m_NextInstruction = LIKELY_DELAY_SLOT; +#ifdef CHECKED_BUILD + if (Section->m_Cont.TargetPC != m_PC + 8 && + Section->m_ContinueSection != NULL && + Section->m_Cont.TargetPC != (uint32_t)-1) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + if (Section->m_Jump.TargetPC != m_PC + 4) + { + //g_Notify->BreakPoint(__FILEW__,__LINE__); + } + /*if (Section->m_Jump.TargetPC != m_PC + ((int16_t)m_Command.offset << 2) + 4) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + }*/ + if (m_PC == m_PC + ((int16_t)m_Command.offset << 2) + 4) + { + if (!DelaySlotEffectsCompare(m_PC, m_Command.rs, m_Command.rt) && !Section->m_Jump.PermLoop) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } +#endif + break; + case R4300i_DADDI: + case R4300i_DADDIU: + if (m_Command.rt == 0) { break; } + if (m_Command.rs == m_Command.rt) + { + m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); + } + if (m_Reg.IsConst(m_Command.rs)) + { + if (m_Reg.Is64Bit(m_Command.rs)) + { + int imm32 = (int16_t)m_Command.immediate; + int64_t imm64 = imm32; + m_Reg.SetMipsReg_S(m_Command.rt, m_Reg.GetMipsRegLo_S(m_Command.rs) + imm64); + } + else + { + m_Reg.SetMipsReg_S(m_Command.rt, m_Reg.GetMipsRegLo_S(m_Command.rs) + (int16_t)m_Command.immediate); + } + m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_CONST_64); + } + else + { + m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); + } + break; + case R4300i_LDR: + case R4300i_LDL: + case R4300i_LB: + case R4300i_LH: + case R4300i_LWL: + case R4300i_LW: + case R4300i_LWU: + case R4300i_LL: + case R4300i_LBU: + case R4300i_LHU: + case R4300i_LWR: + case R4300i_SC: + if (m_Command.rt == 0) { break; } + m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); + break; + case R4300i_SB: break; + case R4300i_SH: break; + case R4300i_SWL: break; + case R4300i_SW: break; + case R4300i_SWR: break; + case R4300i_SDL: break; + case R4300i_SDR: break; + case R4300i_CACHE: break; + case R4300i_LWC1: break; + case R4300i_SWC1: break; + case R4300i_LDC1: break; + case R4300i_LD: + if (m_Command.rt == 0) { break; } + m_Reg.SetMipsRegState(m_Command.rt, CRegInfo::STATE_MODIFIED); + break; + case R4300i_SDC1: break; + case R4300i_SD: break; + default: + m_NextInstruction = END_BLOCK; + m_PC -= 4; + if (m_Command.Hex == 0x7C1C97C0) { break; } + if (m_Command.Hex == 0x7FFFFFFF) { break; } + if (m_Command.Hex == 0xF1F3F5F7) { break; } + if (m_Command.Hex == 0xC1200000) { break; } + if (m_Command.Hex == 0x4C5A5353) { break; } + g_Notify->DisplayError(stdstr_f("Unhandled R4300i OpCode in FillSectionInfo 1\n%s\n%X", R4300iOpcodeName(m_Command.Hex, m_PC), m_Command.Hex).ToUTF16().c_str()); + } - CPU_Message(" %s state: %X value: %X",CRegName::GPR[5],m_Reg.GetMipsRegState(5),m_Reg.GetMipsRegLo(5)); + CPU_Message(" %s state: %X value: %X", CRegName::GPR[5], m_Reg.GetMipsRegState(5), m_Reg.GetMipsRegLo(5)); - if (Section->m_DelaySlot) - { - if (m_NextInstruction != NORMAL && m_NextInstruction != END_BLOCK) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - m_NextInstruction = END_BLOCK; - SetJumpRegSet(Section,m_Reg); - } else { - switch (m_NextInstruction) { - case NORMAL: - m_PC += 4; - break; - case DELAY_SLOT: - m_NextInstruction = DELAY_SLOT_DONE; - m_PC += 4; - if ((m_PC & 0xFFFFF000) != (m_EnterSection->m_EnterPC & 0xFFFFF000)) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - break; - case LIKELY_DELAY_SLOT: - { - SetContinueRegSet(Section,m_Reg); - SetJumpRegSet(Section,m_Reg); - } - m_NextInstruction = END_BLOCK; - break; - case DELAY_SLOT_DONE: - { - SetContinueRegSet(Section,m_Reg); - SetJumpRegSet(Section,m_Reg); - } - m_NextInstruction = END_BLOCK; - break; - case LIKELY_DELAY_SLOT_DONE: - g_Notify->BreakPoint(__FILEW__,__LINE__); - if (Section->m_CompiledLocation) - { - } else { - //Section->m_Jump.RegSet = m_Reg; - //Section->m_Jump.DoneDelaySlot = true; - } - m_NextInstruction = END_BLOCK; - break; - } - } + if (Section->m_DelaySlot) + { + if (m_NextInstruction != NORMAL && m_NextInstruction != END_BLOCK) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + m_NextInstruction = END_BLOCK; + SetJumpRegSet(Section, m_Reg); + } + else { + switch (m_NextInstruction) + { + case NORMAL: + m_PC += 4; + break; + case DELAY_SLOT: + m_NextInstruction = DELAY_SLOT_DONE; + m_PC += 4; + if ((m_PC & 0xFFFFF000) != (m_EnterSection->m_EnterPC & 0xFFFFF000)) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + break; + case LIKELY_DELAY_SLOT: + { + SetContinueRegSet(Section, m_Reg); + SetJumpRegSet(Section, m_Reg); + } + m_NextInstruction = END_BLOCK; + break; + case DELAY_SLOT_DONE: + { + SetContinueRegSet(Section, m_Reg); + SetJumpRegSet(Section, m_Reg); + } + m_NextInstruction = END_BLOCK; + break; + case LIKELY_DELAY_SLOT_DONE: + g_Notify->BreakPoint(__FILEW__, __LINE__); + if (Section->m_CompiledLocation) + { + } + else + { + //Section->m_Jump.RegSet = m_Reg; + //Section->m_Jump.DoneDelaySlot = true; + } + m_NextInstruction = END_BLOCK; + break; + } + } - if (m_PC == ContinueSectionPC) - { - m_NextInstruction = END_BLOCK; - SetContinueRegSet(Section,m_Reg); - } + if (m_PC == ContinueSectionPC) + { + m_NextInstruction = END_BLOCK; + SetContinueRegSet(Section, m_Reg); + } - if ((m_PC & 0xFFFFF000) != (m_EnterSection->m_EnterPC & 0xFFFFF000)) { - if (m_NextInstruction != END_BLOCK && m_NextInstruction != NORMAL) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } while (m_NextInstruction != END_BLOCK); + if ((m_PC & 0xFFFFF000) != (m_EnterSection->m_EnterPC & 0xFFFFF000)) + { + if (m_NextInstruction != END_BLOCK && m_NextInstruction != NORMAL) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } while (m_NextInstruction != END_BLOCK); - if (!CheckLoopRegisterUsage(Section->m_ContinueSection)) { return false; } - if (!CheckLoopRegisterUsage(Section->m_JumpSection)) { return false; } - return true; + if (!CheckLoopRegisterUsage(Section->m_ContinueSection)) { return false; } + if (!CheckLoopRegisterUsage(Section->m_JumpSection)) { return false; } + return true; } -bool LoopAnalysis::SyncRegState ( CRegInfo & RegSet, const CRegInfo& SyncReg ) +bool LoopAnalysis::SyncRegState(CRegInfo & RegSet, const CRegInfo& SyncReg) { - bool bChanged = false; - for (int x = 0; x < 32; x++) - { - if (RegSet.GetMipsRegState(x) != SyncReg.GetMipsRegState(x)) - { - CPU_Message(__FUNCTION__ ": Clear state %s RegEnter State: %X Jump Reg State: %X",CRegName::GPR[x],RegSet.GetMipsRegState(x),SyncReg.GetMipsRegState(x)); - RegSet.SetMipsRegState(x,CRegInfo::STATE_MODIFIED); - bChanged = true; - } - else if (RegSet.IsConst(x) && RegSet.Is32Bit(x) && RegSet.GetMipsRegLo(x) != SyncReg.GetMipsRegLo(x)) - { - CPU_Message(__FUNCTION__ ": Clear state %s RegEnter State: %X Jump Reg State: %X",CRegName::GPR[x],RegSet.GetMipsRegState(x),SyncReg.GetMipsRegState(x)); - RegSet.SetMipsRegState(x,CRegInfo::STATE_MODIFIED); - bChanged = true; - } else if (RegSet.IsConst(x) && RegSet.Is64Bit(x) && RegSet.GetMipsReg_S(x) != SyncReg.GetMipsReg_S(x)) { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } - return bChanged; + bool bChanged = false; + for (int x = 0; x < 32; x++) + { + if (RegSet.GetMipsRegState(x) != SyncReg.GetMipsRegState(x)) + { + CPU_Message(__FUNCTION__ ": Clear state %s RegEnter State: %X Jump Reg State: %X", CRegName::GPR[x], RegSet.GetMipsRegState(x), SyncReg.GetMipsRegState(x)); + RegSet.SetMipsRegState(x, CRegInfo::STATE_MODIFIED); + bChanged = true; + } + else if (RegSet.IsConst(x) && RegSet.Is32Bit(x) && RegSet.GetMipsRegLo(x) != SyncReg.GetMipsRegLo(x)) + { + CPU_Message(__FUNCTION__ ": Clear state %s RegEnter State: %X Jump Reg State: %X", CRegName::GPR[x], RegSet.GetMipsRegState(x), SyncReg.GetMipsRegState(x)); + RegSet.SetMipsRegState(x, CRegInfo::STATE_MODIFIED); + bChanged = true; + } + else if (RegSet.IsConst(x) && RegSet.Is64Bit(x) && RegSet.GetMipsReg_S(x) != SyncReg.GetMipsReg_S(x)) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } + return bChanged; } -void LoopAnalysis::SetJumpRegSet ( CCodeSection * Section, const CRegInfo &Reg ) +void LoopAnalysis::SetJumpRegSet(CCodeSection * Section, const CRegInfo &Reg) { - RegisterMap::iterator itr = m_JumpRegisters.find(Section->m_SectionID); - if (itr != m_JumpRegisters.end()) - { - *(itr->second) = Reg; - } else { - m_JumpRegisters.insert(RegisterMap::value_type(Section->m_SectionID,new CRegInfo(Reg))); - } + RegisterMap::iterator itr = m_JumpRegisters.find(Section->m_SectionID); + if (itr != m_JumpRegisters.end()) + { + *(itr->second) = Reg; + } + else + { + m_JumpRegisters.insert(RegisterMap::value_type(Section->m_SectionID, new CRegInfo(Reg))); + } } -void LoopAnalysis::SetContinueRegSet ( CCodeSection * Section, const CRegInfo &Reg ) +void LoopAnalysis::SetContinueRegSet(CCodeSection * Section, const CRegInfo &Reg) { - RegisterMap::iterator itr = m_ContinueRegisters.find(Section->m_SectionID); - if (itr != m_ContinueRegisters.end()) - { - *(itr->second) = Reg; - } else { - m_ContinueRegisters.insert(RegisterMap::value_type(Section->m_SectionID,new CRegInfo(Reg))); - } + RegisterMap::iterator itr = m_ContinueRegisters.find(Section->m_SectionID); + if (itr != m_ContinueRegisters.end()) + { + *(itr->second) = Reg; + } + else + { + m_ContinueRegisters.insert(RegisterMap::value_type(Section->m_SectionID, new CRegInfo(Reg))); + } } void LoopAnalysis::SPECIAL_SLL() { - if (m_Command.rd == 0) { return; } - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); + if (m_Command.rd == 0) { return; } + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_SRL() { - if (m_Command.rd == 0) { return; } - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); + if (m_Command.rd == 0) { return; } + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_SRA() { - if (m_Command.rd == 0) { return; } - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); + if (m_Command.rd == 0) { return; } + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_SLLV() { - if (m_Command.rd == 0) { return; } - if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } - if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_CONST_32_SIGN); - m_Reg.SetMipsRegLo(m_Command.rd, m_Reg.GetMipsRegLo(m_Command.rt) << (m_Reg.GetMipsRegLo(m_Command.rs) & 0x1F)); - } else { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } + if (m_Command.rd == 0) { return; } + if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } + if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_32_SIGN); + m_Reg.SetMipsRegLo(m_Command.rd, m_Reg.GetMipsRegLo(m_Command.rt) << (m_Reg.GetMipsRegLo(m_Command.rs) & 0x1F)); + } + else + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } } void LoopAnalysis::SPECIAL_SRLV() { - if (m_Command.rd == 0) { return; } - if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) - { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } - if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_CONST_32_SIGN); - m_Reg.SetMipsRegLo(m_Command.rd, m_Reg.GetMipsRegLo(m_Command.rt) >> (m_Reg.GetMipsRegLo(m_Command.rs) & 0x1F)); - } else { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } + if (m_Command.rd == 0) { return; } + if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } + if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_32_SIGN); + m_Reg.SetMipsRegLo(m_Command.rd, m_Reg.GetMipsRegLo(m_Command.rt) >> (m_Reg.GetMipsRegLo(m_Command.rs) & 0x1F)); + } + else + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } } void LoopAnalysis::SPECIAL_SRAV() { - if (m_Command.rd == 0) { return; } - if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) - { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } - if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_CONST_32_SIGN); - m_Reg.SetMipsRegLo(m_Command.rd, m_Reg.GetMipsRegLo_S(m_Command.rt) >> (m_Reg.GetMipsRegLo(m_Command.rs) & 0x1F)); - } else { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } + if (m_Command.rd == 0) { return; } + if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } + if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_32_SIGN); + m_Reg.SetMipsRegLo(m_Command.rd, m_Reg.GetMipsRegLo_S(m_Command.rt) >> (m_Reg.GetMipsRegLo(m_Command.rs) & 0x1F)); + } + else + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } } void LoopAnalysis::SPECIAL_JR() { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); #ifdef tofix - if (m_Reg.IsConst(m_Command.rs)) { - Section->m_Jump.TargetPC = m_Reg.GetMipsRegLo(m_Command.rs); - } else { - Section->m_Jump.TargetPC = (DWORD)-1; - } + if (m_Reg.IsConst(m_Command.rs)) + { + Section->m_Jump.TargetPC = m_Reg.GetMipsRegLo(m_Command.rs); + } + else + { + Section->m_Jump.TargetPC = (uint32_t)-1; + } #endif - m_NextInstruction = DELAY_SLOT; + m_NextInstruction = DELAY_SLOT; } void LoopAnalysis::SPECIAL_JALR() { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); #ifdef tofix - m_Reg.GetMipsRegLo(m_Command.rd) = m_PC + 8; - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_CONST_32_SIGN); - if (m_Reg.IsConst(m_Command.rs)) { - Section->m_Jump.TargetPC = m_Reg.GetMipsRegLo(m_Command.rs); - } else { - Section->m_Jump.TargetPC = (DWORD)-1; - } + m_Reg.GetMipsRegLo(m_Command.rd) = m_PC + 8; + m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_CONST_32_SIGN); + if (m_Reg.IsConst(m_Command.rs)) { + Section->m_Jump.TargetPC = m_Reg.GetMipsRegLo(m_Command.rs); + } + else + { + Section->m_Jump.TargetPC = (uint32_t)-1; + } #endif - m_NextInstruction = DELAY_SLOT; + m_NextInstruction = DELAY_SLOT; } -void LoopAnalysis::SPECIAL_SYSCALL ( CCodeSection * Section ) +void LoopAnalysis::SPECIAL_SYSCALL(CCodeSection * Section) { #ifdef CHECKED_BUILD - if (Section->m_ContinueSection != NULL && - Section->m_Cont.TargetPC != (DWORD)-1) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (Section->m_JumpSection != NULL && - Section->m_Jump.TargetPC != (DWORD)-1) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + if (Section->m_ContinueSection != NULL && + Section->m_Cont.TargetPC != (uint32_t)-1) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + if (Section->m_JumpSection != NULL && + Section->m_Jump.TargetPC != (uint32_t)-1) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } #else - Section = Section; + Section = Section; #endif - m_NextInstruction = END_BLOCK; - m_PC -= 4; + m_NextInstruction = END_BLOCK; + m_PC -= 4; } -void LoopAnalysis::SPECIAL_BREAK ( CCodeSection * Section ) +void LoopAnalysis::SPECIAL_BREAK(CCodeSection * Section) { #ifdef CHECKED_BUILD - if (Section->m_ContinueSection != NULL && - Section->m_Cont.TargetPC != (DWORD)-1) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (Section->m_JumpSection != NULL && - Section->m_Jump.TargetPC != (DWORD)-1) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + if (Section->m_ContinueSection != NULL && + Section->m_Cont.TargetPC != (uint32_t)-1) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + if (Section->m_JumpSection != NULL && + Section->m_Jump.TargetPC != (uint32_t)-1) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } #else - Section = Section; + Section = Section; #endif - m_NextInstruction = END_BLOCK; - m_PC -= 4; + m_NextInstruction = END_BLOCK; + m_PC -= 4; } void LoopAnalysis::SPECIAL_MFHI() { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_MTHI() { - } void LoopAnalysis::SPECIAL_MFLO() { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_MTLO() { - } void LoopAnalysis::SPECIAL_DSLLV() { - if (m_Command.rd == 0) { return; } - if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) - { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } - if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_CONST_64); - m_Reg.SetMipsReg(m_Command.rd, m_Reg.Is64Bit(m_Command.rt)?m_Reg.GetMipsReg(m_Command.rt):(QWORD)m_Reg.GetMipsRegLo_S(m_Command.rt) << (m_Reg.GetMipsRegLo(m_Command.rs) & 0x3F)); - } else { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } + if (m_Command.rd == 0) { return; } + if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } + if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64); + m_Reg.SetMipsReg(m_Command.rd, m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (uint64_t)m_Reg.GetMipsRegLo_S(m_Command.rt) << (m_Reg.GetMipsRegLo(m_Command.rs) & 0x3F)); + } + else + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } } void LoopAnalysis::SPECIAL_DSRLV() { - if (m_Command.rd == 0) { return; } - if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) - { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } - if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_CONST_64); - m_Reg.SetMipsReg(m_Command.rd,m_Reg.Is64Bit(m_Command.rt)?m_Reg.GetMipsReg(m_Command.rt):(QWORD)m_Reg.GetMipsRegLo_S(m_Command.rt) >> (m_Reg.GetMipsRegLo(m_Command.rs) & 0x3F)); - } else { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } - + if (m_Command.rd == 0) { return; } + if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } + if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64); + m_Reg.SetMipsReg(m_Command.rd, m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (uint64_t)m_Reg.GetMipsRegLo_S(m_Command.rt) >> (m_Reg.GetMipsRegLo(m_Command.rs) & 0x3F)); + } + else + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } } void LoopAnalysis::SPECIAL_DSRAV() { - if (m_Command.rd == 0) { return; } - if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) - { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } - if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_CONST_64); - m_Reg.SetMipsReg(m_Command.rd,m_Reg.Is64Bit(m_Command.rt)?m_Reg.GetMipsReg_S(m_Command.rt):(__int64)m_Reg.GetMipsRegLo_S(m_Command.rt) >> (m_Reg.GetMipsRegLo(m_Command.rs) & 0x3F)); - } else { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } + if (m_Command.rd == 0) { return; } + if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } + if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64); + m_Reg.SetMipsReg(m_Command.rd, m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg_S(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt) >> (m_Reg.GetMipsRegLo(m_Command.rs) & 0x3F)); + } + else + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } } void LoopAnalysis::SPECIAL_ADD() { - if (m_Command.rd == 0) { return; } - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); + if (m_Command.rd == 0) { return; } + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_ADDU() { - if (m_Command.rd == 0) { return; } - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); + if (m_Command.rd == 0) { return; } + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_SUB() { - if (m_Command.rd == 0) { return; } - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); + if (m_Command.rd == 0) { return; } + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_SUBU() { - if (m_Command.rd == 0) { return; } - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); + if (m_Command.rd == 0) { return; } + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_AND() { - if (m_Command.rd == 0) { return; } - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); + if (m_Command.rd == 0) { return; } + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_OR() { - if (m_Command.rd == 0) { return; } - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); + if (m_Command.rd == 0) { return; } + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_XOR() { - if (m_Command.rd == 0) { return; } - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); + if (m_Command.rd == 0) { return; } + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_NOR() { - if (m_Command.rd == 0) { return; } - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); + if (m_Command.rd == 0) { return; } + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_SLT() { - if (m_Command.rd == 0) { return; } - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); + if (m_Command.rd == 0) { return; } + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_SLTU() { - if (m_Command.rd == 0) { return; } - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); + if (m_Command.rd == 0) { return; } + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); } void LoopAnalysis::SPECIAL_DADD() { - if (m_Command.rd == 0) { return; } - if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) - { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } - if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) { - m_Reg.SetMipsReg(m_Command.rd, - m_Reg.Is64Bit(m_Command.rs)?m_Reg.GetMipsReg(m_Command.rs):(__int64)m_Reg.GetMipsRegLo_S(m_Command.rs) + - m_Reg.Is64Bit(m_Command.rt)?m_Reg.GetMipsReg(m_Command.rt):(__int64)m_Reg.GetMipsRegLo_S(m_Command.rt) - ); - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_CONST_64); - } else { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } + if (m_Command.rd == 0) { return; } + if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } + if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) + { + m_Reg.SetMipsReg(m_Command.rd, + m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs) + + m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt) + ); + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64); + } + else + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } } void LoopAnalysis::SPECIAL_DADDU() { - if (m_Command.rd == 0) { return; } - if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) - { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } - if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) { - m_Reg.SetMipsReg(m_Command.rd, - m_Reg.Is64Bit(m_Command.rs)?m_Reg.GetMipsReg(m_Command.rs):(__int64)m_Reg.GetMipsRegLo_S(m_Command.rs) + - m_Reg.Is64Bit(m_Command.rt)?m_Reg.GetMipsReg(m_Command.rt):(__int64)m_Reg.GetMipsRegLo_S(m_Command.rt) - ); - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_CONST_64); - } else { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } + if (m_Command.rd == 0) { return; } + if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } + if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) + { + m_Reg.SetMipsReg(m_Command.rd, + m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs) + + m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt) + ); + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64); + } + else + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } } void LoopAnalysis::SPECIAL_DSUB() { - if (m_Command.rd == 0) { return; } - if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) - { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } - if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) { - m_Reg.SetMipsReg(m_Command.rd, - m_Reg.Is64Bit(m_Command.rs)?m_Reg.GetMipsReg(m_Command.rs):(__int64)m_Reg.GetMipsRegLo_S(m_Command.rs) - - m_Reg.Is64Bit(m_Command.rt)?m_Reg.GetMipsReg(m_Command.rt):(__int64)m_Reg.GetMipsRegLo_S(m_Command.rt) - ); - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_CONST_64); - } else { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } + if (m_Command.rd == 0) { return; } + if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } + if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) + { + m_Reg.SetMipsReg(m_Command.rd, + m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs) - + m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt) + ); + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64); + } + else + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } } void LoopAnalysis::SPECIAL_DSUBU() { - if (m_Command.rd == 0) { return; } - if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) - { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } - if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) { - m_Reg.SetMipsReg(m_Command.rd, - m_Reg.Is64Bit(m_Command.rs)?m_Reg.GetMipsReg(m_Command.rs):(__int64)m_Reg.GetMipsRegLo_S(m_Command.rs) - - m_Reg.Is64Bit(m_Command.rt)?m_Reg.GetMipsReg(m_Command.rt):(__int64)m_Reg.GetMipsRegLo_S(m_Command.rt) - ); - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_CONST_64); - } else { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } + if (m_Command.rd == 0) { return; } + if (m_Command.rt == m_Command.rd || m_Command.rs == m_Command.rd) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } + if (m_Reg.IsConst(m_Command.rt) && m_Reg.IsConst(m_Command.rs)) + { + m_Reg.SetMipsReg(m_Command.rd, + m_Reg.Is64Bit(m_Command.rs) ? m_Reg.GetMipsReg(m_Command.rs) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rs) - + m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt) + ); + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64); + } + else + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } } void LoopAnalysis::SPECIAL_DSLL() { - if (m_Command.rd == 0) { return; } - if (m_Command.rt == m_Command.rd) - { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } - if (m_Reg.IsConst(m_Command.rt)) { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_CONST_64); - m_Reg.SetMipsReg(m_Command.rd,m_Reg.Is64Bit(m_Command.rt)?m_Reg.GetMipsReg(m_Command.rt):(__int64)m_Reg.GetMipsRegLo_S(m_Command.rt) << m_Command.sa); - } else { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } + if (m_Command.rd == 0) { return; } + if (m_Command.rt == m_Command.rd) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } + if (m_Reg.IsConst(m_Command.rt)) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64); + m_Reg.SetMipsReg(m_Command.rd, m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt) << m_Command.sa); + } + else + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } } void LoopAnalysis::SPECIAL_DSRL() { - if (m_Command.rd == 0) { return; } - if (m_Command.rt == m_Command.rd) - { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } - if (m_Reg.IsConst(m_Command.rt)) { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_CONST_64); - m_Reg.SetMipsReg(m_Command.rd, m_Reg.Is64Bit(m_Command.rt)?m_Reg.GetMipsReg(m_Command.rt):(QWORD)m_Reg.GetMipsRegLo_S(m_Command.rt) >> m_Command.sa); - } else { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } + if (m_Command.rd == 0) { return; } + if (m_Command.rt == m_Command.rd) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } + if (m_Reg.IsConst(m_Command.rt)) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64); + m_Reg.SetMipsReg(m_Command.rd, m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg(m_Command.rt) : (uint64_t)m_Reg.GetMipsRegLo_S(m_Command.rt) >> m_Command.sa); + } + else + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } } void LoopAnalysis::SPECIAL_DSRA() { - if (m_Command.rd == 0) { return; } - if (m_Command.rt == m_Command.rd) - { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } - if (m_Reg.IsConst(m_Command.rt)) { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_CONST_64); - m_Reg.SetMipsReg_S(m_Command.rd, m_Reg.Is64Bit(m_Command.rt)?m_Reg.GetMipsReg_S(m_Command.rt):(__int64)m_Reg.GetMipsRegLo_S(m_Command.rt) >> m_Command.sa); - } else { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } + if (m_Command.rd == 0) { return; } + if (m_Command.rt == m_Command.rd) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } + if (m_Reg.IsConst(m_Command.rt)) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64); + m_Reg.SetMipsReg_S(m_Command.rd, m_Reg.Is64Bit(m_Command.rt) ? m_Reg.GetMipsReg_S(m_Command.rt) : (int64_t)m_Reg.GetMipsRegLo_S(m_Command.rt) >> m_Command.sa); + } + else + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } } void LoopAnalysis::SPECIAL_DSLL32() { - if (m_Command.rd == 0) { return; } - if (m_Command.rt == m_Command.rd) - { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } - if (m_Reg.IsConst(m_Command.rt)) { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_CONST_64); - m_Reg.SetMipsReg(m_Command.rd, m_Reg.GetMipsRegLo(m_Command.rt) << (m_Command.sa + 32)); - } else { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } + if (m_Command.rd == 0) { return; } + if (m_Command.rt == m_Command.rd) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } + if (m_Reg.IsConst(m_Command.rt)) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_64); + m_Reg.SetMipsReg(m_Command.rd, m_Reg.GetMipsRegLo(m_Command.rt) << (m_Command.sa + 32)); + } + else + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } } void LoopAnalysis::SPECIAL_DSRL32() { - if (m_Command.rd == 0) { return; } - if (m_Command.rt == m_Command.rd) - { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } - if (m_Reg.IsConst(m_Command.rt)) { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_CONST_32_SIGN); - m_Reg.SetMipsRegLo(m_Command.rd,(DWORD)(m_Reg.GetMipsReg(m_Command.rt) >> (m_Command.sa + 32))); - } else { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } + if (m_Command.rd == 0) { return; } + if (m_Command.rt == m_Command.rd) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } + if (m_Reg.IsConst(m_Command.rt)) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_32_SIGN); + m_Reg.SetMipsRegLo(m_Command.rd, (uint32_t)(m_Reg.GetMipsReg(m_Command.rt) >> (m_Command.sa + 32))); + } + else + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } } void LoopAnalysis::SPECIAL_DSRA32() { - if (m_Command.rd == 0) { return; } - if (m_Command.rt == m_Command.rd) - { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } - if (m_Reg.IsConst(m_Command.rt)) { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_CONST_32_SIGN); - m_Reg.SetMipsRegLo(m_Command.rd,(DWORD)(m_Reg.GetMipsReg_S(m_Command.rt) >> (m_Command.sa + 32))); - } else { - m_Reg.SetMipsRegState(m_Command.rd,CRegInfo::STATE_MODIFIED); - } + if (m_Command.rd == 0) { return; } + if (m_Command.rt == m_Command.rd) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } + if (m_Reg.IsConst(m_Command.rt)) + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_32_SIGN); + m_Reg.SetMipsRegLo(m_Command.rd, (uint32_t)(m_Reg.GetMipsReg_S(m_Command.rt) >> (m_Command.sa + 32))); + } + else + { + m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_MODIFIED); + } } diff --git a/Source/Project64/N64 System/Recompiler/Loop Analysis.h b/Source/Project64/N64 System/Recompiler/Loop Analysis.h index 37b3f5620..b840571b9 100644 --- a/Source/Project64/N64 System/Recompiler/Loop Analysis.h +++ b/Source/Project64/N64 System/Recompiler/Loop Analysis.h @@ -16,71 +16,71 @@ class CCodeBlock; class LoopAnalysis { public: - LoopAnalysis(CCodeBlock * CodeBlock, CCodeSection * Section); - ~LoopAnalysis(); + LoopAnalysis(CCodeBlock * CodeBlock, CCodeSection * Section); + ~LoopAnalysis(); - bool SetupRegisterForLoop(); + bool SetupRegisterForLoop(); private: - LoopAnalysis(); // Disable default constructor - LoopAnalysis(const LoopAnalysis&); // Disable copy constructor - LoopAnalysis& operator=(const LoopAnalysis&); // Disable assignment + LoopAnalysis(); // Disable default constructor + LoopAnalysis(const LoopAnalysis&); // Disable copy constructor + LoopAnalysis& operator=(const LoopAnalysis&); // Disable assignment - bool SetupEnterSection ( CCodeSection * Section, bool & bChanged, bool & bSkipedSection ); - bool CheckLoopRegisterUsage ( CCodeSection * Section ); - bool SyncRegState ( CRegInfo & RegSet, const CRegInfo& SyncReg ); - void SetJumpRegSet ( CCodeSection * Section, const CRegInfo &Reg ); - void SetContinueRegSet(CCodeSection * Section, const CRegInfo &Reg); + bool SetupEnterSection(CCodeSection * Section, bool & bChanged, bool & bSkipedSection); + bool CheckLoopRegisterUsage(CCodeSection * Section); + bool SyncRegState(CRegInfo & RegSet, const CRegInfo& SyncReg); + void SetJumpRegSet(CCodeSection * Section, const CRegInfo &Reg); + void SetContinueRegSet(CCodeSection * Section, const CRegInfo &Reg); - /********************** R4300i OpCodes: Special **********************/ - void SPECIAL_SLL(); - void SPECIAL_SRL(); - void SPECIAL_SRA(); - void SPECIAL_SLLV(); - void SPECIAL_SRLV(); - void SPECIAL_SRAV(); - void SPECIAL_JR(); - void SPECIAL_JALR(); - void SPECIAL_SYSCALL(CCodeSection * Section); - void SPECIAL_BREAK(CCodeSection * Section); - void SPECIAL_MFHI(); - void SPECIAL_MTHI(); - void SPECIAL_MFLO(); - void SPECIAL_MTLO(); - void SPECIAL_DSLLV(); - void SPECIAL_DSRLV(); - void SPECIAL_DSRAV(); - void SPECIAL_ADD(); - void SPECIAL_ADDU(); - void SPECIAL_SUB(); - void SPECIAL_SUBU(); - void SPECIAL_AND(); - void SPECIAL_OR(); - void SPECIAL_XOR(); - void SPECIAL_NOR(); - void SPECIAL_SLT(); - void SPECIAL_SLTU(); - void SPECIAL_DADD(); - void SPECIAL_DADDU(); - void SPECIAL_DSUB(); - void SPECIAL_DSUBU(); - void SPECIAL_DSLL(); - void SPECIAL_DSRL(); - void SPECIAL_DSRA(); - void SPECIAL_DSLL32(); - void SPECIAL_DSRL32(); - void SPECIAL_DSRA32(); + /********************** R4300i OpCodes: Special **********************/ + void SPECIAL_SLL(); + void SPECIAL_SRL(); + void SPECIAL_SRA(); + void SPECIAL_SLLV(); + void SPECIAL_SRLV(); + void SPECIAL_SRAV(); + void SPECIAL_JR(); + void SPECIAL_JALR(); + void SPECIAL_SYSCALL(CCodeSection * Section); + void SPECIAL_BREAK(CCodeSection * Section); + void SPECIAL_MFHI(); + void SPECIAL_MTHI(); + void SPECIAL_MFLO(); + void SPECIAL_MTLO(); + void SPECIAL_DSLLV(); + void SPECIAL_DSRLV(); + void SPECIAL_DSRAV(); + void SPECIAL_ADD(); + void SPECIAL_ADDU(); + void SPECIAL_SUB(); + void SPECIAL_SUBU(); + void SPECIAL_AND(); + void SPECIAL_OR(); + void SPECIAL_XOR(); + void SPECIAL_NOR(); + void SPECIAL_SLT(); + void SPECIAL_SLTU(); + void SPECIAL_DADD(); + void SPECIAL_DADDU(); + void SPECIAL_DSUB(); + void SPECIAL_DSUBU(); + void SPECIAL_DSLL(); + void SPECIAL_DSRL(); + void SPECIAL_DSRA(); + void SPECIAL_DSLL32(); + void SPECIAL_DSRL32(); + void SPECIAL_DSRA32(); - typedef std::map RegisterMap; + typedef std::map RegisterMap; - RegisterMap m_EnterRegisters; - RegisterMap m_ContinueRegisters; - RegisterMap m_JumpRegisters; - CCodeSection * m_EnterSection; - CCodeBlock * m_BlockInfo; - DWORD m_PC; - CRegInfo m_Reg; - STEP_TYPE m_NextInstruction; - OPCODE m_Command; - DWORD m_Test; + RegisterMap m_EnterRegisters; + RegisterMap m_ContinueRegisters; + RegisterMap m_JumpRegisters; + CCodeSection * m_EnterSection; + CCodeBlock * m_BlockInfo; + uint32_t m_PC; + CRegInfo m_Reg; + STEP_TYPE m_NextInstruction; + OPCODE m_Command; + uint32_t m_Test; }; From d06eae94578e71a8f115069313f97881f37b42a3 Mon Sep 17 00:00:00 2001 From: zilmar Date: Tue, 10 Nov 2015 07:19:27 +1100 Subject: [PATCH 110/213] [Project64] Update Recompiler Class.cpp to use standard types --- .../Recompiler/Recompiler Class.cpp | 1799 +++++++++-------- .../N64 System/Recompiler/Recompiler Class.h | 91 +- 2 files changed, 972 insertions(+), 918 deletions(-) diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp index 41f88d0e5..e3c578a8d 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp @@ -10,996 +10,1049 @@ ****************************************************************************/ #include "stdafx.h" -CRecompiler::CRecompiler(CRegisters & Registers, CProfiling & Profile, bool & EndEmulation ) : - m_Registers(Registers), - m_Profile(Profile), - m_EndEmulation(EndEmulation), - PROGRAM_COUNTER(Registers.m_PROGRAM_COUNTER) +CRecompiler::CRecompiler(CRegisters & Registers, CProfiling & Profile, bool & EndEmulation) : + m_Registers(Registers), + m_Profile(Profile), + m_EndEmulation(EndEmulation), + PROGRAM_COUNTER(Registers.m_PROGRAM_COUNTER) { - if (g_MMU != NULL) - { - ResetMemoryStackPos(); - } + if (g_MMU != NULL) + { + ResetMemoryStackPos(); + } } CRecompiler::~CRecompiler() { - ResetRecompCode(false); + ResetRecompCode(false); } void CRecompiler::Run() { - CoInitialize(NULL); - if (bLogX86Code()) - { - Start_x86_Log(); - } + CoInitialize(NULL); + if (bLogX86Code()) + { + Start_x86_Log(); + } - if (!CRecompMemory::AllocateMemory()) - { - WriteTrace(TraceError,__FUNCTION__ ": AllocateMemory failed"); - return; - } - if (!CFunctionMap::AllocateMemory()) - { - WriteTrace(TraceError,__FUNCTION__ ": AllocateMemory failed"); - return; - } - m_EndEmulation = false; + if (!CRecompMemory::AllocateMemory()) + { + WriteTrace(TraceError, __FUNCTION__ ": AllocateMemory failed"); + return; + } + if (!CFunctionMap::AllocateMemory()) + { + WriteTrace(TraceError, __FUNCTION__ ": AllocateMemory failed"); + return; + } + m_EndEmulation = false; #ifdef tofix - *g_MemoryStack = (DWORD)(RDRAM+(_GPR[29].W[0] & 0x1FFFFFFF)); + *g_MemoryStack = (uint32_t)(RDRAM+(_GPR[29].W[0] & 0x1FFFFFFF)); #endif - __try { - if (g_System->LookUpMode() == FuncFind_VirtualLookup) - { - if (g_System->bSMM_ValidFunc()) - { - RecompilerMain_VirtualTable_validate(); - } else { - RecompilerMain_VirtualTable(); - } - } - else if (g_System->LookUpMode() == FuncFind_ChangeMemory) - { - RecompilerMain_ChangeMemory(); - } - else - { - if (g_System->bUseTlb()) - { - if (g_System->bSMM_ValidFunc()) - { - RecompilerMain_Lookup_validate_TLB(); - } else { - RecompilerMain_Lookup_TLB(); - } - } else { - if (g_System->bSMM_ValidFunc()) - { - RecompilerMain_Lookup_validate(); - } else { - RecompilerMain_Lookup(); - } - } - } - } - __except( g_MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) + __try { - g_Notify->DisplayError(MSG_UNKNOWN_MEM_ACTION); - } + if (g_System->LookUpMode() == FuncFind_VirtualLookup) + { + if (g_System->bSMM_ValidFunc()) + { + RecompilerMain_VirtualTable_validate(); + } + else + { + RecompilerMain_VirtualTable(); + } + } + else if (g_System->LookUpMode() == FuncFind_ChangeMemory) + { + RecompilerMain_ChangeMemory(); + } + else + { + if (g_System->bUseTlb()) + { + if (g_System->bSMM_ValidFunc()) + { + RecompilerMain_Lookup_validate_TLB(); + } + else + { + RecompilerMain_Lookup_TLB(); + } + } + else + { + if (g_System->bSMM_ValidFunc()) + { + RecompilerMain_Lookup_validate(); + } + else + { + RecompilerMain_Lookup(); + } + } + } + } + __except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation())) + { + g_Notify->DisplayError(MSG_UNKNOWN_MEM_ACTION); + } } void CRecompiler::RecompilerMain_VirtualTable() { - bool & Done = m_EndEmulation; + bool & Done = m_EndEmulation; uint32_t & PC = PROGRAM_COUNTER; - while(!Done) - { - if (!g_TransVaddr->ValidVaddr(PC)) - { - m_Registers.DoTLBReadMiss(false,PC); - if (!g_TransVaddr->ValidVaddr(PC)) - { - g_Notify->DisplayError(stdstr_f("Failed to translate PC to a PAddr: %X\n\nEmulation stopped",PC).ToUTF16().c_str()); - return; - } - continue; - } + while (!Done) + { + if (!g_TransVaddr->ValidVaddr(PC)) + { + m_Registers.DoTLBReadMiss(false, PC); + if (!g_TransVaddr->ValidVaddr(PC)) + { + g_Notify->DisplayError(stdstr_f("Failed to translate PC to a PAddr: %X\n\nEmulation stopped", PC).ToUTF16().c_str()); + return; + } + continue; + } - PCCompiledFunc_TABLE & table = FunctionTable()[PC >> 0xC]; - DWORD TableEntry = (PC & 0xFFF) >> 2; - if (table) - { - CCompiledFunc * info = table[TableEntry]; - if (info != NULL) - { - (info->Function())(); - continue; - } - } - CCompiledFunc * info = CompilerCode(); - if (info == NULL || m_EndEmulation) - { - break; - } + PCCompiledFunc_TABLE & table = FunctionTable()[PC >> 0xC]; + uint32_t TableEntry = (PC & 0xFFF) >> 2; + if (table) + { + CCompiledFunc * info = table[TableEntry]; + if (info != NULL) + { + (info->Function())(); + continue; + } + } + CCompiledFunc * info = CompilerCode(); + if (info == NULL || m_EndEmulation) + { + break; + } - if (table == NULL) - { - table = new PCCompiledFunc[(0x1000 >> 2)]; - if (table == NULL) - { - WriteTrace(TraceError,__FUNCTION__ ": failed to allocate PCCompiledFunc"); - g_Notify->FatalError(MSG_MEM_ALLOC_ERROR); - } - memset(table,0,sizeof(PCCompiledFunc) * (0x1000 >> 2)); - if (g_System->bSMM_Protect()) - { - WriteTraceF(TraceError,__FUNCTION__ ": Create Table (%X): Index = %d",table, PC >> 0xC); - g_MMU->ProtectMemory(PC & ~0xFFF,PC | 0xFFF); - } - } + if (table == NULL) + { + table = new PCCompiledFunc[(0x1000 >> 2)]; + if (table == NULL) + { + WriteTrace(TraceError, __FUNCTION__ ": failed to allocate PCCompiledFunc"); + g_Notify->FatalError(MSG_MEM_ALLOC_ERROR); + } + memset(table, 0, sizeof(PCCompiledFunc) * (0x1000 >> 2)); + if (g_System->bSMM_Protect()) + { + WriteTraceF(TraceError, __FUNCTION__ ": Create Table (%X): Index = %d", table, PC >> 0xC); + g_MMU->ProtectMemory(PC & ~0xFFF, PC | 0xFFF); + } + } - table[TableEntry] = info; - (info->Function())(); - } + table[TableEntry] = info; + (info->Function())(); + } } void CRecompiler::RecompilerMain_VirtualTable_validate() { - g_Notify->BreakPoint(__FILEW__,__LINE__); -/* PCCompiledFunc_TABLE * m_FunctionTable = m_Functions.GetFunctionTable(); + g_Notify->BreakPoint(__FILEW__, __LINE__); + /* PCCompiledFunc_TABLE * m_FunctionTable = m_Functions.GetFunctionTable(); - while(!m_EndEmulation) - { - /*if (NextInstruction == DELAY_SLOT) - { - CCompiledFunc * Info = m_FunctionsDelaySlot.FindFunction(PROGRAM_COUNTER); - //Find Block on hash table - if (Info == NULL) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); -#ifdef tofix - if (!g_TLB->ValidVaddr(PROGRAM_COUNTER)) - { - DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER); - NextInstruction = NORMAL; - if (!g_TLB->ValidVaddr(PROGRAM_COUNTER)) - { - g_Notify->DisplayError(L"Failed to translate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER); - return; - } - continue; - } -#endif - //Find Block on hash table - Info = CompileDelaySlot(PROGRAM_COUNTER); + while(!m_EndEmulation) + { + /*if (NextInstruction == DELAY_SLOT) + { + CCompiledFunc * Info = m_FunctionsDelaySlot.FindFunction(PROGRAM_COUNTER); + //Find Block on hash table + if (Info == NULL) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + #ifdef tofix + if (!g_TLB->ValidVaddr(PROGRAM_COUNTER)) + { + DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER); + NextInstruction = NORMAL; + if (!g_TLB->ValidVaddr(PROGRAM_COUNTER)) + { + g_Notify->DisplayError(L"Failed to translate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER); + return; + } + continue; + } + #endif + //Find Block on hash table + Info = CompileDelaySlot(PROGRAM_COUNTER); - if (Info == NULL || EndEmulation()) - { - break; - } - } - const BYTE * Block = Info->FunctionAddr(); - if ((*Info->MemLocation[0] != Info->MemContents[0]) || - (*Info->MemLocation[1] != Info->MemContents[1])) - { - ClearRecompCode_Virt((Info->VStartPC() - 0x1000) & ~0xFFF,0x2000,Remove_ValidateFunc); - NextInstruction = DELAY_SLOT; - Info = NULL; - continue; - } - _asm { - pushad - call Block - popad - } - continue; - }*/ -/* PCCompiledFunc_TABLE table = m_FunctionTable[PROGRAM_COUNTER >> 0xC]; - if (table) - { - CCompiledFunc * info = table[(PROGRAM_COUNTER & 0xFFF) >> 2]; - if (info != NULL) - { - if ((*info->MemLocation[0] != info->MemContents[0]) || - (*info->MemLocation[1] != info->MemContents[1])) - { - ClearRecompCode_Virt((info->VStartPC() - 0x1000) & ~0xFFF,0x3000,Remove_ValidateFunc); - info = NULL; - continue; - } - const BYTE * Block = info->FunctionAddr(); - _asm { - pushad - call Block - popad - } - continue; - } - } - g_Notify->BreakPoint(__FILEW__,__LINE__); -#ifdef tofix - if (!g_TLB->ValidVaddr(PROGRAM_COUNTER)) - { - DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER); - NextInstruction = NORMAL; - if (!g_TLB->ValidVaddr(PROGRAM_COUNTER)) - { - g_Notify->DisplayError(L"Failed to translate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER); - return; - } - } -#endif - CCompiledFunc * info = CompilerCode(); + if (Info == NULL || EndEmulation()) + { + break; + } + } + const uint8_t * Block = Info->FunctionAddr(); + if ((*Info->MemLocation[0] != Info->MemContents[0]) || + (*Info->MemLocation[1] != Info->MemContents[1])) + { + ClearRecompCode_Virt((Info->VStartPC() - 0x1000) & ~0xFFF,0x2000,Remove_ValidateFunc); + NextInstruction = DELAY_SLOT; + Info = NULL; + continue; + } + _asm { + pushad + call Block + popad + } + continue; + }*/ + /* PCCompiledFunc_TABLE table = m_FunctionTable[PROGRAM_COUNTER >> 0xC]; + if (table) + { + CCompiledFunc * info = table[(PROGRAM_COUNTER & 0xFFF) >> 2]; + if (info != NULL) + { + if ((*info->MemLocation[0] != info->MemContents[0]) || + (*info->MemLocation[1] != info->MemContents[1])) + { + ClearRecompCode_Virt((info->VStartPC() - 0x1000) & ~0xFFF,0x3000,Remove_ValidateFunc); + info = NULL; + continue; + } + const uint8_t * Block = info->FunctionAddr(); + _asm { + pushad + call Block + popad + } + continue; + } + } + g_Notify->BreakPoint(__FILEW__,__LINE__); + #ifdef tofix + if (!g_TLB->ValidVaddr(PROGRAM_COUNTER)) + { + DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER); + NextInstruction = NORMAL; + if (!g_TLB->ValidVaddr(PROGRAM_COUNTER)) + { + g_Notify->DisplayError(L"Failed to translate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER); + return; + } + } + #endif + CCompiledFunc * info = CompilerCode(); - if (info == NULL || EndEmulation()) - { - break; - } + if (info == NULL || EndEmulation()) + { + break; + } + } - } + /* + while(!m_EndEmulation) + { + if (!g_MMU->ValidVaddr(PROGRAM_COUNTER)) + { + DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER); + NextInstruction = NORMAL; + if (!g_MMU->ValidVaddr(PROGRAM_COUNTER)) + { + g_Notify->DisplayError(L"Failed to translate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER); + return; + } + } + if (NextInstruction == DELAY_SLOT) + { + CCompiledFunc * Info = m_FunctionsDelaySlot.FindFunction(PROGRAM_COUNTER); -/* - while(!m_EndEmulation) - { - if (!g_MMU->ValidVaddr(PROGRAM_COUNTER)) - { - DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER); - NextInstruction = NORMAL; - if (!g_MMU->ValidVaddr(PROGRAM_COUNTER)) - { - g_Notify->DisplayError(L"Failed to translate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER); - return; - } - } - if (NextInstruction == DELAY_SLOT) - { - CCompiledFunc * Info = m_FunctionsDelaySlot.FindFunction(PROGRAM_COUNTER); + //Find Block on hash table + if (Info == NULL) + { + Info = CompileDelaySlot(PROGRAM_COUNTER); - //Find Block on hash table - if (Info == NULL) - { - Info = CompileDelaySlot(PROGRAM_COUNTER); + if (Info == NULL || EndEmulation()) + { + break; + } + } + if (bSMM_ValidFunc()) + { + if ((*Info->MemLocation[0] != Info->MemContents[0]) || + (*Info->MemLocation[1] != Info->MemContents[1])) + { + ClearRecompCode_Virt((Info->StartPC() - 0x1000) & ~0xFFF,0x2000,Remove_ValidateFunc); + NextInstruction = DELAY_SLOT; + Info = NULL; + continue; + } + } + const uint8_t * Block = Info->FunctionAddr(); + _asm { + pushad + call Block + popad + } + continue; + } - if (Info == NULL || EndEmulation()) - { - break; - } - } - if (bSMM_ValidFunc()) - { - if ((*Info->MemLocation[0] != Info->MemContents[0]) || - (*Info->MemLocation[1] != Info->MemContents[1])) - { - ClearRecompCode_Virt((Info->StartPC() - 0x1000) & ~0xFFF,0x2000,Remove_ValidateFunc); - NextInstruction = DELAY_SLOT; - Info = NULL; - continue; - } - } - const BYTE * Block = Info->FunctionAddr(); - _asm { - pushad - call Block - popad - } - continue; - } - - CCompiledFunc * Info = m_Functions.FindFunction(PROGRAM_COUNTER); + CCompiledFunc * Info = m_Functions.FindFunction(PROGRAM_COUNTER); - //Find Block on hash table - if (Info == NULL) - { - Info = CompilerCode(); + //Find Block on hash table + if (Info == NULL) + { + Info = CompilerCode(); - if (Info == NULL || EndEmulation()) - { - break; - } - } - if (bSMM_ValidFunc()) - { - if ((*Info->MemLocation[0] != Info->MemContents[0]) || - (*Info->MemLocation[1] != Info->MemContents[1])) - { - ClearRecompCode_Virt((Info->StartPC() - 0x1000) & ~0xFFF,0x3000,Remove_ValidateFunc); - Info = NULL; - continue; - } - } - const BYTE * Block = Info->FunctionAddr(); - _asm { - pushad - call Block - popad - } - } - */ + if (Info == NULL || EndEmulation()) + { + break; + } + } + if (bSMM_ValidFunc()) + { + if ((*Info->MemLocation[0] != Info->MemContents[0]) || + (*Info->MemLocation[1] != Info->MemContents[1])) + { + ClearRecompCode_Virt((Info->StartPC() - 0x1000) & ~0xFFF,0x3000,Remove_ValidateFunc); + Info = NULL; + continue; + } + } + const uint8_t * Block = Info->FunctionAddr(); + _asm { + pushad + call Block + popad + } + } + */ } void CRecompiler::RecompilerMain_Lookup() { - while(!m_EndEmulation) - { - DWORD PhysicalAddr = PROGRAM_COUNTER & 0x1FFFFFFF; - if (PhysicalAddr < g_System->RdramSize()) + while (!m_EndEmulation) + { + uint32_t PhysicalAddr = PROGRAM_COUNTER & 0x1FFFFFFF; + if (PhysicalAddr < g_System->RdramSize()) + { + CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2]; + if (info == NULL) + { + info = CompilerCode(); + if (info == NULL || m_EndEmulation) + { + break; + } + if (g_System->bSMM_Protect()) + { + g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF, PROGRAM_COUNTER | 0xFFF); + } + JumpTable()[PhysicalAddr >> 2] = info; + } + (info->Function())(); + } + else { - CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2]; - if (info == NULL) - { - info = CompilerCode(); - if (info == NULL || m_EndEmulation) - { - break; - } - if (g_System->bSMM_Protect()) - { - g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF,PROGRAM_COUNTER | 0xFFF); - } - JumpTable()[PhysicalAddr >> 2] = info; - } - (info->Function())(); - } else { - DWORD opsExecuted = 0; + uint32_t opsExecuted = 0; - while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr) && PhysicalAddr >= g_System->RdramSize()) - { - CInterpreterCPU::ExecuteOps(g_System->CountPerOp()); - opsExecuted += g_System->CountPerOp(); - } + while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= g_System->RdramSize()) + { + CInterpreterCPU::ExecuteOps(g_System->CountPerOp()); + opsExecuted += g_System->CountPerOp(); + } - if (g_SyncSystem) - { - g_System->UpdateSyncCPU(g_SyncSystem,opsExecuted); - g_System->SyncCPU(g_SyncSystem); - } - } - } - /* - DWORD Addr; - CCompiledFunc * Info; - //const BYTE * Block; + if (g_SyncSystem) + { + g_System->UpdateSyncCPU(g_SyncSystem, opsExecuted); + g_System->SyncCPU(g_SyncSystem); + } + } + } + /* + uint32_t Addr; + CCompiledFunc * Info; + //const uint8_t * Block; - while(!m_EndEmulation) - { - /*if (bUseTlb()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); -#ifdef tofix - if (!g_TLB->TranslateVaddr(PROGRAM_COUNTER, Addr)) - { - DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER); - NextInstruction = NORMAL; - if (!TranslateVaddr(PROGRAM_COUNTER, &Addr)) { - g_Notify->DisplayError(L"Failed to translate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER); - return; - } - } -#endif - } else { - Addr = PROGRAM_COUNTER & 0x1FFFFFFF; - }*/ + while(!m_EndEmulation) + { + /*if (bUseTlb()) + { + g_Notify->BreakPoint(__FILEW__,__LINE__); + #ifdef tofix + if (!g_TLB->TranslateVaddr(PROGRAM_COUNTER, Addr)) + { + DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER); + NextInstruction = NORMAL; + if (!TranslateVaddr(PROGRAM_COUNTER, &Addr)) { + g_Notify->DisplayError(L"Failed to translate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER); + return; + } + } + #endif + } else { + Addr = PROGRAM_COUNTER & 0x1FFFFFFF; + }*/ - /* if (NextInstruction == DELAY_SLOT) { - CCompiledFunc * Info = m_FunctionsDelaySlot.FindFunction(PROGRAM_COUNTER); + /* if (NextInstruction == DELAY_SLOT) { + CCompiledFunc * Info = m_FunctionsDelaySlot.FindFunction(PROGRAM_COUNTER); - //Find Block on hash table - if (Info == NULL) - { - Info = CompileDelaySlot(PROGRAM_COUNTER); + //Find Block on hash table + if (Info == NULL) + { + Info = CompileDelaySlot(PROGRAM_COUNTER); - if (Info == NULL || EndEmulation()) - { - break; - } - } - if (bSMM_ValidFunc()) - { - if ((*Info->MemLocation[0] != Info->MemContents[0]) || - (*Info->MemLocation[1] != Info->MemContents[1])) - { - ClearRecompCode_Virt((Info->VStartPC() - 0x1000) & ~0xFFF,0x2000,Remove_ValidateFunc); - NextInstruction = DELAY_SLOT; - Info = NULL; - continue; - } - } - const BYTE * Block = Info->FunctionAddr(); - _asm { - pushad - call Block - popad - } - continue; - } + if (Info == NULL || EndEmulation()) + { + break; + } + } + if (bSMM_ValidFunc()) + { + if ((*Info->MemLocation[0] != Info->MemContents[0]) || + (*Info->MemLocation[1] != Info->MemContents[1])) + { + ClearRecompCode_Virt((Info->VStartPC() - 0x1000) & ~0xFFF,0x2000,Remove_ValidateFunc); + NextInstruction = DELAY_SLOT; + Info = NULL; + continue; + } + } + const uint8_t * Block = Info->FunctionAddr(); + _asm { + pushad + call Block + popad + } + continue; + } - __try { - if (Addr > 0x10000000) - { - if (bRomInMemory()) - { - if (Addr > 0x20000000) - { - WriteTraceF(TraceDebug,"Executing from non mapped space .1 PC: %X Addr: %X",PROGRAM_COUNTER, Addr); - g_Notify->DisplayError(GS(MSG_NONMAPPED_SPACE)); - break; - } - Info = (CCompiledFunc *)*(JumpTable + (Addr >> 2)); - } else { - if (PROGRAM_COUNTER >= 0xB0000000 && PROGRAM_COUNTER < (RomFileSize | 0xB0000000)) { - while (PROGRAM_COUNTER >= 0xB0000000 && PROGRAM_COUNTER < (RomFileSize | 0xB0000000)) { - ExecuteInterpreterOpCode(); - } - continue; - } else { - WriteTraceF(TraceDebug,"Executing from non mapped space .1 PC: %X Addr: %X",PROGRAM_COUNTER, Addr); - g_Notify->DisplayError(GS(MSG_NONMAPPED_SPACE)); - break; - } - } - } else { - Info = (CCompiledFunc *)*(JumpTable + (Addr >> 2)); - } - } __except(EXCEPTION_EXECUTE_HANDLER) { - if (PROGRAM_COUNTER >= 0xB0000000 && PROGRAM_COUNTER < (RomFileSize | 0xB0000000)) { - while (PROGRAM_COUNTER >= 0xB0000000 && PROGRAM_COUNTER < (RomFileSize | 0xB0000000)) { - ExecuteInterpreterOpCode(); - } - continue; - } else { - WriteTraceF(TraceDebug,"Executing from non mapped space .2 PC: %X Addr: %X",PROGRAM_COUNTER, Addr); - g_Notify->DisplayError(GS(MSG_NONMAPPED_SPACE)); - return; - } - } - - if (Info == NULL) - { - Info = CompilerCode(); + __try { + if (Addr > 0x10000000) + { + if (bRomInMemory()) + { + if (Addr > 0x20000000) + { + WriteTraceF(TraceDebug,"Executing from non mapped space .1 PC: %X Addr: %X",PROGRAM_COUNTER, Addr); + g_Notify->DisplayError(GS(MSG_NONMAPPED_SPACE)); + break; + } + Info = (CCompiledFunc *)*(JumpTable + (Addr >> 2)); + } else { + if (PROGRAM_COUNTER >= 0xB0000000 && PROGRAM_COUNTER < (RomFileSize | 0xB0000000)) { + while (PROGRAM_COUNTER >= 0xB0000000 && PROGRAM_COUNTER < (RomFileSize | 0xB0000000)) { + ExecuteInterpreterOpCode(); + } + continue; + } else { + WriteTraceF(TraceDebug,"Executing from non mapped space .1 PC: %X Addr: %X",PROGRAM_COUNTER, Addr); + g_Notify->DisplayError(GS(MSG_NONMAPPED_SPACE)); + break; + } + } + } else { + Info = (CCompiledFunc *)*(JumpTable + (Addr >> 2)); + } + } __except(EXCEPTION_EXECUTE_HANDLER) { + if (PROGRAM_COUNTER >= 0xB0000000 && PROGRAM_COUNTER < (RomFileSize | 0xB0000000)) { + while (PROGRAM_COUNTER >= 0xB0000000 && PROGRAM_COUNTER < (RomFileSize | 0xB0000000)) { + ExecuteInterpreterOpCode(); + } + continue; + } else { + WriteTraceF(TraceDebug,"Executing from non mapped space .2 PC: %X Addr: %X",PROGRAM_COUNTER, Addr); + g_Notify->DisplayError(GS(MSG_NONMAPPED_SPACE)); + return; + } + } - if (Info == NULL || EndEmulation()) - { - break; - } - *(JumpTable + (Addr >> 2)) = (void *)Info; + if (Info == NULL) + { + Info = CompilerCode(); -// if (SelfModCheck == ModCode_ProtectedMemory) { -// VirtualProtect(RDRAM + Addr, 4, PAGE_READONLY, &OldProtect); -// } - } - if (bSMM_ValidFunc()) - { - if ((*Info->MemLocation[0] != Info->MemContents[0]) || - (*Info->MemLocation[1] != Info->MemContents[1])) - { - ClearRecompCode_Virt((Info->VStartPC() - 0x1000) & ~0xFFF,0x3000,Remove_ValidateFunc); - Info = NULL; - continue; - } - } - g_Notify->BreakPoint(__FILEW__,__LINE__); -#ifdef tofix - if (Profiling && IndvidualBlock) { - static DWORD ProfAddress = 0; + if (Info == NULL || EndEmulation()) + { + break; + } + *(JumpTable + (Addr >> 2)) = (void *)Info; - if ((PROGRAM_COUNTER & ~0xFFF) != ProfAddress) { - char Label[100]; + // if (SelfModCheck == ModCode_ProtectedMemory) { + // VirtualProtect(RDRAM + Addr, 4, PAGE_READONLY, &OldProtect); + // } + } + if (bSMM_ValidFunc()) + { + if ((*Info->MemLocation[0] != Info->MemContents[0]) || + (*Info->MemLocation[1] != Info->MemContents[1])) + { + ClearRecompCode_Virt((Info->VStartPC() - 0x1000) & ~0xFFF,0x3000,Remove_ValidateFunc); + Info = NULL; + continue; + } + } + g_Notify->BreakPoint(__FILEW__,__LINE__); + #ifdef tofix + if (Profiling && IndvidualBlock) { + static uint32_t ProfAddress = 0; - ProfAddress = PROGRAM_COUNTER & ~0xFFF; - sprintf(Label,"PC: %X to %X",ProfAddress,ProfAddress+ 0xFFC); -// StartTimer(Label); - } - /*if (PROGRAM_COUNTER >= 0x800DD000 && PROGRAM_COUNTER <= 0x800DDFFC) { - char Label[100]; - sprintf(Label,"PC: %X Block: %X",PROGRAM_COUNTER,Block); - StartTimer(Label); - }*/ -// } else if ((Profiling || ShowCPUPer) && ProfilingLabel[0] == 0) { -// StartTimer("r4300i Running"); -/* } -#endif - const BYTE * Block = Info->FunctionAddr(); - _asm { - pushad - call Block - popad - } - }*/ + if ((PROGRAM_COUNTER & ~0xFFF) != ProfAddress) { + char Label[100]; + + ProfAddress = PROGRAM_COUNTER & ~0xFFF; + sprintf(Label,"PC: %X to %X",ProfAddress,ProfAddress+ 0xFFC); + // StartTimer(Label); + } + /*if (PROGRAM_COUNTER >= 0x800DD000 && PROGRAM_COUNTER <= 0x800DDFFC) { + char Label[100]; + sprintf(Label,"PC: %X Block: %X",PROGRAM_COUNTER,Block); + StartTimer(Label); + }*/ + // } else if ((Profiling || ShowCPUPer) && ProfilingLabel[0] == 0) { + // StartTimer("r4300i Running"); + /* } + #endif + const uint8_t * Block = Info->FunctionAddr(); + _asm { + pushad + call Block + popad + } + }*/ } void CRecompiler::RecompilerMain_Lookup_TLB() { - DWORD PhysicalAddr; + uint32_t PhysicalAddr; - while(!m_EndEmulation) - { - if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr)) - { - m_Registers.DoTLBReadMiss(false,PROGRAM_COUNTER); - if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr)) - { - g_Notify->DisplayError(stdstr_f("Failed to translate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER).ToUTF16().c_str()); - m_EndEmulation = true; - } - continue; - } - if (PhysicalAddr < g_System->RdramSize()) - { - CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2]; + while (!m_EndEmulation) + { + if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr)) + { + m_Registers.DoTLBReadMiss(false, PROGRAM_COUNTER); + if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr)) + { + g_Notify->DisplayError(stdstr_f("Failed to translate PC to a PAddr: %X\n\nEmulation stopped", PROGRAM_COUNTER).ToUTF16().c_str()); + m_EndEmulation = true; + } + continue; + } + if (PhysicalAddr < g_System->RdramSize()) + { + CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2]; - if (info == NULL) - { - info = CompilerCode(); - if (info == NULL || m_EndEmulation) - { - break; - } - if (g_System->bSMM_Protect()) - { - g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF,PROGRAM_COUNTER | 0xFFF); - } - JumpTable()[PhysicalAddr >> 2] = info; - } - (info->Function())(); - } - else - { - DWORD opsExecuted = 0; + if (info == NULL) + { + info = CompilerCode(); + if (info == NULL || m_EndEmulation) + { + break; + } + if (g_System->bSMM_Protect()) + { + g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF, PROGRAM_COUNTER | 0xFFF); + } + JumpTable()[PhysicalAddr >> 2] = info; + } + (info->Function())(); + } + else + { + uint32_t opsExecuted = 0; - while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr) && PhysicalAddr >= g_System->RdramSize()) - { - CInterpreterCPU::ExecuteOps(g_System->CountPerOp()); - opsExecuted += g_System->CountPerOp(); - } + while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= g_System->RdramSize()) + { + CInterpreterCPU::ExecuteOps(g_System->CountPerOp()); + opsExecuted += g_System->CountPerOp(); + } - if (g_SyncSystem) - { - g_System->UpdateSyncCPU(g_SyncSystem,opsExecuted); - g_System->SyncCPU(g_SyncSystem); - } - } - } + if (g_SyncSystem) + { + g_System->UpdateSyncCPU(g_SyncSystem, opsExecuted); + g_System->SyncCPU(g_SyncSystem); + } + } + } } void CRecompiler::RecompilerMain_Lookup_validate() { - while(!m_EndEmulation) - { - DWORD PhysicalAddr = PROGRAM_COUNTER & 0x1FFFFFFF; - if (PhysicalAddr < g_System->RdramSize()) + while (!m_EndEmulation) + { + uint32_t PhysicalAddr = PROGRAM_COUNTER & 0x1FFFFFFF; + if (PhysicalAddr < g_System->RdramSize()) + { + CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2]; + if (info == NULL) + { + info = CompilerCode(); + if (info == NULL || m_EndEmulation) + { + break; + } + if (g_System->bSMM_Protect()) + { + g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF, PROGRAM_COUNTER | 0xFFF); + } + JumpTable()[PhysicalAddr >> 2] = info; + } + else + { + if (*(info->MemLocation(0)) != info->MemContents(0) || + *(info->MemLocation(1)) != info->MemContents(1)) + { + ClearRecompCode_Virt((info->EnterPC() - 0x1000) & ~0xFFF, 0x3000, Remove_ValidateFunc); + info = NULL; + continue; + } + } + (info->Function())(); + } + else { - CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2]; - if (info == NULL) - { - info = CompilerCode(); - if (info == NULL || m_EndEmulation) - { - break; - } - if (g_System->bSMM_Protect()) - { - g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF,PROGRAM_COUNTER | 0xFFF); - } - JumpTable()[PhysicalAddr >> 2] = info; - } else { - if (*(info->MemLocation(0)) != info->MemContents(0) || - *(info->MemLocation(1)) != info->MemContents(1)) - { - ClearRecompCode_Virt((info->EnterPC() - 0x1000) & ~0xFFF,0x3000,Remove_ValidateFunc); - info = NULL; - continue; - } - } - (info->Function())(); - } else { - DWORD opsExecuted = 0; + uint32_t opsExecuted = 0; - while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr) && PhysicalAddr >= g_System->RdramSize()) - { - CInterpreterCPU::ExecuteOps(g_System->CountPerOp()); - opsExecuted += g_System->CountPerOp(); - } + while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= g_System->RdramSize()) + { + CInterpreterCPU::ExecuteOps(g_System->CountPerOp()); + opsExecuted += g_System->CountPerOp(); + } - if (g_SyncSystem) - { - g_System->UpdateSyncCPU(g_SyncSystem,opsExecuted); - g_System->SyncCPU(g_SyncSystem); - } - } - } + if (g_SyncSystem) + { + g_System->UpdateSyncCPU(g_SyncSystem, opsExecuted); + g_System->SyncCPU(g_SyncSystem); + } + } + } } void CRecompiler::RecompilerMain_Lookup_validate_TLB() { - DWORD PhysicalAddr; + uint32_t PhysicalAddr; - while(!m_EndEmulation) - { - if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr)) - { - m_Registers.DoTLBReadMiss(false,PROGRAM_COUNTER); - if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr)) - { - g_Notify->DisplayError(stdstr_f("Failed to translate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER).ToUTF16().c_str()); - m_EndEmulation = true; - } - continue; - } - if (PhysicalAddr < g_System->RdramSize()) - { - CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2]; + while (!m_EndEmulation) + { + if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr)) + { + m_Registers.DoTLBReadMiss(false, PROGRAM_COUNTER); + if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr)) + { + g_Notify->DisplayError(stdstr_f("Failed to translate PC to a PAddr: %X\n\nEmulation stopped", PROGRAM_COUNTER).ToUTF16().c_str()); + m_EndEmulation = true; + } + continue; + } + if (PhysicalAddr < g_System->RdramSize()) + { + CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2]; - if (info == NULL) + if (info == NULL) + { + info = CompilerCode(); + if (info == NULL || m_EndEmulation) + { + break; + } + if (g_System->bSMM_Protect()) + { + g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF, PROGRAM_COUNTER | 0xFFF); + } + JumpTable()[PhysicalAddr >> 2] = info; + } + else { - info = CompilerCode(); - if (info == NULL || m_EndEmulation) - { - break; - } - if (g_System->bSMM_Protect()) - { - g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF,PROGRAM_COUNTER | 0xFFF); - } - JumpTable()[PhysicalAddr >> 2] = info; - } else { - if (*(info->MemLocation(0)) != info->MemContents(0) || - *(info->MemLocation(1)) != info->MemContents(1)) - { - if (PhysicalAddr > 0x1000) + if (*(info->MemLocation(0)) != info->MemContents(0) || + *(info->MemLocation(1)) != info->MemContents(1)) + { + if (PhysicalAddr > 0x1000) + { + ClearRecompCode_Phys((PhysicalAddr - 0x1000) & ~0xFFF, 0x3000, Remove_ValidateFunc); + } + else { - ClearRecompCode_Phys((PhysicalAddr - 0x1000) & ~0xFFF,0x3000,Remove_ValidateFunc); - } else { - ClearRecompCode_Phys(0,0x2000,Remove_ValidateFunc); - } - info = JumpTable()[PhysicalAddr >> 2]; - if (info != NULL) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - info = NULL; - } - continue; - } - } - (info->Function())(); - } else { - DWORD opsExecuted = 0; + ClearRecompCode_Phys(0, 0x2000, Remove_ValidateFunc); + } + info = JumpTable()[PhysicalAddr >> 2]; + if (info != NULL) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + info = NULL; + } + continue; + } + } + (info->Function())(); + } + else + { + uint32_t opsExecuted = 0; - while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr) && PhysicalAddr >= g_System->RdramSize()) - { - CInterpreterCPU::ExecuteOps(g_System->CountPerOp()); - opsExecuted += g_System->CountPerOp(); - } + while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= g_System->RdramSize()) + { + CInterpreterCPU::ExecuteOps(g_System->CountPerOp()); + opsExecuted += g_System->CountPerOp(); + } - if (g_SyncSystem) - { - g_System->UpdateSyncCPU(g_SyncSystem,opsExecuted); - g_System->SyncCPU(g_SyncSystem); - } - } - } + if (g_SyncSystem) + { + g_System->UpdateSyncCPU(g_SyncSystem, opsExecuted); + g_System->SyncCPU(g_SyncSystem); + } + } + } } void CRecompiler::Reset() { - ResetRecompCode(true); - ResetMemoryStackPos(); + ResetRecompCode(true); + ResetMemoryStackPos(); } -void CRecompiler::ResetRecompCode( bool bAllocate ) +void CRecompiler::ResetRecompCode(bool bAllocate) { - CRecompMemory::Reset(); - CFunctionMap::Reset(bAllocate); + CRecompMemory::Reset(); + CFunctionMap::Reset(bAllocate); - for (CCompiledFuncList::iterator iter = m_Functions.begin(); iter != m_Functions.end(); iter++) - { - CCompiledFunc * Func = iter->second; - while (Func != NULL) - { - CCompiledFunc * CurrentFunc = Func; - Func = Func->Next(); + for (CCompiledFuncList::iterator iter = m_Functions.begin(); iter != m_Functions.end(); iter++) + { + CCompiledFunc * Func = iter->second; + while (Func != NULL) + { + CCompiledFunc * CurrentFunc = Func; + Func = Func->Next(); - delete CurrentFunc; - } - } - m_Functions.clear(); + delete CurrentFunc; + } + } + m_Functions.clear(); } void CRecompiler::RecompilerMain_ChangeMemory() { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); #ifdef tofix - DWORD Value, Addr; - BYTE * Block; + uint32_t Value, Addr; + uint8_t * Block; - while(!EndEmulation()) { - if (UseTlb) { - if (!TranslateVaddr(PROGRAM_COUNTER, &Addr)) { - DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER); - NextInstruction = NORMAL; - if (!TranslateVaddr(PROGRAM_COUNTER, &Addr)) { - g_Notify->DisplayError(L"Failed to translate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER); - ExitThread(0); - } - } - } else { - Addr = PROGRAM_COUNTER & 0x1FFFFFFF; - } - - if (NextInstruction == DELAY_SLOT) { - __try { - Value = (DWORD)(*(DelaySlotTable + (Addr >> 12))); - } __except(EXCEPTION_EXECUTE_HANDLER) { - g_Notify->DisplayError(L"Executing Delay Slot from non maped space\nPROGRAM_COUNTER = 0x%X",PROGRAM_COUNTER); - ExitThread(0); - } - if ( (Value >> 16) == 0x7C7C) { - DWORD Index = (Value & 0xFFFF); - Block = (BYTE *)OrigMem[Index].CompiledLocation; - if (OrigMem[Index].PAddr != Addr) { Block = NULL; } - if (OrigMem[Index].VAddr != PROGRAM_COUNTER) { Block = NULL; } - if (Index >= TargetIndex) { Block = NULL; } - } else { - Block = NULL; - } - if (Block == NULL) { - DWORD MemValue; - - Block = CompileDelaySlot(); - Value = 0x7C7C0000; - Value += (WORD)(TargetIndex); - MemValue = *(DWORD *)(RDRAM + Addr); - if ( (MemValue >> 16) == 0x7C7C) { - MemValue = OrigMem[(MemValue & 0xFFFF)].OriginalValue; - } - OrigMem[(WORD)(TargetIndex)].OriginalValue = MemValue; - OrigMem[(WORD)(TargetIndex)].CompiledLocation = Block; - OrigMem[(WORD)(TargetIndex)].PAddr = Addr; - OrigMem[(WORD)(TargetIndex)].VAddr = PROGRAM_COUNTER; - TargetIndex += 1; - *(DelaySlotTable + (Addr >> 12)) = (void *)Value; - NextInstruction = NORMAL; - } - _asm { - pushad - call Block - popad - } - continue; - } - - __try { - Value = *(DWORD *)(RDRAM + Addr); - if ( (Value >> 16) == 0x7C7C) { - DWORD Index = (Value & 0xFFFF); - Block = (BYTE *)OrigMem[Index].CompiledLocation; - if (OrigMem[Index].PAddr != Addr) { Block = NULL; } - if (OrigMem[Index].VAddr != PROGRAM_COUNTER) { Block = NULL; } - if (Index >= TargetIndex) { Block = NULL; } - } else { - Block = NULL; - } - } __except(EXCEPTION_EXECUTE_HANDLER) { - g_Notify->DisplayError(GS(MSG_NONMAPPED_SPACE)); - ExitThread(0); - } - - if (Block == NULL) { - DWORD MemValue; - - __try { - Block = Compiler4300iBlock(); - } __except(EXCEPTION_EXECUTE_HANDLER) { - ResetRecompCode(); - Block = Compiler4300iBlock(); - } - if (EndEmulation()) + while(!EndEmulation()) + { + if (UseTlb) + { + if (!TranslateVaddr(PROGRAM_COUNTER, &Addr)) { - continue; - } - if (TargetIndex == MaxOrigMem) { - ResetRecompCode(); - continue; - } - Value = 0x7C7C0000; - Value += (WORD)(TargetIndex); - MemValue = *(DWORD *)(RDRAM + Addr); - if ( (MemValue >> 16) == 0x7C7C) { - MemValue = OrigMem[(MemValue & 0xFFFF)].OriginalValue; - } - OrigMem[(WORD)(TargetIndex)].OriginalValue = MemValue; - OrigMem[(WORD)(TargetIndex)].CompiledLocation = Block; - OrigMem[(WORD)(TargetIndex)].PAddr = Addr; - OrigMem[(WORD)(TargetIndex)].VAddr = PROGRAM_COUNTER; - TargetIndex += 1; - *(DWORD *)(RDRAM + Addr) = Value; - NextInstruction = NORMAL; - } - if (Profiling && IndvidualBlock) { - static DWORD ProfAddress = 0; + DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER); + NextInstruction = NORMAL; + if (!TranslateVaddr(PROGRAM_COUNTER, &Addr)) + { + g_Notify->DisplayError(L"Failed to translate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER); + ExitThread(0); + } + } + } else { + Addr = PROGRAM_COUNTER & 0x1FFFFFFF; + } - /*if ((PROGRAM_COUNTER & ~0xFFF) != ProfAddress) { - char Label[100]; + if (NextInstruction == DELAY_SLOT) + { + __try + { + Value = (uint32_t)(*(DelaySlotTable + (Addr >> 12))); + } + __except(EXCEPTION_EXECUTE_HANDLER) + { + g_Notify->DisplayError(L"Executing Delay Slot from non maped space\nPROGRAM_COUNTER = 0x%X",PROGRAM_COUNTER); + ExitThread(0); + } + if ( (Value >> 16) == 0x7C7C) + { + uint32_t Index = (Value & 0xFFFF); + Block = (uint8_t *)OrigMem[Index].CompiledLocation; + if (OrigMem[Index].PAddr != Addr) { Block = NULL; } + if (OrigMem[Index].VAddr != PROGRAM_COUNTER) { Block = NULL; } + if (Index >= TargetIndex) { Block = NULL; } + } + else + { + Block = NULL; + } + if (Block == NULL) + { + uint32_t MemValue; - ProfAddress = PROGRAM_COUNTER & ~0xFFF; - sprintf(Label,"PC: %X to %X",ProfAddress,ProfAddress+ 0xFFC); - StartTimer(Label); - }*/ - /*if (PROGRAM_COUNTER >= 0x800DD000 && PROGRAM_COUNTER <= 0x800DDFFC) { - char Label[100]; - sprintf(Label,"PC: %X Block: %X",PROGRAM_COUNTER,Block); - StartTimer(Label); - }*/ -// } else if ((Profiling || ShowCPUPer) && ProfilingLabel[0] == 0) { -// StartTimer("r4300i Running"); - } - _asm { - pushad - call Block - popad - } - } // end for(;;) + Block = CompileDelaySlot(); + Value = 0x7C7C0000; + Value += (uint16_t)(TargetIndex); + MemValue = *(uint32_t *)(RDRAM + Addr); + if ( (MemValue >> 16) == 0x7C7C) + { + MemValue = OrigMem[(MemValue & 0xFFFF)].OriginalValue; + } + OrigMem[(uint16_t)(TargetIndex)].OriginalValue = MemValue; + OrigMem[(uint16_t)(TargetIndex)].CompiledLocation = Block; + OrigMem[(uint16_t)(TargetIndex)].PAddr = Addr; + OrigMem[(uint16_t)(TargetIndex)].VAddr = PROGRAM_COUNTER; + TargetIndex += 1; + *(DelaySlotTable + (Addr >> 12)) = (void *)Value; + NextInstruction = NORMAL; + } + _asm + { + pushad + call Block + popad + } + continue; + } + + __try + { + Value = *(uint32_t *)(RDRAM + Addr); + if ( (Value >> 16) == 0x7C7C) + { + uint32_t Index = (Value & 0xFFFF); + Block = (uint8_t *)OrigMem[Index].CompiledLocation; + if (OrigMem[Index].PAddr != Addr) { Block = NULL; } + if (OrigMem[Index].VAddr != PROGRAM_COUNTER) { Block = NULL; } + if (Index >= TargetIndex) { Block = NULL; } + } + else + { + Block = NULL; + } + } + __except(EXCEPTION_EXECUTE_HANDLER) + { + g_Notify->DisplayError(GS(MSG_NONMAPPED_SPACE)); + ExitThread(0); + } + + if (Block == NULL) + { + uint32_t MemValue; + + __try + { + Block = Compiler4300iBlock(); + } + __except(EXCEPTION_EXECUTE_HANDLER) + { + ResetRecompCode(); + Block = Compiler4300iBlock(); + } + if (EndEmulation()) + { + continue; + } + if (TargetIndex == MaxOrigMem) + { + ResetRecompCode(); + continue; + } + Value = 0x7C7C0000; + Value += (uint16_t)(TargetIndex); + MemValue = *(uint32_t *)(RDRAM + Addr); + if ( (MemValue >> 16) == 0x7C7C) + { + MemValue = OrigMem[(MemValue & 0xFFFF)].OriginalValue; + } + OrigMem[(uint16_t)(TargetIndex)].OriginalValue = MemValue; + OrigMem[(uint16_t)(TargetIndex)].CompiledLocation = Block; + OrigMem[(uint16_t)(TargetIndex)].PAddr = Addr; + OrigMem[(uint16_t)(TargetIndex)].VAddr = PROGRAM_COUNTER; + TargetIndex += 1; + *(uint32_t *)(RDRAM + Addr) = Value; + NextInstruction = NORMAL; + } + if (Profiling && IndvidualBlock) + { + static uint32_t ProfAddress = 0; + + /*if ((PROGRAM_COUNTER & ~0xFFF) != ProfAddress) + { + char Label[100]; + + ProfAddress = PROGRAM_COUNTER & ~0xFFF; + sprintf(Label,"PC: %X to %X",ProfAddress,ProfAddress+ 0xFFC); + StartTimer(Label); + }*/ + /*if (PROGRAM_COUNTER >= 0x800DD000 && PROGRAM_COUNTER <= 0x800DDFFC) + { + char Label[100]; + sprintf(Label,"PC: %X Block: %X",PROGRAM_COUNTER,Block); + StartTimer(Label); + }*/ + // } else if ((Profiling || ShowCPUPer) && ProfilingLabel[0] == 0) { + // StartTimer("r4300i Running"); + } + _asm + { + pushad + call Block + popad + } + } // end for(;;) #endif } CCompiledFunc * CRecompiler::CompilerCode() { - DWORD pAddr = 0; - if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER,(uint32_t &)pAddr)) - { - WriteTraceF(TraceError,__FUNCTION__ ": Failed to translate %X",PROGRAM_COUNTER); - return NULL; - } - - CCompiledFuncList::iterator iter = m_Functions.find(PROGRAM_COUNTER); - if (iter != m_Functions.end()) - { - for (CCompiledFunc * Func = iter->second; Func != NULL; Func = Func->Next()) - { - DWORD PAddr; - if (g_TransVaddr->TranslateVaddr(Func->MinPC(),(uint32_t &)PAddr)) - { - MD5Digest Hash; - MD5(g_MMU->Rdram() + PAddr,(Func->MaxPC() - Func->MinPC())+ 4).get_digest(Hash); - if (memcmp(Hash.digest,Func->Hash().digest,sizeof(Hash.digest)) == 0) - { - return Func; - } - } - } - } - - CheckRecompMem(); + uint32_t pAddr = 0; + if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, pAddr)) + { + WriteTraceF(TraceError, __FUNCTION__ ": Failed to translate %X", PROGRAM_COUNTER); + return NULL; + } - //DWORD StartTime = timeGetTime(); - WriteTraceF(TraceRecompiler,__FUNCTION__ ": Compile Block-Start: Program Counter: %X pAddr: %X",PROGRAM_COUNTER,pAddr); + CCompiledFuncList::iterator iter = m_Functions.find(PROGRAM_COUNTER); + if (iter != m_Functions.end()) + { + for (CCompiledFunc * Func = iter->second; Func != NULL; Func = Func->Next()) + { + uint32_t PAddr; + if (g_TransVaddr->TranslateVaddr(Func->MinPC(), PAddr)) + { + MD5Digest Hash; + MD5(g_MMU->Rdram() + PAddr, (Func->MaxPC() - Func->MinPC()) + 4).get_digest(Hash); + if (memcmp(Hash.digest, Func->Hash().digest, sizeof(Hash.digest)) == 0) + { + return Func; + } + } + } + } - CCodeBlock CodeBlock(PROGRAM_COUNTER, RecompPos()); - if (!CodeBlock.Compile()) - { - return NULL; - } + CheckRecompMem(); - if (bShowRecompMemSize()) - { - ShowMemUsed(); - } - - CCompiledFunc * Func = new CCompiledFunc(CodeBlock); - CCompiledFuncList::_Pairib ret = m_Functions.insert(CCompiledFuncList::value_type(Func->EnterPC(),Func)); - if (ret.second == false) - { - Func->SetNext(ret.first->second->Next()); - ret.first->second->SetNext(Func); - return Func; - } - return Func; + //uint32_t StartTime = timeGetTime(); + WriteTraceF(TraceRecompiler, __FUNCTION__ ": Compile Block-Start: Program Counter: %X pAddr: %X", PROGRAM_COUNTER, pAddr); + + CCodeBlock CodeBlock(PROGRAM_COUNTER, RecompPos()); + if (!CodeBlock.Compile()) + { + return NULL; + } + + if (bShowRecompMemSize()) + { + ShowMemUsed(); + } + + CCompiledFunc * Func = new CCompiledFunc(CodeBlock); + CCompiledFuncList::_Pairib ret = m_Functions.insert(CCompiledFuncList::value_type(Func->EnterPC(), Func)); + if (ret.second == false) + { + Func->SetNext(ret.first->second->Next()); + ret.first->second->SetNext(Func); + return Func; + } + return Func; } - -void CRecompiler::ClearRecompCode_Phys(DWORD Address, int length, REMOVE_REASON Reason ) +void CRecompiler::ClearRecompCode_Phys(uint32_t Address, int length, REMOVE_REASON Reason) { - if (g_System->LookUpMode() == FuncFind_VirtualLookup) - { - ClearRecompCode_Virt(Address + 0x80000000,length,Reason); - ClearRecompCode_Virt(Address + 0xA0000000,length,Reason); + if (g_System->LookUpMode() == FuncFind_VirtualLookup) + { + ClearRecompCode_Virt(Address + 0x80000000, length, Reason); + ClearRecompCode_Virt(Address + 0xA0000000, length, Reason); - if (g_System->bUseTlb()) + if (g_System->bUseTlb()) + { + uint32_t VAddr, Index = 0; + while (g_TLB->PAddrToVAddr(Address, VAddr, Index)) + { + WriteTraceF(TraceRecompiler, __FUNCTION__ ": ClearRecompCode Vaddr %X len: %d", VAddr, length); + ClearRecompCode_Virt(VAddr, length, Reason); + } + } + } + else if (g_System->LookUpMode() == FuncFind_PhysicalLookup) + { + if (Address < g_System->RdramSize()) + { + int ClearLen = ((length + 3) & ~3); + if (Address + ClearLen > g_System->RdramSize()) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + ClearLen = g_System->RdramSize() - Address; + } + WriteTraceF(TraceRecompiler, __FUNCTION__ ": Reseting Jump Table, Addr: %X len: %d", Address, ClearLen); + memset((uint8_t *)JumpTable() + Address, 0, ClearLen); + if (g_System->bSMM_Protect()) + { + g_MMU->UnProtectMemory(Address + 0x80000000, Address + 0x80000004); + } + } + else { - uint32_t VAddr, Index = 0; - while (g_TLB->PAddrToVAddr(Address,VAddr,Index)) - { - WriteTraceF(TraceRecompiler,__FUNCTION__ ": ClearRecompCode Vaddr %X len: %d",VAddr,length); - ClearRecompCode_Virt(VAddr,length,Reason); - } - } - } - else if (g_System->LookUpMode() == FuncFind_PhysicalLookup) - { - if (Address < g_System->RdramSize()) - { - int ClearLen = ((length + 3) & ~3); - if (Address + ClearLen > g_System->RdramSize()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - ClearLen = g_System->RdramSize() - Address; - } - WriteTraceF(TraceRecompiler,__FUNCTION__ ": Reseting Jump Table, Addr: %X len: %d",Address,ClearLen); - memset((BYTE *)JumpTable() + Address,0,ClearLen); - if (g_System->bSMM_Protect()) - { - g_MMU->UnProtectMemory(Address + 0x80000000,Address + 0x80000004); - } - } else{ - WriteTraceF(TraceRecompiler,__FUNCTION__ ": Ignoring reset of Jump Table, Addr: %X len: %d",Address,((length + 3) & ~3)); - } - } + WriteTraceF(TraceRecompiler, __FUNCTION__ ": Ignoring reset of Jump Table, Addr: %X len: %d", Address, ((length + 3) & ~3)); + } + } } -void CRecompiler::ClearRecompCode_Virt(DWORD Address, int length,REMOVE_REASON Reason ) +void CRecompiler::ClearRecompCode_Virt(uint32_t Address, int length, REMOVE_REASON Reason) { - switch (g_System->LookUpMode()) - { - case FuncFind_VirtualLookup: - { - DWORD AddressIndex = Address >> 0xC; - DWORD WriteStart = (Address & 0xFFC); - length = ((length + 3) & ~0x3); + switch (g_System->LookUpMode()) + { + case FuncFind_VirtualLookup: + { + uint32_t AddressIndex = Address >> 0xC; + uint32_t WriteStart = (Address & 0xFFC); + length = ((length + 3) & ~0x3); - int DataInBlock = 0x1000 - WriteStart; - int DataToWrite = length < DataInBlock ? length : DataInBlock; - int DataLeft = length - DataToWrite; + int DataInBlock = 0x1000 - WriteStart; + int DataToWrite = length < DataInBlock ? length : DataInBlock; + int DataLeft = length - DataToWrite; - PCCompiledFunc_TABLE & table = FunctionTable()[AddressIndex]; - if (table) - { - WriteTraceF(TraceError,__FUNCTION__ ": Delete Table (%X): Index = %d",table, AddressIndex); - delete table; - table = NULL; - g_MMU->UnProtectMemory(Address,Address + length); - } - - if (DataLeft > 0) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - } - break; - case FuncFind_PhysicalLookup: - { - DWORD pAddr = 0; - if (g_TransVaddr->TranslateVaddr(Address,(uint32_t &)pAddr)) - { - ClearRecompCode_Phys(pAddr,length,Reason); - } - } - break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + PCCompiledFunc_TABLE & table = FunctionTable()[AddressIndex]; + if (table) + { + WriteTraceF(TraceError, __FUNCTION__ ": Delete Table (%X): Index = %d", table, AddressIndex); + delete table; + table = NULL; + g_MMU->UnProtectMemory(Address, Address + length); + } + + if (DataLeft > 0) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + } + break; + case FuncFind_PhysicalLookup: + { + uint32_t pAddr = 0; + if (g_TransVaddr->TranslateVaddr(Address, pAddr)) + { + ClearRecompCode_Phys(pAddr, length, Reason); + } + } + break; + default: + g_Notify->BreakPoint(__FILEW__, __LINE__); + } } void CRecompiler::ResetMemoryStackPos() { - if (g_MMU == NULL) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - return; - } - if (m_Registers.m_GPR[29].UW[0] == 0) - { - m_MemoryStack = NULL; - return; - } + if (g_MMU == NULL) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + return; + } + if (m_Registers.m_GPR[29].UW[0] == 0) + { + m_MemoryStack = NULL; + return; + } - DWORD pAddr = 0; - if (g_TransVaddr->TranslateVaddr(m_Registers.m_GPR[29].UW[0],(uint32_t &)pAddr)) + uint32_t pAddr = 0; + if (g_TransVaddr->TranslateVaddr(m_Registers.m_GPR[29].UW[0], pAddr)) + { + m_MemoryStack = (uint32_t)(g_MMU->Rdram() + pAddr); + } + else { - m_MemoryStack = (DWORD)(g_MMU->Rdram() + pAddr); - } else { - WriteTraceF(TraceError,__FUNCTION__ ": Failed to translate SP address (%s)",m_Registers.m_GPR[29].UW[0]); - g_Notify->BreakPoint(__FILEW__,__LINE__); - } + WriteTraceF(TraceError, __FUNCTION__ ": Failed to translate SP address (%s)", m_Registers.m_GPR[29].UW[0]); + g_Notify->BreakPoint(__FILEW__, __LINE__); + } } diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Class.h b/Source/Project64/N64 System/Recompiler/Recompiler Class.h index 5081a7a92..4e7e59eda 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Class.h +++ b/Source/Project64/N64 System/Recompiler/Recompiler Class.h @@ -11,64 +11,65 @@ #pragma once class CRecompiler : - protected CDebugSettings, - public CRecompilerSettings, - public CFunctionMap, - private CRecompMemory, - private CSystemRegisters + protected CDebugSettings, + public CRecompilerSettings, + public CFunctionMap, + private CRecompMemory, + private CSystemRegisters { public: - enum REMOVE_REASON { - Remove_InitialCode, - Remove_Cache, - Remove_ProtectedMem, - Remove_ValidateFunc, - Remove_TLB, - Remove_DMA, - Remove_StoreInstruc, - }; + enum REMOVE_REASON + { + Remove_InitialCode, + Remove_Cache, + Remove_ProtectedMem, + Remove_ValidateFunc, + Remove_TLB, + Remove_DMA, + Remove_StoreInstruc, + }; - typedef void (*DelayFunc)(); + typedef void (*DelayFunc)(); public: - CRecompiler(CRegisters & Registers, CProfiling & Profile, bool & EndEmulation); - ~CRecompiler(); + CRecompiler(CRegisters & Registers, CProfiling & Profile, bool & EndEmulation); + ~CRecompiler(); - void Run(); - void Reset(); - void ResetRecompCode(bool bAllocate); + void Run(); + void Reset(); + void ResetRecompCode(bool bAllocate); - //Self modifying code methods - void ClearRecompCode_Virt ( DWORD VirtualAddress, int length, REMOVE_REASON Reason ); - void ClearRecompCode_Phys ( DWORD PhysicalAddress, int length, REMOVE_REASON Reason ); - - void ResetMemoryStackPos(); + //Self modifying code methods + void ClearRecompCode_Virt ( uint32_t VirtualAddress, int32_t length, REMOVE_REASON Reason ); + void ClearRecompCode_Phys ( uint32_t PhysicalAddress, int32_t length, REMOVE_REASON Reason ); - DWORD& MemoryStackPos() { return m_MemoryStack; } + void ResetMemoryStackPos(); + + uint32_t& MemoryStackPos() { return m_MemoryStack; } private: - CRecompiler(); // Disable default constructor - CRecompiler(const CRecompiler&); // Disable copy constructor - CRecompiler& operator=(const CRecompiler&); // Disable assignment - - CCompiledFunc * CompilerCode(); + CRecompiler(); // Disable default constructor + CRecompiler(const CRecompiler&); // Disable copy constructor + CRecompiler& operator=(const CRecompiler&); // Disable assignment - // Main loops for the different look up methods - void RecompilerMain_VirtualTable(); - void RecompilerMain_VirtualTable_validate(); - void RecompilerMain_ChangeMemory(); - void RecompilerMain_Lookup(); - void RecompilerMain_Lookup_TLB(); - void RecompilerMain_Lookup_validate(); - void RecompilerMain_Lookup_validate_TLB(); + CCompiledFunc * CompilerCode(); - CCompiledFuncList m_Functions; - CRegisters & m_Registers; - CProfiling & m_Profile; - bool & m_EndEmulation; - DWORD m_MemoryStack; + // Main loops for the different look up methods + void RecompilerMain_VirtualTable(); + void RecompilerMain_VirtualTable_validate(); + void RecompilerMain_ChangeMemory(); + void RecompilerMain_Lookup(); + void RecompilerMain_Lookup_TLB(); + void RecompilerMain_Lookup_validate(); + void RecompilerMain_Lookup_validate_TLB(); - //Quick access to registers + CCompiledFuncList m_Functions; + CRegisters & m_Registers; + CProfiling & m_Profile; + bool & m_EndEmulation; + uint32_t m_MemoryStack; + + //Quick access to registers uint32_t & PROGRAM_COUNTER; }; From dda79ce3456d01e2acefc2b4b1006f5306adc3a2 Mon Sep 17 00:00:00 2001 From: zilmar Date: Tue, 10 Nov 2015 07:22:51 +1100 Subject: [PATCH 111/213] [Project64] get Recompiler Memory.cpp to use standard types --- .../Recompiler/Recompiler Memory.cpp | 41 +++++++++---------- .../N64 System/Recompiler/Recompiler Memory.h | 13 +++--- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Memory.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Memory.cpp index b119c6449..be4b9040a 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Memory.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Memory.cpp @@ -11,8 +11,8 @@ #include "stdafx.h" CRecompMemory::CRecompMemory() : - m_RecompCode(NULL), - m_RecompSize(0) +m_RecompCode(NULL), +m_RecompSize(0) { m_RecompPos = NULL; } @@ -21,7 +21,7 @@ CRecompMemory::~CRecompMemory() { if (m_RecompCode) { - VirtualFree( m_RecompCode, 0 , MEM_RELEASE); + VirtualFree(m_RecompCode, 0, MEM_RELEASE); m_RecompCode = NULL; } m_RecompPos = NULL; @@ -29,25 +29,25 @@ CRecompMemory::~CRecompMemory() bool CRecompMemory::AllocateMemory() { - BYTE * RecompCodeBase = (BYTE *)VirtualAlloc( NULL, MaxCompileBufferSize + 4, MEM_RESERVE|MEM_TOP_DOWN, PAGE_EXECUTE_READWRITE); + BYTE * RecompCodeBase = (BYTE *)VirtualAlloc(NULL, MaxCompileBufferSize + 4, MEM_RESERVE | MEM_TOP_DOWN, PAGE_EXECUTE_READWRITE); if (RecompCodeBase == NULL) { - WriteTrace(TraceError,__FUNCTION__ ": failed to allocate RecompCodeBase"); + WriteTrace(TraceError, __FUNCTION__ ": failed to allocate RecompCodeBase"); g_Notify->DisplayError(MSG_MEM_ALLOC_ERROR); return false; } - m_RecompCode = (BYTE *)VirtualAlloc( RecompCodeBase, InitialCompileBufferSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE); + m_RecompCode = (BYTE *)VirtualAlloc(RecompCodeBase, InitialCompileBufferSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE); if (m_RecompCode == NULL) { - WriteTrace(TraceError,__FUNCTION__ ": failed to commit initial buffer"); - VirtualFree( RecompCodeBase, 0 , MEM_RELEASE); + WriteTrace(TraceError, __FUNCTION__ ": failed to commit initial buffer"); + VirtualFree(RecompCodeBase, 0, MEM_RELEASE); g_Notify->DisplayError(MSG_MEM_ALLOC_ERROR); return false; } m_RecompSize = InitialCompileBufferSize; m_RecompPos = m_RecompCode; - memset(m_RecompCode,0,InitialCompileBufferSize); + memset(m_RecompCode, 0, InitialCompileBufferSize); return true; } @@ -58,19 +58,18 @@ void CRecompMemory::CheckRecompMem() { return; } - if (m_RecompSize == MaxCompileBufferSize) - { - g_Recompiler->ResetRecompCode(true); - return; - } - LPVOID MemAddr = VirtualAlloc( m_RecompCode + m_RecompSize , IncreaseCompileBufferSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE); - if (MemAddr == NULL) + if (m_RecompSize == MaxCompileBufferSize) { - WriteTrace(TraceError,__FUNCTION__ ": failed to increase buffer"); + g_Recompiler->ResetRecompCode(true); + return; + } + LPVOID MemAddr = VirtualAlloc(m_RecompCode + m_RecompSize, IncreaseCompileBufferSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE); + if (MemAddr == NULL) + { + WriteTrace(TraceError, __FUNCTION__ ": failed to increase buffer"); g_Notify->FatalError(MSG_MEM_ALLOC_ERROR); } m_RecompSize += IncreaseCompileBufferSize; - } void CRecompMemory::Reset() @@ -84,9 +83,9 @@ void CRecompMemory::ShowMemUsed() DWORD MB = Size / 0x100000; Size -= MB * 0x100000; DWORD KB = Size / 1024; - Size -= KB * 1024; + Size -= KB * 1024; DWORD TotalAvaliable = m_RecompSize / 0x100000; - - g_Notify->DisplayMessage(0,stdstr_f("Memory used: %d mb %-3d kb %-3d bytes Total Available: %d mb",MB,KB,Size, TotalAvaliable).ToUTF16().c_str()); + + g_Notify->DisplayMessage(0, stdstr_f("Memory used: %d mb %-3d kb %-3d bytes Total Available: %d mb", MB, KB, Size, TotalAvaliable).ToUTF16().c_str()); } diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Memory.h b/Source/Project64/N64 System/Recompiler/Recompiler Memory.h index 17a9024c8..092a248c1 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Memory.h +++ b/Source/Project64/N64 System/Recompiler/Recompiler Memory.h @@ -22,13 +22,16 @@ protected: void Reset(); void ShowMemUsed(); - BYTE* RecompPos() const { return m_RecompPos; } + uint8_t* RecompPos() const { return m_RecompPos; } private: - BYTE * m_RecompCode; - DWORD m_RecompSize; + CRecompMemory(const CRecompMemory&); // Disable copy constructor + CRecompMemory& operator=(const CRecompMemory&); // Disable assignment - enum { MaxCompileBufferSize = 0x03C00000 }; - enum { InitialCompileBufferSize = 0x00500000 }; + uint8_t * m_RecompCode; + uint32_t m_RecompSize; + + enum { MaxCompileBufferSize = 0x03C00000 }; + enum { InitialCompileBufferSize = 0x00500000 }; enum { IncreaseCompileBufferSize = 0x00100000 }; }; From eef290f76779e92a2d4aba8d743e8634b7dfeb65 Mon Sep 17 00:00:00 2001 From: zilmar Date: Tue, 10 Nov 2015 07:26:33 +1100 Subject: [PATCH 112/213] [Project64] Clean up Section Info.cpp, x86CodeLog.cpp, plugins --- .../N64 System/Recompiler/Section Info.cpp | 66 +++++++++---------- .../N64 System/Recompiler/Section Info.h | 4 +- .../N64 System/Recompiler/x86CodeLog.cpp | 63 +++++++++--------- Source/Project64/Plugins/Audio Plugin.cpp | 14 ++-- Source/Project64/Plugins/GFX plugin.cpp | 46 ++++++------- Source/Project64/Plugins/RSP Plugin.cpp | 36 +++++----- 6 files changed, 116 insertions(+), 113 deletions(-) diff --git a/Source/Project64/N64 System/Recompiler/Section Info.cpp b/Source/Project64/N64 System/Recompiler/Section Info.cpp index 00cec2444..3bc75b8a4 100644 --- a/Source/Project64/N64 System/Recompiler/Section Info.cpp +++ b/Source/Project64/N64 System/Recompiler/Section Info.cpp @@ -12,29 +12,29 @@ CJumpInfo::CJumpInfo() { - TargetPC = (DWORD)-1; - JumpPC = (DWORD)-1; - BranchLabel = ""; - LinkLocation = NULL; + TargetPC = (uint32_t)-1; + JumpPC = (uint32_t)-1; + BranchLabel = ""; + LinkLocation = NULL; LinkLocation2 = NULL; - FallThrough = false; - PermLoop = false; + FallThrough = false; + PermLoop = false; DoneDelaySlot = false; - ExitReason = CExitInfo::Normal; + ExitReason = CExitInfo::Normal; } #ifdef tofix -bool CCodeSection::IsAllParentLoops(CCodeSection * Parent, bool IgnoreIfCompiled, DWORD Test) -{ +bool CCodeSection::IsAllParentLoops(CCodeSection * Parent, bool IgnoreIfCompiled, uint32_t Test) +{ if (IgnoreIfCompiled && Parent->CompiledLocation != NULL) { return true; } if (!InLoop) { return false; } if (!Parent->InLoop) { return false; } if (Parent->ParentSection.empty()) { return false; } - if (this == Parent) { return true; } + if (this == Parent) { return true; } if (Parent->Test == Test) { return true; } Parent->Test = Test; - + for (SECTION_LIST::iterator iter = Parent->ParentSection.begin(); iter != Parent->ParentSection.end(); iter++) { CCodeSection * ParentSection = *iter; @@ -45,11 +45,11 @@ bool CCodeSection::IsAllParentLoops(CCodeSection * Parent, bool IgnoreIfCompiled void CCodeSection::UnlinkParent( CCodeSection * Parent, bool AllowDelete, bool ContinueSection ) { - if (this == NULL) + if (this == NULL) { return; } - + SECTION_LIST::iterator iter = ParentSection.begin(); while ( iter != ParentSection.end()) { @@ -63,24 +63,24 @@ void CCodeSection::UnlinkParent( CCodeSection * Parent, bool AllowDelete, bool C } } -// if (Parent->ContinueSection != Parent->JumpSection) -// { -// if (!ContinueSection && Parent->ContinueSection == this) -// { -// g_Notify->BreakPoint(__FILEW__,__LINE__); -// } -// } + // if (Parent->ContinueSection != Parent->JumpSection) + // { + // if (!ContinueSection && Parent->ContinueSection == this) + // { + // g_Notify->BreakPoint(__FILEW__,__LINE__); + // } + // } if (ContinueSection && Parent->ContinueSection == this) { Parent->ContinueSection = NULL; } -// if (Parent->ContinueSection != Parent->JumpSection) -// { -// if (ContinueSection && Parent->JumpSection == this) -// { -// g_Notify->BreakPoint(__FILEW__,__LINE__); -// } -// } + // if (Parent->ContinueSection != Parent->JumpSection) + // { + // if (ContinueSection && Parent->JumpSection == this) + // { + // g_Notify->BreakPoint(__FILEW__,__LINE__); + // } + // } if (!ContinueSection && Parent->JumpSection == this) { Parent->JumpSection = NULL; @@ -100,7 +100,7 @@ void CCodeSection::UnlinkParent( CCodeSection * Parent, bool AllowDelete, bool C { delete this; } - } + } } CCodeSection::~CCodeSection() @@ -111,7 +111,7 @@ CCodeSection::~CCodeSection() if (Parent->ContinueSection == this) { UnlinkParent(Parent, false, true); } if (Parent->JumpSection == this) { UnlinkParent(Parent, false, false); } } - + if (ContinueSection) { ContinueSection->UnlinkParent(this, true, true); @@ -132,9 +132,9 @@ CCodeSection::~CCodeSection() } } -DWORD CCodeSection::GetNewTestValue() +uint32_t CCodeSection::GetNewTestValue() { - static DWORD LastTest = 0; + static uint32_t LastTest = 0; if (LastTest == 0xFFFFFFFF) { LastTest = 0; } LastTest += 1; return LastTest; @@ -143,13 +143,12 @@ DWORD CCodeSection::GetNewTestValue() void CRegInfo::Initialize() { int count; - + MIPS_RegState[0] = STATE_CONST_32_SIGN; MIPS_RegVal[0].DW = 0; for (count = 1; count < 32; count ++ ) { MIPS_RegState[count] = STATE_UNKNOWN; MIPS_RegVal[count].DW = 0; - } for (count = 0; count < 10; count ++ ) { x86reg_MappedTo[count] = NotMapped; @@ -170,4 +169,3 @@ void CRegInfo::Initialize() } #endif - diff --git a/Source/Project64/N64 System/Recompiler/Section Info.h b/Source/Project64/N64 System/Recompiler/Section Info.h index e44a30a59..e67f665c0 100644 --- a/Source/Project64/N64 System/Recompiler/Section Info.h +++ b/Source/Project64/N64 System/Recompiler/Section Info.h @@ -12,8 +12,10 @@ class CCodeSection; class CCodeBlock; +struct CJumpInfo; -struct BLOCK_PARENT { +struct BLOCK_PARENT +{ CCodeSection * Parent; CJumpInfo * JumpInfo; }; diff --git a/Source/Project64/N64 System/Recompiler/x86CodeLog.cpp b/Source/Project64/N64 System/Recompiler/x86CodeLog.cpp index ec7f2cce7..c59730b78 100644 --- a/Source/Project64/N64 System/Recompiler/x86CodeLog.cpp +++ b/Source/Project64/N64 System/Recompiler/x86CodeLog.cpp @@ -13,40 +13,43 @@ static HANDLE hCPULogFile = NULL; bool bX86Logging = false; -void x86_Log_Message (const char * Message, ...) { - DWORD dwWritten; - char Msg[400]; - - va_list ap; - va_start( ap, Message ); - vsprintf( Msg, Message, ap ); - va_end( ap ); - - strcat(Msg,"\r\n"); +void x86_Log_Message (const char * Message, ...) +{ + DWORD dwWritten; + char Msg[400]; - WriteFile( hCPULogFile,Msg,strlen(Msg),&dwWritten,NULL ); + va_list ap; + va_start( ap, Message ); + vsprintf( Msg, Message, ap ); + va_end( ap ); + + strcat(Msg,"\r\n"); + + WriteFile( hCPULogFile,Msg,strlen(Msg),&dwWritten,NULL ); } -void Start_x86_Log (void) { +void Start_x86_Log (void) +{ + CPath LogFileName(CPath::MODULE_DIRECTORY); + LogFileName.AppendDirectory("Logs"); + LogFileName.SetNameExtension("CPUoutput.log"); - CPath LogFileName(CPath::MODULE_DIRECTORY); - LogFileName.AppendDirectory("Logs"); - LogFileName.SetNameExtension("CPUoutput.log"); - - if (hCPULogFile) { Stop_x86_Log(); } - hCPULogFile = CreateFile(LogFileName,GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,NULL, - CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); - if (hCPULogFile) - { - bX86Logging = true; - SetFilePointer(hCPULogFile,0,NULL,FILE_BEGIN); - } + if (hCPULogFile) { Stop_x86_Log(); } + hCPULogFile = CreateFile(LogFileName,GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,NULL, + CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); + if (hCPULogFile) + { + bX86Logging = true; + SetFilePointer(hCPULogFile,0,NULL,FILE_BEGIN); + } } -void Stop_x86_Log (void) { - if (hCPULogFile) { - CloseHandle(hCPULogFile); - hCPULogFile = NULL; - bX86Logging = false; - } +void Stop_x86_Log (void) +{ + if (hCPULogFile) + { + CloseHandle(hCPULogFile); + hCPULogFile = NULL; + bX86Logging = false; + } } diff --git a/Source/Project64/Plugins/Audio Plugin.cpp b/Source/Project64/Plugins/Audio Plugin.cpp index 5172a3fa4..bed736a61 100644 --- a/Source/Project64/Plugins/Audio Plugin.cpp +++ b/Source/Project64/Plugins/Audio Plugin.cpp @@ -119,13 +119,13 @@ bool CAudioPlugin::Initiate(CN64System * System, CMainGui * RenderWindow) Info.RDRAM = g_MMU->Rdram(); Info.DMEM = g_MMU->Dmem(); Info.IMEM = g_MMU->Imem(); - Info.MI__INTR_REG = (uint32_t *)&g_Reg->m_AudioIntrReg; - Info.AI__DRAM_ADDR_REG = (uint32_t *)&g_Reg->AI_DRAM_ADDR_REG; - Info.AI__LEN_REG = (uint32_t *)&g_Reg->AI_LEN_REG; - Info.AI__CONTROL_REG = (uint32_t *)&g_Reg->AI_CONTROL_REG; - Info.AI__STATUS_REG = (uint32_t *)&g_Reg->AI_STATUS_REG; - Info.AI__DACRATE_REG = (uint32_t *)&g_Reg->AI_DACRATE_REG; - Info.AI__BITRATE_REG = (uint32_t *)&g_Reg->AI_BITRATE_REG; + Info.MI__INTR_REG = &g_Reg->m_AudioIntrReg; + Info.AI__DRAM_ADDR_REG = &g_Reg->AI_DRAM_ADDR_REG; + Info.AI__LEN_REG = &g_Reg->AI_LEN_REG; + Info.AI__CONTROL_REG = &g_Reg->AI_CONTROL_REG; + Info.AI__STATUS_REG = &g_Reg->AI_STATUS_REG; + Info.AI__DACRATE_REG = &g_Reg->AI_DACRATE_REG; + Info.AI__BITRATE_REG = &g_Reg->AI_BITRATE_REG; } m_Initialized = InitiateAudio(Info) != 0; diff --git a/Source/Project64/Plugins/GFX plugin.cpp b/Source/Project64/Plugins/GFX plugin.cpp index 4dcd9f148..a25ba07bb 100644 --- a/Source/Project64/Plugins/GFX plugin.cpp +++ b/Source/Project64/Plugins/GFX plugin.cpp @@ -191,29 +191,29 @@ bool CGfxPlugin::Initiate(CN64System * System, CMainGui * RenderWindow) Info.RDRAM = g_MMU->Rdram(); Info.DMEM = g_MMU->Dmem(); Info.IMEM = g_MMU->Imem(); - Info.MI__INTR_REG = (uint32_t *)&g_Reg->m_GfxIntrReg; - Info.DPC__START_REG = (uint32_t *)&g_Reg->DPC_START_REG; - Info.DPC__END_REG = (uint32_t *)&g_Reg->DPC_END_REG; - Info.DPC__CURRENT_REG = (uint32_t *)&g_Reg->DPC_CURRENT_REG; - Info.DPC__STATUS_REG = (uint32_t *)&g_Reg->DPC_STATUS_REG; - Info.DPC__CLOCK_REG = (uint32_t *)&g_Reg->DPC_CLOCK_REG; - Info.DPC__BUFBUSY_REG = (uint32_t *)&g_Reg->DPC_BUFBUSY_REG; - Info.DPC__PIPEBUSY_REG = (uint32_t *)&g_Reg->DPC_PIPEBUSY_REG; - Info.DPC__TMEM_REG = (uint32_t *)&g_Reg->DPC_TMEM_REG; - Info.VI__STATUS_REG = (uint32_t *)&g_Reg->VI_STATUS_REG; - Info.VI__ORIGIN_REG = (uint32_t *)&g_Reg->VI_ORIGIN_REG; - Info.VI__WIDTH_REG = (uint32_t *)&g_Reg->VI_WIDTH_REG; - Info.VI__INTR_REG = (uint32_t *)&g_Reg->VI_INTR_REG; - Info.VI__V_CURRENT_LINE_REG = (uint32_t *)&g_Reg->VI_CURRENT_REG; - Info.VI__TIMING_REG = (uint32_t *)&g_Reg->VI_TIMING_REG; - Info.VI__V_SYNC_REG = (uint32_t *)&g_Reg->VI_V_SYNC_REG; - Info.VI__H_SYNC_REG = (uint32_t *)&g_Reg->VI_H_SYNC_REG; - Info.VI__LEAP_REG = (uint32_t *)&g_Reg->VI_LEAP_REG; - Info.VI__H_START_REG = (uint32_t *)&g_Reg->VI_H_START_REG; - Info.VI__V_START_REG = (uint32_t *)&g_Reg->VI_V_START_REG; - Info.VI__V_BURST_REG = (uint32_t *)&g_Reg->VI_V_BURST_REG; - Info.VI__X_SCALE_REG = (uint32_t *)&g_Reg->VI_X_SCALE_REG; - Info.VI__Y_SCALE_REG = (uint32_t *)&g_Reg->VI_Y_SCALE_REG; + Info.MI__INTR_REG = &g_Reg->m_GfxIntrReg; + Info.DPC__START_REG = &g_Reg->DPC_START_REG; + Info.DPC__END_REG = &g_Reg->DPC_END_REG; + Info.DPC__CURRENT_REG = &g_Reg->DPC_CURRENT_REG; + Info.DPC__STATUS_REG = &g_Reg->DPC_STATUS_REG; + Info.DPC__CLOCK_REG = &g_Reg->DPC_CLOCK_REG; + Info.DPC__BUFBUSY_REG = &g_Reg->DPC_BUFBUSY_REG; + Info.DPC__PIPEBUSY_REG = &g_Reg->DPC_PIPEBUSY_REG; + Info.DPC__TMEM_REG = &g_Reg->DPC_TMEM_REG; + Info.VI__STATUS_REG = &g_Reg->VI_STATUS_REG; + Info.VI__ORIGIN_REG = &g_Reg->VI_ORIGIN_REG; + Info.VI__WIDTH_REG = &g_Reg->VI_WIDTH_REG; + Info.VI__INTR_REG = &g_Reg->VI_INTR_REG; + Info.VI__V_CURRENT_LINE_REG = &g_Reg->VI_CURRENT_REG; + Info.VI__TIMING_REG = &g_Reg->VI_TIMING_REG; + Info.VI__V_SYNC_REG = &g_Reg->VI_V_SYNC_REG; + Info.VI__H_SYNC_REG = &g_Reg->VI_H_SYNC_REG; + Info.VI__LEAP_REG = &g_Reg->VI_LEAP_REG; + Info.VI__H_START_REG = &g_Reg->VI_H_START_REG; + Info.VI__V_START_REG = &g_Reg->VI_V_START_REG; + Info.VI__V_BURST_REG = &g_Reg->VI_V_BURST_REG; + Info.VI__X_SCALE_REG = &g_Reg->VI_X_SCALE_REG; + Info.VI__Y_SCALE_REG = &g_Reg->VI_Y_SCALE_REG; } m_Initialized = InitiateGFX(Info) != 0; diff --git a/Source/Project64/Plugins/RSP Plugin.cpp b/Source/Project64/Plugins/RSP Plugin.cpp index 7cac282e9..b33d3d03d 100644 --- a/Source/Project64/Plugins/RSP Plugin.cpp +++ b/Source/Project64/Plugins/RSP Plugin.cpp @@ -161,26 +161,26 @@ bool CRSP_Plugin::Initiate(CPlugins * Plugins, CN64System * System) Info.DMEM = g_MMU->Dmem(); Info.IMEM = g_MMU->Imem(); - Info.MI__INTR_REG = (uint32_t *)&g_Reg->m_RspIntrReg; + Info.MI__INTR_REG = &g_Reg->m_RspIntrReg; - Info.SP__MEM_ADDR_REG = (uint32_t *)&g_Reg->SP_MEM_ADDR_REG; - Info.SP__DRAM_ADDR_REG = (uint32_t *)&g_Reg->SP_DRAM_ADDR_REG; - Info.SP__RD_LEN_REG = (uint32_t *)&g_Reg->SP_RD_LEN_REG; - Info.SP__WR_LEN_REG = (uint32_t *)&g_Reg->SP_WR_LEN_REG; - Info.SP__STATUS_REG = (uint32_t *)&g_Reg->SP_STATUS_REG; - Info.SP__DMA_FULL_REG = (uint32_t *)&g_Reg->SP_DMA_FULL_REG; - Info.SP__DMA_BUSY_REG = (uint32_t *)&g_Reg->SP_DMA_BUSY_REG; - Info.SP__PC_REG = (uint32_t *)&g_Reg->SP_PC_REG; - Info.SP__SEMAPHORE_REG = (uint32_t *)&g_Reg->SP_SEMAPHORE_REG; + Info.SP__MEM_ADDR_REG = &g_Reg->SP_MEM_ADDR_REG; + Info.SP__DRAM_ADDR_REG = &g_Reg->SP_DRAM_ADDR_REG; + Info.SP__RD_LEN_REG = &g_Reg->SP_RD_LEN_REG; + Info.SP__WR_LEN_REG = &g_Reg->SP_WR_LEN_REG; + Info.SP__STATUS_REG = &g_Reg->SP_STATUS_REG; + Info.SP__DMA_FULL_REG = &g_Reg->SP_DMA_FULL_REG; + Info.SP__DMA_BUSY_REG = &g_Reg->SP_DMA_BUSY_REG; + Info.SP__PC_REG = &g_Reg->SP_PC_REG; + Info.SP__SEMAPHORE_REG = &g_Reg->SP_SEMAPHORE_REG; - Info.DPC__START_REG = (uint32_t *)&g_Reg->DPC_START_REG; - Info.DPC__END_REG = (uint32_t *)&g_Reg->DPC_END_REG; - Info.DPC__CURRENT_REG = (uint32_t *)&g_Reg->DPC_CURRENT_REG; - Info.DPC__STATUS_REG = (uint32_t *)&g_Reg->DPC_STATUS_REG; - Info.DPC__CLOCK_REG = (uint32_t *)&g_Reg->DPC_CLOCK_REG; - Info.DPC__BUFBUSY_REG = (uint32_t *)&g_Reg->DPC_BUFBUSY_REG; - Info.DPC__PIPEBUSY_REG = (uint32_t *)&g_Reg->DPC_PIPEBUSY_REG; - Info.DPC__TMEM_REG = (uint32_t *)&g_Reg->DPC_TMEM_REG; + Info.DPC__START_REG = &g_Reg->DPC_START_REG; + Info.DPC__END_REG = &g_Reg->DPC_END_REG; + Info.DPC__CURRENT_REG = &g_Reg->DPC_CURRENT_REG; + Info.DPC__STATUS_REG = &g_Reg->DPC_STATUS_REG; + Info.DPC__CLOCK_REG = &g_Reg->DPC_CLOCK_REG; + Info.DPC__BUFBUSY_REG = &g_Reg->DPC_BUFBUSY_REG; + Info.DPC__PIPEBUSY_REG = &g_Reg->DPC_PIPEBUSY_REG; + Info.DPC__TMEM_REG = &g_Reg->DPC_TMEM_REG; } InitiateRSP(Info, &m_CycleCount); From 7cae59ac0318194a5cf5842ad96a472e20b95dbf Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 Nov 2015 16:22:53 -0500 Subject: [PATCH 113/213] reverted: sizeof(array[0]) is less error-prone. --- Source/Project64/N64 System/Mips/TLB class.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Project64/N64 System/Mips/TLB class.cpp b/Source/Project64/N64 System/Mips/TLB class.cpp index 949f3fccc..4ae8b4d25 100644 --- a/Source/Project64/N64 System/Mips/TLB class.cpp +++ b/Source/Project64/N64 System/Mips/TLB class.cpp @@ -303,7 +303,7 @@ void CTLB::RecordDifference( CLog &LogFile, const CTLB& rTLB) bool CTLB::operator == (const CTLB& rTLB) const { - const size_t n = sizeof(m_tlb) / sizeof(TLB_ENTRY); + const size_t n = sizeof(m_tlb) / sizeof(m_tlb[0]); for (size_t i = 0; i < n; i++) { if (m_tlb[i].EntryDefined != rTLB.m_tlb[i].EntryDefined) From 6f74e382816ebdbaa4f26d08393f2f8050006fff Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 Nov 2015 19:09:40 -0500 Subject: [PATCH 114/213] Try making Project64.sln UTF-8, not UTF-16 LE. --- Project64.sln | Bin 33434 -> 16720 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/Project64.sln b/Project64.sln index 3c73f1127d8bdef38b89f9ec501fb7f6cf077a5d..513cfdcfdf212121e26535b55db23c21ba9f116b 100644 GIT binary patch literal 16720 zcmdU%PjA~e8ph8PAm72rUS@%zA^wp>9_FCG(=NJ2rddoc28uLMGafj0U^`8Avi)Rx z*pIYdVPDE-Xwr%EzG^OeXls$uPY)kHA}LGmfB*fT&vU+jMn%J{z5_ zZ!f2d(b-~lyPhuQqjoy$ej2rl<@Gu2(=AuFkn?ep93TB9I!Giu87-Eh+4;I#TK0T; zeS5tDZ@3Qd^N1(oWULaw&6pn_oh}!DbQkL%PaXtMlSWF(bX!+Ui9#}?a>aNdO`6pz zs~i38VIa7vnrc+ZhU1-hoGO0_EeLFcm zYUY>QQxDW|cmHvEdDX2~RztAyz-4Y)I2+3wSu@q9nwd%nyP2s*WsO$iRW$rEn_hPI z{Er_VOxt9}6e&}@l1wSZnGr?FGHFU#=Xu>6YQHWkQ#GY#x>N<@yiS;|!NMddlFD$X zwaWWGs211Pi@81d+2VG2(M>i5+keJiFYa%kYi<1luvBS`V$d5LdbR{jvJxz7c~!tE zl@dJkW4+rc1X0^A&D4&r$Fj-er$Alaq*7Io7+zEjQ;-v;b&@k_3eKBa)dh##9UuL$ zJ^T#f3YWr<+s(SW>E@T+{9@XztT8u>)p}b6$Nccn))~(moiNj=1bRgRKCKH@8kI?D za?xbPH#iQrBOrZpw@RK1Gr_kHXQw-k!PW%+1TGbMQ>U4zAV@9bs>~Z!W~F4JYICi0 zo{A>w!+~9R)~(mm`Bi^eZIk7SChkL^OhdFX4w=%rHcT}zZWJJgrAb~SNnM*()?vB^ zD$DXr_%7XF< z{0T&+{*HTTUK71qx-B6jDL$10EvM? zvNEicZP_$gp6g70$1qW-noE^v$Sw?&iW|V&j!}gvq)3xANz#6pK<(I%Jg7_7jy$Lx z|9=LveliTEfNjZS`)|;%C_kTFFc8Mri^Z~^tG9!iA3pBxCwKRsY;_>aNTqTvGu9Rr ztRixlJ#;Hm)>bNOVM;ZPKCp@)2>X1#IwZ_i2f~!dTV8`ESvDXHmVPju!}2D{^Fmcg zR_pwArh>csKW@6KCr6QuXPX@Yaj>vxn;I@t1Cs!(f3#vH&kUXK*PL25wh! zm77G@b(OcTW7z56GBtYt;rwd%BAqW``>RMMeZ{A@^PAiCr{6@N5Vi7rc4Q;mj=`LI z)4|=?+3(%~_}I;h83N_xbi}d;@}3Fta^hX=k&j_7rYjzrfw@_#oq{y$->ik@AS?>kk1wbhFNm zz%PM<{hj~@_50og)o{4K&R_2?O`%aq^uku;&R~TgyqREGgDRDT$@z}sINvcj8$$Hz zf;06wqw!+b9B){AEp1<$W1+qwM(2!9^UC6!QCP8KVa}+eSQE`F*ISsJ;gp3$uP!L> zb4KIEt~uVY_FCG$HpfDJ>5tACo#vIrIis**$HJUZNwFrHSFX1(Im0OniC$e$-sgVDV@eAKE4Iz4U!I}DW(0H+HjyJ5mmbS0Wu~1J#(K(~j zys|iF6jtn5m@_IV)pnN-?A>KN9aaA>}y|xebwK*2*r4w|{=rpe^&KZSe z+qnO1a!4CPx5B*Q6a~E>s0wQOTnr(4$G(>ryXJT_-*%2VkTcZ#L+G5*Y2LLsXB1ZK zSeOqgDc0nC$8ntRnDJ}~(W?v2)aRDQi(PZPVePfFeQl0~dK(O#Gdj&Hi*rU{#g2tJ zqmp7xG_PE5VRD93781R>pnS7F!@S#vo;PXg4(AN@dLKGxbeeZ9&KZSuIA>H+tjXmJ z#|e7>g?V!b(W?v2v>DGZFKeQ6MpJhES^uibAZmz}Gy&3gmCYIWQ17ndEpK-w1X z&KjtD@dWR?)w**(?S1OiUfi#9;gq#bsI-RqSn|JiSKdLa*BpTjgJGk-Ct2$OA=6O$x_Qqat}BV8oK*IDeBa#2-T(aYXY(iXt$Alo&5gM-w|M?!KA7j`dmOtp zcjia)9^X!I?9QCw*p>Zug`;;k#_yLna)eLs&AIu~e!fCk7sx5)oa5W==aeHeGMi=# z57zt_q;IQfjC3PBpQD}|yuP=kvP6gb5+z>%%SEG{5byWE6(aZw<*-bm*fcwM9pn2x zK96jv$4Gr;enzfSwBUvL!ra>wyGVIxw(VoXOws0rnVSuiFg7zB-9Q;TW`gGiO5%}y zvupN{YRA4FBG2zA?XRex7`{M?8*uvE9HUh?sOuLTBZF;c?osm0);Gi@?QYsa6@?%~{_wFvD&+pP}|e}lfs z!ujX+KR$AATYL!n?c*^+E7{r+T1f@&*az*ukCx3~=?$c$5)UjhRLKJEU)BColru+Z zbChvl`Q?!v)I`mXQ1%u+P4O-&q@U05WS-GOUdOrjgE{=|0uRO#XZaI+yMrcA!NwB# zeTwF{P4f|HKAGzW{kr`354d*lPNwLU;u~a#7!H7l$F@;A^|1%dkVkq8TS+b%8CKCp z8J?ORNhQ11HraZdZW(zq^X8eOA2FuvfCY&#jAyhtnUiQjD^For`W^K(15+cUV6$j>$MX|CWgAB&J`(4K)dwRqBl|vbjgfi}XMTT()0!m;%2dQ{a>8_}R6O2nx5VW# zdixIj{&7ZQa&BqlJ+GyiwZj5>+5@xfFUj-~p0vh+Jxd$x;mKo6bA+Re%~QPZT6?UM z7t&H6@OTGpz76`SrVqxcmf*6PFV7jR$(ThIOO&FoEpUXK9YULAip-K7_W$%l###36 zOhm&q@!l1x>L(mXRgdWdCpg{@4$5#5%?M_Gb?3jwWV6&Cx8;ZvlzKT^UbuG{HDc z^v+{AKH_MI5s7h`PrmxmgkFh$%%j)K%G{K*Opc#4`fZQ$|06RQc@Cd3`FUY}7SK$y zG|lgMf7R3H)7KYV6wsYto?^yugUFShEu}^uTz6O+zP`r%LvrUCW1q;`;>5-Y_6*~C@67tM(6f*+@oN4Y@MNvJXGI}G=a{NO- z=7^4CW5zem8K^?8(Qe^&eLPkA!4HV*{{q(B8d{vn^`Aapo-@XF&N<12j2TB@XbfJc zHZsZiD94cWNRB9vaEwupnxltv%(zZ!^J9mv%|9~nt(nI0#Wg(U$+Ja2oZ-n=SE+2X98y#hzovbVxluKSZ&=Hg71k#Kz!c5MD`mG#`b!ur^cc2^_qqn8+$$oY>} z0m~rAYdg!jw)H;ZSd6{q!*#qoe-bn9NhT4lFxkC-ByDJi^_fK54j5#Jw+S zi@wK*&)FpVOzMj}MqCHse3SbW9G!9Rgx_VIl5>Chr_)#0{FCc|;qK@+zWN0%I@ zbG?uei7Q^R-^evtzh9PPi#_ZW{GTgv!hU$9$@&Yd>owyL_fRk4!|xD1xU))+77N9i ziz8KBlGObyhyuUa{rgKq%<)4s@)06Dm&*C+p|9j`BEnp9+~sKMFf3D4oIjr{A*?sf z9o8+@$TKbF=g-Ico2%JD_B?Zz(A@0~qkG8nCKM}P{Sp2>hmzj*vUMG72hcQsgLH=8 ziN6<$)x_VIh(4Vj%Hb0A^y4d38h5W{MM&dU3r#yZOkF&c#1ng&w@IF>e4a9P%-6RG z+dS4-K7Ad0&aOG%jPcd9ufx`dw-}e+Z%~?k&_{D&FXYpEd)B~~;_QEg%h@rfu@F}+ zJ335VJe9-~`i6^h)VX;G#vo?$=?(*r&_-0&Rm)6qh z>tgG}TdX_1|Ay+vvl`e^oP}{C)kl@W)upizS1mg_OkF&c#1s3Lx5==0rfJ7Ej4AH& z>3z&7iO<#P(mXUCkzLR_`%=rDEh zR1#0@Tizza;+du$+c2iM%cn1+v$#HI*PPbU>FZ+a!&|I7_5r-&9RFoJ?0O3N@vH{6 z6lY=F@V?`1SqfK|#zI`R?C3Cc@l+B|>|5R@!{V8y9osObxXY(6qqDd^XV+EZSxN33 zwm!VYy3@PTiGDn*fi1;Z7&pA{c%7BPXbQag=?3&YBI(=PieRzv?r+57!{diUbTZ*$VZg}7Ewk(CKOJgCfT6T1px_Byy zC-yCGlVR~p(~fNzQ{3g#m(f{VpR?<#@vJ0w4qG4IV%_Oo8%#f*)xehGEQ}l8cf8I@ z;c|A&X)MH5%Z?6H7f&Ve#J=clGAy2H+OZ8|io1OJGCGUvb9T*XEuFqDwm!VYy3@OQ zpME^6fi1;Z7&pA{cw3gj)upizS1mg_OkF&c#1s3Lx5==0rfJ7Ej4AH&>C5OWuFu(Z z)p%BtJBO_gZ?W$5uB53S&uU;xaTdl6?>k;+rEobr<}?=Ks%1xqsf(wQcw%4lHW?Pr zH0{`iF~wazeHop_^*Oudw3bd^7h50RV%_Oon^HfX)xehGEQ}l8cf2i2;p);@h^v+z z9i}dxO5%xq%iCmFJkzve8^#oO`SfLU7T4$Ox@tTt$(_U2hqq97!>_~|Uq7{Z&FuI- zlQ+1|X`I7Z?`vF7^el1y6|S<&<8lR3-UsF-$~b(uUhnW0yh7Q$8`n8%X z@0=^G)VwFLkS0lzP9SDTz|=cLgO;>g{-yM5(t2;82$EalO^4k|_1YXbvUslEQmg z@{T&ZUjgqe%sV*Ay;9`<>AaJ{F0TE@yYftJdg7SidVsutEbn@-hkK<+B Date: Mon, 9 Nov 2015 19:17:43 -0500 Subject: [PATCH 115/213] [Plugin Specs] Change uint32_t to int32_t (formerly BOOL). --- Source/Project64/Plugins/Controller Plugin.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Project64/Plugins/Controller Plugin.h b/Source/Project64/Plugins/Controller Plugin.h index b8cf32595..2887e5bd2 100644 --- a/Source/Project64/Plugins/Controller Plugin.h +++ b/Source/Project64/Plugins/Controller Plugin.h @@ -45,9 +45,9 @@ typedef union typedef struct { - uint32_t Present; - uint32_t RawData; - int32_t Plugin; + int32_t Present; + int32_t RawData; + int32_t Plugin; } CONTROL; enum PluginType From b617c4db1dbef4e4178bd1ea3fdecb4ff82c2257 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 Nov 2015 22:24:02 -0500 Subject: [PATCH 116/213] [Plugin Specs] moved CONTROL_INFO typedef for accessibility --- Source/Project64/Plugins/Controller Plugin.cpp | 14 -------------- Source/Project64/Plugins/Controller Plugin.h | 10 ++++++++++ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Source/Project64/Plugins/Controller Plugin.cpp b/Source/Project64/Plugins/Controller Plugin.cpp index 8b399bace..3db3ae50d 100644 --- a/Source/Project64/Plugins/Controller Plugin.cpp +++ b/Source/Project64/Plugins/Controller Plugin.cpp @@ -79,20 +79,6 @@ bool CControl_Plugin::Initiate(CN64System * System, CMainGui * RenderWindow) } else if (m_PluginInfo.Version >= 0x0101) { - typedef struct - { - HWND hMainWindow; - HINSTANCE hinst; - - int32_t MemoryBswaped; // If this is set to TRUE, then the memory has been pre - // bswap on a dword (32 bits) boundry, only effects header. - // eg. the first 8 bytes are stored like this: - // 4 3 2 1 8 7 6 5 - uint8_t * HEADER; // This is the rom header (first 40h bytes of the rom) - CONTROL *Controls; // A pointer to an array of 4 controllers .. eg: - // CONTROL Controls[4]; - } CONTROL_INFO; - //Get Function from DLL void(__cdecl *InitiateControllers_1_1)(CONTROL_INFO * ControlInfo); InitiateControllers_1_1 = (void(__cdecl *)(CONTROL_INFO *))GetProcAddress((HMODULE)m_hDll, "InitiateControllers"); diff --git a/Source/Project64/Plugins/Controller Plugin.h b/Source/Project64/Plugins/Controller Plugin.h index b8cf32595..f59a40aba 100644 --- a/Source/Project64/Plugins/Controller Plugin.h +++ b/Source/Project64/Plugins/Controller Plugin.h @@ -50,6 +50,16 @@ typedef struct int32_t Plugin; } CONTROL; +typedef struct +{ + void * hMainWindow; + void * hinst; + + int32_t MemoryBswaped; // memory in client- or server-native endian + uint8_t * HEADER; // the ROM header (first 40h bytes of the ROM) + CONTROL * Controls; // pointer to array of 4 controllers, i.e.: CONTROL Controls[4]; +} CONTROL_INFO; + enum PluginType { PLUGIN_NONE = 1, From e11c0b2c22194b18210e90e60b9fd48fe86d93c1 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 Nov 2015 22:26:59 -0500 Subject: [PATCH 117/213] [Plugin Specs] reverted contr 1.1 for backward-compatibility No plugins for Windows (that can run on Project64) currently use the 1.1 controller plugin specifications, and the ones that do use it (for Linux) use the publicly released spec which did not have the pointer version in the late-modified spec. We don't want to let plugin wars roam between the emulators' implementations. --- .../Project64/Plugins/Controller Plugin.cpp | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/Source/Project64/Plugins/Controller Plugin.cpp b/Source/Project64/Plugins/Controller Plugin.cpp index 3db3ae50d..a0a908ebe 100644 --- a/Source/Project64/Plugins/Controller Plugin.cpp +++ b/Source/Project64/Plugins/Controller Plugin.cpp @@ -60,6 +60,9 @@ bool CControl_Plugin::LoadFunctions(void) bool CControl_Plugin::Initiate(CN64System * System, CMainGui * RenderWindow) { + CONTROL_INFO ControlInfo; + uint8_t Buffer[100]; + for (int32_t i = 0; i < 4; i++) { m_PluginControllers[i].Present = FALSE; @@ -67,6 +70,15 @@ bool CControl_Plugin::Initiate(CN64System * System, CMainGui * RenderWindow) m_PluginControllers[i].Plugin = PLUGIN_NONE; } + if (m_PluginInfo.Version >= 0x0101) + { + ControlInfo.Controls = m_PluginControllers; + ControlInfo.HEADER = (System == NULL ? Buffer : g_Rom->GetRomAddress()); + ControlInfo.hinst = GetModuleHandle(NULL); + ControlInfo.hMainWindow = (HWND)RenderWindow->m_hMainWindow; + ControlInfo.MemoryBswaped = TRUE; + } + // Test Plugin version if (m_PluginInfo.Version == 0x0100) { @@ -74,26 +86,28 @@ bool CControl_Plugin::Initiate(CN64System * System, CMainGui * RenderWindow) void(__cdecl *InitiateControllers_1_0)(HWND hMainWindow, CONTROL Controls[4]); InitiateControllers_1_0 = (void(__cdecl *)(HWND, CONTROL *))GetProcAddress((HMODULE)m_hDll, "InitiateControllers"); if (InitiateControllers_1_0 == NULL) { return false; } - InitiateControllers_1_0((HWND)RenderWindow->m_hMainWindow,m_PluginControllers); + + InitiateControllers_1_0((HWND)RenderWindow->m_hMainWindow, m_PluginControllers); m_Initialized = true; } - else if (m_PluginInfo.Version >= 0x0101) + else if (m_PluginInfo.Version == 0x0101) { //Get Function from DLL - void(__cdecl *InitiateControllers_1_1)(CONTROL_INFO * ControlInfo); - InitiateControllers_1_1 = (void(__cdecl *)(CONTROL_INFO *))GetProcAddress((HMODULE)m_hDll, "InitiateControllers"); + void(__cdecl *InitiateControllers_1_1)(CONTROL_INFO ControlInfo); + InitiateControllers_1_1 = (void(__cdecl *)(CONTROL_INFO))GetProcAddress((HMODULE)m_hDll, "InitiateControllers"); if (InitiateControllers_1_1 == NULL) { return false; } - CONTROL_INFO ControlInfo; - uint8_t Buffer[100]; + InitiateControllers_1_1(ControlInfo); + m_Initialized = true; + } + else if (m_PluginInfo.Version >= 0x0102) + { + //Get Function from DLL + void(__cdecl *InitiateControllers_1_2)(CONTROL_INFO * ControlInfo); + InitiateControllers_1_2 = (void(__cdecl *)(CONTROL_INFO *))GetProcAddress((HMODULE)m_hDll, "InitiateControllers"); + if (InitiateControllers_1_2 == NULL) { return false; } - ControlInfo.Controls = m_PluginControllers; - ControlInfo.HEADER = (System == NULL ? Buffer : g_Rom->GetRomAddress()); - ControlInfo.hinst = GetModuleHandle(NULL); - ControlInfo.hMainWindow = (HWND)RenderWindow->m_hMainWindow; - ControlInfo.MemoryBswaped = TRUE; - - InitiateControllers_1_1(&ControlInfo); + InitiateControllers_1_2(&ControlInfo); m_Initialized = true; } From 3172a3d1d43d5d1d3d42adcc63673a6d4fd1342a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 Nov 2015 22:33:10 -0500 Subject: [PATCH 118/213] [N-Rage] fixed non-compliance to official 1.1 specs --- .../ControllerSpecs/Controller #1.1.h | 13 ++++++- Source/nragev20/NRagePluginV2.cpp | 38 ++++++++++++++----- Source/nragev20/NRagePluginV2.h | 8 ++++ 3 files changed, 49 insertions(+), 10 deletions(-) diff --git a/Source/nragev20/ControllerSpecs/Controller #1.1.h b/Source/nragev20/ControllerSpecs/Controller #1.1.h index ff305862e..13a836797 100644 --- a/Source/nragev20/ControllerSpecs/Controller #1.1.h +++ b/Source/nragev20/ControllerSpecs/Controller #1.1.h @@ -16,6 +16,10 @@ extern "C" { #define PLUGIN_TYPE_CONTROLLER 4 +#ifndef SPECS_VERSION +#define SPECS_VERSION 0x0101 +#endif + /*** Conteroller plugin's ****/ #define PLUGIN_NONE 1 #define PLUGIN_MEMPAK 2 @@ -181,7 +185,14 @@ extern "C" { the emulator to know how to handle each controller. output: none *******************************************************************/ - EXPORT void CALL InitiateControllers(CONTROL_INFO * ControlInfo); +#if (SPECS_VERSION < 0x0101) +EXPORT void CALL InitiateControllers(void * hMainWindow, CONTROL Controls[4]); +#elif (SPECS_VERSION == 0x0101) +EXPORT void CALL InitiateControllers(CONTROL_INFO ControlInfo); +/* Typo in the official specs, but it works! */ +#else +EXPORT void CALL InitiateControllers(CONTROL_INFO * ControlInfo); +#endif /****************************************************************** Function: ReadController diff --git a/Source/nragev20/NRagePluginV2.cpp b/Source/nragev20/NRagePluginV2.cpp index 193a68385..4ec982240 100644 --- a/Source/nragev20/NRagePluginV2.cpp +++ b/Source/nragev20/NRagePluginV2.cpp @@ -36,7 +36,7 @@ // ProtoTypes // bool prepareHeap(); -void FillControls(CONTROL Controls[]); +void FillControls(CONTROL * Controls); void InitiatePaks( bool bInitialize ); void DoShortcut( int iPlayer, int iShortcut ); DWORD WINAPI MsgThreadFunction( LPVOID lpParam ); @@ -156,7 +156,7 @@ EXPORT void CALL GetDllInfo ( PLUGIN_INFO* PluginInfo ) sprintf(PluginInfo->Name,"N-Rage For PJ64: %s",VER_FILE_VERSION_STR); #endif PluginInfo->Type = PLUGIN_TYPE_CONTROLLER; - PluginInfo->Version = 0x0101; + PluginInfo->Version = SPECS_VERSION; } /****************************************************************** @@ -311,15 +311,36 @@ EXPORT void CALL DllTest ( HWND hParent ) the emulator to know how to handle each controller. output: none *******************************************************************/ -EXPORT void CALL InitiateControllers (CONTROL_INFO * ControlInfo) +EXPORT void CALL InitiateControllers( +#if (SPECS_VERSION < 0x0101) + void * hMainWindow, CONTROL Controls[4] +#elif (SPECS_VERSION == 0x0101) + CONTROL_INFO ControlInfo +#else + CONTROL_INFO * ControlInfo +#endif +) { DebugWriteA("CALLED: InitiateControllers\n"); if( !prepareHeap()) return; - g_strEmuInfo.hMainWindow = ControlInfo->hMainWindow; -// g_strEmuInfo.MemoryBswaped = ControlInfo->MemoryBswaped; -// g_strEmuInfo.HEADER = ControlInfo->HEADER; +#if (SPECS_VERSION < 0x0101) + g_strEmuInfo.controllers = &Controls[0]; + g_strEmuInfo.hMainWindow = hMainWindow; + // g_strEmuInfo.MemoryBswaped = TRUE; // Or FALSE. Really does not matter. + // g_strEmuInfo.HEADER = NULL; +#elif (SPECS_VERSION == 0x0101) + g_strEmuInfo.controllers = ControlInfo.Controls; + g_strEmuInfo.hMainWindow = ControlInfo.hMainWindow; + // g_strEmuInfo.MemoryBswaped = ControlInfo.MemoryBswaped; + // g_strEmuInfo.HEADER = ControlInfo.HEADER; +#else + g_strEmuInfo.controllers = ControlInfo->Controls; + g_strEmuInfo.hMainWindow = ControlInfo->hMainWindow; + // g_strEmuInfo.MemoryBswaped = ControlInfo->MemoryBswaped; + // g_strEmuInfo.HEADER = ControlInfo->HEADER; +#endif // UNDONE: Instead of just storing the header, figure out what ROM we're running and save that information somewhere // The emulator expects us to tell what controllers are plugged in and what their paks are at this point. @@ -430,8 +451,7 @@ EXPORT void CALL InitiateControllers (CONTROL_INFO * ControlInfo) LeaveCriticalSection( &g_critical ); - FillControls(ControlInfo->Controls); - + FillControls(g_strEmuInfo.controllers); return; } // end InitiateControllers @@ -884,7 +904,7 @@ void InitiatePaks( bool bInitialize ) // Unfortunately the spec doesn't work that way. Fixed the func and changed the func name to something that makes more sense. // FillControls takes a Controls array from InitiateControllers and fills it with what we know about whether // a controller is plugged in, accepting raw data, and what type of pak is plugged in. -void FillControls(CONTROL Controls[4]) +void FillControls(CONTROL * Controls) { for( int i = 4-1; i >= 0; i-- ) { diff --git a/Source/nragev20/NRagePluginV2.h b/Source/nragev20/NRagePluginV2.h index a9d7208de..4e57663d5 100644 --- a/Source/nragev20/NRagePluginV2.h +++ b/Source/nragev20/NRagePluginV2.h @@ -62,6 +62,14 @@ typedef struct _EMULATOR_INFO LANGID Language; bool fDisplayShortPop; // do we display shortcut message popups? +/* + * 2015.11.09 cxd4 + * Added to keep the real address of the CONTROL array stored. + * + * This became necessary due to conflicts between specs #1.0, #1.1 and #1.2. + */ + CONTROL * controllers; + // BOOL MemoryBswaped; // If this is set to TRUE, then the memory has been pre // bswap on a dword (32 bits) boundry, only effects header. // eg. the first 8 bytes are stored like this: From 67bd22acc2e54e839147c6e99c30fd0a3e53aca9 Mon Sep 17 00:00:00 2001 From: toehead2001 Date: Mon, 9 Nov 2015 21:10:47 -0700 Subject: [PATCH 119/213] Create window using DialogBoxParamW --- Source/Project64/User Interface/Gui Class.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Source/Project64/User Interface/Gui Class.cpp b/Source/Project64/User Interface/Gui Class.cpp index 8b46abed9..d708ddb3f 100644 --- a/Source/Project64/User Interface/Gui Class.cpp +++ b/Source/Project64/User Interface/Gui Class.cpp @@ -149,7 +149,7 @@ void CMainGui::ChangeWinSize(long width, long height) void CMainGui::AboutBox(void) { - DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_About), m_hMainWindow, (DLGPROC)AboutBoxProc, (LPARAM)this); + DialogBoxParamW(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_About), m_hMainWindow, (DLGPROC)AboutBoxProc, (LPARAM)this); } void CMainGui::AboutIniBox(void) @@ -984,10 +984,7 @@ DWORD CALLBACK AboutBoxProc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) case WM_INITDIALOG: { //Title - LONG_PTR originalWndProc = GetWindowLongPtrW(hWnd, GWLP_WNDPROC); - SetWindowLongPtrW(hWnd, GWLP_WNDPROC, (LONG_PTR)DefWindowProcW); SetWindowTextW(hWnd, GS(PLUG_ABOUT)); - SetWindowLongPtrW(hWnd, GWLP_WNDPROC, originalWndProc); // Use the size of the image hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT_LOGO)); From 26d9339e2c0b7f0250fa643378dbb9b207483751 Mon Sep 17 00:00:00 2001 From: toehead2001 Date: Mon, 9 Nov 2015 21:12:48 -0700 Subject: [PATCH 120/213] Remove some dead code This doesn't do anything anymore --- Source/Project64/User Interface/Gui Class.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Source/Project64/User Interface/Gui Class.cpp b/Source/Project64/User Interface/Gui Class.cpp index d708ddb3f..f3a3d5fa6 100644 --- a/Source/Project64/User Interface/Gui Class.cpp +++ b/Source/Project64/User Interface/Gui Class.cpp @@ -992,18 +992,6 @@ DWORD CALLBACK AboutBoxProc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) BITMAP bmTL; GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL); - if (hbmpBackgroundTop) - { - // int iHeight = bmTL.bmHeight; - int iWidth = bmTL.bmWidth; - - RECT rect; - GetWindowRect(hWnd, &rect); - rect.left -= rect.left; - rect.bottom -= rect.top; - rect.top -= rect.top; - } - hTextFont = ::CreateFont(18, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial"); hAuthorFont = ::CreateFont(18, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial"); From 923f6a485af1a6bb8608be05cb4d2dab0b800c98 Mon Sep 17 00:00:00 2001 From: toehead2001 Date: Mon, 9 Nov 2015 22:21:49 -0700 Subject: [PATCH 121/213] "Project 64" -> "Project64" --- Source/Installer/Installer.iss | 10 +++++----- Source/Project64/Logging.cpp | 2 +- Source/Project64/Logging.h | 2 +- Source/Project64/Multilanguage.h | 2 +- Source/Project64/Multilanguage/Language Class.cpp | 2 +- Source/Project64/Multilanguage/Language Class.h | 2 +- Source/Project64/Multilanguage/LanguageSelector.cpp | 2 +- Source/Project64/Multilanguage/LanguageSelector.h | 2 +- Source/Project64/N64 System.h | 2 +- Source/Project64/N64 System/C Core/r4300i Commands.cpp | 2 +- Source/Project64/N64 System/C Core/r4300i Commands.h | 2 +- Source/Project64/N64 System/Cheat Class.cpp | 2 +- Source/Project64/N64 System/Cheat Class.h | 2 +- .../N64 System/Debugger/Debugger - Memory Dump.cpp | 2 +- .../N64 System/Debugger/Debugger - Memory Dump.h | 2 +- .../N64 System/Debugger/Debugger - Memory Search.cpp | 2 +- .../N64 System/Debugger/Debugger - Memory Search.h | 2 +- .../Project64/N64 System/Debugger/Debugger - TLB.cpp | 2 +- Source/Project64/N64 System/Debugger/Debugger - TLB.h | 2 +- .../N64 System/Debugger/Debugger - View Memory.cpp | 2 +- .../N64 System/Debugger/Debugger - View Memory.h | 2 +- Source/Project64/N64 System/Debugger/Debugger.cpp | 2 +- Source/Project64/N64 System/Debugger/debugger.h | 2 +- .../N64 System/Interpreter/Interpreter CPU.cpp | 2 +- .../Project64/N64 System/Interpreter/Interpreter CPU.h | 2 +- .../N64 System/Interpreter/Interpreter Ops 32.cpp | 2 +- .../N64 System/Interpreter/Interpreter Ops 32.h | 2 +- .../N64 System/Interpreter/Interpreter Ops.cpp | 2 +- .../Project64/N64 System/Interpreter/Interpreter Ops.h | 2 +- Source/Project64/N64 System/Mips/Audio.cpp | 2 +- Source/Project64/N64 System/Mips/Audio.h | 2 +- Source/Project64/N64 System/Mips/Dma.cpp | 2 +- Source/Project64/N64 System/Mips/Dma.h | 2 +- Source/Project64/N64 System/Mips/Eeprom.cpp | 2 +- Source/Project64/N64 System/Mips/Eeprom.h | 2 +- Source/Project64/N64 System/Mips/FlashRam.cpp | 2 +- Source/Project64/N64 System/Mips/FlashRam.h | 2 +- Source/Project64/N64 System/Mips/Memory Class.h | 2 +- .../Project64/N64 System/Mips/Memory Labels Class.cpp | 2 +- Source/Project64/N64 System/Mips/Memory Labels Class.h | 2 +- .../Project64/N64 System/Mips/Memory Virtual Mem.cpp | 2 +- Source/Project64/N64 System/Mips/Memory Virtual Mem.h | 2 +- Source/Project64/N64 System/Mips/Mempak.H | 2 +- Source/Project64/N64 System/Mips/Mempak.cpp | 2 +- Source/Project64/N64 System/Mips/OpCode.h | 2 +- Source/Project64/N64 System/Mips/Pif Ram.cpp | 2 +- Source/Project64/N64 System/Mips/Pif Ram.h | 2 +- Source/Project64/N64 System/Mips/Register Class.cpp | 2 +- Source/Project64/N64 System/Mips/Register Class.h | 2 +- Source/Project64/N64 System/Mips/Rumblepak.cpp | 2 +- Source/Project64/N64 System/Mips/Rumblepak.h | 2 +- Source/Project64/N64 System/Mips/Sram.cpp | 2 +- Source/Project64/N64 System/Mips/Sram.h | 2 +- Source/Project64/N64 System/Mips/System Events.cpp | 2 +- Source/Project64/N64 System/Mips/System Events.h | 2 +- Source/Project64/N64 System/Mips/System Timing.cpp | 2 +- Source/Project64/N64 System/Mips/System Timing.h | 2 +- Source/Project64/N64 System/Mips/TLB Class.h | 2 +- Source/Project64/N64 System/Mips/TLB class.cpp | 2 +- Source/Project64/N64 System/Mips/TranslateVaddr.h | 2 +- Source/Project64/N64 System/N64 Class.cpp | 2 +- Source/Project64/N64 System/N64 Class.h | 2 +- Source/Project64/N64 System/N64 Rom Class.cpp | 2 +- Source/Project64/N64 System/N64 Rom Class.h | 2 +- Source/Project64/N64 System/N64 Types.h | 2 +- Source/Project64/N64 System/Profiling Class.cpp | 2 +- Source/Project64/N64 System/Profiling Class.h | 2 +- Source/Project64/N64 System/Recompiler/Code Block.cpp | 2 +- Source/Project64/N64 System/Recompiler/Code Block.h | 2 +- .../Project64/N64 System/Recompiler/Code Section.cpp | 2 +- Source/Project64/N64 System/Recompiler/Code Section.h | 2 +- Source/Project64/N64 System/Recompiler/Exit Info.h | 2 +- .../Project64/N64 System/Recompiler/Function Info.cpp | 2 +- Source/Project64/N64 System/Recompiler/Function Info.h | 2 +- .../N64 System/Recompiler/Function Map Class.cpp | 2 +- .../N64 System/Recompiler/Function Map Class.h | 2 +- Source/Project64/N64 System/Recompiler/Jump Info.h | 2 +- .../Project64/N64 System/Recompiler/Loop Analysis.cpp | 2 +- Source/Project64/N64 System/Recompiler/Loop Analysis.h | 2 +- .../N64 System/Recompiler/Recompiler Class.cpp | 2 +- .../Project64/N64 System/Recompiler/Recompiler Class.h | 2 +- .../N64 System/Recompiler/Recompiler Memory.cpp | 2 +- .../N64 System/Recompiler/Recompiler Memory.h | 2 +- .../Project64/N64 System/Recompiler/Recompiler Ops.cpp | 2 +- .../Project64/N64 System/Recompiler/Recompiler Ops.h | 2 +- Source/Project64/N64 System/Recompiler/Reg Info.cpp | 2 +- Source/Project64/N64 System/Recompiler/Reg Info.h | 2 +- .../Project64/N64 System/Recompiler/Section Info.cpp | 2 +- Source/Project64/N64 System/Recompiler/Section Info.h | 2 +- Source/Project64/N64 System/Recompiler/X86ops.cpp | 2 +- Source/Project64/N64 System/Recompiler/X86ops.h | 2 +- Source/Project64/N64 System/Recompiler/x86CodeLog.cpp | 2 +- Source/Project64/N64 System/Recompiler/x86CodeLog.h | 2 +- Source/Project64/N64 System/Rom Information Class.cpp | 2 +- Source/Project64/N64 System/Rom Information Class.h | 2 +- Source/Project64/N64 System/Speed Limitor Class.cpp | 2 +- Source/Project64/N64 System/Speed Limitor Class.h | 2 +- Source/Project64/N64 System/System Globals.cpp | 2 +- Source/Project64/N64 System/System Globals.h | 2 +- Source/Project64/Plugin.h | 2 +- Source/Project64/Plugins/Audio Plugin.cpp | 2 +- Source/Project64/Plugins/Audio Plugin.h | 2 +- Source/Project64/Plugins/Controller Plugin.cpp | 2 +- Source/Project64/Plugins/Controller Plugin.h | 2 +- Source/Project64/Plugins/GFX plugin.cpp | 2 +- Source/Project64/Plugins/GFX plugin.h | 2 +- Source/Project64/Plugins/Plugin Base.cpp | 2 +- Source/Project64/Plugins/Plugin Base.h | 2 +- Source/Project64/Plugins/Plugin Class.cpp | 2 +- Source/Project64/Plugins/Plugin Class.h | 2 +- Source/Project64/Plugins/Plugin List.cpp | 2 +- Source/Project64/Plugins/RSP Plugin.cpp | 2 +- Source/Project64/Plugins/RSP Plugin.h | 2 +- Source/Project64/Settings.h | 2 +- Source/Project64/Settings/Debug Settings.cpp | 2 +- Source/Project64/Settings/Debug Settings.h | 2 +- Source/Project64/Settings/Game Settings.cpp | 2 +- Source/Project64/Settings/Game Settings.h | 2 +- Source/Project64/Settings/Gui Settings.cpp | 2 +- Source/Project64/Settings/Gui Settings.h | 2 +- Source/Project64/Settings/N64System Settings.cpp | 2 +- Source/Project64/Settings/N64System Settings.h | 2 +- Source/Project64/Settings/Notification Settings.cpp | 2 +- Source/Project64/Settings/Notification Settings.h | 2 +- Source/Project64/Settings/Recompiler Settings.cpp | 2 +- Source/Project64/Settings/Recompiler Settings.h | 2 +- .../Settings/SettingType/SettingsType-Application.cpp | 2 +- .../Settings/SettingType/SettingsType-Application.h | 2 +- .../SettingType/SettingsType-ApplicationIndex.cpp | 2 +- .../SettingType/SettingsType-ApplicationIndex.h | 2 +- .../SettingType/SettingsType-ApplicationPath.cpp | 2 +- .../SettingType/SettingsType-ApplicationPath.h | 2 +- .../Project64/Settings/SettingType/SettingsType-Base.h | 2 +- .../Settings/SettingType/SettingsType-Cheats.cpp | 2 +- .../Settings/SettingType/SettingsType-Cheats.h | 2 +- .../Settings/SettingType/SettingsType-GameSetting.cpp | 2 +- .../Settings/SettingType/SettingsType-GameSetting.h | 2 +- .../SettingType/SettingsType-GameSettingIndex.cpp | 2 +- .../SettingType/SettingsType-GameSettingIndex.h | 2 +- .../Settings/SettingType/SettingsType-RDBCpuType.cpp | 2 +- .../Settings/SettingType/SettingsType-RDBCpuType.h | 2 +- .../Settings/SettingType/SettingsType-RDBOnOff.cpp | 2 +- .../Settings/SettingType/SettingsType-RDBOnOff.h | 2 +- .../Settings/SettingType/SettingsType-RDBRamSize.cpp | 2 +- .../Settings/SettingType/SettingsType-RDBRamSize.h | 2 +- .../Settings/SettingType/SettingsType-RDBSaveChip.cpp | 2 +- .../Settings/SettingType/SettingsType-RDBSaveChip.h | 2 +- .../Settings/SettingType/SettingsType-RDBYesNo.cpp | 2 +- .../Settings/SettingType/SettingsType-RDBYesNo.h | 2 +- .../Settings/SettingType/SettingsType-RelativePath.cpp | 2 +- .../Settings/SettingType/SettingsType-RelativePath.h | 2 +- .../Settings/SettingType/SettingsType-RomDatabase.cpp | 2 +- .../Settings/SettingType/SettingsType-RomDatabase.h | 2 +- .../SettingType/SettingsType-RomDatabaseIndex.cpp | 2 +- .../SettingType/SettingsType-RomDatabaseIndex.h | 2 +- .../SettingType/SettingsType-RomDatabaseSetting.cpp | 2 +- .../SettingType/SettingsType-RomDatabaseSetting.h | 2 +- .../SettingType/SettingsType-SelectedDirectory.cpp | 2 +- .../SettingType/SettingsType-SelectedDirectory.h | 2 +- .../Settings/SettingType/SettingsType-TempBool.cpp | 2 +- .../Settings/SettingType/SettingsType-TempBool.h | 2 +- .../Settings/SettingType/SettingsType-TempNumber.cpp | 2 +- .../Settings/SettingType/SettingsType-TempNumber.h | 2 +- .../Settings/SettingType/SettingsType-TempString.cpp | 2 +- .../Settings/SettingType/SettingsType-TempString.h | 2 +- Source/Project64/Settings/Settings Class.cpp | 2 +- Source/Project64/Settings/Settings Class.h | 2 +- Source/Project64/User Interface.h | 2 +- Source/Project64/User Interface/Cheat Class UI.cpp | 2 +- Source/Project64/User Interface/Cheat Class UI.h | 2 +- .../User Interface/Frame Per Second Class.cpp | 2 +- .../Project64/User Interface/Frame Per Second Class.h | 2 +- Source/Project64/User Interface/Gui Class.cpp | 2 +- Source/Project64/User Interface/Gui Class.h | 2 +- Source/Project64/User Interface/Menu Class.h | 2 +- Source/Project64/User Interface/MenuShortCuts.h | 2 +- Source/Project64/User Interface/Notification Class.h | 2 +- Source/Project64/User Interface/Rom Browser.h | 2 +- .../Settings/Settings Page - Advanced Options.cpp | 2 +- .../Settings/Settings Page - Advanced Options.h | 2 +- .../Settings/Settings Page - Directories.cpp | 2 +- .../Settings/Settings Page - Directories.h | 2 +- .../Settings/Settings Page - Game - General.cpp | 2 +- .../Settings/Settings Page - Game - General.h | 2 +- .../Settings/Settings Page - Game - Plugin.cpp | 2 +- .../Settings/Settings Page - Game - Plugin.h | 2 +- .../Settings/Settings Page - Game - Recompiler.cpp | 2 +- .../Settings/Settings Page - Game - Recompiler.h | 2 +- .../Settings/Settings Page - Game - Status.cpp | 2 +- .../Settings/Settings Page - Game - Status.h | 2 +- .../Settings/Settings Page - Game Browser.cpp | 2 +- .../Settings/Settings Page - Game Browser.h | 2 +- .../Settings/Settings Page - Keyboard Shortcuts.cpp | 2 +- .../Settings/Settings Page - Keyboard Shortcuts.h | 2 +- .../Settings/Settings Page - Options.cpp | 2 +- .../User Interface/Settings/Settings Page - Options.h | 2 +- .../User Interface/Settings/Settings Page - Plugin.cpp | 2 +- .../User Interface/Settings/Settings Page - Plugin.h | 2 +- .../User Interface/Settings/Settings Page.cpp | 2 +- .../Project64/User Interface/Settings/Settings Page.h | 2 +- Source/Project64/User Interface/UI Resources.rc | 2 +- .../User Interface/WTL Controls/ModifiedCheckBox.h | 2 +- .../User Interface/WTL Controls/ModifiedComboBox.h | 2 +- .../User Interface/WTL Controls/ModifiedEditBox.cpp | 2 +- .../User Interface/WTL Controls/ModifiedEditBox.h | 2 +- .../User Interface/WTL Controls/PartialGroupBox.cpp | 2 +- .../User Interface/WTL Controls/PartialGroupBox.h | 2 +- .../Project64/User Interface/WTL Controls/numberctrl.h | 2 +- Source/Project64/Version.h | 4 ++-- Source/Project64/WTL App.h | 2 +- Source/Project64/stdafx.h | 2 +- Source/RSP/Cpu.c | 2 +- Source/RSP/Cpu.h | 2 +- Source/RSP/Interpreter CPU.c | 2 +- Source/RSP/Interpreter CPU.h | 2 +- Source/RSP/Interpreter Ops.c | 2 +- Source/RSP/Interpreter Ops.h | 2 +- Source/RSP/Main.cpp | 2 +- Source/RSP/Mmx.c | 2 +- Source/RSP/OpCode.h | 2 +- Source/RSP/Profiling.cpp | 2 +- Source/RSP/Profiling.h | 2 +- Source/RSP/RSP Command.c | 2 +- Source/RSP/RSP Command.h | 2 +- Source/RSP/RSP Register.c | 2 +- Source/RSP/RSP Registers.h | 2 +- Source/RSP/Recompiler Analysis.c | 2 +- Source/RSP/Recompiler CPU.c | 2 +- Source/RSP/Recompiler CPU.h | 2 +- Source/RSP/Recompiler Ops.c | 2 +- Source/RSP/Recompiler Ops.h | 2 +- Source/RSP/Recompiler Sections.c | 2 +- Source/RSP/Rsp.h | 2 +- Source/RSP/Sse.c | 2 +- Source/RSP/Types.h | 2 +- Source/RSP/Version.h | 2 +- Source/RSP/X86.c | 2 +- Source/RSP/X86.h | 2 +- Source/RSP/breakpoint.c | 2 +- Source/RSP/breakpoint.h | 2 +- Source/RSP/dma.c | 2 +- Source/RSP/dma.h | 2 +- Source/RSP/log.cpp | 2 +- Source/RSP/log.h | 2 +- Source/RSP/memory.c | 2 +- Source/RSP/memory.h | 2 +- 246 files changed, 251 insertions(+), 251 deletions(-) diff --git a/Source/Installer/Installer.iss b/Source/Installer/Installer.iss index b212f81fa..64e5d21df 100644 --- a/Source/Installer/Installer.iss +++ b/Source/Installer/Installer.iss @@ -5,7 +5,7 @@ [Setup] AppId={{BEB5FB69-4080-466F-96C4-F15DF271718B} -AppName=Project 64 +AppName=Project64 AppVersion={#AppVersion} DefaultDirName={pf}\Project64 2.2 VersionInfoVersion={#AppVersion} @@ -21,7 +21,7 @@ UninstallDisplayIcon={uninstallexe} SetupIconFile={#BaseDir}\Source\Project64\User Interface\Icons\pj64.ico [Run] -Filename: "{app}\Project64.exe"; Description: "{cm:LaunchProgram,{#StringChange('Project 64', '&', '&&')}}"; Flags: nowait postinstall skipifsilent +Filename: "{app}\Project64.exe"; Description: "{cm:LaunchProgram,{#StringChange('Project64', '&', '&&')}}"; Flags: nowait postinstall skipifsilent [Files] Source: "{#BaseDir}\Bin\{#Configuration}\Project64.exe"; DestDir: "{app}"; Flags: ignoreversion @@ -44,9 +44,9 @@ Name: "{app}\Screenshots"; Permissions: users-modify Name: "{app}\Textures"; Permissions: users-modify [Icons] -Name: "{commonprograms}\Project 64 2.2\Project 64"; Filename: "{app}\Project64.exe" -Name: "{commonprograms}\Project 64 2.2\Uninstall Project64 2.2"; Filename: "{uninstallexe}"; Parameters: "/LOG" -Name: "{commonprograms}\Project 64 2.2\Support"; Filename: "http://forum.pj64-emu.com" +Name: "{commonprograms}\Project64 2.2\Project64"; Filename: "{app}\Project64.exe" +Name: "{commonprograms}\Project64 2.2\Uninstall Project64 2.2"; Filename: "{uninstallexe}"; Parameters: "/LOG" +Name: "{commonprograms}\Project64 2.2\Support"; Filename: "http://forum.pj64-emu.com" [Code] function HaveCommandlineParam (inParam: String): Boolean; diff --git a/Source/Project64/Logging.cpp b/Source/Project64/Logging.cpp index 5f22e34ee..cb4a5ac33 100644 --- a/Source/Project64/Logging.cpp +++ b/Source/Project64/Logging.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Logging.h b/Source/Project64/Logging.h index c36aba4d4..9d2f34138 100644 --- a/Source/Project64/Logging.h +++ b/Source/Project64/Logging.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Multilanguage.h b/Source/Project64/Multilanguage.h index d0cf68ff3..910540d8a 100644 --- a/Source/Project64/Multilanguage.h +++ b/Source/Project64/Multilanguage.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Multilanguage/Language Class.cpp b/Source/Project64/Multilanguage/Language Class.cpp index dab71accb..e2f3d5855 100644 --- a/Source/Project64/Multilanguage/Language Class.cpp +++ b/Source/Project64/Multilanguage/Language Class.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Multilanguage/Language Class.h b/Source/Project64/Multilanguage/Language Class.h index 50cb67be1..19538d67b 100644 --- a/Source/Project64/Multilanguage/Language Class.h +++ b/Source/Project64/Multilanguage/Language Class.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Multilanguage/LanguageSelector.cpp b/Source/Project64/Multilanguage/LanguageSelector.cpp index e317d6b8b..5a93b00ea 100644 --- a/Source/Project64/Multilanguage/LanguageSelector.cpp +++ b/Source/Project64/Multilanguage/LanguageSelector.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Multilanguage/LanguageSelector.h b/Source/Project64/Multilanguage/LanguageSelector.h index bb88af757..5856c22ff 100644 --- a/Source/Project64/Multilanguage/LanguageSelector.h +++ b/Source/Project64/Multilanguage/LanguageSelector.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System.h b/Source/Project64/N64 System.h index 017ff868c..461cfca60 100644 --- a/Source/Project64/N64 System.h +++ b/Source/Project64/N64 System.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/C Core/r4300i Commands.cpp b/Source/Project64/N64 System/C Core/r4300i Commands.cpp index 9b01fd1f7..36e9049aa 100644 --- a/Source/Project64/N64 System/C Core/r4300i Commands.cpp +++ b/Source/Project64/N64 System/C Core/r4300i Commands.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/C Core/r4300i Commands.h b/Source/Project64/N64 System/C Core/r4300i Commands.h index 5f3a207c7..7390b9dea 100644 --- a/Source/Project64/N64 System/C Core/r4300i Commands.h +++ b/Source/Project64/N64 System/C Core/r4300i Commands.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Cheat Class.cpp b/Source/Project64/N64 System/Cheat Class.cpp index db795f744..65a6b6e1b 100644 --- a/Source/Project64/N64 System/Cheat Class.cpp +++ b/Source/Project64/N64 System/Cheat Class.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Cheat Class.h b/Source/Project64/N64 System/Cheat Class.h index a4416fc7c..5734a2cf1 100644 --- a/Source/Project64/N64 System/Cheat Class.h +++ b/Source/Project64/N64 System/Cheat Class.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.cpp b/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.cpp index 5921c429a..3aedc600d 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.h b/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.h index 274b997ce..3cc97858f 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.h +++ b/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp b/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp index 0672dfb9f..aaa9cf7eb 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Debugger/Debugger - Memory Search.h b/Source/Project64/N64 System/Debugger/Debugger - Memory Search.h index 478684269..9e7127a04 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - Memory Search.h +++ b/Source/Project64/N64 System/Debugger/Debugger - Memory Search.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Debugger/Debugger - TLB.cpp b/Source/Project64/N64 System/Debugger/Debugger - TLB.cpp index d68f704ca..100a1f846 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - TLB.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger - TLB.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Debugger/Debugger - TLB.h b/Source/Project64/N64 System/Debugger/Debugger - TLB.h index 2588b1f67..5039d1ca5 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - TLB.h +++ b/Source/Project64/N64 System/Debugger/Debugger - TLB.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp b/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp index 8c577ab73..941c5c9d4 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Debugger/Debugger - View Memory.h b/Source/Project64/N64 System/Debugger/Debugger - View Memory.h index 4c48ad5b6..f90cb3507 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - View Memory.h +++ b/Source/Project64/N64 System/Debugger/Debugger - View Memory.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Debugger/Debugger.cpp b/Source/Project64/N64 System/Debugger/Debugger.cpp index 433b7bf97..fa22d0dd3 100644 --- a/Source/Project64/N64 System/Debugger/Debugger.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Debugger/debugger.h b/Source/Project64/N64 System/Debugger/debugger.h index e8e48f1c0..568c3f89f 100644 --- a/Source/Project64/N64 System/Debugger/debugger.h +++ b/Source/Project64/N64 System/Debugger/debugger.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp b/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp index 0bd568b59..c56be2342 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Interpreter/Interpreter CPU.h b/Source/Project64/N64 System/Interpreter/Interpreter CPU.h index 8283f56ac..196c60612 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter CPU.h +++ b/Source/Project64/N64 System/Interpreter/Interpreter CPU.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp index f168b946d..339a208e3 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.h b/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.h index 23a3965ed..f92d229ef 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.h +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp index 250893e37..1282ed151 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops.h b/Source/Project64/N64 System/Interpreter/Interpreter Ops.h index 909a0acad..6c9b6484c 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops.h +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/Audio.cpp b/Source/Project64/N64 System/Mips/Audio.cpp index 06b7ec67b..fbe7dbb52 100644 --- a/Source/Project64/N64 System/Mips/Audio.cpp +++ b/Source/Project64/N64 System/Mips/Audio.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/Audio.h b/Source/Project64/N64 System/Mips/Audio.h index 51a50ae17..6f66896d4 100644 --- a/Source/Project64/N64 System/Mips/Audio.h +++ b/Source/Project64/N64 System/Mips/Audio.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/Dma.cpp b/Source/Project64/N64 System/Mips/Dma.cpp index 478e31b78..092e8e458 100644 --- a/Source/Project64/N64 System/Mips/Dma.cpp +++ b/Source/Project64/N64 System/Mips/Dma.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/Dma.h b/Source/Project64/N64 System/Mips/Dma.h index a05c35e96..635e2596e 100644 --- a/Source/Project64/N64 System/Mips/Dma.h +++ b/Source/Project64/N64 System/Mips/Dma.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/Eeprom.cpp b/Source/Project64/N64 System/Mips/Eeprom.cpp index 0dfa07c54..0e74ec3e9 100644 --- a/Source/Project64/N64 System/Mips/Eeprom.cpp +++ b/Source/Project64/N64 System/Mips/Eeprom.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/Eeprom.h b/Source/Project64/N64 System/Mips/Eeprom.h index 34bd246ae..fe739445b 100644 --- a/Source/Project64/N64 System/Mips/Eeprom.h +++ b/Source/Project64/N64 System/Mips/Eeprom.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/FlashRam.cpp b/Source/Project64/N64 System/Mips/FlashRam.cpp index 19644dc24..e54bdb7b8 100644 --- a/Source/Project64/N64 System/Mips/FlashRam.cpp +++ b/Source/Project64/N64 System/Mips/FlashRam.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/FlashRam.h b/Source/Project64/N64 System/Mips/FlashRam.h index e3238b9fe..5c982c996 100644 --- a/Source/Project64/N64 System/Mips/FlashRam.h +++ b/Source/Project64/N64 System/Mips/FlashRam.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/Memory Class.h b/Source/Project64/N64 System/Mips/Memory Class.h index 73579140a..8de1b2865 100644 --- a/Source/Project64/N64 System/Mips/Memory Class.h +++ b/Source/Project64/N64 System/Mips/Memory Class.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/Memory Labels Class.cpp b/Source/Project64/N64 System/Mips/Memory Labels Class.cpp index 1047a7c67..3158798fd 100644 --- a/Source/Project64/N64 System/Mips/Memory Labels Class.cpp +++ b/Source/Project64/N64 System/Mips/Memory Labels Class.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/Memory Labels Class.h b/Source/Project64/N64 System/Mips/Memory Labels Class.h index df1bcdb7a..559c04721 100644 --- a/Source/Project64/N64 System/Mips/Memory Labels Class.h +++ b/Source/Project64/N64 System/Mips/Memory Labels Class.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp index 1d5b05df3..1f8a415b5 100644 --- a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp +++ b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/Memory Virtual Mem.h b/Source/Project64/N64 System/Mips/Memory Virtual Mem.h index 000056827..069b393ca 100644 --- a/Source/Project64/N64 System/Mips/Memory Virtual Mem.h +++ b/Source/Project64/N64 System/Mips/Memory Virtual Mem.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/Mempak.H b/Source/Project64/N64 System/Mips/Mempak.H index 650b466c3..711fc640e 100644 --- a/Source/Project64/N64 System/Mips/Mempak.H +++ b/Source/Project64/N64 System/Mips/Mempak.H @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/Mempak.cpp b/Source/Project64/N64 System/Mips/Mempak.cpp index 83470cc43..7fa9a8905 100644 --- a/Source/Project64/N64 System/Mips/Mempak.cpp +++ b/Source/Project64/N64 System/Mips/Mempak.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/OpCode.h b/Source/Project64/N64 System/Mips/OpCode.h index f764cfcf3..30585894e 100644 --- a/Source/Project64/N64 System/Mips/OpCode.h +++ b/Source/Project64/N64 System/Mips/OpCode.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/Pif Ram.cpp b/Source/Project64/N64 System/Mips/Pif Ram.cpp index 7a4bfa37b..b732877be 100644 --- a/Source/Project64/N64 System/Mips/Pif Ram.cpp +++ b/Source/Project64/N64 System/Mips/Pif Ram.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/Pif Ram.h b/Source/Project64/N64 System/Mips/Pif Ram.h index dcacf494f..9cc1fdc42 100644 --- a/Source/Project64/N64 System/Mips/Pif Ram.h +++ b/Source/Project64/N64 System/Mips/Pif Ram.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/Register Class.cpp b/Source/Project64/N64 System/Mips/Register Class.cpp index 6d12cc6cc..7983bb7c3 100644 --- a/Source/Project64/N64 System/Mips/Register Class.cpp +++ b/Source/Project64/N64 System/Mips/Register Class.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/Register Class.h b/Source/Project64/N64 System/Mips/Register Class.h index 7e66deaae..c2715c579 100644 --- a/Source/Project64/N64 System/Mips/Register Class.h +++ b/Source/Project64/N64 System/Mips/Register Class.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/Rumblepak.cpp b/Source/Project64/N64 System/Mips/Rumblepak.cpp index 51051cc6d..856a3aa86 100644 --- a/Source/Project64/N64 System/Mips/Rumblepak.cpp +++ b/Source/Project64/N64 System/Mips/Rumblepak.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/Rumblepak.h b/Source/Project64/N64 System/Mips/Rumblepak.h index 73b476c15..55308dc8e 100644 --- a/Source/Project64/N64 System/Mips/Rumblepak.h +++ b/Source/Project64/N64 System/Mips/Rumblepak.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/Sram.cpp b/Source/Project64/N64 System/Mips/Sram.cpp index d1f588691..45dd2817f 100644 --- a/Source/Project64/N64 System/Mips/Sram.cpp +++ b/Source/Project64/N64 System/Mips/Sram.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/Sram.h b/Source/Project64/N64 System/Mips/Sram.h index 1b9c9f32c..513a49ad3 100644 --- a/Source/Project64/N64 System/Mips/Sram.h +++ b/Source/Project64/N64 System/Mips/Sram.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/System Events.cpp b/Source/Project64/N64 System/Mips/System Events.cpp index 67e8334e3..590b05fb6 100644 --- a/Source/Project64/N64 System/Mips/System Events.cpp +++ b/Source/Project64/N64 System/Mips/System Events.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/System Events.h b/Source/Project64/N64 System/Mips/System Events.h index de868c75c..3b7101bb9 100644 --- a/Source/Project64/N64 System/Mips/System Events.h +++ b/Source/Project64/N64 System/Mips/System Events.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/System Timing.cpp b/Source/Project64/N64 System/Mips/System Timing.cpp index 82f23388a..681de9245 100644 --- a/Source/Project64/N64 System/Mips/System Timing.cpp +++ b/Source/Project64/N64 System/Mips/System Timing.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/System Timing.h b/Source/Project64/N64 System/Mips/System Timing.h index 74da3abc6..ab6c84633 100644 --- a/Source/Project64/N64 System/Mips/System Timing.h +++ b/Source/Project64/N64 System/Mips/System Timing.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/TLB Class.h b/Source/Project64/N64 System/Mips/TLB Class.h index d1a535fc8..7926b99e8 100644 --- a/Source/Project64/N64 System/Mips/TLB Class.h +++ b/Source/Project64/N64 System/Mips/TLB Class.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/TLB class.cpp b/Source/Project64/N64 System/Mips/TLB class.cpp index 4ae8b4d25..3af3da5b6 100644 --- a/Source/Project64/N64 System/Mips/TLB class.cpp +++ b/Source/Project64/N64 System/Mips/TLB class.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Mips/TranslateVaddr.h b/Source/Project64/N64 System/Mips/TranslateVaddr.h index 679158c4e..4e9ea8340 100644 --- a/Source/Project64/N64 System/Mips/TranslateVaddr.h +++ b/Source/Project64/N64 System/Mips/TranslateVaddr.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index e8539ae97..73013aa41 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/N64 Class.h b/Source/Project64/N64 System/N64 Class.h index bad891662..79971522a 100644 --- a/Source/Project64/N64 System/N64 Class.h +++ b/Source/Project64/N64 System/N64 Class.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/N64 Rom Class.cpp b/Source/Project64/N64 System/N64 Rom Class.cpp index dd2569dc3..00d013eeb 100644 --- a/Source/Project64/N64 System/N64 Rom Class.cpp +++ b/Source/Project64/N64 System/N64 Rom Class.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/N64 Rom Class.h b/Source/Project64/N64 System/N64 Rom Class.h index 363add814..b576a68c1 100644 --- a/Source/Project64/N64 System/N64 Rom Class.h +++ b/Source/Project64/N64 System/N64 Rom Class.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/N64 Types.h b/Source/Project64/N64 System/N64 Types.h index 791cd9e3e..f892557d9 100644 --- a/Source/Project64/N64 System/N64 Types.h +++ b/Source/Project64/N64 System/N64 Types.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Profiling Class.cpp b/Source/Project64/N64 System/Profiling Class.cpp index 367ba545f..421b9320b 100644 --- a/Source/Project64/N64 System/Profiling Class.cpp +++ b/Source/Project64/N64 System/Profiling Class.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Profiling Class.h b/Source/Project64/N64 System/Profiling Class.h index 4e1221a86..0bf5d392e 100644 --- a/Source/Project64/N64 System/Profiling Class.h +++ b/Source/Project64/N64 System/Profiling Class.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Code Block.cpp b/Source/Project64/N64 System/Recompiler/Code Block.cpp index c618bf89d..d5712dc48 100644 --- a/Source/Project64/N64 System/Recompiler/Code Block.cpp +++ b/Source/Project64/N64 System/Recompiler/Code Block.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Code Block.h b/Source/Project64/N64 System/Recompiler/Code Block.h index 7999b7691..8fbf4e5fa 100644 --- a/Source/Project64/N64 System/Recompiler/Code Block.h +++ b/Source/Project64/N64 System/Recompiler/Code Block.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Code Section.cpp b/Source/Project64/N64 System/Recompiler/Code Section.cpp index d176ff6b3..cc3128e58 100644 --- a/Source/Project64/N64 System/Recompiler/Code Section.cpp +++ b/Source/Project64/N64 System/Recompiler/Code Section.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Code Section.h b/Source/Project64/N64 System/Recompiler/Code Section.h index 236a78e7d..1e192d60f 100644 --- a/Source/Project64/N64 System/Recompiler/Code Section.h +++ b/Source/Project64/N64 System/Recompiler/Code Section.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Exit Info.h b/Source/Project64/N64 System/Recompiler/Exit Info.h index bf7dbfdc0..6e3e5a40c 100644 --- a/Source/Project64/N64 System/Recompiler/Exit Info.h +++ b/Source/Project64/N64 System/Recompiler/Exit Info.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Function Info.cpp b/Source/Project64/N64 System/Recompiler/Function Info.cpp index 2721ec1aa..2eac26329 100644 --- a/Source/Project64/N64 System/Recompiler/Function Info.cpp +++ b/Source/Project64/N64 System/Recompiler/Function Info.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Function Info.h b/Source/Project64/N64 System/Recompiler/Function Info.h index 0aaa2d960..f930b196f 100644 --- a/Source/Project64/N64 System/Recompiler/Function Info.h +++ b/Source/Project64/N64 System/Recompiler/Function Info.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Function Map Class.cpp b/Source/Project64/N64 System/Recompiler/Function Map Class.cpp index a76fc1901..942437040 100644 --- a/Source/Project64/N64 System/Recompiler/Function Map Class.cpp +++ b/Source/Project64/N64 System/Recompiler/Function Map Class.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Function Map Class.h b/Source/Project64/N64 System/Recompiler/Function Map Class.h index 49ad9c679..2abef6e36 100644 --- a/Source/Project64/N64 System/Recompiler/Function Map Class.h +++ b/Source/Project64/N64 System/Recompiler/Function Map Class.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Jump Info.h b/Source/Project64/N64 System/Recompiler/Jump Info.h index 9effed90e..b8e14c215 100644 --- a/Source/Project64/N64 System/Recompiler/Jump Info.h +++ b/Source/Project64/N64 System/Recompiler/Jump Info.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp b/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp index bdf61c8e8..6a5b14f4e 100644 --- a/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp +++ b/Source/Project64/N64 System/Recompiler/Loop Analysis.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Loop Analysis.h b/Source/Project64/N64 System/Recompiler/Loop Analysis.h index b840571b9..30afffa81 100644 --- a/Source/Project64/N64 System/Recompiler/Loop Analysis.h +++ b/Source/Project64/N64 System/Recompiler/Loop Analysis.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp index e3c578a8d..4849ed253 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Class.h b/Source/Project64/N64 System/Recompiler/Recompiler Class.h index 4e7e59eda..cc317e3f8 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Class.h +++ b/Source/Project64/N64 System/Recompiler/Recompiler Class.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Memory.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Memory.cpp index be4b9040a..c8a00419b 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Memory.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Memory.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Memory.h b/Source/Project64/N64 System/Recompiler/Recompiler Memory.h index 092a248c1..bff2a26e1 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Memory.h +++ b/Source/Project64/N64 System/Recompiler/Recompiler Memory.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp index cfe6d5e67..a326a5da7 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Ops.h b/Source/Project64/N64 System/Recompiler/Recompiler Ops.h index 594097211..e7cce48a6 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Ops.h +++ b/Source/Project64/N64 System/Recompiler/Recompiler Ops.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Reg Info.cpp b/Source/Project64/N64 System/Recompiler/Reg Info.cpp index 071e5b530..3bde33a10 100644 --- a/Source/Project64/N64 System/Recompiler/Reg Info.cpp +++ b/Source/Project64/N64 System/Recompiler/Reg Info.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Reg Info.h b/Source/Project64/N64 System/Recompiler/Reg Info.h index d9ae33d63..5ed26b813 100644 --- a/Source/Project64/N64 System/Recompiler/Reg Info.h +++ b/Source/Project64/N64 System/Recompiler/Reg Info.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Section Info.cpp b/Source/Project64/N64 System/Recompiler/Section Info.cpp index 3bc75b8a4..a497e4b47 100644 --- a/Source/Project64/N64 System/Recompiler/Section Info.cpp +++ b/Source/Project64/N64 System/Recompiler/Section Info.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/Section Info.h b/Source/Project64/N64 System/Recompiler/Section Info.h index e67f665c0..0a1788dad 100644 --- a/Source/Project64/N64 System/Recompiler/Section Info.h +++ b/Source/Project64/N64 System/Recompiler/Section Info.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/X86ops.cpp b/Source/Project64/N64 System/Recompiler/X86ops.cpp index cdc2a8c95..f2239b028 100644 --- a/Source/Project64/N64 System/Recompiler/X86ops.cpp +++ b/Source/Project64/N64 System/Recompiler/X86ops.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/X86ops.h b/Source/Project64/N64 System/Recompiler/X86ops.h index 937e53f9d..d5f2172a9 100644 --- a/Source/Project64/N64 System/Recompiler/X86ops.h +++ b/Source/Project64/N64 System/Recompiler/X86ops.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/x86CodeLog.cpp b/Source/Project64/N64 System/Recompiler/x86CodeLog.cpp index c59730b78..870e1baf6 100644 --- a/Source/Project64/N64 System/Recompiler/x86CodeLog.cpp +++ b/Source/Project64/N64 System/Recompiler/x86CodeLog.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Recompiler/x86CodeLog.h b/Source/Project64/N64 System/Recompiler/x86CodeLog.h index 3512675cb..03784d109 100644 --- a/Source/Project64/N64 System/Recompiler/x86CodeLog.h +++ b/Source/Project64/N64 System/Recompiler/x86CodeLog.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Rom Information Class.cpp b/Source/Project64/N64 System/Rom Information Class.cpp index 6eca5542a..d2c80225e 100644 --- a/Source/Project64/N64 System/Rom Information Class.cpp +++ b/Source/Project64/N64 System/Rom Information Class.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Rom Information Class.h b/Source/Project64/N64 System/Rom Information Class.h index e4be02d00..6ec536cac 100644 --- a/Source/Project64/N64 System/Rom Information Class.h +++ b/Source/Project64/N64 System/Rom Information Class.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Speed Limitor Class.cpp b/Source/Project64/N64 System/Speed Limitor Class.cpp index 03b7fa13b..061da0766 100644 --- a/Source/Project64/N64 System/Speed Limitor Class.cpp +++ b/Source/Project64/N64 System/Speed Limitor Class.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/Speed Limitor Class.h b/Source/Project64/N64 System/Speed Limitor Class.h index 301d8221f..375d6bd82 100644 --- a/Source/Project64/N64 System/Speed Limitor Class.h +++ b/Source/Project64/N64 System/Speed Limitor Class.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/System Globals.cpp b/Source/Project64/N64 System/System Globals.cpp index 0d88ceb51..64aae0e7c 100644 --- a/Source/Project64/N64 System/System Globals.cpp +++ b/Source/Project64/N64 System/System Globals.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/N64 System/System Globals.h b/Source/Project64/N64 System/System Globals.h index 803f8d401..a63350de3 100644 --- a/Source/Project64/N64 System/System Globals.h +++ b/Source/Project64/N64 System/System Globals.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Plugin.h b/Source/Project64/Plugin.h index e6130b2e9..3c684ab5d 100644 --- a/Source/Project64/Plugin.h +++ b/Source/Project64/Plugin.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Plugins/Audio Plugin.cpp b/Source/Project64/Plugins/Audio Plugin.cpp index bed736a61..618fcee12 100644 --- a/Source/Project64/Plugins/Audio Plugin.cpp +++ b/Source/Project64/Plugins/Audio Plugin.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Plugins/Audio Plugin.h b/Source/Project64/Plugins/Audio Plugin.h index a6bd03c66..bd53392d4 100644 --- a/Source/Project64/Plugins/Audio Plugin.h +++ b/Source/Project64/Plugins/Audio Plugin.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Plugins/Controller Plugin.cpp b/Source/Project64/Plugins/Controller Plugin.cpp index 8b399bace..7da456458 100644 --- a/Source/Project64/Plugins/Controller Plugin.cpp +++ b/Source/Project64/Plugins/Controller Plugin.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Plugins/Controller Plugin.h b/Source/Project64/Plugins/Controller Plugin.h index 2887e5bd2..eadd678c8 100644 --- a/Source/Project64/Plugins/Controller Plugin.h +++ b/Source/Project64/Plugins/Controller Plugin.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Plugins/GFX plugin.cpp b/Source/Project64/Plugins/GFX plugin.cpp index a25ba07bb..b08397a3f 100644 --- a/Source/Project64/Plugins/GFX plugin.cpp +++ b/Source/Project64/Plugins/GFX plugin.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Plugins/GFX plugin.h b/Source/Project64/Plugins/GFX plugin.h index 01f3b71c0..8f5f7a4d4 100644 --- a/Source/Project64/Plugins/GFX plugin.h +++ b/Source/Project64/Plugins/GFX plugin.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Plugins/Plugin Base.cpp b/Source/Project64/Plugins/Plugin Base.cpp index 0ff04e27b..3f3f8df09 100644 --- a/Source/Project64/Plugins/Plugin Base.cpp +++ b/Source/Project64/Plugins/Plugin Base.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Plugins/Plugin Base.h b/Source/Project64/Plugins/Plugin Base.h index 4eb295d4f..eaf5dcd01 100644 --- a/Source/Project64/Plugins/Plugin Base.h +++ b/Source/Project64/Plugins/Plugin Base.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Plugins/Plugin Class.cpp b/Source/Project64/Plugins/Plugin Class.cpp index 6dfccc915..30a5d291d 100644 --- a/Source/Project64/Plugins/Plugin Class.cpp +++ b/Source/Project64/Plugins/Plugin Class.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Plugins/Plugin Class.h b/Source/Project64/Plugins/Plugin Class.h index 51deb2127..21c761293 100644 --- a/Source/Project64/Plugins/Plugin Class.h +++ b/Source/Project64/Plugins/Plugin Class.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Plugins/Plugin List.cpp b/Source/Project64/Plugins/Plugin List.cpp index dd1412d89..244492e76 100644 --- a/Source/Project64/Plugins/Plugin List.cpp +++ b/Source/Project64/Plugins/Plugin List.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Plugins/RSP Plugin.cpp b/Source/Project64/Plugins/RSP Plugin.cpp index b33d3d03d..2a992013d 100644 --- a/Source/Project64/Plugins/RSP Plugin.cpp +++ b/Source/Project64/Plugins/RSP Plugin.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Plugins/RSP Plugin.h b/Source/Project64/Plugins/RSP Plugin.h index ef20275bf..72d1f7297 100644 --- a/Source/Project64/Plugins/RSP Plugin.h +++ b/Source/Project64/Plugins/RSP Plugin.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings.h b/Source/Project64/Settings.h index 869efbfa6..f4d74296b 100644 --- a/Source/Project64/Settings.h +++ b/Source/Project64/Settings.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/Debug Settings.cpp b/Source/Project64/Settings/Debug Settings.cpp index 76110b9f2..dd9390966 100644 --- a/Source/Project64/Settings/Debug Settings.cpp +++ b/Source/Project64/Settings/Debug Settings.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/Debug Settings.h b/Source/Project64/Settings/Debug Settings.h index 79a17c317..77a3283ff 100644 --- a/Source/Project64/Settings/Debug Settings.h +++ b/Source/Project64/Settings/Debug Settings.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/Game Settings.cpp b/Source/Project64/Settings/Game Settings.cpp index af2ffdc57..8dc1d2e05 100644 --- a/Source/Project64/Settings/Game Settings.cpp +++ b/Source/Project64/Settings/Game Settings.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/Game Settings.h b/Source/Project64/Settings/Game Settings.h index 44690d25f..f898dde78 100644 --- a/Source/Project64/Settings/Game Settings.h +++ b/Source/Project64/Settings/Game Settings.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/Gui Settings.cpp b/Source/Project64/Settings/Gui Settings.cpp index 79b19c14e..9eca59014 100644 --- a/Source/Project64/Settings/Gui Settings.cpp +++ b/Source/Project64/Settings/Gui Settings.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/Gui Settings.h b/Source/Project64/Settings/Gui Settings.h index 4e7fa4178..78c76326d 100644 --- a/Source/Project64/Settings/Gui Settings.h +++ b/Source/Project64/Settings/Gui Settings.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/N64System Settings.cpp b/Source/Project64/Settings/N64System Settings.cpp index 3c7b58f54..63bb1925d 100644 --- a/Source/Project64/Settings/N64System Settings.cpp +++ b/Source/Project64/Settings/N64System Settings.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/N64System Settings.h b/Source/Project64/Settings/N64System Settings.h index 73cf60dcf..1016d71b5 100644 --- a/Source/Project64/Settings/N64System Settings.h +++ b/Source/Project64/Settings/N64System Settings.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/Notification Settings.cpp b/Source/Project64/Settings/Notification Settings.cpp index dad717a84..61ecf1ab5 100644 --- a/Source/Project64/Settings/Notification Settings.cpp +++ b/Source/Project64/Settings/Notification Settings.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/Notification Settings.h b/Source/Project64/Settings/Notification Settings.h index 5e75da155..c7ad0dcac 100644 --- a/Source/Project64/Settings/Notification Settings.h +++ b/Source/Project64/Settings/Notification Settings.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/Recompiler Settings.cpp b/Source/Project64/Settings/Recompiler Settings.cpp index b4dd56783..095d9d8d6 100644 --- a/Source/Project64/Settings/Recompiler Settings.cpp +++ b/Source/Project64/Settings/Recompiler Settings.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/Recompiler Settings.h b/Source/Project64/Settings/Recompiler Settings.h index aedbd6c9f..b90d921f3 100644 --- a/Source/Project64/Settings/Recompiler Settings.h +++ b/Source/Project64/Settings/Recompiler Settings.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-Application.cpp b/Source/Project64/Settings/SettingType/SettingsType-Application.cpp index 98f0634be..ba655d8ba 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-Application.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-Application.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-Application.h b/Source/Project64/Settings/SettingType/SettingsType-Application.h index ff14203c0..87a3a883c 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-Application.h +++ b/Source/Project64/Settings/SettingType/SettingsType-Application.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-ApplicationIndex.cpp b/Source/Project64/Settings/SettingType/SettingsType-ApplicationIndex.cpp index 427917a15..c84cd20cd 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-ApplicationIndex.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-ApplicationIndex.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-ApplicationIndex.h b/Source/Project64/Settings/SettingType/SettingsType-ApplicationIndex.h index 336ed62b1..da2b8edc1 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-ApplicationIndex.h +++ b/Source/Project64/Settings/SettingType/SettingsType-ApplicationIndex.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-ApplicationPath.cpp b/Source/Project64/Settings/SettingType/SettingsType-ApplicationPath.cpp index ed907c7e1..d6707ab2d 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-ApplicationPath.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-ApplicationPath.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-ApplicationPath.h b/Source/Project64/Settings/SettingType/SettingsType-ApplicationPath.h index 65e1bf2c6..d74d15191 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-ApplicationPath.h +++ b/Source/Project64/Settings/SettingType/SettingsType-ApplicationPath.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-Base.h b/Source/Project64/Settings/SettingType/SettingsType-Base.h index 56b8d7192..337b78027 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-Base.h +++ b/Source/Project64/Settings/SettingType/SettingsType-Base.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-Cheats.cpp b/Source/Project64/Settings/SettingType/SettingsType-Cheats.cpp index 60efd7290..4cf52eec0 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-Cheats.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-Cheats.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-Cheats.h b/Source/Project64/Settings/SettingType/SettingsType-Cheats.h index cc21be450..d5cc5017b 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-Cheats.h +++ b/Source/Project64/Settings/SettingType/SettingsType-Cheats.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-GameSetting.cpp b/Source/Project64/Settings/SettingType/SettingsType-GameSetting.cpp index 74b2d3c29..72f615211 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-GameSetting.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-GameSetting.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-GameSetting.h b/Source/Project64/Settings/SettingType/SettingsType-GameSetting.h index 9b3a35bc5..191d8e665 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-GameSetting.h +++ b/Source/Project64/Settings/SettingType/SettingsType-GameSetting.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-GameSettingIndex.cpp b/Source/Project64/Settings/SettingType/SettingsType-GameSettingIndex.cpp index 8fdb9e52d..557cffb47 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-GameSettingIndex.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-GameSettingIndex.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-GameSettingIndex.h b/Source/Project64/Settings/SettingType/SettingsType-GameSettingIndex.h index 6940b6812..7cce0e804 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-GameSettingIndex.h +++ b/Source/Project64/Settings/SettingType/SettingsType-GameSettingIndex.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-RDBCpuType.cpp b/Source/Project64/Settings/SettingType/SettingsType-RDBCpuType.cpp index 79200f6a8..d2cdd3fdc 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RDBCpuType.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-RDBCpuType.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-RDBCpuType.h b/Source/Project64/Settings/SettingType/SettingsType-RDBCpuType.h index 231c69ea8..776ddb4ed 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RDBCpuType.h +++ b/Source/Project64/Settings/SettingType/SettingsType-RDBCpuType.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-RDBOnOff.cpp b/Source/Project64/Settings/SettingType/SettingsType-RDBOnOff.cpp index 0e48cbba7..19f7aaf17 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RDBOnOff.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-RDBOnOff.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-RDBOnOff.h b/Source/Project64/Settings/SettingType/SettingsType-RDBOnOff.h index 46f91bed4..064d9b540 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RDBOnOff.h +++ b/Source/Project64/Settings/SettingType/SettingsType-RDBOnOff.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-RDBRamSize.cpp b/Source/Project64/Settings/SettingType/SettingsType-RDBRamSize.cpp index aafda1a9e..43d60b4c8 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RDBRamSize.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-RDBRamSize.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-RDBRamSize.h b/Source/Project64/Settings/SettingType/SettingsType-RDBRamSize.h index 81352e0f1..72b690fc5 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RDBRamSize.h +++ b/Source/Project64/Settings/SettingType/SettingsType-RDBRamSize.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-RDBSaveChip.cpp b/Source/Project64/Settings/SettingType/SettingsType-RDBSaveChip.cpp index 6946e9a4c..d98acc142 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RDBSaveChip.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-RDBSaveChip.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-RDBSaveChip.h b/Source/Project64/Settings/SettingType/SettingsType-RDBSaveChip.h index bf98725d5..b04fb0cf7 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RDBSaveChip.h +++ b/Source/Project64/Settings/SettingType/SettingsType-RDBSaveChip.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.cpp b/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.cpp index 3c4acaef2..d877a838d 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.h b/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.h index 6331504b0..986efafb0 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.h +++ b/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-RelativePath.cpp b/Source/Project64/Settings/SettingType/SettingsType-RelativePath.cpp index 19a547db5..d91a35187 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RelativePath.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-RelativePath.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-RelativePath.h b/Source/Project64/Settings/SettingType/SettingsType-RelativePath.h index 4d3fc24b1..df6c9f4af 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RelativePath.h +++ b/Source/Project64/Settings/SettingType/SettingsType-RelativePath.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-RomDatabase.cpp b/Source/Project64/Settings/SettingType/SettingsType-RomDatabase.cpp index 13ed2e890..1f9fee913 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RomDatabase.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-RomDatabase.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-RomDatabase.h b/Source/Project64/Settings/SettingType/SettingsType-RomDatabase.h index c74723a36..24bc28a01 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RomDatabase.h +++ b/Source/Project64/Settings/SettingType/SettingsType-RomDatabase.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseIndex.cpp b/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseIndex.cpp index 296d70d09..302184c9c 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseIndex.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseIndex.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseIndex.h b/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseIndex.h index 1373f4ef5..ac85c006c 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseIndex.h +++ b/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseIndex.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.cpp b/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.cpp index 0c45ae4f3..b01742bea 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.h b/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.h index 49db4fd06..b763ec032 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.h +++ b/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseSetting.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-SelectedDirectory.cpp b/Source/Project64/Settings/SettingType/SettingsType-SelectedDirectory.cpp index 58de69139..12a4fcb19 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-SelectedDirectory.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-SelectedDirectory.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-SelectedDirectory.h b/Source/Project64/Settings/SettingType/SettingsType-SelectedDirectory.h index f6ebba028..baea2fda4 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-SelectedDirectory.h +++ b/Source/Project64/Settings/SettingType/SettingsType-SelectedDirectory.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-TempBool.cpp b/Source/Project64/Settings/SettingType/SettingsType-TempBool.cpp index 52dfd2a4c..cd27a200a 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-TempBool.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-TempBool.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-TempBool.h b/Source/Project64/Settings/SettingType/SettingsType-TempBool.h index 67e4ca8eb..891db0ed1 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-TempBool.h +++ b/Source/Project64/Settings/SettingType/SettingsType-TempBool.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-TempNumber.cpp b/Source/Project64/Settings/SettingType/SettingsType-TempNumber.cpp index d501ada61..f04640564 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-TempNumber.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-TempNumber.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-TempNumber.h b/Source/Project64/Settings/SettingType/SettingsType-TempNumber.h index b9c72d7eb..459d8dafb 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-TempNumber.h +++ b/Source/Project64/Settings/SettingType/SettingsType-TempNumber.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-TempString.cpp b/Source/Project64/Settings/SettingType/SettingsType-TempString.cpp index a102b890c..b0e536c43 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-TempString.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-TempString.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/SettingType/SettingsType-TempString.h b/Source/Project64/Settings/SettingType/SettingsType-TempString.h index f79db8e33..4bb512d7d 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-TempString.h +++ b/Source/Project64/Settings/SettingType/SettingsType-TempString.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/Settings Class.cpp b/Source/Project64/Settings/Settings Class.cpp index c083a3341..6e1e943c2 100644 --- a/Source/Project64/Settings/Settings Class.cpp +++ b/Source/Project64/Settings/Settings Class.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Settings/Settings Class.h b/Source/Project64/Settings/Settings Class.h index 1f7479223..056fe255c 100644 --- a/Source/Project64/Settings/Settings Class.h +++ b/Source/Project64/Settings/Settings Class.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface.h b/Source/Project64/User Interface.h index a322eca86..9eaa923c0 100644 --- a/Source/Project64/User Interface.h +++ b/Source/Project64/User Interface.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Cheat Class UI.cpp b/Source/Project64/User Interface/Cheat Class UI.cpp index b9bdca508..b40130cea 100644 --- a/Source/Project64/User Interface/Cheat Class UI.cpp +++ b/Source/Project64/User Interface/Cheat Class UI.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Cheat Class UI.h b/Source/Project64/User Interface/Cheat Class UI.h index b72ed6307..3c0a199af 100644 --- a/Source/Project64/User Interface/Cheat Class UI.h +++ b/Source/Project64/User Interface/Cheat Class UI.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Frame Per Second Class.cpp b/Source/Project64/User Interface/Frame Per Second Class.cpp index 3228a31cc..e329a57c2 100644 --- a/Source/Project64/User Interface/Frame Per Second Class.cpp +++ b/Source/Project64/User Interface/Frame Per Second Class.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Frame Per Second Class.h b/Source/Project64/User Interface/Frame Per Second Class.h index 0525fe4b0..77d099b4c 100644 --- a/Source/Project64/User Interface/Frame Per Second Class.h +++ b/Source/Project64/User Interface/Frame Per Second Class.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Gui Class.cpp b/Source/Project64/User Interface/Gui Class.cpp index f3a3d5fa6..57661ec1b 100644 --- a/Source/Project64/User Interface/Gui Class.cpp +++ b/Source/Project64/User Interface/Gui Class.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Gui Class.h b/Source/Project64/User Interface/Gui Class.h index 62dc6f9ad..264bcc7c6 100644 --- a/Source/Project64/User Interface/Gui Class.h +++ b/Source/Project64/User Interface/Gui Class.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Menu Class.h b/Source/Project64/User Interface/Menu Class.h index a8e1fc8b7..fc0e4a3d6 100644 --- a/Source/Project64/User Interface/Menu Class.h +++ b/Source/Project64/User Interface/Menu Class.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/MenuShortCuts.h b/Source/Project64/User Interface/MenuShortCuts.h index f3ccb90cb..b53d62b11 100644 --- a/Source/Project64/User Interface/MenuShortCuts.h +++ b/Source/Project64/User Interface/MenuShortCuts.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Notification Class.h b/Source/Project64/User Interface/Notification Class.h index ed600f4f3..b125e8481 100644 --- a/Source/Project64/User Interface/Notification Class.h +++ b/Source/Project64/User Interface/Notification Class.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Rom Browser.h b/Source/Project64/User Interface/Rom Browser.h index 5890782fb..0d177d36d 100644 --- a/Source/Project64/User Interface/Rom Browser.h +++ b/Source/Project64/User Interface/Rom Browser.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page - Advanced Options.cpp b/Source/Project64/User Interface/Settings/Settings Page - Advanced Options.cpp index ca0cb1678..8866d5ccd 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Advanced Options.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Advanced Options.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page - Advanced Options.h b/Source/Project64/User Interface/Settings/Settings Page - Advanced Options.h index 5ed2bce48..85d0e4243 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Advanced Options.h +++ b/Source/Project64/User Interface/Settings/Settings Page - Advanced Options.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page - Directories.cpp b/Source/Project64/User Interface/Settings/Settings Page - Directories.cpp index 8aa9d0617..239073253 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Directories.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Directories.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page - Directories.h b/Source/Project64/User Interface/Settings/Settings Page - Directories.h index 9e06715d9..f930d3232 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Directories.h +++ b/Source/Project64/User Interface/Settings/Settings Page - Directories.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page - Game - General.cpp b/Source/Project64/User Interface/Settings/Settings Page - Game - General.cpp index 90cff8468..d2554c12d 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game - General.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Game - General.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page - Game - General.h b/Source/Project64/User Interface/Settings/Settings Page - Game - General.h index f2d954907..f26b51801 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game - General.h +++ b/Source/Project64/User Interface/Settings/Settings Page - Game - General.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page - Game - Plugin.cpp b/Source/Project64/User Interface/Settings/Settings Page - Game - Plugin.cpp index 5cb478b02..b095059da 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game - Plugin.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Game - Plugin.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page - Game - Plugin.h b/Source/Project64/User Interface/Settings/Settings Page - Game - Plugin.h index 6d9f0769c..771bb5d15 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game - Plugin.h +++ b/Source/Project64/User Interface/Settings/Settings Page - Game - Plugin.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page - Game - Recompiler.cpp b/Source/Project64/User Interface/Settings/Settings Page - Game - Recompiler.cpp index 3b72f2860..eb4147028 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game - Recompiler.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Game - Recompiler.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page - Game - Recompiler.h b/Source/Project64/User Interface/Settings/Settings Page - Game - Recompiler.h index afefbe8c1..e1ecf8476 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game - Recompiler.h +++ b/Source/Project64/User Interface/Settings/Settings Page - Game - Recompiler.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page - Game - Status.cpp b/Source/Project64/User Interface/Settings/Settings Page - Game - Status.cpp index 2a2e13a9a..83e4d1df1 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game - Status.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Game - Status.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page - Game - Status.h b/Source/Project64/User Interface/Settings/Settings Page - Game - Status.h index 31b93488c..8de3c6f9b 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game - Status.h +++ b/Source/Project64/User Interface/Settings/Settings Page - Game - Status.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page - Game Browser.cpp b/Source/Project64/User Interface/Settings/Settings Page - Game Browser.cpp index acdc22bc8..7d16e778f 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game Browser.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Game Browser.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page - Game Browser.h b/Source/Project64/User Interface/Settings/Settings Page - Game Browser.h index 795beeb9b..3cfd53af1 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game Browser.h +++ b/Source/Project64/User Interface/Settings/Settings Page - Game Browser.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.cpp b/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.cpp index 0ff9a07f3..9eb9ebe51 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.h b/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.h index ca80fdf98..efe129cbf 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.h +++ b/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page - Options.cpp b/Source/Project64/User Interface/Settings/Settings Page - Options.cpp index f60659ea2..3449c4856 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Options.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Options.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page - Options.h b/Source/Project64/User Interface/Settings/Settings Page - Options.h index 4058ac7bf..00240541d 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Options.h +++ b/Source/Project64/User Interface/Settings/Settings Page - Options.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page - Plugin.cpp b/Source/Project64/User Interface/Settings/Settings Page - Plugin.cpp index d15e8f2a1..17be84740 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Plugin.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Plugin.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page - Plugin.h b/Source/Project64/User Interface/Settings/Settings Page - Plugin.h index ec6b04eec..5714ae5f6 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Plugin.h +++ b/Source/Project64/User Interface/Settings/Settings Page - Plugin.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page.cpp b/Source/Project64/User Interface/Settings/Settings Page.cpp index 5f9e20bd4..89277c68b 100644 --- a/Source/Project64/User Interface/Settings/Settings Page.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/Settings/Settings Page.h b/Source/Project64/User Interface/Settings/Settings Page.h index c1a4eff6c..0dce03282 100644 --- a/Source/Project64/User Interface/Settings/Settings Page.h +++ b/Source/Project64/User Interface/Settings/Settings Page.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/UI Resources.rc b/Source/Project64/User Interface/UI Resources.rc index 27a521eb3..c2217bb2a 100644 --- a/Source/Project64/User Interface/UI Resources.rc +++ b/Source/Project64/User Interface/UI Resources.rc @@ -387,7 +387,7 @@ IDD_About DIALOGEX 0, 0, 233, 265 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - LTEXT "Core Project 64 Team:",IDC_TEAM,15,87,168,17 + LTEXT "Core Project64 Team:",IDC_TEAM,15,87,168,17 LTEXT "Zilmar",IDC_ZILMAR,15,108,49,11 LTEXT "founder. Core and application programmer. Web site.",IDC_ZILMAR_DETAILS,69,107,151,24 LTEXT "Jabo",IDC_JABO,15,133,49,11 diff --git a/Source/Project64/User Interface/WTL Controls/ModifiedCheckBox.h b/Source/Project64/User Interface/WTL Controls/ModifiedCheckBox.h index 39a2495b4..aa42745d1 100644 --- a/Source/Project64/User Interface/WTL Controls/ModifiedCheckBox.h +++ b/Source/Project64/User Interface/WTL Controls/ModifiedCheckBox.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/WTL Controls/ModifiedComboBox.h b/Source/Project64/User Interface/WTL Controls/ModifiedComboBox.h index e6da4a608..ba7b6f96b 100644 --- a/Source/Project64/User Interface/WTL Controls/ModifiedComboBox.h +++ b/Source/Project64/User Interface/WTL Controls/ModifiedComboBox.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/WTL Controls/ModifiedEditBox.cpp b/Source/Project64/User Interface/WTL Controls/ModifiedEditBox.cpp index d64ba3449..d87c05bb1 100644 --- a/Source/Project64/User Interface/WTL Controls/ModifiedEditBox.cpp +++ b/Source/Project64/User Interface/WTL Controls/ModifiedEditBox.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/WTL Controls/ModifiedEditBox.h b/Source/Project64/User Interface/WTL Controls/ModifiedEditBox.h index 1a09514d6..5cdc56dfa 100644 --- a/Source/Project64/User Interface/WTL Controls/ModifiedEditBox.h +++ b/Source/Project64/User Interface/WTL Controls/ModifiedEditBox.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/WTL Controls/PartialGroupBox.cpp b/Source/Project64/User Interface/WTL Controls/PartialGroupBox.cpp index 38573ba3c..278c9cdcb 100644 --- a/Source/Project64/User Interface/WTL Controls/PartialGroupBox.cpp +++ b/Source/Project64/User Interface/WTL Controls/PartialGroupBox.cpp @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/WTL Controls/PartialGroupBox.h b/Source/Project64/User Interface/WTL Controls/PartialGroupBox.h index 0a971f3da..52789ccec 100644 --- a/Source/Project64/User Interface/WTL Controls/PartialGroupBox.h +++ b/Source/Project64/User Interface/WTL Controls/PartialGroupBox.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/User Interface/WTL Controls/numberctrl.h b/Source/Project64/User Interface/WTL Controls/numberctrl.h index f75766d61..52ac4ef72 100644 --- a/Source/Project64/User Interface/WTL Controls/numberctrl.h +++ b/Source/Project64/User Interface/WTL Controls/numberctrl.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/Version.h b/Source/Project64/Version.h index becdd7831..12b051a77 100644 --- a/Source/Project64/Version.h +++ b/Source/Project64/Version.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * @@ -16,7 +16,7 @@ #define VERSION_REVISION 0 #define VERSION_BUILD 9999 -#define VER_FILE_DESCRIPTION_STR "Project 64" +#define VER_FILE_DESCRIPTION_STR "Project64" #define VER_FILE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD #define VER_FILE_VERSION_STR STRINGIZE(VERSION_MAJOR) \ "." STRINGIZE(VERSION_MINOR) \ diff --git a/Source/Project64/WTL App.h b/Source/Project64/WTL App.h index cfda490a8..be68d3e84 100644 --- a/Source/Project64/WTL App.h +++ b/Source/Project64/WTL App.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/Project64/stdafx.h b/Source/Project64/stdafx.h index 85725f863..941fedd89 100644 --- a/Source/Project64/stdafx.h +++ b/Source/Project64/stdafx.h @@ -1,6 +1,6 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64 - A Nintendo 64 emulator. * * http://www.pj64-emu.com/ * * Copyright (C) 2012 Project64. All rights reserved. * * * diff --git a/Source/RSP/Cpu.c b/Source/RSP/Cpu.c index 567256593..dac54a873 100644 --- a/Source/RSP/Cpu.c +++ b/Source/RSP/Cpu.c @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/Cpu.h b/Source/RSP/Cpu.h index 4159e8f89..038ab7607 100644 --- a/Source/RSP/Cpu.h +++ b/Source/RSP/Cpu.h @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/Interpreter CPU.c b/Source/RSP/Interpreter CPU.c index f762d9b9f..881b6c192 100644 --- a/Source/RSP/Interpreter CPU.c +++ b/Source/RSP/Interpreter CPU.c @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/Interpreter CPU.h b/Source/RSP/Interpreter CPU.h index 17c33ec3a..78ee3d6d7 100644 --- a/Source/RSP/Interpreter CPU.h +++ b/Source/RSP/Interpreter CPU.h @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/Interpreter Ops.c b/Source/RSP/Interpreter Ops.c index 098dd98b4..135569b39 100644 --- a/Source/RSP/Interpreter Ops.c +++ b/Source/RSP/Interpreter Ops.c @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/Interpreter Ops.h b/Source/RSP/Interpreter Ops.h index f684e5bc0..b422ff264 100644 --- a/Source/RSP/Interpreter Ops.h +++ b/Source/RSP/Interpreter Ops.h @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/Main.cpp b/Source/RSP/Main.cpp index 82e00ac73..cfd068dea 100644 --- a/Source/RSP/Main.cpp +++ b/Source/RSP/Main.cpp @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/Mmx.c b/Source/RSP/Mmx.c index 718fd44e7..26a91788d 100644 --- a/Source/RSP/Mmx.c +++ b/Source/RSP/Mmx.c @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/OpCode.h b/Source/RSP/OpCode.h index 77abb671f..c1e638661 100644 --- a/Source/RSP/OpCode.h +++ b/Source/RSP/OpCode.h @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/Profiling.cpp b/Source/RSP/Profiling.cpp index c7d13aa1c..71ddd7390 100644 --- a/Source/RSP/Profiling.cpp +++ b/Source/RSP/Profiling.cpp @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/Profiling.h b/Source/RSP/Profiling.h index c1aaafbef..06eaaad1c 100644 --- a/Source/RSP/Profiling.h +++ b/Source/RSP/Profiling.h @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/RSP Command.c b/Source/RSP/RSP Command.c index 221854342..6998b0c30 100644 --- a/Source/RSP/RSP Command.c +++ b/Source/RSP/RSP Command.c @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/RSP Command.h b/Source/RSP/RSP Command.h index 7c256dc4b..9c9bd544d 100644 --- a/Source/RSP/RSP Command.h +++ b/Source/RSP/RSP Command.h @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/RSP Register.c b/Source/RSP/RSP Register.c index bb8197415..fff4f245e 100644 --- a/Source/RSP/RSP Register.c +++ b/Source/RSP/RSP Register.c @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/RSP Registers.h b/Source/RSP/RSP Registers.h index 4543def26..3e7505724 100644 --- a/Source/RSP/RSP Registers.h +++ b/Source/RSP/RSP Registers.h @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/Recompiler Analysis.c b/Source/RSP/Recompiler Analysis.c index 2fc25468a..612692e94 100644 --- a/Source/RSP/Recompiler Analysis.c +++ b/Source/RSP/Recompiler Analysis.c @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/Recompiler CPU.c b/Source/RSP/Recompiler CPU.c index ff69c3ba5..7e7f8e248 100644 --- a/Source/RSP/Recompiler CPU.c +++ b/Source/RSP/Recompiler CPU.c @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/Recompiler CPU.h b/Source/RSP/Recompiler CPU.h index e33d1263d..b83a3cf6a 100644 --- a/Source/RSP/Recompiler CPU.h +++ b/Source/RSP/Recompiler CPU.h @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/Recompiler Ops.c b/Source/RSP/Recompiler Ops.c index 594f3c925..b6dde8e51 100644 --- a/Source/RSP/Recompiler Ops.c +++ b/Source/RSP/Recompiler Ops.c @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/Recompiler Ops.h b/Source/RSP/Recompiler Ops.h index 750353259..87ff702e4 100644 --- a/Source/RSP/Recompiler Ops.h +++ b/Source/RSP/Recompiler Ops.h @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/Recompiler Sections.c b/Source/RSP/Recompiler Sections.c index 8a6558285..5069bae44 100644 --- a/Source/RSP/Recompiler Sections.c +++ b/Source/RSP/Recompiler Sections.c @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/Rsp.h b/Source/RSP/Rsp.h index 4b1544853..4d9f15d62 100644 --- a/Source/RSP/Rsp.h +++ b/Source/RSP/Rsp.h @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/Sse.c b/Source/RSP/Sse.c index 6eddbefba..15339f8ca 100644 --- a/Source/RSP/Sse.c +++ b/Source/RSP/Sse.c @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/Types.h b/Source/RSP/Types.h index deaa101f0..d34535a0b 100644 --- a/Source/RSP/Types.h +++ b/Source/RSP/Types.h @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/Version.h b/Source/RSP/Version.h index 909f9602b..b4a4e8f6f 100644 --- a/Source/RSP/Version.h +++ b/Source/RSP/Version.h @@ -1,5 +1,5 @@ /* -* RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). +* RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/X86.c b/Source/RSP/X86.c index 3abdf6c0e..7ddb3dffa 100644 --- a/Source/RSP/X86.c +++ b/Source/RSP/X86.c @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/X86.h b/Source/RSP/X86.h index 6723fe11b..59dc0edd4 100644 --- a/Source/RSP/X86.h +++ b/Source/RSP/X86.h @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/breakpoint.c b/Source/RSP/breakpoint.c index b56bcecf1..416318859 100644 --- a/Source/RSP/breakpoint.c +++ b/Source/RSP/breakpoint.c @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/breakpoint.h b/Source/RSP/breakpoint.h index 8a4933f66..779458da5 100644 --- a/Source/RSP/breakpoint.h +++ b/Source/RSP/breakpoint.h @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/dma.c b/Source/RSP/dma.c index faad399af..cf74508a2 100644 --- a/Source/RSP/dma.c +++ b/Source/RSP/dma.c @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/dma.h b/Source/RSP/dma.h index 199ad2c2b..b9f285faa 100644 --- a/Source/RSP/dma.h +++ b/Source/RSP/dma.h @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/log.cpp b/Source/RSP/log.cpp index 5a07ec162..288950383 100644 --- a/Source/RSP/log.cpp +++ b/Source/RSP/log.cpp @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/log.h b/Source/RSP/log.h index 56700bfc1..206f87813 100644 --- a/Source/RSP/log.h +++ b/Source/RSP/log.h @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/memory.c b/Source/RSP/memory.c index a6cf3c026..19755675d 100644 --- a/Source/RSP/memory.c +++ b/Source/RSP/memory.c @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) diff --git a/Source/RSP/memory.h b/Source/RSP/memory.h index f882ba45e..e3ce42d96 100644 --- a/Source/RSP/memory.h +++ b/Source/RSP/memory.h @@ -1,5 +1,5 @@ /* - * RSP Compiler plug in for Project 64 (A Nintendo 64 emulator). + * RSP Compiler plug in for Project64 (A Nintendo 64 emulator). * * (c) Copyright 2001 jabo (jabo@emulation64.com) and * zilmar (zilmar@emulation64.com) From 623411ce99cebd6f1a1be96002e6a8c51a595b4c Mon Sep 17 00:00:00 2001 From: zilmar Date: Tue, 10 Nov 2015 18:13:49 +1100 Subject: [PATCH 122/213] [Project64] Fix plugin change from uint32_t to int32_t --- Source/Project64/Plugins/Controller Plugin.cpp | 2 +- Source/Project64/Plugins/Controller Plugin.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Project64/Plugins/Controller Plugin.cpp b/Source/Project64/Plugins/Controller Plugin.cpp index 8b399bace..00a07a75c 100644 --- a/Source/Project64/Plugins/Controller Plugin.cpp +++ b/Source/Project64/Plugins/Controller Plugin.cpp @@ -173,7 +173,7 @@ void CControl_Plugin::SetControl(CControl_Plugin const * const Plugin) } } -CCONTROL::CCONTROL(uint32_t &Present, uint32_t &RawData, int32_t &PlugType) : +CCONTROL::CCONTROL(int32_t &Present, int32_t &RawData, int32_t &PlugType) : m_Present(Present), m_RawData(RawData), m_PlugType(PlugType) { m_Buttons.Value = 0; diff --git a/Source/Project64/Plugins/Controller Plugin.h b/Source/Project64/Plugins/Controller Plugin.h index 2887e5bd2..a0a82c49a 100644 --- a/Source/Project64/Plugins/Controller Plugin.h +++ b/Source/Project64/Plugins/Controller Plugin.h @@ -64,7 +64,7 @@ class CControl_Plugin; class CCONTROL { public: - CCONTROL(uint32_t &Present, uint32_t &RawData, int32_t &PlugType); + CCONTROL(int32_t &Present, int32_t &RawData, int32_t &PlugType); inline bool Present(void) const { return m_Present != 0; } inline uint32_t Buttons(void) const { return m_Buttons.Value; } inline PluginType Plugin(void) const { return static_cast(m_PlugType); } From bdfb64c4e884ec6c8347f761f23e1edb14cb44b4 Mon Sep 17 00:00:00 2001 From: toehead2001 Date: Tue, 10 Nov 2015 02:50:08 -0700 Subject: [PATCH 123/213] Get rid of WS_EX_CLIENTEDGE Switch to CreateWindow, as CreateWindowEx is no longer need --- Source/Project64/User Interface/Rom Browser Class.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Project64/User Interface/Rom Browser Class.cpp b/Source/Project64/User Interface/Rom Browser Class.cpp index 7992d092a..11683afb9 100644 --- a/Source/Project64/User Interface/Rom Browser Class.cpp +++ b/Source/Project64/User Interface/Rom Browser Class.cpp @@ -333,7 +333,7 @@ void CRomBrowser::AllocateBrushs(void) void CRomBrowser::CreateRomListControl(void) { - m_hRomList = (HWND)CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, NULL, + m_hRomList = (HWND)CreateWindow(WC_LISTVIEW, NULL, WS_TABSTOP | WS_VISIBLE | WS_CHILD | LVS_OWNERDRAWFIXED | LVS_SINGLESEL | LVS_REPORT, 0, 0, 0, 0, m_MainWindow, (HMENU)IDC_ROMLIST, GetModuleHandle(NULL), NULL); From 8358211e9ab996a62bb8caabb0c52d702dd7c0be Mon Sep 17 00:00:00 2001 From: toehead2001 Date: Tue, 10 Nov 2015 03:04:11 -0700 Subject: [PATCH 124/213] Remove some leftover code from the old About box This allowed you click the top region of the About box to move the window. --- Source/Project64/User Interface/Gui Class.cpp | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/Source/Project64/User Interface/Gui Class.cpp b/Source/Project64/User Interface/Gui Class.cpp index 57661ec1b..f1ba42901 100644 --- a/Source/Project64/User Interface/Gui Class.cpp +++ b/Source/Project64/User Interface/Gui Class.cpp @@ -1017,31 +1017,6 @@ DWORD CALLBACK AboutBoxProc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) SetWindowText(GetDlgItem(hWnd, IDC_VERSION), VersionDisplay.c_str()); } break; - case WM_NCHITTEST: - { - int xPos = LOWORD(lParam); - int yPos = HIWORD(lParam); - RECT client, a; - GetClientRect(hWnd, &a); - GetClientRect(hWnd, &client); - ClientToScreen(hWnd, (LPPOINT)&client); - client.right += client.left; - client.bottom += client.top; - - int nCaption = GetSystemMetrics(SM_CYCAPTION) * 4; - - LRESULT lResult = HTCLIENT; - - //check caption - if (xPos <= client.right && xPos >= client.left && - (yPos >= client.top + 0) && (yPos <= client.top + 0 + nCaption)) - { - lResult = HTCAPTION; - } - SetWindowLong(hWnd, DWLP_MSGRESULT, lResult); - return TRUE; - } - break; case WM_CTLCOLORSTATIC: { HDC hdcStatic = (HDC)wParam; From edf24e534319c350c10e6e104ac1e7571d8e4073 Mon Sep 17 00:00:00 2001 From: "Julio C. Rocha" Date: Tue, 10 Nov 2015 13:21:51 -0800 Subject: [PATCH 125/213] Fix typo in SLN and type for Controller Plugin member variables . --- Project64.sln | 2 +- Source/Project64/Plugins/Controller Plugin.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Project64.sln b/Project64.sln index 513cfdcfd..25ada1938 100644 --- a/Project64.sln +++ b/Project64.sln @@ -9,7 +9,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Glide", "Glide", "{9FE699A5-41C3-4441-92AB-639B3D77DE26}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Common", "Source\Common\Common.vcxproj", "{B4A4B994-9111-42B1-93C2-6F1CA8BC4421}" -EndProjectt +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project64", "Source\Project64\Project64.vcxproj", "{7E534C8E-1ACE-4A88-8807-39A11ED4DA18}" ProjectSection(ProjectDependencies) = postProject {FD617E80-9E40-4138-85DA-B94633972E6A} = {FD617E80-9E40-4138-85DA-B94633972E6A} diff --git a/Source/Project64/Plugins/Controller Plugin.h b/Source/Project64/Plugins/Controller Plugin.h index 7dc64ebca..5ac28657e 100644 --- a/Source/Project64/Plugins/Controller Plugin.h +++ b/Source/Project64/Plugins/Controller Plugin.h @@ -71,8 +71,8 @@ public: private: friend CControl_Plugin; //controller plugin class has full access - uint32_t & m_Present; - uint32_t & m_RawData; + int32_t & m_Present; + int32_t & m_RawData; int32_t & m_PlugType; BUTTONS m_Buttons; From 4df13b4a23ab9d1d159c68e62a58923ce7dbd399 Mon Sep 17 00:00:00 2001 From: exhalatio Date: Wed, 11 Nov 2015 10:10:10 +0900 Subject: [PATCH 126/213] Fix Blurry Fonts on High-DPI Windows 10 --- Source/Project64/Project64.vcxproj | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Project64/Project64.vcxproj b/Source/Project64/Project64.vcxproj index 45a6e4904..7501a67a9 100644 --- a/Source/Project64/Project64.vcxproj +++ b/Source/Project64/Project64.vcxproj @@ -39,6 +39,9 @@ 1 false + + true + @@ -319,4 +322,4 @@ false - \ No newline at end of file + From 762fe5707448785b698e535ecd94a5f0be0c82e5 Mon Sep 17 00:00:00 2001 From: toehead2001 Date: Tue, 10 Nov 2015 20:00:15 -0700 Subject: [PATCH 127/213] Use a standard window for the Language Selector --- .../Multilanguage/LanguageSelector.cpp | 227 ++---------------- .../Project64/User Interface/UI Resources.rc | 6 +- 2 files changed, 20 insertions(+), 213 deletions(-) diff --git a/Source/Project64/Multilanguage/LanguageSelector.cpp b/Source/Project64/Multilanguage/LanguageSelector.cpp index 5a93b00ea..b1cdf940a 100644 --- a/Source/Project64/Multilanguage/LanguageSelector.cpp +++ b/Source/Project64/Multilanguage/LanguageSelector.cpp @@ -20,130 +20,15 @@ void CLanguageSelector::Select ( void ) DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_Lang_Select),NULL,(DLGPROC)LangSelectProc, (LPARAM)this); } -static WNDPROC pfnWndLangSelectOkProc = NULL; -static HBITMAP hOkButton = NULL; - -DWORD CALLBACK LangSelectOkProc (HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) -{ - static bool m_fPressed = false; - static HBITMAP hOkButtonDown = NULL; - - switch (uMsg) - { - case WM_PAINT: - { - PAINTSTRUCT ps; - - if (BeginPaint(hWnd,&ps)) - { - if (m_fPressed) - { - if (hOkButtonDown == NULL) - { - hOkButtonDown = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_LANG_OK_DOWN)); - } - if (hOkButtonDown) - { - RECT rcClient; - GetClientRect(hWnd, &rcClient); - - BITMAP bmTL1; - GetObject(hOkButtonDown, sizeof(BITMAP), &bmTL1); - HDC memdc = CreateCompatibleDC(ps.hdc); - HGDIOBJ save = SelectObject(memdc, hOkButtonDown); - BitBlt(ps.hdc, 0, 0, bmTL1.bmWidth, bmTL1.bmHeight, memdc, 0, 0, SRCCOPY); - SelectObject(memdc, save); - DeleteDC(memdc); - } - } - else - { - if (hOkButton) - { - RECT rcClient; - GetClientRect(hWnd, &rcClient); - - BITMAP bmTL1; - GetObject(hOkButton, sizeof(BITMAP), &bmTL1); - HDC memdc = CreateCompatibleDC(ps.hdc); - HGDIOBJ save = SelectObject(memdc, hOkButton); - BitBlt(ps.hdc, 0, 0, bmTL1.bmWidth, bmTL1.bmHeight, memdc, 0, 0, SRCCOPY); - SelectObject(memdc, save); - DeleteDC(memdc); - } - } - EndPaint(hWnd,&ps); - } - } - break; - case WM_MOUSEMOVE: - if (::GetCapture() == hWnd) - { - POINT ptCursor = { ((int)(short)LOWORD(lParam)), ((int)(short)HIWORD(lParam)) }; - ClientToScreen(hWnd, &ptCursor); - RECT rect; - GetWindowRect(hWnd, &rect); - bool uPressed = ::PtInRect(&rect, ptCursor)==TRUE; - if ( m_fPressed != uPressed ) - { - m_fPressed = uPressed; - ::InvalidateRect(hWnd, NULL, TRUE); - UpdateWindow(hWnd); - } - } - break; - case WM_LBUTTONDOWN: - { - LRESULT lRet = 0; - lRet = DefWindowProc(hWnd, uMsg, wParam, lParam); - SetCapture(hWnd); - if ( ::GetCapture()==hWnd ) - { - m_fPressed = true; - - if (m_fPressed) - { - ::InvalidateRect(hWnd, NULL, TRUE); - UpdateWindow(hWnd); - } - } - return lRet; - } - break; - case WM_LBUTTONUP: - { - LRESULT lRet = 0; - lRet = DefWindowProc(hWnd, uMsg, wParam, lParam); - if ( ::GetCapture() == hWnd ) - { - ::ReleaseCapture(); - if ( m_fPressed ) - { - ::SendMessage(GetParent(hWnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hWnd), BN_CLICKED), (LPARAM)hWnd); - } - } - m_fPressed = false; - - return lRet; - } - break; - } - - return CallWindowProc(pfnWndLangSelectOkProc, hWnd, uMsg, wParam, lParam); -} - LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static HBITMAP hbmpBackgroundTop = NULL; - static HBITMAP hbmpBackgroundBottom = NULL; - static HBITMAP hbmpBackgroundMiddle = NULL; static HFONT hTextFont = NULL; static CLanguageSelector * lngClass; switch (uMsg) { case WM_INITDIALOG: - SetWindowPos(hDlg,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOREPOSITION|SWP_NOSIZE); { lngClass = (CLanguageSelector *)lParam; @@ -167,47 +52,11 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM SendMessage(GetDlgItem(hDlg,IDC_LANG_SEL),CB_SETCURSEL,0,0); } - enum { ROUND_EDGE = 15 }; - - DWORD dwStyle = GetWindowLong(hDlg, GWL_STYLE); - dwStyle &= ~(WS_CAPTION|WS_SIZEBOX); - SetWindowLong(hDlg, GWL_STYLE, dwStyle); - // Use the size of the image - hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_TOP)); - hbmpBackgroundBottom = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_BOTTOM)); - hbmpBackgroundMiddle = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_MIDDLE)); + hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_LOGO)); BITMAP bmTL; GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL); - if (hbmpBackgroundTop) - { - // int iHeight = bmTL.bmHeight; - int iWidth = bmTL.bmWidth; - - RECT rect; - GetWindowRect(hDlg, &rect); - rect.left -= rect.left; - rect.bottom -= rect.top; - rect.top -= rect.top; - - // Tweaked - HRGN hWindowRegion= CreateRoundRectRgn - ( - rect.left, - rect.top, - rect.left+iWidth+GetSystemMetrics(SM_CXEDGE)-1, - rect.bottom+GetSystemMetrics(SM_CYEDGE)-1, - ROUND_EDGE, - ROUND_EDGE - ); - - if (hWindowRegion) - { - SetWindowRgn(hDlg, hWindowRegion, TRUE); - DeleteObject(hWindowRegion); - } - } hTextFont = ::CreateFont ( 18, @@ -227,35 +76,6 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM ); SendDlgItemMessage(hDlg,IDC_SELECT_LANG,WM_SETFONT,(WPARAM)hTextFont,TRUE); } - - hOkButton = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_LANG_OK)); - pfnWndLangSelectOkProc = (WNDPROC)::GetWindowLongPtr(GetDlgItem(hDlg,IDOK), GWLP_WNDPROC); - ::SetWindowLongPtr(GetDlgItem(hDlg,IDOK), GWLP_WNDPROC,(LONG_PTR)LangSelectOkProc); - break; - case WM_NCHITTEST: - { - int xPos = LOWORD(lParam); - int yPos = HIWORD(lParam); - RECT client, a; - GetClientRect(hDlg,&a); - GetClientRect(hDlg,&client); - ClientToScreen(hDlg,(LPPOINT)&client); - client.right += client.left; - client.bottom += client.top; - - int nCaption = GetSystemMetrics(SM_CYCAPTION)*4; - - LRESULT lResult = HTCLIENT; - - //check caption - if (xPos <= client.right && xPos >= client.left && - (yPos >= client.top+ 0)&& (yPos <= client.top + 0+nCaption)) - { - lResult = HTCAPTION; - } - SetWindowLong(hDlg, DWLP_MSGRESULT, lResult); - return TRUE; - } break; case WM_CTLCOLORSTATIC: { @@ -265,6 +85,22 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH)); } break; + case WM_ERASEBKGND: + { + HPEN outline; + HBRUSH fill; + RECT rect; + + outline = CreatePen(PS_SOLID, 1, 0x00FFFFFF); + fill = CreateSolidBrush(0x00FFFFFF); + SelectObject((HDC)wParam, outline); + SelectObject((HDC)wParam, fill); + + GetClientRect(hDlg, &rect); + + Rectangle((HDC)wParam, rect.left, rect.top, rect.right, rect.bottom); + } + break; case WM_PAINT: { PAINTSTRUCT ps; @@ -276,8 +112,6 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM BITMAP bmTL_top, bmTL_bottom, bmTL_Middle; GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top); - GetObject(hbmpBackgroundBottom, sizeof(BITMAP), &bmTL_bottom); - GetObject(hbmpBackgroundMiddle, sizeof(BITMAP), &bmTL_Middle); HDC memdc = CreateCompatibleDC(ps.hdc); HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop); @@ -285,25 +119,6 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM SelectObject(memdc, save); DeleteDC(memdc); - memdc = CreateCompatibleDC(ps.hdc); - save = SelectObject(memdc, hbmpBackgroundMiddle); - for (int x = bmTL_top.bmHeight; x < rcClient.bottom; x += bmTL_Middle.bmHeight) - { - //BitBlt(ps.hdc, 0, bmTL_top.bmHeight, bmTL_Middle.bmWidth, rcClient.bottom - (bmTL_bottom.bmHeight + bmTL_top.bmHeight), memdc, 0, 0, SRCCOPY); - BitBlt(ps.hdc, 0, x, bmTL_Middle.bmWidth, bmTL_Middle.bmHeight, memdc, 0, 0, SRCCOPY); - } - SelectObject(memdc, save); - DeleteDC(memdc); - - BITMAP ; - memdc = CreateCompatibleDC(ps.hdc); - save = SelectObject(memdc, hbmpBackgroundBottom); - BitBlt(ps.hdc, 0, rcClient.bottom - bmTL_bottom.bmHeight, bmTL_bottom.bmWidth, bmTL_bottom.bmHeight, memdc, 0, 0, SRCCOPY); - SelectObject(memdc, save); - DeleteDC(memdc); - - BITMAP ; - EndPaint(hDlg,&ps); } } @@ -316,14 +131,6 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM { DeleteObject(hbmpBackgroundTop); } - if (hbmpBackgroundBottom) - { - DeleteObject(hbmpBackgroundBottom); - } - if (hbmpBackgroundMiddle) - { - DeleteObject(hbmpBackgroundMiddle); - } if (hTextFont) { diff --git a/Source/Project64/User Interface/UI Resources.rc b/Source/Project64/User Interface/UI Resources.rc index c2217bb2a..f763f1b14 100644 --- a/Source/Project64/User Interface/UI Resources.rc +++ b/Source/Project64/User Interface/UI Resources.rc @@ -492,9 +492,9 @@ BEGIN PUSHBUTTON "Close",IDCANCEL,154,110,50,14 END -IDD_Lang_Select DIALOGEX 0, 0, 237, 111 -STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME -CAPTION "Welcome to" +IDD_Lang_Select DIALOGEX 0, 0, 233, 120 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION +CAPTION "Project64" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN DEFPUSHBUTTON "OK",IDOK,90,99,50,12 From 4b150ded0304d052cea5503420cc87ef61553954 Mon Sep 17 00:00:00 2001 From: zilmar Date: Wed, 11 Nov 2015 17:47:22 +1100 Subject: [PATCH 128/213] [Project64] Get File Class.cpp to use standard types --- Source/Common/File Class.cpp | 27 +++++++++------------------ Source/Common/File Class.h | 8 ++++---- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/Source/Common/File Class.cpp b/Source/Common/File Class.cpp index 48acd893a..f9eb583eb 100644 --- a/Source/Common/File Class.cpp +++ b/Source/Common/File Class.cpp @@ -82,13 +82,12 @@ bool CFile::Open(const char * lpszFileName, uint32_t nOpenFlags) ULONG dwCreateFlag = 0; if (nOpenFlags & modeCreate) { - if (nOpenFlags & modeNoTruncate) - dwCreateFlag = OPEN_ALWAYS; - else - dwCreateFlag = CREATE_ALWAYS; + dwCreateFlag = nOpenFlags & modeNoTruncate == 0 ? OPEN_ALWAYS : CREATE_ALWAYS; } else + { dwCreateFlag = OPEN_EXISTING; + } // attempt file creation HANDLE hFile = ::CreateFile(lpszFileName, dwAccess, dwShareMode, &sa, dwCreateFlag, FILE_ATTRIBUTE_NORMAL, NULL); @@ -140,19 +139,15 @@ bool CFile::Flush() return ::FlushFileBuffers(m_hFile) != 0; } -bool CFile::Write(const void* lpBuf, size_t nCount) +bool CFile::Write(const void* lpBuf, uint32_t nCount) { if (nCount == 0) { return true; // avoid Win32 "null-write" option } - if (nCount > ULONG_MAX) - { - nCount = ULONG_MAX; /* Or should we loop WriteFile() every 2 GB? */ - } - DWORD nWritten = 0; - if (!::WriteFile(m_hFile, lpBuf, (DWORD)nCount, &nWritten, NULL)) + ULONG nWritten = 0; + if (!::WriteFile(m_hFile, lpBuf, nCount, &nWritten, NULL)) { return false; } @@ -165,23 +160,19 @@ bool CFile::Write(const void* lpBuf, size_t nCount) return true; } -size_t CFile::Read(void* lpBuf, size_t nCount) +uint32_t CFile::Read(void* lpBuf, uint32_t nCount) { if (nCount == 0) { return 0; // avoid Win32 "null-read" } - if (nCount > ULONG_MAX) - { - nCount = ULONG_MAX; /* Or should we loop ReadFile() every 2 GB? */ - } DWORD dwRead = 0; - if (!::ReadFile(m_hFile, lpBuf, (DWORD)nCount, &dwRead, NULL)) + if (!::ReadFile(m_hFile, lpBuf, nCount, &dwRead, NULL)) { return 0; } - return (dwRead); + return (uint32_t)dwRead; } long CFile::Seek(long lOff, SeekPosition nFrom) diff --git a/Source/Common/File Class.h b/Source/Common/File Class.h index c61730450..fc734f633 100644 --- a/Source/Common/File Class.h +++ b/Source/Common/File Class.h @@ -40,8 +40,8 @@ public: virtual bool SetLength(uint32_t dwNewLen) = 0; virtual uint32_t GetLength() const = 0; - virtual size_t Read(void* lpBuf, size_t nCount) = 0; - virtual bool Write(const void* lpBuf, size_t nCount) = 0; + virtual uint32_t Read(void* lpBuf, uint32_t nCount) = 0; + virtual bool Write(const void* lpBuf, uint32_t nCount) = 0; virtual bool Flush() = 0; virtual bool Close() = 0; @@ -78,8 +78,8 @@ public: virtual bool SetLength(uint32_t dwNewLen); virtual uint32_t GetLength() const; - virtual size_t Read(void* lpBuf, size_t nCount); - virtual bool Write(const void* lpBuf, size_t nCount); + virtual uint32_t Read(void* lpBuf, uint32_t nCount); + virtual bool Write(const void* lpBuf, uint32_t nCount); virtual bool Flush(); virtual bool Close(); From 53aa2faf3b673d6f311c52168e3f6628bd439b8f Mon Sep 17 00:00:00 2001 From: zilmar Date: Wed, 11 Nov 2015 17:51:19 +1100 Subject: [PATCH 129/213] [Project64] Log Class.cpp to use standard types --- Source/Common/Log Class.cpp | 17 ++++++++--------- Source/Common/Log Class.h | 12 ++++++------ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Source/Common/Log Class.cpp b/Source/Common/Log Class.cpp index a0a9560fd..95f001dba 100644 --- a/Source/Common/Log Class.cpp +++ b/Source/Common/Log Class.cpp @@ -120,7 +120,7 @@ void CLog::LogArgs(const char * Message, va_list & args ) void CLog::Log( const char * Message ) { if (!m_hLogFile.IsOpen()) { return; } - m_hLogFile.Write(Message, strlen(Message)*sizeof(TCHAR)); + m_hLogFile.Write(Message,(uint32_t)strlen(Message)*sizeof(TCHAR)); if (m_FlushOnWrite) { m_hLogFile.Flush(); @@ -145,13 +145,13 @@ void CLog::Log( const char * Message ) m_hLogFile.Seek((end - m_MaxFileSize) + m_FileChangeSize,CFile::begin); // Find next end of line - size_t NextEnter = 0, dwRead = 0; + uint32_t NextEnter = 0, dwRead = 0; do { BYTE Data[300]; - size_t dwRead; + uint32_t dwRead; - dwRead = m_hLogFile.Read(Data, sizeof(Data)); + dwRead = m_hLogFile.Read(Data,sizeof(Data)); if (dwRead == 0) { break; @@ -170,9 +170,8 @@ void CLog::Log( const char * Message ) } while(dwRead != 0); // copy content of log to the new file - size_t ReadPos = (end - m_MaxFileSize) + m_FileChangeSize + NextEnter; - uint32_t WritePos = 0; - size_t SizeToRead; + uint32_t ReadPos = (end - m_MaxFileSize) + m_FileChangeSize + NextEnter; + uint32_t SizeToRead, WritePos = 0; do { enum { fIS_MvSize = 0x5000 }; @@ -183,8 +182,8 @@ void CLog::Log( const char * Message ) m_hLogFile.Seek(ReadPos,CFile::begin); - size_t dwRead; - dwRead = m_hLogFile.Read(Data, SizeToRead); + uint32_t dwRead; + dwRead = m_hLogFile.Read(Data,SizeToRead); m_hLogFile.Seek(WritePos,CFile::begin); diff --git a/Source/Common/Log Class.h b/Source/Common/Log Class.h index 1b155da5d..69d322cb1 100644 --- a/Source/Common/Log Class.h +++ b/Source/Common/Log Class.h @@ -15,8 +15,8 @@ class CLog bool m_FlushOnWrite; stdstr m_FileName; bool m_TruncateFileLog; - size_t m_MaxFileSize; - size_t m_FileChangeSize; + uint32_t m_MaxFileSize; + uint32_t m_FileChangeSize; public: CLog ( void ); @@ -29,10 +29,10 @@ public: bool Empty ( void ); void Close ( void ); - inline void SetMaxFileSize(size_t Size) - { - m_MaxFileSize = Size; - m_FileChangeSize = (size_t)(Size * 0.1); + inline void SetMaxFileSize ( uint32_t Size ) + { + m_MaxFileSize = Size; + m_FileChangeSize = (uint32_t)(Size * 0.1); } inline void SetTruncateFile( bool Truncate ) { m_TruncateFileLog = Truncate; } inline void SetFlush ( bool Always ) { m_FlushOnWrite = Always; } From d7429340185442b09734498cecd86797d3d6e893 Mon Sep 17 00:00:00 2001 From: toehead2001 Date: Wed, 11 Nov 2015 01:35:22 -0700 Subject: [PATCH 130/213] Nuke unused resource files --- Source/Project64/Project64.vcxproj | 11 +++-------- Source/Project64/Project64.vcxproj.filters | 15 --------------- .../Bitmaps/AboutScreenBottom.bmp | Bin 24252 -> 0 bytes .../Bitmaps/AboutScreenMiddle.bmp | Bin 8472 -> 0 bytes .../User Interface/Bitmaps/AboutScreenTop.bmp | Bin 132608 -> 0 bytes .../User Interface/Bitmaps/CloseHover.bmp | Bin 1398 -> 0 bytes .../User Interface/Bitmaps/CloseNormal.bmp | Bin 1400 -> 0 bytes .../User Interface/Bitmaps/ClosePushed.bmp | Bin 1398 -> 0 bytes .../User Interface/Bitmaps/LangOK.bmp | Bin 5576 -> 0 bytes .../User Interface/Bitmaps/LangOK_down.bmp | Bin 5576 -> 0 bytes .../Project64/User Interface/UI Resources.rc | 5 ----- Source/Project64/User Interface/resource.h | 5 ----- 12 files changed, 3 insertions(+), 33 deletions(-) delete mode 100644 Source/Project64/User Interface/Bitmaps/AboutScreenBottom.bmp delete mode 100644 Source/Project64/User Interface/Bitmaps/AboutScreenMiddle.bmp delete mode 100644 Source/Project64/User Interface/Bitmaps/AboutScreenTop.bmp delete mode 100644 Source/Project64/User Interface/Bitmaps/CloseHover.bmp delete mode 100644 Source/Project64/User Interface/Bitmaps/CloseNormal.bmp delete mode 100644 Source/Project64/User Interface/Bitmaps/ClosePushed.bmp delete mode 100644 Source/Project64/User Interface/Bitmaps/LangOK.bmp delete mode 100644 Source/Project64/User Interface/Bitmaps/LangOK_down.bmp diff --git a/Source/Project64/Project64.vcxproj b/Source/Project64/Project64.vcxproj index 7501a67a9..0cea30d80 100644 --- a/Source/Project64/Project64.vcxproj +++ b/Source/Project64/Project64.vcxproj @@ -39,9 +39,9 @@ 1 false - + true - + @@ -159,12 +159,7 @@ - - - - - @@ -322,4 +317,4 @@ false - + \ No newline at end of file diff --git a/Source/Project64/Project64.vcxproj.filters b/Source/Project64/Project64.vcxproj.filters index 9805e41ad..1ae4ebd97 100644 --- a/Source/Project64/Project64.vcxproj.filters +++ b/Source/Project64/Project64.vcxproj.filters @@ -422,21 +422,6 @@ - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - Resource Files diff --git a/Source/Project64/User Interface/Bitmaps/AboutScreenBottom.bmp b/Source/Project64/User Interface/Bitmaps/AboutScreenBottom.bmp deleted file mode 100644 index bedfdac44917546f8a5d9f53b8178a4020868ab7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 24252 zcmeI&y-plw6o>J5YZpk{#1%3Pinsu8=OS(p$X5Vbs@zKMg^mkIPlIp*2J>Zy4+rG% z;Rs?8F!}gtjv4LRvgGYNyXQzOf|+^6{MqNxdC%+*&wlQfsvdj&-dDF(%6GoE%ERjS zKRMoh5MR|Vyc``J?eFjJ?d@%EZ*OjHuB@!g&(DvKkGI?HiHV6PS(!j4Fr*0pd~9rN za&mHEVFCE?CjlxT1X?J?_ubvyt*xz%jSZ)?TCHxkyR@|QysBTS`ZX&P$OMKcf#5nA zUtC;-Jn-R90#rZ3|fDqhZDbCVMP(~c*5n^zWjoyWn!f!Tz5(_g=5WdfPNH=IB}uWy24 zID;D60Ec<>5VantfDmY*6i+2gBBE(;h* zGJ%F9&;#x}Aj28d&;~fn!47%g$L4|_2!R%S)}h_@Q|u;U20TE8O1R ze#puMGJ%FC0AzLxLjWA+V23>L;U7~6LZF3vH~2I|Od6tTupO~SAs1`h+}w!c?(XiN ztV|#iXm|oZhBK(44RDx)-97>MF?FDV9yj!EC_LXV#x$*nrh#HY4F6_j0-3;2BoKOl zwp{_t!47%g_iiih`vz`^N0&wtv7v}b1GDHrtQ3j-mz4=*0u4_fSOzt;0nQCzk8K6~ z>xY^BZt!`^+6_7l^UP=(^ibAocp~}dX9AhP#{}REYWo3z!yN3j8%Q8V4xhQ99z@2l zA>EK~r%Yh@66ke9j2!B5zMC?E;Y*;`4KUXTq#K6sznpiJ2@IY n;F;wWnZPI{@Re?OY985%&pzcWaunVdd5@XESGwWHC#C!kXqYi2 diff --git a/Source/Project64/User Interface/Bitmaps/AboutScreenMiddle.bmp b/Source/Project64/User Interface/Bitmaps/AboutScreenMiddle.bmp deleted file mode 100644 index 3bb8f1745bdedb09c75e9cb2168736bd35131347..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8472 zcmeI1p$fw=5QeXAFgI11xjn#G-NeM)USVzzT&St37*R1%fj~&QpY8=t_x?Z<2xsoQ z{-5dN)t_ZsH=GyjcPDbd-ATW_f1Swb_}|+Dj$s(aah#@Up66v*y!Ro57-LE)=Uhsu zwYJt)E)pPtT@XN=5o$ym0Y}Ucc0?Y*NBkiHr~pEM7M!CSb}?@@K>}I=bc2=@>qx*B z0lLA~yxA=YXbI2_T2ibd0b2y<23zxHw)bgr&pb2doXNRw0`$GH&arjt@T&{{ ze-Zva?5H|*rr^Iv)j1RQI(0T3Q@2iolj_L-MS)w_E?r_{W46b|?MO=4xie*VRz`k) z?!LWy%F0R(R8&+~9XME1{rACx|Ni^nzYiV!`|pE)%U$Jv|9uF0XgErNj~L>pD&?+T zG@!lMh`j+)@9+tJNJ9{zRz#1iff(x$eW|CHa$q=;5xs(|ti~W9^df=+FsxJr&%`}~ zJW~*oX0Hrs5YlT<++~zCak8j)OBBtB6YY>C1uLDVqx_kd0+OmD?1L(24p{|E zkkCqocTSToDp@&BmISGnI*5VrQ8F?rMNoqvHPTjaO+iCwQbtk@WHC5yK9HL%Nk%=J0l9%aiI`{|!W85FE1;> zW-rLk#m2|>PfASO78e&A6N9!OyyWcI9F49@4JUWSwDO80?ZZPF z)VS$#uryg%xr~^T>8=+wHJY7;5FFZv=*gp)iIQ0e0fJ*LsMNcIC3uY|>0^0JA}ATf zQ3TQ0kVaP=Mv=?KC5~t;FMaf!DAI=31?pf15w&Ox;(;1S;^M;H)(EI!nP6Q&Y3qeV)WFQRYD6hEM4$n4G8dgj;!8FXML>u{WkhK8m3zpZ zm<~Z|AW#y>K%A`fgoZFNeDblNs-eATn3p7OcUc0?i;08{Y>P-iJb8~yf!oNCRSrK& zP^*K=xNDlOVp=`9hxn6*Jc?jZI5k=*l#!THG0h7G5?aw*rn1sJzJl1JkT(vIr4XghPRWPvtO--Ajia&1 zRwja&tQ$GISdM^HSn_h*fToEDfgHXRUxOM?2~7gZLC`Q{8Y_{GN@xY=-4S3EFtr^H;~$A1$=qOJAJDVf(^#1spMbV83_)q_B{d_jzH$c{DwU^atD%F<h`LdXQ^5NBMNyXdSKlnP55KdN5x=zJr} z7!eC>Nmz4n8R;BxNQ$73Zl(}XE)0pi2J*&YW+BML_AWG*uNGY6N*#1s?G7^m)HE4L zAH|+Z2vQ0Wn3oDVBp?y9pg1l;u@Btch9)Dv*(hN%u!)nJg!t3Z zwLn-h7w4{y2M_U`qN=*8GTa+>XQkt{0S5%Mf~_&pa&F+~4Kdam(t>jXdjni+sw&Z9 z&}bZYM$@z;Ge!$XW)%;+)Id@UM#VCK5-)pHkPuX$uLYv9yrmNYdr!uZ45}-}wJjCF z83$}Vj_3LBgE|U?aP1Ay+4B*Yo|unQV;bOLv8a5xT! z4tlm8KkTcrFQYuN6c7S430mVyq@zUB%g6PC)G#pcP~N}`K=8BUgdlD>M5IeZQehh2 ztd@YsS{e`T1Yd+ObIUr?w>CpR>X z7l(qh)D#>L@X;e0f_&Z}=Z2_laj`oR$OQUh_pN2>uW zL(?({Z8k#NMRaV{%#alXrI5U2OIfDC7aPY)AA=A&io4otg8r^Sg@(lq$qHilL1i?Y zEdknyi;E};IuIzynZBa;aYYapYY*lQN9U`BQhoTYXl5S?=sJW(bfFy}U04K+>J>^M zz^OG~w1H!-aPnwTgpZkd@@lX1MOKc3)`6HornPYlFmREY=p*kyJIp0)>~g8iIY1B) zu1qFNZXtIPBLYK&5ui7F!^gY7=H0nkuz;p-J`=BGc}Jk^{gwszEhD zd(=f_#)3c^GA-^N%#xVlk(Vp@=S2gPNz!o>CaM<$NkI!}^>hp)ID3+zJ;Cok8eId))CiQ}TX7r>$5T6> za5i^nR2d@A88jORwoXK;dKV~2Q}MOlecS1C8WGnUxkv06WGz}DtFMah2c4LCRKOifNoh?jSYDCrIU+>n$Q zpOzw@H{@pHlS??sxuFs*hP^@amb;OX4JQjk%HV@LQjVS0fTa9tGBg&0^M*$dm-%rv zenCQfe-oL-vxgh9)0lWrgLVOGnre(71&hITwzeW#mVx zS1;UyvIEDUTx#STs)j`gY1G9NFa+=A0KI`S50avR6-2=eFvMJa4Z%VOE@~ev9vTGm z$WbBVLCju>Ib&ZaH%GP%ys=MQHChuYg{M?02rAj(u{KG^A<#?5bs$Prh^b{bsK|n; z5ow0)EawLFhEn+~vY-H;MP}fgA{k8p#{_q72=@jwj@=pfEE2sTUwT7n^?~w()zTY; zIG2E9YJ#RxYt+~|V|_fN?OVPyXZK`#p=W_~mbYlU}#7|R`r zJaR|~B6_qSmIHCy#TJ)ma<~vewnP-x-Q6;Ai`3bh-aX0!43z?UpM?(^9QAxPkg4NL z7wFxL=%Z+YSV3NqB~rG5i(?Yj8@>n%*fGtqErshuwv62J(wDlJq{E_LUf#>OX5ie3R78P1w3@)2+xlb{ZY=3I38=on$? zsD?ueb6d>l4K-ER)YS*1H{jgBUvJ1pZ`hfl=LYnK(79oYyi;sXOW6UF{Jh=P8_G)n zaImIQ-YFzzIG~Zz6&G4Qew~`J4vASUcbg(0dvK2IxksCGeKcbi z)Y&Nc2un8`mQE;&%@2IN5`vdi?;pJoLBOqu@TkiE?uQ_FxfWs1!5K&jZZ0gMB=+($A%f{pje>_PT}`AE5u?Gm!FmIJ6B@r3 zxeME0K5vMLjoA`>-hgvMOj5#j=?%MJh~I{g-hguh-YM{7%mYEaeW}vqlk7Q#z z&kfllSAn5c zIemHL3ukdeguul$2AaXq`wH9IzJ4@B0I?#>%%(bkiZl*$3*-Pfn0KQTb`Q)Vatv_7 z#wyoxsr3jOXbx8%j^j0v#9B`)rFEKD# zHAIjrJmhgCDEXMNQId=_Q_0SaGG*o)*qfs%jYhbGssZmxK+ax75GX~nJ8ckD8?ZnL zY)~0Jx2dB5B5|L)=O*cU@l5n(uq4b8m73Ia%m1R6P;9?DU z*(7LMmbZo#n!~-fBI6PJ%&ithRsX-oxBbepV*YW8LiPsy>JwfY@aqlRw#LLpZw}rmHgDS+4K;pe62DcA--AFa zDJ|JsX}zK1P)(%;512$a-V z%I4gqgl>vL%35VcCDa$uZDz#S0NtFZm$wX;El{el;%I7er-6H92wc>-#pSZ_(S2wL zCM$vxGk1>@62#1KB#_DqqMVfp^t>Ft&yMzrudy_)Xb9p*ohCq*tOG!KWJK{YSmy<$ zI;y>wfgeUtcaDmlcR_G^-Lescb%;DQw7Y8vrw?xtS{@!WtkgoOZ-k|$gS%XwTbQuo z1isFgdi4qzx_0IB4G|*;R|E}b3;`ktnxJuTmdeCpxj^culyEmk32KiLD~RGk(6PGm zU{wXa?c zLlxdBq&FOt4<3}=LF*QOqisl7WhXL*I4YXTnyPXHPfJZoPTH;)+7CuyBP~afwKg8p zmr9@rmEy>@@y4T zxp|Vt&8Oz-9PDfkSqLDIvxTf>t6o#hMWlG!7!Dm)yhYXozqMf+kZR3JSBpM(L5K5GJOU!eyuWNCH+jqamw; z)o`-|W5rPeVa^l~R|@E&GlV7>5%f@XMGbpHDbEeXMcC~8qgMQtY3&VBL2u|B!`=`j zy&(xl3mD>@ z-zPo&)OqKf+oVa836GDnY$Pp9(F(vU!=ob01Zrt*l=U!2UmG_wqOWD3)ndV)L4@;#+l)D-G95r-kLl|3E5VdD&lD^M{dR2J509* zggN=kZ0e{rU4>N_xf^+BOc%XWqX-_*n<)VyMtd;`pmfyjS~3qgDyu-FAZj3%+_Dan z*~yTBNFa`S19ef2xl7^#>%A0&rEmyD4%^7Np&Y%Tg1tfCDdg88QxcOB;^MYO#YAuF z(xo&1j5d11CMcjz#knDUXMT2YZm6m(#W#L_9I2uBGYietbD@A}xHL0mRJ^w!Jq^E0 zVP}OMiQA(#Zv7i zL3qeTtUV8ELvY6-!b?w1f>|qse^f!~g_SH09K(0V&5@A=VSp${imvXy8tSD~wIEu2 zkLC?DC@tOPNm6jJbd*uVjDpUla#p>syz}zLVRuz}4Fqo%&MvI?vKL6e(ev&)s*e$t zj$~K~Is915i$#N%bHpewS9~*eX)2CK@W`sEt=B3!UyL5vAhHd3C@s5&U|e5wW$2PJ zSjYbe3`0Xi3-J+HoEyrqweig#=LQ@EH}- zoGQxpRaKT8#E&Yf$`u}`5fRubSX$RJD66KX0s(htq)AuUmYld9Cx-aAn77}4qhrU* z(G^;@Y&mr3&@p4iOqw+5j-j{LRFzp_I5Yb4B0>#9;IJZrBsr$&Ys1iZq`kUJ#=0ET zD{wdF&X<+~8|d8(Fa>6zunaB6w1=_E^deQMH>x2gD$<~aLCuTy@Zxz(FzN0=lr}BJ z(HWSrn7Py}L8*)yhiV>yN#-GvLQD*Vybd{@0V~gtJdM9jD_Ke6PSDhNck?b9Whl8@ zHH?YcGku0*eWWG=t3_t|_Q>jqnPw{KD>B_#Nv*Bfi&BtbDJ~L4@}<4cC7|R3QLu}a zQcr3$1knsIz~`tVFQe)u8Mzb$lLQos`Eq$kEKUI@ogi{&YC7FgCDGGf^lHgF=?Mjg2;dJ%Rh3s)lvb4PFWbLIdP8Prdg{*PL^J{RhN$4& z5XEytV#3zcWy`l7A6+Ut(SB_Rl3#9>N-h>4{yUg32k-8&( zN8+{}NoWk)AiVR|8{NBKb=qmCopsh(Lxv1_>ZzxC^yqQI2`7vmJ$ls05mgl>zIc+8 zP7CM9B_y)eSeB2}o1;<;&KUBhvA-}sTKj+}%7!@+ODUnBBDyOq-GhnMGQ*33XyEWE za1x+V4mJ-uGa8Y1A*R!-mYgn)r3i+sXm%$_a^R&w6~~b$E8!_A6Hqc0K7J8NAgut6 z#TSnx?AYNlrccijFi96LT$)d zFJmR(Mqarw5oJ!nrkjKrmv@+no(!F_DxHl+p^MLvGAqW*>hJk$6q#$*Tr9;#5G=G+ zgS44~RFy-{M$Cw>IJ6NnH83WsVSOZhcNZ6zg2xvGCM$$BF3~KDFbDM&VpZie2g>km zpS=N}Hx%UN=mI(q@Ja6&^}EHy2f)==*X=)HV)wPFdrKt%>pcQFU-;);`h4ly&yswuXctB5v!i2+lDVm4kkY1iADAkHm zgVk#(c=rHP9m(8s@!%#1n&!eHh&@6OQv<06cV}rfkp_kkGN#5+HDY+w5F%K471o6g zz{TCen%*2eHzuW3@|M`GIIrW|GB$W=@gD5l{A~7y)Z_#l5aME^V#4Q!jZh@T^W1== zMSgZhQ9(}G{z9G`DvHr!cy0hShSlYucUgwj01nDBEu26phMP%yw8hRL zw-{?#f*VF1j)I7n&9)+k^)j&>wV)2r%{)UhS<#!L%FdD{cbBh5d9Cdda$$~4Q|4LH z)M64`SEUv~hNzK?Ash!o@Q=dKMiqhJ}1UK$YnWb4C{#I3Zb;3?xd66%jf} zP0e_B1|CzRSS$_dqNsg9Lr2{dn`022IocIe$(KUcu$J1^vsFM-aNJmM(O^^z#F(Sz zWrDLeV|lcs_$F|m6kEHZY;WoQLTq-tD)8Kpl8_W18yCAJHfp2)EHY~2w%9F6+hg%M zkeQw$y&)G)m8E;7H}JK>r{!V>iRNUb^CcoN4i|u5n)ZB~Hf_#0(s4xbiKNb>K%8=@lQ;6;*m!lc2gl}aypT+F>ejz1tp-P7;-{D zBSZ}KPhb+}M0?m!m5`65@PGAA0$h>5>-3sCm-{xvv zK8hzG8X}7(g~EQk_Nr6c15v2NZz#Dwm4`KcF;GbVzQVTngw1Ng9^tVVhRHn{YL+`Q}zZ2VN5 z8{%Wp3c|f%%LeRes8f^C8%lNaIjwM0aS1*+_zxj^Jn%x-cW!hmr-3M}XjE8p~zrlMgj&5WX9%R>_A@ zU-i;(xQF9<*^P$reRL6|N`fr>-6NPg5b}}KAPBdR4K+IHkpu#UX3TXue@G zUPA%7)6oTm>~QEJvLUPf@KFU(@;XO~MoYpXibg~(B0#C(EU4<$MuP^j=Mch?Tm)0; zIebr8f(p3fpe~}fwV@iv2cHt4H&o-?V7&q7hK$Tz=ne5`0z5Zt37s1@#KlN&*s-0x zVK;h1cIo~C_J)f6HT+Qp!a8aYP(PNi>_FLmoI}_c&>j-vMvWYP>7|$U@7Ev4g?S&$ zyYY@2>ou%b=Y%?SPpXHmaO@?=pETf<2DddjzTZhFG&u3;iBFFm^9W(BHUX@}l5jSv zGOD6BS{~&i?m)0h3_Pae>B##KG6@>@a2qYEkLBx1jSEdd2`E$;*$olLXQ2k7VO)8P zFu>4ZdW{$mfPvb`U1d#HEM+k&Nh^+Dk8~s%*FKe)&%#28F93O22qF;NDM?bOdbTF0 zSrElKnTAkz;;65nnXE1h$BpZ4yljF}GJIjEAR%rMR8{Z6H60;fsd+#*q>ZF!Ih`^!Swo z^oGik>WcjpC3|rMD9X>y+nvtduwy&V4KZ6{LhlqfH^gjC#5+Z@_J(x!hJ6JUB}G-` z`)dxA@Z8|*!5>>N2$X0f+7)nLyxt|Y{7yBzyJ38;QIz2b@oy9n$|n|tfP-< zcif3rpIra8h7AUv(O_`nG+5KRtQeV`Cz+5m>35Ca0+!cITwYM7@;{mRAup(< z;zYnA3rR$W{2fc!8+&C~ID)}pEQ z8+dLgK8W^EE$u;rOW1;(Olb^TasTb-AG>wycHMQ?O`A6DmtTI_ylL|dcU|AOW8)Ls zoqT++6HmMC^ai&#Za9REp}~;G$Mrkmv?ixM`^>Ww#*aIsUB_VY=E6kf6-F~Q4b61V zg$UT{4*7;0ojYiIm%tLr!}V}ceXSvRv>77p$O&8IjMb4htgaOe%l$&E)>(K#f zQtlpxC4zEeP`c|V@A62Eyc;rvx73uquR|soOt-gGy?TX_og4tF3-6MGUo&2B5j7)A zlkT`YS`f||1YRMHngv6GDLBgC!}3utR|2HtYt6Q3CG zYQrS><|4KCf;_TR?$TVv*d_;Z*`Wi0z7|i}F|?62CB}gxBC2D6;Ot8UQ{&2d2^K{- zmJwEZfv*|=7e{5{4J?r0KEFwoGmNyIKV$9u8P*2r3ViDwZ zYLvDZ_;RV4e`LUb=6Z9m!J>u6KqL!i;4OnuKcvVGRrcEpKaGe{jPFcQp>KyBi-f z;P{5;HN>wwOnU0cBW!D}*#W;I0zo*i9)6z99WM0p4J>5iXFvot1HE*O>!`#cX4t0o zl9${=tSp>EP$sf!NW-82q6UfvcZU$9-~x%SIr>ZwX;=0jf)I>`OW|;A^e{`+Ym`8C z$X;(W1dXy7Xgc(Yv_B{{_r6jS7AmBXxo}=IP{3Mj!;dgf`@l;8J#0wt`GA{e>$4Nu zHgT$~bq9a%WjTgIQ-k{R&MbJjQAO4?arXiY?9sb~Q~M9Hx_fTMB+?j4nhC5C3&rJV zFhsM!*x^_dTJqd*pnRY7hWw&D_68gZJ?dgCcQTbZXMJjI^Y@-DySn zStWb(D~b!N%Jx=Q?&rBdAayO|Wv8Ph;8&<{U$%4+esSU6d+&X2%G8%$nEKl5uW#D4 z>GxlMzu}2NSAQ_H`QUTw4{g}s-o_2?ao4@<4QE_*2HrlLyl_rSE77+#vAy85W+J_Dh1T2!$1=6NNI=kBHONG~G^j)| z7tKZPny;h~R9>JIO-mt|j*c`GGdUC6wqxr8fb!&g3M{yfVoROgQ6)nt(eS? z%$kx{Sjav{rVl_VvdOO65}IpUymZ!BSf_FMk|9TJMhsjZgN5e_h@}LT3DW2;w5B6` zWNI`tCrj%rX-cgmIv!nI!FN<`&FBhIU&qkq3xVXaITE&jLSv|@z&pj>ijqRS9_-1_ z;<+J>y&+*+^bvZ)#>8zgsY%;llDj)?PhJ+@8p=!98*1bu2dOTnsOCU1Fz`DPNeTGt zXg6Gc-F1To-TdUFXJNXs)WU18!f-o0+b$4hwx0j9hqV&3*9+N&cU9*P~f7Yyvrq2Nn2tWNLUWrtC_10T`;OO z5kYadU!_FMU1`vUYuF4Zge#_rKqCgmR*fYWXb@UM*gb%f`UIu0yZ{AD&&tYTXqK$x z?vRDj!OCL%km5ku-tyu-rF(I1$ikM-OiM~h+9thWW6b7t{+$BnhG_JL=#-?m%w37O zyLaN;0H^ZeLI42fAdU`Np{kO~l0tc#h(UXp^z@TgUw!ps<0nj-FyZ@$FaG4o8{T;L zqqw-ZH9!1t!{nQ8oPX!pLz~yXw_$_(8{35@F}(571CMRirP+)bGhTfDInB&ctSXjA z+=~xY;R8@UN@l*Ck(F~*Q8Q;OpPbT>f>RofE(gI3%wS^|gF4xSTABzikMG>gSM=tn zvJ1hyoD5?;GPSTf>?2(KXl-KR#kIq7X5hbW&0v8vT_)ZpM z<4=3&gLHglf+ZR7A%ZuEK&Ta+vla^H5iCuxmF?p6mXSOL*%3q*Pms7_8VBgzkY^jX zJE~0F;aH(Gu5rd{5i(jjpNJDeXM&n2?EpJ#)Sr#zE$(r;TIX(t1W;TPy&DF;mH1EirD()6YWdTte-2FvMXB-hx^jI)z>CGT0tk7`8 z4p!jYun*t%vBA+B_T*(^%V(q|rY3DmjEllCLCy`*8#+NmZ$QgHZ-7Z&*3P25jFP>% z<@*b&%8CF}Q@P(#uiTF#1sX$Ae9XUoTs?5$fN>L_o_hbSUk*9?m(eH889V6xPZlL6 zCVunn*EdfeeCwk7&bhaF;|H3Y@o>{754r2%vyQ#-`1AW+@bW7!&wS}cS4GQ4Q`c%8 zJb=$RqyQ+M){ol)mB!uk5sfJ6>&(J9v=_Z8!^Sd14&IRh;|iJ)U{H4jAc~`uWE4Xd zNI=v@aEKX1QE(qr9@ViHRX#dnLsl9ZR5`1GOi+lVOF<|(COH2wFT)Ihi_%7wu!V+A zqze!nB?-YtHy19EFjb;?y$?-|W2pE7OJsTUE=nck8{Xo~N6$KI>^Z^pShEvuIq{NfFP=4P*4)`IyV?u>fnt36 z3BKG(njDwBTnOzdq4{xfnMSvr(nD3C*E{uaCv)C)+QrLkWQCfsE+{6*=&Y{FQf7Tr zOR26i@JmAk!V2?%zl6{^k-M8KWu+4<^lXyJlQz5pCO(|$m7B}Lt*Ib27EQ=77r%ZT zvXs>2rBPTS)CUpeZbD!qE;7ne@Y0gH+A;+}&^o|C>JU_nzG^INnHnCg)U1pvh#`xC z=!q;5C9c#;CseDXA(*UyXugcDmcobNnw<$oo}7JLi%3?IKEny;2$BpcAU4FL%wC6_ z-qI8hM$t=nifq-eg40(oSYk+`7&q~?dQw(2!({qKi9^16q7)l9sud7@P36Ao^1bK{ z6~*}_(i^bld2UGDiY9OhyN50v z)nZi3a~^NrY(mTCdW~<{{E3z)-*$4xo7>NxHT%ui=8!(8f>%*qW^zI-4kd_gHITyF zGFO=e;N(ax#aG>BlsFhtjml3%h$bnMbEsBoW;J0_;ZY{2 zLz*DMaaAf|HP&$AMdTp5%ueta8Um&;5lm;M$r8uaR(yk4e8iC0OCW-Xu?D3jE{C9b zslCpZaZ}&J=F3I}fy6X%8oQtd?hE5Srr_+vkqf6cQde!}Sz|m75xohc) z&(qSeu}(I z!Qpch@*$~!7=u#C!1U0VI~^S*1Mz5P6Tz8| zIVKv~sCv%o?jLC^^${;W1wkxtDFT_`lF%j#U?6J>j+?Pk@WR|(g}LdDEnFDI-@O1| zScc6YM{2Z;@Fj@9@I40?2y9yS8s%;-c(M&n- z-ckf(qKUhq2zm&OKw1Iv1g6mNwG!Gk(HK=r2gPK6T>WKoLX4##6QMj|P&~vE?&&CZr_B;tx#5MXkr~3wpy}zBj-mH#3F3VNY)PzC65BRF~u9$h{Jl zEOw{kuXI9hh{8vSov-R~#c4;+ZeMq9*Sc@@Joec~hkyR%*Xg^`=YRUi?H>#qx^%?( zV=p-WxeG6Nt_`jW^_tqI(OnJu-PL2x>^bv4dJlm63wQ5K+A5gQN!xHDiF)((Ieq)| z>DIOD2k*TlnQ0+$d?A6*rH>({oo_-m;^J!@@(tM#GXxS25k!Q6UWYq+UlnSbA-ZJ| z(4(cW($LO@;hb!gXcu~vH9l~pQ#`LMnK3xDuY!UpC-A(I$g$%***$){*cpQA|pniRO zzxVcQFqk-D9H8)s3oZx*!M1w^^3vfX zy#eP2=?xATKgf`C!2SexI zfBVwm7maUo@r!LQnbyu-m$rTB(lhUEa{c{Rqc<%4WL|Do3eF1B81NTJME&{enn(Zf z5dLUJ@7}$~jvYH>@Q|-QTdD~KcgIAFt(7)eQa4M^z+TFx6j`R%TvRU;B{tIkJVM~; z5oC2JLWG$jYx@k@1iRlMXsmF=Fb75Uqe{T;j$6gPL)NDy5Zzr~-rZw{1;z2;wT#1~ zen^dhZ-Qh&OlS^MDgsAC$%d6)U$Jk^sxPs+y(Jbnwwl*qrR%Ig;7S)v7{ClN%y3~t zEMGF8mgGh<+`bjuWVVkh_F}iG(r+?&0SD0`U~h>p4rsc(Ek1VZQ1ZULo+|z<>I4ika1Y)3ZP0ZhyqA78KSQwV&Otr(AdDum|kkH zzK)C`gdd$H6S0UmI=a+UAh?zSLsCEiHzxadI;39QozkOuN&>5njI}o}10QkYI|fdi zxEJQ8?Jw9}T~;KH%7k%UYSds+bLFbCaxYdi_Jn8%D7%*SP%d499nV<(`u5`X#ld3L zm$K^ju37yhHu~t1_i3wu8B)VuM0?N_*hOSV>Lyb@@I}J_2ms|YOl~lnIN>qJkl~<_ zO=h!$N1y>2O1XLg69VyNf&>a(B#p7ObUJa&k({Mx5E&rCka{*eX?`GsRsl!cp;Sz` z01#=C3D7F{T6Ti(%=ThbDnkR{g8(p-<72Fhx){VISi0pnH|#l3T7Yl zZ%B+q6WCg-H{jf$y&)z&6`wcY+_0-;Pj>k}^oD}!GW@6lQ_bKtb;*z#)!8PgW ziEZ0==yhV9$t~(lZgtdiZBKk=;)FFn{j@uC_nV)*dFRp*cYijj!}FJ2{%U7j9bfIj zYi^g0uXkxa{G6c=-#Y7++3&tJH)%VeHmv;_zXyfCQ?ggDUgO7)|7p#?=6&+sh5at9 zdw$)n*K{3n+ifZFF*R7}lA_drWl&072vRvbnt@PN1Gg1~Jc}2y;cC)~iVy)#OXe%e z0JgS`aBxb-qL=XDz7!B@M5$(>xzZ54M_z}AGfkMkV-DZ&s6sF1l@3KU`B&`@ND zK*8$6<{BayDHrCX>3Rs=qmmP%@mi`-c4rR`Ky1CUPo!a)C&xz*zV&9EN7*R9z)Lo0 zFDkjE9^*!=*b7VUGZC=-k;SI9zrc6&i2G3gjq84q4VQ*lSh{3B^e_M*zkf4#ZhBlA z)GwiBOXkCd296=@9S%98F+3>*9L`>F_+izT-d@1z4ocX~VJHwlIBZ!khXD|jHf#_S z+Zts-b{-j{XbBiaMnB+Fg!pJ^@CY14RGx70W>y(xUg?Nc@YungAzAxOl`wWOHZ`_( z+5TJ{0jxKq#^VJ?dc(SibHkrotv5txq{idVUc)@-4LmonH=sjQl@+EY#$XjBY~A$4 zgz;@IY1jL>Iup;X_r%#pO}yxo=O#V%%WuDBXYQW+@!UICjJR|8@J=(kbbaf}u5Vu1 zO|Q4E>h{i+Ek`!LXUrY5Uzz>!`|kj1)mNY0d+$B{`}ZF(V8Cmyy|#JdmKm>4Z_x3S zJYmY=kA5;a2D8_DaMf!R^9+P|=xJL0B53XMJ=qU*YBt>@@-6JT7z5{wdeGG^8 z_FfqlAp1uT;$6Iku(%3yc4}9c_s;7hhTrF}S7*)m_RHl(dFe{n6~u64jWZCIHZ}o9 zRfBDW4UKIL&3kXp#SXw7vh08HNyFI$U-?P=o=EKL|i{9|zdvCq*>a1IDz4e-F zuDR*vn-oW1g-{jSK1t+rD#I0jfC~|?9(Q#fQH81 zvVdT{A#Tf@Su^mb?rMGY>(_VT$MeE`6dB7FJ4V+s1VqGk!DB(rPHYJ62P$X-z&2$M zC@*^NEqoHt9_~M^`U26{tomZqi2G!7vvXkgJUQVpD4!hv70~f@F4Tc~i9q7RU^k9i0C=nC} zz}NJlfsO0}g6oCefFEFDYnScIDcQ4oPfi-PJPrjZ3DF6$o3=)+jo$c2&>Mc=x@9fY zDe=+isoQaGz^SHWPZnGc6tgz~Os*o}C8IZN+Z?xL{louw`26$FzwU%Ok2S70reU42 z_@k9CJimU!#_Y`Om)?KrzEuwoT{`Tlw|eyWuvd?ddiV6#{66Q7Zt=jx;jhkq_10Sk zX=A{@Rq^ARAHVy4^|kl)Z`9+I^B-#6{q0_TKI-4+Eu)83@RTE?kVUX%E^kIOpppj83qlRO^wkL)%aUa*e}(ORjj7ad>Z{&lJ z8KQ&p535#U^Qooz!m*-g>5`Abdbn6IrJf?Y8F!^%skN$BTU`u$K)|3}`pN`%q=`{9 zA!AEoRO(#~$kscG92BPvy`d0W8ymd1Fbll_TRtNN=Z2_+tsB`JHla6kZTLx zjBQ-+AE(!OroH?Lj`^g=8eb~3}{QiAD>E9REf~(uV(BZ@` z^}1c(`Nr#S{OP-|uug;7VA8fuQDCVDH7bNErxT(>n0ygf&cH=ssj>A)8&z^mnI0OQ z0dmkNuwm78J(|oRDAkKYwzNel3)y*T6fw~0HAk)&hd{!boxo}?1SdU)#;Do{8V(6V zSt&GglpxTUqgny0gO$bdB4HyCib5I^4nw>k7v|tsZKXHNoQ{9G3}3i+2{mso37t(-W1EQXdY{&>`gVL~`aim@~_Bko+b=s^{eqPZI@ z&C%VJtrltzf+7}jr67|LhueH7Y z{ARbF)%lgKeHQiayYT8h3;Xw3z^gBWMg1?FaKUMvj~g(!|Bzd6!>L8d=sLCOwF>Df zu!7Z;lQs=xmuMALV+i6E#tG2eN~D*QAsC>-Mg|RI9;~p?-ab4U$O5R38d^!}oq8?` zNk=Umlfd9e9GEY!LYk>#h%jKGSA_80!U>>KQcJr_XtlRd(Nyfu#Ztj;m^E|SW&h!; zY15{u3DJUMWx-i@@U1tYulNv8jvtF%i@oJF8b$X?MBH-8%kezOSvC#K^zs@7@tDBJ zX@L9HxpT;s$Rb*Chza}ABZh%3`j&S=L^Lp-Kb)@);f^B(vak!EI^ftZJJ=I|jk{P1 zn_MB|L6nAu*!0)WlAzBkm^k8)d9c!a6h+{po3#k=vcjrT^oBfa@Z!QuZ1x=VhLmkQ zH^gq-y5+B!jpz;T+<SRu>IBzuTPd+DLjY?#FA9UVZy4>f3#OuXFA@ z^Q@~*A9Tk}k3RI!{=y8+RSH9HysUvq$;(he&Mi(n%3O{z=b!+;Uh;jZ`A04Ms*%mihGilO9+%{-(vZ z^;*)W&$9k~mg4HyduhKu%lh?P+UL9nTRic?xRf0!si~<6+Y%n0^gy=>-ENzIXP*!I z^<2`s=i=VD_gL7g`zJknEa=^1Q7>H3bpEjG8MmB%LBHmM?;QO6bCYzcm6a@QVaO$5 zmsZ_|w71Ee1O|BIg>@9^CB|;M=(_L=!GSxMV5(K)@77J}7@B`W^Bh3HcuIL`42=g- zUpzXctrU5rnd(JgF1Fr-h!)x#I2X}#Coy7qp{$Y2{rTwy*(sQMEJ>UL3U@}`;2n$Uq&JFpM`*X{SvXKG~0@(7{ z_!dEbZ; ztxi8}Y}2EjXjbpBhIJn8)^^@UAMMSEImfYOq)80Lo_wTv9A1^e9 z<^8T)+Uwj0noXWLF%^FW)s7wU+u|oo8#n0vA@{C+u>1QxuKKjcRZDtYxv+cpc|Ci- z-4{RbykgN+S1i5?_ijtBYWsS-MpvJF#Z8@t47r`3ep^w&P3ZB_WC*NNx#?}*tXc)C zmlXk7=7E;(f(%Q0lS0-6p_%92fj71GE zA6ElWX|W0lb|-senFR#eh%MzT!wgASV3{3CVT73oDkGVe7h;#>>`HW);7mZdjDJWD zMt3E}f(cfIu0#Q3IHAYfZ@S_7OYqh9lD4=+!atLY-oRWW>xz9jIq8YX{NO4aPJ?P7 zAC5{`X6=kGF34b}%3r3#%|b!NzU=H>3CZ|f8CISgoS^t#6X@}dQ;?l3JDaRHn*z>d z;OCl2rKBcCM`HRAMt;|hSX9y+WwLzbIo)Li#f2F-v4>bG4Z8y$lc+sL>!Wv_CMD)p zge-w-@u%w=TEzJ`lM^OcdxwhvpYww8QXJiugl); z)Nx^#j*GhD>ae8qxi6g8wD0LR-aYV++lPX-vZ{UO4wGVVW@L-#=Cix30+}>%q@~ne zcMR`tZbc)Bv$VQ=cn|3XAIsLwQg|_L#ELLu+ZMJjf$t-#Al*V?wHt*)U{?7U*&B3) zZiG^ZMc8}rV7(jXfP5i4jc04Z>aSKT|MZhjK6o4N&G@MrekWfA-ly}&?QhPVwc^uH zmVY`Qd#kKyx2(8Y^ftl~|58c#3!gX4p7{dnTwYL=i=S&CobguI{c5&S) z7uI|FoH`S(={kSOKeKmdrzWM2`(*s+&ExQyL8qnNJAc-v^NQZQmiO+oqF0BdSF{*) z){Hk^Oi#l<+?$#dpEU86Cx$G(=k`_iwSTum`wu#Fd#^{I*9TrbZ_s_~CJbBsVEdUJ z+P;5jyG56`UDUDNqK+3W?r_$Gvs?5zW61E^h7TK-fe8unwgy&H<^|L>-xtXX;u5wA zm%p~&c|p%1_ZW7;xdFXl1Fq#uKECjO{$sn#N_j|ICikA%_-w8uX3P%X^=^YQxY2EOyg94r-$TS!a-{%3mm zwf6CEKYcs)kq7YujsG*28o&~Nq6l6t(<1^t^uGfFwpY&{Z@)3yXCcU(k$w5Qe0?-2 zSpIjOH{W!_FKfQ`2oP{k4}*O1<%ZGY*Ijk<+U_^6#ob-&t{Su!*P#2?z5C(%Jvr&M zrc4&z5f({#5kCB5!6#2!Z&1LwdF^@aC;sb)AB4scR}_9LAs;Q4=LYnKf(+!Ilb(>l z-mn?HLCy_9Z&?59)=hsT#G*HBPEU@7A-<_dZ^)|LpIudwTg}%Bu*=7guBqk!TsUax zomZTG^qkAMm)pDC zx?tF2i7(!=bm;jrFSy{Ni!WT%;ev%7E?Cr|`NtPE9^Sa^fY$eqx^MhrW6FxMbk_!R zqNg0b2a&V8l@H-#1zVHu(UN_+C z2pZPC4v*ys0M;{cBzn@I9e_6 z|NhvsNB7NZe@1rFZ@5$s2UL1h#fa;V3maa4b>@FZ{x72sjvi5%g>!f~k^f(SmtEFj z^EzZ9Yk>Fsw4|7%tyZEj|9IfPkf}BF@%wLauJP#tKAhW%f)FHXwqS8=XI|; zyHmaCm(+P`aQ|grd{t0TkQkr%=;Fsl#f<5=s7ssWT`vB-dz;U$YV+BZ7p=Gg_w$xq z)_hdcH$Iq~m9aZ5ZC7$q%F}Zu-tpP}Lss2~pHp1&NZXcu&v{_n$YuXrHtP8Y?)(0+ z$CIY_{qUORvs$$L^hkfDGd+QCPq~Rd= z9UK|DjBQ;xdqIs0cxYpk>CZn?D@fzUjiom@OimUZ% zm&Z;WFT*zz(v!_}IHuAo%1spm#(jPEOaBY5dEqq zSg-Os?|oxTbSh=yWck_J&{5fs8@~VUuP_2IpL=!&7ms?m*%uAhZFOm`^oH!xqAWBp zZ1$X82{;tUxnV6@L8v!Gt^XzH4Lf3UcEw|=_vh~_-6Q7)>^#2YVNvI$C&#ciY+XP9 zqj~)YTtB#ZokauczSX_%oK8ngzUPL|zxuYQsAzlK_D7bEy+7*Vix;*(@3YS5eSQV5 zb3f~P-iofcpR>4Kvr$dooBvkM?i_qLu`@aKnb)2ky!ehA7Y=SUv_;2(m%jVn+o>r# z@dviP{pQE@^YxYv(i>c>0aQ296j$ zV#)k@vRP%zvLx8PT0+v6Vvsz`X}eP_xy5Y{=}w}h?R$D@$`QzJX9EqE#1#ADf?c{u zmoECSRrsqVAMi=swFCNVXyN0cyAZ<7A{rAzCI@pY&2ujT>!(efEWp6F|2AsW=#`gn zZct-s367gJ7#76x&EADKU~JI!Th{&Du3g(!En5PHK<-Y`_;N7V=z2RW=%1cv) z9${acIyu6*Wh>B|_0rV5%p`2M#JCL>H-zvXfE|ou;{Hp|re`*tJ8Qahxb<7s{)>t5 z%bOsp;LFMGzrlz|PJPdvLpblH`B?c#1XMxzn*M!jnfpih=@p90!5gj{fNE!?Y)zB~ z{Q2j9bsYF}$AQ0e93c0BznsXxCxj4L1$H{)YQH_j>ZOe&2S&C=Gsw&}qOg zZ@jVCtxsJr{H9?`g_Fw()qb29x4!3~UnB(GJM{k+uo$(e*G0~?!R1Yml01Ant=yMg zx+k+Ze^+7l4s7}K9kI!Hr-)g*b<^+B8-8);2K0v5O~1#-tWDXziSHEb4Li^q%JyX9 z?{cXs#zzkL#>{ib&IJ5niuK6&{dsTq>D_&&K2(Hqp*`|3Wn$HTzAUb9eRe%K>XUYznYq6j#) zC4x0?*q|XcpCqU~fQkEjt>HOMMslpOo%_mk`U{fY_#`S3IKp8@3Q5$+7mekAEt+54 z<|3?9g?(YlBw#3vxHWIkpaGhP#)Zw?S<@6wy|q$!?>P0;Q%^YIgyTbBC!Kg={rab& zfJVX7lE{N@x*i1q;H$4p2cY{RC3k6jjSx8VS;))X`898jSl9xn8zxkdaktc^5J+2- z#^K=1Gn=C8Qw;!(=;EAydi~_>n|z%oJo{UR{y$yT|Hlq;HET2OZqp$Wfw#|~Hj)at?;{Op?`i(DgO zJ0B>{so1w08ypB|>e3rxkUM$)w9r_1;(Xc%nm{)%Vm}a^q1STyyj@58eIUnx9IFOYrYn zjrnriecK;8d;YmiS9WarMdzkpbZWY?)0tm%JoC#=r+?a}`GaRIUOqoRH-Go;-RZkB zo|y4?r`y^+JMEc-?FrfVSrq=>D17b8$VkuJk+|c(-g4}84H4e5CJDAS}K~t(pRG7p;o8~u756k|D0x6HxXZ0^#iZzXTFYr3vJPb zOlU*%XG2DhmJ+=n6TJaZ)<6H;QxO5qIp_4#Pk-g5DG1@bSb>ntM^cpp(-NZ+h3$i* zh7%`}Fxb{V?X;6lI_bF37q;sur<{TZDhrFFQ8+ zy3;BDY}4|=bC!MaX+eG=dIOFQi~hOrn^oW72ORjqBY)D7vUB=d&%gH3oUDv2yrE2d z`RRL>KlsG1nf<@GzW$sBr!Q*RV0pU+%i1nFVcmNQc)Gu*ezahEXhT!Fh!`$r}O9Gdr7S?ylwaD zaiy#^Y#p``%CYMcWBEvpv|H%Y5~H!8@-hMtwjm zV+TI3T=(8vvui;K&Q#17=Qno!9i!J=+;f$`PCKL5kKcXA+RD^$f=clhHg3fddh_j{ zycvYno!_4|^Hp6W0ws$_8n7-WL|0+O^54UbXJ7Q>jA^d`uxw9;O`?XASXIS2Rr}c+ z$_mjN(okExW@6)~Y}+XB6u(8U``NuyK#bk^YkbUK7{s|DI}N=dX@CAs^akv<1I6qO z)g?In$^=;>qm$fUT~S!D2h9NO0r$MzJhX(YtgQUJ ze0-Go`HVs#HXt=UH zt`iotZg@w-fp_;AGiL0^^WNn8k^)%mWo7B+Ry`8oqn{ZOs!Ma|$O~OC2bLmp(o_ip zQL+xs9U8MltvE%o>+s13j+*W|69ONao_WKy*Qf!u4h1e5US5V^OF;CHQ{y-9%S|C4 zBbLjxCT3Hfc@of!qhC#%o_5-)uS`d8K<;En7YayI(vf_XHbw!i;d=GxP5|QI?VUXF zZS{^Jw@5^0$Hl7^5VY*HZE#%j$$RGHC;;HpQ%`$s_B4eBJ!~MsQ`n}b3O$ZW$~}8r zC54fwWN_xO#~%C5=S$FHu~bn^xl~SrQuS}n#mCN*^m=*PbI5n%_(%Ws-RHo({@QDZ z!f5i<^h`9H0ay3cd1Mwgvz$#VmN<2RX+o;|NpBLQoQPWkfmDLhR|%D0dF{=%!i_E&?m2c>L}mO0`C zalT4(^Rp7wxZ~B|cuNS~t{TEg*V19)bnc{#T1;xB>4v=^PkP}e=S8RnoYKPd9em$ihnM?lGiF?W$;DsX*(i2$t3MuT`1Obe&rBS@cKwC}l?Q(Q{a<5$ z9X~kk?o&Q((crr)c&*0Ojo0^AoV23t`TuD3&G%pJDP(WRkuMbr@(O{RSI4GJ5dyaQ>B69DwyKn2|O;x={NRL%0Ul0eezw-QhT zSy3A`LbF-6_(Lm&Rv@%0G^0rq$02U`3$IQC`u72{HhaWE{oSk>S^NegLXwiZhm*Kc~$#=rgr{lMG5A%fum?F*PG;CYY2k^EA-=!wn0f3($elP7MDims`u`R?b{ zWB(dIIR5TaSF~>UV~>Vw^y=R5haL@o?0NF%?b|%s`iGxZ?=9MgUxvU}PHs+KUS46| zo|UUs^cvZ<*{~)J-)w!_cb!i9wqyMuBgAd^GS2gJ@@*v9vVOT9}hi@T&hbzI6Go#$PCm#&yQ9)s&k@( zE*7Wc5G?~6eWatav?&#kY~LFee)JB$XYlJ3{7=8^zy1*dW&a#lsY>pl(ROVwUcTg` zn&RyIOnhrui?ufC$#I4)FtEj5`D6|*h?0b5?D9DVfB-d$63 zcP0)3TmUiahTU_A_f-J|rcAcp;OY4qklwWC;H&&YzCO=W7Jc*%s;8HiAuRgnZTI-L zGkE*UaztOzP0g>HNYfbP&P_P1f9$m#3h9+f>n_mw_(k<%h!Cf;)idS|M2Y! zG(}vS{`djLSp33v9YQO%Cwk&ZCtcI8H;@HWN?M!)4I&<0k2k$T<16;hPk(ILX@$R< zwSWJWnXf4~z2m#ChQs~EnQOcygj1W`xbUNo6Jyst`P}zm{r@MqVT%Voc=y8~V)1T# z!^hUfH-9W$=?!t%_$llSe`5PcZ@66k{sxG#8-9g4Ic`194LNCXs4JZQA8p?OpjDBq zJILzZ-PL>DbxoKTBe*Imm;n(K1w=(bauSf7gXElZ&KZWx5N3wSIp>^n&N;%&d0$oa zIscg%+;{K3cYoWaPj}TJ_mMhQA;!2cfs80twiAae#7b|Y6U>yirgBy%#@681r#)-U@GAOQ593!3IvA_ zJn#SrEDMOtr@X@6%Pq*DeQ$i2?}9n^QDE6`^Wwtbg!_-KU%doLh2!Twa@%V1-|2zX z^JYzn5A$hD3`1H@uFB;`0La9V$JG2%`j;sN4NYj650KkVD0U>hd-YIUD$`I5sP7yO zA@U(N;PAvqS~A_fy!>1jYom02cT_=UESI>v^ymc8usHZ<_{19q85)l~(eKo;qZr+` z)4|;TKWabu+WJi!wo^!R#Nt9^eR)=GX$HRh5g1tPIjNE9@ga#(emHqRDzM}R>>HfJ z{ay9k5W=}3wmd(Xb3;Z0ZdK4}MNUa>LR^@4T)4NVv+atNt0#7PE_>_8B?o(DZF$dq z*+;8ZE{}?iX};Th<<8}4L9@ON{q9lQcOLib^SEd4$33{9;nnBiTV3Co)ydPxJvu77 zqN1X)v9YA2^x&!eA5VVg^Yx#8cD2XjXPk zQE5^_;%{3QkGej2LH6dp&I2Al_3V?j-JWv#{As72Pq}>l=#%}4EuP&q6M4R zt!hL*Q`0VUE)z%zKm`boayUp<;2NF0IEc4ZQOQH5-872aP>_T;!UP^aw5$F9&IiFB z=mev#&VqnVo=G7T)_R zux!y>al(B^*RNWFFLs&o?#k7ANRTY#36jWBM~5o>$Z26dOIO)E{>F*NJDqsqjT29FI`OxT z8?4Wq7H^>D>7Yrmx#j|b$2*;T;*FC;|Hg@j9)9Qc^=pX{zBbpKpXfxLAb9NM4S#(2 zornJX`hzHcdHtckP~+hzhX9{Mu#`t%Scpy<0>PhO|LW^uq#i4bulo8jvvr2%S$UF!y{*Go&Ag3oOxO6Kf3kl6V@+v zaO&Q{z0WglUv}{L@~_uEd~*0x-;M7(ciy~{NA~J*jaka(9FPt7+~qwG)y4#>DWy@K zQli%Uo%PKnd66cTK%tmMh+WHaTMk~cjn}_Lgvq!YO*N1AR|Up za=d-{_`#i24(+tLbjtpQHQE85_JC>&f*x@i`$ySs_$nhllyUbu=A6f_ZmHY2?LX&@K2+a-`X;7V)77b0}Ig&{w%2?hoO{XM!qz$&k2fk{n*cUxN zQxQT-jkeUps{#Xu2qY;qif`zI2;V?Y*A8zUdgR6Z59{TF9`lo90(S4YuxQ!!Ma!v7 zopYtbKbhtwMfT?oi`xIktA!bHRYiEcyYJJTc7t6&KJK#}KjLAXNg|R5tXRM4=EE-@ z;IjYW=Qa!;JVA`2;8#IT39O+ai*iFrIusTRbeUs>dWY~0#+K~=45ZPZ1J)Uy`E{lGFZFv^WD?m_-z@ucHMeB1FhZF zPTHQB9Y3!}_&1Nab$>E&;8TGEo(lN(X%znfPX`Ws)Zw!a=XD8>2)%gW;>L{|lai8< z9&iQo+=a74w+)?i6xsJ$duZ4qknq@#+7JU;n>(_IYgSKL$?e9T6E(SzhVr z>^O4c*r{PlW~MKD`}*5YU+?^^$5+pK^?%N*UkBfB{&ue0bKgHTZsv%&v*)@yTvv0b z*18Jz|L>ia+;G28Y8zbtUe629KTEOvJ4@3NuxxBbe8|5bM#y9IzG`5W@9UqM;&cK0 zJq0*7{H}V)4Ok+Aa9_FqUMJ^<|A8S0=HzI9QN!`pB}$oGE}lJttcl|9VF&a7^@O%^ z^?luC?v#ZyfANKfI_$KRr#G!xwHZF?_v1lJXG?+y{`79|K0^cwi}A{Z3x9uQn?d~L zfDML}%)~Gl!(m>E-^pGdi(IISL+9Lgv+JGuEf9MeU<6oV6e!8%0RCL6piA)vrNyOZFPsR4fXDW|^X3mP&tE!s z-t5`=>Cuf9S&hhTI4zzIsd&{yy!7DY^lTw3zVWf;QDDwBOfsMmeJ zX8ygXzb_XeH!c)k+rPFQ#WQ_uU{+OON@hZ+gg@&05+6UXGcMGtEeLw-ZO-d%vG}Ak zCq6Yc0BD$fFn;s_{*Y?xkID_dqaJbtrK?b{-;)c1b*p|e6&x;Jw{kIVRKf)0fajj= z&|0LG75Za;C&}5{Sc^mSxy!05NF^&^0#aiAxZeh~cO?{gmb z^GAPsqDw+#AYpQp7H7p>xnOMunK<|)l_IWAr z$CrYB{73Ll&jf$}#Hvmo|MbqHWeYd1U0Gd}3gzJ*@(`tgOcbO}+6?K%($?p}m=JF8 z&PgXG1j3;rjL4(pnK1mxKAUB2KEL3_n*Y5IUdjCP&p)>TP#ryb^f-Uw0Cs&>FPy$F z&B49fWr9$HOxpYQ>}*B+;fEidJ9z-3t@`C~?aHMHZHpdTe)~sIL3IT5wPKgOHX2)z6YQQC;gcR0n4KJkG*nKxA-T3VwZ1gHp)3PNBUs`>J>eDn zwVC-dre2)WMT=gp`Onw9r@9}Uv~~OL;^LC#hUUHYyXWOD=n~xLnXn(8j~n%T?8p~l zP)49e`w6!`UoG#Em=J%#`oiA5drzD=f%I_u_HA5sKzc|^PFuKR(HQ4R^YT}H89)4m z;O}3G9Pv`*@Q#rqo{Jgw)QOK?AM)&(YbR@~>N3+Z7j0iM`qq>s1>1fI9rBXxI~@ZC zz8pRr<&~)6&-s7<)Uq0&Ep3E`Ut~5@a#Ny5j_4nMjd;h-O z2T;zOIF%9;LTg$APelj^NqH7X2Dx>^y}mR9;IQ=i?NnoE@^8VwWE_fNE|g%f zoUy2}w6VbP;&?1}Ecvv!KrDZ35ReK&d>r)L5bWa+X5@z0z#PsEWx4TSttn2eE5#)T z+^xt+jqztUd)~NqdCrvaH`aF7Qa5Yi%e9dCjz?x}-?^{69Df`9-cE<@^NSa~8{Y5v zsGna<824hrSSc@|kvR5A_rCpC_fAeuI&=EWx^?T;tXYG1(BqpGNusK%8jJqWg?$5e z_U-38qI1NsjxnQNjv4cE?3h<#$GjRl_W9@$9X7qyYeF}_Am7^R+OW{DDO;vb^qRXM ze|>MiuU>Ka%EMir5@3^l@LX4FSOb>_a0^4>yLGwM^Hz1G_ z!o6YOsbhx>DMkb0+#PLzU@kCL4%_ZU#E>9Qd(hwofd)?72KEPLL)sD;J;-p|Hm-t1 zqvzjfw3==`oH82AGV)Txy7HI~@=0idnktPj_K;(uJx{};x}k< zD{dc|vup3+>gwvo+Qx0pTjrK6d^h^Lml8&IO!>8A%EXQ-lU}AWv18h#4j%n}*!Xou zdiwV5JNozU|Ji4s;l1Ube){RYJ^K<95?35r^y$2}-Z|F&rO+WSCyakRapLQV6JAgF z1@#*V6W&Og_+r$^XMcNj(5$}k3GuZxwcg%daUq^@As*JJkF~|&+%O+g zaJ5ZtfQYvA_wB(s%cq}wl$#n3h1=rXm*xN33Cy?t`DT6^5}OB>e%p1-xnVsFEJ%w4 z!Hvsje-9HG2n!tu$bYDzAre^I%|F<`|NeUzQjku7x2~Q4J;48dza*QRmrwnF$PI%B z@wBRFkw8MsAOjYDpzDN3#{No(L8NJ6+5O@6T3#S0f^ zPW;L1%#T{xQ7wIkmb&rk!TARcpQx*=Yp8D6>b_}C`NDT&e|$N0;;Wg{U(1|EC4vV{`TkX19P&nH>}@)zfaM#XU`u8{doJPZB$I;uUkfSn)&=I7kYGzANxl7)J|zr zJEctRoI0g*3JMxi-%Op_DRbICJO{rp?wMJeel032!UI&-Z`q7KIAKoO+8H^Ey7_$m zX4v4j5+}cvH0AB&smLYIE_i+Y&J{biZplszF3OClE=X=D$0?E&@)kQRqq-m|J2^Bd z(l;%}za%@BXecYBqX-Sv)Ts{H(|lMCnhf{~p23=SwZFEc&1c-Wag-YXh56wr5}{lZ zJIkUPxq-58h{qM{lWky@eDlpWtCr4(pthrU_0W#3o7%Fp?Lj79ICmO^W+#UFINxkb z@IURDKYu>n7mLTS^3x(>L)`DH9yG^agJMsnLoT+gt5&Z3p9(V5i%?v+gwqJn+rd2g z@3p&k@BU%8_u+g@!M}$fT>5l#{K$0cOB3;fMTsywbj)w*PR(3aZ4EEVh^22Q4mnH^ z1%@gdB-F#Bf>xf9nGm#Rzk>m?d`J21YnP$__M=rs=Qo27h4^_$ZZMFsoa;(cYl>5< z@{@3SfZZyBKRq@8%Rf5EEzA%51|v71Nx30NQUdX_=lcsb@ zpM~;P+Vtm_zqNYn;yv59hxs_fg}B3n%!J^I`~*%9%x{4XJ@22&8B{y(OB%ov_-`P$JZ zT79d~jAL0L-Ztz`Ua(o4zga^qW#tAp!$n4fNDy+WkdTuMK_OIMlA03jw|S?VfiP`J z9L`yep360QexBsEXXic>y9zn*Vrf_AC*o@jxdGb&Yzh)0yiB>F3q9Y^CD{8;xSs>M z6T`jIV*OQa$icpWazkASomQY77fMSfGQj2RxeGJKe;wgEO>4ZMl^)gd_aEB*+u3s$ zo9;DLl~-->TeF~cS=W>?Z|2VKQn28ie3bc8-Y#0$(QnYWJwwZiOC22@Z{NC&hoR3q zo$R%=OXuBhcM2WxR{p$q^A>c;o!2F29@V*XyX4O2!aX_j-^rTse$4QH?tS;!{(oJv zc@bVEgJ&ZW;}R!rojB5I!qn8oz2Zl_n=-X)_I#9gbLPId_T8l$=Iz?HEzsQ-k2~Ox zo#9o%_?51|n{91zGV*3dT%asRLjj9hdpL^~(1QGVbkOdCrqKZBsn>+8E;Y z%F;KiT|W8O$)GbZg-ZmeZa&aS)W6u(zyA8`Z+7k!;&X>F$rW%Bem5;pq6fr(`6X%I z2=B4GhzxSqEc>>?WH>DGk5qV1tI;JkthYD5FM+_rJjO6JiZ!lmQ zYO|i`$7%}la$K|_cjlS~bJ=~sQzupdCi<}7Bvh1>#rC?A)TBu7_1i-XkQH0A&Ry%Pf$Xib;3>eJ1|NB3;~ z?edlDTC-MOQocTT_5Awf-7+S2DO}jCcxkudCEbdsd{DfkYw5Dr{C}EsU=&ga?n>n4 z=dC!spzD&3Z(Z#9&-CeCOO}3Exa5O^#i|r8{(#Do4+|EfptEbvoDY-6d~~+Qt3N(F zfAt*P%*0OR-o1PHCDx4fzYf^@&A8B+eUrz1m@)g~{G}h~FZr-&NyjZ8%v&|>z}|hk zcWyg#=FGl*`|wc3%9Sf|8oGY`Z3hwu95r-kRIQYqjX-?DVbow+I4(fP-RdBm|M zPzi5iZv!*)i!Z*|y=^Tt*}ZkGdY6dlA5yY34a;=&h@WwD55&d?w?;wu(TCl@Xf{Mx z&~xhWt}lA^G`I#08U&r&e!l(oTfxLNJCTgXqmv_j3>*Q6k|w=WlSHfBpgalhLGD*y z_BQ0Ul_)(p_k>)K;Wf{In>cPH%v8=-+dG~M03IPgT*LxBxb6!G>kKRY@sEE9psU?w zO7r?ei_$Q&?JNLOne_Yr4Egap4iXDs3%67Jq!ndE-M)5p*6Q-f%c{&}=U#WipYqM4 z4n;lIP!Bx9smeZvJ*qFDM$$O zL=p(|bqMydx8w#pbVLWaB!qdSQEmt>NDHUjkQYz6p#+y4QcJU=Wf_I~I-fd?+|V;4 zW`(9*)9TMRmY>?Z;kO$%ZezKZ7L}}zTs5zL`3G53J}6!GN%=~YPs>(tS^06rsy6}# z&p0-rv8pjLF?{UqAKzX7%DWEVzE|+ur{$|YD_!|n$;wYls7C2-l;V}27O(s`e?j-e zai3X#-eueyoA+$2s;I_0rtlXo8X6k#u;lEG)B0}iH7H(aoBxOs7Eo6p#>V}G46 zjx&&(siysbo|(|^#%?}M;c6jHWaΝK{?gU4w|`kw+Nx~d z?V{rY&|DZz%;bp{GH8qU*UVg=(h5foKj^h4DUxFtjI2g|NeUKqO<@uiIC!xUz;*x& z|NovFd~w;1b3+X0h9vC00alzD#olrY@^(6Y;@tFcpBAKU)HECI-o?7gvny9Du(NYO zZYV4$SRc1)LBpDl@@96gT=RMLI+R{jYq_lJS+n8o;9+x)|9a8!?11f`zJH`k*XW6# zRj%n>wV`+Ax-Tl%p+@OLWqqHDb$u#Oum7TKUH76Tz2nD!a_HmtNBz_K%DLty4KJ;| zefyS;&Gqc8?3&7&Mce0oy`|Uqkm-YRXZ0#r*0*%S*JT^})^6!^=!?mVNA259+XZ{O zTWM(-mmKQseeT7i-pwtnNlH$+bH{Gc!UdZ*Z#sAG+}X2dv9~yN>Xfy$bzEFrad9zv zwr*VAa(>KnMQv=V;9w*M_~*_I>q!$QqVWIx&m`(tFmKN3qx<<6$Ef$8K8Bwj?>j{` zcOFwihxhMVyK4FL>C?a|pGm~7n%GOb+G0gQs1YM1y|sEJZF)ds>TJPMaz6wm;(j=6 zZ)=IHLw;%)JRp9MP(h8(7Q`ksRDatZMl+N|!)UjFVzO2}1|>Cq2boyZ5Zq|Ckq!kx z&kZ!8y8G2E{P4pMKdIcHc>k5G`{{shT0?G8M&!v8He=@(wJKY8IxA&BY@#<9TQy3u zqCK6RrYtRJg@eQ1Kb$*p_?STtZJ_`bwJA4*W67t*_+o1i739ME20LTl;AtD?dnYPT z_6@$-3BlOwmgPj_6+txx$PG#L#mR-~;jzK4nC&2M$D_wi%^cUYJZC562JKp1#kqO& zW;!}KBR6E{WUo(LweaqSPm30OS-bh`x-C>{Rq5NX?c?zA{q}s)d)wO|UhVl=?!vF? zxAm{x)~{v@m#zJ3w)U@4H5w@2RBh>9x}tB=qz`v@?J@qtI}Ua@bHQ65Zr`@Kb?X+s z-SOhty4v~`dl!Gbwbz8O8AA&ed|kX|VCD9KmD>h3?0WljzwwKPA~!fWITV+aZ9H20 zW~Q7d=YJ_2{S)6R8I*MC-4UHM1G2%8$?eM&2km5 zwCSXkw4z$@Q}A^}hq{JhwdGLFg-*a0F@kW3PXv=i7-%9$=|Dp)h-rAykOJ5x=g5S* zwVlv`1L-e-TO2|NBnUn1Qo|5#C_xr|h>=-ThG53a7aTtRa$Bpie8oYsh%6N|b)SeW z7I*Qq(rl)ByLz?)k;6H&mnz2!U~zJ7kvTVnWhVxuMI$%3M+G{E`Zxr8+UmI>$jdg= z=T3B>GX_&*kQ;&u(!$`L%DlMh!o)hx4S6*4m~GbpFUP}2j?NkXPIb|KO}ni%UA%mH z_W1F?xVX3?H>78$Z%AFW;O_b!CBOA=*fFqi7nO!x-*FjuZ|~<36MG!!)ZO*_K4oja zySwLyhTY%S?~?KZH&AogJ*a;7z`C8^RIKTjIO&63?|nP{tDvADh`>7~?d+}{KYnY( zh@flNoN{xs?=?29KeYPmZM`N&&Kg;~^xLwHKh^B{sb=@!dk5aV{KJ^vhGeB@Hq@7I zK3LG@2krAQ+LsfxZ>DGiXCX=4>ovsD%O@-{G87jfaG?QN0U6@jwQG1kK5ogTq@-QG za%0V^Wx2^A95oU|G#e_WD3nq-l&~ON?XI62-SUH*6ey^;=9VI8-NBShHbz(!o&1Am zLGWTSo?#_j6rkEDdZe4;T^}_KNrn?fMM>eNC^6aslff-L6oWbe8p6drc_}JFjvv}> zs4hl+^wCEvo zesz9Aeo82cx3i653uXo8^zT35$L|Li;-G_4LvM)Af+?^RG_*x4AdpIw8Oa4WaHxACwzX!^*OwDsp3M3KHsyuy07pO$vz(#&0fM{Jos^@87>@;@evN z$%4#-J2s3P^3#u_MvZoLrQDF5nY1|@Zw1}bD}Q#sx~)Go?H}B7$HlqIEi24H~wWA;29ya{9 zLFJ|8O?S(uEKYmAhxX1u?Y-}7-~XYy+u(aW$7x@TukSzdW>$8tmzT$e4IA*|j;mL% zVn>1(SvEE{#3!UJUTuB(%GDiP);5$RH0Ude)!=BJ2$N~q#JsQ z2wf0~Cb_IOiD0d`fz?A=Ne|gfpV5Jkpq1tOZWPsA3HrB5sH&4rZlb-wYz z2e=9f3sfx=LF}|f4be(H5h~!V+NMr6lPx8QVzo&tFhVf_XXhyMxvgf$(3wrsCxu-E zOqM0K@MN*!;snVJbw!EQ1&Nipu~_B>si9c%snI_1q1ZP#wayK(;qE{Ra}QR2|l14gBZ-igD+a8GEC#3r>gXd*0Apxh@$LzV`9ukKBNhL9Fhy zXdm7;IEDJy2YcR@bBg!61bb3$h^E}&mKyC1LhPnWvmz^VW3aiZElj{^MMjKoY_KzO zgTEJY!?q#4UmQMUz|X@*;;Jp~UgKF5FE1}F->Qnr?QT1ERqZ{cT^>`p^4pq?qqJk= zv{U1>lPKe0=NI@+p3p4HR7)938c@PkpUCNneRv%#hR{8oG6?VY}U{)L742k=`L-0s}E#m>&Q zzP`4ita$Z-vOc4N4jjI`YscnrUk5tFBHxqaDGKO>E2%6ilAIIlVte)fe{Mixc=5#- zd-v)tvPilf2-M&+KGDYrLsE>?BUM%GAWZb&61Bm|0jSKOSYx{gP}uV z(WoB9NwRN<33C3u+#o8kT+)p*lS1G_Kv^WRjk*b}7_*DL!b@tf`Ao(t5vJI#Ob{AD zRtAdldR_!CjWQ#(X_TPQpkna`_0W(|io2**as`}fW+5_mBV#hYIwX&=+N`RsEg4Rp zVFien1#u@Zl}f}YWDHJZ3}WV`w)8WN@B&tNm3qaA_`#dwP0ejpBoMN3Rdqc)0o4;pPj&t5y$g*ga7@i)D&3S+CJ( zTc&X5Snb5{x-I>E27UV5yXUW+(VDd8=H|%ANE@4rKmD}5eS7Q}&bM!W#>(o{!w;W3 zcFbOK!>Q}X2JY!IE@H}*x~*dx4^7q1P1Vj$*Dm%CpZD#eFY|J9HLZEgrbw$lMOppD zWyr`4_wLp=-D@l;DEjcb%%?umo_b@S{T=7#=DS73;{Wy zRh%e3QH&*tN?V<*0ge^TQMYUmi!Q=Y6`ceqQ>KIH;QCN20v$&f1-7+kSh_yM-VkLB zLC{>cMOQ}VHxZkLx}t@5ClUAoO}B2{@B=(Nh>kmi;o;$u8&Lbl z1T2kQdPcL}+H~^gnsuX_j!e@o%+M~*P&FD-&?$uur)w8}(N2$S*gC-XhdxU_wR5Bg zCh%xeL_~y_m*<{6+pMhmSy|m^-~LMb_SRNbXa4e+b4QQfDK5sk*Q{@!{ci7Xot(gO-XfxJnEB0#JPu@LmSO43t+Ws@NPX~vuU60?;?%2C`FK!m- z6Q!KZht&3QzK(V9|M6Zt`}J!qJu=Aw1ogY=0i#qI-?LI z*3;QytAh0>J+cs08)WF0B5|$P2D=6P_`&V1JOFdBCpXKIXfRtaRPm`BZR)=JO}9r%!?gR+g^49^I%B2bt`2ECve%8>U&8ENRSB3gzNf$k{6 z2N~-iI0kX6L)EWz;F)4sqKwi+B!UKs0gGDC4G{$?A=wH3X;EGYoEyTt?ShdT-lOLt z-|NyMH$);g_~oYrAvaXyMpfs>*74SX_698Z>Y>eLC3mEkF~6UUDy zCnn;p(ee%ktitAd%~yP{uF6<_LA$p4-jSj8TPHQ2ougfyeZMkCyE2>0B<4&{vO^BX4^WLssnoi8pF3r*|0(Nlby03ognURqOnj?p!tgM`@tZu&h-qh;qGN@Ts zTi#=UpVebo?H=29>B=px@E42@P%v-k6D>yXL z_V#T&&DVgyky4CJm1;K>CnScu@7S~gt9i%96+1R9=Nb(<)H~H7bt-rF*(H3y?Ve3(LtRm1&GXYvW zZ1_qPGi!TaDN27)QdfyUxXo&CTNet?6zOIv5ul_|*sh#o1e;-z;DFI=0@@Y?5vQxc z^f(i!LvF~6tH_Bi%?!s@4@*8Z$}=IvRrU=na>Gr$uq7(MAwI+fIUqaU4?E=2tni8) zY`d*U}z_*U!Mwd;Zf3mok2bMd$Vo_f->+L{_8J=9j$9q~G{ ztz!E{&1Ui4L!<8QovB@(ui2Q(Jk4gFc748feU5hRSMB_my0u@~eld2-(8#C=EM?q6 z^z`tsw>jtMZW|dHap1t-KRh_R-9v8e|6q^w(5~I(|M-tfhYmSQZn))gW6=J-6Jw{& zYTErv^NHEoWfWwiVFg=zFa9hoJq3X0&&OI>-LbN|^~x(#YildegNqOYfAq3yA8GZ_ zrcoz5+yAHB9nq1lahvLgFrQOGCDMA z!mG`Mz?u*;(+ICobAvJ^8dTa6vlQtUt*EV&5xagU{RCz7usMRPMCgo)j0t2&dK8)< zm}`L&6HLw#O;9U*vmq=?2-tQk=h}ieeC< z!#ikFZt$1f;K{im5DA5HLtYGE09KI`8B6;HM;}jDTxRIqyZ4bphhickN@{9iH4T>< z@I7DF++0^(-PF{?%T6mPE?wuf_CVtSYwgCYdk4le9hs|LU#Q(&(6S&yV8<|~VbxdH zd(7Q6tuPN+M#Ed;JlyH0OOS}S=)}ZCA3l8W!H34R`%nM&e{w~7XlHfvp@*&?I^-s~ z!O_$H$Ae%0nlNov^PXRtPs&DQj&^-y#h%ZXev+J;2+Z5JQ`)t2ZfE8E$Rk&W42c^z zE@{%F3>t97x0qWVQXs-e zJp#^LW_k=+=*=`jsS7H?O=*2pXVDjgPAO`WZeoJai*7Az14?P4BO3^<8lpez*+M95 zqFZWFwFM39BRv*M!q?SP?N&NKVZFy_C~aHWtCNu+1J>ZkdG@~0DI};#rTwzZo>g{Jq^1nolD!EYfZ*f8R$uI<{}KlI@3 z0|z`MH@N$|3_09?a?-RJ+HTzGkn@*0n$4J+gFRM!oREb4rMY=zw*QNFy9a&Swa07F zU97AecpKqnWp(w17luOwXz=^3SKo5AdeHyHPCK^labL71V8H0mhdUSiwM$ipkDDKS z-s89BN3LJBhKo!Sg#`rvw5m;WOEXCXI*lAs%`q-Ra;V63dUR4Dd|VOML8y}tO-lrf zEeTW(U_hEaQO``%vJ-$N5s;|DiiEc0vXDuC%TYz&qEq*e-bq)mBt@}$x?LuT(y!x_ zM7_=U!rsbz^)QnIRdb4gEe&yks4d{qBhg~Cb-AQfU13~pL2PwyOnFWu<%Z-yJvTT<`QPE( zaKo~1xDo1gE6VRqd@yo@hbcEiRMEa67GUr?>a=M5X$$9s__)H{+=-`8j|~d4rDr2G zM@|nOxYLL;i+bGrqa`jMJAb?72}`ZDi#xOnqnh?i)~pw4x24S0Zr~Qi$ht-SE_L5| zc1wM216c4w31=rqJY-jr86F+zAp3@dg!mK3Pd@mkdF`HyZ{H!b{a=0B{fFy=e{|fx z&%3mgt~dCGc>jFl+bPM@rZw*ztDT&sU7JnCW=!4T?(05@j;E6p|KQw*Iz(7K8rA-h zK&uDct*o3mL*Oi9(zRo@sI${3>mzH3q|hu2IG;$uIw4kM7*g!atF&T9(M|E{B6MQH6dkw$ zG?8M_M+s8mNHK;I0;Q7CDTatFMMe?@R%EfS=sQggMQyUeP{Ux?l@v>L19cO`MZn>S zCIo{~hH%K8hLWNQI)#Pk4K>&Vr4qLdG+}R{t(lk*l+W9SoYIP=w8Q}myVMwBRci}l zYx84qN`RArk_^rbaXwi1aUsr;{`Qg^uw{^Q3U?dYH*ju9iFD77_o015Mi|mcRc>?* zU5f^^Bnl)=54@Jyz9Z5@Si8Ua{o!Gcz5D#i$|yGkM+OZ)I&f<0 zw5gmMW@^`v9w1^&!_n@WKMRYdhpnUIiXQ!Erqwe^&%VCltaZ@-L*Yx7`3)a_Zq1r~ zxGotM78V~L53-8#^0(fy!wr%5-(ON&Q<h1K%yjkj!N!iTVO1)vkt5k8>qvw4x&5*D*c6C zH-|cvXbE`{p?GDTSs2MJd1-AJ-nqD3f) z5J9X4Z5k*ys031FKLkul*Tk9|Kq zecCi_*J$nJOzk?#EbYd)#^c?0bPtN~1AazUS;wALf9X{6YL~f<4W%p-6)B0oyN4fB zI6FJn@{Z^D@i4xlvHrwK8@vSb>8I~lwF|Ve+P-7wY5ely(z#>Eku;^^a`Fsqt>n-$ z3HpT86=9Tc2(HjUVMhJv#SN)7&29zM8Q3_R>a3Qvc)_G~DWdV&M6GlE1#b}5b zi9kmnd<&&TVZkwKLkBd7on0ZK4NNu)h7$;rDKsIY9+E|#5!e99v5bo0Ej%gUqJz*I`WT(;f7Yr1&pSs~=SEdzM_>zp#h!(ILxek)Kav3D1`iwF zH&AYHm)u|%AMA+SkQM6<@{)|OitO;}oT%FT80;IwwQO;0UZQ_wfJ0V#YIJn;%abR6 zeEIT4O}oPB0oNX!G|dOAjnhN3eqAy(BXx!6vV(W`pV6*Q)(#KVwhT@kG3DIIu!s;W zORx>A9?e!itZ6s(qnHbH{g9rl+T( z$M`fi)j2ym;b+<|E-p}}yu9+&S8=z~{rW44V>%{C*K_C`BapPGf0_ovd)#;^^7avA3WC$`fjF4n5-tCD> zOhco>s|yl(=~S2^v;{tJ$Sy_9Mj0%`#b}B^@LQ_Ha%JnORt(e={fSF-;|5cTjmjZ{ zuls}@Wzg&9C}sH2P=-2Lic(D428%wV$n;TRXYUzyk>=7P(@HAEtLOx#EW;N_x3a}R66Q-C4fH$>z64GX+9 zBQ!rLAUoEZ_6@;~k$!d|UN?i>uk-Z=mi;uBYo}SgE%+DAvXko39MDQQAja$ zNDnHklt!5`_*>jAWyM7<9v+WQoH!&f@Uo^|(lng5+i4o!Tc;r>opSs9lu z*!=nN!_R)HJ^6XvBb*+rIwtKn7*$!350K>4r17VQ%*vTDUE4iOJ273mK0~vaf!xq^ zru*T~y+W{`(aOrIzn@a^-XN`GmkkLCaiUjlUghC)g&~o3HMLDR55oCEZZ7?ut!+Dk zt=i#|<&jmZuJr4N>y;i>R);4{*yQTs7~yMcc!Ot>r$Ub)nm37#0yr(kLVy`VKNm$n zbEp%5UATmdLF#2xp|R)nQ7E8v(B;yhiIND^Ams;^N6Bfdrzj=_T-O%F)Z|B1}Ry<>YA~OO1_w&z1icUk58~@ z6_;4@V)vS-yA^%We_KsWWl&IHOiT=h%F4=Keb3M8fxy?_a{BnQ0L~NE0|zem@^bUA zvnFqlwydya0Z}|s6jP6?DMBeoF;Uz}*2$>EqmU7l7|vu0nHhCng&?yHE(S#GC~$7D zN)%rtfq6Dzd`j0v!@#!paH@hp$=lmu1Vg)zw*R+67I!u4%Y` zf%JflJGKsY8yjUIHrC(Wc45<&3+wSZYV_bispRBjC)+E!w+LCq2<3*57|IRy5&lm3 z`8hV%?EdSSlkW`GI{&1-MCqaaPw$m(JDO5cMY#b9X7agFa|@9h_72vLO{LsmGhMqm zPP6WQ_RBlIbQ_|nsd3w}oc=SKdXFz3J;l1VrUIQ=Ib|RJ-1KtqrdQuxQIMY-8XAHR z`tjMiKgQ~@IIG9w|M2(d_K$>FJ>bx_>+FC4AKNR(4R5H)VV~%lBagOll$t%=Z)~F? zV3ugh($Qz093qieppQx*=z@qvh)pcQB|g-Z(Zfe)G-%iaeKrjckcsjZanS~pSpBaK ziI?eh-3($hcn#60bebDVXNyo>u@+84r|vfsrJ#v9)P`uYIXa73d2u*1lEO4(VQFD+ zy_lm2lys3rjxxB61}SVIGwTLonKh9vye$Y?NU?xe)H7LakwT(d5|a+9K!06Z>VY`! ziLS-IAvdxjJFFx<1dBZz`v&BOV23DQTm1bHBm_%txQ31>-`kQKkVNtm{Yuh8$}>Z& zaw2N-B9R+fI5J;NZ&7McOu(JY)WpJ^oG?8TFxOwhWG(cVOQ=%+pQ zS>vu#*|pX5tW-fk!Hf&z=M~SGrtKc29hhL15-> z0c!-WuC^JR7|C`RMRut$XG)Q-6PSi{O+=_prrctoH>t!ljIZlJJ%-OsfW*#2%))IG zWedAZ_!f(Fw~#F)i?w1w_v0nMu^PH=I=iT0fh8y|EeTX7WYy;3WB~hy2rMz29$>L! z$s;$!W8dI=`#!nBrgd&e4+d*hc0^4sasxK}(e==d6{K1k10kYWRW&-w)X8z?WYA=-${4h{9s;sT54EW zD1J1COan@Mj$5bytxMJ4->d!4x5^*K6`AB;eJa)cZlv8@>pE~*D_=f z=$<5hQbg!v`jnd8dmnsa7jR>?6%Kh1XeL1l+}uO)C5%yZ`B7?4O*$wLLm6%;RRzE0 zkZwXtxvgkS3h2^xQ-0J1OBVSuvjZiM}Oi!R47DRk&3_xdB%Rbsd#n@Dl}B zZ9!C86urQ`uBz&qqvM~)kN?`+`>3X!)U2^3#`z)gaxd-v`(G{|*HJP)0efR{?( z)CZW1L#CJ-+^)!0xdHE~DlILtyXE{;r{e>cX#M6>diY?h_Sz5HzVrF@wRmrfR#8^5 z=-TuJrPHTtyS~$oO`?6n&0n>f-!&h4|NO_7-OeN@q~N@R7ksmmckZy?s)sJoMl9Dx zu0WD#dbjt%lcz7^WiG+N!8pyy%F2@GGpegAznfJ2Vo&X*p3P5oYkd6WwE+QvXOHb= zZ6#(oUM$XGFVQ6E@d8_@NRK#8;z;Z@*Jc`qHKvpt!Y&dV_Pp{K<6{xZ3{9kmKvX~L!|D;f6gA4u zCo=g8<%WnBdXrE?AFx?8)EpJBJhqWH@t0S)%Cr%16{9%cw9$!ToC7mSji1RlpAuwYjPtfH;5>s z7QI+~5G02=$A$Z9jg5QGpSK!6epEuj34G~l8qP1|-llDNc~*Y@J^Ve1#>SGuY8a^>1tjMNRCjMWWvtzwv21tN zysf!|Cf?b-5Bh3&4;)@EjTDlVon2K`Da7Y*6uv#M33oT}dx{Qk9&&Nrj!^2B|2Ma(t?b>Lj>6XG#VCOU4P4vVT;i~h9D@jT?l;TNny0GgOcS^k7876 zKpAwJDTStmqeN$2v=CcZ%$O8Rd!f) zE?sia1)?EEwByqaT-V4BO9*kuNQrBztDCuF#~<-4?(%Z%9!_Z*7Tubdn4NZZc;>OH zva%#E9a|bfla!;^03<28DUlUfAu;~Q4Y%>Dipt6|r#qf6bUpFQE^W+aZSV@M-vaHE zN!pRC#f|m!6jOb5{c79a7FA52tL+`A9h;!t7@=M5Q}){@yWTo;<9K7;UA*HBX9{v5 zK^8rJgn937U0rQmX=w@G<&dAB4;nmwg$7hDE-98@g%lQ*51v)heT??mNbMipF5bHB zeC_htimXuf0}Qb^M0b%GLbhNO=CDOAoW^DvLx#!X7NXQy6oN=m8Cnkt?rf!ilA;fp zk%37?*UF$Ip@ulq6cD9;*n(K-c}Srd;uu_1GK+52R@UjBQBrgel4a=0fI_cebrDK! z0Wm3aA2KtGv_apJh0s_5k#0UD^~gUeXvJhAV5bSCVS+j|NhEq!l0c-GWLel5%>XAg z%tc2KwS~)QTex%(>0z~15DJ=N#B#354d;DBF!l|32|ifzDPekU@VJi6f+aUx32~== zLu{Zub^ss*d2w1`d1i2Bb{Jr=1F56*KItm?9|zDt%ox@F6< z+S=76CG%WduDQBamXws27FFaWiuzp( z$EP3GChyfoZ_);@()!HSj$JQptjC)ew8px|O?OrxH!RThFGF4z%MoMj%uuX{FVzpooJ%RHr3M?rKP3VRUmob5v;;O{E>}TAUyaSVRqW6xF(Cl%rJiiQyJT9faIS9uRiR zluExo%C1(TnUW=v$Ec7{9YNZa_t$%=hq|Ys!LIk>AvE+u!d`@vIF3>)Oa)UeV8&U(xGgNM< z%?lSF)FMeh1^7lUavWWq;S{D(ju(0_h-#|Zu#>4PEJ|r>9|i(UXYF_7>HPB zug#CJpowD$iaS|KCH4(|wo!h!@#J((b)~zj-)lXNE1VLk1#UfkXq~&DFQC$tA6$^DEUxKCJ`nC`nE@I z$d=p?DEkKFhS&i62;>HLugr^OVwoAXTigcq*%^XNH4e#8 zYE;sF3cG0E+jumxwx-I{pyOi28Cp5~o7=9DGB!a|1gMd0Y ze{d*~2k4L&5PArKM+HhkNrxo`h>L2DL5WJ@V&59IBBPK|XhMU2nn#Xn-SY~ZqKT9d z%|(haWGJBXio%S>`Y-|c1Pvj!*hoSRSUoB%;Vkq@RWi*~2ugfH{vjNN&z;m}yO>2G zv&R?{^oo~<=nxI1q>`c&D65t729)5a2@)1oKmm#Z7Oj|FTtvidqacHl8l-^kA9I5! zMO&qzQct+pYVKhK-QkRBpc#xZkJQgu4R;4to3BV;gO?wKkL<<{j6@@6ygY zac;nwL6dgWckkk=>C3deUuBQ{`S{l{@lkgh?*;}2`uO-DA0Rj2!G+L}pwK|C_%JX0 zo-8@cDazletfI2Iiaxk|A|Kr9#MuPytKd0GoQ&X4ZerVk3zXPZ(A9~$y41wzym&7$ z-=wy(U2LIRMVVnB2*@t+5*oVG466-F)nkET{}8&MWg&? zIKk2YrW7TYRV66p8B&ieqTGN*jrE0%esQXQUV=B4d~%p0azljA4ayBJrhUVu5cjL- zMsC20$&7LXIqe(L1FNz^s&hgmHwdskSK)QEnNYfmI@mN&L1!*$!4BYBr(`mtUwD;q zLN6?0L>2B~`rVH5y@g*@G}PDn_=ddutA^@kA4@LfpHDO#^ONAfw>t6|&VpUI_{G4-53b>v(H(VLMM3#R4_Z!>$lpXcFYm z;sHH^EM&T)m{>9Db1N<~rrMAN_p&&{?V^V2B2d;glAKHB16(9afHmu=rb;dW&#$(K2-GLJxdgUSchUji&uqG zCPiStXt_T_2Na9J)NA>;#KYau>^0q6Nz6)NLo-%=(Cr-_PS|X?X`6_8m>KD_pR3M(FD+PZ5fI=X9Ox4f)MBZjou3rMGB{CgecY&>-M`g&;GM8-_1@T+b^@52SrVycd={ z7JgiSEs_9IL7+>k+z{c7+;H2H8&dqs(*r7z8?r-dbHkJa&>)#OLz*`hehw4@Vt6=C2+0)%Lh*+w8R!SG5}f zHO=?bZ@I39og3)z(WWb_ni`vNUf^JJRzX3ZJVU5>om3U+FsCXrG&LqTBQ-uIDl)*| z-_O^_*V`k+-#t3mEhpYrH=hiLs>BHWF`24}Ll~Cr!e||NKzhhz?h$(K=OOA88r?-Y z3p+=N5FFAUqYNtuB2;gSCc*+s30CMKRA@}vGBMFWF`{InSaTufAy!_^wdez4h9XMg zl|$**hjekes)lrn!Whz_Xq4JCL5!)uSzFa9p~bc<|c z%!q|oKve9RFqJ-{n9j(=qN*UU6eW&4Nd$&a;v&)LXWeuboj}l7RfB-(b%!Xmc^(Z7 znVx1=z)2kBs!0@aWVi*KwPFIL8=D4+I1|VY#n(Q*{7X{(@)JC>qTNz(PT_AG;bRlx z{(suLwivyxt30n%MFLt0ctL_EK&VA22&vH0Qc)@-5E2zns8AHj0}?_)JRntlC{jdT zKu}dx)21RM8QY2D*l`kjY>)4r`_*I5_%`wQ7N>D;zNWdf!*^M0oqhfpr#z!ZM<;8q z{jG0(YwdIPod5r4es3Sx8xCz>JiZe@r&s4jE-xL_bHn(XYm>Jx&)_F3o?RUAFIDVO=0;yL_D#e46(JvDdolYjHw$L7}mdwTtm z6MTC3w-?u+pZ&p)-j6Ss8b18k*S7rgy}NJYZ#zeJ;fbM3N1KNPQ!}R0jv-%u;jNh) ztCQDOj=@kN$q-ZwVVN-$iR~hc#W8;mpZ(#b8hX?U*z}~HT+d8xaL!s)wMbFAy>thJ zyiF9kSfv(~GBQP~ige9TlB&`$c*BJTi`Ti+Tre>=Y;JxC*pS^Nlo+N!Y|yHuRWglI z)nsQYDmz4`PN}Uam6;5X5eoZ+E-(U{G8@0!6|I23tF$z#O5@Zdf{q8y~knHh~|zH=H^8+UmHT z8)iVmy`i@bF|_mE%LBu>&@{WrRB0?g-xJ};3$fZ8UU=`_w`b;0{oaF*Jb7~c$%WV+ z@ZQ6o#dm-BUi^{gxr=9SynX|3JRBW;5xZe(YsGZ-+txg=ChZ~*TogoZQp*QtiP;TV zqVVD@V<2gFi+pfu&Ti=8K*+$*<-j?&ArM#Mrr@r7y{b2_uD~0qJk|PJd*f_U{g_16 zfdMuSn;Hj(Nxq@;u|}KwH%4_yolEC%cG)*C0kAH-QQLD4U~<FdKypc!XJ6nD`YZk_QKZ---<=$`t&kZl&k1-aORzCfeN4A_=-+F5O32hJGI=((~ z`rY?)Z}58ti?b6~mk+CRnPpHS<+tFa@a zNeZc9r&F955}dJ-Jwpi2sS?AG^2>0#ZWUA-G0DTd!M4tAc)(h4*#y5GMho+> zarUCXQ{Y0Do|-bO8e)H)%c!*|1{(nQFi)LZLw1y3U^tCYios?M&{kCGRJYsacda&| z&d~we&gj7YY_}ZkDyw7*uxHs@E2Yg!Lq9sRF-i2PIzUvdH>%k8T(E0fq8cHvhe-+%Y*#icW!{>pc@Ew4Ylvc6?$efZ@1|17NUTft|I z@!Wuy5{q+F=V$iz(nUv8kCjy3GAzcx*gZJ z!D5c~wuHvFVAuk)do^1guG(DETF=I7uvrTScHs$5=2&Ru3R;PY?6#xlacy+MM9ZQ| zY9MKo;VniowH*Er9UU?4!k(vkcFQik*kQ#W%Lg z42)rlYMRr;lE0~Cvvj>g1qdTMiR%*&4cG7{;*6dfCT?6f!M)++C~o}Icc$L?`)|#C z^Qme5>NCGs?&3=q&P>192$MEyW)?0*sFlZ(C_{Bw4*`O4c0goPnt2qf^3BW+WVmP} zW6EHo@=kR#BWXoBg;Hw`Rg11KUS*{xYGK1$CzU5v6xC_w+7ZCBTG5}fRLurJYK@O` zdZLpCOJ@>_v!jYa6kh3I7}kmpkLxvHAPY$BX>#$UuC7U6c-bEc$Sk}jvv4=ZP1xvk zCqsPdAxu=&y-s}6MqBFQS1hwwPYfl)R62*kSTC)Pkex84c6L%ZN-G#u$7*(0V6>=s zWLOF7DnFhZ@J4~38zx>oe;haaCGHJ-;<@4A(^Cg(Z3rDdxJa>L(&)VYt z>nn%#+%SIg($t-+cyyq&*c*JEx{K^Rr__n6fEDMOv_13X5a3{A-4@PeWR&Uv?d{9c z5Ub~g-S570Z)y45r@r#t;nVB?Ir_>!efz}UeSP>_kL|=qj(#ceqaVJ1d3mh64Bd=m zM*m`Qs@c&hWfv?8iHbr-)a7?$Yki2XOBLl9ET=O@USL?hm@(Tl%JSr?l9kI>oH&`z z%r@A6fmMsAED2{G)jb+jj@z3WPh@+I`dQm13&@+)(W_I2H&_D-508^(k=bZ!l`3 z{7$5#B(LVnlT~o})Z|iPLmRxZ*R|(W2<6Hc9wt)vg4vqk5i{$`*?z~eG|zHxxH5h7 z^3)q^<2SfB99}zl;QZ_!-2T`EX0bPnZvE{C;_omIY@N~GaC!`T!;6;|_rJVy_|YO-{xQ+ekJ{rAB)v*L6XgDJR4 zgrQ3)Bfx!3F*ue~4WOIdOd-LUrH}(2YuGrux!cAE}H_RV-27AM~nHMiE?7Oyn z==*1nz3~#B8zydFp7KLTZVxl}^cbP!zSVGs6Z;45BpR$h=M=cf9hqXi<&g6(Vz1?p z)y!O&!7q3}durnOAKbh1*3H}7pFe!*(&gF`Y~XJwcmMPFKB~sIrTEYnE`^^l$V>@Q0FgR$Hiykp3 zOYJcb+*Fzvk%tne=(4n>$hIp#_?1tp9z=Y+L61mb41HzIddA06o zDBOXj3K9p#Z6!7%oi23-xmC#-vTf&?u)9}g?p~R`a|LfUOySmkeRT}CId1l~h5fkk zu{U57z*aD|AA7^c@cj)Bd~EW-mYLCQ^GCKXjqN%+`TR@sBUew2zH;V>Usl}0rxkc* zafLg?-K%_tz)y4@81f9yG;+$|I$%iqiv5HE>_8!D>vak-9Wuy`jM!IJ4zJGb#fK(8 zxYs=;cuV-<`|sU-^ZKppD|hf)-9^~tr5=$}BwG?9F{DUN0l-4SCZG;sSW6YiDIifx zlw$_hYbu6UMb4;1p+szfkLIKdX*FKK!sjtCURo~KsHG-p=VtJm=&msLZK2#s`IiBR&IV?08v_~HP}@P?3HEr za>@cY)S;n7M&FFgbM(hbIwv&8(e}-SH@T+oT;?l*o0lf>(D2&%kM# zMy|rZ&@sRXDtZKK&y_0-$+lg140$Lv>^_Y6RAt+-?YUG1Rkn-xjjEi>7z6rvN0BO1 zg9Pd5Nj6XMY`+c9DvEd=(HsGKjS`F=(FWd0#px-W>u@?3%UPt$S_0eza@MhOI!k$6 z5r-COs@6_b1SAjBIiqJ4ZUFf!M0Q9jJ5v-%WrtM!kiV&W`OUTQH&(}9J$Dqh`Q^p^ zxaH6A1I!(Bhn}83uytbpu$~(}@teOfv2S>CKVMehorqIoyUtI)aB+SgA01YX;N{5c z7mmMq5uaI%zjX;OG4KpAp(lySn`;x!6ULhS$c*On@X(`NsjG~`T84`(SErmO^ z#Bi2|(iw@_PC(-)zcedLDina>!5m4&;H2hPqUu|8%px&WNAOTpm0++-MhPK_A(G0B z5|$+^iz;PO71aXNC6H6F6e2qem0&`5DPx(D{04`ZXsqx(Nrtf^c3at{oFaKJV>gwY znMEI>IHzz1RpB*k zLSjl$Z(Jmd9uJWM2AtxFj5VZz?5UHn4wnE1>Y&c@Q%O^oLwd80f^w$o@)9Yj1$Nae zFl8%5Fgm+~85K@v+QDW$Nlq9AsCBeO;t<&(Uh>EwNs3}%&PI)rx`8c}&>tbz@4S^o z*-0pvSIxDTvulN;$lR@XuD(i+env%HHG*@k@6%Xfl9@emhzzNMCl=i>Ew?VMXtHW_ zhndSItEDY%$Vf4{=voMOuL*I(eMz@A2$@vZWHCsFW!KWU5T2=r`VHXaWRX4xp;VbC zE_D=`H&i0oDB9UB+`n(Eo_OuT@f+ul;fVno!`0KHYYY2U=U&8{{wI&`z`F|A1n`(J zF*1y8VQA<>ANr~Bktgx8VsiiR?7?k|NAZs2&T~`v!-_rF9AXBe$rc-SXR6BD_DIcGPiLQ}23li{dFWKFeM%IWGfMTHFp!_aJ}LmEJ~qRCZ~8rqf< z_AxiG$CFL=tn(7kb%0Uk)cL-`Ze$3lnsO=~j5iVW%a8>v=R+Db;xBW*4umnrnv>2#H}i99;=1DXUZe zA*>Q1+!&qNVH4(=!ys`v8QThQY%uhDVjgEqPSw&h2Z6?TwbS6FvWN*6? z#N2wisTNkk%!YH+k{1AZy421^s)8wz$-CH?&5j|XJOS&6bGdN~<3`30{7Z}bF3#`8 z%L8l-xY-wvJ%byc4-NZ<$48#{-Z#FEZDDBW%U}NMzxcB+z~QF{yc1E|!^-%sbJNdb zhghB6^V0m@wfPZjG(7u&?Zf_skxQPH)ApsDYC|x^*@W3HPjHHgNHY{q69^=uG!@|m zYmAn;(~~@d;T0%y$5xhBTj?*Omq`5Z3_2VBjxDPw&!A34*=aF7+Ie=V=c($-FkrLn z4vg?VPnCu)wfyjN2)2!c15N{)bIZeuGzBLQ!=!m&SQ#U{kEG627=V&j$TGwqgqe%O zWC*qmc>61miTW67)c zvoGM*UYXc+YHTMyfryO(4-I%m7n#<@Q3$pe`I{`lh`5r#sjbm zN4B3l{tWh%yC4T0 z7W>&5a56lQF(efV)KQowyYO8HIE+@qP%Kq>b%H!I5+Ix5C^OEjc*Sz6D^rD+NE&L9 zlpC2~w}>g~P%Tc{1e!lNDM=-SwhR|}FPCXEokS)Hohn}>*#}aw&#Y9+J*&&rs-jU| zUuG0xl0*t+loC;OGTg?z>=~Z5WJsd0E@Y8tSz$USD{F&4EH6$EkIQXK2hllo` zc$NVB4Y1!Z*<#qyMFHjzo@IMj%wh}LLc-u74dpDPJ!6d+;{}lB!9=Iq*bG;StZ~2@ zgl!X&Q&S`~#(^a@odxJhGqM7qpLUOSW5c7{iUpn_4TCi}mpU(1fuZ(@^tT_ZCYxiqs-|t zP9A#(Z!0bwehN4E?C4fJ4)CRfHin74Phcy+hJbBhXbAsc3;rp~FMjdQ|Ktmw&F$gw z$r0=jPtF_|o*CUTdyua(=6ztdIPx?$3?4_gb8u)6hBV+zzYT^|l&0u0(o}ZZZaid8 zd}P#YIBOQp;%@;PXc?GdOkx?GYyn(Uk5g2o2eGz!R(8uPk#zbjS$2J*~Z6ISP0l&p>+J~&m zBpsD#J7>ZoX^E+Zqy~m?CzwC9ZT|2!+|KyaVdmhL=>uD)_|7Ar2yi~M>wACv`QOJ@ zfDHlL!qCv_>gt&@XS_Y&L(LtJ{Rel5k;f_iF&vV_NKM%pv|DEhXsI0HT%Pi5M+-vieI<-`kZciKr6Xo`qke#UPGy0I z&i+&~E1j|!W~5~!g|pM?)XCEk$|HRAr0XOzl0o3mpF`KB0@=W*C1|Zj{?O^3lpX;@ zl?=#|3QfX5!yKD-35bR3V9<~aFQ*DeNKrA|vm%UQ?W|Vx@eHR&HF`?1rH~}Tz@T{Y zN9SQziWak>rBL2=*vz7>{$~lQFdW!@X=@s z=F^L3KZqm}@ncnx5ZNOs!YHwswWk2B@c~o+cUX`}mF&%hfiTl`0DIEk??aTSVzcBH zX@zd4{JFec?MS4DLp2r{hogbXL%{ti9atu=T`?q~JjGDP-~w6RK%x-SPzgX1u5v3Z z%P)r1-!{idae;*lC++ccxtyi?kg))4$i*HuwM!lYdm6-?@+=@y*jeB*ln5A-r_+Ir z7}AC_F$1$3hnwe3ZIvqnogFtd4&L2+AIEL}@YnwF4?p|6zx9a+@RjO*V!(!gZDD8# z|3EDMk8J`^5%}WuQ>RWn^w2|}`-9JZ6uZdJ{tQk(IeyZCpLF2=We0eJfAk}t`OK#u Ye)wVB__+P?ud!e&z=nWrVF>^IFZGpsumAu6 diff --git a/Source/Project64/User Interface/Bitmaps/CloseHover.bmp b/Source/Project64/User Interface/Bitmaps/CloseHover.bmp deleted file mode 100644 index 14ea639e31081208d50da98fbaf629be19fd331e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1398 zcma)+-Afcv7>CayL07voJKr-Pm@GtyC}QGWbl*QvBDSrV5p*Fe!6u?sM3fOygoF|i zLPR7bQgk7OMbSlc6QRTsuG_^f*k792}bHjKH1uHHJVcW}Kw*AI+ zKPU9Xbq^Mvmi5B6U&D$^;rpK%#zRc5`>|9iHyRDs{j^`$d5Yb#mdF=>STU9oz?yc0 zz3+d=Nqv0(2isUX<^~o#v)Nhdg%y`uL^eC8Y13pu^1i>3aNS_*`|AnIIzH5|>vs%e zq1Yls=`j3*OlAV!ao+p>Pm}o6QXlD`EHD<(4V_cNI*SZPcUl!M?GibJSH5Ns;D zZNDXdUBAh&Va0U^{$4s=lp|P?35O{VC=Q`W8M;i{@zk_yRDIPG;`R~v*>rl0elSwm zwp}%=C^BxCzZ~`={eqv#3GwO}{hucv+g_nIndfHW&AZk-#fKC~nIip`eiz>JzQ%BCYbB}J?s?zvROcC@!oHm>dM6_m?uC53%z z>JL6t3Qr?qeu?woIIA5UTS}ds)vm5;clW`f1cuMBBc6C1Ar4kgPgSY6x7yeDyTAXR z*v7(>l6haq^ZV!Pe4d$y<7rZDZ51e3F8AGOgUy~loYB$xf282Gv-1DzL%~&9U~N+P GD~Z2Rwju2R diff --git a/Source/Project64/User Interface/Bitmaps/CloseNormal.bmp b/Source/Project64/User Interface/Bitmaps/CloseNormal.bmp deleted file mode 100644 index 5515f296f4d288398b2d0412257fa27c2760c063..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1400 zcmbW1KWoB37{=3~Q@28)pg7k>oC<=I4kB0)7ncmBDE1>{ao5eM{U)v7p)FKs*HUP$ zn$&*W2^2gwoz60!pXjUIo>2({w^nPGNW8`sD6oRB)ttC6 z@}MMND%s3i)}8CRyj2(Qamo&;5FR1AI7f?L+bnpxH8Sp#c*J3Mh_@+dGS)I o*g@eTA=M|R*%TiySiw^X{6h3au;AD4_oVsb4O|@|$rS#eKM;r!VE_OC diff --git a/Source/Project64/User Interface/Bitmaps/ClosePushed.bmp b/Source/Project64/User Interface/Bitmaps/ClosePushed.bmp deleted file mode 100644 index 4209968af2dffb57df748ad9ff06bf7634d627c0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1398 zcmbu8ze>YU7{xya=UbEJUn!-vlv*qu1Qi@alx`LuKt)8~K=xeCKy>C}g?S9;f&>hx-&ROI>5+#`%((#|w44*>p~t z6HmL|BoV8mc@A}hK6JHilXRHn^M0}Dm&<;&8q{h*y&g0gA5!oT!b&A5mHa}%M_+=` z0}I1A%47})7y5Dwsu7vysSurE1qv)p|APlhjfg)J;y|k1?uB83X(q{| zB!AqK<}2=R4IV7bCwa8f)pUXy_*w7^ith^1mj-louXn(MrA4A__FNxG&zLmn0w}Q5 z{OSB}Tclz6{wv^D)%p8EB$PToF+~~Yx4`e=GqElW<5(BN2z9S_K!J^T+rGx1!D8T# z1S3$2cbq%Rx{zX+lizYse16Zil{%d_Y{5(2Ajecs6z{svqe=0e_cEFy9^XG6x!n7( l0tJ>Hw%y*EiG}CA4lW7bZrJp=7V{O=yJQp_r4<^a<%b1QsF#+nl9JC6 zmkAJ+wvkb`ox5=LvCBWR8{c_Hy)?4At*m}RPT_#;FhX()`{b3@E2wtMsiw#%yLI-> zI(_|DMc4cI%-7By&(zc($;dpAmL5JxM&`b(++`)TO)6TgDmn>$lNX=6`Kz|~Lu%e@ zH=pMknvbaB*(FOpBbWL>F0!!?AO1!bLE|E;qzYSB?uL^3E;Zc=>IT{U(^j0n`KzuE z>|gKa>Kat=Z)@wj&6~dheFR59E>IBec(@0(v>pM~0Aa4uYdrR5V~GN7qvftG^(yBF-=`~mbY(3?Qd0=*0m z2O2R3gMTkx{0T|(z$8s0Z^Dfo4E_biEOH8myNwo%!QfwDjvi6z8R%b6&u2gq!k|U8 z!p$5c@e6d%z?9FoK=p50{%dz1>eRnLj{swBaJ4to_Nwbm(J(5QIDOTH+rL^Sf54ghZ=hfo%_D5i~A59a4)SCx25}W1oip3@y`=Nwd~nx%Yd@;!h1- z?^Ci~ySP6yHhE%b^w`jFm>?tL$GV1(b&M|=+N?2k>X^P@$E`=d*Y5tdX!Ym*X&=j~ z-)3aLPRSTf=v7?GE5C>r?qQd`V%IKNck0cDzlSdT+;{xPrd?kbuJ}A{&Zo&UKTeu4 zOwhy`AG;=hsOos1)A%l{_4=h7Z-E8N{bzs9-}-g@;?Lbjzi-+5ZPV^=8;1*8zw7I& zZC@8`{4! diff --git a/Source/Project64/User Interface/Bitmaps/LangOK_down.bmp b/Source/Project64/User Interface/Bitmaps/LangOK_down.bmp deleted file mode 100644 index 790c3a70d8f0d1bb16d9c445ff1d06601c627b40..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5576 zcmZ?rJt4{f24+A~1Be5FSR9BM86#19LWe_p@y>-MAH??3;ubnOvquSpip+l;L4*f>0OaDHm(kJP z7bR71d#8Pzx8}>mJHHkz+o@+!u4Ob!Rdb)b!c7^O2h!5R2g%Al(9wPDAN-=A;!WrD zk7us`nzv-Drcs`{-XtaUU2^g_sN&frOFko)`amwSu@4{qMixQiBCDhdTV3OkyU+8q z{MQZrA5L8THFxnA4WnE&-HAZ|%F11*+=|xLcbhkV1^Nh%fLx#;++?^1wX_}q)c|G7 z%HF_bsm@SSf8^%%JSFFKUGIkzSAGKht8SP>MgPLR19v&lQ$RsD7p}n4@(C~*(A2X) zOM(7%^#u91wr3#y3-l(?vp_Gy!+}PO!QkJE7k@(1JTOVq$eVCu2ZMisF^inS;clY^ zV=(v^n4?EjdItK})AJdSgfM6kt#C63N&EucGce`zqRr}t*{ZtzO6ohQQvU)y0*tl6 z)82r_Z|>`w?hnVW{G79JqnduIs!o@Z+E!V)Yw%=12?LlnA!!vtqSdg#wg<8Z8kZ7# zvFZi-*V*G)Le}ew&iBVI|C}**wSq>Fl4gmb`dm4s{jzdrWn|9{8zd`tPD$;WiS^T< zxR?3O?+%{-Id$d|X+>KJIZqkIELp`4S;gtHinE3dl2e?eq_Nn*a=UBDxuoi+drtq@ zf9Qmq8qmKsB9hi(QeF}=;gYh^!w1R5$f=}i8Q0kP&Wb77bM@{QV8K#c(FXJ~IF@b1 uWk5)5SRjaBfKjQS>1FDi(=%fayc9ij Date: Wed, 11 Nov 2015 12:31:17 -0500 Subject: [PATCH 131/213] inverted the inverted file flags condition --- Source/Common/File Class.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Common/File Class.cpp b/Source/Common/File Class.cpp index f9eb583eb..e6ab04651 100644 --- a/Source/Common/File Class.cpp +++ b/Source/Common/File Class.cpp @@ -82,7 +82,7 @@ bool CFile::Open(const char * lpszFileName, uint32_t nOpenFlags) ULONG dwCreateFlag = 0; if (nOpenFlags & modeCreate) { - dwCreateFlag = nOpenFlags & modeNoTruncate == 0 ? OPEN_ALWAYS : CREATE_ALWAYS; + dwCreateFlag = nOpenFlags & modeNoTruncate != 0 ? OPEN_ALWAYS : CREATE_ALWAYS; } else { From d9ef1cae17ace6a663147a59c6331bca5cc78e51 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Nov 2015 12:32:49 -0500 Subject: [PATCH 132/213] fixed implicit (but wrong) operator precedence --- Source/Common/File Class.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Common/File Class.cpp b/Source/Common/File Class.cpp index e6ab04651..50416675f 100644 --- a/Source/Common/File Class.cpp +++ b/Source/Common/File Class.cpp @@ -82,7 +82,7 @@ bool CFile::Open(const char * lpszFileName, uint32_t nOpenFlags) ULONG dwCreateFlag = 0; if (nOpenFlags & modeCreate) { - dwCreateFlag = nOpenFlags & modeNoTruncate != 0 ? OPEN_ALWAYS : CREATE_ALWAYS; + dwCreateFlag = (nOpenFlags & modeNoTruncate) != 0 ? OPEN_ALWAYS : CREATE_ALWAYS; } else { From ade04862f8631e34ed51face5b3e180ff2754266 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Nov 2015 12:43:57 -0500 Subject: [PATCH 133/213] minor clean-ups --- Source/Common/File Class.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Source/Common/File Class.cpp b/Source/Common/File Class.cpp index 50416675f..f2f431bff 100644 --- a/Source/Common/File Class.cpp +++ b/Source/Common/File Class.cpp @@ -79,14 +79,12 @@ bool CFile::Open(const char * lpszFileName, uint32_t nOpenFlags) sa.bInheritHandle = (nOpenFlags & modeNoInherit) == 0; // map creation flags - ULONG dwCreateFlag = 0; + ULONG dwCreateFlag = OPEN_EXISTING; if (nOpenFlags & modeCreate) { - dwCreateFlag = (nOpenFlags & modeNoTruncate) != 0 ? OPEN_ALWAYS : CREATE_ALWAYS; - } - else - { - dwCreateFlag = OPEN_EXISTING; + dwCreateFlag = + ((nOpenFlags & modeNoTruncate) != 0) + ? OPEN_ALWAYS : CREATE_ALWAYS; } // attempt file creation From 0174bae7a8cb5eea2eb4976e6042a7fc0db8c5b3 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 11 Nov 2015 18:08:24 -0500 Subject: [PATCH 134/213] combined fix into a single line --- Source/Common/File Class.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/Common/File Class.cpp b/Source/Common/File Class.cpp index f2f431bff..cc73de345 100644 --- a/Source/Common/File Class.cpp +++ b/Source/Common/File Class.cpp @@ -82,9 +82,7 @@ bool CFile::Open(const char * lpszFileName, uint32_t nOpenFlags) ULONG dwCreateFlag = OPEN_EXISTING; if (nOpenFlags & modeCreate) { - dwCreateFlag = - ((nOpenFlags & modeNoTruncate) != 0) - ? OPEN_ALWAYS : CREATE_ALWAYS; + dwCreateFlag = ((nOpenFlags & modeNoTruncate) != 0) ? OPEN_ALWAYS : CREATE_ALWAYS; } // attempt file creation From 70a368a8618e8d683b9efc4f4a8e5aa229163201 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 12 Nov 2015 17:47:51 +1100 Subject: [PATCH 135/213] [Project64] Clean up N64 Class.cpp --- Source/Project64/N64 System/N64 Class.cpp | 1381 ++++++++++----------- Source/Project64/N64 System/N64 Class.h | 106 +- 2 files changed, 742 insertions(+), 745 deletions(-) diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index 73013aa41..54f149ba1 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -49,9 +49,9 @@ m_CheatsSlectionChanged(false) { gameHertz = (SystemType() == SYSTEM_PAL) ? 50 : 60; } - m_hPauseEvent = CreateEvent(NULL,true,false,NULL); + m_hPauseEvent = CreateEvent(NULL, true, false, NULL); m_Limitor.SetHertz(gameHertz); - g_Settings->SaveDword(GameRunning_ScreenHertz,gameHertz); + g_Settings->SaveDword(GameRunning_ScreenHertz, gameHertz); m_Cheats.LoadCheats(!g_Settings->LoadDword(Setting_RememberCheats), Plugins); } @@ -82,16 +82,16 @@ CN64System::~CN64System() } } -void CN64System::ExternalEvent ( SystemEvent action ) +void CN64System::ExternalEvent(SystemEvent action) { - switch (action) + switch (action) { - case SysEvent_Profile_GenerateLogs: - case SysEvent_Profile_StartStop: - case SysEvent_Profile_ResetLogs: - case SysEvent_ExecuteInterrupt: - case SysEvent_SaveMachineState: - case SysEvent_LoadMachineState: + case SysEvent_Profile_GenerateLogs: + case SysEvent_Profile_StartStop: + case SysEvent_Profile_ResetLogs: + case SysEvent_ExecuteInterrupt: + case SysEvent_SaveMachineState: + case SysEvent_LoadMachineState: case SysEvent_ChangingFullScreen: case SysEvent_GSButtonPressed: case SysEvent_ResetCPU_SoftDone: @@ -103,18 +103,18 @@ void CN64System::ExternalEvent ( SystemEvent action ) case SysEvent_Interrupt_DP: case SysEvent_ResetCPU_Hard: case SysEvent_ResetCPU_Soft: - case SysEvent_CloseCPU: + case SysEvent_CloseCPU: case SysEvent_ChangePlugins: QueueEvent(action); break; - case SysEvent_PauseCPU_FromMenu: - case SysEvent_PauseCPU_AppLostFocus: - case SysEvent_PauseCPU_AppLostActive: - case SysEvent_PauseCPU_SaveGame: - case SysEvent_PauseCPU_LoadGame: - case SysEvent_PauseCPU_DumpMemory: - case SysEvent_PauseCPU_SearchMemory: - case SysEvent_PauseCPU_Settings: + case SysEvent_PauseCPU_FromMenu: + case SysEvent_PauseCPU_AppLostFocus: + case SysEvent_PauseCPU_AppLostActive: + case SysEvent_PauseCPU_SaveGame: + case SysEvent_PauseCPU_LoadGame: + case SysEvent_PauseCPU_DumpMemory: + case SysEvent_PauseCPU_SearchMemory: + case SysEvent_PauseCPU_Settings: case SysEvent_PauseCPU_Cheats: if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) { @@ -126,43 +126,43 @@ void CN64System::ExternalEvent ( SystemEvent action ) SetEvent(m_hPauseEvent); break; case SysEvent_ResumeCPU_AppGainedFocus: - if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_AppLostFocus ) + if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_AppLostFocus) { SetEvent(m_hPauseEvent); } break; case SysEvent_ResumeCPU_AppGainedActive: - if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_AppLostActive ) + if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_AppLostActive) { SetEvent(m_hPauseEvent); } break; case SysEvent_ResumeCPU_SaveGame: - if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_SaveGame ) + if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_SaveGame) { SetEvent(m_hPauseEvent); } break; case SysEvent_ResumeCPU_LoadGame: - if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_LoadGame ) + if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_LoadGame) { SetEvent(m_hPauseEvent); } break; case SysEvent_ResumeCPU_DumpMemory: - if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_DumpMemory ) + if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_DumpMemory) { SetEvent(m_hPauseEvent); } break; case SysEvent_ResumeCPU_SearchMemory: - if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_SearchMemory ) + if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_SearchMemory) { SetEvent(m_hPauseEvent); } break; case SysEvent_ResumeCPU_Settings: - if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_Settings ) + if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_Settings) { SetEvent(m_hPauseEvent); } @@ -179,38 +179,38 @@ void CN64System::ExternalEvent ( SystemEvent action ) } } -bool CN64System::RunFileImage ( const char * FileLoc ) +bool CN64System::RunFileImage(const char * FileLoc) { CloseSystem(); if (g_Settings->LoadBool(GameRunning_LoadingInProgress)) { return false; } - g_Settings->SaveBool(GameRunning_LoadingInProgress,true); + g_Settings->SaveBool(GameRunning_LoadingInProgress, true); - WriteTrace(TraceDebug,__FUNCTION__ ": Mark Rom as loading"); + WriteTrace(TraceDebug, __FUNCTION__ ": Mark Rom as loading"); //Mark the rom as loading - g_Settings->SaveBool(GameRunning_LoadingInProgress,true); + g_Settings->SaveBool(GameRunning_LoadingInProgress, true); Notify().RefreshMenu(); //Try to load the passed N64 rom if (g_Rom == NULL) { - WriteTrace(TraceDebug,__FUNCTION__ ": Allocating global rom object"); + WriteTrace(TraceDebug, __FUNCTION__ ": Allocating global rom object"); g_Rom = new CN64Rom(); - } - else + } + else { - WriteTrace(TraceDebug,__FUNCTION__ ": Use existing global rom object"); + WriteTrace(TraceDebug, __FUNCTION__ ": Use existing global rom object"); } - WriteTraceF(TraceDebug,__FUNCTION__ ": Loading \"%s\"",FileLoc); - if (g_Rom->LoadN64Image(FileLoc)) + WriteTraceF(TraceDebug, __FUNCTION__ ": Loading \"%s\"", FileLoc); + if (g_Rom->LoadN64Image(FileLoc)) { g_System->RefreshGameSettings(); - WriteTrace(TraceDebug,__FUNCTION__ ": Add Recent Rom"); + WriteTrace(TraceDebug, __FUNCTION__ ": Add Recent Rom"); Notify().AddRecentRom(FileLoc); Notify().SetWindowCaption(g_Settings->LoadStringVal(Game_GoodName).ToUTF16().c_str()); @@ -219,7 +219,7 @@ bool CN64System::RunFileImage ( const char * FileLoc ) if (g_Settings->LoadDword(Setting_AutoStart) != 0) { - g_BaseSystem = new CN64System(g_Plugins,false); + g_BaseSystem = new CN64System(g_Plugins, false); if (g_BaseSystem) { g_BaseSystem->StartEmulation(true); @@ -228,11 +228,11 @@ bool CN64System::RunFileImage ( const char * FileLoc ) } else { - WriteTraceF(TraceError,__FUNCTION__ ": LoadN64Image failed (\"%s\")",FileLoc); + WriteTraceF(TraceError, __FUNCTION__ ": LoadN64Image failed (\"%s\")", FileLoc); g_Notify->DisplayError(g_Rom->GetError()); delete g_Rom; g_Rom = NULL; - g_Settings->SaveBool(GameRunning_LoadingInProgress,false); + g_Settings->SaveBool(GameRunning_LoadingInProgress, false); Notify().RefreshMenu(); return false; } @@ -249,52 +249,52 @@ void CN64System::CloseSystem() } } -bool CN64System::EmulationStarting ( HANDLE hThread, DWORD ThreadId ) +bool CN64System::EmulationStarting(HANDLE hThread, DWORD ThreadId) { bool bRes = true; WriteTrace(TraceDebug, __FUNCTION__ ": Setting N64 system as active"); if (g_BaseSystem->SetActiveSystem(true)) { - g_BaseSystem->m_CPU_Handle = hThread; + g_BaseSystem->m_CPU_Handle = hThread; g_BaseSystem->m_CPU_ThreadID = ThreadId; - WriteTrace(TraceDebug,__FUNCTION__ ": Setting up N64 system done"); - g_Settings->SaveBool(GameRunning_LoadingInProgress,false); + WriteTrace(TraceDebug, __FUNCTION__ ": Setting up N64 system done"); + g_Settings->SaveBool(GameRunning_LoadingInProgress, false); Notify().RefreshMenu(); try { - WriteTrace(TraceDebug,__FUNCTION__ ": Game set to auto start, starting"); - g_BaseSystem->StartEmulation2(false); - WriteTrace(TraceDebug,__FUNCTION__ ": Game Done"); - } + WriteTrace(TraceDebug, __FUNCTION__ ": Game set to auto start, starting"); + g_BaseSystem->StartEmulation2(false); + WriteTrace(TraceDebug, __FUNCTION__ ": Game Done"); + } catch (...) { - WriteTraceF(TraceError,__FUNCTION__ ": Exception caught\nFile: %s\nLine: %d",__FILE__,__LINE__); + WriteTraceF(TraceError, __FUNCTION__ ": Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__); char Message[600]; - sprintf(Message,__FUNCTION__ ": Exception caught\nFile: %s\nLine: %d",__FILE__,__LINE__); - MessageBox(NULL,Message,"Exception",MB_OK); + sprintf(Message, __FUNCTION__ ": Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__); + MessageBox(NULL, Message, "Exception", MB_OK); } } - else + else { - WriteTrace(TraceError,__FUNCTION__ ": SetActiveSystem failed"); + WriteTrace(TraceError, __FUNCTION__ ": SetActiveSystem failed"); g_Notify->DisplayError(__FUNCTIONW__ L": Failed to Initialize N64 System"); - g_Settings->SaveBool(GameRunning_LoadingInProgress,false); + g_Settings->SaveBool(GameRunning_LoadingInProgress, false); Notify().RefreshMenu(); bRes = false; } return bRes; } - -void CN64System::StartEmulation2 ( bool NewThread ) + +void CN64System::StartEmulation2(bool NewThread) { if (NewThread) { - WriteTrace(TraceDebug,__FUNCTION__ ": Starting"); + WriteTrace(TraceDebug, __FUNCTION__ ": Starting"); Notify().HideRomBrowser(); - if (bHaveDebugger()) + if (bHaveDebugger()) { g_LogOptions.GenerateLog = g_Settings->LoadBool(Debugger_GenerateDebugLog); LoadLogOptions(&g_LogOptions, FALSE); @@ -305,7 +305,7 @@ void CN64System::StartEmulation2 ( bool NewThread ) DWORD CpuType = g_Settings->LoadDword(Game_CpuType); - if(CpuType == CPU_SyncCores && !g_Settings->LoadBool(Debugger_Enabled)) + if (CpuType == CPU_SyncCores && !g_Settings->LoadBool(Debugger_Enabled)) { g_Settings->SaveDword(Game_CpuType, CPU_Recompiler); CpuType = CPU_Recompiler; @@ -313,12 +313,12 @@ void CN64System::StartEmulation2 ( bool NewThread ) if (CpuType == CPU_SyncCores) { - g_Notify->DisplayMessage(5,L"Copy Plugins"); + g_Notify->DisplayMessage(5, L"Copy Plugins"); g_Plugins->CopyPlugins(g_Settings->LoadStringVal(Directory_PluginSync)); #if defined(WINDOWS_UI) m_SyncWindow = new CMainGui(false); - m_SyncPlugins = new CPlugins( g_Settings->LoadStringVal(Directory_PluginSync) ); - m_SyncPlugins->SetRenderWindows(m_SyncWindow,m_SyncWindow); + m_SyncPlugins = new CPlugins(g_Settings->LoadStringVal(Directory_PluginSync)); + m_SyncPlugins->SetRenderWindows(m_SyncWindow, m_SyncWindow); m_SyncCPU = new CN64System(m_SyncPlugins, true); #else @@ -328,7 +328,7 @@ void CN64System::StartEmulation2 ( bool NewThread ) if (CpuType == CPU_Recompiler || CpuType == CPU_SyncCores) { - m_Recomp = new CRecompiler(m_Reg,m_Profile,m_EndEmulation); + m_Recomp = new CRecompiler(m_Reg, m_Profile, m_EndEmulation); } bool bSetActive = true; @@ -344,7 +344,7 @@ void CN64System::StartEmulation2 ( bool NewThread ) if (!bSetActive) { - g_Settings->SaveBool(GameRunning_LoadingInProgress,false); + g_Settings->SaveBool(GameRunning_LoadingInProgress, false); g_Notify->DisplayError(MSG_PLUGIN_NOT_INIT); Notify().RefreshMenu(); @@ -360,23 +360,23 @@ void CN64System::StartEmulation2 ( bool NewThread ) //create the needed info into a structure to pass as one parameter //for creating a thread Info->ThreadHandle = hThread; - - *hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)StartEmulationThread,Info,0, &Info->ThreadID); + + *hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)StartEmulationThread, Info, 0, &Info->ThreadID); } - else + else { //mark the emulation as starting and fix up menus - g_Notify->DisplayMessage(5,MSG_EMULATION_STARTED); + g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED); - if (g_Settings->LoadBool(Setting_AutoFullscreen)) + if (g_Settings->LoadBool(Setting_AutoFullscreen)) { - WriteTrace(TraceDebug,__FUNCTION__ " 15"); + WriteTrace(TraceDebug, __FUNCTION__ " 15"); CIniFile RomIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str()); stdstr Status = g_Settings->LoadStringVal(Rdb_Status); char String[100]; - RomIniFile.GetString("Rom Status",stdstr_f("%s.AutoFullScreen", Status.c_str()).c_str(),"true",String,sizeof(String)); - if (_stricmp(String,"true") == 0) + RomIniFile.GetString("Rom Status", stdstr_f("%s.AutoFullScreen", Status.c_str()).c_str(), "true", String, sizeof(String)); + if (_stricmp(String, "true") == 0) { Notify().ChangeFullScreen(); } @@ -385,25 +385,25 @@ void CN64System::StartEmulation2 ( bool NewThread ) } } -void CN64System::StartEmulation ( bool NewThread ) +void CN64System::StartEmulation(bool NewThread) { - __try + __try { StartEmulation2(NewThread); } - __except( g_MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation())) + __except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation())) { char Message[600]; - sprintf(Message,"Exception caught\nFile: %s\nLine: %d",__FILE__,__LINE__); - MessageBox(NULL,Message,"Exception",MB_OK); + sprintf(Message, "Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__); + MessageBox(NULL, Message, "Exception", MB_OK); } } -void CN64System::StartEmulationThread ( ThreadInfo * Info ) +void CN64System::StartEmulationThread(ThreadInfo * Info) { CoInitialize(NULL); - - EmulationStarting(*Info->ThreadHandle,Info->ThreadID); + + EmulationStarting(*Info->ThreadHandle, Info->ThreadID); delete Info->ThreadHandle; delete Info; @@ -412,9 +412,9 @@ void CN64System::StartEmulationThread ( ThreadInfo * Info ) void CN64System::CloseCpu() { - if (m_CPU_Handle == NULL) + if (m_CPU_Handle == NULL) { - return; + return; } m_EndEmulation = true; @@ -422,26 +422,26 @@ void CN64System::CloseCpu() { SetEvent(m_hPauseEvent); } - + if (GetCurrentThreadId() == m_CPU_ThreadID) { ExternalEvent(SysEvent_CloseCPU); return; } - + HANDLE hThread = m_CPU_Handle; - for (int count = 0; count < 200; count ++ ) + for (int count = 0; count < 200; count++) { Sleep(100); if (Notify().ProcessGuiMessages()) { return; } - + DWORD ExitCode; - if (GetExitCodeThread(hThread,&ExitCode)) + if (GetExitCodeThread(hThread, &ExitCode)) { - if (ExitCode != STILL_ACTIVE) + if (ExitCode != STILL_ACTIVE) { break; } @@ -449,21 +449,21 @@ void CN64System::CloseCpu() } if (hThread) - { + { DWORD ExitCode; - GetExitCodeThread(hThread,&ExitCode); - if (ExitCode == STILL_ACTIVE) + GetExitCodeThread(hThread, &ExitCode); + if (ExitCode == STILL_ACTIVE) { - TerminateThread(hThread,0); + TerminateThread(hThread, 0); } } CpuStopped(); } -void CN64System::DisplayRomInfo ( HWND hParent ) +void CN64System::DisplayRomInfo(HWND hParent) { if (!g_Rom) { return; } - + RomInformation Info(g_Rom); Info.DisplayInformation(hParent); } @@ -475,36 +475,36 @@ void CN64System::Pause() return; } ResetEvent(m_hPauseEvent); - g_Settings->SaveBool(GameRunning_CPU_Paused,true); + g_Settings->SaveBool(GameRunning_CPU_Paused, true); Notify().RefreshMenu(); - g_Notify->DisplayMessage(5,MSG_CPU_PAUSED); + g_Notify->DisplayMessage(5, MSG_CPU_PAUSED); WaitForSingleObject(m_hPauseEvent, INFINITE); ResetEvent(m_hPauseEvent); - g_Settings->SaveBool(GameRunning_CPU_Paused,(DWORD)false); + g_Settings->SaveBool(GameRunning_CPU_Paused, (DWORD)false); Notify().RefreshMenu(); Notify().DisplayMessage(5, MSG_CPU_RESUMED); } -stdstr CN64System::ChooseFileToOpen ( HWND hParent ) +stdstr CN64System::ChooseFileToOpen(HWND hParent) { OPENFILENAME openfilename; - char FileName[_MAX_PATH],Directory[_MAX_PATH]; + char FileName[_MAX_PATH], Directory[_MAX_PATH]; memset(&FileName, 0, sizeof(FileName)); memset(&openfilename, 0, sizeof(openfilename)); - strcpy(Directory,g_Settings->LoadStringVal(Directory_Game).c_str()); + strcpy(Directory, g_Settings->LoadStringVal(Directory_Game).c_str()); - openfilename.lStructSize = sizeof( openfilename ); - openfilename.hwndOwner = (HWND)hParent; + openfilename.lStructSize = sizeof(openfilename); + openfilename.hwndOwner = (HWND)hParent; openfilename.lpstrFilter = "N64 ROMs (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0"; - openfilename.lpstrFile = FileName; - openfilename.lpstrInitialDir = Directory; - openfilename.nMaxFile = MAX_PATH; - openfilename.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; + openfilename.lpstrFile = FileName; + openfilename.lpstrInitialDir = Directory; + openfilename.nMaxFile = MAX_PATH; + openfilename.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; - if (GetOpenFileName (&openfilename)) - { + if (GetOpenFileName(&openfilename)) + { return stdstr(FileName); } return stdstr(""); @@ -512,7 +512,7 @@ stdstr CN64System::ChooseFileToOpen ( HWND hParent ) void CN64System::GameReset() { - m_SystemTimer.SetTimer(CSystemTimer::SoftResetTimer,0x3000000,false); + m_SystemTimer.SetTimer(CSystemTimer::SoftResetTimer, 0x3000000, false); m_Plugins->Gfx()->ShowCFB(); m_Reg.FAKE_CAUSE_REGISTER |= CAUSE_IP4; m_Plugins->Gfx()->SoftReset(); @@ -526,7 +526,7 @@ void CN64System::PluginReset() { if (!m_Plugins->ResetInUiThread(this)) { - g_Notify->DisplayMessage(5,MSG_PLUGIN_NOT_INIT); + g_Notify->DisplayMessage(5, MSG_PLUGIN_NOT_INIT); if (g_BaseSystem) { g_BaseSystem->m_EndEmulation = true; @@ -536,7 +536,7 @@ void CN64System::PluginReset() { if (!m_SyncCPU->m_Plugins->ResetInUiThread(m_SyncCPU)) { - g_Notify->DisplayMessage(5,MSG_PLUGIN_NOT_INIT); + g_Notify->DisplayMessage(5, MSG_PLUGIN_NOT_INIT); if (g_BaseSystem) { g_BaseSystem->m_EndEmulation = true; @@ -558,23 +558,23 @@ void CN64System::PluginReset() #endif } -void CN64System::Reset (bool bInitReg, bool ClearMenory) +void CN64System::Reset(bool bInitReg, bool ClearMenory) { - g_Settings->SaveBool(GameRunning_InReset,true); + g_Settings->SaveBool(GameRunning_InReset, true); RefreshGameSettings(); m_Audio.Reset(); m_MMU_VM.Reset(ClearMenory); Mempak::Close(); m_CyclesToSkip = 0; - m_AlistCount = 0; - m_DlistCount = 0; + m_AlistCount = 0; + m_DlistCount = 0; m_UnknownCount = 0; - m_DMAUsed = false; - m_RspBroke = true; - m_SyncCount = 0; + m_DMAUsed = false; + m_RspBroke = true; + m_SyncCount = 0; - for (int i = 0, n = (sizeof(m_LastSuccessSyncPC)/sizeof(m_LastSuccessSyncPC[0])); i < n; i++) + for (int i = 0, n = (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])); i < n; i++) { m_LastSuccessSyncPC[i] = 0; } @@ -582,20 +582,20 @@ void CN64System::Reset (bool bInitReg, bool ClearMenory) if (bInitReg) { bool PostPif = true; - - InitRegisters(PostPif,m_MMU_VM); - if (PostPif) + + InitRegisters(PostPif, m_MMU_VM); + if (PostPif) { - memcpy((m_MMU_VM.Dmem()+0x40), (g_Rom->GetRomAddress() + 0x040), 0xFBC); + memcpy((m_MMU_VM.Dmem() + 0x40), (g_Rom->GetRomAddress() + 0x040), 0xFBC); } } - else + else { m_Reg.Reset(); } m_SystemTimer.Reset(); - m_SystemTimer.SetTimer(CSystemTimer::CompareTimer,m_Reg.COMPARE_REGISTER - m_Reg.COUNT_REGISTER,false); + m_SystemTimer.SetTimer(CSystemTimer::CompareTimer, m_Reg.COMPARE_REGISTER - m_Reg.COUNT_REGISTER, false); if (m_Recomp) { @@ -604,12 +604,12 @@ void CN64System::Reset (bool bInitReg, bool ClearMenory) if (m_Plugins) { m_Plugins->GameReset(); } if (m_SyncCPU) { - m_SyncCPU->Reset(bInitReg,ClearMenory); + m_SyncCPU->Reset(bInitReg, ClearMenory); } - g_Settings->SaveBool(GameRunning_InReset,true); + g_Settings->SaveBool(GameRunning_InReset, true); } -bool CN64System::SetActiveSystem( bool bActive ) +bool CN64System::SetActiveSystem(bool bActive) { bool bInitPlugin = false; bool bReset = false; @@ -621,7 +621,7 @@ bool CN64System::SetActiveSystem( bool bActive ) } if (bActive) - { + { m_Reg.SetAsCurrentSystem(); if (g_System) @@ -631,21 +631,21 @@ bool CN64System::SetActiveSystem( bool bActive ) g_System->m_JumpToLocation = R4300iOp::m_JumpToLocation; } - g_System = this; + g_System = this; if (g_BaseSystem == this) { - g_SyncSystem = m_SyncCPU; + g_SyncSystem = m_SyncCPU; } - g_Recompiler = m_Recomp; - g_MMU = &m_MMU_VM; - g_TLB = &m_TLB; - g_Reg = &m_Reg; - g_Audio = &m_Audio; - g_SystemTimer = &m_SystemTimer; - g_TransVaddr = &m_MMU_VM; + g_Recompiler = m_Recomp; + g_MMU = &m_MMU_VM; + g_TLB = &m_TLB; + g_Reg = &m_Reg; + g_Audio = &m_Audio; + g_SystemTimer = &m_SystemTimer; + g_TransVaddr = &m_MMU_VM; g_SystemEvents = this; - g_NextTimer = &m_NextTimer; - g_Plugins = m_Plugins; + g_NextTimer = &m_NextTimer; + g_Plugins = m_Plugins; g_TLBLoadAddress = &m_TLBLoadAddress; g_TLBStoreAddress = &m_TLBStoreAddress; R4300iOp::m_TestTimer = m_TestTimer; @@ -667,27 +667,27 @@ bool CN64System::SetActiveSystem( bool bActive ) { if (this == g_BaseSystem) { - g_System = NULL; - g_SyncSystem = NULL; - g_Recompiler = NULL; - g_MMU = NULL; - g_TLB = NULL; - g_Reg = NULL; - g_Audio = NULL; - g_SystemTimer = NULL; - g_TransVaddr = NULL; - g_SystemEvents = NULL; - g_NextTimer = NULL; - g_Plugins = m_Plugins; - g_TLBLoadAddress = NULL; + g_System = NULL; + g_SyncSystem = NULL; + g_Recompiler = NULL; + g_MMU = NULL; + g_TLB = NULL; + g_Reg = NULL; + g_Audio = NULL; + g_SystemTimer = NULL; + g_TransVaddr = NULL; + g_SystemEvents = NULL; + g_NextTimer = NULL; + g_Plugins = m_Plugins; + g_TLBLoadAddress = NULL; g_TLBStoreAddress = NULL; } } if (bInitPlugin) { - WriteTrace(TraceDebug,__FUNCTION__ ": Reseting Plugins"); - g_Notify->DisplayMessage(5,MSG_PLUGIN_INIT); + WriteTrace(TraceDebug, __FUNCTION__ ": Reseting Plugins"); + g_Notify->DisplayMessage(5, MSG_PLUGIN_INIT); m_Plugins->CreatePlugins(); bRes = m_Plugins->Initiate(this); if (!bRes) @@ -698,53 +698,53 @@ bool CN64System::SetActiveSystem( bool bActive ) if (bReset) { - Reset(true,true); + Reset(true, true); } return bRes; } -void CN64System::InitRegisters( bool bPostPif, CMipsMemory & MMU ) +void CN64System::InitRegisters(bool bPostPif, CMipsMemory & MMU) { m_Reg.Reset(); //COP0 Registers - m_Reg.RANDOM_REGISTER = 0x1F; - m_Reg.COUNT_REGISTER = 0x5000; - m_Reg.MI_VERSION_REG = 0x02020102; - m_Reg.SP_STATUS_REG = 0x00000001; - m_Reg.CAUSE_REGISTER = 0x0000005C; - m_Reg.CONTEXT_REGISTER = 0x007FFFF0; - m_Reg.EPC_REGISTER = 0xFFFFFFFF; - m_Reg.BAD_VADDR_REGISTER = 0xFFFFFFFF; - m_Reg.ERROREPC_REGISTER = 0xFFFFFFFF; - m_Reg.CONFIG_REGISTER = 0x0006E463; - m_Reg.STATUS_REGISTER = 0x34000000; + m_Reg.RANDOM_REGISTER = 0x1F; + m_Reg.COUNT_REGISTER = 0x5000; + m_Reg.MI_VERSION_REG = 0x02020102; + m_Reg.SP_STATUS_REG = 0x00000001; + m_Reg.CAUSE_REGISTER = 0x0000005C; + m_Reg.CONTEXT_REGISTER = 0x007FFFF0; + m_Reg.EPC_REGISTER = 0xFFFFFFFF; + m_Reg.BAD_VADDR_REGISTER = 0xFFFFFFFF; + m_Reg.ERROREPC_REGISTER = 0xFFFFFFFF; + m_Reg.CONFIG_REGISTER = 0x0006E463; + m_Reg.STATUS_REGISTER = 0x34000000; //m_Reg.REVISION_REGISTER = 0x00000511; m_Reg.FixFpuLocations(); - if (bPostPif) + if (bPostPif) { - m_Reg.m_PROGRAM_COUNTER = 0xA4000040; - - m_Reg.m_GPR[0].DW=0x0000000000000000; - m_Reg.m_GPR[6].DW=0xFFFFFFFFA4001F0C; - m_Reg.m_GPR[7].DW=0xFFFFFFFFA4001F08; - m_Reg.m_GPR[8].DW=0x00000000000000C0; - m_Reg.m_GPR[9].DW=0x0000000000000000; - m_Reg.m_GPR[10].DW=0x0000000000000040; - m_Reg.m_GPR[11].DW=0xFFFFFFFFA4000040; - m_Reg.m_GPR[16].DW=0x0000000000000000; - m_Reg.m_GPR[17].DW=0x0000000000000000; - m_Reg.m_GPR[18].DW=0x0000000000000000; - m_Reg.m_GPR[19].DW=0x0000000000000000; - m_Reg.m_GPR[21].DW=0x0000000000000000; - m_Reg.m_GPR[26].DW=0x0000000000000000; - m_Reg.m_GPR[27].DW=0x0000000000000000; - m_Reg.m_GPR[28].DW=0x0000000000000000; - m_Reg.m_GPR[29].DW=0xFFFFFFFFA4001FF0; - m_Reg.m_GPR[30].DW=0x0000000000000000; - + m_Reg.m_PROGRAM_COUNTER = 0xA4000040; + + m_Reg.m_GPR[0].DW = 0x0000000000000000; + m_Reg.m_GPR[6].DW = 0xFFFFFFFFA4001F0C; + m_Reg.m_GPR[7].DW = 0xFFFFFFFFA4001F08; + m_Reg.m_GPR[8].DW = 0x00000000000000C0; + m_Reg.m_GPR[9].DW = 0x0000000000000000; + m_Reg.m_GPR[10].DW = 0x0000000000000040; + m_Reg.m_GPR[11].DW = 0xFFFFFFFFA4000040; + m_Reg.m_GPR[16].DW = 0x0000000000000000; + m_Reg.m_GPR[17].DW = 0x0000000000000000; + m_Reg.m_GPR[18].DW = 0x0000000000000000; + m_Reg.m_GPR[19].DW = 0x0000000000000000; + m_Reg.m_GPR[21].DW = 0x0000000000000000; + m_Reg.m_GPR[26].DW = 0x0000000000000000; + m_Reg.m_GPR[27].DW = 0x0000000000000000; + m_Reg.m_GPR[28].DW = 0x0000000000000000; + m_Reg.m_GPR[29].DW = 0xFFFFFFFFA4001FF0; + m_Reg.m_GPR[30].DW = 0x0000000000000000; + switch (g_Rom->GetCountry()) { case Germany: case french: case Italian: @@ -754,145 +754,145 @@ void CN64System::InitRegisters( bool bPostPif, CMipsMemory & MMU ) { case CIC_UNKNOWN: case CIC_NUS_6102: - m_Reg.m_GPR[5].DW=0xFFFFFFFFC0F1D859; - m_Reg.m_GPR[14].DW=0x000000002DE108EA; - m_Reg.m_GPR[24].DW=0x0000000000000000; + m_Reg.m_GPR[5].DW = 0xFFFFFFFFC0F1D859; + m_Reg.m_GPR[14].DW = 0x000000002DE108EA; + m_Reg.m_GPR[24].DW = 0x0000000000000000; break; case CIC_NUS_6103: - m_Reg.m_GPR[5].DW=0xFFFFFFFFD4646273; - m_Reg.m_GPR[14].DW=0x000000001AF99984; - m_Reg.m_GPR[24].DW=0x0000000000000000; + m_Reg.m_GPR[5].DW = 0xFFFFFFFFD4646273; + m_Reg.m_GPR[14].DW = 0x000000001AF99984; + m_Reg.m_GPR[24].DW = 0x0000000000000000; break; case CIC_NUS_6105: - MMU.SW_VAddr(0xA4001004,0xBDA807FC); - m_Reg.m_GPR[5].DW=0xFFFFFFFFDECAAAD1; - m_Reg.m_GPR[14].DW=0x000000000CF85C13; - m_Reg.m_GPR[24].DW=0x0000000000000002; + MMU.SW_VAddr(0xA4001004, 0xBDA807FC); + m_Reg.m_GPR[5].DW = 0xFFFFFFFFDECAAAD1; + m_Reg.m_GPR[14].DW = 0x000000000CF85C13; + m_Reg.m_GPR[24].DW = 0x0000000000000002; break; case CIC_NUS_6106: - m_Reg.m_GPR[5].DW=0xFFFFFFFFB04DC903; - m_Reg.m_GPR[14].DW=0x000000001AF99984; - m_Reg.m_GPR[24].DW=0x0000000000000002; + m_Reg.m_GPR[5].DW = 0xFFFFFFFFB04DC903; + m_Reg.m_GPR[14].DW = 0x000000001AF99984; + m_Reg.m_GPR[24].DW = 0x0000000000000002; break; } - m_Reg.m_GPR[20].DW=0x0000000000000000; - m_Reg.m_GPR[23].DW=0x0000000000000006; - m_Reg.m_GPR[31].DW=0xFFFFFFFFA4001554; + m_Reg.m_GPR[20].DW = 0x0000000000000000; + m_Reg.m_GPR[23].DW = 0x0000000000000006; + m_Reg.m_GPR[31].DW = 0xFFFFFFFFA4001554; break; case NTSC_BETA: case X_NTSC: case USA: case Japan: default: - switch (g_Rom->CicChipID()) + switch (g_Rom->CicChipID()) { case CIC_UNKNOWN: case CIC_NUS_6102: - m_Reg.m_GPR[5].DW=0xFFFFFFFFC95973D5; - m_Reg.m_GPR[14].DW=0x000000002449A366; + m_Reg.m_GPR[5].DW = 0xFFFFFFFFC95973D5; + m_Reg.m_GPR[14].DW = 0x000000002449A366; break; case CIC_NUS_6103: - m_Reg.m_GPR[5].DW=0xFFFFFFFF95315A28; - m_Reg.m_GPR[14].DW=0x000000005BACA1DF; + m_Reg.m_GPR[5].DW = 0xFFFFFFFF95315A28; + m_Reg.m_GPR[14].DW = 0x000000005BACA1DF; break; case CIC_NUS_6105: - MMU.SW_VAddr(0xA4001004,0x8DA807FC); - m_Reg.m_GPR[5].DW=0x000000005493FB9A; - m_Reg.m_GPR[14].DW=0xFFFFFFFFC2C20384; + MMU.SW_VAddr(0xA4001004, 0x8DA807FC); + m_Reg.m_GPR[5].DW = 0x000000005493FB9A; + m_Reg.m_GPR[14].DW = 0xFFFFFFFFC2C20384; case CIC_NUS_6106: - m_Reg.m_GPR[5].DW=0xFFFFFFFFE067221F; - m_Reg.m_GPR[14].DW=0x000000005CD2B70F; + m_Reg.m_GPR[5].DW = 0xFFFFFFFFE067221F; + m_Reg.m_GPR[14].DW = 0x000000005CD2B70F; break; } - m_Reg.m_GPR[20].DW=0x0000000000000001; - m_Reg.m_GPR[23].DW=0x0000000000000000; - m_Reg.m_GPR[24].DW=0x0000000000000003; - m_Reg.m_GPR[31].DW=0xFFFFFFFFA4001550; + m_Reg.m_GPR[20].DW = 0x0000000000000001; + m_Reg.m_GPR[23].DW = 0x0000000000000000; + m_Reg.m_GPR[24].DW = 0x0000000000000003; + m_Reg.m_GPR[31].DW = 0xFFFFFFFFA4001550; } switch (g_Rom->CicChipID()) { - case CIC_NUS_6101: - m_Reg.m_GPR[22].DW=0x000000000000003F; + case CIC_NUS_6101: + m_Reg.m_GPR[22].DW = 0x000000000000003F; break; case CIC_NUS_8303: //64DD IPL CIC case CIC_NUS_5167: //64DD CONVERSION CIC - m_Reg.m_GPR[22].DW=0x00000000000000DD; + m_Reg.m_GPR[22].DW = 0x00000000000000DD; break; case CIC_UNKNOWN: - case CIC_NUS_6102: - m_Reg.m_GPR[1].DW=0x0000000000000001; - m_Reg.m_GPR[2].DW=0x000000000EBDA536; - m_Reg.m_GPR[3].DW=0x000000000EBDA536; - m_Reg.m_GPR[4].DW=0x000000000000A536; - m_Reg.m_GPR[12].DW=0xFFFFFFFFED10D0B3; - m_Reg.m_GPR[13].DW=0x000000001402A4CC; - m_Reg.m_GPR[15].DW=0x000000003103E121; - m_Reg.m_GPR[22].DW=0x000000000000003F; - m_Reg.m_GPR[25].DW=0xFFFFFFFF9DEBB54F; + case CIC_NUS_6102: + m_Reg.m_GPR[1].DW = 0x0000000000000001; + m_Reg.m_GPR[2].DW = 0x000000000EBDA536; + m_Reg.m_GPR[3].DW = 0x000000000EBDA536; + m_Reg.m_GPR[4].DW = 0x000000000000A536; + m_Reg.m_GPR[12].DW = 0xFFFFFFFFED10D0B3; + m_Reg.m_GPR[13].DW = 0x000000001402A4CC; + m_Reg.m_GPR[15].DW = 0x000000003103E121; + m_Reg.m_GPR[22].DW = 0x000000000000003F; + m_Reg.m_GPR[25].DW = 0xFFFFFFFF9DEBB54F; break; - case CIC_NUS_6103: - m_Reg.m_GPR[1].DW=0x0000000000000001; - m_Reg.m_GPR[2].DW=0x0000000049A5EE96; - m_Reg.m_GPR[3].DW=0x0000000049A5EE96; - m_Reg.m_GPR[4].DW=0x000000000000EE96; - m_Reg.m_GPR[12].DW=0xFFFFFFFFCE9DFBF7; - m_Reg.m_GPR[13].DW=0xFFFFFFFFCE9DFBF7; - m_Reg.m_GPR[15].DW=0x0000000018B63D28; - m_Reg.m_GPR[22].DW=0x0000000000000078; - m_Reg.m_GPR[25].DW=0xFFFFFFFF825B21C9; + case CIC_NUS_6103: + m_Reg.m_GPR[1].DW = 0x0000000000000001; + m_Reg.m_GPR[2].DW = 0x0000000049A5EE96; + m_Reg.m_GPR[3].DW = 0x0000000049A5EE96; + m_Reg.m_GPR[4].DW = 0x000000000000EE96; + m_Reg.m_GPR[12].DW = 0xFFFFFFFFCE9DFBF7; + m_Reg.m_GPR[13].DW = 0xFFFFFFFFCE9DFBF7; + m_Reg.m_GPR[15].DW = 0x0000000018B63D28; + m_Reg.m_GPR[22].DW = 0x0000000000000078; + m_Reg.m_GPR[25].DW = 0xFFFFFFFF825B21C9; break; - case CIC_NUS_6105: - MMU.SW_VAddr(0xA4001000,0x3C0DBFC0); - MMU.SW_VAddr(0xA4001008,0x25AD07C0); - MMU.SW_VAddr(0xA400100C,0x31080080); - MMU.SW_VAddr(0xA4001010,0x5500FFFC); - MMU.SW_VAddr(0xA4001014,0x3C0DBFC0); - MMU.SW_VAddr(0xA4001018,0x8DA80024); - MMU.SW_VAddr(0xA400101C,0x3C0BB000); - m_Reg.m_GPR[1].DW=0x0000000000000000; - m_Reg.m_GPR[2].DW=0xFFFFFFFFF58B0FBF; - m_Reg.m_GPR[3].DW=0xFFFFFFFFF58B0FBF; - m_Reg.m_GPR[4].DW=0x0000000000000FBF; - m_Reg.m_GPR[12].DW=0xFFFFFFFF9651F81E; - m_Reg.m_GPR[13].DW=0x000000002D42AAC5; - m_Reg.m_GPR[15].DW=0x0000000056584D60; - m_Reg.m_GPR[22].DW=0x0000000000000091; - m_Reg.m_GPR[25].DW=0xFFFFFFFFCDCE565F; + case CIC_NUS_6105: + MMU.SW_VAddr(0xA4001000, 0x3C0DBFC0); + MMU.SW_VAddr(0xA4001008, 0x25AD07C0); + MMU.SW_VAddr(0xA400100C, 0x31080080); + MMU.SW_VAddr(0xA4001010, 0x5500FFFC); + MMU.SW_VAddr(0xA4001014, 0x3C0DBFC0); + MMU.SW_VAddr(0xA4001018, 0x8DA80024); + MMU.SW_VAddr(0xA400101C, 0x3C0BB000); + m_Reg.m_GPR[1].DW = 0x0000000000000000; + m_Reg.m_GPR[2].DW = 0xFFFFFFFFF58B0FBF; + m_Reg.m_GPR[3].DW = 0xFFFFFFFFF58B0FBF; + m_Reg.m_GPR[4].DW = 0x0000000000000FBF; + m_Reg.m_GPR[12].DW = 0xFFFFFFFF9651F81E; + m_Reg.m_GPR[13].DW = 0x000000002D42AAC5; + m_Reg.m_GPR[15].DW = 0x0000000056584D60; + m_Reg.m_GPR[22].DW = 0x0000000000000091; + m_Reg.m_GPR[25].DW = 0xFFFFFFFFCDCE565F; break; - case CIC_NUS_6106: - m_Reg.m_GPR[1].DW=0x0000000000000000; - m_Reg.m_GPR[2].DW=0xFFFFFFFFA95930A4; - m_Reg.m_GPR[3].DW=0xFFFFFFFFA95930A4; - m_Reg.m_GPR[4].DW=0x00000000000030A4; - m_Reg.m_GPR[12].DW=0xFFFFFFFFBCB59510; - m_Reg.m_GPR[13].DW=0xFFFFFFFFBCB59510; - m_Reg.m_GPR[15].DW=0x000000007A3C07F4; - m_Reg.m_GPR[22].DW=0x0000000000000085; - m_Reg.m_GPR[25].DW=0x00000000465E3F72; + case CIC_NUS_6106: + m_Reg.m_GPR[1].DW = 0x0000000000000000; + m_Reg.m_GPR[2].DW = 0xFFFFFFFFA95930A4; + m_Reg.m_GPR[3].DW = 0xFFFFFFFFA95930A4; + m_Reg.m_GPR[4].DW = 0x00000000000030A4; + m_Reg.m_GPR[12].DW = 0xFFFFFFFFBCB59510; + m_Reg.m_GPR[13].DW = 0xFFFFFFFFBCB59510; + m_Reg.m_GPR[15].DW = 0x000000007A3C07F4; + m_Reg.m_GPR[22].DW = 0x0000000000000085; + m_Reg.m_GPR[25].DW = 0x00000000465E3F72; break; } } else { - m_Reg.m_PROGRAM_COUNTER = 0xBFC00000; -/* PIF_Ram[36] = 0x00; PIF_Ram[39] = 0x3F; //common pif ram start values + m_Reg.m_PROGRAM_COUNTER = 0xBFC00000; + /* PIF_Ram[36] = 0x00; PIF_Ram[39] = 0x3F; //common pif ram start values - switch (g_Rom->CicChipID()) { - case CIC_NUS_6101: PIF_Ram[37] = 0x06; PIF_Ram[38] = 0x3F; break; - case CIC_UNKNOWN: - case CIC_NUS_6102: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x3F; break; - case CIC_NUS_6103: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x78; break; - case CIC_NUS_6105: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x91; break; - case CIC_NUS_6106: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x85; break; - }*/ + switch (g_Rom->CicChipID()) { + case CIC_NUS_6101: PIF_Ram[37] = 0x06; PIF_Ram[38] = 0x3F; break; + case CIC_UNKNOWN: + case CIC_NUS_6102: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x3F; break; + case CIC_NUS_6103: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x78; break; + case CIC_NUS_6105: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x91; break; + case CIC_NUS_6106: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x85; break; + }*/ } } void CN64System::ExecuteCPU() { //reset code - g_Settings->SaveBool(GameRunning_CPU_Running,true); - g_Settings->SaveBool(GameRunning_CPU_Paused,false); - g_Notify->DisplayMessage(5,MSG_EMULATION_STARTED); - + g_Settings->SaveBool(GameRunning_CPU_Running, true); + g_Settings->SaveBool(GameRunning_CPU_Paused, false); + g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED); + m_EndEmulation = false; Notify().RefreshMenu(); @@ -907,14 +907,14 @@ void CN64System::ExecuteCPU() switch ((CPU_TYPE)g_Settings->LoadDword(Game_CpuType)) { -// Currently the compiler is 32-bit only. We might have to ignore that RDB setting for now. + // Currently the compiler is 32-bit only. We might have to ignore that RDB setting for now. #ifndef _WIN64 case CPU_Recompiler: ExecuteRecompiler(); break; case CPU_SyncCores: ExecuteSyncCPU(); break; #endif default: ExecuteInterpret(); break; } - g_Settings->SaveBool(GameRunning_CPU_Running,(DWORD)false); + g_Settings->SaveBool(GameRunning_CPU_Running, (DWORD)false); Notify().WindowMode(); m_Plugins->RomClosed(); if (m_SyncCPU) @@ -930,7 +930,7 @@ void CN64System::ExecuteInterpret() } void CN64System::ExecuteRecompiler() -{ +{ m_Recomp->Run(); } @@ -942,7 +942,7 @@ void CN64System::ExecuteSyncCPU() void CN64System::CpuStopped() { - g_Settings->SaveBool(GameRunning_CPU_Running,(DWORD)false); + g_Settings->SaveBool(GameRunning_CPU_Running, (DWORD)false); Notify().WindowMode(); if (!m_InReset) { @@ -954,11 +954,11 @@ void CN64System::CpuStopped() Notify().RefreshMenu(); Notify().MakeWindowOnTop(false); - g_Notify->DisplayMessage(5,MSG_EMULATION_ENDED); + g_Notify->DisplayMessage(5, MSG_EMULATION_ENDED); if (g_Settings->LoadDword(RomBrowser_Enabled)) { Notify().ShowRomBrowser(); - } + } } if (m_SyncCPU) { @@ -966,30 +966,30 @@ void CN64System::CpuStopped() } } -void CN64System::UpdateSyncCPU (CN64System * const SecondCPU, DWORD const Cycles) +void CN64System::UpdateSyncCPU(CN64System * const SecondCPU, DWORD const Cycles) { int CyclesToExecute = Cycles - m_CyclesToSkip; - + //Update the number of cycles to skip m_CyclesToSkip -= Cycles; if (m_CyclesToSkip < 0) { m_CyclesToSkip = 0; } //Run the other CPU For the same amount of cycles if (CyclesToExecute < 0) { return; } - + SecondCPU->SetActiveSystem(true); - + CInterpreterCPU::ExecuteOps(Cycles); SetActiveSystem(true); } -void CN64System::SyncCPUPC (CN64System * const SecondCPU) +void CN64System::SyncCPUPC(CN64System * const SecondCPU) { bool ErrorFound = false; g_SystemTimer->UpdateTimers(); - if (m_Reg.m_PROGRAM_COUNTER != SecondCPU->m_Reg.m_PROGRAM_COUNTER) + if (m_Reg.m_PROGRAM_COUNTER != SecondCPU->m_Reg.m_PROGRAM_COUNTER) { ErrorFound = true; } @@ -1000,33 +1000,33 @@ void CN64System::SyncCPUPC (CN64System * const SecondCPU) if (ErrorFound) { DumpSyncErrors(SecondCPU); } - for (int i = (sizeof(m_LastSuccessSyncPC)/sizeof(m_LastSuccessSyncPC[0])) - 1; i > 0; i--) + for (int i = (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])) - 1; i > 0; i--) { m_LastSuccessSyncPC[i] = m_LastSuccessSyncPC[i - 1]; } m_LastSuccessSyncPC[0] = m_Reg.m_PROGRAM_COUNTER; } -void CN64System::SyncCPU (CN64System * const SecondCPU) +void CN64System::SyncCPU(CN64System * const SecondCPU) { bool ErrorFound = false; m_SyncCount += 1; //WriteTraceF(TraceError,"SyncCPU PC = %08X",m_Reg.m_PROGRAM_COUNTER); g_SystemTimer->UpdateTimers(); - + #ifdef TEST_SP_TRACKING if (m_CurrentSP != GPR[29].UW[0]) { ErrorFound = true; } #endif - if (m_Reg.m_PROGRAM_COUNTER != SecondCPU->m_Reg.m_PROGRAM_COUNTER) + if (m_Reg.m_PROGRAM_COUNTER != SecondCPU->m_Reg.m_PROGRAM_COUNTER) { ErrorFound = true; } if (b32BitCore()) { - for (int count = 0; count < 32; count ++) + for (int count = 0; count < 32; count++) { if (m_Reg.m_GPR[count].W[0] != SecondCPU->m_Reg.m_GPR[count].W[0]) { @@ -1044,13 +1044,13 @@ void CN64System::SyncCPU (CN64System * const SecondCPU) } else { - for (int count = 0; count < 32; count ++) + for (int count = 0; count < 32; count++) { if (m_Reg.m_GPR[count].DW != SecondCPU->m_Reg.m_GPR[count].DW) { ErrorFound = true; } - if (m_Reg.m_FPR[count].DW != SecondCPU->m_Reg.m_FPR[count].DW) + if (m_Reg.m_FPR[count].DW != SecondCPU->m_Reg.m_FPR[count].DW) { ErrorFound = true; } @@ -1060,7 +1060,7 @@ void CN64System::SyncCPU (CN64System * const SecondCPU) } } } - + if (m_TLB != SecondCPU->m_TLB) { ErrorFound = true; } if (m_Reg.m_FPCR[0] != SecondCPU->m_Reg.m_FPCR[0]) { ErrorFound = true; } if (m_Reg.m_FPCR[31] != SecondCPU->m_Reg.m_FPCR[31]) { ErrorFound = true; } @@ -1068,30 +1068,30 @@ void CN64System::SyncCPU (CN64System * const SecondCPU) if (m_Reg.m_LO.DW != SecondCPU->m_Reg.m_LO.DW) { ErrorFound = true; } /*if (m_SyncCount > 4788000) { - if (memcmp(m_MMU_VM.Rdram(),SecondCPU->m_MMU_VM.Rdram(),RdramSize()) != 0) - { - ErrorFound = true; - } - } - if (memcmp(m_MMU_VM.Imem(),SecondCPU->m_MMU_VM.Imem(),0x1000) != 0) + if (memcmp(m_MMU_VM.Rdram(),SecondCPU->m_MMU_VM.Rdram(),RdramSize()) != 0) { - ErrorFound = true; + ErrorFound = true; } - if (memcmp(m_MMU_VM.Dmem(),SecondCPU->m_MMU_VM.Dmem(),0x1000) != 0) + } + if (memcmp(m_MMU_VM.Imem(),SecondCPU->m_MMU_VM.Imem(),0x1000) != 0) { - ErrorFound = true; + ErrorFound = true; + } + if (memcmp(m_MMU_VM.Dmem(),SecondCPU->m_MMU_VM.Dmem(),0x1000) != 0) + { + ErrorFound = true; }*/ /*for (int z = 0; z < 0x100; z++) - { - if (m_MMU_VM.Rdram()[0x00206970 + z] != SecondCPU->m_MMU_VM.Rdram()[0x00206970 + z]) - { - ErrorFound = true; - break; - } + { + if (m_MMU_VM.Rdram()[0x00206970 + z] != SecondCPU->m_MMU_VM.Rdram()[0x00206970 + z]) + { + ErrorFound = true; + break; + } }*/ - - if (bFastSP() && m_Recomp) + + if (bFastSP() && m_Recomp) { if (m_Recomp->MemoryStackPos() != (DWORD)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF))) { @@ -1102,8 +1102,8 @@ void CN64System::SyncCPU (CN64System * const SecondCPU) if (m_SystemTimer != SecondCPU->m_SystemTimer) { ErrorFound = true; } if (m_NextTimer != SecondCPU->m_NextTimer) { ErrorFound = true; } if (m_Reg.m_RoundingModel != SecondCPU->m_Reg.m_RoundingModel) { ErrorFound = true; } - - for (int i = 0, n = sizeof(m_Reg.m_Mips_Interface) / sizeof(m_Reg.m_Mips_Interface[0]); i < n; i ++) + + for (int i = 0, n = sizeof(m_Reg.m_Mips_Interface) / sizeof(m_Reg.m_Mips_Interface[0]); i < n; i++) { if (m_Reg.m_Mips_Interface[i] != SecondCPU->m_Reg.m_Mips_Interface[i]) { @@ -1111,7 +1111,7 @@ void CN64System::SyncCPU (CN64System * const SecondCPU) } } - for (int i = 0, n = sizeof(m_Reg.m_SigProcessor_Interface) / sizeof(m_Reg.m_SigProcessor_Interface[0]); i < n; i ++) + for (int i = 0, n = sizeof(m_Reg.m_SigProcessor_Interface) / sizeof(m_Reg.m_SigProcessor_Interface[0]); i < n; i++) { if (m_Reg.m_SigProcessor_Interface[i] != SecondCPU->m_Reg.m_SigProcessor_Interface[i]) { @@ -1119,24 +1119,24 @@ void CN64System::SyncCPU (CN64System * const SecondCPU) } } - for (int i = 0, n = sizeof(m_Reg.m_Display_ControlReg) / sizeof(m_Reg.m_Display_ControlReg[0]); i < n; i ++) + for (int i = 0, n = sizeof(m_Reg.m_Display_ControlReg) / sizeof(m_Reg.m_Display_ControlReg[0]); i < n; i++) { if (m_Reg.m_Display_ControlReg[i] != SecondCPU->m_Reg.m_Display_ControlReg[i]) { ErrorFound = true; } } - + if (ErrorFound) { DumpSyncErrors(SecondCPU); } - for (int i = (sizeof(m_LastSuccessSyncPC)/sizeof(m_LastSuccessSyncPC[0])) - 1; i > 0; i--) + for (int i = (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])) - 1; i > 0; i--) { m_LastSuccessSyncPC[i] = m_LastSuccessSyncPC[i - 1]; } m_LastSuccessSyncPC[0] = m_Reg.m_PROGRAM_COUNTER; -// if (PROGRAM_COUNTER == 0x8009BBD8) { -// g_Notify->BreakPoint(__FILEW__,__LINE__); -// } + // if (PROGRAM_COUNTER == 0x8009BBD8) { + // g_Notify->BreakPoint(__FILEW__,__LINE__); + // } } void CN64System::SyncSystem() @@ -1149,12 +1149,12 @@ void CN64System::SyncSystemPC() SyncCPUPC(g_SyncSystem); } -void CN64System::DumpSyncErrors (CN64System * SecondCPU) +void CN64System::DumpSyncErrors(CN64System * SecondCPU) { int count; - + { - CPath ErrorFile (CPath::MODULE_DIRECTORY); + CPath ErrorFile(CPath::MODULE_DIRECTORY); ErrorFile.AppendDirectory("Logs"); ErrorFile.SetNameExtension("Sync Errors.txt"); @@ -1162,190 +1162,190 @@ void CN64System::DumpSyncErrors (CN64System * SecondCPU) Error.Open(ErrorFile); Error.Log("Errors:\r\n"); Error.Log("Register, Recompiler, Interpter\r\n"); - #ifdef TEST_SP_TRACKING +#ifdef TEST_SP_TRACKING if (m_CurrentSP != GPR[29].UW[0]) { Error.Log("m_CurrentSP,%X,%X\r\n",m_CurrentSP,GPR[29].UW[0]); } - #endif +#endif if (m_Reg.m_PROGRAM_COUNTER != SecondCPU->m_Reg.m_PROGRAM_COUNTER) { - Error.LogF("PROGRAM_COUNTER 0x%X, 0x%X\r\n",m_Reg.m_PROGRAM_COUNTER,SecondCPU->m_Reg.m_PROGRAM_COUNTER); + Error.LogF("PROGRAM_COUNTER 0x%X, 0x%X\r\n", m_Reg.m_PROGRAM_COUNTER, SecondCPU->m_Reg.m_PROGRAM_COUNTER); } if (b32BitCore()) { - for (count = 0; count < 32; count ++) + for (count = 0; count < 32; count++) { if (m_Reg.m_GPR[count].UW[0] != SecondCPU->m_Reg.m_GPR[count].UW[0]) { - Error.LogF("GPR[%s] 0x%08X%08X, 0x%08X%08X\r\n",CRegName::GPR[count], - m_Reg.m_GPR[count].W[1],m_Reg.m_GPR[count].W[0], - SecondCPU->m_Reg.m_GPR[count].W[1],SecondCPU->m_Reg.m_GPR[count].W[0]); + Error.LogF("GPR[%s] 0x%08X%08X, 0x%08X%08X\r\n", CRegName::GPR[count], + m_Reg.m_GPR[count].W[1], m_Reg.m_GPR[count].W[0], + SecondCPU->m_Reg.m_GPR[count].W[1], SecondCPU->m_Reg.m_GPR[count].W[0]); } } } - else + else { - for (count = 0; count < 32; count ++) + for (count = 0; count < 32; count++) { if (m_Reg.m_GPR[count].DW != SecondCPU->m_Reg.m_GPR[count].DW) { - Error.LogF("GPR[%s] 0x%08X%08X, 0x%08X%08X\r\n",CRegName::GPR[count], - m_Reg.m_GPR[count].W[1],m_Reg.m_GPR[count].W[0], - SecondCPU->m_Reg.m_GPR[count].W[1],SecondCPU->m_Reg.m_GPR[count].W[0]); + Error.LogF("GPR[%s] 0x%08X%08X, 0x%08X%08X\r\n", CRegName::GPR[count], + m_Reg.m_GPR[count].W[1], m_Reg.m_GPR[count].W[0], + SecondCPU->m_Reg.m_GPR[count].W[1], SecondCPU->m_Reg.m_GPR[count].W[0]); } } } - for (count = 0; count < 32; count ++) + for (count = 0; count < 32; count++) { if (m_Reg.m_FPR[count].DW != SecondCPU->m_Reg.m_FPR[count].DW) { - Error.LogF("FPR[%s] 0x%08X%08X, 0x%08X%08X\r\n",CRegName::FPR[count], - m_Reg.m_FPR[count].W[1],m_Reg.m_FPR[count].W[0], - SecondCPU->m_Reg.m_FPR[count].W[1],SecondCPU->m_Reg.m_FPR[count].W[0]); + Error.LogF("FPR[%s] 0x%08X%08X, 0x%08X%08X\r\n", CRegName::FPR[count], + m_Reg.m_FPR[count].W[1], m_Reg.m_FPR[count].W[0], + SecondCPU->m_Reg.m_FPR[count].W[1], SecondCPU->m_Reg.m_FPR[count].W[0]); } - } - for (count = 0; count < 32; count ++) + } + for (count = 0; count < 32; count++) { if (m_Reg.m_FPCR[count] != SecondCPU->m_Reg.m_FPCR[count]) { - Error.LogF("FPCR[%s] 0x%08X, 0x%08X\r\n",CRegName::FPR_Ctrl[count], + Error.LogF("FPCR[%s] 0x%08X, 0x%08X\r\n", CRegName::FPR_Ctrl[count], m_Reg.m_FPCR[count], SecondCPU->m_Reg.m_FPCR[count]); } - } - for (count = 0; count < 32; count ++) + } + for (count = 0; count < 32; count++) { if (m_Reg.m_CP0[count] != SecondCPU->m_Reg.m_CP0[count]) { - Error.LogF("CP0[%s] 0x%08X, 0x%08X\r\n",CRegName::Cop0[count], + Error.LogF("CP0[%s] 0x%08X, 0x%08X\r\n", CRegName::Cop0[count], m_Reg.m_CP0[count], SecondCPU->m_Reg.m_CP0[count]); } - } - if (m_Reg.m_HI.DW != SecondCPU->m_Reg.m_HI.DW) + } + if (m_Reg.m_HI.DW != SecondCPU->m_Reg.m_HI.DW) { - Error.LogF("HI Reg 0x%08X%08X, 0x%08X%08X\r\n",m_Reg.m_HI.UW[1],m_Reg.m_HI.UW[0],SecondCPU->m_Reg.m_HI.UW[1],SecondCPU->m_Reg.m_HI.UW[0]); + Error.LogF("HI Reg 0x%08X%08X, 0x%08X%08X\r\n", m_Reg.m_HI.UW[1], m_Reg.m_HI.UW[0], SecondCPU->m_Reg.m_HI.UW[1], SecondCPU->m_Reg.m_HI.UW[0]); } if (m_Reg.m_LO.DW != SecondCPU->m_Reg.m_LO.DW) { - Error.LogF("LO Reg 0x%08X%08X, 0x%08X%08X\r\n",m_Reg.m_LO.UW[1],m_Reg.m_LO.UW[0], SecondCPU->m_Reg.m_LO.UW[1],SecondCPU->m_Reg.m_LO.UW[0]); + Error.LogF("LO Reg 0x%08X%08X, 0x%08X%08X\r\n", m_Reg.m_LO.UW[1], m_Reg.m_LO.UW[0], SecondCPU->m_Reg.m_LO.UW[1], SecondCPU->m_Reg.m_LO.UW[0]); } - for (int i = 0, n = sizeof(m_Reg.m_Mips_Interface) / sizeof(m_Reg.m_Mips_Interface[0]); i < n; i ++) + for (int i = 0, n = sizeof(m_Reg.m_Mips_Interface) / sizeof(m_Reg.m_Mips_Interface[0]); i < n; i++) { if (m_Reg.m_Mips_Interface[i] != SecondCPU->m_Reg.m_Mips_Interface[i]) { - Error.LogF("Mips_Interface[%d] 0x%08X, 0x%08X\r\n",i, m_Reg.m_Mips_Interface[i], SecondCPU->m_Reg.m_Mips_Interface[i]); + Error.LogF("Mips_Interface[%d] 0x%08X, 0x%08X\r\n", i, m_Reg.m_Mips_Interface[i], SecondCPU->m_Reg.m_Mips_Interface[i]); } } - for (int i = 0, n = sizeof(m_Reg.m_SigProcessor_Interface) / sizeof(m_Reg.m_SigProcessor_Interface[0]); i < n; i ++) + for (int i = 0, n = sizeof(m_Reg.m_SigProcessor_Interface) / sizeof(m_Reg.m_SigProcessor_Interface[0]); i < n; i++) { if (m_Reg.m_SigProcessor_Interface[i] != SecondCPU->m_Reg.m_SigProcessor_Interface[i]) { - Error.LogF("SigProcessor_Interface[%d] 0x%08X, 0x%08X\r\n",i, m_Reg.m_SigProcessor_Interface[i], SecondCPU->m_Reg.m_SigProcessor_Interface[i]); + Error.LogF("SigProcessor_Interface[%d] 0x%08X, 0x%08X\r\n", i, m_Reg.m_SigProcessor_Interface[i], SecondCPU->m_Reg.m_SigProcessor_Interface[i]); } } - for (int i = 0, n = sizeof(m_Reg.m_Display_ControlReg) / sizeof(m_Reg.m_Display_ControlReg[0]); i < n; i ++) + for (int i = 0, n = sizeof(m_Reg.m_Display_ControlReg) / sizeof(m_Reg.m_Display_ControlReg[0]); i < n; i++) { if (m_Reg.m_Display_ControlReg[i] != SecondCPU->m_Reg.m_Display_ControlReg[i]) { - Error.LogF("Display_ControlReg[%d] 0x%08X, 0x%08X\r\n",i, m_Reg.m_Display_ControlReg[i], SecondCPU->m_Reg.m_Display_ControlReg[i]); + Error.LogF("Display_ControlReg[%d] 0x%08X, 0x%08X\r\n", i, m_Reg.m_Display_ControlReg[i], SecondCPU->m_Reg.m_Display_ControlReg[i]); } } - if (m_NextTimer != SecondCPU->m_NextTimer) - { - Error.LogF("Current Time: %X %X\r\n",(DWORD)m_NextTimer,(DWORD)SecondCPU->m_NextTimer); + if (m_NextTimer != SecondCPU->m_NextTimer) + { + Error.LogF("Current Time: %X %X\r\n", (DWORD)m_NextTimer, (DWORD)SecondCPU->m_NextTimer); } - m_TLB.RecordDifference(Error,SecondCPU->m_TLB); - m_SystemTimer.RecordDifference(Error,SecondCPU->m_SystemTimer); - if (m_Reg.m_RoundingModel != SecondCPU->m_Reg.m_RoundingModel) - { - Error.LogF("RoundingModel: %X %X\r\n",m_Reg.m_RoundingModel,SecondCPU->m_Reg.m_RoundingModel); + m_TLB.RecordDifference(Error, SecondCPU->m_TLB); + m_SystemTimer.RecordDifference(Error, SecondCPU->m_SystemTimer); + if (m_Reg.m_RoundingModel != SecondCPU->m_Reg.m_RoundingModel) + { + Error.LogF("RoundingModel: %X %X\r\n", m_Reg.m_RoundingModel, SecondCPU->m_Reg.m_RoundingModel); } - if (bFastSP() && m_Recomp) + if (bFastSP() && m_Recomp) { if (m_Recomp->MemoryStackPos() != (DWORD)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF))) { - Error.LogF("MemoryStack = %X should be: %X\r\n",m_Recomp->MemoryStackPos(), (DWORD)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF))); + Error.LogF("MemoryStack = %X should be: %X\r\n", m_Recomp->MemoryStackPos(), (DWORD)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF))); } } - DWORD * Rdram = (DWORD *)m_MMU_VM.Rdram(), * Rdram2 = (DWORD *)SecondCPU->m_MMU_VM.Rdram(); - for (int z = 0, n = (RdramSize() >> 2); z < n; z ++) - { - if (Rdram[z] != Rdram2[z]) + DWORD * Rdram = (DWORD *)m_MMU_VM.Rdram(), *Rdram2 = (DWORD *)SecondCPU->m_MMU_VM.Rdram(); + for (int z = 0, n = (RdramSize() >> 2); z < n; z++) + { + if (Rdram[z] != Rdram2[z]) { - Error.LogF("Rdram[%X]: %X %X\r\n",z << 2,Rdram[z],Rdram2[z]); + Error.LogF("Rdram[%X]: %X %X\r\n", z << 2, Rdram[z], Rdram2[z]); } } - DWORD * Imem = (DWORD *)m_MMU_VM.Imem(), * Imem2 = (DWORD *)SecondCPU->m_MMU_VM.Imem(); - for (int z = 0; z < (0x1000 >> 2); z ++) - { - if (Imem[z] != Imem2[z]) + DWORD * Imem = (DWORD *)m_MMU_VM.Imem(), *Imem2 = (DWORD *)SecondCPU->m_MMU_VM.Imem(); + for (int z = 0; z < (0x1000 >> 2); z++) + { + if (Imem[z] != Imem2[z]) { - Error.LogF("Imem[%X]: %X %X\r\n",z << 2,Imem[z],Imem2[z]); + Error.LogF("Imem[%X]: %X %X\r\n", z << 2, Imem[z], Imem2[z]); } } - DWORD * Dmem = (DWORD *)m_MMU_VM.Dmem(), * Dmem2 = (DWORD *)SecondCPU->m_MMU_VM.Dmem(); - for (int z = 0; z < (0x1000 >> 2); z ++) - { - if (Dmem[z] != Dmem2[z]) + DWORD * Dmem = (DWORD *)m_MMU_VM.Dmem(), *Dmem2 = (DWORD *)SecondCPU->m_MMU_VM.Dmem(); + for (int z = 0; z < (0x1000 >> 2); z++) + { + if (Dmem[z] != Dmem2[z]) { - Error.LogF("Dmem[%X]: %X %X\r\n",z << 2,Dmem[z],Dmem2[z]); + Error.LogF("Dmem[%X]: %X %X\r\n", z << 2, Dmem[z], Dmem2[z]); } } Error.Log("\r\n"); Error.Log("Information:\r\n"); Error.Log("\r\n"); - Error.LogF("PROGRAM_COUNTER,0x%X\r\n",m_Reg.m_PROGRAM_COUNTER); - Error.LogF("Current Timer,0x%X\r\n",m_NextTimer); - Error.LogF("Timer Type,0x%X\r\n",m_SystemTimer.CurrentType()); + Error.LogF("PROGRAM_COUNTER,0x%X\r\n", m_Reg.m_PROGRAM_COUNTER); + Error.LogF("Current Timer,0x%X\r\n", m_NextTimer); + Error.LogF("Timer Type,0x%X\r\n", m_SystemTimer.CurrentType()); Error.Log("\r\n"); - for (int i = 0; i < (sizeof(m_LastSuccessSyncPC)/sizeof(m_LastSuccessSyncPC[0])); i++) + for (int i = 0; i < (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])); i++) { - Error.LogF("LastSuccessSyncPC[%d],0x%X\r\n",i,m_LastSuccessSyncPC[i]); + Error.LogF("LastSuccessSyncPC[%d],0x%X\r\n", i, m_LastSuccessSyncPC[i]); } Error.Log("\r\n"); - for (count = 0; count < 32; count ++) + for (count = 0; count < 32; count++) { - Error.LogF("GPR[%s], 0x%08X%08X, 0x%08X%08X\r\n",CRegName::GPR[count], - m_Reg.m_GPR[count].W[1],m_Reg.m_GPR[count].W[0], - SecondCPU->m_Reg.m_GPR[count].W[1],SecondCPU->m_Reg.m_GPR[count].W[0]); - } + Error.LogF("GPR[%s], 0x%08X%08X, 0x%08X%08X\r\n", CRegName::GPR[count], + m_Reg.m_GPR[count].W[1], m_Reg.m_GPR[count].W[0], + SecondCPU->m_Reg.m_GPR[count].W[1], SecondCPU->m_Reg.m_GPR[count].W[0]); + } Error.Log("\r\n"); - for (count = 0; count < 32; count ++) + for (count = 0; count < 32; count++) { - Error.LogF("FPR[%s],%*s0x%08X%08X, 0x%08X%08X\r\n",CRegName::FPR[count], - count < 10 ? 9 : 8," ",m_Reg.m_FPR[count].W[1],m_Reg.m_FPR[count].W[0], - SecondCPU->m_Reg.m_FPR[count].W[1],SecondCPU->m_Reg.m_FPR[count].W[0]); - } + Error.LogF("FPR[%s],%*s0x%08X%08X, 0x%08X%08X\r\n", CRegName::FPR[count], + count < 10 ? 9 : 8, " ", m_Reg.m_FPR[count].W[1], m_Reg.m_FPR[count].W[0], + SecondCPU->m_Reg.m_FPR[count].W[1], SecondCPU->m_Reg.m_FPR[count].W[0]); + } Error.Log("\r\n"); - for (count = 0; count < 32; count ++) + for (count = 0; count < 32; count++) { - Error.LogF("FPR_S[%s],%*s%f, %f\r\n",CRegName::FPR[count], - count < 10 ? 7 : 6," ",*(m_Reg.m_FPR_S[count]),*(SecondCPU->m_Reg.m_FPR_S[count])); - } + Error.LogF("FPR_S[%s],%*s%f, %f\r\n", CRegName::FPR[count], + count < 10 ? 7 : 6, " ", *(m_Reg.m_FPR_S[count]), *(SecondCPU->m_Reg.m_FPR_S[count])); + } Error.Log("\r\n"); - for (count = 0; count < 32; count ++) + for (count = 0; count < 32; count++) { - Error.LogF("FPR_D[%s],%*s%f, %f\r\n",CRegName::FPR[count], - count < 10 ? 7 : 6," ",*(m_Reg.m_FPR_D[count]),*(SecondCPU->m_Reg.m_FPR_D[count])); - } + Error.LogF("FPR_D[%s],%*s%f, %f\r\n", CRegName::FPR[count], + count < 10 ? 7 : 6, " ", *(m_Reg.m_FPR_D[count]), *(SecondCPU->m_Reg.m_FPR_D[count])); + } Error.Log("\r\n"); - Error.LogF("Rounding Model, 0x%08X, 0x%08X\r\n",m_Reg.m_RoundingModel,SecondCPU->m_Reg.m_RoundingModel); + Error.LogF("Rounding Model, 0x%08X, 0x%08X\r\n", m_Reg.m_RoundingModel, SecondCPU->m_Reg.m_RoundingModel); Error.Log("\r\n"); - for (count = 0; count < 32; count ++) + for (count = 0; count < 32; count++) { - Error.LogF("CP0[%s],%*s0x%08X, 0x%08X\r\n",CRegName::Cop0[count], - 12 - strlen(CRegName::Cop0[count]),"", - m_Reg.m_CP0[count],SecondCPU->m_Reg.m_CP0[count]); - } + Error.LogF("CP0[%s],%*s0x%08X, 0x%08X\r\n", CRegName::Cop0[count], + 12 - strlen(CRegName::Cop0[count]), "", + m_Reg.m_CP0[count], SecondCPU->m_Reg.m_CP0[count]); + } Error.Log("\r\n"); - Error.LogF("HI 0x%08X%08X, 0x%08X%08X\r\n",m_Reg.m_HI.UW[1],m_Reg.m_HI.UW[0], - SecondCPU->m_Reg.m_HI.UW[1],SecondCPU->m_Reg.m_HI.UW[0]); - Error.LogF("LO 0x%08X%08X, 0x%08X%08X\r\n",m_Reg.m_LO.UW[1],m_Reg.m_LO.UW[0], - SecondCPU->m_Reg.m_LO.UW[1],SecondCPU->m_Reg.m_LO.UW[0]); + Error.LogF("HI 0x%08X%08X, 0x%08X%08X\r\n", m_Reg.m_HI.UW[1], m_Reg.m_HI.UW[0], + SecondCPU->m_Reg.m_HI.UW[1], SecondCPU->m_Reg.m_HI.UW[0]); + Error.LogF("LO 0x%08X%08X, 0x%08X%08X\r\n", m_Reg.m_LO.UW[1], m_Reg.m_LO.UW[0], + SecondCPU->m_Reg.m_LO.UW[1], SecondCPU->m_Reg.m_LO.UW[0]); bool bHasTlb = false; - for (count = 0; count < 32; count ++) + for (count = 0; count < 32; count++) { if (!m_TLB.TlbEntry(count).EntryDefined) { continue; } if (!bHasTlb) @@ -1355,74 +1355,72 @@ void CN64System::DumpSyncErrors (CN64System * SecondCPU) bHasTlb = true; } Error.LogF("TLB[%2d], %08X, %08X, %08X, %08X\r\n", count, - m_TLB.TlbEntry(count).EntryHi.Value,m_TLB.TlbEntry(count).PageMask.Value, - SecondCPU->m_TLB.TlbEntry(count).EntryHi.Value,SecondCPU->m_TLB.TlbEntry(count).PageMask.Value - ); + m_TLB.TlbEntry(count).EntryHi.Value, m_TLB.TlbEntry(count).PageMask.Value, + SecondCPU->m_TLB.TlbEntry(count).EntryHi.Value, SecondCPU->m_TLB.TlbEntry(count).PageMask.Value + ); } Error.Log("\r\n"); Error.Log("Code at PC:\r\n"); for (count = -10; count < 10; count++) { DWORD OpcodeValue, Addr = m_Reg.m_PROGRAM_COUNTER + (count << 2); - if (g_MMU->LW_VAddr(Addr,(uint32_t &)OpcodeValue)) + if (g_MMU->LW_VAddr(Addr, (uint32_t &)OpcodeValue)) { - Error.LogF("%X: %s\r\n",Addr,R4300iOpcodeName(OpcodeValue,Addr)); + Error.LogF("%X: %s\r\n", Addr, R4300iOpcodeName(OpcodeValue, Addr)); } - } Error.Log("\r\n"); Error.Log("Code at Last Sync PC:\r\n"); for (count = 0; count < 50; count++) { DWORD OpcodeValue, Addr = m_LastSuccessSyncPC[0] + (count << 2); - if (g_MMU->LW_VAddr(Addr,(uint32_t &)OpcodeValue)) + if (g_MMU->LW_VAddr(Addr, (uint32_t &)OpcodeValue)) { - Error.LogF("%X: %s\r\n",Addr,R4300iOpcodeName(OpcodeValue,Addr)); + Error.LogF("%X: %s\r\n", Addr, R4300iOpcodeName(OpcodeValue, Addr)); } - } } g_Notify->DisplayError(L"Sync Error"); - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } bool CN64System::SaveState() { - WriteTrace(TraceDebug,__FUNCTION__ ": Start"); + WriteTrace(TraceDebug, __FUNCTION__ ": Start"); -// if (!m_SystemTimer.SaveAllowed()) { return false; } + // if (!m_SystemTimer.SaveAllowed()) { return false; } if ((m_Reg.STATUS_REGISTER & STATUS_EXL) != 0) { return false; } - + //Get the file Name stdstr FileName, ExtraInfoFileName, CurrentSaveName = g_Settings->LoadStringVal(GameRunning_InstantSaveFile); if (CurrentSaveName.empty()) { int Slot = g_Settings->LoadDword(Game_CurrentSaveState); - if (Slot != 0) - { - CurrentSaveName.Format("%s.pj%d",g_Settings->LoadStringVal(Game_GoodName).c_str(), Slot); - } - else + if (Slot != 0) { - CurrentSaveName.Format("%s.pj",g_Settings->LoadStringVal(Game_GoodName).c_str()); + CurrentSaveName.Format("%s.pj%d", g_Settings->LoadStringVal(Game_GoodName).c_str(), Slot); } - FileName.Format("%s%s",g_Settings->LoadStringVal(Directory_InstantSave).c_str(),CurrentSaveName.c_str()); - stdstr_f ZipFileName("%s.zip",FileName.c_str()); - //Make sure the target dir exists - CreateDirectory(g_Settings->LoadStringVal(Directory_InstantSave).c_str(),NULL); + else + { + CurrentSaveName.Format("%s.pj", g_Settings->LoadStringVal(Game_GoodName).c_str()); + } + FileName.Format("%s%s", g_Settings->LoadStringVal(Directory_InstantSave).c_str(), CurrentSaveName.c_str()); + stdstr_f ZipFileName("%s.zip", FileName.c_str()); + //Make sure the target dir exists + CreateDirectory(g_Settings->LoadStringVal(Directory_InstantSave).c_str(), NULL); //delete any old save DeleteFile(FileName.c_str()); DeleteFile(ZipFileName.c_str()); - ExtraInfoFileName.Format("%s.dat",CurrentSaveName.c_str()); - + ExtraInfoFileName.Format("%s.dat", CurrentSaveName.c_str()); + //If ziping save add .zip on the end if (g_Settings->LoadDword(Setting_AutoZipInstantSave)) { FileName = ZipFileName; } - g_Settings->SaveDword(Game_LastSaveSlot,g_Settings->LoadDword(Game_CurrentSaveState)); - } + g_Settings->SaveDword(Game_LastSaveSlot, g_Settings->LoadDword(Game_CurrentSaveState)); + } else { char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; @@ -1442,63 +1440,63 @@ bool CN64System::SaveState() if (FileName.empty()) { return true; } //Open the file - if (g_Settings->LoadDword(Game_FuncLookupMode) == FuncFind_ChangeMemory) + if (g_Settings->LoadDword(Game_FuncLookupMode) == FuncFind_ChangeMemory) { if (m_Recomp) { - m_Recomp->ResetRecompCode(true); + m_Recomp->ResetRecompCode(true); } } DWORD dwWritten, SaveID_0 = 0x23D8A6C8, SaveID_1 = 0x56D2CD23; - DWORD RdramSize = g_Settings->LoadDword(Game_RDRamSize); - DWORD MiInterReg = g_Reg->MI_INTR_REG; + DWORD RdramSize = g_Settings->LoadDword(Game_RDRamSize); + DWORD MiInterReg = g_Reg->MI_INTR_REG; DWORD NextViTimer = m_SystemTimer.GetTimer(CSystemTimer::ViTimer); if (g_Settings->LoadDword(Setting_AutoZipInstantSave)) { zipFile file; - file = zipOpen(FileName.c_str(),0); - zipOpenNewFileInZip(file,CurrentSaveName.c_str(),NULL,NULL,0,NULL,0,NULL,Z_DEFLATED,Z_DEFAULT_COMPRESSION); - zipWriteInFileInZip(file,&SaveID_0,sizeof(SaveID_0)); - zipWriteInFileInZip(file,&RdramSize,sizeof(DWORD)); - zipWriteInFileInZip(file,g_Rom->GetRomAddress(),0x40); - zipWriteInFileInZip(file,&NextViTimer,sizeof(DWORD)); - zipWriteInFileInZip(file,&m_Reg.m_PROGRAM_COUNTER,sizeof(m_Reg.m_PROGRAM_COUNTER)); - zipWriteInFileInZip(file,m_Reg.m_GPR,sizeof(__int64)*32); - zipWriteInFileInZip(file,m_Reg.m_FPR,sizeof(__int64)*32); - zipWriteInFileInZip(file,m_Reg.m_CP0,sizeof(DWORD)*32); - zipWriteInFileInZip(file,m_Reg.m_FPCR,sizeof(DWORD)*32); - zipWriteInFileInZip(file,&m_Reg.m_HI,sizeof(__int64)); - zipWriteInFileInZip(file,&m_Reg.m_LO,sizeof(__int64)); - zipWriteInFileInZip(file,m_Reg.m_RDRAM_Registers,sizeof(DWORD)*10); - zipWriteInFileInZip(file,m_Reg.m_SigProcessor_Interface,sizeof(DWORD)*10); - zipWriteInFileInZip(file,m_Reg.m_Display_ControlReg,sizeof(DWORD)*10); - zipWriteInFileInZip(file,m_Reg.m_Mips_Interface,sizeof(DWORD)*4); - zipWriteInFileInZip(file,m_Reg.m_Video_Interface,sizeof(DWORD)*14); - zipWriteInFileInZip(file,m_Reg.m_Audio_Interface,sizeof(DWORD)*6); - zipWriteInFileInZip(file,m_Reg.m_Peripheral_Interface,sizeof(DWORD)*13); - zipWriteInFileInZip(file,m_Reg.m_RDRAM_Interface,sizeof(DWORD)*8); - zipWriteInFileInZip(file,m_Reg.m_SerialInterface,sizeof(DWORD)*4); - zipWriteInFileInZip(file,(void *const)&m_TLB.TlbEntry(0),sizeof(CTLB::TLB_ENTRY)*32); - zipWriteInFileInZip(file,m_MMU_VM.PifRam(),0x40); - zipWriteInFileInZip(file,m_MMU_VM.Rdram(),RdramSize); - zipWriteInFileInZip(file,m_MMU_VM.Dmem(),0x1000); - zipWriteInFileInZip(file,m_MMU_VM.Imem(),0x1000); + file = zipOpen(FileName.c_str(), 0); + zipOpenNewFileInZip(file, CurrentSaveName.c_str(), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION); + zipWriteInFileInZip(file, &SaveID_0, sizeof(SaveID_0)); + zipWriteInFileInZip(file, &RdramSize, sizeof(DWORD)); + zipWriteInFileInZip(file, g_Rom->GetRomAddress(), 0x40); + zipWriteInFileInZip(file, &NextViTimer, sizeof(DWORD)); + zipWriteInFileInZip(file, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER)); + zipWriteInFileInZip(file, m_Reg.m_GPR, sizeof(__int64) * 32); + zipWriteInFileInZip(file, m_Reg.m_FPR, sizeof(__int64) * 32); + zipWriteInFileInZip(file, m_Reg.m_CP0, sizeof(DWORD) * 32); + zipWriteInFileInZip(file, m_Reg.m_FPCR, sizeof(DWORD) * 32); + zipWriteInFileInZip(file, &m_Reg.m_HI, sizeof(__int64)); + zipWriteInFileInZip(file, &m_Reg.m_LO, sizeof(__int64)); + zipWriteInFileInZip(file, m_Reg.m_RDRAM_Registers, sizeof(DWORD) * 10); + zipWriteInFileInZip(file, m_Reg.m_SigProcessor_Interface, sizeof(DWORD) * 10); + zipWriteInFileInZip(file, m_Reg.m_Display_ControlReg, sizeof(DWORD) * 10); + zipWriteInFileInZip(file, m_Reg.m_Mips_Interface, sizeof(DWORD) * 4); + zipWriteInFileInZip(file, m_Reg.m_Video_Interface, sizeof(DWORD) * 14); + zipWriteInFileInZip(file, m_Reg.m_Audio_Interface, sizeof(DWORD) * 6); + zipWriteInFileInZip(file, m_Reg.m_Peripheral_Interface, sizeof(DWORD) * 13); + zipWriteInFileInZip(file, m_Reg.m_RDRAM_Interface, sizeof(DWORD) * 8); + zipWriteInFileInZip(file, m_Reg.m_SerialInterface, sizeof(DWORD) * 4); + zipWriteInFileInZip(file, (void *const)&m_TLB.TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32); + zipWriteInFileInZip(file, m_MMU_VM.PifRam(), 0x40); + zipWriteInFileInZip(file, m_MMU_VM.Rdram(), RdramSize); + zipWriteInFileInZip(file, m_MMU_VM.Dmem(), 0x1000); + zipWriteInFileInZip(file, m_MMU_VM.Imem(), 0x1000); zipCloseFileInZip(file); - - zipOpenNewFileInZip(file,ExtraInfoFileName.c_str(),NULL,NULL,0,NULL,0,NULL,Z_DEFLATED,Z_DEFAULT_COMPRESSION); - zipWriteInFileInZip(file,&SaveID_1,sizeof(SaveID_1)); + + zipOpenNewFileInZip(file, ExtraInfoFileName.c_str(), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION); + zipWriteInFileInZip(file, &SaveID_1, sizeof(SaveID_1)); m_SystemTimer.SaveData(file); zipCloseFileInZip(file); - zipClose(file,""); - } + zipClose(file, ""); + } else { - HANDLE hSaveFile = CreateFile(FileName.c_str(),GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, - NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); - if (hSaveFile == INVALID_HANDLE_VALUE) + HANDLE hSaveFile = CreateFile(FileName.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, + NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); + if (hSaveFile == INVALID_HANDLE_VALUE) { g_Notify->DisplayError(GS(MSG_FAIL_OPEN_SAVE)); m_Reg.MI_INTR_REG = MiInterReg; @@ -1506,44 +1504,44 @@ bool CN64System::SaveState() } //Write info to file - SetFilePointer(hSaveFile,0,NULL,FILE_BEGIN); - WriteFile( hSaveFile,&SaveID_0,sizeof(DWORD),&dwWritten,NULL); - WriteFile( hSaveFile,&RdramSize,sizeof(DWORD),&dwWritten,NULL); - WriteFile( hSaveFile,g_Rom->GetRomAddress(),0x40,&dwWritten,NULL); - WriteFile( hSaveFile,&NextViTimer,sizeof(DWORD),&dwWritten,NULL); - WriteFile( hSaveFile,&m_Reg.m_PROGRAM_COUNTER,sizeof(m_Reg.m_PROGRAM_COUNTER),&dwWritten,NULL); - WriteFile( hSaveFile,m_Reg.m_GPR,sizeof(__int64)*32,&dwWritten,NULL); - WriteFile( hSaveFile,m_Reg.m_FPR,sizeof(__int64)*32,&dwWritten,NULL); - WriteFile( hSaveFile,m_Reg.m_CP0,sizeof(DWORD)*32,&dwWritten,NULL); - WriteFile( hSaveFile,m_Reg.m_FPCR,sizeof(DWORD)*32,&dwWritten,NULL); - WriteFile( hSaveFile,&m_Reg.m_HI,sizeof(__int64),&dwWritten,NULL); - WriteFile( hSaveFile,&m_Reg.m_LO,sizeof(__int64),&dwWritten,NULL); - WriteFile( hSaveFile,m_Reg.m_RDRAM_Registers,sizeof(DWORD)*10,&dwWritten,NULL); - WriteFile( hSaveFile,m_Reg.m_SigProcessor_Interface,sizeof(DWORD)*10,&dwWritten,NULL); - WriteFile( hSaveFile,m_Reg.m_Display_ControlReg,sizeof(DWORD)*10,&dwWritten,NULL); - WriteFile( hSaveFile,m_Reg.m_Mips_Interface,sizeof(DWORD)*4,&dwWritten,NULL); - WriteFile( hSaveFile,m_Reg.m_Video_Interface,sizeof(DWORD)*14,&dwWritten,NULL); - WriteFile( hSaveFile,m_Reg.m_Audio_Interface,sizeof(DWORD)*6,&dwWritten,NULL); - WriteFile( hSaveFile,m_Reg.m_Peripheral_Interface,sizeof(DWORD)*13,&dwWritten,NULL); - WriteFile( hSaveFile,m_Reg.m_RDRAM_Interface,sizeof(DWORD)*8,&dwWritten,NULL); - WriteFile( hSaveFile,m_Reg.m_SerialInterface,sizeof(DWORD)*4,&dwWritten,NULL); - WriteFile( hSaveFile,&g_TLB->TlbEntry(0),sizeof(CTLB::TLB_ENTRY)*32,&dwWritten,NULL); - WriteFile( hSaveFile,g_MMU->PifRam(),0x40,&dwWritten,NULL); - WriteFile( hSaveFile,g_MMU->Rdram(),RdramSize,&dwWritten,NULL); - WriteFile( hSaveFile,g_MMU->Dmem(),0x1000,&dwWritten,NULL); - WriteFile( hSaveFile,g_MMU->Imem(),0x1000,&dwWritten,NULL); + SetFilePointer(hSaveFile, 0, NULL, FILE_BEGIN); + WriteFile(hSaveFile, &SaveID_0, sizeof(DWORD), &dwWritten, NULL); + WriteFile(hSaveFile, &RdramSize, sizeof(DWORD), &dwWritten, NULL); + WriteFile(hSaveFile, g_Rom->GetRomAddress(), 0x40, &dwWritten, NULL); + WriteFile(hSaveFile, &NextViTimer, sizeof(DWORD), &dwWritten, NULL); + WriteFile(hSaveFile, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER), &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_GPR, sizeof(__int64) * 32, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_FPR, sizeof(__int64) * 32, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_CP0, sizeof(DWORD) * 32, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_FPCR, sizeof(DWORD) * 32, &dwWritten, NULL); + WriteFile(hSaveFile, &m_Reg.m_HI, sizeof(__int64), &dwWritten, NULL); + WriteFile(hSaveFile, &m_Reg.m_LO, sizeof(__int64), &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_RDRAM_Registers, sizeof(DWORD) * 10, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_SigProcessor_Interface, sizeof(DWORD) * 10, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_Display_ControlReg, sizeof(DWORD) * 10, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_Mips_Interface, sizeof(DWORD) * 4, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_Video_Interface, sizeof(DWORD) * 14, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_Audio_Interface, sizeof(DWORD) * 6, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_Peripheral_Interface, sizeof(DWORD) * 13, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_RDRAM_Interface, sizeof(DWORD) * 8, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_SerialInterface, sizeof(DWORD) * 4, &dwWritten, NULL); + WriteFile(hSaveFile, &g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32, &dwWritten, NULL); + WriteFile(hSaveFile, g_MMU->PifRam(), 0x40, &dwWritten, NULL); + WriteFile(hSaveFile, g_MMU->Rdram(), RdramSize, &dwWritten, NULL); + WriteFile(hSaveFile, g_MMU->Dmem(), 0x1000, &dwWritten, NULL); + WriteFile(hSaveFile, g_MMU->Imem(), 0x1000, &dwWritten, NULL); CloseHandle(hSaveFile); } m_Reg.MI_INTR_REG = MiInterReg; - g_Settings->SaveString(GameRunning_InstantSaveFile,""); + g_Settings->SaveString(GameRunning_InstantSaveFile, ""); std::wstring SaveMessage = g_Lang->GetString(MSG_SAVED_STATE); CPath SavedFileName(FileName); - - g_Notify->DisplayMessage(5,stdstr_f("%s %s",SaveMessage.c_str(),SavedFileName.GetNameExtension()).ToUTF16().c_str()); + + g_Notify->DisplayMessage(5, stdstr_f("%s %s", SaveMessage.c_str(), SavedFileName.GetNameExtension()).ToUTF16().c_str()); Notify().RefreshMenu(); - WriteTrace(TraceDebug,__FUNCTION__ ": Done"); + WriteTrace(TraceDebug, __FUNCTION__ ": Done"); return true; } @@ -1553,19 +1551,19 @@ bool CN64System::LoadState() if (!InstantFileName.empty()) { bool Result = LoadState(InstantFileName.c_str()); - g_Settings->SaveString(GameRunning_InstantSaveFile,""); + g_Settings->SaveString(GameRunning_InstantSaveFile, ""); return Result; } CPath FileName; FileName.SetDriveDirectory(g_Settings->LoadStringVal(Directory_InstantSave).c_str()); - if (g_Settings->LoadDword(Game_CurrentSaveState) != 0) + if (g_Settings->LoadDword(Game_CurrentSaveState) != 0) { - FileName.SetNameExtension(stdstr_f("%s.pj%d",g_Settings->LoadStringVal(Game_GoodName).c_str(),g_Settings->LoadDword(Game_CurrentSaveState)).c_str()); - } - else + FileName.SetNameExtension(stdstr_f("%s.pj%d", g_Settings->LoadStringVal(Game_GoodName).c_str(), g_Settings->LoadDword(Game_CurrentSaveState)).c_str()); + } + else { - FileName.SetNameExtension(stdstr_f("%s.pj",g_Settings->LoadStringVal(Game_GoodName).c_str()).c_str()); + FileName.SetNameExtension(stdstr_f("%s.pj", g_Settings->LoadStringVal(Game_GoodName).c_str()).c_str()); } CPath ZipFileName; @@ -1580,119 +1578,119 @@ bool CN64System::LoadState() } //Use old file Name - if (g_Settings->LoadDword(Game_CurrentSaveState) != 0) - { - FileName.SetNameExtension(stdstr_f("%s.pj%d",g_Settings->LoadStringVal(Game_GameName).c_str(),g_Settings->LoadDword(Game_CurrentSaveState)).c_str()); + if (g_Settings->LoadDword(Game_CurrentSaveState) != 0) + { + FileName.SetNameExtension(stdstr_f("%s.pj%d", g_Settings->LoadStringVal(Game_GameName).c_str(), g_Settings->LoadDword(Game_CurrentSaveState)).c_str()); } else { - FileName.SetNameExtension(stdstr_f("%s.pj",g_Settings->LoadStringVal(Game_GameName).c_str()).c_str()); + FileName.SetNameExtension(stdstr_f("%s.pj", g_Settings->LoadStringVal(Game_GameName).c_str()).c_str()); } return LoadState(FileName); } -bool CN64System::LoadState(LPCSTR FileName) +bool CN64System::LoadState(LPCSTR FileName) { - DWORD dwRead, Value,SaveRDRAMSize, NextVITimer = 0, old_status, old_width, old_dacrate; + DWORD dwRead, Value, SaveRDRAMSize, NextVITimer = 0, old_status, old_width, old_dacrate; bool LoadedZipFile = false, AudioResetOnLoad; old_status = g_Reg->VI_STATUS_REG; old_width = g_Reg->VI_WIDTH_REG; old_dacrate = g_Reg->AI_DACRATE_REG; - - WriteTraceF((TraceType)(TraceDebug | TraceRecompiler),__FUNCTION__ "(%s): Start",FileName); - char drive[_MAX_DRIVE] ,dir[_MAX_DIR], fname[_MAX_FNAME],ext[_MAX_EXT]; + WriteTraceF((TraceType)(TraceDebug | TraceRecompiler), __FUNCTION__ "(%s): Start", FileName); + + char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; _splitpath(FileName, drive, dir, fname, ext); stdstr FileNameStr(FileName); - if (g_Settings->LoadDword(Setting_AutoZipInstantSave) || _stricmp(ext,".zip") == 0) + if (g_Settings->LoadDword(Setting_AutoZipInstantSave) || _stricmp(ext, ".zip") == 0) { //If ziping save add .zip on the end - if (_stricmp(ext,".zip") != 0) + if (_stricmp(ext, ".zip") != 0) { FileNameStr += ".zip"; } unzFile file = unzOpen(FileNameStr.c_str()); int port = -1; - if (file != NULL) + if (file != NULL) { port = unzGoToFirstFile(file); } DWORD Value; - while (port == UNZ_OK) + while (port == UNZ_OK) { unz_file_info info; char zname[132]; - unzGetCurrentFileInfo(file, &info, zname, 128, NULL,0, NULL,0); - if (unzLocateFile(file, zname, 1) != UNZ_OK ) + unzGetCurrentFileInfo(file, &info, zname, 128, NULL, 0, NULL, 0); + if (unzLocateFile(file, zname, 1) != UNZ_OK) { unzClose(file); port = -1; continue; } - if( unzOpenCurrentFile(file) != UNZ_OK ) + if (unzOpenCurrentFile(file) != UNZ_OK) { unzClose(file); port = -1; continue; } - unzReadCurrentFile(file,&Value,4); - if (Value != 0x23D8A6C8 && Value != 0x56D2CD23) + unzReadCurrentFile(file, &Value, 4); + if (Value != 0x23D8A6C8 && Value != 0x56D2CD23) { unzCloseCurrentFile(file); port = unzGoToNextFile(file); continue; } - if (!LoadedZipFile && Value == 0x23D8A6C8 && port == UNZ_OK) + if (!LoadedZipFile && Value == 0x23D8A6C8 && port == UNZ_OK) { - unzReadCurrentFile(file,&SaveRDRAMSize,sizeof(SaveRDRAMSize)); + unzReadCurrentFile(file, &SaveRDRAMSize, sizeof(SaveRDRAMSize)); //Check header BYTE LoadHeader[64]; - unzReadCurrentFile(file,LoadHeader,0x40); - if (memcmp(LoadHeader,g_Rom->GetRomAddress(),0x40) != 0) + unzReadCurrentFile(file, LoadHeader, 0x40); + if (memcmp(LoadHeader, g_Rom->GetRomAddress(), 0x40) != 0) { //if (inFullScreen) { return false; } - int result = MessageBoxW(NULL,GS(MSG_SAVE_STATE_HEADER),GS(MSG_MSGBOX_TITLE), - MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2); + int result = MessageBoxW(NULL, GS(MSG_SAVE_STATE_HEADER), GS(MSG_MSGBOX_TITLE), + MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2); if (result == IDNO) return false; } - Reset(false,true); + Reset(false, true); - g_MMU->UnProtectMemory(0x80000000,0x80000000 + g_Settings->LoadDword(Game_RDRamSize) - 4); - g_MMU->UnProtectMemory(0xA4000000,0xA4001FFC); - g_Settings->SaveDword(Game_RDRamSize,SaveRDRAMSize); - unzReadCurrentFile(file,&NextVITimer,sizeof(NextVITimer)); - unzReadCurrentFile(file,&m_Reg.m_PROGRAM_COUNTER,sizeof(m_Reg.m_PROGRAM_COUNTER)); - unzReadCurrentFile(file,m_Reg.m_GPR,sizeof(__int64)*32); - unzReadCurrentFile(file,m_Reg.m_FPR,sizeof(__int64)*32); - unzReadCurrentFile(file,m_Reg.m_CP0,sizeof(DWORD)*32); - unzReadCurrentFile(file,m_Reg.m_FPCR,sizeof(DWORD)*32); - unzReadCurrentFile(file,&m_Reg.m_HI,sizeof(__int64)); - unzReadCurrentFile(file,&m_Reg.m_LO,sizeof(__int64)); - unzReadCurrentFile(file,m_Reg.m_RDRAM_Registers,sizeof(DWORD)*10); - unzReadCurrentFile(file,m_Reg.m_SigProcessor_Interface,sizeof(DWORD)*10); - unzReadCurrentFile(file,m_Reg.m_Display_ControlReg,sizeof(DWORD)*10); - unzReadCurrentFile(file,m_Reg.m_Mips_Interface,sizeof(DWORD)*4); - unzReadCurrentFile(file,m_Reg.m_Video_Interface,sizeof(DWORD)*14); - unzReadCurrentFile(file,m_Reg.m_Audio_Interface,sizeof(DWORD)*6); - unzReadCurrentFile(file,m_Reg.m_Peripheral_Interface,sizeof(DWORD)*13); - unzReadCurrentFile(file,m_Reg.m_RDRAM_Interface,sizeof(DWORD)*8); - unzReadCurrentFile(file,m_Reg.m_SerialInterface,sizeof(DWORD)*4); - unzReadCurrentFile(file,(void *const)&g_TLB->TlbEntry(0),sizeof(CTLB::TLB_ENTRY)*32); - unzReadCurrentFile(file,m_MMU_VM.PifRam(),0x40); - unzReadCurrentFile(file,m_MMU_VM.Rdram(),SaveRDRAMSize); - unzReadCurrentFile(file,m_MMU_VM.Dmem(),0x1000); - unzReadCurrentFile(file,m_MMU_VM.Imem(),0x1000); + g_MMU->UnProtectMemory(0x80000000, 0x80000000 + g_Settings->LoadDword(Game_RDRamSize) - 4); + g_MMU->UnProtectMemory(0xA4000000, 0xA4001FFC); + g_Settings->SaveDword(Game_RDRamSize, SaveRDRAMSize); + unzReadCurrentFile(file, &NextVITimer, sizeof(NextVITimer)); + unzReadCurrentFile(file, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER)); + unzReadCurrentFile(file, m_Reg.m_GPR, sizeof(__int64) * 32); + unzReadCurrentFile(file, m_Reg.m_FPR, sizeof(__int64) * 32); + unzReadCurrentFile(file, m_Reg.m_CP0, sizeof(DWORD) * 32); + unzReadCurrentFile(file, m_Reg.m_FPCR, sizeof(DWORD) * 32); + unzReadCurrentFile(file, &m_Reg.m_HI, sizeof(__int64)); + unzReadCurrentFile(file, &m_Reg.m_LO, sizeof(__int64)); + unzReadCurrentFile(file, m_Reg.m_RDRAM_Registers, sizeof(DWORD) * 10); + unzReadCurrentFile(file, m_Reg.m_SigProcessor_Interface, sizeof(DWORD) * 10); + unzReadCurrentFile(file, m_Reg.m_Display_ControlReg, sizeof(DWORD) * 10); + unzReadCurrentFile(file, m_Reg.m_Mips_Interface, sizeof(DWORD) * 4); + unzReadCurrentFile(file, m_Reg.m_Video_Interface, sizeof(DWORD) * 14); + unzReadCurrentFile(file, m_Reg.m_Audio_Interface, sizeof(DWORD) * 6); + unzReadCurrentFile(file, m_Reg.m_Peripheral_Interface, sizeof(DWORD) * 13); + unzReadCurrentFile(file, m_Reg.m_RDRAM_Interface, sizeof(DWORD) * 8); + unzReadCurrentFile(file, m_Reg.m_SerialInterface, sizeof(DWORD) * 4); + unzReadCurrentFile(file, (void *const)&g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32); + unzReadCurrentFile(file, m_MMU_VM.PifRam(), 0x40); + unzReadCurrentFile(file, m_MMU_VM.Rdram(), SaveRDRAMSize); + unzReadCurrentFile(file, m_MMU_VM.Dmem(), 0x1000); + unzReadCurrentFile(file, m_MMU_VM.Imem(), 0x1000); unzCloseCurrentFile(file); port = unzGoToFirstFile(file); LoadedZipFile = true; continue; } - if (LoadedZipFile && Value == 0x56D2CD23 && port == UNZ_OK) + if (LoadedZipFile && Value == 0x56D2CD23 && port == UNZ_OK) { m_SystemTimer.LoadData(file); } @@ -1701,64 +1699,64 @@ bool CN64System::LoadState(LPCSTR FileName) } unzClose(file); } - if (!LoadedZipFile) + if (!LoadedZipFile) { - HANDLE hSaveFile = CreateFile(FileNameStr.c_str(),GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ,NULL, - OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); - if (hSaveFile == INVALID_HANDLE_VALUE) + HANDLE hSaveFile = CreateFile(FileNameStr.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); + if (hSaveFile == INVALID_HANDLE_VALUE) { - g_Notify->DisplayMessage(5,stdstr_f("%s %s",GS(MSG_UNABLED_LOAD_STATE),FileNameStr).ToUTF16().c_str()); + g_Notify->DisplayMessage(5, stdstr_f("%s %s", GS(MSG_UNABLED_LOAD_STATE), FileNameStr).ToUTF16().c_str()); return false; } - SetFilePointer(hSaveFile,0,NULL,FILE_BEGIN); - ReadFile( hSaveFile,&Value,sizeof(Value),&dwRead,NULL); + SetFilePointer(hSaveFile, 0, NULL, FILE_BEGIN); + ReadFile(hSaveFile, &Value, sizeof(Value), &dwRead, NULL); if (Value != 0x23D8A6C8) return false; - ReadFile( hSaveFile,&SaveRDRAMSize,sizeof(SaveRDRAMSize),&dwRead,NULL); + ReadFile(hSaveFile, &SaveRDRAMSize, sizeof(SaveRDRAMSize), &dwRead, NULL); //Check header BYTE LoadHeader[64]; - ReadFile( hSaveFile,LoadHeader,0x40,&dwRead,NULL); - if (memcmp(LoadHeader,g_Rom->GetRomAddress(),0x40) != 0) + ReadFile(hSaveFile, LoadHeader, 0x40, &dwRead, NULL); + if (memcmp(LoadHeader, g_Rom->GetRomAddress(), 0x40) != 0) { //if (inFullScreen) { return false; } - int result = MessageBoxW(NULL,GS(MSG_SAVE_STATE_HEADER),GS(MSG_MSGBOX_TITLE), - MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2); + int result = MessageBoxW(NULL, GS(MSG_SAVE_STATE_HEADER), GS(MSG_MSGBOX_TITLE), + MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2); if (result == IDNO) return false; } - Reset(false,true); - m_MMU_VM.UnProtectMemory(0x80000000,0x80000000 + g_Settings->LoadDword(Game_RDRamSize) - 4); - m_MMU_VM.UnProtectMemory(0xA4000000,0xA4001FFC); - g_Settings->SaveDword(Game_RDRamSize,SaveRDRAMSize); + Reset(false, true); + m_MMU_VM.UnProtectMemory(0x80000000, 0x80000000 + g_Settings->LoadDword(Game_RDRamSize) - 4); + m_MMU_VM.UnProtectMemory(0xA4000000, 0xA4001FFC); + g_Settings->SaveDword(Game_RDRamSize, SaveRDRAMSize); - ReadFile( hSaveFile,&NextVITimer,sizeof(NextVITimer),&dwRead,NULL); - ReadFile( hSaveFile,&m_Reg.m_PROGRAM_COUNTER,sizeof(m_Reg.m_PROGRAM_COUNTER),&dwRead,NULL); - ReadFile( hSaveFile,m_Reg.m_GPR,sizeof(__int64)*32,&dwRead,NULL); - ReadFile( hSaveFile,m_Reg.m_FPR,sizeof(__int64)*32,&dwRead,NULL); - ReadFile( hSaveFile,m_Reg.m_CP0,sizeof(DWORD)*32,&dwRead,NULL); - ReadFile( hSaveFile,m_Reg.m_FPCR,sizeof(DWORD)*32,&dwRead,NULL); - ReadFile( hSaveFile,&m_Reg.m_HI,sizeof(__int64),&dwRead,NULL); - ReadFile( hSaveFile,&m_Reg.m_LO,sizeof(__int64),&dwRead,NULL); - ReadFile( hSaveFile,m_Reg.m_RDRAM_Registers,sizeof(DWORD)*10,&dwRead,NULL); - ReadFile( hSaveFile,m_Reg.m_SigProcessor_Interface,sizeof(DWORD)*10,&dwRead,NULL); - ReadFile( hSaveFile,m_Reg.m_Display_ControlReg,sizeof(DWORD)*10,&dwRead,NULL); - ReadFile( hSaveFile,m_Reg.m_Mips_Interface,sizeof(DWORD)*4,&dwRead,NULL); - ReadFile( hSaveFile,m_Reg.m_Video_Interface,sizeof(DWORD)*14,&dwRead,NULL); - ReadFile( hSaveFile,m_Reg.m_Audio_Interface,sizeof(DWORD)*6,&dwRead,NULL); - ReadFile( hSaveFile,m_Reg.m_Peripheral_Interface,sizeof(DWORD)*13,&dwRead,NULL); - ReadFile( hSaveFile,m_Reg.m_RDRAM_Interface,sizeof(DWORD)*8,&dwRead,NULL); - ReadFile( hSaveFile,m_Reg.m_SerialInterface,sizeof(DWORD)*4,&dwRead,NULL); - ReadFile( hSaveFile,(void *const)&g_TLB->TlbEntry(0),sizeof(CTLB::TLB_ENTRY)*32,&dwRead,NULL); - ReadFile( hSaveFile,m_MMU_VM.PifRam(),0x40,&dwRead,NULL); - ReadFile( hSaveFile,m_MMU_VM.Rdram(),SaveRDRAMSize,&dwRead,NULL); - ReadFile( hSaveFile,m_MMU_VM.Dmem(),0x1000,&dwRead,NULL); - ReadFile( hSaveFile,m_MMU_VM.Imem(),0x1000,&dwRead,NULL); + ReadFile(hSaveFile, &NextVITimer, sizeof(NextVITimer), &dwRead, NULL); + ReadFile(hSaveFile, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER), &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_GPR, sizeof(__int64) * 32, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_FPR, sizeof(__int64) * 32, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_CP0, sizeof(DWORD) * 32, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_FPCR, sizeof(DWORD) * 32, &dwRead, NULL); + ReadFile(hSaveFile, &m_Reg.m_HI, sizeof(__int64), &dwRead, NULL); + ReadFile(hSaveFile, &m_Reg.m_LO, sizeof(__int64), &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_RDRAM_Registers, sizeof(DWORD) * 10, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_SigProcessor_Interface, sizeof(DWORD) * 10, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_Display_ControlReg, sizeof(DWORD) * 10, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_Mips_Interface, sizeof(DWORD) * 4, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_Video_Interface, sizeof(DWORD) * 14, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_Audio_Interface, sizeof(DWORD) * 6, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_Peripheral_Interface, sizeof(DWORD) * 13, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_RDRAM_Interface, sizeof(DWORD) * 8, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_SerialInterface, sizeof(DWORD) * 4, &dwRead, NULL); + ReadFile(hSaveFile, (void *const)&g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32, &dwRead, NULL); + ReadFile(hSaveFile, m_MMU_VM.PifRam(), 0x40, &dwRead, NULL); + ReadFile(hSaveFile, m_MMU_VM.Rdram(), SaveRDRAMSize, &dwRead, NULL); + ReadFile(hSaveFile, m_MMU_VM.Dmem(), 0x1000, &dwRead, NULL); + ReadFile(hSaveFile, m_MMU_VM.Imem(), 0x1000, &dwRead, NULL); CloseHandle(hSaveFile); } - + //Fix losing audio in certain games with certain plugins AudioResetOnLoad = g_Settings->LoadBool(Game_AudioResetOnLoad); if (AudioResetOnLoad) @@ -1767,63 +1765,63 @@ bool CN64System::LoadState(LPCSTR FileName) m_Reg.AI_STATUS_REG &= ~AI_STATUS_FIFO_FULL; g_Reg->MI_INTR_REG |= MI_INTR_AI; } - + if (bFixedAudio()) { m_Audio.SetFrequency(m_Reg.AI_DACRATE_REG, g_System->SystemType()); } - + if (old_status != g_Reg->VI_STATUS_REG) { g_Plugins->Gfx()->ViStatusChanged(); } - + if (old_width != g_Reg->VI_WIDTH_REG) { g_Plugins->Gfx()->ViWidthChanged(); } - + if (old_dacrate != g_Reg->AI_DACRATE_REG) { g_Plugins->Audio()->DacrateChanged(g_System->SystemType()); } - + //Fix Random Register while ((int)m_Reg.RANDOM_REGISTER < (int)m_Reg.WIRED_REGISTER) { m_Reg.RANDOM_REGISTER += 32 - m_Reg.WIRED_REGISTER; } //Fix up timer - WriteTrace(TraceDebug,__FUNCTION__ ": 2"); - m_SystemTimer.SetTimer(CSystemTimer::CompareTimer,m_Reg.COMPARE_REGISTER - m_Reg.COUNT_REGISTER,false); - m_SystemTimer.SetTimer(CSystemTimer::ViTimer,NextVITimer,false); + WriteTrace(TraceDebug, __FUNCTION__ ": 2"); + m_SystemTimer.SetTimer(CSystemTimer::CompareTimer, m_Reg.COMPARE_REGISTER - m_Reg.COUNT_REGISTER, false); + m_SystemTimer.SetTimer(CSystemTimer::ViTimer, NextVITimer, false); m_Reg.FixFpuLocations(); - WriteTrace(TraceDebug,__FUNCTION__ ": 5"); + WriteTrace(TraceDebug, __FUNCTION__ ": 5"); m_TLB.Reset(false); - WriteTrace(TraceDebug,__FUNCTION__ ": 6"); + WriteTrace(TraceDebug, __FUNCTION__ ": 6"); m_CPU_Usage.ResetCounters(); - WriteTrace(TraceDebug,__FUNCTION__ ": 7"); + WriteTrace(TraceDebug, __FUNCTION__ ": 7"); m_Profile.ResetCounters(); - WriteTrace(TraceDebug,__FUNCTION__ ": 8"); + WriteTrace(TraceDebug, __FUNCTION__ ": 8"); m_FPS.Reset(true); - WriteTrace(TraceDebug,__FUNCTION__ ": 9"); + WriteTrace(TraceDebug, __FUNCTION__ ": 9"); if (bLogX86Code()) { Stop_x86_Log(); Start_x86_Log(); } - WriteTrace(TraceDebug,__FUNCTION__ ": Done"); + WriteTrace(TraceDebug, __FUNCTION__ ": Done"); #ifdef TEST_SP_TRACKING m_CurrentSP = GPR[29].UW[0]; #endif if (bFastSP() && m_Recomp) { m_Recomp->ResetMemoryStackPos(); } - if (g_Settings->LoadDword(Game_CpuType) == CPU_SyncCores) + if (g_Settings->LoadDword(Game_CpuType) == CPU_SyncCores) { if (m_SyncCPU) { - for (int i = 0; i < (sizeof(m_LastSuccessSyncPC)/sizeof(m_LastSuccessSyncPC[0])); i++) + for (int i = 0; i < (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])); i++) { m_LastSuccessSyncPC[i] = 0; } @@ -1833,10 +1831,10 @@ bool CN64System::LoadState(LPCSTR FileName) SyncCPU(m_SyncCPU); } } - WriteTrace(TraceDebug,__FUNCTION__ ": 13"); + WriteTrace(TraceDebug, __FUNCTION__ ": 13"); std::wstring LoadMsg = g_Lang->GetString(MSG_LOADED_STATE); - g_Notify->DisplayMessage(5,stdstr_f("%s %s",LoadMsg.c_str(),CPath(FileNameStr).GetNameExtension()).ToUTF16().c_str()); - WriteTrace(TraceDebug,__FUNCTION__ ": Done"); + g_Notify->DisplayMessage(5, stdstr_f("%s %s", LoadMsg.c_str(), CPath(FileNameStr).GetNameExtension()).ToUTF16().c_str()); + WriteTrace(TraceDebug, __FUNCTION__ ": Done"); return true; } @@ -1847,18 +1845,18 @@ void CN64System::DisplayRSPListCount() void CN64System::RunRSP() { - WriteTraceF(TraceRSP, __FUNCTION__ ": Start (SP Status %X)",m_Reg.SP_STATUS_REG); - if ( ( m_Reg.SP_STATUS_REG & SP_STATUS_HALT ) == 0) - { - if ( ( m_Reg.SP_STATUS_REG & SP_STATUS_BROKE ) == 0 ) - { + WriteTraceF(TraceRSP, __FUNCTION__ ": Start (SP Status %X)", m_Reg.SP_STATUS_REG); + if ((m_Reg.SP_STATUS_REG & SP_STATUS_HALT) == 0) + { + if ((m_Reg.SP_STATUS_REG & SP_STATUS_BROKE) == 0) + { SPECIAL_TIMERS CPU_UsageAddr = Timer_None/*, ProfileAddr = Timer_None*/; - + DWORD Task = 0; if (m_RspBroke) { - g_MMU->LW_VAddr(0xA4000FC0,(uint32_t &)Task); - if (Task == 1 && (m_Reg.DPC_STATUS_REG & DPC_STATUS_FREEZE) != 0) + g_MMU->LW_VAddr(0xA4000FC0, (uint32_t &)Task); + if (Task == 1 && (m_Reg.DPC_STATUS_REG & DPC_STATUS_FREEZE) != 0) { WriteTrace(TraceRSP, __FUNCTION__ ": Dlist that is frozen"); return; @@ -1866,18 +1864,18 @@ void CN64System::RunRSP() switch (Task) { - case 1: + case 1: WriteTrace(TraceRSP, __FUNCTION__ ": *** Display list ***"); - m_DlistCount += 1; + m_DlistCount += 1; m_FPS.UpdateDlCounter(); break; - case 2: + case 2: WriteTrace(TraceRSP, __FUNCTION__ ": *** Audio list ***"); - m_AlistCount += 1; + m_AlistCount += 1; break; - default: + default: WriteTrace(TraceRSP, __FUNCTION__ ": *** Unknown list ***"); - m_UnknownCount += 1; + m_UnknownCount += 1; break; } @@ -1885,9 +1883,9 @@ void CN64System::RunRSP() { DisplayRSPListCount(); } - if (bShowCPUPer()) + if (bShowCPUPer()) { - switch (Task) + switch (Task) { case 1: CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_RSP_Dlist); break; case 2: CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_RSP_Alist); break; @@ -1895,15 +1893,14 @@ void CN64System::RunRSP() } } } - - __try + __try { WriteTrace(TraceRSP, __FUNCTION__ ": do cycles - starting"); g_Plugins->RSP()->DoRspCycles(100); WriteTrace(TraceRSP, __FUNCTION__ ": do cycles - Done"); } - __except( g_MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) + __except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation())) { WriteTrace(TraceError, __FUNCTION__ ": exception generated"); g_Notify->FatalError(__FUNCTIONW__ L"\nUnknown memory action\n\nEmulation stop"); @@ -1911,17 +1908,17 @@ void CN64System::RunRSP() if (Task == 1 && bDelayDP() && ((m_Reg.m_GfxIntrReg & MI_INTR_DP) != 0)) { - g_SystemTimer->SetTimer(CSystemTimer::RSPTimerDlist,0x1000,false); + g_SystemTimer->SetTimer(CSystemTimer::RSPTimerDlist, 0x1000, false); m_Reg.m_GfxIntrReg &= ~MI_INTR_DP; } if (bShowCPUPer()) { m_CPU_Usage.StartTimer(CPU_UsageAddr); } //if (bProfiling) { m_Profile.StartTimer(ProfileAddr); } - if ( ( m_Reg.SP_STATUS_REG & SP_STATUS_HALT ) == 0 && - ( m_Reg.SP_STATUS_REG & SP_STATUS_BROKE ) == 0 && - m_Reg.m_RspIntrReg == 0) + if ((m_Reg.SP_STATUS_REG & SP_STATUS_HALT) == 0 && + (m_Reg.SP_STATUS_REG & SP_STATUS_BROKE) == 0 && + m_Reg.m_RspIntrReg == 0) { - g_SystemTimer->SetTimer(CSystemTimer::RspTimer,0x200,false); + g_SystemTimer->SetTimer(CSystemTimer::RspTimer, 0x200, false); m_RspBroke = false; } else @@ -1932,7 +1929,7 @@ void CN64System::RunRSP() g_Reg->CheckInterrupts(); } } - WriteTraceF(TraceRSP, __FUNCTION__ ": Done (SP Status %X)",m_Reg.SP_STATUS_REG); + WriteTraceF(TraceRSP, __FUNCTION__ ": Done (SP Status %X)", m_Reg.SP_STATUS_REG); } void CN64System::SyncToAudio() @@ -1944,19 +1941,19 @@ void CN64System::SyncToAudio() SPECIAL_TIMERS CPU_UsageAddr = Timer_None; if (bShowCPUPer()) { CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_Idel); } - + for (int i = 0; i < 50; i++) { if (g_Reg->m_AudioIntrReg != 0) { - WriteTraceF(TraceAudio, __FUNCTION__ ": Audio Interrupt done (%d)",i); + WriteTraceF(TraceAudio, __FUNCTION__ ": Audio Interrupt done (%d)", i); break; } Sleep(1); } - if (bShowCPUPer()) + if (bShowCPUPer()) { - m_CPU_Usage.StartTimer(CPU_UsageAddr != Timer_None ? CPU_UsageAddr : Timer_R4300 ); + m_CPU_Usage.StartTimer(CPU_UsageAddr != Timer_None ? CPU_UsageAddr : Timer_R4300); } } @@ -1964,53 +1961,53 @@ void CN64System::RefreshScreen() { SPECIAL_TIMERS CPU_UsageAddr = Timer_None/*, ProfilingAddr = Timer_None*/; DWORD VI_INTR_TIME = 500000; - + if (bShowCPUPer()) { CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_RefreshScreen); } //if (bProfiling) { ProfilingAddr = m_Profile.StartTimer(Timer_RefreshScreen); } //Calculate how many cycles to next refresh - if (m_Reg.VI_V_SYNC_REG == 0) + if (m_Reg.VI_V_SYNC_REG == 0) { VI_INTR_TIME = 500000; } else { VI_INTR_TIME = (m_Reg.VI_V_SYNC_REG + 1) * ViRefreshRate(); - if ((m_Reg.VI_V_SYNC_REG % 1) != 0) + if ((m_Reg.VI_V_SYNC_REG % 1) != 0) { VI_INTR_TIME -= 38; } } - g_SystemTimer->SetTimer(CSystemTimer::ViTimer,VI_INTR_TIME,true); + g_SystemTimer->SetTimer(CSystemTimer::ViTimer, VI_INTR_TIME, true); if (bFixedAudio()) { - g_Audio->SetViIntr (VI_INTR_TIME); + g_Audio->SetViIntr(VI_INTR_TIME); } - if (g_Plugins->Control()->GetKeys) + if (g_Plugins->Control()->GetKeys) { BUTTONS Keys; - memset(&Keys,0,sizeof(Keys)); + memset(&Keys, 0, sizeof(Keys)); for (int Control = 0; Control < 4; Control++) - { - g_Plugins->Control()->GetKeys(Control,&Keys); + { + g_Plugins->Control()->GetKeys(Control, &Keys); m_Buttons[Control] = Keys.Value; } } if (bShowCPUPer()) { m_CPU_Usage.StartTimer(Timer_UpdateScreen); } -// if (bProfiling) { m_Profile.StartTimer(Timer_UpdateScreen); } - + // if (bProfiling) { m_Profile.StartTimer(Timer_UpdateScreen); } + __try { - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Starting"); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Starting"); g_Plugins->Gfx()->UpdateScreen(); - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Done"); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Done"); } - __except (g_MMU->MemoryFilter( GetExceptionCode(), GetExceptionInformation())) + __except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation())) { - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": Exception caught"); - WriteTrace(TraceError,__FUNCTION__ ": Exception caught"); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Exception caught"); + WriteTrace(TraceError, __FUNCTION__ ": Exception caught"); } g_MMU->UpdateFieldSerration((m_Reg.VI_STATUS_REG & 0x40) != 0); @@ -2031,18 +2028,18 @@ void CN64System::RefreshScreen() m_FPS.UpdateViCounter(); m_bCleanFrameBox = true; } - + if (m_bCleanFrameBox && !bDisplayFrameRate()) { - m_FPS.Reset (true); + m_FPS.Reset(true); m_bCleanFrameBox = false; } - if (bShowCPUPer()) + if (bShowCPUPer()) { m_CPU_Usage.StopTimer(); m_CPU_Usage.ShowCPU_Usage(); - m_CPU_Usage.StartTimer(CPU_UsageAddr != Timer_None ? CPU_UsageAddr : Timer_R4300 ); + m_CPU_Usage.StartTimer(CPU_UsageAddr != Timer_None ? CPU_UsageAddr : Timer_R4300); } if ((m_Reg.STATUS_REGISTER & STATUS_IE) != 0) { @@ -2060,12 +2057,12 @@ void CN64System::RefreshScreen() // if (bProfiling) { m_Profile.StartTimer(ProfilingAddr != Timer_None ? ProfilingAddr : Timer_R4300); } } -bool CN64System::WriteToProtectedMemory (uint32_t Address, int length) +bool CN64System::WriteToProtectedMemory(uint32_t Address, int length) { - WriteTraceF(TraceDebug,__FUNCTION__ ": Address: %X Len: %d",Address,length); + WriteTraceF(TraceDebug, __FUNCTION__ ": Address: %X Len: %d", Address, length); if (m_Recomp) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); #ifdef tofix return m_Recomp->ClearRecompCode_Phys(Address,length,CRecompiler::Remove_ProtectedMem); #endif @@ -2073,17 +2070,17 @@ bool CN64System::WriteToProtectedMemory (uint32_t Address, int length) return false; } -void CN64System::TLB_Mapped ( uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly ) +void CN64System::TLB_Mapped(uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly) { - m_MMU_VM.TLB_Mapped(VAddr,Len,PAddr,bReadOnly); + m_MMU_VM.TLB_Mapped(VAddr, Len, PAddr, bReadOnly); } -void CN64System::TLB_Unmaped ( uint32_t VAddr, uint32_t Len ) +void CN64System::TLB_Unmaped(uint32_t VAddr, uint32_t Len) { - m_MMU_VM.TLB_Unmaped(VAddr,Len); + m_MMU_VM.TLB_Unmaped(VAddr, Len); if (m_Recomp && bSMM_TLB()) { - m_Recomp->ClearRecompCode_Virt(VAddr,Len,CRecompiler::Remove_TLB); + m_Recomp->ClearRecompCode_Virt(VAddr, Len, CRecompiler::Remove_TLB); } } @@ -2093,4 +2090,4 @@ void CN64System::TLB_Changed() { g_Debugger->TLBChanged(); } -} +} \ No newline at end of file diff --git a/Source/Project64/N64 System/N64 Class.h b/Source/Project64/N64 System/N64 Class.h index 79971522a..27292a815 100644 --- a/Source/Project64/N64 System/N64 Class.h +++ b/Source/Project64/N64 System/N64 Class.h @@ -21,53 +21,53 @@ class CRecompiler; //#define TEST_SP_TRACKING //track the SP to make sure all ops pick it up fine class CN64System : - public CMipsMemory_CallBack, - public CTLB_CB, - private CSystemEvents, - protected CN64SystemSettings, - public CGameSettings, - protected CDebugSettings + public CMipsMemory_CallBack, + public CTLB_CB, + private CSystemEvents, + protected CN64SystemSettings, + public CGameSettings, + protected CDebugSettings { public: - CN64System(CPlugins * Plugins, bool SavesReadOnly); - virtual ~CN64System(void); + CN64System(CPlugins * Plugins, bool SavesReadOnly); + virtual ~CN64System(void); struct ThreadInfo { HANDLE * ThreadHandle; DWORD ThreadID; }; - CProfiling m_Profile; - CCheats m_Cheats; - bool m_EndEmulation; - SAVE_CHIP_TYPE m_SaveUsing; + CProfiling m_Profile; + CCheats m_Cheats; + bool m_EndEmulation; + SAVE_CHIP_TYPE m_SaveUsing; - //Methods - static bool RunFileImage(const char * FileLoc); - static void CloseSystem(void); + //Methods + static bool RunFileImage(const char * FileLoc); + static void CloseSystem(void); - void CloseCpu (); - void ExternalEvent ( SystemEvent action ); //covers gui interacting and timers etc.. - stdstr ChooseFileToOpen ( HWND hParent ); - void DisplayRomInfo ( HWND hParent ); - void StartEmulation ( bool NewThread ); - void SyncToAudio (); - void IncreaseSpeed () { m_Limitor.IncreaseSpeed(); } - void DecreaseSpeed () { m_Limitor.DecreaseSpeed(); } - void Reset ( bool bInitReg, bool ClearMenory ); - void GameReset (); - void PluginReset (); + void CloseCpu(); + void ExternalEvent(SystemEvent action); //covers gui interacting and timers etc.. + stdstr ChooseFileToOpen(HWND hParent); + void DisplayRomInfo(HWND hParent); + void StartEmulation(bool NewThread); + void SyncToAudio(); + void IncreaseSpeed() { m_Limitor.IncreaseSpeed(); } + void DecreaseSpeed() { m_Limitor.DecreaseSpeed(); } + void Reset(bool bInitReg, bool ClearMenory); + void GameReset(); + void PluginReset(); - void Pause (); - void RunRSP (); - bool SaveState (); - bool LoadState ( LPCSTR FileName ); - bool LoadState (); + void Pause(); + void RunRSP(); + bool SaveState(); + bool LoadState(LPCSTR FileName); + bool LoadState(); bool DmaUsed() const { return m_DMAUsed; } void SetDmaUsed(bool DMAUsed) { m_DMAUsed = DMAUsed; } - void SetCheatsSlectionChanged(bool changed) { m_CheatsSlectionChanged = changed; } - bool HasCheatsSlectionChanged(void) const { return m_CheatsSlectionChanged; } + void SetCheatsSlectionChanged(bool changed) { m_CheatsSlectionChanged = changed; } + bool HasCheatsSlectionChanged(void) const { return m_CheatsSlectionChanged; } DWORD GetButtons(int Control) const { return m_Buttons[Control]; } //Variable used to track that the SP is being handled and stays the same as the real SP in sync core @@ -75,31 +75,31 @@ public: DWORD m_CurrentSP; #endif //For Sync CPU - void UpdateSyncCPU ( CN64System * const SecondCPU, DWORD const Cycles ); - void SyncCPU ( CN64System * const SecondCPU ); - void SyncCPUPC ( CN64System * const SecondCPU ); - void SyncSystem (); - void SyncSystemPC (); + void UpdateSyncCPU(CN64System * const SecondCPU, DWORD const Cycles); + void SyncCPU(CN64System * const SecondCPU); + void SyncCPUPC(CN64System * const SecondCPU); + void SyncSystem(); + void SyncSystemPC(); private: //Make sure plugins can directly access this information friend CGfxPlugin; friend CAudioPlugin; friend CRSP_Plugin; friend CControl_Plugin; - + //Recompiler has access to manipulate and call functions friend CSystemTimer; //Used for loading and potentially executing the CPU in its own thread. - static void StartEmulationThread ( ThreadInfo * Info ); - static bool EmulationStarting ( HANDLE hThread, DWORD ThreadId ); + static void StartEmulationThread(ThreadInfo * Info); + static bool EmulationStarting(HANDLE hThread, DWORD ThreadId); - void ExecuteCPU (); - void RefreshScreen (); - void DumpSyncErrors ( CN64System * SecondCPU ); - void StartEmulation2 ( bool NewThread ); - bool SetActiveSystem ( bool bActive = true ); - void InitRegisters ( bool bPostPif, CMipsMemory & MMU ); + void ExecuteCPU(); + void RefreshScreen(); + void DumpSyncErrors(CN64System * SecondCPU); + void StartEmulation2(bool NewThread); + bool SetActiveSystem(bool bActive = true); + void InitRegisters(bool bPostPif, CMipsMemory & MMU); void DisplayRSPListCount(); //CPU Methods @@ -118,11 +118,11 @@ private: void TLB_Unmaped(uint32_t VAddr, uint32_t Len); void TLB_Changed(); - CPlugins * const m_Plugins; //The plugin container + CPlugins * const m_Plugins; //The plugin container CN64System * m_SyncCPU; CPlugins * m_SyncPlugins; CMainGui * m_SyncWindow; - CMipsMemoryVM m_MMU_VM; //Memory of the n64 + CMipsMemoryVM m_MMU_VM; //Memory of the n64 CTLB m_TLB; CRegisters m_Reg; CFramePerSecond m_FPS; @@ -141,10 +141,10 @@ private: bool m_TestTimer; DWORD m_NextInstruction; DWORD m_JumpToLocation; - uint32_t m_TLBLoadAddress; - uint32_t m_TLBStoreAddress; + uint32_t m_TLBLoadAddress; + uint32_t m_TLBStoreAddress; DWORD m_SyncCount; - bool m_CheatsSlectionChanged; + bool m_CheatsSlectionChanged; //When Syncing cores this is the PC where it last Sync'ed correctly DWORD m_LastSuccessSyncPC[10]; @@ -153,7 +153,7 @@ private: //Handle to the cpu thread HANDLE m_CPU_Handle; DWORD m_CPU_ThreadID; - + //Handle to pause mutex void * m_hPauseEvent; From 66b6be4bd7e3f0b6cb1c8eebbbadc7c2533d1a96 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 12 Nov 2015 17:52:27 +1100 Subject: [PATCH 136/213] [Project64] N64 Class.cpp tabs to spaces --- Source/Project64/N64 System/N64 Class.cpp | 3458 ++++++++++----------- Source/Project64/N64 System/N64 Class.h | 232 +- 2 files changed, 1845 insertions(+), 1845 deletions(-) diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index 54f149ba1..fb49d3464 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -44,2050 +44,2050 @@ m_CPU_Handle(NULL), m_CPU_ThreadID(0), m_CheatsSlectionChanged(false) { - DWORD gameHertz = g_Settings->LoadDword(Game_ScreenHertz); - if (gameHertz == 0) - { - gameHertz = (SystemType() == SYSTEM_PAL) ? 50 : 60; - } - m_hPauseEvent = CreateEvent(NULL, true, false, NULL); - m_Limitor.SetHertz(gameHertz); - g_Settings->SaveDword(GameRunning_ScreenHertz, gameHertz); - m_Cheats.LoadCheats(!g_Settings->LoadDword(Setting_RememberCheats), Plugins); + DWORD gameHertz = g_Settings->LoadDword(Game_ScreenHertz); + if (gameHertz == 0) + { + gameHertz = (SystemType() == SYSTEM_PAL) ? 50 : 60; + } + m_hPauseEvent = CreateEvent(NULL, true, false, NULL); + m_Limitor.SetHertz(gameHertz); + g_Settings->SaveDword(GameRunning_ScreenHertz, gameHertz); + m_Cheats.LoadCheats(!g_Settings->LoadDword(Setting_RememberCheats), Plugins); } CN64System::~CN64System() { - SetActiveSystem(false); - Mempak::Close(); - if (m_SyncCPU) - { - m_SyncCPU->CpuStopped(); - delete m_SyncCPU; - m_SyncCPU = NULL; - } - if (m_Recomp) - { - delete m_Recomp; - m_Recomp = NULL; - } - if (m_SyncPlugins) - { - delete m_SyncPlugins; - m_SyncPlugins = NULL; - } - if (m_SyncWindow) - { - delete m_SyncWindow; - m_SyncWindow = NULL; - } + SetActiveSystem(false); + Mempak::Close(); + if (m_SyncCPU) + { + m_SyncCPU->CpuStopped(); + delete m_SyncCPU; + m_SyncCPU = NULL; + } + if (m_Recomp) + { + delete m_Recomp; + m_Recomp = NULL; + } + if (m_SyncPlugins) + { + delete m_SyncPlugins; + m_SyncPlugins = NULL; + } + if (m_SyncWindow) + { + delete m_SyncWindow; + m_SyncWindow = NULL; + } } void CN64System::ExternalEvent(SystemEvent action) { - switch (action) - { - case SysEvent_Profile_GenerateLogs: - case SysEvent_Profile_StartStop: - case SysEvent_Profile_ResetLogs: - case SysEvent_ExecuteInterrupt: - case SysEvent_SaveMachineState: - case SysEvent_LoadMachineState: - case SysEvent_ChangingFullScreen: - case SysEvent_GSButtonPressed: - case SysEvent_ResetCPU_SoftDone: - case SysEvent_Interrupt_SP: - case SysEvent_Interrupt_SI: - case SysEvent_Interrupt_AI: - case SysEvent_Interrupt_VI: - case SysEvent_Interrupt_PI: - case SysEvent_Interrupt_DP: - case SysEvent_ResetCPU_Hard: - case SysEvent_ResetCPU_Soft: - case SysEvent_CloseCPU: - case SysEvent_ChangePlugins: - QueueEvent(action); - break; - case SysEvent_PauseCPU_FromMenu: - case SysEvent_PauseCPU_AppLostFocus: - case SysEvent_PauseCPU_AppLostActive: - case SysEvent_PauseCPU_SaveGame: - case SysEvent_PauseCPU_LoadGame: - case SysEvent_PauseCPU_DumpMemory: - case SysEvent_PauseCPU_SearchMemory: - case SysEvent_PauseCPU_Settings: - case SysEvent_PauseCPU_Cheats: - if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) - { - QueueEvent(action); - } - break; - case SysEvent_ResumeCPU_FromMenu: - // always resume if from menu - SetEvent(m_hPauseEvent); - break; - case SysEvent_ResumeCPU_AppGainedFocus: - if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_AppLostFocus) - { - SetEvent(m_hPauseEvent); - } - break; - case SysEvent_ResumeCPU_AppGainedActive: - if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_AppLostActive) - { - SetEvent(m_hPauseEvent); - } - break; - case SysEvent_ResumeCPU_SaveGame: - if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_SaveGame) - { - SetEvent(m_hPauseEvent); - } - break; - case SysEvent_ResumeCPU_LoadGame: - if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_LoadGame) - { - SetEvent(m_hPauseEvent); - } - break; - case SysEvent_ResumeCPU_DumpMemory: - if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_DumpMemory) - { - SetEvent(m_hPauseEvent); - } - break; - case SysEvent_ResumeCPU_SearchMemory: - if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_SearchMemory) - { - SetEvent(m_hPauseEvent); - } - break; - case SysEvent_ResumeCPU_Settings: - if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_Settings) - { - SetEvent(m_hPauseEvent); - } - break; - case SysEvent_ResumeCPU_Cheats: - if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_Cheats) - { - SetEvent(m_hPauseEvent); - } - break; - default: - WriteTraceF(TraceError, __FUNCTION__ ": Unknown event %d", action); - g_Notify->BreakPoint(__FILEW__, __LINE__); - } + switch (action) + { + case SysEvent_Profile_GenerateLogs: + case SysEvent_Profile_StartStop: + case SysEvent_Profile_ResetLogs: + case SysEvent_ExecuteInterrupt: + case SysEvent_SaveMachineState: + case SysEvent_LoadMachineState: + case SysEvent_ChangingFullScreen: + case SysEvent_GSButtonPressed: + case SysEvent_ResetCPU_SoftDone: + case SysEvent_Interrupt_SP: + case SysEvent_Interrupt_SI: + case SysEvent_Interrupt_AI: + case SysEvent_Interrupt_VI: + case SysEvent_Interrupt_PI: + case SysEvent_Interrupt_DP: + case SysEvent_ResetCPU_Hard: + case SysEvent_ResetCPU_Soft: + case SysEvent_CloseCPU: + case SysEvent_ChangePlugins: + QueueEvent(action); + break; + case SysEvent_PauseCPU_FromMenu: + case SysEvent_PauseCPU_AppLostFocus: + case SysEvent_PauseCPU_AppLostActive: + case SysEvent_PauseCPU_SaveGame: + case SysEvent_PauseCPU_LoadGame: + case SysEvent_PauseCPU_DumpMemory: + case SysEvent_PauseCPU_SearchMemory: + case SysEvent_PauseCPU_Settings: + case SysEvent_PauseCPU_Cheats: + if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) + { + QueueEvent(action); + } + break; + case SysEvent_ResumeCPU_FromMenu: + // always resume if from menu + SetEvent(m_hPauseEvent); + break; + case SysEvent_ResumeCPU_AppGainedFocus: + if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_AppLostFocus) + { + SetEvent(m_hPauseEvent); + } + break; + case SysEvent_ResumeCPU_AppGainedActive: + if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_AppLostActive) + { + SetEvent(m_hPauseEvent); + } + break; + case SysEvent_ResumeCPU_SaveGame: + if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_SaveGame) + { + SetEvent(m_hPauseEvent); + } + break; + case SysEvent_ResumeCPU_LoadGame: + if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_LoadGame) + { + SetEvent(m_hPauseEvent); + } + break; + case SysEvent_ResumeCPU_DumpMemory: + if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_DumpMemory) + { + SetEvent(m_hPauseEvent); + } + break; + case SysEvent_ResumeCPU_SearchMemory: + if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_SearchMemory) + { + SetEvent(m_hPauseEvent); + } + break; + case SysEvent_ResumeCPU_Settings: + if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_Settings) + { + SetEvent(m_hPauseEvent); + } + break; + case SysEvent_ResumeCPU_Cheats: + if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_Cheats) + { + SetEvent(m_hPauseEvent); + } + break; + default: + WriteTraceF(TraceError, __FUNCTION__ ": Unknown event %d", action); + g_Notify->BreakPoint(__FILEW__, __LINE__); + } } bool CN64System::RunFileImage(const char * FileLoc) { - CloseSystem(); - if (g_Settings->LoadBool(GameRunning_LoadingInProgress)) - { - return false; - } - g_Settings->SaveBool(GameRunning_LoadingInProgress, true); + CloseSystem(); + if (g_Settings->LoadBool(GameRunning_LoadingInProgress)) + { + return false; + } + g_Settings->SaveBool(GameRunning_LoadingInProgress, true); - WriteTrace(TraceDebug, __FUNCTION__ ": Mark Rom as loading"); + WriteTrace(TraceDebug, __FUNCTION__ ": Mark Rom as loading"); - //Mark the rom as loading - g_Settings->SaveBool(GameRunning_LoadingInProgress, true); - Notify().RefreshMenu(); + //Mark the rom as loading + g_Settings->SaveBool(GameRunning_LoadingInProgress, true); + Notify().RefreshMenu(); - //Try to load the passed N64 rom - if (g_Rom == NULL) - { - WriteTrace(TraceDebug, __FUNCTION__ ": Allocating global rom object"); - g_Rom = new CN64Rom(); - } - else - { - WriteTrace(TraceDebug, __FUNCTION__ ": Use existing global rom object"); - } + //Try to load the passed N64 rom + if (g_Rom == NULL) + { + WriteTrace(TraceDebug, __FUNCTION__ ": Allocating global rom object"); + g_Rom = new CN64Rom(); + } + else + { + WriteTrace(TraceDebug, __FUNCTION__ ": Use existing global rom object"); + } - WriteTraceF(TraceDebug, __FUNCTION__ ": Loading \"%s\"", FileLoc); - if (g_Rom->LoadN64Image(FileLoc)) - { - g_System->RefreshGameSettings(); + WriteTraceF(TraceDebug, __FUNCTION__ ": Loading \"%s\"", FileLoc); + if (g_Rom->LoadN64Image(FileLoc)) + { + g_System->RefreshGameSettings(); - WriteTrace(TraceDebug, __FUNCTION__ ": Add Recent Rom"); - Notify().AddRecentRom(FileLoc); - Notify().SetWindowCaption(g_Settings->LoadStringVal(Game_GoodName).ToUTF16().c_str()); + WriteTrace(TraceDebug, __FUNCTION__ ": Add Recent Rom"); + Notify().AddRecentRom(FileLoc); + Notify().SetWindowCaption(g_Settings->LoadStringVal(Game_GoodName).ToUTF16().c_str()); - g_Settings->SaveBool(GameRunning_LoadingInProgress, false); - Notify().RefreshMenu(); + g_Settings->SaveBool(GameRunning_LoadingInProgress, false); + Notify().RefreshMenu(); - if (g_Settings->LoadDword(Setting_AutoStart) != 0) - { - g_BaseSystem = new CN64System(g_Plugins, false); - if (g_BaseSystem) - { - g_BaseSystem->StartEmulation(true); - } - } - } - else - { - WriteTraceF(TraceError, __FUNCTION__ ": LoadN64Image failed (\"%s\")", FileLoc); - g_Notify->DisplayError(g_Rom->GetError()); - delete g_Rom; - g_Rom = NULL; - g_Settings->SaveBool(GameRunning_LoadingInProgress, false); - Notify().RefreshMenu(); - return false; - } - return true; + if (g_Settings->LoadDword(Setting_AutoStart) != 0) + { + g_BaseSystem = new CN64System(g_Plugins, false); + if (g_BaseSystem) + { + g_BaseSystem->StartEmulation(true); + } + } + } + else + { + WriteTraceF(TraceError, __FUNCTION__ ": LoadN64Image failed (\"%s\")", FileLoc); + g_Notify->DisplayError(g_Rom->GetError()); + delete g_Rom; + g_Rom = NULL; + g_Settings->SaveBool(GameRunning_LoadingInProgress, false); + Notify().RefreshMenu(); + return false; + } + return true; } void CN64System::CloseSystem() { - if (g_BaseSystem) - { - g_BaseSystem->CloseCpu(); - delete g_BaseSystem; - g_BaseSystem = NULL; - } + if (g_BaseSystem) + { + g_BaseSystem->CloseCpu(); + delete g_BaseSystem; + g_BaseSystem = NULL; + } } bool CN64System::EmulationStarting(HANDLE hThread, DWORD ThreadId) { - bool bRes = true; + bool bRes = true; - WriteTrace(TraceDebug, __FUNCTION__ ": Setting N64 system as active"); - if (g_BaseSystem->SetActiveSystem(true)) - { - g_BaseSystem->m_CPU_Handle = hThread; - g_BaseSystem->m_CPU_ThreadID = ThreadId; - WriteTrace(TraceDebug, __FUNCTION__ ": Setting up N64 system done"); - g_Settings->SaveBool(GameRunning_LoadingInProgress, false); - Notify().RefreshMenu(); - try - { - WriteTrace(TraceDebug, __FUNCTION__ ": Game set to auto start, starting"); - g_BaseSystem->StartEmulation2(false); - WriteTrace(TraceDebug, __FUNCTION__ ": Game Done"); - } - catch (...) - { - WriteTraceF(TraceError, __FUNCTION__ ": Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__); - char Message[600]; - sprintf(Message, __FUNCTION__ ": Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__); - MessageBox(NULL, Message, "Exception", MB_OK); - } - } - else - { - WriteTrace(TraceError, __FUNCTION__ ": SetActiveSystem failed"); - g_Notify->DisplayError(__FUNCTIONW__ L": Failed to Initialize N64 System"); - g_Settings->SaveBool(GameRunning_LoadingInProgress, false); - Notify().RefreshMenu(); - bRes = false; - } - return bRes; + WriteTrace(TraceDebug, __FUNCTION__ ": Setting N64 system as active"); + if (g_BaseSystem->SetActiveSystem(true)) + { + g_BaseSystem->m_CPU_Handle = hThread; + g_BaseSystem->m_CPU_ThreadID = ThreadId; + WriteTrace(TraceDebug, __FUNCTION__ ": Setting up N64 system done"); + g_Settings->SaveBool(GameRunning_LoadingInProgress, false); + Notify().RefreshMenu(); + try + { + WriteTrace(TraceDebug, __FUNCTION__ ": Game set to auto start, starting"); + g_BaseSystem->StartEmulation2(false); + WriteTrace(TraceDebug, __FUNCTION__ ": Game Done"); + } + catch (...) + { + WriteTraceF(TraceError, __FUNCTION__ ": Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__); + char Message[600]; + sprintf(Message, __FUNCTION__ ": Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__); + MessageBox(NULL, Message, "Exception", MB_OK); + } + } + else + { + WriteTrace(TraceError, __FUNCTION__ ": SetActiveSystem failed"); + g_Notify->DisplayError(__FUNCTIONW__ L": Failed to Initialize N64 System"); + g_Settings->SaveBool(GameRunning_LoadingInProgress, false); + Notify().RefreshMenu(); + bRes = false; + } + return bRes; } void CN64System::StartEmulation2(bool NewThread) { - if (NewThread) - { - WriteTrace(TraceDebug, __FUNCTION__ ": Starting"); + if (NewThread) + { + WriteTrace(TraceDebug, __FUNCTION__ ": Starting"); - Notify().HideRomBrowser(); + Notify().HideRomBrowser(); - if (bHaveDebugger()) - { - g_LogOptions.GenerateLog = g_Settings->LoadBool(Debugger_GenerateDebugLog); - LoadLogOptions(&g_LogOptions, FALSE); - StartLog(); - } + if (bHaveDebugger()) + { + g_LogOptions.GenerateLog = g_Settings->LoadBool(Debugger_GenerateDebugLog); + LoadLogOptions(&g_LogOptions, FALSE); + StartLog(); + } - CInterpreterCPU::BuildCPU(); + CInterpreterCPU::BuildCPU(); - DWORD CpuType = g_Settings->LoadDword(Game_CpuType); + DWORD CpuType = g_Settings->LoadDword(Game_CpuType); - if (CpuType == CPU_SyncCores && !g_Settings->LoadBool(Debugger_Enabled)) - { - g_Settings->SaveDword(Game_CpuType, CPU_Recompiler); - CpuType = CPU_Recompiler; - } + if (CpuType == CPU_SyncCores && !g_Settings->LoadBool(Debugger_Enabled)) + { + g_Settings->SaveDword(Game_CpuType, CPU_Recompiler); + CpuType = CPU_Recompiler; + } - if (CpuType == CPU_SyncCores) - { - g_Notify->DisplayMessage(5, L"Copy Plugins"); - g_Plugins->CopyPlugins(g_Settings->LoadStringVal(Directory_PluginSync)); + if (CpuType == CPU_SyncCores) + { + g_Notify->DisplayMessage(5, L"Copy Plugins"); + g_Plugins->CopyPlugins(g_Settings->LoadStringVal(Directory_PluginSync)); #if defined(WINDOWS_UI) - m_SyncWindow = new CMainGui(false); - m_SyncPlugins = new CPlugins(g_Settings->LoadStringVal(Directory_PluginSync)); - m_SyncPlugins->SetRenderWindows(m_SyncWindow, m_SyncWindow); + m_SyncWindow = new CMainGui(false); + m_SyncPlugins = new CPlugins(g_Settings->LoadStringVal(Directory_PluginSync)); + m_SyncPlugins->SetRenderWindows(m_SyncWindow, m_SyncWindow); - m_SyncCPU = new CN64System(m_SyncPlugins, true); + m_SyncCPU = new CN64System(m_SyncPlugins, true); #else - g_Notify -> BreakPoint(__FILEW__, __LINE__); + g_Notify -> BreakPoint(__FILEW__, __LINE__); #endif - } + } - if (CpuType == CPU_Recompiler || CpuType == CPU_SyncCores) - { - m_Recomp = new CRecompiler(m_Reg, m_Profile, m_EndEmulation); - } + if (CpuType == CPU_Recompiler || CpuType == CPU_SyncCores) + { + m_Recomp = new CRecompiler(m_Reg, m_Profile, m_EndEmulation); + } - bool bSetActive = true; - if (m_SyncCPU) - { - bSetActive = m_SyncCPU->SetActiveSystem(); - } + bool bSetActive = true; + if (m_SyncCPU) + { + bSetActive = m_SyncCPU->SetActiveSystem(); + } - if (bSetActive) - { - bSetActive = SetActiveSystem(); - } + if (bSetActive) + { + bSetActive = SetActiveSystem(); + } - if (!bSetActive) - { - g_Settings->SaveBool(GameRunning_LoadingInProgress, false); - g_Notify->DisplayError(MSG_PLUGIN_NOT_INIT); + if (!bSetActive) + { + g_Settings->SaveBool(GameRunning_LoadingInProgress, false); + g_Notify->DisplayError(MSG_PLUGIN_NOT_INIT); - Notify().RefreshMenu(); - Notify().ShowRomBrowser(); - } + Notify().RefreshMenu(); + Notify().ShowRomBrowser(); + } - Notify().MakeWindowOnTop(g_Settings->LoadBool(UserInterface_AlwaysOnTop)); + Notify().MakeWindowOnTop(g_Settings->LoadBool(UserInterface_AlwaysOnTop)); - ThreadInfo * Info = new ThreadInfo; - HANDLE * hThread = new HANDLE; - *hThread = NULL; + ThreadInfo * Info = new ThreadInfo; + HANDLE * hThread = new HANDLE; + *hThread = NULL; - //create the needed info into a structure to pass as one parameter - //for creating a thread - Info->ThreadHandle = hThread; + //create the needed info into a structure to pass as one parameter + //for creating a thread + Info->ThreadHandle = hThread; - *hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)StartEmulationThread, Info, 0, &Info->ThreadID); - } - else - { - //mark the emulation as starting and fix up menus - g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED); + *hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)StartEmulationThread, Info, 0, &Info->ThreadID); + } + else + { + //mark the emulation as starting and fix up menus + g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED); - if (g_Settings->LoadBool(Setting_AutoFullscreen)) - { - WriteTrace(TraceDebug, __FUNCTION__ " 15"); - CIniFile RomIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str()); - stdstr Status = g_Settings->LoadStringVal(Rdb_Status); + if (g_Settings->LoadBool(Setting_AutoFullscreen)) + { + WriteTrace(TraceDebug, __FUNCTION__ " 15"); + CIniFile RomIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str()); + stdstr Status = g_Settings->LoadStringVal(Rdb_Status); - char String[100]; - RomIniFile.GetString("Rom Status", stdstr_f("%s.AutoFullScreen", Status.c_str()).c_str(), "true", String, sizeof(String)); - if (_stricmp(String, "true") == 0) - { - Notify().ChangeFullScreen(); - } - } - ExecuteCPU(); - } + char String[100]; + RomIniFile.GetString("Rom Status", stdstr_f("%s.AutoFullScreen", Status.c_str()).c_str(), "true", String, sizeof(String)); + if (_stricmp(String, "true") == 0) + { + Notify().ChangeFullScreen(); + } + } + ExecuteCPU(); + } } void CN64System::StartEmulation(bool NewThread) { - __try - { - StartEmulation2(NewThread); - } - __except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation())) - { - char Message[600]; - sprintf(Message, "Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__); - MessageBox(NULL, Message, "Exception", MB_OK); - } + __try + { + StartEmulation2(NewThread); + } + __except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation())) + { + char Message[600]; + sprintf(Message, "Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__); + MessageBox(NULL, Message, "Exception", MB_OK); + } } void CN64System::StartEmulationThread(ThreadInfo * Info) { - CoInitialize(NULL); + CoInitialize(NULL); - EmulationStarting(*Info->ThreadHandle, Info->ThreadID); - delete Info->ThreadHandle; - delete Info; + EmulationStarting(*Info->ThreadHandle, Info->ThreadID); + delete Info->ThreadHandle; + delete Info; - CoUninitialize(); + CoUninitialize(); } void CN64System::CloseCpu() { - if (m_CPU_Handle == NULL) - { - return; - } + if (m_CPU_Handle == NULL) + { + return; + } - m_EndEmulation = true; - if (g_Settings->LoadBool(GameRunning_CPU_Paused)) - { - SetEvent(m_hPauseEvent); - } + m_EndEmulation = true; + if (g_Settings->LoadBool(GameRunning_CPU_Paused)) + { + SetEvent(m_hPauseEvent); + } - if (GetCurrentThreadId() == m_CPU_ThreadID) - { - ExternalEvent(SysEvent_CloseCPU); - return; - } + if (GetCurrentThreadId() == m_CPU_ThreadID) + { + ExternalEvent(SysEvent_CloseCPU); + return; + } - HANDLE hThread = m_CPU_Handle; - for (int count = 0; count < 200; count++) - { - Sleep(100); - if (Notify().ProcessGuiMessages()) - { - return; - } + HANDLE hThread = m_CPU_Handle; + for (int count = 0; count < 200; count++) + { + Sleep(100); + if (Notify().ProcessGuiMessages()) + { + return; + } - DWORD ExitCode; - if (GetExitCodeThread(hThread, &ExitCode)) - { - if (ExitCode != STILL_ACTIVE) - { - break; - } - } - } + DWORD ExitCode; + if (GetExitCodeThread(hThread, &ExitCode)) + { + if (ExitCode != STILL_ACTIVE) + { + break; + } + } + } - if (hThread) - { - DWORD ExitCode; - GetExitCodeThread(hThread, &ExitCode); - if (ExitCode == STILL_ACTIVE) - { - TerminateThread(hThread, 0); - } - } - CpuStopped(); + if (hThread) + { + DWORD ExitCode; + GetExitCodeThread(hThread, &ExitCode); + if (ExitCode == STILL_ACTIVE) + { + TerminateThread(hThread, 0); + } + } + CpuStopped(); } void CN64System::DisplayRomInfo(HWND hParent) { - if (!g_Rom) { return; } + if (!g_Rom) { return; } - RomInformation Info(g_Rom); - Info.DisplayInformation(hParent); + RomInformation Info(g_Rom); + Info.DisplayInformation(hParent); } void CN64System::Pause() { - if (m_EndEmulation) - { - return; - } - ResetEvent(m_hPauseEvent); - g_Settings->SaveBool(GameRunning_CPU_Paused, true); - Notify().RefreshMenu(); - g_Notify->DisplayMessage(5, MSG_CPU_PAUSED); - WaitForSingleObject(m_hPauseEvent, INFINITE); - ResetEvent(m_hPauseEvent); - g_Settings->SaveBool(GameRunning_CPU_Paused, (DWORD)false); - Notify().RefreshMenu(); - Notify().DisplayMessage(5, MSG_CPU_RESUMED); + if (m_EndEmulation) + { + return; + } + ResetEvent(m_hPauseEvent); + g_Settings->SaveBool(GameRunning_CPU_Paused, true); + Notify().RefreshMenu(); + g_Notify->DisplayMessage(5, MSG_CPU_PAUSED); + WaitForSingleObject(m_hPauseEvent, INFINITE); + ResetEvent(m_hPauseEvent); + g_Settings->SaveBool(GameRunning_CPU_Paused, (DWORD)false); + Notify().RefreshMenu(); + Notify().DisplayMessage(5, MSG_CPU_RESUMED); } stdstr CN64System::ChooseFileToOpen(HWND hParent) { - OPENFILENAME openfilename; - char FileName[_MAX_PATH], Directory[_MAX_PATH]; + OPENFILENAME openfilename; + char FileName[_MAX_PATH], Directory[_MAX_PATH]; - memset(&FileName, 0, sizeof(FileName)); - memset(&openfilename, 0, sizeof(openfilename)); + memset(&FileName, 0, sizeof(FileName)); + memset(&openfilename, 0, sizeof(openfilename)); - strcpy(Directory, g_Settings->LoadStringVal(Directory_Game).c_str()); + strcpy(Directory, g_Settings->LoadStringVal(Directory_Game).c_str()); - openfilename.lStructSize = sizeof(openfilename); - openfilename.hwndOwner = (HWND)hParent; - openfilename.lpstrFilter = "N64 ROMs (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0"; - openfilename.lpstrFile = FileName; - openfilename.lpstrInitialDir = Directory; - openfilename.nMaxFile = MAX_PATH; - openfilename.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; + openfilename.lStructSize = sizeof(openfilename); + openfilename.hwndOwner = (HWND)hParent; + openfilename.lpstrFilter = "N64 ROMs (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0"; + openfilename.lpstrFile = FileName; + openfilename.lpstrInitialDir = Directory; + openfilename.nMaxFile = MAX_PATH; + openfilename.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; - if (GetOpenFileName(&openfilename)) - { - return stdstr(FileName); - } - return stdstr(""); + if (GetOpenFileName(&openfilename)) + { + return stdstr(FileName); + } + return stdstr(""); } void CN64System::GameReset() { - m_SystemTimer.SetTimer(CSystemTimer::SoftResetTimer, 0x3000000, false); - m_Plugins->Gfx()->ShowCFB(); - m_Reg.FAKE_CAUSE_REGISTER |= CAUSE_IP4; - m_Plugins->Gfx()->SoftReset(); - if (m_SyncCPU) - { - m_SyncCPU->GameReset(); - } + m_SystemTimer.SetTimer(CSystemTimer::SoftResetTimer, 0x3000000, false); + m_Plugins->Gfx()->ShowCFB(); + m_Reg.FAKE_CAUSE_REGISTER |= CAUSE_IP4; + m_Plugins->Gfx()->SoftReset(); + if (m_SyncCPU) + { + m_SyncCPU->GameReset(); + } } void CN64System::PluginReset() { - if (!m_Plugins->ResetInUiThread(this)) - { - g_Notify->DisplayMessage(5, MSG_PLUGIN_NOT_INIT); - if (g_BaseSystem) - { - g_BaseSystem->m_EndEmulation = true; - } - } - if (m_SyncCPU) - { - if (!m_SyncCPU->m_Plugins->ResetInUiThread(m_SyncCPU)) - { - g_Notify->DisplayMessage(5, MSG_PLUGIN_NOT_INIT); - if (g_BaseSystem) - { - g_BaseSystem->m_EndEmulation = true; - } - } - } - Notify().RefreshMenu(); - if (m_Recomp) - { - m_Recomp->Reset(); - } - m_Plugins->RomOpened(); - if (m_SyncCPU) - { - m_SyncCPU->m_Plugins->RomOpened(); - } + if (!m_Plugins->ResetInUiThread(this)) + { + g_Notify->DisplayMessage(5, MSG_PLUGIN_NOT_INIT); + if (g_BaseSystem) + { + g_BaseSystem->m_EndEmulation = true; + } + } + if (m_SyncCPU) + { + if (!m_SyncCPU->m_Plugins->ResetInUiThread(m_SyncCPU)) + { + g_Notify->DisplayMessage(5, MSG_PLUGIN_NOT_INIT); + if (g_BaseSystem) + { + g_BaseSystem->m_EndEmulation = true; + } + } + } + Notify().RefreshMenu(); + if (m_Recomp) + { + m_Recomp->Reset(); + } + m_Plugins->RomOpened(); + if (m_SyncCPU) + { + m_SyncCPU->m_Plugins->RomOpened(); + } #ifndef _WIN64 - _controlfp(_PC_53, _MCW_PC); + _controlfp(_PC_53, _MCW_PC); #endif } void CN64System::Reset(bool bInitReg, bool ClearMenory) { - g_Settings->SaveBool(GameRunning_InReset, true); - RefreshGameSettings(); - m_Audio.Reset(); - m_MMU_VM.Reset(ClearMenory); - Mempak::Close(); + g_Settings->SaveBool(GameRunning_InReset, true); + RefreshGameSettings(); + m_Audio.Reset(); + m_MMU_VM.Reset(ClearMenory); + Mempak::Close(); - m_CyclesToSkip = 0; - m_AlistCount = 0; - m_DlistCount = 0; - m_UnknownCount = 0; - m_DMAUsed = false; - m_RspBroke = true; - m_SyncCount = 0; + m_CyclesToSkip = 0; + m_AlistCount = 0; + m_DlistCount = 0; + m_UnknownCount = 0; + m_DMAUsed = false; + m_RspBroke = true; + m_SyncCount = 0; - for (int i = 0, n = (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])); i < n; i++) - { - m_LastSuccessSyncPC[i] = 0; - } + for (int i = 0, n = (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])); i < n; i++) + { + m_LastSuccessSyncPC[i] = 0; + } - if (bInitReg) - { - bool PostPif = true; + if (bInitReg) + { + bool PostPif = true; - InitRegisters(PostPif, m_MMU_VM); - if (PostPif) - { - memcpy((m_MMU_VM.Dmem() + 0x40), (g_Rom->GetRomAddress() + 0x040), 0xFBC); - } - } - else - { - m_Reg.Reset(); - } + InitRegisters(PostPif, m_MMU_VM); + if (PostPif) + { + memcpy((m_MMU_VM.Dmem() + 0x40), (g_Rom->GetRomAddress() + 0x040), 0xFBC); + } + } + else + { + m_Reg.Reset(); + } - m_SystemTimer.Reset(); - m_SystemTimer.SetTimer(CSystemTimer::CompareTimer, m_Reg.COMPARE_REGISTER - m_Reg.COUNT_REGISTER, false); + m_SystemTimer.Reset(); + m_SystemTimer.SetTimer(CSystemTimer::CompareTimer, m_Reg.COMPARE_REGISTER - m_Reg.COUNT_REGISTER, false); - if (m_Recomp) - { - m_Recomp->Reset(); - } - if (m_Plugins) { m_Plugins->GameReset(); } - if (m_SyncCPU) - { - m_SyncCPU->Reset(bInitReg, ClearMenory); - } - g_Settings->SaveBool(GameRunning_InReset, true); + if (m_Recomp) + { + m_Recomp->Reset(); + } + if (m_Plugins) { m_Plugins->GameReset(); } + if (m_SyncCPU) + { + m_SyncCPU->Reset(bInitReg, ClearMenory); + } + g_Settings->SaveBool(GameRunning_InReset, true); } bool CN64System::SetActiveSystem(bool bActive) { - bool bInitPlugin = false; - bool bReset = false; - bool bRes = true; + bool bInitPlugin = false; + bool bReset = false; + bool bRes = true; - if (bActive && g_System == this) - { - return true; - } + if (bActive && g_System == this) + { + return true; + } - if (bActive) - { - m_Reg.SetAsCurrentSystem(); + if (bActive) + { + m_Reg.SetAsCurrentSystem(); - if (g_System) - { - g_System->m_TestTimer = R4300iOp::m_TestTimer; - g_System->m_NextInstruction = R4300iOp::m_NextInstruction; - g_System->m_JumpToLocation = R4300iOp::m_JumpToLocation; - } + if (g_System) + { + g_System->m_TestTimer = R4300iOp::m_TestTimer; + g_System->m_NextInstruction = R4300iOp::m_NextInstruction; + g_System->m_JumpToLocation = R4300iOp::m_JumpToLocation; + } - g_System = this; - if (g_BaseSystem == this) - { - g_SyncSystem = m_SyncCPU; - } - g_Recompiler = m_Recomp; - g_MMU = &m_MMU_VM; - g_TLB = &m_TLB; - g_Reg = &m_Reg; - g_Audio = &m_Audio; - g_SystemTimer = &m_SystemTimer; - g_TransVaddr = &m_MMU_VM; - g_SystemEvents = this; - g_NextTimer = &m_NextTimer; - g_Plugins = m_Plugins; - g_TLBLoadAddress = &m_TLBLoadAddress; - g_TLBStoreAddress = &m_TLBStoreAddress; - R4300iOp::m_TestTimer = m_TestTimer; - R4300iOp::m_NextInstruction = m_NextInstruction; - R4300iOp::m_JumpToLocation = m_JumpToLocation; + g_System = this; + if (g_BaseSystem == this) + { + g_SyncSystem = m_SyncCPU; + } + g_Recompiler = m_Recomp; + g_MMU = &m_MMU_VM; + g_TLB = &m_TLB; + g_Reg = &m_Reg; + g_Audio = &m_Audio; + g_SystemTimer = &m_SystemTimer; + g_TransVaddr = &m_MMU_VM; + g_SystemEvents = this; + g_NextTimer = &m_NextTimer; + g_Plugins = m_Plugins; + g_TLBLoadAddress = &m_TLBLoadAddress; + g_TLBStoreAddress = &m_TLBStoreAddress; + R4300iOp::m_TestTimer = m_TestTimer; + R4300iOp::m_NextInstruction = m_NextInstruction; + R4300iOp::m_JumpToLocation = m_JumpToLocation; - if (!m_bInitialized) - { - if (!m_MMU_VM.Initialize()) - { - return false; - } - bReset = true; - m_bInitialized = true; - bInitPlugin = true; - } - } - else - { - if (this == g_BaseSystem) - { - g_System = NULL; - g_SyncSystem = NULL; - g_Recompiler = NULL; - g_MMU = NULL; - g_TLB = NULL; - g_Reg = NULL; - g_Audio = NULL; - g_SystemTimer = NULL; - g_TransVaddr = NULL; - g_SystemEvents = NULL; - g_NextTimer = NULL; - g_Plugins = m_Plugins; - g_TLBLoadAddress = NULL; - g_TLBStoreAddress = NULL; - } - } + if (!m_bInitialized) + { + if (!m_MMU_VM.Initialize()) + { + return false; + } + bReset = true; + m_bInitialized = true; + bInitPlugin = true; + } + } + else + { + if (this == g_BaseSystem) + { + g_System = NULL; + g_SyncSystem = NULL; + g_Recompiler = NULL; + g_MMU = NULL; + g_TLB = NULL; + g_Reg = NULL; + g_Audio = NULL; + g_SystemTimer = NULL; + g_TransVaddr = NULL; + g_SystemEvents = NULL; + g_NextTimer = NULL; + g_Plugins = m_Plugins; + g_TLBLoadAddress = NULL; + g_TLBStoreAddress = NULL; + } + } - if (bInitPlugin) - { - WriteTrace(TraceDebug, __FUNCTION__ ": Reseting Plugins"); - g_Notify->DisplayMessage(5, MSG_PLUGIN_INIT); - m_Plugins->CreatePlugins(); - bRes = m_Plugins->Initiate(this); - if (!bRes) - { - WriteTrace(TraceError, __FUNCTION__ ": g_Plugins->Initiate Failed"); - } - } + if (bInitPlugin) + { + WriteTrace(TraceDebug, __FUNCTION__ ": Reseting Plugins"); + g_Notify->DisplayMessage(5, MSG_PLUGIN_INIT); + m_Plugins->CreatePlugins(); + bRes = m_Plugins->Initiate(this); + if (!bRes) + { + WriteTrace(TraceError, __FUNCTION__ ": g_Plugins->Initiate Failed"); + } + } - if (bReset) - { - Reset(true, true); - } - return bRes; + if (bReset) + { + Reset(true, true); + } + return bRes; } void CN64System::InitRegisters(bool bPostPif, CMipsMemory & MMU) { - m_Reg.Reset(); + m_Reg.Reset(); - //COP0 Registers - m_Reg.RANDOM_REGISTER = 0x1F; - m_Reg.COUNT_REGISTER = 0x5000; - m_Reg.MI_VERSION_REG = 0x02020102; - m_Reg.SP_STATUS_REG = 0x00000001; - m_Reg.CAUSE_REGISTER = 0x0000005C; - m_Reg.CONTEXT_REGISTER = 0x007FFFF0; - m_Reg.EPC_REGISTER = 0xFFFFFFFF; - m_Reg.BAD_VADDR_REGISTER = 0xFFFFFFFF; - m_Reg.ERROREPC_REGISTER = 0xFFFFFFFF; - m_Reg.CONFIG_REGISTER = 0x0006E463; - m_Reg.STATUS_REGISTER = 0x34000000; + //COP0 Registers + m_Reg.RANDOM_REGISTER = 0x1F; + m_Reg.COUNT_REGISTER = 0x5000; + m_Reg.MI_VERSION_REG = 0x02020102; + m_Reg.SP_STATUS_REG = 0x00000001; + m_Reg.CAUSE_REGISTER = 0x0000005C; + m_Reg.CONTEXT_REGISTER = 0x007FFFF0; + m_Reg.EPC_REGISTER = 0xFFFFFFFF; + m_Reg.BAD_VADDR_REGISTER = 0xFFFFFFFF; + m_Reg.ERROREPC_REGISTER = 0xFFFFFFFF; + m_Reg.CONFIG_REGISTER = 0x0006E463; + m_Reg.STATUS_REGISTER = 0x34000000; - //m_Reg.REVISION_REGISTER = 0x00000511; - m_Reg.FixFpuLocations(); + //m_Reg.REVISION_REGISTER = 0x00000511; + m_Reg.FixFpuLocations(); - if (bPostPif) - { - m_Reg.m_PROGRAM_COUNTER = 0xA4000040; + if (bPostPif) + { + m_Reg.m_PROGRAM_COUNTER = 0xA4000040; - m_Reg.m_GPR[0].DW = 0x0000000000000000; - m_Reg.m_GPR[6].DW = 0xFFFFFFFFA4001F0C; - m_Reg.m_GPR[7].DW = 0xFFFFFFFFA4001F08; - m_Reg.m_GPR[8].DW = 0x00000000000000C0; - m_Reg.m_GPR[9].DW = 0x0000000000000000; - m_Reg.m_GPR[10].DW = 0x0000000000000040; - m_Reg.m_GPR[11].DW = 0xFFFFFFFFA4000040; - m_Reg.m_GPR[16].DW = 0x0000000000000000; - m_Reg.m_GPR[17].DW = 0x0000000000000000; - m_Reg.m_GPR[18].DW = 0x0000000000000000; - m_Reg.m_GPR[19].DW = 0x0000000000000000; - m_Reg.m_GPR[21].DW = 0x0000000000000000; - m_Reg.m_GPR[26].DW = 0x0000000000000000; - m_Reg.m_GPR[27].DW = 0x0000000000000000; - m_Reg.m_GPR[28].DW = 0x0000000000000000; - m_Reg.m_GPR[29].DW = 0xFFFFFFFFA4001FF0; - m_Reg.m_GPR[30].DW = 0x0000000000000000; + m_Reg.m_GPR[0].DW = 0x0000000000000000; + m_Reg.m_GPR[6].DW = 0xFFFFFFFFA4001F0C; + m_Reg.m_GPR[7].DW = 0xFFFFFFFFA4001F08; + m_Reg.m_GPR[8].DW = 0x00000000000000C0; + m_Reg.m_GPR[9].DW = 0x0000000000000000; + m_Reg.m_GPR[10].DW = 0x0000000000000040; + m_Reg.m_GPR[11].DW = 0xFFFFFFFFA4000040; + m_Reg.m_GPR[16].DW = 0x0000000000000000; + m_Reg.m_GPR[17].DW = 0x0000000000000000; + m_Reg.m_GPR[18].DW = 0x0000000000000000; + m_Reg.m_GPR[19].DW = 0x0000000000000000; + m_Reg.m_GPR[21].DW = 0x0000000000000000; + m_Reg.m_GPR[26].DW = 0x0000000000000000; + m_Reg.m_GPR[27].DW = 0x0000000000000000; + m_Reg.m_GPR[28].DW = 0x0000000000000000; + m_Reg.m_GPR[29].DW = 0xFFFFFFFFA4001FF0; + m_Reg.m_GPR[30].DW = 0x0000000000000000; - switch (g_Rom->GetCountry()) - { - case Germany: case french: case Italian: - case Europe: case Spanish: case Australia: - case X_PAL: case Y_PAL: - switch (g_Rom->CicChipID()) - { - case CIC_UNKNOWN: - case CIC_NUS_6102: - m_Reg.m_GPR[5].DW = 0xFFFFFFFFC0F1D859; - m_Reg.m_GPR[14].DW = 0x000000002DE108EA; - m_Reg.m_GPR[24].DW = 0x0000000000000000; - break; - case CIC_NUS_6103: - m_Reg.m_GPR[5].DW = 0xFFFFFFFFD4646273; - m_Reg.m_GPR[14].DW = 0x000000001AF99984; - m_Reg.m_GPR[24].DW = 0x0000000000000000; - break; - case CIC_NUS_6105: - MMU.SW_VAddr(0xA4001004, 0xBDA807FC); - m_Reg.m_GPR[5].DW = 0xFFFFFFFFDECAAAD1; - m_Reg.m_GPR[14].DW = 0x000000000CF85C13; - m_Reg.m_GPR[24].DW = 0x0000000000000002; - break; - case CIC_NUS_6106: - m_Reg.m_GPR[5].DW = 0xFFFFFFFFB04DC903; - m_Reg.m_GPR[14].DW = 0x000000001AF99984; - m_Reg.m_GPR[24].DW = 0x0000000000000002; - break; - } - m_Reg.m_GPR[20].DW = 0x0000000000000000; - m_Reg.m_GPR[23].DW = 0x0000000000000006; - m_Reg.m_GPR[31].DW = 0xFFFFFFFFA4001554; - break; - case NTSC_BETA: case X_NTSC: case USA: case Japan: - default: - switch (g_Rom->CicChipID()) - { - case CIC_UNKNOWN: - case CIC_NUS_6102: - m_Reg.m_GPR[5].DW = 0xFFFFFFFFC95973D5; - m_Reg.m_GPR[14].DW = 0x000000002449A366; - break; - case CIC_NUS_6103: - m_Reg.m_GPR[5].DW = 0xFFFFFFFF95315A28; - m_Reg.m_GPR[14].DW = 0x000000005BACA1DF; - break; - case CIC_NUS_6105: - MMU.SW_VAddr(0xA4001004, 0x8DA807FC); - m_Reg.m_GPR[5].DW = 0x000000005493FB9A; - m_Reg.m_GPR[14].DW = 0xFFFFFFFFC2C20384; - case CIC_NUS_6106: - m_Reg.m_GPR[5].DW = 0xFFFFFFFFE067221F; - m_Reg.m_GPR[14].DW = 0x000000005CD2B70F; - break; - } - m_Reg.m_GPR[20].DW = 0x0000000000000001; - m_Reg.m_GPR[23].DW = 0x0000000000000000; - m_Reg.m_GPR[24].DW = 0x0000000000000003; - m_Reg.m_GPR[31].DW = 0xFFFFFFFFA4001550; - } + switch (g_Rom->GetCountry()) + { + case Germany: case french: case Italian: + case Europe: case Spanish: case Australia: + case X_PAL: case Y_PAL: + switch (g_Rom->CicChipID()) + { + case CIC_UNKNOWN: + case CIC_NUS_6102: + m_Reg.m_GPR[5].DW = 0xFFFFFFFFC0F1D859; + m_Reg.m_GPR[14].DW = 0x000000002DE108EA; + m_Reg.m_GPR[24].DW = 0x0000000000000000; + break; + case CIC_NUS_6103: + m_Reg.m_GPR[5].DW = 0xFFFFFFFFD4646273; + m_Reg.m_GPR[14].DW = 0x000000001AF99984; + m_Reg.m_GPR[24].DW = 0x0000000000000000; + break; + case CIC_NUS_6105: + MMU.SW_VAddr(0xA4001004, 0xBDA807FC); + m_Reg.m_GPR[5].DW = 0xFFFFFFFFDECAAAD1; + m_Reg.m_GPR[14].DW = 0x000000000CF85C13; + m_Reg.m_GPR[24].DW = 0x0000000000000002; + break; + case CIC_NUS_6106: + m_Reg.m_GPR[5].DW = 0xFFFFFFFFB04DC903; + m_Reg.m_GPR[14].DW = 0x000000001AF99984; + m_Reg.m_GPR[24].DW = 0x0000000000000002; + break; + } + m_Reg.m_GPR[20].DW = 0x0000000000000000; + m_Reg.m_GPR[23].DW = 0x0000000000000006; + m_Reg.m_GPR[31].DW = 0xFFFFFFFFA4001554; + break; + case NTSC_BETA: case X_NTSC: case USA: case Japan: + default: + switch (g_Rom->CicChipID()) + { + case CIC_UNKNOWN: + case CIC_NUS_6102: + m_Reg.m_GPR[5].DW = 0xFFFFFFFFC95973D5; + m_Reg.m_GPR[14].DW = 0x000000002449A366; + break; + case CIC_NUS_6103: + m_Reg.m_GPR[5].DW = 0xFFFFFFFF95315A28; + m_Reg.m_GPR[14].DW = 0x000000005BACA1DF; + break; + case CIC_NUS_6105: + MMU.SW_VAddr(0xA4001004, 0x8DA807FC); + m_Reg.m_GPR[5].DW = 0x000000005493FB9A; + m_Reg.m_GPR[14].DW = 0xFFFFFFFFC2C20384; + case CIC_NUS_6106: + m_Reg.m_GPR[5].DW = 0xFFFFFFFFE067221F; + m_Reg.m_GPR[14].DW = 0x000000005CD2B70F; + break; + } + m_Reg.m_GPR[20].DW = 0x0000000000000001; + m_Reg.m_GPR[23].DW = 0x0000000000000000; + m_Reg.m_GPR[24].DW = 0x0000000000000003; + m_Reg.m_GPR[31].DW = 0xFFFFFFFFA4001550; + } - switch (g_Rom->CicChipID()) - { - case CIC_NUS_6101: - m_Reg.m_GPR[22].DW = 0x000000000000003F; - break; - case CIC_NUS_8303: //64DD IPL CIC - case CIC_NUS_5167: //64DD CONVERSION CIC - m_Reg.m_GPR[22].DW = 0x00000000000000DD; - break; - case CIC_UNKNOWN: - case CIC_NUS_6102: - m_Reg.m_GPR[1].DW = 0x0000000000000001; - m_Reg.m_GPR[2].DW = 0x000000000EBDA536; - m_Reg.m_GPR[3].DW = 0x000000000EBDA536; - m_Reg.m_GPR[4].DW = 0x000000000000A536; - m_Reg.m_GPR[12].DW = 0xFFFFFFFFED10D0B3; - m_Reg.m_GPR[13].DW = 0x000000001402A4CC; - m_Reg.m_GPR[15].DW = 0x000000003103E121; - m_Reg.m_GPR[22].DW = 0x000000000000003F; - m_Reg.m_GPR[25].DW = 0xFFFFFFFF9DEBB54F; - break; - case CIC_NUS_6103: - m_Reg.m_GPR[1].DW = 0x0000000000000001; - m_Reg.m_GPR[2].DW = 0x0000000049A5EE96; - m_Reg.m_GPR[3].DW = 0x0000000049A5EE96; - m_Reg.m_GPR[4].DW = 0x000000000000EE96; - m_Reg.m_GPR[12].DW = 0xFFFFFFFFCE9DFBF7; - m_Reg.m_GPR[13].DW = 0xFFFFFFFFCE9DFBF7; - m_Reg.m_GPR[15].DW = 0x0000000018B63D28; - m_Reg.m_GPR[22].DW = 0x0000000000000078; - m_Reg.m_GPR[25].DW = 0xFFFFFFFF825B21C9; - break; - case CIC_NUS_6105: - MMU.SW_VAddr(0xA4001000, 0x3C0DBFC0); - MMU.SW_VAddr(0xA4001008, 0x25AD07C0); - MMU.SW_VAddr(0xA400100C, 0x31080080); - MMU.SW_VAddr(0xA4001010, 0x5500FFFC); - MMU.SW_VAddr(0xA4001014, 0x3C0DBFC0); - MMU.SW_VAddr(0xA4001018, 0x8DA80024); - MMU.SW_VAddr(0xA400101C, 0x3C0BB000); - m_Reg.m_GPR[1].DW = 0x0000000000000000; - m_Reg.m_GPR[2].DW = 0xFFFFFFFFF58B0FBF; - m_Reg.m_GPR[3].DW = 0xFFFFFFFFF58B0FBF; - m_Reg.m_GPR[4].DW = 0x0000000000000FBF; - m_Reg.m_GPR[12].DW = 0xFFFFFFFF9651F81E; - m_Reg.m_GPR[13].DW = 0x000000002D42AAC5; - m_Reg.m_GPR[15].DW = 0x0000000056584D60; - m_Reg.m_GPR[22].DW = 0x0000000000000091; - m_Reg.m_GPR[25].DW = 0xFFFFFFFFCDCE565F; - break; - case CIC_NUS_6106: - m_Reg.m_GPR[1].DW = 0x0000000000000000; - m_Reg.m_GPR[2].DW = 0xFFFFFFFFA95930A4; - m_Reg.m_GPR[3].DW = 0xFFFFFFFFA95930A4; - m_Reg.m_GPR[4].DW = 0x00000000000030A4; - m_Reg.m_GPR[12].DW = 0xFFFFFFFFBCB59510; - m_Reg.m_GPR[13].DW = 0xFFFFFFFFBCB59510; - m_Reg.m_GPR[15].DW = 0x000000007A3C07F4; - m_Reg.m_GPR[22].DW = 0x0000000000000085; - m_Reg.m_GPR[25].DW = 0x00000000465E3F72; - break; - } - } - else - { - m_Reg.m_PROGRAM_COUNTER = 0xBFC00000; - /* PIF_Ram[36] = 0x00; PIF_Ram[39] = 0x3F; //common pif ram start values + switch (g_Rom->CicChipID()) + { + case CIC_NUS_6101: + m_Reg.m_GPR[22].DW = 0x000000000000003F; + break; + case CIC_NUS_8303: //64DD IPL CIC + case CIC_NUS_5167: //64DD CONVERSION CIC + m_Reg.m_GPR[22].DW = 0x00000000000000DD; + break; + case CIC_UNKNOWN: + case CIC_NUS_6102: + m_Reg.m_GPR[1].DW = 0x0000000000000001; + m_Reg.m_GPR[2].DW = 0x000000000EBDA536; + m_Reg.m_GPR[3].DW = 0x000000000EBDA536; + m_Reg.m_GPR[4].DW = 0x000000000000A536; + m_Reg.m_GPR[12].DW = 0xFFFFFFFFED10D0B3; + m_Reg.m_GPR[13].DW = 0x000000001402A4CC; + m_Reg.m_GPR[15].DW = 0x000000003103E121; + m_Reg.m_GPR[22].DW = 0x000000000000003F; + m_Reg.m_GPR[25].DW = 0xFFFFFFFF9DEBB54F; + break; + case CIC_NUS_6103: + m_Reg.m_GPR[1].DW = 0x0000000000000001; + m_Reg.m_GPR[2].DW = 0x0000000049A5EE96; + m_Reg.m_GPR[3].DW = 0x0000000049A5EE96; + m_Reg.m_GPR[4].DW = 0x000000000000EE96; + m_Reg.m_GPR[12].DW = 0xFFFFFFFFCE9DFBF7; + m_Reg.m_GPR[13].DW = 0xFFFFFFFFCE9DFBF7; + m_Reg.m_GPR[15].DW = 0x0000000018B63D28; + m_Reg.m_GPR[22].DW = 0x0000000000000078; + m_Reg.m_GPR[25].DW = 0xFFFFFFFF825B21C9; + break; + case CIC_NUS_6105: + MMU.SW_VAddr(0xA4001000, 0x3C0DBFC0); + MMU.SW_VAddr(0xA4001008, 0x25AD07C0); + MMU.SW_VAddr(0xA400100C, 0x31080080); + MMU.SW_VAddr(0xA4001010, 0x5500FFFC); + MMU.SW_VAddr(0xA4001014, 0x3C0DBFC0); + MMU.SW_VAddr(0xA4001018, 0x8DA80024); + MMU.SW_VAddr(0xA400101C, 0x3C0BB000); + m_Reg.m_GPR[1].DW = 0x0000000000000000; + m_Reg.m_GPR[2].DW = 0xFFFFFFFFF58B0FBF; + m_Reg.m_GPR[3].DW = 0xFFFFFFFFF58B0FBF; + m_Reg.m_GPR[4].DW = 0x0000000000000FBF; + m_Reg.m_GPR[12].DW = 0xFFFFFFFF9651F81E; + m_Reg.m_GPR[13].DW = 0x000000002D42AAC5; + m_Reg.m_GPR[15].DW = 0x0000000056584D60; + m_Reg.m_GPR[22].DW = 0x0000000000000091; + m_Reg.m_GPR[25].DW = 0xFFFFFFFFCDCE565F; + break; + case CIC_NUS_6106: + m_Reg.m_GPR[1].DW = 0x0000000000000000; + m_Reg.m_GPR[2].DW = 0xFFFFFFFFA95930A4; + m_Reg.m_GPR[3].DW = 0xFFFFFFFFA95930A4; + m_Reg.m_GPR[4].DW = 0x00000000000030A4; + m_Reg.m_GPR[12].DW = 0xFFFFFFFFBCB59510; + m_Reg.m_GPR[13].DW = 0xFFFFFFFFBCB59510; + m_Reg.m_GPR[15].DW = 0x000000007A3C07F4; + m_Reg.m_GPR[22].DW = 0x0000000000000085; + m_Reg.m_GPR[25].DW = 0x00000000465E3F72; + break; + } + } + else + { + m_Reg.m_PROGRAM_COUNTER = 0xBFC00000; + /* PIF_Ram[36] = 0x00; PIF_Ram[39] = 0x3F; //common pif ram start values - switch (g_Rom->CicChipID()) { - case CIC_NUS_6101: PIF_Ram[37] = 0x06; PIF_Ram[38] = 0x3F; break; - case CIC_UNKNOWN: - case CIC_NUS_6102: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x3F; break; - case CIC_NUS_6103: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x78; break; - case CIC_NUS_6105: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x91; break; - case CIC_NUS_6106: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x85; break; - }*/ - } + switch (g_Rom->CicChipID()) { + case CIC_NUS_6101: PIF_Ram[37] = 0x06; PIF_Ram[38] = 0x3F; break; + case CIC_UNKNOWN: + case CIC_NUS_6102: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x3F; break; + case CIC_NUS_6103: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x78; break; + case CIC_NUS_6105: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x91; break; + case CIC_NUS_6106: PIF_Ram[37] = 0x02; PIF_Ram[38] = 0x85; break; + }*/ + } } void CN64System::ExecuteCPU() { - //reset code - g_Settings->SaveBool(GameRunning_CPU_Running, true); - g_Settings->SaveBool(GameRunning_CPU_Paused, false); - g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED); + //reset code + g_Settings->SaveBool(GameRunning_CPU_Running, true); + g_Settings->SaveBool(GameRunning_CPU_Paused, false); + g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED); - m_EndEmulation = false; - Notify().RefreshMenu(); + m_EndEmulation = false; + Notify().RefreshMenu(); - m_Plugins->RomOpened(); - if (m_SyncCPU) - { - m_SyncCPU->m_Plugins->RomOpened(); - } + m_Plugins->RomOpened(); + if (m_SyncCPU) + { + m_SyncCPU->m_Plugins->RomOpened(); + } #ifndef _WIN64 - _controlfp(_PC_53, _MCW_PC); + _controlfp(_PC_53, _MCW_PC); #endif - switch ((CPU_TYPE)g_Settings->LoadDword(Game_CpuType)) - { - // Currently the compiler is 32-bit only. We might have to ignore that RDB setting for now. + switch ((CPU_TYPE)g_Settings->LoadDword(Game_CpuType)) + { + // Currently the compiler is 32-bit only. We might have to ignore that RDB setting for now. #ifndef _WIN64 - case CPU_Recompiler: ExecuteRecompiler(); break; - case CPU_SyncCores: ExecuteSyncCPU(); break; + case CPU_Recompiler: ExecuteRecompiler(); break; + case CPU_SyncCores: ExecuteSyncCPU(); break; #endif - default: ExecuteInterpret(); break; - } - g_Settings->SaveBool(GameRunning_CPU_Running, (DWORD)false); - Notify().WindowMode(); - m_Plugins->RomClosed(); - if (m_SyncCPU) - { - m_SyncCPU->m_Plugins->RomClosed(); - } + default: ExecuteInterpret(); break; + } + g_Settings->SaveBool(GameRunning_CPU_Running, (DWORD)false); + Notify().WindowMode(); + m_Plugins->RomClosed(); + if (m_SyncCPU) + { + m_SyncCPU->m_Plugins->RomClosed(); + } } void CN64System::ExecuteInterpret() { - SetActiveSystem(); - CInterpreterCPU::ExecuteCPU(); + SetActiveSystem(); + CInterpreterCPU::ExecuteCPU(); } void CN64System::ExecuteRecompiler() { - m_Recomp->Run(); + m_Recomp->Run(); } void CN64System::ExecuteSyncCPU() { - Notify().BringToTop(); - m_Recomp->Run(); + Notify().BringToTop(); + m_Recomp->Run(); } void CN64System::CpuStopped() { - g_Settings->SaveBool(GameRunning_CPU_Running, (DWORD)false); - Notify().WindowMode(); - if (!m_InReset) - { - if (m_hPauseEvent) - { - CloseHandle(m_hPauseEvent); - m_hPauseEvent = NULL; - } + g_Settings->SaveBool(GameRunning_CPU_Running, (DWORD)false); + Notify().WindowMode(); + if (!m_InReset) + { + if (m_hPauseEvent) + { + CloseHandle(m_hPauseEvent); + m_hPauseEvent = NULL; + } - Notify().RefreshMenu(); - Notify().MakeWindowOnTop(false); - g_Notify->DisplayMessage(5, MSG_EMULATION_ENDED); - if (g_Settings->LoadDword(RomBrowser_Enabled)) - { - Notify().ShowRomBrowser(); - } - } - if (m_SyncCPU) - { - m_SyncCPU->CpuStopped(); - } + Notify().RefreshMenu(); + Notify().MakeWindowOnTop(false); + g_Notify->DisplayMessage(5, MSG_EMULATION_ENDED); + if (g_Settings->LoadDword(RomBrowser_Enabled)) + { + Notify().ShowRomBrowser(); + } + } + if (m_SyncCPU) + { + m_SyncCPU->CpuStopped(); + } } void CN64System::UpdateSyncCPU(CN64System * const SecondCPU, DWORD const Cycles) { - int CyclesToExecute = Cycles - m_CyclesToSkip; + int CyclesToExecute = Cycles - m_CyclesToSkip; - //Update the number of cycles to skip - m_CyclesToSkip -= Cycles; - if (m_CyclesToSkip < 0) { m_CyclesToSkip = 0; } + //Update the number of cycles to skip + m_CyclesToSkip -= Cycles; + if (m_CyclesToSkip < 0) { m_CyclesToSkip = 0; } - //Run the other CPU For the same amount of cycles - if (CyclesToExecute < 0) { return; } + //Run the other CPU For the same amount of cycles + if (CyclesToExecute < 0) { return; } - SecondCPU->SetActiveSystem(true); + SecondCPU->SetActiveSystem(true); - CInterpreterCPU::ExecuteOps(Cycles); + CInterpreterCPU::ExecuteOps(Cycles); - SetActiveSystem(true); + SetActiveSystem(true); } void CN64System::SyncCPUPC(CN64System * const SecondCPU) { - bool ErrorFound = false; + bool ErrorFound = false; - g_SystemTimer->UpdateTimers(); - if (m_Reg.m_PROGRAM_COUNTER != SecondCPU->m_Reg.m_PROGRAM_COUNTER) - { - ErrorFound = true; - } + g_SystemTimer->UpdateTimers(); + if (m_Reg.m_PROGRAM_COUNTER != SecondCPU->m_Reg.m_PROGRAM_COUNTER) + { + ErrorFound = true; + } - if (m_TLB != SecondCPU->m_TLB) { ErrorFound = true; } - if (m_SystemTimer != SecondCPU->m_SystemTimer) { ErrorFound = true; } - if (m_NextTimer != SecondCPU->m_NextTimer) { ErrorFound = true; } + if (m_TLB != SecondCPU->m_TLB) { ErrorFound = true; } + if (m_SystemTimer != SecondCPU->m_SystemTimer) { ErrorFound = true; } + if (m_NextTimer != SecondCPU->m_NextTimer) { ErrorFound = true; } - if (ErrorFound) { DumpSyncErrors(SecondCPU); } + if (ErrorFound) { DumpSyncErrors(SecondCPU); } - for (int i = (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])) - 1; i > 0; i--) - { - m_LastSuccessSyncPC[i] = m_LastSuccessSyncPC[i - 1]; - } - m_LastSuccessSyncPC[0] = m_Reg.m_PROGRAM_COUNTER; + for (int i = (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])) - 1; i > 0; i--) + { + m_LastSuccessSyncPC[i] = m_LastSuccessSyncPC[i - 1]; + } + m_LastSuccessSyncPC[0] = m_Reg.m_PROGRAM_COUNTER; } void CN64System::SyncCPU(CN64System * const SecondCPU) { - bool ErrorFound = false; + bool ErrorFound = false; - m_SyncCount += 1; - //WriteTraceF(TraceError,"SyncCPU PC = %08X",m_Reg.m_PROGRAM_COUNTER); - g_SystemTimer->UpdateTimers(); + m_SyncCount += 1; + //WriteTraceF(TraceError,"SyncCPU PC = %08X",m_Reg.m_PROGRAM_COUNTER); + g_SystemTimer->UpdateTimers(); #ifdef TEST_SP_TRACKING - if (m_CurrentSP != GPR[29].UW[0]) { - ErrorFound = true; - } + if (m_CurrentSP != GPR[29].UW[0]) { + ErrorFound = true; + } #endif - if (m_Reg.m_PROGRAM_COUNTER != SecondCPU->m_Reg.m_PROGRAM_COUNTER) - { - ErrorFound = true; - } - if (b32BitCore()) - { - for (int count = 0; count < 32; count++) - { - if (m_Reg.m_GPR[count].W[0] != SecondCPU->m_Reg.m_GPR[count].W[0]) - { - ErrorFound = true; - } - if (m_Reg.m_FPR[count].DW != SecondCPU->m_Reg.m_FPR[count].DW) - { - ErrorFound = true; - } - if (m_Reg.m_CP0[count] != SecondCPU->m_Reg.m_CP0[count]) - { - ErrorFound = true; - } - } - } - else - { - for (int count = 0; count < 32; count++) - { - if (m_Reg.m_GPR[count].DW != SecondCPU->m_Reg.m_GPR[count].DW) - { - ErrorFound = true; - } - if (m_Reg.m_FPR[count].DW != SecondCPU->m_Reg.m_FPR[count].DW) - { - ErrorFound = true; - } - if (m_Reg.m_CP0[count] != SecondCPU->m_Reg.m_CP0[count]) - { - ErrorFound = true; - } - } - } + if (m_Reg.m_PROGRAM_COUNTER != SecondCPU->m_Reg.m_PROGRAM_COUNTER) + { + ErrorFound = true; + } + if (b32BitCore()) + { + for (int count = 0; count < 32; count++) + { + if (m_Reg.m_GPR[count].W[0] != SecondCPU->m_Reg.m_GPR[count].W[0]) + { + ErrorFound = true; + } + if (m_Reg.m_FPR[count].DW != SecondCPU->m_Reg.m_FPR[count].DW) + { + ErrorFound = true; + } + if (m_Reg.m_CP0[count] != SecondCPU->m_Reg.m_CP0[count]) + { + ErrorFound = true; + } + } + } + else + { + for (int count = 0; count < 32; count++) + { + if (m_Reg.m_GPR[count].DW != SecondCPU->m_Reg.m_GPR[count].DW) + { + ErrorFound = true; + } + if (m_Reg.m_FPR[count].DW != SecondCPU->m_Reg.m_FPR[count].DW) + { + ErrorFound = true; + } + if (m_Reg.m_CP0[count] != SecondCPU->m_Reg.m_CP0[count]) + { + ErrorFound = true; + } + } + } - if (m_TLB != SecondCPU->m_TLB) { ErrorFound = true; } - if (m_Reg.m_FPCR[0] != SecondCPU->m_Reg.m_FPCR[0]) { ErrorFound = true; } - if (m_Reg.m_FPCR[31] != SecondCPU->m_Reg.m_FPCR[31]) { ErrorFound = true; } - if (m_Reg.m_HI.DW != SecondCPU->m_Reg.m_HI.DW) { ErrorFound = true; } - if (m_Reg.m_LO.DW != SecondCPU->m_Reg.m_LO.DW) { ErrorFound = true; } - /*if (m_SyncCount > 4788000) - { - if (memcmp(m_MMU_VM.Rdram(),SecondCPU->m_MMU_VM.Rdram(),RdramSize()) != 0) - { - ErrorFound = true; - } - } - if (memcmp(m_MMU_VM.Imem(),SecondCPU->m_MMU_VM.Imem(),0x1000) != 0) - { - ErrorFound = true; - } - if (memcmp(m_MMU_VM.Dmem(),SecondCPU->m_MMU_VM.Dmem(),0x1000) != 0) - { - ErrorFound = true; - }*/ + if (m_TLB != SecondCPU->m_TLB) { ErrorFound = true; } + if (m_Reg.m_FPCR[0] != SecondCPU->m_Reg.m_FPCR[0]) { ErrorFound = true; } + if (m_Reg.m_FPCR[31] != SecondCPU->m_Reg.m_FPCR[31]) { ErrorFound = true; } + if (m_Reg.m_HI.DW != SecondCPU->m_Reg.m_HI.DW) { ErrorFound = true; } + if (m_Reg.m_LO.DW != SecondCPU->m_Reg.m_LO.DW) { ErrorFound = true; } + /*if (m_SyncCount > 4788000) + { + if (memcmp(m_MMU_VM.Rdram(),SecondCPU->m_MMU_VM.Rdram(),RdramSize()) != 0) + { + ErrorFound = true; + } + } + if (memcmp(m_MMU_VM.Imem(),SecondCPU->m_MMU_VM.Imem(),0x1000) != 0) + { + ErrorFound = true; + } + if (memcmp(m_MMU_VM.Dmem(),SecondCPU->m_MMU_VM.Dmem(),0x1000) != 0) + { + ErrorFound = true; + }*/ - /*for (int z = 0; z < 0x100; z++) - { - if (m_MMU_VM.Rdram()[0x00206970 + z] != SecondCPU->m_MMU_VM.Rdram()[0x00206970 + z]) - { - ErrorFound = true; - break; - } - }*/ + /*for (int z = 0; z < 0x100; z++) + { + if (m_MMU_VM.Rdram()[0x00206970 + z] != SecondCPU->m_MMU_VM.Rdram()[0x00206970 + z]) + { + ErrorFound = true; + break; + } + }*/ - if (bFastSP() && m_Recomp) - { - if (m_Recomp->MemoryStackPos() != (DWORD)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF))) - { - ErrorFound = true; - } - } + if (bFastSP() && m_Recomp) + { + if (m_Recomp->MemoryStackPos() != (DWORD)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF))) + { + ErrorFound = true; + } + } - if (m_SystemTimer != SecondCPU->m_SystemTimer) { ErrorFound = true; } - if (m_NextTimer != SecondCPU->m_NextTimer) { ErrorFound = true; } - if (m_Reg.m_RoundingModel != SecondCPU->m_Reg.m_RoundingModel) { ErrorFound = true; } + if (m_SystemTimer != SecondCPU->m_SystemTimer) { ErrorFound = true; } + if (m_NextTimer != SecondCPU->m_NextTimer) { ErrorFound = true; } + if (m_Reg.m_RoundingModel != SecondCPU->m_Reg.m_RoundingModel) { ErrorFound = true; } - for (int i = 0, n = sizeof(m_Reg.m_Mips_Interface) / sizeof(m_Reg.m_Mips_Interface[0]); i < n; i++) - { - if (m_Reg.m_Mips_Interface[i] != SecondCPU->m_Reg.m_Mips_Interface[i]) - { - ErrorFound = true; - } - } + for (int i = 0, n = sizeof(m_Reg.m_Mips_Interface) / sizeof(m_Reg.m_Mips_Interface[0]); i < n; i++) + { + if (m_Reg.m_Mips_Interface[i] != SecondCPU->m_Reg.m_Mips_Interface[i]) + { + ErrorFound = true; + } + } - for (int i = 0, n = sizeof(m_Reg.m_SigProcessor_Interface) / sizeof(m_Reg.m_SigProcessor_Interface[0]); i < n; i++) - { - if (m_Reg.m_SigProcessor_Interface[i] != SecondCPU->m_Reg.m_SigProcessor_Interface[i]) - { - ErrorFound = true; - } - } + for (int i = 0, n = sizeof(m_Reg.m_SigProcessor_Interface) / sizeof(m_Reg.m_SigProcessor_Interface[0]); i < n; i++) + { + if (m_Reg.m_SigProcessor_Interface[i] != SecondCPU->m_Reg.m_SigProcessor_Interface[i]) + { + ErrorFound = true; + } + } - for (int i = 0, n = sizeof(m_Reg.m_Display_ControlReg) / sizeof(m_Reg.m_Display_ControlReg[0]); i < n; i++) - { - if (m_Reg.m_Display_ControlReg[i] != SecondCPU->m_Reg.m_Display_ControlReg[i]) - { - ErrorFound = true; - } - } + for (int i = 0, n = sizeof(m_Reg.m_Display_ControlReg) / sizeof(m_Reg.m_Display_ControlReg[0]); i < n; i++) + { + if (m_Reg.m_Display_ControlReg[i] != SecondCPU->m_Reg.m_Display_ControlReg[i]) + { + ErrorFound = true; + } + } - if (ErrorFound) { DumpSyncErrors(SecondCPU); } + if (ErrorFound) { DumpSyncErrors(SecondCPU); } - for (int i = (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])) - 1; i > 0; i--) - { - m_LastSuccessSyncPC[i] = m_LastSuccessSyncPC[i - 1]; - } - m_LastSuccessSyncPC[0] = m_Reg.m_PROGRAM_COUNTER; - // if (PROGRAM_COUNTER == 0x8009BBD8) { - // g_Notify->BreakPoint(__FILEW__,__LINE__); - // } + for (int i = (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])) - 1; i > 0; i--) + { + m_LastSuccessSyncPC[i] = m_LastSuccessSyncPC[i - 1]; + } + m_LastSuccessSyncPC[0] = m_Reg.m_PROGRAM_COUNTER; + // if (PROGRAM_COUNTER == 0x8009BBD8) { + // g_Notify->BreakPoint(__FILEW__,__LINE__); + // } } void CN64System::SyncSystem() { - SyncCPU(g_SyncSystem); + SyncCPU(g_SyncSystem); } void CN64System::SyncSystemPC() { - SyncCPUPC(g_SyncSystem); + SyncCPUPC(g_SyncSystem); } void CN64System::DumpSyncErrors(CN64System * SecondCPU) { - int count; + int count; - { - CPath ErrorFile(CPath::MODULE_DIRECTORY); - ErrorFile.AppendDirectory("Logs"); - ErrorFile.SetNameExtension("Sync Errors.txt"); + { + CPath ErrorFile(CPath::MODULE_DIRECTORY); + ErrorFile.AppendDirectory("Logs"); + ErrorFile.SetNameExtension("Sync Errors.txt"); - CLog Error; - Error.Open(ErrorFile); - Error.Log("Errors:\r\n"); - Error.Log("Register, Recompiler, Interpter\r\n"); + CLog Error; + Error.Open(ErrorFile); + Error.Log("Errors:\r\n"); + Error.Log("Register, Recompiler, Interpter\r\n"); #ifdef TEST_SP_TRACKING - if (m_CurrentSP != GPR[29].UW[0]) { - Error.Log("m_CurrentSP,%X,%X\r\n",m_CurrentSP,GPR[29].UW[0]); - } + if (m_CurrentSP != GPR[29].UW[0]) { + Error.Log("m_CurrentSP,%X,%X\r\n",m_CurrentSP,GPR[29].UW[0]); + } #endif - if (m_Reg.m_PROGRAM_COUNTER != SecondCPU->m_Reg.m_PROGRAM_COUNTER) { - Error.LogF("PROGRAM_COUNTER 0x%X, 0x%X\r\n", m_Reg.m_PROGRAM_COUNTER, SecondCPU->m_Reg.m_PROGRAM_COUNTER); - } - if (b32BitCore()) - { - for (count = 0; count < 32; count++) - { - if (m_Reg.m_GPR[count].UW[0] != SecondCPU->m_Reg.m_GPR[count].UW[0]) - { - Error.LogF("GPR[%s] 0x%08X%08X, 0x%08X%08X\r\n", CRegName::GPR[count], - m_Reg.m_GPR[count].W[1], m_Reg.m_GPR[count].W[0], - SecondCPU->m_Reg.m_GPR[count].W[1], SecondCPU->m_Reg.m_GPR[count].W[0]); - } - } - } - else - { - for (count = 0; count < 32; count++) - { - if (m_Reg.m_GPR[count].DW != SecondCPU->m_Reg.m_GPR[count].DW) - { - Error.LogF("GPR[%s] 0x%08X%08X, 0x%08X%08X\r\n", CRegName::GPR[count], - m_Reg.m_GPR[count].W[1], m_Reg.m_GPR[count].W[0], - SecondCPU->m_Reg.m_GPR[count].W[1], SecondCPU->m_Reg.m_GPR[count].W[0]); - } - } - } - for (count = 0; count < 32; count++) - { - if (m_Reg.m_FPR[count].DW != SecondCPU->m_Reg.m_FPR[count].DW) - { - Error.LogF("FPR[%s] 0x%08X%08X, 0x%08X%08X\r\n", CRegName::FPR[count], - m_Reg.m_FPR[count].W[1], m_Reg.m_FPR[count].W[0], - SecondCPU->m_Reg.m_FPR[count].W[1], SecondCPU->m_Reg.m_FPR[count].W[0]); - } - } - for (count = 0; count < 32; count++) - { - if (m_Reg.m_FPCR[count] != SecondCPU->m_Reg.m_FPCR[count]) - { - Error.LogF("FPCR[%s] 0x%08X, 0x%08X\r\n", CRegName::FPR_Ctrl[count], - m_Reg.m_FPCR[count], SecondCPU->m_Reg.m_FPCR[count]); - } - } - for (count = 0; count < 32; count++) - { - if (m_Reg.m_CP0[count] != SecondCPU->m_Reg.m_CP0[count]) - { - Error.LogF("CP0[%s] 0x%08X, 0x%08X\r\n", CRegName::Cop0[count], - m_Reg.m_CP0[count], SecondCPU->m_Reg.m_CP0[count]); - } - } - if (m_Reg.m_HI.DW != SecondCPU->m_Reg.m_HI.DW) - { - Error.LogF("HI Reg 0x%08X%08X, 0x%08X%08X\r\n", m_Reg.m_HI.UW[1], m_Reg.m_HI.UW[0], SecondCPU->m_Reg.m_HI.UW[1], SecondCPU->m_Reg.m_HI.UW[0]); - } - if (m_Reg.m_LO.DW != SecondCPU->m_Reg.m_LO.DW) - { - Error.LogF("LO Reg 0x%08X%08X, 0x%08X%08X\r\n", m_Reg.m_LO.UW[1], m_Reg.m_LO.UW[0], SecondCPU->m_Reg.m_LO.UW[1], SecondCPU->m_Reg.m_LO.UW[0]); - } - for (int i = 0, n = sizeof(m_Reg.m_Mips_Interface) / sizeof(m_Reg.m_Mips_Interface[0]); i < n; i++) - { - if (m_Reg.m_Mips_Interface[i] != SecondCPU->m_Reg.m_Mips_Interface[i]) - { - Error.LogF("Mips_Interface[%d] 0x%08X, 0x%08X\r\n", i, m_Reg.m_Mips_Interface[i], SecondCPU->m_Reg.m_Mips_Interface[i]); - } - } + if (m_Reg.m_PROGRAM_COUNTER != SecondCPU->m_Reg.m_PROGRAM_COUNTER) { + Error.LogF("PROGRAM_COUNTER 0x%X, 0x%X\r\n", m_Reg.m_PROGRAM_COUNTER, SecondCPU->m_Reg.m_PROGRAM_COUNTER); + } + if (b32BitCore()) + { + for (count = 0; count < 32; count++) + { + if (m_Reg.m_GPR[count].UW[0] != SecondCPU->m_Reg.m_GPR[count].UW[0]) + { + Error.LogF("GPR[%s] 0x%08X%08X, 0x%08X%08X\r\n", CRegName::GPR[count], + m_Reg.m_GPR[count].W[1], m_Reg.m_GPR[count].W[0], + SecondCPU->m_Reg.m_GPR[count].W[1], SecondCPU->m_Reg.m_GPR[count].W[0]); + } + } + } + else + { + for (count = 0; count < 32; count++) + { + if (m_Reg.m_GPR[count].DW != SecondCPU->m_Reg.m_GPR[count].DW) + { + Error.LogF("GPR[%s] 0x%08X%08X, 0x%08X%08X\r\n", CRegName::GPR[count], + m_Reg.m_GPR[count].W[1], m_Reg.m_GPR[count].W[0], + SecondCPU->m_Reg.m_GPR[count].W[1], SecondCPU->m_Reg.m_GPR[count].W[0]); + } + } + } + for (count = 0; count < 32; count++) + { + if (m_Reg.m_FPR[count].DW != SecondCPU->m_Reg.m_FPR[count].DW) + { + Error.LogF("FPR[%s] 0x%08X%08X, 0x%08X%08X\r\n", CRegName::FPR[count], + m_Reg.m_FPR[count].W[1], m_Reg.m_FPR[count].W[0], + SecondCPU->m_Reg.m_FPR[count].W[1], SecondCPU->m_Reg.m_FPR[count].W[0]); + } + } + for (count = 0; count < 32; count++) + { + if (m_Reg.m_FPCR[count] != SecondCPU->m_Reg.m_FPCR[count]) + { + Error.LogF("FPCR[%s] 0x%08X, 0x%08X\r\n", CRegName::FPR_Ctrl[count], + m_Reg.m_FPCR[count], SecondCPU->m_Reg.m_FPCR[count]); + } + } + for (count = 0; count < 32; count++) + { + if (m_Reg.m_CP0[count] != SecondCPU->m_Reg.m_CP0[count]) + { + Error.LogF("CP0[%s] 0x%08X, 0x%08X\r\n", CRegName::Cop0[count], + m_Reg.m_CP0[count], SecondCPU->m_Reg.m_CP0[count]); + } + } + if (m_Reg.m_HI.DW != SecondCPU->m_Reg.m_HI.DW) + { + Error.LogF("HI Reg 0x%08X%08X, 0x%08X%08X\r\n", m_Reg.m_HI.UW[1], m_Reg.m_HI.UW[0], SecondCPU->m_Reg.m_HI.UW[1], SecondCPU->m_Reg.m_HI.UW[0]); + } + if (m_Reg.m_LO.DW != SecondCPU->m_Reg.m_LO.DW) + { + Error.LogF("LO Reg 0x%08X%08X, 0x%08X%08X\r\n", m_Reg.m_LO.UW[1], m_Reg.m_LO.UW[0], SecondCPU->m_Reg.m_LO.UW[1], SecondCPU->m_Reg.m_LO.UW[0]); + } + for (int i = 0, n = sizeof(m_Reg.m_Mips_Interface) / sizeof(m_Reg.m_Mips_Interface[0]); i < n; i++) + { + if (m_Reg.m_Mips_Interface[i] != SecondCPU->m_Reg.m_Mips_Interface[i]) + { + Error.LogF("Mips_Interface[%d] 0x%08X, 0x%08X\r\n", i, m_Reg.m_Mips_Interface[i], SecondCPU->m_Reg.m_Mips_Interface[i]); + } + } - for (int i = 0, n = sizeof(m_Reg.m_SigProcessor_Interface) / sizeof(m_Reg.m_SigProcessor_Interface[0]); i < n; i++) - { - if (m_Reg.m_SigProcessor_Interface[i] != SecondCPU->m_Reg.m_SigProcessor_Interface[i]) - { - Error.LogF("SigProcessor_Interface[%d] 0x%08X, 0x%08X\r\n", i, m_Reg.m_SigProcessor_Interface[i], SecondCPU->m_Reg.m_SigProcessor_Interface[i]); - } - } - for (int i = 0, n = sizeof(m_Reg.m_Display_ControlReg) / sizeof(m_Reg.m_Display_ControlReg[0]); i < n; i++) - { - if (m_Reg.m_Display_ControlReg[i] != SecondCPU->m_Reg.m_Display_ControlReg[i]) - { - Error.LogF("Display_ControlReg[%d] 0x%08X, 0x%08X\r\n", i, m_Reg.m_Display_ControlReg[i], SecondCPU->m_Reg.m_Display_ControlReg[i]); - } - } + for (int i = 0, n = sizeof(m_Reg.m_SigProcessor_Interface) / sizeof(m_Reg.m_SigProcessor_Interface[0]); i < n; i++) + { + if (m_Reg.m_SigProcessor_Interface[i] != SecondCPU->m_Reg.m_SigProcessor_Interface[i]) + { + Error.LogF("SigProcessor_Interface[%d] 0x%08X, 0x%08X\r\n", i, m_Reg.m_SigProcessor_Interface[i], SecondCPU->m_Reg.m_SigProcessor_Interface[i]); + } + } + for (int i = 0, n = sizeof(m_Reg.m_Display_ControlReg) / sizeof(m_Reg.m_Display_ControlReg[0]); i < n; i++) + { + if (m_Reg.m_Display_ControlReg[i] != SecondCPU->m_Reg.m_Display_ControlReg[i]) + { + Error.LogF("Display_ControlReg[%d] 0x%08X, 0x%08X\r\n", i, m_Reg.m_Display_ControlReg[i], SecondCPU->m_Reg.m_Display_ControlReg[i]); + } + } - if (m_NextTimer != SecondCPU->m_NextTimer) - { - Error.LogF("Current Time: %X %X\r\n", (DWORD)m_NextTimer, (DWORD)SecondCPU->m_NextTimer); - } - m_TLB.RecordDifference(Error, SecondCPU->m_TLB); - m_SystemTimer.RecordDifference(Error, SecondCPU->m_SystemTimer); - if (m_Reg.m_RoundingModel != SecondCPU->m_Reg.m_RoundingModel) - { - Error.LogF("RoundingModel: %X %X\r\n", m_Reg.m_RoundingModel, SecondCPU->m_Reg.m_RoundingModel); - } - if (bFastSP() && m_Recomp) - { - if (m_Recomp->MemoryStackPos() != (DWORD)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF))) - { - Error.LogF("MemoryStack = %X should be: %X\r\n", m_Recomp->MemoryStackPos(), (DWORD)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF))); - } - } + if (m_NextTimer != SecondCPU->m_NextTimer) + { + Error.LogF("Current Time: %X %X\r\n", (DWORD)m_NextTimer, (DWORD)SecondCPU->m_NextTimer); + } + m_TLB.RecordDifference(Error, SecondCPU->m_TLB); + m_SystemTimer.RecordDifference(Error, SecondCPU->m_SystemTimer); + if (m_Reg.m_RoundingModel != SecondCPU->m_Reg.m_RoundingModel) + { + Error.LogF("RoundingModel: %X %X\r\n", m_Reg.m_RoundingModel, SecondCPU->m_Reg.m_RoundingModel); + } + if (bFastSP() && m_Recomp) + { + if (m_Recomp->MemoryStackPos() != (DWORD)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF))) + { + Error.LogF("MemoryStack = %X should be: %X\r\n", m_Recomp->MemoryStackPos(), (DWORD)(m_MMU_VM.Rdram() + (m_Reg.m_GPR[29].W[0] & 0x1FFFFFFF))); + } + } - DWORD * Rdram = (DWORD *)m_MMU_VM.Rdram(), *Rdram2 = (DWORD *)SecondCPU->m_MMU_VM.Rdram(); - for (int z = 0, n = (RdramSize() >> 2); z < n; z++) - { - if (Rdram[z] != Rdram2[z]) - { - Error.LogF("Rdram[%X]: %X %X\r\n", z << 2, Rdram[z], Rdram2[z]); - } - } + DWORD * Rdram = (DWORD *)m_MMU_VM.Rdram(), *Rdram2 = (DWORD *)SecondCPU->m_MMU_VM.Rdram(); + for (int z = 0, n = (RdramSize() >> 2); z < n; z++) + { + if (Rdram[z] != Rdram2[z]) + { + Error.LogF("Rdram[%X]: %X %X\r\n", z << 2, Rdram[z], Rdram2[z]); + } + } - DWORD * Imem = (DWORD *)m_MMU_VM.Imem(), *Imem2 = (DWORD *)SecondCPU->m_MMU_VM.Imem(); - for (int z = 0; z < (0x1000 >> 2); z++) - { - if (Imem[z] != Imem2[z]) - { - Error.LogF("Imem[%X]: %X %X\r\n", z << 2, Imem[z], Imem2[z]); - } - } - DWORD * Dmem = (DWORD *)m_MMU_VM.Dmem(), *Dmem2 = (DWORD *)SecondCPU->m_MMU_VM.Dmem(); - for (int z = 0; z < (0x1000 >> 2); z++) - { - if (Dmem[z] != Dmem2[z]) - { - Error.LogF("Dmem[%X]: %X %X\r\n", z << 2, Dmem[z], Dmem2[z]); - } - } - Error.Log("\r\n"); - Error.Log("Information:\r\n"); - Error.Log("\r\n"); - Error.LogF("PROGRAM_COUNTER,0x%X\r\n", m_Reg.m_PROGRAM_COUNTER); - Error.LogF("Current Timer,0x%X\r\n", m_NextTimer); - Error.LogF("Timer Type,0x%X\r\n", m_SystemTimer.CurrentType()); - Error.Log("\r\n"); - for (int i = 0; i < (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])); i++) - { - Error.LogF("LastSuccessSyncPC[%d],0x%X\r\n", i, m_LastSuccessSyncPC[i]); - } - Error.Log("\r\n"); - for (count = 0; count < 32; count++) - { - Error.LogF("GPR[%s], 0x%08X%08X, 0x%08X%08X\r\n", CRegName::GPR[count], - m_Reg.m_GPR[count].W[1], m_Reg.m_GPR[count].W[0], - SecondCPU->m_Reg.m_GPR[count].W[1], SecondCPU->m_Reg.m_GPR[count].W[0]); - } - Error.Log("\r\n"); - for (count = 0; count < 32; count++) - { - Error.LogF("FPR[%s],%*s0x%08X%08X, 0x%08X%08X\r\n", CRegName::FPR[count], - count < 10 ? 9 : 8, " ", m_Reg.m_FPR[count].W[1], m_Reg.m_FPR[count].W[0], - SecondCPU->m_Reg.m_FPR[count].W[1], SecondCPU->m_Reg.m_FPR[count].W[0]); - } - Error.Log("\r\n"); - for (count = 0; count < 32; count++) - { - Error.LogF("FPR_S[%s],%*s%f, %f\r\n", CRegName::FPR[count], - count < 10 ? 7 : 6, " ", *(m_Reg.m_FPR_S[count]), *(SecondCPU->m_Reg.m_FPR_S[count])); - } - Error.Log("\r\n"); - for (count = 0; count < 32; count++) - { - Error.LogF("FPR_D[%s],%*s%f, %f\r\n", CRegName::FPR[count], - count < 10 ? 7 : 6, " ", *(m_Reg.m_FPR_D[count]), *(SecondCPU->m_Reg.m_FPR_D[count])); - } - Error.Log("\r\n"); - Error.LogF("Rounding Model, 0x%08X, 0x%08X\r\n", m_Reg.m_RoundingModel, SecondCPU->m_Reg.m_RoundingModel); - Error.Log("\r\n"); - for (count = 0; count < 32; count++) - { - Error.LogF("CP0[%s],%*s0x%08X, 0x%08X\r\n", CRegName::Cop0[count], - 12 - strlen(CRegName::Cop0[count]), "", - m_Reg.m_CP0[count], SecondCPU->m_Reg.m_CP0[count]); - } - Error.Log("\r\n"); - Error.LogF("HI 0x%08X%08X, 0x%08X%08X\r\n", m_Reg.m_HI.UW[1], m_Reg.m_HI.UW[0], - SecondCPU->m_Reg.m_HI.UW[1], SecondCPU->m_Reg.m_HI.UW[0]); - Error.LogF("LO 0x%08X%08X, 0x%08X%08X\r\n", m_Reg.m_LO.UW[1], m_Reg.m_LO.UW[0], - SecondCPU->m_Reg.m_LO.UW[1], SecondCPU->m_Reg.m_LO.UW[0]); - bool bHasTlb = false; - for (count = 0; count < 32; count++) - { - if (!m_TLB.TlbEntry(count).EntryDefined) { continue; } - if (!bHasTlb) - { - Error.Log("\r\n"); - Error.Log(" Hi Recomp, PageMask, Hi Interp, PageMask\r\n"); - bHasTlb = true; - } - Error.LogF("TLB[%2d], %08X, %08X, %08X, %08X\r\n", count, - m_TLB.TlbEntry(count).EntryHi.Value, m_TLB.TlbEntry(count).PageMask.Value, - SecondCPU->m_TLB.TlbEntry(count).EntryHi.Value, SecondCPU->m_TLB.TlbEntry(count).PageMask.Value - ); - } - Error.Log("\r\n"); - Error.Log("Code at PC:\r\n"); - for (count = -10; count < 10; count++) - { - DWORD OpcodeValue, Addr = m_Reg.m_PROGRAM_COUNTER + (count << 2); - if (g_MMU->LW_VAddr(Addr, (uint32_t &)OpcodeValue)) - { - Error.LogF("%X: %s\r\n", Addr, R4300iOpcodeName(OpcodeValue, Addr)); - } - } - Error.Log("\r\n"); - Error.Log("Code at Last Sync PC:\r\n"); - for (count = 0; count < 50; count++) - { - DWORD OpcodeValue, Addr = m_LastSuccessSyncPC[0] + (count << 2); - if (g_MMU->LW_VAddr(Addr, (uint32_t &)OpcodeValue)) - { - Error.LogF("%X: %s\r\n", Addr, R4300iOpcodeName(OpcodeValue, Addr)); - } - } - } + DWORD * Imem = (DWORD *)m_MMU_VM.Imem(), *Imem2 = (DWORD *)SecondCPU->m_MMU_VM.Imem(); + for (int z = 0; z < (0x1000 >> 2); z++) + { + if (Imem[z] != Imem2[z]) + { + Error.LogF("Imem[%X]: %X %X\r\n", z << 2, Imem[z], Imem2[z]); + } + } + DWORD * Dmem = (DWORD *)m_MMU_VM.Dmem(), *Dmem2 = (DWORD *)SecondCPU->m_MMU_VM.Dmem(); + for (int z = 0; z < (0x1000 >> 2); z++) + { + if (Dmem[z] != Dmem2[z]) + { + Error.LogF("Dmem[%X]: %X %X\r\n", z << 2, Dmem[z], Dmem2[z]); + } + } + Error.Log("\r\n"); + Error.Log("Information:\r\n"); + Error.Log("\r\n"); + Error.LogF("PROGRAM_COUNTER,0x%X\r\n", m_Reg.m_PROGRAM_COUNTER); + Error.LogF("Current Timer,0x%X\r\n", m_NextTimer); + Error.LogF("Timer Type,0x%X\r\n", m_SystemTimer.CurrentType()); + Error.Log("\r\n"); + for (int i = 0; i < (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])); i++) + { + Error.LogF("LastSuccessSyncPC[%d],0x%X\r\n", i, m_LastSuccessSyncPC[i]); + } + Error.Log("\r\n"); + for (count = 0; count < 32; count++) + { + Error.LogF("GPR[%s], 0x%08X%08X, 0x%08X%08X\r\n", CRegName::GPR[count], + m_Reg.m_GPR[count].W[1], m_Reg.m_GPR[count].W[0], + SecondCPU->m_Reg.m_GPR[count].W[1], SecondCPU->m_Reg.m_GPR[count].W[0]); + } + Error.Log("\r\n"); + for (count = 0; count < 32; count++) + { + Error.LogF("FPR[%s],%*s0x%08X%08X, 0x%08X%08X\r\n", CRegName::FPR[count], + count < 10 ? 9 : 8, " ", m_Reg.m_FPR[count].W[1], m_Reg.m_FPR[count].W[0], + SecondCPU->m_Reg.m_FPR[count].W[1], SecondCPU->m_Reg.m_FPR[count].W[0]); + } + Error.Log("\r\n"); + for (count = 0; count < 32; count++) + { + Error.LogF("FPR_S[%s],%*s%f, %f\r\n", CRegName::FPR[count], + count < 10 ? 7 : 6, " ", *(m_Reg.m_FPR_S[count]), *(SecondCPU->m_Reg.m_FPR_S[count])); + } + Error.Log("\r\n"); + for (count = 0; count < 32; count++) + { + Error.LogF("FPR_D[%s],%*s%f, %f\r\n", CRegName::FPR[count], + count < 10 ? 7 : 6, " ", *(m_Reg.m_FPR_D[count]), *(SecondCPU->m_Reg.m_FPR_D[count])); + } + Error.Log("\r\n"); + Error.LogF("Rounding Model, 0x%08X, 0x%08X\r\n", m_Reg.m_RoundingModel, SecondCPU->m_Reg.m_RoundingModel); + Error.Log("\r\n"); + for (count = 0; count < 32; count++) + { + Error.LogF("CP0[%s],%*s0x%08X, 0x%08X\r\n", CRegName::Cop0[count], + 12 - strlen(CRegName::Cop0[count]), "", + m_Reg.m_CP0[count], SecondCPU->m_Reg.m_CP0[count]); + } + Error.Log("\r\n"); + Error.LogF("HI 0x%08X%08X, 0x%08X%08X\r\n", m_Reg.m_HI.UW[1], m_Reg.m_HI.UW[0], + SecondCPU->m_Reg.m_HI.UW[1], SecondCPU->m_Reg.m_HI.UW[0]); + Error.LogF("LO 0x%08X%08X, 0x%08X%08X\r\n", m_Reg.m_LO.UW[1], m_Reg.m_LO.UW[0], + SecondCPU->m_Reg.m_LO.UW[1], SecondCPU->m_Reg.m_LO.UW[0]); + bool bHasTlb = false; + for (count = 0; count < 32; count++) + { + if (!m_TLB.TlbEntry(count).EntryDefined) { continue; } + if (!bHasTlb) + { + Error.Log("\r\n"); + Error.Log(" Hi Recomp, PageMask, Hi Interp, PageMask\r\n"); + bHasTlb = true; + } + Error.LogF("TLB[%2d], %08X, %08X, %08X, %08X\r\n", count, + m_TLB.TlbEntry(count).EntryHi.Value, m_TLB.TlbEntry(count).PageMask.Value, + SecondCPU->m_TLB.TlbEntry(count).EntryHi.Value, SecondCPU->m_TLB.TlbEntry(count).PageMask.Value + ); + } + Error.Log("\r\n"); + Error.Log("Code at PC:\r\n"); + for (count = -10; count < 10; count++) + { + DWORD OpcodeValue, Addr = m_Reg.m_PROGRAM_COUNTER + (count << 2); + if (g_MMU->LW_VAddr(Addr, (uint32_t &)OpcodeValue)) + { + Error.LogF("%X: %s\r\n", Addr, R4300iOpcodeName(OpcodeValue, Addr)); + } + } + Error.Log("\r\n"); + Error.Log("Code at Last Sync PC:\r\n"); + for (count = 0; count < 50; count++) + { + DWORD OpcodeValue, Addr = m_LastSuccessSyncPC[0] + (count << 2); + if (g_MMU->LW_VAddr(Addr, (uint32_t &)OpcodeValue)) + { + Error.LogF("%X: %s\r\n", Addr, R4300iOpcodeName(OpcodeValue, Addr)); + } + } + } - g_Notify->DisplayError(L"Sync Error"); - g_Notify->BreakPoint(__FILEW__, __LINE__); + g_Notify->DisplayError(L"Sync Error"); + g_Notify->BreakPoint(__FILEW__, __LINE__); } bool CN64System::SaveState() { - WriteTrace(TraceDebug, __FUNCTION__ ": Start"); + WriteTrace(TraceDebug, __FUNCTION__ ": Start"); - // if (!m_SystemTimer.SaveAllowed()) { return false; } - if ((m_Reg.STATUS_REGISTER & STATUS_EXL) != 0) { return false; } + // if (!m_SystemTimer.SaveAllowed()) { return false; } + if ((m_Reg.STATUS_REGISTER & STATUS_EXL) != 0) { return false; } - //Get the file Name - stdstr FileName, ExtraInfoFileName, CurrentSaveName = g_Settings->LoadStringVal(GameRunning_InstantSaveFile); - if (CurrentSaveName.empty()) - { - int Slot = g_Settings->LoadDword(Game_CurrentSaveState); - if (Slot != 0) - { - CurrentSaveName.Format("%s.pj%d", g_Settings->LoadStringVal(Game_GoodName).c_str(), Slot); - } - else - { - CurrentSaveName.Format("%s.pj", g_Settings->LoadStringVal(Game_GoodName).c_str()); - } - FileName.Format("%s%s", g_Settings->LoadStringVal(Directory_InstantSave).c_str(), CurrentSaveName.c_str()); - stdstr_f ZipFileName("%s.zip", FileName.c_str()); - //Make sure the target dir exists - CreateDirectory(g_Settings->LoadStringVal(Directory_InstantSave).c_str(), NULL); - //delete any old save - DeleteFile(FileName.c_str()); - DeleteFile(ZipFileName.c_str()); - ExtraInfoFileName.Format("%s.dat", CurrentSaveName.c_str()); + //Get the file Name + stdstr FileName, ExtraInfoFileName, CurrentSaveName = g_Settings->LoadStringVal(GameRunning_InstantSaveFile); + if (CurrentSaveName.empty()) + { + int Slot = g_Settings->LoadDword(Game_CurrentSaveState); + if (Slot != 0) + { + CurrentSaveName.Format("%s.pj%d", g_Settings->LoadStringVal(Game_GoodName).c_str(), Slot); + } + else + { + CurrentSaveName.Format("%s.pj", g_Settings->LoadStringVal(Game_GoodName).c_str()); + } + FileName.Format("%s%s", g_Settings->LoadStringVal(Directory_InstantSave).c_str(), CurrentSaveName.c_str()); + stdstr_f ZipFileName("%s.zip", FileName.c_str()); + //Make sure the target dir exists + CreateDirectory(g_Settings->LoadStringVal(Directory_InstantSave).c_str(), NULL); + //delete any old save + DeleteFile(FileName.c_str()); + DeleteFile(ZipFileName.c_str()); + ExtraInfoFileName.Format("%s.dat", CurrentSaveName.c_str()); - //If ziping save add .zip on the end - if (g_Settings->LoadDword(Setting_AutoZipInstantSave)) - { - FileName = ZipFileName; - } - g_Settings->SaveDword(Game_LastSaveSlot, g_Settings->LoadDword(Game_CurrentSaveState)); - } - else - { - char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; - _splitpath(CurrentSaveName.c_str(), drive, dir, fname, ext); + //If ziping save add .zip on the end + if (g_Settings->LoadDword(Setting_AutoZipInstantSave)) + { + FileName = ZipFileName; + } + g_Settings->SaveDword(Game_LastSaveSlot, g_Settings->LoadDword(Game_CurrentSaveState)); + } + else + { + char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; + _splitpath(CurrentSaveName.c_str(), drive, dir, fname, ext); - FileName.Format("%s.pj", CurrentSaveName.c_str()); + FileName.Format("%s.pj", CurrentSaveName.c_str()); - CurrentSaveName.Format("%s.pj", fname); - ExtraInfoFileName.Format("%s.dat", fname); + CurrentSaveName.Format("%s.pj", fname); + ExtraInfoFileName.Format("%s.dat", fname); - //If ziping save add .zip on the end - if (g_Settings->LoadDword(Setting_AutoZipInstantSave)) - { - FileName.Format("%s.zip", FileName.c_str()); - } - } - if (FileName.empty()) { return true; } + //If ziping save add .zip on the end + if (g_Settings->LoadDword(Setting_AutoZipInstantSave)) + { + FileName.Format("%s.zip", FileName.c_str()); + } + } + if (FileName.empty()) { return true; } - //Open the file - if (g_Settings->LoadDword(Game_FuncLookupMode) == FuncFind_ChangeMemory) - { - if (m_Recomp) - { - m_Recomp->ResetRecompCode(true); - } - } + //Open the file + if (g_Settings->LoadDword(Game_FuncLookupMode) == FuncFind_ChangeMemory) + { + if (m_Recomp) + { + m_Recomp->ResetRecompCode(true); + } + } - DWORD dwWritten, SaveID_0 = 0x23D8A6C8, SaveID_1 = 0x56D2CD23; - DWORD RdramSize = g_Settings->LoadDword(Game_RDRamSize); - DWORD MiInterReg = g_Reg->MI_INTR_REG; - DWORD NextViTimer = m_SystemTimer.GetTimer(CSystemTimer::ViTimer); - if (g_Settings->LoadDword(Setting_AutoZipInstantSave)) - { - zipFile file; + DWORD dwWritten, SaveID_0 = 0x23D8A6C8, SaveID_1 = 0x56D2CD23; + DWORD RdramSize = g_Settings->LoadDword(Game_RDRamSize); + DWORD MiInterReg = g_Reg->MI_INTR_REG; + DWORD NextViTimer = m_SystemTimer.GetTimer(CSystemTimer::ViTimer); + if (g_Settings->LoadDword(Setting_AutoZipInstantSave)) + { + zipFile file; - file = zipOpen(FileName.c_str(), 0); - zipOpenNewFileInZip(file, CurrentSaveName.c_str(), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION); - zipWriteInFileInZip(file, &SaveID_0, sizeof(SaveID_0)); - zipWriteInFileInZip(file, &RdramSize, sizeof(DWORD)); - zipWriteInFileInZip(file, g_Rom->GetRomAddress(), 0x40); - zipWriteInFileInZip(file, &NextViTimer, sizeof(DWORD)); - zipWriteInFileInZip(file, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER)); - zipWriteInFileInZip(file, m_Reg.m_GPR, sizeof(__int64) * 32); - zipWriteInFileInZip(file, m_Reg.m_FPR, sizeof(__int64) * 32); - zipWriteInFileInZip(file, m_Reg.m_CP0, sizeof(DWORD) * 32); - zipWriteInFileInZip(file, m_Reg.m_FPCR, sizeof(DWORD) * 32); - zipWriteInFileInZip(file, &m_Reg.m_HI, sizeof(__int64)); - zipWriteInFileInZip(file, &m_Reg.m_LO, sizeof(__int64)); - zipWriteInFileInZip(file, m_Reg.m_RDRAM_Registers, sizeof(DWORD) * 10); - zipWriteInFileInZip(file, m_Reg.m_SigProcessor_Interface, sizeof(DWORD) * 10); - zipWriteInFileInZip(file, m_Reg.m_Display_ControlReg, sizeof(DWORD) * 10); - zipWriteInFileInZip(file, m_Reg.m_Mips_Interface, sizeof(DWORD) * 4); - zipWriteInFileInZip(file, m_Reg.m_Video_Interface, sizeof(DWORD) * 14); - zipWriteInFileInZip(file, m_Reg.m_Audio_Interface, sizeof(DWORD) * 6); - zipWriteInFileInZip(file, m_Reg.m_Peripheral_Interface, sizeof(DWORD) * 13); - zipWriteInFileInZip(file, m_Reg.m_RDRAM_Interface, sizeof(DWORD) * 8); - zipWriteInFileInZip(file, m_Reg.m_SerialInterface, sizeof(DWORD) * 4); - zipWriteInFileInZip(file, (void *const)&m_TLB.TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32); - zipWriteInFileInZip(file, m_MMU_VM.PifRam(), 0x40); - zipWriteInFileInZip(file, m_MMU_VM.Rdram(), RdramSize); - zipWriteInFileInZip(file, m_MMU_VM.Dmem(), 0x1000); - zipWriteInFileInZip(file, m_MMU_VM.Imem(), 0x1000); - zipCloseFileInZip(file); + file = zipOpen(FileName.c_str(), 0); + zipOpenNewFileInZip(file, CurrentSaveName.c_str(), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION); + zipWriteInFileInZip(file, &SaveID_0, sizeof(SaveID_0)); + zipWriteInFileInZip(file, &RdramSize, sizeof(DWORD)); + zipWriteInFileInZip(file, g_Rom->GetRomAddress(), 0x40); + zipWriteInFileInZip(file, &NextViTimer, sizeof(DWORD)); + zipWriteInFileInZip(file, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER)); + zipWriteInFileInZip(file, m_Reg.m_GPR, sizeof(__int64) * 32); + zipWriteInFileInZip(file, m_Reg.m_FPR, sizeof(__int64) * 32); + zipWriteInFileInZip(file, m_Reg.m_CP0, sizeof(DWORD) * 32); + zipWriteInFileInZip(file, m_Reg.m_FPCR, sizeof(DWORD) * 32); + zipWriteInFileInZip(file, &m_Reg.m_HI, sizeof(__int64)); + zipWriteInFileInZip(file, &m_Reg.m_LO, sizeof(__int64)); + zipWriteInFileInZip(file, m_Reg.m_RDRAM_Registers, sizeof(DWORD) * 10); + zipWriteInFileInZip(file, m_Reg.m_SigProcessor_Interface, sizeof(DWORD) * 10); + zipWriteInFileInZip(file, m_Reg.m_Display_ControlReg, sizeof(DWORD) * 10); + zipWriteInFileInZip(file, m_Reg.m_Mips_Interface, sizeof(DWORD) * 4); + zipWriteInFileInZip(file, m_Reg.m_Video_Interface, sizeof(DWORD) * 14); + zipWriteInFileInZip(file, m_Reg.m_Audio_Interface, sizeof(DWORD) * 6); + zipWriteInFileInZip(file, m_Reg.m_Peripheral_Interface, sizeof(DWORD) * 13); + zipWriteInFileInZip(file, m_Reg.m_RDRAM_Interface, sizeof(DWORD) * 8); + zipWriteInFileInZip(file, m_Reg.m_SerialInterface, sizeof(DWORD) * 4); + zipWriteInFileInZip(file, (void *const)&m_TLB.TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32); + zipWriteInFileInZip(file, m_MMU_VM.PifRam(), 0x40); + zipWriteInFileInZip(file, m_MMU_VM.Rdram(), RdramSize); + zipWriteInFileInZip(file, m_MMU_VM.Dmem(), 0x1000); + zipWriteInFileInZip(file, m_MMU_VM.Imem(), 0x1000); + zipCloseFileInZip(file); - zipOpenNewFileInZip(file, ExtraInfoFileName.c_str(), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION); - zipWriteInFileInZip(file, &SaveID_1, sizeof(SaveID_1)); - m_SystemTimer.SaveData(file); - zipCloseFileInZip(file); + zipOpenNewFileInZip(file, ExtraInfoFileName.c_str(), NULL, NULL, 0, NULL, 0, NULL, Z_DEFLATED, Z_DEFAULT_COMPRESSION); + zipWriteInFileInZip(file, &SaveID_1, sizeof(SaveID_1)); + m_SystemTimer.SaveData(file); + zipCloseFileInZip(file); - zipClose(file, ""); - } - else - { - HANDLE hSaveFile = CreateFile(FileName.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, - NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); - if (hSaveFile == INVALID_HANDLE_VALUE) - { - g_Notify->DisplayError(GS(MSG_FAIL_OPEN_SAVE)); - m_Reg.MI_INTR_REG = MiInterReg; - return true; - } + zipClose(file, ""); + } + else + { + HANDLE hSaveFile = CreateFile(FileName.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, + NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); + if (hSaveFile == INVALID_HANDLE_VALUE) + { + g_Notify->DisplayError(GS(MSG_FAIL_OPEN_SAVE)); + m_Reg.MI_INTR_REG = MiInterReg; + return true; + } - //Write info to file - SetFilePointer(hSaveFile, 0, NULL, FILE_BEGIN); - WriteFile(hSaveFile, &SaveID_0, sizeof(DWORD), &dwWritten, NULL); - WriteFile(hSaveFile, &RdramSize, sizeof(DWORD), &dwWritten, NULL); - WriteFile(hSaveFile, g_Rom->GetRomAddress(), 0x40, &dwWritten, NULL); - WriteFile(hSaveFile, &NextViTimer, sizeof(DWORD), &dwWritten, NULL); - WriteFile(hSaveFile, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER), &dwWritten, NULL); - WriteFile(hSaveFile, m_Reg.m_GPR, sizeof(__int64) * 32, &dwWritten, NULL); - WriteFile(hSaveFile, m_Reg.m_FPR, sizeof(__int64) * 32, &dwWritten, NULL); - WriteFile(hSaveFile, m_Reg.m_CP0, sizeof(DWORD) * 32, &dwWritten, NULL); - WriteFile(hSaveFile, m_Reg.m_FPCR, sizeof(DWORD) * 32, &dwWritten, NULL); - WriteFile(hSaveFile, &m_Reg.m_HI, sizeof(__int64), &dwWritten, NULL); - WriteFile(hSaveFile, &m_Reg.m_LO, sizeof(__int64), &dwWritten, NULL); - WriteFile(hSaveFile, m_Reg.m_RDRAM_Registers, sizeof(DWORD) * 10, &dwWritten, NULL); - WriteFile(hSaveFile, m_Reg.m_SigProcessor_Interface, sizeof(DWORD) * 10, &dwWritten, NULL); - WriteFile(hSaveFile, m_Reg.m_Display_ControlReg, sizeof(DWORD) * 10, &dwWritten, NULL); - WriteFile(hSaveFile, m_Reg.m_Mips_Interface, sizeof(DWORD) * 4, &dwWritten, NULL); - WriteFile(hSaveFile, m_Reg.m_Video_Interface, sizeof(DWORD) * 14, &dwWritten, NULL); - WriteFile(hSaveFile, m_Reg.m_Audio_Interface, sizeof(DWORD) * 6, &dwWritten, NULL); - WriteFile(hSaveFile, m_Reg.m_Peripheral_Interface, sizeof(DWORD) * 13, &dwWritten, NULL); - WriteFile(hSaveFile, m_Reg.m_RDRAM_Interface, sizeof(DWORD) * 8, &dwWritten, NULL); - WriteFile(hSaveFile, m_Reg.m_SerialInterface, sizeof(DWORD) * 4, &dwWritten, NULL); - WriteFile(hSaveFile, &g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32, &dwWritten, NULL); - WriteFile(hSaveFile, g_MMU->PifRam(), 0x40, &dwWritten, NULL); - WriteFile(hSaveFile, g_MMU->Rdram(), RdramSize, &dwWritten, NULL); - WriteFile(hSaveFile, g_MMU->Dmem(), 0x1000, &dwWritten, NULL); - WriteFile(hSaveFile, g_MMU->Imem(), 0x1000, &dwWritten, NULL); + //Write info to file + SetFilePointer(hSaveFile, 0, NULL, FILE_BEGIN); + WriteFile(hSaveFile, &SaveID_0, sizeof(DWORD), &dwWritten, NULL); + WriteFile(hSaveFile, &RdramSize, sizeof(DWORD), &dwWritten, NULL); + WriteFile(hSaveFile, g_Rom->GetRomAddress(), 0x40, &dwWritten, NULL); + WriteFile(hSaveFile, &NextViTimer, sizeof(DWORD), &dwWritten, NULL); + WriteFile(hSaveFile, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER), &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_GPR, sizeof(__int64) * 32, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_FPR, sizeof(__int64) * 32, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_CP0, sizeof(DWORD) * 32, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_FPCR, sizeof(DWORD) * 32, &dwWritten, NULL); + WriteFile(hSaveFile, &m_Reg.m_HI, sizeof(__int64), &dwWritten, NULL); + WriteFile(hSaveFile, &m_Reg.m_LO, sizeof(__int64), &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_RDRAM_Registers, sizeof(DWORD) * 10, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_SigProcessor_Interface, sizeof(DWORD) * 10, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_Display_ControlReg, sizeof(DWORD) * 10, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_Mips_Interface, sizeof(DWORD) * 4, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_Video_Interface, sizeof(DWORD) * 14, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_Audio_Interface, sizeof(DWORD) * 6, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_Peripheral_Interface, sizeof(DWORD) * 13, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_RDRAM_Interface, sizeof(DWORD) * 8, &dwWritten, NULL); + WriteFile(hSaveFile, m_Reg.m_SerialInterface, sizeof(DWORD) * 4, &dwWritten, NULL); + WriteFile(hSaveFile, &g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32, &dwWritten, NULL); + WriteFile(hSaveFile, g_MMU->PifRam(), 0x40, &dwWritten, NULL); + WriteFile(hSaveFile, g_MMU->Rdram(), RdramSize, &dwWritten, NULL); + WriteFile(hSaveFile, g_MMU->Dmem(), 0x1000, &dwWritten, NULL); + WriteFile(hSaveFile, g_MMU->Imem(), 0x1000, &dwWritten, NULL); - CloseHandle(hSaveFile); - } - m_Reg.MI_INTR_REG = MiInterReg; - g_Settings->SaveString(GameRunning_InstantSaveFile, ""); - std::wstring SaveMessage = g_Lang->GetString(MSG_SAVED_STATE); + CloseHandle(hSaveFile); + } + m_Reg.MI_INTR_REG = MiInterReg; + g_Settings->SaveString(GameRunning_InstantSaveFile, ""); + std::wstring SaveMessage = g_Lang->GetString(MSG_SAVED_STATE); - CPath SavedFileName(FileName); + CPath SavedFileName(FileName); - g_Notify->DisplayMessage(5, stdstr_f("%s %s", SaveMessage.c_str(), SavedFileName.GetNameExtension()).ToUTF16().c_str()); - Notify().RefreshMenu(); - WriteTrace(TraceDebug, __FUNCTION__ ": Done"); - return true; + g_Notify->DisplayMessage(5, stdstr_f("%s %s", SaveMessage.c_str(), SavedFileName.GetNameExtension()).ToUTF16().c_str()); + Notify().RefreshMenu(); + WriteTrace(TraceDebug, __FUNCTION__ ": Done"); + return true; } bool CN64System::LoadState() { - stdstr InstantFileName = g_Settings->LoadStringVal(GameRunning_InstantSaveFile); - if (!InstantFileName.empty()) - { - bool Result = LoadState(InstantFileName.c_str()); - g_Settings->SaveString(GameRunning_InstantSaveFile, ""); - return Result; - } + stdstr InstantFileName = g_Settings->LoadStringVal(GameRunning_InstantSaveFile); + if (!InstantFileName.empty()) + { + bool Result = LoadState(InstantFileName.c_str()); + g_Settings->SaveString(GameRunning_InstantSaveFile, ""); + return Result; + } - CPath FileName; - FileName.SetDriveDirectory(g_Settings->LoadStringVal(Directory_InstantSave).c_str()); - if (g_Settings->LoadDword(Game_CurrentSaveState) != 0) - { - FileName.SetNameExtension(stdstr_f("%s.pj%d", g_Settings->LoadStringVal(Game_GoodName).c_str(), g_Settings->LoadDword(Game_CurrentSaveState)).c_str()); - } - else - { - FileName.SetNameExtension(stdstr_f("%s.pj", g_Settings->LoadStringVal(Game_GoodName).c_str()).c_str()); - } + CPath FileName; + FileName.SetDriveDirectory(g_Settings->LoadStringVal(Directory_InstantSave).c_str()); + if (g_Settings->LoadDword(Game_CurrentSaveState) != 0) + { + FileName.SetNameExtension(stdstr_f("%s.pj%d", g_Settings->LoadStringVal(Game_GoodName).c_str(), g_Settings->LoadDword(Game_CurrentSaveState)).c_str()); + } + else + { + FileName.SetNameExtension(stdstr_f("%s.pj", g_Settings->LoadStringVal(Game_GoodName).c_str()).c_str()); + } - CPath ZipFileName; - ZipFileName = (stdstr&)FileName + ".zip"; + CPath ZipFileName; + ZipFileName = (stdstr&)FileName + ".zip"; - if ((g_Settings->LoadDword(Setting_AutoZipInstantSave) && ZipFileName.Exists()) || FileName.Exists()) - { - if (LoadState(FileName)) - { - return true; - } - } + if ((g_Settings->LoadDword(Setting_AutoZipInstantSave) && ZipFileName.Exists()) || FileName.Exists()) + { + if (LoadState(FileName)) + { + return true; + } + } - //Use old file Name - if (g_Settings->LoadDword(Game_CurrentSaveState) != 0) - { - FileName.SetNameExtension(stdstr_f("%s.pj%d", g_Settings->LoadStringVal(Game_GameName).c_str(), g_Settings->LoadDword(Game_CurrentSaveState)).c_str()); - } - else - { - FileName.SetNameExtension(stdstr_f("%s.pj", g_Settings->LoadStringVal(Game_GameName).c_str()).c_str()); - } - return LoadState(FileName); + //Use old file Name + if (g_Settings->LoadDword(Game_CurrentSaveState) != 0) + { + FileName.SetNameExtension(stdstr_f("%s.pj%d", g_Settings->LoadStringVal(Game_GameName).c_str(), g_Settings->LoadDword(Game_CurrentSaveState)).c_str()); + } + else + { + FileName.SetNameExtension(stdstr_f("%s.pj", g_Settings->LoadStringVal(Game_GameName).c_str()).c_str()); + } + return LoadState(FileName); } bool CN64System::LoadState(LPCSTR FileName) { - DWORD dwRead, Value, SaveRDRAMSize, NextVITimer = 0, old_status, old_width, old_dacrate; - bool LoadedZipFile = false, AudioResetOnLoad; - old_status = g_Reg->VI_STATUS_REG; - old_width = g_Reg->VI_WIDTH_REG; - old_dacrate = g_Reg->AI_DACRATE_REG; + DWORD dwRead, Value, SaveRDRAMSize, NextVITimer = 0, old_status, old_width, old_dacrate; + bool LoadedZipFile = false, AudioResetOnLoad; + old_status = g_Reg->VI_STATUS_REG; + old_width = g_Reg->VI_WIDTH_REG; + old_dacrate = g_Reg->AI_DACRATE_REG; - WriteTraceF((TraceType)(TraceDebug | TraceRecompiler), __FUNCTION__ "(%s): Start", FileName); + WriteTraceF((TraceType)(TraceDebug | TraceRecompiler), __FUNCTION__ "(%s): Start", FileName); - char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; - _splitpath(FileName, drive, dir, fname, ext); + char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; + _splitpath(FileName, drive, dir, fname, ext); - stdstr FileNameStr(FileName); - if (g_Settings->LoadDword(Setting_AutoZipInstantSave) || _stricmp(ext, ".zip") == 0) - { - //If ziping save add .zip on the end - if (_stricmp(ext, ".zip") != 0) - { - FileNameStr += ".zip"; - } - unzFile file = unzOpen(FileNameStr.c_str()); - int port = -1; - if (file != NULL) - { - port = unzGoToFirstFile(file); - } - DWORD Value; - while (port == UNZ_OK) - { - unz_file_info info; - char zname[132]; + stdstr FileNameStr(FileName); + if (g_Settings->LoadDword(Setting_AutoZipInstantSave) || _stricmp(ext, ".zip") == 0) + { + //If ziping save add .zip on the end + if (_stricmp(ext, ".zip") != 0) + { + FileNameStr += ".zip"; + } + unzFile file = unzOpen(FileNameStr.c_str()); + int port = -1; + if (file != NULL) + { + port = unzGoToFirstFile(file); + } + DWORD Value; + while (port == UNZ_OK) + { + unz_file_info info; + char zname[132]; - unzGetCurrentFileInfo(file, &info, zname, 128, NULL, 0, NULL, 0); - if (unzLocateFile(file, zname, 1) != UNZ_OK) - { - unzClose(file); - port = -1; - continue; - } - if (unzOpenCurrentFile(file) != UNZ_OK) - { - unzClose(file); - port = -1; - continue; - } - unzReadCurrentFile(file, &Value, 4); - if (Value != 0x23D8A6C8 && Value != 0x56D2CD23) - { - unzCloseCurrentFile(file); - port = unzGoToNextFile(file); - continue; - } - if (!LoadedZipFile && Value == 0x23D8A6C8 && port == UNZ_OK) - { - unzReadCurrentFile(file, &SaveRDRAMSize, sizeof(SaveRDRAMSize)); - //Check header + unzGetCurrentFileInfo(file, &info, zname, 128, NULL, 0, NULL, 0); + if (unzLocateFile(file, zname, 1) != UNZ_OK) + { + unzClose(file); + port = -1; + continue; + } + if (unzOpenCurrentFile(file) != UNZ_OK) + { + unzClose(file); + port = -1; + continue; + } + unzReadCurrentFile(file, &Value, 4); + if (Value != 0x23D8A6C8 && Value != 0x56D2CD23) + { + unzCloseCurrentFile(file); + port = unzGoToNextFile(file); + continue; + } + if (!LoadedZipFile && Value == 0x23D8A6C8 && port == UNZ_OK) + { + unzReadCurrentFile(file, &SaveRDRAMSize, sizeof(SaveRDRAMSize)); + //Check header - BYTE LoadHeader[64]; - unzReadCurrentFile(file, LoadHeader, 0x40); - if (memcmp(LoadHeader, g_Rom->GetRomAddress(), 0x40) != 0) - { - //if (inFullScreen) { return false; } - int result = MessageBoxW(NULL, GS(MSG_SAVE_STATE_HEADER), GS(MSG_MSGBOX_TITLE), - MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2); + BYTE LoadHeader[64]; + unzReadCurrentFile(file, LoadHeader, 0x40); + if (memcmp(LoadHeader, g_Rom->GetRomAddress(), 0x40) != 0) + { + //if (inFullScreen) { return false; } + int result = MessageBoxW(NULL, GS(MSG_SAVE_STATE_HEADER), GS(MSG_MSGBOX_TITLE), + MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2); - if (result == IDNO) - return false; - } - Reset(false, true); + if (result == IDNO) + return false; + } + Reset(false, true); - g_MMU->UnProtectMemory(0x80000000, 0x80000000 + g_Settings->LoadDword(Game_RDRamSize) - 4); - g_MMU->UnProtectMemory(0xA4000000, 0xA4001FFC); - g_Settings->SaveDword(Game_RDRamSize, SaveRDRAMSize); - unzReadCurrentFile(file, &NextVITimer, sizeof(NextVITimer)); - unzReadCurrentFile(file, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER)); - unzReadCurrentFile(file, m_Reg.m_GPR, sizeof(__int64) * 32); - unzReadCurrentFile(file, m_Reg.m_FPR, sizeof(__int64) * 32); - unzReadCurrentFile(file, m_Reg.m_CP0, sizeof(DWORD) * 32); - unzReadCurrentFile(file, m_Reg.m_FPCR, sizeof(DWORD) * 32); - unzReadCurrentFile(file, &m_Reg.m_HI, sizeof(__int64)); - unzReadCurrentFile(file, &m_Reg.m_LO, sizeof(__int64)); - unzReadCurrentFile(file, m_Reg.m_RDRAM_Registers, sizeof(DWORD) * 10); - unzReadCurrentFile(file, m_Reg.m_SigProcessor_Interface, sizeof(DWORD) * 10); - unzReadCurrentFile(file, m_Reg.m_Display_ControlReg, sizeof(DWORD) * 10); - unzReadCurrentFile(file, m_Reg.m_Mips_Interface, sizeof(DWORD) * 4); - unzReadCurrentFile(file, m_Reg.m_Video_Interface, sizeof(DWORD) * 14); - unzReadCurrentFile(file, m_Reg.m_Audio_Interface, sizeof(DWORD) * 6); - unzReadCurrentFile(file, m_Reg.m_Peripheral_Interface, sizeof(DWORD) * 13); - unzReadCurrentFile(file, m_Reg.m_RDRAM_Interface, sizeof(DWORD) * 8); - unzReadCurrentFile(file, m_Reg.m_SerialInterface, sizeof(DWORD) * 4); - unzReadCurrentFile(file, (void *const)&g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32); - unzReadCurrentFile(file, m_MMU_VM.PifRam(), 0x40); - unzReadCurrentFile(file, m_MMU_VM.Rdram(), SaveRDRAMSize); - unzReadCurrentFile(file, m_MMU_VM.Dmem(), 0x1000); - unzReadCurrentFile(file, m_MMU_VM.Imem(), 0x1000); - unzCloseCurrentFile(file); - port = unzGoToFirstFile(file); - LoadedZipFile = true; - continue; - } - if (LoadedZipFile && Value == 0x56D2CD23 && port == UNZ_OK) - { - m_SystemTimer.LoadData(file); - } - unzCloseCurrentFile(file); - port = unzGoToNextFile(file); - } - unzClose(file); - } - if (!LoadedZipFile) - { - HANDLE hSaveFile = CreateFile(FileNameStr.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); - if (hSaveFile == INVALID_HANDLE_VALUE) - { - g_Notify->DisplayMessage(5, stdstr_f("%s %s", GS(MSG_UNABLED_LOAD_STATE), FileNameStr).ToUTF16().c_str()); - return false; - } + g_MMU->UnProtectMemory(0x80000000, 0x80000000 + g_Settings->LoadDword(Game_RDRamSize) - 4); + g_MMU->UnProtectMemory(0xA4000000, 0xA4001FFC); + g_Settings->SaveDword(Game_RDRamSize, SaveRDRAMSize); + unzReadCurrentFile(file, &NextVITimer, sizeof(NextVITimer)); + unzReadCurrentFile(file, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER)); + unzReadCurrentFile(file, m_Reg.m_GPR, sizeof(__int64) * 32); + unzReadCurrentFile(file, m_Reg.m_FPR, sizeof(__int64) * 32); + unzReadCurrentFile(file, m_Reg.m_CP0, sizeof(DWORD) * 32); + unzReadCurrentFile(file, m_Reg.m_FPCR, sizeof(DWORD) * 32); + unzReadCurrentFile(file, &m_Reg.m_HI, sizeof(__int64)); + unzReadCurrentFile(file, &m_Reg.m_LO, sizeof(__int64)); + unzReadCurrentFile(file, m_Reg.m_RDRAM_Registers, sizeof(DWORD) * 10); + unzReadCurrentFile(file, m_Reg.m_SigProcessor_Interface, sizeof(DWORD) * 10); + unzReadCurrentFile(file, m_Reg.m_Display_ControlReg, sizeof(DWORD) * 10); + unzReadCurrentFile(file, m_Reg.m_Mips_Interface, sizeof(DWORD) * 4); + unzReadCurrentFile(file, m_Reg.m_Video_Interface, sizeof(DWORD) * 14); + unzReadCurrentFile(file, m_Reg.m_Audio_Interface, sizeof(DWORD) * 6); + unzReadCurrentFile(file, m_Reg.m_Peripheral_Interface, sizeof(DWORD) * 13); + unzReadCurrentFile(file, m_Reg.m_RDRAM_Interface, sizeof(DWORD) * 8); + unzReadCurrentFile(file, m_Reg.m_SerialInterface, sizeof(DWORD) * 4); + unzReadCurrentFile(file, (void *const)&g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32); + unzReadCurrentFile(file, m_MMU_VM.PifRam(), 0x40); + unzReadCurrentFile(file, m_MMU_VM.Rdram(), SaveRDRAMSize); + unzReadCurrentFile(file, m_MMU_VM.Dmem(), 0x1000); + unzReadCurrentFile(file, m_MMU_VM.Imem(), 0x1000); + unzCloseCurrentFile(file); + port = unzGoToFirstFile(file); + LoadedZipFile = true; + continue; + } + if (LoadedZipFile && Value == 0x56D2CD23 && port == UNZ_OK) + { + m_SystemTimer.LoadData(file); + } + unzCloseCurrentFile(file); + port = unzGoToNextFile(file); + } + unzClose(file); + } + if (!LoadedZipFile) + { + HANDLE hSaveFile = CreateFile(FileNameStr.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); + if (hSaveFile == INVALID_HANDLE_VALUE) + { + g_Notify->DisplayMessage(5, stdstr_f("%s %s", GS(MSG_UNABLED_LOAD_STATE), FileNameStr).ToUTF16().c_str()); + return false; + } - SetFilePointer(hSaveFile, 0, NULL, FILE_BEGIN); - ReadFile(hSaveFile, &Value, sizeof(Value), &dwRead, NULL); - if (Value != 0x23D8A6C8) - return false; + SetFilePointer(hSaveFile, 0, NULL, FILE_BEGIN); + ReadFile(hSaveFile, &Value, sizeof(Value), &dwRead, NULL); + if (Value != 0x23D8A6C8) + return false; - ReadFile(hSaveFile, &SaveRDRAMSize, sizeof(SaveRDRAMSize), &dwRead, NULL); - //Check header - BYTE LoadHeader[64]; - ReadFile(hSaveFile, LoadHeader, 0x40, &dwRead, NULL); - if (memcmp(LoadHeader, g_Rom->GetRomAddress(), 0x40) != 0) - { - //if (inFullScreen) { return false; } - int result = MessageBoxW(NULL, GS(MSG_SAVE_STATE_HEADER), GS(MSG_MSGBOX_TITLE), - MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2); + ReadFile(hSaveFile, &SaveRDRAMSize, sizeof(SaveRDRAMSize), &dwRead, NULL); + //Check header + BYTE LoadHeader[64]; + ReadFile(hSaveFile, LoadHeader, 0x40, &dwRead, NULL); + if (memcmp(LoadHeader, g_Rom->GetRomAddress(), 0x40) != 0) + { + //if (inFullScreen) { return false; } + int result = MessageBoxW(NULL, GS(MSG_SAVE_STATE_HEADER), GS(MSG_MSGBOX_TITLE), + MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2); - if (result == IDNO) - return false; - } - Reset(false, true); - m_MMU_VM.UnProtectMemory(0x80000000, 0x80000000 + g_Settings->LoadDword(Game_RDRamSize) - 4); - m_MMU_VM.UnProtectMemory(0xA4000000, 0xA4001FFC); - g_Settings->SaveDword(Game_RDRamSize, SaveRDRAMSize); + if (result == IDNO) + return false; + } + Reset(false, true); + m_MMU_VM.UnProtectMemory(0x80000000, 0x80000000 + g_Settings->LoadDword(Game_RDRamSize) - 4); + m_MMU_VM.UnProtectMemory(0xA4000000, 0xA4001FFC); + g_Settings->SaveDword(Game_RDRamSize, SaveRDRAMSize); - ReadFile(hSaveFile, &NextVITimer, sizeof(NextVITimer), &dwRead, NULL); - ReadFile(hSaveFile, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER), &dwRead, NULL); - ReadFile(hSaveFile, m_Reg.m_GPR, sizeof(__int64) * 32, &dwRead, NULL); - ReadFile(hSaveFile, m_Reg.m_FPR, sizeof(__int64) * 32, &dwRead, NULL); - ReadFile(hSaveFile, m_Reg.m_CP0, sizeof(DWORD) * 32, &dwRead, NULL); - ReadFile(hSaveFile, m_Reg.m_FPCR, sizeof(DWORD) * 32, &dwRead, NULL); - ReadFile(hSaveFile, &m_Reg.m_HI, sizeof(__int64), &dwRead, NULL); - ReadFile(hSaveFile, &m_Reg.m_LO, sizeof(__int64), &dwRead, NULL); - ReadFile(hSaveFile, m_Reg.m_RDRAM_Registers, sizeof(DWORD) * 10, &dwRead, NULL); - ReadFile(hSaveFile, m_Reg.m_SigProcessor_Interface, sizeof(DWORD) * 10, &dwRead, NULL); - ReadFile(hSaveFile, m_Reg.m_Display_ControlReg, sizeof(DWORD) * 10, &dwRead, NULL); - ReadFile(hSaveFile, m_Reg.m_Mips_Interface, sizeof(DWORD) * 4, &dwRead, NULL); - ReadFile(hSaveFile, m_Reg.m_Video_Interface, sizeof(DWORD) * 14, &dwRead, NULL); - ReadFile(hSaveFile, m_Reg.m_Audio_Interface, sizeof(DWORD) * 6, &dwRead, NULL); - ReadFile(hSaveFile, m_Reg.m_Peripheral_Interface, sizeof(DWORD) * 13, &dwRead, NULL); - ReadFile(hSaveFile, m_Reg.m_RDRAM_Interface, sizeof(DWORD) * 8, &dwRead, NULL); - ReadFile(hSaveFile, m_Reg.m_SerialInterface, sizeof(DWORD) * 4, &dwRead, NULL); - ReadFile(hSaveFile, (void *const)&g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32, &dwRead, NULL); - ReadFile(hSaveFile, m_MMU_VM.PifRam(), 0x40, &dwRead, NULL); - ReadFile(hSaveFile, m_MMU_VM.Rdram(), SaveRDRAMSize, &dwRead, NULL); - ReadFile(hSaveFile, m_MMU_VM.Dmem(), 0x1000, &dwRead, NULL); - ReadFile(hSaveFile, m_MMU_VM.Imem(), 0x1000, &dwRead, NULL); - CloseHandle(hSaveFile); - } + ReadFile(hSaveFile, &NextVITimer, sizeof(NextVITimer), &dwRead, NULL); + ReadFile(hSaveFile, &m_Reg.m_PROGRAM_COUNTER, sizeof(m_Reg.m_PROGRAM_COUNTER), &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_GPR, sizeof(__int64) * 32, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_FPR, sizeof(__int64) * 32, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_CP0, sizeof(DWORD) * 32, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_FPCR, sizeof(DWORD) * 32, &dwRead, NULL); + ReadFile(hSaveFile, &m_Reg.m_HI, sizeof(__int64), &dwRead, NULL); + ReadFile(hSaveFile, &m_Reg.m_LO, sizeof(__int64), &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_RDRAM_Registers, sizeof(DWORD) * 10, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_SigProcessor_Interface, sizeof(DWORD) * 10, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_Display_ControlReg, sizeof(DWORD) * 10, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_Mips_Interface, sizeof(DWORD) * 4, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_Video_Interface, sizeof(DWORD) * 14, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_Audio_Interface, sizeof(DWORD) * 6, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_Peripheral_Interface, sizeof(DWORD) * 13, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_RDRAM_Interface, sizeof(DWORD) * 8, &dwRead, NULL); + ReadFile(hSaveFile, m_Reg.m_SerialInterface, sizeof(DWORD) * 4, &dwRead, NULL); + ReadFile(hSaveFile, (void *const)&g_TLB->TlbEntry(0), sizeof(CTLB::TLB_ENTRY) * 32, &dwRead, NULL); + ReadFile(hSaveFile, m_MMU_VM.PifRam(), 0x40, &dwRead, NULL); + ReadFile(hSaveFile, m_MMU_VM.Rdram(), SaveRDRAMSize, &dwRead, NULL); + ReadFile(hSaveFile, m_MMU_VM.Dmem(), 0x1000, &dwRead, NULL); + ReadFile(hSaveFile, m_MMU_VM.Imem(), 0x1000, &dwRead, NULL); + CloseHandle(hSaveFile); + } - //Fix losing audio in certain games with certain plugins - AudioResetOnLoad = g_Settings->LoadBool(Game_AudioResetOnLoad); - if (AudioResetOnLoad) - { - m_Reg.m_AudioIntrReg |= MI_INTR_AI; - m_Reg.AI_STATUS_REG &= ~AI_STATUS_FIFO_FULL; - g_Reg->MI_INTR_REG |= MI_INTR_AI; - } + //Fix losing audio in certain games with certain plugins + AudioResetOnLoad = g_Settings->LoadBool(Game_AudioResetOnLoad); + if (AudioResetOnLoad) + { + m_Reg.m_AudioIntrReg |= MI_INTR_AI; + m_Reg.AI_STATUS_REG &= ~AI_STATUS_FIFO_FULL; + g_Reg->MI_INTR_REG |= MI_INTR_AI; + } - if (bFixedAudio()) - { - m_Audio.SetFrequency(m_Reg.AI_DACRATE_REG, g_System->SystemType()); - } + if (bFixedAudio()) + { + m_Audio.SetFrequency(m_Reg.AI_DACRATE_REG, g_System->SystemType()); + } - if (old_status != g_Reg->VI_STATUS_REG) - { - g_Plugins->Gfx()->ViStatusChanged(); - } + if (old_status != g_Reg->VI_STATUS_REG) + { + g_Plugins->Gfx()->ViStatusChanged(); + } - if (old_width != g_Reg->VI_WIDTH_REG) - { - g_Plugins->Gfx()->ViWidthChanged(); - } + if (old_width != g_Reg->VI_WIDTH_REG) + { + g_Plugins->Gfx()->ViWidthChanged(); + } - if (old_dacrate != g_Reg->AI_DACRATE_REG) - { - g_Plugins->Audio()->DacrateChanged(g_System->SystemType()); - } + if (old_dacrate != g_Reg->AI_DACRATE_REG) + { + g_Plugins->Audio()->DacrateChanged(g_System->SystemType()); + } - //Fix Random Register - while ((int)m_Reg.RANDOM_REGISTER < (int)m_Reg.WIRED_REGISTER) - { - m_Reg.RANDOM_REGISTER += 32 - m_Reg.WIRED_REGISTER; - } - //Fix up timer - WriteTrace(TraceDebug, __FUNCTION__ ": 2"); - m_SystemTimer.SetTimer(CSystemTimer::CompareTimer, m_Reg.COMPARE_REGISTER - m_Reg.COUNT_REGISTER, false); - m_SystemTimer.SetTimer(CSystemTimer::ViTimer, NextVITimer, false); - m_Reg.FixFpuLocations(); - WriteTrace(TraceDebug, __FUNCTION__ ": 5"); - m_TLB.Reset(false); - WriteTrace(TraceDebug, __FUNCTION__ ": 6"); - m_CPU_Usage.ResetCounters(); - WriteTrace(TraceDebug, __FUNCTION__ ": 7"); - m_Profile.ResetCounters(); - WriteTrace(TraceDebug, __FUNCTION__ ": 8"); - m_FPS.Reset(true); - WriteTrace(TraceDebug, __FUNCTION__ ": 9"); - if (bLogX86Code()) - { - Stop_x86_Log(); - Start_x86_Log(); - } - WriteTrace(TraceDebug, __FUNCTION__ ": Done"); + //Fix Random Register + while ((int)m_Reg.RANDOM_REGISTER < (int)m_Reg.WIRED_REGISTER) + { + m_Reg.RANDOM_REGISTER += 32 - m_Reg.WIRED_REGISTER; + } + //Fix up timer + WriteTrace(TraceDebug, __FUNCTION__ ": 2"); + m_SystemTimer.SetTimer(CSystemTimer::CompareTimer, m_Reg.COMPARE_REGISTER - m_Reg.COUNT_REGISTER, false); + m_SystemTimer.SetTimer(CSystemTimer::ViTimer, NextVITimer, false); + m_Reg.FixFpuLocations(); + WriteTrace(TraceDebug, __FUNCTION__ ": 5"); + m_TLB.Reset(false); + WriteTrace(TraceDebug, __FUNCTION__ ": 6"); + m_CPU_Usage.ResetCounters(); + WriteTrace(TraceDebug, __FUNCTION__ ": 7"); + m_Profile.ResetCounters(); + WriteTrace(TraceDebug, __FUNCTION__ ": 8"); + m_FPS.Reset(true); + WriteTrace(TraceDebug, __FUNCTION__ ": 9"); + if (bLogX86Code()) + { + Stop_x86_Log(); + Start_x86_Log(); + } + WriteTrace(TraceDebug, __FUNCTION__ ": Done"); #ifdef TEST_SP_TRACKING - m_CurrentSP = GPR[29].UW[0]; + m_CurrentSP = GPR[29].UW[0]; #endif - if (bFastSP() && m_Recomp) { m_Recomp->ResetMemoryStackPos(); } + if (bFastSP() && m_Recomp) { m_Recomp->ResetMemoryStackPos(); } - if (g_Settings->LoadDword(Game_CpuType) == CPU_SyncCores) - { - if (m_SyncCPU) - { - for (int i = 0; i < (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])); i++) - { - m_LastSuccessSyncPC[i] = 0; - } - m_SyncCPU->SetActiveSystem(true); - m_SyncCPU->LoadState(FileNameStr.c_str()); - SetActiveSystem(true); - SyncCPU(m_SyncCPU); - } - } - WriteTrace(TraceDebug, __FUNCTION__ ": 13"); - std::wstring LoadMsg = g_Lang->GetString(MSG_LOADED_STATE); - g_Notify->DisplayMessage(5, stdstr_f("%s %s", LoadMsg.c_str(), CPath(FileNameStr).GetNameExtension()).ToUTF16().c_str()); - WriteTrace(TraceDebug, __FUNCTION__ ": Done"); - return true; + if (g_Settings->LoadDword(Game_CpuType) == CPU_SyncCores) + { + if (m_SyncCPU) + { + for (int i = 0; i < (sizeof(m_LastSuccessSyncPC) / sizeof(m_LastSuccessSyncPC[0])); i++) + { + m_LastSuccessSyncPC[i] = 0; + } + m_SyncCPU->SetActiveSystem(true); + m_SyncCPU->LoadState(FileNameStr.c_str()); + SetActiveSystem(true); + SyncCPU(m_SyncCPU); + } + } + WriteTrace(TraceDebug, __FUNCTION__ ": 13"); + std::wstring LoadMsg = g_Lang->GetString(MSG_LOADED_STATE); + g_Notify->DisplayMessage(5, stdstr_f("%s %s", LoadMsg.c_str(), CPath(FileNameStr).GetNameExtension()).ToUTF16().c_str()); + WriteTrace(TraceDebug, __FUNCTION__ ": Done"); + return true; } void CN64System::DisplayRSPListCount() { - g_Notify->DisplayMessage(0, stdstr_f("Dlist: %d Alist: %d Unknown: %d", m_DlistCount, m_AlistCount, m_UnknownCount).ToUTF16().c_str()); + g_Notify->DisplayMessage(0, stdstr_f("Dlist: %d Alist: %d Unknown: %d", m_DlistCount, m_AlistCount, m_UnknownCount).ToUTF16().c_str()); } void CN64System::RunRSP() { - WriteTraceF(TraceRSP, __FUNCTION__ ": Start (SP Status %X)", m_Reg.SP_STATUS_REG); - if ((m_Reg.SP_STATUS_REG & SP_STATUS_HALT) == 0) - { - if ((m_Reg.SP_STATUS_REG & SP_STATUS_BROKE) == 0) - { - SPECIAL_TIMERS CPU_UsageAddr = Timer_None/*, ProfileAddr = Timer_None*/; + WriteTraceF(TraceRSP, __FUNCTION__ ": Start (SP Status %X)", m_Reg.SP_STATUS_REG); + if ((m_Reg.SP_STATUS_REG & SP_STATUS_HALT) == 0) + { + if ((m_Reg.SP_STATUS_REG & SP_STATUS_BROKE) == 0) + { + SPECIAL_TIMERS CPU_UsageAddr = Timer_None/*, ProfileAddr = Timer_None*/; - DWORD Task = 0; - if (m_RspBroke) - { - g_MMU->LW_VAddr(0xA4000FC0, (uint32_t &)Task); - if (Task == 1 && (m_Reg.DPC_STATUS_REG & DPC_STATUS_FREEZE) != 0) - { - WriteTrace(TraceRSP, __FUNCTION__ ": Dlist that is frozen"); - return; - } + DWORD Task = 0; + if (m_RspBroke) + { + g_MMU->LW_VAddr(0xA4000FC0, (uint32_t &)Task); + if (Task == 1 && (m_Reg.DPC_STATUS_REG & DPC_STATUS_FREEZE) != 0) + { + WriteTrace(TraceRSP, __FUNCTION__ ": Dlist that is frozen"); + return; + } - switch (Task) - { - case 1: - WriteTrace(TraceRSP, __FUNCTION__ ": *** Display list ***"); - m_DlistCount += 1; - m_FPS.UpdateDlCounter(); - break; - case 2: - WriteTrace(TraceRSP, __FUNCTION__ ": *** Audio list ***"); - m_AlistCount += 1; - break; - default: - WriteTrace(TraceRSP, __FUNCTION__ ": *** Unknown list ***"); - m_UnknownCount += 1; - break; - } + switch (Task) + { + case 1: + WriteTrace(TraceRSP, __FUNCTION__ ": *** Display list ***"); + m_DlistCount += 1; + m_FPS.UpdateDlCounter(); + break; + case 2: + WriteTrace(TraceRSP, __FUNCTION__ ": *** Audio list ***"); + m_AlistCount += 1; + break; + default: + WriteTrace(TraceRSP, __FUNCTION__ ": *** Unknown list ***"); + m_UnknownCount += 1; + break; + } - if (bShowDListAListCount()) - { - DisplayRSPListCount(); - } - if (bShowCPUPer()) - { - switch (Task) - { - case 1: CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_RSP_Dlist); break; - case 2: CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_RSP_Alist); break; - default: CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_RSP_Unknown); break; - } - } - } + if (bShowDListAListCount()) + { + DisplayRSPListCount(); + } + if (bShowCPUPer()) + { + switch (Task) + { + case 1: CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_RSP_Dlist); break; + case 2: CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_RSP_Alist); break; + default: CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_RSP_Unknown); break; + } + } + } - __try - { - WriteTrace(TraceRSP, __FUNCTION__ ": do cycles - starting"); - g_Plugins->RSP()->DoRspCycles(100); - WriteTrace(TraceRSP, __FUNCTION__ ": do cycles - Done"); - } - __except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation())) - { - WriteTrace(TraceError, __FUNCTION__ ": exception generated"); - g_Notify->FatalError(__FUNCTIONW__ L"\nUnknown memory action\n\nEmulation stop"); - } + __try + { + WriteTrace(TraceRSP, __FUNCTION__ ": do cycles - starting"); + g_Plugins->RSP()->DoRspCycles(100); + WriteTrace(TraceRSP, __FUNCTION__ ": do cycles - Done"); + } + __except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation())) + { + WriteTrace(TraceError, __FUNCTION__ ": exception generated"); + g_Notify->FatalError(__FUNCTIONW__ L"\nUnknown memory action\n\nEmulation stop"); + } - if (Task == 1 && bDelayDP() && ((m_Reg.m_GfxIntrReg & MI_INTR_DP) != 0)) - { - g_SystemTimer->SetTimer(CSystemTimer::RSPTimerDlist, 0x1000, false); - m_Reg.m_GfxIntrReg &= ~MI_INTR_DP; - } - if (bShowCPUPer()) { m_CPU_Usage.StartTimer(CPU_UsageAddr); } - //if (bProfiling) { m_Profile.StartTimer(ProfileAddr); } + if (Task == 1 && bDelayDP() && ((m_Reg.m_GfxIntrReg & MI_INTR_DP) != 0)) + { + g_SystemTimer->SetTimer(CSystemTimer::RSPTimerDlist, 0x1000, false); + m_Reg.m_GfxIntrReg &= ~MI_INTR_DP; + } + if (bShowCPUPer()) { m_CPU_Usage.StartTimer(CPU_UsageAddr); } + //if (bProfiling) { m_Profile.StartTimer(ProfileAddr); } - if ((m_Reg.SP_STATUS_REG & SP_STATUS_HALT) == 0 && - (m_Reg.SP_STATUS_REG & SP_STATUS_BROKE) == 0 && - m_Reg.m_RspIntrReg == 0) - { - g_SystemTimer->SetTimer(CSystemTimer::RspTimer, 0x200, false); - m_RspBroke = false; - } - else - { - m_RspBroke = true; - } - WriteTrace(TraceRSP, __FUNCTION__ ": check interrupts"); - g_Reg->CheckInterrupts(); - } - } - WriteTraceF(TraceRSP, __FUNCTION__ ": Done (SP Status %X)", m_Reg.SP_STATUS_REG); + if ((m_Reg.SP_STATUS_REG & SP_STATUS_HALT) == 0 && + (m_Reg.SP_STATUS_REG & SP_STATUS_BROKE) == 0 && + m_Reg.m_RspIntrReg == 0) + { + g_SystemTimer->SetTimer(CSystemTimer::RspTimer, 0x200, false); + m_RspBroke = false; + } + else + { + m_RspBroke = true; + } + WriteTrace(TraceRSP, __FUNCTION__ ": check interrupts"); + g_Reg->CheckInterrupts(); + } + } + WriteTraceF(TraceRSP, __FUNCTION__ ": Done (SP Status %X)", m_Reg.SP_STATUS_REG); } void CN64System::SyncToAudio() { - if (!bSyncToAudio() || !bLimitFPS()) - { - return; - } - SPECIAL_TIMERS CPU_UsageAddr = Timer_None; + if (!bSyncToAudio() || !bLimitFPS()) + { + return; + } + SPECIAL_TIMERS CPU_UsageAddr = Timer_None; - if (bShowCPUPer()) { CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_Idel); } + if (bShowCPUPer()) { CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_Idel); } - for (int i = 0; i < 50; i++) - { - if (g_Reg->m_AudioIntrReg != 0) - { - WriteTraceF(TraceAudio, __FUNCTION__ ": Audio Interrupt done (%d)", i); - break; - } - Sleep(1); - } - if (bShowCPUPer()) - { - m_CPU_Usage.StartTimer(CPU_UsageAddr != Timer_None ? CPU_UsageAddr : Timer_R4300); - } + for (int i = 0; i < 50; i++) + { + if (g_Reg->m_AudioIntrReg != 0) + { + WriteTraceF(TraceAudio, __FUNCTION__ ": Audio Interrupt done (%d)", i); + break; + } + Sleep(1); + } + if (bShowCPUPer()) + { + m_CPU_Usage.StartTimer(CPU_UsageAddr != Timer_None ? CPU_UsageAddr : Timer_R4300); + } } void CN64System::RefreshScreen() { - SPECIAL_TIMERS CPU_UsageAddr = Timer_None/*, ProfilingAddr = Timer_None*/; - DWORD VI_INTR_TIME = 500000; + SPECIAL_TIMERS CPU_UsageAddr = Timer_None/*, ProfilingAddr = Timer_None*/; + DWORD VI_INTR_TIME = 500000; - if (bShowCPUPer()) { CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_RefreshScreen); } - //if (bProfiling) { ProfilingAddr = m_Profile.StartTimer(Timer_RefreshScreen); } + if (bShowCPUPer()) { CPU_UsageAddr = m_CPU_Usage.StartTimer(Timer_RefreshScreen); } + //if (bProfiling) { ProfilingAddr = m_Profile.StartTimer(Timer_RefreshScreen); } - //Calculate how many cycles to next refresh - if (m_Reg.VI_V_SYNC_REG == 0) - { - VI_INTR_TIME = 500000; - } - else - { - VI_INTR_TIME = (m_Reg.VI_V_SYNC_REG + 1) * ViRefreshRate(); - if ((m_Reg.VI_V_SYNC_REG % 1) != 0) - { - VI_INTR_TIME -= 38; - } - } - g_SystemTimer->SetTimer(CSystemTimer::ViTimer, VI_INTR_TIME, true); - if (bFixedAudio()) - { - g_Audio->SetViIntr(VI_INTR_TIME); - } - if (g_Plugins->Control()->GetKeys) - { - BUTTONS Keys; - memset(&Keys, 0, sizeof(Keys)); + //Calculate how many cycles to next refresh + if (m_Reg.VI_V_SYNC_REG == 0) + { + VI_INTR_TIME = 500000; + } + else + { + VI_INTR_TIME = (m_Reg.VI_V_SYNC_REG + 1) * ViRefreshRate(); + if ((m_Reg.VI_V_SYNC_REG % 1) != 0) + { + VI_INTR_TIME -= 38; + } + } + g_SystemTimer->SetTimer(CSystemTimer::ViTimer, VI_INTR_TIME, true); + if (bFixedAudio()) + { + g_Audio->SetViIntr(VI_INTR_TIME); + } + if (g_Plugins->Control()->GetKeys) + { + BUTTONS Keys; + memset(&Keys, 0, sizeof(Keys)); - for (int Control = 0; Control < 4; Control++) - { - g_Plugins->Control()->GetKeys(Control, &Keys); - m_Buttons[Control] = Keys.Value; - } - } + for (int Control = 0; Control < 4; Control++) + { + g_Plugins->Control()->GetKeys(Control, &Keys); + m_Buttons[Control] = Keys.Value; + } + } - if (bShowCPUPer()) { m_CPU_Usage.StartTimer(Timer_UpdateScreen); } - // if (bProfiling) { m_Profile.StartTimer(Timer_UpdateScreen); } + if (bShowCPUPer()) { m_CPU_Usage.StartTimer(Timer_UpdateScreen); } + // if (bProfiling) { m_Profile.StartTimer(Timer_UpdateScreen); } - __try - { - WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Starting"); - g_Plugins->Gfx()->UpdateScreen(); - WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Done"); - } - __except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation())) - { - WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Exception caught"); - WriteTrace(TraceError, __FUNCTION__ ": Exception caught"); - } + __try + { + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Starting"); + g_Plugins->Gfx()->UpdateScreen(); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Done"); + } + __except (g_MMU->MemoryFilter(GetExceptionCode(), GetExceptionInformation())) + { + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Exception caught"); + WriteTrace(TraceError, __FUNCTION__ ": Exception caught"); + } - g_MMU->UpdateFieldSerration((m_Reg.VI_STATUS_REG & 0x40) != 0); + g_MMU->UpdateFieldSerration((m_Reg.VI_STATUS_REG & 0x40) != 0); - if ((bBasicMode() || bLimitFPS()) && !bSyncToAudio()) - { - if (bShowCPUPer()) { m_CPU_Usage.StartTimer(Timer_Idel); } - uint32_t FrameRate; - if (m_Limitor.Timer_Process(&FrameRate) && bDisplayFrameRate()) - { - m_FPS.DisplayViCounter(FrameRate); - m_bCleanFrameBox = true; - } - } - else if (bDisplayFrameRate()) - { - if (bShowCPUPer()) { m_CPU_Usage.StartTimer(Timer_UpdateFPS); } - m_FPS.UpdateViCounter(); - m_bCleanFrameBox = true; - } + if ((bBasicMode() || bLimitFPS()) && !bSyncToAudio()) + { + if (bShowCPUPer()) { m_CPU_Usage.StartTimer(Timer_Idel); } + uint32_t FrameRate; + if (m_Limitor.Timer_Process(&FrameRate) && bDisplayFrameRate()) + { + m_FPS.DisplayViCounter(FrameRate); + m_bCleanFrameBox = true; + } + } + else if (bDisplayFrameRate()) + { + if (bShowCPUPer()) { m_CPU_Usage.StartTimer(Timer_UpdateFPS); } + m_FPS.UpdateViCounter(); + m_bCleanFrameBox = true; + } - if (m_bCleanFrameBox && !bDisplayFrameRate()) - { - m_FPS.Reset(true); - m_bCleanFrameBox = false; - } + if (m_bCleanFrameBox && !bDisplayFrameRate()) + { + m_FPS.Reset(true); + m_bCleanFrameBox = false; + } - if (bShowCPUPer()) - { - m_CPU_Usage.StopTimer(); - m_CPU_Usage.ShowCPU_Usage(); - m_CPU_Usage.StartTimer(CPU_UsageAddr != Timer_None ? CPU_UsageAddr : Timer_R4300); - } - if ((m_Reg.STATUS_REGISTER & STATUS_IE) != 0) - { - if (HasCheatsSlectionChanged()) - { - if (this == g_BaseSystem && g_SyncSystem != NULL) - { - g_SyncSystem->SetCheatsSlectionChanged(true); - } - SetCheatsSlectionChanged(false); - m_Cheats.LoadCheats(false, g_BaseSystem->m_Plugins); - } - m_Cheats.ApplyCheats(g_MMU); - } - // if (bProfiling) { m_Profile.StartTimer(ProfilingAddr != Timer_None ? ProfilingAddr : Timer_R4300); } + if (bShowCPUPer()) + { + m_CPU_Usage.StopTimer(); + m_CPU_Usage.ShowCPU_Usage(); + m_CPU_Usage.StartTimer(CPU_UsageAddr != Timer_None ? CPU_UsageAddr : Timer_R4300); + } + if ((m_Reg.STATUS_REGISTER & STATUS_IE) != 0) + { + if (HasCheatsSlectionChanged()) + { + if (this == g_BaseSystem && g_SyncSystem != NULL) + { + g_SyncSystem->SetCheatsSlectionChanged(true); + } + SetCheatsSlectionChanged(false); + m_Cheats.LoadCheats(false, g_BaseSystem->m_Plugins); + } + m_Cheats.ApplyCheats(g_MMU); + } + // if (bProfiling) { m_Profile.StartTimer(ProfilingAddr != Timer_None ? ProfilingAddr : Timer_R4300); } } bool CN64System::WriteToProtectedMemory(uint32_t Address, int length) { - WriteTraceF(TraceDebug, __FUNCTION__ ": Address: %X Len: %d", Address, length); - if (m_Recomp) - { - g_Notify->BreakPoint(__FILEW__, __LINE__); + WriteTraceF(TraceDebug, __FUNCTION__ ": Address: %X Len: %d", Address, length); + if (m_Recomp) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); #ifdef tofix - return m_Recomp->ClearRecompCode_Phys(Address,length,CRecompiler::Remove_ProtectedMem); + return m_Recomp->ClearRecompCode_Phys(Address,length,CRecompiler::Remove_ProtectedMem); #endif - } - return false; + } + return false; } void CN64System::TLB_Mapped(uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly) { - m_MMU_VM.TLB_Mapped(VAddr, Len, PAddr, bReadOnly); + m_MMU_VM.TLB_Mapped(VAddr, Len, PAddr, bReadOnly); } void CN64System::TLB_Unmaped(uint32_t VAddr, uint32_t Len) { - m_MMU_VM.TLB_Unmaped(VAddr, Len); - if (m_Recomp && bSMM_TLB()) - { - m_Recomp->ClearRecompCode_Virt(VAddr, Len, CRecompiler::Remove_TLB); - } + m_MMU_VM.TLB_Unmaped(VAddr, Len); + if (m_Recomp && bSMM_TLB()) + { + m_Recomp->ClearRecompCode_Virt(VAddr, Len, CRecompiler::Remove_TLB); + } } void CN64System::TLB_Changed() { - if (g_Debugger) - { - g_Debugger->TLBChanged(); - } + if (g_Debugger) + { + g_Debugger->TLBChanged(); + } } \ No newline at end of file diff --git a/Source/Project64/N64 System/N64 Class.h b/Source/Project64/N64 System/N64 Class.h index 27292a815..123fa1e64 100644 --- a/Source/Project64/N64 System/N64 Class.h +++ b/Source/Project64/N64 System/N64 Class.h @@ -21,145 +21,145 @@ class CRecompiler; //#define TEST_SP_TRACKING //track the SP to make sure all ops pick it up fine class CN64System : - public CMipsMemory_CallBack, - public CTLB_CB, - private CSystemEvents, - protected CN64SystemSettings, - public CGameSettings, - protected CDebugSettings + public CMipsMemory_CallBack, + public CTLB_CB, + private CSystemEvents, + protected CN64SystemSettings, + public CGameSettings, + protected CDebugSettings { public: - CN64System(CPlugins * Plugins, bool SavesReadOnly); - virtual ~CN64System(void); + CN64System(CPlugins * Plugins, bool SavesReadOnly); + virtual ~CN64System(void); - struct ThreadInfo { - HANDLE * ThreadHandle; - DWORD ThreadID; - }; + struct ThreadInfo { + HANDLE * ThreadHandle; + DWORD ThreadID; + }; - CProfiling m_Profile; - CCheats m_Cheats; - bool m_EndEmulation; - SAVE_CHIP_TYPE m_SaveUsing; + CProfiling m_Profile; + CCheats m_Cheats; + bool m_EndEmulation; + SAVE_CHIP_TYPE m_SaveUsing; - //Methods - static bool RunFileImage(const char * FileLoc); - static void CloseSystem(void); + //Methods + static bool RunFileImage(const char * FileLoc); + static void CloseSystem(void); - void CloseCpu(); - void ExternalEvent(SystemEvent action); //covers gui interacting and timers etc.. - stdstr ChooseFileToOpen(HWND hParent); - void DisplayRomInfo(HWND hParent); - void StartEmulation(bool NewThread); - void SyncToAudio(); - void IncreaseSpeed() { m_Limitor.IncreaseSpeed(); } - void DecreaseSpeed() { m_Limitor.DecreaseSpeed(); } - void Reset(bool bInitReg, bool ClearMenory); - void GameReset(); - void PluginReset(); + void CloseCpu(); + void ExternalEvent(SystemEvent action); //covers gui interacting and timers etc.. + stdstr ChooseFileToOpen(HWND hParent); + void DisplayRomInfo(HWND hParent); + void StartEmulation(bool NewThread); + void SyncToAudio(); + void IncreaseSpeed() { m_Limitor.IncreaseSpeed(); } + void DecreaseSpeed() { m_Limitor.DecreaseSpeed(); } + void Reset(bool bInitReg, bool ClearMenory); + void GameReset(); + void PluginReset(); - void Pause(); - void RunRSP(); - bool SaveState(); - bool LoadState(LPCSTR FileName); - bool LoadState(); + void Pause(); + void RunRSP(); + bool SaveState(); + bool LoadState(LPCSTR FileName); + bool LoadState(); - bool DmaUsed() const { return m_DMAUsed; } - void SetDmaUsed(bool DMAUsed) { m_DMAUsed = DMAUsed; } - void SetCheatsSlectionChanged(bool changed) { m_CheatsSlectionChanged = changed; } - bool HasCheatsSlectionChanged(void) const { return m_CheatsSlectionChanged; } - DWORD GetButtons(int Control) const { return m_Buttons[Control]; } + bool DmaUsed() const { return m_DMAUsed; } + void SetDmaUsed(bool DMAUsed) { m_DMAUsed = DMAUsed; } + void SetCheatsSlectionChanged(bool changed) { m_CheatsSlectionChanged = changed; } + bool HasCheatsSlectionChanged(void) const { return m_CheatsSlectionChanged; } + DWORD GetButtons(int Control) const { return m_Buttons[Control]; } - //Variable used to track that the SP is being handled and stays the same as the real SP in sync core + //Variable used to track that the SP is being handled and stays the same as the real SP in sync core #ifdef TEST_SP_TRACKING - DWORD m_CurrentSP; + DWORD m_CurrentSP; #endif - //For Sync CPU - void UpdateSyncCPU(CN64System * const SecondCPU, DWORD const Cycles); - void SyncCPU(CN64System * const SecondCPU); - void SyncCPUPC(CN64System * const SecondCPU); - void SyncSystem(); - void SyncSystemPC(); + //For Sync CPU + void UpdateSyncCPU(CN64System * const SecondCPU, DWORD const Cycles); + void SyncCPU(CN64System * const SecondCPU); + void SyncCPUPC(CN64System * const SecondCPU); + void SyncSystem(); + void SyncSystemPC(); private: - //Make sure plugins can directly access this information - friend CGfxPlugin; - friend CAudioPlugin; - friend CRSP_Plugin; - friend CControl_Plugin; + //Make sure plugins can directly access this information + friend CGfxPlugin; + friend CAudioPlugin; + friend CRSP_Plugin; + friend CControl_Plugin; - //Recompiler has access to manipulate and call functions - friend CSystemTimer; + //Recompiler has access to manipulate and call functions + friend CSystemTimer; - //Used for loading and potentially executing the CPU in its own thread. - static void StartEmulationThread(ThreadInfo * Info); - static bool EmulationStarting(HANDLE hThread, DWORD ThreadId); + //Used for loading and potentially executing the CPU in its own thread. + static void StartEmulationThread(ThreadInfo * Info); + static bool EmulationStarting(HANDLE hThread, DWORD ThreadId); - void ExecuteCPU(); - void RefreshScreen(); - void DumpSyncErrors(CN64System * SecondCPU); - void StartEmulation2(bool NewThread); - bool SetActiveSystem(bool bActive = true); - void InitRegisters(bool bPostPif, CMipsMemory & MMU); - void DisplayRSPListCount(); + void ExecuteCPU(); + void RefreshScreen(); + void DumpSyncErrors(CN64System * SecondCPU); + void StartEmulation2(bool NewThread); + bool SetActiveSystem(bool bActive = true); + void InitRegisters(bool bPostPif, CMipsMemory & MMU); + void DisplayRSPListCount(); - //CPU Methods - void ExecuteRecompiler(); - void ExecuteInterpret(); - void ExecuteSyncCPU(); + //CPU Methods + void ExecuteRecompiler(); + void ExecuteInterpret(); + void ExecuteSyncCPU(); - //Mark information saying that the CPU has stopped - void CpuStopped(); + //Mark information saying that the CPU has stopped + void CpuStopped(); - //Function in CMipsMemory_CallBack - virtual bool WriteToProtectedMemory(uint32_t Address, int length); + //Function in CMipsMemory_CallBack + virtual bool WriteToProtectedMemory(uint32_t Address, int length); - //Functions in CTLB_CB - void TLB_Mapped(uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly); - void TLB_Unmaped(uint32_t VAddr, uint32_t Len); - void TLB_Changed(); + //Functions in CTLB_CB + void TLB_Mapped(uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly); + void TLB_Unmaped(uint32_t VAddr, uint32_t Len); + void TLB_Changed(); - CPlugins * const m_Plugins; //The plugin container - CN64System * m_SyncCPU; - CPlugins * m_SyncPlugins; - CMainGui * m_SyncWindow; - CMipsMemoryVM m_MMU_VM; //Memory of the n64 - CTLB m_TLB; - CRegisters m_Reg; - CFramePerSecond m_FPS; - CProfiling m_CPU_Usage; //used to track the cpu usage - CRecompiler * m_Recomp; - CAudio m_Audio; - CSpeedLimitor m_Limitor; - bool m_InReset; - int m_NextTimer; - CSystemTimer m_SystemTimer; - bool m_bCleanFrameBox; - bool m_bInitialized; - bool m_RspBroke; - bool m_DMAUsed; - DWORD m_Buttons[4]; - bool m_TestTimer; - DWORD m_NextInstruction; - DWORD m_JumpToLocation; - uint32_t m_TLBLoadAddress; - uint32_t m_TLBStoreAddress; - DWORD m_SyncCount; - bool m_CheatsSlectionChanged; + CPlugins * const m_Plugins; //The plugin container + CN64System * m_SyncCPU; + CPlugins * m_SyncPlugins; + CMainGui * m_SyncWindow; + CMipsMemoryVM m_MMU_VM; //Memory of the n64 + CTLB m_TLB; + CRegisters m_Reg; + CFramePerSecond m_FPS; + CProfiling m_CPU_Usage; //used to track the cpu usage + CRecompiler * m_Recomp; + CAudio m_Audio; + CSpeedLimitor m_Limitor; + bool m_InReset; + int m_NextTimer; + CSystemTimer m_SystemTimer; + bool m_bCleanFrameBox; + bool m_bInitialized; + bool m_RspBroke; + bool m_DMAUsed; + DWORD m_Buttons[4]; + bool m_TestTimer; + DWORD m_NextInstruction; + DWORD m_JumpToLocation; + uint32_t m_TLBLoadAddress; + uint32_t m_TLBStoreAddress; + DWORD m_SyncCount; + bool m_CheatsSlectionChanged; - //When Syncing cores this is the PC where it last Sync'ed correctly - DWORD m_LastSuccessSyncPC[10]; - int m_CyclesToSkip; + //When Syncing cores this is the PC where it last Sync'ed correctly + DWORD m_LastSuccessSyncPC[10]; + int m_CyclesToSkip; - //Handle to the cpu thread - HANDLE m_CPU_Handle; - DWORD m_CPU_ThreadID; + //Handle to the cpu thread + HANDLE m_CPU_Handle; + DWORD m_CPU_ThreadID; - //Handle to pause mutex - void * m_hPauseEvent; + //Handle to pause mutex + SyncEvent m_hPauseEvent; - //No of Alist and Dlist sent to the RSP - DWORD m_AlistCount, m_DlistCount, m_UnknownCount; + //No of Alist and Dlist sent to the RSP + DWORD m_AlistCount, m_DlistCount, m_UnknownCount; - //list of function that have been called .. used in profiling - FUNC_CALLS m_FunctionCalls; + //list of function that have been called .. used in profiling + FUNC_CALLS m_FunctionCalls; }; From 5888b1d3f69b57be40c1dc733834bee7388d129b Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 12 Nov 2015 18:08:10 +1100 Subject: [PATCH 137/213] [Project64] Change m_hPauseEvent to a sync event --- Source/Project64/N64 System/N64 Class.cpp | 34 ++++++++++------------- Source/Project64/N64 System/N64 Class.h | 2 ++ 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index fb49d3464..70955bda8 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -42,6 +42,7 @@ m_TLBStoreAddress(0), m_SyncCount(0), m_CPU_Handle(NULL), m_CPU_ThreadID(0), +m_hPauseEvent(true), m_CheatsSlectionChanged(false) { DWORD gameHertz = g_Settings->LoadDword(Game_ScreenHertz); @@ -49,7 +50,6 @@ m_CheatsSlectionChanged(false) { gameHertz = (SystemType() == SYSTEM_PAL) ? 50 : 60; } - m_hPauseEvent = CreateEvent(NULL, true, false, NULL); m_Limitor.SetHertz(gameHertz); g_Settings->SaveDword(GameRunning_ScreenHertz, gameHertz); m_Cheats.LoadCheats(!g_Settings->LoadDword(Setting_RememberCheats), Plugins); @@ -123,54 +123,54 @@ void CN64System::ExternalEvent(SystemEvent action) break; case SysEvent_ResumeCPU_FromMenu: // always resume if from menu - SetEvent(m_hPauseEvent); + m_hPauseEvent.Trigger(); break; case SysEvent_ResumeCPU_AppGainedFocus: if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_AppLostFocus) { - SetEvent(m_hPauseEvent); + m_hPauseEvent.Trigger(); } break; case SysEvent_ResumeCPU_AppGainedActive: if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_AppLostActive) { - SetEvent(m_hPauseEvent); + m_hPauseEvent.Trigger(); } break; case SysEvent_ResumeCPU_SaveGame: if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_SaveGame) { - SetEvent(m_hPauseEvent); + m_hPauseEvent.Trigger(); } break; case SysEvent_ResumeCPU_LoadGame: if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_LoadGame) { - SetEvent(m_hPauseEvent); + m_hPauseEvent.Trigger(); } break; case SysEvent_ResumeCPU_DumpMemory: if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_DumpMemory) { - SetEvent(m_hPauseEvent); + m_hPauseEvent.Trigger(); } break; case SysEvent_ResumeCPU_SearchMemory: if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_SearchMemory) { - SetEvent(m_hPauseEvent); + m_hPauseEvent.Trigger(); } break; case SysEvent_ResumeCPU_Settings: if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_Settings) { - SetEvent(m_hPauseEvent); + m_hPauseEvent.Trigger(); } break; case SysEvent_ResumeCPU_Cheats: if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_Cheats) { - SetEvent(m_hPauseEvent); + m_hPauseEvent.Trigger(); } break; default: @@ -420,7 +420,7 @@ void CN64System::CloseCpu() m_EndEmulation = true; if (g_Settings->LoadBool(GameRunning_CPU_Paused)) { - SetEvent(m_hPauseEvent); + m_hPauseEvent.Trigger(); } if (GetCurrentThreadId() == m_CPU_ThreadID) @@ -474,12 +474,12 @@ void CN64System::Pause() { return; } - ResetEvent(m_hPauseEvent); + m_hPauseEvent.Reset(); g_Settings->SaveBool(GameRunning_CPU_Paused, true); Notify().RefreshMenu(); g_Notify->DisplayMessage(5, MSG_CPU_PAUSED); - WaitForSingleObject(m_hPauseEvent, INFINITE); - ResetEvent(m_hPauseEvent); + m_hPauseEvent.IsTriggered(SyncEvent::INFINITE_TIMEOUT); + m_hPauseEvent.Reset(); g_Settings->SaveBool(GameRunning_CPU_Paused, (DWORD)false); Notify().RefreshMenu(); Notify().DisplayMessage(5, MSG_CPU_RESUMED); @@ -946,12 +946,6 @@ void CN64System::CpuStopped() Notify().WindowMode(); if (!m_InReset) { - if (m_hPauseEvent) - { - CloseHandle(m_hPauseEvent); - m_hPauseEvent = NULL; - } - Notify().RefreshMenu(); Notify().MakeWindowOnTop(false); g_Notify->DisplayMessage(5, MSG_EMULATION_ENDED); diff --git a/Source/Project64/N64 System/N64 Class.h b/Source/Project64/N64 System/N64 Class.h index 123fa1e64..95b6d6606 100644 --- a/Source/Project64/N64 System/N64 Class.h +++ b/Source/Project64/N64 System/N64 Class.h @@ -10,6 +10,8 @@ ****************************************************************************/ #pragma once +#include + typedef std::list EVENT_LIST; typedef std::map FUNC_CALLS; From efa3c87de720e6db4be5e5ede1708a0021827103 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 12 Nov 2015 19:43:32 +1100 Subject: [PATCH 138/213] {Project64] Tabs to spaces in Plugin List.cpp --- Source/Project64/Plugins/Plugin List.cpp | 211 +++++++++++------------ Source/Project64/Plugins/Plugin List.h | 50 ++++-- 2 files changed, 136 insertions(+), 125 deletions(-) diff --git a/Source/Project64/Plugins/Plugin List.cpp b/Source/Project64/Plugins/Plugin List.cpp index 244492e76..725ad27a7 100644 --- a/Source/Project64/Plugins/Plugin List.cpp +++ b/Source/Project64/Plugins/Plugin List.cpp @@ -12,12 +12,12 @@ #include CPluginList::CPluginList(bool bAutoFill /* = true */) : - m_PluginDir(g_Settings->LoadStringVal(Directory_Plugin),"") +m_PluginDir(g_Settings->LoadStringVal(Directory_Plugin), "") { - if (bAutoFill) - { - LoadList(); - } + if (bAutoFill) + { + LoadList(); + } } CPluginList::~CPluginList() @@ -26,123 +26,122 @@ CPluginList::~CPluginList() int CPluginList::GetPluginCount() const { - return m_PluginList.size(); + return m_PluginList.size(); } -const CPluginList::PLUGIN * CPluginList::GetPluginInfo ( int indx ) const +const CPluginList::PLUGIN * CPluginList::GetPluginInfo(int indx) const { - if (indx < 0 || indx >= (int)m_PluginList.size()) - { - return NULL; - } - return &m_PluginList[indx]; - + if (indx < 0 || indx >= (int)m_PluginList.size()) + { + return NULL; + } + return &m_PluginList[indx]; } bool CPluginList::LoadList() { - WriteTrace(TraceDebug,__FUNCTION__ ": Start"); - m_PluginList.clear(); - AddPluginFromDir(m_PluginDir); - WriteTrace(TraceDebug,__FUNCTION__ ": Done"); - return true; + WriteTrace(TraceDebug, __FUNCTION__ ": Start"); + m_PluginList.clear(); + AddPluginFromDir(m_PluginDir); + WriteTrace(TraceDebug, __FUNCTION__ ": Done"); + return true; } -void CPluginList::AddPluginFromDir ( CPath Dir) +void CPluginList::AddPluginFromDir(CPath Dir) { - Dir.SetNameExtension("*.*"); - if (Dir.FindFirst(_A_SUBDIR)) - { - do { - AddPluginFromDir(Dir); - } while (Dir.FindNext()); - Dir.UpDirectory(); - } + Dir.SetNameExtension("*.*"); + if (Dir.FindFirst(_A_SUBDIR)) + { + do { + AddPluginFromDir(Dir); + } while (Dir.FindNext()); + Dir.UpDirectory(); + } - Dir.SetNameExtension("*.dll"); - if (Dir.FindFirst()) - { - HMODULE hLib = NULL; - do { - if (hLib) - { - FreeLibrary(hLib); - hLib = NULL; - } + Dir.SetNameExtension("*.dll"); + if (Dir.FindFirst()) + { + HMODULE hLib = NULL; + do { + if (hLib) + { + FreeLibrary(hLib); + hLib = NULL; + } - //UINT LastErrorMode = SetErrorMode( SEM_FAILCRITICALERRORS ); - WriteTraceF(TraceDebug,__FUNCTION__ ": loading %s",(LPCSTR)Dir); - hLib = LoadLibrary(Dir); - //SetErrorMode(LastErrorMode); + //UINT LastErrorMode = SetErrorMode( SEM_FAILCRITICALERRORS ); + WriteTraceF(TraceDebug, __FUNCTION__ ": loading %s", (LPCSTR)Dir); + hLib = LoadLibrary(Dir); + //SetErrorMode(LastErrorMode); - if (hLib == NULL) - { - DWORD LoadError = GetLastError(); - WriteTraceF(TraceDebug, __FUNCTION__ ": failed to loadi %s (error: %d)", (LPCSTR)Dir, LoadError); - continue; - } + if (hLib == NULL) + { + DWORD LoadError = GetLastError(); + WriteTraceF(TraceDebug, __FUNCTION__ ": failed to loadi %s (error: %d)", (LPCSTR)Dir, LoadError); + continue; + } - void (__cdecl *GetDllInfo) ( PLUGIN_INFO * PluginInfo ); - GetDllInfo = (void (__cdecl *)(PLUGIN_INFO *))GetProcAddress( hLib, "GetDllInfo" ); - if (GetDllInfo == NULL) - { - continue; - } - - PLUGIN Plugin = { 0 }; - Plugin.Info.MemoryBswaped = true; - GetDllInfo(&Plugin.Info); - if (!ValidPluginVersion(Plugin.Info)) - { - continue; - } + void(__cdecl *GetDllInfo) (PLUGIN_INFO * PluginInfo); + GetDllInfo = (void(__cdecl *)(PLUGIN_INFO *))GetProcAddress(hLib, "GetDllInfo"); + if (GetDllInfo == NULL) + { + continue; + } - Plugin.FullPath = Dir; - std::string& fullPath = Dir; - std::string& pluginPath = m_PluginDir; - Plugin.FileName = fullPath.substr(pluginPath.length()); + PLUGIN Plugin = { 0 }; + Plugin.Info.MemoryBswaped = true; + GetDllInfo(&Plugin.Info); + if (!ValidPluginVersion(Plugin.Info)) + { + continue; + } - if (GetProcAddress(hLib,"DllAbout") != NULL) - { - Plugin.AboutFunction = true; - } - m_PluginList.push_back(Plugin); - } while (Dir.FindNext()); + Plugin.FullPath = Dir; + std::string& fullPath = Dir; + std::string& pluginPath = m_PluginDir; + Plugin.FileName = fullPath.substr(pluginPath.length()); - if (hLib) - { - FreeLibrary(hLib); - hLib = NULL; - } - } + if (GetProcAddress(hLib, "DllAbout") != NULL) + { + Plugin.AboutFunction = true; + } + m_PluginList.push_back(Plugin); + } while (Dir.FindNext()); + + if (hLib) + { + FreeLibrary(hLib); + hLib = NULL; + } + } } -bool CPluginList::ValidPluginVersion ( PLUGIN_INFO & PluginInfo ) { - switch (PluginInfo.Type) - { - case PLUGIN_TYPE_RSP: - if (!PluginInfo.MemoryBswaped) { return false; } - if (PluginInfo.Version == 0x0001) { return true; } - if (PluginInfo.Version == 0x0100) { return true; } - if (PluginInfo.Version == 0x0101) { return true; } - if (PluginInfo.Version == 0x0102) { return true; } - break; - case PLUGIN_TYPE_GFX: - if (!PluginInfo.MemoryBswaped) { return false; } - if (PluginInfo.Version == 0x0102) { return true; } - if (PluginInfo.Version == 0x0103) { return true; } - if (PluginInfo.Version == 0x0104) { return true; } - break; - case PLUGIN_TYPE_AUDIO: - if (!PluginInfo.MemoryBswaped) { return false; } - if (PluginInfo.Version == 0x0101) { return true; } - if (PluginInfo.Version == 0x0102) { return true; } - break; - case PLUGIN_TYPE_CONTROLLER: - if (PluginInfo.Version == 0x0100) { return true; } - if (PluginInfo.Version == 0x0101) { return true; } - if (PluginInfo.Version == 0x0102) { return true; } - break; - } - return FALSE; -} +bool CPluginList::ValidPluginVersion(PLUGIN_INFO & PluginInfo) { + switch (PluginInfo.Type) + { + case PLUGIN_TYPE_RSP: + if (!PluginInfo.MemoryBswaped) { return false; } + if (PluginInfo.Version == 0x0001) { return true; } + if (PluginInfo.Version == 0x0100) { return true; } + if (PluginInfo.Version == 0x0101) { return true; } + if (PluginInfo.Version == 0x0102) { return true; } + break; + case PLUGIN_TYPE_GFX: + if (!PluginInfo.MemoryBswaped) { return false; } + if (PluginInfo.Version == 0x0102) { return true; } + if (PluginInfo.Version == 0x0103) { return true; } + if (PluginInfo.Version == 0x0104) { return true; } + break; + case PLUGIN_TYPE_AUDIO: + if (!PluginInfo.MemoryBswaped) { return false; } + if (PluginInfo.Version == 0x0101) { return true; } + if (PluginInfo.Version == 0x0102) { return true; } + break; + case PLUGIN_TYPE_CONTROLLER: + if (PluginInfo.Version == 0x0100) { return true; } + if (PluginInfo.Version == 0x0101) { return true; } + if (PluginInfo.Version == 0x0102) { return true; } + break; + } + return FALSE; +} \ No newline at end of file diff --git a/Source/Project64/Plugins/Plugin List.h b/Source/Project64/Plugins/Plugin List.h index 17edd39c3..ae67c6805 100644 --- a/Source/Project64/Plugins/Plugin List.h +++ b/Source/Project64/Plugins/Plugin List.h @@ -1,30 +1,42 @@ -#include "..\\Settings.h" +/**************************************************************************** +* * +* Project64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2012 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +#pragma once -class CPluginList +#include + +class CPluginList { public: - typedef struct - { - PLUGIN_INFO Info; - bool AboutFunction; - CPath FullPath; - stdstr FileName; - } PLUGIN; + typedef struct + { + PLUGIN_INFO Info; + bool AboutFunction; + CPath FullPath; + stdstr FileName; + } PLUGIN; public: - CPluginList(bool bAutoFill = true); - ~CPluginList(); + CPluginList(bool bAutoFill = true); + ~CPluginList(); - bool LoadList ( void ); - int GetPluginCount ( void ) const; - const PLUGIN * GetPluginInfo ( int indx ) const; - static bool ValidPluginVersion ( PLUGIN_INFO & PluginInfo ); + bool LoadList(void); + int GetPluginCount(void) const; + const PLUGIN * GetPluginInfo(int indx) const; + static bool ValidPluginVersion(PLUGIN_INFO & PluginInfo); private: - typedef std::vector PluginList; + typedef std::vector PluginList; - PluginList m_PluginList; - CPath m_PluginDir; + PluginList m_PluginList; + CPath m_PluginDir; - void AddPluginFromDir(CPath Dir); + void AddPluginFromDir(CPath Dir); }; From 69383fcc7e80fcca8fb071302b122a4291c09b26 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 12 Nov 2015 20:15:49 +1100 Subject: [PATCH 139/213] [Project64] remove ValidPluginVersion from Plugin List.cpp --- Source/Project64/Plugins/Plugin List.cpp | 38 +++--------------------- Source/Project64/Plugins/Plugin List.h | 3 +- 2 files changed, 5 insertions(+), 36 deletions(-) diff --git a/Source/Project64/Plugins/Plugin List.cpp b/Source/Project64/Plugins/Plugin List.cpp index 725ad27a7..73aaa4f52 100644 --- a/Source/Project64/Plugins/Plugin List.cpp +++ b/Source/Project64/Plugins/Plugin List.cpp @@ -10,6 +10,8 @@ ****************************************************************************/ #include "stdafx.h" #include +#include "Plugin List.h" +#include CPluginList::CPluginList(bool bAutoFill /* = true */) : m_PluginDir(g_Settings->LoadStringVal(Directory_Plugin), "") @@ -91,15 +93,13 @@ void CPluginList::AddPluginFromDir(CPath Dir) PLUGIN Plugin = { 0 }; Plugin.Info.MemoryBswaped = true; GetDllInfo(&Plugin.Info); - if (!ValidPluginVersion(Plugin.Info)) + if (!CPlugin::ValidPluginVersion(Plugin.Info)) { continue; } Plugin.FullPath = Dir; - std::string& fullPath = Dir; - std::string& pluginPath = m_PluginDir; - Plugin.FileName = fullPath.substr(pluginPath.length()); + Plugin.FileName = stdstr((const char *)Dir).substr(strlen(m_PluginDir)); if (GetProcAddress(hLib, "DllAbout") != NULL) { @@ -115,33 +115,3 @@ void CPluginList::AddPluginFromDir(CPath Dir) } } } - -bool CPluginList::ValidPluginVersion(PLUGIN_INFO & PluginInfo) { - switch (PluginInfo.Type) - { - case PLUGIN_TYPE_RSP: - if (!PluginInfo.MemoryBswaped) { return false; } - if (PluginInfo.Version == 0x0001) { return true; } - if (PluginInfo.Version == 0x0100) { return true; } - if (PluginInfo.Version == 0x0101) { return true; } - if (PluginInfo.Version == 0x0102) { return true; } - break; - case PLUGIN_TYPE_GFX: - if (!PluginInfo.MemoryBswaped) { return false; } - if (PluginInfo.Version == 0x0102) { return true; } - if (PluginInfo.Version == 0x0103) { return true; } - if (PluginInfo.Version == 0x0104) { return true; } - break; - case PLUGIN_TYPE_AUDIO: - if (!PluginInfo.MemoryBswaped) { return false; } - if (PluginInfo.Version == 0x0101) { return true; } - if (PluginInfo.Version == 0x0102) { return true; } - break; - case PLUGIN_TYPE_CONTROLLER: - if (PluginInfo.Version == 0x0100) { return true; } - if (PluginInfo.Version == 0x0101) { return true; } - if (PluginInfo.Version == 0x0102) { return true; } - break; - } - return FALSE; -} \ No newline at end of file diff --git a/Source/Project64/Plugins/Plugin List.h b/Source/Project64/Plugins/Plugin List.h index ae67c6805..f1ee46064 100644 --- a/Source/Project64/Plugins/Plugin List.h +++ b/Source/Project64/Plugins/Plugin List.h @@ -10,7 +10,7 @@ ****************************************************************************/ #pragma once -#include +#include class CPluginList { @@ -30,7 +30,6 @@ public: bool LoadList(void); int GetPluginCount(void) const; const PLUGIN * GetPluginInfo(int indx) const; - static bool ValidPluginVersion(PLUGIN_INFO & PluginInfo); private: typedef std::vector PluginList; From 93c76fe7dc78fd855ee7f21c3cfa4dc49a099ff4 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 12 Nov 2015 21:08:47 +1100 Subject: [PATCH 140/213] [Project64] Create RenderWindow interface --- Source/Project64/N64 System/N64 Class.cpp | 27 +- Source/Project64/N64 System/N64 Class.h | 1 - Source/Project64/Plugins/Audio Plugin.cpp | 4 +- Source/Project64/Plugins/Audio Plugin.h | 3 +- .../Project64/Plugins/Controller Plugin.cpp | 6 +- Source/Project64/Plugins/Controller Plugin.h | 3 +- Source/Project64/Plugins/GFX plugin.cpp | 6 +- Source/Project64/Plugins/GFX plugin.h | 3 +- Source/Project64/Plugins/Plugin Class.cpp | 30 +- Source/Project64/Plugins/Plugin Class.h | 18 +- Source/Project64/User Interface/Gui Class.cpp | 1743 ++++++++--------- Source/Project64/User Interface/Gui Class.h | 7 +- .../User Interface/Notification Class.cpp | 515 +++-- 13 files changed, 1177 insertions(+), 1189 deletions(-) diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index 70955bda8..b222b9958 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -22,7 +22,6 @@ m_SaveUsing((SAVE_CHIP_TYPE)g_Settings->LoadDword(Game_SaveChip)), m_Plugins(Plugins), m_SyncCPU(NULL), m_SyncPlugins(NULL), -m_SyncWindow(NULL), m_MMU_VM(this, SavesReadOnly), m_TLB(this), m_Reg(this, this), @@ -75,11 +74,6 @@ CN64System::~CN64System() delete m_SyncPlugins; m_SyncPlugins = NULL; } - if (m_SyncWindow) - { - delete m_SyncWindow; - m_SyncWindow = NULL; - } } void CN64System::ExternalEvent(SystemEvent action) @@ -269,10 +263,7 @@ bool CN64System::EmulationStarting(HANDLE hThread, DWORD ThreadId) } catch (...) { - WriteTraceF(TraceError, __FUNCTION__ ": Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__); - char Message[600]; - sprintf(Message, __FUNCTION__ ": Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__); - MessageBox(NULL, Message, "Exception", MB_OK); + g_Notify->DisplayError(stdstr_f(__FUNCTION__ ": Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__).ToUTF16().c_str()); } } else @@ -313,17 +304,15 @@ void CN64System::StartEmulation2(bool NewThread) if (CpuType == CPU_SyncCores) { + if (g_Plugins->SyncWindow() == NULL) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } g_Notify->DisplayMessage(5, L"Copy Plugins"); g_Plugins->CopyPlugins(g_Settings->LoadStringVal(Directory_PluginSync)); -#if defined(WINDOWS_UI) - m_SyncWindow = new CMainGui(false); m_SyncPlugins = new CPlugins(g_Settings->LoadStringVal(Directory_PluginSync)); - m_SyncPlugins->SetRenderWindows(m_SyncWindow, m_SyncWindow); - + m_SyncPlugins->SetRenderWindows(g_Plugins->SyncWindow(), NULL); m_SyncCPU = new CN64System(m_SyncPlugins, true); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); -#endif } if (CpuType == CPU_Recompiler || CpuType == CPU_SyncCores) @@ -1158,7 +1147,7 @@ void CN64System::DumpSyncErrors(CN64System * SecondCPU) Error.Log("Register, Recompiler, Interpter\r\n"); #ifdef TEST_SP_TRACKING if (m_CurrentSP != GPR[29].UW[0]) { - Error.Log("m_CurrentSP,%X,%X\r\n",m_CurrentSP,GPR[29].UW[0]); + Error.Log("m_CurrentSP,%X,%X\r\n", m_CurrentSP, GPR[29].UW[0]); } #endif if (m_Reg.m_PROGRAM_COUNTER != SecondCPU->m_Reg.m_PROGRAM_COUNTER) { @@ -2058,7 +2047,7 @@ bool CN64System::WriteToProtectedMemory(uint32_t Address, int length) { g_Notify->BreakPoint(__FILEW__, __LINE__); #ifdef tofix - return m_Recomp->ClearRecompCode_Phys(Address,length,CRecompiler::Remove_ProtectedMem); + return m_Recomp->ClearRecompCode_Phys(Address, length, CRecompiler::Remove_ProtectedMem); #endif } return false; diff --git a/Source/Project64/N64 System/N64 Class.h b/Source/Project64/N64 System/N64 Class.h index 95b6d6606..b703e1861 100644 --- a/Source/Project64/N64 System/N64 Class.h +++ b/Source/Project64/N64 System/N64 Class.h @@ -123,7 +123,6 @@ private: CPlugins * const m_Plugins; //The plugin container CN64System * m_SyncCPU; CPlugins * m_SyncPlugins; - CMainGui * m_SyncWindow; CMipsMemoryVM m_MMU_VM; //Memory of the n64 CTLB m_TLB; CRegisters m_Reg; diff --git a/Source/Project64/Plugins/Audio Plugin.cpp b/Source/Project64/Plugins/Audio Plugin.cpp index 618fcee12..2d229cfee 100644 --- a/Source/Project64/Plugins/Audio Plugin.cpp +++ b/Source/Project64/Plugins/Audio Plugin.cpp @@ -51,7 +51,7 @@ bool CAudioPlugin::LoadFunctions(void) return true; } -bool CAudioPlugin::Initiate(CN64System * System, CMainGui * RenderWindow) +bool CAudioPlugin::Initiate(CN64System * System, RenderWindow * Window) { struct AUDIO_INFO { @@ -88,7 +88,7 @@ bool CAudioPlugin::Initiate(CN64System * System, CMainGui * RenderWindow) AUDIO_INFO Info = { 0 }; - Info.hwnd = (HWND)RenderWindow->m_hMainWindow;; + Info.hwnd = (HWND)Window->GetWindowHandle(); Info.hinst = GetModuleHandle(NULL); Info.MemoryBswaped = TRUE; Info.CheckInterrupts = DummyCheckInterrupts; diff --git a/Source/Project64/Plugins/Audio Plugin.h b/Source/Project64/Plugins/Audio Plugin.h index bd53392d4..1890986f5 100644 --- a/Source/Project64/Plugins/Audio Plugin.h +++ b/Source/Project64/Plugins/Audio Plugin.h @@ -9,6 +9,7 @@ * * ****************************************************************************/ #pragma once +#include "Plugin Base.h" class CAudioPlugin : public CPlugin { @@ -17,7 +18,7 @@ public: ~CAudioPlugin(); void DacrateChanged(SYSTEM_TYPE Type); - bool Initiate(CN64System * System, CMainGui * RenderWindow); + bool Initiate(CN64System * System, RenderWindow * Window); void(__cdecl *AiLenChanged)(void); uint32_t(__cdecl *AiReadLength)(void); diff --git a/Source/Project64/Plugins/Controller Plugin.cpp b/Source/Project64/Plugins/Controller Plugin.cpp index dc0810b0d..35bb21f6c 100644 --- a/Source/Project64/Plugins/Controller Plugin.cpp +++ b/Source/Project64/Plugins/Controller Plugin.cpp @@ -58,7 +58,7 @@ bool CControl_Plugin::LoadFunctions(void) return true; } -bool CControl_Plugin::Initiate(CN64System * System, CMainGui * RenderWindow) +bool CControl_Plugin::Initiate(CN64System * System, RenderWindow * Window) { for (int32_t i = 0; i < 4; i++) { @@ -74,7 +74,7 @@ bool CControl_Plugin::Initiate(CN64System * System, CMainGui * RenderWindow) void(__cdecl *InitiateControllers_1_0)(HWND hMainWindow, CONTROL Controls[4]); InitiateControllers_1_0 = (void(__cdecl *)(HWND, CONTROL *))GetProcAddress((HMODULE)m_hDll, "InitiateControllers"); if (InitiateControllers_1_0 == NULL) { return false; } - InitiateControllers_1_0((HWND)RenderWindow->m_hMainWindow,m_PluginControllers); + InitiateControllers_1_0((HWND)Window->GetWindowHandle(),m_PluginControllers); m_Initialized = true; } else if (m_PluginInfo.Version >= 0x0101) @@ -104,7 +104,7 @@ bool CControl_Plugin::Initiate(CN64System * System, CMainGui * RenderWindow) ControlInfo.Controls = m_PluginControllers; ControlInfo.HEADER = (System == NULL ? Buffer : g_Rom->GetRomAddress()); ControlInfo.hinst = GetModuleHandle(NULL); - ControlInfo.hMainWindow = (HWND)RenderWindow->m_hMainWindow; + ControlInfo.hMainWindow = (HWND)Window->GetWindowHandle(); ControlInfo.MemoryBswaped = TRUE; InitiateControllers_1_1(&ControlInfo); diff --git a/Source/Project64/Plugins/Controller Plugin.h b/Source/Project64/Plugins/Controller Plugin.h index 5ac28657e..2613fbdb1 100644 --- a/Source/Project64/Plugins/Controller Plugin.h +++ b/Source/Project64/Plugins/Controller Plugin.h @@ -9,6 +9,7 @@ * * ****************************************************************************/ #pragma once +#include "Plugin Base.h" #pragma warning(push) #pragma warning(disable : 4201) // warning C4201: nonstandard extension used : nameless struct/union @@ -87,7 +88,7 @@ public: CControl_Plugin(void); ~CControl_Plugin(); - bool Initiate(CN64System * System, CMainGui * RenderWindow); + bool Initiate(CN64System * System, RenderWindow * Window); void SetControl(CControl_Plugin const * const Plugin); void UpdateKeys(void); diff --git a/Source/Project64/Plugins/GFX plugin.cpp b/Source/Project64/Plugins/GFX plugin.cpp index b08397a3f..199f716b9 100644 --- a/Source/Project64/Plugins/GFX plugin.cpp +++ b/Source/Project64/Plugins/GFX plugin.cpp @@ -93,7 +93,7 @@ bool CGfxPlugin::LoadFunctions(void) return true; } -bool CGfxPlugin::Initiate(CN64System * System, CMainGui * RenderWindow) +bool CGfxPlugin::Initiate(CN64System * System, RenderWindow * Window) { if (m_Initialized) { @@ -153,8 +153,8 @@ bool CGfxPlugin::Initiate(CN64System * System, CMainGui * RenderWindow) GFX_INFO Info = { 0 }; Info.MemoryBswaped = TRUE; - Info.hWnd = (HWND)RenderWindow->m_hMainWindow; - Info.hStatusBar = (HWND)RenderWindow->m_hStatusWnd; + Info.hWnd = (HWND)Window->GetWindowHandle(); + Info.hStatusBar = (HWND)Window->GetStatusBar(); Info.CheckInterrupts = DummyCheckInterrupts; // We are initializing the plugin before any rom is loaded so we do not have any correct diff --git a/Source/Project64/Plugins/GFX plugin.h b/Source/Project64/Plugins/GFX plugin.h index 8f5f7a4d4..7deb1dc6c 100644 --- a/Source/Project64/Plugins/GFX plugin.h +++ b/Source/Project64/Plugins/GFX plugin.h @@ -9,6 +9,7 @@ * * ****************************************************************************/ #pragma once +#include "Plugin Base.h" class CGfxPlugin : public CPlugin { @@ -52,7 +53,7 @@ public: ~CGfxPlugin(); bool LoadFunctions(void); - bool Initiate(CN64System * System, CMainGui * RenderWindow); + bool Initiate(CN64System * System, RenderWindow * Window); void(__cdecl *CaptureScreen) (const char *); void(__cdecl *ChangeWindow) (void); diff --git a/Source/Project64/Plugins/Plugin Class.cpp b/Source/Project64/Plugins/Plugin Class.cpp index 30a5d291d..e614eed90 100644 --- a/Source/Project64/Plugins/Plugin Class.cpp +++ b/Source/Project64/Plugins/Plugin Class.cpp @@ -9,9 +9,12 @@ * * ****************************************************************************/ #include "stdafx.h" +#include +#include "Plugin Class.h" CPlugins::CPlugins(const stdstr & PluginDir) : - m_RenderWindow(NULL), m_DummyWindow(NULL), +m_MainWindow(NULL), +m_SyncWindow(NULL), m_PluginDir(PluginDir), m_Gfx(NULL), m_Audio(NULL), @@ -215,10 +218,10 @@ void CPlugins::DestroyControlPlugin(void) // g_Settings->UnknownSetting_CTRL = NULL; } -void CPlugins::SetRenderWindows( CMainGui * RenderWindow, CMainGui * DummyWindow ) +void CPlugins::SetRenderWindows(RenderWindow * MainWindow, RenderWindow * SyncWindow) { - m_RenderWindow = RenderWindow; - m_DummyWindow = DummyWindow; + m_MainWindow = MainWindow; + m_SyncWindow = SyncWindow; } void CPlugins::RomOpened(void) @@ -247,13 +250,13 @@ bool CPlugins::Initiate(CN64System * System) if (m_Control == NULL) { return false; } WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Starting"); - if (!m_Gfx->Initiate(System,m_RenderWindow)) { return false; } + if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; } WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Done"); WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Starting"); - if (!m_Audio->Initiate(System,m_RenderWindow)) { return false; } + if (!m_Audio->Initiate(System, m_MainWindow)) { return false; } WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Done"); WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Starting"); - if (!m_Control->Initiate(System,m_RenderWindow)) { return false; } + if (!m_Control->Initiate(System, m_MainWindow)) { return false; } WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Done"); WriteTrace(TraceRSP, __FUNCTION__ ": RSP Initiate Starting"); if (!m_RSP->Initiate(this, System)) { return false; } @@ -264,12 +267,7 @@ bool CPlugins::Initiate(CN64System * System) bool CPlugins::ResetInUiThread(CN64System * System) { -#if defined(WINDOWS_UI) - return m_RenderWindow->ResetPlugins(this, System); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); - return false; -#endif + return m_MainWindow->ResetPluginsInUiThread(this, System); } bool CPlugins::Reset(CN64System * System) @@ -295,19 +293,19 @@ bool CPlugins::Reset(CN64System * System) if (m_Gfx && bGfxChange) { WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Starting"); - if (!m_Gfx->Initiate(System,m_RenderWindow)) { return false; } + if (!m_Gfx->Initiate(System, m_MainWindow)) { return false; } WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Gfx Initiate Done"); } if (m_Audio && bAudioChange) { WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Starting"); - if (!m_Audio->Initiate(System,m_RenderWindow)) { return false; } + if (!m_Audio->Initiate(System, m_MainWindow)) { return false; } WriteTrace(TraceDebug, __FUNCTION__ ": Audio Initiate Done"); } if (m_Control && bContChange) { WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Starting"); - if (!m_Control->Initiate(System,m_RenderWindow)) { return false; } + if (!m_Control->Initiate(System, m_MainWindow)) { return false; } WriteTrace(TraceDebug, __FUNCTION__ ": Control Initiate Done"); } if (m_RSP && bRspChange) diff --git a/Source/Project64/Plugins/Plugin Class.h b/Source/Project64/Plugins/Plugin Class.h index 21c761293..f0acbc5de 100644 --- a/Source/Project64/Plugins/Plugin Class.h +++ b/Source/Project64/Plugins/Plugin Class.h @@ -81,8 +81,16 @@ enum PLUGIN_TYPE }; class CSettings; -class CMainGui; class CGfxPlugin; class CAudioPlugin; class CRSP_Plugin; class CControl_Plugin; +class CN64System; +class CPlugins; + +__interface RenderWindow +{ + bool ResetPluginsInUiThread(CPlugins * plugins, CN64System * System) = 0; + void * GetWindowHandle(void) const = 0; + void * GetStatusBar(void) const = 0; +}; class CPlugins : private CDebugSettings @@ -95,7 +103,7 @@ public: bool Initiate(CN64System * System); void RomOpened(void); void RomClosed(void); - void SetRenderWindows ( CMainGui * RenderWindow, CMainGui * DummyWindow ); + void SetRenderWindows(RenderWindow * MainWindow, RenderWindow * SyncWindow); void ConfigPlugin(uint32_t hParent, PLUGIN_TYPE Type); bool CopyPlugins(const stdstr & DstDir) const; void CreatePlugins(void); @@ -108,6 +116,8 @@ public: inline CRSP_Plugin * RSP(void) const { return m_RSP; } inline CControl_Plugin * Control(void) const { return m_Control; } + inline RenderWindow * MainWindow(void) const { return m_MainWindow; } + inline RenderWindow * SyncWindow(void) const { return m_SyncWindow; } private: CPlugins(void); // Disable default constructor @@ -121,8 +131,8 @@ private: static void PluginChanged(CPlugins * _this); - CMainGui * m_RenderWindow; - CMainGui * m_DummyWindow; + RenderWindow * m_MainWindow; + RenderWindow * m_SyncWindow; stdstr const m_PluginDir; diff --git a/Source/Project64/User Interface/Gui Class.cpp b/Source/Project64/User Interface/Gui Class.cpp index f1ba42901..ee2394dbb 100644 --- a/Source/Project64/User Interface/Gui Class.cpp +++ b/Source/Project64/User Interface/Gui Class.cpp @@ -32,1072 +32,1071 @@ m_MakingVisible(false), m_ResetPlugins(false), m_ResetInfo(NULL) { - m_Menu = NULL; + m_Menu = NULL; - m_hMainWindow = 0; - m_hStatusWnd = 0; - m_SaveMainWindowPos = false; - m_SaveMainWindowTop = 0; - m_SaveMainWindowLeft = 0; + m_hMainWindow = 0; + m_hStatusWnd = 0; + m_SaveMainWindowPos = false; + m_SaveMainWindowTop = 0; + m_SaveMainWindowLeft = 0; - m_SaveRomBrowserPos = false; - m_SaveRomBrowserTop = 0; - m_SaveRomBrowserLeft = 0; + m_SaveRomBrowserPos = false; + m_SaveRomBrowserTop = 0; + m_SaveRomBrowserLeft = 0; - if (m_bMainWindow) - { - g_Settings->RegisterChangeCB(RomBrowser_Enabled, this, (CSettings::SettingChangedFunc)RomBowserEnabledChanged); - g_Settings->RegisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); - g_Settings->RegisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); - } + if (m_bMainWindow) + { + g_Settings->RegisterChangeCB(RomBrowser_Enabled, this, (CSettings::SettingChangedFunc)RomBowserEnabledChanged); + g_Settings->RegisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); + g_Settings->RegisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); + } - //if this fails then it has already been created - RegisterWinClass(); - Create(WindowTitle); + //if this fails then it has already been created + RegisterWinClass(); + Create(WindowTitle); } CMainGui::~CMainGui(void) { - WriteTrace(TraceDebug, __FUNCTION__ ": Start"); - if (m_bMainWindow) - { - g_Settings->UnregisterChangeCB(RomBrowser_Enabled, this, (CSettings::SettingChangedFunc)RomBowserEnabledChanged); - g_Settings->UnregisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); - g_Settings->UnregisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); - } - if (m_hMainWindow) - { - DestroyWindow(m_hMainWindow); - } - WriteTrace(TraceDebug, __FUNCTION__ ": Done"); + WriteTrace(TraceDebug, __FUNCTION__ ": Start"); + if (m_bMainWindow) + { + g_Settings->UnregisterChangeCB(RomBrowser_Enabled, this, (CSettings::SettingChangedFunc)RomBowserEnabledChanged); + g_Settings->UnregisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); + g_Settings->UnregisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); + } + if (m_hMainWindow) + { + DestroyWindow(m_hMainWindow); + } + WriteTrace(TraceDebug, __FUNCTION__ ": Done"); } bool CMainGui::RegisterWinClass(void) { - stdstr_f VersionDisplay("Project64 %s", VER_FILE_VERSION_STR); + stdstr_f VersionDisplay("Project64 %s", VER_FILE_VERSION_STR); - WNDCLASS wcl; + WNDCLASS wcl; - wcl.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; - wcl.cbClsExtra = 0; - wcl.cbWndExtra = 0; - wcl.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_PJ64_Icon)); - wcl.hCursor = LoadCursor(NULL, IDC_ARROW); - wcl.hInstance = GetModuleHandle(NULL); + wcl.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; + wcl.cbClsExtra = 0; + wcl.cbWndExtra = 0; + wcl.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_PJ64_Icon)); + wcl.hCursor = LoadCursor(NULL, IDC_ARROW); + wcl.hInstance = GetModuleHandle(NULL); - wcl.lpfnWndProc = (WNDPROC)MainGui_Proc; - wcl.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - wcl.lpszMenuName = NULL; - wcl.lpszClassName = VersionDisplay.c_str(); - if (RegisterClass(&wcl) == 0) return false; - return true; + wcl.lpfnWndProc = (WNDPROC)MainGui_Proc; + wcl.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); + wcl.lpszMenuName = NULL; + wcl.lpszClassName = VersionDisplay.c_str(); + if (RegisterClass(&wcl) == 0) return false; + return true; } - void RomBowserEnabledChanged(CMainGui * Gui) { - if (Gui && g_Settings->LoadBool(RomBrowser_Enabled)) - { - if (!Gui->RomBrowserVisible()) - { - Gui->ShowRomList(); - } - } - else - { - if (Gui->RomBrowserVisible()) - { - Gui->HideRomList(); - } - } + if (Gui && g_Settings->LoadBool(RomBrowser_Enabled)) + { + if (!Gui->RomBrowserVisible()) + { + Gui->ShowRomList(); + } + } + else + { + if (Gui->RomBrowserVisible()) + { + Gui->HideRomList(); + } + } } void RomBowserColoumnsChanged(CMainGui * Gui) { - Gui->ResetRomBrowserColomuns(); + Gui->ResetRomBrowserColomuns(); } void RomBrowserRecursiveChanged(CMainGui * Gui) { - Gui->RefreshRomBrowser(); - Gui->HighLightLastRom(); + Gui->RefreshRomBrowser(); + Gui->HighLightLastRom(); } void CMainGui::ChangeWinSize(long width, long height) { - CGuard Guard(m_CS); - WINDOWPLACEMENT wndpl; - RECT rc1, swrect; + CGuard Guard(m_CS); + WINDOWPLACEMENT wndpl; + RECT rc1, swrect; - wndpl.length = sizeof(wndpl); - GetWindowPlacement(m_hMainWindow, &wndpl); + wndpl.length = sizeof(wndpl); + GetWindowPlacement(m_hMainWindow, &wndpl); - if ((HWND)m_hStatusWnd != NULL) - { - GetClientRect((HWND)m_hStatusWnd, &swrect); - SetRect(&rc1, 0, 0, width, height + swrect.bottom); - } - else - { - SetRect(&rc1, 0, 0, width, height); - } + if ((HWND)m_hStatusWnd != NULL) + { + GetClientRect((HWND)m_hStatusWnd, &swrect); + SetRect(&rc1, 0, 0, width, height + swrect.bottom); + } + else + { + SetRect(&rc1, 0, 0, width, height); + } - AdjustWindowRectEx(&rc1, GetWindowLong(m_hMainWindow, GWL_STYLE), GetMenu(m_hMainWindow) != NULL, GetWindowLong(m_hMainWindow, GWL_EXSTYLE)); + AdjustWindowRectEx(&rc1, GetWindowLong(m_hMainWindow, GWL_STYLE), GetMenu(m_hMainWindow) != NULL, GetWindowLong(m_hMainWindow, GWL_EXSTYLE)); - MoveWindow(m_hMainWindow, wndpl.rcNormalPosition.left, wndpl.rcNormalPosition.top, rc1.right - rc1.left, rc1.bottom - rc1.top, TRUE); + MoveWindow(m_hMainWindow, wndpl.rcNormalPosition.left, wndpl.rcNormalPosition.top, rc1.right - rc1.left, rc1.bottom - rc1.top, TRUE); } void CMainGui::AboutBox(void) { - DialogBoxParamW(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_About), m_hMainWindow, (DLGPROC)AboutBoxProc, (LPARAM)this); + DialogBoxParamW(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_About), m_hMainWindow, (DLGPROC)AboutBoxProc, (LPARAM)this); } void CMainGui::AboutIniBox(void) { - DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_About_Ini), m_hMainWindow, (DLGPROC)AboutIniBoxProc,(LPARAM)this); + DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_About_Ini), m_hMainWindow, (DLGPROC)AboutIniBoxProc, (LPARAM)this); } DWORD CALLBACK AboutIniBoxProc(HWND hDlg, DWORD uMsg, DWORD wParam, DWORD /*lParam*/) { - static wchar_t RDBHomePage[300], CHTHomePage[300], RDXHomePage[300]; + static wchar_t RDBHomePage[300], CHTHomePage[300], RDXHomePage[300]; - switch (uMsg) { - case WM_INITDIALOG: - { - wchar_t String[200]; + switch (uMsg) { + case WM_INITDIALOG: + { + wchar_t String[200]; - //Title - LONG_PTR originalWndProc = GetWindowLongPtrW(hDlg, GWLP_WNDPROC); - SetWindowLongPtrW(hDlg, GWLP_WNDPROC, (LONG_PTR) DefWindowProcW); - SetWindowTextW(hDlg, GS(INI_TITLE)); - SetWindowLongPtrW(hDlg, GWLP_WNDPROC, originalWndProc); + //Title + LONG_PTR originalWndProc = GetWindowLongPtrW(hDlg, GWLP_WNDPROC); + SetWindowLongPtrW(hDlg, GWLP_WNDPROC, (LONG_PTR)DefWindowProcW); + SetWindowTextW(hDlg, GS(INI_TITLE)); + SetWindowLongPtrW(hDlg, GWLP_WNDPROC, originalWndProc); - //Language - SetDlgItemTextW(hDlg, IDC_LAN, GS(INI_CURRENT_LANG)); - set_about_field(hDlg, IDC_LAN_AUTHOR, GS(INI_AUTHOR), GS(LANGUAGE_AUTHOR)); - set_about_field(hDlg, IDC_LAN_VERSION, GS(INI_VERSION), GS(LANGUAGE_VERSION)); - set_about_field(hDlg, IDC_LAN_DATE, GS(INI_DATE), GS(LANGUAGE_DATE)); - if (wcslen(GS(LANGUAGE_NAME)) == 0) - { - EnableWindow(GetDlgItem(hDlg, IDC_LAN), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_LAN_AUTHOR), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_LAN_VERSION), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_LAN_DATE), FALSE); - } - //RDB - CIniFile RdbIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str()); - wcsncpy(String, RdbIniFile.GetString("Meta", "Author", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); - if (wcslen(String) == 0) - { - EnableWindow(GetDlgItem(hDlg, IDC_RDB), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_RDB_AUTHOR), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_RDB_VERSION), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_RDB_DATE), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_RDB_HOME), FALSE); - } + //Language + SetDlgItemTextW(hDlg, IDC_LAN, GS(INI_CURRENT_LANG)); + set_about_field(hDlg, IDC_LAN_AUTHOR, GS(INI_AUTHOR), GS(LANGUAGE_AUTHOR)); + set_about_field(hDlg, IDC_LAN_VERSION, GS(INI_VERSION), GS(LANGUAGE_VERSION)); + set_about_field(hDlg, IDC_LAN_DATE, GS(INI_DATE), GS(LANGUAGE_DATE)); + if (wcslen(GS(LANGUAGE_NAME)) == 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_LAN), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_LAN_AUTHOR), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_LAN_VERSION), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_LAN_DATE), FALSE); + } + //RDB + CIniFile RdbIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str()); + wcsncpy(String, RdbIniFile.GetString("Meta", "Author", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + if (wcslen(String) == 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_RDB), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDB_AUTHOR), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDB_VERSION), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDB_DATE), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDB_HOME), FALSE); + } - set_about_field(hDlg, IDC_RDB_AUTHOR, GS(INI_AUTHOR), String); + set_about_field(hDlg, IDC_RDB_AUTHOR, GS(INI_AUTHOR), String); - wcsncpy(String, RdbIniFile.GetString("Meta", "Version", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); - set_about_field(hDlg, IDC_RDB_VERSION, GS(INI_VERSION), String); - wcsncpy(String, RdbIniFile.GetString("Meta", "Date", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); - set_about_field(hDlg, IDC_RDB_DATE, GS(INI_DATE), String); - wcsncpy(RDBHomePage, RdbIniFile.GetString("Meta", "Homepage", "").ToUTF16().c_str(), sizeof(RDBHomePage) / sizeof(RDBHomePage[0])); - SetDlgItemTextW(hDlg, IDC_RDB_HOME, GS(INI_HOMEPAGE)); - if (wcslen(RDBHomePage) == 0) - { - EnableWindow(GetDlgItem(hDlg, IDC_RDB_HOME), FALSE); - } + wcsncpy(String, RdbIniFile.GetString("Meta", "Version", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + set_about_field(hDlg, IDC_RDB_VERSION, GS(INI_VERSION), String); + wcsncpy(String, RdbIniFile.GetString("Meta", "Date", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + set_about_field(hDlg, IDC_RDB_DATE, GS(INI_DATE), String); + wcsncpy(RDBHomePage, RdbIniFile.GetString("Meta", "Homepage", "").ToUTF16().c_str(), sizeof(RDBHomePage) / sizeof(RDBHomePage[0])); + SetDlgItemTextW(hDlg, IDC_RDB_HOME, GS(INI_HOMEPAGE)); + if (wcslen(RDBHomePage) == 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_RDB_HOME), FALSE); + } - //Cheat - SetDlgItemTextW(hDlg, IDC_CHT, GS(INI_CURRENT_CHT)); - CIniFile CheatIniFile(g_Settings->LoadStringVal(SupportFile_Cheats).c_str()); - wcsncpy(String, CheatIniFile.GetString("Meta", "Author", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); - if (wcslen(String) == 0) - { - EnableWindow(GetDlgItem(hDlg, IDC_CHT), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_CHT_AUTHOR), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_CHT_VERSION), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_CHT_DATE), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_CHT_HOME), FALSE); - } - set_about_field(hDlg, IDC_CHT_AUTHOR, GS(INI_AUTHOR), String); - wcsncpy(String, CheatIniFile.GetString("Meta", "Version", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); - set_about_field(hDlg, IDC_CHT_VERSION, GS(INI_VERSION), String); - wcsncpy(String, CheatIniFile.GetString("Meta", "Date", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); - set_about_field(hDlg, IDC_CHT_DATE, GS(INI_DATE), String); - wcsncpy(CHTHomePage, CheatIniFile.GetString("Meta", "Homepage", "").ToUTF16().c_str(), sizeof(CHTHomePage) / sizeof(CHTHomePage[0])); - SetDlgItemTextW(hDlg, IDC_CHT_HOME, GS(INI_HOMEPAGE)); - if (wcslen(CHTHomePage) == 0) - { - EnableWindow(GetDlgItem(hDlg, IDC_CHT_HOME), FALSE); - } + //Cheat + SetDlgItemTextW(hDlg, IDC_CHT, GS(INI_CURRENT_CHT)); + CIniFile CheatIniFile(g_Settings->LoadStringVal(SupportFile_Cheats).c_str()); + wcsncpy(String, CheatIniFile.GetString("Meta", "Author", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + if (wcslen(String) == 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_CHT), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_CHT_AUTHOR), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_CHT_VERSION), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_CHT_DATE), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_CHT_HOME), FALSE); + } + set_about_field(hDlg, IDC_CHT_AUTHOR, GS(INI_AUTHOR), String); + wcsncpy(String, CheatIniFile.GetString("Meta", "Version", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + set_about_field(hDlg, IDC_CHT_VERSION, GS(INI_VERSION), String); + wcsncpy(String, CheatIniFile.GetString("Meta", "Date", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + set_about_field(hDlg, IDC_CHT_DATE, GS(INI_DATE), String); + wcsncpy(CHTHomePage, CheatIniFile.GetString("Meta", "Homepage", "").ToUTF16().c_str(), sizeof(CHTHomePage) / sizeof(CHTHomePage[0])); + SetDlgItemTextW(hDlg, IDC_CHT_HOME, GS(INI_HOMEPAGE)); + if (wcslen(CHTHomePage) == 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_CHT_HOME), FALSE); + } - //Extended Info - SetDlgItemTextW(hDlg, IDC_RDX, GS(INI_CURRENT_RDX)); - CIniFile RdxIniFile(g_Settings->LoadStringVal(SupportFile_ExtInfo).c_str()); - wcsncpy(String, RdxIniFile.GetString("Meta", "Author", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); - if (wcslen(String) == 0) - { - EnableWindow(GetDlgItem(hDlg, IDC_RDX), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_RDX_AUTHOR), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_RDX_VERSION), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_RDX_DATE), FALSE); - EnableWindow(GetDlgItem(hDlg, IDC_RDX_HOME), FALSE); - } - set_about_field(hDlg, IDC_RDX_AUTHOR, GS(INI_AUTHOR), String); - wcsncpy(String, RdxIniFile.GetString("Meta", "Version", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); - set_about_field(hDlg, IDC_RDX_VERSION, GS(INI_VERSION), String); - wcsncpy(String, RdxIniFile.GetString("Meta", "Date", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); - set_about_field(hDlg, IDC_RDX_DATE, GS(INI_DATE), String); - wcsncpy(RDXHomePage, RdxIniFile.GetString("Meta", "Homepage", "").ToUTF16().c_str(), sizeof(RDXHomePage) / sizeof(RDXHomePage[0])); - SetDlgItemTextW(hDlg, IDC_RDX_HOME, GS(INI_HOMEPAGE)); - if (wcslen(RDXHomePage) == 0) - { - EnableWindow(GetDlgItem(hDlg, IDC_RDX_HOME), FALSE); - } - SetDlgItemTextW(hDlg, IDOK, GS(CHEAT_OK)); - } - break; - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDC_RDB_HOME: ShellExecuteW(NULL, L"open", RDBHomePage, NULL, NULL, SW_SHOWNORMAL); break; - case IDC_CHT_HOME: ShellExecuteW(NULL, L"open", CHTHomePage, NULL, NULL, SW_SHOWNORMAL); break; - case IDC_RDX_HOME: ShellExecuteW(NULL, L"open", RDXHomePage, NULL, NULL, SW_SHOWNORMAL); break; - case IDOK: - case IDCANCEL: - EndDialog(hDlg, 0); - break; - } - default: - return FALSE; - } - return TRUE; + //Extended Info + SetDlgItemTextW(hDlg, IDC_RDX, GS(INI_CURRENT_RDX)); + CIniFile RdxIniFile(g_Settings->LoadStringVal(SupportFile_ExtInfo).c_str()); + wcsncpy(String, RdxIniFile.GetString("Meta", "Author", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + if (wcslen(String) == 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_RDX), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDX_AUTHOR), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDX_VERSION), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDX_DATE), FALSE); + EnableWindow(GetDlgItem(hDlg, IDC_RDX_HOME), FALSE); + } + set_about_field(hDlg, IDC_RDX_AUTHOR, GS(INI_AUTHOR), String); + wcsncpy(String, RdxIniFile.GetString("Meta", "Version", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + set_about_field(hDlg, IDC_RDX_VERSION, GS(INI_VERSION), String); + wcsncpy(String, RdxIniFile.GetString("Meta", "Date", "").ToUTF16().c_str(), sizeof(String) / sizeof(String[0])); + set_about_field(hDlg, IDC_RDX_DATE, GS(INI_DATE), String); + wcsncpy(RDXHomePage, RdxIniFile.GetString("Meta", "Homepage", "").ToUTF16().c_str(), sizeof(RDXHomePage) / sizeof(RDXHomePage[0])); + SetDlgItemTextW(hDlg, IDC_RDX_HOME, GS(INI_HOMEPAGE)); + if (wcslen(RDXHomePage) == 0) + { + EnableWindow(GetDlgItem(hDlg, IDC_RDX_HOME), FALSE); + } + SetDlgItemTextW(hDlg, IDOK, GS(CHEAT_OK)); + } + break; + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDC_RDB_HOME: ShellExecuteW(NULL, L"open", RDBHomePage, NULL, NULL, SW_SHOWNORMAL); break; + case IDC_CHT_HOME: ShellExecuteW(NULL, L"open", CHTHomePage, NULL, NULL, SW_SHOWNORMAL); break; + case IDC_RDX_HOME: ShellExecuteW(NULL, L"open", RDXHomePage, NULL, NULL, SW_SHOWNORMAL); break; + case IDOK: + case IDCANCEL: + EndDialog(hDlg, 0); + break; + } + default: + return FALSE; + } + return TRUE; } -bool CMainGui::ResetPlugins (CPlugins * plugins, CN64System * System) +bool CMainGui::ResetPluginsInUiThread(CPlugins * plugins, CN64System * System) { - RESET_PLUGIN info; - info.system = System; - info.plugins = plugins; - info.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - bool bRes = true; - if (info.hEvent) - { - PostMessage(m_hMainWindow, WM_RESET_PLUGIN, (WPARAM)&bRes, (LPARAM)&info); + RESET_PLUGIN info; + info.system = System; + info.plugins = plugins; + info.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + bool bRes = true; + if (info.hEvent) + { + PostMessage(m_hMainWindow, WM_RESET_PLUGIN, (WPARAM)&bRes, (LPARAM)&info); #ifdef _DEBUG - DWORD dwRes = WaitForSingleObject(info.hEvent, INFINITE); + DWORD dwRes = WaitForSingleObject(info.hEvent, INFINITE); #else - DWORD dwRes = WaitForSingleObject(info.hEvent, 5000); + DWORD dwRes = WaitForSingleObject(info.hEvent, 5000); #endif - dwRes = dwRes; - CloseHandle(info.hEvent); - } - else - { - WriteTrace(TraceError, __FUNCTION__ ": Failed to create event"); - bRes = false; - } - return bRes; + dwRes = dwRes; + CloseHandle(info.hEvent); + } + else + { + WriteTrace(TraceError, __FUNCTION__ ": Failed to create event"); + bRes = false; + } + return bRes; } void CMainGui::BringToTop(void) { - CGuard Guard(m_CS); - SetForegroundWindow(m_hMainWindow); - SetFocus(GetDesktopWindow()); - Sleep(100); - SetFocus(m_hMainWindow); + CGuard Guard(m_CS); + SetForegroundWindow(m_hMainWindow); + SetFocus(GetDesktopWindow()); + Sleep(100); + SetFocus(m_hMainWindow); } void CMainGui::MakeWindowOnTop(bool OnTop) { - CGuard Guard(m_CS); - SetWindowPos(m_hMainWindow, OnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW); + CGuard Guard(m_CS); + SetWindowPos(m_hMainWindow, OnTop ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOREDRAW); } void CMainGui::Caption(LPCWSTR Caption) { - CGuard Guard(m_CS); - SetWindowTextW(m_hMainWindow, Caption); + CGuard Guard(m_CS); + SetWindowTextW(m_hMainWindow, Caption); } void CMainGui::Create(const char * WindowTitle) { - stdstr_f VersionDisplay("Project64 %s", VER_FILE_VERSION_STR); - m_hMainWindow = (HWND)CreateWindowEx(WS_EX_ACCEPTFILES, VersionDisplay.c_str(), WindowTitle, WS_OVERLAPPED | WS_CLIPCHILDREN | - WS_CLIPSIBLINGS | WS_SYSMENU | WS_MINIMIZEBOX, 5, 5, 640, 480, - NULL, NULL, GetModuleHandle(NULL), this); - m_Created = m_hMainWindow != NULL; + stdstr_f VersionDisplay("Project64 %s", VER_FILE_VERSION_STR); + m_hMainWindow = (HWND)CreateWindowEx(WS_EX_ACCEPTFILES, VersionDisplay.c_str(), WindowTitle, WS_OVERLAPPED | WS_CLIPCHILDREN | + WS_CLIPSIBLINGS | WS_SYSMENU | WS_MINIMIZEBOX, 5, 5, 640, 480, + NULL, NULL, GetModuleHandle(NULL), this); + m_Created = m_hMainWindow != NULL; } void CMainGui::CreateStatusBar(void) { - m_hStatusWnd = (HWND)CreateStatusWindow(WS_CHILD | WS_VISIBLE, "", m_hMainWindow, StatusBarID); - SendMessage((HWND)m_hStatusWnd, SB_SETTEXT, 0, (LPARAM)""); + m_hStatusWnd = (HWND)CreateStatusWindow(WS_CHILD | WS_VISIBLE, "", m_hMainWindow, StatusBarID); + SendMessage((HWND)m_hStatusWnd, SB_SETTEXT, 0, (LPARAM)""); } WPARAM CMainGui::ProcessAllMessages(void) { - MSG msg; + MSG msg; - while (GetMessage(&msg, NULL, 0, 0)) - { - if (g_cheatUI != NULL && g_cheatUI->IsCheatMessage(&msg)) - { - continue; - } + while (GetMessage(&msg, NULL, 0, 0)) + { + if (g_cheatUI != NULL && g_cheatUI->IsCheatMessage(&msg)) + { + continue; + } - if (m_ResetPlugins) - { - m_ResetPlugins = false; - m_ResetInfo->res = m_ResetInfo->plugins->Reset(m_ResetInfo->system); - SetEvent(m_ResetInfo->hEvent); - m_ResetInfo = NULL; - } - if (g_cheatUI && g_cheatUI->IsCheatMessage(&msg)) { continue; } - if (m_Menu->ProcessAccelerator(m_hMainWindow, &msg)) { continue; } - TranslateMessage(&msg); - DispatchMessage(&msg); - } - return msg.wParam; + if (m_ResetPlugins) + { + m_ResetPlugins = false; + m_ResetInfo->res = m_ResetInfo->plugins->Reset(m_ResetInfo->system); + SetEvent(m_ResetInfo->hEvent); + m_ResetInfo = NULL; + } + if (g_cheatUI && g_cheatUI->IsCheatMessage(&msg)) { continue; } + if (m_Menu->ProcessAccelerator(m_hMainWindow, &msg)) { continue; } + TranslateMessage(&msg); + DispatchMessage(&msg); + } + return msg.wParam; } bool CMainGui::ProcessGuiMessages(void) { - MSG msg; + MSG msg; - while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) - { - if (m_ResetPlugins) - { - m_ResetPlugins = false; - } - if (msg.message == WM_QUIT) - { - return true; - } - PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); - if (m_Menu->ProcessAccelerator(m_hMainWindow, &msg)) { continue; } - TranslateMessage(&msg); - DispatchMessage(&msg); - } - return false; + while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) + { + if (m_ResetPlugins) + { + m_ResetPlugins = false; + } + if (msg.message == WM_QUIT) + { + return true; + } + PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); + if (m_Menu->ProcessAccelerator(m_hMainWindow, &msg)) { continue; } + TranslateMessage(&msg); + DispatchMessage(&msg); + } + return false; } void CMainGui::Resize(DWORD /*fwSizeType*/, WORD nWidth, WORD nHeight) { - RECT clrect, swrect; - GetClientRect(m_hMainWindow, &clrect); - GetClientRect((HWND)m_hStatusWnd, &swrect); + RECT clrect, swrect; + GetClientRect(m_hMainWindow, &clrect); + GetClientRect((HWND)m_hStatusWnd, &swrect); - int Parts[2]; - Parts[0] = (nWidth - (int)(clrect.right * 0.25)); - Parts[1] = nWidth; + int Parts[2]; + Parts[0] = (nWidth - (int)(clrect.right * 0.25)); + Parts[1] = nWidth; - SendMessage((HWND)m_hStatusWnd, SB_SETPARTS, 2, (LPARAM)&Parts[0]); - MoveWindow((HWND)m_hStatusWnd, 0, clrect.bottom - swrect.bottom, nWidth, nHeight, TRUE); + SendMessage((HWND)m_hStatusWnd, SB_SETPARTS, 2, (LPARAM)&Parts[0]); + MoveWindow((HWND)m_hStatusWnd, 0, clrect.bottom - swrect.bottom, nWidth, nHeight, TRUE); } void CMainGui::Show(bool Visible) { - m_MakingVisible = true; + m_MakingVisible = true; - CGuard Guard(m_CS); - if (m_hMainWindow) - { - ShowWindow(m_hMainWindow, Visible ? SW_SHOW : SW_HIDE); - if (Visible && RomBrowserVisible()) - { - RomBrowserToTop(); - } - } + CGuard Guard(m_CS); + if (m_hMainWindow) + { + ShowWindow(m_hMainWindow, Visible ? SW_SHOW : SW_HIDE); + if (Visible && RomBrowserVisible()) + { + RomBrowserToTop(); + } + } - m_MakingVisible = false; + m_MakingVisible = false; } -void CMainGui::EnterLogOptions (void) +void CMainGui::EnterLogOptions(void) { - ::EnterLogOptions(m_hMainWindow); + ::EnterLogOptions(m_hMainWindow); } int CMainGui::Height(void) { - if (!m_hMainWindow) { return 0; } + if (!m_hMainWindow) { return 0; } - RECT rect; - GetWindowRect(m_hMainWindow, &rect); - return rect.bottom - rect.top; + RECT rect; + GetWindowRect(m_hMainWindow, &rect); + return rect.bottom - rect.top; } int CMainGui::Width(void) { - if (!m_hMainWindow) { return 0; } + if (!m_hMainWindow) { return 0; } - RECT rect; - GetWindowRect(m_hMainWindow, &rect); - return rect.right - rect.left; + RECT rect; + GetWindowRect(m_hMainWindow, &rect); + return rect.right - rect.left; } void CMainGui::SetPos(int X, int Y) { - SetWindowPos(m_hMainWindow, NULL, X, Y, 0, 0, SWP_NOZORDER | SWP_NOSIZE); + SetWindowPos(m_hMainWindow, NULL, X, Y, 0, 0, SWP_NOZORDER | SWP_NOSIZE); } void CMainGui::SetWindowMenu(CBaseMenu * Menu) { - m_AttachingMenu = true; + m_AttachingMenu = true; - HMENU hMenu = NULL; - { - CGuard Guard(m_CS); - m_Menu = Menu; - hMenu = (HMENU)Menu->GetHandle(); - } + HMENU hMenu = NULL; + { + CGuard Guard(m_CS); + m_Menu = Menu; + hMenu = (HMENU)Menu->GetHandle(); + } - if (hMenu) - { - SetMenu(m_hMainWindow, hMenu); - } + if (hMenu) + { + SetMenu(m_hMainWindow, hMenu); + } - m_AttachingMenu = false; + m_AttachingMenu = false; } void CMainGui::RefreshMenu(void) { - if (!m_Menu) { return; } - m_Menu->ResetMenu(); + if (!m_Menu) { return; } + m_Menu->ResetMenu(); } void CMainGui::SetStatusText(int Panel, const wchar_t * Text) { - static wchar_t Message[2][500]; - if (Panel >= 2) - { - g_Notify->BreakPoint(__FILEW__, __LINE__); - return; - } - wchar_t * Msg = Message[Panel]; + static wchar_t Message[2][500]; + if (Panel >= 2) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + return; + } + wchar_t * Msg = Message[Panel]; - memset(Msg, 0, sizeof(Message[0])); - _snwprintf(Msg, sizeof(Message[0]) / sizeof(Message[0][0]), L"%s", Text); - Msg[(sizeof(Message[0]) / sizeof(Message[0][0])) - 1] = 0; - if (GetCurrentThreadId() == m_ThreadId) - { - SendMessageW((HWND)m_hStatusWnd, SB_SETTEXTW, Panel, (LPARAM)Msg); - } - else { - PostMessageW((HWND)m_hStatusWnd, SB_SETTEXTW, Panel, (LPARAM)Msg); - } + memset(Msg, 0, sizeof(Message[0])); + _snwprintf(Msg, sizeof(Message[0]) / sizeof(Message[0][0]), L"%s", Text); + Msg[(sizeof(Message[0]) / sizeof(Message[0][0])) - 1] = 0; + if (GetCurrentThreadId() == m_ThreadId) + { + SendMessageW((HWND)m_hStatusWnd, SB_SETTEXTW, Panel, (LPARAM)Msg); + } + else { + PostMessageW((HWND)m_hStatusWnd, SB_SETTEXTW, Panel, (LPARAM)Msg); + } } void CMainGui::ShowStatusBar(bool ShowBar) { - ShowWindow((HWND)m_hStatusWnd, ShowBar ? SW_SHOW : SW_HIDE); + ShowWindow((HWND)m_hStatusWnd, ShowBar ? SW_SHOW : SW_HIDE); } void CMainGui::SaveWindowLoc(void) { - bool flush = false; - if (m_SaveMainWindowPos) - { - m_SaveMainWindowPos = false; - g_Settings->SaveDword(UserInterface_MainWindowTop, m_SaveMainWindowTop); - g_Settings->SaveDword(UserInterface_MainWindowLeft, m_SaveMainWindowLeft); - flush = true; - } + bool flush = false; + if (m_SaveMainWindowPos) + { + m_SaveMainWindowPos = false; + g_Settings->SaveDword(UserInterface_MainWindowTop, m_SaveMainWindowTop); + g_Settings->SaveDword(UserInterface_MainWindowLeft, m_SaveMainWindowLeft); + flush = true; + } - if (m_SaveRomBrowserPos) - { - m_SaveRomBrowserPos = false; - g_Settings->SaveDword(RomBrowser_Top, m_SaveRomBrowserTop); - g_Settings->SaveDword(RomBrowser_Left, m_SaveRomBrowserLeft); - flush = true; - } + if (m_SaveRomBrowserPos) + { + m_SaveRomBrowserPos = false; + g_Settings->SaveDword(RomBrowser_Top, m_SaveRomBrowserTop); + g_Settings->SaveDword(RomBrowser_Left, m_SaveRomBrowserLeft); + flush = true; + } - if (flush) - { - CSettingTypeApplication::Flush(); - } + if (flush) + { + CSettingTypeApplication::Flush(); + } } LRESULT CALLBACK CMainGui::MainGui_Proc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) { - switch (uMsg) - { - case WM_CREATE: - { - //record class for future usage - LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam; - CMainGui * _this = (CMainGui *)lpcs->lpCreateParams; - SetProp((HWND)hWnd, "Class", _this); + switch (uMsg) + { + case WM_CREATE: + { + //record class for future usage + LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam; + CMainGui * _this = (CMainGui *)lpcs->lpCreateParams; + SetProp((HWND)hWnd, "Class", _this); - _this->m_hMainWindow = hWnd; - _this->CreateStatusBar(); + _this->m_hMainWindow = hWnd; + _this->CreateStatusBar(); - //Move the Main window to the location last executed from or center the window - int X = (GetSystemMetrics(SM_CXSCREEN) - _this->Width()) / 2; - int Y = (GetSystemMetrics(SM_CYSCREEN) - _this->Height()) / 2; + //Move the Main window to the location last executed from or center the window + int X = (GetSystemMetrics(SM_CXSCREEN) - _this->Width()) / 2; + int Y = (GetSystemMetrics(SM_CYSCREEN) - _this->Height()) / 2; - g_Settings->LoadDword(UserInterface_MainWindowTop, (uint32_t &)Y); - g_Settings->LoadDword(UserInterface_MainWindowLeft, (uint32_t &)X); + g_Settings->LoadDword(UserInterface_MainWindowTop, (uint32_t &)Y); + g_Settings->LoadDword(UserInterface_MainWindowLeft, (uint32_t &)X); - _this->SetPos(X, Y); + _this->SetPos(X, Y); - _this->ChangeWinSize(640, 480); - } - break; - case WM_SYSCOMMAND: - switch (wParam) { - case SC_SCREENSAVE: - case SC_MONITORPOWER: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this && - _this->bCPURunning() && - !g_Settings->LoadBool(GameRunning_CPU_Paused) && - g_Settings->LoadDword(Setting_DisableScrSaver)) - { - return 0; - } - } - break; - case SC_MAXIMIZE: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this) - { - if (_this->RomBrowserVisible()) - { - _this->RomBrowserMaximize(true); - } - } - } - break; - } - return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam); - break; - case WM_MOVE: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + _this->ChangeWinSize(640, 480); + } + break; + case WM_SYSCOMMAND: + switch (wParam) { + case SC_SCREENSAVE: + case SC_MONITORPOWER: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this && + _this->bCPURunning() && + !g_Settings->LoadBool(GameRunning_CPU_Paused) && + g_Settings->LoadDword(Setting_DisableScrSaver)) + { + return 0; + } + } + break; + case SC_MAXIMIZE: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this) + { + if (_this->RomBrowserVisible()) + { + _this->RomBrowserMaximize(true); + } + } + } + break; + } + return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam); + break; + case WM_MOVE: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (!_this->m_bMainWindow || - !_this->m_Created || - _this->m_AttachingMenu || - _this->m_MakingVisible || - IsIconic((HWND)hWnd) || - _this->ShowingRomBrowser()) - { - break; - } + if (!_this->m_bMainWindow || + !_this->m_Created || + _this->m_AttachingMenu || + _this->m_MakingVisible || + IsIconic((HWND)hWnd) || + _this->ShowingRomBrowser()) + { + break; + } - if (IsZoomed((HWND)hWnd)) - { - if (_this->RomBrowserVisible()) - { - // save that browser is maximized - } - break; - } + if (IsZoomed((HWND)hWnd)) + { + if (_this->RomBrowserVisible()) + { + // save that browser is maximized + } + break; + } - //get the current position of the window - RECT WinRect; - GetWindowRect((HWND)hWnd, &WinRect); + //get the current position of the window + RECT WinRect; + GetWindowRect((HWND)hWnd, &WinRect); - //save the location of the window - if (_this->RomBrowserVisible()) - { - _this->m_SaveRomBrowserPos = true; - _this->m_SaveRomBrowserTop = WinRect.top; - _this->m_SaveRomBrowserLeft = WinRect.left; - } - else - { - _this->m_SaveMainWindowPos = true; - _this->m_SaveMainWindowTop = WinRect.top; - _this->m_SaveMainWindowLeft = WinRect.left; - } - KillTimer(hWnd, Timer_SetWindowPos); - SetTimer(hWnd, Timer_SetWindowPos, 1000, NULL); - } - if (CGuiSettings::bCPURunning() && g_BaseSystem) - { - if (g_Plugins->Gfx() && g_Plugins->Gfx()->MoveScreen) - { - WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Starting"); - g_Plugins->Gfx()->MoveScreen((int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)); - WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Done"); - } - } - break; - case WM_TIMER: - if (wParam == Timer_SetWindowPos) - { - KillTimer(hWnd, Timer_SetWindowPos); - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - _this->SaveWindowLoc(); - break; - } - break; - case WM_SIZE: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this) { _this->Resize(wParam, LOWORD(lParam), HIWORD(lParam)); } - if (_this) - { - if (wParam == SIZE_MAXIMIZED) - { - if (_this->RomBrowserVisible()) - { - _this->RomBrowserMaximize(true); - } - } - _this->ResizeRomList(LOWORD(lParam), HIWORD(lParam)); - } - if (_this) - { - if (wParam == SIZE_RESTORED && _this->RomBrowserVisible()) - { - _this->RomBrowserMaximize(false); - } - } - } - break; - case WM_NOTIFY: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this) - { - if (_this->RomBrowserVisible() && !_this->RomListNotify(wParam, lParam)) - { - return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam); - } - } - } - break; - case WM_DRAWITEM: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this) - { - if (!_this->RomListDrawItem(wParam, lParam)) - { - return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam); - } - } - } - break; - case WM_PAINT: - { - // CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); - // CN64System * System = _this->m_System; + //save the location of the window + if (_this->RomBrowserVisible()) + { + _this->m_SaveRomBrowserPos = true; + _this->m_SaveRomBrowserTop = WinRect.top; + _this->m_SaveRomBrowserLeft = WinRect.left; + } + else + { + _this->m_SaveMainWindowPos = true; + _this->m_SaveMainWindowTop = WinRect.top; + _this->m_SaveMainWindowLeft = WinRect.left; + } + KillTimer(hWnd, Timer_SetWindowPos); + SetTimer(hWnd, Timer_SetWindowPos, 1000, NULL); + } + if (CGuiSettings::bCPURunning() && g_BaseSystem) + { + if (g_Plugins->Gfx() && g_Plugins->Gfx()->MoveScreen) + { + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Starting"); + g_Plugins->Gfx()->MoveScreen((int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Done"); + } + } + break; + case WM_TIMER: + if (wParam == Timer_SetWindowPos) + { + KillTimer(hWnd, Timer_SetWindowPos); + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + _this->SaveWindowLoc(); + break; + } + break; + case WM_SIZE: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this) { _this->Resize(wParam, LOWORD(lParam), HIWORD(lParam)); } + if (_this) + { + if (wParam == SIZE_MAXIMIZED) + { + if (_this->RomBrowserVisible()) + { + _this->RomBrowserMaximize(true); + } + } + _this->ResizeRomList(LOWORD(lParam), HIWORD(lParam)); + } + if (_this) + { + if (wParam == SIZE_RESTORED && _this->RomBrowserVisible()) + { + _this->RomBrowserMaximize(false); + } + } + } + break; + case WM_NOTIFY: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this) + { + if (_this->RomBrowserVisible() && !_this->RomListNotify(wParam, lParam)) + { + return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam); + } + } + } + break; + case WM_DRAWITEM: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this) + { + if (!_this->RomListDrawItem(wParam, lParam)) + { + return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam); + } + } + } + break; + case WM_PAINT: + { + // CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd,"Class"); + // CN64System * System = _this->m_System; - // if (bCPURunning() && Settings->Load(CPU_Paused)) { - // CPlugins * Plugins = System->Plugins(); - // if (Plugins->Gfx()->DrawScreen) { - // Plugins->Gfx()->DrawScreen(); - // } - // } - ValidateRect((HWND)hWnd, NULL); - } - break; - case WM_KEYUP: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + // if (bCPURunning() && Settings->Load(CPU_Paused)) { + // CPlugins * Plugins = System->Plugins(); + // if (Plugins->Gfx()->DrawScreen) { + // Plugins->Gfx()->DrawScreen(); + // } + // } + ValidateRect((HWND)hWnd, NULL); + } + break; + case WM_KEYUP: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this->m_bMainWindow && bCPURunning()) - { - if (g_BaseSystem) - { - if (g_Plugins && g_Plugins->Control()->WM_KeyUp) { - g_Plugins->Control()->WM_KeyUp(wParam, lParam); - } - } - } - } - break; - case WM_KEYDOWN: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this->m_bMainWindow && bCPURunning()) + { + if (g_BaseSystem) + { + if (g_Plugins && g_Plugins->Control()->WM_KeyUp) { + g_Plugins->Control()->WM_KeyUp(wParam, lParam); + } + } + } + } + break; + case WM_KEYDOWN: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this->m_bMainWindow && bCPURunning()) - { - if (g_BaseSystem) - { - if (g_Plugins && g_Plugins->Control()->WM_KeyDown) - { - g_Plugins->Control()->WM_KeyDown(wParam, lParam); - } - } - } - } - break; - case WM_SETFOCUS: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this->RomBrowserVisible()) - { - PostMessage((HWND)hWnd, WM_BORWSER_TOP, 0, 0); - break; - } + if (_this->m_bMainWindow && bCPURunning()) + { + if (g_BaseSystem) + { + if (g_Plugins && g_Plugins->Control()->WM_KeyDown) + { + g_Plugins->Control()->WM_KeyDown(wParam, lParam); + } + } + } + } + break; + case WM_SETFOCUS: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this->RomBrowserVisible()) + { + PostMessage((HWND)hWnd, WM_BORWSER_TOP, 0, 0); + break; + } - if (_this->m_bMainWindow && bCPURunning() && bAutoSleep()) - { - if (g_BaseSystem) - { - g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_AppGainedFocus); - } - } - } - break; - case WM_KILLFOCUS: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this->RomBrowserVisible()) - { - break; - } + if (_this->m_bMainWindow && bCPURunning() && bAutoSleep()) + { + if (g_BaseSystem) + { + g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_AppGainedFocus); + } + } + } + break; + case WM_KILLFOCUS: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this->RomBrowserVisible()) + { + break; + } - if (_this->m_bMainWindow && bCPURunning() && bAutoSleep()) - { - if (g_BaseSystem) - { - g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_AppLostFocus); - } - } - } - break; - case WM_ACTIVATEAPP: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - DWORD fActive = (BOOL)wParam; + if (_this->m_bMainWindow && bCPURunning() && bAutoSleep()) + { + if (g_BaseSystem) + { + g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_AppLostFocus); + } + } + } + break; + case WM_ACTIVATEAPP: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + DWORD fActive = (BOOL)wParam; - if (fActive && _this->RomBrowserVisible()) - { - PostMessage((HWND)hWnd, WM_BORWSER_TOP, 0, 0); - } - if (_this->m_bMainWindow && bCPURunning()) - { - if (!fActive && g_Settings->LoadBool(UserInterface_InFullScreen)) - { - Notify().WindowMode(); - if (bAutoSleep() && g_BaseSystem) - { - //System->ExternalEvent(PauseCPU_AppLostActiveDelayed ); - } - break; - } - if (bAutoSleep() || fActive) - { - if (g_BaseSystem) - { - g_BaseSystem->ExternalEvent(fActive ? SysEvent_ResumeCPU_AppGainedActive : SysEvent_PauseCPU_AppLostActive); - } - } - } - } - break; - case WM_HIDE_CUROSR: - if (!wParam) - { - while (ShowCursor(FALSE) >= 0) { Sleep(0); } - } - else - { - while (ShowCursor(TRUE) < 0) { Sleep(0); } - } - break; - case WM_MAKE_FOCUS: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - _this->BringToTop(); - } - break; - case WM_BORWSER_TOP: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - _this->RomBrowserToTop(); - } - break; - case WM_RESET_PLUGIN: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this->m_ResetInfo != NULL) - { - g_Notify->BreakPoint(__FILEW__, __LINE__); - } - _this->m_ResetInfo = (RESET_PLUGIN *)lParam; - _this->m_ResetPlugins = true; - } - break; - case WM_COMMAND: - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this == NULL) { break; } + if (fActive && _this->RomBrowserVisible()) + { + PostMessage((HWND)hWnd, WM_BORWSER_TOP, 0, 0); + } + if (_this->m_bMainWindow && bCPURunning()) + { + if (!fActive && g_Settings->LoadBool(UserInterface_InFullScreen)) + { + Notify().WindowMode(); + if (bAutoSleep() && g_BaseSystem) + { + //System->ExternalEvent(PauseCPU_AppLostActiveDelayed ); + } + break; + } + if (bAutoSleep() || fActive) + { + if (g_BaseSystem) + { + g_BaseSystem->ExternalEvent(fActive ? SysEvent_ResumeCPU_AppGainedActive : SysEvent_PauseCPU_AppLostActive); + } + } + } + } + break; + case WM_HIDE_CUROSR: + if (!wParam) + { + while (ShowCursor(FALSE) >= 0) { Sleep(0); } + } + else + { + while (ShowCursor(TRUE) < 0) { Sleep(0); } + } + break; + case WM_MAKE_FOCUS: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + _this->BringToTop(); + } + break; + case WM_BORWSER_TOP: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + _this->RomBrowserToTop(); + } + break; + case WM_RESET_PLUGIN: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this->m_ResetInfo != NULL) + { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + _this->m_ResetInfo = (RESET_PLUGIN *)lParam; + _this->m_ResetPlugins = true; + } + break; + case WM_COMMAND: + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this == NULL) { break; } - switch (LOWORD(wParam)) { - case ID_POPUPMENU_PLAYGAME: g_BaseSystem->RunFileImage(_this->CurrentedSelectedRom()); break; - case ID_POPUPMENU_ROMDIRECTORY: _this->SelectRomDir(); break; - case ID_POPUPMENU_REFRESHROMLIST: _this->RefreshRomBrowser(); break; - case ID_POPUPMENU_ROMINFORMATION: - { - RomInformation Info(_this->CurrentedSelectedRom()); - Info.DisplayInformation(hWnd); - } - break; - case ID_POPUPMENU_EDITSETTINGS: - case ID_POPUPMENU_EDITCHEATS: - { - CN64Rom Rom; - Rom.LoadN64Image(_this->CurrentedSelectedRom(), true); - Rom.SaveRomSettingID(true); + switch (LOWORD(wParam)) { + case ID_POPUPMENU_PLAYGAME: g_BaseSystem->RunFileImage(_this->CurrentedSelectedRom()); break; + case ID_POPUPMENU_ROMDIRECTORY: _this->SelectRomDir(); break; + case ID_POPUPMENU_REFRESHROMLIST: _this->RefreshRomBrowser(); break; + case ID_POPUPMENU_ROMINFORMATION: + { + RomInformation Info(_this->CurrentedSelectedRom()); + Info.DisplayInformation(hWnd); + } + break; + case ID_POPUPMENU_EDITSETTINGS: + case ID_POPUPMENU_EDITCHEATS: + { + CN64Rom Rom; + Rom.LoadN64Image(_this->CurrentedSelectedRom(), true); + Rom.SaveRomSettingID(true); - if (LOWORD(wParam) == ID_POPUPMENU_EDITSETTINGS) - { - CSettingConfig SettingConfig(true); - SettingConfig.Display(hWnd); - } + if (LOWORD(wParam) == ID_POPUPMENU_EDITSETTINGS) + { + CSettingConfig SettingConfig(true); + SettingConfig.Display(hWnd); + } - if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS) - { - CCheatsUI * cheatUI = new CCheatsUI; - g_cheatUI = cheatUI; - cheatUI->SelectCheats(hWnd, true); - if (g_cheatUI == cheatUI) - { - g_cheatUI = NULL; - } - } + if (LOWORD(wParam) == ID_POPUPMENU_EDITCHEATS) + { + CCheatsUI * cheatUI = new CCheatsUI; + g_cheatUI = cheatUI; + cheatUI->SelectCheats(hWnd, true); + if (g_cheatUI == cheatUI) + { + g_cheatUI = NULL; + } + } - if (g_Rom) - { - g_Rom->SaveRomSettingID(false); - } - else - { - Rom.ClearRomSettingID(); - } - } - break; - default: - if (_this->m_Menu) - { - if (LOWORD(wParam) > 5000 && LOWORD(wParam) <= 5100) - { - if (g_Plugins->RSP()) - { - g_Plugins->RSP()->ProcessMenuItem(LOWORD(wParam)); - } - } - else if (LOWORD(wParam) > 5100 && LOWORD(wParam) <= 5200) - { - if (g_Plugins->Gfx()) - { - WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Starting"); - g_Plugins->Gfx()->ProcessMenuItem(LOWORD(wParam)); - WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Done"); - } - } - else if (LOWORD(wParam) > 5200 && LOWORD(wParam) <= 5300) - { - if (g_Plugins->Gfx() && g_Plugins->Gfx()->OnRomBrowserMenuItem != NULL) - { - CN64Rom Rom; - if (!Rom.LoadN64Image(_this->CurrentedSelectedRom(), true)) - { - break; - } - Rom.SaveRomSettingID(true); - g_Notify->DisplayMessage(0, L""); - BYTE * RomHeader = Rom.GetRomAddress(); - WriteTrace(TraceGfxPlugin, __FUNCTION__ ": OnRomBrowserMenuItem - Starting"); - g_Plugins->Gfx()->OnRomBrowserMenuItem(LOWORD(wParam), hWnd, RomHeader); - WriteTrace(TraceGfxPlugin, __FUNCTION__ ": OnRomBrowserMenuItem - Done"); - if (g_Rom) - { - g_Rom->SaveRomSettingID(false); - } - else - { - g_Settings->SaveString(Game_IniKey, ""); - } - } - } - else if (_this->m_Menu->ProcessMessage(hWnd, HIWORD(wParam), LOWORD(wParam))) - { - return true; - } - } - } - } - break; - case WM_DROPFILES: - { - char filename[MAX_PATH]; + if (g_Rom) + { + g_Rom->SaveRomSettingID(false); + } + else + { + Rom.ClearRomSettingID(); + } + } + break; + default: + if (_this->m_Menu) + { + if (LOWORD(wParam) > 5000 && LOWORD(wParam) <= 5100) + { + if (g_Plugins->RSP()) + { + g_Plugins->RSP()->ProcessMenuItem(LOWORD(wParam)); + } + } + else if (LOWORD(wParam) > 5100 && LOWORD(wParam) <= 5200) + { + if (g_Plugins->Gfx()) + { + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Starting"); + g_Plugins->Gfx()->ProcessMenuItem(LOWORD(wParam)); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": Done"); + } + } + else if (LOWORD(wParam) > 5200 && LOWORD(wParam) <= 5300) + { + if (g_Plugins->Gfx() && g_Plugins->Gfx()->OnRomBrowserMenuItem != NULL) + { + CN64Rom Rom; + if (!Rom.LoadN64Image(_this->CurrentedSelectedRom(), true)) + { + break; + } + Rom.SaveRomSettingID(true); + g_Notify->DisplayMessage(0, L""); + BYTE * RomHeader = Rom.GetRomAddress(); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": OnRomBrowserMenuItem - Starting"); + g_Plugins->Gfx()->OnRomBrowserMenuItem(LOWORD(wParam), hWnd, RomHeader); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": OnRomBrowserMenuItem - Done"); + if (g_Rom) + { + g_Rom->SaveRomSettingID(false); + } + else + { + g_Settings->SaveString(Game_IniKey, ""); + } + } + } + else if (_this->m_Menu->ProcessMessage(hWnd, HIWORD(wParam), LOWORD(wParam))) + { + return true; + } + } + } + } + break; + case WM_DROPFILES: + { + char filename[MAX_PATH]; - HDROP hDrop = (HDROP)wParam; - DragQueryFile(hDrop, 0, filename, sizeof(filename)); - DragFinish(hDrop); + HDROP hDrop = (HDROP)wParam; + DragQueryFile(hDrop, 0, filename, sizeof(filename)); + DragFinish(hDrop); - CN64System::RunFileImage(filename); - } - break; - case WM_DESTROY: - WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - start"); - { - CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); - if (_this->m_bMainWindow) - { - Notify().WindowMode(); - } - _this->m_hMainWindow = NULL; - WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 1"); - if (_this->m_bMainWindow) - { - _this->SaveRomListColoumnInfo(); - WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 2"); - _this->SaveWindowLoc(); - } - } - WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 3"); - RemoveProp((HWND)hWnd, "Class"); - WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 4"); - PostQuitMessage(0); - WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - Done"); - break; - default: - return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam); - } - return TRUE; + CN64System::RunFileImage(filename); + } + break; + case WM_DESTROY: + WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - start"); + { + CMainGui * _this = (CMainGui *)GetProp((HWND)hWnd, "Class"); + if (_this->m_bMainWindow) + { + Notify().WindowMode(); + } + _this->m_hMainWindow = NULL; + WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 1"); + if (_this->m_bMainWindow) + { + _this->SaveRomListColoumnInfo(); + WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 2"); + _this->SaveWindowLoc(); + } + } + WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 3"); + RemoveProp((HWND)hWnd, "Class"); + WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - 4"); + PostQuitMessage(0); + WriteTrace(TraceDebug, __FUNCTION__ ": WM_DESTROY - Done"); + break; + default: + return DefWindowProc((HWND)hWnd, uMsg, wParam, lParam); + } + return TRUE; } DWORD CALLBACK AboutBoxProc(HWND hWnd, DWORD uMsg, DWORD wParam, DWORD lParam) { - static HBITMAP hbmpBackgroundTop = NULL; - static HFONT hPageHeadingFont = NULL; - static HFONT hTextFont = NULL; - static HFONT hAuthorFont = NULL; + static HBITMAP hbmpBackgroundTop = NULL; + static HFONT hPageHeadingFont = NULL; + static HFONT hTextFont = NULL; + static HFONT hAuthorFont = NULL; - switch (uMsg) { - case WM_INITDIALOG: - { - //Title - SetWindowTextW(hWnd, GS(PLUG_ABOUT)); + switch (uMsg) { + case WM_INITDIALOG: + { + //Title + SetWindowTextW(hWnd, GS(PLUG_ABOUT)); - // Use the size of the image - hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT_LOGO)); + // Use the size of the image + hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT_LOGO)); - BITMAP bmTL; - GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL); + BITMAP bmTL; + GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL); - hTextFont = ::CreateFont(18, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial"); - hAuthorFont = ::CreateFont(18, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial"); + hTextFont = ::CreateFont(18, 0, 0, 0, FW_NORMAL, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial"); + hAuthorFont = ::CreateFont(18, 0, 0, 0, FW_BOLD, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial"); - hPageHeadingFont = ::CreateFont(24, 0, 0, 0, FW_BOLD, 0, FALSE, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial Bold"); + hPageHeadingFont = ::CreateFont(24, 0, 0, 0, FW_BOLD, 0, FALSE, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial Bold"); - SendDlgItemMessage(hWnd, IDC_VERSION, WM_SETFONT, (WPARAM)hTextFont, TRUE); - SendDlgItemMessage(hWnd, IDC_TEAM, WM_SETFONT, (WPARAM)hPageHeadingFont, TRUE); - SendDlgItemMessage(hWnd, IDC_THANKS, WM_SETFONT, (WPARAM)hPageHeadingFont, TRUE); + SendDlgItemMessage(hWnd, IDC_VERSION, WM_SETFONT, (WPARAM)hTextFont, TRUE); + SendDlgItemMessage(hWnd, IDC_TEAM, WM_SETFONT, (WPARAM)hPageHeadingFont, TRUE); + SendDlgItemMessage(hWnd, IDC_THANKS, WM_SETFONT, (WPARAM)hPageHeadingFont, TRUE); - SendDlgItemMessage(hWnd, IDC_ZILMAR, WM_SETFONT, (WPARAM)hAuthorFont, TRUE); - SendDlgItemMessage(hWnd, IDC_JABO, WM_SETFONT, (WPARAM)hAuthorFont, TRUE); - SendDlgItemMessage(hWnd, IDC_SMIFF, WM_SETFONT, (WPARAM)hAuthorFont, TRUE); - SendDlgItemMessage(hWnd, IDC_GENT, WM_SETFONT, (WPARAM)hAuthorFont, TRUE); + SendDlgItemMessage(hWnd, IDC_ZILMAR, WM_SETFONT, (WPARAM)hAuthorFont, TRUE); + SendDlgItemMessage(hWnd, IDC_JABO, WM_SETFONT, (WPARAM)hAuthorFont, TRUE); + SendDlgItemMessage(hWnd, IDC_SMIFF, WM_SETFONT, (WPARAM)hAuthorFont, TRUE); + SendDlgItemMessage(hWnd, IDC_GENT, WM_SETFONT, (WPARAM)hAuthorFont, TRUE); - SendDlgItemMessage(hWnd, IDC_ZILMAR_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE); - SendDlgItemMessage(hWnd, IDC_JABO_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE); - SendDlgItemMessage(hWnd, IDC_SMIFF_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE); - SendDlgItemMessage(hWnd, IDC_GENT_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE); + SendDlgItemMessage(hWnd, IDC_ZILMAR_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE); + SendDlgItemMessage(hWnd, IDC_JABO_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE); + SendDlgItemMessage(hWnd, IDC_SMIFF_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE); + SendDlgItemMessage(hWnd, IDC_GENT_DETAILS, WM_SETFONT, (WPARAM)hTextFont, TRUE); - SendDlgItemMessage(hWnd, IDC_THANK_LIST, WM_SETFONT, (WPARAM)hTextFont, TRUE); + SendDlgItemMessage(hWnd, IDC_THANK_LIST, WM_SETFONT, (WPARAM)hTextFont, TRUE); - stdstr_f VersionDisplay("Version: %s", VER_FILE_VERSION_STR); - SetWindowText(GetDlgItem(hWnd, IDC_VERSION), VersionDisplay.c_str()); - } - break; - case WM_CTLCOLORSTATIC: - { - HDC hdcStatic = (HDC)wParam; - SetTextColor(hdcStatic, RGB(0, 0, 0)); - SetBkMode(hdcStatic, TRANSPARENT); - return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH)); - } - break; - case WM_ERASEBKGND: - { - HPEN outline; - HBRUSH fill; - RECT rect; + stdstr_f VersionDisplay("Version: %s", VER_FILE_VERSION_STR); + SetWindowText(GetDlgItem(hWnd, IDC_VERSION), VersionDisplay.c_str()); + } + break; + case WM_CTLCOLORSTATIC: + { + HDC hdcStatic = (HDC)wParam; + SetTextColor(hdcStatic, RGB(0, 0, 0)); + SetBkMode(hdcStatic, TRANSPARENT); + return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH)); + } + break; + case WM_ERASEBKGND: + { + HPEN outline; + HBRUSH fill; + RECT rect; - outline = CreatePen(PS_SOLID, 1, 0x00FFFFFF); - fill = CreateSolidBrush(0x00FFFFFF); - SelectObject((HDC)wParam, outline); - SelectObject((HDC)wParam, fill); + outline = CreatePen(PS_SOLID, 1, 0x00FFFFFF); + fill = CreateSolidBrush(0x00FFFFFF); + SelectObject((HDC)wParam, outline); + SelectObject((HDC)wParam, fill); - GetClientRect(hWnd, &rect); + GetClientRect(hWnd, &rect); - Rectangle((HDC)wParam, rect.left, rect.top, rect.right, rect.bottom); - } - break; - case WM_PAINT: - { - PAINTSTRUCT ps; + Rectangle((HDC)wParam, rect.left, rect.top, rect.right, rect.bottom); + } + break; + case WM_PAINT: + { + PAINTSTRUCT ps; - if (BeginPaint(hWnd, &ps)) - { - RECT rcClient; - GetClientRect(hWnd, &rcClient); + if (BeginPaint(hWnd, &ps)) + { + RECT rcClient; + GetClientRect(hWnd, &rcClient); - BITMAP bmTL_top; - GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top); + BITMAP bmTL_top; + GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top); - HDC memdc = CreateCompatibleDC(ps.hdc); - HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop); - BitBlt(ps.hdc, 0, 0, bmTL_top.bmWidth, bmTL_top.bmHeight, memdc, 0, 0, SRCCOPY); - SelectObject(memdc, save); - DeleteDC(memdc); + HDC memdc = CreateCompatibleDC(ps.hdc); + HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop); + BitBlt(ps.hdc, 0, 0, bmTL_top.bmWidth, bmTL_top.bmHeight, memdc, 0, 0, SRCCOPY); + SelectObject(memdc, save); + DeleteDC(memdc); - EndPaint(hWnd, &ps); - } - } - break; - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDOK: - case IDCANCEL: - if (hbmpBackgroundTop) - { - DeleteObject(hbmpBackgroundTop); - } - if (hTextFont) - { - ::DeleteObject(hTextFont); - } - if (hPageHeadingFont) - { - ::DeleteObject(hPageHeadingFont); - } - if (hAuthorFont) - { - ::DeleteObject(hAuthorFont); - } - //ReleaseCapture(); - EndDialog(hWnd, 0); - break; - } - default: - return FALSE; - } - return TRUE; + EndPaint(hWnd, &ps); + } + } + break; + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDOK: + case IDCANCEL: + if (hbmpBackgroundTop) + { + DeleteObject(hbmpBackgroundTop); + } + if (hTextFont) + { + ::DeleteObject(hTextFont); + } + if (hPageHeadingFont) + { + ::DeleteObject(hPageHeadingFont); + } + if (hAuthorFont) + { + ::DeleteObject(hAuthorFont); + } + //ReleaseCapture(); + EndDialog(hWnd, 0); + break; + } + default: + return FALSE; + } + return TRUE; } BOOL set_about_field(HWND hDlg, int nIDDlgItem, const wchar_t * config_string, const wchar_t * language_string) { - wchar_t temp_string[200]; + wchar_t temp_string[200]; - swprintf(temp_string, sizeof(temp_string) / sizeof(temp_string[0]), L"%s: %s", config_string, language_string); - return SetDlgItemTextW(hDlg, nIDDlgItem, temp_string); -} + swprintf(temp_string, sizeof(temp_string) / sizeof(temp_string[0]), L"%s: %s", config_string, language_string); + return SetDlgItemTextW(hDlg, nIDDlgItem, temp_string); +} \ No newline at end of file diff --git a/Source/Project64/User Interface/Gui Class.h b/Source/Project64/User Interface/Gui Class.h index 264bcc7c6..0ab6b34f6 100644 --- a/Source/Project64/User Interface/Gui Class.h +++ b/Source/Project64/User Interface/Gui Class.h @@ -11,6 +11,7 @@ #pragma once #include +#include class CGfxPlugin; //Plugin that controls the rendering class CAudioPlugin; //Plugin for audio, need the hwnd @@ -28,6 +29,7 @@ enum }; class CMainGui : + public RenderWindow, public CRomBrowser, public CDebuggerUI, private CGuiSettings @@ -80,10 +82,11 @@ public: void AboutBox(void); //Plugins - bool ResetPlugins ( CPlugins * plugins, CN64System * System ); + bool ResetPluginsInUiThread(CPlugins * plugins, CN64System * System); //Get Window Handle - inline HWND GetHandle ( void ) const { return m_hMainWindow; } + void * GetWindowHandle(void) const { return m_hMainWindow; } + void * GetStatusBar(void) const { return m_hStatusWnd; } private: CMainGui(void); // Disable default constructor diff --git a/Source/Project64/User Interface/Notification Class.cpp b/Source/Project64/User Interface/Notification Class.cpp index bbeb27394..764ea07ba 100644 --- a/Source/Project64/User Interface/Notification Class.cpp +++ b/Source/Project64/User Interface/Notification Class.cpp @@ -1,335 +1,322 @@ #include "stdafx.h" #include -CNotification & Notify ( void ) +CNotification & Notify(void) { - static CNotification g_Notify; - return g_Notify; + static CNotification g_Notify; + return g_Notify; } CNotification::CNotification() : - m_hWnd(NULL), - m_gfxPlugin(NULL), - m_NextMsg(0) +m_hWnd(NULL), +m_gfxPlugin(NULL), +m_NextMsg(0) { - _tzset(); + _tzset(); } void CNotification::AppInitDone(void) { - CNotificationSettings::RegisterNotifications(); + CNotificationSettings::RegisterNotifications(); } -void CNotification::SetMainWindow ( CMainGui * Gui ) +void CNotification::SetMainWindow(CMainGui * Gui) { - m_hWnd = Gui; + m_hWnd = Gui; } -void CNotification::WindowMode ( void ) const +void CNotification::WindowMode(void) const { - static bool InsideFunc = false; - if (InsideFunc) - { - return; - } - InsideFunc = true; - if (InFullScreen()) - { - ChangeFullScreen(); - for (int i = 0; i < 5; i++) - { - Sleep(50); - if (ProcessGuiMessages()) - { - break; - } - } - } - InsideFunc = false; + static bool InsideFunc = false; + if (InsideFunc) + { + return; + } + InsideFunc = true; + if (InFullScreen()) + { + ChangeFullScreen(); + for (int i = 0; i < 5; i++) + { + Sleep(50); + if (ProcessGuiMessages()) + { + break; + } + } + } + InsideFunc = false; } void CNotification::DisplayError(LanguageStringID StringID) const { - DisplayError(g_Lang->GetString(StringID).c_str()); + DisplayError(g_Lang->GetString(StringID).c_str()); } void CNotification::DisplayError(const wchar_t * Message) const { - if (this == NULL) { return; } + if (this == NULL) { return; } stdstr TraceMessage; - TraceMessage.FromUTF16(Message); - WriteTrace(TraceError,TraceMessage.c_str()); - WindowMode(); + TraceMessage.FromUTF16(Message); + WriteTrace(TraceError, TraceMessage.c_str()); + WindowMode(); - HWND Parent = NULL; - if (m_hWnd) - { - Parent = m_hWnd->GetHandle(); + HWND Parent = NULL; + if (m_hWnd) + { + Parent = reinterpret_cast(m_hWnd->GetWindowHandle()); } - MessageBoxW(Parent, Message, GS(MSG_MSGBOX_TITLE), MB_OK | MB_ICONERROR | MB_SETFOREGROUND); + MessageBoxW(Parent, Message, GS(MSG_MSGBOX_TITLE), MB_OK | MB_ICONERROR | MB_SETFOREGROUND); } void CNotification::DisplayMessage(int DisplayTime, LanguageStringID StringID) const { - DisplayMessage(DisplayTime, g_Lang->GetString(StringID).c_str()); + DisplayMessage(DisplayTime, g_Lang->GetString(StringID).c_str()); } void CNotification::DisplayMessage(int DisplayTime, const wchar_t * Message) const { - if (!m_hWnd) { return; } + if (!m_hWnd) { return; } - if (m_NextMsg > 0 || DisplayTime > 0) - { - time_t Now = time(NULL); - if (DisplayTime == 0 && Now < m_NextMsg) - { - return; - } - if (DisplayTime > 0) - { - m_NextMsg = Now + DisplayTime; - } - if (m_NextMsg == 0) - { - m_NextMsg = 0; - } - } - - if (InFullScreen()) - { - if (m_gfxPlugin && m_gfxPlugin->DrawStatus) - { - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": DrawStatus - Starting"); - stdstr PluginMessage; - PluginMessage.FromUTF16(Message); - m_gfxPlugin->DrawStatus(PluginMessage.c_str(), FALSE); - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": DrawStatus - Done"); - } - } - else + if (m_NextMsg > 0 || DisplayTime > 0) { -#if defined(WINDOWS_UI) - m_hWnd->SetStatusText(0, Message); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); -#endif - } + time_t Now = time(NULL); + if (DisplayTime == 0 && Now < m_NextMsg) + { + return; + } + if (DisplayTime > 0) + { + m_NextMsg = Now + DisplayTime; + } + if (m_NextMsg == 0) + { + m_NextMsg = 0; + } + } + + if (InFullScreen()) + { + if (m_gfxPlugin && m_gfxPlugin->DrawStatus) + { + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": DrawStatus - Starting"); + stdstr PluginMessage; + PluginMessage.FromUTF16(Message); + m_gfxPlugin->DrawStatus(PluginMessage.c_str(), FALSE); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": DrawStatus - Done"); + } + } + else + { + m_hWnd->SetStatusText(0, Message); + } } -void CNotification::DisplayMessage2 ( const wchar_t * Message ) const +void CNotification::DisplayMessage2(const wchar_t * Message) const { - if (!m_hWnd) { return; } + if (!m_hWnd) { return; } -#if defined(WINDOWS_UI) - m_hWnd->SetStatusText(1, Message); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); -#endif + m_hWnd->SetStatusText(1, Message); } -void CNotification::SetGfxPlugin( CGfxPlugin * Plugin ) +void CNotification::SetGfxPlugin(CGfxPlugin * Plugin) { - m_gfxPlugin = Plugin; + m_gfxPlugin = Plugin; } -void CNotification::SetWindowCaption (const wchar_t * Caption) +void CNotification::SetWindowCaption(const wchar_t * Caption) { - static const size_t TITLE_SIZE = 256; - wchar_t WinTitle[TITLE_SIZE]; + static const size_t TITLE_SIZE = 256; + wchar_t WinTitle[TITLE_SIZE]; - _snwprintf(WinTitle, TITLE_SIZE, L"%s - %s", Caption, g_Settings->LoadStringVal(Setting_ApplicationName).ToUTF16().c_str()); - WinTitle[TITLE_SIZE - 1] = 0; + _snwprintf(WinTitle, TITLE_SIZE, L"%s - %s", Caption, g_Settings->LoadStringVal(Setting_ApplicationName).ToUTF16().c_str()); + WinTitle[TITLE_SIZE - 1] = 0; #if defined(WINDOWS_UI) - m_hWnd->Caption(WinTitle); + m_hWnd->Caption(WinTitle); #else - g_Notify -> BreakPoint(__FILEW__, __LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); #endif } void CNotification::FatalError(LanguageStringID StringID) const { - FatalError(g_Lang->GetString(StringID).c_str()); + FatalError(g_Lang->GetString(StringID).c_str()); } void CNotification::FatalError(const wchar_t * Message) const { - WindowMode(); + WindowMode(); - HWND Parent = NULL; - if (m_hWnd) { Parent = reinterpret_cast(m_hWnd->GetHandle()); } - MessageBoxW(Parent, Message, L"Error", MB_OK | MB_ICONERROR | MB_SETFOREGROUND); - ExitThread(0); + HWND Parent = NULL; + if (m_hWnd) { Parent = reinterpret_cast(m_hWnd->GetWindowHandle()); } + MessageBoxW(Parent, Message, L"Error", MB_OK | MB_ICONERROR | MB_SETFOREGROUND); + ExitThread(0); } -void CNotification::AddRecentDir ( const char * RomDir ) +void CNotification::AddRecentDir(const char * RomDir) { - //Validate the passed string - if (HIWORD(RomDir) == NULL) { return; } + //Validate the passed string + if (HIWORD(RomDir) == NULL) { return; } - //Get Information about the stored rom list - size_t MaxRememberedDirs = g_Settings->LoadDword(Directory_RecentGameDirCount); - strlist RecentDirs; - size_t i; - for (i = 0; i < MaxRememberedDirs; i ++ ) - { - stdstr RecentDir = g_Settings->LoadStringIndex(Directory_RecentGameDirIndex,i); - if (RecentDir.empty()) - { - break; - } - RecentDirs.push_back(RecentDir); - } - - //See if the dir is already in the list if so then move it to the top of the list - strlist::iterator iter; - for (iter = RecentDirs.begin(); iter != RecentDirs.end(); iter++) - { - if (_stricmp(RomDir,iter->c_str()) != 0) - { - continue; - } - RecentDirs.erase(iter); - break; - } - RecentDirs.push_front(RomDir); - if (RecentDirs.size() > MaxRememberedDirs) - { - RecentDirs.pop_back(); - } - - for (i = 0, iter = RecentDirs.begin(); iter != RecentDirs.end(); iter++, i++) - { - g_Settings->SaveStringIndex(Directory_RecentGameDirIndex,i,*iter); - } -} - -void CNotification::AddRecentRom ( const char * ImagePath ) -{ - if (HIWORD(ImagePath) == NULL) { return; } - - //Get Information about the stored rom list - size_t MaxRememberedFiles = g_Settings->LoadDword(File_RecentGameFileCount); - strlist RecentGames; - size_t i; - for (i = 0; i < MaxRememberedFiles; i ++ ) - { - stdstr RecentGame = g_Settings->LoadStringIndex(File_RecentGameFileIndex,i); - if (RecentGame.empty()) - { - break; - } - RecentGames.push_back(RecentGame); - } - - //See if the dir is already in the list if so then move it to the top of the list - strlist::iterator iter; - for (iter = RecentGames.begin(); iter != RecentGames.end(); iter++) - { - if (_stricmp(ImagePath,iter->c_str()) != 0) - { - continue; - } - RecentGames.erase(iter); - break; - } - RecentGames.push_front(ImagePath); - if (RecentGames.size() > MaxRememberedFiles) - { - RecentGames.pop_back(); - } - - for (i = 0, iter = RecentGames.begin(); iter != RecentGames.end(); iter++, i++) - { - g_Settings->SaveStringIndex(File_RecentGameFileIndex,i,*iter); - } -} - -void CNotification::RefreshMenu ( void ) -{ - if (m_hWnd == NULL) { return; } - -#if defined(WINDOWS_UI) - m_hWnd->RefreshMenu(); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); -#endif -} - -void CNotification::HideRomBrowser ( void ) -{ - if (m_hWnd == NULL) { return; } - m_hWnd->HideRomList(); -} - -void CNotification::ShowRomBrowser ( void ) -{ - if (m_hWnd == NULL) { return; } - if (g_Settings->LoadDword(RomBrowser_Enabled)) + //Get Information about the stored rom list + size_t MaxRememberedDirs = g_Settings->LoadDword(Directory_RecentGameDirCount); + strlist RecentDirs; + size_t i; + for (i = 0; i < MaxRememberedDirs; i++) { - //Display the rom browser - m_hWnd->ShowRomList(); - m_hWnd->HighLightLastRom(); - } -} - -void CNotification::BringToTop ( void ) -{ - if (m_hWnd == NULL) { return; } - -#if defined(WINDOWS_UI) - m_hWnd->BringToTop(); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); -#endif -} - -void CNotification::MakeWindowOnTop ( bool OnTop ) -{ - if (m_hWnd == NULL) { return; } - -#if defined(WINDOWS_UI) - m_hWnd->MakeWindowOnTop(OnTop); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); -#endif -} - -void CNotification::ChangeFullScreen ( void ) const -{ - if (m_hWnd == NULL) { return; } - SendMessage((HWND)(m_hWnd->GetHandle()),WM_COMMAND,MAKELPARAM(ID_OPTIONS_FULLSCREEN2,false),0); -} - -bool CNotification::ProcessGuiMessages ( void ) const -{ - if (m_hWnd == NULL) { return false; } - -#if defined(WINDOWS_UI) - return m_hWnd->ProcessGuiMessages(); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); - return false; -#endif -} - -void CNotification::BreakPoint ( const wchar_t * FileName, const int LineNumber ) -{ - if (g_Settings->LoadBool(Debugger_Enabled)) - { - DisplayError(stdstr_f("Break point found at\n%ws\n%d", FileName, LineNumber).ToUTF16().c_str()); - if (IsDebuggerPresent() != 0) - { - DebugBreak(); - } - else + stdstr RecentDir = g_Settings->LoadStringIndex(Directory_RecentGameDirIndex, i); + if (RecentDir.empty()) { - g_BaseSystem->CloseCpu(); - } - } - else + break; + } + RecentDirs.push_back(RecentDir); + } + + //See if the dir is already in the list if so then move it to the top of the list + strlist::iterator iter; + for (iter = RecentDirs.begin(); iter != RecentDirs.end(); iter++) { - DisplayError(L"Fatal Error: Stopping emulation"); - g_BaseSystem->CloseCpu(); - } + if (_stricmp(RomDir, iter->c_str()) != 0) + { + continue; + } + RecentDirs.erase(iter); + break; + } + RecentDirs.push_front(RomDir); + if (RecentDirs.size() > MaxRememberedDirs) + { + RecentDirs.pop_back(); + } + + for (i = 0, iter = RecentDirs.begin(); iter != RecentDirs.end(); iter++, i++) + { + g_Settings->SaveStringIndex(Directory_RecentGameDirIndex, i, *iter); + } } + +void CNotification::AddRecentRom(const char * ImagePath) +{ + if (HIWORD(ImagePath) == NULL) { return; } + + //Get Information about the stored rom list + size_t MaxRememberedFiles = g_Settings->LoadDword(File_RecentGameFileCount); + strlist RecentGames; + size_t i; + for (i = 0; i < MaxRememberedFiles; i++) + { + stdstr RecentGame = g_Settings->LoadStringIndex(File_RecentGameFileIndex, i); + if (RecentGame.empty()) + { + break; + } + RecentGames.push_back(RecentGame); + } + + //See if the dir is already in the list if so then move it to the top of the list + strlist::iterator iter; + for (iter = RecentGames.begin(); iter != RecentGames.end(); iter++) + { + if (_stricmp(ImagePath, iter->c_str()) != 0) + { + continue; + } + RecentGames.erase(iter); + break; + } + RecentGames.push_front(ImagePath); + if (RecentGames.size() > MaxRememberedFiles) + { + RecentGames.pop_back(); + } + + for (i = 0, iter = RecentGames.begin(); iter != RecentGames.end(); iter++, i++) + { + g_Settings->SaveStringIndex(File_RecentGameFileIndex, i, *iter); + } +} + +void CNotification::RefreshMenu(void) +{ + if (m_hWnd == NULL) { return; } + +#if defined(WINDOWS_UI) + m_hWnd->RefreshMenu(); +#else + g_Notify->BreakPoint(__FILEW__, __LINE__); +#endif +} + +void CNotification::HideRomBrowser(void) +{ + if (m_hWnd == NULL) { return; } + m_hWnd->HideRomList(); +} + +void CNotification::ShowRomBrowser(void) +{ + if (m_hWnd == NULL) { return; } + if (g_Settings->LoadDword(RomBrowser_Enabled)) + { + //Display the rom browser + m_hWnd->ShowRomList(); + m_hWnd->HighLightLastRom(); + } +} + +void CNotification::BringToTop(void) +{ + if (m_hWnd == NULL) { return; } + +#if defined(WINDOWS_UI) + m_hWnd->BringToTop(); +#else + g_Notify->BreakPoint(__FILEW__, __LINE__); +#endif +} + +void CNotification::MakeWindowOnTop(bool OnTop) +{ + if (m_hWnd == NULL) { return; } + +#if defined(WINDOWS_UI) + m_hWnd->MakeWindowOnTop(OnTop); +#else + g_Notify->BreakPoint(__FILEW__, __LINE__); +#endif +} + +void CNotification::ChangeFullScreen(void) const +{ + if (m_hWnd == NULL) { return; } + SendMessage((HWND)(m_hWnd->GetWindowHandle()), WM_COMMAND, MAKELPARAM(ID_OPTIONS_FULLSCREEN2, false), 0); +} + +bool CNotification::ProcessGuiMessages(void) const +{ + if (m_hWnd == NULL) { return false; } + + return m_hWnd->ProcessGuiMessages(); +} + +void CNotification::BreakPoint(const wchar_t * FileName, const int LineNumber) +{ + if (g_Settings->LoadBool(Debugger_Enabled)) + { + DisplayError(stdstr_f("Break point found at\n%ws\n%d", FileName, LineNumber).ToUTF16().c_str()); + if (IsDebuggerPresent() != 0) + { + DebugBreak(); + } + else + { + g_BaseSystem->CloseCpu(); + } + } + else + { + DisplayError(L"Fatal Error: Stopping emulation"); + g_BaseSystem->CloseCpu(); + } +} \ No newline at end of file From 89361c57139778c684b618f5d37c97de8d2fbb27 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 12 Nov 2015 21:20:30 +1100 Subject: [PATCH 141/213] [Poject64] register callback for GameRunning_LoadingInProgress to refresh menu --- Source/Project64/N64 System/N64 Class.cpp | 8 -------- Source/Project64/User Interface/Gui Class.cpp | 7 +++++++ Source/Project64/User Interface/Gui Class.h | 1 + 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index b222b9958..9bfe6bdf3 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -180,13 +180,10 @@ bool CN64System::RunFileImage(const char * FileLoc) { return false; } - g_Settings->SaveBool(GameRunning_LoadingInProgress, true); - WriteTrace(TraceDebug, __FUNCTION__ ": Mark Rom as loading"); //Mark the rom as loading g_Settings->SaveBool(GameRunning_LoadingInProgress, true); - Notify().RefreshMenu(); //Try to load the passed N64 rom if (g_Rom == NULL) @@ -209,7 +206,6 @@ bool CN64System::RunFileImage(const char * FileLoc) Notify().SetWindowCaption(g_Settings->LoadStringVal(Game_GoodName).ToUTF16().c_str()); g_Settings->SaveBool(GameRunning_LoadingInProgress, false); - Notify().RefreshMenu(); if (g_Settings->LoadDword(Setting_AutoStart) != 0) { @@ -227,7 +223,6 @@ bool CN64System::RunFileImage(const char * FileLoc) delete g_Rom; g_Rom = NULL; g_Settings->SaveBool(GameRunning_LoadingInProgress, false); - Notify().RefreshMenu(); return false; } return true; @@ -254,7 +249,6 @@ bool CN64System::EmulationStarting(HANDLE hThread, DWORD ThreadId) g_BaseSystem->m_CPU_ThreadID = ThreadId; WriteTrace(TraceDebug, __FUNCTION__ ": Setting up N64 system done"); g_Settings->SaveBool(GameRunning_LoadingInProgress, false); - Notify().RefreshMenu(); try { WriteTrace(TraceDebug, __FUNCTION__ ": Game set to auto start, starting"); @@ -271,7 +265,6 @@ bool CN64System::EmulationStarting(HANDLE hThread, DWORD ThreadId) WriteTrace(TraceError, __FUNCTION__ ": SetActiveSystem failed"); g_Notify->DisplayError(__FUNCTIONW__ L": Failed to Initialize N64 System"); g_Settings->SaveBool(GameRunning_LoadingInProgress, false); - Notify().RefreshMenu(); bRes = false; } return bRes; @@ -336,7 +329,6 @@ void CN64System::StartEmulation2(bool NewThread) g_Settings->SaveBool(GameRunning_LoadingInProgress, false); g_Notify->DisplayError(MSG_PLUGIN_NOT_INIT); - Notify().RefreshMenu(); Notify().ShowRomBrowser(); } diff --git a/Source/Project64/User Interface/Gui Class.cpp b/Source/Project64/User Interface/Gui Class.cpp index ee2394dbb..6ecc23c69 100644 --- a/Source/Project64/User Interface/Gui Class.cpp +++ b/Source/Project64/User Interface/Gui Class.cpp @@ -49,6 +49,7 @@ m_ResetInfo(NULL) g_Settings->RegisterChangeCB(RomBrowser_Enabled, this, (CSettings::SettingChangedFunc)RomBowserEnabledChanged); g_Settings->RegisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); g_Settings->RegisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); + g_Settings->RegisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged); } //if this fails then it has already been created @@ -64,6 +65,7 @@ CMainGui::~CMainGui(void) g_Settings->UnregisterChangeCB(RomBrowser_Enabled, this, (CSettings::SettingChangedFunc)RomBowserEnabledChanged); g_Settings->UnregisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); g_Settings->UnregisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); + g_Settings->UnregisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged); } if (m_hMainWindow) { @@ -111,6 +113,11 @@ void RomBowserEnabledChanged(CMainGui * Gui) } } +void CMainGui::LoadingInProgressChanged(CMainGui * Gui) +{ + Gui->RefreshMenu(); +} + void RomBowserColoumnsChanged(CMainGui * Gui) { Gui->ResetRomBrowserColomuns(); diff --git a/Source/Project64/User Interface/Gui Class.h b/Source/Project64/User Interface/Gui Class.h index 0ab6b34f6..6d06c4fb1 100644 --- a/Source/Project64/User Interface/Gui Class.h +++ b/Source/Project64/User Interface/Gui Class.h @@ -110,6 +110,7 @@ private: friend void RomBowserEnabledChanged(CMainGui * Gui); friend void RomBowserColoumnsChanged(CMainGui * Gui); friend void RomBrowserRecursiveChanged(CMainGui * Gui); + static void LoadingInProgressChanged(CMainGui * Gui); CBaseMenu * m_Menu; From c997b6b1d94cbbb923e153ee96c6c9d167aa20c3 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 12 Nov 2015 21:38:10 +1100 Subject: [PATCH 142/213] [Project64] Get about ini window to be created with DialogBoxParamW --- Source/Project64/User Interface/Gui Class.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Source/Project64/User Interface/Gui Class.cpp b/Source/Project64/User Interface/Gui Class.cpp index 6ecc23c69..843a8d89c 100644 --- a/Source/Project64/User Interface/Gui Class.cpp +++ b/Source/Project64/User Interface/Gui Class.cpp @@ -160,7 +160,7 @@ void CMainGui::AboutBox(void) void CMainGui::AboutIniBox(void) { - DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_About_Ini), m_hMainWindow, (DLGPROC)AboutIniBoxProc, (LPARAM)this); + DialogBoxParamW(GetModuleHandle(NULL), MAKEINTRESOURCEW(IDD_About_Ini), m_hMainWindow, (DLGPROC)AboutIniBoxProc, (LPARAM)this); } DWORD CALLBACK AboutIniBoxProc(HWND hDlg, DWORD uMsg, DWORD wParam, DWORD /*lParam*/) @@ -173,10 +173,7 @@ DWORD CALLBACK AboutIniBoxProc(HWND hDlg, DWORD uMsg, DWORD wParam, DWORD /*lPar wchar_t String[200]; //Title - LONG_PTR originalWndProc = GetWindowLongPtrW(hDlg, GWLP_WNDPROC); - SetWindowLongPtrW(hDlg, GWLP_WNDPROC, (LONG_PTR)DefWindowProcW); SetWindowTextW(hDlg, GS(INI_TITLE)); - SetWindowLongPtrW(hDlg, GWLP_WNDPROC, originalWndProc); //Language SetDlgItemTextW(hDlg, IDC_LAN, GS(INI_CURRENT_LANG)); From 7f73838ffe1baf33015b4c9d173de280445388a5 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 12 Nov 2015 21:47:34 +1100 Subject: [PATCH 143/213] [Project64] Move Settings.h in to Settings directory --- Source/Project64/Plugins/Plugin List.h | 2 +- Source/Project64/Project64.vcxproj | 2 +- Source/Project64/Project64.vcxproj.filters | 6 +++--- Source/Project64/{ => Settings}/Settings.h | 0 Source/Project64/User Interface.h | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) rename Source/Project64/{ => Settings}/Settings.h (100%) diff --git a/Source/Project64/Plugins/Plugin List.h b/Source/Project64/Plugins/Plugin List.h index f1ee46064..04a566351 100644 --- a/Source/Project64/Plugins/Plugin List.h +++ b/Source/Project64/Plugins/Plugin List.h @@ -10,7 +10,7 @@ ****************************************************************************/ #pragma once -#include +#include class CPluginList { diff --git a/Source/Project64/Project64.vcxproj b/Source/Project64/Project64.vcxproj index 0cea30d80..517fca83e 100644 --- a/Source/Project64/Project64.vcxproj +++ b/Source/Project64/Project64.vcxproj @@ -183,7 +183,7 @@ - + diff --git a/Source/Project64/Project64.vcxproj.filters b/Source/Project64/Project64.vcxproj.filters index 1ae4ebd97..437ae1cbf 100644 --- a/Source/Project64/Project64.vcxproj.filters +++ b/Source/Project64/Project64.vcxproj.filters @@ -464,9 +464,6 @@ Header Files - - Header Files - Header Files @@ -833,5 +830,8 @@ Header Files + + Header Files\Settings Headers + \ No newline at end of file diff --git a/Source/Project64/Settings.h b/Source/Project64/Settings/Settings.h similarity index 100% rename from Source/Project64/Settings.h rename to Source/Project64/Settings/Settings.h diff --git a/Source/Project64/User Interface.h b/Source/Project64/User Interface.h index 9eaa923c0..1479e1d56 100644 --- a/Source/Project64/User Interface.h +++ b/Source/Project64/User Interface.h @@ -13,8 +13,8 @@ #pragma warning(disable:4786) #include "Support.h" -#include "Multilanguage.h" -#include "Settings.h" +#include +#include typedef unsigned char BYTE; typedef unsigned short WORD; From 51c89388c74d1944c07c9c0bfc7c2335306c4ad6 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 12 Nov 2015 22:00:47 +1100 Subject: [PATCH 144/213] [Project64] Cleanup Settings.h --- .../N64 System/Mips/Register Class.h | 1 + Source/Project64/N64 System/Profiling Class.h | 1 + .../N64 System/Recompiler/Recompiler Ops.h | 2 + .../N64 System/Speed Limitor Class.h | 2 + Source/Project64/Plugins/Plugin Class.h | 2 +- Source/Project64/Settings/Settings.h | 468 +++++++++--------- Source/Project64/User Interface/Gui Class.h | 1 + 7 files changed, 238 insertions(+), 239 deletions(-) diff --git a/Source/Project64/N64 System/Mips/Register Class.h b/Source/Project64/N64 System/Mips/Register Class.h index c2715c579..f782c6ceb 100644 --- a/Source/Project64/N64 System/Mips/Register Class.h +++ b/Source/Project64/N64 System/Mips/Register Class.h @@ -10,6 +10,7 @@ ****************************************************************************/ #pragma once +#include //CPO registers by name class CP0registers { diff --git a/Source/Project64/N64 System/Profiling Class.h b/Source/Project64/N64 System/Profiling Class.h index 0bf5d392e..daa3bf40d 100644 --- a/Source/Project64/N64 System/Profiling Class.h +++ b/Source/Project64/N64 System/Profiling Class.h @@ -9,6 +9,7 @@ * * ****************************************************************************/ #pragma once +#include "N64 Types.h" typedef std::map PROFILE_ENRTIES; typedef PROFILE_ENRTIES::iterator PROFILE_ENRTY; diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Ops.h b/Source/Project64/N64 System/Recompiler/Recompiler Ops.h index e7cce48a6..ed231e850 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Ops.h +++ b/Source/Project64/N64 System/Recompiler/Recompiler Ops.h @@ -10,6 +10,8 @@ ****************************************************************************/ #pragma once +#include +#include class CCodeSection; diff --git a/Source/Project64/N64 System/Speed Limitor Class.h b/Source/Project64/N64 System/Speed Limitor Class.h index 375d6bd82..7352d0c4d 100644 --- a/Source/Project64/N64 System/Speed Limitor Class.h +++ b/Source/Project64/N64 System/Speed Limitor Class.h @@ -10,6 +10,8 @@ ****************************************************************************/ #pragma once +#include "../Settings/Game Settings.h" + class CSpeedLimitor : private CGameSettings { diff --git a/Source/Project64/Plugins/Plugin Class.h b/Source/Project64/Plugins/Plugin Class.h index f0acbc5de..0ce075a91 100644 --- a/Source/Project64/Plugins/Plugin Class.h +++ b/Source/Project64/Plugins/Plugin Class.h @@ -10,7 +10,7 @@ ****************************************************************************/ #pragma once #include - +#include #ifndef PLUGIN_INFO_STRUCT #define PLUGIN_INFO_STRUCT diff --git a/Source/Project64/Settings/Settings.h b/Source/Project64/Settings/Settings.h index f4d74296b..f51b9700c 100644 --- a/Source/Project64/Settings/Settings.h +++ b/Source/Project64/Settings/Settings.h @@ -12,261 +12,253 @@ enum { - MaxPluginSetting = 65535 + MaxPluginSetting = 65535 }; enum SettingID { - //Default values - Default_None, - Default_Constant, + //Default values + Default_None, + Default_Constant, - //information - temp keys - Info_ShortCutsChanged, + //information - temp keys + Info_ShortCutsChanged, - //Support Files - SupportFile_Settings, - SupportFile_SettingsDefault, - SupportFile_RomDatabase, - SupportFile_RomDatabaseDefault, - SupportFile_Glide64RDB, - SupportFile_Glide64RDBDefault, - SupportFile_Cheats, - SupportFile_CheatsDefault, - SupportFile_Notes, - SupportFile_NotesDefault, - SupportFile_ExtInfo, - SupportFile_ExtInfoDefault, - SupportFile_ShortCuts, - SupportFile_ShortCutsDefault, - SupportFile_RomListCache, - SupportFile_RomListCacheDefault, - SupportFile_7zipCache, - SupportFile_7zipCacheDefault, + //Support Files + SupportFile_Settings, + SupportFile_SettingsDefault, + SupportFile_RomDatabase, + SupportFile_RomDatabaseDefault, + SupportFile_Glide64RDB, + SupportFile_Glide64RDBDefault, + SupportFile_Cheats, + SupportFile_CheatsDefault, + SupportFile_Notes, + SupportFile_NotesDefault, + SupportFile_ExtInfo, + SupportFile_ExtInfoDefault, + SupportFile_ShortCuts, + SupportFile_ShortCutsDefault, + SupportFile_RomListCache, + SupportFile_RomListCacheDefault, + SupportFile_7zipCache, + SupportFile_7zipCacheDefault, - //Settings - Setting_ApplicationName, - Setting_UseFromRegistry, - Setting_RdbEditor, - Setting_PluginPageFirst, - Setting_DisableScrSaver, - Setting_AutoSleep, - Setting_AutoStart, - Setting_AutoFullscreen, - Setting_CheckEmuRunning, - Setting_EraseGameDefaults, + //Settings + Setting_ApplicationName, + Setting_UseFromRegistry, + Setting_RdbEditor, + Setting_PluginPageFirst, + Setting_DisableScrSaver, + Setting_AutoSleep, + Setting_AutoStart, + Setting_AutoFullscreen, + Setting_CheckEmuRunning, + Setting_EraseGameDefaults, - Setting_AutoZipInstantSave, - Setting_RememberCheats, - Setting_LanguageDir, - Setting_LanguageDirDefault, - Setting_CurrentLanguage, + Setting_AutoZipInstantSave, + Setting_RememberCheats, + Setting_LanguageDir, + Setting_LanguageDirDefault, + Setting_CurrentLanguage, - //RDB TLB Settings - Rdb_GoodName, - Rdb_SaveChip, - Rdb_CpuType, - Rdb_RDRamSize, - Rdb_CounterFactor, - Rdb_UseTlb, - Rdb_DelayDP, - Rdb_DelaySi, - Rdb_32Bit, - Rdb_FastSP, - Rdb_Status, - Rdb_NotesCore, - Rdb_NotesPlugin, - Rdb_FixedAudio, - Rdb_SyncViaAudio, - Rdb_RspAudioSignal, - Rdb_TLB_VAddrStart, - Rdb_TLB_VAddrLen, - Rdb_TLB_PAddrStart, - Rdb_UseHleGfx, - Rdb_UseHleAudio, - Rdb_LoadRomToMemory, - Rdb_ScreenHertz, - Rdb_FuncLookupMode, - Rdb_RegCache, - Rdb_BlockLinking, - Rdb_SMM_StoreInstruc, - Rdb_SMM_Cache, - Rdb_SMM_PIDMA, - Rdb_SMM_TLB, - Rdb_SMM_Protect, - Rdb_SMM_ValidFunc, - Rdb_GameCheatFix, - Rdb_GameCheatFixPlugin, - Rdb_ViRefreshRate, - Rdb_AiCountPerBytes, - Rdb_AudioResetOnLoad, - Rdb_AllowROMWrites, - Rdb_CRC_Recalc, + //RDB TLB Settings + Rdb_GoodName, + Rdb_SaveChip, + Rdb_CpuType, + Rdb_RDRamSize, + Rdb_CounterFactor, + Rdb_UseTlb, + Rdb_DelayDP, + Rdb_DelaySi, + Rdb_32Bit, + Rdb_FastSP, + Rdb_Status, + Rdb_NotesCore, + Rdb_NotesPlugin, + Rdb_FixedAudio, + Rdb_SyncViaAudio, + Rdb_RspAudioSignal, + Rdb_TLB_VAddrStart, + Rdb_TLB_VAddrLen, + Rdb_TLB_PAddrStart, + Rdb_UseHleGfx, + Rdb_UseHleAudio, + Rdb_LoadRomToMemory, + Rdb_ScreenHertz, + Rdb_FuncLookupMode, + Rdb_RegCache, + Rdb_BlockLinking, + Rdb_SMM_StoreInstruc, + Rdb_SMM_Cache, + Rdb_SMM_PIDMA, + Rdb_SMM_TLB, + Rdb_SMM_Protect, + Rdb_SMM_ValidFunc, + Rdb_GameCheatFix, + Rdb_GameCheatFixPlugin, + Rdb_ViRefreshRate, + Rdb_AiCountPerBytes, + Rdb_AudioResetOnLoad, + Rdb_AllowROMWrites, + Rdb_CRC_Recalc, - //Individual Game Settings - Game_IniKey, - Game_GameName, - Game_GoodName, - Game_TempLoaded, - Game_SystemType, - Game_EditPlugin_Gfx, - Game_EditPlugin_Audio, - Game_EditPlugin_Contr, - Game_EditPlugin_RSP, - Game_Plugin_Gfx, - Game_Plugin_Audio, - Game_Plugin_Controller, - Game_Plugin_RSP, - Game_SaveChip, - Game_CpuType, - Game_LastSaveSlot, - Game_FixedAudio, - Game_SyncViaAudio, - Game_32Bit, - Game_SMM_Cache, - Game_SMM_Protect, - Game_SMM_ValidFunc, - Game_SMM_PIDMA, - Game_SMM_TLB, - Game_SMM_StoreInstruc, - Game_CurrentSaveState, - Game_RDRamSize, - Game_CounterFactor, - Game_UseTlb, - Game_DelayDP, - Game_DelaySI, - Game_FastSP, - Game_FuncLookupMode, - Game_RegCache, - Game_BlockLinking, - Game_ScreenHertz, - Game_RspAudioSignal, - Game_UseHleGfx, - Game_UseHleAudio, - Game_LoadRomToMemory, - Game_ViRefreshRate, - Game_AiCountPerBytes, - Game_AudioResetOnLoad, - Game_AllowROMWrites, - Game_CRC_Recalc, + //Individual Game Settings + Game_IniKey, + Game_GameName, + Game_GoodName, + Game_TempLoaded, + Game_SystemType, + Game_EditPlugin_Gfx, + Game_EditPlugin_Audio, + Game_EditPlugin_Contr, + Game_EditPlugin_RSP, + Game_Plugin_Gfx, + Game_Plugin_Audio, + Game_Plugin_Controller, + Game_Plugin_RSP, + Game_SaveChip, + Game_CpuType, + Game_LastSaveSlot, + Game_FixedAudio, + Game_SyncViaAudio, + Game_32Bit, + Game_SMM_Cache, + Game_SMM_Protect, + Game_SMM_ValidFunc, + Game_SMM_PIDMA, + Game_SMM_TLB, + Game_SMM_StoreInstruc, + Game_CurrentSaveState, + Game_RDRamSize, + Game_CounterFactor, + Game_UseTlb, + Game_DelayDP, + Game_DelaySI, + Game_FastSP, + Game_FuncLookupMode, + Game_RegCache, + Game_BlockLinking, + Game_ScreenHertz, + Game_RspAudioSignal, + Game_UseHleGfx, + Game_UseHleAudio, + Game_LoadRomToMemory, + Game_ViRefreshRate, + Game_AiCountPerBytes, + Game_AudioResetOnLoad, + Game_AllowROMWrites, + Game_CRC_Recalc, - // General Game running info - GameRunning_LoadingInProgress, - GameRunning_CPU_Running, - GameRunning_CPU_Paused, - GameRunning_CPU_PausedType, - GameRunning_InstantSaveFile, - GameRunning_LimitFPS, - GameRunning_ScreenHertz, - GameRunning_InReset, + // General Game running info + GameRunning_LoadingInProgress, + GameRunning_CPU_Running, + GameRunning_CPU_Paused, + GameRunning_CPU_PausedType, + GameRunning_InstantSaveFile, + GameRunning_LimitFPS, + GameRunning_ScreenHertz, + GameRunning_InReset, - //User Interface - UserInterface_BasicMode, - UserInterface_ShowCPUPer, - UserInterface_DisplayFrameRate, - UserInterface_InFullScreen, - UserInterface_FrameDisplayType, - UserInterface_MainWindowTop, - UserInterface_MainWindowLeft, - UserInterface_AlwaysOnTop, + //User Interface + UserInterface_BasicMode, + UserInterface_ShowCPUPer, + UserInterface_DisplayFrameRate, + UserInterface_InFullScreen, + UserInterface_FrameDisplayType, + UserInterface_MainWindowTop, + UserInterface_MainWindowLeft, + UserInterface_AlwaysOnTop, - RomBrowser_Enabled, - RomBrowser_ColoumnsChanged, - RomBrowser_Top, - RomBrowser_Left, - RomBrowser_Width, - RomBrowser_Height, - RomBrowser_PosIndex, - RomBrowser_WidthIndex, - RomBrowser_SortFieldIndex, - RomBrowser_SortAscendingIndex, - RomBrowser_Recursive, - RomBrowser_Maximized, + RomBrowser_Enabled, + RomBrowser_ColoumnsChanged, + RomBrowser_Top, + RomBrowser_Left, + RomBrowser_Width, + RomBrowser_Height, + RomBrowser_PosIndex, + RomBrowser_WidthIndex, + RomBrowser_SortFieldIndex, + RomBrowser_SortAscendingIndex, + RomBrowser_Recursive, + RomBrowser_Maximized, - //Directory Info - Directory_LastSave, - Directory_RecentGameDirCount, - Directory_RecentGameDirIndex, - Directory_Game, - Directory_GameInitial, - Directory_GameSelected, - Directory_GameUseSelected, - Directory_Plugin, - Directory_PluginInitial, - Directory_PluginSelected, - Directory_PluginUseSelected, - Directory_PluginSync, - Directory_SnapShot, - Directory_SnapShotInitial, - Directory_SnapShotSelected, - Directory_SnapShotUseSelected, - Directory_NativeSave, - Directory_NativeSaveInitial, - Directory_NativeSaveSelected, - Directory_NativeSaveUseSelected, - Directory_InstantSave, - Directory_InstantSaveInitial, - Directory_InstantSaveSelected, - Directory_InstantSaveUseSelected, - Directory_Texture, - Directory_TextureInitial, - Directory_TextureSelected, - Directory_TextureUseSelected, + //Directory Info + Directory_LastSave, + Directory_RecentGameDirCount, + Directory_RecentGameDirIndex, + Directory_Game, + Directory_GameInitial, + Directory_GameSelected, + Directory_GameUseSelected, + Directory_Plugin, + Directory_PluginInitial, + Directory_PluginSelected, + Directory_PluginUseSelected, + Directory_PluginSync, + Directory_SnapShot, + Directory_SnapShotInitial, + Directory_SnapShotSelected, + Directory_SnapShotUseSelected, + Directory_NativeSave, + Directory_NativeSaveInitial, + Directory_NativeSaveSelected, + Directory_NativeSaveUseSelected, + Directory_InstantSave, + Directory_InstantSaveInitial, + Directory_InstantSaveSelected, + Directory_InstantSaveUseSelected, + Directory_Texture, + Directory_TextureInitial, + Directory_TextureSelected, + Directory_TextureUseSelected, - //File Info - File_RecentGameFileCount, - File_RecentGameFileIndex, + //File Info + File_RecentGameFileCount, + File_RecentGameFileIndex, - //Debugger - Debugger_Enabled, - Debugger_ShowTLBMisses, - Debugger_ShowUnhandledMemory, - Debugger_ShowPifErrors, - Debugger_ShowDivByZero, - Debugger_GenerateLogFiles, - Debugger_ProfileCode, - Debugger_DisableGameFixes, - Debugger_AppLogLevel, - Debugger_AppLogFlush, - Debugger_GenerateDebugLog, - Debugger_ShowDListAListCount, - Debugger_ShowRecompMemSize, + //Debugger + Debugger_Enabled, + Debugger_ShowTLBMisses, + Debugger_ShowUnhandledMemory, + Debugger_ShowPifErrors, + Debugger_ShowDivByZero, + Debugger_GenerateLogFiles, + Debugger_ProfileCode, + Debugger_DisableGameFixes, + Debugger_AppLogLevel, + Debugger_AppLogFlush, + Debugger_GenerateDebugLog, + Debugger_ShowDListAListCount, + Debugger_ShowRecompMemSize, - //Plugins - Plugin_RSP_Current, - Plugin_RSP_CurVer, - Plugin_GFX_Current, - Plugin_GFX_CurVer, - Plugin_AUDIO_Current, - Plugin_AUDIO_CurVer, - Plugin_CONT_Current, - Plugin_CONT_CurVer, - Plugin_UseHleGfx, - Plugin_UseHleAudio, + //Plugins + Plugin_RSP_Current, + Plugin_RSP_CurVer, + Plugin_GFX_Current, + Plugin_GFX_CurVer, + Plugin_AUDIO_Current, + Plugin_AUDIO_CurVer, + Plugin_CONT_Current, + Plugin_CONT_CurVer, + Plugin_UseHleGfx, + Plugin_UseHleAudio, - //Cheats - Cheat_Entry, - Cheat_Active, - Cheat_Extension, - Cheat_Notes, - Cheat_Options, - Cheat_Range, - Cheat_RangeNotes, + //Cheats + Cheat_Entry, + Cheat_Active, + Cheat_Extension, + Cheat_Notes, + Cheat_Options, + Cheat_Range, + Cheat_RangeNotes, - FirstRSPDefaultSet, LastRSPDefaultSet = FirstRSPDefaultSet + MaxPluginSetting, - FirstRSPSettings, LastRSPSettings = FirstRSPSettings + MaxPluginSetting, - FirstGfxDefaultSet, LastGfxDefaultSet = FirstGfxDefaultSet + MaxPluginSetting, - FirstGfxSettings, LastGfxSettings = FirstGfxSettings + MaxPluginSetting, - FirstAudioDefaultSet, LastAudioDefaultSet = FirstAudioDefaultSet + MaxPluginSetting, - FirstAudioSettings, LastAudioSettings = FirstAudioSettings + MaxPluginSetting, - FirstCtrlDefaultSet, LastCtrlDefaultSet = FirstCtrlDefaultSet + MaxPluginSetting, - FirstCtrlSettings, LastCtrlSettings = FirstCtrlSettings + MaxPluginSetting, + FirstRSPDefaultSet, LastRSPDefaultSet = FirstRSPDefaultSet + MaxPluginSetting, + FirstRSPSettings, LastRSPSettings = FirstRSPSettings + MaxPluginSetting, + FirstGfxDefaultSet, LastGfxDefaultSet = FirstGfxDefaultSet + MaxPluginSetting, + FirstGfxSettings, LastGfxSettings = FirstGfxSettings + MaxPluginSetting, + FirstAudioDefaultSet, LastAudioDefaultSet = FirstAudioDefaultSet + MaxPluginSetting, + FirstAudioSettings, LastAudioSettings = FirstAudioSettings + MaxPluginSetting, + FirstCtrlDefaultSet, LastCtrlDefaultSet = FirstCtrlDefaultSet + MaxPluginSetting, + FirstCtrlSettings, LastCtrlSettings = FirstCtrlSettings + MaxPluginSetting, }; - -#include "Support.h" -#include "./Settings/Settings Class.h" -#include "./Settings/Debug Settings.h" -#include "./Settings/Game Settings.h" -#include "./Settings/Recompiler Settings.h" -#include "./Settings/N64System Settings.h" -#include "./Settings/Gui Settings.h" diff --git a/Source/Project64/User Interface/Gui Class.h b/Source/Project64/User Interface/Gui Class.h index 6d06c4fb1..6cbdc625f 100644 --- a/Source/Project64/User Interface/Gui Class.h +++ b/Source/Project64/User Interface/Gui Class.h @@ -10,6 +10,7 @@ ****************************************************************************/ #pragma once +#include "../Settings/Gui Settings.h" #include #include From 73d7263de0f7ad368abff84d881005b0e9a0b3a0 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 12 Nov 2015 22:27:19 +1100 Subject: [PATCH 145/213] [Project64] Add GameLoaded setting --- Source/Project64/N64 System/N64 Class.cpp | 11 +- Source/Project64/Settings/Settings Class.cpp | 852 +++++++++--------- Source/Project64/Settings/Settings.h | 1 + Source/Project64/User Interface/Gui Class.cpp | 15 + Source/Project64/User Interface/Gui Class.h | 1 + 5 files changed, 463 insertions(+), 417 deletions(-) diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index 9bfe6bdf3..6b4b9c732 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -181,6 +181,7 @@ bool CN64System::RunFileImage(const char * FileLoc) return false; } WriteTrace(TraceDebug, __FUNCTION__ ": Mark Rom as loading"); + g_Settings->SaveString(Game_File, ""); //Mark the rom as loading g_Settings->SaveBool(GameRunning_LoadingInProgress, true); @@ -201,10 +202,7 @@ bool CN64System::RunFileImage(const char * FileLoc) { g_System->RefreshGameSettings(); - WriteTrace(TraceDebug, __FUNCTION__ ": Add Recent Rom"); - Notify().AddRecentRom(FileLoc); - Notify().SetWindowCaption(g_Settings->LoadStringVal(Game_GoodName).ToUTF16().c_str()); - + g_Settings->SaveString(Game_File, FileLoc); g_Settings->SaveBool(GameRunning_LoadingInProgress, false); if (g_Settings->LoadDword(Setting_AutoStart) != 0) @@ -275,9 +273,6 @@ void CN64System::StartEmulation2(bool NewThread) if (NewThread) { WriteTrace(TraceDebug, __FUNCTION__ ": Starting"); - - Notify().HideRomBrowser(); - if (bHaveDebugger()) { g_LogOptions.GenerateLog = g_Settings->LoadBool(Debugger_GenerateDebugLog); @@ -1805,7 +1800,7 @@ bool CN64System::LoadState(LPCSTR FileName) SetActiveSystem(true); SyncCPU(m_SyncCPU); } - } +} WriteTrace(TraceDebug, __FUNCTION__ ": 13"); std::wstring LoadMsg = g_Lang->GetString(MSG_LOADED_STATE); g_Notify->DisplayMessage(5, stdstr_f("%s %s", LoadMsg.c_str(), CPath(FileNameStr).GetNameExtension()).ToUTF16().c_str()); diff --git a/Source/Project64/Settings/Settings Class.cpp b/Source/Project64/Settings/Settings Class.cpp index 6e1e943c2..b6a4a6400 100644 --- a/Source/Project64/Settings/Settings Class.cpp +++ b/Source/Project64/Settings/Settings Class.cpp @@ -35,7 +35,7 @@ CSettings * g_Settings = NULL; CSettings::CSettings() : - m_NextAutoSettingId(0x200000) +m_NextAutoSettingId(0x200000) { } @@ -63,14 +63,14 @@ CSettings::~CSettings() } } -void CSettings::AddHandler ( SettingID TypeID, CSettingType * Handler ) +void CSettings::AddHandler(SettingID TypeID, CSettingType * Handler) { - SETTING_MAP::_Pairib res = m_SettingInfo.insert(SETTING_MAP::value_type(TypeID,Handler)); + SETTING_MAP::_Pairib res = m_SettingInfo.insert(SETTING_MAP::value_type(TypeID, Handler)); if (!res.second) { delete res.first->second; m_SettingInfo.erase(res.first); - res = m_SettingInfo.insert(SETTING_MAP::value_type(TypeID,Handler)); + res = m_SettingInfo.insert(SETTING_MAP::value_type(TypeID, Handler)); if (!res.second) { delete Handler; @@ -78,183 +78,184 @@ void CSettings::AddHandler ( SettingID TypeID, CSettingType * Handler ) } } -void CSettings::AddHowToHandleSetting () +void CSettings::AddHowToHandleSetting() { //information - temp keys - AddHandler(Info_ShortCutsChanged, new CSettingTypeTempBool(false)); + AddHandler(Info_ShortCutsChanged, new CSettingTypeTempBool(false)); //Support Files - AddHandler(SupportFile_Settings, new CSettingTypeApplicationPath("","ConfigFile",SupportFile_SettingsDefault)); - AddHandler(SupportFile_SettingsDefault, new CSettingTypeRelativePath("Config","Project64.cfg")); - AddHandler(SupportFile_RomDatabase, new CSettingTypeApplicationPath("","RomDatabase",SupportFile_RomDatabaseDefault)); - AddHandler(SupportFile_RomDatabaseDefault, new CSettingTypeRelativePath("Config","Project64.rdb")); - AddHandler(SupportFile_Glide64RDB, new CSettingTypeApplicationPath("","Glide64RDB",SupportFile_Glide64RDBDefault)); - AddHandler(SupportFile_Glide64RDBDefault, new CSettingTypeRelativePath("Config","Glide64.rdb")); - AddHandler(SupportFile_Cheats, new CSettingTypeApplicationPath("","Cheats",SupportFile_CheatsDefault)); - AddHandler(SupportFile_CheatsDefault, new CSettingTypeRelativePath("Config","Project64.cht")); - AddHandler(SupportFile_Notes, new CSettingTypeApplicationPath("","Notes",SupportFile_NotesDefault)); - AddHandler(SupportFile_NotesDefault, new CSettingTypeRelativePath("Config","Project64.rdn")); - AddHandler(SupportFile_ExtInfo, new CSettingTypeApplicationPath("","ExtInfo",SupportFile_ExtInfoDefault)); - AddHandler(SupportFile_ExtInfoDefault, new CSettingTypeRelativePath("Config","Project64.rdx")); - AddHandler(SupportFile_ShortCuts, new CSettingTypeApplicationPath("","ShortCuts",SupportFile_ShortCutsDefault)); - AddHandler(SupportFile_ShortCutsDefault, new CSettingTypeRelativePath("Config","Project64.sc3")); - AddHandler(SupportFile_RomListCache, new CSettingTypeApplicationPath("","RomListCache",SupportFile_RomListCacheDefault)); - AddHandler(SupportFile_RomListCacheDefault,new CSettingTypeRelativePath("Config","Project64.cache3")); - AddHandler(SupportFile_7zipCache, new CSettingTypeApplicationPath("","7zipCache",SupportFile_7zipCacheDefault)); - AddHandler(SupportFile_7zipCacheDefault, new CSettingTypeRelativePath("Config","Project64.zcache")); + AddHandler(SupportFile_Settings, new CSettingTypeApplicationPath("", "ConfigFile", SupportFile_SettingsDefault)); + AddHandler(SupportFile_SettingsDefault, new CSettingTypeRelativePath("Config", "Project64.cfg")); + AddHandler(SupportFile_RomDatabase, new CSettingTypeApplicationPath("", "RomDatabase", SupportFile_RomDatabaseDefault)); + AddHandler(SupportFile_RomDatabaseDefault, new CSettingTypeRelativePath("Config", "Project64.rdb")); + AddHandler(SupportFile_Glide64RDB, new CSettingTypeApplicationPath("", "Glide64RDB", SupportFile_Glide64RDBDefault)); + AddHandler(SupportFile_Glide64RDBDefault, new CSettingTypeRelativePath("Config", "Glide64.rdb")); + AddHandler(SupportFile_Cheats, new CSettingTypeApplicationPath("", "Cheats", SupportFile_CheatsDefault)); + AddHandler(SupportFile_CheatsDefault, new CSettingTypeRelativePath("Config", "Project64.cht")); + AddHandler(SupportFile_Notes, new CSettingTypeApplicationPath("", "Notes", SupportFile_NotesDefault)); + AddHandler(SupportFile_NotesDefault, new CSettingTypeRelativePath("Config", "Project64.rdn")); + AddHandler(SupportFile_ExtInfo, new CSettingTypeApplicationPath("", "ExtInfo", SupportFile_ExtInfoDefault)); + AddHandler(SupportFile_ExtInfoDefault, new CSettingTypeRelativePath("Config", "Project64.rdx")); + AddHandler(SupportFile_ShortCuts, new CSettingTypeApplicationPath("", "ShortCuts", SupportFile_ShortCutsDefault)); + AddHandler(SupportFile_ShortCutsDefault, new CSettingTypeRelativePath("Config", "Project64.sc3")); + AddHandler(SupportFile_RomListCache, new CSettingTypeApplicationPath("", "RomListCache", SupportFile_RomListCacheDefault)); + AddHandler(SupportFile_RomListCacheDefault, new CSettingTypeRelativePath("Config", "Project64.cache3")); + AddHandler(SupportFile_7zipCache, new CSettingTypeApplicationPath("", "7zipCache", SupportFile_7zipCacheDefault)); + AddHandler(SupportFile_7zipCacheDefault, new CSettingTypeRelativePath("Config", "Project64.zcache")); //AddHandler(SyncPluginDir, new CSettingTypeRelativePath("SyncPlugin","")); //Settings location AddHandler(Setting_ApplicationName, new CSettingTypeTempString("")); - AddHandler(Setting_UseFromRegistry, new CSettingTypeApplication("Settings","Use Registry",(uint32_t)false)); - AddHandler(Setting_RdbEditor, new CSettingTypeApplication("","Rdb Editor", false)); - AddHandler(Setting_PluginPageFirst, new CSettingTypeApplication("","Plugin Page First", false)); - AddHandler(Setting_DisableScrSaver, new CSettingTypeApplication("","Disable Screen Saver",(uint32_t)true)); - AddHandler(Setting_AutoSleep, new CSettingTypeApplication("","Auto Sleep", (uint32_t)true)); - AddHandler(Setting_AutoStart, new CSettingTypeApplication("","Auto Start", (uint32_t)true)); - AddHandler(Setting_AutoFullscreen, new CSettingTypeApplication("","Auto Full Screen", (uint32_t)false)); - AddHandler(Setting_AutoZipInstantSave,new CSettingTypeApplication("","Auto Zip Saves", (uint32_t)true)); - AddHandler(Setting_EraseGameDefaults, new CSettingTypeApplication("","Erase on default", (uint32_t)true)); - AddHandler(Setting_CheckEmuRunning, new CSettingTypeApplication("","Check Running", (uint32_t)true)); + AddHandler(Setting_UseFromRegistry, new CSettingTypeApplication("Settings", "Use Registry", (uint32_t)false)); + AddHandler(Setting_RdbEditor, new CSettingTypeApplication("", "Rdb Editor", false)); + AddHandler(Setting_PluginPageFirst, new CSettingTypeApplication("", "Plugin Page First", false)); + AddHandler(Setting_DisableScrSaver, new CSettingTypeApplication("", "Disable Screen Saver", (uint32_t)true)); + AddHandler(Setting_AutoSleep, new CSettingTypeApplication("", "Auto Sleep", (uint32_t)true)); + AddHandler(Setting_AutoStart, new CSettingTypeApplication("", "Auto Start", (uint32_t)true)); + AddHandler(Setting_AutoFullscreen, new CSettingTypeApplication("", "Auto Full Screen", (uint32_t)false)); + AddHandler(Setting_AutoZipInstantSave, new CSettingTypeApplication("", "Auto Zip Saves", (uint32_t)true)); + AddHandler(Setting_EraseGameDefaults, new CSettingTypeApplication("", "Erase on default", (uint32_t)true)); + AddHandler(Setting_CheckEmuRunning, new CSettingTypeApplication("", "Check Running", (uint32_t)true)); - AddHandler(Setting_RememberCheats, new CSettingTypeApplication("","Remember Cheats", (uint32_t)false)); - AddHandler(Setting_CurrentLanguage, new CSettingTypeApplication("","Current Language","")); - AddHandler(Setting_LanguageDirDefault, new CSettingTypeRelativePath("Lang","")); - AddHandler(Setting_LanguageDir, new CSettingTypeApplicationPath("Directory","Lang",Setting_LanguageDirDefault)); + AddHandler(Setting_RememberCheats, new CSettingTypeApplication("", "Remember Cheats", (uint32_t)false)); + AddHandler(Setting_CurrentLanguage, new CSettingTypeApplication("", "Current Language", "")); + AddHandler(Setting_LanguageDirDefault, new CSettingTypeRelativePath("Lang", "")); + AddHandler(Setting_LanguageDir, new CSettingTypeApplicationPath("Directory", "Lang", Setting_LanguageDirDefault)); - AddHandler(Rdb_GoodName, new CSettingTypeRomDatabase("Good Name",Game_GameName)); - AddHandler(Rdb_SaveChip, new CSettingTypeRDBSaveChip("Save Type",SaveChip_Auto)); + AddHandler(Rdb_GoodName, new CSettingTypeRomDatabase("Good Name", Game_GameName)); + AddHandler(Rdb_SaveChip, new CSettingTypeRDBSaveChip("Save Type", SaveChip_Auto)); #ifdef _DEBUG - AddHandler(Rdb_CpuType, new CSettingTypeRDBCpuType("CPU Type",CPU_SyncCores)); + AddHandler(Rdb_CpuType, new CSettingTypeRDBCpuType("CPU Type", CPU_SyncCores)); #else - AddHandler(Rdb_CpuType, new CSettingTypeRDBCpuType("CPU Type",CPU_Recompiler)); + AddHandler(Rdb_CpuType, new CSettingTypeRDBCpuType("CPU Type", CPU_Recompiler)); #endif - AddHandler(Rdb_RDRamSize, new CSettingTypeRDBRDRamSize("RDRAM Size",0x400000)); - AddHandler(Rdb_CounterFactor, new CSettingTypeRomDatabase("Counter Factor",2)); - AddHandler(Rdb_UseTlb, new CSettingTypeRDBYesNo("Use TLB",true)); - AddHandler(Rdb_DelayDP, new CSettingTypeRDBYesNo("Delay DP",true)); - AddHandler(Rdb_DelaySi, new CSettingTypeRDBYesNo("Delay SI",false)); - AddHandler(Rdb_32Bit, new CSettingTypeRDBYesNo("32bit",true)); - AddHandler(Rdb_FastSP, new CSettingTypeRDBYesNo("Fast SP",true)); - AddHandler(Rdb_Status, new CSettingTypeRomDatabase("Status","Unknown")); - AddHandler(Rdb_NotesCore, new CSettingTypeRomDatabase("Core Note","")); - AddHandler(Rdb_NotesPlugin, new CSettingTypeRomDatabase("Plugin Note","")); + AddHandler(Rdb_RDRamSize, new CSettingTypeRDBRDRamSize("RDRAM Size", 0x400000)); + AddHandler(Rdb_CounterFactor, new CSettingTypeRomDatabase("Counter Factor", 2)); + AddHandler(Rdb_UseTlb, new CSettingTypeRDBYesNo("Use TLB", true)); + AddHandler(Rdb_DelayDP, new CSettingTypeRDBYesNo("Delay DP", true)); + AddHandler(Rdb_DelaySi, new CSettingTypeRDBYesNo("Delay SI", false)); + AddHandler(Rdb_32Bit, new CSettingTypeRDBYesNo("32bit", true)); + AddHandler(Rdb_FastSP, new CSettingTypeRDBYesNo("Fast SP", true)); + AddHandler(Rdb_Status, new CSettingTypeRomDatabase("Status", "Unknown")); + AddHandler(Rdb_NotesCore, new CSettingTypeRomDatabase("Core Note", "")); + AddHandler(Rdb_NotesPlugin, new CSettingTypeRomDatabase("Plugin Note", "")); #ifdef _DEBUG - AddHandler(Rdb_FixedAudio, new CSettingTypeRomDatabase("Fixed Audio",true)); + AddHandler(Rdb_FixedAudio, new CSettingTypeRomDatabase("Fixed Audio", true)); #else - AddHandler(Rdb_FixedAudio, new CSettingTypeRomDatabase("Fixed Audio",false)); + AddHandler(Rdb_FixedAudio, new CSettingTypeRomDatabase("Fixed Audio", false)); #endif - AddHandler(Rdb_SyncViaAudio, new CSettingTypeRomDatabase("Sync Audio",true)); - AddHandler(Rdb_RspAudioSignal, new CSettingTypeRDBYesNo("Audio Signal",false)); - AddHandler(Rdb_TLB_VAddrStart, new CSettingTypeRomDatabase("TLB: Vaddr Start",0)); - AddHandler(Rdb_TLB_VAddrLen, new CSettingTypeRomDatabase("TLB: Vaddr Len",0)); - AddHandler(Rdb_TLB_PAddrStart, new CSettingTypeRomDatabase("TLB: PAddr Start",0)); - AddHandler(Rdb_UseHleGfx, new CSettingTypeRomDatabase("HLE GFX",Plugin_UseHleGfx)); - AddHandler(Rdb_UseHleAudio, new CSettingTypeRomDatabase("HLE Audio",Plugin_UseHleAudio)); - AddHandler(Rdb_LoadRomToMemory, new CSettingTypeRomDatabase("Rom In Memory",false)); - AddHandler(Rdb_ScreenHertz, new CSettingTypeRomDatabase("ScreenHertz",0)); - AddHandler(Rdb_FuncLookupMode, new CSettingTypeRomDatabase("FuncFind",FuncFind_PhysicalLookup)); - AddHandler(Rdb_RegCache, new CSettingTypeRDBYesNo("Reg Cache",true)); - AddHandler(Rdb_BlockLinking, new CSettingTypeRDBOnOff("Linking",true)); - AddHandler(Rdb_SMM_Cache, new CSettingTypeRomDatabase("SMM-Cache",true)); - AddHandler(Rdb_SMM_StoreInstruc, new CSettingTypeRomDatabase("SMM-StoreInstr",false)); - AddHandler(Rdb_SMM_PIDMA, new CSettingTypeRomDatabase("SMM-PI DMA",true)); - AddHandler(Rdb_SMM_TLB, new CSettingTypeRomDatabase("SMM-TLB",true)); - AddHandler(Rdb_SMM_Protect, new CSettingTypeRomDatabase("SMM-Protect",false)); - AddHandler(Rdb_SMM_ValidFunc, new CSettingTypeRomDatabase("SMM-FUNC",true)); - AddHandler(Rdb_GameCheatFix, new CSettingTypeRomDatabaseIndex("Cheat","","")); - AddHandler(Rdb_GameCheatFixPlugin, new CSettingTypeRomDatabaseIndex("CheatPlugin","","")); - AddHandler(Rdb_ViRefreshRate, new CSettingTypeRomDatabase("ViRefresh",1500)); - AddHandler(Rdb_AiCountPerBytes, new CSettingTypeRomDatabase("AiCountPerBytes",400)); - AddHandler(Rdb_AudioResetOnLoad, new CSettingTypeRDBYesNo("AudioResetOnLoad", false)); - AddHandler(Rdb_AllowROMWrites, new CSettingTypeRDBYesNo("AllowROMWrites", false)); - AddHandler(Rdb_CRC_Recalc, new CSettingTypeRDBYesNo("CRC-Recalc", false)); + AddHandler(Rdb_SyncViaAudio, new CSettingTypeRomDatabase("Sync Audio", true)); + AddHandler(Rdb_RspAudioSignal, new CSettingTypeRDBYesNo("Audio Signal", false)); + AddHandler(Rdb_TLB_VAddrStart, new CSettingTypeRomDatabase("TLB: Vaddr Start", 0)); + AddHandler(Rdb_TLB_VAddrLen, new CSettingTypeRomDatabase("TLB: Vaddr Len", 0)); + AddHandler(Rdb_TLB_PAddrStart, new CSettingTypeRomDatabase("TLB: PAddr Start", 0)); + AddHandler(Rdb_UseHleGfx, new CSettingTypeRomDatabase("HLE GFX", Plugin_UseHleGfx)); + AddHandler(Rdb_UseHleAudio, new CSettingTypeRomDatabase("HLE Audio", Plugin_UseHleAudio)); + AddHandler(Rdb_LoadRomToMemory, new CSettingTypeRomDatabase("Rom In Memory", false)); + AddHandler(Rdb_ScreenHertz, new CSettingTypeRomDatabase("ScreenHertz", 0)); + AddHandler(Rdb_FuncLookupMode, new CSettingTypeRomDatabase("FuncFind", FuncFind_PhysicalLookup)); + AddHandler(Rdb_RegCache, new CSettingTypeRDBYesNo("Reg Cache", true)); + AddHandler(Rdb_BlockLinking, new CSettingTypeRDBOnOff("Linking", true)); + AddHandler(Rdb_SMM_Cache, new CSettingTypeRomDatabase("SMM-Cache", true)); + AddHandler(Rdb_SMM_StoreInstruc, new CSettingTypeRomDatabase("SMM-StoreInstr", false)); + AddHandler(Rdb_SMM_PIDMA, new CSettingTypeRomDatabase("SMM-PI DMA", true)); + AddHandler(Rdb_SMM_TLB, new CSettingTypeRomDatabase("SMM-TLB", true)); + AddHandler(Rdb_SMM_Protect, new CSettingTypeRomDatabase("SMM-Protect", false)); + AddHandler(Rdb_SMM_ValidFunc, new CSettingTypeRomDatabase("SMM-FUNC", true)); + AddHandler(Rdb_GameCheatFix, new CSettingTypeRomDatabaseIndex("Cheat", "", "")); + AddHandler(Rdb_GameCheatFixPlugin, new CSettingTypeRomDatabaseIndex("CheatPlugin", "", "")); + AddHandler(Rdb_ViRefreshRate, new CSettingTypeRomDatabase("ViRefresh", 1500)); + AddHandler(Rdb_AiCountPerBytes, new CSettingTypeRomDatabase("AiCountPerBytes", 400)); + AddHandler(Rdb_AudioResetOnLoad, new CSettingTypeRDBYesNo("AudioResetOnLoad", false)); + AddHandler(Rdb_AllowROMWrites, new CSettingTypeRDBYesNo("AllowROMWrites", false)); + AddHandler(Rdb_CRC_Recalc, new CSettingTypeRDBYesNo("CRC-Recalc", false)); - AddHandler(Game_IniKey, new CSettingTypeTempString("")); - AddHandler(Game_GameName, new CSettingTypeTempString("")); - AddHandler(Game_GoodName, new CSettingTypeGame("Good Name",Rdb_GoodName)); - AddHandler(Game_TempLoaded, new CSettingTypeTempBool(false)); - AddHandler(Game_SystemType, new CSettingTypeTempNumber(SYSTEM_NTSC)); - AddHandler(Game_EditPlugin_Gfx, new CSettingTypeGame("Plugin-Gfx",Default_None)); - AddHandler(Game_EditPlugin_Audio, new CSettingTypeGame("Plugin-Audio",Default_None)); - AddHandler(Game_EditPlugin_Contr, new CSettingTypeGame("Plugin-Controller",Default_None)); - AddHandler(Game_EditPlugin_RSP, new CSettingTypeGame("Plugin-RSP",Default_None)); - AddHandler(Game_Plugin_Gfx, new CSettingTypeGame("Plugin-Gfx",Plugin_GFX_Current)); - AddHandler(Game_Plugin_Audio, new CSettingTypeGame("Plugin-Audio",Plugin_AUDIO_Current)); - AddHandler(Game_Plugin_Controller, new CSettingTypeGame("Plugin-Controller",Plugin_CONT_Current)); - AddHandler(Game_Plugin_RSP, new CSettingTypeGame("Plugin-RSP",Plugin_RSP_Current)); - AddHandler(Game_SaveChip, new CSettingTypeGame("SaveChip",Rdb_SaveChip)); - AddHandler(Game_CpuType, new CSettingTypeGame("CpuType",Rdb_CpuType)); - AddHandler(Game_LastSaveSlot, new CSettingTypeGame("Last Used Save Slot",(uint32_t)0)); - AddHandler(Game_FixedAudio, new CSettingTypeGame("Fixed Audio",Rdb_FixedAudio)); - AddHandler(Game_RDRamSize, new CSettingTypeGame("RDRamSize",Rdb_RDRamSize)); - AddHandler(Game_CounterFactor, new CSettingTypeGame("Counter Factor",Rdb_CounterFactor)); - AddHandler(Game_UseTlb, new CSettingTypeGame("Use TLB",Rdb_UseTlb)); - AddHandler(Game_DelayDP, new CSettingTypeGame("Delay DP",Rdb_DelayDP)); - AddHandler(Game_DelaySI, new CSettingTypeGame("Delay SI",Rdb_DelaySi)); - AddHandler(Game_RspAudioSignal, new CSettingTypeGame("Audio Signal",Rdb_RspAudioSignal)); - AddHandler(Game_32Bit, new CSettingTypeGame("32bit",Rdb_32Bit)); - AddHandler(Game_FastSP, new CSettingTypeGame("Fast SP",Rdb_FastSP)); - AddHandler(Game_CurrentSaveState, new CSettingTypeTempNumber(0)); - AddHandler(Game_SyncViaAudio, new CSettingTypeGame("Sync Audio",Rdb_SyncViaAudio)); - AddHandler(Game_UseHleGfx, new CSettingTypeGame("HLE GFX",Rdb_UseHleGfx)); - AddHandler(Game_UseHleAudio, new CSettingTypeGame("HLE Audio",Rdb_UseHleAudio)); - AddHandler(Game_LoadRomToMemory, new CSettingTypeGame("Rom In Memory",Rdb_LoadRomToMemory)); - AddHandler(Game_ScreenHertz, new CSettingTypeGame("ScreenHertz",Rdb_ScreenHertz)); - AddHandler(Game_FuncLookupMode, new CSettingTypeGame("FuncFind",Rdb_FuncLookupMode)); - AddHandler(Game_RegCache, new CSettingTypeGame("Reg Cache",Rdb_RegCache)); - AddHandler(Game_BlockLinking, new CSettingTypeGame("Linking",Rdb_BlockLinking)); - AddHandler(Game_SMM_StoreInstruc, new CSettingTypeGame("SMM-StoreInst",Rdb_SMM_StoreInstruc)); - AddHandler(Game_SMM_Cache, new CSettingTypeGame("SMM-Cache",Rdb_SMM_Cache)); - AddHandler(Game_SMM_PIDMA, new CSettingTypeGame("SMM-PI DMA",Rdb_SMM_PIDMA)); - AddHandler(Game_SMM_TLB, new CSettingTypeGame("SMM-TLB",Rdb_SMM_TLB)); - AddHandler(Game_SMM_Protect, new CSettingTypeGame("SMM-Protect",Rdb_SMM_Protect)); - AddHandler(Game_SMM_ValidFunc, new CSettingTypeGame("SMM-FUNC",Rdb_SMM_ValidFunc)); - AddHandler(Game_ViRefreshRate, new CSettingTypeGame("ViRefresh",Rdb_ViRefreshRate)); - AddHandler(Game_AiCountPerBytes, new CSettingTypeGame("AiCountPerBytes",Rdb_AiCountPerBytes)); - AddHandler(Game_AudioResetOnLoad, new CSettingTypeGame("AudioResetOnLoad", Rdb_AudioResetOnLoad)); - AddHandler(Game_AllowROMWrites, new CSettingTypeGame("AllowROMWrites", Rdb_AllowROMWrites)); - AddHandler(Game_CRC_Recalc, new CSettingTypeGame("CRC-Recalc", Rdb_CRC_Recalc)); + AddHandler(Game_IniKey, new CSettingTypeTempString("")); + AddHandler(Game_File, new CSettingTypeTempString("")); + AddHandler(Game_GameName, new CSettingTypeTempString("")); + AddHandler(Game_GoodName, new CSettingTypeGame("Good Name", Rdb_GoodName)); + AddHandler(Game_TempLoaded, new CSettingTypeTempBool(false)); + AddHandler(Game_SystemType, new CSettingTypeTempNumber(SYSTEM_NTSC)); + AddHandler(Game_EditPlugin_Gfx, new CSettingTypeGame("Plugin-Gfx", Default_None)); + AddHandler(Game_EditPlugin_Audio, new CSettingTypeGame("Plugin-Audio", Default_None)); + AddHandler(Game_EditPlugin_Contr, new CSettingTypeGame("Plugin-Controller", Default_None)); + AddHandler(Game_EditPlugin_RSP, new CSettingTypeGame("Plugin-RSP", Default_None)); + AddHandler(Game_Plugin_Gfx, new CSettingTypeGame("Plugin-Gfx", Plugin_GFX_Current)); + AddHandler(Game_Plugin_Audio, new CSettingTypeGame("Plugin-Audio", Plugin_AUDIO_Current)); + AddHandler(Game_Plugin_Controller, new CSettingTypeGame("Plugin-Controller", Plugin_CONT_Current)); + AddHandler(Game_Plugin_RSP, new CSettingTypeGame("Plugin-RSP", Plugin_RSP_Current)); + AddHandler(Game_SaveChip, new CSettingTypeGame("SaveChip", Rdb_SaveChip)); + AddHandler(Game_CpuType, new CSettingTypeGame("CpuType", Rdb_CpuType)); + AddHandler(Game_LastSaveSlot, new CSettingTypeGame("Last Used Save Slot", (uint32_t)0)); + AddHandler(Game_FixedAudio, new CSettingTypeGame("Fixed Audio", Rdb_FixedAudio)); + AddHandler(Game_RDRamSize, new CSettingTypeGame("RDRamSize", Rdb_RDRamSize)); + AddHandler(Game_CounterFactor, new CSettingTypeGame("Counter Factor", Rdb_CounterFactor)); + AddHandler(Game_UseTlb, new CSettingTypeGame("Use TLB", Rdb_UseTlb)); + AddHandler(Game_DelayDP, new CSettingTypeGame("Delay DP", Rdb_DelayDP)); + AddHandler(Game_DelaySI, new CSettingTypeGame("Delay SI", Rdb_DelaySi)); + AddHandler(Game_RspAudioSignal, new CSettingTypeGame("Audio Signal", Rdb_RspAudioSignal)); + AddHandler(Game_32Bit, new CSettingTypeGame("32bit", Rdb_32Bit)); + AddHandler(Game_FastSP, new CSettingTypeGame("Fast SP", Rdb_FastSP)); + AddHandler(Game_CurrentSaveState, new CSettingTypeTempNumber(0)); + AddHandler(Game_SyncViaAudio, new CSettingTypeGame("Sync Audio", Rdb_SyncViaAudio)); + AddHandler(Game_UseHleGfx, new CSettingTypeGame("HLE GFX", Rdb_UseHleGfx)); + AddHandler(Game_UseHleAudio, new CSettingTypeGame("HLE Audio", Rdb_UseHleAudio)); + AddHandler(Game_LoadRomToMemory, new CSettingTypeGame("Rom In Memory", Rdb_LoadRomToMemory)); + AddHandler(Game_ScreenHertz, new CSettingTypeGame("ScreenHertz", Rdb_ScreenHertz)); + AddHandler(Game_FuncLookupMode, new CSettingTypeGame("FuncFind", Rdb_FuncLookupMode)); + AddHandler(Game_RegCache, new CSettingTypeGame("Reg Cache", Rdb_RegCache)); + AddHandler(Game_BlockLinking, new CSettingTypeGame("Linking", Rdb_BlockLinking)); + AddHandler(Game_SMM_StoreInstruc, new CSettingTypeGame("SMM-StoreInst", Rdb_SMM_StoreInstruc)); + AddHandler(Game_SMM_Cache, new CSettingTypeGame("SMM-Cache", Rdb_SMM_Cache)); + AddHandler(Game_SMM_PIDMA, new CSettingTypeGame("SMM-PI DMA", Rdb_SMM_PIDMA)); + AddHandler(Game_SMM_TLB, new CSettingTypeGame("SMM-TLB", Rdb_SMM_TLB)); + AddHandler(Game_SMM_Protect, new CSettingTypeGame("SMM-Protect", Rdb_SMM_Protect)); + AddHandler(Game_SMM_ValidFunc, new CSettingTypeGame("SMM-FUNC", Rdb_SMM_ValidFunc)); + AddHandler(Game_ViRefreshRate, new CSettingTypeGame("ViRefresh", Rdb_ViRefreshRate)); + AddHandler(Game_AiCountPerBytes, new CSettingTypeGame("AiCountPerBytes", Rdb_AiCountPerBytes)); + AddHandler(Game_AudioResetOnLoad, new CSettingTypeGame("AudioResetOnLoad", Rdb_AudioResetOnLoad)); + AddHandler(Game_AllowROMWrites, new CSettingTypeGame("AllowROMWrites", Rdb_AllowROMWrites)); + AddHandler(Game_CRC_Recalc, new CSettingTypeGame("CRC-Recalc", Rdb_CRC_Recalc)); //User Interface - AddHandler(UserInterface_BasicMode, new CSettingTypeApplication("","Basic Mode", (uint32_t)true)); - AddHandler(UserInterface_ShowCPUPer, new CSettingTypeApplication("","Display CPU Usage", (uint32_t)false)); - AddHandler(UserInterface_DisplayFrameRate, new CSettingTypeApplication("","Display Frame Rate", (uint32_t)true)); - AddHandler(UserInterface_InFullScreen, new CSettingTypeTempBool(false)); - AddHandler(UserInterface_FrameDisplayType, new CSettingTypeApplication("","Frame Rate Display Type", (uint32_t)FR_VIs)); - AddHandler(UserInterface_MainWindowTop, new CSettingTypeApplication("Main Window","Top" ,Default_None)); - AddHandler(UserInterface_MainWindowLeft, new CSettingTypeApplication("Main Window","Left" ,Default_None)); - AddHandler(UserInterface_AlwaysOnTop, new CSettingTypeApplication("","Always on top", (uint32_t)false)); + AddHandler(UserInterface_BasicMode, new CSettingTypeApplication("", "Basic Mode", (uint32_t)true)); + AddHandler(UserInterface_ShowCPUPer, new CSettingTypeApplication("", "Display CPU Usage", (uint32_t)false)); + AddHandler(UserInterface_DisplayFrameRate, new CSettingTypeApplication("", "Display Frame Rate", (uint32_t)true)); + AddHandler(UserInterface_InFullScreen, new CSettingTypeTempBool(false)); + AddHandler(UserInterface_FrameDisplayType, new CSettingTypeApplication("", "Frame Rate Display Type", (uint32_t)FR_VIs)); + AddHandler(UserInterface_MainWindowTop, new CSettingTypeApplication("Main Window", "Top", Default_None)); + AddHandler(UserInterface_MainWindowLeft, new CSettingTypeApplication("Main Window", "Left", Default_None)); + AddHandler(UserInterface_AlwaysOnTop, new CSettingTypeApplication("", "Always on top", (uint32_t)false)); - AddHandler(RomBrowser_Enabled, new CSettingTypeApplication("Rom Browser","Rom Browser",true)); - AddHandler(RomBrowser_ColoumnsChanged, new CSettingTypeTempBool(false)); - AddHandler(RomBrowser_Top, new CSettingTypeApplication("Rom Browser","Top" ,Default_None)); - AddHandler(RomBrowser_Left, new CSettingTypeApplication("Rom Browser","Left" ,Default_None)); - AddHandler(RomBrowser_Width, new CSettingTypeApplication("Rom Browser","Width", (uint32_t)640)); - AddHandler(RomBrowser_Height, new CSettingTypeApplication("Rom Browser","Height", (uint32_t)480)); - AddHandler(RomBrowser_PosIndex, new CSettingTypeApplicationIndex("Rom Browser\\Field Pos","Field",Default_None)); - AddHandler(RomBrowser_WidthIndex, new CSettingTypeApplicationIndex("Rom Browser\\Field Width","Field",Default_None)); - AddHandler(RomBrowser_SortFieldIndex, new CSettingTypeApplicationIndex("Rom Browser", "Sort Field", Default_None)); - AddHandler(RomBrowser_SortAscendingIndex, new CSettingTypeApplicationIndex("Rom Browser", "Sort Ascending", Default_None)); - AddHandler(RomBrowser_Recursive, new CSettingTypeApplication("Rom Browser","Recursive", false)); - AddHandler(RomBrowser_Maximized, new CSettingTypeApplication("Rom Browser","Maximized", false)); + AddHandler(RomBrowser_Enabled, new CSettingTypeApplication("Rom Browser", "Rom Browser", true)); + AddHandler(RomBrowser_ColoumnsChanged, new CSettingTypeTempBool(false)); + AddHandler(RomBrowser_Top, new CSettingTypeApplication("Rom Browser", "Top", Default_None)); + AddHandler(RomBrowser_Left, new CSettingTypeApplication("Rom Browser", "Left", Default_None)); + AddHandler(RomBrowser_Width, new CSettingTypeApplication("Rom Browser", "Width", (uint32_t)640)); + AddHandler(RomBrowser_Height, new CSettingTypeApplication("Rom Browser", "Height", (uint32_t)480)); + AddHandler(RomBrowser_PosIndex, new CSettingTypeApplicationIndex("Rom Browser\\Field Pos", "Field", Default_None)); + AddHandler(RomBrowser_WidthIndex, new CSettingTypeApplicationIndex("Rom Browser\\Field Width", "Field", Default_None)); + AddHandler(RomBrowser_SortFieldIndex, new CSettingTypeApplicationIndex("Rom Browser", "Sort Field", Default_None)); + AddHandler(RomBrowser_SortAscendingIndex, new CSettingTypeApplicationIndex("Rom Browser", "Sort Ascending", Default_None)); + AddHandler(RomBrowser_Recursive, new CSettingTypeApplication("Rom Browser", "Recursive", false)); + AddHandler(RomBrowser_Maximized, new CSettingTypeApplication("Rom Browser", "Maximized", false)); - AddHandler(Directory_RecentGameDirCount, new CSettingTypeApplication("","Remembered Rom Dirs",(uint32_t)10)); - AddHandler(Directory_RecentGameDirIndex, new CSettingTypeApplicationIndex("Recent Dir","Recent Dir",Default_None)); + AddHandler(Directory_RecentGameDirCount, new CSettingTypeApplication("", "Remembered Rom Dirs", (uint32_t)10)); + AddHandler(Directory_RecentGameDirIndex, new CSettingTypeApplicationIndex("Recent Dir", "Recent Dir", Default_None)); //Directory_Game, - AddHandler(Directory_Game, new CSettingTypeSelectedDirectory("Dir:Game",Directory_GameInitial,Directory_GameSelected,Directory_GameUseSelected)); - AddHandler(Directory_GameInitial, new CSettingTypeRelativePath("Game Directory","")); - AddHandler(Directory_GameSelected, new CSettingTypeApplication("Directory","Game",Directory_GameInitial)); - AddHandler(Directory_GameUseSelected, new CSettingTypeApplication("Directory","Game - Use Selected",false)); + AddHandler(Directory_Game, new CSettingTypeSelectedDirectory("Dir:Game", Directory_GameInitial, Directory_GameSelected, Directory_GameUseSelected)); + AddHandler(Directory_GameInitial, new CSettingTypeRelativePath("Game Directory", "")); + AddHandler(Directory_GameSelected, new CSettingTypeApplication("Directory", "Game", Directory_GameInitial)); + AddHandler(Directory_GameUseSelected, new CSettingTypeApplication("Directory", "Game - Use Selected", false)); - AddHandler(Directory_Plugin, new CSettingTypeSelectedDirectory("Dir:Plugin",Directory_PluginInitial,Directory_PluginSelected,Directory_PluginUseSelected)); + AddHandler(Directory_Plugin, new CSettingTypeSelectedDirectory("Dir:Plugin", Directory_PluginInitial, Directory_PluginSelected, Directory_PluginUseSelected)); #ifdef _M_IX86 - AddHandler(Directory_PluginInitial, new CSettingTypeRelativePath("Plugin", "")); - AddHandler(Directory_PluginSelected, new CSettingTypeApplicationPath("Directory","Plugin",Directory_PluginInitial)); - AddHandler(Directory_PluginUseSelected, new CSettingTypeApplication("Directory","Plugin - Use Selected",false)); - AddHandler(Directory_PluginSync, new CSettingTypeRelativePath("SyncPlugin","")); + AddHandler(Directory_PluginInitial, new CSettingTypeRelativePath("Plugin", "")); + AddHandler(Directory_PluginSelected, new CSettingTypeApplicationPath("Directory", "Plugin", Directory_PluginInitial)); + AddHandler(Directory_PluginUseSelected, new CSettingTypeApplication("Directory", "Plugin - Use Selected", false)); + AddHandler(Directory_PluginSync, new CSettingTypeRelativePath("SyncPlugin", "")); #else AddHandler(Directory_PluginInitial, new CSettingTypeRelativePath("Plugin64", "")); AddHandler(Directory_PluginSelected, new CSettingTypeApplicationPath("Directory", "Plugin64", Directory_PluginInitial)); @@ -262,79 +263,79 @@ void CSettings::AddHowToHandleSetting () AddHandler(Directory_PluginSync, new CSettingTypeRelativePath("SyncPlugin64", "")); #endif - AddHandler(Directory_SnapShot, new CSettingTypeSelectedDirectory("Dir:Snapshot",Directory_SnapShotInitial,Directory_SnapShotSelected,Directory_SnapShotUseSelected)); - AddHandler(Directory_SnapShotInitial, new CSettingTypeRelativePath("Screenshots","")); - AddHandler(Directory_SnapShotSelected, new CSettingTypeApplicationPath("Directory","Snap Shot",Directory_SnapShotInitial)); - AddHandler(Directory_SnapShotUseSelected, new CSettingTypeApplication("Directory","Snap Shot - Use Selected",false)); + AddHandler(Directory_SnapShot, new CSettingTypeSelectedDirectory("Dir:Snapshot", Directory_SnapShotInitial, Directory_SnapShotSelected, Directory_SnapShotUseSelected)); + AddHandler(Directory_SnapShotInitial, new CSettingTypeRelativePath("Screenshots", "")); + AddHandler(Directory_SnapShotSelected, new CSettingTypeApplicationPath("Directory", "Snap Shot", Directory_SnapShotInitial)); + AddHandler(Directory_SnapShotUseSelected, new CSettingTypeApplication("Directory", "Snap Shot - Use Selected", false)); - AddHandler(Directory_NativeSave, new CSettingTypeSelectedDirectory("Dir:NativeSave",Directory_NativeSaveInitial,Directory_NativeSaveSelected,Directory_NativeSaveUseSelected)); - AddHandler(Directory_NativeSaveInitial, new CSettingTypeRelativePath("Save","")); - AddHandler(Directory_NativeSaveSelected, new CSettingTypeApplicationPath("Directory","Save",Directory_NativeSaveInitial)); - AddHandler(Directory_NativeSaveUseSelected,new CSettingTypeApplication("Directory","Save - Use Selected",false)); + AddHandler(Directory_NativeSave, new CSettingTypeSelectedDirectory("Dir:NativeSave", Directory_NativeSaveInitial, Directory_NativeSaveSelected, Directory_NativeSaveUseSelected)); + AddHandler(Directory_NativeSaveInitial, new CSettingTypeRelativePath("Save", "")); + AddHandler(Directory_NativeSaveSelected, new CSettingTypeApplicationPath("Directory", "Save", Directory_NativeSaveInitial)); + AddHandler(Directory_NativeSaveUseSelected, new CSettingTypeApplication("Directory", "Save - Use Selected", false)); - AddHandler(Directory_InstantSave, new CSettingTypeSelectedDirectory("Dir:InstantSave",Directory_InstantSaveInitial,Directory_InstantSaveSelected,Directory_InstantSaveUseSelected)); - AddHandler(Directory_InstantSaveInitial, new CSettingTypeRelativePath("Save","")); - AddHandler(Directory_InstantSaveSelected, new CSettingTypeApplicationPath("Directory","Instant Save",Directory_InstantSaveInitial)); - AddHandler(Directory_InstantSaveUseSelected,new CSettingTypeApplication("Directory","Instant Save - Use Selected",false)); + AddHandler(Directory_InstantSave, new CSettingTypeSelectedDirectory("Dir:InstantSave", Directory_InstantSaveInitial, Directory_InstantSaveSelected, Directory_InstantSaveUseSelected)); + AddHandler(Directory_InstantSaveInitial, new CSettingTypeRelativePath("Save", "")); + AddHandler(Directory_InstantSaveSelected, new CSettingTypeApplicationPath("Directory", "Instant Save", Directory_InstantSaveInitial)); + AddHandler(Directory_InstantSaveUseSelected, new CSettingTypeApplication("Directory", "Instant Save - Use Selected", false)); - AddHandler(Directory_Texture, new CSettingTypeSelectedDirectory("Dir:Texture",Directory_TextureInitial,Directory_TextureSelected,Directory_TextureUseSelected)); - AddHandler(Directory_TextureInitial, new CSettingTypeRelativePath("Textures","")); - AddHandler(Directory_TextureSelected, new CSettingTypeApplicationPath("Directory","Texture Dir",Directory_InstantSaveInitial)); - AddHandler(Directory_TextureUseSelected, new CSettingTypeApplication("Directory","Texture Dir - Use Selected",false)); + AddHandler(Directory_Texture, new CSettingTypeSelectedDirectory("Dir:Texture", Directory_TextureInitial, Directory_TextureSelected, Directory_TextureUseSelected)); + AddHandler(Directory_TextureInitial, new CSettingTypeRelativePath("Textures", "")); + AddHandler(Directory_TextureSelected, new CSettingTypeApplicationPath("Directory", "Texture Dir", Directory_InstantSaveInitial)); + AddHandler(Directory_TextureUseSelected, new CSettingTypeApplication("Directory", "Texture Dir - Use Selected", false)); - AddHandler(Directory_LastSave, new CSettingTypeApplication("Directory","Last Save Directory", Directory_InstantSave)); + AddHandler(Directory_LastSave, new CSettingTypeApplication("Directory", "Last Save Directory", Directory_InstantSave)); - AddHandler(GameRunning_LoadingInProgress, new CSettingTypeTempBool(false)); - AddHandler(GameRunning_CPU_Running, new CSettingTypeTempBool(false)); - AddHandler(GameRunning_CPU_Paused, new CSettingTypeTempBool(false)); - AddHandler(GameRunning_CPU_PausedType, new CSettingTypeTempNumber(Default_None)); - AddHandler(GameRunning_InstantSaveFile, new CSettingTypeTempString("")); - AddHandler(GameRunning_LimitFPS, new CSettingTypeTempBool(true)); - AddHandler(GameRunning_ScreenHertz, new CSettingTypeTempNumber(60)); - AddHandler(GameRunning_InReset, new CSettingTypeTempBool(false)); + AddHandler(GameRunning_LoadingInProgress, new CSettingTypeTempBool(false)); + AddHandler(GameRunning_CPU_Running, new CSettingTypeTempBool(false)); + AddHandler(GameRunning_CPU_Paused, new CSettingTypeTempBool(false)); + AddHandler(GameRunning_CPU_PausedType, new CSettingTypeTempNumber(Default_None)); + AddHandler(GameRunning_InstantSaveFile, new CSettingTypeTempString("")); + AddHandler(GameRunning_LimitFPS, new CSettingTypeTempBool(true)); + AddHandler(GameRunning_ScreenHertz, new CSettingTypeTempNumber(60)); + AddHandler(GameRunning_InReset, new CSettingTypeTempBool(false)); - AddHandler(File_RecentGameFileCount, new CSettingTypeApplication("","Remembered Rom Files",(uint32_t)10)); - AddHandler(File_RecentGameFileIndex, new CSettingTypeApplicationIndex("Recent File","Recent Rom",Default_None)); + AddHandler(File_RecentGameFileCount, new CSettingTypeApplication("", "Remembered Rom Files", (uint32_t)10)); + AddHandler(File_RecentGameFileIndex, new CSettingTypeApplicationIndex("Recent File", "Recent Rom", Default_None)); - AddHandler(Debugger_Enabled, new CSettingTypeApplication("Debugger","Debugger",false)); - AddHandler(Debugger_ShowTLBMisses, new CSettingTypeApplication("Debugger","Show TLB Misses",false)); - AddHandler(Debugger_ShowUnhandledMemory, new CSettingTypeApplication("Debugger","Show Unhandled Memory",false)); - AddHandler(Debugger_ShowPifErrors, new CSettingTypeApplication("Debugger","Show Pif Errors",false)); - AddHandler(Debugger_DisableGameFixes, new CSettingTypeApplication("Debugger","Disable Game Fixes",false)); - AddHandler(Debugger_ShowDListAListCount, new CSettingTypeApplication("Debugger","Show Dlist Alist Count",false)); - AddHandler(Debugger_ShowRecompMemSize, new CSettingTypeApplication("Debugger","Show Recompiler Memory size",false)); - AddHandler(Debugger_ShowDivByZero, new CSettingTypeApplication("Debugger","Show Div by zero",false)); - AddHandler(Debugger_GenerateDebugLog, new CSettingTypeApplication("Debugger","Generate Debug Code",false)); - AddHandler(Debugger_ProfileCode, new CSettingTypeApplication("Debugger","Profile Code",(uint32_t)false)); - AddHandler(Debugger_AppLogLevel, new CSettingTypeApplication("Logging","Log Level",(uint32_t)TraceError)); - AddHandler(Debugger_AppLogFlush, new CSettingTypeApplication("Logging","Log Auto Flush",(uint32_t)false)); - AddHandler(Debugger_GenerateLogFiles, new CSettingTypeApplication("Debugger","Generate Log Files", false)); + AddHandler(Debugger_Enabled, new CSettingTypeApplication("Debugger", "Debugger", false)); + AddHandler(Debugger_ShowTLBMisses, new CSettingTypeApplication("Debugger", "Show TLB Misses", false)); + AddHandler(Debugger_ShowUnhandledMemory, new CSettingTypeApplication("Debugger", "Show Unhandled Memory", false)); + AddHandler(Debugger_ShowPifErrors, new CSettingTypeApplication("Debugger", "Show Pif Errors", false)); + AddHandler(Debugger_DisableGameFixes, new CSettingTypeApplication("Debugger", "Disable Game Fixes", false)); + AddHandler(Debugger_ShowDListAListCount, new CSettingTypeApplication("Debugger", "Show Dlist Alist Count", false)); + AddHandler(Debugger_ShowRecompMemSize, new CSettingTypeApplication("Debugger", "Show Recompiler Memory size", false)); + AddHandler(Debugger_ShowDivByZero, new CSettingTypeApplication("Debugger", "Show Div by zero", false)); + AddHandler(Debugger_GenerateDebugLog, new CSettingTypeApplication("Debugger", "Generate Debug Code", false)); + AddHandler(Debugger_ProfileCode, new CSettingTypeApplication("Debugger", "Profile Code", (uint32_t)false)); + AddHandler(Debugger_AppLogLevel, new CSettingTypeApplication("Logging", "Log Level", (uint32_t)TraceError)); + AddHandler(Debugger_AppLogFlush, new CSettingTypeApplication("Logging", "Log Auto Flush", (uint32_t)false)); + AddHandler(Debugger_GenerateLogFiles, new CSettingTypeApplication("Debugger", "Generate Log Files", false)); //Plugin - AddHandler(Plugin_RSP_Current, new CSettingTypeApplication("Plugin","RSP Dll", "RSP\\RSP 1.7.dll")); - AddHandler(Plugin_GFX_Current, new CSettingTypeApplication("Plugin","Graphics Dll", "GFX\\Jabo_Direct3D8.dll")); - AddHandler(Plugin_AUDIO_Current, new CSettingTypeApplication("Plugin","Audio Dll", "Audio\\Jabo_Dsound.dll")); - AddHandler(Plugin_CONT_Current, new CSettingTypeApplication("Plugin","Controller Dll","Input\\PJ64_NRage.dll")); + AddHandler(Plugin_RSP_Current, new CSettingTypeApplication("Plugin", "RSP Dll", "RSP\\RSP 1.7.dll")); + AddHandler(Plugin_GFX_Current, new CSettingTypeApplication("Plugin", "Graphics Dll", "GFX\\Jabo_Direct3D8.dll")); + AddHandler(Plugin_AUDIO_Current, new CSettingTypeApplication("Plugin", "Audio Dll", "Audio\\Jabo_Dsound.dll")); + AddHandler(Plugin_CONT_Current, new CSettingTypeApplication("Plugin", "Controller Dll", "Input\\PJ64_NRage.dll")); - AddHandler(Plugin_RSP_CurVer, new CSettingTypeApplication("Plugin","RSP Dll Ver", "")); - AddHandler(Plugin_GFX_CurVer, new CSettingTypeApplication("Plugin","Graphics Dll Ver", "")); - AddHandler(Plugin_AUDIO_CurVer, new CSettingTypeApplication("Plugin","Audio Dll Ver", "")); - AddHandler(Plugin_CONT_CurVer, new CSettingTypeApplication("Plugin","Controller Dll Ver", "")); + AddHandler(Plugin_RSP_CurVer, new CSettingTypeApplication("Plugin", "RSP Dll Ver", "")); + AddHandler(Plugin_GFX_CurVer, new CSettingTypeApplication("Plugin", "Graphics Dll Ver", "")); + AddHandler(Plugin_AUDIO_CurVer, new CSettingTypeApplication("Plugin", "Audio Dll Ver", "")); + AddHandler(Plugin_CONT_CurVer, new CSettingTypeApplication("Plugin", "Controller Dll Ver", "")); - AddHandler(Plugin_UseHleGfx, new CSettingTypeApplication("RSP","HLE GFX",true)); - AddHandler(Plugin_UseHleAudio, new CSettingTypeApplication("RSP","HLE Audio",false)); + AddHandler(Plugin_UseHleGfx, new CSettingTypeApplication("RSP", "HLE GFX", true)); + AddHandler(Plugin_UseHleAudio, new CSettingTypeApplication("RSP", "HLE Audio", false)); // cheats - AddHandler(Cheat_Entry, new CSettingTypeCheats("")); - AddHandler(Cheat_Active, new CSettingTypeGameIndex("Cheat","",(uint32_t)false)); - AddHandler(Cheat_Extension, new CSettingTypeGameIndex("Cheat",".exten","??? - Not Set")); - AddHandler(Cheat_Notes, new CSettingTypeCheats("_N")); - AddHandler(Cheat_Options, new CSettingTypeCheats("_O")); - AddHandler(Cheat_Range, new CSettingTypeCheats("_R")); - AddHandler(Cheat_RangeNotes, new CSettingTypeCheats("_RN")); + AddHandler(Cheat_Entry, new CSettingTypeCheats("")); + AddHandler(Cheat_Active, new CSettingTypeGameIndex("Cheat", "", (uint32_t)false)); + AddHandler(Cheat_Extension, new CSettingTypeGameIndex("Cheat", ".exten", "??? - Not Set")); + AddHandler(Cheat_Notes, new CSettingTypeCheats("_N")); + AddHandler(Cheat_Options, new CSettingTypeCheats("_O")); + AddHandler(Cheat_Range, new CSettingTypeCheats("_R")); + AddHandler(Cheat_RangeNotes, new CSettingTypeCheats("_RN")); } -uint32_t CSettings::FindSetting ( CSettings * _this, const char * Name ) +uint32_t CSettings::FindSetting(CSettings * _this, const char * Name) { for (SETTING_MAP::iterator iter = _this->m_SettingInfo.begin(); iter != _this->m_SettingInfo.end(); iter++) { @@ -342,7 +343,7 @@ uint32_t CSettings::FindSetting ( CSettings * _this, const char * Name ) if (Setting->GetSettingType() == SettingType_GameSetting) { CSettingTypeGame * GameSetting = (CSettingTypeGame *)Setting; - if (_stricmp(GameSetting->GetKeyName(),Name) != 0) + if (_stricmp(GameSetting->GetKeyName(), Name) != 0) { continue; } @@ -351,7 +352,7 @@ uint32_t CSettings::FindSetting ( CSettings * _this, const char * Name ) if (Setting->GetSettingType() == SettingType_CfgFile) { CSettingTypeApplication * CfgSetting = (CSettingTypeApplication *)Setting; - if (_stricmp(CfgSetting->GetKeyName(),Name) != 0) + if (_stricmp(CfgSetting->GetKeyName(), Name) != 0) { continue; } @@ -360,7 +361,7 @@ uint32_t CSettings::FindSetting ( CSettings * _this, const char * Name ) if (Setting->GetSettingType() == SettingType_SelectedDirectory) { CSettingTypeSelectedDirectory * SelectedDirectory = (CSettingTypeSelectedDirectory *)Setting; - if (_stricmp(SelectedDirectory->GetName(),Name) != 0) + if (_stricmp(SelectedDirectory->GetName(), Name) != 0) { continue; } @@ -370,58 +371,58 @@ uint32_t CSettings::FindSetting ( CSettings * _this, const char * Name ) return 0; } -void CSettings::FlushSettings ( CSettings * /*_this*/ ) +void CSettings::FlushSettings(CSettings * /*_this*/) { CSettingTypeCheats::FlushChanges(); CSettingTypeApplication::Flush(); } -uint32_t CSettings::GetSetting ( CSettings * _this, SettingID Type ) +uint32_t CSettings::GetSetting(CSettings * _this, SettingID Type) { return _this->LoadDword(Type); } -const char * CSettings::GetSettingSz ( CSettings * _this, SettingID Type, char * Buffer, int BufferSize ) +const char * CSettings::GetSettingSz(CSettings * _this, SettingID Type, char * Buffer, int BufferSize) { if (Buffer && BufferSize > 0) { Buffer[0] = 0; - _this->LoadStringVal(Type, Buffer,BufferSize); + _this->LoadStringVal(Type, Buffer, BufferSize); } return Buffer; } -void CSettings::SetSetting ( CSettings * _this, SettingID ID, unsigned int Value ) +void CSettings::SetSetting(CSettings * _this, SettingID ID, unsigned int Value) { - _this->SaveDword(ID,Value); + _this->SaveDword(ID, Value); } -void CSettings::SetSettingSz ( CSettings * _this, SettingID ID, const char * Value ) +void CSettings::SetSettingSz(CSettings * _this, SettingID ID, const char * Value) { - _this->SaveString(ID,Value); + _this->SaveString(ID, Value); } -void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID DefaultID, SettingDataType DataType, - SettingType Type, const char * Category, const char * DefaultStr, - uint32_t Value ) +void CSettings::RegisterSetting(CSettings * _this, SettingID ID, SettingID DefaultID, SettingDataType DataType, + SettingType Type, const char * Category, const char * DefaultStr, + uint32_t Value) { switch (Type) { case SettingType_ConstValue: if (DataType != Data_DWORD) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); return; } - _this->AddHandler(ID,new CSettingTypeTempNumber(Value)); + _this->AddHandler(ID, new CSettingTypeTempNumber(Value)); break; case SettingType_ConstString: if (DataType != Data_String) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); return; } - _this->AddHandler(ID,new CSettingTypeTempString(DefaultStr)); + _this->AddHandler(ID, new CSettingTypeTempString(DefaultStr)); break; case SettingType_CfgFile: case SettingType_Registry: @@ -430,73 +431,79 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def case Data_DWORD: if (DefaultID == Default_None) { - _this->AddHandler(ID,new CSettingTypeApplication(Category,DefaultStr,Value)); - } else { - _this->AddHandler(ID,new CSettingTypeApplication(Category,DefaultStr,DefaultID)); + _this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, Value)); + } + else { + _this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, DefaultID)); } break; case Data_String: if (DefaultID == Default_None) { - _this->AddHandler(ID,new CSettingTypeApplication(Category,DefaultStr,"")); - } else { - _this->AddHandler(ID,new CSettingTypeApplication(Category,DefaultStr,DefaultID)); + _this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, "")); + } + else { + _this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, DefaultID)); } break; default: - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } break; case SettingType_GameSetting: + { + stdstr_f Name("%s-%s", Category, DefaultStr); + switch (DataType) { - stdstr_f Name("%s-%s",Category,DefaultStr); - switch (DataType) + case Data_DWORD: + if (DefaultID == Default_None) { - case Data_DWORD: - if (DefaultID == Default_None) - { - SettingID RdbSetting = (SettingID)_this->m_NextAutoSettingId; - _this->m_NextAutoSettingId += 1; - _this->AddHandler(RdbSetting,new CSettingTypeRomDatabase(Name.c_str(),(int)Value)); - _this->AddHandler(ID,new CSettingTypeGame(Name.c_str(),RdbSetting)); - } else { - _this->AddHandler(ID,new CSettingTypeGame(Name.c_str(),DefaultID)); - } - break; - case Data_String: - if (DefaultID == Default_None) - { - _this->AddHandler(ID,new CSettingTypeGame(Name.c_str(),"")); - } else { - _this->AddHandler(ID,new CSettingTypeGame(Name.c_str(),DefaultID)); - } - break; - default: - g_Notify->BreakPoint(__FILEW__,__LINE__); + SettingID RdbSetting = (SettingID)_this->m_NextAutoSettingId; + _this->m_NextAutoSettingId += 1; + _this->AddHandler(RdbSetting, new CSettingTypeRomDatabase(Name.c_str(), (int)Value)); + _this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), RdbSetting)); } + else { + _this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), DefaultID)); + } + break; + case Data_String: + if (DefaultID == Default_None) + { + _this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), "")); + } + else { + _this->AddHandler(ID, new CSettingTypeGame(Name.c_str(), DefaultID)); + } + break; + default: + g_Notify->BreakPoint(__FILEW__, __LINE__); } - break; + } + break; case SettingType_RomDatabase: switch (DataType) { case Data_DWORD: if (DefaultID == Default_None) { - _this->AddHandler(ID,new CSettingTypeRomDatabase(DefaultStr,(int)Value,true)); - } else { - _this->AddHandler(ID,new CSettingTypeRomDatabase(DefaultStr,(SettingID)Value,true)); + _this->AddHandler(ID, new CSettingTypeRomDatabase(DefaultStr, (int)Value, true)); + } + else { + _this->AddHandler(ID, new CSettingTypeRomDatabase(DefaultStr, (SettingID)Value, true)); } break; case Data_String: if (DefaultID == Default_None) { - _this->AddHandler(ID,new CSettingTypeRomDatabase(DefaultStr,"",true)); - } else { - _this->AddHandler(ID,new CSettingTypeRomDatabase(DefaultStr,DefaultID,true)); + _this->AddHandler(ID, new CSettingTypeRomDatabase(DefaultStr, "", true)); + } + else { + _this->AddHandler(ID, new CSettingTypeRomDatabase(DefaultStr, DefaultID, true)); } break; default: - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } break; case SettingType_RdbSetting: @@ -505,24 +512,25 @@ void CSettings::RegisterSetting ( CSettings * _this, SettingID ID, SettingID Def case Data_DWORD: if (DefaultID == Default_None) { - _this->AddHandler(ID,new CSettingTypeRomDatabaseSetting(Category, DefaultStr,(int)Value,true)); - } else { + _this->AddHandler(ID, new CSettingTypeRomDatabaseSetting(Category, DefaultStr, (int)Value, true)); + } + else { SettingID RdbSetting = (SettingID)_this->m_NextAutoSettingId; _this->m_NextAutoSettingId += 1; - _this->AddHandler(RdbSetting,new CSettingTypeRomDatabaseSetting(Category, DefaultStr,DefaultID,true)); - _this->AddHandler(ID,new CSettingTypeApplication(Category,DefaultStr,RdbSetting)); + _this->AddHandler(RdbSetting, new CSettingTypeRomDatabaseSetting(Category, DefaultStr, DefaultID, true)); + _this->AddHandler(ID, new CSettingTypeApplication(Category, DefaultStr, RdbSetting)); } break; default: - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } break; default: - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } } -bool CSettings::Initialize( const char * AppName ) +bool CSettings::Initialize(const char * AppName) { AddHowToHandleSetting(); CSettingTypeApplication::Initialize(AppName); @@ -530,18 +538,18 @@ bool CSettings::Initialize( const char * AppName ) CSettingTypeGame::Initialize(); CSettingTypeCheats::Initialize(); - g_Settings->SaveString(Setting_ApplicationName,AppName); + g_Settings->SaveString(Setting_ApplicationName, AppName); return true; } -bool CSettings::LoadBool ( SettingID Type ) +bool CSettings::LoadBool(SettingID Type) { bool Value = false; - LoadBool(Type,Value); + LoadBool(Type, Value); return Value; } -bool CSettings::LoadBool ( SettingID Type, bool & Value ) +bool CSettings::LoadBool(SettingID Type, bool & Value) { SETTING_HANDLER FindInfo = m_SettingInfo.find(Type); if (FindInfo == m_SettingInfo.end()) @@ -552,21 +560,22 @@ bool CSettings::LoadBool ( SettingID Type, bool & Value ) } if (FindInfo->second->IndexBasedSetting()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } else { - return FindInfo->second->Load(0,Value); + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + else { + return FindInfo->second->Load(0, Value); } return false; } -bool CSettings::LoadBoolIndex( SettingID Type, int index ) +bool CSettings::LoadBoolIndex(SettingID Type, int index) { bool Value = false; - LoadBoolIndex(Type,index,Value); + LoadBoolIndex(Type, index, Value); return Value; } -bool CSettings::LoadBoolIndex( SettingID Type, int index , bool & Value ) +bool CSettings::LoadBoolIndex(SettingID Type, int index, bool & Value) { SETTING_HANDLER FindInfo = m_SettingInfo.find(Type); if (FindInfo == m_SettingInfo.end()) @@ -577,21 +586,22 @@ bool CSettings::LoadBoolIndex( SettingID Type, int index , bool & Value ) } if (FindInfo->second->IndexBasedSetting()) { - return FindInfo->second->Load(index,Value); - } else { - g_Notify->BreakPoint(__FILEW__,__LINE__); + return FindInfo->second->Load(index, Value); + } + else { + g_Notify->BreakPoint(__FILEW__, __LINE__); } return false; } -uint32_t CSettings::LoadDword ( SettingID Type ) +uint32_t CSettings::LoadDword(SettingID Type) { uint32_t Value = 0; - LoadDword(Type,Value); + LoadDword(Type, Value); return Value; } -bool CSettings::LoadDword ( SettingID Type, uint32_t & Value) +bool CSettings::LoadDword(SettingID Type, uint32_t & Value) { SETTING_HANDLER FindInfo = m_SettingInfo.find(Type); if (FindInfo == m_SettingInfo.end()) @@ -602,21 +612,22 @@ bool CSettings::LoadDword ( SettingID Type, uint32_t & Value) } if (FindInfo->second->IndexBasedSetting()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } else { - return FindInfo->second->Load(0,Value); + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + else { + return FindInfo->second->Load(0, Value); } return false; } -uint32_t CSettings::LoadDwordIndex( SettingID Type, int index) +uint32_t CSettings::LoadDwordIndex(SettingID Type, int index) { uint32_t Value; - LoadDwordIndex(Type,index,Value); + LoadDwordIndex(Type, index, Value); return Value; } -bool CSettings::LoadDwordIndex( SettingID Type, int index, uint32_t & Value) +bool CSettings::LoadDwordIndex(SettingID Type, int index, uint32_t & Value) { SETTING_HANDLER FindInfo = m_SettingInfo.find(Type); if (FindInfo == m_SettingInfo.end()) @@ -627,21 +638,22 @@ bool CSettings::LoadDwordIndex( SettingID Type, int index, uint32_t & Value) } if (FindInfo->second->IndexBasedSetting()) { - return FindInfo->second->Load(index,Value); - } else { - g_Notify->BreakPoint(__FILEW__,__LINE__); + return FindInfo->second->Load(index, Value); + } + else { + g_Notify->BreakPoint(__FILEW__, __LINE__); } return false; } -stdstr CSettings::LoadStringVal ( SettingID Type ) +stdstr CSettings::LoadStringVal(SettingID Type) { stdstr Value; - LoadStringVal(Type,Value); + LoadStringVal(Type, Value); return Value; } -bool CSettings::LoadStringVal ( SettingID Type, stdstr & Value ) +bool CSettings::LoadStringVal(SettingID Type, stdstr & Value) { SETTING_HANDLER FindInfo = m_SettingInfo.find(Type); if (FindInfo == m_SettingInfo.end()) @@ -652,14 +664,15 @@ bool CSettings::LoadStringVal ( SettingID Type, stdstr & Value ) } if (FindInfo->second->IndexBasedSetting()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } else { - return FindInfo->second->Load(0,Value); + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + else { + return FindInfo->second->Load(0, Value); } return false; } -bool CSettings::LoadStringVal ( SettingID Type, char * Buffer, int BufferSize ) +bool CSettings::LoadStringVal(SettingID Type, char * Buffer, int BufferSize) { SETTING_HANDLER FindInfo = m_SettingInfo.find(Type); if (FindInfo == m_SettingInfo.end()) @@ -671,28 +684,29 @@ bool CSettings::LoadStringVal ( SettingID Type, char * Buffer, int BufferSize ) bool bRes = false; if (FindInfo->second->IndexBasedSetting()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } else { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + else { stdstr Value; - bRes = FindInfo->second->Load(0,Value); + bRes = FindInfo->second->Load(0, Value); int len = BufferSize; if ((Value.length() + 1) < (size_t)len) { len = Value.length() + 1; } - strncpy(Buffer,Value.c_str(),len); + strncpy(Buffer, Value.c_str(), len); } return bRes; } -stdstr CSettings::LoadStringIndex ( SettingID Type, int index ) +stdstr CSettings::LoadStringIndex(SettingID Type, int index) { stdstr Value; - LoadStringIndex(Type,index,Value); + LoadStringIndex(Type, index, Value); return Value; } -bool CSettings::LoadStringIndex ( SettingID Type, int index, stdstr & Value ) +bool CSettings::LoadStringIndex(SettingID Type, int index, stdstr & Value) { SETTING_HANDLER FindInfo = m_SettingInfo.find(Type); if (FindInfo == m_SettingInfo.end()) @@ -703,136 +717,143 @@ bool CSettings::LoadStringIndex ( SettingID Type, int index, stdstr & Value ) } if (FindInfo->second->IndexBasedSetting()) { - return FindInfo->second->Load(index,Value); - } else { - g_Notify->BreakPoint(__FILEW__,__LINE__); + return FindInfo->second->Load(index, Value); + } + else { + g_Notify->BreakPoint(__FILEW__, __LINE__); } return false; } -bool CSettings::LoadStringIndex ( SettingID /*Type*/, int /*index*/, char * /*Buffer*/, int /*BufferSize*/ ) +bool CSettings::LoadStringIndex(SettingID /*Type*/, int /*index*/, char * /*Buffer*/, int /*BufferSize*/) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); return false; } //Load the default value for the setting -bool CSettings::LoadDefaultBool ( SettingID Type ) +bool CSettings::LoadDefaultBool(SettingID Type) { bool Value = false; - LoadDefaultBool(Type,Value); + LoadDefaultBool(Type, Value); return Value; } -void CSettings::LoadDefaultBool ( SettingID Type, bool & Value ) +void CSettings::LoadDefaultBool(SettingID Type, bool & Value) { SETTING_HANDLER FindInfo = m_SettingInfo.find(Type); if (FindInfo == m_SettingInfo.end()) { //if not found do nothing UnknownSetting(Type); - } else { + } + else { if (FindInfo->second->IndexBasedSetting()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } else { - FindInfo->second->LoadDefault(0,Value); + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + else { + FindInfo->second->LoadDefault(0, Value); } } } -bool CSettings::LoadDefaultBoolIndex ( SettingID /*Type*/, int /*index*/ ) +bool CSettings::LoadDefaultBoolIndex(SettingID /*Type*/, int /*index*/) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); return false; } -void CSettings::LoadDefaultBoolIndex ( SettingID /*Type*/, int /*index*/, bool & /*Value*/ ) +void CSettings::LoadDefaultBoolIndex(SettingID /*Type*/, int /*index*/, bool & /*Value*/) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } -uint32_t CSettings::LoadDefaultDword ( SettingID Type ) +uint32_t CSettings::LoadDefaultDword(SettingID Type) { uint32_t Value = 0; - LoadDefaultDword(Type,Value); + LoadDefaultDword(Type, Value); return Value; } -void CSettings::LoadDefaultDword ( SettingID Type, uint32_t & Value) +void CSettings::LoadDefaultDword(SettingID Type, uint32_t & Value) { SETTING_HANDLER FindInfo = m_SettingInfo.find(Type); if (FindInfo == m_SettingInfo.end()) { //if not found do nothing UnknownSetting(Type); - } else { + } + else { if (FindInfo->second->IndexBasedSetting()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } else { - FindInfo->second->LoadDefault(0,Value); + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + else { + FindInfo->second->LoadDefault(0, Value); } } } -uint32_t CSettings::LoadDefaultDwordIndex ( SettingID /*Type*/, int /*index*/ ) +uint32_t CSettings::LoadDefaultDwordIndex(SettingID /*Type*/, int /*index*/) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); return false; } -void CSettings::LoadDefaultDwordIndex ( SettingID /*Type*/, int /*index*/, uint32_t & /*Value*/) +void CSettings::LoadDefaultDwordIndex(SettingID /*Type*/, int /*index*/, uint32_t & /*Value*/) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } -stdstr CSettings::LoadDefaultString ( SettingID Type ) +stdstr CSettings::LoadDefaultString(SettingID Type) { stdstr Value; - LoadDefaultString(Type,Value); + LoadDefaultString(Type, Value); return Value; } -void CSettings::LoadDefaultString ( SettingID Type, stdstr & Value ) +void CSettings::LoadDefaultString(SettingID Type, stdstr & Value) { SETTING_HANDLER FindInfo = m_SettingInfo.find(Type); if (FindInfo == m_SettingInfo.end()) { //if not found do nothing UnknownSetting(Type); - } else { + } + else { if (FindInfo->second->IndexBasedSetting()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } else { - FindInfo->second->LoadDefault(0,Value); + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + else { + FindInfo->second->LoadDefault(0, Value); } } } -void CSettings::LoadDefaultString ( SettingID /*Type*/, char * /*Buffer*/, int /*BufferSize*/ ) +void CSettings::LoadDefaultString(SettingID /*Type*/, char * /*Buffer*/, int /*BufferSize*/) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } -stdstr CSettings::LoadDefaultStringIndex ( SettingID /*Type*/, int /*index*/ ) +stdstr CSettings::LoadDefaultStringIndex(SettingID /*Type*/, int /*index*/) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); return false; } -void CSettings::LoadDefaultStringIndex ( SettingID /*Type*/, int /*index*/, stdstr & /*Value*/ ) +void CSettings::LoadDefaultStringIndex(SettingID /*Type*/, int /*index*/, stdstr & /*Value*/) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } -void CSettings::LoadDefaultStringIndex ( SettingID /*Type*/, int /*index*/, char * /*Buffer*/, int /*BufferSize*/ ) +void CSettings::LoadDefaultStringIndex(SettingID /*Type*/, int /*index*/, char * /*Buffer*/, int /*BufferSize*/) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } -void CSettings::SaveBool ( SettingID Type, bool Value ) +void CSettings::SaveBool(SettingID Type, bool Value) { SETTING_HANDLER FindInfo = m_SettingInfo.find(Type); if (FindInfo == m_SettingInfo.end()) @@ -843,14 +864,15 @@ void CSettings::SaveBool ( SettingID Type, bool Value ) } if (FindInfo->second->IndexBasedSetting()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } else { - FindInfo->second->Save(0,Value); + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + else { + FindInfo->second->Save(0, Value); } NotifyCallBacks(Type); } -void CSettings::SaveBoolIndex( SettingID Type, int index, bool Value ) +void CSettings::SaveBoolIndex(SettingID Type, int index, bool Value) { SETTING_HANDLER FindInfo = m_SettingInfo.find(Type); if (FindInfo == m_SettingInfo.end()) @@ -861,14 +883,15 @@ void CSettings::SaveBoolIndex( SettingID Type, int index, bool Value ) } if (FindInfo->second->IndexBasedSetting()) { - FindInfo->second->Save(index,Value); - } else { - g_Notify->BreakPoint(__FILEW__,__LINE__); + FindInfo->second->Save(index, Value); + } + else { + g_Notify->BreakPoint(__FILEW__, __LINE__); } NotifyCallBacks(Type); } -void CSettings::SaveDword ( SettingID Type, uint32_t Value ) +void CSettings::SaveDword(SettingID Type, uint32_t Value) { SETTING_HANDLER FindInfo = m_SettingInfo.find(Type); if (FindInfo == m_SettingInfo.end()) @@ -879,14 +902,15 @@ void CSettings::SaveDword ( SettingID Type, uint32_t Value ) } if (FindInfo->second->IndexBasedSetting()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } else { - FindInfo->second->Save(0,Value); + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + else { + FindInfo->second->Save(0, Value); } NotifyCallBacks(Type); } -void CSettings::SaveDwordIndex ( SettingID Type, int index, uint32_t Value ) +void CSettings::SaveDwordIndex(SettingID Type, int index, uint32_t Value) { SETTING_HANDLER FindInfo = m_SettingInfo.find(Type); if (FindInfo == m_SettingInfo.end()) @@ -897,14 +921,15 @@ void CSettings::SaveDwordIndex ( SettingID Type, int index, uint32_t Value ) } if (FindInfo->second->IndexBasedSetting()) { - FindInfo->second->Save(index,Value); - } else { - g_Notify->BreakPoint(__FILEW__,__LINE__); + FindInfo->second->Save(index, Value); + } + else { + g_Notify->BreakPoint(__FILEW__, __LINE__); } NotifyCallBacks(Type); } -void CSettings::SaveString ( SettingID Type, const stdstr & Value ) +void CSettings::SaveString(SettingID Type, const stdstr & Value) { SETTING_HANDLER FindInfo = m_SettingInfo.find(Type); if (FindInfo == m_SettingInfo.end()) @@ -915,14 +940,15 @@ void CSettings::SaveString ( SettingID Type, const stdstr & Value ) } if (FindInfo->second->IndexBasedSetting()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } else { - FindInfo->second->Save(0,Value); + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + else { + FindInfo->second->Save(0, Value); } NotifyCallBacks(Type); } -void CSettings::SaveString ( SettingID Type, const char * Buffer ) +void CSettings::SaveString(SettingID Type, const char * Buffer) { SETTING_HANDLER FindInfo = m_SettingInfo.find(Type); if (FindInfo == m_SettingInfo.end()) @@ -932,14 +958,15 @@ void CSettings::SaveString ( SettingID Type, const char * Buffer ) } if (FindInfo->second->IndexBasedSetting()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } else { - FindInfo->second->Save(0,Buffer); + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + else { + FindInfo->second->Save(0, Buffer); } NotifyCallBacks(Type); } -void CSettings::SaveStringIndex( SettingID Type, int index, const char * Buffer ) +void CSettings::SaveStringIndex(SettingID Type, int index, const char * Buffer) { SETTING_HANDLER FindInfo = m_SettingInfo.find(Type); if (FindInfo == m_SettingInfo.end()) @@ -949,19 +976,20 @@ void CSettings::SaveStringIndex( SettingID Type, int index, const char * Buffer } if (FindInfo->second->IndexBasedSetting()) { - FindInfo->second->Save(index,Buffer); - } else { - g_Notify->BreakPoint(__FILEW__,__LINE__); + FindInfo->second->Save(index, Buffer); + } + else { + g_Notify->BreakPoint(__FILEW__, __LINE__); } NotifyCallBacks(Type); } -void CSettings::SaveStringIndex( SettingID Type, int index, const stdstr & Value ) +void CSettings::SaveStringIndex(SettingID Type, int index, const stdstr & Value) { - SaveStringIndex(Type,index,Value.c_str()); + SaveStringIndex(Type, index, Value.c_str()); } -void CSettings::DeleteSetting( SettingID Type ) +void CSettings::DeleteSetting(SettingID Type) { SETTING_HANDLER FindInfo = m_SettingInfo.find(Type); if (FindInfo == m_SettingInfo.end()) @@ -971,14 +999,15 @@ void CSettings::DeleteSetting( SettingID Type ) } if (FindInfo->second->IndexBasedSetting()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } else { + g_Notify->BreakPoint(__FILEW__, __LINE__); + } + else { FindInfo->second->Delete(0); } NotifyCallBacks(Type); } -void CSettings::DeleteSettingIndex( SettingID Type, int index ) +void CSettings::DeleteSettingIndex(SettingID Type, int index) { SETTING_HANDLER FindInfo = m_SettingInfo.find(Type); if (FindInfo == m_SettingInfo.end()) @@ -989,13 +1018,14 @@ void CSettings::DeleteSettingIndex( SettingID Type, int index ) if (FindInfo->second->IndexBasedSetting()) { FindInfo->second->Delete(index); - } else { - g_Notify->BreakPoint(__FILEW__,__LINE__); + } + else { + g_Notify->BreakPoint(__FILEW__, __LINE__); } NotifyCallBacks(Type); } -SettingType CSettings::GetSettingType ( SettingID Type ) +SettingType CSettings::GetSettingType(SettingID Type) { if (Type == Default_None || Type == Default_Constant) { @@ -1010,7 +1040,7 @@ SettingType CSettings::GetSettingType ( SettingID Type ) return FindInfo->second->GetSettingType(); } -bool CSettings::IndexBasedSetting ( SettingID Type ) +bool CSettings::IndexBasedSetting(SettingID Type) { SETTING_HANDLER FindInfo = m_SettingInfo.find(Type); if (FindInfo == m_SettingInfo.end()) @@ -1020,7 +1050,7 @@ bool CSettings::IndexBasedSetting ( SettingID Type ) return FindInfo->second->IndexBasedSetting(); } -void CSettings::SettingTypeChanged( SettingType Type ) +void CSettings::SettingTypeChanged(SettingType Type) { for (SETTING_MAP::iterator iter = m_SettingInfo.begin(); iter != m_SettingInfo.end(); iter++) { @@ -1030,14 +1060,14 @@ void CSettings::SettingTypeChanged( SettingType Type ) } } } -void CSettings::UnknownSetting (SettingID /*Type*/) +void CSettings::UnknownSetting(SettingID /*Type*/) { #ifdef _DEBUG - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); #endif } -void CSettings::NotifyCallBacks( SettingID Type ) +void CSettings::NotifyCallBacks(SettingID Type) { SETTING_CALLBACK::iterator Callback = m_Callback.find(Type); if (Callback == m_Callback.end()) @@ -1051,7 +1081,7 @@ void CSettings::NotifyCallBacks( SettingID Type ) } } -void CSettings::RegisterChangeCB(SettingID Type,void * Data, SettingChangedFunc Func) +void CSettings::RegisterChangeCB(SettingID Type, void * Data, SettingChangedFunc Func) { SETTING_CHANGED_CB * new_item = new SETTING_CHANGED_CB; new_item->Data = Data; @@ -1067,12 +1097,13 @@ void CSettings::RegisterChangeCB(SettingID Type,void * Data, SettingChangedFunc item = item->Next; } item->Next = new_item; - } else { - m_Callback.insert(SETTING_CALLBACK::value_type(Type,new_item)); + } + else { + m_Callback.insert(SETTING_CALLBACK::value_type(Type, new_item)); } } -void CSettings::UnregisterChangeCB(SettingID Type,void * Data, SettingChangedFunc Func) +void CSettings::UnregisterChangeCB(SettingID Type, void * Data, SettingChangedFunc Func) { bool bRemoved = false; @@ -1095,11 +1126,13 @@ void CSettings::UnregisterChangeCB(SettingID Type,void * Data, SettingChangedFun SettingID Type = Callback->first; SETTING_CHANGED_CB * Next = item->Next; m_Callback.erase(Callback); - m_Callback.insert(SETTING_CALLBACK::value_type(Type,Next)); - } else { + m_Callback.insert(SETTING_CALLBACK::value_type(Type, Next)); + } + else { m_Callback.erase(Callback); } - } else { + } + else { PrevItem->Next = item->Next; } delete item; @@ -1109,13 +1142,14 @@ void CSettings::UnregisterChangeCB(SettingID Type,void * Data, SettingChangedFun PrevItem = item; item = item->Next; } - } else { + } + else { UnknownSetting(Type); return; } if (!bRemoved) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } -} +} \ No newline at end of file diff --git a/Source/Project64/Settings/Settings.h b/Source/Project64/Settings/Settings.h index f51b9700c..24b241421 100644 --- a/Source/Project64/Settings/Settings.h +++ b/Source/Project64/Settings/Settings.h @@ -105,6 +105,7 @@ enum SettingID //Individual Game Settings Game_IniKey, + Game_File, Game_GameName, Game_GoodName, Game_TempLoaded, diff --git a/Source/Project64/User Interface/Gui Class.cpp b/Source/Project64/User Interface/Gui Class.cpp index 843a8d89c..49e5ca6f8 100644 --- a/Source/Project64/User Interface/Gui Class.cpp +++ b/Source/Project64/User Interface/Gui Class.cpp @@ -50,6 +50,7 @@ m_ResetInfo(NULL) g_Settings->RegisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); g_Settings->RegisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); g_Settings->RegisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged); + g_Settings->RegisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded); } //if this fails then it has already been created @@ -66,6 +67,7 @@ CMainGui::~CMainGui(void) g_Settings->UnregisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); g_Settings->UnregisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); g_Settings->UnregisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged); + g_Settings->UnregisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded); } if (m_hMainWindow) { @@ -118,6 +120,19 @@ void CMainGui::LoadingInProgressChanged(CMainGui * Gui) Gui->RefreshMenu(); } +void CMainGui::GameLoaded(CMainGui * Gui) +{ + stdstr FileLoc = g_Settings->LoadStringVal(Game_File); + if (FileLoc.length() > 0) + { + WriteTrace(TraceDebug, __FUNCTION__ ": Add Recent Rom"); + Notify().AddRecentRom(FileLoc.c_str()); + Notify().SetWindowCaption(g_Settings->LoadStringVal(Game_GoodName).ToUTF16().c_str()); + + Gui->HideRomList(); + } +} + void RomBowserColoumnsChanged(CMainGui * Gui) { Gui->ResetRomBrowserColomuns(); diff --git a/Source/Project64/User Interface/Gui Class.h b/Source/Project64/User Interface/Gui Class.h index 6cbdc625f..0032a1327 100644 --- a/Source/Project64/User Interface/Gui Class.h +++ b/Source/Project64/User Interface/Gui Class.h @@ -112,6 +112,7 @@ private: friend void RomBowserColoumnsChanged(CMainGui * Gui); friend void RomBrowserRecursiveChanged(CMainGui * Gui); static void LoadingInProgressChanged(CMainGui * Gui); + static void GameLoaded(CMainGui * Gui); CBaseMenu * m_Menu; From e25fedcae28dee123d600ca5a410b9a44297d60e Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 12 Nov 2015 22:34:55 +1100 Subject: [PATCH 146/213] [Project64] Move AddRecentRom from Notification Class to gui class --- Source/Project64/User Interface/Gui Class.cpp | 43 ++++++++++++++++++- Source/Project64/User Interface/Gui Class.h | 1 + .../User Interface/Notification Class.cpp | 41 ------------------ .../User Interface/Notification Class.h | 1 - 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/Source/Project64/User Interface/Gui Class.cpp b/Source/Project64/User Interface/Gui Class.cpp index 49e5ca6f8..81ad227f3 100644 --- a/Source/Project64/User Interface/Gui Class.cpp +++ b/Source/Project64/User Interface/Gui Class.cpp @@ -97,6 +97,47 @@ bool CMainGui::RegisterWinClass(void) return true; } +void CMainGui::AddRecentRom(const char * ImagePath) +{ + if (HIWORD(ImagePath) == NULL) { return; } + + //Get Information about the stored rom list + size_t MaxRememberedFiles = g_Settings->LoadDword(File_RecentGameFileCount); + strlist RecentGames; + size_t i; + for (i = 0; i < MaxRememberedFiles; i++) + { + stdstr RecentGame = g_Settings->LoadStringIndex(File_RecentGameFileIndex, i); + if (RecentGame.empty()) + { + break; + } + RecentGames.push_back(RecentGame); + } + + //See if the dir is already in the list if so then move it to the top of the list + strlist::iterator iter; + for (iter = RecentGames.begin(); iter != RecentGames.end(); iter++) + { + if (_stricmp(ImagePath, iter->c_str()) != 0) + { + continue; + } + RecentGames.erase(iter); + break; + } + RecentGames.push_front(ImagePath); + if (RecentGames.size() > MaxRememberedFiles) + { + RecentGames.pop_back(); + } + + for (i = 0, iter = RecentGames.begin(); iter != RecentGames.end(); iter++, i++) + { + g_Settings->SaveStringIndex(File_RecentGameFileIndex, i, *iter); + } +} + void RomBowserEnabledChanged(CMainGui * Gui) { if (Gui && g_Settings->LoadBool(RomBrowser_Enabled)) @@ -126,7 +167,7 @@ void CMainGui::GameLoaded(CMainGui * Gui) if (FileLoc.length() > 0) { WriteTrace(TraceDebug, __FUNCTION__ ": Add Recent Rom"); - Notify().AddRecentRom(FileLoc.c_str()); + Gui->AddRecentRom(FileLoc.c_str()); Notify().SetWindowCaption(g_Settings->LoadStringVal(Game_GoodName).ToUTF16().c_str()); Gui->HideRomList(); diff --git a/Source/Project64/User Interface/Gui Class.h b/Source/Project64/User Interface/Gui Class.h index 0032a1327..fc8ed9a23 100644 --- a/Source/Project64/User Interface/Gui Class.h +++ b/Source/Project64/User Interface/Gui Class.h @@ -103,6 +103,7 @@ private: void Create(const char * WindowTitle); void CreateStatusBar(void); void Resize(DWORD fwSizeType, WORD nWidth, WORD nHeight); //responding to WM_SIZE + void AddRecentRom(const char * ImagePath); friend DWORD CALLBACK AboutBoxProc(HWND, DWORD, DWORD, DWORD); friend DWORD CALLBACK AboutIniBoxProc(HWND, DWORD, DWORD, DWORD); diff --git a/Source/Project64/User Interface/Notification Class.cpp b/Source/Project64/User Interface/Notification Class.cpp index 764ea07ba..858b36556 100644 --- a/Source/Project64/User Interface/Notification Class.cpp +++ b/Source/Project64/User Interface/Notification Class.cpp @@ -196,47 +196,6 @@ void CNotification::AddRecentDir(const char * RomDir) } } -void CNotification::AddRecentRom(const char * ImagePath) -{ - if (HIWORD(ImagePath) == NULL) { return; } - - //Get Information about the stored rom list - size_t MaxRememberedFiles = g_Settings->LoadDword(File_RecentGameFileCount); - strlist RecentGames; - size_t i; - for (i = 0; i < MaxRememberedFiles; i++) - { - stdstr RecentGame = g_Settings->LoadStringIndex(File_RecentGameFileIndex, i); - if (RecentGame.empty()) - { - break; - } - RecentGames.push_back(RecentGame); - } - - //See if the dir is already in the list if so then move it to the top of the list - strlist::iterator iter; - for (iter = RecentGames.begin(); iter != RecentGames.end(); iter++) - { - if (_stricmp(ImagePath, iter->c_str()) != 0) - { - continue; - } - RecentGames.erase(iter); - break; - } - RecentGames.push_front(ImagePath); - if (RecentGames.size() > MaxRememberedFiles) - { - RecentGames.pop_back(); - } - - for (i = 0, iter = RecentGames.begin(); iter != RecentGames.end(); iter++, i++) - { - g_Settings->SaveStringIndex(File_RecentGameFileIndex, i, *iter); - } -} - void CNotification::RefreshMenu(void) { if (m_hWnd == NULL) { return; } diff --git a/Source/Project64/User Interface/Notification Class.h b/Source/Project64/User Interface/Notification Class.h index b125e8481..c8b76833b 100644 --- a/Source/Project64/User Interface/Notification Class.h +++ b/Source/Project64/User Interface/Notification Class.h @@ -43,7 +43,6 @@ public: //Remember roms loaded and Rom Dir selected void AddRecentDir ( const char * RomDir ); - void AddRecentRom ( const char * ImagePath ); //Gui for responses void SetMainWindow ( CMainGui * Gui ); From e4bd5eae745f4d95f3e8e47796c2ba28938b7a77 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 12 Nov 2015 22:38:20 +1100 Subject: [PATCH 147/213] [Project64] Move SetWindowCaption from Notification Class to Gui Class --- Source/Project64/User Interface/Gui Class.cpp | 12 +++++++++++- Source/Project64/User Interface/Gui Class.h | 1 + .../User Interface/Notification Class.cpp | 14 -------------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Source/Project64/User Interface/Gui Class.cpp b/Source/Project64/User Interface/Gui Class.cpp index 81ad227f3..17e87d875 100644 --- a/Source/Project64/User Interface/Gui Class.cpp +++ b/Source/Project64/User Interface/Gui Class.cpp @@ -138,6 +138,16 @@ void CMainGui::AddRecentRom(const char * ImagePath) } } +void CMainGui::SetWindowCaption(const wchar_t * title) +{ + static const size_t TITLE_SIZE = 256; + wchar_t WinTitle[TITLE_SIZE]; + + _snwprintf(WinTitle, TITLE_SIZE, L"%s - %s", title, g_Settings->LoadStringVal(Setting_ApplicationName).ToUTF16().c_str()); + WinTitle[TITLE_SIZE - 1] = 0; + Caption(WinTitle); +} + void RomBowserEnabledChanged(CMainGui * Gui) { if (Gui && g_Settings->LoadBool(RomBrowser_Enabled)) @@ -168,7 +178,7 @@ void CMainGui::GameLoaded(CMainGui * Gui) { WriteTrace(TraceDebug, __FUNCTION__ ": Add Recent Rom"); Gui->AddRecentRom(FileLoc.c_str()); - Notify().SetWindowCaption(g_Settings->LoadStringVal(Game_GoodName).ToUTF16().c_str()); + Gui->SetWindowCaption(g_Settings->LoadStringVal(Game_GoodName).ToUTF16().c_str()); Gui->HideRomList(); } diff --git a/Source/Project64/User Interface/Gui Class.h b/Source/Project64/User Interface/Gui Class.h index fc8ed9a23..a98293a0e 100644 --- a/Source/Project64/User Interface/Gui Class.h +++ b/Source/Project64/User Interface/Gui Class.h @@ -104,6 +104,7 @@ private: void CreateStatusBar(void); void Resize(DWORD fwSizeType, WORD nWidth, WORD nHeight); //responding to WM_SIZE void AddRecentRom(const char * ImagePath); + void SetWindowCaption(const wchar_t * Caption); friend DWORD CALLBACK AboutBoxProc(HWND, DWORD, DWORD, DWORD); friend DWORD CALLBACK AboutIniBoxProc(HWND, DWORD, DWORD, DWORD); diff --git a/Source/Project64/User Interface/Notification Class.cpp b/Source/Project64/User Interface/Notification Class.cpp index 858b36556..097adf98f 100644 --- a/Source/Project64/User Interface/Notification Class.cpp +++ b/Source/Project64/User Interface/Notification Class.cpp @@ -125,20 +125,6 @@ void CNotification::SetGfxPlugin(CGfxPlugin * Plugin) m_gfxPlugin = Plugin; } -void CNotification::SetWindowCaption(const wchar_t * Caption) -{ - static const size_t TITLE_SIZE = 256; - wchar_t WinTitle[TITLE_SIZE]; - - _snwprintf(WinTitle, TITLE_SIZE, L"%s - %s", Caption, g_Settings->LoadStringVal(Setting_ApplicationName).ToUTF16().c_str()); - WinTitle[TITLE_SIZE - 1] = 0; -#if defined(WINDOWS_UI) - m_hWnd->Caption(WinTitle); -#else - g_Notify->BreakPoint(__FILEW__, __LINE__); -#endif -} - void CNotification::FatalError(LanguageStringID StringID) const { FatalError(g_Lang->GetString(StringID).c_str()); From 3b74fef76c0a800f085b3fcf948f7881c1eae6db Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 12 Nov 2015 22:45:24 +1100 Subject: [PATCH 148/213] [Project64] Create gui callback on paused --- Source/Project64/N64 System/N64 Class.cpp | 10 ++++------ Source/Project64/User Interface/Gui Class.cpp | 7 +++++++ Source/Project64/User Interface/Gui Class.h | 1 + 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index 6b4b9c732..9fa059785 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -452,12 +452,10 @@ void CN64System::Pause() } m_hPauseEvent.Reset(); g_Settings->SaveBool(GameRunning_CPU_Paused, true); - Notify().RefreshMenu(); g_Notify->DisplayMessage(5, MSG_CPU_PAUSED); m_hPauseEvent.IsTriggered(SyncEvent::INFINITE_TIMEOUT); m_hPauseEvent.Reset(); - g_Settings->SaveBool(GameRunning_CPU_Paused, (DWORD)false); - Notify().RefreshMenu(); + g_Settings->SaveBool(GameRunning_CPU_Paused, false); Notify().DisplayMessage(5, MSG_CPU_RESUMED); } @@ -1107,7 +1105,7 @@ void CN64System::SyncCPU(CN64System * const SecondCPU) // if (PROGRAM_COUNTER == 0x8009BBD8) { // g_Notify->BreakPoint(__FILEW__,__LINE__); // } -} + } void CN64System::SyncSystem() { @@ -1800,7 +1798,7 @@ bool CN64System::LoadState(LPCSTR FileName) SetActiveSystem(true); SyncCPU(m_SyncCPU); } -} + } WriteTrace(TraceDebug, __FUNCTION__ ": 13"); std::wstring LoadMsg = g_Lang->GetString(MSG_LOADED_STATE); g_Notify->DisplayMessage(5, stdstr_f("%s %s", LoadMsg.c_str(), CPath(FileNameStr).GetNameExtension()).ToUTF16().c_str()); @@ -2038,7 +2036,7 @@ bool CN64System::WriteToProtectedMemory(uint32_t Address, int length) #endif } return false; -} + } void CN64System::TLB_Mapped(uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly) { diff --git a/Source/Project64/User Interface/Gui Class.cpp b/Source/Project64/User Interface/Gui Class.cpp index 17e87d875..79ccc8513 100644 --- a/Source/Project64/User Interface/Gui Class.cpp +++ b/Source/Project64/User Interface/Gui Class.cpp @@ -50,6 +50,7 @@ m_ResetInfo(NULL) g_Settings->RegisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); g_Settings->RegisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); g_Settings->RegisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged); + g_Settings->RegisterChangeCB(GameRunning_CPU_Paused, this, (CSettings::SettingChangedFunc)GamePaused); g_Settings->RegisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded); } @@ -67,6 +68,7 @@ CMainGui::~CMainGui(void) g_Settings->UnregisterChangeCB(RomBrowser_ColoumnsChanged, this, (CSettings::SettingChangedFunc)RomBowserColoumnsChanged); g_Settings->UnregisterChangeCB(RomBrowser_Recursive, this, (CSettings::SettingChangedFunc)RomBrowserRecursiveChanged); g_Settings->UnregisterChangeCB(GameRunning_LoadingInProgress, this, (CSettings::SettingChangedFunc)LoadingInProgressChanged); + g_Settings->UnregisterChangeCB(GameRunning_CPU_Paused, this, (CSettings::SettingChangedFunc)GamePaused); g_Settings->UnregisterChangeCB(Game_File, this, (CSettings::SettingChangedFunc)GameLoaded); } if (m_hMainWindow) @@ -184,6 +186,11 @@ void CMainGui::GameLoaded(CMainGui * Gui) } } +void CMainGui::GamePaused(CMainGui * Gui) +{ + Gui->RefreshMenu(); +} + void RomBowserColoumnsChanged(CMainGui * Gui) { Gui->ResetRomBrowserColomuns(); diff --git a/Source/Project64/User Interface/Gui Class.h b/Source/Project64/User Interface/Gui Class.h index a98293a0e..11f93006f 100644 --- a/Source/Project64/User Interface/Gui Class.h +++ b/Source/Project64/User Interface/Gui Class.h @@ -115,6 +115,7 @@ private: friend void RomBrowserRecursiveChanged(CMainGui * Gui); static void LoadingInProgressChanged(CMainGui * Gui); static void GameLoaded(CMainGui * Gui); + static void GamePaused(CMainGui * Gui); CBaseMenu * m_Menu; From 24709944f31ab98485bada54d0ce6f5d8cdb7fd6 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 12 Nov 2015 22:52:06 +1100 Subject: [PATCH 149/213] [Project64] Code cleanup of Main Menu Class.cpp --- Source/Project64/N64 System/N64 Class.cpp | 5 +- .../User Interface/Main Menu Class.cpp | 2345 ++++++++--------- .../User Interface/Main Menu Class.h | 130 +- 3 files changed, 1239 insertions(+), 1241 deletions(-) diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index 9fa059785..eef3d2e92 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -868,7 +868,6 @@ void CN64System::ExecuteCPU() g_Notify->DisplayMessage(5, MSG_EMULATION_STARTED); m_EndEmulation = false; - Notify().RefreshMenu(); m_Plugins->RomOpened(); if (m_SyncCPU) @@ -1105,7 +1104,7 @@ void CN64System::SyncCPU(CN64System * const SecondCPU) // if (PROGRAM_COUNTER == 0x8009BBD8) { // g_Notify->BreakPoint(__FILEW__,__LINE__); // } - } +} void CN64System::SyncSystem() { @@ -2036,7 +2035,7 @@ bool CN64System::WriteToProtectedMemory(uint32_t Address, int length) #endif } return false; - } +} void CN64System::TLB_Mapped(uint32_t VAddr, uint32_t Len, uint32_t PAddr, bool bReadOnly) { diff --git a/Source/Project64/User Interface/Main Menu Class.cpp b/Source/Project64/User Interface/Main Menu Class.cpp index 04b09572d..0fec51d61 100644 --- a/Source/Project64/User Interface/Main Menu Class.cpp +++ b/Source/Project64/User Interface/Main Menu Class.cpp @@ -4,1249 +4,1248 @@ #include #include -CMainMenu::CMainMenu ( CMainGui * hMainWindow ): - CBaseMenu(), - m_ResetAccelerators(true) +CMainMenu::CMainMenu(CMainGui * hMainWindow) : +CBaseMenu(), +m_ResetAccelerators(true) { - _Gui = hMainWindow; //Make a copy of the attatched window - ResetMenu(); + _Gui = hMainWindow; //Make a copy of the attatched window + ResetMenu(); - hMainWindow->SetWindowMenu(this); + hMainWindow->SetWindowMenu(this); - m_ChangeSettingList.push_back(Info_ShortCutsChanged); - m_ChangeSettingList.push_back(GameRunning_LimitFPS); - m_ChangeSettingList.push_back(UserInterface_InFullScreen); - m_ChangeSettingList.push_back(UserInterface_AlwaysOnTop); - m_ChangeSettingList.push_back(UserInterface_ShowCPUPer); - m_ChangeSettingList.push_back(Debugger_ProfileCode); - m_ChangeSettingList.push_back(Debugger_ShowTLBMisses); - m_ChangeSettingList.push_back(Debugger_ShowUnhandledMemory); - m_ChangeSettingList.push_back(Debugger_ShowPifErrors); - m_ChangeSettingList.push_back(Debugger_ShowDListAListCount); - m_ChangeSettingList.push_back(Debugger_ShowRecompMemSize); - m_ChangeSettingList.push_back(Debugger_ShowDivByZero); - m_ChangeSettingList.push_back(Debugger_GenerateLogFiles); - m_ChangeSettingList.push_back(Debugger_DisableGameFixes); - m_ChangeSettingList.push_back(Debugger_AppLogLevel); - m_ChangeSettingList.push_back(Debugger_AppLogFlush); - m_ChangeSettingList.push_back(Debugger_GenerateDebugLog); - m_ChangeSettingList.push_back(Game_CurrentSaveState); - m_ChangeSettingList.push_back(Setting_CurrentLanguage); + m_ChangeSettingList.push_back(Info_ShortCutsChanged); + m_ChangeSettingList.push_back(GameRunning_LimitFPS); + m_ChangeSettingList.push_back(UserInterface_InFullScreen); + m_ChangeSettingList.push_back(UserInterface_AlwaysOnTop); + m_ChangeSettingList.push_back(UserInterface_ShowCPUPer); + m_ChangeSettingList.push_back(Debugger_ProfileCode); + m_ChangeSettingList.push_back(Debugger_ShowTLBMisses); + m_ChangeSettingList.push_back(Debugger_ShowUnhandledMemory); + m_ChangeSettingList.push_back(Debugger_ShowPifErrors); + m_ChangeSettingList.push_back(Debugger_ShowDListAListCount); + m_ChangeSettingList.push_back(Debugger_ShowRecompMemSize); + m_ChangeSettingList.push_back(Debugger_ShowDivByZero); + m_ChangeSettingList.push_back(Debugger_GenerateLogFiles); + m_ChangeSettingList.push_back(Debugger_DisableGameFixes); + m_ChangeSettingList.push_back(Debugger_AppLogLevel); + m_ChangeSettingList.push_back(Debugger_AppLogFlush); + m_ChangeSettingList.push_back(Debugger_GenerateDebugLog); + m_ChangeSettingList.push_back(Game_CurrentSaveState); + m_ChangeSettingList.push_back(Setting_CurrentLanguage); - for (SettingList::const_iterator iter = m_ChangeSettingList.begin(); iter != m_ChangeSettingList.end(); iter++) - { - g_Settings->RegisterChangeCB(*iter,this,(CSettings::SettingChangedFunc)SettingsChanged); - } + for (SettingList::const_iterator iter = m_ChangeSettingList.begin(); iter != m_ChangeSettingList.end(); iter++) + { + g_Settings->RegisterChangeCB(*iter, this, (CSettings::SettingChangedFunc)SettingsChanged); + } } CMainMenu::~CMainMenu() { - for (SettingList::const_iterator iter = m_ChangeSettingList.begin(); iter != m_ChangeSettingList.end(); iter++) - { - g_Settings->UnregisterChangeCB(*iter,this,(CSettings::SettingChangedFunc)SettingsChanged); - } + for (SettingList::const_iterator iter = m_ChangeSettingList.begin(); iter != m_ChangeSettingList.end(); iter++) + { + g_Settings->UnregisterChangeCB(*iter, this, (CSettings::SettingChangedFunc)SettingsChanged); + } } - -void CMainMenu::SettingsChanged (CMainMenu * _this ) +void CMainMenu::SettingsChanged(CMainMenu * _this) { - _this->ResetMenu(); + _this->ResetMenu(); } -int CMainMenu::ProcessAccelerator ( HWND hWnd, void * lpMsg ) +int CMainMenu::ProcessAccelerator(HWND hWnd, void * lpMsg) { - if (m_ResetAccelerators) - { - m_ResetAccelerators = false; - RebuildAccelerators(); - } - if (!m_AccelTable) { return false; } - return TranslateAccelerator((HWND)hWnd,(HACCEL)m_AccelTable,(LPMSG)lpMsg); + if (m_ResetAccelerators) + { + m_ResetAccelerators = false; + RebuildAccelerators(); + } + if (!m_AccelTable) { return false; } + return TranslateAccelerator((HWND)hWnd, (HACCEL)m_AccelTable, (LPMSG)lpMsg); } bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuID) { - switch (MenuID) { - case ID_FILE_OPEN_ROM: - { - stdstr File = g_BaseSystem->ChooseFileToOpen(hWnd); - if (File.length() > 0) { - g_BaseSystem->RunFileImage(File.c_str()); - } - } - break; - case ID_FILE_ROM_INFO: - { - g_BaseSystem->DisplayRomInfo(hWnd); - } - break; - case ID_FILE_STARTEMULATION: - _Gui->SaveWindowLoc(); - //Before we go and create the new system, ensure the previous one has been closed - CN64System::CloseSystem(); - //Ok now g_BaseSystem should definitely be clean for initialization - g_BaseSystem = new CN64System(g_Plugins, false); - //Now we have created again, we can start up emulation - g_BaseSystem->StartEmulation(true); - break; - case ID_FILE_ENDEMULATION: - WriteTrace(TraceDebug,__FUNCTION__ ": ID_FILE_ENDEMULATION"); - CN64System::CloseSystem(); - _Gui->SaveWindowLoc(); - break; - case ID_FILE_ROMDIRECTORY: - WriteTrace(TraceDebug,__FUNCTION__ ": ID_FILE_ROMDIRECTORY 1"); - _Gui->SelectRomDir(); - WriteTrace(TraceDebug,__FUNCTION__ ": ID_FILE_ROMDIRECTORY 2"); - _Gui->RefreshMenu(); - WriteTrace(TraceDebug,__FUNCTION__ ": ID_FILE_ROMDIRECTORY 3"); - break; - case ID_FILE_REFRESHROMLIST: _Gui->RefreshRomBrowser(); break; - case ID_FILE_EXIT: DestroyWindow((HWND)hWnd); break; - case ID_SYSTEM_RESET_SOFT: - WriteTrace(TraceDebug,__FUNCTION__ ": ID_SYSTEM_RESET_SOFT"); - g_BaseSystem->ExternalEvent(SysEvent_ResetCPU_Soft); - break; - case ID_SYSTEM_RESET_HARD: - WriteTrace(TraceDebug,__FUNCTION__ ": ID_SYSTEM_RESET_HARD"); - g_BaseSystem->ExternalEvent(SysEvent_ResetCPU_Hard); - break; - case ID_SYSTEM_PAUSE: - _Gui->SaveWindowLoc(); - WriteTrace(TraceDebug,__FUNCTION__ ": ID_SYSTEM_PAUSE"); - if (g_Settings->LoadBool(GameRunning_CPU_Paused)) - { - g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_FromMenu); - } else { - g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_FromMenu); - } - WriteTrace(TraceDebug,__FUNCTION__ ": ID_SYSTEM_PAUSE 1"); - break; - case ID_SYSTEM_BITMAP: - { - stdstr Dir(g_Settings->LoadStringVal(Directory_SnapShot)); - WriteTraceF(TraceGfxPlugin,__FUNCTION__ ": CaptureScreen(%s): Starting",Dir.c_str()); - g_Plugins->Gfx()->CaptureScreen(Dir.c_str()); - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": CaptureScreen: Done"); - } - break; - case ID_SYSTEM_LIMITFPS: - WriteTrace(TraceDebug,__FUNCTION__ ": ID_SYSTEM_LIMITFPS"); - g_Settings->SaveBool(GameRunning_LimitFPS,!g_Settings->LoadBool(GameRunning_LimitFPS)); - WriteTrace(TraceDebug,__FUNCTION__ ": ID_SYSTEM_LIMITFPS 1"); - break; - case ID_SYSTEM_SAVE: - WriteTrace(TraceDebug,__FUNCTION__ ": ID_SYSTEM_SAVE"); - g_BaseSystem->ExternalEvent(SysEvent_SaveMachineState); - break; - case ID_SYSTEM_SAVEAS: - { - char drive[_MAX_DRIVE] ,dir[_MAX_DIR], fname[_MAX_FNAME],ext[_MAX_EXT]; - char Directory[255], SaveFile[255]; - OPENFILENAME openfilename; + switch (MenuID) { + case ID_FILE_OPEN_ROM: + { + stdstr File = g_BaseSystem->ChooseFileToOpen(hWnd); + if (File.length() > 0) { + g_BaseSystem->RunFileImage(File.c_str()); + } + } + break; + case ID_FILE_ROM_INFO: + { + g_BaseSystem->DisplayRomInfo(hWnd); + } + break; + case ID_FILE_STARTEMULATION: + _Gui->SaveWindowLoc(); + //Before we go and create the new system, ensure the previous one has been closed + CN64System::CloseSystem(); + //Ok now g_BaseSystem should definitely be clean for initialization + g_BaseSystem = new CN64System(g_Plugins, false); + //Now we have created again, we can start up emulation + g_BaseSystem->StartEmulation(true); + break; + case ID_FILE_ENDEMULATION: + WriteTrace(TraceDebug, __FUNCTION__ ": ID_FILE_ENDEMULATION"); + CN64System::CloseSystem(); + _Gui->SaveWindowLoc(); + break; + case ID_FILE_ROMDIRECTORY: + WriteTrace(TraceDebug, __FUNCTION__ ": ID_FILE_ROMDIRECTORY 1"); + _Gui->SelectRomDir(); + WriteTrace(TraceDebug, __FUNCTION__ ": ID_FILE_ROMDIRECTORY 2"); + _Gui->RefreshMenu(); + WriteTrace(TraceDebug, __FUNCTION__ ": ID_FILE_ROMDIRECTORY 3"); + break; + case ID_FILE_REFRESHROMLIST: _Gui->RefreshRomBrowser(); break; + case ID_FILE_EXIT: DestroyWindow((HWND)hWnd); break; + case ID_SYSTEM_RESET_SOFT: + WriteTrace(TraceDebug, __FUNCTION__ ": ID_SYSTEM_RESET_SOFT"); + g_BaseSystem->ExternalEvent(SysEvent_ResetCPU_Soft); + break; + case ID_SYSTEM_RESET_HARD: + WriteTrace(TraceDebug, __FUNCTION__ ": ID_SYSTEM_RESET_HARD"); + g_BaseSystem->ExternalEvent(SysEvent_ResetCPU_Hard); + break; + case ID_SYSTEM_PAUSE: + _Gui->SaveWindowLoc(); + WriteTrace(TraceDebug, __FUNCTION__ ": ID_SYSTEM_PAUSE"); + if (g_Settings->LoadBool(GameRunning_CPU_Paused)) + { + g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_FromMenu); + } + else + { + g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_FromMenu); + } + WriteTrace(TraceDebug, __FUNCTION__ ": ID_SYSTEM_PAUSE 1"); + break; + case ID_SYSTEM_BITMAP: + { + stdstr Dir(g_Settings->LoadStringVal(Directory_SnapShot)); + WriteTraceF(TraceGfxPlugin, __FUNCTION__ ": CaptureScreen(%s): Starting", Dir.c_str()); + g_Plugins->Gfx()->CaptureScreen(Dir.c_str()); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": CaptureScreen: Done"); + } + break; + case ID_SYSTEM_LIMITFPS: + WriteTrace(TraceDebug, __FUNCTION__ ": ID_SYSTEM_LIMITFPS"); + g_Settings->SaveBool(GameRunning_LimitFPS, !g_Settings->LoadBool(GameRunning_LimitFPS)); + WriteTrace(TraceDebug, __FUNCTION__ ": ID_SYSTEM_LIMITFPS 1"); + break; + case ID_SYSTEM_SAVE: + WriteTrace(TraceDebug, __FUNCTION__ ": ID_SYSTEM_SAVE"); + g_BaseSystem->ExternalEvent(SysEvent_SaveMachineState); + break; + case ID_SYSTEM_SAVEAS: + { + char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; + char Directory[255], SaveFile[255]; + OPENFILENAME openfilename; - memset(&SaveFile, 0, sizeof(SaveFile)); - memset(&openfilename, 0, sizeof(openfilename)); + memset(&SaveFile, 0, sizeof(SaveFile)); + memset(&openfilename, 0, sizeof(openfilename)); - g_Settings->LoadStringVal(Directory_LastSave, Directory,sizeof(Directory)); + g_Settings->LoadStringVal(Directory_LastSave, Directory, sizeof(Directory)); - openfilename.lStructSize = sizeof( openfilename ); - openfilename.hwndOwner = (HWND)hWnd; - openfilename.lpstrFilter = "PJ64 Saves (*.zip, *.pj)\0*.pj?;*.pj;*.zip;"; - openfilename.lpstrFile = SaveFile; - openfilename.lpstrInitialDir = Directory; - openfilename.nMaxFile = MAX_PATH; - openfilename.Flags = OFN_HIDEREADONLY; + openfilename.lStructSize = sizeof(openfilename); + openfilename.hwndOwner = (HWND)hWnd; + openfilename.lpstrFilter = "PJ64 Saves (*.zip, *.pj)\0*.pj?;*.pj;*.zip;"; + openfilename.lpstrFile = SaveFile; + openfilename.lpstrInitialDir = Directory; + openfilename.nMaxFile = MAX_PATH; + openfilename.Flags = OFN_HIDEREADONLY; - g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SaveGame); - if (GetSaveFileName (&openfilename)) - { + g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_SaveGame); + if (GetSaveFileName(&openfilename)) + { + _splitpath(SaveFile, drive, dir, fname, ext); + if (_stricmp(ext, ".pj") == 0 || _stricmp(ext, ".zip") == 0) + { + _makepath(SaveFile, drive, dir, fname, NULL); + _splitpath(SaveFile, drive, dir, fname, ext); + if (_stricmp(ext, ".pj") == 0) + { + _makepath(SaveFile, drive, dir, fname, NULL); + } + } + g_Settings->SaveString(GameRunning_InstantSaveFile, SaveFile); - _splitpath( SaveFile, drive, dir, fname, ext ); - if (_stricmp(ext, ".pj") == 0 || _stricmp(ext, ".zip") == 0) - { - _makepath( SaveFile, drive, dir, fname, NULL ); - _splitpath( SaveFile, drive, dir, fname, ext ); - if (_stricmp(ext, ".pj") == 0) - { - _makepath( SaveFile, drive, dir, fname, NULL ); - } - } - g_Settings->SaveString(GameRunning_InstantSaveFile, SaveFile); + char SaveDir[MAX_PATH]; + _makepath(SaveDir, drive, dir, NULL, NULL); + g_Settings->SaveString(Directory_LastSave, SaveDir); + g_BaseSystem->ExternalEvent(SysEvent_SaveMachineState); + } + g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SaveGame); + } + break; + case ID_SYSTEM_RESTORE: WriteTrace(TraceDebug, __FUNCTION__ ": ID_SYSTEM_RESTORE"); g_BaseSystem->ExternalEvent(SysEvent_LoadMachineState); break; + case ID_SYSTEM_LOAD: + { + char Directory[255], SaveFile[255]; + OPENFILENAME openfilename; - char SaveDir[MAX_PATH]; - _makepath( SaveDir, drive, dir, NULL, NULL ); - g_Settings->SaveString(Directory_LastSave,SaveDir); - g_BaseSystem->ExternalEvent(SysEvent_SaveMachineState); - } - g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_SaveGame); - } - break; - case ID_SYSTEM_RESTORE: WriteTrace(TraceDebug,__FUNCTION__ ": ID_SYSTEM_RESTORE"); g_BaseSystem->ExternalEvent(SysEvent_LoadMachineState); break; - case ID_SYSTEM_LOAD: - { - char Directory[255], SaveFile[255]; - OPENFILENAME openfilename; + memset(&SaveFile, 0, sizeof(SaveFile)); + memset(&openfilename, 0, sizeof(openfilename)); - memset(&SaveFile, 0, sizeof(SaveFile)); - memset(&openfilename, 0, sizeof(openfilename)); + g_Settings->LoadStringVal(Directory_LastSave, Directory, sizeof(Directory)); - g_Settings->LoadStringVal(Directory_LastSave, Directory,sizeof(Directory)); + openfilename.lStructSize = sizeof(openfilename); + openfilename.hwndOwner = (HWND)hWnd; + openfilename.lpstrFilter = "PJ64 Saves (*.zip, *.pj)\0*.pj?;*.pj;*.zip;"; + openfilename.lpstrFile = SaveFile; + openfilename.lpstrInitialDir = Directory; + openfilename.nMaxFile = MAX_PATH; + openfilename.Flags = OFN_HIDEREADONLY; - openfilename.lStructSize = sizeof( openfilename ); - openfilename.hwndOwner = (HWND)hWnd; - openfilename.lpstrFilter = "PJ64 Saves (*.zip, *.pj)\0*.pj?;*.pj;*.zip;"; - openfilename.lpstrFile = SaveFile; - openfilename.lpstrInitialDir = Directory; - openfilename.nMaxFile = MAX_PATH; - openfilename.Flags = OFN_HIDEREADONLY; + g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_LoadGame); + if (GetOpenFileName(&openfilename)) + { + g_Settings->SaveString(GameRunning_InstantSaveFile, SaveFile); + char SaveDir[MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; + _splitpath(SaveFile, drive, dir, fname, ext); + _makepath(SaveDir, drive, dir, NULL, NULL); + g_Settings->SaveString(Directory_LastSave, SaveDir); + g_System->LoadState(); + } + g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_LoadGame); + } + break; + case ID_SYSTEM_CHEAT: + { + CCheatsUI * cheatUI = new CCheatsUI; + g_cheatUI = cheatUI; + cheatUI->SelectCheats(hWnd, false); + } + break; + case ID_SYSTEM_GSBUTTON: + g_BaseSystem->ExternalEvent(SysEvent_GSButtonPressed); + break; + case ID_OPTIONS_DISPLAY_FR: + g_Settings->SaveBool(UserInterface_DisplayFrameRate, !g_Settings->LoadBool(UserInterface_DisplayFrameRate)); + break; + case ID_OPTIONS_CHANGE_FR: + switch (g_Settings->LoadDword(UserInterface_FrameDisplayType)) + { + case FR_VIs: + g_Settings->SaveDword(UserInterface_FrameDisplayType, FR_DLs); + break; + case FR_DLs: + g_Settings->SaveDword(UserInterface_FrameDisplayType, FR_PERCENT); + break; + default: + g_Settings->SaveDword(UserInterface_FrameDisplayType, FR_VIs); + } + break; + case ID_OPTIONS_INCREASE_SPEED: + g_BaseSystem->IncreaseSpeed(); + break; + case ID_OPTIONS_DECREASE_SPEED: + g_BaseSystem->DecreaseSpeed(); + break; + case ID_OPTIONS_FULLSCREEN: + g_BaseSystem->ExternalEvent(SysEvent_ChangingFullScreen); + break; + case ID_OPTIONS_FULLSCREEN2: + if (g_Settings->LoadBool(UserInterface_InFullScreen)) + { + WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN a"); + _Gui->MakeWindowOnTop(false); + Notify().SetGfxPlugin(NULL); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": ChangeWindow: Starting"); + g_Plugins->Gfx()->ChangeWindow(); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": ChangeWindow: Done"); + ShowCursor(true); + _Gui->ShowStatusBar(true); + _Gui->MakeWindowOnTop(g_Settings->LoadBool(UserInterface_AlwaysOnTop)); + g_Settings->SaveBool(UserInterface_InFullScreen, (DWORD)false); + } + else + { + WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN b"); + ShowCursor(false); + WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 1"); + _Gui->ShowStatusBar(false); + WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 2"); + try + { + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": ChangeWindow: Starting"); + g_Plugins->Gfx()->ChangeWindow(); + WriteTrace(TraceGfxPlugin, __FUNCTION__ ": ChangeWindow: Done"); + } + catch (...) + { + WriteTrace(TraceError, __FUNCTION__ ": Exception when going to full screen"); + char Message[600]; + sprintf(Message, "Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__); + MessageBox(NULL, Message, "Exception", MB_OK); + } + WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 4"); + _Gui->MakeWindowOnTop(false); + WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 5"); + Notify().SetGfxPlugin(g_Plugins->Gfx()); + WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 3"); + g_Settings->SaveBool(UserInterface_InFullScreen, true); + WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 6"); + } + WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN 1"); + break; + case ID_OPTIONS_ALWAYSONTOP: + if (g_Settings->LoadDword(UserInterface_AlwaysOnTop)) + { + g_Settings->SaveBool(UserInterface_AlwaysOnTop, false); + _Gui->MakeWindowOnTop(false); + } + else + { + g_Settings->SaveBool(UserInterface_AlwaysOnTop, true); + _Gui->MakeWindowOnTop(g_Settings->LoadBool(GameRunning_CPU_Running)); + } + break; + case ID_OPTIONS_CONFIG_RSP: WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_CONFIG_RSP"); g_Plugins->ConfigPlugin((DWORD)hWnd, PLUGIN_TYPE_RSP); break; + case ID_OPTIONS_CONFIG_GFX: WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_CONFIG_GFX"); g_Plugins->ConfigPlugin((DWORD)hWnd, PLUGIN_TYPE_GFX); break; + case ID_OPTIONS_CONFIG_AUDIO:WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_CONFIG_AUDIO"); g_Plugins->ConfigPlugin((DWORD)hWnd, PLUGIN_TYPE_AUDIO); break; + case ID_OPTIONS_CONFIG_CONT: WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_CONFIG_CONT"); g_Plugins->ConfigPlugin((DWORD)hWnd, PLUGIN_TYPE_CONTROLLER); break; + case ID_OPTIONS_CPU_USAGE: + WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_CPU_USAGE"); + if (g_Settings->LoadBool(UserInterface_ShowCPUPer)) + { + g_Settings->SaveBool(UserInterface_ShowCPUPer, false); + g_Notify->DisplayMessage(0, L""); + } + else + { + g_Settings->SaveBool(UserInterface_ShowCPUPer, true); + } + break; + case ID_OPTIONS_SETTINGS: + { + CSettingConfig SettingConfig; + SettingConfig.Display(hWnd); + } + break; + case ID_PROFILE_PROFILE: + g_Settings->SaveBool(Debugger_ProfileCode, !g_Settings->LoadBool(Debugger_ProfileCode)); + g_BaseSystem->ExternalEvent(SysEvent_Profile_StartStop); + break; + case ID_PROFILE_RESETCOUNTER: g_BaseSystem->ExternalEvent(SysEvent_Profile_ResetLogs); break; + case ID_PROFILE_GENERATELOG: g_BaseSystem->ExternalEvent(SysEvent_Profile_GenerateLogs); break; + case ID_DEBUG_SHOW_TLB_MISSES: + g_Settings->SaveBool(Debugger_ShowTLBMisses, !g_Settings->LoadBool(Debugger_ShowTLBMisses)); + break; + case ID_DEBUG_SHOW_UNHANDLED_MEM: + g_Settings->SaveBool(Debugger_ShowUnhandledMemory, !g_Settings->LoadBool(Debugger_ShowUnhandledMemory)); + break; + case ID_DEBUG_SHOW_PIF_ERRORS: + g_Settings->SaveBool(Debugger_ShowPifErrors, !g_Settings->LoadBool(Debugger_ShowPifErrors)); + break; + case ID_DEBUG_SHOW_DLIST_COUNT: + g_Notify->DisplayMessage(0, L""); + g_Settings->SaveBool(Debugger_ShowDListAListCount, !g_Settings->LoadBool(Debugger_ShowDListAListCount)); + break; + case ID_DEBUG_SHOW_RECOMP_MEM_SIZE: + g_Notify->DisplayMessage(0, L""); + g_Settings->SaveBool(Debugger_ShowRecompMemSize, !g_Settings->LoadBool(Debugger_ShowRecompMemSize)); + break; + case ID_DEBUG_SHOW_DIV_BY_ZERO: + g_Settings->SaveBool(Debugger_ShowDivByZero, !g_Settings->LoadBool(Debugger_ShowDivByZero)); + break; + case ID_DEBUG_GENERATE_LOG_FILES: + g_Settings->SaveBool(Debugger_GenerateLogFiles, !g_Settings->LoadBool(Debugger_GenerateLogFiles)); + break; + case ID_DEBUG_DISABLE_GAMEFIX: + g_Settings->SaveBool(Debugger_DisableGameFixes, !g_Settings->LoadBool(Debugger_DisableGameFixes)); + break; + case ID_DEBUGGER_APPLOG_ERRORS: + { + DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); + if ((LogLevel & TraceError) != 0) + { + LogLevel &= ~TraceError; + } + else + { + LogLevel |= TraceError; + } + g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel); + } + break; + case ID_DEBUGGER_APPLOG_SETTINGS: + { + DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); + if ((LogLevel & TraceSettings) != 0) + { + LogLevel &= ~TraceSettings; + } + else + { + LogLevel |= TraceSettings; + } + g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel); + } + break; + case ID_DEBUGGER_APPLOG_RECOMPILER: + { + DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); + if ((LogLevel & TraceRecompiler) != 0) + { + LogLevel &= ~TraceRecompiler; + } + else + { + LogLevel |= TraceRecompiler; + } + g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel); + } + break; + case ID_DEBUGGER_APPLOG_RSP: + { + DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); + if ((LogLevel & TraceRSP) != 0) + { + LogLevel &= ~TraceRSP; + } + else + { + LogLevel |= TraceRSP; + } + g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel); + } + break; + case ID_DEBUGGER_APPLOG_TLB: + { + DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); + if ((LogLevel & TraceTLB) != 0) + { + LogLevel &= ~TraceTLB; + } + else + { + LogLevel |= TraceTLB; + } + g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel); + } + break; + case ID_DEBUGGER_APPLOG_GFX_PLUGIN: + { + DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); + if ((LogLevel & TraceGfxPlugin) != 0) + { + LogLevel &= ~TraceGfxPlugin; + } + else + { + LogLevel |= TraceGfxPlugin; + } + g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel); + } + break; + case ID_DEBUGGER_APPLOG_DEBUG: + { + DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); + if ((LogLevel & TraceDebug) != 0) + { + LogLevel &= ~TraceDebug; + } + else + { + LogLevel |= TraceDebug; + } + g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel); + } + break; + case ID_DEBUGGER_APPLOG_AUDIO_EMU: + { + DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); + if ((LogLevel & TraceAudio) != 0) + { + LogLevel &= ~TraceAudio; + } + else + { + LogLevel |= TraceAudio; + } + g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel); + } + break; + case ID_DEBUGGER_APPLOG_FLUSH: + g_Settings->SaveBool(Debugger_AppLogFlush, !g_Settings->LoadBool(Debugger_AppLogFlush)); + break; + case ID_DEBUGGER_LOGOPTIONS: _Gui->EnterLogOptions(); break; + case ID_DEBUGGER_GENERATELOG: + g_Settings->SaveBool(Debugger_GenerateDebugLog, !g_Settings->LoadBool(Debugger_GenerateDebugLog)); + break; + case ID_DEBUGGER_DUMPMEMORY: _Gui->Debug_ShowMemoryDump(); break; + case ID_DEBUGGER_SEARCHMEMORY: _Gui->Debug_ShowMemorySearch(); break; + case ID_DEBUGGER_MEMORY: _Gui->Debug_ShowMemoryWindow(); break; + case ID_DEBUGGER_TLBENTRIES: _Gui->Debug_ShowTLBWindow(); break; + case ID_DEBUGGER_INTERRUPT_SP: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_SP); break; + case ID_DEBUGGER_INTERRUPT_SI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_SI); break; + case ID_DEBUGGER_INTERRUPT_AI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_AI); break; + case ID_DEBUGGER_INTERRUPT_VI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_VI); break; + case ID_DEBUGGER_INTERRUPT_PI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_PI); break; + case ID_DEBUGGER_INTERRUPT_DP: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_DP); break; + case ID_CURRENT_SAVE_DEFAULT: + Notify().DisplayMessage(3, stdstr_f("Save Slot (%s) selected", GetSaveSlotString(MenuID - ID_CURRENT_SAVE_DEFAULT).c_str()).ToUTF16().c_str()); + g_Settings->SaveDword(Game_CurrentSaveState, (DWORD)(MenuID - ID_CURRENT_SAVE_DEFAULT)); + break; + case ID_CURRENT_SAVE_1: + case ID_CURRENT_SAVE_2: + case ID_CURRENT_SAVE_3: + case ID_CURRENT_SAVE_4: + case ID_CURRENT_SAVE_5: + case ID_CURRENT_SAVE_6: + case ID_CURRENT_SAVE_7: + case ID_CURRENT_SAVE_8: + case ID_CURRENT_SAVE_9: + case ID_CURRENT_SAVE_10: + Notify().DisplayMessage(3, stdstr_f("Save Slot (%s) selected", GetSaveSlotString((MenuID - ID_CURRENT_SAVE_1) + 1)).ToUTF16().c_str()); + g_Settings->SaveDword(Game_CurrentSaveState, (DWORD)((MenuID - ID_CURRENT_SAVE_1) + 1)); + break; + case ID_HELP_SUPPORTFORUM: ShellExecute(NULL, "open", "http://forum.pj64-emu.com/", NULL, NULL, SW_SHOWMAXIMIZED); break; + case ID_HELP_HOMEPAGE: ShellExecute(NULL, "open", "http://www.pj64-emu.com", NULL, NULL, SW_SHOWMAXIMIZED); break; + case ID_HELP_ABOUT: _Gui->AboutBox(); break; + case ID_HELP_ABOUTSETTINGFILES: _Gui->AboutIniBox(); break; + default: + if (MenuID >= ID_RECENT_ROM_START && MenuID < ID_RECENT_ROM_END) + { + stdstr FileName; + if (g_Settings->LoadStringIndex(File_RecentGameFileIndex, MenuID - ID_RECENT_ROM_START, FileName) && + FileName.length() > 0) + { + g_BaseSystem->RunFileImage(FileName.c_str()); + } + } + if (MenuID >= ID_RECENT_DIR_START && MenuID < ID_RECENT_DIR_END) + { + int Offset = MenuID - ID_RECENT_DIR_START; + stdstr Dir = g_Settings->LoadStringIndex(Directory_RecentGameDirIndex, Offset); + if (Dir.length() > 0) + { + g_Settings->SaveString(Directory_Game, Dir.c_str()); + Notify().AddRecentDir(Dir.c_str()); + _Gui->RefreshMenu(); + if (_Gui->RomBrowserVisible()) + { + _Gui->RefreshRomBrowser(); + } + } + } + if (MenuID >= ID_LANG_START && MenuID < ID_LANG_END) + { + MENUITEMINFOW menuinfo; + wchar_t String[300]; - g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_LoadGame); - if (GetOpenFileName (&openfilename)) { - g_Settings->SaveString(GameRunning_InstantSaveFile,SaveFile); - char SaveDir[MAX_PATH], drive[_MAX_DRIVE] ,dir[_MAX_DIR], fname[_MAX_FNAME],ext[_MAX_EXT]; - _splitpath( SaveFile, drive, dir, fname, ext ); - _makepath( SaveDir, drive, dir, NULL, NULL ); - g_Settings->SaveString(Directory_LastSave,SaveDir); - g_System->LoadState(); - } - g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_LoadGame); - } - break; - case ID_SYSTEM_CHEAT: - { - CCheatsUI * cheatUI = new CCheatsUI; - g_cheatUI = cheatUI; - cheatUI->SelectCheats(hWnd, false); - } - break; - case ID_SYSTEM_GSBUTTON: - g_BaseSystem->ExternalEvent(SysEvent_GSButtonPressed); - break; - case ID_OPTIONS_DISPLAY_FR: - g_Settings->SaveBool(UserInterface_DisplayFrameRate,!g_Settings->LoadBool(UserInterface_DisplayFrameRate)); - break; - case ID_OPTIONS_CHANGE_FR: - switch (g_Settings->LoadDword(UserInterface_FrameDisplayType)) - { - case FR_VIs: - g_Settings->SaveDword(UserInterface_FrameDisplayType,FR_DLs); - break; - case FR_DLs: - g_Settings->SaveDword(UserInterface_FrameDisplayType,FR_PERCENT); - break; - default: - g_Settings->SaveDword(UserInterface_FrameDisplayType,FR_VIs); - } - break; - case ID_OPTIONS_INCREASE_SPEED: - g_BaseSystem->IncreaseSpeed(); - break; - case ID_OPTIONS_DECREASE_SPEED: - g_BaseSystem->DecreaseSpeed(); - break; - case ID_OPTIONS_FULLSCREEN: - g_BaseSystem->ExternalEvent(SysEvent_ChangingFullScreen); - break; - case ID_OPTIONS_FULLSCREEN2: - if (g_Settings->LoadBool(UserInterface_InFullScreen)) - { - WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_FULLSCREEN a"); - _Gui->MakeWindowOnTop(false); - Notify().SetGfxPlugin(NULL); - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": ChangeWindow: Starting"); - g_Plugins->Gfx()->ChangeWindow(); - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": ChangeWindow: Done"); - ShowCursor(true); - _Gui->ShowStatusBar(true); - _Gui->MakeWindowOnTop(g_Settings->LoadBool(UserInterface_AlwaysOnTop)); - g_Settings->SaveBool(UserInterface_InFullScreen,(DWORD)false); - } else { - WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_FULLSCREEN b"); - ShowCursor(false); - WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 1"); - _Gui->ShowStatusBar(false); - WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 2"); - try { - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": ChangeWindow: Starting"); - g_Plugins->Gfx()->ChangeWindow(); - WriteTrace(TraceGfxPlugin,__FUNCTION__ ": ChangeWindow: Done"); - } - catch (...) - { - WriteTrace(TraceError,__FUNCTION__ ": Exception when going to full screen"); - char Message[600]; - sprintf(Message,"Exception caught\nFile: %s\nLine: %d",__FILE__,__LINE__); - MessageBox(NULL,Message,"Exception",MB_OK); - } - WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 4"); - _Gui->MakeWindowOnTop(false); - WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 5"); - Notify().SetGfxPlugin(g_Plugins->Gfx()); - WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 3"); - g_Settings->SaveBool(UserInterface_InFullScreen,true); - WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 6"); - } - WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_FULLSCREEN 1"); - break; - case ID_OPTIONS_ALWAYSONTOP: - if (g_Settings->LoadDword(UserInterface_AlwaysOnTop)) { - g_Settings->SaveBool(UserInterface_AlwaysOnTop,false); - _Gui->MakeWindowOnTop(false); - } else { - g_Settings->SaveBool(UserInterface_AlwaysOnTop,true); - _Gui->MakeWindowOnTop(g_Settings->LoadBool(GameRunning_CPU_Running)); - } - break; - case ID_OPTIONS_CONFIG_RSP: WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_CONFIG_RSP"); g_Plugins->ConfigPlugin((DWORD)hWnd,PLUGIN_TYPE_RSP); break; - case ID_OPTIONS_CONFIG_GFX: WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_CONFIG_GFX"); g_Plugins->ConfigPlugin((DWORD)hWnd,PLUGIN_TYPE_GFX); break; - case ID_OPTIONS_CONFIG_AUDIO:WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_CONFIG_AUDIO"); g_Plugins->ConfigPlugin((DWORD)hWnd,PLUGIN_TYPE_AUDIO); break; - case ID_OPTIONS_CONFIG_CONT: WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_CONFIG_CONT"); g_Plugins->ConfigPlugin((DWORD)hWnd,PLUGIN_TYPE_CONTROLLER); break; - case ID_OPTIONS_CPU_USAGE: - WriteTrace(TraceDebug,__FUNCTION__ ": ID_OPTIONS_CPU_USAGE"); - if (g_Settings->LoadBool(UserInterface_ShowCPUPer)) - { - g_Settings->SaveBool(UserInterface_ShowCPUPer,false); - g_Notify->DisplayMessage(0,L""); - } else { - g_Settings->SaveBool(UserInterface_ShowCPUPer,true); - } - break; - case ID_OPTIONS_SETTINGS: - { - CSettingConfig SettingConfig; - SettingConfig.Display(hWnd); - } - break; - case ID_PROFILE_PROFILE: - g_Settings->SaveBool(Debugger_ProfileCode,!g_Settings->LoadBool(Debugger_ProfileCode)); - g_BaseSystem->ExternalEvent(SysEvent_Profile_StartStop); - break; - case ID_PROFILE_RESETCOUNTER: g_BaseSystem->ExternalEvent(SysEvent_Profile_ResetLogs); break; - case ID_PROFILE_GENERATELOG: g_BaseSystem->ExternalEvent(SysEvent_Profile_GenerateLogs); break; - case ID_DEBUG_SHOW_TLB_MISSES: - g_Settings->SaveBool(Debugger_ShowTLBMisses,!g_Settings->LoadBool(Debugger_ShowTLBMisses)); - break; - case ID_DEBUG_SHOW_UNHANDLED_MEM: - g_Settings->SaveBool(Debugger_ShowUnhandledMemory,!g_Settings->LoadBool(Debugger_ShowUnhandledMemory)); - break; - case ID_DEBUG_SHOW_PIF_ERRORS: - g_Settings->SaveBool(Debugger_ShowPifErrors,!g_Settings->LoadBool(Debugger_ShowPifErrors)); - break; - case ID_DEBUG_SHOW_DLIST_COUNT: - g_Notify->DisplayMessage(0,L""); - g_Settings->SaveBool(Debugger_ShowDListAListCount,!g_Settings->LoadBool(Debugger_ShowDListAListCount)); - break; - case ID_DEBUG_SHOW_RECOMP_MEM_SIZE: - g_Notify->DisplayMessage(0,L""); - g_Settings->SaveBool(Debugger_ShowRecompMemSize,!g_Settings->LoadBool(Debugger_ShowRecompMemSize)); - break; - case ID_DEBUG_SHOW_DIV_BY_ZERO: - g_Settings->SaveBool(Debugger_ShowDivByZero,!g_Settings->LoadBool(Debugger_ShowDivByZero)); - break; - case ID_DEBUG_GENERATE_LOG_FILES: - g_Settings->SaveBool(Debugger_GenerateLogFiles,!g_Settings->LoadBool(Debugger_GenerateLogFiles)); - break; - case ID_DEBUG_DISABLE_GAMEFIX: - g_Settings->SaveBool(Debugger_DisableGameFixes,!g_Settings->LoadBool(Debugger_DisableGameFixes)); - break; - case ID_DEBUGGER_APPLOG_ERRORS: - { - DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); - if ((LogLevel & TraceError) != 0) - { - LogLevel &= ~TraceError; - } else { - LogLevel |= TraceError; - } - g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel ); - } - break; - case ID_DEBUGGER_APPLOG_SETTINGS: - { - DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); - if ((LogLevel & TraceSettings) != 0) - { - LogLevel &= ~TraceSettings; - } else { + menuinfo.cbSize = sizeof(MENUITEMINFO); + menuinfo.fMask = MIIM_TYPE; + menuinfo.fType = MFT_STRING; + menuinfo.dwTypeData = String; + menuinfo.cch = sizeof(String); + GetMenuItemInfoW((HMENU)m_MenuHandle, MenuID, FALSE, &menuinfo); - LogLevel |= TraceSettings; - } - g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel ); - } - break; - case ID_DEBUGGER_APPLOG_RECOMPILER: - { - DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); - if ((LogLevel & TraceRecompiler) != 0) - { - LogLevel &= ~TraceRecompiler; - } else { - - LogLevel |= TraceRecompiler; - } - g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel ); - } - break; - case ID_DEBUGGER_APPLOG_RSP: - { - DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); - if ((LogLevel & TraceRSP) != 0) - { - LogLevel &= ~TraceRSP; - } else { - - LogLevel |= TraceRSP; - } - g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel ); - } - break; - case ID_DEBUGGER_APPLOG_TLB: - { - DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); - if ((LogLevel & TraceTLB) != 0) - { - LogLevel &= ~TraceTLB; - } else { - - LogLevel |= TraceTLB; - } - g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel ); - } - break; - case ID_DEBUGGER_APPLOG_GFX_PLUGIN: - { - DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); - if ((LogLevel & TraceGfxPlugin) != 0) - { - LogLevel &= ~TraceGfxPlugin; - } else { - - LogLevel |= TraceGfxPlugin; - } - g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel ); - } - break; - case ID_DEBUGGER_APPLOG_DEBUG: - { - DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); - if ((LogLevel & TraceDebug) != 0) - { - LogLevel &= ~TraceDebug; - } else { - - LogLevel |= TraceDebug; - } - g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel ); - } - break; - case ID_DEBUGGER_APPLOG_AUDIO_EMU: - { - DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); - if ((LogLevel & TraceAudio) != 0) - { - LogLevel &= ~TraceAudio; - } else { - - LogLevel |= TraceAudio; - } - g_Settings->SaveDword(Debugger_AppLogLevel, LogLevel ); - } - break; - case ID_DEBUGGER_APPLOG_FLUSH: - g_Settings->SaveBool(Debugger_AppLogFlush,!g_Settings->LoadBool(Debugger_AppLogFlush)); - break; - case ID_DEBUGGER_LOGOPTIONS: _Gui->EnterLogOptions(); break; - case ID_DEBUGGER_GENERATELOG: - g_Settings->SaveBool(Debugger_GenerateDebugLog,!g_Settings->LoadBool(Debugger_GenerateDebugLog)); - break; - case ID_DEBUGGER_DUMPMEMORY: _Gui->Debug_ShowMemoryDump(); break; - case ID_DEBUGGER_SEARCHMEMORY: _Gui->Debug_ShowMemorySearch(); break; - case ID_DEBUGGER_MEMORY: _Gui->Debug_ShowMemoryWindow(); break; - case ID_DEBUGGER_TLBENTRIES: _Gui->Debug_ShowTLBWindow(); break; - case ID_DEBUGGER_INTERRUPT_SP: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_SP); break; - case ID_DEBUGGER_INTERRUPT_SI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_SI); break; - case ID_DEBUGGER_INTERRUPT_AI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_AI); break; - case ID_DEBUGGER_INTERRUPT_VI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_VI); break; - case ID_DEBUGGER_INTERRUPT_PI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_PI); break; - case ID_DEBUGGER_INTERRUPT_DP: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_DP); break; - case ID_CURRENT_SAVE_DEFAULT: - Notify().DisplayMessage(3,stdstr_f("Save Slot (%s) selected",GetSaveSlotString(MenuID - ID_CURRENT_SAVE_DEFAULT).c_str()).ToUTF16().c_str()); - g_Settings->SaveDword(Game_CurrentSaveState,(DWORD)(MenuID - ID_CURRENT_SAVE_DEFAULT)); - break; - case ID_CURRENT_SAVE_1: - case ID_CURRENT_SAVE_2: - case ID_CURRENT_SAVE_3: - case ID_CURRENT_SAVE_4: - case ID_CURRENT_SAVE_5: - case ID_CURRENT_SAVE_6: - case ID_CURRENT_SAVE_7: - case ID_CURRENT_SAVE_8: - case ID_CURRENT_SAVE_9: - case ID_CURRENT_SAVE_10: - Notify().DisplayMessage(3,stdstr_f("Save Slot (%s) selected",GetSaveSlotString((MenuID - ID_CURRENT_SAVE_1) + 1)).ToUTF16().c_str()); - g_Settings->SaveDword(Game_CurrentSaveState,(DWORD)((MenuID - ID_CURRENT_SAVE_1) + 1)); - break; - case ID_HELP_SUPPORTFORUM: ShellExecute(NULL, "open", "http://forum.pj64-emu.com/", NULL, NULL, SW_SHOWMAXIMIZED); break; - case ID_HELP_HOMEPAGE: ShellExecute(NULL, "open", "http://www.pj64-emu.com", NULL, NULL, SW_SHOWMAXIMIZED); break; - case ID_HELP_ABOUT: _Gui->AboutBox(); break; - case ID_HELP_ABOUTSETTINGFILES: _Gui->AboutIniBox(); break; - default: - if (MenuID >= ID_RECENT_ROM_START && MenuID < ID_RECENT_ROM_END) { - stdstr FileName; - if (g_Settings->LoadStringIndex(File_RecentGameFileIndex,MenuID - ID_RECENT_ROM_START,FileName) && - FileName.length() > 0) - { - g_BaseSystem->RunFileImage(FileName.c_str()); - } - } - if (MenuID >= ID_RECENT_DIR_START && MenuID < ID_RECENT_DIR_END) { - int Offset = MenuID - ID_RECENT_DIR_START; - stdstr Dir = g_Settings->LoadStringIndex(Directory_RecentGameDirIndex,Offset); - if (Dir.length() > 0) { - g_Settings->SaveString(Directory_Game,Dir.c_str()); - Notify().AddRecentDir(Dir.c_str()); - _Gui->RefreshMenu(); - if (_Gui->RomBrowserVisible()) { - _Gui->RefreshRomBrowser(); - } - } - } - if (MenuID >= ID_LANG_START && MenuID < ID_LANG_END) { - MENUITEMINFOW menuinfo; - wchar_t String[300]; - - menuinfo.cbSize = sizeof(MENUITEMINFO); - menuinfo.fMask = MIIM_TYPE; - menuinfo.fType = MFT_STRING; - menuinfo.dwTypeData = String; - menuinfo.cch = sizeof(String); - GetMenuItemInfoW((HMENU)m_MenuHandle,MenuID,FALSE,&menuinfo); - - //See if the language has changed, if not do nothing - //Set the language - g_Lang->SetLanguage(String); - _Gui->ResetRomBrowserColomuns(); - break; - } - return false; - } - return true; + //See if the language has changed, if not do nothing + //Set the language + g_Lang->SetLanguage(String); + _Gui->ResetRomBrowserColomuns(); + break; + } + return false; + } + return true; } -/*stdstr CMainMenu::ShortCutString(MSC_MAP & ShortCuts, int MenuID, CMenuShortCutKey::ACCESS_MODE AccessLevel) { - Notify().BreakPoint(__FILEW__,__LINE__); - MSC_MAP::iterator MenuItem = ShortCuts.find(MenuID); - if (MenuItem == ShortCuts.end()) { return ""; } - - const SHORTCUT_KEY_LIST & ShortCutList = MenuItem->second.GetAccelItems(); - for (SHORTCUT_KEY_LIST::const_iterator item = ShortCutList.begin(); item != ShortCutList.end(); item++) - { - CMenuShortCutKey::ACCESS_MODE ItemMode = item->AccessMode(); - if ((ItemMode & AccessLevel) != AccessLevel ) - { - continue; - } - return item->Name(); - } - return ""; -}*/ - -stdstr CMainMenu::GetFileLastMod (stdstr FileName) +stdstr CMainMenu::GetFileLastMod(stdstr FileName) { - HANDLE hFile = CreateFile(FileName.c_str(), GENERIC_READ, FILE_SHARE_READ,NULL, - OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); - if (hFile == INVALID_HANDLE_VALUE) - { - return ""; - } - FILETIME CreationTime, LastAccessTime, LastWriteTime; - stdstr LastMod; - if (GetFileTime(hFile,&CreationTime,&LastAccessTime,&LastWriteTime)) - { - SYSTEMTIME stUTC, stLocal; + HANDLE hFile = CreateFile(FileName.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); + if (hFile == INVALID_HANDLE_VALUE) + { + return ""; + } + FILETIME CreationTime, LastAccessTime, LastWriteTime; + stdstr LastMod; + if (GetFileTime(hFile, &CreationTime, &LastAccessTime, &LastWriteTime)) + { + SYSTEMTIME stUTC, stLocal; - // Convert the last-write time to local time. - FileTimeToSystemTime(&LastWriteTime, &stUTC); - SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal); - - LastMod.Format(" [%d/%02d/%02d %02d:%02d]", - stLocal.wYear, stLocal.wMonth, stLocal.wDay,stLocal.wHour, stLocal.wMinute); - } - CloseHandle(hFile); + // Convert the last-write time to local time. + FileTimeToSystemTime(&LastWriteTime, &stUTC); + SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal); - return LastMod; + LastMod.Format(" [%d/%02d/%02d %02d:%02d]", stLocal.wYear, stLocal.wMonth, stLocal.wDay, stLocal.wHour, stLocal.wMinute); + } + CloseHandle(hFile); + + return LastMod; } -std::wstring CMainMenu::GetSaveSlotString (int Slot) +std::wstring CMainMenu::GetSaveSlotString(int Slot) { - std::wstring SlotName; - switch (Slot) - { - case 0: SlotName = GS(MENU_SLOT_DEFAULT); break; - case 1: SlotName = GS(MENU_SLOT_1); break; - case 2: SlotName = GS(MENU_SLOT_2); break; - case 3: SlotName = GS(MENU_SLOT_3); break; - case 4: SlotName = GS(MENU_SLOT_4); break; - case 5: SlotName = GS(MENU_SLOT_5); break; - case 6: SlotName = GS(MENU_SLOT_6); break; - case 7: SlotName = GS(MENU_SLOT_7); break; - case 8: SlotName = GS(MENU_SLOT_8); break; - case 9: SlotName = GS(MENU_SLOT_9); break; - case 10: SlotName = GS(MENU_SLOT_10); break; - } + std::wstring SlotName; + switch (Slot) + { + case 0: SlotName = GS(MENU_SLOT_DEFAULT); break; + case 1: SlotName = GS(MENU_SLOT_1); break; + case 2: SlotName = GS(MENU_SLOT_2); break; + case 3: SlotName = GS(MENU_SLOT_3); break; + case 4: SlotName = GS(MENU_SLOT_4); break; + case 5: SlotName = GS(MENU_SLOT_5); break; + case 6: SlotName = GS(MENU_SLOT_6); break; + case 7: SlotName = GS(MENU_SLOT_7); break; + case 8: SlotName = GS(MENU_SLOT_8); break; + case 9: SlotName = GS(MENU_SLOT_9); break; + case 10: SlotName = GS(MENU_SLOT_10); break; + } - if (!g_Settings->LoadBool(GameRunning_CPU_Running)) { return SlotName; } + if (!g_Settings->LoadBool(GameRunning_CPU_Running)) { return SlotName; } - stdstr LastSaveTime; + stdstr LastSaveTime; - //check first save name - stdstr _GoodName = g_Settings->LoadStringVal(Game_GoodName); - stdstr _InstantSaveDirectory = g_Settings->LoadStringVal(Directory_InstantSave); - stdstr CurrentSaveName; - if (Slot != 0) - { - CurrentSaveName.Format("%s.pj%d",_GoodName.c_str(), Slot); - } - else - { - CurrentSaveName.Format("%s.pj",_GoodName.c_str()); - } - stdstr_f FileName("%s%s",_InstantSaveDirectory.c_str(),CurrentSaveName.c_str()); - - if (g_Settings->LoadDword(Setting_AutoZipInstantSave)) - { - stdstr_f ZipFileName("%s.zip",FileName.c_str()); - LastSaveTime = GetFileLastMod(ZipFileName); - } - if (LastSaveTime.empty()) - { - LastSaveTime = GetFileLastMod(FileName); - } + //check first save name + stdstr _GoodName = g_Settings->LoadStringVal(Game_GoodName); + stdstr _InstantSaveDirectory = g_Settings->LoadStringVal(Directory_InstantSave); + stdstr CurrentSaveName; + if (Slot != 0) + { + CurrentSaveName.Format("%s.pj%d", _GoodName.c_str(), Slot); + } + else + { + CurrentSaveName.Format("%s.pj", _GoodName.c_str()); + } + stdstr_f FileName("%s%s", _InstantSaveDirectory.c_str(), CurrentSaveName.c_str()); - // Check old file name - if (LastSaveTime.empty()) - { - stdstr _RomName = g_Settings->LoadStringVal(Game_GameName); - if (Slot > 0) - { - FileName.Format("%s%s.pj%d", _InstantSaveDirectory.c_str(), _RomName.c_str(),Slot); - } - else - { - FileName.Format("%s%s.pj",_InstantSaveDirectory.c_str(),_RomName.c_str()); - } - - if (g_Settings->LoadBool(Setting_AutoZipInstantSave)) - { - stdstr_f ZipFileName("%s.zip",FileName.c_str()); - LastSaveTime = GetFileLastMod(ZipFileName); - } - if (LastSaveTime.empty()) - { - LastSaveTime = GetFileLastMod(FileName); - } - } - SlotName += LastSaveTime.ToUTF16(); - return SlotName; + if (g_Settings->LoadDword(Setting_AutoZipInstantSave)) + { + stdstr_f ZipFileName("%s.zip", FileName.c_str()); + LastSaveTime = GetFileLastMod(ZipFileName); + } + if (LastSaveTime.empty()) + { + LastSaveTime = GetFileLastMod(FileName); + } + + // Check old file name + if (LastSaveTime.empty()) + { + stdstr _RomName = g_Settings->LoadStringVal(Game_GameName); + if (Slot > 0) + { + FileName.Format("%s%s.pj%d", _InstantSaveDirectory.c_str(), _RomName.c_str(), Slot); + } + else + { + FileName.Format("%s%s.pj", _InstantSaveDirectory.c_str(), _RomName.c_str()); + } + + if (g_Settings->LoadBool(Setting_AutoZipInstantSave)) + { + stdstr_f ZipFileName("%s.zip", FileName.c_str()); + LastSaveTime = GetFileLastMod(ZipFileName); + } + if (LastSaveTime.empty()) + { + LastSaveTime = GetFileLastMod(FileName); + } + } + SlotName += LastSaveTime.ToUTF16(); + return SlotName; } -void CMainMenu::FillOutMenu ( HMENU hMenu ) +void CMainMenu::FillOutMenu(HMENU hMenu) { - CGuard Guard(m_CS); + CGuard Guard(m_CS); - MENU_ITEM Item; + MENU_ITEM Item; - //Get all flags - bool inBasicMode = g_Settings->LoadBool(UserInterface_BasicMode); - bool CPURunning = g_Settings->LoadBool(GameRunning_CPU_Running); - bool RomLoading = g_Settings->LoadBool(GameRunning_LoadingInProgress); - bool RomLoaded = g_Settings->LoadStringVal(Game_GameName).length() > 0; - bool RomList = g_Settings->LoadBool(RomBrowser_Enabled) && !CPURunning; - - CMenuShortCutKey::ACCESS_MODE AccessLevel = CMenuShortCutKey::GAME_NOT_RUNNING; - if (g_Settings->LoadBool(GameRunning_CPU_Running)) - { - AccessLevel = g_Settings->LoadBool(UserInterface_InFullScreen) ? - CMenuShortCutKey::GAME_RUNNING_FULLSCREEN : - CMenuShortCutKey::GAME_RUNNING_WINDOW; - } - - //Get the system information to make the menu - LanguageList LangList = g_Lang->GetLangList(); - - MenuItemList LangMenu; - int Offset = 0; - for (LanguageList::iterator Language = LangList.begin(); Language != LangList.end(); Language++) + //Get all flags + bool inBasicMode = g_Settings->LoadBool(UserInterface_BasicMode); + bool CPURunning = g_Settings->LoadBool(GameRunning_CPU_Running); + bool RomLoading = g_Settings->LoadBool(GameRunning_LoadingInProgress); + bool RomLoaded = g_Settings->LoadStringVal(Game_GameName).length() > 0; + bool RomList = g_Settings->LoadBool(RomBrowser_Enabled) && !CPURunning; + + CMenuShortCutKey::ACCESS_MODE AccessLevel = CMenuShortCutKey::GAME_NOT_RUNNING; + if (g_Settings->LoadBool(GameRunning_CPU_Running)) { - Item.Reset(ID_LANG_START + Offset++,EMPTY_STRING,EMPTY_STDSTR,NULL,Language->LanguageName.c_str()); - if (g_Lang->IsCurrentLang(*Language)) - { - Item.SetItemTicked(true); - } - LangMenu.push_back(Item); - } + AccessLevel = g_Settings->LoadBool(UserInterface_InFullScreen) ? CMenuShortCutKey::GAME_RUNNING_FULLSCREEN : CMenuShortCutKey::GAME_RUNNING_WINDOW; + } - //Go through the settings to create a list of Recent Roms - MenuItemList RecentRomMenu; - DWORD count, RomsToRemember = g_Settings->LoadDword(File_RecentGameFileCount); + //Get the system information to make the menu + LanguageList LangList = g_Lang->GetLangList(); - for (count = 0; count < RomsToRemember; count++) + MenuItemList LangMenu; + int Offset = 0; + for (LanguageList::iterator Language = LangList.begin(); Language != LangList.end(); Language++) { - stdstr LastRom = g_Settings->LoadStringIndex(File_RecentGameFileIndex,count); - if (LastRom.empty()) - { - break; - } - stdstr_f MenuString("&%d %s",(count + 1) % 10,LastRom.c_str()); - - WCHAR *w_LastRom = new WCHAR[MenuString.length() + 1]; - ::mbstowcs(w_LastRom, MenuString.c_str(), MenuString.length() + 1); - RecentRomMenu.push_back(MENU_ITEM(ID_RECENT_ROM_START + count, EMPTY_STRING, EMPTY_STDSTR, NULL, w_LastRom)); - delete[] w_LastRom; - } - - - /* Recent Dir - ****************/ - MenuItemList RecentDirMenu; - DWORD DirsToRemember = g_Settings->LoadDword(Directory_RecentGameDirCount); - - for (count = 0; count < DirsToRemember; count++) - { - stdstr LastDir = g_Settings->LoadStringIndex(Directory_RecentGameDirIndex,count); - if (LastDir.empty()) - { - break; - } - - stdstr_f MenuString("&%d %s",(count + 1) % 10,LastDir.c_str()); - - WCHAR *w_LastDir = new WCHAR[MenuString.length() + 1]; - ::mbstowcs(w_LastDir, MenuString.c_str(), MenuString.length() + 1); - RecentDirMenu.push_back(MENU_ITEM(ID_RECENT_DIR_START + count, EMPTY_STRING, EMPTY_STDSTR, NULL, w_LastDir)); - delete[] w_LastDir; - } - - /* File Menu - ****************/ - MenuItemList FileMenu; - Item.Reset(ID_FILE_OPEN_ROM, MENU_OPEN, m_ShortCuts.ShortCutString(ID_FILE_OPEN_ROM,AccessLevel)); - FileMenu.push_back(Item); - if (!inBasicMode) - { - Item.Reset(ID_FILE_ROM_INFO, MENU_ROM_INFO,m_ShortCuts.ShortCutString(ID_FILE_ROM_INFO,AccessLevel)); - Item.SetItemEnabled(RomLoaded); - FileMenu.push_back(Item); - FileMenu.push_back(MENU_ITEM(SPLITER)); - Item.Reset(ID_FILE_STARTEMULATION,MENU_START, m_ShortCuts.ShortCutString(ID_FILE_STARTEMULATION,AccessLevel) ); - Item.SetItemEnabled(RomLoaded && !CPURunning); - FileMenu.push_back(Item); - } - Item.Reset(ID_FILE_ENDEMULATION, MENU_END, m_ShortCuts.ShortCutString(ID_FILE_ENDEMULATION,AccessLevel) ); - Item.SetItemEnabled(CPURunning); - FileMenu.push_back(Item); - FileMenu.push_back(MENU_ITEM(SPLITER)); - Item.Reset(SUB_MENU, MENU_LANGUAGE, EMPTY_STDSTR, &LangMenu ); - FileMenu.push_back(Item); - if (RomList) - { - FileMenu.push_back(MENU_ITEM(SPLITER)); - Item.Reset(ID_FILE_ROMDIRECTORY, MENU_CHOOSE_ROM,m_ShortCuts.ShortCutString(ID_FILE_ROMDIRECTORY,AccessLevel) ); - FileMenu.push_back(Item); - Item.Reset(ID_FILE_REFRESHROMLIST,MENU_REFRESH,m_ShortCuts.ShortCutString(ID_FILE_REFRESHROMLIST,AccessLevel) ); - FileMenu.push_back(Item); - } - - if (!inBasicMode && RomList) - { - FileMenu.push_back(MENU_ITEM(SPLITER)); - Item.Reset(SUB_MENU, MENU_RECENT_ROM,EMPTY_STDSTR, &RecentRomMenu); - if (RecentRomMenu.size() == 0) + Item.Reset(ID_LANG_START + Offset++, EMPTY_STRING, EMPTY_STDSTR, NULL, Language->LanguageName.c_str()); + if (g_Lang->IsCurrentLang(*Language)) { - RecentRomMenu.push_back(MENU_ITEM(SPLITER)); - Item.SetItemEnabled(false); - } - FileMenu.push_back(Item); - Item.Reset(SUB_MENU, MENU_RECENT_DIR,EMPTY_STDSTR, &RecentDirMenu); - if (RecentDirMenu.size() == 0) - { - RecentDirMenu.push_back(MENU_ITEM(SPLITER)); - Item.SetItemEnabled(false); - } - FileMenu.push_back(Item); - } - else - { - if (RecentRomMenu.size() != 0) - { - FileMenu.push_back(MENU_ITEM(SPLITER)); - for (MenuItemList::iterator MenuItem = RecentRomMenu.begin(); MenuItem != RecentRomMenu.end(); MenuItem++) - { - FileMenu.push_back(*MenuItem); - } - } - } - FileMenu.push_back(MENU_ITEM(SPLITER)); - FileMenu.push_back(MENU_ITEM(ID_FILE_EXIT, MENU_EXIT,m_ShortCuts.ShortCutString(ID_FILE_EXIT,AccessLevel))); - - /* Current Save - ****************/ - MenuItemList CurrentSaveMenu; - DWORD _CurrentSaveState = g_Settings->LoadDword(Game_CurrentSaveState); - Item.Reset(ID_CURRENT_SAVE_DEFAULT, EMPTY_STRING,m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_DEFAULT,AccessLevel),NULL,GetSaveSlotString(0)); - if (_CurrentSaveState == 0) { Item.SetItemTicked(true); } - CurrentSaveMenu.push_back(Item); - CurrentSaveMenu.push_back(MENU_ITEM(SPLITER)); - Item.Reset(ID_CURRENT_SAVE_1, EMPTY_STRING,m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_1,AccessLevel),NULL,GetSaveSlotString(1)); - if (_CurrentSaveState == 1) { Item.SetItemTicked(true); } - CurrentSaveMenu.push_back(Item); - Item.Reset(ID_CURRENT_SAVE_2, EMPTY_STRING,m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_2,AccessLevel),NULL,GetSaveSlotString(2)); - if (_CurrentSaveState == 2) { Item.SetItemTicked(true); } - CurrentSaveMenu.push_back(Item); - Item.Reset(ID_CURRENT_SAVE_3, EMPTY_STRING,m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_3,AccessLevel),NULL,GetSaveSlotString(3)); - if (_CurrentSaveState == 3) { Item.SetItemTicked(true); } - CurrentSaveMenu.push_back(Item); - Item.Reset(ID_CURRENT_SAVE_4, EMPTY_STRING,m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_4,AccessLevel),NULL,GetSaveSlotString(4)); - if (_CurrentSaveState == 4) { Item.SetItemTicked(true); } - CurrentSaveMenu.push_back(Item); - Item.Reset(ID_CURRENT_SAVE_5, EMPTY_STRING,m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_5,AccessLevel),NULL,GetSaveSlotString(5)); - if (_CurrentSaveState == 5) { Item.SetItemTicked(true); } - CurrentSaveMenu.push_back(Item); - Item.Reset(ID_CURRENT_SAVE_6, EMPTY_STRING,m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_6,AccessLevel),NULL,GetSaveSlotString(6)); - if (_CurrentSaveState == 6) { Item.SetItemTicked(true); } - CurrentSaveMenu.push_back(Item); - Item.Reset(ID_CURRENT_SAVE_7, EMPTY_STRING,m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_7,AccessLevel),NULL,GetSaveSlotString(7)); - if (_CurrentSaveState == 7) { Item.SetItemTicked(true); } - CurrentSaveMenu.push_back(Item); - Item.Reset(ID_CURRENT_SAVE_8, EMPTY_STRING,m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_8,AccessLevel),NULL,GetSaveSlotString(8)); - if (_CurrentSaveState == 8) { Item.SetItemTicked(true); } - CurrentSaveMenu.push_back(Item); - Item.Reset(ID_CURRENT_SAVE_9, EMPTY_STRING,m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_9,AccessLevel),NULL,GetSaveSlotString(9)); - if (_CurrentSaveState == 9) { Item.SetItemTicked(true); } - CurrentSaveMenu.push_back(Item); - Item.Reset(ID_CURRENT_SAVE_10, EMPTY_STRING,m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_10,AccessLevel),NULL,GetSaveSlotString(10)); - if (_CurrentSaveState == 10) { Item.SetItemTicked(true); } - CurrentSaveMenu.push_back(Item); - - /* System Menu - ****************/ - MenuItemList SystemMenu; - MenuItemList ResetMenu; - if (inBasicMode) - { - SystemMenu.push_back(MENU_ITEM(ID_SYSTEM_RESET_SOFT, MENU_RESET, m_ShortCuts.ShortCutString(ID_SYSTEM_RESET_SOFT,AccessLevel) )); - } - else - { - ResetMenu.push_back(MENU_ITEM(ID_SYSTEM_RESET_SOFT, MENU_RESET_SOFT, m_ShortCuts.ShortCutString(ID_SYSTEM_RESET_SOFT,AccessLevel) )); - ResetMenu.push_back(MENU_ITEM(ID_SYSTEM_RESET_HARD, MENU_RESET_HARD, m_ShortCuts.ShortCutString(ID_SYSTEM_RESET_HARD,AccessLevel))); - SystemMenu.push_back(MENU_ITEM(SUB_MENU,MENU_RESET,EMPTY_STDSTR,&ResetMenu)); - } - if (g_Settings->LoadBool(GameRunning_CPU_Paused)) - { - SystemMenu.push_back(MENU_ITEM(ID_SYSTEM_PAUSE, MENU_RESUME, m_ShortCuts.ShortCutString(ID_SYSTEM_PAUSE,AccessLevel))); - } - else - { - SystemMenu.push_back(MENU_ITEM(ID_SYSTEM_PAUSE, MENU_PAUSE, m_ShortCuts.ShortCutString(ID_SYSTEM_PAUSE,AccessLevel))); - } - SystemMenu.push_back(MENU_ITEM(ID_SYSTEM_BITMAP, MENU_BITMAP, m_ShortCuts.ShortCutString(ID_SYSTEM_BITMAP,AccessLevel))); - SystemMenu.push_back(MENU_ITEM(SPLITER)); - if (!inBasicMode) - { - Item.Reset(ID_SYSTEM_LIMITFPS, MENU_LIMIT_FPS,m_ShortCuts.ShortCutString(ID_SYSTEM_LIMITFPS,AccessLevel) ); - if (g_Settings->LoadBool(GameRunning_LimitFPS)) { Item.SetItemTicked(true); } - SystemMenu.push_back(Item); - SystemMenu.push_back(MENU_ITEM(SPLITER)); - } - SystemMenu.push_back(MENU_ITEM(ID_SYSTEM_SAVE, MENU_SAVE, m_ShortCuts.ShortCutString(ID_SYSTEM_SAVE,AccessLevel))); - if (!inBasicMode) - { - SystemMenu.push_back(MENU_ITEM(ID_SYSTEM_SAVEAS, MENU_SAVE_AS, m_ShortCuts.ShortCutString(ID_SYSTEM_SAVEAS,AccessLevel))); - } - SystemMenu.push_back(MENU_ITEM(ID_SYSTEM_RESTORE, MENU_RESTORE, m_ShortCuts.ShortCutString(ID_SYSTEM_RESTORE,AccessLevel))); - if (!inBasicMode) - { - SystemMenu.push_back(MENU_ITEM(ID_SYSTEM_LOAD, MENU_LOAD, m_ShortCuts.ShortCutString(ID_SYSTEM_LOAD,AccessLevel))); - } - SystemMenu.push_back(MENU_ITEM(SPLITER)); - SystemMenu.push_back(MENU_ITEM(SUB_MENU, MENU_CURRENT_SAVE, EMPTY_STDSTR, &CurrentSaveMenu )); - SystemMenu.push_back(MENU_ITEM(SPLITER)); - SystemMenu.push_back(MENU_ITEM(ID_SYSTEM_CHEAT, MENU_CHEAT, m_ShortCuts.ShortCutString(ID_SYSTEM_CHEAT,AccessLevel))); - SystemMenu.push_back(MENU_ITEM(ID_SYSTEM_GSBUTTON, MENU_GS_BUTTON, m_ShortCuts.ShortCutString(ID_SYSTEM_GSBUTTON,AccessLevel) )); - - /* Option Menu - ****************/ - MenuItemList OptionMenu; - Item.Reset(ID_OPTIONS_FULLSCREEN, MENU_FULL_SCREEN,m_ShortCuts.ShortCutString(ID_OPTIONS_FULLSCREEN,AccessLevel) ); - Item.SetItemEnabled(CPURunning); - if (g_Plugins->Gfx() && g_Plugins->Gfx()->ChangeWindow == NULL) - { - Item.SetItemEnabled(false); - } - OptionMenu.push_back(Item); - if (!inBasicMode) - { - Item.Reset(ID_OPTIONS_ALWAYSONTOP, MENU_ON_TOP,m_ShortCuts.ShortCutString(ID_OPTIONS_ALWAYSONTOP,AccessLevel) ); - if (g_Settings->LoadDword(UserInterface_AlwaysOnTop)) { Item.SetItemTicked(true); } - Item.SetItemEnabled(CPURunning); - OptionMenu.push_back(Item); - } - OptionMenu.push_back(MENU_ITEM(SPLITER)); - - Item.Reset(ID_OPTIONS_CONFIG_GFX, MENU_CONFG_GFX,m_ShortCuts.ShortCutString(ID_OPTIONS_CONFIG_GFX,AccessLevel)); - if (g_Plugins->Gfx() == NULL || g_Plugins->Gfx()->DllConfig == NULL) - { - Item.SetItemEnabled(false); - } - OptionMenu.push_back(Item); - Item.Reset(ID_OPTIONS_CONFIG_AUDIO, MENU_CONFG_AUDIO,m_ShortCuts.ShortCutString(ID_OPTIONS_CONFIG_AUDIO,AccessLevel)); - if (g_Plugins->Audio() == NULL || g_Plugins->Audio()->DllConfig == NULL) - { - Item.SetItemEnabled(false); - } - OptionMenu.push_back(Item); - if (!inBasicMode) - { - Item.Reset(ID_OPTIONS_CONFIG_RSP, MENU_CONFG_RSP,m_ShortCuts.ShortCutString(ID_OPTIONS_CONFIG_RSP,AccessLevel)); - if (g_Plugins->RSP() == NULL || g_Plugins->RSP()->DllConfig == NULL) - { - Item.SetItemEnabled(false); - } - OptionMenu.push_back(Item); - } - Item.Reset(ID_OPTIONS_CONFIG_CONT, MENU_CONFG_CTRL,m_ShortCuts.ShortCutString(ID_OPTIONS_CONFIG_CONT,AccessLevel)); - if (g_Plugins->Control() == NULL || g_Plugins->Control()->DllConfig == NULL) - { - Item.SetItemEnabled(false); - } - OptionMenu.push_back(Item); - - OptionMenu.push_back(MENU_ITEM(SPLITER)); - if (!inBasicMode) - { - Item.Reset(ID_OPTIONS_CPU_USAGE, MENU_SHOW_CPU,m_ShortCuts.ShortCutString(ID_OPTIONS_CPU_USAGE,AccessLevel)); - if (g_Settings->LoadDword(UserInterface_ShowCPUPer)) { Item.SetItemTicked(true); } - OptionMenu.push_back(Item); - } - OptionMenu.push_back(MENU_ITEM(ID_OPTIONS_SETTINGS, MENU_SETTINGS,m_ShortCuts.ShortCutString(ID_OPTIONS_SETTINGS,AccessLevel) )); - - /* Profile Menu - ****************/ - MenuItemList DebugProfileMenu; - if (bHaveDebugger()) - { - Item.Reset(ID_PROFILE_PROFILE,EMPTY_STRING,EMPTY_STDSTR,NULL,L"Profile Code"); - if (g_Settings->LoadBool(Debugger_ProfileCode)) { Item.SetItemTicked(true); } - DebugProfileMenu.push_back(Item); - Item.Reset(ID_PROFILE_RESETCOUNTER,EMPTY_STRING,EMPTY_STDSTR,NULL,L"Reset Counters"); - if (!CPURunning) { Item.SetItemEnabled(false); } - DebugProfileMenu.push_back(Item); - Item.Reset(ID_PROFILE_GENERATELOG,EMPTY_STRING,EMPTY_STDSTR,NULL,L"Generate Log File"); - if (!CPURunning) { Item.SetItemEnabled(false); } - DebugProfileMenu.push_back(Item); - } - - /* Debugger Menu - ****************/ - MenuItemList DebugMenu; - MenuItemList DebugLoggingMenu; - MenuItemList DebugAppLoggingMenu; - MenuItemList DebugR4300Menu; - MenuItemList DebugMemoryMenu; - MenuItemList DebugInterrupt; - MenuItemList DebugNotificationMenu; - if (bHaveDebugger()) - { - /* Debug - Interrupt - *******************/ - Item.Reset(ID_DEBUGGER_INTERRUPT_SP,EMPTY_STRING,EMPTY_STDSTR,NULL,L"SP Interrupt"); - Item.SetItemEnabled(CPURunning); - DebugInterrupt.push_back(Item); - Item.Reset(ID_DEBUGGER_INTERRUPT_SI,EMPTY_STRING,EMPTY_STDSTR,NULL,L"SI Interrupt"); - Item.SetItemEnabled(CPURunning); - DebugInterrupt.push_back(Item); - Item.Reset(ID_DEBUGGER_INTERRUPT_AI,EMPTY_STRING,EMPTY_STDSTR,NULL,L"AI Interrupt"); - Item.SetItemEnabled(CPURunning); - DebugInterrupt.push_back(Item); - Item.Reset(ID_DEBUGGER_INTERRUPT_VI,EMPTY_STRING,EMPTY_STDSTR,NULL,L"VI Interrupt"); - Item.SetItemEnabled(CPURunning); - DebugInterrupt.push_back(Item); - Item.Reset(ID_DEBUGGER_INTERRUPT_PI,EMPTY_STRING,EMPTY_STDSTR,NULL,L"PI Interrupt"); - Item.SetItemEnabled(CPURunning); - DebugInterrupt.push_back(Item); - Item.Reset(ID_DEBUGGER_INTERRUPT_DP,EMPTY_STRING,EMPTY_STDSTR,NULL,L"DP Interrupt"); - Item.SetItemEnabled(CPURunning); - DebugInterrupt.push_back(Item); - - /* Debug - R4300i - *******************/ - Item.Reset(ID_DEBUGGER_LOGOPTIONS,EMPTY_STRING,EMPTY_STDSTR,NULL,L"R4300i &Commands..."); - Item.SetItemEnabled(false); - DebugR4300Menu.push_back(Item); - Item.Reset(ID_DEBUGGER_R4300REGISTERS,EMPTY_STRING,EMPTY_STDSTR,NULL,L"R4300i &Registers..."); - Item.SetItemEnabled(true); - DebugR4300Menu.push_back(Item); - Item.Reset(ID_DEBUG_DISABLE_GAMEFIX,EMPTY_STRING,EMPTY_STDSTR,NULL,L"Disable Game Fixes"); - if (g_Settings->LoadBool(Debugger_DisableGameFixes)) - { - Item.SetItemTicked(true); - } - DebugR4300Menu.push_back(Item); - Item.Reset(SUB_MENU, EMPTY_STRING,EMPTY_STDSTR, &DebugInterrupt,L"&Generate Interrupt"); - DebugR4300Menu.push_back(Item); - - /* Debug - Memory - ****************/ - Item.Reset(ID_DEBUGGER_MEMORY,EMPTY_STRING,EMPTY_STDSTR,NULL,L"View..."); - DebugMemoryMenu.push_back(Item); - Item.Reset(ID_DEBUGGER_SEARCHMEMORY,EMPTY_STRING,EMPTY_STDSTR,NULL,L"Search..."); - DebugMemoryMenu.push_back(Item); - Item.Reset(ID_DEBUGGER_DUMPMEMORY,EMPTY_STRING,EMPTY_STDSTR,NULL,L"Dump..."); - DebugMemoryMenu.push_back(Item); - Item.Reset(ID_DEBUGGER_TLBENTRIES,EMPTY_STRING,EMPTY_STDSTR,NULL,L"TLB Entries..."); - DebugMemoryMenu.push_back(Item); - - /* Debug - App logging - *******************/ - { - DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); - - Item.Reset(ID_DEBUGGER_APPLOG_ERRORS,EMPTY_STRING,EMPTY_STDSTR,NULL,L"Error Messages"); - if ((LogLevel & TraceError) != 0) { Item.SetItemTicked(true); } - DebugAppLoggingMenu.push_back(Item); - - Item.Reset(ID_DEBUGGER_APPLOG_SETTINGS,EMPTY_STRING,EMPTY_STDSTR,NULL,L"Settings"); - if ((LogLevel & TraceSettings) != 0) { Item.SetItemTicked(true); } - DebugAppLoggingMenu.push_back(Item); - - Item.Reset(ID_DEBUGGER_APPLOG_RECOMPILER,EMPTY_STRING,EMPTY_STDSTR,NULL,L"Recompiler"); - if ((LogLevel & TraceRecompiler) != 0) { Item.SetItemTicked(true); } - DebugAppLoggingMenu.push_back(Item); - - Item.Reset(ID_DEBUGGER_APPLOG_RSP,EMPTY_STRING,EMPTY_STDSTR,NULL,L"RSP"); - if ((LogLevel & TraceRSP) != 0) { Item.SetItemTicked(true); } - DebugAppLoggingMenu.push_back(Item); - - Item.Reset(ID_DEBUGGER_APPLOG_TLB,EMPTY_STRING,EMPTY_STDSTR,NULL,L"TLB"); - if ((LogLevel & TraceTLB) != 0) { Item.SetItemTicked(true); } - DebugAppLoggingMenu.push_back(Item); - - Item.Reset(ID_DEBUGGER_APPLOG_GFX_PLUGIN,EMPTY_STRING,EMPTY_STDSTR,NULL,L"Gfx Plugin"); - if ((LogLevel & TraceGfxPlugin) != 0) { Item.SetItemTicked(true); } - DebugAppLoggingMenu.push_back(Item); - - Item.Reset(ID_DEBUGGER_APPLOG_AUDIO_EMU,EMPTY_STRING,EMPTY_STDSTR,NULL,L"Audio Emulation"); - if ((LogLevel & TraceAudio) != 0) { Item.SetItemTicked(true); } - DebugAppLoggingMenu.push_back(Item); - - Item.Reset(ID_DEBUGGER_APPLOG_DEBUG,EMPTY_STRING,EMPTY_STDSTR,NULL,L"Debug Messages"); - if ((LogLevel & TraceDebug) != 0) { Item.SetItemTicked(true); } - DebugAppLoggingMenu.push_back(Item); - - DebugAppLoggingMenu.push_back(MENU_ITEM(SPLITER)); - - Item.Reset(ID_DEBUGGER_APPLOG_FLUSH,EMPTY_STRING,EMPTY_STDSTR,NULL,L"Auto flush file"); - if (g_Settings->LoadBool(Debugger_AppLogFlush)) { Item.SetItemTicked(true); } - DebugAppLoggingMenu.push_back(Item); - } - - - /* Debug - Logging - *******************/ - Item.Reset(ID_DEBUGGER_LOGOPTIONS,EMPTY_STRING,EMPTY_STDSTR,NULL,L"Log Options..."); - DebugLoggingMenu.push_back(Item); - - - Item.Reset(ID_DEBUGGER_GENERATELOG,EMPTY_STRING,EMPTY_STDSTR,NULL,L"Generate Log"); - if (g_Settings->LoadBool(Debugger_GenerateDebugLog)) { Item.SetItemTicked(true); } - DebugLoggingMenu.push_back(Item); - - /* Debugger Main Menu - ****************/ - Item.Reset(ID_DEBUGGER_BREAKPOINTS, EMPTY_STRING,EMPTY_STDSTR, NULL,L"Breakpoint..."); - Item.SetItemEnabled(CPURunning); - DebugMenu.push_back(Item); - DebugMenu.push_back(MENU_ITEM(SPLITER)); - - /* Debug - RSP - *******************/ - if (g_Plugins->RSP() != NULL && IsMenu((HMENU)g_Plugins->RSP()->GetDebugMenu())) - { - Item.Reset(ID_PLUGIN_MENU,EMPTY_STRING,EMPTY_STDSTR,g_Plugins->RSP()->GetDebugMenu(),L"&RSP"); - DebugMenu.push_back(Item); - } - - /* Debug - RDP - *******************/ - if (g_Plugins->Gfx() != NULL && IsMenu((HMENU)g_Plugins->Gfx()->GetDebugMenu())) - { - Item.Reset(ID_PLUGIN_MENU,EMPTY_STRING,EMPTY_STDSTR,g_Plugins->Gfx()->GetDebugMenu(),L"&RDP"); - DebugMenu.push_back(Item); - } - - /* Notification Menu - *******************/ - Item.Reset(ID_DEBUG_SHOW_UNHANDLED_MEM,EMPTY_STRING,EMPTY_STDSTR,NULL,L"On Unhandled Memory Actions"); - if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) - { - Item.SetItemTicked(true); - } - DebugNotificationMenu.push_back(Item); - Item.Reset(ID_DEBUG_SHOW_PIF_ERRORS,EMPTY_STRING,EMPTY_STDSTR,NULL,L"On PIF Errors"); - if (g_Settings->LoadBool(Debugger_ShowPifErrors)) - { - Item.SetItemTicked(true); - } - DebugNotificationMenu.push_back(Item); - Item.Reset(ID_DEBUG_SHOW_DIV_BY_ZERO,EMPTY_STRING,EMPTY_STDSTR,NULL,L"On Div By Zero"); - if (g_Settings->LoadBool(Debugger_ShowDivByZero)) - { - Item.SetItemTicked(true); - } - DebugNotificationMenu.push_back(Item); - - Item.Reset(SUB_MENU, EMPTY_STRING,EMPTY_STDSTR, &DebugR4300Menu,L"&R4300i"); - DebugMenu.push_back(Item); - Item.Reset(SUB_MENU, EMPTY_STRING,EMPTY_STDSTR, &DebugMemoryMenu,L"Memory"); - Item.SetItemEnabled(CPURunning); - DebugMenu.push_back(Item); - DebugMenu.push_back(MENU_ITEM(SPLITER)); - Item.Reset(SUB_MENU, EMPTY_STRING,EMPTY_STDSTR, &DebugProfileMenu,L"Profile"); - DebugMenu.push_back(Item); - Item.Reset(SUB_MENU, EMPTY_STRING,EMPTY_STDSTR, &DebugAppLoggingMenu,L"App Logging"); - DebugMenu.push_back(Item); - Item.Reset(SUB_MENU, EMPTY_STRING,EMPTY_STDSTR, &DebugLoggingMenu,L"Logging"); - DebugMenu.push_back(Item); - Item.Reset(SUB_MENU, EMPTY_STRING,EMPTY_STDSTR, &DebugNotificationMenu,L"Notification"); - DebugMenu.push_back(Item); - DebugMenu.push_back(MENU_ITEM(SPLITER)); - Item.Reset(ID_DEBUG_SHOW_TLB_MISSES,EMPTY_STRING,EMPTY_STDSTR,NULL,L"Show TLB Misses"); - if (g_Settings->LoadBool(Debugger_ShowTLBMisses)) - { Item.SetItemTicked(true); - } - Item.Reset(ID_DEBUG_SHOW_DLIST_COUNT,EMPTY_STRING,EMPTY_STDSTR,NULL,L"Display Alist/Dlist Count"); - if (g_Settings->LoadBool(Debugger_ShowDListAListCount)) - { - Item.SetItemTicked(true); - } - DebugMenu.push_back(Item); - Item.Reset(ID_DEBUG_SHOW_RECOMP_MEM_SIZE,EMPTY_STRING,EMPTY_STDSTR,NULL,L"Display Recompiler Code Buffer Size"); - if (g_Settings->LoadBool(Debugger_ShowRecompMemSize)) - { - Item.SetItemTicked(true); - } - DebugMenu.push_back(Item); - DebugMenu.push_back(MENU_ITEM(SPLITER)); - Item.Reset(ID_DEBUG_GENERATE_LOG_FILES,EMPTY_STRING,EMPTY_STDSTR,NULL,L"Generate Log Files"); - if (g_Settings->LoadBool(Debugger_GenerateLogFiles)) - { - Item.SetItemTicked(true); - } - DebugMenu.push_back(Item); - } + } + LangMenu.push_back(Item); + } - /* Help Menu - ****************/ - MenuItemList HelpMenu; + //Go through the settings to create a list of Recent Roms + MenuItemList RecentRomMenu; + DWORD count, RomsToRemember = g_Settings->LoadDword(File_RecentGameFileCount); - HelpMenu.push_back(MENU_ITEM(ID_HELP_SUPPORTFORUM, MENU_FORUM)); - HelpMenu.push_back(MENU_ITEM(ID_HELP_HOMEPAGE, MENU_HOMEPAGE)); - HelpMenu.push_back(MENU_ITEM(SPLITER)); - if (!inBasicMode) + for (count = 0; count < RomsToRemember; count++) { - HelpMenu.push_back(MENU_ITEM(ID_HELP_ABOUTSETTINGFILES, MENU_ABOUT_INI)); - } - HelpMenu.push_back(MENU_ITEM(ID_HELP_ABOUT, MENU_ABOUT_PJ64)); - - /* Main Title bar Menu - ***********************/ - MenuItemList MainTitleMenu; - Item.Reset(SUB_MENU, MENU_FILE, EMPTY_STDSTR, &FileMenu); - if (RomLoading) { Item.SetItemEnabled(false); } - MainTitleMenu.push_back(Item); - if (CPURunning) - { - Item.Reset(SUB_MENU, MENU_SYSTEM, EMPTY_STDSTR, &SystemMenu); - if (RomLoading) { Item.SetItemEnabled(false); } - MainTitleMenu.push_back(Item); - } - Item.Reset(SUB_MENU, MENU_OPTIONS, EMPTY_STDSTR, &OptionMenu); - if (RomLoading) { Item.SetItemEnabled(false); } - MainTitleMenu.push_back(Item); - if (!inBasicMode) - { - if (bHaveDebugger()) + stdstr LastRom = g_Settings->LoadStringIndex(File_RecentGameFileIndex, count); + if (LastRom.empty()) { - Item.Reset(SUB_MENU, MENU_DEBUGGER, EMPTY_STDSTR, &DebugMenu); - if (RomLoading) { Item.SetItemEnabled(false); } - MainTitleMenu.push_back(Item); - } - } - Item.Reset(SUB_MENU, MENU_HELP, EMPTY_STDSTR, &HelpMenu); - if (RomLoading) { Item.SetItemEnabled(false); } - MainTitleMenu.push_back(Item); + break; + } + stdstr_f MenuString("&%d %s", (count + 1) % 10, LastRom.c_str()); - AddMenu(hMenu,MainTitleMenu); + WCHAR *w_LastRom = new WCHAR[MenuString.length() + 1]; + ::mbstowcs(w_LastRom, MenuString.c_str(), MenuString.length() + 1); + RecentRomMenu.push_back(MENU_ITEM(ID_RECENT_ROM_START + count, EMPTY_STRING, EMPTY_STDSTR, NULL, w_LastRom)); + delete[] w_LastRom; + } + + /* Recent Dir + ****************/ + MenuItemList RecentDirMenu; + DWORD DirsToRemember = g_Settings->LoadDword(Directory_RecentGameDirCount); + + for (count = 0; count < DirsToRemember; count++) + { + stdstr LastDir = g_Settings->LoadStringIndex(Directory_RecentGameDirIndex, count); + if (LastDir.empty()) + { + break; + } + + stdstr_f MenuString("&%d %s", (count + 1) % 10, LastDir.c_str()); + + WCHAR *w_LastDir = new WCHAR[MenuString.length() + 1]; + ::mbstowcs(w_LastDir, MenuString.c_str(), MenuString.length() + 1); + RecentDirMenu.push_back(MENU_ITEM(ID_RECENT_DIR_START + count, EMPTY_STRING, EMPTY_STDSTR, NULL, w_LastDir)); + delete[] w_LastDir; + } + + /* File Menu + ****************/ + MenuItemList FileMenu; + Item.Reset(ID_FILE_OPEN_ROM, MENU_OPEN, m_ShortCuts.ShortCutString(ID_FILE_OPEN_ROM, AccessLevel)); + FileMenu.push_back(Item); + if (!inBasicMode) + { + Item.Reset(ID_FILE_ROM_INFO, MENU_ROM_INFO, m_ShortCuts.ShortCutString(ID_FILE_ROM_INFO, AccessLevel)); + Item.SetItemEnabled(RomLoaded); + FileMenu.push_back(Item); + FileMenu.push_back(MENU_ITEM(SPLITER)); + Item.Reset(ID_FILE_STARTEMULATION, MENU_START, m_ShortCuts.ShortCutString(ID_FILE_STARTEMULATION, AccessLevel)); + Item.SetItemEnabled(RomLoaded && !CPURunning); + FileMenu.push_back(Item); + } + Item.Reset(ID_FILE_ENDEMULATION, MENU_END, m_ShortCuts.ShortCutString(ID_FILE_ENDEMULATION, AccessLevel)); + Item.SetItemEnabled(CPURunning); + FileMenu.push_back(Item); + FileMenu.push_back(MENU_ITEM(SPLITER)); + Item.Reset(SUB_MENU, MENU_LANGUAGE, EMPTY_STDSTR, &LangMenu); + FileMenu.push_back(Item); + if (RomList) + { + FileMenu.push_back(MENU_ITEM(SPLITER)); + Item.Reset(ID_FILE_ROMDIRECTORY, MENU_CHOOSE_ROM, m_ShortCuts.ShortCutString(ID_FILE_ROMDIRECTORY, AccessLevel)); + FileMenu.push_back(Item); + Item.Reset(ID_FILE_REFRESHROMLIST, MENU_REFRESH, m_ShortCuts.ShortCutString(ID_FILE_REFRESHROMLIST, AccessLevel)); + FileMenu.push_back(Item); + } + + if (!inBasicMode && RomList) + { + FileMenu.push_back(MENU_ITEM(SPLITER)); + Item.Reset(SUB_MENU, MENU_RECENT_ROM, EMPTY_STDSTR, &RecentRomMenu); + if (RecentRomMenu.size() == 0) + { + RecentRomMenu.push_back(MENU_ITEM(SPLITER)); + Item.SetItemEnabled(false); + } + FileMenu.push_back(Item); + Item.Reset(SUB_MENU, MENU_RECENT_DIR, EMPTY_STDSTR, &RecentDirMenu); + if (RecentDirMenu.size() == 0) + { + RecentDirMenu.push_back(MENU_ITEM(SPLITER)); + Item.SetItemEnabled(false); + } + FileMenu.push_back(Item); + } + else + { + if (RecentRomMenu.size() != 0) + { + FileMenu.push_back(MENU_ITEM(SPLITER)); + for (MenuItemList::iterator MenuItem = RecentRomMenu.begin(); MenuItem != RecentRomMenu.end(); MenuItem++) + { + FileMenu.push_back(*MenuItem); + } + } + } + FileMenu.push_back(MENU_ITEM(SPLITER)); + FileMenu.push_back(MENU_ITEM(ID_FILE_EXIT, MENU_EXIT, m_ShortCuts.ShortCutString(ID_FILE_EXIT, AccessLevel))); + + /* Current Save + ****************/ + MenuItemList CurrentSaveMenu; + DWORD _CurrentSaveState = g_Settings->LoadDword(Game_CurrentSaveState); + Item.Reset(ID_CURRENT_SAVE_DEFAULT, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_DEFAULT, AccessLevel), NULL, GetSaveSlotString(0)); + if (_CurrentSaveState == 0) { Item.SetItemTicked(true); } + CurrentSaveMenu.push_back(Item); + CurrentSaveMenu.push_back(MENU_ITEM(SPLITER)); + Item.Reset(ID_CURRENT_SAVE_1, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_1, AccessLevel), NULL, GetSaveSlotString(1)); + if (_CurrentSaveState == 1) { Item.SetItemTicked(true); } + CurrentSaveMenu.push_back(Item); + Item.Reset(ID_CURRENT_SAVE_2, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_2, AccessLevel), NULL, GetSaveSlotString(2)); + if (_CurrentSaveState == 2) { Item.SetItemTicked(true); } + CurrentSaveMenu.push_back(Item); + Item.Reset(ID_CURRENT_SAVE_3, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_3, AccessLevel), NULL, GetSaveSlotString(3)); + if (_CurrentSaveState == 3) { Item.SetItemTicked(true); } + CurrentSaveMenu.push_back(Item); + Item.Reset(ID_CURRENT_SAVE_4, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_4, AccessLevel), NULL, GetSaveSlotString(4)); + if (_CurrentSaveState == 4) { Item.SetItemTicked(true); } + CurrentSaveMenu.push_back(Item); + Item.Reset(ID_CURRENT_SAVE_5, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_5, AccessLevel), NULL, GetSaveSlotString(5)); + if (_CurrentSaveState == 5) { Item.SetItemTicked(true); } + CurrentSaveMenu.push_back(Item); + Item.Reset(ID_CURRENT_SAVE_6, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_6, AccessLevel), NULL, GetSaveSlotString(6)); + if (_CurrentSaveState == 6) { Item.SetItemTicked(true); } + CurrentSaveMenu.push_back(Item); + Item.Reset(ID_CURRENT_SAVE_7, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_7, AccessLevel), NULL, GetSaveSlotString(7)); + if (_CurrentSaveState == 7) { Item.SetItemTicked(true); } + CurrentSaveMenu.push_back(Item); + Item.Reset(ID_CURRENT_SAVE_8, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_8, AccessLevel), NULL, GetSaveSlotString(8)); + if (_CurrentSaveState == 8) { Item.SetItemTicked(true); } + CurrentSaveMenu.push_back(Item); + Item.Reset(ID_CURRENT_SAVE_9, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_9, AccessLevel), NULL, GetSaveSlotString(9)); + if (_CurrentSaveState == 9) { Item.SetItemTicked(true); } + CurrentSaveMenu.push_back(Item); + Item.Reset(ID_CURRENT_SAVE_10, EMPTY_STRING, m_ShortCuts.ShortCutString(ID_CURRENT_SAVE_10, AccessLevel), NULL, GetSaveSlotString(10)); + if (_CurrentSaveState == 10) { Item.SetItemTicked(true); } + CurrentSaveMenu.push_back(Item); + + /* System Menu + ****************/ + MenuItemList SystemMenu; + MenuItemList ResetMenu; + if (inBasicMode) + { + SystemMenu.push_back(MENU_ITEM(ID_SYSTEM_RESET_SOFT, MENU_RESET, m_ShortCuts.ShortCutString(ID_SYSTEM_RESET_SOFT, AccessLevel))); + } + else + { + ResetMenu.push_back(MENU_ITEM(ID_SYSTEM_RESET_SOFT, MENU_RESET_SOFT, m_ShortCuts.ShortCutString(ID_SYSTEM_RESET_SOFT, AccessLevel))); + ResetMenu.push_back(MENU_ITEM(ID_SYSTEM_RESET_HARD, MENU_RESET_HARD, m_ShortCuts.ShortCutString(ID_SYSTEM_RESET_HARD, AccessLevel))); + SystemMenu.push_back(MENU_ITEM(SUB_MENU, MENU_RESET, EMPTY_STDSTR, &ResetMenu)); + } + if (g_Settings->LoadBool(GameRunning_CPU_Paused)) + { + SystemMenu.push_back(MENU_ITEM(ID_SYSTEM_PAUSE, MENU_RESUME, m_ShortCuts.ShortCutString(ID_SYSTEM_PAUSE, AccessLevel))); + } + else + { + SystemMenu.push_back(MENU_ITEM(ID_SYSTEM_PAUSE, MENU_PAUSE, m_ShortCuts.ShortCutString(ID_SYSTEM_PAUSE, AccessLevel))); + } + SystemMenu.push_back(MENU_ITEM(ID_SYSTEM_BITMAP, MENU_BITMAP, m_ShortCuts.ShortCutString(ID_SYSTEM_BITMAP, AccessLevel))); + SystemMenu.push_back(MENU_ITEM(SPLITER)); + if (!inBasicMode) + { + Item.Reset(ID_SYSTEM_LIMITFPS, MENU_LIMIT_FPS, m_ShortCuts.ShortCutString(ID_SYSTEM_LIMITFPS, AccessLevel)); + if (g_Settings->LoadBool(GameRunning_LimitFPS)) { Item.SetItemTicked(true); } + SystemMenu.push_back(Item); + SystemMenu.push_back(MENU_ITEM(SPLITER)); + } + SystemMenu.push_back(MENU_ITEM(ID_SYSTEM_SAVE, MENU_SAVE, m_ShortCuts.ShortCutString(ID_SYSTEM_SAVE, AccessLevel))); + if (!inBasicMode) + { + SystemMenu.push_back(MENU_ITEM(ID_SYSTEM_SAVEAS, MENU_SAVE_AS, m_ShortCuts.ShortCutString(ID_SYSTEM_SAVEAS, AccessLevel))); + } + SystemMenu.push_back(MENU_ITEM(ID_SYSTEM_RESTORE, MENU_RESTORE, m_ShortCuts.ShortCutString(ID_SYSTEM_RESTORE, AccessLevel))); + if (!inBasicMode) + { + SystemMenu.push_back(MENU_ITEM(ID_SYSTEM_LOAD, MENU_LOAD, m_ShortCuts.ShortCutString(ID_SYSTEM_LOAD, AccessLevel))); + } + SystemMenu.push_back(MENU_ITEM(SPLITER)); + SystemMenu.push_back(MENU_ITEM(SUB_MENU, MENU_CURRENT_SAVE, EMPTY_STDSTR, &CurrentSaveMenu)); + SystemMenu.push_back(MENU_ITEM(SPLITER)); + SystemMenu.push_back(MENU_ITEM(ID_SYSTEM_CHEAT, MENU_CHEAT, m_ShortCuts.ShortCutString(ID_SYSTEM_CHEAT, AccessLevel))); + SystemMenu.push_back(MENU_ITEM(ID_SYSTEM_GSBUTTON, MENU_GS_BUTTON, m_ShortCuts.ShortCutString(ID_SYSTEM_GSBUTTON, AccessLevel))); + + /* Option Menu + ****************/ + MenuItemList OptionMenu; + Item.Reset(ID_OPTIONS_FULLSCREEN, MENU_FULL_SCREEN, m_ShortCuts.ShortCutString(ID_OPTIONS_FULLSCREEN, AccessLevel)); + Item.SetItemEnabled(CPURunning); + if (g_Plugins->Gfx() && g_Plugins->Gfx()->ChangeWindow == NULL) + { + Item.SetItemEnabled(false); + } + OptionMenu.push_back(Item); + if (!inBasicMode) + { + Item.Reset(ID_OPTIONS_ALWAYSONTOP, MENU_ON_TOP, m_ShortCuts.ShortCutString(ID_OPTIONS_ALWAYSONTOP, AccessLevel)); + if (g_Settings->LoadDword(UserInterface_AlwaysOnTop)) { Item.SetItemTicked(true); } + Item.SetItemEnabled(CPURunning); + OptionMenu.push_back(Item); + } + OptionMenu.push_back(MENU_ITEM(SPLITER)); + + Item.Reset(ID_OPTIONS_CONFIG_GFX, MENU_CONFG_GFX, m_ShortCuts.ShortCutString(ID_OPTIONS_CONFIG_GFX, AccessLevel)); + if (g_Plugins->Gfx() == NULL || g_Plugins->Gfx()->DllConfig == NULL) + { + Item.SetItemEnabled(false); + } + OptionMenu.push_back(Item); + Item.Reset(ID_OPTIONS_CONFIG_AUDIO, MENU_CONFG_AUDIO, m_ShortCuts.ShortCutString(ID_OPTIONS_CONFIG_AUDIO, AccessLevel)); + if (g_Plugins->Audio() == NULL || g_Plugins->Audio()->DllConfig == NULL) + { + Item.SetItemEnabled(false); + } + OptionMenu.push_back(Item); + if (!inBasicMode) + { + Item.Reset(ID_OPTIONS_CONFIG_RSP, MENU_CONFG_RSP, m_ShortCuts.ShortCutString(ID_OPTIONS_CONFIG_RSP, AccessLevel)); + if (g_Plugins->RSP() == NULL || g_Plugins->RSP()->DllConfig == NULL) + { + Item.SetItemEnabled(false); + } + OptionMenu.push_back(Item); + } + Item.Reset(ID_OPTIONS_CONFIG_CONT, MENU_CONFG_CTRL, m_ShortCuts.ShortCutString(ID_OPTIONS_CONFIG_CONT, AccessLevel)); + if (g_Plugins->Control() == NULL || g_Plugins->Control()->DllConfig == NULL) + { + Item.SetItemEnabled(false); + } + OptionMenu.push_back(Item); + + OptionMenu.push_back(MENU_ITEM(SPLITER)); + if (!inBasicMode) + { + Item.Reset(ID_OPTIONS_CPU_USAGE, MENU_SHOW_CPU, m_ShortCuts.ShortCutString(ID_OPTIONS_CPU_USAGE, AccessLevel)); + if (g_Settings->LoadDword(UserInterface_ShowCPUPer)) { Item.SetItemTicked(true); } + OptionMenu.push_back(Item); + } + OptionMenu.push_back(MENU_ITEM(ID_OPTIONS_SETTINGS, MENU_SETTINGS, m_ShortCuts.ShortCutString(ID_OPTIONS_SETTINGS, AccessLevel))); + + /* Profile Menu + ****************/ + MenuItemList DebugProfileMenu; + if (bHaveDebugger()) + { + Item.Reset(ID_PROFILE_PROFILE, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Profile Code"); + if (g_Settings->LoadBool(Debugger_ProfileCode)) { Item.SetItemTicked(true); } + DebugProfileMenu.push_back(Item); + Item.Reset(ID_PROFILE_RESETCOUNTER, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Reset Counters"); + if (!CPURunning) { Item.SetItemEnabled(false); } + DebugProfileMenu.push_back(Item); + Item.Reset(ID_PROFILE_GENERATELOG, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Generate Log File"); + if (!CPURunning) { Item.SetItemEnabled(false); } + DebugProfileMenu.push_back(Item); + } + + /* Debugger Menu + ****************/ + MenuItemList DebugMenu; + MenuItemList DebugLoggingMenu; + MenuItemList DebugAppLoggingMenu; + MenuItemList DebugR4300Menu; + MenuItemList DebugMemoryMenu; + MenuItemList DebugInterrupt; + MenuItemList DebugNotificationMenu; + if (bHaveDebugger()) + { + /* Debug - Interrupt + *******************/ + Item.Reset(ID_DEBUGGER_INTERRUPT_SP, EMPTY_STRING, EMPTY_STDSTR, NULL, L"SP Interrupt"); + Item.SetItemEnabled(CPURunning); + DebugInterrupt.push_back(Item); + Item.Reset(ID_DEBUGGER_INTERRUPT_SI, EMPTY_STRING, EMPTY_STDSTR, NULL, L"SI Interrupt"); + Item.SetItemEnabled(CPURunning); + DebugInterrupt.push_back(Item); + Item.Reset(ID_DEBUGGER_INTERRUPT_AI, EMPTY_STRING, EMPTY_STDSTR, NULL, L"AI Interrupt"); + Item.SetItemEnabled(CPURunning); + DebugInterrupt.push_back(Item); + Item.Reset(ID_DEBUGGER_INTERRUPT_VI, EMPTY_STRING, EMPTY_STDSTR, NULL, L"VI Interrupt"); + Item.SetItemEnabled(CPURunning); + DebugInterrupt.push_back(Item); + Item.Reset(ID_DEBUGGER_INTERRUPT_PI, EMPTY_STRING, EMPTY_STDSTR, NULL, L"PI Interrupt"); + Item.SetItemEnabled(CPURunning); + DebugInterrupt.push_back(Item); + Item.Reset(ID_DEBUGGER_INTERRUPT_DP, EMPTY_STRING, EMPTY_STDSTR, NULL, L"DP Interrupt"); + Item.SetItemEnabled(CPURunning); + DebugInterrupt.push_back(Item); + + /* Debug - R4300i + *******************/ + Item.Reset(ID_DEBUGGER_LOGOPTIONS, EMPTY_STRING, EMPTY_STDSTR, NULL, L"R4300i &Commands..."); + Item.SetItemEnabled(false); + DebugR4300Menu.push_back(Item); + Item.Reset(ID_DEBUGGER_R4300REGISTERS, EMPTY_STRING, EMPTY_STDSTR, NULL, L"R4300i &Registers..."); + Item.SetItemEnabled(true); + DebugR4300Menu.push_back(Item); + Item.Reset(ID_DEBUG_DISABLE_GAMEFIX, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Disable Game Fixes"); + if (g_Settings->LoadBool(Debugger_DisableGameFixes)) + { + Item.SetItemTicked(true); + } + DebugR4300Menu.push_back(Item); + Item.Reset(SUB_MENU, EMPTY_STRING, EMPTY_STDSTR, &DebugInterrupt, L"&Generate Interrupt"); + DebugR4300Menu.push_back(Item); + + /* Debug - Memory + ****************/ + Item.Reset(ID_DEBUGGER_MEMORY, EMPTY_STRING, EMPTY_STDSTR, NULL, L"View..."); + DebugMemoryMenu.push_back(Item); + Item.Reset(ID_DEBUGGER_SEARCHMEMORY, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Search..."); + DebugMemoryMenu.push_back(Item); + Item.Reset(ID_DEBUGGER_DUMPMEMORY, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Dump..."); + DebugMemoryMenu.push_back(Item); + Item.Reset(ID_DEBUGGER_TLBENTRIES, EMPTY_STRING, EMPTY_STDSTR, NULL, L"TLB Entries..."); + DebugMemoryMenu.push_back(Item); + + /* Debug - App logging + *******************/ + { + DWORD LogLevel = g_Settings->LoadDword(Debugger_AppLogLevel); + + Item.Reset(ID_DEBUGGER_APPLOG_ERRORS, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Error Messages"); + if ((LogLevel & TraceError) != 0) { Item.SetItemTicked(true); } + DebugAppLoggingMenu.push_back(Item); + + Item.Reset(ID_DEBUGGER_APPLOG_SETTINGS, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Settings"); + if ((LogLevel & TraceSettings) != 0) { Item.SetItemTicked(true); } + DebugAppLoggingMenu.push_back(Item); + + Item.Reset(ID_DEBUGGER_APPLOG_RECOMPILER, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Recompiler"); + if ((LogLevel & TraceRecompiler) != 0) { Item.SetItemTicked(true); } + DebugAppLoggingMenu.push_back(Item); + + Item.Reset(ID_DEBUGGER_APPLOG_RSP, EMPTY_STRING, EMPTY_STDSTR, NULL, L"RSP"); + if ((LogLevel & TraceRSP) != 0) { Item.SetItemTicked(true); } + DebugAppLoggingMenu.push_back(Item); + + Item.Reset(ID_DEBUGGER_APPLOG_TLB, EMPTY_STRING, EMPTY_STDSTR, NULL, L"TLB"); + if ((LogLevel & TraceTLB) != 0) { Item.SetItemTicked(true); } + DebugAppLoggingMenu.push_back(Item); + + Item.Reset(ID_DEBUGGER_APPLOG_GFX_PLUGIN, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Gfx Plugin"); + if ((LogLevel & TraceGfxPlugin) != 0) { Item.SetItemTicked(true); } + DebugAppLoggingMenu.push_back(Item); + + Item.Reset(ID_DEBUGGER_APPLOG_AUDIO_EMU, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Audio Emulation"); + if ((LogLevel & TraceAudio) != 0) { Item.SetItemTicked(true); } + DebugAppLoggingMenu.push_back(Item); + + Item.Reset(ID_DEBUGGER_APPLOG_DEBUG, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Debug Messages"); + if ((LogLevel & TraceDebug) != 0) { Item.SetItemTicked(true); } + DebugAppLoggingMenu.push_back(Item); + + DebugAppLoggingMenu.push_back(MENU_ITEM(SPLITER)); + + Item.Reset(ID_DEBUGGER_APPLOG_FLUSH, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Auto flush file"); + if (g_Settings->LoadBool(Debugger_AppLogFlush)) { Item.SetItemTicked(true); } + DebugAppLoggingMenu.push_back(Item); + } + + /* Debug - Logging + *******************/ + Item.Reset(ID_DEBUGGER_LOGOPTIONS, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Log Options..."); + DebugLoggingMenu.push_back(Item); + + Item.Reset(ID_DEBUGGER_GENERATELOG, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Generate Log"); + if (g_Settings->LoadBool(Debugger_GenerateDebugLog)) { Item.SetItemTicked(true); } + DebugLoggingMenu.push_back(Item); + + /* Debugger Main Menu + ****************/ + Item.Reset(ID_DEBUGGER_BREAKPOINTS, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Breakpoint..."); + Item.SetItemEnabled(CPURunning); + DebugMenu.push_back(Item); + DebugMenu.push_back(MENU_ITEM(SPLITER)); + + /* Debug - RSP + *******************/ + if (g_Plugins->RSP() != NULL && IsMenu((HMENU)g_Plugins->RSP()->GetDebugMenu())) + { + Item.Reset(ID_PLUGIN_MENU, EMPTY_STRING, EMPTY_STDSTR, g_Plugins->RSP()->GetDebugMenu(), L"&RSP"); + DebugMenu.push_back(Item); + } + + /* Debug - RDP + *******************/ + if (g_Plugins->Gfx() != NULL && IsMenu((HMENU)g_Plugins->Gfx()->GetDebugMenu())) + { + Item.Reset(ID_PLUGIN_MENU, EMPTY_STRING, EMPTY_STDSTR, g_Plugins->Gfx()->GetDebugMenu(), L"&RDP"); + DebugMenu.push_back(Item); + } + + /* Notification Menu + *******************/ + Item.Reset(ID_DEBUG_SHOW_UNHANDLED_MEM, EMPTY_STRING, EMPTY_STDSTR, NULL, L"On Unhandled Memory Actions"); + if (g_Settings->LoadBool(Debugger_ShowUnhandledMemory)) + { + Item.SetItemTicked(true); + } + DebugNotificationMenu.push_back(Item); + Item.Reset(ID_DEBUG_SHOW_PIF_ERRORS, EMPTY_STRING, EMPTY_STDSTR, NULL, L"On PIF Errors"); + if (g_Settings->LoadBool(Debugger_ShowPifErrors)) + { + Item.SetItemTicked(true); + } + DebugNotificationMenu.push_back(Item); + Item.Reset(ID_DEBUG_SHOW_DIV_BY_ZERO, EMPTY_STRING, EMPTY_STDSTR, NULL, L"On Div By Zero"); + if (g_Settings->LoadBool(Debugger_ShowDivByZero)) + { + Item.SetItemTicked(true); + } + DebugNotificationMenu.push_back(Item); + + Item.Reset(SUB_MENU, EMPTY_STRING, EMPTY_STDSTR, &DebugR4300Menu, L"&R4300i"); + DebugMenu.push_back(Item); + Item.Reset(SUB_MENU, EMPTY_STRING, EMPTY_STDSTR, &DebugMemoryMenu, L"Memory"); + Item.SetItemEnabled(CPURunning); + DebugMenu.push_back(Item); + DebugMenu.push_back(MENU_ITEM(SPLITER)); + Item.Reset(SUB_MENU, EMPTY_STRING, EMPTY_STDSTR, &DebugProfileMenu, L"Profile"); + DebugMenu.push_back(Item); + Item.Reset(SUB_MENU, EMPTY_STRING, EMPTY_STDSTR, &DebugAppLoggingMenu, L"App Logging"); + DebugMenu.push_back(Item); + Item.Reset(SUB_MENU, EMPTY_STRING, EMPTY_STDSTR, &DebugLoggingMenu, L"Logging"); + DebugMenu.push_back(Item); + Item.Reset(SUB_MENU, EMPTY_STRING, EMPTY_STDSTR, &DebugNotificationMenu, L"Notification"); + DebugMenu.push_back(Item); + DebugMenu.push_back(MENU_ITEM(SPLITER)); + Item.Reset(ID_DEBUG_SHOW_TLB_MISSES, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Show TLB Misses"); + if (g_Settings->LoadBool(Debugger_ShowTLBMisses)) + { + Item.SetItemTicked(true); + } + Item.Reset(ID_DEBUG_SHOW_DLIST_COUNT, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Display Alist/Dlist Count"); + if (g_Settings->LoadBool(Debugger_ShowDListAListCount)) + { + Item.SetItemTicked(true); + } + DebugMenu.push_back(Item); + Item.Reset(ID_DEBUG_SHOW_RECOMP_MEM_SIZE, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Display Recompiler Code Buffer Size"); + if (g_Settings->LoadBool(Debugger_ShowRecompMemSize)) + { + Item.SetItemTicked(true); + } + DebugMenu.push_back(Item); + DebugMenu.push_back(MENU_ITEM(SPLITER)); + Item.Reset(ID_DEBUG_GENERATE_LOG_FILES, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Generate Log Files"); + if (g_Settings->LoadBool(Debugger_GenerateLogFiles)) + { + Item.SetItemTicked(true); + } + DebugMenu.push_back(Item); + } + + /* Help Menu + ****************/ + MenuItemList HelpMenu; + + HelpMenu.push_back(MENU_ITEM(ID_HELP_SUPPORTFORUM, MENU_FORUM)); + HelpMenu.push_back(MENU_ITEM(ID_HELP_HOMEPAGE, MENU_HOMEPAGE)); + HelpMenu.push_back(MENU_ITEM(SPLITER)); + if (!inBasicMode) + { + HelpMenu.push_back(MENU_ITEM(ID_HELP_ABOUTSETTINGFILES, MENU_ABOUT_INI)); + } + HelpMenu.push_back(MENU_ITEM(ID_HELP_ABOUT, MENU_ABOUT_PJ64)); + + /* Main Title bar Menu + ***********************/ + MenuItemList MainTitleMenu; + Item.Reset(SUB_MENU, MENU_FILE, EMPTY_STDSTR, &FileMenu); + if (RomLoading) { Item.SetItemEnabled(false); } + MainTitleMenu.push_back(Item); + if (CPURunning) + { + Item.Reset(SUB_MENU, MENU_SYSTEM, EMPTY_STDSTR, &SystemMenu); + if (RomLoading) { Item.SetItemEnabled(false); } + MainTitleMenu.push_back(Item); + } + Item.Reset(SUB_MENU, MENU_OPTIONS, EMPTY_STDSTR, &OptionMenu); + if (RomLoading) { Item.SetItemEnabled(false); } + MainTitleMenu.push_back(Item); + if (!inBasicMode) + { + if (bHaveDebugger()) + { + Item.Reset(SUB_MENU, MENU_DEBUGGER, EMPTY_STDSTR, &DebugMenu); + if (RomLoading) { Item.SetItemEnabled(false); } + MainTitleMenu.push_back(Item); + } + } + Item.Reset(SUB_MENU, MENU_HELP, EMPTY_STDSTR, &HelpMenu); + if (RomLoading) { Item.SetItemEnabled(false); } + MainTitleMenu.push_back(Item); + + AddMenu(hMenu, MainTitleMenu); } void CMainMenu::RebuildAccelerators(void) { - CGuard Guard(m_CS); + CGuard Guard(m_CS); - //Delete the old accel list - WriteTrace(TraceDebug,__FUNCTION__ ": Start"); + //Delete the old accel list + WriteTrace(TraceDebug, __FUNCTION__ ": Start"); - HACCEL m_OldAccelTable = (HACCEL)m_AccelTable; - m_AccelTable = m_ShortCuts.GetAcceleratorTable(); - if (m_OldAccelTable) { - DestroyAcceleratorTable(m_OldAccelTable); - } - WriteTrace(TraceDebug,__FUNCTION__ ": Done"); + HACCEL m_OldAccelTable = (HACCEL)m_AccelTable; + m_AccelTable = m_ShortCuts.GetAcceleratorTable(); + if (m_OldAccelTable) { + DestroyAcceleratorTable(m_OldAccelTable); + } + WriteTrace(TraceDebug, __FUNCTION__ ": Done"); } -void CMainMenu::ResetMenu(void) +void CMainMenu::ResetMenu(void) { - WriteTrace(TraceDebug,__FUNCTION__ ": Start"); - if (!g_Settings->LoadBool(UserInterface_InFullScreen)) - { - //Create a new window with all the items - WriteTrace(TraceDebug,__FUNCTION__ ": Create Menu"); - HMENU hMenu = (HMENU)CreateMenu(); - FillOutMenu(hMenu); - WriteTrace(TraceDebug,__FUNCTION__ ": Create Menu Done"); + WriteTrace(TraceDebug, __FUNCTION__ ": Start"); + if (!g_Settings->LoadBool(UserInterface_InFullScreen)) + { + //Create a new window with all the items + WriteTrace(TraceDebug, __FUNCTION__ ": Create Menu"); + HMENU hMenu = (HMENU)CreateMenu(); + FillOutMenu(hMenu); + WriteTrace(TraceDebug, __FUNCTION__ ": Create Menu Done"); - //save old menu to destroy latter - HMENU OldMenuHandle; - { - CGuard Guard(m_CS); - OldMenuHandle = m_MenuHandle; + //save old menu to destroy latter + HMENU OldMenuHandle; + { + CGuard Guard(m_CS); + OldMenuHandle = m_MenuHandle; - //save handle and re-attach to a window - WriteTrace(TraceDebug,__FUNCTION__ ": Attach Menu"); - m_MenuHandle = hMenu; - } - _Gui->SetWindowMenu(this); + //save handle and re-attach to a window + WriteTrace(TraceDebug, __FUNCTION__ ": Attach Menu"); + m_MenuHandle = hMenu; + } + _Gui->SetWindowMenu(this); - WriteTrace(TraceDebug,__FUNCTION__ ": Remove plugin menu"); - if (g_Plugins->Gfx() != NULL && IsMenu((HMENU)g_Plugins->Gfx()->GetDebugMenu())) - { - RemoveMenu((HMENU)OldMenuHandle,(DWORD)g_Plugins->Gfx()->GetDebugMenu(), MF_BYCOMMAND); - } - if (g_Plugins->RSP() != NULL && IsMenu((HMENU)g_Plugins->RSP()->GetDebugMenu())) - { - RemoveMenu((HMENU)OldMenuHandle,(DWORD)g_Plugins->RSP()->GetDebugMenu(), MF_BYCOMMAND); - } - WriteTrace(TraceDebug,__FUNCTION__ ": Destroy Old Menu"); + WriteTrace(TraceDebug, __FUNCTION__ ": Remove plugin menu"); + if (g_Plugins->Gfx() != NULL && IsMenu((HMENU)g_Plugins->Gfx()->GetDebugMenu())) + { + RemoveMenu((HMENU)OldMenuHandle, (DWORD)g_Plugins->Gfx()->GetDebugMenu(), MF_BYCOMMAND); + } + if (g_Plugins->RSP() != NULL && IsMenu((HMENU)g_Plugins->RSP()->GetDebugMenu())) + { + RemoveMenu((HMENU)OldMenuHandle, (DWORD)g_Plugins->RSP()->GetDebugMenu(), MF_BYCOMMAND); + } + WriteTrace(TraceDebug, __FUNCTION__ ": Destroy Old Menu"); - //Destroy the old menu - DestroyMenu((HMENU)OldMenuHandle); - } + //Destroy the old menu + DestroyMenu((HMENU)OldMenuHandle); + } - ResetAccelerators(); + ResetAccelerators(); - WriteTrace(TraceDebug,__FUNCTION__ ": Done"); + WriteTrace(TraceDebug, __FUNCTION__ ": Done"); } -#endif +#endif \ No newline at end of file diff --git a/Source/Project64/User Interface/Main Menu Class.h b/Source/Project64/User Interface/Main Menu Class.h index 880c36208..bf382b57e 100644 --- a/Source/Project64/User Interface/Main Menu Class.h +++ b/Source/Project64/User Interface/Main Menu Class.h @@ -1,85 +1,85 @@ #pragma once -enum MainMenuID +enum MainMenuID { - //File Menu - ID_FILE_OPEN_ROM = 4000, ID_FILE_ROM_INFO, ID_FILE_STARTEMULATION, ID_FILE_ENDEMULATION, - ID_FILE_ROMDIRECTORY, ID_FILE_REFRESHROMLIST, ID_FILE_EXIT, + //File Menu + ID_FILE_OPEN_ROM = 4000, ID_FILE_ROM_INFO, ID_FILE_STARTEMULATION, ID_FILE_ENDEMULATION, + ID_FILE_ROMDIRECTORY, ID_FILE_REFRESHROMLIST, ID_FILE_EXIT, - //language - ID_LANG_START, ID_LANG_END = ID_LANG_START + 100, + //language + ID_LANG_START, ID_LANG_END = ID_LANG_START + 100, - //Recent Files - ID_RECENT_ROM_START, ID_RECENT_ROM_END = ID_RECENT_ROM_START + 20, - - //Recent Dir - ID_RECENT_DIR_START, ID_RECENT_DIR_END = ID_RECENT_DIR_START + 20, + //Recent Files + ID_RECENT_ROM_START, ID_RECENT_ROM_END = ID_RECENT_ROM_START + 20, - //System Menu - ID_SYSTEM_RESET_SOFT, ID_SYSTEM_RESET_HARD, ID_SYSTEM_PAUSE, ID_SYSTEM_BITMAP, - ID_SYSTEM_LIMITFPS, ID_SYSTEM_RESTORE, ID_SYSTEM_LOAD, ID_SYSTEM_SAVE, - ID_SYSTEM_SAVEAS, ID_SYSTEM_CHEAT, ID_SYSTEM_GSBUTTON, + //Recent Dir + ID_RECENT_DIR_START, ID_RECENT_DIR_END = ID_RECENT_DIR_START + 20, - //Current Save Slot - ID_CURRENT_SAVE_1,ID_CURRENT_SAVE_2,ID_CURRENT_SAVE_3,ID_CURRENT_SAVE_4,ID_CURRENT_SAVE_5, - ID_CURRENT_SAVE_6,ID_CURRENT_SAVE_7,ID_CURRENT_SAVE_8,ID_CURRENT_SAVE_9,ID_CURRENT_SAVE_10, - ID_CURRENT_SAVE_DEFAULT, - - //Option Menu - ID_OPTIONS_FULLSCREEN, ID_OPTIONS_FULLSCREEN2, ID_OPTIONS_ALWAYSONTOP, ID_OPTIONS_CONFIG_GFX, - ID_OPTIONS_CONFIG_AUDIO, ID_OPTIONS_CONFIG_CONT,ID_OPTIONS_CONFIG_RSP, ID_OPTIONS_CPU_USAGE, - ID_OPTIONS_SETTINGS, ID_OPTIONS_DISPLAY_FR, ID_OPTIONS_CHANGE_FR, ID_OPTIONS_INCREASE_SPEED, - ID_OPTIONS_DECREASE_SPEED, + //System Menu + ID_SYSTEM_RESET_SOFT, ID_SYSTEM_RESET_HARD, ID_SYSTEM_PAUSE, ID_SYSTEM_BITMAP, + ID_SYSTEM_LIMITFPS, ID_SYSTEM_RESTORE, ID_SYSTEM_LOAD, ID_SYSTEM_SAVE, + ID_SYSTEM_SAVEAS, ID_SYSTEM_CHEAT, ID_SYSTEM_GSBUTTON, - //Debugger Menu - ID_DEBUG_SHOW_TLB_MISSES, ID_DEBUG_SHOW_UNHANDLED_MEM, ID_DEBUG_SHOW_PIF_ERRORS, - ID_DEBUG_SHOW_DLIST_COUNT, ID_DEBUG_SHOW_RECOMP_MEM_SIZE,ID_DEBUG_SHOW_DIV_BY_ZERO, - ID_DEBUG_GENERATE_LOG_FILES, ID_DEBUG_DISABLE_GAMEFIX, - ID_DEBUGGER_LOGOPTIONS, ID_DEBUGGER_GENERATELOG, ID_DEBUGGER_DUMPMEMORY, ID_DEBUGGER_SEARCHMEMORY, - ID_DEBUGGER_TLBENTRIES, ID_DEBUGGER_BREAKPOINTS, ID_DEBUGGER_MEMORY, ID_DEBUGGER_R4300REGISTERS, - ID_DEBUGGER_INTERRUPT_SP, ID_DEBUGGER_INTERRUPT_SI, ID_DEBUGGER_INTERRUPT_AI, ID_DEBUGGER_INTERRUPT_VI, - ID_DEBUGGER_INTERRUPT_PI, ID_DEBUGGER_INTERRUPT_DP, + //Current Save Slot + ID_CURRENT_SAVE_1, ID_CURRENT_SAVE_2, ID_CURRENT_SAVE_3, ID_CURRENT_SAVE_4, ID_CURRENT_SAVE_5, + ID_CURRENT_SAVE_6, ID_CURRENT_SAVE_7, ID_CURRENT_SAVE_8, ID_CURRENT_SAVE_9, ID_CURRENT_SAVE_10, + ID_CURRENT_SAVE_DEFAULT, - // App logging - ID_DEBUGGER_APPLOG_ERRORS, ID_DEBUGGER_APPLOG_SETTINGS, ID_DEBUGGER_APPLOG_GFX_PLUGIN, - ID_DEBUGGER_APPLOG_DEBUG, ID_DEBUGGER_APPLOG_FLUSH, ID_DEBUGGER_APPLOG_RECOMPILER, - ID_DEBUGGER_APPLOG_RSP, ID_DEBUGGER_APPLOG_TLB, ID_DEBUGGER_APPLOG_AUDIO_EMU, + //Option Menu + ID_OPTIONS_FULLSCREEN, ID_OPTIONS_FULLSCREEN2, ID_OPTIONS_ALWAYSONTOP, ID_OPTIONS_CONFIG_GFX, + ID_OPTIONS_CONFIG_AUDIO, ID_OPTIONS_CONFIG_CONT, ID_OPTIONS_CONFIG_RSP, ID_OPTIONS_CPU_USAGE, + ID_OPTIONS_SETTINGS, ID_OPTIONS_DISPLAY_FR, ID_OPTIONS_CHANGE_FR, ID_OPTIONS_INCREASE_SPEED, + ID_OPTIONS_DECREASE_SPEED, - //Profile Menu - ID_PROFILE_PROFILE, ID_PROFILE_RESETCOUNTER, ID_PROFILE_GENERATELOG, + //Debugger Menu + ID_DEBUG_SHOW_TLB_MISSES, ID_DEBUG_SHOW_UNHANDLED_MEM, ID_DEBUG_SHOW_PIF_ERRORS, + ID_DEBUG_SHOW_DLIST_COUNT, ID_DEBUG_SHOW_RECOMP_MEM_SIZE, ID_DEBUG_SHOW_DIV_BY_ZERO, + ID_DEBUG_GENERATE_LOG_FILES, ID_DEBUG_DISABLE_GAMEFIX, + ID_DEBUGGER_LOGOPTIONS, ID_DEBUGGER_GENERATELOG, ID_DEBUGGER_DUMPMEMORY, ID_DEBUGGER_SEARCHMEMORY, + ID_DEBUGGER_TLBENTRIES, ID_DEBUGGER_BREAKPOINTS, ID_DEBUGGER_MEMORY, ID_DEBUGGER_R4300REGISTERS, + ID_DEBUGGER_INTERRUPT_SP, ID_DEBUGGER_INTERRUPT_SI, ID_DEBUGGER_INTERRUPT_AI, ID_DEBUGGER_INTERRUPT_VI, + ID_DEBUGGER_INTERRUPT_PI, ID_DEBUGGER_INTERRUPT_DP, - //Help Menu - ID_HELP_SUPPORTFORUM, ID_HELP_HOMEPAGE, ID_HELP_ABOUTSETTINGFILES, ID_HELP_ABOUT, + // App logging + ID_DEBUGGER_APPLOG_ERRORS, ID_DEBUGGER_APPLOG_SETTINGS, ID_DEBUGGER_APPLOG_GFX_PLUGIN, + ID_DEBUGGER_APPLOG_DEBUG, ID_DEBUGGER_APPLOG_FLUSH, ID_DEBUGGER_APPLOG_RECOMPILER, + ID_DEBUGGER_APPLOG_RSP, ID_DEBUGGER_APPLOG_TLB, ID_DEBUGGER_APPLOG_AUDIO_EMU, + + //Profile Menu + ID_PROFILE_PROFILE, ID_PROFILE_RESETCOUNTER, ID_PROFILE_GENERATELOG, + + //Help Menu + ID_HELP_SUPPORTFORUM, ID_HELP_HOMEPAGE, ID_HELP_ABOUTSETTINGFILES, ID_HELP_ABOUT, }; class CMainMenu : - public CBaseMenu, - private CDebugSettings + public CBaseMenu, + private CDebugSettings { - typedef std::list SettingList; + typedef std::list SettingList; - CMainGui * _Gui; + CMainGui * _Gui; - //MSC_MAP m_ShortCuts; - void * m_AccelTable; - bool m_ResetAccelerators; - CShortCuts m_ShortCuts; - SettingList m_ChangeSettingList; - CriticalSection m_CS; - - void FillOutMenu ( HMENU hMenu ); - //stdstr ShortCutString(MSC_MAP & ShortCuts, int MenuID, CMenuShortCutKey::ACCESS_MODE AccessLevel); - std::wstring GetSaveSlotString ( int Slot ); - stdstr GetFileLastMod ( stdstr FileName ); - void RebuildAccelerators ( void ); + //MSC_MAP m_ShortCuts; + void * m_AccelTable; + bool m_ResetAccelerators; + CShortCuts m_ShortCuts; + SettingList m_ChangeSettingList; + CriticalSection m_CS; - static void SettingsChanged (CMainMenu * _this ); + void FillOutMenu(HMENU hMenu); + //stdstr ShortCutString(MSC_MAP & ShortCuts, int MenuID, CMenuShortCutKey::ACCESS_MODE AccessLevel); + std::wstring GetSaveSlotString(int Slot); + stdstr GetFileLastMod(stdstr FileName); + void RebuildAccelerators(void); + + static void SettingsChanged(CMainMenu * _this); public: - CMainMenu ( CMainGui * Window ); - ~CMainMenu(); - - int ProcessAccelerator ( HWND hWnd, void * lpMsg ); - bool ProcessMessage ( HWND hWnd, DWORD wNotifyCode, DWORD wID); - void ResetMenu ( void ); - void ResetAccelerators ( void ) { m_ResetAccelerators = true; } + CMainMenu(CMainGui * Window); + ~CMainMenu(); + + int ProcessAccelerator(HWND hWnd, void * lpMsg); + bool ProcessMessage(HWND hWnd, DWORD wNotifyCode, DWORD wID); + void ResetMenu(void); + void ResetAccelerators(void) { m_ResetAccelerators = true; } }; From 6d38975b985049f6ba68397c73bbd5c83de8a397 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 12 Nov 2015 23:09:34 +1100 Subject: [PATCH 150/213] [Project64] More code cleanup of gui class --- Source/Project64/N64 System/N64 Class.cpp | 24 ---- Source/Project64/N64 System/N64 Class.h | 1 - .../User Interface/Main Menu Class.cpp | 115 ++++++++++-------- .../User Interface/Main Menu Class.h | 41 ++++--- 4 files changed, 88 insertions(+), 93 deletions(-) diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index eef3d2e92..cd70b8a1a 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -459,30 +459,6 @@ void CN64System::Pause() Notify().DisplayMessage(5, MSG_CPU_RESUMED); } -stdstr CN64System::ChooseFileToOpen(HWND hParent) -{ - OPENFILENAME openfilename; - char FileName[_MAX_PATH], Directory[_MAX_PATH]; - - memset(&FileName, 0, sizeof(FileName)); - memset(&openfilename, 0, sizeof(openfilename)); - - strcpy(Directory, g_Settings->LoadStringVal(Directory_Game).c_str()); - - openfilename.lStructSize = sizeof(openfilename); - openfilename.hwndOwner = (HWND)hParent; - openfilename.lpstrFilter = "N64 ROMs (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0"; - openfilename.lpstrFile = FileName; - openfilename.lpstrInitialDir = Directory; - openfilename.nMaxFile = MAX_PATH; - openfilename.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; - - if (GetOpenFileName(&openfilename)) - { - return stdstr(FileName); - } - return stdstr(""); -} void CN64System::GameReset() { diff --git a/Source/Project64/N64 System/N64 Class.h b/Source/Project64/N64 System/N64 Class.h index b703e1861..beb835c77 100644 --- a/Source/Project64/N64 System/N64 Class.h +++ b/Source/Project64/N64 System/N64 Class.h @@ -50,7 +50,6 @@ public: void CloseCpu(); void ExternalEvent(SystemEvent action); //covers gui interacting and timers etc.. - stdstr ChooseFileToOpen(HWND hParent); void DisplayRomInfo(HWND hParent); void StartEmulation(bool NewThread); void SyncToAudio(); diff --git a/Source/Project64/User Interface/Main Menu Class.cpp b/Source/Project64/User Interface/Main Menu Class.cpp index 0fec51d61..bfdf6baa4 100644 --- a/Source/Project64/User Interface/Main Menu Class.cpp +++ b/Source/Project64/User Interface/Main Menu Class.cpp @@ -1,14 +1,13 @@ #include "stdafx.h" -#ifdef WINDOWS_UI #include #include CMainMenu::CMainMenu(CMainGui * hMainWindow) : CBaseMenu(), -m_ResetAccelerators(true) +m_ResetAccelerators(true), +m_Gui(hMainWindow) { - _Gui = hMainWindow; //Make a copy of the attatched window ResetMenu(); hMainWindow->SetWindowMenu(this); @@ -63,13 +62,39 @@ int CMainMenu::ProcessAccelerator(HWND hWnd, void * lpMsg) return TranslateAccelerator((HWND)hWnd, (HACCEL)m_AccelTable, (LPMSG)lpMsg); } +stdstr CMainMenu::ChooseFileToOpen(HWND hParent) +{ + OPENFILENAME openfilename; + char FileName[_MAX_PATH], Directory[_MAX_PATH]; + + memset(&FileName, 0, sizeof(FileName)); + memset(&openfilename, 0, sizeof(openfilename)); + + strcpy(Directory, g_Settings->LoadStringVal(Directory_Game).c_str()); + + openfilename.lStructSize = sizeof(openfilename); + openfilename.hwndOwner = (HWND)hParent; + openfilename.lpstrFilter = "N64 ROMs (*.zip, *.7z, *.?64, *.rom, *.usa, *.jap, *.pal, *.bin)\0*.?64;*.zip;*.7z;*.bin;*.rom;*.usa;*.jap;*.pal\0All files (*.*)\0*.*\0"; + openfilename.lpstrFile = FileName; + openfilename.lpstrInitialDir = Directory; + openfilename.nMaxFile = MAX_PATH; + openfilename.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; + + if (GetOpenFileName(&openfilename)) + { + return stdstr(FileName); + } + return stdstr(""); +} + bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuID) { switch (MenuID) { case ID_FILE_OPEN_ROM: { - stdstr File = g_BaseSystem->ChooseFileToOpen(hWnd); - if (File.length() > 0) { + stdstr File = ChooseFileToOpen(hWnd); + if (File.length() > 0) + { g_BaseSystem->RunFileImage(File.c_str()); } } @@ -80,7 +105,7 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI } break; case ID_FILE_STARTEMULATION: - _Gui->SaveWindowLoc(); + m_Gui->SaveWindowLoc(); //Before we go and create the new system, ensure the previous one has been closed CN64System::CloseSystem(); //Ok now g_BaseSystem should definitely be clean for initialization @@ -91,16 +116,16 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI case ID_FILE_ENDEMULATION: WriteTrace(TraceDebug, __FUNCTION__ ": ID_FILE_ENDEMULATION"); CN64System::CloseSystem(); - _Gui->SaveWindowLoc(); + m_Gui->SaveWindowLoc(); break; case ID_FILE_ROMDIRECTORY: WriteTrace(TraceDebug, __FUNCTION__ ": ID_FILE_ROMDIRECTORY 1"); - _Gui->SelectRomDir(); + m_Gui->SelectRomDir(); WriteTrace(TraceDebug, __FUNCTION__ ": ID_FILE_ROMDIRECTORY 2"); - _Gui->RefreshMenu(); + m_Gui->RefreshMenu(); WriteTrace(TraceDebug, __FUNCTION__ ": ID_FILE_ROMDIRECTORY 3"); break; - case ID_FILE_REFRESHROMLIST: _Gui->RefreshRomBrowser(); break; + case ID_FILE_REFRESHROMLIST: m_Gui->RefreshRomBrowser(); break; case ID_FILE_EXIT: DestroyWindow((HWND)hWnd); break; case ID_SYSTEM_RESET_SOFT: WriteTrace(TraceDebug, __FUNCTION__ ": ID_SYSTEM_RESET_SOFT"); @@ -111,16 +136,9 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI g_BaseSystem->ExternalEvent(SysEvent_ResetCPU_Hard); break; case ID_SYSTEM_PAUSE: - _Gui->SaveWindowLoc(); + m_Gui->SaveWindowLoc(); WriteTrace(TraceDebug, __FUNCTION__ ": ID_SYSTEM_PAUSE"); - if (g_Settings->LoadBool(GameRunning_CPU_Paused)) - { - g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_FromMenu); - } - else - { - g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_FromMenu); - } + g_BaseSystem->ExternalEvent(g_Settings->LoadBool(GameRunning_CPU_Paused) ? SysEvent_ResumeCPU_FromMenu : SysEvent_PauseCPU_FromMenu); WriteTrace(TraceDebug, __FUNCTION__ ": ID_SYSTEM_PAUSE 1"); break; case ID_SYSTEM_BITMAP: @@ -253,14 +271,14 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI if (g_Settings->LoadBool(UserInterface_InFullScreen)) { WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN a"); - _Gui->MakeWindowOnTop(false); + m_Gui->MakeWindowOnTop(false); Notify().SetGfxPlugin(NULL); WriteTrace(TraceGfxPlugin, __FUNCTION__ ": ChangeWindow: Starting"); g_Plugins->Gfx()->ChangeWindow(); WriteTrace(TraceGfxPlugin, __FUNCTION__ ": ChangeWindow: Done"); ShowCursor(true); - _Gui->ShowStatusBar(true); - _Gui->MakeWindowOnTop(g_Settings->LoadBool(UserInterface_AlwaysOnTop)); + m_Gui->ShowStatusBar(true); + m_Gui->MakeWindowOnTop(g_Settings->LoadBool(UserInterface_AlwaysOnTop)); g_Settings->SaveBool(UserInterface_InFullScreen, (DWORD)false); } else @@ -268,7 +286,7 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN b"); ShowCursor(false); WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 1"); - _Gui->ShowStatusBar(false); + m_Gui->ShowStatusBar(false); WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 2"); try { @@ -284,7 +302,7 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI MessageBox(NULL, Message, "Exception", MB_OK); } WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 4"); - _Gui->MakeWindowOnTop(false); + m_Gui->MakeWindowOnTop(false); WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 5"); Notify().SetGfxPlugin(g_Plugins->Gfx()); WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_FULLSCREEN b 3"); @@ -297,12 +315,12 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI if (g_Settings->LoadDword(UserInterface_AlwaysOnTop)) { g_Settings->SaveBool(UserInterface_AlwaysOnTop, false); - _Gui->MakeWindowOnTop(false); + m_Gui->MakeWindowOnTop(false); } else { g_Settings->SaveBool(UserInterface_AlwaysOnTop, true); - _Gui->MakeWindowOnTop(g_Settings->LoadBool(GameRunning_CPU_Running)); + m_Gui->MakeWindowOnTop(g_Settings->LoadBool(GameRunning_CPU_Running)); } break; case ID_OPTIONS_CONFIG_RSP: WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_CONFIG_RSP"); g_Plugins->ConfigPlugin((DWORD)hWnd, PLUGIN_TYPE_RSP); break; @@ -474,14 +492,14 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI case ID_DEBUGGER_APPLOG_FLUSH: g_Settings->SaveBool(Debugger_AppLogFlush, !g_Settings->LoadBool(Debugger_AppLogFlush)); break; - case ID_DEBUGGER_LOGOPTIONS: _Gui->EnterLogOptions(); break; + case ID_DEBUGGER_LOGOPTIONS: m_Gui->EnterLogOptions(); break; case ID_DEBUGGER_GENERATELOG: g_Settings->SaveBool(Debugger_GenerateDebugLog, !g_Settings->LoadBool(Debugger_GenerateDebugLog)); break; - case ID_DEBUGGER_DUMPMEMORY: _Gui->Debug_ShowMemoryDump(); break; - case ID_DEBUGGER_SEARCHMEMORY: _Gui->Debug_ShowMemorySearch(); break; - case ID_DEBUGGER_MEMORY: _Gui->Debug_ShowMemoryWindow(); break; - case ID_DEBUGGER_TLBENTRIES: _Gui->Debug_ShowTLBWindow(); break; + case ID_DEBUGGER_DUMPMEMORY: m_Gui->Debug_ShowMemoryDump(); break; + case ID_DEBUGGER_SEARCHMEMORY: m_Gui->Debug_ShowMemorySearch(); break; + case ID_DEBUGGER_MEMORY: m_Gui->Debug_ShowMemoryWindow(); break; + case ID_DEBUGGER_TLBENTRIES: m_Gui->Debug_ShowTLBWindow(); break; case ID_DEBUGGER_INTERRUPT_SP: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_SP); break; case ID_DEBUGGER_INTERRUPT_SI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_SI); break; case ID_DEBUGGER_INTERRUPT_AI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_AI); break; @@ -489,7 +507,7 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI case ID_DEBUGGER_INTERRUPT_PI: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_PI); break; case ID_DEBUGGER_INTERRUPT_DP: g_BaseSystem->ExternalEvent(SysEvent_Interrupt_DP); break; case ID_CURRENT_SAVE_DEFAULT: - Notify().DisplayMessage(3, stdstr_f("Save Slot (%s) selected", GetSaveSlotString(MenuID - ID_CURRENT_SAVE_DEFAULT).c_str()).ToUTF16().c_str()); + g_Notify->DisplayMessage(3, stdstr_f("Save Slot (%s) selected", GetSaveSlotString(MenuID - ID_CURRENT_SAVE_DEFAULT).c_str()).ToUTF16().c_str()); g_Settings->SaveDword(Game_CurrentSaveState, (DWORD)(MenuID - ID_CURRENT_SAVE_DEFAULT)); break; case ID_CURRENT_SAVE_1: @@ -502,13 +520,13 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI case ID_CURRENT_SAVE_8: case ID_CURRENT_SAVE_9: case ID_CURRENT_SAVE_10: - Notify().DisplayMessage(3, stdstr_f("Save Slot (%s) selected", GetSaveSlotString((MenuID - ID_CURRENT_SAVE_1) + 1)).ToUTF16().c_str()); + g_Notify->DisplayMessage(3, stdstr_f("Save Slot (%s) selected", GetSaveSlotString((MenuID - ID_CURRENT_SAVE_1) + 1)).ToUTF16().c_str()); g_Settings->SaveDword(Game_CurrentSaveState, (DWORD)((MenuID - ID_CURRENT_SAVE_1) + 1)); break; case ID_HELP_SUPPORTFORUM: ShellExecute(NULL, "open", "http://forum.pj64-emu.com/", NULL, NULL, SW_SHOWMAXIMIZED); break; case ID_HELP_HOMEPAGE: ShellExecute(NULL, "open", "http://www.pj64-emu.com", NULL, NULL, SW_SHOWMAXIMIZED); break; - case ID_HELP_ABOUT: _Gui->AboutBox(); break; - case ID_HELP_ABOUTSETTINGFILES: _Gui->AboutIniBox(); break; + case ID_HELP_ABOUT: m_Gui->AboutBox(); break; + case ID_HELP_ABOUTSETTINGFILES: m_Gui->AboutIniBox(); break; default: if (MenuID >= ID_RECENT_ROM_START && MenuID < ID_RECENT_ROM_END) { @@ -527,10 +545,10 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI { g_Settings->SaveString(Directory_Game, Dir.c_str()); Notify().AddRecentDir(Dir.c_str()); - _Gui->RefreshMenu(); - if (_Gui->RomBrowserVisible()) + m_Gui->RefreshMenu(); + if (m_Gui->RomBrowserVisible()) { - _Gui->RefreshRomBrowser(); + m_Gui->RefreshRomBrowser(); } } } @@ -546,10 +564,8 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI menuinfo.cch = sizeof(String); GetMenuItemInfoW((HMENU)m_MenuHandle, MenuID, FALSE, &menuinfo); - //See if the language has changed, if not do nothing - //Set the language g_Lang->SetLanguage(String); - _Gui->ResetRomBrowserColomuns(); + m_Gui->ResetRomBrowserColomuns(); break; } return false; @@ -882,7 +898,7 @@ void CMainMenu::FillOutMenu(HMENU hMenu) MenuItemList OptionMenu; Item.Reset(ID_OPTIONS_FULLSCREEN, MENU_FULL_SCREEN, m_ShortCuts.ShortCutString(ID_OPTIONS_FULLSCREEN, AccessLevel)); Item.SetItemEnabled(CPURunning); - if (g_Plugins->Gfx() && g_Plugins->Gfx()->ChangeWindow == NULL) + if (g_Plugins && g_Plugins->Gfx() && g_Plugins->Gfx()->ChangeWindow == NULL) { Item.SetItemEnabled(false); } @@ -897,7 +913,7 @@ void CMainMenu::FillOutMenu(HMENU hMenu) OptionMenu.push_back(MENU_ITEM(SPLITER)); Item.Reset(ID_OPTIONS_CONFIG_GFX, MENU_CONFG_GFX, m_ShortCuts.ShortCutString(ID_OPTIONS_CONFIG_GFX, AccessLevel)); - if (g_Plugins->Gfx() == NULL || g_Plugins->Gfx()->DllConfig == NULL) + if (g_Plugins && g_Plugins->Gfx() == NULL || g_Plugins->Gfx()->DllConfig == NULL) { Item.SetItemEnabled(false); } @@ -918,7 +934,7 @@ void CMainMenu::FillOutMenu(HMENU hMenu) OptionMenu.push_back(Item); } Item.Reset(ID_OPTIONS_CONFIG_CONT, MENU_CONFG_CTRL, m_ShortCuts.ShortCutString(ID_OPTIONS_CONFIG_CONT, AccessLevel)); - if (g_Plugins->Control() == NULL || g_Plugins->Control()->DllConfig == NULL) + if (g_Plugins && g_Plugins->Control() == NULL || g_Plugins->Control()->DllConfig == NULL) { Item.SetItemEnabled(false); } @@ -1071,7 +1087,7 @@ void CMainMenu::FillOutMenu(HMENU hMenu) /* Debug - RSP *******************/ - if (g_Plugins->RSP() != NULL && IsMenu((HMENU)g_Plugins->RSP()->GetDebugMenu())) + if (g_Plugins && g_Plugins->RSP() != NULL && IsMenu((HMENU)g_Plugins->RSP()->GetDebugMenu())) { Item.Reset(ID_PLUGIN_MENU, EMPTY_STRING, EMPTY_STDSTR, g_Plugins->RSP()->GetDebugMenu(), L"&RSP"); DebugMenu.push_back(Item); @@ -1079,7 +1095,7 @@ void CMainMenu::FillOutMenu(HMENU hMenu) /* Debug - RDP *******************/ - if (g_Plugins->Gfx() != NULL && IsMenu((HMENU)g_Plugins->Gfx()->GetDebugMenu())) + if (g_Plugins && g_Plugins->Gfx() != NULL && IsMenu((HMENU)g_Plugins->Gfx()->GetDebugMenu())) { Item.Reset(ID_PLUGIN_MENU, EMPTY_STRING, EMPTY_STDSTR, g_Plugins->Gfx()->GetDebugMenu(), L"&RDP"); DebugMenu.push_back(Item); @@ -1213,7 +1229,7 @@ void CMainMenu::ResetMenu(void) { //Create a new window with all the items WriteTrace(TraceDebug, __FUNCTION__ ": Create Menu"); - HMENU hMenu = (HMENU)CreateMenu(); + HMENU hMenu = CreateMenu(); FillOutMenu(hMenu); WriteTrace(TraceDebug, __FUNCTION__ ": Create Menu Done"); @@ -1227,7 +1243,7 @@ void CMainMenu::ResetMenu(void) WriteTrace(TraceDebug, __FUNCTION__ ": Attach Menu"); m_MenuHandle = hMenu; } - _Gui->SetWindowMenu(this); + m_Gui->SetWindowMenu(this); WriteTrace(TraceDebug, __FUNCTION__ ": Remove plugin menu"); if (g_Plugins->Gfx() != NULL && IsMenu((HMENU)g_Plugins->Gfx()->GetDebugMenu())) @@ -1247,5 +1263,4 @@ void CMainMenu::ResetMenu(void) ResetAccelerators(); WriteTrace(TraceDebug, __FUNCTION__ ": Done"); -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/Source/Project64/User Interface/Main Menu Class.h b/Source/Project64/User Interface/Main Menu Class.h index bf382b57e..48bdeb7cd 100644 --- a/Source/Project64/User Interface/Main Menu Class.h +++ b/Source/Project64/User Interface/Main Menu Class.h @@ -56,24 +56,6 @@ class CMainMenu : public CBaseMenu, private CDebugSettings { - typedef std::list SettingList; - - CMainGui * _Gui; - - //MSC_MAP m_ShortCuts; - void * m_AccelTable; - bool m_ResetAccelerators; - CShortCuts m_ShortCuts; - SettingList m_ChangeSettingList; - CriticalSection m_CS; - - void FillOutMenu(HMENU hMenu); - //stdstr ShortCutString(MSC_MAP & ShortCuts, int MenuID, CMenuShortCutKey::ACCESS_MODE AccessLevel); - std::wstring GetSaveSlotString(int Slot); - stdstr GetFileLastMod(stdstr FileName); - void RebuildAccelerators(void); - - static void SettingsChanged(CMainMenu * _this); public: CMainMenu(CMainGui * Window); ~CMainMenu(); @@ -82,4 +64,27 @@ public: bool ProcessMessage(HWND hWnd, DWORD wNotifyCode, DWORD wID); void ResetMenu(void); void ResetAccelerators(void) { m_ResetAccelerators = true; } + +private: + CMainMenu(); // Disable default constructor + CMainMenu(const CMainMenu&); // Disable copy constructor + CMainMenu& operator=(const CMainMenu&); // Disable assignment + + void FillOutMenu(HMENU hMenu); + std::wstring GetSaveSlotString(int Slot); + stdstr GetFileLastMod(stdstr FileName); + void RebuildAccelerators(void); + stdstr ChooseFileToOpen(HWND hParent); + + static void SettingsChanged(CMainMenu * _this); + + typedef std::list SettingList; + + CMainGui * m_Gui; + + void * m_AccelTable; + bool m_ResetAccelerators; + CShortCuts m_ShortCuts; + SettingList m_ChangeSettingList; + CriticalSection m_CS; }; From a4c438c20de201718eb5b72c1259fa3f64c0e612 Mon Sep 17 00:00:00 2001 From: zilmar Date: Fri, 13 Nov 2015 08:27:28 +1100 Subject: [PATCH 151/213] [Project64] Cleanup ModifiedEditBox.cpp --- .../WTL Controls/ModifiedEditBox.cpp | 124 +++++++++--------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/Source/Project64/User Interface/WTL Controls/ModifiedEditBox.cpp b/Source/Project64/User Interface/WTL Controls/ModifiedEditBox.cpp index d87c05bb1..cbdb5062b 100644 --- a/Source/Project64/User Interface/WTL Controls/ModifiedEditBox.cpp +++ b/Source/Project64/User Interface/WTL Controls/ModifiedEditBox.cpp @@ -23,84 +23,84 @@ m_bString(bString) CModifiedEditBox::~CModifiedEditBox() { - if (m_BoldFont) - { - DeleteObject(m_BoldFont); - } + if (m_BoldFont) + { + DeleteObject(m_BoldFont); + } } void CModifiedEditBox::SetReset(bool Reset) { - m_Reset = Reset; - if (m_Reset) - { - SetChanged(false); - } + m_Reset = Reset; + if (m_Reset) + { + SetChanged(false); + } } void CModifiedEditBox::SetChanged(bool Changed) { - m_Changed = Changed; - if (m_Changed) - { - SetReset(false); - if (m_BoldFont == NULL) - { - m_OriginalFont = (HFONT)SendMessage(WM_GETFONT); + m_Changed = Changed; + if (m_Changed) + { + SetReset(false); + if (m_BoldFont == NULL) + { + m_OriginalFont = (HFONT)SendMessage(WM_GETFONT); - LOGFONT lfSystemVariableFont; - GetObject(m_OriginalFont, sizeof(LOGFONT), &lfSystemVariableFont); - lfSystemVariableFont.lfWeight = FW_BOLD; + LOGFONT lfSystemVariableFont; + GetObject(m_OriginalFont, sizeof(LOGFONT), &lfSystemVariableFont); + lfSystemVariableFont.lfWeight = FW_BOLD; - m_BoldFont = CreateFontIndirect(&lfSystemVariableFont); - } - SendMessage(WM_SETFONT, (WPARAM)m_BoldFont); - InvalidateRect(NULL); - if (m_TextField) - { - ::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_BoldFont, 0); - ::InvalidateRect(m_TextField, NULL, true); - } - } - else - { - if (m_OriginalFont) - { - SendMessage(WM_SETFONT, (WPARAM)m_OriginalFont); - InvalidateRect(NULL); - if (m_TextField) - { - ::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_OriginalFont, 0); - ::InvalidateRect(m_TextField, NULL, true); - } - } - } + m_BoldFont = CreateFontIndirect(&lfSystemVariableFont); + } + SendMessage(WM_SETFONT, (WPARAM)m_BoldFont); + InvalidateRect(NULL); + if (m_TextField) + { + ::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_BoldFont, 0); + ::InvalidateRect(m_TextField, NULL, true); + } + } + else + { + if (m_OriginalFont) + { + SendMessage(WM_SETFONT, (WPARAM)m_OriginalFont); + InvalidateRect(NULL); + if (m_TextField) + { + ::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_OriginalFont, 0); + ::InvalidateRect(m_TextField, NULL, true); + } + } + } } stdstr CModifiedEditBox::GetWindowText(void) { - stdstr Result; - ATLASSERT(::IsWindow(m_hWnd)); + stdstr Result; + ATLASSERT(::IsWindow(m_hWnd)); - int nLen = ::GetWindowTextLength(m_hWnd); - if (nLen == 0) - { - return Result; - } - Result.resize(nLen + 1); - ::GetWindowText(m_hWnd, (char *)Result.c_str(), nLen + 1); - return Result; + int nLen = ::GetWindowTextLength(m_hWnd); + if (nLen == 0) + { + return Result; + } + Result.resize(nLen + 1); + ::GetWindowText(m_hWnd, (char *)Result.c_str(), nLen + 1); + return Result; } void CModifiedEditBox::SetTextField(HWND hWnd) { - if (m_TextField && m_OriginalFont) - { - ::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_OriginalFont, 0); - } - m_TextField = hWnd; - if (m_Changed && m_BoldFont) - { - ::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_BoldFont, 0); - } -} + if (m_TextField && m_OriginalFont) + { + ::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_OriginalFont, 0); + } + m_TextField = hWnd; + if (m_Changed && m_BoldFont) + { + ::SendMessage(m_TextField, WM_SETFONT, (WPARAM)m_BoldFont, 0); + } +} \ No newline at end of file From 1b2febc3c2f302e76036d08ad881aa1394180629 Mon Sep 17 00:00:00 2001 From: zilmar Date: Fri, 13 Nov 2015 08:30:40 +1100 Subject: [PATCH 152/213] [Project64] Clean up Settings Page - Keyboard Shortcuts.cpp --- .../Settings Page - Keyboard Shortcuts.cpp | 540 +++++++++--------- 1 file changed, 270 insertions(+), 270 deletions(-) diff --git a/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.cpp b/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.cpp index 9eb9ebe51..29aaff1db 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.cpp @@ -15,362 +15,362 @@ COptionsShortCutsPage::COptionsShortCutsPage(HWND hParent, const RECT & rcDispay) : m_EnableReset(false) { - if (!Create(hParent, rcDispay)) - { - return; - } + if (!Create(hParent, rcDispay)) + { + return; + } - SetDlgItemTextW(m_hWnd, IDC_S_CPU_STATE, GS(ACCEL_CPUSTATE_TITLE)); - SetDlgItemTextW(m_hWnd, IDC_MENU_ITEM_TEXT, GS(ACCEL_MENUITEM_TITLE)); - SetDlgItemTextW(m_hWnd, IDC_S_CURRENT_KEYS, GS(ACCEL_CURRENTKEYS_TITLE)); - SetDlgItemTextW(m_hWnd, IDC_S_SELECT_SHORT, GS(ACCEL_SELKEY_TITLE)); - SetDlgItemTextW(m_hWnd, IDC_S_CURRENT_ASSIGN, GS(ACCEL_ASSIGNEDTO_TITLE)); - SetDlgItemTextW(m_hWnd, IDC_ASSIGN, GS(ACCEL_ASSIGN_BTN)); - SetDlgItemTextW(m_hWnd, IDC_REMOVE, GS(ACCEL_REMOVE_BTN)); - SetDlgItemTextW(m_hWnd, IDC_KEY_PROMPT, GS(ACCEL_DETECTKEY)); + SetDlgItemTextW(m_hWnd, IDC_S_CPU_STATE, GS(ACCEL_CPUSTATE_TITLE)); + SetDlgItemTextW(m_hWnd, IDC_MENU_ITEM_TEXT, GS(ACCEL_MENUITEM_TITLE)); + SetDlgItemTextW(m_hWnd, IDC_S_CURRENT_KEYS, GS(ACCEL_CURRENTKEYS_TITLE)); + SetDlgItemTextW(m_hWnd, IDC_S_SELECT_SHORT, GS(ACCEL_SELKEY_TITLE)); + SetDlgItemTextW(m_hWnd, IDC_S_CURRENT_ASSIGN, GS(ACCEL_ASSIGNEDTO_TITLE)); + SetDlgItemTextW(m_hWnd, IDC_ASSIGN, GS(ACCEL_ASSIGN_BTN)); + SetDlgItemTextW(m_hWnd, IDC_REMOVE, GS(ACCEL_REMOVE_BTN)); + SetDlgItemTextW(m_hWnd, IDC_KEY_PROMPT, GS(ACCEL_DETECTKEY)); - m_CreateNewShortCut.AttachToDlgItem(m_hWnd, IDC_S_SELECT_SHORT); - m_CpuState.Attach(GetDlgItem(IDC_C_CPU_STATE)); - m_MenuItems.Attach(GetDlgItem(IDC_MENU_ITEMS)); - m_CurrentKeys.Attach(GetDlgItem(IDC_CURRENT_KEYS)); - m_VirtualKeyList.Attach(GetDlgItem(IDC_VIRTUALKEY)); + m_CreateNewShortCut.AttachToDlgItem(m_hWnd, IDC_S_SELECT_SHORT); + m_CpuState.Attach(GetDlgItem(IDC_C_CPU_STATE)); + m_MenuItems.Attach(GetDlgItem(IDC_MENU_ITEMS)); + m_CurrentKeys.Attach(GetDlgItem(IDC_CURRENT_KEYS)); + m_VirtualKeyList.Attach(GetDlgItem(IDC_VIRTUALKEY)); - m_MenuItems.ModifyStyle(0, TVS_SHOWSELALWAYS); + m_MenuItems.ModifyStyle(0, TVS_SHOWSELALWAYS); - m_CpuState.SetItemData(m_CpuState.AddStringW(GS(ACCEL_CPUSTATE_1)), CMenuShortCutKey::GAME_NOT_RUNNING); - m_CpuState.SetItemData(m_CpuState.AddStringW(GS(ACCEL_CPUSTATE_3)), CMenuShortCutKey::GAME_RUNNING_WINDOW); - m_CpuState.SetItemData(m_CpuState.AddStringW(GS(ACCEL_CPUSTATE_4)), CMenuShortCutKey::GAME_RUNNING_FULLSCREEN); - m_CpuState.SetCurSel(0); + m_CpuState.SetItemData(m_CpuState.AddStringW(GS(ACCEL_CPUSTATE_1)), CMenuShortCutKey::GAME_NOT_RUNNING); + m_CpuState.SetItemData(m_CpuState.AddStringW(GS(ACCEL_CPUSTATE_3)), CMenuShortCutKey::GAME_RUNNING_WINDOW); + m_CpuState.SetItemData(m_CpuState.AddStringW(GS(ACCEL_CPUSTATE_4)), CMenuShortCutKey::GAME_RUNNING_FULLSCREEN); + m_CpuState.SetCurSel(0); - int VirtualKeyListSize; - VIRTUAL_KEY * VirtualKeyList = CMenuShortCutKey::VirtualKeyList(VirtualKeyListSize); - for (int count = 0; count < VirtualKeyListSize; count++) - { - m_VirtualKeyList.SetItemData(m_VirtualKeyList.AddString(VirtualKeyList[count].Name), VirtualKeyList[count].Key); - } + int VirtualKeyListSize; + VIRTUAL_KEY * VirtualKeyList = CMenuShortCutKey::VirtualKeyList(VirtualKeyListSize); + for (int count = 0; count < VirtualKeyListSize; count++) + { + m_VirtualKeyList.SetItemData(m_VirtualKeyList.AddString(VirtualKeyList[count].Name), VirtualKeyList[count].Key); + } - OnCpuStateChanged(LBN_SELCHANGE, IDC_C_CPU_STATE, GetDlgItem(IDC_C_CPU_STATE)); - CheckResetEnable(); + OnCpuStateChanged(LBN_SELCHANGE, IDC_C_CPU_STATE, GetDlgItem(IDC_C_CPU_STATE)); + CheckResetEnable(); } void COptionsShortCutsPage::CheckResetEnable(void) { - MSC_MAP & ShortCuts = m_ShortCuts.GetShortCuts(); - for (MSC_MAP::iterator Item = ShortCuts.begin(); Item != ShortCuts.end(); Item++) - { - const SHORTCUT_KEY_LIST & ShortCutList = Item->second.GetAccelItems(); - for (SHORTCUT_KEY_LIST::const_iterator ShortCut_item = ShortCutList.begin(); ShortCut_item != ShortCutList.end(); ShortCut_item++) - { - if (!ShortCut_item->Inactive() && !ShortCut_item->UserAdded()) - { - continue; - } - m_EnableReset = true; - return; - } - } - m_EnableReset = false; + MSC_MAP & ShortCuts = m_ShortCuts.GetShortCuts(); + for (MSC_MAP::iterator Item = ShortCuts.begin(); Item != ShortCuts.end(); Item++) + { + const SHORTCUT_KEY_LIST & ShortCutList = Item->second.GetAccelItems(); + for (SHORTCUT_KEY_LIST::const_iterator ShortCut_item = ShortCutList.begin(); ShortCut_item != ShortCutList.end(); ShortCut_item++) + { + if (!ShortCut_item->Inactive() && !ShortCut_item->UserAdded()) + { + continue; + } + m_EnableReset = true; + return; + } + } + m_EnableReset = false; } void COptionsShortCutsPage::OnCpuStateChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { - ACCESS_MODE AccessLevel = (ACCESS_MODE)m_CpuState.GetItemData(m_CpuState.GetCurSel()); + ACCESS_MODE AccessLevel = (ACCESS_MODE)m_CpuState.GetItemData(m_CpuState.GetCurSel()); - MSC_MAP & ShortCuts = m_ShortCuts.GetShortCuts(); - m_MenuItems.DeleteAllItems(); + MSC_MAP & ShortCuts = m_ShortCuts.GetShortCuts(); + m_MenuItems.DeleteAllItems(); - for (MSC_MAP::iterator Item = ShortCuts.begin(); Item != ShortCuts.end(); Item++) - { - ACCESS_MODE ItemMode = Item->second.AccessMode(); - if ((ItemMode & AccessLevel) != AccessLevel) - { - continue; - } - //find Parent - HTREEITEM hParent = m_MenuItems.GetChildItem(TVI_ROOT); - while (hParent) - { - if (m_MenuItems.GetItemData(hParent) == (DWORD_PTR)Item->second.Section()) - { - break; - } - hParent = m_MenuItems.GetNextSiblingItem(hParent); - } + for (MSC_MAP::iterator Item = ShortCuts.begin(); Item != ShortCuts.end(); Item++) + { + ACCESS_MODE ItemMode = Item->second.AccessMode(); + if ((ItemMode & AccessLevel) != AccessLevel) + { + continue; + } + //find Parent + HTREEITEM hParent = m_MenuItems.GetChildItem(TVI_ROOT); + while (hParent) + { + if (m_MenuItems.GetItemData(hParent) == (DWORD_PTR)Item->second.Section()) + { + break; + } + hParent = m_MenuItems.GetNextSiblingItem(hParent); + } - if (hParent == NULL) - { - hParent = m_MenuItems.InsertItemW(TVIF_TEXT | TVIF_PARAM, GS(Item->second.Section()), 0, 0, 0, 0, Item->second.Section(), TVI_ROOT, TVI_LAST); - } + if (hParent == NULL) + { + hParent = m_MenuItems.InsertItemW(TVIF_TEXT | TVIF_PARAM, GS(Item->second.Section()), 0, 0, 0, 0, Item->second.Section(), TVI_ROOT, TVI_LAST); + } - wstring str = GS(Item->second.Title()); - std::wstring::size_type pos = str.find(L"&"); - while (pos != std::wstring::npos) - { - str.replace(pos, 1, L""); - pos = str.find(L"&", pos); - } - pos = str.find(L"..."); - while (pos != std::wstring::npos) - { - str.replace(pos, 3, L""); - pos = str.find(L"...", pos); - } + wstring str = GS(Item->second.Title()); + std::wstring::size_type pos = str.find(L"&"); + while (pos != std::wstring::npos) + { + str.replace(pos, 1, L""); + pos = str.find(L"&", pos); + } + pos = str.find(L"..."); + while (pos != std::wstring::npos) + { + str.replace(pos, 3, L""); + pos = str.find(L"...", pos); + } - HTREEITEM hItem = m_MenuItems.InsertItemW(TVIF_TEXT | TVIF_PARAM, str.c_str(), 0, 0, 0, 0, (DWORD_PTR)&Item->second, hParent, TVI_LAST); + HTREEITEM hItem = m_MenuItems.InsertItemW(TVIF_TEXT | TVIF_PARAM, str.c_str(), 0, 0, 0, 0, (DWORD_PTR)&Item->second, hParent, TVI_LAST); - const SHORTCUT_KEY_LIST & ShortCutList = Item->second.GetAccelItems(); - for (SHORTCUT_KEY_LIST::const_iterator ShortCut_item = ShortCutList.begin(); ShortCut_item != ShortCutList.end(); ShortCut_item++) - { - if (!ShortCut_item->Inactive() && !ShortCut_item->UserAdded()) - { - continue; - } - m_MenuItems.SetItemState(hItem, TVIS_BOLD, TVIS_BOLD); - m_MenuItems.SetItemState(hParent, TVIS_BOLD, TVIS_BOLD); - break; - } - } + const SHORTCUT_KEY_LIST & ShortCutList = Item->second.GetAccelItems(); + for (SHORTCUT_KEY_LIST::const_iterator ShortCut_item = ShortCutList.begin(); ShortCut_item != ShortCutList.end(); ShortCut_item++) + { + if (!ShortCut_item->Inactive() && !ShortCut_item->UserAdded()) + { + continue; + } + m_MenuItems.SetItemState(hItem, TVIS_BOLD, TVIS_BOLD); + m_MenuItems.SetItemState(hParent, TVIS_BOLD, TVIS_BOLD); + break; + } + } } void COptionsShortCutsPage::OnRemoveClicked(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { - HTREEITEM hSelectedItem = m_MenuItems.GetSelectedItem(); - if (hSelectedItem == NULL) - { - g_Notify->DisplayError(GS(MSG_NO_SEL_SHORTCUT)); - return; - } - HTREEITEM hParent = m_MenuItems.GetParentItem(hSelectedItem); - if (hParent == NULL) - { - g_Notify->DisplayError(GS(MSG_NO_SEL_SHORTCUT)); - return; - } + HTREEITEM hSelectedItem = m_MenuItems.GetSelectedItem(); + if (hSelectedItem == NULL) + { + g_Notify->DisplayError(GS(MSG_NO_SEL_SHORTCUT)); + return; + } + HTREEITEM hParent = m_MenuItems.GetParentItem(hSelectedItem); + if (hParent == NULL) + { + g_Notify->DisplayError(GS(MSG_NO_SEL_SHORTCUT)); + return; + } - CShortCutItem * ShortCut = (CShortCutItem *)m_MenuItems.GetItemData(hSelectedItem); + CShortCutItem * ShortCut = (CShortCutItem *)m_MenuItems.GetItemData(hSelectedItem); - //Make sure an item is selected - int index = m_CurrentKeys.GetCurSel(); - if (index < 0) - { - g_Notify->DisplayError(GS(MSG_NO_SEL_SHORTCUT)); - return; - } - ShortCut->RemoveItem((CMenuShortCutKey *)m_CurrentKeys.GetItemData(index)); - m_MenuItems.SetItemState(hSelectedItem, TVIS_BOLD, TVIS_BOLD); - m_MenuItems.SetItemState(hParent, TVIS_BOLD, TVIS_BOLD); - m_EnableReset = true; + //Make sure an item is selected + int index = m_CurrentKeys.GetCurSel(); + if (index < 0) + { + g_Notify->DisplayError(GS(MSG_NO_SEL_SHORTCUT)); + return; + } + ShortCut->RemoveItem((CMenuShortCutKey *)m_CurrentKeys.GetItemData(index)); + m_MenuItems.SetItemState(hSelectedItem, TVIS_BOLD, TVIS_BOLD); + m_MenuItems.SetItemState(hParent, TVIS_BOLD, TVIS_BOLD); + m_EnableReset = true; - RefreshShortCutOptions(hSelectedItem); - SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); + RefreshShortCutOptions(hSelectedItem); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } void COptionsShortCutsPage::OnDetectKeyClicked(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { - CloseHandle(CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)stInputGetKeys, this, 0, NULL)); + CloseHandle(CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)stInputGetKeys, this, 0, NULL)); } void COptionsShortCutsPage::OnAssignClicked(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { - //Get the virtual key info - int index = m_VirtualKeyList.GetCurSel(); - if (index < 0) - { - g_Notify->DisplayError(GS(MSG_NO_SHORTCUT_SEL)); - return; - } + //Get the virtual key info + int index = m_VirtualKeyList.GetCurSel(); + if (index < 0) + { + g_Notify->DisplayError(GS(MSG_NO_SHORTCUT_SEL)); + return; + } - WORD key = (WORD)SendDlgItemMessage(IDC_VIRTUALKEY, CB_GETITEMDATA, index, 0); - bool bCtrl = (SendDlgItemMessage(IDC_CTL, BM_GETCHECK, 0, 0) == BST_CHECKED); - bool bAlt = (SendDlgItemMessage(IDC_ALT, BM_GETCHECK, 0, 0) == BST_CHECKED); - bool bShift = (SendDlgItemMessage(IDC_SHIFT, BM_GETCHECK, 0, 0) == BST_CHECKED); + WORD key = (WORD)SendDlgItemMessage(IDC_VIRTUALKEY, CB_GETITEMDATA, index, 0); + bool bCtrl = (SendDlgItemMessage(IDC_CTL, BM_GETCHECK, 0, 0) == BST_CHECKED); + bool bAlt = (SendDlgItemMessage(IDC_ALT, BM_GETCHECK, 0, 0) == BST_CHECKED); + bool bShift = (SendDlgItemMessage(IDC_SHIFT, BM_GETCHECK, 0, 0) == BST_CHECKED); - ACCESS_MODE AccessLevel = (ACCESS_MODE)m_CpuState.GetItemData(m_CpuState.GetCurSel()); + ACCESS_MODE AccessLevel = (ACCESS_MODE)m_CpuState.GetItemData(m_CpuState.GetCurSel()); - HTREEITEM hSelectedItem = m_MenuItems.GetSelectedItem(); - if (hSelectedItem == NULL) - { - g_Notify->DisplayError(GS(MSG_NO_MENUITEM_SEL)); - return; - } - HTREEITEM hParent = m_MenuItems.GetParentItem(hSelectedItem); - if (hParent == NULL) - { - g_Notify->DisplayError(GS(MSG_NO_MENUITEM_SEL)); - return; - } + HTREEITEM hSelectedItem = m_MenuItems.GetSelectedItem(); + if (hSelectedItem == NULL) + { + g_Notify->DisplayError(GS(MSG_NO_MENUITEM_SEL)); + return; + } + HTREEITEM hParent = m_MenuItems.GetParentItem(hSelectedItem); + if (hParent == NULL) + { + g_Notify->DisplayError(GS(MSG_NO_MENUITEM_SEL)); + return; + } - CShortCutItem * ShortCut = (CShortCutItem *)m_MenuItems.GetItemData(hSelectedItem); + CShortCutItem * ShortCut = (CShortCutItem *)m_MenuItems.GetItemData(hSelectedItem); - LanguageStringID strid = m_ShortCuts.GetMenuItemName(key, bCtrl, bAlt, bShift, AccessLevel); - if (strid != EMPTY_STRING) - { - g_Notify->DisplayError(GS(MSG_MENUITEM_ASSIGNED)); - return; - } - ShortCut->AddShortCut(key, bCtrl, bAlt, bShift, AccessLevel, true, false); - m_MenuItems.SetItemState(hSelectedItem, TVIS_BOLD, TVIS_BOLD); - m_MenuItems.SetItemState(hParent, TVIS_BOLD, TVIS_BOLD); - m_EnableReset = true; + LanguageStringID strid = m_ShortCuts.GetMenuItemName(key, bCtrl, bAlt, bShift, AccessLevel); + if (strid != EMPTY_STRING) + { + g_Notify->DisplayError(GS(MSG_MENUITEM_ASSIGNED)); + return; + } + ShortCut->AddShortCut(key, bCtrl, bAlt, bShift, AccessLevel, true, false); + m_MenuItems.SetItemState(hSelectedItem, TVIS_BOLD, TVIS_BOLD); + m_MenuItems.SetItemState(hParent, TVIS_BOLD, TVIS_BOLD); + m_EnableReset = true; - RefreshShortCutOptions(hSelectedItem); - SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); + RefreshShortCutOptions(hSelectedItem); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); } void COptionsShortCutsPage::OnShortCutChanged(UINT /*Code*/, int /*id*/, HWND /*ctl*/) { - //Get the virtual key info - int index = m_VirtualKeyList.GetCurSel(); - if (index < 0) { return; } - WORD key = (WORD)m_VirtualKeyList.GetItemData(index); - bool bCtrl = (SendDlgItemMessage(IDC_CTL, BM_GETCHECK, 0, 0) == BST_CHECKED); - bool bAlt = (SendDlgItemMessage(IDC_ALT, BM_GETCHECK, 0, 0) == BST_CHECKED); - bool bShift = (SendDlgItemMessage(IDC_SHIFT, BM_GETCHECK, 0, 0) == BST_CHECKED); + //Get the virtual key info + int index = m_VirtualKeyList.GetCurSel(); + if (index < 0) { return; } + WORD key = (WORD)m_VirtualKeyList.GetItemData(index); + bool bCtrl = (SendDlgItemMessage(IDC_CTL, BM_GETCHECK, 0, 0) == BST_CHECKED); + bool bAlt = (SendDlgItemMessage(IDC_ALT, BM_GETCHECK, 0, 0) == BST_CHECKED); + bool bShift = (SendDlgItemMessage(IDC_SHIFT, BM_GETCHECK, 0, 0) == BST_CHECKED); - ACCESS_MODE AccessLevel = (ACCESS_MODE)m_CpuState.GetItemData(m_CpuState.GetCurSel()); + ACCESS_MODE AccessLevel = (ACCESS_MODE)m_CpuState.GetItemData(m_CpuState.GetCurSel()); - stdstr str; - str.FromUTF16(GS(m_ShortCuts.GetMenuItemName(key, bCtrl, bAlt, bShift, AccessLevel))); - if (str.length() > 0) - { - str.resize(std::remove(str.begin(), str.end(), '&') - str.begin()); - } - else - { - str = "None"; - } - SetDlgItemText(IDC_ASSIGNED_MENU_ITEM, str.c_str()); + stdstr str; + str.FromUTF16(GS(m_ShortCuts.GetMenuItemName(key, bCtrl, bAlt, bShift, AccessLevel))); + if (str.length() > 0) + { + str.resize(std::remove(str.begin(), str.end(), '&') - str.begin()); + } + else + { + str = "None"; + } + SetDlgItemText(IDC_ASSIGNED_MENU_ITEM, str.c_str()); } LRESULT COptionsShortCutsPage::OnMenuItemChanged(LPNMHDR lpnmh) { - RefreshShortCutOptions(((LPNMTREEVIEW)lpnmh)->itemNew.hItem); - return true; + RefreshShortCutOptions(((LPNMTREEVIEW)lpnmh)->itemNew.hItem); + return true; } void COptionsShortCutsPage::RefreshShortCutOptions(HTREEITEM hItem) { - HTREEITEM hParent = m_MenuItems.GetParentItem(hItem); - if (hParent == NULL) - { - return; - } + HTREEITEM hParent = m_MenuItems.GetParentItem(hItem); + if (hParent == NULL) + { + return; + } - ACCESS_MODE AccessLevel = (ACCESS_MODE)m_CpuState.GetItemData(m_CpuState.GetCurSel()); - CShortCutItem * ShortCut = (CShortCutItem *)m_MenuItems.GetItemData(hItem); + ACCESS_MODE AccessLevel = (ACCESS_MODE)m_CpuState.GetItemData(m_CpuState.GetCurSel()); + CShortCutItem * ShortCut = (CShortCutItem *)m_MenuItems.GetItemData(hItem); - m_CurrentKeys.ResetContent(); + m_CurrentKeys.ResetContent(); - const SHORTCUT_KEY_LIST & ShortCutList = ShortCut->GetAccelItems(); - for (SHORTCUT_KEY_LIST::const_iterator ShortCut_item = ShortCutList.begin(); ShortCut_item != ShortCutList.end(); ShortCut_item++) - { - if (ShortCut_item->Inactive()) - { - continue; - } + const SHORTCUT_KEY_LIST & ShortCutList = ShortCut->GetAccelItems(); + for (SHORTCUT_KEY_LIST::const_iterator ShortCut_item = ShortCutList.begin(); ShortCut_item != ShortCutList.end(); ShortCut_item++) + { + if (ShortCut_item->Inactive()) + { + continue; + } - ACCESS_MODE ItemMode = ShortCut_item->AccessMode(); - if ((ItemMode & AccessLevel) != AccessLevel) - { - continue; - } - stdstr Name = ShortCut_item->Name(); - m_CurrentKeys.SetItemData(m_CurrentKeys.AddString(Name.c_str()), (DWORD_PTR)&*ShortCut_item); - } + ACCESS_MODE ItemMode = ShortCut_item->AccessMode(); + if ((ItemMode & AccessLevel) != AccessLevel) + { + continue; + } + stdstr Name = ShortCut_item->Name(); + m_CurrentKeys.SetItemData(m_CurrentKeys.AddString(Name.c_str()), (DWORD_PTR)&*ShortCut_item); + } } BOOL CALLBACK KeyPromptDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM /*lParam*/) { - switch (uMsg) - { - case WM_INITDIALOG: - break; - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDCANCEL: - SetForegroundWindow(GetParent(hDlg)); - DestroyWindow(hDlg); - break; - } - break; - default: - return FALSE; - } - return TRUE; + switch (uMsg) + { + case WM_INITDIALOG: + break; + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDCANCEL: + SetForegroundWindow(GetParent(hDlg)); + DestroyWindow(hDlg); + break; + } + break; + default: + return FALSE; + } + return TRUE; } void COptionsShortCutsPage::InputGetKeys(void) { - HWND hKeyDlg = CreateDialogParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Key_Prompt), m_hWnd, (DLGPROC)KeyPromptDlgProc, (LPARAM)::GetDlgItem(m_hWnd, IDC_VIRTUALKEY)); - ::EnableWindow(GetParent(), false); - MSG msg; + HWND hKeyDlg = CreateDialogParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Key_Prompt), m_hWnd, (DLGPROC)KeyPromptDlgProc, (LPARAM)::GetDlgItem(m_hWnd, IDC_VIRTUALKEY)); + ::EnableWindow(GetParent(), false); + MSG msg; - for (bool fDone = false; !fDone; MsgWaitForMultipleObjects(0, NULL, false, 45, QS_ALLINPUT)) { - while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { - if (msg.message == WM_QUIT) { - fDone = true; - ::PostMessage(NULL, WM_QUIT, 0, 0); - break; - } - if (msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN) { - int nVirtKey = (int)msg.wParam; - if (nVirtKey == VK_SHIFT) { continue; } - if (nVirtKey == VK_CONTROL) { continue; } - if (nVirtKey == VK_MENU) { continue; } - SendDlgItemMessage(IDC_VIRTUALKEY, CB_SETCURSEL, (WPARAM)-1, 0); - for (int count = 0; count < SendDlgItemMessage(IDC_VIRTUALKEY, CB_GETCOUNT, 0, 0); count++) { - int Data = (int)SendDlgItemMessage(IDC_VIRTUALKEY, CB_GETITEMDATA, count, 0); - if (Data != nVirtKey) { continue; } - SendDlgItemMessage(IDC_VIRTUALKEY, CB_SETCURSEL, count, 0); - SendDlgItemMessage(IDC_CTL, BM_SETCHECK, (GetKeyState(VK_CONTROL) & 0x80) != 0 ? BST_CHECKED : BST_UNCHECKED, 0); - SendDlgItemMessage(IDC_ALT, BM_SETCHECK, (GetKeyState(VK_MENU) & 0x80) != 0 ? BST_CHECKED : BST_UNCHECKED, 0); - SendDlgItemMessage(IDC_SHIFT, BM_SETCHECK, (GetKeyState(VK_SHIFT) & 0x80) != 0 ? BST_CHECKED : BST_UNCHECKED, 0); - SendMessage(WM_COMMAND, MAKELPARAM(IDC_VIRTUALKEY, LBN_SELCHANGE), (LPARAM)::GetDlgItem(m_hWnd, IDC_VIRTUALKEY)); - SetForegroundWindow(GetParent()); - ::DestroyWindow(hKeyDlg); - } - continue; - } - if (!::IsDialogMessage(hKeyDlg, &msg)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } + for (bool fDone = false; !fDone; MsgWaitForMultipleObjects(0, NULL, false, 45, QS_ALLINPUT)) { + while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { + if (msg.message == WM_QUIT) { + fDone = true; + ::PostMessage(NULL, WM_QUIT, 0, 0); + break; + } + if (msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN) { + int nVirtKey = (int)msg.wParam; + if (nVirtKey == VK_SHIFT) { continue; } + if (nVirtKey == VK_CONTROL) { continue; } + if (nVirtKey == VK_MENU) { continue; } + SendDlgItemMessage(IDC_VIRTUALKEY, CB_SETCURSEL, (WPARAM)-1, 0); + for (int count = 0; count < SendDlgItemMessage(IDC_VIRTUALKEY, CB_GETCOUNT, 0, 0); count++) { + int Data = (int)SendDlgItemMessage(IDC_VIRTUALKEY, CB_GETITEMDATA, count, 0); + if (Data != nVirtKey) { continue; } + SendDlgItemMessage(IDC_VIRTUALKEY, CB_SETCURSEL, count, 0); + SendDlgItemMessage(IDC_CTL, BM_SETCHECK, (GetKeyState(VK_CONTROL) & 0x80) != 0 ? BST_CHECKED : BST_UNCHECKED, 0); + SendDlgItemMessage(IDC_ALT, BM_SETCHECK, (GetKeyState(VK_MENU) & 0x80) != 0 ? BST_CHECKED : BST_UNCHECKED, 0); + SendDlgItemMessage(IDC_SHIFT, BM_SETCHECK, (GetKeyState(VK_SHIFT) & 0x80) != 0 ? BST_CHECKED : BST_UNCHECKED, 0); + SendMessage(WM_COMMAND, MAKELPARAM(IDC_VIRTUALKEY, LBN_SELCHANGE), (LPARAM)::GetDlgItem(m_hWnd, IDC_VIRTUALKEY)); + SetForegroundWindow(GetParent()); + ::DestroyWindow(hKeyDlg); + } + continue; + } + if (!::IsDialogMessage(hKeyDlg, &msg)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } - if (!::IsWindow(hKeyDlg)) { fDone = true; } - } - ::SetFocus(GetParent()); - ::EnableWindow(GetParent(), true); + if (!::IsWindow(hKeyDlg)) { fDone = true; } + } + ::SetFocus(GetParent()); + ::EnableWindow(GetParent(), true); } void COptionsShortCutsPage::HidePage() { - ShowWindow(SW_HIDE); + ShowWindow(SW_HIDE); } void COptionsShortCutsPage::ShowPage() { - ShowWindow(SW_SHOW); + ShowWindow(SW_SHOW); } void COptionsShortCutsPage::ApplySettings(bool /*UpdateScreen*/) { - m_ShortCuts.Save(); - g_Settings->SaveBool(Info_ShortCutsChanged, true); + m_ShortCuts.Save(); + g_Settings->SaveBool(Info_ShortCutsChanged, true); } bool COptionsShortCutsPage::EnableReset(void) { - return m_EnableReset; + return m_EnableReset; } void COptionsShortCutsPage::ResetPage() { - m_EnableReset = false; - m_ShortCuts.Load(true); - OnCpuStateChanged(LBN_SELCHANGE, IDC_C_CPU_STATE, GetDlgItem(IDC_C_CPU_STATE)); - SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); - m_CurrentKeys.ResetContent(); - CSettingsPageImpl::ResetPage(); -} + m_EnableReset = false; + m_ShortCuts.Load(true); + OnCpuStateChanged(LBN_SELCHANGE, IDC_C_CPU_STATE, GetDlgItem(IDC_C_CPU_STATE)); + SendMessage(GetParent(), PSM_CHANGED, (WPARAM)m_hWnd, 0); + m_CurrentKeys.ResetContent(); + CSettingsPageImpl::ResetPage(); +} \ No newline at end of file From 9d487bd969a7d245c8872349d6b6625a5ea8c2ec Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 12 Nov 2015 21:52:34 -0500 Subject: [PATCH 153/213] DllConfig(hParent) should be a pointer, not a uint32_t. --- Source/Project64/Plugins/Plugin Base.cpp | 2 +- Source/Project64/Plugins/Plugin Base.h | 2 +- Source/Project64/Plugins/Plugin Class.cpp | 2 +- Source/Project64/Plugins/Plugin Class.h | 2 +- .../User Interface/Main Menu Class.cpp | 20 +++++++++++++++---- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Source/Project64/Plugins/Plugin Base.cpp b/Source/Project64/Plugins/Plugin Base.cpp index 3f3f8df09..2ef931177 100644 --- a/Source/Project64/Plugins/Plugin Base.cpp +++ b/Source/Project64/Plugins/Plugin Base.cpp @@ -71,7 +71,7 @@ bool CPlugin::Load (const char * FileName) RomOpen = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "RomOpen" ); RomClosed = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "RomClosed" ); PluginOpened = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "PluginLoaded" ); - DllConfig = (void (__cdecl *)(uint32_t)) GetProcAddress( (HMODULE)m_hDll, "DllConfig" ); + DllConfig = (void (__cdecl *)(void *)) GetProcAddress( (HMODULE)m_hDll, "DllConfig" ); DllAbout = (void (__cdecl *)(void *)) GetProcAddress( (HMODULE)m_hDll, "DllAbout" ); SetSettingInfo3 = (void (__cdecl *)(PLUGIN_SETTINGS3 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo3" ); diff --git a/Source/Project64/Plugins/Plugin Base.h b/Source/Project64/Plugins/Plugin Base.h index eaf5dcd01..4312dc8aa 100644 --- a/Source/Project64/Plugins/Plugin Base.h +++ b/Source/Project64/Plugins/Plugin Base.h @@ -30,7 +30,7 @@ public: void Close(); void(__cdecl *DllAbout) (void * hWnd); - void(__cdecl *DllConfig) (uint32_t hParent); + void(__cdecl *DllConfig) (void * hParent); static bool ValidPluginVersion ( PLUGIN_INFO & PluginInfo ); diff --git a/Source/Project64/Plugins/Plugin Class.cpp b/Source/Project64/Plugins/Plugin Class.cpp index e614eed90..820e0cbe8 100644 --- a/Source/Project64/Plugins/Plugin Class.cpp +++ b/Source/Project64/Plugins/Plugin Class.cpp @@ -318,7 +318,7 @@ bool CPlugins::Reset(CN64System * System) return true; } -void CPlugins::ConfigPlugin(uint32_t hParent, PLUGIN_TYPE Type) +void CPlugins::ConfigPlugin(void* hParent, PLUGIN_TYPE Type) { switch (Type) { diff --git a/Source/Project64/Plugins/Plugin Class.h b/Source/Project64/Plugins/Plugin Class.h index 0ce075a91..28a608b9a 100644 --- a/Source/Project64/Plugins/Plugin Class.h +++ b/Source/Project64/Plugins/Plugin Class.h @@ -104,7 +104,7 @@ public: void RomOpened(void); void RomClosed(void); void SetRenderWindows(RenderWindow * MainWindow, RenderWindow * SyncWindow); - void ConfigPlugin(uint32_t hParent, PLUGIN_TYPE Type); + void ConfigPlugin(void* hParent, PLUGIN_TYPE Type); bool CopyPlugins(const stdstr & DstDir) const; void CreatePlugins(void); bool Reset(CN64System * System); diff --git a/Source/Project64/User Interface/Main Menu Class.cpp b/Source/Project64/User Interface/Main Menu Class.cpp index bfdf6baa4..cae92fe2c 100644 --- a/Source/Project64/User Interface/Main Menu Class.cpp +++ b/Source/Project64/User Interface/Main Menu Class.cpp @@ -323,10 +323,22 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI m_Gui->MakeWindowOnTop(g_Settings->LoadBool(GameRunning_CPU_Running)); } break; - case ID_OPTIONS_CONFIG_RSP: WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_CONFIG_RSP"); g_Plugins->ConfigPlugin((DWORD)hWnd, PLUGIN_TYPE_RSP); break; - case ID_OPTIONS_CONFIG_GFX: WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_CONFIG_GFX"); g_Plugins->ConfigPlugin((DWORD)hWnd, PLUGIN_TYPE_GFX); break; - case ID_OPTIONS_CONFIG_AUDIO:WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_CONFIG_AUDIO"); g_Plugins->ConfigPlugin((DWORD)hWnd, PLUGIN_TYPE_AUDIO); break; - case ID_OPTIONS_CONFIG_CONT: WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_CONFIG_CONT"); g_Plugins->ConfigPlugin((DWORD)hWnd, PLUGIN_TYPE_CONTROLLER); break; + case ID_OPTIONS_CONFIG_RSP: + WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_CONFIG_RSP"); + g_Plugins->ConfigPlugin(hWnd, PLUGIN_TYPE_RSP); + break; + case ID_OPTIONS_CONFIG_GFX: + WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_CONFIG_GFX"); + g_Plugins->ConfigPlugin(hWnd, PLUGIN_TYPE_GFX); + break; + case ID_OPTIONS_CONFIG_AUDIO: + WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_CONFIG_AUDIO"); + g_Plugins->ConfigPlugin(hWnd, PLUGIN_TYPE_AUDIO); + break; + case ID_OPTIONS_CONFIG_CONT: + WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_CONFIG_CONT"); + g_Plugins->ConfigPlugin(hWnd, PLUGIN_TYPE_CONTROLLER); + break; case ID_OPTIONS_CPU_USAGE: WriteTrace(TraceDebug, __FUNCTION__ ": ID_OPTIONS_CPU_USAGE"); if (g_Settings->LoadBool(UserInterface_ShowCPUPer)) From 815418c4e9b49e8db20ad44f092af2640567e8a3 Mon Sep 17 00:00:00 2001 From: toehead2001 Date: Thu, 12 Nov 2015 21:21:29 -0700 Subject: [PATCH 154/213] Don't hard code Platform Toolset --- PropertySheets/Platform.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PropertySheets/Platform.props b/PropertySheets/Platform.props index add82bd1a..8e043f9db 100644 --- a/PropertySheets/Platform.props +++ b/PropertySheets/Platform.props @@ -2,7 +2,7 @@ - v140_xp + $(DefaultPlatformToolset)_xp From e87c8de1078a5990bcc31b817208ddb38db568ad Mon Sep 17 00:00:00 2001 From: zilmar Date: Fri, 13 Nov 2015 17:34:57 +1100 Subject: [PATCH 155/213] [Project64] Move Logging.cpp to User Interface/LoggingUI.cpp --- Source/Project64/Logging.cpp | 919 ----------------- .../Interpreter/Interpreter Ops 32.cpp | 307 +++--- .../Interpreter/Interpreter Ops.cpp | 757 +++++++------- Source/Project64/N64 System/Mips/Pif Ram.cpp | 941 +++++++++--------- .../N64 System/Mips/Register Class.cpp | 373 +++---- Source/Project64/N64 System/N64 Class.cpp | 2 +- Source/Project64/Project64.vcxproj | 4 +- Source/Project64/Project64.vcxproj.filters | 10 +- Source/Project64/User Interface/LoggingUI.cpp | 920 +++++++++++++++++ .../{Logging.h => User Interface/LoggingUI.h} | 0 Source/Project64/stdafx.h | 1 - 11 files changed, 2118 insertions(+), 2116 deletions(-) delete mode 100644 Source/Project64/Logging.cpp create mode 100644 Source/Project64/User Interface/LoggingUI.cpp rename Source/Project64/{Logging.h => User Interface/LoggingUI.h} (100%) diff --git a/Source/Project64/Logging.cpp b/Source/Project64/Logging.cpp deleted file mode 100644 index cb4a5ac33..000000000 --- a/Source/Project64/Logging.cpp +++ /dev/null @@ -1,919 +0,0 @@ -/**************************************************************************** -* * -* Project64 - A Nintendo 64 emulator. * -* http://www.pj64-emu.com/ * -* Copyright (C) 2012 Project64. All rights reserved. * -* * -* License: * -* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * -* * -****************************************************************************/ -#include "stdafx.h" - -#include - -void LoadLogSetting (HKEY hKey,char * String, bool * Value); -void SaveLogOptions (void); - -LRESULT CALLBACK LogGeneralProc ( HWND, UINT, WPARAM, LPARAM ); -LRESULT CALLBACK LogPifProc ( HWND, UINT, WPARAM, LPARAM ); -LRESULT CALLBACK LogRegProc ( HWND, UINT, WPARAM, LPARAM ); - -static HANDLE g_hLogFile = NULL; -LOG_OPTIONS g_LogOptions, TempOptions; - -void EnterLogOptions(HWND hwndOwner) -{ - PROPSHEETPAGE psp[3]; - PROPSHEETHEADER psh; - - psp[0].dwSize = sizeof(PROPSHEETPAGE); - psp[0].dwFlags = PSP_USETITLE; - psp[0].hInstance = GetModuleHandle(NULL); - psp[0].pszTemplate = MAKEINTRESOURCE(IDD_Logging_Registers); - psp[0].pfnDlgProc = (DLGPROC)LogRegProc; - psp[0].pszTitle = "Registers"; - psp[0].lParam = 0; - psp[0].pfnCallback = NULL; - - psp[1].dwSize = sizeof(PROPSHEETPAGE); - psp[1].dwFlags = PSP_USETITLE; - psp[1].hInstance = GetModuleHandle(NULL); - psp[1].pszTemplate = MAKEINTRESOURCE(IDD_Logging_PifRam); - psp[1].pfnDlgProc = (DLGPROC)LogPifProc; - psp[1].pszTitle = "Pif Ram"; - psp[1].lParam = 0; - psp[1].pfnCallback = NULL; - - psp[2].dwSize = sizeof(PROPSHEETPAGE); - psp[2].dwFlags = PSP_USETITLE; - psp[2].hInstance = GetModuleHandle(NULL); - psp[2].pszTemplate = MAKEINTRESOURCE(IDD_Logging_General); - psp[2].pfnDlgProc = (DLGPROC)LogGeneralProc; - psp[2].pszTitle = "General"; - psp[2].lParam = 0; - psp[2].pfnCallback = NULL; - - psh.dwSize = sizeof(PROPSHEETHEADER); - psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW; - psh.hwndParent = hwndOwner; - psh.hInstance = GetModuleHandle(NULL); - psh.pszCaption = (LPSTR) "Log Options"; - psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE); - psh.nStartPage = 0; - psh.ppsp = (LPCPROPSHEETPAGE) &psp; - psh.pfnCallback = NULL; - - LoadLogOptions(&TempOptions,TRUE); -#if defined(WINDOWS_UI) - PropertySheet(&psh); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); -#endif - SaveLogOptions(); - LoadLogOptions(&g_LogOptions, FALSE); - return; -} - -void LoadLogOptions (LOG_OPTIONS * LogOptions, bool AlwaysFill) -{ - int32_t lResult; - HKEY hKeyResults = 0; - char String[200]; - - sprintf(String,"Software\\N64 Emulation\\%s\\Logging",g_Settings->LoadStringVal(Setting_ApplicationName).c_str()); - lResult = RegOpenKeyEx( HKEY_CURRENT_USER,String,0,KEY_ALL_ACCESS, - &hKeyResults); - - if (lResult == ERROR_SUCCESS) - { - //LoadLogSetting(hKeyResults,"Generate Log File",&LogOptions->GenerateLog); - if (LogOptions->GenerateLog || AlwaysFill) - { - LoadLogSetting(hKeyResults,"Log RDRAM",&LogOptions->LogRDRamRegisters); - LoadLogSetting(hKeyResults,"Log SP",&LogOptions->LogSPRegisters); - LoadLogSetting(hKeyResults,"Log DP Command",&LogOptions->LogDPCRegisters); - LoadLogSetting(hKeyResults,"Log DP Span",&LogOptions->LogDPSRegisters); - LoadLogSetting(hKeyResults,"Log MIPS Interface (MI)",&LogOptions->LogMIPSInterface); - LoadLogSetting(hKeyResults,"Log Video Interface (VI)",&LogOptions->LogVideoInterface); - LoadLogSetting(hKeyResults,"Log Audio Interface (AI)",&LogOptions->LogAudioInterface); - LoadLogSetting(hKeyResults,"Log Peripheral Interface (PI)",&LogOptions->LogPerInterface); - LoadLogSetting(hKeyResults,"Log RDRAM Interface (RI)",&LogOptions->LogRDRAMInterface); - LoadLogSetting(hKeyResults,"Log Serial Interface (SI)",&LogOptions->LogSerialInterface); - LoadLogSetting(hKeyResults,"Log PifRam DMA Operations",&LogOptions->LogPRDMAOperations); - LoadLogSetting(hKeyResults,"Log PifRam Direct Memory Loads",&LogOptions->LogPRDirectMemLoads); - LoadLogSetting(hKeyResults,"Log PifRam DMA Memory Loads",&LogOptions->LogPRDMAMemLoads); - LoadLogSetting(hKeyResults,"Log PifRam Direct Memory Stores",&LogOptions->LogPRDirectMemStores); - LoadLogSetting(hKeyResults,"Log PifRam DMA Memory Stores",&LogOptions->LogPRDMAMemStores); - LoadLogSetting(hKeyResults,"Log Controller Pak",&LogOptions->LogControllerPak); - LoadLogSetting(hKeyResults,"Log CP0 changes",&LogOptions->LogCP0changes); - LoadLogSetting(hKeyResults,"Log CP0 reads",&LogOptions->LogCP0reads); - LoadLogSetting(hKeyResults,"Log Exceptions",&LogOptions->LogExceptions); - LoadLogSetting(hKeyResults,"No Interrupts",&LogOptions->NoInterrupts); - LoadLogSetting(hKeyResults,"Log TLB",&LogOptions->LogTLB); - LoadLogSetting(hKeyResults,"Log Cache Operations",&LogOptions->LogCache); - LoadLogSetting(hKeyResults,"Log Rom Header",&LogOptions->LogRomHeader); - LoadLogSetting(hKeyResults,"Log Unknown access",&LogOptions->LogUnknown); - return; - } - } - - LogOptions->GenerateLog = FALSE; - LogOptions->LogRDRamRegisters = FALSE; - LogOptions->LogSPRegisters = FALSE; - LogOptions->LogDPCRegisters = FALSE; - LogOptions->LogDPSRegisters = FALSE; - LogOptions->LogMIPSInterface = FALSE; - LogOptions->LogVideoInterface = FALSE; - LogOptions->LogAudioInterface = FALSE; - LogOptions->LogPerInterface = FALSE; - LogOptions->LogRDRAMInterface = FALSE; - LogOptions->LogSerialInterface = FALSE; - - LogOptions->LogPRDMAOperations = FALSE; - LogOptions->LogPRDirectMemLoads = FALSE; - LogOptions->LogPRDMAMemLoads = FALSE; - LogOptions->LogPRDirectMemStores = FALSE; - LogOptions->LogPRDMAMemStores = FALSE; - LogOptions->LogControllerPak = FALSE; - - LogOptions->LogCP0changes = FALSE; - LogOptions->LogCP0reads = FALSE; - LogOptions->LogCache = FALSE; - LogOptions->LogExceptions = FALSE; - LogOptions->NoInterrupts = FALSE; - LogOptions->LogTLB = FALSE; - LogOptions->LogRomHeader = FALSE; - LogOptions->LogUnknown = FALSE; -} - -void LoadLogSetting (HKEY hKey,char * String, bool * Value) -{ - DWORD Type, dwResult, Bytes = 4; - int32_t lResult; - - lResult = RegQueryValueEx(hKey,String,0,&Type,(LPBYTE)(&dwResult),&Bytes); - if (Type == REG_DWORD && lResult == ERROR_SUCCESS) - { - *Value = dwResult != 0; - } - else - { - *Value = FALSE; - } -} - -LRESULT CALLBACK LogGeneralProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam) -{ - switch (uMsg) - { - case WM_INITDIALOG: - if (TempOptions.LogCP0changes) { CheckDlgButton(hDlg,IDC_CP0_WRITE,BST_CHECKED); } - if (TempOptions.LogCP0reads) { CheckDlgButton(hDlg,IDC_CP0_READ,BST_CHECKED); } - if (TempOptions.LogCache) { CheckDlgButton(hDlg,IDC_CACHE,BST_CHECKED); } - if (TempOptions.LogExceptions) { CheckDlgButton(hDlg,IDC_EXCEPTIONS,BST_CHECKED); } - if (TempOptions.NoInterrupts) { CheckDlgButton(hDlg,IDC_INTERRUPTS,BST_CHECKED); } - if (TempOptions.LogTLB) { CheckDlgButton(hDlg,IDC_TLB,BST_CHECKED); } - if (TempOptions.LogRomHeader) { CheckDlgButton(hDlg,IDC_ROM_HEADER,BST_CHECKED); } - if (TempOptions.LogUnknown) { CheckDlgButton(hDlg,IDC_UNKOWN,BST_CHECKED); } - break; - case WM_NOTIFY: - if (((NMHDR FAR *) lParam)->code != PSN_APPLY) { break; } - TempOptions.LogCP0changes = IsDlgButtonChecked(hDlg,IDC_CP0_WRITE) == BST_CHECKED?TRUE:FALSE; - TempOptions.LogCP0reads = IsDlgButtonChecked(hDlg,IDC_CP0_READ) == BST_CHECKED?TRUE:FALSE; - TempOptions.LogCache = IsDlgButtonChecked(hDlg,IDC_CACHE) == BST_CHECKED?TRUE:FALSE; - TempOptions.LogExceptions = IsDlgButtonChecked(hDlg,IDC_EXCEPTIONS) == BST_CHECKED?TRUE:FALSE; - TempOptions.NoInterrupts = IsDlgButtonChecked(hDlg,IDC_INTERRUPTS) == BST_CHECKED?TRUE:FALSE; - TempOptions.LogTLB = IsDlgButtonChecked(hDlg,IDC_TLB) == BST_CHECKED?TRUE:FALSE; - TempOptions.LogRomHeader = IsDlgButtonChecked(hDlg,IDC_ROM_HEADER) == BST_CHECKED?TRUE:FALSE; - TempOptions.LogUnknown = IsDlgButtonChecked(hDlg,IDC_UNKOWN) == BST_CHECKED?TRUE:FALSE; - break; - default: - return FALSE; - } - return TRUE; -} - -void Log_LW (uint32_t PC, uint32_t VAddr) -{ - if (!g_LogOptions.GenerateLog) - { - return; - } - - if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 ) - { - uint32_t PAddr; - if (!g_TransVaddr->TranslateVaddr(VAddr,PAddr)) - { - if (g_LogOptions.LogUnknown) - { - LogMessage("%08X: read from unknown ??? (%08X)",PC,VAddr); - } - return; - } - VAddr = PAddr + 0xA0000000; - } - - uint32_t Value; - if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize())) - { - return; - } - if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) - { - if (!g_LogOptions.LogRDRamRegisters) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - - switch (VAddr) - { - case 0xA3F00000: LogMessage("%08X: read from RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG (%08X)",PC, Value); return; - case 0xA3F00004: LogMessage("%08X: read from RDRAM_DEVICE_ID_REG (%08X)",PC, Value); return; - case 0xA3F00008: LogMessage("%08X: read from RDRAM_DELAY_REG (%08X)",PC, Value); return; - case 0xA3F0000C: LogMessage("%08X: read from RDRAM_MODE_REG (%08X)",PC, Value); return; - case 0xA3F00010: LogMessage("%08X: read from RDRAM_REF_INTERVAL_REG (%08X)",PC, Value); return; - case 0xA3F00014: LogMessage("%08X: read from RDRAM_REF_ROW_REG (%08X)",PC, Value); return; - case 0xA3F00018: LogMessage("%08X: read from RDRAM_RAS_INTERVAL_REG (%08X)",PC, Value); return; - case 0xA3F0001C: LogMessage("%08X: read from RDRAM_MIN_INTERVAL_REG (%08X)",PC, Value); return; - case 0xA3F00020: LogMessage("%08X: read from RDRAM_ADDR_SELECT_REG (%08X)",PC, Value); return; - case 0xA3F00024: LogMessage("%08X: read from RDRAM_DEVICE_MANUF_REG (%08X)",PC, Value); return; - } - } - - if ( VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC ) - { - return; - } - if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C ) - { - if (!g_LogOptions.LogSPRegisters) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - - switch (VAddr) - { - case 0xA4040000: LogMessage("%08X: read from SP_MEM_ADDR_REG (%08X)",PC, Value); break; - case 0xA4040004: LogMessage("%08X: read from SP_DRAM_ADDR_REG (%08X)",PC, Value); break; - case 0xA4040008: LogMessage("%08X: read from SP_RD_LEN_REG (%08X)",PC, Value); break; - case 0xA404000C: LogMessage("%08X: read from SP_WR_LEN_REG (%08X)",PC, Value); break; - case 0xA4040010: LogMessage("%08X: read from SP_STATUS_REG (%08X)",PC, Value); break; - case 0xA4040014: LogMessage("%08X: read from SP_DMA_FULL_REG (%08X)",PC, Value); break; - case 0xA4040018: LogMessage("%08X: read from SP_DMA_BUSY_REG (%08X)",PC, Value); break; - case 0xA404001C: LogMessage("%08X: read from SP_SEMAPHORE_REG (%08X)",PC, Value); break; - } - return; - } - if ( VAddr == 0xA4080000) - { - if (!g_LogOptions.LogSPRegisters) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - LogMessage("%08X: read from SP_PC (%08X)",PC, Value); - return; - } - if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C) - { - if (!g_LogOptions.LogDPCRegisters) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - - switch (VAddr) - { - case 0xA4100000: LogMessage("%08X: read from DPC_START_REG (%08X)",PC, Value); return; - case 0xA4100004: LogMessage("%08X: read from DPC_END_REG (%08X)",PC, Value); return; - case 0xA4100008: LogMessage("%08X: read from DPC_CURRENT_REG (%08X)",PC, Value); return; - case 0xA410000C: LogMessage("%08X: read from DPC_STATUS_REG (%08X)",PC, Value); return; - case 0xA4100010: LogMessage("%08X: read from DPC_CLOCK_REG (%08X)",PC, Value); return; - case 0xA4100014: LogMessage("%08X: read from DPC_BUFBUSY_REG (%08X)",PC, Value); return; - case 0xA4100018: LogMessage("%08X: read from DPC_PIPEBUSY_REG (%08X)",PC, Value); return; - case 0xA410001C: LogMessage("%08X: read from DPC_TMEM_REG (%08X)",PC, Value); return; - } - } - if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C) - { - if (!g_LogOptions.LogMIPSInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - - switch (VAddr) - { - case 0xA4300000: LogMessage("%08X: read from MI_INIT_MODE_REG/MI_MODE_REG (%08X)",PC, Value); return; - case 0xA4300004: LogMessage("%08X: read from MI_VERSION_REG/MI_NOOP_REG (%08X)",PC, Value); return; - case 0xA4300008: LogMessage("%08X: read from MI_INTR_REG (%08X)",PC, Value); return; - case 0xA430000C: LogMessage("%08X: read from MI_INTR_MASK_REG (%08X)",PC, Value); return; - } - } - if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034) - { - if (!g_LogOptions.LogVideoInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - - switch (VAddr) - { - case 0xA4400000: LogMessage("%08X: read from VI_STATUS_REG/VI_CONTROL_REG (%08X)",PC, Value); return; - case 0xA4400004: LogMessage("%08X: read from VI_ORIGIN_REG/VI_DRAM_ADDR_REG (%08X)",PC, Value); return; - case 0xA4400008: LogMessage("%08X: read from VI_WIDTH_REG/VI_H_WIDTH_REG (%08X)",PC, Value); return; - case 0xA440000C: LogMessage("%08X: read from VI_INTR_REG/VI_V_INTR_REG (%08X)",PC, Value); return; - case 0xA4400010: LogMessage("%08X: read from VI_CURRENT_REG/VI_V_CURRENT_LINE_REG (%08X)",PC, Value); return; - case 0xA4400014: LogMessage("%08X: read from VI_BURST_REG/VI_TIMING_REG (%08X)",PC, Value); return; - case 0xA4400018: LogMessage("%08X: read from VI_V_SYNC_REG (%08X)",PC, Value); return; - case 0xA440001C: LogMessage("%08X: read from VI_H_SYNC_REG (%08X)",PC, Value); return; - case 0xA4400020: LogMessage("%08X: read from VI_LEAP_REG/VI_H_SYNC_LEAP_REG (%08X)",PC, Value); return; - case 0xA4400024: LogMessage("%08X: read from VI_H_START_REG/VI_H_VIDEO_REG (%08X)",PC, Value); return; - case 0xA4400028: LogMessage("%08X: read from VI_V_START_REG/VI_V_VIDEO_REG (%08X)",PC, Value); return; - case 0xA440002C: LogMessage("%08X: read from VI_V_BURST_REG (%08X)",PC, Value); return; - case 0xA4400030: LogMessage("%08X: read from VI_X_SCALE_REG (%08X)",PC, Value); return; - case 0xA4400034: LogMessage("%08X: read from VI_Y_SCALE_REG (%08X)",PC, Value); return; - } - } - if (VAddr >= 0xA4500000 && VAddr <= 0xA4500014) - { - if (!g_LogOptions.LogAudioInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - - switch (VAddr) - { - case 0xA4500000: LogMessage("%08X: read from AI_DRAM_ADDR_REG (%08X)",PC, Value); return; - case 0xA4500004: LogMessage("%08X: read from AI_LEN_REG (%08X)",PC, Value); return; - case 0xA4500008: LogMessage("%08X: read from AI_CONTROL_REG (%08X)",PC, Value); return; - case 0xA450000C: LogMessage("%08X: read from AI_STATUS_REG (%08X)",PC, Value); return; - case 0xA4500010: LogMessage("%08X: read from AI_DACRATE_REG (%08X)",PC, Value); return; - case 0xA4500014: LogMessage("%08X: read from AI_BITRATE_REG (%08X)",PC, Value); return; - } - } - if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030) - { - if (!g_LogOptions.LogPerInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - - switch (VAddr) - { - case 0xA4600000: LogMessage("%08X: read from PI_DRAM_ADDR_REG (%08X)",PC, Value); return; - case 0xA4600004: LogMessage("%08X: read from PI_CART_ADDR_REG (%08X)",PC, Value); return; - case 0xA4600008: LogMessage("%08X: read from PI_RD_LEN_REG (%08X)",PC, Value); return; - case 0xA460000C: LogMessage("%08X: read from PI_WR_LEN_REG (%08X)",PC, Value); return; - case 0xA4600010: LogMessage("%08X: read from PI_STATUS_REG (%08X)",PC, Value); return; - case 0xA4600014: LogMessage("%08X: read from PI_BSD_DOM1_LAT_REG/PI_DOMAIN1_REG (%08X)",PC, Value); return; - case 0xA4600018: LogMessage("%08X: read from PI_BSD_DOM1_PWD_REG (%08X)",PC, Value); return; - case 0xA460001C: LogMessage("%08X: read from PI_BSD_DOM1_PGS_REG (%08X)",PC, Value); return; - case 0xA4600020: LogMessage("%08X: read from PI_BSD_DOM1_RLS_REG (%08X)",PC, Value); return; - case 0xA4600024: LogMessage("%08X: read from PI_BSD_DOM2_LAT_REG/PI_DOMAIN2_REG (%08X)",PC, Value); return; - case 0xA4600028: LogMessage("%08X: read from PI_BSD_DOM2_PWD_REG (%08X)",PC, Value); return; - case 0xA460002C: LogMessage("%08X: read from PI_BSD_DOM2_PGS_REG (%08X)",PC, Value); return; - case 0xA4600030: LogMessage("%08X: read from PI_BSD_DOM2_RLS_REG (%08X)",PC, Value); return; - } - } - if (VAddr >= 0xA4700000 && VAddr <= 0xA470001C) - { - if (!g_LogOptions.LogRDRAMInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - - switch (VAddr) - { - case 0xA4700000: LogMessage("%08X: read from RI_MODE_REG (%08X)",PC, Value); return; - case 0xA4700004: LogMessage("%08X: read from RI_CONFIG_REG (%08X)",PC, Value); return; - case 0xA4700008: LogMessage("%08X: read from RI_CURRENT_LOAD_REG (%08X)",PC, Value); return; - case 0xA470000C: LogMessage("%08X: read from RI_SELECT_REG (%08X)",PC, Value); return; - case 0xA4700010: LogMessage("%08X: read from RI_REFRESH_REG/RI_COUNT_REG (%08X)",PC, Value); return; - case 0xA4700014: LogMessage("%08X: read from RI_LATENCY_REG (%08X)",PC, Value); return; - case 0xA4700018: LogMessage("%08X: read from RI_RERROR_REG (%08X)",PC, Value); return; - case 0xA470001C: LogMessage("%08X: read from RI_WERROR_REG (%08X)",PC, Value); return; - } - } - if ( VAddr == 0xA4800000) - { - if (!g_LogOptions.LogSerialInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - LogMessage("%08X: read from SI_DRAM_ADDR_REG (%08X)",PC, Value); - return; - } - if ( VAddr == 0xA4800004) - { - if (!g_LogOptions.LogSerialInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - LogMessage("%08X: read from SI_PIF_ADDR_RD64B_REG (%08X)",PC, Value); - return; - } - if ( VAddr == 0xA4800010) - { - if (!g_LogOptions.LogSerialInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - LogMessage("%08X: read from SI_PIF_ADDR_WR64B_REG (%08X)",PC, Value); - return; - } - if ( VAddr == 0xA4800018) - { - if (!g_LogOptions.LogSerialInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - LogMessage("%08X: read from SI_STATUS_REG (%08X)",PC, Value); - return; - } - if ( VAddr >= 0xBFC00000 && VAddr <= 0xBFC007C0 ) - { - return; - } - if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC ) - { - if (!g_LogOptions.LogPRDirectMemLoads) - { - return; - } - g_MMU->LW_VAddr(VAddr,Value); - LogMessage("%08X: read word from Pif Ram at 0x%X (%08X)",PC,VAddr - 0xBFC007C0, Value); - return; - } - if ( VAddr >= 0xB0000040 && ((VAddr - 0xB0000000) < g_Rom->GetRomSize())) - { - return; - } - if ( VAddr >= 0xB0000000 && VAddr < 0xB0000040) - { - if (!g_LogOptions.LogRomHeader) - { - return; - } - - g_MMU->LW_VAddr(VAddr,Value); - switch (VAddr) - { - case 0xB0000004: LogMessage("%08X: read from Rom Clock Rate (%08X)",PC, Value); break; - case 0xB0000008: LogMessage("%08X: read from Rom Boot address offset (%08X)",PC, Value); break; - case 0xB000000C: LogMessage("%08X: read from Rom Release offset (%08X)",PC, Value); break; - case 0xB0000010: LogMessage("%08X: read from Rom CRC1 (%08X)",PC, Value); break; - case 0xB0000014: LogMessage("%08X: read from Rom CRC2 (%08X)",PC, Value); break; - default: LogMessage("%08X: read from Rom header 0x%X (%08X)",PC, VAddr & 0xFF,Value); break; - } - return; - } - if (!g_LogOptions.LogUnknown) - { - return; - } - LogMessage("%08X: read from unknown ??? (%08X)",PC,VAddr); -} - -void Log_SW (uint32_t PC, uint32_t VAddr, uint32_t Value) -{ - if (!g_LogOptions.GenerateLog) - { - return; - } - - if ( VAddr < 0xA0000000 || VAddr >= 0xC0000000 ) - { - uint32_t PAddr; - if (!g_TransVaddr->TranslateVaddr(VAddr,PAddr)) - { - if (g_LogOptions.LogUnknown) - { - LogMessage("%08X: Writing 0x%08X to %08X",PC, Value, VAddr ); - } - return; - } - VAddr = PAddr + 0xA0000000; - } - - if ( VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize())) - { - return; - } - if ( VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) - { - if (!g_LogOptions.LogRDRamRegisters) - { - return; - } - switch (VAddr) - { - case 0xA3F00000: LogMessage("%08X: Writing 0x%08X to RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG",PC, Value ); return; - case 0xA3F00004: LogMessage("%08X: Writing 0x%08X to RDRAM_DEVICE_ID_REG",PC, Value ); return; - case 0xA3F00008: LogMessage("%08X: Writing 0x%08X to RDRAM_DELAY_REG",PC, Value ); return; - case 0xA3F0000C: LogMessage("%08X: Writing 0x%08X to RDRAM_MODE_REG",PC, Value ); return; - case 0xA3F00010: LogMessage("%08X: Writing 0x%08X to RDRAM_REF_INTERVAL_REG",PC, Value ); return; - case 0xA3F00014: LogMessage("%08X: Writing 0x%08X to RDRAM_REF_ROW_REG",PC, Value ); return; - case 0xA3F00018: LogMessage("%08X: Writing 0x%08X to RDRAM_RAS_INTERVAL_REG",PC, Value ); return; - case 0xA3F0001C: LogMessage("%08X: Writing 0x%08X to RDRAM_MIN_INTERVAL_REG",PC, Value ); return; - case 0xA3F00020: LogMessage("%08X: Writing 0x%08X to RDRAM_ADDR_SELECT_REG",PC, Value ); return; - case 0xA3F00024: LogMessage("%08X: Writing 0x%08X to RDRAM_DEVICE_MANUF_REG",PC, Value ); return; - } - } - if ( VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC ) - { - return; - } - - if ( VAddr >= 0xA4040000 && VAddr <= 0xA404001C) - { - if (!g_LogOptions.LogSPRegisters) - { - return; - } - switch (VAddr) - { - case 0xA4040000: LogMessage("%08X: Writing 0x%08X to SP_MEM_ADDR_REG",PC, Value ); return; - case 0xA4040004: LogMessage("%08X: Writing 0x%08X to SP_DRAM_ADDR_REG",PC, Value ); return; - case 0xA4040008: LogMessage("%08X: Writing 0x%08X to SP_RD_LEN_REG",PC, Value ); return; - case 0xA404000C: LogMessage("%08X: Writing 0x%08X to SP_WR_LEN_REG",PC, Value ); return; - case 0xA4040010: LogMessage("%08X: Writing 0x%08X to SP_STATUS_REG",PC, Value ); return; - case 0xA4040014: LogMessage("%08X: Writing 0x%08X to SP_DMA_FULL_REG",PC, Value ); return; - case 0xA4040018: LogMessage("%08X: Writing 0x%08X to SP_DMA_BUSY_REG",PC, Value ); return; - case 0xA404001C: LogMessage("%08X: Writing 0x%08X to SP_SEMAPHORE_REG",PC, Value ); return; - } - } - if ( VAddr == 0xA4080000) - { - if (!g_LogOptions.LogSPRegisters) - { - return; - } - LogMessage("%08X: Writing 0x%08X to SP_PC",PC, Value ); return; - } - - if ( VAddr >= 0xA4100000 && VAddr <= 0xA410001C) - { - if (!g_LogOptions.LogDPCRegisters) - { - return; - } - switch (VAddr) - { - case 0xA4100000: LogMessage("%08X: Writing 0x%08X to DPC_START_REG",PC, Value ); return; - case 0xA4100004: LogMessage("%08X: Writing 0x%08X to DPC_END_REG",PC, Value ); return; - case 0xA4100008: LogMessage("%08X: Writing 0x%08X to DPC_CURRENT_REG",PC, Value ); return; - case 0xA410000C: LogMessage("%08X: Writing 0x%08X to DPC_STATUS_REG",PC, Value ); return; - case 0xA4100010: LogMessage("%08X: Writing 0x%08X to DPC_CLOCK_REG",PC, Value ); return; - case 0xA4100014: LogMessage("%08X: Writing 0x%08X to DPC_BUFBUSY_REG",PC, Value ); return; - case 0xA4100018: LogMessage("%08X: Writing 0x%08X to DPC_PIPEBUSY_REG",PC, Value ); return; - case 0xA410001C: LogMessage("%08X: Writing 0x%08X to DPC_TMEM_REG",PC, Value ); return; - } - } - - if ( VAddr >= 0xA4200000 && VAddr <= 0xA420000C) - { - if (!g_LogOptions.LogDPSRegisters) - { - return; - } - switch (VAddr) - { - case 0xA4200000: LogMessage("%08X: Writing 0x%08X to DPS_TBIST_REG",PC, Value ); return; - case 0xA4200004: LogMessage("%08X: Writing 0x%08X to DPS_TEST_MODE_REG",PC, Value ); return; - case 0xA4200008: LogMessage("%08X: Writing 0x%08X to DPS_BUFTEST_ADDR_REG",PC, Value ); return; - case 0xA420000C: LogMessage("%08X: Writing 0x%08X to DPS_BUFTEST_DATA_REG",PC, Value ); return; - } - } - - if ( VAddr >= 0xA4300000 && VAddr <= 0xA430000C) - { - if (!g_LogOptions.LogMIPSInterface) - { - return; - } - switch (VAddr) - { - case 0xA4300000: LogMessage("%08X: Writing 0x%08X to MI_INIT_MODE_REG/MI_MODE_REG",PC, Value ); return; - case 0xA4300004: LogMessage("%08X: Writing 0x%08X to MI_VERSION_REG/MI_NOOP_REG",PC, Value ); return; - case 0xA4300008: LogMessage("%08X: Writing 0x%08X to MI_INTR_REG",PC, Value ); return; - case 0xA430000C: LogMessage("%08X: Writing 0x%08X to MI_INTR_MASK_REG",PC, Value ); return; - } - } - if ( VAddr >= 0xA4400000 && VAddr <= 0xA4400034) - { - if (!g_LogOptions.LogVideoInterface) - { - return; - } - switch (VAddr) - { - case 0xA4400000: LogMessage("%08X: Writing 0x%08X to VI_STATUS_REG/VI_CONTROL_REG",PC, Value ); return; - case 0xA4400004: LogMessage("%08X: Writing 0x%08X to VI_ORIGIN_REG/VI_DRAM_ADDR_REG",PC, Value ); return; - case 0xA4400008: LogMessage("%08X: Writing 0x%08X to VI_WIDTH_REG/VI_H_WIDTH_REG",PC, Value ); return; - case 0xA440000C: LogMessage("%08X: Writing 0x%08X to VI_INTR_REG/VI_V_INTR_REG",PC, Value ); return; - case 0xA4400010: LogMessage("%08X: Writing 0x%08X to VI_CURRENT_REG/VI_V_CURRENT_LINE_REG",PC, Value ); return; - case 0xA4400014: LogMessage("%08X: Writing 0x%08X to VI_BURST_REG/VI_TIMING_REG",PC, Value ); return; - case 0xA4400018: LogMessage("%08X: Writing 0x%08X to VI_V_SYNC_REG",PC, Value ); return; - case 0xA440001C: LogMessage("%08X: Writing 0x%08X to VI_H_SYNC_REG",PC, Value ); return; - case 0xA4400020: LogMessage("%08X: Writing 0x%08X to VI_LEAP_REG/VI_H_SYNC_LEAP_REG",PC, Value ); return; - case 0xA4400024: LogMessage("%08X: Writing 0x%08X to VI_H_START_REG/VI_H_VIDEO_REG",PC, Value ); return; - case 0xA4400028: LogMessage("%08X: Writing 0x%08X to VI_V_START_REG/VI_V_VIDEO_REG",PC, Value ); return; - case 0xA440002C: LogMessage("%08X: Writing 0x%08X to VI_V_BURST_REG",PC, Value ); return; - case 0xA4400030: LogMessage("%08X: Writing 0x%08X to VI_X_SCALE_REG",PC, Value ); return; - case 0xA4400034: LogMessage("%08X: Writing 0x%08X to VI_Y_SCALE_REG",PC, Value ); return; - } - } - - if ( VAddr >= 0xA4500000 && VAddr <= 0xA4500014) - { - if (!g_LogOptions.LogAudioInterface) - { - return; - } - switch (VAddr) - { - case 0xA4500000: LogMessage("%08X: Writing 0x%08X to AI_DRAM_ADDR_REG",PC, Value ); return; - case 0xA4500004: LogMessage("%08X: Writing 0x%08X to AI_LEN_REG",PC, Value ); return; - case 0xA4500008: LogMessage("%08X: Writing 0x%08X to AI_CONTROL_REG",PC, Value ); return; - case 0xA450000C: LogMessage("%08X: Writing 0x%08X to AI_STATUS_REG",PC, Value ); return; - case 0xA4500010: LogMessage("%08X: Writing 0x%08X to AI_DACRATE_REG",PC, Value ); return; - case 0xA4500014: LogMessage("%08X: Writing 0x%08X to AI_BITRATE_REG",PC, Value ); return; - } - } - - if ( VAddr >= 0xA4600000 && VAddr <= 0xA4600030) - { - if (!g_LogOptions.LogPerInterface) - { - return; - } - switch (VAddr) - { - case 0xA4600000: LogMessage("%08X: Writing 0x%08X to PI_DRAM_ADDR_REG",PC, Value ); return; - case 0xA4600004: LogMessage("%08X: Writing 0x%08X to PI_CART_ADDR_REG",PC, Value ); return; - case 0xA4600008: LogMessage("%08X: Writing 0x%08X to PI_RD_LEN_REG",PC, Value ); return; - case 0xA460000C: LogMessage("%08X: Writing 0x%08X to PI_WR_LEN_REG",PC, Value ); return; - case 0xA4600010: LogMessage("%08X: Writing 0x%08X to PI_STATUS_REG",PC, Value ); return; - case 0xA4600014: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_LAT_REG/PI_DOMAIN1_REG",PC, Value ); return; - case 0xA4600018: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_PWD_REG",PC, Value ); return; - case 0xA460001C: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_PGS_REG",PC, Value ); return; - case 0xA4600020: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_RLS_REG",PC, Value ); return; - case 0xA4600024: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_LAT_REG/PI_DOMAIN2_REG",PC, Value ); return; - case 0xA4600028: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_PWD_REG",PC, Value ); return; - case 0xA460002C: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_PGS_REG",PC, Value ); return; - case 0xA4600030: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_RLS_REG",PC, Value ); return; - } - } - if ( VAddr >= 0xA4700000 && VAddr <= 0xA470001C) - { - if (!g_LogOptions.LogRDRAMInterface) - { - return; - } - switch (VAddr) - { - case 0xA4700000: LogMessage("%08X: Writing 0x%08X to RI_MODE_REG",PC, Value ); return; - case 0xA4700004: LogMessage("%08X: Writing 0x%08X to RI_CONFIG_REG",PC, Value ); return; - case 0xA4700008: LogMessage("%08X: Writing 0x%08X to RI_CURRENT_LOAD_REG",PC, Value ); return; - case 0xA470000C: LogMessage("%08X: Writing 0x%08X to RI_SELECT_REG",PC, Value ); return; - case 0xA4700010: LogMessage("%08X: Writing 0x%08X to RI_REFRESH_REG/RI_COUNT_REG",PC, Value ); return; - case 0xA4700014: LogMessage("%08X: Writing 0x%08X to RI_LATENCY_REG",PC, Value ); return; - case 0xA4700018: LogMessage("%08X: Writing 0x%08X to RI_RERROR_REG",PC, Value ); return; - case 0xA470001C: LogMessage("%08X: Writing 0x%08X to RI_WERROR_REG",PC, Value ); return; - } - } - if ( VAddr == 0xA4800000) - { - if (!g_LogOptions.LogSerialInterface) - { - return; - } - LogMessage("%08X: Writing 0x%08X to SI_DRAM_ADDR_REG",PC, Value ); return; - } - if ( VAddr == 0xA4800004) - { - if (g_LogOptions.LogPRDMAOperations) - { - LogMessage("%08X: A DMA transfer from the PIF ram has occured",PC ); - } - if (!g_LogOptions.LogSerialInterface) - { - return; - } - LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_RD64B_REG",PC, Value ); return; - } - if ( VAddr == 0xA4800010) - { - if (g_LogOptions.LogPRDMAOperations) - { - LogMessage("%08X: A DMA transfer to the PIF ram has occured",PC ); - } - if (!g_LogOptions.LogSerialInterface) - { - return; - } - LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_WR64B_REG",PC, Value ); return; - } - if ( VAddr == 0xA4800018) - { - if (!g_LogOptions.LogSerialInterface) - { - return; - } - LogMessage("%08X: Writing 0x%08X to SI_STATUS_REG",PC, Value ); return; - } - - if ( VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC ) - { - if (!g_LogOptions.LogPRDirectMemStores) - { - return; - } - LogMessage("%08X: Writing 0x%08X to Pif Ram at 0x%X",PC,Value, VAddr - 0xBFC007C0); - return; - } - if (!g_LogOptions.LogUnknown) - { - return; - } - LogMessage("%08X: Writing 0x%08X to %08X ????",PC, Value, VAddr ); -} - -LRESULT CALLBACK LogPifProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam) -{ - switch (uMsg) - { - case WM_INITDIALOG: - if (TempOptions.LogPRDMAOperations) { CheckDlgButton(hDlg,IDC_SI_DMA,BST_CHECKED); } - if (TempOptions.LogPRDirectMemLoads) { CheckDlgButton(hDlg,IDC_DIRECT_WRITE,BST_CHECKED); } - if (TempOptions.LogPRDMAMemLoads) { CheckDlgButton(hDlg,IDC_DMA_WRITE,BST_CHECKED); } - if (TempOptions.LogPRDirectMemStores) { CheckDlgButton(hDlg,IDC_DIRECT_READ,BST_CHECKED); } - if (TempOptions.LogPRDMAMemStores) { CheckDlgButton(hDlg,IDC_DMA_READ,BST_CHECKED); } - if (TempOptions.LogControllerPak) { CheckDlgButton(hDlg,IDC_CONT_PAK,BST_CHECKED); } - break; - case WM_NOTIFY: - if (((NMHDR FAR *) lParam)->code != PSN_APPLY) - { - break; - } - TempOptions.LogPRDMAOperations = IsDlgButtonChecked(hDlg,IDC_SI_DMA) == BST_CHECKED?TRUE:FALSE; - TempOptions.LogPRDirectMemLoads = IsDlgButtonChecked(hDlg,IDC_DIRECT_WRITE) == BST_CHECKED?TRUE:FALSE; - TempOptions.LogPRDMAMemLoads = IsDlgButtonChecked(hDlg,IDC_DMA_WRITE) == BST_CHECKED?TRUE:FALSE; - TempOptions.LogPRDirectMemStores = IsDlgButtonChecked(hDlg,IDC_DIRECT_READ) == BST_CHECKED?TRUE:FALSE; - TempOptions.LogPRDMAMemStores = IsDlgButtonChecked(hDlg,IDC_DMA_READ) == BST_CHECKED?TRUE:FALSE; - TempOptions.LogControllerPak = IsDlgButtonChecked(hDlg,IDC_CONT_PAK) == BST_CHECKED?TRUE:FALSE; - break; - default: - return FALSE; - } - return TRUE; -} - -LRESULT CALLBACK LogRegProc (HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam) -{ - switch (uMsg) - { - case WM_INITDIALOG: - if (TempOptions.LogRDRamRegisters) { CheckDlgButton(hDlg,IDC_RDRAM,BST_CHECKED); } - if (TempOptions.LogSPRegisters) { CheckDlgButton(hDlg,IDC_SP_REG,BST_CHECKED); } - if (TempOptions.LogDPCRegisters) { CheckDlgButton(hDlg,IDC_DPC_REG,BST_CHECKED); } - if (TempOptions.LogDPSRegisters) { CheckDlgButton(hDlg,IDC_DPS_REG,BST_CHECKED); } - if (TempOptions.LogMIPSInterface) { CheckDlgButton(hDlg,IDC_MI_REG,BST_CHECKED); } - if (TempOptions.LogVideoInterface) { CheckDlgButton(hDlg,IDC_VI_REG,BST_CHECKED); } - if (TempOptions.LogAudioInterface) { CheckDlgButton(hDlg,IDC_AI_REG,BST_CHECKED); } - if (TempOptions.LogPerInterface) { CheckDlgButton(hDlg,IDC_PI_REG,BST_CHECKED); } - if (TempOptions.LogRDRAMInterface) { CheckDlgButton(hDlg,IDC_RI_REG,BST_CHECKED); } - if (TempOptions.LogSerialInterface) { CheckDlgButton(hDlg,IDC_SI_REG,BST_CHECKED); } - break; - case WM_NOTIFY: - if (((NMHDR FAR *) lParam)->code != PSN_APPLY) - { - break; - } - TempOptions.LogRDRamRegisters = IsDlgButtonChecked(hDlg,IDC_RDRAM) == BST_CHECKED?TRUE:FALSE; - TempOptions.LogSPRegisters = IsDlgButtonChecked(hDlg,IDC_SP_REG) == BST_CHECKED?TRUE:FALSE; - TempOptions.LogDPCRegisters = IsDlgButtonChecked(hDlg,IDC_DPC_REG) == BST_CHECKED?TRUE:FALSE; - TempOptions.LogDPSRegisters = IsDlgButtonChecked(hDlg,IDC_DPS_REG) == BST_CHECKED?TRUE:FALSE; - TempOptions.LogMIPSInterface = IsDlgButtonChecked(hDlg,IDC_MI_REG) == BST_CHECKED?TRUE:FALSE; - TempOptions.LogVideoInterface = IsDlgButtonChecked(hDlg,IDC_VI_REG) == BST_CHECKED?TRUE:FALSE; - TempOptions.LogAudioInterface = IsDlgButtonChecked(hDlg,IDC_AI_REG) == BST_CHECKED?TRUE:FALSE; - TempOptions.LogPerInterface = IsDlgButtonChecked(hDlg,IDC_PI_REG) == BST_CHECKED?TRUE:FALSE; - TempOptions.LogRDRAMInterface = IsDlgButtonChecked(hDlg,IDC_RI_REG) == BST_CHECKED?TRUE:FALSE; - TempOptions.LogSerialInterface = IsDlgButtonChecked(hDlg,IDC_SI_REG) == BST_CHECKED?TRUE:FALSE; - break; - default: - return FALSE; - } - return TRUE; -} - -void SaveLogSetting (HKEY hKey,char * String, BOOL Value) -{ - DWORD StoreValue = Value; - RegSetValueEx(hKey,String,0,REG_DWORD,(CONST BYTE *)&StoreValue,sizeof(DWORD)); -} - -void SaveLogOptions (void) -{ - long lResult; - HKEY hKeyResults = 0; - DWORD Disposition = 0; - char String[200]; - - sprintf(String,"Software\\N64 Emulation\\%s\\Logging",g_Settings->LoadStringVal(Setting_ApplicationName).c_str()); - lResult = RegCreateKeyEx( HKEY_CURRENT_USER,String,0,"", REG_OPTION_NON_VOLATILE, - KEY_ALL_ACCESS,NULL,&hKeyResults,&Disposition); - - SaveLogSetting(hKeyResults,"Log RDRAM",TempOptions.LogRDRamRegisters); - SaveLogSetting(hKeyResults,"Log SP",TempOptions.LogSPRegisters); - SaveLogSetting(hKeyResults,"Log DP Command",TempOptions.LogDPCRegisters); - SaveLogSetting(hKeyResults,"Log DP Span",TempOptions.LogDPSRegisters); - SaveLogSetting(hKeyResults,"Log MIPS Interface (MI)",TempOptions.LogMIPSInterface); - SaveLogSetting(hKeyResults,"Log Video Interface (VI)",TempOptions.LogVideoInterface); - SaveLogSetting(hKeyResults,"Log Audio Interface (AI)",TempOptions.LogAudioInterface); - SaveLogSetting(hKeyResults,"Log Peripheral Interface (PI)",TempOptions.LogPerInterface); - SaveLogSetting(hKeyResults,"Log RDRAM Interface (RI)",TempOptions.LogRDRAMInterface); - SaveLogSetting(hKeyResults,"Log Serial Interface (SI)",TempOptions.LogSerialInterface); - SaveLogSetting(hKeyResults,"Log PifRam DMA Operations",TempOptions.LogPRDMAOperations); - SaveLogSetting(hKeyResults,"Log PifRam Direct Memory Loads",TempOptions.LogPRDirectMemLoads); - SaveLogSetting(hKeyResults,"Log PifRam DMA Memory Loads",TempOptions.LogPRDMAMemLoads); - SaveLogSetting(hKeyResults,"Log PifRam Direct Memory Stores",TempOptions.LogPRDirectMemStores); - SaveLogSetting(hKeyResults,"Log PifRam DMA Memory Stores",TempOptions.LogPRDMAMemStores); - SaveLogSetting(hKeyResults,"Log Controller Pak",TempOptions.LogControllerPak); - SaveLogSetting(hKeyResults,"Log CP0 changes",TempOptions.LogCP0changes); - SaveLogSetting(hKeyResults,"Log CP0 reads",TempOptions.LogCP0reads); - SaveLogSetting(hKeyResults,"Log Exceptions",TempOptions.LogExceptions); - SaveLogSetting(hKeyResults,"No Interrupts",TempOptions.NoInterrupts); - SaveLogSetting(hKeyResults,"Log TLB",TempOptions.LogTLB); - SaveLogSetting(hKeyResults,"Log Cache Operations",TempOptions.LogCache); - SaveLogSetting(hKeyResults,"Log Rom Header",TempOptions.LogRomHeader); - SaveLogSetting(hKeyResults,"Log Unknown access",TempOptions.LogUnknown); - - RegCloseKey(hKeyResults); -} - -void LogMessage (const char * Message, ...) -{ - DWORD dwWritten; - char Msg[400]; - va_list ap; - - if (!g_Settings->LoadBool(Debugger_Enabled)) - { - return; - } - if (g_hLogFile == NULL) - { - return; - } - - va_start( ap, Message ); - vsprintf( Msg, Message, ap ); - va_end( ap ); - - strcat(Msg,"\r\n"); - - WriteFile( g_hLogFile,Msg,strlen(Msg),&dwWritten,NULL ); -} - -void StartLog (void) -{ - if (!g_LogOptions.GenerateLog) - { - StopLog(); - return; - } - if (g_hLogFile) - { - return; - } - - CPath LogFile(CPath::MODULE_DIRECTORY); - LogFile.AppendDirectory("Logs"); - LogFile.SetNameExtension("cpudebug.log"); - - g_hLogFile = CreateFile(LogFile,GENERIC_WRITE, FILE_SHARE_READ,NULL,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); - SetFilePointer(g_hLogFile,0,NULL,FILE_BEGIN); -} - -void StopLog (void) -{ - if (g_hLogFile) - { - CloseHandle(g_hLogFile); - } - g_hLogFile = NULL; -} diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp index 339a208e3..217a28188 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp @@ -9,8 +9,9 @@ * * ****************************************************************************/ #include "stdafx.h" +#include -bool DelaySlotEffectsCompare ( uint32_t PC, uint32_t Reg1, uint32_t Reg2 ); +bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2); #define ADDRESS_ERROR_EXCEPTION(Address,FromRead) \ g_Reg->DoAddressError(m_NextInstruction == JUMP,Address,FromRead);\ @@ -25,7 +26,7 @@ bool DelaySlotEffectsCompare ( uint32_t PC, uint32_t Reg1, uint32_t Reg2 ); m_NextInstruction = JUMP;\ m_JumpToLocation = (*_PROGRAM_COUNTER);\ return;\ - } + } #define TLB_READ_EXCEPTION(Address) \ g_Reg->DoTLBReadMiss(m_NextInstruction == JUMP,Address);\ @@ -35,16 +36,16 @@ bool DelaySlotEffectsCompare ( uint32_t PC, uint32_t Reg1, uint32_t Reg2 ); R4300iOp32::Func * R4300iOp32::BuildInterpreter() { - Jump_Opcode[ 0] = SPECIAL; - Jump_Opcode[ 1] = REGIMM; - Jump_Opcode[ 2] = R4300iOp::J; - Jump_Opcode[ 3] = JAL; - Jump_Opcode[ 4] = BEQ; - Jump_Opcode[ 5] = BNE; - Jump_Opcode[ 6] = BLEZ; - Jump_Opcode[ 7] = BGTZ; - Jump_Opcode[ 8] = ADDI; - Jump_Opcode[ 9] = ADDIU; + Jump_Opcode[0] = SPECIAL; + Jump_Opcode[1] = REGIMM; + Jump_Opcode[2] = R4300iOp::J; + Jump_Opcode[3] = JAL; + Jump_Opcode[4] = BEQ; + Jump_Opcode[5] = BNE; + Jump_Opcode[6] = BLEZ; + Jump_Opcode[7] = BGTZ; + Jump_Opcode[8] = ADDI; + Jump_Opcode[9] = ADDIU; Jump_Opcode[10] = SLTI; Jump_Opcode[11] = SLTIU; Jump_Opcode[12] = ANDI; @@ -100,16 +101,16 @@ R4300iOp32::Func * R4300iOp32::BuildInterpreter() Jump_Opcode[62] = R4300iOp::UnknownOpcode; Jump_Opcode[63] = R4300iOp::SD; - Jump_Special[ 0] = SPECIAL_SLL; - Jump_Special[ 1] = R4300iOp::UnknownOpcode; - Jump_Special[ 2] = SPECIAL_SRL; - Jump_Special[ 3] = SPECIAL_SRA; - Jump_Special[ 4] = SPECIAL_SLLV; - Jump_Special[ 5] = R4300iOp::UnknownOpcode; - Jump_Special[ 6] = SPECIAL_SRLV; - Jump_Special[ 7] = SPECIAL_SRAV; - Jump_Special[ 8] = SPECIAL_JR; - Jump_Special[ 9] = SPECIAL_JALR; + Jump_Special[0] = SPECIAL_SLL; + Jump_Special[1] = R4300iOp::UnknownOpcode; + Jump_Special[2] = SPECIAL_SRL; + Jump_Special[3] = SPECIAL_SRA; + Jump_Special[4] = SPECIAL_SLLV; + Jump_Special[5] = R4300iOp::UnknownOpcode; + Jump_Special[6] = SPECIAL_SRLV; + Jump_Special[7] = SPECIAL_SRAV; + Jump_Special[8] = SPECIAL_JR; + Jump_Special[9] = SPECIAL_JALR; Jump_Special[10] = R4300iOp::UnknownOpcode; Jump_Special[11] = R4300iOp::UnknownOpcode; Jump_Special[12] = R4300iOp::SPECIAL_SYSCALL; @@ -165,16 +166,16 @@ R4300iOp32::Func * R4300iOp32::BuildInterpreter() Jump_Special[62] = R4300iOp::SPECIAL_DSRL32; Jump_Special[63] = R4300iOp::SPECIAL_DSRA32; - Jump_Regimm[ 0] = REGIMM_BLTZ; - Jump_Regimm[ 1] = REGIMM_BGEZ; - Jump_Regimm[ 2] = REGIMM_BLTZL; - Jump_Regimm[ 3] = REGIMM_BGEZL; - Jump_Regimm[ 4] = R4300iOp::UnknownOpcode; - Jump_Regimm[ 5] = R4300iOp::UnknownOpcode; - Jump_Regimm[ 6] = R4300iOp::UnknownOpcode; - Jump_Regimm[ 7] = R4300iOp::UnknownOpcode; - Jump_Regimm[ 8] = R4300iOp::UnknownOpcode; - Jump_Regimm[ 9] = R4300iOp::UnknownOpcode; + Jump_Regimm[0] = REGIMM_BLTZ; + Jump_Regimm[1] = REGIMM_BGEZ; + Jump_Regimm[2] = REGIMM_BLTZL; + Jump_Regimm[3] = REGIMM_BGEZL; + Jump_Regimm[4] = R4300iOp::UnknownOpcode; + Jump_Regimm[5] = R4300iOp::UnknownOpcode; + Jump_Regimm[6] = R4300iOp::UnknownOpcode; + Jump_Regimm[7] = R4300iOp::UnknownOpcode; + Jump_Regimm[8] = R4300iOp::UnknownOpcode; + Jump_Regimm[9] = R4300iOp::UnknownOpcode; Jump_Regimm[10] = R4300iOp::UnknownOpcode; Jump_Regimm[11] = R4300iOp::UnknownOpcode; Jump_Regimm[12] = R4300iOp::UnknownOpcode; @@ -198,16 +199,16 @@ R4300iOp32::Func * R4300iOp32::BuildInterpreter() Jump_Regimm[30] = R4300iOp::UnknownOpcode; Jump_Regimm[31] = R4300iOp::UnknownOpcode; - Jump_CoP0[ 0] = COP0_MF; - Jump_CoP0[ 1] = R4300iOp::UnknownOpcode; - Jump_CoP0[ 2] = R4300iOp::UnknownOpcode; - Jump_CoP0[ 3] = R4300iOp::UnknownOpcode; - Jump_CoP0[ 4] = COP0_MT; - Jump_CoP0[ 5] = R4300iOp::UnknownOpcode; - Jump_CoP0[ 6] = R4300iOp::UnknownOpcode; - Jump_CoP0[ 7] = R4300iOp::UnknownOpcode; - Jump_CoP0[ 8] = R4300iOp::UnknownOpcode; - Jump_CoP0[ 9] = R4300iOp::UnknownOpcode; + Jump_CoP0[0] = COP0_MF; + Jump_CoP0[1] = R4300iOp::UnknownOpcode; + Jump_CoP0[2] = R4300iOp::UnknownOpcode; + Jump_CoP0[3] = R4300iOp::UnknownOpcode; + Jump_CoP0[4] = COP0_MT; + Jump_CoP0[5] = R4300iOp::UnknownOpcode; + Jump_CoP0[6] = R4300iOp::UnknownOpcode; + Jump_CoP0[7] = R4300iOp::UnknownOpcode; + Jump_CoP0[8] = R4300iOp::UnknownOpcode; + Jump_CoP0[9] = R4300iOp::UnknownOpcode; Jump_CoP0[10] = R4300iOp::UnknownOpcode; Jump_CoP0[11] = R4300iOp::UnknownOpcode; Jump_CoP0[12] = R4300iOp::UnknownOpcode; @@ -231,16 +232,16 @@ R4300iOp32::Func * R4300iOp32::BuildInterpreter() Jump_CoP0[30] = R4300iOp::COP0_CO; Jump_CoP0[31] = R4300iOp::COP0_CO; - Jump_CoP0_Function[ 0] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[ 1] = R4300iOp::COP0_CO_TLBR; - Jump_CoP0_Function[ 2] = R4300iOp::COP0_CO_TLBWI; - Jump_CoP0_Function[ 3] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[ 4] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[ 5] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[ 6] = R4300iOp::COP0_CO_TLBWR; - Jump_CoP0_Function[ 7] = R4300iOp::UnknownOpcode; - Jump_CoP0_Function[ 8] = R4300iOp::COP0_CO_TLBP; - Jump_CoP0_Function[ 9] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[0] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[1] = R4300iOp::COP0_CO_TLBR; + Jump_CoP0_Function[2] = R4300iOp::COP0_CO_TLBWI; + Jump_CoP0_Function[3] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[4] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[5] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[6] = R4300iOp::COP0_CO_TLBWR; + Jump_CoP0_Function[7] = R4300iOp::UnknownOpcode; + Jump_CoP0_Function[8] = R4300iOp::COP0_CO_TLBP; + Jump_CoP0_Function[9] = R4300iOp::UnknownOpcode; Jump_CoP0_Function[10] = R4300iOp::UnknownOpcode; Jump_CoP0_Function[11] = R4300iOp::UnknownOpcode; Jump_CoP0_Function[12] = R4300iOp::UnknownOpcode; @@ -296,16 +297,16 @@ R4300iOp32::Func * R4300iOp32::BuildInterpreter() Jump_CoP0_Function[62] = R4300iOp::UnknownOpcode; Jump_CoP0_Function[63] = R4300iOp::UnknownOpcode; - Jump_CoP1[ 0] = COP1_MF; - Jump_CoP1[ 1] = R4300iOp::COP1_DMF; - Jump_CoP1[ 2] = COP1_CF; - Jump_CoP1[ 3] = R4300iOp::UnknownOpcode; - Jump_CoP1[ 4] = R4300iOp::COP1_MT; - Jump_CoP1[ 5] = COP1_DMT; - Jump_CoP1[ 6] = R4300iOp::COP1_CT; - Jump_CoP1[ 7] = R4300iOp::UnknownOpcode; - Jump_CoP1[ 8] = R4300iOp::COP1_BC; - Jump_CoP1[ 9] = R4300iOp::UnknownOpcode; + Jump_CoP1[0] = COP1_MF; + Jump_CoP1[1] = R4300iOp::COP1_DMF; + Jump_CoP1[2] = COP1_CF; + Jump_CoP1[3] = R4300iOp::UnknownOpcode; + Jump_CoP1[4] = R4300iOp::COP1_MT; + Jump_CoP1[5] = COP1_DMT; + Jump_CoP1[6] = R4300iOp::COP1_CT; + Jump_CoP1[7] = R4300iOp::UnknownOpcode; + Jump_CoP1[8] = R4300iOp::COP1_BC; + Jump_CoP1[9] = R4300iOp::UnknownOpcode; Jump_CoP1[10] = R4300iOp::UnknownOpcode; Jump_CoP1[11] = R4300iOp::UnknownOpcode; Jump_CoP1[12] = R4300iOp::UnknownOpcode; @@ -329,16 +330,16 @@ R4300iOp32::Func * R4300iOp32::BuildInterpreter() Jump_CoP1[30] = R4300iOp::UnknownOpcode; Jump_CoP1[31] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[ 0] = R4300iOp::COP1_BCF; - Jump_CoP1_BC[ 1] = R4300iOp::COP1_BCT; - Jump_CoP1_BC[ 2] = R4300iOp::COP1_BCFL; - Jump_CoP1_BC[ 3] = R4300iOp::COP1_BCTL; - Jump_CoP1_BC[ 4] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[ 5] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[ 6] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[ 7] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[ 8] = R4300iOp::UnknownOpcode; - Jump_CoP1_BC[ 9] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[0] = R4300iOp::COP1_BCF; + Jump_CoP1_BC[1] = R4300iOp::COP1_BCT; + Jump_CoP1_BC[2] = R4300iOp::COP1_BCFL; + Jump_CoP1_BC[3] = R4300iOp::COP1_BCTL; + Jump_CoP1_BC[4] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[5] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[6] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[7] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[8] = R4300iOp::UnknownOpcode; + Jump_CoP1_BC[9] = R4300iOp::UnknownOpcode; Jump_CoP1_BC[10] = R4300iOp::UnknownOpcode; Jump_CoP1_BC[11] = R4300iOp::UnknownOpcode; Jump_CoP1_BC[12] = R4300iOp::UnknownOpcode; @@ -362,16 +363,16 @@ R4300iOp32::Func * R4300iOp32::BuildInterpreter() Jump_CoP1_BC[30] = R4300iOp::UnknownOpcode; Jump_CoP1_BC[31] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[ 0] = R4300iOp::COP1_S_ADD; - Jump_CoP1_S[ 1] = R4300iOp::COP1_S_SUB; - Jump_CoP1_S[ 2] = R4300iOp::COP1_S_MUL; - Jump_CoP1_S[ 3] = R4300iOp::COP1_S_DIV; - Jump_CoP1_S[ 4] = R4300iOp::COP1_S_SQRT; - Jump_CoP1_S[ 5] = R4300iOp::COP1_S_ABS; - Jump_CoP1_S[ 6] = R4300iOp::COP1_S_MOV; - Jump_CoP1_S[ 7] = R4300iOp::COP1_S_NEG; - Jump_CoP1_S[ 8] = R4300iOp::UnknownOpcode; - Jump_CoP1_S[ 9] = R4300iOp::COP1_S_TRUNC_L; + Jump_CoP1_S[0] = R4300iOp::COP1_S_ADD; + Jump_CoP1_S[1] = R4300iOp::COP1_S_SUB; + Jump_CoP1_S[2] = R4300iOp::COP1_S_MUL; + Jump_CoP1_S[3] = R4300iOp::COP1_S_DIV; + Jump_CoP1_S[4] = R4300iOp::COP1_S_SQRT; + Jump_CoP1_S[5] = R4300iOp::COP1_S_ABS; + Jump_CoP1_S[6] = R4300iOp::COP1_S_MOV; + Jump_CoP1_S[7] = R4300iOp::COP1_S_NEG; + Jump_CoP1_S[8] = R4300iOp::UnknownOpcode; + Jump_CoP1_S[9] = R4300iOp::COP1_S_TRUNC_L; Jump_CoP1_S[10] = R4300iOp::COP1_S_CEIL_L; //added by Witten Jump_CoP1_S[11] = R4300iOp::COP1_S_FLOOR_L; //added by Witten Jump_CoP1_S[12] = R4300iOp::COP1_S_ROUND_W; @@ -427,16 +428,16 @@ R4300iOp32::Func * R4300iOp32::BuildInterpreter() Jump_CoP1_S[62] = R4300iOp::COP1_S_CMP; Jump_CoP1_S[63] = R4300iOp::COP1_S_CMP; - Jump_CoP1_D[ 0] = R4300iOp::COP1_D_ADD; - Jump_CoP1_D[ 1] = R4300iOp::COP1_D_SUB; - Jump_CoP1_D[ 2] = R4300iOp::COP1_D_MUL; - Jump_CoP1_D[ 3] = R4300iOp::COP1_D_DIV; - Jump_CoP1_D[ 4] = R4300iOp::COP1_D_SQRT; - Jump_CoP1_D[ 5] = R4300iOp::COP1_D_ABS; - Jump_CoP1_D[ 6] = R4300iOp::COP1_D_MOV; - Jump_CoP1_D[ 7] = R4300iOp::COP1_D_NEG; - Jump_CoP1_D[ 8] = R4300iOp::UnknownOpcode; - Jump_CoP1_D[ 9] = R4300iOp::COP1_D_TRUNC_L; //added by Witten + Jump_CoP1_D[0] = R4300iOp::COP1_D_ADD; + Jump_CoP1_D[1] = R4300iOp::COP1_D_SUB; + Jump_CoP1_D[2] = R4300iOp::COP1_D_MUL; + Jump_CoP1_D[3] = R4300iOp::COP1_D_DIV; + Jump_CoP1_D[4] = R4300iOp::COP1_D_SQRT; + Jump_CoP1_D[5] = R4300iOp::COP1_D_ABS; + Jump_CoP1_D[6] = R4300iOp::COP1_D_MOV; + Jump_CoP1_D[7] = R4300iOp::COP1_D_NEG; + Jump_CoP1_D[8] = R4300iOp::UnknownOpcode; + Jump_CoP1_D[9] = R4300iOp::COP1_D_TRUNC_L; //added by Witten Jump_CoP1_D[10] = R4300iOp::COP1_D_CEIL_L; //added by Witten Jump_CoP1_D[11] = R4300iOp::COP1_D_FLOOR_L; //added by Witten Jump_CoP1_D[12] = R4300iOp::COP1_D_ROUND_W; @@ -492,16 +493,16 @@ R4300iOp32::Func * R4300iOp32::BuildInterpreter() Jump_CoP1_D[62] = R4300iOp::COP1_D_CMP; Jump_CoP1_D[63] = R4300iOp::COP1_D_CMP; - Jump_CoP1_W[ 0] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[ 1] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[ 2] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[ 3] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[ 4] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[ 5] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[ 6] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[ 7] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[ 8] = R4300iOp::UnknownOpcode; - Jump_CoP1_W[ 9] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[0] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[1] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[2] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[3] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[4] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[5] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[6] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[7] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[8] = R4300iOp::UnknownOpcode; + Jump_CoP1_W[9] = R4300iOp::UnknownOpcode; Jump_CoP1_W[10] = R4300iOp::UnknownOpcode; Jump_CoP1_W[11] = R4300iOp::UnknownOpcode; Jump_CoP1_W[12] = R4300iOp::UnknownOpcode; @@ -557,16 +558,16 @@ R4300iOp32::Func * R4300iOp32::BuildInterpreter() Jump_CoP1_W[62] = R4300iOp::UnknownOpcode; Jump_CoP1_W[63] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[ 0] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[ 1] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[ 2] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[ 3] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[ 4] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[ 5] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[ 6] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[ 7] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[ 8] = R4300iOp::UnknownOpcode; - Jump_CoP1_L[ 9] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[0] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[1] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[2] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[3] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[4] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[5] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[6] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[7] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[8] = R4300iOp::UnknownOpcode; + Jump_CoP1_L[9] = R4300iOp::UnknownOpcode; Jump_CoP1_L[10] = R4300iOp::UnknownOpcode; Jump_CoP1_L[11] = R4300iOp::UnknownOpcode; Jump_CoP1_L[12] = R4300iOp::UnknownOpcode; @@ -646,7 +647,7 @@ void R4300iOp32::BEQ() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER, m_Opcode.rs, m_Opcode.rt)) { m_NextInstruction = PERMLOOP_DO_DELAY; } @@ -666,7 +667,7 @@ void R4300iOp32::BNE() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER, m_Opcode.rs, m_Opcode.rt)) { m_NextInstruction = PERMLOOP_DO_DELAY; } @@ -685,7 +686,7 @@ void R4300iOp32::BLEZ() { m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER, m_Opcode.rs, 0)) { m_NextInstruction = PERMLOOP_DO_DELAY; } @@ -705,7 +706,7 @@ void R4300iOp32::BGTZ() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER, m_Opcode.rs, 0)) { m_NextInstruction = PERMLOOP_DO_DELAY; } @@ -769,7 +770,7 @@ void R4300iOp32::SLTIU() int64_t imm64; imm64 = imm32; - _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rs].UW[0] < (uint64_t)imm64?1:0; + _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rs].UW[0] < (uint64_t)imm64 ? 1 : 0; } void R4300iOp32::ANDI() @@ -806,7 +807,7 @@ void R4300iOp32::BEQL() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER, m_Opcode.rs, m_Opcode.rt)) { m_NextInstruction = PERMLOOP_DO_DELAY; } @@ -827,7 +828,7 @@ void R4300iOp32::BNEL() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER, m_Opcode.rs, m_Opcode.rt)) { m_NextInstruction = PERMLOOP_DO_DELAY; } @@ -848,7 +849,7 @@ void R4300iOp32::BLEZL() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER, m_Opcode.rs, 0)) { m_NextInstruction = PERMLOOP_DO_DELAY; } @@ -869,7 +870,7 @@ void R4300iOp32::BGTZL() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER, m_Opcode.rs, 0)) { m_NextInstruction = PERMLOOP_DO_DELAY; } @@ -884,8 +885,8 @@ void R4300iOp32::BGTZL() void R4300iOp32::LB() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; - if (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0])) + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if (!g_MMU->LB_VAddr(Address, _GPR[m_Opcode.rt].UB[0])) { if (bShowTLBMisses()) { @@ -901,12 +902,12 @@ void R4300iOp32::LB() void R4300iOp32::LH() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; if ((Address & 1) != 0) { ADDRESS_ERROR_EXCEPTION(Address, true); } - if (!g_MMU->LH_VAddr(Address,_GPR[m_Opcode.rt].UHW[0])) + if (!g_MMU->LH_VAddr(Address, _GPR[m_Opcode.rt].UHW[0])) { if (bShowTLBMisses()) { @@ -925,9 +926,9 @@ void R4300iOp32::LWL() uint32_t Offset, Address, Value; Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; - Offset = Address & 3; + Offset = Address & 3; - if (!g_MMU->LW_VAddr((Address & ~3),Value)) + if (!g_MMU->LW_VAddr((Address & ~3), Value)) { if (bShowTLBMisses()) { @@ -943,7 +944,7 @@ void R4300iOp32::LWL() void R4300iOp32::LW() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; if ((Address & 3) != 0) { ADDRESS_ERROR_EXCEPTION(Address, true); @@ -951,10 +952,10 @@ void R4300iOp32::LW() if (g_LogOptions.GenerateLog) { - Log_LW((*_PROGRAM_COUNTER),Address); + Log_LW((*_PROGRAM_COUNTER), Address); } - if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + if (!g_MMU->LW_VAddr(Address, _GPR[m_Opcode.rt].UW[0])) { if (bShowTLBMisses()) { @@ -970,8 +971,8 @@ void R4300iOp32::LW() void R4300iOp32::LBU() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; - if (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0])) + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if (!g_MMU->LB_VAddr(Address, _GPR[m_Opcode.rt].UB[0])) { if (bShowTLBMisses()) { @@ -987,12 +988,12 @@ void R4300iOp32::LBU() void R4300iOp32::LHU() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; if ((Address & 1) != 0) { ADDRESS_ERROR_EXCEPTION(Address, true); } - if (!g_MMU->LH_VAddr(Address,_GPR[m_Opcode.rt].UHW[0])) + if (!g_MMU->LH_VAddr(Address, _GPR[m_Opcode.rt].UHW[0])) { if (bShowTLBMisses()) { @@ -1011,11 +1012,11 @@ void R4300iOp32::LWR() uint32_t Offset, Address, Value; Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; - Offset = Address & 3; + Offset = Address & 3; - if (!g_MMU->LW_VAddr((Address & ~3),Value)) + if (!g_MMU->LW_VAddr((Address & ~3), Value)) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); if (bShowTLBMisses()) { g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); @@ -1029,13 +1030,13 @@ void R4300iOp32::LWR() void R4300iOp32::LWU() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; if ((Address & 3) != 0) { ADDRESS_ERROR_EXCEPTION(Address, true); } - if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + if (!g_MMU->LW_VAddr(Address, _GPR[m_Opcode.rt].UW[0])) { if (bShowTLBMisses()) { @@ -1051,13 +1052,13 @@ void R4300iOp32::LWU() void R4300iOp32::LL() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; if ((Address & 3) != 0) { ADDRESS_ERROR_EXCEPTION(Address, true); } - if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + if (!g_MMU->LW_VAddr(Address, _GPR[m_Opcode.rt].UW[0])) { if (bShowTLBMisses()) { @@ -1203,7 +1204,7 @@ void R4300iOp32::REGIMM_BLTZ() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER), m_Opcode.rs, 0)) { CInterpreterCPU::InPermLoop(); } @@ -1223,7 +1224,7 @@ void R4300iOp32::REGIMM_BGEZ() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER), m_Opcode.rs, 0)) { CInterpreterCPU::InPermLoop(); } @@ -1243,7 +1244,7 @@ void R4300iOp32::REGIMM_BLTZL() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER), m_Opcode.rs, 0)) { CInterpreterCPU::InPermLoop(); } @@ -1264,7 +1265,7 @@ void R4300iOp32::REGIMM_BGEZL() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER), m_Opcode.rs, 0)) { CInterpreterCPU::InPermLoop(); } @@ -1285,7 +1286,7 @@ void R4300iOp32::REGIMM_BLTZAL() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER), m_Opcode.rs, 0)) { CInterpreterCPU::InPermLoop(); } @@ -1295,7 +1296,7 @@ void R4300iOp32::REGIMM_BLTZAL() { m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; } - _GPR[31].W[0]= (int32_t)((*_PROGRAM_COUNTER) + 8); + _GPR[31].W[0] = (int32_t)((*_PROGRAM_COUNTER) + 8); } void R4300iOp32::REGIMM_BGEZAL() @@ -1306,7 +1307,7 @@ void R4300iOp32::REGIMM_BGEZAL() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER), m_Opcode.rs, 0)) { CInterpreterCPU::InPermLoop(); } @@ -1338,10 +1339,10 @@ void R4300iOp32::COP0_MT() { if (g_LogOptions.LogCP0changes) { - LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)",(*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0],CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); + LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)", (*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0], CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); if (m_Opcode.rd == 11) //Compare { - LogMessage("%08X: Cause register changed from %08X to %08X",(*_PROGRAM_COUNTER), g_Reg->CAUSE_REGISTER, (g_Reg->CAUSE_REGISTER & ~CAUSE_IP7)); + LogMessage("%08X: Cause register changed from %08X to %08X", (*_PROGRAM_COUNTER), g_Reg->CAUSE_REGISTER, (g_Reg->CAUSE_REGISTER & ~CAUSE_IP7)); } } @@ -1397,7 +1398,7 @@ void R4300iOp32::COP0_MT() break; case 13: //cause _CP0[m_Opcode.rd] &= 0xFFFFCFF; - if ((_GPR[m_Opcode.rt].UW[0] & 0x300) != 0 && g_Settings->LoadBool(Debugger_Enabled) ) + if ((_GPR[m_Opcode.rt].UW[0] & 0x300) != 0 && g_Settings->LoadBool(Debugger_Enabled)) { g_Notify->DisplayError(L"Set IP0 or IP1"); } @@ -1422,11 +1423,11 @@ void R4300iOp32::COP1_CF() if (g_Settings->LoadBool(Debugger_Enabled)) { g_Notify->DisplayError(L"CFC1 what register are you writing to ?"); } return; } - _GPR[m_Opcode.rt].W[0] = (int32_t)_FPCR[m_Opcode.fs]; + _GPR[m_Opcode.rt].W[0] = (int32_t)_FPCR[m_Opcode.fs]; } void R4300iOp32::COP1_DMT() { TEST_COP1_USABLE_EXCEPTION *(int64_t *)_FPR_D[m_Opcode.fs] = _GPR[m_Opcode.rt].W[0]; -} +} \ No newline at end of file diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp index 1282ed151..49c81c22a 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp @@ -9,6 +9,7 @@ * * ****************************************************************************/ #include "stdafx.h" +#include void InPermLoop(); void TestInterpreterJump(uint32_t PC, uint32_t TargetPC, int32_t Reg1, int32_t Reg2); @@ -30,15 +31,15 @@ R4300iOp::Func R4300iOp::Jump_CoP1_D[64]; R4300iOp::Func R4300iOp::Jump_CoP1_W[64]; R4300iOp::Func R4300iOp::Jump_CoP1_L[64]; -const uint32_t R4300iOp::SWL_MASK[4] = { 0x00000000, 0xFF000000,0xFFFF0000,0xFFFFFF00 }; -const uint32_t R4300iOp::SWR_MASK[4] = { 0x00FFFFFF, 0x0000FFFF,0x000000FF,0x00000000 }; -const uint32_t R4300iOp::LWL_MASK[4] = { 0x00000000, 0x000000FF,0x0000FFFF,0x00FFFFFF }; -const uint32_t R4300iOp::LWR_MASK[4] = { 0xFFFFFF00, 0xFFFF0000,0xFF000000,0x0000000 }; +const uint32_t R4300iOp::SWL_MASK[4] = { 0x00000000, 0xFF000000, 0xFFFF0000, 0xFFFFFF00 }; +const uint32_t R4300iOp::SWR_MASK[4] = { 0x00FFFFFF, 0x0000FFFF, 0x000000FF, 0x00000000 }; +const uint32_t R4300iOp::LWL_MASK[4] = { 0x00000000, 0x000000FF, 0x0000FFFF, 0x00FFFFFF }; +const uint32_t R4300iOp::LWR_MASK[4] = { 0xFFFFFF00, 0xFFFF0000, 0xFF000000, 0x0000000 }; const int32_t R4300iOp::SWL_SHIFT[4] = { 0, 8, 16, 24 }; -const int32_t R4300iOp::SWR_SHIFT[4] = { 24, 16 , 8, 0 }; -const int32_t R4300iOp::LWL_SHIFT[4] = { 0, 8, 16, 24}; -const int32_t R4300iOp::LWR_SHIFT[4] = { 24, 16 ,8, 0 }; +const int32_t R4300iOp::SWR_SHIFT[4] = { 24, 16, 8, 0 }; +const int32_t R4300iOp::LWL_SHIFT[4] = { 0, 8, 16, 24 }; +const int32_t R4300iOp::LWR_SHIFT[4] = { 24, 16, 8, 0 }; #define ADDRESS_ERROR_EXCEPTION(Address,FromRead) \ g_Reg->DoAddressError(m_NextInstruction == JUMP,Address,FromRead);\ @@ -53,7 +54,7 @@ const int32_t R4300iOp::LWR_SHIFT[4] = { 24, 16 ,8, 0 }; m_NextInstruction = JUMP;\ m_JumpToLocation = (*_PROGRAM_COUNTER);\ return;\ - } + } #define TLB_READ_EXCEPTION(Address) \ g_Reg->DoTLBReadMiss(m_NextInstruction == JUMP,Address);\ @@ -63,68 +64,68 @@ const int32_t R4300iOp::LWR_SHIFT[4] = { 24, 16 ,8, 0 }; void R4300iOp::SPECIAL() { - Jump_Special[ m_Opcode.funct ](); + Jump_Special[m_Opcode.funct](); } void R4300iOp::REGIMM() { - Jump_Regimm[ m_Opcode.rt ](); + Jump_Regimm[m_Opcode.rt](); } void R4300iOp::COP0() { - Jump_CoP0[ m_Opcode.rs ](); + Jump_CoP0[m_Opcode.rs](); } void R4300iOp::COP0_CO() { - Jump_CoP0_Function[ m_Opcode.funct ](); + Jump_CoP0_Function[m_Opcode.funct](); } void R4300iOp::COP1() { - Jump_CoP1[ m_Opcode.fmt ](); + Jump_CoP1[m_Opcode.fmt](); } void R4300iOp::COP1_BC() { - Jump_CoP1_BC[ m_Opcode.ft ](); + Jump_CoP1_BC[m_Opcode.ft](); } void R4300iOp::COP1_S() { - _controlfp(*_RoundingModel,_MCW_RC); - Jump_CoP1_S[ m_Opcode.funct ](); + _controlfp(*_RoundingModel, _MCW_RC); + Jump_CoP1_S[m_Opcode.funct](); } void R4300iOp::COP1_D() { - _controlfp(*_RoundingModel,_MCW_RC); - Jump_CoP1_D[ m_Opcode.funct ](); + _controlfp(*_RoundingModel, _MCW_RC); + Jump_CoP1_D[m_Opcode.funct](); } void R4300iOp::COP1_W() { - Jump_CoP1_W[ m_Opcode.funct ](); + Jump_CoP1_W[m_Opcode.funct](); } void R4300iOp::COP1_L() { - Jump_CoP1_L[ m_Opcode.funct ](); + Jump_CoP1_L[m_Opcode.funct](); } R4300iOp::Func * R4300iOp::BuildInterpreter() { - Jump_Opcode[ 0] = SPECIAL; - Jump_Opcode[ 1] = REGIMM; - Jump_Opcode[ 2] = J; - Jump_Opcode[ 3] = JAL; - Jump_Opcode[ 4] = BEQ; - Jump_Opcode[ 5] = BNE; - Jump_Opcode[ 6] = BLEZ; - Jump_Opcode[ 7] = BGTZ; - Jump_Opcode[ 8] = ADDI; - Jump_Opcode[ 9] = ADDIU; + Jump_Opcode[0] = SPECIAL; + Jump_Opcode[1] = REGIMM; + Jump_Opcode[2] = J; + Jump_Opcode[3] = JAL; + Jump_Opcode[4] = BEQ; + Jump_Opcode[5] = BNE; + Jump_Opcode[6] = BLEZ; + Jump_Opcode[7] = BGTZ; + Jump_Opcode[8] = ADDI; + Jump_Opcode[9] = ADDIU; Jump_Opcode[10] = SLTI; Jump_Opcode[11] = SLTIU; Jump_Opcode[12] = ANDI; @@ -180,16 +181,16 @@ R4300iOp::Func * R4300iOp::BuildInterpreter() Jump_Opcode[62] = UnknownOpcode; Jump_Opcode[63] = SD; - Jump_Special[ 0] = SPECIAL_SLL; - Jump_Special[ 1] = UnknownOpcode; - Jump_Special[ 2] = SPECIAL_SRL; - Jump_Special[ 3] = SPECIAL_SRA; - Jump_Special[ 4] = SPECIAL_SLLV; - Jump_Special[ 5] = UnknownOpcode; - Jump_Special[ 6] = SPECIAL_SRLV; - Jump_Special[ 7] = SPECIAL_SRAV; - Jump_Special[ 8] = SPECIAL_JR; - Jump_Special[ 9] = SPECIAL_JALR; + Jump_Special[0] = SPECIAL_SLL; + Jump_Special[1] = UnknownOpcode; + Jump_Special[2] = SPECIAL_SRL; + Jump_Special[3] = SPECIAL_SRA; + Jump_Special[4] = SPECIAL_SLLV; + Jump_Special[5] = UnknownOpcode; + Jump_Special[6] = SPECIAL_SRLV; + Jump_Special[7] = SPECIAL_SRAV; + Jump_Special[8] = SPECIAL_JR; + Jump_Special[9] = SPECIAL_JALR; Jump_Special[10] = UnknownOpcode; Jump_Special[11] = UnknownOpcode; Jump_Special[12] = SPECIAL_SYSCALL; @@ -245,16 +246,16 @@ R4300iOp::Func * R4300iOp::BuildInterpreter() Jump_Special[62] = SPECIAL_DSRL32; Jump_Special[63] = SPECIAL_DSRA32; - Jump_Regimm[ 0] = REGIMM_BLTZ; - Jump_Regimm[ 1] = REGIMM_BGEZ; - Jump_Regimm[ 2] = REGIMM_BLTZL; - Jump_Regimm[ 3] = REGIMM_BGEZL; - Jump_Regimm[ 4] = UnknownOpcode; - Jump_Regimm[ 5] = UnknownOpcode; - Jump_Regimm[ 6] = UnknownOpcode; - Jump_Regimm[ 7] = UnknownOpcode; - Jump_Regimm[ 8] = UnknownOpcode; - Jump_Regimm[ 9] = UnknownOpcode; + Jump_Regimm[0] = REGIMM_BLTZ; + Jump_Regimm[1] = REGIMM_BGEZ; + Jump_Regimm[2] = REGIMM_BLTZL; + Jump_Regimm[3] = REGIMM_BGEZL; + Jump_Regimm[4] = UnknownOpcode; + Jump_Regimm[5] = UnknownOpcode; + Jump_Regimm[6] = UnknownOpcode; + Jump_Regimm[7] = UnknownOpcode; + Jump_Regimm[8] = UnknownOpcode; + Jump_Regimm[9] = UnknownOpcode; Jump_Regimm[10] = UnknownOpcode; Jump_Regimm[11] = UnknownOpcode; Jump_Regimm[12] = UnknownOpcode; @@ -278,16 +279,16 @@ R4300iOp::Func * R4300iOp::BuildInterpreter() Jump_Regimm[30] = UnknownOpcode; Jump_Regimm[31] = UnknownOpcode; - Jump_CoP0[ 0] = COP0_MF; - Jump_CoP0[ 1] = UnknownOpcode; - Jump_CoP0[ 2] = UnknownOpcode; - Jump_CoP0[ 3] = UnknownOpcode; - Jump_CoP0[ 4] = COP0_MT; - Jump_CoP0[ 5] = UnknownOpcode; - Jump_CoP0[ 6] = UnknownOpcode; - Jump_CoP0[ 7] = UnknownOpcode; - Jump_CoP0[ 8] = UnknownOpcode; - Jump_CoP0[ 9] = UnknownOpcode; + Jump_CoP0[0] = COP0_MF; + Jump_CoP0[1] = UnknownOpcode; + Jump_CoP0[2] = UnknownOpcode; + Jump_CoP0[3] = UnknownOpcode; + Jump_CoP0[4] = COP0_MT; + Jump_CoP0[5] = UnknownOpcode; + Jump_CoP0[6] = UnknownOpcode; + Jump_CoP0[7] = UnknownOpcode; + Jump_CoP0[8] = UnknownOpcode; + Jump_CoP0[9] = UnknownOpcode; Jump_CoP0[10] = UnknownOpcode; Jump_CoP0[11] = UnknownOpcode; Jump_CoP0[12] = UnknownOpcode; @@ -311,16 +312,16 @@ R4300iOp::Func * R4300iOp::BuildInterpreter() Jump_CoP0[30] = COP0_CO; Jump_CoP0[31] = COP0_CO; - Jump_CoP0_Function[ 0] = UnknownOpcode; - Jump_CoP0_Function[ 1] = COP0_CO_TLBR; - Jump_CoP0_Function[ 2] = COP0_CO_TLBWI; - Jump_CoP0_Function[ 3] = UnknownOpcode; - Jump_CoP0_Function[ 4] = UnknownOpcode; - Jump_CoP0_Function[ 5] = UnknownOpcode; - Jump_CoP0_Function[ 6] = COP0_CO_TLBWR; - Jump_CoP0_Function[ 7] = UnknownOpcode; - Jump_CoP0_Function[ 8] = COP0_CO_TLBP; - Jump_CoP0_Function[ 9] = UnknownOpcode; + Jump_CoP0_Function[0] = UnknownOpcode; + Jump_CoP0_Function[1] = COP0_CO_TLBR; + Jump_CoP0_Function[2] = COP0_CO_TLBWI; + Jump_CoP0_Function[3] = UnknownOpcode; + Jump_CoP0_Function[4] = UnknownOpcode; + Jump_CoP0_Function[5] = UnknownOpcode; + Jump_CoP0_Function[6] = COP0_CO_TLBWR; + Jump_CoP0_Function[7] = UnknownOpcode; + Jump_CoP0_Function[8] = COP0_CO_TLBP; + Jump_CoP0_Function[9] = UnknownOpcode; Jump_CoP0_Function[10] = UnknownOpcode; Jump_CoP0_Function[11] = UnknownOpcode; Jump_CoP0_Function[12] = UnknownOpcode; @@ -376,16 +377,16 @@ R4300iOp::Func * R4300iOp::BuildInterpreter() Jump_CoP0_Function[62] = UnknownOpcode; Jump_CoP0_Function[63] = UnknownOpcode; - Jump_CoP1[ 0] = COP1_MF; - Jump_CoP1[ 1] = COP1_DMF; - Jump_CoP1[ 2] = COP1_CF; - Jump_CoP1[ 3] = UnknownOpcode; - Jump_CoP1[ 4] = COP1_MT; - Jump_CoP1[ 5] = COP1_DMT; - Jump_CoP1[ 6] = COP1_CT; - Jump_CoP1[ 7] = UnknownOpcode; - Jump_CoP1[ 8] = COP1_BC; - Jump_CoP1[ 9] = UnknownOpcode; + Jump_CoP1[0] = COP1_MF; + Jump_CoP1[1] = COP1_DMF; + Jump_CoP1[2] = COP1_CF; + Jump_CoP1[3] = UnknownOpcode; + Jump_CoP1[4] = COP1_MT; + Jump_CoP1[5] = COP1_DMT; + Jump_CoP1[6] = COP1_CT; + Jump_CoP1[7] = UnknownOpcode; + Jump_CoP1[8] = COP1_BC; + Jump_CoP1[9] = UnknownOpcode; Jump_CoP1[10] = UnknownOpcode; Jump_CoP1[11] = UnknownOpcode; Jump_CoP1[12] = UnknownOpcode; @@ -409,16 +410,16 @@ R4300iOp::Func * R4300iOp::BuildInterpreter() Jump_CoP1[30] = UnknownOpcode; Jump_CoP1[31] = UnknownOpcode; - Jump_CoP1_BC[ 0] = COP1_BCF; - Jump_CoP1_BC[ 1] = COP1_BCT; - Jump_CoP1_BC[ 2] = COP1_BCFL; - Jump_CoP1_BC[ 3] = COP1_BCTL; - Jump_CoP1_BC[ 4] = UnknownOpcode; - Jump_CoP1_BC[ 5] = UnknownOpcode; - Jump_CoP1_BC[ 6] = UnknownOpcode; - Jump_CoP1_BC[ 7] = UnknownOpcode; - Jump_CoP1_BC[ 8] = UnknownOpcode; - Jump_CoP1_BC[ 9] = UnknownOpcode; + Jump_CoP1_BC[0] = COP1_BCF; + Jump_CoP1_BC[1] = COP1_BCT; + Jump_CoP1_BC[2] = COP1_BCFL; + Jump_CoP1_BC[3] = COP1_BCTL; + Jump_CoP1_BC[4] = UnknownOpcode; + Jump_CoP1_BC[5] = UnknownOpcode; + Jump_CoP1_BC[6] = UnknownOpcode; + Jump_CoP1_BC[7] = UnknownOpcode; + Jump_CoP1_BC[8] = UnknownOpcode; + Jump_CoP1_BC[9] = UnknownOpcode; Jump_CoP1_BC[10] = UnknownOpcode; Jump_CoP1_BC[11] = UnknownOpcode; Jump_CoP1_BC[12] = UnknownOpcode; @@ -442,16 +443,16 @@ R4300iOp::Func * R4300iOp::BuildInterpreter() Jump_CoP1_BC[30] = UnknownOpcode; Jump_CoP1_BC[31] = UnknownOpcode; - Jump_CoP1_S[ 0] = COP1_S_ADD; - Jump_CoP1_S[ 1] = COP1_S_SUB; - Jump_CoP1_S[ 2] = COP1_S_MUL; - Jump_CoP1_S[ 3] = COP1_S_DIV; - Jump_CoP1_S[ 4] = COP1_S_SQRT; - Jump_CoP1_S[ 5] = COP1_S_ABS; - Jump_CoP1_S[ 6] = COP1_S_MOV; - Jump_CoP1_S[ 7] = COP1_S_NEG; - Jump_CoP1_S[ 8] = UnknownOpcode; - Jump_CoP1_S[ 9] = COP1_S_TRUNC_L; + Jump_CoP1_S[0] = COP1_S_ADD; + Jump_CoP1_S[1] = COP1_S_SUB; + Jump_CoP1_S[2] = COP1_S_MUL; + Jump_CoP1_S[3] = COP1_S_DIV; + Jump_CoP1_S[4] = COP1_S_SQRT; + Jump_CoP1_S[5] = COP1_S_ABS; + Jump_CoP1_S[6] = COP1_S_MOV; + Jump_CoP1_S[7] = COP1_S_NEG; + Jump_CoP1_S[8] = UnknownOpcode; + Jump_CoP1_S[9] = COP1_S_TRUNC_L; Jump_CoP1_S[10] = COP1_S_CEIL_L; //added by Witten Jump_CoP1_S[11] = COP1_S_FLOOR_L; //added by Witten Jump_CoP1_S[12] = COP1_S_ROUND_W; @@ -507,16 +508,16 @@ R4300iOp::Func * R4300iOp::BuildInterpreter() Jump_CoP1_S[62] = COP1_S_CMP; Jump_CoP1_S[63] = COP1_S_CMP; - Jump_CoP1_D[ 0] = COP1_D_ADD; - Jump_CoP1_D[ 1] = COP1_D_SUB; - Jump_CoP1_D[ 2] = COP1_D_MUL; - Jump_CoP1_D[ 3] = COP1_D_DIV; - Jump_CoP1_D[ 4] = COP1_D_SQRT; - Jump_CoP1_D[ 5] = COP1_D_ABS; - Jump_CoP1_D[ 6] = COP1_D_MOV; - Jump_CoP1_D[ 7] = COP1_D_NEG; - Jump_CoP1_D[ 8] = UnknownOpcode; - Jump_CoP1_D[ 9] = COP1_D_TRUNC_L; //added by Witten + Jump_CoP1_D[0] = COP1_D_ADD; + Jump_CoP1_D[1] = COP1_D_SUB; + Jump_CoP1_D[2] = COP1_D_MUL; + Jump_CoP1_D[3] = COP1_D_DIV; + Jump_CoP1_D[4] = COP1_D_SQRT; + Jump_CoP1_D[5] = COP1_D_ABS; + Jump_CoP1_D[6] = COP1_D_MOV; + Jump_CoP1_D[7] = COP1_D_NEG; + Jump_CoP1_D[8] = UnknownOpcode; + Jump_CoP1_D[9] = COP1_D_TRUNC_L; //added by Witten Jump_CoP1_D[10] = COP1_D_CEIL_L; //added by Witten Jump_CoP1_D[11] = COP1_D_FLOOR_L; //added by Witten Jump_CoP1_D[12] = COP1_D_ROUND_W; @@ -572,16 +573,16 @@ R4300iOp::Func * R4300iOp::BuildInterpreter() Jump_CoP1_D[62] = COP1_D_CMP; Jump_CoP1_D[63] = COP1_D_CMP; - Jump_CoP1_W[ 0] = UnknownOpcode; - Jump_CoP1_W[ 1] = UnknownOpcode; - Jump_CoP1_W[ 2] = UnknownOpcode; - Jump_CoP1_W[ 3] = UnknownOpcode; - Jump_CoP1_W[ 4] = UnknownOpcode; - Jump_CoP1_W[ 5] = UnknownOpcode; - Jump_CoP1_W[ 6] = UnknownOpcode; - Jump_CoP1_W[ 7] = UnknownOpcode; - Jump_CoP1_W[ 8] = UnknownOpcode; - Jump_CoP1_W[ 9] = UnknownOpcode; + Jump_CoP1_W[0] = UnknownOpcode; + Jump_CoP1_W[1] = UnknownOpcode; + Jump_CoP1_W[2] = UnknownOpcode; + Jump_CoP1_W[3] = UnknownOpcode; + Jump_CoP1_W[4] = UnknownOpcode; + Jump_CoP1_W[5] = UnknownOpcode; + Jump_CoP1_W[6] = UnknownOpcode; + Jump_CoP1_W[7] = UnknownOpcode; + Jump_CoP1_W[8] = UnknownOpcode; + Jump_CoP1_W[9] = UnknownOpcode; Jump_CoP1_W[10] = UnknownOpcode; Jump_CoP1_W[11] = UnknownOpcode; Jump_CoP1_W[12] = UnknownOpcode; @@ -637,16 +638,16 @@ R4300iOp::Func * R4300iOp::BuildInterpreter() Jump_CoP1_W[62] = UnknownOpcode; Jump_CoP1_W[63] = UnknownOpcode; - Jump_CoP1_L[ 0] = UnknownOpcode; - Jump_CoP1_L[ 1] = UnknownOpcode; - Jump_CoP1_L[ 2] = UnknownOpcode; - Jump_CoP1_L[ 3] = UnknownOpcode; - Jump_CoP1_L[ 4] = UnknownOpcode; - Jump_CoP1_L[ 5] = UnknownOpcode; - Jump_CoP1_L[ 6] = UnknownOpcode; - Jump_CoP1_L[ 7] = UnknownOpcode; - Jump_CoP1_L[ 8] = UnknownOpcode; - Jump_CoP1_L[ 9] = UnknownOpcode; + Jump_CoP1_L[0] = UnknownOpcode; + Jump_CoP1_L[1] = UnknownOpcode; + Jump_CoP1_L[2] = UnknownOpcode; + Jump_CoP1_L[3] = UnknownOpcode; + Jump_CoP1_L[4] = UnknownOpcode; + Jump_CoP1_L[5] = UnknownOpcode; + Jump_CoP1_L[6] = UnknownOpcode; + Jump_CoP1_L[7] = UnknownOpcode; + Jump_CoP1_L[8] = UnknownOpcode; + Jump_CoP1_L[9] = UnknownOpcode; Jump_CoP1_L[10] = UnknownOpcode; Jump_CoP1_L[11] = UnknownOpcode; Jump_CoP1_L[12] = UnknownOpcode; @@ -705,15 +706,15 @@ R4300iOp::Func * R4300iOp::BuildInterpreter() return Jump_Opcode; } -bool DelaySlotEffectsCompare (uint32_t PC, uint32_t Reg1, uint32_t Reg2); +bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2); -void TestInterpreterJump (uint32_t PC, uint32_t TargetPC, int32_t Reg1, int32_t Reg2) +void TestInterpreterJump(uint32_t PC, uint32_t TargetPC, int32_t Reg1, int32_t Reg2) { if (PC != TargetPC) { return; } - if (DelaySlotEffectsCompare(PC,Reg1,Reg2)) + if (DelaySlotEffectsCompare(PC, Reg1, Reg2)) { return; } @@ -736,7 +737,7 @@ void R4300iOp::JAL() { m_NextInstruction = DELAY_SLOT; m_JumpToLocation = ((*_PROGRAM_COUNTER) & 0xF0000000) + (m_Opcode.target << 2); - _GPR[31].DW= (int32_t)((*_PROGRAM_COUNTER) + 8); + _GPR[31].DW = (int32_t)((*_PROGRAM_COUNTER) + 8); if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { @@ -752,7 +753,7 @@ void R4300iOp::BEQ() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER, m_Opcode.rs, m_Opcode.rt)) { m_NextInstruction = PERMLOOP_DO_DELAY; } @@ -772,7 +773,7 @@ void R4300iOp::BNE() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER, m_Opcode.rs, m_Opcode.rt)) { m_NextInstruction = PERMLOOP_DO_DELAY; } @@ -792,7 +793,7 @@ void R4300iOp::BLEZ() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER, m_Opcode.rs, 0)) { m_NextInstruction = PERMLOOP_DO_DELAY; } @@ -812,7 +813,7 @@ void R4300iOp::BGTZ() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER, m_Opcode.rs, 0)) { m_NextInstruction = PERMLOOP_DO_DELAY; } @@ -876,7 +877,7 @@ void R4300iOp::SLTIU() int64_t imm64; imm64 = imm32; - _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rs].UDW < (uint64_t)imm64?1:0; + _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rs].UDW < (uint64_t)imm64 ? 1 : 0; } void R4300iOp::ANDI() @@ -901,7 +902,7 @@ void R4300iOp::LUI() if (m_Opcode.rt == 29) { StackValue = _GPR[m_Opcode.rt].W[0]; - } +} #endif } @@ -913,7 +914,7 @@ void R4300iOp::BEQL() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER, m_Opcode.rs, m_Opcode.rt)) { m_NextInstruction = PERMLOOP_DO_DELAY; } @@ -934,7 +935,7 @@ void R4300iOp::BNEL() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,m_Opcode.rt)) + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER, m_Opcode.rs, m_Opcode.rt)) { m_NextInstruction = PERMLOOP_DO_DELAY; } @@ -955,7 +956,7 @@ void R4300iOp::BLEZL() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER, m_Opcode.rs, 0)) { m_NextInstruction = PERMLOOP_DO_DELAY; } @@ -976,7 +977,7 @@ void R4300iOp::BGTZL() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER,m_Opcode.rs,0)) + if (!DelaySlotEffectsCompare(*_PROGRAM_COUNTER, m_Opcode.rs, 0)) { m_NextInstruction = PERMLOOP_DO_DELAY; } @@ -994,7 +995,7 @@ void R4300iOp::DADDIU() _GPR[m_Opcode.rt].DW = _GPR[m_Opcode.rs].DW + (int64_t)((int16_t)m_Opcode.immediate); } -uint64_t LDL_MASK[8] = { 0,0xFF,0xFFFF,0xFFFFFF,0xFFFFFFFF,0xFFFFFFFFFF, 0xFFFFFFFFFFFF, 0xFFFFFFFFFFFFFF }; +uint64_t LDL_MASK[8] = { 0, 0xFF, 0xFFFF, 0xFFFFFF, 0xFFFFFFFF, 0xFFFFFFFFFF, 0xFFFFFFFFFFFF, 0xFFFFFFFFFFFFFF }; int32_t LDL_SHIFT[8] = { 0, 8, 16, 24, 32, 40, 48, 56 }; void R4300iOp::LDL() @@ -1003,11 +1004,11 @@ void R4300iOp::LDL() uint64_t Value; Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; - Offset = Address & 7; + Offset = Address & 7; - if (!g_MMU->LD_VAddr((Address & ~7),Value)) + if (!g_MMU->LD_VAddr((Address & ~7), Value)) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); if (bShowTLBMisses()) { g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); @@ -1019,9 +1020,9 @@ void R4300iOp::LDL() } uint64_t LDR_MASK[8] = { 0xFFFFFFFFFFFFFF00, 0xFFFFFFFFFFFF0000, - 0xFFFFFFFFFF000000, 0xFFFFFFFF00000000, - 0xFFFFFF0000000000, 0xFFFF000000000000, - 0xFF00000000000000, 0 }; +0xFFFFFFFFFF000000, 0xFFFFFFFF00000000, +0xFFFFFF0000000000, 0xFFFF000000000000, +0xFF00000000000000, 0 }; int32_t LDR_SHIFT[8] = { 56, 48, 40, 32, 24, 16, 8, 0 }; void R4300iOp::LDR() @@ -1030,11 +1031,11 @@ void R4300iOp::LDR() uint64_t Value; Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; - Offset = Address & 7; + Offset = Address & 7; - if (!g_MMU->LD_VAddr((Address & ~7),Value)) + if (!g_MMU->LD_VAddr((Address & ~7), Value)) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); if (bShowTLBMisses()) { g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); @@ -1048,8 +1049,8 @@ void R4300iOp::LDR() void R4300iOp::LB() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; - if (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0])) + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if (!g_MMU->LB_VAddr(Address, _GPR[m_Opcode.rt].UB[0])) { if (bShowTLBMisses()) { @@ -1065,12 +1066,12 @@ void R4300iOp::LB() void R4300iOp::LH() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; if ((Address & 1) != 0) { ADDRESS_ERROR_EXCEPTION(Address, true); } - if (!g_MMU->LH_VAddr(Address,_GPR[m_Opcode.rt].UHW[0])) + if (!g_MMU->LH_VAddr(Address, _GPR[m_Opcode.rt].UHW[0])) { if (bShowTLBMisses()) { @@ -1089,11 +1090,11 @@ void R4300iOp::LWL() uint32_t Offset, Address, Value; Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; - Offset = Address & 3; + Offset = Address & 3; - if (!g_MMU->LW_VAddr((Address & ~3),Value)) + if (!g_MMU->LW_VAddr((Address & ~3), Value)) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); if (bShowTLBMisses()) { g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); @@ -1107,7 +1108,7 @@ void R4300iOp::LWL() void R4300iOp::LW() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; if ((Address & 3) != 0) { ADDRESS_ERROR_EXCEPTION(Address, true); @@ -1115,10 +1116,10 @@ void R4300iOp::LW() if (g_LogOptions.GenerateLog) { - Log_LW((*_PROGRAM_COUNTER),Address); + Log_LW((*_PROGRAM_COUNTER), Address); } - if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + if (!g_MMU->LW_VAddr(Address, _GPR[m_Opcode.rt].UW[0])) { if (bShowTLBMisses()) { @@ -1134,8 +1135,8 @@ void R4300iOp::LW() void R4300iOp::LBU() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; - if (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0])) + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if (!g_MMU->LB_VAddr(Address, _GPR[m_Opcode.rt].UB[0])) { if (bShowTLBMisses()) { @@ -1151,12 +1152,12 @@ void R4300iOp::LBU() void R4300iOp::LHU() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; if ((Address & 1) != 0) { ADDRESS_ERROR_EXCEPTION(Address, true); } - if (!g_MMU->LH_VAddr(Address,_GPR[m_Opcode.rt].UHW[0])) + if (!g_MMU->LH_VAddr(Address, _GPR[m_Opcode.rt].UHW[0])) { if (bShowTLBMisses()) { @@ -1175,11 +1176,11 @@ void R4300iOp::LWR() uint32_t Offset, Address, Value; Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; - Offset = Address & 3; + Offset = Address & 3; - if (!g_MMU->LW_VAddr((Address & ~3),Value)) + if (!g_MMU->LW_VAddr((Address & ~3), Value)) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); if (bShowTLBMisses()) { g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); @@ -1193,13 +1194,13 @@ void R4300iOp::LWR() void R4300iOp::LWU() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; if ((Address & 3) != 0) { ADDRESS_ERROR_EXCEPTION(Address, true); } - if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + if (!g_MMU->LW_VAddr(Address, _GPR[m_Opcode.rt].UW[0])) { if (bShowTLBMisses()) { @@ -1215,12 +1216,12 @@ void R4300iOp::LWU() void R4300iOp::SB() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; - if (!g_MMU->SB_VAddr(Address,_GPR[m_Opcode.rt].UB[0])) + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + if (!g_MMU->SB_VAddr(Address, _GPR[m_Opcode.rt].UB[0])) { if (bHaveDebugger()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } if (bShowTLBMisses()) { @@ -1231,16 +1232,16 @@ void R4300iOp::SB() void R4300iOp::SH() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; if ((Address & 1) != 0) { ADDRESS_ERROR_EXCEPTION(Address, false); } - if (!g_MMU->SH_VAddr(Address,_GPR[m_Opcode.rt].UHW[0])) + if (!g_MMU->SH_VAddr(Address, _GPR[m_Opcode.rt].UHW[0])) { if (bHaveDebugger()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } if (bShowTLBMisses()) { @@ -1254,13 +1255,13 @@ void R4300iOp::SWL() uint32_t Offset, Address, Value; Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; - Offset = Address & 3; + Offset = Address & 3; - if (!g_MMU->LW_VAddr((Address & ~3),Value)) + if (!g_MMU->LW_VAddr((Address & ~3), Value)) { if (bHaveDebugger()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } if (bShowTLBMisses()) { @@ -1272,11 +1273,11 @@ void R4300iOp::SWL() Value &= SWL_MASK[Offset]; Value += _GPR[m_Opcode.rt].UW[0] >> SWL_SHIFT[Offset]; - if (!g_MMU->SW_VAddr((Address & ~0x03),Value)) + if (!g_MMU->SW_VAddr((Address & ~0x03), Value)) { if (bHaveDebugger()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } if (bShowTLBMisses()) { @@ -1287,20 +1288,20 @@ void R4300iOp::SWL() void R4300iOp::SW() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; if ((Address & 3) != 0) { ADDRESS_ERROR_EXCEPTION(Address, false); } if (g_LogOptions.GenerateLog) { - Log_SW((*_PROGRAM_COUNTER),Address,_GPR[m_Opcode.rt].UW[0]); + Log_SW((*_PROGRAM_COUNTER), Address, _GPR[m_Opcode.rt].UW[0]); } - if (!g_MMU->SW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + if (!g_MMU->SW_VAddr(Address, _GPR[m_Opcode.rt].UW[0])) { if (bHaveDebugger()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } if (bShowTLBMisses()) { @@ -1309,13 +1310,13 @@ void R4300iOp::SW() } } -uint64_t SDL_MASK[8] = { 0,0xFF00000000000000, - 0xFFFF000000000000, - 0xFFFFFF0000000000, - 0xFFFFFFFF00000000, - 0xFFFFFFFFFF000000, - 0xFFFFFFFFFFFF0000, - 0xFFFFFFFFFFFFFF00 }; +uint64_t SDL_MASK[8] = { 0, 0xFF00000000000000, +0xFFFF000000000000, +0xFFFFFF0000000000, +0xFFFFFFFF00000000, +0xFFFFFFFFFF000000, +0xFFFFFFFFFFFF0000, +0xFFFFFFFFFFFFFF00 }; int32_t SDL_SHIFT[8] = { 0, 8, 16, 24, 32, 40, 48, 56 }; @@ -1325,13 +1326,13 @@ void R4300iOp::SDL() uint64_t Value; Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; - Offset = Address & 7; + Offset = Address & 7; - if (!g_MMU->LD_VAddr((Address & ~7),Value)) + if (!g_MMU->LD_VAddr((Address & ~7), Value)) { if (bHaveDebugger()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } if (bShowTLBMisses()) { @@ -1343,11 +1344,11 @@ void R4300iOp::SDL() Value &= SDL_MASK[Offset]; Value += _GPR[m_Opcode.rt].UDW >> SDL_SHIFT[Offset]; - if (!g_MMU->SD_VAddr((Address & ~7),Value)) + if (!g_MMU->SD_VAddr((Address & ~7), Value)) { if (bHaveDebugger()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } if (bShowTLBMisses()) { @@ -1357,15 +1358,15 @@ void R4300iOp::SDL() } uint64_t SDR_MASK[8] = { 0x00FFFFFFFFFFFFFF, - 0x0000FFFFFFFFFFFF, - 0x000000FFFFFFFFFF, - 0x00000000FFFFFFFF, - 0x0000000000FFFFFF, - 0x000000000000FFFF, - 0x00000000000000FF, - 0x0000000000000000 }; +0x0000FFFFFFFFFFFF, +0x000000FFFFFFFFFF, +0x00000000FFFFFFFF, +0x0000000000FFFFFF, +0x000000000000FFFF, +0x00000000000000FF, +0x0000000000000000 }; -int32_t SDR_SHIFT[8] = { 56,48,40,32,24,16,8,0 }; +int32_t SDR_SHIFT[8] = { 56, 48, 40, 32, 24, 16, 8, 0 }; void R4300iOp::SDR() { @@ -1373,13 +1374,13 @@ void R4300iOp::SDR() uint64_t Value; Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; - Offset = Address & 7; + Offset = Address & 7; - if (!g_MMU->LD_VAddr((Address & ~7),Value)) + if (!g_MMU->LD_VAddr((Address & ~7), Value)) { if (bHaveDebugger()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } if (bShowTLBMisses()) { @@ -1391,11 +1392,11 @@ void R4300iOp::SDR() Value &= SDR_MASK[Offset]; Value += _GPR[m_Opcode.rt].UDW << SDR_SHIFT[Offset]; - if (!g_MMU->SD_VAddr((Address & ~7),Value)) + if (!g_MMU->SD_VAddr((Address & ~7), Value)) { if (bHaveDebugger()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } if (bShowTLBMisses()) { @@ -1409,13 +1410,13 @@ void R4300iOp::SWR() uint32_t Offset, Address, Value; Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; - Offset = Address & 3; + Offset = Address & 3; - if (!g_MMU->LW_VAddr((Address & ~3),Value)) + if (!g_MMU->LW_VAddr((Address & ~3), Value)) { if (bHaveDebugger()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } if (bShowTLBMisses()) { @@ -1427,11 +1428,11 @@ void R4300iOp::SWR() Value &= SWR_MASK[Offset]; Value += _GPR[m_Opcode.rt].UW[0] << SWR_SHIFT[Offset]; - if (!g_MMU->SW_VAddr((Address & ~0x03),Value)) + if (!g_MMU->SW_VAddr((Address & ~0x03), Value)) { if (bHaveDebugger()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } if (bShowTLBMisses()) { @@ -1446,18 +1447,18 @@ void R4300iOp::CACHE() { return; } - LogMessage("%08X: Cache operation %d, 0x%08X", (*_PROGRAM_COUNTER), m_Opcode.rt, _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset ); + LogMessage("%08X: Cache operation %d, 0x%08X", (*_PROGRAM_COUNTER), m_Opcode.rt, _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset); } void R4300iOp::LL() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; if ((Address & 3) != 0) { ADDRESS_ERROR_EXCEPTION(Address, true); } - if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + if (!g_MMU->LW_VAddr(Address, _GPR[m_Opcode.rt].UW[0])) { if (bShowTLBMisses()) { @@ -1474,35 +1475,35 @@ void R4300iOp::LL() void R4300iOp::LWC1() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (uint32_t)((int16_t)m_Opcode.offset); + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (uint32_t)((int16_t)m_Opcode.offset); TEST_COP1_USABLE_EXCEPTION if ((Address & 3) != 0) { ADDRESS_ERROR_EXCEPTION(Address, true); } - if (!g_MMU->LW_VAddr(Address,*(uint32_t *)_FPR_S[m_Opcode.ft])) + if (!g_MMU->LW_VAddr(Address, *(uint32_t *)_FPR_S[m_Opcode.ft])) + { + if (bShowTLBMisses()) { - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } - TLB_READ_EXCEPTION(Address); + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); } + TLB_READ_EXCEPTION(Address); + } } void R4300iOp::SC() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; if ((Address & 3) != 0) { ADDRESS_ERROR_EXCEPTION(Address, false); } - Log_SW((*_PROGRAM_COUNTER),Address,_GPR[m_Opcode.rt].UW[0]); + Log_SW((*_PROGRAM_COUNTER), Address, _GPR[m_Opcode.rt].UW[0]); if ((*_LLBit) == 1) { - if (!g_MMU->SW_VAddr(Address,_GPR[m_Opcode.rt].UW[0])) + if (!g_MMU->SW_VAddr(Address, _GPR[m_Opcode.rt].UW[0])) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); if (bShowTLBMisses()) { g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); @@ -1514,16 +1515,16 @@ void R4300iOp::SC() void R4300iOp::LD() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; if ((Address & 7) != 0) { ADDRESS_ERROR_EXCEPTION(Address, true); } - if (!g_MMU->LD_VAddr(Address,_GPR[m_Opcode.rt].UDW)) + if (!g_MMU->LD_VAddr(Address, _GPR[m_Opcode.rt].UDW)) { if (bHaveDebugger()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } if (bShowTLBMisses()) { @@ -1541,82 +1542,82 @@ void R4300iOp::LD() void R4300iOp::LDC1() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; TEST_COP1_USABLE_EXCEPTION if ((Address & 7) != 0) { ADDRESS_ERROR_EXCEPTION(Address, true); } - if (!g_MMU->LD_VAddr(Address,*(uint64_t *)_FPR_D[m_Opcode.ft])) + if (!g_MMU->LD_VAddr(Address, *(uint64_t *)_FPR_D[m_Opcode.ft])) + { + if (bHaveDebugger()) { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } + g_Notify->BreakPoint(__FILEW__, __LINE__); } + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + } } void R4300iOp::SWC1() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; TEST_COP1_USABLE_EXCEPTION if ((Address & 3) != 0) { ADDRESS_ERROR_EXCEPTION(Address, false); } - if (!g_MMU->SW_VAddr(Address,*(uint32_t *)_FPR_S[m_Opcode.ft])) + if (!g_MMU->SW_VAddr(Address, *(uint32_t *)_FPR_S[m_Opcode.ft])) + { + if (bHaveDebugger()) { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } + g_Notify->BreakPoint(__FILEW__, __LINE__); } + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + } } void R4300iOp::SDC1() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; TEST_COP1_USABLE_EXCEPTION if ((Address & 7) != 0) { ADDRESS_ERROR_EXCEPTION(Address, false); } - if (!g_MMU->SD_VAddr(Address,*(int64_t *)_FPR_D[m_Opcode.ft])) + if (!g_MMU->SD_VAddr(Address, *(int64_t *)_FPR_D[m_Opcode.ft])) + { + if (bHaveDebugger()) { - if (bHaveDebugger()) - { - g_Notify->BreakPoint(__FILEW__,__LINE__); - } - if (bShowTLBMisses()) - { - g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); - } + g_Notify->BreakPoint(__FILEW__, __LINE__); } + if (bShowTLBMisses()) + { + g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str()); + } + } } void R4300iOp::SD() { - uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; + uint32_t Address = _GPR[m_Opcode.base].UW[0] + (int16_t)m_Opcode.offset; if ((Address & 7) != 0) { ADDRESS_ERROR_EXCEPTION(Address, false); } - if (!g_MMU->SD_VAddr(Address,_GPR[m_Opcode.rt].UDW)) + if (!g_MMU->SD_VAddr(Address, _GPR[m_Opcode.rt].UDW)) { if (bHaveDebugger()) { - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__, __LINE__); } if (bShowTLBMisses()) { @@ -1739,7 +1740,7 @@ void R4300iOp::SPECIAL_MULTU() void R4300iOp::SPECIAL_DIV() { - if ( _GPR[m_Opcode.rt].UDW != 0 ) + if (_GPR[m_Opcode.rt].UDW != 0) { _RegLO->DW = _GPR[m_Opcode.rs].W[0] / _GPR[m_Opcode.rt].W[0]; _RegHI->DW = _GPR[m_Opcode.rs].W[0] % _GPR[m_Opcode.rt].W[0]; @@ -1803,7 +1804,7 @@ void R4300iOp::SPECIAL_DMULTU() void R4300iOp::SPECIAL_DDIV() { - if ( _GPR[m_Opcode.rt].UDW != 0 ) + if (_GPR[m_Opcode.rt].UDW != 0) { _RegLO->DW = _GPR[m_Opcode.rs].DW / _GPR[m_Opcode.rt].DW; _RegHI->DW = _GPR[m_Opcode.rs].DW % _GPR[m_Opcode.rt].DW; @@ -1819,7 +1820,7 @@ void R4300iOp::SPECIAL_DDIV() void R4300iOp::SPECIAL_DDIVU() { - if ( _GPR[m_Opcode.rt].UDW != 0 ) + if (_GPR[m_Opcode.rt].UDW != 0) { _RegLO->UDW = _GPR[m_Opcode.rs].UDW / _GPR[m_Opcode.rt].UDW; _RegHI->UDW = _GPR[m_Opcode.rs].UDW % _GPR[m_Opcode.rt].UDW; @@ -1865,7 +1866,7 @@ void R4300iOp::SPECIAL_OR() if (m_Opcode.rd == 29) { StackValue = _GPR[m_Opcode.rd].W[0]; - } +} #endif } @@ -1970,7 +1971,7 @@ void R4300iOp::REGIMM_BLTZ() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER), m_Opcode.rs, 0)) { CInterpreterCPU::InPermLoop(); } @@ -1990,7 +1991,7 @@ void R4300iOp::REGIMM_BGEZ() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER), m_Opcode.rs, 0)) { CInterpreterCPU::InPermLoop(); } @@ -2010,7 +2011,7 @@ void R4300iOp::REGIMM_BLTZL() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER), m_Opcode.rs, 0)) { CInterpreterCPU::InPermLoop(); } @@ -2031,7 +2032,7 @@ void R4300iOp::REGIMM_BGEZL() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER), m_Opcode.rs, 0)) { CInterpreterCPU::InPermLoop(); } @@ -2052,7 +2053,7 @@ void R4300iOp::REGIMM_BLTZAL() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER), m_Opcode.rs, 0)) { CInterpreterCPU::InPermLoop(); } @@ -2062,7 +2063,7 @@ void R4300iOp::REGIMM_BLTZAL() { m_JumpToLocation = (*_PROGRAM_COUNTER) + 8; } - _GPR[31].DW= (int32_t)((*_PROGRAM_COUNTER) + 8); + _GPR[31].DW = (int32_t)((*_PROGRAM_COUNTER) + 8); } void R4300iOp::REGIMM_BGEZAL() @@ -2073,7 +2074,7 @@ void R4300iOp::REGIMM_BGEZAL() m_JumpToLocation = (*_PROGRAM_COUNTER) + ((int16_t)m_Opcode.offset << 2) + 4; if ((*_PROGRAM_COUNTER) == m_JumpToLocation) { - if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER),m_Opcode.rs,0)) + if (!DelaySlotEffectsCompare((*_PROGRAM_COUNTER), m_Opcode.rs, 0)) { CInterpreterCPU::InPermLoop(); } @@ -2104,10 +2105,10 @@ void R4300iOp::COP0_MT() { if (g_LogOptions.LogCP0changes) { - LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)",(*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0],CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); + LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)", (*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0], CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); if (m_Opcode.rd == 11) //Compare { - LogMessage("%08X: Cause register changed from %08X to %08X",(*_PROGRAM_COUNTER), g_Reg->CAUSE_REGISTER, (g_Reg->CAUSE_REGISTER & ~CAUSE_IP7)); + LogMessage("%08X: Cause register changed from %08X to %08X", (*_PROGRAM_COUNTER), g_Reg->CAUSE_REGISTER, (g_Reg->CAUSE_REGISTER & ~CAUSE_IP7)); } } @@ -2198,7 +2199,7 @@ void R4300iOp::COP0_CO_TLBWR() { return; } - g_TLB->WriteEntry(g_Reg->RANDOM_REGISTER & 0x1F,true); + g_TLB->WriteEntry(g_Reg->RANDOM_REGISTER & 0x1F, true); } void R4300iOp::COP0_CO_TLBP() @@ -2252,7 +2253,7 @@ void R4300iOp::COP1_CF() } return; } - _GPR[m_Opcode.rt].DW = (int32_t)_FPCR[m_Opcode.fs]; + _GPR[m_Opcode.rt].DW = (int32_t)_FPCR[m_Opcode.fs]; } void R4300iOp::COP1_MT() @@ -2281,10 +2282,10 @@ void R4300iOp::COP1_CT() } return; } - if (bHaveDebugger()) - { - g_Notify->DisplayError(L"CTC1 what register are you writing to ?"); - } + if (bHaveDebugger()) + { + g_Notify->DisplayError(L"CTC1 what register are you writing to ?"); + } } /************************* COP1: BC1 functions ***********************/ @@ -2346,15 +2347,15 @@ void R4300iOp::COP1_BCTL() } } /************************** COP1: S functions ************************/ -__inline void Float_RoundToInteger32( int32_t * Dest, float * Source ) +__inline void Float_RoundToInteger32(int32_t * Dest, float * Source) { #ifdef _M_IX86 _asm { mov esi, [Source] - mov edi, [Dest] - fld dword ptr [esi] - fistp dword ptr [edi] + mov edi, [Dest] + fld dword ptr[esi] + fistp dword ptr[edi] } #else __m128 xmm; @@ -2362,17 +2363,17 @@ __inline void Float_RoundToInteger32( int32_t * Dest, float * Source ) xmm = _mm_load_ss(Source); *(Dest) = _mm_cvt_ss2si(xmm); #endif -} + } -__inline void Float_RoundToInteger64( int64_t * Dest, float * Source ) +__inline void Float_RoundToInteger64(int64_t * Dest, float * Source) { #ifdef _M_IX86 _asm { mov esi, [Source] - mov edi, [Dest] - fld dword ptr [esi] - fistp qword ptr [edi] + mov edi, [Dest] + fld dword ptr[esi] + fistp qword ptr[edi] } #else __m128 xmm; @@ -2380,53 +2381,53 @@ __inline void Float_RoundToInteger64( int64_t * Dest, float * Source ) xmm = _mm_load_ss(Source); *(Dest) = _mm_cvtss_si64(xmm); #endif -} + } void R4300iOp::COP1_S_ADD() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); *(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] + *(float *)_FPR_S[m_Opcode.ft]); } void R4300iOp::COP1_S_SUB() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); *(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] - *(float *)_FPR_S[m_Opcode.ft]); } void R4300iOp::COP1_S_MUL() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); *(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] * *(float *)_FPR_S[m_Opcode.ft]); } void R4300iOp::COP1_S_DIV() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); *(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] / *(float *)_FPR_S[m_Opcode.ft]); } void R4300iOp::COP1_S_SQRT() { - float * Dest = (float *)(_FPR_S[m_Opcode.fd]); + float * Dest = (float *)(_FPR_S[m_Opcode.fd]); float * Source = (float *)(_FPR_S[m_Opcode.fs]); TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); #ifdef _M_IX86 _asm { push esi - mov esi, dword ptr [Source] - fld dword ptr [esi] - fsqrt - mov esi, dword ptr [Dest] - fstp dword ptr [esi] - pop esi + mov esi, dword ptr[Source] + fld dword ptr[esi] + fsqrt + mov esi, dword ptr[Dest] + fstp dword ptr[esi] + pop esi } #else __m128 xmm; @@ -2435,97 +2436,97 @@ void R4300iOp::COP1_S_SQRT() xmm = _mm_sqrt_ss(xmm); *(Dest) = _mm_cvtss_f32(xmm); #endif -} + } void R4300iOp::COP1_S_ABS() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); *(float *)_FPR_S[m_Opcode.fd] = (float)fabs(*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_MOV() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); *(float *)_FPR_S[m_Opcode.fd] = *(float *)_FPR_S[m_Opcode.fs]; } void R4300iOp::COP1_S_NEG() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); *(float *)_FPR_S[m_Opcode.fd] = (*(float *)_FPR_S[m_Opcode.fs] * -1.0f); } void R4300iOp::COP1_S_TRUNC_L() { TEST_COP1_USABLE_EXCEPTION - _controlfp(_RC_CHOP,_MCW_RC); - Float_RoundToInteger64(&*(int64_t *)_FPR_D[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); + _controlfp(_RC_CHOP, _MCW_RC); + Float_RoundToInteger64(&*(int64_t *)_FPR_D[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_CEIL_L() { //added by Witten TEST_COP1_USABLE_EXCEPTION - _controlfp(_RC_UP,_MCW_RC); - Float_RoundToInteger64(&*(int64_t *)_FPR_D[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); + _controlfp(_RC_UP, _MCW_RC); + Float_RoundToInteger64(&*(int64_t *)_FPR_D[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_FLOOR_L() { //added by Witten TEST_COP1_USABLE_EXCEPTION - _controlfp(_RC_DOWN,_MCW_RC); - Float_RoundToInteger64(&*(int64_t *)_FPR_D[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); + _controlfp(_RC_DOWN, _MCW_RC); + Float_RoundToInteger64(&*(int64_t *)_FPR_D[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_ROUND_W() { TEST_COP1_USABLE_EXCEPTION - _controlfp(_RC_NEAR,_MCW_RC); - Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); + _controlfp(_RC_NEAR, _MCW_RC); + Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_TRUNC_W() { TEST_COP1_USABLE_EXCEPTION - _controlfp(_RC_CHOP,_MCW_RC); - Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); + _controlfp(_RC_CHOP, _MCW_RC); + Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_CEIL_W() { //added by Witten TEST_COP1_USABLE_EXCEPTION - _controlfp(_RC_UP,_MCW_RC); - Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); + _controlfp(_RC_UP, _MCW_RC); + Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_FLOOR_W() { TEST_COP1_USABLE_EXCEPTION - _controlfp(_RC_DOWN,_MCW_RC); - Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); + _controlfp(_RC_DOWN, _MCW_RC); + Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_CVT_D() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); *(double *)_FPR_D[m_Opcode.fd] = (double)(*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_CVT_W() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); + _controlfp(*_RoundingModel, _MCW_RC); + Float_RoundToInteger32(&*(int32_t *)_FPR_S[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_CVT_L() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - Float_RoundToInteger64(&*(int64_t *)_FPR_D[m_Opcode.fd],&*(float *)_FPR_S[m_Opcode.fs]); + _controlfp(*_RoundingModel, _MCW_RC); + Float_RoundToInteger64(&*(int64_t *)_FPR_D[m_Opcode.fd], &*(float *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_S_CMP() @@ -2552,7 +2553,7 @@ void R4300iOp::COP1_S_CMP() { if (bHaveDebugger()) { - g_Notify->DisplayError(stdstr_f("Signal InvalidOperationException\nin r4300i_COP1_S_CMP\n%X %ff\n%X %ff", Temp0,Temp0,Temp1,Temp1).ToUTF16().c_str()); + g_Notify->DisplayError(stdstr_f("Signal InvalidOperationException\nin r4300i_COP1_S_CMP\n%X %ff\n%X %ff", Temp0, Temp0, Temp1, Temp1).ToUTF16().c_str()); } } } @@ -2577,15 +2578,15 @@ void R4300iOp::COP1_S_CMP() } /************************** COP1: D functions ************************/ -__inline void Double_RoundToInteger32( uint32_t * Dest, double * Source ) +__inline void Double_RoundToInteger32(uint32_t * Dest, double * Source) { #ifdef _M_IX86 _asm { mov esi, [Source] - mov edi, [Dest] - fld qword ptr [esi] - fistp dword ptr [edi] + mov edi, [Dest] + fld qword ptr[esi] + fistp dword ptr[edi] } #else __m128d xmm; @@ -2593,17 +2594,17 @@ __inline void Double_RoundToInteger32( uint32_t * Dest, double * Source ) xmm = _mm_load_sd(Source); *(Dest) = _mm_cvtsd_si32(xmm); #endif -} + } -__inline void Double_RoundToInteger64( uint64_t * Dest, double * Source ) +__inline void Double_RoundToInteger64(uint64_t * Dest, double * Source) { #ifdef _M_IX86 _asm { mov esi, [Source] - mov edi, [Dest] - fld qword ptr [esi] - fistp qword ptr [edi] + mov edi, [Dest] + fld qword ptr[esi] + fistp qword ptr[edi] } #else __m128d xmm; @@ -2611,132 +2612,132 @@ __inline void Double_RoundToInteger64( uint64_t * Dest, double * Source ) xmm = _mm_load_sd(Source); *(Dest) = _mm_cvtsd_si64(xmm); #endif -} + } void R4300iOp::COP1_D_ADD() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); *(double *)_FPR_D[m_Opcode.fd] = *(double *)_FPR_D[m_Opcode.fs] + *(double *)_FPR_D[m_Opcode.ft]; } void R4300iOp::COP1_D_SUB() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); *(double *)_FPR_D[m_Opcode.fd] = *(double *)_FPR_D[m_Opcode.fs] - *(double *)_FPR_D[m_Opcode.ft]; } void R4300iOp::COP1_D_MUL() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); *(double *)_FPR_D[m_Opcode.fd] = *(double *)_FPR_D[m_Opcode.fs] * *(double *)_FPR_D[m_Opcode.ft]; } void R4300iOp::COP1_D_DIV() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); *(double *)_FPR_D[m_Opcode.fd] = *(double *)_FPR_D[m_Opcode.fs] / *(double *)_FPR_D[m_Opcode.ft]; } void R4300iOp::COP1_D_SQRT() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); *(double *)_FPR_D[m_Opcode.fd] = (double)sqrt(*(double *)_FPR_D[m_Opcode.fs]); } void R4300iOp::COP1_D_ABS() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); *(double *)_FPR_D[m_Opcode.fd] = fabs(*(double *)_FPR_D[m_Opcode.fs]); } void R4300iOp::COP1_D_MOV() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); *(int64_t *)_FPR_D[m_Opcode.fd] = *(int64_t *)_FPR_D[m_Opcode.fs]; } void R4300iOp::COP1_D_NEG() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); *(double *)_FPR_D[m_Opcode.fd] = (*(double *)_FPR_D[m_Opcode.fs] * -1.0); } void R4300iOp::COP1_D_TRUNC_L() { //added by Witten TEST_COP1_USABLE_EXCEPTION - _controlfp(RC_CHOP,_MCW_RC); - Double_RoundToInteger64(&*(uint64_t *)_FPR_S[m_Opcode.fd],&*(double *)_FPR_D[m_Opcode.fs] ); + _controlfp(RC_CHOP, _MCW_RC); + Double_RoundToInteger64(&*(uint64_t *)_FPR_S[m_Opcode.fd], &*(double *)_FPR_D[m_Opcode.fs]); } void R4300iOp::COP1_D_CEIL_L() { //added by Witten TEST_COP1_USABLE_EXCEPTION - _controlfp(RC_UP,_MCW_RC); - Double_RoundToInteger64(&*(uint64_t *)_FPR_S[m_Opcode.fd],&*(double *)_FPR_D[m_Opcode.fs] ); + _controlfp(RC_UP, _MCW_RC); + Double_RoundToInteger64(&*(uint64_t *)_FPR_S[m_Opcode.fd], &*(double *)_FPR_D[m_Opcode.fs]); } void R4300iOp::COP1_D_FLOOR_L() { //added by Witten TEST_COP1_USABLE_EXCEPTION - _controlfp(_RC_DOWN,_MCW_RC); - Double_RoundToInteger64(&*(uint64_t *)_FPR_D[m_Opcode.fd],&*(double *)_FPR_S[m_Opcode.fs]); + _controlfp(_RC_DOWN, _MCW_RC); + Double_RoundToInteger64(&*(uint64_t *)_FPR_D[m_Opcode.fd], &*(double *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_D_ROUND_W() { TEST_COP1_USABLE_EXCEPTION - _controlfp(_RC_NEAR,_MCW_RC); - Double_RoundToInteger32(&*(uint32_t *)_FPR_S[m_Opcode.fd],&*(double *)_FPR_D[m_Opcode.fs] ); + _controlfp(_RC_NEAR, _MCW_RC); + Double_RoundToInteger32(&*(uint32_t *)_FPR_S[m_Opcode.fd], &*(double *)_FPR_D[m_Opcode.fs]); } void R4300iOp::COP1_D_TRUNC_W() { TEST_COP1_USABLE_EXCEPTION - _controlfp(RC_CHOP,_MCW_RC); - Double_RoundToInteger32(&*(uint32_t *)_FPR_S[m_Opcode.fd],&*(double *)_FPR_D[m_Opcode.fs] ); + _controlfp(RC_CHOP, _MCW_RC); + Double_RoundToInteger32(&*(uint32_t *)_FPR_S[m_Opcode.fd], &*(double *)_FPR_D[m_Opcode.fs]); } void R4300iOp::COP1_D_CEIL_W() { //added by Witten TEST_COP1_USABLE_EXCEPTION - _controlfp(RC_UP,_MCW_RC); - Double_RoundToInteger32(&*(uint32_t *)_FPR_S[m_Opcode.fd],&*(double *)_FPR_D[m_Opcode.fs] ); + _controlfp(RC_UP, _MCW_RC); + Double_RoundToInteger32(&*(uint32_t *)_FPR_S[m_Opcode.fd], &*(double *)_FPR_D[m_Opcode.fs]); } void R4300iOp::COP1_D_FLOOR_W() { //added by Witten TEST_COP1_USABLE_EXCEPTION - _controlfp(_RC_DOWN,_MCW_RC); - Double_RoundToInteger32(&*(uint32_t *)_FPR_D[m_Opcode.fd],&*(double *)_FPR_S[m_Opcode.fs]); + _controlfp(_RC_DOWN, _MCW_RC); + Double_RoundToInteger32(&*(uint32_t *)_FPR_D[m_Opcode.fd], &*(double *)_FPR_S[m_Opcode.fs]); } void R4300iOp::COP1_D_CVT_S() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); *(float *)_FPR_S[m_Opcode.fd] = (float)*(double *)_FPR_D[m_Opcode.fs]; } void R4300iOp::COP1_D_CVT_W() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - Double_RoundToInteger32(&*(uint32_t *)_FPR_S[m_Opcode.fd],&*(double *)_FPR_D[m_Opcode.fs] ); + _controlfp(*_RoundingModel, _MCW_RC); + Double_RoundToInteger32(&*(uint32_t *)_FPR_S[m_Opcode.fd], &*(double *)_FPR_D[m_Opcode.fs]); } void R4300iOp::COP1_D_CVT_L() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); - Double_RoundToInteger64(&*(uint64_t *)_FPR_D[m_Opcode.fd],&*(double *)_FPR_D[m_Opcode.fs]); + _controlfp(*_RoundingModel, _MCW_RC); + Double_RoundToInteger64(&*(uint64_t *)_FPR_D[m_Opcode.fd], &*(double *)_FPR_D[m_Opcode.fs]); } void R4300iOp::COP1_D_CMP() @@ -2791,14 +2792,14 @@ void R4300iOp::COP1_D_CMP() void R4300iOp::COP1_W_CVT_S() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); *(float *)_FPR_S[m_Opcode.fd] = (float)*(int32_t *)_FPR_S[m_Opcode.fs]; } void R4300iOp::COP1_W_CVT_D() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); *(double *)_FPR_D[m_Opcode.fd] = (double)*(int32_t *)_FPR_S[m_Opcode.fs]; } @@ -2806,14 +2807,14 @@ void R4300iOp::COP1_W_CVT_D() void R4300iOp::COP1_L_CVT_S() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); *(float *)_FPR_S[m_Opcode.fd] = (float)*(int64_t *)_FPR_D[m_Opcode.fs]; } void R4300iOp::COP1_L_CVT_D() { TEST_COP1_USABLE_EXCEPTION - _controlfp(*_RoundingModel,_MCW_RC); + _controlfp(*_RoundingModel, _MCW_RC); *(double *)_FPR_D[m_Opcode.fd] = (double)*(int64_t *)_FPR_D[m_Opcode.fs]; } @@ -2821,10 +2822,10 @@ void R4300iOp::COP1_L_CVT_D() void R4300iOp::UnknownOpcode() { g_Notify->DisplayError(stdstr_f("%s: %08X\n%s\n\nStopping Emulation !", GS(MSG_UNHANDLED_OP), (*_PROGRAM_COUNTER), - R4300iOpcodeName(m_Opcode.Hex,(*_PROGRAM_COUNTER))).ToUTF16().c_str()); + R4300iOpcodeName(m_Opcode.Hex, (*_PROGRAM_COUNTER))).ToUTF16().c_str()); g_System->m_EndEmulation = true; - g_Notify->BreakPoint(__FILEW__,__LINE__); + g_Notify->BreakPoint(__FILEW__,__LINE__); #ifdef tofix if (HaveDebugger && !inFullScreen) { @@ -2838,6 +2839,6 @@ void R4300iOp::UnknownOpcode() Enter_R4300i_Commands_Window (); } ExitThread(0); - } -#endif } +#endif +} \ No newline at end of file diff --git a/Source/Project64/N64 System/Mips/Pif Ram.cpp b/Source/Project64/N64 System/Mips/Pif Ram.cpp index b732877be..05707b241 100644 --- a/Source/Project64/N64 System/Mips/Pif Ram.cpp +++ b/Source/Project64/N64 System/Mips/Pif Ram.cpp @@ -9,271 +9,270 @@ * * ****************************************************************************/ #include "stdafx.h" +#include int CPifRamSettings::m_RefCount = 0; bool CPifRamSettings::m_bShowPifRamErrors = false; CPifRamSettings::CPifRamSettings() { - m_RefCount += 1; - if (m_RefCount == 1) - { - g_Settings->RegisterChangeCB(Debugger_ShowPifErrors,NULL,RefreshSettings); - RefreshSettings(NULL); - } + m_RefCount += 1; + if (m_RefCount == 1) + { + g_Settings->RegisterChangeCB(Debugger_ShowPifErrors, NULL, RefreshSettings); + RefreshSettings(NULL); + } } CPifRamSettings::~CPifRamSettings() { - m_RefCount -= 1; - if (m_RefCount == 0) - { - g_Settings->UnregisterChangeCB(Debugger_ShowPifErrors,NULL,RefreshSettings); - } + m_RefCount -= 1; + if (m_RefCount == 0) + { + g_Settings->UnregisterChangeCB(Debugger_ShowPifErrors, NULL, RefreshSettings); + } } void CPifRamSettings::RefreshSettings(void *) { - m_bShowPifRamErrors = g_Settings->LoadBool(Debugger_ShowPifErrors); + m_bShowPifRamErrors = g_Settings->LoadBool(Debugger_ShowPifErrors); } -CPifRam::CPifRam( bool SavesReadOnly ) : - CEeprom(SavesReadOnly) +CPifRam::CPifRam(bool SavesReadOnly) : +CEeprom(SavesReadOnly) { - Reset(); + Reset(); } CPifRam::~CPifRam() { - } void CPifRam::Reset() { - memset(m_PifRam,0,sizeof(m_PifRam)); - memset(m_PifRom,0,sizeof(m_PifRom)); + memset(m_PifRam, 0, sizeof(m_PifRam)); + memset(m_PifRom, 0, sizeof(m_PifRom)); } void CPifRam::n64_cic_nus_6105(char challenge[], char respone[], int length) { - static char lut0[0x10] = { - 0x4, 0x7, 0xA, 0x7, 0xE, 0x5, 0xE, 0x1, - 0xC, 0xF, 0x8, 0xF, 0x6, 0x3, 0x6, 0x9 - }; - static char lut1[0x10] = { - 0x4, 0x1, 0xA, 0x7, 0xE, 0x5, 0xE, 0x1, - 0xC, 0x9, 0x8, 0x5, 0x6, 0x3, 0xC, 0x9 - }; - char key, *lut; - int i, sgn, mag, mod; + static char lut0[0x10] = { + 0x4, 0x7, 0xA, 0x7, 0xE, 0x5, 0xE, 0x1, + 0xC, 0xF, 0x8, 0xF, 0x6, 0x3, 0x6, 0x9 + }; + static char lut1[0x10] = { + 0x4, 0x1, 0xA, 0x7, 0xE, 0x5, 0xE, 0x1, + 0xC, 0x9, 0x8, 0x5, 0x6, 0x3, 0xC, 0x9 + }; + char key, *lut; + int i, sgn, mag, mod; - for (key = 0xB, lut = lut0, i = 0; i < length; i++) - { - respone[i] = (key + 5 * challenge[i]) & 0xF; - key = lut[respone[i]]; - sgn = (respone[i] >> 3) & 0x1; - mag = ((sgn == 1) ? ~respone[i] : respone[i]) & 0x7; - mod = (mag % 3 == 1) ? sgn : 1 - sgn; - if (lut == lut1 && (respone[i] == 0x1 || respone[i] == 0x9)) - { - mod = 1; - } - if (lut == lut1 && (respone[i] == 0xB || respone[i] == 0xE)) - { - mod = 0; - } - lut = (mod == 1) ? lut1 : lut0; - } + for (key = 0xB, lut = lut0, i = 0; i < length; i++) + { + respone[i] = (key + 5 * challenge[i]) & 0xF; + key = lut[respone[i]]; + sgn = (respone[i] >> 3) & 0x1; + mag = ((sgn == 1) ? ~respone[i] : respone[i]) & 0x7; + mod = (mag % 3 == 1) ? sgn : 1 - sgn; + if (lut == lut1 && (respone[i] == 0x1 || respone[i] == 0x9)) + { + mod = 1; + } + if (lut == lut1 && (respone[i] == 0xB || respone[i] == 0xE)) + { + mod = 0; + } + lut = (mod == 1) ? lut1 : lut0; + } } - void CPifRam::PifRamRead() { - if (m_PifRam[0x3F] == 0x2) - { - return; - } + if (m_PifRam[0x3F] == 0x2) + { + return; + } - CONTROL * Controllers = g_Plugins->Control()->PluginControllers(); + CONTROL * Controllers = g_Plugins->Control()->PluginControllers(); - int Channel = 0; - for (int CurPos = 0; CurPos < 0x40; CurPos ++) - { - switch (m_PifRam[CurPos]) - { - case 0x00: - Channel += 1; - if (Channel > 6) - { - CurPos = 0x40; - } - break; - case 0xFE: CurPos = 0x40; break; - case 0xFF: break; - case 0xB4: case 0x56: case 0xB8: break; /* ??? */ - default: - if ((m_PifRam[CurPos] & 0xC0) == 0) - { - if (Channel < 4) - { - if (Controllers[Channel].Present && Controllers[Channel].RawData) - { - if (g_Plugins->Control()->ReadController) - { - g_Plugins->Control()->ReadController(Channel,&m_PifRam[CurPos]); - } - } - else - { - ReadControllerCommand(Channel,&m_PifRam[CurPos]); - } - } - CurPos += m_PifRam[CurPos] + (m_PifRam[CurPos + 1] & 0x3F) + 1; - Channel += 1; - } - else - { - if (bShowPifRamErrors()) - { - g_Notify->DisplayError(stdstr_f("Unknown Command in PifRamRead(%X)",m_PifRam[CurPos]).ToUTF16().c_str()); - } - CurPos = 0x40; - } - break; - } - } - if (g_Plugins->Control()->ReadController) - { - g_Plugins->Control()->ReadController(-1,NULL); - } + int Channel = 0; + for (int CurPos = 0; CurPos < 0x40; CurPos++) + { + switch (m_PifRam[CurPos]) + { + case 0x00: + Channel += 1; + if (Channel > 6) + { + CurPos = 0x40; + } + break; + case 0xFE: CurPos = 0x40; break; + case 0xFF: break; + case 0xB4: case 0x56: case 0xB8: break; /* ??? */ + default: + if ((m_PifRam[CurPos] & 0xC0) == 0) + { + if (Channel < 4) + { + if (Controllers[Channel].Present && Controllers[Channel].RawData) + { + if (g_Plugins->Control()->ReadController) + { + g_Plugins->Control()->ReadController(Channel, &m_PifRam[CurPos]); + } + } + else + { + ReadControllerCommand(Channel, &m_PifRam[CurPos]); + } + } + CurPos += m_PifRam[CurPos] + (m_PifRam[CurPos + 1] & 0x3F) + 1; + Channel += 1; + } + else + { + if (bShowPifRamErrors()) + { + g_Notify->DisplayError(stdstr_f("Unknown Command in PifRamRead(%X)", m_PifRam[CurPos]).ToUTF16().c_str()); + } + CurPos = 0x40; + } + break; + } + } + if (g_Plugins->Control()->ReadController) + { + g_Plugins->Control()->ReadController(-1, NULL); + } } void CPifRam::PifRamWrite() { - CONTROL * Controllers = g_Plugins->Control()->PluginControllers(); - int Channel = 0, CurPos; + CONTROL * Controllers = g_Plugins->Control()->PluginControllers(); + int Channel = 0, CurPos; - if ( m_PifRam[0x3F] > 0x1) - { - switch (m_PifRam[0x3F]) - { - case 0x02: - // format the 'challenge' message into 30 nibbles for X-Scale's CIC code - { - char Challenge[30], Response[30]; - for (int i = 0; i < 15; i++) - { - Challenge[i*2] = (m_PifRam[48+i] >> 4) & 0x0f; - Challenge[i*2+1] = m_PifRam[48+i] & 0x0f; - } - n64_cic_nus_6105(Challenge, Response, CHALLENGE_LENGTH - 2); - QWORD ResponseValue = 0; - m_PifRam[46] = m_PifRam[47] = 0x00; - for (int z = 8; z > 0; z--) - { - ResponseValue = (ResponseValue << 8) | ((Response[(z - 1)*2] << 4) + Response[(z - 1)*2+1]); - } - std::memcpy(&m_PifRam[48], &ResponseValue, sizeof(QWORD)); - ResponseValue = 0; - for (int z = 7; z > 0; z--) - { - ResponseValue = (ResponseValue << 8) | ((Response[((z + 8) - 1)*2] << 4) + Response[((z + 8) - 1)*2+1]); - } - std::memcpy(&m_PifRam[56], &ResponseValue, sizeof(QWORD)); - } - break; - case 0x08: - m_PifRam[0x3F] = 0; - g_Reg->MI_INTR_REG |= MI_INTR_SI; - g_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT; - g_Reg->CheckInterrupts(); - break; - case 0x10: - memset(m_PifRom,0,0x7C0); - break; - case 0x30: - m_PifRam[0x3F] = 0x80; - break; - case 0xC0: - memset(m_PifRam,0,0x40); - break; - default: - if (bShowPifRamErrors()) - { - g_Notify->DisplayError(stdstr_f("Unkown PifRam control: %d",m_PifRam[0x3F]).ToUTF16().c_str()); - } - } - return; - } + if (m_PifRam[0x3F] > 0x1) + { + switch (m_PifRam[0x3F]) + { + case 0x02: + // format the 'challenge' message into 30 nibbles for X-Scale's CIC code + { + char Challenge[30], Response[30]; + for (int i = 0; i < 15; i++) + { + Challenge[i * 2] = (m_PifRam[48 + i] >> 4) & 0x0f; + Challenge[i * 2 + 1] = m_PifRam[48 + i] & 0x0f; + } + n64_cic_nus_6105(Challenge, Response, CHALLENGE_LENGTH - 2); + QWORD ResponseValue = 0; + m_PifRam[46] = m_PifRam[47] = 0x00; + for (int z = 8; z > 0; z--) + { + ResponseValue = (ResponseValue << 8) | ((Response[(z - 1) * 2] << 4) + Response[(z - 1) * 2 + 1]); + } + std::memcpy(&m_PifRam[48], &ResponseValue, sizeof(QWORD)); + ResponseValue = 0; + for (int z = 7; z > 0; z--) + { + ResponseValue = (ResponseValue << 8) | ((Response[((z + 8) - 1) * 2] << 4) + Response[((z + 8) - 1) * 2 + 1]); + } + std::memcpy(&m_PifRam[56], &ResponseValue, sizeof(QWORD)); + } + break; + case 0x08: + m_PifRam[0x3F] = 0; + g_Reg->MI_INTR_REG |= MI_INTR_SI; + g_Reg->SI_STATUS_REG |= SI_STATUS_INTERRUPT; + g_Reg->CheckInterrupts(); + break; + case 0x10: + memset(m_PifRom, 0, 0x7C0); + break; + case 0x30: + m_PifRam[0x3F] = 0x80; + break; + case 0xC0: + memset(m_PifRam, 0, 0x40); + break; + default: + if (bShowPifRamErrors()) + { + g_Notify->DisplayError(stdstr_f("Unkown PifRam control: %d", m_PifRam[0x3F]).ToUTF16().c_str()); + } + } + return; + } - for (CurPos = 0; CurPos < 0x40; CurPos++) - { - switch (m_PifRam[CurPos]) - { - case 0x00: - Channel += 1; - if (Channel > 6) - { - CurPos = 0x40; - } - break; - case 0xFE: CurPos = 0x40; break; - case 0xFF: break; - case 0xB4: case 0x56: case 0xB8: break; /* ??? */ - default: - if ((m_PifRam[CurPos] & 0xC0) == 0) - { - if (Channel < 4) - { - if (Controllers[Channel].Present && Controllers[Channel].RawData) - { - if (g_Plugins->Control()->ControllerCommand) - { - g_Plugins->Control()->ControllerCommand(Channel,&m_PifRam[CurPos]); - } - } - else - { - ProcessControllerCommand(Channel,&m_PifRam[CurPos]); - } - } - else if (Channel == 4) - { - EepromCommand(&m_PifRam[CurPos]); - } - else - { - if (bShowPifRamErrors()) - { - g_Notify->DisplayError(L"Command on channel 5?"); - } - } - CurPos += m_PifRam[CurPos] + (m_PifRam[CurPos + 1] & 0x3F) + 1; - Channel += 1; - } - else - { - if (bShowPifRamErrors()) - { - g_Notify->DisplayError(stdstr_f("Unknown Command in PifRamWrite(%X)",m_PifRam[CurPos]).ToUTF16().c_str()); - } - CurPos = 0x40; - } - break; - } - } - m_PifRam[0x3F] = 0; - if (g_Plugins->Control()->ControllerCommand) - { - g_Plugins->Control()->ControllerCommand(-1,NULL); - } + for (CurPos = 0; CurPos < 0x40; CurPos++) + { + switch (m_PifRam[CurPos]) + { + case 0x00: + Channel += 1; + if (Channel > 6) + { + CurPos = 0x40; + } + break; + case 0xFE: CurPos = 0x40; break; + case 0xFF: break; + case 0xB4: case 0x56: case 0xB8: break; /* ??? */ + default: + if ((m_PifRam[CurPos] & 0xC0) == 0) + { + if (Channel < 4) + { + if (Controllers[Channel].Present && Controllers[Channel].RawData) + { + if (g_Plugins->Control()->ControllerCommand) + { + g_Plugins->Control()->ControllerCommand(Channel, &m_PifRam[CurPos]); + } + } + else + { + ProcessControllerCommand(Channel, &m_PifRam[CurPos]); + } + } + else if (Channel == 4) + { + EepromCommand(&m_PifRam[CurPos]); + } + else + { + if (bShowPifRamErrors()) + { + g_Notify->DisplayError(L"Command on channel 5?"); + } + } + CurPos += m_PifRam[CurPos] + (m_PifRam[CurPos + 1] & 0x3F) + 1; + Channel += 1; + } + else + { + if (bShowPifRamErrors()) + { + g_Notify->DisplayError(stdstr_f("Unknown Command in PifRamWrite(%X)", m_PifRam[CurPos]).ToUTF16().c_str()); + } + CurPos = 0x40; + } + break; + } + } + m_PifRam[0x3F] = 0; + if (g_Plugins->Control()->ControllerCommand) + { + g_Plugins->Control()->ControllerCommand(-1, NULL); + } } -void CPifRam::SI_DMA_READ() +void CPifRam::SI_DMA_READ() { - BYTE * PifRamPos = m_PifRam; - BYTE * RDRAM = g_MMU->Rdram(); - + BYTE * PifRamPos = m_PifRam; + BYTE * RDRAM = g_MMU->Rdram(); + uint32_t & SI_DRAM_ADDR_REG = (uint32_t &)g_Reg->SI_DRAM_ADDR_REG; if ((int32_t)SI_DRAM_ADDR_REG > (int32_t)g_System->RdramSize()) { @@ -302,9 +301,9 @@ void CPifRam::SI_DMA_READ() } else { - for (size_t i = 0; i < 64; i++) - { - RDRAM[(SI_DRAM_ADDR_REG + i) ^ 3] = PifRamPos[i]; + for (size_t i = 0; i < 64; i++) + { + RDRAM[(SI_DRAM_ADDR_REG + i) ^ 3] = PifRamPos[i]; } } @@ -314,31 +313,31 @@ void CPifRam::SI_DMA_READ() char HexData[100], AsciiData[100], Addon[20]; LogMessage("\tData DMAed to RDRAM:"); LogMessage("\t--------------------"); - for (count = 0; count < 16; count ++ ) + for (count = 0; count < 16; count++) { if ((count % 4) == 0) { - sprintf(HexData,"\0"); - sprintf(AsciiData,"\0"); + sprintf(HexData, "\0"); + sprintf(AsciiData, "\0"); } - sprintf(Addon,"%02X %02X %02X %02X", + sprintf(Addon, "%02X %02X %02X %02X", m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1], - m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] ); - strcat(HexData,Addon); + m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3]); + strcat(HexData, Addon); if (((count + 1) % 4) != 0) { - sprintf(Addon,"-"); - strcat(HexData,Addon); + sprintf(Addon, "-"); + strcat(HexData, Addon); } - sprintf(Addon,"%c%c%c%c", + sprintf(Addon, "%c%c%c%c", m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1], - m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] ); - strcat(AsciiData,Addon); + m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3]); + strcat(AsciiData, Addon); if (((count + 1) % 4) == 0) { - LogMessage("\t%s %s",HexData, AsciiData); + LogMessage("\t%s %s", HexData, AsciiData); } } LogMessage(""); @@ -388,9 +387,9 @@ void CPifRam::SI_DMA_WRITE() } else { - for (size_t i = 0; i < 64; i++) + for (size_t i = 0; i < 64; i++) { - PifRamPos[i] = RDRAM[(SI_DRAM_ADDR_REG + i) ^ 3]; + PifRamPos[i] = RDRAM[(SI_DRAM_ADDR_REG + i) ^ 3]; } } @@ -401,31 +400,31 @@ void CPifRam::SI_DMA_WRITE() LogMessage(""); LogMessage("\tData DMAed to the Pif Ram:"); LogMessage("\t--------------------------"); - for (count = 0; count < 16; count ++ ) + for (count = 0; count < 16; count++) { if ((count % 4) == 0) { - sprintf(HexData,"\0"); - sprintf(AsciiData,"\0"); + sprintf(HexData, "\0"); + sprintf(AsciiData, "\0"); } - sprintf(Addon,"%02X %02X %02X %02X", + sprintf(Addon, "%02X %02X %02X %02X", m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1], - m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] ); - strcat(HexData,Addon); + m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3]); + strcat(HexData, Addon); if (((count + 1) % 4) != 0) { - sprintf(Addon,"-"); - strcat(HexData,Addon); + sprintf(Addon, "-"); + strcat(HexData, Addon); } - sprintf(Addon,"%c%c%c%c", + sprintf(Addon, "%c%c%c%c", m_PifRam[(count << 2) + 0], m_PifRam[(count << 2) + 1], - m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3] ); - strcat(AsciiData,Addon); + m_PifRam[(count << 2) + 2], m_PifRam[(count << 2) + 3]); + strcat(AsciiData, Addon); if (((count + 1) % 4) == 0) { - LogMessage("\t%s %s",HexData, AsciiData); + LogMessage("\t%s %s", HexData, AsciiData); } } LogMessage(""); @@ -445,237 +444,237 @@ void CPifRam::SI_DMA_WRITE() } } -void CPifRam::ProcessControllerCommand ( int Control, BYTE * Command) +void CPifRam::ProcessControllerCommand(int Control, BYTE * Command) { - CONTROL * Controllers = g_Plugins->Control()->PluginControllers(); + CONTROL * Controllers = g_Plugins->Control()->PluginControllers(); - switch (Command[2]) - { - case 0x00: // check - case 0xFF: // reset & check ? - if ((Command[1] & 0x80) != 0) - { - break; - } - if (bShowPifRamErrors()) - { - if (Command[0] != 1) - { - g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); - } - if (Command[1] != 3) - { - g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); - } - } - if (Controllers[Control].Present == TRUE) - { - Command[3] = 0x05; - Command[4] = 0x00; - switch ( Controllers[Control].Plugin) - { - case PLUGIN_TANSFER_PAK: - case PLUGIN_RUMBLE_PAK: - case PLUGIN_MEMPAK: - case PLUGIN_RAW: - Command[5] = 1; break; - default: Command[5] = 0; break; - } - } - else - { - Command[1] |= 0x80; - } - break; - case 0x01: // read controller - if (bShowPifRamErrors()) - { - if (Command[0] != 1) - { - g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); - } - if (Command[1] != 4) - { - g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); - } - } - if (Controllers[Control].Present == FALSE) - { - Command[1] |= 0x80; - } - break; - case 0x02: //read from controller pack - if (g_LogOptions.LogControllerPak) - { - LogControllerPakData("Read: Before Gettting Results"); - } - if (bShowPifRamErrors()) - { - if (Command[0] != 3) - { - g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); - } - if (Command[1] != 33) - { - g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); - } - } - if (Controllers[Control].Present == TRUE) - { - switch (Controllers[Control].Plugin) - { - case PLUGIN_RUMBLE_PAK: Rumblepak::ReadFrom(Command); break; - case PLUGIN_MEMPAK: Mempak::ReadFrom(Control, Command); break; - case PLUGIN_TANSFER_PAK: /* TODO */; break; - case PLUGIN_RAW: if (g_Plugins->Control()->ControllerCommand) { g_Plugins->Control()->ControllerCommand(Control, Command); } break; - default: - memset(&Command[5], 0, 0x20); - } + switch (Command[2]) + { + case 0x00: // check + case 0xFF: // reset & check ? + if ((Command[1] & 0x80) != 0) + { + break; + } + if (bShowPifRamErrors()) + { + if (Command[0] != 1) + { + g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); + } + if (Command[1] != 3) + { + g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); + } + } + if (Controllers[Control].Present == TRUE) + { + Command[3] = 0x05; + Command[4] = 0x00; + switch (Controllers[Control].Plugin) + { + case PLUGIN_TANSFER_PAK: + case PLUGIN_RUMBLE_PAK: + case PLUGIN_MEMPAK: + case PLUGIN_RAW: + Command[5] = 1; break; + default: Command[5] = 0; break; + } + } + else + { + Command[1] |= 0x80; + } + break; + case 0x01: // read controller + if (bShowPifRamErrors()) + { + if (Command[0] != 1) + { + g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); + } + if (Command[1] != 4) + { + g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); + } + } + if (Controllers[Control].Present == FALSE) + { + Command[1] |= 0x80; + } + break; + case 0x02: //read from controller pack + if (g_LogOptions.LogControllerPak) + { + LogControllerPakData("Read: Before Gettting Results"); + } + if (bShowPifRamErrors()) + { + if (Command[0] != 3) + { + g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); + } + if (Command[1] != 33) + { + g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); + } + } + if (Controllers[Control].Present == TRUE) + { + switch (Controllers[Control].Plugin) + { + case PLUGIN_RUMBLE_PAK: Rumblepak::ReadFrom(Command); break; + case PLUGIN_MEMPAK: Mempak::ReadFrom(Control, Command); break; + case PLUGIN_TANSFER_PAK: /* TODO */; break; + case PLUGIN_RAW: if (g_Plugins->Control()->ControllerCommand) { g_Plugins->Control()->ControllerCommand(Control, Command); } break; + default: + memset(&Command[5], 0, 0x20); + } - if (Controllers[Control].Plugin != PLUGIN_RAW) - { - Command[0x25] = Mempak::CalculateCrc(&Command[5]); - } - } - else - { - Command[1] |= 0x80; - } - if (g_LogOptions.LogControllerPak) - { - LogControllerPakData("Read: After Gettting Results"); - } - break; - case 0x03: //write controller pak - if (g_LogOptions.LogControllerPak) - { - LogControllerPakData("Write: Before Processing"); - } - if (bShowPifRamErrors()) - { - if (Command[0] != 35) - { - g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); - } - if (Command[1] != 1) - { - g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); - } - } - if (Controllers[Control].Present == TRUE) - { - switch (Controllers[Control].Plugin) - { - case PLUGIN_MEMPAK: Mempak::WriteTo(Control, Command); break; - case PLUGIN_RUMBLE_PAK: Rumblepak::WriteTo(Control, Command); break; - case PLUGIN_TANSFER_PAK: /* TODO */; break; - case PLUGIN_RAW: if (g_Plugins->Control()->ControllerCommand) { g_Plugins->Control()->ControllerCommand(Control, Command); } break; - } + if (Controllers[Control].Plugin != PLUGIN_RAW) + { + Command[0x25] = Mempak::CalculateCrc(&Command[5]); + } + } + else + { + Command[1] |= 0x80; + } + if (g_LogOptions.LogControllerPak) + { + LogControllerPakData("Read: After Gettting Results"); + } + break; + case 0x03: //write controller pak + if (g_LogOptions.LogControllerPak) + { + LogControllerPakData("Write: Before Processing"); + } + if (bShowPifRamErrors()) + { + if (Command[0] != 35) + { + g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); + } + if (Command[1] != 1) + { + g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); + } + } + if (Controllers[Control].Present == TRUE) + { + switch (Controllers[Control].Plugin) + { + case PLUGIN_MEMPAK: Mempak::WriteTo(Control, Command); break; + case PLUGIN_RUMBLE_PAK: Rumblepak::WriteTo(Control, Command); break; + case PLUGIN_TANSFER_PAK: /* TODO */; break; + case PLUGIN_RAW: if (g_Plugins->Control()->ControllerCommand) { g_Plugins->Control()->ControllerCommand(Control, Command); } break; + } - if (Controllers[Control].Plugin != PLUGIN_RAW) - { - Command[0x25] = Mempak::CalculateCrc(&Command[5]); - } - } - else - { - Command[1] |= 0x80; - } - if (g_LogOptions.LogControllerPak) - { - LogControllerPakData("Write: After Processing"); - } - break; - default: - if (bShowPifRamErrors()) - { - g_Notify->DisplayError(stdstr_f("Unknown ControllerCommand %d",Command[2]).ToUTF16().c_str()); - } - } + if (Controllers[Control].Plugin != PLUGIN_RAW) + { + Command[0x25] = Mempak::CalculateCrc(&Command[5]); + } + } + else + { + Command[1] |= 0x80; + } + if (g_LogOptions.LogControllerPak) + { + LogControllerPakData("Write: After Processing"); + } + break; + default: + if (bShowPifRamErrors()) + { + g_Notify->DisplayError(stdstr_f("Unknown ControllerCommand %d", Command[2]).ToUTF16().c_str()); + } + } } -void CPifRam::ReadControllerCommand (int Control, BYTE * Command) { - CONTROL * Controllers = g_Plugins->Control()->PluginControllers(); +void CPifRam::ReadControllerCommand(int Control, BYTE * Command) { + CONTROL * Controllers = g_Plugins->Control()->PluginControllers(); - switch (Command[2]) - { - case 0x01: // read controller - if (Controllers[Control].Present == TRUE) - { - if (bShowPifRamErrors()) - { - if (Command[0] != 1) { g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); } - if (Command[1] != 4) { g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); } - } + switch (Command[2]) + { + case 0x01: // read controller + if (Controllers[Control].Present == TRUE) + { + if (bShowPifRamErrors()) + { + if (Command[0] != 1) { g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); } + if (Command[1] != 4) { g_Notify->DisplayError(L"What am I meant to do with this Controller Command"); } + } - const DWORD buttons = g_BaseSystem->GetButtons(Control); - std::memcpy(&Command[3], &buttons, sizeof(DWORD)); - } - break; - case 0x02: //read from controller pack - if (Controllers[Control].Present == TRUE) - { - switch (Controllers[Control].Plugin) - { - case PLUGIN_RAW: if (g_Plugins->Control()->ReadController) { g_Plugins->Control()->ReadController(Control, Command); } break; - } - } - break; - case 0x03: //write controller pak - if (Controllers[Control].Present == TRUE) - { - switch (Controllers[Control].Plugin) - { - case PLUGIN_RAW: if (g_Plugins->Control()->ReadController) { g_Plugins->Control()->ReadController(Control, Command); } break; - } - } - break; - } + const DWORD buttons = g_BaseSystem->GetButtons(Control); + std::memcpy(&Command[3], &buttons, sizeof(DWORD)); + } + break; + case 0x02: //read from controller pack + if (Controllers[Control].Present == TRUE) + { + switch (Controllers[Control].Plugin) + { + case PLUGIN_RAW: if (g_Plugins->Control()->ReadController) { g_Plugins->Control()->ReadController(Control, Command); } break; + } + } + break; + case 0x03: //write controller pak + if (Controllers[Control].Present == TRUE) + { + switch (Controllers[Control].Plugin) + { + case PLUGIN_RAW: if (g_Plugins->Control()->ReadController) { g_Plugins->Control()->ReadController(Control, Command); } break; + } + } + break; + } } -void CPifRam::LogControllerPakData (char * Description) +void CPifRam::LogControllerPakData(char * Description) { - BYTE * PIF_Ram = g_MMU->PifRam(); + BYTE * PIF_Ram = g_MMU->PifRam(); - int count, count2; - char HexData[100], AsciiData[100], Addon[20]; - LogMessage("\t%s:",Description); - LogMessage("\t------------------------------"); - for (count = 0; count < 16; count ++ ) - { - if ((count % 4) == 0) - { - sprintf(HexData,"\0"); - sprintf(AsciiData,"\0"); - } - sprintf(Addon,"%02X %02X %02X %02X", - PIF_Ram[(count << 2) + 0], PIF_Ram[(count << 2) + 1], - PIF_Ram[(count << 2) + 2], PIF_Ram[(count << 2) + 3] ); - strcat(HexData,Addon); - if (((count + 1) % 4) != 0) - { - sprintf(Addon,"-"); - strcat(HexData,Addon); - } - - Addon[0] = 0; - for (count2 = 0; count2 < 4; count2++) - { - if (PIF_Ram[(count << 2) + count2] < 30) - { - strcat(Addon,"."); - } - else - { - sprintf(Addon,"%s%c",Addon,PIF_Ram[(count << 2) + count2]); - } - } - strcat(AsciiData,Addon); - - if (((count + 1) % 4) == 0) - { - LogMessage("\t%s %s",HexData, AsciiData); - } - } - LogMessage(""); -} + int count, count2; + char HexData[100], AsciiData[100], Addon[20]; + LogMessage("\t%s:", Description); + LogMessage("\t------------------------------"); + for (count = 0; count < 16; count++) + { + if ((count % 4) == 0) + { + sprintf(HexData, "\0"); + sprintf(AsciiData, "\0"); + } + sprintf(Addon, "%02X %02X %02X %02X", + PIF_Ram[(count << 2) + 0], PIF_Ram[(count << 2) + 1], + PIF_Ram[(count << 2) + 2], PIF_Ram[(count << 2) + 3]); + strcat(HexData, Addon); + if (((count + 1) % 4) != 0) + { + sprintf(Addon, "-"); + strcat(HexData, Addon); + } + + Addon[0] = 0; + for (count2 = 0; count2 < 4; count2++) + { + if (PIF_Ram[(count << 2) + count2] < 30) + { + strcat(Addon, "."); + } + else + { + sprintf(Addon, "%s%c", Addon, PIF_Ram[(count << 2) + count2]); + } + } + strcat(AsciiData, Addon); + + if (((count + 1) % 4) == 0) + { + LogMessage("\t%s %s", HexData, AsciiData); + } + } + LogMessage(""); +} \ No newline at end of file diff --git a/Source/Project64/N64 System/Mips/Register Class.cpp b/Source/Project64/N64 System/Mips/Register Class.cpp index 7983bb7c3..c66ba1fb5 100644 --- a/Source/Project64/N64 System/Mips/Register Class.cpp +++ b/Source/Project64/N64 System/Mips/Register Class.cpp @@ -9,42 +9,43 @@ * * ****************************************************************************/ #include "stdafx.h" +#include -const char * CRegName::GPR[32] = {"r0","at","v0","v1","a0","a1","a2","a3", - "t0","t1","t2","t3","t4","t5","t6","t7", - "s0","s1","s2","s3","s4","s5","s6","s7", - "t8","t9","k0","k1","gp","sp","s8","ra"}; +const char * CRegName::GPR[32] = { "r0", "at", "v0", "v1", "a0", "a1", "a2", "a3", +"t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", +"s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", +"t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra" }; -const char *CRegName::GPR_Hi[32] = {"r0.HI","at.HI","v0.HI","v1.HI","a0.HI","a1.HI", - "a2.HI","a3.HI","t0.HI","t1.HI","t2.HI","t3.HI", - "t4.HI","t5.HI","t6.HI","t7.HI","s0.HI","s1.HI", - "s2.HI","s3.HI","s4.HI","s5.HI","s6.HI","s7.HI", - "t8.HI","t9.HI","k0.HI","k1.HI","gp.HI","sp.HI", - "s8.HI","ra.HI"}; +const char *CRegName::GPR_Hi[32] = { "r0.HI", "at.HI", "v0.HI", "v1.HI", "a0.HI", "a1.HI", +"a2.HI", "a3.HI", "t0.HI", "t1.HI", "t2.HI", "t3.HI", +"t4.HI", "t5.HI", "t6.HI", "t7.HI", "s0.HI", "s1.HI", +"s2.HI", "s3.HI", "s4.HI", "s5.HI", "s6.HI", "s7.HI", +"t8.HI", "t9.HI", "k0.HI", "k1.HI", "gp.HI", "sp.HI", +"s8.HI", "ra.HI" }; -const char *CRegName::GPR_Lo[32] = {"r0.LO","at.LO","v0.LO","v1.LO","a0.LO","a1.LO", - "a2.LO","a3.LO","t0.LO","t1.LO","t2.LO","t3.LO", - "t4.LO","t5.LO","t6.LO","t7.LO","s0.LO","s1.LO", - "s2.LO","s3.LO","s4.LO","s5.LO","s6.LO","s7.LO", - "t8.LO","t9.LO","k0.LO","k1.LO","gp.LO","sp.LO", - "s8.LO","ra.LO"}; +const char *CRegName::GPR_Lo[32] = { "r0.LO", "at.LO", "v0.LO", "v1.LO", "a0.LO", "a1.LO", +"a2.LO", "a3.LO", "t0.LO", "t1.LO", "t2.LO", "t3.LO", +"t4.LO", "t5.LO", "t6.LO", "t7.LO", "s0.LO", "s1.LO", +"s2.LO", "s3.LO", "s4.LO", "s5.LO", "s6.LO", "s7.LO", +"t8.LO", "t9.LO", "k0.LO", "k1.LO", "gp.LO", "sp.LO", +"s8.LO", "ra.LO" }; -const char * CRegName::Cop0[32] = {"Index","Random","EntryLo0","EntryLo1","Context","PageMask","Wired","", - "BadVAddr","Count","EntryHi","Compare","Status","Cause","EPC","PRId", - "Config","LLAddr","WatchLo","WatchHi","XContext","","","", - "","","ECC","CacheErr","TagLo","TagHi","ErrEPC",""}; +const char * CRegName::Cop0[32] = { "Index", "Random", "EntryLo0", "EntryLo1", "Context", "PageMask", "Wired", "", +"BadVAddr", "Count", "EntryHi", "Compare", "Status", "Cause", "EPC", "PRId", +"Config", "LLAddr", "WatchLo", "WatchHi", "XContext", "", "", "", +"", "", "ECC", "CacheErr", "TagLo", "TagHi", "ErrEPC", "" }; -const char * CRegName::FPR[32] = {"f0","f1","f2","f3","f4","f5","f6","f7", - "f8","f9","f10","f11","f12","f13","f14","f15", - "f16","f17","f18","f19","f20","f21","f22","f23", - "f24","f25","f26","f27","f28","f29","f30","f31"}; +const char * CRegName::FPR[32] = { "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", +"f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", +"f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", +"f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31" }; -const char * CRegName::FPR_Ctrl[32] = {"Revision","Unknown","Unknown","Unknown","Unknown", - "Unknown","Unknown","Unknown","Unknown","Unknown","Unknown", - "Unknown","Unknown","Unknown","Unknown","Unknown","Unknown", - "Unknown","Unknown","Unknown","Unknown","Unknown","Unknown", - "Unknown","Unknown","Unknown","Unknown","Unknown","Unknown", - "Unknown","Unknown","FCSR"}; +const char * CRegName::FPR_Ctrl[32] = { "Revision", "Unknown", "Unknown", "Unknown", "Unknown", +"Unknown", "Unknown", "Unknown", "Unknown", "Unknown", "Unknown", +"Unknown", "Unknown", "Unknown", "Unknown", "Unknown", "Unknown", +"Unknown", "Unknown", "Unknown", "Unknown", "Unknown", "Unknown", +"Unknown", "Unknown", "Unknown", "Unknown", "Unknown", "Unknown", +"Unknown", "Unknown", "FCSR" }; uint32_t * CSystemRegisters::_PROGRAM_COUNTER = NULL; MIPS_DWORD * CSystemRegisters::_GPR = NULL; @@ -59,169 +60,169 @@ uint32_t * CSystemRegisters::_LLBit = NULL; ROUNDING_MODE * CSystemRegisters::_RoundingModel = NULL; CP0registers::CP0registers(uint32_t * _CP0) : - INDEX_REGISTER(_CP0[0]), - RANDOM_REGISTER(_CP0[1]), - ENTRYLO0_REGISTER(_CP0[2]), - ENTRYLO1_REGISTER(_CP0[3]), - CONTEXT_REGISTER(_CP0[4]), - PAGE_MASK_REGISTER(_CP0[5]), - WIRED_REGISTER(_CP0[6]), - BAD_VADDR_REGISTER(_CP0[8]), - COUNT_REGISTER(_CP0[9]), - ENTRYHI_REGISTER(_CP0[10]), - COMPARE_REGISTER(_CP0[11]), - STATUS_REGISTER(_CP0[12]), - CAUSE_REGISTER(_CP0[13]), - EPC_REGISTER(_CP0[14]), - CONFIG_REGISTER(_CP0[16]), - TAGLO_REGISTER(_CP0[28]), - TAGHI_REGISTER(_CP0[29]), - ERROREPC_REGISTER(_CP0[30]), - FAKE_CAUSE_REGISTER(_CP0[32]) +INDEX_REGISTER(_CP0[0]), +RANDOM_REGISTER(_CP0[1]), +ENTRYLO0_REGISTER(_CP0[2]), +ENTRYLO1_REGISTER(_CP0[3]), +CONTEXT_REGISTER(_CP0[4]), +PAGE_MASK_REGISTER(_CP0[5]), +WIRED_REGISTER(_CP0[6]), +BAD_VADDR_REGISTER(_CP0[8]), +COUNT_REGISTER(_CP0[9]), +ENTRYHI_REGISTER(_CP0[10]), +COMPARE_REGISTER(_CP0[11]), +STATUS_REGISTER(_CP0[12]), +CAUSE_REGISTER(_CP0[13]), +EPC_REGISTER(_CP0[14]), +CONFIG_REGISTER(_CP0[16]), +TAGLO_REGISTER(_CP0[28]), +TAGHI_REGISTER(_CP0[29]), +ERROREPC_REGISTER(_CP0[30]), +FAKE_CAUSE_REGISTER(_CP0[32]) { } Rdram_InterfaceReg::Rdram_InterfaceReg(uint32_t * _RdramInterface) : - RDRAM_CONFIG_REG(_RdramInterface[0]), - RDRAM_DEVICE_TYPE_REG(_RdramInterface[0]), - RDRAM_DEVICE_ID_REG(_RdramInterface[1]), - RDRAM_DELAY_REG(_RdramInterface[2]), - RDRAM_MODE_REG(_RdramInterface[3]), - RDRAM_REF_INTERVAL_REG(_RdramInterface[4]), - RDRAM_REF_ROW_REG(_RdramInterface[5]), - RDRAM_RAS_INTERVAL_REG(_RdramInterface[6]), - RDRAM_MIN_INTERVAL_REG(_RdramInterface[7]), - RDRAM_ADDR_SELECT_REG(_RdramInterface[8]), - RDRAM_DEVICE_MANUF_REG(_RdramInterface[9]) +RDRAM_CONFIG_REG(_RdramInterface[0]), +RDRAM_DEVICE_TYPE_REG(_RdramInterface[0]), +RDRAM_DEVICE_ID_REG(_RdramInterface[1]), +RDRAM_DELAY_REG(_RdramInterface[2]), +RDRAM_MODE_REG(_RdramInterface[3]), +RDRAM_REF_INTERVAL_REG(_RdramInterface[4]), +RDRAM_REF_ROW_REG(_RdramInterface[5]), +RDRAM_RAS_INTERVAL_REG(_RdramInterface[6]), +RDRAM_MIN_INTERVAL_REG(_RdramInterface[7]), +RDRAM_ADDR_SELECT_REG(_RdramInterface[8]), +RDRAM_DEVICE_MANUF_REG(_RdramInterface[9]) { } Mips_InterfaceReg::Mips_InterfaceReg(uint32_t * _MipsInterface) : - MI_INIT_MODE_REG(_MipsInterface[0]), - MI_MODE_REG(_MipsInterface[0]), - MI_VERSION_REG(_MipsInterface[1]), - MI_NOOP_REG(_MipsInterface[1]), - MI_INTR_REG(_MipsInterface[2]), - MI_INTR_MASK_REG(_MipsInterface[3]) +MI_INIT_MODE_REG(_MipsInterface[0]), +MI_MODE_REG(_MipsInterface[0]), +MI_VERSION_REG(_MipsInterface[1]), +MI_NOOP_REG(_MipsInterface[1]), +MI_INTR_REG(_MipsInterface[2]), +MI_INTR_MASK_REG(_MipsInterface[3]) { } Video_InterfaceReg::Video_InterfaceReg(uint32_t * _VideoInterface) : - VI_STATUS_REG(_VideoInterface[0]), - VI_CONTROL_REG(_VideoInterface[0]), - VI_ORIGIN_REG(_VideoInterface[1]), - VI_DRAM_ADDR_REG(_VideoInterface[1]), - VI_WIDTH_REG(_VideoInterface[2]), - VI_H_WIDTH_REG(_VideoInterface[2]), - VI_INTR_REG(_VideoInterface[3]), - VI_V_INTR_REG(_VideoInterface[3]), - VI_CURRENT_REG(_VideoInterface[4]), - VI_V_CURRENT_LINE_REG(_VideoInterface[4]), - VI_BURST_REG(_VideoInterface[5]), - VI_TIMING_REG(_VideoInterface[5]), - VI_V_SYNC_REG(_VideoInterface[6]), - VI_H_SYNC_REG(_VideoInterface[7]), - VI_LEAP_REG(_VideoInterface[8]), - VI_H_SYNC_LEAP_REG(_VideoInterface[8]), - VI_H_START_REG(_VideoInterface[9]), - VI_H_VIDEO_REG(_VideoInterface[9]), - VI_V_START_REG(_VideoInterface[10]), - VI_V_VIDEO_REG(_VideoInterface[10]), - VI_V_BURST_REG(_VideoInterface[11]), - VI_X_SCALE_REG(_VideoInterface[12]), - VI_Y_SCALE_REG(_VideoInterface[13]) +VI_STATUS_REG(_VideoInterface[0]), +VI_CONTROL_REG(_VideoInterface[0]), +VI_ORIGIN_REG(_VideoInterface[1]), +VI_DRAM_ADDR_REG(_VideoInterface[1]), +VI_WIDTH_REG(_VideoInterface[2]), +VI_H_WIDTH_REG(_VideoInterface[2]), +VI_INTR_REG(_VideoInterface[3]), +VI_V_INTR_REG(_VideoInterface[3]), +VI_CURRENT_REG(_VideoInterface[4]), +VI_V_CURRENT_LINE_REG(_VideoInterface[4]), +VI_BURST_REG(_VideoInterface[5]), +VI_TIMING_REG(_VideoInterface[5]), +VI_V_SYNC_REG(_VideoInterface[6]), +VI_H_SYNC_REG(_VideoInterface[7]), +VI_LEAP_REG(_VideoInterface[8]), +VI_H_SYNC_LEAP_REG(_VideoInterface[8]), +VI_H_START_REG(_VideoInterface[9]), +VI_H_VIDEO_REG(_VideoInterface[9]), +VI_V_START_REG(_VideoInterface[10]), +VI_V_VIDEO_REG(_VideoInterface[10]), +VI_V_BURST_REG(_VideoInterface[11]), +VI_X_SCALE_REG(_VideoInterface[12]), +VI_Y_SCALE_REG(_VideoInterface[13]) { } AudioInterfaceReg::AudioInterfaceReg(uint32_t * _AudioInterface) : - AI_DRAM_ADDR_REG(_AudioInterface[0]), - AI_LEN_REG(_AudioInterface[1]), - AI_CONTROL_REG(_AudioInterface[2]), - AI_STATUS_REG(_AudioInterface[3]), - AI_DACRATE_REG(_AudioInterface[4]), - AI_BITRATE_REG(_AudioInterface[5]) +AI_DRAM_ADDR_REG(_AudioInterface[0]), +AI_LEN_REG(_AudioInterface[1]), +AI_CONTROL_REG(_AudioInterface[2]), +AI_STATUS_REG(_AudioInterface[3]), +AI_DACRATE_REG(_AudioInterface[4]), +AI_BITRATE_REG(_AudioInterface[5]) { } PeripheralInterfaceReg::PeripheralInterfaceReg(uint32_t * PeripheralInterface) : - PI_DRAM_ADDR_REG(PeripheralInterface[0]), - PI_CART_ADDR_REG(PeripheralInterface[1]), - PI_RD_LEN_REG(PeripheralInterface[2]), - PI_WR_LEN_REG(PeripheralInterface[3]), - PI_STATUS_REG(PeripheralInterface[4]), - PI_BSD_DOM1_LAT_REG(PeripheralInterface[5]), - PI_DOMAIN1_REG(PeripheralInterface[5]), - PI_BSD_DOM1_PWD_REG(PeripheralInterface[6]), - PI_BSD_DOM1_PGS_REG(PeripheralInterface[7]), - PI_BSD_DOM1_RLS_REG(PeripheralInterface[8]), - PI_BSD_DOM2_LAT_REG(PeripheralInterface[9]), - PI_DOMAIN2_REG(PeripheralInterface[9]), - PI_BSD_DOM2_PWD_REG(PeripheralInterface[10]), - PI_BSD_DOM2_PGS_REG(PeripheralInterface[11]), - PI_BSD_DOM2_RLS_REG(PeripheralInterface[12]) +PI_DRAM_ADDR_REG(PeripheralInterface[0]), +PI_CART_ADDR_REG(PeripheralInterface[1]), +PI_RD_LEN_REG(PeripheralInterface[2]), +PI_WR_LEN_REG(PeripheralInterface[3]), +PI_STATUS_REG(PeripheralInterface[4]), +PI_BSD_DOM1_LAT_REG(PeripheralInterface[5]), +PI_DOMAIN1_REG(PeripheralInterface[5]), +PI_BSD_DOM1_PWD_REG(PeripheralInterface[6]), +PI_BSD_DOM1_PGS_REG(PeripheralInterface[7]), +PI_BSD_DOM1_RLS_REG(PeripheralInterface[8]), +PI_BSD_DOM2_LAT_REG(PeripheralInterface[9]), +PI_DOMAIN2_REG(PeripheralInterface[9]), +PI_BSD_DOM2_PWD_REG(PeripheralInterface[10]), +PI_BSD_DOM2_PGS_REG(PeripheralInterface[11]), +PI_BSD_DOM2_RLS_REG(PeripheralInterface[12]) { } RDRAMInt_InterfaceReg::RDRAMInt_InterfaceReg(uint32_t * RdramInterface) : - RI_MODE_REG(RdramInterface[0]), - RI_CONFIG_REG(RdramInterface[1]), - RI_CURRENT_LOAD_REG(RdramInterface[2]), - RI_SELECT_REG(RdramInterface[3]), - RI_COUNT_REG(RdramInterface[4]), - RI_REFRESH_REG(RdramInterface[4]), - RI_LATENCY_REG(RdramInterface[5]), - RI_RERROR_REG(RdramInterface[6]), - RI_WERROR_REG(RdramInterface[7]) +RI_MODE_REG(RdramInterface[0]), +RI_CONFIG_REG(RdramInterface[1]), +RI_CURRENT_LOAD_REG(RdramInterface[2]), +RI_SELECT_REG(RdramInterface[3]), +RI_COUNT_REG(RdramInterface[4]), +RI_REFRESH_REG(RdramInterface[4]), +RI_LATENCY_REG(RdramInterface[5]), +RI_RERROR_REG(RdramInterface[6]), +RI_WERROR_REG(RdramInterface[7]) { } DisplayControlReg::DisplayControlReg(uint32_t * _DisplayProcessor) : - DPC_START_REG(_DisplayProcessor[0]), - DPC_END_REG(_DisplayProcessor[1]), - DPC_CURRENT_REG(_DisplayProcessor[2]), - DPC_STATUS_REG(_DisplayProcessor[3]), - DPC_CLOCK_REG(_DisplayProcessor[4]), - DPC_BUFBUSY_REG(_DisplayProcessor[5]), - DPC_PIPEBUSY_REG(_DisplayProcessor[6]), - DPC_TMEM_REG(_DisplayProcessor[7]) +DPC_START_REG(_DisplayProcessor[0]), +DPC_END_REG(_DisplayProcessor[1]), +DPC_CURRENT_REG(_DisplayProcessor[2]), +DPC_STATUS_REG(_DisplayProcessor[3]), +DPC_CLOCK_REG(_DisplayProcessor[4]), +DPC_BUFBUSY_REG(_DisplayProcessor[5]), +DPC_PIPEBUSY_REG(_DisplayProcessor[6]), +DPC_TMEM_REG(_DisplayProcessor[7]) { } SigProcessor_InterfaceReg::SigProcessor_InterfaceReg(uint32_t * _SignalProcessorInterface) : - SP_MEM_ADDR_REG(_SignalProcessorInterface[0]), - SP_DRAM_ADDR_REG(_SignalProcessorInterface[1]), - SP_RD_LEN_REG(_SignalProcessorInterface[2]), - SP_WR_LEN_REG(_SignalProcessorInterface[3]), - SP_STATUS_REG(_SignalProcessorInterface[4]), - SP_DMA_FULL_REG(_SignalProcessorInterface[5]), - SP_DMA_BUSY_REG(_SignalProcessorInterface[6]), - SP_SEMAPHORE_REG(_SignalProcessorInterface[7]), - SP_PC_REG(_SignalProcessorInterface[8]), - SP_IBIST_REG(_SignalProcessorInterface[9]) +SP_MEM_ADDR_REG(_SignalProcessorInterface[0]), +SP_DRAM_ADDR_REG(_SignalProcessorInterface[1]), +SP_RD_LEN_REG(_SignalProcessorInterface[2]), +SP_WR_LEN_REG(_SignalProcessorInterface[3]), +SP_STATUS_REG(_SignalProcessorInterface[4]), +SP_DMA_FULL_REG(_SignalProcessorInterface[5]), +SP_DMA_BUSY_REG(_SignalProcessorInterface[6]), +SP_SEMAPHORE_REG(_SignalProcessorInterface[7]), +SP_PC_REG(_SignalProcessorInterface[8]), +SP_IBIST_REG(_SignalProcessorInterface[9]) { } Serial_InterfaceReg::Serial_InterfaceReg(uint32_t * SerialInterface) : - SI_DRAM_ADDR_REG(SerialInterface[0]), - SI_PIF_ADDR_RD64B_REG(SerialInterface[1]), - SI_PIF_ADDR_WR64B_REG(SerialInterface[2]), - SI_STATUS_REG(SerialInterface[3]) +SI_DRAM_ADDR_REG(SerialInterface[0]), +SI_PIF_ADDR_RD64B_REG(SerialInterface[1]), +SI_PIF_ADDR_WR64B_REG(SerialInterface[2]), +SI_STATUS_REG(SerialInterface[3]) { } CRegisters::CRegisters(CN64System * System, CSystemEvents * SystemEvents) : - CP0registers(m_CP0), - Rdram_InterfaceReg(m_RDRAM_Registers), - Mips_InterfaceReg(m_Mips_Interface), - Video_InterfaceReg(m_Video_Interface), - AudioInterfaceReg(m_Audio_Interface), - PeripheralInterfaceReg(m_Peripheral_Interface), - RDRAMInt_InterfaceReg(m_RDRAM_Interface), - SigProcessor_InterfaceReg(m_SigProcessor_Interface), - DisplayControlReg(m_Display_ControlReg), - Serial_InterfaceReg(m_SerialInterface), - m_System(System), - m_SystemEvents(SystemEvents) +CP0registers(m_CP0), +Rdram_InterfaceReg(m_RDRAM_Registers), +Mips_InterfaceReg(m_Mips_Interface), +Video_InterfaceReg(m_Video_Interface), +AudioInterfaceReg(m_Audio_Interface), +PeripheralInterfaceReg(m_Peripheral_Interface), +RDRAMInt_InterfaceReg(m_RDRAM_Interface), +SigProcessor_InterfaceReg(m_SigProcessor_Interface), +DisplayControlReg(m_Display_ControlReg), +Serial_InterfaceReg(m_SerialInterface), +m_System(System), +m_SystemEvents(SystemEvents) { Reset(); } @@ -230,26 +231,26 @@ void CRegisters::Reset() { m_FirstInterupt = true; - memset(m_GPR,0,sizeof(m_GPR)); - memset(m_CP0,0,sizeof(m_CP0)); - memset(m_FPR,0,sizeof(m_FPR)); - memset(m_FPCR,0,sizeof(m_FPCR)); - m_HI.DW = 0; - m_LO.DW = 0; + memset(m_GPR, 0, sizeof(m_GPR)); + memset(m_CP0, 0, sizeof(m_CP0)); + memset(m_FPR, 0, sizeof(m_FPR)); + memset(m_FPCR, 0, sizeof(m_FPCR)); + m_HI.DW = 0; + m_LO.DW = 0; m_RoundingModel = ROUND_NEAR; - m_LLBit = 0; + m_LLBit = 0; //Reset System Registers - memset(m_RDRAM_Interface,0,sizeof(m_RDRAM_Interface)); - memset(m_RDRAM_Registers,0,sizeof(m_RDRAM_Registers)); - memset(m_Mips_Interface,0,sizeof(m_Mips_Interface)); - memset(m_Video_Interface,0,sizeof(m_Video_Interface)); - memset(m_Display_ControlReg,0,sizeof(m_Display_ControlReg)); - memset(m_Audio_Interface,0,sizeof(m_Audio_Interface)); - memset(m_SigProcessor_Interface,0,sizeof(m_SigProcessor_Interface)); - memset(m_Peripheral_Interface,0,sizeof(m_Peripheral_Interface)); - memset(m_SerialInterface,0,sizeof(m_SerialInterface)); + memset(m_RDRAM_Interface, 0, sizeof(m_RDRAM_Interface)); + memset(m_RDRAM_Registers, 0, sizeof(m_RDRAM_Registers)); + memset(m_Mips_Interface, 0, sizeof(m_Mips_Interface)); + memset(m_Video_Interface, 0, sizeof(m_Video_Interface)); + memset(m_Display_ControlReg, 0, sizeof(m_Display_ControlReg)); + memset(m_Audio_Interface, 0, sizeof(m_Audio_Interface)); + memset(m_SigProcessor_Interface, 0, sizeof(m_SigProcessor_Interface)); + memset(m_Peripheral_Interface, 0, sizeof(m_Peripheral_Interface)); + memset(m_SerialInterface, 0, sizeof(m_SerialInterface)); m_AudioIntrReg = 0; m_GfxIntrReg = 0; @@ -291,27 +292,27 @@ void CRegisters::CheckInterrupts() FAKE_CAUSE_REGISTER &= ~CAUSE_IP2; } - if (( STATUS_REGISTER & STATUS_IE ) == 0 ) + if ((STATUS_REGISTER & STATUS_IE) == 0) { return; } - if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) + if ((STATUS_REGISTER & STATUS_EXL) != 0) { return; } - if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) + if ((STATUS_REGISTER & STATUS_ERL) != 0) { return; } - if (( STATUS_REGISTER & FAKE_CAUSE_REGISTER & 0xFF00) != 0) + if ((STATUS_REGISTER & FAKE_CAUSE_REGISTER & 0xFF00) != 0) { if (m_FirstInterupt) { m_FirstInterupt = false; if (g_Recompiler) { - g_Recompiler->ClearRecompCode_Virt(0x80000000,0x200,CRecompiler::Remove_InitialCode); + g_Recompiler->ClearRecompCode_Virt(0x80000000, 0x200, CRecompiler::Remove_InitialCode); } } m_SystemEvents->QueueEvent(SysEvent_ExecuteInterrupt); @@ -323,11 +324,11 @@ void CRegisters::DoAddressError(bool DelaySlot, uint32_t BadVaddr, bool FromRead if (bHaveDebugger()) { g_Notify->DisplayError(L"AddressError"); - if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) + if ((STATUS_REGISTER & STATUS_EXL) != 0) { g_Notify->DisplayError(L"EXL set in AddressError Exception"); } - if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) + if ((STATUS_REGISTER & STATUS_ERL) != 0) { g_Notify->DisplayError(L"ERL set in AddressError Exception"); } @@ -359,7 +360,7 @@ void CRegisters::FixFpuLocations() { if ((STATUS_REGISTER & STATUS_FR) == 0) { - for (int count = 0; count < 32; count ++) + for (int count = 0; count < 32; count++) { m_FPR_S[count] = &m_FPR[count >> 1].F[count & 1]; m_FPR_D[count] = &m_FPR[count >> 1].D; @@ -367,7 +368,7 @@ void CRegisters::FixFpuLocations() } else { - for (int count = 0; count < 32; count ++) { + for (int count = 0; count < 32; count++) { m_FPR_S[count] = &m_FPR[count].F[1]; m_FPR_D[count] = &m_FPR[count].D; } @@ -378,11 +379,11 @@ void CRegisters::DoBreakException(bool DelaySlot) { if (bHaveDebugger()) { - if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) + if ((STATUS_REGISTER & STATUS_EXL) != 0) { g_Notify->DisplayError(L"EXL set in Break Exception"); } - if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) + if ((STATUS_REGISTER & STATUS_ERL) != 0) { g_Notify->DisplayError(L"ERL set in Break Exception"); } @@ -406,11 +407,11 @@ void CRegisters::DoCopUnusableException(bool DelaySlot, int Coprocessor) { if (bHaveDebugger()) { - if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) + if ((STATUS_REGISTER & STATUS_EXL) != 0) { g_Notify->DisplayError(L"EXL set in Break Exception"); } - if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) + if ((STATUS_REGISTER & STATUS_ERL) != 0) { g_Notify->DisplayError(L"ERL set in Break Exception"); } @@ -506,7 +507,7 @@ void CRegisters::DoTLBReadMiss(bool DelaySlot, uint32_t BadVaddr) { if (bHaveDebugger()) { - g_Notify->DisplayError(stdstr_f("TLBMiss - EXL Set\nBadVaddr = %X\nAddress Defined: %s",BadVaddr,g_TLB->AddressDefined(BadVaddr)?"TRUE":"FALSE").ToUTF16().c_str()); + g_Notify->DisplayError(stdstr_f("TLBMiss - EXL Set\nBadVaddr = %X\nAddress Defined: %s", BadVaddr, g_TLB->AddressDefined(BadVaddr) ? "TRUE" : "FALSE").ToUTF16().c_str()); } m_PROGRAM_COUNTER = 0x80000180; } @@ -516,11 +517,11 @@ void CRegisters::DoSysCallException(bool DelaySlot) { if (bHaveDebugger()) { - if (( STATUS_REGISTER & STATUS_EXL ) != 0 ) + if ((STATUS_REGISTER & STATUS_EXL) != 0) { g_Notify->DisplayError(L"EXL set in SysCall Exception"); } - if (( STATUS_REGISTER & STATUS_ERL ) != 0 ) + if ((STATUS_REGISTER & STATUS_ERL) != 0) { g_Notify->DisplayError(L"ERL set in SysCall Exception"); } @@ -538,4 +539,4 @@ void CRegisters::DoSysCallException(bool DelaySlot) } STATUS_REGISTER |= STATUS_EXL; m_PROGRAM_COUNTER = 0x80000180; -} +} \ No newline at end of file diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index cd70b8a1a..87dfca5d7 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -9,6 +9,7 @@ * * ****************************************************************************/ #include "stdafx.h" +#include #pragma warning(disable:4355) // Disable 'this' : used in base member initializer list @@ -459,7 +460,6 @@ void CN64System::Pause() Notify().DisplayMessage(5, MSG_CPU_RESUMED); } - void CN64System::GameReset() { m_SystemTimer.SetTimer(CSystemTimer::SoftResetTimer, 0x3000000, false); diff --git a/Source/Project64/Project64.vcxproj b/Source/Project64/Project64.vcxproj index 517fca83e..256bc4408 100644 --- a/Source/Project64/Project64.vcxproj +++ b/Source/Project64/Project64.vcxproj @@ -44,7 +44,6 @@ - @@ -81,6 +80,7 @@ + @@ -176,7 +176,6 @@ - @@ -187,6 +186,7 @@ + diff --git a/Source/Project64/Project64.vcxproj.filters b/Source/Project64/Project64.vcxproj.filters index 437ae1cbf..f387c0509 100644 --- a/Source/Project64/Project64.vcxproj.filters +++ b/Source/Project64/Project64.vcxproj.filters @@ -417,8 +417,8 @@ Source Files\User Interface Source - - Source Files + + Source Files\User Interface Source @@ -827,11 +827,11 @@ Header Files\User Interface Headers - - Header Files - Header Files\Settings Headers + + Header Files\User Interface Headers + \ No newline at end of file diff --git a/Source/Project64/User Interface/LoggingUI.cpp b/Source/Project64/User Interface/LoggingUI.cpp new file mode 100644 index 000000000..ff95a6c56 --- /dev/null +++ b/Source/Project64/User Interface/LoggingUI.cpp @@ -0,0 +1,920 @@ +/**************************************************************************** +* * +* Project64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2012 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +#include "stdafx.h" +#include "LoggingUI.h" + +#include + +void LoadLogSetting(HKEY hKey, char * String, bool * Value); +void SaveLogOptions(void); + +LRESULT CALLBACK LogGeneralProc(HWND, UINT, WPARAM, LPARAM); +LRESULT CALLBACK LogPifProc(HWND, UINT, WPARAM, LPARAM); +LRESULT CALLBACK LogRegProc(HWND, UINT, WPARAM, LPARAM); + +static HANDLE g_hLogFile = NULL; +LOG_OPTIONS g_LogOptions, TempOptions; + +void EnterLogOptions(HWND hwndOwner) +{ + PROPSHEETPAGE psp[3]; + PROPSHEETHEADER psh; + + psp[0].dwSize = sizeof(PROPSHEETPAGE); + psp[0].dwFlags = PSP_USETITLE; + psp[0].hInstance = GetModuleHandle(NULL); + psp[0].pszTemplate = MAKEINTRESOURCE(IDD_Logging_Registers); + psp[0].pfnDlgProc = (DLGPROC)LogRegProc; + psp[0].pszTitle = "Registers"; + psp[0].lParam = 0; + psp[0].pfnCallback = NULL; + + psp[1].dwSize = sizeof(PROPSHEETPAGE); + psp[1].dwFlags = PSP_USETITLE; + psp[1].hInstance = GetModuleHandle(NULL); + psp[1].pszTemplate = MAKEINTRESOURCE(IDD_Logging_PifRam); + psp[1].pfnDlgProc = (DLGPROC)LogPifProc; + psp[1].pszTitle = "Pif Ram"; + psp[1].lParam = 0; + psp[1].pfnCallback = NULL; + + psp[2].dwSize = sizeof(PROPSHEETPAGE); + psp[2].dwFlags = PSP_USETITLE; + psp[2].hInstance = GetModuleHandle(NULL); + psp[2].pszTemplate = MAKEINTRESOURCE(IDD_Logging_General); + psp[2].pfnDlgProc = (DLGPROC)LogGeneralProc; + psp[2].pszTitle = "General"; + psp[2].lParam = 0; + psp[2].pfnCallback = NULL; + + psh.dwSize = sizeof(PROPSHEETHEADER); + psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW; + psh.hwndParent = hwndOwner; + psh.hInstance = GetModuleHandle(NULL); + psh.pszCaption = (LPSTR) "Log Options"; + psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE); + psh.nStartPage = 0; + psh.ppsp = (LPCPROPSHEETPAGE)&psp; + psh.pfnCallback = NULL; + + LoadLogOptions(&TempOptions, TRUE); +#if defined(WINDOWS_UI) + PropertySheet(&psh); +#else + g_Notify -> BreakPoint(__FILEW__, __LINE__); +#endif + SaveLogOptions(); + LoadLogOptions(&g_LogOptions, FALSE); + return; +} + +void LoadLogOptions(LOG_OPTIONS * LogOptions, bool AlwaysFill) +{ + int32_t lResult; + HKEY hKeyResults = 0; + char String[200]; + + sprintf(String, "Software\\N64 Emulation\\%s\\Logging", g_Settings->LoadStringVal(Setting_ApplicationName).c_str()); + lResult = RegOpenKeyEx(HKEY_CURRENT_USER, String, 0, KEY_ALL_ACCESS, + &hKeyResults); + + if (lResult == ERROR_SUCCESS) + { + //LoadLogSetting(hKeyResults,"Generate Log File",&LogOptions->GenerateLog); + if (LogOptions->GenerateLog || AlwaysFill) + { + LoadLogSetting(hKeyResults, "Log RDRAM", &LogOptions->LogRDRamRegisters); + LoadLogSetting(hKeyResults, "Log SP", &LogOptions->LogSPRegisters); + LoadLogSetting(hKeyResults, "Log DP Command", &LogOptions->LogDPCRegisters); + LoadLogSetting(hKeyResults, "Log DP Span", &LogOptions->LogDPSRegisters); + LoadLogSetting(hKeyResults, "Log MIPS Interface (MI)", &LogOptions->LogMIPSInterface); + LoadLogSetting(hKeyResults, "Log Video Interface (VI)", &LogOptions->LogVideoInterface); + LoadLogSetting(hKeyResults, "Log Audio Interface (AI)", &LogOptions->LogAudioInterface); + LoadLogSetting(hKeyResults, "Log Peripheral Interface (PI)", &LogOptions->LogPerInterface); + LoadLogSetting(hKeyResults, "Log RDRAM Interface (RI)", &LogOptions->LogRDRAMInterface); + LoadLogSetting(hKeyResults, "Log Serial Interface (SI)", &LogOptions->LogSerialInterface); + LoadLogSetting(hKeyResults, "Log PifRam DMA Operations", &LogOptions->LogPRDMAOperations); + LoadLogSetting(hKeyResults, "Log PifRam Direct Memory Loads", &LogOptions->LogPRDirectMemLoads); + LoadLogSetting(hKeyResults, "Log PifRam DMA Memory Loads", &LogOptions->LogPRDMAMemLoads); + LoadLogSetting(hKeyResults, "Log PifRam Direct Memory Stores", &LogOptions->LogPRDirectMemStores); + LoadLogSetting(hKeyResults, "Log PifRam DMA Memory Stores", &LogOptions->LogPRDMAMemStores); + LoadLogSetting(hKeyResults, "Log Controller Pak", &LogOptions->LogControllerPak); + LoadLogSetting(hKeyResults, "Log CP0 changes", &LogOptions->LogCP0changes); + LoadLogSetting(hKeyResults, "Log CP0 reads", &LogOptions->LogCP0reads); + LoadLogSetting(hKeyResults, "Log Exceptions", &LogOptions->LogExceptions); + LoadLogSetting(hKeyResults, "No Interrupts", &LogOptions->NoInterrupts); + LoadLogSetting(hKeyResults, "Log TLB", &LogOptions->LogTLB); + LoadLogSetting(hKeyResults, "Log Cache Operations", &LogOptions->LogCache); + LoadLogSetting(hKeyResults, "Log Rom Header", &LogOptions->LogRomHeader); + LoadLogSetting(hKeyResults, "Log Unknown access", &LogOptions->LogUnknown); + return; + } + } + + LogOptions->GenerateLog = FALSE; + LogOptions->LogRDRamRegisters = FALSE; + LogOptions->LogSPRegisters = FALSE; + LogOptions->LogDPCRegisters = FALSE; + LogOptions->LogDPSRegisters = FALSE; + LogOptions->LogMIPSInterface = FALSE; + LogOptions->LogVideoInterface = FALSE; + LogOptions->LogAudioInterface = FALSE; + LogOptions->LogPerInterface = FALSE; + LogOptions->LogRDRAMInterface = FALSE; + LogOptions->LogSerialInterface = FALSE; + + LogOptions->LogPRDMAOperations = FALSE; + LogOptions->LogPRDirectMemLoads = FALSE; + LogOptions->LogPRDMAMemLoads = FALSE; + LogOptions->LogPRDirectMemStores = FALSE; + LogOptions->LogPRDMAMemStores = FALSE; + LogOptions->LogControllerPak = FALSE; + + LogOptions->LogCP0changes = FALSE; + LogOptions->LogCP0reads = FALSE; + LogOptions->LogCache = FALSE; + LogOptions->LogExceptions = FALSE; + LogOptions->NoInterrupts = FALSE; + LogOptions->LogTLB = FALSE; + LogOptions->LogRomHeader = FALSE; + LogOptions->LogUnknown = FALSE; +} + +void LoadLogSetting(HKEY hKey, char * String, bool * Value) +{ + DWORD Type, dwResult, Bytes = 4; + int32_t lResult; + + lResult = RegQueryValueEx(hKey, String, 0, &Type, (LPBYTE)(&dwResult), &Bytes); + if (Type == REG_DWORD && lResult == ERROR_SUCCESS) + { + *Value = dwResult != 0; + } + else + { + *Value = FALSE; + } +} + +LRESULT CALLBACK LogGeneralProc(HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam) +{ + switch (uMsg) + { + case WM_INITDIALOG: + if (TempOptions.LogCP0changes) { CheckDlgButton(hDlg, IDC_CP0_WRITE, BST_CHECKED); } + if (TempOptions.LogCP0reads) { CheckDlgButton(hDlg, IDC_CP0_READ, BST_CHECKED); } + if (TempOptions.LogCache) { CheckDlgButton(hDlg, IDC_CACHE, BST_CHECKED); } + if (TempOptions.LogExceptions) { CheckDlgButton(hDlg, IDC_EXCEPTIONS, BST_CHECKED); } + if (TempOptions.NoInterrupts) { CheckDlgButton(hDlg, IDC_INTERRUPTS, BST_CHECKED); } + if (TempOptions.LogTLB) { CheckDlgButton(hDlg, IDC_TLB, BST_CHECKED); } + if (TempOptions.LogRomHeader) { CheckDlgButton(hDlg, IDC_ROM_HEADER, BST_CHECKED); } + if (TempOptions.LogUnknown) { CheckDlgButton(hDlg, IDC_UNKOWN, BST_CHECKED); } + break; + case WM_NOTIFY: + if (((NMHDR FAR *) lParam)->code != PSN_APPLY) { break; } + TempOptions.LogCP0changes = IsDlgButtonChecked(hDlg, IDC_CP0_WRITE) == BST_CHECKED ? TRUE : FALSE; + TempOptions.LogCP0reads = IsDlgButtonChecked(hDlg, IDC_CP0_READ) == BST_CHECKED ? TRUE : FALSE; + TempOptions.LogCache = IsDlgButtonChecked(hDlg, IDC_CACHE) == BST_CHECKED ? TRUE : FALSE; + TempOptions.LogExceptions = IsDlgButtonChecked(hDlg, IDC_EXCEPTIONS) == BST_CHECKED ? TRUE : FALSE; + TempOptions.NoInterrupts = IsDlgButtonChecked(hDlg, IDC_INTERRUPTS) == BST_CHECKED ? TRUE : FALSE; + TempOptions.LogTLB = IsDlgButtonChecked(hDlg, IDC_TLB) == BST_CHECKED ? TRUE : FALSE; + TempOptions.LogRomHeader = IsDlgButtonChecked(hDlg, IDC_ROM_HEADER) == BST_CHECKED ? TRUE : FALSE; + TempOptions.LogUnknown = IsDlgButtonChecked(hDlg, IDC_UNKOWN) == BST_CHECKED ? TRUE : FALSE; + break; + default: + return FALSE; + } + return TRUE; +} + +void Log_LW(uint32_t PC, uint32_t VAddr) +{ + if (!g_LogOptions.GenerateLog) + { + return; + } + + if (VAddr < 0xA0000000 || VAddr >= 0xC0000000) + { + uint32_t PAddr; + if (!g_TransVaddr->TranslateVaddr(VAddr, PAddr)) + { + if (g_LogOptions.LogUnknown) + { + LogMessage("%08X: read from unknown ??? (%08X)", PC, VAddr); + } + return; + } + VAddr = PAddr + 0xA0000000; + } + + uint32_t Value; + if (VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize())) + { + return; + } + if (VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) + { + if (!g_LogOptions.LogRDRamRegisters) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + + switch (VAddr) + { + case 0xA3F00000: LogMessage("%08X: read from RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG (%08X)", PC, Value); return; + case 0xA3F00004: LogMessage("%08X: read from RDRAM_DEVICE_ID_REG (%08X)", PC, Value); return; + case 0xA3F00008: LogMessage("%08X: read from RDRAM_DELAY_REG (%08X)", PC, Value); return; + case 0xA3F0000C: LogMessage("%08X: read from RDRAM_MODE_REG (%08X)", PC, Value); return; + case 0xA3F00010: LogMessage("%08X: read from RDRAM_REF_INTERVAL_REG (%08X)", PC, Value); return; + case 0xA3F00014: LogMessage("%08X: read from RDRAM_REF_ROW_REG (%08X)", PC, Value); return; + case 0xA3F00018: LogMessage("%08X: read from RDRAM_RAS_INTERVAL_REG (%08X)", PC, Value); return; + case 0xA3F0001C: LogMessage("%08X: read from RDRAM_MIN_INTERVAL_REG (%08X)", PC, Value); return; + case 0xA3F00020: LogMessage("%08X: read from RDRAM_ADDR_SELECT_REG (%08X)", PC, Value); return; + case 0xA3F00024: LogMessage("%08X: read from RDRAM_DEVICE_MANUF_REG (%08X)", PC, Value); return; + } + } + + if (VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC) + { + return; + } + if (VAddr >= 0xA4040000 && VAddr <= 0xA404001C) + { + if (!g_LogOptions.LogSPRegisters) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + + switch (VAddr) + { + case 0xA4040000: LogMessage("%08X: read from SP_MEM_ADDR_REG (%08X)", PC, Value); break; + case 0xA4040004: LogMessage("%08X: read from SP_DRAM_ADDR_REG (%08X)", PC, Value); break; + case 0xA4040008: LogMessage("%08X: read from SP_RD_LEN_REG (%08X)", PC, Value); break; + case 0xA404000C: LogMessage("%08X: read from SP_WR_LEN_REG (%08X)", PC, Value); break; + case 0xA4040010: LogMessage("%08X: read from SP_STATUS_REG (%08X)", PC, Value); break; + case 0xA4040014: LogMessage("%08X: read from SP_DMA_FULL_REG (%08X)", PC, Value); break; + case 0xA4040018: LogMessage("%08X: read from SP_DMA_BUSY_REG (%08X)", PC, Value); break; + case 0xA404001C: LogMessage("%08X: read from SP_SEMAPHORE_REG (%08X)", PC, Value); break; + } + return; + } + if (VAddr == 0xA4080000) + { + if (!g_LogOptions.LogSPRegisters) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + LogMessage("%08X: read from SP_PC (%08X)", PC, Value); + return; + } + if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C) + { + if (!g_LogOptions.LogDPCRegisters) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + + switch (VAddr) + { + case 0xA4100000: LogMessage("%08X: read from DPC_START_REG (%08X)", PC, Value); return; + case 0xA4100004: LogMessage("%08X: read from DPC_END_REG (%08X)", PC, Value); return; + case 0xA4100008: LogMessage("%08X: read from DPC_CURRENT_REG (%08X)", PC, Value); return; + case 0xA410000C: LogMessage("%08X: read from DPC_STATUS_REG (%08X)", PC, Value); return; + case 0xA4100010: LogMessage("%08X: read from DPC_CLOCK_REG (%08X)", PC, Value); return; + case 0xA4100014: LogMessage("%08X: read from DPC_BUFBUSY_REG (%08X)", PC, Value); return; + case 0xA4100018: LogMessage("%08X: read from DPC_PIPEBUSY_REG (%08X)", PC, Value); return; + case 0xA410001C: LogMessage("%08X: read from DPC_TMEM_REG (%08X)", PC, Value); return; + } + } + if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C) + { + if (!g_LogOptions.LogMIPSInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + + switch (VAddr) + { + case 0xA4300000: LogMessage("%08X: read from MI_INIT_MODE_REG/MI_MODE_REG (%08X)", PC, Value); return; + case 0xA4300004: LogMessage("%08X: read from MI_VERSION_REG/MI_NOOP_REG (%08X)", PC, Value); return; + case 0xA4300008: LogMessage("%08X: read from MI_INTR_REG (%08X)", PC, Value); return; + case 0xA430000C: LogMessage("%08X: read from MI_INTR_MASK_REG (%08X)", PC, Value); return; + } + } + if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034) + { + if (!g_LogOptions.LogVideoInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + + switch (VAddr) + { + case 0xA4400000: LogMessage("%08X: read from VI_STATUS_REG/VI_CONTROL_REG (%08X)", PC, Value); return; + case 0xA4400004: LogMessage("%08X: read from VI_ORIGIN_REG/VI_DRAM_ADDR_REG (%08X)", PC, Value); return; + case 0xA4400008: LogMessage("%08X: read from VI_WIDTH_REG/VI_H_WIDTH_REG (%08X)", PC, Value); return; + case 0xA440000C: LogMessage("%08X: read from VI_INTR_REG/VI_V_INTR_REG (%08X)", PC, Value); return; + case 0xA4400010: LogMessage("%08X: read from VI_CURRENT_REG/VI_V_CURRENT_LINE_REG (%08X)", PC, Value); return; + case 0xA4400014: LogMessage("%08X: read from VI_BURST_REG/VI_TIMING_REG (%08X)", PC, Value); return; + case 0xA4400018: LogMessage("%08X: read from VI_V_SYNC_REG (%08X)", PC, Value); return; + case 0xA440001C: LogMessage("%08X: read from VI_H_SYNC_REG (%08X)", PC, Value); return; + case 0xA4400020: LogMessage("%08X: read from VI_LEAP_REG/VI_H_SYNC_LEAP_REG (%08X)", PC, Value); return; + case 0xA4400024: LogMessage("%08X: read from VI_H_START_REG/VI_H_VIDEO_REG (%08X)", PC, Value); return; + case 0xA4400028: LogMessage("%08X: read from VI_V_START_REG/VI_V_VIDEO_REG (%08X)", PC, Value); return; + case 0xA440002C: LogMessage("%08X: read from VI_V_BURST_REG (%08X)", PC, Value); return; + case 0xA4400030: LogMessage("%08X: read from VI_X_SCALE_REG (%08X)", PC, Value); return; + case 0xA4400034: LogMessage("%08X: read from VI_Y_SCALE_REG (%08X)", PC, Value); return; + } + } + if (VAddr >= 0xA4500000 && VAddr <= 0xA4500014) + { + if (!g_LogOptions.LogAudioInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + + switch (VAddr) + { + case 0xA4500000: LogMessage("%08X: read from AI_DRAM_ADDR_REG (%08X)", PC, Value); return; + case 0xA4500004: LogMessage("%08X: read from AI_LEN_REG (%08X)", PC, Value); return; + case 0xA4500008: LogMessage("%08X: read from AI_CONTROL_REG (%08X)", PC, Value); return; + case 0xA450000C: LogMessage("%08X: read from AI_STATUS_REG (%08X)", PC, Value); return; + case 0xA4500010: LogMessage("%08X: read from AI_DACRATE_REG (%08X)", PC, Value); return; + case 0xA4500014: LogMessage("%08X: read from AI_BITRATE_REG (%08X)", PC, Value); return; + } + } + if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030) + { + if (!g_LogOptions.LogPerInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + + switch (VAddr) + { + case 0xA4600000: LogMessage("%08X: read from PI_DRAM_ADDR_REG (%08X)", PC, Value); return; + case 0xA4600004: LogMessage("%08X: read from PI_CART_ADDR_REG (%08X)", PC, Value); return; + case 0xA4600008: LogMessage("%08X: read from PI_RD_LEN_REG (%08X)", PC, Value); return; + case 0xA460000C: LogMessage("%08X: read from PI_WR_LEN_REG (%08X)", PC, Value); return; + case 0xA4600010: LogMessage("%08X: read from PI_STATUS_REG (%08X)", PC, Value); return; + case 0xA4600014: LogMessage("%08X: read from PI_BSD_DOM1_LAT_REG/PI_DOMAIN1_REG (%08X)", PC, Value); return; + case 0xA4600018: LogMessage("%08X: read from PI_BSD_DOM1_PWD_REG (%08X)", PC, Value); return; + case 0xA460001C: LogMessage("%08X: read from PI_BSD_DOM1_PGS_REG (%08X)", PC, Value); return; + case 0xA4600020: LogMessage("%08X: read from PI_BSD_DOM1_RLS_REG (%08X)", PC, Value); return; + case 0xA4600024: LogMessage("%08X: read from PI_BSD_DOM2_LAT_REG/PI_DOMAIN2_REG (%08X)", PC, Value); return; + case 0xA4600028: LogMessage("%08X: read from PI_BSD_DOM2_PWD_REG (%08X)", PC, Value); return; + case 0xA460002C: LogMessage("%08X: read from PI_BSD_DOM2_PGS_REG (%08X)", PC, Value); return; + case 0xA4600030: LogMessage("%08X: read from PI_BSD_DOM2_RLS_REG (%08X)", PC, Value); return; + } + } + if (VAddr >= 0xA4700000 && VAddr <= 0xA470001C) + { + if (!g_LogOptions.LogRDRAMInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + + switch (VAddr) + { + case 0xA4700000: LogMessage("%08X: read from RI_MODE_REG (%08X)", PC, Value); return; + case 0xA4700004: LogMessage("%08X: read from RI_CONFIG_REG (%08X)", PC, Value); return; + case 0xA4700008: LogMessage("%08X: read from RI_CURRENT_LOAD_REG (%08X)", PC, Value); return; + case 0xA470000C: LogMessage("%08X: read from RI_SELECT_REG (%08X)", PC, Value); return; + case 0xA4700010: LogMessage("%08X: read from RI_REFRESH_REG/RI_COUNT_REG (%08X)", PC, Value); return; + case 0xA4700014: LogMessage("%08X: read from RI_LATENCY_REG (%08X)", PC, Value); return; + case 0xA4700018: LogMessage("%08X: read from RI_RERROR_REG (%08X)", PC, Value); return; + case 0xA470001C: LogMessage("%08X: read from RI_WERROR_REG (%08X)", PC, Value); return; + } + } + if (VAddr == 0xA4800000) + { + if (!g_LogOptions.LogSerialInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + LogMessage("%08X: read from SI_DRAM_ADDR_REG (%08X)", PC, Value); + return; + } + if (VAddr == 0xA4800004) + { + if (!g_LogOptions.LogSerialInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + LogMessage("%08X: read from SI_PIF_ADDR_RD64B_REG (%08X)", PC, Value); + return; + } + if (VAddr == 0xA4800010) + { + if (!g_LogOptions.LogSerialInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + LogMessage("%08X: read from SI_PIF_ADDR_WR64B_REG (%08X)", PC, Value); + return; + } + if (VAddr == 0xA4800018) + { + if (!g_LogOptions.LogSerialInterface) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + LogMessage("%08X: read from SI_STATUS_REG (%08X)", PC, Value); + return; + } + if (VAddr >= 0xBFC00000 && VAddr <= 0xBFC007C0) + { + return; + } + if (VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC) + { + if (!g_LogOptions.LogPRDirectMemLoads) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + LogMessage("%08X: read word from Pif Ram at 0x%X (%08X)", PC, VAddr - 0xBFC007C0, Value); + return; + } + if (VAddr >= 0xB0000040 && ((VAddr - 0xB0000000) < g_Rom->GetRomSize())) + { + return; + } + if (VAddr >= 0xB0000000 && VAddr < 0xB0000040) + { + if (!g_LogOptions.LogRomHeader) + { + return; + } + + g_MMU->LW_VAddr(VAddr, Value); + switch (VAddr) + { + case 0xB0000004: LogMessage("%08X: read from Rom Clock Rate (%08X)", PC, Value); break; + case 0xB0000008: LogMessage("%08X: read from Rom Boot address offset (%08X)", PC, Value); break; + case 0xB000000C: LogMessage("%08X: read from Rom Release offset (%08X)", PC, Value); break; + case 0xB0000010: LogMessage("%08X: read from Rom CRC1 (%08X)", PC, Value); break; + case 0xB0000014: LogMessage("%08X: read from Rom CRC2 (%08X)", PC, Value); break; + default: LogMessage("%08X: read from Rom header 0x%X (%08X)", PC, VAddr & 0xFF, Value); break; + } + return; + } + if (!g_LogOptions.LogUnknown) + { + return; + } + LogMessage("%08X: read from unknown ??? (%08X)", PC, VAddr); +} + +void Log_SW(uint32_t PC, uint32_t VAddr, uint32_t Value) +{ + if (!g_LogOptions.GenerateLog) + { + return; + } + + if (VAddr < 0xA0000000 || VAddr >= 0xC0000000) + { + uint32_t PAddr; + if (!g_TransVaddr->TranslateVaddr(VAddr, PAddr)) + { + if (g_LogOptions.LogUnknown) + { + LogMessage("%08X: Writing 0x%08X to %08X", PC, Value, VAddr); + } + return; + } + VAddr = PAddr + 0xA0000000; + } + + if (VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize())) + { + return; + } + if (VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) + { + if (!g_LogOptions.LogRDRamRegisters) + { + return; + } + switch (VAddr) + { + case 0xA3F00000: LogMessage("%08X: Writing 0x%08X to RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG", PC, Value); return; + case 0xA3F00004: LogMessage("%08X: Writing 0x%08X to RDRAM_DEVICE_ID_REG", PC, Value); return; + case 0xA3F00008: LogMessage("%08X: Writing 0x%08X to RDRAM_DELAY_REG", PC, Value); return; + case 0xA3F0000C: LogMessage("%08X: Writing 0x%08X to RDRAM_MODE_REG", PC, Value); return; + case 0xA3F00010: LogMessage("%08X: Writing 0x%08X to RDRAM_REF_INTERVAL_REG", PC, Value); return; + case 0xA3F00014: LogMessage("%08X: Writing 0x%08X to RDRAM_REF_ROW_REG", PC, Value); return; + case 0xA3F00018: LogMessage("%08X: Writing 0x%08X to RDRAM_RAS_INTERVAL_REG", PC, Value); return; + case 0xA3F0001C: LogMessage("%08X: Writing 0x%08X to RDRAM_MIN_INTERVAL_REG", PC, Value); return; + case 0xA3F00020: LogMessage("%08X: Writing 0x%08X to RDRAM_ADDR_SELECT_REG", PC, Value); return; + case 0xA3F00024: LogMessage("%08X: Writing 0x%08X to RDRAM_DEVICE_MANUF_REG", PC, Value); return; + } + } + if (VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC) + { + return; + } + + if (VAddr >= 0xA4040000 && VAddr <= 0xA404001C) + { + if (!g_LogOptions.LogSPRegisters) + { + return; + } + switch (VAddr) + { + case 0xA4040000: LogMessage("%08X: Writing 0x%08X to SP_MEM_ADDR_REG", PC, Value); return; + case 0xA4040004: LogMessage("%08X: Writing 0x%08X to SP_DRAM_ADDR_REG", PC, Value); return; + case 0xA4040008: LogMessage("%08X: Writing 0x%08X to SP_RD_LEN_REG", PC, Value); return; + case 0xA404000C: LogMessage("%08X: Writing 0x%08X to SP_WR_LEN_REG", PC, Value); return; + case 0xA4040010: LogMessage("%08X: Writing 0x%08X to SP_STATUS_REG", PC, Value); return; + case 0xA4040014: LogMessage("%08X: Writing 0x%08X to SP_DMA_FULL_REG", PC, Value); return; + case 0xA4040018: LogMessage("%08X: Writing 0x%08X to SP_DMA_BUSY_REG", PC, Value); return; + case 0xA404001C: LogMessage("%08X: Writing 0x%08X to SP_SEMAPHORE_REG", PC, Value); return; + } + } + if (VAddr == 0xA4080000) + { + if (!g_LogOptions.LogSPRegisters) + { + return; + } + LogMessage("%08X: Writing 0x%08X to SP_PC", PC, Value); return; + } + + if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C) + { + if (!g_LogOptions.LogDPCRegisters) + { + return; + } + switch (VAddr) + { + case 0xA4100000: LogMessage("%08X: Writing 0x%08X to DPC_START_REG", PC, Value); return; + case 0xA4100004: LogMessage("%08X: Writing 0x%08X to DPC_END_REG", PC, Value); return; + case 0xA4100008: LogMessage("%08X: Writing 0x%08X to DPC_CURRENT_REG", PC, Value); return; + case 0xA410000C: LogMessage("%08X: Writing 0x%08X to DPC_STATUS_REG", PC, Value); return; + case 0xA4100010: LogMessage("%08X: Writing 0x%08X to DPC_CLOCK_REG", PC, Value); return; + case 0xA4100014: LogMessage("%08X: Writing 0x%08X to DPC_BUFBUSY_REG", PC, Value); return; + case 0xA4100018: LogMessage("%08X: Writing 0x%08X to DPC_PIPEBUSY_REG", PC, Value); return; + case 0xA410001C: LogMessage("%08X: Writing 0x%08X to DPC_TMEM_REG", PC, Value); return; + } + } + + if (VAddr >= 0xA4200000 && VAddr <= 0xA420000C) + { + if (!g_LogOptions.LogDPSRegisters) + { + return; + } + switch (VAddr) + { + case 0xA4200000: LogMessage("%08X: Writing 0x%08X to DPS_TBIST_REG", PC, Value); return; + case 0xA4200004: LogMessage("%08X: Writing 0x%08X to DPS_TEST_MODE_REG", PC, Value); return; + case 0xA4200008: LogMessage("%08X: Writing 0x%08X to DPS_BUFTEST_ADDR_REG", PC, Value); return; + case 0xA420000C: LogMessage("%08X: Writing 0x%08X to DPS_BUFTEST_DATA_REG", PC, Value); return; + } + } + + if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C) + { + if (!g_LogOptions.LogMIPSInterface) + { + return; + } + switch (VAddr) + { + case 0xA4300000: LogMessage("%08X: Writing 0x%08X to MI_INIT_MODE_REG/MI_MODE_REG", PC, Value); return; + case 0xA4300004: LogMessage("%08X: Writing 0x%08X to MI_VERSION_REG/MI_NOOP_REG", PC, Value); return; + case 0xA4300008: LogMessage("%08X: Writing 0x%08X to MI_INTR_REG", PC, Value); return; + case 0xA430000C: LogMessage("%08X: Writing 0x%08X to MI_INTR_MASK_REG", PC, Value); return; + } + } + if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034) + { + if (!g_LogOptions.LogVideoInterface) + { + return; + } + switch (VAddr) + { + case 0xA4400000: LogMessage("%08X: Writing 0x%08X to VI_STATUS_REG/VI_CONTROL_REG", PC, Value); return; + case 0xA4400004: LogMessage("%08X: Writing 0x%08X to VI_ORIGIN_REG/VI_DRAM_ADDR_REG", PC, Value); return; + case 0xA4400008: LogMessage("%08X: Writing 0x%08X to VI_WIDTH_REG/VI_H_WIDTH_REG", PC, Value); return; + case 0xA440000C: LogMessage("%08X: Writing 0x%08X to VI_INTR_REG/VI_V_INTR_REG", PC, Value); return; + case 0xA4400010: LogMessage("%08X: Writing 0x%08X to VI_CURRENT_REG/VI_V_CURRENT_LINE_REG", PC, Value); return; + case 0xA4400014: LogMessage("%08X: Writing 0x%08X to VI_BURST_REG/VI_TIMING_REG", PC, Value); return; + case 0xA4400018: LogMessage("%08X: Writing 0x%08X to VI_V_SYNC_REG", PC, Value); return; + case 0xA440001C: LogMessage("%08X: Writing 0x%08X to VI_H_SYNC_REG", PC, Value); return; + case 0xA4400020: LogMessage("%08X: Writing 0x%08X to VI_LEAP_REG/VI_H_SYNC_LEAP_REG", PC, Value); return; + case 0xA4400024: LogMessage("%08X: Writing 0x%08X to VI_H_START_REG/VI_H_VIDEO_REG", PC, Value); return; + case 0xA4400028: LogMessage("%08X: Writing 0x%08X to VI_V_START_REG/VI_V_VIDEO_REG", PC, Value); return; + case 0xA440002C: LogMessage("%08X: Writing 0x%08X to VI_V_BURST_REG", PC, Value); return; + case 0xA4400030: LogMessage("%08X: Writing 0x%08X to VI_X_SCALE_REG", PC, Value); return; + case 0xA4400034: LogMessage("%08X: Writing 0x%08X to VI_Y_SCALE_REG", PC, Value); return; + } + } + + if (VAddr >= 0xA4500000 && VAddr <= 0xA4500014) + { + if (!g_LogOptions.LogAudioInterface) + { + return; + } + switch (VAddr) + { + case 0xA4500000: LogMessage("%08X: Writing 0x%08X to AI_DRAM_ADDR_REG", PC, Value); return; + case 0xA4500004: LogMessage("%08X: Writing 0x%08X to AI_LEN_REG", PC, Value); return; + case 0xA4500008: LogMessage("%08X: Writing 0x%08X to AI_CONTROL_REG", PC, Value); return; + case 0xA450000C: LogMessage("%08X: Writing 0x%08X to AI_STATUS_REG", PC, Value); return; + case 0xA4500010: LogMessage("%08X: Writing 0x%08X to AI_DACRATE_REG", PC, Value); return; + case 0xA4500014: LogMessage("%08X: Writing 0x%08X to AI_BITRATE_REG", PC, Value); return; + } + } + + if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030) + { + if (!g_LogOptions.LogPerInterface) + { + return; + } + switch (VAddr) + { + case 0xA4600000: LogMessage("%08X: Writing 0x%08X to PI_DRAM_ADDR_REG", PC, Value); return; + case 0xA4600004: LogMessage("%08X: Writing 0x%08X to PI_CART_ADDR_REG", PC, Value); return; + case 0xA4600008: LogMessage("%08X: Writing 0x%08X to PI_RD_LEN_REG", PC, Value); return; + case 0xA460000C: LogMessage("%08X: Writing 0x%08X to PI_WR_LEN_REG", PC, Value); return; + case 0xA4600010: LogMessage("%08X: Writing 0x%08X to PI_STATUS_REG", PC, Value); return; + case 0xA4600014: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_LAT_REG/PI_DOMAIN1_REG", PC, Value); return; + case 0xA4600018: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_PWD_REG", PC, Value); return; + case 0xA460001C: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_PGS_REG", PC, Value); return; + case 0xA4600020: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_RLS_REG", PC, Value); return; + case 0xA4600024: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_LAT_REG/PI_DOMAIN2_REG", PC, Value); return; + case 0xA4600028: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_PWD_REG", PC, Value); return; + case 0xA460002C: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_PGS_REG", PC, Value); return; + case 0xA4600030: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_RLS_REG", PC, Value); return; + } + } + if (VAddr >= 0xA4700000 && VAddr <= 0xA470001C) + { + if (!g_LogOptions.LogRDRAMInterface) + { + return; + } + switch (VAddr) + { + case 0xA4700000: LogMessage("%08X: Writing 0x%08X to RI_MODE_REG", PC, Value); return; + case 0xA4700004: LogMessage("%08X: Writing 0x%08X to RI_CONFIG_REG", PC, Value); return; + case 0xA4700008: LogMessage("%08X: Writing 0x%08X to RI_CURRENT_LOAD_REG", PC, Value); return; + case 0xA470000C: LogMessage("%08X: Writing 0x%08X to RI_SELECT_REG", PC, Value); return; + case 0xA4700010: LogMessage("%08X: Writing 0x%08X to RI_REFRESH_REG/RI_COUNT_REG", PC, Value); return; + case 0xA4700014: LogMessage("%08X: Writing 0x%08X to RI_LATENCY_REG", PC, Value); return; + case 0xA4700018: LogMessage("%08X: Writing 0x%08X to RI_RERROR_REG", PC, Value); return; + case 0xA470001C: LogMessage("%08X: Writing 0x%08X to RI_WERROR_REG", PC, Value); return; + } + } + if (VAddr == 0xA4800000) + { + if (!g_LogOptions.LogSerialInterface) + { + return; + } + LogMessage("%08X: Writing 0x%08X to SI_DRAM_ADDR_REG", PC, Value); return; + } + if (VAddr == 0xA4800004) + { + if (g_LogOptions.LogPRDMAOperations) + { + LogMessage("%08X: A DMA transfer from the PIF ram has occured", PC); + } + if (!g_LogOptions.LogSerialInterface) + { + return; + } + LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_RD64B_REG", PC, Value); return; + } + if (VAddr == 0xA4800010) + { + if (g_LogOptions.LogPRDMAOperations) + { + LogMessage("%08X: A DMA transfer to the PIF ram has occured", PC); + } + if (!g_LogOptions.LogSerialInterface) + { + return; + } + LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_WR64B_REG", PC, Value); return; + } + if (VAddr == 0xA4800018) + { + if (!g_LogOptions.LogSerialInterface) + { + return; + } + LogMessage("%08X: Writing 0x%08X to SI_STATUS_REG", PC, Value); return; + } + + if (VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC) + { + if (!g_LogOptions.LogPRDirectMemStores) + { + return; + } + LogMessage("%08X: Writing 0x%08X to Pif Ram at 0x%X", PC, Value, VAddr - 0xBFC007C0); + return; + } + if (!g_LogOptions.LogUnknown) + { + return; + } + LogMessage("%08X: Writing 0x%08X to %08X ????", PC, Value, VAddr); +} + +LRESULT CALLBACK LogPifProc(HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam) +{ + switch (uMsg) + { + case WM_INITDIALOG: + if (TempOptions.LogPRDMAOperations) { CheckDlgButton(hDlg, IDC_SI_DMA, BST_CHECKED); } + if (TempOptions.LogPRDirectMemLoads) { CheckDlgButton(hDlg, IDC_DIRECT_WRITE, BST_CHECKED); } + if (TempOptions.LogPRDMAMemLoads) { CheckDlgButton(hDlg, IDC_DMA_WRITE, BST_CHECKED); } + if (TempOptions.LogPRDirectMemStores) { CheckDlgButton(hDlg, IDC_DIRECT_READ, BST_CHECKED); } + if (TempOptions.LogPRDMAMemStores) { CheckDlgButton(hDlg, IDC_DMA_READ, BST_CHECKED); } + if (TempOptions.LogControllerPak) { CheckDlgButton(hDlg, IDC_CONT_PAK, BST_CHECKED); } + break; + case WM_NOTIFY: + if (((NMHDR FAR *) lParam)->code != PSN_APPLY) + { + break; + } + TempOptions.LogPRDMAOperations = IsDlgButtonChecked(hDlg, IDC_SI_DMA) == BST_CHECKED ? TRUE : FALSE; + TempOptions.LogPRDirectMemLoads = IsDlgButtonChecked(hDlg, IDC_DIRECT_WRITE) == BST_CHECKED ? TRUE : FALSE; + TempOptions.LogPRDMAMemLoads = IsDlgButtonChecked(hDlg, IDC_DMA_WRITE) == BST_CHECKED ? TRUE : FALSE; + TempOptions.LogPRDirectMemStores = IsDlgButtonChecked(hDlg, IDC_DIRECT_READ) == BST_CHECKED ? TRUE : FALSE; + TempOptions.LogPRDMAMemStores = IsDlgButtonChecked(hDlg, IDC_DMA_READ) == BST_CHECKED ? TRUE : FALSE; + TempOptions.LogControllerPak = IsDlgButtonChecked(hDlg, IDC_CONT_PAK) == BST_CHECKED ? TRUE : FALSE; + break; + default: + return FALSE; + } + return TRUE; +} + +LRESULT CALLBACK LogRegProc(HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam) +{ + switch (uMsg) + { + case WM_INITDIALOG: + if (TempOptions.LogRDRamRegisters) { CheckDlgButton(hDlg, IDC_RDRAM, BST_CHECKED); } + if (TempOptions.LogSPRegisters) { CheckDlgButton(hDlg, IDC_SP_REG, BST_CHECKED); } + if (TempOptions.LogDPCRegisters) { CheckDlgButton(hDlg, IDC_DPC_REG, BST_CHECKED); } + if (TempOptions.LogDPSRegisters) { CheckDlgButton(hDlg, IDC_DPS_REG, BST_CHECKED); } + if (TempOptions.LogMIPSInterface) { CheckDlgButton(hDlg, IDC_MI_REG, BST_CHECKED); } + if (TempOptions.LogVideoInterface) { CheckDlgButton(hDlg, IDC_VI_REG, BST_CHECKED); } + if (TempOptions.LogAudioInterface) { CheckDlgButton(hDlg, IDC_AI_REG, BST_CHECKED); } + if (TempOptions.LogPerInterface) { CheckDlgButton(hDlg, IDC_PI_REG, BST_CHECKED); } + if (TempOptions.LogRDRAMInterface) { CheckDlgButton(hDlg, IDC_RI_REG, BST_CHECKED); } + if (TempOptions.LogSerialInterface) { CheckDlgButton(hDlg, IDC_SI_REG, BST_CHECKED); } + break; + case WM_NOTIFY: + if (((NMHDR FAR *) lParam)->code != PSN_APPLY) + { + break; + } + TempOptions.LogRDRamRegisters = IsDlgButtonChecked(hDlg, IDC_RDRAM) == BST_CHECKED ? TRUE : FALSE; + TempOptions.LogSPRegisters = IsDlgButtonChecked(hDlg, IDC_SP_REG) == BST_CHECKED ? TRUE : FALSE; + TempOptions.LogDPCRegisters = IsDlgButtonChecked(hDlg, IDC_DPC_REG) == BST_CHECKED ? TRUE : FALSE; + TempOptions.LogDPSRegisters = IsDlgButtonChecked(hDlg, IDC_DPS_REG) == BST_CHECKED ? TRUE : FALSE; + TempOptions.LogMIPSInterface = IsDlgButtonChecked(hDlg, IDC_MI_REG) == BST_CHECKED ? TRUE : FALSE; + TempOptions.LogVideoInterface = IsDlgButtonChecked(hDlg, IDC_VI_REG) == BST_CHECKED ? TRUE : FALSE; + TempOptions.LogAudioInterface = IsDlgButtonChecked(hDlg, IDC_AI_REG) == BST_CHECKED ? TRUE : FALSE; + TempOptions.LogPerInterface = IsDlgButtonChecked(hDlg, IDC_PI_REG) == BST_CHECKED ? TRUE : FALSE; + TempOptions.LogRDRAMInterface = IsDlgButtonChecked(hDlg, IDC_RI_REG) == BST_CHECKED ? TRUE : FALSE; + TempOptions.LogSerialInterface = IsDlgButtonChecked(hDlg, IDC_SI_REG) == BST_CHECKED ? TRUE : FALSE; + break; + default: + return FALSE; + } + return TRUE; +} + +void SaveLogSetting(HKEY hKey, char * String, BOOL Value) +{ + DWORD StoreValue = Value; + RegSetValueEx(hKey, String, 0, REG_DWORD, (CONST BYTE *)&StoreValue, sizeof(DWORD)); +} + +void SaveLogOptions(void) +{ + long lResult; + HKEY hKeyResults = 0; + DWORD Disposition = 0; + char String[200]; + + sprintf(String, "Software\\N64 Emulation\\%s\\Logging", g_Settings->LoadStringVal(Setting_ApplicationName).c_str()); + lResult = RegCreateKeyEx(HKEY_CURRENT_USER, String, 0, "", REG_OPTION_NON_VOLATILE, + KEY_ALL_ACCESS, NULL, &hKeyResults, &Disposition); + + SaveLogSetting(hKeyResults, "Log RDRAM", TempOptions.LogRDRamRegisters); + SaveLogSetting(hKeyResults, "Log SP", TempOptions.LogSPRegisters); + SaveLogSetting(hKeyResults, "Log DP Command", TempOptions.LogDPCRegisters); + SaveLogSetting(hKeyResults, "Log DP Span", TempOptions.LogDPSRegisters); + SaveLogSetting(hKeyResults, "Log MIPS Interface (MI)", TempOptions.LogMIPSInterface); + SaveLogSetting(hKeyResults, "Log Video Interface (VI)", TempOptions.LogVideoInterface); + SaveLogSetting(hKeyResults, "Log Audio Interface (AI)", TempOptions.LogAudioInterface); + SaveLogSetting(hKeyResults, "Log Peripheral Interface (PI)", TempOptions.LogPerInterface); + SaveLogSetting(hKeyResults, "Log RDRAM Interface (RI)", TempOptions.LogRDRAMInterface); + SaveLogSetting(hKeyResults, "Log Serial Interface (SI)", TempOptions.LogSerialInterface); + SaveLogSetting(hKeyResults, "Log PifRam DMA Operations", TempOptions.LogPRDMAOperations); + SaveLogSetting(hKeyResults, "Log PifRam Direct Memory Loads", TempOptions.LogPRDirectMemLoads); + SaveLogSetting(hKeyResults, "Log PifRam DMA Memory Loads", TempOptions.LogPRDMAMemLoads); + SaveLogSetting(hKeyResults, "Log PifRam Direct Memory Stores", TempOptions.LogPRDirectMemStores); + SaveLogSetting(hKeyResults, "Log PifRam DMA Memory Stores", TempOptions.LogPRDMAMemStores); + SaveLogSetting(hKeyResults, "Log Controller Pak", TempOptions.LogControllerPak); + SaveLogSetting(hKeyResults, "Log CP0 changes", TempOptions.LogCP0changes); + SaveLogSetting(hKeyResults, "Log CP0 reads", TempOptions.LogCP0reads); + SaveLogSetting(hKeyResults, "Log Exceptions", TempOptions.LogExceptions); + SaveLogSetting(hKeyResults, "No Interrupts", TempOptions.NoInterrupts); + SaveLogSetting(hKeyResults, "Log TLB", TempOptions.LogTLB); + SaveLogSetting(hKeyResults, "Log Cache Operations", TempOptions.LogCache); + SaveLogSetting(hKeyResults, "Log Rom Header", TempOptions.LogRomHeader); + SaveLogSetting(hKeyResults, "Log Unknown access", TempOptions.LogUnknown); + + RegCloseKey(hKeyResults); +} + +void LogMessage(const char * Message, ...) +{ + DWORD dwWritten; + char Msg[400]; + va_list ap; + + if (!g_Settings->LoadBool(Debugger_Enabled)) + { + return; + } + if (g_hLogFile == NULL) + { + return; + } + + va_start(ap, Message); + vsprintf(Msg, Message, ap); + va_end(ap); + + strcat(Msg, "\r\n"); + + WriteFile(g_hLogFile, Msg, strlen(Msg), &dwWritten, NULL); +} + +void StartLog(void) +{ + if (!g_LogOptions.GenerateLog) + { + StopLog(); + return; + } + if (g_hLogFile) + { + return; + } + + CPath LogFile(CPath::MODULE_DIRECTORY); + LogFile.AppendDirectory("Logs"); + LogFile.SetNameExtension("cpudebug.log"); + + g_hLogFile = CreateFile(LogFile, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); + SetFilePointer(g_hLogFile, 0, NULL, FILE_BEGIN); +} + +void StopLog(void) +{ + if (g_hLogFile) + { + CloseHandle(g_hLogFile); + } + g_hLogFile = NULL; +} \ No newline at end of file diff --git a/Source/Project64/Logging.h b/Source/Project64/User Interface/LoggingUI.h similarity index 100% rename from Source/Project64/Logging.h rename to Source/Project64/User Interface/LoggingUI.h diff --git a/Source/Project64/stdafx.h b/Source/Project64/stdafx.h index 3b2d80888..55e6a56c3 100644 --- a/Source/Project64/stdafx.h +++ b/Source/Project64/stdafx.h @@ -22,7 +22,6 @@ #include #include "Multilanguage.h" #include "User Interface.h" -#include "Logging.h" #include "N64 System.h" #include "Plugin.h" #include "Support.h" From 89fab66ab3b8d0397d4772ead5c952dd8b5cc751 Mon Sep 17 00:00:00 2001 From: zilmar Date: Fri, 13 Nov 2015 17:35:20 +1100 Subject: [PATCH 156/213] [Poject64] Cleanup LanguageSelector.cpp --- .../Multilanguage/LanguageSelector.cpp | 174 +++++++++--------- 1 file changed, 87 insertions(+), 87 deletions(-) diff --git a/Source/Project64/Multilanguage/LanguageSelector.cpp b/Source/Project64/Multilanguage/LanguageSelector.cpp index b1cdf940a..dcc6e9978 100644 --- a/Source/Project64/Multilanguage/LanguageSelector.cpp +++ b/Source/Project64/Multilanguage/LanguageSelector.cpp @@ -15,12 +15,12 @@ CLanguageSelector::CLanguageSelector() { } -void CLanguageSelector::Select ( void ) +void CLanguageSelector::Select(void) { - DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_Lang_Select),NULL,(DLGPROC)LangSelectProc, (LPARAM)this); + DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Lang_Select), NULL, (DLGPROC)LangSelectProc, (LPARAM)this); } -LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK CLanguageSelector::LangSelectProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static HBITMAP hbmpBackgroundTop = NULL; static HFONT hTextFont = NULL; @@ -29,100 +29,100 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM switch (uMsg) { case WM_INITDIALOG: + { + lngClass = (CLanguageSelector *)lParam; + + LanguageList LangList = g_Lang->GetLangList(); + if (LangList.size() == 0) { - lngClass = (CLanguageSelector *)lParam; - - LanguageList LangList = g_Lang->GetLangList(); - if (LangList.size() == 0) - { - EndDialog(hDlg,0); - } - for (LanguageList::iterator Language = LangList.begin(); Language != LangList.end(); Language++) - { - int index = SendMessageW(GetDlgItem(hDlg,IDC_LANG_SEL),CB_ADDSTRING,0,(WPARAM)Language->LanguageName.c_str()); - if (_wcsicmp(Language->LanguageName.c_str(),L"English") == 0) - { - SendMessage(GetDlgItem(hDlg,IDC_LANG_SEL),CB_SETCURSEL,index,0); - } - } - - int Index = SendMessage(GetDlgItem(hDlg,IDC_LANG_SEL),CB_GETCURSEL,0,0); - if (Index < 0) - { - SendMessage(GetDlgItem(hDlg,IDC_LANG_SEL),CB_SETCURSEL,0,0); - } - - // Use the size of the image - hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_ABOUT_LOGO)); - BITMAP bmTL; - GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL); - - hTextFont = ::CreateFont - ( - 18, - 0, - 0, - 0, - FW_NORMAL, - 0, - 0, - 0, - DEFAULT_CHARSET, - OUT_DEFAULT_PRECIS, - CLIP_DEFAULT_PRECIS, - PROOF_QUALITY, - DEFAULT_PITCH|FF_DONTCARE, - "Arial" - ); - SendDlgItemMessage(hDlg,IDC_SELECT_LANG,WM_SETFONT,(WPARAM)hTextFont,TRUE); + EndDialog(hDlg, 0); } - break; + for (LanguageList::iterator Language = LangList.begin(); Language != LangList.end(); Language++) + { + int index = SendMessageW(GetDlgItem(hDlg, IDC_LANG_SEL), CB_ADDSTRING, 0, (WPARAM)Language->LanguageName.c_str()); + if (_wcsicmp(Language->LanguageName.c_str(), L"English") == 0) + { + SendMessage(GetDlgItem(hDlg, IDC_LANG_SEL), CB_SETCURSEL, index, 0); + } + } + + int Index = SendMessage(GetDlgItem(hDlg, IDC_LANG_SEL), CB_GETCURSEL, 0, 0); + if (Index < 0) + { + SendMessage(GetDlgItem(hDlg, IDC_LANG_SEL), CB_SETCURSEL, 0, 0); + } + + // Use the size of the image + hbmpBackgroundTop = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_ABOUT_LOGO)); + BITMAP bmTL; + GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL); + + hTextFont = ::CreateFont + ( + 18, + 0, + 0, + 0, + FW_NORMAL, + 0, + 0, + 0, + DEFAULT_CHARSET, + OUT_DEFAULT_PRECIS, + CLIP_DEFAULT_PRECIS, + PROOF_QUALITY, + DEFAULT_PITCH | FF_DONTCARE, + "Arial" + ); + SendDlgItemMessage(hDlg, IDC_SELECT_LANG, WM_SETFONT, (WPARAM)hTextFont, TRUE); + } + break; case WM_CTLCOLORSTATIC: - { - HDC hdcStatic = (HDC)wParam; - SetTextColor(hdcStatic, RGB(0, 0, 0)); - SetBkMode(hdcStatic, TRANSPARENT); - return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH)); - } - break; + { + HDC hdcStatic = (HDC)wParam; + SetTextColor(hdcStatic, RGB(0, 0, 0)); + SetBkMode(hdcStatic, TRANSPARENT); + return (LONG)(LRESULT)((HBRUSH)GetStockObject(NULL_BRUSH)); + } + break; case WM_ERASEBKGND: - { - HPEN outline; - HBRUSH fill; - RECT rect; + { + HPEN outline; + HBRUSH fill; + RECT rect; - outline = CreatePen(PS_SOLID, 1, 0x00FFFFFF); - fill = CreateSolidBrush(0x00FFFFFF); - SelectObject((HDC)wParam, outline); - SelectObject((HDC)wParam, fill); + outline = CreatePen(PS_SOLID, 1, 0x00FFFFFF); + fill = CreateSolidBrush(0x00FFFFFF); + SelectObject((HDC)wParam, outline); + SelectObject((HDC)wParam, fill); - GetClientRect(hDlg, &rect); + GetClientRect(hDlg, &rect); - Rectangle((HDC)wParam, rect.left, rect.top, rect.right, rect.bottom); - } - break; + Rectangle((HDC)wParam, rect.left, rect.top, rect.right, rect.bottom); + } + break; case WM_PAINT: + { + PAINTSTRUCT ps; + + if (BeginPaint(hDlg, &ps)) { - PAINTSTRUCT ps; + RECT rcClient; + GetClientRect(hDlg, &rcClient); - if (BeginPaint(hDlg,&ps)) - { - RECT rcClient; - GetClientRect(hDlg, &rcClient); + BITMAP bmTL_top; + GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top); - BITMAP bmTL_top, bmTL_bottom, bmTL_Middle; - GetObject(hbmpBackgroundTop, sizeof(BITMAP), &bmTL_top); + HDC memdc = CreateCompatibleDC(ps.hdc); + HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop); + BitBlt(ps.hdc, 0, 0, bmTL_top.bmWidth, bmTL_top.bmHeight, memdc, 0, 0, SRCCOPY); + SelectObject(memdc, save); + DeleteDC(memdc); - HDC memdc = CreateCompatibleDC(ps.hdc); - HGDIOBJ save = SelectObject(memdc, hbmpBackgroundTop); - BitBlt(ps.hdc, 0, 0, bmTL_top.bmWidth, bmTL_top.bmHeight, memdc, 0, 0, SRCCOPY); - SelectObject(memdc, save); - DeleteDC(memdc); - - EndPaint(hDlg,&ps); - } + EndPaint(hDlg, &ps); } - break; + } + break; case WM_COMMAND: switch (LOWORD(wParam)) { @@ -138,17 +138,17 @@ LRESULT CALLBACK CLanguageSelector::LangSelectProc (HWND hDlg, UINT uMsg, WPARAM } { - int Index = SendMessage(GetDlgItem(hDlg,IDC_LANG_SEL),CB_GETCURSEL,0,0); + int Index = SendMessage(GetDlgItem(hDlg, IDC_LANG_SEL), CB_GETCURSEL, 0, 0); if (Index >= 0) { wchar_t String[255]; - SendMessageW(GetDlgItem(hDlg,IDC_LANG_SEL),CB_GETLBTEXT,Index,(LPARAM)String); + SendMessageW(GetDlgItem(hDlg, IDC_LANG_SEL), CB_GETLBTEXT, Index, (LPARAM)String); g_Lang->SetLanguage(String); } } - EndDialog(hDlg,0); + EndDialog(hDlg, 0); break; } default: From 9e744ef180964829ad0892dd6a2fca78dc8e7ad0 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sat, 14 Nov 2015 00:23:43 +1100 Subject: [PATCH 157/213] [Project64] Separate out logging from UI --- Source/Project64/Logging.h | 28 + .../Interpreter/Interpreter Ops 32.cpp | 8 +- .../Interpreter/Interpreter Ops.cpp | 10 +- .../N64 System/Interpreter/Interpreter Ops.h | 1 + Source/Project64/N64 System/Mips/Pif Ram.cpp | 12 +- Source/Project64/N64 System/Mips/Pif Ram.h | 2 + .../N64 System/Mips/Register Class.cpp | 2 +- .../N64 System/Mips/Register Class.h | 3 + Source/Project64/N64 System/N64 Class.cpp | 3 - Source/Project64/N64 System/N64 Class.h | 2 + Source/Project64/Project64.vcproj | 16 + Source/Project64/Project64.vcxproj | 4 + Source/Project64/Project64.vcxproj.filters | 12 + .../Project64/Settings/Logging Settings.cpp | 135 +++ Source/Project64/Settings/Logging Settings.h | 87 ++ Source/Project64/Settings/Settings Class.cpp | 28 +- Source/Project64/Settings/Settings.h | 27 +- Source/Project64/User Interface/LoggingUI.cpp | 876 ++---------------- Source/Project64/User Interface/LoggingUI.h | 43 - .../User Interface/Main Menu Class.cpp | 6 +- Source/Project64/logging.cpp | 628 +++++++++++++ 21 files changed, 1053 insertions(+), 880 deletions(-) create mode 100644 Source/Project64/Logging.h create mode 100644 Source/Project64/Settings/Logging Settings.cpp create mode 100644 Source/Project64/Settings/Logging Settings.h create mode 100644 Source/Project64/logging.cpp diff --git a/Source/Project64/Logging.h b/Source/Project64/Logging.h new file mode 100644 index 000000000..3a98a5a06 --- /dev/null +++ b/Source/Project64/Logging.h @@ -0,0 +1,28 @@ +/**************************************************************************** +* * +* Project64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2012 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +#pragma once +#include +#include + +class CLogging : + public CLogSettings +{ +public: + static void StartLog(void); + static void StopLog(void); + + static void Log_LW(uint32_t PC, uint32_t VAddr); + static void Log_SW(uint32_t PC, uint32_t VAddr, uint32_t Value); + static void LogMessage(const char * Message, ...); + +private: + static CFile * m_hLogFile; +}; \ No newline at end of file diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp index 217a28188..1b8e37aa3 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops 32.cpp @@ -9,7 +9,7 @@ * * ****************************************************************************/ #include "stdafx.h" -#include +#include bool DelaySlotEffectsCompare(uint32_t PC, uint32_t Reg1, uint32_t Reg2); @@ -950,7 +950,7 @@ void R4300iOp32::LW() ADDRESS_ERROR_EXCEPTION(Address, true); } - if (g_LogOptions.GenerateLog) + if (GenerateLog()) { Log_LW((*_PROGRAM_COUNTER), Address); } @@ -1323,7 +1323,7 @@ void R4300iOp32::REGIMM_BGEZAL() /************************** COP0 functions **************************/ void R4300iOp32::COP0_MF() { - if (g_LogOptions.LogCP0reads) + if (LogCP0reads()) { LogMessage("%08X: R4300i Read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); } @@ -1337,7 +1337,7 @@ void R4300iOp32::COP0_MF() void R4300iOp32::COP0_MT() { - if (g_LogOptions.LogCP0changes) + if (LogCP0changes()) { LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)", (*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0], CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); if (m_Opcode.rd == 11) //Compare diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp index 49c81c22a..c3c2e7240 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp @@ -1114,7 +1114,7 @@ void R4300iOp::LW() ADDRESS_ERROR_EXCEPTION(Address, true); } - if (g_LogOptions.GenerateLog) + if (GenerateLog()) { Log_LW((*_PROGRAM_COUNTER), Address); } @@ -1293,7 +1293,7 @@ void R4300iOp::SW() { ADDRESS_ERROR_EXCEPTION(Address, false); } - if (g_LogOptions.GenerateLog) + if (GenerateLog()) { Log_SW((*_PROGRAM_COUNTER), Address, _GPR[m_Opcode.rt].UW[0]); } @@ -1443,7 +1443,7 @@ void R4300iOp::SWR() void R4300iOp::CACHE() { - if (!g_LogOptions.LogCache) + if (!LogCache()) { return; } @@ -2089,7 +2089,7 @@ void R4300iOp::REGIMM_BGEZAL() /************************** COP0 functions **************************/ void R4300iOp::COP0_MF() { - if (g_LogOptions.LogCP0reads) + if (LogCP0reads()) { LogMessage("%08X: R4300i Read from %s (0x%08X)", (*_PROGRAM_COUNTER), CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); } @@ -2103,7 +2103,7 @@ void R4300iOp::COP0_MF() void R4300iOp::COP0_MT() { - if (g_LogOptions.LogCP0changes) + if (LogCP0changes()) { LogMessage("%08X: Writing 0x%X to %s register (Originally: 0x%08X)", (*_PROGRAM_COUNTER), _GPR[m_Opcode.rt].UW[0], CRegName::Cop0[m_Opcode.rd], _CP0[m_Opcode.rd]); if (m_Opcode.rd == 11) //Compare diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops.h b/Source/Project64/N64 System/Interpreter/Interpreter Ops.h index 6c9b6484c..6f607150b 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops.h +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops.h @@ -11,6 +11,7 @@ #pragma once class R4300iOp : + public CLogging, protected CDebugSettings, protected CSystemRegisters { diff --git a/Source/Project64/N64 System/Mips/Pif Ram.cpp b/Source/Project64/N64 System/Mips/Pif Ram.cpp index 05707b241..99ca02bab 100644 --- a/Source/Project64/N64 System/Mips/Pif Ram.cpp +++ b/Source/Project64/N64 System/Mips/Pif Ram.cpp @@ -307,7 +307,7 @@ void CPifRam::SI_DMA_READ() } } - if (g_LogOptions.LogPRDMAMemStores) + if (LogPRDMAMemStores()) { int32_t count; char HexData[100], AsciiData[100], Addon[20]; @@ -393,7 +393,7 @@ void CPifRam::SI_DMA_WRITE() } } - if (g_LogOptions.LogPRDMAMemLoads) + if (LogPRDMAMemLoads()) { int32_t count; char HexData[100], AsciiData[100], Addon[20]; @@ -504,7 +504,7 @@ void CPifRam::ProcessControllerCommand(int Control, BYTE * Command) } break; case 0x02: //read from controller pack - if (g_LogOptions.LogControllerPak) + if (LogControllerPak()) { LogControllerPakData("Read: Before Gettting Results"); } @@ -540,13 +540,13 @@ void CPifRam::ProcessControllerCommand(int Control, BYTE * Command) { Command[1] |= 0x80; } - if (g_LogOptions.LogControllerPak) + if (LogControllerPak()) { LogControllerPakData("Read: After Gettting Results"); } break; case 0x03: //write controller pak - if (g_LogOptions.LogControllerPak) + if (LogControllerPak()) { LogControllerPakData("Write: Before Processing"); } @@ -580,7 +580,7 @@ void CPifRam::ProcessControllerCommand(int Control, BYTE * Command) { Command[1] |= 0x80; } - if (g_LogOptions.LogControllerPak) + if (LogControllerPak()) { LogControllerPakData("Write: After Processing"); } diff --git a/Source/Project64/N64 System/Mips/Pif Ram.h b/Source/Project64/N64 System/Mips/Pif Ram.h index 9cc1fdc42..a7bad744b 100644 --- a/Source/Project64/N64 System/Mips/Pif Ram.h +++ b/Source/Project64/N64 System/Mips/Pif Ram.h @@ -10,6 +10,7 @@ ****************************************************************************/ #pragma once +#include class CPifRamSettings { protected: @@ -31,6 +32,7 @@ private: }; class CPifRam : + public CLogging, private CPifRamSettings, private CEeprom { diff --git a/Source/Project64/N64 System/Mips/Register Class.cpp b/Source/Project64/N64 System/Mips/Register Class.cpp index c66ba1fb5..57c3ecc26 100644 --- a/Source/Project64/N64 System/Mips/Register Class.cpp +++ b/Source/Project64/N64 System/Mips/Register Class.cpp @@ -452,7 +452,7 @@ bool CRegisters::DoIntrException(bool DelaySlot) return false; } - if (g_LogOptions.GenerateLog && g_LogOptions.LogExceptions && !g_LogOptions.NoInterrupts) + if (GenerateLog() && LogExceptions() && !LogNoInterrupts()) { LogMessage("%08X: Interrupt Generated", m_PROGRAM_COUNTER); } diff --git a/Source/Project64/N64 System/Mips/Register Class.h b/Source/Project64/N64 System/Mips/Register Class.h index f782c6ceb..c5252f320 100644 --- a/Source/Project64/N64 System/Mips/Register Class.h +++ b/Source/Project64/N64 System/Mips/Register Class.h @@ -11,6 +11,8 @@ #pragma once #include +#include + //CPO registers by name class CP0registers { @@ -516,6 +518,7 @@ class CN64System; class CSystemEvents; class CRegisters : + public CLogging, private CDebugSettings, private CGameSettings, protected CSystemRegisters, diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index 87dfca5d7..5dce95baa 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -9,7 +9,6 @@ * * ****************************************************************************/ #include "stdafx.h" -#include #pragma warning(disable:4355) // Disable 'this' : used in base member initializer list @@ -276,8 +275,6 @@ void CN64System::StartEmulation2(bool NewThread) WriteTrace(TraceDebug, __FUNCTION__ ": Starting"); if (bHaveDebugger()) { - g_LogOptions.GenerateLog = g_Settings->LoadBool(Debugger_GenerateDebugLog); - LoadLogOptions(&g_LogOptions, FALSE); StartLog(); } diff --git a/Source/Project64/N64 System/N64 Class.h b/Source/Project64/N64 System/N64 Class.h index beb835c77..b770e9e05 100644 --- a/Source/Project64/N64 System/N64 Class.h +++ b/Source/Project64/N64 System/N64 Class.h @@ -11,6 +11,7 @@ #pragma once #include +#include typedef std::list EVENT_LIST; @@ -23,6 +24,7 @@ class CRecompiler; //#define TEST_SP_TRACKING //track the SP to make sure all ops pick it up fine class CN64System : + public CLogging, public CMipsMemory_CallBack, public CTLB_CB, private CSystemEvents, diff --git a/Source/Project64/Project64.vcproj b/Source/Project64/Project64.vcproj index 7be04938f..dfd273f31 100644 --- a/Source/Project64/Project64.vcproj +++ b/Source/Project64/Project64.vcproj @@ -188,6 +188,10 @@ RelativePath="Settings\Gui Settings.cpp" > + + @@ -300,6 +304,10 @@ RelativePath="User Interface\Gui Class.cpp" > + + @@ -840,6 +848,10 @@ RelativePath="Settings\Gui Settings.h" > + + @@ -960,6 +972,10 @@ RelativePath="User Interface\Log Class.h" > + + diff --git a/Source/Project64/Project64.vcxproj b/Source/Project64/Project64.vcxproj index 256bc4408..66fd0c3ae 100644 --- a/Source/Project64/Project64.vcxproj +++ b/Source/Project64/Project64.vcxproj @@ -44,10 +44,12 @@ + + Create @@ -176,12 +178,14 @@ + + diff --git a/Source/Project64/Project64.vcxproj.filters b/Source/Project64/Project64.vcxproj.filters index f387c0509..dd0483794 100644 --- a/Source/Project64/Project64.vcxproj.filters +++ b/Source/Project64/Project64.vcxproj.filters @@ -420,6 +420,12 @@ Source Files\User Interface Source + + Source Files\N64 System Source + + + Source Files\N64 System Source + @@ -833,5 +839,11 @@ Header Files\User Interface Headers + + Header Files\N64 System Headers + + + Header Files\Settings Headers + \ No newline at end of file diff --git a/Source/Project64/Settings/Logging Settings.cpp b/Source/Project64/Settings/Logging Settings.cpp new file mode 100644 index 000000000..259a3ad96 --- /dev/null +++ b/Source/Project64/Settings/Logging Settings.cpp @@ -0,0 +1,135 @@ +/**************************************************************************** +* * +* Project64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2012 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +#include "stdafx.h" +#include "Logging Settings.h" + +int CLogSettings::m_RefCount = 0; +bool CLogSettings::m_GenerateLog = 0; +bool CLogSettings::m_LogRDRamRegisters = 0; +bool CLogSettings::m_LogSPRegisters = 0; +bool CLogSettings::m_LogDPCRegisters = 0; +bool CLogSettings::m_LogDPSRegisters = 0; +bool CLogSettings::m_LogMIPSInterface = 0; +bool CLogSettings::m_LogVideoInterface = 0; +bool CLogSettings::m_LogAudioInterface = 0; +bool CLogSettings::m_LogPerInterface = 0; +bool CLogSettings::m_LogRDRAMInterface = 0; +bool CLogSettings::m_LogSerialInterface = 0; +bool CLogSettings::m_LogPRDMAOperations = 0; +bool CLogSettings::m_LogPRDirectMemLoads = 0; +bool CLogSettings::m_LogPRDMAMemLoads = 0; +bool CLogSettings::m_LogPRDirectMemStores = 0; +bool CLogSettings::m_LogPRDMAMemStores = 0; +bool CLogSettings::m_LogControllerPak = 0; +bool CLogSettings::m_LogCP0changes = 0; +bool CLogSettings::m_LogCP0reads = 0; +bool CLogSettings::m_LogTLB = 0; +bool CLogSettings::m_LogExceptions = 0; +bool CLogSettings::m_NoInterrupts = 0; +bool CLogSettings::m_LogCache = 0; +bool CLogSettings::m_LogRomHeader = 0; +bool CLogSettings::m_LogUnknown = 0; + +CLogSettings::CLogSettings() +{ + m_RefCount += 1; + if (m_RefCount == 1) + { + g_Settings->RegisterChangeCB(Logging_GenerateLog, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogRDRamRegisters, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogSPRegisters, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogDPCRegisters, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogDPSRegisters, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogMIPSInterface, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogVideoInterface, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogAudioInterface, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogPerInterface, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogRDRAMInterface, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogSerialInterface, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogPRDMAOperations, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogPRDirectMemLoads, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogPRDMAMemLoads, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogPRDirectMemStores, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogPRDMAMemStores, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogControllerPak, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogCP0changes, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogCP0reads, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogTLB, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogExceptions, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_NoInterrupts, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogCache, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogRomHeader, NULL, RefreshSettings); + g_Settings->RegisterChangeCB(Logging_LogUnknown, NULL, RefreshSettings); + RefreshSettings(NULL); + } +} + +CLogSettings::~CLogSettings() +{ + m_RefCount -= 1; + if (m_RefCount == 0) + { + g_Settings->UnregisterChangeCB(Logging_GenerateLog, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogRDRamRegisters, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogSPRegisters, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogDPCRegisters, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogDPSRegisters, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogMIPSInterface, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogVideoInterface, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogAudioInterface, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogPerInterface, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogRDRAMInterface, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogSerialInterface, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogPRDMAOperations, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogPRDirectMemLoads, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogPRDMAMemLoads, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogPRDirectMemStores, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogPRDMAMemStores, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogControllerPak, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogCP0changes, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogCP0reads, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogTLB, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogExceptions, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_NoInterrupts, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogCache, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogRomHeader, NULL, RefreshSettings); + g_Settings->UnregisterChangeCB(Logging_LogUnknown, NULL, RefreshSettings); + } +} + +void CLogSettings::RefreshSettings(void *) +{ + m_GenerateLog = g_Settings->LoadBool(Logging_GenerateLog); + m_LogRDRamRegisters = g_Settings->LoadBool(Logging_LogRDRamRegisters); + m_LogSPRegisters = g_Settings->LoadBool(Logging_LogSPRegisters); + m_LogDPCRegisters = g_Settings->LoadBool(Logging_LogDPCRegisters); + m_LogDPSRegisters = g_Settings->LoadBool(Logging_LogDPSRegisters); + m_LogMIPSInterface = g_Settings->LoadBool(Logging_LogMIPSInterface); + m_LogVideoInterface = g_Settings->LoadBool(Logging_LogVideoInterface); + m_LogAudioInterface = g_Settings->LoadBool(Logging_LogAudioInterface); + m_LogPerInterface = g_Settings->LoadBool(Logging_LogPerInterface); + m_LogRDRAMInterface = g_Settings->LoadBool(Logging_LogRDRAMInterface); + m_LogSerialInterface = g_Settings->LoadBool(Logging_LogSerialInterface); + m_LogPRDMAOperations = g_Settings->LoadBool(Logging_LogPRDMAOperations); + m_LogPRDirectMemLoads = g_Settings->LoadBool(Logging_LogPRDirectMemLoads); + m_LogPRDMAMemLoads = g_Settings->LoadBool(Logging_LogPRDMAMemLoads); + m_LogPRDirectMemStores = g_Settings->LoadBool(Logging_LogPRDirectMemStores); + m_LogPRDMAMemStores = g_Settings->LoadBool(Logging_LogPRDMAMemStores); + m_LogControllerPak = g_Settings->LoadBool(Logging_LogControllerPak); + m_LogCP0changes = g_Settings->LoadBool(Logging_LogCP0changes); + m_LogCP0reads = g_Settings->LoadBool(Logging_LogCP0reads); + m_LogTLB = g_Settings->LoadBool(Logging_LogTLB); + m_LogExceptions = g_Settings->LoadBool(Logging_LogExceptions); + m_NoInterrupts = g_Settings->LoadBool(Logging_NoInterrupts); + m_LogCache = g_Settings->LoadBool(Logging_LogCache); + m_LogRomHeader = g_Settings->LoadBool(Logging_LogRomHeader); + m_LogUnknown = g_Settings->LoadBool(Logging_LogUnknown); +} \ No newline at end of file diff --git a/Source/Project64/Settings/Logging Settings.h b/Source/Project64/Settings/Logging Settings.h new file mode 100644 index 000000000..279fc5d84 --- /dev/null +++ b/Source/Project64/Settings/Logging Settings.h @@ -0,0 +1,87 @@ +/**************************************************************************** +* * +* Project 64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2012 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +#pragma once + +class CLogSettings +{ +public: + CLogSettings(); + virtual ~CLogSettings(); + + inline static bool GenerateLog ( void ) { return m_GenerateLog; } + + /* Registers Log */ + inline static bool LogRDRamRegisters ( void ) { return m_LogRDRamRegisters; } + inline static bool LogSPRegisters ( void ) { return m_LogSPRegisters; } + inline static bool LogDPCRegisters ( void ) { return m_LogDPCRegisters; } + inline static bool LogDPSRegisters ( void ) { return m_LogDPSRegisters; } + inline static bool LogMIPSInterface ( void ) { return m_LogMIPSInterface; } + inline static bool LogVideoInterface ( void ) { return m_LogVideoInterface; } + inline static bool LogAudioInterface ( void ) { return m_LogAudioInterface; } + inline static bool LogPerInterface ( void ) { return m_LogPerInterface; } + inline static bool LogRDRAMInterface ( void ) { return m_LogRDRAMInterface; } + inline static bool LogSerialInterface ( void ) { return m_LogSerialInterface; } + + /* Pif Ram Log */ + inline static bool LogPRDMAOperations ( void ) { return m_LogPRDMAOperations; } + inline static bool LogPRDirectMemLoads ( void ) { return m_LogPRDirectMemLoads; } + inline static bool LogPRDMAMemLoads ( void ) { return m_LogPRDMAMemLoads; } + inline static bool LogPRDirectMemStores ( void ) { return m_LogPRDirectMemStores; } + inline static bool LogPRDMAMemStores ( void ) { return m_LogPRDMAMemStores; } + inline static bool LogControllerPak ( void ) { return m_LogControllerPak; } + + /* Special Log */ + inline static bool LogCP0changes ( void ) { return m_LogCP0changes; } + inline static bool LogCP0reads ( void ) { return m_LogCP0reads; } + inline static bool LogTLB ( void ) { return m_LogTLB; } + inline static bool LogExceptions ( void ) { return m_LogExceptions; } + inline static bool LogNoInterrupts ( void ) { return m_NoInterrupts; } + inline static bool LogCache ( void ) { return m_LogCache; } + inline static bool LogRomHeader ( void ) { return m_LogRomHeader; } + inline static bool LogUnknown ( void ) { return m_LogUnknown; } + +private: + static void RefreshSettings ( void * ); + + static bool m_GenerateLog; + + /* Registers Log */ + static bool m_LogRDRamRegisters; + static bool m_LogSPRegisters; + static bool m_LogDPCRegisters; + static bool m_LogDPSRegisters; + static bool m_LogMIPSInterface; + static bool m_LogVideoInterface; + static bool m_LogAudioInterface; + static bool m_LogPerInterface; + static bool m_LogRDRAMInterface; + static bool m_LogSerialInterface; + + /* Pif Ram Log */ + static bool m_LogPRDMAOperations; + static bool m_LogPRDirectMemLoads; + static bool m_LogPRDMAMemLoads; + static bool m_LogPRDirectMemStores; + static bool m_LogPRDMAMemStores; + static bool m_LogControllerPak; + + /* Special Log */ + static bool m_LogCP0changes; + static bool m_LogCP0reads; + static bool m_LogTLB; + static bool m_LogExceptions; + static bool m_NoInterrupts; + static bool m_LogCache; + static bool m_LogRomHeader; + static bool m_LogUnknown; + + static int32_t m_RefCount; +}; diff --git a/Source/Project64/Settings/Settings Class.cpp b/Source/Project64/Settings/Settings Class.cpp index b6a4a6400..0601df605 100644 --- a/Source/Project64/Settings/Settings Class.cpp +++ b/Source/Project64/Settings/Settings Class.cpp @@ -305,7 +305,6 @@ void CSettings::AddHowToHandleSetting() AddHandler(Debugger_ShowDListAListCount, new CSettingTypeApplication("Debugger", "Show Dlist Alist Count", false)); AddHandler(Debugger_ShowRecompMemSize, new CSettingTypeApplication("Debugger", "Show Recompiler Memory size", false)); AddHandler(Debugger_ShowDivByZero, new CSettingTypeApplication("Debugger", "Show Div by zero", false)); - AddHandler(Debugger_GenerateDebugLog, new CSettingTypeApplication("Debugger", "Generate Debug Code", false)); AddHandler(Debugger_ProfileCode, new CSettingTypeApplication("Debugger", "Profile Code", (uint32_t)false)); AddHandler(Debugger_AppLogLevel, new CSettingTypeApplication("Logging", "Log Level", (uint32_t)TraceError)); AddHandler(Debugger_AppLogFlush, new CSettingTypeApplication("Logging", "Log Auto Flush", (uint32_t)false)); @@ -325,6 +324,33 @@ void CSettings::AddHowToHandleSetting() AddHandler(Plugin_UseHleGfx, new CSettingTypeApplication("RSP", "HLE GFX", true)); AddHandler(Plugin_UseHleAudio, new CSettingTypeApplication("RSP", "HLE Audio", false)); + //Logging + AddHandler(Logging_GenerateLog, new CSettingTypeApplication("Logging", "Generate Log Files", false)); + AddHandler(Logging_LogRDRamRegisters, new CSettingTypeApplication("Logging", "Log RDRam Registers", false)); + AddHandler(Logging_LogSPRegisters, new CSettingTypeApplication("Logging", "Log SP Registers", false)); + AddHandler(Logging_LogDPCRegisters, new CSettingTypeApplication("Logging", "Log DPC Registers", false)); + AddHandler(Logging_LogDPSRegisters, new CSettingTypeApplication("Logging", "Log DPS Registers", false)); + AddHandler(Logging_LogMIPSInterface, new CSettingTypeApplication("Logging", "Log MIPS Interface", false)); + AddHandler(Logging_LogVideoInterface, new CSettingTypeApplication("Logging", "Log Video Interface", false)); + AddHandler(Logging_LogAudioInterface, new CSettingTypeApplication("Logging", "Log Audio Interface", false)); + AddHandler(Logging_LogPerInterface, new CSettingTypeApplication("Logging", "Log Per Interface", false)); + AddHandler(Logging_LogRDRAMInterface, new CSettingTypeApplication("Logging", "Log RDRAM Interface", false)); + AddHandler(Logging_LogSerialInterface, new CSettingTypeApplication("Logging", "Log Serial Interface", false)); + AddHandler(Logging_LogPRDMAOperations, new CSettingTypeApplication("Logging", "Log PR DMA Operations", false)); + AddHandler(Logging_LogPRDirectMemLoads, new CSettingTypeApplication("Logging", "Log PR Direct Mem Loads", false)); + AddHandler(Logging_LogPRDMAMemLoads, new CSettingTypeApplication("Logging", "Log PR DMA Mem Loads", false)); + AddHandler(Logging_LogPRDirectMemStores, new CSettingTypeApplication("Logging", "Log PR Direct Mem Stores", false)); + AddHandler(Logging_LogPRDMAMemStores, new CSettingTypeApplication("Logging", "Log PRDMA Mem Stores", false)); + AddHandler(Logging_LogControllerPak, new CSettingTypeApplication("Logging", "Log Controller Pak", false)); + AddHandler(Logging_LogCP0changes, new CSettingTypeApplication("Logging", "Log CP0 changes", false)); + AddHandler(Logging_LogCP0reads, new CSettingTypeApplication("Logging", "Log CP0 reads", false)); + AddHandler(Logging_LogTLB, new CSettingTypeApplication("Logging", "Log TLB", false)); + AddHandler(Logging_LogExceptions, new CSettingTypeApplication("Logging", "Log Exceptions", false)); + AddHandler(Logging_NoInterrupts, new CSettingTypeApplication("Logging", "No Interrupts", false)); + AddHandler(Logging_LogCache, new CSettingTypeApplication("Logging", "Log Cache", false)); + AddHandler(Logging_LogRomHeader, new CSettingTypeApplication("Logging", "Generate Log Files", false)); + AddHandler(Logging_LogUnknown, new CSettingTypeApplication("Logging", "Log Rom Header", false)); + // cheats AddHandler(Cheat_Entry, new CSettingTypeCheats("")); AddHandler(Cheat_Active, new CSettingTypeGameIndex("Cheat", "", (uint32_t)false)); diff --git a/Source/Project64/Settings/Settings.h b/Source/Project64/Settings/Settings.h index 24b241421..64f1196a6 100644 --- a/Source/Project64/Settings/Settings.h +++ b/Source/Project64/Settings/Settings.h @@ -229,7 +229,6 @@ enum SettingID Debugger_DisableGameFixes, Debugger_AppLogLevel, Debugger_AppLogFlush, - Debugger_GenerateDebugLog, Debugger_ShowDListAListCount, Debugger_ShowRecompMemSize, @@ -245,6 +244,32 @@ enum SettingID Plugin_UseHleGfx, Plugin_UseHleAudio, + Logging_GenerateLog, + Logging_LogRDRamRegisters, + Logging_LogSPRegisters, + Logging_LogDPCRegisters, + Logging_LogDPSRegisters, + Logging_LogMIPSInterface, + Logging_LogVideoInterface, + Logging_LogAudioInterface, + Logging_LogPerInterface, + Logging_LogRDRAMInterface, + Logging_LogSerialInterface, + Logging_LogPRDMAOperations, + Logging_LogPRDirectMemLoads, + Logging_LogPRDMAMemLoads, + Logging_LogPRDirectMemStores, + Logging_LogPRDMAMemStores, + Logging_LogControllerPak, + Logging_LogCP0changes, + Logging_LogCP0reads, + Logging_LogTLB, + Logging_LogExceptions, + Logging_NoInterrupts, + Logging_LogCache, + Logging_LogRomHeader, + Logging_LogUnknown, + //Cheats Cheat_Entry, Cheat_Active, diff --git a/Source/Project64/User Interface/LoggingUI.cpp b/Source/Project64/User Interface/LoggingUI.cpp index ff95a6c56..c60b62f33 100644 --- a/Source/Project64/User Interface/LoggingUI.cpp +++ b/Source/Project64/User Interface/LoggingUI.cpp @@ -9,24 +9,19 @@ * * ****************************************************************************/ #include "stdafx.h" -#include "LoggingUI.h" - +#include +#include #include -void LoadLogSetting(HKEY hKey, char * String, bool * Value); -void SaveLogOptions(void); - LRESULT CALLBACK LogGeneralProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK LogPifProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK LogRegProc(HWND, UINT, WPARAM, LPARAM); -static HANDLE g_hLogFile = NULL; -LOG_OPTIONS g_LogOptions, TempOptions; - void EnterLogOptions(HWND hwndOwner) { PROPSHEETPAGE psp[3]; PROPSHEETHEADER psh; + CLogSettings logSettings; psp[0].dwSize = sizeof(PROPSHEETPAGE); psp[0].dwFlags = PSP_USETITLE; @@ -34,7 +29,7 @@ void EnterLogOptions(HWND hwndOwner) psp[0].pszTemplate = MAKEINTRESOURCE(IDD_Logging_Registers); psp[0].pfnDlgProc = (DLGPROC)LogRegProc; psp[0].pszTitle = "Registers"; - psp[0].lParam = 0; + psp[0].lParam = (LPARAM)&logSettings; psp[0].pfnCallback = NULL; psp[1].dwSize = sizeof(PROPSHEETPAGE); @@ -43,7 +38,7 @@ void EnterLogOptions(HWND hwndOwner) psp[1].pszTemplate = MAKEINTRESOURCE(IDD_Logging_PifRam); psp[1].pfnDlgProc = (DLGPROC)LogPifProc; psp[1].pszTitle = "Pif Ram"; - psp[1].lParam = 0; + psp[1].lParam = (LPARAM)&logSettings; psp[1].pfnCallback = NULL; psp[2].dwSize = sizeof(PROPSHEETPAGE); @@ -52,7 +47,7 @@ void EnterLogOptions(HWND hwndOwner) psp[2].pszTemplate = MAKEINTRESOURCE(IDD_Logging_General); psp[2].pfnDlgProc = (DLGPROC)LogGeneralProc; psp[2].pszTitle = "General"; - psp[2].lParam = 0; + psp[2].lParam = (LPARAM)&logSettings; psp[2].pfnCallback = NULL; psh.dwSize = sizeof(PROPSHEETHEADER); @@ -65,129 +60,36 @@ void EnterLogOptions(HWND hwndOwner) psh.ppsp = (LPCPROPSHEETPAGE)&psp; psh.pfnCallback = NULL; - LoadLogOptions(&TempOptions, TRUE); -#if defined(WINDOWS_UI) PropertySheet(&psh); -#else - g_Notify -> BreakPoint(__FILEW__, __LINE__); -#endif - SaveLogOptions(); - LoadLogOptions(&g_LogOptions, FALSE); return; } -void LoadLogOptions(LOG_OPTIONS * LogOptions, bool AlwaysFill) -{ - int32_t lResult; - HKEY hKeyResults = 0; - char String[200]; - - sprintf(String, "Software\\N64 Emulation\\%s\\Logging", g_Settings->LoadStringVal(Setting_ApplicationName).c_str()); - lResult = RegOpenKeyEx(HKEY_CURRENT_USER, String, 0, KEY_ALL_ACCESS, - &hKeyResults); - - if (lResult == ERROR_SUCCESS) - { - //LoadLogSetting(hKeyResults,"Generate Log File",&LogOptions->GenerateLog); - if (LogOptions->GenerateLog || AlwaysFill) - { - LoadLogSetting(hKeyResults, "Log RDRAM", &LogOptions->LogRDRamRegisters); - LoadLogSetting(hKeyResults, "Log SP", &LogOptions->LogSPRegisters); - LoadLogSetting(hKeyResults, "Log DP Command", &LogOptions->LogDPCRegisters); - LoadLogSetting(hKeyResults, "Log DP Span", &LogOptions->LogDPSRegisters); - LoadLogSetting(hKeyResults, "Log MIPS Interface (MI)", &LogOptions->LogMIPSInterface); - LoadLogSetting(hKeyResults, "Log Video Interface (VI)", &LogOptions->LogVideoInterface); - LoadLogSetting(hKeyResults, "Log Audio Interface (AI)", &LogOptions->LogAudioInterface); - LoadLogSetting(hKeyResults, "Log Peripheral Interface (PI)", &LogOptions->LogPerInterface); - LoadLogSetting(hKeyResults, "Log RDRAM Interface (RI)", &LogOptions->LogRDRAMInterface); - LoadLogSetting(hKeyResults, "Log Serial Interface (SI)", &LogOptions->LogSerialInterface); - LoadLogSetting(hKeyResults, "Log PifRam DMA Operations", &LogOptions->LogPRDMAOperations); - LoadLogSetting(hKeyResults, "Log PifRam Direct Memory Loads", &LogOptions->LogPRDirectMemLoads); - LoadLogSetting(hKeyResults, "Log PifRam DMA Memory Loads", &LogOptions->LogPRDMAMemLoads); - LoadLogSetting(hKeyResults, "Log PifRam Direct Memory Stores", &LogOptions->LogPRDirectMemStores); - LoadLogSetting(hKeyResults, "Log PifRam DMA Memory Stores", &LogOptions->LogPRDMAMemStores); - LoadLogSetting(hKeyResults, "Log Controller Pak", &LogOptions->LogControllerPak); - LoadLogSetting(hKeyResults, "Log CP0 changes", &LogOptions->LogCP0changes); - LoadLogSetting(hKeyResults, "Log CP0 reads", &LogOptions->LogCP0reads); - LoadLogSetting(hKeyResults, "Log Exceptions", &LogOptions->LogExceptions); - LoadLogSetting(hKeyResults, "No Interrupts", &LogOptions->NoInterrupts); - LoadLogSetting(hKeyResults, "Log TLB", &LogOptions->LogTLB); - LoadLogSetting(hKeyResults, "Log Cache Operations", &LogOptions->LogCache); - LoadLogSetting(hKeyResults, "Log Rom Header", &LogOptions->LogRomHeader); - LoadLogSetting(hKeyResults, "Log Unknown access", &LogOptions->LogUnknown); - return; - } - } - - LogOptions->GenerateLog = FALSE; - LogOptions->LogRDRamRegisters = FALSE; - LogOptions->LogSPRegisters = FALSE; - LogOptions->LogDPCRegisters = FALSE; - LogOptions->LogDPSRegisters = FALSE; - LogOptions->LogMIPSInterface = FALSE; - LogOptions->LogVideoInterface = FALSE; - LogOptions->LogAudioInterface = FALSE; - LogOptions->LogPerInterface = FALSE; - LogOptions->LogRDRAMInterface = FALSE; - LogOptions->LogSerialInterface = FALSE; - - LogOptions->LogPRDMAOperations = FALSE; - LogOptions->LogPRDirectMemLoads = FALSE; - LogOptions->LogPRDMAMemLoads = FALSE; - LogOptions->LogPRDirectMemStores = FALSE; - LogOptions->LogPRDMAMemStores = FALSE; - LogOptions->LogControllerPak = FALSE; - - LogOptions->LogCP0changes = FALSE; - LogOptions->LogCP0reads = FALSE; - LogOptions->LogCache = FALSE; - LogOptions->LogExceptions = FALSE; - LogOptions->NoInterrupts = FALSE; - LogOptions->LogTLB = FALSE; - LogOptions->LogRomHeader = FALSE; - LogOptions->LogUnknown = FALSE; -} - -void LoadLogSetting(HKEY hKey, char * String, bool * Value) -{ - DWORD Type, dwResult, Bytes = 4; - int32_t lResult; - - lResult = RegQueryValueEx(hKey, String, 0, &Type, (LPBYTE)(&dwResult), &Bytes); - if (Type == REG_DWORD && lResult == ERROR_SUCCESS) - { - *Value = dwResult != 0; - } - else - { - *Value = FALSE; - } -} - LRESULT CALLBACK LogGeneralProc(HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: - if (TempOptions.LogCP0changes) { CheckDlgButton(hDlg, IDC_CP0_WRITE, BST_CHECKED); } - if (TempOptions.LogCP0reads) { CheckDlgButton(hDlg, IDC_CP0_READ, BST_CHECKED); } - if (TempOptions.LogCache) { CheckDlgButton(hDlg, IDC_CACHE, BST_CHECKED); } - if (TempOptions.LogExceptions) { CheckDlgButton(hDlg, IDC_EXCEPTIONS, BST_CHECKED); } - if (TempOptions.NoInterrupts) { CheckDlgButton(hDlg, IDC_INTERRUPTS, BST_CHECKED); } - if (TempOptions.LogTLB) { CheckDlgButton(hDlg, IDC_TLB, BST_CHECKED); } - if (TempOptions.LogRomHeader) { CheckDlgButton(hDlg, IDC_ROM_HEADER, BST_CHECKED); } - if (TempOptions.LogUnknown) { CheckDlgButton(hDlg, IDC_UNKOWN, BST_CHECKED); } - break; + { + if (CLogSettings::LogCP0changes()) { CheckDlgButton(hDlg, IDC_CP0_WRITE, BST_CHECKED); } + if (CLogSettings::LogCP0reads()) { CheckDlgButton(hDlg, IDC_CP0_READ, BST_CHECKED); } + if (CLogSettings::LogCache()) { CheckDlgButton(hDlg, IDC_CACHE, BST_CHECKED); } + if (CLogSettings::LogExceptions()) { CheckDlgButton(hDlg, IDC_EXCEPTIONS, BST_CHECKED); } + if (CLogSettings::LogNoInterrupts()) { CheckDlgButton(hDlg, IDC_INTERRUPTS, BST_CHECKED); } + if (CLogSettings::LogTLB()) { CheckDlgButton(hDlg, IDC_TLB, BST_CHECKED); } + if (CLogSettings::LogRomHeader()) { CheckDlgButton(hDlg, IDC_ROM_HEADER, BST_CHECKED); } + if (CLogSettings::LogUnknown()) { CheckDlgButton(hDlg, IDC_UNKOWN, BST_CHECKED); } + } + break; case WM_NOTIFY: if (((NMHDR FAR *) lParam)->code != PSN_APPLY) { break; } - TempOptions.LogCP0changes = IsDlgButtonChecked(hDlg, IDC_CP0_WRITE) == BST_CHECKED ? TRUE : FALSE; - TempOptions.LogCP0reads = IsDlgButtonChecked(hDlg, IDC_CP0_READ) == BST_CHECKED ? TRUE : FALSE; - TempOptions.LogCache = IsDlgButtonChecked(hDlg, IDC_CACHE) == BST_CHECKED ? TRUE : FALSE; - TempOptions.LogExceptions = IsDlgButtonChecked(hDlg, IDC_EXCEPTIONS) == BST_CHECKED ? TRUE : FALSE; - TempOptions.NoInterrupts = IsDlgButtonChecked(hDlg, IDC_INTERRUPTS) == BST_CHECKED ? TRUE : FALSE; - TempOptions.LogTLB = IsDlgButtonChecked(hDlg, IDC_TLB) == BST_CHECKED ? TRUE : FALSE; - TempOptions.LogRomHeader = IsDlgButtonChecked(hDlg, IDC_ROM_HEADER) == BST_CHECKED ? TRUE : FALSE; - TempOptions.LogUnknown = IsDlgButtonChecked(hDlg, IDC_UNKOWN) == BST_CHECKED ? TRUE : FALSE; + g_Settings->SaveBool(Logging_LogCP0changes, IsDlgButtonChecked(hDlg, IDC_CP0_WRITE) == BST_CHECKED ? true : false); + g_Settings->SaveBool(Logging_LogCP0reads, IsDlgButtonChecked(hDlg, IDC_CP0_READ) == BST_CHECKED ? true : false); + g_Settings->SaveBool(Logging_LogCache, IsDlgButtonChecked(hDlg, IDC_CACHE) == BST_CHECKED ? true : false); + g_Settings->SaveBool(Logging_LogExceptions, IsDlgButtonChecked(hDlg, IDC_EXCEPTIONS) == BST_CHECKED ? true : false); + g_Settings->SaveBool(Logging_NoInterrupts, IsDlgButtonChecked(hDlg, IDC_INTERRUPTS) == BST_CHECKED ? true : false); + g_Settings->SaveBool(Logging_LogTLB, IsDlgButtonChecked(hDlg, IDC_TLB) == BST_CHECKED ? true : false); + g_Settings->SaveBool(Logging_LogRomHeader, IsDlgButtonChecked(hDlg, IDC_ROM_HEADER) == BST_CHECKED ? true : false); + g_Settings->SaveBool(Logging_LogUnknown, IsDlgButtonChecked(hDlg, IDC_UNKOWN) == BST_CHECKED ? true : false); break; default: return FALSE; @@ -195,587 +97,31 @@ LRESULT CALLBACK LogGeneralProc(HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM return TRUE; } -void Log_LW(uint32_t PC, uint32_t VAddr) -{ - if (!g_LogOptions.GenerateLog) - { - return; - } - - if (VAddr < 0xA0000000 || VAddr >= 0xC0000000) - { - uint32_t PAddr; - if (!g_TransVaddr->TranslateVaddr(VAddr, PAddr)) - { - if (g_LogOptions.LogUnknown) - { - LogMessage("%08X: read from unknown ??? (%08X)", PC, VAddr); - } - return; - } - VAddr = PAddr + 0xA0000000; - } - - uint32_t Value; - if (VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize())) - { - return; - } - if (VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) - { - if (!g_LogOptions.LogRDRamRegisters) - { - return; - } - g_MMU->LW_VAddr(VAddr, Value); - - switch (VAddr) - { - case 0xA3F00000: LogMessage("%08X: read from RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG (%08X)", PC, Value); return; - case 0xA3F00004: LogMessage("%08X: read from RDRAM_DEVICE_ID_REG (%08X)", PC, Value); return; - case 0xA3F00008: LogMessage("%08X: read from RDRAM_DELAY_REG (%08X)", PC, Value); return; - case 0xA3F0000C: LogMessage("%08X: read from RDRAM_MODE_REG (%08X)", PC, Value); return; - case 0xA3F00010: LogMessage("%08X: read from RDRAM_REF_INTERVAL_REG (%08X)", PC, Value); return; - case 0xA3F00014: LogMessage("%08X: read from RDRAM_REF_ROW_REG (%08X)", PC, Value); return; - case 0xA3F00018: LogMessage("%08X: read from RDRAM_RAS_INTERVAL_REG (%08X)", PC, Value); return; - case 0xA3F0001C: LogMessage("%08X: read from RDRAM_MIN_INTERVAL_REG (%08X)", PC, Value); return; - case 0xA3F00020: LogMessage("%08X: read from RDRAM_ADDR_SELECT_REG (%08X)", PC, Value); return; - case 0xA3F00024: LogMessage("%08X: read from RDRAM_DEVICE_MANUF_REG (%08X)", PC, Value); return; - } - } - - if (VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC) - { - return; - } - if (VAddr >= 0xA4040000 && VAddr <= 0xA404001C) - { - if (!g_LogOptions.LogSPRegisters) - { - return; - } - g_MMU->LW_VAddr(VAddr, Value); - - switch (VAddr) - { - case 0xA4040000: LogMessage("%08X: read from SP_MEM_ADDR_REG (%08X)", PC, Value); break; - case 0xA4040004: LogMessage("%08X: read from SP_DRAM_ADDR_REG (%08X)", PC, Value); break; - case 0xA4040008: LogMessage("%08X: read from SP_RD_LEN_REG (%08X)", PC, Value); break; - case 0xA404000C: LogMessage("%08X: read from SP_WR_LEN_REG (%08X)", PC, Value); break; - case 0xA4040010: LogMessage("%08X: read from SP_STATUS_REG (%08X)", PC, Value); break; - case 0xA4040014: LogMessage("%08X: read from SP_DMA_FULL_REG (%08X)", PC, Value); break; - case 0xA4040018: LogMessage("%08X: read from SP_DMA_BUSY_REG (%08X)", PC, Value); break; - case 0xA404001C: LogMessage("%08X: read from SP_SEMAPHORE_REG (%08X)", PC, Value); break; - } - return; - } - if (VAddr == 0xA4080000) - { - if (!g_LogOptions.LogSPRegisters) - { - return; - } - g_MMU->LW_VAddr(VAddr, Value); - LogMessage("%08X: read from SP_PC (%08X)", PC, Value); - return; - } - if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C) - { - if (!g_LogOptions.LogDPCRegisters) - { - return; - } - g_MMU->LW_VAddr(VAddr, Value); - - switch (VAddr) - { - case 0xA4100000: LogMessage("%08X: read from DPC_START_REG (%08X)", PC, Value); return; - case 0xA4100004: LogMessage("%08X: read from DPC_END_REG (%08X)", PC, Value); return; - case 0xA4100008: LogMessage("%08X: read from DPC_CURRENT_REG (%08X)", PC, Value); return; - case 0xA410000C: LogMessage("%08X: read from DPC_STATUS_REG (%08X)", PC, Value); return; - case 0xA4100010: LogMessage("%08X: read from DPC_CLOCK_REG (%08X)", PC, Value); return; - case 0xA4100014: LogMessage("%08X: read from DPC_BUFBUSY_REG (%08X)", PC, Value); return; - case 0xA4100018: LogMessage("%08X: read from DPC_PIPEBUSY_REG (%08X)", PC, Value); return; - case 0xA410001C: LogMessage("%08X: read from DPC_TMEM_REG (%08X)", PC, Value); return; - } - } - if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C) - { - if (!g_LogOptions.LogMIPSInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr, Value); - - switch (VAddr) - { - case 0xA4300000: LogMessage("%08X: read from MI_INIT_MODE_REG/MI_MODE_REG (%08X)", PC, Value); return; - case 0xA4300004: LogMessage("%08X: read from MI_VERSION_REG/MI_NOOP_REG (%08X)", PC, Value); return; - case 0xA4300008: LogMessage("%08X: read from MI_INTR_REG (%08X)", PC, Value); return; - case 0xA430000C: LogMessage("%08X: read from MI_INTR_MASK_REG (%08X)", PC, Value); return; - } - } - if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034) - { - if (!g_LogOptions.LogVideoInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr, Value); - - switch (VAddr) - { - case 0xA4400000: LogMessage("%08X: read from VI_STATUS_REG/VI_CONTROL_REG (%08X)", PC, Value); return; - case 0xA4400004: LogMessage("%08X: read from VI_ORIGIN_REG/VI_DRAM_ADDR_REG (%08X)", PC, Value); return; - case 0xA4400008: LogMessage("%08X: read from VI_WIDTH_REG/VI_H_WIDTH_REG (%08X)", PC, Value); return; - case 0xA440000C: LogMessage("%08X: read from VI_INTR_REG/VI_V_INTR_REG (%08X)", PC, Value); return; - case 0xA4400010: LogMessage("%08X: read from VI_CURRENT_REG/VI_V_CURRENT_LINE_REG (%08X)", PC, Value); return; - case 0xA4400014: LogMessage("%08X: read from VI_BURST_REG/VI_TIMING_REG (%08X)", PC, Value); return; - case 0xA4400018: LogMessage("%08X: read from VI_V_SYNC_REG (%08X)", PC, Value); return; - case 0xA440001C: LogMessage("%08X: read from VI_H_SYNC_REG (%08X)", PC, Value); return; - case 0xA4400020: LogMessage("%08X: read from VI_LEAP_REG/VI_H_SYNC_LEAP_REG (%08X)", PC, Value); return; - case 0xA4400024: LogMessage("%08X: read from VI_H_START_REG/VI_H_VIDEO_REG (%08X)", PC, Value); return; - case 0xA4400028: LogMessage("%08X: read from VI_V_START_REG/VI_V_VIDEO_REG (%08X)", PC, Value); return; - case 0xA440002C: LogMessage("%08X: read from VI_V_BURST_REG (%08X)", PC, Value); return; - case 0xA4400030: LogMessage("%08X: read from VI_X_SCALE_REG (%08X)", PC, Value); return; - case 0xA4400034: LogMessage("%08X: read from VI_Y_SCALE_REG (%08X)", PC, Value); return; - } - } - if (VAddr >= 0xA4500000 && VAddr <= 0xA4500014) - { - if (!g_LogOptions.LogAudioInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr, Value); - - switch (VAddr) - { - case 0xA4500000: LogMessage("%08X: read from AI_DRAM_ADDR_REG (%08X)", PC, Value); return; - case 0xA4500004: LogMessage("%08X: read from AI_LEN_REG (%08X)", PC, Value); return; - case 0xA4500008: LogMessage("%08X: read from AI_CONTROL_REG (%08X)", PC, Value); return; - case 0xA450000C: LogMessage("%08X: read from AI_STATUS_REG (%08X)", PC, Value); return; - case 0xA4500010: LogMessage("%08X: read from AI_DACRATE_REG (%08X)", PC, Value); return; - case 0xA4500014: LogMessage("%08X: read from AI_BITRATE_REG (%08X)", PC, Value); return; - } - } - if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030) - { - if (!g_LogOptions.LogPerInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr, Value); - - switch (VAddr) - { - case 0xA4600000: LogMessage("%08X: read from PI_DRAM_ADDR_REG (%08X)", PC, Value); return; - case 0xA4600004: LogMessage("%08X: read from PI_CART_ADDR_REG (%08X)", PC, Value); return; - case 0xA4600008: LogMessage("%08X: read from PI_RD_LEN_REG (%08X)", PC, Value); return; - case 0xA460000C: LogMessage("%08X: read from PI_WR_LEN_REG (%08X)", PC, Value); return; - case 0xA4600010: LogMessage("%08X: read from PI_STATUS_REG (%08X)", PC, Value); return; - case 0xA4600014: LogMessage("%08X: read from PI_BSD_DOM1_LAT_REG/PI_DOMAIN1_REG (%08X)", PC, Value); return; - case 0xA4600018: LogMessage("%08X: read from PI_BSD_DOM1_PWD_REG (%08X)", PC, Value); return; - case 0xA460001C: LogMessage("%08X: read from PI_BSD_DOM1_PGS_REG (%08X)", PC, Value); return; - case 0xA4600020: LogMessage("%08X: read from PI_BSD_DOM1_RLS_REG (%08X)", PC, Value); return; - case 0xA4600024: LogMessage("%08X: read from PI_BSD_DOM2_LAT_REG/PI_DOMAIN2_REG (%08X)", PC, Value); return; - case 0xA4600028: LogMessage("%08X: read from PI_BSD_DOM2_PWD_REG (%08X)", PC, Value); return; - case 0xA460002C: LogMessage("%08X: read from PI_BSD_DOM2_PGS_REG (%08X)", PC, Value); return; - case 0xA4600030: LogMessage("%08X: read from PI_BSD_DOM2_RLS_REG (%08X)", PC, Value); return; - } - } - if (VAddr >= 0xA4700000 && VAddr <= 0xA470001C) - { - if (!g_LogOptions.LogRDRAMInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr, Value); - - switch (VAddr) - { - case 0xA4700000: LogMessage("%08X: read from RI_MODE_REG (%08X)", PC, Value); return; - case 0xA4700004: LogMessage("%08X: read from RI_CONFIG_REG (%08X)", PC, Value); return; - case 0xA4700008: LogMessage("%08X: read from RI_CURRENT_LOAD_REG (%08X)", PC, Value); return; - case 0xA470000C: LogMessage("%08X: read from RI_SELECT_REG (%08X)", PC, Value); return; - case 0xA4700010: LogMessage("%08X: read from RI_REFRESH_REG/RI_COUNT_REG (%08X)", PC, Value); return; - case 0xA4700014: LogMessage("%08X: read from RI_LATENCY_REG (%08X)", PC, Value); return; - case 0xA4700018: LogMessage("%08X: read from RI_RERROR_REG (%08X)", PC, Value); return; - case 0xA470001C: LogMessage("%08X: read from RI_WERROR_REG (%08X)", PC, Value); return; - } - } - if (VAddr == 0xA4800000) - { - if (!g_LogOptions.LogSerialInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr, Value); - LogMessage("%08X: read from SI_DRAM_ADDR_REG (%08X)", PC, Value); - return; - } - if (VAddr == 0xA4800004) - { - if (!g_LogOptions.LogSerialInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr, Value); - LogMessage("%08X: read from SI_PIF_ADDR_RD64B_REG (%08X)", PC, Value); - return; - } - if (VAddr == 0xA4800010) - { - if (!g_LogOptions.LogSerialInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr, Value); - LogMessage("%08X: read from SI_PIF_ADDR_WR64B_REG (%08X)", PC, Value); - return; - } - if (VAddr == 0xA4800018) - { - if (!g_LogOptions.LogSerialInterface) - { - return; - } - g_MMU->LW_VAddr(VAddr, Value); - LogMessage("%08X: read from SI_STATUS_REG (%08X)", PC, Value); - return; - } - if (VAddr >= 0xBFC00000 && VAddr <= 0xBFC007C0) - { - return; - } - if (VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC) - { - if (!g_LogOptions.LogPRDirectMemLoads) - { - return; - } - g_MMU->LW_VAddr(VAddr, Value); - LogMessage("%08X: read word from Pif Ram at 0x%X (%08X)", PC, VAddr - 0xBFC007C0, Value); - return; - } - if (VAddr >= 0xB0000040 && ((VAddr - 0xB0000000) < g_Rom->GetRomSize())) - { - return; - } - if (VAddr >= 0xB0000000 && VAddr < 0xB0000040) - { - if (!g_LogOptions.LogRomHeader) - { - return; - } - - g_MMU->LW_VAddr(VAddr, Value); - switch (VAddr) - { - case 0xB0000004: LogMessage("%08X: read from Rom Clock Rate (%08X)", PC, Value); break; - case 0xB0000008: LogMessage("%08X: read from Rom Boot address offset (%08X)", PC, Value); break; - case 0xB000000C: LogMessage("%08X: read from Rom Release offset (%08X)", PC, Value); break; - case 0xB0000010: LogMessage("%08X: read from Rom CRC1 (%08X)", PC, Value); break; - case 0xB0000014: LogMessage("%08X: read from Rom CRC2 (%08X)", PC, Value); break; - default: LogMessage("%08X: read from Rom header 0x%X (%08X)", PC, VAddr & 0xFF, Value); break; - } - return; - } - if (!g_LogOptions.LogUnknown) - { - return; - } - LogMessage("%08X: read from unknown ??? (%08X)", PC, VAddr); -} - -void Log_SW(uint32_t PC, uint32_t VAddr, uint32_t Value) -{ - if (!g_LogOptions.GenerateLog) - { - return; - } - - if (VAddr < 0xA0000000 || VAddr >= 0xC0000000) - { - uint32_t PAddr; - if (!g_TransVaddr->TranslateVaddr(VAddr, PAddr)) - { - if (g_LogOptions.LogUnknown) - { - LogMessage("%08X: Writing 0x%08X to %08X", PC, Value, VAddr); - } - return; - } - VAddr = PAddr + 0xA0000000; - } - - if (VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize())) - { - return; - } - if (VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) - { - if (!g_LogOptions.LogRDRamRegisters) - { - return; - } - switch (VAddr) - { - case 0xA3F00000: LogMessage("%08X: Writing 0x%08X to RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG", PC, Value); return; - case 0xA3F00004: LogMessage("%08X: Writing 0x%08X to RDRAM_DEVICE_ID_REG", PC, Value); return; - case 0xA3F00008: LogMessage("%08X: Writing 0x%08X to RDRAM_DELAY_REG", PC, Value); return; - case 0xA3F0000C: LogMessage("%08X: Writing 0x%08X to RDRAM_MODE_REG", PC, Value); return; - case 0xA3F00010: LogMessage("%08X: Writing 0x%08X to RDRAM_REF_INTERVAL_REG", PC, Value); return; - case 0xA3F00014: LogMessage("%08X: Writing 0x%08X to RDRAM_REF_ROW_REG", PC, Value); return; - case 0xA3F00018: LogMessage("%08X: Writing 0x%08X to RDRAM_RAS_INTERVAL_REG", PC, Value); return; - case 0xA3F0001C: LogMessage("%08X: Writing 0x%08X to RDRAM_MIN_INTERVAL_REG", PC, Value); return; - case 0xA3F00020: LogMessage("%08X: Writing 0x%08X to RDRAM_ADDR_SELECT_REG", PC, Value); return; - case 0xA3F00024: LogMessage("%08X: Writing 0x%08X to RDRAM_DEVICE_MANUF_REG", PC, Value); return; - } - } - if (VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC) - { - return; - } - - if (VAddr >= 0xA4040000 && VAddr <= 0xA404001C) - { - if (!g_LogOptions.LogSPRegisters) - { - return; - } - switch (VAddr) - { - case 0xA4040000: LogMessage("%08X: Writing 0x%08X to SP_MEM_ADDR_REG", PC, Value); return; - case 0xA4040004: LogMessage("%08X: Writing 0x%08X to SP_DRAM_ADDR_REG", PC, Value); return; - case 0xA4040008: LogMessage("%08X: Writing 0x%08X to SP_RD_LEN_REG", PC, Value); return; - case 0xA404000C: LogMessage("%08X: Writing 0x%08X to SP_WR_LEN_REG", PC, Value); return; - case 0xA4040010: LogMessage("%08X: Writing 0x%08X to SP_STATUS_REG", PC, Value); return; - case 0xA4040014: LogMessage("%08X: Writing 0x%08X to SP_DMA_FULL_REG", PC, Value); return; - case 0xA4040018: LogMessage("%08X: Writing 0x%08X to SP_DMA_BUSY_REG", PC, Value); return; - case 0xA404001C: LogMessage("%08X: Writing 0x%08X to SP_SEMAPHORE_REG", PC, Value); return; - } - } - if (VAddr == 0xA4080000) - { - if (!g_LogOptions.LogSPRegisters) - { - return; - } - LogMessage("%08X: Writing 0x%08X to SP_PC", PC, Value); return; - } - - if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C) - { - if (!g_LogOptions.LogDPCRegisters) - { - return; - } - switch (VAddr) - { - case 0xA4100000: LogMessage("%08X: Writing 0x%08X to DPC_START_REG", PC, Value); return; - case 0xA4100004: LogMessage("%08X: Writing 0x%08X to DPC_END_REG", PC, Value); return; - case 0xA4100008: LogMessage("%08X: Writing 0x%08X to DPC_CURRENT_REG", PC, Value); return; - case 0xA410000C: LogMessage("%08X: Writing 0x%08X to DPC_STATUS_REG", PC, Value); return; - case 0xA4100010: LogMessage("%08X: Writing 0x%08X to DPC_CLOCK_REG", PC, Value); return; - case 0xA4100014: LogMessage("%08X: Writing 0x%08X to DPC_BUFBUSY_REG", PC, Value); return; - case 0xA4100018: LogMessage("%08X: Writing 0x%08X to DPC_PIPEBUSY_REG", PC, Value); return; - case 0xA410001C: LogMessage("%08X: Writing 0x%08X to DPC_TMEM_REG", PC, Value); return; - } - } - - if (VAddr >= 0xA4200000 && VAddr <= 0xA420000C) - { - if (!g_LogOptions.LogDPSRegisters) - { - return; - } - switch (VAddr) - { - case 0xA4200000: LogMessage("%08X: Writing 0x%08X to DPS_TBIST_REG", PC, Value); return; - case 0xA4200004: LogMessage("%08X: Writing 0x%08X to DPS_TEST_MODE_REG", PC, Value); return; - case 0xA4200008: LogMessage("%08X: Writing 0x%08X to DPS_BUFTEST_ADDR_REG", PC, Value); return; - case 0xA420000C: LogMessage("%08X: Writing 0x%08X to DPS_BUFTEST_DATA_REG", PC, Value); return; - } - } - - if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C) - { - if (!g_LogOptions.LogMIPSInterface) - { - return; - } - switch (VAddr) - { - case 0xA4300000: LogMessage("%08X: Writing 0x%08X to MI_INIT_MODE_REG/MI_MODE_REG", PC, Value); return; - case 0xA4300004: LogMessage("%08X: Writing 0x%08X to MI_VERSION_REG/MI_NOOP_REG", PC, Value); return; - case 0xA4300008: LogMessage("%08X: Writing 0x%08X to MI_INTR_REG", PC, Value); return; - case 0xA430000C: LogMessage("%08X: Writing 0x%08X to MI_INTR_MASK_REG", PC, Value); return; - } - } - if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034) - { - if (!g_LogOptions.LogVideoInterface) - { - return; - } - switch (VAddr) - { - case 0xA4400000: LogMessage("%08X: Writing 0x%08X to VI_STATUS_REG/VI_CONTROL_REG", PC, Value); return; - case 0xA4400004: LogMessage("%08X: Writing 0x%08X to VI_ORIGIN_REG/VI_DRAM_ADDR_REG", PC, Value); return; - case 0xA4400008: LogMessage("%08X: Writing 0x%08X to VI_WIDTH_REG/VI_H_WIDTH_REG", PC, Value); return; - case 0xA440000C: LogMessage("%08X: Writing 0x%08X to VI_INTR_REG/VI_V_INTR_REG", PC, Value); return; - case 0xA4400010: LogMessage("%08X: Writing 0x%08X to VI_CURRENT_REG/VI_V_CURRENT_LINE_REG", PC, Value); return; - case 0xA4400014: LogMessage("%08X: Writing 0x%08X to VI_BURST_REG/VI_TIMING_REG", PC, Value); return; - case 0xA4400018: LogMessage("%08X: Writing 0x%08X to VI_V_SYNC_REG", PC, Value); return; - case 0xA440001C: LogMessage("%08X: Writing 0x%08X to VI_H_SYNC_REG", PC, Value); return; - case 0xA4400020: LogMessage("%08X: Writing 0x%08X to VI_LEAP_REG/VI_H_SYNC_LEAP_REG", PC, Value); return; - case 0xA4400024: LogMessage("%08X: Writing 0x%08X to VI_H_START_REG/VI_H_VIDEO_REG", PC, Value); return; - case 0xA4400028: LogMessage("%08X: Writing 0x%08X to VI_V_START_REG/VI_V_VIDEO_REG", PC, Value); return; - case 0xA440002C: LogMessage("%08X: Writing 0x%08X to VI_V_BURST_REG", PC, Value); return; - case 0xA4400030: LogMessage("%08X: Writing 0x%08X to VI_X_SCALE_REG", PC, Value); return; - case 0xA4400034: LogMessage("%08X: Writing 0x%08X to VI_Y_SCALE_REG", PC, Value); return; - } - } - - if (VAddr >= 0xA4500000 && VAddr <= 0xA4500014) - { - if (!g_LogOptions.LogAudioInterface) - { - return; - } - switch (VAddr) - { - case 0xA4500000: LogMessage("%08X: Writing 0x%08X to AI_DRAM_ADDR_REG", PC, Value); return; - case 0xA4500004: LogMessage("%08X: Writing 0x%08X to AI_LEN_REG", PC, Value); return; - case 0xA4500008: LogMessage("%08X: Writing 0x%08X to AI_CONTROL_REG", PC, Value); return; - case 0xA450000C: LogMessage("%08X: Writing 0x%08X to AI_STATUS_REG", PC, Value); return; - case 0xA4500010: LogMessage("%08X: Writing 0x%08X to AI_DACRATE_REG", PC, Value); return; - case 0xA4500014: LogMessage("%08X: Writing 0x%08X to AI_BITRATE_REG", PC, Value); return; - } - } - - if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030) - { - if (!g_LogOptions.LogPerInterface) - { - return; - } - switch (VAddr) - { - case 0xA4600000: LogMessage("%08X: Writing 0x%08X to PI_DRAM_ADDR_REG", PC, Value); return; - case 0xA4600004: LogMessage("%08X: Writing 0x%08X to PI_CART_ADDR_REG", PC, Value); return; - case 0xA4600008: LogMessage("%08X: Writing 0x%08X to PI_RD_LEN_REG", PC, Value); return; - case 0xA460000C: LogMessage("%08X: Writing 0x%08X to PI_WR_LEN_REG", PC, Value); return; - case 0xA4600010: LogMessage("%08X: Writing 0x%08X to PI_STATUS_REG", PC, Value); return; - case 0xA4600014: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_LAT_REG/PI_DOMAIN1_REG", PC, Value); return; - case 0xA4600018: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_PWD_REG", PC, Value); return; - case 0xA460001C: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_PGS_REG", PC, Value); return; - case 0xA4600020: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_RLS_REG", PC, Value); return; - case 0xA4600024: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_LAT_REG/PI_DOMAIN2_REG", PC, Value); return; - case 0xA4600028: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_PWD_REG", PC, Value); return; - case 0xA460002C: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_PGS_REG", PC, Value); return; - case 0xA4600030: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_RLS_REG", PC, Value); return; - } - } - if (VAddr >= 0xA4700000 && VAddr <= 0xA470001C) - { - if (!g_LogOptions.LogRDRAMInterface) - { - return; - } - switch (VAddr) - { - case 0xA4700000: LogMessage("%08X: Writing 0x%08X to RI_MODE_REG", PC, Value); return; - case 0xA4700004: LogMessage("%08X: Writing 0x%08X to RI_CONFIG_REG", PC, Value); return; - case 0xA4700008: LogMessage("%08X: Writing 0x%08X to RI_CURRENT_LOAD_REG", PC, Value); return; - case 0xA470000C: LogMessage("%08X: Writing 0x%08X to RI_SELECT_REG", PC, Value); return; - case 0xA4700010: LogMessage("%08X: Writing 0x%08X to RI_REFRESH_REG/RI_COUNT_REG", PC, Value); return; - case 0xA4700014: LogMessage("%08X: Writing 0x%08X to RI_LATENCY_REG", PC, Value); return; - case 0xA4700018: LogMessage("%08X: Writing 0x%08X to RI_RERROR_REG", PC, Value); return; - case 0xA470001C: LogMessage("%08X: Writing 0x%08X to RI_WERROR_REG", PC, Value); return; - } - } - if (VAddr == 0xA4800000) - { - if (!g_LogOptions.LogSerialInterface) - { - return; - } - LogMessage("%08X: Writing 0x%08X to SI_DRAM_ADDR_REG", PC, Value); return; - } - if (VAddr == 0xA4800004) - { - if (g_LogOptions.LogPRDMAOperations) - { - LogMessage("%08X: A DMA transfer from the PIF ram has occured", PC); - } - if (!g_LogOptions.LogSerialInterface) - { - return; - } - LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_RD64B_REG", PC, Value); return; - } - if (VAddr == 0xA4800010) - { - if (g_LogOptions.LogPRDMAOperations) - { - LogMessage("%08X: A DMA transfer to the PIF ram has occured", PC); - } - if (!g_LogOptions.LogSerialInterface) - { - return; - } - LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_WR64B_REG", PC, Value); return; - } - if (VAddr == 0xA4800018) - { - if (!g_LogOptions.LogSerialInterface) - { - return; - } - LogMessage("%08X: Writing 0x%08X to SI_STATUS_REG", PC, Value); return; - } - - if (VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC) - { - if (!g_LogOptions.LogPRDirectMemStores) - { - return; - } - LogMessage("%08X: Writing 0x%08X to Pif Ram at 0x%X", PC, Value, VAddr - 0xBFC007C0); - return; - } - if (!g_LogOptions.LogUnknown) - { - return; - } - LogMessage("%08X: Writing 0x%08X to %08X ????", PC, Value, VAddr); -} - LRESULT CALLBACK LogPifProc(HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: - if (TempOptions.LogPRDMAOperations) { CheckDlgButton(hDlg, IDC_SI_DMA, BST_CHECKED); } - if (TempOptions.LogPRDirectMemLoads) { CheckDlgButton(hDlg, IDC_DIRECT_WRITE, BST_CHECKED); } - if (TempOptions.LogPRDMAMemLoads) { CheckDlgButton(hDlg, IDC_DMA_WRITE, BST_CHECKED); } - if (TempOptions.LogPRDirectMemStores) { CheckDlgButton(hDlg, IDC_DIRECT_READ, BST_CHECKED); } - if (TempOptions.LogPRDMAMemStores) { CheckDlgButton(hDlg, IDC_DMA_READ, BST_CHECKED); } - if (TempOptions.LogControllerPak) { CheckDlgButton(hDlg, IDC_CONT_PAK, BST_CHECKED); } - break; + { + if (CLogSettings::LogPRDMAOperations()) { CheckDlgButton(hDlg, IDC_SI_DMA, BST_CHECKED); } + if (CLogSettings::LogPRDirectMemLoads()) { CheckDlgButton(hDlg, IDC_DIRECT_WRITE, BST_CHECKED); } + if (CLogSettings::LogPRDMAMemLoads()) { CheckDlgButton(hDlg, IDC_DMA_WRITE, BST_CHECKED); } + if (CLogSettings::LogPRDirectMemStores()) { CheckDlgButton(hDlg, IDC_DIRECT_READ, BST_CHECKED); } + if (CLogSettings::LogPRDMAMemStores()) { CheckDlgButton(hDlg, IDC_DMA_READ, BST_CHECKED); } + if (CLogSettings::LogControllerPak()) { CheckDlgButton(hDlg, IDC_CONT_PAK, BST_CHECKED); } + } + break; case WM_NOTIFY: if (((NMHDR FAR *) lParam)->code != PSN_APPLY) { break; } - TempOptions.LogPRDMAOperations = IsDlgButtonChecked(hDlg, IDC_SI_DMA) == BST_CHECKED ? TRUE : FALSE; - TempOptions.LogPRDirectMemLoads = IsDlgButtonChecked(hDlg, IDC_DIRECT_WRITE) == BST_CHECKED ? TRUE : FALSE; - TempOptions.LogPRDMAMemLoads = IsDlgButtonChecked(hDlg, IDC_DMA_WRITE) == BST_CHECKED ? TRUE : FALSE; - TempOptions.LogPRDirectMemStores = IsDlgButtonChecked(hDlg, IDC_DIRECT_READ) == BST_CHECKED ? TRUE : FALSE; - TempOptions.LogPRDMAMemStores = IsDlgButtonChecked(hDlg, IDC_DMA_READ) == BST_CHECKED ? TRUE : FALSE; - TempOptions.LogControllerPak = IsDlgButtonChecked(hDlg, IDC_CONT_PAK) == BST_CHECKED ? TRUE : FALSE; + g_Settings->SaveBool(Logging_LogPRDMAOperations, IsDlgButtonChecked(hDlg, IDC_SI_DMA) == BST_CHECKED ? true : false); + g_Settings->SaveBool(Logging_LogPRDirectMemLoads, IsDlgButtonChecked(hDlg, IDC_DIRECT_WRITE) == BST_CHECKED ? true : false); + g_Settings->SaveBool(Logging_LogPRDMAMemLoads, IsDlgButtonChecked(hDlg, IDC_DMA_WRITE) == BST_CHECKED ? true : false); + g_Settings->SaveBool(Logging_LogPRDirectMemStores, IsDlgButtonChecked(hDlg, IDC_DIRECT_READ) == BST_CHECKED ? true : false); + g_Settings->SaveBool(Logging_LogPRDMAMemStores, IsDlgButtonChecked(hDlg, IDC_DMA_READ) == BST_CHECKED ? true : false); + g_Settings->SaveBool(Logging_LogControllerPak, IsDlgButtonChecked(hDlg, IDC_CONT_PAK) == BST_CHECKED ? true : false); break; default: return FALSE; @@ -788,133 +134,37 @@ LRESULT CALLBACK LogRegProc(HWND hDlg, UINT uMsg, WPARAM /*wParam*/, LPARAM lPar switch (uMsg) { case WM_INITDIALOG: - if (TempOptions.LogRDRamRegisters) { CheckDlgButton(hDlg, IDC_RDRAM, BST_CHECKED); } - if (TempOptions.LogSPRegisters) { CheckDlgButton(hDlg, IDC_SP_REG, BST_CHECKED); } - if (TempOptions.LogDPCRegisters) { CheckDlgButton(hDlg, IDC_DPC_REG, BST_CHECKED); } - if (TempOptions.LogDPSRegisters) { CheckDlgButton(hDlg, IDC_DPS_REG, BST_CHECKED); } - if (TempOptions.LogMIPSInterface) { CheckDlgButton(hDlg, IDC_MI_REG, BST_CHECKED); } - if (TempOptions.LogVideoInterface) { CheckDlgButton(hDlg, IDC_VI_REG, BST_CHECKED); } - if (TempOptions.LogAudioInterface) { CheckDlgButton(hDlg, IDC_AI_REG, BST_CHECKED); } - if (TempOptions.LogPerInterface) { CheckDlgButton(hDlg, IDC_PI_REG, BST_CHECKED); } - if (TempOptions.LogRDRAMInterface) { CheckDlgButton(hDlg, IDC_RI_REG, BST_CHECKED); } - if (TempOptions.LogSerialInterface) { CheckDlgButton(hDlg, IDC_SI_REG, BST_CHECKED); } - break; + { + if (CLogSettings::LogRDRamRegisters()) { CheckDlgButton(hDlg, IDC_RDRAM, BST_CHECKED); } + if (CLogSettings::LogSPRegisters()) { CheckDlgButton(hDlg, IDC_SP_REG, BST_CHECKED); } + if (CLogSettings::LogDPCRegisters()) { CheckDlgButton(hDlg, IDC_DPC_REG, BST_CHECKED); } + if (CLogSettings::LogDPSRegisters()) { CheckDlgButton(hDlg, IDC_DPS_REG, BST_CHECKED); } + if (CLogSettings::LogMIPSInterface()) { CheckDlgButton(hDlg, IDC_MI_REG, BST_CHECKED); } + if (CLogSettings::LogVideoInterface()) { CheckDlgButton(hDlg, IDC_VI_REG, BST_CHECKED); } + if (CLogSettings::LogAudioInterface()) { CheckDlgButton(hDlg, IDC_AI_REG, BST_CHECKED); } + if (CLogSettings::LogPerInterface()) { CheckDlgButton(hDlg, IDC_PI_REG, BST_CHECKED); } + if (CLogSettings::LogRDRAMInterface()) { CheckDlgButton(hDlg, IDC_RI_REG, BST_CHECKED); } + if (CLogSettings::LogSerialInterface()) { CheckDlgButton(hDlg, IDC_SI_REG, BST_CHECKED); } + } + break; case WM_NOTIFY: if (((NMHDR FAR *) lParam)->code != PSN_APPLY) { break; } - TempOptions.LogRDRamRegisters = IsDlgButtonChecked(hDlg, IDC_RDRAM) == BST_CHECKED ? TRUE : FALSE; - TempOptions.LogSPRegisters = IsDlgButtonChecked(hDlg, IDC_SP_REG) == BST_CHECKED ? TRUE : FALSE; - TempOptions.LogDPCRegisters = IsDlgButtonChecked(hDlg, IDC_DPC_REG) == BST_CHECKED ? TRUE : FALSE; - TempOptions.LogDPSRegisters = IsDlgButtonChecked(hDlg, IDC_DPS_REG) == BST_CHECKED ? TRUE : FALSE; - TempOptions.LogMIPSInterface = IsDlgButtonChecked(hDlg, IDC_MI_REG) == BST_CHECKED ? TRUE : FALSE; - TempOptions.LogVideoInterface = IsDlgButtonChecked(hDlg, IDC_VI_REG) == BST_CHECKED ? TRUE : FALSE; - TempOptions.LogAudioInterface = IsDlgButtonChecked(hDlg, IDC_AI_REG) == BST_CHECKED ? TRUE : FALSE; - TempOptions.LogPerInterface = IsDlgButtonChecked(hDlg, IDC_PI_REG) == BST_CHECKED ? TRUE : FALSE; - TempOptions.LogRDRAMInterface = IsDlgButtonChecked(hDlg, IDC_RI_REG) == BST_CHECKED ? TRUE : FALSE; - TempOptions.LogSerialInterface = IsDlgButtonChecked(hDlg, IDC_SI_REG) == BST_CHECKED ? TRUE : FALSE; + g_Settings->SaveBool(Logging_LogRDRamRegisters, IsDlgButtonChecked(hDlg, IDC_RDRAM) == BST_CHECKED ? true : false); + g_Settings->SaveBool(Logging_LogSPRegisters, IsDlgButtonChecked(hDlg, IDC_SP_REG) == BST_CHECKED ? true : false); + g_Settings->SaveBool(Logging_LogDPCRegisters, IsDlgButtonChecked(hDlg, IDC_DPC_REG) == BST_CHECKED ? true : false); + g_Settings->SaveBool(Logging_LogDPSRegisters, IsDlgButtonChecked(hDlg, IDC_DPS_REG) == BST_CHECKED ? true : false); + g_Settings->SaveBool(Logging_LogMIPSInterface, IsDlgButtonChecked(hDlg, IDC_MI_REG) == BST_CHECKED ? true : false); + g_Settings->SaveBool(Logging_LogVideoInterface, IsDlgButtonChecked(hDlg, IDC_VI_REG) == BST_CHECKED ? true : false); + g_Settings->SaveBool(Logging_LogAudioInterface, IsDlgButtonChecked(hDlg, IDC_AI_REG) == BST_CHECKED ? true : false); + g_Settings->SaveBool(Logging_LogPerInterface, IsDlgButtonChecked(hDlg, IDC_PI_REG) == BST_CHECKED ? true : false); + g_Settings->SaveBool(Logging_LogRDRAMInterface, IsDlgButtonChecked(hDlg, IDC_RI_REG) == BST_CHECKED ? true : false); + g_Settings->SaveBool(Logging_LogSerialInterface, IsDlgButtonChecked(hDlg, IDC_SI_REG) == BST_CHECKED ? true : false); break; default: return FALSE; } return TRUE; -} - -void SaveLogSetting(HKEY hKey, char * String, BOOL Value) -{ - DWORD StoreValue = Value; - RegSetValueEx(hKey, String, 0, REG_DWORD, (CONST BYTE *)&StoreValue, sizeof(DWORD)); -} - -void SaveLogOptions(void) -{ - long lResult; - HKEY hKeyResults = 0; - DWORD Disposition = 0; - char String[200]; - - sprintf(String, "Software\\N64 Emulation\\%s\\Logging", g_Settings->LoadStringVal(Setting_ApplicationName).c_str()); - lResult = RegCreateKeyEx(HKEY_CURRENT_USER, String, 0, "", REG_OPTION_NON_VOLATILE, - KEY_ALL_ACCESS, NULL, &hKeyResults, &Disposition); - - SaveLogSetting(hKeyResults, "Log RDRAM", TempOptions.LogRDRamRegisters); - SaveLogSetting(hKeyResults, "Log SP", TempOptions.LogSPRegisters); - SaveLogSetting(hKeyResults, "Log DP Command", TempOptions.LogDPCRegisters); - SaveLogSetting(hKeyResults, "Log DP Span", TempOptions.LogDPSRegisters); - SaveLogSetting(hKeyResults, "Log MIPS Interface (MI)", TempOptions.LogMIPSInterface); - SaveLogSetting(hKeyResults, "Log Video Interface (VI)", TempOptions.LogVideoInterface); - SaveLogSetting(hKeyResults, "Log Audio Interface (AI)", TempOptions.LogAudioInterface); - SaveLogSetting(hKeyResults, "Log Peripheral Interface (PI)", TempOptions.LogPerInterface); - SaveLogSetting(hKeyResults, "Log RDRAM Interface (RI)", TempOptions.LogRDRAMInterface); - SaveLogSetting(hKeyResults, "Log Serial Interface (SI)", TempOptions.LogSerialInterface); - SaveLogSetting(hKeyResults, "Log PifRam DMA Operations", TempOptions.LogPRDMAOperations); - SaveLogSetting(hKeyResults, "Log PifRam Direct Memory Loads", TempOptions.LogPRDirectMemLoads); - SaveLogSetting(hKeyResults, "Log PifRam DMA Memory Loads", TempOptions.LogPRDMAMemLoads); - SaveLogSetting(hKeyResults, "Log PifRam Direct Memory Stores", TempOptions.LogPRDirectMemStores); - SaveLogSetting(hKeyResults, "Log PifRam DMA Memory Stores", TempOptions.LogPRDMAMemStores); - SaveLogSetting(hKeyResults, "Log Controller Pak", TempOptions.LogControllerPak); - SaveLogSetting(hKeyResults, "Log CP0 changes", TempOptions.LogCP0changes); - SaveLogSetting(hKeyResults, "Log CP0 reads", TempOptions.LogCP0reads); - SaveLogSetting(hKeyResults, "Log Exceptions", TempOptions.LogExceptions); - SaveLogSetting(hKeyResults, "No Interrupts", TempOptions.NoInterrupts); - SaveLogSetting(hKeyResults, "Log TLB", TempOptions.LogTLB); - SaveLogSetting(hKeyResults, "Log Cache Operations", TempOptions.LogCache); - SaveLogSetting(hKeyResults, "Log Rom Header", TempOptions.LogRomHeader); - SaveLogSetting(hKeyResults, "Log Unknown access", TempOptions.LogUnknown); - - RegCloseKey(hKeyResults); -} - -void LogMessage(const char * Message, ...) -{ - DWORD dwWritten; - char Msg[400]; - va_list ap; - - if (!g_Settings->LoadBool(Debugger_Enabled)) - { - return; - } - if (g_hLogFile == NULL) - { - return; - } - - va_start(ap, Message); - vsprintf(Msg, Message, ap); - va_end(ap); - - strcat(Msg, "\r\n"); - - WriteFile(g_hLogFile, Msg, strlen(Msg), &dwWritten, NULL); -} - -void StartLog(void) -{ - if (!g_LogOptions.GenerateLog) - { - StopLog(); - return; - } - if (g_hLogFile) - { - return; - } - - CPath LogFile(CPath::MODULE_DIRECTORY); - LogFile.AppendDirectory("Logs"); - LogFile.SetNameExtension("cpudebug.log"); - - g_hLogFile = CreateFile(LogFile, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); - SetFilePointer(g_hLogFile, 0, NULL, FILE_BEGIN); -} - -void StopLog(void) -{ - if (g_hLogFile) - { - CloseHandle(g_hLogFile); - } - g_hLogFile = NULL; } \ No newline at end of file diff --git a/Source/Project64/User Interface/LoggingUI.h b/Source/Project64/User Interface/LoggingUI.h index 9d2f34138..de73fcab0 100644 --- a/Source/Project64/User Interface/LoggingUI.h +++ b/Source/Project64/User Interface/LoggingUI.h @@ -10,47 +10,4 @@ ****************************************************************************/ #pragma once -typedef struct -{ - bool GenerateLog; - - /* Registers Log */ - bool LogRDRamRegisters; - bool LogSPRegisters; - bool LogDPCRegisters; - bool LogDPSRegisters; - bool LogMIPSInterface; - bool LogVideoInterface; - bool LogAudioInterface; - bool LogPerInterface; - bool LogRDRAMInterface; - bool LogSerialInterface; - - /* Pif Ram Log */ - bool LogPRDMAOperations; - bool LogPRDirectMemLoads; - bool LogPRDMAMemLoads; - bool LogPRDirectMemStores; - bool LogPRDMAMemStores; - bool LogControllerPak; - - /* Special Log */ - bool LogCP0changes; - bool LogCP0reads; - bool LogTLB; - bool LogExceptions; - bool NoInterrupts; - bool LogCache; - bool LogRomHeader; - bool LogUnknown; -} LOG_OPTIONS; - -extern LOG_OPTIONS g_LogOptions; - void EnterLogOptions ( HWND hwndOwner ); -void StartLog ( void ); -void StopLog ( void ); -void LoadLogOptions ( LOG_OPTIONS * LogOptions, bool AlwaysFill ); -void Log_LW ( uint32_t PC, uint32_t VAddr ); -void Log_SW ( uint32_t PC, uint32_t VAddr, uint32_t Value ); -void LogMessage ( const char * Message, ... ); diff --git a/Source/Project64/User Interface/Main Menu Class.cpp b/Source/Project64/User Interface/Main Menu Class.cpp index cae92fe2c..7b760a9f5 100644 --- a/Source/Project64/User Interface/Main Menu Class.cpp +++ b/Source/Project64/User Interface/Main Menu Class.cpp @@ -17,6 +17,7 @@ m_Gui(hMainWindow) m_ChangeSettingList.push_back(UserInterface_InFullScreen); m_ChangeSettingList.push_back(UserInterface_AlwaysOnTop); m_ChangeSettingList.push_back(UserInterface_ShowCPUPer); + m_ChangeSettingList.push_back(Logging_GenerateLog); m_ChangeSettingList.push_back(Debugger_ProfileCode); m_ChangeSettingList.push_back(Debugger_ShowTLBMisses); m_ChangeSettingList.push_back(Debugger_ShowUnhandledMemory); @@ -28,7 +29,6 @@ m_Gui(hMainWindow) m_ChangeSettingList.push_back(Debugger_DisableGameFixes); m_ChangeSettingList.push_back(Debugger_AppLogLevel); m_ChangeSettingList.push_back(Debugger_AppLogFlush); - m_ChangeSettingList.push_back(Debugger_GenerateDebugLog); m_ChangeSettingList.push_back(Game_CurrentSaveState); m_ChangeSettingList.push_back(Setting_CurrentLanguage); @@ -506,7 +506,7 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI break; case ID_DEBUGGER_LOGOPTIONS: m_Gui->EnterLogOptions(); break; case ID_DEBUGGER_GENERATELOG: - g_Settings->SaveBool(Debugger_GenerateDebugLog, !g_Settings->LoadBool(Debugger_GenerateDebugLog)); + g_Settings->SaveBool(Logging_GenerateLog, !g_Settings->LoadBool(Logging_GenerateLog)); break; case ID_DEBUGGER_DUMPMEMORY: m_Gui->Debug_ShowMemoryDump(); break; case ID_DEBUGGER_SEARCHMEMORY: m_Gui->Debug_ShowMemorySearch(); break; @@ -1087,7 +1087,7 @@ void CMainMenu::FillOutMenu(HMENU hMenu) DebugLoggingMenu.push_back(Item); Item.Reset(ID_DEBUGGER_GENERATELOG, EMPTY_STRING, EMPTY_STDSTR, NULL, L"Generate Log"); - if (g_Settings->LoadBool(Debugger_GenerateDebugLog)) { Item.SetItemTicked(true); } + if (g_Settings->LoadBool(Logging_GenerateLog)) { Item.SetItemTicked(true); } DebugLoggingMenu.push_back(Item); /* Debugger Main Menu diff --git a/Source/Project64/logging.cpp b/Source/Project64/logging.cpp new file mode 100644 index 000000000..f11b6c41e --- /dev/null +++ b/Source/Project64/logging.cpp @@ -0,0 +1,628 @@ +/**************************************************************************** +* * +* Project64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2012 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +#include "stdafx.h" +#include "logging.h" +#include +#include +#include +#include +#include + +CFile * CLogging::m_hLogFile = NULL; + +void CLogging::Log_LW(uint32_t PC, uint32_t VAddr) +{ + if (!GenerateLog()) + { + return; + } + + if (VAddr < 0xA0000000 || VAddr >= 0xC0000000) + { + uint32_t PAddr; + if (!g_TransVaddr->TranslateVaddr(VAddr, PAddr)) + { + if (LogUnknown()) + { + LogMessage("%08X: read from unknown ??? (%08X)", PC, VAddr); + } + return; + } + VAddr = PAddr + 0xA0000000; + } + + uint32_t Value; + if (VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize())) + { + return; + } + if (VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) + { + if (!LogRDRamRegisters()) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + + switch (VAddr) + { + case 0xA3F00000: LogMessage("%08X: read from RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG (%08X)", PC, Value); return; + case 0xA3F00004: LogMessage("%08X: read from RDRAM_DEVICE_ID_REG (%08X)", PC, Value); return; + case 0xA3F00008: LogMessage("%08X: read from RDRAM_DELAY_REG (%08X)", PC, Value); return; + case 0xA3F0000C: LogMessage("%08X: read from RDRAM_MODE_REG (%08X)", PC, Value); return; + case 0xA3F00010: LogMessage("%08X: read from RDRAM_REF_INTERVAL_REG (%08X)", PC, Value); return; + case 0xA3F00014: LogMessage("%08X: read from RDRAM_REF_ROW_REG (%08X)", PC, Value); return; + case 0xA3F00018: LogMessage("%08X: read from RDRAM_RAS_INTERVAL_REG (%08X)", PC, Value); return; + case 0xA3F0001C: LogMessage("%08X: read from RDRAM_MIN_INTERVAL_REG (%08X)", PC, Value); return; + case 0xA3F00020: LogMessage("%08X: read from RDRAM_ADDR_SELECT_REG (%08X)", PC, Value); return; + case 0xA3F00024: LogMessage("%08X: read from RDRAM_DEVICE_MANUF_REG (%08X)", PC, Value); return; + } + } + + if (VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC) + { + return; + } + if (VAddr >= 0xA4040000 && VAddr <= 0xA404001C) + { + if (!LogSPRegisters()) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + + switch (VAddr) + { + case 0xA4040000: LogMessage("%08X: read from SP_MEM_ADDR_REG (%08X)", PC, Value); break; + case 0xA4040004: LogMessage("%08X: read from SP_DRAM_ADDR_REG (%08X)", PC, Value); break; + case 0xA4040008: LogMessage("%08X: read from SP_RD_LEN_REG (%08X)", PC, Value); break; + case 0xA404000C: LogMessage("%08X: read from SP_WR_LEN_REG (%08X)", PC, Value); break; + case 0xA4040010: LogMessage("%08X: read from SP_STATUS_REG (%08X)", PC, Value); break; + case 0xA4040014: LogMessage("%08X: read from SP_DMA_FULL_REG (%08X)", PC, Value); break; + case 0xA4040018: LogMessage("%08X: read from SP_DMA_BUSY_REG (%08X)", PC, Value); break; + case 0xA404001C: LogMessage("%08X: read from SP_SEMAPHORE_REG (%08X)", PC, Value); break; + } + return; + } + if (VAddr == 0xA4080000) + { + if (!LogSPRegisters()) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + LogMessage("%08X: read from SP_PC (%08X)", PC, Value); + return; + } + if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C) + { + if (!LogDPCRegisters()) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + + switch (VAddr) + { + case 0xA4100000: LogMessage("%08X: read from DPC_START_REG (%08X)", PC, Value); return; + case 0xA4100004: LogMessage("%08X: read from DPC_END_REG (%08X)", PC, Value); return; + case 0xA4100008: LogMessage("%08X: read from DPC_CURRENT_REG (%08X)", PC, Value); return; + case 0xA410000C: LogMessage("%08X: read from DPC_STATUS_REG (%08X)", PC, Value); return; + case 0xA4100010: LogMessage("%08X: read from DPC_CLOCK_REG (%08X)", PC, Value); return; + case 0xA4100014: LogMessage("%08X: read from DPC_BUFBUSY_REG (%08X)", PC, Value); return; + case 0xA4100018: LogMessage("%08X: read from DPC_PIPEBUSY_REG (%08X)", PC, Value); return; + case 0xA410001C: LogMessage("%08X: read from DPC_TMEM_REG (%08X)", PC, Value); return; + } + } + if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C) + { + if (!LogMIPSInterface()) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + + switch (VAddr) + { + case 0xA4300000: LogMessage("%08X: read from MI_INIT_MODE_REG/MI_MODE_REG (%08X)", PC, Value); return; + case 0xA4300004: LogMessage("%08X: read from MI_VERSION_REG/MI_NOOP_REG (%08X)", PC, Value); return; + case 0xA4300008: LogMessage("%08X: read from MI_INTR_REG (%08X)", PC, Value); return; + case 0xA430000C: LogMessage("%08X: read from MI_INTR_MASK_REG (%08X)", PC, Value); return; + } + } + if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034) + { + if (!LogVideoInterface()) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + + switch (VAddr) + { + case 0xA4400000: LogMessage("%08X: read from VI_STATUS_REG/VI_CONTROL_REG (%08X)", PC, Value); return; + case 0xA4400004: LogMessage("%08X: read from VI_ORIGIN_REG/VI_DRAM_ADDR_REG (%08X)", PC, Value); return; + case 0xA4400008: LogMessage("%08X: read from VI_WIDTH_REG/VI_H_WIDTH_REG (%08X)", PC, Value); return; + case 0xA440000C: LogMessage("%08X: read from VI_INTR_REG/VI_V_INTR_REG (%08X)", PC, Value); return; + case 0xA4400010: LogMessage("%08X: read from VI_CURRENT_REG/VI_V_CURRENT_LINE_REG (%08X)", PC, Value); return; + case 0xA4400014: LogMessage("%08X: read from VI_BURST_REG/VI_TIMING_REG (%08X)", PC, Value); return; + case 0xA4400018: LogMessage("%08X: read from VI_V_SYNC_REG (%08X)", PC, Value); return; + case 0xA440001C: LogMessage("%08X: read from VI_H_SYNC_REG (%08X)", PC, Value); return; + case 0xA4400020: LogMessage("%08X: read from VI_LEAP_REG/VI_H_SYNC_LEAP_REG (%08X)", PC, Value); return; + case 0xA4400024: LogMessage("%08X: read from VI_H_START_REG/VI_H_VIDEO_REG (%08X)", PC, Value); return; + case 0xA4400028: LogMessage("%08X: read from VI_V_START_REG/VI_V_VIDEO_REG (%08X)", PC, Value); return; + case 0xA440002C: LogMessage("%08X: read from VI_V_BURST_REG (%08X)", PC, Value); return; + case 0xA4400030: LogMessage("%08X: read from VI_X_SCALE_REG (%08X)", PC, Value); return; + case 0xA4400034: LogMessage("%08X: read from VI_Y_SCALE_REG (%08X)", PC, Value); return; + } + } + if (VAddr >= 0xA4500000 && VAddr <= 0xA4500014) + { + if (!LogAudioInterface()) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + + switch (VAddr) + { + case 0xA4500000: LogMessage("%08X: read from AI_DRAM_ADDR_REG (%08X)", PC, Value); return; + case 0xA4500004: LogMessage("%08X: read from AI_LEN_REG (%08X)", PC, Value); return; + case 0xA4500008: LogMessage("%08X: read from AI_CONTROL_REG (%08X)", PC, Value); return; + case 0xA450000C: LogMessage("%08X: read from AI_STATUS_REG (%08X)", PC, Value); return; + case 0xA4500010: LogMessage("%08X: read from AI_DACRATE_REG (%08X)", PC, Value); return; + case 0xA4500014: LogMessage("%08X: read from AI_BITRATE_REG (%08X)", PC, Value); return; + } + } + if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030) + { + if (!LogPerInterface()) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + + switch (VAddr) + { + case 0xA4600000: LogMessage("%08X: read from PI_DRAM_ADDR_REG (%08X)", PC, Value); return; + case 0xA4600004: LogMessage("%08X: read from PI_CART_ADDR_REG (%08X)", PC, Value); return; + case 0xA4600008: LogMessage("%08X: read from PI_RD_LEN_REG (%08X)", PC, Value); return; + case 0xA460000C: LogMessage("%08X: read from PI_WR_LEN_REG (%08X)", PC, Value); return; + case 0xA4600010: LogMessage("%08X: read from PI_STATUS_REG (%08X)", PC, Value); return; + case 0xA4600014: LogMessage("%08X: read from PI_BSD_DOM1_LAT_REG/PI_DOMAIN1_REG (%08X)", PC, Value); return; + case 0xA4600018: LogMessage("%08X: read from PI_BSD_DOM1_PWD_REG (%08X)", PC, Value); return; + case 0xA460001C: LogMessage("%08X: read from PI_BSD_DOM1_PGS_REG (%08X)", PC, Value); return; + case 0xA4600020: LogMessage("%08X: read from PI_BSD_DOM1_RLS_REG (%08X)", PC, Value); return; + case 0xA4600024: LogMessage("%08X: read from PI_BSD_DOM2_LAT_REG/PI_DOMAIN2_REG (%08X)", PC, Value); return; + case 0xA4600028: LogMessage("%08X: read from PI_BSD_DOM2_PWD_REG (%08X)", PC, Value); return; + case 0xA460002C: LogMessage("%08X: read from PI_BSD_DOM2_PGS_REG (%08X)", PC, Value); return; + case 0xA4600030: LogMessage("%08X: read from PI_BSD_DOM2_RLS_REG (%08X)", PC, Value); return; + } + } + if (VAddr >= 0xA4700000 && VAddr <= 0xA470001C) + { + if (!LogRDRAMInterface()) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + + switch (VAddr) + { + case 0xA4700000: LogMessage("%08X: read from RI_MODE_REG (%08X)", PC, Value); return; + case 0xA4700004: LogMessage("%08X: read from RI_CONFIG_REG (%08X)", PC, Value); return; + case 0xA4700008: LogMessage("%08X: read from RI_CURRENT_LOAD_REG (%08X)", PC, Value); return; + case 0xA470000C: LogMessage("%08X: read from RI_SELECT_REG (%08X)", PC, Value); return; + case 0xA4700010: LogMessage("%08X: read from RI_REFRESH_REG/RI_COUNT_REG (%08X)", PC, Value); return; + case 0xA4700014: LogMessage("%08X: read from RI_LATENCY_REG (%08X)", PC, Value); return; + case 0xA4700018: LogMessage("%08X: read from RI_RERROR_REG (%08X)", PC, Value); return; + case 0xA470001C: LogMessage("%08X: read from RI_WERROR_REG (%08X)", PC, Value); return; + } + } + if (VAddr == 0xA4800000) + { + if (!LogSerialInterface()) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + LogMessage("%08X: read from SI_DRAM_ADDR_REG (%08X)", PC, Value); + return; + } + if (VAddr == 0xA4800004) + { + if (!LogSerialInterface()) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + LogMessage("%08X: read from SI_PIF_ADDR_RD64B_REG (%08X)", PC, Value); + return; + } + if (VAddr == 0xA4800010) + { + if (!LogSerialInterface()) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + LogMessage("%08X: read from SI_PIF_ADDR_WR64B_REG (%08X)", PC, Value); + return; + } + if (VAddr == 0xA4800018) + { + if (!LogSerialInterface()) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + LogMessage("%08X: read from SI_STATUS_REG (%08X)", PC, Value); + return; + } + if (VAddr >= 0xBFC00000 && VAddr <= 0xBFC007C0) + { + return; + } + if (VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC) + { + if (!LogPRDirectMemLoads()) + { + return; + } + g_MMU->LW_VAddr(VAddr, Value); + LogMessage("%08X: read word from Pif Ram at 0x%X (%08X)", PC, VAddr - 0xBFC007C0, Value); + return; + } + if (VAddr >= 0xB0000040 && ((VAddr - 0xB0000000) < g_Rom->GetRomSize())) + { + return; + } + if (VAddr >= 0xB0000000 && VAddr < 0xB0000040) + { + if (!LogRomHeader()) + { + return; + } + + g_MMU->LW_VAddr(VAddr, Value); + switch (VAddr) + { + case 0xB0000004: LogMessage("%08X: read from Rom Clock Rate (%08X)", PC, Value); break; + case 0xB0000008: LogMessage("%08X: read from Rom Boot address offset (%08X)", PC, Value); break; + case 0xB000000C: LogMessage("%08X: read from Rom Release offset (%08X)", PC, Value); break; + case 0xB0000010: LogMessage("%08X: read from Rom CRC1 (%08X)", PC, Value); break; + case 0xB0000014: LogMessage("%08X: read from Rom CRC2 (%08X)", PC, Value); break; + default: LogMessage("%08X: read from Rom header 0x%X (%08X)", PC, VAddr & 0xFF, Value); break; + } + return; + } + if (!LogUnknown()) + { + return; + } + LogMessage("%08X: read from unknown ??? (%08X)", PC, VAddr); +} + +void CLogging::Log_SW(uint32_t PC, uint32_t VAddr, uint32_t Value) +{ + if (!GenerateLog()) + { + return; + } + + if (VAddr < 0xA0000000 || VAddr >= 0xC0000000) + { + uint32_t PAddr; + if (!g_TransVaddr->TranslateVaddr(VAddr, PAddr)) + { + if (LogUnknown()) + { + LogMessage("%08X: Writing 0x%08X to %08X", PC, Value, VAddr); + } + return; + } + VAddr = PAddr + 0xA0000000; + } + + if (VAddr >= 0xA0000000 && VAddr < (0xA0000000 + g_MMU->RdramSize())) + { + return; + } + if (VAddr >= 0xA3F00000 && VAddr <= 0xA3F00024) + { + if (!LogRDRamRegisters()) + { + return; + } + switch (VAddr) + { + case 0xA3F00000: LogMessage("%08X: Writing 0x%08X to RDRAM_CONFIG_REG/RDRAM_DEVICE_TYPE_REG", PC, Value); return; + case 0xA3F00004: LogMessage("%08X: Writing 0x%08X to RDRAM_DEVICE_ID_REG", PC, Value); return; + case 0xA3F00008: LogMessage("%08X: Writing 0x%08X to RDRAM_DELAY_REG", PC, Value); return; + case 0xA3F0000C: LogMessage("%08X: Writing 0x%08X to RDRAM_MODE_REG", PC, Value); return; + case 0xA3F00010: LogMessage("%08X: Writing 0x%08X to RDRAM_REF_INTERVAL_REG", PC, Value); return; + case 0xA3F00014: LogMessage("%08X: Writing 0x%08X to RDRAM_REF_ROW_REG", PC, Value); return; + case 0xA3F00018: LogMessage("%08X: Writing 0x%08X to RDRAM_RAS_INTERVAL_REG", PC, Value); return; + case 0xA3F0001C: LogMessage("%08X: Writing 0x%08X to RDRAM_MIN_INTERVAL_REG", PC, Value); return; + case 0xA3F00020: LogMessage("%08X: Writing 0x%08X to RDRAM_ADDR_SELECT_REG", PC, Value); return; + case 0xA3F00024: LogMessage("%08X: Writing 0x%08X to RDRAM_DEVICE_MANUF_REG", PC, Value); return; + } + } + if (VAddr >= 0xA4000000 && VAddr <= 0xA4001FFC) + { + return; + } + + if (VAddr >= 0xA4040000 && VAddr <= 0xA404001C) + { + if (!LogSPRegisters()) + { + return; + } + switch (VAddr) + { + case 0xA4040000: LogMessage("%08X: Writing 0x%08X to SP_MEM_ADDR_REG", PC, Value); return; + case 0xA4040004: LogMessage("%08X: Writing 0x%08X to SP_DRAM_ADDR_REG", PC, Value); return; + case 0xA4040008: LogMessage("%08X: Writing 0x%08X to SP_RD_LEN_REG", PC, Value); return; + case 0xA404000C: LogMessage("%08X: Writing 0x%08X to SP_WR_LEN_REG", PC, Value); return; + case 0xA4040010: LogMessage("%08X: Writing 0x%08X to SP_STATUS_REG", PC, Value); return; + case 0xA4040014: LogMessage("%08X: Writing 0x%08X to SP_DMA_FULL_REG", PC, Value); return; + case 0xA4040018: LogMessage("%08X: Writing 0x%08X to SP_DMA_BUSY_REG", PC, Value); return; + case 0xA404001C: LogMessage("%08X: Writing 0x%08X to SP_SEMAPHORE_REG", PC, Value); return; + } + } + if (VAddr == 0xA4080000) + { + if (!LogSPRegisters()) + { + return; + } + LogMessage("%08X: Writing 0x%08X to SP_PC", PC, Value); return; + } + + if (VAddr >= 0xA4100000 && VAddr <= 0xA410001C) + { + if (!LogDPCRegisters()) + { + return; + } + switch (VAddr) + { + case 0xA4100000: LogMessage("%08X: Writing 0x%08X to DPC_START_REG", PC, Value); return; + case 0xA4100004: LogMessage("%08X: Writing 0x%08X to DPC_END_REG", PC, Value); return; + case 0xA4100008: LogMessage("%08X: Writing 0x%08X to DPC_CURRENT_REG", PC, Value); return; + case 0xA410000C: LogMessage("%08X: Writing 0x%08X to DPC_STATUS_REG", PC, Value); return; + case 0xA4100010: LogMessage("%08X: Writing 0x%08X to DPC_CLOCK_REG", PC, Value); return; + case 0xA4100014: LogMessage("%08X: Writing 0x%08X to DPC_BUFBUSY_REG", PC, Value); return; + case 0xA4100018: LogMessage("%08X: Writing 0x%08X to DPC_PIPEBUSY_REG", PC, Value); return; + case 0xA410001C: LogMessage("%08X: Writing 0x%08X to DPC_TMEM_REG", PC, Value); return; + } + } + + if (VAddr >= 0xA4200000 && VAddr <= 0xA420000C) + { + if (!LogDPSRegisters()) + { + return; + } + switch (VAddr) + { + case 0xA4200000: LogMessage("%08X: Writing 0x%08X to DPS_TBIST_REG", PC, Value); return; + case 0xA4200004: LogMessage("%08X: Writing 0x%08X to DPS_TEST_MODE_REG", PC, Value); return; + case 0xA4200008: LogMessage("%08X: Writing 0x%08X to DPS_BUFTEST_ADDR_REG", PC, Value); return; + case 0xA420000C: LogMessage("%08X: Writing 0x%08X to DPS_BUFTEST_DATA_REG", PC, Value); return; + } + } + + if (VAddr >= 0xA4300000 && VAddr <= 0xA430000C) + { + if (!LogMIPSInterface()) + { + return; + } + switch (VAddr) + { + case 0xA4300000: LogMessage("%08X: Writing 0x%08X to MI_INIT_MODE_REG/MI_MODE_REG", PC, Value); return; + case 0xA4300004: LogMessage("%08X: Writing 0x%08X to MI_VERSION_REG/MI_NOOP_REG", PC, Value); return; + case 0xA4300008: LogMessage("%08X: Writing 0x%08X to MI_INTR_REG", PC, Value); return; + case 0xA430000C: LogMessage("%08X: Writing 0x%08X to MI_INTR_MASK_REG", PC, Value); return; + } + } + if (VAddr >= 0xA4400000 && VAddr <= 0xA4400034) + { + if (!LogVideoInterface()) + { + return; + } + switch (VAddr) + { + case 0xA4400000: LogMessage("%08X: Writing 0x%08X to VI_STATUS_REG/VI_CONTROL_REG", PC, Value); return; + case 0xA4400004: LogMessage("%08X: Writing 0x%08X to VI_ORIGIN_REG/VI_DRAM_ADDR_REG", PC, Value); return; + case 0xA4400008: LogMessage("%08X: Writing 0x%08X to VI_WIDTH_REG/VI_H_WIDTH_REG", PC, Value); return; + case 0xA440000C: LogMessage("%08X: Writing 0x%08X to VI_INTR_REG/VI_V_INTR_REG", PC, Value); return; + case 0xA4400010: LogMessage("%08X: Writing 0x%08X to VI_CURRENT_REG/VI_V_CURRENT_LINE_REG", PC, Value); return; + case 0xA4400014: LogMessage("%08X: Writing 0x%08X to VI_BURST_REG/VI_TIMING_REG", PC, Value); return; + case 0xA4400018: LogMessage("%08X: Writing 0x%08X to VI_V_SYNC_REG", PC, Value); return; + case 0xA440001C: LogMessage("%08X: Writing 0x%08X to VI_H_SYNC_REG", PC, Value); return; + case 0xA4400020: LogMessage("%08X: Writing 0x%08X to VI_LEAP_REG/VI_H_SYNC_LEAP_REG", PC, Value); return; + case 0xA4400024: LogMessage("%08X: Writing 0x%08X to VI_H_START_REG/VI_H_VIDEO_REG", PC, Value); return; + case 0xA4400028: LogMessage("%08X: Writing 0x%08X to VI_V_START_REG/VI_V_VIDEO_REG", PC, Value); return; + case 0xA440002C: LogMessage("%08X: Writing 0x%08X to VI_V_BURST_REG", PC, Value); return; + case 0xA4400030: LogMessage("%08X: Writing 0x%08X to VI_X_SCALE_REG", PC, Value); return; + case 0xA4400034: LogMessage("%08X: Writing 0x%08X to VI_Y_SCALE_REG", PC, Value); return; + } + } + + if (VAddr >= 0xA4500000 && VAddr <= 0xA4500014) + { + if (!LogAudioInterface()) + { + return; + } + switch (VAddr) + { + case 0xA4500000: LogMessage("%08X: Writing 0x%08X to AI_DRAM_ADDR_REG", PC, Value); return; + case 0xA4500004: LogMessage("%08X: Writing 0x%08X to AI_LEN_REG", PC, Value); return; + case 0xA4500008: LogMessage("%08X: Writing 0x%08X to AI_CONTROL_REG", PC, Value); return; + case 0xA450000C: LogMessage("%08X: Writing 0x%08X to AI_STATUS_REG", PC, Value); return; + case 0xA4500010: LogMessage("%08X: Writing 0x%08X to AI_DACRATE_REG", PC, Value); return; + case 0xA4500014: LogMessage("%08X: Writing 0x%08X to AI_BITRATE_REG", PC, Value); return; + } + } + + if (VAddr >= 0xA4600000 && VAddr <= 0xA4600030) + { + if (!LogPerInterface()) + { + return; + } + switch (VAddr) + { + case 0xA4600000: LogMessage("%08X: Writing 0x%08X to PI_DRAM_ADDR_REG", PC, Value); return; + case 0xA4600004: LogMessage("%08X: Writing 0x%08X to PI_CART_ADDR_REG", PC, Value); return; + case 0xA4600008: LogMessage("%08X: Writing 0x%08X to PI_RD_LEN_REG", PC, Value); return; + case 0xA460000C: LogMessage("%08X: Writing 0x%08X to PI_WR_LEN_REG", PC, Value); return; + case 0xA4600010: LogMessage("%08X: Writing 0x%08X to PI_STATUS_REG", PC, Value); return; + case 0xA4600014: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_LAT_REG/PI_DOMAIN1_REG", PC, Value); return; + case 0xA4600018: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_PWD_REG", PC, Value); return; + case 0xA460001C: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_PGS_REG", PC, Value); return; + case 0xA4600020: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM1_RLS_REG", PC, Value); return; + case 0xA4600024: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_LAT_REG/PI_DOMAIN2_REG", PC, Value); return; + case 0xA4600028: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_PWD_REG", PC, Value); return; + case 0xA460002C: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_PGS_REG", PC, Value); return; + case 0xA4600030: LogMessage("%08X: Writing 0x%08X to PI_BSD_DOM2_RLS_REG", PC, Value); return; + } + } + if (VAddr >= 0xA4700000 && VAddr <= 0xA470001C) + { + if (!LogRDRAMInterface()) + { + return; + } + switch (VAddr) + { + case 0xA4700000: LogMessage("%08X: Writing 0x%08X to RI_MODE_REG", PC, Value); return; + case 0xA4700004: LogMessage("%08X: Writing 0x%08X to RI_CONFIG_REG", PC, Value); return; + case 0xA4700008: LogMessage("%08X: Writing 0x%08X to RI_CURRENT_LOAD_REG", PC, Value); return; + case 0xA470000C: LogMessage("%08X: Writing 0x%08X to RI_SELECT_REG", PC, Value); return; + case 0xA4700010: LogMessage("%08X: Writing 0x%08X to RI_REFRESH_REG/RI_COUNT_REG", PC, Value); return; + case 0xA4700014: LogMessage("%08X: Writing 0x%08X to RI_LATENCY_REG", PC, Value); return; + case 0xA4700018: LogMessage("%08X: Writing 0x%08X to RI_RERROR_REG", PC, Value); return; + case 0xA470001C: LogMessage("%08X: Writing 0x%08X to RI_WERROR_REG", PC, Value); return; + } + } + if (VAddr == 0xA4800000) + { + if (!LogSerialInterface()) + { + return; + } + LogMessage("%08X: Writing 0x%08X to SI_DRAM_ADDR_REG", PC, Value); return; + } + if (VAddr == 0xA4800004) + { + if (LogPRDMAOperations()) + { + LogMessage("%08X: A DMA transfer from the PIF ram has occured", PC); + } + if (!LogSerialInterface()) + { + return; + } + LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_RD64B_REG", PC, Value); return; + } + if (VAddr == 0xA4800010) + { + if (LogPRDMAOperations()) + { + LogMessage("%08X: A DMA transfer to the PIF ram has occured", PC); + } + if (!LogSerialInterface()) + { + return; + } + LogMessage("%08X: Writing 0x%08X to SI_PIF_ADDR_WR64B_REG", PC, Value); return; + } + if (VAddr == 0xA4800018) + { + if (!LogSerialInterface()) + { + return; + } + LogMessage("%08X: Writing 0x%08X to SI_STATUS_REG", PC, Value); return; + } + + if (VAddr >= 0xBFC007C0 && VAddr <= 0xBFC007FC) + { + if (!LogPRDirectMemStores()) + { + return; + } + LogMessage("%08X: Writing 0x%08X to Pif Ram at 0x%X", PC, Value, VAddr - 0xBFC007C0); + return; + } + if (!LogUnknown()) + { + return; + } + LogMessage("%08X: Writing 0x%08X to %08X ????", PC, Value, VAddr); +} + +void CLogging::LogMessage(const char * Message, ...) +{ + char Msg[400]; + va_list ap; + + if (!g_Settings->LoadBool(Debugger_Enabled)) + { + return; + } + if (m_hLogFile == NULL) + { + return; + } + + va_start(ap, Message); + vsprintf(Msg, Message, ap); + va_end(ap); + + strcat(Msg, "\r\n"); + + m_hLogFile->Write(Msg,strlen(Msg)); +} + +void CLogging::StartLog(void) +{ + if (!GenerateLog()) + { + StopLog(); + return; + } + if (m_hLogFile != NULL) + { + return; + } + + CPath LogFile(CPath::MODULE_DIRECTORY); + LogFile.AppendDirectory("Logs"); + LogFile.SetNameExtension("cpudebug.log"); + + m_hLogFile = new CFile(LogFile, CFileBase::modeCreate | CFileBase::modeWrite); +} + +void CLogging::StopLog(void) +{ + if (m_hLogFile) + { + delete m_hLogFile; + m_hLogFile = NULL; + } +} \ No newline at end of file From 003bcc9096ff01c1f54fabbdeb1a4764ce0bc718 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sat, 14 Nov 2015 08:15:20 +1100 Subject: [PATCH 158/213] [Project64] Clean up Menu Class.cpp --- .../Project64/User Interface/Menu Class.cpp | 112 +++++++++--------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/Source/Project64/User Interface/Menu Class.cpp b/Source/Project64/User Interface/Menu Class.cpp index 42b4fe3eb..6a97624cd 100644 --- a/Source/Project64/User Interface/Menu Class.cpp +++ b/Source/Project64/User Interface/Menu Class.cpp @@ -1,72 +1,72 @@ #include "stdafx.h" -CBaseMenu::CBaseMenu () : - m_MenuHandle((HMENU)CreateMenu()) +CBaseMenu::CBaseMenu() : +m_MenuHandle((HMENU)CreateMenu()) { } -bool CBaseMenu::AddMenu(HMENU hMenu, MenuItemList Items ) { - if (Items.begin() == Items.end()) { return false; } +bool CBaseMenu::AddMenu(HMENU hMenu, MenuItemList Items) +{ + if (Items.begin() == Items.end()) { return false; } - UINT ItemID, uFlags; - std::wstring Text, String; - for (MenuItemList::iterator MenuItem = Items.begin(); MenuItem != Items.end(); MenuItem++) + UINT ItemID, uFlags; + std::wstring Text, String; + for (MenuItemList::iterator MenuItem = Items.begin(); MenuItem != Items.end(); MenuItem++) { - ItemID = MenuItem->ID(); - uFlags = MF_STRING; - Text = g_Lang->GetString(MenuItem->Title()).c_str(); + ItemID = MenuItem->ID(); + uFlags = MF_STRING; + Text = g_Lang->GetString(MenuItem->Title()).c_str(); - if (MenuItem->Title() == EMPTY_STRING && MenuItem->ManualString().length() > 0) + if (MenuItem->Title() == EMPTY_STRING && MenuItem->ManualString().length() > 0) { - Text = MenuItem->ManualString(); - } - if (ItemID == SPLITER) + Text = MenuItem->ManualString(); + } + if (ItemID == SPLITER) { - uFlags |= MF_SEPARATOR; - } - if (MenuItem->ItemTicked()) + uFlags |= MF_SEPARATOR; + } + if (MenuItem->ItemTicked()) { - uFlags |= MFS_CHECKED; - } - if (MenuItem->ItemEnabled()) + uFlags |= MFS_CHECKED; + } + if (MenuItem->ItemEnabled()) { - uFlags |= MFS_ENABLED; - } - else + uFlags |= MFS_ENABLED; + } + else { - uFlags |= MFS_DISABLED; - } - - MenuItemList * SubMenu = (MenuItemList *)MenuItem->SubMenu(); - if (ItemID == SUB_MENU && HIWORD(SubMenu) != 0 && (SubMenu->begin() != SubMenu->end())) - { - ItemID = (UINT)CreatePopupMenu(); - uFlags |= MF_POPUP; + uFlags |= MFS_DISABLED; + } - AddMenu((HMENU)ItemID,*SubMenu); - } - - if (ItemID == ID_PLUGIN_MENU) - { - ItemID = (UINT)MenuItem->SubMenu(); - uFlags |= MF_POPUP; - MENUITEMINFO lpmii; - - lpmii.cbSize = sizeof(MENUITEMINFO); - lpmii.fMask = MIIM_STATE; - lpmii.fState = 0; - SetMenuItemInfo((HMENU)ItemID, (DWORD)MenuItem->SubMenu(), FALSE,&lpmii); - } - - if (MenuItem->ShortCut().empty() == false) + MenuItemList * SubMenu = (MenuItemList *)MenuItem->SubMenu(); + if (ItemID == SUB_MENU && HIWORD(SubMenu) != 0 && (SubMenu->begin() != SubMenu->end())) { - String = Text; - String += L"\t"; - String += MenuItem->ShortCut(); - Text = String; - } - AppendMenuW(hMenu,uFlags,ItemID,Text.c_str()); - } - return true; -} + ItemID = (UINT)CreatePopupMenu(); + uFlags |= MF_POPUP; + AddMenu((HMENU)ItemID, *SubMenu); + } + + if (ItemID == ID_PLUGIN_MENU) + { + ItemID = (UINT)MenuItem->SubMenu(); + uFlags |= MF_POPUP; + MENUITEMINFO lpmii; + + lpmii.cbSize = sizeof(MENUITEMINFO); + lpmii.fMask = MIIM_STATE; + lpmii.fState = 0; + SetMenuItemInfo((HMENU)ItemID, (DWORD)MenuItem->SubMenu(), FALSE, &lpmii); + } + + if (MenuItem->ShortCut().empty() == false) + { + String = Text; + String += L"\t"; + String += MenuItem->ShortCut(); + Text = String; + } + AppendMenuW(hMenu, uFlags, ItemID, Text.c_str()); + } + return true; +} \ No newline at end of file From eab2acdecf168b971fbd51407236a88bacd53743 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sat, 14 Nov 2015 08:18:36 +1100 Subject: [PATCH 159/213] [Project64] Cleanup main.cpp --- Source/Project64/main.cpp | 181 +++++++++++++++++++------------------- 1 file changed, 91 insertions(+), 90 deletions(-) diff --git a/Source/Project64/main.cpp b/Source/Project64/main.cpp index 9f38a1d09..0c84246e3 100644 --- a/Source/Project64/main.cpp +++ b/Source/Project64/main.cpp @@ -4,27 +4,27 @@ CTraceFileLog * LogFile = NULL; -void LogLevelChanged (CTraceFileLog * LogFile) +void LogLevelChanged(CTraceFileLog * LogFile) { LogFile->SetTraceLevel((TraceLevel)g_Settings->LoadDword(Debugger_AppLogLevel)); } -void LogFlushChanged (CTraceFileLog * LogFile) +void LogFlushChanged(CTraceFileLog * LogFile) { LogFile->SetFlushFile(g_Settings->LoadDword(Debugger_AppLogFlush) != 0); } -void InitializeLog ( void) +void InitializeLog(void) { CPath LogFilePath(CPath::MODULE_DIRECTORY); LogFilePath.AppendDirectory("Logs"); if (!LogFilePath.DirectoryExists()) { - LogFilePath.DirectoryCreate(); + LogFilePath.DirectoryCreate(); } LogFilePath.SetNameExtension("Project64.log"); - LogFile = new CTraceFileLog(LogFilePath, g_Settings->LoadDword(Debugger_AppLogFlush) != 0, Log_New,500); + LogFile = new CTraceFileLog(LogFilePath, g_Settings->LoadDword(Debugger_AppLogFlush) != 0, Log_New, 500); #ifdef VALIDATE_DEBUG LogFile->SetTraceLevel((TraceLevel)(g_Settings->LoadDword(Debugger_AppLogLevel) | TraceValidate | TraceDebug)); #else @@ -32,8 +32,8 @@ void InitializeLog ( void) #endif AddTraceModule(LogFile); - g_Settings->RegisterChangeCB(Debugger_AppLogLevel,LogFile,(CSettings::SettingChangedFunc)LogLevelChanged); - g_Settings->RegisterChangeCB(Debugger_AppLogFlush,LogFile,(CSettings::SettingChangedFunc)LogFlushChanged); + g_Settings->RegisterChangeCB(Debugger_AppLogLevel, LogFile, (CSettings::SettingChangedFunc)LogLevelChanged); + g_Settings->RegisterChangeCB(Debugger_AppLogFlush, LogFile, (CSettings::SettingChangedFunc)LogFlushChanged); } /*bool ChangeDirPermission ( const CPath & Dir) @@ -92,27 +92,27 @@ CloseHandle(hDir); return true; }*/ -void FixDirectories ( void ) +void FixDirectories(void) { - CPath Directory(CPath::MODULE_DIRECTORY); - Directory.AppendDirectory("Config"); - if (!Directory.DirectoryExists()) Directory.DirectoryCreate(); + CPath Directory(CPath::MODULE_DIRECTORY); + Directory.AppendDirectory("Config"); + if (!Directory.DirectoryExists()) Directory.DirectoryCreate(); - Directory.UpDirectory(); - Directory.AppendDirectory("Logs"); - if (!Directory.DirectoryExists()) Directory.DirectoryCreate(); + Directory.UpDirectory(); + Directory.AppendDirectory("Logs"); + if (!Directory.DirectoryExists()) Directory.DirectoryCreate(); - Directory.UpDirectory(); - Directory.AppendDirectory("Save"); - if (!Directory.DirectoryExists()) Directory.DirectoryCreate(); + Directory.UpDirectory(); + Directory.AppendDirectory("Save"); + if (!Directory.DirectoryExists()) Directory.DirectoryCreate(); - Directory.UpDirectory(); - Directory.AppendDirectory("Screenshots"); - if (!Directory.DirectoryExists()) Directory.DirectoryCreate(); + Directory.UpDirectory(); + Directory.AppendDirectory("Screenshots"); + if (!Directory.DirectoryExists()) Directory.DirectoryCreate(); - Directory.UpDirectory(); - Directory.AppendDirectory("textures"); - if (!Directory.DirectoryExists()) Directory.DirectoryCreate(); + Directory.UpDirectory(); + Directory.AppendDirectory("textures"); + if (!Directory.DirectoryExists()) Directory.DirectoryCreate(); } bool TerminatedExistingEmu() @@ -122,7 +122,7 @@ bool TerminatedExistingEmu() DWORD pid = GetCurrentProcessId(); HANDLE nSearch = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - if(nSearch != INVALID_HANDLE_VALUE) + if (nSearch != INVALID_HANDLE_VALUE) { PROCESSENTRY32 lppe; @@ -134,7 +134,7 @@ bool TerminatedExistingEmu() { do { - if(_stricmp(lppe.szExeFile, ModuleName.c_str()) != 0 || + if (_stricmp(lppe.szExeFile, ModuleName.c_str()) != 0 || lppe.th32ProcessID == pid) { continue; @@ -142,20 +142,21 @@ bool TerminatedExistingEmu() if (!AskedUser) { AskedUser = true; - int res = MessageBox(NULL,stdstr_f("Project64.exe currently running\n\nTerminate pid %d now?",lppe.th32ProcessID).c_str(),"Terminate project64",MB_YESNO|MB_ICONEXCLAMATION); + int res = MessageBox(NULL, stdstr_f("Project64.exe currently running\n\nTerminate pid %d now?", lppe.th32ProcessID).c_str(), "Terminate project64", MB_YESNO | MB_ICONEXCLAMATION); if (res != IDYES) { break; } } HANDLE hHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, lppe.th32ProcessID); - if(hHandle != NULL) + if (hHandle != NULL) { if (TerminateProcess(hHandle, 0)) { bTerminated = true; - } else { - MessageBox(NULL,stdstr_f("Failed to terminate pid %d",lppe.th32ProcessID).c_str(),"Terminate project64 failed!",MB_YESNO|MB_ICONEXCLAMATION); + } + else { + MessageBox(NULL, stdstr_f("Failed to terminate pid %d", lppe.th32ProcessID).c_str(), "Terminate project64 failed!", MB_YESNO | MB_ICONEXCLAMATION); } CloseHandle(hHandle); } @@ -166,7 +167,7 @@ bool TerminatedExistingEmu() return bTerminated; } -const char * AppName ( void ) +const char * AppName(void) { static stdstr Name; if (Name.empty()) @@ -188,67 +189,66 @@ int main(int argc, char* argv[]) fprintf( stderr, "Cross-platform (graphical/terminal?) UI not yet implemented.\n" - ); + ); return 0; } #else int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR /*lpszArgs*/, int /*nWinMode*/) { - FixDirectories(); + FixDirectories(); - char *lbuffer = new char[10]; - if (GetLocaleInfoA(LOCALE_SYSTEM_DEFAULT, LOCALE_SABBREVLANGNAME, lbuffer, 10)) - setlocale(LC_ALL, lbuffer); - delete[] lbuffer; + char *lbuffer = new char[10]; + if (GetLocaleInfoA(LOCALE_SYSTEM_DEFAULT, LOCALE_SABBREVLANGNAME, lbuffer, 10)) + setlocale(LC_ALL, lbuffer); + delete[] lbuffer; - CoInitialize(NULL); + CoInitialize(NULL); try { - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL ); - g_Settings = new CSettings; - g_Settings->Initialize(AppName()); + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL); + g_Settings = new CSettings; + g_Settings->Initialize(AppName()); - if (g_Settings->LoadBool(Setting_CheckEmuRunning) && - TerminatedExistingEmu()) - { - delete g_Settings; - g_Settings = new CSettings; - g_Settings->Initialize(AppName()); - } + if (g_Settings->LoadBool(Setting_CheckEmuRunning) && + TerminatedExistingEmu()) + { + delete g_Settings; + g_Settings = new CSettings; + g_Settings->Initialize(AppName()); + } - InitializeLog(); - - WriteTrace(TraceDebug,__FUNCTION__ ": Application Starting"); - CMipsMemoryVM::ReserveMemory(); + InitializeLog(); - g_Notify = &Notify(); + WriteTrace(TraceDebug, __FUNCTION__ ": Application Starting"); + CMipsMemoryVM::ReserveMemory(); - //Create the plugin container - WriteTrace(TraceDebug,__FUNCTION__ ": Create Plugins"); - g_Plugins = new CPlugins(g_Settings->LoadStringVal(Directory_Plugin)); + g_Notify = &Notify(); - //Select the language - g_Lang = new CLanguage(); - if (!g_Lang->LoadCurrentStrings()) - { - CLanguageSelector().Select(); - } + //Create the plugin container + WriteTrace(TraceDebug, __FUNCTION__ ": Create Plugins"); + g_Plugins = new CPlugins(g_Settings->LoadStringVal(Directory_Plugin)); + //Select the language + g_Lang = new CLanguage(); + if (!g_Lang->LoadCurrentStrings()) + { + CLanguageSelector().Select(); + } //Create the main window with Menu - WriteTrace(TraceDebug,__FUNCTION__ ": Create Main Window"); - stdstr WinTitle(AppName()); + WriteTrace(TraceDebug, __FUNCTION__ ": Create Main Window"); + stdstr WinTitle(AppName()); - WinTitle.Format("Project64 %s", VER_FILE_VERSION_STR); + WinTitle.Format("Project64 %s", VER_FILE_VERSION_STR); - CMainGui MainWindow(true,WinTitle.c_str()), HiddenWindow(false); + CMainGui MainWindow(true, WinTitle.c_str()), HiddenWindow(false); CMainMenu MainMenu(&MainWindow); - g_Plugins->SetRenderWindows(&MainWindow,&HiddenWindow); - Notify().SetMainWindow(&MainWindow); + g_Plugins->SetRenderWindows(&MainWindow, &HiddenWindow); + Notify().SetMainWindow(&MainWindow); if (__argc > 1) { - WriteTraceF(TraceDebug,__FUNCTION__ ": Cmd line found \"%s\"",__argv[1]); + WriteTraceF(TraceDebug, __FUNCTION__ ": Cmd line found \"%s\"", __argv[1]); MainWindow.Show(true); //Show the main window CN64System::RunFileImage(__argv[1]); } @@ -256,21 +256,22 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR / { if (g_Settings->LoadDword(RomBrowser_Enabled)) { - WriteTrace(TraceDebug,__FUNCTION__ ": Show Rom Browser"); + WriteTrace(TraceDebug, __FUNCTION__ ": Show Rom Browser"); //Display the rom browser MainWindow.ShowRomList(); MainWindow.Show(true); //Show the main window MainWindow.HighLightLastRom(); - } else { - WriteTrace(TraceDebug,__FUNCTION__ ": Show Main Window"); + } + else { + WriteTrace(TraceDebug, __FUNCTION__ ": Show Main Window"); MainWindow.Show(true); //Show the main window } } //Process Messages till program is closed - WriteTrace(TraceDebug,__FUNCTION__ ": Entering Message Loop"); + WriteTrace(TraceDebug, __FUNCTION__ ": Entering Message Loop"); MainWindow.ProcessAllMessages(); - WriteTrace(TraceDebug,__FUNCTION__ ": Message Loop Finished"); + WriteTrace(TraceDebug, __FUNCTION__ ": Message Loop Finished"); if (g_BaseSystem) { @@ -278,28 +279,28 @@ int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR / delete g_BaseSystem; g_BaseSystem = NULL; } - WriteTrace(TraceDebug,__FUNCTION__ ": System Closed"); + WriteTrace(TraceDebug, __FUNCTION__ ": System Closed"); - g_Settings->UnregisterChangeCB(Debugger_AppLogLevel,LogFile,(CSettings::SettingChangedFunc)LogLevelChanged); - g_Settings->UnregisterChangeCB(Debugger_AppLogFlush,LogFile,(CSettings::SettingChangedFunc)LogFlushChanged); + g_Settings->UnregisterChangeCB(Debugger_AppLogLevel, LogFile, (CSettings::SettingChangedFunc)LogLevelChanged); + g_Settings->UnregisterChangeCB(Debugger_AppLogFlush, LogFile, (CSettings::SettingChangedFunc)LogFlushChanged); } - catch(...) + catch (...) { - WriteTraceF(TraceError,__FUNCTION__ ": Exception caught (File: \"%s\" Line: %d)",__FILE__,__LINE__); - MessageBox(NULL,stdstr_f("Exception caught\nFile: %s\nLine: %d",__FILE__,__LINE__).c_str(),"Exception",MB_OK); + WriteTraceF(TraceError, __FUNCTION__ ": Exception caught (File: \"%s\" Line: %d)", __FILE__, __LINE__); + MessageBox(NULL, stdstr_f("Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__).c_str(), "Exception", MB_OK); } - WriteTrace(TraceDebug,__FUNCTION__ ": cleaning up global objects"); - - if (g_Rom) { delete g_Rom; g_Rom = NULL; } - if (g_Plugins) { delete g_Plugins; g_Plugins = NULL; } - if (g_Settings) { delete g_Settings; g_Settings = NULL; } - if (g_Lang) { delete g_Lang; g_Lang = NULL; } + WriteTrace(TraceDebug, __FUNCTION__ ": cleaning up global objects"); - CMipsMemoryVM::FreeReservedMemory(); + if (g_Rom) { delete g_Rom; g_Rom = NULL; } + if (g_Plugins) { delete g_Plugins; g_Plugins = NULL; } + if (g_Settings) { delete g_Settings; g_Settings = NULL; } + if (g_Lang) { delete g_Lang; g_Lang = NULL; } - CoUninitialize(); - WriteTrace(TraceDebug,__FUNCTION__ ": Done"); - CloseTrace(); + CMipsMemoryVM::FreeReservedMemory(); + + CoUninitialize(); + WriteTrace(TraceDebug, __FUNCTION__ ": Done"); + CloseTrace(); return true; } -#endif +#endif \ No newline at end of file From 23e6503a9ff9c7b13e7d68e26dfa14a4fb6fb05b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 Nov 2015 17:51:07 -0500 Subject: [PATCH 160/213] [ROM browser] Loop through a string LUT of extensions. --- .../User Interface/Rom Browser Class.cpp | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/Source/Project64/User Interface/Rom Browser Class.cpp b/Source/Project64/User Interface/Rom Browser Class.cpp index 11683afb9..40abf3be7 100644 --- a/Source/Project64/User Interface/Rom Browser Class.cpp +++ b/Source/Project64/User Interface/Rom Browser Class.cpp @@ -545,8 +545,13 @@ void CRomBrowser::NotificationCB(LPCWSTR Status, CRomBrowser * /*_this*/) g_Notify->DisplayMessage(5, Status); } +static const char* ROM_extensions[] = { + "zip", "7z", "v64", "z64", "n64", "rom", "jap", "pal", "usa", "eur", "bin", +}; void CRomBrowser::AddFileNameToList(strlist & FileList, const stdstr & Directory, CPath & File) { + uint8_t i; + if (FileList.size() > 3000) { return; @@ -555,14 +560,15 @@ void CRomBrowser::AddFileNameToList(strlist & FileList, const stdstr & Directory stdstr Drive, Dir, Name, Extension; File.GetComponents(NULL, &Dir, &Name, &Extension); Extension.ToLower(); - if (Extension == "zip" || Extension == "7z" || Extension == "v64" || Extension == "z64" || - Extension == "n64" || Extension == "rom" || Extension == "jap" || Extension == "pal" || - Extension == "usa" || Extension == "eur" || Extension == "bin") - { - stdstr FileName = Directory + Name + Extension; - FileName.ToLower(); - FileList.push_back(FileName); - } + for (i = 0; i < sizeof(ROM_extensions) / sizeof(ROM_extensions[0]); i++) + { + if (Extension == ROM_extensions[i]) + { + stdstr FileName = Directory + Name + Extension; + FileName.ToLower(); + FileList.push_back(FileName); + } + } } void CRomBrowser::FillRomList(strlist & FileList, const CPath & BaseDirectory, const stdstr & Directory, const char * lpLastRom) @@ -579,6 +585,10 @@ void CRomBrowser::FillRomList(strlist & FileList, const CPath & BaseDirectory, c do { + uint8_t ext_ID; + const uint8_t exts = sizeof(ROM_extensions) / sizeof(ROM_extensions[0]); +rom_entry_begin: + //TODO: Fix exception on Windows XP (Visual Studio 2010+) //WriteTraceF(TraceDebug,__FUNCTION__ ": 2 %s m_StopRefresh = %d",(LPCSTR)SearchPath,m_StopRefresh); if (m_StopRefresh) { break; } @@ -598,13 +608,14 @@ void CRomBrowser::FillRomList(strlist & FileList, const CPath & BaseDirectory, c stdstr Extension = SearchPath.GetExtension(); Extension.ToLower(); - if (Extension == "zip" || Extension == "v64" || Extension == "z64" || Extension == "n64" || - Extension == "rom" || Extension == "jap" || Extension == "pal" || Extension == "usa" || - Extension == "eur" || Extension == "bin") - { - AddRomToList(SearchPath, lpLastRom); - continue; - } + for (ext_ID = 0; ext_ID < exts; ext_ID++) + { + if (Extension == ROM_extensions[ext_ID] && Extension != "7z") + { + AddRomToList(SearchPath, lpLastRom); + goto rom_entry_begin; + } + } if (Extension == "7z") { try From a476d4c36e1b06146277aa27e5f064a7796ad360 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 Nov 2015 17:55:00 -0500 Subject: [PATCH 161/213] [ROM browser] removed redundant stricmp() inverse checks --- Source/Project64/User Interface/Rom Browser Class.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Source/Project64/User Interface/Rom Browser Class.cpp b/Source/Project64/User Interface/Rom Browser Class.cpp index 40abf3be7..42660e946 100644 --- a/Source/Project64/User Interface/Rom Browser Class.cpp +++ b/Source/Project64/User Interface/Rom Browser Class.cpp @@ -652,11 +652,7 @@ rom_entry_begin: _splitpath(FileName.c_str(), drive2, dir2, FileName2, ext2); WriteTraceF(TraceDebug, __FUNCTION__ ": 6 %s", ext2); - if (_stricmp(ext2, ".v64") != 0 && _stricmp(ext2, ".z64") != 0 && - _stricmp(ext2, ".n64") != 0 && _stricmp(ext2, ".rom") != 0 && - _stricmp(ext2, ".jap") != 0 && _stricmp(ext2, ".pal") != 0 && - _stricmp(ext2, ".usa") != 0 && _stricmp(ext2, ".eur") != 0 && - _stricmp(ext2, ".bin") == 0) + if (_stricmp(ext2, ".bin") == 0) { continue; } From b6c6e192eeb157e15fc28309009104e2ee8d9694 Mon Sep 17 00:00:00 2001 From: zilmar Date: Sat, 14 Nov 2015 11:16:03 +1100 Subject: [PATCH 162/213] [Project64] Cleanup Language Class --- .../Multilanguage/Language Class.cpp | 772 +++++++++--------- .../Project64/Multilanguage/Language Class.h | 24 +- .../Multilanguage/LanguageSelector.h | 6 +- 3 files changed, 401 insertions(+), 401 deletions(-) diff --git a/Source/Project64/Multilanguage/Language Class.cpp b/Source/Project64/Multilanguage/Language Class.cpp index e2f3d5855..ea5a79511 100644 --- a/Source/Project64/Multilanguage/Language Class.cpp +++ b/Source/Project64/Multilanguage/Language Class.cpp @@ -14,499 +14,499 @@ CLanguage * g_Lang = NULL; -void CLanguage::LoadDefaultStrings (void) +void CLanguage::LoadDefaultStrings(void) { #define DEF_STR(ID,str) m_DefaultStrings.insert(LANG_STRINGS::value_type(ID,str)) - DEF_STR(EMPTY_STRING, L"" ); + DEF_STR(EMPTY_STRING, L""); /********************************************************************************* * Meta Information * *********************************************************************************/ //About DLL - DEF_STR(LANGUAGE_NAME, L"" ); - DEF_STR(LANGUAGE_AUTHOR, L"" ); - DEF_STR(LANGUAGE_VERSION, L"" ); - DEF_STR(LANGUAGE_DATE, L"" ); + DEF_STR(LANGUAGE_NAME, L""); + DEF_STR(LANGUAGE_AUTHOR, L""); + DEF_STR(LANGUAGE_VERSION, L""); + DEF_STR(LANGUAGE_DATE, L""); //About DLL Dialog - DEF_STR(INI_CURRENT_LANG, L"Current Language" ); - DEF_STR(INI_AUTHOR, L"Author" ); - DEF_STR(INI_VERSION, L"Version" ); - DEF_STR(INI_DATE, L"Date" ); - DEF_STR(INI_HOMEPAGE, L"Visit Home Page" ); - DEF_STR(INI_CURRENT_RDB, L"ROM Database (.RDB)" ); - DEF_STR(INI_CURRENT_CHT, L"Cheat Code File (.CHT)" ); - DEF_STR(INI_CURRENT_RDX, L"Extended ROM Info (.RDX)"); + DEF_STR(INI_CURRENT_LANG, L"Current Language"); + DEF_STR(INI_AUTHOR, L"Author"); + DEF_STR(INI_VERSION, L"Version"); + DEF_STR(INI_DATE, L"Date"); + DEF_STR(INI_HOMEPAGE, L"Visit Home Page"); + DEF_STR(INI_CURRENT_RDB, L"ROM Database (.RDB)"); + DEF_STR(INI_CURRENT_CHT, L"Cheat Code File (.CHT)"); + DEF_STR(INI_CURRENT_RDX, L"Extended ROM Info (.RDX)"); //About INI title - DEF_STR(INI_TITLE, L"About Config Files" ); + DEF_STR(INI_TITLE, L"About Config Files"); /********************************************************************************* * Numbers * *********************************************************************************/ - DEF_STR(NUMBER_0, L"0" ); - DEF_STR(NUMBER_1, L"1" ); - DEF_STR(NUMBER_2, L"2" ); - DEF_STR(NUMBER_3, L"3" ); - DEF_STR(NUMBER_4, L"4" ), - DEF_STR(NUMBER_5, L"5" ); - DEF_STR(NUMBER_6, L"6" ); - DEF_STR(NUMBER_7, L"7" ); - DEF_STR(NUMBER_8, L"8" ); - DEF_STR(NUMBER_9, L"9" ); + DEF_STR(NUMBER_0, L"0"); + DEF_STR(NUMBER_1, L"1"); + DEF_STR(NUMBER_2, L"2"); + DEF_STR(NUMBER_3, L"3"); + DEF_STR(NUMBER_4, L"4"), + DEF_STR(NUMBER_5, L"5"); + DEF_STR(NUMBER_6, L"6"); + DEF_STR(NUMBER_7, L"7"); + DEF_STR(NUMBER_8, L"8"); + DEF_STR(NUMBER_9, L"9"); /********************************************************************************* * Menu * *********************************************************************************/ //File Menu - DEF_STR(MENU_FILE, L"&File" ); - DEF_STR(MENU_OPEN, L"&Open ROM" ); - DEF_STR(MENU_ROM_INFO, L"ROM &Info...." ); - DEF_STR(MENU_START, L"Start Emulation" ); - DEF_STR(MENU_END, L"&End Emulation" ); - DEF_STR(MENU_CHOOSE_ROM, L"Choose ROM Directory..." ); - DEF_STR(MENU_REFRESH, L"Refresh ROM List" ); - DEF_STR(MENU_RECENT_ROM, L"Recent ROM" ); - DEF_STR(MENU_RECENT_DIR, L"Recent ROM Directories" ); - DEF_STR(MENU_EXIT, L"E&xit" ); + DEF_STR(MENU_FILE, L"&File"); + DEF_STR(MENU_OPEN, L"&Open ROM"); + DEF_STR(MENU_ROM_INFO, L"ROM &Info...."); + DEF_STR(MENU_START, L"Start Emulation"); + DEF_STR(MENU_END, L"&End Emulation"); + DEF_STR(MENU_CHOOSE_ROM, L"Choose ROM Directory..."); + DEF_STR(MENU_REFRESH, L"Refresh ROM List"); + DEF_STR(MENU_RECENT_ROM, L"Recent ROM"); + DEF_STR(MENU_RECENT_DIR, L"Recent ROM Directories"); + DEF_STR(MENU_EXIT, L"E&xit"); //System Menu - DEF_STR(MENU_SYSTEM, L"&System" ); - DEF_STR(MENU_RESET, L"&Reset" ); - DEF_STR(MENU_PAUSE, L"&Pause" ); - DEF_STR(MENU_BITMAP, L"Generate Bitmap" ); - DEF_STR(MENU_LIMIT_FPS, L"Limit FPS" ); - DEF_STR(MENU_SAVE, L"&Save State" ); - DEF_STR(MENU_SAVE_AS, L"Save As..." ); - DEF_STR(MENU_RESTORE, L"&Load State" ); - DEF_STR(MENU_LOAD, L"Load..." ); - DEF_STR(MENU_CURRENT_SAVE,L"Current Save S&tate" ); - DEF_STR(MENU_CHEAT, L"Cheats..." ); - DEF_STR(MENU_GS_BUTTON, L"GS Button" ); - DEF_STR(MENU_RESUME, L"R&esume" ); - DEF_STR(MENU_RESET_SOFT, L"&Soft Reset" ); - DEF_STR(MENU_RESET_HARD, L"&Hard Reset" ); + DEF_STR(MENU_SYSTEM, L"&System"); + DEF_STR(MENU_RESET, L"&Reset"); + DEF_STR(MENU_PAUSE, L"&Pause"); + DEF_STR(MENU_BITMAP, L"Generate Bitmap"); + DEF_STR(MENU_LIMIT_FPS, L"Limit FPS"); + DEF_STR(MENU_SAVE, L"&Save State"); + DEF_STR(MENU_SAVE_AS, L"Save As..."); + DEF_STR(MENU_RESTORE, L"&Load State"); + DEF_STR(MENU_LOAD, L"Load..."); + DEF_STR(MENU_CURRENT_SAVE, L"Current Save S&tate"); + DEF_STR(MENU_CHEAT, L"Cheats..."); + DEF_STR(MENU_GS_BUTTON, L"GS Button"); + DEF_STR(MENU_RESUME, L"R&esume"); + DEF_STR(MENU_RESET_SOFT, L"&Soft Reset"); + DEF_STR(MENU_RESET_HARD, L"&Hard Reset"); //Options Menu - DEF_STR(MENU_OPTIONS, L"&Options" ); - DEF_STR(MENU_FULL_SCREEN, L"&Full Screen" ); - DEF_STR(MENU_ON_TOP, L"&Always on &Top" ); - DEF_STR(MENU_CONFG_GFX, L"Configure Graphics Plugin..." ); - DEF_STR(MENU_CONFG_AUDIO, L"Configure Audio Plugin..." ); - DEF_STR(MENU_CONFG_CTRL, L"Configure Controller Plugin..." ); - DEF_STR(MENU_CONFG_RSP, L"Configure RSP Plugin..." ); - DEF_STR(MENU_SHOW_CPU, L"Show CPU Usage" ); - DEF_STR(MENU_SETTINGS, L"&Settings..." ); + DEF_STR(MENU_OPTIONS, L"&Options"); + DEF_STR(MENU_FULL_SCREEN, L"&Full Screen"); + DEF_STR(MENU_ON_TOP, L"&Always on &Top"); + DEF_STR(MENU_CONFG_GFX, L"Configure Graphics Plugin..."); + DEF_STR(MENU_CONFG_AUDIO, L"Configure Audio Plugin..."); + DEF_STR(MENU_CONFG_CTRL, L"Configure Controller Plugin..."); + DEF_STR(MENU_CONFG_RSP, L"Configure RSP Plugin..."); + DEF_STR(MENU_SHOW_CPU, L"Show CPU Usage"); + DEF_STR(MENU_SETTINGS, L"&Settings..."); //Debugger Menu - DEF_STR(MENU_DEBUGGER, L"&Debugger" ); + DEF_STR(MENU_DEBUGGER, L"&Debugger"); //Language Menu - DEF_STR(MENU_LANGUAGE, L"&Language" ); + DEF_STR(MENU_LANGUAGE, L"&Language"); //Help Menu - DEF_STR(MENU_HELP, L"&Help" ); - DEF_STR(MENU_ABOUT_INI, L"About Conf&ig Files" ); - DEF_STR(MENU_ABOUT_PJ64, L"&About Project64" ); - DEF_STR(MENU_FORUM, L"Support &Forum" ); - DEF_STR(MENU_HOMEPAGE, L"&Homepage" ); + DEF_STR(MENU_HELP, L"&Help"); + DEF_STR(MENU_ABOUT_INI, L"About Conf&ig Files"); + DEF_STR(MENU_ABOUT_PJ64, L"&About Project64"); + DEF_STR(MENU_FORUM, L"Support &Forum"); + DEF_STR(MENU_HOMEPAGE, L"&Homepage"); //Current Save Slot menu - DEF_STR(MENU_SLOT_DEFAULT,L"Default" ); - DEF_STR(MENU_SLOT_1, L"Slot 1" ); - DEF_STR(MENU_SLOT_2, L"Slot 2" ); - DEF_STR(MENU_SLOT_3, L"Slot 3" ); - DEF_STR(MENU_SLOT_4, L"Slot 4" ); - DEF_STR(MENU_SLOT_5, L"Slot 5" ); - DEF_STR(MENU_SLOT_6, L"Slot 6" ); - DEF_STR(MENU_SLOT_7, L"Slot 7" ); - DEF_STR(MENU_SLOT_8, L"Slot 8" ); - DEF_STR(MENU_SLOT_9, L"Slot 9" ); - DEF_STR(MENU_SLOT_10, L"Slot 10" ); + DEF_STR(MENU_SLOT_DEFAULT, L"Default"); + DEF_STR(MENU_SLOT_1, L"Slot 1"); + DEF_STR(MENU_SLOT_2, L"Slot 2"); + DEF_STR(MENU_SLOT_3, L"Slot 3"); + DEF_STR(MENU_SLOT_4, L"Slot 4"); + DEF_STR(MENU_SLOT_5, L"Slot 5"); + DEF_STR(MENU_SLOT_6, L"Slot 6"); + DEF_STR(MENU_SLOT_7, L"Slot 7"); + DEF_STR(MENU_SLOT_8, L"Slot 8"); + DEF_STR(MENU_SLOT_9, L"Slot 9"); + DEF_STR(MENU_SLOT_10, L"Slot 10"); //Pop up Menu - DEF_STR(POPUP_PLAY, L"Play Game" ); - DEF_STR(POPUP_INFO, L"ROM Information" ); - DEF_STR(POPUP_SETTINGS, L"Edit Game Settings" ); - DEF_STR(POPUP_CHEATS, L"Edit Cheats" ); - DEF_STR(POPUP_GFX_PLUGIN,L"Graphics Plugin" ); + DEF_STR(POPUP_PLAY, L"Play Game"); + DEF_STR(POPUP_INFO, L"ROM Information"); + DEF_STR(POPUP_SETTINGS, L"Edit Game Settings"); + DEF_STR(POPUP_CHEATS, L"Edit Cheats"); + DEF_STR(POPUP_GFX_PLUGIN, L"Graphics Plugin"); //Alternate Name to save Slot - DEF_STR(SAVE_SLOT_DEFAULT,L"Save Slot - Default" ); - DEF_STR(SAVE_SLOT_1, L"Save Slot - 1" ); - DEF_STR(SAVE_SLOT_2, L"Save Slot - 2" ); - DEF_STR(SAVE_SLOT_3, L"Save Slot - 3" ); - DEF_STR(SAVE_SLOT_4, L"Save Slot - 4" ); - DEF_STR(SAVE_SLOT_5, L"Save Slot - 5" ); - DEF_STR(SAVE_SLOT_6, L"Save Slot - 6" ); - DEF_STR(SAVE_SLOT_7, L"Save Slot - 7" ); - DEF_STR(SAVE_SLOT_8, L"Save Slot - 8" ); - DEF_STR(SAVE_SLOT_9, L"Save Slot - 9" ); - DEF_STR(SAVE_SLOT_10, L"Save Slot - 10" ); + DEF_STR(SAVE_SLOT_DEFAULT, L"Save Slot - Default"); + DEF_STR(SAVE_SLOT_1, L"Save Slot - 1"); + DEF_STR(SAVE_SLOT_2, L"Save Slot - 2"); + DEF_STR(SAVE_SLOT_3, L"Save Slot - 3"); + DEF_STR(SAVE_SLOT_4, L"Save Slot - 4"); + DEF_STR(SAVE_SLOT_5, L"Save Slot - 5"); + DEF_STR(SAVE_SLOT_6, L"Save Slot - 6"); + DEF_STR(SAVE_SLOT_7, L"Save Slot - 7"); + DEF_STR(SAVE_SLOT_8, L"Save Slot - 8"); + DEF_STR(SAVE_SLOT_9, L"Save Slot - 9"); + DEF_STR(SAVE_SLOT_10, L"Save Slot - 10"); /********************************************************************************* * ROM Browser * *********************************************************************************/ //ROM Browser Fields - DEF_STR(RB_FILENAME, L"File Name" ); - DEF_STR(RB_INTERNALNAME, L"Internal Name" ); - DEF_STR(RB_GOODNAME, L"Good Name" ); - DEF_STR(RB_STATUS, L"Status" ); - DEF_STR(RB_ROMSIZE, L"ROM Size" ); - DEF_STR(RB_NOTES_CORE, L"Notes (core)" ); - DEF_STR(RB_NOTES_PLUGIN, L"Notes (default plugins)" ); - DEF_STR(RB_NOTES_USER, L"Notes (user)" ); - DEF_STR(RB_CART_ID, L"Cartridge ID" ); - DEF_STR(RB_MANUFACTUER, L"Manufacturer" ); - DEF_STR(RB_COUNTRY, L"Country" ); - DEF_STR(RB_DEVELOPER, L"Developer" ); - DEF_STR(RB_CRC1, L"CRC1" ); - DEF_STR(RB_CRC2, L"CRC2" ); - DEF_STR(RB_CICCHIP, L"CIC Chip" ); - DEF_STR(RB_RELEASE_DATE, L"Release Date" ); - DEF_STR(RB_GENRE, L"Genre" ); - DEF_STR(RB_PLAYERS, L"Players" ); - DEF_STR(RB_FORCE_FEEDBACK,L"Force Feedback" ); - DEF_STR(RB_FILE_FORMAT, L"File Format" ); + DEF_STR(RB_FILENAME, L"File Name"); + DEF_STR(RB_INTERNALNAME, L"Internal Name"); + DEF_STR(RB_GOODNAME, L"Good Name"); + DEF_STR(RB_STATUS, L"Status"); + DEF_STR(RB_ROMSIZE, L"ROM Size"); + DEF_STR(RB_NOTES_CORE, L"Notes (core)"); + DEF_STR(RB_NOTES_PLUGIN, L"Notes (default plugins)"); + DEF_STR(RB_NOTES_USER, L"Notes (user)"); + DEF_STR(RB_CART_ID, L"Cartridge ID"); + DEF_STR(RB_MANUFACTUER, L"Manufacturer"); + DEF_STR(RB_COUNTRY, L"Country"); + DEF_STR(RB_DEVELOPER, L"Developer"); + DEF_STR(RB_CRC1, L"CRC1"); + DEF_STR(RB_CRC2, L"CRC2"); + DEF_STR(RB_CICCHIP, L"CIC Chip"); + DEF_STR(RB_RELEASE_DATE, L"Release Date"); + DEF_STR(RB_GENRE, L"Genre"); + DEF_STR(RB_PLAYERS, L"Players"); + DEF_STR(RB_FORCE_FEEDBACK, L"Force Feedback"); + DEF_STR(RB_FILE_FORMAT, L"File Format"); //Select ROM - DEF_STR(SELECT_ROM_DIR, L"Select current ROM directory" ); + DEF_STR(SELECT_ROM_DIR, L"Select current ROM directory"); //Messages - DEF_STR(RB_NOT_GOOD_FILE,L"Bad ROM? Use GoodN64 & check for updated RDB." ); + DEF_STR(RB_NOT_GOOD_FILE, L"Bad ROM? Use GoodN64 & check for updated RDB."); /********************************************************************************* * Options * *********************************************************************************/ //Options Title - DEF_STR(OPTIONS_TITLE,L"Settings"); + DEF_STR(OPTIONS_TITLE, L"Settings"); //Tabs - DEF_STR(TAB_PLUGIN, L"Plugins"); - DEF_STR(TAB_DIRECTORY, L"Directories"); - DEF_STR(TAB_OPTIONS, L"Options"); - DEF_STR(TAB_ROMSELECTION,L"ROM Selection"); - DEF_STR(TAB_ADVANCED, L"Advanced"); + DEF_STR(TAB_PLUGIN, L"Plugins"); + DEF_STR(TAB_DIRECTORY, L"Directories"); + DEF_STR(TAB_OPTIONS, L"Options"); + DEF_STR(TAB_ROMSELECTION, L"ROM Selection"); + DEF_STR(TAB_ADVANCED, L"Advanced"); DEF_STR(TAB_ROMSETTINGS, L"General Settings"); - DEF_STR(TAB_SHELLINTERGATION,L"Shell Integration"); - DEF_STR(TAB_ROMNOTES, L"Notes"); - DEF_STR(TAB_SHORTCUTS, L"Keyboard Shortcuts"); - DEF_STR(TAB_ROMSTATUS, L"Status"); - DEF_STR(TAB_RECOMPILER, L"Recompiler"); + DEF_STR(TAB_SHELLINTERGATION, L"Shell Integration"); + DEF_STR(TAB_ROMNOTES, L"Notes"); + DEF_STR(TAB_SHORTCUTS, L"Keyboard Shortcuts"); + DEF_STR(TAB_ROMSTATUS, L"Status"); + DEF_STR(TAB_RECOMPILER, L"Recompiler"); //Plugin Dialog - DEF_STR(PLUG_ABOUT, L"About"); - DEF_STR(PLUG_RSP, L" RSP (Reality Signal Processor) plugin: "); - DEF_STR(PLUG_GFX, L" Video (graphics) plugin: "); - DEF_STR(PLUG_AUDIO, L" Audio (sound) plugin: "); - DEF_STR(PLUG_CTRL, L" Input (controller) plugin: "); - DEF_STR(PLUG_HLE_GFX, L"Graphics HLE"); - DEF_STR(PLUG_HLE_AUDIO,L"Audio HLE"); - DEF_STR(PLUG_DEFAULT, L"** Use System Plugin **"); + DEF_STR(PLUG_ABOUT, L"About"); + DEF_STR(PLUG_RSP, L" RSP (Reality Signal Processor) plugin: "); + DEF_STR(PLUG_GFX, L" Video (graphics) plugin: "); + DEF_STR(PLUG_AUDIO, L" Audio (sound) plugin: "); + DEF_STR(PLUG_CTRL, L" Input (controller) plugin: "); + DEF_STR(PLUG_HLE_GFX, L"Graphics HLE"); + DEF_STR(PLUG_HLE_AUDIO, L"Audio HLE"); + DEF_STR(PLUG_DEFAULT, L"** Use System Plugin **"); //Directory Dialog - DEF_STR(DIR_PLUGIN, L" Plugin directory: "); - DEF_STR(DIR_ROM, L" ROM directory: "); - DEF_STR(DIR_AUTO_SAVE, L" N64 native saves directory: "); - DEF_STR(DIR_INSTANT_SAVE, L" Saved states directory: "); - DEF_STR(DIR_SCREEN_SHOT, L" Screenshot directory: "); - DEF_STR(DIR_ROM_DEFAULT, L"Last folder that a ROM was open from"); + DEF_STR(DIR_PLUGIN, L" Plugin directory: "); + DEF_STR(DIR_ROM, L" ROM directory: "); + DEF_STR(DIR_AUTO_SAVE, L" N64 native saves directory: "); + DEF_STR(DIR_INSTANT_SAVE, L" Saved states directory: "); + DEF_STR(DIR_SCREEN_SHOT, L" Screenshot directory: "); + DEF_STR(DIR_ROM_DEFAULT, L"Last folder that a ROM was open from"); DEF_STR(DIR_SELECT_PLUGIN, L"Select plugin directory"); - DEF_STR(DIR_SELECT_ROM, L"Select ROM directory"); - DEF_STR(DIR_SELECT_AUTO, L"Select N64 native saves directory"); - DEF_STR(DIR_SELECT_INSTANT,L"Select saved states directory"); + DEF_STR(DIR_SELECT_ROM, L"Select ROM directory"); + DEF_STR(DIR_SELECT_AUTO, L"Select N64 native saves directory"); + DEF_STR(DIR_SELECT_INSTANT, L"Select saved states directory"); DEF_STR(DIR_SELECT_SCREEN, L"Select screenshot directory"); - DEF_STR(DIR_TEXTURE, L" Texture pack directory: "); + DEF_STR(DIR_TEXTURE, L" Texture pack directory: "); DEF_STR(DIR_SELECT_TEXTURE, L"Select texture pack directory"); //Options (general) Tab - DEF_STR(OPTION_AUTO_SLEEP, L"Pause emulation when window is not active"); + DEF_STR(OPTION_AUTO_SLEEP, L"Pause emulation when window is not active"); DEF_STR(OPTION_AUTO_FULLSCREEN, L"Enter full-screen mode when loading a ROM"); - DEF_STR(OPTION_BASIC_MODE, L"Hide advanced settings"); - DEF_STR(OPTION_REMEMBER_CHEAT, L"Remember selected cheats"); - DEF_STR(OPTION_DISABLE_SS, L"Disable screen saver when running a ROM"); - DEF_STR(OPTION_DISPLAY_FR, L"Display speed"); - DEF_STR(OPTION_CHECK_RUNNING, L"Check if Project64 is already running"); - DEF_STR(OPTION_CHANGE_FR, L"Speed display:"); + DEF_STR(OPTION_BASIC_MODE, L"Hide advanced settings"); + DEF_STR(OPTION_REMEMBER_CHEAT, L"Remember selected cheats"); + DEF_STR(OPTION_DISABLE_SS, L"Disable screen saver when running a ROM"); + DEF_STR(OPTION_DISPLAY_FR, L"Display speed"); + DEF_STR(OPTION_CHECK_RUNNING, L"Check if Project64 is already running"); + DEF_STR(OPTION_CHANGE_FR, L"Speed display:"); //ROM Browser Tab - DEF_STR(RB_MAX_ROMS, L"Max # of ROMs remembered (0-10):"); - DEF_STR(RB_ROMS, L"ROMs"); - DEF_STR(RB_MAX_DIRS, L"Max # of ROM dirs remembered (0-10):"); - DEF_STR(RB_DIRS, L"dirs"); - DEF_STR(RB_USE, L"Use ROM browser"); - DEF_STR(RB_DIR_RECURSION, L"Use directory recursion"); + DEF_STR(RB_MAX_ROMS, L"Max # of ROMs remembered (0-10):"); + DEF_STR(RB_ROMS, L"ROMs"); + DEF_STR(RB_MAX_DIRS, L"Max # of ROM dirs remembered (0-10):"); + DEF_STR(RB_DIRS, L"dirs"); + DEF_STR(RB_USE, L"Use ROM browser"); + DEF_STR(RB_DIR_RECURSION, L"Use directory recursion"); DEF_STR(RB_AVALIABLE_FIELDS, L"Available fields:"); - DEF_STR(RB_SHOW_FIELDS, L"Order of fields:"); - DEF_STR(RB_ADD, L"Add ->"); - DEF_STR(RB_REMOVE, L"<- Remove"); - DEF_STR(RB_UP, L"Up"); - DEF_STR(RB_DOWN, L"Down"); - DEF_STR(RB_REFRESH, L"Automatically refresh browser"); + DEF_STR(RB_SHOW_FIELDS, L"Order of fields:"); + DEF_STR(RB_ADD, L"Add ->"); + DEF_STR(RB_REMOVE, L"<- Remove"); + DEF_STR(RB_UP, L"Up"); + DEF_STR(RB_DOWN, L"Down"); + DEF_STR(RB_REFRESH, L"Automatically refresh browser"); //Advanced Options - DEF_STR(ADVANCE_INFO, L"Most of these changes will not take effect until a new ROM is opened or current ROM is reset."); - DEF_STR(ADVANCE_DEFAULTS, L"Core Defaults"); - DEF_STR(ADVANCE_CPU_STYLE, L"CPU core style:"); - DEF_STR(ADVANCE_SMCM, L"Self-mod methods:"); - DEF_STR(ADVANCE_MEM_SIZE, L"Default memory size:"); - DEF_STR(ADVANCE_ABL, L"Advanced block linking"); - DEF_STR(ADVANCE_AUTO_START, L"Start emulation when ROM is opened"); - DEF_STR(ADVANCE_OVERWRITE, L"Always override default settings with ones from RDB"); - DEF_STR(ADVANCE_COMPRESS, L"Automatically compress saved states"); - DEF_STR(ADVANCE_DEBUGGER, L"Enable debugger"); - DEF_STR(ADVANCE_SMM_CACHE, L"Cache"); - DEF_STR(ADVANCE_SMM_PIDMA, L"PI DMA"); - DEF_STR(ADVANCE_SMM_VALIDATE,L"Start changed"); + DEF_STR(ADVANCE_INFO, L"Most of these changes will not take effect until a new ROM is opened or current ROM is reset."); + DEF_STR(ADVANCE_DEFAULTS, L"Core Defaults"); + DEF_STR(ADVANCE_CPU_STYLE, L"CPU core style:"); + DEF_STR(ADVANCE_SMCM, L"Self-mod methods:"); + DEF_STR(ADVANCE_MEM_SIZE, L"Default memory size:"); + DEF_STR(ADVANCE_ABL, L"Advanced block linking"); + DEF_STR(ADVANCE_AUTO_START, L"Start emulation when ROM is opened"); + DEF_STR(ADVANCE_OVERWRITE, L"Always override default settings with ones from RDB"); + DEF_STR(ADVANCE_COMPRESS, L"Automatically compress saved states"); + DEF_STR(ADVANCE_DEBUGGER, L"Enable debugger"); + DEF_STR(ADVANCE_SMM_CACHE, L"Cache"); + DEF_STR(ADVANCE_SMM_PIDMA, L"PI DMA"); + DEF_STR(ADVANCE_SMM_VALIDATE, L"Start changed"); DEF_STR(ADVANCE_SMM_PROTECT, L"Protect memory"); - DEF_STR(ADVANCE_SMM_TLB, L"TLB unmapping"); + DEF_STR(ADVANCE_SMM_TLB, L"TLB unmapping"); //ROM Options - DEF_STR(ROM_CPU_STYLE, L"CPU core style:"); - DEF_STR(ROM_VIREFRESH, L"VI refresh rate:"); - DEF_STR(ROM_MEM_SIZE, L"Memory size:"); - DEF_STR(ROM_ABL, L"Advanced block linking"); - DEF_STR(ROM_SAVE_TYPE, L"Default save type:"); - DEF_STR(ROM_COUNTER_FACTOR, L"Counter factor:"); - DEF_STR(ROM_LARGE_BUFFER, L"Larger compile buffer"); - DEF_STR(ROM_USE_TLB, L"Use TLB"); - DEF_STR(ROM_REG_CACHE, L"Register caching"); - DEF_STR(ROM_DELAY_SI, L"Delay SI interrupt"); - DEF_STR(ROM_FAST_SP, L"Fast SP"); - DEF_STR(ROM_DEFAULT, L"Default"); - DEF_STR(ROM_AUDIO_SIGNAL, L"RSP audio signal"); - DEF_STR(ROM_FIXED_AUDIO, L"Fixed audio timing"); - DEF_STR(ROM_FUNC_FIND, L"Function lookup method:"); - DEF_STR(ROM_CUSTOM_SMM, L"Custom self mod Method"); - DEF_STR(ROM_SYNC_AUDIO, L"Sync using audio"); - DEF_STR(ROM_COUNTPERBYTE, L"AI count per byte:"); - DEF_STR(ROM_32BIT, L"32-bit engine:"); - DEF_STR(ROM_DELAY_DP, L"Delay DP interrupt:"); + DEF_STR(ROM_CPU_STYLE, L"CPU core style:"); + DEF_STR(ROM_VIREFRESH, L"VI refresh rate:"); + DEF_STR(ROM_MEM_SIZE, L"Memory size:"); + DEF_STR(ROM_ABL, L"Advanced block linking"); + DEF_STR(ROM_SAVE_TYPE, L"Default save type:"); + DEF_STR(ROM_COUNTER_FACTOR, L"Counter factor:"); + DEF_STR(ROM_LARGE_BUFFER, L"Larger compile buffer"); + DEF_STR(ROM_USE_TLB, L"Use TLB"); + DEF_STR(ROM_REG_CACHE, L"Register caching"); + DEF_STR(ROM_DELAY_SI, L"Delay SI interrupt"); + DEF_STR(ROM_FAST_SP, L"Fast SP"); + DEF_STR(ROM_DEFAULT, L"Default"); + DEF_STR(ROM_AUDIO_SIGNAL, L"RSP audio signal"); + DEF_STR(ROM_FIXED_AUDIO, L"Fixed audio timing"); + DEF_STR(ROM_FUNC_FIND, L"Function lookup method:"); + DEF_STR(ROM_CUSTOM_SMM, L"Custom self mod Method"); + DEF_STR(ROM_SYNC_AUDIO, L"Sync using audio"); + DEF_STR(ROM_COUNTPERBYTE, L"AI count per byte:"); + DEF_STR(ROM_32BIT, L"32-bit engine:"); + DEF_STR(ROM_DELAY_DP, L"Delay DP interrupt:"); //Core Styles - DEF_STR(CORE_INTERPTER, L"Interpreter"); - DEF_STR(CORE_RECOMPILER, L"Recompiler"); - DEF_STR(CORE_SYNC, L"Synchronize cores"); + DEF_STR(CORE_INTERPTER, L"Interpreter"); + DEF_STR(CORE_RECOMPILER, L"Recompiler"); + DEF_STR(CORE_SYNC, L"Synchronize cores"); //Self Mod Methods - DEF_STR(SMCM_NONE, L"None"); - DEF_STR(SMCM_CACHE, L"Cache"); - DEF_STR(SMCM_PROECTED, L"Protect memory"); - DEF_STR(SMCM_CHECK_MEM, L"Check memory & cache"); - DEF_STR(SMCM_CHANGE_MEM, L"Change memory & cache"); - DEF_STR(SMCM_CHECK_ADV, L"Check memory advance"); - DEF_STR(SMCM_CACHE2, L"Clear code on cache"); + DEF_STR(SMCM_NONE, L"None"); + DEF_STR(SMCM_CACHE, L"Cache"); + DEF_STR(SMCM_PROECTED, L"Protect memory"); + DEF_STR(SMCM_CHECK_MEM, L"Check memory & cache"); + DEF_STR(SMCM_CHANGE_MEM, L"Change memory & cache"); + DEF_STR(SMCM_CHECK_ADV, L"Check memory advance"); + DEF_STR(SMCM_CACHE2, L"Clear code on cache"); //Function Lookup method - DEF_STR(FLM_PLOOKUP, L"Physical lookup table"); - DEF_STR(FLM_VLOOKUP, L"Virtual lookup table"); - DEF_STR(FLM_CHANGEMEM, L"Change memory"); + DEF_STR(FLM_PLOOKUP, L"Physical lookup table"); + DEF_STR(FLM_VLOOKUP, L"Virtual lookup table"); + DEF_STR(FLM_CHANGEMEM, L"Change memory"); //RDRAM Size - DEF_STR(RDRAM_4MB, L"4 MB"); - DEF_STR(RDRAM_8MB, L"8 MB"); + DEF_STR(RDRAM_4MB, L"4 MB"); + DEF_STR(RDRAM_8MB, L"8 MB"); //Advanced Block Linking - DEF_STR(ABL_ON, L"On"); - DEF_STR(ABL_OFF, L"Off"); + DEF_STR(ABL_ON, L"On"); + DEF_STR(ABL_OFF, L"Off"); //Save Type - DEF_STR(SAVE_FIRST_USED, L"Use first-used save type"); - DEF_STR(SAVE_4K_EEPROM, L"4-kbit EEPROM"); - DEF_STR(SAVE_16K_EEPROM, L"16-kbit EEPROM"); - DEF_STR(SAVE_SRAM, L"SRAM"); - DEF_STR(SAVE_FLASHRAM, L"Flash RAM"); + DEF_STR(SAVE_FIRST_USED, L"Use first-used save type"); + DEF_STR(SAVE_4K_EEPROM, L"4-kbit EEPROM"); + DEF_STR(SAVE_16K_EEPROM, L"16-kbit EEPROM"); + DEF_STR(SAVE_SRAM, L"SRAM"); + DEF_STR(SAVE_FLASHRAM, L"Flash RAM"); //Shell Integration Tab - DEF_STR(SHELL_TEXT, L"File extension association:"); + DEF_STR(SHELL_TEXT, L"File extension association:"); //ROM Notes - DEF_STR(NOTE_STATUS, L"ROM status:"); - DEF_STR(NOTE_CORE, L"Core note:"); - DEF_STR(NOTE_PLUGIN, L"Plugin note:"); + DEF_STR(NOTE_STATUS, L"ROM status:"); + DEF_STR(NOTE_CORE, L"Core note:"); + DEF_STR(NOTE_PLUGIN, L"Plugin note:"); // Accelerator Selector - DEF_STR(ACCEL_CPUSTATE_TITLE, L"CPU state:"); - DEF_STR(ACCEL_MENUITEM_TITLE, L"Menu item:"); + DEF_STR(ACCEL_CPUSTATE_TITLE, L"CPU state:"); + DEF_STR(ACCEL_MENUITEM_TITLE, L"Menu item:"); DEF_STR(ACCEL_CURRENTKEYS_TITLE, L"Current keys:"); - DEF_STR(ACCEL_SELKEY_TITLE, L"Select new shortcut key:"); - DEF_STR(ACCEL_ASSIGNEDTO_TITLE, L"Currently assigned to:"); - DEF_STR(ACCEL_ASSIGN_BTN, L"Assign"); - DEF_STR(ACCEL_REMOVE_BTN, L"Remove"); - DEF_STR(ACCEL_RESETALL_BTN, L"Reset all"); - DEF_STR(ACCEL_CPUSTATE_1, L"Game not playing"); - DEF_STR(ACCEL_CPUSTATE_2, L"Game playing"); - DEF_STR(ACCEL_CPUSTATE_3, L"Game playing (windowed)"); - DEF_STR(ACCEL_CPUSTATE_4, L"Game playing (full-screen)"); - DEF_STR(ACCEL_DETECTKEY, L"Detect Key"); + DEF_STR(ACCEL_SELKEY_TITLE, L"Select new shortcut key:"); + DEF_STR(ACCEL_ASSIGNEDTO_TITLE, L"Currently assigned to:"); + DEF_STR(ACCEL_ASSIGN_BTN, L"Assign"); + DEF_STR(ACCEL_REMOVE_BTN, L"Remove"); + DEF_STR(ACCEL_RESETALL_BTN, L"Reset all"); + DEF_STR(ACCEL_CPUSTATE_1, L"Game not playing"); + DEF_STR(ACCEL_CPUSTATE_2, L"Game playing"); + DEF_STR(ACCEL_CPUSTATE_3, L"Game playing (windowed)"); + DEF_STR(ACCEL_CPUSTATE_4, L"Game playing (full-screen)"); + DEF_STR(ACCEL_DETECTKEY, L"Detect Key"); // Frame Rate Option - DEF_STR(STR_FR_VIS, L"Vertical interrupts per second"); - DEF_STR(STR_FR_DLS, L"Display lists per second"); - DEF_STR(STR_FR_PERCENT, L"Percentage of full speed"); + DEF_STR(STR_FR_VIS, L"Vertical interrupts per second"); + DEF_STR(STR_FR_DLS, L"Display lists per second"); + DEF_STR(STR_FR_PERCENT, L"Percentage of full speed"); // Increase speed - DEF_STR(STR_INSREASE_SPEED, L"Increase Game Speed"); - DEF_STR(STR_DECREASE_SPEED, L"Decrease Game Speed"); + DEF_STR(STR_INSREASE_SPEED, L"Increase Game Speed"); + DEF_STR(STR_DECREASE_SPEED, L"Decrease Game Speed"); //Bottom page buttons - DEF_STR(BOTTOM_RESET_PAGE, L"Reset Page"); - DEF_STR(BOTTOM_RESET_ALL, L"Reset All"); - DEF_STR(BOTTOM_APPLY, L"Apply"); - DEF_STR(BOTTOM_CLOSE, L"Close"); + DEF_STR(BOTTOM_RESET_PAGE, L"Reset Page"); + DEF_STR(BOTTOM_RESET_ALL, L"Reset All"); + DEF_STR(BOTTOM_APPLY, L"Apply"); + DEF_STR(BOTTOM_CLOSE, L"Close"); /********************************************************************************* * ROM Information * *********************************************************************************/ //ROM Info Title - DEF_STR(INFO_TITLE, L"ROM Information"); + DEF_STR(INFO_TITLE, L"ROM Information"); //ROM Info Text - DEF_STR(INFO_ROM_NAME_TEXT, L"ROM name:"); - DEF_STR(INFO_FILE_NAME_TEXT, L"File name:"); - DEF_STR(INFO_LOCATION_TEXT, L"Location:"); - DEF_STR(INFO_SIZE_TEXT, L"ROM size:"); - DEF_STR(INFO_CART_ID_TEXT, L"Cartridge ID:"); + DEF_STR(INFO_ROM_NAME_TEXT, L"ROM name:"); + DEF_STR(INFO_FILE_NAME_TEXT, L"File name:"); + DEF_STR(INFO_LOCATION_TEXT, L"Location:"); + DEF_STR(INFO_SIZE_TEXT, L"ROM size:"); + DEF_STR(INFO_CART_ID_TEXT, L"Cartridge ID:"); DEF_STR(INFO_MANUFACTURER_TEXT, L"Manufacturer:"); - DEF_STR(INFO_COUNTRY_TEXT, L"Country:"); - DEF_STR(INFO_CRC1_TEXT, L"CRC1:"); - DEF_STR(INFO_CRC2_TEXT, L"CRC2:"); - DEF_STR(INFO_CIC_CHIP_TEXT, L"CIC chip:"); - DEF_STR(INFO_MD5_TEXT, L"MD5:"); + DEF_STR(INFO_COUNTRY_TEXT, L"Country:"); + DEF_STR(INFO_CRC1_TEXT, L"CRC1:"); + DEF_STR(INFO_CRC2_TEXT, L"CRC2:"); + DEF_STR(INFO_CIC_CHIP_TEXT, L"CIC chip:"); + DEF_STR(INFO_MD5_TEXT, L"MD5:"); /********************************************************************************* * Cheats * *********************************************************************************/ //Cheat List - DEF_STR(CHEAT_TITLE, L"Cheats"); - DEF_STR(CHEAT_LIST_FRAME, L"Cheats:"); - DEF_STR(CHEAT_NOTES_FRAME, L" Notes: "); - DEF_STR(CHEAT_MARK_ALL, L"Mark All"); - DEF_STR(CHEAT_MARK_NONE, L"Unmark All"); + DEF_STR(CHEAT_TITLE, L"Cheats"); + DEF_STR(CHEAT_LIST_FRAME, L"Cheats:"); + DEF_STR(CHEAT_NOTES_FRAME, L" Notes: "); + DEF_STR(CHEAT_MARK_ALL, L"Mark All"); + DEF_STR(CHEAT_MARK_NONE, L"Unmark All"); //Add Cheat - DEF_STR(CHEAT_ADDCHEAT_FRAME, L"Add Cheat"); - DEF_STR(CHEAT_ADDCHEAT_NAME, L"Name:"); - DEF_STR(CHEAT_ADDCHEAT_CODE, L"Code:"); + DEF_STR(CHEAT_ADDCHEAT_FRAME, L"Add Cheat"); + DEF_STR(CHEAT_ADDCHEAT_NAME, L"Name:"); + DEF_STR(CHEAT_ADDCHEAT_CODE, L"Code:"); DEF_STR(CHEAT_ADDCHEAT_INSERT, L"Insert"); - DEF_STR(CHEAT_ADDCHEAT_CLEAR, L"Clear"); - DEF_STR(CHEAT_ADDCHEAT_NOTES, L" Cheat Notes: "); - DEF_STR(CHEAT_ADD_TO_DB, L"Add to DB"); + DEF_STR(CHEAT_ADDCHEAT_CLEAR, L"Clear"); + DEF_STR(CHEAT_ADDCHEAT_NOTES, L" Cheat Notes: "); + DEF_STR(CHEAT_ADD_TO_DB, L"Add to DB"); //Code extension - DEF_STR(CHEAT_CODE_EXT_TITLE, L"Code Extensions"); - DEF_STR(CHEAT_CODE_EXT_TXT, L"Please choose a value to be used for:"); - DEF_STR(CHEAT_OK, L"OK"); - DEF_STR(CHEAT_CANCEL, L"Cancel"); + DEF_STR(CHEAT_CODE_EXT_TITLE, L"Code Extensions"); + DEF_STR(CHEAT_CODE_EXT_TXT, L"Please choose a value to be used for:"); + DEF_STR(CHEAT_OK, L"OK"); + DEF_STR(CHEAT_CANCEL, L"Cancel"); //Digital Value - DEF_STR(CHEAT_QUANTITY_TITLE, L"Quantity Digit"); - DEF_STR(CHEAT_CHOOSE_VALUE, L"Please choose a value for:"); - DEF_STR(CHEAT_VALUE, L"&Value"); - DEF_STR(CHEAT_FROM, L"from"); - DEF_STR(CHEAT_TO, L"to"); - DEF_STR(CHEAT_NOTES, L"&Notes:"); - DEF_STR(CHEAT_ADDCHEAT_ADD, L"Add Cheat"); - DEF_STR(CHEAT_ADDCHEAT_NEW, L"New Cheat"); - DEF_STR(CHEAT_ADDCHEAT_CODEDES,L"
"); - DEF_STR(CHEAT_ADDCHEAT_OPT, L"Options:"); + DEF_STR(CHEAT_QUANTITY_TITLE, L"Quantity Digit"); + DEF_STR(CHEAT_CHOOSE_VALUE, L"Please choose a value for:"); + DEF_STR(CHEAT_VALUE, L"&Value"); + DEF_STR(CHEAT_FROM, L"from"); + DEF_STR(CHEAT_TO, L"to"); + DEF_STR(CHEAT_NOTES, L"&Notes:"); + DEF_STR(CHEAT_ADDCHEAT_ADD, L"Add Cheat"); + DEF_STR(CHEAT_ADDCHEAT_NEW, L"New Cheat"); + DEF_STR(CHEAT_ADDCHEAT_CODEDES, L"
"); + DEF_STR(CHEAT_ADDCHEAT_OPT, L"Options:"); DEF_STR(CHEAT_ADDCHEAT_OPTDES, L"