[Project64] Split cheat class between UI and code

This commit is contained in:
zilmar 2015-11-07 14:32:23 +11:00
parent 45a8598290
commit 9f87dbf30d
16 changed files with 2776 additions and 2667 deletions

File diff suppressed because it is too large Load Diff

View File

@ -10,82 +10,39 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
class CCheats class CCheats
{ {
public: public:
CCheats ( const CN64Rom * Rom = NULL ); CCheats();
~CCheats ( void ); ~CCheats(void);
bool IsCheatMessage ( MSG * msg ); enum
void ApplyCheats ( CMipsMemory * MMU ); {
void ApplyGSButton ( CMipsMemory * MMU ); MaxCheats = 50000,
void LoadCheats ( bool DisableSelected, CPlugins * Plugins ); MaxGSEntries = 100,
void SelectCheats ( HWND hParent, bool BlockExecution ); };
inline bool CheatsSlectionChanged ( void ) const { return m_CheatSelectionChanged; }
void ApplyCheats(CMipsMemory * MMU);
void ApplyGSButton(CMipsMemory * MMU);
void LoadCheats(bool DisableSelected, CPlugins * Plugins);
static bool IsValid16BitCode(const char * CheatString);
private: private:
struct GAMESHARK_CODE { struct GAMESHARK_CODE
DWORD Command; {
WORD Value; uint32_t Command;
}; uint16_t Value;
};
typedef std::vector<GAMESHARK_CODE> CODES; typedef std::vector<GAMESHARK_CODE> CODES;
typedef std::vector<CODES> CODES_ARRAY; typedef std::vector<CODES> CODES_ARRAY;
enum { MaxCheats = 50000 }; void LoadPermCheats(CPlugins * Plugins);
void LoadPermCheats ( CPlugins * Plugins );
static int CALLBACK CheatAddProc ( HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam );
static int CALLBACK CheatListProc ( HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam );
static int CALLBACK ManageCheatsProc ( HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam );
static int CALLBACK CheatsCodeExProc ( HWND hDlg, DWORD uMsg, DWORD wParam, DWORD lParam);
static int CALLBACK CheatsCodeQuantProc ( HWND hDlg, DWORD uMsg, DWORD wParam, DWORD lParam);
//information about the gui for selecting cheats
HWND m_Window, m_hSelectCheat, m_AddCheat, m_hCheatTree, m_hSelectedItem;
const CN64Rom * m_Rom;
void * const m_rcList, * const m_rcAdd;
int m_MinSizeDlg, m_MaxSizeDlg;
int m_EditCheat;
bool m_DeleteingEntries;
CODES_ARRAY m_Codes;
bool m_CheatSelectionChanged;
//Information about the current cheat we are editing
stdstr m_EditName;
stdstr m_EditCode;
stdstr m_EditOptions;
stdstr m_EditNotes;
enum Dialog_State { CONTRACTED, EXPANDED } m_DialogState; const CN64Rom * m_Rom;
enum TV_CHECK_STATE { TV_STATE_UNKNOWN, TV_STATE_CLEAR, TV_STATE_CHECKED, TV_STATE_INDETERMINATE }; CODES_ARRAY m_Codes;
enum { MaxGSEntries = 100, IDC_MYTREE = 0x500 };
bool LoadCode ( int CheatNo, LPCSTR CheatString ); bool LoadCode(int32_t CheatNo, const char * CheatString);
void AddCodeLayers ( int CheatNumber, const stdstr &CheatName, HWND hParent, bool CheatActive ); int32_t ApplyCheatEntry(CMipsMemory * MMU, const CODES & CodeEntry, int32_t CurrentEntry, bool Execute);
//Reload the cheats from the ini file to the select gui
void RefreshCheatManager ();
void ChangeChildrenStatus ( HWND hParent, bool Checked );
void CheckParentStatus ( HWND hParent );
static stdstr ReadCodeString ( HWND hDlg, bool &validcodes, bool &validoption, bool &nooptions, int &codeformat );
static stdstr ReadOptionsString( HWND hDlg, bool &validcodes, bool &validoptions, bool &nooptions, int &codeformat );
int ApplyCheatEntry (CMipsMemory * MMU,const CODES & CodeEntry, int CurrentEntry, bool Execute );
void RecordCheatValues ( HWND hDlg );
bool CheatChanged ( HWND hDlg );
bool IsValid16BitCode ( LPCSTR CheatString ) const;
void DeleteCheat(int Index);
//Get Information about the Cheat
stdstr GetCheatName ( int CheatNo, bool AddExtension ) const;
static bool CheatUsesCodeExtensions ( const stdstr &LineEntry );
//Working with treeview
static bool TV_SetCheckState(HWND hwndTreeView, HWND hItem, TV_CHECK_STATE state);
static int TV_GetCheckState(HWND hwndTreeView, HWND hItem);
static DWORD AsciiToHex ( const char * HexValue );
static void MenuSetText ( HMENU hMenu, int MenuPos, const wchar_t * Title, const wchar_t * ShortCut );
//UI Functions
static stdstr GetDlgItemStr (HWND hDlg, int nIDDlgItem);
}; };

View File

@ -49,13 +49,13 @@ void CSystemEvents::ExecuteEvents()
{ {
return; return;
} }
Events = m_Events; Events = m_Events;
m_Events.clear(); m_Events.clear();
} }
bool bPause = false, bLoadedSave = false; bool bPause = false, bLoadedSave = false;
for (EventList::const_iterator iter = Events.begin(); !bLoadedSave && iter != Events.end(); iter++ ) for (EventList::const_iterator iter = Events.begin(); !bLoadedSave && iter != Events.end(); iter++)
{ {
switch (*iter) switch (*iter)
{ {
@ -66,10 +66,10 @@ void CSystemEvents::ExecuteEvents()
m_System->GameReset(); m_System->GameReset();
break; break;
case SysEvent_ResetCPU_SoftDone: case SysEvent_ResetCPU_SoftDone:
m_System->Reset(true,false); m_System->Reset(true, false);
break; break;
case SysEvent_ResetCPU_Hard: case SysEvent_ResetCPU_Hard:
m_System->Reset(true,true); m_System->Reset(true, true);
break; break;
case SysEvent_Profile_GenerateLogs: case SysEvent_Profile_GenerateLogs:
m_System->m_Profile.GenerateLog(); m_System->m_Profile.GenerateLog();
@ -106,7 +106,7 @@ void CSystemEvents::ExecuteEvents()
g_Reg->DoIntrException(false); g_Reg->DoIntrException(false);
break; break;
case SysEvent_SaveMachineState: case SysEvent_SaveMachineState:
if (!m_System->SaveState()) if (!m_System->SaveState())
{ {
m_Events.push_back(SysEvent_SaveMachineState); m_Events.push_back(SysEvent_SaveMachineState);
m_bDoSomething = true; m_bDoSomething = true;
@ -125,8 +125,9 @@ void CSystemEvents::ExecuteEvents()
Notify().ChangeFullScreen(); Notify().ChangeFullScreen();
break; break;
case SysEvent_GSButtonPressed: case SysEvent_GSButtonPressed:
if (m_System->m_Cheats.CheatsSlectionChanged()) if (m_System->HasCheatsSlectionChanged())
{ {
m_System->SetCheatsSlectionChanged(false);
m_System->m_Cheats.LoadCheats(false, m_Plugins); m_System->m_Cheats.LoadCheats(false, m_Plugins);
} }
m_System->m_Cheats.ApplyGSButton(g_MMU); m_System->m_Cheats.ApplyGSButton(g_MMU);
@ -134,7 +135,7 @@ void CSystemEvents::ExecuteEvents()
case SysEvent_PauseCPU_FromMenu: case SysEvent_PauseCPU_FromMenu:
if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
{ {
g_Settings->SaveBool(GameRunning_CPU_Paused,true); g_Settings->SaveBool(GameRunning_CPU_Paused, true);
g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_FromMenu); g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_FromMenu);
bPause = true; bPause = true;
} }
@ -142,7 +143,7 @@ void CSystemEvents::ExecuteEvents()
case SysEvent_PauseCPU_AppLostFocus: case SysEvent_PauseCPU_AppLostFocus:
if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
{ {
g_Settings->SaveBool(GameRunning_CPU_Paused,true); g_Settings->SaveBool(GameRunning_CPU_Paused, true);
g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_AppLostFocus); g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_AppLostFocus);
bPause = true; bPause = true;
} }
@ -150,7 +151,7 @@ void CSystemEvents::ExecuteEvents()
case SysEvent_PauseCPU_AppLostActive: case SysEvent_PauseCPU_AppLostActive:
if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
{ {
g_Settings->SaveBool(GameRunning_CPU_Paused,true); g_Settings->SaveBool(GameRunning_CPU_Paused, true);
g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_AppLostActive); g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_AppLostActive);
bPause = true; bPause = true;
} }
@ -158,7 +159,7 @@ void CSystemEvents::ExecuteEvents()
case SysEvent_PauseCPU_SaveGame: case SysEvent_PauseCPU_SaveGame:
if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
{ {
g_Settings->SaveBool(GameRunning_CPU_Paused,true); g_Settings->SaveBool(GameRunning_CPU_Paused, true);
g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_SaveGame); g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_SaveGame);
bPause = true; bPause = true;
} }
@ -166,7 +167,7 @@ void CSystemEvents::ExecuteEvents()
case SysEvent_PauseCPU_LoadGame: case SysEvent_PauseCPU_LoadGame:
if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
{ {
g_Settings->SaveBool(GameRunning_CPU_Paused,true); g_Settings->SaveBool(GameRunning_CPU_Paused, true);
g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_LoadGame); g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_LoadGame);
bPause = true; bPause = true;
} }
@ -174,7 +175,7 @@ void CSystemEvents::ExecuteEvents()
case SysEvent_PauseCPU_DumpMemory: case SysEvent_PauseCPU_DumpMemory:
if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
{ {
g_Settings->SaveBool(GameRunning_CPU_Paused,true); g_Settings->SaveBool(GameRunning_CPU_Paused, true);
g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_DumpMemory); g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_DumpMemory);
bPause = true; bPause = true;
} }
@ -182,7 +183,7 @@ void CSystemEvents::ExecuteEvents()
case SysEvent_PauseCPU_SearchMemory: case SysEvent_PauseCPU_SearchMemory:
if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
{ {
g_Settings->SaveBool(GameRunning_CPU_Paused,true); g_Settings->SaveBool(GameRunning_CPU_Paused, true);
g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_SearchMemory); g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_SearchMemory);
bPause = true; bPause = true;
} }
@ -190,13 +191,21 @@ void CSystemEvents::ExecuteEvents()
case SysEvent_PauseCPU_Settings: case SysEvent_PauseCPU_Settings:
if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
{ {
g_Settings->SaveBool(GameRunning_CPU_Paused,true); g_Settings->SaveBool(GameRunning_CPU_Paused, true);
g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_Settings); g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_Settings);
bPause = true; bPause = true;
} }
break; break;
case SysEvent_PauseCPU_Cheats:
if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
{
g_Settings->SaveBool(GameRunning_CPU_Paused, true);
g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_Cheats);
bPause = true;
}
break;
default: default:
g_Notify->BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
break; break;
} }
} }
@ -209,6 +218,6 @@ void CSystemEvents::ExecuteEvents()
void CSystemEvents::ChangePluginFunc() void CSystemEvents::ChangePluginFunc()
{ {
g_Notify->DisplayMessage(0,MSG_PLUGIN_INIT); g_Notify->DisplayMessage(0, MSG_PLUGIN_INIT);
m_System->PluginReset(); m_System->PluginReset();
} }

View File

@ -12,42 +12,44 @@
enum SystemEvent enum SystemEvent
{ {
SysEvent_ExecuteInterrupt, SysEvent_ExecuteInterrupt,
SysEvent_GSButtonPressed, SysEvent_GSButtonPressed,
SysEvent_ResetCPU_Soft, SysEvent_ResetCPU_Soft,
SysEvent_ResetCPU_SoftDone, SysEvent_ResetCPU_SoftDone,
SysEvent_ResetCPU_Hard, SysEvent_ResetCPU_Hard,
SysEvent_CloseCPU, SysEvent_CloseCPU,
SysEvent_PauseCPU_FromMenu, SysEvent_PauseCPU_FromMenu,
SysEvent_PauseCPU_AppLostActive, SysEvent_PauseCPU_AppLostActive,
SysEvent_PauseCPU_AppLostActiveDelay, SysEvent_PauseCPU_AppLostActiveDelay,
SysEvent_PauseCPU_AppLostFocus, SysEvent_PauseCPU_AppLostFocus,
SysEvent_PauseCPU_SaveGame, SysEvent_PauseCPU_SaveGame,
SysEvent_PauseCPU_LoadGame, SysEvent_PauseCPU_LoadGame,
SysEvent_PauseCPU_DumpMemory, SysEvent_PauseCPU_DumpMemory,
SysEvent_PauseCPU_SearchMemory, SysEvent_PauseCPU_SearchMemory,
SysEvent_PauseCPU_Settings, SysEvent_PauseCPU_Settings,
SysEvent_ResumeCPU_FromMenu, SysEvent_PauseCPU_Cheats,
SysEvent_ResumeCPU_AppGainedActive, SysEvent_ResumeCPU_FromMenu,
SysEvent_ResumeCPU_AppGainedFocus, SysEvent_ResumeCPU_AppGainedActive,
SysEvent_ResumeCPU_SaveGame, SysEvent_ResumeCPU_AppGainedFocus,
SysEvent_ResumeCPU_LoadGame, SysEvent_ResumeCPU_SaveGame,
SysEvent_ResumeCPU_DumpMemory, SysEvent_ResumeCPU_LoadGame,
SysEvent_ResumeCPU_SearchMemory, SysEvent_ResumeCPU_DumpMemory,
SysEvent_ResumeCPU_Settings, SysEvent_ResumeCPU_SearchMemory,
SysEvent_ChangingFullScreen, SysEvent_ResumeCPU_Settings,
SysEvent_ChangePlugins, SysEvent_ResumeCPU_Cheats,
SysEvent_SaveMachineState, SysEvent_ChangingFullScreen,
SysEvent_LoadMachineState, SysEvent_ChangePlugins,
SysEvent_Interrupt_SP, SysEvent_SaveMachineState,
SysEvent_Interrupt_SI, SysEvent_LoadMachineState,
SysEvent_Interrupt_AI, SysEvent_Interrupt_SP,
SysEvent_Interrupt_VI, SysEvent_Interrupt_SI,
SysEvent_Interrupt_PI, SysEvent_Interrupt_AI,
SysEvent_Interrupt_DP, SysEvent_Interrupt_VI,
SysEvent_Profile_StartStop, SysEvent_Interrupt_PI,
SysEvent_Profile_ResetLogs, SysEvent_Interrupt_DP,
SysEvent_Profile_GenerateLogs, SysEvent_Profile_StartStop,
SysEvent_Profile_ResetLogs,
SysEvent_Profile_GenerateLogs,
}; };
class CSystemEvents class CSystemEvents

View File

@ -15,34 +15,34 @@
#include <windows.h> #include <windows.h>
#include <commdlg.h> #include <commdlg.h>
CN64System::CN64System ( CPlugins * Plugins, bool SavesReadOnly ) : CN64System::CN64System(CPlugins * Plugins, bool SavesReadOnly) :
CSystemEvents(this, Plugins), CSystemEvents(this, Plugins),
m_Cheats(NULL), m_EndEmulation(false),
m_EndEmulation(false), m_SaveUsing((SAVE_CHIP_TYPE)g_Settings->LoadDword(Game_SaveChip)),
m_SaveUsing((SAVE_CHIP_TYPE)g_Settings->LoadDword(Game_SaveChip)), m_Plugins(Plugins),
m_Plugins(Plugins), m_SyncCPU(NULL),
m_SyncCPU(NULL), m_SyncPlugins(NULL),
m_SyncPlugins(NULL), m_SyncWindow(NULL),
m_SyncWindow(NULL), m_MMU_VM(this, SavesReadOnly),
m_MMU_VM(this,SavesReadOnly), m_TLB(this),
m_TLB(this), m_Reg(this, this),
m_Reg(this,this), m_Recomp(NULL),
m_Recomp(NULL), m_InReset(false),
m_InReset(false), m_NextTimer(0),
m_NextTimer(0), m_SystemTimer(m_NextTimer),
m_SystemTimer(m_NextTimer), m_bCleanFrameBox(true),
m_bCleanFrameBox(true), m_bInitialized(false),
m_bInitialized(false), m_RspBroke(true),
m_RspBroke(true), m_DMAUsed(false),
m_DMAUsed(false), m_TestTimer(false),
m_TestTimer(false), m_NextInstruction(0),
m_NextInstruction(0), m_JumpToLocation(0),
m_JumpToLocation(0), m_TLBLoadAddress(0),
m_TLBLoadAddress(0), m_TLBStoreAddress(0),
m_TLBStoreAddress(0), m_SyncCount(0),
m_SyncCount(0), m_CPU_Handle(NULL),
m_CPU_Handle(NULL), m_CPU_ThreadID(0),
m_CPU_ThreadID(0) m_CheatsSlectionChanged(false)
{ {
DWORD gameHertz = g_Settings->LoadDword(Game_ScreenHertz); DWORD gameHertz = g_Settings->LoadDword(Game_ScreenHertz);
if (gameHertz == 0) if (gameHertz == 0)
@ -115,9 +115,10 @@ void CN64System::ExternalEvent ( SystemEvent action )
case SysEvent_PauseCPU_DumpMemory: case SysEvent_PauseCPU_DumpMemory:
case SysEvent_PauseCPU_SearchMemory: case SysEvent_PauseCPU_SearchMemory:
case SysEvent_PauseCPU_Settings: case SysEvent_PauseCPU_Settings:
case SysEvent_PauseCPU_Cheats:
if (!g_Settings->LoadBool(GameRunning_CPU_Paused)) if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
{ {
QueueEvent(action); QueueEvent(action);
} }
break; break;
case SysEvent_ResumeCPU_FromMenu: case SysEvent_ResumeCPU_FromMenu:
@ -166,9 +167,15 @@ void CN64System::ExternalEvent ( SystemEvent action )
SetEvent(m_hPauseEvent); SetEvent(m_hPauseEvent);
} }
break; break;
case SysEvent_ResumeCPU_Cheats:
if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_Cheats)
{
SetEvent(m_hPauseEvent);
}
break;
default: default:
WriteTraceF(TraceError,__FUNCTION__ ": Unknown event %d",action); WriteTraceF(TraceError, __FUNCTION__ ": Unknown event %d", action);
g_Notify->BreakPoint(__FILEW__,__LINE__); g_Notify->BreakPoint(__FILEW__, __LINE__);
} }
} }
@ -453,11 +460,6 @@ void CN64System::CloseCpu()
CpuStopped(); CpuStopped();
} }
void CN64System::SelectCheats ( HWND hParent )
{
m_Cheats.SelectCheats(hParent,false);
}
void CN64System::DisplayRomInfo ( HWND hParent ) void CN64System::DisplayRomInfo ( HWND hParent )
{ {
if (!g_Rom) { return; } if (!g_Rom) { return; }
@ -508,15 +510,6 @@ stdstr CN64System::ChooseFileToOpen ( HWND hParent )
return stdstr(""); return stdstr("");
} }
bool CN64System::IsDialogMsg( MSG * msg )
{
if (m_Cheats.IsCheatMessage(msg))
{
return true;
}
return false;
}
void CN64System::GameReset() void CN64System::GameReset()
{ {
m_SystemTimer.SetTimer(CSystemTimer::SoftResetTimer,0x3000000,false); m_SystemTimer.SetTimer(CSystemTimer::SoftResetTimer,0x3000000,false);
@ -2051,19 +2044,20 @@ void CN64System::RefreshScreen()
m_CPU_Usage.ShowCPU_Usage(); m_CPU_Usage.ShowCPU_Usage();
m_CPU_Usage.StartTimer(CPU_UsageAddr != Timer_None ? CPU_UsageAddr : Timer_R4300 ); m_CPU_Usage.StartTimer(CPU_UsageAddr != Timer_None ? CPU_UsageAddr : Timer_R4300 );
} }
if ((m_Reg.STATUS_REGISTER & STATUS_IE) != 0 ) if ((m_Reg.STATUS_REGISTER & STATUS_IE) != 0)
{ {
if (g_BaseSystem == NULL) if (HasCheatsSlectionChanged())
{ {
return; if (this == g_BaseSystem && g_SyncSystem != NULL)
{
g_SyncSystem->SetCheatsSlectionChanged(true);
}
SetCheatsSlectionChanged(false);
m_Cheats.LoadCheats(false, g_BaseSystem->m_Plugins);
} }
if (g_BaseSystem->m_Cheats.CheatsSlectionChanged()) m_Cheats.ApplyCheats(g_MMU);
{
g_BaseSystem->m_Cheats.LoadCheats(false, g_BaseSystem->m_Plugins);
}
g_BaseSystem->m_Cheats.ApplyCheats(g_MMU);
} }
// if (bProfiling) { m_Profile.StartTimer(ProfilingAddr != Timer_None ? ProfilingAddr : Timer_R4300); } // if (bProfiling) { m_Profile.StartTimer(ProfilingAddr != Timer_None ? ProfilingAddr : Timer_R4300); }
} }
bool CN64System::WriteToProtectedMemory (DWORD Address, int length) bool CN64System::WriteToProtectedMemory (DWORD Address, int length)

View File

@ -50,10 +50,8 @@ public:
void ExternalEvent ( SystemEvent action ); //covers gui interacting and timers etc.. void ExternalEvent ( SystemEvent action ); //covers gui interacting and timers etc..
stdstr ChooseFileToOpen ( HWND hParent ); stdstr ChooseFileToOpen ( HWND hParent );
void DisplayRomInfo ( HWND hParent ); void DisplayRomInfo ( HWND hParent );
void SelectCheats ( HWND hParent );
void StartEmulation ( bool NewThread ); void StartEmulation ( bool NewThread );
void SyncToAudio (); void SyncToAudio ();
bool IsDialogMsg ( MSG * msg );
void IncreaseSpeed () { m_Limitor.IncreaseSpeed(); } void IncreaseSpeed () { m_Limitor.IncreaseSpeed(); }
void DecreaseSpeed () { m_Limitor.DecreaseSpeed(); } void DecreaseSpeed () { m_Limitor.DecreaseSpeed(); }
void Reset ( bool bInitReg, bool ClearMenory ); void Reset ( bool bInitReg, bool ClearMenory );
@ -68,6 +66,8 @@ public:
bool DmaUsed() const { return m_DMAUsed; } bool DmaUsed() const { return m_DMAUsed; }
void SetDmaUsed(bool DMAUsed) { m_DMAUsed = DMAUsed; } void SetDmaUsed(bool DMAUsed) { m_DMAUsed = DMAUsed; }
void SetCheatsSlectionChanged(bool changed) { m_CheatsSlectionChanged = changed; }
bool HasCheatsSlectionChanged(void) const { return m_CheatsSlectionChanged; }
DWORD GetButtons(int Control) const { return m_Buttons[Control]; } DWORD GetButtons(int Control) const { return m_Buttons[Control]; }
//Variable used to track that the SP is being handled and stays the same as the real SP in sync core //Variable used to track that the SP is being handled and stays the same as the real SP in sync core
@ -144,6 +144,7 @@ private:
DWORD m_TLBLoadAddress; DWORD m_TLBLoadAddress;
DWORD m_TLBStoreAddress; DWORD m_TLBStoreAddress;
DWORD m_SyncCount; DWORD m_SyncCount;
bool m_CheatsSlectionChanged;
//When Syncing cores this is the PC where it last Sync'ed correctly //When Syncing cores this is the PC where it last Sync'ed correctly
DWORD m_LastSuccessSyncPC[10]; DWORD m_LastSuccessSyncPC[10];

View File

@ -26,61 +26,71 @@ enum PauseType
PauseType_DumpMemory, PauseType_DumpMemory,
PauseType_SearchMemory, PauseType_SearchMemory,
PauseType_Settings, PauseType_Settings,
PauseType_Cheats,
}; };
enum CPU_TYPE { enum CPU_TYPE
{
CPU_Default = -1, CPU_Interpreter = 1, CPU_Recompiler = 2, CPU_SyncCores = 3 CPU_Default = -1, CPU_Interpreter = 1, CPU_Recompiler = 2, CPU_SyncCores = 3
}; };
enum FRAMERATE_TYPE { enum FRAMERATE_TYPE
{
FR_VIs = 0, FR_DLs = 1, FR_PERCENT = 2, FR_VIs = 0, FR_DLs = 1, FR_PERCENT = 2,
}; };
enum SAVE_CHIP_TYPE { enum SAVE_CHIP_TYPE
SaveChip_Auto = -1, SaveChip_Eeprom_4K, SaveChip_Eeprom_16K, SaveChip_Sram, SaveChip_FlashRam {
SaveChip_Auto = -1, SaveChip_Eeprom_4K, SaveChip_Eeprom_16K, SaveChip_Sram, SaveChip_FlashRam
}; };
enum FUNC_LOOKUP_METHOD enum FUNC_LOOKUP_METHOD
{ {
FuncFind_Default = -1, FuncFind_PhysicalLookup = 1, FuncFind_VirtualLookup = 2, FuncFind_ChangeMemory = 3, FuncFind_Default = -1, FuncFind_PhysicalLookup = 1, FuncFind_VirtualLookup = 2, FuncFind_ChangeMemory = 3,
}; };
enum SYSTEM_TYPE { enum SYSTEM_TYPE
{
SYSTEM_NTSC = 0, SYSTEM_PAL = 1, SYSTEM_MPAL = 2 SYSTEM_NTSC = 0, SYSTEM_PAL = 1, SYSTEM_MPAL = 2
}; };
enum CICChip { enum CICChip
CIC_UNKNOWN = -1, CIC_NUS_6101 = 1, CIC_NUS_6102 = 2, CIC_NUS_6103 = 3, {
CIC_NUS_6104 = 4, CIC_NUS_6105 = 5, CIC_NUS_6106 = 6, CIC_NUS_5167 = 7, CIC_UNKNOWN = -1, CIC_NUS_6101 = 1, CIC_NUS_6102 = 2, CIC_NUS_6103 = 3,
CIC_NUS_6104 = 4, CIC_NUS_6105 = 5, CIC_NUS_6106 = 6, CIC_NUS_5167 = 7,
CIC_NUS_8303 = 8 CIC_NUS_8303 = 8
}; };
enum Country { enum Country
NTSC_BETA = 0x37, X_NTSC = 0x41, Germany = 0x44, USA = 0x45, french = 0x46, Italian = 0x49, {
Japan = 0x4A, Europe = 0x50, Spanish = 0x53, Australia = 0x55, X_PAL = 0x58, Y_PAL = 0x59, NTSC_BETA = 0x37, X_NTSC = 0x41, Germany = 0x44, USA = 0x45, french = 0x46, Italian = 0x49,
Japan = 0x4A, Europe = 0x50, Spanish = 0x53, Australia = 0x55, X_PAL = 0x58, Y_PAL = 0x59,
UnknownCountry = 0 UnknownCountry = 0
}; };
enum SPECIAL_TIMERS { enum SPECIAL_TIMERS
Timer_None = 0, Timer_R4300 = -1, Timer_RSP_Dlist = -2, {
Timer_RSP_Alist = -3, Timer_RSP_Unknown = -5, Timer_RefreshScreen = -6, Timer_None = 0, Timer_R4300 = -1, Timer_RSP_Dlist = -2,
Timer_UpdateScreen = -7, Timer_UpdateFPS = -9, Timer_Idel = -10, Timer_RSP_Alist = -3, Timer_RSP_Unknown = -5, Timer_RefreshScreen = -6,
Timer_FuncLookup = -11,Timer_Done = -13,Timer_GetBlockInfo = -14, Timer_UpdateScreen = -7, Timer_UpdateFPS = -9, Timer_Idel = -10,
Timer_AnalyseBlock = -15,Timer_CompileBlock = -17, Timer_CompileDone = -18, Timer_FuncLookup = -11, Timer_Done = -13, Timer_GetBlockInfo = -14,
Timer_AnalyseBlock = -15, Timer_CompileBlock = -17, Timer_CompileDone = -18,
Timer_InheritParentInfo = -19, Timer_AddX86Code = -20, Timer_InheritParentInfo = -19, Timer_AddX86Code = -20,
}; };
enum STEP_TYPE { enum STEP_TYPE
NORMAL = 0, {
DO_DELAY_SLOT = 1, NORMAL = 0,
DO_END_DELAY_SLOT = 2, DO_DELAY_SLOT = 1,
DELAY_SLOT = 3, DO_END_DELAY_SLOT = 2,
END_DELAY_SLOT = 4, DELAY_SLOT = 3,
LIKELY_DELAY_SLOT = 5, END_DELAY_SLOT = 4,
JUMP = 6, LIKELY_DELAY_SLOT = 5,
DELAY_SLOT_DONE = 7, JUMP = 6,
LIKELY_DELAY_SLOT_DONE= 8, DELAY_SLOT_DONE = 7,
END_BLOCK = 9, LIKELY_DELAY_SLOT_DONE = 8,
PERMLOOP_DO_DELAY = 10, END_BLOCK = 9,
PERMLOOP_DELAY_DONE = 11, PERMLOOP_DO_DELAY = 10,
PERMLOOP_DELAY_DONE = 11,
}; };

View File

@ -284,6 +284,10 @@
<Filter <Filter
Name="User Interface Source" Name="User Interface Source"
> >
<File
RelativePath=".\User Interface\Cheat Class UI.cpp"
>
</File>
<File <File
RelativePath="User Interface\Frame Per Second Class.cpp" RelativePath="User Interface\Frame Per Second Class.cpp"
> >
@ -936,6 +940,10 @@
<Filter <Filter
Name="User Interface Headers" Name="User Interface Headers"
> >
<File
RelativePath=".\User Interface\Cheat Class UI.h"
>
</File>
<File <File
RelativePath="User Interface\Frame Per Second Class.h" RelativePath="User Interface\Frame Per Second Class.h"
> >

View File

@ -74,6 +74,7 @@
<ClCompile Include="Settings\SettingType\SettingsType-TempBool.cpp" /> <ClCompile Include="Settings\SettingType\SettingsType-TempBool.cpp" />
<ClCompile Include="Settings\SettingType\SettingsType-TempNumber.cpp" /> <ClCompile Include="Settings\SettingType\SettingsType-TempNumber.cpp" />
<ClCompile Include="Settings\SettingType\SettingsType-TempString.cpp" /> <ClCompile Include="Settings\SettingType\SettingsType-TempString.cpp" />
<ClCompile Include="User Interface\Cheat Class UI.cpp" />
<ClCompile Include="User Interface\Frame Per Second Class.cpp" /> <ClCompile Include="User Interface\Frame Per Second Class.cpp" />
<ClCompile Include="User Interface\Gui Class.cpp" /> <ClCompile Include="User Interface\Gui Class.cpp" />
<ClCompile Include="User Interface\Main Menu Class.cpp" /> <ClCompile Include="User Interface\Main Menu Class.cpp" />
@ -186,6 +187,7 @@
<ClInclude Include="Settings.h" /> <ClInclude Include="Settings.h" />
<ClInclude Include="stdafx.h" /> <ClInclude Include="stdafx.h" />
<ClInclude Include="User Interface.h" /> <ClInclude Include="User Interface.h" />
<ClInclude Include="User Interface\Cheat Class UI.h" />
<ClInclude Include="Version.h" /> <ClInclude Include="Version.h" />
<ClInclude Include="WTL App.h" /> <ClInclude Include="WTL App.h" />
<ClInclude Include="Settings\Debug Settings.h" /> <ClInclude Include="Settings\Debug Settings.h" />

View File

@ -417,6 +417,9 @@
<ClCompile Include="Multilanguage\LanguageSelector.cpp"> <ClCompile Include="Multilanguage\LanguageSelector.cpp">
<Filter>Source Files\Multilanguage Source</Filter> <Filter>Source Files\Multilanguage Source</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="User Interface\Cheat Class UI.cpp">
<Filter>Source Files\User Interface Source</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Image Include="User Interface\Bitmaps\AboutScreenBottom.bmp"> <Image Include="User Interface\Bitmaps\AboutScreenBottom.bmp">
@ -842,5 +845,8 @@
<ClInclude Include="Multilanguage\LanguageSelector.h"> <ClInclude Include="Multilanguage\LanguageSelector.h">
<Filter>Header Files\Multilanguage Headers</Filter> <Filter>Header Files\Multilanguage Headers</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="User Interface\Cheat Class UI.h">
<Filter>Header Files\User Interface Headers</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -61,3 +61,4 @@ class CN64System;
#include ".\\User Interface\\Frame Per Second Class.h" #include ".\\User Interface\\Frame Per Second Class.h"
#include ".\\User Interface\\resource.h" #include ".\\User Interface\\resource.h"
#include ".\\User Interface\\Settings Config.h" #include ".\\User Interface\\Settings Config.h"
#include ".\\User Interface\\Cheat Class UI.h"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,71 @@
/****************************************************************************
* *
* Project 64 - A Nintendo 64 emulator. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#pragma once
class CCheatsUI
{
public:
CCheatsUI(void);
~CCheatsUI(void);
bool IsCheatMessage(MSG * msg);
void SelectCheats(HWND hParent, bool BlockExecution);
private:
static int CALLBACK CheatAddProc(HWND hDlg, uint32_t uMsg, uint32_t wParam, uint32_t lParam);
static int CALLBACK CheatListProc(HWND hDlg, uint32_t uMsg, uint32_t wParam, uint32_t lParam);
static int CALLBACK ManageCheatsProc(HWND hDlg, uint32_t uMsg, uint32_t wParam, uint32_t lParam);
static int CALLBACK CheatsCodeExProc(HWND hDlg, uint32_t uMsg, uint32_t wParam, uint32_t lParam);
static int CALLBACK CheatsCodeQuantProc(HWND hDlg, uint32_t uMsg, uint32_t wParam, uint32_t lParam);
//information about the gui for selecting cheats
HWND m_Window, m_hSelectCheat, m_AddCheat, m_hCheatTree, m_hSelectedItem;
void * const m_rcList, *const m_rcAdd;
int m_MinSizeDlg, m_MaxSizeDlg;
int m_EditCheat;
bool m_DeleteingEntries;
//Information about the current cheat we are editing
stdstr m_EditName;
stdstr m_EditCode;
stdstr m_EditOptions;
stdstr m_EditNotes;
enum Dialog_State { CONTRACTED, EXPANDED } m_DialogState;
enum TV_CHECK_STATE { TV_STATE_UNKNOWN, TV_STATE_CLEAR, TV_STATE_CHECKED, TV_STATE_INDETERMINATE };
enum { IDC_MYTREE = 0x500 };
void AddCodeLayers(int CheatNumber, const stdstr &CheatName, HWND hParent, bool CheatActive);
//Reload the cheats from the ini file to the select gui
void RefreshCheatManager();
void ChangeChildrenStatus(HWND hParent, bool Checked);
void CheckParentStatus(HWND hParent);
static stdstr ReadCodeString(HWND hDlg, bool &validcodes, bool &validoption, bool &nooptions, int &codeformat);
static stdstr ReadOptionsString(HWND hDlg, bool &validcodes, bool &validoptions, bool &nooptions, int &codeformat);
void RecordCheatValues(HWND hDlg);
bool CheatChanged(HWND hDlg);
void DeleteCheat(int Index);
//Get Information about the Cheat
stdstr GetCheatName(int CheatNo, bool AddExtension) const;
static bool CheatUsesCodeExtensions(const stdstr &LineEntry);
//Working with treeview
static bool TV_SetCheckState(HWND hwndTreeView, HWND hItem, TV_CHECK_STATE state);
static int TV_GetCheckState(HWND hwndTreeView, HWND hItem);
static void MenuSetText(HMENU hMenu, int MenuPos, const wchar_t * Title, const wchar_t * ShortCut);
//UI Functions
static stdstr GetDlgItemStr(HWND hDlg, int nIDDlgItem);
};
extern CCheatsUI * g_cheatUI;

File diff suppressed because it is too large Load Diff

View File

@ -32,102 +32,101 @@ class CMainGui :
public CDebuggerUI, public CDebuggerUI,
private CGuiSettings private CGuiSettings
{ {
enum { StatusBarID = 400 }; enum { StatusBarID = 400 };
enum { Timer_SetWindowPos = 1 }; enum { Timer_SetWindowPos = 1 };
struct RESET_PLUGIN struct RESET_PLUGIN
{ {
CN64System * system; CN64System * system;
CPlugins * plugins; CPlugins * plugins;
HANDLE hEvent; HANDLE hEvent;
bool res; bool res;
}; };
public: public:
CMainGui ( bool bMainWindow, const char * WindowTitle = "" ); CMainGui(bool bMainWindow, const char * WindowTitle = "");
~CMainGui ( void ); ~CMainGui(void);
//Message Processing
WPARAM ProcessAllMessages ( void );
bool ProcessGuiMessages ( void );
//debugging functions //Message Processing
void EnterLogOptions ( void ); WPARAM ProcessAllMessages(void);
bool ProcessGuiMessages(void);
//Get Information about the window //debugging functions
int Height ( void ); //Get the Height of the window void EnterLogOptions(void);
int Width ( void ); //Get the Width of the window
//Manipulate the state of the window //Get Information about the window
void SetPos ( int X, int Y ); //Move the window to this screen location int Height(void); //Get the Height of the window
void Show ( bool ShowWindow ); //Show or Hide the current window int Width(void); //Get the Width of the window
void MakeWindowOnTop ( bool OnTop );
void BringToTop ( void );
void Caption ( LPCWSTR Caption ); //Set the caption of the window
void SaveWindowLoc ( void );
//Menu Function //Manipulate the state of the window
void SetWindowMenu ( CBaseMenu * Menu ); void SetPos(int X, int Y); //Move the window to this screen location
void RefreshMenu ( void ); void Show(bool ShowWindow); //Show or Hide the current window
CBaseMenu * GetMenuClass ( void ) { return m_Menu; } void MakeWindowOnTop(bool OnTop);
void BringToTop(void);
void Caption(LPCWSTR Caption); //Set the caption of the window
void SaveWindowLoc(void);
// Status bar //Menu Function
void SetStatusText ( int Panel,const wchar_t * Text ); void SetWindowMenu(CBaseMenu * Menu);
void ShowStatusBar ( bool ShowBar ); void RefreshMenu(void);
CBaseMenu * GetMenuClass(void) { return m_Menu; }
//About Window // Status bar
void AboutIniBox ( void ); void SetStatusText(int Panel, const wchar_t * Text);
void AboutBox ( void ); void ShowStatusBar(bool ShowBar);
//Plugins //About Window
void AboutIniBox(void);
void AboutBox(void);
//Plugins
bool ResetPlugins ( CPlugins * plugins, CN64System * System ); bool ResetPlugins ( CPlugins * plugins, CN64System * System );
//Get Window Handle //Get Window Handle
inline HWND GetHandle ( void ) const { return m_hMainWindow; } inline HWND GetHandle ( void ) const { return m_hMainWindow; }
private: private:
CMainGui(void); // Disable default constructor CMainGui(void); // Disable default constructor
CMainGui(const CMainGui&); // Disable copy constructor CMainGui(const CMainGui&); // Disable copy constructor
CMainGui& operator=(const CMainGui&); // Disable assignment CMainGui& operator=(const CMainGui&); // Disable assignment
friend CGfxPlugin; friend CGfxPlugin;
friend CAudioPlugin; friend CAudioPlugin;
friend CControl_Plugin; friend CControl_Plugin;
bool RegisterWinClass ( void ); bool RegisterWinClass(void);
void ChangeWinSize ( long width, long height ); void ChangeWinSize(long width, long height);
void Create ( const char * WindowTitle ); void Create(const char * WindowTitle);
void CreateStatusBar ( void ); void CreateStatusBar(void);
void Resize ( DWORD fwSizeType, WORD nWidth, WORD nHeight ); //responding to WM_SIZE void Resize(DWORD fwSizeType, WORD nWidth, WORD nHeight); //responding to WM_SIZE
friend DWORD CALLBACK AboutBoxProc ( HWND, DWORD, DWORD, DWORD ); friend DWORD CALLBACK AboutBoxProc(HWND, DWORD, DWORD, DWORD);
friend DWORD CALLBACK AboutIniBoxProc ( HWND, DWORD, DWORD, DWORD ); friend DWORD CALLBACK AboutIniBoxProc(HWND, DWORD, DWORD, DWORD);
static LRESULT CALLBACK MainGui_Proc ( HWND, DWORD, DWORD, DWORD ); static LRESULT CALLBACK MainGui_Proc(HWND, DWORD, DWORD, DWORD);
friend void RomBowserEnabledChanged (CMainGui * Gui); friend void RomBowserEnabledChanged(CMainGui * Gui);
friend void RomBowserColoumnsChanged (CMainGui * Gui); friend void RomBowserColoumnsChanged(CMainGui * Gui);
friend void RomBrowserRecursiveChanged (CMainGui * Gui); friend void RomBrowserRecursiveChanged(CMainGui * Gui);
CBaseMenu * m_Menu; CBaseMenu * m_Menu;
HWND m_hMainWindow, m_hStatusWnd; HWND m_hMainWindow, m_hStatusWnd;
DWORD m_ThreadId; DWORD m_ThreadId;
const bool m_bMainWindow; const bool m_bMainWindow;
bool m_Created; bool m_Created;
bool m_AttachingMenu; bool m_AttachingMenu;
bool m_MakingVisible; bool m_MakingVisible;
bool m_ResetPlugins; bool m_ResetPlugins;
RESET_PLUGIN * m_ResetInfo; RESET_PLUGIN * m_ResetInfo;
CriticalSection m_CS; CriticalSection m_CS;
bool m_SaveMainWindowPos; bool m_SaveMainWindowPos;
LONG m_SaveMainWindowTop; LONG m_SaveMainWindowTop;
LONG m_SaveMainWindowLeft; LONG m_SaveMainWindowLeft;
bool m_SaveRomBrowserPos;
LONG m_SaveRomBrowserTop;
LONG m_SaveRomBrowserLeft;
bool m_SaveRomBrowserPos;
LONG m_SaveRomBrowserTop;
LONG m_SaveRomBrowserLeft;
}; };

View File

@ -214,10 +214,12 @@ bool CMainMenu::ProcessMessage(HWND hWnd, DWORD /*FromAccelerator*/, DWORD MenuI
} }
break; break;
case ID_SYSTEM_CHEAT: case ID_SYSTEM_CHEAT:
{ {
g_BaseSystem->SelectCheats(hWnd); CCheatsUI * cheatUI = new CCheatsUI;
} g_cheatUI = cheatUI;
break; cheatUI->SelectCheats(hWnd, false);
}
break;
case ID_SYSTEM_GSBUTTON: case ID_SYSTEM_GSBUTTON:
g_BaseSystem->ExternalEvent(SysEvent_GSButtonPressed); g_BaseSystem->ExternalEvent(SysEvent_GSButtonPressed);
break; break;