Merge pull request #70 from edorax/master

Some fixes for MSVC.
This commit is contained in:
Rafael Kitover 2017-02-11 08:02:02 -08:00 committed by GitHub
commit 98718f2094
18 changed files with 98 additions and 34 deletions

View File

@ -64,6 +64,10 @@ ENDIF()
OPTION(ENABLE_LTO "Compile with Link Time Optimization (gcc and clang only)" ${LTO_DEFAULT}) OPTION(ENABLE_LTO "Compile with Link Time Optimization (gcc and clang only)" ${LTO_DEFAULT})
if(MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
endif(MSVC)
option( ENABLE_GBA_LOGGING "Enable extended GBA logging" ON ) option( ENABLE_GBA_LOGGING "Enable extended GBA logging" ON )
if( ENABLE_GBA_LOGGING ) if( ENABLE_GBA_LOGGING )
ADD_DEFINITIONS (-DGBA_LOGGING ) ADD_DEFINITIONS (-DGBA_LOGGING )
@ -191,8 +195,8 @@ IF( NOT SYSCONF_INSTALL_DIR )
ENDIF( NOT SYSCONF_INSTALL_DIR ) ENDIF( NOT SYSCONF_INSTALL_DIR )
# C defines # C defines
ADD_DEFINITIONS (-DHAVE_NETINET_IN_H -DHAVE_ARPA_INET_H -DHAVE_ZLIB_H -DFINAL_VERSION -DSDL -DUSE_OPENGL -DSYSCONF_INSTALL_DIR='"${SYSCONF_INSTALL_DIR}"' -DWITH_LIRC='${WITHLIRC}') ADD_DEFINITIONS (-DHAVE_NETINET_IN_H -DHAVE_ARPA_INET_H -DHAVE_ZLIB_H -DFINAL_VERSION -DSDL -DUSE_OPENGL -DSYSCONF_INSTALL_DIR=\\\""${SYSCONF_INSTALL_DIR}"\\\" -DWITH_LIRC=${WITHLIRC})
ADD_DEFINITIONS (-DVERSION='"${VERSION}"' -DPKGDATADIR='"${PKGDATADIR}"' -DPACKAGE='') ADD_DEFINITIONS (-DVERSION=\\\""${VERSION}"\\\" -DPKGDATADIR=\\\""${PKGDATADIR}"\\\" -DPACKAGE=)
if( ENABLE_LINK ) if( ENABLE_LINK )
# IPC linking code needs sem_timedwait which can be either in librt or pthreads # IPC linking code needs sem_timedwait which can be either in librt or pthreads
@ -233,7 +237,7 @@ ENDIF( NOT ENABLE_ASM_CORE )
if( ENABLE_NLS ) if( ENABLE_NLS )
SET( LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale ) SET( LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale )
ADD_DEFINITIONS ( -DENABLE_NLS ) ADD_DEFINITIONS ( -DENABLE_NLS )
ADD_DEFINITIONS ( -DLOCALEDIR='"${LOCALEDIR}"' ) ADD_DEFINITIONS ( -DLOCALEDIR=\\\""${LOCALEDIR}"\\\" )
# for now, only GBALink.cpp uses gettext() directly # for now, only GBALink.cpp uses gettext() directly
IF(APPLE) IF(APPLE)
# use Homebrew gettext if available # use Homebrew gettext if available
@ -271,6 +275,11 @@ IF(WIN32)
ENDIF() ENDIF()
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include") INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include")
IF(MSVC)
SET(DEPS_MSVC "${CMAKE_SOURCE_DIR}/dependencies/msvc")
INCLUDE_DIRECTORIES("${DEPS_MSVC}") # for GL/glext.h and getopt.h
ENDIF()
ENDIF() ENDIF()
# Compiler flags # Compiler flags
@ -317,10 +326,6 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
ENDIF() ENDIF()
ENDIF() ENDIF()
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(MY_C_FLAGS ${MY_C_FLAGS} -std=gnu++11)
ENDIF()
IF(MINGW) IF(MINGW)
SET(MY_C_FLAGS ${MY_C_FLAGS} -static-libgcc -static-libstdc++) SET(MY_C_FLAGS ${MY_C_FLAGS} -static-libgcc -static-libstdc++)
ENDIF(MINGW) ENDIF(MINGW)
@ -335,6 +340,11 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
ADD_COMPILE_OPTIONS(${C_COMPILE_FLAG}) ADD_COMPILE_OPTIONS(${C_COMPILE_FLAG})
ENDFOREACH() ENDFOREACH()
# This one must be set for C++ only, and we can't use generator expressions
# in ADD_COMPILE_OPTIONS because that's a cmake 3.3 feature and we need
# 2.8.12 compat for Ubuntu 14.
SET(CMAKE_CXX_COMPILE_OBJECT "${CMAKE_CXX_COMPILE_OBJECT} -std=gnu++11")
# make a string of compile options to add to link flags # make a string of compile options to add to link flags
UNSET(C_COMPILE_FLAGS_STR) UNSET(C_COMPILE_FLAGS_STR)
@ -397,6 +407,10 @@ SET(SRC_MAIN
src/common/SoundSDL.cpp src/common/SoundSDL.cpp
) )
if(MSVC)
SET(SRC_MAIN ${SRC_MAIN} "dependencies/msvc/getopt.c")
endif(MSVC)
SET(HDR_MAIN SET(HDR_MAIN
src/AutoBuild.h src/AutoBuild.h
src/System.h src/System.h
@ -412,6 +426,10 @@ SET(HDR_MAIN
src/common/SoundSDL.h src/common/SoundSDL.h
) )
if(MSVC)
SET(HDR_MAIN ${HDR_MAIN} "dependencies/msvc/getopt.h")
endif(MSVC)
if(ENABLE_FFMPEG) if(ENABLE_FFMPEG)
SET(SRC_MAIN ${SRC_MAIN} src/common/ffmpeg.cpp) SET(SRC_MAIN ${SRC_MAIN} src/common/ffmpeg.cpp)
SET(HDR_MAIN ${HDR_MAIN} src/common/ffmpeg.h) SET(HDR_MAIN ${HDR_MAIN} src/common/ffmpeg.h)

View File

@ -89,7 +89,8 @@ SET(SDL2_SEARCH_PATHS
/opt/local # MacPorts /opt/local # MacPorts
/opt/csw # OpenCSW (Solaris) /opt/csw # OpenCSW (Solaris)
/opt /opt
${SDL2_PATH} ${SDL2_PATH}/include
${SDL2_PATH}/lib
) )
FIND_PATH(SDL2_INCLUDE_DIR SDL.h FIND_PATH(SDL2_INCLUDE_DIR SDL.h

View File

@ -34,6 +34,7 @@ SET(SRC_FEX
INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(
. .
${ZLIB_INCLUDE_DIRS}
) )
ADD_LIBRARY( ADD_LIBRARY(

View File

@ -820,6 +820,28 @@ const char* ReadPrefString(const char* pref_key)
return ReadPrefString(pref_key, ""); return ReadPrefString(pref_key, "");
} }
/*-------------------------------------------------------------------------*/
/**
@brief Duplicate a string
@param s String to duplicate
@return Pointer to a newly allocated string, to be freed with free()
This is a replacement for strdup(). This implementation is provided
for systems that do not have it.
*/
/*--------------------------------------------------------------------------*/
static char *xstrdup(const char *s)
{
char *t;
if (!s)
return NULL;
t = (char *)malloc(strlen(s) + 1);
if (t) {
strcpy(t, s);
}
return t;
}
int ReadOpts(int argc, char ** argv) int ReadOpts(int argc, char ** argv)
{ {
int op = -1; int op = -1;
@ -859,7 +881,7 @@ int ReadOpts(int argc, char ** argv)
log("Missing BIOS file name\n"); log("Missing BIOS file name\n");
break; break;
} }
biosFileNameGBA = strdup(optarg); biosFileNameGBA = xstrdup(optarg);
break; break;
case 'c': case 'c':
{ {

View File

@ -18,6 +18,8 @@
#ifndef __VBA_SOUND_DRIVER_H__ #ifndef __VBA_SOUND_DRIVER_H__
#define __VBA_SOUND_DRIVER_H__ #define __VBA_SOUND_DRIVER_H__
#include <stdint.h> // for uint16_t
/** /**
* Sound driver abstract interface for the core to use to output sound. * Sound driver abstract interface for the core to use to output sound.
* Subclass this to implement a new sound driver. * Subclass this to implement a new sound driver.

View File

@ -717,8 +717,9 @@ int ZEXPORT memgzclose(file) gzFile file;
long ZEXPORT memtell(file) gzFile file; long ZEXPORT memtell(file) gzFile file;
{ {
mem_stream *s;
do_flush(file, Z_FULL_FLUSH); // makes memtell to tell truth do_flush(file, Z_FULL_FLUSH); // makes memtell to tell truth
mem_stream *s = (mem_stream *)file; s = (mem_stream *)file;
if (s == NULL) if (s == NULL)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;

View File

@ -1,6 +1,7 @@
#Do not use this file directly. Always use the top level CMakeLists.txt file #Do not use this file directly. Always use the top level CMakeLists.txt file
# This build is much easier if we just do it here. # This build is much easier if we just do it here.
SET( CMAKE_CXX_FLAGS -std=gnu++11 )
cmake_policy(SET CMP0043 NEW) # for wxWidgets
# not yet implemented # not yet implemented
SET(CAIRO_DEFAULT OFF) SET(CAIRO_DEFAULT OFF)
@ -198,9 +199,16 @@ IF(CMAKE_HOST_WIN32)
SET(BIN2C ${BIN2C}.exe) SET(BIN2C ${BIN2C}.exe)
ENDIF() ENDIF()
ADD_CUSTOM_COMMAND(OUTPUT ${BIN2C} IF(MSVC)
COMMAND cc ${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c -o ${BIN2C} ADD_CUSTOM_COMMAND(OUTPUT ${BIN2C}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c) COMMAND cl ${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c /link "/out:${BIN2C}"
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c)
ELSE(MSVC)
ADD_CUSTOM_COMMAND(OUTPUT ${BIN2C}
COMMAND cc ${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c -o ${BIN2C}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin2c.c)
ENDIF(MSVC)
ADD_CUSTOM_COMMAND(OUTPUT wxvbam.xrs ADD_CUSTOM_COMMAND(OUTPUT wxvbam.xrs
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND wxrc ${XRC_SOURCES} -o wxvbam.xrs COMMAND wxrc ${XRC_SOURCES} -o wxvbam.xrs
@ -301,10 +309,14 @@ ENDIF(ENABLE_XAUDIO2)
IF( WIN32 ) IF( WIN32 )
SET( SRC_WX ${SRC_WX} wxvbam.rc dsound.cpp ) SET( SRC_WX ${SRC_WX} wxvbam.rc dsound.cpp )
SET(DIRECTX_LIBRARIES -ldxguid -ldsound -lws2_32) SET(DIRECTX_LIBRARIES dxguid dsound ws2_32)
IF(MSVC)
# workaround for some symbols needed by static SDL2.lib
SET(DIRECTX_LIBRARIES ${DIRECTX_LIBRARIES} imm32 version)
ENDIF(MSVC)
# not strictly directx, but win32-related # not strictly directx, but win32-related
IF(ENABLE_DEBUGGER) IF(ENABLE_DEBUGGER)
SET(DIRECTX_LIBRARIES ${DIRECTX_LIBRARIES} -lwsock32) SET(DIRECTX_LIBRARIES ${DIRECTX_LIBRARIES} wsock32)
ENDIF(ENABLE_DEBUGGER) ENDIF(ENABLE_DEBUGGER)
ENDIF( WIN32 ) ENDIF( WIN32 )

View File

@ -34,7 +34,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <ctype.h> #include <ctype.h>
#include <wchar.h> #include <wchar.h>
#include <locale.h> #include <locale.h>
#ifndef _MSC_VER
#include <unistd.h> #include <unistd.h>
#endif
#include <wctype.h> #include <wctype.h>
#define BUF_SIZE 4096 #define BUF_SIZE 4096

View File

@ -192,7 +192,8 @@ bool DirectSound::init(long sampleRate)
void DirectSound::pause() void DirectSound::pause()
{ {
for (auto buf : {dsbPrimary, dsbSecondary}) { LPDIRECTSOUNDBUFFER bufs[] = {dsbPrimary, dsbSecondary};
for (auto buf : bufs) {
if (buf == NULL) if (buf == NULL)
continue; continue;
@ -216,7 +217,8 @@ void DirectSound::reset()
void DirectSound::resume() void DirectSound::resume()
{ {
for (auto buf : {dsbPrimary, dsbSecondary}) { LPDIRECTSOUNDBUFFER bufs[] = {dsbPrimary, dsbSecondary};
for (auto buf : bufs) {
if (buf == NULL) if (buf == NULL)
return; return;

View File

@ -752,7 +752,7 @@ public:
int count8, count16, count32; // number of aligned addresses in addrs int count8, count16, count32; // number of aligned addresses in addrs
wxString OnGetItemText(long item, long column) const; wxString OnGetItemText(long item, long column) const;
DECLARE_DYNAMIC_CLASS() DECLARE_DYNAMIC_CLASS(CheatListCtrl)
}; };
IMPLEMENT_DYNAMIC_CLASS(CheatListCtrl, wxListCtrl); IMPLEMENT_DYNAMIC_CLASS(CheatListCtrl, wxListCtrl);

View File

@ -1308,6 +1308,7 @@ DrawingPanelBase::DrawingPanelBase(int _width, int _height)
: width(_width) : width(_width)
, height(_height) , height(_height)
, scale(1) , scale(1)
, did_init(false)
, todraw(0) , todraw(0)
, pixbuf1(0) , pixbuf1(0)
, pixbuf2(0) , pixbuf2(0)

View File

@ -686,7 +686,7 @@ private:
wxRect margins; wxRect margins;
int npw, nph; int npw, nph;
DECLARE_CLASS() DECLARE_CLASS(PrintDialog)
}; };
IMPLEMENT_CLASS(PrintDialog, wxEvtHandler) IMPLEMENT_CLASS(PrintDialog, wxEvtHandler)

View File

@ -14,6 +14,8 @@
#include <wx/stattext.h> #include <wx/stattext.h>
#include <wx/checkbox.h> #include <wx/checkbox.h>
#include <stdint.h> // for uint32_t
// avoid exporting too much stuff // avoid exporting too much stuff
namespace Viewers { namespace Viewers {
// common to all viewers: // common to all viewers:
@ -151,7 +153,7 @@ protected:
uint32_t seladdr; uint32_t seladdr;
bool issel; bool issel;
DECLARE_DYNAMIC_CLASS() // for xrc DECLARE_DYNAMIC_CLASS(DisList) // for xrc
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
@ -229,7 +231,7 @@ protected:
bool isasc; bool isasc;
void ShowCaret(); void ShowCaret();
DECLARE_DYNAMIC_CLASS() // for xrc DECLARE_DYNAMIC_CLASS(MemView) // for xrc
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
@ -314,7 +316,7 @@ protected:
int ox, oy, selx, sely; int ox, oy, selx, sely;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS() DECLARE_DYNAMIC_CLASS(PixView)
}; };
#define pixview(v, n, w, h, cv) \ #define pixview(v, n, w, h, cv) \
do { \ do { \
@ -348,7 +350,7 @@ protected:
private: private:
int selx, sely; int selx, sely;
DECLARE_DYNAMIC_CLASS() DECLARE_DYNAMIC_CLASS(GfxPanel)
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
@ -398,7 +400,7 @@ protected:
// always generates a GFX_CLICK // always generates a GFX_CLICK
void SelPoint(wxMouseEvent& ev); void SelPoint(wxMouseEvent& ev);
void click(); void click();
DECLARE_DYNAMIC_CLASS() DECLARE_DYNAMIC_CLASS(PixViewEvt)
}; };
// a display-only checkbox which does not look like it's disabled // a display-only checkbox which does not look like it's disabled
@ -412,7 +414,7 @@ public:
{ {
} }
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS() DECLARE_DYNAMIC_CLASS(DispCheckBox)
}; };
// standard widgets in graphical viewers // standard widgets in graphical viewers

View File

@ -62,7 +62,7 @@ public:
protected: protected:
void OnJoy(wxSDLJoyEvent&); void OnJoy(wxSDLJoyEvent&);
DECLARE_DYNAMIC_CLASS(); DECLARE_DYNAMIC_CLASS(wxJoyKeyTextCtrl);
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
}; };

View File

@ -74,7 +74,7 @@ protected:
// the last keydown event received; this is processed on next keyup // the last keydown event received; this is processed on next keyup
int lastmod, lastkey; int lastmod, lastkey;
DECLARE_DYNAMIC_CLASS(); DECLARE_DYNAMIC_CLASS(wxKeyTextCtrl);
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
}; };

View File

@ -23,7 +23,7 @@ protected:
void UpdatedValue(); void UpdatedValue();
void UpdateEvt(wxCommandEvent& ev); void UpdateEvt(wxCommandEvent& ev);
wxFarRadio* Next; wxFarRadio* Next;
DECLARE_DYNAMIC_CLASS() DECLARE_DYNAMIC_CLASS(wxFarRadio)
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@ -5,7 +5,6 @@
// create & display main frame // create & display main frame
#include "wxvbam.h" #include "wxvbam.h"
#include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <wx/cmdline.h> #include <wx/cmdline.h>
#include <wx/file.h> #include <wx/file.h>

View File

@ -307,7 +307,7 @@ public:
virtual bool DialogOpened() { return dialog_opened != 0; } virtual bool DialogOpened() { return dialog_opened != 0; }
// required for building from xrc // required for building from xrc
DECLARE_DYNAMIC_CLASS(); DECLARE_DYNAMIC_CLASS(MainFrame);
// required for event handling // required for event handling
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
@ -364,12 +364,13 @@ private:
// helper class to add HiDPI awareness (mostly for Mac OS X) // helper class to add HiDPI awareness (mostly for Mac OS X)
class HiDPIAware { class HiDPIAware {
public: public:
HiDPIAware() { hidpi_scale_factor = 0; }
virtual double HiDPIScaleFactor(); virtual double HiDPIScaleFactor();
virtual void RequestHighResolutionOpenGLSurface(); virtual void RequestHighResolutionOpenGLSurface();
virtual void GetRealPixelClientSize(int* x, int* y); virtual void GetRealPixelClientSize(int* x, int* y);
virtual wxWindow* GetWindow() = 0; virtual wxWindow* GetWindow() = 0;
private: private:
double hidpi_scale_factor = 0; double hidpi_scale_factor;
}; };
// a helper class to avoid forgetting StopModal() // a helper class to avoid forgetting StopModal()
@ -624,7 +625,7 @@ protected:
bool pointer_blanked; bool pointer_blanked;
uint32_t mouse_active_time; uint32_t mouse_active_time;
DECLARE_DYNAMIC_CLASS() DECLARE_DYNAMIC_CLASS(GameArea)
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
@ -667,7 +668,7 @@ protected:
int width, height; int width, height;
double scale; double scale;
virtual void DrawingPanelInit(); virtual void DrawingPanelInit();
bool did_init = false; bool did_init;
uint8_t* todraw; uint8_t* todraw;
uint8_t *pixbuf1, *pixbuf2; uint8_t *pixbuf1, *pixbuf2;
FilterThread* threads; FilterThread* threads;