diff --git a/packages/games/emulators/flycastsa/package.mk b/packages/games/emulators/flycastsa/package.mk new file mode 100644 index 000000000..f9d48aa9c --- /dev/null +++ b/packages/games/emulators/flycastsa/package.mk @@ -0,0 +1,30 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2021-present Shanti Gilbert (https://github.com/shantigilbert) + +PKG_NAME="flycastsa" +PKG_VERSION="fd50529d864c0af7007f2f283a84bf67851fe0e4" +PKG_LICENSE="GPLv2" +PKG_SITE="https://github.com/flyinghead/flycast" +PKG_URL="$PKG_SITE.git" +PKG_DEPENDS_TARGET="toolchain $OPENGLES alsa SDL2 libzip zip" +PKG_LONGDESC="Flycast is a multiplatform Sega Dreamcast, Naomi and Atomiswave emulator" +PKG_TOOLCHAIN="cmake" +PKG_GIT_CLONE_BRANCH="master" + + +if [ "${ARCH}" == "arm" ]; then + PKG_PATCH_DIRS="arm" +fi +pre_configure_target() { +export CXXFLAGS="${CXXFLAGS} -Wno-error=array-bounds" +PKG_CMAKE_OPTS_TARGET+="-DUSE_GLES=ON -DUSE_VULKAN=OFF" +} + +makeinstall_target() { + mkdir -p $INSTALL/usr/bin + cp $PKG_BUILD/.${TARGET_NAME}/flycast $INSTALL/usr/bin/flycast + cp $PKG_DIR/scripts/* $INSTALL/usr/bin + + chmod +x $INSTALL/usr/bin/start_flycastsa.sh + chmod +x $INSTALL/usr/bin/set_flycast_joy.sh +} diff --git a/packages/games/emulators/flycastsa/patches/01-fix-zip-error.patch b/packages/games/emulators/flycastsa/patches/01-fix-zip-error.patch new file mode 100644 index 000000000..3ca113697 --- /dev/null +++ b/packages/games/emulators/flycastsa/patches/01-fix-zip-error.patch @@ -0,0 +1,27 @@ +diff --git a/core/archive/ZipArchive.cpp b/core/archive/ZipArchive.cpp +index 394f919a..58cd295e 100644 +--- a/core/archive/ZipArchive.cpp ++++ b/core/archive/ZipArchive.cpp +@@ -27,20 +27,8 @@ ZipArchive::~ZipArchive() + + bool ZipArchive::Open(const char* path) + { +- FILE *file = nowide::fopen(path, "rb"); +- if (file == nullptr) +- return false; +- zip_error_t error; +- zip_source_t *source = zip_source_filep_create(file, 0, -1, &error); +- if (source == nullptr) +- { +- std::fclose(file); +- return false; +- } +- zip = zip_open_from_source(source, 0, NULL); +- if (zip == nullptr) +- zip_source_free(source); +- return zip != nullptr; ++ zip = zip_open(path, 0, NULL); ++ return (zip != NULL); + } + + ArchiveFile* ZipArchive::OpenFile(const char* name) diff --git a/packages/games/emulators/flycastsa/patches/03-fix-sdl-controller.patch b/packages/games/emulators/flycastsa/patches/03-fix-sdl-controller.patch new file mode 100644 index 000000000..acdf902ef --- /dev/null +++ b/packages/games/emulators/flycastsa/patches/03-fix-sdl-controller.patch @@ -0,0 +1,16 @@ +diff --git a/core/sdl/sdl.cpp b/core/sdl/sdl.cpp +index 62467d08..cb167b4f 100644 +--- a/core/sdl/sdl.cpp ++++ b/core/sdl/sdl.cpp +@@ -160,6 +160,11 @@ void input_sdl_init() + #endif + std::string db = get_readonly_data_path("gamecontrollerdb.txt"); + int rv = SDL_GameControllerAddMappingsFromFile(db.c_str()); ++ if (rv < 0 && (nowide::getenv("SDL_GAMECONTROLLERCONFIG_FILE") != NULL)) ++ { ++ db = (std::string) nowide::getenv("SDL_GAMECONTROLLERCONFIG_FILE"); ++ rv = SDL_GameControllerAddMappingsFromFile(db.c_str()); ++ } + if (rv < 0) + { + db = get_readonly_config_path("gamecontrollerdb.txt"); diff --git a/packages/games/emulators/flycastsa/patches/RG351MP b/packages/games/emulators/flycastsa/patches/RG351MP new file mode 120000 index 000000000..0067f8043 --- /dev/null +++ b/packages/games/emulators/flycastsa/patches/RG351MP @@ -0,0 +1 @@ +RG351P \ No newline at end of file diff --git a/packages/games/emulators/flycastsa/patches/RG351P/01-platform.patch b/packages/games/emulators/flycastsa/patches/RG351P/01-platform.patch new file mode 100644 index 000000000..a8665d578 --- /dev/null +++ b/packages/games/emulators/flycastsa/patches/RG351P/01-platform.patch @@ -0,0 +1,34 @@ +diff -rupN flycast.orig/Makefile flycast/Makefile +--- flycast.orig/Makefile 2022-04-08 18:10:23.156125702 -0400 ++++ flycast/Makefile 2022-04-08 18:59:10.972092728 -0400 +@@ -610,6 +610,30 @@ else ifneq (,$(findstring RK,$(platform) + WITH_DYNAREC=arm + HAVE_GENERIC_JIT = 0 + ++else ifeq ($(platform), RG351x) ++ EXT ?= so ++ TARGET := $(TARGET_NAME)_libretro.$(EXT) ++ SHARED += -shared -Wl,--version-script=link.T ++ fpic = -fPIC ++ LIBS += -lrt ++ ARM_FLOAT_ABI_HARD = 0 ++ FORCE_GLES = 1 ++ SINGLE_PREC_FLAGS = 1 ++ HAVE_LTCG = 0 ++ HAVE_OPENMP = 0 ++ CFLAGS += -Ofast \ ++ -fuse-linker-plugin \ ++ -fno-stack-protector -fno-ident -fomit-frame-pointer \ ++ -fmerge-all-constants -ffast-math -funroll-all-loops \ ++ -mcpu=cortex-a35 -mtune=cortex-a35 ++ CXXFLAGS += $(CFLAGS) ++ LDFLAGS += -mcpu=cortex-a35 -mtune=cortex-a35 -Ofast -flto -fuse-linker-plugin ++ PLATFORM_EXT := unix ++ CORE_DEFINES += -DLOW_END -DLOW_RES ++ WITH_DYNAREC=arm64 ++ PLATFORM_EXT := unix ++ HAVE_GENERIC_JIT = 0 ++ + # RockPro64 + else ifeq ($(platform), rockpro64) + EXT ?= so diff --git a/packages/games/emulators/flycastsa/patches/RG351V b/packages/games/emulators/flycastsa/patches/RG351V new file mode 120000 index 000000000..0067f8043 --- /dev/null +++ b/packages/games/emulators/flycastsa/patches/RG351V @@ -0,0 +1 @@ +RG351P \ No newline at end of file diff --git a/packages/games/emulators/flycastsa/patches/RG552/01-platform.patch b/packages/games/emulators/flycastsa/patches/RG552/01-platform.patch new file mode 100644 index 000000000..c73a29ae3 --- /dev/null +++ b/packages/games/emulators/flycastsa/patches/RG552/01-platform.patch @@ -0,0 +1,28 @@ +diff -rupN flycast.orig/Makefile flycast/Makefile +--- flycast.orig/Makefile 2022-04-08 18:10:23.156125702 -0400 ++++ flycast/Makefile 2022-04-08 18:48:44.236265589 -0400 +@@ -610,6 +610,24 @@ else ifneq (,$(findstring RK,$(platform) + WITH_DYNAREC=arm + HAVE_GENERIC_JIT = 0 + ++else ifeq ($(platform), RG552) ++ EXT ?= so ++ TARGET := $(TARGET_NAME)_libretro.$(EXT) ++ SHARED += -shared -Wl,--version-script=link.T ++ fpic = -fPIC ++ LIBS += -lrt ++ ARM_FLOAT_ABI_HARD = 0 ++ FORCE_GLES = 1 ++ SINGLE_PREC_FLAGS = 1 ++ FORCE_GLES = 1 ++ CPUFLAGS += -DTARGET_LINUX_ARMv8 -frename-registers ++ CFLAGS += -march=armv8-a+crc -mcpu=cortex-a72 -mtune=cortex-a72 $(CPUFLAGS) ++ CXXFLAGS += -march=armv8-a+crc -mcpu=cortex-a72 -mtune=cortex-a72 $(CPUFLAGS) ++ ASFLAGS += -march=armv8-a+crc -mcpu=cortex-a72 -c ++ WITH_DYNAREC=arm64 ++ PLATFORM_EXT := unix ++ HAVE_GENERIC_JIT = 0 ++ + # RockPro64 + else ifeq ($(platform), rockpro64) + EXT ?= so diff --git a/packages/games/emulators/flycastsa/scripts/set_flycast_joy.sh b/packages/games/emulators/flycastsa/scripts/set_flycast_joy.sh new file mode 100644 index 000000000..f3dd23193 --- /dev/null +++ b/packages/games/emulators/flycastsa/scripts/set_flycast_joy.sh @@ -0,0 +1,232 @@ +#!/bin/bash + +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2020-present Shanti Gilbert (https://github.com/shantigilbert) + +# Source predefined functions and variables +. /etc/profile + +# Configure ADVMAME players based on ES settings +CONFIG_DIR="/storage/.config/flycast" +EMU_FILE="${CONFIG_DIR}/emu.cfg" +MAPPING_DIR="${CONFIG_DIR}/mappings" + + +source /usr/bin/joy_common.sh "flycast" + +CONFIG_TMP_A="/tmp/jc/SDLflycastA.tmp" +CONFIG_TMP_D="/tmp/jc/SDLflycastD.tmp" +CONFIG_TMP_E="/tmp/jc/SDLflycastE.tmp" + + +BTN_H0=$(get_ee_setting flycast_btn_h0) +[[ -z "$BTN_H0" ]] && BTN_H0=255 + +declare -A FLYCAST_D_INDEXES=( + [h0.1]=$(( BTN_H0+1 )) + [h0.4]=$(( BTN_H0+2 )) + [h0.8]=$(( BTN_H0+3 )) + [h0.2]=$(( BTN_H0+4 )) +) + +# Only needed for version 3. +#declare -A FLYCAST_D_BIND=( +# [a]=1 +# [b]=0 +# [x]=3 +# [y]=2 +# [leftshoulder]=4 +# [rightshoulder]=5 +# [lefttrigger]=6 +# [righttrigger]=7 +# [back]=8 +# [start]=9 +# [guide]=10 +# [dpup]=11 +# [dpdown]=12 +# [dpleft]=13 +# [dpright]=14 +#) + +# Regular buttons a,b,x,y flipped. +declare -A FLYCAST_D_BUTTONS=( + [x]="btn_y" + [y]="btn_x" + [a]="btn_b" + [b]="btn_a" + [leftshoulder]="btn_c" + [rightshoulder]="btn_d" + [lefttrigger]="btn_trigger_left" + [righttrigger]="btn_trigger_right" + [back]="btn_menu" + [start]="btn_start" + [guide]="btn_escape" + [dpup]="btn_dpad1_up" + [dpdown]="btn_dpad1_down" + [dpleft]="btn_dpad1_left" + [dpright]="btn_dpad1_right" + [leftx,0]="axis_x" + [leftx,1]="axis_dpad1_x" + [lefty,0]="axis_y" + [lefty,1]="axis_dpad1_y" + [rightx]="axis_right_x" + [righty]="axis_right_y" +) + +BTN_SWAP_XY=$(get_ee_setting flycast_joy_swap_xy) +if [[ "$BTN_SWAP_XY" == "1" ]]; then + FLYCAST_D_BUTTONS[x]="btn_x" + FLYCAST_D_BUTTONS[y]="btn_y" +fi + +BTN_SWAP_AB=$(get_ee_setting flycast_joy_swap_ab) +if [[ "$BTN_SWAP_AB" == "1" ]]; then + FLYCAST_D_BUTTONS[a]="btn_a" + FLYCAST_D_BUTTONS[b]="btn_b" +fi + + +# Cleans all the inputs for the gamepad with name $GAMEPAD and player $1 +clean_pad() { + #echo "Cleaning pad $1 $2" #debug + [[ -f "${CONFIG_TMP_A}" ]] && rm "${CONFIG_TMP_A}" + [[ -f "${CONFIG_TMP_D}" ]] && rm "${CONFIG_TMP_D}" + [[ -f "${CONFIG_TMP_E}" ]] && rm "${CONFIG_TMP_E}" +} + +# Sets pad depending on parameters. +# $1 = Player Number +# $2 = js[0-7] +# $3 = Device GUID +# $4 = Device Name + +set_pad() { + local DEVICE_GUID=$3 + local JOY_NAME="$4" + + # Insert the correct configs into emu.cfg to enable sdl to work. + declare -i LN=$( cat "$EMU_FILE" | grep -n "\[input\]" | cut -d: -f1 | head -1 ) + + declare -i index=$(( $1 - 1 )) + sed -i "/device${1}/d" "$EMU_FILE" + sed -i "/maple_sdl_joystick_${index}/d" "$EMU_FILE" + + local DEVICE="maple_sdl_joystick_${index} = ${index}\ndevice${1} = 0\ndevice${1}.1 = 1\ndevice${1}.2 = 1\n" + [[ "$LN" -gt "0" ]] && LN=$(( LN+1 )) && sed -i "${LN} i ${DEVICE}" "$EMU_FILE" + + + local CONFIG="${MAPPING_DIR}/SDL_${JOY_NAME}.cfg" + [[ -f "${CONFIG}" ]] && return + + #echo "DEVICE_GUID=${DEVICE_GUID}" + + touch "${CONFIG_TMP_A}" + touch "${CONFIG_TMP_D}" + touch "${CONFIG_TMP_E}" + + echo "axis_right_x_inverted = no" >> ${CONFIG_TMP_A} + echo "axis_right_y_inverted = no" >> ${CONFIG_TMP_A} + echo "axis_x_inverted = no" >> ${CONFIG_TMP_A} + echo "axis_y_inverted = no" >> ${CONFIG_TMP_A} + + local GC_RECORD + [[ -f "${CONFIG}" ]] && GC_RECORD=$(cat "${CONFIG}" | grep -E "^dead_zone \= [0-9]*$") + [[ -z "$GC_RECORD" ]] && GC_RECORD="dead_zone = 10" + echo "$GC_RECORD" >> ${CONFIG_TMP_E} + + [[ -f "${CONFIG}" ]] && rm "${CONFIG}" + + echo "mapping_name = $JOY_NAME" >> ${CONFIG_TMP_E} + echo "version = 2" >> ${CONFIG_TMP_E} + + local GC_CONFIG=$(cat "$GCDB" | grep "$DEVICE_GUID" | grep "platform:Linux" | head -1) + echo "GC_CONFIG=$GC_CONFIG" + [[ -z $GC_CONFIG ]] && return + + local GC_MAP=$(echo $GC_CONFIG | cut -d',' -f3-) + + set -f + local GC_ARRAY=(${GC_MAP//,/ }) + + for index in "${!GC_ARRAY[@]}"; do + local REC=${GC_ARRAY[$index]} + local BUTTON_INDEX=$(echo $REC | cut -d ":" -f 1) + local TVAL=$(echo $REC | cut -d ":" -f 2) + local BTN_TYPE="${TVAL:1}" + local FC_INDEX_D=${FLYCAST_D_BUTTONS[$BUTTON_INDEX]} + local ABORT_ENTRY=0 + local BTN_TYPE=${TVAL:0:1} + local NUM=${TVAL:1} + + if [[ $BUTTON_INDEX == "leftx" || $BUTTON_INDEX == "lefty" ]]; then + FC_INDEX_D=${FLYCAST_D_BUTTONS[$BUTTON_INDEX,0]} + echo "${FC_INDEX_D} = $NUM" >> ${CONFIG_TMP_D} + FC_INDEX_D=${FLYCAST_D_BUTTONS[$BUTTON_INDEX,1]} + echo "${FC_INDEX_D} = $NUM" >> ${CONFIG_TMP_A} + continue + fi + if [[ ! -z "$FC_INDEX_D" ]]; then + [[ $BUTTON_INDEX == "lefttrigger" ]] && ABORT_ENTRY=1 + [[ $BUTTON_INDEX == "righttrigger" ]] && ABORT_ENTRY=1 + [[ $BUTTON_INDEX == "back" ]] && ABORT_ENTRY=1 && echo "${FC_INDEX_D} = $NUM" >> ${CONFIG_TMP_E} + [[ $BUTTON_INDEX == "guide" ]] && ABORT_ENTRY=1 && echo "${FC_INDEX_D} = $NUM" >> ${CONFIG_TMP_E} + + if [[ $ABORT_ENTRY == 0 ]]; then + [[ $BTN_TYPE == "a" ]] && echo "${FC_INDEX_D} = $NUM" >> ${CONFIG_TMP_D} + [[ $BTN_TYPE == "b" ]] && echo "${FC_INDEX_D} = $NUM" >> ${CONFIG_TMP_D} + [[ $BTN_TYPE == "h" ]] && NUM=${FLYCAST_D_INDEXES[$TVAL]} && echo "${FC_INDEX_D} = ${NUM}" >> ${CONFIG_TMP_D} + fi + fi + + local FC_INDEX_A=${FLYCAST_D_BUTTONS[$BUTTON_INDEX]} + if [[ ! -z "$FC_INDEX_A" ]]; then + case $BUTTON_INDEX in + "lefttrigger") + echo "${FC_INDEX_A} = $NUM" >> ${CONFIG_TMP_A} + ;; + "righttrigger") + echo "${FC_INDEX_A} = $NUM" >> ${CONFIG_TMP_A} + ;; + esac + fi + done + + echo "[compat]" >> "${CONFIG}" + cat "${CONFIG_TMP_A}" | sort >> "${CONFIG}" + + echo -e "\n[dreamcast]" >> "${CONFIG}" + cat "${CONFIG_TMP_D}" | sort >> "${CONFIG}" + + echo -e "\n[emulator]" >> "${CONFIG}" + cat "${CONFIG_TMP_E}" | sort >> "${CONFIG}" + + rm "${CONFIG_TMP_A}" + rm "${CONFIG_TMP_D}" + rm "${CONFIG_TMP_E}" + + local ARCADE_CFG="${CONFIG:0:-4}_arcade.cfg" + cp -f "${CONFIG}" "${ARCADE_CFG}" + + sed -i '/axis_dpad1_x =/d' "${CONFIG}" + sed -i '/axis_dpad1_y =/d' "${CONFIG}" + +} + +init_config() { + mkdir -p "/storage/.config/flycast/mappings" + + # Adjust the emulator config file to load sdl controller files. + local SDL_JOYSTICK="maple_sdl_joystick_0 = 0\nmaple_sdl_joystick_1 = 1\n" + local DEVICES="device1 = 0\ndevice1.1 = 1\ndevice1.2 = 1\ndevice2 = 0\ndevice2.1 = 1\ndevice2.2 = 1\n" + if [[ ! -f "$EMU_FILE" ]]; then + echo "[input]" >> "$EMU_FILE" + echo -e "$SDL_JOYSTICK" >> "$EMU_FILE" + echo -e "$DEVICES" >> "$EMU_FILE" + return + fi +} + + +init_config + +jc_get_players diff --git a/packages/games/emulators/flycastsa/scripts/start_flycastsa.sh b/packages/games/emulators/flycastsa/scripts/start_flycastsa.sh new file mode 100644 index 000000000..4aad8a3b3 --- /dev/null +++ b/packages/games/emulators/flycastsa/scripts/start_flycastsa.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2021-present Shanti Gilbert (https://github.com/shantigilbert) + +# Source predefined functions and variables +. /etc/profile + +mkdir -p "/storage/.local/share/" + +if [ ! -L "/storage/.local/share/flycast" ]; then + mkdir -p "/storage/roms/bios/dc" + rm -rf "/storage/.local/share/flycast" + ln -sf "/storage/roms/bios/dc" "/storage/.local/share/flycast" +fi + +AUTOGP=$(get_ee_setting flycast_auto_gamepad) +if [[ "${AUTOGP}" != "0" ]]; then + mkdir -p "/storage/.config/flycast/mappings" + /usr/bin/set_flycast_joy.sh +fi + +flycast "${1}" diff --git a/packages/jelos/package.mk b/packages/jelos/package.mk index e027b1a35..f1fe7721e 100644 --- a/packages/jelos/package.mk +++ b/packages/jelos/package.mk @@ -24,7 +24,7 @@ PKG_EMUS="common-shaders glsl-shaders libretro-database retroarch hatarisa openb scummvmsa PPSSPPSDL yabasanshiroSA vicesa mupen64plussa-audio-sdl \ mupen64plussa-input-sdl mupen64plussa-ui-console mupen64plussa-video-rice \ mupen64plussa-core mupen64plussa-rsp-hle mupen64plussa-video-glide64mk2 \ - lzdoom gzdoom ecwolf amiberry raze pico-8 drastic" + lzdoom gzdoom ecwolf amiberry raze pico-8 drastic flycastsa" LIBRETRO_CORES="2048 81 a5200 atari800 beetle-gba beetle-lynx beetle-ngp beetle-pce beetle-pcfx \ beetle-supafaust beetle-supergrafx beetle-vb beetle-wswan bluemsx cannonball cap32 \ diff --git a/packages/virtual/arm32/package.mk b/packages/virtual/arm32/package.mk index 523e9f382..1b6348722 100644 --- a/packages/virtual/arm32/package.mk +++ b/packages/virtual/arm32/package.mk @@ -4,6 +4,6 @@ PKG_NAME="arm32" PKG_LICENSE="GPL" PKG_SITE="www.jelos.org" -PKG_DEPENDS_TARGET="toolchain squashfs-tools:host dosfstools:host fakeroot:host kmod:host mtools:host populatefs:host libc gcc linux linux-drivers linux-firmware libusb unzip socat p7zip file ${OPENGLES} SDL2 SDL2_gfx SDL2_image SDL2_mixer SDL2_net SDL2_ttf libgo2 retroarch pcsx_rearmed parallel-n64_rice parallel-n64_gln64 parallel-n64_glide64 gpsp" +PKG_DEPENDS_TARGET="toolchain squashfs-tools:host dosfstools:host fakeroot:host kmod:host mtools:host populatefs:host libc gcc linux linux-drivers linux-firmware libusb unzip socat p7zip file ${OPENGLES} SDL2 SDL2_gfx SDL2_image SDL2_mixer SDL2_net SDL2_ttf libgo2 retroarch pcsx_rearmed parallel-n64_rice parallel-n64_gln64 parallel-n64_glide64 gpsp flycastsa" PKG_SECTION="virtual" PKG_LONGDESC="Root package used to build and create 32-bit userland"