diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/LibGambatte.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/LibGambatte.cs
index 4dfb591cb2..aa9dab97e2 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/LibGambatte.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/LibGambatte.cs
@@ -140,7 +140,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
/// combination of button flags used by the input callback
///
[Flags]
- public enum Buttons
+ public enum Buttons: uint
{
A = 0x01,
B = 0x02,
@@ -333,12 +333,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern bool gambatte_newstateload(IntPtr core, byte[] data, int len);
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- public delegate void DataFunction(IntPtr data, int length, string name);
-
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- public delegate void SectionFunction(string name);
-
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void gambatte_newstatesave_ex(IntPtr core, ref TextStateFPtrs ff);
diff --git a/libgambatte/Makefile b/libgambatte/Makefile
index 1d57f948ab..152f913d1d 100644
--- a/libgambatte/Makefile
+++ b/libgambatte/Makefile
@@ -1,11 +1,25 @@
CXX = g++
-#CXXFLAGS = -Wall -I -Wno-multichar -O3
-CXXFLAGS = -Wall -Iinclude -Isrc -O3 -std=c++11 -fomit-frame-pointer -fno-exceptions
-TARGET = libgambatte.dll
-LDFLAGS = -shared -static-libgcc -static-libstdc++ $(CXXFLAGS)
RM = rm
CP = cp
+MACHINE = $(shell $(CXX) -dumpmachine)
+ifneq (,$(findstring i686,$(MACHINE)))
+ ARCH = 32
+else ifneq (,$(findstring x86_64,$(MACHINE)))
+ ARCH = 64
+else
+ $(error Unknown arch)
+endif
+
+CXXFLAGS = -Wall -Iinclude -Isrc -O3 -std=c++11 -fno-exceptions -flto
+TARGET = libgambatte.dll
+LDFLAGS_32 = -static -static-libgcc -static-libstdc++
+LDFLAGS_64 =
+LDFLAGS = -shared $(LDFLAGS_$(ARCH)) $(CXXFLAGS)
+
+DEST_32 = ../output/dll
+DEST_64 = ../output64/dll
+
SRCS = \
src/cinterface.cpp \
src/cpu.cpp \
@@ -49,4 +63,4 @@ clean:
$(RM) $(TARGET)
install:
- $(CP) $(TARGET) ../output/dll
+ $(CP) $(TARGET) $(DEST_$(ARCH))
diff --git a/libgambatte/libgambatte.sln b/libgambatte/libgambatte.sln
index 00dac72925..fe5fec1e4a 100644
--- a/libgambatte/libgambatte.sln
+++ b/libgambatte/libgambatte.sln
@@ -6,13 +6,19 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5D630682-7BDA-474D-B387-0EB420DDC199}.Debug|Win32.ActiveCfg = Debug|Win32
{5D630682-7BDA-474D-B387-0EB420DDC199}.Debug|Win32.Build.0 = Debug|Win32
+ {5D630682-7BDA-474D-B387-0EB420DDC199}.Debug|x64.ActiveCfg = Debug|x64
+ {5D630682-7BDA-474D-B387-0EB420DDC199}.Debug|x64.Build.0 = Debug|x64
{5D630682-7BDA-474D-B387-0EB420DDC199}.Release|Win32.ActiveCfg = Release|Win32
{5D630682-7BDA-474D-B387-0EB420DDC199}.Release|Win32.Build.0 = Release|Win32
+ {5D630682-7BDA-474D-B387-0EB420DDC199}.Release|x64.ActiveCfg = Release|x64
+ {5D630682-7BDA-474D-B387-0EB420DDC199}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/libgambatte/libgambatte.vcxproj b/libgambatte/libgambatte.vcxproj
index a61ab0e8fc..a0a7b5eb34 100644
--- a/libgambatte/libgambatte.vcxproj
+++ b/libgambatte/libgambatte.vcxproj
@@ -5,10 +5,18 @@
Debug
Win32
+
+ Debug
+ x64
+
Release
Win32
+
+ Release
+ x64
+
{5D630682-7BDA-474D-B387-0EB420DDC199}
@@ -21,28 +29,51 @@
true
Unicode
+
+ DynamicLibrary
+ true
+ Unicode
+
DynamicLibrary
false
true
Unicode
+
+ DynamicLibrary
+ false
+ true
+ Unicode
+
+
+
+
+
+
+
true
+
+ true
+
false
+
+ false
+
@@ -61,6 +92,24 @@
copy /y $(TargetDir)$(TargetFileName) $(ProjectDir)..\output\dll\$(TargetFileName)
+
+
+
+
+ Level3
+ Disabled
+ WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBGAMBATTE_EXPORTS;%(PreprocessorDefinitions)
+ include;src;src\common
+ 4244;4373;4800;4804
+
+
+ Windows
+ true
+
+
+ copy /y $(TargetDir)$(TargetFileName) $(ProjectDir)..\output64\dll\$(TargetFileName)
+
+
Level3
@@ -83,6 +132,28 @@
copy /y $(TargetDir)$(TargetFileName) $(ProjectDir)..\output\dll\$(TargetFileName)
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBGAMBATTE_EXPORTS;%(PreprocessorDefinitions)
+ include;src;src\common
+ 4244;4373;4800;4804
+
+
+ Windows
+ true
+ true
+ true
+
+
+ copy /y $(TargetDir)$(TargetFileName) $(ProjectDir)..\output64\dll\$(TargetFileName)
+
+
diff --git a/libgambatte/src/cinterface.cpp b/libgambatte/src/cinterface.cpp
index c3ca84feb2..c224fdf725 100644
--- a/libgambatte/src/cinterface.cpp
+++ b/libgambatte/src/cinterface.cpp
@@ -35,15 +35,15 @@ GBEXPORT int gambatte_load(GB *g, const char *romfiledata, unsigned romfilelengt
return ret;
}
-GBEXPORT long gambatte_runfor(GB *g, short *soundbuf, unsigned *samples)
+GBEXPORT int gambatte_runfor(GB *g, short *soundbuf, unsigned *samples)
{
unsigned sampv = *samples;
- long ret = g->runFor((unsigned int *) soundbuf, sampv);
+ int ret = g->runFor((unsigned int *) soundbuf, sampv);
*samples = sampv;
return ret;
}
-GBEXPORT void gambatte_blitto(GB *g, unsigned long *videobuf, int pitch)
+GBEXPORT void gambatte_blitto(GB *g, unsigned int *videobuf, int pitch)
{
g->blitTo((unsigned int *)videobuf, pitch);
}
@@ -134,21 +134,21 @@ GBEXPORT int gambatte_savesavedatalength(GB *g)
return g->saveSavedataLength();
}
-GBEXPORT long gambatte_newstatelen(GB *g)
+GBEXPORT int gambatte_newstatelen(GB *g)
{
NewStateDummy dummy;
g->SyncState(&dummy);
return dummy.GetLength();
}
-GBEXPORT int gambatte_newstatesave(GB *g, char *data, long len)
+GBEXPORT int gambatte_newstatesave(GB *g, char *data, int len)
{
NewStateExternalBuffer saver(data, len);
g->SyncState(&saver);
return !saver.Overflow() && saver.GetLength() == len;
}
-GBEXPORT int gambatte_newstateload(GB *g, const char *data, long len)
+GBEXPORT int gambatte_newstateload(GB *g, const char *data, int len)
{
NewStateExternalBuffer loader((char *)data, len);
g->SyncState(&loader);