From 1ad9e8845b9be0135d2154597af11da56287c3b2 Mon Sep 17 00:00:00 2001 From: momatrix Date: Mon, 17 Jul 2023 08:36:15 +0100 Subject: [PATCH] Added c64 core (vice-libretro) and Fronted menu item to manually connect RetroPad to input port --- cores/makefile | 6 +++- cores/patches/vice-c64.patch | 32 +++++++++++++++++ makefile | 1 + skeleton/EXTRAS/Bios/C64/.keep | 0 .../EXTRAS/Emus/rg35xx/C64.pak/default.cfg | 25 +++++++++++++ skeleton/EXTRAS/Emus/rg35xx/C64.pak/launch.sh | 14 ++++++++ skeleton/EXTRAS/README.txt | 2 ++ skeleton/EXTRAS/Roms/Commodore 64 (C64)/.keep | 0 skeleton/EXTRAS/Saves/C64/.keep | 0 src/minarch/minarch.c | 35 +++++++++++++++---- 10 files changed, 107 insertions(+), 8 deletions(-) create mode 100644 cores/patches/vice-c64.patch create mode 100644 skeleton/EXTRAS/Bios/C64/.keep create mode 100644 skeleton/EXTRAS/Emus/rg35xx/C64.pak/default.cfg create mode 100755 skeleton/EXTRAS/Emus/rg35xx/C64.pak/launch.sh create mode 100644 skeleton/EXTRAS/Roms/Commodore 64 (C64)/.keep create mode 100644 skeleton/EXTRAS/Saves/C64/.keep diff --git a/cores/makefile b/cores/makefile index 22cce55..e5e13f9 100644 --- a/cores/makefile +++ b/cores/makefile @@ -1,7 +1,7 @@ # this logic was broken out from picoarch's all-in-one makefile CORES = fceumm gambatte gpsp pcsx_rearmed picodrive snes9x2005_plus -CORES+= beetle-pce-fast beetle-vb mednafen_supafaust mgba pokemini mame2003-plus # extras +CORES+= beetle-pce-fast beetle-vb mednafen_supafaust mgba pokemini mame2003-plus vice-c64 # extras ############################### @@ -39,6 +39,10 @@ snes9x2005_plus_FLAGS = USE_BLARGG_APU=1 mame2003-plus_REPO = https://github.com/libretro/mame2003-plus-libretro mame2003-plus_CORE = mame2003_plus_libretro.so +vice-c64_REPO = https://github.com/libretro/vice-libretro +vice-c64_FLAGS= EMUTYPE=x64 +vice-c64_CORE = vice_x64_libretro.so + ############################### PATCH = git apply diff --git a/cores/patches/vice-c64.patch b/cores/patches/vice-c64.patch new file mode 100644 index 0000000..f01d7a9 --- /dev/null +++ b/cores/patches/vice-c64.patch @@ -0,0 +1,32 @@ +diff --git a/Makefile b/Makefile +index 5f5fd96..949ddbc 100644 +--- a/Makefile ++++ b/Makefile +@@ -101,6 +101,27 @@ else ifeq ($(platform), classic_armv7_a7) + endif + endif + ++# RG35XX ++else ifeq ($(platform), rg35xx) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ fpic := -fPIC ++ LDFLAGS += $(fpic) -shared -Wl,--version-script=$(CORE_DIR)/libretro/link.T -Wl,-no-undefined ++ CFLAGS += -Ofast \ ++ -flto=4 -fwhole-program -fuse-linker-plugin \ ++ -fdata-sections -ffunction-sections -Wl,--gc-sections \ ++ -fno-stack-protector -fno-ident -fomit-frame-pointer \ ++ -falign-functions=1 -falign-jumps=1 -falign-loops=1 \ ++ -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \ ++ -fmerge-all-constants -fno-math-errno \ ++ -marm -mtune=cortex-a9 -mfpu=neon-fp16 -mfloat-abi=hard ++ CXXFLAGS += $(CFLAGS) ++ CPPFLAGS += $(CFLAGS) ++ ASFLAGS += $(CFLAGS) ++ HAVE_NEON = 1 ++ + # (armv8 a35, hard point, neon based) ### + # PS Classic + else ifeq ($(platform), classic_armv8_a35) diff --git a/makefile b/makefile index 4ef7370..d73f754 100644 --- a/makefile +++ b/makefile @@ -91,6 +91,7 @@ bundle: cp ./cores/output/mednafen_supafaust_libretro.so ./build/EXTRAS/Emus/rg35xx/SUPA.pak cp ./cores/output/mednafen_vb_libretro.so ./build/EXTRAS/Emus/rg35xx/VB.pak cp ./cores/output/pokemini_libretro.so ./build/EXTRAS/Emus/rg35xx/PKM.pak + cp ./cores/output/vice_x64_libretro.so ./build/EXTRAS/Emus/rg35xx/C64.pak cp ./other/DinguxCommander/output/DinguxCommander ./build/EXTRAS/Tools/rg35xx/Files.pak cp -R ./other/DinguxCommander/res ./build/EXTRAS/Tools/rg35xx/Files.pak/ diff --git a/skeleton/EXTRAS/Bios/C64/.keep b/skeleton/EXTRAS/Bios/C64/.keep new file mode 100644 index 0000000..e69de29 diff --git a/skeleton/EXTRAS/Emus/rg35xx/C64.pak/default.cfg b/skeleton/EXTRAS/Emus/rg35xx/C64.pak/default.cfg new file mode 100644 index 0000000..044ec01 --- /dev/null +++ b/skeleton/EXTRAS/Emus/rg35xx/C64.pak/default.cfg @@ -0,0 +1,25 @@ +minarch_screen_scaling = Fullscreen +minarch_cpu_speed = Powersave +minarch_connect_port = On + +vice_jiffydos = "enabled" +vice_warp_boost = "enabled" +vice_statusbar_messages = "enabled" +vice_resid_sampling = "fast" + +bind Up = UP +bind Down = DOWN +bind Left = LEFT +bind Right = RIGHT +bind Select = SELECT +bind Start = START +bind X = X +bind Y = Y +bind B / Fire = B +bind A = A +bind L = L1 +bind L2 = L2 +bind L3 = NONE +bind R = R1 +bind R2 = R2 +bind R3 = NONE diff --git a/skeleton/EXTRAS/Emus/rg35xx/C64.pak/launch.sh b/skeleton/EXTRAS/Emus/rg35xx/C64.pak/launch.sh new file mode 100755 index 0000000..31cf4fe --- /dev/null +++ b/skeleton/EXTRAS/Emus/rg35xx/C64.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=vice_x64 +CORES_PATH=$(dirname "$0") + +############################### + +EMU_TAG=$(basename "$(dirname "$0")" .pak) +ROM="$1" +mkdir -p "$BIOS_PATH/$EMU_TAG" +mkdir -p "$SAVES_PATH/$EMU_TAG" +HOME="$USERDATA_PATH" +cd "$HOME" +minarch.elf "$CORES_PATH/${EMU_EXE}_libretro.so" "$ROM" &> "$LOGS_PATH/$EMU_TAG.txt" diff --git a/skeleton/EXTRAS/README.txt b/skeleton/EXTRAS/README.txt index cb3715e..044292b 100644 --- a/skeleton/EXTRAS/README.txt +++ b/skeleton/EXTRAS/README.txt @@ -28,7 +28,9 @@ Bios files You'll need to BYOB for the emulator paks included in this zip file. + C64: vice/JiffyDOS_C64.bin and vice/JiffyDOS_1541-II.bin (reccomanded but not needed) MGBA: gba_bios.bin PCE: syscard3.pce PKM: bios.min SGB: sgb.bios + \ No newline at end of file diff --git a/skeleton/EXTRAS/Roms/Commodore 64 (C64)/.keep b/skeleton/EXTRAS/Roms/Commodore 64 (C64)/.keep new file mode 100644 index 0000000..e69de29 diff --git a/skeleton/EXTRAS/Saves/C64/.keep b/skeleton/EXTRAS/Saves/C64/.keep new file mode 100644 index 0000000..e69de29 diff --git a/src/minarch/minarch.c b/src/minarch/minarch.c index 6f98a98..c094e9d 100644 --- a/src/minarch/minarch.c +++ b/src/minarch/minarch.c @@ -42,6 +42,7 @@ static int show_debug = 0; static int max_ff_speed = 3; // 4x static int fast_forward = 0; static int overclock = 1; // normal +static int connect_port = 0; //// See retro_set_controller_port_device in libretro.h, most cores will do this automatically. static struct Renderer { int src_w; @@ -579,6 +580,7 @@ enum { FE_OPT_OVERCLOCK, FE_OPT_DEBUG, FE_OPT_MAXFF, + FE_OPT_CONNECTPORT, FE_OPT_COUNT, }; @@ -811,6 +813,16 @@ static struct Config { .values = max_ff_labels, .labels = max_ff_labels, }, + [FE_OPT_CONNECTPORT] = { + .key = "minarch_connect_port", + .name = "Connect RetroPad Device", + .desc = "Connect RetroPad device to input port.\nEnable this, if a core cannot automatically detect\nthe appropriate input device type on its own.", + .default_value = 0, + .value = 0, + .count = 2, + .values = onoff_labels, + .labels = onoff_labels, + }, [FE_OPT_COUNT] = {NULL} } }, @@ -862,13 +874,14 @@ static void setOverclock(int i) { } static void Config_syncFrontend(int i, int value) { switch (i) { - case FE_OPT_SCALING: screen_scaling = value; renderer.src_w = 0; break; - case FE_OPT_SCANLINES: show_scanlines = value; renderer.src_w = 0; break; - case FE_OPT_TEXT: optimize_text = value; renderer.src_w = 0; break; - case FE_OPT_TEARING: prevent_tearing = value; break; - case FE_OPT_OVERCLOCK: overclock = value; break; - case FE_OPT_DEBUG: show_debug = value; break; - case FE_OPT_MAXFF: max_ff_speed = value; break; + case FE_OPT_SCALING: screen_scaling = value; renderer.src_w = 0; break; + case FE_OPT_SCANLINES: show_scanlines = value; renderer.src_w = 0; break; + case FE_OPT_TEXT: optimize_text = value; renderer.src_w = 0; break; + case FE_OPT_TEARING: prevent_tearing = value; break; + case FE_OPT_OVERCLOCK: overclock = value; break; + case FE_OPT_DEBUG: show_debug = value; break; + case FE_OPT_MAXFF: max_ff_speed = value; break; + case FE_OPT_CONNECTPORT: connect_port = value; break; } Option* option = &config.frontend.options[i]; option->value = value; @@ -2901,6 +2914,14 @@ void Core_init(void) { } void Core_load(void) { LOG_info("Core_load\n"); + + // See retro_set_controller_port_device in libretro.h + // "It is only a hint to the libretro core when a core cannot automatically detect + // the appropriate input device type on its own." + // This seems to be the case for vice-libretro, but could be true of other cores. + // The new option in the Frontend menu, makes it possible to enabled this if necessary + if (connect_port) core.set_controller_port_device(0,RETRO_DEVICE_JOYPAD); + struct retro_game_info game_info; game_info.path = game.tmp_path[0]?game.tmp_path:game.path; game_info.data = game.data;