Skip to content

Commit

Permalink
TEMP: Add some delay to SIF transfers from IOP.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpd002 committed Sep 10, 2024
1 parent 9752b30 commit 5619958
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions Source/iop/IopBios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1913,6 +1913,7 @@ uint64 CIopBios::ClockToMicroSec(uint64 clock)
void CIopBios::CountTicks(uint32 ticks)
{
CurrentTime() += ticks;
m_sifMan->CountTicks(ticks);
#ifdef _IOP_EMULATE_MODULES
m_cdvdman->CountTicks(ticks);
m_mcserv->CountTicks(ticks, m_sifMan.get());
Expand Down
16 changes: 15 additions & 1 deletion Source/iop/Iop_SifMan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,32 @@ void CSifMan::GenerateHandlers(uint8* ram, CSysmem& sysMem)
assert((assembler.GetProgramSize() * 4) <= handlerAllocSize);
}

void CSifMan::CountTicks(int32 ticks)
{
m_lastTransferDelay = std::max(0, m_lastTransferDelay - ticks);
}

uint32 CSifMan::SifSetDma(uint32 structAddr, uint32 count)
{
CLog::GetInstance().Print(LOG_NAME, FUNCTION_SIFSETDMA "(structAddr = 0x%08X, count = %d);\r\n",
structAddr, count);
assert(m_lastTransferDelay == 0);
m_lastTransferDelay = 0x800;
return count;
}

uint32 CSifMan::SifDmaStat(uint32 transferId)
{
CLog::GetInstance().Print(LOG_NAME, FUNCTION_SIFDMASTAT "(transferId = %X);\r\n",
transferId);
return -1;
if(m_lastTransferDelay != 0)
{
return 0;
}
else
{
return -1;
}
}

uint32 CSifMan::SifCheckInit()
Expand Down
2 changes: 2 additions & 0 deletions Source/iop/Iop_SifMan.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace Iop
virtual ~CSifMan() = default;

void GenerateHandlers(uint8*, CSysmem&);
void CountTicks(int32);

std::string GetId() const override;
std::string GetFunctionName(unsigned int) const override;
Expand All @@ -42,6 +43,7 @@ namespace Iop
virtual uint32 SifSetDmaCallback(CMIPS&, uint32, uint32, uint32, uint32);

uint32 m_sifSetDmaCallbackHandlerPtr;
int32 m_lastTransferDelay = 0;
};

typedef std::shared_ptr<CSifMan> SifManPtr;
Expand Down

0 comments on commit 5619958

Please sign in to comment.