basic ideas for actual HLE functionality. do the init handshake.

This commit is contained in:
Arisotura
2025-07-11 23:12:26 +02:00
parent f6104609f9
commit af768fe729
4 changed files with 196 additions and 50 deletions

View File

@ -40,7 +40,11 @@ DSPHLE_UcodeBase::~DSPHLE_UcodeBase()
void DSPHLE_UcodeBase::Reset()
{
//
memset(CmdReg, 0, sizeof(CmdReg));
memset(CmdWritten, 0, sizeof(CmdWritten));
memset(ReplyReg, 0, sizeof(ReplyReg));
memset(ReplyWritten, 0, sizeof(ReplyWritten));
memset(ReplyReadCb, 0, sizeof(ReplyReadCb));
}
void DSPHLE_UcodeBase::DoSavestate(Savestate *file)
@ -48,18 +52,67 @@ void DSPHLE_UcodeBase::DoSavestate(Savestate *file)
//
}
bool DSPHLE_UcodeBase::SendDataIsEmpty(u8 index)
bool DSPHLE_UcodeBase::RecvDataIsReady(u8 index)
{
//
return false;
return ReplyWritten[index];
}
bool DSPHLE_UcodeBase::RecvDataIsEmpty(u8 index)
bool DSPHLE_UcodeBase::SendDataIsEmpty(u8 index)
{
//
return false;
return !CmdWritten[index];
}
u16 DSPHLE_UcodeBase::RecvData(u8 index)
{
if (!ReplyWritten[index]) return 0; // CHECKME
u16 ret = ReplyReg[index];
ReplyWritten[index] = false;
if (ReplyReadCb[index])
{
ReplyReadCb[index]();
ReplyReadCb[index] = nullptr;
}
return ret;
}
void DSPHLE_UcodeBase::SendData(u8 index, u16 val)
{
if (CmdWritten[index])
{
printf("??? trying to write cmd but there's already one\n");
return; // CHECKME
}
CmdReg[index] = val;
CmdWritten[index] = true;
printf("DSP: send cmd%d %04X\n", index, val);
}
void DSPHLE_UcodeBase::SendReply(u8 index, u16 val)
{
if (ReplyWritten[index])
{
printf("??? trying to write reply but there's already one\n");
return;
}
ReplyReg[index] = val;
ReplyWritten[index] = true;
// TODO add callback for when it is successfully written
}
void DSPHLE_UcodeBase::SetReplyReadCallback(u8 index, fnReplyReadCb callback)
{
ReplyReadCb[index] = callback;
}
u16 DSPHLE_UcodeBase::DMAChan0GetDstHigh()
{
//
@ -160,16 +213,26 @@ void DSPHLE_UcodeBase::MaskSemaphore(u16 val)
//
}
u16 DSPHLE_UcodeBase::RecvData(u8 index)
void DSPHLE_UcodeBase::Start()
{
//
return 0;
printf("DSP HLE: start\n");
// TODO later: detect which ucode it is and create the right class!
// (and fall back to Teakra if not a known ucode)
SendReply(0, 1);
SendReply(1, 1);
SendReply(2, 1);
SetReplyReadCallback(2, [=]()
{
printf("reply 2 was read\n");
SendReply(2, 0x0800);
});
// TODO more shit
}
void DSPHLE_UcodeBase::SendData(u8 index, u16 val)
{
//
}
void DSPHLE_UcodeBase::Run(u32 cycles)
{