Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make PSP UI platform independent. #49

Merged
merged 57 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
28345d3
move PSP UI to top level
howard0su Dec 5, 2023
d3c304a
Cleanup UI code for platform independent
howard0su Dec 5, 2023
c580dfc
Get Code compiled
howard0su Dec 5, 2023
7b02681
Start working on UIContext implementation
howard0su Dec 5, 2023
2681ec5
Always Install resources for UI
howard0su Dec 5, 2023
c090e9a
rename to avoid conflict
howard0su Dec 5, 2023
9837fe1
Add back PSP output about color mode
howard0su Dec 5, 2023
1c6edff
Move DrawText.h to UI
howard0su Dec 6, 2023
8fe4602
UI is showing
howard0su Dec 6, 2023
abba1cd
Add input support
howard0su Dec 6, 2023
8d47324
Add stick support
howard0su Dec 6, 2023
659331f
Fix CI
howard0su Dec 6, 2023
e2f0ffa
More fixes on PSP
howard0su Dec 6, 2023
d6c79f1
Fix build
howard0su Dec 6, 2023
ae1b89b
Add cmake modeul for sdl2 ttf
howard0su Dec 6, 2023
f6b4b7d
fix psp build
howard0su Dec 6, 2023
1b5472b
Add more UI elements
howard0su Dec 6, 2023
860980c
Fix PSP build
howard0su Dec 6, 2023
7ee5048
Rename sdl2_ttf-config.cmake to FindSDL2_ttf.cmake
howard0su Dec 6, 2023
15bc0f5
Fix PSP Build
howard0su Dec 6, 2023
f1ebb46
Fix PSP build
howard0su Dec 6, 2023
62a5ac5
Fix PSP build
howard0su Dec 6, 2023
97e844e
Revert the sdl2_ttf cmake module
howard0su Dec 6, 2023
02b610e
Fix PSP build
howard0su Dec 6, 2023
734ed87
Make Win32 build on Release
howard0su Dec 7, 2023
66c15a0
Use release build
howard0su Dec 7, 2023
b457518
Fix 3DS
howard0su Dec 7, 2023
75d3eb0
enable debug build of win32
howard0su Dec 7, 2023
644d080
Handle special character
howard0su Dec 7, 2023
8791a7a
Merge branch 'master' into pspui
howard0su Dec 7, 2023
5c0dd83
Merge branch 'master' into pspui
howard0su Dec 8, 2023
a47d61a
Fix Windows build
howard0su Dec 8, 2023
8a6f1e6
different approach to handle x64 dynarec
howard0su Dec 8, 2023
f3a9ee8
Fix windows
howard0su Dec 8, 2023
f5771fe
Disable amd64 dynarec for now
howard0su Dec 9, 2023
29aa05b
fix compile error
howard0su Dec 9, 2023
b625001
Fix display on Windows
howard0su Dec 9, 2023
199835e
support OSX and enable screen scale
howard0su Dec 9, 2023
43f6f81
Fix font height API on TTF
howard0su Dec 9, 2023
22e7d34
try to render utf8
howard0su Dec 9, 2023
0e5a430
Try to fix linux build
howard0su Dec 9, 2023
15b9a01
Fix debug build
howard0su Dec 9, 2023
9cba217
osx has this support
howard0su Dec 10, 2023
c49122b
Try to fix OSX
howard0su Dec 10, 2023
5868e25
Fix Dynarec X64 bug on Windows
howard0su Dec 10, 2023
806baac
Enable AMD64 dynarec again
howard0su Dec 10, 2023
8f408a6
Fix windows x64 dynarec
howard0su Dec 10, 2023
76ca4a4
Fix Windows x64 dynarec
howard0su Dec 10, 2023
b1609f8
Add vcpkg installation script
howard0su Dec 11, 2023
b986a52
Merge branch 'master' into pspui
howard0su Dec 11, 2023
9adbe81
Fix env in workflow yml
howard0su Dec 11, 2023
6f4bd88
Fix 3ds build
howard0su Dec 11, 2023
7d6d937
Fix CI windows build
howard0su Dec 11, 2023
a754796
Fix 3DS build
howard0su Dec 11, 2023
b903b06
Move UIContext to Graphics
howard0su Dec 11, 2023
f9e0d98
Fix PSP build
howard0su Dec 11, 2023
0f48c67
Fix a bug in x64 dynarec
howard0su Dec 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:

- name: Install dependencies
run: |
sudo apt install build-essential git bash cmake libpng-dev libz-dev libminizip-dev libsdl2-dev libglew-dev
sudo apt install build-essential git bash cmake libpng-dev libz-dev libminizip-dev libsdl2-dev libsdl2-ttf-dev libglew-dev

- name: Compile project
run: |
Expand All @@ -99,9 +99,9 @@ jobs:
DaedalusX64/roms.ini \
DaedalusX64/readme.txt \
DaedalusX64/copying.txt \
# DaedalusX64/Resources \ # Not used in Posix Buiilds
# DaedalusX64/Languages \ # Not used in Posix Builds
# DaedalusX64/ControllerConfigs \ # Not used in Posix Builds
DaedalusX64/Resources \
DaedalusX64/Languages \
DaedalusX64/ControllerConfigs \


- name: Upload artifacts
Expand Down Expand Up @@ -195,7 +195,7 @@ jobs:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- name: Install dependencies
run: |
brew install git bash cmake libpng minizip sdl2 glew
brew install git bash cmake libpng minizip sdl2 sdl2_ttf glew

- name: Compile project
run: |
Expand All @@ -213,9 +213,9 @@ jobs:
DaedalusX64/roms.ini \
DaedalusX64/readme.txt \
DaedalusX64/copying.txt \
# DaedalusX64/Resources \ # Not used in Posix Buiilds
# DaedalusX64/Languages \ # Not used in Posix Builds
# DaedalusX64/ControllerConfigs \ # Not used in Posix Builds
DaedalusX64/Resources \
DaedalusX64/Languages \
DaedalusX64/ControllerConfigs \


- name: Upload artifacts
Expand Down Expand Up @@ -248,4 +248,27 @@ jobs:
# files: daedalusX64-macos-x86.tar.gz
# tag_name: ${{ steps.tag.outputs.VERSION }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-windows:
runs-on: windows-latest
env:
VCPKG_DEFAULT_TRIPLET: x64-windows
steps:
- uses: actions/checkout@v2

- uses: lukka/get-cmake@latest

- name: Setup a new (or from cache) vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: aa628ceb5f15f0c30d4d481f14fa5b2be2b4a658
runVcpkgInstall: true

- name: Run CMake config
run: |
cmake -S . -B build "-DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake" "-DVCPKG_TARGET_TRIPLET=x64-windows"

- name: Build
run: |
cmake --build build --config Release
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ Source/tmp
*.cia
*.3dsx
/debug/
/vcpkg_installed/
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ project (DaedalusX64 LANGUAGES C CXX ASM)

message(${CMAKE_SYSTEM_PROCESSOR} " Detected")

INCLUDE(FindPkgConfig)

add_subdirectory(Source)
9 changes: 3 additions & 6 deletions Source/Base/Assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ enum EAssertResult
AR_BREAK,
};

EAssertResult DAEDALUS_VARARG_CALL_TYPE DaedalusAssert( const char * expression, const char * file, unsigned int line, const char * msg, ... );

#ifdef DAEDALUS_PSP
#define DAEDALUS_HALT __asm__ __volatile__ ( "break" )
#elif DAEDALUS_POSIX
Expand All @@ -48,18 +46,17 @@ EAssertResult DAEDALUS_VARARG_CALL_TYPE DaedalusAssert( const char * expression,
#define DAEDALUS_HALT __asm__ __volatile__ ( "bkpt" )

#elif DAEDALUS_W32 // Ugh this needs simplifying
#include "Sys32/Include/DaedalusW32.h" // Windows is special
#include <crtdbg.h>
#define __PRETTY_FUNCTION__ __FUNCTION__
#define _CRT_SECURE_NO_DEPRECATE
#define _DO_NOT_DECLARE_INTERLOCKED_INTRINSICS_IN_MEMORY

#define DAEDALUS_THREAD_CALL_TYPE __stdcall // Thread functions need to be __stdcall to work with the W32 api
#define DAEDALUS_VARARG_CALL_TYPE __cdecl // Vararg functions need to be __cdecl
#define DAEDALUS_HALT __asm { int 3 }
#define DAEDALUS_HALT _CrtDbgBreak()
#else
#error Unknown Platforn DAEDALUS_HALT should be defined in Base/Assert.h
#endif

EAssertResult DAEDALUS_VARARG_CALL_TYPE DaedalusAssert( const char * expression, const char * file, unsigned int line, const char * msg, ... );

//
// Use this api to override the default assert handler, e.g. for logging asserts during a batch process
Expand Down
4 changes: 4 additions & 0 deletions Source/Base/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,8 @@ union REG32
#define DATA_ALIGN 16
#define CACHE_ALIGN 64

#ifdef _MSC_VER
#define strcasecmp _stricmp
#endif

#endif // UTILITY_DAEDALUSTYPES_H_
80 changes: 40 additions & 40 deletions Source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ if(DEBUG)
option(DAEDALUS_DEBUG_CONSOLE "Enable Debug Console" ON)
option(DAEDALUS_DEBUG_DISPLAYLIST "Options for debugging the display list, useful for determining texture issues" OFF)
option(DAEDALUS_LOG "Enable various logging" ON)
add_compile_options("-g")
if(NOT WIN32)
add_compile_options("-Wall")
add_compile_options("-Wextra")
endif()
else()
set(CMAKE_BUILD_TYPE RelWithDebInfo)
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
add_compile_definitions(DAEDALUS_CONFIG_VERSION="Release") ## Perhaps we can remove this. It's only used in the PSP UI and model doesn't matter as much
endif()
Expand All @@ -45,6 +46,9 @@ endif()
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
message("x86_64 Dynarec Enabled")
option(DAEDALUS_ENABLE_DYNAREC "Enable Dynarec" ON)
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
message("AMD64 Dynarec Enabled")
option(DAEDALUS_ENABLE_DYNAREC "Enable Dynarec" ON)
else()
message("Platform unknown, Dynarec disabled")
option(DAEDALUS_ENABLE_DYNAREC "Enable Dynarec" OFF)
Expand Down Expand Up @@ -106,40 +110,33 @@ endif()
option(DAEDALUS_DAEDALUS_ACCURATE_CVT "Convert using the rounding mode specified in the Floating Control/Status register (FCSR)")
option(DAEDALUS_GL "OpenGL Renderer" ON)
elseif(WIN32)
option(DAEDALUS_WIN32 "Windows specific Options" ON)
option(DAEDALUS_SDL "SDL Build" ON)
option(DAEDALUS_W32 "Windows specific Options" ON)
option(DAEDALUS_ENABLE_DYNAREC "Enable Dynamic Recompilation, Disable if system not supported" ON)
option(DAEDALUS_ACCURATE_TMEM "Accurate TMEM" ON)
option(DAEDALUS_BREAKPOINTS_ENABLED "Enable Breakpoints" OFF)
option(DAEDALUS_GL "OpenGL Renderer" ON)
enable_language(CXX ASM_MASM)
elseif(CTR)
option(DAEDALUS_CTR "3DS Specific Options" ON)
option(DAEDALUS_ENABLE_DYNAREC "Enable Dynamic Recompilation" ON)
option(DAEDALUS_ENABLE_OS_HOOKS " High Level Emulation Hooks" ON)
endif()

if(DAEDALUS_SDL)
find_package(SDL2 CONFIG REQUIRED)
list(APPEND default_libraries "${SDL2_LIBRARIES}")
list(APPEND include_dirs "${SDL2_INCLUDE_DIRS}")

if(DAEDALUS_GL)
list(APPEND include_dirs "${PROJECT_SOURCE_DIR}/Source/third_party/imgui/" ) #This doesn't like being called from another file
endif(DAEDALUS_GL)

endif(DAEDALUS_SDL)

# Needed below the options to post process
include(${PROJECT_SOURCE_DIR}/Options.cmake)

#Setup directories to include
list(APPEND include_dirs "${PROJECT_SOURCE_DIR}/Source")
include_directories( BEFORE ${include_dirs})


## Generic defines for certain things that Windows requires.
if(NOT WIN32)
add_compile_definitions(DAEDALUS_THREAD_CALL_TYPE=${})
add_compile_definitions(DAEDALUS_VARARG_CALL_TYPE=${})
else()
add_compile_definitions(DAEDALUS_THREAD_CALL_TYPE=__stdcall)
add_compile_definitions(DAEDALUS_VARARG_CALL_TYPE=__cdecl)
endif()

if(UNIX)
Expand Down Expand Up @@ -168,29 +165,36 @@ if(CTR)
include_directories($ENV{DEVKITPRO}/portlibs/3ds/lib)
endif(CTR)

if(WIN32)
set(CMAKE_TOOLCHAIN_FILE ${VCPKG_TOOLCHAIN})
find_package(ZLIB)
if(DAEDALUS_SDL)
find_package(SDL2 CONFIG REQUIRED)
find_package(GLEW REQUIRED)

set(sys_libraries png z minizip pthread GLEW SDL2 dl ${OS_LIBS})
# Pull in modules for glew / SDL2 / ZLib / LibPNG / Minizip
link_libraries(SDL2::SDL2)
link_libraries(${SDL2_LIBRARIES})

if(NOT PSP)
# PSP is not needed as it uses built-in native font
find_package(SDL2_ttf QUIET)
if(SDL2_ttf_FOUND)
link_libraries(SDL2_ttf::SDL2_ttf)
else()
PKG_SEARCH_MODULE(SDL2_TTF REQUIRED SDL2_ttf>=2.0.0)
link_libraries(${SDL2_TTF_LIBRARIES})
endif()
endif()
endif(DAEDALUS_SDL)

# add_library(sysGL OBJECT ${SYSGL_BUILD})
# target_link_libraries(sysGL OpenGL32 glfw3 glew32s SDL2 Xinput ${OS_LIBS})
if(DAEDALUS_GL)
find_package(OpenGL REQUIRED)
link_libraries(OpenGL::GL)

# add_library(daedalus.lib OBJECT ${BUILD} ${WIN_BUILD} ${AUDIO_DRIVER} )
# target_link_libraries(daedalus.lib dsound dxguid sysGL libpng zlib zlibwapi)
find_package(GLEW REQUIRED)
link_libraries(GLEW::GLEW)
endif(DAEDALUS_GL)

#Build and Link Executable
find_package(PNG REQUIRED)
link_libraries(PNG::PNG)

add_executable(daedalus SysW32/main.cpp)
target_link_libraries(daedalus LINK_PUBLIC
Core Config Debug Graphics HLEAudio HLEGraphics Interface Math OSHLE RomFile System Utility
Graphics_GL HLEGraphics_GL Input_GL Interface_GL imgui
Win_Debug Win_Audio Win_Utility)
endif (WIN32)
find_package(ZLIB REQUIRED)
link_libraries(ZLIB::ZLIB)

## Daedalus Core Build
add_subdirectory(Config)
Expand All @@ -207,11 +211,11 @@ if(WIN32)
add_subdirectory(System)
add_subdirectory(Test)
add_subdirectory(Utility)
add_subdirectory(UI)

if(UNIX)
add_subdirectory(SysPosix)
add_subdirectory(SysGL)
add_subdirectory(third_party/imgui)
elseif(WIN32) ## Probably keep this generic as we'll build this on Linux too?
add_subdirectory(SysGL)
add_subdirectory(SysW32)
Expand All @@ -221,13 +225,9 @@ if(WIN32)
add_subdirectory(SysPSP)
endif()


# --- Build ----
add_executable(daedalus ${plat_main})
list(APPEND default_libraries png z) ## Required Libraries

message(" ${daed_libs} ${default_libraries} ${sys_libraries} " )
target_include_directories(daedalus BEFORE PUBLIC ${include_dirs})

target_link_libraries(daedalus PRIVATE ${daed_libs} ${default_libraries} ${sys_libraries})

# --- Post Build ---
Expand Down Expand Up @@ -278,7 +278,7 @@ if(WIN32)
endif(CTR)

## Install and setup basic directories
install(DIRECTORY DESTINATION DaedalusX64)
install(DIRECTORY ${PROJECT_BINARY_DIR}/../Data/ DESTINATION DaedalusX64)
install(DIRECTORY DESTINATION DaedalusX64/Roms)
install(DIRECTORY DESTINATION DaedalusX64/SaveGames)
install(DIRECTORY DESTINATION DaedalusX64/SaveStates)
19 changes: 9 additions & 10 deletions Source/Core/CPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ bool CPU_RequestSaveState( const std::filesystem::path &filename )
}

gSaveStateOperation = SSO_SAVE;
gSaveStateFilename = filename;
gSaveStateFilename = filename.string();
gCPUState.AddJob(CPU_CHANGE_CORE);

return true;
Expand All @@ -453,7 +453,7 @@ bool CPU_RequestLoadState( const std::filesystem::path &filename )
}

gSaveStateOperation = SSO_LOAD;
gSaveStateFilename = filename;
gSaveStateFilename = filename.string();
gCPUState.AddJob(CPU_CHANGE_CORE);

return true; // XXXX could fail
Expand Down Expand Up @@ -672,16 +672,15 @@ void CPU_HANDLE_COUNT_INTERRUPT()
// N cycles, but that would have a small impact on framerate (it would
// interrupt the dynamo tracer for instance)
// TODO(strmnnrmn): should register this with CPU_RegisterVblCallback.
if ((gVerticalInterrupts & 0x3F) == 0) // once every 60 VBLs
// Save_Flush();
if ((gVerticalInterrupts & 0x3F) == 0) { // once every 60 VBLs
// Save_Flush();
for (size_t i = 0; i < gVblCallbacks.size(); ++i)
{
VblCallback & callback = gVblCallbacks[i];
callback.Fn(callback.Arg);
}

//TESTING
for (size_t i = 0; i < gVblCallbacks.size(); ++i)
{
VblCallback & callback = gVblCallbacks[i];
callback.Fn(callback.Arg);
}

HandleSaveStateOperationOnVerticalBlank();
}
break;
Expand Down
9 changes: 3 additions & 6 deletions Source/Core/Cheats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Ultra/ultra_R4300.h"
#include "System/IO.h"
#include "Utility/StringUtil.h"
#include "SysPSP/Utility/VolatileMem.h"
#include "Utility/VolatileMem.h"
#include <filesystem>

//
Expand Down Expand Up @@ -290,14 +290,11 @@ bool CheatCodes_Read(const char *rom_name, const char *file, u8 countryID)
// Always clear when parsing a new ROM
CheatCodes_Clear();

std::filesystem::path p(file);
const char *cheat_file = p.c_str();

stream = fopen(cheat_file, "rt");
stream = fopen("cheat_file", "rt");
if(stream == nullptr)
{
// File does not exist, try to create a new empty one
stream = fopen(cheat_file, "wt");
stream = fopen("cheat_file", "wt");

if(stream == nullptr)
{
Expand Down
4 changes: 4 additions & 0 deletions Source/Core/Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "HLEAudio/AudioPlugin.h"
#include "HLEGraphics/GraphicsPlugin.h"

#ifdef DAEDALUS_W32
#include <windows.h>
#endif

static const u32 kMaximumMemSize = MEMORY_8_MEG;

#undef min
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/ROM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ void ROM_UnloadFile()

bool ROM_LoadFile(const RomID & rom_id, const RomSettings & settings, const SRomPreferences & preferences )
{
DBGConsole_Msg(0, "Reading rom image: [C%s]", g_ROM.mFileName.c_str());
DBGConsole_Msg(0, "Reading rom image: [C%s]", g_ROM.mFileName.string().c_str());

// Get information about the rom header
RomBuffer::GetRomBytesRaw( &g_ROM.rh, 0, sizeof(ROMHeader) );
Expand Down
Loading
Loading