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

on: [push, pull_request]

jobs:
build:
name: ${{ matrix.config.name }}
runs-on: ubuntu-latest
container: vitasdk/vitasdk:latest

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

steps:
- name: Set up build environment
run: |
apk add --no-cache aws-cli ccache git ninja
vdpm curl libzip openssl SceShaccCgExt sdl2 vitaGL vitaShaRK taihen zlib

- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true

- uses: actions/cache@v3
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 kubridge_all
cmake --build build --config Release --target Flycast.vpk-vpk

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

- name: Configure AWS Credentials
id: aws-credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: AKIAJOZQS4H2PHQWYFCA
aws-secret-access-key: ${{ secrets.S3_SECRET_KEY }}
aws-region: us-east-2
if: github.repository == 'flyinghead/flycast' && github.event_name == 'push' && matrix.config.destDir != ''

- name: Upload to S3
run: aws s3 sync artifact/bin s3://flycast-builds/${{ matrix.config.destDir }}/${GITHUB_REF#refs/}-$GITHUB_SHA --acl public-read --follow-symlinks
if: ${{ steps.aws-credentials.outputs.aws-account-id != '' }}
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@
[submodule "core/deps/Spout"]
path = core/deps/Spout
url = https://github.com/vkedwardli/Spout2.git
[submodule "core/deps/kubridge"]
path = core/deps/kubridge
url = https://github.com/bythos14/kubridge.git
114 changes: 106 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ if(APPLE)
endif()
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 Down Expand Up @@ -111,7 +121,34 @@ 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} -I${VITASDK}/arm-vita-eabi/include/SDL2 -Wl,-q,--wrap,memcpy,--wrap,memset,--wrap,malloc,--wrap,memalign,--wrap,free,--wrap,calloc,--wrap,realloc -O3 -DNDEBUG -fno-optimize-sibling-calls -fsigned-char -fno-short-enums -marm")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${VITASDK}/arm-vita-eabi/include/SDL2 -Wl,-q,--wrap,malloc,--wrap,memalign,--wrap,free,--wrap,calloc,--wrap,realloc -O3 -DNDEBUG -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)
target_compile_definitions(${PROJECT_NAME} PRIVATE EGL_NO_PLATFORM_SPECIFIC_TYPES)
endif()

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

Expand Down Expand Up @@ -200,9 +237,11 @@ if(WINDOWS_STORE)
set(USE_VULKAN OFF)
endif()

set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_EXTENSIONS OFF
LINK_FLAGS_RELEASE -s)
if(NOT VITA)
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_EXTENSIONS OFF
LINK_FLAGS_RELEASE -s)
endif()
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /GR /GS-)
if(WINDOWS_STORE)
Expand Down Expand Up @@ -400,6 +439,9 @@ if(NOT LIBRETRO)
if(USE_HOST_SDL)
find_package(SDL2)
endif()
if(VITA)
set(SDL2_FOUND 1)
endif()
if(NOT SDL2_FOUND)
add_subdirectory(core/deps/SDL EXCLUDE_FROM_ALL)
set(SDL2_FOUND 1)
Expand All @@ -411,7 +453,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 Down Expand Up @@ -510,6 +552,10 @@ if(NINTENDO_SWITCH AND USE_GLES)
target_link_libraries(${PROJECT_NAME} PRIVATE PkgConfig::GLESV2)
endif()

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

if(UNIX AND NOT APPLE AND NOT ANDROID)
add_definitions(
-DFLYCAST_DATADIR="${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}/"
Expand Down Expand Up @@ -594,11 +640,11 @@ target_sources(${PROJECT_NAME} PRIVATE
core/deps/chdpsr/cdipsr.h)

add_subdirectory(core/deps/nowide EXCLUDE_FROM_ALL)
target_compile_definitions(nowide PRIVATE $<$<BOOL:${NINTENDO_SWITCH}>:_DEFAULT_SOURCE>)
target_compile_definitions(nowide PRIVATE $<$<BOOL:${NINTENDO_SWITCH}>:_DEFAULT_SOURCE> $<$<BOOL:${VITA}>:_GNU_SOURCE>)
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 @@ -635,6 +681,35 @@ if(NOT LIBZIP_FOUND OR NINTENDO_SWITCH)
target_link_libraries(${PROJECT_NAME} PRIVATE zip)
endif()

if(VITA)
add_subdirectory(core/deps/kubridge)
add_dependencies(${PROJECT_NAME} kubridge_all)
target_include_directories(${PROJECT_NAME} PRIVATE core/deps/kubridge) # to override system kubridge.h if present
target_link_libraries(${PROJECT_NAME} PRIVATE
-Wl,--whole-archive pthread -Wl,--no-whole-archive
stdc++
SDL2
${CMAKE_CURRENT_BINARY_DIR}/core/deps/kubridge/stubs/libkubridge_stub.a
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()
Expand Down Expand Up @@ -1023,6 +1098,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 @@ -1702,7 +1783,7 @@ if(NOT LIBRETRO)
${CMAKE_CURRENT_BINARY_DIR}/Flycast.app/Contents/Frameworks/libvulkan.dylib)
endif()
endif()
elseif(UNIX OR NINTENDO_SWITCH)
elseif(UNIX OR NINTENDO_SWITCH OR VITA)
if(NOT BUILD_TESTING)
target_sources(${PROJECT_NAME} PRIVATE
core/linux-dist/main.cpp)
Expand Down Expand Up @@ -1787,6 +1868,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 @@ -105,7 +105,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

// Sound

Expand Down Expand Up @@ -81,6 +89,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 @@ -359,6 +359,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__)
#elif defined(__unix__) || defined(__APPLE__) || defined(__SWITCH__) || 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__)
#if defined(__unix__) || defined(__APPLE__) || defined(__SWITCH__) || 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