From d5cc9f7cef622fb9e4a28d450114fb317979b6db Mon Sep 17 00:00:00 2001 From: Shaun Inman Date: Mon, 13 Feb 2023 21:11:57 -0500 Subject: [PATCH] added supafaust core --- cores/makefile | 14 ++- cores/patches/mednafen_supafaust.patch | 31 +++++ skeleton/EXTRAS/Bios/P8/.keep | 0 .../EXTRAS/Emus/rg35xx/SUPA.pak/launch.sh | 14 +++ skeleton/EXTRAS/Roms/Pico-8 (P8)/.keep | 0 skeleton/EXTRAS/Saves/P8/.keep | 0 src/minarch/main.c | 116 ++++++++++++------ src/minarch/overrides/fake-08.h | 3 - src/minarch/overrides/mednafen_supafaust.h | 25 ++++ 9 files changed, 155 insertions(+), 48 deletions(-) create mode 100644 cores/patches/mednafen_supafaust.patch create mode 100644 skeleton/EXTRAS/Bios/P8/.keep create mode 100755 skeleton/EXTRAS/Emus/rg35xx/SUPA.pak/launch.sh create mode 100644 skeleton/EXTRAS/Roms/Pico-8 (P8)/.keep create mode 100644 skeleton/EXTRAS/Saves/P8/.keep create mode 100644 src/minarch/overrides/mednafen_supafaust.h diff --git a/cores/makefile b/cores/makefile index 9d6e207..d4ad7e1 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 pokemini snes9x2005_plus -CORES+= beetle-vb fake-08 +CORES = fceumm gambatte gpsp pcsx_rearmed picodrive snes9x2005_plus +CORES+= beetle-vb fake-08 mednafen_supafaust pokemini # extras ############################### @@ -16,10 +16,16 @@ CORES+= beetle-vb fake-08 beetle-vb_REPO = https://github.com/libretro/beetle-vb-libretro beetle-vb_CORE = mednafen_vb_libretro.so +fake-08_REPO = https://github.com/jtothebell/fake-08 +fake-08_CORE = fake08_libretro.so +fake-08_BUILD_PATH = fake-08/platform/libretro + fceumm_REPO = https://github.com/libretro/libretro-fceumm gambatte_REPO = https://github.com/libretro/gambatte-libretro +mednafen_supafaust_REPO = https://github.com/libretro/supafaust + pcsx_rearmed_MAKEFILE = Makefile.libretro picodrive_REPO = https://github.com/irixxxx/picodrive @@ -31,10 +37,6 @@ pokemini_MAKEFILE = Makefile.libretro snes9x2005_plus_REPO = https://github.com/libretro/snes9x2005 snes9x2005_plus_FLAGS = USE_BLARGG_APU=1 -fake-08_REPO = https://github.com/jtothebell/fake-08 -fake-08_CORE = fake08_libretro.so -fake-08_BUILD_PATH = fake-08/platform/libretro - ############################### PATCH = git apply diff --git a/cores/patches/mednafen_supafaust.patch b/cores/patches/mednafen_supafaust.patch new file mode 100644 index 0000000..331f62d --- /dev/null +++ b/cores/patches/mednafen_supafaust.patch @@ -0,0 +1,31 @@ +diff --git forkSrcPrefix/Makefile forkDstPrefix/Makefile +index 58120a1a88eab75ca13f2ed062f37d075c05a51b..c60ebf68483aebf7a0dc320e4589f29cf6457013 100644 +--- forkSrcPrefix/Makefile ++++ forkDstPrefix/Makefile +@@ -187,6 +187,26 @@ else ifeq ($(platform), wii) + + EXTRA_INCLUDES := -I$(DEVKITPRO)/libogc/include + STATIC_LINKING = 1 ++else ifeq ($(platform), rg35xx) ++ TARGET := $(TARGET_NAME)_libretro.so ++ CC = $(CROSS_COMPILE)gcc ++ CXX = $(CROSS_COMPILE)g++ ++ AR = $(CROSS_COMPILE)ar ++ fpic := -fPIC ++ SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T ++ 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 ++ CFLAGS += -marm -mtune=cortex-a9 -mfpu=neon-fp16 -mfloat-abi=hard -march=armv7-a -fomit-frame-pointer -DRG35XX ++ CXXFLAGS += $(CFLAGS) ++ CFLAGS += -fPIC ++ LDFLAGS += -flto ++ HAVE_NEON = 1 ++ ARCH = arm + else ifneq (,$(findstring rpi,$(platform))) + TARGET := $(TARGET_NAME)_libretro.so + fpic := -fPIC diff --git a/skeleton/EXTRAS/Bios/P8/.keep b/skeleton/EXTRAS/Bios/P8/.keep new file mode 100644 index 0000000..e69de29 diff --git a/skeleton/EXTRAS/Emus/rg35xx/SUPA.pak/launch.sh b/skeleton/EXTRAS/Emus/rg35xx/SUPA.pak/launch.sh new file mode 100755 index 0000000..a0f6d49 --- /dev/null +++ b/skeleton/EXTRAS/Emus/rg35xx/SUPA.pak/launch.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +EMU_EXE=mednafen_supafaust +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" DMG &> "$LOGS_PATH/$EMU_TAG.txt" diff --git a/skeleton/EXTRAS/Roms/Pico-8 (P8)/.keep b/skeleton/EXTRAS/Roms/Pico-8 (P8)/.keep new file mode 100644 index 0000000..e69de29 diff --git a/skeleton/EXTRAS/Saves/P8/.keep b/skeleton/EXTRAS/Saves/P8/.keep new file mode 100644 index 0000000..e69de29 diff --git a/src/minarch/main.c b/src/minarch/main.c index 424b18a..7791e5d 100644 --- a/src/minarch/main.c +++ b/src/minarch/main.c @@ -28,6 +28,7 @@ #include "overrides/gambatte.h" #include "overrides/gpsp.h" #include "overrides/mednafen_vb.h" +#include "overrides/mednafen_supafaust.h" #include "overrides/pcsx_rearmed.h" #include "overrides/picodrive.h" #include "overrides/pokemini.h" @@ -38,6 +39,7 @@ static CoreOverrides* overrides[] = { &fceumm_overrides, &gambatte_overrides, &gpsp_overrides, + &mednafen_supafaust_overrides, &mednafen_vb_overrides, &pcsx_rearmed_overrides, &picodrive_overrides, @@ -560,7 +562,7 @@ static struct Config { [FE_OPT_SCANLINES] = { .key = "minarch_scanlines_grid", .name = "Scanlines/Grid", - .desc = "Simulate scanlines (or a pixel grid at odd scales).\nDarkens the overall image by about 50%. Reduces CPU load.\nOnly applies to native scaling.", + .desc = "Simulate scanlines (or a pixel grid at odd scales).\nOnly applies to native scaling.", .default_value = 0, .value = 0, .count = 2, @@ -1578,6 +1580,24 @@ static double cpu_double = 0; static double use_double = 0; static uint32_t sec_start = 0; + +//from RGB565 +#define cR(A) (((A) & 0xf800) >> 11) +#define cG(A) (((A) & 0x7e0) >> 5) +#define cB(A) ((A) & 0x1f) +//to RGB565 +#define Weight1_1(A, B) ((((cR(A) + cR(B)) >> 1) & 0x1f) << 11 | (((cG(A) + cG(B)) >> 1) & 0x3f) << 5 | (((cB(A) + cB(B)) >> 1) & 0x1f)) +#define Weight1_2(A, B) ((((cR(A) + (cR(B) << 1)) / 3) & 0x1f) << 11 | (((cG(A) + (cG(B) << 1)) / 3) & 0x3f) << 5 | (((cB(A) + (cB(B) << 1)) / 3) & 0x1f)) +#define Weight2_1(A, B) ((((cR(B) + (cR(A) << 1)) / 3) & 0x1f) << 11 | (((cG(B) + (cG(A) << 1)) / 3) & 0x3f) << 5 | (((cB(B) + (cB(A) << 1)) / 3) & 0x1f)) +#define Weight1_3(A, B) ((((cR(A) + (cR(B) * 3)) >> 2) & 0x1f) << 11 | (((cG(A) + (cG(B) * 3)) >> 2) & 0x3f) << 5 | (((cB(A) + (cB(B) * 3)) >> 2) & 0x1f)) +#define Weight3_1(A, B) ((((cR(B) + (cR(A) * 3)) >> 2) & 0x1f) << 11 | (((cG(B) + (cG(A) * 3)) >> 2) & 0x3f) << 5 | (((cB(B) + (cB(A) * 3)) >> 2) & 0x1f)) +#define Weight1_4(A, B) ((((cR(A) + (cR(B) << 2)) / 5) & 0x1f) << 11 | (((cG(A) + (cG(B) << 2)) / 5) & 0x3f) << 5 | (((cB(A) + (cB(B) << 2)) / 5) & 0x1f)) +#define Weight4_1(A, B) ((((cR(B) + (cR(A) << 2)) / 5) & 0x1f) << 11 | (((cG(B) + (cG(A) << 2)) / 5) & 0x3f) << 5 | (((cB(B) + (cB(A) << 2)) / 5) & 0x1f)) +#define Weight2_3(A, B) (((((cR(A) << 1) + (cR(B) * 3)) / 5) & 0x1f) << 11 | ((((cG(A) << 1) + (cG(B) * 3)) / 5) & 0x3f) << 5 | ((((cB(A) << 1) + (cB(B) * 3)) / 5) & 0x1f)) +#define Weight3_2(A, B) (((((cR(B) << 1) + (cR(A) * 3)) / 5) & 0x1f) << 11 | ((((cG(B) << 1) + (cG(A) * 3)) / 5) & 0x3f) << 5 | ((((cB(B) << 1) + (cB(A) * 3)) / 5) & 0x1f)) +#define Weight1_1_1_1(A, B, C, D) ((((cR(A) + cR(B) + cR(C) + cR(D)) >> 2) & 0x1f) << 11 | (((cG(A) + cG(B) + cG(C) + cG(D)) >> 2) & 0x3f) << 5 | (((cB(A) + cB(B) + cB(C) + cB(D)) >> 2) & 0x1f)) + + static void scaleNull(void* __restrict src, void* __restrict dst, uint32_t w, uint32_t h, uint32_t pitch, uint32_t dst_pitch) {} static void scale1x(void* __restrict src, void* __restrict dst, uint32_t w, uint32_t h, uint32_t pitch, uint32_t dst_pitch) { // pitch of src image not src buffer! @@ -1608,12 +1628,18 @@ static void scale1x_scanline(void* __restrict src, void* __restrict dst, uint32_ int dst_stride = 2 * dst_pitch / SCREEN_BPP; int cpy_pitch = MIN(src_pitch, dst_pitch); + uint16_t k = 0x0000; uint16_t* restrict src_row = (uint16_t*)src; uint16_t* restrict dst_row = (uint16_t*)dst; - for (int y=0; y