Audio works

This commit is contained in:
SimoneN64
2024-01-22 18:37:02 +01:00
parent b358862314
commit 7caa8c25c5
12 changed files with 22 additions and 121 deletions

View File

@@ -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));

View File

@@ -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)

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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: