2012-06-30 02:31:22 +00:00
|
|
|
#include "Iop_Thmsgbx.h"
|
|
|
|
#include "IopBios.h"
|
2025-03-11 12:48:26 -04:00
|
|
|
#include "Log.h"
|
2012-06-30 02:31:22 +00:00
|
|
|
|
|
|
|
#define LOG_NAME ("iop_thmsgbx")
|
|
|
|
|
|
|
|
using namespace Iop;
|
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
#define FUNCTION_CREATEMBX "CreateMbx"
|
|
|
|
#define FUNCTION_DELETEMBX "DeleteMbx"
|
|
|
|
#define FUNCTION_SENDMBX "SendMbx"
|
|
|
|
#define FUNCTION_ISENDMBX "iSendMbx"
|
|
|
|
#define FUNCTION_RECEIVEMBX "ReceiveMbx"
|
|
|
|
#define FUNCTION_POLLMBX "PollMbx"
|
|
|
|
#define FUNCTION_REFERMBXSTATUS "ReferMbxStatus"
|
2012-06-30 02:31:22 +00:00
|
|
|
|
|
|
|
CThmsgbx::CThmsgbx(CIopBios& bios, uint8* ram)
|
2018-04-30 21:01:23 +01:00
|
|
|
: m_bios(bios)
|
|
|
|
, m_ram(ram)
|
2012-06-30 02:31:22 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CThmsgbx::~CThmsgbx()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string CThmsgbx::GetId() const
|
|
|
|
{
|
|
|
|
return "thmsgbx";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string CThmsgbx::GetFunctionName(unsigned int functionId) const
|
|
|
|
{
|
|
|
|
switch(functionId)
|
|
|
|
{
|
|
|
|
case 4:
|
|
|
|
return FUNCTION_CREATEMBX;
|
|
|
|
break;
|
2015-11-01 16:21:07 -05:00
|
|
|
case 5:
|
|
|
|
return FUNCTION_DELETEMBX;
|
|
|
|
break;
|
2012-06-30 02:31:22 +00:00
|
|
|
case 6:
|
|
|
|
return FUNCTION_SENDMBX;
|
|
|
|
break;
|
2016-10-20 21:09:41 -04:00
|
|
|
case 7:
|
|
|
|
return FUNCTION_ISENDMBX;
|
|
|
|
break;
|
2012-06-30 02:31:22 +00:00
|
|
|
case 8:
|
|
|
|
return FUNCTION_RECEIVEMBX;
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
return FUNCTION_POLLMBX;
|
|
|
|
break;
|
2015-11-01 23:43:25 -05:00
|
|
|
case 11:
|
|
|
|
return FUNCTION_REFERMBXSTATUS;
|
|
|
|
break;
|
2012-06-30 02:31:22 +00:00
|
|
|
default:
|
|
|
|
return "unknown";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CThmsgbx::Invoke(CMIPS& context, unsigned int functionId)
|
|
|
|
{
|
|
|
|
switch(functionId)
|
|
|
|
{
|
|
|
|
case 4:
|
|
|
|
context.m_State.nGPR[CMIPS::V0].nV0 = CreateMbx(
|
2018-04-30 21:01:23 +01:00
|
|
|
reinterpret_cast<MSGBX*>(&m_ram[context.m_State.nGPR[CMIPS::A0].nV0]));
|
2012-06-30 02:31:22 +00:00
|
|
|
break;
|
2015-11-01 16:21:07 -05:00
|
|
|
case 5:
|
|
|
|
context.m_State.nGPR[CMIPS::V0].nV0 = DeleteMbx(
|
2018-04-30 21:01:23 +01:00
|
|
|
context.m_State.nGPR[CMIPS::A0].nV0);
|
2015-11-01 16:21:07 -05:00
|
|
|
break;
|
2012-06-30 02:31:22 +00:00
|
|
|
case 6:
|
|
|
|
context.m_State.nGPR[CMIPS::V0].nV0 = SendMbx(
|
2018-04-30 21:01:23 +01:00
|
|
|
context.m_State.nGPR[CMIPS::A0].nV0,
|
|
|
|
context.m_State.nGPR[CMIPS::A1].nV0);
|
2012-06-30 02:31:22 +00:00
|
|
|
break;
|
2016-10-20 21:09:41 -04:00
|
|
|
case 7:
|
|
|
|
context.m_State.nGPR[CMIPS::V0].nV0 = iSendMbx(
|
2018-04-30 21:01:23 +01:00
|
|
|
context.m_State.nGPR[CMIPS::A0].nV0,
|
|
|
|
context.m_State.nGPR[CMIPS::A1].nV0);
|
2016-10-20 21:09:41 -04:00
|
|
|
break;
|
2012-06-30 02:31:22 +00:00
|
|
|
case 8:
|
|
|
|
context.m_State.nGPR[CMIPS::V0].nV0 = ReceiveMbx(
|
2018-04-30 21:01:23 +01:00
|
|
|
context.m_State.nGPR[CMIPS::A0].nV0,
|
|
|
|
context.m_State.nGPR[CMIPS::A1].nV0);
|
2012-06-30 02:31:22 +00:00
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
context.m_State.nGPR[CMIPS::V0].nV0 = PollMbx(
|
2018-04-30 21:01:23 +01:00
|
|
|
context.m_State.nGPR[CMIPS::A0].nV0,
|
|
|
|
context.m_State.nGPR[CMIPS::A1].nV0);
|
2012-06-30 02:31:22 +00:00
|
|
|
break;
|
2015-11-01 23:43:25 -05:00
|
|
|
case 11:
|
|
|
|
context.m_State.nGPR[CMIPS::V0].nV0 = ReferMbxStatus(
|
2018-04-30 21:01:23 +01:00
|
|
|
context.m_State.nGPR[CMIPS::A0].nV0,
|
|
|
|
context.m_State.nGPR[CMIPS::A1].nV0);
|
2015-11-01 23:43:25 -05:00
|
|
|
break;
|
2012-06-30 02:31:22 +00:00
|
|
|
default:
|
2018-05-24 12:59:15 -04:00
|
|
|
CLog::GetInstance().Warn(LOG_NAME, "Unknown function (%d) called at (%08X).\r\n", functionId, context.m_State.nPC);
|
2012-06-30 02:31:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 CThmsgbx::CreateMbx(const MSGBX* msgBx)
|
|
|
|
{
|
|
|
|
return m_bios.CreateMessageBox();
|
|
|
|
}
|
|
|
|
|
2015-11-01 16:21:07 -05:00
|
|
|
uint32 CThmsgbx::DeleteMbx(uint32 boxId)
|
|
|
|
{
|
|
|
|
return m_bios.DeleteMessageBox(boxId);
|
|
|
|
}
|
|
|
|
|
2012-06-30 02:31:22 +00:00
|
|
|
uint32 CThmsgbx::SendMbx(uint32 boxId, uint32 messagePtr)
|
|
|
|
{
|
2016-10-20 21:09:41 -04:00
|
|
|
return m_bios.SendMessageBox(boxId, messagePtr, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 CThmsgbx::iSendMbx(uint32 boxId, uint32 messagePtr)
|
|
|
|
{
|
|
|
|
return m_bios.SendMessageBox(boxId, messagePtr, true);
|
2012-06-30 02:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32 CThmsgbx::ReceiveMbx(uint32 messagePtr, uint32 boxId)
|
|
|
|
{
|
|
|
|
return m_bios.ReceiveMessageBox(messagePtr, boxId);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 CThmsgbx::PollMbx(uint32 messagePtr, uint32 boxId)
|
|
|
|
{
|
|
|
|
return m_bios.PollMessageBox(messagePtr, boxId);
|
|
|
|
}
|
2015-11-01 23:43:25 -05:00
|
|
|
|
|
|
|
uint32 CThmsgbx::ReferMbxStatus(uint32 boxId, uint32 statusPtr)
|
|
|
|
{
|
|
|
|
return m_bios.ReferMessageBoxStatus(boxId, statusPtr);
|
|
|
|
}
|