Skip to content

Commit

Permalink
Fix up Windows build errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
bearoso committed Mar 7, 2023
1 parent 65dbcaf commit 11dd6b1
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 76 deletions.
4 changes: 2 additions & 2 deletions bsx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions fscompat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 10 additions & 0 deletions port.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down
4 changes: 2 additions & 2 deletions snes9x.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion win32/CShaderParamDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions win32/_tfwopen.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions win32/glslang/glslang/glslang.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
1 change: 1 addition & 0 deletions win32/glslang/glslang/glslang.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
21 changes: 16 additions & 5 deletions win32/snes9xw.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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" />
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -747,4 +758,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
14 changes: 13 additions & 1 deletion win32/snes9xw.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -886,4 +898,4 @@
</CustomBuild>
<CustomBuild Include="snes9x.cfg" />
</ItemGroup>
</Project>
</Project>
18 changes: 10 additions & 8 deletions win32/win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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--){
Expand All @@ -198,15 +198,15 @@ 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);

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];
Expand All @@ -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);

Expand Down
Loading

0 comments on commit 11dd6b1

Please sign in to comment.