Fix Windows CI (linux still bork)
Update unarr Add new log options Minor improvements
This commit is contained in:
@@ -6,7 +6,7 @@ namespace n64 {
|
||||
#define AUDIO_SAMPLE_RATE 44100
|
||||
#define SYSTEM_SAMPLE_FORMAT AUDIO_F32SYS
|
||||
#define SYSTEM_SAMPLE_SIZE 4
|
||||
#define BYTES_PER_HALF_SECOND ((AUDIO_SAMPLE_RATE / 2) * SYSTEM_SAMPLE_SIZE)
|
||||
#define BYTES_PER_HALF_SECOND (((float)AUDIO_SAMPLE_RATE / 2) * SYSTEM_SAMPLE_SIZE)
|
||||
|
||||
static SDL_AudioStream* audioStream = nullptr;
|
||||
SDL_mutex* audioStreamMutex;
|
||||
@@ -70,7 +70,7 @@ void PushSample(float left, float volumeL, float right, float volumeR) {
|
||||
float adjustedR = right * volumeR;
|
||||
float samples[2]{ adjustedL, adjustedR };
|
||||
|
||||
int availableBytes = SDL_AudioStreamAvailable(audioStream);
|
||||
float availableBytes = SDL_AudioStreamAvailable(audioStream);
|
||||
if(availableBytes <= BYTES_PER_HALF_SECOND) {
|
||||
SDL_AudioStreamPut(audioStream, samples, 2 * sizeof(float));
|
||||
}
|
||||
|
||||
@@ -32,8 +32,6 @@ auto AI::Read(u32 addr) const -> u32 {
|
||||
return dmaLen[0];
|
||||
}
|
||||
|
||||
#define max(x, y) ((x) > (y) ? (x) : (y))
|
||||
|
||||
void AI::Write(Mem& mem, Registers& regs, u32 addr, u32 val) {
|
||||
switch(addr) {
|
||||
case 0x04500000:
|
||||
@@ -43,8 +41,8 @@ void AI::Write(Mem& mem, Registers& regs, u32 addr, u32 val) {
|
||||
break;
|
||||
case 0x04500004: {
|
||||
u32 len = (val & 0x3FFFF) & ~7;
|
||||
if((dmaCount < 2) && len) {
|
||||
// if(dmaCount == 0) InterruptRaise(mem.mmio.mi, regs, Interrupt::AI);
|
||||
if(dmaCount < 2) {
|
||||
if(dmaCount == 0) InterruptRaise(mem.mmio.mi, regs, Interrupt::AI);
|
||||
dmaLen[dmaCount] = len;
|
||||
dmaCount++;
|
||||
}
|
||||
@@ -58,7 +56,7 @@ void AI::Write(Mem& mem, Registers& regs, u32 addr, u32 val) {
|
||||
case 0x04500010: {
|
||||
u32 old_dac_freq = dac.freq;
|
||||
dacRate = val & 0x3FFF;
|
||||
dac.freq = max(1, N64_CPU_FREQ / 2 / (dacRate + 1)) * 1.037;
|
||||
dac.freq = std::max(1u, GetVideoFrequency(mem.IsROMPAL()) / (dacRate + 1));
|
||||
dac.period = N64_CPU_FREQ / dac.freq;
|
||||
if(old_dac_freq != dac.freq) {
|
||||
AdjustSampleRate(dac.freq);
|
||||
|
||||
@@ -122,7 +122,7 @@ void PI::Write(Mem& mem, Registers& regs, u32 addr, u32 val) {
|
||||
for (int i = 0; i < rdLen; i++) {
|
||||
mem.rom.cart[BYTE_ADDRESS(cartAddrInternal + i) & mem.rom.mask] = mem.mmio.rdp.rdram[BYTE_ADDRESS(dramAddrInternal + i) & RDRAM_DSIZE];
|
||||
}
|
||||
Util::debug("PI DMA from RDRAM to CARTRIDGE (size: {} B, {:08X} to {:08X})", len, dramAddr, cartAddr);
|
||||
Util::trace("PI DMA from RDRAM to CARTRIDGE (size: {} B, {:08X} to {:08X})", len, dramAddr, cartAddr);
|
||||
dmaBusy = true;
|
||||
ioBusy = true;
|
||||
scheduler.enqueueRelative(Event{PIAccessTiming(*this, PIGetDomain(cartAddr), len), OnDMAComplete<true>});
|
||||
@@ -140,7 +140,7 @@ void PI::Write(Mem& mem, Registers& regs, u32 addr, u32 val) {
|
||||
}
|
||||
dmaBusy = true;
|
||||
ioBusy = true;
|
||||
Util::debug("PI DMA from CARTRIDGE to RDRAM (size: {} B, {:08X} to {:08X})", len, cartAddr, dramAddr);
|
||||
Util::trace("PI DMA from CARTRIDGE to RDRAM (size: {} B, {:08X} to {:08X})", len, cartAddr, dramAddr);
|
||||
scheduler.enqueueRelative(Event{PIAccessTiming(*this, PIGetDomain(cartAddr), len), OnDMAComplete<false>});
|
||||
} break;
|
||||
case 0x04600010:
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <cic_nus_6105/n64_cic_nus_6105.hpp>
|
||||
#include <cassert>
|
||||
#include <Netplay.hpp>
|
||||
#include <PIF/Device.hpp>
|
||||
|
||||
#define MEMPAK_SIZE 32768
|
||||
|
||||
@@ -207,10 +206,7 @@ void PIF::ProcessCommands(Mem &mem) {
|
||||
break;
|
||||
case 7:
|
||||
switch(cmd[CMD_START]) {
|
||||
case 0: case 3:
|
||||
for(int i = 0; i < 8; i++) {
|
||||
res[i] = 0;
|
||||
}
|
||||
case 0: case 1: case 3:
|
||||
break;
|
||||
case 2: {
|
||||
auto now = std::time(nullptr);
|
||||
@@ -332,21 +328,11 @@ void PIF::EepromWrite(const u8* cmd, u8* res, const Mem& mem) {
|
||||
}
|
||||
|
||||
void PIF::UpdateController() {
|
||||
joybusDevices[channel].controller.a = players[channel].controller.a;
|
||||
joybusDevices[channel].controller.b = players[channel].controller.b;
|
||||
joybusDevices[channel].controller.z = players[channel].controller.z;
|
||||
joybusDevices[channel].controller.start = players[channel].controller.start;
|
||||
joybusDevices[channel].controller.dp_up = players[channel].controller.dp_up;
|
||||
joybusDevices[channel].controller.dp_down = players[channel].controller.dp_down;
|
||||
joybusDevices[channel].controller.dp_left = players[channel].controller.dp_left;
|
||||
joybusDevices[channel].controller.dp_right = players[channel].controller.dp_right;
|
||||
joybusDevices[channel].controller.joy_reset = players[channel].controller.joy_reset;
|
||||
joybusDevices[channel].controller.l = players[channel].controller.l;
|
||||
joybusDevices[channel].controller.r = players[channel].controller.r;
|
||||
joybusDevices[channel].controller.c_up = players[channel].controller.c_up;
|
||||
joybusDevices[channel].controller.c_down = players[channel].controller.c_down;
|
||||
joybusDevices[channel].controller.c_left = players[channel].controller.c_left;
|
||||
joybusDevices[channel].controller.c_right = players[channel].controller.c_right;
|
||||
if(Netplay::connected) {
|
||||
Util::panic("Netplay!!!");
|
||||
} else {
|
||||
PollController();
|
||||
}
|
||||
}
|
||||
|
||||
void PIF::DoPIFHLE(Mem& mem, Registers& regs, bool pal, CICType cicType) {
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace fs = std::filesystem;
|
||||
|
||||
namespace n64 {
|
||||
|
||||
enum AccessoryType {
|
||||
enum AccessoryType : u8 {
|
||||
ACCESSORY_NONE,
|
||||
ACCESSORY_MEMPACK,
|
||||
ACCESSORY_RUMBLE_PACK
|
||||
@@ -18,7 +18,7 @@ enum AccessoryType {
|
||||
|
||||
struct Controller {
|
||||
union {
|
||||
u8 byte1;
|
||||
u8 byte1{};
|
||||
struct {
|
||||
bool dp_right:1;
|
||||
bool dp_left:1;
|
||||
@@ -31,7 +31,7 @@ struct Controller {
|
||||
};
|
||||
};
|
||||
union {
|
||||
u8 byte2;
|
||||
u8 byte2{};
|
||||
struct {
|
||||
bool c_right:1;
|
||||
bool c_left:1;
|
||||
@@ -45,11 +45,21 @@ struct Controller {
|
||||
};
|
||||
s8 joy_x{};
|
||||
s8 joy_y{};
|
||||
|
||||
Controller() = default;
|
||||
Controller& operator=(u32 v) {
|
||||
joy_y = v & 0xff;
|
||||
joy_x = v >> 8;
|
||||
byte2 = v >> 16;
|
||||
byte1 = v >> 24;
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
static_assert(sizeof(Controller) == 4);
|
||||
|
||||
enum JoybusType {
|
||||
enum JoybusType : u8 {
|
||||
JOYBUS_NONE,
|
||||
JOYBUS_CONTROLLER,
|
||||
JOYBUS_DANCEPAD,
|
||||
@@ -66,8 +76,12 @@ struct JoybusDevice {
|
||||
AccessoryType accessoryType{};
|
||||
Controller controller{};
|
||||
|
||||
auto operator<<(const sf::Packet& packet) {
|
||||
JoybusDevice() = default;
|
||||
|
||||
explicit JoybusDevice(const u64& packet) {
|
||||
type = static_cast<JoybusType>(packet >> offsetof(JoybusDevice, type));
|
||||
accessoryType = static_cast<AccessoryType>((packet >> offsetof(JoybusDevice, accessoryType)) & 0xff);
|
||||
controller = packet >> offsetof(JoybusDevice, controller);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
#include <PIF.hpp>
|
||||
#include <MupenMovie.hpp>
|
||||
#include <PIF/Device.hpp>
|
||||
#include <Netplay.hpp>
|
||||
#include "log.hpp"
|
||||
#include <log.hpp>
|
||||
#include <SDL2/SDL_keyboard.h>
|
||||
|
||||
namespace n64 {
|
||||
JoybusDevice players[4]{};
|
||||
|
||||
void PIF::InitDevices(SaveType saveType) {
|
||||
for (int i = 0; i < 4; i++) { //TODO: make this configurable
|
||||
joybusDevices[i].type = JOYBUS_CONTROLLER;
|
||||
@@ -44,21 +41,21 @@ void PIF::PollController() {
|
||||
bool CLEFT = GET_AXIS(gamepad, SDL_CONTROLLER_AXIS_RIGHTX) <= -127;
|
||||
bool CRIGHT = GET_AXIS(gamepad, SDL_CONTROLLER_AXIS_RIGHTX) >= 127;
|
||||
|
||||
players[0].controller.a = A;
|
||||
players[0].controller.b = B;
|
||||
players[0].controller.z = Z;
|
||||
players[0].controller.start = START;
|
||||
players[0].controller.dp_up = DUP;
|
||||
players[0].controller.dp_down = DDOWN;
|
||||
players[0].controller.dp_left = DLEFT;
|
||||
players[0].controller.dp_right = DRIGHT;
|
||||
players[0].controller.joy_reset = L && R && START;
|
||||
players[0].controller.l = L;
|
||||
players[0].controller.r = R;
|
||||
players[0].controller.c_up = CUP;
|
||||
players[0].controller.c_down = CDOWN;
|
||||
players[0].controller.c_left = CLEFT;
|
||||
players[0].controller.c_right = CRIGHT;
|
||||
joybusDevices[channel].controller.a = A;
|
||||
joybusDevices[channel].controller.b = B;
|
||||
joybusDevices[channel].controller.z = Z;
|
||||
joybusDevices[channel].controller.start = START;
|
||||
joybusDevices[channel].controller.dp_up = DUP;
|
||||
joybusDevices[channel].controller.dp_down = DDOWN;
|
||||
joybusDevices[channel].controller.dp_left = DLEFT;
|
||||
joybusDevices[channel].controller.dp_right = DRIGHT;
|
||||
joybusDevices[channel].controller.joy_reset = L && R && START;
|
||||
joybusDevices[channel].controller.l = L;
|
||||
joybusDevices[channel].controller.r = R;
|
||||
joybusDevices[channel].controller.c_up = CUP;
|
||||
joybusDevices[channel].controller.c_down = CDOWN;
|
||||
joybusDevices[channel].controller.c_left = CLEFT;
|
||||
joybusDevices[channel].controller.c_right = CRIGHT;
|
||||
|
||||
float xclamped = GET_AXIS(gamepad, SDL_CONTROLLER_AXIS_LEFTX);
|
||||
if(xclamped < 0) {
|
||||
@@ -78,31 +75,31 @@ void PIF::PollController() {
|
||||
|
||||
yclamped *= 86;
|
||||
|
||||
players[0].controller.joy_x = xclamped;
|
||||
players[0].controller.joy_y = -yclamped;
|
||||
joybusDevices[channel].controller.joy_x = xclamped;
|
||||
joybusDevices[channel].controller.joy_y = -yclamped;
|
||||
|
||||
if (players[0].controller.joy_reset) {
|
||||
players[0].controller.start = false;
|
||||
players[0].controller.joy_x = 0;
|
||||
players[0].controller.joy_y = 0;
|
||||
if (joybusDevices[channel].controller.joy_reset) {
|
||||
joybusDevices[channel].controller.start = false;
|
||||
joybusDevices[channel].controller.joy_x = 0;
|
||||
joybusDevices[channel].controller.joy_y = 0;
|
||||
}
|
||||
} else {
|
||||
const uint8_t* state = SDL_GetKeyboardState(nullptr);
|
||||
players[0].controller.a = state[SDL_SCANCODE_X];
|
||||
players[0].controller.b = state[SDL_SCANCODE_C];
|
||||
players[0].controller.z = state[SDL_SCANCODE_Z];
|
||||
players[0].controller.start = state[SDL_SCANCODE_RETURN];
|
||||
players[0].controller.dp_up = state[SDL_SCANCODE_PAGEUP];
|
||||
players[0].controller.dp_down = state[SDL_SCANCODE_PAGEDOWN];
|
||||
players[0].controller.dp_left = state[SDL_SCANCODE_HOME];
|
||||
players[0].controller.dp_right = state[SDL_SCANCODE_END];
|
||||
players[0].controller.joy_reset = state[SDL_SCANCODE_RETURN] && state[SDL_SCANCODE_A] && state[SDL_SCANCODE_S];
|
||||
players[0].controller.l = state[SDL_SCANCODE_A];
|
||||
players[0].controller.r = state[SDL_SCANCODE_S];
|
||||
players[0].controller.c_up = state[SDL_SCANCODE_I];
|
||||
players[0].controller.c_down = state[SDL_SCANCODE_K];
|
||||
players[0].controller.c_left = state[SDL_SCANCODE_J];
|
||||
players[0].controller.c_right = state[SDL_SCANCODE_L];
|
||||
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];
|
||||
|
||||
s16 xaxis = 0, yaxis = 0;
|
||||
if (state[SDL_SCANCODE_LEFT]) {
|
||||
@@ -117,13 +114,13 @@ void PIF::PollController() {
|
||||
yaxis = 86;
|
||||
}
|
||||
|
||||
players[0].controller.joy_x = xaxis;
|
||||
players[0].controller.joy_y = yaxis;
|
||||
joybusDevices[channel].controller.joy_x = xaxis;
|
||||
joybusDevices[channel].controller.joy_y = yaxis;
|
||||
|
||||
if (players[0].controller.joy_reset) {
|
||||
players[0].controller.start = false;
|
||||
players[0].controller.joy_x = 0;
|
||||
players[0].controller.joy_y = 0;
|
||||
if (joybusDevices[channel].controller.joy_reset) {
|
||||
joybusDevices[channel].controller.start = false;
|
||||
joybusDevices[channel].controller.joy_x = 0;
|
||||
joybusDevices[channel].controller.joy_y = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace n64 {
|
||||
struct JoybusDevice;
|
||||
|
||||
extern JoybusDevice players[4];
|
||||
}
|
||||
Reference in New Issue
Block a user