2013-04-18 03:43:35 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2014-02-17 10:18:15 +00:00
|
|
|
#include <algorithm>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <cstddef>
|
|
|
|
#include <mutex>
|
|
|
|
#include <string>
|
2014-02-17 10:18:15 +00:00
|
|
|
#include <vector>
|
2014-02-22 22:36:30 +00:00
|
|
|
|
|
|
|
#include <wx/accel.h>
|
|
|
|
#include <wx/button.h>
|
|
|
|
#include <wx/chartype.h>
|
|
|
|
#include <wx/checkbox.h>
|
2014-02-19 01:56:29 +00:00
|
|
|
#include <wx/clipbrd.h>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <wx/dataobj.h>
|
|
|
|
#include <wx/defs.h>
|
|
|
|
#include <wx/dialog.h>
|
|
|
|
#include <wx/event.h>
|
|
|
|
#include <wx/filedlg.h>
|
|
|
|
#include <wx/gdicmn.h>
|
|
|
|
#include <wx/listbox.h>
|
2014-07-25 01:46:46 +00:00
|
|
|
#include <wx/msgdlg.h>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <wx/notebook.h>
|
|
|
|
#include <wx/panel.h>
|
|
|
|
#include <wx/sizer.h>
|
|
|
|
#include <wx/spinbutt.h>
|
2014-02-19 01:56:29 +00:00
|
|
|
#include <wx/spinctrl.h>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <wx/statbox.h>
|
|
|
|
#include <wx/stattext.h>
|
|
|
|
#include <wx/string.h>
|
|
|
|
#include <wx/textctrl.h>
|
|
|
|
#include <wx/translation.h>
|
|
|
|
#include <wx/utils.h>
|
2014-02-17 10:18:15 +00:00
|
|
|
|
|
|
|
#include "Common/Common.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "Core/FifoPlayer/FifoDataFile.h"
|
|
|
|
#include "Core/FifoPlayer/FifoPlaybackAnalyzer.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Core/FifoPlayer/FifoPlayer.h"
|
|
|
|
#include "Core/FifoPlayer/FifoRecorder.h"
|
|
|
|
#include "DolphinWX/FifoPlayerDlg.h"
|
|
|
|
#include "DolphinWX/WxUtils.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "VideoCommon/BPMemory.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/OpcodeDecoding.h"
|
2013-01-08 20:41:58 +00:00
|
|
|
|
2014-02-22 22:36:30 +00:00
|
|
|
class wxWindow;
|
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
DECLARE_EVENT_TYPE(RECORDING_FINISHED_EVENT, -1)
|
|
|
|
DEFINE_EVENT_TYPE(RECORDING_FINISHED_EVENT)
|
|
|
|
|
|
|
|
DECLARE_EVENT_TYPE(FRAME_WRITTEN_EVENT, -1)
|
|
|
|
DEFINE_EVENT_TYPE(FRAME_WRITTEN_EVENT)
|
|
|
|
|
2014-07-08 13:58:25 +00:00
|
|
|
static std::recursive_mutex sMutex;
|
2014-03-09 20:14:26 +00:00
|
|
|
wxEvtHandler *volatile FifoPlayerDlg::m_EvtHandler = nullptr;
|
2011-03-27 02:55:08 +00:00
|
|
|
|
|
|
|
FifoPlayerDlg::FifoPlayerDlg(wxWindow * const parent) :
|
2014-03-06 04:02:34 +00:00
|
|
|
wxDialog(parent, wxID_ANY, _("FIFO Player")),
|
2012-01-21 12:40:14 +00:00
|
|
|
m_search_result_idx(0), m_FramesToRecord(1)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
CreateGUIControls();
|
|
|
|
|
2013-05-01 13:05:37 +00:00
|
|
|
sMutex.lock();
|
|
|
|
m_EvtHandler = GetEventHandler();
|
2011-03-27 02:55:08 +00:00
|
|
|
sMutex.unlock();
|
|
|
|
|
|
|
|
FifoPlayer::GetInstance().SetFileLoadedCallback(FileLoaded);
|
|
|
|
FifoPlayer::GetInstance().SetFrameWrittenCallback(FrameWritten);
|
|
|
|
}
|
|
|
|
|
|
|
|
FifoPlayerDlg::~FifoPlayerDlg()
|
|
|
|
{
|
2013-01-13 18:07:45 +00:00
|
|
|
Unbind(RECORDING_FINISHED_EVENT, &FifoPlayerDlg::OnRecordingFinished, this);
|
|
|
|
Unbind(FRAME_WRITTEN_EVENT, &FifoPlayerDlg::OnFrameWritten, this);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
|
|
|
// Disconnect Events
|
2013-01-13 18:07:45 +00:00
|
|
|
Unbind(wxEVT_PAINT, &FifoPlayerDlg::OnPaint, this);
|
2014-05-17 16:49:00 +00:00
|
|
|
m_FrameFromCtrl->Unbind(wxEVT_SPINCTRL, &FifoPlayerDlg::OnFrameFrom, this);
|
|
|
|
m_FrameToCtrl->Unbind(wxEVT_SPINCTRL, &FifoPlayerDlg::OnFrameTo, this);
|
|
|
|
m_ObjectFromCtrl->Unbind(wxEVT_SPINCTRL, &FifoPlayerDlg::OnObjectFrom, this);
|
|
|
|
m_ObjectToCtrl->Unbind(wxEVT_SPINCTRL, &FifoPlayerDlg::OnObjectTo, this);
|
|
|
|
m_EarlyMemoryUpdates->Unbind(wxEVT_CHECKBOX, &FifoPlayerDlg::OnCheckEarlyMemoryUpdates, this);
|
|
|
|
m_RecordStop->Unbind(wxEVT_BUTTON, &FifoPlayerDlg::OnRecordStop, this);
|
|
|
|
m_Save->Unbind(wxEVT_BUTTON, &FifoPlayerDlg::OnSaveFile, this);
|
|
|
|
m_FramesToRecordCtrl->Unbind(wxEVT_SPINCTRL, &FifoPlayerDlg::OnNumFramesToRecord, this);
|
|
|
|
m_Close->Unbind(wxEVT_BUTTON, &FifoPlayerDlg::OnCloseClick, this);
|
|
|
|
|
|
|
|
m_framesList->Unbind(wxEVT_LISTBOX, &FifoPlayerDlg::OnFrameListSelectionChanged, this);
|
|
|
|
m_objectsList->Unbind(wxEVT_LISTBOX, &FifoPlayerDlg::OnObjectListSelectionChanged, this);
|
|
|
|
m_objectCmdList->Unbind(wxEVT_LISTBOX, &FifoPlayerDlg::OnObjectCmdListSelectionChanged, this);
|
2012-01-03 01:30:37 +00:00
|
|
|
|
2014-03-09 20:14:26 +00:00
|
|
|
FifoPlayer::GetInstance().SetFrameWrittenCallback(nullptr);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2013-05-01 13:05:37 +00:00
|
|
|
sMutex.lock();
|
2014-03-09 20:14:26 +00:00
|
|
|
m_EvtHandler = nullptr;
|
2011-03-27 02:55:08 +00:00
|
|
|
sMutex.unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FifoPlayerDlg::CreateGUIControls()
|
|
|
|
{
|
|
|
|
wxBoxSizer* sMain;
|
2011-04-17 21:39:58 +00:00
|
|
|
sMain = new wxBoxSizer(wxVERTICAL);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-03-06 04:02:34 +00:00
|
|
|
m_Notebook = new wxNotebook(this, wxID_ANY);
|
2012-01-03 01:30:37 +00:00
|
|
|
|
|
|
|
{
|
2011-04-17 21:39:58 +00:00
|
|
|
m_PlayPage = new wxPanel(m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
2011-03-27 02:55:08 +00:00
|
|
|
wxBoxSizer* sPlayPage;
|
2011-04-17 21:39:58 +00:00
|
|
|
sPlayPage = new wxBoxSizer(wxVERTICAL);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
wxStaticBoxSizer* sPlayInfo;
|
2011-04-17 21:39:58 +00:00
|
|
|
sPlayInfo = new wxStaticBoxSizer(new wxStaticBox(m_PlayPage, wxID_ANY, _("File Info")), wxVERTICAL);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-03-06 04:02:34 +00:00
|
|
|
m_NumFramesLabel = new wxStaticText(m_PlayPage, wxID_ANY, wxEmptyString);
|
2011-04-17 21:39:58 +00:00
|
|
|
m_NumFramesLabel->Wrap(-1);
|
|
|
|
sPlayInfo->Add(m_NumFramesLabel, 0, wxALL, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-03-06 04:02:34 +00:00
|
|
|
m_CurrentFrameLabel = new wxStaticText(m_PlayPage, wxID_ANY, wxEmptyString);
|
2011-04-17 21:39:58 +00:00
|
|
|
m_CurrentFrameLabel->Wrap(-1);
|
|
|
|
sPlayInfo->Add(m_CurrentFrameLabel, 0, wxALL, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-03-06 04:02:34 +00:00
|
|
|
m_NumObjectsLabel = new wxStaticText(m_PlayPage, wxID_ANY, wxEmptyString);
|
2011-04-17 21:39:58 +00:00
|
|
|
m_NumObjectsLabel->Wrap(-1);
|
|
|
|
sPlayInfo->Add(m_NumObjectsLabel, 0, wxALL, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
sPlayPage->Add(sPlayInfo, 1, wxEXPAND, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
wxStaticBoxSizer* sFrameRange;
|
2011-04-17 21:39:58 +00:00
|
|
|
sFrameRange = new wxStaticBoxSizer(new wxStaticBox(m_PlayPage, wxID_ANY, _("Frame Range")), wxHORIZONTAL);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-03-06 04:02:34 +00:00
|
|
|
m_FrameFromLabel = new wxStaticText(m_PlayPage, wxID_ANY, _("From"));
|
2011-04-17 21:39:58 +00:00
|
|
|
m_FrameFromLabel->Wrap(-1);
|
|
|
|
sFrameRange->Add(m_FrameFromLabel, 0, wxALL, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_FrameFromCtrl = new wxSpinCtrl(m_PlayPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 10, 0);
|
|
|
|
sFrameRange->Add(m_FrameFromCtrl, 0, wxALL, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-03-06 04:02:34 +00:00
|
|
|
m_FrameToLabel = new wxStaticText(m_PlayPage, wxID_ANY, _("To"));
|
2011-04-17 21:39:58 +00:00
|
|
|
m_FrameToLabel->Wrap(-1);
|
|
|
|
sFrameRange->Add(m_FrameToLabel, 0, wxALL, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_FrameToCtrl = new wxSpinCtrl(m_PlayPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(-1,-1), wxSP_ARROW_KEYS, 0, 10, 0);
|
|
|
|
sFrameRange->Add(m_FrameToCtrl, 0, wxALL, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
sPlayPage->Add(sFrameRange, 0, wxEXPAND, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
wxStaticBoxSizer* sObjectRange;
|
2011-04-17 21:39:58 +00:00
|
|
|
sObjectRange = new wxStaticBoxSizer(new wxStaticBox(m_PlayPage, wxID_ANY, _("Object Range")), wxHORIZONTAL);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-03-06 04:02:34 +00:00
|
|
|
m_ObjectFromLabel = new wxStaticText(m_PlayPage, wxID_ANY, _("From"));
|
2011-04-17 21:39:58 +00:00
|
|
|
m_ObjectFromLabel->Wrap(-1);
|
|
|
|
sObjectRange->Add(m_ObjectFromLabel, 0, wxALL, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_ObjectFromCtrl = new wxSpinCtrl(m_PlayPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 10000, 0);
|
|
|
|
sObjectRange->Add(m_ObjectFromCtrl, 0, wxALL, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-03-06 04:02:34 +00:00
|
|
|
m_ObjectToLabel = new wxStaticText(m_PlayPage, wxID_ANY, _("To"));
|
2011-04-17 21:39:58 +00:00
|
|
|
m_ObjectToLabel->Wrap(-1);
|
|
|
|
sObjectRange->Add(m_ObjectToLabel, 0, wxALL, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_ObjectToCtrl = new wxSpinCtrl(m_PlayPage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 10000, 0);
|
|
|
|
sObjectRange->Add(m_ObjectToCtrl, 0, wxALL, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
sPlayPage->Add(sObjectRange, 0, wxEXPAND, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
wxStaticBoxSizer* sPlayOptions;
|
2011-04-17 21:39:58 +00:00
|
|
|
sPlayOptions = new wxStaticBoxSizer(new wxStaticBox(m_PlayPage, wxID_ANY, _("Playback Options")), wxVERTICAL);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-03-06 04:02:34 +00:00
|
|
|
m_EarlyMemoryUpdates = new wxCheckBox(m_PlayPage, wxID_ANY, _("Early Memory Updates"));
|
2011-04-17 21:39:58 +00:00
|
|
|
sPlayOptions->Add(m_EarlyMemoryUpdates, 0, wxALL, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
sPlayPage->Add(sPlayOptions, 0, wxEXPAND, 5);
|
2012-01-21 12:40:14 +00:00
|
|
|
sPlayPage->AddStretchSpacer();
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_PlayPage->SetSizer(sPlayPage);
|
2011-03-27 02:55:08 +00:00
|
|
|
m_PlayPage->Layout();
|
2011-04-17 21:39:58 +00:00
|
|
|
sPlayPage->Fit(m_PlayPage);
|
2011-04-27 01:10:58 +00:00
|
|
|
m_Notebook->AddPage(m_PlayPage, _("Play"), true);
|
2012-01-03 01:30:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2011-04-17 21:39:58 +00:00
|
|
|
m_RecordPage = new wxPanel(m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
2011-03-27 02:55:08 +00:00
|
|
|
wxBoxSizer* sRecordPage;
|
2011-04-17 21:39:58 +00:00
|
|
|
sRecordPage = new wxBoxSizer(wxVERTICAL);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
wxStaticBoxSizer* sRecordInfo;
|
2011-04-17 21:39:58 +00:00
|
|
|
sRecordInfo = new wxStaticBoxSizer(new wxStaticBox(m_RecordPage, wxID_ANY, _("Recording Info")), wxVERTICAL);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-03-06 04:02:34 +00:00
|
|
|
m_RecordingFifoSizeLabel = new wxStaticText(m_RecordPage, wxID_ANY, wxEmptyString);
|
2011-04-17 21:39:58 +00:00
|
|
|
m_RecordingFifoSizeLabel->Wrap(-1);
|
|
|
|
sRecordInfo->Add(m_RecordingFifoSizeLabel, 0, wxALL, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-03-06 04:02:34 +00:00
|
|
|
m_RecordingMemSizeLabel = new wxStaticText(m_RecordPage, wxID_ANY, wxEmptyString);
|
2011-04-17 21:39:58 +00:00
|
|
|
m_RecordingMemSizeLabel->Wrap(-1);
|
|
|
|
sRecordInfo->Add(m_RecordingMemSizeLabel, 0, wxALL, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-03-06 04:02:34 +00:00
|
|
|
m_RecordingFramesLabel = new wxStaticText(m_RecordPage, wxID_ANY, wxEmptyString);
|
2011-04-17 21:39:58 +00:00
|
|
|
m_RecordingFramesLabel->Wrap(-1);
|
|
|
|
sRecordInfo->Add(m_RecordingFramesLabel, 0, wxALL, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
sRecordPage->Add(sRecordInfo, 0, wxEXPAND, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
wxBoxSizer* sRecordButtons;
|
2011-04-17 21:39:58 +00:00
|
|
|
sRecordButtons = new wxBoxSizer(wxHORIZONTAL);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-03-06 04:02:34 +00:00
|
|
|
m_RecordStop = new wxButton(m_RecordPage, wxID_ANY, _("Record"));
|
2011-04-17 21:39:58 +00:00
|
|
|
sRecordButtons->Add(m_RecordStop, 0, wxALL, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-03-06 04:02:34 +00:00
|
|
|
m_Save = new wxButton(m_RecordPage, wxID_ANY, _("Save"));
|
2011-04-17 21:39:58 +00:00
|
|
|
sRecordButtons->Add(m_Save, 0, wxALL, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
sRecordPage->Add(sRecordButtons, 0, wxEXPAND, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
wxStaticBoxSizer* sRecordingOptions;
|
2011-04-17 21:39:58 +00:00
|
|
|
sRecordingOptions = new wxStaticBoxSizer(new wxStaticBox(m_RecordPage, wxID_ANY, _("Recording Options")), wxHORIZONTAL);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-03-06 04:02:34 +00:00
|
|
|
m_FramesToRecordLabel = new wxStaticText(m_RecordPage, wxID_ANY, _("Frames To Record"));
|
2011-04-17 21:39:58 +00:00
|
|
|
m_FramesToRecordLabel->Wrap(-1);
|
|
|
|
sRecordingOptions->Add(m_FramesToRecordLabel, 0, wxALL, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-03-29 16:20:46 +00:00
|
|
|
wxString initialNum = wxString::Format("%d", m_FramesToRecord);
|
2013-05-01 13:41:45 +00:00
|
|
|
m_FramesToRecordCtrl = new wxSpinCtrl(m_RecordPage, wxID_ANY, initialNum, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 10000, 1);
|
2011-04-17 21:39:58 +00:00
|
|
|
sRecordingOptions->Add(m_FramesToRecordCtrl, 0, wxALL, 5);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
sRecordPage->Add(sRecordingOptions, 0, wxEXPAND, 5);
|
2012-01-21 12:40:14 +00:00
|
|
|
sRecordPage->AddStretchSpacer();
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
m_RecordPage->SetSizer(sRecordPage);
|
2011-03-27 02:55:08 +00:00
|
|
|
m_RecordPage->Layout();
|
2011-04-17 21:39:58 +00:00
|
|
|
sRecordPage->Fit(m_RecordPage);
|
|
|
|
m_Notebook->AddPage(m_RecordPage, _("Record"), false);
|
2012-01-03 01:30:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Analyze page
|
|
|
|
{
|
|
|
|
m_AnalyzePage = new wxPanel(m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
|
|
|
wxBoxSizer* sAnalyzePage;
|
|
|
|
sAnalyzePage = new wxBoxSizer(wxVERTICAL);
|
|
|
|
|
2012-01-21 12:40:14 +00:00
|
|
|
wxStaticBoxSizer* sFrameInfoSizer;
|
|
|
|
sFrameInfoSizer = new wxStaticBoxSizer(new wxStaticBox(m_AnalyzePage, wxID_ANY, _("Frame Info")), wxVERTICAL);
|
2012-01-05 16:49:46 +00:00
|
|
|
|
|
|
|
wxBoxSizer* sListsSizer = new wxBoxSizer(wxHORIZONTAL);
|
2012-01-03 01:30:37 +00:00
|
|
|
|
|
|
|
m_framesList = new wxListBox(m_AnalyzePage, wxID_ANY);
|
|
|
|
m_framesList->SetMinSize(wxSize(100, 250));
|
2012-01-05 16:49:46 +00:00
|
|
|
sListsSizer->Add(m_framesList, 0, wxALL, 5);
|
2012-01-03 01:30:37 +00:00
|
|
|
|
|
|
|
m_objectsList = new wxListBox(m_AnalyzePage, wxID_ANY);
|
|
|
|
m_objectsList->SetMinSize(wxSize(110, 250));
|
2012-01-05 16:49:46 +00:00
|
|
|
sListsSizer->Add(m_objectsList, 0, wxALL, 5);
|
2012-01-03 01:30:37 +00:00
|
|
|
|
|
|
|
m_objectCmdList = new wxListBox(m_AnalyzePage, wxID_ANY);
|
|
|
|
m_objectCmdList->SetMinSize(wxSize(175, 250));
|
2012-01-05 16:49:46 +00:00
|
|
|
sListsSizer->Add(m_objectCmdList, 0, wxALL, 5);
|
|
|
|
|
2012-01-21 12:40:14 +00:00
|
|
|
sFrameInfoSizer->Add(sListsSizer, 0, wxALL, 5);
|
2012-01-05 16:49:46 +00:00
|
|
|
|
|
|
|
m_objectCmdInfo = new wxStaticText(m_AnalyzePage, wxID_ANY, wxString());
|
2012-01-21 12:40:14 +00:00
|
|
|
sFrameInfoSizer->Add(m_objectCmdInfo, 0, wxALL, 5);
|
|
|
|
|
|
|
|
sAnalyzePage->Add(sFrameInfoSizer, 0, wxEXPAND, 5);
|
|
|
|
|
|
|
|
wxStaticBoxSizer* sSearchSizer = new wxStaticBoxSizer(new wxStaticBox(m_AnalyzePage, wxID_ANY, _("Search current Object")), wxVERTICAL);
|
|
|
|
|
|
|
|
wxBoxSizer* sSearchField = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
|
|
|
|
sSearchField->Add(new wxStaticText(m_AnalyzePage, wxID_ANY, _("Search for hex Value:")), 0, wxALIGN_CENTER_VERTICAL, 5);
|
|
|
|
// TODO: ugh, wxValidator sucks - but we should use it anyway.
|
|
|
|
m_searchField = new wxTextCtrl(m_AnalyzePage, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
|
|
|
|
m_numResultsText = new wxStaticText(m_AnalyzePage, wxID_ANY, wxEmptyString);
|
|
|
|
|
|
|
|
sSearchField->Add(m_searchField, 0, wxALL, 5);
|
|
|
|
sSearchField->Add(m_numResultsText, 0, wxALIGN_CENTER_VERTICAL, 5);
|
|
|
|
|
|
|
|
wxBoxSizer* sSearchButtons = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
|
|
|
|
m_beginSearch = new wxButton(m_AnalyzePage, wxID_ANY, _("Search"));
|
|
|
|
m_findNext = new wxButton(m_AnalyzePage, wxID_ANY, _("Find next"));
|
|
|
|
m_findPrevious = new wxButton(m_AnalyzePage, wxID_ANY, _("Find previous"));
|
|
|
|
|
2013-05-06 20:18:46 +00:00
|
|
|
ResetSearch();
|
2012-01-21 12:40:14 +00:00
|
|
|
|
|
|
|
sSearchButtons->Add(m_beginSearch, 0, wxALL, 5);
|
|
|
|
sSearchButtons->Add(m_findNext, 0, wxALL, 5);
|
|
|
|
sSearchButtons->Add(m_findPrevious, 0, wxALL, 5);
|
|
|
|
|
|
|
|
sSearchSizer->Add(sSearchField, 0, wxEXPAND, 5);
|
|
|
|
sSearchSizer->Add(sSearchButtons, 0, wxEXPAND, 5);
|
|
|
|
|
|
|
|
sAnalyzePage->Add(sSearchSizer, 0, wxEXPAND, 5);
|
|
|
|
sAnalyzePage->AddStretchSpacer();
|
2012-01-03 01:30:37 +00:00
|
|
|
|
|
|
|
m_AnalyzePage->SetSizer(sAnalyzePage);
|
|
|
|
m_AnalyzePage->Layout();
|
|
|
|
sAnalyzePage->Fit(m_AnalyzePage);
|
|
|
|
m_Notebook->AddPage(m_AnalyzePage, _("Analyze"), false);
|
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
sMain->Add(m_Notebook, 1, wxEXPAND | wxALL, 5);
|
2012-01-03 01:30:37 +00:00
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
wxBoxSizer* sButtons;
|
2011-04-17 21:39:58 +00:00
|
|
|
sButtons = new wxBoxSizer(wxHORIZONTAL);
|
2012-01-03 01:30:37 +00:00
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
wxBoxSizer* sCloseButtonExpander;
|
2011-04-17 21:39:58 +00:00
|
|
|
sCloseButtonExpander = new wxBoxSizer(wxHORIZONTAL);
|
2012-01-03 01:30:37 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
sButtons->Add(sCloseButtonExpander, 1, wxEXPAND, 5);
|
2012-01-03 01:30:37 +00:00
|
|
|
|
2014-03-06 04:02:34 +00:00
|
|
|
m_Close = new wxButton(this, wxID_ANY, _("Close"));
|
2011-04-17 21:39:58 +00:00
|
|
|
sButtons->Add(m_Close, 0, wxALL, 5);
|
2012-01-03 01:30:37 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
sMain->Add(sButtons, 0, wxEXPAND, 5);
|
2012-01-03 01:30:37 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
SetSizer(sMain);
|
2011-03-27 02:55:08 +00:00
|
|
|
Layout();
|
2011-04-17 21:39:58 +00:00
|
|
|
sMain->Fit(this);
|
2012-01-03 01:30:37 +00:00
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
Center(wxBOTH);
|
2012-01-03 01:30:37 +00:00
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
// Connect Events
|
2013-01-13 18:07:45 +00:00
|
|
|
Bind(wxEVT_PAINT, &FifoPlayerDlg::OnPaint, this);
|
2014-05-17 16:49:00 +00:00
|
|
|
m_FrameFromCtrl->Bind(wxEVT_SPINCTRL, &FifoPlayerDlg::OnFrameFrom, this);
|
|
|
|
m_FrameToCtrl->Bind(wxEVT_SPINCTRL, &FifoPlayerDlg::OnFrameTo, this);
|
|
|
|
m_ObjectFromCtrl->Bind(wxEVT_SPINCTRL, &FifoPlayerDlg::OnObjectFrom, this);
|
|
|
|
m_ObjectToCtrl->Bind(wxEVT_SPINCTRL, &FifoPlayerDlg::OnObjectTo, this);
|
|
|
|
m_EarlyMemoryUpdates->Bind(wxEVT_CHECKBOX, &FifoPlayerDlg::OnCheckEarlyMemoryUpdates, this);
|
|
|
|
m_RecordStop->Bind(wxEVT_BUTTON, &FifoPlayerDlg::OnRecordStop, this);
|
|
|
|
m_Save->Bind(wxEVT_BUTTON, &FifoPlayerDlg::OnSaveFile, this);
|
|
|
|
m_FramesToRecordCtrl->Bind(wxEVT_SPINCTRL, &FifoPlayerDlg::OnNumFramesToRecord, this);
|
|
|
|
Bind(wxEVT_BUTTON, &FifoPlayerDlg::OnCloseClick, this);
|
|
|
|
|
|
|
|
m_framesList->Bind(wxEVT_LISTBOX, &FifoPlayerDlg::OnFrameListSelectionChanged, this);
|
|
|
|
m_objectsList->Bind(wxEVT_LISTBOX, &FifoPlayerDlg::OnObjectListSelectionChanged, this);
|
|
|
|
m_objectCmdList->Bind(wxEVT_LISTBOX, &FifoPlayerDlg::OnObjectCmdListSelectionChanged, this);
|
|
|
|
|
|
|
|
m_beginSearch->Bind(wxEVT_BUTTON, &FifoPlayerDlg::OnBeginSearch, this);
|
|
|
|
m_findNext->Bind(wxEVT_BUTTON, &FifoPlayerDlg::OnFindNextClick, this);
|
|
|
|
m_findPrevious->Bind(wxEVT_BUTTON, &FifoPlayerDlg::OnFindPreviousClick, this);
|
|
|
|
|
|
|
|
m_searchField->Bind(wxEVT_TEXT_ENTER, &FifoPlayerDlg::OnBeginSearch, this);
|
|
|
|
m_searchField->Bind(wxEVT_TEXT, &FifoPlayerDlg::OnSearchFieldTextChanged, this);
|
2012-01-21 12:40:14 +00:00
|
|
|
|
2012-10-22 10:25:41 +00:00
|
|
|
// Setup command copying
|
|
|
|
wxAcceleratorEntry entry;
|
|
|
|
entry.Set(wxACCEL_CTRL, (int)'C', wxID_COPY);
|
|
|
|
wxAcceleratorTable accel(1, &entry);
|
|
|
|
m_objectCmdList->SetAcceleratorTable(accel);
|
2014-05-17 16:49:00 +00:00
|
|
|
m_objectCmdList->Bind(wxEVT_MENU, &FifoPlayerDlg::OnObjectCmdListSelectionCopy, this, wxID_COPY);
|
2012-10-22 10:25:41 +00:00
|
|
|
|
2013-01-13 18:07:45 +00:00
|
|
|
Bind(RECORDING_FINISHED_EVENT, &FifoPlayerDlg::OnRecordingFinished, this);
|
|
|
|
Bind(FRAME_WRITTEN_EVENT, &FifoPlayerDlg::OnFrameWritten, this);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
|
|
|
Show();
|
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnPaint(wxPaintEvent& event)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
UpdatePlayGui();
|
|
|
|
UpdateRecorderGui();
|
2012-01-03 01:30:37 +00:00
|
|
|
UpdateAnalyzerGui();
|
2011-03-27 02:55:08 +00:00
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnFrameFrom(wxSpinEvent& event)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
FifoPlayer &player = FifoPlayer::GetInstance();
|
2012-01-03 01:30:37 +00:00
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
player.SetFrameRangeStart(event.GetPosition());
|
|
|
|
|
|
|
|
m_FrameFromCtrl->SetValue(player.GetFrameRangeStart());
|
2012-01-03 01:30:37 +00:00
|
|
|
m_FrameToCtrl->SetValue(player.GetFrameRangeEnd());
|
2011-03-27 02:55:08 +00:00
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnFrameTo(wxSpinEvent& event)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
FifoPlayer &player = FifoPlayer::GetInstance();
|
|
|
|
player.SetFrameRangeEnd(event.GetPosition());
|
|
|
|
|
|
|
|
m_FrameFromCtrl->SetValue(player.GetFrameRangeStart());
|
2013-10-29 05:23:17 +00:00
|
|
|
m_FrameToCtrl->SetValue(player.GetFrameRangeEnd());
|
2011-03-27 02:55:08 +00:00
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnObjectFrom(wxSpinEvent& event)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
FifoPlayer::GetInstance().SetObjectRangeStart(event.GetPosition());
|
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnObjectTo(wxSpinEvent& event)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
FifoPlayer::GetInstance().SetObjectRangeEnd(event.GetPosition());
|
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnCheckEarlyMemoryUpdates(wxCommandEvent& event)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
FifoPlayer::GetInstance().SetEarlyMemoryUpdates(event.IsChecked());
|
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnSaveFile(wxCommandEvent& WXUNUSED(event))
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
2013-04-08 05:16:50 +00:00
|
|
|
// Pointer to the file data that was created as a result of recording.
|
2011-03-27 02:55:08 +00:00
|
|
|
FifoDataFile *file = FifoRecorder::GetInstance().GetRecordedFile();
|
|
|
|
|
|
|
|
if (file)
|
2013-04-08 05:16:50 +00:00
|
|
|
{
|
|
|
|
// Bring up a save file dialog. The location the user chooses will be assigned to this variable.
|
2014-03-29 16:20:46 +00:00
|
|
|
wxString path = wxSaveFileSelector(_("Dolphin FIFO"), "dff", wxEmptyString, this);
|
2011-03-27 02:55:08 +00:00
|
|
|
|
2013-04-08 05:16:50 +00:00
|
|
|
// Has a valid file path
|
2011-03-27 02:55:08 +00:00
|
|
|
if (!path.empty())
|
|
|
|
{
|
2013-04-08 05:16:50 +00:00
|
|
|
// Attempt to save the file to the path the user chose
|
2011-03-27 02:55:08 +00:00
|
|
|
wxBeginBusyCursor();
|
2014-03-12 19:33:41 +00:00
|
|
|
bool result = file->Save(WxStrToStr(path));
|
2011-03-27 02:55:08 +00:00
|
|
|
wxEndBusyCursor();
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2013-04-08 05:16:50 +00:00
|
|
|
// Wasn't able to save the file, shit's whack, yo.
|
2011-03-27 02:55:08 +00:00
|
|
|
if (!result)
|
2014-07-25 01:46:46 +00:00
|
|
|
WxUtils::ShowErrorDialog(_("Error saving file."));
|
2011-03-27 02:55:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnRecordStop(wxCommandEvent& WXUNUSED(event))
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
FifoRecorder& recorder = FifoRecorder::GetInstance();
|
|
|
|
|
2013-04-08 05:16:50 +00:00
|
|
|
// Recorder is still recording
|
2011-03-27 02:55:08 +00:00
|
|
|
if (recorder.IsRecording())
|
|
|
|
{
|
2013-04-08 05:16:50 +00:00
|
|
|
// Then stop recording
|
2011-03-27 02:55:08 +00:00
|
|
|
recorder.StopRecording();
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2013-05-01 13:05:37 +00:00
|
|
|
// and change the button label accordingly.
|
|
|
|
m_RecordStop->SetLabel(_("Record"));
|
2011-03-27 02:55:08 +00:00
|
|
|
}
|
2013-04-08 05:16:50 +00:00
|
|
|
else // Recorder is actually about to start recording
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
2013-04-08 05:16:50 +00:00
|
|
|
// So start recording
|
2011-03-27 02:55:08 +00:00
|
|
|
recorder.StartRecording(m_FramesToRecord, RecordingFinished);
|
2013-04-08 05:16:50 +00:00
|
|
|
|
|
|
|
// and change the button label accordingly.
|
2011-03-27 02:55:08 +00:00
|
|
|
m_RecordStop->SetLabel(_("Stop"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnNumFramesToRecord(wxSpinEvent& event)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
m_FramesToRecord = event.GetPosition();
|
|
|
|
|
|
|
|
// Entering 0 frames in the control indicates infinite frames to record
|
|
|
|
// The fifo recorder takes any value < 0 to be infinite frames
|
|
|
|
if (m_FramesToRecord < 1)
|
|
|
|
m_FramesToRecord = -1;
|
|
|
|
}
|
|
|
|
|
2012-01-21 12:40:14 +00:00
|
|
|
void FifoPlayerDlg::OnBeginSearch(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
wxString str_search_val = m_searchField->GetValue();
|
|
|
|
|
|
|
|
if (m_framesList->GetSelection() == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// TODO: Limited to even str lengths...
|
2014-07-13 18:29:03 +00:00
|
|
|
if (!str_search_val.empty() && str_search_val.length() % 2)
|
2012-01-21 12:40:14 +00:00
|
|
|
{
|
|
|
|
m_numResultsText->SetLabel(_("Invalid search string (only even string lengths supported)"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-13 18:29:03 +00:00
|
|
|
unsigned int const val_length = str_search_val.length() / 2;
|
2013-01-08 20:41:58 +00:00
|
|
|
std::vector<u8> search_val(val_length);
|
2012-01-21 12:40:14 +00:00
|
|
|
for (unsigned int i = 0; i < val_length; ++i)
|
|
|
|
{
|
|
|
|
wxString char_str = str_search_val.Mid(2*i, 2);
|
2013-01-08 20:41:58 +00:00
|
|
|
unsigned long val = 0;
|
2012-01-21 12:40:14 +00:00
|
|
|
if (!char_str.ToULong(&val, 16))
|
|
|
|
{
|
|
|
|
m_numResultsText->SetLabel(_("Invalid search string (couldn't convert to number)"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
search_val[i] = (u8)val;
|
|
|
|
}
|
|
|
|
search_results.clear();
|
|
|
|
|
2013-01-08 20:41:58 +00:00
|
|
|
int const frame_idx = m_framesList->GetSelection();
|
2012-01-21 12:40:14 +00:00
|
|
|
FifoPlayer& player = FifoPlayer::GetInstance();
|
|
|
|
const AnalyzedFrameInfo& frame = player.GetAnalyzedFrameInfo(frame_idx);
|
|
|
|
const FifoFrameInfo& fifo_frame = player.GetFile()->GetFrame(frame_idx);
|
|
|
|
|
|
|
|
// TODO: Support searching through the last object... How do we know were the cmd data ends?
|
|
|
|
// TODO: Support searching for bit patterns
|
|
|
|
int obj_idx = m_objectsList->GetSelection();
|
|
|
|
if (obj_idx == -1)
|
|
|
|
{
|
|
|
|
m_numResultsText->SetLabel(_("Invalid search parameters (no object selected)"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-08 20:41:58 +00:00
|
|
|
const u8* const start_ptr = &fifo_frame.fifoData[frame.objectStarts[obj_idx]];
|
|
|
|
const u8* const end_ptr = &fifo_frame.fifoData[frame.objectStarts[obj_idx+1]];
|
|
|
|
|
|
|
|
for (const u8* ptr = start_ptr; ptr < end_ptr-val_length+1; ++ptr)
|
2012-01-21 12:40:14 +00:00
|
|
|
{
|
2013-01-08 20:41:58 +00:00
|
|
|
if (std::equal(search_val.begin(), search_val.end(), ptr))
|
2012-01-21 12:40:14 +00:00
|
|
|
{
|
|
|
|
SearchResult result;
|
|
|
|
result.frame_idx = frame_idx;
|
|
|
|
|
2013-01-30 05:24:51 +00:00
|
|
|
result.obj_idx = m_objectsList->GetSelection();
|
2012-01-21 12:40:14 +00:00
|
|
|
result.cmd_idx = 0;
|
|
|
|
for (unsigned int cmd_idx = 1; cmd_idx < m_objectCmdOffsets.size(); ++cmd_idx)
|
|
|
|
{
|
|
|
|
if (ptr < start_ptr + m_objectCmdOffsets[cmd_idx])
|
|
|
|
{
|
|
|
|
result.cmd_idx = cmd_idx-1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
search_results.push_back(result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ChangeSearchResult(0);
|
|
|
|
m_beginSearch->Disable();
|
2014-03-29 16:39:54 +00:00
|
|
|
m_numResultsText->SetLabel(wxString::Format(_("Found %u results for \'"), (u32)search_results.size()) + m_searchField->GetValue() + "\'");
|
2012-01-21 12:40:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FifoPlayerDlg::OnSearchFieldTextChanged(wxCommandEvent& event)
|
|
|
|
{
|
2013-05-06 20:18:46 +00:00
|
|
|
ResetSearch();
|
2012-01-21 12:40:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FifoPlayerDlg::OnFindNextClick(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
int cur_cmd_index = m_objectCmdList->GetSelection();
|
|
|
|
if (cur_cmd_index == -1)
|
|
|
|
{
|
|
|
|
ChangeSearchResult(0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-12 15:00:34 +00:00
|
|
|
for (auto it = search_results.begin(); it != search_results.end(); ++it)
|
2012-01-21 12:40:14 +00:00
|
|
|
{
|
|
|
|
if (it->cmd_idx > cur_cmd_index)
|
|
|
|
{
|
|
|
|
ChangeSearchResult(it - search_results.begin());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FifoPlayerDlg::OnFindPreviousClick(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
int cur_cmd_index = m_objectCmdList->GetSelection();
|
|
|
|
if (cur_cmd_index == -1)
|
|
|
|
{
|
|
|
|
ChangeSearchResult(search_results.size() - 1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-12 15:00:34 +00:00
|
|
|
for (auto it = search_results.rbegin(); it != search_results.rend(); ++it)
|
2012-01-21 12:40:14 +00:00
|
|
|
{
|
|
|
|
if (it->cmd_idx < cur_cmd_index)
|
|
|
|
{
|
|
|
|
ChangeSearchResult(search_results.size()-1 - (it - search_results.rbegin()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FifoPlayerDlg::ChangeSearchResult(unsigned int result_idx)
|
|
|
|
{
|
2013-05-06 20:18:46 +00:00
|
|
|
if (result_idx < search_results.size()) // if index is valid
|
2012-01-21 12:40:14 +00:00
|
|
|
{
|
|
|
|
m_search_result_idx = result_idx;
|
|
|
|
int prev_frame = m_framesList->GetSelection();
|
|
|
|
int prev_obj = m_objectsList->GetSelection();
|
|
|
|
int prev_cmd = m_objectCmdList->GetSelection();
|
|
|
|
m_framesList->SetSelection(search_results[result_idx].frame_idx);
|
|
|
|
m_objectsList->SetSelection(search_results[result_idx].obj_idx);
|
|
|
|
m_objectCmdList->SetSelection(search_results[result_idx].cmd_idx);
|
|
|
|
|
2014-05-17 16:49:00 +00:00
|
|
|
wxCommandEvent ev(wxEVT_LISTBOX);
|
2012-01-21 12:40:14 +00:00
|
|
|
if (prev_frame != m_framesList->GetSelection())
|
|
|
|
{
|
|
|
|
ev.SetInt(m_framesList->GetSelection());
|
|
|
|
OnFrameListSelectionChanged(ev);
|
|
|
|
}
|
|
|
|
if (prev_obj != m_objectsList->GetSelection())
|
|
|
|
{
|
|
|
|
ev.SetInt(m_objectsList->GetSelection());
|
|
|
|
OnObjectListSelectionChanged(ev);
|
|
|
|
}
|
|
|
|
if (prev_cmd != m_objectCmdList->GetSelection())
|
|
|
|
{
|
|
|
|
ev.SetInt(m_objectCmdList->GetSelection());
|
|
|
|
OnObjectCmdListSelectionChanged(ev);
|
|
|
|
}
|
2013-05-06 20:18:46 +00:00
|
|
|
|
|
|
|
m_findNext->Enable(result_idx+1 < search_results.size());
|
|
|
|
m_findPrevious->Enable(result_idx != 0);
|
2012-01-21 12:40:14 +00:00
|
|
|
}
|
|
|
|
else if (search_results.size())
|
|
|
|
{
|
|
|
|
ChangeSearchResult(search_results.size() - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-06 20:18:46 +00:00
|
|
|
void FifoPlayerDlg::ResetSearch()
|
|
|
|
{
|
|
|
|
m_beginSearch->Enable(m_searchField->GetLineLength(0) > 0);
|
|
|
|
m_findNext->Disable();
|
|
|
|
m_findPrevious->Disable();
|
|
|
|
|
|
|
|
search_results.clear();
|
|
|
|
}
|
|
|
|
|
2012-01-03 01:30:37 +00:00
|
|
|
void FifoPlayerDlg::OnFrameListSelectionChanged(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
FifoPlayer& player = FifoPlayer::GetInstance();
|
|
|
|
|
|
|
|
m_objectsList->Clear();
|
|
|
|
if (event.GetInt() != -1)
|
|
|
|
{
|
2014-03-29 16:39:54 +00:00
|
|
|
size_t num_objects = player.GetAnalyzedFrameInfo(event.GetInt()).objectStarts.size();
|
|
|
|
for (size_t i = 0; i < num_objects; ++i)
|
|
|
|
m_objectsList->Append(wxString::Format("Object %u", (u32)i));
|
2012-01-03 01:30:37 +00:00
|
|
|
}
|
|
|
|
|
2012-01-21 12:40:14 +00:00
|
|
|
// Update object list
|
2014-05-17 16:49:00 +00:00
|
|
|
wxCommandEvent ev = wxCommandEvent(wxEVT_LISTBOX);
|
2012-01-21 12:40:14 +00:00
|
|
|
ev.SetInt(-1);
|
|
|
|
OnObjectListSelectionChanged(ev);
|
2013-05-06 20:18:46 +00:00
|
|
|
|
|
|
|
ResetSearch();
|
2012-01-03 01:30:37 +00:00
|
|
|
}
|
|
|
|
|
2012-01-05 16:49:46 +00:00
|
|
|
void FifoPlayerDlg::OnObjectListSelectionChanged(wxCommandEvent& event)
|
2012-01-03 01:30:37 +00:00
|
|
|
{
|
|
|
|
FifoPlayer& player = FifoPlayer::GetInstance();
|
|
|
|
|
|
|
|
int frame_idx = m_framesList->GetSelection();
|
|
|
|
int object_idx = event.GetInt();
|
|
|
|
|
|
|
|
m_objectCmdList->Clear();
|
2012-01-05 16:49:46 +00:00
|
|
|
m_objectCmdOffsets.clear();
|
2012-01-03 01:30:37 +00:00
|
|
|
if (frame_idx != -1 && object_idx != -1)
|
|
|
|
{
|
|
|
|
const AnalyzedFrameInfo& frame = player.GetAnalyzedFrameInfo(frame_idx);
|
|
|
|
const FifoFrameInfo& fifo_frame = player.GetFile()->GetFrame(frame_idx);
|
2013-10-29 05:23:17 +00:00
|
|
|
const u8* objectdata_start = &fifo_frame.fifoData[frame.objectStarts[object_idx]];
|
|
|
|
const u8* objectdata_end = &fifo_frame.fifoData[frame.objectEnds[object_idx]];
|
2012-01-03 01:30:37 +00:00
|
|
|
u8* objectdata = (u8*)objectdata_start;
|
|
|
|
const int obj_offset = objectdata_start - &fifo_frame.fifoData[frame.objectStarts[0]];
|
|
|
|
|
|
|
|
int cmd = *objectdata++;
|
|
|
|
int stream_size = Common::swap16(objectdata);
|
|
|
|
objectdata += 2;
|
2014-03-29 16:20:46 +00:00
|
|
|
wxString newLabel = wxString::Format("%08X: %02X %04X ", obj_offset, cmd, stream_size);
|
2013-02-09 11:38:20 +00:00
|
|
|
if (stream_size && ((objectdata_end - objectdata) % stream_size))
|
|
|
|
newLabel += _("NOTE: Stream size doesn't match actual data length\n");
|
|
|
|
|
2012-01-03 01:30:37 +00:00
|
|
|
while (objectdata < objectdata_end)
|
|
|
|
{
|
2014-03-29 16:20:46 +00:00
|
|
|
newLabel += wxString::Format("%02X", *objectdata++);
|
2012-01-03 01:30:37 +00:00
|
|
|
}
|
|
|
|
m_objectCmdList->Append(newLabel);
|
2012-01-05 16:49:46 +00:00
|
|
|
m_objectCmdOffsets.push_back(0);
|
2012-01-03 01:30:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Between objectdata_end and next_objdata_start, there are register setting commands
|
2012-01-21 12:40:14 +00:00
|
|
|
if (object_idx + 1 < (int)frame.objectStarts.size())
|
2012-01-03 01:30:37 +00:00
|
|
|
{
|
2013-10-29 05:23:17 +00:00
|
|
|
const u8* next_objdata_start = &fifo_frame.fifoData[frame.objectStarts[object_idx+1]];
|
2012-01-03 01:30:37 +00:00
|
|
|
while (objectdata < next_objdata_start)
|
|
|
|
{
|
2012-01-05 16:49:46 +00:00
|
|
|
m_objectCmdOffsets.push_back(objectdata - objectdata_start);
|
2012-01-21 12:40:14 +00:00
|
|
|
int new_offset = objectdata - &fifo_frame.fifoData[frame.objectStarts[0]];
|
2013-01-30 05:24:51 +00:00
|
|
|
int command = *objectdata++;
|
|
|
|
switch (command)
|
2012-01-03 01:30:37 +00:00
|
|
|
{
|
|
|
|
case GX_NOP:
|
2014-03-29 16:20:46 +00:00
|
|
|
newLabel = "NOP";
|
2012-01-03 01:30:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x44:
|
2014-03-29 16:20:46 +00:00
|
|
|
newLabel = "0x44";
|
2012-01-03 01:30:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GX_CMD_INVL_VC:
|
2014-03-29 16:20:46 +00:00
|
|
|
newLabel = "GX_CMD_INVL_VC";
|
2012-01-03 01:30:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GX_LOAD_CP_REG:
|
|
|
|
{
|
|
|
|
u32 cmd2 = *objectdata++;
|
|
|
|
u32 value = Common::swap32(objectdata);
|
|
|
|
objectdata += 4;
|
|
|
|
|
2014-03-29 16:20:46 +00:00
|
|
|
newLabel = wxString::Format("CP %02X %08X", cmd2, value);
|
2012-01-03 01:30:37 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GX_LOAD_XF_REG:
|
|
|
|
{
|
|
|
|
u32 cmd2 = Common::swap32(objectdata);
|
|
|
|
objectdata += 4;
|
2012-01-03 21:26:54 +00:00
|
|
|
|
2012-01-03 01:30:37 +00:00
|
|
|
u8 streamSize = ((cmd2 >> 16) & 15) + 1;
|
|
|
|
|
2012-01-03 21:26:54 +00:00
|
|
|
const u8* stream_start = objectdata;
|
|
|
|
const u8* stream_end = stream_start + streamSize * 4;
|
2012-01-03 01:30:37 +00:00
|
|
|
|
2014-03-29 16:20:46 +00:00
|
|
|
newLabel = wxString::Format("XF %08X ", cmd2);
|
2012-01-03 21:26:54 +00:00
|
|
|
while (objectdata < stream_end)
|
|
|
|
{
|
2014-03-29 16:20:46 +00:00
|
|
|
newLabel += wxString::Format("%02X", *objectdata++);
|
|
|
|
|
|
|
|
if (((objectdata - stream_start) % 4) == 0)
|
|
|
|
newLabel += " ";
|
2012-01-03 21:26:54 +00:00
|
|
|
}
|
2012-01-03 01:30:37 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GX_LOAD_INDX_A:
|
|
|
|
case GX_LOAD_INDX_B:
|
|
|
|
case GX_LOAD_INDX_C:
|
|
|
|
case GX_LOAD_INDX_D:
|
|
|
|
objectdata += 4;
|
2014-03-29 16:20:46 +00:00
|
|
|
newLabel = wxString::Format("LOAD INDX %s", (command == GX_LOAD_INDX_A) ? "A" :
|
|
|
|
(command == GX_LOAD_INDX_B) ? "B" :
|
|
|
|
(command == GX_LOAD_INDX_C) ? "C" : "D");
|
2012-01-03 01:30:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GX_CMD_CALL_DL:
|
|
|
|
// The recorder should have expanded display lists into the fifo stream and skipped the call to start them
|
|
|
|
// That is done to make it easier to track where memory is updated
|
|
|
|
_assert_(false);
|
|
|
|
objectdata += 8;
|
2014-03-29 16:20:46 +00:00
|
|
|
newLabel = wxString::Format("CALL DL");
|
2012-01-03 01:30:37 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GX_LOAD_BP_REG:
|
|
|
|
{
|
|
|
|
u32 cmd2 = Common::swap32(objectdata);
|
|
|
|
objectdata += 4;
|
2014-03-29 16:20:46 +00:00
|
|
|
newLabel = wxString::Format("BP %02X %06X", cmd2 >> 24, cmd2 & 0xFFFFFF);
|
2012-01-03 01:30:37 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
newLabel = _("Unexpected 0x80 call? Aborting...");
|
|
|
|
objectdata = (u8*)next_objdata_start;
|
|
|
|
break;
|
|
|
|
}
|
2014-03-29 16:20:46 +00:00
|
|
|
newLabel = wxString::Format("%08X: ", new_offset) + newLabel;
|
2012-01-03 01:30:37 +00:00
|
|
|
m_objectCmdList->Append(newLabel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-01-21 12:40:14 +00:00
|
|
|
// Update command list
|
2014-05-17 16:49:00 +00:00
|
|
|
wxCommandEvent ev = wxCommandEvent(wxEVT_LISTBOX);
|
2012-01-21 12:40:14 +00:00
|
|
|
ev.SetInt(-1);
|
|
|
|
OnObjectCmdListSelectionChanged(ev);
|
2013-05-06 20:18:46 +00:00
|
|
|
|
|
|
|
ResetSearch();
|
2012-01-03 01:30:37 +00:00
|
|
|
}
|
|
|
|
|
2012-01-05 16:49:46 +00:00
|
|
|
void FifoPlayerDlg::OnObjectCmdListSelectionChanged(wxCommandEvent& event)
|
2012-01-03 01:30:37 +00:00
|
|
|
{
|
2012-01-05 16:49:46 +00:00
|
|
|
const int frame_idx = m_framesList->GetSelection();
|
|
|
|
const int object_idx = m_objectsList->GetSelection();
|
2012-01-03 01:30:37 +00:00
|
|
|
|
2012-01-05 16:49:46 +00:00
|
|
|
if (event.GetInt() == -1 || frame_idx == -1 || object_idx == -1)
|
|
|
|
{
|
2012-01-21 12:40:14 +00:00
|
|
|
m_objectCmdInfo->SetLabel(wxEmptyString);
|
2012-01-05 16:49:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
FifoPlayer& player = FifoPlayer::GetInstance();
|
|
|
|
const AnalyzedFrameInfo& frame = player.GetAnalyzedFrameInfo(frame_idx);
|
|
|
|
const FifoFrameInfo& fifo_frame = player.GetFile()->GetFrame(frame_idx);
|
|
|
|
const u8* cmddata = &fifo_frame.fifoData[frame.objectStarts[object_idx]] + m_objectCmdOffsets[event.GetInt()];
|
|
|
|
|
|
|
|
// TODO: Not sure whether we should bother translating the descriptions
|
|
|
|
wxString newLabel;
|
|
|
|
if (*cmddata == GX_LOAD_BP_REG)
|
|
|
|
{
|
2014-05-25 01:55:13 +00:00
|
|
|
std::string name;
|
|
|
|
std::string desc;
|
|
|
|
GetBPRegInfo(cmddata+1, &name, &desc);
|
|
|
|
|
2012-01-05 16:49:46 +00:00
|
|
|
newLabel = _("BP register ");
|
2014-05-25 01:55:13 +00:00
|
|
|
newLabel += (name.empty()) ? wxString::Format(_("UNKNOWN_%02X"), *(cmddata+1)) : StrToWxStr(name);
|
2014-03-29 16:20:46 +00:00
|
|
|
newLabel += ":\n";
|
|
|
|
|
2014-05-25 01:55:13 +00:00
|
|
|
if (desc.empty())
|
2012-01-05 16:49:46 +00:00
|
|
|
newLabel += _("No description available");
|
2014-05-25 01:55:13 +00:00
|
|
|
else
|
|
|
|
newLabel += StrToWxStr(desc);
|
2012-01-05 16:49:46 +00:00
|
|
|
}
|
|
|
|
else if (*cmddata == GX_LOAD_CP_REG)
|
2014-03-29 16:20:46 +00:00
|
|
|
{
|
|
|
|
newLabel = _("CP register ");
|
|
|
|
}
|
2012-01-05 16:49:46 +00:00
|
|
|
else if (*cmddata == GX_LOAD_XF_REG)
|
2014-03-29 16:20:46 +00:00
|
|
|
{
|
|
|
|
newLabel = _("XF register ");
|
|
|
|
}
|
2012-01-05 16:49:46 +00:00
|
|
|
else
|
2014-03-29 16:20:46 +00:00
|
|
|
{
|
2012-01-05 16:49:46 +00:00
|
|
|
newLabel = _("No description available");
|
2014-03-29 16:20:46 +00:00
|
|
|
}
|
2012-01-05 16:49:46 +00:00
|
|
|
|
|
|
|
m_objectCmdInfo->SetLabel(newLabel);
|
|
|
|
Layout();
|
|
|
|
Fit();
|
2012-01-03 01:30:37 +00:00
|
|
|
}
|
|
|
|
|
2012-10-22 10:25:41 +00:00
|
|
|
void FifoPlayerDlg::OnObjectCmdListSelectionCopy(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
if (wxTheClipboard->Open())
|
|
|
|
{
|
|
|
|
wxTheClipboard->SetData(new wxTextDataObject(m_objectCmdList->GetStringSelection()));
|
|
|
|
wxTheClipboard->Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
void FifoPlayerDlg::OnCloseClick(wxCommandEvent& WXUNUSED(event))
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
Hide();
|
|
|
|
}
|
|
|
|
|
2013-01-13 18:07:45 +00:00
|
|
|
void FifoPlayerDlg::OnRecordingFinished(wxEvent&)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
m_RecordStop->SetLabel(_("Record"));
|
|
|
|
m_RecordStop->Enable();
|
|
|
|
|
|
|
|
UpdateRecorderGui();
|
|
|
|
}
|
|
|
|
|
2013-01-13 18:07:45 +00:00
|
|
|
void FifoPlayerDlg::OnFrameWritten(wxEvent&)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
m_CurrentFrameLabel->SetLabel(CreateCurrentFrameLabel());
|
2013-10-29 05:23:17 +00:00
|
|
|
m_NumObjectsLabel->SetLabel(CreateFileObjectCountLabel());
|
2011-03-27 02:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FifoPlayerDlg::UpdatePlayGui()
|
|
|
|
{
|
|
|
|
m_NumFramesLabel->SetLabel(CreateFileFrameCountLabel());
|
|
|
|
m_CurrentFrameLabel->SetLabel(CreateCurrentFrameLabel());
|
|
|
|
m_NumObjectsLabel->SetLabel(CreateFileObjectCountLabel());
|
|
|
|
|
|
|
|
FifoPlayer &player = FifoPlayer::GetInstance();
|
|
|
|
FifoDataFile *file = player.GetFile();
|
|
|
|
u32 frameCount = 0;
|
|
|
|
if (file)
|
|
|
|
frameCount = file->GetFrameCount();
|
|
|
|
|
|
|
|
m_FrameFromCtrl->SetRange(0, frameCount);
|
|
|
|
m_FrameFromCtrl->SetValue(player.GetFrameRangeStart());
|
|
|
|
|
|
|
|
m_FrameToCtrl->SetRange(0, frameCount);
|
|
|
|
m_FrameToCtrl->SetValue(player.GetFrameRangeEnd());
|
|
|
|
|
|
|
|
m_ObjectFromCtrl->SetValue(player.GetObjectRangeStart());
|
|
|
|
m_ObjectToCtrl->SetValue(player.GetObjectRangeEnd());
|
|
|
|
}
|
|
|
|
|
|
|
|
void FifoPlayerDlg::UpdateRecorderGui()
|
|
|
|
{
|
|
|
|
m_RecordingFifoSizeLabel->SetLabel(CreateRecordingFifoSizeLabel());
|
|
|
|
m_RecordingMemSizeLabel->SetLabel(CreateRecordingMemSizeLabel());
|
2013-10-29 05:23:17 +00:00
|
|
|
m_RecordingFramesLabel->SetLabel(CreateRecordingFrameCountLabel());
|
2011-03-27 02:55:08 +00:00
|
|
|
m_Save->Enable(GetSaveButtonEnabled());
|
|
|
|
}
|
|
|
|
|
2012-01-03 01:30:37 +00:00
|
|
|
void FifoPlayerDlg::UpdateAnalyzerGui()
|
|
|
|
{
|
|
|
|
FifoPlayer &player = FifoPlayer::GetInstance();
|
|
|
|
FifoDataFile* file = player.GetFile();
|
|
|
|
|
2014-02-15 03:07:12 +00:00
|
|
|
size_t num_frames = (file) ? player.GetFile()->GetFrameCount() : 0U;
|
|
|
|
if (m_framesList->GetCount() != num_frames)
|
2012-01-03 01:30:37 +00:00
|
|
|
{
|
|
|
|
m_framesList->Clear();
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2014-02-15 03:07:12 +00:00
|
|
|
for (size_t i = 0; i < num_frames; ++i)
|
2012-01-03 01:30:37 +00:00
|
|
|
{
|
2014-03-29 16:39:54 +00:00
|
|
|
m_framesList->Append(wxString::Format("Frame %u", (u32)i));
|
2012-01-03 01:30:37 +00:00
|
|
|
}
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2014-05-17 16:49:00 +00:00
|
|
|
wxCommandEvent ev = wxCommandEvent(wxEVT_LISTBOX);
|
2012-01-21 12:40:14 +00:00
|
|
|
ev.SetInt(-1);
|
|
|
|
OnFrameListSelectionChanged(ev);
|
2012-01-03 01:30:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
wxString FifoPlayerDlg::CreateFileFrameCountLabel() const
|
|
|
|
{
|
|
|
|
FifoDataFile *file = FifoPlayer::GetInstance().GetFile();
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
return CreateIntegerLabel(file->GetFrameCount(), _("Frame"));
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
return _("No file loaded");
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString FifoPlayerDlg::CreateCurrentFrameLabel() const
|
|
|
|
{
|
|
|
|
FifoDataFile *file = FifoPlayer::GetInstance().GetFile();
|
|
|
|
|
|
|
|
if (file)
|
2014-03-29 16:39:54 +00:00
|
|
|
return _("Frame ") + wxString::Format("%u", FifoPlayer::GetInstance().GetCurrentFrameNum());
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString FifoPlayerDlg::CreateFileObjectCountLabel() const
|
|
|
|
{
|
|
|
|
FifoDataFile *file = FifoPlayer::GetInstance().GetFile();
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
return CreateIntegerLabel(FifoPlayer::GetInstance().GetFrameObjectCount(), _("Object"));
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString FifoPlayerDlg::CreateRecordingFifoSizeLabel() const
|
|
|
|
{
|
|
|
|
FifoDataFile *file = FifoRecorder::GetInstance().GetRecordedFile();
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
{
|
2014-02-15 03:07:12 +00:00
|
|
|
size_t fifoBytes = 0;
|
|
|
|
for (size_t i = 0; i < file->GetFrameCount(); ++i)
|
2011-03-27 02:55:08 +00:00
|
|
|
fifoBytes += file->GetFrame(i).fifoDataSize;
|
|
|
|
|
2013-10-29 05:23:17 +00:00
|
|
|
return CreateIntegerLabel(fifoBytes, _("FIFO Byte"));
|
2011-03-27 02:55:08 +00:00
|
|
|
}
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
return _("No recorded file");
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString FifoPlayerDlg::CreateRecordingMemSizeLabel() const
|
|
|
|
{
|
|
|
|
FifoDataFile *file = FifoRecorder::GetInstance().GetRecordedFile();
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
{
|
2014-02-15 03:07:12 +00:00
|
|
|
size_t memBytes = 0;
|
|
|
|
for (size_t frameNum = 0; frameNum < file->GetFrameCount(); ++frameNum)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
2014-08-10 02:44:27 +00:00
|
|
|
const std::vector<MemoryUpdate>& memUpdates = file->GetFrame(frameNum).memoryUpdates;
|
2013-10-29 05:09:01 +00:00
|
|
|
for (auto& memUpdate : memUpdates)
|
|
|
|
memBytes += memUpdate.size;
|
2011-03-27 02:55:08 +00:00
|
|
|
}
|
|
|
|
|
2013-10-29 05:23:17 +00:00
|
|
|
return CreateIntegerLabel(memBytes, _("Memory Byte"));
|
2011-03-27 02:55:08 +00:00
|
|
|
}
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString FifoPlayerDlg::CreateRecordingFrameCountLabel() const
|
|
|
|
{
|
|
|
|
FifoDataFile *file = FifoRecorder::GetInstance().GetRecordedFile();
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
{
|
2014-02-15 03:07:12 +00:00
|
|
|
size_t numFrames = file->GetFrameCount();
|
2011-03-27 02:55:08 +00:00
|
|
|
return CreateIntegerLabel(numFrames, _("Frame"));
|
|
|
|
}
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
|
2014-02-15 03:07:12 +00:00
|
|
|
wxString FifoPlayerDlg::CreateIntegerLabel(size_t size, const wxString& label) const
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
wxString postfix;
|
|
|
|
if (size != 1)
|
|
|
|
postfix = _("s");
|
|
|
|
|
2014-03-29 16:39:54 +00:00
|
|
|
return wxString::Format("%u ", (u32)size) + label + postfix;
|
2011-03-27 02:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool FifoPlayerDlg::GetSaveButtonEnabled() const
|
|
|
|
{
|
2014-03-09 20:14:26 +00:00
|
|
|
return (FifoRecorder::GetInstance().GetRecordedFile() != nullptr);
|
2011-03-27 02:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FifoPlayerDlg::RecordingFinished()
|
|
|
|
{
|
|
|
|
sMutex.lock();
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
if (m_EvtHandler)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
wxCommandEvent event(RECORDING_FINISHED_EVENT);
|
2011-04-17 21:39:58 +00:00
|
|
|
m_EvtHandler->AddPendingEvent(event);
|
2011-03-27 02:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sMutex.unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FifoPlayerDlg::FileLoaded()
|
|
|
|
{
|
|
|
|
sMutex.lock();
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
if (m_EvtHandler)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
wxPaintEvent event;
|
2011-04-17 21:39:58 +00:00
|
|
|
m_EvtHandler->AddPendingEvent(event);
|
2011-03-27 02:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sMutex.unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FifoPlayerDlg::FrameWritten()
|
|
|
|
{
|
|
|
|
sMutex.lock();
|
|
|
|
|
2011-04-17 21:39:58 +00:00
|
|
|
if (m_EvtHandler)
|
2011-03-27 02:55:08 +00:00
|
|
|
{
|
|
|
|
wxCommandEvent event(FRAME_WRITTEN_EVENT);
|
2011-04-17 21:39:58 +00:00
|
|
|
m_EvtHandler->AddPendingEvent(event);
|
2011-03-27 02:55:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sMutex.unlock();
|
2011-04-17 21:39:58 +00:00
|
|
|
}
|