Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
flyinghead committed Dec 29, 2024
2 parents 32d8d9a + ee1a716 commit a067917
Show file tree
Hide file tree
Showing 252 changed files with 11,255 additions and 7,146 deletions.
1 change: 1 addition & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [push, pull_request]

jobs:
build:
name: Android
runs-on: ubuntu-latest

steps:
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/bsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ jobs:
architecture: [ arm64, x86-64 ]
include:
- operating_system: freebsd
version: '14.1'
pkginstall: sudo pkg install -y alsa-lib ccache cmake evdev-proto git libao libevdev libudev-devd libzip lua54 miniupnpc ninja pkgconf pulseaudio sdl2
version: '14.2'
pkginstall: sudo pkg install -y alsa-lib ccache cmake evdev-proto git libao libevdev libudev-devd libzip lua54 miniupnpc ninja pkgconf pulseaudio sdl2 libcdio
- operating_system: netbsd
version: '10.0'
pkginstall: sudo pkgin update && sudo pkgin -y install alsa-lib ccache cmake gcc12 git libao libzip lua54 miniupnpc ninja-build pkgconf pulseaudio SDL2 && export PATH=/usr/pkg/gcc12/bin:$PATH
pkginstall: sudo pkgin update && sudo pkgin -y install alsa-lib ccache cmake gcc12 git libao libzip lua54 miniupnpc ninja-build pkgconf pulseaudio SDL2 libcdio && export PATH=/usr/pkg/gcc12/bin:$PATH
- operating_system: openbsd
version: '7.5'
pkginstall: sudo pkg_add ccache cmake git libao libzip miniupnpc ninja pkgconf pulseaudio sdl2
version: '7.6'
pkginstall: sudo pkg_add ccache cmake git libao libzip miniupnpc ninja pkgconf pulseaudio sdl2 libcdio
exclude:
- architecture: arm64

Expand All @@ -36,13 +36,13 @@ jobs:
key: ccache-${{ matrix.operating_system }}-${{ matrix.architecture }}-${{ github.sha }}
restore-keys: ccache-${{ matrix.operating_system }}-${{ matrix.architecture }}-

- uses: cross-platform-actions/action@v0.25.0
- uses: cross-platform-actions/action@v0.26.0
with:
operating_system: ${{ matrix.operating_system }}
architecture: ${{ matrix.architecture }}
version: ${{ matrix.version }}
environment_variables: CCACHE_DIR
run: |
${{ matrix.pkginstall }}
cmake -B build -DCMAKE_BUILD_TYPE=Release -G Ninja
cmake -B build -DUSE_LIBCDIO=ON -DCMAKE_BUILD_TYPE=Release -G Ninja
cmake --build build --config Release
12 changes: 6 additions & 6 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ jobs:
- {name: i686-pc-windows-msvc, os: windows-latest, shell: cmd, arch: x86, cmakeArgs: -G Ninja, buildType: Release}
- {name: apple-darwin, os: macos-latest, shell: sh, cmakeArgs: -G Xcode -DUSE_DISCORD=ON, destDir: osx, buildType: RelWithDebInfo}
- {name: apple-ios, os: macos-latest, shell: sh, cmakeArgs: -DCMAKE_SYSTEM_NAME=iOS -G Xcode, destDir: ios, buildType: Release}
- {name: x86_64-pc-linux-gnu, os: ubuntu-20.04, shell: sh, cmakeArgs: -G Ninja -DUSE_DISCORD=ON, destDir: linux, buildType: RelWithDebInfo}
- {name: x86_64-pc-linux-gnu, os: ubuntu-20.04, shell: sh, cmakeArgs: -G Ninja -DUSE_DISCORD=ON -DUSE_LIBCDIO=ON, destDir: linux, buildType: RelWithDebInfo}
- {name: x86_64-pc-windows-msvc, os: windows-latest, shell: cmd, arch: x64, cmakeArgs: -G Ninja -DUSE_DISCORD=ON, buildType: Release}
- {name: x86_64-w64-mingw32, os: windows-latest, shell: 'msys2 {0}', cmakeArgs: -G Ninja -DUSE_DISCORD=ON, destDir: win, buildType: RelWithDebInfo}
- {name: libretro-x86_64-pc-linux-gnu, os: ubuntu-latest, shell: sh, cmakeArgs: -DLIBRETRO=ON -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -G Ninja, buildType: Release}
- {name: libretro-x86_64-w64-mingw32, os: windows-latest, shell: 'msys2 {0}', cmakeArgs: -DLIBRETRO=ON -G Ninja, buildType: Release}
- {name: x86_64-w64-mingw32, os: windows-latest, shell: 'msys2 {0}', cmakeArgs: -G Ninja -DUSE_DISCORD=ON -DUSE_LIBCDIO=ON, destDir: win, buildType: RelWithDebInfo}
- {name: libretro-x86_64-pc-linux-gnu, os: ubuntu-latest, shell: sh, cmakeArgs: -DLIBRETRO=ON -DUSE_LIBCDIO=ON -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -G Ninja, buildType: Release}
- {name: libretro-x86_64-w64-mingw32, os: windows-latest, shell: 'msys2 {0}', cmakeArgs: -DLIBRETRO=ON -DUSE_LIBCDIO=ON -G Ninja, buildType: Release}

steps:
- name: Set up build environment (macOS)
Expand All @@ -45,15 +45,15 @@ jobs:
run: |
sudo add-apt-repository ppa:christianrauch/libdecoration
sudo apt-get update
sudo apt-get -y install ccache libao-dev libasound2-dev libevdev-dev libgl1-mesa-dev liblua5.3-dev libminiupnpc-dev libpulse-dev libsdl2-dev libudev-dev libzip-dev ninja-build libcurl4-openssl-dev
sudo apt-get -y install ccache libao-dev libasound2-dev libevdev-dev libgl1-mesa-dev liblua5.3-dev libminiupnpc-dev libpulse-dev libsdl2-dev libudev-dev libzip-dev ninja-build libcurl4-openssl-dev libcdio-dev
sudo apt-get -y install libwayland-dev libdecor-0-dev libaudio-dev libjack-dev libsndio-dev libsamplerate0-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libxkbcommon-dev libdrm-dev libgbm-dev libgles2-mesa-dev libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev
if: runner.os == 'Linux'

- name: Set up build environment (Windows, MinGW)
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
install: git make mingw-w64-x86_64-ccache mingw-w64-x86_64-cmake mingw-w64-x86_64-lua mingw-w64-x86_64-ninja mingw-w64-x86_64-SDL2 mingw-w64-x86_64-toolchain
install: git make mingw-w64-x86_64-ccache mingw-w64-x86_64-cmake mingw-w64-x86_64-lua mingw-w64-x86_64-ninja mingw-w64-x86_64-SDL2 mingw-w64-x86_64-toolchain mingw-w64-x86_64-libcdio
if: matrix.config.shell == 'msys2 {0}'

- name: Set up build environment (Windows, Visual Studio)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/switch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request]

jobs:
build:
name: ${{ matrix.config.name }}
name: Switch ${{ matrix.config.name }}
runs-on: ubuntu-latest
container: devkitpro/devkita64:latest

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/uwp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [push, pull_request]

jobs:
build:
name: UWP
runs-on: windows-latest

steps:
Expand Down
6 changes: 3 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
variables:
GIT_SUBMODULE_STRATEGY: recursive
CORENAME: flycast
CORE_ARGS: -DLIBRETRO=ON -DCMAKE_BUILD_TYPE=Release
CORE_ARGS: -DLIBRETRO=ON -DUSE_LIBCDIO=ON -DCMAKE_BUILD_TYPE=Release

.core-defs-linux:
extends: .core-defs
variables:
CORE_ARGS: -DLIBRETRO=ON -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -DCMAKE_BUILD_TYPE=Release
CORE_ARGS: -DLIBRETRO=ON -DUSE_LIBCDIO=ON -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -DCMAKE_BUILD_TYPE=Release

.core-defs-osx-x64:
extends: .core-defs
Expand All @@ -36,7 +36,7 @@
.core-defs-android:
extends: .core-defs
script:
- cmake $CORE_ARGS -DANDROID_PLATFORM=android-$API_LEVEL -DCMAKE_TOOLCHAIN_FILE=$NDK_ROOT/build/cmake/android.toolchain.cmake -DANDROID_STL=c++_static -DANDROID_ABI=$ANDROID_ABI -DANDROID_ARM_MODE=arm "$CMAKE_SOURCE_ROOT" -B$BUILD_DIR
- cmake -DLIBRETRO=ON -DCMAKE_BUILD_TYPE=Release -DANDROID_PLATFORM=android-$API_LEVEL -DCMAKE_TOOLCHAIN_FILE=$NDK_ROOT/build/cmake/android.toolchain.cmake -DANDROID_STL=c++_static -DANDROID_ABI=$ANDROID_ABI -DANDROID_ARM_MODE=arm "$CMAKE_SOURCE_ROOT" -B$BUILD_DIR
- cmake --build $BUILD_DIR --target ${CORENAME}_libretro --config Release -- -j $NUMPROC
- mv $BUILD_DIR/${CORENAME}_libretro.so $LIBNAME
- if [ $STRIP_CORE_LIB -eq 1 ]; then $NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip $LIBNAME; fi
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@
[submodule "core/deps/googletest"]
path = core/deps/googletest
url = https://github.com/google/googletest.git
[submodule "core/deps/asio"]
path = core/deps/asio
url = https://github.com/chriskohlhoff/asio.git
56 changes: 48 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ option(ENABLE_GDB_SERVER "Build with GDB debugging support" OFF)
option(ENABLE_DC_PROFILER "Build with support for target machine (SH4) profiler" OFF)
option(ENABLE_FC_PROFILER "Build with support for host app (Flycast) profiler" OFF)
option(USE_DISCORD "Use Discord Presence API" OFF)
option(USE_LIBCDIO "Use libcdio for CDROM access" OFF)

if(IOS AND NOT LIBRETRO)
set(USE_VULKAN OFF CACHE BOOL "Force vulkan off" FORCE)
Expand Down Expand Up @@ -264,7 +265,7 @@ if(NOT "${SENTRY_UPLOAD_URL}" STREQUAL "")
target_compile_definitions(${PROJECT_NAME} PRIVATE SENTRY_UPLOAD="${SENTRY_UPLOAD_URL}")
endif()

target_include_directories(${PROJECT_NAME} PRIVATE core core/deps core/deps/stb core/deps/json)
target_include_directories(${PROJECT_NAME} PRIVATE core core/deps core/deps/stb core/deps/json core/deps/asio/asio/include)
if(LIBRETRO)
target_include_directories(${PROJECT_NAME} PRIVATE shell/libretro)
endif()
Expand Down Expand Up @@ -460,7 +461,14 @@ if(NOT LIBRETRO)
endif()

target_compile_definitions(${PROJECT_NAME} PRIVATE USE_SDL USE_SDL_AUDIO)
target_sources(${PROJECT_NAME} PRIVATE core/sdl/sdl.cpp core/sdl/sdl.h core/sdl/sdl_gamepad.h core/sdl/sdl_keyboard.h)
target_sources(${PROJECT_NAME} PRIVATE
core/sdl/sdl.cpp
core/sdl/sdl.h
core/sdl/sdl_gamepad.h
core/sdl/sdl_keyboard.h
core/sdl/sdl_keyboard_mac.h
core/sdl/dreamconn.cpp
core/sdl/dreamconn.h)

if((UNIX AND NOT APPLE) OR NINTENDO_SWITCH)
find_package(CURL REQUIRED)
Expand Down Expand Up @@ -672,6 +680,28 @@ if(NOT LIBZIP_FOUND OR NINTENDO_SWITCH)
target_link_libraries(${PROJECT_NAME} PRIVATE libzip::zip)
endif()

if(USE_LIBCDIO)
if(PKG_CONFIG_FOUND)
pkg_check_modules(CDIO IMPORTED_TARGET libcdio)
if(CDIO_FOUND)
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_LIBCDIO)
if(MINGW)
# Force static link
target_link_libraries(${PROJECT_NAME} PRIVATE "-l:libcdio.a -l:libiconv.a -lwinmm")
else()
target_link_libraries(${PROJECT_NAME} PRIVATE PkgConfig::CDIO)
endif()
endif()
endif()
if(NOT CDIO_FOUND)
find_package(libcdio)
if(TARGET libcdio::libcdio)
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_LIBCDIO)
target_link_libraries(${PROJECT_NAME} PRIVATE libcdio::libcdio)
endif()
endif()
endif()

if(WIN32)
target_include_directories(${PROJECT_NAME} PRIVATE core/deps/dirent)
endif()
Expand Down Expand Up @@ -1052,22 +1082,23 @@ if(NOT LIBRETRO)
fonts/Roboto-Medium.ttf.zip
fonts/Roboto-Regular.ttf.zip
fonts/fa-solid-900.ttf.zip)
if(ANDROID)
if(ANDROID OR IOS)
cmrc_add_resources(flycast-resources
WHENCE resources
resources/picture/buttons.png)
resources/picture/buttons.png
resources/picture/buttons-arcade.png)
endif()
endif()

target_sources(${PROJECT_NAME} PRIVATE
core/imgread/cdi.cpp
core/imgread/cdio.cpp
core/imgread/chd.cpp
core/imgread/common.cpp
core/imgread/common.h
core/imgread/cue.cpp
core/imgread/gdi.cpp
core/imgread/ImgReader.cpp
core/imgread/ioctl.cpp
core/imgread/iso9660.h
core/imgread/isofs.cpp
core/imgread/isofs.h)
Expand Down Expand Up @@ -1324,6 +1355,8 @@ target_sources(${PROJECT_NAME} PRIVATE
core/rend/tileclip.h
core/rend/TexCache.cpp
core/rend/TexCache.h
core/rend/texconv.cpp
core/rend/texconv.h
core/rend/norend/norend.cpp)
if(NOT LIBRETRO)
target_sources(${PROJECT_NAME} PRIVATE
Expand All @@ -1333,8 +1366,8 @@ if(NOT LIBRETRO)
core/ui/gui.cpp
core/ui/gui.h
core/ui/gui_achievements.cpp
core/ui/gui_android.cpp
core/ui/gui_android.h
core/ui/vgamepad.cpp
core/ui/vgamepad.h
core/ui/gui_chat.h
core/ui/gui_cheats.cpp
core/ui/gui_util.cpp
Expand Down Expand Up @@ -1640,6 +1673,10 @@ if(NOT LIBRETRO)
target_sources(${PROJECT_NAME} PRIVATE
shell/android-studio/flycast/src/main/jni/src/Android.cpp
shell/android-studio/flycast/src/main/jni/src/android_gamepad.h
shell/android-studio/flycast/src/main/jni/src/android_storage.h
shell/android-studio/flycast/src/main/jni/src/http_client.h
shell/android-studio/flycast/src/main/jni/src/jni_util.h
shell/android-studio/flycast/src/main/jni/src/android_input.cpp
shell/android-studio/flycast/src/main/jni/src/android_keyboard.h)

target_link_libraries(${PROJECT_NAME} PRIVATE android log)
Expand All @@ -1664,6 +1701,8 @@ if(NOT LIBRETRO)
shell/apple/emulator-ios/emulator/FlycastViewController.mm
shell/apple/emulator-ios/emulator/PadViewController.h
shell/apple/emulator-ios/emulator/PadViewController.mm
shell/apple/emulator-ios/emulator/EditPadViewController.h
shell/apple/emulator-ios/emulator/EditPadViewController.mm
shell/apple/emulator-ios/emulator/EmulatorView.h
shell/apple/emulator-ios/emulator/EmulatorView.mm
shell/apple/emulator-ios/emulator/main.m
Expand All @@ -1678,7 +1717,8 @@ if(NOT LIBRETRO)
shell/apple/emulator-ios/emulator/Images.xcassets
shell/apple/emulator-ios/emulator/FlycastStoryboard.storyboard
shell/apple/emulator-ios/emulator/LaunchScreen.storyboard
shell/apple/emulator-ios/emulator/PadViewController.xib)
shell/apple/emulator-ios/emulator/PadViewController.xib
shell/apple/emulator-ios/emulator/EditPadViewController.xib)
target_sources(${PROJECT_NAME} PRIVATE ${IOS_RESOURCES})
source_group("Resources" FILES ${IOS_RESOURCES})
set_source_files_properties(${IOS_RESOURCES} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
Expand Down
6 changes: 3 additions & 3 deletions core/achievements/achievements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,7 @@ std::string Achievements::getGameHash()
{
if (settings.platform.isConsole())
{
const u32 diskType = libGDR_GetDiscType();
if (diskType == NoDisk || diskType == Open)
if (!gdr::isLoaded())
return {};
// Reopen the disk locally to avoid threading issues (CHD)
try {
Expand Down Expand Up @@ -964,7 +963,8 @@ void Achievements::unloadGame()

void Achievements::diskChange()
{
if (!active)
if (!active || settings.content.path.empty())
// Don't unload the game when the lid is open while swapping disks
return;
std::string hash = getGameHash();
if (hash == "") {
Expand Down
19 changes: 11 additions & 8 deletions core/audio/audiobackend_null.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@ class NullAudioBackend : public AudioBackend

u32 push(const void* frame, u32 samples, bool wait) override
{
if (wait)
if (wait && last_time.time_since_epoch() != the_clock::duration::zero())
{
if (last_time.time_since_epoch() != the_clock::duration::zero())
{
auto fduration = std::chrono::nanoseconds(1000000000L * samples / 44100);
auto duration = fduration - (the_clock::now() - last_time);
auto fduration = std::chrono::nanoseconds(1'000'000'000LL * samples / 44100);
auto duration = fduration - (the_clock::now() - last_time);
if (duration > std::chrono::nanoseconds::zero())
std::this_thread::sleep_for(duration);
last_time += fduration;
}
else
if (duration < -std::chrono::milliseconds(67))
// if ~4 frames ahead, reset time (fast forward detection)
last_time = the_clock::now();
else
last_time += fduration;
}
else {
last_time = the_clock::now();
}
return 1;
}
Expand Down
20 changes: 20 additions & 0 deletions core/audio/audiostream.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "audiostream.h"
#include "cfg/option.h"
#include "emulator.h"

static void registerForEvents();

struct SoundFrame { s16 l; s16 r; };

Expand Down Expand Up @@ -60,6 +63,7 @@ void WriteSample(s16 r, s16 l)

void InitAudio()
{
registerForEvents();
TermAudio();

std::string slug = config::AudioBackend;
Expand Down Expand Up @@ -138,3 +142,19 @@ void StopAudioRecording()
currentBackend->termRecord();
audio_recording_started = false;
}

static void registerForEvents()
{
static bool done;
if (done)
return;
done = true;
// Empty the audio buffer when loading a state or terminating the game
const auto& callback = [](Event, void *) {
writePtr = 0;
};
EventManager::listen(Event::Terminate, callback);
EventManager::listen(Event::LoadState, callback);
}


7 changes: 6 additions & 1 deletion core/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
#define HOST_CPU CPU_GENERIC
#endif

#if defined(TARGET_IPHONE) && !defined(__aarch64__)
// iOS simulator
#define TARGET_NO_REC
#endif

#if defined(TARGET_NO_REC)
#define FEAT_SHREC DYNAREC_NONE
#define FEAT_AREC DYNAREC_NONE
Expand Down Expand Up @@ -100,7 +105,7 @@
#endif
#endif

#if !defined(LIBRETRO) && !defined(TARGET_NO_EXCEPTIONS)
#if !defined(LIBRETRO)
#define USE_GGPO
#endif

Expand Down
9 changes: 9 additions & 0 deletions core/cfg/cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,12 @@ void cfgSetAutoSave(bool autoSave)
if (autoSave)
saveConfigFile();
}

void cfgSaveFloat(const std::string& section, const std::string& key, float value)
{
cfgdb.set_float(section, key, value);
}
float cfgLoadFloat(const std::string& section, const std::string& key, float def)
{
return cfgdb.get_float(section, key, def);
}
2 changes: 2 additions & 0 deletions core/cfg/cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ std::string cfgLoadStr(const std::string& section, const std::string& key, const
void cfgSaveStr(const std::string& section, const std::string& key, const std::string& value);
void cfgSaveBool(const std::string& section, const std::string& key, bool value);
bool cfgLoadBool(const std::string& section, const std::string& key, bool def);
void cfgSaveFloat(const std::string& section, const std::string& key, float value);
float cfgLoadFloat(const std::string& section, const std::string& key, float def);
void cfgSetVirtual(const std::string& section, const std::string& key, const std::string& value);
bool cfgIsVirtual(const std::string& section, const std::string& key);

Expand Down
Loading

0 comments on commit a067917

Please sign in to comment.