[General][WIP] Merge upstream changes at 2015-11-30 (unofficial).
}
#endif
+#ifndef SUPPORT_SECURE_FUNCTIONS
+//errno_t my_tfopen_s(FILE** pFile, const _TCHAR *filename, const _TCHAR *mode)
+//{
+// if((*pFile = _tfopen(filename, mode)) != NULL) {
+// return 0;
+// } else {
+// return errno;
+// }
+//}
+
+errno_t my_strcpy_s(char *strDestination, size_t numberOfElements, const char *strSource)
+{
+ strcpy(strDestination, strSource);
+ return 0;
+}
+
+errno_t my_tcscpy_s(_TCHAR *strDestination, size_t numberOfElements, const _TCHAR *strSource)
+{
+ _tcscpy(strDestination, strSource);
+ return 0;
+}
+
+_TCHAR *my_tcstok_s(_TCHAR *strToken, const char *strDelimit, _TCHAR **context)
+{
+ return _tcstok(strToken, strDelimit);
+}
+
+int my_stprintf_s(_TCHAR *buffer, size_t sizeOfBuffer, const _TCHAR *format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ int result = _vstprintf(buffer, format, ap);
+ va_end(ap);
+ return result;
+}
+
+int my_vstprintf_s(_TCHAR *buffer, size_t numberOfElements, const _TCHAR *format, va_list argptr)
+{
+ return _vstprintf(buffer, format, argptr);
+}
+#endif
+
+#ifndef _MSC_VER
+BOOL MyWritePrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpString, LPCTSTR lpFileName)
+{
+ // 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)
+{
+ // write your compatible function, if possible in standard C/C++ code
+ return 0;
+}
+
+UINT MyGetPrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, INT nDefault, LPCTSTR lpFileName)
+{
+ // write your compatible function, if possible in standard C/C++ code
+ return 0;
+}
+#endif
+
#if defined(_RGB555)
scrntype RGB_COLOR(uint r, uint g, uint b)
{
#include "fileio.h"
-#if !defined(SUPPORT_SECURE_FUNCTIONS) || defined(Q_OS_WIN)
-errno_t _tcscpy_s(_TCHAR *strDestination, size_t numberOfElements, const _TCHAR *strSource)
-{
- _tcscpy(strDestination, strSource);
- return 0;
-}
-
-_TCHAR *_tcstok_s(_TCHAR *strToken, const char *strDelimit, _TCHAR **context)
-{
- return _tcstok(strToken, strDelimit);
-}
-
-int _stprintf_s(_TCHAR *buffer, size_t sizeOfBuffer, const _TCHAR *format, ...)
-{
- va_list ap;
- va_start(ap, format);
- int result = _vstprintf(buffer, format, ap);
- va_end(ap);
- return result;
-}
-
-int _vstprintf_s(_TCHAR *buffer, size_t numberOfElements, const _TCHAR *format, va_list argptr)
-{
- return _vstprintf(buffer, format, argptr);
-}
-#endif
-
bool check_file_extension(const _TCHAR* file_path, const _TCHAR* ext)
{
#if defined(_USE_AGAR)
#else
- _tcscpy_s(path, _MAX_PATH, file_path);
+ my_tcscpy_s(path, _MAX_PATH, file_path);
PathRemoveExtension(path);
return path;
#endif
#include <tchar.h>
#endif
#include <stdio.h>
+#include <errno.h>
#if defined(_MSC_VER)
#include <windows.h>
#if defined(__GNUC__)
#include "common_gcc.h"
-#else
-#include <tchar.h>
+#elif defined(_MSC_VER)
+#include "common_msc.h"
// variable scope of 'for' loop for Microsoft Visual C++ 6.0
#if defined(_MSC_VER) && (_MSC_VER == 1200)
#define for if(0);else for
#endif
#endif
-static inline DWORD EndianToLittle_DWORD(DWORD x)
+#if defined(__LITTLE_ENDIAN__)
+static inline uint32_t EndianToLittle_DWORD(uint32_t x)
{
return x;
}
-static inline WORD EndianToLittle_WORD(WORD x)
+static inline uint16_t EndianToLittle_WORD(uint16_t x)
{
return x;
}
+#else // BIG_ENDIAN
+static inline uint32_t EndianToLittle_DWORD(uint32_t x)
+{
+ uint32_t y;
+ y = ((x & 0x000000ff) << 24) | ((x & 0x0000ff00) << 8) |
+ ((x & 0x00ff0000) >> 8) | ((x & 0xff000000) >> 24);
+ return y;
+}
-
+static inline uint16_t EndianToLittle_WORD(uint16_t x)
+{
+ uint16_t y;
+ y = ((x & 0x00ff) << 8) | ((x & 0xff00) >> 8);
+ return y;
+}
#endif
typedef union {
inline unsigned int min(unsigned int a, unsigned int b);
#endif
+// _TCHAR
+#ifndef SUPPORT_TCHAR_TYPE
+ #ifndef _tfopen
+ #define _tfopen fopen
+ #endif
+ #ifndef _tcscmp
+ #define _tcscmp strcmp
+ #endif
+ #ifndef _tcscpy
+ #define _tcscpy strcpy
+ #endif
+ #ifndef _tcsicmp
+ #define _tcsicmp stricmp
+ #endif
+ #ifndef _tcslen
+ #define _tcslen strlen
+ #endif
+ #ifndef _tcsncat
+ #define _tcsncat strncat
+ #endif
+ #ifndef _tcsncpy
+ #define _tcsncpy strncpy
+ #endif
+ #ifndef _tcsncicmp
+ #define _tcsncicmp strnicmp
+ #endif
+ #ifndef _tcsstr
+ #define _tcsstr strstr
+ #endif
+ #ifndef _tcstok
+ #define _tcstok strtok
+ #endif
+ #ifndef _tcstol
+ #define _tcstol strtol
+ #endif
+ #ifndef _tcstoul
+ #define _tcstoul strtoul
+ #endif
+ #ifndef _stprintf
+ #define _stprintf sprintf
+ #endif
+ #ifndef _vstprintf
+ #define _vstprintf vsprintf
+ #endif
+ #ifndef _taccess
+ #define _taccess access
+ #endif
+ #ifndef _tremove
+ #define _tremove remove
+ #endif
+ #define __T(x) x
+ #define _T(x) __T(x)
+ #define _TEXT(x) __T(x)
+#endif
+
+// secture functions
+#ifndef SUPPORT_SECURE_FUNCTIONS
+ #ifndef errno_t
+ typedef int errno_t;
+ #endif
+// errno_t my_tfopen_s(FILE** pFile, const _TCHAR *filename, const _TCHAR *mode);
+ errno_t my_strcpy_s(char *strDestination, size_t numberOfElements, const char *strSource);
+ errno_t my_tcscpy_s(_TCHAR *strDestination, size_t numberOfElements, const _TCHAR *strSource);
+ _TCHAR *my_tcstok_s(_TCHAR *strToken, const char *strDelimit, _TCHAR **context);
+ int my_stprintf_s(_TCHAR *buffer, size_t sizeOfBuffer, const _TCHAR *format, ...);
+ int my_vstprintf_s(_TCHAR *buffer, size_t numberOfElements, const _TCHAR *format, va_list argptr);
+#else
+// #define my_tfopen_s _tfopen_s
+ #define my_strcpy_s strcpy_s
+ #define my_tcscpy_s _tcscpy_s
+ #define my_tcstok_s _tcstok_s
+ #define my_stprintf_s _stprintf_s
+ #define my_vstprintf_s _vstprintf_s
+#endif
+
+#ifndef _MSC_VER
+ BOOL MyWritePrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpString, LPCTSTR lpFileName);
+ DWORD MyGetPrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpDefault, LPTSTR lpReturnedString, DWORD nSize, LPCTSTR lpFileName);
+ UINT MyGetPrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, INT nDefault, LPCTSTR lpFileName);
+#else
+ #define MyWritePrivateProfileString WritePrivateProfileString
+ #define MyGetPrivateProfileString GetPrivateProfileString
+ #define MyGetPrivateProfileInt GetPrivateProfileInt
+#endif
+
// rgb color
#define _RGB888
#include <stdarg.h>
+#include <string>
+#include <iostream>
+#include <fstream>
+
#include <SDL.h>
#if defined(Q_OS_CYGWIN)
typedef uint64_t uint64;
typedef int64_t int64;
typedef int BOOL;
+
# if defined(CSP_OS_GCC_GENERIC)
typedef uint8_t BYTE;
typedef uint16_t WORD;
# define _T(x) __T(x)
# define _TEXT(x) __T(x)
-typedef char _TCHAR;
# if defined(CSP_OS_GCC_GENERIC)
typedef _TCHAR* LPCTSTR;
# endif
-static inline char *_tcsncpy(_TCHAR *d, _TCHAR *s, int n) {
- return strncpy((char *)d, (char *)s, n);
-}
-
-static inline char *_tcsncat(_TCHAR *d, _TCHAR *s, int n) {
- return strncat((char *)d, (char *)s, n);
-}
# if defined(CSP_OS_GCC_CYGWIN)
# define stricmp(a,b) strcmp(a,b)
# define strnicmp(a,b,n) strncmp(a,b,n)
static int DeleteFile(_TCHAR *path)
{
- QString fpath = (char *)path;
- QFile tfp(fpath);
- if(tfp.remove(fpath)) return (int)true;
- return 0;
+ if(std::remove(path) == 0) return (int)true;
+ return 0;
}
#include <algorithm>
# include <tchar.h>
# endif
-#undef __LITTLE_ENDIAN___
-#undef __BIG_ENDIAN___
-
-# if (SDL_BYTEORDER == SDL_LIL_ENDIAN)
-# define __LITTLE_ENDIAN__
-static inline uint32_t EndianToLittle_DWORD(uint32_t x)
-{
- return x;
-}
-
-static inline uint16_t EndianToLittle_WORD(uint16_t x)
-{
- return x;
-}
-# else // BIG_ENDIAN
-# define __BIG_ENDIAN__
-static inline uint32_t EndianToLittle_DWORD(uint32_t x)
-{
- uint32_t y;
- y = ((x & 0x000000ff) << 24) | ((x & 0x0000ff00) << 8) |
- ((x & 0x00ff0000) >> 8) | ((x & 0xff000000) >> 24);
- return y;
-}
-
-static inline uint16_t EndianToLittle_WORD(uint16_t x)
-{
- uint16_t y;
- y = ((x & 0x00ff) << 8) | ((x & 0xff00) >> 8);
- return y;
-}
-# endif
# if !defined(CSP_OS_WINDOWS)
# define ZeroMemory(p,s) memset(p,0x00,s)
--- /dev/null
+/*
+ * common.h → common_msc.h
+ * Defines for gcc excepts Windows.
+ * (c) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
+ * History :
+ * Nov 20,2015 : Initial
+ */
+
+#ifndef _COMMON_MSC_H
+#define _COMMON_MSC_H
+
+
+#include <stdarg.h>
+
+#if defined(MSC_VER)
+# define CSP_OS_VISUALC
+# define CSP_OS_WINDOWS
+#endif
+
+typedef int errno_t;
+typedef uint8_t uint8;
+typedef int8_t int8;
+typedef uint16_t uint16;
+typedef int16_t int16;
+typedef uint32_t uint32;
+typedef int32_t int32;
+typedef uint64_t uint64;
+typedef int64_t int64;
+typedef int BOOL;
+
+typedef uint8_t BYTE;
+typedef uint16_t WORD;
+typedef uint32_t DWORD;
+typedef uint64_t QWORD;
+//# if !defined(Q_OS_CYGWIN)
+typedef uint8_t UINT8;
+typedef uint16_t UINT16;
+typedef uint32_t UINT32;
+typedef uint64_t UINT64;
+typedef int8_t INT8;
+typedef int16_t INT16;
+typedef int32_t INT32;
+typedef int64_t INT64;
+
+
+#ifndef SUPPORT_TCHAR_TYPE
+ #ifndef _TCHAR
+ typedef char _TCHAR;
+ #endif
+#endif
+
+#ifndef _MSC_VER
+ #ifndef LPTSTR
+ typedef _TCHAR* LPTSTR;
+ #endif
+ #ifndef LPCTSTR
+ typedef const _TCHAR* LPCTSTR;
+ #endif
+#endif
+//static inline char *_tcsncpy(_TCHAR *d, _TCHAR *s, int n) {
+// return strncpy((char *)d, (char *)s, n);
+//}
+
+//static inline char *_tcsncat(_TCHAR *d, _TCHAR *s, int n) {
+// return strncat((char *)d, (char *)s, n);
+//}
+//static int DeleteFile(_TCHAR *path)
+//{
+// QString fpath = (char *)path;
+// QFile tfp(fpath);
+// if(tfp.remove(fpath)) return (int)true;
+// return 0;
+//}
+
+//#include <algorithm>
+
+# if !defined(CSP_OS_WINDOWS)
+# define _N(x) _T(x)
+# else
+# include <tchar.h>
+# endif
+
+// How define for ARMEB?
+#define __LITTLE_ENDIAN___
+#undef __BIG_ENDIAN___
+
+# if defined(__LITTLE_ENDIAN__)
+static inline uint32_t EndianToLittle_DWORD(uint32_t x)
+{
+ return x;
+}
+
+static inline uint16_t EndianToLittle_WORD(uint16_t x)
+{
+ return x;
+}
+# else // BIG_ENDIAN
+# define __BIG_ENDIAN__
+static inline uint32_t EndianToLittle_DWORD(uint32_t x)
+{
+ uint32_t y;
+ y = ((x & 0x000000ff) << 24) | ((x & 0x0000ff00) << 8) |
+ ((x & 0x00ff0000) >> 8) | ((x & 0xff000000) >> 24);
+ return y;
+}
+
+static inline uint16_t EndianToLittle_WORD(uint16_t x)
+{
+ uint16_t y;
+ y = ((x & 0x00ff) << 8) | ((x & 0xff00) >> 8);
+ return y;
+}
+# endif
+
+#endif // _COMMON_GCC_H
#endif
#if defined(_USE_QT) && !defined(Q_OS_WIN32)
-bool WritePrivateProfileString(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, char *Value, FILEIO *lpFileName)
+bool MyWritePrivateProfileString(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, char *Value, FILEIO *lpFileName)
{
QString s;
QString v;
return true;
}
-bool WritePrivateProfileInt(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, int Value, FILEIO *lpFileName)
+bool MyWritePrivateProfileInt(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, int Value, FILEIO *lpFileName)
{
std::string s;
int l;
memset(valuebuf, 0x00, sizeof(valuebuf));
l = snprintf(valuebuf, 63, "%d", Value);
if((l <= 0) || (l >= 63)) return false;
- return WritePrivateProfileString(lpAppName, lpKeyName, valuebuf, lpFileName);
+ return MyWritePrivateProfileString(lpAppName, lpKeyName, valuebuf, lpFileName);
}
-BOOL WritePrivateProfileBool(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, bool Value, FILEIO *lpFileName)
+BOOL MyWritePrivateProfileBool(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, bool Value, FILEIO *lpFileName)
{
int v = 0;
if(Value) v = 1;
- return WritePrivateProfileInt(lpAppName, lpKeyName, v, lpFileName);
+ return MyWritePrivateProfileInt(lpAppName, lpKeyName, v, lpFileName);
}
-std::string GetPrivateProfileStr(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, FILEIO *lpFileName)
+std::string MyGetPrivateProfileStr(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, FILEIO *lpFileName)
{
std::string key;
char ibuf[4096 + 102];
}
-void GetPrivateProfileString(const _TCHAR *section, const _TCHAR *key, const _TCHAR *defaultstr, char *str, int max_len, FILEIO *p)
+void MyGetPrivateProfileString(const _TCHAR *section, const _TCHAR *key, const _TCHAR *defaultstr, char *str, int max_len, FILEIO *p)
{
- std::string sp = GetPrivateProfileStr(section, key, p);
-
+ std::string sp = MyGetPrivateProfileStr(section, key, p);
if((!sp.empty()) && (max_len > 1)){
strncpy(str, sp.c_str(), max_len);
} else {
}
}
-int GetPrivateProfileInt(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, int nDefault, FILEIO *lpFileName)
+int MyGetPrivateProfileInt(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, int nDefault, FILEIO *lpFileName)
{
int i;
char sstr[128];
char sval[128];
- QString s;
+ std::string s;
bool r;
memset(sstr, 0x00, sizeof(sstr));
memset(sval, 0x00, sizeof(sval));
snprintf(sval, 128, "%d", nDefault);
- GetPrivateProfileString(lpAppName,lpKeyName, sval, sstr, 128, lpFileName);
- s = QString::fromUtf8(sstr);
+ MyGetPrivateProfileString(lpAppName,lpKeyName, sval, sstr, 128, lpFileName);
+ s = sstr;
- if(s.isEmpty()) {
+ if(s.empty()) {
i = nDefault;
} else {
i = s.toInt(&r);
return i;
}
-
-
-bool GetPrivateProfileBool(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, bool bDefault, FILEIO *lpFileName)
+bool MyGetPrivateProfileBool(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, bool bDefault, FILEIO *lpFileName)
{
- return (GetPrivateProfileInt(lpAppName, lpKeyName, bDefault ? 1 : 0, lpFileName) != 0);
+ return (MyGetPrivateProfileInt(lpAppName, lpKeyName, bDefault ? 1 : 0, lpFileName) != 0);
}
-#else
-extern _TCHAR* get_parent_dir(_TCHAR* file);
-BOOL WritePrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, int Value, LPCTSTR lpFileName)
+#else // MSC or Windows
+//extern _TCHAR* get_parent_dir(_TCHAR* file);
+BOOL MyWritePrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, int Value, LPCTSTR lpFileName)
{
- _TCHAR String[32];
- _stprintf_s(String, 32, _T("%d"), Value);
- return WritePrivateProfileString(lpAppName, lpKeyName, String, lpFileName);
+ _TCHAR String[32];
+ my_stprintf_s(String, 32, _T("%d"), Value);
+ return MyWritePrivateProfileString(lpAppName, lpKeyName, String, lpFileName);
}
-
-BOOL WritePrivateProfileBool(LPCTSTR lpAppName, LPCTSTR lpKeyName, bool Value, LPCTSTR lpFileName)
+
+BOOL MyWritePrivateProfileBool(LPCTSTR lpAppName, LPCTSTR lpKeyName, bool Value, LPCTSTR lpFileName)
{
- _TCHAR String[32];
- _stprintf_s(String, 32, _T("%d"), Value ? 1 : 0);
- return WritePrivateProfileString(lpAppName, lpKeyName, String, lpFileName);
+ _TCHAR String[32];
+ my_stprintf_s(String, 32, _T("%d"), Value ? 1 : 0);
+ return MyWritePrivateProfileString(lpAppName, lpKeyName, String, lpFileName);
}
-
-BOOL GetPrivateProfileBool(LPCTSTR lpAppName, LPCTSTR lpKeyName, bool bDefault, LPCTSTR lpFileName)
+
+bool MyGetPrivateProfileBool(LPCTSTR lpAppName, LPCTSTR lpKeyName, bool bDefault, LPCTSTR lpFileName)
{
- return (GetPrivateProfileInt(lpAppName, lpKeyName, bDefault ? 1 : 0, lpFileName) != 0);
+ return (MyGetPrivateProfileInt(lpAppName, lpKeyName, bDefault ? 1 : 0, lpFileName) != 0);
}
#endif
+
void init_config()
{
int i;
GetModuleFileName(NULL, config_path, _MAX_PATH);
GetFullPathName(config_path, _MAX_PATH, app_path, &ptr);
if(ptr != NULL) *ptr = _T('\0');
- _stprintf_s(config_path, _MAX_PATH, _T("%s%s.ini"), app_path, _T(CONFIG_NAME));
+ my_stprintf_s(config_path, _MAX_PATH, _T("%s%s.ini"), app_path, _T(CONFIG_NAME));
#endif
// control
#ifdef USE_BOOT_MODE
- config.boot_mode = GetPrivateProfileInt(_T("Control"), _T("BootMode"), config.boot_mode, config_path);
+ config.boot_mode = MyGetPrivateProfileInt(_T("Control"), _T("BootMode"), config.boot_mode, config_path);
#endif
#ifdef USE_CPU_TYPE
- config.cpu_type = GetPrivateProfileInt(_T("Control"), _T("CPUType"), config.cpu_type, config_path);
+ config.cpu_type = MyGetPrivateProfileInt(_T("Control"), _T("CPUType"), config.cpu_type, config_path);
#endif
#ifdef USE_DIPSWITCH
- config.dipswitch = GetPrivateProfileInt(_T("Control"), _T("DipSwitch"), config.dipswitch, config_path);
+ config.dipswitch = MyGetPrivateProfileInt(_T("Control"), _T("DipSwitch"), config.dipswitch, config_path);
#endif
#ifdef USE_DEVICE_TYPE
- config.device_type = GetPrivateProfileInt(_T("Control"), _T("DeviceType"), config.device_type, config_path);
+ config.device_type = MyGetPrivateProfileInt(_T("Control"), _T("DeviceType"), config.device_type, config_path);
#endif
#ifdef USE_DRIVE_TYPE
- config.drive_type = GetPrivateProfileInt(_T("Control"), _T("DriveType"), config.drive_type, config_path);
+ config.drive_type = MyGetPrivateProfileInt(_T("Control"), _T("DriveType"), config.drive_type, config_path);
#endif
#ifdef USE_FD1
{
_TCHAR name[64];
for(drv = 0; drv < MAX_FD; drv++) {
memset(name, 0x00, sizeof(name));
- _stprintf_s(name, 64, _T("CorrectDiskTiming%d"), drv + 1);
- config.correct_disk_timing[drv] = GetPrivateProfileBool(_T("Control"), (const _TCHAR *)name,
+ my_stprintf_s(name, 64, _T("CorrectDiskTiming%d"), drv + 1);
+ config.correct_disk_timing[drv] = MyGetPrivateProfileBool(_T("Control"), (const _TCHAR *)name,
config.correct_disk_timing[drv], config_path);
- _stprintf_s(name, 64, _T("IgnoreDiskCRC%d"), drv + 1);
- config.ignore_disk_crc[drv] = GetPrivateProfileBool(_T("Control"), (const _TCHAR *)name,
+ my_stprintf_s(name, 64, _T("IgnoreDiskCRC%d"), drv + 1);
+ config.ignore_disk_crc[drv] = MyGetPrivateProfileBool(_T("Control"), (const _TCHAR *)name,
config.ignore_disk_crc[drv], config_path);
}
}
#endif
#ifdef USE_TAPE
- config.tape_sound = GetPrivateProfileBool(_T("Control"), _T("TapeSound"), config.tape_sound, config_path);
- config.wave_shaper = GetPrivateProfileBool(_T("Control"), _T("WaveShaper"), config.wave_shaper, config_path);
- config.direct_load_mzt = GetPrivateProfileBool(_T("Control"), _T("DirectLoadMZT"), config.direct_load_mzt, config_path);
- config.baud_high = GetPrivateProfileBool(_T("Control"), _T("BaudHigh"), config.baud_high, config_path);
+ config.tape_sound = MyGetPrivateProfileBool(_T("Control"), _T("TapeSound"), config.tape_sound, config_path);
+ config.wave_shaper = MyGetPrivateProfileBool(_T("Control"), _T("WaveShaper"), config.wave_shaper, config_path);
+ config.direct_load_mzt = MyGetPrivateProfileBool(_T("Control"), _T("DirectLoadMZT"), config.direct_load_mzt, config_path);
+ config.baud_high = MyGetPrivateProfileBool(_T("Control"), _T("BaudHigh"), config.baud_high, config_path);
#endif
// recent files
#ifdef USE_CART1
- GetPrivateProfileString(_T("RecentFiles"), _T("InitialCartDir"), _T(""), config.initial_cart_dir, _MAX_PATH, config_path);
+ MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialCartDir"), _T(""), config.initial_cart_dir, _MAX_PATH, config_path);
for(drv = 0; drv < MAX_CART; drv++) {
for(i = 0; i < MAX_HISTORY; i++) {
_TCHAR name[64];
- _stprintf_s(name, 64, _T("RecentCartPath%d_%d"), drv + 1, i + 1);
- GetPrivateProfileString(_T("RecentFiles"), name, _T(""),
+ my_stprintf_s(name, 64, _T("RecentCartPath%d_%d"), drv + 1, i + 1);
+ MyGetPrivateProfileString(_T("RecentFiles"), name, _T(""),
config.recent_cart_path[drv][i], _MAX_PATH, config_path);
}
}
#endif
#ifdef USE_FD1
- GetPrivateProfileString(_T("RecentFiles"), _T("InitialDiskDir"), _T(""),
+ MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialDiskDir"), _T(""),
config.initial_disk_dir, _MAX_PATH, config_path);
// get_parent_dir(config.initial_disk_dir);
for(drv = 0; drv < MAX_FD; drv++) {
for(i = 0; i < MAX_HISTORY; i++) {
_TCHAR name[64];
- _stprintf_s(name, 64, _T("RecentDiskPath%d_%d"), drv + 1, i + 1);
- GetPrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name,
+ my_stprintf_s(name, 64, _T("RecentDiskPath%d_%d"), drv + 1, i + 1);
+ MyGetPrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name,
_T(""), config.recent_disk_path[drv][i], _MAX_PATH, config_path);
}
}
#endif
#ifdef USE_QD1
- GetPrivateProfileString(_T("RecentFiles"), _T("InitialQuickDiskDir"),
+ MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialQuickDiskDir"),
_T(""), config.initial_quickdisk_dir, _MAX_PATH, config_path);
for(drv = 0; drv < MAX_QD; drv++) {
for(i = 0; i < MAX_HISTORY; i++) {
_TCHAR name[64];
- _stprintf_s(name, 64, _T("RecentQuickDiskPath%d_%d"), drv + 1, i + 1);
- GetPrivateProfileString(_T("RecentFiles"), name, _T(""),
+ my_stprintf_s(name, 64, _T("RecentQuickDiskPath%d_%d"), drv + 1, i + 1);
+ MyGetPrivateProfileString(_T("RecentFiles"), name, _T(""),
config.recent_quickdisk_path[drv][i], _MAX_PATH, config_path);
}
}
#endif
#ifdef USE_TAPE
- GetPrivateProfileString(_T("RecentFiles"), _T("InitialTapeDir"), _T(""),
+ MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialTapeDir"), _T(""),
config.initial_tape_dir, _MAX_PATH, config_path);
for(i = 0; i < MAX_HISTORY; i++) {
_TCHAR name[64];
- _stprintf_s(name, 64, _T("RecentTapePath1_%d"), i + 1);
- GetPrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name, _T(""),
+ my_stprintf_s(name, 64, _T("RecentTapePath1_%d"), i + 1);
+ MyGetPrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name, _T(""),
config.recent_tape_path[i], _MAX_PATH, config_path);
}
#endif
#ifdef USE_LASER_DISC
- GetPrivateProfileString(_T("RecentFiles"), _T("InitialLaserDiscDir"), _T(""),
+ MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialLaserDiscDir"), _T(""),
config.initial_laser_disc_dir, _MAX_PATH, config_path);
for(int i = 0; i < MAX_HISTORY; i++) {
_TCHAR name[64];
- _stprintf_s(name, 64, _T("RecentLaserDiscPath1_%d"), i + 1);
- GetPrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name, _T(""),
+ my_stprintf_s(name, 64, _T("RecentLaserDiscPath1_%d"), i + 1);
+ MyGetPrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name, _T(""),
config.recent_laser_disc_path[i], _MAX_PATH, config_path);
}
#endif
#ifdef USE_BINARY_FILE1
- GetPrivateProfileString(_T("RecentFiles"), _T("InitialBinaryDir"), _T(""),
+ MyGetPrivateProfileString(_T("RecentFiles"), _T("InitialBinaryDir"), _T(""),
config.initial_binary_dir, _MAX_PATH, config_path);
for(drv = 0; drv < MAX_BINARY; drv++) {
for(i = 0; i < MAX_HISTORY; i++) {
_TCHAR name[64];
- _stprintf_s(name, 64, _T("RecentBinaryPath%d_%d"), drv + 1, i + 1);
- GetPrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name, _T(""),
+ my_stprintf_s(name, 64, _T("RecentBinaryPath%d_%d"), drv + 1, i + 1);
+ MyGetPrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name, _T(""),
config.recent_binary_path[drv][i], _MAX_PATH, config_path);
}
}
// screen
#ifndef ONE_BOARD_MICRO_COMPUTER
- config.window_mode = GetPrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
+ config.window_mode = MyGetPrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
#ifdef _WIN32
- config.use_d3d9 = GetPrivateProfileBool(_T("Screen"), _T("UseD3D9"), config.use_d3d9, config_path);
- config.wait_vsync = GetPrivateProfileBool(_T("Screen"), _T("WaitVSync"), config.wait_vsync, config_path);
+ config.use_d3d9 = MyGetPrivateProfileBool(_T("Screen"), _T("UseD3D9"), config.use_d3d9, config_path);
+ config.wait_vsync = MyGetPrivateProfileBool(_T("Screen"), _T("WaitVSync"), config.wait_vsync, config_path);
#endif
- config.stretch_type = GetPrivateProfileInt(_T("Screen"), _T("StretchType"), config.stretch_type, config_path);
+ config.stretch_type = MyGetPrivateProfileInt(_T("Screen"), _T("StretchType"), config.stretch_type, config_path);
#else
- config.window_mode = GetPrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
+ config.window_mode = MyGetPrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
#endif
#ifdef USE_MONITOR_TYPE
- config.monitor_type = GetPrivateProfileInt(_T("Screen"), _T("MonitorType"), config.monitor_type, config_path);
+ config.monitor_type = MyGetPrivateProfileInt(_T("Screen"), _T("MonitorType"), config.monitor_type, config_path);
#endif
#ifdef USE_CRT_FILTER
- config.crt_filter = GetPrivateProfileBool(_T("Screen"), _T("CRTFilter"), config.crt_filter, config_path);
+ config.crt_filter = MyGetPrivateProfileBool(_T("Screen"), _T("CRTFilter"), config.crt_filter, config_path);
#endif
#ifdef USE_SCANLINE
- config.scan_line = GetPrivateProfileBool(_T("Screen"), _T("ScanLine"), config.scan_line, config_path);
+ config.scan_line = MyGetPrivateProfileBool(_T("Screen"), _T("ScanLine"), config.scan_line, config_path);
#endif
#ifdef USE_SCREEN_ROTATE
- config.rotate_type = GetPrivateProfileInt(_T("Screen"), _T("RotateType"), config.rotate_type, config_path);
+ config.rotate_type = MyGetPrivateProfileInt(_T("Screen"), _T("RotateType"), config.rotate_type, config_path);
#endif
#if defined(_USE_QT)
- config.use_opengl_scanline = GetPrivateProfileBool(_T("Screen"), _T("UseOpenGLScanLine"),
+ config.use_opengl_scanline = MyGetPrivateProfileBool(_T("Screen"), _T("UseOpenGLScanLine"),
config.use_opengl_scanline, config_path);
- config.opengl_scanline_vert = GetPrivateProfileBool(_T("Screen"), _T("OpenGLScanLineVert"),
+ config.opengl_scanline_vert = MyGetPrivateProfileBool(_T("Screen"), _T("OpenGLScanLineVert"),
config.opengl_scanline_vert, config_path);;
- config.opengl_scanline_horiz = GetPrivateProfileBool(_T("Screen"), _T("OpenGLScanLineHoriz"),
+ config.opengl_scanline_horiz = MyGetPrivateProfileBool(_T("Screen"), _T("OpenGLScanLineHoriz"),
config.opengl_scanline_horiz, config_path);;
- config.use_opengl_filters = GetPrivateProfileBool(_T("Screen"), _T("UseOpenGLFilters"),
+ config.use_opengl_filters = MyGetPrivateProfileBool(_T("Screen"), _T("UseOpenGLFilters"),
config.use_opengl_filters, config_path);
- config.opengl_filter_num = GetPrivateProfileInt(_T("Screen"), _T("OpenGLFilterNum"),
+ config.opengl_filter_num = MyGetPrivateProfileInt(_T("Screen"), _T("OpenGLFilterNum"),
config.opengl_filter_num, config_path);
#endif
// sound
- config.sound_frequency = GetPrivateProfileInt(_T("Sound"), _T("Frequency"), config.sound_frequency, config_path);
- config.sound_latency = GetPrivateProfileInt(_T("Sound"), _T("Latency"), config.sound_latency, config_path);
+ config.sound_frequency = MyGetPrivateProfileInt(_T("Sound"), _T("Frequency"), config.sound_frequency, config_path);
+ config.sound_latency = MyGetPrivateProfileInt(_T("Sound"), _T("Latency"), config.sound_latency, config_path);
#ifdef USE_SOUND_DEVICE_TYPE
- config.sound_device_type = GetPrivateProfileInt(_T("Sound"), _T("DeviceType"), config.sound_device_type, config_path);
+ config.sound_device_type = MyGetPrivateProfileInt(_T("Sound"), _T("DeviceType"), config.sound_device_type, config_path);
#endif
#if !defined(_USE_QT)
- GetPrivateProfileString(_T("Sound"), _T("FMGenDll"), _T("mamefm.dll"), config.fmgen_dll_path, _MAX_PATH, config_path);
+ MyGetPrivateProfileString(_T("Sound"), _T("FMGenDll"), _T("mamefm.dll"), config.fmgen_dll_path, _MAX_PATH, config_path);
#endif
// input
- config.multiple_speakers = GetPrivateProfileBool(_T("Sound"), _T("MultipleSpeakers"),
+ config.multiple_speakers = MyGetPrivateProfileBool(_T("Sound"), _T("MultipleSpeakers"),
config.multiple_speakers, config_path);
- config.general_sound_level = GetPrivateProfileInt(_T("Sound"), _T("GeneralSoundLevel"),
+ config.general_sound_level = MyGetPrivateProfileInt(_T("Sound"), _T("GeneralSoundLevel"),
config.general_sound_level, config_path);
#ifdef USE_MULTIPLE_SOUNDCARDS
{
int ii;
for(ii = 0; ii < USE_MULTIPLE_SOUNDCARDS; ii++) {
memset(_tag, 0x00, sizeof(_tag));
- _stprintf_s(_tag, 64, _T("DeviceVolumeLevel_%d"), ii + 1);
- config.sound_device_level[ii] = GetPrivateProfileInt(_T("Sound"), (const _TCHAR *)_tag, config.sound_device_level[ii], config_path);
+ my_stprintf_s(_tag, 64, _T("DeviceVolumeLevel_%d"), ii + 1);
+ config.sound_device_level[ii] = MyGetPrivateProfileInt(_T("Sound"), (const _TCHAR *)_tag, config.sound_device_level[ii], config_path);
}
}
#endif
#ifdef _WIN32
- config.use_direct_input = GetPrivateProfileBool(_T("Input"), _T("UseDirectInput"), config.use_direct_input, config_path);
- config.disable_dwm = GetPrivateProfileBool(_T("Input"), _T("DisableDwm"), config.disable_dwm, config_path);
+ config.use_direct_input = MyGetPrivateProfileBool(_T("Input"), _T("UseDirectInput"), config.use_direct_input, config_path);
+ config.disable_dwm = MyGetPrivateProfileBool(_T("Input"), _T("DisableDwm"), config.disable_dwm, config_path);
#endif
- config.swap_joy_buttons = GetPrivateProfileBool(_T("Input"), _T("SwapJoyButtons"), config.swap_joy_buttons, config_path);
+ 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.");
GetModuleFileName(NULL, config_path, _MAX_PATH);
GetFullPathName(config_path, _MAX_PATH, app_path, &ptr);
if(ptr != NULL) *ptr = _T('\0');
- _stprintf_s(config_path, _MAX_PATH, _T("%s%s.ini"), app_path, _T(CONFIG_NAME));
+ my_stprintf_s(config_path, _MAX_PATH, _T("%s%s.ini"), app_path, _T(CONFIG_NAME));
#endif
// control
# ifdef USE_BOOT_MODE
- WritePrivateProfileInt(_T("Control"), _T("BootMode"), config.boot_mode, config_path);
+ MyWritePrivateProfileInt(_T("Control"), _T("BootMode"), config.boot_mode, config_path);
#endif
#ifdef USE_CPU_TYPE
- WritePrivateProfileInt(_T("Control"), _T("CPUType"), config.cpu_type, config_path);
+ MyWritePrivateProfileInt(_T("Control"), _T("CPUType"), config.cpu_type, config_path);
#endif
#ifdef USE_DIPSWITCH
- WritePrivateProfileInt(_T("Control"), _T("DipSwitch"), config.dipswitch, config_path);
+ MyWritePrivateProfileInt(_T("Control"), _T("DipSwitch"), config.dipswitch, config_path);
#endif
#ifdef USE_DEVICE_TYPE
- WritePrivateProfileInt(_T("Control"), _T("DeviceType"), config.device_type, config_path);
+ MyWritePrivateProfileInt(_T("Control"), _T("DeviceType"), config.device_type, config_path);
#endif
#ifdef USE_DRIVE_TYPE
- WritePrivateProfileInt(_T("Control"), _T("DriveType"), config.drive_type, config_path);
+ MyWritePrivateProfileInt(_T("Control"), _T("DriveType"), config.drive_type, config_path);
#endif
#ifdef USE_FD1
{
_TCHAR name[64];
for(drv = 0; drv < MAX_FD; drv++) {
memset(name, 0x00, sizeof(name));
- _stprintf_s(name, 64, _T("CorrectDiskTiming%d"), drv + 1);
- WritePrivateProfileBool(_T("Control"), (const _TCHAR *)name, config.correct_disk_timing[drv], config_path);
- _stprintf_s(name, 64, _T("IgnoreDiskCRC%d"), drv + 1);
- WritePrivateProfileBool(_T("Control"), (const _TCHAR *)name, config.ignore_disk_crc[drv], config_path);
+ my_stprintf_s(name, 64, _T("CorrectDiskTiming%d"), drv + 1);
+ MyWritePrivateProfileBool(_T("Control"), (const _TCHAR *)name, config.correct_disk_timing[drv], config_path);
+ my_stprintf_s(name, 64, _T("IgnoreDiskCRC%d"), drv + 1);
+ MyWritePrivateProfileBool(_T("Control"), (const _TCHAR *)name, config.ignore_disk_crc[drv], config_path);
}
}
#endif
#ifdef USE_TAPE
- WritePrivateProfileBool(_T("Control"), _T("TapeSound"), config.tape_sound, config_path);
- WritePrivateProfileBool(_T("Control"), _T("WaveShaper"), config.wave_shaper, config_path);
- WritePrivateProfileBool(_T("Control"), _T("DirectLoadMZT"), config.direct_load_mzt, config_path);
- WritePrivateProfileBool(_T("Control"), _T("BaudHigh"), config.baud_high, config_path);
+ MyWritePrivateProfileBool(_T("Control"), _T("TapeSound"), config.tape_sound, config_path);
+ MyWritePrivateProfileBool(_T("Control"), _T("WaveShaper"), config.wave_shaper, config_path);
+ MyWritePrivateProfileBool(_T("Control"), _T("DirectLoadMZT"), config.direct_load_mzt, config_path);
+ MyWritePrivateProfileBool(_T("Control"), _T("BaudHigh"), config.baud_high, config_path);
#endif
// recent files
#ifdef USE_CART1
- WritePrivateProfileString(_T("RecentFiles"), _T("InitialCartDir"), config.initial_cart_dir, config_path);
+ MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialCartDir"), config.initial_cart_dir, config_path);
for(drv = 0; drv < MAX_CART; drv++) {
for(i = 0; i < MAX_HISTORY; i++) {
_TCHAR name[64];
- _stprintf_s(name, 64, _T("RecentCartPath%d_%d"), drv + 1, i + 1);
- WritePrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name, config.recent_cart_path[drv][i], config_path);
+ my_stprintf_s(name, 64, _T("RecentCartPath%d_%d"), drv + 1, i + 1);
+ MyWritePrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name, config.recent_cart_path[drv][i], config_path);
}
}
#endif
#ifdef USE_FD1
- WritePrivateProfileString(_T("RecentFiles"), _T("InitialDiskDir"), config.initial_disk_dir, config_path);
+ MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialDiskDir"), config.initial_disk_dir, config_path);
for(drv = 0; drv < MAX_FD; drv++) {
for(i = 0; i < MAX_HISTORY; i++) {
_TCHAR name[64];
- _stprintf_s(name, 64, _T("RecentDiskPath%d_%d"), drv + 1, i + 1);
- WritePrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name,
+ my_stprintf_s(name, 64, _T("RecentDiskPath%d_%d"), drv + 1, i + 1);
+ MyWritePrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name,
config.recent_disk_path[drv][i], config_path);
}
}
#endif
#ifdef USE_QD1
- WritePrivateProfileString(_T("RecentFiles"), _T("InitialQuickDiskDir"),
+ MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialQuickDiskDir"),
config.initial_quickdisk_dir, config_path);
for(drv = 0; drv < MAX_QD; drv++) {
for(i = 0; i < MAX_HISTORY; i++) {
_TCHAR name[64];
- _stprintf_s(name, 64, _T("RecentQuickDiskPath%d_%d"), drv + 1, i + 1);
- WritePrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name,
+ my_stprintf_s(name, 64, _T("RecentQuickDiskPath%d_%d"), drv + 1, i + 1);
+ MyWritePrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name,
config.recent_quickdisk_path[drv][i], config_path);
}
}
#endif
#ifdef USE_TAPE
- WritePrivateProfileString(_T("RecentFiles"), _T("InitialTapeDir"), config.initial_tape_dir, config_path);
+ MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialTapeDir"), config.initial_tape_dir, config_path);
for(i = 0; i < MAX_HISTORY; i++) {
_TCHAR name[64];
- _stprintf_s(name, 64, _T("RecentTapePath1_%d"), i + 1);
- WritePrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name,
+ my_stprintf_s(name, 64, _T("RecentTapePath1_%d"), i + 1);
+ MyWritePrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name,
config.recent_tape_path[i], config_path);
}
#endif
#ifdef USE_LASER_DISC
- WritePrivateProfileString(_T("RecentFiles"), _T("InitialLaserDiscDir"), config.initial_laser_disc_dir, config_path);
+ MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialLaserDiscDir"), config.initial_laser_disc_dir, config_path);
for(int i = 0; i < MAX_HISTORY; i++) {
_TCHAR name[64];
- _stprintf_s(name, 64, _T("RecentLaserDiscPath1_%d"), i + 1);
- WritePrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name,
+ my_stprintf_s(name, 64, _T("RecentLaserDiscPath1_%d"), i + 1);
+ MyWritePrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name,
config.recent_laser_disc_path[i], config_path);
}
#endif
#ifdef USE_BINARY_FILE1
- WritePrivateProfileString(_T("RecentFiles"), _T("InitialBinaryDir"), config.initial_binary_dir, config_path);
+ MyWritePrivateProfileString(_T("RecentFiles"), _T("InitialBinaryDir"), config.initial_binary_dir, config_path);
for(drv = 0; drv < MAX_BINARY; drv++) {
for(i = 0; i < MAX_HISTORY; i++) {
_TCHAR name[64];
- _stprintf_s(name, 64, _T("RecentBinaryPath%d_%d"), drv + 1, i + 1);
- WritePrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name,
+ my_stprintf_s(name, 64, _T("RecentBinaryPath%d_%d"), drv + 1, i + 1);
+ MyWritePrivateProfileString(_T("RecentFiles"), (const _TCHAR *)name,
config.recent_binary_path[drv][i], config_path);
}
}
// screen
#ifndef ONE_BOARD_MICRO_COMPUTER
- WritePrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
+ MyWritePrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
#ifdef _WIN32
- WritePrivateProfileBool(_T("Screen"), _T("UseD3D9"), config.use_d3d9, config_path);
- WritePrivateProfileBool(_T("Screen"), _T("WaitVSync"), config.wait_vsync, config_path);
+ MyWritePrivateProfileBool(_T("Screen"), _T("UseD3D9"), config.use_d3d9, config_path);
+ MyWritePrivateProfileBool(_T("Screen"), _T("WaitVSync"), config.wait_vsync, config_path);
#endif
- WritePrivateProfileInt(_T("Screen"), _T("StretchType"), config.stretch_type, config_path);
+ MyWritePrivateProfileInt(_T("Screen"), _T("StretchType"), config.stretch_type, config_path);
#else
- WritePrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
+ MyWritePrivateProfileInt(_T("Screen"), _T("WindowMode"), config.window_mode, config_path);
#endif
#ifdef USE_MONITOR_TYPE
- WritePrivateProfileInt(_T("Screen"), _T("MonitorType"), config.monitor_type, config_path);
+ MyWritePrivateProfileInt(_T("Screen"), _T("MonitorType"), config.monitor_type, config_path);
#endif
#ifdef USE_CRT_FILTER
- WritePrivateProfileBool(_T("Screen"), _T("CRTFilter"), config.crt_filter, config_path);
+ MyWritePrivateProfileBool(_T("Screen"), _T("CRTFilter"), config.crt_filter, config_path);
#endif
#ifdef USE_SCANLINE
- WritePrivateProfileBool(_T("Screen"), _T("ScanLine"), config.scan_line, config_path);
+ MyWritePrivateProfileBool(_T("Screen"), _T("ScanLine"), config.scan_line, config_path);
#endif
#ifdef USE_SCREEN_ROTATE
- WritePrivateProfileInt(_T("Screen"), _T("RotateType"), config.rotate_type, config_path);
+ MyWritePrivateProfileInt(_T("Screen"), _T("RotateType"), config.rotate_type, config_path);
#endif
#if defined(_USE_QT)
- WritePrivateProfileBool(_T("Screen"), _T("UseOpenGLScanLine"),
+ MyWritePrivateProfileBool(_T("Screen"), _T("UseOpenGLScanLine"),
config.use_opengl_scanline, config_path);
- WritePrivateProfileBool(_T("Screen"), _T("OpenGLScanLineVert"),
+ MyWritePrivateProfileBool(_T("Screen"), _T("OpenGLScanLineVert"),
config.opengl_scanline_vert, config_path);;
- WritePrivateProfileBool(_T("Screen"), _T("OpenGLScanLineHoriz"),
+ MyWritePrivateProfileBool(_T("Screen"), _T("OpenGLScanLineHoriz"),
config.opengl_scanline_horiz, config_path);;
- WritePrivateProfileBool(_T("Screen"), _T("UseOpenGLFilters"),
+ MyWritePrivateProfileBool(_T("Screen"), _T("UseOpenGLFilters"),
config.use_opengl_filters, config_path);
- WritePrivateProfileInt(_T("Screen"), _T("OpenGLFilterNum"),
+ MyWritePrivateProfileInt(_T("Screen"), _T("OpenGLFilterNum"),
config.opengl_filter_num, config_path);
#endif
// sound
- WritePrivateProfileInt(_T("Sound"), _T("Frequency"), config.sound_frequency, config_path);
- WritePrivateProfileInt(_T("Sound"), _T("Latency"), config.sound_latency, config_path);
+ MyWritePrivateProfileInt(_T("Sound"), _T("Frequency"), config.sound_frequency, config_path);
+ MyWritePrivateProfileInt(_T("Sound"), _T("Latency"), config.sound_latency, config_path);
#ifdef USE_SOUND_DEVICE_TYPE
- WritePrivateProfileInt(_T("Sound"), _T("DeviceType"), config.sound_device_type, config_path);
+ MyWritePrivateProfileInt(_T("Sound"), _T("DeviceType"), config.sound_device_type, config_path);
#endif
#if !defined(_USE_QT)
- WritePrivateProfileString(_T("Sound"), _T("FMGenDll"), config.fmgen_dll_path, config_path);
+ MyWritePrivateProfileString(_T("Sound"), _T("FMGenDll"), config.fmgen_dll_path, config_path);
#endif
- WritePrivateProfileBool(_T("Sound"), _T("MultipleSpeakers"),
+ MyWritePrivateProfileBool(_T("Sound"), _T("MultipleSpeakers"),
config.multiple_speakers, config_path);
- WritePrivateProfileInt(_T("Sound"), _T("GeneralSoundLevel"),
+ MyWritePrivateProfileInt(_T("Sound"), _T("GeneralSoundLevel"),
config.general_sound_level, config_path);
#ifdef USE_MULTIPLE_SOUNDCARDS
{
int ii;
for(ii = 0; ii < USE_MULTIPLE_SOUNDCARDS; ii++) {
memset(_tag, 0x00, sizeof(_tag));
- _stprintf_s(_tag, 64, _T("DeviceVolumeLevel_%d"), ii + 1);
- WritePrivateProfileInt(_T("Sound"), (const _TCHAR *)_tag, config.sound_device_level[ii], config_path);
+ my_stprintf_s(_tag, 64, _T("DeviceVolumeLevel_%d"), ii + 1);
+ MyWritePrivateProfileInt(_T("Sound"), (const _TCHAR *)_tag, config.sound_device_level[ii], config_path);
}
}
#endif
// input
#ifdef _WIN32
- WritePrivateProfileBool(_T("Input"), _T("UseDirectInput"), config.use_direct_input, config_path);
- WritePrivateProfileBool(_T("Input"), _T("DisableDwm"), config.disable_dwm, config_path);
+ MyWritePrivateProfileBool(_T("Input"), _T("UseDirectInput"), config.use_direct_input, config_path);
+ MyWritePrivateProfileBool(_T("Input"), _T("DisableDwm"), config.disable_dwm, config_path);
#endif
- WritePrivateProfileBool(_T("Input"), _T("SwapJoyButtons"), config.swap_joy_buttons, config_path);
+ 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;
#endif
-
}
#define STATE_VERSION 3
va_list ap;
va_start(ap, format);
- _vstprintf_s(buffer, 1024, format, ap);
+ my_vstprintf_s(buffer, 1024, format, ap);
va_end(ap);
if(logfile != NULL && logfile->IsOpened()) {
if(str == NULL || _tcslen(str) == 0) {
return 0;
}
- _tcscpy_s(tmp, 1024, str);
+ my_tcscpy_s(tmp, 1024, str);
if(_tcslen(tmp) == 3 && tmp[0] == _T('\'') && tmp[2] == _T('\'')) {
// ank
// initialize console
_TCHAR buffer[1024];
- _stprintf_s(buffer, 1024, _T("Debugger - %s"), _T(DEVICE_NAME));
+ my_stprintf_s(buffer, 1024, _T("Debugger - %s"), _T(DEVICE_NAME));
p->osd->open_console(buffer);
_TCHAR *params[32], *token = NULL, *context = NULL;
int num = 0;
- if((token = _tcstok_s(command, _T(" "), &context)) != NULL) {
+ if((token = my_tcstok_s(command, _T(" "), &context)) != NULL) {
params[num++] = token;
- while(num < 32 && (token = _tcstok_s(NULL, _T(" "), &context)) != NULL) {
+ while(num < 32 && (token = my_tcstok_s(NULL, _T(" "), &context)) != NULL) {
params[num++] = token;
}
}
} else if(_tcsicmp(params[0], _T("EA")) == 0) {
if(num >= 3) {
uint32 addr = my_hexatoi(params[1]) & data_addr_mask;
- _tcscpy_s(buffer, 1024, prev_command);
- if((token = _tcstok_s(buffer, _T("\""), &context)) != NULL && (token = _tcstok_s(NULL, _T("\""), &context)) != NULL) {
+ my_tcscpy_s(buffer, 1024, prev_command);
+ if((token = my_tcstok_s(buffer, _T("\""), &context)) != NULL && (token = my_tcstok_s(NULL, _T("\""), &context)) != NULL) {
int len = _tcslen(token);
for(int i = 0; i < len; i++) {
cpu->debug_write_data8(addr, token[i] & 0xff);
}
} else if(_tcsicmp(params[0], _T("N")) == 0) {
if(num >= 2 && params[1][0] == _T('\"')) {
- _tcscpy_s(buffer, 1024, prev_command);
- if((token = _tcstok_s(buffer, _T("\""), &context)) != NULL && (token = _tcstok_s(NULL, _T("\""), &context)) != NULL) {
- _tcscpy_s(debugger->file_path, _MAX_PATH, token);
+ my_tcscpy_s(buffer, 1024, prev_command);
+ if((token = my_tcstok_s(buffer, _T("\""), &context)) != NULL && (token = my_tcstok_s(NULL, _T("\""), &context)) != NULL) {
+ my_tcscpy_s(debugger->file_path, _MAX_PATH, token);
} else {
my_printf(p->osd, _T("invalid parameter\n"));
}
} else if(num == 2) {
- _tcscpy_s(debugger->file_path, _MAX_PATH, params[1]);
+ my_tcscpy_s(debugger->file_path, _MAX_PATH, params[1]);
} else {
my_printf(p->osd, _T("invalid parameter number\n"));
}
#endif
{
#ifdef _DEBUG_LOG
- // open debug logfile
initialize_debug_log();
#endif
message_count = 0;
// store main window handle
-
#if !defined(_USE_QT)
// check os version
OSVERSIONINFO os_info;
initialize_debugger();
#endif
initialize_media();
- initialize_printer();
vm->initialize_sound(sound_rate, sound_samples);
vm->reset();
now_suspended = false;
#ifdef USE_DEBUGGER
release_debugger();
#endif
- release_printer();
osd->release();
delete osd;
delete vm;
}
//LockVM();
osd->update_input();
- update_media();
- update_printer();
+ osd->update_printer();
#ifdef USE_SOCKET
//osd->update_socket();
#endif
+ update_media();
// virtual machine may be driven to fill sound buffer
int extra_frames = 0;
}
// reset printer
- reset_printer();
+ osd->reset_printer();
// restart recording
osd->restart_rec_sound();
vm->special_reset();
// reset printer
- reset_printer();
+ osd->reset_printer();
// restart recording
restart_rec_sound();
return osd->now_rec_sound;
}
-#if defined(USE_MOVIE_PLAYER) || defined(USE_VIDEO_CAPTURE)
// ----------------------------------------------------------------------------
// video
// ----------------------------------------------------------------------------
+
+#if defined(USE_MOVIE_PLAYER) || defined(USE_VIDEO_CAPTURE)
void EMU::get_video_buffer()
{
osd->get_video_buffer();
}
#endif
-#ifdef USE_SOCKET
+
// ----------------------------------------------------------------------------
// socket
// ----------------------------------------------------------------------------
+#ifdef USE_SOCKET
int EMU::get_socket(int ch)
{
return osd->get_socket(ch);
}
#endif
-
-// ----------------------------------------------------------------------------
-// printer
-// ----------------------------------------------------------------------------
-
-void EMU::initialize_printer()
-{
- prn_fio = new FILEIO();
- prn_data = -1;
- prn_strobe = false;
-}
-
-void EMU::release_printer()
-{
- close_printer_file();
- delete prn_fio;
-}
-
-void EMU::reset_printer()
-{
- close_printer_file();
- prn_data = -1;
- prn_strobe = false;
-}
-
-void EMU::update_printer()
-{
- if(prn_fio->IsOpened() && --prn_wait_frames == 0) {
- close_printer_file();
- }
-}
-
-void EMU::open_printer_file()
-{
- cur_time_t time;
- get_host_time(&time);
- _stprintf_s(prn_file_name, _MAX_PATH, _T("prn_%d-%0.2d-%0.2d_%0.2d-%0.2d-%0.2d.txt"), time.year, time.month, time.day, time.hour, time.minute, time.second);
- prn_fio->Fopen(bios_path(prn_file_name), FILEIO_WRITE_BINARY);
-}
-
-void EMU::close_printer_file()
-{
- if(prn_fio->IsOpened()) {
- // remove if the file size is less than 2 bytes
- bool remove = (prn_fio->Ftell() < 2);
- prn_fio->Fclose();
- if(remove) {
- FILEIO::RemoveFile(bios_path(prn_file_name));
- }
- }
-}
-
-void EMU::printer_out(uint8 value)
-{
- prn_data = value;
-}
-
-void EMU::printer_strobe(bool value)
-{
- bool falling = (prn_strobe && !value);
- prn_strobe = value;
-
- if(falling) {
- if(!prn_fio->IsOpened()) {
- if(prn_data == -1) {
- return;
- }
- open_printer_file();
- }
- prn_fio->Fputc(prn_data);
- // wait 10sec
-#ifdef SUPPORT_VARIABLE_TIMING
- prn_wait_frames = (int)(vm->frame_rate() * 10.0 + 0.5);
-#else
- prn_wait_frames = (int)(FRAMES_PER_SEC * 10.0 + 0.5);
-#endif
- }
-}
-
-// ----------------------------------------------------------------------------
-// misc
-// ----------------------------------------------------------------------------
-
-_TCHAR* EMU::application_path()
-{
- return osd->application_path();
-}
-
-_TCHAR* EMU::bios_path(const _TCHAR* file_name)
-{
- return osd->bios_path(file_name);
-}
-
-void EMU::sleep(uint32 ms)
-{
- osd->sleep(ms);
-}
-
-void EMU::get_host_time(cur_time_t* time)
-{
- osd->get_host_time(time);
-}
-
// ----------------------------------------------------------------------------
// debug log
// ----------------------------------------------------------------------------
#if defined(_USE_QT) || defined(_USE_AGAR) || defined(_USE_SDL)
#else // Window
- debug_log = _tfopen(_T("d:\\debug.log"), _T("w"));
+ TCHAR path[_MAX_PATH];
+ osd->create_date_file_name(path, _MAX_PATH, _T("log"));
+ debug_log = _tfopen(path, _T("w"));
#endif
}
static _TCHAR prev_buffer[1024] = {0};
va_start(ap, format);
- _vstprintf_s(buffer, 1024, format, ap);
+ my_vstprintf_s(buffer, 1024, format, ap);
va_end(ap);
#if defined(_USE_QT) || defined(_USE_AGAR) || defined(_USE_SDL)
AGAR_DebugLog(AGAR_LOG_DEBUG, "%s", buffer);
#else
- if(_tcscmp(prev_buffer, buffer) == 0) {
+ if(my_tcscmp(prev_buffer, buffer) == 0) {
return;
}
- _tcscpy_s(prev_buffer, 1024, buffer);
+ my_tcscpy_s(prev_buffer, 1024, buffer);
if(debug_log) {
_ftprintf(debug_log, _T("%s"), buffer);
static int size = 0;
if((size += _tcslen(buffer)) > 0x8000000) { // 128MB
- static int index = 1;
TCHAR path[_MAX_PATH];
- _stprintf_s(path, _MAX_PATH, _T("d:\\debug_#%d.log"), ++index);
+ osd->create_date_file_name(path, _MAX_PATH, _T("log"));
fclose(debug_log);
debug_log = _tfopen(path, _T("w"));
size = 0;
{
va_list ap;
va_start(ap, format);
- _vstprintf_s(message, 260, format, ap); // Security for MSVC:C6386.
+ my_vstprintf_s(message, 260, format, ap); // Security for MSVC:C6386.
va_end(ap);
message_count = 4; // 4sec
}
// ----------------------------------------------------------------------------
+// misc
+// ----------------------------------------------------------------------------
+
+_TCHAR* EMU::application_path()
+{
+ return osd->application_path();
+}
+
+_TCHAR* EMU::bios_path(const _TCHAR* file_name)
+{
+ return osd->bios_path(file_name);
+}
+
+void EMU::sleep(uint32 ms)
+{
+ osd->sleep(ms);
+}
+
+void EMU::get_host_time(cur_time_t* time)
+{
+ osd->get_host_time(time);
+}
+
+
+// ----------------------------------------------------------------------------
// user interface
// ----------------------------------------------------------------------------
#ifdef USE_CART1
for(int drv = 0; drv < MAX_CART; drv++) {
if(cart_status[drv].path[0] != _T('\0')) {
- if(check_file_extension(cart_status[drv].path, _T(".hex")) && hex2bin(cart_status[drv].path, bios_path(_T("hex2bin.$$$")))) {
- vm->open_cart(drv, bios_path(_T("hex2bin.$$$")));
- FILEIO::RemoveFile(bios_path(_T("hex2bin.$$$")));
+ if(check_file_extension(cart_status[drv].path, _T(".hex")) && hex2bin(cart_status[drv].path, osd->bios_path(_T("hex2bin.$$$")))) {
+ vm->open_cart(drv, osd->bios_path(_T("hex2bin.$$$")));
+ FILEIO::RemoveFile(osd->bios_path(_T("hex2bin.$$$")));
} else {
vm->open_cart(drv, cart_status[drv].path);
}
void EMU::open_cart(int drv, const _TCHAR* file_path)
{
if(drv < MAX_CART) {
- if(check_file_extension(file_path, _T(".hex")) && hex2bin(file_path, bios_path(_T("hex2bin.$$$")))) {
- vm->open_cart(drv, bios_path(_T("hex2bin.$$$")));
- FILEIO::RemoveFile(bios_path(_T("hex2bin.$$$")));
+ if(check_file_extension(file_path, _T(".hex")) && hex2bin(file_path, osd->bios_path(_T("hex2bin.$$$")))) {
+ vm->open_cart(drv, osd->bios_path(_T("hex2bin.$$$")));
+ FILEIO::RemoveFile(osd->bios_path(_T("hex2bin.$$$")));
} else {
vm->open_cart(drv, file_path);
}
- _tcscpy_s(cart_status[drv].path, _MAX_PATH, file_path);
+ my_tcscpy_s(cart_status[drv].path, _MAX_PATH, file_path);
out_message(_T("Cart%d: %s"), drv + 1, file_path);
// restart recording
vm->open_disk(drv, file_path, bank);
out_message(_T("FD%d: %s"), drv + FD_BASE_NUMBER, file_path);
}
- _tcscpy_s(disk_status[drv].path, _MAX_PATH, file_path);
+ my_tcscpy_s(disk_status[drv].path, _MAX_PATH, file_path);
disk_status[drv].bank = bank;
}
}
vm->open_quickdisk(drv, file_path);
out_message(_T("QD%d: %s"), drv + QD_BASE_NUMBER, file_path);
}
- _tcscpy_s(quickdisk_status[drv].path, _MAX_PATH, file_path);
+ my_tcscpy_s(quickdisk_status[drv].path, _MAX_PATH, file_path);
}
}
vm->play_tape(file_path);
out_message(_T("CMT: %s"), file_path);
}
- _tcscpy_s(tape_status.path, _MAX_PATH, file_path);
+ my_tcscpy_s(tape_status.path, _MAX_PATH, file_path);
tape_status.play = true;
}
vm->rec_tape(file_path);
out_message(_T("CMT: %s"), file_path);
}
- _tcscpy_s(tape_status.path, _MAX_PATH, file_path);
+ my_tcscpy_s(tape_status.path, _MAX_PATH, file_path);
tape_status.play = false;
}
vm->open_laser_disc(file_path);
out_message(_T("LD: %s"), file_path);
}
- _tcscpy_s(laser_disc_status.path, _MAX_PATH, file_path);
+ my_tcscpy_s(laser_disc_status.path, _MAX_PATH, file_path);
}
void EMU::close_laser_disc()
void EMU::load_binary(int drv, const _TCHAR* file_path)
{
if(drv < MAX_BINARY) {
- if(check_file_extension(file_path, _T(".hex")) && hex2bin(file_path, bios_path(_T("hex2bin.$$$")))) {
- vm->load_binary(drv, bios_path(_T("hex2bin.$$$")));
- FILEIO::RemoveFile(bios_path(_T("hex2bin.$$$")));
+ if(check_file_extension(file_path, _T(".hex")) && hex2bin(file_path, osd->bios_path(_T("hex2bin.$$$")))) {
+ vm->load_binary(drv, osd->bios_path(_T("hex2bin.$$$")));
+ FILEIO::RemoveFile(osd->bios_path(_T("hex2bin.$$$")));
} else {
vm->load_binary(drv, file_path);
}
-#ifdef USE_STATE
// ----------------------------------------------------------------------------
// state
// ----------------------------------------------------------------------------
+#ifdef USE_STATE
#define STATE_VERSION 2
void EMU::save_state()
{
_TCHAR file_name[_MAX_PATH];
- _stprintf_s(file_name, _MAX_PATH, _T("%s.sta"), _T(CONFIG_NAME));
- save_state_tmp(bios_path(file_name));
+ my_stprintf_s(file_name, _MAX_PATH, _T("%s.sta"), _T(CONFIG_NAME));
+ save_state_tmp(osd->bios_path(file_name));
}
void EMU::load_state()
{
_TCHAR file_name[_MAX_PATH];
- _stprintf_s(file_name, _MAX_PATH, _T("%s.sta"), _T(CONFIG_NAME));
- FILEIO ffp;
- if(ffp.IsFileExists(bios_path(file_name))) {
+ my_stprintf_s(file_name, _MAX_PATH, _T("%s.sta"), _T(CONFIG_NAME));
+ FILEIO ffp;
+ if(ffp.IsFileExists(osd->bios_path(file_name))) {
save_state_tmp(bios_path(_T("$temp$.sta")));
- if(!load_state_tmp(bios_path(file_name))) {
+ if(!load_state_tmp(osd->bios_path(file_name))) {
out_debug_log("failed to load state file\n");
- load_state_tmp(bios_path(_T("$temp$.sta")));
+ load_state_tmp(osd->bios_path(_T("$temp$.sta")));
}
- DeleteFile(bios_path(_T("$temp$.sta")));
+ DeleteFile(osd->bios_path(_T("$temp$.sta")));
}
}
VM* vm;
OSD* osd;
private:
-
+ _TCHAR app_path[_MAX_PATH];
+
// ----------------------------------------
// sound
// ----------------------------------------
#ifdef USE_LASER_DISC
media_status_t laser_disc_status;
#endif
-
- void initialize_media();
- void update_media();
- void restore_media();
-
- void clear_media_status(media_status_t *status)
- {
- status->path[0] = _T('\0');
- status->wait_count = 0;
- }
-
- // ----------------------------------------
- // printer
- // ----------------------------------------
- void initialize_printer();
- void release_printer();
- void reset_printer();
- void update_printer();
- void open_printer_file();
- void close_printer_file();
-#ifdef _USE_QT
- _TCHAR prn_file_name[_MAX_PATH];
-#else
- _TCHAR prn_file_name[_MAX_PATH];
-#endif
- FILEIO *prn_fio;
- int prn_data, prn_wait_frames;
- bool prn_strobe;
-
+
#ifdef USE_SOCKET
- // ----------------------------------------
- // socket
- // ----------------------------------------
- void initialize_socket();
- void release_socket();
- void update_socket();
-
int soc[SOCKET_MAX];
bool is_tcp[SOCKET_MAX];
#if !defined(_USE_QT)
int recv_r_ptr[SOCKET_MAX], recv_w_ptr[SOCKET_MAX];
#endif
-#ifdef USE_DEBUGGER
- // ----------------------------------------
- // debugger
- // ----------------------------------------
- void initialize_debugger();
- void release_debugger();
-#if defined(_USE_QT)
- //CSP_Debugger *hDebugger;
- //QThread *hDebuggerThread;
-#else
- HANDLE hDebuggerThread;
- debugger_thread_t debugger_thread_param;
-#endif
-#endif
+ void initialize_media();
+ void update_media();
+ void restore_media();
-#ifdef _DEBUG_LOG
- // ----------------------------------------
- // debug log
- // ----------------------------------------
- void initialize_debug_log();
- void release_debug_log();
- FILE* debug_log;
-#endif
+ void clear_media_status(media_status_t *status)
+ {
+ status->path[0] = _T('\0');
+ status->wait_count = 0;
+ }
+
-#ifdef USE_STATE
// ----------------------------------------
// state
// ----------------------------------------
+#ifdef USE_STATE
void save_state_tmp(const _TCHAR* file_path);
bool load_state_tmp(const _TCHAR* file_path);
#endif
-
- // ----------------------------------------
- // misc
- // ----------------------------------------
-#ifdef USE_CPU_TYPE
- int cpu_type;
-#endif
-#ifdef USE_SOUND_DEVICE_TYPE
- int sound_device_type;
-#endif
- _TCHAR app_path[_MAX_PATH];
- bool now_suspended;
-
+
public:
uint32 *getJoyStatPtr(void) {
return joy_status;
int GetHostCpus() {
return host_cpus;
}
-
#else // M$ VC
void LockVM(void) {
}
// for windows
// ----------------------------------------
#if defined(_USE_QT)
- class Ui_MainWindow *main_window_handle;
+ class Ui_MainWindow *main_window_handle;
GLDrawClass *instance_handle;
#ifdef USE_DEBUGGER
- debugger_thread_t debugger_thread_param;
+ debugger_thread_t debugger_thread_param;
CSP_Debugger *hDebugger;
#endif
VM *getVM(void) {
void stop_rec_sound();
bool now_rec_sound();
-#if defined(USE_MOVIE_PLAYER) || defined(USE_VIDEO_CAPTURE)
// video device
+#if defined(USE_MOVIE_PLAYER) || defined(USE_VIDEO_CAPTURE)
void get_video_buffer();
void mute_video_dev(bool l, bool r);
#endif
void set_capture_dev_channel(int ch);
#endif
-#ifdef USE_SOCKET
+ // printer
+ void printer_out(uint8 value);
+ void printer_strobe(bool value);
// socket
+#ifdef USE_SOCKET
int get_socket(int ch);
void socket_connected(int ch);
void socket_disconnected(int ch);
void send_data(int ch);
void recv_data(int ch);
#endif
-
- // printer
- void printer_out(uint8 value);
- void printer_strobe(bool value);
-
-
-
+ // debugger
+#ifdef USE_DEBUGGER
+ void open_debugger(int cpu_index);
+ void close_debugger();
+ bool debugger_enabled(int cpu_index);
+ bool now_debugging;
+#endif
+ // debug log
+ void out_debug_log(const _TCHAR* format, ...);
+ void out_message(const _TCHAR* format, ...);
+ int message_count;
+ _TCHAR message[1024];
+
// misc
_TCHAR* application_path();
_TCHAR* bios_path(const _TCHAR* file_name);
void get_host_time(cur_time_t* time);
+ // debug log
+#ifdef _DEBUG_LOG
+ void initialize_debug_log();
+ void release_debug_log();
+ FILE* debug_log;
+#endif
+
+ // misc
+ int sound_rate, sound_samples;
+#ifdef USE_CPU_TYPE
+ int cpu_type;
+#endif
+#ifdef USE_SOUND_DEVICE_TYPE
+ int sound_device_type;
+#endif
+ bool now_suspended;
+
// media
#ifdef USE_FD1
struct {
#ifdef SUPPORT_DUMMY_DEVICE_LED
uint32 get_led_status(void);
#endif
-
-
void update_config();
-
- // input device
-
-#ifdef USE_DEBUGGER
- // debugger
- void open_debugger(int cpu_index);
- void close_debugger();
- bool debugger_enabled(int cpu_index);
- bool now_debugging;
-#endif
- // debug log
- void out_debug_log(const _TCHAR* format, ...);
- void out_message(const _TCHAR* format, ...);
- int message_count;
- _TCHAR message[_MAX_PATH];
-#ifdef USE_STATE
// state
+#ifdef USE_STATE
void save_state();
void load_state();
#endif
#if !defined(MSC_VER)
#include <stdarg.h>
#include <stdio.h>
+#include <iostream>
+#include <fstream>
+#include <cstdio>
#endif
FILEIO::FILEIO()
Fclose();
}
-bool FILEIO::IsFileExists(const _TCHAR *filename)
+bool FILEIO::IsFileExists(const _TCHAR *file_path)
{
-#if defined(_USE_AGAR) || defined(_USE_SDL)
- if(AG_FileExists((char *)filename) > 0) return true;
- return false;
-#elif defined(_USE_QT)
- QString fname((const char *)filename);
- QFileInfo f(fname);
-
- bool val = false;
- if(f.exists()) val = true;
-
- return val;
+#if defined(_USE_QT) || defined(_USE_SDL)
+ std::FILE *f;
+ f = std::fopen(file_path, "r");
+ if(f >= 0) return true;
+ return false;
#else
- DWORD attr = GetFileAttributes(filename);
- if(attr == -1) {
- return false;
- }
- return ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0);
+# ifdef _MSC_VER
+ DWORD attr = GetFileAttributes(file_path);
+ if(attr == -1) {
+ return false;
+ }
+ return ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0);
+# else
+ return (_taccess(file_path, 0) == 0); // not supported on wince ???
+# endif
#endif
}
-
-bool FILEIO::IsFileProtected(const _TCHAR *filename)
-{
#if defined(_USE_QT)
- QString fname((const char *)filename);
- QFileInfo f(fname);
-
- bool val = false;
- if(f.exists()) {
- if(f.isReadable() && !(f.isWritable())) val = true;
- }
-
- return val;
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <unistd.h>
+#endif
+bool FILEIO::IsFileProtected(const _TCHAR *file_path)
+{
+#if defined(_USE_QT) || defined(_USE_SDL)
+ struct stat st;
+ if(stat(file_path, &st) == 0) {
+ if((st.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH)) == 0) return true;
+ }
+ return false;
#else
- return ((GetFileAttributes(filename) & FILE_ATTRIBUTE_READONLY) != 0);
+# ifdef _MSC_VER
+ return ((GetFileAttributes(file_path) & FILE_ATTRIBUTE_READONLY) != 0);
+# else
+ return (_taccess(file_path, 2) != 0); // not supported on wince ???
+# endif
#endif
}
-void FILEIO::RemoveFile(const _TCHAR *filename)
+void FILEIO::RemoveFile(const _TCHAR *file_path)
{
-#if defined(_USE_QT)
- QString fname = (const char *)filename;
- QFile tmpfp;
- tmpfp.remove(fname);
+#if defined(_USE_QT) || defined(_USE_SDL)
+ std::remove(file_path);
#else
- DeleteFile(filename);
+# ifdef _MSC_VER
+ DeleteFile(file_path);
+# else
+ _tremove(file_path); // not supported on wince ???
+# endif
#endif
-// _tremove(filename); // not supported on wince
}
-bool FILEIO::Fopen(const _TCHAR *filename, int mode)
+bool FILEIO::Fopen(const _TCHAR *file_path, int mode)
{
Fclose();
switch(mode) {
case FILEIO_READ_BINARY:
- return ((fp = _tfopen(filename, _T("rb"))) != NULL);
+ return ((fp = _tfopen(file_path, _T("rb"))) != NULL);
case FILEIO_WRITE_BINARY:
- return ((fp = _tfopen(filename, _T("wb"))) != NULL);
+ return ((fp = _tfopen(file_path, _T("wb"))) != NULL);
case FILEIO_READ_WRITE_BINARY:
- return ((fp = _tfopen(filename, _T("r+b"))) != NULL);
+ return ((fp = _tfopen(file_path, _T("r+b"))) != NULL);
case FILEIO_READ_WRITE_NEW_BINARY:
- return ((fp = _tfopen(filename, _T("w+b"))) != NULL);
+ return ((fp = _tfopen(file_path, _T("w+b"))) != NULL);
case FILEIO_READ_ASCII:
- return ((fp = _tfopen(filename, _T("r"))) != NULL);
+ return ((fp = _tfopen(file_path, _T("r"))) != NULL);
case FILEIO_WRITE_ASCII:
- return ((fp = _tfopen(filename, _T("w"))) != NULL);
+ return ((fp = _tfopen(file_path, _T("w"))) != NULL);
case FILEIO_READ_WRITE_ASCII:
- return ((fp = _tfopen(filename, _T("r+"))) != NULL);
+ return ((fp = _tfopen(file_path, _T("r+"))) != NULL);
case FILEIO_READ_WRITE_NEW_ASCII:
- return ((fp = _tfopen(filename, _T("w+"))) != NULL);
+ return ((fp = _tfopen(file_path, _T("w+"))) != NULL);
}
return false;
}
FILEIO();
~FILEIO();
- static bool IsFileExists(const _TCHAR *filename);
- static bool IsFileProtected(const _TCHAR *filename);
- static void RemoveFile(const _TCHAR *filename);
+ static bool IsFileExists(const _TCHAR *file_path);
+ static bool IsFileProtected(const _TCHAR *file_path);
+ static void RemoveFile(const _TCHAR *file_path);
- bool Fopen(const _TCHAR *filename, int mode);
+ bool Fopen(const _TCHAR *file_path, int mode);
void Fclose();
bool IsOpened() { return (fp != NULL); }
uint32 FileLength();
_TCHAR tmp[_MAX_PATH];
if(GetFullPathName(src, _MAX_PATH, tmp, NULL) == 0) {
- _tcscpy_s(dst, dst_len, src);
+ my_tcscpy_s(dst, dst_len, src);
} else if(GetLongPathName(tmp, dst, _MAX_PATH) == 0) {
- _tcscpy_s(dst, dst_len, tmp);
+ my_tcscpy_s(dst, dst_len, tmp);
}
}
}
if(GetOpenFileName(&OpenFileName)) {
get_long_full_path_name(OpenFileName.lpstrFile, path, _MAX_PATH);
- _tcscpy_s(dir, dir_len, get_parent_dir(path));
+ my_tcscpy_s(dir, dir_len, get_parent_dir(path));
return path;
}
return NULL;
} \
} \
for(int i = no; i > 0; i--) { \
- _tcscpy_s(recent[i], _MAX_PATH, recent[i - 1]); \
+ my_tcscpy_s(recent[i], _MAX_PATH, recent[i - 1]); \
} \
- _tcscpy_s(recent[0], _MAX_PATH, path); \
+ my_tcscpy_s(recent[0], _MAX_PATH, path); \
}
// screen
_TCHAR buf[256];
int ratio = (int)(100.0 * (double)draw_frames / (double)total_frames + 0.5);
if(emu->message_count > 0) {
- _stprintf_s(buf, 256, _T("%s - %s"), _T(DEVICE_NAME), emu->message);
+ my_stprintf_s(buf, 256, _T("%s - %s"), _T(DEVICE_NAME), emu->message);
emu->message_count--;
} else if(now_skip) {
- _stprintf_s(buf, 256, _T("%s - Skip Frames"), _T(DEVICE_NAME));
+ my_stprintf_s(buf, 256, _T("%s - Skip Frames"), _T(DEVICE_NAME));
} else {
- _stprintf_s(buf, 256, _T("%s - %d fps (%d %%)"), _T(DEVICE_NAME), draw_frames, ratio);
+ my_stprintf_s(buf, 256, _T("%s - %d fps (%d %%)"), _T(DEVICE_NAME), draw_frames, ratio);
}
SetWindowText(hWnd, buf);
logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
logfont.lfQuality = DEFAULT_QUALITY;
logfont.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
- _tcscpy_s(logfont.lfFaceName, LF_FACESIZE, _T("Arial"));
+ my_tcscpy_s(logfont.lfFaceName, LF_FACESIZE, _T("Arial"));
logfont.lfHeight = buttons[i].font_size;
logfont.lfWidth = buttons[i].font_size >> 1;
hFont[buttons[i].font_size] = CreateFontIndirect(&logfont);
case ID_RECENT_CART + 6: \
case ID_RECENT_CART + 7: \
no = LOWORD(wParam) - ID_RECENT_CART; \
- _tcscpy_s(path, _MAX_PATH, config.recent_cart_path[drv][no]); \
+ my_tcscpy_s(path, _MAX_PATH, config.recent_cart_path[drv][no]); \
for(int i = no; i > 0; i--) { \
- _tcscpy_s(config.recent_cart_path[drv][i], _MAX_PATH, config.recent_cart_path[drv][i - 1]); \
+ my_tcscpy_s(config.recent_cart_path[drv][i], _MAX_PATH, config.recent_cart_path[drv][i - 1]); \
} \
- _tcscpy_s(config.recent_cart_path[drv][0], _MAX_PATH, path); \
+ my_tcscpy_s(config.recent_cart_path[drv][0], _MAX_PATH, path); \
if(emu) { \
emu->open_cart(drv, path); \
} \
case ID_RECENT_FD + 6: \
case ID_RECENT_FD + 7: \
no = LOWORD(wParam) - ID_RECENT_FD; \
- _tcscpy_s(path, _MAX_PATH, config.recent_disk_path[drv][no]); \
+ my_tcscpy_s(path, _MAX_PATH, config.recent_disk_path[drv][no]); \
for(int i = no; i > 0; i--) { \
- _tcscpy_s(config.recent_disk_path[drv][i], _MAX_PATH, config.recent_disk_path[drv][i - 1]); \
+ my_tcscpy_s(config.recent_disk_path[drv][i], _MAX_PATH, config.recent_disk_path[drv][i - 1]); \
} \
- _tcscpy_s(config.recent_disk_path[drv][0], _MAX_PATH, path); \
+ my_tcscpy_s(config.recent_disk_path[drv][0], _MAX_PATH, path); \
if(emu) { \
open_disk(drv, path, 0); \
} \
case ID_RECENT_QD + 6: \
case ID_RECENT_QD + 7: \
no = LOWORD(wParam) - ID_RECENT_QD; \
- _tcscpy_s(path, _MAX_PATH, config.recent_quickdisk_path[drv][no]); \
+ my_tcscpy_s(path, _MAX_PATH, config.recent_quickdisk_path[drv][no]); \
for(int i = no; i > 0; i--) { \
- _tcscpy_s(config.recent_quickdisk_path[drv][i], _MAX_PATH, config.recent_quickdisk_path[drv][i - 1]); \
+ my_tcscpy_s(config.recent_quickdisk_path[drv][i], _MAX_PATH, config.recent_quickdisk_path[drv][i - 1]); \
} \
- _tcscpy_s(config.recent_quickdisk_path[drv][0], _MAX_PATH, path); \
+ my_tcscpy_s(config.recent_quickdisk_path[drv][0], _MAX_PATH, path); \
if(emu) { \
emu->open_quickdisk(drv, path); \
} \
case ID_RECENT_TAPE + 6:
case ID_RECENT_TAPE + 7:
no = LOWORD(wParam) - ID_RECENT_TAPE;
- _tcscpy_s(path, _MAX_PATH, config.recent_tape_path[no]);
+ my_tcscpy_s(path, _MAX_PATH, config.recent_tape_path[no]);
for(int i = no; i > 0; i--) {
- _tcscpy_s(config.recent_tape_path[i], _MAX_PATH, config.recent_tape_path[i - 1]);
+ my_tcscpy_s(config.recent_tape_path[i], _MAX_PATH, config.recent_tape_path[i - 1]);
}
- _tcscpy_s(config.recent_tape_path[0], _MAX_PATH, path);
+ my_tcscpy_s(config.recent_tape_path[0], _MAX_PATH, path);
if(emu) {
emu->play_tape(path);
}
case ID_RECENT_LASER_DISC + 6:
case ID_RECENT_LASER_DISC + 7:
no = LOWORD(wParam) - ID_RECENT_LASER_DISC;
- _tcscpy_s(path, _MAX_PATH, config.recent_laser_disc_path[no]);
+ my_tcscpy_s(path, _MAX_PATH, config.recent_laser_disc_path[no]);
for(int i = no; i > 0; i--) {
- _tcscpy_s(config.recent_laser_disc_path[i], _MAX_PATH, config.recent_laser_disc_path[i - 1]);
+ my_tcscpy_s(config.recent_laser_disc_path[i], _MAX_PATH, config.recent_laser_disc_path[i - 1]);
}
- _tcscpy_s(config.recent_laser_disc_path[0], _MAX_PATH, path);
+ my_tcscpy_s(config.recent_laser_disc_path[0], _MAX_PATH, path);
if(emu) {
emu->open_laser_disc(path);
}
case ID_RECENT_BINARY + 6: \
case ID_RECENT_BINARY + 7: \
no = LOWORD(wParam) - ID_RECENT_BINARY; \
- _tcscpy_s(path, _MAX_PATH, config.recent_binary_path[drv][no]); \
+ my_tcscpy_s(path, _MAX_PATH, config.recent_binary_path[drv][no]); \
for(int i = no; i > 0; i--) { \
- _tcscpy_s(config.recent_binary_path[drv][i], _MAX_PATH, config.recent_binary_path[drv][i - 1]); \
+ my_tcscpy_s(config.recent_binary_path[drv][i], _MAX_PATH, config.recent_binary_path[drv][i - 1]); \
} \
- _tcscpy_s(config.recent_binary_path[drv][0], _MAX_PATH, path); \
+ my_tcscpy_s(config.recent_binary_path[drv][0], _MAX_PATH, path); \
if(emu) { \
emu->load_binary(drv, path); \
} \
AppendMenu(hMenu, MF_STRING | MF_DISABLED, ID_D88_FILE_PATH, emu->d88_file[drv].path); \
for(int i = 0; i < emu->d88_file[drv].bank_num; i++) { \
_TCHAR tmp[32]; \
- _stprintf_s(tmp, 32, _T("%d: %s"), i + 1, emu->d88_file[drv].disk_name[i]); \
+ my_stprintf_s(tmp, 32, _T("%d: %s"), i + 1, emu->d88_file[drv].disk_name[i]); \
AppendMenu(hMenu, MF_STRING | (emu->d88_file[drv].cur_bank == i ? MF_CHECKED : 0), ID_SELECT_D88_BANK + i, tmp); \
} \
AppendMenu(hMenu, MF_STRING | (emu->d88_file[drv].cur_bank == -1 ? MF_CHECKED : 0), ID_EJECT_D88_BANK, _T("0: (Disk Ejected)")); \
for(int i = 1; i < MAX_WINDOW; i++) {
if(emu && emu->get_window_width(i) <= desktop_width && emu->get_window_height(i) <= desktop_height) {
_TCHAR buf[16];
- _stprintf_s(buf, 16, _T("Window x%d"), i + 1);
+ my_stprintf_s(buf, 16, _T("Window x%d"), i + 1);
InsertMenu(hMenu, ID_SCREEN_FULLSCREEN1, MF_BYCOMMAND | MF_STRING, ID_SCREEN_WINDOW1 + i, buf);
last = ID_SCREEN_WINDOW1 + i;
}
ZeroMemory(&info, sizeof(info));
info.cbSize = sizeof(info);
_TCHAR buf[64];
- _stprintf_s(buf, 64, _T("Fullscreen %dx%d"), screen_mode_width[i], screen_mode_height[i]);
+ my_stprintf_s(buf, 64, _T("Fullscreen %dx%d"), screen_mode_width[i], screen_mode_height[i]);
info.fMask = MIIM_TYPE;
info.fType = MFT_STRING;
info.dwTypeData = buf;
);
if(path) {
UPDATE_HISTORY(path, config.recent_cart_path[drv]);
- _tcscpy_s(config.initial_cart_dir, _MAX_PATH, get_parent_dir(path));
+ my_tcscpy_s(config.initial_cart_dir, _MAX_PATH, get_parent_dir(path));
emu->open_cart(drv, path);
}
}
);
if(path) {
UPDATE_HISTORY(path, config.recent_disk_path[drv]);
- _tcscpy_s(config.initial_disk_dir, _MAX_PATH, get_parent_dir(path));
+ my_tcscpy_s(config.initial_disk_dir, _MAX_PATH, get_parent_dir(path));
open_disk(drv, path, 0);
}
}
file_offset += fio->FgetUint32_LE();
emu->d88_file[drv].bank_num++;
}
- _tcscpy_s(emu->d88_file[drv].path, _MAX_PATH, path);
+ my_tcscpy_s(emu->d88_file[drv].path, _MAX_PATH, path);
emu->d88_file[drv].cur_bank = bank;
} catch(...) {
emu->d88_file[drv].bank_num = 0;
);
if(path) {
UPDATE_HISTORY(path, config.recent_quickdisk_path[drv]);
- _tcscpy_s(config.initial_quickdisk_dir, _MAX_PATH, get_parent_dir(path));
+ my_tcscpy_s(config.initial_quickdisk_dir, _MAX_PATH, get_parent_dir(path));
emu->open_quickdisk(drv, path);
}
}
);
if(path) {
UPDATE_HISTORY(path, config.recent_tape_path);
- _tcscpy_s(config.initial_tape_dir, _MAX_PATH, get_parent_dir(path));
+ my_tcscpy_s(config.initial_tape_dir, _MAX_PATH, get_parent_dir(path));
if(play) {
emu->play_tape(path);
} else {
);
if(path) {
UPDATE_HISTORY(path, config.recent_laser_disc_path);
- _tcscpy_s(config.initial_laser_disc_dir, _MAX_PATH, get_parent_dir(path));
+ my_tcscpy_s(config.initial_laser_disc_dir, _MAX_PATH, get_parent_dir(path));
emu->open_laser_disc(path);
}
}
);
if(path) {
UPDATE_HISTORY(path, config.recent_binary_path[drv]);
- _tcscpy_s(config.initial_binary_dir, _MAX_PATH, get_parent_dir(path));
+ my_tcscpy_s(config.initial_binary_dir, _MAX_PATH, get_parent_dir(path));
if(load) {
emu->load_binary(drv, path);
} else {
check_file_extension(path, _T(".60" )) ||
check_file_extension(path, _T(".pce"))) {
UPDATE_HISTORY(path, config.recent_cart_path[0]);
- _tcscpy_s(config.initial_cart_dir, _MAX_PATH, get_parent_dir(path));
+ my_tcscpy_s(config.initial_cart_dir, _MAX_PATH, get_parent_dir(path));
emu->open_cart(0, path);
return;
}
check_file_extension(path, _T(".ima")) ||
check_file_extension(path, _T(".vfd"))) {
UPDATE_HISTORY(path, config.recent_disk_path[0]);
- _tcscpy_s(config.initial_disk_dir, _MAX_PATH, get_parent_dir(path));
+ my_tcscpy_s(config.initial_disk_dir, _MAX_PATH, get_parent_dir(path));
open_disk(0, path, 0);
return;
}
check_file_extension(path, _T(".tap")) ||
check_file_extension(path, _T(".t77"))) {
UPDATE_HISTORY(path, config.recent_tape_path);
- _tcscpy_s(config.initial_tape_dir, _MAX_PATH, get_parent_dir(path));
+ my_tcscpy_s(config.initial_tape_dir, _MAX_PATH, get_parent_dir(path));
emu->play_tape(path);
return;
}
check_file_extension(path, _T(".bin")) ||
check_file_extension(path, _T(".hex"))) {
UPDATE_HISTORY(path, config.recent_binary_path[0]);
- _tcscpy_s(config.initial_binary_dir, _MAX_PATH, get_parent_dir(path));
+ my_tcscpy_s(config.initial_binary_dir, _MAX_PATH, get_parent_dir(path));
emu->load_binary(0, path);
return;
}