diff --git a/Source/Core/Core/Src/ActionReplay.cpp b/Source/Core/Core/Src/ActionReplay.cpp index 0f0fa61ffd..d77241026c 100644 --- a/Source/Core/Core/Src/ActionReplay.cpp +++ b/Source/Core/Core/Src/ActionReplay.cpp @@ -39,13 +39,14 @@ namespace { static std::vector::const_iterator iter; - static std::vector arCodes; static ARCode code; static bool b_RanOnce = false; + static std::vector arCodes; + static std::vector activeCodes; } // namespace void LogInfo(const char *format, ...); -// --Codes-- +// --- Codes --- // SubTypes (Normal 0 Codes) bool Subtype_RamWriteAndFill(u32 addr, u32 data); bool Subtype_WriteToPointer(u32 addr, u32 data); @@ -64,9 +65,9 @@ bool NormalCode_Type_5(u8 subtype, u32 addr, u32 data, int *count, bool *skip); bool NormalCode_Type_6(u8 subtype, u32 addr, u32 data, int *count, bool *skip); bool NormalCode_Type_7(u8 subtype, u32 addr, u32 data, int *count, bool *skip); -// Parses the Action Replay section of a game ini file. void LoadActionReplayCodes(IniFile &ini) { + // Parses the Action Replay section of a game ini file. if (!Core::GetStartupParameter().bEnableCheats) return; // If cheats are off, do not load them @@ -88,7 +89,7 @@ void LoadActionReplayCodes(IniFile &ini) { if (currentCode.ops.size()) { - if (currentCode.active) arCodes.push_back(currentCode); //temp hack to not store inactive codes + arCodes.push_back(currentCode); currentCode.ops.clear(); } if (encryptedLines.size()) @@ -98,13 +99,21 @@ void LoadActionReplayCodes(IniFile &ini) currentCode.ops.clear(); encryptedLines.clear(); } - currentCode.name = line; - if (line[0] == '+'){ - Core::DisplayMessage("AR code active: " + line, 5000); - currentCode.active = true; + + if(line.size() > 1) + { + if (line[0] == '+') + { + currentCode.active = true; + currentCode.name = line.substr(2, line.size() - 2);; + Core::DisplayMessage("AR code active: " + currentCode.name, 5000); + } + else + { + currentCode.active = false; + currentCode.name = line.substr(1, line.size() - 1); + } } - else - currentCode.active = false; continue; } @@ -147,6 +156,8 @@ void LoadActionReplayCodes(IniFile &ini) DecryptARCode(encryptedLines, currentCode.ops); arCodes.push_back(currentCode); } + + ActionReplay_UpdateActiveList(); } void LogInfo(const char *format, ...) @@ -164,7 +175,7 @@ void LogInfo(const char *format, ...) void ActionReplayRunAllActive() { if (Core::GetStartupParameter().bEnableCheats) { - for (std::vector::iterator iter = arCodes.begin(); iter != arCodes.end(); ++iter) + for (std::vector::iterator iter = activeCodes.begin(); iter != activeCodes.end(); ++iter) if (iter->active) { if(!RunActionReplayCode(*iter)) iter->active = false; @@ -176,11 +187,9 @@ void ActionReplayRunAllActive() } -// The mechanism is slightly different than what the real AR uses, so there may be compatibility problems. -// For example, some authors have created codes that add features to AR. Hacks for popular ones can be added here, -// but the problem is not generally solvable. -// TODO: what is "nowIsBootup" for? + bool RunActionReplayCode(const ARCode &arcode) { + // The mechanism is slightly different than what the real AR uses, so there may be compatibility problems. u8 cmd; u32 addr; u32 data; @@ -216,6 +225,9 @@ bool RunActionReplayCode(const ARCode &arcode) { if (!skip && count == 0) { LogInfo("Line skipped"); continue; }// Skip rest of lines if (!skip && count > 0) count--; // execute n lines // if -2 : execute all lines + + if(b_RanOnce) + b_RanOnce = false; } cmd = iter->cmd_addr >> 24; // AR command @@ -348,6 +360,10 @@ bool RunActionReplayCode(const ARCode &arcode) { PanicAlert("Action Replay: Invalid Normal Code Type %08x (%s)", type, code.name.c_str()); } } + + if(b_RanOnce && cond) + b_RanOnce = true; + return true; } @@ -926,3 +942,37 @@ bool NormalCode_Type_7(u8 subtype, u32 addr, u32 data, int *count, bool *skip) } return true; } + +size_t ActionReplay_GetCodeListSize() +{ + return arCodes.size(); +} +ARCode ActionReplay_GetARCode(size_t index) +{ + if (index > arCodes.size()) + { + PanicAlert("ActionReplay_GetARCode: Index is greater than ar code list size %i", index); + return ARCode(); + } + return arCodes[index]; +} +void ActionReplay_SetARCode_IsActive(bool active, size_t index) +{ + if (index > arCodes.size()) + { + PanicAlert("ActionReplay_SetARCode_IsActive: Index is greater than ar code list size %i", index); + return; + } + arCodes[index].active = active; + ActionReplay_UpdateActiveList(); +} +void ActionReplay_UpdateActiveList() +{ + b_RanOnce = false; + activeCodes.clear(); + for (size_t i = 0; i < arCodes.size(); i++) + { + if (arCodes[i].active) + activeCodes.push_back(arCodes[i]); + } +} diff --git a/Source/Core/Core/Src/ActionReplay.h b/Source/Core/Core/Src/ActionReplay.h index ff98898c8f..5c92d3c070 100644 --- a/Source/Core/Core/Src/ActionReplay.h +++ b/Source/Core/Core/Src/ActionReplay.h @@ -14,6 +14,7 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ + #ifndef _ACTIONREPLAY_H_ #define _ACTIONREPLAY_H_ @@ -33,5 +34,9 @@ struct ARCode { void ActionReplayRunAllActive(); bool RunActionReplayCode(const ARCode &arcode); void LoadActionReplayCodes(IniFile &ini); +size_t ActionReplay_GetCodeListSize(); +ARCode ActionReplay_GetARCode(size_t index); +void ActionReplay_SetARCode_IsActive(bool active, size_t index); +void ActionReplay_UpdateActiveList(); #endif //_ACTIONREPLAY_H_ diff --git a/Source/Core/DolphinWX/DolphinWX.vcproj b/Source/Core/DolphinWX/DolphinWX.vcproj index e4a84ba5a2..d005b9448c 100644 --- a/Source/Core/DolphinWX/DolphinWX.vcproj +++ b/Source/Core/DolphinWX/DolphinWX.vcproj @@ -127,7 +127,7 @@ @@ -762,6 +762,14 @@ RelativePath=".\Src\AboutDolphin.h" > + + + + diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index aead7a10e8..8b2bb43dfc 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -29,6 +29,7 @@ #include "ConfigMain.h" #include "PluginManager.h" #include "MemcardManager.h" +#include "CheatsWindow.h" #include "AboutDolphin.h" #include @@ -96,6 +97,7 @@ EVT_MENU(IDM_CONFIG_PAD_PLUGIN, CFrame::OnPluginPAD) EVT_MENU(IDM_CONFIG_WIIMOTE_PLUGIN, CFrame::OnPluginWiimote) EVT_MENU(IDM_BROWSE, CFrame::OnBrowse) EVT_MENU(IDM_MEMCARD, CFrame::OnMemcard) +EVT_MENU(IDM_CHEATS, OnShow_CheatsWindow) EVT_MENU(IDM_TOGGLE_FULLSCREEN, CFrame::OnToggleFullscreen) EVT_MENU(IDM_TOGGLE_DUALCORE, CFrame::OnToggleDualCore) EVT_MENU(IDM_TOGGLE_SKIPIDLE, CFrame::OnToggleSkipIdle) @@ -124,6 +126,12 @@ EVT_MENU(IDM_SAVESLOT10, CFrame::OnSaveState) EVT_HOST_COMMAND(wxID_ANY, CFrame::OnHostMessage) END_EVENT_TABLE() +// ---------------------------------------------------------------------------- +// Other Windows +// ---------------------------------------------------------------------------- + +wxCheatsWindow* CheatsWindow; + // ---------------------------------------------------------------------------- // implementation // ---------------------------------------------------------------------------- @@ -252,6 +260,7 @@ void CFrame::CreateMenu() miscMenu->Check(IDM_TOGGLE_STATUSBAR, true); miscMenu->AppendSeparator(); miscMenu->Append(IDM_MEMCARD, _T("&Memcard manager")); + miscMenu->Append(IDM_CHEATS, _T("Action &Replay Manager")); m_pMenuBar->Append(miscMenu, _T("&Misc")); // help menu @@ -508,6 +517,11 @@ void CFrame::OnMemcard(wxCommandEvent& WXUNUSED (event)) MemcardManager.ShowModal(); } +void CFrame::OnShow_CheatsWindow(wxCommandEvent& WXUNUSED (event)) +{ + CheatsWindow = new wxCheatsWindow(this, wxDefaultPosition, wxSize(600, 390)); +} + void CFrame::OnHostMessage(wxCommandEvent& event) { switch (event.GetId()) diff --git a/Source/Core/DolphinWX/Src/Frame.h b/Source/Core/DolphinWX/Src/Frame.h index 6d419de80b..64324fd969 100644 --- a/Source/Core/DolphinWX/Src/Frame.h +++ b/Source/Core/DolphinWX/Src/Frame.h @@ -13,7 +13,7 @@ class CFrame : public wxFrame const wxString& title = _T("Dolphin"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN | wxNO_FULL_REPAINT_ON_RESIZE); + long style = wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE); void* GetRenderHandle() {return(m_Panel->GetHandle());} @@ -70,6 +70,7 @@ class CFrame : public wxFrame void OnStop(wxCommandEvent& event); void OnBrowse(wxCommandEvent& event); void OnMemcard(wxCommandEvent& event); + void OnShow_CheatsWindow(wxCommandEvent& event); void OnToggleFullscreen(wxCommandEvent& event); void OnToggleDualCore(wxCommandEvent& event); void OnToggleSkipIdle(wxCommandEvent& event); @@ -82,7 +83,6 @@ class CFrame : public wxFrame void OnSaveState(wxCommandEvent& event); void OnClose(wxCloseEvent &event); - wxStatusBar* m_pStatusBar; wxMenuBar* m_pMenuBar; diff --git a/Source/Core/DolphinWX/Src/Globals.h b/Source/Core/DolphinWX/Src/Globals.h index 591697c708..edaa2af118 100644 --- a/Source/Core/DolphinWX/Src/Globals.h +++ b/Source/Core/DolphinWX/Src/Globals.h @@ -46,6 +46,7 @@ enum IDM_STOP, IDM_BROWSE, IDM_MEMCARD, + IDM_CHEATS, IDM_PROPERTIES, IDM_OPENCONTAININGFOLDER, IDM_SETDEFAULTGCM, diff --git a/Source/Core/DolphinWX/Src/SConscript b/Source/Core/DolphinWX/Src/SConscript index 36f28c72cd..7bb1b2c78b 100644 --- a/Source/Core/DolphinWX/Src/SConscript +++ b/Source/Core/DolphinWX/Src/SConscript @@ -21,6 +21,7 @@ if not env['osx64']: 'MemcardManager.cpp', 'MemoryCards/GCMemcard.cpp', 'PluginManager.cpp', + 'CheatsWindow.cpp', 'stdafx.cpp', ]