VRSQ + VNAND + fix "Paused" in window title

This commit is contained in:
Simone Coco
2022-10-05 17:21:03 +02:00
parent 4757cbb8ef
commit 89daa969eb
5 changed files with 46 additions and 7 deletions

View File

@@ -168,6 +168,7 @@ void Window::LoadROM(n64::Core& core, const std::string &path) {
void Window::Render(n64::Core& core) { void Window::Render(n64::Core& core) {
ImGui::PushFont(uiFont); ImGui::PushFont(uiFont);
static bool showSettings = false; static bool showSettings = false;
static std::string windowTitleCache = windowTitle;
bool showMainMenuBar = windowID == SDL_GetWindowID(SDL_GetMouseFocus()); bool showMainMenuBar = windowID == SDL_GetWindowID(SDL_GetMouseFocus());
if(showMainMenuBar) { if(showMainMenuBar) {
ImGui::BeginMainMenuBar(); ImGui::BeginMainMenuBar();
@@ -197,14 +198,12 @@ void Window::Render(n64::Core& core) {
} }
if (ImGui::MenuItem(core.pause ? "Resume" : "Pause", nullptr, false, core.romLoaded)) { if (ImGui::MenuItem(core.pause ? "Resume" : "Pause", nullptr, false, core.romLoaded)) {
core.TogglePause(); core.TogglePause();
std::string paused = "| Paused"; std::string paused = " | Paused";
if(core.pause) { if(core.pause) {
windowTitleCache = windowTitle;
windowTitle += paused; windowTitle += paused;
} else { } else {
auto pausedPos = windowTitle.find_first_of(paused); windowTitle = windowTitleCache;
if(pausedPos != std::string::npos) {
windowTitle.erase(pausedPos, paused.length());
}
} }
SDL_SetWindowTitle(window, windowTitle.c_str()); SDL_SetWindowTitle(window, windowTitle.c_str());
} }

View File

@@ -2,7 +2,6 @@
#include <ParallelRDPWrapper.hpp> #include <ParallelRDPWrapper.hpp>
#include <Window.hpp> #include <Window.hpp>
#include <algorithm> #include <algorithm>
#include <util.hpp>
namespace n64 { namespace n64 {
Core::Core() { Core::Core() {

View File

@@ -383,6 +383,7 @@ struct RSP {
void vadd(u32 instr); void vadd(u32 instr);
void vaddc(u32 instr); void vaddc(u32 instr);
void vand(u32 instr); void vand(u32 instr);
void vnand(u32 instr);
void vch(u32 instr); void vch(u32 instr);
void vcr(u32 instr); void vcr(u32 instr);
void vcl(u32 instr); void vcl(u32 instr);
@@ -402,6 +403,7 @@ struct RSP {
void vne(u32 instr); void vne(u32 instr);
void vge(u32 instr); void vge(u32 instr);
void vrcp(u32 instr); void vrcp(u32 instr);
void vrsq(u32 instr);
void vrcpl(u32 instr); void vrcpl(u32 instr);
void vrsql(u32 instr); void vrsql(u32 instr);
void vrcph(u32 instr); void vrcph(u32 instr);

View File

@@ -7,6 +7,7 @@
namespace n64 { namespace n64 {
inline void special(MI& mi, Registers& regs, RSP& rsp, u32 instr) { inline void special(MI& mi, Registers& regs, RSP& rsp, u32 instr) {
u8 mask = instr & 0x3f; u8 mask = instr & 0x3f;
//util::print("rsp special {:02X}\n", mask);
switch(mask) { switch(mask) {
case 0x00: case 0x00:
if(instr != 0) { if(instr != 0) {
@@ -45,6 +46,7 @@ inline void special(MI& mi, Registers& regs, RSP& rsp, u32 instr) {
inline void regimm(RSP& rsp, u32 instr) { inline void regimm(RSP& rsp, u32 instr) {
u8 mask = ((instr >> 16) & 0x1F); u8 mask = ((instr >> 16) & 0x1F);
//util::print("rsp regimm {:02X}\n", mask);
switch(mask) { switch(mask) {
case 0x00: rsp.b(instr, (s32)rsp.gpr[RS(instr)] < 0); break; case 0x00: rsp.b(instr, (s32)rsp.gpr[RS(instr)] < 0); break;
case 0x01: rsp.b(instr, (s32)rsp.gpr[RS(instr)] >= 0); break; case 0x01: rsp.b(instr, (s32)rsp.gpr[RS(instr)] >= 0); break;
@@ -56,6 +58,7 @@ inline void regimm(RSP& rsp, u32 instr) {
inline void lwc2(RSP& rsp, u32 instr) { inline void lwc2(RSP& rsp, u32 instr) {
u8 mask = (instr >> 11) & 0x1F; u8 mask = (instr >> 11) & 0x1F;
//util::print("lwc2 {:02X}\n", mask);
switch(mask) { switch(mask) {
case 0x01: rsp.lsv(instr); break; case 0x01: rsp.lsv(instr); break;
case 0x02: rsp.llv(instr); break; case 0x02: rsp.llv(instr); break;
@@ -71,6 +74,7 @@ inline void lwc2(RSP& rsp, u32 instr) {
inline void swc2(RSP& rsp, u32 instr) { inline void swc2(RSP& rsp, u32 instr) {
u8 mask = (instr >> 11) & 0x1F; u8 mask = (instr >> 11) & 0x1F;
//util::print("swc2 {:02X}\n", mask);
switch(mask) { switch(mask) {
case 0x00: rsp.sbv(instr); break; case 0x00: rsp.sbv(instr); break;
case 0x01: rsp.slv(instr); break; case 0x01: rsp.slv(instr); break;
@@ -87,15 +91,17 @@ inline void swc2(RSP& rsp, u32 instr) {
inline void cop2(RSP& rsp, u32 instr) { inline void cop2(RSP& rsp, u32 instr) {
u8 mask = instr & 0x3F; u8 mask = instr & 0x3F;
u8 mask_sub = (instr >> 21) & 0x1F; u8 mask_sub = (instr >> 21) & 0x1F;
//util::print("Cop2 {:02X}\n", mask);
switch(mask) { switch(mask) {
case 0x00: case 0x00:
//util::print("Cop2 sub {:02X}\n", mask_sub);
switch(mask_sub) { switch(mask_sub) {
case 0x00: rsp.mfc2(instr); break; case 0x00: rsp.mfc2(instr); break;
case 0x02: rsp.cfc2(instr); break; case 0x02: rsp.cfc2(instr); break;
case 0x04: rsp.mtc2(instr); break; case 0x04: rsp.mtc2(instr); break;
case 0x06: rsp.ctc2(instr); break; case 0x06: rsp.ctc2(instr); break;
case 0x10: case 0x1C: case 0x1E: case 0x10: case 0x1C: case 0x1E:
case 0x1F: case 0x14: rsp.vzero(instr); break; case 0x1F: case 0x14: break; //rsp.vzero(instr); break;
default: util::panic("Unhandled RSP COP2 sub ({:05b})\n", mask_sub); default: util::panic("Unhandled RSP COP2 sub ({:05b})\n", mask_sub);
} }
break; break;
@@ -123,6 +129,7 @@ inline void cop2(RSP& rsp, u32 instr) {
case 0x26: rsp.vcr(instr); break; case 0x26: rsp.vcr(instr); break;
case 0x27: rsp.vmrg(instr); break; case 0x27: rsp.vmrg(instr); break;
case 0x28: rsp.vand(instr); break; case 0x28: rsp.vand(instr); break;
case 0x29: rsp.vnand(instr); break;
case 0x2A: rsp.vnor(instr); break; case 0x2A: rsp.vnor(instr); break;
case 0x2C: rsp.vxor(instr); break; case 0x2C: rsp.vxor(instr); break;
case 0x2D: rsp.vxnor(instr); break; case 0x2D: rsp.vxnor(instr); break;
@@ -133,6 +140,7 @@ inline void cop2(RSP& rsp, u32 instr) {
break; break;
case 0x30: rsp.vrcp(instr); break; case 0x30: rsp.vrcp(instr); break;
case 0x33: rsp.vmov(instr); break; case 0x33: rsp.vmov(instr); break;
case 0x34: rsp.vrsq(instr); break;
default: util::panic("Unhandled RSP COP2 ({:06b})\n", mask); default: util::panic("Unhandled RSP COP2 ({:06b})\n", mask);
} }
} }
@@ -142,6 +150,7 @@ inline void cop0(Registers& regs, Mem& mem, u32 instr) {
MMIO& mmio = mem.mmio; MMIO& mmio = mem.mmio;
RSP& rsp = mmio.rsp; RSP& rsp = mmio.rsp;
RDP& rdp = mmio.rdp; RDP& rdp = mmio.rdp;
//util::print("Cop0 {:02X}\n", mask);
switch(mask) { switch(mask) {
case 0x00: rsp.mfc0(rdp, instr); break; case 0x00: rsp.mfc0(rdp, instr); break;
case 0x04: rsp.mtc0(regs, mem, instr); break; case 0x04: rsp.mtc0(regs, mem, instr); break;
@@ -154,6 +163,7 @@ void RSP::Exec(Registers &regs, Mem& mem, u32 instr) {
MMIO& mmio = mem.mmio; MMIO& mmio = mem.mmio;
RDP& rdp = mmio.rdp; RDP& rdp = mmio.rdp;
MI& mi = mmio.mi; MI& mi = mmio.mi;
//util::print("RSP {:02X}\n", mask);
switch(mask) { switch(mask) {
case 0x00: special(mi, regs, *this, instr); break; case 0x00: special(mi, regs, *this, instr); break;
case 0x01: regimm(*this, instr); break; case 0x01: regimm(*this, instr); break;

View File

@@ -1062,6 +1062,23 @@ void RSP::vrcp(u32 instr) {
} }
} }
void RSP::vrsq(u32 instr) {
VPR& vd = vpr[VD(instr)];
VPR& vt = vpr[VT(instr)];
VPR vte = GetVTE(vpr[VT(instr)], E2(instr));
int e = E2(instr) & 7;
int de = DE(instr) & 7;
s32 input = vt.selement[ELEMENT_INDEX(e)];
s32 result = rsq(input);
vd.element[ELEMENT_INDEX(de)] = result;
divOut = result >> 16;
divInLoaded = false;
for (int i = 0; i < 8; i++) {
acc.l.element[i] = vte.element[i];
}
}
void RSP::vrsql(u32 instr) { void RSP::vrsql(u32 instr) {
VPR& vd = vpr[VD(instr)]; VPR& vd = vpr[VD(instr)];
VPR& vt = vpr[VT(instr)]; VPR& vt = vpr[VT(instr)];
@@ -1209,6 +1226,18 @@ void RSP::vand(u32 instr) {
} }
} }
void RSP::vnand(u32 instr) {
int e = E2(instr);
VPR& vs = vpr[VS(instr)];
VPR& vd = vpr[VD(instr)];
VPR vte = GetVTE(vpr[VT(instr)], e);
for(int i = 0; i < 8; i++) {
acc.l.element[i] = ~(vte.element[i] & vs.element[i]);
vd.element[i] = acc.l.element[i];
}
}
void RSP::vnor(u32 instr) { void RSP::vnor(u32 instr) {
int e = E2(instr); int e = E2(instr);
VPR& vs = vpr[VS(instr)]; VPR& vs = vpr[VS(instr)];