From 2edab83ff318aa6fdc6727561898390ac5dc6e5c Mon Sep 17 00:00:00 2001 From: Ian Brown Date: Tue, 19 Dec 2023 19:37:44 +0000 Subject: [PATCH] Dead or Alive 2 fix --- Source/iop/IopBios.h | 1 + Source/iop/Iop_Intrman.cpp | 25 ++++++++++++++++++++----- patches.xml | 6 ++++++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Source/iop/IopBios.h b/Source/iop/IopBios.h index ae0fc84e4d..a343091535 100644 --- a/Source/iop/IopBios.h +++ b/Source/iop/IopBios.h @@ -39,6 +39,7 @@ class CIopBios : public Iop::CBiosBase KERNEL_RESULT_ERROR_ILLEGAL_CONTEXT = -100, KERNEL_RESULT_ERROR_ILLEGAL_INTRCODE = -101, KERNEL_RESULT_ERROR_CPUDI = -102, + KERNEL_RESULT_ERROR_INTRDISABLE = -103, KERNEL_RESULT_ERROR_FOUND_HANDLER = -104, KERNEL_RESULT_ERROR_NOTFOUND_HANDLER = -105, KERNEL_RESULT_ERROR_NO_TIMER = -150, diff --git a/Source/iop/Iop_Intrman.cpp b/Source/iop/Iop_Intrman.cpp index 6f3b0f0aaa..eb5afc1011 100644 --- a/Source/iop/Iop_Intrman.cpp +++ b/Source/iop/Iop_Intrman.cpp @@ -159,13 +159,28 @@ uint32 CIntrman::DisableIntrLine(CMIPS& context, uint32 line, uint32 res) CLog::GetInstance().Print(LOGNAME, FUNCTION_DISABLEINTRLINE "(line = %d, res = %08X);\r\n", line, res); #endif + uint32 ret = CIopBios::KERNEL_RESULT_OK; + uint32 stat = line; UNION64_32 mask( context.m_pMemoryMap->GetWord(CIntc::MASK0), context.m_pMemoryMap->GetWord(CIntc::MASK1)); - mask.f &= ~(1LL << line); - context.m_pMemoryMap->SetWord(CIntc::MASK0, mask.h0); - context.m_pMemoryMap->SetWord(CIntc::MASK1, mask.h1); - return 0; + if(mask.f & (1LL << line)) + { + mask.f &= ~(1LL << line); + context.m_pMemoryMap->SetWord(CIntc::MASK0, mask.h0); + context.m_pMemoryMap->SetWord(CIntc::MASK1, mask.h1); + } + else + { + ret = CIopBios::KERNEL_RESULT_ERROR_INTRDISABLE; + stat = CIopBios::KERNEL_RESULT_ERROR_INTRDISABLE; + } + if(res != 0) + { + uint32* state = reinterpret_cast(m_ram + res); + (*state) = stat; + } + return ret; } uint32 CIntrman::EnableInterrupts(CMIPS& context) @@ -210,7 +225,7 @@ uint32 CIntrman::SuspendInterrupts(CMIPS& context, uint32 statePtr) uint32 CIntrman::ResumeInterrupts(CMIPS& context, uint32 state) { #ifdef _DEBUG - CLog::GetInstance().Print(LOGNAME, FUNCTION_RESUMEINTERRUPTS "();\r\n"); + CLog::GetInstance().Print(LOGNAME, FUNCTION_RESUMEINTERRUPTS "(0x%x);\r\n", state); #endif uint32& statusRegister = context.m_State.nCOP0[CCOP_SCU::STATUS]; if(state) diff --git a/patches.xml b/patches.xml index 09313c9284..9a54f7401c 100644 --- a/patches.xml +++ b/patches.xml @@ -5,4 +5,10 @@ + + + + + +