diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index 7ebe837991..ccb1156285 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -374,7 +374,12 @@ namespace BizHawk.MultiClient void SNES_Check(string profile) { if (SNES_prepared.ContainsKey(profile)) return; - string exename = "libsneshawk-" + profile.ToLower() + ".exe"; + + string bits = "32"; + if (Win32.Is64BitOperatingSystem) + bits = "64"; + + string exename = "libsneshawk-" + bits + "-" + profile.ToLower() + ".exe"; string thisDir = PathManager.GetExeDirectoryAbsolute(); string exePath = Path.Combine(thisDir, exename); diff --git a/BizHawk.MultiClient/output/dll/libsneshawk-compatibility.exe b/BizHawk.MultiClient/output/dll/libsneshawk-32-compatibility.exe similarity index 99% rename from BizHawk.MultiClient/output/dll/libsneshawk-compatibility.exe rename to BizHawk.MultiClient/output/dll/libsneshawk-32-compatibility.exe index 9055499c25..bbe4b693fc 100644 Binary files a/BizHawk.MultiClient/output/dll/libsneshawk-compatibility.exe and b/BizHawk.MultiClient/output/dll/libsneshawk-32-compatibility.exe differ diff --git a/BizHawk.MultiClient/output/dll/libsneshawk-performance.exe b/BizHawk.MultiClient/output/dll/libsneshawk-32-performance.exe similarity index 99% rename from BizHawk.MultiClient/output/dll/libsneshawk-performance.exe rename to BizHawk.MultiClient/output/dll/libsneshawk-32-performance.exe index cf63e5d88b..e4edaaefe3 100644 Binary files a/BizHawk.MultiClient/output/dll/libsneshawk-performance.exe and b/BizHawk.MultiClient/output/dll/libsneshawk-32-performance.exe differ diff --git a/BizHawk.MultiClient/output/dll/libsneshawk-64-compatibility.exe b/BizHawk.MultiClient/output/dll/libsneshawk-64-compatibility.exe new file mode 100644 index 0000000000..6bb48d1a0f Binary files /dev/null and b/BizHawk.MultiClient/output/dll/libsneshawk-64-compatibility.exe differ diff --git a/BizHawk.MultiClient/output/dll/libsneshawk-64-performance.exe b/BizHawk.MultiClient/output/dll/libsneshawk-64-performance.exe new file mode 100644 index 0000000000..8412a59e7e Binary files /dev/null and b/BizHawk.MultiClient/output/dll/libsneshawk-64-performance.exe differ diff --git a/BizHawk.Util/Win32.cs b/BizHawk.Util/Win32.cs index a2ef8b929b..9ba504323f 100644 --- a/BizHawk.Util/Win32.cs +++ b/BizHawk.Util/Win32.cs @@ -9,6 +9,38 @@ namespace BizHawk { public static class Win32 { + + public static bool Is64BitProcess { get { return (IntPtr.Size == 8); } } + public static bool Is64BitOperatingSystem { get { return Is64BitProcess || InternalCheckIsWow64(); } } + + [DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)] + [return: MarshalAs(UnmanagedType.Bool)] + private static extern bool IsWow64Process( + [In] IntPtr hProcess, + [Out] out bool wow64Process + ); + + static bool InternalCheckIsWow64() + { + if ((Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor >= 1) || + Environment.OSVersion.Version.Major >= 6) + { + using (var p = System.Diagnostics.Process.GetCurrentProcess()) + { + bool retVal; + if (!IsWow64Process(p.Handle, out retVal)) + { + return false; + } + return retVal; + } + } + else + { + return false; + } + } + [StructLayout(LayoutKind.Sequential, Pack = 1)] public struct RECT { diff --git a/libsnes/bizwinmake.sh b/libsnes/bizwinmake.sh index b559010cc0..29baba8541 100644 --- a/libsnes/bizwinmake.sh +++ b/libsnes/bizwinmake.sh @@ -1,3 +1,3 @@ #!/bin/sh -./bizwinmakeone.sh compatibility \ No newline at end of file +./bizwinmakeone.sh 32 compatibility \ No newline at end of file diff --git a/libsnes/bizwinmakedistro.sh b/libsnes/bizwinmakedistro.sh index 314c03d272..a2de094ed4 100644 --- a/libsnes/bizwinmakedistro.sh +++ b/libsnes/bizwinmakedistro.sh @@ -1,12 +1,12 @@ #!/bin/sh #makes all bsnes binaries for distribution -#TODO - 64bit +#use bizwinmakedistro64.sh for 64bit (dont run it at the same time!) ./bizwinclean.sh -./bizwinmakeone.sh performance compress +./bizwinmakeone.sh 32 performance compress ./bizwinclean.sh -./bizwinmakeone.sh compatibility compress +./bizwinmakeone.sh 32 compatibility compress #leave compatibility built as objs because thats more useful to us while devving diff --git a/libsnes/bizwinmakedistro64.sh b/libsnes/bizwinmakedistro64.sh new file mode 100644 index 0000000000..a4870e22dc --- /dev/null +++ b/libsnes/bizwinmakedistro64.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +#makes all bsnes binaries for distribution +#use bizwinmakedistro64.sh for 64bit (dont run it at the same time!) + +./bizwinclean.sh +./bizwinmakeone.sh 64 performance compress +./bizwinclean.sh +./bizwinmakeone.sh 64 compatibility compress + +#leave compatibility built as objs because thats more useful to us while devving + diff --git a/libsnes/bizwinmakeone.sh b/libsnes/bizwinmakeone.sh index cd43121be0..7a242e4e11 100644 --- a/libsnes/bizwinmakeone.sh +++ b/libsnes/bizwinmakeone.sh @@ -5,22 +5,32 @@ cd bsnes mkdir obj mkdir out +if [ "$1" == "64" ]; then + export cflags64=-m64 ; + export compiler=i686-w64-mingw32-c++.exe +fi + +if [ "$1" == "32" ]; then + export cflags32=-llibco_msvc_win32 ; +fi + #debug: #export BIZWINCFLAGS="-I. -O0 -g -masm=intel -DLIBCO_IMPORT -DLIBCO_MSVC -static-libgcc -static-libstdc++" #not debug -export BIZWINCFLAGS="-I. -O3 -masm=intel -static-libgcc -static-libstdc++" +export BIZWINCFLAGS="-I. -O3 -masm=intel -static-libgcc -static-libstdc++ ${cflags64}" -export TARGET_LIBSNES_LIBDEPS="-L ../libco_msvc_win32/release/ -llibco_msvc_win32 -static-libgcc -static-libstdc++ -Wl,--subsystem,windows" -export profile=$1 +export TARGET_LIBSNES_LIBDEPS="-L ../libco_msvc_win32/release/ -static-libgcc -static-libstdc++ ${cflags64} ${cflags32} -mwindows" +export profile=$2 +export bits=$1 platform=win target=libsnes make -e -j 4 cd .. -filename=libsneshawk-${profile}.exe +filename=libsneshawk-${bits}-${profile}.exe targetdir=../BizHawk.MultiClient/output/dll targetpath=${targetdir}/${filename} cp bsnes/out/${filename} ${targetdir} -if [ "$2" == "compress" ]; then +if [ "$3" == "compress" ]; then upx -9 ${targetpath} ; fi \ No newline at end of file diff --git a/libsnes/bsnes/Makefile b/libsnes/bsnes/Makefile index ad0b445cd5..c1b89f9102 100644 --- a/libsnes/bsnes/Makefile +++ b/libsnes/bsnes/Makefile @@ -37,7 +37,7 @@ else ifeq ($(platform),osx) else ifeq ($(platform),win) link += $(if $(findstring console,$(options)),-mconsole,-mwindows) link += -mthreads -s -luuid -lkernel32 -luser32 -lgdi32 -lcomctl32 -lcomdlg32 -lshell32 -lole32 - link += -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc + link += -enable-auto-import -enable-runtime-pseudo-reloc else unknown_platform: help; endif diff --git a/libsnes/bsnes/target-libsnes/Makefile b/libsnes/bsnes/target-libsnes/Makefile index ac4e7517b5..9ebdc9bde2 100644 --- a/libsnes/bsnes/target-libsnes/Makefile +++ b/libsnes/bsnes/target-libsnes/Makefile @@ -20,12 +20,12 @@ obj/libsnes_pwrap.o: $(ui)/libsnes_pwrap.cpp $(ui)/* build: $(objects) ifeq ($(platform),x) ar rcs out/libsnes.a $(objects) - $(cpp) -o out/libsnes.so -shared -Wl,-soname,libsnes.so.1 $(objects) + $(cpp) -o out/libsnes.so -shared -soname,libsnes.so.1 $(objects) else ifeq ($(platform),osx) ar rcs out/libsnes.a $(objects) $(cpp) -o out/libsnes.dylib -install_name @executable_path/../Libraries/libsnes.dylib -shared -dynamiclib $(objects) else ifeq ($(platform),win) - $(cpp) -o out/libsneshawk-$(profile).exe -Wl $(objects) $(TARGET_LIBSNES_LIBDEPS) + $(cpp) -o out/libsneshawk-$(bits)-$(profile).exe $(objects) $(TARGET_LIBSNES_LIBDEPS) endif install: