OSDN Git Service

[UI][Qt] Move machine-dependent files to qt/machines/ .
authorK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 1 Dec 2015 05:26:22 +0000 (14:26 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 1 Dec 2015 05:26:22 +0000 (14:26 +0900)
[General][WIP] Merge upstream changes at 2015-11-30 (unofficial).

171 files changed:
source/src/common.cpp
source/src/common.h
source/src/common_gcc.h
source/src/common_msc.h [new file with mode: 0644]
source/src/config.cpp
source/src/debugger.cpp
source/src/emu.cpp
source/src/emu.h
source/src/fileio.cpp
source/src/fileio.h
source/src/qt/CMakeLists.txt [moved from source/src/qt/osd/CMakeLists.txt with 100% similarity]
source/src/qt/machines/babbage2nd/CMakeLists.txt [moved from source/src/qt/babbage2nd/CMakeLists.txt with 100% similarity]
source/src/qt/machines/babbage2nd/MainWindow.cpp [moved from source/src/qt/babbage2nd/MainWindow.cpp with 100% similarity]
source/src/qt/machines/babbage2nd/menuclasses.h [moved from source/src/qt/babbage2nd/menuclasses.h with 100% similarity]
source/src/qt/machines/bmjr/CMakeLists.txt [moved from source/src/qt/bmjr/CMakeLists.txt with 100% similarity]
source/src/qt/machines/bmjr/MainWindow.cpp [moved from source/src/qt/bmjr/MainWindow.cpp with 100% similarity]
source/src/qt/machines/bmjr/menuclasses.h [moved from source/src/qt/bmjr/menuclasses.h with 100% similarity]
source/src/qt/machines/familybasic/CMakeLists.txt [moved from source/src/qt/familybasic/CMakeLists.txt with 100% similarity]
source/src/qt/machines/familybasic/MainWindow.cpp [moved from source/src/qt/familybasic/MainWindow.cpp with 100% similarity]
source/src/qt/machines/familybasic/menuclasses.h [moved from source/src/qt/familybasic/menuclasses.h with 100% similarity]
source/src/qt/machines/fm16pi/CMakeLists.txt [moved from source/src/qt/fm16pi/CMakeLists.txt with 100% similarity]
source/src/qt/machines/fm16pi/MainWindow.cpp [moved from source/src/qt/fm16pi/MainWindow.cpp with 100% similarity]
source/src/qt/machines/fm16pi/menuclasses.h [moved from source/src/qt/fm16pi/menuclasses.h with 100% similarity]
source/src/qt/machines/fm7/CMakeLists.txt [moved from source/src/qt/fm7/CMakeLists.txt with 100% similarity]
source/src/qt/machines/fm7/MainWindow.cpp [moved from source/src/qt/fm7/MainWindow.cpp with 100% similarity]
source/src/qt/machines/fm7/menuclasses.h [moved from source/src/qt/fm7/menuclasses.h with 100% similarity]
source/src/qt/machines/fmr30/CMakeLists.txt [moved from source/src/qt/fmr30/CMakeLists.txt with 100% similarity]
source/src/qt/machines/fmr30/MainWindow.cpp [moved from source/src/qt/fmr30/MainWindow.cpp with 100% similarity]
source/src/qt/machines/fmr30/menuclasses.h [moved from source/src/qt/fmr30/menuclasses.h with 100% similarity]
source/src/qt/machines/fmr50/CMakeLists.txt [moved from source/src/qt/fmr50/CMakeLists.txt with 100% similarity]
source/src/qt/machines/fmr50/MainWindow.cpp [moved from source/src/qt/fmr50/MainWindow.cpp with 100% similarity]
source/src/qt/machines/fmr50/menuclasses.h [moved from source/src/qt/fmr50/menuclasses.h with 100% similarity]
source/src/qt/machines/fp1100/CMakeLists.txt [moved from source/src/qt/fp1100/CMakeLists.txt with 100% similarity]
source/src/qt/machines/fp1100/MainWindow.cpp [moved from source/src/qt/fp1100/MainWindow.cpp with 100% similarity]
source/src/qt/machines/fp1100/menuclasses.h [moved from source/src/qt/fp1100/menuclasses.h with 100% similarity]
source/src/qt/machines/fp200/CMakeLists.txt [moved from source/src/qt/fp200/CMakeLists.txt with 100% similarity]
source/src/qt/machines/fp200/MainWindow.cpp [moved from source/src/qt/fp200/MainWindow.cpp with 100% similarity]
source/src/qt/machines/fp200/menuclasses.h [moved from source/src/qt/fp200/menuclasses.h with 100% similarity]
source/src/qt/machines/gamegear/CMakeLists.txt [moved from source/src/qt/gamegear/CMakeLists.txt with 100% similarity]
source/src/qt/machines/gamegear/MainWindow.cpp [moved from source/src/qt/gamegear/MainWindow.cpp with 100% similarity]
source/src/qt/machines/gamegear/menuclasses.h [moved from source/src/qt/gamegear/menuclasses.h with 100% similarity]
source/src/qt/machines/hc20/CMakeLists.txt [moved from source/src/qt/hc20/CMakeLists.txt with 100% similarity]
source/src/qt/machines/hc20/MainWindow.cpp [moved from source/src/qt/hc20/MainWindow.cpp with 100% similarity]
source/src/qt/machines/hc20/menuclasses.h [moved from source/src/qt/hc20/menuclasses.h with 100% similarity]
source/src/qt/machines/hc40/CMakeLists.txt [moved from source/src/qt/hc40/CMakeLists.txt with 100% similarity]
source/src/qt/machines/hc40/MainWindow.cpp [moved from source/src/qt/hc40/MainWindow.cpp with 100% similarity]
source/src/qt/machines/hc40/menuclasses.h [moved from source/src/qt/hc40/menuclasses.h with 100% similarity]
source/src/qt/machines/hc80/CMakeLists.txt [moved from source/src/qt/hc80/CMakeLists.txt with 100% similarity]
source/src/qt/machines/hc80/MainWindow.cpp [moved from source/src/qt/hc80/MainWindow.cpp with 100% similarity]
source/src/qt/machines/hc80/menuclasses.h [moved from source/src/qt/hc80/menuclasses.h with 100% similarity]
source/src/qt/machines/j3100/CMakeLists.txt [moved from source/src/qt/j3100/CMakeLists.txt with 100% similarity]
source/src/qt/machines/j3100/MainWindow.cpp [moved from source/src/qt/j3100/MainWindow.cpp with 100% similarity]
source/src/qt/machines/j3100/menuclasses.h [moved from source/src/qt/j3100/menuclasses.h with 100% similarity]
source/src/qt/machines/jr100/CMakeLists.txt [moved from source/src/qt/jr100/CMakeLists.txt with 100% similarity]
source/src/qt/machines/jr100/MainWindow.cpp [moved from source/src/qt/jr100/MainWindow.cpp with 100% similarity]
source/src/qt/machines/jr100/menuclasses.h [moved from source/src/qt/jr100/menuclasses.h with 100% similarity]
source/src/qt/machines/jx/CMakeLists.txt [moved from source/src/qt/jx/CMakeLists.txt with 100% similarity]
source/src/qt/machines/jx/MainWindow.cpp [moved from source/src/qt/jx/MainWindow.cpp with 100% similarity]
source/src/qt/machines/jx/menuclasses.h [moved from source/src/qt/jx/menuclasses.h with 100% similarity]
source/src/qt/machines/m5/CMakeLists.txt [moved from source/src/qt/m5/CMakeLists.txt with 100% similarity]
source/src/qt/machines/m5/MainWindow.cpp [moved from source/src/qt/m5/MainWindow.cpp with 100% similarity]
source/src/qt/machines/m5/menuclasses.h [moved from source/src/qt/m5/menuclasses.h with 100% similarity]
source/src/qt/machines/msx1/CMakeLists.txt [moved from source/src/qt/msx1/CMakeLists.txt with 100% similarity]
source/src/qt/machines/msx1/MainWindow.cpp [moved from source/src/qt/msx1/MainWindow.cpp with 100% similarity]
source/src/qt/machines/msx1/menuclasses.h [moved from source/src/qt/msx1/menuclasses.h with 100% similarity]
source/src/qt/machines/multi8/CMakeLists.txt [moved from source/src/qt/multi8/CMakeLists.txt with 100% similarity]
source/src/qt/machines/multi8/MainWindow.cpp [moved from source/src/qt/multi8/MainWindow.cpp with 100% similarity]
source/src/qt/machines/multi8/menuclasses.h [moved from source/src/qt/multi8/menuclasses.h with 100% similarity]
source/src/qt/machines/mycomz80a/CMakeLists.txt [moved from source/src/qt/mycomz80a/CMakeLists.txt with 100% similarity]
source/src/qt/machines/mycomz80a/MainWindow.cpp [moved from source/src/qt/mycomz80a/MainWindow.cpp with 100% similarity]
source/src/qt/machines/mycomz80a/menuclasses.h [moved from source/src/qt/mycomz80a/menuclasses.h with 100% similarity]
source/src/qt/machines/mz2500/CMakeLists.txt [moved from source/src/qt/mz2500/CMakeLists.txt with 100% similarity]
source/src/qt/machines/mz2500/MainWindow.cpp [moved from source/src/qt/mz2500/MainWindow.cpp with 100% similarity]
source/src/qt/machines/mz2500/menuclasses.h [moved from source/src/qt/mz2500/menuclasses.h with 100% similarity]
source/src/qt/machines/mz2800/CMakeLists.txt [moved from source/src/qt/mz2800/CMakeLists.txt with 100% similarity]
source/src/qt/machines/mz2800/MainWindow.cpp [moved from source/src/qt/mz2800/MainWindow.cpp with 100% similarity]
source/src/qt/machines/mz2800/menuclasses.h [moved from source/src/qt/mz2800/menuclasses.h with 100% similarity]
source/src/qt/machines/mz3500/CMakeLists.txt [moved from source/src/qt/mz3500/CMakeLists.txt with 100% similarity]
source/src/qt/machines/mz3500/MainWindow.cpp [moved from source/src/qt/mz3500/MainWindow.cpp with 100% similarity]
source/src/qt/machines/mz3500/menuclasses.h [moved from source/src/qt/mz3500/menuclasses.h with 100% similarity]
source/src/qt/machines/mz5500/CMakeLists.txt [moved from source/src/qt/mz5500/CMakeLists.txt with 100% similarity]
source/src/qt/machines/mz5500/MainWindow.cpp [moved from source/src/qt/mz5500/MainWindow.cpp with 100% similarity]
source/src/qt/machines/mz5500/menuclasses.h [moved from source/src/qt/mz5500/menuclasses.h with 100% similarity]
source/src/qt/machines/mz700/CMakeLists.txt [moved from source/src/qt/mz700/CMakeLists.txt with 100% similarity]
source/src/qt/machines/mz700/MainWindow.cpp [moved from source/src/qt/mz700/MainWindow.cpp with 100% similarity]
source/src/qt/machines/mz700/menuclasses.h [moved from source/src/qt/mz700/menuclasses.h with 100% similarity]
source/src/qt/machines/mz80k/CMakeLists.txt [moved from source/src/qt/mz80k/CMakeLists.txt with 100% similarity]
source/src/qt/machines/mz80k/MainWindow.cpp [moved from source/src/qt/mz80k/MainWindow.cpp with 100% similarity]
source/src/qt/machines/mz80k/menuclasses.h [moved from source/src/qt/mz80k/menuclasses.h with 100% similarity]
source/src/qt/machines/n5200/CMakeLists.txt [moved from source/src/qt/n5200/CMakeLists.txt with 100% similarity]
source/src/qt/machines/n5200/MainWindow.cpp [moved from source/src/qt/n5200/MainWindow.cpp with 100% similarity]
source/src/qt/machines/n5200/menuclasses.h [moved from source/src/qt/n5200/menuclasses.h with 100% similarity]
source/src/qt/machines/pasopia/CMakeLists.txt [moved from source/src/qt/pasopia/CMakeLists.txt with 100% similarity]
source/src/qt/machines/pasopia/MainWindow.cpp [moved from source/src/qt/pasopia/MainWindow.cpp with 100% similarity]
source/src/qt/machines/pasopia/menuclasses.h [moved from source/src/qt/pasopia/menuclasses.h with 100% similarity]
source/src/qt/machines/pc100/CMakeLists.txt [moved from source/src/qt/pc100/CMakeLists.txt with 100% similarity]
source/src/qt/machines/pc100/MainWindow.cpp [moved from source/src/qt/pc100/MainWindow.cpp with 100% similarity]
source/src/qt/machines/pc100/menuclasses.h [moved from source/src/qt/pc100/menuclasses.h with 100% similarity]
source/src/qt/machines/pc6001/CMakeLists.txt [moved from source/src/qt/pc6001/CMakeLists.txt with 100% similarity]
source/src/qt/machines/pc6001/MainWindow.cpp [moved from source/src/qt/pc6001/MainWindow.cpp with 100% similarity]
source/src/qt/machines/pc6001/menuclasses.h [moved from source/src/qt/pc6001/menuclasses.h with 100% similarity]
source/src/qt/machines/pc8201/CMakeLists.txt [moved from source/src/qt/pc8201/CMakeLists.txt with 100% similarity]
source/src/qt/machines/pc8201/MainWindow.cpp [moved from source/src/qt/pc8201/MainWindow.cpp with 100% similarity]
source/src/qt/machines/pc8201/menuclasses.h [moved from source/src/qt/pc8201/menuclasses.h with 100% similarity]
source/src/qt/machines/pc8801ma/CMakeLists.txt [moved from source/src/qt/pc8801ma/CMakeLists.txt with 100% similarity]
source/src/qt/machines/pc8801ma/MainWindow.cpp [moved from source/src/qt/pc8801ma/MainWindow.cpp with 100% similarity]
source/src/qt/machines/pc8801ma/menuclasses.h [moved from source/src/qt/pc8801ma/menuclasses.h with 100% similarity]
source/src/qt/machines/pc9801/CMakeLists.txt [moved from source/src/qt/pc9801/CMakeLists.txt with 100% similarity]
source/src/qt/machines/pc9801/MainWindow.cpp [moved from source/src/qt/pc9801/MainWindow.cpp with 100% similarity]
source/src/qt/machines/pc9801/menuclasses.h [moved from source/src/qt/pc9801/menuclasses.h with 100% similarity]
source/src/qt/machines/pc98ha/CMakeLists.txt [moved from source/src/qt/pc98ha/CMakeLists.txt with 100% similarity]
source/src/qt/machines/pc98ha/MainWindow.cpp [moved from source/src/qt/pc98ha/MainWindow.cpp with 100% similarity]
source/src/qt/machines/pc98ha/menuclasses.h [moved from source/src/qt/pc98ha/menuclasses.h with 100% similarity]
source/src/qt/machines/pcengine/CMakeLists.txt [moved from source/src/qt/pcengine/CMakeLists.txt with 100% similarity]
source/src/qt/machines/pcengine/MainWindow.cpp [moved from source/src/qt/pcengine/MainWindow.cpp with 100% similarity]
source/src/qt/machines/pcengine/menuclasses.h [moved from source/src/qt/pcengine/menuclasses.h with 100% similarity]
source/src/qt/machines/phc20/CMakeLists.txt [moved from source/src/qt/phc20/CMakeLists.txt with 100% similarity]
source/src/qt/machines/phc20/MainWindow.cpp [moved from source/src/qt/phc20/MainWindow.cpp with 100% similarity]
source/src/qt/machines/phc20/menuclasses.h [moved from source/src/qt/phc20/menuclasses.h with 100% similarity]
source/src/qt/machines/phc25/CMakeLists.txt [moved from source/src/qt/phc25/CMakeLists.txt with 100% similarity]
source/src/qt/machines/phc25/MainWindow.cpp [moved from source/src/qt/phc25/MainWindow.cpp with 100% similarity]
source/src/qt/machines/phc25/menuclasses.h [moved from source/src/qt/phc25/menuclasses.h with 100% similarity]
source/src/qt/machines/pv1000/CMakeLists.txt [moved from source/src/qt/pv1000/CMakeLists.txt with 100% similarity]
source/src/qt/machines/pv1000/MainWindow.cpp [moved from source/src/qt/pv1000/MainWindow.cpp with 100% similarity]
source/src/qt/machines/pv1000/menuclasses.h [moved from source/src/qt/pv1000/menuclasses.h with 100% similarity]
source/src/qt/machines/pv2000/CMakeLists.txt [moved from source/src/qt/pv2000/CMakeLists.txt with 100% similarity]
source/src/qt/machines/pv2000/MainWindow.cpp [moved from source/src/qt/pv2000/MainWindow.cpp with 100% similarity]
source/src/qt/machines/pv2000/menuclasses.h [moved from source/src/qt/pv2000/menuclasses.h with 100% similarity]
source/src/qt/machines/pyuta/CMakeLists.txt [moved from source/src/qt/pyuta/CMakeLists.txt with 100% similarity]
source/src/qt/machines/pyuta/MainWindow.cpp [moved from source/src/qt/pyuta/MainWindow.cpp with 100% similarity]
source/src/qt/machines/pyuta/menuclasses.h [moved from source/src/qt/pyuta/menuclasses.h with 100% similarity]
source/src/qt/machines/qc10/CMakeLists.txt [moved from source/src/qt/qc10/CMakeLists.txt with 100% similarity]
source/src/qt/machines/qc10/MainWindow.cpp [moved from source/src/qt/qc10/MainWindow.cpp with 100% similarity]
source/src/qt/machines/qc10/menuclasses.h [moved from source/src/qt/qc10/menuclasses.h with 100% similarity]
source/src/qt/machines/rx78/CMakeLists.txt [moved from source/src/qt/rx78/CMakeLists.txt with 100% similarity]
source/src/qt/machines/rx78/MainWindow.cpp [moved from source/src/qt/rx78/MainWindow.cpp with 100% similarity]
source/src/qt/machines/rx78/menuclasses.h [moved from source/src/qt/rx78/menuclasses.h with 100% similarity]
source/src/qt/machines/sc3000/CMakeLists.txt [moved from source/src/qt/sc3000/CMakeLists.txt with 100% similarity]
source/src/qt/machines/sc3000/MainWindow.cpp [moved from source/src/qt/sc3000/MainWindow.cpp with 100% similarity]
source/src/qt/machines/sc3000/menuclasses.h [moved from source/src/qt/sc3000/menuclasses.h with 100% similarity]
source/src/qt/machines/scv/CMakeLists.txt [moved from source/src/qt/scv/CMakeLists.txt with 100% similarity]
source/src/qt/machines/scv/MainWindow.cpp [moved from source/src/qt/scv/MainWindow.cpp with 100% similarity]
source/src/qt/machines/scv/menuclasses.h [moved from source/src/qt/scv/menuclasses.h with 100% similarity]
source/src/qt/machines/smc777/CMakeLists.txt [moved from source/src/qt/smc777/CMakeLists.txt with 100% similarity]
source/src/qt/machines/smc777/MainWindow.cpp [moved from source/src/qt/smc777/MainWindow.cpp with 100% similarity]
source/src/qt/machines/smc777/menuclasses.h [moved from source/src/qt/smc777/menuclasses.h with 100% similarity]
source/src/qt/machines/templetes/MainWindow.cpp [moved from source/src/qt/templetes/MainWindow.cpp with 100% similarity]
source/src/qt/machines/tk80bs/CMakeLists.txt [moved from source/src/qt/tk80bs/CMakeLists.txt with 100% similarity]
source/src/qt/machines/tk80bs/MainWindow.cpp [moved from source/src/qt/tk80bs/MainWindow.cpp with 100% similarity]
source/src/qt/machines/tk80bs/menuclasses.h [moved from source/src/qt/tk80bs/menuclasses.h with 100% similarity]
source/src/qt/machines/ui/OpenFDs.ui [moved from source/src/qt/ui/OpenFDs.ui with 100% similarity]
source/src/qt/machines/ui/mainwindow.ui [moved from source/src/qt/ui/mainwindow.ui with 100% similarity]
source/src/qt/machines/x1turboz/CMakeLists.txt [moved from source/src/qt/x1turboz/CMakeLists.txt with 100% similarity]
source/src/qt/machines/x1turboz/MainWindow.cpp [moved from source/src/qt/x1turboz/MainWindow.cpp with 100% similarity]
source/src/qt/machines/x1turboz/menuclasses.h [moved from source/src/qt/x1turboz/menuclasses.h with 100% similarity]
source/src/qt/machines/ys6464a/CMakeLists.txt [moved from source/src/qt/ys6464a/CMakeLists.txt with 100% similarity]
source/src/qt/machines/ys6464a/MainWindow.cpp [moved from source/src/qt/ys6464a/MainWindow.cpp with 100% similarity]
source/src/qt/machines/ys6464a/menuclasses.h [moved from source/src/qt/ys6464a/menuclasses.h with 100% similarity]
source/src/qt/machines/z80tvgame/CMakeLists.txt [moved from source/src/qt/z80tvgame/CMakeLists.txt with 100% similarity]
source/src/qt/machines/z80tvgame/MainWindow.cpp [moved from source/src/qt/z80tvgame/MainWindow.cpp with 100% similarity]
source/src/qt/machines/z80tvgame/menuclasses.h [moved from source/src/qt/z80tvgame/menuclasses.h with 100% similarity]
source/src/qt/osd.cpp [moved from source/src/qt/osd/osd.cpp with 100% similarity]
source/src/qt/osd.h [moved from source/src/qt/osd/osd.h with 100% similarity]
source/src/qt/osd_console.cpp [moved from source/src/qt/osd/osd_console.cpp with 100% similarity]
source/src/qt/osd_input.cpp [moved from source/src/qt/osd/osd_input.cpp with 100% similarity]
source/src/qt/osd_printer.cpp [moved from source/src/qt/osd/osd_printer.cpp with 100% similarity]
source/src/qt/osd_screen.cpp [moved from source/src/qt/osd/osd_screen.cpp with 100% similarity]
source/src/qt/osd_socket.cpp [moved from source/src/qt/osd/osd_socket.cpp with 100% similarity]
source/src/qt/osd_sound.cpp [moved from source/src/qt/osd/osd_sound.cpp with 100% similarity]
source/src/qt/osd_video.cpp [moved from source/src/qt/osd/osd_video.cpp with 100% similarity]
source/src/winmain.cpp

index 4ae9e0f..00b15b8 100644 (file)
@@ -55,6 +55,68 @@ inline unsigned int min(unsigned int a, unsigned int b)
 }
 #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)
 {
@@ -128,33 +190,6 @@ uint8 A_OF_COLOR(scrntype c)
 
 #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)
@@ -206,7 +241,7 @@ _TCHAR *get_file_path_without_extensiton(const _TCHAR* file_path)
    
    
 #else
-       _tcscpy_s(path, _MAX_PATH, file_path);
+       my_tcscpy_s(path, _MAX_PATH, file_path);
         PathRemoveExtension(path);
        return path;
 #endif
index d97e787..f589528 100644 (file)
@@ -20,6 +20,7 @@
  #include <tchar.h>
 #endif
 #include <stdio.h>
+#include <errno.h>
 
 #if defined(_MSC_VER)
 #include <windows.h>
@@ -43,8 +44,8 @@
 
 #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
@@ -117,17 +118,31 @@ typedef signed long long int64;
 #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 {
@@ -208,6 +223,91 @@ 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
 
index 804470d..cfb82d0 100644 (file)
 
 
 #include <stdarg.h>
+#include <string>
+#include <iostream>
+#include <fstream>
+
 #include <SDL.h>
 
 #if defined(Q_OS_CYGWIN) 
@@ -46,6 +50,7 @@ typedef int32_t int32;
 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;
@@ -77,17 +82,9 @@ static inline void _stprintf(char *s, const char *fmt, ...) {
 # 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)
@@ -95,10 +92,8 @@ static inline char *_tcsncat(_TCHAR *d, _TCHAR *s, int 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>
@@ -109,37 +104,6 @@ static int DeleteFile(_TCHAR *path)
 #  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)
diff --git a/source/src/common_msc.h b/source/src/common_msc.h
new file mode 100644 (file)
index 0000000..6150975
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * 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
index 4e59d0a..366989c 100644 (file)
@@ -47,7 +47,7 @@ config_t config;
 #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;
@@ -67,7 +67,7 @@ bool WritePrivateProfileString(const _TCHAR *lpAppName, const _TCHAR *lpKeyName,
        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;
@@ -75,19 +75,19 @@ bool WritePrivateProfileInt(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, in
        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];
@@ -135,10 +135,9 @@ std::string GetPrivateProfileStr(const _TCHAR *lpAppName, const _TCHAR *lpKeyNam
 }
 
 
-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 {
@@ -146,20 +145,20 @@ void GetPrivateProfileString(const _TCHAR *section, const _TCHAR *key, const _TC
        }
 }
 
-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);
@@ -171,36 +170,35 @@ int GetPrivateProfileInt(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, int n
        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;
@@ -324,115 +322,115 @@ void load_config()
        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);
                }
        }
@@ -440,53 +438,53 @@ void load_config()
        
        // 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
        {
@@ -494,16 +492,16 @@ void load_config()
                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.");
@@ -538,103 +536,103 @@ void save_config()
        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);
                }
        }
@@ -642,52 +640,52 @@ void save_config()
        
        // 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
        {
@@ -695,23 +693,22 @@ void save_config()
                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
index 2db10d0..da4c4ba 100644 (file)
@@ -39,7 +39,7 @@ void my_printf(OSD *osd, const _TCHAR *format, ...)
        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()) {
@@ -63,7 +63,7 @@ uint32 my_hexatoi(const _TCHAR *str)
        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
@@ -140,7 +140,7 @@ void* debugger_thread(void *lpx)
        
        // 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);
        
@@ -215,9 +215,9 @@ void* debugger_thread(void *lpx)
                        _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;
                                }
                        }
@@ -303,8 +303,8 @@ void* debugger_thread(void *lpx)
                        } 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);
@@ -433,14 +433,14 @@ void* debugger_thread(void *lpx)
                                }
                        } 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"));
                                }
index 5f7cc4f..695082c 100644 (file)
@@ -47,13 +47,11 @@ EMU::EMU()
 #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;
@@ -128,7 +126,6 @@ EMU::EMU()
        initialize_debugger();
 #endif
        initialize_media();
-       initialize_printer();
        vm->initialize_sound(sound_rate, sound_samples);
        vm->reset();
        now_suspended = false;
@@ -139,7 +136,6 @@ EMU::~EMU()
 #ifdef USE_DEBUGGER
        release_debugger();
 #endif
-       release_printer();
        osd->release();
        delete osd;
        delete vm;
@@ -186,11 +182,11 @@ int EMU::run()
        }
        //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;
@@ -236,7 +232,7 @@ void EMU::reset()
        }
        
        // reset printer
-       reset_printer();
+       osd->reset_printer();
        
        // restart recording
        osd->restart_rec_sound();
@@ -250,7 +246,7 @@ void EMU::special_reset()
        vm->special_reset();
        
        // reset printer
-       reset_printer();
+       osd->reset_printer();
        
        // restart recording
        restart_rec_sound();
@@ -478,10 +474,11 @@ bool EMU::now_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();
@@ -587,11 +584,12 @@ void EMU::set_capture_dev_channel(int ch)
 }
 #endif
 
-#ifdef USE_SOCKET
+
 // ----------------------------------------------------------------------------
 // socket
 // ----------------------------------------------------------------------------
 
+#ifdef USE_SOCKET
 int EMU::get_socket(int ch)
 {
        return osd->get_socket(ch);
@@ -653,109 +651,6 @@ void EMU::recv_data(int 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
 // ----------------------------------------------------------------------------
@@ -766,7 +661,9 @@ void EMU::initialize_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
 }
 
@@ -791,23 +688,22 @@ void EMU::out_debug_log(const _TCHAR* format, ...)
        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;
@@ -821,12 +717,37 @@ void EMU::out_message(const _TCHAR* format, ...)
 {
        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
 // ----------------------------------------------------------------------------
 
@@ -947,9 +868,9 @@ void EMU::restore_media()
 #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);
                        }
@@ -990,13 +911,13 @@ void EMU::restore_media()
 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
@@ -1049,7 +970,7 @@ void EMU::open_disk(int drv, const _TCHAR* file_path, int bank)
                        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;
        }
 }
@@ -1125,7 +1046,7 @@ void EMU::open_quickdisk(int drv, const _TCHAR* file_path)
                        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);
        }
 }
 
@@ -1164,7 +1085,7 @@ void EMU::play_tape(const _TCHAR* 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;
 }
 
@@ -1183,7 +1104,7 @@ void EMU::rec_tape(const _TCHAR* file_path)
                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;
 }
 
@@ -1265,7 +1186,7 @@ void EMU::open_laser_disc(const _TCHAR* file_path)
                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()
@@ -1285,9 +1206,9 @@ bool EMU::laser_disc_inserted()
 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);
                }
@@ -1322,32 +1243,32 @@ void EMU::update_config()
 
 
 
-#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")));
        }
 }
 
index 7e85a15..8001af1 100644 (file)
@@ -101,7 +101,8 @@ protected:
        VM* vm;
        OSD* osd;
 private:
-
+       _TCHAR app_path[_MAX_PATH];
+       
        // ----------------------------------------
        // sound
        // ----------------------------------------
@@ -135,43 +136,8 @@ private:
 #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) 
@@ -182,50 +148,25 @@ private:
        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;
@@ -262,7 +203,6 @@ public:
        int GetHostCpus() {
                return host_cpus;
        }
-   
 #else // M$ VC
         void LockVM(void) {
        }
@@ -273,10 +213,10 @@ public:
        // 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) {
@@ -348,8 +288,8 @@ public:
        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
@@ -376,8 +316,11 @@ public:
        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);
@@ -391,13 +334,19 @@ public:
        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);
@@ -405,6 +354,23 @@ public:
        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 {
@@ -465,26 +431,9 @@ public:
 #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
index 486f48f..247a0d1 100644 (file)
@@ -11,6 +11,9 @@
 #if !defined(MSC_VER)
 #include <stdarg.h>
 #include <stdio.h>
+#include <iostream>
+#include <fstream>
+#include <cstdio>
 #endif
 
 FILEIO::FILEIO()
@@ -23,78 +26,81 @@ FILEIO::~FILEIO(void)
        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;
 }
index 77f7898..240cdc7 100644 (file)
@@ -42,11 +42,11 @@ public:
        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();
similarity index 100%
rename from source/src/qt/osd/osd.h
rename to source/src/qt/osd.h
index bb983d9..f2edebe 100644 (file)
@@ -87,9 +87,9 @@ void get_long_full_path_name(const _TCHAR* src, _TCHAR* dst, size_t dst_len)
        _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);
        }
 }
 
@@ -125,7 +125,7 @@ _TCHAR* get_open_file_name(HWND hWnd, const _TCHAR* filter, const _TCHAR* title,
        }
        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;
@@ -140,9 +140,9 @@ _TCHAR* get_open_file_name(HWND hWnd, const _TCHAR* filter, const _TCHAR* title,
                } \
        } \
        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
@@ -397,12 +397,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR szCmdLin
                                _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);
                                
@@ -478,7 +478,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
                                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);
@@ -839,11 +839,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
                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); \
                        } \
@@ -885,11 +885,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
                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); \
                        } \
@@ -1014,11 +1014,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
                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); \
                        } \
@@ -1062,11 +1062,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
                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);
                        }
@@ -1132,11 +1132,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
                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);
                        }
@@ -1163,11 +1163,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
                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); \
                        } \
@@ -1590,7 +1590,7 @@ void update_menu(HWND hWnd, HMENU hMenu, int pos)
                        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)")); \
@@ -1782,7 +1782,7 @@ void update_menu(HWND hWnd, HMENU hMenu, int pos)
                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;
                        }
@@ -1793,7 +1793,7 @@ void update_menu(HWND hWnd, HMENU hMenu, int pos)
                                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;
@@ -1917,7 +1917,7 @@ void open_cart_dialog(HWND hWnd, int drv)
        );
        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);
        }
 }
@@ -1934,7 +1934,7 @@ void open_disk_dialog(HWND hWnd, int drv)
        );
        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);
        }
 }
@@ -1965,7 +1965,7 @@ void open_disk(int drv, const _TCHAR* path, int bank)
                                        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;
@@ -2002,7 +2002,7 @@ void open_quickdisk_dialog(HWND hWnd, int drv)
        );
        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);
        }
 }
@@ -2038,7 +2038,7 @@ void open_tape_dialog(HWND hWnd, bool play)
        );
        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 {
@@ -2059,7 +2059,7 @@ void open_laser_disc_dialog(HWND hWnd)
        );
        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);
        }
 }
@@ -2080,7 +2080,7 @@ void open_binary_dialog(HWND hWnd, int drv, bool load)
        );
        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 {
@@ -2103,7 +2103,7 @@ void open_any_file(const _TCHAR* path)
           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;
        }
@@ -2125,7 +2125,7 @@ void open_any_file(const _TCHAR* path)
           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;
        }
@@ -2145,7 +2145,7 @@ void open_any_file(const _TCHAR* path)
           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;
        }
@@ -2155,7 +2155,7 @@ void open_any_file(const _TCHAR* path)
           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;
        }