OSDN Git Service

[Qt][X1][General] Fix FILEIO::IsFileExists(). Fixed non-start X1 series when not...
authorK.Ohta <whatisthis.sowhat@gmail.com>
Thu, 10 Dec 2015 07:41:44 +0000 (16:41 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Thu, 10 Dec 2015 07:41:44 +0000 (16:41 +0900)
source/src/common.cpp
source/src/common.h
source/src/emu.cpp
source/src/emu.h
source/src/fileio.cpp
source/src/fileio.h
source/src/vm/x1/iobus.cpp
source/src/vm/x1/psub.cpp
source/src/vm/x1/x1.cpp
source/src/vm/x1/x1.h

index 67e210c..14b5dd3 100644 (file)
@@ -20,7 +20,7 @@
 #include "common.h"
 #endif
 
-#ifdef MAX_MACRO_NOT_DEFINED
+#if defined(MAX_MACRO_NOT_DEFINED)
 int max(int a, int b)
 {
        if(a > b) {
@@ -60,6 +60,7 @@ 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)
 //{
@@ -82,11 +83,25 @@ errno_t my_tcscpy_s(_TCHAR *strDestination, size_t numberOfElements, const _TCHA
        return 0;
 }
 
+char *my_strtok_s(char *strToken, const char *strDelimit, char **context)
+{
+       return strtok(strToken, strDelimit);
+}
+
 _TCHAR *my_tcstok_s(_TCHAR *strToken, const char *strDelimit, _TCHAR **context)
 {
        return _tcstok(strToken, strDelimit);
 }
 
+int my_sprintf_s(char *buffer, size_t sizeOfBuffer, const char *format, ...)
+{
+       va_list ap;
+       va_start(ap, format);
+       int result = vsprintf(buffer, format, ap);
+       va_end(ap);
+       return result;
+}
+
 int my_stprintf_s(_TCHAR *buffer, size_t sizeOfBuffer, const _TCHAR *format, ...)
 {
        va_list ap;
@@ -96,6 +111,11 @@ int my_stprintf_s(_TCHAR *buffer, size_t sizeOfBuffer, const _TCHAR *format, ...
        return result;
 }
 
+int my_vsprintf_s(char *buffer, size_t numberOfElements, const char *format, va_list argptr)
+{
+       return vsprintf(buffer, format, argptr);
+}
+
 int my_vstprintf_s(_TCHAR *buffer, size_t numberOfElements, const _TCHAR *format, va_list argptr)
 {
        return _vstprintf(buffer, format, argptr);
@@ -105,36 +125,95 @@ int my_vstprintf_s(_TCHAR *buffer, size_t numberOfElements, const _TCHAR *format
 #if !defined(_MSC_VER) && !defined(CSP_OS_WINDOWS)
 BOOL MyWritePrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpString, LPCTSTR lpFileName)
 {
-       std::string s;
-       std::string v;
-       char app_path2[_MAX_PATH], *ptr;
-       FILEIO *path = new FILEIO;
-   
-       if((lpKeyName == NULL) || (lpAppName == NULL) || (lpFileName == NULL)) {
-               delete path;
-               return FALSE;
-       }
-       if(path->Fopen(lpFileName, FILEIO_WRITE_APPEND_ASCII) != true) {
-               delete path;
-               return FALSE;
-       }
-       
-       if(lpString == NULL) {
-               v = "";
+//     std::string s;
+//     std::string v;
+//     char app_path2[_MAX_PATH], *ptr;
+//     FILEIO *path = new FILEIO;
+       BOOL result = FALSE;
+       FILEIO* fio_i = new FILEIO();
+       if(fio_i->Fopen(lpFileName, FILEIO_READ_ASCII)) {
+               char tmp_path[_MAX_PATH];
+               my_sprintf_s(tmp_path, _MAX_PATH, "%s.$$$", lpFileName);
+               FILEIO* fio_o = new FILEIO();
+               if(fio_o->Fopen(tmp_path, FILEIO_WRITE_ASCII)) {
+                       bool in_section = false;
+                       char section[1024], line[1024], *equal;
+                       my_sprintf_s(section, 1024, "[%s]", lpAppName);
+                       while(fio_i->Fgets(line, 1024) != NULL && strlen(line) > 0) {
+                               if(line[strlen(line) - 1] == '\n') {
+                                       line[strlen(line) - 1] = '\0';
+                               }
+                               if(!result) {
+                                       if(line[0] == '[') {
+                                               if(in_section) {
+                                                       fio_o->Fprintf("%s=%s\n", lpKeyName, lpString);
+                                                       result = TRUE;
+                                               } else if(strcmp(line, section) == 0) {
+                                                       in_section = true;
+                                               }
+                                       } else if(in_section && (equal = strstr(line, "=")) != NULL) {
+                                               *equal = '\0';
+                                               if(strcmp(line, lpKeyName) == 0) {
+                                                       fio_o->Fprintf("%s=%s\n", lpKeyName, lpString);
+                                                       result = TRUE;
+                                                       continue;
+                                               }
+                                               *equal = '=';
+                                       }
+                               }
+                               fio_o->Fprintf("%s\n", line);
+                       }
+                       if(!result) {
+                               if(!in_section) {
+                                       fio_o->Fprintf("[%s]\n", lpAppName);
+                               }
+                               fio_o->Fprintf("%s=%s\n", lpKeyName, lpString);
+                               result = TRUE;
+                       }
+                       fio_o->Fclose();
+               }
+               delete fio_o;
+               fio_i->Fclose();
+               if(result) {
+                       if(!(FILEIO::RemoveFile(lpFileName) && FILEIO::RenameFile(tmp_path, lpFileName))) {
+                               result = FALSE;
+                       }
+               }
        } else {
-               v = lpString;
+               FILEIO* fio_o = new FILEIO();
+               if(fio_o->Fopen(lpFileName, FILEIO_WRITE_ASCII)) {
+                       fio_o->Fprintf("[%s]\n", lpAppName);
+                       fio_o->Fprintf("%s=%s\n", lpKeyName, lpString);
+                       fio_o->Fclose();
+               }
+               delete fio_o;
        }
-       s = lpAppName;
-       s.append(".");
-       s.append(lpKeyName);
-       s.append("=");
-       s.append(v);
-       s.append("\n");
-       path->Fwrite((void *)s.c_str(), s.length(), 1);
-       path->Fclose();
-       delete path;
-       return TRUE;
-       // write your compatible function, if possible in standard C/C++ code
+       delete fio_i;
+       return result;
+//     if((lpKeyName == NULL) || (lpAppName == NULL) || (lpFileName == NULL)) {
+//             delete path;
+//             return FALSE;
+//     }
+//     if(path->Fopen(lpFileName, FILEIO_WRITE_APPEND_ASCII) != true) {
+//             delete path;
+//             return FALSE;
+//     }
+//     
+//     if(lpString == NULL) {
+//             v = "";
+//     } else {
+//             v = lpString;
+//     }
+//     s = lpAppName;
+//     s.append(".");
+//     s.append(lpKeyName);
+//     s.append("=");
+//     s.append(v);
+//     s.append("\n");
+//     path->Fwrite((void *)s.c_str(), s.length(), 1);
+//     path->Fclose();
+//     delete path;
+//     return TRUE;
 }
 
 static std::string MyGetPrivateProfileStr(const _TCHAR *lpAppName, const _TCHAR *lpKeyName, _TCHAR *lpFileName)
@@ -195,13 +274,45 @@ static std::string MyGetPrivateProfileStr(const _TCHAR *lpAppName, const _TCHAR
 
 DWORD MyGetPrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpDefault, LPCTSTR lpReturnedString, DWORD nSize, LPCTSTR lpFileName)
 {
-       std::string sp = MyGetPrivateProfileStr(lpAppName, lpKeyName, lpFileName);
-       if((!sp.empty()) && (nSize > 1)){
-               strncpy(lpReturnedString, sp.c_str(), nSize);
+       if(lpDefault != NULL) {
+               my_strcpy_s(lpReturnedString, nSize, lpDefault);
        } else {
-               strncpy(lpReturnedString, lpDefault, nSize);
+               lpReturnedString[0] = '\0';
+       }
+       FILEIO* fio = new FILEIO();
+       if(fio->Fopen(lpFileName, FILEIO_READ_ASCII)) {
+               bool in_section = false;
+               char section[1024], line[1024], *equal;
+               my_sprintf_s(section, 1024, "[%s]", lpAppName);
+               while(fio->Fgets(line, 1024) != NULL && strlen(line) > 0) {
+                       if(line[strlen(line) - 1] == '\n') {
+                               line[strlen(line) - 1] = '\0';
+                       }
+                       if(line[0] == '[') {
+                               if(in_section) {
+                                       break;
+                               } else if(strcmp(line, section) == 0) {
+                                       in_section = true;
+                               }
+                       } else if(in_section && (equal = strstr(line, "=")) != NULL) {
+                               *equal = '\0';
+                               if(strcmp(line, lpKeyName) == 0) {
+                                       my_strcpy_s(lpReturnedString, nSize, equal + 1);
+                                       break;
+                               }
+                       }
+               }
+               fio->Fclose();
        }
-       return  strlen(lpReturnedString);
+       delete fio;
+       return strlen(lpReturnedString);
+//     std::string sp = MyGetPrivateProfileStr(lpAppName, lpKeyName, lpFileName);
+//     if((!sp.empty()) && (nSize > 1)){
+//             strncpy(lpReturnedString, sp.c_str(), nSize);
+//     } else {
+//             strncpy(lpReturnedString, lpDefault, nSize);
+//     }
+//     return  strlen(lpReturnedString);
 }
 
 UINT MyGetPrivateProfileInt(LPCTSTR lpAppName, LPCTSTR lpKeyName, INT nDefault, LPCTSTR lpFileName)
index cc555ab..4372a02 100644 (file)
 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
 #define SUPPORT_SECURE_FUNCTIONS
 #endif
+
 #ifdef SUPPORT_TCHAR_TYPE
- #include <tchar.h>
+#include <tchar.h>
 #endif
 #include <stdio.h>
+#include <stdlib.h>
 #include <errno.h>
 
 #if defined(_MSC_VER)
 
 // type definition
 #ifndef uint8
-typedef unsigned char uint8;
+ typedef unsigned char uint8;
 #endif
 #ifndef uint16
-typedef unsigned short uint16;
+ typedef unsigned short uint16;
 #endif
 #ifndef uint32
-typedef unsigned int uint32;
+ typedef unsigned int uint32;
 #endif
 #ifndef uint64
-#ifdef _MSC_VER
-typedef unsigned __int64 uint64;
-#else
+ #ifdef _MSC_VER
+ typedef unsigned __int64 uint64;
+ #else
 //typedef unsigned long long uint64;
-#endif
+ #endif
 #endif
 #ifndef int8
-typedef signed char int8;
+ typedef signed char int8;
 #endif
 #ifndef int16
-typedef signed short int16;
+ typedef signed short int16;
 #endif
 #ifndef int32
-typedef signed int int32;
+ typedef signed int int32;
 #endif
 #ifndef int64
-#ifdef _MSC_VER
-typedef signed __int64 int64;
-#else
-//typedef signed long long int64;
-#endif
+ #ifdef _MSC_VER
+  typedef signed __int64 int64;
+ #else
+ //typedef signed long long int64;
+ #endif
 #endif
 
 #if defined(__LITTLE_ENDIAN__)
@@ -213,17 +215,22 @@ typedef union {
 } pair;
 
 // max/min from WinDef.h
-#ifndef max
+#ifndef _MSC_VER
+       #undef max
+       #undef min
        #define MAX_MACRO_NOT_DEFINED
        int max(int a, int b);
        unsigned int max(unsigned int a, unsigned int b);
-#endif
-#ifndef min
        #define MIN_MACRO_NOT_DEFINED
        int min(int a, int b);
        unsigned int min(unsigned int a, unsigned int b);
 #endif
 
+//#if defined(__GNUC__) || defined(__CYGWIN__) || defined(Q_OS_CYGWIN)
+//     #define stricmp(a,b) strcasecmp(a,b)
+//     #define strnicmp(a,b,n) strncasecmp(a,b,n)
+//#endif
+
 // _TCHAR
 #ifndef SUPPORT_TCHAR_TYPE
        #ifndef _tfopen
@@ -274,12 +281,14 @@ typedef union {
        #ifndef _tremove
                #define _tremove remove
        #endif
+       #ifndef _trename
+               #define _trename rename
+       #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;
@@ -287,18 +296,27 @@ typedef union {
 //     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);
+       char *my_strtok_s(char *strToken, const char *strDelimit, char **context);
        _TCHAR *my_tcstok_s(_TCHAR *strToken, const char *strDelimit, _TCHAR **context);
-       int my_stprintf_s(_TCHAR *buffer, size_t sizeOfBuffer, const _TCHAR *format, ...);
+       #define my_fprintf_s fprintf
+       int my_sprintf_s(char *buffer, size_t sizeOfBuffer, const char *format, ...);
+       int my_stprintf_s(_TCHAR *buffer, size_t sizeOfBuffer, const _TCHAR *format, ...);
+       int my_vsprintf_s(char *buffer, size_t numberOfElements, const char *format, va_list argptr);
        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_strtok_s strtok_s
        #define my_tcstok_s _tcstok_s
+       #define my_fprintf_s fprintf_s
+       #define my_sprintf_s sprintf_s
        #define my_stprintf_s _stprintf_s
+       #define my_vsprintf_s vsprintf_s
        #define my_vstprintf_s _vstprintf_s
 #endif
 
+// ini file parser
 #if!defined(_MSC_VER) && !defined(CSP_OS_WINDOWS)
        BOOL MyWritePrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpString, LPCTSTR lpFileName);
        DWORD MyGetPrivateProfileString(LPCTSTR lpAppName, LPCTSTR lpKeyName, LPCTSTR lpDefault, LPCTSTR lpReturnedString, DWORD nSize, LPCTSTR lpFileName);
@@ -309,6 +327,12 @@ typedef union {
        #define MyGetPrivateProfileInt GetPrivateProfileInt
 #endif
 
+// win32 api
+#ifndef _MSC_VER
+       #define ZeroMemory(p,s) memset(p,0x00,s)
+       #define CopyMemory(t,f,s) memcpy(t,f,s)
+#endif
+
 // rgb color
 #define _RGB888
 
@@ -346,6 +370,12 @@ typedef union {
 #endif  // ENDIAN
 
 
+// string
+#if defined(__GNUC__) || defined(__CYGWIN__) || defined(Q_OS_CYGWIN)
+       #define stricmp(a,b) strcasecmp(a,b)
+       #define strnicmp(a,b,n) strncasecmp(a,b,n)
+#endif
+
 // _TCHAR
 #ifndef SUPPORT_TCHAR_TYPE
        typedef char _TCHAR;
index 41c5d31..7a78fce 100644 (file)
@@ -110,19 +110,21 @@ EMU::EMU()
 #ifdef USE_SOUND_DEVICE_TYPE
        sound_device_type = config.sound_device_type;
 #endif
-       
        osd = new OSD();
-
-#if defined(OSD_WIN32) || defined(_USE_QT)
+#if defined(_USE_QT)
        osd->main_window_handle = hwnd;
        osd->glv = hinst;
 #endif 
        osd->initialize(sound_rate, sound_samples);
+       osd->lock_vm();
        osd->vm = vm = new VM(this);
        
        initialize_media();
+       osd->initialize_printer();
        vm->initialize_sound(sound_rate, sound_samples);
        vm->reset();
+       osd->unlock_vm();
+       
        now_suspended = false;
 }
 
@@ -157,7 +159,7 @@ int EMU::frame_interval()
        return (int)(1024. * 1000. / FRAMES_PER_SEC + 0.5);
 #endif
 #else
-        return (int)(1024. * 1000. / FRAMES_PER_SEC + 0.5);
+       return (int)(1024. * 1000. / FRAMES_PER_SEC + 0.5);
 #endif
 }
 
@@ -167,7 +169,6 @@ int EMU::run()
                osd->restore();
                now_suspended = false;
        }
-       //LockVM();
        osd->update_input();
        osd->update_printer();
 #ifdef USE_SOCKET
@@ -178,13 +179,12 @@ int EMU::run()
        // virtual machine may be driven to fill sound buffer
        int extra_frames = 0;
        osd->update_sound(&extra_frames);
-       
        // drive virtual machine
        if(extra_frames == 0) {
-               lock_vm();
+               osd->lock_vm();
                vm->run();
                extra_frames = 1;
-               unlock_vm();
+               osd->unlock_vm();
        }
        osd->add_extra_frames(extra_frames);
        return extra_frames;
@@ -206,19 +206,19 @@ void EMU::reset()
                // stop sound
                osd->stop_sound();
                // reinitialize virtual machine
-               lock_vm();              
+               osd->lock_vm();         
                delete vm;
                osd->vm = vm = new VM(this);
                vm->initialize_sound(sound_rate, sound_samples);
                vm->reset();
-               unlock_vm();
+               osd->unlock_vm();
                // restore inserted medias
                restore_media();
        } else {
           // reset virtual machine
-               lock_vm();              
+               osd->lock_vm();         
                vm->reset();
-               unlock_vm();            
+               osd->unlock_vm();               
        }
        
        // reset printer
@@ -235,9 +235,9 @@ void EMU::reset()
 void EMU::special_reset()
 {
        // reset virtual machine
-       lock_vm();              
+       osd->lock_vm();         
        vm->special_reset();
-       unlock_vm();
+       osd->unlock_vm();
        // reset printer
        osd->reset_printer();
        
@@ -269,6 +269,16 @@ void EMU::suspend()
        }
 }
 
+void EMU::lock_vm()
+{
+       osd->lock_vm();
+}
+
+void EMU::unlock_vm()
+{
+       osd->unlock_vm();
+}
+
 // ----------------------------------------------------------------------------
 // input
 // ----------------------------------------------------------------------------
@@ -1258,7 +1268,7 @@ void EMU::load_state()
 void EMU::save_state_tmp(const _TCHAR* file_path)
 {
        FILEIO* fio = new FILEIO();
-       lock_vm();
+       osd->lock_vm();
        if(fio->Fopen(file_path, FILEIO_WRITE_BINARY)) {
                // save state file version
                fio->FputUint32(STATE_VERSION);
@@ -1287,7 +1297,7 @@ void EMU::save_state_tmp(const _TCHAR* file_path)
                fio->FputInt32(-1);
                fio->Fclose();
        }
-       unlock_vm();
+       osd->unlock_vm();
        delete fio;
 }
 
@@ -1329,14 +1339,14 @@ bool EMU::load_state_tmp(const _TCHAR* file_path)
 #endif
                                if(reinitialize) {
                                        // stop sound
-                                       lock_vm();
+                                       osd->lock_vm();
                                        // reinitialize virtual machine
                                        osd->stop_sound();
                                        delete vm;
                                        osd->vm = vm = new VM(this);
                                        vm->initialize_sound(sound_rate, sound_samples);
                                        vm->reset();
-                                       unlock_vm();
+                                       osd->unlock_vm();
                                }
                                // restore inserted medias
                                restore_media();
@@ -1349,6 +1359,7 @@ bool EMU::load_state_tmp(const _TCHAR* file_path)
                }
                fio->Fclose();
        }
+       osd->unlock_vm();
        delete fio;
        return result;
 }
index daeef41..9149b6e 100644 (file)
@@ -433,12 +433,14 @@ public:
 #if defined(USE_DIG_RESOLUTION)
        void get_screen_resolution(int *w, int *h);
 #endif
-       void lock_vm(void) {
-               osd->lock_vm();
-       }
-       void unlock_vm(void) {
-               osd->unlock_vm();
-       }
+       void lock_vm(void);
+       void unlock_vm(void);
+       //{
+       //      osd->lock_vm();
+       //}
+       //void unlock_vm(void) {
+       //      osd->unlock_vm();
+       //}
        void update_config();
        // state
 #ifdef USE_STATE
index 3c869ca..cdb9d4b 100644 (file)
@@ -10,6 +10,7 @@
 #include "fileio.h"
 #if !defined(MSC_VER)
 #include <stdarg.h>
+#include <fcntl.h>
 #include <stdio.h>
 #include <iostream>
 #include <fstream>
@@ -29,9 +30,12 @@ FILEIO::~FILEIO(void)
 bool FILEIO::IsFileExists(const _TCHAR *file_path)
 {
 #if defined(_USE_QT) || defined(_USE_SDL)
-       std::FILE *f;
-       f = std::fopen(file_path, "r");
-       if(f >= 0)  return true;
+       FILE *f;
+       f = fopen(file_path, "r");
+       if(f != NULL)  {
+               fclose(f);         
+               return true;
+       }
        return false;
 #else   
 # ifdef _MSC_VER
@@ -41,7 +45,7 @@ bool FILEIO::IsFileExists(const _TCHAR *file_path)
        }
        return ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0);
 # else
-       return (_taccess(file_path, 0) == 0);   // not supported on wince ???
+       return (_taccess(file_path, 0) == 0);
 # endif
 #endif
 }
@@ -62,24 +66,37 @@ bool FILEIO::IsFileProtected(const _TCHAR *file_path)
 # ifdef _MSC_VER
        return ((GetFileAttributes(file_path) & FILE_ATTRIBUTE_READONLY) != 0);
 # else
-       return (_taccess(file_path, 2) != 0);   // not supported on wince ???
+       return (_taccess(file_path, 2) != 0);
 # endif
 #endif
 }
 
-void FILEIO::RemoveFile(const _TCHAR *file_path)
+bool FILEIO::RemoveFile(const _TCHAR *file_path)
 {
 #if defined(_USE_QT) || defined(_USE_SDL)
-       std::remove(file_path);
+       return (remove(file_path) == 0);
 #else
 # ifdef _MSC_VER
-       DeleteFile(file_path);
+       return (DeleteFile(file_path) != 0);
 # else
-       _tremove(file_path);    // not supported on wince ???
+       return (_tremove(file_path) == 0);      // not supported on wince ???
 # endif
 #endif
 }
 
+bool FILEIO::RenameFile(const _TCHAR *existing_file_path, const _TCHAR *new_file_path)
+{
+#if defined(_USE_QT)
+       return (rename(existing_file_path, new_file_path) == 0);
+       #else
+               #ifdef _MSC_VER
+                       return (MoveFile(existing_file_path, new_file_path) != 0);
+               #else
+                       return (_trename(existing_file_path, new_file_path) == 0);
+               #endif
+#endif                 
+}
+
 bool FILEIO::Fopen(const _TCHAR *file_path, int mode)
 {
        Fclose();
@@ -557,18 +574,10 @@ int FILEIO::Fprintf(const char* format, ...)
        char buffer[1024];
        
        va_start(ap, format);
-#if defined(MSC_VER)
-       vsprintf_s(buffer, 1024, format, ap);
-#else
-       vsnprintf(buffer, 1024, format, ap);
-#endif 
+       my_vsprintf_s(buffer, 1024, format, ap);
        va_end(ap);
        
-#if defined(MSC_VER)
-       return fprintf_s(fp, "%s", buffer);
-#else
-       return fprintf(fp, "%s", buffer);
-#endif
+       return my_fprintf_s(fp, "%s", buffer);
 }
 
 uint32 FILEIO::Fread(void* buffer, uint32 size, uint32 count)
index 41bd0c4..bab98db 100644 (file)
@@ -46,7 +46,8 @@ public:
 
        static bool IsFileExists(const _TCHAR *file_path);
        static bool IsFileProtected(const _TCHAR *file_path);
-       static void RemoveFile(const _TCHAR *file_path);
+       static bool RemoveFile(const _TCHAR *file_path);
+       static bool FILEIO::RenameFile(const _TCHAR *existing_file_path, const _TCHAR *new_file_path);
 
        bool Fopen(const _TCHAR *file_path, int mode);
        void Fclose();
index 60a6cf4..dbed9d9 100644 (file)
@@ -125,6 +125,7 @@ void IOBUS::write_port8(uint32 addr, uint32 data, bool is_dma, int* wait)
                hireso = (vt_total > 400);
        }
 #endif
+       //printf("IO WRITE:%04x %02x CPU_PC=%04x\n", addr, data & 0xff, d_cpu->get_pc());
        if(is_dma) {
                d_io->write_dma_io8(addr, data & 0xff);
        } else {
@@ -165,6 +166,7 @@ uint32 IOBUS::read_port8(uint32 addr, bool is_dma, int* wait)
                }
                vdisp = val;
        }
+       //printf("IO READ:%04x %02x CPU_PC=%04x\n", addr, val, d_cpu->get_pc());
        switch(addr & 0xff00) {
        case 0x1900:    // sub cpu
        case 0x1b00:    // psg
index 57586b8..18e213d 100644 (file)
@@ -139,6 +139,42 @@ static const uint8 keycode_ks[256] = {     // kana+shift
        0x00, 0x00, 0xdb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 };
+static const uint8 keycode_kb[256] = { // kana (mode b)
+       0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x08, 0x09, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0xe8, 0x00, 0x00, 0x00,
+       0x20, 0x0e, 0x0f, 0x11, 0x0b, 0x1d, 0x1e, 0x1c, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x12, 0x08, 0x00,
+       0xc9, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xc5, 0xc6, 0xc7, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0xbb, 0xc4, 0xc2, 0xbd, 0xb8, 0xbe, 0xbf, 0xcf, 0xcc, 0xd0, 0xd1, 0xd2, 0xd5, 0xd4, 0xcd,
+       0xce, 0xb6, 0xb9, 0xbc, 0xba, 0xcb, 0xc3, 0xb7, 0xc1, 0xca, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2a, 0x2b, 0xc8, 0x2d, 0x2e, 0xd2,
+       0x71, 0x72, 0x73, 0x74, 0x75, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xde, 0xd3, 0xd6, 0xd7, 0xdc, 0xa6,
+       0xda, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdb, 0xd9, 0xdf, 0xd8, 0x00,
+       0x00, 0x00, 0xdd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+static const uint8 keycode_ksb[256] = {        // kana+shift (mode b)
+       0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x12, 0x09, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0xe8, 0x00, 0x00, 0x00,
+       0x20, 0x0e, 0x0f, 0x11, 0x0c, 0x1d, 0x1e, 0x1c, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x12, 0x08, 0x00,
+       0xc9, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xc5, 0xc6, 0xc7, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0xbb, 0xc4, 0xaf, 0xbd, 0xb8, 0xbe, 0xbf, 0xcf, 0xcc, 0xd0, 0xd1, 0xd2, 0xad, 0xac, 0xcd,
+       0xce, 0xb6, 0xb9, 0xbc, 0xba, 0xcb, 0xc3, 0xb7, 0xc1, 0xca, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2a, 0x2b, 0xa4, 0x2d, 0x2e, 0xa5,
+       0x76, 0x77, 0x78, 0x79, 0x7a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0xd3, 0xae, 0xd7, 0xa4, 0xa1,
+       0xda, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa2, 0x20, 0xa3, 0xd8, 0x00,
+       0x00, 0x00, 0xa5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
 
 void PSUB::initialize()
 {
@@ -745,8 +781,18 @@ uint16 PSUB::get_key(int code, bool repeat)
        }
        if(key_kana_locked) {
                if(!(l & 0x02)) {
+#ifdef _X1TURBO_FEATURE
+                       if(config.device_type != 0) {
+                               h = keycode_ksb[code];  // kana+shift (mode b)
+                       } else
+#endif
                        h = keycode_ks[code];   // kana+shift
                } else {
+#ifdef _X1TURBO_FEATURE
+                       if(config.device_type != 0) {
+                               h = keycode_kb[code];   // kana (mode b)
+                       } else
+#endif
                        h = keycode_k[code];    // kana
                }
        } else {
index 8ab221d..2610bf3 100644 (file)
@@ -153,7 +153,11 @@ VM::VM(EMU* parent_emu) : emu(parent_emu)
 //     sio->set_rx_clock(0, 9600 * 16);        // clock is from Z-80CTC ch1 (2MHz/13)
 //     sio->set_tx_clock(1, 4800 * 16);        // 4800 baud for mouse
 //     sio->set_rx_clock(1, 4800 * 16);        // clock is from Z-80CTC ch2 (2MHz/26)
-
+       //event->register_frame_event(crtc);
+       //event->register_vline_event(crtc);
+       //event->register_frame_event(display);
+       //event->register_vline_event(display);
+   
        if(sound_device_type >= 1) {
                ctc1->set_context_zc0(ctc1, SIG_Z80CTC_TRIG_3, 1);
 //             ctc1->set_constant_clock(1, CPU_CLOCKS >> 1);
@@ -328,7 +332,7 @@ VM::VM(EMU* parent_emu) : emu(parent_emu)
        io->set_iomap_single_w(0x1fe0, display);
 #endif
        // 0x1ff0: dipswitch
-//     io->set_iovalue_single_r(0x1ff0, 0x00);
+       //io->set_iovalue_single_r(0x1ff0, 0x00);
        update_dipswitch();
 #endif
        io->set_iomap_range_rw(0x2000, 0x3fff, display);        // tvram
index 71dedf6..f44b463 100644 (file)
 #endif
 
 // device informations for virtual machine (x1)
-//#ifdef _X1TURBO_FEATURE
+#ifdef _X1TURBO_FEATURE
 //24KHz
-//#define FRAMES_PER_SEC       55.49
-//#define LINES_PER_FRAME      448
-//#define CHARS_PER_LINE       56
-//#define HD46505_HORIZ_FREQ   24860
-//#else
+#define FRAMES_PER_SEC 55.49
+#define LINES_PER_FRAME        448
+#define CHARS_PER_LINE 56
+#define HD46505_HORIZ_FREQ     24860
+#else
 // 15KHz
 #define FRAMES_PER_SEC         61.94
 #define LINES_PER_FRAME        258
 #define CHARS_PER_LINE         56
 #define HD46505_HORIZ_FREQ     15980
-//#endif
+#endif
 #define CPU_CLOCKS             4000000
 #define SCREEN_WIDTH           640
 #define SCREEN_HEIGHT          400