Audio works
This commit is contained in:
54
external/parallel-rdp/ParallelRDPWrapper.cpp
vendored
54
external/parallel-rdp/ParallelRDPWrapper.cpp
vendored
@@ -1,10 +1,7 @@
|
|||||||
#include <ParallelRDPWrapper.hpp>
|
#include <ParallelRDPWrapper.hpp>
|
||||||
#include <core/RDP.hpp>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <rdp_device.hpp>
|
#include <rdp_device.hpp>
|
||||||
#include <log.hpp>
|
|
||||||
#include <File.hpp>
|
#include <File.hpp>
|
||||||
#include <imgui_impl_vulkan.h>
|
|
||||||
|
|
||||||
using namespace Vulkan;
|
using namespace Vulkan;
|
||||||
using namespace RDP;
|
using namespace RDP;
|
||||||
@@ -12,47 +9,6 @@ using namespace RDP;
|
|||||||
static CommandProcessor* command_processor;
|
static CommandProcessor* command_processor;
|
||||||
static std::unique_ptr<ParallelRdpWindowInfo> windowInfo;
|
static std::unique_ptr<ParallelRdpWindowInfo> windowInfo;
|
||||||
|
|
||||||
VkQueue GetGraphicsQueue() {
|
|
||||||
return wsi->get_context().get_queue_info().queues[QUEUE_INDEX_GRAPHICS];
|
|
||||||
}
|
|
||||||
|
|
||||||
VkInstance GetVkInstance() {
|
|
||||||
return wsi->get_context().get_instance();
|
|
||||||
}
|
|
||||||
|
|
||||||
VkPhysicalDevice GetVkPhysicalDevice() {
|
|
||||||
return wsi->get_device().get_physical_device();
|
|
||||||
}
|
|
||||||
|
|
||||||
VkDevice GetVkDevice() {
|
|
||||||
return wsi->get_device().get_device();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t GetVkGraphicsQueueFamily() {
|
|
||||||
return wsi->get_context().get_queue_info().family_indices[QUEUE_INDEX_GRAPHICS];
|
|
||||||
}
|
|
||||||
|
|
||||||
VkFormat GetVkFormat() {
|
|
||||||
return wsi->get_device().get_swapchain_view().get_format();
|
|
||||||
}
|
|
||||||
|
|
||||||
CommandBufferHandle requested_command_buffer;
|
|
||||||
|
|
||||||
VkRenderPass GetVkRenderPass() {
|
|
||||||
return wsi->get_device().request_render_pass(
|
|
||||||
wsi->get_device().get_swapchain_render_pass(SwapchainRenderPass::ColorOnly), true
|
|
||||||
).get_render_pass();
|
|
||||||
}
|
|
||||||
|
|
||||||
VkCommandBuffer GetVkCommandBuffer() {
|
|
||||||
requested_command_buffer = wsi->get_device().request_command_buffer();
|
|
||||||
return requested_command_buffer->get_command_buffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SubmitRequestedVkCommandBuffer() {
|
|
||||||
wsi->get_device().submit(requested_command_buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsFramerateUnlocked() {
|
bool IsFramerateUnlocked() {
|
||||||
return wsi->get_present_mode() != PresentMode::SyncToVBlank;
|
return wsi->get_present_mode() != PresentMode::SyncToVBlank;
|
||||||
}
|
}
|
||||||
@@ -162,7 +118,7 @@ void DrawFullscreenTexturedQuad(Util::IntrusivePtr<Image> image, Util::Intrusive
|
|||||||
cmd->draw(3, 1);
|
cmd->draw(3, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateScreen(n64::Core& core, Util::IntrusivePtr<Image> image) {
|
void UpdateScreen(Util::IntrusivePtr<Image> image) {
|
||||||
wsi->begin_frame();
|
wsi->begin_frame();
|
||||||
|
|
||||||
if (!image) {
|
if (!image) {
|
||||||
@@ -197,7 +153,7 @@ void UpdateScreen(n64::Core& core, Util::IntrusivePtr<Image> image) {
|
|||||||
wsi->end_frame();
|
wsi->end_frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateScreenParallelRdp(n64::Core& core, n64::VI& vi) {
|
void UpdateScreenParallelRdp(n64::VI& vi) {
|
||||||
command_processor->set_vi_register(VIRegister::Control, vi.status.raw);
|
command_processor->set_vi_register(VIRegister::Control, vi.status.raw);
|
||||||
command_processor->set_vi_register(VIRegister::Origin, vi.origin);
|
command_processor->set_vi_register(VIRegister::Origin, vi.origin);
|
||||||
command_processor->set_vi_register(VIRegister::Width, vi.width);
|
command_processor->set_vi_register(VIRegister::Width, vi.width);
|
||||||
@@ -223,12 +179,12 @@ void UpdateScreenParallelRdp(n64::Core& core, n64::VI& vi) {
|
|||||||
opts.downscale_steps = true;
|
opts.downscale_steps = true;
|
||||||
opts.crop_overscan_pixels = true;
|
opts.crop_overscan_pixels = true;
|
||||||
Util::IntrusivePtr<Image> image = command_processor->scanout(opts);
|
Util::IntrusivePtr<Image> image = command_processor->scanout(opts);
|
||||||
UpdateScreen(core, image);
|
UpdateScreen(image);
|
||||||
command_processor->begin_frame_context();
|
command_processor->begin_frame_context();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateScreenParallelRdpNoGame(n64::Core& core) {
|
void UpdateScreenParallelRdpNoGame() {
|
||||||
UpdateScreen(core, static_cast<Util::IntrusivePtr<Image>>(nullptr));
|
UpdateScreen(static_cast<Util::IntrusivePtr<Image>>(nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParallelRdpEnqueueCommand(int command_length, u32* buffer) {
|
void ParallelRdpEnqueueCommand(int command_length, u32* buffer) {
|
||||||
|
|||||||
13
external/parallel-rdp/ParallelRDPWrapper.hpp
vendored
13
external/parallel-rdp/ParallelRDPWrapper.hpp
vendored
@@ -14,20 +14,11 @@ public:
|
|||||||
|
|
||||||
static Vulkan::WSI* wsi;
|
static Vulkan::WSI* wsi;
|
||||||
|
|
||||||
VkRenderPass GetVkRenderPass();
|
|
||||||
VkQueue GetGraphicsQueue();
|
|
||||||
VkInstance GetVkInstance();
|
|
||||||
VkPhysicalDevice GetVkPhysicalDevice();
|
|
||||||
VkDevice GetVkDevice();
|
|
||||||
uint32_t GetVkGraphicsQueueFamily();
|
|
||||||
VkFormat GetVkFormat();
|
|
||||||
VkCommandBuffer GetVkCommandBuffer();
|
|
||||||
void SubmitRequestedVkCommandBuffer();
|
|
||||||
void LoadParallelRDP(const u8* rdram);
|
void LoadParallelRDP(const u8* rdram);
|
||||||
Vulkan::WSI* LoadWSIPlatform(Vulkan::InstanceFactory*, std::unique_ptr<Vulkan::WSIPlatform>&& wsi_platform, std::unique_ptr<ParallelRdpWindowInfo>&& newWindowInfo);
|
Vulkan::WSI* LoadWSIPlatform(Vulkan::InstanceFactory*, std::unique_ptr<Vulkan::WSIPlatform>&& wsi_platform, std::unique_ptr<ParallelRdpWindowInfo>&& newWindowInfo);
|
||||||
void UpdateScreenParallelRdp(n64::Core& core, n64::VI& vi);
|
void UpdateScreenParallelRdp(n64::VI& vi);
|
||||||
void ParallelRdpEnqueueCommand(int command_length, u32* buffer);
|
void ParallelRdpEnqueueCommand(int command_length, u32* buffer);
|
||||||
void ParallelRdpOnFullSync();
|
void ParallelRdpOnFullSync();
|
||||||
void UpdateScreenParallelRdpNoGame(n64::Core& core);
|
void UpdateScreenParallelRdpNoGame();
|
||||||
bool IsFramerateUnlocked();
|
bool IsFramerateUnlocked();
|
||||||
void SetFramerateUnlocked(bool unlocked);
|
void SetFramerateUnlocked(bool unlocked);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#include <Core.hpp>
|
#include <Core.hpp>
|
||||||
#include <Scheduler.hpp>
|
#include <Scheduler.hpp>
|
||||||
#include <ParallelRDPWrapper.hpp>
|
#include <ParallelRDPWrapper.hpp>
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
|
|
||||||
namespace n64 {
|
namespace n64 {
|
||||||
u32 extraCycles = 0;
|
u32 extraCycles = 0;
|
||||||
@@ -16,13 +15,7 @@ u32 PopStalledCycles() {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::Core() {
|
Core::Core() : cpu(std::make_unique<Interpreter>()) {}
|
||||||
if(SDL_GameControllerAddMappingsFromFile("resources/gamecontrollerdb.txt") < 0) {
|
|
||||||
Util::warn("Failed to load game controller DB");
|
|
||||||
}
|
|
||||||
|
|
||||||
cpu = std::make_unique<Interpreter>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Core::Stop() {
|
void Core::Stop() {
|
||||||
render = false;
|
render = false;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <Audio.hpp>
|
#include <Audio.hpp>
|
||||||
#include <SDL2/SDL_audio.h>
|
|
||||||
#include <log.hpp>
|
#include <log.hpp>
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
namespace n64 {
|
namespace n64 {
|
||||||
#define AUDIO_SAMPLE_RATE 44100
|
#define AUDIO_SAMPLE_RATE 44100
|
||||||
@@ -38,6 +38,7 @@ void audioCallback(void*, Uint8* stream, int length) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InitAudio() {
|
void InitAudio() {
|
||||||
|
SDL_InitSubSystem(SDL_INIT_AUDIO);
|
||||||
AdjustSampleRate(AUDIO_SAMPLE_RATE);
|
AdjustSampleRate(AUDIO_SAMPLE_RATE);
|
||||||
memset(&request, 0, sizeof(request));
|
memset(&request, 0, sizeof(request));
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
file(GLOB_RECURSE SOURCES *.cpp)
|
file(GLOB_RECURSE SOURCES *.cpp)
|
||||||
file(GLOB_RECURSE HEADERS *.hpp)
|
file(GLOB_RECURSE HEADERS *.hpp)
|
||||||
|
|
||||||
add_library(mmio ${SOURCES} ${HEADERS} ../../../../external/cic_nus_6105/n64_cic_nus_6105.cpp)
|
find_package(SDL2 REQUIRED)
|
||||||
|
|
||||||
|
add_library(mmio ${SOURCES} ${HEADERS} ../../../../external/cic_nus_6105/n64_cic_nus_6105.cpp)
|
||||||
|
|
||||||
|
target_link_libraries(mmio PRIVATE SDL2::SDL2)
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
#include <core/Mem.hpp>
|
#include <core/Mem.hpp>
|
||||||
#include <core/registers/Registers.hpp>
|
#include <core/registers/Registers.hpp>
|
||||||
#include <log.hpp>
|
#include <log.hpp>
|
||||||
#include <SDL_keyboard.h>
|
|
||||||
#include <cic_nus_6105/n64_cic_nus_6105.hpp>
|
#include <cic_nus_6105/n64_cic_nus_6105.hpp>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <Netplay.hpp>
|
#include <Netplay.hpp>
|
||||||
@@ -335,46 +334,7 @@ void PIF::EepromWrite(const u8* cmd, u8* res, const Mem& mem) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PIF::UpdateController() {
|
void PIF::UpdateController() {
|
||||||
const uint8_t* state = SDL_GetKeyboardState(nullptr);
|
|
||||||
joybusDevices[channel].controller.a = state[SDL_SCANCODE_X];
|
|
||||||
joybusDevices[channel].controller.b = state[SDL_SCANCODE_C];
|
|
||||||
joybusDevices[channel].controller.z = state[SDL_SCANCODE_Z];
|
|
||||||
joybusDevices[channel].controller.start = state[SDL_SCANCODE_RETURN];
|
|
||||||
joybusDevices[channel].controller.dp_up = state[SDL_SCANCODE_PAGEUP];
|
|
||||||
joybusDevices[channel].controller.dp_down = state[SDL_SCANCODE_PAGEDOWN];
|
|
||||||
joybusDevices[channel].controller.dp_left = state[SDL_SCANCODE_HOME];
|
|
||||||
joybusDevices[channel].controller.dp_right = state[SDL_SCANCODE_END];
|
|
||||||
joybusDevices[channel].controller.joy_reset = state[SDL_SCANCODE_RETURN] && state[SDL_SCANCODE_A] && state[SDL_SCANCODE_S];
|
|
||||||
joybusDevices[channel].controller.l = state[SDL_SCANCODE_A];
|
|
||||||
joybusDevices[channel].controller.r = state[SDL_SCANCODE_S];
|
|
||||||
joybusDevices[channel].controller.c_up = state[SDL_SCANCODE_I];
|
|
||||||
joybusDevices[channel].controller.c_down = state[SDL_SCANCODE_K];
|
|
||||||
joybusDevices[channel].controller.c_left = state[SDL_SCANCODE_J];
|
|
||||||
joybusDevices[channel].controller.c_right = state[SDL_SCANCODE_L];
|
|
||||||
|
|
||||||
s8 xaxis = 0, yaxis = 0;
|
|
||||||
if (state[SDL_SCANCODE_LEFT]) {
|
|
||||||
xaxis = -86;
|
|
||||||
}
|
|
||||||
else if (state[SDL_SCANCODE_RIGHT]) {
|
|
||||||
xaxis = 86;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state[SDL_SCANCODE_DOWN]) {
|
|
||||||
yaxis = -86;
|
|
||||||
}
|
|
||||||
else if (state[SDL_SCANCODE_UP]) {
|
|
||||||
yaxis = 86;
|
|
||||||
}
|
|
||||||
|
|
||||||
joybusDevices[channel].controller.joy_x = xaxis;
|
|
||||||
joybusDevices[channel].controller.joy_y = yaxis;
|
|
||||||
|
|
||||||
if (joybusDevices[channel].controller.joy_reset) {
|
|
||||||
joybusDevices[channel].controller.start = false;
|
|
||||||
joybusDevices[channel].controller.joy_x = 0;
|
|
||||||
joybusDevices[channel].controller.joy_y = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PIF::DoPIFHLE(Mem& mem, Registers& regs, bool pal, CICType cicType) {
|
void PIF::DoPIFHLE(Mem& mem, Registers& regs, bool pal, CICType cicType) {
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ enum CICType {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct PIF {
|
struct PIF {
|
||||||
PIF() : inputMap(inputManager) {}
|
PIF() = default;
|
||||||
~PIF() = default;
|
~PIF() = default;
|
||||||
void Reset();
|
void Reset();
|
||||||
void MaybeLoadMempak();
|
void MaybeLoadMempak();
|
||||||
@@ -124,9 +124,6 @@ struct PIF {
|
|||||||
std::vector<u8> Serialize();
|
std::vector<u8> Serialize();
|
||||||
|
|
||||||
bool gamepadConnected = false, mempakOpen = false;
|
bool gamepadConnected = false, mempakOpen = false;
|
||||||
gainput::InputManager inputManager;
|
|
||||||
gainput::InputMap inputMap;
|
|
||||||
gainput::DeviceId keyboardId, padId;
|
|
||||||
JoybusDevice joybusDevices[6]{};
|
JoybusDevice joybusDevices[6]{};
|
||||||
u8 bootrom[PIF_BOOTROM_SIZE]{}, ram[PIF_RAM_SIZE]{};
|
u8 bootrom[PIF_BOOTROM_SIZE]{}, ram[PIF_RAM_SIZE]{};
|
||||||
mio::mmap_sink mempak, eeprom;
|
mio::mmap_sink mempak, eeprom;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
#include <PIF/MupenMovie.hpp>
|
#include <PIF/MupenMovie.hpp>
|
||||||
#include <Netplay.hpp>
|
#include <Netplay.hpp>
|
||||||
#include <log.hpp>
|
#include <log.hpp>
|
||||||
#include <SDL2/SDL_keyboard.h>
|
|
||||||
|
|
||||||
namespace n64 {
|
namespace n64 {
|
||||||
void PIF::InitDevices(SaveType saveType) {
|
void PIF::InitDevices(SaveType saveType) {
|
||||||
|
|||||||
@@ -278,11 +278,11 @@ FORCE_INLINE void SetCauseOnResult(Registers& regs, T& d) {
|
|||||||
if constexpr(std::is_same_v<T, float>) {
|
if constexpr(std::is_same_v<T, float>) {
|
||||||
u32 c = 0x7FBFFFFF;
|
u32 c = 0x7FBFFFFF;
|
||||||
magic = U32_TO_F(c);
|
magic = U32_TO_F(c);
|
||||||
min = FLT_MIN;
|
min = std::numeric_limits<float>::min();
|
||||||
} else if constexpr(std::is_same_v<T, double>) {
|
} else if constexpr(std::is_same_v<T, double>) {
|
||||||
u64 c = 0x7FF7FFFFFFFFFFFF;
|
u64 c = 0x7FF7FFFFFFFFFFFF;
|
||||||
magic = U64_TO_D(c);
|
magic = U64_TO_D(c);
|
||||||
min = DBL_MIN;
|
min = std::numeric_limits<double>::min();
|
||||||
}
|
}
|
||||||
switch (fp_class) {
|
switch (fp_class) {
|
||||||
case FP_NAN:
|
case FP_NAN:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <ParallelRDPWrapper.hpp>
|
#include <ParallelRDPWrapper.hpp>
|
||||||
#include <EmuThread.hpp>
|
#include <EmuThread.hpp>
|
||||||
#include <RenderWidget.hpp>
|
#include <RenderWidget.hpp>
|
||||||
|
#include "Audio.hpp"
|
||||||
|
|
||||||
EmuThread::EmuThread(std::unique_ptr<QtInstanceFactory>&& instance, std::unique_ptr<Vulkan::WSIPlatform>&& wsiPlatform, std::unique_ptr<ParallelRdpWindowInfo>&& windowInfo, QObject* parent_object) noexcept
|
EmuThread::EmuThread(std::unique_ptr<QtInstanceFactory>&& instance, std::unique_ptr<Vulkan::WSIPlatform>&& wsiPlatform, std::unique_ptr<ParallelRdpWindowInfo>&& windowInfo, QObject* parent_object) noexcept
|
||||||
: QThread(parent_object), instance(std::move(instance)), wsiPlatform(std::move(wsiPlatform)), windowInfo(std::move(windowInfo)) {}
|
: QThread(parent_object), instance(std::move(instance)), wsiPlatform(std::move(wsiPlatform)), windowInfo(std::move(windowInfo)) {}
|
||||||
@@ -8,15 +9,16 @@ EmuThread::EmuThread(std::unique_ptr<QtInstanceFactory>&& instance, std::unique_
|
|||||||
[[noreturn]] void EmuThread::run() noexcept {
|
[[noreturn]] void EmuThread::run() noexcept {
|
||||||
LoadWSIPlatform(instance.get(), std::move(wsiPlatform), std::move(windowInfo));
|
LoadWSIPlatform(instance.get(), std::move(wsiPlatform), std::move(windowInfo));
|
||||||
LoadParallelRDP(core->cpu->mem.GetRDRAM());
|
LoadParallelRDP(core->cpu->mem.GetRDRAM());
|
||||||
|
n64::InitAudio();
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!core->pause) {
|
if (!core->pause) {
|
||||||
core->Run(0.5, 0.5);
|
core->Run(0.5, 0.5);
|
||||||
if(core->render) {
|
if(core->render) {
|
||||||
UpdateScreenParallelRdp(*core, core->cpu->mem.mmio.vi);
|
UpdateScreenParallelRdp(core->cpu->mem.mmio.vi);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(core->render) {
|
if(core->render) {
|
||||||
UpdateScreenParallelRdpNoGame(*core);
|
UpdateScreenParallelRdpNoGame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDropEvent>
|
#include <QDropEvent>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
|
|
||||||
KaizenQt::KaizenQt() noexcept : QWidget(nullptr) {
|
KaizenQt::KaizenQt() noexcept : QWidget(nullptr) {
|
||||||
mainWindow = new MainWindowController();
|
mainWindow = new MainWindowController();
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <MainWindow.hpp>
|
#include <MainWindow.hpp>
|
||||||
#include <SDL2/SDL.h>
|
|
||||||
|
|
||||||
MainWindowController::MainWindowController() noexcept {
|
MainWindowController::MainWindowController() noexcept {
|
||||||
view.setupUi(this);
|
view.setupUi(this);
|
||||||
|
|||||||
Reference in New Issue
Block a user