From 83a7c837617d0a8c067f19b096e4aef0d66faea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandro=20S=C3=A1nchez=20Bach?= Date: Wed, 19 Feb 2014 05:33:31 +0100 Subject: [PATCH 01/10] Moved some lines and deleted old code * Removed Compiler ELF references from rpcs3.cpp * Reordered the menu bar lines. * Moved the construction of some panels of MainFrame from rpcs3.cpp to MainFrame.cpp --- rpcs3/Gui/MainFrame.cpp | 26 +++++++++++++++----------- rpcs3/Gui/MainFrame.h | 6 +++++- rpcs3/rpcs3.cpp | 9 --------- rpcs3/rpcs3.h | 2 -- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/rpcs3/Gui/MainFrame.cpp b/rpcs3/Gui/MainFrame.cpp index 16d9e2ff00..916f960731 100644 --- a/rpcs3/Gui/MainFrame.cpp +++ b/rpcs3/Gui/MainFrame.cpp @@ -5,7 +5,6 @@ #include "RSXDebugger.h" #include "git-version.h" -#include "Emu/System.h" #include "Ini.h" #include "Emu/GS/sysutil_video.h" #include "Gui/VHDDManager.h" @@ -81,45 +80,50 @@ MainFrame::MainFrame() wxMenuBar& menubar(*new wxMenuBar()); wxMenu& menu_boot(*new wxMenu()); - wxMenu& menu_sys(*new wxMenu()); - wxMenu& menu_conf(*new wxMenu()); - wxMenu& menu_tools(*new wxMenu()); - wxMenu& menu_help(*new wxMenu()); - menubar.Append(&menu_boot, "Boot"); - menubar.Append(&menu_sys, "System"); - menubar.Append(&menu_conf, "Config"); - menubar.Append(&menu_tools, "Tools"); - menubar.Append(&menu_help, "Help"); - menu_boot.Append(id_boot_game, "Boot game"); menu_boot.Append(id_install_pkg, "Install PKG"); menu_boot.AppendSeparator(); menu_boot.Append(id_boot_elf, "Boot (S)ELF"); + wxMenu& menu_sys(*new wxMenu()); + menubar.Append(&menu_sys, "System"); menu_sys.Append(id_sys_pause, "Pause")->Enable(false); menu_sys.Append(id_sys_stop, "Stop\tCtrl + S")->Enable(false); menu_sys.AppendSeparator(); menu_sys.Append(id_sys_send_open_menu, "Send open system menu cmd")->Enable(false); menu_sys.Append(id_sys_send_exit, "Send exit cmd")->Enable(false); + wxMenu& menu_conf(*new wxMenu()); + menubar.Append(&menu_conf, "Config"); menu_conf.Append(id_config_emu, "Settings"); menu_conf.Append(id_config_pad, "PAD Settings"); menu_conf.AppendSeparator(); menu_conf.Append(id_config_vfs_manager, "Virtual File System Manager"); menu_conf.Append(id_config_vhdd_manager, "Virtual HDD Manager"); + wxMenu& menu_tools(*new wxMenu()); + menubar.Append(&menu_tools, "Tools"); menu_tools.Append(id_tools_compiler, "ELF Compiler"); menu_tools.Append(id_tools_memory_viewer, "Memory Viewer"); menu_tools.Append(id_tools_rsx_debugger, "RSX Debugger"); + wxMenu& menu_help(*new wxMenu()); + menubar.Append(&menu_help, "Help"); menu_help.Append(id_help_about, "About..."); SetMenuBar(&menubar); + // Panels m_game_viewer = new GameViewer(this); + m_debugger_frame = new DebuggerPanel(this); + ConLogFrame = new LogFrame(this); + AddPane(m_game_viewer, "Game List", wxAUI_DOCK_BOTTOM); + AddPane(ConLogFrame, "Log", wxAUI_DOCK_BOTTOM); + AddPane(m_debugger_frame, "Debugger", wxAUI_DOCK_RIGHT); + // Events Connect( id_boot_game, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::BootGame) ); Connect( id_install_pkg, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::InstallPkg) ); Connect( id_boot_elf, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::BootElf) ); diff --git a/rpcs3/Gui/MainFrame.h b/rpcs3/Gui/MainFrame.h index ea4e1d0bce..af1cc69419 100644 --- a/rpcs3/Gui/MainFrame.h +++ b/rpcs3/Gui/MainFrame.h @@ -1,9 +1,13 @@ #pragma once -#include "GameViewer.h" + +#include "Gui/Debugger.h" +#include "Gui/GameViewer.h" + #include class MainFrame : public FrameBase { + DebuggerPanel* m_debugger_frame; GameViewer* m_game_viewer; wxAuiManager m_aui_mgr; AppConnector m_app_connector; diff --git a/rpcs3/rpcs3.cpp b/rpcs3/rpcs3.cpp index 87b82ed0ca..d2d015c2cb 100644 --- a/rpcs3/rpcs3.cpp +++ b/rpcs3/rpcs3.cpp @@ -3,7 +3,6 @@ #include "Ini.h" #include "Emu/System.h" #include -#include "Gui/CompilerELF.h" const wxEventType wxEVT_DBG_COMMAND = wxNewEventType(); @@ -22,15 +21,7 @@ bool Rpcs3App::OnInit() SetTopWindow(m_MainFrame); Emu.Init(); - // (new CompilerELF(m_MainFrame))->Show(); - m_debugger_frame = new DebuggerPanel(m_MainFrame); - ConLogFrame = new LogFrame(m_MainFrame); - - m_MainFrame->AddPane(ConLogFrame, "Log", wxAUI_DOCK_BOTTOM); - m_MainFrame->AddPane(m_debugger_frame, "Debugger", wxAUI_DOCK_RIGHT); - //ConLogFrame->Show(); m_MainFrame->Show(); - m_MainFrame->DoSettings(true); return true; diff --git a/rpcs3/rpcs3.h b/rpcs3/rpcs3.h index 019185cce4..7100b182f0 100644 --- a/rpcs3/rpcs3.h +++ b/rpcs3/rpcs3.h @@ -1,7 +1,6 @@ #pragma once #include "Gui/MainFrame.h" -#include "Gui/Debugger.h" template T min(const T a, const T b) { return a < b ? a : b; } template T max(const T a, const T b) { return a > b ? a : b; } @@ -55,7 +54,6 @@ class Rpcs3App : public wxApp { public: MainFrame* m_MainFrame; - DebuggerPanel* m_debugger_frame; virtual bool OnInit(); virtual void Exit(); From 5f9e60c45ff1f4ddcad166ce6aadea264a4f35bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandro=20S=C3=A1nchez=20Bach?= Date: Fri, 21 Feb 2014 02:35:33 +0100 Subject: [PATCH 02/10] PKG Loader rewritten * Rewritten unpkg.c -> Loader/PKG.cpp * MainFrame::InstallPkg now *only* installs the PKG. * Fixed crash when unpacking big debug PKG files. * Debug PKGs are no longer recrypted. * 'About...' dialog updated to remove PKG-related notice. * Unpkg removed. NOTE: The class PKGLoader is using wxWidgets functions to access the files. I think VFS would be better, but the Emulator isn't necessarily running when installing the PKG. In the other hand, initializing VFS with RPCS3 may be somewhat risky... Any alternatives? TODO: Get rid of the decrypted "*.dec" files, and try to decrypt and read contents of the PKG on the fly using the information stored in m_entries. --- rpcs3.sln | 8 - rpcs3/Gui/AboutDialog.h | 2 +- rpcs3/Gui/MainFrame.cpp | 46 +--- rpcs3/Loader/PKG.cpp | 242 ++++++++++++++++++++ rpcs3/Loader/PKG.h | 76 +++++++ rpcs3/rpcs3.vcxproj | 1 + rpcs3/rpcs3.vcxproj.filters | 3 + unpkg/oddkeys.h | 20 -- unpkg/ps3_common.h | 106 --------- unpkg/unpkg.c | 435 ------------------------------------ unpkg/unpkg.h | 180 --------------- 11 files changed, 335 insertions(+), 784 deletions(-) create mode 100644 rpcs3/Loader/PKG.cpp create mode 100644 rpcs3/Loader/PKG.h delete mode 100644 unpkg/oddkeys.h delete mode 100644 unpkg/ps3_common.h delete mode 100644 unpkg/unpkg.c delete mode 100644 unpkg/unpkg.h diff --git a/rpcs3.sln b/rpcs3.sln index 0d54438b39..fd82dacfc1 100644 --- a/rpcs3.sln +++ b/rpcs3.sln @@ -104,14 +104,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scetool", "scetool", "{AB33 scetool\zlib.h = scetool\zlib.h EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "unpkg", "unpkg", "{9F2D2094-BA46-4456-8C45-FD9EC108F1EE}" - ProjectSection(SolutionItems) = preProject - unpkg\oddkeys.h = unpkg\oddkeys.h - unpkg\ps3_common.h = unpkg\ps3_common.h - unpkg\unpkg.c = unpkg\unpkg.c - unpkg\unpkg.h = unpkg\unpkg.h - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ribbon", "wxWidgets\build\msw\wx_vc10_ribbon.vcxproj", "{87B42A9C-3F5C-53D7-9017-2B1CAE39457D}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "stc", "wxWidgets\build\msw\wx_vc10_stc.vcxproj", "{23E1C437-A951-5943-8639-A17F3CF2E606}" diff --git a/rpcs3/Gui/AboutDialog.h b/rpcs3/Gui/AboutDialog.h index 3096f4c85b..1ac1839100 100644 --- a/rpcs3/Gui/AboutDialog.h +++ b/rpcs3/Gui/AboutDialog.h @@ -47,7 +47,7 @@ AboutDialog::AboutDialog(wxWindow *parent) wxBoxSizer* s_panel_credits(new wxBoxSizer(wxHORIZONTAL)); wxStaticText* t_section1 = new wxStaticText(this, wxID_ANY, "\nDevelopers:\n\nDH\nAlexAltea\nHykem\nOil", wxDefaultPosition, wxSize(156,160)); wxStaticText* t_section2 = new wxStaticText(this, wxID_ANY, "\nThanks:\n\nBlackDaemon", wxDefaultPosition, wxSize(156,160)); - wxStaticText* t_section3 = new wxStaticText(this, wxID_ANY, "\nExternal code:\n\n - SELF Decrypter based on scetool (C) 2011-2013 by naehrwert\n - PKG Installer based on ps3pkgtool (C) 2011-2013 by avtolstoy and PKG Finalize (C) by geohot", wxDefaultPosition, wxSize(156,160)); + wxStaticText* t_section3 = new wxStaticText(this, wxID_ANY, "\nExternal code:\n\n - SELF Decrypter based on scetool (C) 2011-2013 by naehrwert", wxDefaultPosition, wxSize(156,160)); s_panel_credits->AddSpacer(12); s_panel_credits->Add(t_section1); diff --git a/rpcs3/Gui/MainFrame.cpp b/rpcs3/Gui/MainFrame.cpp index 916f960731..150c4be1e3 100644 --- a/rpcs3/Gui/MainFrame.cpp +++ b/rpcs3/Gui/MainFrame.cpp @@ -12,7 +12,7 @@ #include "Gui/AboutDialog.h" #include -#include "unpkg/unpkg.c" +#include "Loader/PKG.h" BEGIN_EVENT_TABLE(MainFrame, FrameBase) EVT_CLOSE(MainFrame::OnQuit) @@ -225,43 +225,21 @@ void MainFrame::InstallPkg(wxCommandEvent& WXUNUSED(event)) return; } - ConLog.Write("PKG: extracting..."); - Emu.Stop(); - - wxString fileName = ctrl.GetPath(); - if (!pkg_unpack(static_cast(fileName))) - ConLog.Error("Could not unpack PKG!"); - else ConLog.Success("PKG: extract done."); - - if (!wxRemoveFile(ctrl.GetPath()+".dec")) - ConLog.Warning("Could not delete the decoded DEC file"); - - pkg_header *header; - pkg_info(static_cast(fileName), &header); - - wxString titleID_full (header->title_id); - wxString titleID = titleID_full.SubString(7, 15); - - wxString mainDir = wxGetCwd(); - wxString gamePath = "\\dev_hdd0\\game\\"; - - wxString pkgDir = mainDir + gamePath + titleID; - - // Save the title ID. - Emu.SetTitleID(titleID); - - //Refresh game list - m_game_viewer->Refresh(); - if(Emu.BootGame(pkgDir.ToStdString())) + // Open and install PKG file + std::string filePath = ctrl.GetPath(); + wxFile pkg_f(filePath, wxFile::read); // TODO: Use VFS to install PKG files + + if (pkg_f.IsOpened()) { - ConLog.Success("Game: boot done."); - } - else - { - ConLog.Error("Ps3 executable not found in folder (%s)", pkgDir.wx_str()); + PKGLoader pkg(pkg_f); + pkg.Install("/dev_hdd0/game/"); + pkg.Close(); } + + // Refresh game list + m_game_viewer->Refresh(); } void MainFrame::BootElf(wxCommandEvent& WXUNUSED(event)) diff --git a/rpcs3/Loader/PKG.cpp b/rpcs3/Loader/PKG.cpp new file mode 100644 index 0000000000..fa861df607 --- /dev/null +++ b/rpcs3/Loader/PKG.cpp @@ -0,0 +1,242 @@ +#include "stdafx.h" +#include "PKG.h" +#include "scetool/aes.h" +#include "scetool/sha1.h" + +#include + +PKGLoader::PKGLoader(wxFile& f) : pkg_f(f) +{ +} + +bool PKGLoader::Install(std::string dest, bool show) +{ + // Initial checks + if(!pkg_f.IsOpened()) + return false; + + dest = wxGetCwd() + dest; + if (!dest.empty() && dest.back() != '/') + dest += '/'; + + if(!LoadHeader(show)) + return false; + + std::string titleID = std::string(m_header.title_id).substr(7, 9); + std::string decryptedFile = wxGetCwd() + "/dev_hdd1/" + titleID + ".dec"; + + if (wxDirExists(dest+titleID)) { + ConLog.Error("PKG Loader: Another installation found in: %s", wxString(titleID).wx_str()); + return false; + } + if (!wxMkdir(dest+titleID)) { + ConLog.Error("PKG Loader: Could not make the installation directory: %s", wxString(titleID).wx_str()); + return false; + } + + // Decrypt the PKG file + wxFile out; + out.Create(decryptedFile, true); + Decrypt(out); + out.Close(); + + // Unpack the decrypted file + wxFile dec(decryptedFile, wxFile::read); + LoadEntries(dec); + wxProgressDialog pdlg("PKG Decrypter / Installer", "Please wait, unpacking...", m_entries.size(), 0, wxPD_AUTO_HIDE | wxPD_APP_MODAL); + + for (const PKGEntry& entry : m_entries) + { + UnpackEntry(dec, entry, dest+titleID+'/'); + pdlg.Update(pdlg.GetValue() + 1); + } + pdlg.Update(m_entries.size()); + + // Delete decrypted file + dec.Close(); + wxRemoveFile(decryptedFile); + ConLog.Write("PKG Loader: Package successfully installed in: /dev_hdd0/game/%s", wxString(titleID.c_str()).wx_str()); + return true; +} + +bool PKGLoader::Close() +{ + return pkg_f.Close(); +} + +bool PKGLoader::LoadHeader(bool show) +{ + pkg_f.Seek(0); + if (pkg_f.Read(&m_header, sizeof(PKGHeader)) != sizeof(PKGHeader)) { + ConLog.Error("PKG Loader: Package file is too short!"); + return false; + } + + if (!CheckHeader()) + return false; + + return true; +} + +bool PKGLoader::CheckHeader() +{ + if (m_header.pkg_magic != 0x7F504B47) { + ConLog.Error("PKG Loader: Not a package file!"); + return false; + } + + switch (m_header.pkg_type) + { + case PKG_RELEASE_TYPE_DEBUG: break; + case PKG_RELEASE_TYPE_RELEASE: break; + default: + ConLog.Error("PKG Loader: Unknown PKG type!"); + return false; + } + + switch (m_header.pkg_platform) + { + case PKG_PLATFORM_TYPE_PS3: break; + case PKG_PLATFORM_TYPE_PSP: break; + default: + ConLog.Error("PKG Loader: Unknown PKG type!"); + return false; + } + + if (m_header.header_size != PKG_HEADER_SIZE) { + ConLog.Error("PKG Loader: Wrong header size!"); + return false; + } + + if (m_header.pkg_size != pkg_f.Length()) { + ConLog.Error("PKG Loader: File size mismatch."); + return false; + } + + if (m_header.data_size + m_header.data_offset + 0x60 != pkg_f.Length()) { + ConLog.Error("PKG Loader: Data size mismatch."); + return false; + } + + return true; +} + +bool PKGLoader::LoadEntries(wxFile& dec) +{ + m_entries.resize(m_header.file_count); + + dec.Seek(0); + dec.Read(&m_entries[0], sizeof(PKGEntry) * m_header.file_count); + + if (m_entries[0].name_offset / sizeof(PKGEntry) != m_header.file_count) { + ConLog.Error("PKG Loader: Entries are damaged!"); + return false; + } + + return true; +} + +bool PKGLoader::UnpackEntry(wxFile& dec, const PKGEntry& entry, std::string dir) +{ + u8 buf[BUF_SIZE]; + + dec.Seek(entry.name_offset); + dec.Read(buf, entry.name_size); + buf[entry.name_size] = 0; + + switch (entry.type & (0xffff)) + { + case PKG_FILE_ENTRY_NPDRM: + case PKG_FILE_ENTRY_NPDRMEDAT: + case PKG_FILE_ENTRY_SDAT: + case PKG_FILE_ENTRY_REGULAR: + { + wxFile out; + out.Create(dir + buf); + dec.Seek(entry.file_offset); + + for (u64 size = 0; size < entry.file_size; ) { + size += dec.Read(buf, BUF_SIZE); + if (size > entry.file_size) + out.Write(buf, BUF_SIZE - (size - entry.file_size)); + else + out.Write(buf, BUF_SIZE); + } + out.Close(); + } + break; + + case PKG_FILE_ENTRY_FOLDER: + wxMkdir(dir + buf); + break; + } + return true; +} + +void PKGLoader::Decrypt(wxFile& out) +{ + aes_context c; + u8 iv[HASH_LEN]; + u8 buf[BUF_SIZE]; + u8 ctr[BUF_SIZE]; + + // Debug key + u8 key[0x40]; + memset(key, 0, 0x40); + memcpy(key+0x00, &m_header.qa_digest[0], 8); // &data[0x60] + memcpy(key+0x08, &m_header.qa_digest[0], 8); // &data[0x60] + memcpy(key+0x10, &m_header.qa_digest[8], 8); // &data[0x68] + memcpy(key+0x18, &m_header.qa_digest[8], 8); // &data[0x68] + + pkg_f.Seek(m_header.data_offset); + u32 parts = (m_header.data_size + BUF_SIZE - 1) / BUF_SIZE; + + wxProgressDialog pdlg("PKG Decrypter / Installer", "Please wait, decrypting...", parts, 0, wxPD_AUTO_HIDE | wxPD_APP_MODAL); + + memcpy(iv, m_header.klicensee, sizeof(iv)); + aes_setkey_enc(&c, PKG_AES_KEY, 128); + + for (u32 i=0; i*)&key[0x38] += 1; + } + } + + if (m_header.pkg_type == PKG_RELEASE_TYPE_RELEASE) + { + for (u32 j=0; j hi = *(be_t*)&iv[0]; + be_t lo = *(be_t*)&iv[8] + 1; + + if (lo == 0) + hi += 1; + + *(be_t*)&iv[0] = hi; + *(be_t*)&iv[8] = lo; + } + + for (u32 j=0; j pkg_magic; // Magic (0x7f504b47) + be_t pkg_type; // Release type (Retail:0x8000, Debug:0x0000) + be_t pkg_platform; // Platform type (PS3:0x0001, PSP:0x0002) + be_t header_size; // Header size (0xc0) + be_t unk1; // Some PKG version maybe? + be_t meta_size; // Size of metadata (block after header & hashes) + be_t file_count; // Number of files + be_t pkg_size; // PKG size in bytes + be_t data_offset; // Encrypted data offset + be_t data_size; // Encrypted data size in bytes + char title_id[48]; // Title ID + u8 qa_digest[16]; // This should be the hash of "files + attribs" + u8 klicensee[16]; // Nonce +}; + +struct PKGEntry +{ + be_t name_offset; // File name offset + be_t name_size; // File name size + be_t file_offset; // File offset + be_t file_size; // File size + be_t type; // File type + be_t pad; // Padding (zeros) +}; + +class PKGLoader +{ + wxFile& pkg_f; + PKGHeader m_header; + std::vector m_entries; + + virtual void Decrypt(wxFile& out); + +public: + PKGLoader(wxFile& f); + virtual bool Install(std::string dest, bool show = false); + + virtual bool LoadHeader(bool show = false); + virtual bool CheckHeader(); + + virtual bool LoadEntries(wxFile& dec); + virtual bool UnpackEntry(wxFile& dec, const PKGEntry& entry, std::string dir); + + virtual bool Close(); +}; diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index dd103943cc..e60df54659 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -318,6 +318,7 @@ + diff --git a/rpcs3/rpcs3.vcxproj.filters b/rpcs3/rpcs3.vcxproj.filters index 67d1df150a..691c4365c9 100644 --- a/rpcs3/rpcs3.vcxproj.filters +++ b/rpcs3/rpcs3.vcxproj.filters @@ -406,6 +406,9 @@ Emu\FS + + Loader + diff --git a/unpkg/oddkeys.h b/unpkg/oddkeys.h deleted file mode 100644 index 9c53edab34..0000000000 --- a/unpkg/oddkeys.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include "stdafx.h" - -u8 retail_pkg_aes_key[] = {0x2E,0x7B,0x71,0xD7,0xC9,0xC9,0xA1,0x4E,0xA3,0x22,0x1F,0x18,0x88,0x28,0xB8,0xF8}; - -u8 npdrm_keypair_e[] = { -0xA1,0xC0,0x13,0xAB,0xCE,0x98,0xA7,0xE3,0xDC,0x69,0x92,0x3B,0x07,0xC0,0x28,0x5F, -0x75,0x54,0xC5,0x12,0xB0,0xB0,0xA9,0x6F,0x24,0x52,0x40,0xF2,0xFD,0x43,0x3A,0xF2, -0x3F,0x4E,0xFE,0xC6,0xC1,0x83,0xEA,0x37,0x8D,0x1B,0xEC,0xB0,0x9D,0x88,0xDB,0x32, -0x8F,0x2C,0x86,0x37,0xB7,0xAC,0x72,0x05,0x9B,0x15,0x56,0xB0,0xD9,0x5B,0x5B,0xE0}; - -u8 npdrm_keypair_d[] = { -0x87,0xC7,0x4F,0xFE,0x66,0x93,0x0B,0xAA,0xA1,0x6F,0x86,0x40,0x91,0xC5,0x66,0xFB, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x08,0x28,0xB5,0x8F,0xAC,0xF9,0xDE,0xC8,0xD7,0x0D,0xFE,0xF0,0xF3,0x76,0x63,0xAE, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; - -u8 npdrm_omac_key1[] = {0x72,0xF9,0x90,0x78,0x8F,0x9C,0xFF,0x74,0x57,0x25,0xF0,0x8E,0x4C,0x12,0x83,0x87}; -u8 npdrm_omac_key2[] = {0x6B,0xA5,0x29,0x76,0xEF,0xDA,0x16,0xEF,0x3C,0x33,0x9F,0xB2,0x97,0x1E,0x25,0x6B}; -u8 npdrm_omac_key3[] = {0x9B,0x51,0x5F,0xEA,0xCF,0x75,0x06,0x49,0x81,0xAA,0x60,0x4D,0x91,0xA5,0x4E,0x97}; diff --git a/unpkg/ps3_common.h b/unpkg/ps3_common.h deleted file mode 100644 index 73d8e2185d..0000000000 --- a/unpkg/ps3_common.h +++ /dev/null @@ -1,106 +0,0 @@ -#pragma once -#include "stdafx.h" - -typedef struct { - u32 magic; - u32 debugFlag; - u32 infoOffset; - u32 unknown1; - u32 headSize; - u32 itemCount; - u64 packageSize; - u64 dataOffset; - u64 dataSize; -} pkg_header2; - -u64 get_u64(void* vd) { - u8 *d = (u8*)vd; - return ((u64)d[0]<<56) | ((u64)d[1]<<48) | ((u64)d[2]<<40) | ((u64)d[3]<<32) | (d[4]<<24) | (d[5]<<16) | (d[6]<<8) | d[7]; -} - -void set_u64(void* vd, u64 v) { - u8 *d = (u8*)vd; - d[0] = v>>56; - d[1] = v>>48; - d[2] = v>>40; - d[3] = v>>32; - d[4] = v>>24; - d[5] = v>>16; - d[6] = v>>8; - d[7] = v>>0; -} - -void set_u32(void* vd, u32 v) { - u8 *d = (u8*)vd; - d[0] = v>>24; - d[1] = v>>16; - d[2] = v>>8; - d[3] = v>>0; -} - -void set_u16(void* vd, u16 v) { - u8 *d = (u8*)vd; - d[0] = v>>8; - d[1] = v>>0; -} - -u32 get_u32(void* vd) { - u8 *d = (u8*)vd; - return (d[0]<<24) | (d[1]<<16) | (d[2]<<8) | d[3]; -} - -float get_float(u8* d) { - float ret; - u32 inter = (d[0]<<24) | (d[1]<<16) | (d[2]<<8) | d[3]; - memcpy(&ret, &inter, 4); - return ret; -} - -u32 get_u16(void* vd) { - u8 *d = (u8*)vd; - return (d[0]<<8) | d[1]; -} - -void hexdump(u8* d, int l) { - int i; - for(i=0;i - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#include "unpkg.h" -#include "ps3_common.h" -#include "oddkeys.h" - -#include //in a *.c file ? - -static void hash_tostring(char *str, u8 *hash, u32 len) -{ - u8 *p; - memset(str, 0, 2*len+1); - for (p = hash; p-hash < len; p++) - { - str += 2; - } -} - -static void *pkg_open(const char *fname) -{ - FILE *f; - - f = fopen(fname, "rb"); - if (f == NULL) - { - ConLog.Error ("UnPkg: Could not open package file!"); - return NULL; - } - - return f; -} - -static int pkg_sanity_check(FILE *f, FILE *g, pkg_header **h_ptr, const char *fname) -{ - pkg_header *header = (pkg_header*)malloc(sizeof(pkg_header)); - u64 tmp; - - if (!fread(header, sizeof(pkg_header), 1, f)) - { - ConLog.Error("UnPkg: Package file is too short!"); - return 1; - } - - // some sanity checks - - if (ntohl(header->magic) != PKG_MAGIC) - { - ConLog.Error("UnPkg: Not a package file!"); - return 1; - } - - switch (ntohl(header->rel_type) >> 16 & (0xffff)) - { - case PKG_RELEASE_TYPE_DEBUG: - { - ConLog.Warning ("UnPkg: Debug PKG detected."); - wxProgressDialog pdlg ("PKG Decrypter / Installer", "Please wait, recrypting...", 0, 0, wxPD_AUTO_HIDE | wxPD_APP_MODAL); - - u8* data; - u8 sha_key[0x40]; - int i; - f= fopen(fname, "rb"); - _fseeki64(f, 0, SEEK_END); - int nlen = _ftelli64(f); - _fseeki64(f, 0, SEEK_SET); - data = (u8*)malloc(nlen); - fread(data, 1, nlen, f); - fclose(f); - - pkg_header2 *header = (pkg_header2 *)data; - int data_offset = get_u64(&(header->dataOffset)); - int data_size = get_u64(&(header->dataSize)); - - // decrypt debug - u8 sha_crap[0x40]; - memset(sha_crap, 0, 0x40); - memcpy(sha_crap, &data[0x60], 8); - memcpy(sha_crap+0x8, &data[0x60], 8); - memcpy(sha_crap+0x10, &data[0x68], 8); - memcpy(sha_crap+0x18, &data[0x68], 8); - - int dptr; - for(dptr = data_offset; dptr < (data_offset+data_size); dptr+=0x10) { - u8 hash[0x14]; - sha1(sha_crap, 0x40, hash); - for(i=0;i<0x10;i++) data[dptr+i] ^= hash[i]; - - set_u64(sha_crap+0x38, get_u64(sha_crap+0x38)+1); - } - - // recrypt retail - u8 pkg_key[0x10]; - memcpy(pkg_key, &data[0x70], 0x10); - - //AES_KEY aes_key; - aes_context aes_key; - aes_setkey_enc(&aes_key, retail_pkg_aes_key, 128); - - size_t num=0; u8 ecount_buf[0x10]; memset(ecount_buf, 0, 0x10); - aes_crypt_ctr(&aes_key, data_size, &num, pkg_key, ecount_buf, &data[data_offset], &data[data_offset]); - - // write back - g = fopen(fname, "wb"); - data[4] = 0x80; // set finalize flag - memset(&data[(data_offset+data_size)], 0, 0x60); - - // add hash - sha1(data, nlen-0x20, &data[nlen-0x20]); - - fwrite(data, 1, nlen, g); - //fclose(g); // not close the file for continuing - - _fseeki64(g, 0, SEEK_END); - tmp = _ftelli64(g); - } - break; - - - case PKG_RELEASE_TYPE_RELEASE: - { - ConLog.Warning ("UnPkg: Retail PKG detected."); - _fseeki64(f, 0, SEEK_END); - tmp = _ftelli64(f); - } - break; - - default: - ConLog.Error("UnPkg: Unknown release type."); - return 1; - - - } - switch (ntohl(header->rel_type) & (0xffff)) - { - case PKG_PLATFORM_TYPE_PS3: - case PKG_PLATFORM_TYPE_PSP: - break; - - default: - ConLog.Error("UnPkg: Unknown platform type."); - return 1; - } - - if (ntohl(header->header_size) != PKG_HEADER_SIZE) - { - ConLog.Error("UnPkg: Wrong header size: "); - return 1; - } - - //fseek(g, 0, SEEK_END); - //tmp = ftell(g); - if (ntohll(header->pkg_size) != tmp) - { - ConLog.Error("UnPkg: File size mismatch."); - return 1; - } - - tmp -= ntohll(header->data_offset) + 0x60; - if (ntohll(header->data_size) != tmp) - { - ConLog.Error("UnPkg: Data size mismatch."); - return 1; - } - - if (h_ptr != NULL) - { - (*h_ptr) = (pkg_header*) malloc(sizeof(pkg_header)); - memcpy(h_ptr, &header, sizeof(pkg_header*)); - } - - return 0; -} - -static void print_pkg_header(pkg_header *header) -{ - char qa[33], kl[33]; - - if (header == NULL) - return; - - hash_tostring(qa, header->qa_digest, sizeof(header->qa_digest)); - hash_tostring(kl, header->klicensee, sizeof(header->klicensee)); - - ConLog.Write("Magic: 0x%x", ntohl(header->magic)); - ConLog.Write("Release Type: 0x%x", ntohl(header->rel_type) >> 16 & (0xffff)); - ConLog.Write("Platform Type: 0x%x", ntohl(header->rel_type) & (0xffff)); - ConLog.Write("Header size: 0x%x", ntohl(header->header_size)); - ConLog.Write("Unk1: 0x%x", ntohl(header->unk1)); - ConLog.Write("Metadata size: 0x%x", ntohl(header->meta_size)); - ConLog.Write("File count: %u", ntohl(header->file_count)); - ConLog.Write("Pkg size: %llu", ntohll(header->pkg_size)); - ConLog.Write("Data offset: 0x%llx", ntohll(header->data_offset)); - ConLog.Write("Data size: 0x%llu", ntohll(header->data_size)); - ConLog.Write("TitleID: %s", wxString(header->title_id, 48).wx_str()); - ConLog.Write("QA Digest: %s", wxString(qa, 33).wx_str()); - ConLog.Write("KLicensee: %s", wxString(kl, 33).wx_str()); -} - -static void *pkg_info(const char *fname, pkg_header **h_ptr) -{ - FILE *f; - pkg_header *header; - - f = (FILE*) pkg_open(fname); - if (f == NULL) - return NULL; - - if (pkg_sanity_check(f, NULL, &header, fname)) - return NULL; - - print_pkg_header(header); - - if (h_ptr != NULL) - { - (*h_ptr) = header; - } - else - { - free(header); - } - - - return f; -} - - -static void pkg_crypt(const u8 *key, const u8 *kl, FILE *f, - u64 len, FILE *out) -{ - aes_context c; - u32 parts, bits; - u32 i, j; - u8 iv[HASH_LEN]; - u8 buf[BUF_SIZE]; - u8 ctr[BUF_SIZE]; - u8 out_buf[BUF_SIZE]; - u32 l; - u64 hi, lo; - - int max = len / BUF_SIZE; - wxProgressDialog pdlg("PKG Decrypter / Installer", "Please wait, decrypting...", max, 0, wxPD_AUTO_HIDE | wxPD_APP_MODAL); - - parts = len / BUF_SIZE; - if (len % BUF_SIZE != 0) - parts++; - - memcpy(iv, kl, sizeof(iv)); - aes_setkey_enc(&c, key, 128); - - for (i = 0; iname_offset, SEEK_SET); - - memset(buf, 0, sizeof(buf)); - fread(buf, fentry->name_size, 1, dec); - - switch (fentry->type & (0xffff)) - { - case PKG_FILE_ENTRY_NPDRM: - case PKG_FILE_ENTRY_NPDRMEDAT: - case PKG_FILE_ENTRY_SDAT: - case PKG_FILE_ENTRY_REGULAR: - out = fopen((char *)buf, "wb"); - _fseeki64(dec, fentry->file_offset, SEEK_SET); - for (size = 0; size < fentry->file_size; ) - { - size += fread(buf, sizeof(u8), BUF_SIZE, dec); - if (size > fentry->file_size) - tmp = size - fentry->file_size; - else - tmp = 0; - - fwrite(buf, sizeof(u8), BUF_SIZE - tmp, out); - } - - fclose(out); - break; - - case PKG_FILE_ENTRY_FOLDER: - mkdir ((char *)buf); - break; - } - return true; -} - -static void pkg_unpack_data(u32 file_count, FILE *dec) -{ - int max = file_count; - wxProgressDialog pdlg ("PKG Decrypter / Installer", "Please wait, unpacking...", max, 0, wxPD_AUTO_HIDE | wxPD_APP_MODAL); - - u32 i; - pkg_file_entry *file_table = NULL; - - _fseeki64(dec, 0, SEEK_SET); - - file_table = (pkg_file_entry *)malloc(sizeof(pkg_file_entry)*file_count); - i = fread(file_table, sizeof(pkg_file_entry), file_count, dec); - - if (ntohl(file_table->name_offset) / sizeof(pkg_file_entry) != file_count) - { - ConLog.Error("UnPkg: ERROR. Impossiburu!"); - return; - } - - for (i = 0; iname_offset = ntohl((file_table+i)->name_offset); - (file_table+i)->name_size = ntohl((file_table+i)->name_size); - (file_table+i)->file_offset = ntohll((file_table+i)->file_offset); - (file_table+i)->file_size = ntohll((file_table+i)->file_size); - (file_table+i)->type = ntohl((file_table+i)->type); - - if(pkg_unpack_file(file_table+i, dec)) pdlg.Update(i); - } - - free(file_table); - pdlg.Update(max); -} - -bool pkg_unpack(const char *fname) -{ - FILE *f, *dec; - char *dec_fname; - pkg_header *header; - struct stat sb; - - f = (FILE*) pkg_info(fname, &header); - - if (f == NULL) - return false; - - // Save the main dir. - wxString mainDir = wxGetCwd(); - - // Set the working directory. - wxSetWorkingDirectory(wxGetCwd() + "\\dev_hdd0\\game\\"); - - std::string gamePath = "\\dev_hdd0\\game\\"; - - // Get the PKG title ID from the header and format it (should match TITLE ID from PARAM.SFO). - std::string titleID_full (header->title_id); - std::string titleID = titleID_full.substr(7, 9); - std::string pkgDir = mainDir + gamePath + titleID; - - _fseeki64(f, ntohll(header->data_offset), SEEK_SET); - - dec_fname = (char*)malloc(strlen(fname)+4); - memset(dec_fname, 0, strlen(fname)+4); - sprintf(dec_fname, "%s.dec", fname); - - dec = fopen(dec_fname, "wb+"); - if (dec == NULL) - { - ConLog.Error("UnPkg: Could not create temp file for decrypted data."); - free(header); - return false; - } - unlink(dec_fname); - - pkg_crypt(PKG_AES_KEY, header->klicensee, f, ntohll(header->data_size), - dec); - _fseeki64(dec, 0, SEEK_SET); - - fclose(f); - - if (stat(header->title_id, &sb) != 0) - { - if (mkdir(titleID.c_str()) < 0) - { - ConLog.Error("UnPkg: Could not mkdir."); - ConLog.Error("UnPkg: Possibly, folder already exists in dev_hdd0\\game : %s", wxString(titleID).wx_str()); - wxSetWorkingDirectory(mainDir); - free(header); - return false; - } - } - - chdir(titleID.c_str()); - - pkg_unpack_data(ntohl(header->file_count), dec); - fclose(dec); - - wxSetWorkingDirectory(mainDir); - return true; -} \ No newline at end of file diff --git a/unpkg/unpkg.h b/unpkg/unpkg.h deleted file mode 100644 index fa8262eb0e..0000000000 --- a/unpkg/unpkg.h +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright 2011 Andrey Tolstoy - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - - -#ifndef UNPKG_H_ -#define UNPKG_H_ - -#include "stdafx.h" -#include "scetool/aes.h" -#include "scetool/sha1.h" - -#ifdef __GNUG__ -#include -#endif - -#define ntohll(x) (((u64) ntohl (x) << 32) | (u64) ntohl (x >> 32) ) -#define htonll(x) (((u64) htonl (x) << 32) | (u64) htonl (x >> 32) ) -#define conv_ntohl(x) { x = ntohl(x); } -#define conv_ntohll(x) { x = ntohll(x); } -#define conv_htonl(x) { x = htonl(x); } -#define conv_htonll(x) { x = htonll(x); } - -#define unpack32(x) ((u32) ((u32)*(x) << 24 | \ - (u32)*(x+1) << 16 | \ - (u32)*(x+2) << 8 | \ - (u32)*(x+3) << 0)) - -#define unpack64(x) ((u64)unpack32(x) << 32 | (u64)unpack32(x+4)) - -#define pack32(x, p) \ - { \ - *(x) = (u8)(p >> 24); \ - *((x)+1) = (u8)(p >> 16); \ - *((x)+2) = (u8)(p >> 8); \ - *((x)+3) = (u8)(p >> 0); \ - } - -#define pack64(x, p) { pack32((x + 4), p); pack32((x), p >> 32); } - -#define HASH_LEN 16 -#define BUF_SIZE 4096 - -typedef struct { - u32 magic; // magic 0x7f504b47 - u32 rel_type; // release type - u32 header_size; // 0xc0 - u32 unk1; //some pkg version maybe - u32 meta_size; //size of metadata (block after header & hashes) - u32 file_count; // number of files - u64 pkg_size; // pkg size in bytes - u64 data_offset; // encrypted data offset - u64 data_size; // encrypted data size in bytes - char title_id[48]; // title id - u8 qa_digest[16]; // this should be the hash of "files + attribs" - u8 klicensee[16]; // nonce -} pkg_header; - -typedef struct { - u8 hash1[16]; - u8 hash2[16]; - u8 hash3[16]; - u8 hash4[16]; -} pkg_unk_checksum; - -/* - is it in meta or sfo? - # CATEGORY : HG - # BOOTABLE : YES - # VERSION : 01.00 - # APP_VER : 01.00 - # PS3_SYSTEM_VER : 03.0000 - */ - -/* meta hell structure */ -typedef struct { - u32 unk1; - u32 unk2; - u32 drm_type; - u32 unk3; - - u32 unk4; - u32 unk5; - u32 unk6; - u32 unk7; - - u32 unk8; - u32 unk9; - u32 unk10; - u32 unk11; - - u32 data_size; - u32 unk12; - u32 unk13; - u32 packager; - - u8 unk14[64]; -} pkg_meta; - -typedef struct { - u32 name_offset; // file name offset - u32 name_size; // file name size - u64 file_offset; // file offset - u64 file_size; // file size - u32 type; // file type - /* - 0x80000003 - regular file - 0x80000001 - npdrm - 0x80000004 - folder - 0x80000009 - sdat ? - 0x80000002 - npdrm.edat ? - */ - u32 pad; // padding (zeros) -} pkg_file_entry; - -typedef struct { - pkg_file_entry fe; - char *name; - char *path; -} file_table_tr; - -#define PKG_MAGIC 0x7f504b47 // \x7fPKG -#define PKG_HEADER_SIZE sizeof(pkg_header) + sizeof(pkg_unk_checksum) -#define PKG_RELEASE_TYPE_RELEASE 0x8000 -#define PKG_RELEASE_TYPE_DEBUG 0x0000 -#define PKG_PLATFORM_TYPE_PS3 0x0001 -#define PKG_PLATFORM_TYPE_PSP 0x0002 - -#define PKG_FILE_ENTRY_OVERWRITE 0x80000000 -#define PKG_FILE_ENTRY_NPDRM 0x0001 -#define PKG_FILE_ENTRY_NPDRMEDAT 0x0002 // npdrm.edat -#define PKG_FILE_ENTRY_REGULAR 0x0003 -#define PKG_FILE_ENTRY_FOLDER 0x0004 -#define PKG_FILE_ENTRY_SDAT 0x0009 // .sdat ? - -static const u8 PKG_AES_KEY[16] = { - 0x2e, 0x7b, 0x71, 0xd7, - 0xc9, 0xc9, 0xa1, 0x4e, - 0xa3, 0x22, 0x1f, 0x18, - 0x88, 0x28, 0xb8, 0xf8 -}; - -static void hash_tostring(char *str, u8 *hash, u32 len); - -static void *pkg_open(const char *fname); - -static int pkg_sanity_check(FILE *f, FILE *g, pkg_header **h_ptr, const char *fname); - -static void print_pkg_header(pkg_header *header); - -static void *pkg_info(const char *fname, pkg_header **h_ptr); - -static void pkg_crypt(const u8 *key, const u8 *kl, FILE *f, - u64 len, FILE *out); - -bool pkg_unpack(const char *fname); - -static void pkg_unpack_data(u32 file_count, FILE *dec); - -static bool pkg_unpack_file(pkg_file_entry *fentry, FILE *dec);; - -static int pkg_pack_data(file_table_tr *ftr, pkg_file_entry *table, - int file_count, sha1_context *ctx, FILE *out); - - -static void *pkg_pack_create_filetable(file_table_tr *tr, int file_count, - char **n_table, u32 *n_table_len); - -#endif From 17b877e448b204c44f65291fc0e9e4bd5f1b1147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandro=20S=C3=A1nchez=20Bach?= Date: Fri, 21 Feb 2014 14:21:08 +0100 Subject: [PATCH 03/10] Minor changes in RSXTexture.h and PKG Loader * Moved RSXTexture from RSXThread.h to RSXTexture.h * Renamed RSXTexture::Getmipmap to RSXTexture::GetMipmap * Used more GCM texture format constants in GLGSRender.h * PKG Loader: Added an "Overwrite?" dialog in case the folder dest+titleID (i.e. "/dev_hdd0/game/"+titleID) already exists. Note that in that case, the game won't be installed regardless of the option you choose on the dialog. --- rpcs3/Emu/GS/GL/GLGSRender.h | 8 ++--- rpcs3/Emu/GS/RSXTexture.cpp | 6 ++-- rpcs3/Emu/GS/RSXTexture.h | 62 ++++++++++++++++++++++++++++++++++++ rpcs3/Emu/GS/RSXThread.h | 62 +----------------------------------- rpcs3/Gui/RSXDebugger.cpp | 2 +- rpcs3/Loader/PKG.cpp | 8 ++++- 6 files changed, 78 insertions(+), 70 deletions(-) create mode 100644 rpcs3/Emu/GS/RSXTexture.h diff --git a/rpcs3/Emu/GS/GL/GLGSRender.h b/rpcs3/Emu/GS/GL/GLGSRender.h index b0ea63df71..e3875f665d 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.h +++ b/rpcs3/Emu/GS/GL/GLGSRender.h @@ -175,10 +175,10 @@ public: default: ConLog.Error("Init tex error: Bad tex format (0x%x | %s | 0x%x)", format, is_swizzled ? "swizzled" : "linear", tex.GetFormat() & 0x40); break; } - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, tex.Getmipmap() - 1); - glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, tex.Getmipmap() > 1); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, tex.GetMipmap() - 1); + glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, tex.GetMipmap() > 1); - if(format != 0x81 && format != 0x94) + if(format != CELL_GCM_TEXTURE_B8 && format != CELL_GCM_TEXTURE_X16) { u8 remap_a = tex.GetRemap() & 0x3; u8 remap_r = (tex.GetRemap() >> 2) & 0x3; @@ -245,7 +245,7 @@ public: //Unbind(); - if(is_swizzled && format == 0x85) + if(is_swizzled && format == CELL_GCM_TEXTURE_A8R8G8B8) { free(unswizzledPixels); } diff --git a/rpcs3/Emu/GS/RSXTexture.cpp b/rpcs3/Emu/GS/RSXTexture.cpp index 9ac888c8e9..966e97a0af 100644 --- a/rpcs3/Emu/GS/RSXTexture.cpp +++ b/rpcs3/Emu/GS/RSXTexture.cpp @@ -1,5 +1,5 @@ #include "stdafx.h" -#include "RSXThread.h" +#include "RSXTexture.h" RSXTexture::RSXTexture() { @@ -70,7 +70,7 @@ u8 RSXTexture::GetFormat() const return ((methodRegisters[NV4097_SET_TEXTURE_FORMAT + (m_index*32)] >> 8) & 0xff); } -u16 RSXTexture::Getmipmap() const +u16 RSXTexture::GetMipmap() const { return ((methodRegisters[NV4097_SET_TEXTURE_FORMAT + (m_index*32)] >> 16) & 0xffff); } @@ -199,4 +199,4 @@ void RSXTexture::SetControl3(u16 depth, u32 pitch) { m_depth = depth; m_pitch = pitch; -} \ No newline at end of file +} diff --git a/rpcs3/Emu/GS/RSXTexture.h b/rpcs3/Emu/GS/RSXTexture.h new file mode 100644 index 0000000000..8b87a9d7d9 --- /dev/null +++ b/rpcs3/Emu/GS/RSXTexture.h @@ -0,0 +1,62 @@ +#pragma once + +class RSXTexture +{ + u8 m_index; + +public: + u32 m_pitch; + u16 m_depth; + +public: + RSXTexture(); + RSXTexture(u8 index); + void Init(); + + // Offset + u32 GetOffset() const; + + // Format + u8 GetLocation() const; + bool isCubemap() const; + u8 GetBorderType() const; + u8 GetDimension() const; + u8 GetFormat() const; + u16 GetMipmap() const; + + // Address + u8 GetWrapS() const; + u8 GetWrapT() const; + u8 GetWrapR() const; + u8 GetUnsignedRemap() const; + u8 GetZfunc() const; + u8 GetGamma() const; + u8 GetAnisoBias() const; + u8 GetSignedRemap() const; + + // Control0 + bool IsEnabled() const; + u16 GetMinLOD() const; + u16 GetMaxLOD() const; + u8 GetMaxAniso() const; + bool IsAlphaKillEnabled() const; + + // Control1 + u32 GetRemap() const; + + // Filter + u16 GetBias() const; + u8 GetMinFilter() const; + u8 GetMagFilter() const; + u8 GetConvolutionFilter() const; + bool isASigned() const; + bool isRSigned() const; + bool isGSigned() const; + bool isBSigned() const; + + // Image Rect + u16 GetWidth() const; + u16 GetHeight() const; + + void SetControl3(u16 depth, u32 pitch); +}; diff --git a/rpcs3/Emu/GS/RSXThread.h b/rpcs3/Emu/GS/RSXThread.h index bfe5256ddb..3063520c2e 100644 --- a/rpcs3/Emu/GS/RSXThread.h +++ b/rpcs3/Emu/GS/RSXThread.h @@ -1,5 +1,6 @@ #pragma once #include "GCM.h" +#include "RSXTexture.h" #include "RSXVertexProgram.h" #include "RSXFragmentProgram.h" #include "Emu/SysCalls/Callback.h" @@ -15,67 +16,6 @@ enum Method extern u32 methodRegisters[0xffff]; u32 GetAddress(u32 offset, u8 location); -class RSXTexture -{ - u8 m_index; - -public: - u32 m_pitch; - u16 m_depth; - -public: - RSXTexture(); - RSXTexture(u8 index); - void Init(); - - // Offset - u32 GetOffset() const; - - // Format - u8 GetLocation() const; - bool isCubemap() const; - u8 GetBorderType() const; - u8 GetDimension() const; - u8 GetFormat() const; - u16 Getmipmap() const; - - // Address - u8 GetWrapS() const; - u8 GetWrapT() const; - u8 GetWrapR() const; - u8 GetUnsignedRemap() const; - u8 GetZfunc() const; - u8 GetGamma() const; - u8 GetAnisoBias() const; - u8 GetSignedRemap() const; - - // Control0 - bool IsEnabled() const; - u16 GetMinLOD() const; - u16 GetMaxLOD() const; - u8 GetMaxAniso() const; - bool IsAlphaKillEnabled() const; - - // Control1 - u32 GetRemap() const; - - // Filter - u16 GetBias() const; - u8 GetMinFilter() const; - u8 GetMagFilter() const; - u8 GetConvolutionFilter() const; - bool isASigned() const; - bool isRSigned() const; - bool isGSigned() const; - bool isBSigned() const; - - // Image Rect - u16 GetWidth() const; - u16 GetHeight() const; - - void SetControl3(u16 depth, u32 pitch); -}; - struct RSXVertexData { u32 frequency; diff --git a/rpcs3/Gui/RSXDebugger.cpp b/rpcs3/Gui/RSXDebugger.cpp index e49614c029..a1df62713e 100644 --- a/rpcs3/Gui/RSXDebugger.cpp +++ b/rpcs3/Gui/RSXDebugger.cpp @@ -548,7 +548,7 @@ void RSXDebugger::GetTexture() m_list_texture->SetItem(i, 3, wxString::Format("%dD", render.m_textures[i].GetDimension())); m_list_texture->SetItem(i, 4, render.m_textures[i].IsEnabled() ? "True" : "False"); m_list_texture->SetItem(i, 5, wxString::Format("0x%x", render.m_textures[i].GetFormat())); - m_list_texture->SetItem(i, 6, wxString::Format("0x%x", render.m_textures[i].Getmipmap())); + m_list_texture->SetItem(i, 6, wxString::Format("0x%x", render.m_textures[i].GetMipmap())); m_list_texture->SetItem(i, 7, wxString::Format("0x%x", render.m_textures[i].m_pitch)); m_list_texture->SetItem(i, 8, wxString::Format("%dx%d", render.m_textures[i].GetWidth(), diff --git a/rpcs3/Loader/PKG.cpp b/rpcs3/Loader/PKG.cpp index fa861df607..fba5988eb6 100644 --- a/rpcs3/Loader/PKG.cpp +++ b/rpcs3/Loader/PKG.cpp @@ -12,7 +12,7 @@ PKGLoader::PKGLoader(wxFile& f) : pkg_f(f) bool PKGLoader::Install(std::string dest, bool show) { // Initial checks - if(!pkg_f.IsOpened()) + if (!pkg_f.IsOpened()) return false; dest = wxGetCwd() + dest; @@ -26,6 +26,12 @@ bool PKGLoader::Install(std::string dest, bool show) std::string decryptedFile = wxGetCwd() + "/dev_hdd1/" + titleID + ".dec"; if (wxDirExists(dest+titleID)) { + wxMessageDialog d_overwrite(NULL, "Another installation was found. Do you want to overwrite it?", "PKG Decrypter / Installer", wxYES_NO|wxCENTRE); + if (d_overwrite.ShowModal() != wxID_YES) { + ConLog.Error("PKG Loader: Another installation found in: %s", wxString(titleID).wx_str()); + return false; + } + // TODO: Remove the following two lines and remove the folder dest+titleID ConLog.Error("PKG Loader: Another installation found in: %s", wxString(titleID).wx_str()); return false; } From e7a721a1fbd47452ce289de405ae4a697f0912fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandro=20S=C3=A1nchez=20Bach?= Date: Fri, 21 Feb 2014 17:13:57 +0100 Subject: [PATCH 04/10] Merge pull request #46 from krofna --- Utilities/GNU.h | 1 + rpcs3/CMakeLists.txt | 13 +++++++++++-- rpcs3/Emu/Cell/MFC.h | 8 ++++---- rpcs3/Emu/GS/GL/GLGSRender.cpp | 7 ++++++- rpcs3/Emu/GS/GL/GLProcTable.tbl | 2 +- rpcs3/Emu/GS/GL/OpenGL.cpp | 8 ++++++++ rpcs3/Emu/GS/GL/OpenGL.h | 6 +++++- rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp | 2 +- rpcs3/Emu/System.cpp | 2 +- rpcs3/Gui/CompilerELF.cpp | 4 ++++ rpcs3/Gui/ConLog.cpp | 2 ++ rpcs3/Gui/RSXDebugger.cpp | 10 +++++----- rpcs3/Gui/RSXDebugger.h | 2 +- rpcs3/Ini.cpp | 8 +++++++- rpcs3/rpcs3.cpp | 3 +++ 15 files changed, 60 insertions(+), 18 deletions(-) diff --git a/Utilities/GNU.h b/Utilities/GNU.h index 4995297187..f3678958d8 100644 --- a/Utilities/GNU.h +++ b/Utilities/GNU.h @@ -10,4 +10,5 @@ #define Sleep(x) usleep(x * 1000) #define mkdir(x) mkdir(x, 0777) #define INFINITE 0xFFFFFFFF +#define _CRT_ALIGN(x) __attribute__((aligned(x))) #endif diff --git a/rpcs3/CMakeLists.txt b/rpcs3/CMakeLists.txt index 8412a2d5a9..e9e5502f41 100644 --- a/rpcs3/CMakeLists.txt +++ b/rpcs3/CMakeLists.txt @@ -11,7 +11,12 @@ if (CMAKE_COMPILER_IS_GNUCXX) add_definitions(-fpermissive) # TODO: remove me endif() -find_package(wxWidgets) +add_definitions(-DGL_GLEXT_PROTOTYPES) +add_definitions(-DGLX_GLXEXT_PROTOTYPES) + +find_package(wxWidgets COMPONENTS core base net aui gl REQUIRED) +find_package(OpenGL REQUIRED) +find_package(ZLIB REQUIRED) include("${wxWidgets_USE_FILE}") @@ -27,11 +32,15 @@ ${CMAKE_SOURCE_DIR}/.. file( GLOB_RECURSE RPCS3_SRC +${CMAKE_SOURCE_DIR}/rpcs3.cpp +${CMAKE_SOURCE_DIR}/AppConnector.cpp +${CMAKE_SOURCE_DIR}/Ini.cpp ${CMAKE_SOURCE_DIR}/Emu/* ${CMAKE_SOURCE_DIR}/Gui/* ${CMAKE_SOURCE_DIR}/Loader/* ${CMAKE_SOURCE_DIR}/../Utilities/* +${CMAKE_SOURCE_DIR}/../scetool/scetool.cpp ) add_executable(rpcs3 ${RPCS3_SRC}) -target_link_libraries(rpcs3 ${wxWidgets_LIBRARIES}) +target_link_libraries(rpcs3 ${wxWidgets_LIBRARIES} ${OPENGL_LIBRARIES} ${ZLIB_LIBRARIES}) diff --git a/rpcs3/Emu/Cell/MFC.h b/rpcs3/Emu/Cell/MFC.h index 5ddf7a073a..ca8235c05a 100644 --- a/rpcs3/Emu/Cell/MFC.h +++ b/rpcs3/Emu/Cell/MFC.h @@ -158,7 +158,7 @@ struct DMAC u32 queue_pos; u32 proxy_pos; long queue_lock; - long proxy_lock; + volatile std::atomic proxy_lock; bool ProcessCmd(u32 cmd, u32 tag, u32 lsa, u64 ea, u32 size) { @@ -193,7 +193,7 @@ struct DMAC return MFC_PPU_DMA_QUEUE_FULL; } - /* while (_InterlockedExchange(&proxy_lock, 1)); + /* while (std::atomic_exchange(&proxy_lock, 1)); _mm_lfence(); DMAC_Proxy& p = proxy[proxy_pos]; p.cmd = cmd; @@ -212,7 +212,7 @@ struct DMAC void ClearCmd() { - while (_InterlockedExchange(&proxy_lock, 1)); + while (std::atomic_exchange(&proxy_lock, 1)); _mm_lfence(); memcpy(proxy, proxy + 1, --proxy_pos * sizeof(DMAC_Proxy)); _mm_sfence(); @@ -298,4 +298,4 @@ struct MFC MFC_QStatus.SetValue(mask); } } -}; \ No newline at end of file +}; diff --git a/rpcs3/Emu/GS/GL/GLGSRender.cpp b/rpcs3/Emu/GS/GL/GLGSRender.cpp index 98cb204231..386921abdf 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.cpp +++ b/rpcs3/Emu/GS/GL/GLGSRender.cpp @@ -652,7 +652,12 @@ void GLGSRender::OnInitThread() glEnable(GL_TEXTURE_2D); glEnable(GL_SCISSOR_TEST); +#ifdef _WIN32 glSwapInterval(Ini.GSVSyncEnable.GetValue() ? 1 : 0); +#else + if (GLXDrawable drawable = glXGetCurrentDrawable()) + glXSwapIntervalEXT(glXGetCurrentDisplay(), drawable, Ini.GSVSyncEnable.GetValue() ? 1 : 0); +#endif } void GLGSRender::OnExitThread() @@ -961,7 +966,7 @@ void GLGSRender::ExecCMD() if(m_set_depth_bounds) { //ConLog.Warning("glDepthBounds(%f, %f)", m_depth_bounds_min, m_depth_bounds_max); - glDepthBounds(m_depth_bounds_min, m_depth_bounds_max); + glDepthBoundsEXT(m_depth_bounds_min, m_depth_bounds_max); checkForGlError("glDepthBounds"); } diff --git a/rpcs3/Emu/GS/GL/GLProcTable.tbl b/rpcs3/Emu/GS/GL/GLProcTable.tbl index 265eda6154..fb6acb64c7 100644 --- a/rpcs3/Emu/GS/GL/GLProcTable.tbl +++ b/rpcs3/Emu/GS/GL/GLProcTable.tbl @@ -78,7 +78,7 @@ OPENGL_PROC(PFNGLPROGRAMUNIFORM1FPROC, ProgramUniform1f); OPENGL_PROC(PFNGLPROGRAMUNIFORM4FPROC, ProgramUniform4f); OPENGL_PROC(PFNGLUNIFORMMATRIX4FVPROC, UniformMatrix4fv); OPENGL_PROC(PFNGLUSEPROGRAMPROC, UseProgram); -OPENGL_PROC2(PFNGLDEPTHBOUNDSEXTPROC, DepthBounds, glDepthBoundsEXT); +OPENGL_PROC2(PFNGLDEPTHBOUNDSEXTPROC, DepthBoundsEXT, glDepthBoundsEXT); OPENGL_PROC(PFNGLSTENCILOPSEPARATEPROC, StencilOpSeparate); OPENGL_PROC(PFNGLSTENCILFUNCSEPARATEPROC, StencilFuncSeparate); OPENGL_PROC(PFNGLSTENCILMASKSEPARATEPROC, StencilMaskSeparate); diff --git a/rpcs3/Emu/GS/GL/OpenGL.cpp b/rpcs3/Emu/GS/GL/OpenGL.cpp index f113c447de..8de1efdd79 100644 --- a/rpcs3/Emu/GS/GL/OpenGL.cpp +++ b/rpcs3/Emu/GS/GL/OpenGL.cpp @@ -3,18 +3,22 @@ void InitProcTable() { +#ifdef _WIN32 #define OPENGL_PROC(p, n) OPENGL_PROC2(p, n, gl##n) #define OPENGL_PROC2(p, n, tn) /*if(!gl##n)*/ if(!(gl##n = (p)wglGetProcAddress(#tn))) ConLog.Error("OpenGL: initialization of " #tn " failed.") #include "GLProcTable.tbl" #undef OPENGL_PROC #undef OPENGL_PROC2 +#endif } +#ifdef _WIN32 #define OPENGL_PROC(p, n) p gl##n = nullptr #define OPENGL_PROC2(p, n, tn) OPENGL_PROC(p, n) #include "GLProcTable.tbl" #undef OPENGL_PROC #undef OPENGL_PROC2 +#endif OpenGL::OpenGL() { @@ -29,18 +33,22 @@ OpenGL::~OpenGL() void OpenGL::Init() { +#ifdef _WIN32 #define OPENGL_PROC(p, n) OPENGL_PROC2(p, n, gl##n) #define OPENGL_PROC2(p, n, tn) if(!(n = (p)wglGetProcAddress(#tn))) ConLog.Error("OpenGL: initialization of " #tn " failed.") #include "GLProcTable.tbl" #undef OPENGL_PROC #undef OPENGL_PROC2 +#endif } void OpenGL::Close() { +#ifdef _WIN32 #define OPENGL_PROC(p, n) n = nullptr #define OPENGL_PROC2(p, n, tn) OPENGL_PROC(p, n) #include "GLProcTable.tbl" #undef OPENGL_PROC #undef OPENGL_PROC2 +#endif } diff --git a/rpcs3/Emu/GS/GL/OpenGL.h b/rpcs3/Emu/GS/GL/OpenGL.h index 67cfe0c6c5..4089f466e1 100644 --- a/rpcs3/Emu/GS/GL/OpenGL.h +++ b/rpcs3/Emu/GS/GL/OpenGL.h @@ -4,7 +4,6 @@ #ifdef _WIN32 typedef BOOL (WINAPI* PFNWGLSWAPINTERVALEXTPROC) (int interval); -#endif #define OPENGL_PROC(p, n) extern p gl##n #define OPENGL_PROC2(p, n, tn) OPENGL_PROC(p, n) @@ -12,6 +11,11 @@ typedef BOOL (WINAPI* PFNWGLSWAPINTERVALEXTPROC) (int interval); #undef OPENGL_PROC #undef OPENGL_PROC2 +#else +#include +#include +#endif + void InitProcTable(); struct OpenGL diff --git a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp index 71bf06d477..35b1f8ab79 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp @@ -44,7 +44,7 @@ int cellPngDecOpen(u32 mainHandle, mem32_t subHandle, mem_ptr_t s // Get size of file MemoryAllocator sb; // Alloc a CellFsStat struct - ret = cellFsFstat(current_subHandle->fd, sb); + ret = cellFsFstat(current_subHandle->fd, sb.GetAddr()); if(ret != CELL_OK) return ret; current_subHandle->fileSize = sb->st_size; // Get CellFsStat.st_size break; diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 5846edec19..bff251bd08 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -190,7 +190,7 @@ void Emulator::Load() if(IsSelf(m_path.ToStdString())) { - std::string self_path = m_path; + std::string self_path = m_path.mb_str(); std::string elf_path = wxFileName(m_path).GetPath().c_str(); if(wxFileName(m_path).GetFullName().CmpNoCase("EBOOT.BIN") == 0) diff --git a/rpcs3/Gui/CompilerELF.cpp b/rpcs3/Gui/CompilerELF.cpp index d455da5390..9ef926ba6b 100644 --- a/rpcs3/Gui/CompilerELF.cpp +++ b/rpcs3/Gui/CompilerELF.cpp @@ -127,8 +127,10 @@ CompilerELF::CompilerELF(wxWindow* parent) " b exit, 0, 0\n" ); +#ifdef _WIN32 ::SendMessage((HWND)hex_list->GetHWND(), WM_VSCROLL, SB_BOTTOM, 0); ::SendMessage((HWND)asm_list->GetHWND(), WM_VSCROLL, SB_BOTTOM, 0); +#endif } CompilerELF::~CompilerELF() @@ -318,6 +320,7 @@ void CompilerELF::OnScroll(wxScrollWinEvent& event) dst = hex_list; } +#ifdef _WIN32 if(!m_disable_scroll && src && dst && event.GetOrientation() == wxVERTICAL) { s64 kind = -1; @@ -364,6 +367,7 @@ void CompilerELF::OnScroll(wxScrollWinEvent& event) m_disable_scroll = false; } } +#endif event.Skip(); } diff --git a/rpcs3/Gui/ConLog.cpp b/rpcs3/Gui/ConLog.cpp index ca658c0813..33a324dd9e 100644 --- a/rpcs3/Gui/ConLog.cpp +++ b/rpcs3/Gui/ConLog.cpp @@ -268,7 +268,9 @@ void LogFrame::Task() m_log.SetColumnWidth(0, -1); // crashes on exit m_log.SetColumnWidth(1, -1); +#ifdef _WIN32 ::SendMessage((HWND)m_log.GetHWND(), WM_VSCROLL, SB_BOTTOM, 0); +#endif } LogBuffer.Flush(); diff --git a/rpcs3/Gui/RSXDebugger.cpp b/rpcs3/Gui/RSXDebugger.cpp index a1df62713e..207f8c237c 100644 --- a/rpcs3/Gui/RSXDebugger.cpp +++ b/rpcs3/Gui/RSXDebugger.cpp @@ -571,7 +571,7 @@ void RSXDebugger::GetSettings() LIST_SETTINGS_ADD("Alpha func", !(render.m_set_alpha_func) ? "(none)" : wxString::Format("0x%x (%s)", render.m_alpha_func, - ParseGCMEnum(render.m_alpha_func, CELL_GCM_ENUM).wx_str())); + ParseGCMEnum(render.m_alpha_func, CELL_GCM_ENUM))); LIST_SETTINGS_ADD("Blend color", !(render.m_set_blend_color) ? "(none)" : wxString::Format("R:%d, G:%d, B:%d, A:%d", render.m_blend_color_r, render.m_blend_color_g, @@ -591,10 +591,10 @@ void RSXDebugger::GetSettings() LIST_SETTINGS_ADD("Depth bounds", wxString::Format("Min:%f, Max:%f", render.m_depth_bounds_min, render.m_depth_bounds_max)); LIST_SETTINGS_ADD("Depth func", !(render.m_set_depth_func) ? "(none)" : wxString::Format("0x%x (%s)", render.m_depth_func, - ParseGCMEnum(render.m_depth_func, CELL_GCM_ENUM).wx_str())); + ParseGCMEnum(render.m_depth_func, CELL_GCM_ENUM))); LIST_SETTINGS_ADD("Draw mode", wxString::Format("%d (%s)", render.m_draw_mode, - ParseGCMEnum(render.m_draw_mode, CELL_GCM_PRIMITIVE_ENUM).wx_str())); + ParseGCMEnum(render.m_draw_mode, CELL_GCM_PRIMITIVE_ENUM))); LIST_SETTINGS_ADD("Scissor", wxString::Format("X:%d, Y:%d, W:%d, H:%d", render.m_scissor_x, render.m_scissor_y, @@ -602,7 +602,7 @@ void RSXDebugger::GetSettings() render.m_scissor_h)); LIST_SETTINGS_ADD("Stencil func", !(render.m_set_stencil_func) ? "(none)" : wxString::Format("0x%x (%s)", render.m_stencil_func, - ParseGCMEnum(render.m_stencil_func, CELL_GCM_ENUM).wx_str())); + ParseGCMEnum(render.m_stencil_func, CELL_GCM_ENUM))); LIST_SETTINGS_ADD("Surface Pitch A", wxString::Format("0x%x", render.m_surface_pitch_a)); LIST_SETTINGS_ADD("Surface Pitch B", wxString::Format("0x%x", render.m_surface_pitch_b)); LIST_SETTINGS_ADD("Surface Pitch C", wxString::Format("0x%x", render.m_surface_pitch_c)); @@ -692,7 +692,7 @@ void RSXDebugger::OnSelectTexture(wxListEvent& event) UpdateInformation(); } -wxString RSXDebugger::ParseGCMEnum(u32 value, u32 type) +const char* RSXDebugger::ParseGCMEnum(u32 value, u32 type) { switch(type) { diff --git a/rpcs3/Gui/RSXDebugger.h b/rpcs3/Gui/RSXDebugger.h index 8877016974..872735b4db 100644 --- a/rpcs3/Gui/RSXDebugger.h +++ b/rpcs3/Gui/RSXDebugger.h @@ -79,7 +79,7 @@ public: virtual void SetPrograms(wxListEvent& event); virtual void OnSelectTexture(wxListEvent& event); - wxString ParseGCMEnum(u32 value, u32 type); + const char* ParseGCMEnum(u32 value, u32 type); wxString DisAsmCommand(u32 cmd, u32 count, u32 currentAddr, u32 ioAddr); diff --git a/rpcs3/Ini.cpp b/rpcs3/Ini.cpp index 96240a09d4..292f8d0f13 100644 --- a/rpcs3/Ini.cpp +++ b/rpcs3/Ini.cpp @@ -1,7 +1,9 @@ #include "stdafx.h" #include "Ini.h" +#ifdef _WIN32 #include +#endif Inis Ini; @@ -148,9 +150,13 @@ static wxString WindowInfoToString(const WindowInfo wind) //Ini Ini::Ini() { +#ifdef _WIN32 m_Config = new wxIniConfig( wxEmptyString, wxEmptyString, wxGetCwd() + "\\rpcs3.ini", wxEmptyString, wxCONFIG_USE_LOCAL_FILE ); +#else + m_Config = new wxConfig("rpcs3"); +#endif } void Ini::Save(wxString key, int value) @@ -211,4 +217,4 @@ wxString Ini::Load(wxString key, const wxString& def_value) WindowInfo Ini::Load(wxString key, const WindowInfo& def_value) { return StringToWindowInfo(m_Config->Read(key, WindowInfoToString(def_value))); -} \ No newline at end of file +} diff --git a/rpcs3/rpcs3.cpp b/rpcs3/rpcs3.cpp index d2d015c2cb..3ecc343150 100644 --- a/rpcs3/rpcs3.cpp +++ b/rpcs3/rpcs3.cpp @@ -2,7 +2,10 @@ #include "rpcs3.h" #include "Ini.h" #include "Emu/System.h" + +#ifdef _WIN32 #include +#endif const wxEventType wxEVT_DBG_COMMAND = wxNewEventType(); From 9a30ce5f18a26886d272059a2f2cb0a02365ef70 Mon Sep 17 00:00:00 2001 From: Bigpet Date: Sun, 23 Feb 2014 17:52:52 +0100 Subject: [PATCH 05/10] Make buildable with GCC in Linux * replace GetThreadID with std::this_thread.getId() * name all anonymous structs and unions that contain non-trivially constructable objects * made default constructor for big endian type noexcept to make it work with std::atomic * move instantiated specialized template function members ouside of the class definition to comply with the standard * added default instantiation for template parameter "=nullptr" * used the C++11 standardized thread_local instead of the __declspec(thread) * added transitional definitions to bridge the microsoft specific calls (compare and exchange and aligned alloc) * removed cyclic dependency between Emulator->CPUThreadManager->CPUThread->SMutex->Emulator->... * fixed some instances of indentation by space instead of tabs * surrounded some unused code with an #if 0 block to make sure it doesn't compile --- Utilities/BEType.h | 4 +--- Utilities/GNU.h | 9 +++++-- Utilities/IdManager.h | 4 ++-- Utilities/MTProgressDialog.h | 2 +- Utilities/SMutex.cpp | 6 ++--- Utilities/SMutex.h | 8 +++---- Utilities/Thread.cpp | 6 ++--- Utilities/Thread.h | 2 +- rpcs3/CMakeLists.txt | 13 +++++----- rpcs3/Emu/CPU/CPUThread.h | 2 +- rpcs3/Emu/CPU/CPUThreadManager.h | 5 ++-- rpcs3/Emu/Cell/PPCThreadManager.cpp | 4 +++- rpcs3/Emu/Cell/PPCThreadManager.h | 8 +++---- rpcs3/Emu/Cell/PPUInterpreter.h | 4 ++-- rpcs3/Emu/Cell/PPUThread.h | 9 +++---- rpcs3/Emu/FS/vfsLocalDir.cpp | 3 +-- rpcs3/Emu/GS/GL/GLGSRender.cpp | 9 ++++--- rpcs3/Emu/GS/GSManager.cpp | 4 ++-- rpcs3/Emu/GS/GSRender.cpp | 2 +- rpcs3/Emu/GS/sysutil_video.h | 2 +- rpcs3/Emu/HDD/HDD.h | 6 ++--- rpcs3/Emu/Memory/Memory.h | 9 +++---- rpcs3/Emu/SysCalls/Modules/cellDmux.h | 20 ++++++++-------- rpcs3/Emu/SysCalls/Modules/cellGame.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/cellResc.cpp | 8 +++---- rpcs3/Emu/SysCalls/Modules/cellSync.cpp | 28 ++++++++++------------ rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/sceNp.cpp | 6 ++++- rpcs3/Emu/SysCalls/Modules/sys_fs.cpp | 4 ++-- rpcs3/Emu/SysCalls/SC_FUNC.h | 1 + rpcs3/Emu/SysCalls/SysCalls.cpp | 9 ++++++- rpcs3/Emu/SysCalls/SysCalls.h | 27 +++++++++++---------- rpcs3/Emu/SysCalls/lv2/SC_Event.cpp | 2 +- rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp | 24 +++++++++---------- rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp | 18 +++++++------- rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.h | 13 ++++------ rpcs3/Emu/SysCalls/lv2/SC_sys_spu.cpp | 2 ++ rpcs3/Emu/System.cpp | 6 ++--- rpcs3/Emu/System.h | 9 +++---- rpcs3/Gui/InterpreterDisAsm.cpp | 4 ++-- rpcs3/Gui/MainFrame.cpp | 2 +- rpcs3/Gui/MemoryViewer.cpp | 4 ++-- rpcs3/Gui/VFSManager.cpp | 2 +- rpcs3/Gui/VHDDManager.cpp | 4 ++-- rpcs3/Ini.cpp | 2 +- rpcs3/Loader/PKG.cpp | 2 +- rpcs3/rpcs3.h | 3 +-- rpcs3/stdafx.h | 19 ++++++++++++++- 48 files changed, 190 insertions(+), 154 deletions(-) diff --git a/Utilities/BEType.h b/Utilities/BEType.h index cfd2c4265e..688c9858ba 100644 --- a/Utilities/BEType.h +++ b/Utilities/BEType.h @@ -52,9 +52,7 @@ class be_t T m_data; public: - be_t() - { - } + be_t() noexcept = default; be_t(const T& value) { diff --git a/Utilities/GNU.h b/Utilities/GNU.h index f3678958d8..a21c99c726 100644 --- a/Utilities/GNU.h +++ b/Utilities/GNU.h @@ -1,8 +1,8 @@ #pragma once #if defined(__GNUG__) -#include -#define _fpclass(x) fpclassify(x) +#include +#define _fpclass(x) std::fpclassify(x) #define __forceinline __attribute__((always_inline)) #define _byteswap_ushort(x) __builtin_bswap16(x) #define _byteswap_ulong(x) __builtin_bswap32(x) @@ -11,4 +11,9 @@ #define mkdir(x) mkdir(x, 0777) #define INFINITE 0xFFFFFFFF #define _CRT_ALIGN(x) __attribute__((aligned(x))) +#define InterlockedCompareExchange(ptr,new_val,old_val) __sync_val_compare_and_swap(ptr,old_val,new_val) +#define InterlockedCompareExchange64(ptr,new_val,old_val) __sync_val_compare_and_swap(ptr,old_val,new_val) +#define _aligned_malloc(size,alignment) aligned_alloc(alignment,size) +#define _aligned_free(pointer) free(pointer) +#define DWORD int64_t #endif diff --git a/Utilities/IdManager.h b/Utilities/IdManager.h index d543769356..ff1185c415 100644 --- a/Utilities/IdManager.h +++ b/Utilities/IdManager.h @@ -96,7 +96,7 @@ public: m_cur_id = s_first_id; } - template + template ID_TYPE GetNewID(const std::string& name = "", T* data = nullptr, const u8 attr = 0) { std::lock_guard lock(m_mtx_main); @@ -155,4 +155,4 @@ public: return true; } -}; \ No newline at end of file +}; diff --git a/Utilities/MTProgressDialog.h b/Utilities/MTProgressDialog.h index 5fb9f467a7..72ef148805 100644 --- a/Utilities/MTProgressDialog.h +++ b/Utilities/MTProgressDialog.h @@ -95,4 +95,4 @@ public: wxDialog::Close(force); } -}; \ No newline at end of file +}; diff --git a/Utilities/SMutex.cpp b/Utilities/SMutex.cpp index 3c1eecb3fc..7d9e9fdbd7 100644 --- a/Utilities/SMutex.cpp +++ b/Utilities/SMutex.cpp @@ -6,9 +6,9 @@ __forceinline void SM_Sleep() Sleep(1); } -__forceinline DWORD SM_GetCurrentThreadId() +__forceinline std::thread::id SM_GetCurrentThreadId() { - return GetCurrentThreadId(); + return std::this_thread::get_id(); } __forceinline u32 SM_GetCurrentCPUThreadId() @@ -23,4 +23,4 @@ __forceinline u32 SM_GetCurrentCPUThreadId() __forceinline be_t SM_GetCurrentCPUThreadIdBE() { return SM_GetCurrentCPUThreadId(); -} \ No newline at end of file +} diff --git a/Utilities/SMutex.h b/Utilities/SMutex.h index 3746620526..9cb03be3d9 100644 --- a/Utilities/SMutex.h +++ b/Utilities/SMutex.h @@ -1,7 +1,7 @@ #pragma once extern void SM_Sleep(); -extern DWORD SM_GetCurrentThreadId(); +extern std::thread::id SM_GetCurrentThreadId(); extern u32 SM_GetCurrentCPUThreadId(); extern be_t SM_GetCurrentCPUThreadIdBE(); @@ -22,7 +22,7 @@ template typename T, u32 free_value = 0, u32 dead_value = ~0, - void (wait)() = SM_Sleep + void (*wait)() = SM_Sleep > class SMutexBase { @@ -149,9 +149,9 @@ typedef SMutexBase typedef SMutexBase> SMutexBE; -typedef SMutexLockerBase +typedef SMutexLockerBase SMutexGeneralLocker; typedef SMutexLockerBase SMutexLocker; typedef SMutexLockerBase, SM_GetCurrentCPUThreadIdBE> - SMutexBELocker; \ No newline at end of file + SMutexBELocker; diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 793e963be9..ad8633a6b6 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "Thread.h" -__declspec(thread) NamedThreadBase* g_tls_this_thread = nullptr; +/*__declspec(thread)*/ thread_local NamedThreadBase* g_tls_this_thread = nullptr; NamedThreadBase* GetCurrentNamedThread() { @@ -124,7 +124,7 @@ void thread::start(std::function func) catch(...) { ConLog.Error("Crash :("); - terminate(); + std::terminate(); } }); } @@ -142,4 +142,4 @@ void thread::join() bool thread::joinable() const { return m_thr.joinable(); -} \ No newline at end of file +} diff --git a/Utilities/Thread.h b/Utilities/Thread.h index 33b45911c4..da04de0051 100644 --- a/Utilities/Thread.h +++ b/Utilities/Thread.h @@ -141,7 +141,7 @@ class StepThread : public ThreadBase volatile bool m_exit; protected: - StepThread(const wxString& name = "Unknown StepThread") + StepThread(const std::string& name = "Unknown StepThread") : ThreadBase(true, name) , m_exit(false) { diff --git a/rpcs3/CMakeLists.txt b/rpcs3/CMakeLists.txt index e9e5502f41..3f041c074e 100644 --- a/rpcs3/CMakeLists.txt +++ b/rpcs3/CMakeLists.txt @@ -3,14 +3,15 @@ cmake_minimum_required(VERSION 2.8) project(rpcs3) if (CMAKE_COMPILER_IS_GNUCXX) - add_definitions(-std=gnu++11) - add_definitions(-D__WXGTK__) - #add_definitions(-Wfatal-errors) - add_definitions(-w) # TODO: remove me - add_definitions(-DwxUSE_UNICODE=0) - add_definitions(-fpermissive) # TODO: remove me + add_definitions(-std=gnu++11) + #add_definitions(-D__WXGTK__) + #add_definitions(-Wfatal-errors) + add_definitions(-w) # TODO: remove me + add_definitions(-fpermissive) # TODO: remove me endif() +SET(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/../bin") + add_definitions(-DGL_GLEXT_PROTOTYPES) add_definitions(-DGLX_GLXEXT_PROTOTYPES) diff --git a/rpcs3/Emu/CPU/CPUThread.h b/rpcs3/Emu/CPU/CPUThread.h index c7e369fbad..88470283bc 100644 --- a/rpcs3/Emu/CPU/CPUThread.h +++ b/rpcs3/Emu/CPU/CPUThread.h @@ -21,7 +21,7 @@ struct reservation_struct extern reservation_struct reservation; -enum CPUThreadType +enum CPUThreadType :unsigned char { CPU_THREAD_PPU, CPU_THREAD_SPU, diff --git a/rpcs3/Emu/CPU/CPUThreadManager.h b/rpcs3/Emu/CPU/CPUThreadManager.h index 45081d3625..1dd312ecbf 100644 --- a/rpcs3/Emu/CPU/CPUThreadManager.h +++ b/rpcs3/Emu/CPU/CPUThreadManager.h @@ -1,5 +1,6 @@ #pragma once -#include "CPUThread.h" +class CPUThread; +enum CPUThreadType : unsigned char; class CPUThreadManager { @@ -24,4 +25,4 @@ public: void Exec(); void Task(); -}; \ No newline at end of file +}; diff --git a/rpcs3/Emu/Cell/PPCThreadManager.cpp b/rpcs3/Emu/Cell/PPCThreadManager.cpp index 2be6a26806..52e8b83ae7 100644 --- a/rpcs3/Emu/Cell/PPCThreadManager.cpp +++ b/rpcs3/Emu/Cell/PPCThreadManager.cpp @@ -1,3 +1,4 @@ +#if 0 #include "stdafx.h" #include "PPCThreadManager.h" #include "PPUThread.h" @@ -33,7 +34,7 @@ PPCThread& PPCThreadManager::AddThread(PPCThreadType type) default: assert(0); } - new_thread->SetId(Emu.GetIdManager().GetNewID(wxString::Format("%s Thread", name), new_thread)); + new_thread->SetId(Emu.GetIdManager().GetNewID(wxString::Format("%s Thread", name).ToStdString(), new_thread)); m_threads.Add(new_thread); wxGetApp().SendDbgCommand(DID_CREATE_THREAD, new_thread); @@ -106,3 +107,4 @@ void PPCThreadManager::Exec() m_threads[i].Exec(); } } +#endif diff --git a/rpcs3/Emu/Cell/PPCThreadManager.h b/rpcs3/Emu/Cell/PPCThreadManager.h index 3d2754302b..e1bea459cb 100644 --- a/rpcs3/Emu/Cell/PPCThreadManager.h +++ b/rpcs3/Emu/Cell/PPCThreadManager.h @@ -3,9 +3,9 @@ enum PPCThreadType { - PPC_THREAD_PPU, - PPC_THREAD_SPU, - PPC_THREAD_RAW_SPU + PPC_THREAD_PPU, + PPC_THREAD_SPU, + PPC_THREAD_RAW_SPU }; class PPCThreadManager @@ -17,7 +17,7 @@ class PPCThreadManager std::mutex m_mtx_thread; wxSemaphore m_sem_task; Stack m_delete_threads; - u32 m_raw_spu_num; + u32 m_raw_spu_num; public: PPCThreadManager(); diff --git a/rpcs3/Emu/Cell/PPUInterpreter.h b/rpcs3/Emu/Cell/PPUInterpreter.h index 47ab964606..6784e2d1b5 100644 --- a/rpcs3/Emu/Cell/PPUInterpreter.h +++ b/rpcs3/Emu/Cell/PPUInterpreter.h @@ -97,7 +97,7 @@ private: const int fpc = _fpclass(v); #ifdef __GNUG__ if(fpc == FP_SUBNORMAL) - return signbit(v) ? -0.0f : 0.0f; + return std::signbit(v) ? -0.0f : 0.0f; #else if(fpc & _FPCLASS_ND) return -0.0f; if(fpc & _FPCLASS_PD) return 0.0f; @@ -3361,7 +3361,7 @@ private: #ifdef _MSC_VER if(_fpclass(CPU.FPR[frb]) >= _FPCLASS_NZ) #else - if(_fpclass(CPU.FPR[frb]) == FP_ZERO || signbit(CPU.FPR[frb]) == 0) + if(_fpclass(CPU.FPR[frb]) == FP_ZERO || std::signbit(CPU.FPR[frb]) == 0) #endif { res = static_cast(1.0 / CPU.FPR[frb]); diff --git a/rpcs3/Emu/Cell/PPUThread.h b/rpcs3/Emu/Cell/PPUThread.h index ddbb04945a..b4a12efedf 100644 --- a/rpcs3/Emu/Cell/PPUThread.h +++ b/rpcs3/Emu/Cell/PPUThread.h @@ -2,6 +2,7 @@ #include "Emu/Cell/PPCThread.h" #include "Emu/SysCalls/SysCalls.h" #include "rpcs3.h" +#include enum { @@ -373,10 +374,10 @@ struct PPCdouble switch (fpc) { case FP_NAN: return FPR_QNAN; - case FP_INFINITE: return signbit(_double) ? FPR_NINF : FPR_PINF; - case FP_SUBNORMAL: return signbit(_double) ? FPR_ND : FPR_PD; - case FP_ZERO: return signbit(_double) ? FPR_NZ : FPR_PZ; - default: return signbit(_double) ? FPR_NN : FPR_PN; + case FP_INFINITE: return std::signbit(_double) ? FPR_NINF : FPR_PINF; + case FP_SUBNORMAL: return std::signbit(_double) ? FPR_ND : FPR_PD; + case FP_ZERO: return std::signbit(_double) ? FPR_NZ : FPR_PZ; + default: return std::signbit(_double) ? FPR_NN : FPR_PN; } #endif diff --git a/rpcs3/Emu/FS/vfsLocalDir.cpp b/rpcs3/Emu/FS/vfsLocalDir.cpp index 144e5d46a4..d35de98a51 100644 --- a/rpcs3/Emu/FS/vfsLocalDir.cpp +++ b/rpcs3/Emu/FS/vfsLocalDir.cpp @@ -1,6 +1,5 @@ #include "stdafx.h" #include "vfsLocalDir.h" -#include vfsLocalDir::vfsLocalDir(vfsDevice* device) : vfsDirBase(device) { @@ -50,4 +49,4 @@ bool vfsLocalDir::Rename(const wxString& from, const wxString& to) bool vfsLocalDir::Remove(const wxString& path) { return wxRmdir(path); -} \ No newline at end of file +} diff --git a/rpcs3/Emu/GS/GL/GLGSRender.cpp b/rpcs3/Emu/GS/GL/GLGSRender.cpp index afeb7e8998..b4c08c40c9 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.cpp +++ b/rpcs3/Emu/GS/GL/GLGSRender.cpp @@ -2,6 +2,7 @@ #include "GLGSRender.h" #include "Emu/Cell/PPCInstrTable.h" #include "Gui/RSXDebugger.h" +#include "OpenGL.h" #define CMD_DEBUG 0 #define DUMP_VERTEX_DATA 0 @@ -649,12 +650,10 @@ void GLGSRender::OnInitThread() #ifdef _WIN32 glSwapInterval(Ini.GSVSyncEnable.GetValue() ? 1 : 0); - - glGenTextures(1, &g_depth_tex); - glGenTextures(1, &g_flip_tex); #else - if (GLXDrawable drawable = glXGetCurrentDrawable()) - glXSwapIntervalEXT(glXGetCurrentDisplay(), drawable, Ini.GSVSyncEnable.GetValue() ? 1 : 0); + if (GLXDrawable drawable = glXGetCurrentDrawable()){ + //glXSwapIntervalEXT(glXGetCurrentDisplay(), drawable, Ini.GSVSyncEnable.GetValue() ? 1 : 0); + } #endif } diff --git a/rpcs3/Emu/GS/GSManager.cpp b/rpcs3/Emu/GS/GSManager.cpp index ad6ac2bedf..0d2c1b0451 100644 --- a/rpcs3/Emu/GS/GSManager.cpp +++ b/rpcs3/Emu/GS/GSManager.cpp @@ -4,7 +4,7 @@ #include "GL/GLGSRender.h" BEGIN_EVENT_TABLE(GSFrame, wxFrame) - EVT_PAINT(GSFrame::OnPaint) + EVT_PAINT(GSFrame::OnPaint) EVT_SIZE(GSFrame::OnSize) END_EVENT_TABLE() @@ -45,4 +45,4 @@ u8 GSManager::GetState() u8 GSManager::GetColorSpace() { return CELL_VIDEO_OUT_COLOR_SPACE_RGB; -} \ No newline at end of file +} diff --git a/rpcs3/Emu/GS/GSRender.cpp b/rpcs3/Emu/GS/GSRender.cpp index 5a1fc4bceb..e07efaff07 100644 --- a/rpcs3/Emu/GS/GSRender.cpp +++ b/rpcs3/Emu/GS/GSRender.cpp @@ -78,4 +78,4 @@ void GSFrame::SetSize(int width, int height) GSLockCurrent::GSLockCurrent(GSLockType type) : GSLock(Emu.GetGSManager().GetRender(), type) { -} \ No newline at end of file +} diff --git a/rpcs3/Emu/GS/sysutil_video.h b/rpcs3/Emu/GS/sysutil_video.h index 6ec3f0de63..630106116e 100644 --- a/rpcs3/Emu/GS/sysutil_video.h +++ b/rpcs3/Emu/GS/sysutil_video.h @@ -75,7 +75,7 @@ enum CellVideoOutPortType enum CellVideoOutDisplayAspect { - CELL_VIDEO_OUT_ASPECT_AUTO, + CELL_VIDEO_OUT_ASPECT_AUTO, CELL_VIDEO_OUT_ASPECT_4_3, CELL_VIDEO_OUT_ASPECT_16_9, }; diff --git a/rpcs3/Emu/HDD/HDD.h b/rpcs3/Emu/HDD/HDD.h index 3478d30fbb..ed3650ed54 100644 --- a/rpcs3/Emu/HDD/HDD.h +++ b/rpcs3/Emu/HDD/HDD.h @@ -482,7 +482,7 @@ public: int OpenDir(const wxString& name) { - ConLog.Warning("OpenDir(%s)", name.mb_str()); + ConLog.Warning("OpenDir(%s)", name.wx_str()); u64 entry_block; if(!SearchEntry(name, entry_block)) return -1; @@ -769,7 +769,7 @@ public: if(entry.type == vfsHDD_Entry_Dir && name != "." && name != "..") { - ConLog.Warning("removing sub folder '%s'", name.mb_str()); + ConLog.Warning("removing sub folder '%s'", name.wx_str()); RemoveBlocksDir(entry.data_block); } else if(entry.type == vfsHDD_Entry_File) @@ -869,4 +869,4 @@ public: { return m_file.GetSize(); } -}; \ No newline at end of file +}; diff --git a/rpcs3/Emu/Memory/Memory.h b/rpcs3/Emu/Memory/Memory.h index d4b5108e1c..b90be6a2d8 100644 --- a/rpcs3/Emu/Memory/Memory.h +++ b/rpcs3/Emu/Memory/Memory.h @@ -1,5 +1,6 @@ #pragma once #include "MemoryBlock.h" +#include enum MemoryType { @@ -912,10 +913,10 @@ public: return m_ptr; } - T operator [](int index) - { - return *(m_ptr + index); - } + T operator [](int index) + { + return *(m_ptr + index); + } template operator const mem_t() const diff --git a/rpcs3/Emu/SysCalls/Modules/cellDmux.h b/rpcs3/Emu/SysCalls/Modules/cellDmux.h index 77bab0fcdb..08616f565c 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellDmux.h +++ b/rpcs3/Emu/SysCalls/Modules/cellDmux.h @@ -96,20 +96,20 @@ struct CellDmuxResource2 be_t memSize; be_t ppuThreadPriority; be_t ppuThreadStackSize; - union + union cell_info { - struct + struct spu_info { be_t noex_spuThreadPriority; be_t noex_numOfSpus; - }; - struct + }spu_inf; + struct spurs_info { be_t ex_spurs_addr; u8 ex_priority[8]; be_t ex_maxContention; - }; - }; + }spurs_inf; + }cell_inf; }; struct CellDmuxCb @@ -140,8 +140,8 @@ struct CellDmuxEsAttr struct CellDmuxEsResource { - be_t memAddr; - be_t memSize; + be_t memAddr; + be_t memSize; }; struct CellDmuxAuInfo @@ -149,7 +149,7 @@ struct CellDmuxAuInfo be_t auAddr; be_t auSize; be_t auMaxSize; - be_t userData; + be_t userData; be_t ptsUpper; be_t ptsLower; be_t dtsUpper; @@ -165,4 +165,4 @@ struct CellDmuxAuInfoEx be_t userData; CellCodecTimeStamp pts; CellCodecTimeStamp dts; -}; \ No newline at end of file +}; diff --git a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp index 912acc1282..a42dcb14fe 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp @@ -292,7 +292,7 @@ int cellGameContentErrorDialog(s32 type, s32 errNeedSizeKB, u32 dirName_addr) } std::string errorMsg = wxString::Format("%s\nSpace needed: %d KB\nDirectory name: %s", - wxString(errorName).wx_str(), errNeedSizeKB, wxString(dirName).wx_str()); + wxString(errorName).wx_str(), errNeedSizeKB, wxString(dirName).wx_str()).ToStdString(); wxMessageBox(errorMsg, wxGetApp().GetAppName(), wxICON_ERROR | wxOK); return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp index 2f38d070e8..99fc56d3ed 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp @@ -728,9 +728,9 @@ int cellRescSetBufferAddress(mem32_t colorBuffers, mem32_t vertexArray, mem32_t if(!colorBuffers.IsGood() || !vertexArray.IsGood() || !fragmentShader.IsGood()) return CELL_RESC_ERROR_BAD_ARGUMENT; if(colorBuffers.GetAddr() % COLOR_BUFFER_ALIGNMENT || - vertexArray.GetAddr() % VERTEX_BUFFER_ALIGNMENT || - fragmentShader.GetAddr() % FRAGMENT_SHADER_ALIGNMENT) - return CELL_RESC_ERROR_BAD_ALIGNMENT; + vertexArray.GetAddr() % VERTEX_BUFFER_ALIGNMENT || + fragmentShader.GetAddr() % FRAGMENT_SHADER_ALIGNMENT) + return CELL_RESC_ERROR_BAD_ALIGNMENT; s_rescInternalInstance->m_colorBuffersEA_addr = colorBuffers.GetAddr(); s_rescInternalInstance->m_vertexArrayEA_addr = vertexArray.GetAddr(); @@ -813,4 +813,4 @@ void cellResc_init() void cellResc_unload() { s_rescInternalInstance->m_bInitialized = false; -} \ No newline at end of file +} diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp index 95ecd1e8d2..da3c545199 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp @@ -24,14 +24,12 @@ enum }; #pragma pack(push, 1) -struct CellSyncMutex { - union { - struct { - be_t m_freed; - be_t m_order; - }; - volatile u32 m_data; - }; +union CellSyncMutex { + struct cell_sync_mutex_info{ + be_t m_freed; + be_t m_order; + }parts; + volatile u32 m_data; /* (???) Initialize: set zeros (???) Lock: increase m_order and wait until m_freed == old m_order @@ -87,9 +85,9 @@ int cellSyncMutexLock(mem_ptr_t mutex) { reservation.clear(); } - old_order = mutex->m_order; - mutex->m_order = mutex->m_order + 1; - if (old_order == mutex->m_freed) + old_order = mutex->parts.m_order; + mutex->parts.m_order = mutex->parts.m_order + 1; + if (old_order == mutex->parts.m_freed) { return CELL_OK; } @@ -127,11 +125,11 @@ int cellSyncMutexTryLock(mem_ptr_t mutex) { reservation.clear(); } - if (mutex->m_order != mutex->m_freed) + if (mutex->parts.m_order != mutex->parts.m_freed) { return CELL_SYNC_ERROR_BUSY; } - mutex->m_order = mutex->m_order + 1; + mutex->parts.m_order = mutex->parts.m_order + 1; return CELL_OK; } } @@ -156,7 +154,7 @@ int cellSyncMutexUnlock(mem_ptr_t mutex) { reservation.clear(); } - mutex->m_freed = mutex->m_freed + 1; + mutex->parts.m_freed = mutex->parts.m_freed + 1; return CELL_OK; } } @@ -167,4 +165,4 @@ void cellSync_init() cellSync.AddFunc(0x1bb675c2, cellSyncMutexLock); cellSync.AddFunc(0xd06918c4, cellSyncMutexTryLock); cellSync.AddFunc(0x91f2b7b0, cellSyncMutexUnlock); -} \ No newline at end of file +} diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp index 7f83764416..51c4165363 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp @@ -1007,4 +1007,4 @@ void cellSysutil_init() cellSysutil.AddFunc(0x1e7bff94, cellSysCacheMount); cellSysutil.AddFunc(0x744c1544, cellSysCacheClear); -} \ No newline at end of file +} diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp index 7d019f813b..8f3960e36d 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp @@ -1,12 +1,16 @@ +#if 0 #include "stdafx.h" #include "Emu/SysCalls/SysCalls.h" #include "Emu/SysCalls/SC_FUNC.h" #include "sceNp.h" -void sceNp_init(); +void sceNpTrophy_init(); Module sceNp(0x0016, sceNpTrophy_init); void sceNpTrophy_init() { } +#endif + + diff --git a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp index 27f22ab243..c840f18f57 100644 --- a/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sys_fs.cpp @@ -129,8 +129,8 @@ int cellFsSdataOpen(u32 path_addr, int flags, mem32_t fd, mem32_t arg, u64 size) return CELL_OK; } -std::atomic g_FsAioReadID = 0; -std::atomic g_FsAioReadCur = 0; +std::atomic g_FsAioReadID( 0 ); +std::atomic g_FsAioReadCur( 0 ); bool aio_init; void fsAioRead(u32 fd, mem_ptr_t aio, int xid, mem_func_ptr_t xaio, u32 error, int xid, u64 size)> func) diff --git a/rpcs3/Emu/SysCalls/SC_FUNC.h b/rpcs3/Emu/SysCalls/SC_FUNC.h index 0157a8bf2f..c77c80af7b 100644 --- a/rpcs3/Emu/SysCalls/SC_FUNC.h +++ b/rpcs3/Emu/SysCalls/SC_FUNC.h @@ -1,4 +1,5 @@ #pragma once +#include "Modules.h" #define RESULT(x) SC_ARGS_1 = (x) diff --git a/rpcs3/Emu/SysCalls/SysCalls.cpp b/rpcs3/Emu/SysCalls/SysCalls.cpp index 5b24a0e199..4014f859d2 100644 --- a/rpcs3/Emu/SysCalls/SysCalls.cpp +++ b/rpcs3/Emu/SysCalls/SysCalls.cpp @@ -3,6 +3,13 @@ #include "Modules.h" #include "SC_FUNC.h" +namespace detail{ +template<> bool CheckId(u32 id, ID*& _id,const std::string &name) +{ + return Emu.GetIdManager().CheckID(id) && (_id = &Emu.GetIdManager().GetID(id))->m_name == name; +} +} + void default_syscall(); static func_caller *null_func = bind_func(default_syscall); @@ -358,4 +365,4 @@ void SysCalls::DoSyscall(u32 code) //TODO: remove this declCPU(); RESULT(DoFunc(code)); -} \ No newline at end of file +} diff --git a/rpcs3/Emu/SysCalls/SysCalls.h b/rpcs3/Emu/SysCalls/SysCalls.h index 531cb88f88..8632ab062b 100644 --- a/rpcs3/Emu/SysCalls/SysCalls.h +++ b/rpcs3/Emu/SysCalls/SysCalls.h @@ -14,6 +14,20 @@ #define declCPU PPUThread& CPU = GetCurrentPPUThread +class SysCallBase; + +namespace detail{ + template bool CheckId(u32 id, T*& data,const std::string &name) + { + ID* id_data; + if(!CheckId(id, id_data,name)) return false; + data = id_data->m_data->get(); + return true; + } + + template<> bool CheckId(u32 id, ID*& _id,const std::string &name); +} + class SysCallBase //Module { private: @@ -94,18 +108,7 @@ public: template bool CheckId(u32 id, T*& data) { - ID* id_data; - - if(!CheckId(id, id_data)) return false; - - data = id_data->m_data->get(); - - return true; - } - - template<> bool CheckId(u32 id, ID*& _id) - { - return Emu.GetIdManager().CheckID(id) && (_id = &Emu.GetIdManager().GetID(id))->m_name == GetName(); + return detail::CheckId(id,data,GetName()); } template diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Event.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Event.cpp index b900be9046..0aea42d6cf 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Event.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Event.cpp @@ -430,4 +430,4 @@ int sys_event_port_send(u32 eport_id, u64 data1, u64 data2, u64 data3) } return CELL_OK; -} \ No newline at end of file +} diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp index 89dd8c7409..6a7524a88b 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp @@ -86,11 +86,11 @@ int sys_lwcond_signal(mem_ptr_t lwcond) if (be_t target = mutex->attribute.ToBE() == se32(SYS_SYNC_PRIORITY) ? sq->pop_prio() : sq->pop()) { - if (mutex->owner.trylock(target) != SMR_OK) + if (mutex->vars.parts.owner.trylock(target) != SMR_OK) { - mutex->owner.lock(tid); + mutex->vars.parts.owner.lock(tid); mutex->recursive_count = 1; - mutex->owner.unlock(tid, target); + mutex->vars.parts.owner.unlock(tid, target); } } @@ -122,11 +122,11 @@ int sys_lwcond_signal_all(mem_ptr_t lwcond) while (be_t target = mutex->attribute.ToBE() == se32(SYS_SYNC_PRIORITY) ? sq->pop_prio() : sq->pop()) { - if (mutex->owner.trylock(target) != SMR_OK) + if (mutex->vars.parts.owner.trylock(target) != SMR_OK) { - mutex->owner.lock(tid); + mutex->vars.parts.owner.lock(tid); mutex->recursive_count = 1; - mutex->owner.unlock(tid, target); + mutex->vars.parts.owner.unlock(tid, target); } } @@ -163,11 +163,11 @@ int sys_lwcond_signal_to(mem_ptr_t lwcond, u32 ppu_thread_id) be_t target = ppu_thread_id; - if (mutex->owner.trylock(target) != SMR_OK) + if (mutex->vars.parts.owner.trylock(target) != SMR_OK) { - mutex->owner.lock(tid); + mutex->vars.parts.owner.lock(tid); mutex->recursive_count = 1; - mutex->owner.unlock(tid, target); + mutex->vars.parts.owner.unlock(tid, target); } if (Emu.IsStopped()) @@ -197,7 +197,7 @@ int sys_lwcond_wait(mem_ptr_t lwcond, u64 timeout) u32 tid_le = GetCurrentPPUThread().GetId(); be_t tid = tid_le; - if (mutex->owner.GetOwner() != tid) + if (mutex->vars.parts.owner.GetOwner() != tid) { return CELL_EPERM; // caller must own this lwmutex } @@ -205,7 +205,7 @@ int sys_lwcond_wait(mem_ptr_t lwcond, u64 timeout) sq->push(tid_le); mutex->recursive_count = 0; - mutex->owner.unlock(tid); + mutex->vars.parts.owner.unlock(tid); u32 counter = 0; const u32 max_counter = timeout ? (timeout / 1000) : ~0; @@ -216,7 +216,7 @@ int sys_lwcond_wait(mem_ptr_t lwcond, u64 timeout) case SMR_OK: mutex->unlock(tid); break; case SMR_SIGNAL: return CELL_OK; } */ - if (mutex->owner.GetOwner() == tid) + if (mutex->vars.parts.owner.GetOwner() == tid) { _mm_mfence(); mutex->recursive_count = 1; diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp index db07fbed3b..9a2a900905 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp @@ -28,7 +28,7 @@ int sys_lwmutex_create(mem_ptr_t lwmutex, mem_ptr_tattribute = attr->attr_protocol | attr->attr_recursive; - lwmutex->all_info = 0; + lwmutex->vars.all_info = 0; lwmutex->pad = 0; lwmutex->recursive_count = 0; @@ -68,7 +68,7 @@ int sys_lwmutex_lock(mem_ptr_t lwmutex, u64 timeout) if (!lwmutex.IsGood()) return CELL_EFAULT; //ConLog.Write("*** lock mutex (addr=0x%x, attr=0x%x, Nrec=%d, owner=%d, waiter=%d)", - //lwmutex.GetAddr(), (u32)lwmutex->attribute, (u32)lwmutex->recursive_count, lwmutex->owner.GetOwner(), (u32)lwmutex->waiter); + //lwmutex.GetAddr(), (u32)lwmutex->attribute, (u32)lwmutex->recursive_count, lwmutex->vars.parts.owner.GetOwner(), (u32)lwmutex->waiter); return lwmutex->lock(GetCurrentPPUThread().GetId(), timeout ? ((timeout < 1000) ? 1 : (timeout / 1000)) : 0); } @@ -89,7 +89,7 @@ int sys_lwmutex_unlock(mem_ptr_t lwmutex) if (!lwmutex.IsGood()) return CELL_EFAULT; //ConLog.Write("*** unlocking mutex (addr=0x%x, attr=0x%x, Nrec=%d, owner=%d, waiter=%d)", - //lwmutex.GetAddr(), (u32)lwmutex->attribute, (u32)lwmutex->recursive_count, (u32)lwmutex->owner.GetOwner(), (u32)lwmutex->waiter); + //lwmutex.GetAddr(), (u32)lwmutex->attribute, (u32)lwmutex->recursive_count, (u32)lwmutex->vars.parts.owner.GetOwner(), (u32)lwmutex->waiter); return lwmutex->unlock(GetCurrentPPUThread().GetId()); } @@ -204,7 +204,7 @@ int sys_lwmutex_t::trylock(be_t tid) { if (!attribute.ToBE()) return CELL_EINVAL; - if (tid == owner.GetOwner()) + if (tid == vars.parts.owner.GetOwner()) { if (attribute.ToBE() & se32(SYS_SYNC_RECURSIVE)) { @@ -218,7 +218,7 @@ int sys_lwmutex_t::trylock(be_t tid) } } - switch (owner.trylock(tid)) + switch (vars.parts.owner.trylock(tid)) { case SMR_OK: recursive_count = 1; return CELL_OK; case SMR_FAILED: return CELL_EBUSY; @@ -228,7 +228,7 @@ int sys_lwmutex_t::trylock(be_t tid) int sys_lwmutex_t::unlock(be_t tid) { - if (tid != owner.GetOwner()) + if (tid != vars.parts.owner.GetOwner()) { return CELL_EPERM; } @@ -245,7 +245,7 @@ int sys_lwmutex_t::unlock(be_t tid) SleepQueue* sq; if (!Emu.GetIdManager().GetIDData(sleep_queue, sq)) return CELL_ESRCH; target = attribute.ToBE() & se32(SYS_SYNC_FIFO) ? sq->pop() : sq->pop_prio(); - case se32(SYS_SYNC_RETRY): default: owner.unlock(tid, target); break; + case se32(SYS_SYNC_RETRY): default: vars.parts.owner.unlock(tid, target); break; } } return CELL_OK; @@ -271,7 +271,7 @@ int sys_lwmutex_t::lock(be_t tid, u64 timeout) default: break; } - switch (owner.lock(tid, timeout)) + switch (vars.parts.owner.lock(tid, timeout)) { case SMR_OK: sq->invalidate(tid); @@ -284,4 +284,4 @@ int sys_lwmutex_t::lock(be_t tid, u64 timeout) default: sq->invalidate(tid); return CELL_EINVAL; } -} \ No newline at end of file +} diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.h b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.h index 4d104a556b..2d569a7494 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.h +++ b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.h @@ -65,18 +65,15 @@ struct SleepQueue struct sys_lwmutex_t { - union // sys_lwmutex_variable_t + union sys_lwmutex_variable_t { - struct // sys_lwmutex_lock_info_t + struct sys_lwmutex_lock_info_t { /* volatile */ SMutexBE owner; /* volatile */ be_t waiter; // not used - }; - struct - { + }parts; /* volatile */ be_t all_info; - }; - }; + }vars; be_t attribute; be_t recursive_count; be_t sleep_queue; @@ -85,4 +82,4 @@ struct sys_lwmutex_t int trylock(be_t tid); int unlock(be_t tid); int lock(be_t tid, u64 timeout); -}; \ No newline at end of file +}; diff --git a/rpcs3/Emu/SysCalls/lv2/SC_sys_spu.cpp b/rpcs3/Emu/SysCalls/lv2/SC_sys_spu.cpp index 0f12143b20..0565f8bbd8 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_sys_spu.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_sys_spu.cpp @@ -1,3 +1,4 @@ +#if 0 #include "stdafx.h" #include "Emu/SysCalls/SysCalls.h" @@ -19,3 +20,4 @@ int sys_raw_spu_create(u32 id_addr, u32 attr_addr) Memory.Write32(id_addr, Emu.GetIdManager().GetNewID("raw_spu")); return CELL_OK; } +#endif diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index bff251bd08..33c527fb92 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -190,8 +190,8 @@ void Emulator::Load() if(IsSelf(m_path.ToStdString())) { - std::string self_path = m_path.mb_str(); - std::string elf_path = wxFileName(m_path).GetPath().c_str(); + std::string self_path = m_path.ToStdString(); + std::string elf_path = wxFileName(m_path).GetPath().ToStdString(); if(wxFileName(m_path).GetFullName().CmpNoCase("EBOOT.BIN") == 0) { @@ -216,7 +216,7 @@ void Emulator::Load() ConLog.Write("Mount info:"); for(uint i=0; i %s", m_vfs.m_devices[i].GetPs3Path().wx_str(), m_vfs.m_devices[i].GetLocalPath().wx_str()); + ConLog.Write("%s -> %s", static_cast(m_vfs.m_devices[i].GetPs3Path()), static_cast(m_vfs.m_devices[i].GetLocalPath().ToAscii())); } ConLog.SkipLn(); diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index 20c6baa4cc..603936d4bf 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -12,8 +12,9 @@ #include "Emu/DbgConsole.h" #include "Loader/Loader.h" #include "SysCalls/Callback.h" -#include "SysCalls/Modules.h" -#include "event.h" + +class EventManager; +extern void UnloadModules(); struct EmuInfo { @@ -90,7 +91,7 @@ class Emulator AudioManager m_audio_manager; CallbackManager m_callback_manager; CPUThread* m_ppu_callback_thr; - EventManager m_event_manager; + EventManager &m_event_manager; VFS m_vfs; @@ -164,4 +165,4 @@ public: __forceinline bool IsReady() const { return m_status == Ready; } }; -extern Emulator Emu; \ No newline at end of file +extern Emulator Emu; diff --git a/rpcs3/Gui/InterpreterDisAsm.cpp b/rpcs3/Gui/InterpreterDisAsm.cpp index d862d1dc42..362c01dd64 100644 --- a/rpcs3/Gui/InterpreterDisAsm.cpp +++ b/rpcs3/Gui/InterpreterDisAsm.cpp @@ -167,7 +167,7 @@ void InterpreterDisAsmFrame::OnKeyDown(wxKeyEvent& event) { if(event.GetKeyCode() == WXK_SPACE) { - wxCommandEvent ce; + wxCommandEvent ce; DoStep(ce); return; } @@ -222,7 +222,7 @@ void InterpreterDisAsmFrame::OnResize(wxSizeEvent& event) void InterpreterDisAsmFrame::DoUpdate() { - wxCommandEvent ce; + wxCommandEvent ce; Show_PC(ce); WriteRegs(); WriteCallStack(); diff --git a/rpcs3/Gui/MainFrame.cpp b/rpcs3/Gui/MainFrame.cpp index 150c4be1e3..9473644526 100644 --- a/rpcs3/Gui/MainFrame.cpp +++ b/rpcs3/Gui/MainFrame.cpp @@ -228,7 +228,7 @@ void MainFrame::InstallPkg(wxCommandEvent& WXUNUSED(event)) Emu.Stop(); // Open and install PKG file - std::string filePath = ctrl.GetPath(); + std::string filePath = ctrl.GetPath().ToStdString(); wxFile pkg_f(filePath, wxFile::read); // TODO: Use VFS to install PKG files if (pkg_f.IsOpened()) diff --git a/rpcs3/Gui/MemoryViewer.cpp b/rpcs3/Gui/MemoryViewer.cpp index c3a95a74ad..41d2fc85fb 100644 --- a/rpcs3/Gui/MemoryViewer.cpp +++ b/rpcs3/Gui/MemoryViewer.cpp @@ -25,7 +25,7 @@ MemoryViewerPanel::MemoryViewerPanel(wxWindow* parent) wxStaticBoxSizer& s_tools_mem_bytes = *new wxStaticBoxSizer(wxHORIZONTAL, this, "Bytes"); sc_bytes = new wxSpinCtrl(this, wxID_ANY, "16", wxDefaultPosition, wxSize(44,-1)); - sc_bytes->SetRange(1, 16); + sc_bytes->SetRange(1, 16); s_tools_mem_bytes.Add(sc_bytes); wxStaticBoxSizer& s_tools_mem_buttons = *new wxStaticBoxSizer(wxHORIZONTAL, this, "Control"); @@ -52,7 +52,7 @@ MemoryViewerPanel::MemoryViewerPanel(wxWindow* parent) s_tools_img_size.Add(new wxStaticText(this, wxID_ANY, " x ")); s_tools_img_size.Add(sc_img_size_y); - sc_img_size_x->SetRange(1, 8192); + sc_img_size_x->SetRange(1, 8192); sc_img_size_y->SetRange(1, 8192); wxStaticBoxSizer& s_tools_img_mode = *new wxStaticBoxSizer(wxHORIZONTAL, this, "Mode"); diff --git a/rpcs3/Gui/VFSManager.cpp b/rpcs3/Gui/VFSManager.cpp index 2215be3949..9b61daf0c5 100644 --- a/rpcs3/Gui/VFSManager.cpp +++ b/rpcs3/Gui/VFSManager.cpp @@ -58,7 +58,7 @@ VFSEntrySettingsDialog::VFSEntrySettingsDialog(wxWindow* parent, VFSManagerEntry m_tctrl_mount->SetValue(m_entry.mount); m_ch_type->SetSelection(m_entry.device); - wxCommandEvent ce; + wxCommandEvent ce; OnSelectType(ce); } diff --git a/rpcs3/Gui/VHDDManager.cpp b/rpcs3/Gui/VHDDManager.cpp index 59916e26e6..bc16439916 100644 --- a/rpcs3/Gui/VHDDManager.cpp +++ b/rpcs3/Gui/VHDDManager.cpp @@ -347,10 +347,10 @@ VHDDSetInfoDialog::VHDDSetInfoDialog(wxWindow* parent) : wxDialog(parent, wxID_A m_ch_type->Append("MB"); m_ch_type->Append("GB"); - m_spin_size->SetRange(1, 0x7fffffff); + m_spin_size->SetRange(1, 0x7fffffff); m_spin_size->SetValue(64); m_ch_type->SetSelection(3); - m_spin_block_size->SetRange(64, 0x7fffffff); + m_spin_block_size->SetRange(64, 0x7fffffff); m_spin_block_size->SetValue(2048); Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(VHDDSetInfoDialog::OnOk)); } diff --git a/rpcs3/Ini.cpp b/rpcs3/Ini.cpp index 292f8d0f13..e5b84d76af 100644 --- a/rpcs3/Ini.cpp +++ b/rpcs3/Ini.cpp @@ -155,7 +155,7 @@ Ini::Ini() wxGetCwd() + "\\rpcs3.ini", wxEmptyString, wxCONFIG_USE_LOCAL_FILE ); #else - m_Config = new wxConfig("rpcs3"); + m_Config = new wxConfig("rpcs3"); #endif } diff --git a/rpcs3/Loader/PKG.cpp b/rpcs3/Loader/PKG.cpp index fba5988eb6..95438b7716 100644 --- a/rpcs3/Loader/PKG.cpp +++ b/rpcs3/Loader/PKG.cpp @@ -23,7 +23,7 @@ bool PKGLoader::Install(std::string dest, bool show) return false; std::string titleID = std::string(m_header.title_id).substr(7, 9); - std::string decryptedFile = wxGetCwd() + "/dev_hdd1/" + titleID + ".dec"; + std::string decryptedFile = wxGetCwd().ToStdString() + "/dev_hdd1/" + titleID + ".dec"; if (wxDirExists(dest+titleID)) { wxMessageDialog d_overwrite(NULL, "Another installation was found. Do you want to overwrite it?", "PKG Decrypter / Installer", wxYES_NO|wxCENTRE); diff --git a/rpcs3/rpcs3.h b/rpcs3/rpcs3.h index 7100b182f0..876c931e0b 100644 --- a/rpcs3/rpcs3.h +++ b/rpcs3/rpcs3.h @@ -1,5 +1,4 @@ #pragma once - #include "Gui/MainFrame.h" template T min(const T a, const T b) { return a < b ? a : b; } @@ -66,4 +65,4 @@ DECLARE_APP(Rpcs3App) //extern CPUThread& GetCPU(const u8 core); extern Rpcs3App* TheApp; -static const u64 PS3_CLK = 3200000000; \ No newline at end of file +static const u64 PS3_CLK = 3200000000; diff --git a/rpcs3/stdafx.h b/rpcs3/stdafx.h index 71ac10705d..3a9515c24f 100644 --- a/rpcs3/stdafx.h +++ b/rpcs3/stdafx.h @@ -3,19 +3,33 @@ #define NOMINMAX #ifndef QT_UI +#ifdef _WIN32 #include -#include +#endif +#include #include #include #include #include +#include +#include #include #include #include #include #include +#include #include +#include +#include +#include "wx/gauge.h" +#include +#include "wx/scrolbar.h" +#include "wx/frame.h" +#include +#include +#include "wx/app.h" #include #endif @@ -199,12 +213,15 @@ enum Status #include "AppConnector.h" +#include "Emu/SysCalls/Callback.h" #include "Ini.h" #include "Gui/FrameBase.h" #include "Gui/ConLog.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "Emu/Cell/PPUThread.h" +#include "Emu/SysCalls/Modules.h" + #include "Emu/FS/vfsDirBase.h" #include "Emu/FS/vfsFileBase.h" From 92fb77d50ed725155718d5076fa82312d801fa54 Mon Sep 17 00:00:00 2001 From: Bigpet Date: Sun, 23 Feb 2014 20:05:49 +0100 Subject: [PATCH 06/10] more merge fixes, I should really compile it before submitting a pull request --- rpcs3/Emu/Event.cpp | 6 +++--- rpcs3/Emu/GS/GL/GLGSRender.cpp | 2 +- rpcs3/Emu/SysCalls/Modules/cellAdec.h | 18 +++++++++--------- rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp | 6 +++--- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/rpcs3/Emu/Event.cpp b/rpcs3/Emu/Event.cpp index e31e2601fa..a1fee9d086 100644 --- a/rpcs3/Emu/Event.cpp +++ b/rpcs3/Emu/Event.cpp @@ -26,9 +26,9 @@ bool EventManager::RegisterKey(EventQueue* data, u64 key) if (key_map.find(key) != key_map.end()) return false; - for (auto& v = key_map.begin(); v != key_map.end(); ++v) + for (auto& v : key_map) { - if (v->second == data) return false; + if (v.second == data) return false; } key_map[key] = data; @@ -79,4 +79,4 @@ bool EventManager::SendEvent(u64 key, u64 source, u64 d1, u64 d2, u64 d3) eq->events.push(source, d1, d2, d3); return true; -} \ No newline at end of file +} diff --git a/rpcs3/Emu/GS/GL/GLGSRender.cpp b/rpcs3/Emu/GS/GL/GLGSRender.cpp index be30d8e121..442942f881 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.cpp +++ b/rpcs3/Emu/GS/GL/GLGSRender.cpp @@ -652,7 +652,7 @@ void GLGSRender::OnInitThread() glSwapInterval(Ini.GSVSyncEnable.GetValue() ? 1 : 0); #else if (GLXDrawable drawable = glXGetCurrentDrawable()){ - //glXSwapIntervalEXT(glXGetCurrentDisplay(), drawable, Ini.GSVSyncEnable.GetValue() ? 1 : 0); + glXSwapIntervalEXT(glXGetCurrentDisplay(), drawable, Ini.GSVSyncEnable.GetValue() ? 1 : 0); } #endif glGenTextures(1, &g_depth_tex); diff --git a/rpcs3/Emu/SysCalls/Modules/cellAdec.h b/rpcs3/Emu/SysCalls/Modules/cellAdec.h index 9f9e633110..e05a394561 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAdec.h +++ b/rpcs3/Emu/SysCalls/Modules/cellAdec.h @@ -524,16 +524,16 @@ struct CellAdecParamM4Aac be_t configNumber; union { - struct { struct + struct { be_t adifProgramNumber; // 0 - } adifConfig; }; + } adifConfig; - struct { struct + struct { be_t samplingFreqIndex; be_t profile; // LC profile (1) - } rawDataBlockConfig; }; + } rawDataBlockConfig; } configInfo; be_t enableDownmix; // enable downmix to 2.0 (if (enableDownmix)) @@ -557,7 +557,7 @@ struct CellAdecM4AacInfo be_t pad1; // TODO: check alignment union { - struct { struct + struct { be_t copyrightIdPresent; char copyrightId[9]; @@ -567,9 +567,9 @@ struct CellAdecM4AacInfo be_t bitrate; be_t numberOfProgramConfigElements; be_t bufferFullness; - } adif; }; + } adif; - struct { struct + struct { be_t id; be_t layer; @@ -586,7 +586,7 @@ struct CellAdecM4AacInfo be_t bufferFullness; be_t numberOfRawDataBlocks; be_t crcCheck; - } adts; }; + } adts; } bsi; be_t pad2; // TODO: check alignment @@ -980,4 +980,4 @@ struct CellAdecMpmcInfo be_t multiCodecMode; be_t lfePresent; be_t channelCoufiguration; -}; \ No newline at end of file +}; diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp index e08f0a34fb..872d2053f1 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp @@ -54,10 +54,10 @@ int sys_lwmutex_destroy(mem_ptr_t lwmutex) if (!Emu.GetIdManager().CheckID(sq_id)) return CELL_ESRCH; // try to make it unable to lock - switch (int res = lwmutex->trylock(lwmutex->owner.GetDeadValue())) + switch (int res = lwmutex->trylock(lwmutex->vars.parts.owner.GetDeadValue())) { case CELL_OK: - lwmutex->all_info = 0; + lwmutex->vars.all_info = 0; lwmutex->attribute = 0; lwmutex->sleep_queue = 0; Emu.GetIdManager().RemoveID(sq_id); @@ -252,7 +252,7 @@ int sys_lwmutex_t::unlock(be_t tid) case se32(SYS_SYNC_RETRY): break; } if (target) vars.parts.owner.unlock(tid, target); - else owner.unlock(tid); + else vars.parts.owner.unlock(tid); } return CELL_OK; } From 1908286e7c0545532eb9a094d08027f161c63155 Mon Sep 17 00:00:00 2001 From: Peter Tissen Date: Mon, 24 Feb 2014 00:40:03 +0100 Subject: [PATCH 07/10] make things compile under windows again, there's still some ugly ifdefs I'd like to get rid of --- Utilities/BEType.h | 5 +- Utilities/IdManager.h | 6 ++- Utilities/Thread.cpp | 7 ++- rpcs3/Emu/SysCalls/Modules/cellAdec.h | 70 +++++++++++++------------ rpcs3/Emu/SysCalls/Modules/cellDmux.h | 15 +----- rpcs3/Emu/SysCalls/Modules/cellSync.cpp | 24 ++++----- rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp | 24 ++++----- rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp | 22 ++++---- rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.h | 14 +++-- rpcs3/Emu/System.cpp | 1 + rpcs3/Emu/System.h | 4 +- 11 files changed, 97 insertions(+), 95 deletions(-) diff --git a/Utilities/BEType.h b/Utilities/BEType.h index 1195693178..17e8e61beb 100644 --- a/Utilities/BEType.h +++ b/Utilities/BEType.h @@ -50,7 +50,10 @@ class be_t public: typedef T type; - be_t() noexcept = default; +#ifdef __GNUG__ + be_t() noexcept = default +#endif + be_t(){} be_t(const T& value) { diff --git a/Utilities/IdManager.h b/Utilities/IdManager.h index a47dd3dcfd..9ceb8ae66e 100644 --- a/Utilities/IdManager.h +++ b/Utilities/IdManager.h @@ -96,7 +96,11 @@ public: m_cur_id = s_first_id; } - template + template ID_TYPE GetNewID(const std::string& name = "", T* data = nullptr, const u32 attr = 0) { std::lock_guard lock(m_mtx_main); diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index f756027ba9..6bd33d6b86 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -1,7 +1,12 @@ #include "stdafx.h" #include "Thread.h" -/*__declspec(thread)*/ thread_local NamedThreadBase* g_tls_this_thread = nullptr; +#ifdef _WIN32 +__declspec(thread) +#else +thread_local +#endif +NamedThreadBase* g_tls_this_thread = nullptr; NamedThreadBase* GetCurrentNamedThread() { diff --git a/rpcs3/Emu/SysCalls/Modules/cellAdec.h b/rpcs3/Emu/SysCalls/Modules/cellAdec.h index e05a394561..2aa17ead21 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAdec.h +++ b/rpcs3/Emu/SysCalls/Modules/cellAdec.h @@ -524,16 +524,16 @@ struct CellAdecParamM4Aac be_t configNumber; union { - struct + struct { struct { be_t adifProgramNumber; // 0 - } adifConfig; + } adifConfig; }; - struct + struct { struct { be_t samplingFreqIndex; be_t profile; // LC profile (1) - } rawDataBlockConfig; + } rawDataBlockConfig; }; } configInfo; be_t enableDownmix; // enable downmix to 2.0 (if (enableDownmix)) @@ -557,36 +557,40 @@ struct CellAdecM4AacInfo be_t pad1; // TODO: check alignment union { - struct - { - be_t copyrightIdPresent; - char copyrightId[9]; - be_t originalCopy; - be_t home; - be_t bitstreamType; - be_t bitrate; - be_t numberOfProgramConfigElements; - be_t bufferFullness; - } adif; + struct { + struct + { + be_t copyrightIdPresent; + char copyrightId[9]; + be_t originalCopy; + be_t home; + be_t bitstreamType; + be_t bitrate; + be_t numberOfProgramConfigElements; + be_t bufferFullness; + } adif; + }; - struct - { - be_t id; - be_t layer; - be_t protectionAbsent; - be_t profile; - be_t samplingFreqIndex; - be_t privateBit; - be_t channelConfiguration; - be_t originalCopy; - be_t home; - be_t copyrightIdBit; - be_t copyrightIdStart; - be_t frameLength; - be_t bufferFullness; - be_t numberOfRawDataBlocks; - be_t crcCheck; - } adts; + struct { + struct + { + be_t id; + be_t layer; + be_t protectionAbsent; + be_t profile; + be_t samplingFreqIndex; + be_t privateBit; + be_t channelConfiguration; + be_t originalCopy; + be_t home; + be_t copyrightIdBit; + be_t copyrightIdStart; + be_t frameLength; + be_t bufferFullness; + be_t numberOfRawDataBlocks; + be_t crcCheck; + } adts; + }; } bsi; be_t pad2; // TODO: check alignment diff --git a/rpcs3/Emu/SysCalls/Modules/cellDmux.h b/rpcs3/Emu/SysCalls/Modules/cellDmux.h index 08616f565c..9fa0067ee0 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellDmux.h +++ b/rpcs3/Emu/SysCalls/Modules/cellDmux.h @@ -96,20 +96,7 @@ struct CellDmuxResource2 be_t memSize; be_t ppuThreadPriority; be_t ppuThreadStackSize; - union cell_info - { - struct spu_info - { - be_t noex_spuThreadPriority; - be_t noex_numOfSpus; - }spu_inf; - struct spurs_info - { - be_t ex_spurs_addr; - u8 ex_priority[8]; - be_t ex_maxContention; - }spurs_inf; - }cell_inf; + be_t shit[4]; }; struct CellDmuxCb diff --git a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp index da3c545199..ba812cb2cb 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSync.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSync.cpp @@ -24,12 +24,12 @@ enum }; #pragma pack(push, 1) -union CellSyncMutex { - struct cell_sync_mutex_info{ - be_t m_freed; +struct CellSyncMutex { + be_t m_freed; be_t m_order; - }parts; - volatile u32 m_data; + volatile u32& m_data(){ + return *reinterpret_cast(this); + }; /* (???) Initialize: set zeros (???) Lock: increase m_order and wait until m_freed == old m_order @@ -59,7 +59,7 @@ int cellSyncMutexInitialize(mem_ptr_t mutex) { reservation.clear(); } - mutex->m_data = 0; + mutex->m_data() = 0; return CELL_OK; } } @@ -85,9 +85,9 @@ int cellSyncMutexLock(mem_ptr_t mutex) { reservation.clear(); } - old_order = mutex->parts.m_order; - mutex->parts.m_order = mutex->parts.m_order + 1; - if (old_order == mutex->parts.m_freed) + old_order = mutex->m_order; + mutex->m_order = mutex->m_order + 1; + if (old_order == mutex->m_freed) { return CELL_OK; } @@ -125,11 +125,11 @@ int cellSyncMutexTryLock(mem_ptr_t mutex) { reservation.clear(); } - if (mutex->parts.m_order != mutex->parts.m_freed) + if (mutex->m_order != mutex->m_freed) { return CELL_SYNC_ERROR_BUSY; } - mutex->parts.m_order = mutex->parts.m_order + 1; + mutex->m_order = mutex->m_order + 1; return CELL_OK; } } @@ -154,7 +154,7 @@ int cellSyncMutexUnlock(mem_ptr_t mutex) { reservation.clear(); } - mutex->parts.m_freed = mutex->parts.m_freed + 1; + mutex->m_freed = mutex->m_freed + 1; return CELL_OK; } } diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp index a07403532a..64539b0002 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Lwcond.cpp @@ -86,11 +86,11 @@ int sys_lwcond_signal(mem_ptr_t lwcond) if (be_t target = (mutex->attribute.ToBE() == se32(SYS_SYNC_PRIORITY) ? sq->pop_prio() : sq->pop())) { - if (mutex->vars.parts.owner.trylock(target) != SMR_OK) + if (mutex->mutex.owner.trylock(target) != SMR_OK) { - mutex->vars.parts.owner.lock(tid); + mutex->mutex.owner.lock(tid); mutex->recursive_count = 1; - mutex->vars.parts.owner.unlock(tid, target); + mutex->mutex.owner.unlock(tid, target); } } @@ -122,11 +122,11 @@ int sys_lwcond_signal_all(mem_ptr_t lwcond) while (be_t target = (mutex->attribute.ToBE() == se32(SYS_SYNC_PRIORITY) ? sq->pop_prio() : sq->pop())) { - if (mutex->vars.parts.owner.trylock(target) != SMR_OK) + if (mutex->mutex.owner.trylock(target) != SMR_OK) { - mutex->vars.parts.owner.lock(tid); + mutex->mutex.owner.lock(tid); mutex->recursive_count = 1; - mutex->vars.parts.owner.unlock(tid, target); + mutex->mutex.owner.unlock(tid, target); } } @@ -163,11 +163,11 @@ int sys_lwcond_signal_to(mem_ptr_t lwcond, u32 ppu_thread_id) be_t target = ppu_thread_id; - if (mutex->vars.parts.owner.trylock(target) != SMR_OK) + if (mutex->mutex.owner.trylock(target) != SMR_OK) { - mutex->vars.parts.owner.lock(tid); + mutex->mutex.owner.lock(tid); mutex->recursive_count = 1; - mutex->vars.parts.owner.unlock(tid, target); + mutex->mutex.owner.unlock(tid, target); } if (Emu.IsStopped()) @@ -197,7 +197,7 @@ int sys_lwcond_wait(mem_ptr_t lwcond, u64 timeout) u32 tid_le = GetCurrentPPUThread().GetId(); be_t tid = tid_le; - if (mutex->vars.parts.owner.GetOwner() != tid) + if (mutex->mutex.owner.GetOwner() != tid) { return CELL_EPERM; // caller must own this lwmutex } @@ -205,7 +205,7 @@ int sys_lwcond_wait(mem_ptr_t lwcond, u64 timeout) sq->push(tid_le); mutex->recursive_count = 0; - mutex->vars.parts.owner.unlock(tid); + mutex->mutex.owner.unlock(tid); u32 counter = 0; const u32 max_counter = timeout ? (timeout / 1000) : ~0; @@ -216,7 +216,7 @@ int sys_lwcond_wait(mem_ptr_t lwcond, u64 timeout) case SMR_OK: mutex->unlock(tid); break; case SMR_SIGNAL: return CELL_OK; } */ - if (mutex->vars.parts.owner.GetOwner() == tid) + if (mutex->mutex.owner.GetOwner() == tid) { _mm_mfence(); mutex->recursive_count = 1; diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp index 872d2053f1..97de2549d0 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.cpp @@ -28,9 +28,9 @@ int sys_lwmutex_create(mem_ptr_t lwmutex, mem_ptr_tattribute = attr->attr_protocol | attr->attr_recursive; - lwmutex->vars.all_info = 0; - lwmutex->vars.all_info = 0; - lwmutex->vars.parts.owner.initialize(); + lwmutex->mutex.all_info() = 0; + lwmutex->mutex.all_info() = 0; + lwmutex->mutex.owner.initialize(); //lwmutex->waiter = lwmutex->owner.GetOwner(); lwmutex->pad = 0; lwmutex->recursive_count = 0; @@ -54,10 +54,10 @@ int sys_lwmutex_destroy(mem_ptr_t lwmutex) if (!Emu.GetIdManager().CheckID(sq_id)) return CELL_ESRCH; // try to make it unable to lock - switch (int res = lwmutex->trylock(lwmutex->vars.parts.owner.GetDeadValue())) + switch (int res = lwmutex->trylock(lwmutex->mutex.owner.GetDeadValue())) { case CELL_OK: - lwmutex->vars.all_info = 0; + lwmutex->mutex.all_info() = 0; lwmutex->attribute = 0; lwmutex->sleep_queue = 0; Emu.GetIdManager().RemoveID(sq_id); @@ -208,7 +208,7 @@ int sys_lwmutex_t::trylock(be_t tid) { if (!attribute.ToBE()) return CELL_EINVAL; - if (tid == vars.parts.owner.GetOwner()) + if (tid == mutex.owner.GetOwner()) { if (attribute.ToBE() & se32(SYS_SYNC_RECURSIVE)) { @@ -222,7 +222,7 @@ int sys_lwmutex_t::trylock(be_t tid) } } - switch (vars.parts.owner.trylock(tid)) + switch (mutex.owner.trylock(tid)) { case SMR_OK: recursive_count = 1; return CELL_OK; case SMR_FAILED: return CELL_EBUSY; @@ -232,7 +232,7 @@ int sys_lwmutex_t::trylock(be_t tid) int sys_lwmutex_t::unlock(be_t tid) { - if (tid != vars.parts.owner.GetOwner()) + if (tid != mutex.owner.GetOwner()) { return CELL_EPERM; } @@ -251,8 +251,8 @@ int sys_lwmutex_t::unlock(be_t tid) target = attribute.ToBE() & se32(SYS_SYNC_FIFO) ? sq->pop() : sq->pop_prio(); case se32(SYS_SYNC_RETRY): break; } - if (target) vars.parts.owner.unlock(tid, target); - else vars.parts.owner.unlock(tid); + if (target) mutex.owner.unlock(tid, target); + else mutex.owner.unlock(tid); } return CELL_OK; } @@ -277,7 +277,7 @@ int sys_lwmutex_t::lock(be_t tid, u64 timeout) default: break; } - switch (vars.parts.owner.lock(tid, timeout)) + switch (mutex.owner.lock(tid, timeout)) { case SMR_OK: sq->invalidate(tid); diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.h b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.h index f60a520ed8..24c4f30edb 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.h +++ b/rpcs3/Emu/SysCalls/lv2/SC_Lwmutex.h @@ -65,15 +65,13 @@ struct SleepQueue struct sys_lwmutex_t { - union sys_lwmutex_variable_t + struct sys_lwmutex_lock_info_t { - struct sys_lwmutex_lock_info_t - { - /* volatile */ SMutexBase, 0xffffffff, 0> owner; - /* volatile */ be_t waiter; // not used - }parts; - /* volatile */ be_t all_info; - }vars; + /* volatile */ SMutexBase, 0xffffffff, 0> owner; + /* volatile */ be_t waiter; // not used + u64 &all_info(){return *(reinterpret_cast(this)); + } + }mutex; be_t attribute; be_t recursive_count; be_t sleep_queue; diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 33c527fb92..f3ce2765ad 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -28,6 +28,7 @@ Emulator::Emulator() , m_dbg_console(nullptr) , m_rsx_callback(0) , m_ppu_callback_thr(0) + , m_event_manager(new EventManager()) { } diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index 603936d4bf..4887f4ef75 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -91,7 +91,7 @@ class Emulator AudioManager m_audio_manager; CallbackManager m_callback_manager; CPUThread* m_ppu_callback_thr; - EventManager &m_event_manager; + std::unique_ptr m_event_manager; VFS m_vfs; @@ -121,7 +121,7 @@ public: Array& GetBreakPoints() { return m_break_points; } Array& GetMarkedPoints() { return m_marked_points; } CPUThread& GetCallbackThread() { return *m_ppu_callback_thr; } - EventManager& GetEventManager() { return m_event_manager; } + EventManager& GetEventManager() { return *m_event_manager; } void AddModuleInit(ModuleInitializer* m) { From 7379b0e2ed1d770898dcd661092b2aeafcb3b523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandro=20S=C3=A1nchez=20Bach?= Date: Mon, 24 Feb 2014 07:54:42 +0100 Subject: [PATCH 08/10] Minor changes: GCM command, PKG loader & SysCalls * Fixed incorrect time displayed on NV4097_GET_REPORT. * Fixed small bug in PKGLoader::UnpackEntry * Moved some code in SC_Time.cpp * Auxiliary function declarations of SC_Time.cpp in SC_Time.h * Updated cellFsUnlink. *This won't work until ExistsFile is fully implemented*. --- rpcs3/Emu/GS/GCM.h | 1 + rpcs3/Emu/GS/RSXThread.cpp | 5 +++-- rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp | 15 ++++++++++--- rpcs3/Emu/SysCalls/lv2/SC_Time.cpp | 27 +++++++++++++----------- rpcs3/Emu/SysCalls/lv2/SC_Time.h | 4 ++++ rpcs3/Loader/PKG.cpp | 2 +- 6 files changed, 36 insertions(+), 18 deletions(-) create mode 100644 rpcs3/Emu/SysCalls/lv2/SC_Time.h diff --git a/rpcs3/Emu/GS/GCM.h b/rpcs3/Emu/GS/GCM.h index da9c068027..8494862523 100644 --- a/rpcs3/Emu/GS/GCM.h +++ b/rpcs3/Emu/GS/GCM.h @@ -1198,6 +1198,7 @@ static const wxString GetMethodName(const u32 id) { NV4097_SET_TRANSFORM_CONSTANT_LOAD , "SetTransformConstantLoad" } , { NV4097_SET_FREQUENCY_DIVIDER_OPERATION , "SetFrequencyDividerOperation" } , { NV4097_INVALIDATE_L2 , "InvalidateL2" } , + { NV4097_SET_TRANSFORM_BRANCH_BITS, "SetTransformBranchBits" } , }; for(u32 i = 0; i < WXSIZEOF(METHOD_NAME_LIST); ++i) diff --git a/rpcs3/Emu/GS/RSXThread.cpp b/rpcs3/Emu/GS/RSXThread.cpp index 7fb5238fb4..79ea127c73 100644 --- a/rpcs3/Emu/GS/RSXThread.cpp +++ b/rpcs3/Emu/GS/RSXThread.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "RSXThread.h" +#include "Emu/SysCalls/lv2/SC_Time.h" #define ARGS(x) (x >= count ? OutOfArgsCount(x, cmd, count) : Memory.Read32(Memory.RSXIOMem.GetStartAddr() + re(m_ctrl->get) + (4*(x+1)))) @@ -1195,8 +1196,8 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3 switch(type) { case 1: - data = std::chrono::steady_clock::now().time_since_epoch().count(); - data *= 1000000; + data = get_system_time(); + data *= 1000; // Microseconds to nanoseconds break; default: diff --git a/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp b/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp index e688a46d74..5a40ca84d6 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_FileSystem.cpp @@ -323,9 +323,18 @@ int cellFsUnlink(u32 path_addr) const wxString& ps3_path = Memory.ReadString(path_addr); sys_fs.Warning("cellFsUnlink(path=\"%s\")", ps3_path.wx_str()); - //wxString localPath; - //Emu.GetVFS().GetDevice(ps3_path, localPath); - //wxRemoveFile(localPath); + if (ps3_path.empty()) + return CELL_EFAULT; + + if (Emu.GetVFS().ExistsDir(ps3_path)) + return CELL_EISDIR; + + if (!Emu.GetVFS().ExistsFile(ps3_path)) + return CELL_ENOENT; + + if (!Emu.GetVFS().RemoveFile(ps3_path)) + return CELL_EACCES; + return CELL_OK; } diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Time.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Time.cpp index 764b47f71e..f8d2a3c148 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Time.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Time.cpp @@ -7,23 +7,14 @@ * */ #include "stdafx.h" #include "Emu/SysCalls/SysCalls.h" -#include +#include "SC_Time.h" SysCallBase sys_time("sys_time"); //static const u64 timebase_frequency = 79800000; extern int cellSysutilGetSystemParamInt(int id, mem32_t value); -int sys_time_get_timezone(mem32_t timezone, mem32_t summertime) -{ - int ret; - ret = cellSysutilGetSystemParamInt(0x0116, timezone); //0x0116 = CELL_SYSUTIL_SYSTEMPARAM_ID_TIMEZONE - if (ret != CELL_OK) return ret; - ret = cellSysutilGetSystemParamInt(0x0117, summertime); //0x0117 = CELL_SYSUTIL_SYSTEMPARAM_ID_TIMEZONE - if (ret != CELL_OK) return ret; - return CELL_OK; -} - +// Auxiliary functions u64 get_time() { #ifdef _WIN32 @@ -39,12 +30,24 @@ u64 get_time() #endif } +// Returns some relative time in microseconds, don't change this fact u64 get_system_time() { - // returns some relative time in microseconds, don't change this fact return get_time() / 10; } + +// Functions +int sys_time_get_timezone(mem32_t timezone, mem32_t summertime) +{ + int ret; + ret = cellSysutilGetSystemParamInt(0x0116, timezone); //0x0116 = CELL_SYSUTIL_SYSTEMPARAM_ID_TIMEZONE + if (ret != CELL_OK) return ret; + ret = cellSysutilGetSystemParamInt(0x0117, summertime); //0x0117 = CELL_SYSUTIL_SYSTEMPARAM_ID_TIMEZONE + if (ret != CELL_OK) return ret; + return CELL_OK; +} + int sys_time_get_current_time(u32 sec_addr, u32 nsec_addr) { sys_time.Log("sys_time_get_current_time(sec_addr=0x%x, nsec_addr=0x%x)", sec_addr, nsec_addr); diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Time.h b/rpcs3/Emu/SysCalls/lv2/SC_Time.h new file mode 100644 index 0000000000..4d5b326e74 --- /dev/null +++ b/rpcs3/Emu/SysCalls/lv2/SC_Time.h @@ -0,0 +1,4 @@ +#pragma once + +u64 get_time(); +u64 get_system_time(); diff --git a/rpcs3/Loader/PKG.cpp b/rpcs3/Loader/PKG.cpp index fba5988eb6..d55b1e5f95 100644 --- a/rpcs3/Loader/PKG.cpp +++ b/rpcs3/Loader/PKG.cpp @@ -150,7 +150,7 @@ bool PKGLoader::UnpackEntry(wxFile& dec, const PKGEntry& entry, std::string dir) dec.Read(buf, entry.name_size); buf[entry.name_size] = 0; - switch (entry.type & (0xffff)) + switch (entry.type & (0xff)) { case PKG_FILE_ENTRY_NPDRM: case PKG_FILE_ENTRY_NPDRMEDAT: From 2827db0e2a43b329c21fa4f8364feb302cd2fc87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandro=20S=C3=A1nchez=20Bach?= Date: Mon, 24 Feb 2014 17:03:47 +0100 Subject: [PATCH 09/10] Using be_t in some cellGcm structs & minor fixes * Using be_t in CellGcmControl, CellGcmConfig, CellGcmContextData and CellGcmTileInfo. * Fixed wrong names in Emu/SysCalls/Modules/sceNp.cpp * Fixed ConLog's mount info strings in System.cpp --- rpcs3/Emu/GS/GCM.h | 42 +++++++++++------------ rpcs3/Emu/GS/RSXThread.cpp | 14 ++++---- rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp | 33 +++++++++--------- rpcs3/Emu/SysCalls/Modules/sceNp.cpp | 8 ++--- rpcs3/Emu/SysCalls/lv2/SC_GCM.cpp | 8 ++--- rpcs3/Emu/System.cpp | 2 +- rpcs3/Gui/RSXDebugger.cpp | 4 +-- 7 files changed, 55 insertions(+), 56 deletions(-) diff --git a/rpcs3/Emu/GS/GCM.h b/rpcs3/Emu/GS/GCM.h index 8494862523..a4d97f8562 100644 --- a/rpcs3/Emu/GS/GCM.h +++ b/rpcs3/Emu/GS/GCM.h @@ -75,27 +75,27 @@ enum struct CellGcmControl { - u32 put; - u32 get; - u32 ref; + be_t put; + be_t get; + be_t ref; }; struct CellGcmConfig { - u32 localAddress; - u32 ioAddress; - u32 localSize; - u32 ioSize; - u32 memoryFrequency; - u32 coreFrequency; + be_t localAddress; + be_t ioAddress; + be_t localSize; + be_t ioSize; + be_t memoryFrequency; + be_t coreFrequency; }; struct CellGcmContextData { - u32 begin; - u32 end; - u32 current; - u32 callback; + be_t begin; + be_t end; + be_t current; + be_t callback; }; struct gcmInfo @@ -147,10 +147,10 @@ struct CellGcmZcullInfo struct CellGcmTileInfo { - u32 tile; - u32 limit; - u32 pitch; - u32 format; + be_t tile; + be_t limit; + be_t pitch; + be_t format; }; struct GcmZcullInfo @@ -194,10 +194,10 @@ struct GcmTileInfo { CellGcmTileInfo ret; - re(ret.tile, (m_location + 1) | (m_bank << 4) | ((m_offset / 0x10000) << 16) | (m_location << 31)); - re(ret.limit, ((m_offset + m_size - 1) / 0x10000) << 16 | (m_location << 31)); - re(ret.pitch, (m_pitch / 0x100) << 8); - re(ret.format, m_base | ((m_base + ((m_size - 1) / 0x10000)) << 13) | (m_comp << 26) | (1 << 30)); + ret.tile = (m_location + 1) | (m_bank << 4) | ((m_offset / 0x10000) << 16) | (m_location << 31); + ret.limit = ((m_offset + m_size - 1) / 0x10000) << 16 | (m_location << 31); + ret.pitch = (m_pitch / 0x100) << 8; + ret.format = m_base | ((m_base + ((m_size - 1) / 0x10000)) << 13) | (m_comp << 26) | (1 << 30); return ret; } diff --git a/rpcs3/Emu/GS/RSXThread.cpp b/rpcs3/Emu/GS/RSXThread.cpp index 79ea127c73..e46b81e32c 100644 --- a/rpcs3/Emu/GS/RSXThread.cpp +++ b/rpcs3/Emu/GS/RSXThread.cpp @@ -2,7 +2,7 @@ #include "RSXThread.h" #include "Emu/SysCalls/lv2/SC_Time.h" -#define ARGS(x) (x >= count ? OutOfArgsCount(x, cmd, count) : Memory.Read32(Memory.RSXIOMem.GetStartAddr() + re(m_ctrl->get) + (4*(x+1)))) +#define ARGS(x) (x >= count ? OutOfArgsCount(x, cmd, count) : Memory.Read32(Memory.RSXIOMem.GetStartAddr() + m_ctrl->get + (4*(x+1)))) u32 methodRegisters[0xffff]; @@ -208,7 +208,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t& args, const u3 break; case NV406E_SET_REFERENCE: - m_ctrl->ref = re32(ARGS(0)); + m_ctrl->ref = ARGS(0); break; case_16(NV4097_SET_TEXTURE_OFFSET, 0x20): @@ -1510,7 +1510,7 @@ void RSXThread::Task() { u32 addr = cmd & ~(CELL_GCM_METHOD_FLAG_JUMP | CELL_GCM_METHOD_FLAG_NON_INCREMENT); //ConLog.Warning("rsx jump(0x%x) #addr=0x%x, cmd=0x%x, get=0x%x, put=0x%x", addr, m_ioAddress + get, cmd, get, put); - re(m_ctrl->get, addr); + m_ctrl->get = addr; continue; } if(cmd & CELL_GCM_METHOD_FLAG_CALL) @@ -1519,7 +1519,7 @@ void RSXThread::Task() u32 offs = cmd & ~CELL_GCM_METHOD_FLAG_CALL; u32 addr = Memory.RSXIOMem.GetStartAddr() + offs; //ConLog.Warning("rsx call(0x%x) #0x%x - 0x%x - 0x%x", offs, addr, cmd, get); - m_ctrl->get = re32(offs); + m_ctrl->get = offs; continue; } if(cmd == CELL_GCM_METHOD_FLAG_RETURN) @@ -1527,7 +1527,7 @@ void RSXThread::Task() //ConLog.Warning("rsx return!"); u32 get = m_call_stack.Pop(); //ConLog.Warning("rsx return(0x%x)", get); - m_ctrl->get = re32(get); + m_ctrl->get = get; continue; } if(cmd & CELL_GCM_METHOD_FLAG_NON_INCREMENT) @@ -1538,7 +1538,7 @@ void RSXThread::Task() if(cmd == 0) { - ConLog.Warning("null cmd: addr=0x%x, put=0x%x, get=0x%x", Memory.RSXIOMem.GetStartAddr() + get, re(m_ctrl->put), get); + ConLog.Warning("null cmd: addr=0x%x, put=0x%x, get=0x%x", Memory.RSXIOMem.GetStartAddr() + get, m_ctrl->put, get); Emu.Pause(); continue; } @@ -1551,7 +1551,7 @@ void RSXThread::Task() mem32_ptr_t args(Memory.RSXIOMem.GetStartAddr() + get + 4); DoCmd(cmd, cmd & 0x3ffff, args, count); - re(m_ctrl->get, get + (count + 1) * 4); + m_ctrl->get = get + (count + 1) * 4; //memset(Memory.GetMemFromAddr(p.m_ioAddress + get), 0, (count + 1) * 4); } diff --git a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp index 99927ac4d1..6133a6b111 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp @@ -70,12 +70,12 @@ int cellGcmInit(u32 context_addr, u32 cmdSize, u32 ioSize, u32 ioAddress) map_offset_addr = 0; map_offset_pos = 0; - current_config.ioSize = re32(ioSize); - current_config.ioAddress = re32(ioAddress); - current_config.localSize = re32(local_size); - current_config.localAddress = re32(local_addr); - current_config.memoryFrequency = re32(650000000); - current_config.coreFrequency = re32(500000000); + current_config.ioSize = ioSize; + current_config.ioAddress = ioAddress; + current_config.localSize = local_size; + current_config.localAddress = local_addr; + current_config.memoryFrequency = 650000000; + current_config.coreFrequency = 500000000; InitOffsetTable(); Memory.RSXCMDMem.AllocAlign(cmdSize); @@ -84,10 +84,10 @@ int cellGcmInit(u32 context_addr, u32 cmdSize, u32 ioSize, u32 ioAddress) u32 ctx_begin = ioAddress/* + 0x1000*/; u32 ctx_size = 0x6ffc; - current_context.begin = re(ctx_begin); - current_context.end = re(ctx_begin + ctx_size); + current_context.begin = ctx_begin; + current_context.end = ctx_begin + ctx_size; current_context.current = current_context.begin; - current_context.callback = re32(Emu.GetRSXCallback() - 4); + current_context.callback = Emu.GetRSXCallback() - 4; gcm_info.context_addr = Memory.MainMem.AllocAlign(0x1000); gcm_info.control_addr = gcm_info.context_addr + 0x40; @@ -169,8 +169,8 @@ int cellGcmSetPrepareFlip(mem_ptr_t ctxt, u32 id) GSLockCurrent gslock(GS_LOCK_WAIT_FLUSH); // could stall on exit - u32 current = re(ctxt->current); - u32 end = re(ctxt->end); + u32 current = ctxt->current; + u32 end = ctxt->end; if(current + 8 >= end) { @@ -178,15 +178,15 @@ int cellGcmSetPrepareFlip(mem_ptr_t ctxt, u32 id) cellGcmCallback(ctxt.GetAddr(), current + 8 - end); } - current = re(ctxt->current); + current = ctxt->current; Memory.Write32(current, 0x3fead | (1 << 18)); Memory.Write32(current + 4, id); - re(ctxt->current, current + 8); + ctxt->current += 8; if(ctxt.GetAddr() == gcm_info.context_addr) { CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr]; - re(ctrl.put, re(ctrl.put) + 8); + ctrl.put += 8; } return id; @@ -416,7 +416,8 @@ int cellGcmSetTile(u8 index, u8 location, u32 offset, u32 size, u32 pitch, u8 co { cellGcmSys.Warning("cellGcmSetTile(index=%d, location=%d, offset=%d, size=%d, pitch=%d, comp=%d, base=%d, bank=%d)", index, location, offset, size, pitch, comp, base, bank); - //copied form cellGcmSetTileInfo + + // Copied form cellGcmSetTileInfo if(index >= RSXThread::m_tiles_count || base >= 800 || bank >= 4) { return CELL_GCM_ERROR_INVALID_VALUE; @@ -434,7 +435,7 @@ int cellGcmSetTile(u8 index, u8 location, u32 offset, u32 size, u32 pitch, u8 co if(comp) { - cellGcmSys.Error("cellGcmSetTileInfo: bad comp! (%d)", comp); + cellGcmSys.Error("cellGcmSetTile: bad comp! (%d)", comp); } auto& tile = Emu.GetGSManager().GetRender().m_tiles[index]; diff --git a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp index 8f3960e36d..5b6a955daf 100644 --- a/rpcs3/Emu/SysCalls/Modules/sceNp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/sceNp.cpp @@ -5,12 +5,10 @@ #include "sceNp.h" -void sceNpTrophy_init(); -Module sceNp(0x0016, sceNpTrophy_init); +void sceNp_init(); +Module sceNp(0x0016, sceNp_init); -void sceNpTrophy_init() +void sceNp_init() { } #endif - - diff --git a/rpcs3/Emu/SysCalls/lv2/SC_GCM.cpp b/rpcs3/Emu/SysCalls/lv2/SC_GCM.cpp index cd29d5e144..520883fecf 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_GCM.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_GCM.cpp @@ -12,13 +12,13 @@ int cellGcmCallback(u32 context_addr, u32 count) CellGcmContextData& ctx = (CellGcmContextData&)Memory[context_addr]; CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr]; - const s32 res = re(ctx.current) - re(ctx.begin) - re(ctrl.put); + const s32 res = ctx.current - ctx.begin - ctrl.put; - if(res > 0) memcpy(&Memory[re(ctx.begin)], &Memory[re(ctx.current) - res], res); + if(res > 0) memcpy(&Memory[ctx.begin], &Memory[ctx.current - res], res); - ctx.current = re(re(ctx.begin) + res); + ctx.current = ctx.begin + res; - ctrl.put = re(res); + ctrl.put = res; ctrl.get = 0; return CELL_OK; diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index f3ce2765ad..e1d1e51a06 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -217,7 +217,7 @@ void Emulator::Load() ConLog.Write("Mount info:"); for(uint i=0; i %s", static_cast(m_vfs.m_devices[i].GetPs3Path()), static_cast(m_vfs.m_devices[i].GetLocalPath().ToAscii())); + ConLog.Write("%s -> %s", m_vfs.m_devices[i].GetPs3Path().wx_str(), m_vfs.m_devices[i].GetLocalPath().wx_str()); } ConLog.SkipLn(); diff --git a/rpcs3/Gui/RSXDebugger.cpp b/rpcs3/Gui/RSXDebugger.cpp index 7d7340364f..7a69ac0793 100644 --- a/rpcs3/Gui/RSXDebugger.cpp +++ b/rpcs3/Gui/RSXDebugger.cpp @@ -322,7 +322,7 @@ void RSXDebugger::GoToGet(wxCommandEvent& event) { if (!RSXReady()) return; CellGcmControl* ctrl = (CellGcmControl*)&Memory[Emu.GetGSManager().GetRender().m_ctrlAddress]; - m_addr = Memory.RSXIOMem.getRealAddr(Memory.RSXIOMem.GetStartAddr() + re(ctrl->get)); + m_addr = Memory.RSXIOMem.getRealAddr(Memory.RSXIOMem.GetStartAddr() + ctrl->get); t_addr->SetValue(wxString::Format("%08x", m_addr)); UpdateInformation(); event.Skip(); @@ -332,7 +332,7 @@ void RSXDebugger::GoToPut(wxCommandEvent& event) { if (!RSXReady()) return; CellGcmControl* ctrl = (CellGcmControl*)&Memory[Emu.GetGSManager().GetRender().m_ctrlAddress]; - m_addr = Memory.RSXIOMem.getRealAddr(Memory.RSXIOMem.GetStartAddr() + re(ctrl->put)); + m_addr = Memory.RSXIOMem.getRealAddr(Memory.RSXIOMem.GetStartAddr() + ctrl->put); t_addr->SetValue(wxString::Format("%08x", m_addr)); UpdateInformation(); event.Skip(); From 681c3c53f00efe477288e09b998430de733f91c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandro=20S=C3=A1nchez=20Bach?= Date: Tue, 25 Feb 2014 14:09:44 +0100 Subject: [PATCH 10/10] cellPad modifications * Using be_t on cellPad structs. * Swapped Square and Circle default keys (they were inverted). --- rpcs3/Emu/SysCalls/lv2/SC_Pad.cpp | 102 +++++++++++++++--------------- rpcs3/Ini.h | 4 +- 2 files changed, 53 insertions(+), 53 deletions(-) diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Pad.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Pad.cpp index e4259ab0f1..54a786ba13 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Pad.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Pad.cpp @@ -20,29 +20,29 @@ enum CELL_PAD_ERROR_CODE struct CellPadData { - s32 len; - u16 button[CELL_PAD_MAX_CODES]; + be_t len; + be_t button[CELL_PAD_MAX_CODES]; }; struct CellPadInfo { - u32 max_connect; - u32 now_connect; - u32 system_info; - u16 vendor_id[CELL_MAX_PADS]; - u16 product_id[CELL_MAX_PADS]; - u8 status[CELL_MAX_PADS]; + be_t max_connect; + be_t now_connect; + be_t system_info; + be_t vendor_id[CELL_MAX_PADS]; + be_t product_id[CELL_MAX_PADS]; + u8 status[CELL_MAX_PADS]; }; struct CellPadInfo2 { - u32 max_connect; - u32 now_connect; - u32 system_info; - u32 port_status[CELL_PAD_MAX_PORT_NUM]; - u32 port_setting[CELL_PAD_MAX_PORT_NUM]; - u32 device_capability[CELL_PAD_MAX_PORT_NUM]; - u32 device_type[CELL_PAD_MAX_PORT_NUM]; + be_t max_connect; + be_t now_connect; + be_t system_info; + be_t port_status[CELL_PAD_MAX_PORT_NUM]; + be_t port_setting[CELL_PAD_MAX_PORT_NUM]; + be_t device_capability[CELL_PAD_MAX_PORT_NUM]; + be_t device_type[CELL_PAD_MAX_PORT_NUM]; }; int cellPadInit(u32 max_connect) @@ -130,29 +130,29 @@ int cellPadGetData(u32 port_no, u32 data_addr) *res = 0; } - data.len = re(len); - data.button[CELL_PAD_BTN_OFFSET_DIGITAL1] = re(d1); - data.button[CELL_PAD_BTN_OFFSET_DIGITAL2] = re(d2); - data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X] = re(rx); - data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y] = re(ry); - data.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X] = re(lx); - data.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y] = re(ly); - data.button[CELL_PAD_BTN_OFFSET_PRESS_RIGHT] = re(pad.m_press_right); - data.button[CELL_PAD_BTN_OFFSET_PRESS_LEFT] = re(pad.m_press_left); - data.button[CELL_PAD_BTN_OFFSET_PRESS_UP] = re(pad.m_press_up); - data.button[CELL_PAD_BTN_OFFSET_PRESS_DOWN] = re(pad.m_press_down); - data.button[CELL_PAD_BTN_OFFSET_PRESS_TRIANGLE] = re(pad.m_press_triangle); - data.button[CELL_PAD_BTN_OFFSET_PRESS_CIRCLE] = re(pad.m_press_circle); - data.button[CELL_PAD_BTN_OFFSET_PRESS_CROSS] = re(pad.m_press_cross); - data.button[CELL_PAD_BTN_OFFSET_PRESS_SQUARE] = re(pad.m_press_square); - data.button[CELL_PAD_BTN_OFFSET_PRESS_L1] = re(pad.m_press_L1); - data.button[CELL_PAD_BTN_OFFSET_PRESS_L2] = re(pad.m_press_L2); - data.button[CELL_PAD_BTN_OFFSET_PRESS_R1] = re(pad.m_press_R1); - data.button[CELL_PAD_BTN_OFFSET_PRESS_R2] = re(pad.m_press_R2); - data.button[CELL_PAD_BTN_OFFSET_SENSOR_X] = re(pad.m_sensor_x); - data.button[CELL_PAD_BTN_OFFSET_SENSOR_Y] = re(pad.m_sensor_y); - data.button[CELL_PAD_BTN_OFFSET_SENSOR_Z] = re(pad.m_sensor_z); - data.button[CELL_PAD_BTN_OFFSET_SENSOR_G] = re(pad.m_sensor_g); + data.len = len; + data.button[CELL_PAD_BTN_OFFSET_DIGITAL1] = d1; + data.button[CELL_PAD_BTN_OFFSET_DIGITAL2] = d2; + data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X] = rx; + data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y] = ry; + data.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X] = lx; + data.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y] = ly; + data.button[CELL_PAD_BTN_OFFSET_PRESS_RIGHT] = pad.m_press_right; + data.button[CELL_PAD_BTN_OFFSET_PRESS_LEFT] = pad.m_press_left; + data.button[CELL_PAD_BTN_OFFSET_PRESS_UP] = pad.m_press_up; + data.button[CELL_PAD_BTN_OFFSET_PRESS_DOWN] = pad.m_press_down; + data.button[CELL_PAD_BTN_OFFSET_PRESS_TRIANGLE] = pad.m_press_triangle; + data.button[CELL_PAD_BTN_OFFSET_PRESS_CIRCLE] = pad.m_press_circle; + data.button[CELL_PAD_BTN_OFFSET_PRESS_CROSS] = pad.m_press_cross; + data.button[CELL_PAD_BTN_OFFSET_PRESS_SQUARE] = pad.m_press_square; + data.button[CELL_PAD_BTN_OFFSET_PRESS_L1] = pad.m_press_L1; + data.button[CELL_PAD_BTN_OFFSET_PRESS_L2] = pad.m_press_L2; + data.button[CELL_PAD_BTN_OFFSET_PRESS_R1] = pad.m_press_R1; + data.button[CELL_PAD_BTN_OFFSET_PRESS_R2] = pad.m_press_R2; + data.button[CELL_PAD_BTN_OFFSET_SENSOR_X] = pad.m_sensor_x; + data.button[CELL_PAD_BTN_OFFSET_SENSOR_Y] = pad.m_sensor_y; + data.button[CELL_PAD_BTN_OFFSET_SENSOR_Z] = pad.m_sensor_z; + data.button[CELL_PAD_BTN_OFFSET_SENSOR_G] = pad.m_sensor_g; Memory.WriteData(data_addr, data); @@ -184,9 +184,9 @@ int cellPadGetInfo(u32 info_addr) memset(&info, 0, sizeof(CellPadInfo)); const PadInfo& rinfo = Emu.GetPadManager().GetInfo(); - info.max_connect = re(rinfo.max_connect); - info.now_connect = re(rinfo.now_connect); - info.system_info = re(rinfo.system_info); + info.max_connect = rinfo.max_connect; + info.now_connect = rinfo.now_connect; + info.system_info = rinfo.system_info; const Array& pads = Emu.GetPadManager().GetPads(); @@ -194,9 +194,9 @@ int cellPadGetInfo(u32 info_addr) { if(i >= pads.GetCount()) break; - re(info.status[i], pads[i].m_port_status); - info.product_id[i] = const_se_t::value; - info.vendor_id[i] = const_se_t::value; + info.status[i] = pads[i].m_port_status; + info.product_id[i] = 0x0268; + info.vendor_id[i] = 0x054C; } Memory.WriteData(info_addr, info); @@ -213,19 +213,19 @@ int cellPadGetInfo2(u32 info_addr) memset(&info, 0, sizeof(CellPadInfo2)); const PadInfo& rinfo = Emu.GetPadManager().GetInfo(); - info.max_connect = re(rinfo.max_connect); - info.now_connect = re(rinfo.now_connect); - info.system_info = re(rinfo.system_info); + info.max_connect = rinfo.max_connect; + info.now_connect = rinfo.now_connect; + info.system_info = rinfo.system_info; const Array& pads = Emu.GetPadManager().GetPads(); for(u32 i=0; i= pads.GetCount()) break; - info.port_status[i] = re(pads[i].m_port_status); - info.port_setting[i] = re(pads[i].m_port_setting); - info.device_capability[i] = re(pads[i].m_device_capability); - info.device_type[i] = re(pads[i].m_device_type); + info.port_status[i] = pads[i].m_port_status; + info.port_setting[i] = pads[i].m_port_setting; + info.device_capability[i] = pads[i].m_device_capability; + info.device_type[i] = pads[i].m_device_type; } Memory.WriteData(info_addr, info); diff --git a/rpcs3/Ini.h b/rpcs3/Ini.h index dcfdee1176..db7ec83fb2 100644 --- a/rpcs3/Ini.h +++ b/rpcs3/Ini.h @@ -200,9 +200,9 @@ public: PadHandlerR3.Load(static_cast('C')); PadHandlerL3.Load(static_cast('Z')); PadHandlerSelect.Load(0); - PadHandlerSquare.Load(static_cast('L')); + PadHandlerSquare.Load(static_cast('J')); PadHandlerCross.Load(static_cast('K')); - PadHandlerCircle.Load(static_cast('J')); + PadHandlerCircle.Load(static_cast('L')); PadHandlerTriangle.Load(static_cast('I')); PadHandlerR1.Load(static_cast('3')); PadHandlerL1.Load(static_cast('1'));