From 9128b4e516438301cfcfa7f400d9a4b46bac73ac Mon Sep 17 00:00:00 2001 From: neonloop Date: Mon, 16 Jan 2023 23:15:21 +0000 Subject: Adds fake-08 core Includes resume state patch from shauninman, thanks! https://github.com/shauninman/picoarch/blob/miniui-miyoomini/patches/fake-08/001-fix-resume-state.patch --- .gitignore | 1 + Makefile | 11 +++- core.c | 11 ---- core.h | 1 - main.c | 20 ++++++- main.h | 1 + overrides.c | 2 + overrides/fake-08.h | 19 +++++++ patches/fake-08/0001-fix-resume-state.patch | 81 +++++++++++++++++++++++++++++ patches/fake-08/1000-funkey-s-build.patch | 17 ++++++ 10 files changed, 150 insertions(+), 14 deletions(-) create mode 100644 overrides/fake-08.h create mode 100644 patches/fake-08/0001-fix-resume-state.patch create mode 100644 patches/fake-08/1000-funkey-s-build.patch diff --git a/.gitignore b/.gitignore index 759282c..9e6bce1 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ picoarch /beetle-pce-fast /bluemsx +/fake-08 /fbalpha2012 /fceumm /fmsx diff --git a/Makefile b/Makefile index 8f8e19d..28cc4de 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ LDFLAGS = -lc -ldl -lgcc -lm -lSDL -lasound -lpng -lz -Wl,--gc-sections -flto CORES = beetle-pce-fast bluemsx fceumm fmsx gambatte gme gpsp mame2000 pcsx_rearmed picodrive quicknes smsplus-gx snes9x2002 snes9x2005 $(EXTRA_CORES) ifneq ($(platform), trimui) -CORES := $(CORES) snes9x2005_plus +CORES := $(CORES) fake-08 snes9x2005_plus endif beetle-pce-fast_REPO = https://github.com/libretro/beetle-pce-fast-libretro @@ -34,6 +34,12 @@ beetle-pce-fast_TYPES = pce,cue,ccd,chd,toc,m3u bluemsx_REPO = https://github.com/libretro/blueMSX-libretro bluemsx_TYPES = rom,ri,mx1,mx2,dsk,col,sg,sc,cas,m3u +fake-08_REPO = https://github.com/jtothebell/fake-08 +fake-08_BUILD_PATH = fake-08/platform/libretro +fake-08_MAKEFILE = Makefile +fake-08_CORE = fake08_libretro.so +fake-08_TYPES = p8,png + fbalpha2012_BUILD_PATH = fbalpha2012/svn-current/trunk fbalpha2012_MAKEFILE = makefile.libretro fbalpha2012_TYPES = zip @@ -371,6 +377,9 @@ bluemsx_ROM_DIR = /mnt/MSX bluemsx_ICON_URL = https://raw.githubusercontent.com/MiyooCFW/gmenunx/master/assets/miyoo/skins/PixUI/icons/dingux-msx.png bluemsx_ICON = dingux-msx +fake-08_NAME = fake-08 +fake-08_ROM_DIR = /mnt/PICO-8 + fbalpha2012_NAME = fba2012 fbalpha2012_ROM_DIR = /mnt/Arcade fbalpha2012_ICON_URL = https://raw.githubusercontent.com/MiyooCFW/gmenunx/master/assets/miyoo/skins/PixUI/icons/fba.png diff --git a/core.c b/core.c index 57ad0d3..058236d 100644 --- a/core.c +++ b/core.c @@ -26,7 +26,6 @@ double frame_rate; double aspect_ratio; unsigned audio_buffer_size_override; int state_slot; -int resume_slot = -1; static char config_dir[MAX_PATH]; static char save_dir[MAX_PATH]; @@ -221,16 +220,6 @@ error: return ret; } -int state_resume(void) { - int ret = 0; - if (resume_slot != -1) { - state_slot = resume_slot; - ret = state_read(); - resume_slot = -1; - } - return ret; -} - unsigned disc_get_count(void) { if (disk_control_ext.get_num_images) return disk_control_ext.get_num_images(); diff --git a/core.h b/core.h index a667e36..2ec86b5 100644 --- a/core.h +++ b/core.h @@ -41,7 +41,6 @@ extern double frame_rate; extern double aspect_ratio; extern unsigned audio_buffer_size_override; extern int state_slot; -extern int resume_slot; void config_file_name(char *buf, size_t len, config_type config_type); void save_relative_path(char *buf, size_t len, const char *basename); diff --git a/main.c b/main.c index 6625133..2884850 100644 --- a/main.c +++ b/main.c @@ -34,6 +34,7 @@ bool should_quit = false; unsigned current_audio_buffer_size; char core_name[MAX_PATH]; int config_override = 0; +int resume_slot = -1; static int last_screenshot = 0; static uint32_t vsyncs; @@ -228,6 +229,11 @@ void set_defaults(void) scale_filter = SCALE_FILTER_SMOOTH; } + if (!strcmp(core_name, "fake-08")) { + scale_size = SCALE_SIZE_ASPECT; + scale_filter = SCALE_FILTER_NEAREST; + } + if (!strcmp(core_name, "pcsx_rearmed") || !strcmp(core_name, "picodrive")) { scale_size = SCALE_SIZE_FULL; @@ -584,6 +590,18 @@ static void adjust_audio(void) { } } + +int state_resume(void) { + int ret = 0; + + if (resume_slot != -1) { + state_slot = resume_slot; + ret = state_read(); + resume_slot = -1; + } + return ret; +} + int main(int argc, char **argv) { char content_path[MAX_PATH]; #ifdef FUNKEY_S @@ -677,6 +695,7 @@ int main(int argc, char **argv) { } instant_play = false; + FK_InitInstantPlay(argc, argv); } #endif show_startup_message(); @@ -685,7 +704,6 @@ int main(int argc, char **argv) { #ifdef FUNKEY_S remove(autosave_path); remove_config(CONFIG_TYPE_AUTO); - FK_InitInstantPlay(argc, argv); #endif do { diff --git a/main.h b/main.h index 5428d6c..f4fc12a 100644 --- a/main.h +++ b/main.h @@ -36,6 +36,7 @@ extern bool should_quit; extern unsigned current_audio_buffer_size; extern char core_name[MAX_PATH]; extern int config_override; +extern int resume_slot; #ifdef MMENU extern void* mmenu; diff --git a/overrides.c b/overrides.c index 576328a..2fe0111 100644 --- a/overrides.c +++ b/overrides.c @@ -1,6 +1,7 @@ #include "overrides.h" #include "overrides/beetle-pce-fast.h" #include "overrides/bluemsx.h" +#include "overrides/fake-08.h" #include "overrides/fceumm.h" #include "overrides/fmsx.h" #include "overrides/gambatte.h" @@ -19,6 +20,7 @@ static const struct core_override overrides[] = { beetle_pce_fast_overrides, bluemsx_overrides, + fake08_overrides, fceumm_overrides, fmsx_overrides, gambatte_overrides, diff --git a/overrides/fake-08.h b/overrides/fake-08.h new file mode 100644 index 0000000..8773958 --- /dev/null +++ b/overrides/fake-08.h @@ -0,0 +1,19 @@ +#include "overrides.h" + +me_bind_action fake08_ctrl_actions[] = +{ + { "UP ", 1 << RETRO_DEVICE_ID_JOYPAD_UP}, + { "DOWN ", 1 << RETRO_DEVICE_ID_JOYPAD_DOWN }, + { "LEFT ", 1 << RETRO_DEVICE_ID_JOYPAD_LEFT }, + { "RIGHT ", 1 << RETRO_DEVICE_ID_JOYPAD_RIGHT }, + { "O ", 1 << RETRO_DEVICE_ID_JOYPAD_A }, + { "X ", 1 << RETRO_DEVICE_ID_JOYPAD_B }, + { "START ", 1 << RETRO_DEVICE_ID_JOYPAD_START }, + { NULL, 0 } +}; + +#define fake08_overrides { \ + .core_name = "fake-08", \ + .actions = fake08_ctrl_actions, \ + .action_size = array_size(fake08_ctrl_actions), \ +} diff --git a/patches/fake-08/0001-fix-resume-state.patch b/patches/fake-08/0001-fix-resume-state.patch new file mode 100644 index 0000000..b3d73bc --- /dev/null +++ b/patches/fake-08/0001-fix-resume-state.patch @@ -0,0 +1,81 @@ +diff --git a/platform/libretro/libretro.cpp b/platform/libretro/libretro.cpp +index 927ea8d4b8d1658a1d7521fe7e9abcbdede0ba5f..63a43f3f065344cdf45e0b10e5c9c089736695f2 100644 +--- a/platform/libretro/libretro.cpp ++++ b/platform/libretro/libretro.cpp +@@ -82,6 +82,46 @@ EXPORT void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb) { audio_ + EXPORT void retro_set_input_poll(retro_input_poll_t cb) { input_poll_cb = cb; } + EXPORT void retro_set_input_state(retro_input_state_t cb) { input_state_cb = cb; } + ++ ++static int frames = 0; ++static int defer_frames = 2; ++static void* deferred_data = NULL; ++static size_t deferred_size = 0; ++ ++static void free_deferred_data(void) { ++ if (deferred_size) { ++ if (log_cb) log_cb(RETRO_LOG_INFO, "Freed deferred save state.\n"); ++ free(deferred_data); ++ deferred_data = NULL; ++ deferred_size = 0; ++ } ++} ++ ++static void defer_unserialize(const void *data, size_t size) { ++ free_deferred_data(); ++ ++ if (data==NULL || size<=0) return; ++ ++ if (log_cb) log_cb(RETRO_LOG_INFO, "Deferred save state load.\n"); ++ ++ deferred_data = malloc(size); ++ memcpy(deferred_data, data, size); ++ deferred_size = size; ++} ++static void update_deferred(void) { ++ frames += 1; ++ ++ if (framesCloseCart(); + _host->oneTimeCleanup(); +@@ -205,6 +247,8 @@ int flip = 0; + + EXPORT void retro_run() + { ++ if (framesgetTargetFps() == 60 || frame % 2 == 0) + { +@@ -396,6 +440,11 @@ EXPORT bool retro_serialize(void *data, size_t size) + + EXPORT bool retro_unserialize(const void *data, size_t size) + { ++ if (frames