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/)
vm_vm
common_common
vm_fmgen
-# common_scaler-generic
+ qt_osd
qt_fm7
qt_gui
)
#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)
set(LOCAL_LIBS vm_fmr50
vm_vm
common_common
-# common_scaler-generic
+ qt_osd
qt_fmr50
qt_gui
)
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)
set(LOCAL_LIBS vm_sms
vm_vm
common_common
+ qt_osd
vm_fmgen
-# common_scaler-generic
qt_sms
qt_gui
)
#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)
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)
vm_vm
common_common
qt_gui
+ qt_osd
qt_debugger
qt_pasopia
)
vm_vm
common_common
qt_gui
+ qt_osd
qt_debugger
qt_pasopia
)
vm_vm
common_common
qt_gui
+ qt_osd
qt_debugger
qt_pasopia
)
vm_vm
common_common
qt_gui
+ qt_osd
qt_debugger
qt_pasopia
)
vm_vm
common_common
vm_fmgen
-# common_scaler-generic
+ qt_osd
qt_pc9801
qt_gui
)
#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()
-
set(LOCAL_LIBS vm_mz2500
vm_vm
common_common
+ qt_osd
qt_mz2500
qt_gui
)
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)
vm_vm
common_common
vm_fmgen
-# common_scaler-generic
+ qt_osd
qt_mz700
qt_gui
)
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)
vm_vm
common_common
vm_fmgen
-# common_scaler-generic
+ qt_osd
qt_mz80
qt_gui
)
#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)
vm_vm
common_common
vm_fmgen
-# common_scaler-generic
+ qt_osd
qt_pc6001
qt_gui
qt_debugger
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)
set(LOCAL_LIBS vm_pc8201
vm_vm
common_common
+ qt_osd
qt_pc8201
qt_gui
qt_debugger
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)
vm_vm
common_common
vm_fmgen
-# common_scaler-generic
+ qt_osd
qt_x1turboz
qt_gui
)
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)
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()
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../cmake")
-project (emufm7)
+project (emufm77)
set(BUILD_FM77 ON CACHE BOOL "Build for FM77")
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()
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()
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()
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)
#include <string.h>
#include "common.h"
#include "config.h"
+#include "agar_logger.h"
+#include <string>
+
#else
# include <windows.h>
# include <shlwapi.h>
#endif
#ifdef MAX_MACRO_NOT_DEFINED
-inline int max(int a, int b)
+int max(int a, int b)
{
if(a > b) {
return a;
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;
#endif
#ifdef MIN_MACRO_NOT_DEFINED
-inline int min(int a, int b)
+int min(int a, int b)
{
if(a < b) {
return a;
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;
}
#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
#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
#ifdef _MSC_VER
typedef unsigned __int64 uint64;
#else
-typedef unsigned long long uint64;
+//typedef unsigned long long uint64;
#endif
#endif
#ifndef int8
#ifdef _MSC_VER
typedef signed __int64 int64;
#else
-typedef signed long long int64;
+//typedef signed long long int64;
#endif
#endif
// 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
#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
// _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
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;
# define _TEXT(x) __T(x)
# if defined(CSP_OS_GCC_GENERIC)
+typedef char _TCHAR;
typedef _TCHAR* LPCTSTR;
# endif
# if defined(CSP_OS_GCC_CYGWIN)
#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)
{
return (MyGetPrivateProfileInt(lpAppName, lpKeyName, bDefault ? 1 : 0, lpFileName) != 0);
}
-#endif
-
void init_config()
{
int i;
// 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
#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
}
{
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
#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
}
#if defined(_USE_QT)
#include <sys/param.h>
-#include <QtCore/QFile>
-#include <QtCore/QFileInfo>
#ifndef _MAX_PATH
#define _MAX_PATH 2048
# 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
//#include <SDL/SDL.h>
#include "qt_main.h"
+#include "mainwidget.h"
+#include "qt_gldraw.h"
+
#include "agar_logger.h"
#include <ctime>
# endif
#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
#endif
// get module path
// Initialize keymod.
- modkey_status = 0;
#if defined(_USE_QT)
std::string tmps;
_TCHAR tmp_path[PATH_MAX], *ptr;
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;
// 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,
#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();
EMU::~EMU()
{
-#ifdef USE_DEBUGGER
- release_debugger();
-#endif
osd->release();
delete osd;
delete vm;
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
}
}
//LockVM();
osd->update_input();
- osd->update_printer();
+ //osd->update_printer();
#ifdef USE_SOCKET
//osd->update_socket();
#endif
}
// 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
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
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) {
#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
protected:
VM* vm;
OSD* osd;
+ int host_cpus;
private:
_TCHAR app_path[_MAX_PATH];
-
// ----------------------------------------
// sound
// ----------------------------------------
#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
// ----------------------------------------
#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;
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;
void stop_auto_key();
bool now_auto_key();
#endif
+
uint8* key_buffer();
uint32* joy_buffer();
int* mouse_buffer();
_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
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);
#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
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;
}
#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
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;
}
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();
}
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) {
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()
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);
#endif
int sig_resize_screen(int, int);
int sig_resize_uibar(int, int);
+ int sig_auto_key_string(QByteArray);
};
QT_END_NAMESPACE
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();
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) {
emu->hDebugger = NULL;
emu->now_debugging = false;
}
+# endif
}
#endif
{
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
{
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
{
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));
}
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));
}
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
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);
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);
+ }
+}
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) {
}
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);
}
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()));
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) || \
void Ui_MainWindow::OnWindowRedraw(void)
{
if(emu) {
- emu->update_screen();
+ //emu->update_screen();
}
}
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);
}
-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
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)
#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()
}
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();
{
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;
}
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();
}
//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;
scrntype* lpBmp;
//LPBITMAPINFOHEADER pbmInfoHeader;
DWORD dwAVIFileSize;
- LONG lAVIFrames;
+ UINT64 lAVIFrames;
int frames;
int result;
} rec_video_thread_param_t;
class FILEIO;
class GLDrawClass;
class EmuThreadClass;
+class Ui_MainWindow;
+class EMU;
+class VM;
QT_BEGIN_NAMESPACE
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();
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
//PAVISTREAM pAVICompressed;
//AVICOMPRESSOPTIONS AVIOpts;
DWORD dwAVIFileSize;
- LONG lAVIFrames;
+ UINT64 lAVIFrames;
//HANDLE hVideoThread;
rec_video_thread_param_t rec_video_thread_param;
int sound_rate, sound_samples;
bool sound_ok, sound_started, now_mute;
-
bool sound_first_half;
_TCHAR sound_file_name[_MAX_PATH];
int rec_sound_bytes;
int rec_sound_buffer_ptr;
+
#if defined(USE_MOVIE_PLAYER) || defined(USE_VIDEO_CAPTURE)
// video device
void initialize_video();
// common
VM* vm;
//EMU* emu;
-
+ class Ui_MainWindow *main_window_handle;
+ GLDrawClass *glv;
+
void initialize(int rate, int samples);
void release();
void power_off();
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();
// 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);
};
#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)
{
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++) {
}
}
#endif
- count = 0;
return count;
}
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) {
void OSD::key_up(int code)
{
- uint8 code = sym;
if(code == VK_SHIFT) {
#ifndef USE_SHIFT_NUMPAD_KEY
if(!(GetAsyncKeyState(VK_SHIFT) & 0x8000)) {
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);
mouse_status[1] = 0;
mouse_status[2] = mouse_button;
}
- instance_handle->setMouseTracking(true);
+ glv->setMouseTracking(true);
mouse_enabled = true;
}
// 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;
}
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()
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;
#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)
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);
}
}
return vm_screen_buffer.get_buffer(y);
}
+
int OSD::draw_screen()
{
// check avi file recording timing
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()
// 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
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));
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
}
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
#include "osd.h"
+#ifdef USE_SOCKET
void OSD::initialize_socket()
{
for(int i = 0; i < SOCKET_MAX; i++) {
void OSD::recv_data(int ch)
{
}
-
+#endif
#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)
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;
}
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
// start play
// check current position
play_c = nSndWritePos;
- if(!first_half) {
+ if(!sound_first_half) {
if(play_c < (uBufSize / 2)) {
return;
}
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;
// rec_video_run_frames -= rec_video_frames;
}
}
- rec_buffer_ptr = 0;
+ rec_sound_buffer_ptr = 0;
}
if(sound_buffer) {
int ssize;
}
// SDL_PauseAudioDevice(nAudioDevid, 0);
- first_half = !first_half;
+ sound_first_half = !sound_first_half;
}
}
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;
}
}
{
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)) {
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);
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();
}
}
#include "osd.h"
+#if defined(USE_MOVIE_PLAYER) || defined(USE_VIDEO_CAPTURE)
void OSD::initialize_video()
{
#if 0
}
#endif
}
+#endif // #if defined(USE_MOVIE_PLAYER) || defined(USE_VIDEO_CAPTURE)
+
#ifdef USE_MOVIE_PLAYER
bool OSD::open_movie_file(const _TCHAR* file_path)
}
SAFE_RELEASE(pCrs);
}
-#enduif
+#endif
}
void OSD::set_capture_dev_channel(int ch)