Audio works
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#include <Core.hpp>
|
||||
#include <Scheduler.hpp>
|
||||
#include <ParallelRDPWrapper.hpp>
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
namespace n64 {
|
||||
u32 extraCycles = 0;
|
||||
@@ -16,13 +15,7 @@ u32 PopStalledCycles() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
Core::Core() {
|
||||
if(SDL_GameControllerAddMappingsFromFile("resources/gamecontrollerdb.txt") < 0) {
|
||||
Util::warn("Failed to load game controller DB");
|
||||
}
|
||||
|
||||
cpu = std::make_unique<Interpreter>();
|
||||
}
|
||||
Core::Core() : cpu(std::make_unique<Interpreter>()) {}
|
||||
|
||||
void Core::Stop() {
|
||||
render = false;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <Audio.hpp>
|
||||
#include <SDL2/SDL_audio.h>
|
||||
#include <log.hpp>
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
namespace n64 {
|
||||
#define AUDIO_SAMPLE_RATE 44100
|
||||
@@ -38,6 +38,7 @@ void audioCallback(void*, Uint8* stream, int length) {
|
||||
}
|
||||
|
||||
void InitAudio() {
|
||||
SDL_InitSubSystem(SDL_INIT_AUDIO);
|
||||
AdjustSampleRate(AUDIO_SAMPLE_RATE);
|
||||
memset(&request, 0, sizeof(request));
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
file(GLOB_RECURSE SOURCES *.cpp)
|
||||
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/registers/Registers.hpp>
|
||||
#include <log.hpp>
|
||||
#include <SDL_keyboard.h>
|
||||
#include <cic_nus_6105/n64_cic_nus_6105.hpp>
|
||||
#include <cassert>
|
||||
#include <Netplay.hpp>
|
||||
@@ -335,46 +334,7 @@ void PIF::EepromWrite(const u8* cmd, u8* res, const Mem& mem) {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -104,7 +104,7 @@ enum CICType {
|
||||
};
|
||||
|
||||
struct PIF {
|
||||
PIF() : inputMap(inputManager) {}
|
||||
PIF() = default;
|
||||
~PIF() = default;
|
||||
void Reset();
|
||||
void MaybeLoadMempak();
|
||||
@@ -124,9 +124,6 @@ struct PIF {
|
||||
std::vector<u8> Serialize();
|
||||
|
||||
bool gamepadConnected = false, mempakOpen = false;
|
||||
gainput::InputManager inputManager;
|
||||
gainput::InputMap inputMap;
|
||||
gainput::DeviceId keyboardId, padId;
|
||||
JoybusDevice joybusDevices[6]{};
|
||||
u8 bootrom[PIF_BOOTROM_SIZE]{}, ram[PIF_RAM_SIZE]{};
|
||||
mio::mmap_sink mempak, eeprom;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <PIF/MupenMovie.hpp>
|
||||
#include <Netplay.hpp>
|
||||
#include <log.hpp>
|
||||
#include <SDL2/SDL_keyboard.h>
|
||||
|
||||
namespace n64 {
|
||||
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>) {
|
||||
u32 c = 0x7FBFFFFF;
|
||||
magic = U32_TO_F(c);
|
||||
min = FLT_MIN;
|
||||
min = std::numeric_limits<float>::min();
|
||||
} else if constexpr(std::is_same_v<T, double>) {
|
||||
u64 c = 0x7FF7FFFFFFFFFFFF;
|
||||
magic = U64_TO_D(c);
|
||||
min = DBL_MIN;
|
||||
min = std::numeric_limits<double>::min();
|
||||
}
|
||||
switch (fp_class) {
|
||||
case FP_NAN:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <ParallelRDPWrapper.hpp>
|
||||
#include <EmuThread.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
|
||||
: 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 {
|
||||
LoadWSIPlatform(instance.get(), std::move(wsiPlatform), std::move(windowInfo));
|
||||
LoadParallelRDP(core->cpu->mem.GetRDRAM());
|
||||
n64::InitAudio();
|
||||
while (true) {
|
||||
if (!core->pause) {
|
||||
core->Run(0.5, 0.5);
|
||||
if(core->render) {
|
||||
UpdateScreenParallelRdp(*core, core->cpu->mem.mmio.vi);
|
||||
UpdateScreenParallelRdp(core->cpu->mem.mmio.vi);
|
||||
}
|
||||
} else {
|
||||
if(core->render) {
|
||||
UpdateScreenParallelRdpNoGame(*core);
|
||||
UpdateScreenParallelRdpNoGame();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <QApplication>
|
||||
#include <QDropEvent>
|
||||
#include <QMimeData>
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
KaizenQt::KaizenQt() noexcept : QWidget(nullptr) {
|
||||
mainWindow = new MainWindowController();
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <QMessageBox>
|
||||
#include <QKeyEvent>
|
||||
#include <MainWindow.hpp>
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
MainWindowController::MainWindowController() noexcept {
|
||||
view.setupUi(this);
|
||||
|
||||
Reference in New Issue
Block a user