From 62fff80925c475c4d1932091b9fe1a586a59c9a7 Mon Sep 17 00:00:00 2001 From: John Peterson Date: Tue, 23 Dec 2008 08:47:37 +0000 Subject: [PATCH] Change disc: Moved some code around, no change in functionality git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1632 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/Boot/Boot.cpp | 3 + Source/Core/Core/Src/HW/DVDInterface.cpp | 42 ++++--- Source/Core/Core/Src/VolumeHandler.cpp | 4 +- Source/Core/Core/Src/VolumeHandler.h | 2 +- Source/Core/DolphinWX/DolphinWX.vcproj | 14 +-- Source/Core/DolphinWX/Src/Frame.cpp | 140 ++++++++++++++--------- Source/Core/DolphinWX/Src/Frame.h | 42 ++++--- Source/Core/DolphinWX/Src/Globals.h | 32 +++--- 8 files changed, 164 insertions(+), 115 deletions(-) diff --git a/Source/Core/Core/Src/Boot/Boot.cpp b/Source/Core/Core/Src/Boot/Boot.cpp index cf67b41f58..7ad7bb8b5c 100644 --- a/Source/Core/Core/Src/Boot/Boot.cpp +++ b/Source/Core/Core/Src/Boot/Boot.cpp @@ -205,6 +205,9 @@ bool CBoot::BootUp(const SCoreStartupParameter& _StartupPara) and eventually replace code */ if (LoadMapFromFilename(_StartupPara.m_strFilename, gameID)) HLE::PatchFunctions(); + + // We don't need the volume any more + delete pVolume; } break; diff --git a/Source/Core/Core/Src/HW/DVDInterface.cpp b/Source/Core/Core/Src/HW/DVDInterface.cpp index 9dd785a4ce..32a4033587 100644 --- a/Source/Core/Core/Src/HW/DVDInterface.cpp +++ b/Source/Core/Core/Src/HW/DVDInterface.cpp @@ -15,19 +15,16 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ -#include "Common.h" +#include "Common.h" // Common #include "ChunkFile.h" -#include "StreamADPCM.H" +#include "StreamADPCM.H" // Core #include "DVDInterface.h" - #include "../PowerPC/PowerPC.h" #include "PeripheralInterface.h" #include "Memmap.h" #include "Thread.h" - #include "../VolumeHandler.h" -#include "VolumeCreator.h" // DiscIO namespace DVDInterface { @@ -221,11 +218,7 @@ void SetDiscInside(bool _DiscInside) { g_bDiscInside = _DiscInside; } -void SwapDisc(const char * fileName) -{ - VolumeHandler::SetVolumeName(fileName); - DVDInterface::SetDiscInside(VolumeHandler::IsValid()); -} + void SetLidOpen(bool _bOpen) { if (_bOpen) @@ -234,6 +227,16 @@ void SetLidOpen(bool _bOpen) dvdMem.CoverReg.Hex = 0x0; CPeripheralInterface::SetInterrupt(CPeripheralInterface::INT_CAUSE_DI, true); + + /* + Todo: Make this work perhaps? + if (_bOpen) + dvdMem.CoverReg.CVR = 1; + else + dvdMem.CoverReg.CVR = 0; + + UpdateInterrupts(); + */ } bool IsLidOpen() @@ -340,15 +343,20 @@ void Write32(const u32 _iValue, const u32 _iAddress) case DI_COVER_REGISTER: { - // UDICVR tmpCoverReg(_iValue); + /* + // Todo: fix this, it doesn't work properly - // dvdMem.CoverReg.CVR = 0; - // dvdMem.CoverReg.CVRINTMASK = tmpCoverReg.CVRINTMASK; - // if (tmpCoverReg.CVRINT) dvdMem.CoverReg.CVRINT = 0; - // - // UpdateInterrupts(); + UDICVR tmpCoverReg(_iValue); + + dvdMem.CoverReg.CVR = 0; + dvdMem.CoverReg.CVRINTMASK = tmpCoverReg.CVRINTMASK; + if (tmpCoverReg.CVRINT) dvdMem.CoverReg.CVRINT = 0; + + UpdateInterrupts(); + + _dbg_assert_(DVDINTERFACE, (tmpCoverReg.CVR == 0)); + */ - // _dbg_assert_(DVDINTERFACE, (tmpCoverReg.CVR == 0)); } break; diff --git a/Source/Core/Core/Src/VolumeHandler.cpp b/Source/Core/Core/Src/VolumeHandler.cpp index cca0ebcfef..35b9587dae 100644 --- a/Source/Core/Core/Src/VolumeHandler.cpp +++ b/Source/Core/Core/Src/VolumeHandler.cpp @@ -27,7 +27,7 @@ DiscIO::IVolume *GetVolume() { return g_pVolume; } -void SetVolumeName(const std::string& _rFullPath) +bool SetVolumeName(const std::string& _rFullPath) { if (g_pVolume) { @@ -40,6 +40,8 @@ void SetVolumeName(const std::string& _rFullPath) } g_pVolume = DiscIO::CreateVolumeFromFilename(_rFullPath); + + return g_pVolume != NULL; } void SetVolumeDirectory(const std::string& _rFullPath, bool _bIsWii) diff --git a/Source/Core/Core/Src/VolumeHandler.h b/Source/Core/Core/Src/VolumeHandler.h index a9359ee037..0428b3e835 100644 --- a/Source/Core/Core/Src/VolumeHandler.h +++ b/Source/Core/Core/Src/VolumeHandler.h @@ -28,7 +28,7 @@ namespace VolumeHandler { -void SetVolumeName(const std::string& _rFullPath); +bool SetVolumeName(const std::string& _rFullPath); void SetVolumeDirectory(const std::string& _rFullPath, bool _bIsWii); u32 Read32(u64 _Offset); diff --git a/Source/Core/DolphinWX/DolphinWX.vcproj b/Source/Core/DolphinWX/DolphinWX.vcproj index 9c44a01172..d8e3b8c8e3 100644 --- a/Source/Core/DolphinWX/DolphinWX.vcproj +++ b/Source/Core/DolphinWX/DolphinWX.vcproj @@ -1,7 +1,7 @@ +#include "FileUtil.h" // Common +#include "Common.h" + +#include "Config.h" // Core +#include "Core.h" +#include "HW/DVDInterface.h" +#include "State.h" +#include "VolumeHandler.h" + +#include // wxWidgets // ---------------------------------------------------------------------------- // resources @@ -55,7 +56,6 @@ extern "C" { #include "../resources/toolbar_stop.c" }; -using namespace DVDInterface; #define wxGetBitmapFromMemory(name) _wxGetBitmapFromMemory(name, sizeof(name)) inline wxBitmap _wxGetBitmapFromMemory(const unsigned char* data, int length) @@ -98,8 +98,7 @@ EVT_MENU(IDM_CONFIG_WIIMOTE_PLUGIN, CFrame::OnPluginWiimote) EVT_MENU(IDM_BROWSE, CFrame::OnBrowse) EVT_MENU(IDM_MEMCARD, CFrame::OnMemcard) EVT_MENU(IDM_CHEATS, CFrame::OnShow_CheatsWindow) -EVT_MENU(IDM_SWAPDISC, CFrame::OnSwapDisc) -EVT_MENU(IDM_TOGGLECOVER, CFrame::OnSwapDisc) +EVT_MENU(IDM_CHANGEDISC, CFrame::OnChangeDisc) EVT_MENU(IDM_TOGGLE_FULLSCREEN, CFrame::OnToggleFullscreen) EVT_MENU(IDM_TOGGLE_DUALCORE, CFrame::OnToggleDualCore) EVT_MENU(IDM_TOGGLE_SKIPIDLE, CFrame::OnToggleSkipIdle) @@ -206,7 +205,7 @@ void CFrame::CreateMenu() // file menu wxMenu* fileMenu = new wxMenu; - fileMenu->Append(wxID_OPEN, _T("&Open...\tCtrl+O")); + m_pMenuItemOpen = fileMenu->Append(wxID_OPEN, _T("&Open...\tCtrl+O")); fileMenu->Append(wxID_REFRESH, _T("&Refresh")); fileMenu->Append(IDM_BROWSE, _T("&Browse for ISOs...")); @@ -214,9 +213,10 @@ void CFrame::CreateMenu() fileMenu->Append(wxID_EXIT, _T("E&xit"), _T("Alt+F4")); m_pMenuBar->Append(fileMenu, _T("&File")); - // emulation menu + // Emulation menu wxMenu* emulationMenu = new wxMenu; m_pMenuItemPlay = emulationMenu->Append(IDM_PLAY, _T("&Play")); + m_pMenuChangeDisc = emulationMenu->Append(IDM_CHANGEDISC, _T("Change disc")); m_pMenuItemStop = emulationMenu->Append(IDM_STOP, _T("&Stop")); emulationMenu->AppendSeparator(); wxMenu *saveMenu = new wxMenu; @@ -229,7 +229,7 @@ void CFrame::CreateMenu() } m_pMenuBar->Append(emulationMenu, _T("&Emulation")); - // options menu + // Options menu wxMenu* pOptionsMenu = new wxMenu; m_pPluginOptions = pOptionsMenu->Append(IDM_CONFIG_MAIN, _T("Co&nfigure...")); pOptionsMenu->AppendSeparator(); @@ -242,13 +242,7 @@ void CFrame::CreateMenu() #endif m_pMenuBar->Append(pOptionsMenu, _T("&Options")); - //DVD menu - wxMenu* dvdMenu = new wxMenu; - dvdMenu->Append(IDM_SWAPDISC, _T("S&wap Disc")); - dvdMenu->Append(IDM_TOGGLECOVER, _T("Toggle \"DVD co&ver is open\"")); - m_pMenuBar->Append(dvdMenu, _T("&DVD")); - - // misc menu + // Misc menu wxMenu* miscMenu = new wxMenu; miscMenu->AppendCheckItem(IDM_TOGGLE_TOOLBAR, _T("View &toolbar")); miscMenu->Check(IDM_TOGGLE_TOOLBAR, true); @@ -256,10 +250,10 @@ void CFrame::CreateMenu() miscMenu->Check(IDM_TOGGLE_STATUSBAR, true); miscMenu->AppendSeparator(); miscMenu->Append(IDM_MEMCARD, _T("&Memcard manager")); - miscMenu->Append(IDM_CHEATS, _T("Action &Replay Manager")); + miscMenu->Append(IDM_CHEATS, _T("Action &Replay Manager")); m_pMenuBar->Append(miscMenu, _T("&Misc")); - // help menu + // Help menu wxMenu* helpMenu = new wxMenu; /*helpMenu->Append(wxID_HELP, _T("&Help")); re-enable when there's something useful to display*/ @@ -347,10 +341,20 @@ void CFrame::InitBitmaps() } +// ======================================================= +// Open file +// ------------- void CFrame::OnOpen(wxCommandEvent& WXUNUSED (event)) { - if (Core::GetState() != Core::CORE_UNINITIALIZED) - return; + // Don't allow this for an initialized core + //if (Core::GetState() != Core::CORE_UNINITIALIZED) + // return; + + DoOpen(true); +} + +void CFrame::DoOpen(bool Boot) +{ wxString path = wxFileSelector( _T("Select the file to load"), wxEmptyString, wxEmptyString, wxEmptyString, @@ -366,9 +370,41 @@ void CFrame::OnOpen(wxCommandEvent& WXUNUSED (event)) { return; } - BootManager::BootCore(std::string(path.ToAscii())); + + // Should we boot a new game or just change the disc? + if(Boot) + { + BootManager::BootCore(std::string(path.ToAscii())); + } + else + { + // Get the current ISO name + std::string OldName = SConfig::GetInstance().m_LocalCoreStartupParameter.m_strFilename; + + // Change the iso and make sure it's a valid file + if(!VolumeHandler::SetVolumeName(std::string(path.ToAscii()))) + { + PanicAlert("The file you selected is not a valid ISO file. Please try again."); + + // Put back the old one + VolumeHandler::SetVolumeName(OldName); + } + else + { + // Save the current ISO file name + SConfig::GetInstance().m_LocalCoreStartupParameter.m_strFilename = std::string(path.ToAscii()); + } + } } +void CFrame::OnChangeDisc(wxCommandEvent& WXUNUSED (event)) +{ + DVDInterface::SetLidOpen(true); + DoOpen(false); + DVDInterface::SetLidOpen(false); +} +// ============= + void CFrame::OnQuit(wxCommandEvent& WXUNUSED (event)) { @@ -629,22 +665,38 @@ void CFrame::OnKeyDown(wxKeyEvent& event) } } + +// ======================================================= +// Update the enabled/disabled status +// ------------- void CFrame::UpdateGUI() { + // Save status bool initialized = Core::GetState() != Core::CORE_UNINITIALIZED; bool running = Core::GetState() == Core::CORE_RUN; bool paused = Core::GetState() == Core::CORE_PAUSE; + // Make sure that we have a toolbar if (GetToolBar() != NULL) { + // Enable/disable the Config and Stop buttons GetToolBar()->EnableTool(IDM_CONFIG_MAIN, !initialized); + GetToolBar()->EnableTool(wxID_OPEN, !initialized); GetToolBar()->EnableTool(IDM_STOP, running || paused); } + + // File + m_pMenuItemOpen->Enable(!initialized); + + // Emulation m_pMenuItemStop->Enable(running || paused); m_pMenuItemLoad->Enable(initialized); m_pMenuItemSave->Enable(initialized); m_pPluginOptions->Enable(!running && !paused); + // Misc + m_pMenuChangeDisc->Enable(initialized); + if (running) { if (GetToolBar() != NULL) @@ -686,30 +738,4 @@ void CFrame::UpdateGUI() } } } - -void CFrame::OnSwapDisc(wxCommandEvent& event) -{ - switch (event.GetId()) - { - case IDM_SWAPDISC: - { - SetLidOpen(true); - wxString path = wxFileSelector( - _T("Select the Disc to swap"), - wxEmptyString, wxEmptyString, wxEmptyString, - wxString::Format - ( - _T("All GC/Wii files (elf, dol, gcm, iso)|*.elf;*.dol;*.gcm;*.iso;*.gcz|All files (%s)|%s"), - wxFileSelectorDefaultWildcardStr, - wxFileSelectorDefaultWildcardStr - ), - wxFD_OPEN | wxFD_PREVIEW | wxFD_FILE_MUST_EXIST, - this); - SwapDisc(path.mb_str()); - SetLidOpen(false); - break; - } - default: - SetLidOpen(!IsLidOpen()); - } -} +// ============= \ No newline at end of file diff --git a/Source/Core/DolphinWX/Src/Frame.h b/Source/Core/DolphinWX/Src/Frame.h index 7f1507dce7..3432e903db 100644 --- a/Source/Core/DolphinWX/Src/Frame.h +++ b/Source/Core/DolphinWX/Src/Frame.h @@ -89,21 +89,27 @@ class CFrame : public wxFrame // Override window proc for tricks like screensaver disabling WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); #endif - // event handler + // Event functions void OnQuit(wxCommandEvent& event); void OnHelp(wxCommandEvent& event); + + void OnOpen(wxCommandEvent& event); void DoOpen(bool Boot); // File void OnRefresh(wxCommandEvent& event); - void OnConfigMain(wxCommandEvent& event); + void OnBrowse(wxCommandEvent& event); + + void OnPlay(wxCommandEvent& event); // Emulation + void OnChangeDisc(wxCommandEvent& event); + void OnStop(wxCommandEvent& event); + void OnClose(wxCloseEvent &event); + void OnLoadState(wxCommandEvent& event); + void OnSaveState(wxCommandEvent& event); + + void OnConfigMain(wxCommandEvent& event); // Options void OnPluginGFX(wxCommandEvent& event); void OnPluginDSP(wxCommandEvent& event); void OnPluginPAD(wxCommandEvent& event); void OnPluginWiimote(wxCommandEvent& event); - void OnOpen(wxCommandEvent& event); - void OnPlay(wxCommandEvent& event); - void OnStop(wxCommandEvent& event); - void OnBrowse(wxCommandEvent& event); - void OnMemcard(wxCommandEvent& event); - void OnShow_CheatsWindow(wxCommandEvent& event); + void OnToggleFullscreen(wxCommandEvent& event); void OnToggleDualCore(wxCommandEvent& event); void OnToggleSkipIdle(wxCommandEvent& event); @@ -113,26 +119,26 @@ class CFrame : public wxFrame void OnToggleStatusbar(wxCommandEvent& event); void OnKeyDown(wxKeyEvent& event); void OnHostMessage(wxCommandEvent& event); - void OnLoadState(wxCommandEvent& event); - void OnSaveState(wxCommandEvent& event); - void OnClose(wxCloseEvent &event); - void OnSwapDisc(wxCommandEvent& event); + void OnMemcard(wxCommandEvent& event); // Misc + void OnShow_CheatsWindow(wxCommandEvent& event); + + // Menu items wxMenuBar* m_pMenuBar; - wxMenuItem* m_pMenuItemPlay; - wxMenuItem* m_pMenuItemStop; - wxMenuItem* m_pPluginOptions; + wxMenuItem* m_pMenuItemOpen; // File + wxMenuItem* m_pMenuItemPlay; // Emulation + wxMenuItem* m_pMenuItemStop; + wxMenuItem* m_pMenuChangeDisc; + wxMenuItem* m_pPluginOptions; wxMenuItem* m_pMenuItemLoad; wxMenuItem* m_pMenuItemSave; - wxToolBarToolBase* m_pToolPlay; void UpdateGUI(); - - // old function that could be cool + // Old function that could be cool DECLARE_EVENT_TABLE(); }; diff --git a/Source/Core/DolphinWX/Src/Globals.h b/Source/Core/DolphinWX/Src/Globals.h index f68133bd15..d0b4d56e1e 100644 --- a/Source/Core/DolphinWX/Src/Globals.h +++ b/Source/Core/DolphinWX/Src/Globals.h @@ -21,7 +21,7 @@ #include "Common.h" enum { - IDM_LOADSTATE = 200, + IDM_LOADSTATE = 200, // File IDM_SAVESTATE, IDM_SAVESLOT1, IDM_SAVESLOT2, @@ -46,37 +46,41 @@ enum IDM_PLAY, IDM_STOP, IDM_BROWSE, - IDM_MEMCARD, + + IDM_MEMCARD, // Misc IDM_CHEATS, - IDM_SWAPDISC, - IDM_TOGGLECOVER, + IDM_CHANGEDISC, IDM_PROPERTIES, - IDM_OPENCONTAININGFOLDER, - IDM_SETDEFAULTGCM, - IDM_DELETEGCM, - IDM_COMPRESSGCM, - IDM_MULTICOMPRESSGCM, - IDM_MULTIDECOMPRESSGCM, + + IDM_HELPABOUT, + IDM_HELPWEBSITE, + IDM_HELPGOOGLECODE, + IDM_CONFIG_MAIN, IDM_CONFIG_GFX_PLUGIN, IDM_CONFIG_DSP_PLUGIN, IDM_CONFIG_PAD_PLUGIN, IDM_CONFIG_WIIMOTE_PLUGIN, IDM_TOGGLE_FULLSCREEN, - IDM_TOGGLE_DUALCORE, + + IDM_TOGGLE_DUALCORE, // Other IDM_TOGGLE_SKIPIDLE, IDM_TOGGLE_TOOLBAR, IDM_TOGGLE_STATUSBAR, IDM_NOTIFYMAPLOADED, + IDM_OPENCONTAININGFOLDER, + IDM_SETDEFAULTGCM, + IDM_DELETEGCM, + IDM_COMPRESSGCM, + IDM_MULTICOMPRESSGCM, + IDM_MULTIDECOMPRESSGCM, IDM_UPDATELOGDISPLAY, IDM_UPDATEDISASMDIALOG, IDM_UPDATEGUI, IDM_UPDATESTATUSBAR, IDM_UPDATEBREAKPOINTS, IDM_HOST_MESSAGE, - IDM_HELPABOUT, - IDM_HELPWEBSITE, - IDM_HELPGOOGLECODE, + ID_TOOLBAR = 500, LIST_CTRL = 1000 };