Merge branch 'master' into more-dsp

This commit is contained in:
wheremyfoodat 2024-11-20 02:40:20 +02:00
commit 33f45cf1f5
13 changed files with 83 additions and 42 deletions

View file

@ -9,7 +9,8 @@
variables:
GIT_SUBMODULE_STRATEGY: recursive
CORENAME: panda3ds
CORE_ARGS: -DBUILD_LIBRETRO_CORE=ON -DENABLE_USER_BUILD=ON -DENABLE_VULKAN=OFF -DENABLE_LUAJIT=OFF -DENABLE_DISCORD_RPC=OFF
BASE_CORE_ARGS: -DBUILD_LIBRETRO_CORE=ON -DENABLE_USER_BUILD=ON -DENABLE_VULKAN=OFF -DENABLE_LUAJIT=OFF -DENABLE_DISCORD_RPC=OFF -DENABLE_METAL=OFF
CORE_ARGS: ${BASE_CORE_ARGS}
# Inclusion templates, required for the build to work
@ -80,7 +81,7 @@ libretro-build-osx-x64:
tags:
- mac-apple-silicon
variables:
CORE_ARGS: -DBUILD_LIBRETRO_CORE=ON -DENABLE_USER_BUILD=ON -DENABLE_VULKAN=OFF -DENABLE_LUAJIT=OFF -DENABLE_DISCORD_RPC=OFF -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCRYPTOPP_AMD64=1
CORE_ARGS: ${BASE_CORE_ARGS} -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCRYPTOPP_AMD64=1
extends:
- .libretro-osx-cmake-x86
- .core-defs

3
.gitmodules vendored
View file

@ -82,3 +82,6 @@
[submodule "third_party/fdk-aac"]
path = third_party/fdk-aac
url = https://github.com/Panda3DS-emu/fdk-aac/
[submodule "third_party/cryptoppwin"]
path = third_party/cryptoppwin
url = https://github.com/shadps4-emu/ext-cryptoppwin

View file

@ -57,6 +57,7 @@ option(ENABLE_HTTP_SERVER "Enable HTTP server. Used for Discord bot support" OFF
option(ENABLE_DISCORD_RPC "Compile with Discord RPC support (disabled by default)" ON)
option(ENABLE_LUAJIT "Enable scripting with the Lua programming language" ON)
option(ENABLE_QT_GUI "Enable the Qt GUI. If not selected then the emulator uses a minimal SDL-based UI instead" OFF)
option(USE_SYSTEM_SDL2 "Use the system's SDL2 package" OFF)
option(ENABLE_GIT_VERSIONING "Enables querying git for the emulator version" ON)
option(BUILD_HYDRA_CORE "Build a Hydra core" OFF)
option(BUILD_LIBRETRO_CORE "Build a Libretro core" OFF)
@ -126,7 +127,6 @@ include_directories(third_party/elfio/)
include_directories(third_party/hips/include/)
include_directories(third_party/imgui/)
include_directories(third_party/dynarmic/src)
include_directories(third_party/cryptopp/)
include_directories(third_party/cityhash/include)
include_directories(third_party/result/include)
include_directories(third_party/xxhash/include)
@ -145,18 +145,22 @@ if(ENABLE_DISCORD_RPC AND NOT ANDROID)
include_directories(third_party/discord-rpc/include)
endif()
set(SDL_STATIC ON CACHE BOOL "" FORCE)
set(SDL_SHARED OFF CACHE BOOL "" FORCE)
set(SDL_TEST OFF CACHE BOOL "" FORCE)
if (NOT ANDROID)
add_subdirectory(third_party/SDL2)
target_link_libraries(AlberCore PUBLIC SDL2-static)
if (USE_SYSTEM_SDL2)
find_package(SDL2 CONFIG REQUIRED)
target_link_libraries(AlberCore PUBLIC SDL2::SDL2)
else()
set(SDL_STATIC ON CACHE BOOL "" FORCE)
set(SDL_SHARED OFF CACHE BOOL "" FORCE)
set(SDL_TEST OFF CACHE BOOL "" FORCE)
add_subdirectory(third_party/SDL2)
target_link_libraries(AlberCore PUBLIC SDL2-static)
endif()
endif()
add_subdirectory(third_party/fmt)
add_subdirectory(third_party/toml11)
include_directories(${SDL2_INCLUDE_DIR})
include_directories(third_party/toml11)
include_directories(third_party/glm)
include_directories(third_party/renderdoc)
@ -178,10 +182,21 @@ if(ANDROID)
target_link_libraries(AlberCore PRIVATE EGL log)
endif()
set(CRYPTOPP_BUILD_TESTING OFF)
add_subdirectory(third_party/cryptopp)
add_subdirectory(third_party/glad)
# Cryptopp doesn't support compiling under clang-cl, so we have to include it as a prebuilt MSVC static library
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND MSVC)
add_subdirectory(third_party/cryptoppwin)
include_directories(third_party/cryptoppwin/include)
target_link_libraries(AlberCore PRIVATE cryptoppwin)
else()
set(CRYPTOPP_BUILD_TESTING OFF)
add_subdirectory(third_party/cryptopp)
include_directories(third_party/cryptopp)
target_link_libraries(AlberCore PRIVATE cryptopp)
endif()
if(ENABLE_LUAJIT)
add_subdirectory(third_party/LuaJIT luajit)
include_directories(third_party/LuaJIT/src ${CMAKE_BINARY_DIR}/luajit)
@ -224,6 +239,11 @@ endif()
if(NOT MSVC OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT DISABLE_SSE4 AND HOST_X64)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse4.1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1")
elseif(MSVC AND NOT DISABLE_SSE4)
# Tell our SIMD code to use SSE4.1 by defining the relevant macros.
# Clang defines these macros, MSVC does not.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D__SSE3__ /D__SSE4_1__")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D__SSE3__ /D__SSE4_1__")
endif()
if(ENABLE_RENDERDOC_API)
@ -574,7 +594,7 @@ set(ALL_SOURCES ${SOURCE_FILES} ${FS_SOURCE_FILES} ${CRYPTO_SOURCE_FILES} ${KERN
${AUDIO_SOURCE_FILES} ${HEADER_FILES} ${FRONTEND_HEADER_FILES})
target_sources(AlberCore PRIVATE ${ALL_SOURCES})
target_link_libraries(AlberCore PRIVATE dynarmic cryptopp glad resources_console_fonts teakra fdk-aac)
target_link_libraries(AlberCore PRIVATE dynarmic glad resources_console_fonts teakra fdk-aac)
target_link_libraries(AlberCore PUBLIC glad capstone fmt::fmt)
if(ENABLE_DISCORD_RPC AND NOT ANDROID)

View file

@ -1,7 +1,7 @@
# Software Information
display_name = "Nintendo - 3DS (Panda3DS)"
authors = "Panda3DS Authors (tm)"
supported_extensions = "3ds|3dsx|elf|axf|cci|cxi|app"
supported_extensions = "3ds|3dsx|elf|axf|cci|cxi|app|ncch"
corename = "Panda3DS"
categories = "Emulator"
license = "GPLv3"

View file

@ -21,10 +21,12 @@ class MiniAudioDevice {
bool running = false;
std::vector<std::string> audioDevices;
public:
MiniAudioDevice();
// If safe is on, we create a null audio device
void init(Samples& samples, bool safe = false);
void close();
void start();
void stop();

View file

@ -4,7 +4,6 @@
#include <cstdint>
#include <iostream>
#include <iterator>
#include <sstream>
#include <string>
#include <vector>
#include <memory>
@ -162,19 +161,6 @@ namespace Helpers {
return std::bit_cast<To, From>(from);
}
#endif
static std::vector<std::string> split(const std::string& s, const char c) {
std::istringstream tmp(s);
std::vector<std::string> result(1);
while (std::getline(tmp, *result.rbegin(), c)) {
result.emplace_back();
}
// Remove temporary slot
result.pop_back();
return result;
}
}; // namespace Helpers
// UDLs for memory size values

View file

@ -29,9 +29,9 @@ namespace Renderdoc {
#else
namespace Renderdoc {
static void loadRenderdoc() {}
static void startCapture() { Helpers::panic("Tried to start a Renderdoc capture while support for renderdoc is disabled") }
static void endCapture() { Helpers::panic("Tried to end a Renderdoc capture while support for renderdoc is disabled") }
static void triggerCapture() { Helpers::panic("Tried to trigger a Renderdoc capture while support for renderdoc is disabled") }
static void startCapture() { Helpers::panic("Tried to start a Renderdoc capture while support for renderdoc is disabled"); }
static void endCapture() { Helpers::panic("Tried to end a Renderdoc capture while support for renderdoc is disabled"); }
static void triggerCapture() { Helpers::panic("Tried to trigger a Renderdoc capture while support for renderdoc is disabled"); }
static void setOutputDir(const std::string& path, const std::string& prefix) {}
static constexpr bool isSupported() { return false; }
} // namespace Renderdoc
@ -66,4 +66,4 @@ namespace Renderdoc {
InstantScope(InstantScope&&) = delete;
InstantScope& operator=(const InstantScope&&) = delete;
};
} // namespace Renderdoc
} // namespace Renderdoc

View file

@ -68,7 +68,7 @@ Simply drag and drop a ROM to the executable if supported, or invoke the executa
<br>
Panda3DS can load ROMs in the following formats:
- .3ds/.cci
- .cxi/.app
- .cxi/.app/.ncch
- .elf/.axf
- .3dsx

View file

@ -27,8 +27,8 @@ void MiniAudioDevice::init(Samples& samples, bool safe) {
// TODO: Make backend selectable here
found = true;
//count = 1;
//backends[0] = backend;
// count = 1;
// backends[0] = backend;
}
if (!found) {
@ -81,8 +81,8 @@ void MiniAudioDevice::init(Samples& samples, bool safe) {
deviceConfig.playback.format = ma_format_s16;
deviceConfig.playback.channels = channelCount;
deviceConfig.sampleRate = sampleRate;
//deviceConfig.periodSizeInFrames = 64;
//deviceConfig.periods = 16;
// deviceConfig.periodSizeInFrames = 64;
// deviceConfig.periods = 16;
deviceConfig.pUserData = this;
deviceConfig.aaudio.usage = ma_aaudio_usage_game;
deviceConfig.wasapi.noAutoConvertSRC = true;
@ -130,7 +130,7 @@ void MiniAudioDevice::start() {
void MiniAudioDevice::stop() {
if (!initialized) {
Helpers::warn("MiniAudio device not initialized, can't start");
Helpers::warn("MiniAudio device not initialized, can't stop");
return;
}
@ -139,6 +139,17 @@ void MiniAudioDevice::stop() {
if (ma_device_stop(&device) != MA_SUCCESS) {
Helpers::warn("Failed to stop audio device");
}
}
}
}
void MiniAudioDevice::close() {
stop();
if (initialized) {
initialized = false;
ma_device_uninit(&device);
ma_context_uninit(&context);
}
}

View file

@ -2,7 +2,10 @@
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
#include "helpers.hpp"
@ -15,6 +18,19 @@ namespace Crypto {
return;
}
auto splitString = [](const std::string& s, const char c) -> std::vector<std::string> {
std::istringstream tmp(s);
std::vector<std::string> result(1);
while (std::getline(tmp, *result.rbegin(), c)) {
result.emplace_back();
}
// Remove temporary slot
result.pop_back();
return result;
};
while (!file.eof()) {
std::string line;
std::getline(file, line);
@ -24,7 +40,7 @@ namespace Crypto {
continue;
}
const auto parts = Helpers::split(line, '=');
const auto parts = splitString(line, '=');
if (parts.size() != 2) {
Helpers::warn("Keys: Failed to parse %s", line.c_str());
continue;

View file

@ -50,6 +50,7 @@ Emulator::Emulator()
Emulator::~Emulator() {
config.save();
lua.close();
audioDevice.close();
#ifdef PANDA3DS_ENABLE_DISCORD_RPC
discordRpc.stop();
@ -249,7 +250,7 @@ bool Emulator::loadROM(const std::filesystem::path& path) {
success = loadELF(path);
else if (extension == ".3ds" || extension == ".cci")
success = loadNCSD(path, ROMType::NCSD);
else if (extension == ".cxi" || extension == ".app")
else if (extension == ".cxi" || extension == ".app" || extension == ".ncch")
success = loadNCSD(path, ROMType::CXI);
else if (extension == ".3dsx")
success = load3DSX(path);
@ -442,4 +443,4 @@ void Emulator::loadRenderdoc() {
std::string capturePath = (std::filesystem::current_path() / "RenderdocCaptures").generic_string();
Renderdoc::loadRenderdoc();
Renderdoc::setOutputDir(capturePath, "");
}
}

View file

@ -189,7 +189,7 @@ void MainWindow::swapEmuBuffer() {
void MainWindow::selectROM() {
auto path = QFileDialog::getOpenFileName(
this, tr("Select 3DS ROM to load"), QString::fromStdU16String(emu->getConfig().defaultRomPath.u16string()),
tr("Nintendo 3DS ROMs (*.3ds *.cci *.cxi *.app *.3dsx *.elf *.axf)")
tr("Nintendo 3DS ROMs (*.3ds *.cci *.cxi *.app *.ncch *.3dsx *.elf *.axf)")
);
if (!path.isEmpty()) {

1
third_party/cryptoppwin vendored Submodule

@ -0,0 +1 @@
Subproject commit bc3441dd2d6a9728e747dc0180bc8b9065a2923c