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 Oct 11, 2024
2 parents 4d73cc8 + efd71b3 commit b2c6159
Show file tree
Hide file tree
Showing 58 changed files with 1,494 additions and 420 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,18 @@ jobs:
key: android-ccache-${{ github.sha }}
restore-keys: android-ccache-

- name: Bump version code
uses: chkfung/[email protected]
with:
gradlePath: shell/android-studio/flycast/build.gradle
versionCode: ${{ github.run_number }}

- name: Gradle
working-directory: shell/android-studio
run: ./gradlew assembleRelease --parallel
run: ./gradlew assembleRelease bundleRelease --parallel
env:
SENTRY_UPLOAD_URL: ${{ secrets.SENTRY_UPLOAD_URL }}
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}

- uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -68,7 +75,9 @@ jobs:
if: github.repository == 'flyinghead/flycast' && github.event_name == 'push'

- name: Upload to S3
run: aws s3 sync shell/android-studio/flycast/build/outputs/apk/release s3://flycast-builds/android/${GITHUB_REF#refs/}-$GITHUB_SHA --acl public-read --exclude='*.json' --follow-symlinks
run: |
cp shell/android-studio/flycast/build/outputs/bundle/release/*.aab shell/android-studio/flycast/build/outputs/apk/release/
aws s3 sync shell/android-studio/flycast/build/outputs/apk/release s3://flycast-builds/android/${GITHUB_REF#refs/}-$GITHUB_SHA --acl public-read --exclude='*.json' --follow-symlinks
if: ${{ steps.aws-credentials.outputs.aws-account-id != '' }}

- name: Setup Sentry CLI
Expand Down
2 changes: 1 addition & 1 deletion core/audio/audiobackend_oboe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class OboeBackend : AudioBackend
}
recordStream->requestStart();
NOTICE_LOG(AUDIO, "Oboe recorder started. stream capacity: %d frames",
stream->getBufferCapacityInFrames());
recordStream->getBufferCapacityInFrames());

return true;
}
Expand Down
1 change: 1 addition & 0 deletions core/cfg/option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ Option<bool> OmxAudioHdmi("audio_hdmi", true, "omx");

Option<int> MouseSensitivity("MouseSensitivity", 100, "input");
Option<int> VirtualGamepadVibration("VirtualGamepadVibration", 20, "input");
Option<int> VirtualGamepadTransparency("VirtualGamepadTransparency", 37, "input");

std::array<Option<MapleDeviceType>, 4> MapleMainDevices {
Option<MapleDeviceType>("device1", MDT_SegaController, "input"),
Expand Down
1 change: 1 addition & 0 deletions core/cfg/option.h
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ extern Option<bool> OmxAudioHdmi;

extern Option<int> MouseSensitivity;
extern Option<int> VirtualGamepadVibration;
extern Option<int> VirtualGamepadTransparency;
extern std::array<Option<MapleDeviceType>, 4> MapleMainDevices;
extern std::array<std::array<Option<MapleDeviceType>, 2>, 4> MapleExpansionDevices;
extern Option<bool> PerGameVmu;
Expand Down
14 changes: 13 additions & 1 deletion core/cheats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,17 @@ void CheatManager::setActive(bool active)
void CheatManager::loadCheatFile(const std::string& filename)
{
#ifndef LIBRETRO
try {
hostfs::FileInfo fileInfo = hostfs::storage().getFileInfo(filename);
if (fileInfo.size >= 1_MB) {
WARN_LOG(COMMON, "Cheat file '%s' is too big", filename.c_str());
return;
}
} catch (const hostfs::StorageException& e) {
WARN_LOG(COMMON, "Cannot find cheat file '%s': %s", filename.c_str(), e.what());
return;
}

FILE* cheatfile = hostfs::storage().openFile(filename, "r");
if (cheatfile == nullptr)
{
Expand Down Expand Up @@ -421,7 +432,8 @@ void CheatManager::loadCheatFile(const std::string& filename)
}
setActive(!cheats.empty());
INFO_LOG(COMMON, "%d cheats loaded", (int)cheats.size());
cfgSaveStr("cheats", gameId, filename);
if (!cheats.empty())
cfgSaveStr("cheats", gameId, filename);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion core/deps/SDL
Submodule SDL updated 170 files
24 changes: 17 additions & 7 deletions core/emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ void Emulator::runInternal()
{
nvmem::saveFiles();
dc_reset(false);
sh4_cpu.Start();
}
} while (resetRequested);
}
Expand Down Expand Up @@ -895,6 +896,8 @@ void Emulator::run()
verify(state == Running);
startTime = sh4_sched_now64();
renderTimeout = false;
if (!singleStep && stepRangeTo == 0)
sh4_cpu.Start();
try {
runInternal();
if (ggpo::active())
Expand Down Expand Up @@ -937,6 +940,7 @@ void Emulator::start()
if (config::ThreadedRendering)
{
const std::lock_guard<std::mutex> lock(mutex);
sh4_cpu.Start();
threadResult = std::async(std::launch::async, [this] {
ThreadName _("Flycast-emu");
InitAudio();
Expand Down Expand Up @@ -971,15 +975,20 @@ void Emulator::start()
bool Emulator::checkStatus(bool wait)
{
try {
const std::lock_guard<std::mutex> lock(mutex);
std::unique_lock<std::mutex> lock(mutex);
if (threadResult.valid())
{
if (!wait)
{
auto result = threadResult.wait_for(std::chrono::seconds(0));
lock.unlock();
auto localResult = threadResult;
if (wait) {
localResult.wait();
}
else {
auto result = localResult.wait_for(std::chrono::seconds(0));
if (result == std::future_status::timeout)
return true;
}
lock.lock();
threadResult.get();
}
return false;
Expand All @@ -996,16 +1005,17 @@ bool Emulator::render()

if (!config::ThreadedRendering)
{
if (state != Running)
return false;
run();
if (stopRequested)
{
stopRequested = false;
TermAudio();
nvmem::saveFiles();
EventManager::event(Event::Pause);
return false;
}
if (state != Running)
return false;
run();
// TODO if stopping due to a user request, no frame has been rendered
return !renderTimeout;
}
Expand Down
2 changes: 1 addition & 1 deletion core/emulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class Emulator
Terminated,
};
State state = Uninitialized;
std::future<void> threadResult;
std::shared_future<void> threadResult;
bool resetRequested = false;
bool singleStep = false;
u64 startTime = 0;
Expand Down
3 changes: 2 additions & 1 deletion core/hw/flashrom/flashrom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
#include "flashrom.h"
#include "oslib/oslib.h"
#include "stdclass.h"
#include "oslib/storage.h"

bool MemChip::Load(const std::string& file)
{
FILE *f = nowide::fopen(file.c_str(), "rb");
FILE *f = hostfs::storage().openFile(file, "rb");
if (f)
{
bool rv = std::fread(data + write_protect_size, 1, size - write_protect_size, f) == size - write_protect_size;
Expand Down
4 changes: 2 additions & 2 deletions core/hw/naomi/gdcartridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,18 +494,18 @@ void GDCartridge::device_start(LoadProgress *progress, std::vector<u8> *digest)
u8 buffer[2048];
std::string parent = hostfs::storage().getParentPath(settings.content.path);
std::string gdrom_path = get_file_basename(settings.content.fileName) + "/" + gdrom_name;
gdrom_path = hostfs::storage().getSubPath(parent, gdrom_path);
std::unique_ptr<Disc> gdrom;
try {
gdrom_path = hostfs::storage().getSubPath(parent, gdrom_path);
gdrom = std::unique_ptr<Disc>(OpenDisc(gdrom_path + ".chd", digest));
}
catch (const FlycastException& e)
{
WARN_LOG(NAOMI, "Opening chd failed: %s", e.what());
if (gdrom_parent_name != nullptr)
{
std::string gdrom_parent_path = hostfs::storage().getSubPath(parent, std::string(gdrom_parent_name) + "/" + gdrom_name);
try {
std::string gdrom_parent_path = hostfs::storage().getSubPath(parent, std::string(gdrom_parent_name) + "/" + gdrom_name);
gdrom = std::unique_ptr<Disc>(OpenDisc(gdrom_parent_path + ".chd", digest));
} catch (const FlycastException& e) {
WARN_LOG(NAOMI, "Opening parent chd failed: %s", e.what());
Expand Down
20 changes: 13 additions & 7 deletions core/hw/naomi/naomi_cart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,12 @@ void naomi_cart_LoadBios(const char *filename)
std::unique_ptr<Archive> parent_archive;
if (game->parent_name != nullptr)
{
std::string parentPath = hostfs::storage().getParentPath(filename);
parentPath = hostfs::storage().getSubPath(parentPath, game->parent_name);
parent_archive.reset(OpenArchive(parentPath));
try {
std::string parentPath = hostfs::storage().getParentPath(filename);
parentPath = hostfs::storage().getSubPath(parentPath, game->parent_name);
parent_archive.reset(OpenArchive(parentPath));
} catch (const FlycastException& e) {
}
}

const char *bios = "naomi";
Expand Down Expand Up @@ -218,13 +221,16 @@ static void loadMameRom(const std::string& path, const std::string& fileName, Lo
std::unique_ptr<Archive> parent_archive;
if (game->parent_name != nullptr)
{
std::string parentPath = hostfs::storage().getParentPath(path);
parentPath = hostfs::storage().getSubPath(parentPath, game->parent_name);
parent_archive.reset(OpenArchive(parentPath));
try {
std::string parentPath = hostfs::storage().getParentPath(path);
parentPath = hostfs::storage().getSubPath(parentPath, game->parent_name);
parent_archive.reset(OpenArchive(parentPath));
} catch (const FlycastException& e) {
}
if (parent_archive != nullptr)
INFO_LOG(NAOMI, "Opened %s", game->parent_name);
else
WARN_LOG(NAOMI, "Parent not found: %s", parentPath.c_str());
WARN_LOG(NAOMI, "Parent not found: %s", game->parent_name);

}

Expand Down
14 changes: 10 additions & 4 deletions core/hw/naomi/systemsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2088,12 +2088,18 @@ void SystemSpCart::Init(LoadProgress *progress, std::vector<u8> *digest)
{
std::string parent = hostfs::storage().getParentPath(settings.content.path);
std::string gdrom_path = get_file_basename(settings.content.fileName) + "/" + std::string(mediaName) + ".chd";
gdrom_path = hostfs::storage().getSubPath(parent, gdrom_path);
chd = openChd(gdrom_path);
try {
gdrom_path = hostfs::storage().getSubPath(parent, gdrom_path);
chd = openChd(gdrom_path);
} catch (const FlycastException& e) {
}
if (parentName != nullptr && chd == nullptr)
{
std::string gdrom_parent_path = hostfs::storage().getSubPath(parent, std::string(parentName) + "/" + std::string(mediaName) + ".chd");
chd = openChd(gdrom_parent_path);
try {
std::string gdrom_parent_path = hostfs::storage().getSubPath(parent, std::string(parentName) + "/" + std::string(mediaName) + ".chd");
chd = openChd(gdrom_parent_path);
} catch (const FlycastException& e) {
}
}
if (chd == nullptr)
throw NaomiCartException("SystemSP: Cannot open CompactFlash file " + gdrom_path);
Expand Down
7 changes: 6 additions & 1 deletion core/hw/sh4/dyna/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ static void recSh4_ClearCache()

static void recSh4_Run()
{
sh4_int_bCpuRun = true;
RestoreHostRoundingMode();

u8 *sh4_dyna_rcb = (u8 *)&Sh4cntx + sizeof(Sh4cntx);
Expand Down Expand Up @@ -341,6 +340,11 @@ void* DYNACALL rdv_LinkBlock(u8* code,u32 dpc)
return (void*)rv;
}

static void recSh4_Start()
{
sh4Interp.Start();
}

static void recSh4_Stop()
{
sh4Interp.Stop();
Expand Down Expand Up @@ -409,6 +413,7 @@ static bool recSh4_IsCpuRunning()
void Get_Sh4Recompiler(sh4_if* cpu)
{
cpu->Run = recSh4_Run;
cpu->Start = recSh4_Start;
cpu->Stop = recSh4_Stop;
cpu->Step = recSh4_Step;
cpu->Reset = recSh4_Reset;
Expand Down
7 changes: 6 additions & 1 deletion core/hw/sh4/interpr/sh4_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ static u16 ReadNexOp()

static void Sh4_int_Run()
{
sh4_int_bCpuRun = true;
RestoreHostRoundingMode();

try {
Expand All @@ -74,6 +73,11 @@ static void Sh4_int_Run()
sh4_int_bCpuRun = false;
}

static void Sh4_int_Start()
{
sh4_int_bCpuRun = true;
}

static void Sh4_int_Stop()
{
sh4_int_bCpuRun = false;
Expand Down Expand Up @@ -206,6 +210,7 @@ static void Sh4_int_Term()

void Get_Sh4Interpreter(sh4_if* cpu)
{
cpu->Start = Sh4_int_Start;
cpu->Run = Sh4_int_Run;
cpu->Stop = Sh4_int_Stop;
cpu->Step = Sh4_int_Step;
Expand Down
Loading

0 comments on commit b2c6159

Please sign in to comment.