OSDN Git Service

[Build][Qt] Build passed, and start okay, but don't display, something wrongs :-(
authorK.Ohta <whatisthis.sowhat@gmail.com>
Sun, 11 Jan 2015 19:36:12 +0000 (04:36 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Sun, 11 Jan 2015 19:36:12 +0000 (04:36 +0900)
31 files changed:
source/build-cmake/cmake/config_commonsource.cmake
source/build-cmake/cmake/simd-x86.cmake
source/build-cmake/x1turboz/CMakeLists.txt
source/src/common.h
source/src/config.cpp
source/src/emu.h
source/src/fileio.cpp
source/src/qt/common/CMakeLists.txt
source/src/qt/common/emu_utils.cpp
source/src/qt/common/emu_utils.h
source/src/qt/common/qt_debugger.cpp [new file with mode: 0644]
source/src/qt/common/qt_dialogs.cpp
source/src/qt/common/qt_dialogs.h
source/src/qt/common/qt_gldraw.cpp
source/src/qt/common/qt_gldraw.h
source/src/qt/common/qt_glutil.cpp
source/src/qt/common/qt_input.cpp [new file with mode: 0644]
source/src/qt/common/qt_input.h [new file with mode: 0644]
source/src/qt/common/qt_main.cpp
source/src/qt/common/qt_main.h
source/src/qt/common/qt_screen.cpp
source/src/qt/gui/menu_control.cpp
source/src/qt/x1turboz/MainWindow.cpp
source/src/qt/x1turboz/menuclasses.h
source/src/vm/datarec.h
source/src/vm/fmgen/file.cpp
source/src/vm/fmgen/headers.h
source/src/vm/fmgen/opna.cpp
source/src/vm/fmgen/opna.h
source/src/vm/fmgen/psg.h
source/src/vm/z80.h

index 6b92010..3b4726c 100644 (file)
@@ -6,7 +6,7 @@
 include(CheckFunctionExists)
 
 
-FIND_PACKAGE(Qt4 REQUIRED)
+FIND_PACKAGE(Qt4 REQUIRED QtCore QtGui QtOpenGL )
 INCLUDE(${QT_USE_FILE})
 
 add_definitions(-D_USE_QT)
index 729a19a..98c5b32 100644 (file)
@@ -13,10 +13,10 @@ endif()
 
 
 if(USE_SSE2)
- set(LOCAL_LIBS ${LOCAL_LIBS} common_scaler-sse2)
+# set(LOCAL_LIBS ${LOCAL_LIBS} common_scaler-sse2)
  add_definitions(-DUSE_SSE2)
 # add_subdirectory(sdl/vram/sse2)
- add_subdirectory(../../src/agar/common/scaler/sse2 agar/common/scaler/sse2)
+# add_subdirectory(../../src/agar/common/scaler/sse2 agar/common/scaler/sse2)
 endif()
 
 #if(USE_SSE)
index 9fef829..bc9271d 100644 (file)
@@ -21,10 +21,9 @@ set(LOCAL_LIBS          vm_x1
                   vm_vm
                   common_common
                   vm_fmgen
-                  common_scaler-generic
-                  qt_common
-                  qt_gui
+#                 common_scaler-generic
                   qt_x1turboz
+                  qt_gui
                    )
 
 set(VMFILES
@@ -98,7 +97,7 @@ add_subdirectory(../../src/vm/fmgen vm/fmgen)
 add_subdirectory(../../src/qt/x1turboz qt/x1turboz)
 
 set(BUNDLE_LIBS 
-                          ${OPENGL_LIBRARY}
+                           ${OPENGL_LIBRARY}
                           ${OPENCL_LIBRARY}
                           ${GETTEXT_LIBRARY}
                           ${OPENMP_LIBRARY}
index 546aa6b..58158b7 100644 (file)
@@ -194,8 +194,8 @@ static inline WORD EndianToLittle_WORD(WORD x)
 extern "C" \r
 {\r
 #endif\r
-extern void Sleep(int tick);\r
-extern uint32_t timeGetTime(void);\r
+//extern void Sleep(uint32_t tick);\r
+//extern uint32_t timeGetTime(void);\r
 #ifdef __cplusplus\r
 }\r
 #endif\r
@@ -301,7 +301,7 @@ typedef union {
 //#define _RGB888\r
 #define _RGBA888\r
 \r
-#if defined(_USE_SDL) || defined(_USE_AGAR)\r
+#if defined(_USE_AGAR)\r
 \r
 # if AG_BYTEORDER == AG_BIG_ENDIAN\r
 # if defined(_RGB555)\r
@@ -350,7 +350,7 @@ typedef uint16 scrntype;
 #define RGB_COLOR(r, g, b) (((uint32)(r) << 16) | ((uint32)(g) << 8) | ((uint32)(b) << 0))\r
 typedef uint32 scrntype;\r
 #elif defined(_RGBA888)\r
-#define RGBA_COLOR(r, g, b) (((uint32)(r) << 16) | ((uint32)(g) << 8) | ((uint32)(b) << 0)) | ((uint32)0xff << 24)\r
+#define RGB_COLOR(r, g, b) (((uint32)(r) << 16) | ((uint32)(g) << 8) | ((uint32)(b) << 0)) | ((uint32)0xff << 24)\r
 typedef uint32 scrntype;\r
 #endif\r
 \r
index 7a425a2..e99fddf 100644 (file)
@@ -335,7 +335,7 @@ void load_config()
 #ifdef USE_SOUND_DEVICE_TYPE\r
        config.sound_device_type = GetPrivateProfileInt(_T("Sound"), _T("DeviceType"), config.sound_device_type, config_path);\r
 #endif\r
-       GetPrivateProfileString(_T("Sound"), _T("FMGenDll"), _T("mamefm.dll"), config.fmgen_dll_path, _MAX_PATH, config_path);\r
+//     GetPrivateProfileString(_T("Sound"), _T("FMGenDll"), _T("mamefm.dll"), config.fmgen_dll_path, _MAX_PATH, config_path);\r
 \r
 #if defined(_USE_AGAR) || defined(_USE_QT)\r
      config_path->Fclose();\r
index 961db3d..5fba1e8 100644 (file)
@@ -38,6 +38,7 @@
 # include <SDL/SDL.h>\r
 # include "menuclasses.h"\r
 # include "qt_gldraw.h"\r
+# include "emu_utils.h"\r
 # include "qt_main.h"\r
 # include "simd_types.h"\r
 // Wrapper of WIN32->*nix\r
 \r
 #if defined(_USE_AGAR)\r
 #include "agar_input.h"\r
+#elif defined(_USE_QT)\r
+#include "qt_input.h"\r
+#endif\r
 \r
-#elit defined(_USE_QT)\r
-\r
+#if defined(_USE_AGAR) || defined(_USE_QT)\r
 # define WM_RESIZE  1\r
 #define WM_SOCKET0 2\r
 #define WM_SOCKET1 3\r
index 6226570..23058c4 100644 (file)
@@ -76,37 +76,38 @@ bool FILEIO::Fopen(_TCHAR *filename, int mode)
           fp->close();\r
        }\r
         fp = new QFile((const char *)filename);\r
-        int open_mode;\r
+        QIODevice::OpenMode open_mode;\r
        switch(mode) {\r
        case FILEIO_READ_BINARY:\r
-               mode = IO_ReadOnly;\r
+               open_mode = QIODevice::ReadOnly;\r
                break;\r
        case FILEIO_WRITE_BINARY:\r
-               mode = IO_WriteOnly;\r
+               open_mode = QIODevice::WriteOnly;\r
                break;\r
        case FILEIO_READ_WRITE_BINARY:\r
-               mode = IO_ReadWrite;\r
+               open_mode = QIODevice::ReadWrite;\r
                break;\r
        case FILEIO_READ_WRITE_NEW_BINARY:\r
-               mode = IO_ReadWrite;\r
+               open_mode = QIODevice::ReadWrite;\r
                break;\r
        case FILEIO_READ_ASCII:\r
-               mode = IO_ReadOnly | IO_Translate;\r
+               open_mode = QIODevice::ReadOnly;\r
                break;\r
        case FILEIO_WRITE_ASCII:\r
-               mode = IO_WriteOnly | IO_Translate;\r
+               open_mode = QIODevice::WriteOnly;\r
                break;\r
        case FILEIO_READ_WRITE_ASCII:\r
-               mode = IO_ReadWrite | IO_Translate;\r
+               open_mode = QIODevice::ReadWrite;\r
                break;\r
        case FILEIO_READ_WRITE_NEW_ASCII:\r
-               mode = IO_ReadWrite | IO_Translate;\r
+               open_mode = QIODevice::ReadWrite;\r
                break;\r
         default:\r
                return false;\r
                break;\r
        }\r
-        return fp->open(mode);\r
+        if(fp->open(open_mode) == false) return false;\r
+        return true;\r
   \r
 #else   \r
         Fclose();\r
@@ -152,12 +153,11 @@ void FILEIO::Fclose()
 \r
 # define GET_VALUE(type) \\r
        uint8 buffer[sizeof(type)]; \\r
-       fp->readBlock(buffer, sizeof(type)); \n\r
+       fp->read(buffer, sizeof(type)); \\r
        return *(type *)buffer\r
 \r
 #define PUT_VALUE(type, v) \\r
-        fp->writeBlock(&v, sizeof(type))\r
-\r
+       fp->write((char *)&v, sizeof(type))\r
 #else\r
 \r
 # define GET_VALUE(type) \\r
@@ -283,7 +283,9 @@ void FILEIO::FputDouble(double val)
 int FILEIO::Fgetc()\r
 {\r
 #if defined(_USE_QT)\r
-        return fp->getch();\r
+   char buffer;\r
+   fp->read(&buffer, sizeof(char));\r
+   return buffer;\r
 #else\r
        return fgetc(fp);\r
 #endif\r
@@ -292,7 +294,7 @@ int FILEIO::Fgetc()
 int FILEIO::Fputc(int c)\r
 {\r
 #if defined(_USE_QT)\r
-        return fp->putch(c);\r
+        return fp->write((char *)&c, sizeof(char));\r
 #else\r
        return fputc(c, fp);\r
 #endif\r
@@ -302,7 +304,8 @@ uint32 FILEIO::Fread(void* buffer, uint32 size, uint32 count)
 {\r
 #if defined(_USE_QT)\r
         uint64 l = (uint64)size * (uint64)count;\r
-        l = l + fp->readData(buffer, l);\r
+        uint8 *p = (uint8 *)buffer;\r
+        l = fp->read((uint8 *)p, l);\r
         return (uint32)l;\r
 #else\r
        return fread(buffer, size, count, fp);\r
@@ -313,7 +316,14 @@ uint32 FILEIO::Fwrite(void* buffer, uint32 size, uint32 count)
 {\r
 #if defined(_USE_QT)\r
         uint64 l = (uint64)size * (uint64)count;\r
-        l = l + fp->writeData(buffer, l);\r
+//        uint64 i;\r
+        uint8  *p = (uint8 *)buffer;\r
+//        int c;\r
+//        for(i = 0; i < l; i++) {\r
+//        c = fp->putch(p[i]);\r
+//        if(c < 0) break;\r
+//     }\r
+        l = fp->write(p, l);\r
         return (uint32)l;\r
 #else\r
        return fwrite(buffer, size, count, fp);\r
@@ -325,7 +335,7 @@ uint32 FILEIO::Fseek(long offset, int origin)
 #if defined(_USE_QT)\r
         switch(origin) {\r
        case FILEIO_SEEK_CUR:\r
-               if( fp->seek(offset + fp->pos())) ) return 0;\r
+               if( fp->seek(offset + fp->pos()) ) return 0;\r
        case FILEIO_SEEK_END:\r
                fp->seek(fp->size()); return 0; \r
         case FILEIO_SEEK_SET:\r
index a3d1400..a28cdec 100644 (file)
@@ -1,13 +1,21 @@
 message("* qt/common")
 
  
-add_library(qt_common
+add_executable(${EXEC_TARGET}
          emuevents_control.cpp
+         emu_utils.cpp
          qt_gldraw.cpp
+         qt_glutil.cpp
+         qt_dialogs.cpp
          qt_main.cpp
          qt_screen.cpp
+         qt_input.cpp
          agar_logger.cpp
          sdl_sound.cpp
+         qt_debugger.cpp
          sdl_cpuid.c
 )
+target_link_libraries(${EXEC_TARGET} ${LOCAL_LIBS} ${BUNDLE_LIBS})
+
+install(TARGETS ${EXEC_TARGET} DESTINATION bin)
 
index 89439af..84fbb7c 100644 (file)
@@ -1,5 +1,5 @@
 
-
+#include <SDL/SDL.h>
 #include <stdio.h>
 #include <string>
 #include <vector>
@@ -7,7 +7,24 @@
 #include "emu.h"
 #include "qt_main.h"
 
-#if defined(USE_FD1) || defined(USE_FD2) || defined(USE_FD3) || defined(USE_FD4) || 
+
+// Belows are Wrappers.
+extern "C" {
+   
+   void Sleep(uint32_t tick) 
+     {
+       SDL_Delay(tick);
+     }
+
+   uint32_t timeGetTime(void)
+     {
+       return SDL_GetTicks();
+     }
+}
+
+
+
+#if defined(USE_FD1) || defined(USE_FD2) || defined(USE_FD3) || defined(USE_FD4) || \
     defined(USE_FD5) || defined(USE_FD6) || defined(USE_FD7) || defined(USE_FD8)
 
 void open_disk(int drv, _TCHAR* path, int bank)
index db297c7..11f17bc 100644 (file)
@@ -5,6 +5,11 @@
 #include "emu.h"
 #include "qt_main.h"
 
+extern "C" {
+   extern uint32_t timeGetTime(void);
+   extern void Sleep(uint32_t);
+}
+
 #if defined(USE_FD1) || defined(USE_FD2) || defined(USE_FD3) || defined(USE_FD4) || \
     defined(USE_FD5) || defined(USE_FD6) || defined(USE_FD7) || defined(USE_FD8)
 
diff --git a/source/src/qt/common/qt_debugger.cpp b/source/src/qt/common/qt_debugger.cpp
new file mode 100644 (file)
index 0000000..9f6172e
--- /dev/null
@@ -0,0 +1,117 @@
+#include "emu.h"
+#include "vm/device.h"
+#include "vm/debugger.h"
+#include "vm/vm.h"
+#include "fileio.h"
+
+#ifdef USE_DEBUGGER
+#if 0 //!
+void my_printf(HANDLE hStdOut, const _TCHAR *format, ...)
+{
+       DWORD dwWritten;
+       _TCHAR buffer[1024];
+       va_list ap;
+       
+       va_start(ap, format);
+       _vstprintf(buffer, format, ap);
+       va_end(ap);
+       
+       WriteConsole(hStdOut, buffer, _tcslen(buffer), &dwWritten, NULL);
+}
+
+void my_putch(HANDLE hStdOut, _TCHAR c)
+{
+       DWORD dwWritten;
+       
+       WriteConsole(hStdOut, &c, 1, &dwWritten, NULL);
+}
+
+uint32 my_hexatoi(_TCHAR *str)
+{
+       _TCHAR *s;
+       
+       if(str == NULL || _tcslen(str) == 0) {
+               return 0;
+       } else if(_tcslen(str) == 3 && str[0] == _T('\'') && str[2] == _T('\'')) {
+               // ank
+               return str[1] & 0xff;
+       } else if((s = _tcsstr(str, _T(":"))) != NULL) {
+               // 0000:0000
+               s[0] = _T('\0');
+               return (my_hexatoi(str) << 4) + my_hexatoi(s + 1);
+       } else if(str[0] == _T('%')) {
+               // decimal
+               return atoi(str + 1);
+       }
+       return _tcstol(str, NULL, 16);
+}
+
+break_point_t *get_break_point(DEBUGGER *debugger, _TCHAR *command)
+{
+       if(command[0] == _T('B') || command[0] == _T('b')) {
+               return &debugger->bp;
+       } else if(command[0] == _T('R') || command[0] == _T('r')) {
+               return &debugger->rbp;
+       } else if(command[0] == _T('W') || command[0] == _T('w')) {
+               return &debugger->wbp;
+       } else if(command[0] == _T('I') || command[0] == _T('i')) {
+               return &debugger->ibp;
+       } else if(command[0] == _T('O') || command[0] == _T('o')) {
+               return &debugger->obp;
+       }
+       return NULL;
+}
+
+//unsigned __stdcall debugger_thread(void *lpx)
+#endif //!
+
+void EMU::initialize_debugger()
+{
+       now_debugging = false;
+}
+
+void EMU::release_debugger()
+{
+       close_debugger();
+}
+
+void EMU::open_debugger(int cpu_index)
+{
+#if 0
+       if(!(now_debugging && debugger_thread_param.cpu_index == cpu_index)) {
+               close_debugger();
+               if(vm->get_cpu(cpu_index) != NULL && vm->get_cpu(cpu_index)->get_debugger() != NULL) {
+                       debugger_thread_param.emu = this;
+                       debugger_thread_param.vm = vm;
+                       debugger_thread_param.cpu_index = cpu_index;
+                       debugger_thread_param.request_terminate = false;
+                       if((hDebuggerThread = (HANDLE)_beginthreadex(NULL, 0, debugger_thread, &debugger_thread_param, 0, NULL)) != (HANDLE)0) {
+                               stop_rec_sound();
+                               stop_rec_video();
+                               now_debugging = true;
+                       }
+               }
+       }
+#endif
+}
+
+void EMU::close_debugger()
+{
+       if(now_debugging) {
+//             if(debugger_thread_param.running) {
+//                     debugger_thread_param.request_terminate = true;
+//                     WaitForSingleObject(hDebuggerThread, INFINITE);
+//             }
+//             CloseHandle(hDebuggerThread);
+               now_debugging = false;
+       }
+}
+
+bool EMU::debugger_enabled(int cpu_index)
+{
+   return false;
+//     return (vm->get_cpu(cpu_index) != NULL && vm->get_cpu(cpu_index)->get_debugger() != NULL);
+}
+
+#endif
+
index c4c8049..ffcae13 100644 (file)
 #include "qt_main.h"
 
 
-void CSP_FileParams::open_disk(const QString fname)
+void CSP_FileParams::_open_disk(const QString fname)
 {
    char path_shadow[PATH_MAX];
    int drv;
    CSP_DiskParams *my = this;
+#ifdef USE_FD1
    
    drv = this->getDrive();
    if(fname.length() <= 0) return;
-   strncpy(path_shadow, fname.c_str(), PATH_MAX);
+   strncpy(path_shadow, fname.toUtf8().constData(), PATH_MAX);
    UPDATE_HISTORY(path_shadow, config.recent_disk_path[drv]);
    get_parent_dir(path_shadow);
    strcpy(config.initial_disk_dir, path_shadow);
-#ifdef USE_FD1
-   open_disk(drv, path, 0);
+   open_disk(drv, path_shadow, 0);
 #endif
 }
 
-void CSP_FileParams::open_cart(const QString fname)
+void CSP_FileParams::_open_cart(const QString fname)
 {
    char path_shadow[PATH_MAX];
    int drv;
    CSP_DiskParams *my = this;
+#ifdef USE_CART1
    drv = this->getDrive();
    if(fname.length() <= 0) return;
-   strncpy(path_shadow, fname.c_str(), PATH_MAX);
+   strncpy(path_shadow, fname.toUtf8().constData(), PATH_MAX);
    UPDATE_HISTORY(path_shadow, config.recent_cart_path[drv]);
    get_parent_dir(path_shadow);
    strcpy(config.initial_cart_dir, path_shadow);
-#ifdef USE_CART1
+
    if(emu) emu->open_cart(drv, path_shadow);
 #endif
 }
 
-void CSP_FileParams::open_cmt(const QString path)
+void CSP_FileParams::_open_cmt(const QString path)
 {
-   AG_FileType *filetype = (AG_FileType *)AG_PTR(3);
   char path_shadow[PATH_MAX];
   int play;
    
   play = this->getRecMode();
+#ifdef USE_TAPE
   if(path.length() <= 0) return;
-  strncpy(path_shadow, path.c_str, PATH_MAX);
+  strncpy(path_shadow, path.toUtf8().constData(), PATH_MAX);
   UPDATE_HISTORY(path_shadow, config.recent_tape_path);
   get_parent_dir(path_shadow);
   strcpy(config.initial_tape_dir, path_shadow);
-#ifdef USE_TAPE
    if(play != 0) {
       emu->play_tape(path_shadow);
   } else {
@@ -69,28 +69,33 @@ void CSP_FileParams::open_cmt(const QString path)
 #endif
 }
 
-
+extern "C" 
+{
+   
 #ifdef USE_CART1
 void open_cart_dialog(QWidget *hWnd, int drv)
 {
+               CSP_DiskDialog dlg(hWnd);
+   
 #if defined(_GAMEGEAR)
                QString ext = "*.rom,*.bin,*.gg,*.col";
-               char *desc = _N("Game Cartridge");
+               QString desc = "Game Cartridge";
 #elif defined(_MASTERSYSTEM)
                QString ext = "*.rom,*.bin,*.sms";
-               char *desc = _N("Game Cartridge");
+               QString desc = "Game Cartridge";
 #elif defined(_PC6001) || defined(_PC6001MK2) || defined(_PC6001MK2SR) || defined(_PC6601) || defined(_PC6601SR)
-               QString *ext = "*.rom,*.bin,*.60";
-               char *desc = _N("Game Cartridge");
+               QString ext = "*.rom,*.bin,*.60";
+               QString desc = "Game Cartridge";
 #elif defined(_PCENGINE) || defined(_X1TWIN)
-               QString *ext = "*.rom,*.bin,*.pce";
-               char *desc = _N("HuCARD");
+               QString ext = "*.rom,*.bin,*.pce";
+               QString desc = "HuCARD";
 #else
-               QString *ext = "*.rom,*.bin"; 
-               char *desc = _N("Game Cartridge");
+               QString ext = "*.rom,*.bin"; 
+               QString desc = "Game Cartridge";
 #endif
-                QString filter = desc;
-                filter = filter + " (" + ext + ")";
+                QString dirname;
+                desc = desc + " (" + ext + ")";
+                QStringList filter(desc);
                 if(config.initial_cart_dir != NULL) {
                   dirname = config.initial_cart_dir;           
                } else {
@@ -98,36 +103,38 @@ void open_cart_dialog(QWidget *hWnd, int drv)
                   getcwd(app, PATH_MAX);
                   dirname = get_parent_dir(app);
                }
-                dlg->param.setDrive(drv);
-                dlg->setDir(dirname);
-                dlg->setFilter(filter); 
-                QObject::connect(dlg, SIGNAL(fileSelected(const QString)), &(dlg->param), SLOT(dlg->open_cart(const QString))); 
+                dlg.param.setDrive(drv);
+                dlg.setDirectory(dirname);
+                dlg.setNameFilters(filter); 
+                QObject::connect(&dlg, SIGNAL(fileSelected(const QString)), dlg.param, SLOT(dlg.param->_open_cart(const QString))); 
+                dlg.exec();
 }
 #endif
 
 #ifdef USE_FD1
-void open_disk(int drv, _TCHAR* path, int bank);
 
 void open_disk_dialog(QWidget *wid, int drv)
 {
   QString ext = "Disk Images (*.d88,*.d77,*.td0,*.imd,*.dsk,*.fdi,*.hdm,*.tfd,*.xdf,*.2d,*.sf7)";
-  QString desc = _N("Floppy Disk");
-  CSP_DiskDialog *dlg = new CSP_DiskDialog();
+  QString desc = "Floppy Disk";
+  CSP_DiskDialog dlg(wid);
   QString dirname;
   
   if(config.initial_disk_dir != NULL) {
     dirname = config.initial_disk_dir;         
   } else {
-    _TCHAR app[PATH_MAX];
-    getcwd(app, PATH_MAX);
+    char app[PATH_MAX];
+    QDir df;
+    dirname = df.currentPath();
+    strncpy(app, dirname.toUtf8().constData(), PATH_MAX);
     dirname = get_parent_dir(app);
   }
-  dlg->param.setDrive(drv);
-  dlg->setDir(dirname);
-  dlg->setFilter(ext); 
-  QObject::connect(dlg, SIGNAL(fileSelected(const QString)), &(dlg->param), SLOT(dlg->open_disk(const QString))); 
-  AG_FileDlgAddType(dlg, desc, ext, OnOpenFDSub, "%i", drv);
-
+  QStringList filter(ext);
+  dlg.param->setDrive(drv);
+  dlg.setDirectory(dirname);
+  dlg.setNameFilters(filter); 
+  QObject::connect(&dlg, SIGNAL(fileSelected(QString)), dlg.param, SLOT(dlg.param->open_disk(QString))); 
+  dlg.exec();
   return;
 }
 
@@ -154,6 +161,7 @@ void open_quickdisk_dialog(AG_Widget *hWnd, int drv)
    char path_shadow[AG_PATHNAME_MAX];
   const char *ext = "*.mzt,*.q20,*qdf";
   char *desc = _N("Quick Disk");
+  QString dirname;
   AG_Window *win;
    
   win = AG_WindowNew(0);
@@ -164,9 +172,11 @@ void open_quickdisk_dialog(AG_Widget *hWnd, int drv)
   if(config.initial_quickdisk_dir != NULL) {
     AG_FileDlgSetDirectory(dlg, "%s", config.initial_quickdisk_dir);           
   } else {
-    _TCHAR app[AG_PATHNAME_MAX];
-    AG_GetCWD(app, AG_PATHNAME_MAX);
-    AG_FileDlgSetDirectory(dlg, "%s", get_parent_dir(app));
+    char app[PATH_MAX];
+    QDir df;
+    dirname = df.currentPath();
+    strncpy(app, dirname.toUtf8().constData(), PATH_MAX);
+    dirname = get_parent_dir(app);
   }
   AG_FileDlgAddType(dlg, desc, ext, OnOpenQDSub, "%i", drv);
   AG_WindowShow(win);
@@ -178,9 +188,9 @@ void open_quickdisk_dialog(AG_Widget *hWnd, int drv)
 void open_tape_dialog(QWidget *hWnd, bool play)
 {
   int playf = play ? 1 : 0;
-  CSP_DiskDialog *dlg = new CSP_DiskDialog;
   QString ext;
-  char *desc;
+  QString dirname;
+  QString desc;
 #if defined(_PC6001) || defined(_PC6001MK2) || defined(_PC6001MK2SR) || defined(_PC6601) || defined(_PC6601SR)
   ext = "*.wav,*.p6,*.cas";
 #elif defined(_PC8001SR) || defined(_PC8801MA) || defined(_PC98DO)
@@ -198,23 +208,28 @@ void open_tape_dialog(QWidget *hWnd, bool play)
 #else
   ext = "*.wav;*.cas";
 #endif
-  desc = play ? _N("Data Recorder Tape [Play]") : _N("Data Recorder Tape [Rec]");
-  QString filter = desc;
-  filter = filter + " (" + ext + ")";
-  if(config.initial_cart_dir != NULL) {
-     dirname = config.initial_cart_dir;                
+  desc = play ? "Data Recorder Tape [Play]" : "Data Recorder Tape [Rec]";
+  desc = desc + " (" + ext + ")";
+  QStringList filter(desc);
+  if(config.initial_tape_dir != NULL) {
+     dirname = config.initial_tape_dir;                
   } else {
-     _TCHAR app[PATH_MAX];
-     getcwd(app, PATH_MAX);
+    char app[PATH_MAX];
+    QDir df;
+    dirname = df.currentPath();
+    strncpy(app, dirname.toUtf8().constData(), PATH_MAX);
      dirname = get_parent_dir(app);
   }
-   dlg->param.setREcMode(play);
-   dlg->setDir(dirname);
-   dlg->setFilter(filter); 
-   QObject::connect(dlg, SIGNAL(fileSelected(const QString)), &(dlg->param), SLOT(dlg->open_cmt(const QString))); 
+   CSP_DiskDialog dlg(hWnd);
+   dlg.param->setRecMode(play);
+   dlg.setDirectory(dirname);
+   dlg.setNameFilters(filter); 
+   QObject::connect(&dlg, SIGNAL(fileSelected(QString)), dlg.param, SLOT(dlg.param->_open_cmt(QString))); 
+   dlg.exec();
 }
 #endif
-
+}
+#if 0 // !
 #ifdef USE_LASER_DISC
 void OnOpenLaserDiscSub(AG_Event *event)
 {
@@ -235,7 +250,7 @@ void OnOpenLaserDiscSub(AG_Event *event)
 void open_laser_disc_dialog(AG_Widget *hWnd)
 {
   const char *ext = "*.avi,*.mpg,*.mpeg,*.wmv,*.ogv";
-  char *desc = _N("Laser Disc");
+  char *desc = "Laser Disc";
   AG_Window *win;
    
   win = AG_WindowNew(0);
@@ -286,9 +301,9 @@ void open_binary_dialog(AG_Widget *hWnd, int drv, bool load)
    
   int loadf = load ? 1 : 0;
 #if defined(_PASOPIA) || defined(_PASOPIA7)
-  char *desc = _N("RAM Pack Cartridge");
+  char *desc = "RAM Pack Cartridge";
 #else
-  char *desc = _N("Memory Dump");
+  char *desc = "Memory Dump";
 #endif
   win = AG_WIndowNew(0);
   AG_FileDlg *dlg = AG_FileDlgNew(win, AG_FILEDLG_MASK_EXT | AG_FILEDLG_ASYNC | AG_FILEDLG_CLOSEWIN);
@@ -307,6 +322,7 @@ void open_binary_dialog(AG_Widget *hWnd, int drv, bool load)
 
 }
 #endif
+#endif // !
 
 #ifdef SUPPORT_DRAG_DROP
 void open_any_file(_TCHAR* path)
index e718619..385ab6d 100644 (file)
@@ -5,12 +5,27 @@
 #include "emu.h"
 #include "qt_main.h"
 
-typedef class CSP_DiskParams : QObject {   
-   Q_OBJECT
-   Q_DISABLE_COPY(CSP_DiskParams)
+typedef class CSP_DiskParams : public QObject {   
+//   Q_OBJECT
+//   Q_DISABLE_COPY(CSP_DiskParams)
  public:
-   explicit CSP_DiskParams(QObject *parent = 0);
-   
+//   explicit CSP_DiskParams(QObject *parent = 0);
+   CSP_DiskParams(QObject *parent) : QObject(parent){
+       record = false;
+        drive = 0;
+   }
+   ~CSP_DiskParams() {}
+   // Virtual Functions
+   bool event(QEvent *e) { return true;} 
+   bool eventFilter ( QObject * watched, QEvent * event ){
+       return true;
+   }
+   void childEvent (QChildEvent * event ){ };
+   void connectNotify ( const char * signal ) {}
+   void customEvent ( QEvent * event ) { }
+   void disconnectNotify ( const char * signal ) {  }
+   void timerEvent ( QTimerEvent * event ){ }
+   // End
    void setDrive(int num) {if((num < 0) || (num >= 8)) num = 0; drive = num;}
    int getDrive(void) { return drive;}
    void setRecMode(bool num) {
@@ -23,19 +38,28 @@ typedef class CSP_DiskParams : QObject {
    
  signals:
  public slots:
-     void open_disk(const QString fname);
-     void open_cart(const QString fname);
-     void open_cmt(const QString fname);
+     void _open_disk(const QString fname);
+     void _open_cart(const QString fname);
+     void _open_cmt(const QString fname);
  private:
    int drive;
    bool record;
 } CSP_FileParams;
 
-typedef class CSP_DiskDialog : QFileDialog {
+typedef class CSP_DiskDialog : public QFileDialog {
  public:
-   CSP_FileParams param;
+   CSP_FileParams *param;
+   CSP_DiskDialog(QObject *parent) : QFileDialog(parent) {
+       param = new CSP_FileParams(parent);
+   }
+   ~CSP_DiskDialog() {
+       delete param;
+   }
+   
+   
 } CSP_DiskDialog;
 
+extern "C" {
 #ifdef USE_CART1
 extern void open_cart_dialog(QWidget *hWnd, int drv);
 #endif
@@ -44,7 +68,8 @@ extern void open_cart_dialog(QWidget *hWnd, int drv);
 extern void open_disk_dialog(QWidget *hWnd, int drv);
 #endif
 #ifdef USE_TAPE
-void open_tape_dialog(QWidget *hWnd, bool play);
+extern void open_tape_dialog(QWidget *hWnd, bool play);
 #endif
+}
 
 #endif //End.
\ No newline at end of file
index 4c7faf3..c5f400c 100644 (file)
@@ -17,6 +17,7 @@
 #include <GL/glx.h>
 #include <GL/glxext.h>
 #endif
+#include <GL/glu.h>
 
 #undef _USE_OPENCL
 #ifdef _USE_OPENCL
@@ -95,8 +96,9 @@ void GLDrawClass::drawUpdateTexture(Uint32 *p, int w, int h, bool crtflag)
        //       glPushAttrib(GL_TEXTURE_BIT);
        ww = w >> 3;
        hh = h >> 3;
-
-#ifdef _USE_OPENCL
+       crtflag = true;
+//#ifdef _USE_OPENCL
+#if 0
        if((cldraw != NULL) && (bCLEnabled)) {
          cl_int ret = CL_SUCCESS;
 //       LockVram();
@@ -114,14 +116,14 @@ void GLDrawClass::drawUpdateTexture(Uint32 *p, int w, int h, bool crtflag)
                if(ret != CL_SUCCESS) {
                  //SDLDrawFlag.Drawn = FALSE;
                  bPaletFlag = FALSE;
-                 glBindTexture(GL_TEXTURE_2D, 0);
+                 this->bindTexture(GL_TEXTURE_2D, 0);
                  //UnlockVram();
                  return;
                }
            }
            if(bCLGLInterop){
                glBindBuffer(GL_PIXEL_UNPACK_BUFFER, cldraw->GetPbo());
-               glBindTexture(GL_TEXTURE_2D, uVramTextureID);
+               this->bindTexture(GL_TEXTURE_2D, uVramTextureID);
                // Copy pbo to texture 
                glTexSubImage2D(GL_TEXTURE_2D, 
                                0,
@@ -134,12 +136,12 @@ void GLDrawClass::drawUpdateTexture(Uint32 *p, int w, int h, bool crtflag)
                                NULL);
                glFinish();
                glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
-               glBindTexture(GL_TEXTURE_2D, 0);
+               this->indTexture(GL_TEXTURE_2D, 0);
                glFinish();
            } else { // Not interoperability with GL
                Uint32 *pp;
                pp = cldraw->GetPixelBuffer();
-               glBindTexture(GL_TEXTURE_2D, uVramTextureID);
+               this->indTexture(GL_TEXTURE_2D, uVramTextureID);
                if(pp != NULL) glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
                                              w, h, GL_RGBA, GL_UNSIGNED_BYTE, pp);
                glFinish();
@@ -156,7 +158,8 @@ void GLDrawClass::drawUpdateTexture(Uint32 *p, int w, int h, bool crtflag)
          flag = TRUE;
          //flag |= SDLDrawFlag.Drawn;
          if((p != NULL) && (flag)) {
-            if(crtflag != false) {
+//          printf("Update: %d %d\n", SDL_GetTicks(), uVramTextureID);
+            //if(crtflag != false) {
                glBindTexture(GL_TEXTURE_2D, uVramTextureID);
                glTexSubImage2D(GL_TEXTURE_2D, 
                          0,
@@ -169,27 +172,39 @@ void GLDrawClass::drawUpdateTexture(Uint32 *p, int w, int h, bool crtflag)
                          p);
               glFinish();
               glBindTexture(GL_TEXTURE_2D, 0); // 20111023 チラつきなど抑止
-            }
+            //}
             //bPaletFlag = FALSE;
             //SDLDrawFlag.Drawn = FALSE;
          }
          //UnlockVram();
-#ifdef _USE_OPENCL
+//#ifdef _USE_OPENCL
+#if 0
        }
 #endif       
     }
 }
 
-   
-
-
 
+void GLDrawClass::resizeGL(int width, int height)
+{
+   int side = qMin(width, height);
+   glViewport((width - side) / 2, (height - side) / 2, side, side);
+   printf("ResizeGL: %dx%d\n", width , height);
+   glMatrixMode(GL_PROJECTION);
+   glLoadIdentity();
+#ifdef QT_OPENGL_ES_1
+   glOrthof(-0.5, +0.5, -0.5, +0.5, 4.0, 15.0);
+#else
+   glOrtho(-0.5, +0.5, -0.5, +0.5, 4.0, 15.0);
+#endif
+   glMatrixMode(GL_MODELVIEW);//    glLoadIdentity();
+}
 
 /*
  * "Draw"イベントハンドラ
  */
 
-void GLDrawClass::DrawHandler(void)
+void GLDrawClass::paintGL(void)
 {
    int w;
    int h;
@@ -209,12 +224,12 @@ void GLDrawClass::DrawHandler(void)
    p = emu->screen_buffer(0);
    w = SCREEN_WIDTH;
    h = SCREEN_HEIGHT;
-   if((p == NULL) && (bCLEnabled == FALSE)) return;
+   if(p == NULL) return;
    TexCoords[0][0] = TexCoords[3][0] = 0.0f; // Xbegin
    TexCoords[0][1] = TexCoords[1][1] = 0.0f; // Ybegin
    
-   TexCoords[2][0] = TexCoords[1][0] = (float)w / (float)w; // Xend
-   TexCoords[2][1] = TexCoords[3][1] = (float)(h - 1) / (float)h; // Yend
+   TexCoords[2][0] = TexCoords[1][0] = 1.0f; // Xend
+   TexCoords[2][1] = TexCoords[3][1] = 1.0f; // Yend
    gridtid = GridVertexs400l;
 
     Vertexs[0][2] = Vertexs[1][2] = Vertexs[2][2] = Vertexs[3][2] = -0.98f;
@@ -236,10 +251,9 @@ void GLDrawClass::DrawHandler(void)
 #ifdef _USE_OPENCL
     InitContextCL();   
 #endif
-    glMatrixMode(GL_PROJECTION);
-    glLoadIdentity();
-    
-   
+    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+//    glMatrixMode(GL_PROJECTION);
+//    glLoadIdentity();
     glEnable(GL_DEPTH_TEST);
     glDisable(GL_BLEND);
    
@@ -249,37 +263,33 @@ void GLDrawClass::DrawHandler(void)
      //if(uVramTextureID != 0) {
 
        if(crtflag){
-         drawUpdateTexture(p, w, h, crtflag);
-         glEnable(GL_TEXTURE_2D);
-         glBindTexture(GL_TEXTURE_2D, uVramTextureID);
-         glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
-     //} else {
-//     glDisable(GL_TEXTURE_2D);
-//     glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
-//     }
+//       drawUpdateTexture(p, w, h, crtflag);
+//       glEnable(GL_TEXTURE_2D);
+//       glBindTexture(GL_TEXTURE_2D, uVramTextureID);
+         glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
      } else {
-          glEnable(GL_TEXTURE_2D);
+//        glEnable(GL_TEXTURE_2D);
          glBindTexture(GL_TEXTURE_2D, uNullTextureID);
           glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
      }      
        //if(!bSmoosing) {
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+//      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+//      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        //} else {
        // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
       // }
-       if(bGL_EXT_VERTEX_ARRAY) {
-        glEnable(GL_TEXTURE_COORD_ARRAY_EXT);
-        glEnable(GL_VERTEX_ARRAY_EXT);
+       //if(bGL_EXT_VERTEX_ARRAY) {
+//      glEnable(GL_TEXTURE_COORD_ARRAY_EXT);
+//      glEnable(GL_VERTEX_ARRAY_EXT);
              
-        glTexCoordPointerEXT(2, GL_FLOAT, 0, 4, TexCoords);
-        glVertexPointerEXT(3, GL_FLOAT, 0, 4, Vertexs);
-        glDrawArraysEXT(GL_POLYGON, 0, 4);
+//      glTexCoordPointerEXT(2, GL_FLOAT, 0, 4, TexCoords);
+//      glVertexPointerEXT(3, GL_FLOAT, 0, 4, Vertexs);
+//      glDrawArraysEXT(GL_POLYGON, 0, 4);
         
-        glDisable(GL_VERTEX_ARRAY_EXT);
-        glDisable(GL_TEXTURE_COORD_ARRAY_EXT);
-       } else {
+//      glDisable(GL_VERTEX_ARRAY_EXT);
+//      glDisable(GL_TEXTURE_COORD_ARRAY_EXT);
+//       } else {
         glBegin(GL_POLYGON);
         glTexCoord2f(TexCoords[0][0], TexCoords[0][1]);
         glVertex3f(Vertexs[0][0], Vertexs[0][1], Vertexs[0][2]);
@@ -293,42 +303,44 @@ void GLDrawClass::DrawHandler(void)
         glTexCoord2f(TexCoords[3][0], TexCoords[3][1]);
         glVertex3f(Vertexs[3][0], Vertexs[3][1], Vertexs[3][2]);
         glEnd();
-       }
+         printf("Done. %d\n", SDL_GetTicks());
+//       }
     // }
    
      // 20120502 輝度調整
-    glBindTexture(GL_TEXTURE_2D, 0); // 20111023
-    glDisable(GL_TEXTURE_2D);
-    glDisable(GL_DEPTH_TEST);
-
-    if(bCLEnabled == FALSE){
-       glEnable(GL_BLEND);
+//    glBindTexture(GL_TEXTURE_2D, 0); // 20111023
+//    glDisable(GL_TEXTURE_2D);
+//    glDisable(GL_DEPTH_TEST);
+#if 0 // !
+//    if(bCLEnabled == FALSE){
+//       glEnable(GL_BLEND);
    
-       glColor3f(fBrightR , fBrightG, fBrightB);
-       glBlendFunc(GL_ZERO, GL_SRC_COLOR);
+//       glColor3f(fBrightR , fBrightG, fBrightB);
+//       glBlendFunc(GL_ZERO, GL_SRC_COLOR);
     
        //    glBlendFunc(GL_ZERO, GL_SRC_ALPHA);
-       if(bGL_EXT_VERTEX_ARRAY) {
-         glEnable(GL_VERTEX_ARRAY_EXT);
-         glVertexPointerEXT(3, GL_FLOAT, 0, 4, Vertexs);
-         glDrawArraysEXT(GL_POLYGON, 0, 4);
-         glDisable(GL_VERTEX_ARRAY_EXT);
-       } else {
+//       if(bGL_EXT_VERTEX_ARRAY) {
+//       glEnable(GL_VERTEX_ARRAY_EXT);
+//       glVertexPointerEXT(3, GL_FLOAT, 0, 4, Vertexs);
+//       glDrawArraysEXT(GL_POLYGON, 0, 4);
+//       glDisable(GL_VERTEX_ARRAY_EXT);
+//       } else {
          glBegin(GL_POLYGON);
          glVertex3f(Vertexs[0][0], Vertexs[0][1], Vertexs[0][2]);
          glVertex3f(Vertexs[1][0], Vertexs[1][1], Vertexs[1][2]);
          glVertex3f(Vertexs[2][0], Vertexs[2][1], Vertexs[2][2]);
          glVertex3f(Vertexs[3][0], Vertexs[3][1], Vertexs[3][2]);
          glEnd();
-       }
+//       }
        
        glBlendFunc(GL_ONE, GL_ZERO);
    
        glDisable(GL_BLEND);
-    }
+//    }
        glDisable(GL_TEXTURE_2D);
        glDisable(GL_DEPTH_TEST);
-#if 0
+#endif // !
+# if 0
         if(glv->wid.rView.h >= h) {
          glLineWidth((float)(glv->wid.rView.h) / (float)(h * 2));
          glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
index 0fe329c..6ceb191 100644 (file)
@@ -2,12 +2,15 @@
 #ifndef _CSP_QT_DIALOG_H
 #define _CSP_QT_DIALOG_H
 
+#include <Qt>
 #include <QtGui>
 #include <QtOpenGL/QtOpenGL>
 #include <GL/gl.h>
 class GLDrawClass: public QGLWidget 
 {
-   Q_OBJECT
+
+ private:
+     quint32 modifier;
  protected:
      GLuint uVramTextureID;
      GLuint uNullTextureID;
@@ -26,10 +29,14 @@ class GLDrawClass: public QGLWidget
      int nCLDeviceNum;
      bool bCLInteropGL;
      //
+     int pushed_keycode;
+     quint32 pushed_mod;
      bool InitVideo;
      void drawGrids(void *pg,int w, int h);
-     void InitGL(void);
-
+     void initializeGL(void);
+     void paintGL(void);
+     void resizeGL(int width, int height);
+       
 #ifdef _USE_OPENCL
 //     extern class GLCLDraw *cldraw;
 #endif
@@ -43,14 +50,16 @@ class GLDrawClass: public QGLWidget
      GLuint CreateNullTexture(int w, int h);
      GLuint CreateNullTextureCL(int w, int h);
      GLDrawClass( QWidget *parent = 0 , const char *name = 0 ) {
-        InitGL();
-        InitGLExtensionVars();
+//        InitGLExtensionVars();
 #ifdef _USE_OPENCL
        // Init CL
 #endif
-       
+       modifier = 0;
      }
-   
+     quint32 getModState(void) { return modifier;}
+     void ProcessKeyUp(QKeyEvent *event);
+     void ProcessKeyDown(QKeyEvent *event);
+       
      bool bGL_ARB_IMAGING; // イメージ操作可能か?
      bool bGL_ARB_COPY_BUFFER;  // バッファ内コピー(高速化!)サポート
      bool bGL_EXT_INDEX_TEXTURE; // パレットモードに係わる
@@ -73,7 +82,7 @@ class GLDrawClass: public QGLWidget
      PFNGLDELETEBUFFERSPROC glDeleteBuffers;
      void SetBrightRGB(float r, float g, float b);
      void drawUpdateTexture(Uint32 *p, int w, int h, bool crtflag);
-     void DrawHandler(void);
+     //void DrawHandler(void);
      void InitFBO(void);
      void InitGridVertexs(void);
      void DiscardTextures(int n, GLuint *id);
index 58ddc76..20825e9 100644 (file)
@@ -8,7 +8,7 @@
 //#include "agar_glcl.h"
 #endif
 #include "agar_logger.h"
-#indlude "qt_gldraw.h"
+#include "qt_gldraw.h"
 #include "emu.h"
 
 #ifdef USE_OPENMP
@@ -73,13 +73,11 @@ GLuint GLDrawClass::CreateNullTextureCL(int w, int h)
 
 void GLDrawClass::DiscardTextures(int n, GLuint *id)
 {
-       if(hGLView == NULL) return;
-       if(agDriverOps == NULL) return;
        glDeleteTextures(n, id);
 
 }
 
-void GLDrawClas::DiscardTexture(GLuint tid)
+void GLDrawClass::DiscardTexture(GLuint tid)
 {
        DiscardTextures(1, &tid);
 }
@@ -164,7 +162,7 @@ void GLDrawClass::InitGridVertexs(void)
 }
 
 
-void GLDrawClass::InitGL(void)
+void GLDrawClass::initializeGL(void)
 {
    int bpp = 32;
    int rgb_size[3];
@@ -215,7 +213,9 @@ void GLDrawClass::InitGL(void)
           // FBOの有無を受けて、拡張の有無変数を変更する(念のために)
           InitGLExtensionVars();
           InitGridVertexs(); // Grid初期化
-       //}
+    // Init view
+     glClearColor(0.0, 0.0, 0.0, 1.0);
+     glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
    
     fBrightR = 1.0; // 輝度の初期化
     fBrightG = 1.0;
@@ -289,19 +289,19 @@ void GLDrawClass::InitFBO(void)
 {
 //#ifndef _WINDOWS // glx is for X11.
 // Use SDL for wrapper. 20130128
-       glVertexPointerEXT = (PFNGLVERTEXPOINTEREXTPROC)SDL_GL_GetProcAddress("glVertexPointerEXT");
-       if(glVertexPointerEXT == NULL) bGL_EXT_VERTEX_ARRAY = false;
-       glDrawArraysEXT = (PFNGLDRAWARRAYSEXTPROC)SDL_GL_GetProcAddress("glDrawArraysEXT");
-       if(glDrawArraysEXT == NULL) bGL_EXT_VERTEX_ARRAY = false;
-       glTexCoordPointerEXT = (PFNGLTEXCOORDPOINTEREXTPROC)SDL_GL_GetProcAddress("glTexCoordPointerEXT");
-       if(glTexCoordPointerEXT == NULL) bGL_EXT_VERTEX_ARRAY = false;
-       glBindBuffer = (PFNGLBINDBUFFERPROC)SDL_GL_GetProcAddress("glBindBuffer");
-       if(glBindBuffer == NULL) bGL_PIXEL_UNPACK_BUFFER_BINDING = false;
-       glBufferData = (PFNGLBUFFERDATAPROC)SDL_GL_GetProcAddress("glBufferData");
-       if(glBufferData == NULL) bGL_PIXEL_UNPACK_BUFFER_BINDING = false;
-       glGenBuffers = (PFNGLGENBUFFERSPROC)SDL_GL_GetProcAddress("glGenBuffers");
-       if(glGenBuffers == NULL) bGL_PIXEL_UNPACK_BUFFER_BINDING = false;
-       glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)SDL_GL_GetProcAddress("glDeleteBuffers");
-       if(glDeleteBuffers == NULL) bGL_PIXEL_UNPACK_BUFFER_BINDING = false;
+       //glVertexPointerEXT = (PFNGLVERTEXPOINTEREXTPROC)SDL_GL_GetProcAddress("glVertexPointerEXT");
+       bGL_EXT_VERTEX_ARRAY = false;
+       //glDrawArraysEXT = (PFNGLDRAWARRAYSEXTPROC)SDL_GL_GetProcAddress("glDrawArraysEXT");
+       bGL_EXT_VERTEX_ARRAY = false;
+       //glTexCoordPointerEXT = (PFNGLTEXCOORDPOINTEREXTPROC)SDL_GL_GetProcAddress("glTexCoordPointerEXT");
+       bGL_EXT_VERTEX_ARRAY = false;
+       //glBindBuffer = (PFNGLBINDBUFFERPROC)SDL_GL_GetProcAddress("glBindBuffer");
+       bGL_PIXEL_UNPACK_BUFFER_BINDING = false;
+       //glBufferData = (PFNGLBUFFERDATAPROC)SDL_GL_GetProcAddress("glBufferData");
+       bGL_PIXEL_UNPACK_BUFFER_BINDING = false;
+       //glGenBuffers = (PFNGLGENBUFFERSPROC)SDL_GL_GetProcAddress("glGenBuffers");
+       bGL_PIXEL_UNPACK_BUFFER_BINDING = false;
+       //glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)SDL_GL_GetProcAddress("glDeleteBuffers");
+       bGL_PIXEL_UNPACK_BUFFER_BINDING = false;
    
 }
diff --git a/source/src/qt/common/qt_input.cpp b/source/src/qt/common/qt_input.cpp
new file mode 100644 (file)
index 0000000..5efd20f
--- /dev/null
@@ -0,0 +1,844 @@
+/*
+       Skelton for retropc emulator
+
+       Author : Takeda.Toshiya
+       Date   : 2006.08.18 -
+
+       [ win32 input ]
+*/
+
+#include <Qt>
+#include <QKeyEvent>
+#include "emu.h"
+#include "vm/vm.h"
+#include "fifo.h"
+#include "fileio.h"
+#include "qt_input.h"
+#include "qt_gldraw.h"
+#include "qt_main.h"
+#include "menuclasses.h"
+
+#ifndef Ulong
+#define Ulong unsigned long
+#endif
+
+#define KEY_KEEP_FRAMES 3
+
+const struct WIndowsKeyTable  WindowsKeyMappings[] = {
+       { '0',                  Qt::Key_0 },
+       { '1',                  Qt::Key_1 },
+       { '2',                  Qt::Key_2 },
+       { '3',                  Qt::Key_3 },
+       { '4',                  Qt::Key_4 },
+       { '5',                  Qt::Key_5 },
+       { '6',                  Qt::Key_6 },
+       { '7',                  Qt::Key_7 },
+       { '8',                  Qt::Key_8 },
+       { '9',                  Qt::Key_9 },
+       { 'A',                  Qt::Key_A },
+       { 'B',                  Qt::Key_B },
+       { 'C',                  Qt::Key_C },
+       { 'D',                  Qt::Key_D },
+       { 'E',                  Qt::Key_E },
+       { 'F',                  Qt::Key_F },
+       { 'G',                  Qt::Key_G },
+       { 'H',                  Qt::Key_H },
+       { 'I',                  Qt::Key_I },
+       { 'J',                  Qt::Key_J },
+       { 'K',                  Qt::Key_K },
+       { 'L',                  Qt::Key_L },
+       { 'M',                  Qt::Key_M },
+       { 'N',                  Qt::Key_N },
+       { 'O',                  Qt::Key_O },
+       { 'P',                  Qt::Key_P },
+       { 'Q',                  Qt::Key_Q },
+       { 'R',                  Qt::Key_R },
+       { 'S',                  Qt::Key_S },
+       { 'T',                  Qt::Key_T },
+       { 'U',                  Qt::Key_U },
+       { 'V',                  Qt::Key_V },
+       { 'W',                  Qt::Key_W },
+       { 'X',                  Qt::Key_X },
+       { 'Y',                  Qt::Key_Y },
+       { 'Z',                  Qt::Key_Z },
+       { VK_F1,                Qt::Key_F1 },
+       { VK_F2,                Qt::Key_F2 },
+       { VK_F3,                Qt::Key_F3 },
+       { VK_F4,                Qt::Key_F4 },
+       { VK_F5,                Qt::Key_F5 },
+       { VK_F6,                Qt::Key_F6 },
+       { VK_F7,                Qt::Key_F7 },
+       { VK_F8,                Qt::Key_F8 },
+       { VK_F9,                Qt::Key_F9 },
+       { VK_F10,               Qt::Key_F10 },
+       { VK_F11,               Qt::Key_F11 },
+       { VK_F12,               Qt::Key_F12 },
+       { VK_F13,               Qt::Key_F13 },
+       { VK_F14,               Qt::Key_F14 },
+       { VK_F15,               Qt::Key_F15 },
+
+       { VK_BACK,              Qt::Key_Backspace },
+       { VK_TAB,               Qt::Key_Tab },
+       { VK_CLEAR,             Qt::Key_Clear },
+       { VK_RETURN,            Qt::Key_Return },
+       { VK_PAUSE,             Qt::Key_Pause },
+       { VK_ESCAPE,            Qt::Key_Escape },
+       { VK_SPACE,             Qt::Key_Space },
+       { VK_DELETE,            Qt::Key_Delete },
+       { VK_UP,                Qt::Key_Up },
+       { VK_DOWN,              Qt::Key_Down },
+       { VK_RIGHT,             Qt::Key_Right },
+       { VK_LEFT,              Qt::Key_Left },
+       { VK_INSERT,            Qt::Key_Insert },
+       { VK_HOME,              Qt::Key_Home },
+       { VK_END,               Qt::Key_End },
+       { VK_PRIOR,             Qt::Key_PageUp },
+       { VK_NEXT,              Qt::Key_PageDown },
+
+//     { VK_NUMPAD0,           Qt::Key_KP0 },
+//     { VK_NUMPAD1,           Qt::Key_KP1 },
+//     { VK_NUMPAD2,           Qt::Key_KP2 },
+//     { VK_NUMPAD3,           Qt::Key_KP3 },
+//     { VK_NUMPAD4,           Qt::Key_KP4 },
+//     { VK_NUMPAD5,           Qt::Key_KP5 },
+//     { VK_NUMPAD6,           Qt::Key_KP6 },
+//     { VK_NUMPAD7,           Qt::Key_KP7 },
+//     { VK_NUMPAD8,           Qt::Key_KP8 },
+//     { VK_NUMPAD9,           Qt::Key_KP9 },
+//     { VK_DECIMAL,           Qt::Key_KP_Period },
+//     { VK_DIVIDE,            Qt::Key_KP_Divide },
+//     { VK_MULTIPLY,          Qt::Key_KP_Multiply },
+//     { VK_SUBTRACT,          Qt::Key_KP_Minus },
+//     { VK_ADD,               Qt::Key_KP_Plus },
+
+       { VK_NUMLOCK,           Qt::Key_NumLock },
+       { VK_CAPITAL,           Qt::Key_CapsLock },
+       { VK_SCROLL,            Qt::Key_ScrollLock },
+       { VK_SHIFT,             Qt::Key_Shift }, // Right
+       { VK_RSHIFT,            Qt::Key_Shift }, // Right
+       { VK_LSHIFT,            Qt::Key_Shift }, // Left
+       { VK_RCONTROL,          Qt::Key_Control }, // Right
+       { VK_LCONTROL,          Qt::Key_Control }, // Left
+       { VK_RMENU,             Qt::Key_Alt },  // Right
+       { VK_LMENU,             Qt::Key_Alt },  // Left
+//     { VK_RWIN,              Qt::Key_RSuper },
+//     { VK_LWIN,              Qt::Key_LSuper },
+       { VK_HELP,              Qt::Key_Help },
+#ifdef VK_PRINT
+       { VK_PRINT,             Qt::Key_Print },
+#endif
+       { VK_SNAPSHOT,          Qt::Key_Print },
+       { VK_CANCEL,            Qt::Key_Pause },
+       { VK_APPS,              Qt::Key_Menu },
+       { 0xBA,                 Qt::Key_Semicolon },
+       { 0xBC,                 Qt::Key_Comma },
+       { 0xBD,                 Qt::Key_Minus },
+       { 0xBE,                 Qt::Key_Period },
+       { 0xBF,                 Qt::Key_Slash },
+       { 0xBB,                 Qt::Key_Equal },
+       { 0xC0,                 Qt::Key_QuoteLeft },
+       { 0xDB,                 Qt::Key_BracketLeft },
+       { 0xDC,                 Qt::Key_Backslash },
+       { 0xDD,                 Qt::Key_BracketRight },
+       { 0xDE,                 Qt::Key_Apostrophe },
+       { 0xDF,                 Qt::Key_QuoteLeft },
+       { 0xE2,                 Qt::Key_Less },
+        { 0xffff, 0xffff}
+};
+
+
+static int mouse_x = 0;
+static int mouse_y = 0;
+static int mouse_relx = 0;
+static int mouse_rely = 0;
+static uint32 mouse_buttons = 0;
+   
+   
+void GLDrawClass::ProcessKeyUp(QKeyEvent *event)
+{
+  int key = event->key();
+  pushed_mod = event->nativeModifiers();
+  emu->key_up(key);
+  printf("Key up. Modifier = %08x", pushed_mod);
+}
+
+void GLDrawClass::ProcessKeyDown(QKeyEvent *event)
+{
+       int key = event->key();
+       pushed_mod = event->nativeModifiers();
+       emu->key_down(key, false);
+       
+}
+
+#if 0
+void OnMouseMotion(Q *event)
+{
+  // Need lock?
+  int x = AG_INT(1);
+  int y = AG_INT(2);
+  mouse_relx = AG_INT(3);
+  mouse_rely = AG_INT(4);
+  int buttons = AG_INT(5);
+
+  if((hScreenWidget != NULL) && (emu != NULL)){
+    //mouse_x = (x * emu->screen_width)  /  hScreenWidget->w;
+    //mouse_y = (y * emu->screen_height) /  hScreenWidget->h;
+    mouse_x = x;
+    mouse_y = y;
+  }
+  // Need Unlock?
+}
+
+void OnMouseButtonDown(AG_Event *event)
+{
+  // Need Lock?
+  int buttons = AG_INT(1);
+  switch (buttons){
+  case AG_MOUSE_NONE:
+    break;
+  case AG_MOUSE_LEFT:
+    mouse_buttons |= UI_MOUSE_LEFT;
+    break;
+  case AG_MOUSE_MIDDLE:
+    mouse_buttons |= UI_MOUSE_MIDDLE;
+    break;
+  case AG_MOUSE_RIGHT:
+    mouse_buttons |= UI_MOUSE_RIGHT;
+    break;
+  case AG_MOUSE_X1:
+    mouse_buttons |= UI_MOUSE_X1;
+    break;
+  case AG_MOUSE_X2:
+    mouse_buttons |= UI_MOUSE_X2;
+    break;
+  case AG_MOUSE_WHEELUP:
+    mouse_buttons |= UI_MOUSE_WHEELUP;
+    break;
+  case AG_MOUSE_WHEELDOWN:
+    mouse_buttons |= UI_MOUSE_WHEELDOWN;
+    break;
+  default:
+    break;
+  }
+  // Need Unlock?
+}
+
+void OnMouseButtonUp(AG_Event *event)
+{
+  // Need Lock?
+  int buttons = AG_INT(1);
+  switch (buttons){
+  case AG_MOUSE_NONE:
+    break;
+  case AG_MOUSE_LEFT:
+    mouse_buttons &= ~UI_MOUSE_LEFT;
+    break;
+  case AG_MOUSE_MIDDLE:
+    mouse_buttons &= ~UI_MOUSE_MIDDLE;
+    break;
+  case AG_MOUSE_RIGHT:
+    mouse_buttons &= ~UI_MOUSE_RIGHT;
+    break;
+  case AG_MOUSE_X1:
+    mouse_buttons &= ~UI_MOUSE_X1;
+    break;
+  case AG_MOUSE_X2:
+    mouse_buttons &= ~UI_MOUSE_X2;
+    break;
+  case AG_MOUSE_WHEELUP:
+    mouse_buttons &= ~UI_MOUSE_WHEELUP;
+    break;
+  case AG_MOUSE_WHEELDOWN:
+    mouse_buttons &= ~UI_MOUSE_WHEELDOWN;
+    break;
+  default:
+    break;
+  }
+}
+#endif
+
+extern "C"{   
+uint32 GetAsyncKeyState(uint32 vk)
+{
+   GLDrawClass *draw = emu->main_window_handle->getGraphicsView();
+   vk = vk & 0xff; // OK?
+   quint32 modstate;
+   
+   modstate =  draw->getModState();
+#if 0
+   switch(vk) {
+    case VK_LSHIFT:
+      if((modstate & ) != 0) return 0xffffffff;
+      break;
+    case VK_RSHIFT:
+      if((modstate & Qt::ShiftModifier) != 0) return 0xffffffff;
+      break;
+    case VK_LCONTROL:
+      if((modstate & Qt::ControlModifier) != 0) return 0xffffffff;
+      break;
+    case VK_RCONTROL:
+      if((modstate & Qt::ControlModifier) != 0) return 0xffffffff;
+      break;
+    case VK_LMENU:
+      if((modstate & Qt::AltModifier) != 0) return 0xffffffff;
+      break;
+    case VK_RMENU:
+      if((modstate & Qt::AltModifier) != 0) return 0xffffffff;
+      break;
+    default:
+      break;
+   }
+#endif
+   return 0;
+}
+
+uint8_t convert_AGKey2VK(int sym)
+{
+   uint32 n;
+   int i = 0;
+   do {
+      if(WindowsKeyMappings[i].agkey == sym) {
+          n = WindowsKeyMappings[i].vk;
+          return (uint8_t)n;
+      }
+      
+      i++;
+   } while(WindowsKeyMappings[i].vk != 0xffff);
+   return 0;
+}
+   
+}
+
+
+void EMU::initialize_input()
+{
+       // initialize status
+       memset(key_status, 0, sizeof(key_status));
+       memset(joy_status, 0, sizeof(joy_status));
+       memset(mouse_status, 0, sizeof(mouse_status));
+       
+       // initialize joysticks
+#if 0
+        joy_num = joyGetNumDevs();
+       for(int i = 0; i < joy_num && i < 2; i++) {
+               JOYCAPS joycaps;
+               if(joyGetDevCaps(i, &joycaps, sizeof(joycaps)) == JOYERR_NOERROR) {
+                       joy_mask[i] = (1 << joycaps.wNumButtons) - 1;
+               } else {
+                       joy_mask[i] = 0x0f; // 4buttons
+               }
+       }
+#else
+        joy_num = 0;
+#endif 
+       // mouse emulation is disenabled
+       mouse_enabled = false;
+       
+       // initialize keycode convert table
+       FILEIO* fio = new FILEIO();
+       if(fio->Fopen(bios_path(_T("keycode.cfg")), FILEIO_READ_BINARY)) {
+               fio->Fread(keycode_conv, sizeof(keycode_conv), 1);
+               fio->Fclose();
+       } else {
+               for(int i = 0; i < 256; i++) {
+                       keycode_conv[i] = i;
+               }
+       }
+       delete fio;
+       
+#ifdef USE_SHIFT_NUMPAD_KEY
+       // initialize shift+numpad conversion
+       memset(key_converted, 0, sizeof(key_converted));
+       key_shift_pressed = key_shift_released = false;
+#endif
+#ifdef USE_AUTO_KEY
+       // initialize autokey
+       autokey_buffer = new FIFO(65536);
+       autokey_buffer->clear();
+       autokey_phase = autokey_shift = 0;
+#endif
+       lost_focus = false;
+}
+
+void EMU::release_input()
+{
+       // release mouse
+       if(mouse_enabled) {
+               disenable_mouse();
+       }
+       
+#ifdef USE_AUTO_KEY
+       // release autokey buffer
+       if(autokey_buffer) {
+               autokey_buffer->release();
+               delete autokey_buffer;
+       }
+#endif
+}
+
+void EMU::update_input()
+{
+
+    int *keystat;
+    int i_c = 0;;
+   
+
+# ifdef USE_SHIFT_NUMPAD_KEY
+       // update numpad key status
+       if(key_shift_pressed && !key_shift_released) {
+               if(key_status[VK_SHIFT] == 0) {
+                       // shift key is newly pressed
+                       key_status[VK_SHIFT] = 0x80;
+#ifdef NOTIFY_KEY_DOWN
+                       vm->key_down(VK_SHIFT, false);
+#endif
+               }
+       } else if(!key_shift_pressed && key_shift_released) {
+               if(key_status[VK_SHIFT] != 0) {
+                       // shift key is newly released
+                       key_status[VK_SHIFT] = 0;
+#ifdef NOTIFY_KEY_DOWN
+                       vm->key_up(VK_SHIFT);
+#endif
+                       // check l/r shift
+                       if(!(GetAsyncKeyState(VK_LSHIFT) & 0x8000)) key_status[VK_LSHIFT] &= 0x7f;
+                       if(!(GetAsyncKeyState(VK_RSHIFT) & 0x8000)) key_status[VK_RSHIFT] &= 0x7f;
+                  
+               }
+       }
+       key_shift_pressed = key_shift_released = false;
+#endif
+       
+       // release keys
+#ifdef USE_AUTO_KEY
+       if(lost_focus && autokey_phase == 0) {
+#else
+       if(lost_focus) {
+#endif
+               // we lost key focus so release all pressed keys
+               for(int i = 0; i < 256; i++) {
+                       if(key_status[i] & 0x80) {
+                               key_status[i] &= 0x7f;
+#ifdef NOTIFY_KEY_DOWN
+                               if(!key_status[i]) {
+                                       vm->key_up(i);
+                               }
+#endif
+                       }
+               }
+       } else {
+               for(int i = 0; i < 256; i++) {
+                       if(key_status[i] & 0x7f) {
+                               key_status[i] = (key_status[i] & 0x80) | ((key_status[i] & 0x7f) - 1);
+#ifdef NOTIFY_KEY_DOWN
+                               if(!key_status[i]) {
+                                       vm->key_up(i);
+                               }
+#endif
+                       }
+               }
+       }
+       lost_focus = false;
+#if 0  
+       // update joystick status
+       memset(joy_status, 0, sizeof(joy_status));
+       for(int i = 0; i < joy_num && i < 2; i++) {
+               JOYINFOEX joyinfo;
+               joyinfo.dwSize = sizeof(JOYINFOEX);
+               joyinfo.dwFlags = JOY_RETURNALL;
+               if(joyGetPosEx(i, &joyinfo) == JOYERR_NOERROR) {
+                       if(joyinfo.dwYpos < 0x3fff) joy_status[i] |= 0x01;      // up
+                       if(joyinfo.dwYpos > 0xbfff) joy_status[i] |= 0x02;      // down
+                       if(joyinfo.dwXpos < 0x3fff) joy_status[i] |= 0x04;      // left
+                       if(joyinfo.dwXpos > 0xbfff) joy_status[i] |= 0x08;      // right
+                       joy_status[i] |= ((joyinfo.dwButtons & joy_mask[i]) << 4);
+               }
+       }
+#ifdef USE_KEY_TO_JOY
+       // emulate joystick #1 with keyboard
+       if(key_status[0x26]) joy_status[0] |= 0x01;     // up
+       if(key_status[0x28]) joy_status[0] |= 0x02;     // down
+       if(key_status[0x25]) joy_status[0] |= 0x04;     // left
+       if(key_status[0x27]) joy_status[0] |= 0x08;     // right
+#ifdef KEY_TO_JOY_BUTTON_U
+       if(key_status[KEY_TO_JOY_BUTTON_U]) joy_status[0] |= 0x01;
+#endif
+#ifdef KEY_TO_JOY_BUTTON_D
+       if(key_status[KEY_TO_JOY_BUTTON_D]) joy_status[0] |= 0x02;
+#endif
+#ifdef KEY_TO_JOY_BUTTON_L
+       if(key_status[KEY_TO_JOY_BUTTON_L]) joy_status[0] |= 0x04;
+#endif
+#ifdef KEY_TO_JOY_BUTTON_R
+       if(key_status[KEY_TO_JOY_BUTTON_R]) joy_status[0] |= 0x08;
+#endif
+#ifdef KEY_TO_JOY_BUTTON_1
+       if(key_status[KEY_TO_JOY_BUTTON_1]) joy_status[0] |= 0x10;
+#endif
+#ifdef KEY_TO_JOY_BUTTON_2
+       if(key_status[KEY_TO_JOY_BUTTON_2]) joy_status[0] |= 0x20;
+#endif
+#ifdef KEY_TO_JOY_BUTTON_3
+       if(key_status[KEY_TO_JOY_BUTTON_3]) joy_status[0] |= 0x40;
+#endif
+#ifdef KEY_TO_JOY_BUTTON_4
+       if(key_status[KEY_TO_JOY_BUTTON_4]) joy_status[0] |= 0x80;
+#endif
+#endif
+
+#endif
+       // update mouse status
+       memset(mouse_status, 0, sizeof(mouse_status));
+#if 0
+          if(mouse_enabled) {
+               // get current status
+               POINT pt;
+               GetCursorPos(&pt);
+               ScreenToClient(main_window_handle, &pt);
+               mouse_status[0]  = pt.x - display_width / 2;
+               mouse_status[1]  = pt.y - display_height / 2;
+               mouse_status[2]  = (GetAsyncKeyState(VK_LBUTTON) & 0x8000) ? 1 : 0;
+               mouse_status[2] |= (GetAsyncKeyState(VK_RBUTTON) & 0x8000) ? 2 : 0;
+               mouse_status[2] |= (GetAsyncKeyState(VK_MBUTTON) & 0x8000) ? 4 : 0;
+                move mouse cursor to the center of window
+               if(!(mouse_status[0] == 0 && mouse_status[1] == 0)) {
+                       pt.x = display_width / 2;
+                       pt.y = display_height / 2;
+               //      ClientToScreen(main_window_handle, &pt);
+               //      SetCursorPos(pt.x, pt.y);
+               }
+       }
+#endif
+
+#if 0
+#ifdef USE_AUTO_KEY
+       // auto key
+       switch(autokey_phase) {
+       case 1:
+               if(autokey_buffer && !autokey_buffer->empty()) {
+                       // update shift key status
+                       int shift = autokey_buffer->read_not_remove(0) & 0x100;
+                       if(shift && !autokey_shift) {
+                               key_down(VK_SHIFT, false);
+                       } else if(!shift && autokey_shift) {
+                               key_up(VK_SHIFT);
+                       }
+                       autokey_shift = shift;
+                       autokey_phase++;
+                       break;
+               }
+       case 3:
+               if(autokey_buffer && !autokey_buffer->empty()) {
+                       key_down(autokey_buffer->read_not_remove(0) & 0xff, false);
+               }
+               autokey_phase++;
+               break;
+       case USE_AUTO_KEY:
+               if(autokey_buffer && !autokey_buffer->empty()) {
+                       key_up(autokey_buffer->read_not_remove(0) & 0xff);
+               }
+               autokey_phase++;
+               break;
+       case USE_AUTO_KEY_RELEASE:
+               if(autokey_buffer && !autokey_buffer->empty()) {
+                       // wait enough while vm analyzes one line
+                       if(autokey_buffer->read() == 0xd) {
+                               autokey_phase++;
+                               break;
+                       }
+               }
+       case 30:
+               if(autokey_buffer && !autokey_buffer->empty()) {
+                       autokey_phase = 1;
+               } else {
+                       stop_auto_key();
+               }
+               break;
+       default:
+               if(autokey_phase) {
+                       autokey_phase++;
+               }
+       }
+#endif
+#endif
+       }
+
+
+
+#ifdef USE_SHIFT_NUMPAD_KEY
+static const int numpad_table[256] = {
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+//     0x00, 0x69, 0x63, 0x61, 0x67, 0x64, 0x68, 0x66, 0x62, 0x00, 0x00, 0x00, 0x00, 0x60, 0x6e, 0x00,
+       0x00, 0x69, 0x63, 0x61, 0x67, 0x64, 0x68, 0x66, 0x62, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, // remove shift + period
+       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, 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, 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, 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, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+#endif
+
+void EMU::key_down(int sym, bool repeat)
+{
+       bool keep_frames = false;
+       uint8 code;
+        code = convert_AGKey2VK(sym);
+   //printf("Key down %03x %03x\n", sym, code);
+#if 1
+        if(code == VK_SHIFT) {
+               if(GetAsyncKeyState(VK_LSHIFT) & 0x8000) key_status[VK_LSHIFT] = 0x80;
+               if(GetAsyncKeyState(VK_RSHIFT) & 0x8000) key_status[VK_RSHIFT] = 0x80;
+               if(!(key_status[VK_LSHIFT] || key_status[VK_RSHIFT])) key_status[VK_LSHIFT] = 0x80;
+       } else if(code == VK_CONTROL) {
+               if(GetAsyncKeyState(VK_LCONTROL) & 0x8000) key_status[VK_LCONTROL] = 0x80;
+               if(GetAsyncKeyState(VK_RCONTROL) & 0x8000) key_status[VK_RCONTROL] = 0x80;
+               if(!(key_status[VK_LCONTROL] || key_status[VK_RCONTROL])) key_status[VK_LCONTROL] = 0x80;
+       } else if(code == VK_MENU) {
+               if(GetAsyncKeyState(VK_LMENU) & 0x8000) key_status[VK_LMENU] = 0x80;
+               if(GetAsyncKeyState(VK_RMENU) & 0x8000) key_status[VK_RMENU] = 0x80;
+               if(!(key_status[VK_LMENU] || key_status[VK_RMENU])) key_status[VK_LMENU] = 0x80;
+       } else if(code == 0xf0) {
+               code = VK_CAPITAL;
+               keep_frames = true;
+       } else if(code == 0xf2) {
+               code = VK_KANA;
+               keep_frames = true;
+       } else if(code == 0xf3 || code == 0xf4) {
+               code = VK_KANJI;
+               keep_frames = true;
+       }
+#ifdef USE_SHIFT_NUMPAD_KEY
+       if(code == VK_SHIFT) {
+               key_shift_pressed = true;
+               return;
+       } else if(numpad_table[code] != 0) {
+               if(key_shift_pressed || key_shift_released) {
+                       key_converted[code] = 1;
+                       key_shift_pressed = true;
+                       code = numpad_table[code];
+               }
+       }
+#endif
+       if(!(code == VK_SHIFT || code == VK_CONTROL || code == VK_MENU)) {
+               code = keycode_conv[code];
+       }
+       
+#ifdef DONT_KEEEP_KEY_PRESSED
+       if(!(code == VK_SHIFT || code == VK_CONTROL || code == VK_MENU)) {
+               key_status[code] = KEY_KEEP_FRAMES;
+       } else
+#endif
+       key_status[code] = keep_frames ? KEY_KEEP_FRAMES : 0x80;
+#ifdef NOTIFY_KEY_DOWN
+       if(keep_frames) {
+               repeat = false;
+       }
+       vm->key_down(code, repeat);
+#endif
+#endif
+}
+
+void EMU::key_up(int sym)
+{
+       uint8 code;
+        code = convert_AGKey2VK(sym);
+   //printf("Key up %03x %03x\n", sym, code);
+#if 1
+   if(code == VK_SHIFT) {
+#ifndef USE_SHIFT_NUMPAD_KEY
+               if(!(GetAsyncKeyState(VK_LSHIFT) & 0x8000)) key_status[VK_LSHIFT] &= 0x7f;
+               if(!(GetAsyncKeyState(VK_RSHIFT) & 0x8000)) key_status[VK_RSHIFT] &= 0x7f;
+#endif
+       } else if(code == VK_CONTROL) {
+               if(!(GetAsyncKeyState(VK_LCONTROL) & 0x8000)) key_status[VK_LCONTROL] &= 0x7f;
+               if(!(GetAsyncKeyState(VK_RCONTROL) & 0x8000)) key_status[VK_RCONTROL] &= 0x7f;
+       } else if(code == VK_MENU) {
+               if(!(GetAsyncKeyState(VK_LMENU) & 0x8000)) key_status[VK_LMENU] &= 0x7f;
+               if(!(GetAsyncKeyState(VK_RMENU) & 0x8000)) key_status[VK_RMENU] &= 0x7f;
+       } else {
+          key_status[code] &= 0x7f;
+          vm->key_up(code);
+       }
+   
+#ifdef USE_SHIFT_NUMPAD_KEY
+       if(code == VK_SHIFT) {
+               key_shift_pressed = false;
+               key_shift_released = true;
+               return;
+       } else if(key_converted[code] != 0) {
+               key_converted[code] = 0;
+               code = numpad_table[code];
+       }
+   
+#endif
+       if(!(code == VK_SHIFT || code == VK_CONTROL || code == VK_MENU)) {
+               code = keycode_conv[code];
+       }
+       if(key_status[code]) {
+               key_status[code] &= 0x7f;
+#ifdef NOTIFY_KEY_DOWN
+               if(!key_status[code]) {
+                       vm->key_up(code);
+               }
+#endif
+       }
+#endif
+}
+
+#ifdef USE_BUTTON
+void EMU::press_button(int num)
+{
+#if 1
+       int code = buttons[num].code;
+       
+       if(code) {
+               key_down(code, false);
+               key_status[code] = KEY_KEEP_FRAMES;
+       } else {
+               // code=0: reset virtual machine
+               vm->reset();
+       }
+#endif
+}
+#endif
+
+void EMU::enable_mouse()
+{
+       // enable mouse emulation
+       if(!mouse_enabled) {
+#if 0
+               // hide mouse cursor
+               ShowCursor(FALSE);
+               // move mouse cursor to the center of window
+               POINT pt;
+               pt.x = display_width / 2;
+               pt.y = display_height / 2;
+               ClientToScreen(main_window_handle, &pt);
+               SetCursorPos(pt.x, pt.y);
+#endif
+       }
+       mouse_enabled = true;
+
+}
+
+
+
+void EMU::disenable_mouse()
+{
+#if 0
+       // disenable mouse emulation
+       if(mouse_enabled) {
+               ShowCursor(TRUE);
+       }
+#endif
+      mouse_enabled = false;
+}
+
+void EMU::toggle_mouse()
+{
+       // toggle mouse enable / disenable
+       if(mouse_enabled) {
+               disenable_mouse();
+       } else {
+               enable_mouse();
+       }
+}
+
+#ifdef USE_AUTO_KEY
+static const int autokey_table[256] = {
+       // 0x100: shift
+       // 0x200: kana
+       // 0x400: alphabet
+       // 0x800: ALPHABET
+       0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x00d,0x000,0x000,0x00d,0x000,0x000,
+       0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
+       0x020,0x131,0x132,0x133,0x134,0x135,0x136,0x137,0x138,0x139,0x1ba,0x1bb,0x0bc,0x0bd,0x0be,0x0bf,
+       0x030,0x031,0x032,0x033,0x034,0x035,0x036,0x037,0x038,0x039,0x0ba,0x0bb,0x1bc,0x1bd,0x1be,0x1bf,
+       0x0c0,0x441,0x442,0x443,0x444,0x445,0x446,0x447,0x448,0x449,0x44a,0x44b,0x44c,0x44d,0x44e,0x44f,
+       0x450,0x451,0x452,0x453,0x454,0x455,0x456,0x457,0x458,0x459,0x45a,0x0db,0x0dc,0x0dd,0x0de,0x1e2,
+       0x1c0,0x841,0x842,0x843,0x844,0x845,0x846,0x847,0x848,0x849,0x84a,0x84b,0x84c,0x84d,0x84e,0x84f,
+       0x850,0x851,0x852,0x853,0x854,0x855,0x856,0x857,0x858,0x859,0x85a,0x1db,0x1dc,0x1dd,0x1de,0x000,
+       0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
+       0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
+       // kana -->
+       0x000,0x3be,0x3db,0x3dd,0x3bc,0x3bf,0x330,0x333,0x345,0x334,0x335,0x336,0x337,0x338,0x339,0x35a,
+       0x2dc,0x233,0x245,0x234,0x235,0x236,0x254,0x247,0x248,0x2ba,0x242,0x258,0x244,0x252,0x250,0x243,
+       0x251,0x241,0x25a,0x257,0x253,0x255,0x249,0x231,0x2bc,0x24b,0x246,0x256,0x232,0x2de,0x2bd,0x24a,
+       0x24e,0x2dd,0x2bf,0x24d,0x237,0x238,0x239,0x24f,0x24c,0x2be,0x2bb,0x2e2,0x230,0x259,0x2c0,0x2db,
+       // <--- kana
+       0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,
+       0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000
+};
+
+void EMU::start_auto_key()
+{
+#if 0
+        stop_auto_key();
+       
+       if(OpenClipboard(NULL)) {
+               HANDLE hClip = GetClipboardData(CF_TEXT);
+               if(hClip) {
+                       autokey_buffer->clear();
+                       char* buf = (char*)GlobalLock(hClip);
+                       int size = strlen(buf), prev_kana = 0;
+                       for(int i = 0; i < size; i++) {
+                               int code = buf[i] & 0xff;
+                               if((0x81 <= code && code <= 0x9f) || 0xe0 <= code) {
+                                       i++;    // kanji ?
+                                       continue;
+                               } else if(code == 0xa) {
+                                       continue;       // cr-lf
+                               }
+                               if((code = autokey_table[code]) != 0) {
+                                       int kana = code & 0x200;
+                                       if(prev_kana != kana) {
+                                               autokey_buffer->write(0xf2);
+                                       }
+                                       prev_kana = kana;
+#if defined(USE_AUTO_KEY_NO_CAPS)
+                                       if((code & 0x100) && !(code & (0x400 | 0x800))) {
+#elif defined(USE_AUTO_KEY_CAPS)
+                                       if(code & (0x100 | 0x800)) {
+#else
+                                       if(code & (0x100 | 0x400)) {
+#endif
+                                               autokey_buffer->write((code & 0xff) | 0x100);
+                                       } else {
+                                               autokey_buffer->write(code & 0xff);
+                                       }
+                               }
+                       }
+                       if(prev_kana) {
+                               autokey_buffer->write(0xf2);
+                       }
+                       GlobalUnlock(hClip);
+                       
+                       autokey_phase = 1;
+                       autokey_shift = 0;
+               }
+               CloseClipboard();
+       }
+#endif
+}
+
+void EMU::stop_auto_key()
+{
+#if 1
+        if(autokey_shift) {
+               key_up(VK_SHIFT);
+       }
+       autokey_phase = autokey_shift = 0;
+#endif
+}
+          
+          
+#endif
diff --git a/source/src/qt/common/qt_input.h b/source/src/qt/common/qt_input.h
new file mode 100644 (file)
index 0000000..73f5691
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * 
+ */
+
+#ifndef _AGAR_INPUT_H_
+#define _AGAR_INPUT_H_
+
+#include <Qt>
+#include <QKeyEvent>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+   // Include from gui/drv_wgl_keymaps.h , libagar.
+enum {
+   VK_F1   = 0x70,
+   VK_F2   = 0x71,
+   VK_F3   = 0x72,
+   VK_F4   = 0x73,
+   VK_F5   = 0x74,
+   VK_F6   = 0x75,
+   VK_F7   = 0x76,
+   VK_F8   = 0x77,
+   VK_F9   = 0x78,
+   VK_F10  = 0x79,
+   VK_F11  = 0x7a,
+   VK_F12  = 0x7b,
+   VK_F13  = 0x7c,
+   VK_F14    = 0x7d,
+   VK_F15    = 0x7e,
+   VK_BACK   = 0x08,
+   VK_TAB    = 0x09,
+   VK_CLEAR  = 0x0c,
+   VK_RETURN = 0x0d,
+   VK_PAUSE  = 0x13,
+   VK_ESCAPE = 0x1b,
+   VK_SPACE  = 0x20,
+   VK_DELETE = 0x2e,
+   VK_UP     = 0x26,
+   VK_DOWN   = 0x28,
+   VK_RIGHT  = 0x27,
+   VK_LEFT   = 0x25,
+   VK_INSERT = 0x2d,
+   VK_HOME = 0x24,
+   VK_END = 0x23,
+   VK_PRIOR = 0x21,
+   VK_NEXT = 0x22,
+   VK_NUMPAD0 = 0x60,
+   VK_NUMPAD1 = 0x61,
+   VK_NUMPAD2 = 0x62,
+   VK_NUMPAD3 = 0x63,
+   VK_NUMPAD4 = 0x64,
+   VK_NUMPAD5 = 0x65,
+   VK_NUMPAD6 = 0x66,
+   VK_NUMPAD7 = 0x67,
+   VK_NUMPAD8 = 0x68,
+   VK_NUMPAD9 = 0x69,
+   VK_DECIMAL = 0x6e,
+   VK_DIVIDE = 0x6f,
+   VK_MULTIPLY = 0x6a,
+   VK_SUBTRACT = 0x6d,
+   VK_ADD = 0x6b,
+   VK_NUMLOCK = 0x90,
+   VK_CAPITAL = 0x14,
+   VK_SCROLL = 0x91,
+   VK_SHIFT = 0x10,
+   VK_LSHIFT = 0xa0,
+   VK_RSHIFT = 0xa1,
+   VK_LCONTROL = 0xa2,
+   VK_RCONTROL = 0xa3,
+   VK_RMENU = 0xa5,
+   VK_LMENU = 0xa4,
+   VK_RWIN = 0x5c,
+   VK_LWIN = 0x5b,
+   VK_HELP = 0x2f,     
+   VK_PRINT = 0x2a,
+   VK_SNAPSHOT = 0x2c,
+   VK_CANCEL = 0x03,
+   VK_APPS = 0x5d,
+   VK_KANA = 0x15,
+   VK_KANJI = 0x19,
+   VK_CONTROL = 0x11,
+   VK_MENU = 0x12
+};
+
+   
+
+struct WIndowsKeyTable {
+   uint32_t vk;
+   uint32_t agkey;
+};
+   
+extern const struct WIndowsKeyTable  WindowsKeyMappings[];
+extern uint8_t convert_QTKey2VK(int sym);
+extern uint32 GetAsyncKeyState(uint32 vk);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
index c72dce0..c05b61e 100644 (file)
@@ -14,7 +14,7 @@
 #include "common.h"\r
 #include "fileio.h"\r
 #include "emu.h"\r
-//#include "agar_main.h"\r
+#include "emu_utils.h"\r
 #include "menuclasses.h"\r
 //#include "agar_gldraw.h"\r
 #include "qt_main.h"\r
@@ -62,19 +62,24 @@ int get_interval()
        return interval;\r
 }\r
 \r
-void EmuThreadClass::run()\r
+\r
+\r
+//void EmuThreadClass::run()\r
+void EmuThread(void *p)\r
 {\r
    int total_frames = 0, draw_frames = 0, skip_frames = 0;\r
    DWORD next_time = 0;\r
    DWORD update_fps_time = 0;\r
    bool prev_skip = false;\r
    bRunEmuThread = true;\r
-      \r
+   class Ui_MainWindow *method = (class Ui_MainWindow *)p;\r
+   \r
     do {\r
-    \r
     if(emu) {\r
+//      printf("%d %08x\n", SDL_GetTicks(), method);    \r
       int interval = 0, sleep_period = 0;                      \r
       // drive machine\r
+\r
       int run_frames = emu->run();\r
       total_frames += run_frames;\r
        \r
@@ -97,7 +102,7 @@ void EmuThreadClass::run()
       if(next_time > timeGetTime()) {\r
        // update window if enough time\r
        draw_frames += emu->draw_screen();\r
-       //emu->update_screen(hScreenWidget);// Okay?\r
+       if(method) emu->update_screen(method->getGraphicsView());// Okay?\r
        skip_frames = 0;\r
        \r
        // sleep 1 frame priod if need\r
@@ -108,15 +113,16 @@ void EmuThreadClass::run()
       } else if(++skip_frames > MAX_SKIP_FRAMES) {\r
        // update window at least once per 10 frames\r
        draw_frames += emu->draw_screen();\r
-       //emu->update_screen(hScreenWidget);// Okay?\r
+       if(method) emu->update_screen(method->getGraphicsView());// Okay?\r
+//     emu->update_screen(hScreenWidget);// Okay?\r
        //printf("EMU::Updated Frame %d\n", AG_GetTicks());\r
        skip_frames = 0;\r
        next_time = timeGetTime();\r
       }\r
       SDL_Delay(sleep_period);\r
       if(bRunEmuThread != true) {\r
-       exit();\r
-       //return;\r
+       //exit(0);\r
+       return;\r
       }\r
       // calc frame rate\r
       DWORD current_time = timeGetTime();\r
@@ -131,7 +137,7 @@ void EmuThreadClass::run()
          sprintf(buf, _T("%s - %d fps (%d %%)"), DEVICE_NAME, draw_frames, ratio);\r
        }\r
        message = buf;\r
-       emit valueChanged(message);\r
+       //emit Changed(message);\r
        update_fps_time += 1000;\r
        total_frames = draw_frames = 0;\r
       }\r
@@ -141,7 +147,7 @@ void EmuThreadClass::run()
     } else {\r
       SDL_Delay(10);\r
       if(bRunEmuThread != true) {\r
-       exit();\r
+       return;\r
       }\r
     }\r
   } while(1);\r
@@ -151,16 +157,20 @@ void JoyThreadClass::run()
 {\r
   bRunJoyThread = TRUE;\r
   do {\r
+//     rMainWindow->getGraphicsView()->updateGL();\r
     // Event Handling for joystick\r
     SDL_Delay(10); // Right?\r
   } while(1);\r
 }\r
 \r
-static EmuThreadClass *hEmuThread;\r
-static JoyThreadClass *hJoyThread;\r
+//EmuThreadClass *hEmuThread;\r
+SDL_Thread *hEmuThread;\r
+JoyThreadClass *pJoyThread;\r
+//QThread *hEmuThread;\r
+QThread *hJoyThread;\r
 \r
 // Important Flags\r
-//AGAR_CPUID *pCpuID;\r
+AGAR_CPUID *pCpuID;\r
 \r
 //#ifdef USE_ICONV\r
 #include <iconv.h>\r
@@ -330,13 +340,15 @@ extern "C" {
     bRunEmuThread = false;\r
     save_config();\r
     if(hEmuThread != NULL) {\r
-      hEmuThread->terminate();\r
+      //hEmuThread->terminate();\r
 //    do {\r
-       SDL_Delay(50);\r
+//     SDL_Delay(50);\r
 //     if(hEmuThread->finished()) break;\r
 //      } while(1);\r
-      delete hEmuThread;\r
-//      hEmuThread = NULL;\r
+      //delete hEmuThread;\r
+       SDL_WaitThread(hEmuThread, NULL);\r
+      \r
+      hEmuThread = NULL;\r
     }\r
     bRunJoyThread = false;\r
     if(hJoyThread != NULL) {\r
@@ -387,7 +399,7 @@ extern "C" {
 }  // extern "C"\r
 \r
 \r
-bool InitInstance(void)\r
+bool InitInstance(int argc, char *argv[])\r
 {\r
   rMainWindow = new Ui_MainWindow();\r
   rMainWindow->setupUi();\r
@@ -653,8 +665,9 @@ int MainLoop(int argc, char *argv[])
    \r
          SDL_InitSubSystem(SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);\r
          AGAR_DebugLog(AGAR_LOG_DEBUG, "Audio and JOYSTICK subsystem was initialised.");\r
+         GuiMain = new QApplication(argc, argv);\r
 \r
-         InitInstance();\r
+         InitInstance(argc, argv);\r
          AGAR_DebugLog(AGAR_LOG_DEBUG, "InitInstance() OK.");\r
 //       if(agDriverSw && AG_UsingSDL(NULL)) {\r
 //         SDL_Init(SDL_INIT_VIDEO);\r
@@ -676,7 +689,7 @@ int MainLoop(int argc, char *argv[])
          screen_mode_count++;\r
        } while(1);\r
        \r
-#if 0  \r
+#if 0\r
        // restore screen mode\r
        if(config.window_mode >= 0 && config.window_mode < MAX_WINDOW) {\r
                PostMessage(hWnd, WM_COMMAND, ID_SCREEN_WINDOW1 + config.window_mode, 0L);\r
@@ -694,9 +707,10 @@ int MainLoop(int argc, char *argv[])
        //ImmAssociateContext(hWnd, 0);\r
        \r
        // initialize emulation core\r
+        rMainWindow->getWindow()->show();\r
        emu = new EMU(rMainWindow, rMainWindow->getGraphicsView());\r
        emu->set_display_size(WINDOW_WIDTH, WINDOW_HEIGHT, true);\r
-        set_window(rMainWindow->getWindow(), config.window_mode);\r
+        //set_window(rMainWindow->getWindow(), config.window_mode);\r
 \r
 \r
 #ifdef SUPPORT_DRAG_DROP\r
@@ -718,17 +732,24 @@ int MainLoop(int argc, char *argv[])
        \r
        // main loop\r
        // Launch Emulator loop\r
-       bRunEmuThread = false;\r
-       hEmuThread = new EmuThreadClass();\r
-        QObject::connect(hEmuThread, SIGNAL(messageChanged(QString)), rMainWindow->getStatusBar(), SLOT(message(QString)));\r
-       hEmuThread->run();\r
+#if 1\r
+        bRunEmuThread = false;\r
+       hEmuThread = SDL_CreateThread(EmuThread, (void *)rMainWindow);\r
+        //hEmuThread = new QThread();\r
+        //pEmuThread->property("Emu Thread");\r
+        //pEmuThread->moveToThread(hEmuThread);\r
+        //QObject::connect(hEmuThread, SIGNAL(messageChanged(QString)), rMainWindow->getStatusBar(), SLOT(message(QString)));\r
+       //hEmuThread->start();\r
        // Launch JoystickClass\r
        bRunJoyThread = false;\r
-       hJoyThread = new JoyThreadClass();\r
-       hJoyThread->run();\r
-       \r
+       //pJoyThread = new JoyThreadClass();\r
+        //hJoyThread = new QThread();\r
+        //hJoyThread->property("SDL Joy Thread");\r
+        //pJoyThread->moveToThread(hJoyThread);\r
+       //hJoyThread->start();\r
+        //QMetaObject::invokeMethod(pEmuThread, "doWork");\r
+#endif\r
        //AG_EventLoop(); // Right? maybe unusable Joystick.\r
-        GuiMain = new QApplication(argc, argv);\r
         GuiMain->exec();\r
        return 0;\r
 }\r
@@ -778,6 +799,8 @@ void set_window(QMainWindow *hWnd, int mode)
                // set screen size to emu class\r
                emu->suspend();\r
                emu->set_display_size(width, height, true);\r
+               if(rMainWindow) rMainWindow->getGraphicsView()->resize(width, height);\r
+\r
        } else if(!now_fullscreen) {\r
                // fullscreen\r
                int width = (mode == -1) ? desktop_width : screen_mode_width[mode - MAX_WINDOW];\r
@@ -791,6 +814,8 @@ void set_window(QMainWindow *hWnd, int mode)
                        \r
                        // set screen size to emu class\r
                emu->set_display_size(width, height, false);\r
+               \r
+              if(rMainWindow) rMainWindow->getGraphicsView()->resize(width, height);\r
        }\r
 }\r
 \r
index e9c5150..9d7fdfd 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <string>
 #include <qthread.h>
+#include <SDL/SDL.h>
 #include "sdl_cpuid.h"
 #include "simd_types.h"
 #include "common.h"
@@ -31,16 +32,34 @@ extern bool bRunJoyThread;
 #define MAX_HISTORY 8
 #endif
 
+#ifndef UPDATE_HISTORY
+#define UPDATE_HISTORY(path, recent) { \
+       int no = MAX_HISTORY - 1; \
+       for(int i = 0; i < MAX_HISTORY; i++) { \
+               if(strcmp(recent[i], path) == 0) { \
+                       no = i; \
+                       break; \
+               } \
+       } \
+       for(int i = no; i > 0; i--) { \
+               strcpy(recent[i], recent[i - 1]); \
+       } \
+       strcpy(recent[0], path); \
+}
+#endif
+
+
+
 
 class EmuThreadClass : public QThread {
+ private:
+// public slots:
  public:
    void run();
-signals:
-   void valueChanged(QString);
 }; 
 
-class JoyThreadClass : public QThread {
- public:
+class JoyThreadClass : public QObject {
+ public slots:
    void run();
 };
 
@@ -51,6 +70,6 @@ extern void get_short_filename(_TCHAR *dst, _TCHAR *file, int maxlen);
 extern void set_window(QMainWindow * hWnd, int mode);
 
 // Important Flags
-AGAR_CPUID *pCpuID;
+extern AGAR_CPUID *pCpuID;
 
 #endif
index c66ab71..abba45e 100644 (file)
@@ -128,8 +128,6 @@ void EMU::set_display_size(int width, int height, bool window_mode)
    bool stretch_changed = false;
    int prev_stretched_width = stretched_width;
    int prev_stretched_height = stretched_height;
-   AGAR_DebugLog(AGAR_LOG_DEBUG, "Set display size");
-   AGAR_DebugLog(AGAR_LOG_DEBUG, "       to %d x %d", width, height);
    
    if(width != -1 && (display_width != width || display_height != height)) {
       display_width = width;
@@ -142,11 +140,7 @@ void EMU::set_display_size(int width, int height, bool window_mode)
    //}
    //display_size_changed = stretch_changed = true;
 //}
-
-   if(main_window_handle != NULL) {
-      set_window(main_window_handle->getWindow(), window_mode);
-   }
-
+   
 #ifdef USE_SCREEN_ROTATE
        if(config.monitor_type) {
                
@@ -224,6 +218,13 @@ void EMU::set_display_size(int width, int height, bool window_mode)
       stretch_pow_y = new_pow_y;
       stretch_changed = true;
    }
+   if(!stretch_changed && !display_size_changed) return;
+   AGAR_DebugLog(AGAR_LOG_DEBUG, "Set display size");
+   AGAR_DebugLog(AGAR_LOG_DEBUG, "       to %d x %d", width, height);
+
+   if(main_window_handle != NULL) {
+//      set_window(main_window_handle->getWindow(), window_mode);
+   }
    
      if(main_window_handle != NULL) {
        main_window_handle->getGraphicsView()->resize(display_width, display_height);
@@ -281,9 +282,9 @@ int EMU::draw_screen()
 {
 #if 1
         // don't draw screen before new screen size is applied to buffers
-       if(screen_size_changed) {
-               return 0;
-       }
+//     if(screen_size_changed) {
+//             return 0;
+//     }
        
        // check avi file recording timing
 //     if(now_rec_video && rec_video_run_frames <= 0) {
@@ -294,7 +295,7 @@ int EMU::draw_screen()
        
        // draw screen
        vm->draw_screen();
-       
+        printf("Draw Screen %d\n", SDL_GetTicks());
        // screen size was changed in vm->draw_screen()
        if(screen_size_changed) {
                // unlock offscreen surface
@@ -627,9 +628,9 @@ scrntype* EMU::screen_buffer(int y)
 void EMU::update_screen(GLDrawClass *glv)
 {
    // UpdateScreen
-//   if(glv != NULL) {
-//     glv->;
-//   }
+   if(glv != NULL) {
+       glv->update();
+   }
        
    
 
index 95fae11..e900880 100644 (file)
@@ -14,32 +14,32 @@ void Ui_MainWindow::ConfigCpuSpeed(QMainWindow *MainWindow)
   actionSpeed_x1->setObjectName(QString::fromUtf8("actionSpeed_x1"));
   actionSpeed_x1->setCheckable(true);
   actionSpeed_x1->setChecked(true);
-  actionSpeed_x1->binds.setValue1(0);
-  QObject::connect(actionSpeed_x1, SIGNAL(triggered()), actionSpeed_x1, SLOT(OnCpuPower())); // OK?  
+  actionSpeed_x1->binds->setValue1(0);
+  //QObject::connect(actionSpeed_x1, SIGNAL(triggered()), actionSpeed_x1, SLOT(OnCpuPower())); // OK?  
   
   actionSpeed_x2 = new Action_Control(MainWindow);
   actionSpeed_x2->setObjectName(QString::fromUtf8("actionSpeed_x2"));
   actionSpeed_x2->setCheckable(true);
-  actionSpeed_x2->binds.setValue1(1);
-  QObject::connect(actionSpeed_x2, SIGNAL(triggered()), actionSpeed_x2, SLOT(OnCpuPower())); // OK?  
+  actionSpeed_x2->binds->setValue1(1);
+  //QObject::connect(actionSpeed_x2, SIGNAL(triggered()), actionSpeed_x2, SLOT(OnCpuPower())); // OK?  
   
   actionSpeed_x4 = new Action_Control(MainWindow);
   actionSpeed_x4->setObjectName(QString::fromUtf8("actionSpeed_x4"));
   actionSpeed_x4->setCheckable(true);
-  actionSpeed_x4->binds.setValue1(2);
-  QObject::connect(actionSpeed_x4, SIGNAL(triggered()), actionSpeed_x4, SLOT(OnCpuPower())); // OK?  
+  actionSpeed_x4->binds->setValue1(2);
+  //QObject::connect(actionSpeed_x4, SIGNAL(triggered()), actionSpeed_x4, SLOT(OnCpuPower())); // OK?  
   
   actionSpeed_x8 = new Action_Control(MainWindow);
   actionSpeed_x8->setObjectName(QString::fromUtf8("actionSpeed_x8"));
   actionSpeed_x8->setCheckable(true);
-  actionSpeed_x8->binds.setValue1(3);
-  QObject::connect(actionSpeed_x8, SIGNAL(triggered()), actionSpeed_x8, SLOT(OnCpuPower())); // OK?  
+  actionSpeed_x8->binds->setValue1(3);
+  //QObject::connect(actionSpeed_x8, SIGNAL(triggered()), actionSpeed_x8, SLOT(OnCpuPower())); // OK?  
   
   actionSpeed_x16 = new Action_Control(MainWindow);
   actionSpeed_x16->setObjectName(QString::fromUtf8("actionSpeed_x16"));
   actionSpeed_x16->setCheckable(true);
-  actionSpeed_x16->binds.setValue1(4);
-  QObject::connect(actionSpeed_x16, SIGNAL(triggered()), actionSpeed_x16, SLOT(OnCpuPower())); // OK?  
+  actionSpeed_x16->binds->setValue1(4);
+  //QObject::connect(actionSpeed_x16, SIGNAL(triggered()), actionSpeed_x16, SLOT(OnCpuPower())); // OK?  
 
 }
 
@@ -47,58 +47,58 @@ void Ui_MainWindow::ConfigControlMenu(QMainWindow *MainWindow)
 {
   actionReset = new Action_Control(MainWindow);
   actionReset->setObjectName(QString::fromUtf8("actionReset"));
-  QObject::connect(actionReset, SIGNAL(triggered()), actionReset, SLOT(OnReset())); // OK?  
+  //QObject::connect(actionReset, SIGNAL(triggered()), actionReset->binds, SLOT(OnReset())); // OK?  
 
   actionSpecial_Reset = new Action_Control(MainWindow);
   actionSpecial_Reset->setObjectName(QString::fromUtf8("actionSpecial_Reset"));
-  QObject::connect(actionSpecial_Reset, SIGNAL(triggered()), actionSpecial_Reset, SLOT(OnSpecialReset())); // OK?  
+  //QObject::connect(actionSpecial_Reset, SIGNAL(triggered()), actionSpecial_Reset->binds, SLOT(OnSpecialReset())); // OK?  
 
   actionExit_Emulator = new Action_Control(MainWindow);
   actionExit_Emulator->setObjectName(QString::fromUtf8("actionExit_Emulator"));
-  QObject::connect(actionExit_Emulator, SIGNAL(triggered()), MainWindow, SLOT(OnGuiExit())); // OK?  
+  //QObject::connect(actionExit_Emulator, SIGNAL(triggered()), MainWindow, SLOT(OnGuiExit())); // OK?  
 
   actionPaste_from_Clipboard = new Action_Control(MainWindow);
   actionPaste_from_Clipboard->setObjectName(QString::fromUtf8("actionPaste_from_Clipboard"));
-  QObject::connect(actionPaste_from_Clipboard, SIGNAL(triggered()),
-                    actionPaste_from_Clipboard, SLOT(OnStartAutoKey())); // OK?  
+  //QObject::connect(actionPaste_from_Clipboard, SIGNAL(triggered()),
+//                  actionPaste_from_Clipboard->binds, SLOT(OnStartAutoKey())); // OK?  
 
   actionStop_Pasting = new Action_Control(MainWindow);
   actionStop_Pasting->setObjectName(QString::fromUtf8("actionStop_Pasting"));
-  QObject::connect(actionStop_Pasting, SIGNAL(triggered()),
-                  actionStop_Pasting, SLOT(OnStopAutoKey())); // OK?  
+  //QObject::connect(actionStop_Pasting, SIGNAL(triggered()),
+//                actionStop_Pasting->binds, SLOT(OnStopAutoKey())); // OK?  
   
   actionSave_State = new Action_Control(MainWindow);
   actionSave_State->setObjectName(QString::fromUtf8("actionSave_State"));
-  QObject::connect(actionSave_State, SIGNAL(triggered()),
-                  actionSave_State, SLOT(OnSaveState())); // OK?  
+  //QObject::connect(actionSave_State, SIGNAL(triggered()),
+//                actionSave_State->binds, SLOT(OnSaveState())); // OK?  
 
   actionLoad_State = new Action_Control(MainWindow);
   actionLoad_State->setObjectName(QString::fromUtf8("actionLoad_State"));
-  QObject::connect(actionLoad_State, SIGNAL(triggered()),
-                  actionLoad_State, SLOT(OnLoadState())); // OK?  
+  //QObject::connect(actionLoad_State, SIGNAL(triggered()),
+//                actionLoad_State->binds, SLOT(OnLoadState())); // OK?  
 
   actionDebugger_1 = new Action_Control(MainWindow);
   actionDebugger_1->setObjectName(QString::fromUtf8("actionDebugger_1"));
-  actionDebugger_1->binds.setValue1(0);
-  QObject::connect(actionDebugger_1, SIGNAL(triggered()),
-                  actionDebugger_1, SLOT(OnOpenDebugger())); // OK?  
+  actionDebugger_1->binds->setValue1(0);
+  //QObject::connect(actionDebugger_1, SIGNAL(triggered()),
+//                actionDebugger_1->binds, SLOT(OnOpenDebugger())); // OK?  
   
   actionDebugger_2 = new Action_Control(MainWindow);
   actionDebugger_2->setObjectName(QString::fromUtf8("actionDebugger_2"));
-  actionDebugger_2->binds.setValue1(1);
-  QObject::connect(actionDebugger_2, SIGNAL(triggered()),
-                  actionDebugger_2, SLOT(OnOpenDebugger())); // OK?  
+  actionDebugger_2->binds->setValue1(1);
+  //QObject::connect(actionDebugger_2, SIGNAL(triggered()),
+//                actionDebugger_2->binds, SLOT(OnOpenDebugger())); // OK?  
   
   actionDebugger_3 = new Action_Control(MainWindow);
-  actionDebugger_3->binds.setValue1(2);
+  actionDebugger_3->binds->setValue1(2);
   actionDebugger_3->setObjectName(QString::fromUtf8("actionDebugger_3"));
-  QObject::connect(actionDebugger_3, SIGNAL(triggered()),
-                  actionDebugger_3, SLOT(OnOpenDebugger())); // OK?  
+  //QObject::connect(actionDebugger_3, SIGNAL(triggered()),
+//                actionDebugger_3->binds, SLOT(OnOpenDebugger())); // OK?  
 
   actionClose_Debuggers = new Action_Control(MainWindow);
   actionClose_Debuggers->setObjectName(QString::fromUtf8("actionClose_Debuggers"));
-  QObject::connect(actionClose_Debuggers, SIGNAL(triggered()),
-                  actionClose_Debuggers, SLOT(OnCloseDebugger())); // OK?  
+  //QObject::connect(actionClose_Debuggers, SIGNAL(triggered()),
+//                actionClose_Debuggers->binds, SLOT(OnCloseDebugger())); // OK?  
 
   ConfigCpuSpeed(MainWindow);
 }
@@ -169,3 +169,4 @@ void Ui_MainWindow::retranslateControlMenu(QMainWindow *MainWindow, const char *
   menuDebugger->setTitle(QApplication::translate("MainWindow", "Debugger", 0, QApplication::UnicodeUTF8));
 }
 
+QT_END_NAMESPACE
\ No newline at end of file
index 9836423..963ec4a 100644 (file)
@@ -30,8 +30,7 @@ void Ui_MainWindow::setupUi(void)
         if (MainWindow->objectName().isEmpty())
             MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
         MainWindow->resize(1288, 862);
-
-
+   
        ConfigControlMenu(MainWindow);
        
         actionInsert_FD1 = new QAction(MainWindow);
@@ -180,7 +179,7 @@ void Ui_MainWindow::setupUi(void)
         centralwidget = new QWidget(MainWindow);
         centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
        
-        graphicsView = new GLDrawClass(centralwidget);
+        graphicsView = new GLDrawClass(MainWindow);
         graphicsView->setObjectName(QString::fromUtf8("graphicsView"));
         graphicsView->setGeometry(QRect(0, 0, 1280, 800));
        
@@ -217,8 +216,7 @@ void Ui_MainWindow::setupUi(void)
         //menuQD0->setObjectName(QString::fromUtf8("menuQD0"));
         //menuWrite_Protection_QD0 = new QMenu(menuQD0);
         //menuWrite_Protection_QD0->setObjectName(QString::fromUtf8("menuWrite_Protection_QD0"));
-        //menuCMT = new QMenu(menubar);
-       
+        menuCMT = new QMenu(menubar);
         menuCMT->setObjectName(QString::fromUtf8("menuCMT"));
         menuWrite_Protection_CMT = new QMenu(menuCMT);
         menuWrite_Protection_CMT->setObjectName(QString::fromUtf8("menuWrite_Protection_CMT"));
@@ -384,6 +382,9 @@ void Ui_MainWindow::setupUi(void)
        QObject::connect(MainWindow, SIGNAL(destroyed()), MainWindow, SLOT(close()));
 
         QMetaObject::connectSlotsByName(MainWindow);
+        menubar->show();
+        graphicsView->show();
+//        this->show();
 } // setupUi
 
 void Ui_MainWindow::retranslateUi(QMainWindow *MainWindow)
index beac5a0..d8b5aea 100644 (file)
@@ -33,14 +33,27 @@ QT_BEGIN_NAMESPACE
 extern class EMU* emu;
 
 typedef class Object_Menu_Control: public QObject {
-    Q_OBJECT
-    Q_DISABLE_COPY(Object_Menu_Control)
+// Do not add Q_OBJECT macro.
+// See: http://www.qtcentre.org/threads/37731-QOBJECT-and-undefined-reference-to-vtable-errors
+//    Q_OBJECT
+//    Q_DISABLE_COPY(Object_Menu_Control)
 public:
-    explicit Object_Menu_Control(QObject *parent = 0);
-
-signals:
-
-public slots: // [1]
+//    explicit Object_Menu_Control(QObject *parent = 0);
+   Object_Menu_Control(QObject *parent) : QObject(parent){
+      bindValue = 0;
+   }
+   Object_Menu_Control() {}
+   // Virtual Functions
+   bool event(QEvent *e) { return true;} 
+   bool eventFilter ( QObject * watched, QEvent * event ){
+       return true;
+   }
+   void childEvent (QChildEvent * event ){ };
+   void connectNotify ( const char * signal ) {}
+   void customEvent ( QEvent * event ) { }
+   void disconnectNotify ( const char * signal ) {  }
+   void timerEvent ( QTimerEvent * event ){ }
+   // End
      void OnReset(void);
      void OnSpecialReset(void);
 #ifdef USE_STATE
@@ -62,18 +75,92 @@ public slots: // [1]
      void OnOpenDebugger(void);
      void OnCloseDebugger(void);
 #endif
+public slots: // [1]
      void setValue1(int v) {bindValue = v;}
      int getValue1(void) {return bindValue;}
+signals:
 private:
  int bindValue;
 } Object_Menu_Control ;
 
 typedef class Action_Control: public QAction {
+    //Q_OBJECT
  private:
  protected:
+//    virtual void addedTo ( QWidget * actionWidget, QWidget * container ){}
+ //   virtual void addedTo ( int index, QPopupMenu * menu ){}
  public:
-  Object_Menu_Control binds;
-  Action_Control (QObject *parent) : QAction(parent)    {binds.setValue1(0);}
+  Object_Menu_Control *binds;
+  Action_Control (QObject *parent) : QAction(parent) {
+     binds = new Object_Menu_Control(parent);
+  }
+  ~Action_Control() {
+       delete binds;
+  }
+//  virtual void setIconSet ( const QIconSet str ){}
+//  virtual void setText ( const QString str ){}
+//  virtual void setMenuText ( const QString str ){}
+//  virtual void setToolTip ( const QString str ){}
+//  virtual void setStatusTip ( const QString str ){}
+//  virtual void setWhatsThis ( const QString str){}
+//  virtual void setAccel ( const QKeySequence key ){}
+//  virtual void setToggleAction ( bool toggle){}
+//  virtual bool addTo ( QWidget * w ) {return true;}
+//  virtual bool removeFrom ( QWidget *w ) {return true;}
+   
+private slots: 
+     void OnReset(void) {
+       binds->OnReset();
+     }
+     void OnSpecialReset(void) {
+       binds->OnSpecialReset();
+     }
+     virtual void setOn ( bool a) {}
+     virtual void setEnabled ( bool a){}
+#ifdef USE_STATE
+     void OnLoadState(void){
+       binds->OnSaveState();
+     }
+   
+     void OnSaveState(void) {
+       binds->OnSaveState();
+     }
+   
+#endif
+#ifdef USE_BOOT_MODE
+     void OnBootMode(void){
+       binds->OnBootMode();
+     }
+   
+#endif
+#ifdef USE_CPU_TYPE
+     void OnCpuType(void){
+       binds->OnCpuType();
+     }
+   
+#endif
+     void OnCpuPower(void) {
+       binds->OnCpuPower();
+     }
+#ifdef USE_AUTO_KEY
+     void OnStartAutoKey(void) {
+       binds->OnStartAutoKey();
+     }
+     void OnStopAutoKey(void) {
+       binds->OnStopAutoKey();
+     }
+#endif
+#ifdef USE_DEBUGGER
+     void OnOpenDebugger(void) {
+       binds->OnOpenDebugger();
+     }
+     void OnCloseDebugger(void) {
+       binds->OnCloseDebugger();
+     }
+   
+#endif
+signals:
+   void triggered();
 // Action_Control(QObject * parent, const char *name = 0) : QAction(parent, name)
 //    {binds.setValue1(0);}
 // Action_Control(const QString &menuText, QKeySequence accel, QObject *parent, const char *name = 0) : QAction(menuText, accel, parent, name)
@@ -85,7 +172,7 @@ typedef class Action_Control: public QAction {
 } ActionControl;
 
 
-class Ui_MainWindow
+class Ui_MainWindow : public QWidget
 {
 protected:
   void ConfigCpuSpeed(QMainWindow *MainWindow);
@@ -94,6 +181,11 @@ protected:
   void retranslateControlMenu(QMainWindow *MainWindow, const char *SpecialResetTitle,  bool WithSpecialReset);
   QMainWindow *MainWindow;
 public:
+   Ui_MainWindow(QWidget *parent = 0) : QWidget(parent) {
+       setupUi();
+   }
+   ~Ui_MainWindow() { }
+   
     QApplication *GuiMain;
     Action_Control *actionReset;
     Action_Control *actionSpecial_Reset;
@@ -330,4 +422,4 @@ namespace Ui {
 
 QT_END_NAMESPACE
 
-#endif
\ No newline at end of file
+#endif
index 4d338f2..250e9f2 100644 (file)
 \r
 #include "vm.h"\r
 #include "../emu.h"\r
+#include "../config.h"\r
 #include "device.h"\r
-\r
+#ifndef MAX_PATH\r
+#define MAX_PATH _MAX_PATH\r
+#endif\r
 #define SIG_DATAREC_OUT                0\r
 #define SIG_DATAREC_REMOTE     1\r
 #define SIG_DATAREC_TRIG       2\r
@@ -34,7 +37,7 @@ private:
        // data recorder\r
        FILEIO* play_fio;\r
        FILEIO* rec_fio;\r
-#if defined(_USE_AGAR) || defined(_USE_SDL)\r
+#if defined(_USE_AGAR)\r
        _TCHAR rec_file_path[AG_PATHNAME_MAX];\r
 #else\r
        _TCHAR rec_file_path[MAX_PATH];\r
@@ -77,7 +80,7 @@ private:
        int load_p6_image();\r
        int load_tap_image();\r
        int load_mzt_image();\r
-#if defined(_USE_AGAR) || defined(_USE_SDL)   \r
+#if defined(_USE_AGAR) || defined(_USE_SDL) || defined(_USE_QT)   \r
         unsigned int min(int *x, unsigned int y) {\r
           if((unsigned int)x < y) return (unsigned int)x;\r
           return y;\r
index e4c2a4f..65f4596 100644 (file)
@@ -40,7 +40,7 @@ bool FileIO::Open(const _TCHAR* filename, uint flg)
 \r
        hfile = CreateFile(filename, access, share, 0, creation, 0, 0);\r
        \r
-#if defined(_USE_AGAR) || defined(_USE_SDL)\r
+#if defined(_USE_AGAR) || defined(_USE_SDL) || defined(_USE_QT)\r
         flags = (flg & readonly) | (hfile == NULL ? 0 : open);\r
 #else\r
        flags = (flg & readonly) | (hfile == INVALID_HANDLE_VALUE ? 0 : open);\r
@@ -75,7 +75,7 @@ bool FileIO::CreateNew(const _TCHAR* filename)
 \r
        hfile = CreateFile(filename, access, share, 0, creation, 0, 0);\r
        \r
-#if defined(_USE_AGAR) || defined(_USE_SDL)\r
+#if defined(_USE_AGAR) || defined(_USE_SDL) || defined(_USE_QT)\r
         flags = (hfile == NULL ? 0 : open);\r
 #else\r
        flags = (hfile == INVALID_HANDLE_VALUE ? 0 : open);\r
@@ -105,7 +105,7 @@ bool FileIO::Reopen(uint flg)
 \r
        hfile = CreateFile(path, access, share, 0, creation, 0, 0);\r
        \r
-#if defined(_USE_AGAR) || defined(_USE_SDL)\r
+#if defined(_USE_AGAR) || defined(_USE_SDL) || defined(_USE_QT)\r
         flags = (hfile == NULL ? 0 : open);\r
 #else\r
        flags = (hfile == INVALID_HANDLE_VALUE ? 0 : open);\r
@@ -123,7 +123,7 @@ void FileIO::Close()
 {\r
        if (GetFlags() & open)\r
        {\r
-#if defined(_USE_AGAR) || (_USE_SDL)\r
+#if defined(_USE_AGAR) || (_USE_SDL) || defined(_USE_QT)\r
           if(hfile != NULL) AG_CloseDataSource(hfile);\r
 #else\r
           CloseHandle(hfile);\r
index 64ac6d3..d9974c3 100644 (file)
@@ -4,7 +4,7 @@
 #define STRICT\r
 #define WIN32_LEAN_AND_MEAN\r
 \r
-#if defined(_USE_AGAR) || defined(_USE_SDL)\r
+#if defined(_USE_AGAR) || defined(_USE_SDL) || defined(_USE_QT)\r
 #else\r
 # include <windows.h>\r
 #endif\r
index bb7c8c7..8b25b8f 100644 (file)
 #define BUILD_OPN\r
 #define BUILD_OPNA\r
 #define BUILD_OPNB\r
-#if defined(_USE_AGAR) || (_USE_SDL)\r
+#if defined(_USE_AGAR)\r
 # ifndef MAX_PATH\r
 #  define MAX_PATH AG_PATHNAME_MAX\r
 # endif\r
 #endif\r
 \r
+#ifdef USE_QT\r
+# ifndef MAX_PATH\r
+#   define MAX_PATH 2048\r
+# endif\r
+#endif\r
+\r
+\r
 //     TOFIX:\r
 //      OPN ch3 \82ª\8fí\82ÉPrepare\82Ì\91Î\8fÛ\82Æ\82È\82Á\82Ä\82µ\82Ü\82¤\8fá\8aQ\r
 \r
index b8e4112..23c4d0c 100644 (file)
@@ -7,7 +7,7 @@
 #ifndef FM_OPNA_H\r
 #define FM_OPNA_H\r
 \r
-#if defined(_USE_AGAR) || defined(_USE_SDL)\r
+#if defined(_USE_AGAR) || defined(_USE_SDL) || defined(_USE_QT)\r
 # include "common.h"\r
 #else\r
 # include <tchar.h>\r
index 83d3c09..a87cdfc 100644 (file)
@@ -7,7 +7,7 @@
 #ifndef PSG_H\r
 #define PSG_H\r
 \r
-#if defined(_USE_AGAR) || defined(_USE_SDL)\r
+#if defined(_USE_AGAR) || defined(_USE_SDL) || defined(_USE_QT)\r
 # include "common.h"\r
 #else\r
 # include "types.h"\r
index cc1352f..c202de4 100644 (file)
@@ -96,7 +96,7 @@ private:
        /* ---------------------------------------------------------------------------\r
        debug\r
        --------------------------------------------------------------------------- */\r
-#if defined(_USE_AGAR) || defined(_USE_SDL)\r
+#if defined(_USE_AGAR) || defined(_USE_SDL) || defined(_USE_QT)\r
        int max(int x, int y) {\r
          if(x > y) return x;\r
          return y;\r