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();