From 41d4f7ff04b87b634d046819c12f934349ce274f Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 7 Jun 2010 02:23:58 +0000 Subject: [PATCH] git-svn-id: https://localhost/svn/Project64/trunk@33 111125ac-702d-7242-af9c-5ba8ae61c1ef --- Bin/Debug/pifdata.bin | Bin 0 -> 2048 bytes .../Multilanguage/Language Class.cpp | 5 +- .../N64 System/C Core/BreakPoints.cpp | 2 + .../N64 System/C Core/C Core Interface.cpp | 210 -- .../N64 System/C Core/C Core Interface.h | 7 - Source/Project64/N64 System/C Core/C Core.h | 0 .../N64 System/C Core/C Global Variable.h | 0 .../Project64/N64 System/C Core/C Memory.cpp | 0 Source/Project64/N64 System/C Core/C Memory.h | 0 .../Project64/N64 System/C Core/CPU Log.cpp | 2 + Source/Project64/N64 System/C Core/CPU.cpp | 0 Source/Project64/N64 System/C Core/CPU.h | 39 - Source/Project64/N64 System/C Core/Debugger.h | 1 - .../Project64/N64 System/C Core/Exception.cpp | 1 - .../Project64/N64 System/C Core/Exception.h | 77 - Source/Project64/N64 System/C Core/FlashRam.c | 243 --- .../N64 System/C Core/Interpreter CPU.cpp | 0 .../N64 System/C Core/Interpreter CPU.h | 0 Source/Project64/N64 System/C Core/Main.h | 1 - Source/Project64/N64 System/C Core/Plugin.h | 403 ---- .../N64 System/C Core/Recompiler CPU.cpp | 385 ---- .../N64 System/C Core/Recompiler CPU.h | 246 --- .../N64 System/C Core/Recompiler Fpu Ops.cpp | 0 .../N64 System/C Core/Recompiler Ops.cpp | 0 .../N64 System/C Core/Recompiler Ops.h | 26 - .../Project64/N64 System/C Core/Registers.cpp | 0 .../Project64/N64 System/C Core/Registers.h | 0 Source/Project64/N64 System/C Core/Sync CPU.c | 660 ------ Source/Project64/N64 System/C Core/Sync CPU.h | 41 - .../Project64/N64 System/C Core/TLB Display.c | 291 --- Source/Project64/N64 System/C Core/Tlb.c | 0 Source/Project64/N64 System/C Core/Tlb.h | 108 - Source/Project64/N64 System/C Core/X86.cpp | 0 Source/Project64/N64 System/C Core/X86.h | 0 .../N64 System/C Core/r4300i Memory.cpp | 366 ---- .../N64 System/C Core/r4300i Memory.h | 32 - .../N64 System/C Core/r4300i Registers.cpp | 2 + .../Project64/N64 System/C Core/tlb Display.h | 27 - .../Project64/N64 System/C Core/x86 fpu.cpp | 100 - .../Debugger/Debugger - Memory Dump.cpp | 1 + .../Debugger/Debugger - Memory Search.cpp | 1 + .../N64 System/Debugger/Debugger - TLB.cpp | 1 + .../Debugger/Debugger - View Memory.cpp | 1 + .../N64 System/Debugger/Debugger.cpp | 6 +- .../Interpreter/Interpreter CPU.cpp | 8 +- .../N64 System/Mips/Memory Virtual Mem.h | 3 +- Source/Project64/N64 System/Mips/Memory.cpp | 1294 ++++++------ .../N64 System/Mips/System Timing.cpp | 9 +- Source/Project64/N64 System/N64 Class.cpp | 87 +- Source/Project64/N64 System/N64 Class.h | 3 +- .../Project64/N64 System/Profiling Class.cpp | 4 +- .../N64 System/Recompiler/Code Block.h | 6 +- .../N64 System/Recompiler/Code Section.cpp | 107 +- .../N64 System/Recompiler/Code Section.h | 51 +- .../Recompiler/Function Map Class.cpp | 17 +- .../Recompiler/Function Map Class.h | 37 +- .../Recompiler/Recompiler Class.cpp | 207 +- .../N64 System/Recompiler/Recompiler Class.h | 4 +- .../N64 System/Recompiler/Recompiler Ops.cpp | 348 ++- .../N64 System/Recompiler/Recompiler Ops.h | 6 +- .../N64 System/Recompiler/Reg Info.cpp | 23 +- .../N64 System/Recompiler/Section Info.cpp | 26 +- .../N64 System/Recompiler/X86ops.cpp | 4 +- .../N64 System/Rom Information Class.cpp | 3 +- .../N64 System/Speed Limitor Class.cpp | 4 +- Source/Project64/Plugins/Audio Plugin.cpp | 3 +- .../Project64/Plugins/Controller Plugin.cpp | 3 +- Source/Project64/Plugins/GFX plugin.cpp | 3 +- Source/Project64/Plugins/Plugin Class.cpp | 55 +- Source/Project64/Plugins/Plugin Class.h | 7 + Source/Project64/Plugins/RSP Plugin.cpp | 3 +- Source/Project64/Project64.dsp | 161 +- Source/Project64/Settings/Gui Settings.cpp | 3 +- .../Project64/Settings/N64System Settings.cpp | 3 +- .../Settings/Notification Settings.cpp | 3 +- .../Settings/Recompiler Settings.cpp | 3 +- Source/Project64/Settings/Setting Config.cpp | 1872 ----------------- .../SettingType/SettingsType-Application.cpp | 3 +- .../SettingsType-ApplicationIndex.cpp | 3 +- .../SettingType/SettingsType-Cheats.cpp | 3 +- .../SettingType/SettingsType-GameSetting.cpp | 3 +- .../SettingsType-GameSettingIndex.cpp | 3 +- .../SettingType/SettingsType-RDBCpuType.cpp | 3 +- .../SettingType/SettingsType-RDBOnOff.cpp | 3 +- .../SettingType/SettingsType-RDBRamSize.cpp | 3 +- .../SettingType/SettingsType-RDBSaveChip.cpp | 3 +- .../SettingType/SettingsType-RDBYesNo.cpp | 3 +- .../SettingType/SettingsType-RelativePath.cpp | 3 +- .../SettingType/SettingsType-RomDatabase.cpp | 3 +- .../SettingsType-RomDatabaseIndex.cpp | 3 +- .../SettingsType-SelectedDirectory.cpp | 3 +- .../SettingType/SettingsType-TempBool.cpp | 3 +- .../SettingType/SettingsType-TempNumber.cpp | 3 +- .../SettingType/SettingsType-TempString.cpp | 3 +- Source/Project64/User Interface.h | 1 - Source/Project64/User Interface/Cheats.cpp | 5 - Source/Project64/User Interface/Cheats.h | 0 .../User Interface/Frame Per Second Class.cpp | 5 +- .../User Interface/Main Menu Class.cpp | 7 +- .../Project64/User Interface/Menu Class.cpp | 3 +- .../User Interface/MenuShortCuts.cpp | 3 +- .../User Interface/Notification Class.cpp | 7 +- .../User Interface/Rom Browser Class.cpp | 11 +- .../User Interface/Settings Config.cpp | 3 +- .../Settings Page - Advanced Options.cpp | 2 +- .../Settings/Settings Page - Directories.cpp | 2 +- .../Settings Page - Game - General.cpp | 2 +- .../Settings Page - Game - Plugin.cpp | 2 +- .../Settings Page - Game - Recompiler.cpp | 2 +- .../Settings Page - Game - Status.cpp | 2 +- .../Settings/Settings Page - Game Browser.cpp | 2 +- .../Settings Page - Keyboard Shortcuts.cpp | 2 +- .../Settings/Settings Page - Options.cpp | 2 +- .../Settings/Settings Page - Plugin.cpp | 2 +- .../User Interface/Settings/Settings Page.cpp | 2 +- .../Project64/User Interface/UI Resources.aps | Bin 309664 -> 306564 bytes .../Project64/User Interface/UI Resources.rc | 7 - .../WTL Controls/ModifiedEditBox.cpp | 2 +- .../WTL Controls/PartialGroupBox.cpp | 3 +- Source/Project64/User Interface/about.htm | 62 - Source/Project64/ValidateBinary.cpp | 7 +- Source/Project64/stdafx.cpp | 1 + Source/Project64/stdafx.h | 5 - 123 files changed, 1151 insertions(+), 6709 deletions(-) create mode 100644 Bin/Debug/pifdata.bin delete mode 100644 Source/Project64/N64 System/C Core/C Core.h delete mode 100644 Source/Project64/N64 System/C Core/C Global Variable.h delete mode 100644 Source/Project64/N64 System/C Core/C Memory.cpp delete mode 100644 Source/Project64/N64 System/C Core/C Memory.h delete mode 100644 Source/Project64/N64 System/C Core/CPU.cpp delete mode 100644 Source/Project64/N64 System/C Core/Exception.h delete mode 100644 Source/Project64/N64 System/C Core/FlashRam.c delete mode 100644 Source/Project64/N64 System/C Core/Interpreter CPU.cpp delete mode 100644 Source/Project64/N64 System/C Core/Interpreter CPU.h delete mode 100644 Source/Project64/N64 System/C Core/Plugin.h delete mode 100644 Source/Project64/N64 System/C Core/Recompiler CPU.cpp delete mode 100644 Source/Project64/N64 System/C Core/Recompiler CPU.h delete mode 100644 Source/Project64/N64 System/C Core/Recompiler Fpu Ops.cpp delete mode 100644 Source/Project64/N64 System/C Core/Recompiler Ops.cpp delete mode 100644 Source/Project64/N64 System/C Core/Recompiler Ops.h delete mode 100644 Source/Project64/N64 System/C Core/Registers.cpp delete mode 100644 Source/Project64/N64 System/C Core/Registers.h delete mode 100644 Source/Project64/N64 System/C Core/Sync CPU.c delete mode 100644 Source/Project64/N64 System/C Core/Sync CPU.h delete mode 100644 Source/Project64/N64 System/C Core/TLB Display.c delete mode 100644 Source/Project64/N64 System/C Core/Tlb.c delete mode 100644 Source/Project64/N64 System/C Core/Tlb.h delete mode 100644 Source/Project64/N64 System/C Core/X86.cpp delete mode 100644 Source/Project64/N64 System/C Core/X86.h delete mode 100644 Source/Project64/N64 System/C Core/tlb Display.h delete mode 100644 Source/Project64/N64 System/C Core/x86 fpu.cpp delete mode 100644 Source/Project64/User Interface/Cheats.cpp delete mode 100644 Source/Project64/User Interface/Cheats.h delete mode 100644 Source/Project64/User Interface/about.htm create mode 100644 Source/Project64/stdafx.cpp diff --git a/Bin/Debug/pifdata.bin b/Bin/Debug/pifdata.bin new file mode 100644 index 0000000000000000000000000000000000000000..58ed067ff4ce846998965b3955f6d24c118ee847 GIT binary patch literal 2048 zcmdT_PiP!f82`PQ$?j~D+DV$$EyQ+)o!Q+qIV5X}73MIc3c0ybA~`NJ#jOcAkQ{R8 zVQC{Ikj(_`A%`B8c3Ts>n~D9S6}cQ5C%uIdT)nE5br?fB#Jh<8lxtf@yDO?%EeoTiPfGpR zKYEq=g4El(8gcG%-r1BU?3Oer^EDG_N$n*r?S(J5qYAh4Zo}Pkx8Y10a2D~SQ;+wS z7a-@FGYM^fIohe8j&_>Z*Q$^>QGou&ox|JGuDlxGp-qD^mgslq`5xow*Z}kk_j1z^ z&~KmZE%09;-F``H;5^qV_i^SVfn&l9k zroOjfO~M;`0@1aFxKn2?X)kqh&V6%iOP;H0aDaP^f6%e&@FbU|M?19FxYqU~dRAW} zR-cL=)fY~QQ5*!!ZhMaBZmYt+3{UIAK6*grPV}Is0wui5cp6zJa|Hv`MVU{L4XPaL z7!dc3RF4M*UeZA+=>)`P?qCoF!%?@OxBQs&;f7ygIQ#;G;Y|#LH;@gl!w#>(3_nM2 zxPj#2xJz>F_I@8NR%5Dy^Z7nA=UvDoV<--jC5y%Pk?xC8hxw;pJ7Gh z$F1-xR&r-?nE9Gh9wk%oiyHEUm?*D0@Hb<~H#G6ntQCfsQx7u6DwgT1(&W2@MfzG+ zRJ}iMLJzKDE|4*FOsN3BZ-X!mN#n7kiTmS;8P z@n%YVcg#^=XPncGSWw3WRnI#jGj53w3KltPVGXNFA?rwca*v4((_(%r)LnRK{~htb zOfv`PdAC*SDq?#xtse6%1JQK2imH4M@*QQaW5(Xke#P2m?j|^j98( z80$uim?_@fl<@hcq}>|V+-un#YS~S__i+>J^IiEOUzGPA3+wQS^;_6|Evzr=;K0%7 z`}8z4>L-HBC^AnSQXkZ4vrZ1yT)^53Sc3s;F)VbTiUR#WByX{dlI2T2t-Lo-oI?iOgv1_lKV4v9K+YMVT zHhZvHKZW6c?Y+d9?9*0X6tN#iQc64a@lw7$`a|mMc6f|y_ufsc{D<(L0@-inKjcMt N(f{z1vHzE_{{qpG-@5<+ literal 0 HcmV?d00001 diff --git a/Source/Project64/Multilanguage/Language Class.cpp b/Source/Project64/Multilanguage/Language Class.cpp index 7ac1ca94f..137ef76a0 100644 --- a/Source/Project64/Multilanguage/Language Class.cpp +++ b/Source/Project64/Multilanguage/Language Class.cpp @@ -1,7 +1,4 @@ -#include "..\\Multilanguage.h" -#include "..\\Settings.h" -#include -#include "..\User Interface\resource.h" +#include "stdafx.h" CLanguage * _Lang = NULL; diff --git a/Source/Project64/N64 System/C Core/BreakPoints.cpp b/Source/Project64/N64 System/C Core/BreakPoints.cpp index d692a20e6..816b91364 100644 --- a/Source/Project64/N64 System/C Core/BreakPoints.cpp +++ b/Source/Project64/N64 System/C Core/BreakPoints.cpp @@ -1,3 +1,5 @@ +#include "stdafx.h" + /* * Project 64 - A Nintendo 64 emulator. * diff --git a/Source/Project64/N64 System/C Core/C Core Interface.cpp b/Source/Project64/N64 System/C Core/C Core Interface.cpp index 895ae4890..c5a85d33c 100644 --- a/Source/Project64/N64 System/C Core/C Core Interface.cpp +++ b/Source/Project64/N64 System/C Core/C Core Interface.cpp @@ -1,11 +1,8 @@ #include "stdafx.h" -#include "C Core.h" #include "eeprom.h" #include "mempak.h" #include "Plugin.h" #include "Logging.h" -#include "Interpreter CPU.h" -#include "Recompiler CPU.h" #include "CPU Log.h" #include "sram.h" #include "flashram.h" @@ -27,87 +24,13 @@ char g_RomName [300]; DWORD * _AudioIntrReg = NULL; enum SystemType g_SystemType; -#ifdef toremove -/******** All DLLs have this function **************/ -void (__cdecl *GetDllInfo) ( PLUGIN_INFO * PluginInfo ); - -/********** RSP DLL: Functions *********************/ -//void (__cdecl *GetRspDebugInfo) ( RSPDEBUG_INFO * DebugInfo ); -//void (__cdecl *RSPCloseDLL) ( void ); -//void (__cdecl *RSPDllAbout) ( HWND hWnd ); -//void (__cdecl *RSPDllConfig) ( HWND hWnd ); -//void (__cdecl *RSPRomClosed) ( void ); -DWORD (__cdecl *DoRspCycles) ( DWORD ); -//void (__cdecl *InitiateRSP_1_0) ( RSP_INFO_1_0 Rsp_Info, DWORD * Cycles); -//void (__cdecl *InitiateRSP_1_1) ( RSP_INFO_1_1 Rsp_Info, DWORD * Cycles); -//void (__cdecl *InitiateRSPDebugger)( DEBUG_INFO DebugInfo); - -/********** GFX DLL: Functions *********************/ -void (__cdecl *CaptureScreen) ( const char * ); -void (__cdecl *ChangeWindow) ( void ); -//void (__cdecl *GetGfxDebugInfo) ( GFXDEBUG_INFO * GFXDebugInfo ); -//void (__cdecl *GFXCloseDLL) ( void ); -//void (__cdecl *GFXDllAbout) ( HWND hParent ); -//void (__cdecl *GFXDllConfig) ( HWND hParent ); -//void (__cdecl *GfxRomClosed) ( void ); -//void (__cdecl *GfxRomOpen) ( void ); -void (__cdecl *DrawScreen) ( void ); -//void (__cdecl *FrameBufferRead) ( DWORD addr ); -//void (__cdecl *FrameBufferWrite) ( DWORD addr, DWORD Bytes ); -//BOOL (__cdecl *InitiateGFX) ( GFX_INFO Gfx_Info ); -//void (__cdecl *InitiateGFXDebugger)( DEBUG_INFO DebugInfo); -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 ); - -/************ Audio DLL: Functions *****************/ -//void (__cdecl *AiCloseDLL) ( void ); -//void (__cdecl *AiDacrateChanged) ( int SystemType ); -void (__cdecl *AiLenChanged) ( void ); -//void (__cdecl *AiDllAbout) ( HWND hParent ); -//void (__cdecl *AiDllConfig) ( HWND hParent ); -//void (__cdecl *AiDllTest) ( HWND hParent ); -DWORD (__cdecl *AiReadLength) ( void ); -//void (__cdecl *AiRomClosed) ( void ); -//void (__cdecl *AiUpdate) ( BOOL Wait ); -//BOOL (__cdecl *InitiateAudio) ( AUDIO_INFO Audio_Info ); -void (__cdecl *ProcessAList) ( void ); - -/********** Controller DLL: Functions **************/ -//void (__cdecl *ContCloseDLL) ( void ); -void (__cdecl *ControllerCommand)( int Control, BYTE * Command ); -//void (__cdecl *ContDllAbout) ( HWND hParent ); -//void (__cdecl *ContConfig) ( HWND hParent ); -//void (__cdecl *InitiateControllers_1_0)( HWND hMainWindow, CONTROL Controls[4] ); -//void (__cdecl *InitiateControllers_1_1)( CONTROL_INFO ControlInfo ); -void (__cdecl *GetKeys) ( int Control, BUTTONS * Keys ); -void (__cdecl *ReadController) ( int Control, BYTE * Command ); -//void (__cdecl *ContRomOpen) ( void ); -//void (__cdecl *ContRomClosed) ( void ); -//void (__cdecl *WM_KeyDown) ( WPARAM wParam, LPARAM lParam ); -//void (__cdecl *WM_KeyUp) ( WPARAM wParam, LPARAM lParam ); -void (__cdecl *RumbleCommand) ( int Control, BOOL bRumble ); -#endif - //Memory DWORD g_RdramSize; BOOL g_IndvidualBlock, g_Profiling; -DWORD g_CurrentFrame; -QWORD g_Frequency, g_Frames[NoOfFrames], g_LastFrame; - -void CC_Core::SetSyncCpu ( CN64System * System ) -{ - _SyncSystem = System; -} void CC_Core::SetSettings ( ) { - _Settings = _Settings; if (_Settings) { g_HaveDebugger = _Settings->LoadBool(Debugger_Enabled); @@ -142,122 +65,6 @@ void CC_Core::SetSettings ( ) } } - -#ifdef toremove -void CC_Core::SetCurrentSystem (CN64System * System ) -{ - _MMU = NULL; - _Reg = NULL; - _TLB = NULL; - _Audio = NULL; - _Recompiler = NULL; - - _N64System = System; - - if (_N64System) - { - _Recompiler = System->m_Recomp; - _MMU = &System->m_MMU_VM; - _TLB = &System->m_TLB; - _Plugins = System->m_Plugins; - _Audio = &System->m_Audio; - _Reg = &System->m_Reg; - } - if (_Reg) - { - _GPR = _Reg->m_GPR; - _CP0 = _Reg->m_CP0; - _FPR = _Reg->m_FPR; - _FPCR = _Reg->m_FPCR; - _FPRFloatLocation = _Reg->m_FPR_S; - _FPRDoubleLocation = _Reg->m_FPR_D; - _RegHI = &_Reg->m_HI; - _RegLO = &_Reg->m_LO; - _LLBit = &_Reg->m_LLBit; - _LLAddr = &_Reg->m_LLAddr; - _RegRI = _Reg->m_RDRAM_Interface; - _RegRDRAM = _Reg->m_RDRAM_Registers; - _RegMI = _Reg->m_Mips_Interface; - _RegVI = _Reg->m_Video_Interface; - _RegDPC = _Reg->m_Display_ControlReg; - _RegAI = _Reg->m_Audio_Interface; - _RegSP = _Reg->m_SigProcessor_Interface; - _RegPI = _Reg->m_Peripheral_Interface; - _RegSI = _Reg->m_SerialInterface; - _AudioIntrReg = &_Reg->m_AudioIntrReg; - _PROGRAM_COUNTER = &_Reg->m_PROGRAM_COUNTER; - _NextTimer = &_N64System->m_NextTimer; - } - - CaptureScreen = _Plugins->Gfx()->CaptureScreen; - ChangeWindow = _Plugins->Gfx()->ChangeWindow; - DrawScreen = _Plugins->Gfx()->DrawScreen; - MoveScreen = _Plugins->Gfx()->MoveScreen; - ProcessDList = _Plugins->Gfx()->ProcessDList; - ProcessRDPList = _Plugins->Gfx()->ProcessRDPList; - ShowCFB = _Plugins->Gfx()->ShowCFB; - UpdateScreen = _Plugins->Gfx()->UpdateScreen; - ViStatusChanged = _Plugins->Gfx()->ViStatusChanged; - ViWidthChanged = _Plugins->Gfx()->ViWidthChanged; -#ifdef tofix -// GetGfxDebugInfo = _Plugins->Gfx()->GetGfxDebugInfo; -// GFXCloseDLL = _Plugins->Gfx()->GFXCloseDLL; -// GFXDllAbout = _Plugins->Gfx()->GFXDllAbout; -// GFXDllConfig = _Plugins->Gfx()->GFXDllConfig; -// GfxRomClosed = _Plugins->Gfx()->GfxRomClosed; -// GfxRomOpen = _Plugins->Gfx()->GfxRomOpen; -// FrameBufferRead = _Plugins->Gfx()->FrameBufferRead; -// FrameBufferWrite = _Plugins->Gfx()->FrameBufferWrite; -// InitiateGFX = _Plugins->Gfx()->InitiateGFX; -// InitiateGFXDebugger = _Plugins->Gfx()->InitiateGFXDebugger; -#endif - - ControllerCommand = _Plugins->Control()->ControllerCommand; - GetKeys = _Plugins->Control()->GetKeys; - ReadController = _Plugins->Control()->ReadController; - RumbleCommand = _Plugins->Control()->RumbleCommand; - g_Controllers = _Plugins->Control()->m_PluginControllers; -#ifdef tofix -// ContCloseDLL = _Plugins->Control()->ContCloseDLL; -// ContDllAbout = _Plugins->Control()->ContDllAbout; -// ContConfig = _Plugins->Control()->ContConfig; -// InitiateControllers_1_0= _Plugins->Control()->InitiateControllers_1_0; -// InitiateControllers_1_1= _Plugins->Control()->InitiateControllers_1_1; -// ContRomOpen = _Plugins->Control()->ContRomOpen; -// ContRomClosed = _Plugins->Control()->ContRomClosed; -// WM_KeyDown = _Plugins->Control()->WM_KeyDown; -// WM_KeyUp = _Plugins->Control()->WM_KeyUp; -#endif - - DoRspCycles = _Plugins->RSP()->DoRspCycles; -#ifdef tofix -// GetRspDebugInfo = _Plugins->RSP()->GetRspDebugInfo; -// RSPCloseDLL = _Plugins->RSP()->RSPCloseDLL; -// RSPDllAbout = _Plugins->RSP()->RSPDllAbout; -// RSPDllConfig = _Plugins->RSP()->RSPDllConfig; -// RSPRomClosed = _Plugins->RSP()->RSPRomClosed; -// InitiateRSP_1_0 = _Plugins->RSP()->InitiateRSP_1_0; -// InitiateRSP_1_1 = _Plugins->RSP()->InitiateRSP_1_1; -// InitiateRSPDebugger = _Plugins->RSP()->InitiateRSPDebugger; -#endif - - AiLenChanged = _Plugins->Audio()->LenChanged; - AiReadLength = _Plugins->Audio()->ReadLength; - ProcessAList = _Plugins->Audio()->ProcessAList; -#ifdef tofix -// AiCloseDLL = _Plugins->Audio()->AiCloseDLL; -// AiDacrateChanged = _Plugins->Audio()->AiDacrateChanged; -// AiDllAbout = _Plugins->Audio()->AiDllAbout; -// AiDllConfig = _Plugins->Audio()->AiDllConfig; -// AiDllTest = _Plugins->Audio()->AiDllTest; -// AiRomClosed = _Plugins->Audio()->AiRomClosed; -// AiUpdate = _Plugins->Audio()->Update; -// InitiateAudio = _Plugins->Audio()->InitiateAudio; - g_MemorStack = &_MMU->m_MemoryStack; -#endif -} -#endif - void CC_Core::PauseExecution ( void ) { _N64System->Pause(); @@ -277,18 +84,6 @@ void CC_Core::RunRsp ( void ) } } -void CC_Core::RefreshScreen(void) -{ - try - { - _N64System->RefreshScreen(); - } - catch (...) - { - WriteTraceF(TraceError,"Exception caught\nFile: %s\nLine: %d",__FILE__,__LINE__); - } -} - void CC_Core::GenerateProfileLog ( void ) { _N64System->m_Profile.GenerateLog(); @@ -390,11 +185,6 @@ void RunRsp( void ) CC_Core::RunRsp(); } -void RefreshScreen( void ) -{ - CC_Core::RefreshScreen(); -} - void SyncSystem (void) { _N64System->SyncCPU(_SyncSystem); diff --git a/Source/Project64/N64 System/C Core/C Core Interface.h b/Source/Project64/N64 System/C Core/C Core Interface.h index 944562e26..d5ad9b3d5 100644 --- a/Source/Project64/N64 System/C Core/C Core Interface.h +++ b/Source/Project64/N64 System/C Core/C Core Interface.h @@ -10,9 +10,7 @@ class CC_Core { public: static void SetSettings ( ); - static void SetSyncCpu ( CN64System * System ); static void RunRsp (void ); - static void RefreshScreen (void ); static void ApplyCheats (CN64System * System ); static void ApplyGSButtonCheats (CN64System * System ); static void PauseExecution ( void ); @@ -86,11 +84,6 @@ extern enum SystemType g_SystemType; extern DWORD g_RdramSize; -//Misc -enum { NoOfFrames = 7 }; -extern DWORD g_CurrentFrame; -extern QWORD g_Frequency, g_Frames[NoOfFrames], g_LastFrame; - #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/Source/Project64/N64 System/C Core/C Core.h b/Source/Project64/N64 System/C Core/C Core.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/Source/Project64/N64 System/C Core/C Global Variable.h b/Source/Project64/N64 System/C Core/C Global Variable.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/Source/Project64/N64 System/C Core/C Memory.cpp b/Source/Project64/N64 System/C Core/C Memory.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/Source/Project64/N64 System/C Core/C Memory.h b/Source/Project64/N64 System/C Core/C Memory.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/Source/Project64/N64 System/C Core/CPU Log.cpp b/Source/Project64/N64 System/C Core/CPU Log.cpp index 9854b5577..613a50033 100644 --- a/Source/Project64/N64 System/C Core/CPU Log.cpp +++ b/Source/Project64/N64 System/C Core/CPU Log.cpp @@ -1,3 +1,5 @@ +#include "stdafx.h" + /* * Project 64 - A Nintendo 64 emulator. * diff --git a/Source/Project64/N64 System/C Core/CPU.cpp b/Source/Project64/N64 System/C Core/CPU.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/Source/Project64/N64 System/C Core/CPU.h b/Source/Project64/N64 System/C Core/CPU.h index 11f89f452..6b5a172d1 100644 --- a/Source/Project64/N64 System/C Core/CPU.h +++ b/Source/Project64/N64 System/C Core/CPU.h @@ -1,58 +1,19 @@ #include #include "Plugin.h" -#include "c core.h" -#include "C Global Variable.h" #include "..\\Types.h" -#include "Interpreter CPU.h" -#include "Recompiler CPU.h" -#include "c memory.h" -#include "Registers.h" -#include "Exception.h" #include "r4300i Commands.h" -#include "TLB.h" #include "DMA.h" #include "eeprom.h" #include "sram.h" #include "flashram.h" #include "mempak.h" #include "pif.h" -#include "Sync Cpu.h" -//extern int NextInstruction/*, ManualPaused*/; extern DWORD JumpToLocation; extern BOOL TestTimer; -/*#define MaxTimers 5 -#define CompareTimer 0 -#define SiTimer 1 -#define PiTimer 2 -#define ViTimer 3 -#define RspTimer 4 - -typedef struct { - int NextTimer[MaxTimers]; - BOOL Active[MaxTimers]; - int CurrentTimerType; - int Timer; -} SYSTEM_TIMERS; - -extern SYSTEM_TIMERS Timers;*/ -//extern DWORD MemoryStack; - -/*extern BOOL HaveDebugger, AutoLoadMapFile, - AutoStart, - AutoSleep, UseIni, RomBrowser, - IgnoreMove, Rercursion, ShowCPUPer, AutoZip, - AutoFullScreen, SystemABL, AlwaysOnTop, BasicMode, RememberCheats,AudioSignal; - -void ChangeCompareTimer ( void ); -void CheckTimer ( void ); -void TimerDone ( void ); -void DoSomething ( void ); -*/ - int DelaySlotEffectsCompare ( DWORD PC, DWORD Reg1, DWORD Reg2 ); int DelaySlotEffectsJump (DWORD JumpPC); void InPermLoop ( void ); diff --git a/Source/Project64/N64 System/C Core/Debugger.h b/Source/Project64/N64 System/C Core/Debugger.h index 4a633e283..9e940e484 100644 --- a/Source/Project64/N64 System/C Core/Debugger.h +++ b/Source/Project64/N64 System/C Core/Debugger.h @@ -29,7 +29,6 @@ #include "BreakPoints.h" #include "R4300i Registers.h" #include "R4300i Memory.h" -#include "TLB Display.h" #include "Logging.h" //#include "Reverse Code.h" diff --git a/Source/Project64/N64 System/C Core/Exception.cpp b/Source/Project64/N64 System/C Core/Exception.cpp index ebefa138b..b3f0df1ae 100644 --- a/Source/Project64/N64 System/C Core/Exception.cpp +++ b/Source/Project64/N64 System/C Core/Exception.cpp @@ -27,4 +27,3 @@ #include "main.h" #include "cpu.h" #include "plugin.h" -#include "stdafx.h" \ No newline at end of file diff --git a/Source/Project64/N64 System/C Core/Exception.h b/Source/Project64/N64 System/C Core/Exception.h deleted file mode 100644 index 4ec8c9990..000000000 --- a/Source/Project64/N64 System/C Core/Exception.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifdef toremove -/* - * Project 64 - A Nintendo 64 emulator. - * - * (c) Copyright 2001 zilmar (zilmar@emulation64.com) and - * Jabo (jabo@emulation64.com). - * - * pj64 homepage: www.pj64.net - * - * Permission to use, copy, modify and distribute Project64 in both binary and - * source form, for non-commercial purposes, is hereby granted without fee, - * providing that this license information and copyright notice appear with - * all copies and any derived work. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event shall the authors be held liable for any damages - * arising from the use of this software. - * - * Project64 is freeware for PERSONAL USE only. Commercial users should - * seek permission of the copyright holders first. Commercial use includes - * charging money for Project64 or software derived from Project64. - * - * The copyright holders request that bug fixes and improvements to the code - * should be forwarded to them so if they want them. - * - */ -#define EXC_CODE(x) ((x)<<2) -#define EXC_INT EXC_CODE(0) /* interrupt */ -#define EXC_MOD EXC_CODE(1) /* TLB mod */ -#define EXC_RMISS EXC_CODE(2) /* Read TLB Miss */ -#define EXC_WMISS EXC_CODE(3) /* Write TLB Miss */ -#define EXC_RADE EXC_CODE(4) /* Read Address Error */ -#define EXC_WADE EXC_CODE(5) /* Write Address Error */ -#define EXC_IBE EXC_CODE(6) /* Instruction Bus Error */ -#define EXC_DBE EXC_CODE(7) /* Data Bus Error */ -#define EXC_SYSCALL EXC_CODE(8) /* SYSCALL */ -#define EXC_BREAK EXC_CODE(9) /* BREAKpoint */ -#define EXC_II EXC_CODE(10)/* Illegal Instruction */ -#define EXC_CPU EXC_CODE(11)/* CoProcessor Unusable */ -#define EXC_OV EXC_CODE(12)/* OVerflow */ -#define EXC_TRAP EXC_CODE(13)/* Trap exception */ -#define EXC_VCEI EXC_CODE(14)/* Virt. Coherency on Inst. fetch */ -#define EXC_FPE EXC_CODE(15)/* Floating Point Exception */ -#define EXC_WATCH EXC_CODE(23)/* Watchpoint reference */ -#define EXC_VCED EXC_CODE(31)/* Virt. Coherency on data read */ - -#define Exception_Name(Except)\ - (Except) == EXC_INT ? "interrupt" :\ - (Except) == EXC_MOD ? "TLB mod" :\ - (Except) == EXC_RMISS ? "Read TLB Miss" :\ - (Except) == EXC_WMISS ? "Write TLB Miss" :\ - (Except) == EXC_RADE ? "Read Address Error" :\ - (Except) == EXC_WADE ? "Write Address Error" :\ - (Except) == EXC_IBE ? "Instruction Bus Error" :\ - (Except) == EXC_DBE ? "Data Bus Error" :\ - (Except) == EXC_SYSCALL ? "SYSCALL" :\ - (Except) == EXC_BREAK ? "Break" :\ - (Except) == EXC_II ? "Illegal Instruction" :\ - (Except) == EXC_CPU ? "CoProcessor Unusable" :\ - (Except) == EXC_OV ? "OVerflow" :\ - (Except) == EXC_TRAP ? "Trap exception" :\ - (Except) == EXC_VCEI ? "Virt. Coherency on Inst. fetch" :\ - (Except) == EXC_FPE ? "Floating Point Exception" :\ - (Except) == EXC_WATCH ? "Watchpoint reference" :\ - (Except) == EXC_VCED ? "Virt. Coherency on data read" :\ - "Unkown" - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef __cplusplus -} -#endif - -#endif \ No newline at end of file diff --git a/Source/Project64/N64 System/C Core/FlashRam.c b/Source/Project64/N64 System/C Core/FlashRam.c deleted file mode 100644 index 433fc0f3f..000000000 --- a/Source/Project64/N64 System/C Core/FlashRam.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Project 64 - A Nintendo 64 emulator. - * - * (c) Copyright 2001 zilmar (zilmar@emulation64.com) and - * Jabo (jabo@emulation64.com). - * - * pj64 homepage: www.pj64.net - * - * Permission to use, copy, modify and distribute Project64 in both binary and - * source form, for non-commercial purposes, is hereby granted without fee, - * providing that this license information and copyright notice appear with - * all copies and any derived work. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event shall the authors be held liable for any damages - * arising from the use of this software. - * - * Project64 is freeware for PERSONAL USE only. Commercial users should - * seek permission of the copyright holders first. Commercial use includes - * charging money for Project64 or software derived from Project64. - * - * The copyright holders request that bug fixes and improvements to the code - * should be forwarded to them so if they want them. - * - */ - -#include -#include -#include "main.h" -#include "CPU.h" - -typedef enum TFlashRam_Modes { - FLASHRAM_MODE_NOPES = 0, - FLASHRAM_MODE_ERASE = 1, - FLASHRAM_MODE_WRITE, - FLASHRAM_MODE_READ, - FLASHRAM_MODE_STATUS, -}; - -BOOL LoadFlashram (void); - -DWORD FlashRAM_Offset, FlashFlag = FLASHRAM_MODE_NOPES; -static HANDLE hFlashRamFile = NULL; -BYTE * FlashRamPointer; -QWORD FlashStatus = 0; - -void CloseFlashRam ( void) -{ - if (hFlashRamFile) { - CloseHandle(hFlashRamFile); - hFlashRamFile = NULL; - } -} - -void DmaFromFlashram(BYTE * dest, int StartOffset, int len) { - BYTE FlipBuffer[0x10000]; - DWORD dwRead, count; - - switch (FlashFlag) { - case FLASHRAM_MODE_READ: - if (hFlashRamFile == NULL) { - if (!LoadFlashram()) { return; } - } - if (len > 0x10000) { -#ifndef EXTERNAL_RELEASE - DisplayError("DmaFromFlashram FlipBuffer to small (len: %d)",len); -#endif - len = 0x10000; - } - if ((len & 3) != 0) { -#ifndef EXTERNAL_RELEASE - DisplayError("Unaligned flash ram read ???"); -#endif - return; - } - memset(FlipBuffer,0,sizeof(FlipBuffer)); - StartOffset = StartOffset << 1; - SetFilePointer(hFlashRamFile,StartOffset,NULL,FILE_BEGIN); - ReadFile(hFlashRamFile,FlipBuffer,len,&dwRead,NULL); - for (count = dwRead; (int)count < len; count ++) { - FlipBuffer[count] = 0xFF; - } - _asm { - mov edi, dest - lea ecx, [FlipBuffer] - mov edx, 0 - mov ebx, len - - memcpyloop: - mov eax, dword ptr [ecx + edx] - ;bswap eax - mov dword ptr [edi + edx],eax - add edx, 4 - cmp edx, ebx - jb memcpyloop - } - break; - case FLASHRAM_MODE_STATUS: - if (StartOffset != 0 && len != 8) { -#ifndef EXTERNAL_RELEASE - DisplayError("Reading flashstatus not being handled correctly\nStart: %X len: %X",StartOffset,len); -#endif - } - *((DWORD *)(dest)) = (DWORD)(FlashStatus >> 32); - *((DWORD *)(dest) + 1) = (DWORD)(FlashStatus); - break; -#ifndef EXTERNAL_RELEASE - default: - DisplayError("DmaFromFlashram Start: %X, Offset: %X len: %X",dest - N64MEM,StartOffset,len); -#endif - } -} - -void DmaToFlashram(BYTE * Source, int StartOffset, int len) { - switch (FlashFlag) { - case FLASHRAM_MODE_WRITE: - FlashRamPointer = Source; - break; -#ifndef EXTERNAL_RELEASE - default: - DisplayError("DmaToFlashram Start: %X, Offset: %X len: %X",Source - N64MEM,StartOffset,len); -#endif - } -} - -DWORD ReadFromFlashStatus (DWORD PAddr) { - switch (PAddr) { - case 0x08000000: return (DWORD)(FlashStatus >> 32); - default: -#ifndef EXTERNAL_RELEASE - DisplayError("Reading from flash ram status (%X)",PAddr); -#endif - break; - } - return (DWORD)(FlashStatus >> 32); -} - -BOOL LoadFlashram (void) { - char File[255], Directory[255]; - - GetAutoSaveDir(Directory); - sprintf(File,"%s%s.fla",Directory,RomName); - - hFlashRamFile = CreateFile(File,GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ,NULL,OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); - if (hFlashRamFile == INVALID_HANDLE_VALUE) { - switch (GetLastError()) { - case ERROR_PATH_NOT_FOUND: - CreateDirectory(Directory,NULL); - hFlashRamFile = CreateFile(File,GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ, - NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL); - if (hFlashRamFile == INVALID_HANDLE_VALUE) { - DisplayError(GS(MSG_FAIL_OPEN_FLASH)); - return FALSE; - } - break; - default: - DisplayError(GS(MSG_FAIL_OPEN_FLASH)); - return FALSE; - } - } - return TRUE; -} - -void WriteToFlashCommand(DWORD FlashRAM_Command) { - BYTE EmptyBlock[128]; - DWORD dwWritten; - - switch (FlashRAM_Command & 0xFF000000) { - case 0xD2000000: - switch (FlashFlag) { - case FLASHRAM_MODE_NOPES: break; - case FLASHRAM_MODE_READ: break; - case FLASHRAM_MODE_STATUS: break; - case FLASHRAM_MODE_ERASE: - memset(EmptyBlock,0xFF,sizeof(EmptyBlock)); - if (hFlashRamFile == NULL) { - if (!LoadFlashram()) { return; } - } - SetFilePointer(hFlashRamFile,FlashRAM_Offset,NULL,FILE_BEGIN); - WriteFile(hFlashRamFile,EmptyBlock,128,&dwWritten,NULL); - break; - case FLASHRAM_MODE_WRITE: - if (hFlashRamFile == NULL) { - if (!LoadFlashram()) { return; } - } - { - BYTE FlipBuffer[128]; - DWORD dwWritten; - - memset(FlipBuffer,0,sizeof(FlipBuffer)); - _asm { - lea edi, [FlipBuffer] - mov ecx, FlashRamPointer - mov edx, 0 - - memcpyloop: - mov eax, dword ptr [ecx + edx] - ;bswap eax - mov dword ptr [edi + edx],eax - add edx, 4 - cmp edx, 128 - jb memcpyloop - } - - SetFilePointer(hFlashRamFile,FlashRAM_Offset,NULL,FILE_BEGIN); - WriteFile(hFlashRamFile,FlipBuffer,128,&dwWritten,NULL); - } - break; - default: - DisplayError("Writing %X to flash ram command register\nFlashFlag: %d",FlashRAM_Command,FlashFlag); - } - FlashFlag = FLASHRAM_MODE_NOPES; - break; - case 0xE1000000: - FlashFlag = FLASHRAM_MODE_STATUS; - FlashStatus = 0x1111800100C20000; - break; - case 0xF0000000: - FlashFlag = FLASHRAM_MODE_READ; - FlashStatus = 0x11118004F0000000; - break; - case 0x4B000000: - FlashRAM_Offset = (FlashRAM_Command & 0xffff) * 128; - break; - case 0x78000000: - FlashFlag = FLASHRAM_MODE_ERASE; - FlashStatus = 0x1111800800C20000; - break; - case 0xB4000000: - FlashFlag = FLASHRAM_MODE_WRITE; //???? - break; - case 0xA5000000: - FlashRAM_Offset = (FlashRAM_Command & 0xffff) * 128; - FlashStatus = 0x1111800400C20000; - break; -#ifndef EXTERNAL_RELEASE - default: - DisplayError("Writing %X to flash ram command register",FlashRAM_Command); -#endif - } -} - diff --git a/Source/Project64/N64 System/C Core/Interpreter CPU.cpp b/Source/Project64/N64 System/C Core/Interpreter CPU.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/Source/Project64/N64 System/C Core/Interpreter CPU.h b/Source/Project64/N64 System/C Core/Interpreter CPU.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/Source/Project64/N64 System/C Core/Main.h b/Source/Project64/N64 System/C Core/Main.h index d99b47ea3..5ea5944be 100644 --- a/Source/Project64/N64 System/C Core/Main.h +++ b/Source/Project64/N64 System/C Core/Main.h @@ -30,7 +30,6 @@ #include "..\N64 Types.h" #include "..\\Types.h" #include "plugin.h" -#include "c core.h" #include "..\\..\\Multilanguage.h" #include "win32Timer.h" diff --git a/Source/Project64/N64 System/C Core/Plugin.h b/Source/Project64/N64 System/C Core/Plugin.h deleted file mode 100644 index 9021972f3..000000000 --- a/Source/Project64/N64 System/C Core/Plugin.h +++ /dev/null @@ -1,403 +0,0 @@ -#ifdef toremove -/* - * Project 64 - A Nintendo 64 emulator. - * - * (c) Copyright 2001 zilmar (zilmar@emulation64.com) and - * Jabo (jabo@emulation64.com). - * - * pj64 homepage: www.pj64.net - * - * Permission to use, copy, modify and distribute Project64 in both binary and - * source form, for non-commercial purposes, is hereby granted without fee, - * providing that this license information and copyright notice appear with - * all copies and any derived work. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event shall the authors be held liable for any damages - * arising from the use of this software. - * - * Project64 is freeware for PERSONAL USE only. Commercial users should - * seek permission of the copyright holders first. Commercial use includes - * charging money for Project64 or software derived from Project64. - * - * The copyright holders request that bug fixes and improvements to the code - * should be forwarded to them so if they want them. - * - */ -#ifndef __PLUGIN_C_H__ -#define __PLUGIN_C_H__ - -#include - - - /* -#define DefaultGFXDll "Jabo_Direct3D8.dll" -#define DefaultRSPDll "RSP.dll" -#define DefaultAudioDll "Jabo_Dsound.dll" -#define DefaultControllerDll "Jabo_DInput.dll" - -#define PLUGIN_TYPE_RSP 1 -#define PLUGIN_TYPE_GFX 2 -#define PLUGIN_TYPE_AUDIO 3 -#define PLUGIN_TYPE_CONTROLLER 4 -*/ - -//#define SYSTEM_NTSC 0 -//#define SYSTEM_PAL 1 -//#define SYSTEM_MPAL 2 - -#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 */ - - /* 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 */ -} PLUGIN_INFO; - -#endif - -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 - - 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; - - DWORD * 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; - - 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; - - void (__cdecl *CheckInterrupts)( void ); -} GFX_INFO; - -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; - - DWORD * 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; - - 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; - - void ( __cdecl *CheckInterrupts)( void ); - void (__cdecl *ProcessDlist)( void ); - void (__cdecl *ProcessAlist)( void ); - void (__cdecl *ProcessRdpList)( void ); -} RSP_INFO_1_0; - -#ifndef CONTROL_STRUCTS -#define CONTROL_STRUCTS - -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; - - signed Y_AXIS : 8; - - signed X_AXIS : 8; - }; -} BUTTONS; - -typedef struct { - BOOL Present; - BOOL RawData; - int Plugin; -} CONTROL; - -#endif - -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; - -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; - - DWORD * 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; - - 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; - - void ( __cdecl *CheckInterrupts)( void ); - void (__cdecl *ProcessDlist)( void ); - void (__cdecl *ProcessAlist)( void ); - void (__cdecl *ProcessRdpList)( void ); - void (__cdecl *ShowCFB)( void ); -} RSP_INFO_1_1; - -typedef struct { - /* Menu */ - /* Items should have an ID between 5001 and 5100 */ - HMENU hRSPMenu; - void (__cdecl *ProcessMenuItem) ( int ID ); - - /* Break Points */ - BOOL UseBPoints; - char BPPanelName[20]; - void (__cdecl *Add_BPoint) ( void ); - void (__cdecl *CreateBPPanel) ( HWND hDlg, RECT rcBox ); - void (__cdecl *HideBPPanel) ( void ); - void (__cdecl *PaintBPPanel) ( PAINTSTRUCT ps ); - void (__cdecl *ShowBPPanel) ( void ); - void (__cdecl *RefreshBpoints) ( HWND hList ); - void (__cdecl *RemoveBpoint) ( HWND hList, int index ); - void (__cdecl *RemoveAllBpoint) ( void ); - - /* RSP command Window */ - void (__cdecl *Enter_RSP_Commands_Window) ( void ); -} RSPDEBUG_INFO; - -typedef struct { - /* Menu */ - /* Items should have an ID between 5101 and 5200 */ - HMENU hGFXMenu; - void (__cdecl *ProcessMenuItem) ( int ID ); - - /* Break Points */ - BOOL UseBPoints; - char BPPanelName[20]; - void (__cdecl *Add_BPoint) ( void ); - void (__cdecl *CreateBPPanel) ( HWND hDlg, RECT rcBox ); - void (__cdecl *HideBPPanel) ( void ); - void (__cdecl *PaintBPPanel) ( PAINTSTRUCT ps ); - void (__cdecl *ShowBPPanel) ( void ); - void (__cdecl *RefreshBpoints) ( HWND hList ); - void (__cdecl *RemoveBpoint) ( HWND hList, int index ); - void (__cdecl *RemoveAllBpoint) ( void ); - - /* 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 { - 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; - - DWORD * MI__INTR_REG; - - 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; - - void (__cdecl *CheckInterrupts)( void ); -} AUDIO_INFO; - -/*** Conteroller plugin's ****/ -#ifndef __cplusplus -#define PLUGIN_NONE 1 -#define PLUGIN_MEMPAK 2 -#define PLUGIN_RUMBLE_PAK 3 -#define PLUGIN_TANSFER_PAK 4 // not implemeted for non raw data -#define PLUGIN_RAW 5 // the controller plugin is passed in raw data -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/******** All DLLs have this function **************/ -extern void (__cdecl *GetDllInfo) ( PLUGIN_INFO * PluginInfo ); - -/********** RSP DLL: Functions *********************/ -//void (__cdecl *GetRspDebugInfo) ( RSPDEBUG_INFO * DebugInfo ); -//extern void (__cdecl *RSPCloseDLL) ( void ); -//extern void (__cdecl *RSPDllAbout) ( HWND hWnd ); -//extern void (__cdecl *RSPDllConfig) ( HWND hWnd ); -//extern void (__cdecl *RSPRomClosed) ( void ); -extern DWORD (__cdecl *DoRspCycles) ( DWORD ); -//extern void (__cdecl *InitiateRSP_1_0) ( RSP_INFO_1_0 Rsp_Info, DWORD * Cycles); -//extern void (__cdecl *InitiateRSP_1_1) ( RSP_INFO_1_1 Rsp_Info, DWORD * Cycles); -//extern void (__cdecl *InitiateRSPDebugger)( DEBUG_INFO DebugInfo); - -/********** GFX DLL: Functions *********************/ -extern void (__cdecl *CaptureScreen) ( const char * ); -extern void (__cdecl *ChangeWindow) ( void ); -//extern void (__cdecl *GetGfxDebugInfo) ( GFXDEBUG_INFO * GFXDebugInfo ); -//extern void (__cdecl *GFXCloseDLL) ( void ); -//extern void (__cdecl *GFXDllAbout) ( HWND hParent ); -//extern void (__cdecl *GFXDllConfig) ( HWND hParent ); -//extern void (__cdecl *GfxRomClosed) ( void ); -//extern void (__cdecl *GfxRomOpen) ( void ); -extern void (__cdecl *DrawScreen) ( void ); -//extern void (__cdecl *FrameBufferRead) ( DWORD addr ); -//extern void (__cdecl *FrameBufferWrite) ( DWORD addr, DWORD Bytes ); -//BOOL (__cdecl *InitiateGFX) ( GFX_INFO Gfx_Info ); -//extern void (__cdecl *InitiateGFXDebugger)( DEBUG_INFO DebugInfo); -extern void (__cdecl *MoveScreen) ( int xpos, int ypos ); -extern void (__cdecl *ProcessDList) ( void ); -extern void (__cdecl *ProcessRDPList) ( void ); -extern void (__cdecl *ShowCFB) ( void ); -extern void (__cdecl *UpdateScreen) ( void ); -extern void (__cdecl *ViStatusChanged) ( void ); -extern void (__cdecl *ViWidthChanged) ( void ); - -/************ Audio DLL: Functions *****************/ -//extern void (__cdecl *AiCloseDLL) ( void ); -//extern void (__cdecl *AiDacrateChanged) ( int SystemType ); -extern void (__cdecl *AiLenChanged) ( void ); -//extern void (__cdecl *AiDllAbout) ( HWND hParent ); -//extern void (__cdecl *AiDllConfig) ( HWND hParent ); -//extern void (__cdecl *AiDllTest) ( HWND hParent ); -extern DWORD (__cdecl *AiReadLength) ( void ); -//extern void (__cdecl *AiRomClosed) ( void ); -//extern void (__cdecl *AiUpdate) ( BOOL Wait ); -//extern BOOL (__cdecl *InitiateAudio) ( AUDIO_INFO Audio_Info ); -extern void (__cdecl *ProcessAList) ( void ); - -/********** Controller DLL: Functions **************/ -extern void (__cdecl *ControllerCommand)( int Control, BYTE * Command ); -extern void (__cdecl *GetKeys) ( int Control, BUTTONS * Keys ); -extern void (__cdecl *ReadController) ( int Control, BYTE * Command ); -extern void (__cdecl *RumbleCommand) ( int Control, BOOL bRumble ); - -#ifdef __cplusplus -} -#endif -#endif - -/********** Plugin: Functions *********************/ -void GetPluginDir ( char * Directory ); -void GetSnapShotDir ( char * Directory ); -void PluginConfiguration ( HWND hWnd ); -void SetupPlugins ( HWND hWnd ); -void SetupPluginScreen ( HWND hDlg ); -void ShutdownPlugins ( void ); - -/********** External Global Variables ***************/ -#define MaxDlls 100 -extern char RspDLL[100], GfxDLL[100], AudioDLL[100],ControllerDLL[100], * PluginNames[MaxDlls]; -extern DWORD PluginCount, RspTaskValue; -extern GFXDEBUG_INFO GFXDebug; -extern RSPDEBUG_INFO RspDebug; -extern WORD RSPVersion; -extern BOOL PluginsInitilized; - -#endif diff --git a/Source/Project64/N64 System/C Core/Recompiler CPU.cpp b/Source/Project64/N64 System/C Core/Recompiler CPU.cpp deleted file mode 100644 index 53bacf05b..000000000 --- a/Source/Project64/N64 System/C Core/Recompiler CPU.cpp +++ /dev/null @@ -1,385 +0,0 @@ -/* - * Project 64 - A Nintendo 64 emulator. - * - * (c) Copyright 2001 zilmar (zilmar@emulation64.com) and - * Jabo (jabo@emulation64.com). - * - * pj64 homepage: www.pj64.net - * - * Permission to use, copy, modify and distribute Project64 in both binary and - * source form, for non-commercial purposes, is hereby granted without fee, - * providing that this license information and copyright notice appear with - * all copies and any derived work. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event shall the authors be held liable for any damages - * arising from the use of this software. - * - * Project64 is freeware for PERSONAL USE only. Commercial users should - * seek permission of the copyright holders first. Commercial use includes - * charging money for Project64 or software derived from Project64. - * - * The copyright holders request that bug fixes and improvements to the code - * should be forwarded to them so if they want them. - * - */ -#ifdef tofix -#include -#include -#include -#include "c core.h" -#include "main.h" -#include "C Global Variable.h" -#include "cpu.h" -#include "x86.h" -#include "debugger.h" -#include "plugin.h" -#include "Recompiler CPU.h" - -N64_BLOCKS N64_Blocks; -DWORD TLBLoadAddress, TLBStoreAddress; - -void FixRandomReg (void) { - while ((int)_CP0[1] < (int)_CP0[6]) { - _CP0[1] += 32 - _CP0[6]; - } -} - - - -BOOL DisplaySectionInformation (BLOCK_SECTION * Section, DWORD ID, DWORD Test); -BLOCK_SECTION * ExistingSection(BLOCK_SECTION * StartSection, DWORD Addr, DWORD Test); -void _fastcall FillSectionInfo(BLOCK_SECTION * Section); -void _fastcall FixConstants ( BLOCK_SECTION * Section, DWORD Test,int * Changed ); -BOOL GenerateX86Code (BLOCK_SECTION * Section, DWORD Test ); -DWORD GetNewTestValue( void ); -void _fastcall InheritConstants(BLOCK_SECTION * Section); -BOOL InheritParentInfo (BLOCK_SECTION * Section); -void _fastcall InitilzeSection(BLOCK_SECTION * Section, BLOCK_SECTION * Parent, DWORD StartAddr, DWORD ID); -void InitilizeRegSet(REG_INFO * RegSet); -BOOL IsAllParentLoops(BLOCK_SECTION * Section, BLOCK_SECTION * Parent, BOOL IgnoreIfCompiled, DWORD Test); -void MarkCodeBlock (DWORD PAddr); -void SyncRegState (BLOCK_SECTION * Section, REG_INFO * SyncTo); - -DWORD TLBLoadAddress, TargetIndex; -TARGET_INFO * TargetInfo = NULL; -BLOCK_INFO BlockInfo; -ORIGINAL_MEMMARKER * OrigMem = NULL; - - -void InitilizeInitialCompilerVariable ( void) -{ - memset(&BlockInfo,0,sizeof(BlockInfo)); -} - -void _fastcall AddParent(BLOCK_SECTION * Section, BLOCK_SECTION * Parent){ - int NoOfParents, count; - - - if (Section == NULL) { return; } - if (Parent == NULL) { - InitilizeRegSet(&Section->RegStart); - memcpy(&Section->RegWorking,&Section->RegStart,sizeof(REG_INFO)); - return; - } - - if (Section->ParentSection != NULL) { - for (NoOfParents = 0;Section->ParentSection[NoOfParents] != NULL;NoOfParents++) { - if (Section->ParentSection[NoOfParents] == Parent) { - return; - } - } - for (NoOfParents = 0;Section->ParentSection[NoOfParents] != NULL;NoOfParents++); - NoOfParents += 1; - } else { - NoOfParents = 1; - } - - if (NoOfParents == 1) { - Section->ParentSection = (void **)malloc((NoOfParents + 1)*sizeof(void *)); - } else { - Section->ParentSection = (void **)realloc(Section->ParentSection,(NoOfParents + 1)*sizeof(void *)); - } - Section->ParentSection[NoOfParents - 1] = Parent; - Section->ParentSection[NoOfParents] = NULL; - - if (NoOfParents == 1) { - if (Parent->ContinueSection == Section) { - memcpy(&Section->RegStart,&Parent->Cont.RegSet,sizeof(REG_INFO)); - } else if (Parent->JumpSection == Section) { - memcpy(&Section->RegStart,&Parent->Jump.RegSet,sizeof(REG_INFO)); - } else { -#ifndef EXTERNAL_RELEASE - DisplayError("How are these sections joined?????"); -#endif - } - memcpy(&Section->RegWorking,&Section->RegStart,sizeof(REG_INFO)); - } else { - if (Parent->ContinueSection == Section) { - for (count = 0; count < 32; count++) { - if (Section->RegStart.MIPS_RegState[count] != Parent->Cont.RegSet.MIPS_RegState[count]) { - Section->RegStart.MIPS_RegState[count] = STATE_UNKNOWN; - } - } - } - if (Parent->JumpSection == Section) { - for (count = 0; count < 32; count++) { - if (Section->RegStart.MIPS_RegState[count] != Parent->Jump.RegSet.MIPS_RegState[count]) { - Section->RegStart.MIPS_RegState[count] = STATE_UNKNOWN; - } - } - } - memcpy(&Section->RegWorking,&Section->RegStart,sizeof(REG_INFO)); - } -} - -void _fastcall DetermineLoop(BLOCK_SECTION * Section, DWORD Test, DWORD Test2, DWORD TestID) { - if (Section == NULL) { return; } - if (Section->SectionID != TestID) { - if (Section->Test2 == Test2) { - return; - } - Section->Test2 = Test2; - DetermineLoop((BLOCK_SECTION *)Section->ContinueSection,Test,Test2,TestID); - DetermineLoop((BLOCK_SECTION *)Section->JumpSection,Test,Test2,TestID); - return; - } - if (Section->Test2 == Test2) { - Section->InLoop = TRUE; - return; - } - Section->Test2 = Test2; - DetermineLoop((BLOCK_SECTION *)Section->ContinueSection,Test,Test2,TestID); - DetermineLoop((BLOCK_SECTION *)Section->JumpSection,Test,Test2,TestID); - if (Section->Test == Test) { return; } - Section->Test = Test; - if (Section->ContinueSection != NULL) { - DetermineLoop((BLOCK_SECTION *)Section->ContinueSection,Test,GetNewTestValue(),((BLOCK_SECTION *)Section->ContinueSection)->SectionID); - } - if (Section->JumpSection != NULL) { - DetermineLoop((BLOCK_SECTION *)Section->JumpSection,Test,GetNewTestValue(),((BLOCK_SECTION *)Section->JumpSection)->SectionID); - } -} - -void _fastcall FixConstants (BLOCK_SECTION * Section, DWORD Test, int * Changed) { - BLOCK_SECTION * Parent; - int count, NoOfParents; - REG_INFO Original[2]; - - if (Section == NULL) { return; } - if (Section->Test == Test) { return; } - Section->Test = Test; - - InheritConstants(Section); - - memcpy(&Original[0],&Section->Cont.RegSet,sizeof(REG_INFO)); - memcpy(&Original[1],&Section->Jump.RegSet,sizeof(REG_INFO)); - - if (Section->ParentSection) { - for (NoOfParents = 0;Section->ParentSection[NoOfParents] != NULL;NoOfParents++) { - Parent = (BLOCK_SECTION *)Section->ParentSection[NoOfParents]; - if (Parent->ContinueSection == Section) { - for (count = 0; count < 32; count++) { - if (Section->RegStart.MIPS_RegState[count] != Parent->Cont.RegSet.MIPS_RegState[count]) { - Section->RegStart.MIPS_RegState[count] = STATE_UNKNOWN; - //*Changed = TRUE; - } - Section->RegStart.MIPS_RegState[count] = STATE_UNKNOWN; - } - } - if (Parent->JumpSection == Section) { - for (count = 0; count < 32; count++) { - if (Section->RegStart.MIPS_RegState[count] != Parent->Jump.RegSet.MIPS_RegState[count]) { - Section->RegStart.MIPS_RegState[count] = STATE_UNKNOWN; - //*Changed = TRUE; - } - } - } - memcpy(&Section->RegWorking,&Section->RegStart,sizeof(REG_INFO)); - } - } - FillSectionInfo(Section); - if (memcmp(&Original[0],&Section->Cont.RegSet,sizeof(REG_INFO)) != 0) { *Changed = TRUE; } - if (memcmp(&Original[1],&Section->Jump.RegSet,sizeof(REG_INFO)) != 0) { *Changed = TRUE; } - - if (Section->JumpSection) { FixConstants((BLOCK_SECTION *)Section->JumpSection,Test,Changed); } - if (Section->ContinueSection) { FixConstants((BLOCK_SECTION *)Section->ContinueSection,Test,Changed); } -} - -void FreeSection (BLOCK_SECTION * Section, BLOCK_SECTION * Parent) { - if (Section == NULL) { return; } - - if (Section->ParentSection) { - int NoOfParents, count; - - for (NoOfParents = 0;Section->ParentSection[NoOfParents] != NULL;NoOfParents++); - - for (count = 0; count < NoOfParents; count++) { - if (Section->ParentSection[count] == Parent) { - if (NoOfParents == 1) { - free(Section->ParentSection); - //CPU_Message("Free Parent Section (Section: %d)",Section->SectionID); - Section->ParentSection = NULL; - } else { - memmove(&Section->ParentSection[count],&Section->ParentSection[count + 1], - sizeof(void*) * (NoOfParents - count)); - Section->ParentSection = (void **)realloc(Section->ParentSection,NoOfParents*sizeof(void *)); - } - NoOfParents -= 1; - } - } - - if (Parent->JumpSection == Section) { Parent->JumpSection = NULL; } - if (Parent->ContinueSection == Section) { Parent->ContinueSection = NULL; } - - if (Section->ParentSection) { - for (count = 0; count < NoOfParents; count++) { - if (!IsAllParentLoops(Section,(BLOCK_SECTION *)Section->ParentSection[count],FALSE,GetNewTestValue())) { return; } - } - for (count = 0; count < NoOfParents; count++) { - Parent = (BLOCK_SECTION *)Section->ParentSection[count]; - if (Parent->JumpSection == Section) { Parent->JumpSection = NULL; } - if (Parent->ContinueSection == Section) { Parent->ContinueSection = NULL; } - } - free(Section->ParentSection); - //CPU_Message("Free Parent Section (Section: %d)",Section->SectionID); - Section->ParentSection = NULL; - } - } - if (Section->ParentSection == NULL) { - FreeSection((BLOCK_SECTION *)Section->JumpSection,Section); - FreeSection((BLOCK_SECTION *)Section->ContinueSection,Section); - //CPU_Message("Free Section (Section: %d)",Section->SectionID); - free(Section); - } -} - -void GenerateBasicSectionLinkage (BLOCK_SECTION * Section) { - BreakPoint(__FILE__,__LINE__); -} - -DWORD GetNewTestValue(void) { - static DWORD LastTest = 0; - if (LastTest == 0xFFFFFFFF) { LastTest = 0; } - LastTest += 1; - return LastTest; -} - -void InitilizeRegSet(REG_INFO * RegSet) { - int count; - - RegSet->MIPS_RegState[0] = STATE_CONST_32; - RegSet->MIPS_RegVal[0].DW = 0; - for (count = 1; count < 32; count ++ ) { - RegSet->MIPS_RegState[count] = STATE_UNKNOWN; - RegSet->MIPS_RegVal[count].DW = 0; - - } - for (count = 0; count < 10; count ++ ) { - RegSet->x86reg_MappedTo[count] = NotMapped; - RegSet->x86reg_Protected[count] = FALSE; - RegSet->x86reg_MapOrder[count] = 0; - } - RegSet->CycleCount = 0; - RegSet->RandomModifier = 0; - - RegSet->Stack_TopPos = 0; - for (count = 0; count < 8; count ++ ) { - RegSet->x86fpu_MappedTo[count] = -1; - RegSet->x86fpu_State[count] = FPU_Unkown; - RegSet->x86fpu_RoundingModel[count] = RoundDefault; - } - RegSet->Fpu_Used = FALSE; - RegSet->RoundingModel = RoundUnknown; -} - -void _fastcall InheritConstants(BLOCK_SECTION * Section) { - int NoOfParents, count; - BLOCK_SECTION * Parent; - REG_INFO * RegSet; - - - if (Section->ParentSection == NULL) { - InitilizeRegSet(&Section->RegStart); - memcpy(&Section->RegWorking,&Section->RegStart,sizeof(REG_INFO)); - return; - } - - Parent = (BLOCK_SECTION *)Section->ParentSection[0]; - RegSet = Section == Parent->ContinueSection?&Parent->Cont.RegSet:&Parent->Jump.RegSet; - memcpy(&Section->RegStart,RegSet,sizeof(REG_INFO)); - memcpy(&Section->RegWorking,&Section->RegStart,sizeof(REG_INFO)); - - for (NoOfParents = 1;Section->ParentSection[NoOfParents] != NULL;NoOfParents++) { - Parent = (BLOCK_SECTION *)Section->ParentSection[NoOfParents]; - RegSet = Section == Parent->ContinueSection?&Parent->Cont.RegSet:&Parent->Jump.RegSet; - - for (count = 0; count < 32; count++) { - if (IsConst(count)) { - if (MipsRegState(count) != RegSet->MIPS_RegState[count]) { - MipsRegState(count) = STATE_UNKNOWN; - } else if (Is32Bit(count) && MipsRegLo(count) != RegSet->MIPS_RegVal[count].UW[0]) { - MipsRegState(count) = STATE_UNKNOWN; - } else if (Is64Bit(count) && MipsReg(count) != RegSet->MIPS_RegVal[count].UDW) { - MipsRegState(count) = STATE_UNKNOWN; - } - } - } - } - memcpy(&Section->RegStart,&Section->RegWorking,sizeof(REG_INFO)); -} - - -void _fastcall InitilzeSection (BLOCK_SECTION * Section, BLOCK_SECTION * Parent, DWORD StartAddr, DWORD ID) { - Section->ParentSection = NULL; - Section->JumpSection = NULL; - Section->ContinueSection = NULL; - Section->CompiledLocation = NULL; - - Section->SectionID = ID; - Section->Test = 0; - Section->Test2 = 0; - Section->InLoop = FALSE; - - Section->StartPC = StartAddr; - Section->CompilePC = Section->StartPC; - - Section->Jump.BranchLabel = NULL; - Section->Jump.LinkLocation = NULL; - Section->Jump.LinkLocation2 = NULL; - Section->Jump.FallThrough = FALSE; - Section->Jump.PermLoop = FALSE; - Section->Jump.TargetPC = (DWORD)-1; - Section->Cont.BranchLabel = NULL; - Section->Cont.LinkLocation = NULL; - Section->Cont.LinkLocation2 = NULL; - Section->Cont.FallThrough = FALSE; - Section->Cont.PermLoop = FALSE; - Section->Cont.TargetPC = (DWORD)-1; - - AddParent(Section,Parent); -} - -void MarkCodeBlock (DWORD PAddr) { - if (PAddr < RdramSize) { - N64_Blocks.NoOfRDRamBlocks[PAddr >> 12] += 1; - } else if (PAddr >= 0x04000000 && PAddr <= 0x04000FFC) { - N64_Blocks.NoOfDMEMBlocks += 1; - } else if (PAddr >= 0x04001000 && PAddr <= 0x04001FFC) { - N64_Blocks.NoOfIMEMBlocks += 1; - } else if (PAddr >= 0x1FC00000 && PAddr <= 0x1FC00800) { - N64_Blocks.NoOfPifRomBlocks += 1; - } else { -#ifndef ROM_IN_MAPSPACE -#ifndef EXTERNAL_RELEASE - DisplayError("Ummm... Which code block should be marked on\nPC = 0x%08X\nRdramSize: %X",PAddr,RdramSize); -#endif - ExitThread(0); -#endif - } -} - - - - -#endif \ No newline at end of file diff --git a/Source/Project64/N64 System/C Core/Recompiler CPU.h b/Source/Project64/N64 System/C Core/Recompiler CPU.h deleted file mode 100644 index d857d8b62..000000000 --- a/Source/Project64/N64 System/C Core/Recompiler CPU.h +++ /dev/null @@ -1,246 +0,0 @@ -#ifdef toremove -/* - * Project 64 - A Nintendo 64 emulator. - * - * (c) Copyright 2001 zilmar (zilmar@emulation64.com) and - * Jabo (jabo@emulation64.com). - * - * pj64 homepage: www.pj64.net - * - * Permission to use, copy, modify and distribute Project64 in both binary and - * source form, for non-commercial purposes, is hereby granted without fee, - * providing that this license information and copyright notice appear with - * all copies and any derived work. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event shall the authors be held liable for any damages - * arising from the use of this software. - * - * Project64 is freeware for PERSONAL USE only. Commercial users should - * seek permission of the copyright holders first. Commercial use includes - * charging money for Project64 or software derived from Project64. - * - * The copyright holders request that bug fixes and improvements to the code - * should be forwarded to them so if they want them. - * - */ -#ifndef _RECOMPILER_CPU__H_ -#define _RECOMPILER_CPU__H_ - - -#define MaxCodeBlocks 50000 -#define MaxOrigMem 65000 - -#ifdef toremove - -#define NotMapped 0 -#define GPR_Mapped 1 -#define Temp_Mapped 2 -#define Stack_Mapped 3 - -//Exit Block Methods -#define Normal 0 -#define Normal_NoSysCheck 1 -#define DoCPU_Action 2 -#define COP1_Unuseable 3 -#define DoSysCall 4 -#define TLBReadMiss 5 -#define ExitResetRecompCode 6 - - -#define BranchTypeCop1 0 -#define BranchTypeRs 1 -#define BranchTypeRsRt 2 - -#define STATE_KNOWN_VALUE 1 -//#define STATE_UNKNOW_VALUE - -#define STATE_X86_MAPPED 2 -//#define STATE_CONST - -#define STATE_SIGN 4 -//#define STATE_ZERO - -#define STATE_32BIT 8 -//#define STATE_64BIT - -#define STATE_UNKNOWN 0 - -//STATE_MAPPED_64 = 3; -//STATE_MAPPED_32_ZERO = 11 -//STATE_MAPPED_32_SIGN = 15 -#define STATE_MAPPED_64 (STATE_KNOWN_VALUE | STATE_X86_MAPPED) -#define STATE_MAPPED_32_ZERO (STATE_KNOWN_VALUE | STATE_X86_MAPPED | STATE_32BIT) -#define STATE_MAPPED_32_SIGN (STATE_KNOWN_VALUE | STATE_X86_MAPPED | STATE_32BIT | STATE_SIGN) - -//STATE_CONST_64 = 1 -//STATE_CONST_32 = 13 -#define STATE_CONST_64 (STATE_KNOWN_VALUE) -#define STATE_CONST_32 (STATE_KNOWN_VALUE | STATE_32BIT | STATE_SIGN) - -#define IsKnown(Reg) ((MipsRegState(Reg) & STATE_KNOWN_VALUE) != 0) -#define IsUnknown(Reg) (!IsKnown(Reg)) - -#define IsMapped(Reg) (IsKnown(Reg) && (MipsRegState(Reg) & STATE_X86_MAPPED) != 0) -#define IsConst(Reg) (IsKnown(Reg) && !IsMapped(Reg)) - -#define IsSigned(Reg) (IsKnown(Reg) && (MipsRegState(Reg) & STATE_SIGN) != 0) -#define IsUnsigned(Reg) (IsKnown(Reg) && !IsSigned(Reg)) - -#define Is32Bit(Reg) (IsKnown(Reg) && (MipsRegState(Reg) & STATE_32BIT) != 0) -#define Is64Bit(Reg) (IsKnown(Reg) && !Is32Bit(Reg)) - -#define Is32BitMapped(Reg) (Is32Bit(Reg) && (MipsRegState(Reg) & STATE_X86_MAPPED) != 0) -#define Is64BitMapped(Reg) (Is64Bit(Reg) && !Is32BitMapped(Reg)) - -/*#define MipsRegState(Reg) Section->RegWorking.MIPS_RegState[Reg] -#define MipsReg(Reg) Section->RegWorking.MIPS_RegVal[Reg].UDW -#define MipsReg_S(Reg) Section->RegWorking.MIPS_RegVal[Reg].DW -#define MipsRegLo(Reg) Section->RegWorking.MIPS_RegVal[Reg].UW[0] -#define MipsRegLo_S(Reg) Section->RegWorking.MIPS_RegVal[Reg].W[0] -#define MipsRegHi(Reg) Section->RegWorking.MIPS_RegVal[Reg].UW[1] -#define MipsRegHi_S(Reg) Section->RegWorking.MIPS_RegVal[Reg].W[1] -#define x86MapOrder(Reg) Section->RegWorking.x86reg_MapOrder[Reg] -#define x86Protected(Reg) Section->RegWorking.x86reg_Protected[Reg] -#define x86Mapped(Reg) Section->RegWorking.x86reg_MappedTo[Reg] -*/ - -#define BlockCycleCount Section->RegWorking.CycleCount -#define BlockRandomModifier Section->RegWorking.RandomModifier - - -#define StackTopPos Section->RegWorking.Stack_TopPos -#define FpuMappedTo(Reg) Section->RegWorking.x86fpu_MappedTo[Reg] -#define FpuState(Reg) Section->RegWorking.x86fpu_State[Reg] -#define FpuRoundingModel(Reg) Section->RegWorking.x86fpu_RoundingModel[Reg] -#define FpuBeenUsed Section->RegWorking.Fpu_Used -#define CurrentRoundingModel Section->RegWorking.RoundingModel - -typedef struct { - //r4k - int MIPS_RegState[32]; - MIPS_DWORD MIPS_RegVal[32]; - - DWORD x86reg_MappedTo[10]; - DWORD x86reg_MapOrder[10]; - BOOL x86reg_Protected[10]; - - DWORD CycleCount; - DWORD RandomModifier; - - //FPU - DWORD Stack_TopPos; - DWORD x86fpu_MappedTo[8]; - DWORD x86fpu_State[8]; - DWORD x86fpu_RoundingModel[8]; - - BOOL Fpu_Used; - DWORD RoundingModel; -} REG_INFO; - -typedef struct { - DWORD TargetPC; - char * BranchLabel; - BYTE * LinkLocation; - BYTE * LinkLocation2; - BOOL FallThrough; - BOOL PermLoop; - BOOL DoneDelaySlot; - REG_INFO RegSet; -} JUMP_INFO; - -typedef struct { - /* Block Connection info */ - void ** ParentSection; - void * ContinueSection; - void * JumpSection; - BYTE * CompiledLocation; - - - DWORD SectionID; - DWORD Test; - DWORD Test2; - BOOL InLoop; - - DWORD StartPC; - DWORD CompilePC; - - /* Register Info */ - REG_INFO RegStart; - REG_INFO RegWorking; - - /* Jump Info */ - JUMP_INFO Jump; - JUMP_INFO Cont; -} BLOCK_SECTION; - -typedef struct { - BLOCK_SECTION * Parent; - JUMP_INFO * JumpInfo; -} BLOCK_PARENT; - -typedef struct { - DWORD TargetPC; - REG_INFO ExitRegSet; - int reason; - int NextInstruction; - BYTE * JumpLoc; //32bit jump -} EXIT_INFO; - -typedef struct { - DWORD StartVAddr; - BYTE * CompiledLocation; - int NoOfSections; - BLOCK_SECTION BlockInfo; - EXIT_INFO ** ExitInfo; - int ExitCount; -} BLOCK_INFO; -#endif - -typedef struct { - void * CodeBlock; - QWORD OriginalMemory; -} TARGET_INFO; - -typedef struct { - DWORD PAddr; - DWORD VAddr; - DWORD OriginalValue; - void * CompiledLocation; -} ORIGINAL_MEMMARKER; - -typedef struct { - DWORD NoOfRDRamBlocks[2048]; - DWORD NoOfDMEMBlocks; - DWORD NoOfIMEMBlocks; - DWORD NoOfPifRomBlocks; -} N64_BLOCKS; - -#ifdef __cplusplus - -//void CompileSystemCheck ( DWORD TargetPC, CRegInfo RegSet ); -//void FreeSection ( CCodeSection * Section, CCodeSection * Parent); -void GenerateSectionLinkage ( CCodeSection * Section ); - -extern "C" { -#endif - -BYTE *CompileDelaySlot ( void ); -void FixRandomReg ( void ); -void StartRecompilerCPU ( void ); -void InitilizeInitialCompilerVariable ( void); - -extern DWORD TLBLoadAddress, TLBStoreAddress, TargetIndex; -extern ORIGINAL_MEMMARKER * OrigMem; -extern TARGET_INFO * TargetInfo; -extern N64_BLOCKS N64_Blocks; - -#ifdef __cplusplus -} -#endif - -//#define SetJump32(Loc,JumpLoc) *(DWORD *)(Loc)= (DWORD)(((DWORD)(JumpLoc)) - (((DWORD)(Loc)) + 4)); -//#define SetJump8(Loc,JumpLoc) *(BYTE *)(Loc)= (BYTE )(((BYTE )(JumpLoc)) - (((BYTE )(Loc)) + 1)); - -#endif -#endif \ No newline at end of file diff --git a/Source/Project64/N64 System/C Core/Recompiler Fpu Ops.cpp b/Source/Project64/N64 System/C Core/Recompiler Fpu Ops.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/Source/Project64/N64 System/C Core/Recompiler Ops.cpp b/Source/Project64/N64 System/C Core/Recompiler Ops.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/Source/Project64/N64 System/C Core/Recompiler Ops.h b/Source/Project64/N64 System/C Core/Recompiler Ops.h deleted file mode 100644 index 7a583bd1d..000000000 --- a/Source/Project64/N64 System/C Core/Recompiler Ops.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Project 64 - A Nintendo 64 emulator. - * - * (c) Copyright 2001 zilmar (zilmar@emulation64.com) and - * Jabo (jabo@emulation64.com). - * - * pj64 homepage: www.pj64.net - * - * Permission to use, copy, modify and distribute Project64 in both binary and - * source form, for non-commercial purposes, is hereby granted without fee, - * providing that this license information and copyright notice appear with - * all copies and any derived work. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event shall the authors be held liable for any damages - * arising from the use of this software. - * - * Project64 is freeware for PERSONAL USE only. Commercial users should - * seek permission of the copyright holders first. Commercial use includes - * charging money for Project64 or software derived from Project64. - * - * The copyright holders request that bug fixes and improvements to the code - * should be forwarded to them so if they want them. - * - */ - diff --git a/Source/Project64/N64 System/C Core/Registers.cpp b/Source/Project64/N64 System/C Core/Registers.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/Source/Project64/N64 System/C Core/Registers.h b/Source/Project64/N64 System/C Core/Registers.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/Source/Project64/N64 System/C Core/Sync CPU.c b/Source/Project64/N64 System/C Core/Sync CPU.c deleted file mode 100644 index 32577a888..000000000 --- a/Source/Project64/N64 System/C Core/Sync CPU.c +++ /dev/null @@ -1,660 +0,0 @@ -/* - * Project 64 - A Nintendo 64 emulator. - * - * (c) Copyright 2001 zilmar (zilmar@emulation64.com) and - * Jabo (jabo@emulation64.com). - * - * pj64 homepage: www.pj64.net - * - * Permission to use, copy, modify and distribute Project64 in both binary and - * source form, for non-commercial purposes, is hereby granted without fee, - * providing that this license information and copyright notice appear with - * all copies and any derived work. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event shall the authors be held liable for any damages - * arising from the use of this software. - * - * Project64 is freeware for PERSONAL USE only. Commercial users should - * seek permission of the copyright holders first. Commercial use includes - * charging money for Project64 or software derived from Project64. - * - * The copyright holders request that bug fixes and improvements to the code - * should be forwarded to them so if they want them. - * - */ -#ifdef todelete - -#include -#include -#include "main.h" -#include "cpu.h" -#include "debugger.h" -#include "plugin.h" - -#define MaxMemory 2000 - -void StartErrorLog ( void ); -void StopErrorLog ( void ); -void WriteSyncMemoryLineDump ( char * Label, BYTE * Memory ); - -DWORD CurrentBlock, *TLB_SyncReadMap, *TLB_SyncWriteMap, * MemAddrUsed[2] = { NULL,NULL }; -int SyncNextInstruction, SyncJumpToLocation; -HANDLE hErrorLogFile = NULL; -N64_REGISTERS SyncRegisters; -int MemAddrUsedCount[2]; -BYTE * SyncMemory; - -#ifdef toremove -//TLB -//FASTTLB SyncFastTlb[64]; -//TLB SyncTlb[32]; -#endif - -int Sync_MemoryFilter( DWORD dwExptCode, LPEXCEPTION_POINTERS lpEP); - -void AllocateSyncMemory ( void ) { - DWORD * TempReadMap, *TempWriteMap; - BYTE * TempMemPtr; - FreeSyncMemory(); - - if(SyncMemory==NULL) { - DisplayError(GS(MSG_MEM_ALLOC_ERROR)); - ExitThread(0); - } - - if(VirtualAlloc(SyncMemory, RdramSize, MEM_COMMIT, PAGE_READWRITE)==NULL) { - DisplayError(GS(MSG_MEM_ALLOC_ERROR)); - ExitThread(0); - } - - if(VirtualAlloc(SyncMemory + 0x04000000, 0x2000, MEM_COMMIT, PAGE_READWRITE)==NULL) { - DisplayError(GS(MSG_MEM_ALLOC_ERROR)); - ExitThread(0); - } - - TLB_SyncReadMap = (DWORD *)VirtualAlloc(NULL,0xFFFFF * sizeof(DWORD),MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE); - if (TLB_SyncReadMap == NULL) { - DisplayError(GS(MSG_MEM_ALLOC_ERROR)); - ExitThread(0); - } - - TLB_SyncWriteMap = (DWORD *)VirtualAlloc(NULL,0xFFFFF * sizeof(DWORD),MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE); - if (TLB_SyncWriteMap == NULL) { - DisplayError(GS(MSG_MEM_ALLOC_ERROR)); - ExitThread(0); - } - - MemAddrUsed[0] = (DWORD *)malloc(MaxMemory * sizeof(DWORD *)); - MemAddrUsed[1] = (DWORD *)malloc(MaxMemory * sizeof(DWORD *)); - - TempReadMap = TLB_ReadMap; - TLB_ReadMap = TLB_SyncReadMap; - TLB_SyncReadMap = TempReadMap; - - TempWriteMap = TLB_WriteMap; - TLB_WriteMap = TLB_SyncWriteMap; - TLB_SyncWriteMap = TempWriteMap; - - TempMemPtr = N64MEM; - N64MEM = SyncMemory; - RDRAM = (unsigned char *)(N64MEM); - DMEM = (unsigned char *)(N64MEM+0x04000000); - IMEM = (unsigned char *)(N64MEM+0x04001000); - SyncMemory = TempMemPtr; - - InitilizeTLB(); - memcpy(SyncFastTlb,FastTlb,sizeof(FastTlb)); - memcpy(SyncTlb,tlb,sizeof(tlb)); -} - -void __cdecl Error_Message (char * Message, ...) { - DWORD dwWritten; - char Msg[400]; - va_list ap; - - if (hErrorLogFile == NULL) { StartErrorLog(); } - va_start( ap, Message ); - vsprintf( Msg, Message, ap ); - va_end( ap ); - - strcat(Msg,"\r\n"); - - WriteFile( hErrorLogFile,Msg,strlen(Msg),&dwWritten,NULL ); -} - -void FreeSyncMemory (void) { - if (TLB_SyncReadMap) { - VirtualFree( TLB_SyncReadMap, 0 , MEM_RELEASE); - TLB_SyncReadMap = NULL; - } - if (TLB_SyncWriteMap) { - VirtualFree( TLB_SyncWriteMap, 0 , MEM_RELEASE); - TLB_SyncWriteMap = NULL; - } - if (MemAddrUsed[0]) { free(MemAddrUsed[0]); } - MemAddrUsed[0] = NULL; - if (MemAddrUsed[1]) { free(MemAddrUsed[1]); } - MemAddrUsed[1] = NULL; -} - -void ProtectMemory (void) { - DWORD OldProtect; - - VirtualProtect(N64MEM,RdramSize,PAGE_READONLY,&OldProtect); - VirtualProtect(N64MEM + 0x04000000,0x2000,PAGE_READONLY,&OldProtect); -} - -void ReInitializeRSP (void) { -#ifdef hhhh - RSP_INFO_1_0 RspInfo10; - RSP_INFO_1_1 RspInfo11; - - RspInfo10.CheckInterrupts = CheckInterrupts; - RspInfo11.CheckInterrupts = CheckInterrupts; - RspInfo10.ProcessDlist = ProcessDList; - RspInfo11.ProcessDlist = ProcessDList; - RspInfo10.ProcessAlist = ProcessAList; - RspInfo11.ProcessAlist = ProcessAList; - RspInfo10.ProcessRdpList = ProcessRDPList; - RspInfo11.ProcessRdpList = ProcessRDPList; - RspInfo11.ShowCFB = ShowCFB; - - RspInfo10.hInst = hInst; - RspInfo11.hInst = hInst; - RspInfo10.RDRAM = N64MEM; - RspInfo11.RDRAM = N64MEM; - RspInfo10.DMEM = DMEM; - RspInfo11.DMEM = DMEM; - RspInfo10.IMEM = IMEM; - RspInfo11.IMEM = IMEM; - RspInfo10.MemoryBswaped = FALSE; - RspInfo11.MemoryBswaped = FALSE; - - RspInfo10.MI__INTR_REG = &MI_INTR_REG; - RspInfo11.MI__INTR_REG = &MI_INTR_REG; - - RspInfo10.SP__MEM_ADDR_REG = &SP_MEM_ADDR_REG; - RspInfo11.SP__MEM_ADDR_REG = &SP_MEM_ADDR_REG; - RspInfo10.SP__DRAM_ADDR_REG = &SP_DRAM_ADDR_REG; - RspInfo11.SP__DRAM_ADDR_REG = &SP_DRAM_ADDR_REG; - RspInfo10.SP__RD_LEN_REG = &SP_RD_LEN_REG; - RspInfo11.SP__RD_LEN_REG = &SP_RD_LEN_REG; - RspInfo10.SP__WR_LEN_REG = &SP_WR_LEN_REG; - RspInfo11.SP__WR_LEN_REG = &SP_WR_LEN_REG; - RspInfo10.SP__STATUS_REG = &SP_STATUS_REG; - RspInfo11.SP__STATUS_REG = &SP_STATUS_REG; - RspInfo10.SP__DMA_FULL_REG = &SP_DMA_FULL_REG; - RspInfo11.SP__DMA_FULL_REG = &SP_DMA_FULL_REG; - RspInfo10.SP__DMA_BUSY_REG = &SP_DMA_BUSY_REG; - RspInfo11.SP__DMA_BUSY_REG = &SP_DMA_BUSY_REG; - RspInfo10.SP__PC_REG = &SP_PC_REG; - RspInfo11.SP__PC_REG = &SP_PC_REG; - RspInfo10.SP__SEMAPHORE_REG = &SP_SEMAPHORE_REG; - RspInfo11.SP__SEMAPHORE_REG = &SP_SEMAPHORE_REG; - - RspInfo10.DPC__START_REG = &DPC_START_REG; - RspInfo11.DPC__START_REG = &DPC_START_REG; - RspInfo10.DPC__END_REG = &DPC_END_REG; - RspInfo11.DPC__END_REG = &DPC_END_REG; - RspInfo10.DPC__CURRENT_REG = &DPC_CURRENT_REG; - RspInfo11.DPC__CURRENT_REG = &DPC_CURRENT_REG; - RspInfo10.DPC__STATUS_REG = &DPC_STATUS_REG; - RspInfo11.DPC__STATUS_REG = &DPC_STATUS_REG; - RspInfo10.DPC__CLOCK_REG = &DPC_CLOCK_REG; - RspInfo11.DPC__CLOCK_REG = &DPC_CLOCK_REG; - RspInfo10.DPC__BUFBUSY_REG = &DPC_BUFBUSY_REG; - RspInfo11.DPC__BUFBUSY_REG = &DPC_BUFBUSY_REG; - RspInfo10.DPC__PIPEBUSY_REG = &DPC_PIPEBUSY_REG; - RspInfo11.DPC__PIPEBUSY_REG = &DPC_PIPEBUSY_REG; - RspInfo10.DPC__TMEM_REG = &DPC_TMEM_REG; - RspInfo11.DPC__TMEM_REG = &DPC_TMEM_REG; - - if (RSPVersion == 0x0100) { InitiateRSP_1_0(RspInfo10, &RspTaskValue); } - if (RSPVersion == 0x0101) { InitiateRSP_1_1(RspInfo11, &RspTaskValue); } -#else -BreakPoint(__FILE__,__LINE__); -#endif -} - -void StartErrorLog (void) { -#ifdef ggg - char path_buffer[_MAX_PATH], drive[_MAX_DRIVE] ,dir[_MAX_DIR]; - char fname[_MAX_FNAME],ext[_MAX_EXT], LogFileName[_MAX_PATH]; - - GetModuleFileName(NULL,path_buffer,sizeof(path_buffer)); - _splitpath( path_buffer, drive, dir, fname, ext ); - _makepath( LogFileName, drive, dir, "CPU Error", "log" ); - - hErrorLogFile = CreateFile(LogFileName,GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,NULL, - CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL); - SetFilePointer(hErrorLogFile,0,NULL,FILE_BEGIN); - - Error_Message("=== Error Has occured !?! ==="); - Error_Message("Block Address: 0x%X",CurrentBlock); - if (PROGRAM_COUNTER != Registers.PROGRAM_COUNTER) { - Error_Message("interp PC: 0x%08X",PROGRAM_COUNTER); - Error_Message("Recomp PC: 0x%08X",Registers.PROGRAM_COUNTER); - } else { - Error_Message("PC: 0x%08X",PROGRAM_COUNTER); - } - Error_Message(""); -#else - BreakPoint(__FILE__,__LINE__); -#endif -} - -#ifdef todelete -void StartSyncCPU (void ) { -#ifdef hhh - DWORD Addr; - BYTE * Block; -#ifdef Log_x86Code - Start_x86_Log(); -#endif - - ResetRecompCode(); - AllocateSyncMemory(); - Registers.PROGRAM_COUNTER = PROGRAM_COUNTER; - Registers.HI.DW = HI.DW; - Registers.LO.DW = LO.DW; - Registers.DMAUsed = DMAUsed; - memcpy(&SyncRegisters,&Registers,sizeof(Registers)); - memcpy(N64MEM,SyncMemory,RdramSize); - memcpy(N64MEM + 0x04000000,SyncMemory + 0x04000000,0x2000); - ProtectMemory(); - SyncNextInstruction = NORMAL; - SyncJumpToLocation = -1; - __try { - for (;;) { - Addr = PROGRAM_COUNTER; - if (UseTlb) { - if (!TranslateVaddr(&Addr)) { - DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER); - NextInstruction = NORMAL; - Addr = PROGRAM_COUNTER; - if (!TranslateVaddr(&Addr)) { - DisplayError("Failed to tranlate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER); - ExitThread(0); - } - } - } else { - Addr &= 0x1FFFFFFF; - } - if (NextInstruction == DELAY_SLOT) { - __try { - Block = *(DelaySlotTable + (Addr >> 12)); - } __except(EXCEPTION_EXECUTE_HANDLER) { - DisplayError("Executing Delay Slot from non maped space"); - ExitThread(0); - } - if (Block == NULL) { - Block = CompileDelaySlot(); - *(DelaySlotTable + (Addr >> 12)) = Block; - NextInstruction = NORMAL; - } - _asm { - pushad - call Block - popad - } - continue; - } - __try { - Block = *(JumpTable + (Addr >> 2)); - } __except(EXCEPTION_EXECUTE_HANDLER) { - DisplayError(GS(MSG_NONMAPPED_SPACE)); - ExitThread(0); - } - if (Block == NULL) { - __try { - Block = Compiler4300iBlock(); - } __except(EXCEPTION_EXECUTE_HANDLER) { - DisplayError("Reset Recompiler Code"); - //ResetRecompCode(); - //Block = Compiler4300iBlock(); - } - *(JumpTable + (Addr >> 2)) = Block; - NextInstruction = NORMAL; - } - _asm { - pushad - call Block - popad - } - } - } __except( Sync_MemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) { - DisplayError(GS(MSG_UNKNOWN_MEM_ACTION)); - ExitThread(0); - } -#else - BreakPoint(__FILE__,__LINE__); -#endif -} -#endif - -void StopErrorLog (void) { - if (hErrorLogFile) { - CloseHandle(hErrorLogFile); - hErrorLogFile = NULL; - } -} - -void SwitchSyncRegisters (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix - FASTTLB TempFastTlb[64]; - TLB Temptlb[32]; - BYTE * TempMemPtr; - DWORD * Temp; - - if (GPR == Registers.GPR) { - Registers.PROGRAM_COUNTER = PROGRAM_COUNTER; - Registers.HI.DW = HI.DW; - Registers.LO.DW = LO.DW; - Registers.DMAUsed = DMAUsed; - SetupRegisters(&SyncRegisters); - } else { - SyncRegisters.PROGRAM_COUNTER = PROGRAM_COUNTER; - SyncRegisters.HI.DW = HI.DW; - SyncRegisters.LO.DW = LO.DW; - SyncRegisters.DMAUsed = DMAUsed; - SetupRegisters(&Registers); - } - - Temp = MemAddrUsed[1]; - MemAddrUsed[1] = MemAddrUsed[0]; - MemAddrUsed[0] = Temp; - MemAddrUsedCount[1] = MemAddrUsedCount[0]; - MemAddrUsedCount[0] = 0; - - memcpy(TempFastTlb,FastTlb,sizeof(FastTlb)); - memcpy(FastTlb,SyncFastTlb,sizeof(FastTlb)); - memcpy(SyncFastTlb,TempFastTlb,sizeof(FastTlb)); - - memcpy(Temptlb,tlb,sizeof(tlb)); - memcpy(tlb,SyncTlb,sizeof(tlb)); - memcpy(SyncTlb,Temptlb,sizeof(tlb)); - - Temp = TLB_ReadMap; - TLB_ReadMap = TLB_SyncReadMap; - TLB_SyncReadMap = Temp; - - Temp = TLB_WriteMap; - TLB_WriteMap = TLB_SyncWriteMap; - TLB_SyncWriteMap = Temp; - - TempMemPtr = N64MEM; - N64MEM = SyncMemory; - RDRAM = (unsigned char *)(N64MEM); - DMEM = (unsigned char *)(N64MEM+0x04000000); - IMEM = (unsigned char *)(N64MEM+0x04001000); - SyncMemory = TempMemPtr; - ReInitializeRSP(); - ProtectMemory(); -#else - BreakPoint(__FILE__,__LINE__); -#endif -} - -/*void SyncSystem (void) { -#ifdef hhhh - int count, i, error; - - error = FALSE; - if (PROGRAM_COUNTER != Registers.PROGRAM_COUNTER) { - error = TRUE; - Error_Message("*** Program counter is not equal!!!"); - Error_Message(""); - } - - //GPR - for (count = 0; count < 32; count ++) { - if (Registers.GPR[count].DW != SyncRegisters.GPR[count].DW) { - error = TRUE; - Error_Message("*** %s (GPR %d) is not equal!!!",GPR_Name[count],count); - Error_Message("interp value: 0x%08X%08X",SyncRegisters.GPR[count].UW[1],SyncRegisters.GPR[count].UW[0]); - Error_Message("Recomp value: 0x%08X%08X",Registers.GPR[count].UW[1],Registers.GPR[count].UW[0]); - Error_Message(""); - } - } - - //COP0 - FixRandomReg(); - for (count = 0; count < 33; count ++) { - if (Registers.CP0[count] != SyncRegisters.CP0[count]) { - error = TRUE; - Error_Message("*** %s (CP0 %d) is not equal!!!",count == 32?"Fake cause":Cop0_Name[count],count); - Error_Message("interp value: 0x%08X",SyncRegisters.CP0[count]); - Error_Message("Recomp value: 0x%08X",Registers.CP0[count]); - Error_Message(""); - } - } - - //FPU - for (count = 0; count < 32; count ++) { - if (Registers.FPR[count].DW != SyncRegisters.FPR[count].DW) { - error = TRUE; - Error_Message("*** %s (FPR %d) is not equal!!!",FPR_Name[count],count); - Error_Message("interp value: 0x%08X%08X",SyncRegisters.FPR[count].UW[1],SyncRegisters.FPR[count].UW[0]); - Error_Message("Recomp value: 0x%08X%08X",Registers.FPR[count].UW[1],Registers.FPR[count].UW[0]); - Error_Message(""); - } - } - - if (Registers.FPCR[31] != SyncRegisters.FPCR[31]) { - error = TRUE; - Error_Message("*** %s is not equal!!!",FPR_Ctrl_Name[31]); - Error_Message("interp value: 0x%08X",SyncRegisters.FPCR[31]); - Error_Message("Recomp value: 0x%08X",Registers.FPCR[31]); - Error_Message(""); - } - //HI - if (Registers.HI.DW != HI.DW) { - error = TRUE; - Error_Message("*** HI register is not equal!!!"); - Error_Message("interp value: 0x%08X",HI.DW); - Error_Message("Recomp value: 0x%08X",Registers.HI.DW); - Error_Message(""); - } - - //LO - if (Registers.LO.DW != LO.DW) { - error = TRUE; - Error_Message("*** LO register is not equal!!!"); - Error_Message("interp value: 0x%08X",LO.DW); - Error_Message("Recomp value: 0x%08X",Registers.LO.DW); - Error_Message(""); - } - - //TLB - for (count = 0; count < 32; count ++) { - if (tlb[count].PageMask.Value != SyncTlb[count].PageMask.Value) { - error = TRUE; - Error_Message("*** tlb[%d].PageMask is not equal!!!",count); - Error_Message("interp value: 0x%08X",SyncTlb[count].PageMask.Value); - Error_Message("Recomp value: 0x%08X",tlb[count].PageMask.Value ); - Error_Message(""); - } - if (tlb[count].EntryHi.Value != SyncTlb[count].EntryHi.Value) { - error = TRUE; - Error_Message("*** tlb[%d].EntryHi is not equal!!!",count); - Error_Message("interp value: 0x%08X",SyncTlb[count].EntryHi.Value); - Error_Message("Recomp value: 0x%08X",tlb[count].EntryHi.Value ); - Error_Message(""); - } - if (tlb[count].EntryLo0.Value != SyncTlb[count].EntryLo0.Value) { - error = TRUE; - Error_Message("*** tlb[%d].PageMask is not equal!!!",count); - Error_Message("interp value: 0x%08X",SyncTlb[count].EntryLo0.Value); - Error_Message("Recomp value: 0x%08X",tlb[count].EntryLo0.Value ); - Error_Message(""); - } - if (tlb[count].EntryLo1.Value != SyncTlb[count].EntryLo1.Value) { - error = TRUE; - Error_Message("*** tlb[%d].PageMask is not equal!!!",count); - Error_Message("interp value: 0x%08X",SyncTlb[count].EntryLo1.Value); - Error_Message("Recomp value: 0x%08X",tlb[count].EntryLo1.Value ); - Error_Message(""); - } - } - - //Mips Interface - for (count = 0; count < 4; count ++) { - if (Registers.MI[count] != SyncRegisters.MI[count]) { - error = TRUE; - Error_Message("*** MI %d is not equal!!!",count); - Error_Message("interp value: 0x%08X",SyncRegisters.MI[count]); - Error_Message("Recomp value: 0x%08X",Registers.MI[count]); - Error_Message(""); - } - } - - //PI Interface - for (count = 0; count < 12; count ++) { - if (Registers.PI[count] != SyncRegisters.PI[count]) { - error = TRUE; - Error_Message("*** PI %d is not equal!!!",count); - Error_Message("interp value: 0x%08X",SyncRegisters.PI[count]); - Error_Message("Recomp value: 0x%08X",Registers.PI[count]); - Error_Message(""); - } - } - - //Memory - for (count = 0; count < MemAddrUsedCount[0]; count ++) { - int count2; - - for (count2 = 0; count2 < MemAddrUsedCount[1]; count2 ++) { - if (MemAddrUsed[0][count] == MemAddrUsed[1][count2]) { - MemAddrUsed[1][count2] = (DWORD)-1; - } - } - } - for (i = 0; i < 2; i++) { - for (count = 0; count < MemAddrUsedCount[i]; count ++) { - DWORD count2; - - if (MemAddrUsed[i][count] == (DWORD)-1) { continue; } - if (memcmp(N64MEM + MemAddrUsed[i][count], SyncMemory + MemAddrUsed[i][count],0xFFF) == 0) { - continue; - } - error = TRUE; - for (count2 = MemAddrUsed[i][count]; count2 < (MemAddrUsed[i][count] + 0x1000); count2 += 0x10) { - if (memcmp(N64MEM + count2, SyncMemory + count2,0x10) == 0) { continue; } - Error_Message("*** Memory (Address: %X) is not equal!!!",count2); - WriteSyncMemoryLineDump("Interp",N64MEM + count2); - WriteSyncMemoryLineDump("Recomp",SyncMemory + count2); - Error_Message(""); - } - } - } - - if (error) { - SwitchSyncRegisters(); - DisplayError("Sync Error has occured see log for details\n\nEmulation Has stoped"); - ExitThread(0); - } -#else - BreakPoint(__FILE__,__LINE__); -#endif -}*/ - -void SyncToPC (void) { - FixRandomReg(); - SyncSystem (); - return; -#ifdef toremove - - { - int RecNextInstruction, RecJumpToLocation; - - //LogMessage("Recompiler (PC: %X count: %X)",PROGRAM_COUNTER,CP0[9]); - RecNextInstruction = NextInstruction; - RecJumpToLocation = JumpToLocation; - NextInstruction = SyncNextInstruction; - JumpToLocation = SyncJumpToLocation; - - SwitchSyncRegisters(); - /*if ((DWORD)RecompPos > 0x609844D8) { - while (PROGRAM_COUNTER != Registers.PROGRAM_COUNTER) { - ExecuteInterpreterOpCode(); - } - } else { - while (CP0[9] != Registers.CP0[9]) { - ExecuteInterpreterOpCode(); - } - }*/ - while (CP0[9] != Registers.CP0[9]) { - ExecuteInterpreterOpCode(); - } - SyncRegisters.MI[2] = Registers.MI[2]; //MI_INTR_REG - SyncRegisters.CP0[32] = Registers.CP0[32]; //FAKE_CAUSE_REGISTER - SyncSystem (); - SwitchSyncRegisters(); - - SyncNextInstruction = NextInstruction; - SyncJumpToLocation = JumpToLocation; - NextInstruction = RecNextInstruction; - JumpToLocation = RecJumpToLocation; - - MemAddrUsedCount[0] = 0; - MemAddrUsedCount[1] = 0; - } -#endif -} - -int Sync_MemoryFilter( DWORD dwExptCode, LPEXCEPTION_POINTERS lpEP) { - DWORD MemAddress = (char *)lpEP->ExceptionRecord->ExceptionInformation[1] - (char *)N64MEM; - EXCEPTION_RECORD exRec; - - if (dwExptCode != EXCEPTION_ACCESS_VIOLATION) { - return EXCEPTION_CONTINUE_SEARCH; - } - exRec = *lpEP->ExceptionRecord; - - if ((int)((char *)lpEP->ExceptionRecord->ExceptionInformation[1] - N64MEM) < 0) { - return EXCEPTION_CONTINUE_SEARCH; - } - if ((int)((char *)lpEP->ExceptionRecord->ExceptionInformation[1] - N64MEM) > 0x1FFFFFFF) { - return EXCEPTION_CONTINUE_SEARCH; - } - - if (MemAddress < RdramSize || (MemAddress >= 0x4000000 && MemAddress < 0x4002000)) { - DWORD OldProtect; - - VirtualProtect(N64MEM+(MemAddress & 0xFFFFF000),0xFFF,PAGE_READWRITE,&OldProtect); - MemAddrUsed[0][MemAddrUsedCount[0]] = (MemAddress & 0xFFFFF000); - MemAddrUsedCount[0] += 1; - if (MemAddrUsedCount[0] == MaxMemory) { - DisplayError("Used up all sync blocks ????"); - ExitThread(0); - } - if (CPU_Type != ModCode_ProtectedMemory) { return EXCEPTION_CONTINUE_EXECUTION; } - } - return r4300i_CPU_MemoryFilter(dwExptCode,lpEP); -} - -void WriteSyncMemoryLineDump (char * Label, BYTE * Memory) { - char Hex[100], Ascii[30]; - DWORD count; - - memset(&Hex,0,sizeof(Hex)); - memset(&Ascii,0,sizeof(Ascii)); - - for (count = 0; count < 0x10; count ++ ) { - if ((count % 4) != 0 || count == 0) { - sprintf(Hex,"%s %02X",Hex,Memory[count]); - } else { - sprintf(Hex,"%s - %02X",Hex,Memory[count]); - } - if (Memory[count] < 30 || Memory[count] > 127) { - strcat(Ascii,"."); - } else { - sprintf(Ascii,"%s%c",Ascii,Memory[count]); - } - } - Error_Message("%s:%s %s",Label,Hex,Ascii); -} - -#endif \ No newline at end of file diff --git a/Source/Project64/N64 System/C Core/Sync CPU.h b/Source/Project64/N64 System/C Core/Sync CPU.h deleted file mode 100644 index d2486d27c..000000000 --- a/Source/Project64/N64 System/C Core/Sync CPU.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Project 64 - A Nintendo 64 emulator. - * - * (c) Copyright 2001 zilmar (zilmar@emulation64.com) and - * Jabo (jabo@emulation64.com). - * - * pj64 homepage: www.pj64.net - * - * Permission to use, copy, modify and distribute Project64 in both binary and - * source form, for non-commercial purposes, is hereby granted without fee, - * providing that this license information and copyright notice appear with - * all copies and any derived work. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event shall the authors be held liable for any damages - * arising from the use of this software. - * - * Project64 is freeware for PERSONAL USE only. Commercial users should - * seek permission of the copyright holders first. Commercial use includes - * charging money for Project64 or software derived from Project64. - * - * The copyright holders request that bug fixes and improvements to the code - * should be forwarded to them so if they want them. - * - */ - -#ifdef todelete -void StartSyncCPU ( void ); -void SwitchSyncRegisters (void); -void SyncToPC ( void ); -void FreeSyncMemory ( void ); - - -extern int SyncNextInstruction, SyncJumpToLocation, MemAddrUsedCount[2]; -extern DWORD CurrentBlock, *TLB_SyncReadMap, *TLB_SyncWriteMap; -extern N64_REGISTERS SyncRegisters; -extern BYTE * SyncMemory; -extern FASTTLB SyncFastTlb[64]; -extern TLB SyncTlb[32]; - -#endif \ No newline at end of file diff --git a/Source/Project64/N64 System/C Core/TLB Display.c b/Source/Project64/N64 System/C Core/TLB Display.c deleted file mode 100644 index 8c93e6455..000000000 --- a/Source/Project64/N64 System/C Core/TLB Display.c +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Project 64 - A Nintendo 64 emulator. - * - * (c) Copyright 2001 zilmar (zilmar@emulation64.com) and - * Jabo (jabo@emulation64.com). - * - * pj64 homepage: www.pj64.net - * - * Permission to use, copy, modify and distribute Project64 in both binary and - * source form, for non-commercial purposes, is hereby granted without fee, - * providing that this license information and copyright notice appear with - * all copies and any derived work. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event shall the authors be held liable for any damages - * arising from the use of this software. - * - * Project64 is freeware for PERSONAL USE only. Commercial users should - * seek permission of the copyright holders first. Commercial use includes - * charging money for Project64 or software derived from Project64. - * - * The copyright holders request that bug fixes and improvements to the code - * should be forwarded to them so if they want them. - * - */ -#ifdef todelete - -#if (!defined(EXTERNAL_RELEASE)) -#include -#include -#include -#include "main.h" -#include "cpu.h" -#include "..\..\User Interface\resource.h" - -LRESULT CALLBACK TLB_Proc (HWND, UINT, WPARAM, LPARAM); -HWND TlbDlg = NULL; - -void Create_TLB_Window ( int Child ) { - if ( Child ) { - DialogBox( GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Debugger_TLB), NULL,(DLGPROC) TLB_Proc ); - TlbDlg = NULL; - } else { - if (TlbDlg == NULL) { - DWORD ThreadID; - - CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)Create_TLB_Window,(LPVOID)TRUE,0, - &ThreadID); - } else { - SetForegroundWindow(TlbDlg); - } - } -} - -void Enter_TLB_Window ( void ) { - if (!HaveDebugger) { return; } - Create_TLB_Window ( FALSE ); -} - -void RefreshTLBWindow (void) { - HWND hList = GetDlgItem(TlbDlg,IDC_LIST); - char Output[100], OldText[100]; - LV_ITEM item, OldItem; - int count; - - if (!TlbDlg) { return; } - for (count = 0; count < 32; count ++) { - sprintf(Output,"0x%02X",count); - item.mask = LVIF_TEXT; - item.iItem = count; - item.pszText = Output; - item.iSubItem = 0; - - OldItem.mask = LVIF_TEXT; - OldItem.iItem = count; - OldItem.pszText = OldText; - OldItem.cchTextMax = sizeof( OldText )-1; - OldItem.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); - } - - 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].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].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); - } - } - - hList = GetDlgItem(TlbDlg,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; - - OldItem.mask = LVIF_TEXT; - OldItem.iItem = count; - OldItem.pszText = OldText; - OldItem.cchTextMax = sizeof( OldText )-1; - OldItem.iSubItem = 0; - - 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) { - 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].VEND - FastTlb[count].VSTART + FastTlb[count].PHYSSTART); - } else { - strcpy(Output,"................"); - } - item.iSubItem = 3; - OldItem.iSubItem = 3; - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) { - ListView_SetItem(hList,&item); - } - } -} - -void SetupTLBWindow (HWND hDlg) { - LV_COLUMN col; - DWORD X, Y; - - 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(hDlg,IDC_LIST), 0, &col); - - col.pszText = "Page Mask"; - col.cx = 90; - col.iSubItem = 1; - ListView_InsertColumn ( GetDlgItem(hDlg,IDC_LIST), 1, &col); - - col.pszText = "Entry Hi"; - col.cx = 90; - col.iSubItem = 2; - ListView_InsertColumn ( GetDlgItem(hDlg,IDC_LIST), 2, &col); - - col.pszText = "Entry Lo0"; - col.cx = 90; - col.iSubItem = 3; - ListView_InsertColumn ( GetDlgItem(hDlg,IDC_LIST), 3, &col); - - col.pszText = "Entry Lo1"; - col.cx = 90; - col.iSubItem = 4; - ListView_InsertColumn ( GetDlgItem(hDlg,IDC_LIST), 4, &col); - - col.pszText = "Index"; - col.cx = 40; - col.iSubItem = 0; - ListView_InsertColumn ( GetDlgItem(hDlg,IDC_LIST2), 0, &col); - - col.pszText = "Valid"; - col.cx = 40; - col.iSubItem = 1; - ListView_InsertColumn ( GetDlgItem(hDlg,IDC_LIST2), 1, &col); - - col.pszText = "Dirty"; - col.cx = 40; - col.iSubItem = 2; - ListView_InsertColumn ( GetDlgItem(hDlg,IDC_LIST2), 2, &col); - - col.pszText = "Rule"; - col.cx = 280; - col.iSubItem = 3; - ListView_InsertColumn ( GetDlgItem(hDlg,IDC_LIST2), 3, &col); - - RefreshTLBWindow(); - SendMessage(GetDlgItem(hDlg,IDC_TLB_ENTRIES),BM_SETCHECK, BST_CHECKED,0); - - if (GetStoredWinPos( "TLB Window", &X, &Y )) { - SetWindowPos(hDlg,NULL,X,Y,0,0, SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW); - } -} - -LRESULT CALLBACK TLB_Proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch (uMsg) { - case WM_INITDIALOG: - TlbDlg = hDlg; - SetupTLBWindow(hDlg); - break; - case WM_MOVE: - StoreCurrentWinPos("TLB Window",hDlg); - break; - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_TLB_ENTRIES: - ShowWindow(GetDlgItem(hDlg,IDC_LIST),SW_SHOW); - ShowWindow(GetDlgItem(hDlg,IDC_LIST2),SW_HIDE); - break; - case IDC_TLB_RULES: - ShowWindow(GetDlgItem(hDlg,IDC_LIST),SW_HIDE); - ShowWindow(GetDlgItem(hDlg,IDC_LIST2),SW_SHOW); - break; - case IDCANCEL: - EndDialog( hDlg, IDCANCEL ); - break; - } - break; - default: - return FALSE; - } - return TRUE; -} -#endif - -#endif \ No newline at end of file diff --git a/Source/Project64/N64 System/C Core/Tlb.c b/Source/Project64/N64 System/C Core/Tlb.c deleted file mode 100644 index e69de29bb..000000000 diff --git a/Source/Project64/N64 System/C Core/Tlb.h b/Source/Project64/N64 System/C Core/Tlb.h deleted file mode 100644 index e905ec5ae..000000000 --- a/Source/Project64/N64 System/C Core/Tlb.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Project 64 - A Nintendo 64 emulator. - * - * (c) Copyright 2001 zilmar (zilmar@emulation64.com) and - * Jabo (jabo@emulation64.com). - * - * pj64 homepage: www.pj64.net - * - * Permission to use, copy, modify and distribute Project64 in both binary and - * source form, for non-commercial purposes, is hereby granted without fee, - * providing that this license information and copyright notice appear with - * all copies and any derived work. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event shall the authors be held liable for any damages - * arising from the use of this software. - * - * Project64 is freeware for PERSONAL USE only. Commercial users should - * seek permission of the copyright holders first. Commercial use includes - * charging money for Project64 or software derived from Project64. - * - * The copyright holders request that bug fixes and improvements to the code - * should be forwarded to them so if they want them. - * - */ - -#ifdef todelete -typedef struct { - BOOL EntryDefined; - union { - unsigned long Value; - unsigned char A[4]; - - struct BreakDownPageMask{ - unsigned zero : 13; - unsigned Mask : 12; - unsigned zero2 : 7; - } ; - - } PageMask; - - union { - unsigned long Value; - unsigned char A[4]; - - struct BreakDownEntryHi { - unsigned ASID : 8; - unsigned Zero : 4; - unsigned G : 1; - unsigned VPN2 : 19; - }; - - } EntryHi; - - union { - unsigned long Value; - unsigned char A[4]; - - struct BreakDownEntryLo0{ - 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 BreakDownEntryLo1{ - unsigned GLOBAL: 1; - unsigned V : 1; - unsigned D : 1; - unsigned C : 3; - unsigned PFN : 20; - unsigned ZERO: 6; - } ; - - } EntryLo1; -} TLB; - -typedef struct { - DWORD VSTART; - DWORD VEND; - DWORD PHYSSTART; - DWORD PHYSEND; - BOOL VALID; - BOOL DIRTY; - BOOL GLOBAL; - BOOL ValidEntry; -} FASTTLB; - -extern FASTTLB FastTlb[64]; -extern TLB tlb[32]; - -BOOL AddressDefined ( DWORD VAddr); -void InitilizeTLB ( void ); -void SetupTLB ( void ); -void TLB_Probe ( void ); -void TLB_Read ( void ); -BOOL TranslateVaddr ( DWORD * Addr); -void _fastcall WriteTLBEntry ( int index ); - -#endif \ No newline at end of file diff --git a/Source/Project64/N64 System/C Core/X86.cpp b/Source/Project64/N64 System/C Core/X86.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/Source/Project64/N64 System/C Core/X86.h b/Source/Project64/N64 System/C Core/X86.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/Source/Project64/N64 System/C Core/r4300i Memory.cpp b/Source/Project64/N64 System/C Core/r4300i Memory.cpp index 52ea145f5..e69de29bb 100644 --- a/Source/Project64/N64 System/C Core/r4300i Memory.cpp +++ b/Source/Project64/N64 System/C Core/r4300i Memory.cpp @@ -1,366 +0,0 @@ -/* - * Project 64 - A Nintendo 64 emulator. - * - * (c) Copyright 2001 zilmar (zilmar@emulation64.com) and - * Jabo (jabo@emulation64.com). - * - * pj64 homepage: www.pj64.net - * - * Permission to use, copy, modify and distribute Project64 in both binary and - * source form, for non-commercial purposes, is hereby granted without fee, - * providing that this license information and copyright notice appear with - * all copies and any derived work. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event shall the authors be held liable for any damages - * arising from the use of this software. - * - * Project64 is freeware for PERSONAL USE only. Commercial users should - * seek permission of the copyright holders first. Commercial use includes - * charging money for Project64 or software derived from Project64. - * - * The copyright holders request that bug fixes and improvements to the code - * should be forwarded to them so if they want them. - * - */ -void __cdecl Refresh_Memory ( void ) { -} - -#ifdef OLD_CODE - -#if (!defined(EXTERNAL_RELEASE)) -#include -#include -#include -#include "main.h" -#include "CPU.h" -#include "debugger.h" -#include "resource.h" - -#define IDC_VADDR 0x100 -#define IDC_PADDR 0x101 -#define IDC_LIST_VIEW 0x102 -#define IDC_SCRL_BAR 0x103 - -void Setup_Memory_Window (HWND hDlg); - -LRESULT CALLBACK Memory_Window_Proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); - -static HWND Memory_Win_hDlg, hAddrEdit, hVAddr, hPAddr, hList, hScrlBar; -static int InMemoryWindow = FALSE; - -void Create_Memory_Window ( int Child ) { - DWORD ThreadID; - if ( Child ) { - InMemoryWindow = TRUE; - DialogBox( hInst, "MEMORY", NULL,(DLGPROC) Memory_Window_Proc ); - InMemoryWindow = FALSE; - } else { - if (!InMemoryWindow) { - CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)Create_Memory_Window, - (LPVOID)TRUE,0, &ThreadID); - } else { - SetForegroundWindow(Memory_Win_hDlg); - } - } -} - -void __cdecl Enter_Memory_Window ( void ) { - if (!HaveDebugger) { return; } - Create_Memory_Window ( FALSE ); -} - -void Insert_MemoryLineDump (unsigned int location, int InsertPos) { - char Output[20], Hex[60], Ascii[20], HexAddOn[15], AsciiAddOn[15], OldText[100]; - LV_ITEM item, OldItem; - int count; - MIPS_WORD word; - - location = location << 4; - item.mask = LVIF_TEXT | LVIF_PARAM; - item.iItem = InsertPos; - item.lParam = location; - sprintf(Output,"0x%08X",location); - item.pszText = Output; - item.iSubItem = 0; - - OldItem.mask = LVIF_TEXT | LVIF_PARAM; - OldItem.iItem = InsertPos; - OldItem.pszText = OldText; - OldItem.cchTextMax = sizeof( OldText )-1; - OldItem.iSubItem = 0; - - if (ListView_GetItemCount(hList) <= InsertPos) { - ListView_InsertItem(hList,&item); - } else { - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) { - ListView_SetItem(hList,&item); - } - } - - sprintf(Hex,"\0"); sprintf(Ascii,"\0"); - - __try { - if ( SendMessage(hVAddr,BM_GETSTATE,0,0) & BST_CHECKED != 0 ) { - for (count = 0; count < 4; count ++) { - if (r4300i_LW_VAddr(location, &word.UW)) { - sprintf(HexAddOn,"%02X %02X %02X %02X",word.UB[3], - word.UB[2],word.UB[1],word.UB[0]); - sprintf(AsciiAddOn,"0x%08X",word.UW); - sprintf(AsciiAddOn,"%c%c%c%c", - word.UB[3]==0 ? ' ':word.UB[3], - word.UB[2]==0 ? ' ':word.UB[2], - word.UB[1]==0 ? ' ':word.UB[1], - word.UB[0]==0 ? ' ':word.UB[0]); - } else { - strcpy(HexAddOn,"** ** ** **"); - strcpy(AsciiAddOn,"****"); - } - if (count != 3) { - strcat(HexAddOn,"-"); - } - strcat(Hex,HexAddOn); - strcat(Ascii,AsciiAddOn); - location += 4; - } - } else { - for (count = 0; count < 4; count ++) { - if (location < 0x1FFFFFFC) { - r4300i_LW_PAddr(location, &word.UW); - sprintf(HexAddOn,"%02X %02X %02X %02X",word.UB[3], - word.UB[2],word.UB[1],word.UB[0]); - sprintf(AsciiAddOn,"0x%08X",word.UW); - sprintf(AsciiAddOn,"%c%c%c%c", - word.UB[3]==0 ? ' ':word.UB[3], - word.UB[2]==0 ? ' ':word.UB[2], - word.UB[1]==0 ? ' ':word.UB[1], - word.UB[0]==0 ? ' ':word.UB[0]); - } else { - strcpy(HexAddOn,"** ** ** **"); - strcpy(AsciiAddOn,"****"); - } - if (count != 3) { - strcat(HexAddOn,"-"); - } - strcat(Hex,HexAddOn); - strcat(Ascii,AsciiAddOn); - location += 4; - } - } - } __except( r4300i_Command_MemoryFilter( GetExceptionCode(), GetExceptionInformation()) ) { - DisplayError(GS(MSG_UNKNOWN_MEM_ACTION)); - PostQuitMessage(0); - } - - - item.mask = LVIF_TEXT; - item.pszText = Hex; - item.iSubItem = 1; - OldItem.mask = LVIF_TEXT; - OldItem.iSubItem = 1; - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) { - ListView_SetItem(hList,&item); - } - item.pszText = Ascii; - item.iSubItem = 2; - OldItem.iSubItem = 2; - ListView_GetItem(hList,&OldItem); - if ( strcmp( item.pszText, OldItem.pszText ) != 0 ) { - ListView_SetItem(hList,&item); - } -} - -LRESULT CALLBACK Memory_Window_Proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - PAINTSTRUCT ps; - RECT rcBox; - - switch (uMsg) { - case WM_INITDIALOG: - Memory_Win_hDlg = hDlg; - Setup_Memory_Window ( hDlg ); - break; - case WM_MOVE: - if (IsIconic(hDlg)) { break; } - StoreCurrentWinPos("Memory",hDlg); - break; - case WM_PAINT: - BeginPaint( hDlg, &ps ); - SelectObject(ps.hdc, GetStockObject(ANSI_FIXED_FONT)); - SetBkMode( ps.hdc, TRANSPARENT ); - TextOut(ps.hdc,25,17,"Address:",8); - rcBox.left = 5; - rcBox.top = 5; - rcBox.right = 666; - rcBox.bottom = 310; - DrawEdge( ps.hdc, &rcBox, EDGE_RAISED, BF_RECT ); - rcBox.left = 8; - rcBox.top = 8; - rcBox.right = 663; - rcBox.bottom = 307; - DrawEdge( ps.hdc, &rcBox, EDGE_ETCHED, BF_RECT ); - EndPaint( hDlg, &ps ); - return TRUE; - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_ADDR_EDIT: - if (HIWORD(wParam) == EN_CHANGE ) { - Refresh_Memory(); - } - break; - case IDC_VADDR: - case IDC_PADDR: - Refresh_Memory(); - break; - case IDC_CLOSE_BUTTON: - case IDCANCEL: - EndDialog( hDlg, IDCANCEL ); - break; - } - case WM_VSCROLL: - if ((HWND)lParam == hScrlBar) { - unsigned int location; - char Value[20]; - - GetWindowText(hAddrEdit,Value,sizeof(Value)); - location = AsciiToHex(Value); - switch (LOWORD(wParam)) { - case SB_LINEDOWN: - if (location < 0xFFFFFFEF) { - sprintf(Value,"%08X",location + 0x10); - SetWindowText(hAddrEdit,Value); - } else { - sprintf(Value,"%08X",0xFFFFFFFF); - SetWindowText(hAddrEdit,Value); - } - break; - case SB_LINEUP: - if (location > 0x10 ) { - sprintf(Value,"%08X",location - 0x10); - SetWindowText(hAddrEdit,Value); - } else { - sprintf(Value,"%08X",0); - SetWindowText(hAddrEdit,Value); - } - break; - case SB_PAGEDOWN: - if (location < 0xFFFFFEFF) { - sprintf(Value,"%08X",location + 0x100); - SetWindowText(hAddrEdit,Value); - } else { - sprintf(Value,"%08X",0xFFFFFFFF); - SetWindowText(hAddrEdit,Value); - } - break; - case SB_PAGEUP: - if (location > 0x100 ) { - sprintf(Value,"%08X",location - 0x100); - SetWindowText(hAddrEdit,Value); - } else { - sprintf(Value,"%08X",0); - SetWindowText(hAddrEdit,Value); - } - break; - } - } - break; - default: - return FALSE; - } - return TRUE; -} - -void __cdecl Refresh_Memory ( void ) { - DWORD location; - char Value[20]; - int count; - - if (InMemoryWindow == FALSE) { return; } - - GetWindowText(hAddrEdit,Value,sizeof(Value)); - location = (AsciiToHex(Value) >> 4); - if (location > 0x0FFFFFF0) { location = 0x0FFFFFF0; } - for (count = 0 ; count < 16;count ++ ){ - Insert_MemoryLineDump ( count + location , count ); - } -} - -void Setup_Memory_Window (HWND hDlg) { -#define WindowWidth 683 -#define WindowHeight 341 - DWORD X, Y; - - hVAddr = CreateWindowEx(0,"BUTTON", "Virtual Addressing", WS_CHILD | WS_VISIBLE | - BS_AUTORADIOBUTTON, 215,13,150,21,hDlg,(HMENU)IDC_VADDR,hInst,NULL ); - SendMessage(hVAddr,BM_SETCHECK, BST_CHECKED,0); - - hPAddr = CreateWindowEx(0,"BUTTON", "Physical Addressing", WS_CHILD | WS_VISIBLE | - BS_AUTORADIOBUTTON, 375,13,155,21,hDlg,(HMENU)IDC_PADDR,hInst,NULL ); - - hList = CreateWindowEx(WS_EX_CLIENTEDGE,WC_LISTVIEW, "", WS_CHILD | WS_VISIBLE | - /*LVS_OWNERDRAWFIXED | */ LVS_REPORT | LVS_NOSORTHEADER, 14,39,622,261,hDlg, - (HMENU)IDC_LIST_VIEW,hInst,NULL ); - if (hList) { - LV_COLUMN col; - int count; - - col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; - col.fmt = LVCFMT_LEFT; - - col.pszText = "Address"; - col.cx = 90; - col.iSubItem = 0; - ListView_InsertColumn ( hList, 0, &col); - - col.pszText = "Memory Dump"; - col.cx = 390; - col.iSubItem = 1; - ListView_InsertColumn ( hList, 1, &col); - - col.cx = 140; - col.pszText = "Memory Ascii"; - col.iSubItem = 2; - ListView_InsertColumn ( hList, 2, &col); - ListView_SetItemCount ( hList, 16); - SendMessage(hList,WM_SETFONT, (WPARAM)GetStockObject(ANSI_FIXED_FONT),0); - for (count = 0 ; count < 16;count ++ ){ - Insert_MemoryLineDump (count,count); - } - - } - - SetWindowPos(GetDlgItem(hDlg,IDC_CLOSE_BUTTON),NULL, 560,13,90,21, SWP_NOZORDER | - SWP_SHOWWINDOW); - - hAddrEdit = GetDlgItem(hDlg,IDC_ADDR_EDIT); - SetWindowText(hAddrEdit,"00000000"); - SendMessage(hAddrEdit,EM_SETLIMITTEXT,(WPARAM)8,(LPARAM)0); - SetWindowPos(hAddrEdit,NULL, 100,13,100,21, SWP_NOZORDER | SWP_SHOWWINDOW); - SendMessage(hAddrEdit,WM_SETFONT, (WPARAM)GetStockObject(ANSI_FIXED_FONT),0); - - hScrlBar = CreateWindowEx(WS_EX_STATICEDGE, "SCROLLBAR","", WS_CHILD | WS_VISIBLE | - WS_TABSTOP | SBS_VERT, 635,39,18,260, hDlg, (HMENU)IDC_SCRL_BAR, hInst, NULL ); - if (hScrlBar) { - SCROLLINFO si; - - si.cbSize = sizeof(si); - si.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; - si.nMin = 0; - si.nMax = 300; - si.nPos = 145; - si.nPage = 10; - SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE); - } - - if ( !GetStoredWinPos( "Memory", &X, &Y ) ) { - X = (GetSystemMetrics( SM_CXSCREEN ) - WindowWidth) / 2; - Y = (GetSystemMetrics( SM_CYSCREEN ) - WindowHeight) / 2; - } - - SetWindowPos(hDlg,NULL,X,Y,WindowWidth,WindowHeight, SWP_NOZORDER | SWP_SHOWWINDOW); - -} -#endif - -#endif \ No newline at end of file diff --git a/Source/Project64/N64 System/C Core/r4300i Memory.h b/Source/Project64/N64 System/C Core/r4300i Memory.h index 83cff13a1..e69de29bb 100644 --- a/Source/Project64/N64 System/C Core/r4300i Memory.h +++ b/Source/Project64/N64 System/C Core/r4300i Memory.h @@ -1,32 +0,0 @@ -/* - * Project 64 - A Nintendo 64 emulator. - * - * (c) Copyright 2001 zilmar (zilmar@emulation64.com) and - * Jabo (jabo@emulation64.com). - * - * pj64 homepage: www.pj64.net - * - * Permission to use, copy, modify and distribute Project64 in both binary and - * source form, for non-commercial purposes, is hereby granted without fee, - * providing that this license information and copyright notice appear with - * all copies and any derived work. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event shall the authors be held liable for any damages - * arising from the use of this software. - * - * Project64 is freeware for PERSONAL USE only. Commercial users should - * seek permission of the copyright holders first. Commercial use includes - * charging money for Project64 or software derived from Project64. - * - * The copyright holders request that bug fixes and improvements to the code - * should be forwarded to them so if they want them. - * - */ -#ifndef __r4300i_memory_h -#define __r4300i_memory_h - -void __cdecl Enter_Memory_Window ( void ); -void __cdecl Refresh_Memory ( void ); - -#endif \ No newline at end of file diff --git a/Source/Project64/N64 System/C Core/r4300i Registers.cpp b/Source/Project64/N64 System/C Core/r4300i Registers.cpp index b0353a1a9..1bf319889 100644 --- a/Source/Project64/N64 System/C Core/r4300i Registers.cpp +++ b/Source/Project64/N64 System/C Core/r4300i Registers.cpp @@ -1,3 +1,5 @@ +#include "stdafx.h" + /* * Project 64 - A Nintendo 64 emulator. * diff --git a/Source/Project64/N64 System/C Core/tlb Display.h b/Source/Project64/N64 System/C Core/tlb Display.h deleted file mode 100644 index c24961309..000000000 --- a/Source/Project64/N64 System/C Core/tlb Display.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Project 64 - A Nintendo 64 emulator. - * - * (c) Copyright 2001 zilmar (zilmar@emulation64.com) and - * Jabo (jabo@emulation64.com). - * - * pj64 homepage: www.pj64.net - * - * Permission to use, copy, modify and distribute Project64 in both binary and - * source form, for non-commercial purposes, is hereby granted without fee, - * providing that this license information and copyright notice appear with - * all copies and any derived work. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event shall the authors be held liable for any damages - * arising from the use of this software. - * - * Project64 is freeware for PERSONAL USE only. Commercial users should - * seek permission of the copyright holders first. Commercial use includes - * charging money for Project64 or software derived from Project64. - * - * The copyright holders request that bug fixes and improvements to the code - * should be forwarded to them so if they want them. - * - */ -void Enter_TLB_Window ( void ); -void RefreshTLBWindow ( void ); diff --git a/Source/Project64/N64 System/C Core/x86 fpu.cpp b/Source/Project64/N64 System/C Core/x86 fpu.cpp deleted file mode 100644 index 58acb4de8..000000000 --- a/Source/Project64/N64 System/C Core/x86 fpu.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#ifdef tofix - -/* - * Project 64 - A Nintendo 64 emulator. - * - * (c) Copyright 2001 zilmar (zilmar@emulation64.com) and - * Jabo (jabo@emulation64.com). - * - * pj64 homepage: www.pj64.net - * - * Permission to use, copy, modify and distribute Project64 in both binary and - * source form, for non-commercial purposes, is hereby granted without fee, - * providing that this license information and copyright notice appear with - * all copies and any derived work. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event shall the authors be held liable for any damages - * arising from the use of this software. - * - * Project64 is freeware for PERSONAL USE only. Commercial users should - * seek permission of the copyright holders first. Commercial use includes - * charging money for Project64 or software derived from Project64. - * - * The copyright holders request that bug fixes and improvements to the code - * should be forwarded to them so if they want them. - * - */ -#include -#include -#include "main.h" -#include "cpu.h" -#include "x86.h" -#include "debugger.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 fpu_Name(Reg) (Reg) == x86_ST0 ? "ST(0)" : (Reg) == x86_ST1 ? "ST(1)" :\ - (Reg) == x86_ST2 ? "ST(2)" : (Reg) == x86_ST3 ? "ST(3)" :\ - (Reg) == x86_ST4 ? "ST(4)" : (Reg) == x86_ST5 ? "ST(5)" :\ - (Reg) == x86_ST6 ? "ST(6)" : (Reg) == x86_ST7 ? "ST(7)" :\ - "Unknown x86fpu Register" - - -void fpuDivDwordReverse(void *Variable, const char * VariableName) { - CPU_Message(" fdivr ST(0), dword ptr [%s]", VariableName); - PUTDST16(RecompPos,0x3DD8); - PUTDST32(RecompPos,Variable); -} - - -void fpuDivQwordReverse(void *Variable, const char * VariableName) { - CPU_Message(" fdivr ST(0), qword ptr [%s]", VariableName); - PUTDST16(RecompPos,0x3DDC); - PUTDST32(RecompPos,Variable); -} - -// -// FPU Utility -// - -static unsigned int fpucontrol; - -/* returns and pushes current fpu state, bool for set normal */ -int fpuSaveControl(BOOL bSetNormal) { - _asm { - fnstcw word ptr [fpucontrol] - } - - if (bSetNormal == TRUE) { - unsigned short fpunormal = fpucontrol & 0xF3FF; - _asm { - fldcw word ptr [fpunormal] - } - } - - return fpucontrol; -} - -/* returns and pops fpu state previously pushed */ -int fpuRestoreControl() { - _asm { - fldcw word ptr [fpucontrol] - } - return fpucontrol; -} - -void fpuSetupDouble(void) { - int temp = 0; - - _asm { - fnstcw word ptr [temp] - or [temp], 0x300 - and [temp], 0xFFFFF3FF - fldcw word ptr [temp] - } -} - -#endif \ No newline at end of file diff --git a/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.cpp b/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.cpp index 85e4bae46..dc52ef760 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger - Memory Dump.cpp @@ -1,3 +1,4 @@ +#include "stdafx.h" #include "Debugger UI.h" CDumpMemory::CDumpMemory(CDebugger * debugger) : diff --git a/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp b/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp index 48d80f047..7e6e9bdf1 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger - Memory Search.cpp @@ -1,3 +1,4 @@ +#include "stdafx.h" #include "Debugger UI.h" CDebugMemorySearch::CDebugMemorySearch(CDebugger * debugger) : diff --git a/Source/Project64/N64 System/Debugger/Debugger - TLB.cpp b/Source/Project64/N64 System/Debugger/Debugger - TLB.cpp index b640111cb..177089495 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - TLB.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger - TLB.cpp @@ -1,3 +1,4 @@ +#include "stdafx.h" #include "Debugger UI.h" CDebugTlb::CDebugTlb(CDebugger * debugger) : diff --git a/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp b/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp index 68f57742e..f67eb8d3b 100644 --- a/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger - View Memory.cpp @@ -1,3 +1,4 @@ +#include "stdafx.h" #include "Debugger UI.h" CDebugMemoryView::CDebugMemoryView(CDebugger * debugger) : diff --git a/Source/Project64/N64 System/Debugger/Debugger.cpp b/Source/Project64/N64 System/Debugger/Debugger.cpp index a8a108a12..c29a678d2 100644 --- a/Source/Project64/N64 System/Debugger/Debugger.cpp +++ b/Source/Project64/N64 System/Debugger/Debugger.cpp @@ -1,8 +1,4 @@ -#include -#include -#include - -#include "..\\..\\N64 System.h" +#include "stdafx.h" #include "Debugger UI.h" CPj64Module _Module; diff --git a/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp b/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp index b1ff989df..70e0f84cc 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp @@ -239,7 +239,7 @@ void CInterpreterCPU::ExecuteCPU (void ) { if (_MMU->LW_VAddr(PROGRAM_COUNTER, Opcode.Hex)) { - /*if (PROGRAM_COUNTER > 0x80323000 && PROGRAM_COUNTER< 0x80380000) + /*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]); @@ -308,6 +308,12 @@ void CInterpreterCPU::ExecuteOps ( int Cycles ) if (_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,*_NextTimer,_SystemTimer->CurrentType()); + }*/ /*if (PROGRAM_COUNTER > 0x80323000 && PROGRAM_COUNTER< 0x80380000) { WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %s",*_PROGRAM_COUNTER,R4300iOpcodeName(Opcode.Hex,*_PROGRAM_COUNTER)); diff --git a/Source/Project64/N64 System/Mips/Memory Virtual Mem.h b/Source/Project64/N64 System/Mips/Memory Virtual Mem.h index 282d90b16..82b7d3fd7 100644 --- a/Source/Project64/N64 System/Mips/Memory Virtual Mem.h +++ b/Source/Project64/N64 System/Mips/Memory Virtual Mem.h @@ -5,7 +5,8 @@ class CRSP_Plugin; class CMipsMemoryVM : public CMipsMemory, public CTransVaddr, - private CRecompilerOps + private CRecompilerOps, + private R4300iOp { //Make sure plugins can directly access this information friend CGfxPlugin; diff --git a/Source/Project64/N64 System/Mips/Memory.cpp b/Source/Project64/N64 System/Mips/Memory.cpp index cbfe2ca7f..f8bc3300e 100644 --- a/Source/Project64/N64 System/Mips/Memory.cpp +++ b/Source/Project64/N64 System/Mips/Memory.cpp @@ -640,10 +640,10 @@ void CMipsMemoryVM::Compile_LW (x86Reg Reg, DWORD VAddr ) { switch (PAddr) { case 0x04400010: UpdateCounters(m_RegWorkingSet,false,true); - Pushad(); + BeforeCallDirect(); MoveConstToX86reg((DWORD)this,x86_ECX); Call_Direct(AddressOf(CMipsMemoryVM::UpdateHalfLine),"CMipsMemoryVM::UpdateHalfLine"); - Popad(); + AfterCallDirect(); MoveVariableToX86reg(&m_HalfLine,"m_HalfLine",Reg); break; default: @@ -657,18 +657,18 @@ void CMipsMemoryVM::Compile_LW (x86Reg Reg, DWORD VAddr ) { if (_Settings->LoadBool(Game_FixedAudio)) { UpdateCounters(m_RegWorkingSet,false,true); - Pushad(); + BeforeCallDirect(); MoveConstToX86reg((DWORD)_Audio,x86_ECX); Call_Direct(AddressOf(CAudio::AiGetLength),"CAudio::AiGetLength"); MoveX86regToVariable(x86_EAX,&m_TempValue,"m_TempValue"); - Popad(); + AfterCallDirect(); MoveVariableToX86reg(&m_TempValue,"m_TempValue",Reg); } else { if (_Plugins->Audio()->ReadLength != NULL) { - Pushad(); + BeforeCallDirect(); Call_Direct(_Plugins->Audio()->ReadLength,"AiReadLength"); MoveX86regToVariable(x86_EAX,&m_TempValue,"m_TempValue"); - Popad(); + AfterCallDirect(); MoveVariableToX86reg(&m_TempValue,"m_TempValue",Reg); } else { MoveConstToX86reg(0,Reg); @@ -678,11 +678,11 @@ void CMipsMemoryVM::Compile_LW (x86Reg Reg, DWORD VAddr ) { case 0x0450000C: if (_Settings->LoadBool(Game_FixedAudio)) { - Pushad(); + BeforeCallDirect(); MoveConstToX86reg((DWORD)_Audio,x86_ECX); Call_Direct(AddressOf(CAudio::AiGetStatus),"AiGetStatus"); MoveX86regToVariable(x86_EAX,&m_TempValue,"m_TempValue"); - Popad(); + AfterCallDirect(); MoveVariableToX86reg(&m_TempValue,"m_TempValue",Reg); } else { MoveVariableToX86reg(&_Reg->AI_STATUS_REG,"AI_STATUS_REG",Reg); @@ -903,9 +903,9 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) { case 0x04040004: MoveConstToVariable(Value,&_Reg->SP_DRAM_ADDR_REG,"SP_DRAM_ADDR_REG"); break; case 0x04040008: MoveConstToVariable(Value,&_Reg->SP_RD_LEN_REG,"SP_RD_LEN_REG"); - Pushad(); + BeforeCallDirect(); Call_Direct(&SP_DMA_READ,"SP_DMA_READ"); - Popad(); + AfterCallDirect(); break; case 0x04040010: { @@ -945,22 +945,22 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) { if ( ( Value & SP_SET_SIG0 ) != 0 && _Settings->LoadBool(Game_RspAudioSignal) ) { OrConstToVariable(MI_INTR_SP,&_Reg->MI_INTR_REG,"MI_INTR_REG"); - Pushad(); + BeforeCallDirect(); MoveConstToX86reg((DWORD)_Reg,x86_ECX); Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - Popad(); + AfterCallDirect(); } if ( ( Value & SP_CLR_INTR ) != 0) { AndConstToVariable(~MI_INTR_SP,&_Reg->MI_INTR_REG,"MI_INTR_REG"); - Pushad(); + BeforeCallDirect(); Call_Direct(RunRsp,"RunRsp"); MoveConstToX86reg((DWORD)_Reg,x86_ECX); Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - Popad(); + AfterCallDirect(); } else { - Pushad(); + BeforeCallDirect(); Call_Direct(RunRsp,"RunRsp"); - Popad(); + AfterCallDirect(); } } break; @@ -1033,9 +1033,9 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) { JeLabel8("Continue",0); Jump = m_RecompPos - 1; MoveConstToVariable(Value,&_Reg->VI_STATUS_REG,"VI_STATUS_REG"); - Pushad(); + BeforeCallDirect(); Call_Direct(_Plugins->Gfx()->ViStatusChanged,"ViStatusChanged"); - Popad(); + AfterCallDirect(); CPU_Message(""); CPU_Message(" Continue:"); *((BYTE *)(Jump))=(BYTE)(m_RecompPos - Jump - 1); @@ -1048,9 +1048,9 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) { JeLabel8("Continue",0); Jump = m_RecompPos - 1; MoveConstToVariable(Value,&_Reg->VI_WIDTH_REG,"VI_WIDTH_REG"); - Pushad(); + BeforeCallDirect(); Call_Direct(_Plugins->Gfx()->ViWidthChanged,"ViWidthChanged"); - Popad(); + AfterCallDirect(); CPU_Message(""); CPU_Message(" Continue:"); *((BYTE *)(Jump))=(BYTE)(m_RecompPos - Jump - 1); @@ -1059,10 +1059,10 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) { case 0x0440000C: MoveConstToVariable(Value,&_Reg->VI_INTR_REG,"VI_INTR_REG"); break; case 0x04400010: AndConstToVariable(~MI_INTR_VI,&_Reg->MI_INTR_REG,"MI_INTR_REG"); - Pushad(); + BeforeCallDirect(); MoveConstToX86reg((DWORD)_Reg,x86_ECX); Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - Popad(); + AfterCallDirect(); break; case 0x04400014: MoveConstToVariable(Value,&_Reg->VI_BURST_REG,"VI_BURST_REG"); break; case 0x04400018: MoveConstToVariable(Value,&_Reg->VI_V_SYNC_REG,"VI_V_SYNC_REG"); break; @@ -1082,7 +1082,7 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) { case 0x04500000: MoveConstToVariable(Value,&_Reg->AI_DRAM_ADDR_REG,"AI_DRAM_ADDR_REG"); break; case 0x04500004: MoveConstToVariable(Value,&_Reg->AI_LEN_REG,"AI_LEN_REG"); - Pushad(); + BeforeCallDirect(); if (_Settings->LoadBool(Game_FixedAudio)) { X86BreakPoint(__FILE__,__LINE__); @@ -1091,7 +1091,7 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) { Call_Direct(AddressOf(CAudio::AiSetLength),"AiSetLength"); } Call_Direct(_Plugins->Audio()->LenChanged,"AiLenChanged"); - Popad(); + AfterCallDirect(); break; case 0x04500008: MoveConstToVariable((Value & 1),&_Reg->AI_CONTROL_REG,"AI_CONTROL_REG"); break; case 0x0450000C: @@ -1103,10 +1103,10 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) { AndConstToVariable(~MI_INTR_AI,&_Reg->m_AudioIntrReg,"m_AudioIntrReg"); } #endif - Pushad(); + BeforeCallDirect(); MoveConstToX86reg((DWORD)_Reg,x86_ECX); Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - Popad(); + AfterCallDirect(); break; case 0x04500010: sprintf(VarName,"m_RDRAM + %X",PAddr); @@ -1125,23 +1125,23 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) { case 0x04600004: MoveConstToVariable(Value,&_Reg->PI_CART_ADDR_REG,"PI_CART_ADDR_REG"); break; case 0x04600008: MoveConstToVariable(Value,&_Reg->PI_RD_LEN_REG,"PI_RD_LEN_REG"); - Pushad(); + BeforeCallDirect(); Call_Direct(&PI_DMA_READ,"PI_DMA_READ"); - Popad(); + AfterCallDirect(); break; case 0x0460000C: MoveConstToVariable(Value,&_Reg->PI_WR_LEN_REG,"PI_WR_LEN_REG"); - Pushad(); + BeforeCallDirect(); Call_Direct(&PI_DMA_WRITE,"PI_DMA_WRITE"); - Popad(); + AfterCallDirect(); break; case 0x04600010: if ((Value & PI_CLR_INTR) != 0 ) { AndConstToVariable(~MI_INTR_PI,&_Reg->MI_INTR_REG,"MI_INTR_REG"); - Pushad(); + BeforeCallDirect(); MoveConstToX86reg((DWORD)_Reg,x86_ECX); Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - Popad(); + AfterCallDirect(); } break; case 0x04600014: MoveConstToVariable((Value & 0xFF),&_Reg->PI_DOMAIN1_REG,"PI_DOMAIN1_REG"); break; @@ -1167,23 +1167,23 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) { case 0x04800000: MoveConstToVariable(Value,&_Reg->SI_DRAM_ADDR_REG,"SI_DRAM_ADDR_REG"); break; case 0x04800004: MoveConstToVariable(Value,&_Reg->SI_PIF_ADDR_RD64B_REG,"SI_PIF_ADDR_RD64B_REG"); - Pushad(); + BeforeCallDirect(); Call_Direct(&SI_DMA_READ,"SI_DMA_READ"); - Popad(); + AfterCallDirect(); break; case 0x04800010: MoveConstToVariable(Value,&_Reg->SI_PIF_ADDR_WR64B_REG,"SI_PIF_ADDR_WR64B_REG"); - Pushad(); + BeforeCallDirect(); Call_Direct(&SI_DMA_WRITE,"SI_DMA_WRITE"); - Popad(); + AfterCallDirect(); break; case 0x04800018: AndConstToVariable(~MI_INTR_SI,&_Reg->MI_INTR_REG,"MI_INTR_REG"); AndConstToVariable(~SI_STATUS_INTERRUPT,&_Reg->SI_STATUS_REG,"SI_STATUS_REG"); - Pushad(); + BeforeCallDirect(); MoveConstToX86reg((DWORD)_Reg,x86_ECX); Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - Popad(); + AfterCallDirect(); break; default: if (_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { DisplayError("Compile_SW_Const\ntrying to store %X in %X?",Value,VAddr); } @@ -1224,21 +1224,21 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr ) case 0x04040004: MoveX86regToVariable(Reg,&_Reg->SP_DRAM_ADDR_REG,"SP_DRAM_ADDR_REG"); break; case 0x04040008: MoveX86regToVariable(Reg,&_Reg->SP_RD_LEN_REG,"SP_RD_LEN_REG"); - Pushad(); + BeforeCallDirect(); Call_Direct(&SP_DMA_READ,"SP_DMA_READ"); - Popad(); + AfterCallDirect(); break; case 0x0404000C: MoveX86regToVariable(Reg,&_Reg->SP_WR_LEN_REG,"SP_WR_LEN_REG"); - Pushad(); + BeforeCallDirect(); Call_Direct(&SP_DMA_WRITE,"SP_DMA_WRITE"); - Popad(); + AfterCallDirect(); break; case 0x04040010: MoveX86regToVariable(Reg,&RegModValue,"RegModValue"); - Pushad(); + BeforeCallDirect(); Call_Direct(ChangeSpStatus,"ChangeSpStatus"); - Popad(); + AfterCallDirect(); break; case 0x0404001C: MoveConstToVariable(0,&_Reg->SP_SEMAPHORE_REG,"SP_SEMAPHORE_REG"); break; case 0x04080000: @@ -1264,15 +1264,15 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr ) switch (PAddr) { case 0x04300000: MoveX86regToVariable(Reg,&RegModValue,"RegModValue"); - Pushad(); + BeforeCallDirect(); Call_Direct(ChangeMiIntrMask,"ChangeMiModeReg"); - Popad(); + AfterCallDirect(); break; case 0x0430000C: MoveX86regToVariable(Reg,&RegModValue,"RegModValue"); - Pushad(); + BeforeCallDirect(); Call_Direct(ChangeMiIntrMask,"ChangeMiIntrMask"); - Popad(); + AfterCallDirect(); break; default: CPU_Message(" Should be moving %s in to %X ?!?",x86_Name(Reg),VAddr); @@ -1287,9 +1287,9 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr ) JeLabel8("Continue",0); Jump = m_RecompPos - 1; MoveX86regToVariable(Reg,&_Reg->VI_STATUS_REG,"VI_STATUS_REG"); - Pushad(); + BeforeCallDirect(); Call_Direct(_Plugins->Gfx()->ViStatusChanged,"ViStatusChanged"); - Popad(); + AfterCallDirect(); CPU_Message(""); CPU_Message(" Continue:"); *((BYTE *)(Jump))=(BYTE)(m_RecompPos - Jump - 1); @@ -1305,9 +1305,9 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr ) JeLabel8("Continue",0); Jump = m_RecompPos - 1; MoveX86regToVariable(Reg,&_Reg->VI_WIDTH_REG,"VI_WIDTH_REG"); - Pushad(); + BeforeCallDirect(); Call_Direct(_Plugins->Gfx()->ViWidthChanged,"ViWidthChanged"); - Popad(); + AfterCallDirect(); CPU_Message(""); CPU_Message(" Continue:"); *((BYTE *)(Jump))=(BYTE)(m_RecompPos - Jump - 1); @@ -1316,10 +1316,10 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr ) case 0x0440000C: MoveX86regToVariable(Reg,&_Reg->VI_INTR_REG,"VI_INTR_REG"); break; case 0x04400010: AndConstToVariable(~MI_INTR_VI,&_Reg->MI_INTR_REG,"MI_INTR_REG"); - Pushad(); + BeforeCallDirect(); MoveConstToX86reg((DWORD)_Reg,x86_ECX); Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - Popad(); + AfterCallDirect(); break; case 0x04400014: MoveX86regToVariable(Reg,&_Reg->VI_BURST_REG,"VI_BURST_REG"); break; case 0x04400018: MoveX86regToVariable(Reg,&_Reg->VI_V_SYNC_REG,"VI_V_SYNC_REG"); break; @@ -1341,14 +1341,14 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr ) case 0x04500004: UpdateCounters(m_RegWorkingSet,false,true); MoveX86regToVariable(Reg,&_Reg->AI_LEN_REG,"AI_LEN_REG"); - Pushad(); + BeforeCallDirect(); if (_Settings->LoadBool(Game_FixedAudio)) { MoveConstToX86reg((DWORD)_Audio,x86_ECX); Call_Direct(AddressOf(CAudio::AiSetLength),"AiSetLength"); } Call_Direct(_Plugins->Audio()->LenChanged,"AiLenChanged"); - Popad(); + AfterCallDirect(); break; case 0x04500008: MoveX86regToVariable(Reg,&_Reg->AI_CONTROL_REG,"AI_CONTROL_REG"); @@ -1357,10 +1357,10 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr ) /* Clear Interrupt */; AndConstToVariable(~MI_INTR_AI,&_Reg->MI_INTR_REG,"MI_INTR_REG"); AndConstToVariable(~MI_INTR_AI,&_Reg->m_AudioIntrReg,"m_AudioIntrReg"); - Pushad(); + BeforeCallDirect(); MoveConstToX86reg((DWORD)_Reg,x86_ECX); Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - Popad(); + AfterCallDirect(); break; case 0x04500010: sprintf(VarName,"m_RDRAM + %X",PAddr); @@ -1378,23 +1378,23 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr ) case 0x04600004: MoveX86regToVariable(Reg,&_Reg->PI_CART_ADDR_REG,"PI_CART_ADDR_REG"); break; case 0x04600008: MoveX86regToVariable(Reg,&_Reg->PI_RD_LEN_REG,"PI_RD_LEN_REG"); - Pushad(); + BeforeCallDirect(); Call_Direct(&PI_DMA_READ,"PI_DMA_READ"); - Popad(); + AfterCallDirect(); break; case 0x0460000C: MoveX86regToVariable(Reg,&_Reg->PI_WR_LEN_REG,"PI_WR_LEN_REG"); - Pushad(); + BeforeCallDirect(); Call_Direct(&PI_DMA_WRITE,"PI_DMA_WRITE"); - Popad(); + AfterCallDirect(); break; case 0x04600010: if (_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { DisplayError("Compile_SW_Register\ntrying to store at %X?",VAddr); } AndConstToVariable(~MI_INTR_PI,&_Reg->MI_INTR_REG,"MI_INTR_REG"); - Pushad(); + BeforeCallDirect(); MoveConstToX86reg((DWORD)_Reg,x86_ECX); Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - Popad(); + AfterCallDirect(); break; MoveX86regToVariable(Reg,&_Reg->VI_ORIGIN_REG,"VI_ORIGIN_REG"); AndConstToVariable(0xFFFFFF,&_Reg->VI_ORIGIN_REG,"VI_ORIGIN_REG"); @@ -1431,23 +1431,23 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr ) case 0x04800000: MoveX86regToVariable(Reg,&_Reg->SI_DRAM_ADDR_REG,"SI_DRAM_ADDR_REG"); break; case 0x04800004: MoveX86regToVariable(Reg,&_Reg->SI_PIF_ADDR_RD64B_REG,"SI_PIF_ADDR_RD64B_REG"); - Pushad(); + BeforeCallDirect(); Call_Direct(&SI_DMA_READ,"SI_DMA_READ"); - Popad(); + AfterCallDirect(); break; case 0x04800010: MoveX86regToVariable(Reg,&_Reg->SI_PIF_ADDR_WR64B_REG,"SI_PIF_ADDR_WR64B_REG"); - Pushad(); + BeforeCallDirect(); Call_Direct(&SI_DMA_WRITE,"SI_DMA_WRITE"); - Popad(); + AfterCallDirect(); break; case 0x04800018: AndConstToVariable(~MI_INTR_SI,&_Reg->MI_INTR_REG,"MI_INTR_REG"); AndConstToVariable(~SI_STATUS_INTERRUPT,&_Reg->SI_STATUS_REG,"SI_STATUS_REG"); - Pushad(); + BeforeCallDirect(); MoveConstToX86reg((DWORD)_Reg,x86_ECX); Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - Popad(); + AfterCallDirect(); break; default: if (_Settings->LoadBool(Debugger_ShowUnhandledMemory)) { DisplayError("Compile_SW_Register\ntrying to store at %X?",VAddr); } @@ -1953,32 +1953,24 @@ int CMipsMemoryVM::LW_NonMemory ( DWORD PAddr, DWORD * Value ) { case 0x04500000: switch (PAddr) { case 0x04500004: -#ifdef tofix if (_Settings->LoadBool(Game_FixedAudio)) { - *Value = CAudio::AiGetLength(g_Audio); + *Value = _Audio->AiGetLength(); } else { -#endif if (_Plugins->Audio()->ReadLength != NULL) { *Value = _Plugins->Audio()->ReadLength(); } else { *Value = 0; } -#ifdef tofix } -#endif break; case 0x0450000C: -#ifdef tofix if (_Settings->LoadBool(Game_FixedAudio)) { - *Value = CAudio::AiGetStatus(g_Audio); + *Value = _Audio->AiGetStatus(); } else { -#endif *Value = _Reg->AI_STATUS_REG; -#ifdef tofix } -#endif break; default: * Value = 0; @@ -3745,31 +3737,33 @@ void CMipsMemoryVM::UnProtectMemory( DWORD StartVaddr, DWORD EndVaddr ) } -void CMipsMemoryVM::Compile_LB (void) { +void CMipsMemoryVM::Compile_LB (void) +{ + OPCODE & Opcode = CRecompilerOps::m_Opcode; x86Reg TempReg1, TempReg2; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); - if (m_Opcode.rt == 0) return; + if (Opcode.rt == 0) return; - if (IsConst(m_Opcode.base)) { - DWORD Address = (cMipsRegLo(m_Opcode.base) + (short)m_Opcode.offset) ^ 3; - Map_GPR_32bit(m_Opcode.rt,TRUE,0); - Compile_LB(cMipsRegMapLo(m_Opcode.rt),Address,TRUE); + if (IsConst(Opcode.base)) { + DWORD Address = (cMipsRegLo(Opcode.base) + (short)Opcode.offset) ^ 3; + Map_GPR_32bit(Opcode.rt,TRUE,0); + Compile_LB(cMipsRegMapLo(Opcode.rt),Address,TRUE); return; } - if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } - if (IsMapped(m_Opcode.base)) { - ProtectGPR(m_Opcode.base); - if (m_Opcode.offset != 0) { + 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,cMipsRegMapLo(m_Opcode.base),(short)m_Opcode.offset); + LeaSourceAndOffset(TempReg1,cMipsRegMapLo(Opcode.base),(short)Opcode.offset); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); - AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); + AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } if (g_UseTlb) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); @@ -3778,41 +3772,43 @@ void CMipsMemoryVM::Compile_LB (void) { MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); CompileReadTLBMiss(TempReg1,TempReg2); XorConstToX86Reg(TempReg1,3); - Map_GPR_32bit(m_Opcode.rt,TRUE,-1); - MoveSxByteX86regPointerToX86reg(TempReg1, TempReg2,cMipsRegMapLo(m_Opcode.rt)); + Map_GPR_32bit(Opcode.rt,TRUE,-1); + MoveSxByteX86regPointerToX86reg(TempReg1, TempReg2,cMipsRegMapLo(Opcode.rt)); } else { AndConstToX86Reg(TempReg1,0x1FFFFFFF); XorConstToX86Reg(TempReg1,3); - Map_GPR_32bit(m_Opcode.rt,TRUE,-1); - MoveSxN64MemToX86regByte(cMipsRegMapLo(m_Opcode.rt), TempReg1); + Map_GPR_32bit(Opcode.rt,TRUE,-1); + MoveSxN64MemToX86regByte(cMipsRegMapLo(Opcode.rt), TempReg1); } } -void CMipsMemoryVM::Compile_LBU (void) { +void CMipsMemoryVM::Compile_LBU (void) +{ + OPCODE & Opcode = CRecompilerOps::m_Opcode; x86Reg TempReg1, TempReg2; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); - if (m_Opcode.rt == 0) return; + if (Opcode.rt == 0) return; - if (IsConst(m_Opcode.base)) { - DWORD Address = (cMipsRegLo(m_Opcode.base) + (short)m_Opcode.offset) ^ 3; - Map_GPR_32bit(m_Opcode.rt,FALSE,0); - Compile_LB(cMipsRegMapLo(m_Opcode.rt),Address,FALSE); + if (IsConst(Opcode.base)) { + DWORD Address = (cMipsRegLo(Opcode.base) + (short)Opcode.offset) ^ 3; + Map_GPR_32bit(Opcode.rt,FALSE,0); + Compile_LB(cMipsRegMapLo(Opcode.rt),Address,FALSE); return; } - if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } - if (IsMapped(m_Opcode.base)) { - ProtectGPR(m_Opcode.base); - if (m_Opcode.offset != 0) { + 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,cMipsRegMapLo(m_Opcode.base),(short)m_Opcode.offset); + LeaSourceAndOffset(TempReg1,cMipsRegMapLo(Opcode.base),(short)Opcode.offset); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); - AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); + AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } if (g_UseTlb) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); @@ -3821,41 +3817,43 @@ void CMipsMemoryVM::Compile_LBU (void) { MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); CompileReadTLBMiss(TempReg1,TempReg2); XorConstToX86Reg(TempReg1,3); - Map_GPR_32bit(m_Opcode.rt,FALSE,-1); - MoveZxByteX86regPointerToX86reg(TempReg1, TempReg2,cMipsRegMapLo(m_Opcode.rt)); + Map_GPR_32bit(Opcode.rt,FALSE,-1); + MoveZxByteX86regPointerToX86reg(TempReg1, TempReg2,cMipsRegMapLo(Opcode.rt)); } else { AndConstToX86Reg(TempReg1,0x1FFFFFFF); XorConstToX86Reg(TempReg1,3); - Map_GPR_32bit(m_Opcode.rt,FALSE,-1); - MoveZxN64MemToX86regByte(cMipsRegMapLo(m_Opcode.rt), TempReg1); + Map_GPR_32bit(Opcode.rt,FALSE,-1); + MoveZxN64MemToX86regByte(cMipsRegMapLo(Opcode.rt), TempReg1); } } -void CMipsMemoryVM::Compile_LH (void) { +void CMipsMemoryVM::Compile_LH (void) +{ + OPCODE & Opcode = CRecompilerOps::m_Opcode; x86Reg TempReg1, TempReg2; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); - if (m_Opcode.rt == 0) return; + if (Opcode.rt == 0) return; - if (IsConst(m_Opcode.base)) { - DWORD Address = (cMipsRegLo(m_Opcode.base) + (short)m_Opcode.offset) ^ 2; - Map_GPR_32bit(m_Opcode.rt,TRUE,0); - Compile_LH(cMipsRegMapLo(m_Opcode.rt),Address,TRUE); + if (IsConst(Opcode.base)) { + DWORD Address = (cMipsRegLo(Opcode.base) + (short)Opcode.offset) ^ 2; + Map_GPR_32bit(Opcode.rt,TRUE,0); + Compile_LH(cMipsRegMapLo(Opcode.rt),Address,TRUE); return; } - if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } - if (IsMapped(m_Opcode.base)) { - ProtectGPR(m_Opcode.base); - if (m_Opcode.offset != 0) { + 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,cMipsRegMapLo(m_Opcode.base),(short)m_Opcode.offset); + LeaSourceAndOffset(TempReg1,cMipsRegMapLo(Opcode.base),(short)Opcode.offset); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); - AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); + AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } if (g_UseTlb) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); @@ -3864,41 +3862,43 @@ void CMipsMemoryVM::Compile_LH (void) { MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); CompileReadTLBMiss(TempReg1,TempReg2); XorConstToX86Reg(TempReg1,2); - Map_GPR_32bit(m_Opcode.rt,TRUE,-1); - MoveSxHalfX86regPointerToX86reg(TempReg1, TempReg2,cMipsRegMapLo(m_Opcode.rt)); + Map_GPR_32bit(Opcode.rt,TRUE,-1); + MoveSxHalfX86regPointerToX86reg(TempReg1, TempReg2,cMipsRegMapLo(Opcode.rt)); } else { AndConstToX86Reg(TempReg1,0x1FFFFFFF); XorConstToX86Reg(TempReg1,2); - Map_GPR_32bit(m_Opcode.rt,TRUE,-1); - MoveSxN64MemToX86regHalf(cMipsRegMapLo(m_Opcode.rt), TempReg1); + Map_GPR_32bit(Opcode.rt,TRUE,-1); + MoveSxN64MemToX86regHalf(cMipsRegMapLo(Opcode.rt), TempReg1); } } -void CMipsMemoryVM::Compile_LHU (void) { +void CMipsMemoryVM::Compile_LHU (void) +{ + OPCODE & Opcode = CRecompilerOps::m_Opcode; x86Reg TempReg1, TempReg2; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); - if (m_Opcode.rt == 0) return; + if (Opcode.rt == 0) return; - if (IsConst(m_Opcode.base)) { - DWORD Address = (cMipsRegLo(m_Opcode.base) + (short)m_Opcode.offset) ^ 2; - Map_GPR_32bit(m_Opcode.rt,FALSE,0); - Compile_LH(cMipsRegMapLo(m_Opcode.rt),Address,FALSE); + if (IsConst(Opcode.base)) { + DWORD Address = (cMipsRegLo(Opcode.base) + (short)Opcode.offset) ^ 2; + Map_GPR_32bit(Opcode.rt,FALSE,0); + Compile_LH(cMipsRegMapLo(Opcode.rt),Address,FALSE); return; } - if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } - if (IsMapped(m_Opcode.base)) { - ProtectGPR(m_Opcode.base); - if (m_Opcode.offset != 0) { + 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,cMipsRegMapLo(m_Opcode.base),(short)m_Opcode.offset); + LeaSourceAndOffset(TempReg1,cMipsRegMapLo(Opcode.base),(short)Opcode.offset); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); - AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); + AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } if (g_UseTlb) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); @@ -3907,55 +3907,56 @@ void CMipsMemoryVM::Compile_LHU (void) { MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); CompileReadTLBMiss(TempReg1,TempReg2); XorConstToX86Reg(TempReg1,2); - Map_GPR_32bit(m_Opcode.rt,FALSE,-1); - MoveZxHalfX86regPointerToX86reg(TempReg1, TempReg2,cMipsRegMapLo(m_Opcode.rt)); + Map_GPR_32bit(Opcode.rt,FALSE,-1); + MoveZxHalfX86regPointerToX86reg(TempReg1, TempReg2,cMipsRegMapLo(Opcode.rt)); } else { AndConstToX86Reg(TempReg1,0x1FFFFFFF); XorConstToX86Reg(TempReg1,2); - Map_GPR_32bit(m_Opcode.rt,TRUE,-1); - MoveZxN64MemToX86regHalf(cMipsRegMapLo(m_Opcode.rt), TempReg1); + Map_GPR_32bit(Opcode.rt,TRUE,-1); + MoveZxN64MemToX86regHalf(cMipsRegMapLo(Opcode.rt), TempReg1); } } void CMipsMemoryVM::Compile_LW (void) { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + OPCODE & Opcode = CRecompilerOps::m_Opcode; + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); - if (m_Opcode.rt == 0) return; + if (Opcode.rt == 0) return; x86Reg TempReg1, TempReg2; #ifdef tofix - if (m_Opcode.base == 29 && SPHack) { + if (Opcode.base == 29 && SPHack) { char String[100]; - Map_GPR_32bit(m_Opcode.rt,TRUE,-1); + Map_GPR_32bit(Opcode.rt,TRUE,-1); TempReg1 = Map_MemoryStack(x86_Any,true); - sprintf(String,"%Xh",(short)m_Opcode.offset); - MoveVariableDispToX86Reg((void *)((DWORD)(short)m_Opcode.offset),String,cMipsRegLo(m_Opcode.rt),TempReg1,1); + sprintf(String,"%Xh",(short)Opcode.offset); + MoveVariableDispToX86Reg((void *)((DWORD)(short)Opcode.offset),String,cMipsRegLo(Opcode.rt),TempReg1,1); } else { #endif - if (IsConst(m_Opcode.base)) { - DWORD Address = cMipsRegLo(m_Opcode.base) + (short)m_Opcode.offset; - Map_GPR_32bit(m_Opcode.rt,TRUE,-1); - Compile_LW(cMipsRegMapLo(m_Opcode.rt),Address); + if (IsConst(Opcode.base)) { + DWORD Address = cMipsRegLo(Opcode.base) + (short)Opcode.offset; + Map_GPR_32bit(Opcode.rt,TRUE,-1); + Compile_LW(cMipsRegMapLo(Opcode.rt),Address); } else { if (g_UseTlb) { - if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } - if (IsMapped(m_Opcode.base) && m_Opcode.offset == 0) { - ProtectGPR(m_Opcode.base); - TempReg1 = cMipsRegMapLo(m_Opcode.base); + if (IsMapped(Opcode.rt)) { ProtectGPR(Opcode.rt); } + if (IsMapped(Opcode.base) && Opcode.offset == 0) { + ProtectGPR(Opcode.base); + TempReg1 = cMipsRegMapLo(Opcode.base); } else { - if (IsMapped(m_Opcode.base)) { - ProtectGPR(m_Opcode.base); - if (m_Opcode.offset != 0) { + if (IsMapped(Opcode.base)) { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) { TempReg1 = Map_TempReg(x86_Any,-1,FALSE); - LeaSourceAndOffset(TempReg1,cMipsRegMapLo(m_Opcode.base),(short)m_Opcode.offset); + LeaSourceAndOffset(TempReg1,cMipsRegMapLo(Opcode.base),(short)Opcode.offset); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); - AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); + AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } } TempReg2 = Map_TempReg(x86_Any,-1,FALSE); @@ -3963,28 +3964,28 @@ void CMipsMemoryVM::Compile_LW (void) ShiftRightUnsignImmed(TempReg2,12); MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); CompileReadTLBMiss(TempReg1,TempReg2); - Map_GPR_32bit(m_Opcode.rt,TRUE,-1); - MoveX86regPointerToX86reg(TempReg1, TempReg2,cMipsRegMapLo(m_Opcode.rt)); + Map_GPR_32bit(Opcode.rt,TRUE,-1); + MoveX86regPointerToX86reg(TempReg1, TempReg2,cMipsRegMapLo(Opcode.rt)); } else { - if (IsMapped(m_Opcode.base)) { - ProtectGPR(m_Opcode.base); - if (m_Opcode.offset != 0) { - Map_GPR_32bit(m_Opcode.rt,TRUE,-1); - LeaSourceAndOffset(cMipsRegMapLo(m_Opcode.rt),cMipsRegMapLo(m_Opcode.base),(short)m_Opcode.offset); + if (IsMapped(Opcode.base)) { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) { + Map_GPR_32bit(Opcode.rt,TRUE,-1); + LeaSourceAndOffset(cMipsRegMapLo(Opcode.rt),cMipsRegMapLo(Opcode.base),(short)Opcode.offset); } else { - Map_GPR_32bit(m_Opcode.rt,TRUE,m_Opcode.base); + Map_GPR_32bit(Opcode.rt,TRUE,Opcode.base); } } else { - Map_GPR_32bit(m_Opcode.rt,TRUE,m_Opcode.base); - AddConstToX86Reg(cMipsRegMapLo(m_Opcode.rt),(short)m_Opcode.immediate); + Map_GPR_32bit(Opcode.rt,TRUE,Opcode.base); + AddConstToX86Reg(cMipsRegMapLo(Opcode.rt),(short)Opcode.immediate); } - AndConstToX86Reg(cMipsRegMapLo(m_Opcode.rt),0x1FFFFFFF); - MoveN64MemToX86reg(cMipsRegMapLo(m_Opcode.rt),cMipsRegMapLo(m_Opcode.rt)); + AndConstToX86Reg(cMipsRegMapLo(Opcode.rt),0x1FFFFFFF); + MoveN64MemToX86reg(cMipsRegMapLo(Opcode.rt),cMipsRegMapLo(Opcode.rt)); } } #ifdef tofix } - if (SPHack && m_Opcode.rt == 29) + if (SPHack && Opcode.rt == 29) { ResetX86Protection(); _MMU->ResetMemoryStack(m_Section); @@ -3992,61 +3993,63 @@ void CMipsMemoryVM::Compile_LW (void) #endif } -void CMipsMemoryVM::Compile_LWC1 (void) { +void CMipsMemoryVM::Compile_LWC1 (void) +{ + OPCODE & Opcode = CRecompilerOps::m_Opcode; x86Reg TempReg1, TempReg2, TempReg3; char Name[50]; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); m_Section->CompileCop1Test(); - if ((m_Opcode.ft & 1) != 0) { - if (RegInStack(m_Opcode.ft-1,CRegInfo::FPU_Double) || RegInStack(m_Opcode.ft-1,CRegInfo::FPU_Qword)) { - UnMap_FPR(m_Opcode.ft-1,TRUE); + 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(m_Opcode.ft,CRegInfo::FPU_Double) || RegInStack(m_Opcode.ft,CRegInfo::FPU_Qword)) { - UnMap_FPR(m_Opcode.ft,TRUE); + if (RegInStack(Opcode.ft,CRegInfo::FPU_Double) || RegInStack(Opcode.ft,CRegInfo::FPU_Qword)) { + UnMap_FPR(Opcode.ft,TRUE); } else { - UnMap_FPR(m_Opcode.ft,FALSE); + UnMap_FPR(Opcode.ft,FALSE); } - if (IsConst(m_Opcode.base)) { - DWORD Address = cMipsRegLo(m_Opcode.base) + (short)m_Opcode.offset; + if (IsConst(Opcode.base)) { + DWORD Address = cMipsRegLo(Opcode.base) + (short)Opcode.offset; TempReg1 = Map_TempReg(x86_Any,-1,FALSE); Compile_LW(TempReg1,Address); TempReg2 = Map_TempReg(x86_Any,-1,FALSE); - sprintf(Name,"_FPR_S[%d]",m_Opcode.ft); - MoveVariableToX86reg(&_FPR_S[m_Opcode.ft],Name,TempReg2); + sprintf(Name,"_FPR_S[%d]",Opcode.ft); + MoveVariableToX86reg(&_FPR_S[Opcode.ft],Name,TempReg2); MoveX86regToX86Pointer(TempReg1,TempReg2); return; } - if (IsMapped(m_Opcode.base) && m_Opcode.offset == 0) { + if (IsMapped(Opcode.base) && Opcode.offset == 0) { if (g_UseTlb) { - ProtectGPR(m_Opcode.base); - TempReg1 = cMipsRegMapLo(m_Opcode.base); + ProtectGPR(Opcode.base); + TempReg1 = cMipsRegMapLo(Opcode.base); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } } else { - if (IsMapped(m_Opcode.base)) { - ProtectGPR(m_Opcode.base); - if (m_Opcode.offset != 0) { + if (IsMapped(Opcode.base)) { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) { TempReg1 = Map_TempReg(x86_Any,-1,FALSE); - LeaSourceAndOffset(TempReg1,cMipsRegMapLo(m_Opcode.base),(short)m_Opcode.offset); + LeaSourceAndOffset(TempReg1,cMipsRegMapLo(Opcode.base),(short)Opcode.offset); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } - UnProtectGPR(m_Opcode.base); + UnProtectGPR(Opcode.base); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); - if (m_Opcode.immediate == 0) { - } else if (m_Opcode.immediate == 1) { + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); + if (Opcode.immediate == 0) { + } else if (Opcode.immediate == 1) { IncX86reg(TempReg1); - } else if (m_Opcode.immediate == 0xFFFF) { + } else if (Opcode.immediate == 0xFFFF) { DecX86reg(TempReg1); } else { - AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); + AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } } } @@ -4064,49 +4067,47 @@ void CMipsMemoryVM::Compile_LWC1 (void) { TempReg3 = Map_TempReg(x86_Any,-1,FALSE); MoveN64MemToX86reg(TempReg3,TempReg1); } - sprintf(Name,"_FPR_S[%d]",m_Opcode.ft); - MoveVariableToX86reg(&_FPR_S[m_Opcode.ft],Name,TempReg2); + sprintf(Name,"_FPR_S[%d]",Opcode.ft); + MoveVariableToX86reg(&_FPR_S[Opcode.ft],Name,TempReg2); MoveX86regToX86Pointer(TempReg3,TempReg2); } -void CMipsMemoryVM::Compile_LWL (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix - x86Reg TempReg1, TempReg2, Offset, shift; +void CMipsMemoryVM::Compile_LWL (void) +{ + OPCODE & Opcode = CRecompilerOps::m_Opcode; + x86Reg TempReg1, TempReg2, OffsetReg, shift; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); - if (m_Opcode.rt == 0) return; + if (Opcode.rt == 0) return; - if (IsConst(m_Opcode.base)) { - DWORD Address, Value; - - Address = cMipsRegLo(m_Opcode.base) + (short)m_Opcode.offset; - Offset = Address & 3; + if (IsConst(Opcode.base)) { + DWORD Address = cMipsRegLo(Opcode.base) + (short)Opcode.offset; + DWORD Offset = Address & 3; - Map_GPR_32bit(m_Opcode.rt,TRUE,m_Opcode.rt); - Value = Map_TempReg(x86_Any,-1,FALSE); + Map_GPR_32bit(Opcode.rt,TRUE,Opcode.rt); + x86Reg Value = Map_TempReg(x86_Any,-1,FALSE); Compile_LW(Value,(Address & ~3)); - AndConstToX86Reg(cMipsRegLo(m_Opcode.rt),LWL_MASK[Offset]); + AndConstToX86Reg(cMipsRegMapLo(Opcode.rt),LWL_MASK[Offset]); ShiftLeftSignImmed(Value,(BYTE)LWL_SHIFT[Offset]); - AddX86RegToX86Reg(cMipsRegLo(m_Opcode.rt),Value); + AddX86RegToX86Reg(cMipsRegMapLo(Opcode.rt),Value); return; } shift = Map_TempReg(x86_ECX,-1,FALSE); - if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } - if (IsMapped(m_Opcode.base)) { - ProtectGPR(m_Opcode.base); - if (m_Opcode.offset != 0) { + 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,cMipsRegLo(m_Opcode.base),(short)m_Opcode.offset); + LeaSourceAndOffset(TempReg1,cMipsRegMapLo(Opcode.base),(short)Opcode.offset); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } - UnProtectGPR(m_Opcode.base); + UnProtectGPR(Opcode.base); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); - AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); + AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } if (g_UseTlb) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); @@ -4116,14 +4117,14 @@ void CMipsMemoryVM::Compile_LWL (void) { CompileReadTLBMiss(TempReg1,TempReg2); } - Offset = Map_TempReg(x86_Any,-1,FALSE); - MoveX86RegToX86Reg(TempReg1, Offset); - AndConstToX86Reg(Offset,3); + OffsetReg = Map_TempReg(x86_Any,-1,FALSE); + MoveX86RegToX86Reg(TempReg1, OffsetReg); + AndConstToX86Reg(OffsetReg,3); AndConstToX86Reg(TempReg1,~3); - Map_GPR_32bit(m_Opcode.rt,TRUE,m_Opcode.rt); - AndVariableDispToX86Reg(LWL_MASK,"LWL_MASK",cMipsRegLo(m_Opcode.rt),Offset,4); - MoveVariableDispToX86Reg(LWL_SHIFT,"LWL_SHIFT",shift,Offset,4); + Map_GPR_32bit(Opcode.rt,TRUE,Opcode.rt); + AndVariableDispToX86Reg((void *)LWL_MASK,"LWL_MASK",cMipsRegMapLo(Opcode.rt),OffsetReg,Multip_x4); + MoveVariableDispToX86Reg((void *)LWL_SHIFT,"LWL_SHIFT",shift,OffsetReg,4); if (g_UseTlb) { MoveX86regPointerToX86reg(TempReg1, TempReg2,TempReg1); } else { @@ -4131,48 +4132,45 @@ void CMipsMemoryVM::Compile_LWL (void) { MoveN64MemToX86reg(TempReg1,TempReg1); } ShiftLeftSign(TempReg1); - AddX86RegToX86Reg(cMipsRegLo(m_Opcode.rt),TempReg1); -#endif + AddX86RegToX86Reg(cMipsRegMapLo(Opcode.rt),TempReg1); } -void CMipsMemoryVM::Compile_LWR (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix - x86Reg TempReg1, TempReg2, Offset, shift; +void CMipsMemoryVM::Compile_LWR (void) +{ + OPCODE & Opcode = CRecompilerOps::m_Opcode; + x86Reg TempReg1, TempReg2, OffsetReg, shift; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); - if (m_Opcode.rt == 0) return; + if (Opcode.rt == 0) return; - if (IsConst(m_Opcode.base)) { - DWORD Address, Value; - - Address = cMipsRegLo(m_Opcode.base) + (short)m_Opcode.offset; - Offset = Address & 3; + if (IsConst(Opcode.base)) { + DWORD Address = cMipsRegLo(Opcode.base) + (short)Opcode.offset; + DWORD Offset = Address & 3; - Map_GPR_32bit(m_Opcode.rt,TRUE,m_Opcode.rt); - Value = Map_TempReg(x86_Any,-1,FALSE); + Map_GPR_32bit(Opcode.rt,TRUE,Opcode.rt); + x86Reg Value = Map_TempReg(x86_Any,-1,FALSE); Compile_LW(Value,(Address & ~3)); - AndConstToX86Reg(cMipsRegLo(m_Opcode.rt),LWR_MASK[Offset]); + AndConstToX86Reg(cMipsRegMapLo(Opcode.rt),LWR_MASK[Offset]); ShiftRightUnsignImmed(Value,(BYTE)LWR_SHIFT[Offset]); - AddX86RegToX86Reg(cMipsRegLo(m_Opcode.rt),Value); + AddX86RegToX86Reg(cMipsRegMapLo(Opcode.rt),Value); return; } shift = Map_TempReg(x86_ECX,-1,FALSE); - if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } - if (IsMapped(m_Opcode.base)) { - ProtectGPR(m_Opcode.base); - if (m_Opcode.offset != 0) { + 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,cMipsRegLo(m_Opcode.base),(short)m_Opcode.offset); + LeaSourceAndOffset(TempReg1,cMipsRegMapLo(Opcode.base),(short)Opcode.offset); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } - UnProtectGPR(m_Opcode.base); + UnProtectGPR(Opcode.base); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); - AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); + AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } if (g_UseTlb) { @@ -4183,14 +4181,14 @@ void CMipsMemoryVM::Compile_LWR (void) { CompileReadTLBMiss(TempReg1,TempReg2); } - Offset = Map_TempReg(x86_Any,-1,FALSE); - MoveX86RegToX86Reg(TempReg1, Offset); - AndConstToX86Reg(Offset,3); + OffsetReg = Map_TempReg(x86_Any,-1,FALSE); + MoveX86RegToX86Reg(TempReg1, OffsetReg); + AndConstToX86Reg(OffsetReg,3); AndConstToX86Reg(TempReg1,~3); - Map_GPR_32bit(m_Opcode.rt,TRUE,m_Opcode.rt); - AndVariableDispToX86Reg(LWR_MASK,"LWR_MASK",cMipsRegLo(m_Opcode.rt),Offset,4); - MoveVariableDispToX86Reg(LWR_SHIFT,"LWR_SHIFT",shift,Offset,4); + Map_GPR_32bit(Opcode.rt,TRUE,Opcode.rt); + AndVariableDispToX86Reg((void *)LWR_MASK,"LWR_MASK",cMipsRegMapLo(Opcode.rt),OffsetReg,Multip_x4); + MoveVariableDispToX86Reg((void *)LWR_SHIFT,"LWR_SHIFT",shift,OffsetReg,4); if (g_UseTlb) { MoveX86regPointerToX86reg(TempReg1, TempReg2,TempReg1); } else { @@ -4198,37 +4196,38 @@ void CMipsMemoryVM::Compile_LWR (void) { MoveN64MemToX86reg(TempReg1,TempReg1); } ShiftRightUnsign(TempReg1); - AddX86RegToX86Reg(cMipsRegLo(m_Opcode.rt),TempReg1); -#endif + AddX86RegToX86Reg(cMipsRegMapLo(Opcode.rt),TempReg1); } -void CMipsMemoryVM::Compile_LWU (void) { //added by Witten +void CMipsMemoryVM::Compile_LWU (void) +{ + OPCODE & Opcode = CRecompilerOps::m_Opcode; _Notify->BreakPoint(__FILE__,__LINE__); #ifdef tofix x86Reg TempReg1, TempReg2; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); - if (m_Opcode.rt == 0) return; + if (Opcode.rt == 0) return; - if (IsConst(m_Opcode.base)) { - DWORD Address = (cMipsRegLo(m_Opcode.base) + (short)m_Opcode.offset); - Map_GPR_32bit(m_Opcode.rt,FALSE,0); - Compile_LW(cMipsRegLo(m_Opcode.rt),Address); + if (IsConst(Opcode.base)) { + DWORD Address = (cMipsRegLo(Opcode.base) + (short)Opcode.offset); + Map_GPR_32bit(Opcode.rt,FALSE,0); + Compile_LW(cMipsRegLo(Opcode.rt),Address); return; } - if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } - if (IsMapped(m_Opcode.base)) { - ProtectGPR(m_Opcode.base); - if (m_Opcode.offset != 0) { + 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,cMipsRegLo(m_Opcode.base),(short)m_Opcode.offset); + LeaSourceAndOffset(TempReg1,cMipsRegLo(Opcode.base),(short)Opcode.offset); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); - AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); + AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } if (g_UseTlb) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); @@ -4236,53 +4235,55 @@ void CMipsMemoryVM::Compile_LWU (void) { //added by Witten ShiftRightUnsignImmed(TempReg2,12); MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); CompileReadTLBMiss(TempReg1,TempReg2); - Map_GPR_32bit(m_Opcode.rt,FALSE,-1); - MoveZxHalfX86regPointerToX86reg(TempReg1, TempReg2,cMipsRegLo(m_Opcode.rt)); + Map_GPR_32bit(Opcode.rt,FALSE,-1); + MoveZxHalfX86regPointerToX86reg(TempReg1, TempReg2,cMipsRegLo(Opcode.rt)); } else { AndConstToX86Reg(TempReg1,0x1FFFFFFF); - Map_GPR_32bit(m_Opcode.rt,TRUE,-1); - MoveZxN64MemToX86regHalf(cMipsRegLo(m_Opcode.rt), TempReg1); + Map_GPR_32bit(Opcode.rt,TRUE,-1); + MoveZxN64MemToX86regHalf(cMipsRegLo(Opcode.rt), TempReg1); } #endif } -void CMipsMemoryVM::Compile_LD (void) { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); +void CMipsMemoryVM::Compile_LD (void) +{ + OPCODE & Opcode = CRecompilerOps::m_Opcode; + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); - if (m_Opcode.rt == 0) return; + if (Opcode.rt == 0) return; x86Reg TempReg1, TempReg2; - if (IsConst(m_Opcode.base)) { - DWORD Address = cMipsRegLo(m_Opcode.base) + (short)m_Opcode.offset; - Map_GPR_64bit(m_Opcode.rt,-1); - Compile_LW(cMipsRegMapHi(m_Opcode.rt),Address); - Compile_LW(cMipsRegMapLo(m_Opcode.rt),Address + 4); + if (IsConst(Opcode.base)) { + DWORD Address = cMipsRegLo(Opcode.base) + (short)Opcode.offset; + Map_GPR_64bit(Opcode.rt,-1); + Compile_LW(cMipsRegMapHi(Opcode.rt),Address); + Compile_LW(cMipsRegMapLo(Opcode.rt),Address + 4); #ifdef tofix - if (SPHack && m_Opcode.rt == 29) { _MMU->ResetMemoryStack(m_Section); } + if (SPHack && Opcode.rt == 29) { _MMU->ResetMemoryStack(m_Section); } #endif return; } - if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } - if (IsMapped(m_Opcode.base) && m_Opcode.offset == 0) { + if (IsMapped(Opcode.rt)) { ProtectGPR(Opcode.rt); } + if (IsMapped(Opcode.base) && Opcode.offset == 0) { if (g_UseTlb) { - ProtectGPR(m_Opcode.base); - TempReg1 = cMipsRegMapLo(m_Opcode.base); + ProtectGPR(Opcode.base); + TempReg1 = cMipsRegMapLo(Opcode.base); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } } else { - if (IsMapped(m_Opcode.base)) { - ProtectGPR(m_Opcode.base); - if (m_Opcode.offset != 0) { + if (IsMapped(Opcode.base)) { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) { TempReg1 = Map_TempReg(x86_Any,-1,FALSE); - LeaSourceAndOffset(TempReg1,cMipsRegMapLo(m_Opcode.base),(short)m_Opcode.offset); + LeaSourceAndOffset(TempReg1,cMipsRegMapLo(Opcode.base),(short)Opcode.offset); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); - AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); + AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } } if (g_UseTlb) { @@ -4293,74 +4294,76 @@ void CMipsMemoryVM::Compile_LD (void) { //For tlb miss //0041C522 85 C0 test eax,eax //0041C524 75 01 jne 0041C527 - Map_GPR_64bit(m_Opcode.rt,-1); - MoveX86regPointerToX86reg(TempReg1, TempReg2,cMipsRegMapHi(m_Opcode.rt)); - MoveX86regPointerToX86regDisp8(TempReg1, TempReg2,cMipsRegMapLo(m_Opcode.rt),4); + Map_GPR_64bit(Opcode.rt,-1); + MoveX86regPointerToX86reg(TempReg1, TempReg2,cMipsRegMapHi(Opcode.rt)); + MoveX86regPointerToX86regDisp8(TempReg1, TempReg2,cMipsRegMapLo(Opcode.rt),4); } else { AndConstToX86Reg(TempReg1,0x1FFFFFFF); - Map_GPR_64bit(m_Opcode.rt,-1); - MoveN64MemToX86reg(cMipsRegMapHi(m_Opcode.rt),TempReg1); - MoveN64MemDispToX86reg(cMipsRegMapLo(m_Opcode.rt),TempReg1,4); + Map_GPR_64bit(Opcode.rt,-1); + MoveN64MemToX86reg(cMipsRegMapHi(Opcode.rt),TempReg1); + MoveN64MemDispToX86reg(cMipsRegMapLo(Opcode.rt),TempReg1,4); } #ifdef tofix - if (SPHack && m_Opcode.rt == 29) { + if (SPHack && Opcode.rt == 29) { ResetX86Protection(); _MMU->ResetMemoryStack(m_Section); } #endif } -void CMipsMemoryVM::Compile_LDC1 (void) { +void CMipsMemoryVM::Compile_LDC1 (void) +{ + OPCODE & Opcode = CRecompilerOps::m_Opcode; x86Reg TempReg1, TempReg2, TempReg3; char Name[50]; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); m_Section->CompileCop1Test(); - UnMap_FPR(m_Opcode.ft,FALSE); - if (IsConst(m_Opcode.base)) { - DWORD Address = cMipsRegLo(m_Opcode.base) + (short)m_Opcode.offset; + UnMap_FPR(Opcode.ft,FALSE); + if (IsConst(Opcode.base)) { + DWORD Address = cMipsRegLo(Opcode.base) + (short)Opcode.offset; TempReg1 = Map_TempReg(x86_Any,-1,FALSE); Compile_LW(TempReg1,Address); TempReg2 = Map_TempReg(x86_Any,-1,FALSE); - sprintf(Name,"_FPR_D[%d]",m_Opcode.ft); - MoveVariableToX86reg(&_FPR_D[m_Opcode.ft],Name,TempReg2); + sprintf(Name,"_FPR_D[%d]",Opcode.ft); + MoveVariableToX86reg(&_FPR_D[Opcode.ft],Name,TempReg2); AddConstToX86Reg(TempReg2,4); MoveX86regToX86Pointer(TempReg1,TempReg2); Compile_LW(TempReg1,Address + 4); - sprintf(Name,"_FPR_S[%d]",m_Opcode.ft); - MoveVariableToX86reg(&_FPR_D[m_Opcode.ft],Name,TempReg2); + sprintf(Name,"_FPR_S[%d]",Opcode.ft); + MoveVariableToX86reg(&_FPR_D[Opcode.ft],Name,TempReg2); MoveX86regToX86Pointer(TempReg1,TempReg2); return; } - if (IsMapped(m_Opcode.base) && m_Opcode.offset == 0) { + if (IsMapped(Opcode.base) && Opcode.offset == 0) { if (g_UseTlb) { - ProtectGPR(m_Opcode.base); - TempReg1 = cMipsRegMapLo(m_Opcode.base); + ProtectGPR(Opcode.base); + TempReg1 = cMipsRegMapLo(Opcode.base); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } } else { - if (IsMapped(m_Opcode.base)) { - ProtectGPR(m_Opcode.base); - if (m_Opcode.offset != 0) { + if (IsMapped(Opcode.base)) { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) { TempReg1 = Map_TempReg(x86_Any,-1,FALSE); - LeaSourceAndOffset(TempReg1,cMipsRegMapLo(m_Opcode.base),(short)m_Opcode.offset); + LeaSourceAndOffset(TempReg1,cMipsRegMapLo(Opcode.base),(short)Opcode.offset); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); - if (m_Opcode.immediate == 0) { - } else if (m_Opcode.immediate == 1) { + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); + if (Opcode.immediate == 0) { + } else if (Opcode.immediate == 1) { IncX86reg(TempReg1); - } else if (m_Opcode.immediate == 0xFFFF) { + } else if (Opcode.immediate == 0xFFFF) { DecX86reg(TempReg1); } else { - AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); + AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } } } @@ -4374,88 +4377,94 @@ void CMipsMemoryVM::Compile_LDC1 (void) { TempReg3 = Map_TempReg(x86_Any,-1,FALSE); MoveX86regPointerToX86reg(TempReg1, TempReg2,TempReg3); Push(TempReg2); - sprintf(Name,"_FPR_S[%d]",m_Opcode.ft); - MoveVariableToX86reg(&_FPR_D[m_Opcode.ft],Name,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]",m_Opcode.ft); - MoveVariableToX86reg(&_FPR_D[m_Opcode.ft],Name,TempReg2); + 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); - sprintf(Name,"_FPR_S[%d]",m_Opcode.ft); - MoveVariableToX86reg(&_FPR_D[m_Opcode.ft],Name,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]",m_Opcode.ft); - MoveVariableToX86reg(&_FPR_D[m_Opcode.ft],Name,TempReg2); + sprintf(Name,"_FPR_S[%d]",Opcode.ft); + MoveVariableToX86reg(&_FPR_D[Opcode.ft],Name,TempReg2); MoveX86regToX86Pointer(TempReg3,TempReg2); } } -void CMipsMemoryVM::Compile_LDL (void) { +void CMipsMemoryVM::Compile_LDL (void) +{ + OPCODE & Opcode = CRecompilerOps::m_Opcode; _Notify->BreakPoint(__FILE__,__LINE__); #ifdef tofix - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.base != 0) { UnMap_GPR(m_Opcode.base,TRUE); } - if (m_Opcode.rt != 0) { UnMap_GPR(m_Opcode.rt,TRUE); } - Pushad(); + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + if (Opcode.base != 0) { UnMap_GPR(Opcode.base,TRUE); } + if (Opcode.rt != 0) { UnMap_GPR(Opcode.rt,TRUE); } + BeforeCallDirect(); MoveConstToVariable(Opcode.Hex, &Opcode.Hex, "Opcode.Hex" ); Call_Direct(R4300iOp::LDL, "R4300iOp::LDL"); - Popad(); + AfterCallDirect(); #endif } -void CMipsMemoryVM::Compile_LDR (void) { +void CMipsMemoryVM::Compile_LDR (void) +{ + OPCODE & Opcode = CRecompilerOps::m_Opcode; _Notify->BreakPoint(__FILE__,__LINE__); #ifdef tofix - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.base != 0) { UnMap_GPR(m_Opcode.base,TRUE); } - if (m_Opcode.rt != 0) { UnMap_GPR(m_Opcode.rt,TRUE); } - Pushad(); + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + if (Opcode.base != 0) { UnMap_GPR(Opcode.base,TRUE); } + if (Opcode.rt != 0) { UnMap_GPR(Opcode.rt,TRUE); } + BeforeCallDirect(); MoveConstToVariable(Opcode.Hex, &Opcode.Hex, "Opcode.Hex" ); Call_Direct(R4300iOp::LDR, "R4300iOp::LDR"); - Popad(); + AfterCallDirect(); #endif } -void CMipsMemoryVM::Compile_SB (void){ +void CMipsMemoryVM::Compile_SB (void) +{ + OPCODE & Opcode = CRecompilerOps::m_Opcode; x86Reg TempReg1, TempReg2; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); - if (IsConst(m_Opcode.base)) { - DWORD Address = (cMipsRegLo(m_Opcode.base) + (short)m_Opcode.offset) ^ 3; + if (IsConst(Opcode.base)) { + DWORD Address = (cMipsRegLo(Opcode.base) + (short)Opcode.offset) ^ 3; - if (IsConst(m_Opcode.rt)) { - Compile_SB_Const((BYTE)cMipsRegLo(m_Opcode.rt), Address); - } else if (IsMapped(m_Opcode.rt) && Is8BitReg(cMipsRegMapLo(m_Opcode.rt))) { - Compile_SB_Register(cMipsRegMapLo(m_Opcode.rt), Address); + if (IsConst(Opcode.rt)) { + Compile_SB_Const((BYTE)cMipsRegLo(Opcode.rt), Address); + } else if (IsMapped(Opcode.rt) && Is8BitReg(cMipsRegMapLo(Opcode.rt))) { + Compile_SB_Register(cMipsRegMapLo(Opcode.rt), Address); } else { - Compile_SB_Register(Map_TempReg(x86_Any8Bit,m_Opcode.rt,FALSE), Address); + Compile_SB_Register(Map_TempReg(x86_Any8Bit,Opcode.rt,FALSE), Address); } return; } - if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } - if (IsMapped(m_Opcode.base)) { - ProtectGPR(m_Opcode.base); - if (m_Opcode.offset != 0) { + 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,cMipsRegMapLo(m_Opcode.base),(short)m_Opcode.offset); + LeaSourceAndOffset(TempReg1,cMipsRegMapLo(Opcode.base),(short)Opcode.offset); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } - UnProtectGPR(m_Opcode.base); + UnProtectGPR(Opcode.base); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); - AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); + AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } if (g_UseTlb) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); @@ -4467,58 +4476,60 @@ void CMipsMemoryVM::Compile_SB (void){ //0041C524 75 01 jne 0041C527 XorConstToX86Reg(TempReg1,3); - if (IsConst(m_Opcode.rt)) { - MoveConstByteToX86regPointer((BYTE)cMipsRegLo(m_Opcode.rt),TempReg1, TempReg2); - } else if (IsMapped(m_Opcode.rt) && Is8BitReg(cMipsRegMapLo(m_Opcode.rt))) { - MoveX86regByteToX86regPointer(cMipsRegMapLo(m_Opcode.rt),TempReg1, TempReg2); + if (IsConst(Opcode.rt)) { + MoveConstByteToX86regPointer((BYTE)cMipsRegLo(Opcode.rt),TempReg1, TempReg2); + } else if (IsMapped(Opcode.rt) && Is8BitReg(cMipsRegMapLo(Opcode.rt))) { + MoveX86regByteToX86regPointer(cMipsRegMapLo(Opcode.rt),TempReg1, TempReg2); } else { - UnProtectGPR(m_Opcode.rt); - MoveX86regByteToX86regPointer(Map_TempReg(x86_Any8Bit,m_Opcode.rt,FALSE),TempReg1, TempReg2); + UnProtectGPR(Opcode.rt); + MoveX86regByteToX86regPointer(Map_TempReg(x86_Any8Bit,Opcode.rt,FALSE),TempReg1, TempReg2); } } else { AndConstToX86Reg(TempReg1,0x1FFFFFFF); XorConstToX86Reg(TempReg1,3); - if (IsConst(m_Opcode.rt)) { - MoveConstByteToN64Mem((BYTE)cMipsRegLo(m_Opcode.rt),TempReg1); - } else if (IsMapped(m_Opcode.rt) && Is8BitReg(cMipsRegMapLo(m_Opcode.rt))) { - MoveX86regByteToN64Mem(cMipsRegMapLo(m_Opcode.rt),TempReg1); + if (IsConst(Opcode.rt)) { + MoveConstByteToN64Mem((BYTE)cMipsRegLo(Opcode.rt),TempReg1); + } else if (IsMapped(Opcode.rt) && Is8BitReg(cMipsRegMapLo(Opcode.rt))) { + MoveX86regByteToN64Mem(cMipsRegMapLo(Opcode.rt),TempReg1); } else { - UnProtectGPR(m_Opcode.rt); - MoveX86regByteToN64Mem(Map_TempReg(x86_Any8Bit,m_Opcode.rt,FALSE),TempReg1); + UnProtectGPR(Opcode.rt); + MoveX86regByteToN64Mem(Map_TempReg(x86_Any8Bit,Opcode.rt,FALSE),TempReg1); } } } -void CMipsMemoryVM::Compile_SH (void){ +void CMipsMemoryVM::Compile_SH (void) +{ + OPCODE & Opcode = CRecompilerOps::m_Opcode; x86Reg TempReg1, TempReg2; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); - if (IsConst(m_Opcode.base)) { - DWORD Address = (cMipsRegLo(m_Opcode.base) + (short)m_Opcode.offset) ^ 2; + if (IsConst(Opcode.base)) { + DWORD Address = (cMipsRegLo(Opcode.base) + (short)Opcode.offset) ^ 2; - if (IsConst(m_Opcode.rt)) { - Compile_SH_Const((WORD)cMipsRegLo(m_Opcode.rt), Address); - } else if (IsMapped(m_Opcode.rt)) { - Compile_SH_Register(cMipsRegMapLo(m_Opcode.rt), Address); + if (IsConst(Opcode.rt)) { + Compile_SH_Const((WORD)cMipsRegLo(Opcode.rt), Address); + } else if (IsMapped(Opcode.rt)) { + Compile_SH_Register(cMipsRegMapLo(Opcode.rt), Address); } else { - Compile_SH_Register(Map_TempReg(x86_Any,m_Opcode.rt,FALSE), Address); + Compile_SH_Register(Map_TempReg(x86_Any,Opcode.rt,FALSE), Address); } return; } - if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } - if (IsMapped(m_Opcode.base)) { - ProtectGPR(m_Opcode.base); - if (m_Opcode.offset != 0) { + 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,cMipsRegMapLo(m_Opcode.base),(short)m_Opcode.offset); + LeaSourceAndOffset(TempReg1,cMipsRegMapLo(Opcode.base),(short)Opcode.offset); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } - UnProtectGPR(m_Opcode.base); + UnProtectGPR(Opcode.base); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); - AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); + AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } if (g_UseTlb) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); @@ -4530,71 +4541,72 @@ void CMipsMemoryVM::Compile_SH (void){ //0041C524 75 01 jne 0041C527 XorConstToX86Reg(TempReg1,2); - if (IsConst(m_Opcode.rt)) { - MoveConstHalfToX86regPointer((WORD)cMipsRegLo(m_Opcode.rt),TempReg1, TempReg2); - } else if (IsMapped(m_Opcode.rt)) { - MoveX86regHalfToX86regPointer(cMipsRegMapLo(m_Opcode.rt),TempReg1, TempReg2); + if (IsConst(Opcode.rt)) { + MoveConstHalfToX86regPointer((WORD)cMipsRegLo(Opcode.rt),TempReg1, TempReg2); + } else if (IsMapped(Opcode.rt)) { + MoveX86regHalfToX86regPointer(cMipsRegMapLo(Opcode.rt),TempReg1, TempReg2); } else { - MoveX86regHalfToX86regPointer(Map_TempReg(x86_Any,m_Opcode.rt,FALSE),TempReg1, TempReg2); + MoveX86regHalfToX86regPointer(Map_TempReg(x86_Any,Opcode.rt,FALSE),TempReg1, TempReg2); } } else { AndConstToX86Reg(TempReg1,0x1FFFFFFF); XorConstToX86Reg(TempReg1,2); - if (IsConst(m_Opcode.rt)) { - MoveConstHalfToN64Mem((WORD)cMipsRegLo(m_Opcode.rt),TempReg1); - } else if (IsMapped(m_Opcode.rt)) { - MoveX86regHalfToN64Mem(cMipsRegMapLo(m_Opcode.rt),TempReg1); + if (IsConst(Opcode.rt)) { + MoveConstHalfToN64Mem((WORD)cMipsRegLo(Opcode.rt),TempReg1); + } else if (IsMapped(Opcode.rt)) { + MoveX86regHalfToN64Mem(cMipsRegMapLo(Opcode.rt),TempReg1); } else { - MoveX86regHalfToN64Mem(Map_TempReg(x86_Any,m_Opcode.rt,FALSE),TempReg1); + MoveX86regHalfToN64Mem(Map_TempReg(x86_Any,Opcode.rt,FALSE),TempReg1); } } } void CMipsMemoryVM::Compile_SW (void) { - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + OPCODE & Opcode = CRecompilerOps::m_Opcode; + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); x86Reg TempReg1, TempReg2; #ifdef tofix - if (m_Opcode.base == 29 && SPHack) { - if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } + if (Opcode.base == 29 && SPHack) { + if (IsMapped(Opcode.rt)) { ProtectGPR(Opcode.rt); } TempReg1 = Map_MemoryStack(x86_Any,true); - if (IsConst(m_Opcode.rt)) { - MoveConstToMemoryDisp (cMipsRegLo(m_Opcode.rt),TempReg1, (DWORD)((short)m_Opcode.offset)); - } else if (IsMapped(m_Opcode.rt)) { - MoveX86regToMemory(cMipsRegLo(m_Opcode.rt),TempReg1,(DWORD)((short)m_Opcode.offset)); + if (IsConst(Opcode.rt)) { + MoveConstToMemoryDisp (cMipsRegLo(Opcode.rt),TempReg1, (DWORD)((short)Opcode.offset)); + } else if (IsMapped(Opcode.rt)) { + MoveX86regToMemory(cMipsRegLo(Opcode.rt),TempReg1,(DWORD)((short)Opcode.offset)); } else { - TempReg2 = Map_TempReg(x86_Any,m_Opcode.rt,FALSE); - MoveX86regToMemory(TempReg2,TempReg1,(DWORD)((short)m_Opcode.offset)); + TempReg2 = Map_TempReg(x86_Any,Opcode.rt,FALSE); + MoveX86regToMemory(TempReg2,TempReg1,(DWORD)((short)Opcode.offset)); } } else { #endif - if (IsConst(m_Opcode.base)) { - DWORD Address = cMipsRegLo(m_Opcode.base) + (short)m_Opcode.offset; + if (IsConst(Opcode.base)) { + DWORD Address = cMipsRegLo(Opcode.base) + (short)Opcode.offset; - if (IsConst(m_Opcode.rt)) { - Compile_SW_Const(cMipsRegLo(m_Opcode.rt), Address); - } else if (IsMapped(m_Opcode.rt)) { - Compile_SW_Register(cMipsRegMapLo(m_Opcode.rt), Address); + if (IsConst(Opcode.rt)) { + Compile_SW_Const(cMipsRegLo(Opcode.rt), Address); + } else if (IsMapped(Opcode.rt)) { + Compile_SW_Register(cMipsRegMapLo(Opcode.rt), Address); } else { - Compile_SW_Register(Map_TempReg(x86_Any,m_Opcode.rt,FALSE), Address); + Compile_SW_Register(Map_TempReg(x86_Any,Opcode.rt,FALSE), Address); } return; } - if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } - if (IsMapped(m_Opcode.base)) { - ProtectGPR(m_Opcode.base); - if (m_Opcode.offset != 0) { + 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,cMipsRegMapLo(m_Opcode.base),(short)m_Opcode.offset); + LeaSourceAndOffset(TempReg1,cMipsRegMapLo(Opcode.base),(short)Opcode.offset); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } - UnProtectGPR(m_Opcode.base); + UnProtectGPR(Opcode.base); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); - AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); + AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } if (g_UseTlb) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); @@ -4605,21 +4617,21 @@ void CMipsMemoryVM::Compile_SW (void) //0041C522 85 C0 test eax,eax //0041C524 75 01 jne 0041C527 - if (IsConst(m_Opcode.rt)) { - MoveConstToX86regPointer(cMipsRegLo(m_Opcode.rt),TempReg1, TempReg2); - } else if (IsMapped(m_Opcode.rt)) { - MoveX86regToX86regPointer(cMipsRegMapLo(m_Opcode.rt),TempReg1, TempReg2); + if (IsConst(Opcode.rt)) { + MoveConstToX86regPointer(cMipsRegLo(Opcode.rt),TempReg1, TempReg2); + } else if (IsMapped(Opcode.rt)) { + MoveX86regToX86regPointer(cMipsRegMapLo(Opcode.rt),TempReg1, TempReg2); } else { - MoveX86regToX86regPointer(Map_TempReg(x86_Any,m_Opcode.rt,FALSE),TempReg1, TempReg2); + MoveX86regToX86regPointer(Map_TempReg(x86_Any,Opcode.rt,FALSE),TempReg1, TempReg2); } } else { AndConstToX86Reg(TempReg1,0x1FFFFFFF); - if (IsConst(m_Opcode.rt)) { - MoveConstToN64Mem(cMipsRegLo(m_Opcode.rt),TempReg1); - } else if (IsMapped(m_Opcode.rt)) { - MoveX86regToN64Mem(cMipsRegMapLo(m_Opcode.rt),TempReg1); + if (IsConst(Opcode.rt)) { + MoveConstToN64Mem(cMipsRegLo(Opcode.rt),TempReg1); + } else if (IsMapped(Opcode.rt)) { + MoveX86regToN64Mem(cMipsRegMapLo(Opcode.rt),TempReg1); } else { - MoveX86regToN64Mem(Map_TempReg(x86_Any,m_Opcode.rt,FALSE),TempReg1); + MoveX86regToN64Mem(Map_TempReg(x86_Any,Opcode.rt,FALSE),TempReg1); } } #ifdef tofix @@ -4627,43 +4639,45 @@ void CMipsMemoryVM::Compile_SW (void) #endif } -void CMipsMemoryVM::Compile_SWC1 (void){ +void CMipsMemoryVM::Compile_SWC1 (void) +{ + OPCODE & Opcode = CRecompilerOps::m_Opcode; x86Reg TempReg1, TempReg2, TempReg3; char Name[50]; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); m_Section->CompileCop1Test(); - if (IsConst(m_Opcode.base)) { - DWORD Address = cMipsRegLo(m_Opcode.base) + (short)m_Opcode.offset; + if (IsConst(Opcode.base)) { + DWORD Address = cMipsRegLo(Opcode.base) + (short)Opcode.offset; - UnMap_FPR(m_Opcode.ft,TRUE); + UnMap_FPR(Opcode.ft,TRUE); TempReg1 = Map_TempReg(x86_Any,-1,FALSE); - sprintf(Name,"_FPR_S[%d]",m_Opcode.ft); - MoveVariableToX86reg(&_FPR_S[m_Opcode.ft],Name,TempReg1); + 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(m_Opcode.base)) { - ProtectGPR(m_Opcode.base); - if (m_Opcode.offset != 0) { + if (IsMapped(Opcode.base)) { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) { TempReg1 = Map_TempReg(x86_Any,-1,FALSE); - LeaSourceAndOffset(TempReg1,cMipsRegMapLo(m_Opcode.base),(short)m_Opcode.offset); + LeaSourceAndOffset(TempReg1,cMipsRegMapLo(Opcode.base),(short)Opcode.offset); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); - if (m_Opcode.immediate == 0) { - } else if (m_Opcode.immediate == 1) { + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); + if (Opcode.immediate == 0) { + } else if (Opcode.immediate == 1) { IncX86reg(TempReg1); - } else if (m_Opcode.immediate == 0xFFFF) { + } else if (Opcode.immediate == 0xFFFF) { DecX86reg(TempReg1); } else { - AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); + AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } } if (g_UseTlb) { @@ -4675,58 +4689,58 @@ void CMipsMemoryVM::Compile_SWC1 (void){ //0041C522 85 C0 test eax,eax //0041C524 75 01 jne 0041C527 - UnMap_FPR(m_Opcode.ft,TRUE); + UnMap_FPR(Opcode.ft,TRUE); TempReg3 = Map_TempReg(x86_Any,-1,FALSE); - sprintf(Name,"_FPR_S[%d]",m_Opcode.ft); - MoveVariableToX86reg(&_FPR_S[m_Opcode.ft],Name,TempReg3); + 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(m_Opcode.ft,TRUE); - sprintf(Name,"_FPR_S[%d]",m_Opcode.ft); - MoveVariableToX86reg(&_FPR_S[m_Opcode.ft],Name,TempReg2); + 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) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix - x86Reg TempReg1, TempReg2, Value, Offset, shift; +void CMipsMemoryVM::Compile_SWL (void) +{ + OPCODE & Opcode = CRecompilerOps::m_Opcode; + x86Reg TempReg1, TempReg2, Value, shift, OffsetReg; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); - if (IsConst(m_Opcode.base)) { + if (IsConst(Opcode.base)) { DWORD Address; - Address = cMipsRegLo(m_Opcode.base) + (short)m_Opcode.offset; - Offset = Address & 3; + Address = cMipsRegLo(Opcode.base) + (short)Opcode.offset; + DWORD Offset = Address & 3; Value = Map_TempReg(x86_Any,-1,FALSE); Compile_LW(Value,(Address & ~3)); - AndConstToX86Reg(Value,SWL_MASK[Offset]); - TempReg1 = Map_TempReg(x86_Any,m_Opcode.rt,FALSE); + 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(m_Opcode.base)) { - ProtectGPR(m_Opcode.base); - if (m_Opcode.offset != 0) { + if (IsMapped(Opcode.base)) { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) { TempReg1 = Map_TempReg(x86_Any,-1,FALSE); - LeaSourceAndOffset(TempReg1,cMipsRegLo(m_Opcode.base),(short)m_Opcode.offset); + LeaSourceAndOffset(TempReg1,cMipsRegMapLo(Opcode.base),(short)Opcode.offset); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } - UnProtectGPR(m_Opcode.base); + UnProtectGPR(Opcode.base); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); - AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); + AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } if (g_UseTlb) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); @@ -4739,9 +4753,9 @@ void CMipsMemoryVM::Compile_SWL (void) { //0041C524 75 01 jne 0041C527 } - Offset = Map_TempReg(x86_Any,-1,FALSE); - MoveX86RegToX86Reg(TempReg1, Offset); - AndConstToX86Reg(Offset,3); + OffsetReg = Map_TempReg(x86_Any,-1,FALSE); + MoveX86RegToX86Reg(TempReg1, OffsetReg); + AndConstToX86Reg(OffsetReg,3); AndConstToX86Reg(TempReg1,~3); Value = Map_TempReg(x86_Any,-1,FALSE); @@ -4752,18 +4766,18 @@ void CMipsMemoryVM::Compile_SWL (void) { MoveN64MemToX86reg(Value,TempReg1); } - AndVariableDispToX86Reg(SWL_MASK,"SWL_MASK",Value,Offset,4); - if (!IsConst(m_Opcode.rt) || cMipsRegLo(m_Opcode.rt) != 0) { - MoveVariableDispToX86Reg(SWL_SHIFT,"SWL_SHIFT",shift,Offset,4); - if (IsConst(m_Opcode.rt)) { - MoveConstToX86reg(cMipsRegLo(m_Opcode.rt),Offset); - } else if (IsMapped(m_Opcode.rt)) { - MoveX86RegToX86Reg(cMipsRegLo(m_Opcode.rt),Offset); + AndVariableDispToX86Reg((void *)SWL_MASK,"SWL_MASK",Value,OffsetReg,Multip_x4); + if (!IsConst(Opcode.rt) || cMipsRegLo(Opcode.rt) != 0) { + MoveVariableDispToX86Reg((void *)SWL_SHIFT,"SWL_SHIFT",shift,OffsetReg,4); + if (IsConst(Opcode.rt)) { + MoveConstToX86reg(cMipsRegLo(Opcode.rt),OffsetReg); + } else if (IsMapped(Opcode.rt)) { + MoveX86RegToX86Reg(cMipsRegMapLo(Opcode.rt),OffsetReg); } else { - MoveVariableToX86reg(&_GPR[m_Opcode.rt].UW[0],CRegName::GPR_Lo[m_Opcode.rt],Offset); + MoveVariableToX86reg(&_GPR[Opcode.rt].UW[0],CRegName::GPR_Lo[Opcode.rt],OffsetReg); } - ShiftRightUnsign(Offset); - AddX86RegToX86Reg(Value,Offset); + ShiftRightUnsign(OffsetReg); + AddX86RegToX86Reg(Value,OffsetReg); } if (g_UseTlb) { @@ -4775,44 +4789,41 @@ void CMipsMemoryVM::Compile_SWL (void) { } else { MoveX86regToN64Mem(Value,TempReg1); } -#endif } -void CMipsMemoryVM::Compile_SWR (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix - x86Reg TempReg1, TempReg2, Value, Offset, shift; +void CMipsMemoryVM::Compile_SWR (void) +{ + OPCODE & Opcode = CRecompilerOps::m_Opcode; + x86Reg TempReg1, TempReg2, Value, OffsetReg, shift; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); - if (IsConst(m_Opcode.base)) { - DWORD Address; - - Address = cMipsRegLo(m_Opcode.base) + (short)m_Opcode.offset; - Offset = Address & 3; + if (IsConst(Opcode.base)) { + DWORD Address = cMipsRegLo(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,m_Opcode.rt,FALSE); + 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(m_Opcode.base)) { - ProtectGPR(m_Opcode.base); - if (m_Opcode.offset != 0) { + if (IsMapped(Opcode.base)) { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) { TempReg1 = Map_TempReg(x86_Any,-1,FALSE); - LeaSourceAndOffset(TempReg1,cMipsRegLo(m_Opcode.base),(short)m_Opcode.offset); + LeaSourceAndOffset(TempReg1,cMipsRegMapLo(Opcode.base),(short)Opcode.offset); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } - UnProtectGPR(m_Opcode.base); + UnProtectGPR(Opcode.base); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); - AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); + AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } if (g_UseTlb) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); @@ -4825,9 +4836,9 @@ void CMipsMemoryVM::Compile_SWR (void) { //0041C524 75 01 jne 0041C527 } - Offset = Map_TempReg(x86_Any,-1,FALSE); - MoveX86RegToX86Reg(TempReg1, Offset); - AndConstToX86Reg(Offset,3); + OffsetReg = Map_TempReg(x86_Any,-1,FALSE); + MoveX86RegToX86Reg(TempReg1, OffsetReg); + AndConstToX86Reg(OffsetReg,3); AndConstToX86Reg(TempReg1,~3); Value = Map_TempReg(x86_Any,-1,FALSE); @@ -4838,18 +4849,18 @@ void CMipsMemoryVM::Compile_SWR (void) { MoveN64MemToX86reg(Value,TempReg1); } - AndVariableDispToX86Reg(SWR_MASK,"SWR_MASK",Value,Offset,4); - if (!IsConst(m_Opcode.rt) || cMipsRegLo(m_Opcode.rt) != 0) { - MoveVariableDispToX86Reg(SWR_SHIFT,"SWR_SHIFT",shift,Offset,4); - if (IsConst(m_Opcode.rt)) { - MoveConstToX86reg(cMipsRegLo(m_Opcode.rt),Offset); - } else if (IsMapped(m_Opcode.rt)) { - MoveX86RegToX86Reg(cMipsRegLo(m_Opcode.rt),Offset); + AndVariableDispToX86Reg((void *)SWR_MASK,"SWR_MASK",Value,OffsetReg,Multip_x4); + if (!IsConst(Opcode.rt) || cMipsRegLo(Opcode.rt) != 0) { + MoveVariableDispToX86Reg((void *)SWR_SHIFT,"SWR_SHIFT",shift,OffsetReg,4); + if (IsConst(Opcode.rt)) { + MoveConstToX86reg(cMipsRegLo(Opcode.rt),OffsetReg); + } else if (IsMapped(Opcode.rt)) { + MoveX86RegToX86Reg(cMipsRegMapLo(Opcode.rt),OffsetReg); } else { - MoveVariableToX86reg(&_GPR[m_Opcode.rt].UW[0],CRegName::GPR_Lo[m_Opcode.rt],Offset); + MoveVariableToX86reg(&_GPR[Opcode.rt].UW[0],CRegName::GPR_Lo[Opcode.rt],OffsetReg); } - ShiftLeftSign(Offset); - AddX86RegToX86Reg(Value,Offset); + ShiftLeftSign(OffsetReg); + AddX86RegToX86Reg(Value,OffsetReg); } if (g_UseTlb) { @@ -4861,49 +4872,50 @@ void CMipsMemoryVM::Compile_SWR (void) { } else { MoveX86regToN64Mem(Value,TempReg1); } -#endif } -void CMipsMemoryVM::Compile_SD (void){ +void CMipsMemoryVM::Compile_SD (void) +{ + OPCODE & Opcode = CRecompilerOps::m_Opcode; x86Reg TempReg1, TempReg2; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); - if (IsConst(m_Opcode.base)) { - DWORD Address = cMipsRegLo(m_Opcode.base) + (short)m_Opcode.offset; + if (IsConst(Opcode.base)) { + DWORD Address = cMipsRegLo(Opcode.base) + (short)Opcode.offset; - if (IsConst(m_Opcode.rt)) { - if (Is64Bit(m_Opcode.rt)) { - Compile_SW_Const(MipsRegHi(m_Opcode.rt), Address); + if (IsConst(Opcode.rt)) { + if (Is64Bit(Opcode.rt)) { + Compile_SW_Const(MipsRegHi(Opcode.rt), Address); } else { - Compile_SW_Const((MipsRegLo_S(m_Opcode.rt) >> 31), Address); + Compile_SW_Const((MipsRegLo_S(Opcode.rt) >> 31), Address); } - Compile_SW_Const(cMipsRegLo(m_Opcode.rt), Address + 4); - } else if (IsMapped(m_Opcode.rt)) { - if (Is64Bit(m_Opcode.rt)) { - Compile_SW_Register(MipsRegMapHi(m_Opcode.rt), Address); + Compile_SW_Const(cMipsRegLo(Opcode.rt), Address + 4); + } else if (IsMapped(Opcode.rt)) { + if (Is64Bit(Opcode.rt)) { + Compile_SW_Register(MipsRegMapHi(Opcode.rt), Address); } else { - Compile_SW_Register(Map_TempReg(x86_Any,m_Opcode.rt,TRUE), Address); + Compile_SW_Register(Map_TempReg(x86_Any,Opcode.rt,TRUE), Address); } - Compile_SW_Register(cMipsRegMapLo(m_Opcode.rt), Address + 4); + Compile_SW_Register(cMipsRegMapLo(Opcode.rt), Address + 4); } else { - Compile_SW_Register(TempReg1 = Map_TempReg(x86_Any,m_Opcode.rt,TRUE), Address); - Compile_SW_Register(Map_TempReg(TempReg1,m_Opcode.rt,FALSE), Address + 4); + Compile_SW_Register(TempReg1 = Map_TempReg(x86_Any,Opcode.rt,TRUE), Address); + Compile_SW_Register(Map_TempReg(TempReg1,Opcode.rt,FALSE), Address + 4); } return; } - if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } - if (IsMapped(m_Opcode.base)) { - ProtectGPR(m_Opcode.base); - if (m_Opcode.offset != 0) { + 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,cMipsRegMapLo(m_Opcode.base),(short)m_Opcode.offset); + LeaSourceAndOffset(TempReg1,cMipsRegMapLo(Opcode.base),(short)Opcode.offset); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); - AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); + AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } if (g_UseTlb) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); @@ -4914,97 +4926,99 @@ void CMipsMemoryVM::Compile_SD (void){ //0041C522 85 C0 test eax,eax //0041C524 75 01 jne 0041C527 - if (IsConst(m_Opcode.rt)) { - if (Is64Bit(m_Opcode.rt)) { - MoveConstToX86regPointer(MipsRegHi(m_Opcode.rt),TempReg1, TempReg2); + if (IsConst(Opcode.rt)) { + if (Is64Bit(Opcode.rt)) { + MoveConstToX86regPointer(MipsRegHi(Opcode.rt),TempReg1, TempReg2); } else { - MoveConstToX86regPointer((MipsRegLo_S(m_Opcode.rt) >> 31),TempReg1, TempReg2); + MoveConstToX86regPointer((MipsRegLo_S(Opcode.rt) >> 31),TempReg1, TempReg2); } AddConstToX86Reg(TempReg1,4); - MoveConstToX86regPointer(cMipsRegLo(m_Opcode.rt),TempReg1, TempReg2); - } else if (IsMapped(m_Opcode.rt)) { - if (Is64Bit(m_Opcode.rt)) { - MoveX86regToX86regPointer(MipsRegMapHi(m_Opcode.rt),TempReg1, TempReg2); + MoveConstToX86regPointer(cMipsRegLo(Opcode.rt),TempReg1, TempReg2); + } else if (IsMapped(Opcode.rt)) { + if (Is64Bit(Opcode.rt)) { + MoveX86regToX86regPointer(MipsRegMapHi(Opcode.rt),TempReg1, TempReg2); } else { - MoveX86regToX86regPointer(Map_TempReg(x86_Any,m_Opcode.rt,TRUE),TempReg1, TempReg2); + MoveX86regToX86regPointer(Map_TempReg(x86_Any,Opcode.rt,TRUE),TempReg1, TempReg2); } AddConstToX86Reg(TempReg1,4); - MoveX86regToX86regPointer(cMipsRegMapLo(m_Opcode.rt),TempReg1, TempReg2); + MoveX86regToX86regPointer(cMipsRegMapLo(Opcode.rt),TempReg1, TempReg2); } else { - x86Reg Reg = Map_TempReg(x86_Any,m_Opcode.rt,TRUE); + x86Reg Reg = Map_TempReg(x86_Any,Opcode.rt,TRUE); MoveX86regToX86regPointer(Reg,TempReg1, TempReg2); AddConstToX86Reg(TempReg1,4); - MoveX86regToX86regPointer(Map_TempReg(Reg,m_Opcode.rt,FALSE),TempReg1, TempReg2); + MoveX86regToX86regPointer(Map_TempReg(Reg,Opcode.rt,FALSE),TempReg1, TempReg2); } } else { AndConstToX86Reg(TempReg1,0x1FFFFFFF); - if (IsConst(m_Opcode.rt)) { - if (Is64Bit(m_Opcode.rt)) { - MoveConstToN64Mem(MipsRegHi(m_Opcode.rt),TempReg1); - } else if (IsSigned(m_Opcode.rt)) { - MoveConstToN64Mem((cMipsRegLo_S(m_Opcode.rt) >> 31),TempReg1); + if (IsConst(Opcode.rt)) { + if (Is64Bit(Opcode.rt)) { + MoveConstToN64Mem(MipsRegHi(Opcode.rt),TempReg1); + } else if (IsSigned(Opcode.rt)) { + MoveConstToN64Mem((cMipsRegLo_S(Opcode.rt) >> 31),TempReg1); } else { MoveConstToN64Mem(0,TempReg1); } - MoveConstToN64MemDisp(cMipsRegLo(m_Opcode.rt),TempReg1,4); - } else if (IsKnown(m_Opcode.rt) && IsMapped(m_Opcode.rt)) { - if (Is64Bit(m_Opcode.rt)) { - MoveX86regToN64Mem(MipsRegMapHi(m_Opcode.rt),TempReg1); - } else if (IsSigned(m_Opcode.rt)) { - MoveX86regToN64Mem(Map_TempReg(x86_Any,m_Opcode.rt,TRUE), TempReg1); + MoveConstToN64MemDisp(cMipsRegLo(Opcode.rt),TempReg1,4); + } else if (IsKnown(Opcode.rt) && IsMapped(Opcode.rt)) { + if (Is64Bit(Opcode.rt)) { + MoveX86regToN64Mem(MipsRegMapHi(Opcode.rt),TempReg1); + } else if (IsSigned(Opcode.rt)) { + MoveX86regToN64Mem(Map_TempReg(x86_Any,Opcode.rt,TRUE), TempReg1); } else { MoveConstToN64Mem(0,TempReg1); } - MoveX86regToN64MemDisp(cMipsRegMapLo(m_Opcode.rt),TempReg1, 4); + MoveX86regToN64MemDisp(cMipsRegMapLo(Opcode.rt),TempReg1, 4); } else { x86Reg Reg; - MoveX86regToN64Mem(Reg = Map_TempReg(x86_Any,m_Opcode.rt,TRUE), TempReg1); - MoveX86regToN64MemDisp(Map_TempReg(Reg,m_Opcode.rt,FALSE), TempReg1,4); + MoveX86regToN64Mem(Reg = Map_TempReg(x86_Any,Opcode.rt,TRUE), TempReg1); + MoveX86regToN64MemDisp(Map_TempReg(Reg,Opcode.rt,FALSE), TempReg1,4); } } } -void CMipsMemoryVM::Compile_SDC1 (void){ +void CMipsMemoryVM::Compile_SDC1 (void) +{ + OPCODE & Opcode = CRecompilerOps::m_Opcode; x86Reg TempReg1, TempReg2, TempReg3; char Name[50]; - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); m_Section->CompileCop1Test(); - if (IsConst(m_Opcode.base)) { - DWORD Address = cMipsRegLo(m_Opcode.base) + (short)m_Opcode.offset; + if (IsConst(Opcode.base)) { + DWORD Address = cMipsRegLo(Opcode.base) + (short)Opcode.offset; TempReg1 = Map_TempReg(x86_Any,-1,FALSE); - sprintf(Name,"_FPR_D[%d]",m_Opcode.ft); - MoveVariableToX86reg((BYTE *)&_FPR_D[m_Opcode.ft],Name,TempReg1); + 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); - sprintf(Name,"_FPR_D[%d]",m_Opcode.ft); - MoveVariableToX86reg(&_FPR_D[m_Opcode.ft],Name,TempReg1); + 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(m_Opcode.base)) { - ProtectGPR(m_Opcode.base); - if (m_Opcode.offset != 0) { + if (IsMapped(Opcode.base)) { + ProtectGPR(Opcode.base); + if (Opcode.offset != 0) { TempReg1 = Map_TempReg(x86_Any,-1,FALSE); - LeaSourceAndOffset(TempReg1,cMipsRegMapLo(m_Opcode.base),(short)m_Opcode.offset); + LeaSourceAndOffset(TempReg1,cMipsRegMapLo(Opcode.base),(short)Opcode.offset); } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); } } else { - TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); - if (m_Opcode.immediate == 0) { - } else if (m_Opcode.immediate == 1) { + TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); + if (Opcode.immediate == 0) { + } else if (Opcode.immediate == 1) { IncX86reg(TempReg1); - } else if (m_Opcode.immediate == 0xFFFF) { + } else if (Opcode.immediate == 0xFFFF) { DecX86reg(TempReg1); } else { - AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); + AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } } if (g_UseTlb) { @@ -5017,27 +5031,27 @@ void CMipsMemoryVM::Compile_SDC1 (void){ //0041C524 75 01 jne 0041C527 TempReg3 = Map_TempReg(x86_Any,-1,FALSE); - sprintf(Name,"_FPR_D[%d]",m_Opcode.ft); - MoveVariableToX86reg((BYTE *)&_FPR_D[m_Opcode.ft],Name,TempReg3); + 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]",m_Opcode.ft); - MoveVariableToX86reg((BYTE *)&_FPR_D[m_Opcode.ft],Name,TempReg3); + 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]",m_Opcode.ft); - MoveVariableToX86reg((BYTE *)&_FPR_D[m_Opcode.ft],Name,TempReg3); + 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]",m_Opcode.ft); - MoveVariableToX86reg((BYTE *)&_FPR_D[m_Opcode.ft],Name,TempReg3); + sprintf(Name,"_FPR_D[%d]",Opcode.ft); + MoveVariableToX86reg((BYTE *)&_FPR_D[Opcode.ft],Name,TempReg3); MoveX86PointerToX86reg(TempReg3,TempReg3); MoveX86regToN64MemDisp(TempReg3, TempReg1,4); } @@ -5046,13 +5060,13 @@ void CMipsMemoryVM::Compile_SDC1 (void){ void CMipsMemoryVM::Compile_SDL (void) { _Notify->BreakPoint(__FILE__,__LINE__); #ifdef tofix - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.base != 0) { UnMap_GPR(m_Opcode.base,TRUE); } - if (m_Opcode.rt != 0) { UnMap_GPR(m_Opcode.rt,TRUE); } - Pushad(); + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + if (Opcode.base != 0) { UnMap_GPR(Opcode.base,TRUE); } + if (Opcode.rt != 0) { UnMap_GPR(Opcode.rt,TRUE); } + BeforeCallDirect(); MoveConstToVariable(Opcode.Hex, &Opcode.Hex, "Opcode.Hex" ); Call_Direct(R4300iOp::SDL, "R4300iOp::SDL"); - Popad(); + AfterCallDirect(); #endif } @@ -5060,13 +5074,13 @@ void CMipsMemoryVM::Compile_SDL (void) { void CMipsMemoryVM::Compile_SDR (void) { _Notify->BreakPoint(__FILE__,__LINE__); #ifdef tofix - CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (m_Opcode.base != 0) { UnMap_GPR(m_Opcode.base,TRUE); } - if (m_Opcode.rt != 0) { UnMap_GPR(m_Opcode.rt,TRUE); } - Pushad(); + CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); + if (Opcode.base != 0) { UnMap_GPR(Opcode.base,TRUE); } + if (Opcode.rt != 0) { UnMap_GPR(Opcode.rt,TRUE); } + BeforeCallDirect(); MoveConstToVariable(Opcode.Hex, &Opcode.Hex, "Opcode.Hex" ); Call_Direct(R4300iOp::SDR, "R4300iOp::SDR"); - Popad(); + AfterCallDirect(); #endif } diff --git a/Source/Project64/N64 System/Mips/System Timing.cpp b/Source/Project64/N64 System/Mips/System Timing.cpp index c2828fdc2..92b82ff58 100644 --- a/Source/Project64/N64 System/Mips/System Timing.cpp +++ b/Source/Project64/N64 System/Mips/System Timing.cpp @@ -152,7 +152,14 @@ void CSystemTimer::TimerDone (void) _Reg->CheckInterrupts(); break; case CSystemTimer::ViTimer: - RefreshScreen(); + try + { + _N64System->RefreshScreen(); + } + catch (...) + { + WriteTraceF(TraceError,"Exception caught in Refresh Screen\nFile: %s\nLine: %d",__FILE__,__LINE__); + } _Reg->MI_INTR_REG |= MI_INTR_VI; _Reg->CheckInterrupts(); break; diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index 2b66b5dd2..3546bc112 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -6,26 +6,18 @@ void InitializeCPUCore ( void ) { - LARGE_INTEGER PerformanceFrequency; - g_CurrentFrame = 0; - - QueryPerformanceFrequency(&PerformanceFrequency); - g_Frequency = PerformanceFrequency.QuadPart; - + switch (_Rom->GetCountry()) { - switch (_Rom->GetCountry()) - { - case Germany: case french: case Italian: - case Europe: case Spanish: case Australia: - case X_PAL: case Y_PAL: - Timer_Initialize(50); - g_SystemType = SYSTEM_PAL; - break; - default: - Timer_Initialize(60); - g_SystemType = SYSTEM_NTSC; - break; - } + case Germany: case french: case Italian: + case Europe: case Spanish: case Australia: + case X_PAL: case Y_PAL: + Timer_Initialize(50); + g_SystemType = SYSTEM_PAL; + break; + default: + Timer_Initialize(60); + g_SystemType = SYSTEM_NTSC; + break; } #ifndef EXTERNAL_RELEASE LogOptions.GenerateLog = g_GenerateLog; @@ -54,17 +46,6 @@ CN64System::CN64System ( CPlugins * Plugins, bool SavesReadOnly ) : m_CPU_Handle(NULL), m_CPU_ThreadID(0) { - _Settings->RegisterChangeCB(Plugin_RSP_Current,this,(CSettings::SettingChangedFunc)PluginChanged); - _Settings->RegisterChangeCB(Plugin_GFX_Current,this,(CSettings::SettingChangedFunc)PluginChanged); - _Settings->RegisterChangeCB(Plugin_AUDIO_Current,this,(CSettings::SettingChangedFunc)PluginChanged); - _Settings->RegisterChangeCB(Plugin_CONT_Current,this,(CSettings::SettingChangedFunc)PluginChanged); - _Settings->RegisterChangeCB(Plugin_UseHleGfx,this,(CSettings::SettingChangedFunc)PluginChanged); - _Settings->RegisterChangeCB(Plugin_UseHleAudio,this,(CSettings::SettingChangedFunc)PluginChanged); - _Settings->RegisterChangeCB(Game_EditPlugin_Gfx,this,(CSettings::SettingChangedFunc)PluginChanged); - _Settings->RegisterChangeCB(Game_EditPlugin_Audio,this,(CSettings::SettingChangedFunc)PluginChanged); - _Settings->RegisterChangeCB(Game_EditPlugin_Contr,this,(CSettings::SettingChangedFunc)PluginChanged); - _Settings->RegisterChangeCB(Game_EditPlugin_RSP,this,(CSettings::SettingChangedFunc)PluginChanged); - //InterpreterOpcode = NULL; m_hPauseEvent = CreateEvent(NULL,true,false,NULL); @@ -90,23 +71,6 @@ CN64System::CN64System ( CPlugins * Plugins, bool SavesReadOnly ) : CN64System::~CN64System ( void ) { } -void CN64System::PluginChanged ( CN64System * _this ) -{ - if (_Settings->LoadBool(GameRunning_LoadingInProgress)) - { - return; - } - if (_Settings->LoadBool(GameRunning_CPU_Running) != 0) { - _this->ExternalEvent(SysEvent_ChangePlugins); - } else { - _this->Plugins()->Reset(); - if (_Notify) - { - _Notify->RefreshMenu(); - } - } -} - void CN64System::ExternalEvent ( SystemEvent action ) { @@ -247,7 +211,6 @@ bool CN64System::RunFileImage ( const char * FileLoc ) bool CN64System::EmulationStarting ( HANDLE hThread, DWORD ThreadId ) { -// _Plugins->Reset(); bool bRes = true; if (_N64System) @@ -622,6 +585,7 @@ bool CN64System::SetActiveSystem( bool bActive ) _TransVaddr = &m_MMU_VM; _SystemEvents = this; _NextTimer = &m_NextTimer; + _Plugins = m_Plugins; } else { if (_N64System == this) { @@ -637,6 +601,7 @@ bool CN64System::SetActiveSystem( bool bActive ) _TransVaddr = NULL; _SystemEvents = NULL; _NextTimer = NULL; + _Plugins = m_Plugins; } } @@ -826,11 +791,9 @@ void CN64System::ExecuteCPU ( void ) g_RomFileSize = _Rom->GetRomSize(); g_CicChip = _Rom->CicChipID(); - g_CurrentFrame = 0; CC_Core C_Core; C_Core.SetSettings(); - C_Core.SetSyncCpu(NULL); switch ((CPU_TYPE)_Settings->LoadDword(Game_CpuType)) { case CPU_Recompiler: ExecuteRecompiler(C_Core); break; @@ -843,6 +806,7 @@ void CN64System::ExecuteCPU ( void ) void CN64System::ExecuteInterpret (CC_Core & C_Core) { InitializeCPUCore(); + SetActiveSystem(); CInterpreterCPU::ExecuteCPU(); } @@ -851,6 +815,7 @@ void CN64System::ExecuteRecompiler (CC_Core & C_Core) //execute opcodes while no errors m_Recomp = new CRecompiler(m_Profile,m_EndEmulation); InitializeCPUCore(); + SetActiveSystem(); m_Recomp->Run(); } @@ -892,16 +857,6 @@ void CN64System::CpuStopped ( void ) { m_hPauseEvent = NULL; } - _Settings->UnregisterChangeCB(Plugin_RSP_Current,this,(CSettings::SettingChangedFunc)PluginChanged); - _Settings->UnregisterChangeCB(Plugin_GFX_Current,this,(CSettings::SettingChangedFunc)PluginChanged); - _Settings->UnregisterChangeCB(Plugin_AUDIO_Current,this,(CSettings::SettingChangedFunc)PluginChanged); - _Settings->UnregisterChangeCB(Plugin_CONT_Current,this,(CSettings::SettingChangedFunc)PluginChanged); - _Settings->UnregisterChangeCB(Plugin_UseHleGfx,this,(CSettings::SettingChangedFunc)PluginChanged); - _Settings->UnregisterChangeCB(Plugin_UseHleAudio,this,(CSettings::SettingChangedFunc)PluginChanged); - _Settings->UnregisterChangeCB(Game_EditPlugin_Gfx,this,(CSettings::SettingChangedFunc)PluginChanged); - _Settings->UnregisterChangeCB(Game_EditPlugin_Audio,this,(CSettings::SettingChangedFunc)PluginChanged); - _Settings->UnregisterChangeCB(Game_EditPlugin_Contr,this,(CSettings::SettingChangedFunc)PluginChanged); - _Settings->UnregisterChangeCB(Game_EditPlugin_RSP,this,(CSettings::SettingChangedFunc)PluginChanged); _Notify->RefreshMenu(); _Notify->MakeWindowOnTop(false); _Notify->DisplayMessage(5,MSG_EMULATION_ENDED); @@ -964,6 +919,9 @@ void CN64System::SyncCPU (CN64System * const SecondCPU) { 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; } for (int z = 0; z < 0x100; z++) { @@ -984,6 +942,7 @@ void CN64System::SyncCPU (CN64System * const SecondCPU) { #endif } + if (m_Audio.AiGetLength() != SecondCPU->m_Audio.AiGetLength()) { ErrorFound = true; } if (m_SystemTimer.CurrentType() != SecondCPU->m_SystemTimer.CurrentType()) { ErrorFound = true; } if (m_NextTimer != SecondCPU->m_NextTimer) { ErrorFound = true; } if (m_Reg.m_RoundingModel != SecondCPU->m_Reg.m_RoundingModel) { ErrorFound = true; } @@ -1033,10 +992,16 @@ void CN64System::DumpSyncErrors (CN64System * SecondCPU) { 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] Different,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] Different,0x%08X, 0x%08X\r\n",CRegName::Cop0[count], - m_Reg.m_CP0[count], SecondCPU->m_Reg.m_CP0[count]); + m_Reg.m_CP0[count], SecondCPU->m_Reg.m_CP0[count]); } } if (m_NextTimer != SecondCPU->m_NextTimer) diff --git a/Source/Project64/N64 System/N64 Class.h b/Source/Project64/N64 System/N64 Class.h index 4ed430841..bc291e346 100644 --- a/Source/Project64/N64 System/N64 Class.h +++ b/Source/Project64/N64 System/N64 Class.h @@ -68,6 +68,7 @@ private: //Recompiler has access to manipulate and call functions friend CC_Core; + friend CSystemTimer; //Used for loading and potentialy executing the CPU in its own thread. static void stLoadFileImage ( FileImageInfo * Info ); @@ -103,8 +104,6 @@ private: void CpuStopped ( void ); void Pause ( void ); - static void PluginChanged ( CN64System * _this ); - //Function in CMipsMemory_CallBack virtual bool WriteToProtectedMemory (DWORD Address, int length); diff --git a/Source/Project64/N64 System/Profiling Class.cpp b/Source/Project64/N64 System/Profiling Class.cpp index 0b49e11c4..d6a7297a4 100644 --- a/Source/Project64/N64 System/Profiling Class.cpp +++ b/Source/Project64/N64 System/Profiling Class.cpp @@ -1,6 +1,4 @@ -#include "..\N64 System.h" - -#include +#include "stdafx.h" enum { MAX_FRAMES = 13 }; diff --git a/Source/Project64/N64 System/Recompiler/Code Block.h b/Source/Project64/N64 System/Recompiler/Code Block.h index ea6c30843..96a03f278 100644 --- a/Source/Project64/N64 System/Recompiler/Code Block.h +++ b/Source/Project64/N64 System/Recompiler/Code Block.h @@ -2,7 +2,7 @@ class CCodeBlock : private CRecompilerOps { public: - CCodeBlock(DWORD VAddrEnter, BYTE * RecompPos); + CCodeBlock(DWORD VAddrEnter, BYTE * RecompPos, bool bDelaySlot ); bool Compile ( void ); @@ -13,6 +13,7 @@ public: inline int NoOfSections ( void ) const { return m_NoOfSections; } inline const CCodeSection & EnterSection ( void ) const { return m_EnterSection; } inline DWORD NextTest ( void ) const { return m_EnterSection.m_Test + 1; } + inline bool bDelaySlot ( void ) const { return m_bDelaySlot; } inline void SetVAddrFirst ( DWORD VAddr ) { m_VAddrFirst = VAddr; } inline void SetVAddrLast ( DWORD VAddr ) { m_VAddrLast = VAddr; } @@ -28,5 +29,6 @@ private: DWORD m_VAddrLast; // the address of the first opcode in the block BYTE * m_CompiledLocation; // What address is this compiled at int m_NoOfSections; // The number of sections this block uses - CCodeSection m_EnterSection; + bool m_bDelaySlot; + CCodeSection m_EnterSection; }; diff --git a/Source/Project64/N64 System/Recompiler/Code Section.cpp b/Source/Project64/N64 System/Recompiler/Code Section.cpp index a4ff70cb4..aafa08886 100644 --- a/Source/Project64/N64 System/Recompiler/Code Section.cpp +++ b/Source/Project64/N64 System/Recompiler/Code Section.cpp @@ -82,6 +82,7 @@ CCodeSection::CCodeSection( CCodeBlock * CodeBlock, DWORD EnterPC, DWORD ID) : m_JumpSection(NULL), m_LinkAllowed(true), m_CompiledLocation(NULL), + m_DelaySlotSection(CodeBlock? CodeBlock->bDelaySlot() : false), m_Test(0) { /* @@ -329,8 +330,6 @@ void CCodeSection::GenerateSectionLinkage (void) } if ((CRecompilerOps::CompilePC() & 0xFFC) == 0xFFC) { - _Notify->BreakPoint(__FILE__,__LINE__); - #ifdef tofix //Handle Fall througth BYTE * Jump = NULL; for (count = 0; count < 2; count ++) { @@ -344,7 +343,7 @@ void CCodeSection::GenerateSectionLinkage (void) JumpInfo[count]->LinkLocation2 = NULL; } } - MoveConstToVariable(JumpInfo[count]->TargetPC,&JumpToLocation,"JumpToLocation"); + PushImm32(stdstr_f("0x%08X",JumpInfo[count]->TargetPC).c_str(),JumpInfo[count]->TargetPC); if (JumpInfo[(count + 1) & 1]->LinkLocation == NULL) { break; } JmpLabel8("FinishBlock",0); Jump = m_RecompPos - 1; @@ -360,7 +359,7 @@ void CCodeSection::GenerateSectionLinkage (void) JumpInfo[count]->LinkLocation2 = NULL; } } - MoveConstToVariable(JumpInfo[count]->TargetPC,&JumpToLocation,"JumpToLocation"); + PushImm32(stdstr_f("0x%08X",JumpInfo[count]->TargetPC).c_str(),JumpInfo[count]->TargetPC); if (JumpInfo[(count + 1) & 1]->LinkLocation == NULL) { break; } JmpLabel8("FinishBlock",0); Jump = m_RecompPos - 1; @@ -369,31 +368,33 @@ void CCodeSection::GenerateSectionLinkage (void) CPU_Message(" $FinishBlock:"); SetJump8(Jump,m_RecompPos); } - MoveConstToVariable(CRecompilerOps::CompilePC() + 4,_PROGRAM_COUNTER,"PROGRAM_COUNTER"); + //MoveConstToVariable(CRecompilerOps::CompilePC() + 4,_PROGRAM_COUNTER,"PROGRAM_COUNTER"); m_RegWorkingSet.WriteBackRegisters(); - m_RegWorkingSet.UpdateCounters(&BlockCycleCount(),&BlockRandomModifier(),false); + UpdateCounters(m_RegWorkingSet,false,true); // WriteBackRegisters(Section); // if (_SyncSystem) { Call_Direct(SyncToPC, "SyncToPC"); } - MoveConstToVariable(DELAY_SLOT,&NextInstruction,"NextInstruction"); + // MoveConstToVariable(DELAY_SLOT,&NextInstruction,"NextInstruction"); + PushImm32(stdstr_f("0x%08X",CRecompilerOps::CompilePC() + 4).c_str(),CRecompilerOps::CompilePC() + 4); + + // check if there is an existing section + + MoveConstToX86reg((DWORD)_Recompiler,x86_ECX); + Call_Direct(AddressOf(CRecompiler::CompileDelaySlot), "CRecompiler::CompileDelaySlot"); + JmpDirectReg(x86_EAX); ExitCodeBlock(); - #endif return; } if (!g_UseLinking) { if (CRecompilerOps::m_CompilePC == m_Jump.TargetPC && (m_Cont.FallThrough == false)) { if (!DelaySlotEffectsJump(CRecompilerOps::CompilePC())) { -CPU_Message("PermLoop *** a"); -_Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix MoveConstToVariable(CRecompilerOps::CompilePC(),_PROGRAM_COUNTER,"PROGRAM_COUNTER"); m_RegWorkingSet.WriteBackRegisters(); - m_RegWorkingSet.BlockCycleCount() -= g_CountPerOp; - UpdateCounters(&m_RegWorkingSet.BlockCycleCount(),&m_RegWorkingSet.BlockRandomModifier(), false); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_CountPerOp) ; + UpdateCounters(m_RegWorkingSet,false, true); Call_Direct(InPermLoop,"InPermLoop"); - m_RegWorkingSet.BlockCycleCount() += g_CountPerOp; - UpdateCounters(&m_RegWorkingSet.BlockCycleCount(),&m_RegWorkingSet.BlockRandomModifier(), true); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_CountPerOp) ; + UpdateCounters(m_RegWorkingSet,true,true); CompileSystemCheck(-1,m_RegWorkingSet); -#endif } } } @@ -650,7 +651,7 @@ bool CCodeSection::GenerateX86Code ( DWORD Test ) m_RegWorkingSet = m_RegEnter; m_CompiledLocation = m_RecompPos; m_CompilePC = m_EnterPC; - m_NextInstruction = NORMAL; + m_NextInstruction = m_DelaySlotSection ? END_BLOCK : NORMAL; m_RegWorkingSet = m_RegEnter; m_Section = this; @@ -675,22 +676,26 @@ bool CCodeSection::GenerateX86Code ( DWORD Test ) { m_BlockInfo->SetVAddrLast(m_CompilePC); } + /*if (m_CompilePC == 0x80194A40) + { + // m_RegWorkingSet.UnMap_AllFPRs(); + }*/ + /*if (m_CompilePC >= 0x802CF644 && m_CompilePC <= 0x802CF650 && m_NextInstruction == NORMAL) + { + m_RegWorkingSet.WriteBackRegisters(); + UpdateCounters(m_RegWorkingSet,false,true); + MoveConstToVariable(m_CompilePC,&_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER"); + if (_SyncSystem) { Call_Direct(SyncToPC, "SyncToPC"); } + }*/ - /*if (m_CompilePC >= 0x803259A0 && m_CompilePC < 0x803259D8 && m_NextInstruction == NORMAL) + /*if (m_CompilePC == 0x803254F0 && m_NextInstruction == NORMAL) { m_RegWorkingSet.WriteBackRegisters(); UpdateCounters(m_RegWorkingSet,false,true); MoveConstToVariable(m_CompilePC,&_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER"); if (_SyncSystem) { Call_Direct(SyncToPC, "SyncToPC"); } - } - if (m_CompilePC == 0x803259AC && m_NextInstruction == NORMAL) - { - m_RegWorkingSet.WriteBackRegisters(); - UpdateCounters(m_RegWorkingSet,false,true); - MoveConstToVariable(m_CompilePC,&_Reg->m_PROGRAM_COUNTER,"PROGRAM_COUNTER"); - if (_SyncSystem) { Call_Direct(SyncToPC, "SyncToPC"); } - } - if (m_CompilePC == 0x803259C0) + }*/ + /*if (m_CompilePC == 0x803254F0 && m_NextInstruction == NORMAL) { X86BreakPoint(__FILE__,__LINE__); }*/ @@ -933,46 +938,24 @@ bool CCodeSection::GenerateX86Code ( DWORD Test ) UnknownOpcode(); break; } + #ifdef tofix if (!bRegCaching()) { WriteBackRegisters(); } - - /*if ((DWORD)RecompPos > 0x60B452E6) { - if (m_CompilePC == 0x8002D9B8 && m_CompilePC < 0x8002DA20) { - CurrentRoundingModel = RoundUnknown; - } - }*/ - UnMap_AllFPRs(); - - /*if ((DWORD)RecompPos > 0x60AD0BD3) { - if (m_CompilePC >= 0x8008B804 && m_CompilePC < 0x800496D8) { - CPU_Message("Blah *"); - WriteBackRegisters(); - } - /*if (m_CompilePC >= 0x80000180 && m_CompilePC < 0x80000190) { - CPU_Message("Blah *"); - //WriteBackRegisters(); - }*/ - //} - - /*for (count = 1; count < 10; count ++) { - if (x86Mapped(count) == CRegInfo::Stack_Mapped) { - UnMap_X86reg (Section, count); - } - }*/ - //CPU_Message("MemoryStack = %s",Map_MemoryStack(Section, false) > 0?x86_Name(Map_MemoryStack(Section, false)):"Not Mapped"); - - if ((m_CompilePC &0xFFC) == 0xFFC) { - if (NextInstruction == DO_DELAY_SLOT) { - #ifndef EXTERNAL_RELEASE - DisplayError("Wanting to do delay slot over end of block"); #endif + + if ((m_CompilePC &0xFFC) == 0xFFC) + { + if (m_NextInstruction == DO_DELAY_SLOT) + { + DisplayError("Wanting to do delay slot over end of block"); } - if (NextInstruction == NORMAL) { - CompileExit (Section,m_CompilePC, m_CompilePC + 4,m_RegWorkingSet,CExitInfo::Normal,true,NULL); - NextInstruction = END_BLOCK; + if (m_NextInstruction == NORMAL) { + CompileExit (m_CompilePC, m_CompilePC + 4,m_RegWorkingSet,CExitInfo::Normal,true,NULL); + m_NextInstruction = END_BLOCK; } } + #ifdef tofix if (DelaySlotSection) { Cont.RegSet = m_RegWorkingSet; @@ -997,5 +980,9 @@ bool CCodeSection::GenerateX86Code ( DWORD Test ) } } while (m_NextInstruction != END_BLOCK); + if (m_DelaySlotSection) + { + CompileExit (m_CompilePC, -1,m_RegWorkingSet,CExitInfo::Normal,true,NULL); + } return true; } diff --git a/Source/Project64/N64 System/Recompiler/Code Section.h b/Source/Project64/N64 System/Recompiler/Code Section.h index ffa4bc753..22598f436 100644 --- a/Source/Project64/N64 System/Recompiler/Code Section.h +++ b/Source/Project64/N64 System/Recompiler/Code Section.h @@ -24,12 +24,11 @@ public: bool m_LinkAllowed; // are other sections allowed to find block to link to it DWORD m_Test; BYTE * m_CompiledLocation; + bool m_DelaySlotSection; /* SECTION_LIST ParentSection; - DWORD Test2; bool InLoop; - bool DelaySlotSection; /* Register Info */ @@ -39,54 +38,6 @@ public: CJumpInfo m_Jump; CJumpInfo m_Cont; - //Information about the opcode current being compiled -/* DWORD m_CompilePC; - OPCODE m_CompileOpcode; - - void AddParent ( CCodeSection * Parent ); - void UnlinkParent ( CCodeSection * Parent, bool AllowDelete, bool ContinueLink ); - bool IsAllParentLoops ( CCodeSection * Parent, bool IgnoreIfCompiled, DWORD Test ); - void ResetX86Protection ( void ); - static DWORD GetNewTestValue ( void ); - - static void TestRegConstantStates ( CRegInfo & Base, CRegInfo & Reg ); - - //Handy Functions - inline CRegInfo::REG_STATE & MipsRegState ( int Reg ) { return RegWorking.MipsRegState(Reg); } - inline unsigned _int64 & MipsReg ( int Reg ) { return RegWorking.MipsReg(Reg); } - inline _int64 & MipsReg_S ( int Reg ) { return RegWorking.MipsReg_S(Reg); } - inline DWORD & MipsRegLo ( int Reg ) { return RegWorking.MipsRegLo(Reg); } - inline long & MipsRegLo_S ( int Reg ) { return RegWorking.MipsRegLo_S(Reg); } - inline DWORD & MipsRegHi ( int Reg ) { return RegWorking.MipsRegHi(Reg); } - inline long & MipsRegHi_S ( int Reg ) { return RegWorking.MipsRegHi_S(Reg); } - inline DWORD & BlockCycleCount(void) { return RegWorking.BlockCycleCount(); } - inline DWORD & BlockRandomModifier(void) { return RegWorking.BlockRandomModifier(); } - - inline DWORD & x86MapOrder( int Reg ) { return RegWorking.x86MapOrder(Reg); } - inline bool & x86Protected( int Reg ) { return RegWorking.x86Protected(Reg); } - inline CRegInfo::REG_MAPPED & x86Mapped(int Reg) { return RegWorking.x86Mapped(Reg); } - - inline bool IsKnown(int Reg) { return RegWorking.IsKnown(Reg); } - inline bool IsUnknown(int Reg) { return RegWorking.IsUnknown(Reg); } - - inline bool IsMapped(int Reg) { return RegWorking.IsMapped(Reg); } - inline bool IsConst(int Reg) { return RegWorking.IsConst(Reg); } - - inline bool IsSigned(int Reg) { return RegWorking.IsSigned(Reg); } - inline bool IsUnsigned(int Reg) { return RegWorking.IsUnsigned(Reg); } - - inline bool Is32Bit(int Reg) { return RegWorking.Is32Bit(Reg); } - inline bool Is64Bit(int Reg) { return RegWorking.Is64Bit(Reg); } - - inline bool Is32BitMapped(int Reg) { return RegWorking.Is32BitMapped(Reg); } - inline bool Is64BitMapped(int Reg) { return RegWorking.Is64BitMapped(Reg); } - - inline int & StackTopPos ( void ) { return RegWorking.StackTopPos(); } - inline DWORD & FpuMappedTo( int Reg) { return RegWorking.FpuMappedTo(Reg); } - inline CRegInfo::FPU_STATE & FpuState(int Reg) { return RegWorking.FpuState(Reg); } - inline CRegInfo::FPU_ROUND & FpuRoundingModel(int Reg) { return RegWorking.FpuRoundingModel(Reg); } - inline bool & FpuBeenUsed (void ) { return RegWorking.FpuBeenUsed(); } - inline CRegInfo::FPU_ROUND & CurrentRoundingModel ( void ) { return RegWorking.CurrentRoundingModel(); }*/ private: diff --git a/Source/Project64/N64 System/Recompiler/Function Map Class.cpp b/Source/Project64/N64 System/Recompiler/Function Map Class.cpp index 0edae1454..424d156e6 100644 --- a/Source/Project64/N64 System/Recompiler/Function Map Class.cpp +++ b/Source/Project64/N64 System/Recompiler/Function Map Class.cpp @@ -1,7 +1,8 @@ #include "stdafx.h" CFunctionMap::CFunctionMap() : - m_FunctionTable(NULL) + m_FunctionTable(NULL), + m_DelaySlotTable(NULL) { } @@ -19,6 +20,11 @@ CFunctionMap::~CFunctionMap() VirtualFree( m_FunctionTable, 0 , MEM_RELEASE); m_FunctionTable = NULL; } + if (m_DelaySlotTable) + { + VirtualFree( m_DelaySlotTable, 0 , MEM_RELEASE); + m_DelaySlotTable = NULL; + } } bool CFunctionMap::AllocateMemory() @@ -32,6 +38,15 @@ bool CFunctionMap::AllocateMemory() } memset(m_FunctionTable,0,0xFFFFF * sizeof(CCompiledFunc *)); } + if (m_DelaySlotTable == NULL) + { + m_DelaySlotTable = (BYTE **)VirtualAlloc(NULL,0xFFFFF * sizeof(BYTE *),MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE); + if (m_DelaySlotTable == NULL) { + _Notify->FatalError(MSG_MEM_ALLOC_ERROR); + return false; + } + memset(m_DelaySlotTable,0,0xFFFFF * sizeof(BYTE *)); + } return true; } diff --git a/Source/Project64/N64 System/Recompiler/Function Map Class.h b/Source/Project64/N64 System/Recompiler/Function Map Class.h index 17bc5fae8..f1dec346f 100644 --- a/Source/Project64/N64 System/Recompiler/Function Map Class.h +++ b/Source/Project64/N64 System/Recompiler/Function Map Class.h @@ -10,40 +10,5 @@ protected: bool AllocateMemory ( void ); PCCompiledFunc_TABLE * m_FunctionTable; - -/*public: - typedef CCompiledFunc * PCCompiledFunc; - typedef PCCompiledFunc * PCCompiledFunc_TABLE; - -private: - void Reset ( bool AllocateMemory ); - - PCCompiledFunc_TABLE * m_FunctionTable; - -public: - CFunctionMap ( void ); - ~CFunctionMap ( void ); - - CCompiledFunc * AddFunctionInfo ( DWORD vAddr, DWORD pAddr ); - CCompiledFunc * FindFunction ( DWORD vAddr, int Length ); - - static void * __fastcall CFunctionMap::CompilerFindFunction( CFunctionMap * _this, DWORD vAddr ); - inline CCompiledFunc * CFunctionMap::FindFunction( DWORD vAddr ) const - { - PCCompiledFunc_TABLE table = m_FunctionTable[vAddr >> 0xC]; - if (table) - { - PCCompiledFunc & info = table[(vAddr & 0xFFF) >> 2]; - if (info != NULL) - { - return info; - } - } - return NULL; - } - - PCCompiledFunc_TABLE * GetFunctionTable ( void ) { return m_FunctionTable; } - - inline void Reset (void) { Reset(true); } - void Remove (CCompiledFunc * info);*/ + BYTE ** m_DelaySlotTable; }; diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp index a297c8097..c3369ea19 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp @@ -528,210 +528,33 @@ void CRecompiler::ResetRecompCode() */ } -CCompiledFunc * CRecompiler::CompileDelaySlot(DWORD PC) +BYTE * CRecompiler::CompileDelaySlot(DWORD PC) { + int Index = PC >> 0xC; + BYTE * delayFunc = m_DelaySlotTable[Index]; + if (delayFunc) + { + return delayFunc; + } WriteTraceF(TraceRecompiler,"Compile Delay Slot: %X",PC); - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix if ((PC & 0xFFC) != 0) { DisplayError("Why are you compiling the Delay Slot at %X",PC); return NULL; } - if (!_MMU->LW_VAddr(PC, g_Opcode.Hex)) { - DisplayError("TLB Miss in delay slot\nEmulation will know stop"); - return NULL; - } + CheckRecompMem(); - CCompiledFunc * info = m_FunctionsDelaySlot.AddFunctionInfo(PC, _TLB->TranslateVaddr(PC)); - - CCodeBlock BlockInfo(PROGRAM_COUNTER, RecompPos()); - CCodeSection * Section = &BlockInfo.ParentSection; - - BYTE * Block = RecompPos(); - DWORD StartAddress; - if (!TranslateVaddr(PC, &StartAddress)) + CCodeBlock CodeBlock(PC, RecompPos(), true); + if (!CodeBlock.Compile()) { return NULL; } - if (StartAddress < RdramSize()) { - CPU_Message("====== RDRAM: Delay Slot ======"); - } else if (StartAddress >= 0x04000000 && StartAddress <= 0x04000FFC) { - CPU_Message("====== DMEM: Delay Slot ======"); - } else if (StartAddress >= 0x04001000 && StartAddress <= 0x04001FFC) { - CPU_Message("====== IMEM: Delay Slot ======"); - } else if (StartAddress >= 0x1FC00000 && StartAddress <= 0x1FC00800) { - CPU_Message("====== PIF ROM: Delay Slot ======"); - } else { - CPU_Message("====== Unknown: Delay Slot ======"); - } - CPU_Message("x86 code at: %X",Block); - CPU_Message("Delay Slot location: %X",PROGRAM_COUNTER ); - CPU_Message("====== recompiled code ======"); - - Section->AddParent(NULL); - Section->BlockCycleCount() += CountPerOp(); - Section->BlockRandomModifier() += 1; - - switch (Opcode.op) { - case R4300i_SPECIAL: - switch (Opcode.funct) { - case R4300i_SPECIAL_SLL: Compile_R4300i_SPECIAL_SLL(Section); break; - case R4300i_SPECIAL_SRL: Compile_R4300i_SPECIAL_SRL(Section); break; - case R4300i_SPECIAL_SRA: Compile_R4300i_SPECIAL_SRA(Section); break; - case R4300i_SPECIAL_SLLV: Compile_R4300i_SPECIAL_SLLV(Section); break; - case R4300i_SPECIAL_SRLV: Compile_R4300i_SPECIAL_SRLV(Section); break; - case R4300i_SPECIAL_SRAV: Compile_R4300i_SPECIAL_SRAV(Section); break; - case R4300i_SPECIAL_MFLO: Compile_R4300i_SPECIAL_MFLO(Section); break; - case R4300i_SPECIAL_MTLO: Compile_R4300i_SPECIAL_MTLO(Section); break; - case R4300i_SPECIAL_MFHI: Compile_R4300i_SPECIAL_MFHI(Section); break; - case R4300i_SPECIAL_MTHI: Compile_R4300i_SPECIAL_MTHI(Section); break; - case R4300i_SPECIAL_MULT: Compile_R4300i_SPECIAL_MULT(Section); break; - case R4300i_SPECIAL_DIV: Compile_R4300i_SPECIAL_DIV(Section); break; - case R4300i_SPECIAL_DIVU: Compile_R4300i_SPECIAL_DIVU(Section); break; - case R4300i_SPECIAL_MULTU: Compile_R4300i_SPECIAL_MULTU(Section); break; - case R4300i_SPECIAL_DMULTU: Compile_R4300i_SPECIAL_DMULTU(Section); break; - case R4300i_SPECIAL_DDIVU: Compile_R4300i_SPECIAL_DDIVU(Section); break; - case R4300i_SPECIAL_ADD: Compile_R4300i_SPECIAL_ADD(Section); break; - case R4300i_SPECIAL_ADDU: Compile_R4300i_SPECIAL_ADDU(Section); break; - case R4300i_SPECIAL_SUB: Compile_R4300i_SPECIAL_SUB(Section); break; - case R4300i_SPECIAL_SUBU: Compile_R4300i_SPECIAL_SUBU(Section); break; - case R4300i_SPECIAL_AND: Compile_R4300i_SPECIAL_AND(Section); break; - case R4300i_SPECIAL_OR: Compile_R4300i_SPECIAL_OR(Section); break; - case R4300i_SPECIAL_XOR: Compile_R4300i_SPECIAL_XOR(Section); break; - case R4300i_SPECIAL_SLT: Compile_R4300i_SPECIAL_SLT(Section); break; - case R4300i_SPECIAL_SLTU: Compile_R4300i_SPECIAL_SLTU(Section); break; - case R4300i_SPECIAL_DADD: Compile_R4300i_SPECIAL_DADD(Section); break; - case R4300i_SPECIAL_DADDU: Compile_R4300i_SPECIAL_DADDU(Section); break; - case R4300i_SPECIAL_DSLL32: Compile_R4300i_SPECIAL_DSLL32(Section); break; - case R4300i_SPECIAL_DSRA32: Compile_R4300i_SPECIAL_DSRA32(Section); break; - default: - Compile_R4300i_UnknownOpcode(Section); break; - } - break; - case R4300i_ADDI: Compile_R4300i_ADDI(Section); break; - case R4300i_ADDIU: Compile_R4300i_ADDIU(Section); break; - case R4300i_SLTI: Compile_R4300i_SLTI(Section); break; - case R4300i_SLTIU: Compile_R4300i_SLTIU(Section); break; - case R4300i_ANDI: Compile_R4300i_ANDI(Section); break; - case R4300i_ORI: Compile_R4300i_ORI(Section); break; - case R4300i_XORI: Compile_R4300i_XORI(Section); break; - case R4300i_LUI: Compile_R4300i_LUI(Section); break; - case R4300i_CP1: - switch (Opcode.rs) { - case R4300i_COP1_CF: Compile_R4300i_COP1_CF(Section); break; - case R4300i_COP1_MT: Compile_R4300i_COP1_MT(Section); break; - case R4300i_COP1_CT: Compile_R4300i_COP1_CT(Section); break; - case R4300i_COP1_MF: Compile_R4300i_COP1_MF(Section); break; - case R4300i_COP1_S: - switch (Opcode.funct) { - case R4300i_COP1_FUNCT_ADD: Compile_R4300i_COP1_S_ADD(Section); break; - case R4300i_COP1_FUNCT_SUB: Compile_R4300i_COP1_S_SUB(Section); break; - case R4300i_COP1_FUNCT_MUL: Compile_R4300i_COP1_S_MUL(Section); break; - case R4300i_COP1_FUNCT_DIV: Compile_R4300i_COP1_S_DIV(Section); break; - case R4300i_COP1_FUNCT_ABS: Compile_R4300i_COP1_S_ABS(Section); break; - case R4300i_COP1_FUNCT_NEG: Compile_R4300i_COP1_S_NEG(Section); break; - case R4300i_COP1_FUNCT_SQRT: Compile_R4300i_COP1_S_SQRT(Section); break; - case R4300i_COP1_FUNCT_MOV: Compile_R4300i_COP1_S_MOV(Section); break; - case R4300i_COP1_FUNCT_CVT_D: Compile_R4300i_COP1_S_CVT_D(Section); break; - case R4300i_COP1_FUNCT_ROUND_W: Compile_R4300i_COP1_S_ROUND_W(Section); break; - case R4300i_COP1_FUNCT_TRUNC_W: Compile_R4300i_COP1_S_TRUNC_W(Section); break; - case R4300i_COP1_FUNCT_FLOOR_W: Compile_R4300i_COP1_S_FLOOR_W(Section); break; - case R4300i_COP1_FUNCT_C_F: case R4300i_COP1_FUNCT_C_UN: - case R4300i_COP1_FUNCT_C_EQ: case R4300i_COP1_FUNCT_C_UEQ: - case R4300i_COP1_FUNCT_C_OLT: case R4300i_COP1_FUNCT_C_ULT: - case R4300i_COP1_FUNCT_C_OLE: case R4300i_COP1_FUNCT_C_ULE: - case R4300i_COP1_FUNCT_C_SF: case R4300i_COP1_FUNCT_C_NGLE: - case R4300i_COP1_FUNCT_C_SEQ: case R4300i_COP1_FUNCT_C_NGL: - case R4300i_COP1_FUNCT_C_LT: case R4300i_COP1_FUNCT_C_NGE: - case R4300i_COP1_FUNCT_C_LE: case R4300i_COP1_FUNCT_C_NGT: - Compile_R4300i_COP1_S_CMP(Section); break; - default: - Compile_R4300i_UnknownOpcode(Section); break; - } - break; - case R4300i_COP1_D: - switch (Opcode.funct) { - case R4300i_COP1_FUNCT_ADD: Compile_R4300i_COP1_D_ADD(Section); break; - case R4300i_COP1_FUNCT_SUB: Compile_R4300i_COP1_D_SUB(Section); break; - case R4300i_COP1_FUNCT_MUL: Compile_R4300i_COP1_D_MUL(Section); break; - case R4300i_COP1_FUNCT_DIV: Compile_R4300i_COP1_D_DIV(Section); break; - case R4300i_COP1_FUNCT_ABS: Compile_R4300i_COP1_D_ABS(Section); break; - case R4300i_COP1_FUNCT_NEG: Compile_R4300i_COP1_D_NEG(Section); break; - case R4300i_COP1_FUNCT_SQRT: Compile_R4300i_COP1_D_SQRT(Section); break; - case R4300i_COP1_FUNCT_MOV: Compile_R4300i_COP1_D_MOV(Section); break; - case R4300i_COP1_FUNCT_TRUNC_W: Compile_R4300i_COP1_D_TRUNC_W(Section); break; - case R4300i_COP1_FUNCT_CVT_S: Compile_R4300i_COP1_D_CVT_S(Section); break; - case R4300i_COP1_FUNCT_CVT_W: Compile_R4300i_COP1_D_CVT_W(Section); break; - case R4300i_COP1_FUNCT_C_F: case R4300i_COP1_FUNCT_C_UN: - case R4300i_COP1_FUNCT_C_EQ: case R4300i_COP1_FUNCT_C_UEQ: - case R4300i_COP1_FUNCT_C_OLT: case R4300i_COP1_FUNCT_C_ULT: - case R4300i_COP1_FUNCT_C_OLE: case R4300i_COP1_FUNCT_C_ULE: - case R4300i_COP1_FUNCT_C_SF: case R4300i_COP1_FUNCT_C_NGLE: - case R4300i_COP1_FUNCT_C_SEQ: case R4300i_COP1_FUNCT_C_NGL: - case R4300i_COP1_FUNCT_C_LT: case R4300i_COP1_FUNCT_C_NGE: - case R4300i_COP1_FUNCT_C_LE: case R4300i_COP1_FUNCT_C_NGT: - Compile_R4300i_COP1_D_CMP(Section); break; - default: - Compile_R4300i_UnknownOpcode(Section); break; - } - break; - case R4300i_COP1_W: - switch (Opcode.funct) { - case R4300i_COP1_FUNCT_CVT_S: Compile_R4300i_COP1_W_CVT_S(Section); break; - case R4300i_COP1_FUNCT_CVT_D: Compile_R4300i_COP1_W_CVT_D(Section); break; - default: - Compile_R4300i_UnknownOpcode(Section); break; - } - break; - default: - Compile_R4300i_UnknownOpcode(Section); break; - } - break; - case R4300i_LB: Compile_R4300i_LB(Section); break; - case R4300i_LH: Compile_R4300i_LH(Section); break; - case R4300i_LW: Compile_R4300i_LW(Section); break; - case R4300i_LBU: Compile_R4300i_LBU(Section); break; - case R4300i_LHU: Compile_R4300i_LHU(Section); break; - case R4300i_SB: Compile_R4300i_SB(Section); break; - case R4300i_SH: Compile_R4300i_SH(Section); break; - case R4300i_SW: Compile_R4300i_SW(Section); break; - case R4300i_SWR: Compile_R4300i_SWR(Section); break; - case R4300i_CACHE: Compile_R4300i_CACHE(Section); break; - case R4300i_LWC1: Compile_R4300i_LWC1(Section); break; - case R4300i_LDC1: Compile_R4300i_LDC1(Section); break; - case R4300i_LD: Compile_R4300i_LD(Section); break; - case R4300i_SWC1: Compile_R4300i_SWC1(Section); break; - case R4300i_SDC1: Compile_R4300i_SDC1(Section); break; - case R4300i_SD: Compile_R4300i_SD(Section); break; - default: - Compile_R4300i_UnknownOpcode(Section); break; - } - - Section->ResetX86Protection(); - WriteBackRegisters(Section); - UpdateCounters(&Section->BlockCycleCount(),&Section->BlockRandomModifier(), FALSE); - int x86Reg = Map_TempReg(Section,x86_Any,-1,FALSE); - MoveVariableToX86reg(&JumpToLocation,"JumpToLocation",x86Reg); - MoveX86regToVariable(x86Reg,&PROGRAM_COUNTER,"PROGRAM_COUNTER"); - MoveConstToVariable(NORMAL,&NextInstruction,"NextInstruction"); - if (CPU_Type == CPU_SyncCores) { Call_Direct(SyncToPC, "SyncToPC"); } - ExitCodeBlock(); - CompileExitCode(BlockInfo); - CPU_Message("====== End of recompiled code ======"); - - info->SetVEndPC(BlockInfo.EndVAddr); - info->SetFunctionAddr(BlockInfo.CompiledLocation); - _TLB->VAddrToRealAddr(info->VStartPC(),*(reinterpret_cast(&info->MemLocation[0]))); - info->MemLocation[1] = info->MemLocation[0] + 1; - info->MemContents[0] = *info->MemLocation[0]; - info->MemContents[1] = *info->MemLocation[1]; - NextInstruction = NORMAL; - return info; -#endif - return NULL; + CCompiledFunc * Func = new CCompiledFunc(CodeBlock); + delayFunc = (BYTE *)Func->Function(); + m_DelaySlotTable[Index] = delayFunc; + return delayFunc; } bool CRecompiler::AnalyseBlock ( CCodeBlock & BlockInfo) @@ -2014,7 +1837,7 @@ CCompiledFunc * CRecompiler::CompilerCode ( void ) WriteTraceF(TraceRecompiler,"Compile Block-Start: Program Counter: %X pAddr: %X",*_PROGRAM_COUNTER,pAddr); - CCodeBlock CodeBlock(*_PROGRAM_COUNTER, RecompPos()); + CCodeBlock CodeBlock(*_PROGRAM_COUNTER, RecompPos(),false); if (!CodeBlock.Compile()) { return NULL; diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Class.h b/Source/Project64/N64 System/Recompiler/Recompiler Class.h index 4c3338152..dddfbf03e 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Class.h +++ b/Source/Project64/N64 System/Recompiler/Recompiler Class.h @@ -15,6 +15,8 @@ public: Remove_DMA, }; + typedef void (* DelayFunc)(void); + public: CRecompiler (CProfiling & Profile, bool & EndEmulation ); ~CRecompiler (void); @@ -23,6 +25,7 @@ public: void ResetRecompCode ( void ); bool GenerateX86Code (CCodeBlock & BlockInfo, CCodeSection * Section, DWORD Test ); + BYTE * CompileDelaySlot ( DWORD PC ); //Self modifying code methods void ClearRecompCode_Virt ( DWORD VirtualAddress, int length, REMOVE_REASON Reason ); @@ -41,7 +44,6 @@ private: //CFunctionMap m_Functions; CCompiledFunc * CompilerCode ( void ); - CCompiledFunc * CompileDelaySlot ( DWORD PC ); bool Compiler4300iBlock ( CCompiledFunc * info ); // Compiling code diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp index f1cdfaec4..a62671bc9 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp @@ -44,7 +44,7 @@ void CRecompilerOps::Compile_Branch (CRecompilerOps::BranchFunction CompareFunc, { OPCODE Command; - if (!_MMU ->LW_VAddr(m_CompilePC + 4, Command.Hex)) { + if (!_MMU->LW_VAddr(m_CompilePC + 4, Command.Hex)) { DisplayError(GS(MSG_FAIL_LOAD_WORD)); ExitThread(0); } @@ -1013,8 +1013,6 @@ void CRecompilerOps::BGEZ_Compare (void) { } void CRecompilerOps::COP1_BCF_Compare (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix TestVariable(FPCSR_C,&_FPCR[31],"_FPCR[31]"); if (m_Section->m_Cont.FallThrough) { JeLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); @@ -1028,12 +1026,9 @@ void CRecompilerOps::COP1_BCF_Compare (void) { JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); } -#endif } void CRecompilerOps::COP1_BCT_Compare (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix TestVariable(FPCSR_C,&_FPCR[31],"_FPCR[31]"); if (m_Section->m_Cont.FallThrough) { JneLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); @@ -1047,7 +1042,6 @@ void CRecompilerOps::COP1_BCT_Compare (void) { JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); } -#endif } /************************* OpCode functions *************************/ @@ -1087,21 +1081,15 @@ void CRecompilerOps::JAL (void) { UnMap_GPR( 31, FALSE); MipsRegLo(31) = m_CompilePC + 8; MipsRegState(31) = CRegInfo::STATE_CONST_32; - if ((m_CompilePC & 0xFFC) == 0xFFC) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix - MoveConstToVariable((m_CompilePC & 0xF0000000) + (m_Opcode.target << 2),&JumpToLocation,"JumpToLocation"); - MoveConstToVariable(m_CompilePC + 4,_PROGRAM_COUNTER,"_PROGRAM_COUNTER"); - UpdateCounters(&m_RegWorkingSet.BlockCycleCount(),&m_RegWorkingSet.BlockRandomModifier(),FALSE); - m_RegWorkingSet.WriteBackRegisters(); - if (CPU_Type == CPU_SyncCores) { Call_Direct(SyncToPC, "SyncToPC"); } - MoveConstToVariable(DELAY_SLOT,&m_NextInstruction,"m_NextInstruction"); - Ret(); + if ((m_CompilePC & 0xFFC) == 0xFFC) + { + DWORD TargetPC = (m_CompilePC & 0xF0000000) + (m_Opcode.target << 2); + PushImm32(stdstr_f("0x%08X",TargetPC).c_str(),TargetPC); + m_Section->GenerateSectionLinkage(); m_NextInstruction = END_BLOCK; - return; -#endif + } else { + m_NextInstruction = DO_DELAY_SLOT; } - m_NextInstruction = DO_DELAY_SLOT; } else if (m_NextInstruction == DELAY_SLOT_DONE ) { DWORD TargetPC = (m_CompilePC & 0xF0000000) + (m_Opcode.target << 2); m_Section->CompileExit(m_CompilePC,TargetPC,m_RegWorkingSet,CExitInfo::Normal,TRUE,NULL); @@ -1408,10 +1396,10 @@ void CRecompilerOps::DADDIU (void) { if (m_Opcode.rs != 0) { UnMap_GPR(m_Opcode.rs,TRUE); } if (m_Opcode.rs != 0) { UnMap_GPR(m_Opcode.rt,TRUE); } - Pushad(); + BeforeCallDirect(); MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); Call_Direct(R4300iOp::DADDIU, "R4300iOp::DADDIU"); - Popad(); + AfterCallDirect(); } void CRecompilerOps::CACHE (void){ @@ -1425,7 +1413,7 @@ void CRecompilerOps::CACHE (void){ switch(m_Opcode.rt) { case 0: case 16: - Pushad(); + BeforeCallDirect(); PushImm32("CRecompiler::Remove_Cache",CRecompiler::Remove_Cache); PushImm32("20",20); if (IsConst(m_Opcode.base)) { @@ -1441,7 +1429,7 @@ void CRecompilerOps::CACHE (void){ } MoveConstToX86reg((DWORD)_N64System->GetRecompiler(),x86_ECX); Call_Direct(AddressOf(CRecompiler::ClearRecompCode_Virt), "CRecompiler::ClearRecompCode_Virt"); - Popad(); + AfterCallDirect(); break; case 1: case 3: @@ -1800,6 +1788,7 @@ void CRecompilerOps::SPECIAL_JR (void) { } else { MoveX86regToVariable(Map_TempReg(x86_Any,m_Opcode.rs,FALSE),_PROGRAM_COUNTER, "PROGRAM_COUNTER"); } + UpdateCounters(m_RegWorkingSet,true,true); m_Section->CompileExit(-1, (DWORD)-1,m_RegWorkingSet,CExitInfo::Normal,TRUE,NULL); } } @@ -1858,6 +1847,7 @@ _Notify->BreakPoint(__FILE__,__LINE__); } else { MoveX86regToVariable(Map_TempReg(x86_Any,m_Opcode.rs,FALSE),_PROGRAM_COUNTER, "PROGRAM_COUNTER"); } + UpdateCounters(m_RegWorkingSet,true,true); m_Section->CompileExit(m_CompilePC, (DWORD)-1,m_RegWorkingSet,CExitInfo::Normal,TRUE,NULL); } m_NextInstruction = END_BLOCK; @@ -2266,10 +2256,10 @@ void CRecompilerOps::SPECIAL_DMULT (void) { if (m_Opcode.rs != 0) { UnMap_GPR(m_Opcode.rs,TRUE); } if (m_Opcode.rs != 0) { UnMap_GPR(m_Opcode.rt,TRUE); } - Pushad(); + BeforeCallDirect(); MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); Call_Direct(R4300iOp::SPECIAL_DMULT, "R4300iOp::SPECIAL_DMULT"); - Popad(); + AfterCallDirect(); #endif } @@ -2347,10 +2337,10 @@ void CRecompilerOps::SPECIAL_DDIV (void) { UnMap_GPR(m_Opcode.rs,TRUE); UnMap_GPR(m_Opcode.rt,TRUE); - Pushad(); + BeforeCallDirect(); MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); Call_Direct(R4300iOp::SPECIAL_DDIV, "R4300iOp::SPECIAL_DDIV"); - Popad(); + AfterCallDirect(); } void CRecompilerOps::SPECIAL_DDIVU (void) @@ -2359,10 +2349,10 @@ void CRecompilerOps::SPECIAL_DDIVU (void) UnMap_GPR(m_Opcode.rs,TRUE); UnMap_GPR(m_Opcode.rt,TRUE); - Pushad(); + BeforeCallDirect(); MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); Call_Direct(R4300iOp::SPECIAL_DDIVU, "R4300iOp::SPECIAL_DDIVU"); - Popad(); + AfterCallDirect(); } void CRecompilerOps::SPECIAL_ADD (void) { @@ -2800,8 +2790,6 @@ void CRecompilerOps::SPECIAL_XOR (void) { } void CRecompilerOps::SPECIAL_NOR (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); if (m_Section->IsKnown(m_Opcode.rt) && m_Section->IsKnown(m_Opcode.rs)) { @@ -2837,7 +2825,7 @@ void CRecompilerOps::SPECIAL_NOR (void) { Map_GPR_32bit(m_Opcode.rd,m_Section->IsSigned(m_Opcode.rt),source1); } OrX86RegToX86Reg(cMipsRegMapLo(m_Opcode.rd),cMipsRegMapLo(source2)); - NotX86Reg(cMipsRegLo(m_Opcode.rd)); + NotX86Reg(cMipsRegMapLo(m_Opcode.rd)); } } else { DWORD ConstReg = IsConst(m_Opcode.rt)?m_Opcode.rt:m_Opcode.rs; @@ -2853,13 +2841,13 @@ void CRecompilerOps::SPECIAL_NOR (void) { } Map_GPR_64bit(m_Opcode.rd,MappedReg); if ((Value >> 32) != 0) { - OrConstToX86Reg((DWORD)(Value >> 32),MipsRegHi(m_Opcode.rd)); + OrConstToX86Reg((DWORD)(Value >> 32),MipsRegMapHi(m_Opcode.rd)); } if ((DWORD)Value != 0) { - OrConstToX86Reg((DWORD)Value,cMipsRegLo(m_Opcode.rd)); + OrConstToX86Reg((DWORD)Value,cMipsRegMapLo(m_Opcode.rd)); } - NotX86Reg(MipsRegHi(m_Opcode.rd)); - NotX86Reg(cMipsRegLo(m_Opcode.rd)); + NotX86Reg(cMipsRegMapHi(m_Opcode.rd)); + NotX86Reg(cMipsRegMapLo(m_Opcode.rd)); } else { int Value = cMipsRegLo(ConstReg); if (m_Section->IsSigned(m_Opcode.rt) != m_Section->IsSigned(m_Opcode.rs)) { @@ -2867,8 +2855,8 @@ void CRecompilerOps::SPECIAL_NOR (void) { } else { Map_GPR_32bit(m_Opcode.rd,m_Section->IsSigned(MappedReg)?TRUE:FALSE, MappedReg); } - if (Value != 0) { OrConstToX86Reg(Value,cMipsRegLo(m_Opcode.rd)); } - NotX86Reg(cMipsRegLo(m_Opcode.rd)); + if (Value != 0) { OrConstToX86Reg(Value,cMipsRegMapLo(m_Opcode.rd)); } + NotX86Reg(cMipsRegMapLo(m_Opcode.rd)); } } } else if (m_Section->IsKnown(m_Opcode.rt) || m_Section->IsKnown(m_Opcode.rs)) { @@ -2881,26 +2869,25 @@ void CRecompilerOps::SPECIAL_NOR (void) { Value = Is64Bit(KnownReg)?m_Section->MipsReg(KnownReg):m_Section->MipsRegLo_S(KnownReg); Map_GPR_64bit(m_Opcode.rd,UnknownReg); if ((Value >> 32) != 0) { - OrConstToX86Reg((DWORD)(Value >> 32),MipsRegHi(m_Opcode.rd)); + OrConstToX86Reg((DWORD)(Value >> 32),MipsRegMapHi(m_Opcode.rd)); } if ((DWORD)Value != 0) { - OrConstToX86Reg((DWORD)Value,cMipsRegLo(m_Opcode.rd)); + OrConstToX86Reg((DWORD)Value,cMipsRegMapLo(m_Opcode.rd)); } } else { Map_GPR_64bit(m_Opcode.rd,KnownReg); - OrVariableToX86Reg(&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg],MipsRegHi(m_Opcode.rd)); - OrVariableToX86Reg(&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg],cMipsRegLo(m_Opcode.rd)); + OrVariableToX86Reg(&_GPR[UnknownReg].W[1],CRegName::GPR_Hi[UnknownReg],cMipsRegMapHi(m_Opcode.rd)); + OrVariableToX86Reg(&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg],cMipsRegMapLo(m_Opcode.rd)); } - NotX86Reg(MipsRegHi(m_Opcode.rd)); - NotX86Reg(cMipsRegLo(m_Opcode.rd)); + NotX86Reg(cMipsRegMapHi(m_Opcode.rd)); + NotX86Reg(cMipsRegMapLo(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],MipsRegHi(m_Opcode.rd)); - OrVariableToX86Reg(&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs],cMipsRegLo(m_Opcode.rd)); - NotX86Reg(MipsRegHi(m_Opcode.rd)); - NotX86Reg(cMipsRegLo(m_Opcode.rd)); + OrVariableToX86Reg(&_GPR[m_Opcode.rs].W[1],CRegName::GPR_Hi[m_Opcode.rs],cMipsRegMapHi(m_Opcode.rd)); + OrVariableToX86Reg(&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs],cMipsRegMapLo(m_Opcode.rd)); + NotX86Reg(cMipsRegMapHi(m_Opcode.rd)); + NotX86Reg(cMipsRegMapLo(m_Opcode.rd)); } -#endif } void CRecompilerOps::SPECIAL_SLT (void) { @@ -3668,10 +3655,10 @@ void CRecompilerOps::COP0_MT (void) { break; case 11: //Compare UpdateCounters(m_RegWorkingSet,false,true); - Pushad(); + BeforeCallDirect(); MoveConstToX86reg((DWORD)_SystemTimer,x86_ECX); Call_Direct(AddressOf(CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); - Popad(); + AfterCallDirect(); if (IsConst(m_Opcode.rt)) { MoveConstToVariable(cMipsRegLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); } else if (IsMapped(m_Opcode.rt)) { @@ -3680,17 +3667,17 @@ void CRecompilerOps::COP0_MT (void) { MoveX86regToVariable(Map_TempReg(x86_Any,m_Opcode.rt,FALSE), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); } AndConstToVariable(~CAUSE_IP7,&_Reg->FAKE_CAUSE_REGISTER,"FAKE_CAUSE_REGISTER"); - Pushad(); + BeforeCallDirect(); MoveConstToX86reg((DWORD)_SystemTimer,x86_ECX); Call_Direct(AddressOf(CSystemTimer::UpdateCompareTimer), "CSystemTimer::UpdateCompareTimer"); - Popad(); + AfterCallDirect(); break; case 9: //Count UpdateCounters(m_RegWorkingSet,false,true); - Pushad(); + BeforeCallDirect(); MoveConstToX86reg((DWORD)_SystemTimer,x86_ECX); Call_Direct(AddressOf(CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); - Popad(); + AfterCallDirect(); if (IsConst(m_Opcode.rt)) { MoveConstToVariable(cMipsRegLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); } else if (IsMapped(m_Opcode.rt)) { @@ -3698,10 +3685,10 @@ void CRecompilerOps::COP0_MT (void) { } else { MoveX86regToVariable(Map_TempReg(x86_Any,m_Opcode.rt,FALSE), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); } - Pushad(); + BeforeCallDirect(); MoveConstToX86reg((DWORD)_SystemTimer,x86_ECX); Call_Direct(AddressOf(CSystemTimer::UpdateCompareTimer), "CSystemTimer::UpdateCompareTimer"); - Popad(); + AfterCallDirect(); break; case 12: //Status { @@ -3718,28 +3705,28 @@ void CRecompilerOps::COP0_MT (void) { TestConstToX86Reg(STATUS_FR,OldStatusReg); JeLabel8("FpuFlagFine",0); Jump = m_RecompPos - 1; - Pushad(); + BeforeCallDirect(); Call_Direct(SetFpuLocations,"SetFpuLocations"); - Popad(); + AfterCallDirect(); *(BYTE *)(Jump)= (BYTE )(((BYTE )(m_RecompPos)) - (((BYTE )(Jump)) + 1)); //TestConstToX86Reg(STATUS_FR,OldStatusReg); //BreakPoint(__FILE__,__LINE__); //m_Section->CompileExit(m_CompilePC+4,m_RegWorkingSet,ExitResetRecompCode,FALSE,JneLabel32); - Pushad(); + BeforeCallDirect(); MoveConstToX86reg((DWORD)_Reg,x86_ECX); Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - Popad(); + AfterCallDirect(); } break; case 6: //Wired _Notify->BreakPoint(__FILE__,__LINE__); #ifdef tofix - Pushad(); + BeforeCallDirect(); UpdateCounters(&m_RegWorkingSet.BlockCycleCount(),&m_RegWorkingSet.BlockRandomModifier(),FALSE); m_RegWorkingSet.BlockCycleCount() = 0; m_RegWorkingSet.BlockRandomModifier() = 0; Call_Direct(FixRandomReg,"FixRandomReg"); - Popad(); + AfterCallDirect(); if (IsConst(m_Opcode.rt)) { MoveConstToVariable(cMipsRegLo(m_Opcode.rt), &_CP0[m_Opcode.rd], CRegName::Cop0[m_Opcode.rd]); } else if (IsMapped(m_Opcode.rt)) { @@ -3761,10 +3748,10 @@ void CRecompilerOps::COP0_MT (void) { CRecompilerOps::UnknownOpcode(); #endif } - Pushad(); + BeforeCallDirect(); MoveConstToX86reg((DWORD)_Reg,x86_ECX); Call_Direct(AddressOf(CRegisters::CheckInterrupts),"CRegisters::CheckInterrupts"); - Popad(); + AfterCallDirect(); break; default: _Notify->BreakPoint(__FILE__,__LINE__); @@ -3780,23 +3767,23 @@ void CRecompilerOps::COP0_CO_TLBR( void) { #ifdef tofix CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); if (!g_UseTlb) { return; } - Pushad(); + BeforeCallDirect(); Call_Direct(TLB_ReadEntry,"TLB_ReadEntry"); - Popad(); + AfterCallDirect(); #endif } void CRecompilerOps::COP0_CO_TLBWI( void) { CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); if (!g_UseTlb) { return; } - Pushad(); + BeforeCallDirect(); PushImm32("FALSE",FALSE); MoveVariableToX86reg(&_Reg->INDEX_REGISTER,"INDEX_REGISTER",x86_ECX); AndConstToX86Reg(x86_ECX,0x1F); Push(x86_ECX); MoveConstToX86reg((DWORD)_TLB,x86_ECX); Call_Direct(AddressOf(CTLB::WriteEntry),"CTLB::WriteEntry"); - Popad(); + AfterCallDirect(); } void CRecompilerOps::COP0_CO_TLBWR( void) { @@ -3808,7 +3795,7 @@ void CRecompilerOps::COP0_CO_TLBWR( void) { UpdateCounters(&m_RegWorkingSet.BlockCycleCount(),&m_RegWorkingSet.BlockRandomModifier(),FALSE); m_RegWorkingSet.BlockCycleCount() = 0; m_RegWorkingSet.BlockRandomModifier() = 0; - Pushad(); + BeforeCallDirect(); Call_Direct(FixRandomReg,"FixRandomReg"); PushImm32("TRUE",TRUE); MoveVariableToX86reg(&_Reg->RANDOM_REGISTER,"RANDOM_REGISTER",x86_ECX); @@ -3816,7 +3803,7 @@ void CRecompilerOps::COP0_CO_TLBWR( void) { Push(x86_ECX); Call_Direct(TLB_WriteEntry,"TLB_WriteEntry"); AddConstToX86Reg(x86_ESP,8); - Popad(); + AfterCallDirect(); #endif } @@ -3824,10 +3811,10 @@ void CRecompilerOps::COP0_CO_TLBP( void) { CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); if (!g_UseTlb) { return; } - Pushad(); + BeforeCallDirect(); MoveConstToX86reg((DWORD)_TLB,x86_ECX); Call_Direct(AddressOf(CTLB::Probe), "CTLB::TLB_Probe"); - Popad(); + AfterCallDirect(); } void compiler_COP0_CO_ERET (void) { @@ -3847,6 +3834,8 @@ void CRecompilerOps::COP0_CO_ERET( void) { 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; } @@ -3888,12 +3877,12 @@ void CRecompilerOps::COP1_DMF (void) { UnMap_FPR(m_Opcode.fs,TRUE); Map_GPR_64bit(m_Opcode.rt, -1); TempReg = Map_TempReg(x86_Any,-1,FALSE); - sprintf(Name,"_FPRDoubleLocation[%d]",m_Opcode.fs); - MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[m_Opcode.fs],Name,TempReg); + sprintf(Name,"_FPR_D[%d]",m_Opcode.fs); + MoveVariableToX86reg((BYTE *)&_FPR_D[m_Opcode.fs],Name,TempReg); AddConstToX86Reg(TempReg,4); MoveX86PointerToX86reg(MipsRegHi(m_Opcode.rt),TempReg); - sprintf(Name,"_FPRDoubleLocation[%d]",m_Opcode.fs); - MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[m_Opcode.fs],Name,TempReg); + sprintf(Name,"_FPR_D[%d]",m_Opcode.fs); + MoveVariableToX86reg((BYTE *)&_FPR_D[m_Opcode.fs],Name,TempReg); MoveX86PointerToX86reg(cMipsRegLo(m_Opcode.rt),TempReg); #endif } @@ -3949,8 +3938,8 @@ void CRecompilerOps::COP1_DMT( void) { } UnMap_FPR(m_Opcode.fs,TRUE); TempReg = Map_TempReg(x86_Any,-1,FALSE); - sprintf(Name,"_FPRDoubleLocation[%d]",m_Opcode.fs); - MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[m_Opcode.fs],Name,TempReg); + sprintf(Name,"_FPR_D[%d]",m_Opcode.fs); + MoveVariableToX86reg((BYTE *)&_FPR_D[m_Opcode.fs],Name,TempReg); if (IsConst(m_Opcode.rt)) { MoveConstToX86Pointer(cMipsRegLo(m_Opcode.rt),TempReg); @@ -3990,9 +3979,9 @@ void CRecompilerOps::COP1_CT(void) { } else { MoveX86regToVariable(Map_TempReg(x86_Any,m_Opcode.rt,FALSE),&_FPCR[m_Opcode.fs],CRegName::FPR_Ctrl[m_Opcode.fs]); } - Pushad(); + BeforeCallDirect(); Call_Direct(ChangeDefaultRoundingModel, "ChangeDefaultRoundingModel"); - Popad(); + AfterCallDirect(); m_RegWorkingSet.CurrentRoundingModel() = CRegInfo::RoundUnknown; } @@ -4024,11 +4013,10 @@ void CRecompilerOps::COP1_S_ADD (void) { } void CRecompilerOps::COP1_S_SUB (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix 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)); @@ -4058,7 +4046,6 @@ void CRecompilerOps::COP1_S_SUB (void) { } } UnMap_FPR(m_Opcode.fd,TRUE); -#endif } void CRecompilerOps::COP1_S_MUL (void) { @@ -4137,37 +4124,28 @@ void CRecompilerOps::COP1_S_ABS (void) { } void CRecompilerOps::COP1_S_NEG (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix 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); -#endif } void CRecompilerOps::COP1_S_SQRT (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix 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); -#endif } void CRecompilerOps::COP1_S_MOV (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix 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); -#endif } void CRecompilerOps::COP1_S_TRUNC_L (void) { @@ -4223,8 +4201,6 @@ void CRecompilerOps::COP1_S_ROUND_W (void) { } void CRecompilerOps::COP1_S_TRUNC_W (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); m_Section->CompileCop1Test(); @@ -4232,7 +4208,6 @@ void CRecompilerOps::COP1_S_TRUNC_W (void) { Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float); } ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Float,CRegInfo::FPU_Dword,CRegInfo::RoundTruncate); -#endif } void CRecompilerOps::COP1_S_CEIL_W (void) { // added by Witten @@ -4249,8 +4224,6 @@ void CRecompilerOps::COP1_S_CEIL_W (void) { // added by Witten } void CRecompilerOps::COP1_S_FLOOR_W (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); m_Section->CompileCop1Test(); @@ -4258,12 +4231,10 @@ void CRecompilerOps::COP1_S_FLOOR_W (void) { Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float); } ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Float,CRegInfo::FPU_Dword,CRegInfo::RoundDown); -#endif } -void CRecompilerOps::COP1_S_CVT_D (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix +void CRecompilerOps::COP1_S_CVT_D (void) +{ CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); m_Section->CompileCop1Test(); @@ -4271,7 +4242,6 @@ void CRecompilerOps::COP1_S_CVT_D (void) { Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float); } ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Float,CRegInfo::FPU_Double,CRegInfo::RoundDefault); -#endif } void CRecompilerOps::COP1_S_CVT_W (void) { @@ -4285,8 +4255,6 @@ void CRecompilerOps::COP1_S_CVT_W (void) { } void CRecompilerOps::COP1_S_CVT_L (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); m_Section->CompileCop1Test(); @@ -4294,21 +4262,23 @@ void CRecompilerOps::COP1_S_CVT_L (void) { Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Float); } ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Float,CRegInfo::FPU_Qword,CRegInfo::RoundDefault); -#endif } void CRecompilerOps::COP1_S_CMP (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix - DWORD Reg1 = RegInStack(m_Opcode.ft, CRegInfo::FPU_Float)?m_Opcode.ft:m_Opcode.fs; - DWORD Reg2 = RegInStack(m_Opcode.ft, CRegInfo::FPU_Float)?m_Opcode.fs:m_Opcode.ft; - x86Reg Reg, cmp = 0; + DWORD Reg1 = m_Opcode.fs; + DWORD Reg2 = m_Opcode.ft; + DWORD 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 & 1) != 0) { CRecompilerOps::UnknownOpcode(Section); } + if ((m_Opcode.funct & 1) != 0) { CRecompilerOps::UnknownOpcode(); } if ((m_Opcode.funct & 2) != 0) { cmp |= 0x4000; } if ((m_Opcode.funct & 4) != 0) { cmp |= 0x0100; } @@ -4317,53 +4287,47 @@ void CRecompilerOps::COP1_S_CMP (void) { if (RegInStack(Reg2, CRegInfo::FPU_Float)) { fpuComReg(StackPosition(Reg2),FALSE); } else { - x86Reg TempReg; - UnMap_FPR(Reg2,TRUE); Load_FPR_ToTop(Reg1,Reg1, CRegInfo::FPU_Float); - TempReg = Map_TempReg(x86_Any,-1,FALSE); + 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); } - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix - AndConstToVariable(~FPCSR_C, &FSTATUS_REGISTER, "FSTATUS_REGISTER"); -#endif + AndConstToVariable(~FPCSR_C, &_FPCR[31], "_FPCR[31]"); fpuStoreStatus(); - x86reg = Map_TempReg(x86_Any8Bit, 0, FALSE); + x86Reg Reg = Map_TempReg(x86_Any8Bit, 0, FALSE); TestConstToX86Reg(cmp,x86_EAX); - Setnz(x86reg); + Setnz(Reg); if (cmp != 0) { TestConstToX86Reg(cmp,x86_EAX); - Setnz(x86reg); + 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(x86reg2); + Setz(Reg2); - OrX86RegToX86Reg(x86reg, x86reg2); + OrX86RegToX86Reg(Reg, Reg2); } } else if ((m_Opcode.funct & 1) != 0) { AndConstToX86Reg(x86_EAX, 0x4300); CompConstToX86reg(x86_EAX, 0x4300); - Setz(x86reg); + Setz(Reg); } - ShiftLeftSignImmed(x86reg, 23); - OrX86RegToVariable(&_FPCR[31], "_FPCR[31]", x86reg); -#endif + ShiftLeftSignImmed(Reg, 23); + OrX86RegToVariable(&_FPCR[31], "_FPCR[31]", Reg); } /************************** COP1: D functions ************************/ void CRecompilerOps::COP1_D_ADD (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix 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)); @@ -4377,20 +4341,18 @@ void CRecompilerOps::COP1_D_ADD (void) { UnMap_FPR(Reg2,TRUE); TempReg = Map_TempReg(x86_Any,-1,FALSE); - sprintf(Name,"_FPRDoubleLocation[%d]",Reg2); - MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[Reg2],Name,TempReg); + 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); } -#endif } void CRecompilerOps::COP1_D_SUB (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix 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)); @@ -4399,8 +4361,8 @@ void CRecompilerOps::COP1_D_SUB (void) { if (m_Opcode.fd == m_Opcode.ft) { UnMap_FPR(m_Opcode.fd,TRUE); TempReg = Map_TempReg(x86_Any,-1,FALSE); - sprintf(Name,"_FPRDoubleLocation[%d]",m_Opcode.ft); - MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[m_Opcode.ft],Name,TempReg); + 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 { @@ -4411,21 +4373,19 @@ void CRecompilerOps::COP1_D_SUB (void) { UnMap_FPR(Reg2,TRUE); TempReg = Map_TempReg(x86_Any,-1,FALSE); - sprintf(Name,"_FPRDoubleLocation[%d]",Reg2); - MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[Reg2],Name,TempReg); + 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); } } -#endif } void CRecompilerOps::COP1_D_MUL (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix 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)); @@ -4439,19 +4399,17 @@ void CRecompilerOps::COP1_D_MUL (void) { 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,"_FPRDoubleLocation[%d]",Reg2); - MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[Reg2],Name,TempReg); + sprintf(Name,"_FPR_D[%d]",Reg2); + MoveVariableToX86reg((BYTE *)&_FPR_D[Reg2],Name,TempReg); fpuMulQwordRegPointer(TempReg); } -#endif } void CRecompilerOps::COP1_D_DIV (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix 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)); @@ -4460,8 +4418,8 @@ void CRecompilerOps::COP1_D_DIV (void) { if (m_Opcode.fd == m_Opcode.ft) { UnMap_FPR(m_Opcode.fd,TRUE); TempReg = Map_TempReg(x86_Any,-1,FALSE); - sprintf(Name,"_FPRDoubleLocation[%d]",m_Opcode.ft); - MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[m_Opcode.ft],Name,TempReg); + 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 { @@ -4471,13 +4429,12 @@ void CRecompilerOps::COP1_D_DIV (void) { } else { UnMap_FPR(Reg2,TRUE); TempReg = Map_TempReg(x86_Any,-1,FALSE); - sprintf(Name,"_FPRDoubleLocation[%d]",Reg2); - MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[Reg2],Name,TempReg); + 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); } } -#endif } void CRecompilerOps::COP1_D_ABS (void) { @@ -4508,11 +4465,8 @@ void CRecompilerOps::COP1_D_SQRT (void) { } void CRecompilerOps::COP1_D_MOV (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double); -#endif } void CRecompilerOps::COP1_D_TRUNC_L (void) { //added by Witten @@ -4580,19 +4534,16 @@ void CRecompilerOps::COP1_D_ROUND_W (void) { } void CRecompilerOps::COP1_D_TRUNC_W (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix 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 (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); -#endif } void CRecompilerOps::COP1_D_CEIL_W (void) { // added by Witten @@ -4628,24 +4579,19 @@ void CRecompilerOps::COP1_D_FLOOR_W (void) { //added by Witten } void CRecompilerOps::COP1_D_CVT_S (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix 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 (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); -#endif } void CRecompilerOps::COP1_D_CVT_W (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); m_Section->CompileCop1Test(); @@ -4656,7 +4602,6 @@ void CRecompilerOps::COP1_D_CVT_W (void) { Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Double); } ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Double,CRegInfo::FPU_Dword,CRegInfo::RoundDefault); -#endif } void CRecompilerOps::COP1_D_CVT_L (void) { @@ -4676,17 +4621,19 @@ void CRecompilerOps::COP1_D_CVT_L (void) { } void CRecompilerOps::COP1_D_CMP (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix - DWORD Reg1 = RegInStack(m_Opcode.ft, CRegInfo::FPU_Float)?m_Opcode.ft:m_Opcode.fs; - DWORD Reg2 = RegInStack(m_Opcode.ft, CRegInfo::FPU_Float)?m_Opcode.fs:m_Opcode.ft; - x86Reg Reg, cmp = 0; + DWORD Reg1 = m_Opcode.fs; + DWORD Reg2 = m_Opcode.ft; + DWORD 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 & 1) != 0) { CRecompilerOps::UnknownOpcode(Section); } + if ((m_Opcode.funct & 1) != 0) { CRecompilerOps::UnknownOpcode(); } if ((m_Opcode.funct & 2) != 0) { cmp |= 0x4000; } if ((m_Opcode.funct & 4) != 0) { cmp |= 0x0100; } @@ -4695,43 +4642,39 @@ void CRecompilerOps::COP1_D_CMP (void) { if (RegInStack(Reg2, CRegInfo::FPU_Double)) { fpuComReg(StackPosition(Reg2),FALSE); } else { - x86Reg TempReg; + char Name[50]; UnMap_FPR(Reg2,TRUE); - TempReg = Map_TempReg(x86_Any,-1,FALSE); - sprintf(Name,"_FPRDoubleLocation[%d]",Reg2); - MoveVariableToX86reg((BYTE *)&_FPRDoubleLocation[Reg2],Name,TempReg); + 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); } - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix - AndConstToVariable(~FPCSR_C, &FSTATUS_REGISTER, "FSTATUS_REGISTER"); -#endif + AndConstToVariable(~FPCSR_C, &_FPCR[31], "_FPCR[31]"); fpuStoreStatus(); - x86reg = Map_TempReg(x86_Any8Bit, 0, FALSE); + x86Reg Reg = Map_TempReg(x86_Any8Bit, 0, FALSE); TestConstToX86Reg(cmp,x86_EAX); - Setnz(x86reg); + Setnz(Reg); if (cmp != 0) { TestConstToX86Reg(cmp,x86_EAX); - Setnz(x86reg); + 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(x86reg2); + Setz(Reg2); - OrX86RegToX86Reg(x86reg, x86reg2); + OrX86RegToX86Reg(Reg, Reg2); } } else if ((m_Opcode.funct & 1) != 0) { AndConstToX86Reg(x86_EAX, 0x4300); CompConstToX86reg(x86_EAX, 0x4300); - Setz(x86reg); + Setz(Reg); } - ShiftLeftSignImmed(x86reg, 23); - OrX86RegToVariable(&_FPCR[31], "_FPCR[31]", x86reg); -#endif + ShiftLeftSignImmed(Reg, 23); + OrX86RegToVariable(&_FPCR[31], "_FPCR[31]", Reg); } /************************** COP1: W functions ************************/ @@ -4746,8 +4689,6 @@ void CRecompilerOps::COP1_W_CVT_S (void) { } void CRecompilerOps::COP1_W_CVT_D (void) { - _Notify->BreakPoint(__FILE__,__LINE__); -#ifdef tofix CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); m_Section->CompileCop1Test(); @@ -4755,7 +4696,6 @@ void CRecompilerOps::COP1_W_CVT_D (void) { Load_FPR_ToTop(m_Opcode.fd,m_Opcode.fs,CRegInfo::FPU_Dword); } ChangeFPURegFormat(m_Opcode.fd,CRegInfo::FPU_Dword,CRegInfo::FPU_Double,CRegInfo::RoundDefault); -#endif } /************************** COP1: L functions ************************/ @@ -4806,6 +4746,18 @@ void CRecompilerOps::UnknownOpcode (void) { #endif } +void CRecompilerOps::BeforeCallDirect ( void ) +{ + UnMap_AllFPRs(); + Pushad(); +} + +void CRecompilerOps::AfterCallDirect ( void ) +{ + Popad(); + m_RegWorkingSet.CurrentRoundingModel() = CRegInfo::RoundUnknown; +} + void CRecompilerOps::EnterCodeBlock ( void ) { #ifdef _DEBUG @@ -4828,12 +4780,12 @@ void CRecompilerOps::UpdateCounters ( CRegInfo & RegSet, bool CheckTimer, bool C if (_SyncSystem) { WriteX86Comment("Updating Sync CPU"); - Pushad(); + BeforeCallDirect(); PushImm32(stdstr_f("%d",RegSet.GetBlockCycleCount()).c_str(),RegSet.GetBlockCycleCount()); PushImm32("_SyncSystem",(DWORD)_SyncSystem); MoveConstToX86reg((DWORD)_N64System,x86_ECX); Call_Direct(AddressOf(CN64System::UpdateSyncCPU),"CN64System::UpdateSyncCPU"); - Popad(); + AfterCallDirect(); } WriteX86Comment("Update Counter"); SubConstFromVariable(RegSet.GetBlockCycleCount(),_NextTimer,"_NextTimer"); // updates compare flag diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Ops.h b/Source/Project64/N64 System/Recompiler/Recompiler Ops.h index 40076afdf..e36467d1b 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Ops.h +++ b/Source/Project64/N64 System/Recompiler/Recompiler Ops.h @@ -182,8 +182,10 @@ protected: static void UnknownOpcode ( void ); - static void EnterCodeBlock ( void ); - static void ExitCodeBlock ( void ); + static void BeforeCallDirect ( void ); + static void AfterCallDirect ( void ); + static void EnterCodeBlock ( void ); + static void ExitCodeBlock ( void ); static void CompileReadTLBMiss (int AddressReg, int LookUpReg ); static void CompileWriteTLBMiss (int AddressReg, int LookUpReg ); static void UpdateCounters (CRegInfo & RegSet, bool CheckTimer, bool ClearValues = false ); diff --git a/Source/Project64/N64 System/Recompiler/Reg Info.cpp b/Source/Project64/N64 System/Recompiler/Reg Info.cpp index 753f31575..c0801ea00 100644 --- a/Source/Project64/N64 System/Recompiler/Reg Info.cpp +++ b/Source/Project64/N64 System/Recompiler/Reg Info.cpp @@ -139,15 +139,26 @@ void CRegInfo::Load_FPR_ToTop ( int Reg, int RegToLoad, FPU_STATE Format) if (Reg == RegToLoad) { //if different format then unmap original reg from stack for (i = 0; i < 8; i++) { - if (FpuMappedTo(i) == (DWORD)Reg) { - if (FpuState(i) != (DWORD)Format) { - UnMap_FPR(Reg,TRUE); - } - i = 8; + if (FpuMappedTo(i) != (DWORD)Reg) + { + continue; } + if (FpuState(i) != (DWORD)Format) { + UnMap_FPR(Reg,TRUE); + } + break; } } else { - UnMap_FPR(Reg,FALSE); + //if different format then unmap original reg from stack + for (i = 0; i < 8; i++) + { + if (FpuMappedTo(i) != (DWORD)Reg) + { + continue; + } + UnMap_FPR(Reg,FpuState(i) != (DWORD)Format); + break; + } } if (RegInStack(RegToLoad,Format)) { diff --git a/Source/Project64/N64 System/Recompiler/Section Info.cpp b/Source/Project64/N64 System/Recompiler/Section Info.cpp index ad8117b74..be883a0e3 100644 --- a/Source/Project64/N64 System/Recompiler/Section Info.cpp +++ b/Source/Project64/N64 System/Recompiler/Section Info.cpp @@ -1,12 +1,13 @@ #include "stdafx.h" -CCodeBlock::CCodeBlock(DWORD VAddrEnter, BYTE * RecompPos) : +CCodeBlock::CCodeBlock(DWORD VAddrEnter, BYTE * RecompPos, bool bDelaySlot) : m_VAddrEnter(VAddrEnter), m_VAddrFirst(VAddrEnter), m_VAddrLast(VAddrEnter), m_CompiledLocation(RecompPos), m_NoOfSections(1), - m_EnterSection(this, VAddrEnter, 1) + m_EnterSection(this, VAddrEnter, 1), + m_bDelaySlot(bDelaySlot) { AnalyseBlock(); } @@ -25,13 +26,29 @@ void CCodeBlock::AnalyseBlock ( void ) bool CCodeBlock::Compile() { - CPU_Message("====== Code Block ======"); + if (m_bDelaySlot) + { + CPU_Message("====== Delay Block ======"); + } else { + 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(); + if (m_bDelaySlot) + { + Pop(x86_EAX); + MoveX86regToVariable(x86_EAX,_PROGRAM_COUNTER,"_PROGRAM_COUNTER"); + } else { + EnterCodeBlock(); + } + + if (m_bDelaySlot) + { + m_EnterSection.GenerateX86Code(m_EnterSection.m_Test + 1); + } else { #ifdef tofix if (bLinkBlocks()) { for (int count = 0; count < BlockInfo.NoOfSections; count ++) { @@ -56,6 +73,7 @@ bool CCodeBlock::Compile() #ifdef tofix } #endif + } CompileExitCode(); return true; } diff --git a/Source/Project64/N64 System/Recompiler/X86ops.cpp b/Source/Project64/N64 System/Recompiler/X86ops.cpp index 9b2bf83d4..0c67d912c 100644 --- a/Source/Project64/N64 System/Recompiler/X86ops.cpp +++ b/Source/Project64/N64 System/Recompiler/X86ops.cpp @@ -125,8 +125,8 @@ void CX86Ops::AndVariableDispToX86Reg(void *Variable, const char * VariableName, { CPU_Message(" and %s, dword ptr [%s+%s*%i]",x86_Name(reg),VariableName, x86_Name(AddrReg), Multiply); - PUTDST16(m_RecompPos,0x0423 + (reg * 0x100)); - PUTDST16(m_RecompPos,0x0505 + CalcMultiplyCode(Multiply) + (AddrReg * 0x100)); + PUTDST16(m_RecompPos,0x0423 + (reg * 0x800)); + PUTDST8(m_RecompPos,0x05 + CalcMultiplyCode(Multiply) + (AddrReg * 0x8)); PUTDST32(m_RecompPos,Variable); } diff --git a/Source/Project64/N64 System/Rom Information Class.cpp b/Source/Project64/N64 System/Rom Information Class.cpp index 2bbf492cb..f25141d66 100644 --- a/Source/Project64/N64 System/Rom Information Class.cpp +++ b/Source/Project64/N64 System/Rom Information Class.cpp @@ -1,5 +1,4 @@ -#include "..\N64 System.h" -#include "..\\User Interface\\resource.h" +#include "stdafx.h" RomInformation::RomInformation (const char * RomFile): m_DeleteRomInfo(true), diff --git a/Source/Project64/N64 System/Speed Limitor Class.cpp b/Source/Project64/N64 System/Speed Limitor Class.cpp index d87897524..675eae469 100644 --- a/Source/Project64/N64 System/Speed Limitor Class.cpp +++ b/Source/Project64/N64 System/Speed Limitor Class.cpp @@ -1,6 +1,4 @@ -#include "..\N64 System.h" -#include - +#include "stdafx.h" #pragma comment(lib, "winmm.lib") CSpeedLimitor::CSpeedLimitor(CNotification * const _Notify ) : diff --git a/Source/Project64/Plugins/Audio Plugin.cpp b/Source/Project64/Plugins/Audio Plugin.cpp index 7193b92b6..6566c65f9 100644 --- a/Source/Project64/Plugins/Audio Plugin.cpp +++ b/Source/Project64/Plugins/Audio Plugin.cpp @@ -1,5 +1,4 @@ -#include "..\Plugin.h" -#include +#include "stdafx.h" void FixUPXIssue ( BYTE * ProgramLocation ); diff --git a/Source/Project64/Plugins/Controller Plugin.cpp b/Source/Project64/Plugins/Controller Plugin.cpp index 78a701bac..bf0800e4a 100644 --- a/Source/Project64/Plugins/Controller Plugin.cpp +++ b/Source/Project64/Plugins/Controller Plugin.cpp @@ -1,5 +1,4 @@ -#include "..\Plugin.h" -#include +#include "stdafx.h" void FixUPXIssue ( BYTE * ProgramLocation ); diff --git a/Source/Project64/Plugins/GFX plugin.cpp b/Source/Project64/Plugins/GFX plugin.cpp index bcc833b13..527bdc51e 100644 --- a/Source/Project64/Plugins/GFX plugin.cpp +++ b/Source/Project64/Plugins/GFX plugin.cpp @@ -1,5 +1,4 @@ -#include "..\Plugin.h" -#include +#include "stdafx.h" void FixUPXIssue ( BYTE * ProgramLocation ); diff --git a/Source/Project64/Plugins/Plugin Class.cpp b/Source/Project64/Plugins/Plugin Class.cpp index c83a16662..cf52864ec 100644 --- a/Source/Project64/Plugins/Plugin Class.cpp +++ b/Source/Project64/Plugins/Plugin Class.cpp @@ -1,17 +1,56 @@ -#include "..\Settings.h" -#include "..\Plugin.h" +#include "stdafx.h" CPlugins::CPlugins (const stdstr & PluginDir): m_PluginDir(PluginDir), m_Gfx(NULL), m_Audio(NULL), m_RSP(NULL), m_Control(NULL) { CreatePlugins(); + _Settings->RegisterChangeCB(Plugin_RSP_Current,this,(CSettings::SettingChangedFunc)PluginChanged); + _Settings->RegisterChangeCB(Plugin_GFX_Current,this,(CSettings::SettingChangedFunc)PluginChanged); + _Settings->RegisterChangeCB(Plugin_AUDIO_Current,this,(CSettings::SettingChangedFunc)PluginChanged); + _Settings->RegisterChangeCB(Plugin_CONT_Current,this,(CSettings::SettingChangedFunc)PluginChanged); + _Settings->RegisterChangeCB(Plugin_UseHleGfx,this,(CSettings::SettingChangedFunc)PluginChanged); + _Settings->RegisterChangeCB(Plugin_UseHleAudio,this,(CSettings::SettingChangedFunc)PluginChanged); + _Settings->RegisterChangeCB(Game_EditPlugin_Gfx,this,(CSettings::SettingChangedFunc)PluginChanged); + _Settings->RegisterChangeCB(Game_EditPlugin_Audio,this,(CSettings::SettingChangedFunc)PluginChanged); + _Settings->RegisterChangeCB(Game_EditPlugin_Contr,this,(CSettings::SettingChangedFunc)PluginChanged); + _Settings->RegisterChangeCB(Game_EditPlugin_RSP,this,(CSettings::SettingChangedFunc)PluginChanged); + } CPlugins::~CPlugins (void) { + _Settings->UnregisterChangeCB(Plugin_RSP_Current,this,(CSettings::SettingChangedFunc)PluginChanged); + _Settings->UnregisterChangeCB(Plugin_GFX_Current,this,(CSettings::SettingChangedFunc)PluginChanged); + _Settings->UnregisterChangeCB(Plugin_AUDIO_Current,this,(CSettings::SettingChangedFunc)PluginChanged); + _Settings->UnregisterChangeCB(Plugin_CONT_Current,this,(CSettings::SettingChangedFunc)PluginChanged); + _Settings->UnregisterChangeCB(Plugin_UseHleGfx,this,(CSettings::SettingChangedFunc)PluginChanged); + _Settings->UnregisterChangeCB(Plugin_UseHleAudio,this,(CSettings::SettingChangedFunc)PluginChanged); + _Settings->UnregisterChangeCB(Game_EditPlugin_Gfx,this,(CSettings::SettingChangedFunc)PluginChanged); + _Settings->UnregisterChangeCB(Game_EditPlugin_Audio,this,(CSettings::SettingChangedFunc)PluginChanged); + _Settings->UnregisterChangeCB(Game_EditPlugin_Contr,this,(CSettings::SettingChangedFunc)PluginChanged); + _Settings->UnregisterChangeCB(Game_EditPlugin_RSP,this,(CSettings::SettingChangedFunc)PluginChanged); ShutDownPlugins(); } +void CPlugins::PluginChanged ( CPlugins * _this ) +{ + bool bGfxChange = stricmp(_this->m_GfxFile.c_str(),_Settings->LoadString(Game_Plugin_Gfx).c_str()) != 0; + bool bAudioChange = stricmp(_this->m_AudioFile.c_str(),_Settings->LoadString(Game_Plugin_Audio).c_str()) != 0; + bool bRspChange = stricmp(_this->m_RSPFile.c_str(),_Settings->LoadString(Game_Plugin_RSP).c_str()) != 0; + bool bContChange = stricmp(_this->m_ControlFile.c_str(),_Settings->LoadString(Game_Plugin_Controller).c_str()) != 0; + + if ( bGfxChange || bAudioChange || bRspChange || bContChange ) + { + if (_Settings->LoadBool(GameRunning_CPU_Running) != 0) + { + if (_N64System) { _N64System->ExternalEvent(SysEvent_ChangePlugins); } + } else { + _this->Reset(); + _Notify->RefreshMenu(); + } + } +} + void CPlugins::CreatePlugins( void ) { Reset(PLUGIN_TYPE_GFX); Reset(PLUGIN_TYPE_AUDIO); @@ -156,7 +195,8 @@ void CPlugins::Reset ( PLUGIN_TYPE Type ) m_RSP = NULL; } { - stdstr_f RspPluginFile("%s%s",m_PluginDir.c_str(),_Settings->LoadString(Plugin_RSP_Current).c_str()); + m_RSPFile = _Settings->LoadString(Plugin_RSP_Current); + stdstr_f RspPluginFile("%s%s",m_PluginDir.c_str(),m_RSPFile.c_str()); WriteTraceF(TraceRSP,"Loading (%s): Starting",RspPluginFile.c_str()); m_RSP = new CRSP_Plugin(RspPluginFile.c_str()); WriteTrace(TraceRSP,"Loading Done"); @@ -185,7 +225,8 @@ void CPlugins::Reset ( PLUGIN_TYPE Type ) m_Gfx = NULL; } { - stdstr_f GfxPluginFile("%s%s",m_PluginDir.c_str(),_Settings->LoadString(Game_Plugin_Gfx).c_str()); + m_GfxFile = _Settings->LoadString(Game_Plugin_Gfx); + stdstr_f GfxPluginFile("%s%s",m_PluginDir.c_str(),m_GfxFile.c_str()); WriteTraceF(TraceGfxPlugin,"Loading (%s): Starting",GfxPluginFile.c_str()); m_Gfx = new CGfxPlugin(GfxPluginFile.c_str()); WriteTrace(TraceGfxPlugin,"Loading Done"); @@ -204,7 +245,8 @@ void CPlugins::Reset ( PLUGIN_TYPE Type ) m_Audio = NULL; } { - stdstr_f PluginFile("%s%s",m_PluginDir.c_str(),_Settings->LoadString(Game_Plugin_Audio).c_str()); + m_AudioFile = _Settings->LoadString(Game_Plugin_Audio); + stdstr_f PluginFile("%s%s",m_PluginDir.c_str(),m_AudioFile.c_str()); WriteTraceF(TraceDebug,"Loading (%s): Starting",PluginFile.c_str()); m_Audio = new CAudioPlugin(PluginFile.c_str()); WriteTrace(TraceDebug,"Loading Done"); @@ -222,7 +264,8 @@ void CPlugins::Reset ( PLUGIN_TYPE Type ) m_Control = NULL; } { - stdstr_f PluginFile("%s%s",m_PluginDir.c_str(),_Settings->LoadString(Game_Plugin_Controller).c_str()); + m_ControlFile = _Settings->LoadString(Game_Plugin_Controller); + stdstr_f PluginFile("%s%s",m_PluginDir.c_str(),m_ControlFile.c_str()); WriteTraceF(TraceDebug,"Loading (%s): Starting",PluginFile.c_str()); m_Control = new CControl_Plugin(PluginFile.c_str()); WriteTrace(TraceDebug,"Loading Done"); diff --git a/Source/Project64/Plugins/Plugin Class.h b/Source/Project64/Plugins/Plugin Class.h index a67003c63..d7055cf8d 100644 --- a/Source/Project64/Plugins/Plugin Class.h +++ b/Source/Project64/Plugins/Plugin Class.h @@ -79,12 +79,19 @@ class CPlugins { void CreatePlugins ( void ); void CreatePluginDir ( const stdstr & DstDir ) const; + static void PluginChanged ( CPlugins * _this ); + //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; + public: //Functions CPlugins (const stdstr & PluginDir ); diff --git a/Source/Project64/Plugins/RSP Plugin.cpp b/Source/Project64/Plugins/RSP Plugin.cpp index 88dcea7b5..648f0b4e5 100644 --- a/Source/Project64/Plugins/RSP Plugin.cpp +++ b/Source/Project64/Plugins/RSP Plugin.cpp @@ -1,5 +1,4 @@ -#include "..\Plugin.h" -#include +#include "stdafx.h" void FixUPXIssue ( BYTE * ProgramLocation ); void DummyFunc1 ( BOOL a) {} diff --git a/Source/Project64/Project64.dsp b/Source/Project64/Project64.dsp index 85a39b23e..e2cb0d183 100644 --- a/Source/Project64/Project64.dsp +++ b/Source/Project64/Project64.dsp @@ -44,7 +44,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "../" /I "./" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "../" /I "./" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c # SUBTRACT CPP /Fr # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -71,7 +71,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../" /I "./" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../" /I "./" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c # SUBTRACT CPP /Fr # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 @@ -100,7 +100,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "../" /I "./" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "EXTERNAL_RELEASE" /YX /FD /EHa /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I "../" /I "./" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "EXTERNAL_RELEASE" /Yu"stdafx.h" /FD /EHa /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0xc09 /d "NDEBUG" @@ -211,10 +211,6 @@ SOURCE="Settings\Recompiler Settings.cpp" # End Source File # Begin Source File -SOURCE="Settings\Setting Config.cpp" -# End Source File -# Begin Source File - SOURCE="Settings\Settings Class.cpp" # End Source File # End Group @@ -307,10 +303,6 @@ SOURCE="N64 System\Debugger\Debugger.cpp" # End Group # Begin Source File -SOURCE="User Interface\Cheats.cpp" -# End Source File -# Begin Source File - SOURCE="User Interface\Frame Per Second Class.cpp" # End Source File # Begin Source File @@ -414,18 +406,10 @@ SOURCE=".\N64 System\C Core\C main.cpp" # End Source File # Begin Source File -SOURCE="N64 System\C Core\C Memory.cpp" -# End Source File -# Begin Source File - SOURCE=".\N64 System\C Core\CPU Log.cpp" # End Source File # Begin Source File -SOURCE="N64 System\C Core\CPU.cpp" -# End Source File -# Begin Source File - SOURCE="N64 System\C Core\Dma.cpp" # End Source File # Begin Source File @@ -434,10 +418,6 @@ SOURCE=".\N64 System\C Core\Eeprom.cpp" # End Source File # Begin Source File -SOURCE=".\N64 System\C Core\Exception.cpp" -# End Source File -# Begin Source File - SOURCE=".\N64 System\C Core\FlashRam.cpp" # End Source File # Begin Source File @@ -458,47 +438,15 @@ SOURCE=".\N64 System\C Core\r4300i Commands.cpp" # End Source File # Begin Source File -SOURCE=".\N64 System\C Core\r4300i Memory.cpp" -# End Source File -# Begin Source File - SOURCE=".\N64 System\C Core\r4300i Registers.cpp" # End Source File # Begin Source File -SOURCE="N64 System\C Core\Recompiler CPU.cpp" -# End Source File -# Begin Source File - -SOURCE="N64 System\C Core\Recompiler Fpu Ops.cpp" -# End Source File -# Begin Source File - -SOURCE="N64 System\C Core\Registers.cpp" -# End Source File -# Begin Source File - SOURCE=".\N64 System\C Core\Sram.cpp" # End Source File # Begin Source File -SOURCE="N64 System\C Core\Sync CPU.c" -# End Source File -# Begin Source File - -SOURCE="N64 System\C Core\TLB Display.c" -# End Source File -# Begin Source File - -SOURCE="N64 System\C Core\Win32Timer.c" -# End Source File -# Begin Source File - -SOURCE=".\N64 System\C Core\x86 fpu.cpp" -# End Source File -# Begin Source File - -SOURCE=".\N64 System\C Core\X86.cpp" +SOURCE=".\N64 System\C Core\Win32Timer.cpp" # End Source File # End Group # Begin Group "Recompiler Files" @@ -635,19 +583,63 @@ SOURCE="Plugins\RSP Plugin.cpp" # Begin Source File SOURCE="3rd Party\zlib\UNZIP.C" + +!IF "$(CFG)" == "Project64 - Win32 Release" + +!ELSEIF "$(CFG)" == "Project64 - Win32 Debug" + +# SUBTRACT CPP /YX /Yc /Yu + +!ELSEIF "$(CFG)" == "Project64 - Win32 External Release" + +!ENDIF + # End Source File # Begin Source File SOURCE="3rd Party\zlib\zip.c" + +!IF "$(CFG)" == "Project64 - Win32 Release" + +!ELSEIF "$(CFG)" == "Project64 - Win32 Debug" + +# SUBTRACT CPP /YX /Yc /Yu + +!ELSEIF "$(CFG)" == "Project64 - Win32 External Release" + +!ENDIF + # End Source File # End Group # Begin Source File SOURCE="3rd Party\7zip.cpp" + +!IF "$(CFG)" == "Project64 - Win32 Release" + +!ELSEIF "$(CFG)" == "Project64 - Win32 Debug" + +# SUBTRACT CPP /YX /Yc /Yu + +!ELSEIF "$(CFG)" == "Project64 - Win32 External Release" + +!ENDIF + # End Source File # Begin Source File SOURCE="3rd Party\Processor Info.cpp" + +!IF "$(CFG)" == "Project64 - Win32 Release" + +!ELSEIF "$(CFG)" == "Project64 - Win32 Debug" + +# SUBTRACT CPP /YX /Yc /Yu + +!ELSEIF "$(CFG)" == "Project64 - Win32 External Release" + +!ENDIF + # End Source File # End Group # Begin Source File @@ -660,6 +652,11 @@ SOURCE=main.cpp # End Source File # Begin Source File +SOURCE=.\stdafx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# Begin Source File + SOURCE=ValidateBinary.cpp # End Source File # End Group @@ -911,10 +908,6 @@ SOURCE=".\User Interface\WTL Controls\PartialGroupBox.h" # End Group # Begin Source File -SOURCE="User Interface\Cheats.h" -# End Source File -# Begin Source File - SOURCE="User Interface\Frame Per Second Class.h" # End Source File # Begin Source File @@ -1030,18 +1023,6 @@ SOURCE="N64 System\C Core\C Core Interface.h" # End Source File # Begin Source File -SOURCE="N64 System\C Core\C Core.h" -# End Source File -# Begin Source File - -SOURCE="N64 System\C Core\C Global Variable.h" -# End Source File -# Begin Source File - -SOURCE="N64 System\C Core\C Memory.h" -# End Source File -# Begin Source File - SOURCE="N64 System\C Core\Core Settings.h" # End Source File # Begin Source File @@ -1066,10 +1047,6 @@ SOURCE="N64 System\C Core\Eeprom.h" # End Source File # Begin Source File -SOURCE="N64 System\C Core\Exception.h" -# End Source File -# Begin Source File - SOURCE="N64 System\C Core\Flashram.h" # End Source File # Begin Source File @@ -1090,10 +1067,6 @@ SOURCE="N64 System\C Core\Pif.h" # End Source File # Begin Source File -SOURCE="N64 System\C Core\Plugin.h" -# End Source File -# Begin Source File - SOURCE="N64 System\C Core\r4300i Commands.h" # End Source File # Begin Source File @@ -1106,40 +1079,12 @@ SOURCE="N64 System\C Core\r4300i Registers.h" # End Source File # Begin Source File -SOURCE="N64 System\C Core\Recompiler CPU.h" -# End Source File -# Begin Source File - -SOURCE="N64 System\C Core\Recompiler Ops.h" -# End Source File -# Begin Source File - -SOURCE="N64 System\C Core\Registers.h" -# End Source File -# Begin Source File - SOURCE="N64 System\C Core\Sram.h" # End Source File # Begin Source File -SOURCE="N64 System\C Core\Sync CPU.h" -# End Source File -# Begin Source File - -SOURCE="N64 System\C Core\tlb Display.h" -# End Source File -# Begin Source File - -SOURCE="N64 System\C Core\Tlb.h" -# End Source File -# Begin Source File - SOURCE="N64 System\C Core\Win32Timer.h" # End Source File -# Begin Source File - -SOURCE="N64 System\C Core\X86.h" -# End Source File # End Group # Begin Group "Debugger Headers" diff --git a/Source/Project64/Settings/Gui Settings.cpp b/Source/Project64/Settings/Gui Settings.cpp index dcae8b4a6..8e59dfb64 100644 --- a/Source/Project64/Settings/Gui Settings.cpp +++ b/Source/Project64/Settings/Gui Settings.cpp @@ -1,5 +1,4 @@ -#include "..\support.h" -#include "..\Settings.h" +#include "stdafx.h" int CGuiSettings::m_RefCount = 0; bool CGuiSettings::m_bCPURunning; diff --git a/Source/Project64/Settings/N64System Settings.cpp b/Source/Project64/Settings/N64System Settings.cpp index fa57e960c..38e57e8f0 100644 --- a/Source/Project64/Settings/N64System Settings.cpp +++ b/Source/Project64/Settings/N64System Settings.cpp @@ -1,5 +1,4 @@ -#include "..\support.h" -#include "..\Settings.h" +#include "stdafx.h" int CN64SystemSettings::m_RefCount = 0; diff --git a/Source/Project64/Settings/Notification Settings.cpp b/Source/Project64/Settings/Notification Settings.cpp index 3c72f3b91..02dcf53ed 100644 --- a/Source/Project64/Settings/Notification Settings.cpp +++ b/Source/Project64/Settings/Notification Settings.cpp @@ -1,5 +1,4 @@ -#include "..\Settings.h" -#include "Notification Settings.h" +#include "stdafx.h" bool CNotificationSettings::m_bInFullScreen = false; diff --git a/Source/Project64/Settings/Recompiler Settings.cpp b/Source/Project64/Settings/Recompiler Settings.cpp index 0ca1d8c70..1f42bd70b 100644 --- a/Source/Project64/Settings/Recompiler Settings.cpp +++ b/Source/Project64/Settings/Recompiler Settings.cpp @@ -1,5 +1,4 @@ -#pragma once -#include "..\Settings.h" +#include "stdafx.h" bool CRecompilerSettings::m_bShowRecompMemSize; bool CRecompilerSettings::m_bSMM_Protect; diff --git a/Source/Project64/Settings/Setting Config.cpp b/Source/Project64/Settings/Setting Config.cpp index d37965a2d..e69de29bb 100644 --- a/Source/Project64/Settings/Setting Config.cpp +++ b/Source/Project64/Settings/Setting Config.cpp @@ -1,1872 +0,0 @@ -#ifdef old -#include "..\\Multilanguage.h" -#include "..\\Settings.h" -#include "..\\Plugin.h" - -#include -#include -#include -#include - -#include "..\\User Interface\\resource.h" - -BOOL CALLBACK AdvancedOptionsProc ( HWND, UINT, WPARAM, LPARAM ); -BOOL CALLBACK DirSelectProc ( HWND, UINT, WPARAM, LPARAM ); -BOOL CALLBACK PluginSelectProc ( HWND, UINT, WPARAM, LPARAM ); -BOOL CALLBACK GeneralOptionsProc ( HWND, UINT, WPARAM, LPARAM ); -BOOL CALLBACK RomSettingsProc ( HWND, UINT, WPARAM, LPARAM ); -BOOL CALLBACK RomStatusProc ( HWND, UINT, WPARAM, LPARAM ); -int CALLBACK RomBrowserConfigProc ( DWORD, DWORD, DWORD, DWORD ); -BOOL CALLBACK ShortCutConfigProc ( HWND, UINT, WPARAM, LPARAM ); -BOOL CALLBACK ShellIntegrationProc ( HWND, UINT, WPARAM, LPARAM ); - -class SETTINGS_TAB { -public: - SETTINGS_TAB(LanguageStringID LanguageID, WORD TemplateID, DLGPROC pfnDlgProc) { - this->LanguageID = LanguageID; - this->TemplateID = TemplateID; - this->pfnDlgProc = pfnDlgProc; - } - stdstr Title; - LanguageStringID LanguageID; - WORD TemplateID; - DLGPROC pfnDlgProc; -} ; - -typedef std::vector SETTINGS_TAB_VECTOR; - -typedef struct { - CN64System * System; - CMainGui * Gui; -} SETTING_CLASSES; - -SETTINGS_TAB BasicSettingsTabs[] = { - SETTINGS_TAB( TAB_PLUGIN, IDD_Settings_PlugSel, PluginSelectProc ), - SETTINGS_TAB( TAB_OPTIONS, IDD_Settings_General, GeneralOptionsProc ), -}; - -SETTINGS_TAB AdvancedSettingsTabs[] = { - SETTINGS_TAB( TAB_DIRECTORY, IDD_Settings_Directory, DirSelectProc ), - SETTINGS_TAB( TAB_ADVANCED, IDD_Settings_Advanced, AdvancedOptionsProc ), - SETTINGS_TAB( TAB_ROMSELECTION, IDD_Settings_RomBrowser,(DLGPROC)RomBrowserConfigProc ), - SETTINGS_TAB( TAB_SHORTCUTS, IDD_Settings_Accelerator,ShortCutConfigProc ), - SETTINGS_TAB( TAB_SHELLINTERGATION,IDD_Settings_ShellInt, ShellIntegrationProc ), -}; - -SETTINGS_TAB RomSettingsTabs[] = { - SETTINGS_TAB( TAB_ROMSETTINGS, IDD_Settings_Rom, RomSettingsProc ), - SETTINGS_TAB( TAB_ROMSTATUS, IDD_Settings_RomStatus, RomStatusProc ), -}; - -enum { MaxConfigPages = 40 }; - -/*void CSettings::Config (void * ParentWindow, CN64System * System, CMainGui * Gui) { - if (_Lang == NULL) { return; } - int count; - - SETTING_CLASSES Classes; - Classes.System = System; - Classes.Gui = Gui; - - SETTINGS_TAB_VECTOR Tabs; - - for (count = 0; count < (sizeof(BasicSettingsTabs) / sizeof(SETTINGS_TAB)); count ++) { - Tabs.push_back(BasicSettingsTabs[count]); - } - if (LoadString(ROM_NAME).length() > 0) { - if (LoadString(ROM_MD5).length() == 0) { - CN64Rom * Rom = System->GetCurrentRom(); - if (Rom) - { - SaveDword(ROM_MD5,Rom->GetRomMD5().c_str()); - SaveDword(ROM_InternalName,Rom->GetRomName().c_str()); - } - } - for (count = 0; count < (sizeof(RomSettingsTabs) / sizeof(SETTINGS_TAB)); count ++) { - Tabs.push_back(RomSettingsTabs[count]); - } - } - if (!LoadDword(BasicMode)) { - for (count = 0; count < (sizeof(AdvancedSettingsTabs) / sizeof(SETTINGS_TAB)); count ++) { - Tabs.push_back(AdvancedSettingsTabs[count]); - } - } - - PROPSHEETPAGE psp[MaxConfigPages]; - - for (count = 0; count < Tabs.size(); count ++) { - Tabs[count].Title = _Lang->GetString(Tabs[count].LanguageID); - psp[count].dwSize = sizeof(PROPSHEETPAGE); - psp[count].dwFlags = PSP_USETITLE; - psp[count].hInstance = GetModuleHandle(NULL); - psp[count].pszTemplate = MAKEINTRESOURCE(Tabs[count].TemplateID); - psp[count].pfnDlgProc = Tabs[count].pfnDlgProc; - psp[count].pszTitle = Tabs[count].Title.c_str(); - psp[count].lParam = (long)&Classes; - psp[count].pfnCallback = NULL; - } - - PROPSHEETHEADER psh; - stdstr SettingTitle = _Lang->GetString(OPTIONS_TITLE); - psh.dwSize = sizeof(PROPSHEETHEADER); - psh.dwFlags = PSH_PROPSHEETPAGE; - psh.hwndParent = (HWND)ParentWindow; - psh.hInstance = GetModuleHandle(NULL); - psh.pszCaption = SettingTitle.c_str(); - psh.nPages = Tabs.size(); - psh.nStartPage = 0; - psh.ppsp = (LPCPROPSHEETPAGE) &psp; - psh.pfnCallback = NULL; - - PropertySheet(&psh); -}*/ - -/*void CSettings::ConfigRom (void * ParentWindow, CMainGui * Gui) -{ - if (_Lang == NULL) { return; } - int count; - - SETTING_CLASSES Classes; - Classes.System = NULL; - Classes.Gui = Gui; - - SETTINGS_TAB_VECTOR Tabs; - - for (count = 0; count < (sizeof(RomSettingsTabs) / sizeof(SETTINGS_TAB)); count ++) { - Tabs.push_back(RomSettingsTabs[count]); - } - - PROPSHEETPAGE psp[MaxConfigPages]; - - for (count = 0; count < Tabs.size(); count ++) { - Tabs[count].Title = _Lang->GetString(Tabs[count].LanguageID); - psp[count].dwSize = sizeof(PROPSHEETPAGE); - psp[count].dwFlags = PSP_USETITLE; - psp[count].hInstance = GetModuleHandle(NULL); - psp[count].pszTemplate = MAKEINTRESOURCE(Tabs[count].TemplateID); - psp[count].pfnDlgProc = Tabs[count].pfnDlgProc; - psp[count].pszTitle = _Lang->GetString(Tabs[count].LanguageID).c_str(); - psp[count].lParam = (long)&Classes; - psp[count].pfnCallback = NULL; - } - - PROPSHEETHEADER psh; - stdstr SettingTitle = _Lang->GetString(OPTIONS_TITLE); - psh.dwSize = sizeof(PROPSHEETHEADER); - psh.dwFlags = PSH_PROPSHEETPAGE; - psh.hwndParent = (HWND)ParentWindow; - psh.hInstance = GetModuleHandle(NULL); - psh.pszCaption = SettingTitle.c_str(); - psh.nPages = Tabs.size(); - psh.nStartPage = 0; - psh.ppsp = (LPCPROPSHEETPAGE) &psp; - psh.pfnCallback = NULL; - - PropertySheet(&psh); -}*/ - -typedef struct _PLUGIN_LIST{ - int Type; - WORD ListID; - WORD AboutID; - SettingID Setting_ID; - SettingID ChangeSettingID; - stdstr CurrentPlugin; - - _PLUGIN_LIST (int _Type, WORD _ListID, WORD _AboutID, SettingID _Setting_ID, SettingID _ChangeSettingID, LPCSTR _CurrentPlugin) : - Type(_Type), - ListID(_ListID), - AboutID(_AboutID), - Setting_ID(_Setting_ID), - ChangeSettingID(_ChangeSettingID), - CurrentPlugin(_CurrentPlugin) - { - } -} PLUGIN_LIST; - -PLUGIN_LIST Items[] = { - PLUGIN_LIST(PLUGIN_TYPE_RSP, RSP_LIST, RSP_ABOUT, CurrentRSP_Plugin, RSP_PluginChanged, "" ), - PLUGIN_LIST(PLUGIN_TYPE_GFX, GFX_LIST, GFX_ABOUT, CurrentGFX_Plugin, GFX_PluginChanged, "" ), - PLUGIN_LIST(PLUGIN_TYPE_AUDIO, AUDIO_LIST, AUDIO_ABOUT, CurrentAUDIO_Plugin, AUDIO_PluginChanged, "" ), - PLUGIN_LIST(PLUGIN_TYPE_CONTROLLER, CONT_LIST, CONT_ABOUT, CurrentCONT_Plugin, CONT_PluginChanged, "" ), -}; - -int AddDropDownItem (HWND hDlg, WORD CtrlID, LPCSTR StringID, int ItemData, DWORD * Variable) { - HWND hCtrl = GetDlgItem(hDlg,CtrlID); - int indx; - - indx = SendMessage(hCtrl,CB_ADDSTRING,0,(LPARAM)StringID); - SendMessage(hCtrl,CB_SETITEMDATA,indx,ItemData); - if (*Variable == ItemData) { SendMessage(hCtrl,CB_SETCURSEL,indx,0); } - if (SendMessage(hCtrl,CB_GETCOUNT,0,0) == 1) { SendMessage(hCtrl,CB_SETCURSEL,0,0); } - return indx; -} - -void SetFlagControl (HWND hDlg, bool Flag, WORD CtrlID, const char * Name) { - SetDlgItemText(hDlg,CtrlID,Name); - if (Flag) { SendMessage(GetDlgItem(hDlg,CtrlID),BM_SETCHECK, BST_CHECKED,0); } -} - -BOOL CALLBACK AdvancedOptionsProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch (uMsg) { - case WM_INITDIALOG: - { - //record class for future usage - LPPROPSHEETPAGE ps = (LPPROPSHEETPAGE)lParam; - SetProp((HWND)hDlg,"Classes",(SETTING_CLASSES *)ps->lParam); - SETTING_CLASSES * Classes = (SETTING_CLASSES *)ps->lParam; - - SetDlgItemText(hDlg,IDC_CORE_DEFAULTS,GS(ADVANCE_DEFAULTS)); - - //Self mod method - SetFlagControl(hDlg,_Settings->LoadDword(SYSTEM_SMM_Cache) != 0, IDC_SMM_CACHE, GS(ADVANCE_SMM_CACHE)); - SetFlagControl(hDlg,_Settings->LoadDword(SYSTEM_SMM_PIDMA) != 0, IDC_SMM_DMA, GS(ADVANCE_SMM_PIDMA)); - SetFlagControl(hDlg,_Settings->LoadDword(SYSTEM_SMM_ValidFunc) != 0, IDC_SMM_VALIDATE, GS(ADVANCE_SMM_VALIDATE)); - SetFlagControl(hDlg,_Settings->LoadDword(SYSTEM_SMM_Protect) != 0, IDC_SMM_PROTECT, GS(ADVANCE_SMM_PROTECT)); - SetFlagControl(hDlg,_Settings->LoadDword(SYSTEM_SMM_TLB) != 0, IDC_SMM_TLB, GS(ADVANCE_SMM_TLB)); - - SetFlagControl(hDlg,_Settings->LoadDword(AutoStart) != 0, IDC_START_ON_ROM_OPEN, GS(ADVANCE_AUTO_START)); - SetFlagControl(hDlg,_Settings->LoadDword(AutoZip) != 0, IDC_ZIP, GS(ADVANCE_COMPRESS)); - SetFlagControl(hDlg,_Settings->LoadDword(Debugger) != 0, IDC_DEBUGGER, GS(ADVANCE_DEBUGGER)); - - DWORD CPU_Type = _Settings->LoadDword(SYSTEM_CPUType); - AddDropDownItem(hDlg,IDC_CPU_TYPE,GS(CORE_INTERPTER),CPU_Interpreter,&CPU_Type); - AddDropDownItem(hDlg,IDC_CPU_TYPE,GS(CORE_RECOMPILER),CPU_Recompiler,&CPU_Type); - if (_Settings->LoadDword(Debugger)) { - AddDropDownItem(hDlg,IDC_CPU_TYPE,GS(CORE_SYNC),CPU_SyncCores,&CPU_Type); - } - - DWORD FunctionLookup = _Settings->LoadDword(SYSTEM_FunctionLookup); - AddDropDownItem(hDlg,IDC_FUNCFIND,GS(FLM_PLOOKUP),FuncFind_PhysicalLookup,&FunctionLookup); - AddDropDownItem(hDlg,IDC_FUNCFIND,GS(FLM_VLOOKUP),FuncFind_VirtualLookup,&FunctionLookup); - //AddDropDownItem(hDlg,IDC_FUNCFIND,GS(FLM_CHANGEMEM),FuncFind_ChangeMemory,&FunctionLookup); - - DWORD RDRamSize = _Settings->LoadDword(SYSTEM_RDRamSize); - AddDropDownItem(hDlg,IDC_RDRAM_SIZE,GS(RDRAM_4MB),0x400000,&RDRamSize); - AddDropDownItem(hDlg,IDC_RDRAM_SIZE,GS(RDRAM_8MB),0x800000,&RDRamSize); - - DWORD SystemABL = _Settings->LoadDword(SYSTEM_BlockLinking); - AddDropDownItem(hDlg,IDC_ABL,GS(ABL_ON),TRUE,(DWORD *)&SystemABL); - AddDropDownItem(hDlg,IDC_ABL,GS(ABL_OFF),FALSE,(DWORD *)&SystemABL); - } - break; - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_CPU_TYPE: - case IDC_RDRAM_SIZE: - case IDC_FUNCFIND: - case IDC_ABL: - if (HIWORD(wParam) == LBN_SELCHANGE) { - SendMessage(GetParent((HWND)hDlg),PSM_CHANGED ,(WPARAM)hDlg,0); - } - break; - case IDC_SMM_CACHE: - case IDC_SMM_DMA: - case IDC_SMM_VALIDATE: - case IDC_SMM_PROTECT: - case IDC_SMM_TLB: - case IDC_START_ON_ROM_OPEN: - case IDC_ZIP: - case IDC_DEBUGGER: - SendMessage(GetParent((HWND)hDlg),PSM_CHANGED ,(WPARAM)hDlg,0); - break; - - } - break; - case WM_NOTIFY: - if (((NMHDR FAR *) lParam)->code == PSN_APPLY) { - SETTING_CLASSES * Classes = (SETTING_CLASSES *)GetProp((HWND)hDlg,"Classes"); - int indx; - - indx = SendDlgItemMessage(hDlg,IDC_CPU_TYPE,CB_GETCURSEL,0,0); - _Settings->SaveDword(SYSTEM_CPUType,SendDlgItemMessage(hDlg,IDC_CPU_TYPE,CB_GETITEMDATA,indx >= 0 ? indx : 0,0)); - - indx = SendDlgItemMessage(hDlg,IDC_RDRAM_SIZE,CB_GETCURSEL,0,0); - _Settings->SaveDword(SYSTEM_RDRamSize,SendDlgItemMessage(hDlg,IDC_RDRAM_SIZE,CB_GETITEMDATA,indx >= 0 ? indx : 0,0)); - - indx = SendDlgItemMessage(hDlg,IDC_FUNCFIND,CB_GETCURSEL,0,0); - _Settings->SaveDword(SYSTEM_FunctionLookup,SendDlgItemMessage(hDlg,IDC_FUNCFIND,CB_GETITEMDATA,indx >= 0 ? indx : 0,0)); - - indx = SendDlgItemMessage(hDlg,IDC_ABL,CB_GETCURSEL,0,0); - _Settings->SaveDword(SYSTEM_BlockLinking,SendDlgItemMessage(hDlg,IDC_ABL,CB_GETITEMDATA,indx >= 0 ? indx : 0,0)); - - - _Settings->SaveDword(SYSTEM_SMM_Cache,SendMessage(GetDlgItem(hDlg,IDC_SMM_CACHE),BM_GETSTATE, 0,0) == BST_CHECKED); - _Settings->SaveDword(SYSTEM_SMM_PIDMA,SendMessage(GetDlgItem(hDlg,IDC_SMM_DMA),BM_GETSTATE, 0,0) == BST_CHECKED); - _Settings->SaveDword(SYSTEM_SMM_ValidFunc,SendMessage(GetDlgItem(hDlg,IDC_SMM_VALIDATE),BM_GETSTATE, 0,0) == BST_CHECKED); - _Settings->SaveDword(SYSTEM_SMM_Protect,SendMessage(GetDlgItem(hDlg,IDC_SMM_PROTECT),BM_GETSTATE, 0,0) == BST_CHECKED); - _Settings->SaveDword(SYSTEM_SMM_TLB,SendMessage(GetDlgItem(hDlg,IDC_SMM_TLB),BM_GETSTATE, 0,0) == BST_CHECKED); - - _Settings->SaveDword(AutoStart,SendMessage(GetDlgItem(hDlg,IDC_START_ON_ROM_OPEN),BM_GETSTATE, 0,0) == BST_CHECKED); - _Settings->SaveDword(AutoZip,SendMessage(GetDlgItem(hDlg,IDC_ZIP),BM_GETSTATE, 0,0) == BST_CHECKED); - _Settings->SaveDword(Debugger,SendMessage(GetDlgItem(hDlg,IDC_DEBUGGER),BM_GETSTATE, 0,0) == BST_CHECKED); - - CBaseMenu * Menu = Classes->Gui->GetMenuClass(); - Menu->ResetMenu(); - } - //Free allocated memory - if (((NMHDR FAR *) lParam)->code == PSN_RESET || - (((NMHDR FAR *) lParam)->code == PSN_APPLY && ((LPPSHNOTIFY)lParam)->lParam)) - { - RemoveProp((HWND)hDlg,"Classes"); - } - break; - default: - return FALSE; - } - return TRUE; -} - -int CALLBACK SelectDirCallBack (WND_HANDLE 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)hwnd,BFFM_SETSELECTION,TRUE,lpData); - } - break; - } - return 0; -} -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; -} - -void InputGetKeys (HWND hDlg ) { - HWND hKeyDlg = CreateDialogParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_Key_Prompt),hDlg,KeyPromptDlgProc,(LPARAM)GetDlgItem(hDlg,IDC_VIRTUALKEY)); - EnableWindow(GetParent(hDlg),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; - DWORD lKeyData = msg.lParam; - if (nVirtKey == VK_SHIFT) { continue; } - if (nVirtKey == VK_CONTROL) { continue; } - if (nVirtKey == VK_MENU) { continue; } - SendDlgItemMessage(hDlg,IDC_VIRTUALKEY,CB_SETCURSEL,-1,0); - for (int count = 0; count < SendDlgItemMessage(hDlg,IDC_VIRTUALKEY,CB_GETCOUNT,0,0); count++) { - int Data = (int)SendDlgItemMessage(hDlg,IDC_VIRTUALKEY,CB_GETITEMDATA,count,0); - if (Data != nVirtKey) { continue; } - SendDlgItemMessage(hDlg,IDC_VIRTUALKEY,CB_SETCURSEL,count,0); - SendDlgItemMessage(hDlg,IDC_CTL,BM_SETCHECK, (GetKeyState(VK_CONTROL) & 0x80) != 0 ? BST_CHECKED : BST_UNCHECKED,0); - SendDlgItemMessage(hDlg,IDC_ALT,BM_SETCHECK, (GetKeyState(VK_MENU) & 0x80) != 0 ? BST_CHECKED : BST_UNCHECKED,0); - SendDlgItemMessage(hDlg,IDC_SHIFT,BM_SETCHECK, (GetKeyState(VK_SHIFT) & 0x80) != 0 ? BST_CHECKED : BST_UNCHECKED,0); - SendMessage(hDlg,WM_COMMAND,MAKELPARAM(IDC_VIRTUALKEY,LBN_SELCHANGE),(LPARAM)GetDlgItem(hDlg,IDC_VIRTUALKEY)); - SetForegroundWindow(GetParent(hDlg)); - DestroyWindow(hKeyDlg); - } - continue; - } - if(!IsDialogMessage(hKeyDlg,&msg)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - - if(!IsWindow(hKeyDlg)) { fDone = true; } - - } - SetFocus(GetParent(hDlg)); - EnableWindow(GetParent(hDlg),true); -} - -void RefreshShortCutOptions ( HWND hDlg, HTREEITEM hItem ) -{ - SendDlgItemMessage(hDlg,IDC_CURRENT_KEYS,LB_RESETCONTENT,0,0); - - HWND hTree = GetDlgItem(hDlg,IDC_MENU_ITEMS); - - HTREEITEM hParent = TreeView_GetParent(hTree,hItem); - if (hParent == NULL) - { - return; - } - - TVITEM item; - item.mask = TVIF_PARAM; - item.hItem = (HTREEITEM)hItem; - TreeView_GetItem(hTree,&item); - - int SelIndex = SendDlgItemMessage(hDlg,IDC_C_CPU_STATE,CB_GETCURSEL,0,0); - int AccessLevel = SendDlgItemMessage(hDlg,IDC_C_CPU_STATE,CB_GETITEMDATA,SelIndex,0); - - MENU_SHORT_CUT * ShortCut = (MENU_SHORT_CUT *)item.lParam; - for (SHORTCUT_KEY_LIST::const_iterator ShortCut_item = ShortCut->GetAccelItems().begin(); ShortCut_item != ShortCut->GetAccelItems().end(); ShortCut_item++) - { - MENU_SHORT_CUT_KEY::ACCESS_MODE ItemMode = ShortCut_item->AccessMode(); - if ((ItemMode & AccessLevel) != AccessLevel ) - { - continue; - } - stdstr Name = ShortCut_item->Name(); - int index = SendDlgItemMessage(hDlg,IDC_CURRENT_KEYS,LB_ADDSTRING,0,(LPARAM)Name.c_str()); - SendDlgItemMessage(hDlg,IDC_CURRENT_KEYS,LB_SETITEMDATA,index,(LPARAM)&*ShortCut_item); - } -} - -BOOL CALLBACK ShortCutConfigProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch (uMsg) { - case WM_INITDIALOG: - { - //record class for future usage - LPPROPSHEETPAGE ps = (LPPROPSHEETPAGE)lParam; - SetProp((HWND)hDlg,"Classes",(SETTING_CLASSES *)ps->lParam); - SETTING_CLASSES * Classes = (SETTING_CLASSES *)ps->lParam; - CBaseMenu *Menu = Classes->Gui->GetMenuClass(); - - MSC_MAP * ShortCuts = new MSC_MAP(Menu->GetShortCutInfo(false)); - SetProp((HWND)hDlg,"ShortCuts",(SETTING_CLASSES *)ShortCuts); - - SetDlgItemText(hDlg,IDC_S_CPU_STATE,GS(ACCEL_CPUSTATE_TITLE)); - SetDlgItemText(hDlg,IDC_MENU_ITEM_TEXT,GS(ACCEL_MENUITEM_TITLE)); - SetDlgItemText(hDlg,IDC_S_CURRENT_KEYS,GS(ACCEL_CURRENTKEYS_TITLE)); - SetDlgItemText(hDlg,IDC_S_SELECT_SHORT,GS(ACCEL_SELKEY_TITLE)); - SetDlgItemText(hDlg,IDC_S_CURRENT_ASSIGN,GS(ACCEL_ASSIGNEDTO_TITLE)); - SetDlgItemText(hDlg,IDC_ASSIGN,GS(ACCEL_ASSIGN_BTN)); - SetDlgItemText(hDlg,IDC_REMOVE,GS(ACCEL_REMOVE_BTN)); - SetDlgItemText(hDlg,IDC_RESET,GS(ACCEL_RESETALL_BTN)); - - int index = SendDlgItemMessage(hDlg,IDC_C_CPU_STATE,CB_ADDSTRING,0,(LPARAM)GS(ACCEL_CPUSTATE_1)); - SendDlgItemMessage(hDlg,IDC_C_CPU_STATE,CB_SETITEMDATA,index,MENU_SHORT_CUT_KEY::GAME_NOT_RUNNING); - index = SendDlgItemMessage(hDlg,IDC_C_CPU_STATE,CB_ADDSTRING,0,(LPARAM)GS(ACCEL_CPUSTATE_3)); - SendDlgItemMessage(hDlg,IDC_C_CPU_STATE,CB_SETITEMDATA,index,MENU_SHORT_CUT_KEY::GAME_RUNNING_WINDOW); - SendDlgItemMessage(hDlg,IDC_C_CPU_STATE,CB_SETCURSEL,index,0); - index = SendDlgItemMessage(hDlg,IDC_C_CPU_STATE,CB_ADDSTRING,0,(LPARAM)GS(ACCEL_CPUSTATE_4)); - SendDlgItemMessage(hDlg,IDC_C_CPU_STATE,CB_SETITEMDATA,index,MENU_SHORT_CUT_KEY::GAME_RUNNING_FULLSCREEN); - - SendMessage(hDlg,WM_COMMAND,MAKELPARAM(IDC_C_CPU_STATE,LBN_SELCHANGE),(LPARAM)GetDlgItem(hDlg,IDC_C_CPU_STATE)); - - HWND hTree = GetDlgItem(hDlg,IDC_MENU_ITEMS); - DWORD Style = GetWindowLong(hTree,GWL_STYLE); - SetWindowLong(hTree,GWL_STYLE,TVS_SHOWSELALWAYS| Style); - } - break; - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_C_CPU_STATE: - if (HIWORD(wParam) == LBN_SELCHANGE) - { - SETTING_CLASSES * Classes = (SETTING_CLASSES *)GetProp((HWND)hDlg,"Classes"); - CBaseMenu *Menu = Classes->Gui->GetMenuClass(); - - int SelIndex = SendDlgItemMessage(hDlg,IDC_C_CPU_STATE,CB_GETCURSEL,0,0); - int AccessLevel = SendDlgItemMessage(hDlg,IDC_C_CPU_STATE,CB_GETITEMDATA,SelIndex,0); - MSC_MAP * ShortCuts = (MSC_MAP *)GetProp((HWND)hDlg,"ShortCuts"); - - - HWND hTree = GetDlgItem((HWND)hDlg, IDC_MENU_ITEMS); - - TreeView_DeleteAllItems(hTree); - for (MSC_MAP::iterator Item = ShortCuts->begin(); Item != ShortCuts->end(); Item++) - { - MENU_SHORT_CUT_KEY::ACCESS_MODE ItemMode = Item->second.AccessMode(); - if ((ItemMode & AccessLevel) != AccessLevel ) - { - continue; - } - - //find Parent - TV_INSERTSTRUCT tv; - tv.item.mask = TVIF_PARAM; - tv.item.hItem = TreeView_GetChild((HWND)hTree,TVI_ROOT); - while (tv.item.hItem) - { - TreeView_GetItem((HWND)hTree,&tv.item); - if (tv.item.lParam == Item->second.Section()) - { - break; - } - tv.item.hItem = TreeView_GetNextSibling(hTree,tv.item.hItem); - } - - if (tv.item.hItem == NULL) - { - char Text[500]; - - strcpy(Text,GS(Item->second.Section())); - - tv.item.mask = TVIF_TEXT | TVIF_PARAM; - tv.item.pszText = Text; - tv.item.lParam = Item->second.Section(); - tv.item.cchTextMax = sizeof(Text); - - tv.hInsertAfter = TVI_LAST; - tv.hParent = TVI_ROOT; - tv.item.hItem = TreeView_InsertItem((HWND)hTree,&tv); - } - - char Text[500]; - - stdstr str = GS(Item->second.Title()); - str.resize(std::remove(str.begin(), str.end(), '&') - str.begin()); - - tv.hParent = tv.item.hItem; - tv.hInsertAfter = TVI_LAST; - strcpy(Text,str.c_str()); - - tv.item.mask = TVIF_TEXT | TVIF_PARAM; - tv.item.pszText = Text; - tv.item.lParam = (WPARAM)&Item->second; - tv.item.cchTextMax = sizeof(Text); - - tv.item.hItem = TreeView_InsertItem((HWND)hTree,&tv); - } - - int VirtualKeyListSize; - VIRTUAL_KEY *VirtualKeyList = MENU_SHORT_CUT_KEY::VirtualKeyList(VirtualKeyListSize); - for (int count = 0; count < VirtualKeyListSize; count++) { - int index = SendDlgItemMessage(hDlg,IDC_VIRTUALKEY,CB_ADDSTRING,0,(LPARAM)VirtualKeyList[count].Name); - SendDlgItemMessage(hDlg,IDC_VIRTUALKEY,CB_SETITEMDATA,index,VirtualKeyList[count].Key); - } - //SendMessage(hDlg,WM_COMMAND,MAKELPARAM(IDC_MENU_ITEM_LIST,LBN_SELCHANGE),(LPARAM)GetDlgItem(hDlg,IDC_MENU_ITEM_LIST)); - SendMessage(hDlg,WM_COMMAND,MAKELPARAM(IDC_VIRTUALKEY,LBN_SELCHANGE),(LPARAM)GetDlgItem(hDlg,IDC_VIRTUALKEY)); - } - break; - case IDC_KEY_PROMPT: - { - CloseHandle(CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)InputGetKeys,hDlg,0,NULL)); - } - break; - case IDC_ASSIGN: - { - SETTING_CLASSES * Classes = (SETTING_CLASSES *)GetProp((HWND)hDlg,"Classes"); - CNotification * _Notify = Classes->Gui->GetNotifyClass(); - - //Get the virtual key info - int index = SendDlgItemMessage(hDlg,IDC_VIRTUALKEY,CB_GETCURSEL,0,0); - if (index < 0) { _Notify->DisplayError(GS(MSG_NO_SHORTCUT_SEL)); break; } - WORD key = SendDlgItemMessage(hDlg,IDC_VIRTUALKEY,CB_GETITEMDATA,index,0); - bool bCtrl = (SendDlgItemMessage(hDlg,IDC_CTL,BM_GETCHECK, 0,0) == BST_CHECKED); - bool bAlt = (SendDlgItemMessage(hDlg,IDC_ALT,BM_GETCHECK, 0,0) == BST_CHECKED); - bool bShift = (SendDlgItemMessage(hDlg,IDC_SHIFT,BM_GETCHECK, 0,0) == BST_CHECKED); - - int SelIndex = SendDlgItemMessage(hDlg,IDC_C_CPU_STATE,CB_GETCURSEL,0,0); - MENU_SHORT_CUT_KEY::ACCESS_MODE AccessLevel = (MENU_SHORT_CUT_KEY::ACCESS_MODE)SendDlgItemMessage(hDlg,IDC_C_CPU_STATE,CB_GETITEMDATA,SelIndex,0); - - HWND hTree = GetDlgItem(hDlg,IDC_MENU_ITEMS); - - HTREEITEM hSelectedItem = TreeView_GetSelection(hTree); - if (hSelectedItem == NULL) - { - _Notify->DisplayError(GS(MSG_NO_MENUITEM_SEL)); - break; - } - HTREEITEM hParent = TreeView_GetParent(hTree,hSelectedItem); - if (hParent == NULL) - { - _Notify->DisplayError(GS(MSG_NO_MENUITEM_SEL)); - break; - } - - TVITEM item; - item.mask = TVIF_PARAM; - item.hItem = (HTREEITEM)hSelectedItem; - TreeView_GetItem(hTree,&item); - - MENU_SHORT_CUT * ShortCut = (MENU_SHORT_CUT *)item.lParam; - - /*index = SendDlgItemMessage(hDlg,IDC_MENU_ITEM_LIST,LB_GETCURSEL,0,0); - if (index < 0) { _Notify->DisplayError(GS(MSG_NO_MENUITEM_SEL)); break; } - */ - CBaseMenu *Menu = Classes->Gui->GetMenuClass(); - MSC_MAP * ShortCuts = (MSC_MAP *)GetProp((HWND)hDlg,"ShortCuts"); - LanguageStringID strid = Menu->GetShortCutMenuItemName(ShortCuts,key,bCtrl,bAlt,bShift,AccessLevel); - if (strid != EMPTY_STRING) - { - _Notify->DisplayError(GS(MSG_MENUITEM_ASSIGNED)); - break; - } - - ShortCut->AddShortCut(key,bCtrl,bAlt,bShift,AccessLevel); - RefreshShortCutOptions(hDlg,hSelectedItem); - //SendMessage(hDlg,WM_COMMAND,MAKELPARAM(IDC_MENU_ITEM_LIST,LBN_SELCHANGE),(LPARAM)GetDlgItem(hDlg,IDC_MENU_ITEM_LIST)); - //SendMessage(hDlg,WM_COMMAND,MAKELPARAM(IDC_VIRTUALKEY,LBN_SELCHANGE),(LPARAM)GetDlgItem(hDlg,IDC_VIRTUALKEY)); - SendMessage(GetParent((HWND)hDlg),PSM_CHANGED ,(WPARAM)hDlg,0); - } - break; - //Remove a short cut key - case IDC_REMOVE: - { - SETTING_CLASSES * Classes = (SETTING_CLASSES *)GetProp((HWND)hDlg,"Classes"); - CNotification * _Notify = Classes->Gui->GetNotifyClass(); - - HWND hTree = GetDlgItem(hDlg,IDC_MENU_ITEMS); - - HTREEITEM hSelectedItem = TreeView_GetSelection(hTree); - if (hSelectedItem == NULL) - { - _Notify->DisplayError(GS(MSG_NO_SEL_SHORTCUT)); - break; - } - HTREEITEM hParent = TreeView_GetParent(hTree,hSelectedItem); - if (hParent == NULL) - { - _Notify->DisplayError(GS(MSG_NO_SEL_SHORTCUT)); - break; - } - - TVITEM item; - item.mask = TVIF_PARAM; - item.hItem = (HTREEITEM)hSelectedItem; - TreeView_GetItem(hTree,&item); - - int SelIndex = SendDlgItemMessage(hDlg,IDC_C_CPU_STATE,CB_GETCURSEL,0,0); - int AccessLevel = SendDlgItemMessage(hDlg,IDC_C_CPU_STATE,CB_GETITEMDATA,SelIndex,0); - - MENU_SHORT_CUT * ShortCut = (MENU_SHORT_CUT *)item.lParam; - - - //Male sure an item is selected - int index = SendDlgItemMessage(hDlg,IDC_CURRENT_KEYS,LB_GETCURSEL,0,0); - if (index < 0) { _Notify->DisplayError(GS(MSG_NO_SEL_SHORTCUT)); break; } - MENU_SHORT_CUT_KEY * ShortCutKey = (MENU_SHORT_CUT_KEY *)SendDlgItemMessage(hDlg,IDC_CURRENT_KEYS,LB_GETITEMDATA,index,0); - ShortCut->RemoveItem(ShortCutKey); - RefreshShortCutOptions(hDlg,hSelectedItem); - SendMessage(hDlg,WM_COMMAND,MAKELPARAM(IDC_VIRTUALKEY,LBN_SELCHANGE),(LPARAM)GetDlgItem(hDlg,IDC_VIRTUALKEY)); - SendMessage(GetParent((HWND)hDlg),PSM_CHANGED ,(WPARAM)hDlg,0); - } - break; -// case IDC_MENU_ITEM_LIST: -// { -// SETTING_CLASSES * Classes = (SETTING_CLASSES *)GetProp((HWND)hDlg,"Classes"); -// if (Classes == NULL) { break; } -// -// if (HIWORD(wParam) != LBN_SELCHANGE) { break; } -// SendDlgItemMessage(hDlg,IDC_CURRENT_KEYS,LB_RESETCONTENT,0,0); -// -// int index = SendDlgItemMessage(hDlg,IDC_MENU_ITEM_LIST,LB_GETCURSEL,0,0); -// if (index < 0) { break; } -// -// int SelIndex = SendDlgItemMessage(hDlg,IDC_C_CPU_STATE,CB_GETCURSEL,0,0); -// int AccessLevel = SendDlgItemMessage(hDlg,IDC_C_CPU_STATE,CB_GETITEMDATA,SelIndex,0); -// -// -// MENU_SHORT_CUT * ShortCut = (MENU_SHORT_CUT *)SendDlgItemMessage(hDlg,IDC_MENU_ITEM_LIST,LB_GETITEMDATA,index,0); -// for (SHORTCUT_KEY_LIST::const_iterator item = ShortCut->GetAccelItems().begin(); item != ShortCut->GetAccelItems().end(); item++) -// { -// MENU_SHORT_CUT_KEY::ACCESS_MODE ItemMode = item->AccessMode(); -// if ((ItemMode & AccessLevel) != AccessLevel ) -// { -// continue; -// } -// stdstr Name = item->Name(); -// index = SendDlgItemMessage(hDlg,IDC_CURRENT_KEYS,LB_ADDSTRING,0,(LPARAM)Name.c_str()); -// SendDlgItemMessage(hDlg,IDC_CURRENT_KEYS,LB_SETITEMDATA,index,(LPARAM)&*item); -// } -// } -// break; - case IDC_VIRTUALKEY: - if (HIWORD(wParam) != LBN_SELCHANGE) { break; } - case IDC_CTL: - case IDC_ALT: - case IDC_SHIFT: -// case IDC_RUNNING: - { - SETTING_CLASSES * Classes = (SETTING_CLASSES *)GetProp((HWND)hDlg,"Classes"); - - //Get the virtual key info - int index = SendDlgItemMessage(hDlg,IDC_VIRTUALKEY,CB_GETCURSEL,0,0); - if (index < 0) { break; } - WORD key = SendDlgItemMessage(hDlg,IDC_VIRTUALKEY,CB_GETITEMDATA,index,0); - bool bCtrl = (SendDlgItemMessage(hDlg,IDC_CTL,BM_GETCHECK, 0,0) == BST_CHECKED); - bool bAlt = (SendDlgItemMessage(hDlg,IDC_ALT,BM_GETCHECK, 0,0) == BST_CHECKED); - bool bShift = (SendDlgItemMessage(hDlg,IDC_SHIFT,BM_GETCHECK, 0,0) == BST_CHECKED); - - int SelIndex = SendDlgItemMessage(hDlg,IDC_C_CPU_STATE,CB_GETCURSEL,0,0); - MENU_SHORT_CUT_KEY::ACCESS_MODE AccessLevel = (MENU_SHORT_CUT_KEY::ACCESS_MODE)SendDlgItemMessage(hDlg,IDC_C_CPU_STATE,CB_GETITEMDATA,SelIndex,0); - - CNotification * _Notify = Classes->Gui->GetNotifyClass(); - CBaseMenu *Menu = Classes->Gui->GetMenuClass(); - MSC_MAP * ShortCuts = (MSC_MAP *)GetProp((HWND)hDlg,"ShortCuts"); - stdstr str = GS(Menu->GetShortCutMenuItemName(ShortCuts,key,bCtrl,bAlt,bShift,AccessLevel)); - str.resize(std::remove(str.begin(), str.end(), '&') - str.begin()); - if (str.length() == 0) - { - str = "None"; - } - SetDlgItemText(hDlg,IDC_ASSIGNED_MENU_ITEM,str.c_str()); - - } - break; - case IDC_RESET: - { - SETTING_CLASSES * Classes = (SETTING_CLASSES *)GetProp((HWND)hDlg,"Classes"); - - int result = MessageBox(NULL,GS(STR_SHORTCUT_RESET_TEXT),GS(STR_SHORTCUT_RESET_TITLE), - MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2); - if (result == IDNO) - { - break; - } - - CBaseMenu *Menu = Classes->Gui->GetMenuClass(); - - //Remove current short cuts - MSC_MAP * ShortCuts = (MSC_MAP *)GetProp((HWND)hDlg,"ShortCuts"); - RemoveProp((HWND)hDlg,"ShortCuts"); - delete ShortCuts; - - // Recreate short cuts - ShortCuts = new MSC_MAP(Menu->GetShortCutInfo(true)); - SetProp((HWND)hDlg,"ShortCuts",(SETTING_CLASSES *)ShortCuts); - - SendDlgItemMessage(hDlg,IDC_CURRENT_KEYS,LB_RESETCONTENT,0,0); - SendMessage(hDlg,WM_COMMAND,MAKELPARAM(IDC_C_CPU_STATE,LBN_SELCHANGE),(LPARAM)GetDlgItem(hDlg,IDC_C_CPU_STATE)); - SendMessage(GetParent((HWND)hDlg),PSM_CHANGED ,(WPARAM)hDlg,0); -// SendMessage(hDlg,WM_COMMAND,MAKELPARAM(IDC_MENU_ITEM_LIST,LBN_SELCHANGE),(LPARAM)GetDlgItem(hDlg,IDC_MENU_ITEM_LIST)); - SendMessage(hDlg,WM_COMMAND,MAKELPARAM(IDC_VIRTUALKEY,LBN_SELCHANGE),(LPARAM)GetDlgItem(hDlg,IDC_VIRTUALKEY)); - } - break; - } - break; - case WM_NOTIFY: - if (((NMHDR FAR *) lParam)->code == PSN_APPLY) { - SETTING_CLASSES * Classes = (SETTING_CLASSES *)GetProp((HWND)hDlg,"Classes"); - MSC_MAP * ShortCuts = (MSC_MAP *)GetProp((HWND)hDlg,"ShortCuts"); - CBaseMenu * Menu = Classes->Gui->GetMenuClass(); - Menu->SaveShortCuts(ShortCuts); - Menu->ResetMenu(); - } - //Free allocated memory - if (((NMHDR FAR *) lParam)->code == PSN_RESET || - (((NMHDR FAR *) lParam)->code == PSN_APPLY && ((LPPSHNOTIFY)lParam)->lParam)) - { - MSC_MAP * ShortCuts = (MSC_MAP *)GetProp((HWND)hDlg,"ShortCuts"); - delete ShortCuts; - RemoveProp((HWND)hDlg,"ShortCuts"); - RemoveProp((HWND)hDlg,"Classes"); - } - - { - LPNMHDR lpnmh = (LPNMHDR) lParam; - if ((lpnmh->code == TVN_SELCHANGED) && (lpnmh->idFrom == IDC_MENU_ITEMS)) - { - LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam; - RefreshShortCutOptions(hDlg,pnmtv->itemNew.hItem); - - } - } - break; - default: - return FALSE; - } - return TRUE; -} - -BOOL CALLBACK DirSelectProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch (uMsg) { - case WM_INITDIALOG: - { - //record class for future usage - LPPROPSHEETPAGE ps = (LPPROPSHEETPAGE)lParam; - SetProp((HWND)hDlg,"Classes",(SETTING_CLASSES *)ps->lParam); - SETTING_CLASSES * Classes = (SETTING_CLASSES *)ps->lParam; - - stdstr &TexturePath = _Settings->LoadString(TextureDir); - - SendMessage(GetDlgItem(hDlg,_Settings->LoadDword(UsePluginDirSelected) ? IDC_PLUGIN_OTHER : IDC_PLUGIN_DEFAULT),BM_SETCHECK, BST_CHECKED,0); - SendMessage(GetDlgItem(hDlg,_Settings->LoadDword(UseSaveDirSelected) ? IDC_AUTO_OTHER : IDC_AUTO_DEFAULT),BM_SETCHECK, BST_CHECKED,0); - SendMessage(GetDlgItem(hDlg,_Settings->LoadDword(UseInstantDirSelected) ? IDC_INSTANT_OTHER : IDC_INSTANT_DEFAULT),BM_SETCHECK, BST_CHECKED,0); - SendMessage(GetDlgItem(hDlg,_Settings->LoadDword(UseSnapShotDirSelected) ? IDC_SNAP_OTHER : IDC_SNAP_DEFAULT),BM_SETCHECK, BST_CHECKED,0); - SendMessage(GetDlgItem(hDlg,TexturePath.empty() ? IDC_TEXTURE_DEFAULT : IDC_TEXTURE_OTHER),BM_SETCHECK, BST_CHECKED,0); - - SetDlgItemText(hDlg,IDC_PLUGIN_DIR,_Settings->LoadString(SelectedPluginDirectory).c_str()); - SetDlgItemText(hDlg,IDC_INSTANT_DIR,_Settings->LoadString(SelectedInstantSaveDirectory).c_str()); - SetDlgItemText(hDlg,IDC_AUTO_DIR,_Settings->LoadString(SelectedSaveDirectory).c_str()); - SetDlgItemText(hDlg,IDC_SNAP_DIR,_Settings->LoadString(SelectedSnapShotDir).c_str()); - SetDlgItemText(hDlg,IDC_TEXTURE_DIR,TexturePath.empty() ? _Settings->LoadString(InitialTextureDir).c_str() : TexturePath.c_str()); - - //Set Text language for the dialog box - SetDlgItemText(hDlg,IDC_DIR_FRAME1,GS(DIR_PLUGIN)); - SetDlgItemText(hDlg,IDC_DIR_FRAME3,GS(DIR_AUTO_SAVE)); - SetDlgItemText(hDlg,IDC_DIR_FRAME4,GS(DIR_INSTANT_SAVE)); - SetDlgItemText(hDlg,IDC_DIR_FRAME5,GS(DIR_SCREEN_SHOT)); - SetDlgItemText(hDlg,IDC_DIR_TEXTURE_FRAME,GS(DIR_TEXTURE)); - } - break; - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_SELECT_PLUGIN_DIR: - case IDC_SELECT_INSTANT_DIR: - case IDC_SELECT_AUTO_DIR: - case IDC_SELECT_SNAP_DIR: - case IDC_SELECT_TEXTURE_DIR: - { - SETTING_CLASSES * Classes = (SETTING_CLASSES *)GetProp((HWND)hDlg,"Classes"); - - char Buffer[MAX_PATH], Directory[255]; - LPITEMIDLIST pidl; - BROWSEINFO bi; - - //get the title of the select box - char Title[255]; - switch (LOWORD(wParam)) { - case IDC_SELECT_PLUGIN_DIR: strcpy(Title,GS(DIR_SELECT_PLUGIN)); break; - case IDC_SELECT_AUTO_DIR: strcpy(Title,GS(DIR_SELECT_AUTO)); break; - case IDC_SELECT_INSTANT_DIR: strcpy(Title,GS(DIR_SELECT_INSTANT)); break; - case IDC_SELECT_SNAP_DIR: strcpy(Title,GS(DIR_SELECT_SCREEN)); break; - case IDC_SELECT_TEXTURE_DIR: strcpy(Title,GS(DIR_SELECT_TEXTURE)); break; - } - - //Get the initial Dir - char InitialDir[_MAX_PATH]; - switch (LOWORD(wParam)) { - case IDC_SELECT_PLUGIN_DIR: GetDlgItemText(hDlg,IDC_PLUGIN_DIR,InitialDir,sizeof(InitialDir)); break; - case IDC_SELECT_AUTO_DIR: GetDlgItemText(hDlg,IDC_AUTO_DIR,InitialDir,sizeof(InitialDir)); break; - case IDC_SELECT_INSTANT_DIR: GetDlgItemText(hDlg,IDC_INSTANT_DIR,InitialDir,sizeof(InitialDir)); break; - case IDC_SELECT_SNAP_DIR: GetDlgItemText(hDlg,IDC_SNAP_DIR,InitialDir,sizeof(InitialDir)); break; - case IDC_SELECT_TEXTURE_DIR: GetDlgItemText(hDlg,IDC_TEXTURE_DIR,InitialDir,sizeof(InitialDir)); break; - } - - - bi.hwndOwner = hDlg; - bi.pidlRoot = NULL; - bi.pszDisplayName = Buffer; - bi.lpszTitle = Title; - bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; - bi.lpfn = (BFFCALLBACK)SelectDirCallBack; - bi.lParam = (DWORD)InitialDir; - if ((pidl = SHBrowseForFolder(&bi)) != NULL) { - if (SHGetPathFromIDList(pidl, Directory)) { - int len = strlen(Directory); - - if (Directory[len - 1] != '\\') { strcat(Directory,"\\"); } - switch (LOWORD(wParam)) { - case IDC_SELECT_PLUGIN_DIR: - SetDlgItemText(hDlg,IDC_PLUGIN_DIR,Directory); - SendMessage(GetDlgItem(hDlg,IDC_PLUGIN_DEFAULT),BM_SETCHECK, BST_UNCHECKED,0); - SendMessage(GetDlgItem(hDlg,IDC_PLUGIN_OTHER),BM_SETCHECK, BST_CHECKED,0); - break; - case IDC_SELECT_INSTANT_DIR: - SetDlgItemText(hDlg,IDC_INSTANT_DIR,Directory); - SendMessage(GetDlgItem(hDlg,IDC_INSTANT_DEFAULT),BM_SETCHECK, BST_UNCHECKED,0); - SendMessage(GetDlgItem(hDlg,IDC_INSTANT_OTHER),BM_SETCHECK, BST_CHECKED,0); - break; - case IDC_SELECT_AUTO_DIR: - SetDlgItemText(hDlg,IDC_AUTO_DIR,Directory); - SendMessage(GetDlgItem(hDlg,IDC_AUTO_DEFAULT),BM_SETCHECK, BST_UNCHECKED,0); - SendMessage(GetDlgItem(hDlg,IDC_AUTO_OTHER),BM_SETCHECK, BST_CHECKED,0); - break; - case IDC_SELECT_SNAP_DIR: - SetDlgItemText(hDlg,IDC_SNAP_DIR,Directory); - SendMessage(GetDlgItem(hDlg,IDC_SNAP_DEFAULT),BM_SETCHECK, BST_UNCHECKED,0); - SendMessage(GetDlgItem(hDlg,IDC_SNAP_OTHER),BM_SETCHECK, BST_CHECKED,0); - break; - case IDC_SELECT_TEXTURE_DIR: - SetDlgItemText(hDlg,IDC_TEXTURE_DIR,Directory); - SendMessage(GetDlgItem(hDlg,IDC_TEXTURE_DEFAULT),BM_SETCHECK, BST_UNCHECKED,0); - SendMessage(GetDlgItem(hDlg,IDC_TEXTURE_OTHER),BM_SETCHECK, BST_CHECKED,0); - break; - } - SendMessage(GetParent(hDlg),PSM_CHANGED ,(WPARAM)hDlg,0); - } - } - } - break; - - } - break; - case WM_NOTIFY: - if (((NMHDR FAR *) lParam)->code == PSN_APPLY) { - SETTING_CLASSES * Classes = (SETTING_CLASSES *)GetProp((HWND)hDlg,"Classes"); - - //Current Dir - stdstr strRomDir = _Settings->LoadString(RomDirectory); - - //Save all selected dirs - char String[300]; - - GetDlgItemText(hDlg,IDC_PLUGIN_DIR,String,sizeof(String)); - _Settings->SaveString(SelectedPluginDirectory,String); - GetDlgItemText(hDlg,IDC_AUTO_DIR,String,sizeof(String)); - _Settings->SaveString(SelectedSaveDirectory,String); - GetDlgItemText(hDlg,IDC_INSTANT_DIR,String,sizeof(String)); - _Settings->SaveString(SelectedInstantSaveDirectory,String); - GetDlgItemText(hDlg,IDC_SNAP_DIR,String,sizeof(String)); - _Settings->SaveString(SelectedSnapShotDir,String); - if (SendMessage(GetDlgItem(hDlg,IDC_TEXTURE_DEFAULT),BM_GETSTATE, 0,0) != BST_CHECKED) - { - GetDlgItemText(hDlg,IDC_TEXTURE_DIR,String,sizeof(String)); - _Settings->SaveString(TextureDir,String); - } else { - _Settings->SaveString(TextureDir,""); - } - - //Save if using selected - _Settings->SaveDword(UsePluginDirSelected,SendMessage(GetDlgItem(hDlg,IDC_PLUGIN_DEFAULT),BM_GETSTATE, 0,0) != BST_CHECKED); - _Settings->SaveDword(UseSaveDirSelected,SendMessage(GetDlgItem(hDlg,IDC_AUTO_DEFAULT),BM_GETSTATE, 0,0) != BST_CHECKED); - _Settings->SaveDword(UseInstantDirSelected,SendMessage(GetDlgItem(hDlg,IDC_INSTANT_DEFAULT),BM_GETSTATE, 0,0) != BST_CHECKED); - _Settings->SaveDword(UseSnapShotDirSelected,SendMessage(GetDlgItem(hDlg,IDC_SNAP_DEFAULT),BM_GETSTATE, 0,0) != BST_CHECKED); - - SettingID Dir; - Dir = _Settings->LoadDword(UsePluginDirSelected) ? SelectedPluginDirectory : InitialPluginDirectory ; - _Settings->SaveString(PluginDirectory,_Settings->LoadString(Dir).c_str()); - Dir = _Settings->LoadDword(UseSaveDirSelected) ? SelectedSaveDirectory : InitialSaveDirectory ; - _Settings->SaveString(SaveDirectory,_Settings->LoadString(Dir).c_str()); - Dir = _Settings->LoadDword(UseInstantDirSelected) ? SelectedInstantSaveDirectory : InitialInstantSaveDirectory ; - _Settings->SaveString(InstantSaveDirectory,_Settings->LoadString(Dir).c_str()); - Dir = _Settings->LoadDword(UseSnapShotDirSelected) ? SelectedSnapShotDir : InitialSnapShotDir ; - _Settings->SaveString(SnapShotDir,_Settings->LoadString(Dir).c_str()); - - } - //Free allocated memory - if (((NMHDR FAR *) lParam)->code == PSN_RESET || - (((NMHDR FAR *) lParam)->code == PSN_APPLY && ((LPPSHNOTIFY)lParam)->lParam)) - { - RemoveProp((HWND)hDlg,"Classes"); - } - break; - case WM_CLOSE: - _asm int 3 - break; - default: - return FALSE; - } - return TRUE; -} - -BOOL CALLBACK PluginSelectProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - PluginList * List = NULL; - int index; - - switch (uMsg) { - case WM_INITDIALOG: - { - //record class for future usage - LPPROPSHEETPAGE ps = (LPPROPSHEETPAGE)lParam; - SetProp((HWND)hDlg,"Classes",(SETTING_CLASSES *)ps->lParam); - SETTING_CLASSES * Classes = (SETTING_CLASSES *)ps->lParam; - - //Set the text for all gui Items - SetDlgItemText(hDlg,RSP_ABOUT,GS(PLUG_ABOUT)); - SetDlgItemText(hDlg,GFX_ABOUT,GS(PLUG_ABOUT)); - SetDlgItemText(hDlg,AUDIO_ABOUT,GS(PLUG_ABOUT)); - SetDlgItemText(hDlg,CONT_ABOUT,GS(PLUG_ABOUT)); - - SetDlgItemText(hDlg,IDC_RSP_NAME,GS(PLUG_RSP)); - SetDlgItemText(hDlg,IDC_GFX_NAME,GS(PLUG_GFX)); - SetDlgItemText(hDlg,IDC_AUDIO_NAME,GS(PLUG_AUDIO)); - SetDlgItemText(hDlg,IDC_CONT_NAME,GS(PLUG_CTRL)); - - SetDlgItemText(hDlg,IDC_HLE_GFX,GS(PLUG_HLE_GFX)); - SetDlgItemText(hDlg,IDC_HLE_AUDIO,GS(PLUG_HLE_AUDIO)); - - //Create the list of plugins - CPluginList Plugins(_Settings); - List = new PluginList; - *List = Plugins.GetPluginList(); - SetProp((HWND)hDlg,"Plugin List",List); - - for (int count = 0; count < sizeof(Items) / sizeof(Items[0]); count++) { - Items[count].CurrentPlugin = _Settings->LoadString(Items[count].Setting_ID); - } - - //Add in all the plugins to the gui - for (PluginList::iterator PluginIter = List->begin(); PluginIter != List->end(); PluginIter++) { - PLUGIN * Plugin = &(*PluginIter); - - for (int count = 0; count < sizeof(Items) / sizeof(Items[0]); count++) { - if (Plugin->info.Type != Items[count].Type) { continue; } - - index = SendMessage(GetDlgItem(hDlg,Items[count].ListID),CB_ADDSTRING,(WPARAM)0, (LPARAM)&Plugin->info.Name); - SendMessage(GetDlgItem(hDlg,Items[count].ListID),CB_SETITEMDATA ,(WPARAM)index, (LPARAM)Plugin); - - //See if added plugin is currently selected - if(_stricmp(Items[count].CurrentPlugin.c_str(),Plugin->FileName.c_str()) != 0) { continue; } - SendMessage(GetDlgItem(hDlg,Items[count].ListID),CB_SETCURSEL,(WPARAM)index,(LPARAM)0); - EnableWindow(GetDlgItem(hDlg,Items[count].AboutID),Plugin->InfoFunction); - break; - } - } - - if (_Settings->LoadDword(UseHighLevelGfx)) { SendMessage(GetDlgItem((HWND)hDlg,IDC_HLE_GFX),BM_SETCHECK, BST_CHECKED,0); } - if (_Settings->LoadDword(UseHighLevelAudio)) { SendMessage(GetDlgItem((HWND)hDlg,IDC_HLE_AUDIO),BM_SETCHECK, BST_CHECKED,0); } - - } - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_HLE_GFX: - { - SETTING_CLASSES * Classes = (SETTING_CLASSES *)GetProp((HWND)hDlg,"Classes"); - - if ((SendMessage(GetDlgItem(hDlg,IDC_HLE_GFX), BM_GETSTATE, 0,0) & BST_CHECKED) == 0) - { - stdstr Caption(GS(MSG_SET_LLE_GFX_TITLE)),Message(GS(MSG_SET_LLE_GFX_MSG)); - if (MessageBox(hDlg,Message.c_str(),Caption.c_str(),MB_OKCANCEL|MB_ICONWARNING) != IDOK) - { - SendMessage(GetDlgItem((HWND)hDlg,IDC_HLE_GFX),BM_SETCHECK, BST_CHECKED,0); - break; - } - } - SendMessage(GetParent((HWND)hDlg),PSM_CHANGED ,(WPARAM)hDlg,0); - } - break; - case IDC_HLE_AUDIO: - { - SETTING_CLASSES * Classes = (SETTING_CLASSES *)GetProp((HWND)hDlg,"Classes"); - - if ((SendMessage(GetDlgItem(hDlg,IDC_HLE_AUDIO), BM_GETSTATE, 0,0) & BST_CHECKED) != 0) - { - stdstr Caption(GS(MSG_SET_HLE_AUD_TITLE)),Message(GS(MSG_SET_HLE_AUD_MSG)); - if (MessageBox(hDlg,Message.c_str(),Caption.c_str(),MB_OKCANCEL|MB_ICONWARNING) != IDOK) - { - SendMessage(GetDlgItem((HWND)hDlg,IDC_HLE_AUDIO),BM_SETCHECK, BST_UNCHECKED,0); - break; - } - } - SendMessage(GetParent((HWND)hDlg),PSM_CHANGED ,(WPARAM)hDlg,0); - } - break; - } - //Highlight the about button if the plugin has the dll about function - if (HIWORD(wParam) == CBN_SELCHANGE) { - for (int count = 0; count < sizeof(Items) / sizeof(Items[0]); count++) { - if (LOWORD(wParam) != Items[count].ListID) { continue; } - index = SendMessage(GetDlgItem(hDlg,LOWORD(wParam)),CB_GETCURSEL,0,0); - if (index == CB_ERR) { break; } - PLUGIN * Plugin = (PLUGIN *)SendMessage(GetDlgItem(hDlg,LOWORD(wParam)),CB_GETITEMDATA,(WPARAM)index,0); - EnableWindow(GetDlgItem(hDlg,Items[count].AboutID),Plugin->InfoFunction); - break; - } - SendMessage(GetParent(hDlg),PSM_CHANGED ,(WPARAM)hDlg,0); - } else { - SETTING_CLASSES * Classes = (SETTING_CLASSES *)GetProp((HWND)hDlg,"Classes"); - - //Check for about button pressed - for (int count = 0; count < sizeof(Items) / sizeof(Items[0]); count++) { - if (LOWORD(wParam) != Items[count].AboutID) { continue; } - - index = SendMessage(GetDlgItem(hDlg,Items[count].ListID),CB_GETCURSEL,0,0); - PLUGIN * Plugin = (PLUGIN *)SendMessage(GetDlgItem(hDlg,Items[count].ListID),CB_GETITEMDATA,(WPARAM)index,0); - - CPluginList Plugins(_Settings); - - Plugins.DllAbout((void *)hDlg,Plugin->FullPath.c_str()); - } - } - break; - case WM_NOTIFY: - //Save each selected plugin - if (((NMHDR FAR *) lParam)->code == PSN_APPLY) { - SETTING_CLASSES * Classes = (SETTING_CLASSES *)GetProp((HWND)hDlg,"Classes"); - - List = (PluginList *)GetProp(hDlg,"Plugin List"); - - bool PluginsChanged = false; - for (int count = 0; count < sizeof(Items) / sizeof(Items[0]); count++) { - index = SendMessage(GetDlgItem(hDlg,Items[count].ListID),CB_GETCURSEL,0,0); - if (index < 0) { continue; } - PLUGIN * Plugin = (PLUGIN *)SendMessage(GetDlgItem(hDlg,Items[count].ListID),CB_GETITEMDATA,(WPARAM)index,0); - if (_Settings->LoadString(Items[count].Setting_ID) != Plugin->FileName.c_str()) { - PluginsChanged = true; - _Settings->SaveString(Items[count].Setting_ID,Plugin->FileName.c_str()); - _Settings->SaveDword(Items[count].ChangeSettingID,true); - } - } - - if (_Settings->LoadDword(UseHighLevelGfx) != SendMessage(GetDlgItem(hDlg,IDC_HLE_GFX), BM_GETSTATE, 0,0) == BST_CHECKED) - { - _Settings->SaveDword(UseHighLevelGfx, SendMessage(GetDlgItem(hDlg,IDC_HLE_GFX), BM_GETSTATE, 0,0) == BST_CHECKED); - _Settings->SaveDword(Items[0].ChangeSettingID,true); - PluginsChanged = true; - - } - if (_Settings->LoadDword(UseHighLevelAudio) != SendMessage(GetDlgItem(hDlg,IDC_HLE_AUDIO), BM_GETSTATE, 0,0) == BST_CHECKED) - { - _Settings->SaveDword(UseHighLevelAudio,SendMessage(GetDlgItem(hDlg,IDC_HLE_AUDIO),BM_GETSTATE, 0,0) == BST_CHECKED); - _Settings->SaveDword(Items[0].ChangeSettingID,true); - PluginsChanged = true; - - } - - if (PluginsChanged) { - if (_Settings->LoadDword(CPU_Running) != 0) { - Classes->System->ExternalEvent(ChangePlugins); - } else { - Classes->System->Plugins()->Reset(); - Classes->Gui->RefreshMenu(); - } - } - } - - //Free allocated memory - if (((NMHDR FAR *) lParam)->code == PSN_RESET || - (((NMHDR FAR *) lParam)->code == PSN_APPLY && ((LPPSHNOTIFY)lParam)->lParam)) - { - List = (PluginList *)GetProp(hDlg,"Plugin List"); - delete List; - - RemoveProp((HWND)hDlg,"Plugin List"); - RemoveProp((HWND)hDlg,"Classes"); - } - break; - default: - return false; - } - return true; -} - -bool RomBrowserConfig_FieldsChanged (HWND hDlg,ROMBROWSER_FIELDS_LIST * Fields) { - int ItemsSelected = 0; - for (int count = 0; count < Fields->size(); count++) { - if ((*Fields)[count].Pos >= 0) { ItemsSelected += 1; } - } - - int listCount = SendDlgItemMessage((HWND)hDlg,IDC_USING,LB_GETCOUNT,0,0); - if (listCount != ItemsSelected) { return true; } - for (int Item = 0; Item < listCount; Item ++ ){ - int Pos = SendMessage(GetDlgItem((HWND)hDlg,IDC_USING),LB_GETITEMDATA,Item,0); - if ((*Fields)[Pos].Pos != Item) { return true; }; - } - return false; -} - -int CALLBACK RomBrowserConfigProc (DWORD hDlg, DWORD uMsg, DWORD wParam, DWORD lParam) { - switch (uMsg) { - case WM_INITDIALOG: - { - //record class for future usage - LPPROPSHEETPAGE ps = (LPPROPSHEETPAGE)lParam; - SetProp((HWND)hDlg,"Classes",(SETTING_CLASSES *)ps->lParam); - SETTING_CLASSES * Classes = (SETTING_CLASSES *)ps->lParam; - - if (_Settings->LoadDword(RomBrowser)) { SendMessage(GetDlgItem((HWND)hDlg,IDC_USE_ROMBROWSER),BM_SETCHECK, BST_CHECKED,0); } - if (_Settings->LoadDword(RomBrowserRecursive)) { SendMessage(GetDlgItem((HWND)hDlg,IDC_RECURSION),BM_SETCHECK, BST_CHECKED,0); } - - ROMBROWSER_FIELDS_LIST * Fields = &Classes->Gui->m_Fields; - - for (int count = 0; count < Fields->size(); count ++) { - int Pos = (*Fields)[count].Pos; - if (Pos < 0) { - int index = SendDlgItemMessage((HWND)hDlg,IDC_AVALIABLE,LB_ADDSTRING,0,(LPARAM)GS((*Fields)[count].LangID)); - SendDlgItemMessage((HWND)hDlg,IDC_AVALIABLE,LB_SETITEMDATA,index,count); - continue; - } - int listCount = SendDlgItemMessage((HWND)hDlg,IDC_USING,LB_GETCOUNT,0,0); - if (Pos > listCount) { Pos = listCount; } - int index = SendDlgItemMessage((HWND)hDlg,IDC_USING,LB_INSERTSTRING,Pos,(LPARAM)GS((*Fields)[count].LangID)); - SendDlgItemMessage((HWND)hDlg,IDC_USING,LB_SETITEMDATA,index,count); - } - - //char String[256]; - //sprintf(String,"%d",_Settings->LoadDword(RememberedRomFilesCount)); - //SetDlgItemText((HWND)hDlg,IDC_REMEMBER,String); - //sprintf(String,"%d",_Settings->LoadDword(RememberedRomDir)); - //SetDlgItemText((HWND)hDlg,IDC_REMEMBERDIR,String); - Notify().BreakPoint(__FILE__,__LINE__); - - SetDlgItemText((HWND)hDlg,IDC_ROMSEL_TEXT1,GS(RB_MAX_ROMS)); - SetDlgItemText((HWND)hDlg,IDC_ROMSEL_TEXT2,GS(RB_ROMS)); - SetDlgItemText((HWND)hDlg,IDC_ROMSEL_TEXT3,GS(RB_MAX_DIRS)); - SetDlgItemText((HWND)hDlg,IDC_ROMSEL_TEXT4,GS(RB_DIRS)); - SetDlgItemText((HWND)hDlg,IDC_USE_ROMBROWSER,GS(RB_USE)); -// SetDlgItemText((HWND)hDlg,IDC_REFRESH_BROSWER,GS(RB_REFRESH)); - SetDlgItemText((HWND)hDlg,IDC_RECURSION,GS(RB_DIR_RECURSION)); - SetDlgItemText((HWND)hDlg,IDC_ROMSEL_TEXT5,GS(RB_AVALIABLE_FIELDS)); - SetDlgItemText((HWND)hDlg,IDC_ROMSEL_TEXT6,GS(RB_SHOW_FIELDS)); - SetDlgItemText((HWND)hDlg,IDC_ADD,GS(RB_ADD)); - SetDlgItemText((HWND)hDlg,IDC_REMOVE,GS(RB_REMOVE)); - SetDlgItemText((HWND)hDlg,IDC_UP,GS(RB_UP)); - SetDlgItemText((HWND)hDlg,IDC_DOWN,GS(RB_DOWN)); - } - break; - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_ADD: - { - char String[100]; - int index, listCount, Data; - - index = SendMessage(GetDlgItem((HWND)hDlg,IDC_AVALIABLE),LB_GETCURSEL,0,0); - if (index < 0) { break; } - SendMessage(GetDlgItem((HWND)hDlg,IDC_AVALIABLE),LB_GETTEXT,index,(LPARAM)String); - Data = SendMessage(GetDlgItem((HWND)hDlg,IDC_AVALIABLE),LB_GETITEMDATA,index,0); - SendDlgItemMessage((HWND)hDlg,IDC_AVALIABLE,LB_DELETESTRING,index,0); - listCount = SendDlgItemMessage((HWND)hDlg,IDC_AVALIABLE,LB_GETCOUNT,0,0); - if (index >= listCount) { index -= 1;} - SendDlgItemMessage((HWND)hDlg,IDC_AVALIABLE,LB_SETCURSEL,index,0); - index = SendDlgItemMessage((HWND)hDlg,IDC_USING,LB_ADDSTRING,0,(LPARAM)String); - SendDlgItemMessage((HWND)hDlg,IDC_USING,LB_SETITEMDATA,index,Data); - } - break; - case IDC_REMOVE: - { - char String[100]; - int index, listCount, Data; - - index = SendMessage(GetDlgItem((HWND)hDlg,IDC_USING),LB_GETCURSEL,0,0); - if (index < 0) { break; } - SendMessage(GetDlgItem((HWND)hDlg,IDC_USING),LB_GETTEXT,index,(LPARAM)String); - Data = SendMessage(GetDlgItem((HWND)hDlg,IDC_USING),LB_GETITEMDATA,index,0); - SendDlgItemMessage((HWND)hDlg,IDC_USING,LB_DELETESTRING,index,0); - listCount = SendDlgItemMessage((HWND)hDlg,IDC_USING,LB_GETCOUNT,0,0); - if (index >= listCount) { index -= 1;} - SendDlgItemMessage((HWND)hDlg,IDC_USING,LB_SETCURSEL,index,0); - index = SendDlgItemMessage((HWND)hDlg,IDC_AVALIABLE,LB_ADDSTRING,0,(LPARAM)String); - SendDlgItemMessage((HWND)hDlg,IDC_AVALIABLE,LB_SETITEMDATA,index,Data); - } - break; - case IDC_UP: - { - char String[100]; - int index, Data; - - index = SendMessage(GetDlgItem((HWND)hDlg,IDC_USING),LB_GETCURSEL,0,0); - if (index <= 0) { break; } - SendMessage(GetDlgItem((HWND)hDlg,IDC_USING),LB_GETTEXT,index,(LPARAM)String); - Data = SendMessage(GetDlgItem((HWND)hDlg,IDC_USING),LB_GETITEMDATA,index,0); - SendDlgItemMessage((HWND)hDlg,IDC_USING,LB_DELETESTRING,index,0); - index = SendDlgItemMessage((HWND)hDlg,IDC_USING,LB_INSERTSTRING,index - 1,(LPARAM)String); - SendDlgItemMessage((HWND)hDlg,IDC_USING,LB_SETCURSEL,index,0); - SendDlgItemMessage((HWND)hDlg,IDC_USING,LB_SETITEMDATA,index,Data); - } - break; - case IDC_DOWN: - { - char String[100]; - int index,listCount,Data; - - index = SendMessage(GetDlgItem((HWND)hDlg,IDC_USING),LB_GETCURSEL,0,0); - if (index < 0) { break; } - listCount = SendDlgItemMessage((HWND)hDlg,IDC_USING,LB_GETCOUNT,0,0); - if ((index + 1) == listCount) { break; } - SendMessage(GetDlgItem((HWND)hDlg,IDC_USING),LB_GETTEXT,index,(LPARAM)String); - Data = SendMessage(GetDlgItem((HWND)hDlg,IDC_USING),LB_GETITEMDATA,index,0); - SendDlgItemMessage((HWND)hDlg,IDC_USING,LB_DELETESTRING,index,0); - index = SendDlgItemMessage((HWND)hDlg,IDC_USING,LB_INSERTSTRING,index + 1,(LPARAM)String); - SendDlgItemMessage((HWND)hDlg,IDC_USING,LB_SETCURSEL,index,0); - SendDlgItemMessage((HWND)hDlg,IDC_USING,LB_SETITEMDATA,index,Data); - } - break; - case IDC_REMEMBER: - case IDC_REMEMBERDIR: - if (HIWORD(wParam) != EN_CHANGE) { break; } - case IDC_USE_ROMBROWSER: -// case IDC_REFRESH_BROSWER: - case IDC_RECURSION: - SendMessage(GetParent((HWND)hDlg),PSM_CHANGED ,(WPARAM)hDlg,0); - break; - } - { - SETTING_CLASSES * Classes = (SETTING_CLASSES *)GetProp((HWND)hDlg,"Classes"); - if (RomBrowserConfig_FieldsChanged((HWND)hDlg,&Classes->Gui->m_Fields)) { - SendMessage(GetParent((HWND)hDlg),PSM_CHANGED ,(WPARAM)hDlg,0); - } - } - break; - case WM_NOTIFY: - //Save each selected plugin - if (((NMHDR FAR *) lParam)->code == PSN_APPLY) { - SETTING_CLASSES * Classes = (SETTING_CLASSES *)GetProp((HWND)hDlg,"Classes"); - - bool ResetMenu = false; - - Notify().BreakPoint(__FILE__,__LINE__); - - /*int OldRememberedRomFiles = _Settings->LoadDword(RememberedRomFilesCount); - int RomsToRemember = GetDlgItemInt((HWND)hDlg,IDC_REMEMBER,NULL,FALSE); - if (OldRememberedRomFiles != RomsToRemember) { - if (RomsToRemember < 0) { RomsToRemember = 0; } - if (RomsToRemember > MaxRememberedFiles) { RomsToRemember = MaxRememberedFiles; } - _Settings->SaveDword(RememberedRomFilesCount,RomsToRemember); - ResetMenu = true; - - //Reset the amount to the max on the gui - char String[100]; sprintf(String,"%d",RomsToRemember); - SetDlgItemText((HWND)hDlg,IDC_REMEMBER,String); - } - - int OldRememberedRomDirs = _Settings->LoadDword(RememberedRomDir); - int DirsToRemember = GetDlgItemInt((HWND)hDlg,IDC_REMEMBERDIR,NULL,FALSE); - if (OldRememberedRomDirs != DirsToRemember) { - if (DirsToRemember < 0) { DirsToRemember = 0; } - if (DirsToRemember > MaxRememberedDirs) { DirsToRemember = MaxRememberedDirs; } - _Settings->SaveDword(RememberedRomDir,DirsToRemember); - ResetMenu = true; - - //Reset the amount to the max on the gui - char String[100]; sprintf(String,"%d",DirsToRemember); - SetDlgItemText((HWND)hDlg,IDC_REMEMBERDIR,String); - }*/ - //Get the field information - ROMBROWSER_FIELDS_LIST * Fields = &Classes->Gui->m_Fields; - - bool ResetColoums = false; - bool RefreshData = false; - - //Handle changes in fields - if (RomBrowserConfig_FieldsChanged((HWND)hDlg,Fields)) { - //So we save the correct coloumn widths - Classes->Gui->SaveRomListColoumnInfo(); - - //Modify the Field List to have the new fields used - for (int count = 0; count < Fields->size(); count ++) { (*Fields)[count].Pos = -1; } - int listCount = SendDlgItemMessage((HWND)hDlg,IDC_USING,LB_GETCOUNT,0,0); - for (int Item = 0; Item < listCount; Item ++ ){ - int Pos = SendMessage(GetDlgItem((HWND)hDlg,IDC_USING),LB_GETITEMDATA,Item,0); - (*Fields)[Pos].Pos = Item; - } - - //Reset the Rom Browser to see any changes - ResetColoums = true; - RefreshData = true; - } - - //Handle recursion - bool Recursion = SendMessage(GetDlgItem((HWND)hDlg,IDC_RECURSION),BM_GETSTATE, 0,0) == BST_CHECKED?true:false; - if (Recursion != (_Settings->LoadDword(RomBrowserRecursive) != 0)) { - _Settings->SaveDword(RomBrowserRecursive,(DWORD)Recursion); - RefreshData = true; - } - - bool HaveRomBrowser = SendMessage(GetDlgItem((HWND)hDlg,IDC_USE_ROMBROWSER),BM_GETSTATE, 0,0) == BST_CHECKED?true:false; - if (HaveRomBrowser != (_Settings->LoadDword(RomBrowser) != 0)) { - _Settings->SaveDword(RomBrowser,(DWORD)HaveRomBrowser); - ResetMenu = true; - if (HaveRomBrowser) { - Classes->Gui->ShowRomList(); - ResetColoums = true; - RefreshData = true; - } else { - Classes->Gui->HideRomList(); - ResetColoums = false; - RefreshData = false; - } - } - if (ResetMenu) { Classes->Gui->GetNotifyClass()->RefreshMenu(); } - if (ResetColoums) { - Classes->Gui->ResetRomBrowserColomuns(); - Classes->Gui->SaveRomListColoumnInfo(); - } - if (RefreshData) { - Classes->Gui->RefreshRomBrowser(); - Classes->Gui->HighLightLastRom(); - } - - } - - //Free allocated memory - if (((NMHDR FAR *) lParam)->code == PSN_RESET || - (((NMHDR FAR *) lParam)->code == PSN_APPLY && ((LPPSHNOTIFY)lParam)->lParam)) - { - RemoveProp((HWND)hDlg,"Classes"); - } - break; - default: - return false; - } - return true; -} - -BOOL CALLBACK GeneralOptionsProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch (uMsg) { - case WM_INITDIALOG: - { - //record class for future usage - LPPROPSHEETPAGE ps = (LPPROPSHEETPAGE)lParam; - SetProp((HWND)hDlg,"Classes",(SETTING_CLASSES *)ps->lParam); - SETTING_CLASSES * Classes = (SETTING_CLASSES *)ps->lParam; - - if (_Settings->LoadDword(AutoSleep)) { SendMessage(GetDlgItem((HWND)hDlg,IDC_AUTOSLEEP),BM_SETCHECK, BST_CHECKED,0); } - if (_Settings->LoadDword(AutoFullScreen)) { SendMessage(GetDlgItem((HWND)hDlg,IDC_LOAD_FULLSCREEN),BM_SETCHECK, BST_CHECKED,0); } - if (_Settings->LoadDword(RememberCheats)) { SendMessage(GetDlgItem((HWND)hDlg,IDC_REMEMBER_CHEAT),BM_SETCHECK, BST_CHECKED,0); } - if (_Settings->LoadDword(DisableScrSaver)) { SendMessage(GetDlgItem((HWND)hDlg,IDC_SCREEN_SAVER),BM_SETCHECK, BST_CHECKED,0); } - if (_Settings->LoadDword(BasicMode)) { SendMessage(GetDlgItem((HWND)hDlg,IDC_BASIC_MODE),BM_SETCHECK, BST_CHECKED,0); } - if (_Settings->LoadDword(DisplayFrameRate)){ SendMessage(GetDlgItem((HWND)hDlg,IDC_DISPLAY_FRAMERATE),BM_SETCHECK, BST_CHECKED,0); } - - SetDlgItemText((HWND)hDlg,IDC_AUTOSLEEP, GS(OPTION_AUTO_SLEEP)); - SetDlgItemText((HWND)hDlg,IDC_LOAD_FULLSCREEN, GS(OPTION_AUTO_FULLSCREEN)); - SetDlgItemText((HWND)hDlg,IDC_BASIC_MODE, GS(OPTION_BASIC_MODE)); - SetDlgItemText((HWND)hDlg,IDC_REMEMBER_CHEAT, GS(OPTION_REMEMBER_CHEAT)); - SetDlgItemText((HWND)hDlg,IDC_SCREEN_SAVER, GS(OPTION_DISABLE_SS)); - SetDlgItemText((HWND)hDlg,IDC_DISPLAY_FRAMERATE, GS(OPTION_DISPLAY_FR)); - - DWORD FRDisplayType = _Settings->LoadDword(FrameDisplayType); - AddDropDownItem(hDlg,IDC_FRAME_DISPLAY_TYPE,GS(STR_FR_VIS),FR_VIs,&FRDisplayType); - AddDropDownItem(hDlg,IDC_FRAME_DISPLAY_TYPE,GS(STR_FR_DLS),FR_DLs,&FRDisplayType); - AddDropDownItem(hDlg,IDC_FRAME_DISPLAY_TYPE,GS(STR_FR_PERCENT),FR_PERCENT,&FRDisplayType); - - ShowWindow(GetDlgItem((HWND)hDlg,IDC_FRAME_DISPLAY_TYPE),SendMessage(GetDlgItem(hDlg,IDC_DISPLAY_FRAMERATE),BM_GETSTATE, 0,0) == BST_CHECKED ? SW_SHOW : SW_HIDE); - } - break; - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_FRAME_DISPLAY_TYPE: - if (HIWORD(wParam) == LBN_SELCHANGE) { - SendMessage(GetParent((HWND)hDlg),PSM_CHANGED ,(WPARAM)hDlg,0); - } - break; - case IDC_AUTOSLEEP: - case IDC_LOAD_FULLSCREEN: - case IDC_BASIC_MODE: - case IDC_REMEMBER_CHEAT: - case IDC_SCREEN_SAVER: - SendMessage(GetParent((HWND)hDlg),PSM_CHANGED ,(WPARAM)hDlg,0); - break; - case IDC_DISPLAY_FRAMERATE: - SendMessage(GetParent((HWND)hDlg),PSM_CHANGED ,(WPARAM)hDlg,0); - ShowWindow(GetDlgItem((HWND)hDlg,IDC_FRAME_DISPLAY_TYPE),(SendMessage(GetDlgItem(hDlg,IDC_DISPLAY_FRAMERATE),BM_GETSTATE, 0,0) & BST_CHECKED) == BST_CHECKED ? SW_SHOW : SW_HIDE); - break; - } - break; - case WM_NOTIFY: - //Save each selected plugin - if (((NMHDR FAR *) lParam)->code == PSN_APPLY) { - SETTING_CLASSES * Classes = (SETTING_CLASSES *)GetProp((HWND)hDlg,"Classes"); - - bool WasBasicMode = _Settings->LoadDword(BasicMode) != 0; - - //Save if using selected - _Settings->SaveDword(AutoSleep, SendMessage(GetDlgItem(hDlg,IDC_AUTOSLEEP), BM_GETSTATE, 0,0) == BST_CHECKED); - _Settings->SaveDword(AutoFullScreen, SendMessage(GetDlgItem(hDlg,IDC_LOAD_FULLSCREEN), BM_GETSTATE, 0,0) == BST_CHECKED); - _Settings->SaveDword(BasicMode, SendMessage(GetDlgItem(hDlg,IDC_BASIC_MODE), BM_GETSTATE, 0,0) == BST_CHECKED); - _Settings->SaveDword(RememberCheats, SendMessage(GetDlgItem(hDlg,IDC_REMEMBER_CHEAT), BM_GETSTATE, 0,0) == BST_CHECKED); - _Settings->SaveDword(DisableScrSaver, SendMessage(GetDlgItem(hDlg,IDC_SCREEN_SAVER), BM_GETSTATE, 0,0) == BST_CHECKED); - _Settings->SaveDword(DisplayFrameRate,SendMessage(GetDlgItem(hDlg,IDC_DISPLAY_FRAMERATE),BM_GETSTATE, 0,0) == BST_CHECKED); - - int indx = SendDlgItemMessage(hDlg,IDC_FRAME_DISPLAY_TYPE,CB_GETCURSEL,0,0); - _Settings->SaveDword(FrameDisplayType,SendDlgItemMessage(hDlg,IDC_FRAME_DISPLAY_TYPE,CB_GETITEMDATA,indx >= 0 ? indx : 0,0)); - - if (WasBasicMode != (_Settings->LoadDword(BasicMode) != 0)) { - if (WasBasicMode && !((LPPSHNOTIFY)lParam)->lParam) { - - //add Advanced tabs - for (int count = 0; count < (sizeof(AdvancedSettingsTabs) / sizeof(SETTINGS_TAB)); count ++) { - PROPSHEETPAGE page; - - AdvancedSettingsTabs[count].Title = _Lang->GetString(AdvancedSettingsTabs[count].LanguageID); - - page.dwSize = sizeof(PROPSHEETPAGE); - page.dwFlags = PSP_USETITLE; - page.hInstance = GetModuleHandle(NULL); - page.pszTemplate = MAKEINTRESOURCE(AdvancedSettingsTabs[count].TemplateID); - page.pfnDlgProc = AdvancedSettingsTabs[count].pfnDlgProc; - page.pszTitle = AdvancedSettingsTabs[count].Title.c_str(); - page.lParam = (DWORD)Classes; - page.pfnCallback = NULL; - - PropSheet_AddPage(GetParent(hDlg),CreatePropertySheetPage(&page)); - } - } - if (!WasBasicMode && !((LPPSHNOTIFY)lParam)->lParam) { - int MinPages = (sizeof(BasicSettingsTabs) / sizeof(SETTINGS_TAB)); - if (_Settings->LoadString(ROM_NAME).length() > 0) { - MinPages += (sizeof(RomSettingsTabs) / sizeof(SETTINGS_TAB)); - } - for (int count = MaxConfigPages; count >= MinPages; count --) { - PropSheet_RemovePage(GetParent(hDlg),count,0); - } - } - Classes->Gui->RefreshMenu(); - } - } - - //Free allocated memory - if (((NMHDR FAR *) lParam)->code == PSN_RESET || - (((NMHDR FAR *) lParam)->code == PSN_APPLY && ((LPPSHNOTIFY)lParam)->lParam)) - { - RemoveProp((HWND)hDlg,"Classes"); - } - break; - default: - return false; - } - return true; -} - -BOOL CALLBACK RomSettingsProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch (uMsg) { - case WM_INITDIALOG: - { - //record class for future usage - LPPROPSHEETPAGE ps = (LPPROPSHEETPAGE)lParam; - SetProp((HWND)hDlg,"Classes",(SETTING_CLASSES *)ps->lParam); - SETTING_CLASSES * Classes = (SETTING_CLASSES *)ps->lParam; - - SetDlgItemText(hDlg,IDC_CPU_TYPE_TEXT,GS(ROM_CPU_STYLE)); - SetDlgItemText(hDlg,IDC_FUNCFIND_TEXT,GS(ROM_FUNC_FIND)); - SetDlgItemText(hDlg,IDC_MEMORY_SIZE_TEXT,GS(ROM_MEM_SIZE)); - SetDlgItemText(hDlg,IDC_BLOCK_LINKING_TEXT,GS(ROM_ABL)); - SetDlgItemText(hDlg,IDC_SAVE_TYPE_TEXT,GS(ROM_SAVE_TYPE)); -// SetDlgItemText(hDlg,IDC_COUNTFACT_TEXT,GS(ROM_COUNTER_FACTOR)); - - SetDlgItemText(hDlg,IDC_GOOD_NAME,_Settings->LoadString(ROM_GoodName).c_str()); - - DWORD CPU_Type = _Settings->LoadDword(ROM_CPUType); - AddDropDownItem(hDlg,IDC_CPU_TYPE,GS(ROM_DEFAULT), CPU_Default, &CPU_Type); - AddDropDownItem(hDlg,IDC_CPU_TYPE,GS(CORE_INTERPTER), CPU_Interpreter,&CPU_Type); - AddDropDownItem(hDlg,IDC_CPU_TYPE,GS(CORE_RECOMPILER),CPU_Recompiler, &CPU_Type); - if (_Settings->LoadDword(Debugger)) { - AddDropDownItem(hDlg,IDC_CPU_TYPE,GS(CORE_SYNC), CPU_SyncCores, &CPU_Type); - } - - DWORD FunctionLookup = _Settings->LoadDword(ROM_FunctionLookup); - AddDropDownItem(hDlg,IDC_FUNCFIND,GS(ROM_DEFAULT),FuncFind_Default,&FunctionLookup); - AddDropDownItem(hDlg,IDC_FUNCFIND,GS(FLM_PLOOKUP),FuncFind_PhysicalLookup,&FunctionLookup); - AddDropDownItem(hDlg,IDC_FUNCFIND,GS(FLM_VLOOKUP),FuncFind_VirtualLookup,&FunctionLookup); - //AddDropDownItem(hDlg,IDC_FUNCFIND,GS(FLM_CHANGEMEM),FuncFind_ChangeMemory,&FunctionLookup); - - DWORD RomRamSize = _Settings->LoadDword(ROM_RamSize); - AddDropDownItem(hDlg,IDC_RDRAM_SIZE,GS(ROM_DEFAULT),-1,&RomRamSize); - AddDropDownItem(hDlg,IDC_RDRAM_SIZE,GS(RDRAM_4MB),4,&RomRamSize); - AddDropDownItem(hDlg,IDC_RDRAM_SIZE,GS(RDRAM_8MB),8,&RomRamSize); - - DWORD RomUseLinking = _Settings->LoadDword(ROM_BlockLinking); - AddDropDownItem(hDlg,IDC_BLOCK_LINKING,GS(ROM_DEFAULT),-1,&RomUseLinking); - AddDropDownItem(hDlg,IDC_BLOCK_LINKING,GS(ABL_ON),1,&RomUseLinking); - AddDropDownItem(hDlg,IDC_BLOCK_LINKING,GS(ABL_OFF),0,&RomUseLinking); - - DWORD RomSaveUsing = _Settings->LoadDword(ROM_SaveChip); - AddDropDownItem(hDlg,IDC_SAVE_TYPE,GS(SAVE_FIRST_USED),SaveChip_Auto, &RomSaveUsing); - AddDropDownItem(hDlg,IDC_SAVE_TYPE,GS(SAVE_4K_EEPROM), SaveChip_Eeprom_4K, &RomSaveUsing); - AddDropDownItem(hDlg,IDC_SAVE_TYPE,GS(SAVE_16K_EEPROM),SaveChip_Eeprom_16K,&RomSaveUsing); - AddDropDownItem(hDlg,IDC_SAVE_TYPE,GS(SAVE_SRAM), SaveChip_Sram, &RomSaveUsing); - AddDropDownItem(hDlg,IDC_SAVE_TYPE,GS(SAVE_FLASHRAM), SaveChip_FlashRam, &RomSaveUsing); - - DWORD RomCF = _Settings->LoadDword(ROM_CounterFactor); - AddDropDownItem(hDlg,IDC_COUNTFACT,GS(ROM_DEFAULT),-1,&RomCF); - AddDropDownItem(hDlg,IDC_COUNTFACT,GS(NUMBER_1),1,&RomCF); - AddDropDownItem(hDlg,IDC_COUNTFACT,GS(NUMBER_2),2,&RomCF); - AddDropDownItem(hDlg,IDC_COUNTFACT,GS(NUMBER_3),3,&RomCF); - AddDropDownItem(hDlg,IDC_COUNTFACT,GS(NUMBER_4),4,&RomCF); - AddDropDownItem(hDlg,IDC_COUNTFACT,GS(NUMBER_5),5,&RomCF); - AddDropDownItem(hDlg,IDC_COUNTFACT,GS(NUMBER_6),6,&RomCF); - - SetFlagControl(hDlg,_Settings->LoadDword(ROM_SyncAudio) != 0, IDC_SYNC_AUDIO, GS(ROM_SYNC_AUDIO)); - SetFlagControl(hDlg,_Settings->LoadDword(ROM_UseTlb) != 0, IDC_USE_TLB, GS(ROM_USE_TLB)); - SetFlagControl(hDlg,_Settings->LoadDword(ROM_RegCache) != 0, IDC_ROM_REGCACHE, GS(ROM_REG_CACHE)); - SetFlagControl(hDlg,_Settings->LoadDword(ROM_DelaySI) != 0, IDC_DELAY_SI, GS(ROM_DELAY_SI)); - SetFlagControl(hDlg,_Settings->LoadDword(ROM_AudioSignal) != 0, IDC_AUDIO_SIGNAL, GS(ROM_AUDIO_SIGNAL)); - SetFlagControl(hDlg,_Settings->LoadDword(ROM_SPHack) != 0, IDC_ROM_SPHACK, GS(ROM_SP_HACK)); - SetFlagControl(hDlg,_Settings->LoadDword(ROM_FixedAudio) != 0, IDC_ROM_FIXEDAUDIO, GS(ROM_FIXED_AUDIO)); - SetFlagControl(hDlg,_Settings->LoadDword(ROM_CustomSMM) != 0, IDC_CUSTOM_SMM, GS(ROM_CUSTOM_SMM)); - SetFlagControl(hDlg,_Settings->LoadDword(ROM_SMM_Cache) != 0, IDC_SMM_CACHE, GS(ADVANCE_SMM_CACHE)); - SetFlagControl(hDlg,_Settings->LoadDword(ROM_SMM_PIDMA) != 0, IDC_SMM_DMA, GS(ADVANCE_SMM_PIDMA)); - SetFlagControl(hDlg,_Settings->LoadDword(ROM_SMM_TLB) != 0, IDC_SMM_TLB, GS(ADVANCE_SMM_TLB)); - SetFlagControl(hDlg,_Settings->LoadDword(ROM_SMM_Protect) != 0, IDC_SMM_PROTECT, GS(ADVANCE_SMM_PROTECT)); - SetFlagControl(hDlg,_Settings->LoadDword(ROM_SMM_ValidFunc)!= 0, IDC_SMM_VALIDATE, GS(ADVANCE_SMM_VALIDATE)); - - bool UseCustomSMM = _Settings->LoadDword(ROM_CustomSMM) != 0; - EnableWindow(GetDlgItem(hDlg,IDC_SMM_FRAME),UseCustomSMM ? TRUE : FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_SMM_CACHE),UseCustomSMM ? TRUE : FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_SMM_DMA),UseCustomSMM ? TRUE : FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_SMM_TLB),UseCustomSMM ? TRUE : FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_SMM_PROTECT),UseCustomSMM ? TRUE : FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_SMM_VALIDATE),UseCustomSMM ? TRUE : FALSE); - } - break; - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_CPU_TYPE: - case IDC_RDRAM_SIZE: - case IDC_SAVE_TYPE: - case IDC_COUNTFACT: - if (HIWORD(wParam) == LBN_SELCHANGE) { - SendMessage(GetParent((HWND)hDlg),PSM_CHANGED ,(WPARAM)hDlg,0); - } - break; - case IDC_CUSTOM_SMM: - { - int MSGState = SendMessage(GetDlgItem(hDlg,IDC_CUSTOM_SMM),BM_GETSTATE, 0,0); - bool UseCustomSMM = (SendMessage(GetDlgItem(hDlg,IDC_CUSTOM_SMM),BM_GETSTATE, 0,0) & BST_CHECKED) == BST_CHECKED; - EnableWindow(GetDlgItem(hDlg,IDC_SMM_FRAME),UseCustomSMM ? TRUE : FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_SMM_CACHE),UseCustomSMM ? TRUE : FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_SMM_DMA),UseCustomSMM ? TRUE : FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_SMM_TLB),UseCustomSMM ? TRUE : FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_SMM_PROTECT),UseCustomSMM ? TRUE : FALSE); - EnableWindow(GetDlgItem(hDlg,IDC_SMM_VALIDATE),UseCustomSMM ? TRUE : FALSE); - SendMessage(GetParent((HWND)hDlg),PSM_CHANGED ,(WPARAM)hDlg,0); - } - break; - case IDC_CACHE: - //case IDC_LINKED: - //case IDC_PI_DMA: - case IDC_TLB: - //case IDC_PROTECT: - //case IDC_VALIDATE: - //case IDC_VALIDATE_FUNCTION: - case IDC_USE_TLB: - case IDC_BLOCK_LINKING: -// case IDC_DELAY_DLIST: - case IDC_DELAY_SI: - SendMessage(GetParent((HWND)hDlg),PSM_CHANGED ,(WPARAM)hDlg,0); - break; - } - break; - case WM_NOTIFY: - if (((NMHDR FAR *) lParam)->code == PSN_APPLY) { - SETTING_CLASSES * Classes = (SETTING_CLASSES *)GetProp((HWND)hDlg,"Classes"); - - int indx = SendDlgItemMessage(hDlg,IDC_CPU_TYPE,CB_GETCURSEL,0,0); - _Settings->SaveDword(ROM_CPUType,SendDlgItemMessage(hDlg,IDC_CPU_TYPE,CB_GETITEMDATA,indx >= 0 ? indx : 0,0)); - - indx = SendDlgItemMessage(hDlg,IDC_RDRAM_SIZE,CB_GETCURSEL,0,0); - _Settings->SaveDword(ROM_RamSize,SendDlgItemMessage(hDlg,IDC_RDRAM_SIZE,CB_GETITEMDATA,indx >= 0 ? indx : 0,0)); - - indx = SendDlgItemMessage(hDlg,IDC_SAVE_TYPE,CB_GETCURSEL,0,0); - _Settings->SaveDword(ROM_SaveChip,SendDlgItemMessage(hDlg,IDC_SAVE_TYPE,CB_GETITEMDATA,indx >= 0 ? indx : 0,0)); - - indx = SendDlgItemMessage(hDlg,IDC_FUNCFIND,CB_GETCURSEL,0,0); - _Settings->SaveDword(ROM_FunctionLookup,SendDlgItemMessage(hDlg,IDC_FUNCFIND,CB_GETITEMDATA,indx >= 0 ? indx : 0,0)); - - indx = SendDlgItemMessage(hDlg,IDC_COUNTFACT,CB_GETCURSEL,0,0); - _Settings->SaveDword(ROM_CounterFactor,SendDlgItemMessage(hDlg,IDC_COUNTFACT,CB_GETITEMDATA,indx >= 0 ? indx : 0,0)); - - indx = SendDlgItemMessage(hDlg,IDC_BLOCK_LINKING,CB_GETCURSEL,0,0); - _Settings->SaveDword(ROM_BlockLinking,SendDlgItemMessage(hDlg,IDC_BLOCK_LINKING,CB_GETITEMDATA,indx >= 0 ? indx : 0,0)); - - _Settings->SaveDword(ROM_SyncAudio, (SendMessage(GetDlgItem(hDlg,IDC_SYNC_AUDIO), BM_GETSTATE, 0,0) == BST_CHECKED)); - _Settings->SaveDword(ROM_UseTlb, (SendMessage(GetDlgItem(hDlg,IDC_USE_TLB), BM_GETSTATE, 0,0) == BST_CHECKED)); - _Settings->SaveDword(ROM_RegCache, (SendMessage(GetDlgItem(hDlg,IDC_ROM_REGCACHE), BM_GETSTATE, 0,0) == BST_CHECKED)); - _Settings->SaveDword(ROM_DelaySI, (SendMessage(GetDlgItem(hDlg,IDC_DELAY_SI), BM_GETSTATE, 0,0) == BST_CHECKED)); - _Settings->SaveDword(ROM_AudioSignal, (SendMessage(GetDlgItem(hDlg,IDC_AUDIO_SIGNAL), BM_GETSTATE, 0,0) == BST_CHECKED)); - _Settings->SaveDword(ROM_SPHack, (SendMessage(GetDlgItem(hDlg,IDC_ROM_SPHACK), BM_GETSTATE, 0,0) == BST_CHECKED)); - _Settings->SaveDword(ROM_FixedAudio, (SendMessage(GetDlgItem(hDlg,IDC_ROM_FIXEDAUDIO), BM_GETSTATE, 0,0) == BST_CHECKED)); - _Settings->SaveDword(ROM_CustomSMM, (SendMessage(GetDlgItem(hDlg,IDC_CUSTOM_SMM), BM_GETSTATE, 0,0) == BST_CHECKED)); - _Settings->SaveDword(ROM_SMM_Cache, (SendMessage(GetDlgItem(hDlg,IDC_SMM_CACHE), BM_GETSTATE, 0,0) == BST_CHECKED)); - _Settings->SaveDword(ROM_SMM_PIDMA, (SendMessage(GetDlgItem(hDlg,IDC_SMM_DMA), BM_GETSTATE, 0,0) == BST_CHECKED)); - _Settings->SaveDword(ROM_SMM_TLB, (SendMessage(GetDlgItem(hDlg,IDC_SMM_TLB), BM_GETSTATE, 0,0) == BST_CHECKED)); - _Settings->SaveDword(ROM_SMM_Protect, (SendMessage(GetDlgItem(hDlg,IDC_SMM_PROTECT), BM_GETSTATE, 0,0) == BST_CHECKED)); - _Settings->SaveDword(ROM_SMM_ValidFunc,(SendMessage(GetDlgItem(hDlg,IDC_SMM_VALIDATE), BM_GETSTATE, 0,0) == BST_CHECKED)); - } - - //Free allocated memory - if (((NMHDR FAR *) lParam)->code == PSN_RESET || - (((NMHDR FAR *) lParam)->code == PSN_APPLY && ((LPPSHNOTIFY)lParam)->lParam)) - { - RemoveProp((HWND)hDlg,"Classes"); - } - break; - default: - return false; - } - return true; -} - -BOOL CALLBACK RomStatusProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch (uMsg) { - case WM_INITDIALOG: - { - //record class for future usage - LPPROPSHEETPAGE ps = (LPPROPSHEETPAGE)lParam; - SetProp((HWND)hDlg,"Classes",(SETTING_CLASSES *)ps->lParam); - SETTING_CLASSES * Classes = (SETTING_CLASSES *)ps->lParam; - - SetDlgItemText(hDlg,IDC_STATUS_TEXT,GS(RB_STATUS)); - SetDlgItemText(hDlg,IDC_NOTES_CORE_TEXT,GS(RB_NOTES_CORE)); - SetDlgItemText(hDlg,IDC_NOTES_PLUGIN_TEXT,GS(RB_NOTES_PLUGIN)); - - CIniFile RomIniFile (_Settings->LoadString(RomDatabaseFile).c_str()); - strlist Keys; - RomIniFile.GetKeyList("Rom Status",Keys); - stdstr Status = _Settings->LoadString(ROM_Status); - 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; } - DWORD CurrentStatus = _stricmp(Status.c_str(),item->c_str()) == 0; - AddDropDownItem(hDlg,IDC_STATUS_TYPE,item->c_str(),true,&CurrentStatus); - } - - SetDlgItemText(hDlg,IDC_NOTES_CORE,_Settings->LoadString(ROM_CoreNotes).c_str()); - SetDlgItemText(hDlg,IDC_NOTES_PLUGIN,_Settings->LoadString(ROM_PluginNotes).c_str()); - } - break; - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_STATUS_TYPE: - if (HIWORD(wParam) == LBN_SELCHANGE) { - SendMessage(GetParent((HWND)hDlg),PSM_CHANGED ,(WPARAM)hDlg,0); - } - break; - case IDC_NOTES_CORE: - if (HIWORD(wParam) == EN_CHANGE) - { - char text[2000]; - - GetDlgItemText(hDlg,IDC_NOTES_CORE,text,sizeof(text)); - if (stricmp(text,_Settings->LoadString(ROM_CoreNotes).c_str()) != 0) - { - SendMessage(GetParent((HWND)hDlg),PSM_CHANGED ,(WPARAM)hDlg,0); - } - } - case IDC_NOTES_PLUGIN: - if (HIWORD(wParam) == EN_CHANGE) - { - char text[2000]; - - GetDlgItemText(hDlg,IDC_NOTES_PLUGIN,text,sizeof(text)); - if (stricmp(text,_Settings->LoadString(ROM_PluginNotes).c_str()) != 0) - { - SendMessage(GetParent((HWND)hDlg),PSM_CHANGED ,(WPARAM)hDlg,0); - } - } - } - break; - case WM_NOTIFY: - if (((NMHDR FAR *) lParam)->code == PSN_APPLY) { - SETTING_CLASSES * Classes = (SETTING_CLASSES *)GetProp((HWND)hDlg,"Classes"); - - bool changed = false; - char text[2000]; - GetDlgItemText(hDlg,IDC_STATUS_TYPE,text,sizeof(text)); - if (stricmp(text,_Settings->LoadString(ROM_Status).c_str()) != 0) { changed = true; } - _Settings->SaveString(ROM_Status,text); - - GetDlgItemText(hDlg,IDC_NOTES_CORE,text,sizeof(text)); - if (stricmp(text,_Settings->LoadString(ROM_CoreNotes).c_str()) != 0) { changed = true; } - if (strlen(text) > 0) { - _Settings->SaveString(ROM_CoreNotes,text); - } else { - _Settings->SaveString(ROM_CoreNotes,""); - } - GetDlgItemText(hDlg,IDC_NOTES_PLUGIN,text,sizeof(text)); - if (stricmp(text,_Settings->LoadString(ROM_PluginNotes).c_str()) != 0) { changed = true; } - if (strlen(text) > 0) { - _Settings->SaveString(ROM_PluginNotes,text); - } else { - _Settings->SaveString(ROM_PluginNotes,""); - } - if (changed) { - Classes->Gui->RefreshRomBrowser(); - Classes->Gui->HighLightLastRom(); - } - } - - //Free allocated memory - if (((NMHDR FAR *) lParam)->code == PSN_RESET || - (((NMHDR FAR *) lParam)->code == PSN_APPLY && ((LPPSHNOTIFY)lParam)->lParam)) - { - RemoveProp((HWND)hDlg,"Classes"); - } - break; - default: - return false; - } - return true; -} - -BOOL TestExtensionRegistered ( char * Extension ) { - char ShortAppName[] = { "PJ64" }; - HKEY hKeyResults = 0; - char Association[100]; - long lResult; - DWORD Type, Bytes; - - lResult = RegOpenKey( HKEY_CLASSES_ROOT,Extension,&hKeyResults); - if (lResult != ERROR_SUCCESS) { return FALSE; } - - Bytes = sizeof(Association); - lResult = RegQueryValueEx(hKeyResults,"",0,&Type,(LPBYTE)(&Association),&Bytes); - RegCloseKey(hKeyResults); - if (lResult != ERROR_SUCCESS) { return FALSE; } - - if (strcmp(Association,ShortAppName) != 0) { return FALSE; } - return TRUE; -} - -void RegisterExtension ( char * Extension, BOOL RegisterWithPj64 ) { - char ShortAppName[] = { "PJ64" }; - char sKeyValue[] = { "Project 64" }; - char app_path[_MAX_PATH]; - - char String[200]; - DWORD Disposition = 0; - HKEY hKeyResults = 0; - long lResult; - - //Find Application name - GetModuleFileName(NULL,app_path,sizeof(app_path)); - - //creates a Root entry for sKeyName - lResult = RegCreateKeyEx( HKEY_CLASSES_ROOT, ShortAppName,0,"", REG_OPTION_NON_VOLATILE, - KEY_ALL_ACCESS,NULL, &hKeyResults,&Disposition); - RegSetValueEx(hKeyResults,"",0,REG_SZ,(BYTE *)sKeyValue,sizeof(sKeyValue)); - RegCloseKey(hKeyResults); - - // Set the command line for "MyApp". - sprintf(String,"%s\\DefaultIcon",ShortAppName); - lResult = RegCreateKeyEx( HKEY_CLASSES_ROOT, String,0,"", REG_OPTION_NON_VOLATILE, - KEY_ALL_ACCESS,NULL, &hKeyResults,&Disposition); - sprintf(String,"%s",app_path); - RegSetValueEx(hKeyResults,"",0,REG_SZ,(BYTE *)String,strlen(String)); - RegCloseKey(hKeyResults); - - //set the icon for the file extension - sprintf(String,"%s\\shell\\open\\command",ShortAppName); - lResult = RegCreateKeyEx( HKEY_CLASSES_ROOT, String,0,"", REG_OPTION_NON_VOLATILE, - KEY_ALL_ACCESS,NULL, &hKeyResults,&Disposition); - sprintf(String,"%s %%1",app_path); - RegSetValueEx(hKeyResults,"",0,REG_SZ,(BYTE *)String,strlen(String)); - RegCloseKey(hKeyResults); - - // creates a Root entry for passed associated with sKeyName - lResult = RegCreateKeyEx( HKEY_CLASSES_ROOT, Extension,0,"", REG_OPTION_NON_VOLATILE, - KEY_ALL_ACCESS,NULL, &hKeyResults,&Disposition); - if (RegisterWithPj64) { - RegSetValueEx(hKeyResults,"",0,REG_SZ,(BYTE *)ShortAppName,sizeof(ShortAppName)); - } else { - RegSetValueEx(hKeyResults,"",0,REG_SZ,(BYTE *)"",1); - } - - SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0); -} - -BOOL CALLBACK ShellIntegrationProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch (uMsg) { - case WM_INITDIALOG: - { - //record class for future usage - LPPROPSHEETPAGE ps = (LPPROPSHEETPAGE)lParam; - - SetDlgItemText(hDlg,IDC_SHELL_INT_TEXT,GS(SHELL_TEXT)); - if (TestExtensionRegistered(".v64")) { SendMessage(GetDlgItem(hDlg,IDC_V64),BM_SETCHECK, BST_CHECKED,0); } - if (TestExtensionRegistered(".z64")) { SendMessage(GetDlgItem(hDlg,IDC_Z64),BM_SETCHECK, BST_CHECKED,0); } - if (TestExtensionRegistered(".n64")) { SendMessage(GetDlgItem(hDlg,IDC_N64),BM_SETCHECK, BST_CHECKED,0); } - if (TestExtensionRegistered(".rom")) { SendMessage(GetDlgItem(hDlg,IDC_ROM),BM_SETCHECK, BST_CHECKED,0); } - if (TestExtensionRegistered(".jap")) { SendMessage(GetDlgItem(hDlg,IDC_JAP),BM_SETCHECK, BST_CHECKED,0); } - if (TestExtensionRegistered(".pal")) { SendMessage(GetDlgItem(hDlg,IDC_PAL),BM_SETCHECK, BST_CHECKED,0); } - if (TestExtensionRegistered(".usa")) { SendMessage(GetDlgItem(hDlg,IDC_USA),BM_SETCHECK, BST_CHECKED,0); } - } - break; - case WM_NOTIFY: - if (((NMHDR FAR *) lParam)->code == PSN_APPLY) { - RegisterExtension(".v64",SendMessage(GetDlgItem(hDlg,IDC_V64),BM_GETSTATE, 0,0) == BST_CHECKED?TRUE:FALSE); - RegisterExtension(".z64",SendMessage(GetDlgItem(hDlg,IDC_Z64),BM_GETSTATE, 0,0) == BST_CHECKED?TRUE:FALSE); - RegisterExtension(".n64",SendMessage(GetDlgItem(hDlg,IDC_N64),BM_GETSTATE, 0,0) == BST_CHECKED?TRUE:FALSE); - RegisterExtension(".rom",SendMessage(GetDlgItem(hDlg,IDC_ROM),BM_GETSTATE, 0,0) == BST_CHECKED?TRUE:FALSE); - RegisterExtension(".jap",SendMessage(GetDlgItem(hDlg,IDC_JAP),BM_GETSTATE, 0,0) == BST_CHECKED?TRUE:FALSE); - RegisterExtension(".pal",SendMessage(GetDlgItem(hDlg,IDC_PAL),BM_GETSTATE, 0,0) == BST_CHECKED?TRUE:FALSE); - RegisterExtension(".usa",SendMessage(GetDlgItem(hDlg,IDC_USA),BM_GETSTATE, 0,0) == BST_CHECKED?TRUE:FALSE); - } - break; - default: - return FALSE; - } - return TRUE; -} - -#endif \ No newline at end of file diff --git a/Source/Project64/Settings/SettingType/SettingsType-Application.cpp b/Source/Project64/Settings/SettingType/SettingsType-Application.cpp index 5791392f1..555abdd3a 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-Application.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-Application.cpp @@ -1,5 +1,4 @@ -#include "..\..\Settings.h" -#include "..\..\User Interface.h" +#include "stdafx.h" #include "SettingsType-Application.h" bool CSettingTypeApplication::m_UseRegistry = false; diff --git a/Source/Project64/Settings/SettingType/SettingsType-ApplicationIndex.cpp b/Source/Project64/Settings/SettingType/SettingsType-ApplicationIndex.cpp index 749151c3e..ecc6a9367 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-ApplicationIndex.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-ApplicationIndex.cpp @@ -1,5 +1,4 @@ -#include "..\..\Settings.h" -#include "..\..\User Interface.h" +#include "stdafx.h" #include "SettingsType-Application.h" #include "SettingsType-ApplicationIndex.h" diff --git a/Source/Project64/Settings/SettingType/SettingsType-Cheats.cpp b/Source/Project64/Settings/SettingType/SettingsType-Cheats.cpp index 9ebf64727..e60fe6ffb 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-Cheats.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-Cheats.cpp @@ -1,5 +1,4 @@ -#include "..\..\Settings.h" -#include "..\..\User Interface.h" +#include "stdafx.h" #include "SettingsType-Cheats.h" CIniFile * CSettingTypeCheats::m_CheatIniFile = NULL; diff --git a/Source/Project64/Settings/SettingType/SettingsType-GameSetting.cpp b/Source/Project64/Settings/SettingType/SettingsType-GameSetting.cpp index a91d461f8..5515faa8c 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-GameSetting.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-GameSetting.cpp @@ -1,5 +1,4 @@ -#include "..\..\Settings.h" -#include "..\..\User Interface.h" +#include "stdafx.h" #include "SettingsType-Application.h" #include "SettingsType-GameSetting.h" diff --git a/Source/Project64/Settings/SettingType/SettingsType-GameSettingIndex.cpp b/Source/Project64/Settings/SettingType/SettingsType-GameSettingIndex.cpp index 40683353c..0c04966fc 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-GameSettingIndex.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-GameSettingIndex.cpp @@ -1,5 +1,4 @@ -#include "..\..\Settings.h" -#include "..\..\User Interface.h" +#include "stdafx.h" #include "SettingsType-Application.h" #include "SettingsType-GameSetting.h" #include "SettingsType-GameSettingIndex.h" diff --git a/Source/Project64/Settings/SettingType/SettingsType-RDBCpuType.cpp b/Source/Project64/Settings/SettingType/SettingsType-RDBCpuType.cpp index 59805a2cc..4b2ac52cf 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RDBCpuType.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-RDBCpuType.cpp @@ -1,5 +1,4 @@ -#include "..\..\Settings.h" -#include "..\..\User Interface.h" +#include "stdafx.h" #include "SettingsType-RomDatabase.h" #include "SettingsType-RDBCpuType.h" diff --git a/Source/Project64/Settings/SettingType/SettingsType-RDBOnOff.cpp b/Source/Project64/Settings/SettingType/SettingsType-RDBOnOff.cpp index b6e96b6e5..4e61de03b 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RDBOnOff.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-RDBOnOff.cpp @@ -1,5 +1,4 @@ -#include "..\..\Settings.h" -#include "..\..\User Interface.h" +#include "stdafx.h" #include "SettingsType-RomDatabase.h" #include "SettingsType-RDBOnOff.h" diff --git a/Source/Project64/Settings/SettingType/SettingsType-RDBRamSize.cpp b/Source/Project64/Settings/SettingType/SettingsType-RDBRamSize.cpp index 40831300e..c71e5b6e4 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RDBRamSize.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-RDBRamSize.cpp @@ -1,5 +1,4 @@ -#include "..\..\Settings.h" -#include "..\..\User Interface.h" +#include "stdafx.h" #include "SettingsType-RomDatabase.h" #include "SettingsType-RDBRamSize.h" diff --git a/Source/Project64/Settings/SettingType/SettingsType-RDBSaveChip.cpp b/Source/Project64/Settings/SettingType/SettingsType-RDBSaveChip.cpp index 1b31870e4..3d80d50db 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RDBSaveChip.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-RDBSaveChip.cpp @@ -1,5 +1,4 @@ -#include "..\..\Settings.h" -#include "..\..\User Interface.h" +#include "stdafx.h" #include "SettingsType-RomDatabase.h" #include "SettingsType-RDBSaveChip.h" diff --git a/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.cpp b/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.cpp index 119d0d8c7..0a06a6427 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-RDBYesNo.cpp @@ -1,5 +1,4 @@ -#include "..\..\Settings.h" -#include "..\..\User Interface.h" +#include "stdafx.h" #include "SettingsType-RomDatabase.h" #include "SettingsType-RDBYesNo.h" diff --git a/Source/Project64/Settings/SettingType/SettingsType-RelativePath.cpp b/Source/Project64/Settings/SettingType/SettingsType-RelativePath.cpp index ee7c50e1f..cf8feff72 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RelativePath.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-RelativePath.cpp @@ -1,5 +1,4 @@ -#include "..\..\Settings.h" -#include "..\..\User Interface.h" +#include "stdafx.h" #include "SettingsType-RelativePath.h" CSettingTypeRelativePath::CSettingTypeRelativePath(LPCSTR Path, LPCSTR FileName) diff --git a/Source/Project64/Settings/SettingType/SettingsType-RomDatabase.cpp b/Source/Project64/Settings/SettingType/SettingsType-RomDatabase.cpp index a626c42fb..3916aa373 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RomDatabase.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-RomDatabase.cpp @@ -1,5 +1,4 @@ -#include "..\..\Settings.h" -#include "..\..\User Interface.h" +#include "stdafx.h" #include "SettingsType-RomDatabase.h" CIniFile * CSettingTypeRomDatabase::m_SettingsIniFile = NULL; diff --git a/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseIndex.cpp b/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseIndex.cpp index b62d8b4fe..fb69a4446 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseIndex.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-RomDatabaseIndex.cpp @@ -1,5 +1,4 @@ -#include "..\..\Settings.h" -#include "..\..\User Interface.h" +#include "stdafx.h" #include "SettingsType-RomDatabase.h" #include "SettingsType-RomDatabaseIndex.h" diff --git a/Source/Project64/Settings/SettingType/SettingsType-SelectedDirectory.cpp b/Source/Project64/Settings/SettingType/SettingsType-SelectedDirectory.cpp index 915719e0c..964437e6d 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-SelectedDirectory.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-SelectedDirectory.cpp @@ -1,5 +1,4 @@ -#include "..\..\Settings.h" -#include "..\..\User Interface.h" +#include "stdafx.h" #include "SettingsType-SelectedDirectory.h" diff --git a/Source/Project64/Settings/SettingType/SettingsType-TempBool.cpp b/Source/Project64/Settings/SettingType/SettingsType-TempBool.cpp index 547c44d5d..331415402 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-TempBool.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-TempBool.cpp @@ -1,5 +1,4 @@ -#include "..\..\Settings.h" -#include "..\..\User Interface.h" +#include "stdafx.h" #include "SettingsType-TempBool.h" CSettingTypeTempBool::CSettingTypeTempBool(bool initialValue) : diff --git a/Source/Project64/Settings/SettingType/SettingsType-TempNumber.cpp b/Source/Project64/Settings/SettingType/SettingsType-TempNumber.cpp index fe74ee458..fcc113001 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-TempNumber.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-TempNumber.cpp @@ -1,5 +1,4 @@ -#include "..\..\Settings.h" -#include "..\..\User Interface.h" +#include "stdafx.h" #include "SettingsType-TempNumber.h" CSettingTypeTempNumber::CSettingTypeTempNumber(ULONG initialValue) : diff --git a/Source/Project64/Settings/SettingType/SettingsType-TempString.cpp b/Source/Project64/Settings/SettingType/SettingsType-TempString.cpp index ce6f4bfa4..182566a2a 100644 --- a/Source/Project64/Settings/SettingType/SettingsType-TempString.cpp +++ b/Source/Project64/Settings/SettingType/SettingsType-TempString.cpp @@ -1,5 +1,4 @@ -#include "..\..\Settings.h" -#include "..\..\User Interface.h" +#include "stdafx.h" #include "SettingsType-TempString.h" CSettingTypeTempString::CSettingTypeTempString(LPCSTR initialValue) : diff --git a/Source/Project64/User Interface.h b/Source/Project64/User Interface.h index 30b8e645e..de9149de7 100644 --- a/Source/Project64/User Interface.h +++ b/Source/Project64/User Interface.h @@ -50,7 +50,6 @@ class CN64System; #include ".\\User Interface\\Main Menu Class.h" #include ".\\User Interface\\Notification Class.h" #include ".\\User Interface\\Frame Per Second Class.h" -#include ".\\User Interface\\Cheats.h" #include ".\\User Interface\\resource.h" #include ".\\User Interface\\Settings Config.h" diff --git a/Source/Project64/User Interface/Cheats.cpp b/Source/Project64/User Interface/Cheats.cpp deleted file mode 100644 index 4fbfd5841..000000000 --- a/Source/Project64/User Interface/Cheats.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "..\\User Interface.h" -#include "..\\N64 System.h" -#include - - diff --git a/Source/Project64/User Interface/Cheats.h b/Source/Project64/User Interface/Cheats.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/Source/Project64/User Interface/Frame Per Second Class.cpp b/Source/Project64/User Interface/Frame Per Second Class.cpp index f78a2c35c..924e166b7 100644 --- a/Source/Project64/User Interface/Frame Per Second Class.cpp +++ b/Source/Project64/User Interface/Frame Per Second Class.cpp @@ -1,7 +1,4 @@ -#include "..\\User Interface.h" -#include "../N64 System/N64 Types.h" - -#include //for QueryPerformanceCounter +#include "stdafx.h" CFramePerSecond::CFramePerSecond (CNotification * Notification): _Notify(Notification) diff --git a/Source/Project64/User Interface/Main Menu Class.cpp b/Source/Project64/User Interface/Main Menu Class.cpp index 8abf9ba6c..115e42f80 100644 --- a/Source/Project64/User Interface/Main Menu Class.cpp +++ b/Source/Project64/User Interface/Main Menu Class.cpp @@ -1,10 +1,5 @@ -#include "..\\User Interface.h" -#include "..\\N64 System.h" -#include "..\\Plugin.h" -#include "..\\User Interface\\Settings Config.h" -#include +#include "stdafx.h" #include "..\\3rd Party\\HTML Help\\HTMLHELP.H" -#include CMainMenu::CMainMenu ( CMainGui * hMainWindow ): CBaseMenu(), diff --git a/Source/Project64/User Interface/Menu Class.cpp b/Source/Project64/User Interface/Menu Class.cpp index 546940017..ff287a16b 100644 --- a/Source/Project64/User Interface/Menu Class.cpp +++ b/Source/Project64/User Interface/Menu Class.cpp @@ -1,5 +1,4 @@ -#include "..\\User Interface.h" -#include +#include "stdafx.h" CBaseMenu::CBaseMenu () : m_MenuHandle((MENU_HANDLE)CreateMenu()) diff --git a/Source/Project64/User Interface/MenuShortCuts.cpp b/Source/Project64/User Interface/MenuShortCuts.cpp index 232eb639b..6a0e38c0d 100644 --- a/Source/Project64/User Interface/MenuShortCuts.cpp +++ b/Source/Project64/User Interface/MenuShortCuts.cpp @@ -1,5 +1,4 @@ -#include "..\\User Interface.h" -#include +#include "stdafx.h" VIRTUAL_KEY CMenuShortCutKey::m_VirtualKeyList[] = { { "VK_LBUTTON", 0x01, "VK_LBUTTON" }, diff --git a/Source/Project64/User Interface/Notification Class.cpp b/Source/Project64/User Interface/Notification Class.cpp index 5b8d5243e..c288e7f86 100644 --- a/Source/Project64/User Interface/Notification Class.cpp +++ b/Source/Project64/User Interface/Notification Class.cpp @@ -1,8 +1,4 @@ -#include "..\\User Interface.h" -#include "..\\Plugin.h" - -#include -#include +#include "stdafx.h" #include CNotification & Notify ( void ) @@ -279,6 +275,5 @@ bool CNotification::ProcessGuiMessages ( void ) const void CNotification::BreakPoint ( const char * File, const int LineNumber ) { DisplayError("Break point found at\n%s\n%d",File, LineNumber); - _asm int 3 } \ No newline at end of file diff --git a/Source/Project64/User Interface/Rom Browser Class.cpp b/Source/Project64/User Interface/Rom Browser Class.cpp index 81e1d3df7..c72908f0b 100644 --- a/Source/Project64/User Interface/Rom Browser Class.cpp +++ b/Source/Project64/User Interface/Rom Browser Class.cpp @@ -1,13 +1,4 @@ -#include "../User Interface.h" -#include "../N64 System.h" -#include "../Plugin.h" -#include "..\3rd Party\Zip.h" -#include "..\3rd Party\7zip.h" -#include "../Support.h" -#include -#include -#include -#include +#include "stdafx.h" CRomBrowser::CRomBrowser (WND_HANDLE & MainWindow, WND_HANDLE & StatusWindow ) : m_MainWindow(MainWindow), diff --git a/Source/Project64/User Interface/Settings Config.cpp b/Source/Project64/User Interface/Settings Config.cpp index eb3068387..db01b1b56 100644 --- a/Source/Project64/User Interface/Settings Config.cpp +++ b/Source/Project64/User Interface/Settings Config.cpp @@ -1,8 +1,7 @@ -#include "../User Interface.h" +#include "stdafx.h" #include "Settings Config.h" #include "Settings/Settings Page.h" - CSettingConfig::CSettingConfig(bool bJustGameSetting /* = false */) : m_CurrentPage(NULL), m_GameConfig(bJustGameSetting) 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 be51223a4..6a33d2f4d 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Advanced Options.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Advanced Options.cpp @@ -1,4 +1,4 @@ -#include "../../User Interface.h" +#include "stdafx.h" #include "Settings Page.h" CAdvancedOptionsPage::CAdvancedOptionsPage (HWND hParent, const RECT & rcDispay ) diff --git a/Source/Project64/User Interface/Settings/Settings Page - Directories.cpp b/Source/Project64/User Interface/Settings/Settings Page - Directories.cpp index fc40415bd..0115fe2f8 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Directories.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Directories.cpp @@ -1,4 +1,4 @@ -#include "../../User Interface.h" +#include "stdafx.h" #include "Settings Page.h" COptionsDirectoriesPage::COptionsDirectoriesPage (HWND hParent, const RECT & rcDispay ) : 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 11fd9949f..6565dbec9 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game - General.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Game - General.cpp @@ -1,4 +1,4 @@ -#include "../../User Interface.h" +#include "stdafx.h" #include "Settings Page.h" #include "Settings Page - Game - General.h" 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 2ae64b2da..5ce145e0e 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game - Plugin.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Game - Plugin.cpp @@ -1,4 +1,4 @@ -#include "../../User Interface.h" +#include "stdafx.h" #include "Settings Page.h" #include "Settings Page - Game - Plugin.h" 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 376ea9c47..a1be35fc9 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game - Recompiler.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Game - Recompiler.cpp @@ -1,4 +1,4 @@ -#include "../../User Interface.h" +#include "stdafx.h" #include "Settings Page.h" #include "Settings Page - Game - Recompiler.h" 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 3232a76d4..c9622c2c2 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game - Status.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Game - Status.cpp @@ -1,4 +1,4 @@ -#include "../../User Interface.h" +#include "stdafx.h" #include "Settings Page.h" #include "Settings Page - Game - Status.h" 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 e3b305eec..60aa1e193 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Game Browser.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Game Browser.cpp @@ -1,4 +1,4 @@ -#include "../../User Interface.h" +#include "stdafx.h" #include "Settings Page.h" COptionsGameBrowserPage::COptionsGameBrowserPage (HWND hParent, const RECT & rcDispay ) : 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 054a979c0..9e3d59e5f 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Keyboard Shortcuts.cpp @@ -1,4 +1,4 @@ -#include "../../User Interface.h" +#include "stdafx.h" #include "Settings Page.h" COptionsShortCutsPage::COptionsShortCutsPage (HWND hParent, const RECT & rcDispay ) : diff --git a/Source/Project64/User Interface/Settings/Settings Page - Options.cpp b/Source/Project64/User Interface/Settings/Settings Page - Options.cpp index 6bfbac8e6..3d976c2a1 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Options.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Options.cpp @@ -1,4 +1,4 @@ -#include "../../User Interface.h" +#include "stdafx.h" #include "Settings Page.h" CGeneralOptionsPage::CGeneralOptionsPage (HWND hParent, const RECT & rcDispay ) diff --git a/Source/Project64/User Interface/Settings/Settings Page - Plugin.cpp b/Source/Project64/User Interface/Settings/Settings Page - Plugin.cpp index 22aa6949d..9c3f54229 100644 --- a/Source/Project64/User Interface/Settings/Settings Page - Plugin.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page - Plugin.cpp @@ -1,4 +1,4 @@ -#include "../../User Interface.h" +#include "stdafx.h" #include "Settings Page.h" COptionPluginPage::COptionPluginPage (HWND hParent, const RECT & rcDispay ) diff --git a/Source/Project64/User Interface/Settings/Settings Page.cpp b/Source/Project64/User Interface/Settings/Settings Page.cpp index 52307acd1..c7f4fcf8f 100644 --- a/Source/Project64/User Interface/Settings/Settings Page.cpp +++ b/Source/Project64/User Interface/Settings/Settings Page.cpp @@ -1,4 +1,4 @@ -#include "../../User Interface.h" +#include "stdafx.h" #include "Settings Page.h" CConfigSettingSection::CConfigSettingSection( LPCSTR PageTitle ) : diff --git a/Source/Project64/User Interface/UI Resources.aps b/Source/Project64/User Interface/UI Resources.aps index 31f311011787d439c89dd927f4ed1662c2ff01e2..0d8dd868ad9cb69b0f6bfd8e6f08c7b50d471117 100644 GIT binary patch delta 2267 zcmZXUeN0nV7{<@J_fXhiN|6@RB4j-(b5YVvc=IK&88AoX)f2bPQ_u+}XHB zDJb6bgdJx7_wFnq%43$oyW-uk)x}sZ9@9&W-iQ zMCalI0|F{x4N(Dgiw@2{mK&dJQ{x&wcxcsQ1s5T{=@k*bY+5bi!ovY-b0GQ-r;Fxt zSAhAJE8y^CH~%4;Yg$T0Om2Nw#P3?y%wtzuktlfE%p#iFpQV#Lxjo}a=Q0lMpVNM2 zWrv&bKRc7?CFQvzKT32JPmyBy9d4qld5#pNEIXPk^N67MLlw|m0Ti2rO&+NLW)GoB zaLvt@;N^jvWz!be=3xmdZ4x1rq!BZ=SN+#Q{3Rp`8zmb_87alDo$Mi%q+;ZhhrLMU zBtqbaUbY;jdzoc%oZo3B<>W(BO$yLwCmTo=QVFraJAG`gj24*aV~b(Bk6A{n1FVix z>&WFn=AsMoESXrqObL<5YzPz%v3R;24iB+JItBwnY)Q}={EJ877rZsZrVwJw<$H2X zhDl8IxAK?UO@@9(h^GzK4KtJB(oRAgpF!a;i@Pg`ogt>?^;>7p%U9G=x@uCVTOzfh@1DEkH$JteL5Vk`)vlGqX#hTus z)2+A)o)S&()ah%nez;T99Z%~aWE2ZHDk;QNQ)6g8Lgqfd8+`ZW$i#6BjMZxKlBeUO z27A2wDP-4E;|DVcmO9PctTVUaT(;J0dYew)i6@R6)btjej>nPgZ^RvIqQ+o`(A`8K z%SDYTS1>u|(vt1EBI5{!dtErxX&lON6qo1= z-253#nn6p}!9v{p1WUKpQL8J}f$3vC6yA1I;~U?jZ1HI3UY$7v&C7Z#sHQCpvQj>T6F?xP2NY5rQ+idYVG}8BD52kPK?c6S|}YlOe+tzCDLY z8$J%5=O`>WPhW?I5yqrN7r`~cOj7GYH>0=?h-Z*siQ1XigQ8HD28T_GdSCWHV@jQ%pN$2y}@HWs-3~l zyJ%!^63%4BR}8MZnK4v-OI7x&Dn6X}x_~%*{N&j_ln1ej`Y_5rA$_A!tQFr)K3^EN II^Deg2Ytx6WdHyG delta 4910 zcmb_fYitzP6~1@(VuP^(MRABBwXZicRjJpD?S+7`EsPCu2o085Y9)l)qpcekrpKivO+}ukSLaW?yhaH zJ#LnYvDRnKchC9G{qAdKcKz#-zHc7+4aE%y^PhA!UL+Q7oHwgV)!L~Vq_w*Gvh26= z8@<0f^3NCXwfL5eTOB!b(eUtbG=oT}38^TC7%D`~@IPXGvFU~B2pugzXaVBiog}$d z;Fp>Wn>DLpksaLD;IV^0Ybc!n$MYLKcmgK68Q(8G<*>o6TmDb%;Gw{f4IK9duh_DC zn>!}ql{*&4zf@LF!l5^ovU!~iy>(}Er5zjz+l^IxZY0x|d{Z=L$C9aDvV(`zckJLV zwIeog{M{||!mZowf470- z-**hzvXpebHZlCKou5sF#L61n_P8xWMc4Ne!(mBSvF(#YR_+K*j1-IH-#eDr!F4-J z?BMry+D3bJ*}}cMitI=-cH2gG?6%#0|Ji-rj^w-Uh#lO&r_K&`?_F#MAKhDQ2T$MU zwSi|cvH;E=@w;wq-&Zy{WP$a?zC-wOymNmq$u2HIMN5j&v(4<`>` z(XwdH3?i(!%JQq%Rry}1T}6djTDxK8+Gne%%kA;hmsEK?)xPRvgST)|5%uX()KHkB zMy0UFv+8+QR)(vYF|E|&X>DySY%M8N^^nI`=V@k*{t@>jTIm*gB$p(ms$V{T5fLq=YQ(DShRce$$h}+k$$u84wb86+?9|UAov@<}OMUH&}aErVR2%!u^JkXvlZFvoZ=3%|&!;5GdV2 zDWZhiOKGL9NZ|rnBZpgLrud}-YJh&XA?r%8b2O=#Zq3S=F;$*9DRKE|bgQg{npr7r zQp15U&`>($Qd;cQ+5j4>QStyCTTT;w8DTe*^c1MvZZYVdgwn)ab8;R4Y*GX50@5nV z3{8qse^@e%a#td>*i}&`7^&!5xy$RS_=T(+umosP;nQUv(NqDfkOoGZ$YS14BS(Or z>1s4oQ5KuXntW?uOT5%4OOetsW(b5nCzCvaVO%XHHNmvDDgoA9?kZlk)CGF=fUK9h z7Kz!VCM{#SxPhyT1x6#EUgDxHQdkK^VKt~4NSvg*WV~(|h8LA^MAFAPHX@mcwLF2o zxJZne2r$QuB`n4J#}a~qYAg!fEu>YdE>kHQppvGAVXcWxMm1dx=~5&jPgNE6N>bf; zmG`8XDQa6IHL3qgnau!A7So~xWVL`wv4El`v?x(ii!rK&VTG^*~brm0{Xqa4JwErfI6qXiTF_ zr7f^e%;ZK{TsXzx{@?_rDEXPh!8v|23c=>+(o9LQAC3e@0}|{i$&l~UJW*lFa?Iqm zySE@y)Zjr<*PhX*f8q_Q0^SKP`T9vG#^}=Dj+1UY>(68b zfL@G{13fW=2Tu|gZs7Y)lAqwK2mABVt~ucAeWTT~F?X8yi0|Rwo+No`*CA)^uXye$ zlDqISyl&R^AXJ0u;T=`HjJkm>@gkZD$%*U3m%u-0tvQgJHd8cx#os+ep5Ozg$YTyI z;S@XmGy={VAdjWr_(~8tt#yOhe8m7E>CJbNzySan0dOoDw$=>I<6YwZ?tI=oKysa3 z6!RmwIETM4(3&EC1<;v2^;mGhFP(opK(ZZw*u>M`gz!1_nEz}8gs*s$5a+HR5i-NMsOLji9K z=IfZC1T;OfBN;aPJOK?NuBVd+MI76P`GHpiJ)q7xCUmP4y!VAiyD(qA4ZIs7z&3aDr-bd<%U6ReNNM%Nk0IR9(jEh45{d;qM|dl>rkTfqmd zPV_qF^Eu8rd{z`b28EA86BS;d7jyFs@Kz++jze1?c#XpQ8oZhP;B|rLc>EOaJ}WwL zh7W*sl5?2noq^UHBKG8Y%-=gJV#U~f^fpgB2QmM62lLw(0bOwp(3gJCSDzy*9XI~S z_d~0r;3_{WqS)s!FgI~d+MQ{zlm_`N0X}-i$vs~?bJ8>N5xQAR`0(>2C+%`JLUVM! z<~*bi?%^*Bd-V;zU)aoEepc9?UViO7nU}T{KKJhS@>_5}TYN*+o**!RiEk)=`wXlQ k?E=rZ010>B;tRn#KX{Aqw~v$LN=aXPQG{pmJdU&f3!5)XwEzGB diff --git a/Source/Project64/User Interface/UI Resources.rc b/Source/Project64/User Interface/UI Resources.rc index e28553ae3..335aa4132 100644 --- a/Source/Project64/User Interface/UI Resources.rc +++ b/Source/Project64/User Interface/UI Resources.rc @@ -1124,13 +1124,6 @@ END #endif // !_MAC -///////////////////////////////////////////////////////////////////////////// -// -// HTML -// - -IDR_HTML_ABOUT HTML DISCARDABLE "about.htm" - ///////////////////////////////////////////////////////////////////////////// // // Cursor diff --git a/Source/Project64/User Interface/WTL Controls/ModifiedEditBox.cpp b/Source/Project64/User Interface/WTL Controls/ModifiedEditBox.cpp index 22387f730..bfd40cb94 100644 --- a/Source/Project64/User Interface/WTL Controls/ModifiedEditBox.cpp +++ b/Source/Project64/User Interface/WTL Controls/ModifiedEditBox.cpp @@ -1,4 +1,4 @@ -#include +#include "stdafx.h" CModifiedEditBox::CModifiedEditBox(bool bString /* = true */, HWND hWnd /* = NULL */) : CEdit(hWnd), diff --git a/Source/Project64/User Interface/WTL Controls/PartialGroupBox.cpp b/Source/Project64/User Interface/WTL Controls/PartialGroupBox.cpp index ec805442b..e9d066c3d 100644 --- a/Source/Project64/User Interface/WTL Controls/PartialGroupBox.cpp +++ b/Source/Project64/User Interface/WTL Controls/PartialGroupBox.cpp @@ -1,5 +1,4 @@ -#include -//#include +#include "stdafx.h" BOOL CPartialGroupBox::Attach(HWND hWndNew) { diff --git a/Source/Project64/User Interface/about.htm b/Source/Project64/User Interface/about.htm deleted file mode 100644 index bbb3c6949..000000000 --- a/Source/Project64/User Interface/about.htm +++ /dev/null @@ -1,62 +0,0 @@ - - - -Untitled Document - - - - - -

Version 1.7

-

Project64 Team:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Zilmarfounder. Core and application programmer
Jabovideo, audio and input plugin programmer
Smiffbug tracking, testing, suggestions, rdb, end user support up to version 1.5.
Gentcheat database, testing, end user support.
Tooielead application programmer for v1.5
Wittenapplication programmer for v1.5.
RadeonUsertesting
TrotterWtesting
Pixitesting
- - \ No newline at end of file diff --git a/Source/Project64/ValidateBinary.cpp b/Source/Project64/ValidateBinary.cpp index c8e501b2a..2d54a7352 100644 --- a/Source/Project64/ValidateBinary.cpp +++ b/Source/Project64/ValidateBinary.cpp @@ -1,10 +1,5 @@ -#include +#include "stdafx.h" #include -#include -#include "settings.h" -#include "support.h" -#include "Validate Binary.h" - #pragma comment(lib, "Wininet.lib") LPSTR ValidateDecryptString (LPSTR String, int Len) diff --git a/Source/Project64/stdafx.cpp b/Source/Project64/stdafx.cpp new file mode 100644 index 000000000..1577c4e3b --- /dev/null +++ b/Source/Project64/stdafx.cpp @@ -0,0 +1 @@ +#include "stdafx.h" \ No newline at end of file diff --git a/Source/Project64/stdafx.h b/Source/Project64/stdafx.h index d3946258a..69e83abaf 100644 --- a/Source/Project64/stdafx.h +++ b/Source/Project64/stdafx.h @@ -10,15 +10,10 @@ #include "Validate Binary.h" #include -#include "N64 System/C Core/Registers.h" #include "N64 System/C Core/CPU Log.h" -#include "N64 System/C Core/X86.h" #include "N64 System/C Core/Dma.h" -#include "N64 System/C Core/Plugin.h" -#include "N64 System/C Core/Exception.h" #include "N64 System/C Core/C Core Interface.h" #include "N64 System/C Core/Pif.h" -#include "N64 System/C Core/c core.h" #include "3rd Party/Zip.h" #include "3rd Party/7zip.h"