Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .devcontainer/switch/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"image": "devkitpro/devkita64"
}
41 changes: 39 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ jobs:

build_test_headless_alpine:
runs-on: ubuntu-latest
container:
container:
image: alpine:latest
options: --shm-size=8g
steps:
Expand All @@ -383,7 +383,7 @@ jobs:

- name: Setup ccache
uses: hendrikmuhs/[email protected]

- name: Compile ffmpeg
run: |
cd ffmpeg && ./linux_x86-64.sh
Expand All @@ -399,3 +399,40 @@ jobs:
- name: Execute headless tests
run: |
python test.py -g --graphics=software

build_switch:
runs-on: ubuntu-latest
container:
image: 'devkitpro/devkita64'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Build
run: |
mkdir -p build-switch
cd build-switch
cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/cmake/Switch.cmake \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_CONFIGURATION }} \
-DUSE_LIBNX:BOOL=TRUE \
-DUSING_GLES2:BOOL=TRUE \
-DUSING_EGL:BOOL=FALSE \
-DUSE_FFMPEG:BOOL=FALSE \
-DUSE_DISCORD:BOOL=FALSE \
-DUSE_MINIUPNPC:BOOL=FALSE \
-DUSE_ARMIPS:BOOL=FALSE \
-DUSE_SYSTEM_LIBPNG:BOOL=FALSE \
-DCMAKE_COLOR_DIAGNOSTICS:BOOL=TRUE \
..
ninja

- name: Upload artifacts
if: success()
uses: actions/upload-artifact@v4
with:
name: ppsspp-switch-build
path: |
build-switch/PPSSPP.elf
build-switch/PPSSPP.nro
29 changes: 24 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ option(UNITTEST "Set to ON to generate the unittest target" ${UNITTEST})
option(SIMULATOR "Set to ON when targeting an x86 simulator of an ARM platform" ${SIMULATOR})
option(LIBRETRO "Set to ON to generate the libretro target" OFF)
# :: Options
option(USE_LIBNX "Set to ON to build for Switch(libnx)" OFF)
option(USE_LIBNX "Set to ON to build for Switch (libnx)" OFF)
option(USE_FFMPEG "Build with FFMPEG support" ON)
option(USE_DISCORD "Build with Discord support" ON)
option(USE_MINIUPNPC "Build with miniUPnPc support" ON)
Expand Down Expand Up @@ -221,12 +221,21 @@ endif()

if(LIBRETRO)
add_definitions(-D__LIBRETRO__)
add_definitions(-DGLEW_NO_GLU)
set(GLEW_NO_GLU ON)
if(NOT MSVC)
add_compile_options(-fPIC)
endif()
endif()

if (USE_LIBNX)
add_definitions(-DHAVE_LIBNX)
set(GLEW_NO_GLU ON)
endif()

if (GLEW_NO_GLU)
add_definitions(-DGLEW_NO_GLU)
endif()

if(ANDROID)
set(MOBILE_DEVICE ON)
set(USING_GLES2 ON)
Expand Down Expand Up @@ -946,7 +955,7 @@ if(ARM64)
endif()
endif()

if(USING_GLES2 OR (USING_EGL AND NOT USING_FBDEV))
if((USING_GLES2 OR (USING_EGL AND NOT USING_FBDEV)) AND NOT USE_LIBNX)
find_package(X11)
endif()

Expand Down Expand Up @@ -1468,7 +1477,17 @@ else()
message(WARNING "Found SDL2_ttf <2.0.18 - this is too old, falling back to atlas")
endif()
if(SDL2_ttf_FOUND)
set(nativeExtraLibs ${nativeExtraLibs} SDL2_ttf::SDL2_ttf)
if(TARGET SDL2_ttf::SDL2_ttf)
set(nativeExtraLibs ${nativeExtraLibs} SDL2_ttf::SDL2_ttf)
else()
set(nativeExtraLibs ${nativeExtraLibs} SDL2_ttf::SDL2_ttf-static)
if (USE_LIBNX)
# devkitpro switch portlibs SDL2_ttf is pulling -lpng16. Remove it to use libpng17
get_target_property(SDL2_ttf_extra_libs SDL2_ttf::SDL2_ttf-static INTERFACE_LINK_LIBRARIES)
string(REPLACE "png16" "" SDL2_ttf_extra_libs_fixed "${SDL2_ttf_extra_libs}")
set_target_properties(SDL2_ttf::SDL2_ttf-static PROPERTIES INTERFACE_LINK_LIBRARIES "${SDL2_ttf_extra_libs_fixed}")
endif()
endif()
elseif(SDL2_ttf_PKGCONFIG_FOUND)
set(nativeExtraLibs ${nativeExtraLibs} PkgConfig::SDL2_ttf_PKGCONFIG)
endif()
Expand Down Expand Up @@ -2492,7 +2511,7 @@ endif()
include_directories(ext/libchdr/include)

target_link_libraries(${CoreLibName} Common native chdr kirk cityhash sfmt19937 xbrz xxhash rcheevos minimp3 at3_standalone lua ${GlslangLibs}
${CoreExtraLibs} ${OPENGL_LIBRARIES} ${X11_LIBRARIES} ${CMAKE_DL_LIBS})
${CoreExtraLibs} ${OPENGL_LIBRARIES} ${X11_LIBRARIES} $<$<NOT:$<BOOL:${USE_LIBNX}>>:${CMAKE_DL_LIBS}>)

# Winsock
if(WIN32)
Expand Down
66 changes: 43 additions & 23 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,43 @@
{
"version": 2,
"configurePresets": [
{
"name": "gcc-debug",
"binaryDir": "build-gcc-debug",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
},
{
"name": "clang-debug",
"binaryDir": "build-clang-debug",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
}
]
}
{
"version": 8,
"configurePresets": [
{
"name": "gcc-debug",
"binaryDir": "build-gcc-debug",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
},
{
"name": "clang-debug",
"binaryDir": "build-clang-debug",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
},
{
"name": "switch-debug",
"hidden": false,
"generator": "Ninja",
"binaryDir": "build-switch-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_TOOLCHAIN_FILE": "$env{DEVKITPRO}/cmake/Switch.cmake",
"USE_LIBNX": true,
"USING_GLES2": true,
"USING_EGL": false,
"USE_FFMPEG": false,
"USE_DISCORD": false,
"USE_MINIUPNPC": false,
"USE_ARMIPS": false,
"USE_SYSTEM_LIBPNG": false,
"CMAKE_EXPORT_COMPILE_COMMANDS": "YES",
"CMAKE_COLOR_DIAGNOSTICS": "YES"
}
}
]
}
3 changes: 3 additions & 0 deletions Common/Arm64Emitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#ifdef FMIN
#undef FMIN
#endif
#ifdef BIT
#undef BIT
#endif

namespace Arm64Gen
{
Expand Down
2 changes: 2 additions & 0 deletions Common/CommonTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ typedef signed __int64 s64;
#define Framebuffer _Framebuffer
#define Waitable _Waitable
#define ThreadContext _ThreadContext
#define BreakReason _BreakReason
#include <switch.h>
// Cleanup
#undef KEY_UP
Expand All @@ -57,6 +58,7 @@ typedef signed __int64 s64;
#undef Framebuffer
#undef Waitable
#undef ThreadContext
#undef BreakReason

// Conflicting types with libnx
#ifndef _u64
Expand Down
2 changes: 1 addition & 1 deletion Common/GPU/OpenGL/gl3stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "Common/GPU/OpenGL/GLCommon.h"

#if defined(USING_GLES2)
#if !PPSSPP_PLATFORM(IOS)
#if !PPSSPP_PLATFORM(IOS) && !PPSSPP_PLATFORM(SWITCH)
#include "EGL/egl.h"

GLboolean gl3stubInit() {
Expand Down
4 changes: 2 additions & 2 deletions Common/MemArenaHorizon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ u8 *MemArena::Find4GBBase() {
memorySrcBase = (uintptr_t)memalign(0x1000, 0x10000000);

if (!memoryBase)
memoryBase = (uintptr_t)virtmemReserve(0x10000000);
memoryBase = (uintptr_t)virtmemFindAslr(0x10000000, 0x1000);

if (!memoryCodeBase)
memoryCodeBase = (uintptr_t)virtmemReserve(0x10000000);
memoryCodeBase = (uintptr_t)virtmemFindAslr(0x10000000, 0x1000);

if (R_FAILED(svcMapProcessCodeMemory(envGetOwnProcessHandle(), (u64)memoryCodeBase, (u64)memorySrcBase, 0x10000000)))
printf("Failed to map memory...\n");
Expand Down
5 changes: 3 additions & 2 deletions Common/MemoryUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
#ifndef __SWITCH__
#include <sys/mman.h>
#else
#include <switch.h>
//#include <switch.h>
#endif // !__SWITCH__
#endif
#include <stdint.h>
#include <cstdint>
#include <cstddef>

// Returns true if we need to avoid setting both writable and executable at the same time (W^X)
bool PlatformIsWXExclusive();
Expand Down
19 changes: 4 additions & 15 deletions Common/Net/SocketCompat.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "ppsspp_config.h"

#include "Common/CommonTypes.h"

#if PPSSPP_PLATFORM(WINDOWS)
#include "Common/CommonWindows.h"
#include <io.h>
Expand All @@ -13,7 +15,9 @@
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/select.h>
#if !PPSSPP_PLATFORM(SWITCH)
#include <sys/mman.h>
#endif
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
Expand All @@ -27,21 +31,6 @@
#include <fcntl.h>
#include <errno.h>

#if defined(HAVE_LIBNX) || PPSSPP_PLATFORM(SWITCH)
#undef __BSD_VISIBLE
#define __BSD_VISIBLE 1
#define TCP_MAXSEG 2
#include <netdb.h>
#include <switch.h>
// Missing include, *shrugs*
extern "C" struct hostent *gethostbyname(const char *name);
#endif // defined(HAVE_LIBNX) || PPSSPP_PLATFORM(SWITCH)

#if PPSSPP_PLATFORM(SWITCH) && !defined(INADDR_NONE)
// Missing toolchain define
#define INADDR_NONE 0xFFFFFFFF
#endif

// TODO: move this to some common set
#if PPSSPP_PLATFORM(WINDOWS)
#undef ESHUTDOWN
Expand Down
11 changes: 5 additions & 6 deletions Common/StringUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/

#include <cstring>

#include "ppsspp_config.h"

#if PPSSPP_PLATFORM(SWITCH)
#define _GNU_SOURCE
#endif

#ifdef _WIN32
#include "Common/CommonWindows.h"
#endif

#if PPSSPP_PLATFORM(SWITCH)
#define _GNU_SOURCE
#include <cstdio>
#endif

#include <cstdarg>
#include <cstring>

#include <string>
#include <sstream>
Expand Down
2 changes: 2 additions & 0 deletions Common/Thread/ThreadUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ void RegisterAttachDetach(AttachDetachFunc attach, AttachDetachFunc detach) {
#include <pthread.h>
#include <sys/types.h>
#include <unistd.h>
#if !PPSSPP_PLATFORM(SWITCH)
#include <sys/syscall.h>
#endif
#endif

#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#include <pthread_np.h>
Expand Down
6 changes: 6 additions & 0 deletions Core/HLE/NetInetConstants.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include "ppsspp_config.h"

#if PPSSPP_PLATFORM(SWITCH)
#define __LINUX_ERRNO_EXTENSIONS__ 1
#endif

#include <string>
#include "Common/Net/SocketCompat.h"
#include "Common/StringUtils.h"
Expand Down Expand Up @@ -843,8 +847,10 @@ int convertInetErrnoHost2PSP(int error) {
return ERROR_INET_ECONNABORTED;
case ENETUNREACH:
return ERROR_INET_ENETUNREACH;
#if ENETDOWN != ESHUTDOWN
case ENETDOWN:
return ERROR_INET_ENETDOWN;
#endif
case ETIMEDOUT:
return ERROR_INET_ETIMEDOUT;
case EHOSTDOWN:
Expand Down
15 changes: 4 additions & 11 deletions Core/HLE/sceRtc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@
#include "Core/HLE/sceKernel.h"
#include "Core/HLE/sceRtc.h"

#ifdef HAVE_LIBNX
// I guess that works...
#define setenv(x, y, z) (void*)0
#define tzset() (void*)0
#define unsetenv(x) (void*)0
#endif // HAVE_LIBNX

// This is a base time that everything is relative to.
// This way, time doesn't move strangely with savestates, turbo speed, etc.
static PSPTimeval rtcBaseTime;
Expand Down Expand Up @@ -258,10 +251,10 @@ static u64 __RtcPspTimeToTicks(const ScePspDateTime &pt)
{
s64 z = days_from_civil(s64(pt.year), pt.month, pt.day);
return rtcMagicOffset +
pt.microsecond +
pt.microsecond +
1000000ull * (pt.second +
60ull * (pt.minute +
60ull * (pt.hour +
60ull * (pt.minute +
60ull * (pt.hour +
24ull * u64(z))));
}

Expand Down Expand Up @@ -822,7 +815,7 @@ static int sceRtcGetLastReincarnatedTime(u32 tickPtr)
static int sceRtcSetAlarmTick(u32 unknown1, u32 unknown2)
{
ERROR_LOG_REPORT(Log::sceRtc, "UNIMPL sceRtcSetAlarmTick(%x, %x)", unknown1, unknown2);
return 0;
return 0;
}

// Caller must check outPtr and srcTickPtr.
Expand Down
Loading
Loading