From 81cb80997ac3e0867c954cedcf3b43e7096d35d0 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 27 Apr 2014 21:49:50 -0400 Subject: [PATCH 01/28] add missing bswap functions --- src/common/common.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/common/common.h b/src/common/common.h index 418757855..58de0c7d9 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -159,4 +159,48 @@ enum EMUSTATE_CHANGE EMUSTATE_CHANGE_STOP }; + +#ifdef _MSC_VER +#ifndef _XBOX +inline unsigned long long bswap64(unsigned long long x) { return _byteswap_uint64(x); } +inline unsigned int bswap32(unsigned int x) { return _byteswap_ulong(x); } +inline unsigned short bswap16(unsigned short x) { return _byteswap_ushort(x); } +#else +inline unsigned long long bswap64(unsigned long long x) { return __loaddoublewordbytereverse(0, &x); } +inline unsigned int bswap32(unsigned int x) { return __loadwordbytereverse(0, &x); } +inline unsigned short bswap16(unsigned short x) { return __loadshortbytereverse(0, &x); } +#endif +#else +// TODO: speedup +inline unsigned short bswap16(unsigned short x) { return (x << 8) | (x >> 8); } +inline unsigned int bswap32(unsigned int x) { return (x >> 24) | ((x & 0xFF0000) >> 8) | ((x & 0xFF00) << 8) | (x << 24);} +inline unsigned long long bswap64(unsigned long long x) {return ((unsigned long long)bswap32(x) << 32) | bswap32(x >> 32); } +#endif + +inline float bswapf(float f) { + union { + float f; + unsigned int u32; + } dat1, dat2; + + dat1.f = f; + dat2.u32 = bswap32(dat1.u32); + + return dat2.f; +} + +inline double bswapd(double f) { + union { + double f; + unsigned long long u64; + } dat1, dat2; + + dat1.f = f; + dat2.u64 = bswap64(dat1.u64); + + return dat2.f; +} + +#include "swap.h" + #endif // _COMMON_H_ From ff48c8bed3a7329b57f3889b36492f31e6d44700 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 27 Apr 2014 22:21:46 -0700 Subject: [PATCH 02/28] Rect to BasicRect Somewhere along the line an OSX header had already taken the name Rect. --- src/common/common_types.h | 8 ++++---- src/video_core/renderer_opengl/renderer_opengl.cpp | 4 ++-- src/video_core/renderer_opengl/renderer_opengl.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/common/common_types.h b/src/common/common_types.h index 4289b88d3..50cf18738 100644 --- a/src/common/common_types.h +++ b/src/common/common_types.h @@ -101,15 +101,15 @@ union t128 { }; /// Rectangle data structure -class Rect { +class BasicRect { public: - Rect(int x0=0, int y0=0, int x1=0, int y1=0) { + BasicRect(int x0=0, int y0=0, int x1=0, int y1=0) { x0_ = x0; y0_ = y0; x1_ = x1; y1_ = y1; } - ~Rect() { } + ~BasicRect() { } int x0_; ///< Rect top left X-coordinate int y0_; ///< Rect top left Y-coordinate @@ -119,7 +119,7 @@ public: inline u32 width() const { return abs(x1_ - x0_); } inline u32 height() const { return abs(y1_ - y0_); } - inline bool operator == (const Rect& val) const { + inline bool operator == (const BasicRect& val) const { return (x0_ == val.x0_ && y0_ == val.y0_ && x1_ == val.x1_ && y1_ == val.y1_); } }; diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index b63a73d18..314b1a8ed 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -37,7 +37,7 @@ void RendererOpenGL::SwapBuffers() { // EFB->XFB copy // TODO(bunnei): This is a hack and does not belong here. The copy should be triggered by some // register write We're also treating both framebuffers as a single one in OpenGL. - Rect framebuffer_size(0, 0, m_resolution_width, m_resolution_height); + BasicRect framebuffer_size(0, 0, m_resolution_width, m_resolution_height); RenderXFB(framebuffer_size, framebuffer_size); // XFB->Window copy @@ -76,7 +76,7 @@ void RendererOpenGL::FlipFramebuffer(const u8* in, u8* out) { * @param src_rect Source rectangle in XFB to copy * @param dst_rect Destination rectangle in output framebuffer to copy to */ -void RendererOpenGL::RenderXFB(const Rect& src_rect, const Rect& dst_rect) { +void RendererOpenGL::RenderXFB(const BasicRect& src_rect, const BasicRect& dst_rect) { FlipFramebuffer(LCD::GetFramebufferPointer(LCD::g_regs.framebuffer_top_left_1), m_xfb_top_flipped); FlipFramebuffer(LCD::GetFramebufferPointer(LCD::g_regs.framebuffer_sub_left_1), m_xfb_bottom_flipped); diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h index 4c0b6e59d..cd0480173 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.h +++ b/src/video_core/renderer_opengl/renderer_opengl.h @@ -28,7 +28,7 @@ public: * @param src_rect Source rectangle in XFB to copy * @param dst_rect Destination rectangle in output framebuffer to copy to */ - void RenderXFB(const Rect& src_rect, const Rect& dst_rect); + void RenderXFB(const BasicRect& src_rect, const BasicRect& dst_rect); /** * Set the emulator window to use for renderer From 48deb456244312940ea127ac8ec57e45f8413992 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 27 Apr 2014 22:23:01 -0700 Subject: [PATCH 03/28] Xcode complains that the class name is redundant. --- src/video_core/renderer_opengl/renderer_opengl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h index cd0480173..06e602b46 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.h +++ b/src/video_core/renderer_opengl/renderer_opengl.h @@ -59,7 +59,7 @@ private: * @param out Pointer to output buffer with flipped framebuffer * @todo Early on hack... I'd like to find a more efficient way of doing this /bunnei */ - void RendererOpenGL::FlipFramebuffer(const u8* in, u8* out); + void FlipFramebuffer(const u8* in, u8* out); EmuWindow* m_render_window; ///< Handle to render window From b9fc729928ff76b26cc10456bdc68728fc53732c Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 27 Apr 2014 22:23:58 -0700 Subject: [PATCH 04/28] Problematic template functions --- src/core/hle/function_wrappers.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h index 4897d3f28..cab772004 100644 --- a/src/core/hle/function_wrappers.h +++ b/src/core/hle/function_wrappers.h @@ -83,15 +83,6 @@ template void WrapU_IV() { RETURN(retval); } -template void WrapF_V() { - RETURNF(func()); -} - -// TODO: Not sure about the floating point parameter passing -template void WrapF_IFU() { - RETURNF(func(PARAM(0), PARAMF(0), PARAM(1))); -} - template void WrapU_U() { u32 retval = func(PARAM(0)); RETURN(retval); @@ -127,12 +118,6 @@ template void WrapI_UU() { RETURN(retval); } -template void WrapI_UFF() { - // Not sure about the float arguments. - int retval = func(PARAM(0), PARAMF(0), PARAMF(1)); - RETURN(retval); -} - template void WrapI_UUU() { int retval = func(PARAM(0), PARAM(1), PARAM(2)); RETURN(retval); From 5741f2fb267daa7b1e8001a19bbd243bd2dc8f26 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 27 Apr 2014 22:24:39 -0700 Subject: [PATCH 05/28] Problematic class with no current implementation --- src/common/chunk_file.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/chunk_file.h b/src/common/chunk_file.h index a41205857..c6a7cee35 100644 --- a/src/common/chunk_file.h +++ b/src/common/chunk_file.h @@ -654,7 +654,7 @@ inline PointerWrapSection::~PointerWrapSection() { } -class CChunkFileReader +/*class CChunkFileReader { public: enum Error { @@ -869,6 +869,6 @@ private: int UncompressedSize; char GitVersion[32]; }; -}; +}; */ #endif // _POINTERWRAP_H_ From 5749d1eabe9aa016affdc528c06b2a5f6a7f23a4 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 27 Apr 2014 22:25:30 -0700 Subject: [PATCH 06/28] Fix complaints about functions that could not be found --- src/common/common_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/common_types.h b/src/common/common_types.h index 50cf18738..25dc912a9 100644 --- a/src/common/common_types.h +++ b/src/common/common_types.h @@ -62,7 +62,7 @@ typedef signed long long s64; ///< 64-bit signed int typedef float f32; ///< 32-bit floating point typedef double f64; ///< 64-bit floating point -#include "common/swap.h" +#include "common/common.h" /// Union for fast 16-bit type casting union t16 { From 5a9c2ce5ea1b272d73001acaf9ec15f1c0e5e041 Mon Sep 17 00:00:00 2001 From: archshift Date: Mon, 28 Apr 2014 19:40:39 -0700 Subject: [PATCH 07/28] IT'S ALIVE! --- CMakeLists.txt | 11 ++++++++-- src/citra/CMakeLists.txt | 4 +++- src/citra_qt/CMakeLists.txt | 25 ++++++++++++++++++++-- src/common/CMakeLists.txt | 40 ++++++++++++++++++++++++++++++++++- src/video_core/CMakeLists.txt | 7 +++++- 5 files changed, 80 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a588fe193..bd21af25e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 2.6) project(citra) -SET(GCC_COMPILE_FLAGS "-std=c++11 -fpermissive") +SET(CMAKE_CXX_FLAGS_DEBUG "-std=c++11 -fpermissive") +SET(CMAKE_CXX_FLAGS_RELEASE "-std=c++11 -fpermissive") # silence some spam add_definitions(-Wno-attributes) @@ -11,11 +12,16 @@ add_definitions(${GCC_COMPILE_FLAGS}) # dependency checking set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeTests) -include(FindOpenGL REQUIRED) include(FindX11 REQUIRED) find_package(PkgConfig REQUIRED) +find_package(GLEW REQUIRED) +find_package(OpenGL REQUIRED) pkg_search_module(GLFW REQUIRED glfw3) +IF (APPLE) + FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation) +ENDIF (APPLE) + include_directories(${GLFW_INCLUDE_DIRS}) option(DISABLE_QT4 "Disable Qt4 GUI" OFF) if(NOT DISABLE_QT4) @@ -40,6 +46,7 @@ git_branch_name(GIT_BRANCH) # external includes include_directories(${OPENGL_INCLUDE_DIR}) +include_directories(${GLEW_INCLUDE_DIR}) # internal includes include_directories(src) diff --git a/src/citra/CMakeLists.txt b/src/citra/CMakeLists.txt index 0023da2bf..d7478a2d2 100644 --- a/src/citra/CMakeLists.txt +++ b/src/citra/CMakeLists.txt @@ -1,12 +1,14 @@ set(SRCS citra.cpp emu_window/emu_window_glfw.cpp) +set(HEADS citra.h + resource.h) # NOTE: This is a workaround for CMake bug 0006976 (missing X11_xf86vmode_LIB variable) if (NOT X11_xf86vmode_LIB) set(X11_xv86vmode_LIB Xxf86vm) endif() -add_executable(citra ${SRCS}) +add_executable(citra ${SRCS} ${HEADS}) target_link_libraries(citra core common video_core GLEW pthread X11 Xxf86vm Xi ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES} rt ${X11_Xrandr_LIB} ${X11_xv86vmode_LIB}) #install(TARGETS citra RUNTIME DESTINATION ${bindir}) diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index 594460a71..abca202ea 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt @@ -8,6 +8,23 @@ set(SRCS main.cpp config/controller_config.cpp config/controller_config_util.cpp) +set (HEADS + bootmanager.hxx + debugger/callstack.hxx + debugger/disassembler.hxx + debugger/ramview.hxx + debugger/registers.hxx + hotkeys.hxx + main.hxx + ui_callstack.h + ui_controller_config.h + ui_disassembler.h + ui_hotkeys.h + ui_main.h + ui_registers.h + version.h + config/controller_config.hxx + config/controller_config_util.hxx) qt4_wrap_ui(UI_HDRS debugger/callstack.ui @@ -32,7 +49,11 @@ qt4_wrap_cpp(MOC_SRCS include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(./) -add_executable(citra-qt ${SRCS} ${MOC_SRCS} ${UI_HDRS}) -target_link_libraries(citra-qt core common video_core qhexedit ${QT_LIBRARIES} ${OPENGL_LIBRARIES} ${SDL2_LIBRARY} rt GLEW ${GLFW_LIBRARIES}) +add_executable(citra-qt ${SRCS} ${HEADS} ${MOC_SRCS} ${UI_HDRS}) +if (APPLE) + target_link_libraries(citra-qt core common video_core qhexedit iconv ${COREFOUNDATION_LIBRARY} ${QT_LIBRARIES} ${GLEW_LIBRARY} ${OPENGL_LIBRARIES}) +else() + +endif() #install(TARGETS citra-qt RUNTIME DESTINATION ${bindir}) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 5eaf67365..48f30de4c 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -19,4 +19,42 @@ set(SRCS break_points.cpp timer.cpp utf8.cpp) -add_library(common STATIC ${SRCS}) +set(HEADS atomic.h + atomic_gcc.h + atomic_win32.h + break_points.h + chunk_file.h + common_funcs.h + common_paths.h + common_types.h + common.h + console_listener.h + cpu_detect.h + debug_interface.h + emu_window.h + extended_trace.h + fifo_queue.h + file_search.h + file_util.h + hash.h + linear_disk_cache.h + log_manager.h + log.h + math_util.h + mem_arena.h + memory_util.h + msg_handler.h + platform.h + scm_rev.h + std_condition_variable.h + std_mutex.h + std_thread.h + string_util.h + swap.h + symbols.h + thread.h + thunk.h + timer.h + utf8.h) + +add_library(common STATIC ${SRCS} ${HEADS}) diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 56394b930..8d04d381c 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt @@ -2,4 +2,9 @@ set(SRCS video_core.cpp utils.cpp renderer_opengl/renderer_opengl.cpp) -add_library(video_core STATIC ${SRCS}) +set(HEADS video_core.h + utils.h + renderer_base.h + renderer_opengl/renderer_opengl.h) + +add_library(video_core STATIC ${SRCS} ${HEADS}) From 52377cf0d2e29143717898e82f09349d417da1a0 Mon Sep 17 00:00:00 2001 From: archshift Date: Tue, 29 Apr 2014 19:27:01 -0700 Subject: [PATCH 08/28] Some more experimentation --- CMakeLists.txt | 6 +++++- src/citra/CMakeLists.txt | 2 +- src/common/common.h | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd21af25e..49c1a384a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 2.6) project(citra) +SET(CMAKE_CXX_FLAGS "-std=c++11 -fpermissive") SET(CMAKE_CXX_FLAGS_DEBUG "-std=c++11 -fpermissive") SET(CMAKE_CXX_FLAGS_RELEASE "-std=c++11 -fpermissive") @@ -19,7 +20,10 @@ find_package(OpenGL REQUIRED) pkg_search_module(GLFW REQUIRED glfw3) IF (APPLE) - FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation) + FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation) + SET(CMAKE_CXX_FLAGS "-stdlib=libc++") + SET(CMAKE_CXX_FLAGS_DEBUG "-stdlib=libc++") + SET(CMAKE_CXX_FLAGS_RELEASE "-stdlib=libc++") ENDIF (APPLE) include_directories(${GLFW_INCLUDE_DIRS}) diff --git a/src/citra/CMakeLists.txt b/src/citra/CMakeLists.txt index ca272249f..25f476895 100644 --- a/src/citra/CMakeLists.txt +++ b/src/citra/CMakeLists.txt @@ -9,6 +9,6 @@ if (NOT X11_xf86vmode_LIB) endif() add_executable(citra ${SRCS} ${HEADS}) -target_link_libraries(citra core common video_core GLEW pthread X11 Xxf86vm Xi Xcursor ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES} rt ${X11_Xrandr_LIB} ${X11_xv86vmode_LIB}) +target_link_libraries(citra core common video_core iconv pthread ${COREFOUNDATION_LIBRARY} ${OPENGL_LIBRARIES} ${GLEW_LIBRARY} ${GLFW_LIBRARIES}) #install(TARGETS citra RUNTIME DESTINATION ${bindir}) diff --git a/src/common/common.h b/src/common/common.h index 58de0c7d9..30a6761b7 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -21,11 +21,11 @@ #define STACKALIGN -#if __cplusplus >= 201103 || defined(_MSC_VER) || defined(__GXX_EXPERIMENTAL_CXX0X__) +#if __cplusplus >= 201103L || defined(_MSC_VER) || defined(__GXX_EXPERIMENTAL_CXX0X__) #define HAVE_CXX11_SYNTAX 1 #endif -#if HAVE_CXX11_SYNTAX +//#if HAVE_CXX11_SYNTAX // An inheritable class to disallow the copy constructor and operator= functions class NonCopyable { @@ -37,7 +37,7 @@ private: NonCopyable(NonCopyable&); NonCopyable& operator=(NonCopyable& other); }; -#endif +//#endif #include "common/log.h" #include "common/common_types.h" From a7f3ed003d03c79f83c1c354329e5ce47f6940e7 Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 30 Apr 2014 16:56:25 -0700 Subject: [PATCH 09/28] A bit of Cmake love --- CMakeLists.txt | 11 +++++++---- src/citra/CMakeLists.txt | 12 ++++++------ src/citra_qt/CMakeLists.txt | 4 ++-- src/core/CMakeLists.txt | 39 ++++++++++++++++++++++++++++++++++++- 4 files changed, 53 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 49c1a384a..6837d36fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,14 @@ IF (APPLE) SET(CMAKE_CXX_FLAGS_RELEASE "-stdlib=libc++") ENDIF (APPLE) +#external includes include_directories(${GLFW_INCLUDE_DIRS}) +include_directories(${OPENGL_INCLUDE_DIR}) +include_directories(${GLEW_INCLUDE_DIR}) + +#use pkg_search_module library dirs +link_directories(${GLFW_LIBRARY_DIRS}) + option(DISABLE_QT4 "Disable Qt4 GUI" OFF) if(NOT DISABLE_QT4) include(FindQt4) @@ -47,10 +54,6 @@ include(GetGitRevisionDescription) get_git_head_revision(GIT_REF_SPEC GIT_REV) git_describe(GIT_DESC --always --long --dirty) git_branch_name(GIT_BRANCH) - -# external includes -include_directories(${OPENGL_INCLUDE_DIR}) -include_directories(${GLEW_INCLUDE_DIR}) # internal includes include_directories(src) diff --git a/src/citra/CMakeLists.txt b/src/citra/CMakeLists.txt index 25f476895..ee3cb55cf 100644 --- a/src/citra/CMakeLists.txt +++ b/src/citra/CMakeLists.txt @@ -3,12 +3,12 @@ set(SRCS citra.cpp set(HEADS citra.h resource.h) -# NOTE: This is a workaround for CMake bug 0006976 (missing X11_xf86vmode_LIB variable) -if (NOT X11_xf86vmode_LIB) - set(X11_xv86vmode_LIB Xxf86vm) +add_executable(citra ${SRCS} ${HEADS}) + +if (APPLE) + target_link_libraries(citra core common video_core iconv pthread ${COREFOUNDATION_LIBRARY} ${OPENGL_LIBRARIES} ${GLEW_LIBRARY} ${GLFW_LIBRARIES}) +else() + target_link_libraries(citra core common video_core pthread ${OPENGL_LIBRARIES} ${GLEW_LIBRARY} ${GLFW_LIBRARIES}) endif() -add_executable(citra ${SRCS} ${HEADS}) -target_link_libraries(citra core common video_core iconv pthread ${COREFOUNDATION_LIBRARY} ${OPENGL_LIBRARIES} ${GLEW_LIBRARY} ${GLFW_LIBRARIES}) - #install(TARGETS citra RUNTIME DESTINATION ${bindir}) diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index abca202ea..b06be56fe 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt @@ -51,9 +51,9 @@ include_directories(./) add_executable(citra-qt ${SRCS} ${HEADS} ${MOC_SRCS} ${UI_HDRS}) if (APPLE) - target_link_libraries(citra-qt core common video_core qhexedit iconv ${COREFOUNDATION_LIBRARY} ${QT_LIBRARIES} ${GLEW_LIBRARY} ${OPENGL_LIBRARIES}) + target_link_libraries(citra-qt core common video_core qhexedit iconv ${COREFOUNDATION_LIBRARY} ${QT_LIBRARIES} ${GLEW_LIBRARY} ${OPENGL_LIBRARIES}) else() - + target_link_libraries(citra-qt core common video_core qhexedit ${QT_LIBRARIES} ${GLEW_LIBRARY} ${OPENGL_LIBRARIES}) endif() #install(TARGETS citra-qt RUNTIME DESTINATION ${bindir}) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 314f6e64c..c8d95ba5d 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -29,4 +29,41 @@ set(SRCS core.cpp hw/lcd.cpp hw/ndma.cpp) -add_library(core STATIC ${SRCS}) +set(HEADS core.h + core_timing.h + loader.h + mem_map.h + system.h + arm/disassembler/arm_disasm.h + arm/interpreter/arm_interpreter.h + arm/interpreter/arm_regformat.h + arm/interpreter/armcpu.h + arm/interpreter/armdefs.h + arm/interpreter/armemu.h + arm/interpreter/armmmu.h + arm/interpreter/armos.h + arm/interpreter/skyeye_defs.h + arm/mmu/arm1176jzf_s_mmu.h + arm/mmu/cache.h + arm/mmu/rb.h + arm/mmu/tlb.h + arm/mmu/wb.h + elf/elf_reader.h + elf/elf_types.h + file_sys/directory_file_system.h + file_sys/file_sys.h + file_sys/meta_file_system.h + hle/hle.h + hle/mrc.h + hle/syscall.h + hle/function_wrappers.h + hle/service/apt.h + hle/service/gsp.h + hle/service/hid.h + hle/service/service.h + hle/service/srv.h + hw/hw.h + hw/lcd.h + hw/ndma.h) + +add_library(core STATIC ${SRCS} ${HEADS}) From c1b770cc0db5649c4b9dc52f5e31105b2bc88eb6 Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 30 Apr 2014 17:00:36 -0700 Subject: [PATCH 10/28] OpenGL 3+ on OSX with GLFW --- src/citra/emu_window/emu_window_glfw.cpp | 9 ++++++++- src/video_core/video_core.cpp | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/citra/emu_window/emu_window_glfw.cpp b/src/citra/emu_window/emu_window_glfw.cpp index e6943f146..ea1499e7c 100644 --- a/src/citra/emu_window/emu_window_glfw.cpp +++ b/src/citra/emu_window/emu_window_glfw.cpp @@ -27,11 +27,18 @@ EmuWindow_GLFW::EmuWindow_GLFW() { exit(1); } glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); m_render_window = glfwCreateWindow(VideoCore::kScreenTopWidth, (VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight), m_window_title.c_str(), NULL, NULL); + if (m_render_window == NULL) { + printf("Failed to create GLFW window! Exiting..."); + exit(1); + } + // Setup callbacks glfwSetWindowUserPointer(m_render_window, this); //glfwSetKeyCallback(m_render_window, OnKeyEvent); diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp index f2e17f9f9..4e9cd70bc 100644 --- a/src/video_core/video_core.cpp +++ b/src/video_core/video_core.cpp @@ -30,6 +30,8 @@ void Start() { /// Initialize the video core void Init(EmuWindow* emu_window) { + glewExperimental = GL_TRUE; + g_emu_window = emu_window; g_emu_window->MakeCurrent(); g_renderer = new RendererOpenGL(); From 3dad4e3b5cf0e5cc0c52fa28fb055ed98f912915 Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 30 Apr 2014 17:10:38 -0700 Subject: [PATCH 11/28] Sets OGL version for Qt; will only work with Qt5 --- src/citra_qt/bootmanager.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 31958ac28..52b39eb27 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -73,11 +73,10 @@ void EmuThread::Stop() class GGLWidgetInternal : public QGLWidget { public: - GGLWidgetInternal(GRenderWindow* parent) : QGLWidget(parent) + GGLWidgetInternal(QGLFormat fmt, GRenderWindow* parent) : QGLWidget(parent) { - setAutoBufferSwap(false); - doneCurrent(); - parent_ = parent; + doneCurrent(); + parent_ = parent; } void paintEvent(QPaintEvent* ev) @@ -103,8 +102,13 @@ EmuThread& GRenderWindow::GetEmuThread() GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this) { // TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground, WA_DontShowOnScreen, WA_DeleteOnClose - - child = new GGLWidgetInternal(this); + QGLFormat fmt; + fmt.setProfile(QGLFormat::CoreProfile); + fmt.setVersion(4,1); + fmt.setSampleBuffers(true); + fmt.setSamples(4); + + child = new GGLWidgetInternal(fmt, this); QBoxLayout* layout = new QHBoxLayout(this); resize(VideoCore::kScreenTopWidth, VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight); layout->addWidget(child); From fb47258af76898f9f495e3da1a7db03a724cc9b3 Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 30 Apr 2014 18:34:49 -0700 Subject: [PATCH 12/28] TGA dumps work, courtesy of @bunnei --- src/citra/citra.cpp | 2 +- .../renderer_opengl/renderer_opengl.cpp | 2 + src/video_core/utils.cpp | 72 +++++++++---------- 3 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index d55b97393..458695ca7 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp @@ -24,7 +24,7 @@ int __cdecl main(int argc, char **argv) { System::Init(emu_window); - std::string boot_filename = "homebrew.elf"; + std::string boot_filename = "/Users/gandrade-air/Downloads/homebrew/yeti3DS-master.elf"; std::string error_str; bool res = Loader::LoadFile(boot_filename, &error_str); diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 314b1a8ed..5407c483a 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -6,6 +6,7 @@ #include "video_core/video_core.h" #include "video_core/renderer_opengl/renderer_opengl.h" +#include "video_core/utils.h" #include "core/mem_map.h" @@ -49,6 +50,7 @@ void RendererOpenGL::SwapBuffers() { // Switch back to EFB and clear glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo[kFramebuffer_EFB]); + VideoCore::DumpTGA("dump.tga", 400, 240, m_xfb_top_flipped); } /** diff --git a/src/video_core/utils.cpp b/src/video_core/utils.cpp index 67d74a2d8..9fcefaad3 100644 --- a/src/video_core/utils.cpp +++ b/src/video_core/utils.cpp @@ -8,39 +8,39 @@ #include "video_core/utils.h" namespace VideoCore { - -/** - * Dumps a texture to TGA - * @param filename String filename to dump texture to - * @param width Width of texture in pixels - * @param height Height of texture in pixels - * @param raw_data Raw RGBA8 texture data to dump - * @todo This should be moved to some general purpose/common code - */ -void DumpTGA(std::string filename, int width, int height, u8* raw_data) { - TGAHeader hdr; - FILE* fout; - u8 r, g, b; - - memset(&hdr, 0, sizeof(hdr)); - hdr.datatypecode = 2; // uncompressed RGB - hdr.bitsperpixel = 24; // 24 bpp - hdr.width = width; - hdr.height = height; - - fout = fopen(filename.c_str(), "wb"); - fwrite(&hdr, sizeof(TGAHeader), 1, fout); - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - r = raw_data[(4 * (i * width)) + (4 * j) + 0]; - g = raw_data[(4 * (i * width)) + (4 * j) + 1]; - b = raw_data[(4 * (i * width)) + (4 * j) + 2]; - putc(b, fout); - putc(g, fout); - putc(r, fout); - } - } - fclose(fout); -} - -} // namespace + + /** + * Dumps a texture to TGA + * @param filename String filename to dump texture to + * @param width Width of texture in pixels + * @param height Height of texture in pixels + * @param raw_data Raw RGBA8 texture data to dump + * @todo This should be moved to some general purpose/common code + */ + void DumpTGA(std::string filename, int width, int height, u8* raw_data) { + TGAHeader hdr; + FILE* fout; + u8 r, g, b; + + memset(&hdr, 0, sizeof(hdr)); + hdr.datatypecode = 2; // uncompressed RGB + hdr.bitsperpixel = 24; // 24 bpp + hdr.width = width; + hdr.height = height; + + fout = fopen(filename.c_str(), "wb"); + fwrite(&hdr, sizeof(TGAHeader), 1, fout); + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) { + b = raw_data[(3 * (i * width)) + (3 * j) + 0]; + g = raw_data[(3 * (i * width)) + (3 * j) + 1]; + r = raw_data[(3 * (i * width)) + (3 * j) + 2]; + putc(b, fout); + putc(g, fout); + putc(r, fout); + } + } + fclose(fout); + } + +} // namespace \ No newline at end of file From 541c9dffb7ff0b71d0e67b5f4a61ce4b3b89a494 Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 30 Apr 2014 18:34:49 -0700 Subject: [PATCH 13/28] Unintended change reversal --- src/video_core/utils.cpp | 72 ++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/video_core/utils.cpp b/src/video_core/utils.cpp index 67d74a2d8..9fcefaad3 100644 --- a/src/video_core/utils.cpp +++ b/src/video_core/utils.cpp @@ -8,39 +8,39 @@ #include "video_core/utils.h" namespace VideoCore { - -/** - * Dumps a texture to TGA - * @param filename String filename to dump texture to - * @param width Width of texture in pixels - * @param height Height of texture in pixels - * @param raw_data Raw RGBA8 texture data to dump - * @todo This should be moved to some general purpose/common code - */ -void DumpTGA(std::string filename, int width, int height, u8* raw_data) { - TGAHeader hdr; - FILE* fout; - u8 r, g, b; - - memset(&hdr, 0, sizeof(hdr)); - hdr.datatypecode = 2; // uncompressed RGB - hdr.bitsperpixel = 24; // 24 bpp - hdr.width = width; - hdr.height = height; - - fout = fopen(filename.c_str(), "wb"); - fwrite(&hdr, sizeof(TGAHeader), 1, fout); - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - r = raw_data[(4 * (i * width)) + (4 * j) + 0]; - g = raw_data[(4 * (i * width)) + (4 * j) + 1]; - b = raw_data[(4 * (i * width)) + (4 * j) + 2]; - putc(b, fout); - putc(g, fout); - putc(r, fout); - } - } - fclose(fout); -} - -} // namespace + + /** + * Dumps a texture to TGA + * @param filename String filename to dump texture to + * @param width Width of texture in pixels + * @param height Height of texture in pixels + * @param raw_data Raw RGBA8 texture data to dump + * @todo This should be moved to some general purpose/common code + */ + void DumpTGA(std::string filename, int width, int height, u8* raw_data) { + TGAHeader hdr; + FILE* fout; + u8 r, g, b; + + memset(&hdr, 0, sizeof(hdr)); + hdr.datatypecode = 2; // uncompressed RGB + hdr.bitsperpixel = 24; // 24 bpp + hdr.width = width; + hdr.height = height; + + fout = fopen(filename.c_str(), "wb"); + fwrite(&hdr, sizeof(TGAHeader), 1, fout); + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) { + b = raw_data[(3 * (i * width)) + (3 * j) + 0]; + g = raw_data[(3 * (i * width)) + (3 * j) + 1]; + r = raw_data[(3 * (i * width)) + (3 * j) + 2]; + putc(b, fout); + putc(g, fout); + putc(r, fout); + } + } + fclose(fout); + } + +} // namespace \ No newline at end of file From dade106aa92cd82864aeda2f17ef10da1ed8b49d Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 30 Apr 2014 18:44:48 -0700 Subject: [PATCH 14/28] Linux support --- src/citra/CMakeLists.txt | 7 ++++++- src/citra_qt/CMakeLists.txt | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/citra/CMakeLists.txt b/src/citra/CMakeLists.txt index ee3cb55cf..2e4fbe353 100644 --- a/src/citra/CMakeLists.txt +++ b/src/citra/CMakeLists.txt @@ -3,12 +3,17 @@ set(SRCS citra.cpp set(HEADS citra.h resource.h) +# NOTE: This is a workaround for CMake bug 0006976 (missing X11_xf86vmode_LIB variable) +if (NOT X11_xf86vmode_LIB) + set(X11_xv86vmode_LIB Xxf86vm) +endif() + add_executable(citra ${SRCS} ${HEADS}) if (APPLE) target_link_libraries(citra core common video_core iconv pthread ${COREFOUNDATION_LIBRARY} ${OPENGL_LIBRARIES} ${GLEW_LIBRARY} ${GLFW_LIBRARIES}) else() - target_link_libraries(citra core common video_core pthread ${OPENGL_LIBRARIES} ${GLEW_LIBRARY} ${GLFW_LIBRARIES}) + target_link_libraries(citra core common video_core GLEW pthread X11 Xxf86vm Xi Xcursor ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES} rt ${X11_Xrandr_LIB} ${X11_xv86vmode_LIB}) endif() #install(TARGETS citra RUNTIME DESTINATION ${bindir}) diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index b06be56fe..3a1335544 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt @@ -53,7 +53,7 @@ add_executable(citra-qt ${SRCS} ${HEADS} ${MOC_SRCS} ${UI_HDRS}) if (APPLE) target_link_libraries(citra-qt core common video_core qhexedit iconv ${COREFOUNDATION_LIBRARY} ${QT_LIBRARIES} ${GLEW_LIBRARY} ${OPENGL_LIBRARIES}) else() - target_link_libraries(citra-qt core common video_core qhexedit ${QT_LIBRARIES} ${GLEW_LIBRARY} ${OPENGL_LIBRARIES}) + target_link_libraries(citra-qt core common video_core qhexedit ${QT_LIBRARIES} ${OPENGL_LIBRARIES} ${SDL2_LIBRARY} rt GLEW ${GLFW_LIBRARIES}) endif() #install(TARGETS citra-qt RUNTIME DESTINATION ${bindir}) From 7b1d8045eeff7efded31aa50548e96dcfaba4959 Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 30 Apr 2014 19:51:36 -0700 Subject: [PATCH 15/28] Fix Travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8bad122b2..515dbde4a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,11 +4,11 @@ compiler: before_install: - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get -qq update - - sudo apt-get -qq install g++-4.8 xorg-dev libglu1-mesa-dev libglew-dev libxcursor-dev + - sudo apt-get -qq install g++-4.8 xorg-dev libglu1-mesa-dev libglew-dev libxcursor-dev libglew-dev - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 90 - git clone https://github.com/glfw/glfw.git - "mkdir glfw/build && cd glfw/build && cmake .. && make && sudo make install ; cd -" script: - mkdir build && cd build - cmake .. - - make -j4 \ No newline at end of file + - make -j4 From 25106ac96ee311e658a55b169eb8df0bb52900ee Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 30 Apr 2014 19:59:38 -0700 Subject: [PATCH 16/28] Revert "Fix Travis" This reverts commit 7b1d8045eeff7efded31aa50548e96dcfaba4959. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 515dbde4a..8bad122b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,11 +4,11 @@ compiler: before_install: - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get -qq update - - sudo apt-get -qq install g++-4.8 xorg-dev libglu1-mesa-dev libglew-dev libxcursor-dev libglew-dev + - sudo apt-get -qq install g++-4.8 xorg-dev libglu1-mesa-dev libglew-dev libxcursor-dev - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 90 - git clone https://github.com/glfw/glfw.git - "mkdir glfw/build && cd glfw/build && cmake .. && make && sudo make install ; cd -" script: - mkdir build && cd build - cmake .. - - make -j4 + - make -j4 \ No newline at end of file From 948cfe6d37558ee3a98649d88655a08774f09e3e Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 30 Apr 2014 20:00:44 -0700 Subject: [PATCH 17/28] Reverse debugging changes --- src/citra/citra.cpp | 2 +- src/video_core/renderer_opengl/renderer_opengl.cpp | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index 458695ca7..d55b97393 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp @@ -24,7 +24,7 @@ int __cdecl main(int argc, char **argv) { System::Init(emu_window); - std::string boot_filename = "/Users/gandrade-air/Downloads/homebrew/yeti3DS-master.elf"; + std::string boot_filename = "homebrew.elf"; std::string error_str; bool res = Loader::LoadFile(boot_filename, &error_str); diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 5407c483a..314b1a8ed 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -6,7 +6,6 @@ #include "video_core/video_core.h" #include "video_core/renderer_opengl/renderer_opengl.h" -#include "video_core/utils.h" #include "core/mem_map.h" @@ -50,7 +49,6 @@ void RendererOpenGL::SwapBuffers() { // Switch back to EFB and clear glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo[kFramebuffer_EFB]); - VideoCore::DumpTGA("dump.tga", 400, 240, m_xfb_top_flipped); } /** From 704075f04a8adda82141f3c68addfd6c34a08765 Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 30 Apr 2014 20:12:01 -0700 Subject: [PATCH 18/28] Fixed indents --- src/citra/CMakeLists.txt | 2 +- src/citra/emu_window/emu_window_glfw.cpp | 14 ++--- src/citra_qt/CMakeLists.txt | 2 +- src/citra_qt/bootmanager.cpp | 38 ++++++------- src/common/CMakeLists.txt | 2 +- src/core/CMakeLists.txt | 4 +- src/video_core/utils.cpp | 68 ++++++++++++------------ src/video_core/video_core.cpp | 4 +- 8 files changed, 66 insertions(+), 68 deletions(-) diff --git a/src/citra/CMakeLists.txt b/src/citra/CMakeLists.txt index 2e4fbe353..7787d6a72 100644 --- a/src/citra/CMakeLists.txt +++ b/src/citra/CMakeLists.txt @@ -13,7 +13,7 @@ add_executable(citra ${SRCS} ${HEADS}) if (APPLE) target_link_libraries(citra core common video_core iconv pthread ${COREFOUNDATION_LIBRARY} ${OPENGL_LIBRARIES} ${GLEW_LIBRARY} ${GLFW_LIBRARIES}) else() - target_link_libraries(citra core common video_core GLEW pthread X11 Xxf86vm Xi Xcursor ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES} rt ${X11_Xrandr_LIB} ${X11_xv86vmode_LIB}) + target_link_libraries(citra core common video_core GLEW pthread X11 Xxf86vm Xi Xcursor ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES} rt ${X11_Xrandr_LIB} ${X11_xv86vmode_LIB}) endif() #install(TARGETS citra RUNTIME DESTINATION ${bindir}) diff --git a/src/citra/emu_window/emu_window_glfw.cpp b/src/citra/emu_window/emu_window_glfw.cpp index ea1499e7c..73c116373 100644 --- a/src/citra/emu_window/emu_window_glfw.cpp +++ b/src/citra/emu_window/emu_window_glfw.cpp @@ -28,17 +28,17 @@ EmuWindow_GLFW::EmuWindow_GLFW() { } glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); - glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); m_render_window = glfwCreateWindow(VideoCore::kScreenTopWidth, (VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight), m_window_title.c_str(), NULL, NULL); - if (m_render_window == NULL) { - printf("Failed to create GLFW window! Exiting..."); - exit(1); - } - + if (m_render_window == NULL) { + printf("Failed to create GLFW window! Exiting..."); + exit(1); + } + // Setup callbacks glfwSetWindowUserPointer(m_render_window, this); //glfwSetKeyCallback(m_render_window, OnKeyEvent); diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index 3a1335544..9d983c0f0 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt @@ -53,7 +53,7 @@ add_executable(citra-qt ${SRCS} ${HEADS} ${MOC_SRCS} ${UI_HDRS}) if (APPLE) target_link_libraries(citra-qt core common video_core qhexedit iconv ${COREFOUNDATION_LIBRARY} ${QT_LIBRARIES} ${GLEW_LIBRARY} ${OPENGL_LIBRARIES}) else() - target_link_libraries(citra-qt core common video_core qhexedit ${QT_LIBRARIES} ${OPENGL_LIBRARIES} ${SDL2_LIBRARY} rt GLEW ${GLFW_LIBRARIES}) + target_link_libraries(citra-qt core common video_core qhexedit ${QT_LIBRARIES} ${OPENGL_LIBRARIES} ${SDL2_LIBRARY} rt GLEW ${GLFW_LIBRARIES}) endif() #install(TARGETS citra-qt RUNTIME DESTINATION ${bindir}) diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 52b39eb27..bd01b78c5 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -47,7 +47,7 @@ void EmuThread::run() void EmuThread::Stop() { - if (!isRunning()) + if (!isRunning()) { INFO_LOG(MASTER_LOG, "EmuThread::Stop called while emu thread wasn't running, returning..."); return; @@ -62,7 +62,7 @@ void EmuThread::Stop() terminate(); wait(1000); if (isRunning()) - WARN_LOG(MASTER_LOG, "EmuThread STILL running, something is wrong here..."); + WARN_LOG(MASTER_LOG, "EmuThread STILL running, something is wrong here..."); } INFO_LOG(MASTER_LOG, "EmuThread stopped"); } @@ -75,8 +75,8 @@ class GGLWidgetInternal : public QGLWidget public: GGLWidgetInternal(QGLFormat fmt, GRenderWindow* parent) : QGLWidget(parent) { - doneCurrent(); - parent_ = parent; + doneCurrent(); + parent_ = parent; } void paintEvent(QPaintEvent* ev) @@ -102,12 +102,12 @@ EmuThread& GRenderWindow::GetEmuThread() GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this) { // TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground, WA_DontShowOnScreen, WA_DeleteOnClose - QGLFormat fmt; - fmt.setProfile(QGLFormat::CoreProfile); - fmt.setVersion(4,1); - fmt.setSampleBuffers(true); - fmt.setSamples(4); - + QGLFormat fmt; + fmt.setProfile(QGLFormat::CoreProfile); + fmt.setVersion(4,1); + fmt.setSampleBuffers(true); + fmt.setSamples(4); + child = new GGLWidgetInternal(fmt, this); QBoxLayout* layout = new QHBoxLayout(this); resize(VideoCore::kScreenTopWidth, VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight); @@ -148,12 +148,12 @@ void GRenderWindow::DoneCurrent() void GRenderWindow::PollEvents() { // TODO(ShizZy): Does this belong here? This is a reasonable place to update the window title // from the main thread, but this should probably be in an event handler... - /* - static char title[128]; + /* + static char title[128]; sprintf(title, "%s (FPS: %02.02f)", window_title_.c_str(), video_core::g_renderer->current_fps()); setWindowTitle(title); - */ + */ } void GRenderWindow::BackupGeometry() @@ -186,26 +186,26 @@ QByteArray GRenderWindow::saveGeometry() void GRenderWindow::keyPressEvent(QKeyEvent* event) { - /* - bool key_processed = false; + /* + bool key_processed = false; for (unsigned int channel = 0; channel < 4 && controller_interface(); ++channel) if (controller_interface()->SetControllerStatus(channel, event->key(), input_common::GCController::PRESSED)) key_processed = true; if (!key_processed) QWidget::keyPressEvent(event); - */ + */ } void GRenderWindow::keyReleaseEvent(QKeyEvent* event) { - /* - bool key_processed = false; + /* + bool key_processed = false; for (unsigned int channel = 0; channel < 4 && controller_interface(); ++channel) if (controller_interface()->SetControllerStatus(channel, event->key(), input_common::GCController::RELEASED)) key_processed = true; if (!key_processed) QWidget::keyPressEvent(event); - */ + */ } \ No newline at end of file diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 48f30de4c..ae2331070 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -45,7 +45,7 @@ set(HEADS atomic.h memory_util.h msg_handler.h platform.h - scm_rev.h + scm_rev.h std_condition_variable.h std_mutex.h std_thread.h diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index c8d95ba5d..11b90434d 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -50,10 +50,10 @@ set(HEADS core.h arm/mmu/wb.h elf/elf_reader.h elf/elf_types.h - file_sys/directory_file_system.h + file_sys/directory_file_system.h file_sys/file_sys.h file_sys/meta_file_system.h - hle/hle.h + hle/hle.h hle/mrc.h hle/syscall.h hle/function_wrappers.h diff --git a/src/video_core/utils.cpp b/src/video_core/utils.cpp index 9fcefaad3..29382c814 100644 --- a/src/video_core/utils.cpp +++ b/src/video_core/utils.cpp @@ -8,39 +8,37 @@ #include "video_core/utils.h" namespace VideoCore { - - /** - * Dumps a texture to TGA - * @param filename String filename to dump texture to - * @param width Width of texture in pixels - * @param height Height of texture in pixels - * @param raw_data Raw RGBA8 texture data to dump - * @todo This should be moved to some general purpose/common code - */ - void DumpTGA(std::string filename, int width, int height, u8* raw_data) { - TGAHeader hdr; - FILE* fout; - u8 r, g, b; - - memset(&hdr, 0, sizeof(hdr)); - hdr.datatypecode = 2; // uncompressed RGB - hdr.bitsperpixel = 24; // 24 bpp - hdr.width = width; - hdr.height = height; - - fout = fopen(filename.c_str(), "wb"); - fwrite(&hdr, sizeof(TGAHeader), 1, fout); - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - b = raw_data[(3 * (i * width)) + (3 * j) + 0]; - g = raw_data[(3 * (i * width)) + (3 * j) + 1]; - r = raw_data[(3 * (i * width)) + (3 * j) + 2]; - putc(b, fout); - putc(g, fout); - putc(r, fout); - } - } - fclose(fout); - } - + /** + * Dumps a texture to TGA + * @param filename String filename to dump texture to + * @param width Width of texture in pixels + * @param height Height of texture in pixels + * @param raw_data Raw RGBA8 texture data to dump + * @todo This should be moved to some general purpose/common code + */ + void DumpTGA(std::string filename, int width, int height, u8* raw_data) { + TGAHeader hdr; + FILE* fout; + u8 r, g, b; + + memset(&hdr, 0, sizeof(hdr)); + hdr.datatypecode = 2; // uncompressed RGB + hdr.bitsperpixel = 24; // 24 bpp + hdr.width = width; + hdr.height = height; + + fout = fopen(filename.c_str(), "wb"); + fwrite(&hdr, sizeof(TGAHeader), 1, fout); + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) { + b = raw_data[(3 * (i * width)) + (3 * j) + 0]; + g = raw_data[(3 * (i * width)) + (3 * j) + 1]; + r = raw_data[(3 * (i * width)) + (3 * j) + 2]; + putc(b, fout); + putc(g, fout); + putc(r, fout); + } + } + fclose(fout); + } } // namespace \ No newline at end of file diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp index 4e9cd70bc..5f1933b1e 100644 --- a/src/video_core/video_core.cpp +++ b/src/video_core/video_core.cpp @@ -30,8 +30,8 @@ void Start() { /// Initialize the video core void Init(EmuWindow* emu_window) { - glewExperimental = GL_TRUE; - + glewExperimental = GL_TRUE; + g_emu_window = emu_window; g_emu_window->MakeCurrent(); g_renderer = new RendererOpenGL(); From 7817d6c79a2c169eb90714c1a05745d208e8ad32 Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 30 Apr 2014 23:47:38 -0700 Subject: [PATCH 19/28] Support for C++11 on OSX --- CMakeLists.txt | 5 ++--- src/common/common.h | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6837d36fd..07a04c2c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,9 +21,8 @@ pkg_search_module(GLFW REQUIRED glfw3) IF (APPLE) FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation) - SET(CMAKE_CXX_FLAGS "-stdlib=libc++") - SET(CMAKE_CXX_FLAGS_DEBUG "-stdlib=libc++") - SET(CMAKE_CXX_FLAGS_RELEASE "-stdlib=libc++") + SET(CMAKE_CXX_FLAGS "-stdlib=libc++") + SET(CMAKE_EXE_LINKER_FLAGS "-stdlib=libc++") ENDIF (APPLE) #external includes diff --git a/src/common/common.h b/src/common/common.h index 30a6761b7..2578d0010 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -25,7 +25,7 @@ #define HAVE_CXX11_SYNTAX 1 #endif -//#if HAVE_CXX11_SYNTAX +#if HAVE_CXX11_SYNTAX // An inheritable class to disallow the copy constructor and operator= functions class NonCopyable { @@ -37,7 +37,7 @@ private: NonCopyable(NonCopyable&); NonCopyable& operator=(NonCopyable& other); }; -//#endif +#endif #include "common/log.h" #include "common/common_types.h" From 1e729e7cae237a14067138aaf2b4f5933dba3b36 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 16 May 2014 23:03:10 -0700 Subject: [PATCH 20/28] Added FindGLEW to cmake-modules --- CMakeLists.txt | 2 +- externals/cmake-modules/FindGLEW.cmake | 47 ++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 externals/cmake-modules/FindGLEW.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 07a04c2c3..7aa6637df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,7 @@ add_definitions(-DSINGLETHREADED) add_definitions(${GCC_COMPILE_FLAGS}) # dependency checking +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules/") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeTests) include(FindX11 REQUIRED) find_package(PkgConfig REQUIRED) @@ -48,7 +49,6 @@ if(NOT DISABLE_QT4) endif() # generate git revision information -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules/") include(GetGitRevisionDescription) get_git_head_revision(GIT_REF_SPEC GIT_REV) git_describe(GIT_DESC --always --long --dirty) diff --git a/externals/cmake-modules/FindGLEW.cmake b/externals/cmake-modules/FindGLEW.cmake new file mode 100644 index 000000000..c95d558b6 --- /dev/null +++ b/externals/cmake-modules/FindGLEW.cmake @@ -0,0 +1,47 @@ +# +# Try to find GLEW library and include path. +# Once done this will define +# +# GLEW_FOUND +# GLEW_INCLUDE_PATH +# GLEW_LIBRARY +# + +IF (WIN32) + FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h + $ENV{PROGRAMFILES}/GLEW/include + ${PROJECT_SOURCE_DIR}/src/nvgl/glew/include + DOC "The directory where GL/glew.h resides") + FIND_LIBRARY( GLEW_LIBRARY + NAMES glew GLEW glew32 glew32s + PATHS + $ENV{PROGRAMFILES}/GLEW/lib + ${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin + ${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib + DOC "The GLEW library") +ELSE (WIN32) + FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h + /usr/include + /usr/local/include + /sw/include + /opt/local/include + DOC "The directory where GL/glew.h resides") + FIND_LIBRARY( GLEW_LIBRARY + NAMES GLEW glew + PATHS + /usr/lib64 + /usr/lib + /usr/local/lib64 + /usr/local/lib + /sw/lib + /opt/local/lib + DOC "The GLEW library") +ENDIF (WIN32) + +IF (GLEW_INCLUDE_PATH) + SET( GLEW_FOUND 1 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") +ELSE (GLEW_INCLUDE_PATH) + SET( GLEW_FOUND 0 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") +ENDIF (GLEW_INCLUDE_PATH) + +MARK_AS_ADVANCED( GLEW_FOUND ) From c1394650ff0ab1859b93505771e14c9afdb8aeb3 Mon Sep 17 00:00:00 2001 From: archshift Date: Fri, 16 May 2014 23:39:27 -0700 Subject: [PATCH 21/28] Updated cmakelists --- src/common/CMakeLists.txt | 1 + src/core/CMakeLists.txt | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index ae2331070..0027ae2b0 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -22,6 +22,7 @@ set(SRCS break_points.cpp set(HEADS atomic.h atomic_gcc.h atomic_win32.h + bit_field.h break_points.h chunk_file.h common_funcs.h diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index f96f04b15..ddf6bf79c 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -49,6 +49,7 @@ set(HEADS core.h mem_map.h system.h arm/disassembler/arm_disasm.h + arm/disassembler/load_symbol_map.h arm/interpreter/arm_interpreter.h arm/interpreter/arm_regformat.h arm/interpreter/armcpu.h @@ -57,18 +58,23 @@ set(HEADS core.h arm/interpreter/armmmu.h arm/interpreter/armos.h arm/interpreter/skyeye_defs.h - arm/mmu/arm1176jzf_s_mmu.h - arm/mmu/cache.h - arm/mmu/rb.h - arm/mmu/tlb.h - arm/mmu/wb.h + arm/interpreter/mmu/arm1176jzf_s_mmu.h + arm/interpreter/mmu/cache.h + arm/interpreter/mmu/rb.h + arm/interpreter/mmu/sa_mmu.h + arm/interpreter/mmu/tlb.h + arm/interpreter/mmu/wb.h + arm/interpreter/vfp/asm_vfp.h + arm/interpreter/vfp/vfp.h + arm/interpreter/vfp/vfp_helper.h elf/elf_reader.h elf/elf_types.h file_sys/directory_file_system.h file_sys/file_sys.h file_sys/meta_file_system.h + hle/config_mem.h + hle/coprocessor.h hle/hle.h - hle/mrc.h hle/syscall.h hle/function_wrappers.h hle/service/apt.h From c396a5ac576c172951e129f19a987398d53dc95c Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 17 May 2014 10:55:45 -0700 Subject: [PATCH 22/28] Fixed vfp issues --- src/core/arm/interpreter/mmu/maverick.cpp | 4 ++-- src/core/arm/interpreter/vfp/vfp_helper.h | 4 ++-- src/core/arm/interpreter/vfp/vfpdouble.cpp | 8 ++++---- src/core/arm/interpreter/vfp/vfpsingle.cpp | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/core/arm/interpreter/mmu/maverick.cpp b/src/core/arm/interpreter/mmu/maverick.cpp index 0e98ef22b..adcc2efb5 100644 --- a/src/core/arm/interpreter/mmu/maverick.cpp +++ b/src/core/arm/interpreter/mmu/maverick.cpp @@ -86,12 +86,12 @@ static union } reg_conv; static void -printf_nothing (void *foo, ...) +printf_nothing (const char *foo, ...) { } static void -cirrus_not_implemented (char *insn) +cirrus_not_implemented (const char *insn) { fprintf (stderr, "Cirrus instruction '%s' not implemented.\n", insn); fprintf (stderr, "aborting!\n"); diff --git a/src/core/arm/interpreter/vfp/vfp_helper.h b/src/core/arm/interpreter/vfp/vfp_helper.h index 80f9a93f4..b222e79f1 100644 --- a/src/core/arm/interpreter/vfp/vfp_helper.h +++ b/src/core/arm/interpreter/vfp/vfp_helper.h @@ -50,7 +50,7 @@ #define pr_info //printf #define pr_debug //printf -static u32 fls(int x); +static u32 vfp_fls(int x); #define do_div(n, base) {n/=base;} /* From vfpinstr.h */ @@ -508,7 +508,7 @@ struct op { u32 flags; }; -static inline u32 fls(int x) +static u32 vfp_fls(int x) { int r = 32; diff --git a/src/core/arm/interpreter/vfp/vfpdouble.cpp b/src/core/arm/interpreter/vfp/vfpdouble.cpp index cd5b5afa4..7f975cbeb 100644 --- a/src/core/arm/interpreter/vfp/vfpdouble.cpp +++ b/src/core/arm/interpreter/vfp/vfpdouble.cpp @@ -69,9 +69,9 @@ static void vfp_double_dump(const char *str, struct vfp_double *d) static void vfp_double_normalise_denormal(struct vfp_double *vd) { - int bits = 31 - fls(vd->significand >> 32); + int bits = 31 - vfp_fls(vd->significand >> 32); if (bits == 31) - bits = 63 - fls(vd->significand); + bits = 63 - vfp_fls(vd->significand); vfp_double_dump("normalise_denormal: in", vd); @@ -108,9 +108,9 @@ u32 vfp_double_normaliseround(ARMul_State* state, int dd, struct vfp_double *vd, exponent = vd->exponent; significand = vd->significand; - shift = 32 - fls(significand >> 32); + shift = 32 - vfp_fls(significand >> 32); if (shift == 32) - shift = 64 - fls(significand); + shift = 64 - vfp_fls(significand); if (shift) { exponent -= shift; significand <<= shift; diff --git a/src/core/arm/interpreter/vfp/vfpsingle.cpp b/src/core/arm/interpreter/vfp/vfpsingle.cpp index 05279f5ce..602713cff 100644 --- a/src/core/arm/interpreter/vfp/vfpsingle.cpp +++ b/src/core/arm/interpreter/vfp/vfpsingle.cpp @@ -69,7 +69,7 @@ static void vfp_single_dump(const char *str, struct vfp_single *s) static void vfp_single_normalise_denormal(struct vfp_single *vs) { - int bits = 31 - fls(vs->significand); + int bits = 31 - vfp_fls(vs->significand); vfp_single_dump("normalise_denormal: in", vs); @@ -111,7 +111,7 @@ u32 vfp_single_normaliseround(ARMul_State* state, int sd, struct vfp_single *vs, * bit 31, so we have VFP_SINGLE_LOW_BITS + 1 below the least * significant bit. */ - shift = 32 - fls(significand); + shift = 32 - vfp_fls(significand); if (shift < 32 && shift) { exponent -= shift; significand <<= shift; From 603ef89dad8f261464067c0e68c320d5bd595d25 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 17 May 2014 12:54:38 -0700 Subject: [PATCH 23/28] Indent fixes --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7aa6637df..f7ea1949b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ pkg_search_module(GLFW REQUIRED glfw3) IF (APPLE) FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation) - SET(CMAKE_CXX_FLAGS "-stdlib=libc++") + SET(CMAKE_CXX_FLAGS "-stdlib=libc++") SET(CMAKE_EXE_LINKER_FLAGS "-stdlib=libc++") ENDIF (APPLE) From 71b8789803e801dae6eae081c741523c62e071cd Mon Sep 17 00:00:00 2001 From: archshift Date: Mon, 19 May 2014 13:51:59 -0700 Subject: [PATCH 24/28] Indent fixes --- CMakeLists.txt | 2 +- externals/cmake-modules/FindGLEW.cmake | 58 ++++++++++++------------ src/video_core/utils.cpp | 62 +++++++++++++------------- 3 files changed, 61 insertions(+), 61 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f7ea1949b..b4665640c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ pkg_search_module(GLFW REQUIRED glfw3) IF (APPLE) FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation) SET(CMAKE_CXX_FLAGS "-stdlib=libc++") - SET(CMAKE_EXE_LINKER_FLAGS "-stdlib=libc++") + SET(CMAKE_EXE_LINKER_FLAGS "-stdlib=libc++") ENDIF (APPLE) #external includes diff --git a/externals/cmake-modules/FindGLEW.cmake b/externals/cmake-modules/FindGLEW.cmake index c95d558b6..105e30eb0 100644 --- a/externals/cmake-modules/FindGLEW.cmake +++ b/externals/cmake-modules/FindGLEW.cmake @@ -8,40 +8,40 @@ # IF (WIN32) - FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h - $ENV{PROGRAMFILES}/GLEW/include - ${PROJECT_SOURCE_DIR}/src/nvgl/glew/include - DOC "The directory where GL/glew.h resides") - FIND_LIBRARY( GLEW_LIBRARY - NAMES glew GLEW glew32 glew32s - PATHS - $ENV{PROGRAMFILES}/GLEW/lib - ${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin - ${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib - DOC "The GLEW library") + FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h + $ENV{PROGRAMFILES}/GLEW/include + ${PROJECT_SOURCE_DIR}/src/nvgl/glew/include + DOC "The directory where GL/glew.h resides") + FIND_LIBRARY( GLEW_LIBRARY + NAMES glew GLEW glew32 glew32s + PATHS + $ENV{PROGRAMFILES}/GLEW/lib + ${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin + ${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib + DOC "The GLEW library") ELSE (WIN32) - FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h - /usr/include - /usr/local/include - /sw/include - /opt/local/include - DOC "The directory where GL/glew.h resides") - FIND_LIBRARY( GLEW_LIBRARY - NAMES GLEW glew - PATHS - /usr/lib64 - /usr/lib - /usr/local/lib64 - /usr/local/lib - /sw/lib - /opt/local/lib - DOC "The GLEW library") + FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h + /usr/include + /usr/local/include + /sw/include + /opt/local/include + DOC "The directory where GL/glew.h resides") + FIND_LIBRARY( GLEW_LIBRARY + NAMES GLEW glew + PATHS + /usr/lib64 + /usr/lib + /usr/local/lib64 + /usr/local/lib + /sw/lib + /opt/local/lib + DOC "The GLEW library") ENDIF (WIN32) IF (GLEW_INCLUDE_PATH) - SET( GLEW_FOUND 1 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") + SET( GLEW_FOUND 1 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") ELSE (GLEW_INCLUDE_PATH) - SET( GLEW_FOUND 0 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") + SET( GLEW_FOUND 0 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise") ENDIF (GLEW_INCLUDE_PATH) MARK_AS_ADVANCED( GLEW_FOUND ) diff --git a/src/video_core/utils.cpp b/src/video_core/utils.cpp index 29382c814..a90fc183b 100644 --- a/src/video_core/utils.cpp +++ b/src/video_core/utils.cpp @@ -8,37 +8,37 @@ #include "video_core/utils.h" namespace VideoCore { - /** - * Dumps a texture to TGA - * @param filename String filename to dump texture to - * @param width Width of texture in pixels - * @param height Height of texture in pixels - * @param raw_data Raw RGBA8 texture data to dump - * @todo This should be moved to some general purpose/common code - */ - void DumpTGA(std::string filename, int width, int height, u8* raw_data) { - TGAHeader hdr; - FILE* fout; - u8 r, g, b; - - memset(&hdr, 0, sizeof(hdr)); - hdr.datatypecode = 2; // uncompressed RGB - hdr.bitsperpixel = 24; // 24 bpp - hdr.width = width; - hdr.height = height; - - fout = fopen(filename.c_str(), "wb"); - fwrite(&hdr, sizeof(TGAHeader), 1, fout); - for (int i = 0; i < height; i++) { - for (int j = 0; j < width; j++) { - b = raw_data[(3 * (i * width)) + (3 * j) + 0]; - g = raw_data[(3 * (i * width)) + (3 * j) + 1]; - r = raw_data[(3 * (i * width)) + (3 * j) + 2]; - putc(b, fout); - putc(g, fout); - putc(r, fout); - } +/** + * Dumps a texture to TGA + * @param filename String filename to dump texture to + * @param width Width of texture in pixels + * @param height Height of texture in pixels + * @param raw_data Raw RGBA8 texture data to dump + * @todo This should be moved to some general purpose/common code + */ +void DumpTGA(std::string filename, int width, int height, u8* raw_data) { + TGAHeader hdr; + FILE* fout; + u8 r, g, b; + + memset(&hdr, 0, sizeof(hdr)); + hdr.datatypecode = 2; // uncompressed RGB + hdr.bitsperpixel = 24; // 24 bpp + hdr.width = width; + hdr.height = height; + + fout = fopen(filename.c_str(), "wb"); + fwrite(&hdr, sizeof(TGAHeader), 1, fout); + for (int i = 0; i < height; i++) { + for (int j = 0; j < width; j++) { + b = raw_data[(3 * (i * width)) + (3 * j) + 0]; + g = raw_data[(3 * (i * width)) + (3 * j) + 1]; + r = raw_data[(3 * (i * width)) + (3 * j) + 2]; + putc(b, fout); + putc(g, fout); + putc(r, fout); } - fclose(fout); } + fclose(fout); +} } // namespace \ No newline at end of file From 403e4bf837c47c7e10dc006fafffea8c160c890f Mon Sep 17 00:00:00 2001 From: archshift Date: Mon, 19 May 2014 15:19:36 -0700 Subject: [PATCH 25/28] CMakeLists: rename HEADS, improved comments Changes for clarity of comments, removed redundant compiler flags. --- CMakeLists.txt | 5 ++--- src/citra/CMakeLists.txt | 4 ++-- src/citra_qt/CMakeLists.txt | 4 ++-- src/common/CMakeLists.txt | 4 ++-- src/core/CMakeLists.txt | 4 ++-- src/video_core/CMakeLists.txt | 4 ++-- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b4665640c..76190c5e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,8 +3,6 @@ cmake_minimum_required(VERSION 2.6) project(citra) SET(CMAKE_CXX_FLAGS "-std=c++11 -fpermissive") -SET(CMAKE_CXX_FLAGS_DEBUG "-std=c++11 -fpermissive") -SET(CMAKE_CXX_FLAGS_RELEASE "-std=c++11 -fpermissive") # silence some spam add_definitions(-Wno-attributes) @@ -20,6 +18,7 @@ find_package(GLEW REQUIRED) find_package(OpenGL REQUIRED) pkg_search_module(GLFW REQUIRED glfw3) +# corefoundation is required only on OSX IF (APPLE) FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation) SET(CMAKE_CXX_FLAGS "-stdlib=libc++") @@ -31,7 +30,7 @@ include_directories(${GLFW_INCLUDE_DIRS}) include_directories(${OPENGL_INCLUDE_DIR}) include_directories(${GLEW_INCLUDE_DIR}) -#use pkg_search_module library dirs +# workaround for GLFW linking on OSX link_directories(${GLFW_LIBRARY_DIRS}) option(DISABLE_QT4 "Disable Qt4 GUI" OFF) diff --git a/src/citra/CMakeLists.txt b/src/citra/CMakeLists.txt index 7787d6a72..1ad607d76 100644 --- a/src/citra/CMakeLists.txt +++ b/src/citra/CMakeLists.txt @@ -1,6 +1,6 @@ set(SRCS citra.cpp emu_window/emu_window_glfw.cpp) -set(HEADS citra.h +set(HEADERS citra.h resource.h) # NOTE: This is a workaround for CMake bug 0006976 (missing X11_xf86vmode_LIB variable) @@ -8,7 +8,7 @@ if (NOT X11_xf86vmode_LIB) set(X11_xv86vmode_LIB Xxf86vm) endif() -add_executable(citra ${SRCS} ${HEADS}) +add_executable(citra ${SRCS} ${HEADERS}) if (APPLE) target_link_libraries(citra core common video_core iconv pthread ${COREFOUNDATION_LIBRARY} ${OPENGL_LIBRARIES} ${GLEW_LIBRARY} ${GLFW_LIBRARIES}) diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index 9d983c0f0..549f69217 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt @@ -8,7 +8,7 @@ set(SRCS main.cpp config/controller_config.cpp config/controller_config_util.cpp) -set (HEADS +set (HEADERS bootmanager.hxx debugger/callstack.hxx debugger/disassembler.hxx @@ -49,7 +49,7 @@ qt4_wrap_cpp(MOC_SRCS include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(./) -add_executable(citra-qt ${SRCS} ${HEADS} ${MOC_SRCS} ${UI_HDRS}) +add_executable(citra-qt ${SRCS} ${HEADERS} ${MOC_SRCS} ${UI_HDRS}) if (APPLE) target_link_libraries(citra-qt core common video_core qhexedit iconv ${COREFOUNDATION_LIBRARY} ${QT_LIBRARIES} ${GLEW_LIBRARY} ${OPENGL_LIBRARIES}) else() diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 0027ae2b0..aae183393 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -19,7 +19,7 @@ set(SRCS break_points.cpp timer.cpp utf8.cpp) -set(HEADS atomic.h +set(HEADERS atomic.h atomic_gcc.h atomic_win32.h bit_field.h @@ -58,4 +58,4 @@ set(HEADS atomic.h timer.h utf8.h) -add_library(common STATIC ${SRCS} ${HEADS}) +add_library(common STATIC ${SRCS} ${HEADERS}) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index ddf6bf79c..14c598bf3 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -43,7 +43,7 @@ set(SRCS core.cpp hw/lcd.cpp hw/ndma.cpp) -set(HEADS core.h +set(HEADERS core.h core_timing.h loader.h mem_map.h @@ -86,4 +86,4 @@ set(HEADS core.h hw/lcd.h hw/ndma.h) -add_library(core STATIC ${SRCS} ${HEADS}) +add_library(core STATIC ${SRCS} ${HEADERS}) diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 8d04d381c..e43e6e1bb 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt @@ -2,9 +2,9 @@ set(SRCS video_core.cpp utils.cpp renderer_opengl/renderer_opengl.cpp) -set(HEADS video_core.h +set(HEADERS video_core.h utils.h renderer_base.h renderer_opengl/renderer_opengl.h) -add_library(video_core STATIC ${SRCS} ${HEADS}) +add_library(video_core STATIC ${SRCS} ${HEADERS}) From 034e3aabc81219ca3804bfa6483d6667c3ab5679 Mon Sep 17 00:00:00 2001 From: archshift Date: Mon, 19 May 2014 15:21:55 -0700 Subject: [PATCH 26/28] Improved clarity and whitespace Changed QGL version to 3,2 in order to be less restrictive, yet it should still change up to 4,1 on OSX on Qt5. --- src/citra_qt/bootmanager.cpp | 2 +- src/common/chunk_file.h | 1 + src/video_core/utils.cpp | 6 +++--- src/video_core/video_core.cpp | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index bd01b78c5..7089b9f97 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -104,7 +104,7 @@ GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this // TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground, WA_DontShowOnScreen, WA_DeleteOnClose QGLFormat fmt; fmt.setProfile(QGLFormat::CoreProfile); - fmt.setVersion(4,1); + fmt.setVersion(3,2); fmt.setSampleBuffers(true); fmt.setSamples(4); diff --git a/src/common/chunk_file.h b/src/common/chunk_file.h index c6a7cee35..8c9f839da 100644 --- a/src/common/chunk_file.h +++ b/src/common/chunk_file.h @@ -654,6 +654,7 @@ inline PointerWrapSection::~PointerWrapSection() { } +// Commented out because it is currently unused, and breaks builds on OSX /*class CChunkFileReader { public: diff --git a/src/video_core/utils.cpp b/src/video_core/utils.cpp index a90fc183b..b94376ac1 100644 --- a/src/video_core/utils.cpp +++ b/src/video_core/utils.cpp @@ -20,13 +20,13 @@ void DumpTGA(std::string filename, int width, int height, u8* raw_data) { TGAHeader hdr; FILE* fout; u8 r, g, b; - + memset(&hdr, 0, sizeof(hdr)); hdr.datatypecode = 2; // uncompressed RGB hdr.bitsperpixel = 24; // 24 bpp hdr.width = width; hdr.height = height; - + fout = fopen(filename.c_str(), "wb"); fwrite(&hdr, sizeof(TGAHeader), 1, fout); for (int i = 0; i < height; i++) { @@ -41,4 +41,4 @@ void DumpTGA(std::string filename, int width, int height, u8* raw_data) { } fclose(fout); } -} // namespace \ No newline at end of file +} // namespace diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp index 5f1933b1e..cbd540bdf 100644 --- a/src/video_core/video_core.cpp +++ b/src/video_core/video_core.cpp @@ -30,6 +30,7 @@ void Start() { /// Initialize the video core void Init(EmuWindow* emu_window) { + // Known problem with GLEW prevents contexts above 2.x on OSX unless glewExperimental is enabled. glewExperimental = GL_TRUE; g_emu_window = emu_window; From 9216c96f48b498788b78739655b64caf95307fe3 Mon Sep 17 00:00:00 2001 From: archshift Date: Mon, 19 May 2014 16:33:23 -0700 Subject: [PATCH 27/28] CMakeLists: Fixed GLEW include var name, compile flag vars After adding FindGLEW.cmake to externals, the variable call for the GLEW include path needed to be revised. Append flags on OSX, rather than overwrite them. I realized that GCC_COMPILE_FLAGS was changed to CMAKE_CXX_FLAGS mistakenly, so both were changed to a more platform-independent name. --- CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 76190c5e4..114e39207 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,12 +2,12 @@ cmake_minimum_required(VERSION 2.6) project(citra) -SET(CMAKE_CXX_FLAGS "-std=c++11 -fpermissive") +SET(CXX_COMPILE_FLAGS "-std=c++11 -fpermissive") # silence some spam add_definitions(-Wno-attributes) add_definitions(-DSINGLETHREADED) -add_definitions(${GCC_COMPILE_FLAGS}) +add_definitions(${CXX_COMPILE_FLAGS}) # dependency checking list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules/") @@ -21,14 +21,14 @@ pkg_search_module(GLFW REQUIRED glfw3) # corefoundation is required only on OSX IF (APPLE) FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation) - SET(CMAKE_CXX_FLAGS "-stdlib=libc++") - SET(CMAKE_EXE_LINKER_FLAGS "-stdlib=libc++") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++") ENDIF (APPLE) #external includes include_directories(${GLFW_INCLUDE_DIRS}) include_directories(${OPENGL_INCLUDE_DIR}) -include_directories(${GLEW_INCLUDE_DIR}) +include_directories(${GLEW_INCLUDE_PATH}) # workaround for GLFW linking on OSX link_directories(${GLFW_LIBRARY_DIRS}) From 5a8ed196e6e9416134a85fbc7da14fed3af307e4 Mon Sep 17 00:00:00 2001 From: archshift Date: Mon, 19 May 2014 17:57:35 -0700 Subject: [PATCH 28/28] common_types: Changed BasicRect back to Rect, in the common namespace Only Rect is in the namespace for now; the rest of common should be added in the future --- src/common/common_types.h | 10 ++++++---- src/video_core/renderer_opengl/renderer_opengl.cpp | 4 ++-- src/video_core/renderer_opengl/renderer_opengl.h | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/common/common_types.h b/src/common/common_types.h index 25dc912a9..402410507 100644 --- a/src/common/common_types.h +++ b/src/common/common_types.h @@ -100,16 +100,17 @@ union t128 { __m128 a; ///< 128-bit floating point (__m128 maps to the XMM[0-7] registers) }; +namespace common { /// Rectangle data structure -class BasicRect { +class Rect { public: - BasicRect(int x0=0, int y0=0, int x1=0, int y1=0) { + Rect(int x0=0, int y0=0, int x1=0, int y1=0) { x0_ = x0; y0_ = y0; x1_ = x1; y1_ = y1; } - ~BasicRect() { } + ~Rect() { } int x0_; ///< Rect top left X-coordinate int y0_; ///< Rect top left Y-coordinate @@ -119,7 +120,8 @@ public: inline u32 width() const { return abs(x1_ - x0_); } inline u32 height() const { return abs(y1_ - y0_); } - inline bool operator == (const BasicRect& val) const { + inline bool operator == (const Rect& val) const { return (x0_ == val.x0_ && y0_ == val.y0_ && x1_ == val.x1_ && y1_ == val.y1_); } }; +} diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index f2e809b1d..bb5eb34aa 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -37,7 +37,7 @@ void RendererOpenGL::SwapBuffers() { // EFB->XFB copy // TODO(bunnei): This is a hack and does not belong here. The copy should be triggered by some // register write We're also treating both framebuffers as a single one in OpenGL. - BasicRect framebuffer_size(0, 0, m_resolution_width, m_resolution_height); + common::Rect framebuffer_size(0, 0, m_resolution_width, m_resolution_height); RenderXFB(framebuffer_size, framebuffer_size); // XFB->Window copy @@ -75,7 +75,7 @@ void RendererOpenGL::FlipFramebuffer(const u8* in, u8* out) { * @param src_rect Source rectangle in XFB to copy * @param dst_rect Destination rectangle in output framebuffer to copy to */ -void RendererOpenGL::RenderXFB(const BasicRect& src_rect, const BasicRect& dst_rect) { +void RendererOpenGL::RenderXFB(const common::Rect& src_rect, const common::Rect& dst_rect) { FlipFramebuffer(LCD::GetFramebufferPointer(LCD::g_regs.framebuffer_top_left_1), m_xfb_top_flipped); FlipFramebuffer(LCD::GetFramebufferPointer(LCD::g_regs.framebuffer_sub_left_1), m_xfb_bottom_flipped); diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h index 06e602b46..dd811cad6 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.h +++ b/src/video_core/renderer_opengl/renderer_opengl.h @@ -28,7 +28,7 @@ public: * @param src_rect Source rectangle in XFB to copy * @param dst_rect Destination rectangle in output framebuffer to copy to */ - void RenderXFB(const BasicRect& src_rect, const BasicRect& dst_rect); + void RenderXFB(const common::Rect& src_rect, const common::Rect& dst_rect); /** * Set the emulator window to use for renderer