OSDN Git Service

[UI][Qt] Fix FTBFSs basically, now enable to work for FM77AV40EX.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 1 Dec 2015 09:55:09 +0000 (18:55 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 1 Dec 2015 09:55:09 +0000 (18:55 +0900)
45 files changed:
source/build-cmake/cmake/config_commonsource.cmake
source/build-cmake/cmake/config_emufm7.cmake
source/build-cmake/cmake/config_emufmr50.cmake
source/build-cmake/cmake/config_emumastersystem.cmake
source/build-cmake/cmake/config_emupasopia.cmake
source/build-cmake/cmake/config_emupc9801.cmake
source/build-cmake/cmake/config_mz2500.cmake
source/build-cmake/cmake/config_mz700.cmake
source/build-cmake/cmake/config_mz80.cmake
source/build-cmake/cmake/config_pc6001.cmake
source/build-cmake/cmake/config_pc8201.cmake
source/build-cmake/cmake/config_x1.cmake
source/build-cmake/fm7/CMakeLists.txt
source/build-cmake/fm77/CMakeLists.txt
source/build-cmake/fm77av/CMakeLists.txt
source/build-cmake/fm77av40/CMakeLists.txt
source/build-cmake/fm77av40ex/CMakeLists.txt
source/src/common.cpp
source/src/common.h
source/src/common_gcc.h
source/src/config.cpp
source/src/config.h
source/src/emu.cpp
source/src/emu.h
source/src/fileio.cpp
source/src/fileio.h
source/src/qt/common/draw_thread.cpp
source/src/qt/common/emu_thread.cpp
source/src/qt/common/emu_thread.h
source/src/qt/common/emuevents_control.cpp
source/src/qt/common/joy_thread.cpp
source/src/qt/common/qt_gldraw.h
source/src/qt/common/qt_glevents.cpp
source/src/qt/common/qt_main.cpp
source/src/qt/debugger/debugger_thread.cpp
source/src/qt/debugger/qt_debugger.cpp
source/src/qt/gui/mainwidget.h
source/src/qt/osd.cpp
source/src/qt/osd.h
source/src/qt/osd_console.cpp
source/src/qt/osd_input.cpp
source/src/qt/osd_screen.cpp
source/src/qt/osd_socket.cpp
source/src/qt/osd_sound.cpp
source/src/qt/osd_video.cpp

index 7b45cca..fa175aa 100644 (file)
@@ -122,8 +122,10 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/common)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/gui)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt)
 
 add_subdirectory(../../src/qt/gui qt/gui)
+add_subdirectory(../../src/qt qt/osd)
 add_subdirectory(../../src common)
 add_subdirectory(../../src/vm vm/)
 
index 3baa901..7e4ee64 100644 (file)
@@ -11,7 +11,7 @@ set(LOCAL_LIBS           vm_fm7
                   vm_vm
                   common_common
                   vm_fmgen
-#                 common_scaler-generic
+                  qt_osd
                    qt_fm7
                   qt_gui
                   )
@@ -175,7 +175,7 @@ endif()
 #include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm/fm7)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm/fmgen)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/fm7)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/machines/fm7)
 
 
 
index ef77de2..0ec070b 100644 (file)
@@ -9,7 +9,7 @@ cmake_policy(SET CMP0011 NEW)
 set(LOCAL_LIBS            vm_fmr50
                   vm_vm
                   common_common
-#                 common_scaler-generic
+                  qt_osd
                    qt_fmr50
                   qt_gui
                   )
@@ -106,10 +106,8 @@ elseif(BUILD_FMR280)
 endif()
 
 
-#include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm/fmr50)
-#include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm/fmgen)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/fmr50)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/machines/fmr50)
 
 include(config_commonsource)
 
index 07f2216..af2f7ef 100644 (file)
@@ -9,8 +9,8 @@ cmake_policy(SET CMP0011 NEW)
 set(LOCAL_LIBS            vm_sms
                   vm_vm
                   common_common
+                  qt_osd
                   vm_fmgen
-#                 common_scaler-generic
                    qt_sms
                   qt_gui
                   )
@@ -82,7 +82,7 @@ endif()
 #include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm/gamegear)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm/fmgen)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/gamegear)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/machines/gamegear)
 
 include(config_commonsource)
 
index b6e7023..f665012 100644 (file)
@@ -54,7 +54,7 @@ set(CMAKE_SYSTEM_PROCESSOR ${ARCHITECTURE} CACHE STRING "Set processor to build.
 
 add_definitions(-D_CONFIGURE_WITH_CMAKE)
 
-  include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/pasopia)
+  include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/machines/pasopia)
   include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm)
   
 if(BUILD_PASOPIA)
@@ -68,6 +68,7 @@ if(BUILD_PASOPIA)
                   vm_vm
                   common_common
                   qt_gui
+                  qt_osd
                   qt_debugger
                   qt_pasopia
                   )
@@ -85,6 +86,7 @@ elseif(BUILD_PASOPIA_LCD)
                   vm_vm
                   common_common
                   qt_gui
+                  qt_osd
                   qt_debugger
                   qt_pasopia
                   )
@@ -101,6 +103,7 @@ elseif(BUILD_PASOPIA7)
                   vm_vm
                   common_common
                   qt_gui
+                  qt_osd
                   qt_debugger
                   qt_pasopia
                   )
@@ -119,6 +122,7 @@ elseif(BUILD_PASOPIA7_LCD)
                   vm_vm
                   common_common
                   qt_gui
+                  qt_osd
                   qt_debugger
                   qt_pasopia
                   )
index a776bae..d9e9691 100644 (file)
@@ -2,7 +2,7 @@ set(LOCAL_LIBS     vm_pc98
                   vm_vm
                   common_common
                   vm_fmgen
-#                 common_scaler-generic
+                  qt_osd
                    qt_pc9801
                   qt_gui
                   )
@@ -130,20 +130,9 @@ endif()
 #include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm/pc9801)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm/fmgen)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/pc9801)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/machines/pc9801)
 if(BUILD_PC98DO)
   include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/pc8801)
 endif()
 
 include(config_commonsource)
-
-if(USE_SSE2)
-#  include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm/fm7/vram/sse2)
-#  add_subdirectory(../../src/vm/fm7/vram/sse2 vm/fm7/vram/sse2)
-endif()
-
-
-if(USE_SSE2)
-# include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/agar/common/scaler/sse2)
-endif()
-
index 02cb37f..e30a151 100644 (file)
@@ -11,6 +11,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../cmake")
 set(LOCAL_LIBS            vm_mz2500
                   vm_vm
                   common_common
+                  qt_osd
                   qt_mz2500
                   qt_gui
                    )
@@ -135,7 +136,7 @@ endif()
 if(BUILD_MZ2500)
   include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm/fmgen)
 endif()
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/mz2500)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/machines/mz2500)
 
 include(config_commonsource)
 
index da6648c..ae48490 100644 (file)
@@ -10,7 +10,7 @@ set(LOCAL_LIBS           vm_mz700
                   vm_vm
                   common_common
                   vm_fmgen
-#                 common_scaler-generic
+                  qt_osd
                   qt_mz700
                   qt_gui
                    )
@@ -93,7 +93,7 @@ endif()
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm/mz700)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm/fmgen)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/mz700)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/machines/mz700)
 
 include(config_commonsource)
 
index 53d2c3e..7cc4a49 100644 (file)
@@ -12,7 +12,7 @@ set(LOCAL_LIBS           vm_mz80
                   vm_vm
                   common_common
                   vm_fmgen
-#                 common_scaler-generic
+                  qt_osd
                   qt_mz80
                   qt_gui
                    )
@@ -102,7 +102,7 @@ endif()
 #include_directories(${CMAKE_CURRENT_SOURCE_DIR})
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm/mz80k)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm/fmgen)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/mz80k)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/machines/mz80k)
 
 include(config_commonsource)
 
index d94aa5f..a56b965 100644 (file)
@@ -12,7 +12,7 @@ set(LOCAL_LIBS           vm_pc60
                   vm_vm
                   common_common
                   vm_fmgen
-#                 common_scaler-generic
+                  qt_osd
                    qt_pc6001
                   qt_gui
                   qt_debugger
@@ -100,7 +100,7 @@ endif()
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm/pc6001)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm/fmgen)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/pc6001)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/machines/pc6001)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/debugger)
 
 include(config_commonsource)
index 6462dee..17cf54d 100644 (file)
@@ -11,6 +11,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../cmake")
 set(LOCAL_LIBS            vm_pc8201
                   vm_vm
                   common_common
+                  qt_osd
                    qt_pc8201
                   qt_gui
                   qt_debugger
@@ -62,7 +63,7 @@ endif()
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm/pc8201)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/pc8201)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/machines/pc8201)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/debugger)
 
 include(config_commonsource)
index f726c39..27ed6e4 100644 (file)
@@ -16,7 +16,7 @@ set(LOCAL_LIBS           vm_x1
                   vm_vm
                   common_common
                   vm_fmgen
-#                 common_scaler-generic
+                  qt_osd
                   qt_x1turboz
                   qt_gui
                    )
@@ -99,7 +99,7 @@ if(BUILD_X1TWIN)
 endif()
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm/fmgen)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/x1turboz)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/machines/x1turboz)
 
 include(config_commonsource)
 
index f4d1b82..b6e911b 100644 (file)
@@ -19,10 +19,6 @@ include(config_commonsource)
 
 add_subdirectory(../../src/vm/fm7 vm/fm7)
 add_subdirectory(../../src/vm/fmgen vm/fmgen)
-add_subdirectory(../../src/qt/fm7 qt/fm7)
+add_subdirectory(../../src/qt/machines/fm7 qt/fm7)
                            
 add_subdirectory(../../src/qt/common qt/common)
-
-if(USE_SSE2)
-#  add_subdirectory(../../src/vm/fm7/vram/sse2 vm/fm7/vram/sse2)
-endif()
index 1ba18f7..f699c6a 100644 (file)
@@ -8,7 +8,7 @@ cmake_policy(SET CMP0011 NEW)
 
 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../cmake")
 
-project (emufm7)
+project (emufm77)
 
 
 set(BUILD_FM77 ON CACHE BOOL "Build for FM77")
@@ -19,10 +19,6 @@ include(config_commonsource)
 
 add_subdirectory(../../src/vm/fm7 vm/fm7)
 add_subdirectory(../../src/vm/fmgen vm/fmgen)
-add_subdirectory(../../src/qt/fm7 qt/fm7)
+add_subdirectory(../../src/qt/machines/fm7 qt/fm7)
                            
 add_subdirectory(../../src/qt/common qt/common)
-
-if(USE_SSE2)
-#  add_subdirectory(../../src/vm/fm7/vram/sse2 vm/fm7/vram/sse2)
-endif()
index 9ef9c96..0f7334e 100644 (file)
@@ -19,10 +19,7 @@ include(config_commonsource)
 
 add_subdirectory(../../src/vm/fm7 vm/fm7)
 add_subdirectory(../../src/vm/fmgen vm/fmgen)
-add_subdirectory(../../src/qt/fm7 qt/fm7)
+add_subdirectory(../../src/qt/machines/fm7 qt/fm7)
                            
 add_subdirectory(../../src/qt/common qt/common)
 
-if(USE_SSE2)
-#  add_subdirectory(../../src/vm/fm7/vram/sse2 vm/fm7/vram/sse2)
-endif()
index 10469d7..385c165 100644 (file)
@@ -19,10 +19,6 @@ include(config_commonsource)
 
 add_subdirectory(../../src/vm/fm7 vm/fm7)
 add_subdirectory(../../src/vm/fmgen vm/fmgen)
-add_subdirectory(../../src/qt/fm7 qt/fm7)
+add_subdirectory(../../src/qt/machines/fm7 qt/fm7)
                            
 add_subdirectory(../../src/qt/common qt/common)
-
-if(USE_SSE2)
-#  add_subdirectory(../../src/vm/fm7/vram/sse2 vm/fm7/vram/sse2)
-endif()
index 111f10c..5ef8cf6 100644 (file)
@@ -19,7 +19,7 @@ include(config_commonsource)
 
 add_subdirectory(../../src/vm/fm7 vm/fm7)
 add_subdirectory(../../src/vm/fmgen vm/fmgen)
-add_subdirectory(../../src/qt/fm7 qt/fm7)
+add_subdirectory(../../src/qt/machines/fm7 qt/fm7)
                            
 add_subdirectory(../../src/qt/common qt/common)
 
index 00b15b8..67e210c 100644 (file)
@@ -10,6 +10,9 @@
 #include <string.h>
 #include "common.h"
 #include "config.h"
+#include "agar_logger.h"
+#include <string>
+
 #else
 # include <windows.h>
 # include <shlwapi.h>
@@ -18,7 +21,7 @@
 #endif
 
 #ifdef MAX_MACRO_NOT_DEFINED
-inline int max(int a, int b)
+int max(int a, int b)
 {
        if(a > b) {
                return a;
@@ -26,7 +29,8 @@ inline int max(int a, int b)
                return b;
        }
 }
-inline unsigned int max(unsigned int a, unsigned int b)
+
+unsigned int max(unsigned int a, unsigned int b)
 {
        if(a > b) {
                return a;
@@ -37,7 +41,7 @@ inline unsigned int max(unsigned int a, unsigned int b)
 #endif
 
 #ifdef MIN_MACRO_NOT_DEFINED
-inline int min(int a, int b)
+int min(int a, int b)
 {
        if(a < b) {
                return a;
@@ -45,7 +49,8 @@ inline int min(int a, int b)
                return b;
        }
 }
-inline unsigned int min(unsigned int a, unsigned int b)
+
+unsigned int min(unsigned int a, unsigned int b)
 {
        if(a < b) {
                return a;
@@ -97,23 +102,128 @@ int my_vstprintf_s(_TCHAR *buffer, size_t numberOfElements, const _TCHAR *format
 }
 #endif
 
-#ifndef _MSC_VER
+#if !defined(_MSC_VER) && !defined(CSP_OS_WINDOWS)
 BOOL MyWritePrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpString, LPCTSTR lpFileName)
 {
+       std::string s;
+       std::string v;
+       char app_path2[_MAX_PATH], *ptr;
+       FILEIO *path = new FILEIO;
+   
+       if((lpKeyName == NULL) || (lpAppName == NULL) || (lpFileName == NULL)) {
+               delete path;
+               return FALSE;
+       }
+       if(path->Fopen(lpFileName, FILEIO_WRITE_APPEND_ASCII) != true) {
+               delete path;
+               return FALSE;
+       }
+       
+       if(lpString == NULL) {
+               v = "";
+       } else {
+               v = lpString;
+       }
+       s = lpAppName;
+       s.append(".");
+       s.append(lpKeyName);
+       s.append("=");
+       s.append(v);
+       s.append("\n");
+       path->Fwrite((void *)s.c_str(), s.length(), 1);
+       path->Fclose();
+       delete path;
+       return TRUE;
        // write your compatible function, if possible in standard C/C++ code
-       return FALSE;
 }
 
-DWORD MyGetPrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpDefault, LPTSTR lpReturnedString, DWORD nSize, LPCTSTR lpFileName)
+static std::string MyGetPrivateProfileStr(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, _TCHAR *lpFileName)
+{
+   std::string key;
+   char ibuf[4096 + 102];
+   int64_t i;
+   int l_len;
+   int c = '\0';
+   std::string::size_type  pos;
+   std::string key_str;
+   std::string got_str;
+   FILEIO *pf = new FILEIO;
+   
+   key = lpAppName;
+   key = key + ".";
+   key = key + lpKeyName;
+   got_str = "";
+   if(pf->Fopen(lpFileName, FILEIO_READ_ASCII) != true) {
+          delete pf;
+          return got_str;
+   }
+   AGAR_DebugLog(AGAR_LOG_DEBUG, "Try App: %s Key: %s", lpAppName, lpKeyName);
+   pf->Fseek(0, FILEIO_SEEK_SET);
+   do {
+          key_str = key;
+          ibuf[0] = '\0';
+          i = 0;
+          l_len = 0;
+          while(1) {
+                  if(l_len > (4096 + 100)) { // Too long, read dummy.
+                          c = (char)pf->Fgetc();
+                          if((c != EOF) && (c != '\n') && (c != '\0')) continue;
+                          break;
+                  }
+                  c = (char)pf->Fgetc();
+                  if((c == EOF) || (c == '\n') || (c == '\0')) break;
+                  ibuf[i] = (char)c;
+                  i++;
+                  l_len++;
+          }
+          l_len = 0;
+          ibuf[i] = '\0';
+          got_str = ibuf;
+          key_str = key_str + "=";
+          pos = got_str.find(key_str);
+          if(pos != std::string::npos) break;
+          if(c == EOF) return "";
+   } while(c != EOF);
+   pf->Fclose();
+   delete pf;
+   
+   got_str.erase(0, pos + key_str.length());
+   AGAR_DebugLog(AGAR_LOG_DEBUG, "Got: %s Length: %d", got_str.c_str(), got_str.length());
+   return got_str;
+}
+
+
+DWORD MyGetPrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpDefault, LPCTSTR lpReturnedString, DWORD nSize, LPCTSTR lpFileName)
 {
-       // write your compatible function, if possible in standard C/C++ code
-       return 0;
+       std::string sp = MyGetPrivateProfileStr(lpAppName, lpKeyName, lpFileName);
+       if((!sp.empty()) && (nSize > 1)){
+               strncpy(lpReturnedString, sp.c_str(), nSize);
+       } else {
+               strncpy(lpReturnedString, lpDefault, nSize);
+       }
+       return  strlen(lpReturnedString);
 }
 
 UINT MyGetPrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, INT nDefault, LPCTSTR lpFileName)
 {
        // write your compatible function, if possible in standard C/C++ code
-       return 0;
+       int i;
+       char sstr[128];
+       char sval[128];
+       std::string s;
+       memset(sstr, 0x00, sizeof(sstr));
+       memset(sval, 0x00, sizeof(sval));
+       snprintf(sval, 128, "%d", nDefault); 
+       MyGetPrivateProfileString(lpAppName,lpKeyName, sval, sstr, 128, lpFileName);
+       s = sstr;
+       
+       if(s.empty()) {
+               i = nDefault;
+       } else {
+               i = strtol(s.c_str(), NULL, 10);
+       }
+       //AGAR_DebugLog(AGAR_LOG_DEBUG, "Got Int: %d\n", i);
+       return i;
 }
 #endif
 
index f589528..cc555ab 100644 (file)
@@ -46,6 +46,7 @@
 #include "common_gcc.h"
 #elif defined(_MSC_VER)
 #include "common_msc.h"
+#endif
 // variable scope of 'for' loop for Microsoft Visual C++ 6.0
 #if defined(_MSC_VER) && (_MSC_VER == 1200)
 #define for if(0);else for
@@ -98,7 +99,7 @@ typedef unsigned int uint32;
 #ifdef _MSC_VER
 typedef unsigned __int64 uint64;
 #else
-typedef unsigned long long uint64;
+//typedef unsigned long long uint64;
 #endif
 #endif
 #ifndef int8
@@ -114,7 +115,7 @@ typedef signed int int32;
 #ifdef _MSC_VER
 typedef signed __int64 int64;
 #else
-typedef signed long long int64;
+//typedef signed long long int64;
 #endif
 #endif
 
@@ -214,13 +215,13 @@ typedef union {
 // max/min from WinDef.h
 #ifndef max
        #define MAX_MACRO_NOT_DEFINED
-       inline int max(int a, int b);
-       inline unsigned int max(unsigned int a, unsigned int b);
+       int max(int a, int b);
+       unsigned int max(unsigned int a, unsigned int b);
 #endif
 #ifndef min
        #define MIN_MACRO_NOT_DEFINED
-       inline int min(int a, int b);
-       inline unsigned int min(unsigned int a, unsigned int b);
+       int min(int a, int b);
+       unsigned int min(unsigned int a, unsigned int b);
 #endif
 
 // _TCHAR
@@ -298,9 +299,9 @@ typedef union {
        #define my_vstprintf_s _vstprintf_s
 #endif
 
-#ifndef _MSC_VER
+#if!defined(_MSC_VER) && !defined(CSP_OS_WINDOWS)
        BOOL MyWritePrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpString, LPCTSTR lpFileName);
-       DWORD MyGetPrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpDefault, LPTSTR lpReturnedString, DWORD nSize, LPCTSTR lpFileName);
+       DWORD MyGetPrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpDefault, LPCTSTR lpReturnedString, DWORD nSize, LPCTSTR lpFileName);
        UINT MyGetPrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, INT nDefault, LPCTSTR lpFileName);
 #else
        #define MyWritePrivateProfileString WritePrivateProfileString
@@ -348,7 +349,7 @@ typedef union {
 // _TCHAR
 #ifndef SUPPORT_TCHAR_TYPE
        typedef char _TCHAR;
-       #define _T(s) (s)
+//#define _T(s) (s)
        #define _tfopen fopen
        #define _tcscmp strcmp
        #define _tcscpy strcpy
index cfb82d0..d15b149 100644 (file)
@@ -57,14 +57,22 @@ typedef uint16_t WORD;
 typedef uint32_t DWORD;
 typedef uint64_t QWORD;
 //# if !defined(Q_OS_CYGWIN)
+typedef uint32_t UINT;
 typedef uint8_t UINT8;
 typedef uint16_t UINT16;
 typedef uint32_t UINT32;
 typedef uint64_t UINT64;
+typedef int32_t INT;
 typedef int8_t INT8;
 typedef int16_t INT16;
 typedef int32_t INT32;
 typedef int64_t INT64;
+# if !defined(TRUE)
+#  define TRUE 1
+# endif
+# if !defined(FALSE)
+#  define FALSE 0
+# endif
 static inline void _stprintf(char *s, const char *fmt, ...) {
    va_list args;
    
@@ -83,6 +91,7 @@ static inline void _stprintf(char *s, const char *fmt, ...) {
 # define _TEXT(x)    __T(x)
 
 # if defined(CSP_OS_GCC_GENERIC)
+typedef char _TCHAR;
 typedef _TCHAR* LPCTSTR;
 # endif
 # if defined(CSP_OS_GCC_CYGWIN)
index 366989c..a6441c4 100644 (file)
@@ -46,137 +46,6 @@ config_t config;
 #define CONFIG_NAME "conf"
 #endif
 
-#if defined(_USE_QT) && !defined(Q_OS_WIN32)
-bool MyWritePrivateProfileString(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, char *Value, FILEIO *lpFileName)
-{
-       QString s;
-       QString v;
-       if((lpKeyName == NULL) || (lpAppName == NULL)) return false;
-       if(Value == NULL) {
-               v = QString::fromUtf8("");
-       } else {
-               v = QString::fromUtf8(Value);
-       }
-       s = QString::fromUtf8(lpAppName);
-       s.append(QString::fromUtf8("."));
-       s.append(QString::fromUtf8(lpKeyName));
-       s.append(QString::fromUtf8("="));
-       s.append(v);
-       s.append(QString::fromUtf8("\n"));
-       lpFileName->Fwrite((void *)s.toUtf8().constData(), s.toUtf8().length(), 1);
-       return true;
-}
-
-bool MyWritePrivateProfileInt(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, int Value, FILEIO *lpFileName)
-{
-       std::string s;
-       int l;
-       char valuebuf[64];
-       memset(valuebuf, 0x00, sizeof(valuebuf));
-       l = snprintf(valuebuf, 63, "%d", Value);
-       if((l <= 0) || (l >= 63)) return false;
-       return MyWritePrivateProfileString(lpAppName, lpKeyName, valuebuf, lpFileName);
-}
-
-BOOL MyWritePrivateProfileBool(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, bool Value, FILEIO *lpFileName)
-{
-   int v = 0;
-   if(Value) v = 1; 
-   return MyWritePrivateProfileInt(lpAppName, lpKeyName, v, lpFileName);
-}
-
-
-std::string MyGetPrivateProfileStr(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, FILEIO *lpFileName)
-{
-   std::string key;
-   char ibuf[4096 + 102];
-   int64_t i;
-   int l_len;
-   int c = '\0';
-   std::string::size_type  pos;
-   std::string key_str;
-   std::string got_str;
-  
-   key = lpAppName;
-   key = key + ".";
-   key = key + lpKeyName;
-   AGAR_DebugLog(AGAR_LOG_DEBUG, "Try App: %s Key: %s", lpAppName, lpKeyName);
-   lpFileName->Fseek(0, FILEIO_SEEK_SET);
-   do {
-          key_str = key;
-          ibuf[0] = '\0';
-          i = 0;
-          l_len = 0;
-          while(1) {
-                  if(l_len > (4096 + 100)) { // Too long, read dummy.
-                          c = (char)lpFileName->Fgetc();
-                          if((c != EOF) && (c != '\n') && (c != '\0')) continue;
-                          break;
-                  }
-                  c = (char)lpFileName->Fgetc();
-                  if((c == EOF) || (c == '\n') || (c == '\0')) break;
-                  ibuf[i] = (char)c;
-                  i++;
-                  l_len++;
-          }
-          l_len = 0;
-          ibuf[i] = '\0';
-          got_str = ibuf;
-          key_str = key_str + "=";
-          pos = got_str.find(key_str);
-          if(pos != std::string::npos) break;
-          if(c == EOF) return "";
-   } while(c != EOF);
-   
-   got_str.erase(0, pos + key_str.length());
-   AGAR_DebugLog(AGAR_LOG_DEBUG, "Got: %s Length: %d", got_str.c_str(), got_str.length());
-   return got_str;
-}
-
-
-void MyGetPrivateProfileString(const _TCHAR *section, const _TCHAR *key, const _TCHAR *defaultstr, char *str, int max_len, FILEIO *p)
-{
-       std::string sp = MyGetPrivateProfileStr(section, key, p);
-       if((!sp.empty()) && (max_len > 1)){
-               strncpy(str, sp.c_str(), max_len);
-       } else {
-               strncpy(str, defaultstr, max_len);
-       }
-}
-
-int MyGetPrivateProfileInt(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, int nDefault, FILEIO *lpFileName)
-{
-       int i;
-       char sstr[128];
-       char sval[128];
-       std::string s;
-       bool r;
-       memset(sstr, 0x00, sizeof(sstr));
-       memset(sval, 0x00, sizeof(sval));
-       snprintf(sval, 128, "%d", nDefault); 
-       MyGetPrivateProfileString(lpAppName,lpKeyName, sval, sstr, 128, lpFileName);
-       s = sstr;
-       
-       if(s.empty()) {
-               i = nDefault;
-       } else {
-               i = s.toInt(&r);
-               if(!r) {
-                       i = nDefault;
-               }
-       }
-       AGAR_DebugLog(AGAR_LOG_DEBUG, "Got Int: %d\n", i);
-       return i;
-}
-
-bool MyGetPrivateProfileBool(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, bool bDefault, FILEIO *lpFileName)
-{
-   
-       return (MyGetPrivateProfileInt(lpAppName, lpKeyName, bDefault ? 1 : 0, lpFileName) != 0);
-}
-   
-#else // MSC or Windows
 //extern _TCHAR* get_parent_dir(_TCHAR* file);
 BOOL MyWritePrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, int Value, LPCTSTR lpFileName)
 {
@@ -197,8 +66,6 @@ bool MyGetPrivateProfileBool(LPCTSTR lpAppName, LPCTSTR lpKeyName, bool bDefault
        return (MyGetPrivateProfileInt(lpAppName, lpKeyName, bDefault ? 1 : 0, lpFileName) != 0);
 }
 
-#endif
-
 void init_config()
 {
        int i;
@@ -300,31 +167,17 @@ void load_config()
        
        // get config path
 
-#if defined(_USE_QT) && !defined(Q_OS_WIN)
-       char app_path2[_MAX_PATH], *ptr;
-       FILEIO *config_path = new FILEIO;
-       
-       memset(app_path2, 0x00, _MAX_PATH);
-       cpp_confdir.copy(app_path2, _MAX_PATH, 0);
-    
-       strncat(app_path2, CONFIG_NAME, _MAX_PATH);
-       strncat(app_path2, ".ini", _MAX_PATH);
-       
-       AGAR_DebugLog(AGAR_LOG_INFO, "Try to read config: %s", app_path2);
-       if(!config_path->Fopen(app_path2, FILEIO_READ_ASCII)) {
-               delete config_path;
-               return;
-       }
-#else
        _TCHAR app_path[_MAX_PATH], config_path[_MAX_PATH], *ptr;
        memset(config_path, 0x00, _MAX_PATH);
        memset(app_path, 0x00, _MAX_PATH);
+#if defined(_USE_QT)
+       strncpy(app_path , cpp_confdir.c_str(),  _MAX_PATH);
+#elif defined(_MSC_VER)
        GetModuleFileName(NULL, config_path, _MAX_PATH);
        GetFullPathName(config_path, _MAX_PATH, app_path, &ptr);
        if(ptr != NULL) *ptr = _T('\0');
+#endif 
        my_stprintf_s(config_path, _MAX_PATH, _T("%s%s.ini"), app_path, _T(CONFIG_NAME));
-#endif
-   
        
        // control
 #ifdef USE_BOOT_MODE
@@ -503,9 +356,7 @@ void load_config()
 #endif
        config.swap_joy_buttons = MyGetPrivateProfileBool(_T("Input"), _T("SwapJoyButtons"), config.swap_joy_buttons, config_path);
 #if defined(_USE_QT) && !defined(Q_OS_WIN)
-     config_path->Fclose();
-     AGAR_DebugLog(AGAR_LOG_INFO, "Read Done.");
-        delete config_path;
+       AGAR_DebugLog(AGAR_LOG_INFO, "Read Done.");
 #endif
 }
 
@@ -513,30 +364,28 @@ void save_config()
 {
        int drv, i;
        // get config path
-#if defined(_USE_QT) && !defined(Q_OS_WIN)
-       char app_path2[_MAX_PATH], *ptr;
-       FILEIO *config_path = new FILEIO;
-   
-       app_path2[0] = '\0';
-       memset(app_path2, 0x00, _MAX_PATH);
-       cpp_confdir.copy(app_path2, _MAX_PATH, 0);
-    
-       strncat(app_path2, CONFIG_NAME, _MAX_PATH);
-       strncat(app_path2, ".ini", _MAX_PATH);
-
-       AGAR_DebugLog(AGAR_LOG_INFO, "Try to write config: %s", app_path2);
-       if(config_path->Fopen(app_path2, FILEIO_WRITE_ASCII) != true) {
-               delete config_path;
-               return;
-       }
-#else
        _TCHAR app_path[_MAX_PATH], config_path[_MAX_PATH], *ptr;
        memset(config_path, 0x00, _MAX_PATH);
        memset(app_path, 0x00, _MAX_PATH);
+#if defined(_USE_QT)
+       strncpy(app_path , cpp_confdir.c_str(),  _MAX_PATH);
+#elif defined(_MSC_VER)
        GetModuleFileName(NULL, config_path, _MAX_PATH);
        GetFullPathName(config_path, _MAX_PATH, app_path, &ptr);
        if(ptr != NULL) *ptr = _T('\0');
+#endif 
        my_stprintf_s(config_path, _MAX_PATH, _T("%s%s.ini"), app_path, _T(CONFIG_NAME));
+#if !defined(_MSC_VER)
+       {
+               FILEIO *pt = new FILEIO;
+               if(pt->Fopen(config_path, FILEIO_WRITE_ASCII) != true) {
+                       delete pt;
+                       return;
+               }
+               pt->Fclose();
+               delete pt;
+       }
+       
 #endif 
        // control
 # ifdef USE_BOOT_MODE
@@ -705,9 +554,7 @@ void save_config()
 #endif
        MyWritePrivateProfileBool(_T("Input"), _T("SwapJoyButtons"), config.swap_joy_buttons, config_path);
 #if defined(_USE_QT) && !defined(Q_OS_WIN)
-        config_path->Fclose();
-        AGAR_DebugLog(AGAR_LOG_INFO, "Write done.");
-               delete config_path;
+       AGAR_DebugLog(AGAR_LOG_INFO, "Write done.");
 #endif
 }
 
index bcdc62b..23aabae 100644 (file)
@@ -12,8 +12,6 @@
 
 #if defined(_USE_QT)
 #include <sys/param.h>
-#include <QtCore/QFile>
-#include <QtCore/QFileInfo>
 
 #ifndef _MAX_PATH
  #define _MAX_PATH 2048
@@ -210,15 +208,6 @@ extern config_t config;
 
 # include <string>
 
-extern bool WritePrivateProfileString(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, char *Value, FILEIO *lpFileName);
-extern bool WritePrivateProfileInt(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, int Value, FILEIO *lpFileName);
-extern BOOL WritePrivateProfileBool(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, bool Value, FILEIO *lpFileName);
-extern std::string GetPrivateProfileStr(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, FILEIO *lpFileName);
-extern void GetPrivateProfileString(const _TCHAR *section, const _TCHAR *key, const _TCHAR *defaultstr,
-                                                                       char *str, int max_len, FILEIO *p);
-extern int GetPrivateProfileInt(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, int nDefault, FILEIO *lpFileName);
-extern bool GetPrivateProfileBool(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, bool bDefault, FILEIO *lpFileName);
-
 #endif
 
 #endif
index 695082c..ca817a8 100644 (file)
@@ -19,6 +19,9 @@
 //#include <SDL/SDL.h>
 
 #include "qt_main.h"
+#include "mainwidget.h"
+#include "qt_gldraw.h"
+
 #include "agar_logger.h"
 #include <ctime>
 # endif
@@ -39,7 +42,7 @@ extern void get_long_full_path_name(_TCHAR* src, _TCHAR* dst);
 #endif
 
 #if defined(_USE_QT)
-EMU::EMU(Ui_MainWindow *hwnd, GLDrawClass *hinst)
+EMU::EMU(class Ui_MainWindow *hwnd, GLDrawClass *hinst)
 #elif defined(OSD_WIN32)
 EMU::EMU(HWND hwnd, HINSTANCE hinst)
 #else
@@ -61,7 +64,6 @@ EMU::EMU()
 #endif 
        // get module path
        // Initialize keymod.
-       modkey_status = 0;
 #if defined(_USE_QT)
        std::string tmps;
        _TCHAR tmp_path[PATH_MAX], *ptr;
@@ -69,9 +71,7 @@ EMU::EMU()
        memset(app_path, 0x00, sizeof(app_path));
        get_long_full_path_name(tmp_path, app_path);
        //AGAR_DebugLog("APPPATH=%s\n", app_path);
-       use_opengl = true;
-       use_opencl = false;
-       VMSemaphore = new QMutex(QMutex::Recursive);
+       //VMSemaphore = new QMutex(QMutex::Recursive);
        host_cpus = 4;
 #else
        _TCHAR tmp_path[_MAX_PATH], *ptr;
@@ -84,9 +84,6 @@ EMU::EMU()
                // initialize d88 file info
        memset(d88_file, 0, sizeof(d88_file));
 #endif
-#ifdef USE_AUTO_KEY
-       memset(auto_key_str, 0x00, sizeof(auto_key_str));
-#endif 
                // load sound config
        static const int freq_table[8] = {
                        2000, 4000, 8000, 11025, 22050, 44100,
@@ -114,17 +111,16 @@ EMU::EMU()
 #ifdef USE_SOUND_DEVICE_TYPE
        sound_device_type = config.sound_device_type;
 #endif
+       
        osd = new OSD();
+
 #if defined(OSD_WIN32) || defined(_USE_QT)
        osd->main_window_handle = hwnd;
-       osd->instance_handle = hinst;
+       osd->glv = hinst;
 #endif 
        osd->initialize(sound_rate, sound_samples);
        osd->vm = vm = new VM(this);
        
-#ifdef USE_DEBUGGER
-       initialize_debugger();
-#endif
        initialize_media();
        vm->initialize_sound(sound_rate, sound_samples);
        vm->reset();
@@ -133,9 +129,6 @@ EMU::EMU()
 
 EMU::~EMU()
 {
-#ifdef USE_DEBUGGER
-       release_debugger();
-#endif
        osd->release();
        delete osd;
        delete vm;
@@ -144,9 +137,9 @@ EMU::~EMU()
        release_debug_log();
 #endif
 #if defined(_USE_AGAR)
-       if(pVMSemaphore) SDL_DestroySemaphore(pVMSemaphore);
+       //if(pVMSemaphore) SDL_DestroySemaphore(pVMSemaphore);
 #elif defined(_USE_QT)
-       delete VMSemaphore;
+       //delete VMSemaphore;
 #endif
 }
 
@@ -182,7 +175,7 @@ int EMU::run()
        }
        //LockVM();
        osd->update_input();
-       osd->update_printer();
+       //osd->update_printer();
 #ifdef USE_SOCKET
        //osd->update_socket();
 #endif
@@ -232,11 +225,13 @@ void EMU::reset()
        }
        
        // reset printer
-       osd->reset_printer();
-       
+       //osd->reset_printer();
+
+#if !defined(_USE_QT) // Temporally
        // restart recording
        osd->restart_rec_sound();
        osd->restart_rec_video();
+#endif 
 }
 
 #ifdef USE_SPECIAL_RESET
@@ -246,11 +241,13 @@ void EMU::special_reset()
        vm->special_reset();
        
        // reset printer
-       osd->reset_printer();
+       //osd->reset_printer();
        
        // restart recording
+#if !defined(_USE_QT) // Temporally
        restart_rec_sound();
        restart_rec_video();
+#endif 
 }
 #endif
 
@@ -266,31 +263,6 @@ void EMU::power_off()
        osd->power_off();
 }
 
-
-_TCHAR* EMU::bios_path(const _TCHAR* file_name)
-{
-       static _TCHAR file_path[_MAX_PATH];
-       memset(file_path, 0x00, sizeof(file_path));
-       _stprintf_s(file_path, _MAX_PATH, _T("%s%s"), app_path, file_name);
-#if defined(_USE_AGAR) || defined(_USE_SDL) || defined(_USE_QT)
-       AGAR_DebugLog(AGAR_LOG_INFO, "BIOS: %s", file_path);
-#endif
-       return file_path;
-//#if defined(_USE_AGAR) || defined(_USE_SDL) || defined(_USE_QT)
-//        static _TCHAR file_path[_MAX_PATH];
-//        strcpy(file_path, app_path);
-//        strcat(file_path, file_name);
-//#if defined(_USE_AGAR) || defined(_USE_SDL) || defined(_USE_QT)
-//        AGAR_DebugLog(AGAR_LOG_INFO, "LOAD BIOS: %s\n", file_path);
-//#endif
-//#else
-//        static _TCHAR file_path[_MAX_PATH];
-//     _stprintf(file_path, _T("%s%s"), app_path, file_name);
-//        printf("LOAD: %s\n", file_path);
-//#endif
-//     return file_path;
-}
-
 void EMU::suspend()
 {
        if(!now_suspended) {
index 8001af1..718211e 100644 (file)
@@ -63,7 +63,7 @@
 #if defined(OSD_WIN32)
 #include "win32/osd.h"
 #elif defined(OSD_QT)
-#include "qt/osd/osd.h"
+#include "qt/osd.h"
 #elif defined(OSD_SDL)
 #include "sdl/osd.h"
  #endif
@@ -100,9 +100,9 @@ class EMU
 protected:
        VM* vm;
        OSD* osd;
+       int host_cpus;
 private:
        _TCHAR app_path[_MAX_PATH];
-       
        // ----------------------------------------
        // sound
        // ----------------------------------------
@@ -168,45 +168,21 @@ private:
 #endif
 
 public:
-       uint32 *getJoyStatPtr(void) {
-               return joy_status;
-       }
-   
        // ----------------------------------------
        // initialize
        // ----------------------------------------
 #if defined(_USE_QT)
-       EMU(class Ui_MainWindow*, GLDrawClass*);
+       EMU(class Ui_MainWindow *,  GLDrawClass *);
 #else
        EMU(HWND hwnd, HINSTANCE hinst);
 #endif
-        ~EMU();
+       ~EMU();
 
-       _TCHAR* application_path()
-       {
-               return app_path;
-       }
-       _TCHAR* bios_path(const _TCHAR* file_name);
 #if defined(_USE_QT)
-       EmuThreadClass *get_parent_handler(void);
-       void set_parent_handler(EmuThreadClass *p);
+#else // M$ VC
        void LockVM(void) {
-               if(host_cpus > 1) VMSemaphore->lock();
        }
        void UnlockVM(void) {
-               if(host_cpus > 1) VMSemaphore->unlock();
-       }
-       void SetHostCpus(int v) {
-               if(v <= 0) v = 1;
-               host_cpus = v;
-       }
-       int GetHostCpus() {
-               return host_cpus;
-       }
-#else // M$ VC
-        void LockVM(void) {
-       }
-        void UnlockVM(void) {
        }
 #endif
        // ----------------------------------------
@@ -215,6 +191,10 @@ public:
 #if defined(_USE_QT)
        class Ui_MainWindow *main_window_handle;
        GLDrawClass *instance_handle;
+       EmuThreadClass *get_parent_handler(void);
+       void set_parent_handler(EmuThreadClass *p) {
+               osd->set_parent_thread(p);
+       }
 #ifdef USE_DEBUGGER
     debugger_thread_t debugger_thread_param;
        CSP_Debugger *hDebugger;
@@ -222,6 +202,28 @@ public:
        VM *getVM(void) {
                return vm;
        }
+       void setMousePointer(int x, int y) {
+               osd->setMousePointer(x, y);
+       }
+       void setMouseButton(int button) {
+               osd->setMouseButton(button);
+       }
+       int getMouseButton() {
+               return osd->getMouseButton();
+       }
+       void LockVM(void) {
+               //if(host_cpus > 1) VMSemaphore->lock();
+       }
+       void UnlockVM(void) {
+               //if(host_cpus > 1) VMSemaphore->unlock();
+       }
+       void SetHostCpus(int v) {
+               if(v <= 0) v = 1;
+               host_cpus = v;
+       }
+       int GetHostCpus() {
+               return host_cpus;
+       }
        //QThread *hDebuggerThread;
 #else
        HWND main_window_handle;
@@ -257,6 +259,7 @@ public:
        void stop_auto_key();
        bool now_auto_key();
 #endif
+       
        uint8* key_buffer();
        uint32* joy_buffer();
        int* mouse_buffer();
@@ -352,7 +355,11 @@ public:
        _TCHAR* bios_path(const _TCHAR* file_name);
        void sleep(uint32 ms);
        void get_host_time(cur_time_t* time);
-
+#if defined(USE_MINIMUM_RENDERING)
+       bool screen_changed() {
+               return vm->screen_changed();
+       }
+#endif
        
        // debug log
 #ifdef _DEBUG_LOG
@@ -380,8 +387,12 @@ public:
                int cur_bank;
        } d88_file[MAX_FD];
 #endif
-       int get_access_lamp(void);
-       
+       int get_access_lamp(void);
+#if defined(_USE_QT)
+       void key_mod(uint32 mod) {
+               osd->key_mod(mod);
+       }
+#endif 
        // user interface
 #ifdef USE_CART1
        void open_cart(int drv, const _TCHAR* file_path);
@@ -431,6 +442,9 @@ public:
 #ifdef SUPPORT_DUMMY_DEVICE_LED
        uint32 get_led_status(void);
 #endif
+#if defined(USE_DIG_RESOLUTION)
+       void get_screen_resolution(int *w, int *h);
+#endif
        void update_config();
        // state
 #ifdef USE_STATE
index 247a0d1..3c869ca 100644 (file)
@@ -97,10 +97,14 @@ bool FILEIO::Fopen(const _TCHAR *file_path, int mode)
                return ((fp = _tfopen(file_path, _T("r"))) != NULL);
        case FILEIO_WRITE_ASCII:
                return ((fp = _tfopen(file_path, _T("w"))) != NULL);
+       case FILEIO_WRITE_APPEND_ASCII:
+               return ((fp = _tfopen(file_path, _T("a"))) != NULL);
        case FILEIO_READ_WRITE_ASCII:
                return ((fp = _tfopen(file_path, _T("r+"))) != NULL);
        case FILEIO_READ_WRITE_NEW_ASCII:
                return ((fp = _tfopen(file_path, _T("w+"))) != NULL);
+       case FILEIO_READ_WRITE_APPEND_ASCII:
+               return ((fp = _tfopen(file_path, _T("a+"))) != NULL);
        }
        return false;
 }
index 240cdc7..41bd0c4 100644 (file)
@@ -29,6 +29,8 @@
 #define FILEIO_WRITE_ASCII             6
 #define FILEIO_READ_WRITE_ASCII                7
 #define FILEIO_READ_WRITE_NEW_ASCII    8
+#define FILEIO_WRITE_APPEND_ASCII      9
+#define FILEIO_READ_WRITE_APPEND_ASCII 10
 #define FILEIO_SEEK_SET                        0
 #define FILEIO_SEEK_CUR                        1
 #define FILEIO_SEEK_END                        2
index 3e11c00..a3409d5 100644 (file)
@@ -32,8 +32,8 @@ void DrawThreadClass::doDraw(bool flag)
        if(flag) {
                emit sig_draw_timing(true);
                draw_frames = p_emu->draw_screen();
-               p = p_emu->getPseudoVramClass(); 
-               emit sig_update_screen(p);
+               //p = p_emu->getPseudoVramClass(); 
+               //emit sig_update_screen(p);
        } else {
                draw_frames = 1;
        }
index 9fe7ee5..6ff19a4 100644 (file)
@@ -134,7 +134,8 @@ void EmuThreadClass::do_start_auto_key(QString ctext)
        clipBoardText = ctext;
        if(clipBoardText.size() > 0) {
                array = codec->fromUnicode(clipBoardText.toUtf8());
-               p_emu->set_auto_key_string((const char *)array.constData());
+               //p_emu->set_auto_key_string((const char *)array.constData());
+               emit sig_auto_key_string(array);
                //AGAR_DebugLog(AGAR_LOG_DEBUG, "AutoKey: SET :%s\n", clipBoardText.toUtf8().constData());
                p_emu->start_auto_key();
        }
@@ -601,7 +602,7 @@ void EmuThreadClass::doWork(const QString &params)
                        opengl_filter_num_bak = config.opengl_filter_num;
 #endif
                        interval += get_interval();
-                       now_skip = p_emu->now_skip() & !p_emu->now_rec_video;
+                       now_skip = p_emu->now_skip() & !p_emu->now_rec_video();
                        //p_emu->UnlockVM();
 
                        if((prev_skip && !now_skip) || next_time == 0) {
@@ -658,10 +659,10 @@ _exit:
        this->quit();
 }
 
-void EmuThreadClass::doSetDisplaySize(int w, int h, bool flag)
+void EmuThreadClass::doSetDisplaySize(int w, int h, int ww, int wh)
 {
        p_emu->suspend();
-       p_emu->set_display_size(w, h, flag);
+       p_emu->set_vm_screen_size(w, h, -1, -1, ww, wh);
 }
 
 void EmuThreadClass::doUpdateConfig()
index 9a65fcd..6715e9d 100644 (file)
@@ -95,7 +95,7 @@ public slots:
        void doUpdateConfig();
        void doStartRecordSound();
        void doStopRecordSound();
-       void doSetDisplaySize(int w, int h, bool flag);
+       void doSetDisplaySize(int w, int h, int ww, int wh);
        
        void moved_mouse(int, int);
        void button_pressed_mouse(Qt::MouseButton);
@@ -169,6 +169,7 @@ signals:
 #endif
        int sig_resize_screen(int, int);
        int sig_resize_uibar(int, int);
+       int sig_auto_key_string(QByteArray);
 };
 
 QT_END_NAMESPACE
index 20038e4..9d9fe68 100644 (file)
@@ -65,6 +65,7 @@ void Ui_MainWindow::OnStopAutoKey(void)
 void Ui_MainWindow::OnOpenDebugger(int no)
 {
        if((no < 0) || (no > 3)) return;
+# if 0 
        //emu->open_debugger(no);
        VM *vm = emu->getVM();
        if(emu->now_debugging)  this->OnCloseDebugger();
@@ -89,10 +90,12 @@ void Ui_MainWindow::OnOpenDebugger(int no)
                        emu->hDebugger->run();
                }
        }
+# endif        
 }
 
 void Ui_MainWindow::OnCloseDebugger(void )
 {
+# if 0
 //     emu->close_debugger();
        if(emu->now_debugging) {
                if(emu->hDebugger->debugger_thread_param.running) {
@@ -103,6 +106,7 @@ void Ui_MainWindow::OnCloseDebugger(void )
                emu->hDebugger = NULL;
                emu->now_debugging = false;
        }
+# endif
 }
 #endif
 
index 9ed6002..0096851 100644 (file)
@@ -73,7 +73,7 @@ void JoyThreadClass::x_axis_changed(int index, int value)
 {
        if(p_emu == NULL) return;
        p_emu->LockVM();
-       uint32_t *joy_status = p_emu->getJoyStatPtr();
+       uint32_t *joy_status = p_emu->joy_buffer();
    
        if(joy_status != NULL) {
                if(value < -8192) { // left
@@ -91,7 +91,7 @@ void JoyThreadClass::y_axis_changed(int index, int value)
 {
        if(p_emu == NULL) return;
        p_emu->LockVM();
-       uint32_t *joy_status = p_emu->getJoyStatPtr();
+       uint32_t *joy_status = p_emu->joy_buffer();
    
        if(joy_status != NULL) {
                if(value < -8192) {// up
@@ -109,7 +109,7 @@ void JoyThreadClass::button_down(int index, unsigned int button)
 {
        if(p_emu == NULL) return;
        p_emu->LockVM();
-       uint32_t *joy_status = p_emu->getJoyStatPtr();
+       uint32_t *joy_status = p_emu->joy_buffer();
        if(joy_status != NULL) {
                joy_status[index] |= (1 << (button + 4));
        }
@@ -121,7 +121,7 @@ void JoyThreadClass::button_up(int index, unsigned int button)
        if(p_emu == NULL) return;
    
        p_emu->LockVM();
-       uint32_t *joy_status = p_emu->getJoyStatPtr();
+       uint32_t *joy_status = p_emu->joy_buffer();
        if(joy_status != NULL) {
                joy_status[index] &= ~(1 << (button + 4));
        }
index 86f99a9..1936bc8 100644 (file)
@@ -60,13 +60,13 @@ struct NativeVirtualKeyCode {
        uint32_t key;
 };
 
-typedef struct VertexTexCoord_t {
+typedef struct  {
                GLfloat x, y, z;
                GLfloat s, t;
-};
-typedef struct VertexLines_t {
+} VertexTexCoord_t;
+typedef struct {
                GLfloat x, y;
-};
+} VertexLines_t ;
 
 #if defined(_USE_GLAPI_QT5_4)
 class GLDrawClass: public QOpenGLWidget 
@@ -265,6 +265,7 @@ public slots:
        void enterEvent(QEvent *);
        void leaveEvent(QEvent *);
        void do_save_frame_screen(void);
+       void do_save_frame_screen(const char *);
        
 signals:
        void update_screenChanged(int tick);
index 321cc5a..71cba76 100644 (file)
@@ -142,3 +142,11 @@ void GLDrawClass::do_save_frame_screen(void)
                filename_screen_pixmap = QString::fromUtf8(p_emu->bios_path(tmps.toUtf8().constData()));
        }
 }
+
+void GLDrawClass::do_save_frame_screen(const char *name)
+{
+       if(!save_pixmap_req) {
+               save_pixmap_req = true;
+               filename_screen_pixmap = QString::fromUtf8(name);
+       }
+}
index be80467..59d7974 100644 (file)
@@ -85,7 +85,7 @@ void Ui_MainWindow::set_window(int mode)
                config.window_mode = prev_window_mode = mode;
                
                // set screen size to emu class
-               emit sig_emu_set_display_size(width, height, true);
+               emit sig_emu_set_display_size(width, height, width, height);
                //emit sig_resize_screen(width, height);
                this->resize_statusbar(width, height);
        } else if(!now_fullscreen) {
@@ -110,7 +110,7 @@ void Ui_MainWindow::set_window(int mode)
 
                }
                config.window_mode = mode;
-               emit sig_emu_set_display_size(width, height, false);
+               emit sig_emu_set_display_size(SCREEN_WIDTH, SCREEN_HEIGHT, width, height);
                //emit sig_resize_screen(width, height);
                this->resize_statusbar(width, height);
        }
@@ -164,7 +164,9 @@ void Ui_MainWindow::LaunchEmuThread(void)
        int drvs;
        
        hRunEmu = new EmuThreadClass(rMainWindow, emu, this);
+       emu->set_parent_handler(hRunEmu);
        connect(hRunEmu, SIGNAL(message_changed(QString)), this, SLOT(message_status_bar(QString)));
+       
        //connect(hRunEmu, SIGNAL(sig_finished()), this, SLOT(delete_emu_thread()));
        connect(this, SIGNAL(sig_vm_reset()), hRunEmu, SLOT(doReset()));
        connect(this, SIGNAL(sig_vm_specialreset()), hRunEmu, SLOT(doSpecialReset()));
@@ -174,7 +176,7 @@ void Ui_MainWindow::LaunchEmuThread(void)
        connect(this, SIGNAL(sig_emu_update_config()), hRunEmu, SLOT(doUpdateConfig()));
        connect(this, SIGNAL(sig_emu_start_rec_sound()), hRunEmu, SLOT(doStartRecordSound()));
        connect(this, SIGNAL(sig_emu_stop_rec_sound()), hRunEmu, SLOT(doStopRecordSound()));
-       connect(this, SIGNAL(sig_emu_set_display_size(int, int, bool)), hRunEmu, SLOT(doSetDisplaySize(int, int, bool)));
+       connect(this, SIGNAL(sig_emu_set_display_size(int, int, int, int)), hRunEmu, SLOT(doSetDisplaySize(int, int, int, int)));
        
 
 #if defined(USE_FD1) || defined(USE_FD2) || defined(USE_FD3) || defined(USE_FD4) || \
@@ -449,7 +451,7 @@ void get_short_filename(_TCHAR *dst, _TCHAR *file, int maxlen)
 void Ui_MainWindow::OnWindowRedraw(void)
 {
        if(emu) {
-               emu->update_screen();
+               //emu->update_screen();
        }
 }
 
index 6582d79..d03a9f7 100644 (file)
@@ -742,9 +742,9 @@ int CSP_DebuggerThread::debugger_main(QString command)
                                                msec = my_hexatoi(arg_3);
                                        }
 #ifdef SUPPORT_VARIABLE_TIMING
-                                       p->emu->key_buffer()[code] = (int)fmax(p->vm->frame_rate() * (double)msec / 1000.0 + 0.5, 1.0);
+                                       //p->emu->key_buffer()[code] = (int)fmax(p->vm->frame_rate() * (double)msec / 1000.0 + 0.5, 1.0);
 #else
-                                       p->emu->key_buffer()[code] = (int)fmax(FRAMES_PER_SEC * (double)msec / 1000.0 + 0.5, 1.0);
+                                       //p->emu->key_buffer()[code] = (int)fmax(FRAMES_PER_SEC * (double)msec / 1000.0 + 0.5, 1.0);
 #endif
 #ifdef NOTIFY_KEY_DOWN
                                        p->vm->key_down(code, false);
index b4bd925..224de1b 100644 (file)
@@ -146,29 +146,6 @@ CSP_Debugger::~CSP_Debugger()
 }
    
 
-void EMU::initialize_debugger()
-{
-       now_debugging = false;
-       hDebugger = NULL;
-}
-
-void EMU::release_debugger()
-{
-       close_debugger();
-}
-
-void EMU::open_debugger(int cpu_index)
-{
-}
-
-void EMU::close_debugger()
-{
-}
-
-bool EMU::debugger_enabled(int cpu_index)
-{
-       return (vm->get_cpu(cpu_index) != NULL && vm->get_cpu(cpu_index)->get_debugger() != NULL);
-}
 
 #endif
 
index e3a5ac2..bbc1542 100644 (file)
@@ -559,7 +559,7 @@ signals:
        int sig_emu_update_config(void);
        int sig_emu_start_rec_sound(void);
        int sig_emu_stop_rec_sound(void);
-       int sig_emu_set_display_size(int, int, bool);
+       int sig_emu_set_display_size(int, int, int, int);
        
 #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 4bd879a..bd873c5 100644 (file)
@@ -9,14 +9,17 @@
 
 #include "osd.h"
 #include <string>
-#include <QDataTime>
+#include <QDateTime>
 #include <QDate>
 #include <QTime>
 #include <QString>
+#include <QObject>
+#include "emu_thread.h"
+#include "qt_gldraw.h"
+#include "agar_logger.h"
 
-OSD::OSD() : public QThread(0)
+OSD::OSD() : QThread(0)
 {
-
 }
 
 OSD::~OSD()
@@ -24,22 +27,34 @@ OSD::~OSD()
 }
 
 extern std::string cpp_homedir;
+extern std::string my_procname;
+
+void OSD::set_parent_thread(EmuThreadClass *parent)
+{
+       parent_thread = parent;
+       QObject::moveToThread(parent);
+       connect(this, SIGNAL(sig_update_screen(QImage *)), glv, SLOT(update_screen(QImage *)));
+       connect(this, SIGNAL(sig_save_screen(const char *)), glv, SLOT(do_save_frame_screen(const char *)));
+       connect(this, SIGNAL(sig_close_window()), parent, SLOT(doExit()));
+       connect(parent, SIGNAL(sig_auto_key_string(QByteArray)), this, SLOT(set_auto_key_string(QByteArray)));
+}
+
 void OSD::initialize(int rate, int samples)
 {
        // get module path
        QString tmp_path;
-       tmp_path.fromStdString(cpp_homedir);
+       tmp_path = QString::fromStdString(cpp_homedir);
        tmp_path = tmp_path + QString::fromStdString(my_procname);
 #if defined(Q_OS_WIN)
        const char *delim = "\\";
 #else
        const char *delim = "/";
 #endif
-       tmp_path = tmp_path + tmp_path.fromUtf8(delim);
-       memset(app_path, 0x00, sizeof(app_path);
+       tmp_path = tmp_path + QString::fromUtf8(delim);
+       memset(app_path, 0x00, sizeof(app_path));
        strncpy(app_path, tmp_path.toUtf8().constData(), _MAX_PATH);
        
-                  //CoInitialize(NULL);
+       //CoInitialize(NULL);
        initialize_input();
 //     initialize_printer();
        initialize_screen();
@@ -96,6 +111,7 @@ _TCHAR* OSD::bios_path(const _TCHAR* file_name)
 {
        static _TCHAR file_path[_MAX_PATH];
        snprintf(file_path, _MAX_PATH, _T("%s%s"), app_path, file_name);
+       AGAR_DebugLog(AGAR_LOG_INFO, "BIOS PATH:%s", file_path);
        return file_path;
 }
 
@@ -112,7 +128,7 @@ void OSD::get_host_time(cur_time_t* time)
        time->day = d.day();
        time->day_of_week = d.dayOfWeek();
        time->hour = t.hour();
-       time->minute = t.mnute();
+       time->minute = t.minute();
        time->second = t.second();
 }
 
index 4588545..1a486fa 100644 (file)
@@ -120,10 +120,10 @@ typedef struct screen_buffer_s {
        //HBITMAP hBmp, hOldBmp;
        //LPBYTE lpBuf;
        scrntype* lpBuf;
-       QImage *pImage
+       QImage *pImage;
        inline scrntype* get_buffer(int y)
        {
-               if((pImage !=NULL) && (y < height) && (y >= 0)) return pImage->scanLine(y);
+               if((pImage !=NULL) && (y < height) && (y >= 0)) return (scrntype *)pImage->scanLine(y);
                return NULL;
        }
 } screen_buffer_t;
@@ -133,7 +133,7 @@ typedef struct {
        scrntype* lpBmp;
        //LPBITMAPINFOHEADER pbmInfoHeader;
        DWORD dwAVIFileSize;
-       LONG lAVIFrames;
+       UINT64 lAVIFrames;
        int frames;
        int result;
 } rec_video_thread_param_t;
@@ -142,6 +142,9 @@ class FIFO;
 class FILEIO;
 class GLDrawClass;
 class EmuThreadClass;
+class Ui_MainWindow;
+class EMU;
+class VM;
 
 QT_BEGIN_NAMESPACE
 class OSD : public QThread
@@ -150,13 +153,15 @@ class OSD : public QThread
 protected:
 //     VM* vm;
 //     EMU* emu;
-       
-private:
+       EmuThreadClass *parent_thread;
+       _TCHAR auto_key_str[2048];
+       sdl_snddata_t snddata;
+       private:
        _TCHAR app_path[_MAX_PATH];
        
        // console
        FILE *hStdIn, *hStdOut;
-       
+
        // input
        void initialize_input();
        void release_input();
@@ -173,6 +178,7 @@ private:
        uint8 key_converted[256];
        bool key_shift_pressed, key_shift_released;
 #endif
+       uint32_t modkey_status;
        bool lost_focus;
        
        uint32 joy_status[2];   // joystick #1, #2 (b0 = up, b1 = down, b2 = left, b3 = right, b4- = buttons
@@ -238,7 +244,7 @@ private:
        //PAVISTREAM pAVICompressed;
        //AVICOMPRESSOPTIONS AVIOpts;
        DWORD dwAVIFileSize;
-       LONG lAVIFrames;
+       UINT64 lAVIFrames;
        //HANDLE hVideoThread;
        rec_video_thread_param_t rec_video_thread_param;
        
@@ -252,7 +258,6 @@ private:
        
        int sound_rate, sound_samples;
        bool sound_ok, sound_started, now_mute;
-       
        bool sound_first_half;
        
        _TCHAR sound_file_name[_MAX_PATH];
@@ -260,6 +265,7 @@ private:
        int rec_sound_bytes;
        int rec_sound_buffer_ptr;
        
+       
 #if defined(USE_MOVIE_PLAYER) || defined(USE_VIDEO_CAPTURE)
        // video device
        void initialize_video();
@@ -318,7 +324,9 @@ public:
        // common
        VM* vm;
        //EMU* emu;
-       
+       class Ui_MainWindow *main_window_handle;
+       GLDrawClass *glv;
+
        void initialize(int rate, int samples);
        void release();
        void power_off();
@@ -359,7 +367,6 @@ public:
        void key_mod(uint32 mod) {
                modkey_status = mod;
        }
-       void set_auto_key_string(const char *cstr);
        void enable_mouse();
        void disenable_mouse();
        void toggle_mouse();
@@ -499,9 +506,13 @@ public:
 
        // win32 dependent
        void update_screen();
+       void set_parent_thread(EmuThreadClass *parent);
+public slots:
+       void set_auto_key_string(QByteArray);
+       
 signals:
-       int sig_update_screen(void *);
-       int sig_save_screen(void);
+       int sig_update_screen(QImage *);
+       int sig_save_screen(const char *);
        int sig_window_close(void);
        
 };
index da363cb..85d4727 100644 (file)
@@ -9,10 +9,10 @@
 
 #include "osd.h"
 
-BOOL WINAPI ctrl_c_handler(DWORD type)
-{
-       return TRUE;
-}
+//BOOL WINAPI ctrl_c_handler(DWORD type)
+//{
+//     return TRUE;
+//}
 
 void OSD::open_console(_TCHAR* title)
 {
@@ -64,10 +64,10 @@ void OSD::write_console(_TCHAR* buffer, unsigned int length)
 
 int OSD::read_console_input(_TCHAR* buffer)
 {
+       int count = 0;
 #if 0
        INPUT_RECORD ir[16];
        DWORD dwRead;
-       int count = 0;
        
        if(ReadConsoleInput(hStdIn, ir, 16, &dwRead)) {
                for(unsigned int i = 0; i < dwRead; i++) {
@@ -83,7 +83,6 @@ int OSD::read_console_input(_TCHAR* buffer)
                }
        }
 #endif
-       count = 0;
        return count;
 }
 
index 62857e4..374e05f 100644 (file)
@@ -538,7 +538,6 @@ void OSD::update_input()
 void OSD::key_down(int code, bool repeat)
 {
        bool keep_frames = false;
-       uint8 code = sym;
        if(code == VK_SHIFT){
 #ifndef USE_SHIFT_NUMPAD_KEY
                if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
@@ -622,7 +621,6 @@ void OSD::key_down(int code, bool repeat)
 
 void OSD::key_up(int code)
 {
-       uint8 code = sym;
        if(code == VK_SHIFT) {
 #ifndef USE_SHIFT_NUMPAD_KEY
                if(!(GetAsyncKeyState(VK_SHIFT) & 0x8000)) {
@@ -832,10 +830,10 @@ void OSD::enable_mouse()
                QPoint pos;
                mouse_oldx = mouse_ptrx = SCREEN_WIDTH / 2;
                mouse_oldy = mouse_ptry = SCREEN_HEIGHT / 2;
-               cursor = instance_handle->cursor();
-               pos.setX(instance_handle->width() / 2);
-               pos.setY(instance_handle->height() / 2);
-               cursor.setPos(instance_handle->mapToGlobal(pos));
+               cursor = glv->cursor();
+               pos.setX(glv->width() / 2);
+               pos.setY(glv->height() / 2);
+               cursor.setPos(glv->mapToGlobal(pos));
                QApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
                //mouse_shape = cursor.shape();
                //cursor.setShape(Qt::BlankCursor);
@@ -843,7 +841,7 @@ void OSD::enable_mouse()
                mouse_status[1] = 0;
                mouse_status[2] = mouse_button;
        }
-       instance_handle->setMouseTracking(true);
+       glv->setMouseTracking(true);
        mouse_enabled = true;
 }
 
@@ -852,10 +850,10 @@ void OSD::disenable_mouse()
        // disenable mouse emulation
        if(mouse_enabled) {
                QCursor cursor;
-               cursor = instance_handle->cursor();
+               cursor = glv->cursor();
                if(QApplication::overrideCursor() != NULL) QApplication::restoreOverrideCursor();
                //QApplication::restoreOverrideCursor();
-               instance_handle->setMouseTracking(false);
+               glv->setMouseTracking(false);
        }
        mouse_enabled = false;
 }
@@ -897,11 +895,11 @@ static const int autokey_table[256] = {
        0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000
 };
 
-void OSD::set_auto_key_string(const char *cstr)
+void OSD::set_auto_key_string(QByteArray cstr)
 {
        stop_auto_key();
        memset(auto_key_str, 0x00, sizeof(auto_key_str));
-       strncpy(auto_key_str, cstr, sizeof(auto_key_str) - 2);
+       strncpy(auto_key_str, (const char *)(cstr.constData()), sizeof(auto_key_str) - 2);
 }
 
 void OSD::start_auto_key()
index 773acd8..6adf31b 100644 (file)
@@ -26,15 +26,11 @@ void OSD::initialize_screen()
        vm_screen_height_aspect = SCREEN_HEIGHT_ASPECT;
        
        memset(&vm_screen_buffer, 0, sizeof(screen_buffer_t));
+       vm_screen_buffer.pImage = new QImage(SCREEN_WIDTH, SCREEN_HEIGHT, QImage::Format_ARGB32);
 #ifdef USE_CRT_FILTER
        memset(&filtered_screen_buffer, 0, sizeof(screen_buffer_t));
+       filtered_screen_buffer.pImage = new QImage(SCREEN_WIDTH_ASPECT, SCREEN_HEIGHT_ASPECT, QImage::Format_ARGB32);
 #endif
-#ifdef USE_SCREEN_ROTATE
-       memset(&rotated_screen_buffer, 0, sizeof(screen_buffer_t));
-#endif
-       memset(&stretched_screen_buffer, 0, sizeof(screen_buffer_t));
-       memset(&shrinked_screen_buffer, 0, sizeof(screen_buffer_t));
-       memset(&video_screen_buffer, 0, sizeof(screen_buffer_t));
        
        now_rec_video = false;
        //pAVIStream = NULL;
@@ -55,12 +51,6 @@ void OSD::release_screen()
 #ifdef USE_CRT_FILTER
        release_screen_buffer(&filtered_screen_buffer);
 #endif
-#ifdef USE_SCREEN_ROTATE
-       release_screen_buffer(&rotated_screen_buffer);
-#endif
-       release_screen_buffer(&stretched_screen_buffer);
-       release_screen_buffer(&shrinked_screen_buffer);
-       release_screen_buffer(&video_screen_buffer);
 }
 
 int OSD::get_window_width(int mode)
@@ -114,7 +104,7 @@ void OSD::set_vm_screen_size(int width, int height, int width_aspect, int height
                base_window_height = window_height;
                
                // change the window size
-               PostMessage(main_window_handle, WM_RESIZE, 0L, 0L);
+               //emit sig_resize_glv(vm_screen_width, vm_screen_height);
        }
 }
 
@@ -123,6 +113,7 @@ scrntype* OSD::get_vm_screen_buffer(int y)
        return vm_screen_buffer.get_buffer(y);
 }
 
+
 int OSD::draw_screen()
 {
        // check avi file recording timing
@@ -136,8 +127,9 @@ int OSD::draw_screen()
                        stop_rec_video();
 //                     stop_rec_sound();
                }
-               initialize_screen_buffer(&vm_screen_buffer, vm_screen_width, vm_screen_height, COLORONCOLOR);
+               initialize_screen_buffer(&vm_screen_buffer, vm_screen_width, vm_screen_height, 0);
        }
+
        vm->draw_screen();
        
        // screen size was changed in vm->draw_screen()
@@ -148,7 +140,8 @@ int OSD::draw_screen()
        
        // calculate screen size
        // invalidate window
-       emit sig_update_screen((void *)draw_screen_buffer);
+       emit sig_update_screen(draw_screen_buffer->pImage);
+
        first_draw_screen = self_invalidate = true;
        
        // record avi file
@@ -181,7 +174,7 @@ void OSD::initialize_screen_buffer(screen_buffer_t *buffer, int width, int heigh
 
 void OSD::release_screen_buffer(screen_buffer_t *buffer)
 {
-       if(!(buffer->width == 0 && buffer->height == 0)) {
+       if(!(buffer->width == 0 && buffer->height == 0) && (buffer->pImage != NULL)) {
                delete buffer->pImage;
        }
        memset(buffer, 0, sizeof(screen_buffer_t));
@@ -575,9 +568,10 @@ void OSD::stretch_screen_buffer(screen_buffer_t *source, screen_buffer_t *dest)
 void OSD::capture_screen()
 {
        // create file name
-       //_TCHAR file_name[_MAX_PATH];
-       //create_date_file_name(file_name, _MAX_PATH, _T("bmp"));
-       emit sig_save_screen(); 
+       char file_name[_MAX_PATH];
+       memset(file_name, 0x00, sizeof(file_name));
+       create_date_file_name((_TCHAR *)file_name, _MAX_PATH, _T("png"));
+       emit sig_save_screen((const char *)file_name); 
        // create bitmap
 }
 
@@ -598,7 +592,7 @@ bool OSD::start_rec_video(int fps)
                return false;
        }
        if(video_screen_buffer.width != vm_screen_buffer.width || video_screen_buffer.height != vm_screen_buffer.height) {
-               initialize_screen_buffer(&video_screen_buffer, vm_screen_buffer.width, vm_screen_buffer.height, COLORONCOLOR);
+               initialize_screen_buffer(&video_screen_buffer, vm_screen_buffer.width, vm_screen_buffer.height, 0);
        }
        
        // stream header
index 51dd48c..0a03fd4 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "osd.h"
 
+#ifdef USE_SOCKET
 void OSD::initialize_socket()
 {
        for(int i = 0; i < SOCKET_MAX; i++) {
@@ -118,4 +119,4 @@ void OSD::send_data(int ch)
 void OSD::recv_data(int ch)
 {
 }
-
+#endif
index 3527c39..761bf4b 100644 (file)
 #include "osd.h"
 #include "../fileio.h"
 #include <SDL.h>
+#include "qt_main.h"
+#include "agar_logger.h"
+
+#include <QString>
+#include <QDateTime>
 
 extern "C" {
-       int uBufSize;
-       int nSndDataLen, nSndDataPos, nSndWritePos;
-       bool bSndExit;
-       bool bSoundDebug;
-       SDL_sem *pSndApplySem;
-       Sint16 *pSoundBuf;
+       static int uBufSize;
+       static int nSndDataLen, nSndDataPos, nSndWritePos;
+       static bool bSndExit;
+       static bool bSoundDebug;
+       static SDL_sem *pSndApplySem;
+       static Sint16 *pSoundBuf;
        Uint8 iTotalVolume;
 #if defined(USE_SDL2)   
-       SDL_AudioDeviceID nAudioDevid;
+       static SDL_AudioDeviceID nAudioDevid;
 #else
-       int nAudioDevid;
-#endif  
+       static int nAudioDevid;
+#endif
+       static SDL_AudioSpec SndSpecReq, SndSpecPresented;
 }
 
 void AudioCallbackSDL(void *udata, Uint8 *stream, int len)
@@ -102,15 +108,14 @@ void AudioCallbackSDL(void *udata, Uint8 *stream, int len)
 
 void OSD::initialize_sound(int rate, int samples)
 {
+       std::string devname;
+       int i;
+
        sound_rate = rate;
        sound_samples = samples;
        sound_ok = sound_started = now_mute = now_rec_sound = false;
        rec_sound_buffer_ptr = 0;
-       std::string devname;
-       int i;
-
        sound_ok = sound_started = now_mute = now_rec_sound = false;
-       rec_buffer_ptr = 0;
        nSndWritePos = 0;
        nSndDataLen = 0;
        uBufSize = 0;
@@ -166,7 +171,6 @@ void OSD::initialize_sound(int rate, int samples)
        }
        AGAR_DebugLog(AGAR_LOG_INFO, "Sound OK: BufSize = %d", uBufSize);
        ZeroMemory(pSoundBuf, uBufSize * sizeof(Sint16));
-       sound_ok = first_half = true;
 #if defined(USE_SDL2)   
        SDL_PauseAudioDevice(nAudioDevid, 0);
 #else   
@@ -209,7 +213,7 @@ void OSD::update_sound(int* extra_frames)
                // start play
                // check current position
                play_c = nSndWritePos;
-               if(!first_half) {
+               if(!sound_first_half) {
                        if(play_c < (uBufSize / 2)) {
                                return;
                        }
@@ -225,11 +229,11 @@ void OSD::update_sound(int* extra_frames)
                Sint16* sound_buffer = (Sint16 *)vm->create_sound(extra_frames);
                if(now_rec_sound) {
                        // record sound
-                       if(sound_samples > rec_buffer_ptr) {
-                               int samples = sound_samples - rec_buffer_ptr;
+                       if(sound_samples > rec_sound_buffer_ptr) {
+                               int samples = sound_samples - rec_sound_buffer_ptr;
                                int length = samples * sizeof(uint16) * 2; // stereo
-                               rec->Fwrite(sound_buffer + rec_buffer_ptr * 2, length, 1);
-                               rec_bytes += length;
+                               rec_sound_fio->Fwrite(sound_buffer + rec_sound_buffer_ptr * 2, length, 1);
+                               rec_sound_bytes += length;
                                if(now_rec_video) {
                                        // sync video recording
                                        static double frames = 0;
@@ -257,7 +261,7 @@ void OSD::update_sound(int* extra_frames)
 //                                     rec_video_run_frames -= rec_video_frames;
                                }
                        }
-                       rec_buffer_ptr = 0;
+                       rec_sound_buffer_ptr = 0;
                }
                if(sound_buffer) {
                        int ssize;
@@ -295,7 +299,7 @@ void OSD::update_sound(int* extra_frames)
                }
           
 //             SDL_PauseAudioDevice(nAudioDevid, 0);
-               first_half = !first_half;
+               sound_first_half = !sound_first_half;
        }
 }
 
@@ -340,7 +344,11 @@ void OSD::mute_sound()
 void OSD::stop_sound()
 {
        if(sound_ok && sound_started) {
-               lpdsSecondaryBuffer->Stop();
+#if defined(USE_SDL2)   
+               SDL_PauseAudioDevice(nAudioDevid, 1);
+#else   
+               SDL_PauseAudio(1);
+#endif   
                sound_started = false;
        }
 }
@@ -349,15 +357,15 @@ void OSD::start_rec_sound()
 {
    
        if(!now_rec_sound) {
-               LockVM();
-               std::tm *tm;
-               std::time_t tnow;
-               tnow = std::time(NULL);
-               tm = std::localtime(&tnow);
-               
-               sprintf(sound_file_name, _T("%d-%0.2d-%0.2d_%0.2d-%0.2d-%0.2d.wav"), tm->tm_year + 1900, tm->tm_mon + 1, 
-                               tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
+               //LockVM();
                
+               QDateTime nowTime = QDateTime::currentDateTime();
+               QString tmps = QString::fromUtf8("Screen_Save_emu");
+               tmps = tmps + QString::fromUtf8(CONFIG_NAME);
+               tmps = tmps + QString::fromUtf8("_");
+               tmps = tmps + nowTime.toString(QString::fromUtf8("yyyy-MM-dd_hh-mm-ss.zzz"));
+               tmps = tmps + QString::fromUtf8(".wav");
+               strncpy(sound_file_name, tmps.toUtf8().constData(), sizeof(sound_file_name));
                // create wave file
                rec_sound_fio = new FILEIO();
                if(rec_sound_fio->Fopen(bios_path(sound_file_name), FILEIO_WRITE_BINARY)) {
@@ -365,21 +373,21 @@ void OSD::start_rec_sound()
                        wav_header_t header;
                        memset(&header, 0, sizeof(wav_header_t));
                        rec_sound_fio->Fwrite(&header, sizeof(wav_header_t), 1);
-                       rec_bytes = 0;
-                       rec_buffer_ptr = vm->sound_buffer_ptr();
+                       rec_sound_bytes = 0;
+                       rec_sound_buffer_ptr = vm->sound_buffer_ptr();
                        now_rec_sound = true;
                } else {
                        // failed to open the wave file
                        delete rec_sound_fio;
                }
-               UnlockVM();
+               //UnlockVM();
        }
 }
 
 void OSD::stop_rec_sound()
 {
                if(now_rec_sound) {
-               LockVM();
+                       //LockVM();
                if(rec_sound_bytes == 0) {
                        rec_sound_fio->Fclose();
                        rec_sound_fio->RemoveFile(sound_file_name);
@@ -399,16 +407,16 @@ void OSD::stop_rec_sound()
                        wav_header.block_size = EndianToLittle_WORD(wav_header.channels * wav_header.sample_bits / 8);
                        wav_header.data_speed = EndianToLittle_DWORD(wav_header.sample_rate * wav_header.block_size);
                        
-                       memcpy(wav_chunk.id, "data", 4);
-                       wav_chunk.size = EndianToLittle_DWORD(rec_sound_bytes);
+                       memcpy(wav_header.fmt_chunk.id, "data", 4);
+                       wav_header.fmt_chunk.size = EndianToLittle_DWORD(rec_sound_bytes);
 
                        rec_sound_fio->Fseek(0, FILEIO_SEEK_SET);
-                       rec_sound_fio->Fwrite(&header, sizeof(wav_header_t), 1);
+                       rec_sound_fio->Fwrite(&wav_header, sizeof(wav_header_t), 1);
                        rec_sound_fio->Fclose();
                }
                delete rec_sound_fio;
                now_rec_sound = false;
-               UnlockVM();
+               //UnlockVM();
        }
 }
 
index a5686c4..50f17cb 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "osd.h"
 
+#if defined(USE_MOVIE_PLAYER) || defined(USE_VIDEO_CAPTURE)
 void OSD::initialize_video()
 {
 #if 0
@@ -122,6 +123,8 @@ void OSD::mute_video_dev(bool l, bool r)
        }
 #endif 
 }
+#endif // #if defined(USE_MOVIE_PLAYER) || defined(USE_VIDEO_CAPTURE)
+
 
 #ifdef USE_MOVIE_PLAYER
 bool OSD::open_movie_file(const _TCHAR* file_path)
@@ -576,7 +579,7 @@ void OSD::show_capture_dev_source()
                }
                SAFE_RELEASE(pCrs);
        }
-#enduif        
+#endif 
 }
 
 void OSD::set_capture_dev_channel(int ch)