CDVD: add menu item for discReader and gui for drive selection

This commit is contained in:
Filjo Abraham 2020-07-01 14:56:58 -05:00 committed by refractionpcsx2
parent 0c67dc99f7
commit a70bfbdaa9
14 changed files with 259 additions and 10 deletions

View File

@ -40,6 +40,7 @@ const wxChar* CDVD_SourceLabels[] =
{
L"ISO",
L"Plugin",
L"Disc",
L"NoDisc",
NULL
};
@ -327,6 +328,10 @@ void CDVDsys_ChangeSource( CDVD_SourceType type )
CDVD = &CDVDapi_Iso;
break;
case CDVD_SourceType::Disc:
CDVD = &CDVDapi_Disc;
break;
case CDVD_SourceType::NoDisc:
CDVD = &CDVDapi_NoDisc;
break;

View File

@ -21,6 +21,7 @@ enum class CDVD_SourceType : uint8_t
{
Iso, // use built in ISO api
Plugin, // use external plugin
Disc, // use built in Disc api
NoDisc, // use built in CDVDnull
};
@ -63,6 +64,7 @@ extern CDVD_API* CDVD; // currently active CDVD access mode api (either Iso, No
extern CDVD_API CDVDapi_Plugin;
extern CDVD_API CDVDapi_Iso;
extern CDVD_API CDVDapi_Disc;
extern CDVD_API CDVDapi_NoDisc;
extern const wxChar* CDVD_SourceLabels[];

View File

@ -0,0 +1,113 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "IopCommon.h"
s32 CALLBACK DISCopen(const char* pTitle)
{
return 0;
}
void CALLBACK DISCclose()
{
}
s32 CALLBACK DISCreadTrack(u32 lsn, int mode)
{
return -1;
}
// return can be NULL (for async modes)
u8* CALLBACK DISCgetBuffer()
{
return NULL;
}
s32 CALLBACK DISCreadSubQ(u32 lsn, cdvdSubQ* subq)
{
return -1;
}
s32 CALLBACK DISCgetTN(cdvdTN* Buffer)
{
return -1;
}
s32 CALLBACK DISCgetTD(u8 Track, cdvdTD* Buffer)
{
return -1;
}
s32 CALLBACK DISCgetTOC(void* toc)
{
return -1;
}
s32 CALLBACK DISCgetDiskType()
{
return CDVD_TYPE_NODISC;
}
s32 CALLBACK DISCgetTrayStatus()
{
return CDVD_TRAY_CLOSE;
}
s32 CALLBACK DISCdummyS32()
{
return 0;
}
void CALLBACK DISCnewDiskCB(void (* /* callback */)())
{
}
s32 CALLBACK DISCreadSector(u8* tempbuffer, u32 lsn, int mode)
{
return -1;
}
s32 CALLBACK DISCgetBuffer2(u8* buffer)
{
return -1;
}
s32 CALLBACK DISCgetDualInfo(s32* dualType, u32* _layer1start)
{
return -1;
}
CDVD_API CDVDapi_Disc =
{
DISCclose,
DISCopen,
DISCreadTrack,
DISCgetBuffer,
DISCreadSubQ,
DISCgetTN,
DISCgetTD,
DISCgetTOC,
DISCgetDiskType,
DISCgetTrayStatus,
DISCdummyS32,
DISCdummyS32,
DISCnewDiskCB,
DISCreadSector,
DISCgetBuffer2,
DISCgetDualInfo,
};

View File

@ -0,0 +1,21 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __CDVD_DISC_READER_H__
#define __CDVD_DISC_READER_H__
#include "IopCommon.h"
#endif /* __CDVD_DISC_READER_H__ */

View File

@ -181,6 +181,7 @@ set(pcsx2CDVDSources
CDVD/CdRom.cpp
CDVD/CDVDaccess.cpp
CDVD/CDVD.cpp
CDVD/CDVDdiscReader.cpp
CDVD/CDVDisoReader.cpp
CDVD/InputIsoFile.cpp
CDVD/OutputIsoFile.cpp
@ -199,6 +200,7 @@ set(pcsx2CDVDHeaders
CDVD/CDVDaccess.h
CDVD/CDVD.h
CDVD/CDVD_internal.h
CDVD/CDVDdiscReader.h
CDVD/CDVDisoReader.h
CDVD/ChunksCache.h
CDVD/CompressedFileReader.h
@ -269,6 +271,7 @@ set(pcsx2GuiSources
gui/Dialogs/ConfirmationDialogs.cpp
gui/Dialogs/ConvertMemoryCardDialog.cpp
gui/Dialogs/CreateMemoryCardDialog.cpp
gui/Dialogs/DriveSelectorDialog.cpp
gui/Dialogs/FirstTimeWizard.cpp
gui/Dialogs/ImportSettingsDialog.cpp
gui/Dialogs/LogOptionsDialog.cpp

View File

@ -98,8 +98,10 @@ enum MenuIdentifiers
// Run SubSection
MenuId_Cdvd_Source,
MenuId_DriveSelector,
MenuId_Src_Iso,
MenuId_Src_Plugin,
MenuId_Src_Disc,
MenuId_Src_NoDisc,
MenuId_Boot_Iso, // Opens submenu with Iso browser, and recent isos.
MenuId_RecentIsos_reservedStart,

View File

@ -229,6 +229,7 @@ void Pcsx2App::OnInitCmdLine( wxCmdLineParser& parser )
parser.AddOption( wxEmptyString,L"elf", _("executes an ELF image"), wxCMD_LINE_VAL_STRING );
parser.AddOption( wxEmptyString,L"irx", _("executes an IRX image"), wxCMD_LINE_VAL_STRING );
parser.AddSwitch( wxEmptyString,L"nodisc", _("boots an empty DVD tray; use to enter the PS2 system menu") );
//TODO_CDVD update string
parser.AddSwitch( wxEmptyString,L"usecd", _("boots from the CDVD plugin (overrides IsoFile parameter)") );
parser.AddSwitch( wxEmptyString,L"nohacks", _("disables all speedhacks") );
@ -363,6 +364,7 @@ bool Pcsx2App::OnCmdLineParsed( wxCmdLineParser& parser )
if( parser.Found(L"usecd") )
{
//TODO_CDVD change plugin to disc
Startup.CdvdSource = CDVD_SourceType::Plugin;
Startup.SysAutoRun = true;
}

View File

@ -0,0 +1,62 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2020 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "Dialogs/ModalPopups.h"
static wxArrayString GetOpticalDriveList()
{
DWORD size = GetLogicalDriveStrings(0, nullptr);
std::vector<wchar_t> drive_strings(size);
if (GetLogicalDriveStrings(size, drive_strings.data()) != size - 1)
return {};
wxArrayString drives;
for (auto p = drive_strings.data(); *p; ++p) {
if (GetDriveType(p) == DRIVE_CDROM)
drives.Add(p);
while (*p)
++p;
}
return drives;
}
Dialogs::DriveSelectorDialog::DriveSelectorDialog(wxWindow* parent)
: wxDialog(parent, wxID_ANY, "")
{
wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL);
wxStaticBoxSizer* staticSizer = new wxStaticBoxSizer(wxVERTICAL, this, "Source drive...");
wxBoxSizer* btnSizer = new wxBoxSizer(wxHORIZONTAL);
wxArrayString driveList = GetOpticalDriveList();
choiceDrive = new wxChoice(this, wxID_ANY, wxDefaultPosition, { 240, 40 }, driveList);
wxButton* btnOk = new wxButton(this, wxID_OK);
wxButton* btnCancel = new wxButton(this, wxID_CANCEL);
btnSizer->Add(btnOk, wxSizerFlags(1).Expand());
btnSizer->Add(btnCancel, wxSizerFlags(1).Expand().Border(wxLEFT, 5));
staticSizer->Add(choiceDrive, wxSizerFlags(1).Expand().Border(wxTOP, 10).Border(wxLEFT, 7));
topSizer->Add(staticSizer, wxSizerFlags(2).Expand().Border(wxALL, 10));
topSizer->Add(btnSizer, wxSizerFlags(0).Border(wxRIGHT | wxLEFT | wxBOTTOM, 5).Right());
SetSizerAndFit(topSizer);
}
wxString Dialogs::DriveSelectorDialog::GetSelectedDrive()
{
return choiceDrive->GetStringSelection();
}

View File

@ -101,6 +101,15 @@ namespace Dialogs
AssertionDialog( const wxString& text, const wxString& stacktrace );
virtual ~AssertionDialog() = default;
};
class DriveSelectorDialog : public wxDialog
{
public:
DriveSelectorDialog( wxWindow* parent );
wxString GetSelectedDrive();
private:
wxChoice* choiceDrive;
};
}
wxWindowID pxIssueConfirmation( wxDialogWithHelpers& confirmDlg, const MsgButtons& buttons );

View File

@ -73,21 +73,20 @@ void MainEmuFrame::UpdateStatusBar()
#endif
}
void MainEmuFrame::UpdateIsoSrcSelection()
void MainEmuFrame::UpdateCdvdSrcSelection()
{
MenuIdentifiers cdsrc = MenuId_Src_Iso;
switch( g_Conf->CdvdSource )
{
case CDVD_SourceType::Iso: cdsrc = MenuId_Src_Iso; break;
case CDVD_SourceType::Plugin: cdsrc = MenuId_Src_Plugin; break;
case CDVD_SourceType::Disc: cdsrc = MenuId_Src_Disc; break;
case CDVD_SourceType::NoDisc: cdsrc = MenuId_Src_NoDisc; break;
jNO_DEFAULT
}
sMenuBar.Check( cdsrc, true );
UpdateStatusBar();
EnableCdvdPluginSubmenu( cdsrc == MenuId_Src_Plugin );
}
bool MainEmuFrame::Destroy()
@ -229,7 +228,10 @@ void MainEmuFrame::ConnectMenus()
Bind(wxEVT_MENU, &MainEmuFrame::Menu_IsoBrowse_Click, this, MenuId_IsoBrowse);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_IsoClear_Click, this, MenuId_IsoClear);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_CdvdSource_Click, this, MenuId_Src_Iso);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_CdvdSource_Click, this, MenuId_Src_Plugin);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_DiscBrowse_Click, this, MenuId_DriveSelector);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_CdvdSource_Click, this, MenuId_Src_Disc);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_DriveSelector_Click, this, MenuId_DriveSelector);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_CdvdSource_Click, this, MenuId_Src_Disc);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_CdvdSource_Click, this, MenuId_Src_NoDisc);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_Ask_On_Boot_Click, this, MenuId_Ask_On_Booting);
Bind(wxEVT_MENU, &MainEmuFrame::Menu_Debug_CreateBlockdump_Click, this, MenuId_Debug_CreateBlockdump);
@ -399,14 +401,20 @@ void MainEmuFrame::CreateCdvdMenu()
{
// ------------------------------------------------------------------------
wxMenu& isoRecents( wxGetApp().GetRecentIsoMenu() );
wxMenu& driveList ( wxGetApp().GetDriveListMenu() );
m_menuItem_RecentIsoMenu = m_menuCDVD.AppendSubMenu(&isoRecents, _("ISO &Selector"));
m_menuCDVD.Append( GetPluginMenuId_Settings(PluginId_CDVD), _("Plugin &Menu"), m_PluginMenuPacks[PluginId_CDVD] );
m_menuItem_DriveListMenu = m_menuCDVD.AppendSubMenu(&driveList, _("D&rive Selector"));
m_menuCDVD.AppendSeparator();
m_menuCDVD.Append( MenuId_Src_Iso, _("&ISO"), _("Makes the specified ISO image the CDVD source."), wxITEM_RADIO );
m_menuCDVD.Append( MenuId_Src_Plugin, _("&Plugin"), _("Uses an external plugin as the CDVD source."), wxITEM_RADIO );
m_menuCDVD.Append( MenuId_Src_NoDisc, _("&No Disc"), _("Use this to boot into your virtual PS2's BIOS configuration."), wxITEM_RADIO );
m_menuCDVD.Append( MenuId_Src_Disc, _("&Disc"), _("Uses a disc drive as the CDVD source."), wxITEM_RADIO );
m_menuCDVD.Append( MenuId_Src_NoDisc, _("&No disc"), _("Use this to boot into your virtual PS2's BIOS configuration."), wxITEM_RADIO );
#if defined(__FREEBSD__) || defined(__APPLE__)
m_menuItem_DriveListMenu->Enable(false);
m_menuCDVD.Enable(MenuId_Src_Disc, false);
#endif
}
@ -705,7 +713,7 @@ void MainEmuFrame::ApplyCoreStatus()
case CDVD_SourceType::Iso:
label = _("Boot ISO");
break;
case CDVD_SourceType::Plugin:
case CDVD_SourceType::Disc:
label = _("Boot CDVD");
break;
case CDVD_SourceType::NoDisc:
@ -754,7 +762,7 @@ void MainEmuFrame::ApplyConfigToGui(AppConfig& configToApply, int flags)
menubar.Check( MenuId_Config_FastBoot, configToApply.EnableFastBoot );
}
UpdateIsoSrcSelection(); //shouldn't be affected by presets but updates from g_Conf anyway and not from configToApply, so no problem here.
UpdateCdvdSrcSelection(); //shouldn't be affected by presets but updates from g_Conf anyway and not from configToApply, so no problem here.
}
//write pending preset settings from the gui to g_Conf,

View File

@ -189,6 +189,7 @@ protected:
void Menu_IsoBrowse_Click(wxCommandEvent &event);
void Menu_IsoClear_Click(wxCommandEvent &event);
void Menu_DriveSelector_Click(wxCommandEvent &event);
void Menu_EnableBackupStates_Click(wxCommandEvent &event);
void Menu_EnablePatches_Click(wxCommandEvent &event);
void Menu_EnableCheats_Click(wxCommandEvent &event);

View File

@ -364,6 +364,16 @@ void MainEmuFrame::_DoBootCdvd()
sApp.SysExecute( g_Conf->CdvdSource );
}
void MainEmuFrame::Menu_DriveSelector_Click(wxCommandEvent& event)
{
DriveSelectorDialog driveDialog(this);
if (driveDialog.ShowModal() == wxID_OK)
{
wxString driveLetter = driveDialog.GetSelectedDrive();
//TODO_CDVD send driveLetter to CDVDdiscReader
}
}
void MainEmuFrame::EnableCdvdPluginSubmenu(bool isEnable)
{
EnableMenuItem( GetPluginMenuId_Settings(PluginId_CDVD), isEnable );
@ -377,6 +387,7 @@ void MainEmuFrame::Menu_CdvdSource_Click( wxCommandEvent &event )
{
case MenuId_Src_Iso: newsrc = CDVD_SourceType::Iso; break;
case MenuId_Src_Plugin: newsrc = CDVD_SourceType::Plugin; break;
case MenuId_Src_Disc: newsrc = CDVD_SourceType::Disc; break;
case MenuId_Src_NoDisc: newsrc = CDVD_SourceType::NoDisc; break;
jNO_DEFAULT
}

View File

@ -147,6 +147,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\CDVD\BlockdumpFileReader.cpp" />
<ClCompile Include="..\..\CDVD\CDVDdiscReader.cpp" />
<ClCompile Include="..\..\CDVD\ChunksCache.cpp" />
<ClCompile Include="..\..\CDVD\CompressedFileReader.cpp" />
<ClCompile Include="..\..\CDVD\CsoFileReader.cpp" />
@ -174,6 +175,7 @@
<ClCompile Include="..\..\gui\Debugger\DebugEvents.cpp" />
<ClCompile Include="..\..\gui\Debugger\DebuggerLists.cpp" />
<ClCompile Include="..\..\gui\Debugger\DisassemblyDialog.cpp" />
<ClCompile Include="..\..\gui\Dialogs\DriveSelectorDialog.cpp" />
<ClCompile Include="..\..\gui\Dialogs\McdConfigDialog.cpp" />
<ClCompile Include="..\..\gui\Panels\MemoryCardListView.cpp" />
<ClCompile Include="..\..\IopGte.cpp" />
@ -395,6 +397,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\AsyncFileReader.h" />
<ClInclude Include="..\..\CDVD\CDVDdiscReader.h" />
<ClInclude Include="..\..\CDVD\ChunksCache.h" />
<ClInclude Include="..\..\CDVD\CompressedFileReader.h" />
<ClInclude Include="..\..\CDVD\CompressedFileReaderUtils.h" />

View File

@ -861,6 +861,11 @@
</ClCompile>
<ClCompile Include="..\..\Recording\InputRecordingControls.cpp">
<Filter>Recording</Filter>
<ClCompile Include="..\..\CDVD\CDVDdiscReader.cpp">
<Filter>System\Ps2\Iop\CDVD</Filter>
</ClCompile>
<ClCompile Include="..\..\gui\Dialogs\DriveSelectorDialog.cpp">
<Filter>AppHost\Dialogs</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
@ -1310,6 +1315,8 @@
</ClInclude>
<ClInclude Include="..\..\Recording\InputRecordingControls.h">
<Filter>Recording</Filter>
<ClInclude Include="..\..\CDVD\CDVDdiscReader.h">
<Filter>System\Ps2\Iop\CDVD</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
@ -1395,4 +1402,4 @@
<Filter>AppHost\Resources</Filter>
</Manifest>
</ItemGroup>
</Project>
</Project>