Adjust s_DIMAR/s_DILENGTH behavior (fixes Baten Kaitos music)

https://bugs.dolphin-emu.org/issues/11997

The problem seemed to be that s_DILENGTH would get set to 0
at times when it shouldn't. Simply not changing it in case
of NoReply or DTK seems to fix the problem. However, we can
actually go one step further in accuracy and use data.size()
to change s_DIMAR and s_DILENGTH as partial reads (NoReply
commands) complete, instead of jumping directly to 0 when
the whole read completes.
This commit is contained in:
JosJuice 2020-04-09 21:44:45 +02:00
parent 9a2d8a9623
commit 94f83db2b5

View File

@ -1233,8 +1233,17 @@ void SetHighError(u32 high_error)
void FinishExecutingCommand(ReplyType reply_type, DIInterruptType interrupt_type, s64 cycles_late, void FinishExecutingCommand(ReplyType reply_type, DIInterruptType interrupt_type, s64 cycles_late,
const std::vector<u8>& data) const std::vector<u8>& data)
{ {
s_DIMAR += s_DILENGTH; // The data parameter contains the requested data iff this was called from DVDThread, and is
s_DILENGTH = 0; // empty otherwise. DVDThread is the only source of ReplyType::NoReply and ReplyType::DTK.
u32 transfer_size = 0;
if (reply_type == ReplyType::NoReply)
transfer_size = static_cast<u32>(data.size());
else if (reply_type == ReplyType::Interrupt || reply_type == ReplyType::IOS)
transfer_size = s_DILENGTH;
s_DIMAR += transfer_size;
s_DILENGTH -= transfer_size;
switch (reply_type) switch (reply_type)
{ {