Merge pull request #1756 from JosJuice/eslaunch-regression

Fix 4.0-4724 ES_Launch and System Menu regressions
This commit is contained in:
Ryan Houdek 2014-12-26 08:02:39 -06:00
commit 339383b8dd
2 changed files with 93 additions and 102 deletions

View File

@ -251,6 +251,8 @@ static int insertDisc;
void EjectDiscCallback(u64 userdata, int cyclesLate); void EjectDiscCallback(u64 userdata, int cyclesLate);
void InsertDiscCallback(u64 userdata, int cyclesLate); void InsertDiscCallback(u64 userdata, int cyclesLate);
void SetLidOpen(bool _bOpen);
void UpdateInterrupts(); void UpdateInterrupts();
void GenerateDIInterrupt(DIInterruptType _DVDInterrupt); void GenerateDIInterrupt(DIInterruptType _DVDInterrupt);
@ -363,7 +365,7 @@ static void DTKStreamingCallback(u64 userdata, int cyclesLate)
void Init() void Init()
{ {
m_DISR.Hex = 0; m_DISR.Hex = 0;
m_DICVR.Hex = 0; m_DICVR.Hex = 1; // Disc Channel relies on cover being open when no disc is inserted
m_DICMDBUF[0].Hex = 0; m_DICMDBUF[0].Hex = 0;
m_DICMDBUF[1].Hex = 0; m_DICMDBUF[1].Hex = 0;
m_DICMDBUF[2].Hex = 0; m_DICMDBUF[2].Hex = 0;
@ -403,6 +405,9 @@ void Shutdown()
void SetDiscInside(bool _DiscInside) void SetDiscInside(bool _DiscInside)
{ {
if (g_bDiscInside != _DiscInside)
SetLidOpen(!_DiscInside);
g_bDiscInside = _DiscInside; g_bDiscInside = _DiscInside;
} }
@ -419,7 +424,6 @@ void EjectDiscCallback(u64 userdata, int cyclesLate)
{ {
// Empty the drive // Empty the drive
SetDiscInside(false); SetDiscInside(false);
SetLidOpen();
VolumeHandler::EjectVolume(); VolumeHandler::EjectVolume();
} }
@ -434,7 +438,6 @@ void InsertDiscCallback(u64 userdata, int cyclesLate)
VolumeHandler::SetVolumeName(SavedFileName); VolumeHandler::SetVolumeName(SavedFileName);
PanicAlertT("Invalid file"); PanicAlertT("Invalid file");
} }
SetLidOpen(false);
SetDiscInside(VolumeHandler::IsValid()); SetDiscInside(VolumeHandler::IsValid());
delete _FileName; delete _FileName;
} }
@ -464,11 +467,6 @@ void SetLidOpen(bool _bOpen)
GenerateDIInterrupt(INT_CVRINT); GenerateDIInterrupt(INT_CVRINT);
} }
bool IsLidOpen()
{
return (m_DICVR.CVR == 1);
}
bool DVDRead(u64 _iDVDOffset, u32 _iRamAddress, u32 _iLength, bool raw) bool DVDRead(u64 _iDVDOffset, u32 _iRamAddress, u32 _iLength, bool raw)
{ {
if (raw) if (raw)
@ -628,28 +626,12 @@ DVDCommandResult ExecuteReadCommand(u64 DVD_offset, u32 output_address,
DVDCommandResult result; DVDCommandResult result;
result.ticks_until_completion = SimulateDiscReadTime(DVD_offset, DVD_length); result.ticks_until_completion = SimulateDiscReadTime(DVD_offset, DVD_length);
if (raw) if (!g_bDiscInside)
{ {
// We must make sure it is in a valid area! (#001 check) g_ErrorCode = ERROR_NO_DISK | ERROR_COVER_H;
// * 0x00000000 - 0x00014000 (limit of older IOS versions) result.interrupt_type = INT_DEINT;
// * 0x460a0000 - 0x460a0008
// * 0x7ed40000 - 0x7ed40008
u32 DVD_offset_32 = (u32)(DVD_offset >> 2);
// Are these checks correct? They seem to mix 32-bit offsets and 8-bit lengths
if (!((DVD_offset_32 > 0x00000000 && DVD_offset_32 < 0x00014000) ||
(((DVD_offset_32 + DVD_length) > 0x00000000) && (DVD_offset_32 + DVD_length) < 0x00014000) ||
(DVD_offset_32 > 0x460a0000 && DVD_offset_32 < 0x460a0008) ||
(((DVD_offset_32 + DVD_length) > 0x460a0000) && (DVD_offset_32 + DVD_length) < 0x460a0008) ||
(DVD_offset_32 > 0x7ed40000 && DVD_offset_32 < 0x7ed40008) ||
(((DVD_offset_32 + DVD_length) > 0x7ed40000) && (DVD_offset_32 + DVD_length) < 0x7ed40008)))
{
WARN_LOG(DVDINTERFACE, "DVDLowUnencryptedRead: trying to read out of bounds @ %09" PRIx64, DVD_offset);
g_ErrorCode = ERROR_READY | ERROR_BLOCK_OOB;
// Should cause software to call DVDLowRequestError
result.interrupt_type = INT_BRKINT;
return result; return result;
} }
}
if (!DVDRead(DVD_offset, output_address, DVD_length, raw)) if (!DVDRead(DVD_offset, output_address, DVD_length, raw))
PanicAlertT("Can't read from DVD_Plugin - DVD-Interface: Fatal Error"); PanicAlertT("Can't read from DVD_Plugin - DVD-Interface: Fatal Error");
@ -708,7 +690,7 @@ DVDCommandResult ExecuteCommand(u32 command_0, u32 command_1, u32 command_2,
// Only seems to be used from WII_IPC, not through direct access // Only seems to be used from WII_IPC, not through direct access
case DVDLowReadDiskID: case DVDLowReadDiskID:
INFO_LOG(DVDINTERFACE, "DVDLowReadDiskID"); INFO_LOG(DVDINTERFACE, "DVDLowReadDiskID");
result = ExecuteReadCommand(0, output_address, command_1, output_length, true); result = ExecuteReadCommand(0, output_address, 0x20, output_length, true);
break; break;
// Only seems to be used from WII_IPC, not through direct access // Only seems to be used from WII_IPC, not through direct access
@ -784,7 +766,29 @@ DVDCommandResult ExecuteCommand(u32 command_0, u32 command_1, u32 command_2,
// Probably only used by Wii // Probably only used by Wii
case DVDLowUnencryptedRead: case DVDLowUnencryptedRead:
INFO_LOG(DVDINTERFACE, "DVDLowUnencryptedRead: DVDAddr: 0x%09" PRIx64 ", Size: 0x%x", (u64)command_2 << 2, command_1); INFO_LOG(DVDINTERFACE, "DVDLowUnencryptedRead: DVDAddr: 0x%09" PRIx64 ", Size: 0x%x", (u64)command_2 << 2, command_1);
// We must make sure it is in a valid area! (#001 check)
// Are these checks correct? They seem to mix 32-bit offsets and 8-bit lengths
// * 0x00000000 - 0x00014000 (limit of older IOS versions)
// * 0x460a0000 - 0x460a0008
// * 0x7ed40000 - 0x7ed40008
if (((command_2 > 0x00000000 && command_2 < 0x00014000) ||
(((command_2 + command_1) > 0x00000000) && (command_2 + command_1) < 0x00014000) ||
(command_2 > 0x460a0000 && command_2 < 0x460a0008) ||
(((command_2 + command_1) > 0x460a0000) && (command_2 + command_1) < 0x460a0008) ||
(command_2 > 0x7ed40000 && command_2 < 0x7ed40008) ||
(((command_2 + command_1) > 0x7ed40000) && (command_2 + command_1) < 0x7ed40008)))
{
result = ExecuteReadCommand((u64)command_2 << 2, output_address, command_1, output_length, true); result = ExecuteReadCommand((u64)command_2 << 2, output_address, command_1, output_length, true);
}
else
{
WARN_LOG(DVDINTERFACE, "DVDLowUnencryptedRead: trying to read out of bounds @ %09" PRIx64, (u64)command_2 << 2);
g_ErrorCode = ERROR_READY | ERROR_BLOCK_OOB;
// Should cause software to call DVDLowRequestError
result.interrupt_type = INT_BRKINT;
}
break; break;
// Probably only used by Wii // Probably only used by Wii
@ -812,8 +816,6 @@ DVDCommandResult ExecuteCommand(u32 command_0, u32 command_1, u32 command_2,
// DMA Read from Disc. Only seems to be used through direct access, not WII_IPC // DMA Read from Disc. Only seems to be used through direct access, not WII_IPC
case 0xA8: case 0xA8:
if (g_bDiscInside)
{
switch (command_0 & 0xFF) switch (command_0 & 0xFF)
{ {
case 0x00: // Read Sector case 0x00: // Read Sector
@ -879,20 +881,13 @@ DVDCommandResult ExecuteCommand(u32 command_0, u32 command_1, u32 command_2,
case 0x40: // Read DiscID case 0x40: // Read DiscID
INFO_LOG(DVDINTERFACE, "Read DiscID %08x", Memory::Read_U32(output_address)); INFO_LOG(DVDINTERFACE, "Read DiscID %08x", Memory::Read_U32(output_address));
result = ExecuteReadCommand(0, output_address, command_2, output_length); result = ExecuteReadCommand(0, output_address, 0x20, output_length);
break; break;
default: default:
ERROR_LOG(DVDINTERFACE, "Unknown read subcommand: %08x", command_0); ERROR_LOG(DVDINTERFACE, "Unknown read subcommand: %08x", command_0);
break; break;
} }
}
else
{
// there is no disc to read
g_ErrorCode = ERROR_NO_DISK | ERROR_COVER_H;
result.interrupt_type = INT_DEINT;
}
break; break;
// GC-AM only // GC-AM only

View File

@ -102,10 +102,6 @@ void SetDiscInside(bool _DiscInside);
bool IsDiscInside(); bool IsDiscInside();
void ChangeDisc(const std::string& fileName); void ChangeDisc(const std::string& fileName);
// Lid Functions
void SetLidOpen(bool _bOpen = true);
bool IsLidOpen();
// DVD Access Functions // DVD Access Functions
bool DVDRead(u64 _iDVDOffset, u32 _iRamAddress, u32 _iLength, bool raw = false); bool DVDRead(u64 _iDVDOffset, u32 _iRamAddress, u32 _iLength, bool raw = false);
extern bool g_bStream; extern bool g_bStream;