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/rpcs3/CMakeLists.txt b/rpcs3/CMakeLists.txt index ae72e0f56b..be1a49418e 100644 --- a/rpcs3/CMakeLists.txt +++ b/rpcs3/CMakeLists.txt @@ -7,22 +7,28 @@ 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) 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 +54,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/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.h b/rpcs3/Emu/GS/RSXThread.h index 3dd6abbf58..2246cb416a 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 diff --git a/rpcs3/Emu/Memory/Memory.cpp b/rpcs3/Emu/Memory/Memory.cpp index 9f70616622..719e8a7579 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 3a51f61b15..74f5a2d880 100644 --- a/rpcs3/Emu/Memory/Memory.h +++ b/rpcs3/Emu/Memory/Memory.h @@ -1,10 +1,12 @@ #pragma once -#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 e9a6e7c1d1..9d0284045c 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/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/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/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..9a11d02f13 100644 --- a/rpcs3/Gui/MainFrame.h +++ b/rpcs3/Gui/MainFrame.h @@ -1,6 +1,7 @@ #pragma once #include "Gui/Debugger.h" +#include "Gui/ConLogFrame.h" #include diff --git a/rpcs3/stdafx.h b/rpcs3/stdafx.h index 4fbb2d8d3e..618f526901 100644 --- a/rpcs3/stdafx.h +++ b/rpcs3/stdafx.h @@ -68,202 +68,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, @@ -286,10 +90,7 @@ enum Status #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"