Skip to content

Commit f27872b

Browse files
authored
feat: comprehensive libretro core improvements — bug fixes, new options, modern API, CUE/CCD detection (#1825)
* fix: libretro core improvements — save state bug, aspect ratio, controller types, input polling - Fix double zfile_fclose in retro_unserialize (restore_state_file already closes via savestate_restore_finish) - Fix retro_serialize_size to sum all RAM boards (MAX_RAM_BOARDS) with z3chipmem/mbresmem and increase overhead from 2MB to 8MB - Add RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME for Workbench boot - Use fixed 4:3 aspect ratio instead of raw pixel ratio - Add CD32 Pad and Joystick controller subtypes - Add RETRO_ENVIRONMENT_GET_PERF_INTERFACE for profiling - Fix mouse polling to support both Amiga ports (was hardcoded to 1) - Skip input polling for ports configured as RETRO_DEVICE_NONE - Extract Makefile version from CMakeLists.txt instead of hardcoding * fix: mask device subclass IDs for joyport auto-ordering RETRO_DEVICE_SUBCLASS values (CD32 Pad, Joystick) encode the subclass in the upper bits. The joyport auto-ordering logic compared the raw device ID against RETRO_DEVICE_JOYPAD, causing subclass selections to be treated as non-joypad devices. Apply RETRO_DEVICE_MASK before comparison, matching how poll_input() already handles these values. * fix: harden libretro core — defensive fixes and modern API adoption - Guard environ_cb against NULL before first use in retro_set_environment - Replace all bare strdup() calls in core_entry() with safe_strdup that tracks allocation failures; skip amiberry_main if OOM occurs - Declare serialization quirks (CORE_VARIABLE_SIZE, MUST_INITIALIZE) so frontends handle variable save-state sizes and pre-init correctly - Upgrade show_message() to SET_MESSAGE_EXT with severity, duration in ms, and priority; falls back to legacy SET_MESSAGE automatically - Warn on unreadable disk paths in replace_image_index (accept anyway since the file may appear later, e.g. network mount) - Truncate WHDLoad sanitized filenames to 200 chars to prevent filesystem path-length overflows on extraction * feat: add core options, audio API, superhires geometry, CUE/CCD parsing, disk mutex Phase 3 — Core options expansion: - amiberry_sound_filter: off/emulated/on (Amiga low-pass filter) - amiberry_stereo_separation: 0-10 (Amiga hard-panned audio mixing) - amiberry_floppy_speed: turbo/1x/2x/4x/8x - amiberry_video_standard: auto/PAL/NTSC (core restart required) Phase 4 — Audio API: - Register SET_MINIMUM_AUDIO_LATENCY (64ms) to reduce crackling on 50Hz PAL content running on 60Hz displays - Register SET_AUDIO_BUFFER_STATUS_CALLBACK to receive underrun alerts Phase 5 — Video geometry: - Increase MAX_GFX_WIDTH from 1280 to 1920 and MAX_GFX_HEIGHT from 1024 to 1280, matching the draw buffer dimensions so superhires modes (1508px wide) are not clamped by initial geometry Phase 6 — Disk improvements: - Implement CUE sheet parser (detect_cd_content_from_cue): parses FILE/TRACK directives, resolves binary path, reads sector 16 with correct offset for MODE1/2048 and MODE1/2352 sector sizes - Implement CCD parser (detect_cd_content_from_ccd): finds companion .img file with raw 2352-byte sectors and reads sector 16 - Replace TODO heuristic with actual CUE/CCD detection in detect_cd_content() - Add std::mutex protection to all disk control callbacks to prevent race conditions from concurrent frontend/emulator access * fix: address PR review — subclass masking, aspect ratio, CUE case-sensitivity - Apply RETRO_DEVICE_MASK in apply_port_device() so CD32 Pad and Joystick subclass IDs are correctly recognized as joypads - Remove redundant amiga_aspect_ratio() helper; inline 4:3 constant - Make CUE parser fully case-insensitive via lowercase copy matching
1 parent 0138766 commit f27872b

File tree

2 files changed

+404
-73
lines changed

2 files changed

+404
-73
lines changed

libretro/Makefile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,19 @@ ifeq ($(SANITIZE), 1)
100100
LDFLAGS += -fsanitize=address
101101
endif
102102

103+
# Extract version from root CMakeLists.txt (single source of truth)
104+
AMIBERRY_VERSION := $(shell sed -n 's/^.*VERSION \([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/p' $(AMIBERRY_DIR)/CMakeLists.txt | head -1)
105+
ifeq ($(AMIBERRY_VERSION),)
106+
AMIBERRY_VERSION := 0.0.0
107+
endif
108+
AMIBERRY_VERSION_MAJOR := $(word 1,$(subst ., ,$(AMIBERRY_VERSION)))
109+
AMIBERRY_VERSION_MINOR := $(word 2,$(subst ., ,$(AMIBERRY_VERSION)))
110+
AMIBERRY_VERSION_PATCH := $(word 3,$(subst ., ,$(AMIBERRY_VERSION)))
111+
103112
# Add Amiberry defines
104113
FLAGS += -DAMIBERRY -DLIBRETRO -DUTF8PROC_STATIC -D_FILE_OFFSET_BITS=64 -DAMIBERRY_DATADIR=\".\" -DAMIBERRY_LIBDIR=\".\"
105-
FLAGS += -DAMIBERRY_VERSION=\"8.0.0\" -DAMIBERRY_VERSION_PRE_RELEASE=\"\"
106-
FLAGS += -DAMIBERRY_VERSION_MAJOR=8 -DAMIBERRY_VERSION_MINOR=0 -DAMIBERRY_VERSION_PATCH=0
114+
FLAGS += -DAMIBERRY_VERSION=\"$(AMIBERRY_VERSION)\" -DAMIBERRY_VERSION_PRE_RELEASE=\"\"
115+
FLAGS += -DAMIBERRY_VERSION_MAJOR=$(AMIBERRY_VERSION_MAJOR) -DAMIBERRY_VERSION_MINOR=$(AMIBERRY_VERSION_MINOR) -DAMIBERRY_VERSION_PATCH=$(AMIBERRY_VERSION_PATCH)
107116
FLAGS += -DAMIBERRY_IS_PRE_RELEASE=0
108117
FLAGS += -DAMIBERRY_BUILD_YEAR=$(shell date +%Y) -DAMIBERRY_BUILD_MONTH=$(shell date +%-m) -DAMIBERRY_BUILD_DAY=$(shell date +%-d)
109118
FLAGS += -DAMIBERRY_BUILD_DATE=\"$(shell date +%Y-%m-%d)\"

0 commit comments

Comments
 (0)