From 36f8b9751a5de8548e6ed1f0d62035dd5f54a761 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Sun, 20 Jul 2008 21:20:22 +0000 Subject: [PATCH] Better error messages, Dolphin will create save directories if not present. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@37 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/CPUDetect.cpp | 1 + Source/Core/Common/Src/FileUtil.cpp | 22 ++++++++++++++++++ Source/Core/Common/Src/FileUtil.h | 1 + Source/Core/Core/Src/Core.cpp | 6 ++--- Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp | 10 +++++--- .../Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp | 18 +++++++++++---- Source/Core/DolphinWX/DolphinWX.vcproj | 6 +++++ Source/Core/DolphinWX/src/Main.cpp | 17 ++++++++++---- .../Plugins/Plugin_VideoDX9/Src/D3DBase.cpp | 23 +++++++++++++++---- 9 files changed, 82 insertions(+), 22 deletions(-) diff --git a/Source/Core/Common/Src/CPUDetect.cpp b/Source/Core/Common/Src/CPUDetect.cpp index 718754354d..41f03be964 100644 --- a/Source/Core/Common/Src/CPUDetect.cpp +++ b/Source/Core/Common/Src/CPUDetect.cpp @@ -128,6 +128,7 @@ void CPUInfoStruct::Detect() // Interpret CPU brand string and cache information. if (i == 0x80000001) { + // This block seems bugged. nFeatureInfo2 = CPUInfo[1]; // ECX bSSE5 = (nFeatureInfo2 & (1 << 11)) ? true : false; bLZCNT = (nFeatureInfo2 & (1 << 5)) ? true : false; diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index f8d9b565ff..2c14db9ab1 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -51,3 +51,25 @@ void File::Explore(const std::string &path) ShellExecuteEx(&shex); #endif } + +// Returns true if successful, or path already exists. +bool File::CreateDir(const std::string &path) +{ +#ifdef _WIN32 + if (::CreateDirectory(path.c_str(), NULL)) + { + return true; + } + else + { + DWORD error = GetLastError(); + if (error == ERROR_ALREADY_EXISTS) + { + PanicAlert("%s already exists", path.c_str()); + return true; + } + PanicAlert("Error creating directory: %i", error); + return false; + } +#endif +} \ No newline at end of file diff --git a/Source/Core/Common/Src/FileUtil.h b/Source/Core/Common/Src/FileUtil.h index 85a6933e94..530785f851 100644 --- a/Source/Core/Common/Src/FileUtil.h +++ b/Source/Core/Common/Src/FileUtil.h @@ -10,6 +10,7 @@ public: static void Launch(const std::string &filename); static void Explore(const std::string &path); static bool IsDirectory(const std::string &filename); + static bool CreateDir(const std::string &filename); }; #endif diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 518e609f19..82be0365e6 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -432,11 +432,9 @@ void Callback_VideoCopiedToXFB() idleTicks = newIdleTicks; float t = (float)(Timer.GetTimeDifference()) / 1000.f; - char isoName[64]; - isoName[0] = 0x00; char temp[256]; - sprintf(temp, "%s - FPS: %8.2f - %s - %i MHz (%i real, %i idle skipped) out of %i MHz", - isoName, (float)frames / t, + sprintf(temp, "FPS: %8.2f - %s - %i MHz (%i real, %i idle skipped) out of %i MHz", + (float)frames / t, g_CoreStartupParameter.bUseDynarec ? "JIT" : "Interpreter", (int)(diff), (int)(diff-idleDiff), diff --git a/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp b/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp index 99fbda116c..a3a878469a 100644 --- a/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp +++ b/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp @@ -45,9 +45,13 @@ const unsigned char sram_dump_german[64] ={ 0x00, 0x00, 0x84, 0xFF, 0x00, 0x00, 0x00, 0x00 }; -static const char iplver[0x100] = "(C) 1999-2001 Nintendo. All rights reserved." - "(C) 1999 ArtX Inc. All rights reserved." - "PAL Revision 1.0 "; + +// We should provide an option to choose from the above, or figure out the checksum (the algo in yagcd seems wrong) +// so that people can change default language. + +static const char iplver[0x100] = "(C) 1999-2001 Nintendo. All rights reserved." + "(C) 1999 ArtX Inc. All rights reserved." + "PAL Revision 1.0 "; CEXIIPL::CEXIIPL() : m_uPosition(0), diff --git a/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp b/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp index 3773672bd9..b1ca947f85 100644 --- a/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp +++ b/Source/Core/Core/Src/HW/EXI_DeviceMemoryCard.cpp @@ -15,6 +15,9 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ +#include "Common.h" +#include "FileUtil.h" +#include "StringUtil.h" #include "../Core.h" #include "../CoreTiming.h" @@ -52,7 +55,7 @@ CEXIMemoryCard::CEXIMemoryCard(const std::string& _rName, const std::string& _rF else { LOG(EXPANSIONINTERFACE, "No memory card found. Will create new."); - //MessageBox(0, "Could not read memory card file - starting with corrupt", m_strFilename.c_str(),0); + Flush(); } formatDelay = 0; @@ -66,16 +69,21 @@ void CEXIMemoryCard::Flush() { FILE* pFile = NULL; pFile = fopen(m_strFilename.c_str(), "wb"); - if (pFile) + if (!pFile) { - fwrite(memory_card_content, memory_card_size, 1, pFile); - fclose(pFile); + std::string dir; + SplitPath(m_strFilename, &dir, 0, 0); + File::CreateDir(dir); + pFile = fopen(m_strFilename.c_str(), "wb"); } - else + if (!pFile) //Note - pFile changed inside above if { PanicAlert("Could not write memory card file %s.\n\n" "Are you running Dolphin from a CD/DVD, or is the save file maybe write protected?", m_strFilename.c_str()); + return; } + fwrite(memory_card_content, memory_card_size, 1, pFile); + fclose(pFile); } void CEXIMemoryCard::FlushCallback(u64 userdata, int cyclesLate) diff --git a/Source/Core/DolphinWX/DolphinWX.vcproj b/Source/Core/DolphinWX/DolphinWX.vcproj index 1ab5715ba0..54d8891b98 100644 --- a/Source/Core/DolphinWX/DolphinWX.vcproj +++ b/Source/Core/DolphinWX/DolphinWX.vcproj @@ -28,6 +28,7 @@ > CreateDevice( + adapter, + D3DDEVTYPE_HAL, + wnd, + D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, + // |D3DCREATE_MULTITHREADED /* | D3DCREATE_PUREDEVICE*/, + //D3DCREATE_SOFTWARE_VERTEXPROCESSING , + &d3dpp, &dev ) ) ) + { + MessageBox(wnd, + "Software VP failed too. Upgrade your graphics card.", + "Dolphin Direct3D plugin", MB_OK | MB_ICONERROR); + return E_FAIL; + } } dev->GetDeviceCaps(&caps); dev->GetRenderTarget(0,&backBuffer); @@ -225,7 +239,6 @@ namespace D3D vsMajor = (D3D::caps.VertexShaderVersion >>8) & 0xFF; vsMinor = (D3D::caps.VertexShaderVersion) & 0xFF; - // Device state would normally be set here return S_OK; }