diff --git a/pcsx2/CDVD/CDVDaccess.cpp b/pcsx2/CDVD/CDVDaccess.cpp
index 6b310608be..ec431782a3 100644
--- a/pcsx2/CDVD/CDVDaccess.cpp
+++ b/pcsx2/CDVD/CDVDaccess.cpp
@@ -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;
diff --git a/pcsx2/CDVD/CDVDaccess.h b/pcsx2/CDVD/CDVDaccess.h
index e667898fa5..6e6b18cd07 100644
--- a/pcsx2/CDVD/CDVDaccess.h
+++ b/pcsx2/CDVD/CDVDaccess.h
@@ -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[];
diff --git a/pcsx2/CDVD/CDVDdiscReader.cpp b/pcsx2/CDVD/CDVDdiscReader.cpp
new file mode 100644
index 0000000000..83e5ee7e13
--- /dev/null
+++ b/pcsx2/CDVD/CDVDdiscReader.cpp
@@ -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 .
+ */
+
+#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,
+};
\ No newline at end of file
diff --git a/pcsx2/CDVD/CDVDdiscReader.h b/pcsx2/CDVD/CDVDdiscReader.h
new file mode 100644
index 0000000000..b3a7b09282
--- /dev/null
+++ b/pcsx2/CDVD/CDVDdiscReader.h
@@ -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 .
+ */
+
+#ifndef __CDVD_DISC_READER_H__
+#define __CDVD_DISC_READER_H__
+
+#include "IopCommon.h"
+
+#endif /* __CDVD_DISC_READER_H__ */
\ No newline at end of file
diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt
index ba9650bcbd..de52eaaa70 100644
--- a/pcsx2/CMakeLists.txt
+++ b/pcsx2/CMakeLists.txt
@@ -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
diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h
index 6f38f6e15a..bfdc407c7d 100644
--- a/pcsx2/gui/App.h
+++ b/pcsx2/gui/App.h
@@ -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,
diff --git a/pcsx2/gui/AppInit.cpp b/pcsx2/gui/AppInit.cpp
index a063bf0608..f38a5212de 100644
--- a/pcsx2/gui/AppInit.cpp
+++ b/pcsx2/gui/AppInit.cpp
@@ -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;
}
diff --git a/pcsx2/gui/Dialogs/DriveSelectorDialog.cpp b/pcsx2/gui/Dialogs/DriveSelectorDialog.cpp
new file mode 100644
index 0000000000..1cdaa62a84
--- /dev/null
+++ b/pcsx2/gui/Dialogs/DriveSelectorDialog.cpp
@@ -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 .
+ */
+
+#include "PrecompiledHeader.h"
+#include "Dialogs/ModalPopups.h"
+
+static wxArrayString GetOpticalDriveList()
+{
+ DWORD size = GetLogicalDriveStrings(0, nullptr);
+ std::vector 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();
+}
\ No newline at end of file
diff --git a/pcsx2/gui/Dialogs/ModalPopups.h b/pcsx2/gui/Dialogs/ModalPopups.h
index 27814bd491..d95b20c8af 100644
--- a/pcsx2/gui/Dialogs/ModalPopups.h
+++ b/pcsx2/gui/Dialogs/ModalPopups.h
@@ -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 );
diff --git a/pcsx2/gui/MainFrame.cpp b/pcsx2/gui/MainFrame.cpp
index 7eb65f82b6..66eb67b4e9 100644
--- a/pcsx2/gui/MainFrame.cpp
+++ b/pcsx2/gui/MainFrame.cpp
@@ -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,
diff --git a/pcsx2/gui/MainFrame.h b/pcsx2/gui/MainFrame.h
index db88991104..4b46ded28e 100644
--- a/pcsx2/gui/MainFrame.h
+++ b/pcsx2/gui/MainFrame.h
@@ -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);
diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp
index 1c85da7d5f..c108307794 100644
--- a/pcsx2/gui/MainMenuClicks.cpp
+++ b/pcsx2/gui/MainMenuClicks.cpp
@@ -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
}
diff --git a/pcsx2/windows/VCprojects/pcsx2.vcxproj b/pcsx2/windows/VCprojects/pcsx2.vcxproj
index 23a4d988cf..30e67caadf 100644
--- a/pcsx2/windows/VCprojects/pcsx2.vcxproj
+++ b/pcsx2/windows/VCprojects/pcsx2.vcxproj
@@ -147,6 +147,7 @@
+
@@ -174,6 +175,7 @@
+
@@ -395,6 +397,7 @@
+
diff --git a/pcsx2/windows/VCprojects/pcsx2.vcxproj.filters b/pcsx2/windows/VCprojects/pcsx2.vcxproj.filters
index 5ffaa322b6..0fd51f33f1 100644
--- a/pcsx2/windows/VCprojects/pcsx2.vcxproj.filters
+++ b/pcsx2/windows/VCprojects/pcsx2.vcxproj.filters
@@ -861,6 +861,11 @@
Recording
+
+ System\Ps2\Iop\CDVD
+
+
+ AppHost\Dialogs
@@ -1310,6 +1315,8 @@
Recording
+
+ System\Ps2\Iop\CDVD
@@ -1395,4 +1402,4 @@
AppHost\Resources
-
\ No newline at end of file
+