From f3663fa018515eacccc95f2f04cb16cc7127073c Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Mon, 30 Sep 2019 01:13:56 +1000 Subject: [PATCH] GTE: Implement GPF instruction --- src/pse/gte.cpp | 24 ++++++++++++++++++++++++ src/pse/gte.h | 1 + 2 files changed, 25 insertions(+) diff --git a/src/pse/gte.cpp b/src/pse/gte.cpp index fb1390ccb..5a5788512 100644 --- a/src/pse/gte.cpp +++ b/src/pse/gte.cpp @@ -314,6 +314,10 @@ void Core::ExecuteInstruction(Instruction inst) Execute_RTPT(inst); break; + case 0x3D: + Execute_GPF(inst); + break; + case 0x3E: Execute_GPL(inst); break; @@ -847,4 +851,24 @@ void Core::Execute_GPL(Instruction inst) m_regs.FLAG.UpdateError(); } + +void Core::Execute_GPF(Instruction inst) +{ + m_regs.FLAG.Clear(); + + const u8 shift = inst.GetShift(); + const bool lm = inst.lm; + + // [MAC1,MAC2,MAC3] = [0,0,0] ;<--- for GPF only + // [MAC1,MAC2,MAC3] = (([IR1,IR2,IR3] * IR0) + [MAC1,MAC2,MAC3]) SAR (sf*12) + TruncateAndSetMACAndIR<1>(s64(s32(m_regs.IR1) * s32(m_regs.IR0)), shift, lm); + TruncateAndSetMACAndIR<2>(s64(s32(m_regs.IR2) * s32(m_regs.IR0)), shift, lm); + TruncateAndSetMACAndIR<3>(s64(s32(m_regs.IR3) * s32(m_regs.IR0)), shift, lm); + + // Color FIFO = [MAC1/16,MAC2/16,MAC3/16,CODE], [IR1,IR2,IR3] = [MAC1,MAC2,MAC3] + PushRGBFromMAC(); + + m_regs.FLAG.UpdateError(); +} + } // namespace GTE \ No newline at end of file diff --git a/src/pse/gte.h b/src/pse/gte.h index 009f91647..8bbc4021f 100644 --- a/src/pse/gte.h +++ b/src/pse/gte.h @@ -87,6 +87,7 @@ private: void Execute_DPCT(Instruction inst); void Execute_DPCL(Instruction inst); void Execute_GPL(Instruction inst); + void Execute_GPF(Instruction inst); Regs m_regs = {}; };