Added Action Replay logging support to the AR window and possible Fill 'N' Slide fix.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1503 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
omegadox 2008-12-12 06:44:02 +00:00
parent 66536235e6
commit b743aad2a5
4 changed files with 103 additions and 33 deletions

View File

@ -43,6 +43,8 @@ namespace
static bool b_RanOnce = false;
static std::vector<ARCode> arCodes;
static std::vector<ARCode> activeCodes;
static bool logSelf = false;
static std::vector<std::string> arLog;
} // namespace
void LogInfo(const char *format, ...);
@ -162,13 +164,24 @@ void LoadActionReplayCodes(IniFile &ini)
void LogInfo(const char *format, ...)
{
if(!b_RanOnce && IsLoggingActivated()) {
char* temp = (char*)alloca(strlen(format)+512);
va_list args;
va_start(args, format);
CharArrayFromFormatV(temp, 512, format, args);
va_end(args);
LogManager::Log(LogTypes::ACTIONREPLAY, temp);
if(!b_RanOnce)
{
if (IsLoggingActivated() || logSelf)
{
char* temp = (char*)alloca(strlen(format)+512);
va_list args;
va_start(args, format);
CharArrayFromFormatV(temp, 512, format, args);
va_end(args);
if (IsLoggingActivated())
LogManager::Log(LogTypes::ACTIONREPLAY, temp);
if (logSelf)
{
std::string text = temp;
text += "\n";
arLog.push_back(text.c_str());
}
}
}
}
@ -535,7 +548,7 @@ bool Subtype_MasterCodeAndWriteToCCXXXXXX()
bool ZeroCode_FillAndSlide(u32 addr_last, u32 addr, u32 data) // This needs more testing
{
u32 new_addr = (addr_last & 0x81FFFFFF);
u8 size = ((new_addr >> 25) & 0x03);
u8 size = ((addr_last >> 25) & 0x03);
int addr_incr;
u32 val = addr;
int val_incr;
@ -576,15 +589,12 @@ bool ZeroCode_FillAndSlide(u32 addr_last, u32 addr, u32 data) // This needs more
LogInfo("Byte Write");
LogInfo("--------");
for (int i=0; i < write_num; i++) {
u8 repeat = val >> 8;
for(int j=0; j < repeat; j++) {
Memory::Write_U8(val & 0xFF, new_addr + j);
LogInfo("Write %08x to address %08x", val & 0xFF, new_addr + j);
val += val_incr;
curr_addr += addr_incr;
LogInfo("Value Update: %08x", val);
LogInfo("Current Hardware Address Update: %08x", curr_addr);
}
Memory::Write_U8(val & 0xFF, curr_addr);
LogInfo("Write %08x to address %08x", val & 0xFF, curr_addr);
val += val_incr;
curr_addr += addr_incr;
LogInfo("Value Update: %08x", val);
LogInfo("Current Hardware Address Update: %08x", curr_addr);
}
LogInfo("--------");
break;
@ -594,15 +604,12 @@ bool ZeroCode_FillAndSlide(u32 addr_last, u32 addr, u32 data) // This needs more
LogInfo("Short Write");
LogInfo("--------");
for (int i=0; i < write_num; i++) {
u8 repeat = val >> 16;
for(int j=0; j < repeat; j++) {
Memory::Write_U16(val & 0xFFFF, new_addr + j * 2);
LogInfo("Write %08x to address %08x", val & 0xFFFF, new_addr + j * 2);
val += val_incr;
curr_addr += addr_incr;
LogInfo("Value Update: %08x", val);
LogInfo("Current Hardware Address Update: %08x", curr_addr);
}
Memory::Write_U16(val & 0xFFFF, curr_addr);
LogInfo("Write %08x to address %08x", val & 0xFFFF, curr_addr);
val += val_incr;
curr_addr += addr_incr;
LogInfo("Value Update: %08x", val);
LogInfo("Current Hardware Address Update: %08x", curr_addr);
}
LogInfo("--------");
break;
@ -612,8 +619,8 @@ bool ZeroCode_FillAndSlide(u32 addr_last, u32 addr, u32 data) // This needs more
LogInfo("Word Write");
LogInfo("--------");
for (int i=0; i < write_num; i++) {
Memory::Write_U32(val, new_addr);
LogInfo("Write %08x to address %08x", val, new_addr);
Memory::Write_U32(val, curr_addr);
LogInfo("Write %08x to address %08x", val, curr_addr);
val += val_incr;
curr_addr += addr_incr;
LogInfo("Value Update: %08x", val);
@ -983,3 +990,16 @@ void ActionReplay_UpdateActiveList()
activeCodes.push_back(arCodes[i]);
}
}
void ActionReplay_EnableSelfLogging(bool enable)
{
logSelf = enable;
}
std::vector<std::string> ActionReplay_GetSelfLog()
{
return arLog;
}
bool ActionReplay_IsSelfLogging()
{
return logSelf;
}

View File

@ -38,5 +38,8 @@ size_t ActionReplay_GetCodeListSize();
ARCode ActionReplay_GetARCode(size_t index);
void ActionReplay_SetARCode_IsActive(bool active, size_t index);
void ActionReplay_UpdateActiveList();
void ActionReplay_EnableSelfLogging(bool enable);
std::vector<std::string> ActionReplay_GetSelfLog();
bool ActionReplay_IsSelfLogging();
#endif //_ACTIONREPLAY_H_

View File

@ -21,12 +21,14 @@
#include "Core.h"
BEGIN_EVENT_TABLE(wxCheatsWindow, wxWindow)
EVT_SIZE( wxCheatsWindow::OnEvent_Window_Resize)
EVT_CLOSE( wxCheatsWindow::OnEvent_Window_Close)
EVT_BUTTON(ID_BUTTON_CLOSE, wxCheatsWindow::OnEvent_ButtonClose_Press)
EVT_SIZE( wxCheatsWindow::OnEvent_Window_Resize)
EVT_CLOSE( wxCheatsWindow::OnEvent_Window_Close)
EVT_BUTTON(ID_BUTTON_CLOSE, wxCheatsWindow::OnEvent_ButtonClose_Press)
EVT_LISTBOX(ID_CHECKLISTBOX_CHEATSLIST, wxCheatsWindow::OnEvent_CheatsList_ItemSelected)
EVT_CHECKLISTBOX(ID_CHECKLISTBOX_CHEATSLIST, wxCheatsWindow::OnEvent_CheatsList_ItemToggled)
EVT_BUTTON(ID_BUTTON_APPLYCODES, wxCheatsWindow::OnEvent_ButtonUpdateCodes_Press)
EVT_BUTTON(ID_BUTTON_APPLYCODES, wxCheatsWindow::OnEvent_ButtonUpdateCodes_Press)
EVT_BUTTON(ID_BUTTON_UPDATELOG, wxCheatsWindow::OnEvent_ButtonUpdateLog_Press)
EVT_CHECKBOX(ID_CHECKBOX_LOGAR, wxCheatsWindow::OnEvent_CheckBoxEnableLogging_StateChange)
END_EVENT_TABLE()
wxCheatsWindow::wxCheatsWindow(wxFrame* parent, const wxPoint& pos, const wxSize& size) : wxFrame(parent, wxID_ANY, _T("Action Replay"), pos, size, wxCHEATSWINDOW_STYLE)
@ -89,6 +91,22 @@ void wxCheatsWindow::Init_ChildControls()
// $ Log Tab
m_Tab_Log = new wxPanel(m_Notebook_Main, ID_TAB_LOG, wxDefaultPosition, wxDefaultSize);
m_Button_UpdateLog = new wxButton(m_Tab_Log, ID_BUTTON_UPDATELOG, wxT("Update"));
m_CheckBox_LogAR = new wxCheckBox(m_Tab_Log, ID_CHECKBOX_LOGAR, wxT("Enable AR Logging"));
m_CheckBox_LogAR->SetValue(ActionReplay_IsSelfLogging());
m_TextCtrl_Log = new wxTextCtrl(m_Tab_Log, ID_TEXTCTRL_LOG, wxT(""), wxDefaultPosition, wxSize(100, 600), wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP);
wxBoxSizer *HStrip1 = new wxBoxSizer(wxHORIZONTAL);
HStrip1->Add(m_CheckBox_LogAR, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
HStrip1->Add(m_Button_UpdateLog, 0, wxALL, 5);
wxBoxSizer *sTabLog = new wxBoxSizer(wxVERTICAL);
sTabLog->Add(HStrip1, 0, wxALL, 5);
sTabLog->Add(m_TextCtrl_Log, 1, wxALL|wxEXPAND, 5);
m_Tab_Log->SetSizer(sTabLog);
m_Tab_Log->Layout();
// Add Tabs to Notebook
m_Notebook_Main->AddPage(m_Tab_Cheats, _T("Codes List"));
m_Notebook_Main->AddPage(m_Tab_Log, _T("Logging"));
@ -176,3 +194,18 @@ void wxCheatsWindow::OnEvent_ButtonUpdateCodes_Press(wxCommandEvent& WXUNUSED (e
ActionReplay_SetARCode_IsActive(m_CheckListBox_CheatsList->IsChecked(indexList[i].uiIndex), indexList[i].index);
}
}
void wxCheatsWindow::OnEvent_ButtonUpdateLog_Press(wxCommandEvent& WXUNUSED (event))
{
m_TextCtrl_Log->Clear();
std::vector<std::string> arLog = ActionReplay_GetSelfLog();
for (int i = 0; i < arLog.size(); i++)
{
m_TextCtrl_Log->AppendText(wxString::FromAscii(arLog[i].c_str()));
}
}
void wxCheatsWindow::OnEvent_CheckBoxEnableLogging_StateChange(wxCommandEvent& WXUNUSED (event))
{
ActionReplay_EnableSelfLogging(m_CheckBox_LogAR->IsChecked());
}

View File

@ -67,12 +67,17 @@ class wxCheatsWindow : public wxFrame
wxButton *m_Button_Close;
wxButton *m_Button_ApplyCodes;
wxButton *m_Button_UpdateLog;
wxCheckBox *m_CheckBox_LogAR;
wxStaticText *m_Label_Codename;
wxStaticText *m_Label_NumCodes;
wxCheckListBox *m_CheckListBox_CheatsList;
wxTextCtrl *m_TextCtrl_Log;
wxListBox *m_ListBox_CodesList;
wxStaticBox *m_GroupBox_Info;
@ -93,7 +98,10 @@ class wxCheatsWindow : public wxFrame
ID_GROUPBOX_INFO,
ID_BUTTON_APPLYCODES,
ID_LABEL_NUMCODES,
ID_LISTBOX_CODESLIST
ID_LISTBOX_CODESLIST,
ID_BUTTON_UPDATELOG,
ID_CHECKBOX_LOGAR,
ID_TEXTCTRL_LOG
};
void Init_ChildControls();
@ -114,6 +122,12 @@ class wxCheatsWindow : public wxFrame
// $ Update Active Codes Button
void OnEvent_ButtonUpdateCodes_Press(wxCommandEvent& event);
// $ Update Log Button
void OnEvent_ButtonUpdateLog_Press(wxCommandEvent& event);
// $ Enable Logging Checkbox
void OnEvent_CheckBoxEnableLogging_StateChange(wxCommandEvent& event);
};
#endif