Skip to content

enhancement: Add Libretro core#1803

Merged
midwan merged 248 commits intomasterfrom
libretro-core
Feb 20, 2026
Merged

enhancement: Add Libretro core#1803
midwan merged 248 commits intomasterfrom
libretro-core

Conversation

@midwan
Copy link
Collaborator

@midwan midwan commented Feb 20, 2026

Fixes #1759 .

midwan and others added 21 commits February 9, 2026 21:20
…erry into libretro-core

# Conflicts:
#	.github/workflows/c-cpp.yml
* WIP libretro work

* Working PoC lr core

* stub SDL, add audio

* Makefile optimization

* Wire inputs and vendor libretro-common

* Switch libretro build to dr_flac (decoding only, encoding stubbed out)

* Fixup libco include

* Fixup libco include

* Vendor libco as it's removed in lr-common

* WIP working core (display, input, audio, fast-forward, temptative sync)

* WIP SDL pruning

* WIP SDL pruning

* Dummy SDL files to continue pruning

* More pruning

* Prune libpng for libretro core (only genlock feature is discutable)

* Try to implement more libretro features

* More complete libretro core options

* Refactor to cleanup #ifdef LIBRETRO blocks

* Remove libretro debug instrumentation

* Cleanup src/main.cpp

* Fix standalone build

* Fix lr-build following cpu-thread PR

* Try to fix libretro/windows CI

* More MingW fix

* Try harder to fix gh libretro workflows

* Vendor libretro-common and fix aarch64 zlib

* Fix aarch64 zlib dependency in libretro workflow

* More libretro core options and some debug (to be removed later)

* Implement mostly VFS libretro

* libretro VFS implementation (missing CHD+7z still) + more memory maps exposed

* Fix standalone build

* Try to address high priority issues

* Try to address more feedback issues

* Vendor libco and libretro-common as git submodules

* Fix libretro CI: checkout submodules for build

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix FLAC decoded size calculation and 64-bit seek truncation

Use sizeof(int16_t) for FLAC filesize/frame calculations since
drflac_read_pcm_frames_s16 always outputs 16-bit samples, regardless
of source bit depth (e.g. 24-bit FLAC would overallocate).

Widen posixemu_seek and io_lseek from int to off_t so that seek offsets
on large disk images (>2GB HDF/CHD) are not truncated to 32 bits.

* Add curl --fail flag to zlib download in CI

Prevents tar from receiving an HTML error page on transient
network failures, giving a clear error instead.

---------

Co-authored-by: Dimitris Panokostas <midwan@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
# Conflicts:
#	.github/workflows/c-cpp.yml
#	CMakeLists.txt
#	cmake/SourceFiles.cmake
#	src/osdep/amiberry.cpp
#	src/osdep/amiberry_gfx.cpp
#	src/osdep/amiberry_whdbooter.cpp
#	src/osdep/blkdev_ioctl.cpp
#	src/osdep/crtemu.h
#	src/osdep/imgui/input.cpp
Address several issues in the libretro core before merging to master:

- Fix memory leak: free strdup'd argv strings after amiberry_main() returns
- Fix hardcoded /tmp/ paths: use portable get_log_directory() helper with
  fallback chain (save_dir -> system_dir -> env TMPDIR/TMP/TEMP -> ".")
- Fix version string: use AMIBERRY_VERSION macro instead of hardcoded v5.7.0
- Fix pixel format: store XRGB8888 negotiation result and fall back to RGB565
- Fix duplicate conditional blocks in input logging functions
- Add Windows portability guards across libretro.cpp, sdl_stub.cpp, and
  writelog.cpp (unistd.h, termios.h, POSIX APIs -> Win32 equivalents)
- Remove dead Win32 console code from writelog.cpp that referenced undefined
  functions from the standalone build
- Extract magic numbers into named constants (geometry, fiber stack, buffers)
- Re-enable Windows CI build with MSYS2/MinGW toolchain
- Add log message when booting with no game content
- Add sync warning comment for v1/v2 options arrays

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Preserve _WIN32 on MinGW builds by guarding the unconditional #undef
in sysconfig.h. This fixes the cascade of "Only Win32 target is
supported!" errors from MinGW system headers.

Key changes:
- sysconfig.h: preserve _WIN32 on MinGW, undef Linux-only HAVE_*
  macros, fix SIZEOF_LONG for LLP64, add .dll LT_MODULE_EXT, skip
  POSIX-to-Windows mappings that are native on MinGW (Sleep,
  _timezone, _daylight, _ftelli64, _fseeki64, _wunlink)
- fsusage.cpp: route MinGW through GetDiskFreeSpaceEx path, guard
  od-win32/posixemu.h for libretro
- registry.cpp: guard WinUAE-specific win32.h include and hWinUAEKey
  reference, force inimode=1 for libretro
- zfile_archive.cpp: guard win32.h include for libretro
- zfile.cpp: guard WinInet internet download block for libretro

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Now that _WIN32 is preserved on MinGW, three new issues surfaced:

- byteswap.h: MSVC intrinsic names (_byteswap_uint16/32) don't exist
  on MinGW; use GCC __builtin_bswap* instead
- target.h: dummy Windows types (GUID, etc.) were skipped because
  _WIN32 is defined, but <windows.h> wasn't included yet; add it
- sysconfig.h: _istalnum redefined warning because MinGW's tchar.h
  already defines it; guard with #ifndef __MINGW32__

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Including <windows.h> in target.h causes cascading conflicts:
- std::byte vs rpcndr.h byte ambiguity (C++17 headers included first)
- UINT8 signed vs unsigned char mismatch (uae/types.h vs basetsd.h)
- SOCKET int vs UINT_PTR mismatch (sysconfig.h vs winsock.h)

Instead of including <windows.h> early, use dummy types for MinGW
libretro builds (same as Linux/macOS path). Also guard SOCKET and
INT8/UINT8/etc typedefs that MinGW provides natively.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- uae/string.h: define uaestrlen and uaetcslen in the _WIN32 path
  (they were only defined for non-Windows, mapping to SDL_strlen)
- sysconfig.h: keep HAVE_SYS_TIME_H for MinGW (it has <sys/time.h>
  which provides gettimeofday needed by arcadia.cpp)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The CD drive enumeration block uses GetDriveType() and DRIVE_CDROM
from <windows.h>, which isn't available in libretro builds. Guard
with !defined(LIBRETRO) since libretro doesn't access host hardware.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
MinGW doesn't have <sys/wait.h> (POSIX process wait header).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
# Conflicts:
#	.github/workflows/c-cpp.yml
#	src/blkdev_cdimage.cpp
#	src/fpp_native.cpp
#	src/fsusage.cpp
#	src/include/uae/byteswap.h
#	src/include/uae/string.h
#	src/include/uae/types.h
#	src/osdep/amiberry_filesys.cpp
#	src/osdep/amiberry_whdbooter.cpp
#	src/osdep/bsdsocket_host.cpp
#	src/osdep/dpi_handler.hpp
#	src/osdep/registry.cpp
#	src/osdep/sysconfig.h
#	src/osdep/target.h
#	src/osdep/writelog.cpp
#	src/zfile.cpp
* WIP libretro work

* Working PoC lr core

* stub SDL, add audio

* Makefile optimization

* Wire inputs and vendor libretro-common

* Switch libretro build to dr_flac (decoding only, encoding stubbed out)

* Fixup libco include

* Fixup libco include

* Vendor libco as it's removed in lr-common

* WIP working core (display, input, audio, fast-forward, temptative sync)

* WIP SDL pruning

* WIP SDL pruning

* Dummy SDL files to continue pruning

* More pruning

* Prune libpng for libretro core (only genlock feature is discutable)

* Try to implement more libretro features

* More complete libretro core options

* Refactor to cleanup #ifdef LIBRETRO blocks

* Remove libretro debug instrumentation

* Cleanup src/main.cpp

* Fix standalone build

* Fix lr-build following cpu-thread PR

* Try to fix libretro/windows CI

* More MingW fix

* Try harder to fix gh libretro workflows

* Vendor libretro-common and fix aarch64 zlib

* Fix aarch64 zlib dependency in libretro workflow

* More libretro core options and some debug (to be removed later)

* Implement mostly VFS libretro

* libretro VFS implementation (missing CHD+7z still) + more memory maps exposed

* Fix standalone build

* Try to address high priority issues

* Try to address more feedback issues

* Vendor libco and libretro-common as git submodules

* Fix libretro CI: checkout submodules for build

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix FLAC decoded size calculation and 64-bit seek truncation

Use sizeof(int16_t) for FLAC filesize/frame calculations since
drflac_read_pcm_frames_s16 always outputs 16-bit samples, regardless
of source bit depth (e.g. 24-bit FLAC would overallocate).

Widen posixemu_seek and io_lseek from int to off_t so that seek offsets
on large disk images (>2GB HDF/CHD) are not truncated to 32 bits.

* Add curl --fail flag to zlib download in CI

Prevents tar from receiving an HTML error page on transient
network failures, giving a clear error instead.

* Improve libretro core with MIDI support, IPF temptative support and proper version info

* WIP changes before merging upstream libretro-core

* Re-add lost SDL IME code in merge

* Fix CI zlib URL

* Test windows build

* Try to fix libretro/Win32 build + WIP CD32 debug

* Fix CD32 from the plane

* Remove debug

* Fix zlib CI failure + try to fix windows/libretro build

* Another libretro/windows mkdir fix

* Try to fix some HWND vs SDL_Window type error (meaningless for libretro core)

* Fix makefile for windows

* lr-windows progress

* Continue lr-windows CI fixes

* Continue lr-windows CI fixes

* lr-windows compiles, now try to make it link

---------

Co-authored-by: Dimitris Panokostas <midwan@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* WIP libretro work

* Working PoC lr core

* stub SDL, add audio

* Makefile optimization

* Wire inputs and vendor libretro-common

* Switch libretro build to dr_flac (decoding only, encoding stubbed out)

* Fixup libco include

* Fixup libco include

* Vendor libco as it's removed in lr-common

* WIP working core (display, input, audio, fast-forward, temptative sync)

* WIP SDL pruning

* WIP SDL pruning

* Dummy SDL files to continue pruning

* More pruning

* Prune libpng for libretro core (only genlock feature is discutable)

* Try to implement more libretro features

* More complete libretro core options

* Refactor to cleanup #ifdef LIBRETRO blocks

* Remove libretro debug instrumentation

* Cleanup src/main.cpp

* Fix standalone build

* Fix lr-build following cpu-thread PR

* Try to fix libretro/windows CI

* More MingW fix

* Try harder to fix gh libretro workflows

* Vendor libretro-common and fix aarch64 zlib

* Fix aarch64 zlib dependency in libretro workflow

* More libretro core options and some debug (to be removed later)

* Implement mostly VFS libretro

* libretro VFS implementation (missing CHD+7z still) + more memory maps exposed

* Fix standalone build

* Try to address high priority issues

* Try to address more feedback issues

* Vendor libco and libretro-common as git submodules

* Fix libretro CI: checkout submodules for build

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Fix FLAC decoded size calculation and 64-bit seek truncation

Use sizeof(int16_t) for FLAC filesize/frame calculations since
drflac_read_pcm_frames_s16 always outputs 16-bit samples, regardless
of source bit depth (e.g. 24-bit FLAC would overallocate).

Widen posixemu_seek and io_lseek from int to off_t so that seek offsets
on large disk images (>2GB HDF/CHD) are not truncated to 32 bits.

* Add curl --fail flag to zlib download in CI

Prevents tar from receiving an HTML error page on transient
network failures, giving a clear error instead.

* Improve libretro core with MIDI support, IPF temptative support and proper version info

* WIP changes before merging upstream libretro-core

* Re-add lost SDL IME code in merge

* Fix CI zlib URL

* Test windows build

* Try to fix libretro/Win32 build + WIP CD32 debug

* Fix CD32 from the plane

* Remove debug

* Fix zlib CI failure + try to fix windows/libretro build

* Another libretro/windows mkdir fix

* Try to fix some HWND vs SDL_Window type error (meaningless for libretro core)

* Fix makefile for windows

* lr-windows progress

* Continue lr-windows CI fixes

* Continue lr-windows CI fixes

* lr-windows compiles, now try to make it link

* Try to fix libretro windows DLL

* Static link because of outdated libwinpthread in RA distribution

---------

Co-authored-by: Dimitris Panokostas <midwan@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
# Conflicts:
#	src/osdep/amiberry.cpp
#	src/osdep/amiberry_input.cpp
#	src/osdep/sysconfig.h
@midwan midwan linked an issue Feb 20, 2026 that may be closed by this pull request
@midwan midwan self-assigned this Feb 20, 2026
@midwan midwan merged commit e4f3d41 into master Feb 20, 2026
23 checks passed
@midwan midwan deleted the libretro-core branch February 20, 2026 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Libretro implementation

2 participants