diff options
author | Arisotura <thetotalworm@gmail.com> | 2023-12-26 19:04:31 +0100 |
---|---|---|
committer | Arisotura <thetotalworm@gmail.com> | 2023-12-26 19:04:31 +0100 |
commit | fd1e4379b99c01be0ebcfa8cde390a51ca09f716 (patch) | |
tree | 3ab9c48c003b0750e7f2023e4600a225309be34f /src | |
parent | 7f437d48db554a739dd1cab53fb0536783c87432 (diff) | |
parent | d55a384c8807cd0962399dac69e8ee1a9d5c53fd (diff) |
Merge branch 'master' of github.com:melonDS-emu/melonDS
Diffstat (limited to 'src')
-rw-r--r-- | src/DSi_NAND.cpp | 4 | ||||
-rw-r--r-- | src/FATStorage.cpp | 10 | ||||
-rw-r--r-- | src/FATStorage.h | 4 | ||||
-rw-r--r-- | src/NDSCart.cpp | 10 | ||||
-rw-r--r-- | src/frontend/qt_sdl/CMakeLists.txt | 9 | ||||
-rw-r--r-- | src/frontend/qt_sdl/Screen.cpp | 2 | ||||
-rw-r--r-- | src/frontend/qt_sdl/main.cpp | 6 |
7 files changed, 28 insertions, 17 deletions
diff --git a/src/DSi_NAND.cpp b/src/DSi_NAND.cpp index 5f76714..8da0254 100644 --- a/src/DSi_NAND.cpp +++ b/src/DSi_NAND.cpp @@ -122,7 +122,8 @@ NANDImage::NANDImage(NANDImage&& other) noexcept : ConsoleID(other.ConsoleID), FATIV(other.FATIV), FATKey(other.FATKey), - ESKey(other.ESKey) + ESKey(other.ESKey), + Length(other.Length) { other.CurFile = nullptr; } @@ -140,6 +141,7 @@ NANDImage& NANDImage::operator=(NANDImage&& other) noexcept FATIV = other.FATIV; FATKey = other.FATKey; ESKey = other.ESKey; + Length = other.Length; other.CurFile = nullptr; } diff --git a/src/FATStorage.cpp b/src/FATStorage.cpp index 52011a8..9a1a9ad 100644 --- a/src/FATStorage.cpp +++ b/src/FATStorage.cpp @@ -32,14 +32,8 @@ using namespace Platform; using std::string; FATStorage::FATStorage(const std::string& filename, u64 size, bool readonly, const std::optional<string>& sourcedir) : - FilePath(filename), - FileSize(size), - ReadOnly(readonly), - SourceDir(sourcedir) + FATStorage(FATStorageArgs { filename, size, readonly, sourcedir }) { - Load(filename, size, sourcedir); - - File = Platform::OpenLocalFile(FilePath, FileMode::ReadWriteExisting); } FATStorage::FATStorage(const FATStorageArgs& args) noexcept : @@ -55,7 +49,7 @@ FATStorage::FATStorage(FATStorageArgs&& args) noexcept : { Load(FilePath, FileSize, SourceDir); - File = nullptr; + File = Platform::OpenLocalFile(FilePath, FileMode::ReadWriteExisting); } FATStorage::FATStorage(FATStorage&& other) noexcept diff --git a/src/FATStorage.h b/src/FATStorage.h index 1e89b76..48a411b 100644 --- a/src/FATStorage.h +++ b/src/FATStorage.h @@ -48,8 +48,8 @@ class FATStorage { public: FATStorage(const std::string& filename, u64 size, bool readonly, const std::optional<std::string>& sourcedir = std::nullopt); - FATStorage(const FATStorageArgs& args) noexcept; - FATStorage(FATStorageArgs&& args) noexcept; + explicit FATStorage(const FATStorageArgs& args) noexcept; + explicit FATStorage(FATStorageArgs&& args) noexcept; FATStorage(FATStorage&& other) noexcept; FATStorage(const FATStorage& other) = delete; FATStorage& operator=(const FATStorage& other) = delete; diff --git a/src/NDSCart.cpp b/src/NDSCart.cpp index a5fe318..a64d8a2 100644 --- a/src/NDSCart.cpp +++ b/src/NDSCart.cpp @@ -1657,9 +1657,15 @@ std::unique_ptr<CartCommon> ParseROM(std::unique_ptr<u8[]>&& romdata, u32 romlen std::unique_ptr<u8[]> sram = args ? std::move(args->SRAM) : nullptr; u32 sramlen = args ? args->SRAMLength : 0; if (homebrew) - cart = std::make_unique<CartHomebrew>(std::move(cartrom), cartromsize, cartid, romparams, args ? std::move(args->SDCard) : std::nullopt); + { + std::optional<FATStorage> sdcard = args && args->SDCard ? std::make_optional<FATStorage>(std::move(*args->SDCard)) : std::nullopt; + cart = std::make_unique<CartHomebrew>(std::move(cartrom), cartromsize, cartid, romparams, std::move(sdcard)); + } else if (gametitle[0] == 0 && !strncmp("SD/TF-NDS", gametitle + 1, 9) && gamecode == 0x414D5341) - cart = std::make_unique<CartR4>(std::move(cartrom), cartromsize, cartid, romparams, CartR4TypeR4, CartR4LanguageEnglish, args ? std::move(args->SDCard) : std::nullopt); + { + std::optional<FATStorage> sdcard = args && args->SDCard ? std::make_optional<FATStorage>(std::move(*args->SDCard)) : std::nullopt; + cart = std::make_unique<CartR4>(std::move(cartrom), cartromsize, cartid, romparams, CartR4TypeR4, CartR4LanguageEnglish, std::move(sdcard)); + } else if (cartid & 0x08000000) cart = std::make_unique<CartRetailNAND>(std::move(cartrom), cartromsize, cartid, romparams, std::move(sram), sramlen); else if (irversion != 0) diff --git a/src/frontend/qt_sdl/CMakeLists.txt b/src/frontend/qt_sdl/CMakeLists.txt index 9da2c91..c2fa5b5 100644 --- a/src/frontend/qt_sdl/CMakeLists.txt +++ b/src/frontend/qt_sdl/CMakeLists.txt @@ -84,11 +84,11 @@ if (BUILD_STATIC) endif() pkg_check_modules(SDL2 REQUIRED IMPORTED_TARGET sdl2) -pkg_check_modules(Slirp REQUIRED IMPORTED_TARGET slirp) +pkg_check_modules(Slirp REQUIRED slirp) pkg_check_modules(LibArchive REQUIRED IMPORTED_TARGET libarchive) pkg_check_modules(Zstd REQUIRED IMPORTED_TARGET libzstd) -fix_interface_includes(PkgConfig::SDL2 PkgConfig::Slirp PkgConfig::LibArchive) +fix_interface_includes(PkgConfig::SDL2 PkgConfig::LibArchive) add_compile_definitions(ARCHIVE_SUPPORT_ENABLED) @@ -160,9 +160,12 @@ else() target_include_directories(melonDS PUBLIC ${Qt5Gui_PRIVATE_INCLUDE_DIRS}) endif() target_link_libraries(melonDS PRIVATE core) -target_link_libraries(melonDS PRIVATE PkgConfig::SDL2 PkgConfig::Slirp PkgConfig::LibArchive PkgConfig::Zstd) +target_link_libraries(melonDS PRIVATE PkgConfig::SDL2 PkgConfig::LibArchive PkgConfig::Zstd) target_link_libraries(melonDS PRIVATE ${QT_LINK_LIBS} ${CMAKE_DL_LIBS}) +target_include_directories(melonDS PRIVATE "${Slirp_INCLUDE_DIRS}") +target_link_libraries(melonDS PRIVATE "${Slirp_LINK_LIBRARIES}") + if (UNIX) option(PORTABLE "Make a portable build that looks for its configuration in the current directory" OFF) elseif (WIN32) diff --git a/src/frontend/qt_sdl/Screen.cpp b/src/frontend/qt_sdl/Screen.cpp index a86147c..35be7e6 100644 --- a/src/frontend/qt_sdl/Screen.cpp +++ b/src/frontend/qt_sdl/Screen.cpp @@ -25,9 +25,11 @@ #include <vector> #include <string> #include <algorithm> +#include <cmath> #include <QPaintEvent> #include <QPainter> +#include <QDebug> #ifndef _WIN32 #ifndef APPLE #include <qpa/qplatformnativeinterface.h> diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp index 22cb034..e8859ef 100644 --- a/src/frontend/qt_sdl/main.cpp +++ b/src/frontend/qt_sdl/main.cpp @@ -326,10 +326,14 @@ bool EmuThread::UpdateConsole(UpdateConsoleNDSArgs&& ndsargs, UpdateConsoleGBAAr NDS::Current = nullptr; NDS = CreateConsole(std::move(nextndscart), std::move(nextgbacart)); + + if (NDS == nullptr) + return false; + NDS->Reset(); NDS::Current = NDS.get(); - return NDS != nullptr; + return true; } auto arm9bios = ROMManager::LoadARM9BIOS(); |