Skip to content
Draft
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
72 changes: 72 additions & 0 deletions .github/workflows/vita.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: PlayStation Vita

on:
push:
branches-ignore:
- 'l10n_**'
pull_request:

env:
VITASDK: /usr/local/vitasdk

jobs:
build:
name: Vita ${{ matrix.config.name }}
runs-on: ubuntu-latest

strategy:
matrix:
config:
- {name: standalone, destDir: vita}

steps:
- name: Set up build environment
run: |
sudo apt-get update
sudo apt-get -y install ccache
git clone --depth=1 https://github.com/vitasdk/vdpm.git
bash vdpm/bootstrap-vitasdk.sh
echo "$VITASDK/bin" >> "$GITHUB_PATH"

- name: Set up dependencies
run: |
vdpm asio bzip2 curl-mbedtls kubridge libmathneon libpng libzip mbedtls openssl SceShaccCgExt vitaShaRK taihen zlib zstd xz
git clone --depth 1 https://github.com/Rinnegatamante/vitaGL.git
make -C vitaGL CIRCULAR_VERTEX_POOL=2 DEPTH_STENCIL_HACK=1 HAVE_SHADER_CACHE=1 HAVE_WRAPPED_ALLOCATORS=1 NO_DEBUG=1 -j4 install
git clone -b vitagl --depth 1 https://github.com/Northfear/SDL.git
cmake -S SDL -B SDL_build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_TOOLCHAIN_FILE=${VITASDK}/share/vita.toolchain.cmake -DVIDEO_VITA_VGL=ON
cmake --build SDL_build --config Release
cmake --install SDL_build

- uses: actions/checkout@v6
with:
fetch-depth: 0
submodules: recursive

- uses: actions/cache@v5
with:
path: ~/.ccache
key: ccache-vita-${{ matrix.config.name }}-${{ github.sha }}
restore-keys: ccache-vita-${{ matrix.config.name }}-

- name: CMake
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$VITASDK/share/vita.toolchain.cmake -G Ninja ${{ matrix.config.cmakeArgs }}
cmake --build build --config Release --target Flycast.vpk-vpk

- uses: actions/upload-artifact@v6
with:
name: flycast-vita-${{ matrix.config.name }}
path: |
build/flycast
build/Flycast.vpk

- name: Setup Rclone
uses: AnimMouse/setup-rclone@v1
with:
rclone_config: ${{ secrets.RCLONE_CONFIG }}
version: v1.69.1

- name: Upload to S3
run: rclone copy build scaleway:flycast-builds/${{ matrix.config.destDir }}/${GITHUB_REF#refs/}-$GITHUB_SHA
if: github.repository == 'flyinghead/flycast' && github.event_name == 'push' && matrix.config.destDir != ''
116 changes: 106 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ if(APPLE)
set(ZLIB_LIBRARY "-lz" CACHE STRING "Use generic linker flag for Xcode to support multiple SDKs")
endif()

if(VITA)
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
if(DEFINED ENV{VITASDK})
set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file")
else()
message(FATAL_ERROR "Please define VITASDK to point to your SDK path!")
endif()
endif()
endif()

if(LIBRETRO)
project(flycast_libretro)
else()
Expand All @@ -49,7 +59,7 @@ endif()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(CMAKE_SYSTEM_NAME MATCHES "NetBSD|Haiku" OR NINTENDO_SWITCH)
if(CMAKE_SYSTEM_NAME MATCHES "NetBSD|Haiku" OR NINTENDO_SWITCH OR VITA)
set(CMAKE_CXX_EXTENSIONS ON)
else()
set(CMAKE_CXX_EXTENSIONS OFF)
Expand Down Expand Up @@ -159,7 +169,32 @@ endif()
string(TIMESTAMP BUILD_TIMESTAMP UTC)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/core/version.h.in" "${CMAKE_CURRENT_SOURCE_DIR}/core/version.h" @ONLY)

if(NINTENDO_SWITCH)
if(VITA)
include("${VITASDK}/share/vita.cmake" REQUIRED)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-q,--wrap,memcpy,--wrap,memset,--wrap,malloc,--wrap,memalign,--wrap,free,--wrap,calloc,--wrap,realloc -fno-optimize-sibling-calls -fsigned-char -fno-short-enums -marm")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q,--wrap,malloc,--wrap,memalign,--wrap,free,--wrap,calloc,--wrap,realloc -fno-optimize-sibling-calls -fsigned-char -fno-short-enums -marm")

set(VITA_APP_NAME "Flycast")
set(VITA_TITLEID "FLYCASTDC")
set(VITA_VPKNAME "Flycast")
set(VITA_VERSION "01.00")
set(VITA_MKSFOEX_FLAGS "-d ATTRIBUTE2=12")

set(USE_VULKAN OFF)
set(USE_GLES2 ON)
enable_language(ASM)

if(LIBRETRO)
add_library(${PROJECT_NAME} STATIC core/emulator.cpp)
target_compile_definitions(${PROJECT_NAME} PRIVATE LIBRETRO VITA)
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "flycast_libretro_vita")
else()
add_executable(${PROJECT_NAME} core/emulator.cpp)
endif()

target_compile_definitions(${PROJECT_NAME} PRIVATE GLES IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS)
elseif(NINTENDO_SWITCH)
set(USE_VULKAN OFF)
enable_language(ASM)

Expand Down Expand Up @@ -276,7 +311,9 @@ if(WINDOWS_STORE)
set(USE_VULKAN OFF)
endif()

set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE -s)
if(NOT VITA)
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS_RELEASE -s)
endif()
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /GR /GS- /utf-8)
if(WINDOWS_STORE)
Expand Down Expand Up @@ -320,7 +357,10 @@ if(NOT "${SENTRY_UPLOAD_URL}" STREQUAL "")
target_compile_definitions(${PROJECT_NAME} PRIVATE SENTRY_UPLOAD="${SENTRY_UPLOAD_URL}")
endif()

target_include_directories(${PROJECT_NAME} PRIVATE core core/deps core/deps/stb core/deps/json core/deps/asio/asio/include)
target_include_directories(${PROJECT_NAME} PRIVATE core core/deps core/deps/stb core/deps/json)
if (NOT VITA)
target_include_directories(${PROJECT_NAME} PRIVATE core/deps/asio/asio/include)
endif()
if(LIBRETRO)
target_include_directories(${PROJECT_NAME} PRIVATE shell/libretro)
endif()
Expand Down Expand Up @@ -482,7 +522,7 @@ if(NOT LIBRETRO)
endif()

if(NOT ANDROID AND NOT IOS)
if (NOT NINTENDO_SWITCH)
if (NOT NINTENDO_SWITCH AND NOT VITA)
# DreamLink enabled for non-mobile Linux, MacOS, and Windows
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_DREAMLINK_DEVICES=1)
set(USE_DREAMLINK_DEVICES ON) # Must be set before adding core/sdl
Expand Down Expand Up @@ -518,6 +558,9 @@ if(NOT LIBRETRO)
if(USE_HOST_SDL)
find_package(SDL2 2.0.9)
endif()
if(VITA)
set(SDL2_FOUND 1)
endif()
if(NOT SDL2_FOUND)
set(SDL_TEST_ENABLED_BY_DEFAULT OFF)
add_subdirectory(core/deps/SDL EXCLUDE_FROM_ALL)
Expand All @@ -530,7 +573,7 @@ if(NOT LIBRETRO)
target_link_libraries(${PROJECT_NAME} PRIVATE SDL2::SDL2main)
endif()

if((APPLE OR WIN32) AND TARGET SDL2::SDL2-static)
if((APPLE OR WIN32 OR VITA) AND TARGET SDL2::SDL2-static)
target_link_libraries(${PROJECT_NAME} PRIVATE SDL2::SDL2-static)
elseif(TARGET SDL2::SDL2)
target_link_libraries(${PROJECT_NAME} PRIVATE SDL2::SDL2)
Expand All @@ -542,7 +585,7 @@ if(NOT LIBRETRO)
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_SDL USE_SDL_AUDIO)
add_subdirectory(core/sdl)

if((UNIX AND NOT APPLE) OR NINTENDO_SWITCH)
if((UNIX AND NOT APPLE) OR NINTENDO_SWITCH OR VITA)
find_package(CURL REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE CURL::libcurl)
endif()
Expand Down Expand Up @@ -643,6 +686,10 @@ if(PKG_CONFIG_FOUND AND NOT ANDROID AND NOT APPLE AND NOT LIBRETRO)
endif()
endif()

if(VITA)
target_link_libraries(${PROJECT_NAME} PRIVATE vitaGL vitashark SceShaccCg_stub SceShaccCgExt taihen_stub mathneon)
endif()

if(UNIX AND NOT APPLE AND NOT ANDROID)
add_definitions(
-DFLYCAST_DATADIR="${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/"
Expand Down Expand Up @@ -718,7 +765,7 @@ add_subdirectory(core/deps/nowide EXCLUDE_FROM_ALL)
target_link_libraries(${PROJECT_NAME} PRIVATE nowide::nowide)

if(NOT MINIUPNP_FOUND)
if(NINTENDO_SWITCH)
if(NINTENDO_SWITCH OR VITA)
target_compile_definitions(${PROJECT_NAME} PRIVATE FEAT_NO_MINIUPNPC)
else()
option(UPNPC_BUILD_SHARED "Build shared library" OFF)
Expand Down Expand Up @@ -776,11 +823,37 @@ if(USE_LIBCDIO)
endif()
endif()

if(VITA)
target_link_libraries(${PROJECT_NAME} PRIVATE
-Wl,--whole-archive pthread -Wl,--no-whole-archive
stdc++
SDL2
kubridge_stub
ScePgf_stub
SceHid_stub
SceAppMgr_stub
SceAppUtil_stub
SceAudio_stub
SceAudioIn_stub
SceDisplay_stub
SceKernelDmacMgr_stub
SceIme_stub
ScePower_stub
SceSysmodule_stub
SceTouch_stub
SceMotion_stub
SceCommonDialog_stub
SceCtrl_stub
SceGxm_stub
SceVshBridge_stub
)
endif()

if(WIN32)
target_include_directories(${PROJECT_NAME} PRIVATE core/deps/dirent)
endif()

if(NOT LIBRETRO AND NOT NINTENDO_SWITCH)
if(NOT LIBRETRO AND NOT NINTENDO_SWITCH AND NOT VITA)
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_ICE)
# libjuice
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
Expand Down Expand Up @@ -990,6 +1063,12 @@ if(WIN32)
core/windows/fault_handler.cpp
core/windows/unwind_info.cpp
core/windows/win_vmem.cpp)
elseif(VITA)
target_sources(${PROJECT_NAME} PRIVATE
core/linux/common.cpp
core/linux/unwind_info.cpp
core/linux/vita_fault_handler.cpp
core/linux/vita_vmem.cpp)
else()
target_sources(${PROJECT_NAME} PRIVATE
core/linux/common.cpp
Expand Down Expand Up @@ -1550,7 +1629,7 @@ if(NOT LIBRETRO)
COMMAND ${CMAKE_COMMAND} -E copy "$ENV{VULKAN_SDK}/lib/libMoltenVK.dylib"
$<TARGET_FILE_DIR:flycast>/../Frameworks/libvulkan.dylib)
endif()
elseif(UNIX)
elseif(UNIX OR VITA)
if(NOT BUILD_TESTING)
target_sources(${PROJECT_NAME} PRIVATE
core/linux-dist/main.cpp)
Expand Down Expand Up @@ -1624,6 +1703,23 @@ if(NINTENDO_SWITCH)
endif()
endif()

if(VITA)
if(LIBRETRO)
# TODO?
else()
vita_create_self(eboot.bin ${PROJECT_NAME} UNSAFE STRIPPED NOASLR)
vita_create_vpk(${VITA_VPKNAME}.vpk ${VITA_TITLEID} eboot.bin
VERSION ${VITA_VERSION}
NAME ${VITA_APP_NAME}
FILE ${CMAKE_SOURCE_DIR}/shell/vita/icon0.png sce_sys/icon0.png
${CMAKE_SOURCE_DIR}/shell/vita/startup.png sce_sys/livearea/contents/startup.png
${CMAKE_SOURCE_DIR}/shell/vita/bg.png sce_sys/livearea/contents/bg.png
${CMAKE_SOURCE_DIR}/shell/vita/template.xml sce_sys/livearea/contents/template.xml
${VPK_INCLUDES}
)
endif()
endif()

if(IOS)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>-${CMAKE_OSX_SYSROOT}/Flycast.ipa" TYPE BIN)
elseif(NINTENDO_SWITCH AND NOT LIBRETRO)
Expand Down
2 changes: 1 addition & 1 deletion core/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
#endif

#if !defined(__ANDROID__) && !defined(TARGET_IPHONE) && !defined(TARGET_UWP) \
&& !defined(__SWITCH__) && !defined(LIBRETRO) && !defined(__NetBSD__) && !defined(__OpenBSD__)
&& !defined(__SWITCH__) && !defined(LIBRETRO) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__vita__)
#define NAOMI_MULTIBOARD
#endif

Expand Down
12 changes: 12 additions & 0 deletions core/cfg/option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ namespace config {

Option<bool> DynarecEnabled("Dynarec.Enabled", true);
Option<int> Sh4Clock("Sh4Clock", 200);
#ifdef __vita__
Option<int> DynarecSmcChecks("Dynarec.smcChecks", 0);
#endif

// General

Expand All @@ -38,8 +41,13 @@ Option<bool> AutoLoadState("Dreamcast.AutoLoadState");
Option<bool> AutoSaveState("Dreamcast.AutoSaveState");
Option<int, false> SavestateSlot("Dreamcast.SavestateSlot");
Option<bool> ForceFreePlay("ForceFreePlay", true);
#ifdef __vita__
Option<bool, false> FetchBoxart("FetchBoxart", false);
Option<bool, false> BoxartDisplayMode("BoxartDisplayMode", false);
#else
Option<bool, false> FetchBoxart("FetchBoxart", true);
Option<bool, false> BoxartDisplayMode("BoxartDisplayMode", true);
#endif
Option<int, false> UIScaling("UIScaling", 100);
Option<int, false> UITheme("UITheme", 0);

Expand Down Expand Up @@ -85,6 +93,10 @@ Option<bool> Fog("rend.Fog", true);
Option<bool> FloatVMUs("rend.FloatVMUs");
Option<bool> Rotate90("rend.Rotate90");
Option<bool> PerStripSorting("rend.PerStripSorting");
#ifdef __vita__
Option<bool> UseSimpleShaders("rend.UseSimpleShaders", true);
Option<bool> FastSorting("rend.FastSorting", true);
#endif
#ifdef __APPLE__
Option<bool> DelayFrameSwapping("rend.DelayFrameSwapping", false);
#else
Expand Down
5 changes: 5 additions & 0 deletions core/cfg/option.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,11 @@ extern Option<bool> DynarecEnabled;
#ifndef LIBRETRO
extern Option<int> Sh4Clock;
#endif
#ifdef __vita__
extern Option<int> DynarecSmcChecks;
extern Option<bool> FastSorting;
extern Option<bool> UseSimpleShaders;
#endif

// General

Expand Down
2 changes: 1 addition & 1 deletion core/deps/ggpo/lib/ggpo/ggpo_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class GGPOException : public std::runtime_error {
*/
#if defined(_WIN32)
# include "platform_windows.h"
#elif defined(__unix__) || defined(__APPLE__) || defined(__SWITCH__) || defined(__HAIKU__)
#elif defined(__unix__) || defined(__APPLE__) || defined(__SWITCH__) || defined(__HAIKU__) || defined(__vita__)
# include "platform_linux.h"
#else
# error Unsupported platform
Expand Down
2 changes: 1 addition & 1 deletion core/deps/ggpo/lib/ggpo/platform_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Use of this software is governed by the MIT license that can be found
* in the LICENSE file.
*/
#if defined(__unix__) || defined(__APPLE__) || defined(__SWITCH__) || defined(__HAIKU__)
#if defined(__unix__) || defined(__APPLE__) || defined(__SWITCH__) || defined(__HAIKU__) || defined(__vita__)

#include "platform_linux.h"
#include <time.h>
Expand Down
2 changes: 1 addition & 1 deletion core/deps/ggpo/lib/ggpo/platform_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <netinet/in.h>
#ifdef __SWITCH__
#include "nswitch.h"
#else
#elif !defined(__vita__)
#include <netinet/ip.h>
#endif
#include <netinet/tcp.h>
Expand Down
Loading
Loading