Skip to content

Commit

Permalink
Don't delay stat when using SifSetDmaCallback.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpd002 committed Oct 21, 2024
1 parent fd39628 commit 2b3882e
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Source/iop/Iop_SifCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ uint32 CSifCmd::SifSendCmd(uint32 commandId, uint32 packetPtr, uint32 packetSize
dmaReg->size = sizeExtra;
dmaReg->flags = 0;

m_sifMan.SifSetDma(m_sendCmdExtraStructAddr, 1);
m_sifMan.ExecuteSifDma(m_sendCmdExtraStructAddr, 1);
}

m_sifMan.SendPacket(packetData, packetSize);
Expand Down Expand Up @@ -904,7 +904,7 @@ void CSifCmd::SifCallRpc(CMIPS& context)
dmaReg->size = sendSize;
dmaReg->flags = 0;

m_sifMan.SifSetDma(m_sendCmdExtraStructAddr, 1);
m_sifMan.ExecuteSifDma(m_sendCmdExtraStructAddr, 1);
}

SIFRPCCALL callPacket;
Expand Down
10 changes: 8 additions & 2 deletions Source/iop/Iop_SifMan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

using namespace Iop;

constexpr uint32 SIFDMA_XFER_ID = 0x2222;

std::string CSifMan::GetId() const
{
return "sifman";
Expand Down Expand Up @@ -121,13 +123,16 @@ uint32 CSifMan::SifSetDma(uint32 structAddr, uint32 count)
//This is needed because RenderWare FS code doesn't expect SIF CMD callbacks to
//arrive so quickly
m_moduleData->dmaTransferTime = 0x800;
return count;

ExecuteSifDma(structAddr, count);
return SIFDMA_XFER_ID;
}

uint32 CSifMan::SifDmaStat(uint32 transferId)
{
CLog::GetInstance().Print(LOG_NAME, FUNCTION_SIFDMASTAT "(transferId = %X);\r\n",
transferId);
assert(transferId == SIFDMA_XFER_ID);
if(m_moduleData->dmaTransferTime != 0)
{
return 0;
Expand Down Expand Up @@ -155,5 +160,6 @@ uint32 CSifMan::SifSetDmaCallback(CMIPS& context, uint32 structAddr, uint32 coun
context.m_State.nGPR[CMIPS::A0].nV0 = callbackParam;
context.m_State.nGPR[CMIPS::A1].nV0 = callbackPtr;

return SifSetDma(structAddr, count);
ExecuteSifDma(structAddr, count);
return SIFDMA_XFER_ID;
}
4 changes: 2 additions & 2 deletions Source/iop/Iop_SifMan.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ namespace Iop
virtual void GetOtherData(uint32, uint32, uint32) = 0;
virtual void SetModuleResetHandler(const ModuleResetHandler&) = 0;
virtual void SetCustomCommandHandler(const CustomCommandHandler&) = 0;

virtual uint32 SifSetDma(uint32, uint32);
virtual void ExecuteSifDma(uint32, uint32) = 0;

private:
uint32 SifSetDma(uint32, uint32);
uint32 SifDmaStat(uint32);
uint32 SifCheckInit();
uint32 SifSetDmaCallback(CMIPS&, uint32, uint32, uint32, uint32);
Expand Down
4 changes: 4 additions & 0 deletions Source/iop/Iop_SifManNull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ void CSifManNull::SetModuleResetHandler(const ModuleResetHandler&)
void CSifManNull::SetCustomCommandHandler(const CustomCommandHandler&)
{
}

void CSifManNull::ExecuteSifDma(uint32, uint32)
{
}
1 change: 1 addition & 0 deletions Source/iop/Iop_SifManNull.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ namespace Iop
void GetOtherData(uint32, uint32, uint32) override;
void SetModuleResetHandler(const ModuleResetHandler&) override;
void SetCustomCommandHandler(const CustomCommandHandler&) override;
void ExecuteSifDma(uint32, uint32) override;
};
}
9 changes: 3 additions & 6 deletions Source/iop/Iop_SifManPs2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,12 @@ void CSifManPs2::SetCustomCommandHandler(const CustomCommandHandler& customComma
m_sif.SetCustomCommandHandler(customCommandHandler);
}

uint32 CSifManPs2::SifSetDma(uint32 structAddr, uint32 count)
void CSifManPs2::ExecuteSifDma(uint32 structAddr, uint32 count)
{
CSifMan::SifSetDma(structAddr, count);

if(structAddr == 0)
{
return 0;
//Nothing to transfer
return;
}

auto dmaRegs = reinterpret_cast<const SIFDMAREG*>(m_iopRam + structAddr);
Expand All @@ -89,8 +88,6 @@ uint32 CSifManPs2::SifSetDma(uint32 structAddr, uint32 count)
memcpy(dst, src, dmaReg.size);
}
}

return count;
}

uint8* CSifManPs2::GetEeRam() const
Expand Down
3 changes: 1 addition & 2 deletions Source/iop/Iop_SifManPs2.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ namespace Iop
void GetOtherData(uint32, uint32, uint32) override;
void SetModuleResetHandler(const ModuleResetHandler&) override;
void SetCustomCommandHandler(const CustomCommandHandler&) override;

uint32 SifSetDma(uint32, uint32) override;
void ExecuteSifDma(uint32, uint32) override;

uint8* GetEeRam() const;

Expand Down

0 comments on commit 2b3882e

Please sign in to comment.