diff --git a/.travis.yml b/.travis.yml index 4866b49c1d..f34b33dfcf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,13 +19,12 @@ before_install: - sudo apt-get install libwxgtk3.0-dev libopenal-dev freeglut3-dev libglew-dev - sudo apt-get install aria2 -qq - download_extract() { aria2c -x 16 $1 -o $2 && tar -xf $2; } + - if [ "$CXX" = "g++" ]; then sudo apt-get install -qq g++-4.8; export CXX="g++-4.8" CC="gcc-4.8"; else sudo apt-get install libstdc++-4.8-dev; fi # Travis uses CMake 2.8.7. We require 2.8.8. Grab latest - - sudo apt-get install -qq g++-4.8 - - if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi - sudo apt-get install lib32stdc++6 -qq && - aria2c -x 16 http://www.cmake.org/files/v2.8/cmake-2.8.12.1-Linux-i386.sh && - chmod a+x cmake-2.8.12.1-Linux-i386.sh && - sudo ./cmake-2.8.12.1-Linux-i386.sh --skip-license --prefix=/usr; + aria2c -x 16 http://www.cmake.org/files/v3.0/cmake-3.0.0-Linux-i386.sh && + chmod a+x cmake-3.0.0-Linux-i386.sh && + sudo ./cmake-3.0.0-Linux-i386.sh --skip-license --prefix=/usr; before_script: - git submodule update --init asmjit ffmpeg diff --git a/CMakeLists.txt b/CMakeLists.txt index bfb3c82402..3abe8d579a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,5 +2,14 @@ cmake_minimum_required(VERSION 2.8) set(ASMJIT_STATIC TRUE) +if (NOT CMAKE_BUILD_TYPE) + message(STATUS "No build type selected, default to Release") + set(CMAKE_BUILD_TYPE "Release") +endif() + +if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8) + message( FATAL_ERROR "RPCS3 can only be compiled on 64-bit platforms." ) +endif() + add_subdirectory( asmjit ) add_subdirectory( rpcs3 ) diff --git a/Utilities/Log.cpp b/Utilities/Log.cpp index 7f6b68fcb4..8361dcbf9d 100644 --- a/Utilities/Log.cpp +++ b/Utilities/Log.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" +#include "rPlatform.h" #include "Log.h" #include #include @@ -98,7 +99,7 @@ struct FileListener : LogListener bool mPrependChannelName; FileListener(const std::string& name = _PRGNAME_, bool prependChannel = true) - : mFile(name + ".log", rFile::write), + : mFile(std::string(rPlatform::getConfigDir() + name + ".log").c_str(), rFile::write), mPrependChannelName(prependChannel) { if (!mFile.IsOpened()) @@ -236,4 +237,4 @@ LogManager& LogManager::getInstance() LogChannel &LogManager::getChannel(LogType type) { return mChannels[static_cast(type)]; -} \ No newline at end of file +} diff --git a/Utilities/SMutex.h b/Utilities/SMutex.h index fb29087c6b..a769fe5469 100644 --- a/Utilities/SMutex.h +++ b/Utilities/SMutex.h @@ -1,5 +1,6 @@ #pragma once #include "BEType.h" +#include "Emu/System.h" extern void SM_Sleep(); extern size_t SM_GetCurrentThreadId(); diff --git a/Utilities/rPlatform.cpp b/Utilities/rPlatform.cpp index 60144f5001..d6729c718b 100644 --- a/Utilities/rPlatform.cpp +++ b/Utilities/rPlatform.cpp @@ -15,6 +15,10 @@ #include "Emu/Io/XInput/XInputPadHandler.h" #endif +#ifndef _WIN32 +#include +#endif + rCanvas::rCanvas(void *parent) { @@ -135,6 +139,27 @@ int rPlatform::getMouseHandlerCount() return 2; } +std::string rPlatform::getConfigDir() +{ + static std::string dir = "."; + if (dir == ".") { +#ifdef _WIN32 + dir = ""; + //mkdir(dir.c_str()); +#else + if (getenv("XDG_CONFIG_HOME") != NULL) + dir = getenv("XDG_CONFIG_HOME"); + else if (getenv("HOME") != NULL) + dir = getenv("HOME") + std::string("/.config"); + else // Just in case + dir = "./config"; + dir = dir + "/rpcs3/"; + mkdir(dir.c_str()); +#endif + } + return dir; +} + MouseHandlerBase *rPlatform::getMouseHandler(int i) { @@ -179,4 +204,4 @@ PadHandlerBase *rPlatform::getPadHandler(int i) default: return new NullPadHandler(); } -} \ No newline at end of file +} diff --git a/Utilities/rPlatform.h b/Utilities/rPlatform.h index 8d8edfca98..c5b1beab3f 100644 --- a/Utilities/rPlatform.h +++ b/Utilities/rPlatform.h @@ -46,6 +46,7 @@ struct rPlatform static MouseHandlerBase *getMouseHandler(int i); static int getPadHandlerCount(); static PadHandlerBase *getPadHandler(int i); + static std::string getConfigDir(); }; /********************************************************************** diff --git a/rpcs3/CMakeLists.txt b/rpcs3/CMakeLists.txt index ae72e0f56b..956b612d2b 100644 --- a/rpcs3/CMakeLists.txt +++ b/rpcs3/CMakeLists.txt @@ -7,22 +7,27 @@ project(rpcs3) if (CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7.0) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + message(FATAL_ERROR "GCC ${CMAKE_CXX_COMPILER_VERSION} is too old.") endif() - add_definitions(-DwxGUI) - #add_definitions(-D__WXGTK__) - #add_definitions(-Wfatal-errors) - add_definitions(-w) # TODO: remove me - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions") - add_definitions(-fpermissive) # TODO: remove me - add_definitions(-g) # Debugging!! - add_definitions(-msse2) + # Warnings + add_definitions(-Wno-attributes -Wno-enum-compare) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof") elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + # TODO: stdlib? +endif() + +if (NOT MSVC) add_definitions(-DwxGUI) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fexceptions") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -D_DEBUG") + set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -D_NDEBUG") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O1 -D_NDEBUG") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O1 -g -D_NDEBUG") + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -D_DEBUG") + set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -Os -D_NDEBUG") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O1 -D_NDEBUG") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O1 -g -D_NDEBUG") + add_definitions(-msse2) endif() If( NOT RPCS3_SRC_DIR) @@ -48,11 +53,6 @@ find_package(OpenAL REQUIRED) include("${wxWidgets_USE_FILE}") -if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8) - message( FATAL_ERROR "RPCS3 can only be compiled on 64-bit platforms." ) -endif() - - if(APPLE) set(PLATFORM_ARCH "macosx/x86_64") elseif(WIN32) diff --git a/rpcs3/Emu/Audio/AL/OpenALThread.cpp b/rpcs3/Emu/Audio/AL/OpenALThread.cpp index 705df90f71..9ed92f04e3 100644 --- a/rpcs3/Emu/Audio/AL/OpenALThread.cpp +++ b/rpcs3/Emu/Audio/AL/OpenALThread.cpp @@ -1,7 +1,5 @@ #include "stdafx.h" #include "Utilities/Log.h" -#include "Emu/Memory/Memory.h" -#include "Emu/System.h" #include "rpcs3/Ini.h" #include "OpenALThread.h" diff --git a/rpcs3/Emu/Cell/SPUThread.h b/rpcs3/Emu/Cell/SPUThread.h index cd98ac713e..3df6c315a1 100644 --- a/rpcs3/Emu/Cell/SPUThread.h +++ b/rpcs3/Emu/Cell/SPUThread.h @@ -310,7 +310,7 @@ class SPUThread : public PPCThread public: SPU_GPR_hdr GPR[128]; //General-Purpose Register SPU_SPR_hdr SPR[128]; //Special-Purpose Registers - FPSCR FPSCR; +// FPSCR fpscr; //Unused SPU_SNRConfig_hdr cfg; //Signal Notification Registers Configuration (OR-mode enabled: 0x1 for SNR1, 0x2 for SNR2) EventPort SPUPs[64]; // SPU Thread Event Ports diff --git a/rpcs3/Emu/DbgCommand.cpp b/rpcs3/Emu/DbgCommand.cpp index 211195e1cf..adc4b58bfe 100644 --- a/rpcs3/Emu/DbgCommand.cpp +++ b/rpcs3/Emu/DbgCommand.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" +#include "rpcs3.h" void SendDbgCommand(DbgCommand id, CPUThread* thr ) { wxGetApp().SendDbgCommand(id, thr); -} \ No newline at end of file +} diff --git a/rpcs3/Emu/GS/GCM.h b/rpcs3/Emu/GS/GCM.h index 1b444ae079..5c766ebf46 100644 --- a/rpcs3/Emu/GS/GCM.h +++ b/rpcs3/Emu/GS/GCM.h @@ -1330,10 +1330,8 @@ static const std::string GetMethodName(const u32 id) { NV4097_SET_TRANSFORM_BRANCH_BITS, "SetTransformBranchBits" } , }; - for (u32 i = 0; i < SARRSIZEOF(METHOD_NAME_LIST); ++i) - { - if(METHOD_NAME_LIST[i].id == id) return "cellGcm" + METHOD_NAME_LIST[i].name; - } + for(auto& s: METHOD_NAME_LIST) + if(s.id == id) return "cellGcm" + s.name; return fmt::Format("unknown/illegal method [0x%08x]", id); } diff --git a/rpcs3/Emu/GS/GL/GLBuffers.cpp b/rpcs3/Emu/GS/GL/GLBuffers.cpp index 41ddddf619..9dd2d35f76 100644 --- a/rpcs3/Emu/GS/GL/GLBuffers.cpp +++ b/rpcs3/Emu/GS/GL/GLBuffers.cpp @@ -67,11 +67,11 @@ void GLBufferObject::SetData(const void* data, u32 size, u32 usage) SetData(m_type, data, size, usage); } -void GLBufferObject::SetAttribPointer(int location, int size, int type, int pointer, int stride, bool normalized) +void GLBufferObject::SetAttribPointer(int location, int size, int type, GLvoid* pointer, int stride, bool normalized) { if(location < 0) return; - glVertexAttribPointer(location, size, type, normalized ? GL_TRUE : GL_FALSE, stride, (const GLvoid*)pointer); + glVertexAttribPointer(location, size, type, normalized ? GL_TRUE : GL_FALSE, stride, pointer); glEnableVertexAttribArray(location); } diff --git a/rpcs3/Emu/GS/GL/GLBuffers.h b/rpcs3/Emu/GS/GL/GLBuffers.h index dfd58a8595..659365d29b 100644 --- a/rpcs3/Emu/GS/GL/GLBuffers.h +++ b/rpcs3/Emu/GS/GL/GLBuffers.h @@ -21,7 +21,7 @@ public: void UnBind(); void SetData(u32 type, const void* data, u32 size, u32 usage = GL_DYNAMIC_DRAW); void SetData(const void* data, u32 size, u32 usage = GL_DYNAMIC_DRAW); - void SetAttribPointer(int location, int size, int type, int pointer, int stride, bool normalized = false); + void SetAttribPointer(int location, int size, int type, GLvoid* pointer, int stride, bool normalized = false); bool IsCreated() const; }; diff --git a/rpcs3/Emu/GS/GL/GLGSRender.cpp b/rpcs3/Emu/GS/GL/GLGSRender.cpp index 8022d6864e..e7a86654e0 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.cpp +++ b/rpcs3/Emu/GS/GL/GLGSRender.cpp @@ -54,7 +54,7 @@ GLGSRender::GLGSRender() GLGSRender::~GLGSRender() { m_frame->Close(); - delete m_context; +// delete m_context; // This won't do anything (deleting void* instead of wglContext*) } void GLGSRender::Enable(bool enable, const u32 cap) @@ -249,7 +249,7 @@ void GLGSRender::EnableVertexData(bool indexed_draw) glEnableVertexAttribArray(i); checkForGlError("glEnableVertexAttribArray"); - glVertexAttribPointer(i, m_vertex_data[i].size, gltype, normalized, 0, (void*)offset_list[i]); + glVertexAttribPointer(i, m_vertex_data[i].size, gltype, normalized, 0, reinterpret_cast(offset_list[i])); checkForGlError("glVertexAttribPointer"); } } @@ -1016,21 +1016,18 @@ void GLGSRender::ExecCMD() if(m_set_depth_func) { - //ConLog.Warning("glDepthFunc(0x%x)", m_depth_func); glDepthFunc(m_depth_func); checkForGlError("glDepthFunc"); } if(m_set_depth_bounds) { - //ConLog.Warning("glDepthBounds(%f, %f)", m_depth_bounds_min, m_depth_bounds_max); glDepthBoundsEXT(m_depth_bounds_min, m_depth_bounds_max); checkForGlError("glDepthBounds"); } if(m_set_clip) { - //ConLog.Warning("glDepthRangef(%f, %f)", m_clip_min, m_clip_max); glDepthRangef(m_clip_min, m_clip_max); checkForGlError("glDepthRangef"); } @@ -1083,7 +1080,7 @@ void GLGSRender::ExecCMD() checkForGlError("glFrontFace"); } - if(m_set_alpha_func && m_set_alpha_ref && m_alpha_func) + if(m_set_alpha_func && m_set_alpha_ref) { glAlphaFunc(m_alpha_func, m_alpha_ref); checkForGlError("glAlphaFunc"); diff --git a/rpcs3/Emu/GS/GL/GLGSRender.h b/rpcs3/Emu/GS/GL/GLGSRender.h index b3bca78d01..c2ad1a82b0 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.h +++ b/rpcs3/Emu/GS/GL/GLGSRender.h @@ -1,6 +1,7 @@ #pragma once #include "Emu/GS/GSRender.h" #include "Emu/GS/RSXThread.h" +#include "Utilities/rPlatform.h" #include "GLBuffers.h" #include "GLProgramBuffer.h" diff --git a/rpcs3/Emu/GS/GL/GLVertexProgram.cpp b/rpcs3/Emu/GS/GL/GLVertexProgram.cpp index cc6f14312e..82f08dc5b7 100644 --- a/rpcs3/Emu/GS/GL/GLVertexProgram.cpp +++ b/rpcs3/Emu/GS/GL/GLVertexProgram.cpp @@ -77,7 +77,7 @@ std::string GLVertexDecompilerThread::GetSRC(const u32 n) ret += m_parr.AddParam(PARAM_NONE, "vec4", "tmp" + std::to_string(src[n].tmp_src)); break; case 2: //input - if (d1.input_src < SARRSIZEOF(reg_table)) + if (d1.input_src < (sizeof(reg_table)/sizeof(reg_table[0]))) { ret += m_parr.AddParam(PARAM_IN, "vec4", reg_table[d1.input_src], d1.input_src); } diff --git a/rpcs3/Emu/GS/GSManager.h b/rpcs3/Emu/GS/GSManager.h index bb00909f73..08f424a9a9 100644 --- a/rpcs3/Emu/GS/GSManager.h +++ b/rpcs3/Emu/GS/GSManager.h @@ -1,6 +1,7 @@ #pragma once #include "sysutil_video.h" #include "GSRender.h" +#include "rpcs3/Ini.h" struct GSInfo { @@ -58,4 +59,4 @@ public: u8 GetState(); u8 GetColorSpace(); -}; \ No newline at end of file +}; diff --git a/rpcs3/Emu/GS/RSXThread.cpp b/rpcs3/Emu/GS/RSXThread.cpp index 473b9e0464..1172b627ec 100644 --- a/rpcs3/Emu/GS/RSXThread.cpp +++ b/rpcs3/Emu/GS/RSXThread.cpp @@ -1284,7 +1284,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t args, const u32 } break; - // Point + // Point size case NV4097_SET_POINT_SIZE: { m_set_point_size = true; @@ -1293,10 +1293,11 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t args, const u32 } break; + // Point sprite case NV4097_SET_POINT_PARAMS_ENABLE: { if (ARGS(0)) - LOG_ERROR(RSX, "NV4097_SET_POINT_PARAMS_ENABLE"); + LOG_ERROR(RSX, "NV4097_SET_POINT_PARAMS_ENABLE: %x", ARGS(0)); } break; @@ -1340,7 +1341,7 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t args, const u32 } break; - // Depth/ Color buffer usage + // Depth/Color buffer usage case NV4097_SET_SURFACE_FORMAT: { const u32 a0 = ARGS(0); diff --git a/rpcs3/Emu/GS/RSXThread.h b/rpcs3/Emu/GS/RSXThread.h index e776af2214..8444083d93 100644 --- a/rpcs3/Emu/GS/RSXThread.h +++ b/rpcs3/Emu/GS/RSXThread.h @@ -4,6 +4,7 @@ #include "RSXVertexProgram.h" #include "RSXFragmentProgram.h" #include "Emu/SysCalls/Callback.h" +#include "Emu/Memory/Memory.h" #include #include // For tracking a list of used gcm commands @@ -466,24 +467,39 @@ protected: m_set_line_stipple = false; m_set_polygon_stipple = false; + // Default value + // TODO: Check against the default value on PS3 m_clear_color_r = 0; m_clear_color_g = 0; m_clear_color_b = 0; m_clear_color_a = 0; m_clear_z = 0xffffff; m_clear_s = 0; - m_poly_offset_scale_factor = 0.0; m_poly_offset_bias = 0.0; - m_depth_bounds_min = 0.0; m_depth_bounds_max = 1.0; m_restart_index = 0xffffffff; - m_front_polygon_mode = 0x1b02; // GL_FILL m_back_polygon_mode = 0x1b02; // GL_FILL - m_front_face = 0x0901; - + m_front_face = 0x0901; // GL_CCW + m_cull_face = 0x0405; // GL_BACK + m_alpha_func = 0x0207; // GL_ALWAYS + m_alpha_ref = 0; + m_logic_op = 0x1503; // GL_COPY + m_shade_mode = 0x1D01; // GL_SMOOTH + m_depth_mask = 1; + m_depth_func = 0x0201; // GL_LESS + m_depth_bounds_min = 0.0; + m_depth_bounds_max = 1.0; + m_clip_min = 0.0; + m_clip_max = 1.0; + m_blend_equation_rgb = 0x8006; // GL_FUNC_ADD + m_blend_equation_alpha = 0x8006; // GL_FUNC_ADD + m_blend_sfactor_rgb = 1; // GL_ONE + m_blend_dfactor_rgb = 0; // GL_ZERO + m_blend_sfactor_alpha = 1; // GL_ONE + m_blend_dfactor_alpha = 0; // GL_ZERO m_point_x = 0; m_point_y = 0; m_point_size = 1.0; @@ -492,7 +508,6 @@ protected: m_line_stipple_factor = 1; for (size_t i = 0; i < 32; i++) { - // TODO: Check if the polygon stipple pattern is really "all ones" m_polygon_stipple_pattern[i] = 0xFFFFFFFF; } diff --git a/rpcs3/Emu/Io/Keyboard.cpp b/rpcs3/Emu/Io/Keyboard.cpp index b6c1f2e963..03b0a72a50 100644 --- a/rpcs3/Emu/Io/Keyboard.cpp +++ b/rpcs3/Emu/Io/Keyboard.cpp @@ -38,4 +38,4 @@ void KeyboardManager::Close() m_keyboard_handler = nullptr; m_inited = false; -} \ No newline at end of file +} diff --git a/rpcs3/Emu/Io/Mouse.cpp b/rpcs3/Emu/Io/Mouse.cpp index e938745249..3c9d569125 100644 --- a/rpcs3/Emu/Io/Mouse.cpp +++ b/rpcs3/Emu/Io/Mouse.cpp @@ -38,4 +38,4 @@ void MouseManager::Close() m_mouse_handler = nullptr; m_inited = false; -} \ No newline at end of file +} diff --git a/rpcs3/Emu/Io/Windows/WindowsKeyboardHandler.h b/rpcs3/Emu/Io/Windows/WindowsKeyboardHandler.h index 3ecb827d4b..92012237f3 100644 --- a/rpcs3/Emu/Io/Windows/WindowsKeyboardHandler.h +++ b/rpcs3/Emu/Io/Windows/WindowsKeyboardHandler.h @@ -3,6 +3,7 @@ #include #include #include "Emu/Io/KeyboardHandler.h" +#include "rpcs3.h" class WindowsKeyboardHandler final : public wxWindow @@ -171,4 +172,4 @@ public: m_keyboards[0].m_buttons.emplace_back('\\', CELL_KEYC_BACKSLASH_106); //m_keyboards[0].m_buttons.emplace_back(, CELL_KEYC_YEN_106); } -}; \ No newline at end of file +}; diff --git a/rpcs3/Emu/Memory/Memory.cpp b/rpcs3/Emu/Memory/Memory.cpp index cd78fee7ad..6352cd735b 100644 --- a/rpcs3/Emu/Memory/Memory.cpp +++ b/rpcs3/Emu/Memory/Memory.cpp @@ -3,8 +3,6 @@ #include "Utilities/Log.h" #include "Memory.h" -#include "MemoryBlock.h" -#include "Emu/System.h" MemoryBase Memory; diff --git a/rpcs3/Emu/Memory/Memory.h b/rpcs3/Emu/Memory/Memory.h index 8a9376df3c..ddadd97a5c 100644 --- a/rpcs3/Emu/Memory/Memory.h +++ b/rpcs3/Emu/Memory/Memory.h @@ -4,12 +4,14 @@ #include #endif -#include "Emu/SysCalls/Callback.h" #include "MemoryBlock.h" #include using std::nullptr_t; +#define safe_delete(x) do {delete (x);(x)=nullptr;} while(0) +#define safe_free(x) do {free(x);(x)=nullptr;} while(0) + enum MemoryType { Memory_PS3, diff --git a/rpcs3/Emu/Memory/MemoryBlock.h b/rpcs3/Emu/Memory/MemoryBlock.h index caac4efc56..7d8e1e9657 100644 --- a/rpcs3/Emu/Memory/MemoryBlock.h +++ b/rpcs3/Emu/Memory/MemoryBlock.h @@ -2,6 +2,193 @@ #define PAGE_4K(x) (x + 4095) & ~(4095) +union u128 +{ + struct + { + u64 hi; + u64 lo; + }; + + u64 _u64[2]; + u32 _u32[4]; + u16 _u16[8]; + u8 _u8[16]; + + operator u64() const { return _u64[0]; } + operator u32() const { return _u32[0]; } + operator u16() const { return _u16[0]; } + operator u8() const { return _u8[0]; } + + operator bool() const { return _u64[0] != 0 || _u64[1] != 0; } + + static u128 From128( u64 hi, u64 lo ) + { + u128 ret = {hi, lo}; + return ret; + } + + static u128 From64( u64 src ) + { + u128 ret = {0, src}; + return ret; + } + + static u128 From32( u32 src ) + { + u128 ret; + ret._u32[0] = src; + ret._u32[1] = 0; + ret._u32[2] = 0; + ret._u32[3] = 0; + return ret; + } + + static u128 FromBit ( u32 bit ) + { + u128 ret; + if (bit < 64) + { + ret.hi = 0; + ret.lo = (u64)1 << bit; + } + else if (bit < 128) + { + ret.hi = (u64)1 << (bit - 64); + ret.lo = 0; + } + else + { + ret.hi = 0; + ret.lo = 0; + } + return ret; + } + + bool operator == ( const u128& right ) const + { + return (lo == right.lo) && (hi == right.hi); + } + + bool operator != ( const u128& right ) const + { + return (lo != right.lo) || (hi != right.hi); + } + + u128 operator | ( const u128& right ) const + { + return From128(hi | right.hi, lo | right.lo); + } + + u128 operator & ( const u128& right ) const + { + return From128(hi & right.hi, lo & right.lo); + } + + u128 operator ^ ( const u128& right ) const + { + return From128(hi ^ right.hi, lo ^ right.lo); + } + + u128 operator ~ () const + { + return From128(~hi, ~lo); + } +}; + +union s128 +{ + struct + { + s64 hi; + s64 lo; + }; + + u64 _i64[2]; + u32 _i32[4]; + u16 _i16[8]; + u8 _i8[16]; + + operator s64() const { return _i64[0]; } + operator s32() const { return _i32[0]; } + operator s16() const { return _i16[0]; } + operator s8() const { return _i8[0]; } + + operator bool() const { return _i64[0] != 0 || _i64[1] != 0; } + + static s128 From64( s64 src ) + { + s128 ret = {src, 0}; + return ret; + } + + static s128 From32( s32 src ) + { + s128 ret; + ret._i32[0] = src; + ret._i32[1] = 0; + ret.hi = 0; + return ret; + } + + bool operator == ( const s128& right ) const + { + return (lo == right.lo) && (hi == right.hi); + } + + bool operator != ( const s128& right ) const + { + return (lo != right.lo) || (hi != right.hi); + } +}; + +#include +#include + +//TODO: SSE style +/* +struct u128 +{ + __m128 m_val; + + u128 GetValue128() + { + u128 ret; + _mm_store_ps( (float*)&ret, m_val ); + return ret; + } + + u64 GetValue64() + { + u64 ret; + _mm_store_ps( (float*)&ret, m_val ); + return ret; + } + + u32 GetValue32() + { + u32 ret; + _mm_store_ps( (float*)&ret, m_val ); + return ret; + } + + u16 GetValue16() + { + u16 ret; + _mm_store_ps( (float*)&ret, m_val ); + return ret; + } + + u8 GetValue8() + { + u8 ret; + _mm_store_ps( (float*)&ret, m_val ); + return ret; + } +}; +*/ + + struct MemInfo { u64 addr; diff --git a/rpcs3/Emu/SysCalls/Modules.h b/rpcs3/Emu/SysCalls/Modules.h index ee55d8de93..e0374db2bf 100644 --- a/rpcs3/Emu/SysCalls/Modules.h +++ b/rpcs3/Emu/SysCalls/Modules.h @@ -1,5 +1,7 @@ #pragma once +#include "Emu/Memory/Memory.h" + #define declCPU PPUThread& CPU = GetCurrentPPUThread //TODO diff --git a/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp b/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp index fec90b45d1..560850d32a 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAdec.cpp @@ -21,7 +21,7 @@ extern "C" //void cellAdec_init(); //Module cellAdec(0x0006, cellAdec_init); -extern Module *cellAdec=nullptr; +Module *cellAdec = nullptr; int adecRawRead(void* opaque, u8* buf, int buf_size) { diff --git a/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp b/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp index f0b2ac8206..664d55024a 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAtrac.cpp @@ -7,7 +7,7 @@ #include "Emu/SysCalls/Modules.h" #include "Emu/SysCalls/SysCalls.h" -extern Module *cellAtrac = nullptr; +Module *cellAtrac = nullptr; #include "cellAtrac.h" @@ -240,4 +240,4 @@ void cellAtrac_init() cellAtrac->AddFunc(0x7772eb2b, cellAtracResetPlayPosition); cellAtrac->AddFunc(0xb5c11938, cellAtracGetInternalErrorInfo); -} \ No newline at end of file +} diff --git a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp index 255a6558df..8fd2e0b9ac 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellAudio.cpp @@ -13,7 +13,7 @@ //void cellAudio_init(); //Module cellAudio(0x0011, cellAudio_init); -extern Module *cellAudio = nullptr; +Module *cellAudio = nullptr; static std::mutex audioMutex; diff --git a/rpcs3/Emu/SysCalls/Modules/cellFontFT.cpp b/rpcs3/Emu/SysCalls/Modules/cellFontFT.cpp index 92361c370f..19d3c204cd 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellFontFT.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellFontFT.cpp @@ -12,7 +12,7 @@ //void cellFontFT_load(); //void cellFontFT_unload(); //Module cellFontFT(0x001a, cellFontFT_init, cellFontFT_load, cellFontFT_unload); -extern Module *cellFontFT = nullptr; +Module *cellFontFT = nullptr; struct CellFontLibraryConfigFT { @@ -85,4 +85,4 @@ void cellFontFT_load() void cellFontFT_unload() { delete s_fontFtInternalInstance; -} \ No newline at end of file +} diff --git a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp index 1d0dfef4e9..d693772ff2 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGame.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGame.cpp @@ -14,7 +14,7 @@ //void cellGame_init(); //Module cellGame(0x003e, cellGame_init); -extern Module *cellGame = nullptr; +Module *cellGame = nullptr; std::string contentInfo = ""; std::string usrdir = ""; diff --git a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp index b1b74b4c76..6ebe0c0228 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp @@ -12,7 +12,7 @@ //void cellGcmSys_load(); //void cellGcmSys_unload(); //Module cellGcmSys(0x0010, cellGcmSys_init, cellGcmSys_load, cellGcmSys_unload); -extern Module *cellGcmSys = nullptr; +Module *cellGcmSys = nullptr; u32 local_size = 0; u32 local_addr = 0; diff --git a/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp index 1aeb261a14..e0ccafb456 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGifDec.cpp @@ -13,7 +13,7 @@ //void cellGifDec_init(); //Module cellGifDec(0xf010, cellGifDec_init); -extern Module *cellGifDec = nullptr; +Module *cellGifDec = nullptr; int cellGifDecCreate(u32 mainHandle, u32 threadInParam, u32 threadOutParam) { @@ -174,7 +174,8 @@ int cellGifDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m //Decode GIF file. (TODO: Is there any faster alternative? Can we do it without external libraries?) int width, height, actual_components; std::shared_ptr image(stbi_load_from_memory(gif, fileSize, &width, &height, &actual_components, 4)); - if (!image) return CELL_GIFDEC_ERROR_STREAM_FORMAT; + if (!image) + return CELL_GIFDEC_ERROR_STREAM_FORMAT; uint image_size = width * height * 4; diff --git a/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp index dc7a4b53a6..922321f9c9 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellJpgDec.cpp @@ -10,7 +10,7 @@ //void cellJpgDec_init(); //Module cellJpgDec(0x000f, cellJpgDec_init); -extern Module *cellJpgDec = nullptr; +Module *cellJpgDec = nullptr; int cellJpgDecCreate(u32 mainHandle, u32 threadInParam, u32 threadOutParam) { @@ -155,7 +155,8 @@ int cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, mem8_ptr_t data, const m int width, height, actual_components; std::shared_ptr image(stbi_load_from_memory(jpg, fileSize, &width, &height, &actual_components, 4)); - if (!image) return CELL_JPGDEC_ERROR_STREAM_FORMAT; + if (!image) + return CELL_JPGDEC_ERROR_STREAM_FORMAT; uint image_size = width * height; switch((u32)current_outParam.outputColorSpace) diff --git a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp index e339a6143e..7fcc039748 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellMsgDialog.cpp @@ -5,6 +5,7 @@ #include "Emu/Cell/PPUThread.h" #include "Emu/SysCalls/SC_FUNC.h" #include "Emu/SysCalls/Modules.h" +#include "rpcs3.h" #include "cellSysutil.h" #include "cellMsgDialog.h" @@ -442,4 +443,4 @@ int cellMsgDialogProgressBarInc(u32 progressBarIndex, u32 delta) } }); return CELL_OK; -} \ No newline at end of file +} diff --git a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp index 5f61fb8aa1..5dda7675d1 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellPngDec.cpp @@ -11,7 +11,7 @@ //void cellPngDec_init(); //Module cellPngDec(0x0018, cellPngDec_init); -extern Module *cellPngDec = nullptr; +Module *cellPngDec = nullptr; static std::map cellPngDecMap; diff --git a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp index 3f30a84c95..4618e9f94b 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp @@ -456,10 +456,10 @@ void InitMembers() { s_rescInternalInstance->m_dstMode = (CellRescBufferMode)0; s_rescInternalInstance->m_interlaceElement = CELL_RESC_ELEMENT_FLOAT; - s_rescInternalInstance->m_colorBuffersEA = NULL; - s_rescInternalInstance->m_vertexArrayEA = NULL; - s_rescInternalInstance->m_fragmentUcodeEA = NULL; - s_rescInternalInstance->m_interlaceTableEA = NULL; + s_rescInternalInstance->m_colorBuffersEA = 0; + s_rescInternalInstance->m_vertexArrayEA = 0; + s_rescInternalInstance->m_fragmentUcodeEA = 0; + s_rescInternalInstance->m_interlaceTableEA = 0; s_rescInternalInstance->m_bufIdFront = 0; s_rescInternalInstance->m_dstWidth = 0; s_rescInternalInstance->m_dstHeight = 0; @@ -668,7 +668,7 @@ void cellRescExit() if (IsPalTemporal()) { cellGcmSetSecondVFrequency(CELL_GCM_DISPLAY_FREQUENCY_DISABLE); - cellGcmSetVBlankHandler(NULL); + cellGcmSetVBlankHandler(0); //GcmSysTypePrefix::cellGcmSetSecondVHandler(NULL); if (IsPalInterpolate()) @@ -756,12 +756,12 @@ void SetVBlankHandler(u32 handler) if (IsNotPalTemporal()) { cellGcmSetVBlankHandler(handler); - s_rescInternalInstance->s_applicationVBlankHandler = NULL; + s_rescInternalInstance->s_applicationVBlankHandler = 0; } else if (IsPal60Hsync()) { //cellGcmSetSecondVHandler(handler); - s_rescInternalInstance->s_applicationVBlankHandler = NULL; + s_rescInternalInstance->s_applicationVBlankHandler = 0; } else { @@ -782,7 +782,7 @@ void SetFlipHandler(u32 handler) if (IsGcmFlip()) { cellGcmSetFlipHandler(handler); - s_rescInternalInstance->s_applicationFlipHandler = NULL; + s_rescInternalInstance->s_applicationFlipHandler = 0; } else { @@ -857,20 +857,20 @@ int cellRescSetDisplayMode(u32 displayMode) cellGcmSetSecondVFrequency(CELL_GCM_DISPLAY_FREQUENCY_59_94HZ); //cellGcmSetVBlankHandler(IntrHandler50); //cellGcmSetSecondVHandler(IntrHandler60); - cellGcmSetFlipHandler(NULL); + cellGcmSetFlipHandler(0); } else if (IsPalDrop()) { //InitLabels(); cellGcmSetSecondVFrequency(CELL_GCM_DISPLAY_FREQUENCY_59_94HZ); - cellGcmSetVBlankHandler(NULL); + cellGcmSetVBlankHandler(0); //cellGcmSetSecondVHandler(IntrHandler60Drop); - cellGcmSetFlipHandler(NULL); + cellGcmSetFlipHandler(0); } else if (IsPal60Hsync()) { cellGcmSetSecondVFrequency(CELL_GCM_DISPLAY_FREQUENCY_59_94HZ); - cellGcmSetVBlankHandler(NULL); + cellGcmSetVBlankHandler(0); } if (s_rescInternalInstance->s_applicationVBlankHandler) SetVBlankHandler(s_rescInternalInstance->s_applicationVBlankHandler); @@ -1323,7 +1323,7 @@ int cellRescCreateInterlaceTable(u32 ea_addr, float srcH, CellRescTableElement d return CELL_RESC_ERROR_NOT_INITIALIZED; } - if ((ea_addr == NULL) || (srcH <= 0.f) || (!(depth == CELL_RESC_ELEMENT_HALF || depth == CELL_RESC_ELEMENT_FLOAT)) || (length <= 0)) + if ((ea_addr == 0) || (srcH <= 0.f) || (!(depth == CELL_RESC_ELEMENT_HALF || depth == CELL_RESC_ELEMENT_FLOAT)) || (length <= 0)) { cellResc->Error("cellRescCreateInterlaceTable : CELL_RESC_ERROR_NOT_INITIALIZED"); return CELL_RESC_ERROR_BAD_ARGUMENT; diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp index e657106523..c1072297c4 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutil.cpp @@ -20,7 +20,7 @@ typedef void (*CellHddGameStatCallback)(mem_ptr_t cbResult, //void cellSysutil_init(); //Module cellSysutil(0x0015, cellSysutil_init); -Module *cellSysutil; +Module *cellSysutil = nullptr; int cellSysutilGetSystemParamInt(int id, mem32_t value) { diff --git a/rpcs3/Emu/SysCalls/Modules/cellSysutilAp.cpp b/rpcs3/Emu/SysCalls/Modules/cellSysutilAp.cpp index 834871b5d5..e18d269089 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellSysutilAp.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellSysutilAp.cpp @@ -8,7 +8,7 @@ //void cellSysutilAp_init(); //Module cellSysutilAp(0x0039, cellSysutilAp_init); -extern Module *cellSysutilAp = nullptr; +Module *cellSysutilAp = nullptr; // Return Codes enum @@ -46,4 +46,4 @@ void cellSysutilAp_init() cellSysutilAp->AddFunc(0x9e67e0dd, cellSysutilApGetRequiredMemSize); cellSysutilAp->AddFunc(0x3343824c, cellSysutilApOn); cellSysutilAp->AddFunc(0x90c2bb19, cellSysutilApOff); -} \ No newline at end of file +} diff --git a/rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp b/rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp index a148c957b5..7143cca15f 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellUserInfo.cpp @@ -10,7 +10,7 @@ //void cellUserInfo_init(); //Module cellUserInfo(0x0032, cellUserInfo_init); -extern Module *cellUserInfo = nullptr; +Module *cellUserInfo = nullptr; int cellUserInfoGetStat(u32 id, mem_ptr_t stat) { diff --git a/rpcs3/Emu/SysCalls/SC_FUNC.h b/rpcs3/Emu/SysCalls/SC_FUNC.h index c03ed9ec76..a30d52505c 100644 --- a/rpcs3/Emu/SysCalls/SC_FUNC.h +++ b/rpcs3/Emu/SysCalls/SC_FUNC.h @@ -1,5 +1,7 @@ #pragma once +#include "Emu/Memory/Memory.h" + #define RESULT(x) SC_ARGS_1 = (x) class func_caller diff --git a/rpcs3/Emu/SysCalls/SysCalls.h b/rpcs3/Emu/SysCalls/SysCalls.h index 95a6267464..ff34ff8d2f 100644 --- a/rpcs3/Emu/SysCalls/SysCalls.h +++ b/rpcs3/Emu/SysCalls/SysCalls.h @@ -2,6 +2,9 @@ #include "ErrorCodes.h" #include "Static.h" +#include "Emu/Memory/Memory.h" + +// Most of the headers below rely on Memory.h #include "lv2/lv2Fs.h" #include "lv2/sys_cond.h" #include "lv2/sys_event.h" @@ -26,6 +29,8 @@ #include "Emu/Event.h" +#include "rpcs3/Ini.h" + //#define SYSCALLS_DEBUG #define declCPU PPUThread& CPU = GetCurrentPPUThread diff --git a/rpcs3/Emu/SysCalls/lv2/sys_event.h b/rpcs3/Emu/SysCalls/lv2/sys_event.h index e823c7832b..09866991e7 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_event.h +++ b/rpcs3/Emu/SysCalls/lv2/sys_event.h @@ -95,4 +95,4 @@ s32 sys_event_flag_trywait(u32 eflag_id, u64 bitptn, u32 mode, mem64_t result); s32 sys_event_flag_set(u32 eflag_id, u64 bitptn); s32 sys_event_flag_clear(u32 eflag_id, u64 bitptn); s32 sys_event_flag_cancel(u32 eflag_id, mem32_t num); -s32 sys_event_flag_get(u32 eflag_id, mem64_t flags); \ No newline at end of file +s32 sys_event_flag_get(u32 eflag_id, mem64_t flags); diff --git a/rpcs3/Emu/SysCalls/lv2/sys_process.cpp b/rpcs3/Emu/SysCalls/lv2/sys_process.cpp index a5bd6933d7..7ea71a6d9a 100644 --- a/rpcs3/Emu/SysCalls/lv2/sys_process.cpp +++ b/rpcs3/Emu/SysCalls/lv2/sys_process.cpp @@ -4,6 +4,7 @@ #include "Emu/System.h" #include "Emu/SysCalls/SysCalls.h" #include "sys_process.h" +#include "rpcs3.h" SysCallBase sc_p("Process"); diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index 8f99e5b284..d64cc2e592 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -8,9 +8,18 @@ #include "Emu/GS/GSManager.h" #include "Emu/Audio/AudioManager.h" #include "Emu/FS/VFS.h" +#include "Emu/DbgCommand.h" #include "Loader/Loader.h" #include "SysCalls/Callback.h" +enum Status +{ + Running, + Paused, + Stopped, + Ready, +}; + class EventManager; class ModuleManager; class StaticFuncManager; diff --git a/rpcs3/Gui/CompilerELF.h b/rpcs3/Gui/CompilerELF.h index 6e1c4df161..6608f4d8c3 100644 --- a/rpcs3/Gui/CompilerELF.h +++ b/rpcs3/Gui/CompilerELF.h @@ -4,6 +4,7 @@ #include "Loader/ELF64.h" #include #include +#include "Gui/MainFrame.h" class CompilerELF : public FrameBase { diff --git a/rpcs3/Gui/FrameBase.h b/rpcs3/Gui/FrameBase.h index 8c054d848b..7ae79c4435 100644 --- a/rpcs3/Gui/FrameBase.h +++ b/rpcs3/Gui/FrameBase.h @@ -1,4 +1,5 @@ #pragma once +#include "rpcs3/Ini.h" class FrameBase : public wxFrame { diff --git a/rpcs3/Gui/GSFrame.cpp b/rpcs3/Gui/GSFrame.cpp index b180c0c54d..0a3f53f92f 100644 --- a/rpcs3/Gui/GSFrame.cpp +++ b/rpcs3/Gui/GSFrame.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include "GSFrame.h" +#include "rpcs3.h" BEGIN_EVENT_TABLE(GSFrame, wxFrame) EVT_PAINT(GSFrame::OnPaint) @@ -79,4 +80,4 @@ m_size.SetHeight(height); //wxFrame::SetSize(width, height); OnSize(wxSizeEvent()); } -*/ \ No newline at end of file +*/ diff --git a/rpcs3/Gui/MainFrame.cpp b/rpcs3/Gui/MainFrame.cpp index 20c6a55274..d0bb8d6daf 100644 --- a/rpcs3/Gui/MainFrame.cpp +++ b/rpcs3/Gui/MainFrame.cpp @@ -1,6 +1,5 @@ #include "stdafx.h" #include "Utilities/Log.h" -#include "Gui/ConLogFrame.h" #include "Emu/Memory/Memory.h" #include "Emu/System.h" #include "rpcs3.h" diff --git a/rpcs3/Gui/MainFrame.h b/rpcs3/Gui/MainFrame.h index 932087fe30..975230eef7 100644 --- a/rpcs3/Gui/MainFrame.h +++ b/rpcs3/Gui/MainFrame.h @@ -1,6 +1,8 @@ #pragma once #include "Gui/Debugger.h" +#include "Gui/ConLogFrame.h" +#include "Gui/FrameBase.h" #include diff --git a/rpcs3/Ini.cpp b/rpcs3/Ini.cpp index 008be9c59d..ad54b0dca8 100644 --- a/rpcs3/Ini.cpp +++ b/rpcs3/Ini.cpp @@ -16,7 +16,7 @@ CSimpleIniCaseA *getIniFile() if (inited == false) { ini.SetUnicode(true); - ini.LoadFile(DEF_CONFIG_NAME); + ini.LoadFile(std::string(rPlatform::getConfigDir() + DEF_CONFIG_NAME).c_str()); inited = true; } return &ini; @@ -24,7 +24,7 @@ CSimpleIniCaseA *getIniFile() void saveIniFile() { - getIniFile()->SaveFile(DEF_CONFIG_NAME); + getIniFile()->SaveFile(std::string(rPlatform::getConfigDir() + DEF_CONFIG_NAME).c_str()); } Inis Ini; @@ -77,14 +77,14 @@ static WindowInfo StringToWindowInfo(const std::string& str) vec.push_back(std::stoi(str.substr(start, found == std::string::npos ? found : found - start))); } catch (const std::invalid_argument& e) { - return WindowInfo::GetDefault(); + return WindowInfo(); } if (found == std::string::npos) break; start = found + 1; } if (vec.size() < 4 || vec[0] <= 0 || vec[1] <= 0 || vec[2] < 0 || vec[3] < 0) - return WindowInfo::GetDefault(); + return WindowInfo(); return WindowInfo(std::make_pair(vec[0], vec[1]), std::make_pair(vec[2], vec[3])); } diff --git a/rpcs3/Ini.h b/rpcs3/Ini.h index 9af5e69b33..8abdfec5ea 100644 --- a/rpcs3/Ini.h +++ b/rpcs3/Ini.h @@ -1,7 +1,8 @@ #pragma once #include -#include "../Utilities/simpleini/SimpleIni.h" +#include "Utilities/rPlatform.h" +#include "Utilities/simpleini/SimpleIni.h" //TODO: make thread safe/remove static singleton CSimpleIniCaseA *getIniFile(); @@ -18,12 +19,6 @@ struct WindowInfo , position(_position) { } - - //TODO: remove - static WindowInfo GetDefault() - { - return WindowInfo({ -1, -1 }, { -1, -1 }); - } }; class Ini diff --git a/rpcs3/stdafx.h b/rpcs3/stdafx.h index 4fbb2d8d3e..c61296bf72 100644 --- a/rpcs3/stdafx.h +++ b/rpcs3/stdafx.h @@ -6,9 +6,6 @@ #include #endif -/* size of statically declared array */ -#define SARRSIZEOF(array) (sizeof(array)/sizeof(array[0])) - #define NOMINMAX #ifndef QT_UI #include @@ -41,14 +38,10 @@ #include #endif -#ifdef MSVC_CRT_MEMLEAK_DETECTION - #ifdef _DEBUG - #ifndef DBG_NEW - #define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ ) - #define new DBG_NEW - #endif - #endif // _DEBUG -#endif // MSVC_CRT_MEMLEAK_DETECTION +#if defined(MSVC_CRT_MEMLEAK_DETECTION) && defined(_DEBUG) && !defined(DBG_NEW) + #define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ ) + #define new DBG_NEW +#endif // This header should be frontend-agnostic, so don't assume wx includes everything #include @@ -68,210 +61,6 @@ typedef int16_t s16; typedef int32_t s32; typedef int64_t s64; -union u128 -{ - struct - { - u64 hi; - u64 lo; - }; - - u64 _u64[2]; - u32 _u32[4]; - u16 _u16[8]; - u8 _u8[16]; - - operator u64() const { return _u64[0]; } - operator u32() const { return _u32[0]; } - operator u16() const { return _u16[0]; } - operator u8() const { return _u8[0]; } - - operator bool() const { return _u64[0] != 0 || _u64[1] != 0; } - - static u128 From128( u64 hi, u64 lo ) - { - u128 ret = {hi, lo}; - return ret; - } - - static u128 From64( u64 src ) - { - u128 ret = {0, src}; - return ret; - } - - static u128 From32( u32 src ) - { - u128 ret; - ret._u32[0] = src; - ret._u32[1] = 0; - ret._u32[2] = 0; - ret._u32[3] = 0; - return ret; - } - - static u128 FromBit ( u32 bit ) - { - u128 ret; - if (bit < 64) - { - ret.hi = 0; - ret.lo = (u64)1 << bit; - } - else if (bit < 128) - { - ret.hi = (u64)1 << (bit - 64); - ret.lo = 0; - } - else - { - ret.hi = 0; - ret.lo = 0; - } - return ret; - } - - bool operator == ( const u128& right ) const - { - return (lo == right.lo) && (hi == right.hi); - } - - bool operator != ( const u128& right ) const - { - return (lo != right.lo) || (hi != right.hi); - } - - u128 operator | ( const u128& right ) const - { - return From128(hi | right.hi, lo | right.lo); - } - - u128 operator & ( const u128& right ) const - { - return From128(hi & right.hi, lo & right.lo); - } - - u128 operator ^ ( const u128& right ) const - { - return From128(hi ^ right.hi, lo ^ right.lo); - } - - u128 operator ~ () const - { - return From128(~hi, ~lo); - } -}; - -union s128 -{ - struct - { - s64 hi; - s64 lo; - }; - - u64 _i64[2]; - u32 _i32[4]; - u16 _i16[8]; - u8 _i8[16]; - - operator s64() const { return _i64[0]; } - operator s32() const { return _i32[0]; } - operator s16() const { return _i16[0]; } - operator s8() const { return _i8[0]; } - - operator bool() const { return _i64[0] != 0 || _i64[1] != 0; } - - static s128 From64( s64 src ) - { - s128 ret = {src, 0}; - return ret; - } - - static s128 From32( s32 src ) - { - s128 ret; - ret._i32[0] = src; - ret._i32[1] = 0; - ret.hi = 0; - return ret; - } - - bool operator == ( const s128& right ) const - { - return (lo == right.lo) && (hi == right.hi); - } - - bool operator != ( const s128& right ) const - { - return (lo != right.lo) || (hi != right.hi); - } -}; - -#include -#include - -//TODO: SSE style -/* -struct u128 -{ - __m128 m_val; - - u128 GetValue128() - { - u128 ret; - _mm_store_ps( (float*)&ret, m_val ); - return ret; - } - - u64 GetValue64() - { - u64 ret; - _mm_store_ps( (float*)&ret, m_val ); - return ret; - } - - u32 GetValue32() - { - u32 ret; - _mm_store_ps( (float*)&ret, m_val ); - return ret; - } - - u16 GetValue16() - { - u16 ret; - _mm_store_ps( (float*)&ret, m_val ); - return ret; - } - - u8 GetValue8() - { - u8 ret; - _mm_store_ps( (float*)&ret, m_val ); - return ret; - } -}; -*/ - -template -static void safe_realloc(T* ptr, uint new_size) -{ - if(new_size == 0) return; - ptr = (T*)((ptr == NULL) ? malloc(new_size * sizeof(T)) : realloc(ptr, new_size * sizeof(T))); -} - -#define safe_delete(x) do {delete (x);(x)=nullptr;} while(0) -#define safe_free(x) do {free(x);(x)=nullptr;} while(0) - -enum Status -{ - Running, - Paused, - Stopped, - Ready, -}; - #include "Utilities/StrFmt.h" #include "Utilities/Log.h" #include "Utilities/BEType.h" @@ -280,24 +69,16 @@ enum Status #include "Utilities/rXml.h" #include "Utilities/rConcurrency.h" #include "Utilities/rMsgBox.h" -#include "Utilities/rPlatform.h" #include "Utilities/Thread.h" #include "Utilities/Array.h" #include "Utilities/Timer.h" #include "Utilities/IdManager.h" -#include "rpcs3/Ini.h" -#include "Gui/FrameBase.h" -#include "Gui/ConLogFrame.h" -#include "Emu/Memory/Memory.h" -#include "Emu/System.h" #include "Emu/SysCalls/Callback.h" -#include "Emu/DbgCommand.h" #include "Emu/Cell/PPUThread.h" #include "Emu/SysCalls/SC_FUNC.h" #include "Emu/SysCalls/Modules.h" - #include "Emu/FS/vfsDirBase.h" #include "Emu/FS/vfsFileBase.h" #include "Emu/FS/vfsLocalDir.h" @@ -306,9 +87,6 @@ enum Status #include "Emu/FS/vfsStreamMemory.h" #include "Emu/FS/vfsFile.h" #include "Emu/FS/vfsDir.h" -#ifndef QT_UI -#include "rpcs3.h" -#endif #define _PRGNAME_ "RPCS3" #define _PRGVER_ "0.0.0.4"