From 2cafa84b754a4844369ba992061879beb1c5eb1c Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sat, 18 Apr 2015 20:18:23 +0300 Subject: [PATCH] Small changes --- rpcs3/Emu/ARMv7/PSVFuncList.h | 2 +- rpcs3/Emu/FS/VFS.cpp | 23 ++++--- rpcs3/Emu/FS/vfsDevice.cpp | 2 +- rpcs3/Emu/Memory/vm_ptr.h | 4 +- rpcs3/Emu/SysCalls/CB_FUNC.h | 7 +- rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp | 24 ++----- rpcs3/Emu/SysCalls/Modules/cellMsgDialog.h | 4 +- rpcs3/Emu/SysCalls/Modules/cellSaveData.h | 4 +- rpcs3/Emu/SysCalls/Modules/cellVdec.cpp | 12 +++- rpcs3/Gui/MsgDialog.cpp | 69 ++++++++++++-------- rpcs3/Gui/MsgDialog.h | 5 +- 11 files changed, 86 insertions(+), 70 deletions(-) diff --git a/rpcs3/Emu/ARMv7/PSVFuncList.h b/rpcs3/Emu/ARMv7/PSVFuncList.h index 811f33675a..170b6690e5 100644 --- a/rpcs3/Emu/ARMv7/PSVFuncList.h +++ b/rpcs3/Emu/ARMv7/PSVFuncList.h @@ -46,7 +46,7 @@ namespace psv_func_detail ARG_STACK, }; - static const auto FIXED_STACK_FRAME_SIZE = 0x100; // described in CB_FUNC.h + static const auto FIXED_STACK_FRAME_SIZE = 0x80; // described in CB_FUNC.h template struct bind_arg; diff --git a/rpcs3/Emu/FS/VFS.cpp b/rpcs3/Emu/FS/VFS.cpp index c228797978..c3fbad4d33 100644 --- a/rpcs3/Emu/FS/VFS.cpp +++ b/rpcs3/Emu/FS/VFS.cpp @@ -136,6 +136,7 @@ void VFS::UnMountAll() vfsFileBase* VFS::OpenFile(const std::string& ps3_path, vfsOpenMode mode) const { std::string path; + if (vfsDevice* dev = GetDevice(ps3_path, path)) { if (vfsFileBase* res = dev->GetNewFileStream()) @@ -167,9 +168,10 @@ vfsDirBase* VFS::OpenDir(const std::string& ps3_path) const bool VFS::CreateFile(const std::string& ps3_path, bool overwrite) const { std::string path; + if (vfsDevice* dev = GetDevice(ps3_path, path)) { - std::shared_ptr res(dev->GetNewFileStream()); + std::unique_ptr res(dev->GetNewFileStream()); if (res) { @@ -183,9 +185,10 @@ bool VFS::CreateFile(const std::string& ps3_path, bool overwrite) const bool VFS::CreateDir(const std::string& ps3_path) const { std::string path; + if (vfsDevice* dev = GetDevice(ps3_path, path)) { - std::shared_ptr res(dev->GetNewDirStream()); + std::unique_ptr res(dev->GetNewDirStream()); if (res) { @@ -199,9 +202,10 @@ bool VFS::CreateDir(const std::string& ps3_path) const bool VFS::RemoveFile(const std::string& ps3_path) const { std::string path; + if (vfsDevice* dev = GetDevice(ps3_path, path)) { - std::shared_ptr res(dev->GetNewFileStream()); + std::unique_ptr res(dev->GetNewFileStream()); if (res) { @@ -215,9 +219,10 @@ bool VFS::RemoveFile(const std::string& ps3_path) const bool VFS::RemoveDir(const std::string& ps3_path) const { std::string path; + if (vfsDevice* dev = GetDevice(ps3_path, path)) { - std::shared_ptr res(dev->GetNewDirStream()); + std::unique_ptr res(dev->GetNewDirStream()); if (res) { @@ -231,9 +236,10 @@ bool VFS::RemoveDir(const std::string& ps3_path) const bool VFS::ExistsFile(const std::string& ps3_path) const { std::string path; + if (vfsDevice* dev = GetDevice(ps3_path, path)) { - std::shared_ptr res(dev->GetNewFileStream()); + std::unique_ptr res(dev->GetNewFileStream()); if (res) { @@ -247,9 +253,10 @@ bool VFS::ExistsFile(const std::string& ps3_path) const bool VFS::ExistsDir(const std::string& ps3_path) const { std::string path; + if (vfsDevice* dev = GetDevice(ps3_path, path)) { - std::shared_ptr res(dev->GetNewDirStream()); + std::unique_ptr res(dev->GetNewDirStream()); if (res) { @@ -268,7 +275,7 @@ bool VFS::RenameFile(const std::string& ps3_path_from, const std::string& ps3_pa { if (vfsDevice* dev_ = GetDevice(ps3_path_to, path_to)) { - std::shared_ptr res(dev->GetNewFileStream()); + std::unique_ptr res(dev->GetNewFileStream()); if (res) { @@ -288,7 +295,7 @@ bool VFS::RenameDir(const std::string& ps3_path_from, const std::string& ps3_pat { if (vfsDevice* dev_ = GetDevice(ps3_path_to, path_to)) { - std::shared_ptr res(dev->GetNewDirStream()); + std::unique_ptr res(dev->GetNewDirStream()); if (res) { diff --git a/rpcs3/Emu/FS/vfsDevice.cpp b/rpcs3/Emu/FS/vfsDevice.cpp index e61fc98d99..1349939987 100644 --- a/rpcs3/Emu/FS/vfsDevice.cpp +++ b/rpcs3/Emu/FS/vfsDevice.cpp @@ -252,4 +252,4 @@ void vfsDevice::Unlock() const bool vfsDevice::TryLock() const { return m_mtx_lock.try_lock(); -} \ No newline at end of file +} diff --git a/rpcs3/Emu/Memory/vm_ptr.h b/rpcs3/Emu/Memory/vm_ptr.h index 0edd41d0c0..d1eef9fe21 100644 --- a/rpcs3/Emu/Memory/vm_ptr.h +++ b/rpcs3/Emu/Memory/vm_ptr.h @@ -1,6 +1,6 @@ #pragma once -class CPUThread; +class PPUThread; struct ARMv7Context; namespace vm @@ -354,7 +354,7 @@ namespace vm public: typedef RT(type)(T...); - RT operator()(CPUThread& CPU, T... args) const; // defined in CB_FUNC.h, call using specified PPU thread context + RT operator()(PPUThread& CPU, T... args) const; // defined in CB_FUNC.h, call using specified PPU thread context RT operator()(ARMv7Context& context, T... args) const; // defined in ARMv7Callback.h, passing context is mandatory diff --git a/rpcs3/Emu/SysCalls/CB_FUNC.h b/rpcs3/Emu/SysCalls/CB_FUNC.h index 13203e43dc..92b8c13847 100644 --- a/rpcs3/Emu/SysCalls/CB_FUNC.h +++ b/rpcs3/Emu/SysCalls/CB_FUNC.h @@ -162,14 +162,13 @@ namespace cb_detail namespace vm { template - __forceinline RT _ptr_base::operator()(CPUThread& CPU, T... args) const + __forceinline RT _ptr_base::operator()(PPUThread& CPU, T... args) const { - auto data = vm::get_ptr>(vm::cast(m_addr)); + const auto data = vm::get_ptr>(vm::cast(m_addr)); const u32 pc = data[0]; const u32 rtoc = data[1]; - assert(CPU.GetType() == CPU_THREAD_PPU); - return cb_detail::_func_caller::call(static_cast(CPU), pc, rtoc, args...); + return cb_detail::_func_caller::call(CPU, pc, rtoc, args...); } template diff --git a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp index 1123f9df6c..cbf57a31aa 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp @@ -109,8 +109,8 @@ s32 cellMsgDialogOpen2(u32 type, vm::ptr msgString, vm::ptrstatus = CELL_MSGDIALOG_BUTTON_NONE; @@ -120,7 +120,7 @@ s32 cellMsgDialogOpen2(u32 type, vm::ptr msgString, vm::ptrCreate(type, msg.c_str()); + g_msg_dialog->Create(type, msg); m_signal = true; }); @@ -266,6 +266,7 @@ s32 cellMsgDialogClose(float delay) } g_msg_dialog->wait_until = get_system_time() + static_cast(std::max(delay, 0.0f) * 1000); + return CELL_OK; } @@ -306,12 +307,7 @@ s32 cellMsgDialogProgressBarSetMsg(u32 progressBarIndex, vm::ptr msg return CELL_MSGDIALOG_ERROR_PARAM; } - std::string text = msgString.get_ptr(); - - CallAfter([text, progressBarIndex]() - { - g_msg_dialog->ProgressBarSetMsg(progressBarIndex, text.c_str()); - }); + g_msg_dialog->ProgressBarSetMsg(progressBarIndex, msgString.get_ptr()); return CELL_OK; } @@ -330,10 +326,7 @@ s32 cellMsgDialogProgressBarReset(u32 progressBarIndex) return CELL_MSGDIALOG_ERROR_PARAM; } - CallAfter([=]() - { - g_msg_dialog->ProgressBarReset(progressBarIndex); - }); + g_msg_dialog->ProgressBarReset(progressBarIndex); return CELL_OK; } @@ -352,10 +345,7 @@ s32 cellMsgDialogProgressBarInc(u32 progressBarIndex, u32 delta) return CELL_MSGDIALOG_ERROR_PARAM; } - CallAfter([=]() - { - g_msg_dialog->ProgressBarInc(progressBarIndex, delta); - }); + g_msg_dialog->ProgressBarInc(progressBarIndex, delta); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.h b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.h index b1b1e8b880..25c1434fcc 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.h +++ b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.h @@ -103,9 +103,9 @@ struct MsgDialogInstance virtual void Close(); - virtual void Create(u32 type, const char* msg) = 0; + virtual void Create(u32 type, std::string msg) = 0; virtual void Destroy() = 0; - virtual void ProgressBarSetMsg(u32 progressBarIndex, const char* msg) = 0; + virtual void ProgressBarSetMsg(u32 progressBarIndex, std::string msg) = 0; virtual void ProgressBarReset(u32 progressBarIndex) = 0; virtual void ProgressBarInc(u32 progressBarIndex, u32 delta) = 0; }; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSaveData.h b/rpcs3/Emu/SysCalls/Modules/cellSaveData.h index cd5174656c..1c9351ca3a 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSaveData.h +++ b/rpcs3/Emu/SysCalls/Modules/cellSaveData.h @@ -183,13 +183,13 @@ struct CellSaveDataDirStat struct CellSaveDataFileStat { be_t fileType; - u8 reserved1[4]; + char reserved1[4]; be_t size; be_t atime; be_t mtime; be_t ctime; char fileName[CELL_SAVEDATA_FILENAME_SIZE]; - u8 reserved2[3]; + char reserved2[3]; }; struct CellSaveDataStatGet diff --git a/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp b/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp index efeb202354..3ce4ae1e11 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellVdec.cpp @@ -719,7 +719,11 @@ s32 cellVdecGetPicture(u32 handle, vm::ptr format, vm:: case CELL_VDEC_PICFMT_RGBA32_ILV: out_f = AV_PIX_FMT_RGBA; alpha_plane.reset(new u8[w * h]); break; case CELL_VDEC_PICFMT_UYVY422_ILV: out_f = AV_PIX_FMT_UYVY422; break; case CELL_VDEC_PICFMT_YUV420_PLANAR: out_f = AV_PIX_FMT_YUV420P; break; - default: cellVdec.Fatal("cellVdecGetPicture: unknown formatType(%d)", type); + + default: + { + cellVdec.Fatal("cellVdecGetPicture: unknown formatType(%d)", type); + } } if (format->colorMatrixType != CELL_VDEC_COLOR_MATRIX_TYPE_BT709) @@ -737,7 +741,11 @@ s32 cellVdecGetPicture(u32 handle, vm::ptr format, vm:: switch (f) { case AV_PIX_FMT_YUV420P: in_f = alpha_plane ? AV_PIX_FMT_YUVA420P : AV_PIX_FMT_YUV420P; break; - default: cellVdec.Fatal("cellVdecGetPicture: unknown pix_fmt(%d)", f); + + default: + { + cellVdec.Fatal("cellVdecGetPicture: unknown pix_fmt(%d)", f); + } } std::unique_ptr sws(sws_getContext(w, h, in_f, w, h, out_f, SWS_POINT, NULL, NULL, NULL), sws_freeContext); diff --git a/rpcs3/Gui/MsgDialog.cpp b/rpcs3/Gui/MsgDialog.cpp index c9d6c3bf05..6a713908d8 100644 --- a/rpcs3/Gui/MsgDialog.cpp +++ b/rpcs3/Gui/MsgDialog.cpp @@ -1,10 +1,11 @@ #include "stdafx_gui.h" +#include "rpcs3.h" #include "Emu/Memory/Memory.h" #include "Emu/SysCalls/lv2/sys_time.h" #include "MsgDialog.h" -void MsgDialogFrame::Create(u32 type, const char* msg) +void MsgDialogFrame::Create(u32 type, std::string msg) { wxWindow* parent = nullptr; // TODO: align the window better @@ -23,7 +24,7 @@ void MsgDialogFrame::Create(u32 type, const char* msg) m_sizer1 = new wxBoxSizer(wxVERTICAL); - m_text = new wxStaticText(m_dialog, wxID_ANY, wxString(msg, wxConvUTF8)); + m_text = new wxStaticText(m_dialog, wxID_ANY, wxString(msg.c_str(), wxConvUTF8)); m_sizer1->Add(m_text, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 16); switch (type & CELL_MSGDIALOG_TYPE_PROGRESSBAR) @@ -46,6 +47,7 @@ void MsgDialogFrame::Create(u32 type, const char* msg) m_sizer1->Add(m_gauge1, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT, 16); m_gauge1->SetValue(0); } + if (m_gauge2) { m_sizer1->Add(m_text2, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 8); @@ -53,15 +55,15 @@ void MsgDialogFrame::Create(u32 type, const char* msg) m_gauge2->SetValue(0); } - wxBoxSizer* buttons = new wxBoxSizer(wxHORIZONTAL); + m_buttons = new wxBoxSizer(wxHORIZONTAL); - switch (type & CELL_MSGDIALOG_TYPE_BUTTON_TYPE) + if (type & CELL_MSGDIALOG_TYPE_BUTTON_TYPE_YESNO) { - case CELL_MSGDIALOG_TYPE_BUTTON_TYPE_YESNO: m_button_yes = new wxButton(m_dialog, wxID_YES); - buttons->Add(m_button_yes, 0, wxALIGN_CENTER_HORIZONTAL | wxRIGHT, 8); + m_buttons->Add(m_button_yes, 0, wxALIGN_CENTER_HORIZONTAL | wxRIGHT, 8); m_button_no = new wxButton(m_dialog, wxID_NO); - buttons->Add(m_button_no, 0, wxALIGN_CENTER_HORIZONTAL, 16); + m_buttons->Add(m_button_no, 0, wxALIGN_CENTER_HORIZONTAL, 16); + if ((type & CELL_MSGDIALOG_TYPE_DEFAULT_CURSOR) == CELL_MSGDIALOG_TYPE_DEFAULT_CURSOR_NO) { m_button_no->SetFocus(); @@ -71,19 +73,20 @@ void MsgDialogFrame::Create(u32 type, const char* msg) m_button_yes->SetFocus(); } - m_sizer1->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 16); - break; + m_sizer1->Add(m_buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 16); + } - case CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK: + if (type & CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK) + { m_button_ok = new wxButton(m_dialog, wxID_OK); - buttons->Add(m_button_ok, 0, wxALIGN_CENTER_HORIZONTAL, 16); + m_buttons->Add(m_button_ok, 0, wxALIGN_CENTER_HORIZONTAL, 16); + if ((type & CELL_MSGDIALOG_TYPE_DEFAULT_CURSOR) == CELL_MSGDIALOG_TYPE_DEFAULT_CURSOR_OK) { m_button_ok->SetFocus(); } - m_sizer1->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 16); - break; + m_sizer1->Add(m_buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 16); } m_sizer1->AddSpacer(16); @@ -100,7 +103,6 @@ void MsgDialogFrame::Create(u32 type, const char* msg) this->Close(); }); - m_dialog->Bind(wxEVT_CLOSE_WINDOW, [&](wxCloseEvent& event) { if (type & CELL_MSGDIALOG_TYPE_DISABLE_CANCEL) @@ -121,31 +123,40 @@ void MsgDialogFrame::Destroy() m_dialog = nullptr; } -void MsgDialogFrame::ProgressBarSetMsg(u32 index, const char* msg) +void MsgDialogFrame::ProgressBarSetMsg(u32 index, std::string msg) { - if (m_dialog) + wxGetApp().CallAfter([=]() { - if (index == 0 && m_text1) m_text1->SetLabelText(wxString(msg, wxConvUTF8)); - if (index == 1 && m_text2) m_text2->SetLabelText(wxString(msg, wxConvUTF8)); - m_dialog->Layout(); - m_dialog->Fit(); - } + if (m_dialog) + { + if (index == 0 && m_text1) m_text1->SetLabelText(wxString(msg.c_str(), wxConvUTF8)); + if (index == 1 && m_text2) m_text2->SetLabelText(wxString(msg.c_str(), wxConvUTF8)); + m_dialog->Layout(); + m_dialog->Fit(); + } + }); } void MsgDialogFrame::ProgressBarReset(u32 index) { - if (m_dialog) + wxGetApp().CallAfter([=]() { - if (index == 0 && m_gauge1) m_gauge1->SetValue(0); - if (index == 1 && m_gauge2) m_gauge2->SetValue(0); - } + if (m_dialog) + { + if (index == 0 && m_gauge1) m_gauge1->SetValue(0); + if (index == 1 && m_gauge2) m_gauge2->SetValue(0); + } + }); } void MsgDialogFrame::ProgressBarInc(u32 index, u32 delta) { - if (m_dialog) + wxGetApp().CallAfter([=]() { - if (index == 0 && m_gauge1) m_gauge1->SetValue(m_gauge1->GetValue() + delta); - if (index == 1 && m_gauge2) m_gauge2->SetValue(m_gauge2->GetValue() + delta); - } + if (m_dialog) + { + if (index == 0 && m_gauge1) m_gauge1->SetValue(m_gauge1->GetValue() + delta); + if (index == 1 && m_gauge2) m_gauge2->SetValue(m_gauge2->GetValue() + delta); + } + }); } diff --git a/rpcs3/Gui/MsgDialog.h b/rpcs3/Gui/MsgDialog.h index bcb282ad95..413e4efe4e 100644 --- a/rpcs3/Gui/MsgDialog.h +++ b/rpcs3/Gui/MsgDialog.h @@ -14,11 +14,12 @@ class MsgDialogFrame : public MsgDialogInstance wxButton* m_button_no; wxStaticText* m_text; wxSizer* m_sizer1; + wxSizer* m_buttons; public: - virtual void Create(u32 type, const char* msg) override; + virtual void Create(u32 type, std::string msg) override; virtual void Destroy() override; - virtual void ProgressBarSetMsg(u32 progressBarIndex, const char* msg) override; + virtual void ProgressBarSetMsg(u32 progressBarIndex, std::string msg) override; virtual void ProgressBarReset(u32 progressBarIndex) override; virtual void ProgressBarInc(u32 progressBarIndex, u32 delta) override; };