From 67740303f51ca3e5aa7edb19d1d2760990bf0b0c Mon Sep 17 00:00:00 2001 From: neonloop Date: Sun, 29 Jan 2023 07:37:02 +0000 Subject: Adds dosbox-pure core dosbox-pure does not support resume states, because it loads puremenu before loading game. Savestates can also glitch loaded game. --- .gitignore | 1 + Makefile | 10 +- funkey/fk_instant_play.c | 7 +- funkey/fk_instant_play.h | 1 - menu.c | 2 + overrides.c | 2 + overrides.h | 1 + overrides/dosbox-pure.h | 366 +++++++++++++++++++++ .../dosbox-pure/0001-add-auto-cycle-limit.patch | 35 ++ patches/dosbox-pure/1000-funkey-s-support.patch | 4 +- 10 files changed, 423 insertions(+), 6 deletions(-) create mode 100644 overrides/dosbox-pure.h create mode 100644 patches/dosbox-pure/0001-add-auto-cycle-limit.patch diff --git a/.gitignore b/.gitignore index 61f0877..e9187e1 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ picoarch /beetle-pce-fast /bluemsx +/dosbox-pure /fake-08 /fbalpha2012 /fceumm diff --git a/Makefile b/Makefile index 452eeee..8e0ab16 100644 --- a/Makefile +++ b/Makefile @@ -23,10 +23,10 @@ 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) fake-08 snes9x2005_plus snes9x2010 +CORES := $(CORES) dosbox-pure fake-08 snes9x2005_plus snes9x2010 endif -#CORES=tyrquake +# CORES = dosbox-pure beetle-pce-fast_REPO = https://github.com/libretro/beetle-pce-fast-libretro beetle-pce-fast_CORE = mednafen_pce_fast_libretro.so @@ -37,6 +37,7 @@ bluemsx_TYPES = rom,ri,mx1,mx2,dsk,col,sg,sc,cas,m3u dosbox-pure_REPO = https://github.com/schellingb/dosbox-pure dosbox-pure_CORE = dosbox_pure_libretro.so +dosbox-pure_TYPES = zip,dosz,exe,com,bat,iso,cue,ins,img,ima,vhd,jrc,tc,m3u,m3u8,conf fake-08_REPO = https://github.com/jtothebell/fake-08 fake-08_BUILD_PATH = fake-08/platform/libretro @@ -168,6 +169,7 @@ clean-libpicofe: plat_trimui.o: plat_sdl.c plat_funkey.o: plat_sdl.c plat_linux.o: plat_sdl.c +overrides.o: overrides.c overrides/*.h $(BIN): libpicofe/.patched $(OBJS) $(CC) $(OBJS) $(LDFLAGS) -o $(BIN) @@ -395,6 +397,10 @@ 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 +dosbox-pure_ROM_DIR = /mnt/DOS +dosbox-pure_ICON_URL = https://raw.githubusercontent.com/MiyooCFW/gmenunx/master/assets/miyoo/skins/PixUI/icons/dosbox.png +dosbox-pure_ICON = dosbox + fake-08_NAME = fake-08 fake-08_ROM_DIR = /mnt/PICO-8 diff --git a/funkey/fk_instant_play.c b/funkey/fk_instant_play.c index 638e0fd..aac9091 100644 --- a/funkey/fk_instant_play.c +++ b/funkey/fk_instant_play.c @@ -33,6 +33,7 @@ #include "fk_menu.h" #include "fk_instant_play.h" #include "core.h" +#include "overrides.h" #include "util.h" #ifndef SHELL_CMD_POWERDOWN @@ -40,6 +41,8 @@ #define SHELL_CMD_POWERDOWN_HANDLE "powerdown handle" #endif +#define AUTOSAVE_SLOT 99 + static char *prog_name; int instant_play = 0; @@ -125,7 +128,9 @@ void FK_LoadNewGame(const char *fname) void FK_Autosave(void) { - if (state_allowed()) { + const struct core_override *override = get_overrides(); + + if (state_allowed() && (!override || !(override->prevent_resume))) { int prev_state_slot = state_slot; state_slot = AUTOSAVE_SLOT; state_write(); diff --git a/funkey/fk_instant_play.h b/funkey/fk_instant_play.h index 2ed3c71..d51cc5b 100644 --- a/funkey/fk_instant_play.h +++ b/funkey/fk_instant_play.h @@ -38,7 +38,6 @@ extern "C" { #include -#define AUTOSAVE_SLOT 99 extern int instant_play; extern void FK_InitInstantPlay(int argc, char **argv); diff --git a/menu.c b/menu.c index bd00e52..5b70b90 100644 --- a/menu.c +++ b/menu.c @@ -62,6 +62,8 @@ me_bind_action me_ctrl_actions[] = { "R BUTTON ", 1 << RETRO_DEVICE_ID_JOYPAD_R }, { "L2 BUTTON ", 1 << RETRO_DEVICE_ID_JOYPAD_L2 }, { "R2 BUTTON ", 1 << RETRO_DEVICE_ID_JOYPAD_R2 }, + { "L3 BUTTON ", 1 << RETRO_DEVICE_ID_JOYPAD_L3 }, + { "R3 BUTTON ", 1 << RETRO_DEVICE_ID_JOYPAD_R3 }, { NULL, 0 } }; diff --git a/overrides.c b/overrides.c index 4d195c7..0058144 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/dosbox-pure.h" #include "overrides/fake-08.h" #include "overrides/fceumm.h" #include "overrides/fmsx.h" @@ -21,6 +22,7 @@ static const struct core_override overrides[] = { beetle_pce_fast_overrides, bluemsx_overrides, + dosbox_pure_overrides, fake08_overrides, fceumm_overrides, fmsx_overrides, diff --git a/overrides.h b/overrides.h index 19efdf3..2ab0633 100644 --- a/overrides.h +++ b/overrides.h @@ -36,6 +36,7 @@ struct core_override { const size_t emu_action_size; const struct core_override_option* options; int needs_reopen; + int prevent_resume; }; #define CORE_OVERRIDE(override, key, fallback) ((override && override->key) ? (override->key) : (fallback)) diff --git a/overrides/dosbox-pure.h b/overrides/dosbox-pure.h new file mode 100644 index 0000000..1d58d35 --- /dev/null +++ b/overrides/dosbox-pure.h @@ -0,0 +1,366 @@ +#include "main.h" +#include "overrides.h" + +static const struct core_override_option dosbox_pure_core_option_overrides[] = { + { + .key = "dosbox_pure_advanced", + .desc = "Show Advanced", + }, + { + .key = "dosbox_pure_force60fps", + .desc = "Force 60FPS", + }, + { + .key = "dosbox_pure_perfstats", + .desc = "Show Performance", + .options = { + { "none", "Disabled" }, + { "simple", "Simple" }, + { "detailed", "Detailed" }, + }, + }, + { + .key = "dosbox_pure_savestate", + .blocked = true, + }, + { + .key = "dosbox_pure_conf", + .desc = "Load dosbox.conf", + .info = "Load legacy dosbox.conf files. 'inside' loads files in the loaded zip or folder. 'outside' loads files next to the zip or folder.", + .options = { + { "false", "Off" }, + { "inside", "Inside" }, + { "outside", "Outside" } + } + }, + { + .key = "dosbox_pure_menu_time", + .blocked = true, + }, + { + .key = "dosbox_pure_latency", + .blocked = true, + }, + { + .key = "dosbox_pure_auto_target", + .blocked = true, + }, + { + .key = "dosbox_pure_bind_unused", + .desc = "Bind unused buttons", + .info = "Bind all unused controller buttons to keyboard keys.", + }, + { + .key = "dosbox_pure_on_screen_keyboard", + .desc = "Enable OSK", + }, + { + .key = "dosbox_pure_mouse_wheel", + .default_value = "none", + .blocked = true, + }, + { + .key = "dosbox_pure_mouse_speed_factor", + .desc = "Mouse Sensitivity", + }, + { + .key = "dosbox_pure_mouse_speed_factor_x", + .desc = "Horz. Sensitivity", + }, + { + .key = "dosbox_pure_mouse_input", + .blocked = true, + .default_value = "false", + }, + { + .key = "dosbox_pure_auto_mapping", + .desc = "Auto Button Map", + .info = "Automatically apply a gamepad control mapping scheme when it detects a game, provided by the Keyb2Joypad Project (by Jemy Murphy and bigjim)", + .options = { + { "true", "On" }, + { "notify", "On (notify)" }, + { "false", "Off" } + } + }, + { + .key = "dosbox_pure_keyboard_layout", + .blocked = true, + }, + { + .key = "dosbox_pure_menu_transparency", + .desc = "Transparency", + }, + { + .key = "dosbox_pure_joystick_analog_deadzone", + .blocked = true, + }, + { + .key = "dosbox_pure_joystick_timed", + .blocked = true, + }, + { + .key = "dosbox_pure_cycles", + .desc = "Performance", + .options = { + { "auto", "AUTO" }, + { "max", "MAX" }, + { "315", "8086/8088" }, + { "1320", "286 slow" }, + { "2750", "286 fast" }, + { "4720", "386" }, + { "7800", "386DX" }, + { "13400", "486DX" }, + { "26800", "486DX2" }, + { "77000", "Pentium" }, + { "200000", "PII" }, + { "500000", "PIII" }, + { "1000000", "Athlon" }, + } + }, + { + .key = "dosbox_pure_cycles_scale", + .desc = "Perf. Scale", + }, + { + .key = "dosbox_pure_cycle_limit", + .desc = "CPU Limit", + .info = "When emulating DOS as fast as possible, how much time per frame should be used by the emulation.", + .default_value = "0.8", + }, + { + .key = "dosbox_pure_machine", + .desc = "Graphics", + .info = "The type of graphics chip that DOSBox will emulate. Requires restart.", + .options = { + { "svga", "SVGA" }, + { "vga", "VGA" }, + { "ega", "EGA" }, + { "cga", "CGA" }, + { "tandy", "Tandy" }, + { "hercules", "Hercules" }, + { "pcjr", "PCjr" }, + } + }, + { + .key = "dosbox_pure_cga", + .desc = "CGA Mode", + .options = { + { "early_auto", "Early, comp. auto" }, + { "early_on", "Early, comp. on" }, + { "early_off", "Early, comp. off" }, + { "late_auto", "Late, comp. auto" }, + { "late_on", "Late, comp. on" }, + { "late_off", "Late, comp. off" }, + } + }, + { + .key = "dosbox_pure_hercules", + .desc = "Hercules Color", + .options = { + { "white", "white" }, + { "amber", "amber" }, + { "green", "green" }, + } + }, + { + .key = "dosbox_pure_svga", + .desc = "SVGA Mode", + .info = "The SVGA variation that is being emulated. Try changing this if you encounter graphical glitches. Requires restart.", + .options = { + { "svga_s3", "Trio64" }, + { "vesa_nolfb", "Trio64 (FB hack)" }, + { "vesa_oldvbe", "Trio64 (VESA 1.3)" }, + { "svga_et3000", "ET3000" }, + { "svga_et4000", "ET4000" }, + { "svga_paradise", "PVGA1A" }, + } + }, + { + .key = "dosbox_pure_svgamem", + .desc = "SVGA Memory", + .info = "The amount of memory available to the emulated SVGA card. Requires restart.", + .options = { + { "0", "512KB" }, + { "1", "1MB" }, + { "2", "2MB" }, + { "3", "3MB" }, + { "4", "4MB" }, + { "8", "8MB" }, + } + }, + { + .key = "dosbox_pure_voodoo", + .blocked = true, + .default_value = "off", + }, + { + .key = "dosbox_pure_voodoo_perf", + .blocked = true, + }, + { + .key = "dosbox_pure_aspect_correction", + .desc = "Correct Aspect", + .options = { + { "false", "Off" }, + { "true", "On" }, + }, + }, + { + .key = "dosbox_pure_memory_size", + .desc = "Memory Size", + .info = "The amount of (high) memory that the emulated machine has. You can also disable extended memory (EMS/XMS). Requires restart.", + .options = { + { "none", "no EMS/XMS" }, + { "4", "4 MB" }, + { "8", "8 MB" }, + { "16", "16 MB" }, + { "24", "24 MB" }, + { "32", "32 MB" }, + { "48", "48 MB" }, + { "64", "64 MB" }, + { "96", "96 MB" }, + { "128", "128 MB" }, + { "224", "224 MB" }, + } + }, + { + .key = "dosbox_pure_cpu_type", + .desc = "CPU Type", + .info = "Emulated CPU type. Auto is the fastest choice. Requires restart.", + .options = { + { "auto", "Auto" }, + { "386", "386" }, + { "386_slow", "386 (slow)" }, + { "386_prefetch", "386 (prefetch)" }, + { "486_slow", "486 (slow)" }, + { "pentium_slow", "Pentium (slow)" }, + } + }, + { + .key = "dosbox_pure_cpu_core", + .desc = "CPU Core", + .info = "Emulation method (DOSBox CPU core) used. Dynamic uses a dynarec implementation. Simple uses an interpreter optimized for old games.", + .options = { + { "auto", "Auto" }, + { "dynamic", "Dynamic" }, + { "normal", "Normal" }, + { "simple", "Simple" }, + }, + .default_value = "dynamic", + }, + { + .key = "dosbox_pure_bootos_ramdisk", + .desc = "Ignore Disk Changes", + .info = "When running an installed operating system, modifications to the C: drive will not be saved permanently.", + .options = { + { "false", "Off" }, + { "true", "On" }, + }, + }, + { + .key = "dosbox_pure_bootos_dfreespace", + .blocked = true, + }, + { + .key = "dosbox_pure_bootos_forcenormal", + .blocked = true, + }, + { + .key = "dosbox_pure_audiorate", + .desc = "Sample rate", + .info = "Sets the audio sample rate. Requires restart.", + }, + { + .key = "dosbox_pure_sblaster_conf", + .desc = "SoundBlaster Conf", + .options = { + { "A220 I7 D1 H5", "A220 I7 D1 H5" }, + { "A220 I5 D1 H5", "A220 I5 D1 H5" }, + { "A240 I7 D1 H5", "A240 I7 D1 H5" }, + { "A240 I7 D3 H7", "A240 I7 D3 H7" }, + { "A240 I2 D3 H7", "A240 I2 D3 H7" }, + { "A240 I5 D3 H5", "A240 I5 D3 H5" }, + { "A240 I5 D1 H5", "A240 I5 D1 H5" }, + { "A240 I10 D3 H7", "A240 I10 D3 H7" }, + { "A280 I10 D0 H6", "A280 I10 D0 H6" }, + { "A280 I5 D1 H5", "A280 I5 D1 H5" }, + }, + }, + { + .key = "dosbox_pure_midi", + .blocked = true, + }, + { + .key = "dosbox_pure_sblaster_type", + .desc = "SoundBlaster Type", + .options = { + { "sb16", "SB16" }, + { "sbpro2", "SB Pro 2" }, + { "sbpro1", "SB Pro" }, + { "sb2", "SB 2.0" }, + { "sb1", "SB 1.0" }, + { "gb", "GameBlaster" }, + { "none", "none" }, + }, + }, + { + .key = "dosbox_pure_sblaster_adlib_mode", + .desc = "SB Adlib Mode", + .options = { + { "auto", "Auto" }, + { "cms", "CMS" }, + { "opl2", "OPL-2" }, + { "dualopl2", "Dual OPL-2" }, + { "opl3", "OPL-3" }, + { "opl3gold", "OPL-3 Gold" }, + { "none", "Disabled" }, + }, + }, + { + .key = "dosbox_pure_sblaster_adlib_emu", + .desc = "Adlib Provider", + .options = { + { "default", "Default" }, + { "nuked", "Nuked OPL3" }, + }, + }, + { + .key = "dosbox_pure_gus", + .desc = "Gravis Ultrasound", + .info = "Enable Gravis Ultrasound emulation. Requires restart.", + .options = { + { "false", "Off" }, + { "true", "On" }, + }, + }, + { NULL } +}; + +me_bind_action dosbox_pure_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 }, + { "A BUTTON ", 1 << RETRO_DEVICE_ID_JOYPAD_A }, + { "B BUTTON ", 1 << RETRO_DEVICE_ID_JOYPAD_B }, + { "X BUTTON ", 1 << RETRO_DEVICE_ID_JOYPAD_X }, + { "Y BUTTON ", 1 << RETRO_DEVICE_ID_JOYPAD_Y }, + { "START ", 1 << RETRO_DEVICE_ID_JOYPAD_START }, + { "SELECT ", 1 << RETRO_DEVICE_ID_JOYPAD_SELECT }, + { "L BUTTON ", 1 << RETRO_DEVICE_ID_JOYPAD_L }, + { "R BUTTON ", 1 << RETRO_DEVICE_ID_JOYPAD_R }, + { "L2 BUTTON", 1 << RETRO_DEVICE_ID_JOYPAD_L2 }, + { "R2 BUTTON", 1 << RETRO_DEVICE_ID_JOYPAD_R2 }, + { "SHOW OSK ", 1 << RETRO_DEVICE_ID_JOYPAD_L3 }, + { NULL, 0 } +}; + +#define dosbox_pure_overrides { \ + .core_name = "dosbox-pure", \ + .actions = dosbox_pure_ctrl_actions, \ + .action_size = array_size(dosbox_pure_ctrl_actions), \ + .options = dosbox_pure_core_option_overrides, \ + .needs_reopen = 1, \ + .prevent_resume = 1, \ +} diff --git a/patches/dosbox-pure/0001-add-auto-cycle-limit.patch b/patches/dosbox-pure/0001-add-auto-cycle-limit.patch new file mode 100644 index 0000000..69baeb9 --- /dev/null +++ b/patches/dosbox-pure/0001-add-auto-cycle-limit.patch @@ -0,0 +1,35 @@ +diff --git a/dosbox_pure_libretro.cpp b/dosbox_pure_libretro.cpp +index 6a03631..dc4f70d 100644 +--- a/dosbox_pure_libretro.cpp ++++ b/dosbox_pure_libretro.cpp +@@ -451,15 +451,30 @@ void DBP_SetRealModeCycles() + (year > 1993 ? 60000 : // Pentium 90 MHz + Cycles1981to1993[year - 1981]))); // Matching speed for year + ++#ifdef CYCLE_LIMIT ++ if (CPU_CycleMax > CYCLE_LIMIT) ++ { ++ CPU_CycleMax = CYCLE_LIMIT; ++ CPU_AutoDetermineMode &= ~(CPU_AUTODETERMINE_CYCLES|(CPU_AUTODETERMINE_CYCLES<= 8192 && (CPU_AutoDetermineMode & CPU_AUTODETERMINE_CORE)) + { ++#endif + #if (C_DYNAMIC_X86) + if (cpudecoder != CPU_Core_Dyn_X86_Run) { void CPU_Core_Dyn_X86_Cache_Init(bool); CPU_Core_Dyn_X86_Cache_Init(true); cpudecoder = CPU_Core_Dyn_X86_Run; } + #elif (C_DYNREC) + if (cpudecoder != CPU_Core_Dynrec_Run) { void CPU_Core_Dynrec_Cache_Init(bool); CPU_Core_Dynrec_Cache_Init(true); cpudecoder = CPU_Core_Dynrec_Run; } + #endif + } ++#ifdef CYCLE_LIMIT ++ } ++#endif + } + + static void DBP_UnlockSpeed(bool unlock, int start_frame_skip = 0, bool skip_once = false) diff --git a/patches/dosbox-pure/1000-funkey-s-support.patch b/patches/dosbox-pure/1000-funkey-s-support.patch index 27ef8f7..59f7888 100644 --- a/patches/dosbox-pure/1000-funkey-s-support.patch +++ b/patches/dosbox-pure/1000-funkey-s-support.patch @@ -1,5 +1,5 @@ diff --git a/Makefile b/Makefile -index f0acd51..8ad5a68 100644 +index f0acd51..7b42e9b 100644 --- a/Makefile +++ b/Makefile @@ -104,6 +104,16 @@ else ifeq ($(platform),ctr) @@ -10,7 +10,7 @@ index f0acd51..8ad5a68 100644 + OUTNAME := dosbox_pure_libretro.so + CXX := $(CROSS_COMPILE)g++ + LDFLAGS := -Wl,--gc-sections -fno-ident -+ COMMONFLAGS += -pthread ++ COMMONFLAGS += -pthread -DCYCLE_LIMIT=8200 + CPUFLAGS += -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -march=armv7ve + STRIPCMD := $(CROSS_COMPILE)strip --strip-all + ifeq ($(DEBUG), 1) -- cgit v1.2.3