work harder to update mednafen CDC from 1.24.0-UNSTABLE more exactly

This commit is contained in:
zeromus 2020-04-09 15:55:10 -04:00
parent b3531b6dc9
commit f6a165752e
2 changed files with 1004 additions and 982 deletions

View File

@ -42,6 +42,32 @@
Nightmare Creatures hangs during startup for some CD timing alignments/windows, and it spams command 0x0A without properly waiting for it to complete. Nightmare Creatures hangs during startup for some CD timing alignments/windows, and it spams command 0x0A without properly waiting for it to complete.
*/ */
// TODO: async command counter and async command phase?
/*
TODO:
Implement missing commands.
SPU CD-DA and CD-XA streaming semantics.
*/
/*
After eject(doesn't appear to occur when drive is in STOP state):
* Does not appear to occur in STOP state.
* Does not appear to occur in PAUSE state.
* DOES appear to occur in STANDBY state. (TODO: retest)
% Result 0: 16
% Result 1: 08
% IRQ Result: e5
% 19 e0
Command abortion tests(NOP tested):
Does not appear to occur when in STOP or PAUSE states(STOP or PAUSE command just executed).
DOES occur after a ReadTOC completes, if ReadTOC is not followed by a STOP or PAUSE. Odd.
*/
#include "psx.h" #include "psx.h"
#include "cdc.h" #include "cdc.h"
#include "spu.h" #include "spu.h"
@ -191,7 +217,7 @@ void PS_CDC::SoftReset(void)
SectorPipe_Pos = SectorPipe_In = 0; SectorPipe_Pos = SectorPipe_In = 0;
SectorsRead = 0; SectorsRead = 0;
//memset(SubQBuf, 0, sizeof(SubQBuf)); memset(SubQBuf, 0, sizeof(SubQBuf));
memset(SubQBuf_Safe, 0, sizeof(SubQBuf_Safe)); memset(SubQBuf_Safe, 0, sizeof(SubQBuf_Safe));
SubQChecksumOK = false; SubQChecksumOK = false;
@ -288,7 +314,7 @@ SYNCFUNC(PS_CDC)
NSS(SectorPipe_Pos); NSS(SectorPipe_Pos);
NSS(SectorPipe_In); NSS(SectorPipe_In);
//NSS(SubQBuf); NSS(SubQBuf);
NSS(SubQBuf_Safe); NSS(SubQBuf_Safe);
NSS(SubQChecksumOK); NSS(SubQChecksumOK);
@ -379,6 +405,7 @@ void PS_CDC::RecalcIRQ(void)
{ {
IRQ_Assert(IRQ_CD, (bool)(IRQBuffer & (IRQOutTestMask & 0x1F))); IRQ_Assert(IRQ_CD, (bool)(IRQBuffer & (IRQOutTestMask & 0x1F)));
} }
//static int32 doom_ts; //static int32 doom_ts;
void PS_CDC::WriteIRQ(uint8 V) void PS_CDC::WriteIRQ(uint8 V)
{ {
@ -471,6 +498,7 @@ bool PS_CDC::DecodeSubQ(uint8 *subpw)
if((tmp_q[0] & 0xF) == 1) if((tmp_q[0] & 0xF) == 1)
{ {
memcpy(SubQBuf, tmp_q, 0xC);
SubQChecksumOK = subq_check_checksum(tmp_q); SubQChecksumOK = subq_check_checksum(tmp_q);
if(SubQChecksumOK) if(SubQChecksumOK)
@ -877,8 +905,8 @@ void PS_CDC::EnbufferizeCDDASector(const uint8 *buf)
{ {
for(int i = 0; i < 588; i++) for(int i = 0; i < 588; i++)
{ {
ab->Samples[0][i] = (int16)MDFN_de16lsb<false>(&buf[i * sizeof(int16) * 2 + 0]); ab->Samples[0][i] = (int16)MDFN_de16lsb(&buf[i * sizeof(int16) * 2 + 0]);
ab->Samples[1][i] = (int16)MDFN_de16lsb<false>(&buf[i * sizeof(int16) * 2 + 2]); ab->Samples[1][i] = (int16)MDFN_de16lsb(&buf[i * sizeof(int16) * 2 + 2]);
} }
} }
@ -1144,7 +1172,7 @@ pscpu_timestamp_t PS_CDC::Update(const pscpu_timestamp_t timestamp)
{ {
int32 clocks = timestamp - lastts; int32 clocks = timestamp - lastts;
if(!Cur_CDIF) if(!Cur_disc)
{ {
if(DriveStatus != DS_STOPPED || (PendingCommandCounter > 0 && PendingCommandPhase >= 2)) if(DriveStatus != DS_STOPPED || (PendingCommandCounter > 0 && PendingCommandPhase >= 2))
{ {
@ -1604,7 +1632,7 @@ uint32 PS_CDC::DMARead(void)
data |= DMABuffer.ReadByte() << (i * 8); data |= DMABuffer.ReadByte() << (i * 8);
else else
{ {
//assert(0); PSX_WARNING("[CDC] DMA read buffer underflow!");
} }
} }
@ -1626,7 +1654,7 @@ bool PS_CDC::CommandCheckDiscPresent(void)
return(true); return(true);
} }
int32 PS_CDC::Command_GetStat(const int arg_count, const uint8 *args) int32 PS_CDC::Command_Nop(const int arg_count, const uint8 *args)
{ {
WriteResult(MakeStatus()); WriteResult(MakeStatus());
@ -1716,7 +1744,6 @@ int32 PS_CDC::CalcSeekTime(int32 initial, int32 target, bool motor_on, bool paus
return(ret); return(ret);
} }
#if 0 #if 0
void PS_CDC::BeginSeek(uint32 target, int after_seek) void PS_CDC::BeginSeek(uint32 target, int after_seek)
{ {
@ -1727,7 +1754,6 @@ void PS_CDC::BeginSeek(uint32 target, int after_seek)
} }
#endif #endif
// Remove this function when we have better seek emulation; it's here because the Rockman complete works games(at least 2 and 4) apparently have finicky fubared CD // Remove this function when we have better seek emulation; it's here because the Rockman complete works games(at least 2 and 4) apparently have finicky fubared CD
// access code. // access code.
void PS_CDC::PreSeekHack(int32 target) void PS_CDC::PreSeekHack(int32 target)
@ -1790,7 +1816,6 @@ int32 PS_CDC::Command_Play(const int arg_count, const uint8 *args)
PreSeekHack(SeekTarget); PreSeekHack(SeekTarget);
SeekFinished = false; SeekFinished = false;
DriveStatus = DS_SEEKING; DriveStatus = DS_SEEKING;
StatusAfterSeek = DS_PLAYING; StatusAfterSeek = DS_PLAYING;
} }
@ -1812,7 +1837,6 @@ int32 PS_CDC::Command_Play(const int arg_count, const uint8 *args)
PreSeekHack(SeekTarget); PreSeekHack(SeekTarget);
SeekFinished = false; SeekFinished = false;
DriveStatus = DS_SEEKING; DriveStatus = DS_SEEKING;
StatusAfterSeek = DS_PLAYING; StatusAfterSeek = DS_PLAYING;
} }
@ -2037,7 +2061,7 @@ int32 PS_CDC::Command_Reset(const int arg_count, const uint8 *args)
// //
// //
// printf("DriveStatus: %d %d %d\n", DriveStatus, StatusAfterSeek, SeekTarget); // printf("DriveStatus: %d %d %d\n", DriveStatus, StatusAfterSeek, SeekTarget);
if(Cur_CDIF && DiscStartupDelay <= 0) if(Cur_disc && DiscStartupDelay <= 0)
{ {
if((DriveStatus == DS_SEEKING_LOGICAL || DriveStatus == DS_SEEKING) && StatusAfterSeek == DS_PAUSED && SeekTarget == 0) if((DriveStatus == DS_SEEKING_LOGICAL || DriveStatus == DS_SEEKING) && StatusAfterSeek == DS_PAUSED && SeekTarget == 0)
{ {
@ -2551,7 +2575,7 @@ int32 PS_CDC::Command_0x1d(const int arg_count, const uint8 *args)
const PS_CDC::CDC_CTEntry PS_CDC::Commands[0x20] = const PS_CDC::CDC_CTEntry PS_CDC::Commands[0x20] =
{ {
{ /* 0x00, */ 0, 0, NULL, NULL, NULL }, { /* 0x00, */ 0, 0, NULL, NULL, NULL },
{ /* 0x01, */ 0, 0, "GetStat", &PS_CDC::Command_GetStat, NULL }, { /* 0x01, */ 0, 0, "Nop", &PS_CDC::Command_Nop, NULL },
{ /* 0x02, */ 3, 3, "Setloc", &PS_CDC::Command_Setloc, NULL }, { /* 0x02, */ 3, 3, "Setloc", &PS_CDC::Command_Setloc, NULL },
{ /* 0x03, */ 0, 1, "Play", &PS_CDC::Command_Play, NULL }, { /* 0x03, */ 0, 1, "Play", &PS_CDC::Command_Play, NULL },
{ /* 0x04, */ 0, 0, "Forward", &PS_CDC::Command_Forward, NULL }, { /* 0x04, */ 0, 0, "Forward", &PS_CDC::Command_Forward, NULL },

View File

@ -70,7 +70,6 @@ class PS_CDC
void SetLEC(bool enable) { EnableLEC = enable; } void SetLEC(bool enable) { EnableLEC = enable; }
private: private:
CDIF *Cur_CDIF;
ShockDiscRef* Cur_disc; ShockDiscRef* Cur_disc;
bool EnableLEC; bool EnableLEC;
bool TrayOpen; bool TrayOpen;
@ -123,7 +122,7 @@ class PS_CDC
uint8 SectorPipe_Pos; uint8 SectorPipe_Pos;
uint8 SectorPipe_In; uint8 SectorPipe_In;
//uint8 SubQBuf[0xC]; uint8 SubQBuf[0xC];
uint8 SubQBuf_Safe[0xC]; uint8 SubQBuf_Safe[0xC];
bool SubQChecksumOK; bool SubQChecksumOK;
@ -191,7 +190,6 @@ class PS_CDC
DS_SEEKING, DS_SEEKING,
DS_SEEKING_LOGICAL, DS_SEEKING_LOGICAL,
DS_SEEKING_LOGICAL2, DS_SEEKING_LOGICAL2,
DS_PLAY_SEEKING,
DS_PLAYING, DS_PLAYING,
DS_READING, DS_READING,
//DS_RESETTING //DS_RESETTING
@ -267,7 +265,7 @@ class PS_CDC
static const CDC_CTEntry Commands[0x20]; static const CDC_CTEntry Commands[0x20];
int32 Command_GetStat(const int arg_count, const uint8 *args); int32 Command_Nop(const int arg_count, const uint8 *args);
int32 Command_Setloc(const int arg_count, const uint8 *args); int32 Command_Setloc(const int arg_count, const uint8 *args);
int32 Command_Play(const int arg_count, const uint8 *args); int32 Command_Play(const int arg_count, const uint8 *args);
int32 Command_Forward(const int arg_count, const uint8 *args); int32 Command_Forward(const int arg_count, const uint8 *args);