OSDN Git Service

[BUILD][Qt][WIN32] Build environment with MINGW / Qt, with GNU/Linux host, but, still...
authorK.Ohta <whatisthis.sowhat@gmail.com>
Fri, 30 Oct 2015 15:07:05 +0000 (00:07 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Fri, 30 Oct 2015 15:07:05 +0000 (00:07 +0900)
27 files changed:
source/build-cmake/cmake/config_commonsource.cmake
source/build-cmake/cmake/toolchain_mingw_cross_linux.cmake [new file with mode: 0644]
source/build-cmake/config_build_cross_win32.sh [new file with mode: 0755]
source/src/common.cpp
source/src/common.h
source/src/emu.h
source/src/qt/common/agar_logger.cpp
source/src/qt/common/agar_logger.h
source/src/qt/common/emu_input.cpp
source/src/qt/common/emu_utils.h
source/src/qt/common/qt_gldraw.cpp
source/src/qt/common/qt_gldraw.h
source/src/qt/common/qt_glevents.cpp
source/src/qt/common/qt_input.h
source/src/qt/common/qt_main.cpp
source/src/qt/common/qt_main.h
source/src/qt/common/sdl_sound.cpp
source/src/qt/debugger/debugger_thread.cpp
source/src/qt/debugger/qt_debugger.cpp
source/src/qt/gui/qt_input.cpp
source/src/vm/debugger.h
source/src/vm/fm7/display.cpp
source/src/vm/fm7/fm7_keyboard.h
source/src/vm/fm7/fm7_mainio.cpp
source/src/vm/fm7/sound.cpp
source/src/vm/mc6809.cpp
source/src/vm/ym2203.h

index 1dea19d..2fe97fc 100644 (file)
@@ -80,8 +80,12 @@ include_directories(${THREADS_INCLUDE_PATH})
 
 include(FindPkgConfig)
 
-pkg_search_module(SDL2 REQUIRED sdl2)
-include_directories(${SDL2_INCLUDE_DIRS})
+if(CMAKE_CROSSCOMPILING)
+  include_directories(${SDL2_INCLUDE_DIRS})
+else()
+  pkg_search_module(SDL2 REQUIRED sdl2)
+  include_directories(${SDL2_INCLUDE_DIRS})
+endif()
 
 #if(ICONV_FOUND)
 # include_directories(${ICONV_INCLUDE_DIRS})
@@ -150,6 +154,7 @@ set(BUNDLE_LIBS
                           ${OPENMP_LIBRARY}
 #                         ${SDL_LIBRARY}
                            ${SDL2_LIBRARIES}
+                          ${ADDITIONAL_LIBRARIES}
 )
 if(USE_QT_5)
   set(BUNDLE_LIBS ${BUNDLE_LIBS} ${QT_LIBRARIES})
diff --git a/source/build-cmake/cmake/toolchain_mingw_cross_linux.cmake b/source/build-cmake/cmake/toolchain_mingw_cross_linux.cmake
new file mode 100644 (file)
index 0000000..25c3260
--- /dev/null
@@ -0,0 +1,30 @@
+# the name of the target operating system
+SET(CMAKE_SYSTEM_NAME Windows)
+
+# which compilers to use for C and C++
+SET(CMAKE_C_COMPILER i586-mingw32msvc-gcc)
+SET(CMAKE_CXX_COMPILER i586-mingw32msvc-g++)
+SET(CMAKE_RC_COMPILER i586-mingw32msvc-windres)
+
+# here is the target environment located
+SET(CMAKE_FIND_ROOT_PATH  /usr/i586-mingw32msvc 
+                          /usr/local/i586-mingw-msvc
+                          /usr/local/i586-mingw-msvc/SDL/i686-w64-mingw32
+                         /usr/local/i586-mingw-msvc/5.5/mingw492_32)
+
+
+
+# adjust the default behaviour of the FIND_XXX() commands:
+# search headers and libraries in the target environment, search 
+# programs in the host environment
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+
+set(SDL2_LIBRARIES
+                         /usr/local/i586-mingw-msvc/SDL/i686-w64-mingw32/lib/libSDL2.dll.a 
+                        /usr/local/i586-mingw-msvc/SDL/i686-w64-mingw32/lib/libSDL2main.a)
+set(SDL2_INCLUDE_DIRS /usr/local/i586-mingw-msvc/SDL/i686-w64-mingw32/include/SDL2)
+set(SDLMAIN_LIBRARY "")
+
+set(ADDITIONAL_LIBRARIES libwinmm.a)
\ No newline at end of file
diff --git a/source/build-cmake/config_build_cross_win32.sh b/source/build-cmake/config_build_cross_win32.sh
new file mode 100755 (executable)
index 0000000..c32c5f5
--- /dev/null
@@ -0,0 +1,78 @@
+#!/bin/bash
+
+CMAKE=/usr/bin/cmake
+TOOLCHAIN_SCRIPT="../../cmake/toolchain_mingw_cross_linux.cmake"
+
+#MAKEFLAGS_CXX="-g -O2 -DNDEBUG"
+#MAKEFLAGS_CC="-g -O2 -DNDEBUG"
+BUILD_TYPE="Relwithdebinfo"
+CMAKE_APPENDFLAG=""
+
+#if [ -e ./buildvars.dat ] ; then
+#    . ./buildvars.dat
+#fi
+#MAKEFLAGS_CXX="-g -O3 -ftree-vectorize -flto -DNDEBUG" 
+#MAKEFLAGS_CC="-g -O3 -ftree-vectorize  -flto -DNDEBUG"
+#MAKEFLAGS_GENERAL="-j4"
+
+#CMAKE_LINKFLAG="-DCMAKE_EXE_LINKER_FLAGS='${CMAKE_EXE_LINKER_FLAGS} -flto -O3 -ftree-vectorize -g'"
+#CMAKE_LINKFLAG=""
+#CMAKE_APPENDFLAG="-DCMAKE_AR=/usr/bin/gcc-ar -DCMAKE_NM=/usr/bin/gcc-nm -DCMAKE_RANLIB=/usr/bin/gcc-ranlib"
+
+case ${BUILD_TYPE} in
+    "Debug" | "DEBUG" | "debug" ) 
+            CMAKE_FLAGS1="-DCMAKE_BUILD_TYPE:STRING=debug"
+           CMAKE_FLAGS2="-DCMAKE_CXX_FLAGS_DEBUG:STRING"
+           CMAKE_FLAGS3="-DCMAKE_C_FLAGS_DEBUG:STRING"
+           ;;
+    "Release" | "RELEASE" | "release" ) 
+            CMAKE_FLAGS1="-DCMAKE_BUILD_TYPE:STRING=Release"
+           CMAKE_FLAGS2="-DCMAKE_CXX_FLAGS_RELEASE:STRING"
+           CMAKE_FLAGS3="-DCMAKE_C_FLAGS_RELEASE:STRING"
+           ;;
+    "Relwithdebinfo" | "RELWITHDEBINFO" | "relwithdebinfo" ) 
+            CMAKE_FLAGS1="-DCMAKE_BUILD_TYPE:STRING=Relwithdebinfo"
+           CMAKE_FLAGS2="-DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING"
+           CMAKE_FLAGS3="-DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING"
+           ;;
+     * )
+            echo "Specify BUILD_TYPE in buildvars.dat to Debug, Release, Relwithdebinfo."
+           exit -1
+           ;;
+esac
+
+for SRCDATA in $@ ; do\
+
+    mkdir -p ${SRCDATA}/build-win32
+    cd ${SRCDATA}/build-win32
+    
+    echo ${CMAKE_FLAGS1} ${CMAKE_FLAGS2}
+    ${CMAKE} -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_SCRIPT} \
+            ${CMAKE_FLAGS1} \
+            "${CMAKE_FLAGS2}=${MAKEFLAGS_CXX}" \
+            "${CMAKE_FLAGS3}=${MAKEFLAGS_CC}" \
+            ${CMAKE_APPENDFLAG} \
+            ${CMAKE_LINKFLAG} \
+            .. | tee make.log
+
+    ${CMAKE} ${CMAKE_FLAGS1} \
+            "${CMAKE_FLAGS2}=${MAKEFLAGS_CXX}" \
+            "${CMAKE_FLAGS3}=${MAKEFLAGS_CC}" \
+            ${CMAKE_APPENDFLAG} \
+            ${CMAKE_LINKFLAG} \
+            .. | tee -a make.log
+
+    make clean
+    
+    make ${MAKEFLAGS_GENERAL} 2>&1 | tee -a ./make.log
+#    case $? in
+#      0 ) sudo make install 2>&1 | tee -a ./make.log ;;
+#      * ) exit $? ;;
+#    esac
+    
+#    make clean
+    cd ../..
+done
+
+exit 0
+
index 1678d5e..d11c36b 100644 (file)
 //             return errno;
 //     }
 //}
-
 errno_t _strcpy_s(char *strDestination, size_t numberOfElements, const char *strSource)
 {
        strcpy(strDestination, strSource);
        return 0;
 }
 
+# if !defined(Q_OS_WIN32)
 errno_t _tcscpy_s(_TCHAR *strDestination, size_t numberOfElements, const _TCHAR *strSource)
 {
        _tcscpy(strDestination, strSource);
@@ -47,7 +47,7 @@ _TCHAR *_tcstok_s(_TCHAR *strToken, const char *strDelimit, _TCHAR **context)
 {
        return _tcstok(strToken, strDelimit);
 }
-
+# endif
 int _stprintf_s(_TCHAR *buffer, size_t sizeOfBuffer, const _TCHAR *format, ...)
 {
        va_list ap;
index ce15ab1..76c8394 100644 (file)
 #include <agar/core.h>
 #include <stdarg.h>
 #elif defined(_USE_QT)
-#include <SDL2/SDL.h>
+#include <SDL.h>
 #include <stdarg.h>
-
+# if defined(Q_OS_WIN32)
+#  include <tchar.h>
+# endif
 # if defined(_USE_QT5)
 #  include <QString>
 #  include <QFile>
 
 #if defined(_USE_AGAR) || defined(_USE_SDL) || defined(_USE_QT)
 
-#ifndef uint8
+#  ifndef uint8
    typedef uint8_t uint8;
-# endif
-# ifndef int8
+#  endif
+#  ifndef int8
    typedef int8_t int8;
-# endif
-# ifndef uint16
+#  endif
+#  ifndef uint16
    typedef uint16_t uint16;
-# endif
-# ifndef int16
+#  endif
+#  ifndef int16
    typedef int16_t int16;
-# endif
-# ifndef uint32
+#  endif
+#  ifndef uint32
    typedef uint32_t uint32;
-# endif
-# ifndef int32
+#  endif
+#  ifndef int32
    typedef int32_t int32;
-# endif
-# ifndef uint64
+#  endif
+#  ifndef uint64
    typedef uint64_t uint64;
-# endif
-# ifndef int64
+#  endif
+#  ifndef int64
    typedef int64_t int64;
-# endif
-# ifndef BOOL
+#  endif
+#  ifndef BOOL
    typedef int BOOL;
-# endif
-# ifndef BYTE
+#  endif
+# ifndef Q_OS_WIN32
+#  ifndef BYTE
    typedef uint8_t BYTE;
-# endif
-# ifndef WORD
+#  endif
+#  ifndef WORD
    typedef uint16_t WORD;
-# endif
-# ifndef DWORD
+#  endif
+#  ifndef DWORD
    typedef uint32_t DWORD;
-# endif
-# ifndef QWORD
+#  endif
+#  ifndef QWORD
    typedef uint64_t QWORD;
-# endif
+#  endif
 
-# ifndef UINT8
+#  ifndef UINT8
    typedef uint8_t UINT8;
-# endif
-# ifndef UINT16
+#  endif
+#  ifndef UINT16
    typedef uint16_t UINT16;
-# endif
-# ifndef UINT32
+#  endif
+#  ifndef UINT32
    typedef uint32_t UINT32;
-# endif
-# ifndef UINT64
+#  endif
+#  ifndef UINT64
    typedef uint64_t UINT64;
-# endif
+#  endif
 
-# ifndef INT8
+#  ifndef INT8
    typedef int8_t INT8;
-# endif
-# ifndef INT16
+#  endif
+#  ifndef INT16
    typedef int16_t INT16;
-# endif
-# ifndef INT32
+#  endif
+#  ifndef INT32
    typedef int32_t INT32;
-# endif
-# ifndef INT64
+#  endif
+#  ifndef INT64
    typedef int64_t INT64;
-# endif
+#  endif
 
+//# ifndef Q_OS_WIN32
 static inline void _stprintf(char *s, const char *fmt, ...) {
    va_list args;
    
@@ -123,8 +127,8 @@ static inline void _stprintf(char *s, const char *fmt, ...) {
    sprintf(s, fmt, args);
    va_end(args);
 }
-#define stricmp(a,b) strcmp(a,b)
-#define strnicmp(a,b,n) strncmp(a,b,n)
+# define stricmp(a,b) strcmp(a,b)
+# define strnicmp(a,b,n) strncmp(a,b,n)
 
 
 // tchar.h
@@ -155,9 +159,15 @@ static inline char *_tcsncpy(_TCHAR *d, _TCHAR *s, int n) {
 static inline char *_tcsncat(_TCHAR *d, _TCHAR *s, int n) {
    return strncat((char *)d, (char *)s, n);
 }
+# endif
+#endif
 
+#if defined(_USE_AGAR) || defined(_USE_SDL) || defined(_USE_QT)
 
-static inline int DeleteFile(_TCHAR *path) 
+# if defined(Q_OS_WIN32)
+   typedef char    _TCHAR;
+# endif
+static int DeleteFile(_TCHAR *path) 
 {
 #ifdef _USE_QT
        QString fpath = (char *)path;
@@ -170,40 +180,48 @@ static inline int DeleteFile(_TCHAR *path)
 }
 #include <algorithm>
 
+# ifndef Q_OS_WIN32
 #  ifdef USE_GETTEXT
 #  include <libintl.h>
 #  define _N(x) gettext(x)
 # else
 #  define _N(x) _T(x)
 # endif
+# endif
+#endif
+
+#if defined(_USE_AGAR) || defined(_USE_SDL) || defined(_USE_QT)
+# if defined(Q_OS_WIN32)
+#  include <tchar.h>
+# endif
 
 #undef __LITTLE_ENDIAN___
 #undef __BIG_ENDIAN___
 
 # if (SDL_BYTEORDER == SDL_LIL_ENDIAN)
 #  define __LITTLE_ENDIAN__
-static inline DWORD EndianToLittle_DWORD(DWORD x)
+static inline uint32_t EndianToLittle_DWORD(uint32_t x)
 {
    return x;
 }
 
-static inline WORD EndianToLittle_WORD(WORD x)
+static inline uint16_t EndianToLittle_WORD(uint16_t x)
 {
    return x;
 }
 # else // BIG_ENDIAN
 #  define __BIG_ENDIAN__
-static inline DWORD EndianToLittle_DWORD(DWORD x)
+static inline uint32_t EndianToLittle_DWORD(uint32_t x)
 {
-   DWORD y;
+   uint32_t y;
    y = ((x & 0x000000ff) << 24) | ((x & 0x0000ff00) << 8) |
        ((x & 0x00ff0000) >> 8)  | ((x & 0xff000000) >> 24);
    return y;
 }
 
-static inline WORD EndianToLittle_WORD(WORD x)
+static inline uint16_t EndianToLittle_WORD(uint16_t x)
 {
-   WORD y;
+   uint16_t y;
    y = ((x & 0x00ff) << 8) | ((x & 0xff00) >> 8);
    return y;
 }
@@ -304,7 +322,6 @@ static inline WORD EndianToLittle_WORD(WORD x)
 
 #endif
 
-
 typedef union {
        struct {
 #ifdef __BIG_ENDIAN__
@@ -437,11 +454,15 @@ typedef char _TCHAR;
 #define _tfopen fopen
 #define _tcscmp strcmp
 #define _tcscpy strcpy
-#define _tcsicmp stricmp
+# if !defined(_tcsicmp)
+# define _tcsicmp stricmp
+# endif
 #define _tcslen strlen
 #define _tcsncat strncat
 #define _tcsncpy strncpy
+# if !defined(_tcsncicmp)
 #define _tcsncicmp strnicmp
+# endif
 #define _tcsstr strstr
 #define _tcstok strtok
 #define _tcstol strtol
@@ -456,13 +477,15 @@ typedef int errno_t;
 #endif
 // secture functions
 #ifndef SUPPORT_SECURE_FUNCTIONS
-#ifndef errno_t
+# ifndef errno_t
 typedef int errno_t;
-#endif
+# endif
 //errno_t _tfopen_s(FILE** pFile, const _TCHAR *filename, const _TCHAR *mode);
 errno_t _strcpy_s(char *strDestination, size_t numberOfElements, const char *strSource);
+# if !defined(Q_OS_WIN32)
 errno_t _tcscpy_s(_TCHAR *strDestination, size_t numberOfElements, const _TCHAR *strSource);
 _TCHAR *_tcstok_s(_TCHAR *strToken, const char *strDelimit, _TCHAR **context);
+# endif
 int _stprintf_s(_TCHAR *buffer, size_t sizeOfBuffer, const _TCHAR *format, ...);
 int _vstprintf_s(_TCHAR *buffer, size_t numberOfElements, const _TCHAR *format, va_list argptr);
 #else
index 1d62646..4650707 100644 (file)
@@ -37,7 +37,7 @@
 #endif
 
 #elif defined(_USE_QT)
-# include <SDL2/SDL.h>
+# include <SDL.h>
 //# include "menuclasses.h"
 //# include "mainwidget.h"
 //# include "qt_gldraw.h"
@@ -79,7 +79,7 @@
 #include <QSemaphore>
 #include <QMutex>
 #include <QThread>
-#include "qt_input.h"
+//#include "qt_input.h"
 #endif
 
 #if defined(_USE_AGAR) || defined(_USE_QT)
index 7832f91..73c6507 100644 (file)
@@ -55,6 +55,7 @@ void AGAR_DebugLog(int level, const char *fmt, ...)
        char strbuf2[256];
        char strbuf3[24];
        struct timeval tv;
+#if !defined(Q_OS_WIN32)   
        int level_flag = LOG_USER;
        
        if(log_onoff == 0) return;
@@ -68,7 +69,7 @@ void AGAR_DebugLog(int level, const char *fmt, ...)
        } else {
           level_flag |= LOG_DEBUG;
        }
-       
+#endif 
        char *p;
        char *p_bak;
        const char delim[2] = "\n";
@@ -87,7 +88,9 @@ void AGAR_DebugLog(int level, const char *fmt, ...)
                do {
                        if(p != NULL) {
                                if(log_cons != 0) fprintf(stdout, "%s : %s%s %s\n", log_sysname, strbuf2, strbuf3, p);
+#if !defined(Q_OS_WIN32)   
                                if(syslog_flag != 0) syslog(level_flag, "uS=%06ld %s", tv.tv_usec, p);
+#endif
                                p = strtok_r(NULL, delim, &p_bak);
                        }
                } while(p != NULL);
@@ -130,9 +133,11 @@ bool AGAR_LogGetStatus(void)
        
 void AGAR_CloseLog(void)
 {
+#if !defined(Q_OS_WIN32)   
        if(syslog_flag != 0) {
             closelog();
        }
+#endif
        syslog_flag = 0;
        log_cons = 0;
         log_onoff = 0;
index fd392df..39bc4f5 100644 (file)
 
 #include <stdarg.h>
 #include <stdio.h>
-
-#include <syslog.h>
-
+#include <QWidget>
+#if !defined(Q_OS_WIN32)
+#  include <syslog.h>
+#endif
 #include <time.h>
 #include <sys/time.h>
 
index 371df80..8758b32 100644 (file)
@@ -11,7 +11,7 @@
 
 #include <Qt>
 #include <QApplication>
-#include <SDL2/SDL.h>
+#include <SDL.h>
 #include "emu.h"
 #include "vm/vm.h"
 #include "fifo.h"
@@ -115,8 +115,13 @@ void EMU::update_input()
                        vm->key_up(VK_SHIFT);
 # endif
                        // check l/r shift
+# if defined(Q_OS_WIN32)                       // 
+                       if(!(GetAsyncKeyState(VK_LSHIFT) & 0x8000)) key_status[VK_LSHIFT] &= 0x7f;
+                       if(!(GetAsyncKeyState(VK_RSHIFT) & 0x8000)) key_status[VK_RSHIFT] &= 0x7f;
+# else            
                        if(!(GetAsyncKeyState(VK_LSHIFT, modkey_status) & 0x8000)) key_status[VK_LSHIFT] &= 0x7f;
                        if(!(GetAsyncKeyState(VK_RSHIFT, modkey_status) & 0x8000)) key_status[VK_RSHIFT] &= 0x7f;
+#endif
                }
                if(key_status[VK_LSHIFT] != 0) {
                        // shift key is newly released
@@ -125,7 +130,11 @@ void EMU::update_input()
                        vm->key_up(VK_LSHIFT);
 # endif
                        // check l/r shift
+# if defined(Q_OS_WIN32)                       // 
+                       if(!(GetAsyncKeyState(VK_LSHIFT) & 0x8000)) key_status[VK_LSHIFT] &= 0x7f;
+# else            
                        if(!(GetAsyncKeyState(VK_LSHIFT, modkey_status) & 0x8000)) key_status[VK_LSHIFT] &= 0x7f;
+# endif                   
                }
                if(key_status[VK_RSHIFT] != 0) {
                        // shift key is newly released
@@ -134,7 +143,11 @@ void EMU::update_input()
                        vm->key_up(VK_RSHIFT);
 # endif
                        // check l/r shift
+# if defined(Q_OS_WIN32)                       // 
+                       if(!(GetAsyncKeyState(VK_RSHIFT) & 0x8000)) key_status[VK_RSHIFT] &= 0x7f;
+# else            
                        if(!(GetAsyncKeyState(VK_RSHIFT, modkey_status) & 0x8000)) key_status[VK_RSHIFT] &= 0x7f;
+# endif                   
                }
        }
        key_shift_pressed = key_shift_released = false;
@@ -341,7 +354,11 @@ void EMU::key_down(int sym, bool repeat)
        uint8 code = sym;
        if(code == VK_SHIFT){
 #ifndef USE_SHIFT_NUMPAD_KEY
+# if defined(Q_OS_WIN32)                       // 
+               if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
+# else            
                if(GetAsyncKeyState(VK_SHIFT, modkey_status) & 0x8000) {
+# endif                   
                         key_status[VK_LSHIFT] = 0x80;
                         key_status[VK_RSHIFT] = 0x80;
                         key_status[VK_SHIFT] = 0x80;
@@ -349,32 +366,64 @@ void EMU::key_down(int sym, bool repeat)
 #endif
        } else if(code == VK_LSHIFT){
 #ifndef USE_SHIFT_NUMPAD_KEY
+# if defined(Q_OS_WIN32)
+               if(GetAsyncKeyState(VK_LSHIFT) & 0x8000) key_status[VK_LSHIFT] = 0x80;
+# else
                if(GetAsyncKeyState(VK_LSHIFT, modkey_status) & 0x8000) key_status[VK_LSHIFT] = 0x80;
+# endif           
 #endif
        } else if(code == VK_RSHIFT){
 #ifndef USE_SHIFT_NUMPAD_KEY
+# if defined(Q_OS_WIN32)
+               if(GetAsyncKeyState(VK_RSHIFT) & 0x8000) key_status[VK_RSHIFT] = 0x80;
+# else
                if(GetAsyncKeyState(VK_RSHIFT, modkey_status) & 0x8000) key_status[VK_RSHIFT] = 0x80;
+# endif           
 #endif
        } else if(code == VK_CONTROL) {
+# if defined(Q_OS_WIN32)
+               if(GetAsyncKeyState(VK_CONTROL) & 0x8000) {
+# else
                if(GetAsyncKeyState(VK_CONTROL, modkey_status) & 0x8000) {
+# endif                   
                        key_status[VK_LCONTROL] = 0x80;
                        key_status[VK_RCONTROL] = 0x80;
                        key_status[VK_CONTROL] = 0x80;
                }
        } else if(code == VK_LCONTROL) {
+# if defined(Q_OS_WIN32) 
+               if(GetAsyncKeyState(VK_LCONTROL) & 0x8000) key_status[VK_LCONTROL] = 0x80;
+# else
                if(GetAsyncKeyState(VK_LCONTROL, modkey_status) & 0x8000) key_status[VK_LCONTROL] = 0x80;
+# endif           
        } else if(code == VK_RCONTROL) {
+# if defined(Q_OS_WIN32) 
+               if(GetAsyncKeyState(VK_RCONTROL) & 0x8000) key_status[VK_RCONTROL] = 0x80;
+# else
                if(GetAsyncKeyState(VK_RCONTROL, modkey_status) & 0x8000) key_status[VK_RCONTROL] = 0x80;
+# endif           
        } else if(code == VK_MENU) {
+# if defined(Q_OS_WIN32) 
+               if(GetAsyncKeyState(VK_MENU) & 0x8000) {
+# else
                if(GetAsyncKeyState(VK_MENU, modkey_status) & 0x8000) {
+# endif                   
                        key_status[VK_LMENU] = 0x80;
                        key_status[VK_RMENU] = 0x80;
                        key_status[VK_MENU] = 0x80;
                }
        } else if(code == VK_LMENU) {
+# if defined(Q_OS_WIN32)          
+               if(GetAsyncKeyState(VK_LMENU) & 0x8000) key_status[VK_LMENU] = 0x80;
+# else    
                if(GetAsyncKeyState(VK_LMENU, modkey_status) & 0x8000) key_status[VK_LMENU] = 0x80;
+# endif           
        } else if(code == VK_RMENU) {
+# if defined(Q_OS_WIN32)          
+               if(GetAsyncKeyState(VK_RMENU) & 0x8000) key_status[VK_RMENU] = 0x80;
+# else    
                if(GetAsyncKeyState(VK_RMENU, modkey_status) & 0x8000) key_status[VK_RMENU] = 0x80;
+# endif           
        } else if(code == 0xf0) {
                code = VK_CAPITAL;
                keep_frames = true;
@@ -427,7 +476,11 @@ void EMU::key_up(int sym)
        uint8 code = sym;
        if(code == VK_SHIFT) {
 #ifndef USE_SHIFT_NUMPAD_KEY
+# if defined(Q_OS_WIN32)
+               if(!(GetAsyncKeyState(VK_SHIFT) & 0x8000)) {
+# else            
                if(!(GetAsyncKeyState(VK_SHIFT, modkey_status) & 0x8000)) {
+# endif                   
                        key_status[VK_LSHIFT] &= 0x7f;
                        key_status[VK_RSHIFT] &= 0x7f;
                        key_status[VK_SHIFT] &= 0x7f;
@@ -435,32 +488,64 @@ void EMU::key_up(int sym)
 #endif
        } else if(code == VK_LSHIFT) {
 #ifndef USE_SHIFT_NUMPAD_KEY
+# if defined(Q_OS_WIN32)
+               if(!(GetAsyncKeyState(VK_LSHIFT) & 0x8000)) key_status[VK_LSHIFT] &= 0x7f;
+# else            
                if(!(GetAsyncKeyState(VK_LSHIFT, modkey_status) & 0x8000)) key_status[VK_LSHIFT] &= 0x7f;
+# endif           
 #endif
        } else if(code == VK_RSHIFT) {
 #ifndef USE_SHIFT_NUMPAD_KEY
+# if defined(Q_OS_WIN32)
+               if(!(GetAsyncKeyState(VK_RSHIFT) & 0x8000)) key_status[VK_RSHIFT] &= 0x7f;
+# else            
                if(!(GetAsyncKeyState(VK_RSHIFT, modkey_status) & 0x8000)) key_status[VK_RSHIFT] &= 0x7f;
+# endif           
 #endif
        } else if(code == VK_CONTROL) {
+# if defined(Q_OS_WIN32)
+               if(!(GetAsyncKeyState(VK_CONTROL) & 0x8000)) {
+# else            
                if(!(GetAsyncKeyState(VK_CONTROL, modkey_status) & 0x8000)) {
+# endif                   
                        key_status[VK_LCONTROL] &= 0x7f;
                        key_status[VK_RCONTROL] &= 0x7f;
                        key_status[VK_CONTROL] &= 0x7f;
                }
        } else if(code == VK_LCONTROL) {
+# if defined(Q_OS_WIN32)
+               if(!(GetAsyncKeyState(VK_LCONTROL) & 0x8000)) key_status[VK_LCONTROL] &= 0x7f;
+# else            
                if(!(GetAsyncKeyState(VK_LCONTROL, modkey_status) & 0x8000)) key_status[VK_LCONTROL] &= 0x7f;
+# endif                   
        } else if(code == VK_RCONTROL) {
+# if defined(Q_OS_WIN32)
+               if(!(GetAsyncKeyState(VK_RCONTROL) & 0x8000)) key_status[VK_RCONTROL] &= 0x7f;
+# else            
                if(!(GetAsyncKeyState(VK_RCONTROL, modkey_status) & 0x8000)) key_status[VK_RCONTROL] &= 0x7f;
+# endif           
        } else if(code == VK_MENU) {
+# if defined(Q_OS_WIN32)
+               if(!(GetAsyncKeyState(VK_MENU) & 0x8000)) {
+# else            
                if(!(GetAsyncKeyState(VK_MENU, modkey_status) & 0x8000)) {
+# endif                   
                        key_status[VK_LMENU] &= 0x7f;
                        key_status[VK_RMENU] &= 0x7f;
                        key_status[VK_MENU] &= 0x7f;
                }
        } else if(code == VK_LMENU) {
+# if defined(Q_OS_WIN32)
+               if(!(GetAsyncKeyState(VK_LMENU) & 0x8000)) key_status[VK_LMENU] &= 0x7f;
+# else            
                if(!(GetAsyncKeyState(VK_LMENU, modkey_status) & 0x8000)) key_status[VK_LMENU] &= 0x7f;
+# endif           
        } else if(code == VK_RMENU) {
+# if defined(Q_OS_WIN32)
+               if(!(GetAsyncKeyState(VK_RMENU) & 0x8000)) key_status[VK_RMENU] &= 0x7f;
+# else            
                if(!(GetAsyncKeyState(VK_RMENU, modkey_status) & 0x8000)) key_status[VK_RMENU] &= 0x7f;
+# endif           
        }
 
 #ifdef USE_SHIFT_NUMPAD_KEY
index 390c775..6535e57 100644 (file)
@@ -5,9 +5,11 @@
 #include "emu.h"
 #include "qt_main.h"
 
+#if !defined(Q_OS_WIN32)
 extern "C" {
        extern uint32_t timeGetTime(void);
 }
+#endif
 
 #if defined(USE_FD1) || defined(USE_FD2) || defined(USE_FD3) || defined(USE_FD4) || \
     defined(USE_FD5) || defined(USE_FD6) || defined(USE_FD7) || defined(USE_FD8)
index 687cad8..b5b6e17 100644 (file)
@@ -17,7 +17,7 @@
 #include <QRect>
 #endif
 //#include <SDL/SDL.h>
-#ifdef _WINDOWS
+#if defined(_WINDOWS) || defined(Q_OS_WIN32)
 #include <GL/gl.h>
 #include <GL/glext.h>
 #else
index 0294fc5..f762c16 100644 (file)
 class EMU;
 
 struct NativeScanCode {
-       uint32 vk;
-       uint32 scan;
+       uint32_t vk;
+       uint32_t scan;
 };
 struct NativeVirtualKeyCode {
-       uint32 vk;
-       uint32 key;
+       uint32_t vk;
+       uint32_t key;
 };
 
 #if defined(_USE_GLAPI_QT5_4)
index 60dc50f..bfc25c3 100644 (file)
@@ -11,7 +11,7 @@
 #include <QtGui>
 #include <QMouseEvent>
 #include <QApplication>
-#ifdef _WINDOWS
+#if defined(_WINDOWS) || defined(Q_OS_WIN32)
 #include <GL/gl.h>
 #include <GL/glext.h>
 #else
index 2f6e57e..330aa91 100644 (file)
@@ -12,7 +12,7 @@
 extern "C" {
 #endif
    // Include from gui/drv_wgl_keymaps.h , libagar.
-enum {
+   enum {
        VK_LBUTTON = 0x01,
        VK_RBUTTON = 0x02,
        
@@ -151,7 +151,9 @@ enum {
        VK_OME_CLEAR = 0xfe, 
 };
 
+# if !defined(Q_OS_WIN32)
 uint32_t GetAsyncKeyState(uint32_t vk, uint32_t mod);
+# endif   
 uint8_t convert_AGKey2VK(uint32_t sym);
    
 #ifdef __cplusplus
index 739d45b..84382a5 100644 (file)
@@ -287,7 +287,7 @@ void EmuThreadClass::print_framerate(int frames)
 {
        if(frames >= 0) draw_frames += frames;
        if(calc_message) {
-                       DWORD current_time = timeGetTime();
+                       uint32_t current_time = timeGetTime();
                        if(update_fps_time <= current_time && update_fps_time != 0) {
                                _TCHAR buf[256];
                                QString message;
@@ -1156,3 +1156,9 @@ int main(int argc, char *argv[])
        nErrorCode = MainLoop(argc, argv);
        return nErrorCode;
 }
+#if defined(Q_OS_WIN32)
+int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
+{
+   main(0, NULL);
+}
+#endif
index 4634d94..e724c17 100644 (file)
@@ -17,7 +17,7 @@
 #include <QImage>
 #include <QString>
 
-#include <SDL2/SDL.h>
+#include <SDL.h>
 #include "sdl_cpuid.h"
 #include "simd_types.h"
 #include "common.h"
index 0812100..9c8b343 100644 (file)
 #include "agar_logger.h"
 
 typedef struct {
-       DWORD dwRIFF;
-       DWORD dwFileSize;
-       DWORD dwWAVE;
-       DWORD dwfmt_;
-       DWORD dwFormatSize;
-       WORD wFormatTag;
-       WORD wChannels;
-       DWORD dwSamplesPerSec;
-       DWORD dwAvgBytesPerSec;
-       WORD wBlockAlign;
-       WORD wBitsPerSample;
-       DWORD dwdata;
-       DWORD dwDataLength;
+       uint32_t dwRIFF;
+       uint32_t dwFileSize;
+       uint32_t dwWAVE;
+       uint32_t dwfmt_;
+       uint32_t dwFormatSize;
+       uint16_t wFormatTag;
+       uint16_t wChannels;
+       uint32_t dwSamplesPerSec;
+       uint32_t dwAvgBytesPerSec;
+       uint16_t wBlockAlign;
+       uint16_t wBitsPerSample;
+       uint32_t dwdata;
+       uint32_t dwDataLength;
 } wavheader_t;
 
 extern "C" {
@@ -102,7 +102,11 @@ void AudioCallbackSDL(void *udata, Uint8 *stream, int len)
                        SDL_SemPost(*pData->pSndApplySem);
                        if(spos >= (len / 2)) return;
                        //         while(nSndDataLen <= 0) {
+#if defined(Q_OS_WIN32)
+                       SDL_Delay(1);
+#else
                        nanosleep(&req, &remain); // Wait 500uS
+#endif
                        if(bSndExit) return;
                        //         }
                }
@@ -201,7 +205,7 @@ void EMU::update_sound(int* extra_frames)
        now_mute = false;
         
        if(sound_ok) {
-               DWORD play_c, offset, size1, size2;
+               uint32_t play_c, offset, size1, size2;
                Sint16 *ptr1, *ptr2;
                
                // start play
@@ -303,7 +307,7 @@ void EMU::mute_sound()
 {
        if(!now_mute && sound_ok) {
                // check current position
-               DWORD size1, size2;
+               uint32_t size1, size2;
                
                Sint16 *ptr1, *ptr2;
                // WIP
index 3b8d371..6582d79 100644 (file)
@@ -1,12 +1,12 @@
 
 #include <QThread>
 #include <QMetaObject>
+#include <math.h>
 #include "./qt_debugger.h"
 
 
 void CSP_DebuggerThread::my_printf(const _TCHAR *format, ...)
 {
-       DWORD dwWritten;
        _TCHAR buffer[4096];
        va_list ap;
 
index af4e279..6490966 100644 (file)
@@ -9,7 +9,7 @@
 
 #include <stdio.h>
 #include <string.h>
-#include <termios.h>
+
 #include <unistd.h>
 #include <fcntl.h>
 #include <QObject>
index 9cee56f..435743d 100644 (file)
@@ -322,8 +322,8 @@ uint32_t GLDrawClass::getNativeKey2VK(uint32_t data)
 
 uint32_t GLDrawClass::get106Scancode2VK(uint32_t data)
 {
-       uint32 val = 0;
-       uint32 vk;
+       uint32_t val = 0;
+       uint32_t vk;
        int i = 0;
        while(NativeScanCode[i].vk != 0xffffffff) {
                val = NativeScanCode[i].scan;
@@ -364,6 +364,7 @@ void GLDrawClass::initKeyCode(void)
        NativeScanCode[i].vk = 0xffffffff;
        NativeScanCode[i].scan = 0xffffffff;
 
+#if !defined(Q_OS_WIN32)
        for(i = 0; i < 255; i++) {
                if(convTable_QTKey[i].vk == 0xffffffff) break;
                NativeVirtualKeyCode[i].vk = convTable_QTKey[i].vk;
@@ -371,7 +372,7 @@ void GLDrawClass::initKeyCode(void)
        }
        NativeVirtualKeyCode[i].vk = 0xffffffff;
        NativeVirtualKeyCode[i].key = 0xffffffff;
-
+#endif
        // Replace only ScanCode
        FILEIO *fio = new FILEIO();
        std::string app_path2;
@@ -387,14 +388,14 @@ void GLDrawClass::initKeyCode(void)
                        nstr = QString::fromUtf8(buf);
                        nlist = nstr.split(",", QString::SkipEmptyParts);
                        if(nlist.count() < 2) continue;
-                       uint32 vk   = nlist.at(0).toULong(&ok1, 16);
-                       uint32 scan = nlist.at(1).toULong(&ok2, 16);
+                       uint32_t vk   = nlist.at(0).toULong(&ok1, 16);
+                       uint32_t scan = nlist.at(1).toULong(&ok2, 16);
                        if((vk == 0) || (vk > 255)) continue;
                        if(ok1 && ok2) {
                                for(i = 0; i < 255; i++) {
                                        if(NativeScanCode[i].vk == 0xffffffff) break;
                                        if(NativeScanCode[i].scan == scan) {
-                                               NativeScanCode[i].vk = (uint32)vk;
+                                               NativeScanCode[i].vk = (uint32_t)vk;
                                                break;
                                        }
                                }
@@ -426,9 +427,9 @@ void GLDrawClass::releaseKeyCode(void)
 void GLDrawClass::keyReleaseEvent(QKeyEvent *event)
 {
        int key = event->key();
-       uint32 mod = event->modifiers();
-       uint32 scan;
-       uint32 vk;
+       uint32_t mod = event->modifiers();
+       uint32_t scan;
+       uint32_t vk;
        if(event->isAutoRepeat()) return;
        //scan = event->nativeVirtualKey();
        //vk = getNativeKey2VK(scan);
@@ -449,9 +450,9 @@ void GLDrawClass::keyReleaseEvent(QKeyEvent *event)
 void GLDrawClass::keyPressEvent(QKeyEvent *event)
 {
        int key = event->key();
-       uint32 mod = event->modifiers();;
-       uint32 scan;
-       uint32 vk;
+       uint32_t mod = event->modifiers();;
+       uint32_t scan;
+       uint32_t vk;
    
        if(event->isAutoRepeat()) return;
        //scan = event->nativeVirtualKey();
@@ -473,7 +474,7 @@ void GLDrawClass::keyPressEvent(QKeyEvent *event)
        emu->UnlockVM();
 }
 
-
+#if !defined(Q_OS_WIN32)
 extern "C"{   
 uint32_t GetAsyncKeyState(uint32_t vk, uint32_t mod)
 {
@@ -513,5 +514,5 @@ uint32_t GetAsyncKeyState(uint32_t vk, uint32_t mod)
 
 
 }
-
+#endif
 
index a7906a9..48bd026 100644 (file)
 #include "../emu.h"
 #include "device.h"
 #if defined(_USE_QT)
-#include <SDL2/SDL.h>
+#include <SDL.h>
 
 #define Sleep(n) SDL_Delay(n)
+# if defined(Q_OS_WIN32)
+#  include <tchar.h>
+# endif
 #endif
 
 #ifdef USE_DEBUGGER
index ba5220e..714bea4 100644 (file)
@@ -668,10 +668,6 @@ void DISPLAY::set_apalette_g(uint8 val)
 
 #endif // _FM77AV_VARIANTS
 
-// Test header
-#if !defined(_MSC_VER)
-#include <SDL2/SDL.h>
-#endif
 
 // Timing values from XM7 . Thanks Ryu.
 void DISPLAY::event_callback(int event_id, int err)
index 735929b..cd99142 100644 (file)
 #include "../../fileio.h"
 
 #include "fm7_common.h"
+#if defined(_USE_QT)
+# include "qt_input.h"
+#endif
+
 #if defined(_FM77AV_VARIANTS)  
 class BEEP;
 #endif
index 7afdf7b..f4b567d 100644 (file)
 #include "hd6844.h"
 #endif
 
-// TEST
-#if !defined(_MSC_VER)
-#include <SDL2/SDL.h>
-#endif
 
 FM7_MAINIO::FM7_MAINIO(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
 {
index 740849b..9aa6f75 100644 (file)
@@ -17,9 +17,6 @@
 #include "fm7_mainio.h"
 #include "../../config.h"
 
-// TEST
-//#include <SDL2/SDL.h>
-
 void FM7_MAINIO::reset_sound(void)
 {
        int i, j, k;
index f00a426..b3db887 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "mc6809.h"
 #include "mc6809_consts.h"
+#include "common.h"
 #ifdef USE_DEBUGGER
 #include "debugger.h"
 #endif
@@ -1132,12 +1133,12 @@ uint32 MC6809::cpu_disassemble_m6809(_TCHAR *buffer, uint32 pc, const uint8 *opr
                break;
 
        case REL:
-               offset = (INT8)operandarray[0];
+               offset = (int8)operandarray[0];
                buffer += _stprintf(buffer, _T("$%04X"), (pc + offset) & 0xffff);
                break;
 
        case LREL:
-               offset = (INT16)((operandarray[0] << 8) + operandarray[1]);
+               offset = (int16)((operandarray[0] << 8) + operandarray[1]);
                buffer += _stprintf(buffer, _T("$%04X"), (pc + offset) & 0xffff);
                break;
 
@@ -1200,14 +1201,14 @@ uint32 MC6809::cpu_disassemble_m6809(_TCHAR *buffer, uint32 pc, const uint8 *opr
                        //break;
 
                case 0x88:  // (+/- 7 bit offset),R
-                       offset = (INT8)opram[p++];
+                       offset = (int8)opram[p++];
                        buffer += _stprintf(buffer, _T("%s"), (offset < 0) ? "-" : "");
                        buffer += _stprintf(buffer, _T("$%02X,"), (offset < 0) ? -offset : offset);
                        buffer += _stprintf(buffer, _T("%s"), m6809_regs[reg]);
                        break;
 
                case 0x89:  // (+/- 15 bit offset),R
-                       offset = (INT16)((opram[p+0] << 8) + opram[p+1]);
+                       offset = (int16)((opram[p+0] << 8) + opram[p+1]);
                        p += 2;
                        buffer += _stprintf(buffer, _T("%s"), (offset < 0) ? "-" : "");
                        buffer += _stprintf(buffer, _T("$%04X,"), (offset < 0) ? -offset : offset);
@@ -1223,13 +1224,13 @@ uint32 MC6809::cpu_disassemble_m6809(_TCHAR *buffer, uint32 pc, const uint8 *opr
                        break;
 
                case 0x8c:  // (+/- 7 bit offset),PC
-                       offset = (INT8)opram[p++];
+                       offset = (int8)opram[p++];
                        buffer += _stprintf(buffer, _T("%s"), (offset < 0) ? "-" : "");
                        buffer += _stprintf(buffer, _T("$%02X,PC"), (offset < 0) ? -offset : offset);
                        break;
 
                case 0x8d:  // (+/- 15 bit offset),PC
-                       offset = (INT16)((opram[p+0] << 8) + opram[p+1]);
+                       offset = (int16)((opram[p+0] << 8) + opram[p+1]);
                        p += 2;
                        buffer += _stprintf(buffer, _T("%s"), (offset < 0) ? "-" : "");
                        buffer += _stprintf(buffer, _T("$%04X,PC"), (offset < 0) ? -offset : offset);
@@ -1237,7 +1238,7 @@ uint32 MC6809::cpu_disassemble_m6809(_TCHAR *buffer, uint32 pc, const uint8 *opr
 
                case 0x8e: // $FFFFF
                  //_tcscpy(buffer, _T("Illegal Postbyte"));
-                       offset = (INT16)0xffff;
+                       offset = (int16)0xffff;
                        //p += 2;
                        buffer += _stprintf(buffer, _T("$%04X"), offset);
                        break;
index 3855cc6..281f143 100644 (file)
@@ -18,7 +18,7 @@
 
 #if !(defined(HAS_AY_3_8910) || defined(HAS_AY_3_8912) || defined(HAS_AY_3_8913))
 #define HAS_YM_SERIES
-#if defined(_WIN32) && !defined(SDL)
+#if defined(_WIN32) && !defined(SDL) && !defined(_USE_QT)
 #define SUPPORT_MAME_FM_DLL
 #include "fmdll/fmdll.h"
 #endif