Fix up Windows build errors.

This commit is contained in:
BearOso 2023-01-26 17:06:45 -06:00
parent 65dbcaf2fb
commit 11dd6b1e6d
12 changed files with 109 additions and 76 deletions

View file

@ -745,7 +745,7 @@ void S9xBSXSetStream1 (uint8 count)
path += name;
BSX.sat_stream1.clear();
BSX.sat_stream1.open(path, std::ios::in | std::ios::binary);
BSX.sat_stream1.open(path.c_str(), std::ios::in | std::ios::binary);
if (BSX.sat_stream1.good())
{
BSX.sat_stream1.seekg(0, BSX.sat_stream1.end);
@ -776,7 +776,7 @@ void S9xBSXSetStream2 (uint8 count)
path += name;
BSX.sat_stream2.clear();
BSX.sat_stream2.open(path, std::ios::in | std::ios::binary);
BSX.sat_stream2.open(path.c_str(), std::ios::in | std::ios::binary);
if (BSX.sat_stream2.good())
{
BSX.sat_stream2.seekg(0, BSX.sat_stream2.end);

View file

@ -61,17 +61,17 @@ SplitPath splitpath(string str)
fs::path path(str);
if (path.has_root_name())
output.drive = path.root_name();
output.drive = path.root_name().string();
if (path.has_filename())
{
output.stem = path.stem();
output.ext = path.extension();
output.stem = path.stem().string();
output.ext = path.extension().string();
path.remove_filename();
}
if (!path.empty())
output.dir = path;
output.dir = path.string();
return output;
}

10
port.h
View file

@ -114,6 +114,16 @@ typedef size_t pint;
#define START_EXTERN_C extern "C" {
#define END_EXTERN_C }
#ifndef __WIN32__
#ifndef PATH_MAX
#define PATH_MAX 1024
#endif
#else
#ifndef PATH_MAX
#define PATH_MAX _MAX_PATH
#endif
#endif
#include "fscompat.h"
#ifndef __WIN32__

View file

@ -255,8 +255,8 @@ struct SSettings
bool8 BilinearFilter;
bool8 Multi;
char CartAName[4097];
char CartBName[4097];
char CartAName[PATH_MAX + 1];
char CartBName[PATH_MAX + 1];
bool8 DisableGameSpecificHacks;
bool8 BlockInvalidVRAMAccessMaster;

View file

@ -208,7 +208,7 @@ void CShaderParamDlg::createContent(HWND hDlg)
for(int i = 0; i < shader.param.size(); i++) {
GLSLParam &p = shader.param[i];
TCHAR desc[270];
_stprintf(desc, TEXT("%s [%g-%g]"), (TCHAR*)_tFromChar(p.name), p.min, p.max);
_stprintf(desc, TEXT("%s [%g-%g]"), (TCHAR*)_tFromChar(p.name.c_str()), p.min, p.max);
HWND item = CreateWindow(TEXT("STATIC"), desc, SS_LEFTNOWORDWRAP | WS_VISIBLE | WS_CHILD, desc_left, (INT)(top + avgCharHeight * 0.3), desc_width, avgCharHeight, parent, (HMENU)(UINT_PTR)(IDC_PARAMS_START_STATIC + i), GUI.hInstance, NULL);
SendMessage(item, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(FALSE, 0));
TCHAR val[100];

View file

@ -74,12 +74,12 @@ namespace std {
class u8nifstream: public std::ifstream
{
public:
void __CLR_OR_THIS_CALL open(const char *_Filename, ios_base::open_mode _Mode)
void __CLR_OR_THIS_CALL open(const char *_Filename, ios_base::openmode _Mode)
{
std::ifstream::open(Utf8ToWide(_Filename), (ios_base::openmode)_Mode);
}
void __CLR_OR_THIS_CALL open(const wchar_t *_Filename, ios_base::open_mode _Mode)
void __CLR_OR_THIS_CALL open(const wchar_t *_Filename, ios_base::openmode _Mode)
{
std::ifstream::open(_Filename, (ios_base::openmode)_Mode);
}

View file

@ -563,6 +563,7 @@
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|Win32'">%(AdditionalOptions) /Zm300</AdditionalOptions>
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'">%(AdditionalOptions) /Zm300</AdditionalOptions>
</ClCompile>
<ClCompile Include="..\..\..\external\glslang\glslang\MachineIndependent\SpirvIntrinsics.cpp" />
<ClCompile Include="..\..\..\external\glslang\glslang\MachineIndependent\SymbolTable.cpp">
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalOptions) /Zm300</AdditionalOptions>
<AdditionalOptions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">%(AdditionalOptions) /Zm300</AdditionalOptions>

View file

@ -31,6 +31,7 @@
<ClCompile Include="..\..\..\external\glslang\glslang\GenericCodeGen\CodeGen.cpp" />
<ClCompile Include="..\..\..\external\glslang\glslang\GenericCodeGen\Link.cpp" />
<ClCompile Include="..\..\..\external\glslang\StandAlone\ResourceLimits.cpp" />
<ClCompile Include="..\..\..\external\glslang\glslang\MachineIndependent\SpirvIntrinsics.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\external\glslang\glslang\Public\ShaderLang.h" />

View file

@ -117,7 +117,7 @@
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\;$(ProjectDir)..\..\;$(ProjectDir)zlib\src;$(ProjectDir)..\unzip;$(ProjectDir)libpng\src;$(ProjectDir)..\apu\bapu;$(ProjectDir)..\external\glslang</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\;$(ProjectDir)..\..\;$(ProjectDir)zlib\src;$(ProjectDir)..\unzip;$(ProjectDir)libpng\src;$(ProjectDir)..\apu\bapu;$(ProjectDir)..\external\glslang;;..\external\fmt\include</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_DEBUG;ALLOW_CPU_OVERCLOCK;HAVE_LIBPNG;JMA_SUPPORT;ZLIB;UNZIP_SUPPORT;__WIN32__;NETPLAY_SUPPORT;D3D_DEBUG_INFO;DIRECTDRAW_SUPPORT;USE_SLANG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<StructMemberAlignment>Default</StructMemberAlignment>
@ -132,6 +132,8 @@
<CompileAs>Default</CompileAs>
<ForcedIncludeFiles>_tfwopen.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
<AdditionalOptions>/Zc:__cplusplus $(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -166,7 +168,7 @@
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\;$(ProjectDir)..\..\;$(ProjectDir)zlib\src;$(ProjectDir)..\unzip;$(ProjectDir)libpng\src;$(ProjectDir)..\apu\bapu;$(ProjectDir)..\external\glslang</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\;$(ProjectDir)..\..\;$(ProjectDir)zlib\src;$(ProjectDir)..\unzip;$(ProjectDir)libpng\src;$(ProjectDir)..\apu\bapu;$(ProjectDir)..\external\glslang;;..\external\fmt\include</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_DEBUG;ALLOW_CPU_OVERCLOCK;HAVE_LIBPNG;JMA_SUPPORT;ZLIB;UNZIP_SUPPORT;__WIN32__;NETPLAY_SUPPORT;D3D_DEBUG_INFO;DIRECTDRAW_SUPPORT;USE_SLANG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<StructMemberAlignment>Default</StructMemberAlignment>
@ -181,6 +183,8 @@
<CompileAs>Default</CompileAs>
<ForcedIncludeFiles>_tfwopen.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
<AdditionalOptions>/Zc:__cplusplus $(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -220,7 +224,7 @@
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<WholeProgramOptimization>true</WholeProgramOptimization>
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\;$(ProjectDir)..\..\;$(ProjectDir)zlib\src;$(ProjectDir)..\unzip;$(ProjectDir)libpng\src;$(ProjectDir)..\apu\bapu;$(ProjectDir)..\external\glslang;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\;$(ProjectDir)..\..\;$(ProjectDir)zlib\src;$(ProjectDir)..\unzip;$(ProjectDir)libpng\src;$(ProjectDir)..\apu\bapu;$(ProjectDir)..\external\glslang;%(AdditionalIncludeDirectories);..\external\fmt\include</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;ALLOW_CPU_OVERCLOCK;HAVE_LIBPNG;JMA_SUPPORT;ZLIB;UNZIP_SUPPORT;__WIN32__;NETPLAY_SUPPORT;DIRECTDRAW_SUPPORT;USE_SLANG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@ -236,6 +240,8 @@
<CompileAs>Default</CompileAs>
<ForcedIncludeFiles>_tfwopen.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
<AdditionalOptions>/Zc:__cplusplus $(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -273,7 +279,7 @@
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<WholeProgramOptimization>true</WholeProgramOptimization>
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\;$(ProjectDir)..\..\;$(ProjectDir)zlib\src;$(ProjectDir)..\unzip;$(ProjectDir)libpng\src;$(ProjectDir)..\apu\bapu;$(ProjectDir)..\external\glslang;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)..\;$(ProjectDir)..\..\;$(ProjectDir)zlib\src;$(ProjectDir)..\unzip;$(ProjectDir)libpng\src;$(ProjectDir)..\apu\bapu;$(ProjectDir)..\external\glslang;%(AdditionalIncludeDirectories);..\external\fmt\include</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;ALLOW_CPU_OVERCLOCK;HAVE_LIBPNG;JMA_SUPPORT;ZLIB;UNZIP_SUPPORT;__WIN32__;NETPLAY_SUPPORT;DIRECTDRAW_SUPPORT;USE_SLANG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@ -289,6 +295,8 @@
<CompileAs>Default</CompileAs>
<ForcedIncludeFiles>_tfwopen.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
<AdditionalOptions>/Zc:__cplusplus $(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -350,6 +358,7 @@
<CustomBuild Include="..\gfx.h" />
<ClInclude Include="..\filter\xbrz_config.h" />
<ClInclude Include="..\filter\xbrz_tools.h" />
<ClInclude Include="..\fscompat.h" />
<ClInclude Include="..\jma\7z.h" />
<ClInclude Include="..\jma\aribitcd.h" />
<ClInclude Include="..\jma\ariconst.h" />
@ -486,12 +495,14 @@
<ClCompile Include="..\dsp2.cpp" />
<ClCompile Include="..\dsp3.cpp" />
<ClCompile Include="..\dsp4.cpp" />
<ClCompile Include="..\external\fmt\src\format.cc" />
<ClCompile Include="..\filter\2xsai.cpp" />
<ClCompile Include="..\filter\blit.cpp" />
<ClCompile Include="..\filter\epx.cpp" />
<ClCompile Include="..\filter\hq2x.cpp" />
<ClCompile Include="..\filter\snes_ntsc.c" />
<ClCompile Include="..\filter\xbrz.cpp" />
<ClCompile Include="..\fscompat.cpp" />
<ClCompile Include="..\fxdbg.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Unicode|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Unicode|x64'">true</ExcludedFromBuild>
@ -747,4 +758,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View file

@ -43,6 +43,9 @@
<Filter Include="Shaders">
<UniqueIdentifier>{31758447-7e76-4af0-8561-a377194049e1}</UniqueIdentifier>
</Filter>
<Filter Include="fmtlib">
<UniqueIdentifier>{07a3a904-2263-4912-80ea-c31a0e4c78c5}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\statemanager.h">
@ -288,6 +291,9 @@
<ClInclude Include="CSaveLoadWithPreviewDlg.h">
<Filter>GUI</Filter>
</ClInclude>
<ClInclude Include="..\fscompat.h">
<Filter>Emu</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\bsx.cpp">
@ -629,6 +635,12 @@
<ClCompile Include="CSaveLoadWithPreviewDlg.cpp">
<Filter>GUI</Filter>
</ClCompile>
<ClCompile Include="..\external\fmt\src\format.cc">
<Filter>fmtlib</Filter>
</ClCompile>
<ClCompile Include="..\fscompat.cpp">
<Filter>Emu</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="rsrc\nodrop.cur">
@ -886,4 +898,4 @@
</CustomBuild>
<CustomBuild Include="snes9x.cfg" />
</ItemGroup>
</Project>
</Project>

View file

@ -100,9 +100,9 @@ const char *S9xGetFilename (const char *ex, enum s9x_getdirtype dirtype)
char drive [_MAX_DRIVE + 1];
char fname [_MAX_FNAME + 1];
char ext [_MAX_EXT + 1];
_splitpath (Memory.ROMFilename, drive, dir, fname, ext);
_splitpath (Memory.ROMFilename.c_str(), drive, dir, fname, ext);
_snprintf(filename, sizeof(filename), "%s" SLASH_STR "%s%s",
S9xGetDirectory(dirtype), fname, ex);
S9xGetDirectory(dirtype).c_str(), fname, ex);
return (filename);
}
@ -172,7 +172,7 @@ const TCHAR *S9xGetDirectoryT (enum s9x_getdirtype dirtype)
break;
case ROMFILENAME_DIR: {
lstrcpy(filename, _tFromChar(Memory.ROMFilename));
lstrcpy(filename, _tFromChar(Memory.ROMFilename.c_str()));
if(!filename[0])
rv = GUI.RomDir;
for(int i=lstrlen(filename); i>=0; i--){
@ -198,7 +198,7 @@ const TCHAR *S9xGetDirectoryT (enum s9x_getdirtype dirtype)
return rv;
}
const char *S9xGetDirectory (enum s9x_getdirtype dirtype)
std::string S9xGetDirectory (enum s9x_getdirtype dirtype)
{
static char path[PATH_MAX]={0};
strncpy(path,_tToChar(S9xGetDirectoryT(dirtype)),PATH_MAX-1);
@ -206,7 +206,7 @@ const char *S9xGetDirectory (enum s9x_getdirtype dirtype)
return path;
}
const char *S9xGetFilenameInc (const char *e, enum s9x_getdirtype dirtype)
std::string S9xGetFilenameInc (std::string e, enum s9x_getdirtype dirtype)
{
static char filename [PATH_MAX + 1];
char dir [_MAX_DIR + 1];
@ -216,10 +216,12 @@ const char *S9xGetFilenameInc (const char *e, enum s9x_getdirtype dirtype)
unsigned int i=0;
const char *d;
_splitpath (Memory.ROMFilename, drive, dir, fname, ext);
d=S9xGetDirectory(dirtype);
_splitpath (Memory.ROMFilename.c_str(), drive, dir, fname, ext);
std::string directory_string = S9xGetDirectory(dirtype);
d = directory_string.c_str();
do {
_snprintf(filename, sizeof(filename), "%s\\%s%03d%s", d, fname, i, e);
_snprintf(filename, sizeof(filename), "%s\\%s%03d%s", d, fname, i, e.c_str());
i++;
} while(_taccess (_tFromChar(filename), 0) == 0 && i!=0);

View file

@ -704,7 +704,7 @@ void S9xRestoreWindowTitle ()
if (Memory.ROMFilename[0])
{
char def[_MAX_FNAME];
_splitpath(Memory.ROMFilename, NULL, NULL, def, NULL);
_splitpath(Memory.ROMFilename.c_str(), NULL, NULL, def, NULL);
_stprintf(buf, TEXT("%s - %s %s"), (wchar_t *)Utf8ToWide(def), WINDOW_TITLE, TEXT(VERSION));
}
else
@ -1439,10 +1439,10 @@ bool WinMoviePlay(LPCTSTR filename)
return false;
}
while (info.ROMCRC32 != Memory.ROMCRC32 || strcmp(info.ROMName, Memory.RawROMName) != 0) {
while (info.ROMCRC32 != Memory.ROMCRC32) {
TCHAR temp[512];
wsprintf(temp, TEXT("Movie's ROM: crc32=%08X, name=%s\nCurrent ROM: crc32=%08X, name=%s\n\nstill want to play the movie?"),
info.ROMCRC32, _tFromMS932(info.ROMName), Memory.ROMCRC32, _tFromMS932(Memory.RawROMName));
wsprintf(temp, TEXT("Movie's ROM: crc32=%08X, name=%s\nCurrent ROM: crc32=%08X\n\nstill want to play the movie?"),
info.ROMCRC32, _tFromMS932(info.ROMName), Memory.ROMCRC32);
int sel = MessageBox(GUI.hWnd, temp, SNES9X_INFO, MB_ABORTRETRYIGNORE|MB_ICONQUESTION);
switch (sel) {
case IDABORT:
@ -2137,18 +2137,18 @@ LRESULT CALLBACK WinProc(
S9xMessage(S9X_INFO, 0, INFO_SAVE_SPC);
break;
case ID_FILE_SAVE_SRAM_DATA: {
bool8 success = Memory.SaveSRAM (S9xGetFilename (".srm", SRAM_DIR));
bool8 success = Memory.SaveSRAM (S9xGetFilename (".srm", SRAM_DIR).c_str());
if(!success)
S9xMessage(S9X_ERROR, S9X_FREEZE_FILE_INFO, SRM_SAVE_FAILED);
} break;
case ID_SAVEMEMPACK: {
const char *filename = S9xGetFilenameInc(".bs", SRAM_DIR);
bool8 success = Memory.SaveMPAK(filename);
std::string filename = S9xGetFilenameInc(".bs", SRAM_DIR);
bool8 success = Memory.SaveMPAK(filename.c_str());
if (!success)
S9xMessage(S9X_ERROR, 0, MPAK_SAVE_FAILED);
else
{
sprintf(String, "Saved Memory Pack %s", filename);
sprintf(String, "Saved Memory Pack %s", filename.c_str());
S9xMessage(S9X_INFO, 0, String);
}
} break;
@ -2229,8 +2229,8 @@ LRESULT CALLBACK WinProc(
S9xCheatsEnable ();
bool on = false;
extern struct SCheatData Cheat;
for (uint32 i = 0; i < Cheat.g.size() && !on; i++)
if (Cheat.g [i].enabled)
for (uint32 i = 0; i < Cheat.group.size() && !on; i++)
if (Cheat.group[i].enabled)
on = true;
S9xMessage (S9X_INFO, S9X_GAME_GENIE_CODE_ERROR, on ? CHEATS_INFO_ENABLED : CHEATS_INFO_ENABLED_NONE);
}
@ -2330,7 +2330,7 @@ LRESULT CALLBACK WinProc(
break;
case WM_DESTROY:
Memory.SaveSRAM(S9xGetFilename(".srm", SRAM_DIR));
Memory.SaveSRAM(S9xGetFilename(".srm", SRAM_DIR).c_str());
GUI.hWnd = NULL;
PostQuitMessage (0);
return (0);
@ -3596,8 +3596,8 @@ loop_exit:
if (!Settings.StopEmulation)
{
Memory.SaveSRAM (S9xGetFilename (".srm", SRAM_DIR));
S9xSaveCheatFile (S9xGetFilename (".cht", CHEAT_DIR));
Memory.SaveSRAM (S9xGetFilename (".srm", SRAM_DIR).c_str());
S9xSaveCheatFile (S9xGetFilename (".cht", CHEAT_DIR).c_str());
}
//if (!VOODOO_MODE && !GUI.FullScreen)
// GetWindowRect (GUI.hWnd, &GUI.window_size);
@ -3681,7 +3681,7 @@ void GetSlotFilename(int slot, char filename[_MAX_PATH + 1])
strcpy(ext, ".oops");
else
snprintf(ext, _MAX_EXT, ".%03d", slot);
strcpy(filename, S9xGetFilename(ext, SNAPSHOT_DIR));
strcpy(filename, S9xGetFilename(ext, SNAPSHOT_DIR).c_str());
}
void FreezeUnfreezeSlot(int slot, bool8 freeze)
@ -4087,8 +4087,8 @@ static bool LoadROM(const TCHAR *filename, const TCHAR *filename2 /*= NULL*/) {
#endif
if (!Settings.StopEmulation) {
Memory.SaveSRAM (S9xGetFilename (".srm", SRAM_DIR));
S9xSaveCheatFile (S9xGetFilename (".cht", CHEAT_DIR));
Memory.SaveSRAM (S9xGetFilename (".srm", SRAM_DIR).c_str());
S9xSaveCheatFile (S9xGetFilename (".cht", CHEAT_DIR).c_str());
}
if(filename2)
@ -4097,12 +4097,12 @@ static bool LoadROM(const TCHAR *filename, const TCHAR *filename2 /*= NULL*/) {
Settings.StopEmulation = !LoadROMPlain(filename);
if (!Settings.StopEmulation) {
bool8 loadedSRAM = Memory.LoadSRAM (S9xGetFilename (".srm", SRAM_DIR));
bool8 loadedSRAM = Memory.LoadSRAM (S9xGetFilename (".srm", SRAM_DIR).c_str());
if(!loadedSRAM) // help migration from earlier Snes9x versions by checking ROM directory for savestates
Memory.LoadSRAM (S9xGetFilename (".srm", ROMFILENAME_DIR));
Memory.LoadSRAM (S9xGetFilename (".srm", ROMFILENAME_DIR).c_str());
if(!filename2) // no recent for multi cart
S9xAddToRecentGames (filename);
CheckDirectoryIsWritable (S9xGetFilename (".---", SNAPSHOT_DIR));
CheckDirectoryIsWritable (S9xGetFilename (".---", SNAPSHOT_DIR).c_str());
#ifdef NETPLAY_SUPPORT
if (NPServer.SendROMImageOnConnect)
@ -4335,7 +4335,7 @@ void S9xSetRecentGames ()
// append the game title to name, with formatting modifications as necessary
{
TCHAR baseName [256];
lstrcpy (baseName, _tFromChar(S9xBasename (_tToChar(GUI.RecentGames [i]))));
lstrcpy (baseName, _tFromChar(S9xBasename (std::string(_tToChar(GUI.RecentGames [i]))).c_str()));
int pos = lstrlen (name), baseNameLen = lstrlen (baseName);
for (int j = 0; j < baseNameLen ; j++)
{
@ -4771,7 +4771,7 @@ INT_PTR CALLBACK DlgInfoProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
char temp[100];
char romtext[4096];
sprintf(romtext, "File: %s\r\nName: %s\r\n", Memory.ROMFilename, Memory.RawROMName);
sprintf(romtext, "File: %s\r\n", Memory.ROMFilename);
sprintf(temp, "Speed: %02X/%s\r\nROM Map: %s\r\nType: %02x\r\n", Memory.ROMSpeed, ((Memory.ROMSpeed&0x10)!=0)?"FastROM":"SlowROM",(Memory.HiROM)?"HiROM":"LoROM",Memory.ROMType);
strcat(romtext, temp);
strcat(romtext, "Kart contents: ");
@ -6453,7 +6453,7 @@ INT_PTR CALLBACK DlgOpenROMProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara
memset(&lvfi, 0, sizeof(LVFINDINFO));
TCHAR filename[_MAX_PATH];
TCHAR *tmp, *tmp2;
lstrcpy(filename,_tFromChar(Memory.ROMFilename));
lstrcpy(filename,_tFromChar(Memory.ROMFilename.c_str()));
tmp = filename;
while(tmp2=_tcsstr(tmp, TEXT("\\")))
tmp=tmp2+sizeof(TCHAR);
@ -7759,7 +7759,7 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
GUI.filterMessagFont = (bool)(IsDlgButtonChecked(hDlg, IDC_MESSAGES_SCALE) == BST_CHECKED);
if(Settings.AutoDisplayMessages)
{
if(!GFX.InfoString || !*GFX.InfoString){
if(GFX.InfoString.empty()) {
GFX.InfoString = "Test message!";
GFX.InfoStringTimeout = 1;
}
@ -8796,15 +8796,14 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
ListView_InsertColumn(GetDlgItem(hDlg,IDC_CHEAT_LIST), 1, &col);
ct.state.resize(Cheat.g.size());
ct.state.resize(Cheat.group.size());
for(uint32 counter =0; counter < Cheat.g.size(); counter++)
for(uint32 counter =0; counter < Cheat.group.size(); counter++)
{
char *code_string;
std::string code_string;
int curr_idx = -1;
code_string = S9xCheatGroupToText(counter);
Utf8ToWide wstring(code_string);
delete[] code_string;
Utf8ToWide wstring(code_string.c_str());
LVITEM lvi;
memset(&lvi, 0, sizeof(LVITEM));
@ -8817,7 +8816,7 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
ct.state[counter] = Untouched;
Utf8ToWide wstring_name(Cheat.g[counter].name);
Utf8ToWide wstring_name(Cheat.group[counter].name.c_str());
memset(&lvi, 0, sizeof(LVITEM));
lvi.iItem = curr_idx;
lvi.iSubItem = 1;
@ -8826,7 +8825,7 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
lvi.pszText = wstring_name;
SendDlgItemMessage(hDlg,IDC_CHEAT_LIST, LVM_SETITEM, 0, (LPARAM)&lvi);
ListView_SetCheckState(GetDlgItem(hDlg,IDC_CHEAT_LIST), curr_idx, Cheat.g[counter].enabled);
ListView_SetCheckState(GetDlgItem(hDlg,IDC_CHEAT_LIST), curr_idx, Cheat.group[counter].enabled);
}
return true;
@ -8910,12 +8909,11 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
GetDlgItemTextA(hDlg, IDC_CHEAT_CODE, temp, CHEAT_SIZE);
GetDlgItemText(hDlg, IDC_CHEAT_DESCRIPTION, tempDesc, CHEAT_SIZE);
char *valid_cheat = S9xCheatValidate (temp);
std::string valid_cheat = S9xCheatValidate(temp);
if(valid_cheat)
if(!valid_cheat.empty())
{
Utf8ToWide wstring(valid_cheat);
delete[] valid_cheat;
Utf8ToWide wstring(valid_cheat.c_str());
int curr_idx = -1;
@ -8951,12 +8949,10 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
char code[CHEAT_SIZE];
GetDlgItemTextA(hDlg, IDC_CHEAT_CODE, code, CHEAT_SIZE);
char *valid_cheat = S9xCheatValidate(code);
std::string valid_cheat = S9xCheatValidate(code);
if(valid_cheat)
if(!valid_cheat.empty())
{
delete[] valid_cheat;
Utf8ToWide wstring(code);
LVITEM lvi;
@ -9021,7 +9017,7 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
break;
}
ListView_DeleteAllItems(GetDlgItem(hDlg, IDC_CHEAT_LIST));
for (unsigned int j = 0; j < Cheat.g.size(); j++)
for (unsigned int j = 0; j < Cheat.group.size(); j++)
{
ct.state[j] = Deleted;
}
@ -9062,7 +9058,7 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
char *valid_cheat = NULL;
GetDlgItemTextA(hDlg, IDC_CHEAT_CODE, temp, CHEAT_SIZE);
if (temp && temp[0] && (valid_cheat = S9xCheatValidate(temp)))
if (temp && temp[0] && (!S9xCheatValidate(temp).empty()))
{
if (has_sel)
EnableWindow(GetDlgItem(hDlg, IDC_UPDATE_CHEAT), true);
@ -9122,7 +9118,7 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
WideToUtf8 code(wcode);
WideToUtf8 description(wdescription);
S9xModifyCheatGroup(internal_index, description, code);
S9xModifyCheatGroup(internal_index, std::string(description), std::string(code));
}
// set core state according to checkbox
@ -9155,7 +9151,7 @@ INT_PTR CALLBACK DlgCheater(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
WideToUtf8 code(wcode);
WideToUtf8 description(wdescription);
int index = S9xAddCheatGroup(description, code);
int index = S9xAddCheatGroup(std::string(description), std::string(code));
if (index >= 0)
if (ListView_GetCheckState(GetDlgItem(hDlg, IDC_CHEAT_LIST), k))
@ -10572,7 +10568,7 @@ INT_PTR CALLBACK DlgOpenMovie(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
TCHAR dir [_MAX_DIR + 1];
TCHAR fname [_MAX_FNAME + 1];
TCHAR ext [_MAX_EXT + 1];
_tsplitpath (_tFromChar(Memory.ROMFilename), drive, dir, fname, ext);
_tsplitpath (_tFromChar(Memory.ROMFilename.c_str()), drive, dir, fname, ext);
_tmakepath (filename, TEXT(""), TEXT(""), fname, TEXT("smv"));
SetWindowText(GetDlgItem(hDlg, IDC_MOVIE_PATH), filename);
set_movieinfo(filename, hDlg);
@ -10669,7 +10665,7 @@ INT_PTR CALLBACK DlgOpenMovie(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
// checks if the currently loaded ROM has an SRAM file in the saves directory that we have write access to
static bool existsSRAM ()
{
return(!access(S9xGetFilename(".srm", SRAM_DIR), R_OK|W_OK));
return(!access(S9xGetFilename(".srm", SRAM_DIR).c_str(), R_OK | W_OK));
}
INT_PTR CALLBACK DlgCreateMovie(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
@ -10689,7 +10685,7 @@ INT_PTR CALLBACK DlgCreateMovie(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara
// have to save here or the SRAM file might not exist when we check for it
// (which would cause clear SRAM option to not work)
Memory.SaveSRAM(S9xGetFilename (".srm", SRAM_DIR));
Memory.SaveSRAM(S9xGetFilename (".srm", SRAM_DIR).c_str());
op=(OpenMovieParams*)lParam;
@ -10711,7 +10707,7 @@ INT_PTR CALLBACK DlgCreateMovie(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara
TCHAR dir [_MAX_DIR + 1];
TCHAR fname [_MAX_FNAME + 1];
TCHAR ext [_MAX_EXT + 1];
_tsplitpath (_tFromChar(Memory.ROMFilename), drive, dir, fname, ext);
_tsplitpath (_tFromChar(Memory.ROMFilename.c_str()), drive, dir, fname, ext);
_tmakepath (filename, TEXT(""), TEXT(""), fname, TEXT("smv"));
SetWindowText(GetDlgItem(hDlg, IDC_MOVIE_PATH), filename);
}
@ -10799,9 +10795,9 @@ INT_PTR CALLBACK DlgCreateMovie(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPara
if(IsDlgButtonChecked(hDlg, IDC_CLEARSRAM) && IsDlgButtonChecked(hDlg, IDC_RECORD_RESET) && existsSRAM())
{
GUI.MovieClearSRAM = TRUE;
remove(S9xGetFilename (".srm", SRAM_DIR)); // delete SRAM if it exists (maybe unnecessary?)
remove(S9xGetFilename (".srm", ROMFILENAME_DIR));
Memory.LoadSRAM(S9xGetFilename (".srm", SRAM_DIR)); // refresh memory (hard reset)
remove(S9xGetFilename (".srm", SRAM_DIR).c_str()); // delete SRAM if it exists (maybe unnecessary?)
remove(S9xGetFilename (".srm", ROMFILENAME_DIR).c_str());
Memory.LoadSRAM(S9xGetFilename (".srm", SRAM_DIR).c_str()); // refresh memory (hard reset)
}
else if(!IsDlgButtonChecked(hDlg, IDC_CLEARSRAM) && IsDlgButtonChecked(hDlg, IDC_RECORD_RESET) && existsSRAM())
{
@ -10955,9 +10951,9 @@ void S9xPostRomInit()
{
S9xCheatsEnable();
extern struct SCheatData Cheat;
for (uint32 i = 0; i < Cheat.g.size(); i++)
for (uint32 i = 0; i < Cheat.group.size(); i++)
{
if (Cheat.g [i].enabled)
if (Cheat.group[i].enabled)
{
char String2 [1024];
sprintf(String2, "(CHEATS ARE ON!) %s", String);