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
This commit is contained in:
John Peterson 2008-12-23 08:47:37 +00:00
parent 5464f2274a
commit 62fff80925
8 changed files with 164 additions and 115 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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)

View File

@ -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);

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Version="9,00"
Name="DolphinWX"
ProjectGUID="{A72606EF-C5C1-4954-90AD-F0F93A8D97D9}"
RootNamespace="DolphinWX"
@ -55,7 +55,7 @@
Optimization="3"
InlineFunctionExpansion="0"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\DiscIO\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\DebuggerWX\src"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\Common\Src;..\Core\Src;..\DiscIO\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\DebuggerWX\src"
PreprocessorDefinitions="WIN32;__WXMSW__;_WINDOWS;NOPCH;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
StringPooling="false"
RuntimeLibrary="0"
@ -170,7 +170,7 @@
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="false"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\DiscIO\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\DebuggerWX\src"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\Common\Src;..\Core\Src;..\DiscIO\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\DebuggerWX\src"
PreprocessorDefinitions="WIN32;__WXMSW__;_WINDOWS;NOPCH;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS"
StringPooling="true"
RuntimeLibrary="0"
@ -278,7 +278,7 @@
Name="VCCLCompilerTool"
AdditionalOptions="/EHsc "
Optimization="0"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\DiscIO\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\DebuggerWX\src"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\Common\Src;..\Core\Src;..\DiscIO\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\DebuggerWX\src"
PreprocessorDefinitions="WIN32;_DEBUG;__WXMSW__;__WXDEBUG__;_WINDOWS;NOPCH;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -387,7 +387,7 @@
Name="VCCLCompilerTool"
AdditionalOptions="/EHsc "
Optimization="0"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\DiscIO\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\DebuggerWX\src"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\Common\Src;..\Core\Src;..\DiscIO\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\DebuggerWX\src"
PreprocessorDefinitions="WIN32;_DEBUG;__WXMSW__;__WXDEBUG__;_WINDOWS;NOPCH;_SECURE_SCL=0"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -498,7 +498,7 @@
Optimization="2"
InlineFunctionExpansion="1"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..\Common\Src;..\Core\Src;..\DiscIO\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\DebuggerWX\src"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\Common\Src;..\Core\Src;..\DiscIO\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\DebuggerWX\src"
PreprocessorDefinitions="WIN32;__WXMSW__;_WINDOWS;NOPCH;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
StringPooling="true"
RuntimeLibrary="0"
@ -612,7 +612,7 @@
InlineFunctionExpansion="1"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
AdditionalIncludeDirectories="..\..\..\Externals\LZO;..\Common\Src;..\Core\Src;..\DiscIO\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\DebuggerWX\src"
AdditionalIncludeDirectories="..\..\PluginSpecs;..\..\..\Externals\LZO;..\Common\Src;..\Core\Src;..\DiscIO\Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\DebuggerWX\src"
PreprocessorDefinitions="DEBUGFAST;WIN32;__WXMSW__;_WINDOWS;NOPCH;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS"
StringPooling="true"
RuntimeLibrary="0"

View File

@ -15,25 +15,26 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Globals.h"
#include "Globals.h" // Local
#include "Frame.h"
#include "FileUtil.h"
#include "GameListCtrl.h"
#include "BootManager.h"
#include "Common.h"
#include "Config.h"
#include "Core.h"
#include "HW/DVDInterface.h"
#include "State.h"
#include "ConfigMain.h"
#include "PluginManager.h"
#include "MemcardManager.h"
#include "CheatsWindow.h"
#include "AboutDolphin.h"
#include "GameListCtrl.h"
#include "BootManager.h"
#include <wx/mstream.h>
#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 <wx/mstream.h> // 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);
@ -259,7 +253,7 @@ void CFrame::CreateMenu()
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;
}
// 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());
}
}
// =============

View File

@ -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();
};

View File

@ -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
};