From 8762b37edfdb2ddcddcd7d736c67536a53259a8a Mon Sep 17 00:00:00 2001 From: "K.Ohta" Date: Fri, 29 May 2015 02:18:09 +0900 Subject: [PATCH] [Qt][General] Fix indent : replace space to ^I. --- source/src/qt/common/emu_input.cpp | 544 ++++++-------------- source/src/qt/common/emu_utils.h | 4 +- source/src/qt/common/emuevents_control.cpp | 132 ++--- source/src/qt/common/qt_dialogs.cpp | 133 +---- source/src/qt/common/qt_dialogs.h | 109 ++-- source/src/qt/common/qt_emuevents.h | 53 +- source/src/qt/common/qt_gldraw.cpp | 452 +++++++---------- source/src/qt/common/qt_gldraw.h | 178 ++++--- source/src/qt/common/qt_glevents.cpp | 8 +- source/src/qt/common/qt_glutil.cpp | 269 +++++----- source/src/qt/common/qt_input.h | 150 +++--- source/src/qt/common/qt_main.cpp | 779 ++++++++++++++--------------- source/src/qt/common/qt_main.h | 172 +++---- source/src/qt/common/qt_screen.cpp | 190 +++---- source/src/qt/common/sdl_cpuid.c | 54 +- source/src/qt/common/sdl_cpuid.h | 32 +- source/src/qt/common/simd_types.h | 58 +-- source/src/qt/gui/commonclasses.h | 227 ++++----- source/src/qt/gui/display_statusbar.cpp | 226 ++++----- source/src/qt/gui/mainwidget.h | 669 ++++++++++++------------- source/src/qt/gui/mainwindow_utils.cpp | 171 +++---- source/src/qt/gui/menu_binary.cpp | 4 +- source/src/qt/gui/menu_cart.cpp | 225 ++++----- source/src/qt/gui/menu_cmt.cpp | 404 ++++++++------- source/src/qt/gui/menu_control.cpp | 367 +++++++------- source/src/qt/gui/menu_disk.cpp | 361 +++++++------ source/src/qt/gui/menu_main.cpp | 225 +++++---- source/src/qt/gui/menu_quickdisk.cpp | 287 +++++------ source/src/qt/gui/menu_screen.cpp | 258 +++++----- source/src/qt/gui/menu_sound.cpp | 183 ++++--- source/src/qt/gui/qt_input.cpp | 549 ++++++++++---------- source/src/qt/gui/util_cart.cpp | 99 ++-- source/src/qt/gui/util_cmt.cpp | 194 ++++--- source/src/qt/gui/util_fd.cpp | 374 +++++++------- source/src/qt/gui/util_qd.cpp | 149 +++--- 35 files changed, 3767 insertions(+), 4522 deletions(-) diff --git a/source/src/qt/common/emu_input.cpp b/source/src/qt/common/emu_input.cpp index 6c9240784..aa6e377d3 100644 --- a/source/src/qt/common/emu_input.cpp +++ b/source/src/qt/common/emu_input.cpp @@ -4,8 +4,8 @@ * Author : Takeda.Toshiya * Date : 2006.08.18 - * Converted to QT by (C) 2015 K.Ohta - * History: - * Jan 12, 2015 (maybe) : Initial + * History: + * Jan 12, 2015 (maybe) : Initial * [ SDL input -> Keyboard] */ @@ -29,176 +29,6 @@ extern EMU* emu; -struct SDLKeyTable SDLKeyMappings[] = { - { '0', SDL_SCANCODE_0 }, - { '1', SDL_SCANCODE_1 }, - { '2', SDL_SCANCODE_2 }, - { '3', SDL_SCANCODE_3 }, - { '4', SDL_SCANCODE_4 }, - { '5', SDL_SCANCODE_5 }, - { '6', SDL_SCANCODE_6 }, - { '7', SDL_SCANCODE_7 }, - { '8', SDL_SCANCODE_8 }, - { '9', SDL_SCANCODE_9 }, - { 'A', SDL_SCANCODE_A }, - { 'B', SDL_SCANCODE_B }, - { 'C', SDL_SCANCODE_C }, - { 'D', SDL_SCANCODE_D }, - { 'E', SDL_SCANCODE_E }, - { 'F', SDL_SCANCODE_F }, - { 'G', SDL_SCANCODE_G }, - { 'H', SDL_SCANCODE_H }, - { 'I', SDL_SCANCODE_I }, - { 'J', SDL_SCANCODE_J }, - { 'K', SDL_SCANCODE_K }, - { 'L', SDL_SCANCODE_L }, - { 'M', SDL_SCANCODE_M }, - { 'N', SDL_SCANCODE_N }, - { 'O', SDL_SCANCODE_O }, - { 'P', SDL_SCANCODE_P }, - { 'Q', SDL_SCANCODE_Q }, - { 'R', SDL_SCANCODE_R }, - { 'S', SDL_SCANCODE_S }, - { 'T', SDL_SCANCODE_T }, - { 'U', SDL_SCANCODE_U }, - { 'V', SDL_SCANCODE_V }, - { 'W', SDL_SCANCODE_W }, - { 'X', SDL_SCANCODE_X }, - { 'Y', SDL_SCANCODE_Y }, - { 'Z', SDL_SCANCODE_Z }, - // Start Qt's workaround: Qt returns character directry when keyin/out. - // Excepts(maybe) 'a' to 'z'? - // So, you should change keycode, using other than 109 / 106 Keyboard. -// {0xBA, SDL_SCANCODE_ASTERISK}, // $2a -// {0xBB, SDL_SCANCODE_PLUS}, // $2b -// {0xBC, SDL_SCANCODE_LESS}, // , -// {0xBD, SDL_SCANCODE_CARET}, // ^~ -// {0xBE, SDL_SCANCODE_GREATER}, //$2e -// {0xBF, SDL_SCANCODE_QUSETION}, //$2f - //{0xC0, SDL_SCANCODE_BACKQUOTE}, //` -// {0xE2, SDL_SCANCODE_UNDERSCORE},//_\ - {0xE2, SDL_SCANCODE_INTERNATIONAL3},//_\ - // End. - { VK_F1, SDL_SCANCODE_F1 }, - { VK_F2, SDL_SCANCODE_F2 }, - { VK_F3, SDL_SCANCODE_F3 }, - { VK_F4, SDL_SCANCODE_F4 }, - { VK_F5, SDL_SCANCODE_F5 }, - { VK_F6, SDL_SCANCODE_F6 }, - { VK_F7, SDL_SCANCODE_F7 }, - { VK_F8, SDL_SCANCODE_F8 }, - { VK_F9, SDL_SCANCODE_F9 }, - { VK_F10, SDL_SCANCODE_F10 }, - { VK_F11, SDL_SCANCODE_F11 }, - { VK_F12, SDL_SCANCODE_F12 }, - { VK_F13, SDL_SCANCODE_F13 }, - { VK_F14, SDL_SCANCODE_F14 }, - { VK_F15, SDL_SCANCODE_F15 }, - { VK_BACK, SDL_SCANCODE_BACKSPACE }, - { VK_TAB, SDL_SCANCODE_TAB }, - { VK_CLEAR, SDL_SCANCODE_CLEAR }, - { VK_RETURN, SDL_SCANCODE_RETURN }, - { VK_PAUSE, SDL_SCANCODE_PAUSE }, - { VK_ESCAPE, SDL_SCANCODE_ESCAPE }, - { VK_SPACE, SDL_SCANCODE_SPACE }, - { VK_DELETE, SDL_SCANCODE_DELETE }, - { VK_UP, SDL_SCANCODE_UP }, - { VK_DOWN, SDL_SCANCODE_DOWN}, - { VK_RIGHT, SDL_SCANCODE_RIGHT }, - { VK_LEFT, SDL_SCANCODE_LEFT }, - { VK_INSERT, SDL_SCANCODE_INSERT }, - { VK_HOME, SDL_SCANCODE_HOME }, - { VK_END, SDL_SCANCODE_END }, - { VK_PRIOR, SDL_SCANCODE_PAGEUP }, - { VK_NEXT, SDL_SCANCODE_PAGEDOWN }, - - { VK_NUMPAD0, SDL_SCANCODE_KP_0 }, - { VK_NUMPAD1, SDL_SCANCODE_KP_1 }, - { VK_NUMPAD2, SDL_SCANCODE_KP_2 }, - { VK_NUMPAD3, SDL_SCANCODE_KP_3 }, - { VK_NUMPAD4, SDL_SCANCODE_KP_4 }, - { VK_NUMPAD5, SDL_SCANCODE_KP_5 }, - { VK_NUMPAD6, SDL_SCANCODE_KP_6 }, - { VK_NUMPAD7, SDL_SCANCODE_KP_7 }, - { VK_NUMPAD8, SDL_SCANCODE_KP_8 }, - { VK_NUMPAD9, SDL_SCANCODE_KP_9 }, - - { VK_DECIMAL, SDL_SCANCODE_KP_PERIOD }, - { VK_DIVIDE, SDL_SCANCODE_KP_DIVIDE}, - { VK_MULTIPLY, SDL_SCANCODE_KP_MULTIPLY }, - { VK_SUBTRACT, SDL_SCANCODE_KP_MINUS }, - { VK_ADD, SDL_SCANCODE_KP_PLUS }, - - { VK_NUMLOCK, SDL_SCANCODE_NUMLOCKCLEAR }, -// { VK_CAPITAL, SDL_SCANCODE_Henkan }, // Need check - { VK_CAPITAL, SDL_SCANCODE_CAPSLOCK}, // Need check - { VK_SCROLL, SDL_SCANCODE_SCROLLLOCK }, -// { VK_SHIFT, SDL_SCANCODE_LSHIFT }, // Left - { VK_RSHIFT, SDL_SCANCODE_RSHIFT }, // Right - { VK_LSHIFT, SDL_SCANCODE_LSHIFT }, // Right -// { VK_CONTROL, SDL_SCANCODE_CTRL }, // Right - { VK_RCONTROL, SDL_SCANCODE_RCTRL }, // Right - { VK_LCONTROL, SDL_SCANCODE_LCTRL }, // Left - { VK_RMENU, SDL_SCANCODE_RALT }, // Right - { VK_LMENU, SDL_SCANCODE_LALT }, // Left - { VK_MENU, SDL_SCANCODE_MENU }, // Right - { VK_RWIN, SDL_SCANCODE_RGUI }, - { VK_LWIN, SDL_SCANCODE_LGUI }, - { VK_HELP, SDL_SCANCODE_HELP }, // Right? -#ifdef VK_PRINT - { VK_PRINT, SDL_SCANCODE_PRINTSCREEN }, -#endif - { VK_SNAPSHOT, SDL_SCANCODE_PRINTSCREEN }, - { VK_CANCEL, SDL_SCANCODE_PAUSE }, - { VK_APPS, SDL_SCANCODE_APPLICATION }, - { 0xBA, SDL_SCANCODE_KP_COLON }, - { 0xBB, SDL_SCANCODE_SEMICOLON }, -// { 0xBB, SDL_SCANCODE_KP_SEMICOLON }, - { 0xBC, SDL_SCANCODE_COMMA }, - { 0xBD, SDL_SCANCODE_MINUS },// - { 0xBE, SDL_SCANCODE_PERIOD },// - { 0xBF, SDL_SCANCODE_SLASH },// - { 0xBB, SDL_SCANCODE_EQUALS },// - { 0xC0, SDL_SCANCODE_KP_AT }, - { 0xDB, SDL_SCANCODE_LEFTBRACKET },//] - { 0xDC, SDL_SCANCODE_BACKSLASH }, // Okay? - { 0xDD, SDL_SCANCODE_RIGHTBRACKET }, //[ - { 0xDE, SDL_SCANCODE_NONUSBACKSLASH }, // ^ -// { 0xDF, SDL_SCANCODE_QuoteLeft }, - - // VK_CAPITAL - { 0xF0, SDL_SCANCODE_CAPSLOCK }, - // VK_KANA - { 0xF2, SDL_SCANCODE_LANG3 }, - { 0xF2, SDL_SCANCODE_LANG4 }, - // VK_KANJI - { 0xF3, SDL_SCANCODE_LANG5 }, -// { 0xF4, SDL_SCANCODE_Hankaku }, - - { 0xffffffff, 0xffffffff} -}; - - - - -uint32_t convert_SDLKey2VK(uint32_t sym) -{ - uint32 n = 0; - int i = 0; - do { - if(SDLKeyMappings[i].sdlkey == sym) { - n = SDLKeyMappings[i].vk; - break; - } - - i++; - } while(QtKeyMappings[i].vk != 0xffffffff); - //if((n == VK_LSHIFT) || (n == VK_RSHIFT)) n = VK_SHIFT; - //if((n == VK_LCTRL) || (n == VK_RCTRL)) n = VK_CONTROL; - //if((n == VL_RMENU) || (n == VK_RMENU)) n = VK_MENU; - return n; -} - void EMU::initialize_input() { // initialize status @@ -209,19 +39,10 @@ void EMU::initialize_input() // initialize joysticks // mouse emulation is disenabled mouse_enabled = false; - joy_num = SDL_NumJoysticks(); - for(int i = 0; i < joy_num && i < 2; i++) { - //SDL_Joystick *joycaps = SDL_JoystickOpen(i); - //if(joycaps != NULL) { - // joy_mask[i] = (1 << SDL_JoystickNumButtons(joycaps)) - 1; - // SDL_JoystickClose(joycaps); - //} else { - joy_mask[i] = 0x0f; // 4buttons - //} - + joy_num = SDL_NumJoysticks(); + for(int i = 0; i < joy_num && i < 2; i++) { + joy_mask[i] = 0x0f; // 4buttons } - - // initialize keycode convert table FILEIO* fio = new FILEIO(); if(fio->Fopen(bios_path(_T("keycode.cfg")), FILEIO_READ_BINARY)) { @@ -268,31 +89,31 @@ void EMU::release_input() void EMU::update_input() { - int *keystat; - int i_c = 0;; + 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; + //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); + 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; + } + } 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); + vm->key_up(VK_SHIFT); # endif - // check l/r shift - if(!(GetAsyncKeyState(VK_LSHIFT, modkey_status) & 0x8000)) key_status[VK_LSHIFT] &= 0x7f; - if(!(GetAsyncKeyState(VK_RSHIFT, modkey_status) & 0x8000)) key_status[VK_RSHIFT] &= 0x7f; - } - } - key_shift_pressed = key_shift_released = false; + // check l/r shift + if(!(GetAsyncKeyState(VK_LSHIFT, modkey_status) & 0x8000)) key_status[VK_LSHIFT] &= 0x7f; + if(!(GetAsyncKeyState(VK_RSHIFT, modkey_status) & 0x8000)) key_status[VK_RSHIFT] &= 0x7f; + } + } + key_shift_pressed = key_shift_released = false; #endif // release keys @@ -382,8 +203,7 @@ void EMU::update_input() } } #endif - -#if 1 + #ifdef USE_AUTO_KEY // auto key switch(autokey_phase) { @@ -433,8 +253,7 @@ void EMU::update_input() } } #endif -#endif - } +} @@ -464,19 +283,14 @@ void EMU::key_down(int sym, bool repeat) { bool keep_frames = false; uint8 code = sym; -// code = convert_AGKey2VK(sym); - - //printf("Key down %08x\n", sym); - -#if 1 // No needed with SDL? - if(code == VK_SHIFT){ + if(code == VK_SHIFT){ #ifndef USE_SHIFT_NUMPAD_KEY if(GetAsyncKeyState(VK_LSHIFT, modkey_status) & 0x8000) key_status[VK_LSHIFT] = 0x80; if(GetAsyncKeyState(VK_RSHIFT, modkey_status) & 0x8000) key_status[VK_RSHIFT] = 0x80; if(GetAsyncKeyState(VK_SHIFT, modkey_status) & 0x8000) key_status[VK_LSHIFT] = 0x80; if(!(key_status[VK_LSHIFT] || key_status[VK_RSHIFT])) key_status[VK_LSHIFT] = 0x80; #endif - } else if(code == VK_LSHIFT){ + } else if(code == VK_LSHIFT){ #ifndef USE_SHIFT_NUMPAD_KEY if(GetAsyncKeyState(VK_LSHIFT, modkey_status) & 0x8000) key_status[VK_LSHIFT] = 0x80; // if(GetAsyncKeyState(VK_RSHIFT, modkey_status) & 0x8000) key_status[VK_RSHIFT] = 0x80; @@ -506,35 +320,7 @@ void EMU::key_down(int sym, bool repeat) code = VK_KANJI; keep_frames = true; } -#else //SDL - if((code == VK_LSHIFT) || (code == VK_RSHIFT)) { - key_status[code] = 0x80; - if(!(key_status[VK_LSHIFT] || key_status[VK_RSHIFT])) key_status[VK_LSHIFT] = 0x80; - } else if(code == VK_SHIFT) { - key_status[code] = 0x80; - if(!(key_status[VK_LSHIFT] || key_status[VK_RSHIFT])) key_status[VK_LSHIFT] = 0x80; - } else if((code == VK_LCONTROL) || (code == VK_RCONTROL)) { - key_status[code] = 0x80; - } else if(code == VK_CONTROL) { - key_status[code] = 0x80; - key_status[VK_LCONTROL] = 0x80; - } else if((code == VK_LMENU) || (code == VK_RMENU)) { - key_status[code] = 0x80; - } else if(code == VK_MENU) { - key_status[code] = 0x80; - 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; - } -#endif - + # ifdef USE_SHIFT_NUMPAD_KEY if(code == VK_SHIFT) { key_shift_pressed = true; @@ -550,7 +336,7 @@ void EMU::key_down(int sym, bool repeat) } #endif - if(!(code == VK_CONTROL || code == VK_MENU || code == VK_SHIFT)) { + if(!(code == VK_CONTROL || code == VK_MENU || code == VK_SHIFT)) { code = keycode_conv[code]; } @@ -574,10 +360,7 @@ void EMU::key_down(int sym, bool repeat) void EMU::key_up(int sym) { uint8 code = sym; -// code = convert_AGKey2VK(sym); - //printf("Key up %03x %03x\n", sym, code); -#if 1 - if(code == VK_SHIFT) { + if(code == VK_SHIFT) { #ifndef USE_SHIFT_NUMPAD_KEY if(!(GetAsyncKeyState(VK_SHIFT, modkey_status) & 0x8000)) key_status[VK_LSHIFT] &= 0x7f; // if(!(GetAsyncKeyState(VK_RSHIFT, modkey_status) & 0x8000)) key_status[VK_RSHIFT] &= 0x7f; @@ -598,32 +381,12 @@ void EMU::key_up(int sym) } else if(code == VK_MENU) { if(!(GetAsyncKeyState(VK_LMENU, modkey_status) & 0x8000)) key_status[VK_LMENU] &= 0x7f; if(!(GetAsyncKeyState(VK_RMENU, modkey_status) & 0x8000)) key_status[VK_RMENU] &= 0x7f; - } else -#else - if((code == VK_LSHIFT) || (code == VK_RSHIFT)) { - key_status[code] &= 0x7f; - } else if(code == VK_SHIFT) { - key_status[code] &= 0x7f; - key_status[VK_LSHIFT] &= 0x7f; - } else if((code == VK_LCONTROL) || (code == VK_RCONTROL)) { - key_status[code] &= 0x7f; - } else if(code == VK_CONTROL) { - key_status[code] &= 0x7f; - key_status[VK_LCONTROL] &= 0x7f; - } else if((code == VK_LMENU) || (code == VK_RMENU)) { - key_status[code] &= 0x7f; - } else if(code == VK_MENU) { - key_status[code] &= 0x7f; - key_status[VK_LMENU] &= 0x7f; - } else -#endif - { - key_status[code] &= 0x7f; + } else { + key_status[code] &= 0x7f; #ifdef NOTIFY_KEY_DOWN - vm->key_up(code); + vm->key_up(code); #endif - } - + } #ifdef USE_SHIFT_NUMPAD_KEY if((code == VK_SHIFT) || (code == VK_RSHIFT) || (code == VK_LSHIFT)) { @@ -653,7 +416,6 @@ void EMU::key_up(int sym) #ifdef USE_BUTTON void EMU::press_button(int num) { -#if 1 int code = buttons[num].code; if(code) { @@ -663,16 +425,16 @@ void EMU::press_button(int num) // code=0: reset virtual machine vm->reset(); } -#endif } #endif + void EMU::enable_mouse() { // enable mouse emulation if(!mouse_enabled) { #if 0 - // hide mouse cursor + // hide mouse cursor ShowCursor(FALSE); // move mouse cursor to the center of window POINT pt; @@ -738,7 +500,7 @@ static const int autokey_table[256] = { void EMU::start_auto_key() { #if 0 - stop_auto_key(); + stop_auto_key(); if(OpenClipboard(NULL)) { HANDLE hClip = GetClipboardData(CF_TEXT); @@ -789,7 +551,7 @@ void EMU::start_auto_key() void EMU::stop_auto_key() { #if 1 - if(autokey_shift) { + if(autokey_shift) { key_up(VK_SHIFT); } autokey_phase = autokey_shift = 0; @@ -798,125 +560,123 @@ void EMU::stop_auto_key() #endif - JoyThreadClass::JoyThreadClass(QObject *parent) : QThread(parent) - { - int i; - for(i = 0; i < 2; i++) joyhandle[i] = SDL_JoystickOpen(i); - joy_num = SDL_NumJoysticks(); - AGAR_DebugLog(AGAR_LOG_DEBUG, "JoyThread : Start."); - bRunThread = true; - } +JoyThreadClass::JoyThreadClass(QObject *parent) : QThread(parent) +{ + int i; + for(i = 0; i < 2; i++) joyhandle[i] = SDL_JoystickOpen(i); + joy_num = SDL_NumJoysticks(); + AGAR_DebugLog(AGAR_LOG_DEBUG, "JoyThread : Start."); + bRunThread = true; +} - JoyThreadClass::~JoyThreadClass() - { - int i; - for(i = 0; i < 2; i++) { - if(joyhandle[i] != NULL) SDL_JoystickClose(joyhandle[i]); - } - AGAR_DebugLog(AGAR_LOG_DEBUG, "JoyThread : EXIT"); - } +JoyThreadClass::~JoyThreadClass() +{ + int i; + for(i = 0; i < 2; i++) { + if(joyhandle[i] != NULL) SDL_JoystickClose(joyhandle[i]); + } + AGAR_DebugLog(AGAR_LOG_DEBUG, "JoyThread : EXIT"); +} void JoyThreadClass::x_axis_changed(int index, int value) { - if(p_emu == NULL) return; - p_emu->LockVM(); - uint32_t *joy_status = p_emu->getJoyStatPtr(); - - if(joy_status != NULL) { - if(value < -8192) { // left - joy_status[index] |= 0x04; joy_status[index] &= ~0x08; - } else if(value > 8192) { // right - joy_status[index] |= 0x08; joy_status[index] &= ~0x04; - } else { // center - joy_status[index] &= ~0x0c; - } - } + if(p_emu == NULL) return; + p_emu->LockVM(); + uint32_t *joy_status = p_emu->getJoyStatPtr(); - p_emu->UnlockVM(); + if(joy_status != NULL) { + if(value < -8192) { // left + joy_status[index] |= 0x04; joy_status[index] &= ~0x08; + } else if(value > 8192) { // right + joy_status[index] |= 0x08; joy_status[index] &= ~0x04; + } else { // center + joy_status[index] &= ~0x0c; + } + } + p_emu->UnlockVM(); } void JoyThreadClass::y_axis_changed(int index, int value) { - if(p_emu == NULL) return; - p_emu->LockVM(); - uint32_t *joy_status = p_emu->getJoyStatPtr(); - - if(joy_status != NULL) { - if(value < -8192) {// up - joy_status[index] |= 0x01; joy_status[index] &= ~0x02; - } else if(value > 8192) {// down - joy_status[index] |= 0x02; joy_status[index] &= ~0x01; - } else { - joy_status[index] &= ~0x03; - } - } + if(p_emu == NULL) return; + p_emu->LockVM(); + uint32_t *joy_status = p_emu->getJoyStatPtr(); - p_emu->UnlockVM(); + if(joy_status != NULL) { + if(value < -8192) {// up + joy_status[index] |= 0x01; joy_status[index] &= ~0x02; + } else if(value > 8192) {// down + joy_status[index] |= 0x02; joy_status[index] &= ~0x01; + } else { + joy_status[index] &= ~0x03; + } + } + p_emu->UnlockVM(); } void JoyThreadClass::button_down(int index, unsigned int button) { - if(p_emu == NULL) return; - p_emu->LockVM(); - uint32_t *joy_status = p_emu->getJoyStatPtr(); - if(joy_status != NULL) { - joy_status[index] |= (1 << (button + 4)); - } - p_emu->UnlockVM(); + if(p_emu == NULL) return; + p_emu->LockVM(); + uint32_t *joy_status = p_emu->getJoyStatPtr(); + if(joy_status != NULL) { + joy_status[index] |= (1 << (button + 4)); + } + p_emu->UnlockVM(); } void JoyThreadClass::button_up(int index, unsigned int button) { - if(p_emu == NULL) return; + if(p_emu == NULL) return; - p_emu->LockVM(); - uint32_t *joy_status = p_emu->getJoyStatPtr(); - if(joy_status != NULL) { - joy_status[index] &= ~(1 << (button + 4)); - } - p_emu->UnlockVM(); + p_emu->LockVM(); + uint32_t *joy_status = p_emu->getJoyStatPtr(); + if(joy_status != NULL) { + joy_status[index] &= ~(1 << (button + 4)); + } + p_emu->UnlockVM(); } // SDL Event Handler bool JoyThreadClass::EventSDL(SDL_Event *eventQueue) { - // SDL_Surface *p; - Sint16 value; - unsigned int button; - int vk; - uint32_t sym; - uint32_t mod; - int i; - if(eventQueue == NULL) return false; + // SDL_Surface *p; + Sint16 value; + unsigned int button; + int vk; + uint32_t sym; + uint32_t mod; + int i; + if(eventQueue == NULL) return false; /* * JoyStickなどはSDLが管理する */ - switch (eventQueue->type){ - case SDL_JOYAXISMOTION: - value = eventQueue->jaxis.value; - i = eventQueue->jaxis.which; - if((i < 0) || (i > 1)) break; - - if(eventQueue->jaxis.axis == 0) { // X - x_axis_changed(i, value); - } else if(eventQueue->jaxis.axis == 1) { // Y - y_axis_changed(i, value); - } - break; - case SDL_JOYBUTTONDOWN: - button = eventQueue->jbutton.button; - i = eventQueue->jbutton.which; - if((i < 0) || (i > 1)) break; - button_down(i, button); - break; - case SDL_JOYBUTTONUP: - button = eventQueue->jbutton.button; - i = eventQueue->jbutton.which; - if((i < 0) || (i > 1)) break; - button_up(i, button); - break; - default: - break; + switch (eventQueue->type){ + case SDL_JOYAXISMOTION: + value = eventQueue->jaxis.value; + i = eventQueue->jaxis.which; + if((i < 0) || (i > 1)) break; + + if(eventQueue->jaxis.axis == 0) { // X + x_axis_changed(i, value); + } else if(eventQueue->jaxis.axis == 1) { // Y + y_axis_changed(i, value); + } + break; + case SDL_JOYBUTTONDOWN: + button = eventQueue->jbutton.button; + i = eventQueue->jbutton.which; + if((i < 0) || (i > 1)) break; + button_down(i, button); + break; + case SDL_JOYBUTTONUP: + button = eventQueue->jbutton.button; + i = eventQueue->jbutton.which; + if((i < 0) || (i > 1)) break; + button_up(i, button); + break; + default: + break; } return true; } @@ -924,40 +684,40 @@ bool JoyThreadClass::EventSDL(SDL_Event *eventQueue) void JoyThreadClass::doWork(const QString ¶ms) { - do { - if(bRunThread == false) { - return; - } - while(SDL_PollEvent(&event) == 1) { - EventSDL(&event); - } - msleep(10); - } while(1); - - //timer.setInterval(5); - return; + do { + if(bRunThread == false) { + return; + } + while(SDL_PollEvent(&event) == 1) { + EventSDL(&event); + } + msleep(10); + } while(1); + //timer.setInterval(5); + return; } void JoyThreadClass::doExit(void) { - bRunThread = false; + bRunThread = false; } void Ui_MainWindow::LaunchJoyThread(void) { - hRunJoy = new JoyThreadClass(this); - hRunJoy->SetEmu(emu); - connect(this, SIGNAL(quit_joy_thread()), hRunJoy, SLOT(doExit())); - hRunJoy->setObjectName("JoyThread"); - hRunJoy->start(); + hRunJoy = new JoyThreadClass(this); + hRunJoy->SetEmu(emu); + connect(this, SIGNAL(quit_joy_thread()), hRunJoy, SLOT(doExit())); + hRunJoy->setObjectName("JoyThread"); + hRunJoy->start(); } -void Ui_MainWindow::StopJoyThread(void) { - emit quit_joy_thread(); +void Ui_MainWindow::StopJoyThread(void) +{ + emit quit_joy_thread(); } void Ui_MainWindow::delete_joy_thread(void) { - // delete hRunJoyThread; - // delete hRunJoy; + // delete hRunJoyThread; + // delete hRunJoy; } diff --git a/source/src/qt/common/emu_utils.h b/source/src/qt/common/emu_utils.h index 153ab4e27..9b76786dc 100644 --- a/source/src/qt/common/emu_utils.h +++ b/source/src/qt/common/emu_utils.h @@ -6,8 +6,8 @@ #include "qt_main.h" extern "C" { - extern uint32_t timeGetTime(void); - extern void Sleep(uint32_t); + extern uint32_t timeGetTime(void); + extern void Sleep(uint32_t); } #if defined(USE_FD1) || defined(USE_FD2) || defined(USE_FD3) || defined(USE_FD4) || \ diff --git a/source/src/qt/common/emuevents_control.cpp b/source/src/qt/common/emuevents_control.cpp index 0cc538dea..f5818d67b 100644 --- a/source/src/qt/common/emuevents_control.cpp +++ b/source/src/qt/common/emuevents_control.cpp @@ -41,143 +41,67 @@ void Ui_MainWindow::OnSaveState(void) void Ui_MainWindow::OnCpuPower(int mode) { - config.cpu_power = mode; - if(emu) { - emu->update_config(); - } + config.cpu_power = mode; + if(emu) { + emu->update_config(); + } } #ifdef USE_AUTO_KEY void Ui_MainWindow::OnStartAutoKey(void) { - if(emu) { - emu->start_auto_key(); - } + if(emu) { + emu->start_auto_key(); + } } void Ui_MainWindow::OnStopAutoKey(void) { - if(emu) { - emu->stop_auto_key(); - } + if(emu) { + emu->stop_auto_key(); + } } #endif #ifdef USE_DEBUGGER - void Ui_MainWindow::OnOpenDebugger(int no) - { - if((no < 0) || (no > 3)) return; - emu->open_debugger(no); - } -void Ui_MainWindow::OnCloseDebugger(void ) - { - emu->close_debugger(); - } -#endif - - -// Will move to other file. -#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 OpenRecentFloppy(QWidget *parent, int drv, int num) - -void OnCloseFD(int drive) +void Ui_MainWindow::OnOpenDebugger(int no) { - if(emu) close_disk(drive); + if((no < 0) || (no > 3)) return; + emu->open_debugger(no); } -// Use Dialog -#endif -#ifdef USE_DIPSWITCH -void OnToggleDipSw(int dipsw) -{ - if((dipsw < 0) || (dipsw > 31)) return; - config.dipswitch ^= (1 << dipsw); -} -void OnChangeDipSw(int dipsw, int flag) -{ - - if((dipsw < 0) || (dipsw > 31)) return; - if(flag == 0) { - config.dipswitch &= ~(1 << dipsw); - } else { - config.dipswitch |= (1 << dipsw); - } -} -#endif -#ifdef USE_DEVICE_TYPE -void OnSetDeviceType(int devtype) +void Ui_MainWindow::OnCloseDebugger(void ) { - if((devtype < 0) || (devtype > 7)) return; - config.device_type = devtype; + emu->close_debugger(); } #endif -#if defined(USE_CART1) || defined(USE_CART2) -#endif - - -#if defined(USE_QD1) || defined(USE_QD2) -void OnOpenQD(QWidget *parent, int drive) -{ -// if(emu) open_quickdisk_dialog(AGWIDGET(hWindow), drive); -} - -void OnCloseQD(int drive) -{ -// if(emu) emu->close_quickdisk(drive); -} -void OnRecentQD(int drive, int menunum) -{ - std::string path; - int i; - - if((menunum < 0) || (menunum > 7)) return; - path = config.recent_quickdisk_path[drive][menunum]; - - for(int i = menunum; i > 0; i--) { - strcpy(config.recent_quickdisk_path[drive][i], config.recent_quickdisk_path[drive][i - 1]); - } - strcpy(config.recent_quickdisk_path[drive][0], path.c_str()); - if(emu) { - emu->open_quickdisk(drive, (_TCHAR *)(path.c_str())); - } -} -#endif -#ifdef USE_TAPE - -#endif -#ifdef USE_TAPE_BUTTON -#endif // Implement LASER-DISC, BINARY // void OnStartRecordScreen(int num) { - - const int fps[3] = {60, 30, 15}; - if((num < 0) || (num > 2)) return; - if(emu) { - emu->start_rec_sound(); - if(!emu->start_rec_video(fps[num])) { - emu->stop_rec_sound(); - } - } + const int fps[3] = {60, 30, 15}; + if((num < 0) || (num > 2)) return; + if(emu) { + emu->start_rec_sound(); + if(!emu->start_rec_video(fps[num])) { + emu->stop_rec_sound(); + } + } } void OnStopRecordScreen(void) { - if(emu) { - emu->stop_rec_video(); - emu->stop_rec_sound(); - } + if(emu) { + emu->stop_rec_video(); + emu->stop_rec_sound(); + } } void OnScreenCapture(QWidget *parent) { - if(emu) emu->capture_screen(); + if(emu) emu->capture_screen(); } - - - void OnFullScreen(QMainWindow *MainWindow, QWidget *drawspace, int mode) { } diff --git a/source/src/qt/common/qt_dialogs.cpp b/source/src/qt/common/qt_dialogs.cpp index 0c42dec44..ebaf24aa9 100644 --- a/source/src/qt/common/qt_dialogs.cpp +++ b/source/src/qt/common/qt_dialogs.cpp @@ -4,7 +4,7 @@ Author : K.Ohta Date : 2015.01.07 - [agar dialogs] + [Qt dialogs] */ #include @@ -15,133 +15,30 @@ #include "qt_main.h" #include "agar_logger.h" -void CSP_DiskParams::_open_disk(QString s) { - int d = getDrive(); - AGAR_DebugLog(AGAR_LOG_INFO, "Try to open disk: %s", s.toUtf8().constData()); - AGAR_DebugLog(AGAR_LOG_INFO, "Drive = %d\n", d); - emit do_open_disk(d, s); -} - -void CSP_DiskParams::_open_cart(QString s) { - int d = getDrive(); - emit sig_open_cart(d, s); -} -void CSP_DiskParams::_open_cmt(QString s) { - emit do_open_cmt(play, s); -} - -#if defined(USE_BINARY_FILE1) || defined(USE_BINARY_FILE2) -void CSP_DiskParams::_open_binary(QString s) { - emit sig_open_binary_file(drive, s, play); -} -#endif - -extern "C" +void CSP_DiskParams::_open_disk(QString s) { - -#ifdef USE_CART1 - -#endif - - - -#ifdef USE_TAPE -#endif -} -#if 0 // ! -#ifdef USE_LASER_DISC -void OnOpenLaserDiscSub(AG_Event *event) -{ - AG_FileType *filetype = (AG_FileType *)AG_PTR(2); - char *path = AG_STRING(1); - char path_shadow[AG_PATHNAME_MAX]; - AG_FileDlg *my = (AG_FileDlg *)AG_SELF(); - if(path) { - if(strlen(path) <= 0) return; - strncpy(path_shadow, path, AG_PATHNAME_MAX); - UPDATE_HISTORY(path, config.recent_laser_disc_path); - get_parent_dir(path_shadow); - strcpy(config.initial_laser_disc_dir, path_shadow); - if(emu) emu->open_laser_disc(path); - } + int d = getDrive(); + AGAR_DebugLog(AGAR_LOG_INFO, "Try to open disk: %s", s.toUtf8().constData()); + AGAR_DebugLog(AGAR_LOG_INFO, "Drive = %d\n", d); + emit do_open_disk(d, s); } -void open_laser_disc_dialog(AG_Widget *hWnd) +void CSP_DiskParams::_open_cart(QString s) { - const char *ext = "*.avi,*.mpg,*.mpeg,*.wmv,*.ogv"; - char *desc = "Laser Disc"; - AG_Window *win; - - win = AG_WindowNew(0); - - AG_FileDlg *dlg = AG_FileDlgNew(win, AG_FILEDLG_MASK_EXT | AG_FILEDLG_ASYNC | AG_FILEDLG_CLOSEWIN); - if(dlg == NULL) return; - - if(config.initial_laser_disc_dir != NULL) { - AG_FileDlgSetDirectory(dlg, "%s", config.initial_laser_disc_dir); - } else { - _TCHAR app[AG_PATHNAME_MAX]; - AG_GetCWD(app, AG_PATHNAME_MAX); - AG_FileDlgSetDirectory(dlg, "%s", get_parent_dir(app)); - } - AG_FileDlgAddType(dlg, desc, ext, OnOpenLaserDiscSub, "%p", NULL); - AG_WindowShow(win); - return; + int d = getDrive(); + emit sig_open_cart(d, s); } -#endif - -#ifdef USE_BINARY_FILE1 - -void OnOpenBinarySub(AG_Event *event) +void CSP_DiskParams::_open_cmt(QString s) { - AG_FileType *filetype = (AG_FileType *)AG_PTR(4); - char *path = AG_STRING(3); - char path_shadow[AG_PATHNAME_MAX]; - int drv = AG_INT(1); - int load = AG_INT(2); - AG_FileDlg *my = (AG_FileDlg *)AG_SELF(); - if(path) { - strncpy(path_shadow, path, AG_PATHNAME_MAX); - UPDATE_HISTORY(path, config.recent_binary_path[drv]); - get_parent_dir(path_shadow); - strcpy(config.initial_binary_dir, path_shadow); - if(load != 0) { - emu->load_binary(drv, path); - } else { - emu->save_binary(drv, path); - } - } + emit do_open_cmt(play, s); } -void open_binary_dialog(AG_Widget *hWnd, int drv, bool load) -{ - const char ext = "*.ram,*.bin"; - AG_Window *win; - - int loadf = load ? 1 : 0; -#if defined(_PASOPIA) || defined(_PASOPIA7) - char *desc = "RAM Pack Cartridge"; -#else - 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); - if(dlg == NULL) return; - - if(config.initial_binary_dir != NULL) { - AG_FileDlgSetDirectory(dlg, "%s", config.initial_binary_dir); - } else { - _TCHAR app[AG_PATHNAME_MAX]; - AG_GetCWD(app, AG_PATHNAME_MAX); - AG_FileDlgSetDirectory(dlg, "%s", get_parent_dir(app)); - } - AG_FileDlgAddType(dlg, desc, ext, OnOpenBinarySub, "%i,%i", drv, loadf); - AG_WindowShow(win); - return; - +#if defined(USE_BINARY_FILE1) || defined(USE_BINARY_FILE2) +void CSP_DiskParams::_open_binary(QString s) { + emit sig_open_binary_file(drive, s, play); } #endif -#endif // ! + #ifdef SUPPORT_DRAG_DROP void open_any_file(_TCHAR* path) diff --git a/source/src/qt/common/qt_dialogs.h b/source/src/qt/common/qt_dialogs.h index d57b00161..b7d6b1204 100644 --- a/source/src/qt/common/qt_dialogs.h +++ b/source/src/qt/common/qt_dialogs.h @@ -1,3 +1,11 @@ +/* + Skelton for retropc emulator + + Author : K.Ohta + Date : 2015.01.07 + + [Qt dialogs] +*/ #ifndef _CSP_QT_DIALOGS_H #define _CSP_QT_DIALOGS_H @@ -5,74 +13,65 @@ #include "emu.h" #include "qt_main.h" -typedef class CSP_DiskParams : public QObject { - Q_OBJECT - Q_DISABLE_COPY(CSP_DiskParams) - public: +typedef class CSP_DiskParams : public QObject +{ +Q_OBJECT +Q_DISABLE_COPY(CSP_DiskParams) +public: // explicit CSP_DiskParams(QObject *parent = 0); - CSP_DiskParams(QObject *parent = 0) : QObject(parent){ - play = true; - drive = 0; - } - ~CSP_DiskParams() {} - void setDrive(int num) {drive = num & 7;} - int getDrive(void) { return drive;} - void setPlay(bool num) {play = num;} - bool isPlaying(void) { return play;} - void setRecMode(bool num) {play = num; } - int getRecMode(void) { - if(play) return 1; - return 0;; - } - - signals: - int do_open_disk(int, QString); - int do_close_disk(int); - int sig_open_cart(int, QString); - int do_close_cart(int); - int do_open_cmt(bool, QString); - int do_close_cmt(); + CSP_DiskParams(QObject *parent = 0) : QObject(parent){ + play = true; + drive = 0; + } + ~CSP_DiskParams() {} + void setDrive(int num) {drive = num & 7;} + int getDrive(void) { return drive;} + void setPlay(bool num) {play = num;} + bool isPlaying(void) { return play;} + void setRecMode(bool num) {play = num; } + int getRecMode(void) { + if(play) return 1; + return 0; + } +signals: + int do_open_disk(int, QString); + int do_close_disk(int); + int sig_open_cart(int, QString); + int do_close_cart(int); + int do_open_cmt(bool, QString); + int do_close_cmt(); #if defined(USE_QD1) || defined(USE_QD2) - int do_open_quick_disk(int, QString); + int do_open_quick_disk(int, QString); #endif #if defined(USE_BINARY_FILE1) || defined(USE_BINARY_FILE2) - int sig_open_binary_file(int, QString, bool); + int sig_open_binary_file(int, QString, bool); #endif - public slots: - void _open_disk(const QString fname); - void _open_cart(const QString fname); - void _open_cmt(const QString fname); +public slots: + void _open_disk(const QString fname); + void _open_cart(const QString fname); + void _open_cmt(const QString fname); #if defined(USE_BINARY_FILE1) || defined(USE_BINARY_FILE2) - void _open_binary(QString); + void _open_binary(QString); #endif #if defined(USE_QD1) || defined(USE_QD2) - void _open_quick_disk(QString); + void _open_quick_disk(QString); #endif - private: - int drive; - bool play; +private: + int drive; + bool play; } CSP_FileParams; typedef class CSP_DiskDialog : public QFileDialog { - Q_OBJECT - public: - CSP_FileParams *param; - CSP_DiskDialog(QWidget *parent = 0) : QFileDialog(parent) { - param = new CSP_FileParams(); - } - ~CSP_DiskDialog() { - delete param; - } - - +Q_OBJECT +public: + CSP_FileParams *param; + CSP_DiskDialog(QWidget *parent = 0) : QFileDialog(parent) { + param = new CSP_FileParams(); + } + ~CSP_DiskDialog() { + delete param; + } } CSP_DiskDialog; -extern "C" { -#ifdef USE_CART1 -#endif -#ifdef USE_FD1 -#endif -} - #endif //End. diff --git a/source/src/qt/common/qt_emuevents.h b/source/src/qt/common/qt_emuevents.h index eb0cd05a7..396c0e8be 100644 --- a/source/src/qt/common/qt_emuevents.h +++ b/source/src/qt/common/qt_emuevents.h @@ -16,54 +16,9 @@ extern EMU *emu; -#ifdef USE_DIPSWITCH -void OnToggleDipSw(int dipsw); -void OnChangeDipSw(int dipsw, int flag); -#endif - -#ifdef USE_DEVICE_TYPE -void OnSetDeviceType(int devtype); -#endif - -#if defined(USE_CART1) || defined(USE_CART2) -void OnOpenCart(QWidget *parent, int drive); -void OnCloseCart(int drive); -void OnRecentCart(int drive, int menunum); -#endif - -#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 OpenRecentFloppy(QWidget *parent, int drv, int num); -void OnCloseFD(int drive); -void OnOpenFD(QWidget *parent,int drive); -void OnSelectD88Bank(int drive, int no); -void Floppy_SelectD88(int drive, int num); -#endif - -#if defined(USE_QD1) || defined(USE_QD2) -//void OnOpenQD(QWidget *parent, int drive); -//void OnCloseQD(int drive); -//void OnRecentQD(QWidget *parent, int drive, int menunum); -#endif - -#ifdef USE_TAPE -void OnPlayTAPE(QWidget *parent); -void OnRecTAPE(QWidget *parent); -void OnCloseTAPE(void); -void OnUseWaveShaperTAPE(QWidget *wid); -void OnDirectLoadMZT(QWidget *wid); -void OnRecentTAPE(QWidget *parent, int menunum); -#endif - -#ifdef USE_TAPE_BUTTON -void OnPushPlayButton(QWidget *parent); -void OnPushStopButton(QWidget *parent); -#endif - -// Implement LASER Disc, binary -void OnStartRecordScreen(int num); -void OnStopRecordScreen(void); -void OnScreenCapture(QWidget *parent); -void OnFullScreen(QMainWindow *MainWindow, QWidget *drawspace, int mode); - +extern void OnStartRecordScreen(int num); +extern void OnStopRecordScreen(void); +extern void OnScreenCapture(QWidget *parent); +extern void OnFullScreen(QMainWindow *MainWindow, QWidget *drawspace, int mode); #endif // End diff --git a/source/src/qt/common/qt_gldraw.cpp b/source/src/qt/common/qt_gldraw.cpp index e2fa686a5..205529447 100644 --- a/source/src/qt/common/qt_gldraw.cpp +++ b/source/src/qt/common/qt_gldraw.cpp @@ -36,10 +36,10 @@ void GLDrawClass::SetBrightRGB(float r, float g, float b) { - fBrightR = r; - fBrightG = g; - fBrightB = b; -// SDLDrawFlag.Drawn = TRUE; // Force draw. + fBrightR = r; + fBrightG = g; + fBrightB = b; + // SDLDrawFlag.Drawn = TRUE; // Force draw. } @@ -63,278 +63,208 @@ void GLDrawClass::drawGrids(void *pg,int w, int h) void GLDrawClass::drawUpdateTexture(QImage *p, int w, int h, bool crtflag) { - uint32_t *pu; - uint32_t *pq; - int xx; - int yy; - int ww; - int hh; - int ofset; - BOOL flag; - int i; - // glPushAttrib(GL_TEXTURE_BIT); - ww = w >> 3; - hh = h >> 3; - crtflag = true; -//#ifdef _USE_OPENCL -#if 0 - if((cldraw != NULL) && (bCLEnabled)) { - cl_int ret = CL_SUCCESS; -// LockVram(); - flag = FALSE; - for(i = 0; i < h; i++) { - if(bDrawLine[i]) { - flag = TRUE; - } - } - //if(SDLDrawFlag.Drawn) flag = TRUE; - if(flag) { - ret = cldraw->GetVram(bModeOld); - for(i = 0; i < h; i++) bDrawLine[i] = FALSE; - - if(ret != CL_SUCCESS) { - //SDLDrawFlag.Drawn = FALSE; - bPaletFlag = FALSE; - this->bindTexture(GL_TEXTURE_2D, 0); - //UnlockVram(); - return; - } - } - if(bCLGLInterop){ - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, cldraw->GetPbo()); - this->bindTexture(GL_TEXTURE_2D, uVramTextureID); - // Copy pbo to texture - glTexSubImage2D(GL_TEXTURE_2D, - 0, - 0, - 0, - w, - h, - GL_RGBA, - GL_UNSIGNED_BYTE, - NULL); - glFinish(); - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); - this->indTexture(GL_TEXTURE_2D, 0); - glFinish(); - } else { // Not interoperability with GL - uint32_t *pp; - pp = cldraw->GetPixelBuffer(); - 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(); - cldraw->ReleasePixelBuffer(pp); - glBindTexture(GL_TEXTURE_2D, 0); - glFinish(); - } - //SDLDrawFlag.Drawn = FALSE; - bPaletFlag = FALSE; - //UnlockVram(); - } else { -#endif - //LockVram(); - flag = TRUE; - //flag |= SDLDrawFlag.Drawn; - if((p != NULL)) { - if(uVramTextureID != 0) deleteTexture(uVramTextureID); - uVramTextureID = QGLWidget::bindTexture(*p, GL_TEXTURE_2D, GL_RGBA); - } + uint32_t *pu; + uint32_t *pq; + int xx; + int yy; + int ww; + int hh; + int ofset; + BOOL flag; + int i; + // glPushAttrib(GL_TEXTURE_BIT); + ww = w >> 3; + hh = h >> 3; + crtflag = true; + //LockVram(); + flag = TRUE; + //flag |= SDLDrawFlag.Drawn; + if((p != NULL)) { + if(uVramTextureID != 0) deleteTexture(uVramTextureID); + uVramTextureID = QGLWidget::bindTexture(*p, GL_TEXTURE_2D, GL_RGBA); + } //#ifdef _USE_OPENCL -#if 0 - } -#endif - } void GLDrawClass::resizeGL(int width, int height) { - int side = qMin(width, height); - double ww, hh; - double ratio; - int w, h; - if(emu == NULL) return; - ww = (double)width; - hh = (double)height; + int side = qMin(width, height); + double ww, hh; + double ratio; + int w, h; + if(emu == NULL) return; + ww = (double)width; + hh = (double)height; #if 1 - switch(config.stretch_type) { - case 0: // Dot by Dot - ratio = (double)SCREEN_WIDTH / (double)SCREEN_HEIGHT; - h = (int)(ww / ratio); - w = (int)(hh * ratio); - break; - case 1: // Keep Aspect - ratio = (double)emu->get_screen_width_aspect() / (double)emu->get_screen_height_aspect(); - h = (int)(ww / ratio); - w = (int)(hh * ratio); - break; - case 2: // Fill - default: - h = height; - w = width; - ratio = (double)width / (double)height; - break; - } - if(h > height) { - h = height; - w = (int)((double)h * ratio); - } - if(w > width) { - w = width; - h = (int)((double)w / ratio); - } - glViewport((width - w) / 2, (height - h) / 2, w, h); + switch(config.stretch_type) { + case 0: // Dot by Dot + ratio = (double)SCREEN_WIDTH / (double)SCREEN_HEIGHT; + h = (int)(ww / ratio); + w = (int)(hh * ratio); + break; + case 1: // Keep Aspect + ratio = (double)emu->get_screen_width_aspect() / (double)emu->get_screen_height_aspect(); + h = (int)(ww / ratio); + w = (int)(hh * ratio); + break; + case 2: // Fill + default: + h = height; + w = width; + ratio = (double)width / (double)height; + break; + } + if(h > height) { + h = height; + w = (int)((double)h * ratio); + } + if(w > width) { + w = width; + h = (int)((double)w / ratio); + } + glViewport((width - w) / 2, (height - h) / 2, w, h); #else - glViewport(0, 0, width, height); + glViewport(0, 0, width, height); #endif - AGAR_DebugLog(AGAR_LOG_DEBUG, "ResizeGL: %dx%d\n", width , height); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); + AGAR_DebugLog(AGAR_LOG_DEBUG, "ResizeGL: %dx%d\n", width , height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); #ifdef QT_OPENGL_ES_1 - glOrthof(-1.0, 1.0, +1.0, -1.0, -1.0, 1.0); + glOrthof(-1.0, 1.0, +1.0, -1.0, -1.0, 1.0); #else - glOrtho(-1.0, 1.0, +1.0, -1.0, -1.0, 1.0); + glOrtho(-1.0, 1.0, +1.0, -1.0, -1.0, 1.0); #endif -// glMatrixMode(GL_MODELVIEW);// glLoadIdentity(); + // glMatrixMode(GL_MODELVIEW);// glLoadIdentity(); } /* - * "Paint"イベントハンドラ + * "Paint" Event handler */ void GLDrawClass::paintGL(void) { - int w; - int h; - int i; - float width; - float yf; - QImage *p; - uint32_t *pp; - int x; - int y; - GLfloat TexCoords[4][2]; - GLfloat Vertexs[4][3]; - GLfloat TexCoords2[4][2]; - GLfloat *gridtid; - bool crtflag = true; - - if(emu == NULL) return; - w = SCREEN_WIDTH; - h = SCREEN_HEIGHT; - p = emu->getPseudoVramClass(); - if(p == NULL) return; - TexCoords[0][0] = TexCoords[3][0] = 0.0f; // Xbegin - TexCoords[0][1] = TexCoords[1][1] = 0.0f; // Ybegin + int w; + int h; + int i; + float width; + float yf; + QImage *p; + uint32_t *pp; + int x; + int y; + GLfloat TexCoords[4][2]; + GLfloat Vertexs[4][3]; + GLfloat TexCoords2[4][2]; + GLfloat *gridtid; + bool crtflag = true; + + if(emu == NULL) return; + w = SCREEN_WIDTH; + h = SCREEN_HEIGHT; + p = emu->getPseudoVramClass(); + 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] = 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.0f; - Vertexs[0][0] = Vertexs[3][0] = -1.0f; // Xbegin - Vertexs[0][1] = Vertexs[1][1] = 1.0f; // Yend - Vertexs[2][0] = Vertexs[1][0] = 1.0f; // Xend - Vertexs[2][1] = Vertexs[3][1] = -1.0f; // Ybegin - - -// if(uVramTextureID == 0) uVramTextureID = CreateNullTexture(640, 400); // ドットゴーストを防ぐ - if(uNullTextureID == 0) uNullTextureID = CreateNullTexture(640, 400); // ドットゴーストを防ぐ - /* - * 20110904 OOPS! Updating-Texture must be in Draw-Event-Handler(--; - */ - - glPushAttrib(GL_TEXTURE_BIT); - glPushAttrib(GL_TRANSFORM_BIT); - glPushAttrib(GL_ENABLE_BIT); + 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.0f; + Vertexs[0][0] = Vertexs[3][0] = -1.0f; // Xbegin + Vertexs[0][1] = Vertexs[1][1] = 1.0f; // Yend + Vertexs[2][0] = Vertexs[1][0] = 1.0f; // Xend + Vertexs[2][1] = Vertexs[3][1] = -1.0f; // Ybegin + + + // if(uVramTextureID == 0) uVramTextureID = CreateNullTexture(640, 400); // ドットゴーストを防ぐ + if(uNullTextureID == 0) uNullTextureID = CreateNullTexture(640, 400); // ドットゴーストを防ぐ + /* + * 20110904 OOPS! Updating-Texture must be in Draw-Event-Handler(--; + */ + + glPushAttrib(GL_TEXTURE_BIT); + glPushAttrib(GL_TRANSFORM_BIT); + glPushAttrib(GL_ENABLE_BIT); #ifdef _USE_OPENCL -// InitContextCL(); + // InitContextCL(); #endif - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glEnable(GL_DEPTH_TEST); - glDisable(GL_BLEND); - - /* - * VRAMの表示:テクスチャ貼った四角形 - */ - //if(uVramTextureID != 0) { - -// if(crtflag){ - glEnable(GL_TEXTURE_2D); - 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); -// 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); -// drawTexture(QPointF(0,0),uVramTextureID,GL_TEXTURE_2D); - //} 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); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glEnable(GL_DEPTH_TEST); + glDisable(GL_BLEND); + + /* + * VRAMの表示:テクスチャ貼った四角形 + */ + //if(uVramTextureID != 0) { + + glEnable(GL_TEXTURE_2D); + drawUpdateTexture(p, w, h, crtflag); + //if(!bSmoosing) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + // drawTexture(QPointF(0,0),uVramTextureID,GL_TEXTURE_2D); + //} 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); -// 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 { - glBegin(GL_POLYGON); - glTexCoord2f(TexCoords[0][0], TexCoords[0][1]); - glVertex3f(Vertexs[0][0], Vertexs[0][1], Vertexs[0][2]); + // 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 { + glBegin(GL_POLYGON); + glTexCoord2f(TexCoords[0][0], TexCoords[0][1]); + glVertex3f(Vertexs[0][0], Vertexs[0][1], Vertexs[0][2]); + + glTexCoord2f(TexCoords[1][0], TexCoords[1][1]); + glVertex3f(Vertexs[1][0], Vertexs[1][1], Vertexs[1][2]); - glTexCoord2f(TexCoords[1][0], TexCoords[1][1]); - glVertex3f(Vertexs[1][0], Vertexs[1][1], Vertexs[1][2]); - - glTexCoord2f(TexCoords[2][0], TexCoords[2][1]); - glVertex3f(Vertexs[2][0], Vertexs[2][1], Vertexs[2][2]); + glTexCoord2f(TexCoords[2][0], TexCoords[2][1]); + glVertex3f(Vertexs[2][0], Vertexs[2][1], Vertexs[2][2]); - glTexCoord2f(TexCoords[3][0], TexCoords[3][1]); - glVertex3f(Vertexs[3][0], Vertexs[3][1], Vertexs[3][2]); - glEnd(); - // } + glTexCoord2f(TexCoords[3][0], TexCoords[3][1]); + glVertex3f(Vertexs[3][0], Vertexs[3][1], Vertexs[3][2]); + glEnd(); + // } - // 20120502 輝度調整 - glBindTexture(GL_TEXTURE_2D, 0); // 20111023 - glDisable(GL_TEXTURE_2D); - glDisable(GL_DEPTH_TEST); + // 20120502 輝度調整 + glBindTexture(GL_TEXTURE_2D, 0); // 20111023 + glDisable(GL_TEXTURE_2D); + glDisable(GL_DEPTH_TEST); // if(bCLEnabled == FALSE){ - glEnable(GL_BLEND); + 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 { - 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_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 { + 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); + glBlendFunc(GL_ONE, GL_ZERO); - glDisable(GL_BLEND); + glDisable(GL_BLEND); // } - glDisable(GL_TEXTURE_2D); - glDisable(GL_DEPTH_TEST); + glDisable(GL_TEXTURE_2D); + glDisable(GL_DEPTH_TEST); # if 0 if(glv->wid.rView.h >= h) { glLineWidth((float)(glv->wid.rView.h) / (float)(h * 2)); @@ -357,26 +287,26 @@ void GLDrawClass::paintGL(void) } #endif //} - glDisable(GL_BLEND); - glDisable(GL_TEXTURE_2D); - glDisable(GL_DEPTH_TEST); + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glDisable(GL_DEPTH_TEST); #ifdef USE_OPENGL - //DrawOSDGL(glv); + //DrawOSDGL(glv); #endif - glPopAttrib(); - glPopAttrib(); - glPopAttrib(); - glFlush(); -// swapBuffers(); + glPopAttrib(); + glPopAttrib(); + glPopAttrib(); + glFlush(); + // swapBuffers(); } #ifndef GL_MULTISAMPLE #define GL_MULTISAMPLE 0x809D #endif - GLDrawClass::GLDrawClass(QWidget *parent) +GLDrawClass::GLDrawClass(QWidget *parent) : QGLWidget(QGLFormat(QGL::SampleBuffers), parent) - { +{ uVramTextureID = 0; uNullTextureID = 0; fBrightR = 1.0; // 輝度の初期化 @@ -393,7 +323,7 @@ void GLDrawClass::paintGL(void) //bCLDirectMapping = false; #endif this->setFocusPolicy(Qt::StrongFocus); - } +} GLDrawClass::~GLDrawClass() { @@ -401,11 +331,11 @@ GLDrawClass::~GLDrawClass() QSize GLDrawClass::minimumSizeHint() const { - return QSize(50, 50); + return QSize(50, 50); } QSize GLDrawClass::sizeHint() const - { - return QSize(400, 400); - } +{ + return QSize(400, 400); +} diff --git a/source/src/qt/common/qt_gldraw.h b/source/src/qt/common/qt_gldraw.h index 0cee70bf9..fa4a7852b 100644 --- a/source/src/qt/common/qt_gldraw.h +++ b/source/src/qt/common/qt_gldraw.h @@ -1,6 +1,11 @@ - -#ifndef _CSP_QT_DIALOG_H -#define _CSP_QT_DIALOG_H +/* + * qt_gldraw.h + * (c) 2011 K.Ohta + * Modified to Common Source code Project, License is changed to GPLv2. + * + */ +#ifndef _CSP_QT_GLDRAW_H +#define _CSP_QT_GLDRAW_H //#include #include @@ -9,106 +14,91 @@ class GLDrawClass: public QGLWidget { - Q_OBJECT - +Q_OBJECT public: - GLDrawClass(QWidget *parent = 0); - ~GLDrawClass(); + GLDrawClass(QWidget *parent = 0); + ~GLDrawClass(); - QSize minimumSizeHint() const; - QSize sizeHint() const; - bool crt_flag; - GLuint CreateNullTexture(int w, int h); - GLuint CreateNullTextureCL(int w, int h); -#if 0 // TEST - GLDrawClass( QWidget *parent = 0 , const char *name = 0 ) { -// InitGLExtensionVars(); -#ifdef _USE_OPENCL - // Init CL -#endif - modifier = 0; - } -#else // TEST - //GLDrawClass(QWidget *parent) - //: QGLWidget(QGLFormat(QGL::SampleBuffers), parent) - //~GLWidget(); -#endif // Test - quint32 getModState(void) { return modifier;} - quint32 modifier; - void SetBrightRGB(float r, float g, float b); - void drawUpdateTexture(QImage *p, int w, int h, bool crtflag); - //void DrawHandler(void); - void InitFBO(void); - void InitGridVertexs(void); - void DiscardTextures(int n, GLuint *id); - void DiscardTexture(GLuint tid); + QSize minimumSizeHint() const; + QSize sizeHint() const; + bool crt_flag; + GLuint CreateNullTexture(int w, int h); + GLuint CreateNullTextureCL(int w, int h); + quint32 getModState(void) { return modifier;} + quint32 modifier; + void SetBrightRGB(float r, float g, float b); + void drawUpdateTexture(QImage *p, int w, int h, bool crtflag); + //void DrawHandler(void); + void InitFBO(void); + void InitGridVertexs(void); + void DiscardTextures(int n, GLuint *id); + void DiscardTexture(GLuint tid); - bool bGL_ARB_IMAGING; // イメージ操作可能か? - bool bGL_ARB_COPY_BUFFER; // バッファ内コピー(高速化!)サポート - bool bGL_EXT_INDEX_TEXTURE; // パレットモードに係わる - bool bGL_EXT_COPY_TEXTURE; // テクスチャ間のコピー - bool bGL_SGI_COLOR_TABLE; // パレットモード(SGI拡張) - bool bGL_SGIS_PIXEL_TEXTURE; // テクスチャアップデート用 - bool bGL_EXT_PACKED_PIXEL; // PackedPixelを使ってアップデートを高速化? - bool bGL_EXT_VERTEX_ARRAY; // 頂点を配列化して描画を高速化 - bool bGL_EXT_PALETTED_TEXTURE; // パレットモード(更に別拡張) - bool bGL_PIXEL_UNPACK_BUFFER_BINDING; // ピクセルバッファがあるか? + bool bGL_ARB_IMAGING; // イメージ操作可能か? + bool bGL_ARB_COPY_BUFFER; // バッファ内コピー(高速化!)サポート + bool bGL_EXT_INDEX_TEXTURE; // パレットモードに係わる + bool bGL_EXT_COPY_TEXTURE; // テクスチャ間のコピー + bool bGL_SGI_COLOR_TABLE; // パレットモード(SGI拡張) + bool bGL_SGIS_PIXEL_TEXTURE; // テクスチャアップデート用 + bool bGL_EXT_PACKED_PIXEL; // PackedPixelを使ってアップデートを高速化? + bool bGL_EXT_VERTEX_ARRAY; // 頂点を配列化して描画を高速化 + bool bGL_EXT_PALETTED_TEXTURE; // パレットモード(更に別拡張) + bool bGL_PIXEL_UNPACK_BUFFER_BINDING; // ピクセルバッファがあるか? -// FBO API - PFNGLVERTEXPOINTEREXTPROC glVertexPointerEXT; - PFNGLDRAWARRAYSEXTPROC glDrawArraysEXT; - PFNGLTEXCOORDPOINTEREXTPROC glTexCoordPointerEXT; - - PFNGLBINDBUFFERPROC glBindBuffer; - PFNGLBUFFERDATAPROC glBufferData; - PFNGLGENBUFFERSPROC glGenBuffers; - PFNGLDELETEBUFFERSPROC glDeleteBuffers; + // FBO API + PFNGLVERTEXPOINTEREXTPROC glVertexPointerEXT; + PFNGLDRAWARRAYSEXTPROC glDrawArraysEXT; + PFNGLTEXCOORDPOINTEREXTPROC glTexCoordPointerEXT; - public slots: - void update_screen(int tick); - void resizeGL(int width, int height); - signals: - void update_screenChanged(int tick); - protected: - uint32_t keyin_lasttime; - void keyReleaseEvent(QKeyEvent *event); - void keyPressEvent(QKeyEvent *event); - void initializeGL(); - void paintGL(); - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - GLuint uVramTextureID; - GLuint uNullTextureID; - float GridVertexs200l[202 * 6]; - float GridVertexs400l[402 * 6]; - float fBrightR; - float fBrightG; - float fBrightB; - QTimer *timer; - // Will move to OpenCL - bool bInitCL; - bool bCLEnabled; - bool bCLGLInterop; - int nCLGlobalWorkThreads; - bool bCLSparse; // TRUE=Multi threaded CL,FALSE = Single Thread. - int nCLPlatformNum; - int nCLDeviceNum; - bool bCLInteropGL; + PFNGLBINDBUFFERPROC glBindBuffer; + PFNGLBUFFERDATAPROC glBufferData; + PFNGLGENBUFFERSPROC glGenBuffers; + PFNGLDELETEBUFFERSPROC glDeleteBuffers; +public slots: + void update_screen(int tick); + void resizeGL(int width, int height); +signals: + void update_screenChanged(int tick); +protected: + uint32_t keyin_lasttime; + void keyReleaseEvent(QKeyEvent *event); + void keyPressEvent(QKeyEvent *event); + void initializeGL(); + void paintGL(); + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + GLuint uVramTextureID; + GLuint uNullTextureID; + float GridVertexs200l[202 * 6]; + float GridVertexs400l[402 * 6]; + float fBrightR; + float fBrightG; + float fBrightB; + QTimer *timer; + // Will move to OpenCL + bool bInitCL; + bool bCLEnabled; + bool bCLGLInterop; + int nCLGlobalWorkThreads; + bool bCLSparse; // TRUE=Multi threaded CL,FALSE = Single Thread. + int nCLPlatformNum; + int nCLDeviceNum; + bool bCLInteropGL; // - bool InitVideo; - void drawGrids(void *pg,int w, int h); - // void initializeGL(void); - //void paintGL(void); - //void resizeGL(int width, int height); - uint32_t get106Scancode2VK(uint32_t data); + bool InitVideo; + void drawGrids(void *pg,int w, int h); + // void initializeGL(void); + //void paintGL(void); + //void resizeGL(int width, int height); + uint32_t get106Scancode2VK(uint32_t data); #ifdef _USE_OPENCL -// extern class GLCLDraw *cldraw; + // extern class GLCLDraw *cldraw; #endif - bool QueryGLExtensions(const char *str); - void InitGLExtensionVars(void); - void InitGridVertexsSub(GLfloat *p, int h); - void InitContextCL(void); + bool QueryGLExtensions(const char *str); + void InitGLExtensionVars(void); + void InitGridVertexsSub(GLfloat *p, int h); + void InitContextCL(void); }; #endif // End. diff --git a/source/src/qt/common/qt_glevents.cpp b/source/src/qt/common/qt_glevents.cpp index 3f8206959..89a64911d 100644 --- a/source/src/qt/common/qt_glevents.cpp +++ b/source/src/qt/common/qt_glevents.cpp @@ -22,13 +22,13 @@ #include "qt_gldraw.h" void GLDrawClass::mousePressEvent(QMouseEvent *event) - { +{ // lastPos = event->pos(); - } +} void GLDrawClass::mouseMoveEvent(QMouseEvent *event) - { +{ // int dx = event->x() - lastPos.x(); // int dy = event->y() - lastPos.y(); - } +} diff --git a/source/src/qt/common/qt_glutil.cpp b/source/src/qt/common/qt_glutil.cpp index f4ec31bb9..1250851e3 100644 --- a/source/src/qt/common/qt_glutil.cpp +++ b/source/src/qt/common/qt_glutil.cpp @@ -1,5 +1,5 @@ /* - * Agar: OpenGLUtils + * Qt: OpenGL Utils * (C) 2011 K.Ohta */ @@ -22,67 +22,66 @@ #endif void GLDrawClass::update_screen(int tick) { - //if(tick < (1000 / 75)) tick = 1000 / 75; - updateGL(); - printf("UpdateGL(), %d\n", SDL_GetTicks()); - //timer->start(tick); - //emit update_screenChanged(tick); + //if(tick < (1000 / 75)) tick = 1000 / 75; + updateGL(); + printf("UpdateGL(), %d\n", SDL_GetTicks()); + //timer->start(tick); + //emit update_screenChanged(tick); } GLuint GLDrawClass::CreateNullTexture(int w, int h) { - GLuint ttid; - Uint32 *p; + GLuint ttid; + Uint32 *p; - p =(Uint32 *)malloc((w + 2)* (h + 2) * sizeof(Uint32)); - if(p == NULL) return 0; + p =(Uint32 *)malloc((w + 2)* (h + 2) * sizeof(Uint32)); + if(p == NULL) return 0; - // memset(p, 0x00, (w + 2) * (h + 2) * sizeof(Uint32)); - memset(p, 0x00, (w + 2) * (h + 2) * sizeof(Uint32)); - glGenTextures(1, &ttid); - glBindTexture(GL_TEXTURE_2D, ttid); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1); // Limit mipmap level , reduce resources. - glTexImage2D(GL_TEXTURE_2D, - 0, - GL_RGBA, - w, h + 2, - 0, - GL_RGBA, - GL_UNSIGNED_BYTE, - p); - free(p); - return ttid; + // memset(p, 0x00, (w + 2) * (h + 2) * sizeof(Uint32)); + memset(p, 0x00, (w + 2) * (h + 2) * sizeof(Uint32)); + glGenTextures(1, &ttid); + glBindTexture(GL_TEXTURE_2D, ttid); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1); // Limit mipmap level , reduce resources. + glTexImage2D(GL_TEXTURE_2D, + 0, + GL_RGBA, + w, h + 2, + 0, + GL_RGBA, + GL_UNSIGNED_BYTE, + p); + free(p); + return ttid; } GLuint GLDrawClass::CreateNullTextureCL(int w, int h) { - GLuint ttid; - Uint32 *p; + GLuint ttid; + Uint32 *p; - p =(Uint32 *)malloc((w + 2)* (h + 2) * sizeof(Uint32)); - if(p == NULL) return 0; - memset(p, 0x00, (w + 2) * (h + 2) * sizeof(Uint32)); - glGenTextures(1, &ttid); - glBindTexture(GL_TEXTURE_2D, ttid); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1); // Limit mipmap level , reduce resources. - glTexImage2D(GL_TEXTURE_2D, - 0, - GL_RGBA8UI, - w, h + 2, - 0, - GL_RGBA_INTEGER, - GL_UNSIGNED_BYTE, - p); - glBindTexture(GL_TEXTURE_2D, 0); - free(p); - return ttid; + p =(Uint32 *)malloc((w + 2)* (h + 2) * sizeof(Uint32)); + if(p == NULL) return 0; + memset(p, 0x00, (w + 2) * (h + 2) * sizeof(Uint32)); + glGenTextures(1, &ttid); + glBindTexture(GL_TEXTURE_2D, ttid); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1); // Limit mipmap level , reduce resources. + glTexImage2D(GL_TEXTURE_2D, + 0, + GL_RGBA8UI, + w, h + 2, + 0, + GL_RGBA_INTEGER, + GL_UNSIGNED_BYTE, + p); + glBindTexture(GL_TEXTURE_2D, 0); + free(p); + return ttid; } void GLDrawClass::DiscardTextures(int n, GLuint *id) { glDeleteTextures(n, id); - } void GLDrawClass::DiscardTexture(GLuint tid) @@ -93,9 +92,8 @@ void GLDrawClass::DiscardTexture(GLuint tid) void GLDrawClass::InitContextCL(void) { - #if 0 - if(bInitCL == true) return; // CL already initialized. + if(bInitCL == true) return; // CL already initialized. # ifdef _USE_OPENCL bCLEnabled = false; bCLGLInterop = false; @@ -145,107 +143,95 @@ void GLDrawClass::InitContextCL(void) void GLDrawClass::InitGridVertexsSub(GLfloat *p, int h) { - int y; - int yp; - float yf; - yp = 0; - for(y = 0; y < (h + 1); y++) { - yf = -1.0f + (float) (y + 1) * 2.0f / (float)h; - p[yp + 0] = -1.0f; - p[yp + 1] = yf; - p[yp + 2] = 0.96f; - p[yp + 3] = -1.0f; - p[yp + 4] = yf; - p[yp + 5] = 0.96f; - yp += 6; - } - return; + int y; + int yp; + float yf; + yp = 0; + for(y = 0; y < (h + 1); y++) { + yf = -1.0f + (float) (y + 1) * 2.0f / (float)h; + p[yp + 0] = -1.0f; + p[yp + 1] = yf; + p[yp + 2] = 0.96f; + p[yp + 3] = -1.0f; + p[yp + 4] = yf; + p[yp + 5] = 0.96f; + yp += 6; + } + return; } void GLDrawClass::InitGridVertexs(void) { - InitGridVertexsSub(GridVertexs200l, 200); - InitGridVertexsSub(GridVertexs400l, 400); + InitGridVertexsSub(GridVertexs200l, 200); + InitGridVertexsSub(GridVertexs400l, 400); } -#if 1 void GLDrawClass::initializeGL(void) { - #ifdef _USE_OPENCL - cldraw = NULL; + cldraw = NULL; #endif - /* - * GL 拡張の取得 20110907- - */ + /* + * GL 拡張の取得 20110907- + */ //InitVramSemaphore(); -// InitVirtualVram(); + // InitVirtualVram(); //if(AG_UsingSDL(NULL)) { - InitFBO(); // 拡張の有無を調べてからFBOを初期化する。 - // FBOの有無を受けて、拡張の有無変数を変更する(念のために) - InitGLExtensionVars(); - InitGridVertexs(); // Grid初期化 - // Init view - glClearColor(0.0, 0.0, 0.0, 1.0); -#ifdef QT_OPENGL_ES_1 -// glOrthof(-1.0, 1.0, +1.0, -1.0, -1.0, 1.0); -#else -// glOrtho(-1.0, 1.0, +1.0, -1.0, -1.0, 1.0); -#endif + InitFBO(); // 拡張の有無を調べてからFBOを初期化する。 + // FBOの有無を受けて、拡張の有無変数を変更する(念のために) + InitGLExtensionVars(); + InitGridVertexs(); // Grid初期化 + // Init view + glClearColor(0.0, 0.0, 0.0, 1.0); } -#endif // OpenGL状態変数 -//#endif - bool GLDrawClass::QueryGLExtensions(const char *str) { - char *ext; - char *p; - int i; - int j; - int k; - int l; - int ll; -//#ifndef _WINDOWS + char *ext; + char *p; + int i; + int j; + int k; + int l; + int ll; - if(str == NULL) return false; - ll = strlen(str); - if(ll <= 0) return false; - - ext =(char *)glGetString(GL_EXTENSIONS); - if(ext == NULL) return false; - l = strlen(ext); - if(l <= 0) return false; - p = ext; - for(i = 0; i < l ; ){ - int j = strcspn(p, " "); - if((ll == j) && (strncmp(str, p, j) == 0)) { - return true; - } - p += (j + 1); - i += (j + 1); - } -//#endif - return false; + if(str == NULL) return false; + ll = strlen(str); + if(ll <= 0) return false; + + ext =(char *)glGetString(GL_EXTENSIONS); + if(ext == NULL) return false; + l = strlen(ext); + if(l <= 0) return false; + p = ext; + for(i = 0; i < l ; ){ + int j = strcspn(p, " "); + if((ll == j) && (strncmp(str, p, j) == 0)) { + return true; + } + p += (j + 1); + i += (j + 1); + } + return false; } void GLDrawClass::InitGLExtensionVars(void) { - bGL_ARB_IMAGING = QueryGLExtensions("GL_ARB_imaging"); - bGL_ARB_COPY_BUFFER = QueryGLExtensions("GL_ARB_copy_buffer"); - bGL_EXT_INDEX_TEXTURE = QueryGLExtensions("GL_EXT_index_texture"); - bGL_EXT_COPY_TEXTURE = QueryGLExtensions("GL_EXT_copy_texture"); - bGL_SGI_COLOR_TABLE = QueryGLExtensions("GL_SGI_color_table"); - bGL_SGIS_PIXEL_TEXTURE = QueryGLExtensions("GL_SGIS_pixel_texture"); - bGL_EXT_PACKED_PIXEL = QueryGLExtensions("GL_EXT_packed_pixel"); - bGL_EXT_PALETTED_TEXTURE = QueryGLExtensions("GL_EXT_paletted_texture"); - bGL_EXT_VERTEX_ARRAY = QueryGLExtensions("GL_EXT_vertex_array"); -// bGL_PIXEL_UNPACK_BUFFER_BINDING = QueryGLExtensions("GL_pixel_unpack_buffer_binding"); - bGL_PIXEL_UNPACK_BUFFER_BINDING = true; - bCLEnabled = false; - bCLGLInterop = false; + bGL_ARB_IMAGING = QueryGLExtensions("GL_ARB_imaging"); + bGL_ARB_COPY_BUFFER = QueryGLExtensions("GL_ARB_copy_buffer"); + bGL_EXT_INDEX_TEXTURE = QueryGLExtensions("GL_EXT_index_texture"); + bGL_EXT_COPY_TEXTURE = QueryGLExtensions("GL_EXT_copy_texture"); + bGL_SGI_COLOR_TABLE = QueryGLExtensions("GL_SGI_color_table"); + bGL_SGIS_PIXEL_TEXTURE = QueryGLExtensions("GL_SGIS_pixel_texture"); + bGL_EXT_PACKED_PIXEL = QueryGLExtensions("GL_EXT_packed_pixel"); + bGL_EXT_PALETTED_TEXTURE = QueryGLExtensions("GL_EXT_paletted_texture"); + bGL_EXT_VERTEX_ARRAY = QueryGLExtensions("GL_EXT_vertex_array"); + // bGL_PIXEL_UNPACK_BUFFER_BINDING = QueryGLExtensions("GL_pixel_unpack_buffer_binding"); + bGL_PIXEL_UNPACK_BUFFER_BINDING = true; + bCLEnabled = false; + bCLGLInterop = false; } @@ -258,21 +244,20 @@ extern PROC WINAPI wglGetProcAddress(LPCSTR lpszProc); void GLDrawClass::InitFBO(void) { -//#ifndef _WINDOWS // glx is for X11. -// Use SDL for wrapper. 20130128 - //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; - + //#ifndef _WINDOWS // glx is for X11. + // Use SDL for wrapper. 20130128 + //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.h b/source/src/qt/common/qt_input.h index 3cc8285e6..faba0a5ce 100644 --- a/source/src/qt/common/qt_input.h +++ b/source/src/qt/common/qt_input.h @@ -13,88 +13,82 @@ 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 + 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 QtKeyTable { - uint32_t vk; - enum Qt::Key qtkey; -}; -struct SDLKeyTable { - uint32_t vk; - uint32_t sdlkey; + uint32_t vk; + enum Qt::Key qtkey; }; - uint32_t GetAsyncKeyState(uint32_t vk, uint32_t mod); - uint8_t convert_AGKey2VK(uint32_t sym); +uint32_t GetAsyncKeyState(uint32_t vk, uint32_t mod); +uint8_t convert_AGKey2VK(uint32_t sym); extern const struct QtKeyTable QtKeyMappings[]; #ifdef __cplusplus diff --git a/source/src/qt/common/qt_main.cpp b/source/src/qt/common/qt_main.cpp index c8c2c4db5..02c0c8779 100644 --- a/source/src/qt/common/qt_main.cpp +++ b/source/src/qt/common/qt_main.cpp @@ -60,10 +60,7 @@ int get_interval() void EmuThreadClass::doExit(void) { int status; -// setRunEmuThread(false); -// if(hRunEmuThread != NULL) SDL_WaitThread(hRunEmuThread, &status); bRunThread = false; -// delete_emu_thread(); } void EmuThreadClass::set_tape_play(bool flag) @@ -134,81 +131,81 @@ void EmuThreadClass::doWork(const QString ¶ms) } msleep(10); continue; - } - interval = 0; - sleep_period = 0; - if(p_emu) { - // drive machine - run_frames = p_emu->run(); - total_frames += run_frames; - //p_emu->LockVM(); + } + interval = 0; + sleep_period = 0; + if(p_emu) { + // drive machine + run_frames = p_emu->run(); + total_frames += run_frames; + //p_emu->LockVM(); #ifdef USE_TAPE_BUTTON - tape_flag = p_emu->get_tape_play(); - if(tape_play_flag != tape_flag) emit sig_tape_play_stat(tape_flag); - tape_play_flag = tape_flag; + tape_flag = p_emu->get_tape_play(); + if(tape_play_flag != tape_flag) emit sig_tape_play_stat(tape_flag); + tape_play_flag = tape_flag; #endif - interval += get_interval(); + interval += get_interval(); - now_skip = p_emu->now_skip() & !p_emu->now_rec_video; - //p_emu->UnlockVM(); + now_skip = p_emu->now_skip() & !p_emu->now_rec_video; + //p_emu->UnlockVM(); - if((prev_skip && !now_skip) || next_time == 0) { - next_time = timeGetTime(); - } - if(!now_skip) { - next_time += interval; - } - prev_skip = now_skip; - //printf("p_emu::RUN Frames = %d SKIP=%d Interval = %d NextTime = %d\n", run_frames, now_skip, interval, next_time); + if((prev_skip && !now_skip) || next_time == 0) { + next_time = timeGetTime(); + } + if(!now_skip) { + next_time += interval; + } + prev_skip = now_skip; + //printf("p_emu::RUN Frames = %d SKIP=%d Interval = %d NextTime = %d\n", run_frames, now_skip, interval, next_time); - if(next_time > timeGetTime()) { - // update window if enough time - emit sig_draw_thread(); - skip_frames = 0; + if(next_time > timeGetTime()) { + // update window if enough time + emit sig_draw_thread(); + skip_frames = 0; - // sleep 1 frame priod if need - current_time = timeGetTime(); - if((int)(next_time - current_time) >= 10) { - sleep_period = next_time - current_time; + // sleep 1 frame priod if need + current_time = timeGetTime(); + if((int)(next_time - current_time) >= 10) { + sleep_period = next_time - current_time; + } + } else if(++skip_frames > MAX_SKIP_FRAMES) { + // update window at least once per 10 frames + emit sig_draw_thread(); + + //printf("p_emu::Updated Frame %d\n", AG_GetTicks()); + skip_frames = 0; + next_time = timeGetTime() + get_interval(); + sleep_period = next_time - timeGetTime(); + } + if(bResetReq != false) { + p_emu->reset(); + bResetReq = false; } - } else if(++skip_frames > MAX_SKIP_FRAMES) { - // update window at least once per 10 frames - emit sig_draw_thread(); - - //printf("p_emu::Updated Frame %d\n", AG_GetTicks()); - skip_frames = 0; - next_time = timeGetTime() + get_interval(); - sleep_period = next_time - timeGetTime(); - } - if(bResetReq != false) { - p_emu->reset(); - bResetReq = false; - } #ifdef USE_SPECIAL_RESET - if(bSpecialResetReq != false) { - p_emu->special_reset(); - bSpecialResetReq = false; - } + if(bSpecialResetReq != false) { + p_emu->special_reset(); + bSpecialResetReq = false; + } #endif #ifdef USE_STATE - if(bLoadStateReq != false) { - p_emu->load_state(); - bLoadStateReq = false; + if(bLoadStateReq != false) { + p_emu->load_state(); + bLoadStateReq = false; + } + if(bSaveStateReq != false) { + p_emu->load_state(); + bSaveStateReq = false; + } +#endif } - if(bSaveStateReq != false) { - p_emu->load_state(); - bSaveStateReq = false; + if(bRunThread == false){ + goto _exit; } -#endif - } - if(bRunThread == false){ - goto _exit; - } - if(sleep_period <= 0) sleep_period = 1; - msleep(sleep_period); - } while(1); + if(sleep_period <= 0) sleep_period = 1; + msleep(sleep_period); + } while(1); _exit: emit quit_draw_thread(); AGAR_DebugLog(AGAR_LOG_DEBUG, "EmuThread : EXIT"); @@ -268,16 +265,6 @@ void DrawThreadClass::doWork(const QString ¶m) } - - -void Ui_MainWindow::doExit_EmuThread(void) -{ - int status; - setRunEmuThread(false); - if(hRunEmuThread != NULL) SDL_WaitThread(hRunEmuThread, &status); - delete_emu_thread(); -} - void Ui_MainWindow::doChangeMessage_EmuThread(QString message) { emit message_changed(message); @@ -329,7 +316,8 @@ void Ui_MainWindow::LaunchEmuThread(void) } -void Ui_MainWindow::StopEmuThread(void) { +void Ui_MainWindow::StopEmuThread(void) +{ emit quit_emu_thread(); } @@ -349,77 +337,76 @@ AGAR_CPUID *pCpuID; void Convert_CP932_to_UTF8(char *dst, char *src, int n_limit, int i_limit) { //#ifdef USE_ICONV - char *pIn, *pOut; - iconv_t hd; - size_t in, out; - char utf8[1024]; - char s_in[1024]; + char *pIn, *pOut; + iconv_t hd; + size_t in, out; + char utf8[1024]; + char s_in[1024]; // printf("Convert CP932 to UTF8: %08x, %d\n", src, n_limit); - if((n_limit <= 0) || (src == NULL)) return; - if(n_limit > 1023) n_limit = 1023; - if(i_limit > 1023) i_limit = 1023; - memset(utf8, 0x00, sizeof(utf8)); - memset(s_in, 0x00, sizeof(s_in)); - memset(dst, 0x00, n_limit); - //strncpy(s_in, src, i_limit); - //pIn = s_in; - pIn = src; - pOut = utf8; - in = strlen(pIn); - if(in > i_limit) in = i_limit; - if(in <= 0) return; + if((n_limit <= 0) || (src == NULL)) return; + if(n_limit > 1023) n_limit = 1023; + if(i_limit > 1023) i_limit = 1023; + memset(utf8, 0x00, sizeof(utf8)); + memset(s_in, 0x00, sizeof(s_in)); + memset(dst, 0x00, n_limit); + //strncpy(s_in, src, i_limit); + //pIn = s_in; + pIn = src; + pOut = utf8; + in = strlen(pIn); + if(in > i_limit) in = i_limit; + if(in <= 0) return; - out = n_limit; - hd = iconv_open("utf-8", "cp932"); - if((hd >= 0) && (in > 0)){ - while(in > 0) { - iconv(hd, &pIn, &in, &pOut, &out); - } - iconv_close(hd); - } + out = n_limit; + hd = iconv_open("utf-8", "cp932"); + if((hd >= 0) && (in > 0)){ + while(in > 0) { + iconv(hd, &pIn, &in, &pOut, &out); + } + iconv_close(hd); + } // printf("UTF8: %s\n", pOut); - if(out <= 0) return; - strncpy(dst, utf8, out); + if(out <= 0) return; + strncpy(dst, utf8, out); //#else // strncpy(dst, src, n_limit); //#endif -} +} void get_long_full_path_name(_TCHAR* src, _TCHAR* dst) { - QString r_path; - QString delim; - QString ss; - const char *s; - QDir mdir; - if(src == NULL) { - if(dst != NULL) dst[0] = '\0'; - return; - } + QString r_path; + QString delim; + QString ss; + const char *s; + QDir mdir; + if(src == NULL) { + if(dst != NULL) dst[0] = '\0'; + return; + } #ifdef _WINDOWS - delim = "\\"; + delim = "\\"; #else - delim = "/"; + delim = "/"; #endif - ss = ""; - - if(cpp_homedir == "") { - r_path = mdir.currentPath(); - } else { - r_path = QString::fromStdString(cpp_homedir); - } - //s = AG_ShortFilename(src); - r_path = r_path + QString::fromStdString(my_procname); - r_path = r_path + delim; - mdir.mkdir(r_path); - ss = ""; -// if(s != NULL) ss = s; -// r_path.append(ss); - if(dst != NULL) strncpy(dst, r_path.toUtf8().constData(), - strlen(r_path.toUtf8().constData()) >= PATH_MAX ? PATH_MAX : strlen(r_path.toUtf8().constData())); - return; + ss = ""; + if(cpp_homedir == "") { + r_path = mdir.currentPath(); + } else { + r_path = QString::fromStdString(cpp_homedir); + } + //s = AG_ShortFilename(src); + r_path = r_path + QString::fromStdString(my_procname); + r_path = r_path + delim; + mdir.mkdir(r_path); + ss = ""; + // if(s != NULL) ss = s; + // r_path.append(ss); + if(dst != NULL) strncpy(dst, r_path.toUtf8().constData(), + strlen(r_path.toUtf8().constData()) >= PATH_MAX ? PATH_MAX : strlen(r_path.toUtf8().constData())); + return; } _TCHAR* get_parent_dir(_TCHAR* file) @@ -433,7 +420,7 @@ _TCHAR* get_parent_dir(_TCHAR* file) char *p = (char *)file; if(file == NULL) return NULL; for(ptr = strlen(p) - 1; ptr >= 0; ptr--) { - if(p[ptr] == delim) break; + if(p[ptr] == delim) break; } if(ptr >= 0) for(ptr = ptr + 1; ptr < strlen(p); ptr++) p[ptr] = '\0'; return p; @@ -441,24 +428,24 @@ _TCHAR* get_parent_dir(_TCHAR* file) void get_short_filename(_TCHAR *dst, _TCHAR *file, int maxlen) { - int i, l; - if((dst == NULL) || (file == NULL)) return; + int i, l; + if((dst == NULL) || (file == NULL)) return; #ifdef _WINDOWS _TCHAR delim = '\\'; #else _TCHAR delim = '/'; #endif - for(i = strlen(file) - 1; i <= 0; i--) { - if(file[i] == delim) break; - } - if(i >= (strlen(file) - 1)) { - dst[0] = '\0'; - return; - } - l = strlen(file) - i + 1; - if(l >= maxlen) l = maxlen; - strncpy(dst, &file[i + 1], l); - return; + for(i = strlen(file) - 1; i <= 0; i--) { + if(file[i] == delim) break; + } + if(i >= (strlen(file) - 1)) { + dst[0] = '\0'; + return; + } + l = strlen(file) - i + 1; + if(l >= maxlen) l = maxlen; + strncpy(dst, &file[i + 1], l); + return; } @@ -479,97 +466,93 @@ int screen_mode_count; void Ui_MainWindow::OnWindowRedraw(void) { - if(emu) { - emu->update_screen(this->getGraphicsView()); - } + if(emu) { + emu->update_screen(this->getGraphicsView()); + } } void Ui_MainWindow::OnWindowMove(void) { - if(emu) { - emu->suspend(); - } + if(emu) { + emu->suspend(); + } } void Ui_MainWindow::OnWindowResize(void) { - if(emu) { - //if(now_fullscreen) { - //emu->set_display_size(-1, -1, false); - //} else { - set_window(config.window_mode); - //} - } + if(emu) { + //if(now_fullscreen) { + //emu->set_display_size(-1, -1, false); + //} else { + set_window(config.window_mode); + //} + } } #ifdef USE_POWER_OFF bool Ui_MainWindow::GetPowerState(void) { - if(close_notified == 0) return true; - return false; + if(close_notified == 0) return true; + return false; } #endif void Ui_MainWindow::OnMainWindowClosed(void) { - #ifdef USE_POWER_OFF - // notify power off - if(emu) { - if(!close_notified) { - emu->LockVM(); - emu->notify_power_off(); - emu->UnlockVM(); - close_notified = 1; - return; - } - } + // notify power off + if(emu) { + if(!close_notified) { + emu->LockVM(); + emu->notify_power_off(); + emu->UnlockVM(); + close_notified = 1; + return; + } + } #endif - setRunJoyThread(false); - emit quit_joy_thread(); - - setRunEmuThread(false); - emit quit_emu_thread(); - - // release window - if(now_fullscreen) { - //ChangeDisplaySettings(NULL, 0); - } - now_fullscreen = false; + emit quit_joy_thread(); + emit quit_emu_thread(); + + // release window + if(now_fullscreen) { + //ChangeDisplaySettings(NULL, 0); + } + now_fullscreen = false; #ifdef USE_BUTTON - for(int i = 0; i < MAX_FONT_SIZE; i++) { - if(hFont[i]) { - DeleteObject(hFont[i]); - } - } + for(int i = 0; i < MAX_FONT_SIZE; i++) { + if(hFont[i]) { + DeleteObject(hFont[i]); + } + } #endif - return; + return; } extern "C" { - void LostFocus(QWidget *widget) - { - if(emu) { - emu->key_lost_focus(); - } - } +void LostFocus(QWidget *widget) +{ + if(emu) { + emu->key_lost_focus(); + } +} } // extern "C" void Ui_MainWindow::do_release_emu_resources(void) { - if(emu) { - delete emu; - emu = NULL; - } + if(emu) { + delete emu; + emu = NULL; + } } bool InitInstance(int argc, char *argv[]) { - rMainWindow = new META_MainWindow(); - rMainWindow->connect(rMainWindow, SIGNAL(sig_quit_all(void)), rMainWindow, SLOT(deleteLater(void))); - return true; + rMainWindow = new META_MainWindow(); + rMainWindow->connect(rMainWindow, SIGNAL(sig_quit_all(void)), rMainWindow, SLOT(deleteLater(void))); + return true; } @@ -592,86 +575,75 @@ bool InitInstance(int argc, char *argv[]) int MainLoop(int argc, char *argv[]) { - char c; - char strbuf[2048]; - bool flag; - char homedir[PATH_MAX]; - int thread_ret; + char c; + char strbuf[2048]; + bool flag; + char homedir[PATH_MAX]; + int thread_ret; - cpp_homedir.copy(homedir, PATH_MAX - 1, 0); - flag = FALSE; - /* - * Into Qt's Loop. - */ + cpp_homedir.copy(homedir, PATH_MAX - 1, 0); + flag = FALSE; + /* + * Into Qt's Loop. + */ - SDL_InitSubSystem(SDL_INIT_AUDIO | SDL_INIT_JOYSTICK ); - AGAR_DebugLog(AGAR_LOG_DEBUG, "Audio and JOYSTICK subsystem was initialised."); - GuiMain = new QApplication(argc, argv); + SDL_InitSubSystem(SDL_INIT_AUDIO | SDL_INIT_JOYSTICK ); + AGAR_DebugLog(AGAR_LOG_DEBUG, "Audio and JOYSTICK subsystem was initialised."); + GuiMain = new QApplication(argc, argv); - load_config(); - InitInstance(argc, argv); - AGAR_DebugLog(AGAR_LOG_DEBUG, "InitInstance() OK."); + load_config(); + InitInstance(argc, argv); + AGAR_DebugLog(AGAR_LOG_DEBUG, "InitInstance() OK."); - screen_mode_count = 0; - do { - if(screen_mode_width[screen_mode_count] <= 0) break; - screen_mode_count++; - } while(1); + screen_mode_count = 0; + do { + if(screen_mode_width[screen_mode_count] <= 0) break; + screen_mode_count++; + } while(1); -#if 0 - // restore screen mode - if(config.window_mode >= 0 && config.window_mode < MAX_WINDOW) { - PostMessage(hWnd, WM_COMMAND, ID_SCREEN_WINDOW1 + config.window_mode, 0L); - } else if(config.window_mode >= MAX_WINDOW && config.window_mode < screen_mode_count + MAX_WINDOW) { - PostMessage(hWnd, WM_COMMAND, ID_SCREEN_FULLSCREEN1 + config.window_mode - MAX_WINDOW, 0L); - } else { - config.window_mode = 0; - PostMessage(hWnd, WM_COMMAND, ID_SCREEN_WINDOW1, 0L); - } -#endif - // disenable ime - //ImmAssociateContext(hWnd, 0); + // disenable ime + //ImmAssociateContext(hWnd, 0); - // initialize emulation core - rMainWindow->getWindow()->show(); + // initialize emulation core + rMainWindow->getWindow()->show(); - emu = new EMU(rMainWindow, rMainWindow->getGraphicsView()); + emu = new EMU(rMainWindow, rMainWindow->getGraphicsView()); #ifdef SUPPORT_DRAG_DROP - // open command line path - // if(szCmdLine[0]) { - // if(szCmdLine[0] == _T('"')) { - // int len = strlen(szCmdLine); - // szCmdLine[len - 1] = _T('\0'); - // szCmdLine++; - // } - // _TCHAR path[_MAX_PATH]; - // get_long_full_path_name(szCmdLine, path); - // open_any_file(path); - //} + // open command line path + // if(szCmdLine[0]) { + // if(szCmdLine[0] == _T('"')) { + // int len = strlen(szCmdLine); + // szCmdLine[len - 1] = _T('\0'); + // szCmdLine++; + // } + // _TCHAR path[_MAX_PATH]; + // get_long_full_path_name(szCmdLine, path); + // open_any_file(path); + //} #endif - // set priority + // set priority - // main loop - rMainWindow->LaunchEmuThread(); - rMainWindow->LaunchJoyThread(); - GuiMain->exec(); - return 0; + // main loop + rMainWindow->LaunchEmuThread(); + rMainWindow->LaunchJoyThread(); + GuiMain->exec(); + return 0; } void Ui_MainWindow::set_window(int mode) { - QMenuBar *hMenu; -// static LONG style = WS_VISIBLE; + QMenuBar *hMenu; + // static LONG style = WS_VISIBLE; if(mode >= 0 && mode < MAX_WINDOW) { // window int width = emu->get_window_width(mode); int height = emu->get_window_height(mode); - + this->resize(width + 10, height + 100); // OK? int dest_x = 0; int dest_y = 0; @@ -695,7 +667,7 @@ void Ui_MainWindow::set_window(int mode) // set screen size to emu class emu->set_display_size(width, height, false); - if(rMainWindow) rMainWindow->getGraphicsView()->resize(width, height); + if(rMainWindow) rMainWindow->getGraphicsView()->resize(width, height); } } @@ -703,190 +675,183 @@ void Ui_MainWindow::set_window(int mode) /* - * This is main for agar. + * This is main for Qt. */ int main(int argc, char *argv[]) { - int rgb_size[3]; - int flags; - char simdstr[1024]; - char *optArg; - std::string archstr; - std::string delim; - int bLogSYSLOG; - int bLogSTDOUT; - char c; - int nErrorCode; - /* - * Get current DIR - */ - char *p; - int simdid = 0; - /* - * Check CPUID - */ - pCpuID = initCpuID(); - - my_procname = "emu"; - my_procname = my_procname + CONFIG_NAME; + int rgb_size[3]; + int flags; + char simdstr[1024]; + char *optArg; + std::string archstr; + std::string delim; + int bLogSYSLOG; + int bLogSTDOUT; + char c; + int nErrorCode; + /* + * Get current DIR + */ + char *p; + int simdid = 0; + /* + * Check CPUID + */ + pCpuID = initCpuID(); + + my_procname = "emu"; + my_procname = my_procname + CONFIG_NAME; #ifdef _WINDOWS - delim = "\\"; + delim = "\\"; #else - delim = "/"; + delim = "/"; #endif - p = SDL_getenv("HOME"); - if(p == NULL) { - p = SDL_getenv("PWD"); - if(p == NULL) { - cpp_homedir = "."; - } else { - cpp_homedir = p; - } - std::string tmpstr; - tmpstr = "Warning : Can't get HOME directory...Making conf on " + cpp_homedir + delim; - perror(tmpstr.c_str()); - } else { - cpp_homedir = p; - } - cpp_homedir = cpp_homedir + delim; + p = SDL_getenv("HOME"); + if(p == NULL) { + p = SDL_getenv("PWD"); + if(p == NULL) { + cpp_homedir = "."; + } else { + cpp_homedir = p; + } + std::string tmpstr; + tmpstr = "Warning : Can't get HOME directory...Making conf on " + cpp_homedir + delim; + perror(tmpstr.c_str()); + } else { + cpp_homedir = p; + } + cpp_homedir = cpp_homedir + delim; #ifdef _WINDOWS - cpp_confdir = cpp_homedir + my_procname + delim; + cpp_confdir = cpp_homedir + my_procname + delim; #else - cpp_confdir = cpp_homedir + ".config" + delim + my_procname + delim; + cpp_confdir = cpp_homedir + ".config" + delim + my_procname + delim; #endif - bLogSYSLOG = (int)0; - bLogSTDOUT = (int)1; - AGAR_OpenLog(bLogSYSLOG, bLogSTDOUT); // Write to syslog, console - - archstr = "Generic"; + bLogSYSLOG = (int)0; + bLogSTDOUT = (int)1; + AGAR_OpenLog(bLogSYSLOG, bLogSTDOUT); // Write to syslog, console + + archstr = "Generic"; #if defined(__x86_64__) - archstr = "amd64"; + archstr = "amd64"; #endif #if defined(__i386__) - archstr = "ia32"; + archstr = "ia32"; #endif - printf("Common Source Project : %s %s\n", my_procname.c_str(), "1.0"); - printf("(C) Toshiya Takeda / SDL Version K.Ohta \n"); - printf("Architecture: %s\n", archstr.c_str()); - printf(" -? is print help(s).\n"); + printf("Common Source Project : %s %s\n", my_procname.c_str(), "1.0"); + printf("(C) Toshiya Takeda / SDL Version K.Ohta \n"); + printf("Architecture: %s\n", archstr.c_str()); + printf(" -? is print help(s).\n"); /* Print SIMD features */ - simdstr[0] = '\0'; + simdstr[0] = '\0'; #if defined(__x86_64__) || defined(__i386__) if(pCpuID != NULL) { - - if(pCpuID->use_mmx) { - strcat(simdstr, " MMX"); - simdid |= 0xffffffff; - } - if(pCpuID->use_mmxext) { - strcat(simdstr, " MMXEXT"); - simdid |= 0xffffffff; - } - if(pCpuID->use_sse) { - strcat(simdstr, " SSE"); - simdid |= 0xffffffff; - } - if(pCpuID->use_sse2) { - strcat(simdstr, " SSE2"); - simdid |= 0xffffffff; - } - if(pCpuID->use_sse3) { - strcat(simdstr, " SSE3"); - simdid |= 0xffffffff; - } - if(pCpuID->use_ssse3) { - strcat(simdstr, " SSSE3"); - simdid |= 0xffffffff; - } - if(pCpuID->use_sse41) { - strcat(simdstr, " SSE4.1"); - simdid |= 0xffffffff; - } - if(pCpuID->use_sse42) { - strcat(simdstr, " SSE4.2"); - simdid |= 0xffffffff; - } - if(pCpuID->use_sse4a) { - strcat(simdstr, " SSE4a"); - simdid |= 0xffffffff; - } - if(pCpuID->use_abm) { - strcat(simdstr, " ABM"); - simdid |= 0xffffffff; - } - if(pCpuID->use_avx) { - strcat(simdstr, " AVX"); - simdid |= 0xffffffff; - } - if(pCpuID->use_3dnow) { - strcat(simdstr, " 3DNOW"); - simdid |= 0xffffffff; - } - if(pCpuID->use_3dnowp) { - strcat(simdstr, " 3DNOWP"); - simdid |= 0xffffffff; - } - if(simdid == 0) strcpy(simdstr, "NONE"); + if(pCpuID->use_mmx) { + strcat(simdstr, " MMX"); + simdid |= 0xffffffff; + } + if(pCpuID->use_mmxext) { + strcat(simdstr, " MMXEXT"); + simdid |= 0xffffffff; + } + if(pCpuID->use_sse) { + strcat(simdstr, " SSE"); + simdid |= 0xffffffff; + } + if(pCpuID->use_sse2) { + strcat(simdstr, " SSE2"); + simdid |= 0xffffffff; + } + if(pCpuID->use_sse3) { + strcat(simdstr, " SSE3"); + simdid |= 0xffffffff; + } + if(pCpuID->use_ssse3) { + strcat(simdstr, " SSSE3"); + simdid |= 0xffffffff; + } + if(pCpuID->use_sse41) { + strcat(simdstr, " SSE4.1"); + simdid |= 0xffffffff; + } + if(pCpuID->use_sse42) { + strcat(simdstr, " SSE4.2"); + simdid |= 0xffffffff; + } + if(pCpuID->use_sse4a) { + strcat(simdstr, " SSE4a"); + simdid |= 0xffffffff; + } + if(pCpuID->use_abm) { + strcat(simdstr, " ABM"); + simdid |= 0xffffffff; + } + if(pCpuID->use_avx) { + strcat(simdstr, " AVX"); + simdid |= 0xffffffff; + } + if(pCpuID->use_3dnow) { + strcat(simdstr, " 3DNOW"); + simdid |= 0xffffffff; + } + if(pCpuID->use_3dnowp) { + strcat(simdstr, " 3DNOWP"); + simdid |= 0xffffffff; + } + if(simdid == 0) strcpy(simdstr, "NONE"); } else { - strcpy(simdstr, "NONE"); + strcpy(simdstr, "NONE"); } #else // Not ia32 or amd64 strcpy(simdstr, "NONE"); #endif - AGAR_DebugLog(AGAR_LOG_INFO, "Supported SIMD: %s", simdstr); - cpp_simdtype = simdstr; - - - - AGAR_DebugLog(AGAR_LOG_INFO, "Start Common Source Project '%s'", my_procname.c_str()); - AGAR_DebugLog(AGAR_LOG_INFO, "(C) Toshiya Takeda / Agar Version K.Ohta"); - AGAR_DebugLog(AGAR_LOG_INFO, "Architecture: %s", archstr.c_str()); - - AGAR_DebugLog(AGAR_LOG_DEBUG, "Start Common Source Project '%s'", my_procname.c_str()); - AGAR_DebugLog(AGAR_LOG_DEBUG, "(C) Toshiya Takeda / Agar Version K.Ohta"); - AGAR_DebugLog(AGAR_LOG_DEBUG, "Architecture: %s", archstr.c_str()); - AGAR_DebugLog(AGAR_LOG_DEBUG, "Supported SIMD: %s", cpp_simdtype.c_str()); - AGAR_DebugLog(AGAR_LOG_DEBUG, " -? is print help(s)."); - AGAR_DebugLog(AGAR_LOG_DEBUG, "Moduledir = %s home = %s", cpp_confdir.c_str(), cpp_homedir.c_str()); // Debug - - { - QDir dir; - dir.mkdir( QString::fromStdString(cpp_confdir)); - } + AGAR_DebugLog(AGAR_LOG_INFO, "Supported SIMD: %s", simdstr); + cpp_simdtype = simdstr; + + AGAR_DebugLog(AGAR_LOG_INFO, "Start Common Source Project '%s'", my_procname.c_str()); + AGAR_DebugLog(AGAR_LOG_INFO, "(C) Toshiya Takeda / Agar Version K.Ohta"); + AGAR_DebugLog(AGAR_LOG_INFO, "Architecture: %s", archstr.c_str()); + + AGAR_DebugLog(AGAR_LOG_DEBUG, "Start Common Source Project '%s'", my_procname.c_str()); + AGAR_DebugLog(AGAR_LOG_DEBUG, "(C) Toshiya Takeda / Agar Version K.Ohta"); + AGAR_DebugLog(AGAR_LOG_DEBUG, "Architecture: %s", archstr.c_str()); + AGAR_DebugLog(AGAR_LOG_DEBUG, "Supported SIMD: %s", cpp_simdtype.c_str()); + AGAR_DebugLog(AGAR_LOG_DEBUG, " -? is print help(s)."); + AGAR_DebugLog(AGAR_LOG_DEBUG, "Moduledir = %s home = %s", cpp_confdir.c_str(), cpp_homedir.c_str()); // Debug + + { + QDir dir; + dir.mkdir( QString::fromStdString(cpp_confdir)); + } //AG_MkPath(cpp_confdir.c_str()); /* Gettext */ #ifndef RSSDIR -#if defined(_USE_AGAR) || defined(_USE_SDL) - sRssDir = "/usr/local/share/"; +#if defined(_USE_AGAR) || defined(_USE_QT) + sRssDir = "/usr/local/share/"; #else - sRssDir = "." + delim; + sRssDir = "." + delim; #endif - sRssDir = sRssDir + "CommonSourceCodeProject" + delim + my_procname; + sRssDir = sRssDir + "CommonSourceCodeProject" + delim + my_procname; #else - sRssDir = RSSDIR; + sRssDir = RSSDIR; #endif - setlocale(LC_ALL, ""); - bindtextdomain("messages", sRssDir.c_str()); - textdomain("messages"); - AGAR_DebugLog(AGAR_LOG_DEBUG, "I18N via gettext initialized."); // Will move to Qt; - AGAR_DebugLog(AGAR_LOG_DEBUG, "I18N resource dir: %s", sRssDir.c_str()); - + setlocale(LC_ALL, ""); + bindtextdomain("messages", sRssDir.c_str()); + textdomain("messages"); + AGAR_DebugLog(AGAR_LOG_DEBUG, "I18N via gettext initialized."); // Will move to Qt; + AGAR_DebugLog(AGAR_LOG_DEBUG, "I18N resource dir: %s", sRssDir.c_str()); - //SDL_Init(SDL_INIT_EVERYTHING | SDL_INIT_TIMER); + //SDL_Init(SDL_INIT_EVERYTHING | SDL_INIT_TIMER); #if ((AGAR_VER <= 2) && defined(FMTV151)) - bFMTV151 = TRUE; + bFMTV151 = TRUE; #endif /* */ /* * アプリケーション初期化 */ - nErrorCode = MainLoop(argc, argv); - return nErrorCode; + nErrorCode = MainLoop(argc, argv); + return nErrorCode; } - - - diff --git a/source/src/qt/common/qt_main.h b/source/src/qt/common/qt_main.h index 56163fb5b..527cc3a8c 100644 --- a/source/src/qt/common/qt_main.h +++ b/source/src/qt/common/qt_main.h @@ -62,121 +62,115 @@ QT_BEGIN_NAMESPACE class EmuThreadClass : public QThread { Q_OBJECT - private: - bool calc_message; - bool tape_play_flag; +private: + bool calc_message; + bool tape_play_flag; protected: - EMU *p_emu; - bool bRunThread; - bool bResetReq; - bool bSpecialResetReq; - bool bLoadStateReq; - bool bSaveStateReq; - uint32 next_time; - uint32 update_fps_time; - bool prev_skip; - int total_frames; - int draw_frames; - int skip_frames; + EMU *p_emu; + bool bRunThread; + bool bResetReq; + bool bSpecialResetReq; + bool bLoadStateReq; + bool bSaveStateReq; + uint32 next_time; + uint32 update_fps_time; + bool prev_skip; + int total_frames; + int draw_frames; + int skip_frames; public: - EmuThreadClass(QObject *parent = 0) : QThread(parent) { - bRunThread = true; - prev_skip = false; - update_fps_time = SDL_GetTicks(); - next_time = update_fps_time; - total_frames = 0; - draw_frames = 0; - skip_frames = 0; - calc_message = true; - }; - ~EmuThreadClass() {}; - void SetEmu(EMU *p) { - p_emu = p; - } - QTimer timer; - void set_tape_play(bool); - void run() { doWork("");} + EmuThreadClass(QObject *parent = 0) : QThread(parent) { + bRunThread = true; + prev_skip = false; + update_fps_time = SDL_GetTicks(); + next_time = update_fps_time; + total_frames = 0; + draw_frames = 0; + skip_frames = 0; + calc_message = true; + }; + ~EmuThreadClass() {}; + void SetEmu(EMU *p) { + p_emu = p; + } + void set_tape_play(bool); + void run() { doWork("");} - public slots: - void doWork(const QString ¶m); - void doExit(void); - void print_framerate(int frames); - void doReset(); - void doSpecialReset(); - void doLoadState(); - void doSaveState(); - signals: - int message_changed(QString); - int sig_draw_thread(void); - int quit_draw_thread(void); - int sig_screen_aspect(int); - int sig_screen_size(int, int); - int sig_finished(void); - int call_emu_thread(EMU *); +public slots: + void doWork(const QString ¶m); + void doExit(void); + void print_framerate(int frames); + void doReset(); + void doSpecialReset(); + void doLoadState(); + void doSaveState(); +signals: + int message_changed(QString); + int sig_draw_thread(void); + int quit_draw_thread(void); + int sig_screen_aspect(int); + int sig_screen_size(int, int); + int sig_finished(void); + int call_emu_thread(EMU *); #ifdef USE_TAPE_BUTTON - int sig_tape_play_stat(bool); + int sig_tape_play_stat(bool); #endif - }; class JoyThreadClass : public QThread { Q_OBJECT private: - int joy_num; - SDL_Event event; - SDL_Joystick *joyhandle[2]; - EMU *p_emu; + int joy_num; + SDL_Event event; + SDL_Joystick *joyhandle[2]; + EMU *p_emu; protected: - bool bRunThread; - bool EventSDL(SDL_Event *); - void x_axis_changed(int, int); - void y_axis_changed(int, int); - void button_down(int, unsigned int); - void button_up(int, unsigned int); + bool bRunThread; + bool EventSDL(SDL_Event *); + void x_axis_changed(int, int); + void y_axis_changed(int, int); + void button_down(int, unsigned int); + void button_up(int, unsigned int); public: - JoyThreadClass(QObject *parent = 0); - ~JoyThreadClass(); - QTimer timer; - void run() { doWork("");} - void SetEmu(EMU *p) { - p_emu = p; - } + JoyThreadClass(QObject *parent = 0); + ~JoyThreadClass(); + void run() { doWork("");} + void SetEmu(EMU *p) { + p_emu = p; + } public slots: - void doWork(const QString &); - void doExit(void); - + void doWork(const QString &); + void doExit(void); signals: - int sig_finished(void); - int call_joy_thread(EMU *); + int sig_finished(void); + int call_joy_thread(EMU *); }; class DrawThreadClass : public QThread { Q_OBJECT private: - EMU *p_emu; - Ui_MainWindow *MainWindow; + EMU *p_emu; + Ui_MainWindow *MainWindow; protected: - int draw_frames; - bool bRunThread; + int draw_frames; + bool bRunThread; public: - DrawThreadClass(QObject *parent = 0); - ~DrawThreadClass() {}; - QTimer timer; - void run() { doWork("");} - void SetEmu(EMU *p) { - p_emu = p; - } + DrawThreadClass(QObject *parent = 0); + ~DrawThreadClass() {}; + void run() { doWork("");} + void SetEmu(EMU *p) { + p_emu = p; + } public slots: - void doWork(const QString &); - void doExit(void); - void doDraw(void); - + void doWork(const QString &); + void doExit(void); + void doDraw(void); signals: - int sig_draw_frames(int); - int message_changed(QString); + int sig_draw_frames(int); + int message_changed(QString); }; diff --git a/source/src/qt/common/qt_screen.cpp b/source/src/qt/common/qt_screen.cpp index cf498f426..d6aca6ec8 100644 --- a/source/src/qt/common/qt_screen.cpp +++ b/source/src/qt/common/qt_screen.cpp @@ -31,7 +31,7 @@ static uint8 r1[2048], g1[2048], b1[2048]; #endif extern "C" { - int bFullScan = 0; + int bFullScan = 0; } @@ -58,26 +58,18 @@ void EMU::initialize_screen() use_SDLFB = false; wait_vsync = false; // *nix only, need to change on WIndows. -#if 0 - if(posix_memalign(&pPseudoVram, 64, sizeof(Uint32) * SCREEN_WIDTH * SCREEN_HEIGHT) != 0){ - pPseudoVram = NULL; - } -#else pPseudoVram = new QImage(SCREEN_WIDTH, SCREEN_HEIGHT, QImage::Format_ARGB32); -#endif { - int i; - for(i = 0; i < SCREEN_HEIGHT; i++) { - bDrawLine[i] = false; - } + int i; + for(i = 0; i < SCREEN_HEIGHT; i++) { + bDrawLine[i] = false; + } } - - //if(AG_UsingGL()) { // render_to_GL = true; // use_GL = true; //} else { - single_window = false; + single_window = false; now_rec_video = false; // initialize update flags @@ -95,8 +87,8 @@ void EMU::initialize_screen() void EMU::release_screen() { - if(pPseudoVram != NULL) delete pPseudoVram; - pPseudoVram = NULL; + if(pPseudoVram != NULL) delete pPseudoVram; + pPseudoVram = NULL; // stop video recording //stop_rec_video(); } @@ -125,20 +117,18 @@ int EMU::get_window_height(int mode) void EMU::set_display_size(int width, int height, bool window_mode) { - bool display_size_changed = false; - bool stretch_changed = false; - int prev_stretched_width = stretched_width; - int prev_stretched_height = stretched_height; - - if(width != -1 && (display_width != width || display_height != height)) { - display_width = width; - display_height = height; - display_size_changed = stretch_changed = true; - } + bool display_size_changed = false; + bool stretch_changed = false; + int prev_stretched_width = stretched_width; + int prev_stretched_height = stretched_height; + if(width != -1 && (display_width != width || display_height != height)) { + display_width = width; + display_height = height; + display_size_changed = stretch_changed = true; + } #ifdef USE_SCREEN_ROTATE if(config.rotate_type) { - stretch_changed |= (source_width != screen_height); stretch_changed |= (source_height != screen_width); stretch_changed |= (source_width_aspect != screen_height_aspect); @@ -148,11 +138,9 @@ void EMU::set_display_size(int width, int height, bool window_mode) source_height = screen_width; source_width_aspect = screen_height_aspect; source_height_aspect = screen_width_aspect; - // render_to_d3d9Buffer = false; } else { #endif - stretch_changed |= (source_width != screen_width); stretch_changed |= (source_height != screen_height); stretch_changed |= (source_width_aspect != screen_width_aspect); @@ -166,74 +154,68 @@ void EMU::set_display_size(int width, int height, bool window_mode) } #endif - if(config.stretch_type == 1) { + if(config.stretch_type == 1) { // fit to full screen (aspect) - stretched_width = (display_height * source_width_aspect) / source_height_aspect; - stretched_height = display_height; - if(stretched_width > display_width) { - stretched_width = display_width; - stretched_height = (display_width * source_height_aspect) / source_width_aspect; - } - } else if(config.stretch_type == 2) { + stretched_width = (display_height * source_width_aspect) / source_height_aspect; + stretched_height = display_height; + if(stretched_width > display_width) { + stretched_width = display_width; + stretched_height = (display_width * source_height_aspect) / source_width_aspect; + } + } else if(config.stretch_type == 2) { // fit to full screen (fill) stretched_width = display_width; stretched_height = display_height; - } else { - // dot by dot - int tmp_pow_x = display_width / source_width_aspect; - int tmp_pow_y = display_height / source_height_aspect; - int tmp_pow = 1; - if(tmp_pow_y >= tmp_pow_x && tmp_pow_x > 1) { - tmp_pow = tmp_pow_x; - } else if(tmp_pow_x >= tmp_pow_y && tmp_pow_y > 1) { - tmp_pow = tmp_pow_y; - } - stretched_width = source_width_aspect * tmp_pow; - stretched_height = source_height_aspect * tmp_pow; - } - screen_dest_x = (display_width - stretched_width) / 2; - screen_dest_y = (display_height - stretched_height) / 2; + } else { + // dot by dot + int tmp_pow_x = display_width / source_width_aspect; + int tmp_pow_y = display_height / source_height_aspect; + int tmp_pow = 1; + if(tmp_pow_y >= tmp_pow_x && tmp_pow_x > 1) { + tmp_pow = tmp_pow_x; + } else if(tmp_pow_x >= tmp_pow_y && tmp_pow_y > 1) { + tmp_pow = tmp_pow_y; + } + stretched_width = source_width_aspect * tmp_pow; + stretched_height = source_height_aspect * tmp_pow; + } + screen_dest_x = (display_width - stretched_width) / 2; + screen_dest_y = (display_height - stretched_height) / 2; - stretch_changed |= (prev_stretched_width != stretched_width); - stretch_changed |= (prev_stretched_height != stretched_height); + stretch_changed |= (prev_stretched_width != stretched_width); + stretch_changed |= (prev_stretched_height != stretched_height); - int new_pow_x = 1, new_pow_y = 1; - while(stretched_width > source_width * new_pow_x) { - new_pow_x++; - } - while(stretched_height > source_height * new_pow_y) { - new_pow_y++; - } -// if(!use_d3d9 && new_pow_x > 1 && new_pow_y > 1) { -// // support high quality stretch only for x1 window size in gdi mode -// new_pow_x = new_pow_y = 1; -// } - if(stretch_pow_x != new_pow_x || stretch_pow_y != new_pow_y) { - stretch_pow_x = new_pow_x; - 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); - + int new_pow_x = 1, new_pow_y = 1; + while(stretched_width > source_width * new_pow_x) { + new_pow_x++; + } + while(stretched_height > source_height * new_pow_y) { + new_pow_y++; + } + if(stretch_pow_x != new_pow_x || stretch_pow_y != new_pow_y) { + stretch_pow_x = new_pow_x; + 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 1 - if(main_window_handle != NULL) { - main_window_handle->resize(stretched_width, stretched_height); - // main_window_handle->getGraphicsView()->resize(stretched_width, stretched_height); - } + if(main_window_handle != NULL) { + main_window_handle->resize(stretched_width, stretched_height); + // main_window_handle->getGraphicsView()->resize(stretched_width, stretched_height); + } #endif - first_draw_screen = false; - first_invalidate = true; - screen_size_changed = false; - + first_draw_screen = false; + first_invalidate = true; + screen_size_changed = false; } void EMU::change_screen_size(int sw, int sh, int swa, int sha, int ww, int wh) { - AGAR_DebugLog(AGAR_LOG_DEBUG, "Change Screen Width"); - AGAR_DebugLog(AGAR_LOG_DEBUG, " From %d x %d", screen_width, screen_height); - // virtual machine changes the screen size + AGAR_DebugLog(AGAR_LOG_DEBUG, "Change Screen Width"); + AGAR_DebugLog(AGAR_LOG_DEBUG, " From %d x %d", screen_width, screen_height); + // virtual machine changes the screen size if(screen_width != sw || screen_height != sh) { screen_width = sw; screen_height = sh; @@ -250,15 +232,14 @@ void EMU::change_screen_size(int sw, int sh, int swa, int sha, int ww, int wh) stop_rec_video(); stop_rec_sound(); } - // change the window size //AG_PushEvent(main_window_handle, WM_RESIZE, 0L, 0L); } AGAR_DebugLog(AGAR_LOG_DEBUG, " To %d x %d", screen_width, screen_height); AGAR_DebugLog(AGAR_LOG_DEBUG, "Window Size:%d x %d", window_width, window_height); if(main_window_handle != NULL) { - // set_window(main_window_handle->getWindow(), window_mode); - main_window_handle->getGraphicsView()->resize(screen_width, screen_height); + // set_window(main_window_handle->getWindow(), window_mode); + main_window_handle->getGraphicsView()->resize(screen_width, screen_height); } } @@ -283,7 +264,7 @@ int EMU::draw_screen() // screen size was changed in vm->draw_screen() if(screen_size_changed) { // unlock offscreen surface - screen_size_changed = false; + screen_size_changed = false; // return 0; } return 1; @@ -293,34 +274,21 @@ int EMU::draw_screen() scrntype* EMU::screen_buffer(int y) { -#if 0 - Uint32 *p = pPseudoVram; - if((y >= SCREEN_HEIGHT) || (y < 0)) return NULL; - - bDrawLine[y] = true;; - - p = &(p[y * SCREEN_WIDTH]); -#else - uchar *p = NULL; - if((pPseudoVram != NULL) && (y < SCREEN_HEIGHT) && (y >= 0)) p = pPseudoVram->scanLine(y); - return (scrntype *)p; -#endif + uchar *p = NULL; + if((pPseudoVram != NULL) && (y < SCREEN_HEIGHT) && (y >= 0)) p = pPseudoVram->scanLine(y); + return (scrntype *)p; } void EMU::update_screen(GLDrawClass *glv) { - // UpdateScreen - if(glv != NULL) { - // In Qt, You should updateGL() inside of widget? - glv->update(); - //glv->updateGL(); - } - - + // UpdateScreen + if(glv != NULL) { + // In Qt, You should updateGL() inside of widget? + glv->update(); + //glv->updateGL(); + } #if 0 - - # ifdef USE_BITMAP if(first_invalidate || !self_invalidate) { HDC hmdc = CreateCompatibleDC(hdc); diff --git a/source/src/qt/common/sdl_cpuid.c b/source/src/qt/common/sdl_cpuid.c index b40d3df4a..a213acd0e 100644 --- a/source/src/qt/common/sdl_cpuid.c +++ b/source/src/qt/common/sdl_cpuid.c @@ -13,36 +13,36 @@ void getCpuID(struct AGAR_CPUID *p) { - Uint32 a,b,c,d; - a = b = c = d = 0; - if(__get_cpuid(0x80000001 , &a, &b, &c, &d) == 0) return; // Get Features + Uint32 a,b,c,d; + a = b = c = d = 0; + if(__get_cpuid(0x80000001 , &a, &b, &c, &d) == 0) return; // Get Features #ifdef __llvm__ #elif defined(__GNUC__) - p->use_mmx = ((d & bit_MMX) != 0)?-1:0; - p->use_sse = ((d & bit_SSE) != 0)?-1:0; - p->use_sse2 = ((d & bit_SSE2) != 0)?-1:0; - p->use_cmov = ((d & bit_CMOV) != 0)?-1:0; - p->use_sse3 = ((c & bit_SSE3) != 0)?-1:0; - p->use_ssse3 = ((c & bit_SSSE3) != 0)?-1:0; - p->use_sse41 = ((c & bit_SSE4_1) != 0)?-1:0; - p->use_sse42 = ((c & bit_SSE4_2) != 0)?-1:0; - p->use_sse4a = ((c & bit_SSE4a) != 0)?-1:0; - p->use_abm = ((c & bit_ABM) != 0)?-1:0; - p->use_avx = ((c & bit_AVX) != 0)?-1:0; - p->use_mmxext = ((d & bit_MMXEXT) != 0)?-1:0; - p->use_3dnow = ((d & bit_3DNOW) != 0)?-1:0; - p->use_3dnowp = ((d & bit_3DNOWP) != 0)?-1:0; + p->use_mmx = ((d & bit_MMX) != 0)?-1:0; + p->use_sse = ((d & bit_SSE) != 0)?-1:0; + p->use_sse2 = ((d & bit_SSE2) != 0)?-1:0; + p->use_cmov = ((d & bit_CMOV) != 0)?-1:0; + p->use_sse3 = ((c & bit_SSE3) != 0)?-1:0; + p->use_ssse3 = ((c & bit_SSSE3) != 0)?-1:0; + p->use_sse41 = ((c & bit_SSE4_1) != 0)?-1:0; + p->use_sse42 = ((c & bit_SSE4_2) != 0)?-1:0; + p->use_sse4a = ((c & bit_SSE4a) != 0)?-1:0; + p->use_abm = ((c & bit_ABM) != 0)?-1:0; + p->use_avx = ((c & bit_AVX) != 0)?-1:0; + p->use_mmxext = ((d & bit_MMXEXT) != 0)?-1:0; + p->use_3dnow = ((d & bit_3DNOW) != 0)?-1:0; + p->use_3dnowp = ((d & bit_3DNOWP) != 0)?-1:0; #endif } struct AGAR_CPUID *initCpuID(void) { - struct AGAR_CPUID *p; - p = (struct AGAR_CPUID *)malloc(sizeof(struct AGAR_CPUID)); - if(p == NULL) return NULL; - memset(p, 0x00, sizeof(struct AGAR_CPUID)); - getCpuID(p); - return p; + struct AGAR_CPUID *p; + p = (struct AGAR_CPUID *)malloc(sizeof(struct AGAR_CPUID)); + if(p == NULL) return NULL; + memset(p, 0x00, sizeof(struct AGAR_CPUID)); + getCpuID(p); + return p; } @@ -54,14 +54,12 @@ void getCpuID(struct AGAR_CPUID *p) struct AGAR_CPUID *initCpuID(void) { - return NULL; + return NULL; } - #endif void detachCpuID(struct AGAR_CPUID *p) { - if(p == NULL) return; - free(p); + if(p == NULL) return; + free(p); } - diff --git a/source/src/qt/common/sdl_cpuid.h b/source/src/qt/common/sdl_cpuid.h index 7cac44150..b6bcf610c 100644 --- a/source/src/qt/common/sdl_cpuid.h +++ b/source/src/qt/common/sdl_cpuid.h @@ -18,24 +18,24 @@ extern "C" #if defined(__x86_64__) || defined(__i386__) #include struct AGAR_CPUID { - int use_mmx; - int use_mmxext; - int use_sse; - int use_sse2; - int use_sse3; - int use_ssse3; - int use_sse41; - int use_sse42; - int use_sse4a; - int use_3dnow; - int use_3dnowp; - int use_abm; - int use_avx; - int use_cmov; + int use_mmx; + int use_mmxext; + int use_sse; + int use_sse2; + int use_sse3; + int use_ssse3; + int use_sse41; + int use_sse42; + int use_sse4a; + int use_3dnow; + int use_3dnowp; + int use_abm; + int use_avx; + int use_cmov; }; #else // 他のアーキテクチャは#ifdefネストで新しく作ること struct AGAR_CPUID { - int dummy; + int dummy; }; #endif @@ -48,4 +48,4 @@ void detachCpuID(struct AGAR_CPUID *p); } #endif -#endif \ No newline at end of file +#endif diff --git a/source/src/qt/common/simd_types.h b/source/src/qt/common/simd_types.h index 79bc61360..10c8a1307 100644 --- a/source/src/qt/common/simd_types.h +++ b/source/src/qt/common/simd_types.h @@ -44,44 +44,44 @@ typedef uint32_t v8ui __attribute__ ((__vector_size__(32))); typedef union { - v2si v; - v2ii vv; - v2ui uv; - uint32_t i[2]; - uint16_t s[4]; - uint8_t b[8]; - int32_t si[2]; - int16_t ss[4]; - int8_t sb[8]; + v2si v; + v2ii vv; + v2ui uv; + uint32_t i[2]; + uint16_t s[4]; + uint8_t b[8]; + int32_t si[2]; + int16_t ss[4]; + int8_t sb[8]; } v2hi; typedef union { - v4si v; - v4ii vv; - v4ui uv; - uint32_t i[4]; - uint16_t s[8]; - uint8_t b[16]; - int32_t si[4]; - int16_t ss[8]; - int8_t sb[16]; + v4si v; + v4ii vv; + v4ui uv; + uint32_t i[4]; + uint16_t s[8]; + uint8_t b[16]; + int32_t si[4]; + int16_t ss[8]; + int8_t sb[16]; } v4hi; typedef union { - v8si v; - v8ii vv; - v8ui uv; - v4si v4[2]; - v4ii vv4[2]; + v8si v; + v8ii vv; + v8ui uv; + v4si v4[2]; + v4ii vv4[2]; - uint32_t i[8]; - uint16_t s[16]; - uint8_t b[32]; - int32_t si[8]; - int16_t ss[16]; - int8_t sb[32]; + uint32_t i[8]; + uint16_t s[16]; + uint8_t b[32]; + int32_t si[8]; + int16_t ss[16]; + int8_t sb[32]; } v8hi_t; #endif //#ifndef __XM7_TYPES_H diff --git a/source/src/qt/gui/commonclasses.h b/source/src/qt/gui/commonclasses.h index cc9caf54c..9bca9fc62 100644 --- a/source/src/qt/gui/commonclasses.h +++ b/source/src/qt/gui/commonclasses.h @@ -34,155 +34,146 @@ extern class EMU* emu; QT_BEGIN_NAMESPACE typedef class Object_Menu_Control: public QObject { - Q_OBJECT + Q_OBJECT public: // explicit Object_Menu_Control(QObject *parent = 0); - Object_Menu_Control(QObject *parent) : QObject(parent){ - bindValue = 0; - drive = 0; - s_num = 0; - height = 0; - width = 0; - play = true; // Read - write_protect = false; // Enable to write - } - Object_Menu_Control() {} + Object_Menu_Control(QObject *parent) : QObject(parent){ + bindValue = 0; + drive = 0; + s_num = 0; + height = 0; + width = 0; + play = true; // Read + write_protect = false; // Enable to write + } + Object_Menu_Control() {} private: - int bindValue; - int drive; - int s_num; - int width; - int height; - bool play; - bool write_protect; + int bindValue; + int drive; + int s_num; + int width; + int height; + bool play; + bool write_protect; signals: - int on_boot_mode(int); - int on_cpu_type(int); - int on_cpu_power(int); - int on_open_debugger(int); - - int sig_insert_fd(int); - int sig_eject_fd(int); - int set_d88_slot(int, int); - int set_recent_disk(int, int); - int sig_write_protect_fd(int, bool); + int on_boot_mode(int); + int on_cpu_type(int); + int on_cpu_power(int); + int on_open_debugger(int); + + int sig_insert_fd(int); + int sig_eject_fd(int); + int set_d88_slot(int, int); + int set_recent_disk(int, int); + int sig_write_protect_fd(int, bool); #if defined(USE_QD1) || defined(USE_QD2) - int set_recent_quick_disk(int, int); - int sig_write_protect_Qd(int, bool); - int sig_eject_Qd(int); - int sig_insert_Qd(int); + int set_recent_quick_disk(int, int); + int sig_write_protect_Qd(int, bool); + int sig_eject_Qd(int); + int sig_insert_Qd(int); #endif - int sig_insert_play_cmt(bool); - int sig_eject_cmt(void); - int sig_recent_cmt(int); - int sig_set_write_protect_cmt(bool); + int sig_insert_play_cmt(bool); + int sig_eject_cmt(void); + int sig_recent_cmt(int); + int sig_set_write_protect_cmt(bool); #ifdef USE_CART1 - int sig_insert_cart(int); - int sig_eject_cart(int); - int set_recent_cart(int, int); + int sig_insert_cart(int); + int sig_eject_cart(int); + int set_recent_cart(int, int); #endif #if defined(USE_BINARY_FILE1) - int sig_open_binary_file(int, QString, bool); - int sig_open_binary(int, bool); - int set_recent_binary_load(int, int); - int set_recent_binary_save(int, int); + int sig_open_binary_file(int, QString, bool); + int sig_open_binary(int, bool); + int set_recent_binary_load(int, int); + int set_recent_binary_save(int, int); #endif - int sig_freq(int); - int sig_latency(int); - int sig_sounddevice(int); - int sig_set_dipsw(int, bool); - int sig_screen_aspect(int); - int sig_screen_size(int, int); + int sig_freq(int); + int sig_latency(int); + int sig_sounddevice(int); + int sig_set_dipsw(int, bool); + int sig_screen_aspect(int); + int sig_screen_size(int, int); public slots: - void set_boot_mode(void); - void set_cpu_type(void); - void set_cpupower(void); - void open_debugger(void); - void do_set_write_protect_cmt(void); - void do_unset_write_protect_cmt(void); - void insert_fd(void); - void eject_fd(void); - void on_d88_slot(void); - void on_recent_disk(void); - void write_protect_fd(void); - void no_write_protect_fd(void); + void set_boot_mode(void); + void set_cpu_type(void); + void set_cpupower(void); + void open_debugger(void); + void do_set_write_protect_cmt(void); + void do_unset_write_protect_cmt(void); + void insert_fd(void); + void eject_fd(void); + void on_d88_slot(void); + void on_recent_disk(void); + void write_protect_fd(void); + void no_write_protect_fd(void); - void set_screen_aspect(void); - void set_screen_size(void); + void set_screen_aspect(void); + void set_screen_size(void); #if defined(USE_QD1) || defined(USE_QD2) - void insert_Qd(void); - void eject_Qd(void); - void on_recent_quick_disk(void); - void write_protect_Qd(void); - void no_write_protect_Qd(void); + void insert_Qd(void); + void eject_Qd(void); + void on_recent_quick_disk(void); + void write_protect_Qd(void); + void no_write_protect_Qd(void); #endif #if defined(USE_BINARY_FILE1) - void on_recent_binary_load(void); - void on_recent_binary_save(void); - void _open_binary(QString s); - void insert_binary_load(void); - void insert_binary_save(void); + void on_recent_binary_load(void); + void on_recent_binary_save(void); + void _open_binary(QString s); + void insert_binary_load(void); + void insert_binary_save(void); #endif - void start_insert_play_cmt(void); - void eject_cmt(void); - void on_recent_cmt(void); + void start_insert_play_cmt(void); + void eject_cmt(void); + void on_recent_cmt(void); - void on_set_freq(void); - void on_set_latency(void); + void on_set_freq(void); + void on_set_latency(void); #ifdef USE_CART1 - void insert_cart(void); - void eject_cart(void); - void on_recent_cart(void); + void insert_cart(void); + void eject_cart(void); + void on_recent_cart(void); #endif public: - void setValue1(int v) {bindValue = v;} - int getValue1(void) {return bindValue;} - void setDrive(int num) { drive = num;} - int getDrive(void) { return drive;} - void setNumber(int num) { s_num = num;} - int getNumber(void) { return s_num;} - - bool isPlay(void) { return play; } - void setPlay(bool b) { play = b; } + void setValue1(int v) {bindValue = v;} + int getValue1(void) {return bindValue;} + void setDrive(int num) { drive = num;} + int getDrive(void) { return drive;} + void setNumber(int num) { s_num = num;} + int getNumber(void) { return s_num;} + + bool isPlay(void) { return play; } + void setPlay(bool b) { play = b; } - bool isWriteProtect(void) { return write_protect; } - void setWriteProtect(bool b) {write_protect = b;} - void setSize(int w, int h) { width = w, height = h;} - void getSize(int *w, int *h) { - if((w == NULL) || (h == NULL)) return; - *w = width; - *h = height; - } - + bool isWriteProtect(void) { return write_protect; } + void setWriteProtect(bool b) {write_protect = b;} + void setSize(int w, int h) { width = w, height = h;} + void getSize(int *w, int *h) { + if((w == NULL) || (h == NULL)) return; + *w = width; + *h = height; + } } Object_Menu_Control ; typedef class Action_Control: public QAction { - Q_OBJECT + Q_OBJECT protected: -// virtual void addedTo ( QWidget * actionWidget, QWidget * container ){} - // virtual void addedTo ( int index, QPopupMenu * menu ){} + // 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 = new Object_Menu_Control(parent); - } - ~Action_Control() { - delete binds; - } + Object_Menu_Control *binds; + Action_Control (QObject *parent) : QAction(parent) { + binds = new Object_Menu_Control(parent); + } + ~Action_Control() { + delete binds; + } signals: - int quit_emu_thread(void); -// 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) -// {binds.setValue1(0);} -// Action_Control (const QIconSet &icon, const QString &menuText, QKeySequence accel, QObject *parent, const char *name) : -// QAction(icon, menuText, accel, parent, name) -// {binds.setValue1(0);} - + int quit_emu_thread(void); } ActionControl; QT_END_NAMESPACE diff --git a/source/src/qt/gui/display_statusbar.cpp b/source/src/qt/gui/display_statusbar.cpp index 1d5f0428b..9564b4b14 100644 --- a/source/src/qt/gui/display_statusbar.cpp +++ b/source/src/qt/gui/display_statusbar.cpp @@ -20,156 +20,148 @@ extern EMU* emu; void Ui_MainWindow::initStatusBar(void) { - int i; - statusUpdateTimer = new QTimer; - messagesStatusBar = new QLabel; - //dummyStatusArea1 = new QWidget; - QSize size1, size2, size3; - QString tmpstr; -// QHBoxLayout *layout = new QHBoxLayout(); - - //statusbar->addWidget(layout, 0); - messagesStatusBar->setFixedWidth(350); - statusbar->addPermanentWidget(messagesStatusBar, 0); - dummyStatusArea1 = new QWidget; - statusbar->addPermanentWidget(dummyStatusArea1, 1); -// statusbar->insertStretch(1); + int i; + statusUpdateTimer = new QTimer; + messagesStatusBar = new QLabel; + //dummyStatusArea1 = new QWidget; + QSize size1, size2, size3; + QString tmpstr; + // QHBoxLayout *layout = new QHBoxLayout(); + + //statusbar->addWidget(layout, 0); + messagesStatusBar->setFixedWidth(350); + statusbar->addPermanentWidget(messagesStatusBar, 0); + dummyStatusArea1 = new QWidget; + statusbar->addPermanentWidget(dummyStatusArea1, 1); + // statusbar->insertStretch(1); #ifdef USE_FD1 - for(i = 0; i < MAX_FD; i++) { // Will Fix - fd_StatusBar[i] = new QLabel; - fd_StatusBar[i]->setFixedWidth(200); -// fd_StatusBar[i]->setAlignment(Qt::AlignRight); - statusbar->addPermanentWidget(fd_StatusBar[i]); - } + for(i = 0; i < MAX_FD; i++) { // Will Fix + fd_StatusBar[i] = new QLabel; + fd_StatusBar[i]->setFixedWidth(200); + // fd_StatusBar[i]->setAlignment(Qt::AlignRight); + statusbar->addPermanentWidget(fd_StatusBar[i]); + } #endif #ifdef USE_QD1 - for(i = 0; i < MAX_QD; i++) { - qd_StatusBar[i] = new QLabel; - qd_StatusBar[i]->setFixedWidth(150); -// qd_StatusBar[i]->setAlignment(Qt::AlignRight); - statusbar->addPermanentWidget(qd_StatusBar[i]); - } + for(i = 0; i < MAX_QD; i++) { + qd_StatusBar[i] = new QLabel; + qd_StatusBar[i]->setFixedWidth(150); + // qd_StatusBar[i]->setAlignment(Qt::AlignRight); + statusbar->addPermanentWidget(qd_StatusBar[i]); + } #endif #ifdef USE_TAPE - cmt_StatusBar = new QLabel; - cmt_StatusBar->setFixedWidth(100); - statusbar->addPermanentWidget(cmt_StatusBar); - + cmt_StatusBar = new QLabel; + cmt_StatusBar->setFixedWidth(100); + statusbar->addPermanentWidget(cmt_StatusBar); #endif - dummyStatusArea2 = new QWidget; - dummyStatusArea2->setFixedWidth(100); - statusbar->addPermanentWidget(dummyStatusArea2, 0); -// statusbar->addWidget(dummyStatusArea2); - - connect(statusUpdateTimer, SIGNAL(timeout()), this, SLOT(redraw_status_bar())); - statusUpdateTimer->start(50); + dummyStatusArea2 = new QWidget; + dummyStatusArea2->setFixedWidth(100); + statusbar->addPermanentWidget(dummyStatusArea2, 0); + // statusbar->addWidget(dummyStatusArea2); + connect(statusUpdateTimer, SIGNAL(timeout()), this, SLOT(redraw_status_bar())); + statusUpdateTimer->start(50); } void Ui_MainWindow::redraw_status_bar(void) { - int access_drv; - int tape_counter; - QString alamp; - QString tmpstr; - QString iname; - int i; - if(emu) { - // emu->LockVM(); + int access_drv; + int tape_counter; + QString alamp; + QString tmpstr; + QString iname; + int i; + if(emu) { + // emu->LockVM(); #if defined(USE_QD1) # if defined(USE_ACCESS_LAMP) - access_drv = emu->get_access_lamp(); + access_drv = emu->get_access_lamp(); # endif - for(i = 0; i < MAX_QD ; i++) { - if(emu->quickdisk_inserted(i)) { - // printf("%d\n", access_drv); + for(i = 0; i < MAX_QD ; i++) { + if(emu->quickdisk_inserted(i)) { + // printf("%d\n", access_drv); # if defined(USE_ACCESS_LAMP) - if(i == (access_drv - 1)) { - alamp = QString::fromUtf8("● "); - } else { - alamp = QString::fromUtf8("○ "); - } - tmpstr = QString::fromUtf8("QD"); - tmpstr = alamp + tmpstr + QString::number(i) + QString::fromUtf8(":"); + if(i == (access_drv - 1)) { + alamp = QString::fromUtf8("● "); + } else { + alamp = QString::fromUtf8("○ "); + } + tmpstr = QString::fromUtf8("QD"); + tmpstr = alamp + tmpstr + QString::number(i) + QString::fromUtf8(":"); # else - tmpstr = QString::fromUtf8("QD"); - tmpstr = tmpstr + QString::number(i) + QString::fromUtf8(":"); + tmpstr = QString::fromUtf8("QD"); + tmpstr = tmpstr + QString::number(i) + QString::fromUtf8(":"); # endif - iname = QString::fromUtf8("*Inserted*"); - tmpstr = tmpstr + iname; - } else { - tmpstr = QString::fromUtf8("× QD") + QString::number(i) + QString::fromUtf8(":"); - tmpstr = tmpstr + QString::fromUtf8(" "); - } - if(tmpstr != qd_StatusBar[i]->text()) qd_StatusBar[i]->setText(tmpstr); - } + iname = QString::fromUtf8("*Inserted*"); + tmpstr = tmpstr + iname; + } else { + tmpstr = QString::fromUtf8("× QD") + QString::number(i) + QString::fromUtf8(":"); + tmpstr = tmpstr + QString::fromUtf8(" "); + } + if(tmpstr != qd_StatusBar[i]->text()) qd_StatusBar[i]->setText(tmpstr); + } #endif #if defined(USE_FD1) # if defined(USE_ACCESS_LAMP) - access_drv = emu->get_access_lamp(); + access_drv = emu->get_access_lamp(); # endif - for(i = 0; i < MAX_FD; i++) { - if(emu->disk_inserted(i)) { + for(i = 0; i < MAX_FD; i++) { + if(emu->disk_inserted(i)) { # if defined(USE_ACCESS_LAMP) - if(i == (access_drv - 1)) { - alamp = QString::fromUtf8("● "); - } else { - alamp = QString::fromUtf8("○ "); - } - tmpstr = QString::fromUtf8("FD"); - tmpstr = alamp + tmpstr + QString::number(i) + QString::fromUtf8(":"); + if(i == (access_drv - 1)) { + alamp = QString::fromUtf8("● "); + } else { + alamp = QString::fromUtf8("○ "); + } + tmpstr = QString::fromUtf8("FD"); + tmpstr = alamp + tmpstr + QString::number(i) + QString::fromUtf8(":"); # else - tmpstr = QString::fromUtf8("FD"); - tmpstr = tmpstr + QString::number(i) + QString::fromUtf8(":"); + tmpstr = QString::fromUtf8("FD"); + tmpstr = tmpstr + QString::number(i) + QString::fromUtf8(":"); # endif - if(emu->d88_file[i].bank_num > 0) { - iname = QString::fromUtf8(emu->d88_file[i].disk_name[emu->d88_file[i].cur_bank]); - } else { - iname = QString::fromUtf8("*Inserted*"); - } - tmpstr = tmpstr + iname; - } else { - tmpstr = QString::fromUtf8("× FD") + QString::number(i) + QString::fromUtf8(":"); - tmpstr = tmpstr + QString::fromUtf8(" "); - } - if(tmpstr != fd_StatusBar[i]->text()) fd_StatusBar[i]->setText(tmpstr); - } + if(emu->d88_file[i].bank_num > 0) { + iname = QString::fromUtf8(emu->d88_file[i].disk_name[emu->d88_file[i].cur_bank]); + } else { + iname = QString::fromUtf8("*Inserted*"); + } + tmpstr = tmpstr + iname; + } else { + tmpstr = QString::fromUtf8("× FD") + QString::number(i) + QString::fromUtf8(":"); + tmpstr = tmpstr + QString::fromUtf8(" "); + } + if(tmpstr != fd_StatusBar[i]->text()) fd_StatusBar[i]->setText(tmpstr); + } #endif #ifdef USE_TAPE - if(emu->tape_inserted()) { + if(emu->tape_inserted()) { # if defined(USE_TAPE_PTR) - tape_counter = emu->get_tape_ptr(); - if(tape_counter >= 0) { - tmpstr = QString::fromUtf8("CMT:"); - tmpstr = tmpstr + QString::number(tape_counter) + QString::fromUtf8("%"); - } else { - tmpstr = QString::fromUtf8("CMT:"); - tmpstr = tmpstr + QString::fromUtf8("TOP"); - } + tape_counter = emu->get_tape_ptr(); + if(tape_counter >= 0) { + tmpstr = QString::fromUtf8("CMT:"); + tmpstr = tmpstr + QString::number(tape_counter) + QString::fromUtf8("%"); + } else { + tmpstr = QString::fromUtf8("CMT:"); + tmpstr = tmpstr + QString::fromUtf8("TOP"); + } # else - tmpstr = QString::fromUtf8("CMT:Inserted"); + tmpstr = QString::fromUtf8("CMT:Inserted"); # endif -// cmt_StatusBar->setText(tmpstr); - } else { - tmpstr = QString::fromUtf8("CMT:EMPTY"); - } - if(tmpstr != cmt_StatusBar->text()) cmt_StatusBar->setText(tmpstr); + // cmt_StatusBar->setText(tmpstr); + } else { + tmpstr = QString::fromUtf8("CMT:EMPTY"); + } + if(tmpstr != cmt_StatusBar->text()) cmt_StatusBar->setText(tmpstr); #endif - // emu->UnlockVM(); - } - + // emu->UnlockVM(); + } } void Ui_MainWindow::message_status_bar(QString str) { - //QString tmpstr; - if(messagesStatusBar == NULL) return; - if(str != messagesStatusBar->text()) messagesStatusBar->setText(str); - } - - - - - + //QString tmpstr; + if(messagesStatusBar == NULL) return; + if(str != messagesStatusBar->text()) messagesStatusBar->setText(str); +} diff --git a/source/src/qt/gui/mainwidget.h b/source/src/qt/gui/mainwidget.h index 9e5c70550..2038f0cb2 100644 --- a/source/src/qt/gui/mainwidget.h +++ b/source/src/qt/gui/mainwidget.h @@ -41,449 +41,428 @@ QT_BEGIN_NAMESPACE class Ui_MainWindow : public QMainWindow { - Q_OBJECT + Q_OBJECT protected: - QMainWindow *MainWindow; - QWidget *centralwidget; - GLDrawClass *graphicsView; - QStatusBar *statusbar; - QMenuBar *menubar; - QTimer *statusUpdateTimer; + QMainWindow *MainWindow; + QWidget *centralwidget; + GLDrawClass *graphicsView; + QStatusBar *statusbar; + QMenuBar *menubar; + QTimer *statusUpdateTimer; - // Some Functions - void ConfigCpuSpeed(void); - void ConfigControlMenu(void); - void connectActions_ControlMenu(void); - void retranslateControlMenu(const char *SpecialResetTitle, bool WithSpecialReset); - void ConfigFloppyMenu(void); - void ConfigSoundMenu(void); - void CreateSoundMenu(void); + // Some Functions + void ConfigCpuSpeed(void); + void ConfigControlMenu(void); + void connectActions_ControlMenu(void); + void retranslateControlMenu(const char *SpecialResetTitle, bool WithSpecialReset); + void ConfigFloppyMenu(void); + void ConfigSoundMenu(void); + void CreateSoundMenu(void); - void OnWindowResize(void); - void OnWindowMove(void); - void OnWindowRedraw(void); - void CreateFloppyMenu(int drv, int drv_base); - void CreateFloppyPulldownMenu(int drv); - void ConfigFloppyMenuSub(int drv); - void retranslateFloppyMenu(int drv, int basedrv); - void CreateCMTMenu(void); - void CreateCMTPulldownMenu(void); - void ConfigCMTMenuSub(void); - void retranslateCMTMenu(void); - void ConfigCMTMenu(void); + void OnWindowResize(void); + void OnWindowMove(void); + void OnWindowRedraw(void); + void CreateFloppyMenu(int drv, int drv_base); + void CreateFloppyPulldownMenu(int drv); + void ConfigFloppyMenuSub(int drv); + void retranslateFloppyMenu(int drv, int basedrv); + void CreateCMTMenu(void); + void CreateCMTPulldownMenu(void); + void ConfigCMTMenuSub(void); + void retranslateCMTMenu(void); + void ConfigCMTMenu(void); - void ConfigQuickDiskMenu(void); - void retranslateQuickDiskMenu(int drv, int basedrv); - void ConfigQuickDiskMenuSub(int drv); - void CreateQuickDiskPulldownMenu(int drv); - void CreateQuickDiskMenu(int drv, int drv_base); - void eject_Qd(int drv); + void ConfigQuickDiskMenu(void); + void retranslateQuickDiskMenu(int drv, int basedrv); + void ConfigQuickDiskMenuSub(int drv); + void CreateQuickDiskPulldownMenu(int drv); + void CreateQuickDiskMenu(int drv, int drv_base); + void eject_Qd(int drv); - void CreateCartMenu(int drv, int drv_base); - void CreateCartPulldownMenu(int drv); - void ConfigCartMenuSub(int drv); - void ConfigCartMenu(void); - virtual void retranslateCartMenu(int drv, int basedrv); + void CreateCartMenu(int drv, int drv_base); + void CreateCartPulldownMenu(int drv); + void ConfigCartMenuSub(int drv); + void ConfigCartMenu(void); + virtual void retranslateCartMenu(int drv, int basedrv); - void ConfigBinaryMenu(void); - void retranslateBinaryMenu(int drv, int basedrv); + void ConfigBinaryMenu(void); + void retranslateBinaryMenu(int drv, int basedrv); + + void retranslateSoundMenu(void); + + void ConfigScreenMenu(void); + void ConfigScreenMenu_List(void); + void CreateScreenMenu(void); + void retranslateScreenMenu(void); - void retranslateSoundMenu(void); - - void ConfigScreenMenu(void); - void ConfigScreenMenu_List(void); - void CreateScreenMenu(void); - void retranslateScreenMenu(void); - - class Action_Control *actionReset; - class Action_Control *actionSpecial_Reset; - class Action_Control *actionExit_Emulator; + class Action_Control *actionReset; + class Action_Control *actionSpecial_Reset; + class Action_Control *actionExit_Emulator; #ifdef USE_CPU_TYPE - // Pls.Override - QActionGroup *actionGroup_CpuType; - QMenu *menuCpuType; - class Action_Control *actionCpuType[8]; - void ConfigCPUTypes(int num); -#endif - QActionGroup *actionGroup_CpuSpeed; - class Action_Control *actionSpeed_x1; - class Action_Control *actionSpeed_x2; - class Action_Control *actionSpeed_x4; - class Action_Control *actionSpeed_x8; - class Action_Control *actionSpeed_x16; + // Pls.Override + QActionGroup *actionGroup_CpuType; + QMenu *menuCpuType; + class Action_Control *actionCpuType[8]; + void ConfigCPUTypes(int num); +#endif + QActionGroup *actionGroup_CpuSpeed; + class Action_Control *actionSpeed_x1; + class Action_Control *actionSpeed_x2; + class Action_Control *actionSpeed_x4; + class Action_Control *actionSpeed_x8; + class Action_Control *actionSpeed_x16; #ifdef USE_BOOT_MODE - // Pls.Override - QActionGroup *actionGroup_BootMode; - QMenu *menuBootMode; - class Action_Control *actionBootMode[8]; - void ConfigCPUBootMode(int num); + // Pls.Override + QActionGroup *actionGroup_BootMode; + QMenu *menuBootMode; + class Action_Control *actionBootMode[8]; + void ConfigCPUBootMode(int num); #endif - class Action_Control *actionPaste_from_Clipboard; - class Action_Control *actionStop_Pasting; + class Action_Control *actionPaste_from_Clipboard; + class Action_Control *actionStop_Pasting; #ifdef USE_STATE - class Action_Control *actionSave_State; - class Action_Control *actionLoad_State; + class Action_Control *actionSave_State; + class Action_Control *actionLoad_State; #endif #ifdef USE_DEBUGGER - class Action_Control *actionDebugger_1; - class Action_Control *actionDebugger_2; - class Action_Control *actionDebugger_3; - class Action_Control *actionClose_Debuggers; + class Action_Control *actionDebugger_1; + class Action_Control *actionDebugger_2; + class Action_Control *actionDebugger_3; + class Action_Control *actionClose_Debuggers; #endif #if defined(USE_CART1) || defined(USE_CART2) - QActionGroup *actionGroup_Opened_CART[2]; - class Action_Control *actionRecent_Opened_CART[2]; - class Action_Control *action_Recent_List_CART[2][MAX_HISTORY]; - class Action_Control *actionInsert_CART[2]; - class Action_Control *actionEject_CART[2]; + QActionGroup *actionGroup_Opened_CART[2]; + class Action_Control *actionRecent_Opened_CART[2]; + class Action_Control *action_Recent_List_CART[2][MAX_HISTORY]; + class Action_Control *actionInsert_CART[2]; + class Action_Control *actionEject_CART[2]; #endif #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) - QActionGroup *actionGroup_Opened_FD[8]; - QActionGroup *actionGroup_Protect_FD[8]; - class Action_Control *actionRecent_Opened_FD[8]; - class Action_Control *action_Recent_List_FD[8][MAX_HISTORY]; - - QActionGroup *actionGroup_D88_Image_FD[8]; - class Action_Control *actionSelect_D88_Image_FD[8]; - class Action_Control *action_D88_ListImage_FD[8][64]; - class Action_Control *actionInsert_FD[8]; - class Action_Control *actionEject_FD[8]; - - class Action_Control *actionProtection_ON_FD[8]; - class Action_Control *actionProtection_OFF_FD[8]; + QActionGroup *actionGroup_Opened_FD[8]; + QActionGroup *actionGroup_Protect_FD[8]; + class Action_Control *actionRecent_Opened_FD[8]; + class Action_Control *action_Recent_List_FD[8][MAX_HISTORY]; + + QActionGroup *actionGroup_D88_Image_FD[8]; + class Action_Control *actionSelect_D88_Image_FD[8]; + class Action_Control *action_D88_ListImage_FD[8][64]; + class Action_Control *actionInsert_FD[8]; + class Action_Control *actionEject_FD[8]; + + class Action_Control *actionProtection_ON_FD[8]; + class Action_Control *actionProtection_OFF_FD[8]; #endif #if defined(USE_QD1) || defined(USE_QD2) - QActionGroup *actionGroup_Opened_QD[2]; - QActionGroup *actionGroup_Protect_QD[2]; - class Action_Control *actionRecent_Opened_QD[2]; - class Action_Control *action_Recent_List_QD[2][MAX_HISTORY]; - class Action_Control *actionInsert_QD[2]; - class Action_Control *actionEject_QD[2]; - class Action_Control *actionProtection_ON_QD[2]; - class Action_Control *actionProtection_OFF_QD[2]; + QActionGroup *actionGroup_Opened_QD[2]; + QActionGroup *actionGroup_Protect_QD[2]; + class Action_Control *actionRecent_Opened_QD[2]; + class Action_Control *action_Recent_List_QD[2][MAX_HISTORY]; + class Action_Control *actionInsert_QD[2]; + class Action_Control *actionEject_QD[2]; + class Action_Control *actionProtection_ON_QD[2]; + class Action_Control *actionProtection_OFF_QD[2]; #endif #ifdef USE_TAPE - QActionGroup *actionGroup_Opened_CMT; - QActionGroup *actionGroup_Protect_CMT; - class Action_Control *actionWaveShaper; - class Action_Control *actionDirectLoadMZT; - class Action_Control *actionRecent_Opened_CMT; - class Action_Control *action_Recent_List_CMT[MAX_HISTORY]; - class Action_Control *actionInsert_CMT; - class Action_Control *actionEject_CMT; + QActionGroup *actionGroup_Opened_CMT; + QActionGroup *actionGroup_Protect_CMT; + class Action_Control *actionWaveShaper; + class Action_Control *actionDirectLoadMZT; + class Action_Control *actionRecent_Opened_CMT; + class Action_Control *action_Recent_List_CMT[MAX_HISTORY]; + class Action_Control *actionInsert_CMT; + class Action_Control *actionEject_CMT; #ifdef USE_TAPE_BUTTON - QActionGroup *actionGroup_PlayTape; - class Action_Control *actionPlay_Start; - class Action_Control *actionPlay_Stop; + QActionGroup *actionGroup_PlayTape; + class Action_Control *actionPlay_Start; + class Action_Control *actionPlay_Stop; #endif - class Action_Control *actionRecording; - class Action_Control *actionProtection_ON_CMT; - class Action_Control *actionProtection_OFF_CMT; - bool write_protect; + class Action_Control *actionRecording; + class Action_Control *actionProtection_ON_CMT; + class Action_Control *actionProtection_OFF_CMT; + bool write_protect; #endif #if defined(USE_LASER_DISC) - class Action_Control *actionInsert_LD; - class Action_Control *actionEject_LD; - QActionGroup *actionGroup_Opened_LD; - class Action_Control *actionRecent_Opened_LD; - class Action_Control *action_Recent_List_LD[MAX_HISTORY]; + class Action_Control *actionInsert_LD; + class Action_Control *actionEject_LD; + QActionGroup *actionGroup_Opened_LD; + class Action_Control *actionRecent_Opened_LD; + class Action_Control *action_Recent_List_LD[MAX_HISTORY]; #endif #if defined(USE_BINARY_FILE1) - QActionGroup *actionGroup_Opened_BIN[8]; - QActionGroup *actionGroup_Protect_BIN[8]; // Is needed? - class Action_Control *actionRecent_Opened_BIN[8]; - class Action_Control *action_Recent_List_BIN[8][MAX_HISTORY]; - class Action_Control *actionLoad_BIN[8]; - class Action_Control *actionSave_BIN[8]; -#endif - // Screen - QActionGroup *actionGroup_Stretch; - class Action_Control *actionZoom; - class Action_Control *actionDisplay_Mode; - class Action_Control *actionScanLine; - class Action_Control *actionCRT_Filter; - class Action_Control *actionDot_by_Dot; - class Action_Control *actionKeep_Aspect; - class Action_Control *actionFill_Display; - class Action_Control *actionCapture_Screen; + QActionGroup *actionGroup_Opened_BIN[8]; + QActionGroup *actionGroup_Protect_BIN[8]; // Is needed? + class Action_Control *actionRecent_Opened_BIN[8]; + class Action_Control *action_Recent_List_BIN[8][MAX_HISTORY]; + class Action_Control *actionLoad_BIN[8]; + class Action_Control *actionSave_BIN[8]; +#endif + // Screen + QActionGroup *actionGroup_Stretch; + class Action_Control *actionZoom; + class Action_Control *actionDisplay_Mode; + class Action_Control *actionScanLine; + class Action_Control *actionCRT_Filter; + class Action_Control *actionDot_by_Dot; + class Action_Control *actionKeep_Aspect; + class Action_Control *actionFill_Display; + class Action_Control *actionCapture_Screen; - QActionGroup *actionGroup_ScreenSize; - class Action_Control *actionScreenSize[_SCREEN_MODE_NUM]; - - - class Action_Control *actionAbout; - QActionGroup *actionGroup_Sound_Freq; - QActionGroup *actionGroup_Sound_Latency; + QActionGroup *actionGroup_ScreenSize; + class Action_Control *actionScreenSize[_SCREEN_MODE_NUM]; + class Action_Control *actionAbout; + QActionGroup *actionGroup_Sound_Freq; + QActionGroup *actionGroup_Sound_Latency; #ifdef DATAREC_SOUND - class Action_Control *actionSoundCMT; -#endif - - class Action_Control *action_Freq[8]; - - class Action_Control *action_Latency[6]; - - class Action_Control *actionStart_Record; - class Action_Control *actionStop_Record; - class Action_Control *actionStart_Record_Movie; - class Action_Control *actionStop_Record_Movie; - - // Manus - QMenu *menuControl; - QMenu *menuState; - QMenu *menuCopy_Paste; - QMenu *menuCpu_Speed; - QMenu *menuDebugger; - + class Action_Control *actionSoundCMT; +#endif + class Action_Control *action_Freq[8]; + class Action_Control *action_Latency[6]; + class Action_Control *actionStart_Record; + class Action_Control *actionStop_Record; + class Action_Control *actionStart_Record_Movie; + class Action_Control *actionStop_Record_Movie; + // Menus + QMenu *menuControl; + QMenu *menuState; + QMenu *menuCopy_Paste; + QMenu *menuCpu_Speed; + QMenu *menuDebugger; #if defined(USE_CART1) || defined(USE_CART2) - QMenu *menuCART[8]; - QMenu *menuCART_Recent[8]; + QMenu *menuCART[8]; + QMenu *menuCART_Recent[8]; #endif #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) - QMenu *menuFD[8]; - QMenu *menuFD_Recent[8]; - QMenu *menuFD_D88[8]; - QMenu *menuWrite_Protection_FD[8]; + QMenu *menuFD[8]; + QMenu *menuFD_Recent[8]; + QMenu *menuFD_D88[8]; + QMenu *menuWrite_Protection_FD[8]; #endif #if defined(USE_QD1) || defined(USE_QD2) - QMenu *menuQD[2]; - QMenu *menuQD_Recent[2]; - QMenu *menuWrite_Protection_QD[2]; + QMenu *menuQD[2]; + QMenu *menuQD_Recent[2]; + QMenu *menuWrite_Protection_QD[2]; #endif #ifdef USE_TAPE - QMenu *menuCMT; - QMenu *menuCMT_Recent; - QMenu *menuWrite_Protection_CMT; + QMenu *menuCMT; + QMenu *menuCMT_Recent; + QMenu *menuWrite_Protection_CMT; #endif #ifdef USE_LASER_DISC - QMenu *menuLD; - QMenu *menuLD_Recent; + QMenu *menuLD; + QMenu *menuLD_Recent; #endif #if defined(USE_BINARY_FILE1) - QMenu *menuBIN[8]; - QMenu *menuBIN_Recent[8]; -#endif - - QMenu *menuScreen; - QMenu *menuStretch_Mode; - QMenu *menuScreenSize; - - - QMenu *menuSound; - QMenu *menuOutput_Frequency; - QMenu *menuSound_Latency; - QMenu *menuMachine; - QMenu *menuRecord; - QMenu *menuRecord_sound; - QMenu *menuRecord_as_movie; - QMenu *menuEmulator; - QMenu *menuHELP; - // Status Bar - QWidget *dummyStatusArea1; - QLabel *messagesStatusBar; - QWidget *dummyStatusArea2; + QMenu *menuBIN[8]; + QMenu *menuBIN_Recent[8]; +#endif + QMenu *menuScreen; + QMenu *menuStretch_Mode; + QMenu *menuScreenSize; + + QMenu *menuSound; + QMenu *menuOutput_Frequency; + QMenu *menuSound_Latency; + QMenu *menuMachine; + QMenu *menuRecord; + QMenu *menuRecord_sound; + QMenu *menuRecord_as_movie; + QMenu *menuEmulator; + QMenu *menuHELP; + // Status Bar + QWidget *dummyStatusArea1; + QLabel *messagesStatusBar; + QWidget *dummyStatusArea2; #ifdef USE_FD1 - QLabel *fd_StatusBar[8]; + QLabel *fd_StatusBar[8]; #endif #ifdef USE_QD1 - QLabel *qd_StatusBar[8]; + QLabel *qd_StatusBar[8]; #endif #ifdef USE_TAPE - QLabel *cmt_StatusBar; -#endif - // About Status bar - virtual void initStatusBar(void); - // Constructor - class EmuThreadClass *hRunEmu; - class DrawThreadClass *hDrawEmu; -// class EmuThreadCore *hRunEmuThread; - SDL_Thread *hRunEmuThread; - bool bRunEmuThread; + QLabel *cmt_StatusBar; +#endif + // About Status bar + virtual void initStatusBar(void); + // Constructor + class EmuThreadClass *hRunEmu; + class DrawThreadClass *hDrawEmu; - class JoyThreadClass *hRunJoy; - bool bRunJoyThread; + class JoyThreadClass *hRunJoy; public: - Ui_MainWindow(QWidget *parent = 0); - ~Ui_MainWindow(); - // Initializer : using from InitContext. - void createContextMenu(void); - void setupUi(void); - void set_window(int mode); - // Belows are able to re-implement. - virtual void retranslateUi(void); - // EmuThread - void StopEmuThread(void); - void LaunchEmuThread(void); - - void StopJoyThread(void); - void LaunchJoyThread(void); - - // Getting important widgets. - QMainWindow *getWindow(void) { return MainWindow; } - QMenuBar *getMenuBar(void) { return menubar;} - GLDrawClass *getGraphicsView(void) { return graphicsView; } - QStatusBar *getStatusBar(void) { return statusbar;} - void OnMainWindowClosed(void); - // Basic Action Definition - void OnCpuPower(int mode); -//#ifdef USE_TAPE - bool get_wave_shaper(void); - bool get_direct_load_mzt(void); -//#endif - bool getRunEmuThread(void) {return bRunEmuThread; } - void setRunEmuThread(bool f) {bRunEmuThread = f; } + Ui_MainWindow(QWidget *parent = 0); + ~Ui_MainWindow(); + // Initializer : using from InitContext. + void createContextMenu(void); + void setupUi(void); + void set_window(int mode); + // Belows are able to re-implement. + virtual void retranslateUi(void); + // EmuThread + void StopEmuThread(void); + void LaunchEmuThread(void); + + void StopJoyThread(void); + void LaunchJoyThread(void); - bool getRunJoyThread(void) {return bRunJoyThread; } - void setRunJoyThread(bool f) {bRunJoyThread = f; } + // Getting important widgets. + QMainWindow *getWindow(void) { return MainWindow; } + QMenuBar *getMenuBar(void) { return menubar;} + GLDrawClass *getGraphicsView(void) { return graphicsView; } + QStatusBar *getStatusBar(void) { return statusbar;} + void OnMainWindowClosed(void); + // Basic Action Definition + void OnCpuPower(int mode); + //#ifdef USE_TAPE + bool get_wave_shaper(void); + bool get_direct_load_mzt(void); + //#endif #ifdef USE_POWER_OFF - bool GetPowerState(void); + bool GetPowerState(void); #endif - // Basic slots + // Basic slots public slots: - void delete_emu_thread(void); - void doExit_EmuThread(void); - void doChangeMessage_EmuThread(QString str); + void delete_emu_thread(void); + void doChangeMessage_EmuThread(QString str); - void delete_joy_thread(void); - virtual void redraw_status_bar(void); - void set_screen_aspect(int num); - void set_screen_size(int w, int h); - void OnReset(void); - void OnSpecialReset(void); + void delete_joy_thread(void); + virtual void redraw_status_bar(void); + void set_screen_aspect(int num); + void set_screen_size(int w, int h); + void OnReset(void); + void OnSpecialReset(void); #ifdef USE_STATE - void OnLoadState(void); - void OnSaveState(void); + void OnLoadState(void); + void OnSaveState(void); #endif #ifdef USE_DEBUGGER - void OnOpenDebugger(int n); - void OnCloseDebugger(void); + void OnOpenDebugger(int n); + void OnCloseDebugger(void); #endif - void set_cpu_power(int pw) { - OnCpuPower(pw); - } - - void on_actionExit_triggered() { - save_config(); - OnMainWindowClosed(); - } - + void set_cpu_power(int pw) { + OnCpuPower(pw); + } + void on_actionExit_triggered() { + save_config(); + OnMainWindowClosed(); + } #ifdef USE_AUTO_KEY - void OnStartAutoKey(void); - void OnStopAutoKey(void); + void OnStartAutoKey(void); + void OnStopAutoKey(void); #endif #ifdef USE_FD1 - void open_disk_dialog(int drv); + void open_disk_dialog(int drv); #endif #ifdef USE_CART1 - void open_cart_dialog(int); - void eject_cart(int); - void set_recent_cart(int, int); + void open_cart_dialog(int); + void eject_cart(int); + void set_recent_cart(int, int); #endif #if defined(USE_BINARY_FILE1) - void open_binary_dialog(int drive, bool load); - void CreateBinaryMenu(int drv, int drv_base); - void CreateBinaryPulldownMenu(int drv); - void ConfigBinaryMenuSub(int drv); - int set_recent_binary_load(int drv, int num); - int set_recent_binary_save(int drv, int num); - void _open_binary(int drive, const QString fname, bool load); + void open_binary_dialog(int drive, bool load); + void CreateBinaryMenu(int drv, int drv_base); + void CreateBinaryPulldownMenu(int drv); + void ConfigBinaryMenuSub(int drv); + int set_recent_binary_load(int drv, int num); + int set_recent_binary_save(int drv, int num); + void _open_binary(int drive, const QString fname, bool load); #endif //#ifdef USE_QD1 - void open_quick_disk_dialog(int drv); - int set_recent_quick_disk(int drive, int num); - int write_protect_Qd(int drv, bool flag); - void _open_quick_disk(int drv, const QString fname); + void open_quick_disk_dialog(int drv); + int set_recent_quick_disk(int drive, int num); + int write_protect_Qd(int drv, bool flag); + void _open_quick_disk(int drv, const QString fname); //#endif - void _open_disk(int drv, const QString fname); - void _open_cart(int drv, const QString fname); - void _open_cmt(bool mode,const QString path); - void eject_cmt(void); + void _open_disk(int drv, const QString fname); + void _open_cart(int drv, const QString fname); + void _open_cmt(bool mode,const QString path); + void eject_cmt(void); #ifdef USE_BOOT_MODE - void do_change_boot_mode(int mode); + void do_change_boot_mode(int mode); #endif #ifdef USE_CPU_TYPE - void do_change_cpu_type(int mode); + void do_change_cpu_type(int mode); #endif #ifdef USE_TAPE - void open_cmt_dialog(bool play); - void do_write_protect_cmt(bool flag); - int set_recent_cmt(int num); - void set_wave_shaper(bool f); - void set_direct_load_from_mzt(bool f); + void open_cmt_dialog(bool play); + void do_write_protect_cmt(bool flag); + int set_recent_cmt(int num); + void set_wave_shaper(bool f); + void set_direct_load_from_mzt(bool f); #ifdef USE_TAPE_BUTTON - void do_push_play_tape(void); - void do_push_stop_tape(void); - void do_display_tape_play(bool flag); + void do_push_play_tape(void); + void do_push_stop_tape(void); + void do_display_tape_play(bool flag); #endif #endif #ifdef DATAREC_SOUND - void set_cmt_sound(bool); + void set_cmt_sound(bool); #endif - int write_protect_fd(int drv, bool flag); - void eject_fd(int drv); + int write_protect_fd(int drv, bool flag); + void eject_fd(int drv); #ifdef USE_FD1 - int set_d88_slot(int drive, int num); - int set_recent_disk(int, int); -#endif - void start_record_sound(bool rec); - void set_freq(int); - void set_latency(int); - void set_sound_device(int); - void set_monitor_type(int); - void message_status_bar(QString); - void do_release_emu_resources(void); + int set_d88_slot(int drive, int num); + int set_recent_disk(int, int); +#endif + void start_record_sound(bool rec); + void set_freq(int); + void set_latency(int); + void set_sound_device(int); + void set_monitor_type(int); + void message_status_bar(QString); + void do_release_emu_resources(void); #if defined(USE_SCANLINE) - void set_scan_line(bool); + void set_scan_line(bool); #endif #if defined(USE_DIPSWITCH) - void set_dipsw(int num, bool flag) { - if((num < 0) || (num >= 32)) return; - if(flag) { - config.dipswitch = config.dipswitch | (1 << num); - } else { - config.dipswitch = config.dipswitch & ~(1 << num); + void set_dipsw(int num, bool flag) { + if((num < 0) || (num >= 32)) return; + if(flag) { + config.dipswitch = config.dipswitch | (1 << num); + } else { + config.dipswitch = config.dipswitch & ~(1 << num); + } + } + bool get_dipsw(int num) { + if((num < 0) || (num >= 32)) return false; + if(((1 << num) & config.dipswitch) == 0) return false; + return true; } - } - bool get_dipsw(int num) { - if((num < 0) || (num >= 32)) return false; - if(((1 << num) & config.dipswitch) == 0) return false; - return true; - } #endif signals: - int message_changed(QString); - int quit_emu_thread(); - int call_joy_thread(EMU *); - int quit_joy_thread(); - int quit_draw_thread(); - int on_boot_mode(int); - int on_cpu_type(int); - int on_cpu_power(int); - int on_open_debugger(int); - int on_insert_fd(int); - int on_eject_fd(int); - int do_open_disk(int, QString); - int do_recent_cmt(bool); - int closed(void); - int sig_quit_all(void); - int sig_vm_reset(void); - int sig_vm_specialreset(void); - int sig_vm_loadstate(void); - int sig_vm_savestate(void); + int message_changed(QString); + int quit_emu_thread(); + int call_joy_thread(EMU *); + int quit_joy_thread(); + int quit_draw_thread(); + int on_boot_mode(int); + int on_cpu_type(int); + int on_cpu_power(int); + int on_open_debugger(int); + int on_insert_fd(int); + int on_eject_fd(int); + int do_open_disk(int, QString); + int do_recent_cmt(bool); + int closed(void); + int sig_quit_all(void); + int sig_vm_reset(void); + int sig_vm_specialreset(void); + int sig_vm_loadstate(void); + int sig_vm_savestate(void); }; QT_END_NAMESPACE diff --git a/source/src/qt/gui/mainwindow_utils.cpp b/source/src/qt/gui/mainwindow_utils.cpp index cc10ad42a..15f35c659 100644 --- a/source/src/qt/gui/mainwindow_utils.cpp +++ b/source/src/qt/gui/mainwindow_utils.cpp @@ -21,138 +21,131 @@ extern const double s_late_table[]; void Ui_MainWindow::set_latency(int num) { - if((num < 0) || (num > 4)) return; - config.sound_latency = num; - if(emu) { - emu->LockVM(); - emu->update_config(); - emu->UnlockVM(); - } + if((num < 0) || (num > 4)) return; + config.sound_latency = num; + if(emu) { + emu->LockVM(); + emu->update_config(); + emu->UnlockVM(); + } } void Ui_MainWindow::set_freq(int num) { - if((num < 0) || (num > 7)) return; - config.sound_frequency = num; - if(emu) { - emu->LockVM(); - emu->update_config(); - emu->UnlockVM(); - } + if((num < 0) || (num > 7)) return; + config.sound_frequency = num; + if(emu) { + emu->LockVM(); + emu->update_config(); + emu->UnlockVM(); + } } void Ui_MainWindow::set_sound_device(int num) { #ifdef USE_SOUND_DEVICE_TYPE - if((num < 0) || (num >7)) return; - config.sound_device_type = num; - if(emu) { - emu->LockVM(); - emu->update_config(); - emu->UnlockVM(); - } + if((num < 0) || (num >7)) return; + config.sound_device_type = num; + if(emu) { + emu->LockVM(); + emu->update_config(); + emu->UnlockVM(); + } #endif } void Ui_MainWindow::start_record_sound(bool start) { - if(emu) { - if(start) { - emu->LockVM(); - emu->start_rec_sound(); - emu->UnlockVM(); - } else { - emu->LockVM(); - emu->stop_rec_sound(); - emu->UnlockVM(); + if(emu) { + emu->LockVM(); + if(start) { + emu->start_rec_sound(); + } else { + emu->stop_rec_sound(); + } + emu->UnlockVM(); } - } } void Ui_MainWindow::set_monitor_type(int num) { #ifdef USE_MONITOR_TYPE - if((num < 0) || (num >7)) return; - config.monitor_type = num; - if(emu) { - emu->LockVM(); - emu->update_config(); - emu->UnlockVM(); - } + if((num < 0) || (num >7)) return; + config.monitor_type = num; + if(emu) { + emu->LockVM(); + emu->update_config(); + emu->UnlockVM(); + } #endif } #if defined(USE_SCANLINE) void Ui_MainWindow::set_scan_line(bool flag) { - if(flag) { - config.scan_line = ~0; - } else { - config.scan_line = 0; - } - if(emu) { - emu->LockVM(); - emu->update_config(); - emu->UnlockVM(); - } + if(flag) { + config.scan_line = ~0; + } else { + config.scan_line = 0; + } + if(emu) { + emu->LockVM(); + emu->update_config(); + emu->UnlockVM(); + } } #endif #ifdef DATAREC_SOUND void Ui_MainWindow::set_cmt_sound(bool flag) { - config.tape_sound = flag; - if(emu) { - emu->LockVM(); - emu->update_config(); - emu->UnlockVM(); - } + config.tape_sound = flag; + if(emu) { + emu->LockVM(); + emu->update_config(); + emu->UnlockVM(); + } } #endif void Ui_MainWindow::set_screen_size(int w, int h) { - if((w <= 0) || (h <= 0)) return; - //QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + if((w <= 0) || (h <= 0)) return; + //QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); - this->graphicsView->setFixedSize(w, h); - MainWindow->centralWidget()->adjustSize(); - MainWindow->adjustSize(); - - // graphicsView->setSizePolicy(sizePolicy); - //MainWindow->centralWidget()->setSizePolicy(sizePolicy); - + this->graphicsView->setFixedSize(w, h); + MainWindow->centralWidget()->adjustSize(); + MainWindow->adjustSize(); + // graphicsView->setSizePolicy(sizePolicy); + //MainWindow->centralWidget()->setSizePolicy(sizePolicy); } void Ui_MainWindow::set_screen_aspect(int num) { - if((num < 0) || (num >= 3)) return; - double ww = SCREEN_WIDTH; - double hh = SCREEN_HEIGHT; - double whratio = ww / hh; - double ratio; - int width, height; - QSizePolicy policy; - // 0 = DOT - // 1 = ASPECT - // 2 = FILL - // On Common Sourcecode Project / Agar, - // Scaling is done by Agar Widget. - // So, does need below action? - // Maybe, needs Agar's changing action. - - config.stretch_type = num; - - if(emu) { - int w, h; - w = this->graphicsView->width(); - h = this->graphicsView->height(); - this->graphicsView->resizeGL(w, h); - } + if((num < 0) || (num >= 3)) return; + double ww = SCREEN_WIDTH; + double hh = SCREEN_HEIGHT; + double whratio = ww / hh; + double ratio; + int width, height; + QSizePolicy policy; + // 0 = DOT + // 1 = ASPECT + // 2 = FILL + // On Common Sourcecode Project / Agar, + // Scaling is done by Agar Widget. + // So, does need below action? + // Maybe, needs Agar's changing action. + + config.stretch_type = num; + + if(emu) { + int w, h; + w = this->graphicsView->width(); + h = this->graphicsView->height(); + this->graphicsView->resizeGL(w, h); + } } - - - QT_END_NAMESPACE diff --git a/source/src/qt/gui/menu_binary.cpp b/source/src/qt/gui/menu_binary.cpp index b90872e31..bdd120d2d 100644 --- a/source/src/qt/gui/menu_binary.cpp +++ b/source/src/qt/gui/menu_binary.cpp @@ -16,11 +16,11 @@ #ifdef USE_BINARY_FILE1 void Object_Menu_Control::on_recent_binary_load(void){ - // write_protect = false; // Right? On D88, May be writing entry exists. + // write_protect = false; // Right? On D88, May be writing entry exists. emit set_recent_binary_load(drive, s_num); } void Object_Menu_Control::on_recent_binary_save(void){ - // write_protect = false; // Right? On D88, May be writing entry exists. + // write_protect = false; // Right? On D88, May be writing entry exists. emit set_recent_binary_save(drive, s_num); } diff --git a/source/src/qt/gui/menu_cart.cpp b/source/src/qt/gui/menu_cart.cpp index 31a758425..f44698212 100644 --- a/source/src/qt/gui/menu_cart.cpp +++ b/source/src/qt/gui/menu_cart.cpp @@ -16,16 +16,14 @@ #ifdef USE_CART1 void Object_Menu_Control::insert_cart(void) { - //AGAR_DebugLog(AGAR_LOG_DEBUG, "cart Insert: %d", getDrive()); - emit sig_insert_cart(getDrive()); + emit sig_insert_cart(getDrive()); } void Object_Menu_Control::eject_cart(void) { - write_protect = false; - emit sig_eject_cart(getDrive()); + write_protect = false; + emit sig_eject_cart(getDrive()); } void Object_Menu_Control::on_recent_cart(void){ - // write_protect = false; // Right? On D88, May be writing entry exists. - emit set_recent_cart(drive, s_num); + emit set_recent_cart(drive, s_num); } #endif @@ -34,163 +32,158 @@ QT_BEGIN_NAMESPACE void Ui_MainWindow::open_cart_dialog(int drive) { - QString ext; - QString desc1; - QString desc2; - CSP_DiskDialog dlg; - QString dirname; + QString ext; + QString desc1; + QString desc2; + CSP_DiskDialog dlg; + QString dirname; #if defined(_GAMEGEAR) - ext = "*.rom *.bin *.gg *.col"; - desc1 = "Game Cartridge"; + ext = "*.rom *.bin *.gg *.col"; + desc1 = "Game Cartridge"; #elif defined(_MASTERSYSTEM) - ext = "*.rom *.bin *.sms"; - desc1 = "Game Cartridge"; + ext = "*.rom *.bin *.sms"; + desc1 = "Game Cartridge"; #elif defined(_PC6001) || defined(_PC6001MK2) || defined(_PC6001MK2SR) || defined(_PC6601) || defined(_PC6601SR) - ext = "*.rom *.bin *.60"; - desc1 = "Game Cartridge"; + ext = "*.rom *.bin *.60"; + desc1 = "Game Cartridge"; #elif defined(_PCENGINE) || defined(_X1TWIN) - ext = "*.rom *.bin *.pce"; - desc1 = "HuCARD"; + ext = "*.rom *.bin *.pce"; + desc1 = "HuCARD"; #else - ext = "*.rom *.bin"; - desc1 = "Game Cartridge"; + ext = "*.rom *.bin"; + desc1 = "Game Cartridge"; #endif - desc2.number(drive + 1); - desc2 = QString::fromUtf8("Open Cartridge on #") + desc2; - dlg.setWindowTitle(desc2); - - desc2 = desc1 + " (" + ext.toLower() + ")"; - desc1 = desc1 + " (" + ext.toUpper() + ")"; + desc2.number(drive + 1); + desc2 = QString::fromUtf8("Open Cartridge on #") + desc2; + dlg.setWindowTitle(desc2); + + desc2 = desc1 + " (" + ext.toLower() + ")"; + desc1 = desc1 + " (" + ext.toUpper() + ")"; - if(config.initial_cart_dir != NULL) { - dirname = QString::fromUtf8(config.initial_cart_dir); - } else { - char app[PATH_MAX]; - QDir df; - dirname = df.currentPath(); - strncpy(app, dirname.toUtf8().constData(), PATH_MAX); - dirname = get_parent_dir(app); - } - QStringList filter; - filter << desc1 << desc2; - dlg.param->setDrive(drive); - dlg.setDirectory(dirname); - dlg.setNameFilters(filter); - QObject::connect(&dlg, SIGNAL(fileSelected(QString)), dlg.param, SLOT(_open_cart(QString))); - QObject::connect(dlg.param, SIGNAL(sig_open_cart(int, QString)), this, SLOT(_open_cart(int, QString))); - dlg.show(); - dlg.exec(); - return; + if(config.initial_cart_dir != NULL) { + dirname = QString::fromUtf8(config.initial_cart_dir); + } else { + char app[PATH_MAX]; + QDir df; + dirname = df.currentPath(); + strncpy(app, dirname.toUtf8().constData(), PATH_MAX); + dirname = get_parent_dir(app); + } + QStringList filter; + filter << desc1 << desc2; + dlg.param->setDrive(drive); + dlg.setDirectory(dirname); + dlg.setNameFilters(filter); + QObject::connect(&dlg, SIGNAL(fileSelected(QString)), dlg.param, SLOT(_open_cart(QString))); + QObject::connect(dlg.param, SIGNAL(sig_open_cart(int, QString)), this, SLOT(_open_cart(int, QString))); + dlg.show(); + dlg.exec(); + return; } #endif void Ui_MainWindow::CreateCartMenu(int drv, int drv_base) { #ifdef USE_CART1 - QString drv_base_name = QString::number(drv_base); - menuCART[drv] = new QMenu(menubar); - menuCART[drv]->setObjectName(QString::fromUtf8("menuCART", -1) + drv_base_name); + QString drv_base_name = QString::number(drv_base); + menuCART[drv] = new QMenu(menubar); + menuCART[drv]->setObjectName(QString::fromUtf8("menuCART", -1) + drv_base_name); #endif } void Ui_MainWindow::CreateCartPulldownMenu(int drv) { #ifdef USE_CART1 - menuCART[drv]->addAction(actionInsert_CART[drv]); - menuCART[drv]->addAction(actionEject_CART[drv]); - menuCART[drv]->addSeparator(); - menuCART_Recent[drv] = new QMenu(menuCART[drv]); - menuCART_Recent[drv]->setObjectName(QString::fromUtf8("Recent_CART", -1) + QString::number(drv)); - menuCART[drv]->addAction(menuCART_Recent[drv]->menuAction()); - { - int ii; - for(ii = 0; ii < MAX_HISTORY; ii++) { - menuCART_Recent[drv]->addAction(action_Recent_List_CART[drv][ii]); - action_Recent_List_CART[drv][ii]->setVisible(true); - } - - } - + menuCART[drv]->addAction(actionInsert_CART[drv]); + menuCART[drv]->addAction(actionEject_CART[drv]); + menuCART[drv]->addSeparator(); + menuCART_Recent[drv] = new QMenu(menuCART[drv]); + menuCART_Recent[drv]->setObjectName(QString::fromUtf8("Recent_CART", -1) + QString::number(drv)); + menuCART[drv]->addAction(menuCART_Recent[drv]->menuAction()); + { + int ii; + for(ii = 0; ii < MAX_HISTORY; ii++) { + menuCART_Recent[drv]->addAction(action_Recent_List_CART[drv][ii]); + action_Recent_List_CART[drv][ii]->setVisible(true); + } + } #endif } void Ui_MainWindow::ConfigCartMenuSub(int drv) { #ifdef USE_CART1 - QString drive_name = QString::number(drv); - //AGAR_DebugLog(AGAR_LOG_DEBUG, "Create: %d\n", drv); + QString drive_name = QString::number(drv); + //AGAR_DebugLog(AGAR_LOG_DEBUG, "Create: %d\n", drv); - actionInsert_CART[drv] = new Action_Control(this); - actionInsert_CART[drv]->setObjectName(QString::fromUtf8("actionInsert_CART") + drive_name); - actionInsert_CART[drv]->binds->setDrive(drv); - actionInsert_CART[drv]->binds->setNumber(0); + actionInsert_CART[drv] = new Action_Control(this); + actionInsert_CART[drv]->setObjectName(QString::fromUtf8("actionInsert_CART") + drive_name); + actionInsert_CART[drv]->binds->setDrive(drv); + actionInsert_CART[drv]->binds->setNumber(0); - actionEject_CART[drv] = new Action_Control(this); - actionEject_CART[drv]->setObjectName(QString::fromUtf8("actionEject_CART") + drive_name); - actionEject_CART[drv]->binds->setDrive(drv); - actionEject_CART[drv]->binds->setNumber(0); + actionEject_CART[drv] = new Action_Control(this); + actionEject_CART[drv]->setObjectName(QString::fromUtf8("actionEject_CART") + drive_name); + actionEject_CART[drv]->binds->setDrive(drv); + actionEject_CART[drv]->binds->setNumber(0); - actionGroup_Opened_CART[drv] = new QActionGroup(this); - actionRecent_Opened_CART[drv] = new Action_Control(this); - actionRecent_Opened_CART[drv]->setObjectName(QString::fromUtf8("actionRecent_Opened_CART") + drive_name); - actionRecent_Opened_CART[drv]->binds->setDrive(drv); - actionRecent_Opened_CART[drv]->binds->setNumber(0); + actionGroup_Opened_CART[drv] = new QActionGroup(this); + actionRecent_Opened_CART[drv] = new Action_Control(this); + actionRecent_Opened_CART[drv]->setObjectName(QString::fromUtf8("actionRecent_Opened_CART") + drive_name); + actionRecent_Opened_CART[drv]->binds->setDrive(drv); + actionRecent_Opened_CART[drv]->binds->setNumber(0); - { - int ii; - actionGroup_Opened_CART[drv] = new QActionGroup(this); - actionGroup_Opened_CART[drv]->setExclusive(true); + { + int ii; + actionGroup_Opened_CART[drv] = new QActionGroup(this); + actionGroup_Opened_CART[drv]->setExclusive(true); - actionRecent_Opened_CART[drv] = new Action_Control(this); - actionRecent_Opened_CART[drv]->setObjectName(QString::fromUtf8("actionSelect_Recent_CART") + drive_name); - actionRecent_Opened_CART[drv]->binds->setDrive(drv); - actionRecent_Opened_CART[drv]->binds->setNumber(0); - for(ii = 0; ii < MAX_HISTORY; ii++) { - action_Recent_List_CART[drv][ii] = new Action_Control(this); - action_Recent_List_CART[drv][ii]->binds->setDrive(drv); - action_Recent_List_CART[drv][ii]->binds->setNumber(ii); - action_Recent_List_CART[drv][ii]->setText(QString::fromUtf8(config.recent_cart_path[drv][ii])); - actionGroup_Opened_CART[drv]->addAction(action_Recent_List_CART[drv][ii]); - connect(action_Recent_List_CART[drv][ii], SIGNAL(triggered()), - action_Recent_List_CART[drv][ii]->binds, SLOT(on_recent_cart())); - connect(action_Recent_List_CART[drv][ii]->binds, SIGNAL(set_recent_cart(int, int)), - this, SLOT(set_recent_cart(int, int))); - } - } - - connect(actionInsert_CART[drv], SIGNAL(triggered()), actionInsert_CART[drv]->binds, SLOT(insert_cart())); - connect(actionInsert_CART[drv]->binds, SIGNAL(sig_insert_cart(int)), this, SLOT(open_cart_dialog(int))); + actionRecent_Opened_CART[drv] = new Action_Control(this); + actionRecent_Opened_CART[drv]->setObjectName(QString::fromUtf8("actionSelect_Recent_CART") + drive_name); + actionRecent_Opened_CART[drv]->binds->setDrive(drv); + actionRecent_Opened_CART[drv]->binds->setNumber(0); + for(ii = 0; ii < MAX_HISTORY; ii++) { + action_Recent_List_CART[drv][ii] = new Action_Control(this); + action_Recent_List_CART[drv][ii]->binds->setDrive(drv); + action_Recent_List_CART[drv][ii]->binds->setNumber(ii); + action_Recent_List_CART[drv][ii]->setText(QString::fromUtf8(config.recent_cart_path[drv][ii])); + actionGroup_Opened_CART[drv]->addAction(action_Recent_List_CART[drv][ii]); + connect(action_Recent_List_CART[drv][ii], SIGNAL(triggered()), + action_Recent_List_CART[drv][ii]->binds, SLOT(on_recent_cart())); + connect(action_Recent_List_CART[drv][ii]->binds, SIGNAL(set_recent_cart(int, int)), + this, SLOT(set_recent_cart(int, int))); + } + } + connect(actionInsert_CART[drv], SIGNAL(triggered()), actionInsert_CART[drv]->binds, SLOT(insert_cart())); + connect(actionInsert_CART[drv]->binds, SIGNAL(sig_insert_cart(int)), this, SLOT(open_cart_dialog(int))); - connect(actionEject_CART[drv], SIGNAL(triggered()), actionEject_CART[drv]->binds, SLOT(eject_cart())); - connect(actionEject_CART[drv]->binds, SIGNAL(sig_eject_cart(int)), this, SLOT(eject_cart(int))); - // Translate Menu + connect(actionEject_CART[drv], SIGNAL(triggered()), actionEject_CART[drv]->binds, SLOT(eject_cart())); + connect(actionEject_CART[drv]->binds, SIGNAL(sig_eject_cart(int)), this, SLOT(eject_cart(int))); + // Translate Menu #endif } void Ui_MainWindow::retranslateCartMenu(int drv, int basedrv) { #ifdef USE_CART1 - QString drive_name = (QApplication::translate("MainWindow", "Cartridge ", 0, QApplication::UnicodeUTF8)); - drive_name += QString::number(basedrv); + QString drive_name = (QApplication::translate("MainWindow", "Cartridge ", 0, QApplication::UnicodeUTF8)); + drive_name += QString::number(basedrv); - if((drv < 0) || (drv >= 8)) return; - actionInsert_CART[drv]->setText(QApplication::translate("MainWindow", "Insert", 0, QApplication::UnicodeUTF8)); - actionEject_CART[drv]->setText(QApplication::translate("MainWindow", "Eject", 0, QApplication::UnicodeUTF8)); + if((drv < 0) || (drv >= 8)) return; + actionInsert_CART[drv]->setText(QApplication::translate("MainWindow", "Insert", 0, QApplication::UnicodeUTF8)); + actionEject_CART[drv]->setText(QApplication::translate("MainWindow", "Eject", 0, QApplication::UnicodeUTF8)); - menuCART_Recent[drv]->setTitle(QApplication::translate("MainWindow", "Recent Opened", 0, QApplication::UnicodeUTF8)); - - menuCART[drv]->setTitle(QApplication::translate("MainWindow", drive_name.toUtf8().constData() , 0, QApplication::UnicodeUTF8)); + menuCART_Recent[drv]->setTitle(QApplication::translate("MainWindow", "Recent Opened", 0, QApplication::UnicodeUTF8)); + menuCART[drv]->setTitle(QApplication::translate("MainWindow", drive_name.toUtf8().constData() , 0, QApplication::UnicodeUTF8)); #endif } void Ui_MainWindow::ConfigCartMenu(void) { - #if defined(USE_CART1) - ConfigCartMenuSub(0); + ConfigCartMenuSub(0); #endif #if defined(USE_CART2) - ConfigCartMenuSub(1); + ConfigCartMenuSub(1); #endif } diff --git a/source/src/qt/gui/menu_cmt.cpp b/source/src/qt/gui/menu_cmt.cpp index f6a5f7c81..be6541ad9 100644 --- a/source/src/qt/gui/menu_cmt.cpp +++ b/source/src/qt/gui/menu_cmt.cpp @@ -14,22 +14,22 @@ void Object_Menu_Control::start_insert_play_cmt(void) { - //AGAR_DebugLog(AGAR_LOG_DEBUG, "%d", play); - emit sig_insert_play_cmt(play); + //AGAR_DebugLog(AGAR_LOG_DEBUG, "%d", play); + emit sig_insert_play_cmt(play); } void Object_Menu_Control::eject_cmt(void) { - emit sig_eject_cmt(); + emit sig_eject_cmt(); } void Object_Menu_Control::on_recent_cmt(){ - emit sig_recent_cmt(s_num); + emit sig_recent_cmt(s_num); } void Object_Menu_Control::do_set_write_protect_cmt(void) { - write_protect = true; - emit sig_set_write_protect_cmt(write_protect); + write_protect = true; + emit sig_set_write_protect_cmt(write_protect); } void Object_Menu_Control::do_unset_write_protect_cmt(void) { - write_protect = false; - emit sig_set_write_protect_cmt(write_protect); + write_protect = false; + emit sig_set_write_protect_cmt(write_protect); } //QT_BEGIN_NAMESPACE @@ -37,56 +37,56 @@ void Object_Menu_Control::do_unset_write_protect_cmt(void) { #if defined(USE_TAPE) void Ui_MainWindow::open_cmt_dialog(bool play) { - QString ext; - QString desc1; - QString desc2; - CSP_DiskDialog dlg; - QString dirname; + QString ext; + QString desc1; + QString desc2; + CSP_DiskDialog dlg; + QString dirname; #if defined(_PC6001) || defined(_PC6001MK2) || defined(_PC6001MK2SR) || defined(_PC6601) || defined(_PC6601SR) - ext = "*.wav *.p6 *.cas"; + ext = "*.wav *.p6 *.cas"; #elif defined(_PC8001SR) || defined(_PC8801MA) || defined(_PC98DO) - ext = play ? "*.cas *.cmt *.n80 *.t88" : "*.cas *.cmt"; + ext = play ? "*.cas *.cmt *.n80 *.t88" : "*.cas *.cmt"; #elif defined(_MZ80A) || defined(_MZ80K) || defined(_MZ1200) || defined(_MZ700) || defined(_MZ800) || defined(_MZ1500) - ext = play ? "*.wav *.cas *.mzt *.m12 *.t77" :"*.wav *.cas"; + ext = play ? "*.wav *.cas *.mzt *.m12 *.t77" :"*.wav *.cas"; #elif defined(_MZ80B) || defined(_MZ2000) || defined(_MZ2200) - ext = play ? "*.wav *.cas *.mzt *.mti *.mtw *.dat" : "*.wav *.cas"; + ext = play ? "*.wav *.cas *.mzt *.mti *.mtw *.dat" : "*.wav *.cas"; #elif defined(_X1) || defined(_X1TWIN) || defined(_X1TURBO) || defined(_X1TURBOZ) - ext = play ? "*.wav *.cas *.tap *.t77" : "*.wav *.cas"; + ext = play ? "*.wav *.cas *.tap *.t77" : "*.wav *.cas"; #elif defined(_FM7) || defined(_FM77) || defined(_FM77AV) || defined(_FM77AV40) - ext = "*.wav *.t77"; + ext = "*.wav *.t77"; #elif defined(TAPE_BINARY_ONLY) - ext = "*.cas *.cmt"; + ext = "*.cas *.cmt"; #else - ext = "*.wav *.cas"; + ext = "*.wav *.cas"; #endif - desc1 = play ? "Data Recorder Tape [Play]" : "Data Recorder Tape [Rec]"; - if(play) { - dlg.setWindowTitle("Open Tape"); - } else { - dlg.setWindowTitle("Record Tape"); - } - desc2 = desc1 + " (" + ext.toLower() + ")"; - desc1 = desc1 + " (" + ext.toUpper() + ")"; - if(config.initial_tape_dir != NULL) { - dirname = QString::fromUtf8(config.initial_tape_dir); - } else { - char app[PATH_MAX]; - QDir df; - dirname = df.currentPath(); - strncpy(app, dirname.toUtf8().constData(), PATH_MAX); - dirname = get_parent_dir(app); - } - QStringList filter; - filter << desc1 << desc2; - dlg.param->setRecMode(play); - dlg.setDirectory(dirname); - dlg.setNameFilters(filter); - QObject::connect(&dlg, SIGNAL(fileSelected(QString)), dlg.param, SLOT(_open_cmt(QString))); - QObject::connect(dlg.param, SIGNAL(do_open_cmt(bool, QString)), this, SLOT(_open_cmt(bool, QString))); - dlg.show(); - dlg.exec(); - return; + desc1 = play ? "Data Recorder Tape [Play]" : "Data Recorder Tape [Rec]"; + if(play) { + dlg.setWindowTitle("Open Tape"); + } else { + dlg.setWindowTitle("Record Tape"); + } + desc2 = desc1 + " (" + ext.toLower() + ")"; + desc1 = desc1 + " (" + ext.toUpper() + ")"; + if(config.initial_tape_dir != NULL) { + dirname = QString::fromUtf8(config.initial_tape_dir); + } else { + char app[PATH_MAX]; + QDir df; + dirname = df.currentPath(); + strncpy(app, dirname.toUtf8().constData(), PATH_MAX); + dirname = get_parent_dir(app); + } + QStringList filter; + filter << desc1 << desc2; + dlg.param->setRecMode(play); + dlg.setDirectory(dirname); + dlg.setNameFilters(filter); + QObject::connect(&dlg, SIGNAL(fileSelected(QString)), dlg.param, SLOT(_open_cmt(QString))); + QObject::connect(dlg.param, SIGNAL(do_open_cmt(bool, QString)), this, SLOT(_open_cmt(bool, QString))); + dlg.show(); + dlg.exec(); + return; } #endif @@ -94,207 +94,205 @@ void Ui_MainWindow::open_cmt_dialog(bool play) void Ui_MainWindow::CreateCMTMenu(void) { #if defined(USE_TAPE) - menuCMT = new QMenu(menubar); - menuCMT->setObjectName(QString::fromUtf8("menuCMT", -1)); - menuWrite_Protection_CMT = new QMenu(menuCMT); - menuWrite_Protection_CMT->setObjectName(QString::fromUtf8("menuWrite_Protection_CMT", -1)); - //CreateCMTPulldownMenu(p); + menuCMT = new QMenu(menubar); + menuCMT->setObjectName(QString::fromUtf8("menuCMT", -1)); + menuWrite_Protection_CMT = new QMenu(menuCMT); + menuWrite_Protection_CMT->setObjectName(QString::fromUtf8("menuWrite_Protection_CMT", -1)); + //CreateCMTPulldownMenu(p); #endif // USE_TAPE } void Ui_MainWindow::CreateCMTPulldownMenu(void) { #if defined(USE_TAPE) - menuCMT->addAction(actionInsert_CMT); - menuCMT->addAction(actionEject_CMT); - menuCMT->addSeparator(); + menuCMT->addAction(actionInsert_CMT); + menuCMT->addAction(actionEject_CMT); + menuCMT->addSeparator(); #ifdef USE_TAPE_BUTTON - menuCMT->addAction(actionPlay_Start); - menuCMT->addAction(actionPlay_Stop); + menuCMT->addAction(actionPlay_Start); + menuCMT->addAction(actionPlay_Stop); #endif - menuCMT->addSeparator(); - menuCMT->addAction(actionWaveShaper); - menuCMT->addAction(actionDirectLoadMZT); - menuCMT->addSeparator(); + menuCMT->addSeparator(); + menuCMT->addAction(actionWaveShaper); + menuCMT->addAction(actionDirectLoadMZT); + menuCMT->addSeparator(); - menuCMT_Recent = new QMenu(menuCMT); - menuCMT_Recent->setObjectName(QString::fromUtf8("Recent_CMT", -1)); - menuCMT->addAction(menuCMT_Recent->menuAction()); - // menuCMT->addAction(actionRecent_Opened_FD[0]); - { - int ii; - for(ii = 0; ii < MAX_HISTORY; ii++) { - menuCMT_Recent->addAction(action_Recent_List_CMT[ii]); - action_Recent_List_CMT[ii]->setVisible(true); - } + menuCMT_Recent = new QMenu(menuCMT); + menuCMT_Recent->setObjectName(QString::fromUtf8("Recent_CMT", -1)); + menuCMT->addAction(menuCMT_Recent->menuAction()); + // menuCMT->addAction(actionRecent_Opened_FD[0]); + { + int ii; + for(ii = 0; ii < MAX_HISTORY; ii++) { + menuCMT_Recent->addAction(action_Recent_List_CMT[ii]); + action_Recent_List_CMT[ii]->setVisible(true); + } - } - menuCMT->addSeparator(); - menuCMT->addAction(menuWrite_Protection_CMT->menuAction()); - menuWrite_Protection_CMT->addAction(actionProtection_ON_CMT); - menuWrite_Protection_CMT->addAction(actionProtection_OFF_CMT); + } + menuCMT->addSeparator(); + menuCMT->addAction(menuWrite_Protection_CMT->menuAction()); + menuWrite_Protection_CMT->addAction(actionProtection_ON_CMT); + menuWrite_Protection_CMT->addAction(actionProtection_OFF_CMT); #endif // USE_TAPE } void Ui_MainWindow::ConfigCMTMenuSub(void) { #if defined(USE_TAPE) - actionInsert_CMT = new Action_Control(this); - actionInsert_CMT->setObjectName(QString::fromUtf8("actionInsert_CMT")); - actionInsert_CMT->binds->setPlay(true); - actionInsert_CMT->binds->setNumber(0); + actionInsert_CMT = new Action_Control(this); + actionInsert_CMT->setObjectName(QString::fromUtf8("actionInsert_CMT")); + actionInsert_CMT->binds->setPlay(true); + actionInsert_CMT->binds->setNumber(0); - actionEject_CMT = new Action_Control(this); - actionEject_CMT->setObjectName(QString::fromUtf8("actionEject_CMT")); - actionEject_CMT->binds->setPlay(true); + actionEject_CMT = new Action_Control(this); + actionEject_CMT->setObjectName(QString::fromUtf8("actionEject_CMT")); + actionEject_CMT->binds->setPlay(true); + actionWaveShaper = new Action_Control(this); + actionWaveShaper->setObjectName(QString::fromUtf8("actionWaveShaper")); + actionWaveShaper->setCheckable(true); + if(config.wave_shaper == 0) { + actionWaveShaper->setChecked(false); + } else { + actionWaveShaper->setChecked(true); + } + connect(actionWaveShaper, SIGNAL(toggled(bool)), + this, SLOT(set_wave_shaper(bool))); - actionWaveShaper = new Action_Control(this); - actionWaveShaper->setObjectName(QString::fromUtf8("actionWaveShaper")); - actionWaveShaper->setCheckable(true); - if(config.wave_shaper == 0) { - actionWaveShaper->setChecked(false); - } else { - actionWaveShaper->setChecked(true); - } - connect(actionWaveShaper, SIGNAL(toggled(bool)), - this, SLOT(set_wave_shaper(bool))); - - actionDirectLoadMZT = new Action_Control(this); - actionDirectLoadMZT->setObjectName(QString::fromUtf8("actionDirectLoadMZT")); - actionDirectLoadMZT->setCheckable(true); - if(config.direct_load_mzt == 0) { - actionDirectLoadMZT->setChecked(false); - } else { - actionDirectLoadMZT->setChecked(true); - } - connect(actionDirectLoadMZT, SIGNAL(toggled(bool)), - this, SLOT(set_direct_load_from_mzt(bool))); + actionDirectLoadMZT = new Action_Control(this); + actionDirectLoadMZT->setObjectName(QString::fromUtf8("actionDirectLoadMZT")); + actionDirectLoadMZT->setCheckable(true); + if(config.direct_load_mzt == 0) { + actionDirectLoadMZT->setChecked(false); + } else { + actionDirectLoadMZT->setChecked(true); + } + connect(actionDirectLoadMZT, SIGNAL(toggled(bool)), + this, SLOT(set_direct_load_from_mzt(bool))); #ifdef USE_TAPE_BUTTON - actionGroup_PlayTape = new QActionGroup(this); - actionGroup_PlayTape->setExclusive(true); - actionGroup_PlayTape->setObjectName(QString::fromUtf8("actionGroup_PLayTape")); + actionGroup_PlayTape = new QActionGroup(this); + actionGroup_PlayTape->setExclusive(true); + actionGroup_PlayTape->setObjectName(QString::fromUtf8("actionGroup_PLayTape")); - actionPlay_Start = new Action_Control(this); - actionPlay_Start->setObjectName(QString::fromUtf8("actionPlay_Start")); - actionGroup_PlayTape->addAction(actionPlay_Start); - actionPlay_Start->setCheckable(true); - actionPlay_Start->setChecked(false); - connect(actionPlay_Start, SIGNAL(triggered()), - this, SLOT(do_push_play_tape())); + actionPlay_Start = new Action_Control(this); + actionPlay_Start->setObjectName(QString::fromUtf8("actionPlay_Start")); + actionGroup_PlayTape->addAction(actionPlay_Start); + actionPlay_Start->setCheckable(true); + actionPlay_Start->setChecked(false); + connect(actionPlay_Start, SIGNAL(triggered()), + this, SLOT(do_push_play_tape())); - actionPlay_Stop = new Action_Control(this); - actionPlay_Stop->setObjectName(QString::fromUtf8("actionPlay_Stop")); - actionPlay_Stop->binds->setPlay(true); - actionGroup_PlayTape->addAction(actionPlay_Stop); - actionPlay_Stop->setCheckable(true); - actionPlay_Stop->setChecked(true); - connect(actionPlay_Stop, SIGNAL(triggered()), - this, SLOT(do_push_stop_tape())); + actionPlay_Stop = new Action_Control(this); + actionPlay_Stop->setObjectName(QString::fromUtf8("actionPlay_Stop")); + actionPlay_Stop->binds->setPlay(true); + actionGroup_PlayTape->addAction(actionPlay_Stop); + actionPlay_Stop->setCheckable(true); + actionPlay_Stop->setChecked(true); + connect(actionPlay_Stop, SIGNAL(triggered()), + this, SLOT(do_push_stop_tape())); #endif - actionRecording = new Action_Control(this); - actionRecording->setObjectName(QString::fromUtf8("actionRecording")); - actionRecording->binds->setPlay(false); - actionRecording->binds->setNumber(0); - - actionGroup_Opened_CMT = new QActionGroup(this); - actionRecent_Opened_CMT = new Action_Control(this); - actionRecent_Opened_CMT->setObjectName(QString::fromUtf8("actionRecent_Opened_CMT")); - actionRecent_Opened_CMT->binds->setPlay(true); - - { - int ii; - actionGroup_Opened_CMT = new QActionGroup(this); - actionGroup_Opened_CMT->setExclusive(true); - - actionRecent_Opened_CMT = new Action_Control(this); - actionRecent_Opened_CMT->setObjectName(QString::fromUtf8("actionSelect_Recent_CMT")); - actionRecent_Opened_CMT->binds->setPlay(true); // For safety - for(ii = 0; ii < MAX_HISTORY; ii++) { - action_Recent_List_CMT[ii] = new Action_Control(this); - action_Recent_List_CMT[ii]->binds->setPlay(true); - action_Recent_List_CMT[ii]->binds->setNumber(ii); - action_Recent_List_CMT[ii]->setText(QString::fromUtf8(config.recent_tape_path[ii])); - actionGroup_Opened_CMT->addAction(action_Recent_List_CMT[ii]); - connect(action_Recent_List_CMT[ii], SIGNAL(triggered()), - action_Recent_List_CMT[ii]->binds, SLOT(on_recent_cmt())); - connect(action_Recent_List_CMT[ii]->binds, SIGNAL(sig_recent_cmt(int)), - this, SLOT(set_recent_cmt(int))); - } - } - - { - int ii; - actionProtection_ON_CMT = new Action_Control(this); - actionProtection_ON_CMT->setObjectName(QString::fromUtf8("actionProtection_ON_CMT")); - actionProtection_ON_CMT->setCheckable(true); - actionProtection_ON_CMT->setChecked(true); - actionProtection_OFF_CMT = new Action_Control(this); - actionProtection_OFF_CMT->setObjectName(QString::fromUtf8("actionProtection_OFF_CMT")); - actionProtection_OFF_CMT->setCheckable(true); - actionProtection_OFF_CMT->setChecked(false); - connect(actionProtection_OFF_CMT, SIGNAL(triggered()), actionProtection_OFF_CMT->binds, SLOT(do_unset_write_protect_cmt())); - connect(actionProtection_OFF_CMT->binds, SIGNAL(sig_set_write_protect_cmt(bool)), this, SLOT(do_write_protect_cmt(bool))); + actionRecording = new Action_Control(this); + actionRecording->setObjectName(QString::fromUtf8("actionRecording")); + actionRecording->binds->setPlay(false); + actionRecording->binds->setNumber(0); + + actionGroup_Opened_CMT = new QActionGroup(this); + actionRecent_Opened_CMT = new Action_Control(this); + actionRecent_Opened_CMT->setObjectName(QString::fromUtf8("actionRecent_Opened_CMT")); + actionRecent_Opened_CMT->binds->setPlay(true); + { + int ii; + actionGroup_Opened_CMT = new QActionGroup(this); + actionGroup_Opened_CMT->setExclusive(true); - connect(actionProtection_ON_CMT, SIGNAL(triggered()), actionProtection_ON_CMT->binds, SLOT(do_set_write_protect_cmt())); - connect(actionProtection_ON_CMT->binds, SIGNAL(sig_set_write_protect_cmt(bool)), this, SLOT(do_write_protect_cmt(bool))); + actionRecent_Opened_CMT = new Action_Control(this); + actionRecent_Opened_CMT->setObjectName(QString::fromUtf8("actionSelect_Recent_CMT")); + actionRecent_Opened_CMT->binds->setPlay(true); // For safety + for(ii = 0; ii < MAX_HISTORY; ii++) { + action_Recent_List_CMT[ii] = new Action_Control(this); + action_Recent_List_CMT[ii]->binds->setPlay(true); + action_Recent_List_CMT[ii]->binds->setNumber(ii); + action_Recent_List_CMT[ii]->setText(QString::fromUtf8(config.recent_tape_path[ii])); + actionGroup_Opened_CMT->addAction(action_Recent_List_CMT[ii]); + connect(action_Recent_List_CMT[ii], SIGNAL(triggered()), + action_Recent_List_CMT[ii]->binds, SLOT(on_recent_cmt())); + connect(action_Recent_List_CMT[ii]->binds, SIGNAL(sig_recent_cmt(int)), + this, SLOT(set_recent_cmt(int))); + } + } + { + int ii; + actionProtection_ON_CMT = new Action_Control(this); + actionProtection_ON_CMT->setObjectName(QString::fromUtf8("actionProtection_ON_CMT")); + actionProtection_ON_CMT->setCheckable(true); + actionProtection_ON_CMT->setChecked(true); + actionProtection_OFF_CMT = new Action_Control(this); + actionProtection_OFF_CMT->setObjectName(QString::fromUtf8("actionProtection_OFF_CMT")); + actionProtection_OFF_CMT->setCheckable(true); + actionProtection_OFF_CMT->setChecked(false); + connect(actionProtection_OFF_CMT, SIGNAL(triggered()), + actionProtection_OFF_CMT->binds, SLOT(do_unset_write_protect_cmt())); + connect(actionProtection_OFF_CMT->binds, SIGNAL(sig_set_write_protect_cmt(bool)), + this, SLOT(do_write_protect_cmt(bool))); - actionGroup_Protect_CMT = new QActionGroup(this); - //actionGroup_Protect_CMT->setExclusive(true); - actionGroup_Protect_CMT->addAction(actionProtection_ON_CMT); - actionGroup_Protect_CMT->addAction(actionProtection_OFF_CMT); - actionProtection_ON_CMT->setActionGroup(actionGroup_Protect_CMT); - actionProtection_OFF_CMT->setActionGroup(actionGroup_Protect_CMT); - - } - - connect(actionRecording, SIGNAL(triggered()), actionRecording->binds, SLOT(start_insert_play_cmt())); - connect(actionRecording->binds, SIGNAL(sig_insert_play_cmt(bool)), this, SLOT(open_cmt_dialog(bool))); - connect(actionInsert_CMT, SIGNAL(triggered()), actionInsert_CMT->binds, SLOT(start_insert_play_cmt())); - connect(actionInsert_CMT->binds, SIGNAL(sig_insert_play_cmt(bool)), this, SLOT(open_cmt_dialog(bool))); - connect(actionEject_CMT, SIGNAL(triggered()), this, SLOT(eject_cmt())); - // Translate Menu -#endif // USE_TAPE + connect(actionProtection_ON_CMT, SIGNAL(triggered()), + actionProtection_ON_CMT->binds, SLOT(do_set_write_protect_cmt())); + connect(actionProtection_ON_CMT->binds, SIGNAL(sig_set_write_protect_cmt(bool)), + this, SLOT(do_write_protect_cmt(bool))); + actionGroup_Protect_CMT = new QActionGroup(this); + //actionGroup_Protect_CMT->setExclusive(true); + actionGroup_Protect_CMT->addAction(actionProtection_ON_CMT); + actionGroup_Protect_CMT->addAction(actionProtection_OFF_CMT); + actionProtection_ON_CMT->setActionGroup(actionGroup_Protect_CMT); + actionProtection_OFF_CMT->setActionGroup(actionGroup_Protect_CMT); + } + connect(actionRecording, SIGNAL(triggered()), + actionRecording->binds, SLOT(start_insert_play_cmt())); + connect(actionRecording->binds, SIGNAL(sig_insert_play_cmt(bool)), + this, SLOT(open_cmt_dialog(bool))); + connect(actionInsert_CMT, SIGNAL(triggered()), + actionInsert_CMT->binds, SLOT(start_insert_play_cmt())); + connect(actionInsert_CMT->binds, SIGNAL(sig_insert_play_cmt(bool)), + this, SLOT(open_cmt_dialog(bool))); + connect(actionEject_CMT, SIGNAL(triggered()), + this, SLOT(eject_cmt())); + // Translate Menu +#endif // USE_TAPE } void Ui_MainWindow::retranslateCMTMenu(void) { #ifdef USE_TAPE - actionInsert_CMT->setText(QApplication::translate("MainWindow", "Insert CMT", 0, QApplication::UnicodeUTF8)); - actionEject_CMT->setText(QApplication::translate("MainWindow", "Eject CMT", 0, QApplication::UnicodeUTF8)); + actionInsert_CMT->setText(QApplication::translate("MainWindow", "Insert CMT", 0, QApplication::UnicodeUTF8)); + actionEject_CMT->setText(QApplication::translate("MainWindow", "Eject CMT", 0, QApplication::UnicodeUTF8)); - actionWaveShaper->setText(QApplication::translate("MainWindow", "Enable Wave Shaper", 0, QApplication::UnicodeUTF8)); - actionDirectLoadMZT->setText(QApplication::translate("MainWindow", "Direct load from MZT", 0, QApplication::UnicodeUTF8)); + actionWaveShaper->setText(QApplication::translate("MainWindow", "Enable Wave Shaper", 0, QApplication::UnicodeUTF8)); + actionDirectLoadMZT->setText(QApplication::translate("MainWindow", "Direct load from MZT", 0, QApplication::UnicodeUTF8)); - menuCMT_Recent->setTitle(QApplication::translate("MainWindow", "Recent Opened", 0, QApplication::UnicodeUTF8)); + menuCMT_Recent->setTitle(QApplication::translate("MainWindow", "Recent Opened", 0, QApplication::UnicodeUTF8)); - actionProtection_ON_CMT->setText(QApplication::translate("MainWindow", "Protection ON", 0, QApplication::UnicodeUTF8)); - actionProtection_OFF_CMT->setText(QApplication::translate("MainWindow", "Protection OFF", 0, QApplication::UnicodeUTF8)); + actionProtection_ON_CMT->setText(QApplication::translate("MainWindow", "Protection ON", 0, QApplication::UnicodeUTF8)); + actionProtection_OFF_CMT->setText(QApplication::translate("MainWindow", "Protection OFF", 0, QApplication::UnicodeUTF8)); - menuCMT->setTitle(QApplication::translate("MainWindow", "Casette tape" , 0, QApplication::UnicodeUTF8)); - menuWrite_Protection_CMT->setTitle(QApplication::translate("MainWindow", "Write Protection", 0, QApplication::UnicodeUTF8)); + menuCMT->setTitle(QApplication::translate("MainWindow", "Casette tape" , 0, QApplication::UnicodeUTF8)); + menuWrite_Protection_CMT->setTitle(QApplication::translate("MainWindow", "Write Protection", 0, QApplication::UnicodeUTF8)); #ifdef USE_TAPE_BUTTON - actionPlay_Stop->setText(QApplication::translate("MainWindow", "Play Stop", 0, QApplication::UnicodeUTF8)); - actionPlay_Start->setText(QApplication::translate("MainWindow", "Play Start", 0, QApplication::UnicodeUTF8)); + actionPlay_Stop->setText(QApplication::translate("MainWindow", "Play Stop", 0, QApplication::UnicodeUTF8)); + actionPlay_Start->setText(QApplication::translate("MainWindow", "Play Start", 0, QApplication::UnicodeUTF8)); #endif - actionRecording->setText(QApplication::translate("MainWindow", "Recording", 0, QApplication::UnicodeUTF8)); + actionRecording->setText(QApplication::translate("MainWindow", "Recording", 0, QApplication::UnicodeUTF8)); #endif } - - - void Ui_MainWindow::ConfigCMTMenu(void) { - #if defined(USE_TAPE) - write_protect = true; - ConfigCMTMenuSub(); + write_protect = true; + ConfigCMTMenuSub(); #endif - } //QT_END_NAMESPACE diff --git a/source/src/qt/gui/menu_control.cpp b/source/src/qt/gui/menu_control.cpp index f4b1f410d..339d24c6f 100644 --- a/source/src/qt/gui/menu_control.cpp +++ b/source/src/qt/gui/menu_control.cpp @@ -10,104 +10,100 @@ QT_BEGIN_NAMESPACE void Object_Menu_Control::set_boot_mode(void) { - emit on_boot_mode(bindValue); + emit on_boot_mode(bindValue); } void Object_Menu_Control::set_cpu_type(void) { - emit on_cpu_type(bindValue); + emit on_cpu_type(bindValue); } void Object_Menu_Control::set_cpupower(void) { - emit on_cpu_power(bindValue); + emit on_cpu_power(bindValue); } void Object_Menu_Control::open_debugger(void) { - emit on_open_debugger(bindValue); + emit on_open_debugger(bindValue); } void Ui_MainWindow::ConfigCpuSpeed(void) { - actionSpeed_x1 = new Action_Control(this); - actionSpeed_x1->setObjectName(QString::fromUtf8("actionSpeed_x1")); - actionSpeed_x1->setCheckable(true); - actionSpeed_x1->setChecked(true); - actionSpeed_x1->binds->setValue1(0); - connect(actionSpeed_x1, SIGNAL(triggered()), actionSpeed_x1->binds, SLOT(set_cpupower())); // OK? - connect(actionSpeed_x1->binds, SIGNAL(on_cpu_power(int)), this, SLOT(set_cpu_power(int))); // OK? + actionSpeed_x1 = new Action_Control(this); + actionSpeed_x1->setObjectName(QString::fromUtf8("actionSpeed_x1")); + actionSpeed_x1->setCheckable(true); + actionSpeed_x1->setChecked(true); + actionSpeed_x1->binds->setValue1(0); + connect(actionSpeed_x1, SIGNAL(triggered()), actionSpeed_x1->binds, SLOT(set_cpupower())); // OK? + connect(actionSpeed_x1->binds, SIGNAL(on_cpu_power(int)), this, SLOT(set_cpu_power(int))); // OK? - actionSpeed_x2 = new Action_Control(this); - actionSpeed_x2->setObjectName(QString::fromUtf8("actionSpeed_x2")); - actionSpeed_x2->setCheckable(true); - actionSpeed_x2->binds->setValue1(1); - connect(actionSpeed_x2, SIGNAL(triggered()), actionSpeed_x2->binds, SLOT(set_cpupower())); // OK? - connect(actionSpeed_x2->binds, SIGNAL(on_cpu_power(int)), this, SLOT(set_cpu_power(int))); // OK? + actionSpeed_x2 = new Action_Control(this); + actionSpeed_x2->setObjectName(QString::fromUtf8("actionSpeed_x2")); + actionSpeed_x2->setCheckable(true); + actionSpeed_x2->binds->setValue1(1); + connect(actionSpeed_x2, SIGNAL(triggered()), actionSpeed_x2->binds, SLOT(set_cpupower())); // OK? + connect(actionSpeed_x2->binds, SIGNAL(on_cpu_power(int)), this, SLOT(set_cpu_power(int))); // OK? - actionSpeed_x4 = new Action_Control(this); - actionSpeed_x4->setObjectName(QString::fromUtf8("actionSpeed_x4")); - actionSpeed_x4->setCheckable(true); - actionSpeed_x4->binds->setValue1(2); - connect(actionSpeed_x4, SIGNAL(triggered()), actionSpeed_x4->binds, SLOT(set_cpupower())); // OK? - connect(actionSpeed_x4->binds, SIGNAL(on_cpu_power(int)), this, SLOT(set_cpu_power(int))); // OK? + actionSpeed_x4 = new Action_Control(this); + actionSpeed_x4->setObjectName(QString::fromUtf8("actionSpeed_x4")); + actionSpeed_x4->setCheckable(true); + actionSpeed_x4->binds->setValue1(2); + connect(actionSpeed_x4, SIGNAL(triggered()), actionSpeed_x4->binds, SLOT(set_cpupower())); // OK? + connect(actionSpeed_x4->binds, SIGNAL(on_cpu_power(int)), this, SLOT(set_cpu_power(int))); // OK? - actionSpeed_x8 = new Action_Control(this); - actionSpeed_x8->setObjectName(QString::fromUtf8("actionSpeed_x8")); - actionSpeed_x8->setCheckable(true); - actionSpeed_x8->binds->setValue1(3); - connect(actionSpeed_x8, SIGNAL(triggered()), actionSpeed_x8->binds, SLOT(set_cpupower())); // OK? - connect(actionSpeed_x8->binds, SIGNAL(on_cpu_power(int)), this, SLOT(set_cpu_power(int))); // OK? - + actionSpeed_x8 = new Action_Control(this); + actionSpeed_x8->setObjectName(QString::fromUtf8("actionSpeed_x8")); + actionSpeed_x8->setCheckable(true); + actionSpeed_x8->binds->setValue1(3); + connect(actionSpeed_x8, SIGNAL(triggered()), actionSpeed_x8->binds, SLOT(set_cpupower())); // OK? + connect(actionSpeed_x8->binds, SIGNAL(on_cpu_power(int)), this, SLOT(set_cpu_power(int))); // OK? - actionSpeed_x16 = new Action_Control(this); - actionSpeed_x16->setObjectName(QString::fromUtf8("actionSpeed_x16")); - actionSpeed_x16->setCheckable(true); - actionSpeed_x16->binds->setValue1(4); - connect(actionSpeed_x16, SIGNAL(triggered()), actionSpeed_x16->binds, SLOT(set_cpupower())); // OK? - connect(actionSpeed_x16->binds, SIGNAL(on_cpu_power(int)), this, SLOT(set_cpu_power(int))); // OK? + actionSpeed_x16 = new Action_Control(this); + actionSpeed_x16->setObjectName(QString::fromUtf8("actionSpeed_x16")); + actionSpeed_x16->setCheckable(true); + actionSpeed_x16->binds->setValue1(4); + connect(actionSpeed_x16, SIGNAL(triggered()), actionSpeed_x16->binds, SLOT(set_cpupower())); // OK? + connect(actionSpeed_x16->binds, SIGNAL(on_cpu_power(int)), this, SLOT(set_cpu_power(int))); // OK? - actionGroup_CpuSpeed = new QActionGroup(this); - actionGroup_CpuSpeed->setExclusive(true); - actionGroup_CpuSpeed->addAction(actionSpeed_x1); - actionGroup_CpuSpeed->addAction(actionSpeed_x2); - actionGroup_CpuSpeed->addAction(actionSpeed_x4); - actionGroup_CpuSpeed->addAction(actionSpeed_x8); - actionGroup_CpuSpeed->addAction(actionSpeed_x16); - + actionGroup_CpuSpeed = new QActionGroup(this); + actionGroup_CpuSpeed->setExclusive(true); + actionGroup_CpuSpeed->addAction(actionSpeed_x1); + actionGroup_CpuSpeed->addAction(actionSpeed_x2); + actionGroup_CpuSpeed->addAction(actionSpeed_x4); + actionGroup_CpuSpeed->addAction(actionSpeed_x8); + actionGroup_CpuSpeed->addAction(actionSpeed_x16); } #ifdef USE_BOOT_MODE void Ui_MainWindow::do_change_boot_mode(int mode) { - if((mode < 0) || (mode >= 8)) return; - - if(emu) { - emu->LockVM(); - config.boot_mode = mode; - emu->update_config(); - emu->UnlockVM(); - } - + if((mode < 0) || (mode >= 8)) return; + if(emu) { + emu->LockVM(); + config.boot_mode = mode; + emu->update_config(); + emu->UnlockVM(); + } } + void Ui_MainWindow::ConfigCPUBootMode(int num) { - int i; - QString tmps; - if(num <= 0) return; - if(num >= 8) num = 7; - - - actionGroup_BootMode = new QActionGroup(this); - actionGroup_BootMode->setExclusive(true); - for(i = 0; i < num; i++) { - actionBootMode[i] = new Action_Control(this); - tmps = tmps.setNum(i); - tmps = QString::fromUtf8("actionBootMode_") + tmps; - actionBootMode[i]->setObjectName(tmps); - actionBootMode[i]->setCheckable(true); - if(i == config.boot_mode) actionBootMode[i]->setChecked(true); - actionBootMode[i]->binds->setValue1(i); - menuBootMode->addAction(actionBootMode[i]); - actionGroup_BootMode->addAction(actionBootMode[i]); - connect(actionBootMode[i], SIGNAL(triggered()), actionBootMode[i]->binds, SLOT(set_boot_mode())); // OK? - connect(actionBootMode[i]->binds, SIGNAL(on_boot_mode(int)), this, SLOT(do_change_boot_mode(int))); // OK? - } + int i; + QString tmps; + if(num <= 0) return; + if(num >= 8) num = 7; + + actionGroup_BootMode = new QActionGroup(this); + actionGroup_BootMode->setExclusive(true); + for(i = 0; i < num; i++) { + actionBootMode[i] = new Action_Control(this); + tmps = tmps.setNum(i); + tmps = QString::fromUtf8("actionBootMode_") + tmps; + actionBootMode[i]->setObjectName(tmps); + actionBootMode[i]->setCheckable(true); + if(i == config.boot_mode) actionBootMode[i]->setChecked(true); + actionBootMode[i]->binds->setValue1(i); + menuBootMode->addAction(actionBootMode[i]); + actionGroup_BootMode->addAction(actionBootMode[i]); + connect(actionBootMode[i], SIGNAL(triggered()), actionBootMode[i]->binds, SLOT(set_boot_mode())); // OK? + connect(actionBootMode[i]->binds, SIGNAL(on_boot_mode(int)), this, SLOT(do_change_boot_mode(int))); // OK? + } } #endif @@ -153,169 +149,174 @@ void Ui_MainWindow::ConfigCPUTypes(int num) void Ui_MainWindow::ConfigControlMenu(void) { - actionReset = new Action_Control(this); - actionReset->setObjectName(QString::fromUtf8("actionReset")); - connect(actionReset, SIGNAL(triggered()), this, SLOT(OnReset())); // OK? + actionReset = new Action_Control(this); + actionReset->setObjectName(QString::fromUtf8("actionReset")); + connect(actionReset, SIGNAL(triggered()), + this, SLOT(OnReset())); // OK? #ifdef USE_SPECIAL_RESET - actionSpecial_Reset = new Action_Control(this); - actionSpecial_Reset->setObjectName(QString::fromUtf8("actionSpecial_Reset")); - connect(actionSpecial_Reset, SIGNAL(triggered()), this, SLOT(OnSpecialReset())); // OK? + actionSpecial_Reset = new Action_Control(this); + actionSpecial_Reset->setObjectName(QString::fromUtf8("actionSpecial_Reset")); + connect(actionSpecial_Reset, SIGNAL(triggered()), + this, SLOT(OnSpecialReset())); // OK? #endif - - actionExit_Emulator = new Action_Control(this); - actionExit_Emulator->setObjectName(QString::fromUtf8("actionExit_Emulator")); - connect(actionExit_Emulator, SIGNAL(triggered()), this, SLOT(on_actionExit_triggered())); // OnGuiExit()? -// connect(actionExit_Emulator, SIGNAL(triggered()), hRunEmu, SLOT(doExit())); // OnGuiExit()? + actionExit_Emulator = new Action_Control(this); + actionExit_Emulator->setObjectName(QString::fromUtf8("actionExit_Emulator")); + connect(actionExit_Emulator, SIGNAL(triggered()), + this, SLOT(on_actionExit_triggered())); // OnGuiExit()? + // connect(actionExit_Emulator, SIGNAL(triggered()), hRunEmu, SLOT(doExit())); // OnGuiExit()? - actionPaste_from_Clipboard = new Action_Control(this); - actionPaste_from_Clipboard->setObjectName(QString::fromUtf8("actionPaste_from_Clipboard")); - connect(actionPaste_from_Clipboard, SIGNAL(triggered()), - this, SLOT(OnStartAutoKey())); // OK? + actionPaste_from_Clipboard = new Action_Control(this); + actionPaste_from_Clipboard->setObjectName(QString::fromUtf8("actionPaste_from_Clipboard")); + connect(actionPaste_from_Clipboard, SIGNAL(triggered()), + this, SLOT(OnStartAutoKey())); // OK? - actionStop_Pasting = new Action_Control(this); - actionStop_Pasting->setObjectName(QString::fromUtf8("actionStop_Pasting")); - connect(actionStop_Pasting, SIGNAL(triggered()), - this, SLOT(OnStopAutoKey())); // OK? + actionStop_Pasting = new Action_Control(this); + actionStop_Pasting->setObjectName(QString::fromUtf8("actionStop_Pasting")); + connect(actionStop_Pasting, SIGNAL(triggered()), + this, SLOT(OnStopAutoKey())); // OK? #ifdef USE_STATE - actionSave_State = new Action_Control(this); - actionSave_State->setObjectName(QString::fromUtf8("actionSave_State")); - connect(actionSave_State, SIGNAL(triggered()), - this, SLOT(OnSaveState())); // OK? + actionSave_State = new Action_Control(this); + actionSave_State->setObjectName(QString::fromUtf8("actionSave_State")); + connect(actionSave_State, SIGNAL(triggered()), + this, SLOT(OnSaveState())); // OK? - actionLoad_State = new Action_Control(this); - actionLoad_State->setObjectName(QString::fromUtf8("actionLoad_State")); - connect(actionLoad_State, SIGNAL(triggered()), - this, SLOT(OnLoadState())); // OK? + actionLoad_State = new Action_Control(this); + actionLoad_State->setObjectName(QString::fromUtf8("actionLoad_State")); + connect(actionLoad_State, SIGNAL(triggered()), + this, SLOT(OnLoadState())); // OK? #endif // USE_STATE #ifdef USE_DEBUGGER - actionDebugger_1 = new Action_Control(this); - actionDebugger_1->setObjectName(QString::fromUtf8("actionDebugger_1")); - actionDebugger_1->binds->setValue1(0); - connect(actionDebugger_1, SIGNAL(triggered()), actionDebugger_1->binds, SLOT(open_debugger())); // OK? - connect(actionDebugger_1->binds, SIGNAL(on_open_debugger(int)), this, SLOT(OnOpenDebugger(int))); // OK? + actionDebugger_1 = new Action_Control(this); + actionDebugger_1->setObjectName(QString::fromUtf8("actionDebugger_1")); + actionDebugger_1->binds->setValue1(0); + connect(actionDebugger_1, SIGNAL(triggered()), + actionDebugger_1->binds, SLOT(open_debugger())); // OK? + connect(actionDebugger_1->binds, SIGNAL(on_open_debugger(int)), + this, SLOT(OnOpenDebugger(int))); // OK? - actionDebugger_2 = new Action_Control(this); - actionDebugger_2->setObjectName(QString::fromUtf8("actionDebugger_2")); - actionDebugger_2->binds->setValue1(1); - connect(actionDebugger_2, SIGNAL(triggered()), actionDebugger_2->binds, SLOT(open_debugger())); // OK? - connect(actionDebugger_2->binds, SIGNAL(on_open_debugger(int)), this, SLOT(OnOpenDebugger(int))); // OK? + actionDebugger_2 = new Action_Control(this); + actionDebugger_2->setObjectName(QString::fromUtf8("actionDebugger_2")); + actionDebugger_2->binds->setValue1(1); + connect(actionDebugger_2, SIGNAL(triggered()), + actionDebugger_2->binds, SLOT(open_debugger())); // OK? + connect(actionDebugger_2->binds, SIGNAL(on_open_debugger(int)), + this, SLOT(OnOpenDebugger(int))); // OK? - actionDebugger_3 = new Action_Control(this); - actionDebugger_3->binds->setValue1(2); - actionDebugger_3->setObjectName(QString::fromUtf8("actionDebugger_3")); - connect(actionDebugger_3, SIGNAL(triggered()), actionDebugger_3->binds, SLOT(open_debugger())); // OK? - connect(actionDebugger_3->binds, SIGNAL(on_open_debugger(int)), this, SLOT(OnOpenDebugger(int))); // OK? + actionDebugger_3 = new Action_Control(this); + actionDebugger_3->binds->setValue1(2); + actionDebugger_3->setObjectName(QString::fromUtf8("actionDebugger_3")); + connect(actionDebugger_3, SIGNAL(triggered()), + actionDebugger_3->binds, SLOT(open_debugger())); // OK? + connect(actionDebugger_3->binds, SIGNAL(on_open_debugger(int)), + this, SLOT(OnOpenDebugger(int))); // OK? - actionClose_Debuggers = new Action_Control(this); - actionClose_Debuggers->setObjectName(QString::fromUtf8("actionClose_Debuggers")); - connect(actionClose_Debuggers, SIGNAL(triggered()), - this, SLOT(OnCloseDebugger())); // OK? + actionClose_Debuggers = new Action_Control(this); + actionClose_Debuggers->setObjectName(QString::fromUtf8("actionClose_Debuggers")); + connect(actionClose_Debuggers, SIGNAL(triggered()), + this, SLOT(OnCloseDebugger())); // OK? #endif // USE_DEBUGGER - ConfigCpuSpeed(); + ConfigCpuSpeed(); } void Ui_MainWindow::connectActions_ControlMenu(void) { - - menuControl->addAction(actionReset); + menuControl->addAction(actionReset); #ifdef USE_SPECIAL_RESET - menuControl->addAction(actionSpecial_Reset); + menuControl->addAction(actionSpecial_Reset); #endif - menuControl->addSeparator(); + menuControl->addSeparator(); #ifdef USE_CPU_TYPE -// menuControl->addAction(menuCpuType->menuAction()); -// menuControl->addSeparator(); + // menuControl->addAction(menuCpuType->menuAction()); + // menuControl->addSeparator(); #endif #ifdef USE_BOOT_MODE -// menuControl->addAction(menuBootMode->menuAction()); -// menuControl->addSeparator(); + // menuControl->addAction(menuBootMode->menuAction()); + // menuControl->addSeparator(); #endif - menuControl->addAction(menuCpu_Speed->menuAction()); - menuControl->addSeparator(); - menuControl->addAction(menuCopy_Paste->menuAction()); - menuControl->addSeparator(); - menuControl->addAction(menuState->menuAction()); + menuControl->addAction(menuCpu_Speed->menuAction()); + menuControl->addSeparator(); + menuControl->addAction(menuCopy_Paste->menuAction()); + menuControl->addSeparator(); + menuControl->addAction(menuState->menuAction()); #ifdef USE_DEBUGGER - menuControl->addAction(menuDebugger->menuAction()); + menuControl->addAction(menuDebugger->menuAction()); #endif - menuControl->addSeparator(); - menuControl->addAction(actionExit_Emulator); + menuControl->addSeparator(); + menuControl->addAction(actionExit_Emulator); #ifdef USE_STATE - menuState->addAction(actionSave_State); - menuState->addSeparator(); - menuState->addAction(actionLoad_State); + menuState->addAction(actionSave_State); + menuState->addSeparator(); + menuState->addAction(actionLoad_State); #endif - menuCopy_Paste->addAction(actionPaste_from_Clipboard); - menuCopy_Paste->addAction(actionStop_Pasting); - menuCpu_Speed->addAction(actionSpeed_x1); - menuCpu_Speed->addAction(actionSpeed_x2); - menuCpu_Speed->addAction(actionSpeed_x4); - menuCpu_Speed->addAction(actionSpeed_x8); - menuCpu_Speed->addAction(actionSpeed_x16); + menuCopy_Paste->addAction(actionPaste_from_Clipboard); + menuCopy_Paste->addAction(actionStop_Pasting); + menuCpu_Speed->addAction(actionSpeed_x1); + menuCpu_Speed->addAction(actionSpeed_x2); + menuCpu_Speed->addAction(actionSpeed_x4); + menuCpu_Speed->addAction(actionSpeed_x8); + menuCpu_Speed->addAction(actionSpeed_x16); #ifdef USE_DEBUGGER - menuDebugger->addAction(actionDebugger_1); - menuDebugger->addAction(actionDebugger_2); - menuDebugger->addAction(actionDebugger_3); - menuDebugger->addSeparator(); - menuDebugger->addAction(actionClose_Debuggers); + menuDebugger->addAction(actionDebugger_1); + menuDebugger->addAction(actionDebugger_2); + menuDebugger->addAction(actionDebugger_3); + menuDebugger->addSeparator(); + menuDebugger->addAction(actionClose_Debuggers); #endif } void Ui_MainWindow::createContextMenu(void) { - addAction(actionReset); + addAction(actionReset); #ifdef USE_SPECIAL_RESET - addAction(actionSpecial_Reset); + addAction(actionSpecial_Reset); #endif - addAction(menuCpu_Speed->menuAction()); - addAction(menuCopy_Paste->menuAction()); - addAction(menuState->menuAction()); + addAction(menuCpu_Speed->menuAction()); + addAction(menuCopy_Paste->menuAction()); + addAction(menuState->menuAction()); #ifdef USE_DEBUGGER - addAction(menuDebugger->menuAction()); + addAction(menuDebugger->menuAction()); #endif - addAction(actionExit_Emulator); + addAction(actionExit_Emulator); } void Ui_MainWindow::retranslateControlMenu(const char *SpecialResetTitle, bool WithSpecialReset) { - actionReset->setText(QApplication::translate("MainWindow", "Reset", 0, QApplication::UnicodeUTF8)); + actionReset->setText(QApplication::translate("MainWindow", "Reset", 0, QApplication::UnicodeUTF8)); #ifdef USE_SPECIAL_RESET - if(WithSpecialReset) - actionSpecial_Reset->setText(QApplication::translate("MainWindow", SpecialResetTitle, 0, QApplication::UnicodeUTF8)); + actionSpecial_Reset->setText(QApplication::translate("MainWindow", SpecialResetTitle, 0, QApplication::UnicodeUTF8)); #endif - actionExit_Emulator->setText(QApplication::translate("MainWindow", "Exit Emulator", 0, QApplication::UnicodeUTF8)); + actionExit_Emulator->setText(QApplication::translate("MainWindow", "Exit Emulator", 0, QApplication::UnicodeUTF8)); - actionSpeed_x1->setText(QApplication::translate("MainWindow", "Speed x1", 0, QApplication::UnicodeUTF8)); - actionSpeed_x2->setText(QApplication::translate("MainWindow", "Speed x2", 0, QApplication::UnicodeUTF8)); - actionSpeed_x4->setText(QApplication::translate("MainWindow", "Speed x4", 0, QApplication::UnicodeUTF8)); - actionSpeed_x8->setText(QApplication::translate("MainWindow", "Seppd x8", 0, QApplication::UnicodeUTF8)); - actionSpeed_x16->setText(QApplication::translate("MainWindow", "Speed x16", 0, QApplication::UnicodeUTF8)); - - actionPaste_from_Clipboard->setText(QApplication::translate("MainWindow", "Paste from Clipboard", 0, QApplication::UnicodeUTF8)); - actionStop_Pasting->setText(QApplication::translate("MainWindow", "Stop Pasting", 0, QApplication::UnicodeUTF8)); + actionSpeed_x1->setText(QApplication::translate("MainWindow", "Speed x1", 0, QApplication::UnicodeUTF8)); + actionSpeed_x2->setText(QApplication::translate("MainWindow", "Speed x2", 0, QApplication::UnicodeUTF8)); + actionSpeed_x4->setText(QApplication::translate("MainWindow", "Speed x4", 0, QApplication::UnicodeUTF8)); + actionSpeed_x8->setText(QApplication::translate("MainWindow", "Seppd x8", 0, QApplication::UnicodeUTF8)); + actionSpeed_x16->setText(QApplication::translate("MainWindow", "Speed x16", 0, QApplication::UnicodeUTF8)); + + actionPaste_from_Clipboard->setText(QApplication::translate("MainWindow", "Paste from Clipboard", 0, QApplication::UnicodeUTF8)); + actionStop_Pasting->setText(QApplication::translate("MainWindow", "Stop Pasting", 0, QApplication::UnicodeUTF8)); #ifdef USE_STATE - actionSave_State->setText(QApplication::translate("MainWindow", "Save State", 0, QApplication::UnicodeUTF8)); - actionLoad_State->setText(QApplication::translate("MainWindow", "Load State", 0, QApplication::UnicodeUTF8)); + actionSave_State->setText(QApplication::translate("MainWindow", "Save State", 0, QApplication::UnicodeUTF8)); + actionLoad_State->setText(QApplication::translate("MainWindow", "Load State", 0, QApplication::UnicodeUTF8)); #endif #ifdef USE_DEBUGGER - actionDebugger_1->setText(QApplication::translate("MainWindow", "Debugger 1", 0, QApplication::UnicodeUTF8)); - actionDebugger_2->setText(QApplication::translate("MainWindow", "Debugger 2", 0, QApplication::UnicodeUTF8)); - actionDebugger_3->setText(QApplication::translate("MainWindow", "Debugger 3", 0, QApplication::UnicodeUTF8)); - actionClose_Debuggers->setText(QApplication::translate("MainWindow", "Close Debuggers", 0, QApplication::UnicodeUTF8)); - menuDebugger->setTitle(QApplication::translate("MainWindow", "Debugger", 0, QApplication::UnicodeUTF8)); + actionDebugger_1->setText(QApplication::translate("MainWindow", "Debugger 1", 0, QApplication::UnicodeUTF8)); + actionDebugger_2->setText(QApplication::translate("MainWindow", "Debugger 2", 0, QApplication::UnicodeUTF8)); + actionDebugger_3->setText(QApplication::translate("MainWindow", "Debugger 3", 0, QApplication::UnicodeUTF8)); + actionClose_Debuggers->setText(QApplication::translate("MainWindow", "Close Debuggers", 0, QApplication::UnicodeUTF8)); + menuDebugger->setTitle(QApplication::translate("MainWindow", "Debugger", 0, QApplication::UnicodeUTF8)); #endif - menuControl->setTitle(QApplication::translate("MainWindow", "control", 0, QApplication::UnicodeUTF8)); - menuState->setTitle(QApplication::translate("MainWindow", "State", 0, QApplication::UnicodeUTF8)); - - menuCopy_Paste->setTitle(QApplication::translate("MainWindow", "Copy/Paste", 0, QApplication::UnicodeUTF8)); - menuCpu_Speed->setTitle(QApplication::translate("MainWindow", "Cpu Speed", 0, QApplication::UnicodeUTF8)); + menuControl->setTitle(QApplication::translate("MainWindow", "control", 0, QApplication::UnicodeUTF8)); + menuState->setTitle(QApplication::translate("MainWindow", "State", 0, QApplication::UnicodeUTF8)); + menuCopy_Paste->setTitle(QApplication::translate("MainWindow", "Copy/Paste", 0, QApplication::UnicodeUTF8)); + menuCpu_Speed->setTitle(QApplication::translate("MainWindow", "Cpu Speed", 0, QApplication::UnicodeUTF8)); } QT_END_NAMESPACE diff --git a/source/src/qt/gui/menu_disk.cpp b/source/src/qt/gui/menu_disk.cpp index bb463b1c2..a05d13b0d 100644 --- a/source/src/qt/gui/menu_disk.cpp +++ b/source/src/qt/gui/menu_disk.cpp @@ -12,76 +12,75 @@ QT_BEGIN_NAMESPACE void Object_Menu_Control::insert_fd(void) { - //write_protect = false; // Right? On D88, May be writing entry exists. - emit sig_insert_fd(getDrive()); + //write_protect = false; // Right? On D88, May be writing entry exists. + emit sig_insert_fd(getDrive()); } void Object_Menu_Control::eject_fd(void) { - write_protect = false; - emit sig_eject_fd(getDrive()); + write_protect = false; + emit sig_eject_fd(getDrive()); } void Object_Menu_Control::on_d88_slot(void) { - emit set_d88_slot(drive, s_num); + emit set_d88_slot(drive, s_num); } void Object_Menu_Control::on_recent_disk(void){ // write_protect = false; // Right? On D88, May be writing entry exists. - emit set_recent_disk(drive, s_num); + emit set_recent_disk(drive, s_num); } void Object_Menu_Control::write_protect_fd(void) { - write_protect = true; - emit sig_write_protect_fd(drive, write_protect); + write_protect = true; + emit sig_write_protect_fd(drive, write_protect); } void Object_Menu_Control::no_write_protect_fd(void) { - write_protect = false; - emit sig_write_protect_fd(drive, write_protect); + write_protect = false; + emit sig_write_protect_fd(drive, write_protect); } // Common Routine #ifdef USE_FD1 - - void Ui_MainWindow::open_disk_dialog(int drv) { - QString ext = "*.d88 *.d77 *.td0 *.imd *.dsk *.fdi *.hdm *.tfd *.xdf *.2d *.sf7"; - QString desc1 = "Floppy Disk"; - QString desc2; - CSP_DiskDialog dlg; - QString dirname; - - dlg.setWindowTitle("Open Floppy Disk"); + QString ext = "*.d88 *.d77 *.td0 *.imd *.dsk *.fdi *.hdm *.tfd *.xdf *.2d *.sf7"; + QString desc1 = "Floppy Disk"; + QString desc2; + CSP_DiskDialog dlg; + QString dirname; + dlg.setWindowTitle("Open Floppy Disk"); - desc2 = desc1 + " (" + ext.toLower() + ")"; - desc1 = desc1 + " (" + ext.toUpper() + ")"; - if(config.initial_disk_dir != NULL) { - dirname = QString::fromUtf8(config.initial_disk_dir); - } else { - char app[PATH_MAX]; - QDir df; - dirname = df.currentPath(); - strncpy(app, dirname.toUtf8().constData(), PATH_MAX); - dirname = get_parent_dir(app); - } - QStringList filter; - filter << desc1 << desc2; + desc2 = desc1 + " (" + ext.toLower() + ")"; + desc1 = desc1 + " (" + ext.toUpper() + ")"; + if(config.initial_disk_dir != NULL) { + dirname = QString::fromUtf8(config.initial_disk_dir); + } else { + char app[PATH_MAX]; + QDir df; + dirname = df.currentPath(); + strncpy(app, dirname.toUtf8().constData(), PATH_MAX); + dirname = get_parent_dir(app); + } + QStringList filter; + filter << desc1 << desc2; - dlg.param->setDrive(drv); - dlg.setDirectory(dirname); - dlg.setNameFilters(filter); - QObject::connect(&dlg, SIGNAL(fileSelected(QString)), dlg.param, SLOT(_open_disk(QString))); - QObject::connect(dlg.param, SIGNAL(do_open_disk(int, QString)), this, SLOT(_open_disk(int, QString))); - dlg.show(); - dlg.exec(); - return; + dlg.param->setDrive(drv); + dlg.setDirectory(dirname); + dlg.setNameFilters(filter); + QObject::connect(&dlg, SIGNAL(fileSelected(QString)), + dlg.param, SLOT(_open_disk(QString))); + QObject::connect(dlg.param, SIGNAL(do_open_disk(int, QString)), + this, SLOT(_open_disk(int, QString))); + dlg.show(); + dlg.exec(); + return; } #endif void Ui_MainWindow::CreateFloppyMenu(int drv, int drv_base) { #ifdef USE_FD1 - QString drv_base_name = QString::number(drv_base); - menuFD[drv] = new QMenu(menubar); - menuFD[drv]->setObjectName(QString::fromUtf8("menuFD", -1) + drv_base_name); + QString drv_base_name = QString::number(drv_base); + menuFD[drv] = new QMenu(menubar); + menuFD[drv]->setObjectName(QString::fromUtf8("menuFD", -1) + drv_base_name); # if defined(USE_DISK_WRITE_PROTECT) - menuWrite_Protection_FD[drv] = new QMenu(menuFD[drv]); - menuWrite_Protection_FD[drv]->setObjectName(QString::fromUtf8("menuWrite_Protection_FD", -1) + drv_base_name); + menuWrite_Protection_FD[drv] = new QMenu(menuFD[drv]); + menuWrite_Protection_FD[drv]->setObjectName(QString::fromUtf8("menuWrite_Protection_FD", -1) + drv_base_name); # endif #endif } @@ -89,40 +88,38 @@ void Ui_MainWindow::CreateFloppyMenu(int drv, int drv_base) void Ui_MainWindow::CreateFloppyPulldownMenu(int drv) { #ifdef USE_FD1 - menuFD[drv]->addAction(actionInsert_FD[drv]); - menuFD[drv]->addAction(actionEject_FD[drv]); - menuFD[drv]->addSeparator(); - menuFD_Recent[drv] = new QMenu(menuFD[drv]); - menuFD_Recent[drv]->setObjectName(QString::fromUtf8("Recent_FD", -1) + QString::number(drv)); - menuFD[drv]->addAction(menuFD_Recent[drv]->menuAction()); - // menuFD[drv]->addAction(actionRecent_Opened_FD[0]); - { - int ii; - for(ii = 0; ii < MAX_HISTORY; ii++) { - menuFD_Recent[drv]->addAction(action_Recent_List_FD[drv][ii]); - action_Recent_List_FD[drv][ii]->setVisible(true); - } - - } - menuFD[drv]->addSeparator(); - menuFD_D88[drv] = new QMenu(menuFD[drv]); - menuFD_D88[drv]->setObjectName(QString::fromUtf8("D88_FD", -1) + QString::number(drv)); - menuFD[drv]->addAction(menuFD_D88[drv]->menuAction()); - // menuFD[drv]->addAction(actionSelect_D88_Image_FD[0]); - { - int ii; - for(ii = 0; ii < MAX_D88_BANKS; ii++) { - menuFD_D88[drv]->addAction(action_D88_ListImage_FD[drv][ii]); - action_D88_ListImage_FD[drv][ii]->setVisible(false); - } + menuFD[drv]->addAction(actionInsert_FD[drv]); + menuFD[drv]->addAction(actionEject_FD[drv]); + menuFD[drv]->addSeparator(); + menuFD_Recent[drv] = new QMenu(menuFD[drv]); + menuFD_Recent[drv]->setObjectName(QString::fromUtf8("Recent_FD", -1) + QString::number(drv)); + menuFD[drv]->addAction(menuFD_Recent[drv]->menuAction()); + // menuFD[drv]->addAction(actionRecent_Opened_FD[0]); + { + int ii; + for(ii = 0; ii < MAX_HISTORY; ii++) { + menuFD_Recent[drv]->addAction(action_Recent_List_FD[drv][ii]); + action_Recent_List_FD[drv][ii]->setVisible(true); + } + } + menuFD[drv]->addSeparator(); + menuFD_D88[drv] = new QMenu(menuFD[drv]); + menuFD_D88[drv]->setObjectName(QString::fromUtf8("D88_FD", -1) + QString::number(drv)); + menuFD[drv]->addAction(menuFD_D88[drv]->menuAction()); + // menuFD[drv]->addAction(actionSelect_D88_Image_FD[0]); + { + int ii; + for(ii = 0; ii < MAX_D88_BANKS; ii++) { + menuFD_D88[drv]->addAction(action_D88_ListImage_FD[drv][ii]); + action_D88_ListImage_FD[drv][ii]->setVisible(false); + } - } - + } # if defined(USE_DISK_WRITE_PROTECT) - menuFD[drv]->addSeparator(); - menuFD[drv]->addAction(menuWrite_Protection_FD[drv]->menuAction()); - menuWrite_Protection_FD[drv]->addAction(actionProtection_ON_FD[drv]); - menuWrite_Protection_FD[drv]->addAction(actionProtection_OFF_FD[drv]); + menuFD[drv]->addSeparator(); + menuFD[drv]->addAction(menuWrite_Protection_FD[drv]->menuAction()); + menuWrite_Protection_FD[drv]->addAction(actionProtection_ON_FD[drv]); + menuWrite_Protection_FD[drv]->addAction(actionProtection_OFF_FD[drv]); # endif #endif } @@ -130,152 +127,148 @@ void Ui_MainWindow::CreateFloppyPulldownMenu(int drv) void Ui_MainWindow::ConfigFloppyMenuSub(int drv) { #ifdef USE_FD1 - QString drive_name = QString::number(drv); + QString drive_name = QString::number(drv); - actionInsert_FD[drv] = new Action_Control(this); - actionInsert_FD[drv]->setObjectName(QString::fromUtf8("actionInsert_FD") + drive_name); - actionInsert_FD[drv]->binds->setDrive(drv); - actionInsert_FD[drv]->binds->setNumber(0); + actionInsert_FD[drv] = new Action_Control(this); + actionInsert_FD[drv]->setObjectName(QString::fromUtf8("actionInsert_FD") + drive_name); + actionInsert_FD[drv]->binds->setDrive(drv); + actionInsert_FD[drv]->binds->setNumber(0); - actionEject_FD[drv] = new Action_Control(this); - actionEject_FD[drv]->setObjectName(QString::fromUtf8("actionEject_FD") + drive_name); - actionEject_FD[drv]->binds->setDrive(drv); - actionEject_FD[drv]->binds->setNumber(0); + actionEject_FD[drv] = new Action_Control(this); + actionEject_FD[drv]->setObjectName(QString::fromUtf8("actionEject_FD") + drive_name); + actionEject_FD[drv]->binds->setDrive(drv); + actionEject_FD[drv]->binds->setNumber(0); - actionGroup_Opened_FD[drv] = new QActionGroup(this); - actionRecent_Opened_FD[drv] = new Action_Control(this); - actionRecent_Opened_FD[drv]->setObjectName(QString::fromUtf8("actionRecent_Opened_FD") + drive_name); - actionRecent_Opened_FD[drv]->binds->setDrive(drv); - actionRecent_Opened_FD[drv]->binds->setNumber(0); + actionGroup_Opened_FD[drv] = new QActionGroup(this); + actionRecent_Opened_FD[drv] = new Action_Control(this); + actionRecent_Opened_FD[drv]->setObjectName(QString::fromUtf8("actionRecent_Opened_FD") + drive_name); + actionRecent_Opened_FD[drv]->binds->setDrive(drv); + actionRecent_Opened_FD[drv]->binds->setNumber(0); - { - int ii; - actionGroup_D88_Image_FD[drv] = new QActionGroup(this); - actionGroup_D88_Image_FD[drv]->setExclusive(true); - - actionSelect_D88_Image_FD[drv] = new Action_Control(this); - actionSelect_D88_Image_FD[drv]->setObjectName(QString::fromUtf8("actionSelect_D88_Image_FD") + drive_name); - actionSelect_D88_Image_FD[drv]->binds->setDrive(drv); - actionSelect_D88_Image_FD[drv]->binds->setNumber(0); - for(ii = 0; ii < MAX_D88_BANKS; ii++) { - action_D88_ListImage_FD[drv][ii] = new Action_Control(this); - action_D88_ListImage_FD[drv][ii]->setCheckable(true); - if(ii == 0) action_D88_ListImage_FD[drv][ii]->setChecked(true); - action_D88_ListImage_FD[drv][ii]->binds->setDrive(drv); - action_D88_ListImage_FD[drv][ii]->binds->setNumber(ii); - actionGroup_D88_Image_FD[drv]->addAction(action_D88_ListImage_FD[drv][ii]); - connect(action_D88_ListImage_FD[drv][ii], SIGNAL(triggered()), - action_D88_ListImage_FD[drv][ii]->binds, SLOT(on_d88_slot())); - connect(action_D88_ListImage_FD[drv][ii]->binds, SIGNAL(set_d88_slot(int, int)), - this, SLOT(set_d88_slot(int, int))); - } - } - { - int ii; - actionGroup_Opened_FD[drv] = new QActionGroup(this); - actionGroup_Opened_FD[drv]->setExclusive(true); - - actionRecent_Opened_FD[drv] = new Action_Control(this); - actionRecent_Opened_FD[drv]->setObjectName(QString::fromUtf8("actionSelect_Recent_FD") + drive_name); - actionRecent_Opened_FD[drv]->binds->setDrive(drv); - actionRecent_Opened_FD[drv]->binds->setNumber(0); - for(ii = 0; ii < MAX_HISTORY; ii++) { - action_Recent_List_FD[drv][ii] = new Action_Control(this); - action_Recent_List_FD[drv][ii]->binds->setDrive(drv); - action_Recent_List_FD[drv][ii]->binds->setNumber(ii); - action_Recent_List_FD[drv][ii]->setText(QString::fromUtf8(config.recent_disk_path[drv][ii])); - actionGroup_Opened_FD[drv]->addAction(action_Recent_List_FD[drv][ii]); - connect(action_Recent_List_FD[drv][ii], SIGNAL(triggered()), - action_Recent_List_FD[drv][ii]->binds, SLOT(on_recent_disk())); - connect(action_Recent_List_FD[drv][ii]->binds, SIGNAL(set_recent_disk(int, int)), - this, SLOT(set_recent_disk(int, int))); - } - } + { + int ii; + actionGroup_D88_Image_FD[drv] = new QActionGroup(this); + actionGroup_D88_Image_FD[drv]->setExclusive(true); + + actionSelect_D88_Image_FD[drv] = new Action_Control(this); + actionSelect_D88_Image_FD[drv]->setObjectName(QString::fromUtf8("actionSelect_D88_Image_FD") + drive_name); + actionSelect_D88_Image_FD[drv]->binds->setDrive(drv); + actionSelect_D88_Image_FD[drv]->binds->setNumber(0); + for(ii = 0; ii < MAX_D88_BANKS; ii++) { + action_D88_ListImage_FD[drv][ii] = new Action_Control(this); + action_D88_ListImage_FD[drv][ii]->setCheckable(true); + if(ii == 0) action_D88_ListImage_FD[drv][ii]->setChecked(true); + action_D88_ListImage_FD[drv][ii]->binds->setDrive(drv); + action_D88_ListImage_FD[drv][ii]->binds->setNumber(ii); + actionGroup_D88_Image_FD[drv]->addAction(action_D88_ListImage_FD[drv][ii]); + connect(action_D88_ListImage_FD[drv][ii], SIGNAL(triggered()), + action_D88_ListImage_FD[drv][ii]->binds, SLOT(on_d88_slot())); + connect(action_D88_ListImage_FD[drv][ii]->binds, SIGNAL(set_d88_slot(int, int)), + this, SLOT(set_d88_slot(int, int))); + } + } + { + int ii; + actionGroup_Opened_FD[drv] = new QActionGroup(this); + actionGroup_Opened_FD[drv]->setExclusive(true); + + actionRecent_Opened_FD[drv] = new Action_Control(this); + actionRecent_Opened_FD[drv]->setObjectName(QString::fromUtf8("actionSelect_Recent_FD") + drive_name); + actionRecent_Opened_FD[drv]->binds->setDrive(drv); + actionRecent_Opened_FD[drv]->binds->setNumber(0); + for(ii = 0; ii < MAX_HISTORY; ii++) { + action_Recent_List_FD[drv][ii] = new Action_Control(this); + action_Recent_List_FD[drv][ii]->binds->setDrive(drv); + action_Recent_List_FD[drv][ii]->binds->setNumber(ii); + action_Recent_List_FD[drv][ii]->setText(QString::fromUtf8(config.recent_disk_path[drv][ii])); + actionGroup_Opened_FD[drv]->addAction(action_Recent_List_FD[drv][ii]); + connect(action_Recent_List_FD[drv][ii], SIGNAL(triggered()), + action_Recent_List_FD[drv][ii]->binds, SLOT(on_recent_disk())); + connect(action_Recent_List_FD[drv][ii]->binds, SIGNAL(set_recent_disk(int, int)), + this, SLOT(set_recent_disk(int, int))); + } + } # if defined(USE_DISK_WRITE_PROTECT) - { - int ii; - actionGroup_Protect_FD[drv] = new QActionGroup(this); - actionGroup_Protect_FD[drv]->setExclusive(true); - actionProtection_ON_FD[drv] = new Action_Control(this); - actionProtection_ON_FD[drv]->setObjectName(QString::fromUtf8("actionProtection_ON_FD") + drive_name); - actionProtection_ON_FD[drv]->setCheckable(true); - actionProtection_ON_FD[drv]->setChecked(true); - actionProtection_ON_FD[drv]->binds->setDrive(drv); - actionProtection_ON_FD[drv]->binds->setNumber(0); - actionProtection_OFF_FD[drv] = new Action_Control(this); - actionProtection_OFF_FD[drv]->setObjectName(QString::fromUtf8("actionProtection_OFF_FD") + drive_name); - actionProtection_OFF_FD[drv]->setCheckable(true); - actionProtection_OFF_FD[drv]->binds->setDrive(drv); - actionProtection_OFF_FD[drv]->binds->setNumber(0); + { + int ii; + actionGroup_Protect_FD[drv] = new QActionGroup(this); + actionGroup_Protect_FD[drv]->setExclusive(true); + actionProtection_ON_FD[drv] = new Action_Control(this); + actionProtection_ON_FD[drv]->setObjectName(QString::fromUtf8("actionProtection_ON_FD") + drive_name); + actionProtection_ON_FD[drv]->setCheckable(true); + actionProtection_ON_FD[drv]->setChecked(true); + actionProtection_ON_FD[drv]->binds->setDrive(drv); + actionProtection_ON_FD[drv]->binds->setNumber(0); + actionProtection_OFF_FD[drv] = new Action_Control(this); + actionProtection_OFF_FD[drv]->setObjectName(QString::fromUtf8("actionProtection_OFF_FD") + drive_name); + actionProtection_OFF_FD[drv]->setCheckable(true); + actionProtection_OFF_FD[drv]->binds->setDrive(drv); + actionProtection_OFF_FD[drv]->binds->setNumber(0); - actionGroup_Protect_FD[drv]->addAction(actionProtection_ON_FD[drv]); - actionGroup_Protect_FD[drv]->addAction(actionProtection_OFF_FD[drv]); - - connect(actionProtection_ON_FD[drv], SIGNAL(triggered()), actionProtection_ON_FD[drv]->binds, SLOT(write_protect_fd())); - connect(actionProtection_ON_FD[drv]->binds, SIGNAL(sig_write_protect_fd(int, bool)), this, SLOT(write_protect_fd(int, bool))); - connect(actionProtection_OFF_FD[drv], SIGNAL(triggered()), actionProtection_OFF_FD[drv]->binds, SLOT(no_write_protect_fd())); - connect(actionProtection_OFF_FD[drv]->binds, SIGNAL(sig_write_protect_fd(int, bool)), this, SLOT(write_protect_fd(int, bool))); + actionGroup_Protect_FD[drv]->addAction(actionProtection_ON_FD[drv]); + actionGroup_Protect_FD[drv]->addAction(actionProtection_OFF_FD[drv]); + connect(actionProtection_ON_FD[drv], SIGNAL(triggered()), actionProtection_ON_FD[drv]->binds, SLOT(write_protect_fd())); + connect(actionProtection_ON_FD[drv]->binds, SIGNAL(sig_write_protect_fd(int, bool)), this, SLOT(write_protect_fd(int, bool))); + connect(actionProtection_OFF_FD[drv], SIGNAL(triggered()), actionProtection_OFF_FD[drv]->binds, SLOT(no_write_protect_fd())); + connect(actionProtection_OFF_FD[drv]->binds, SIGNAL(sig_write_protect_fd(int, bool)), this, SLOT(write_protect_fd(int, bool))); - } + } # endif - - connect(actionInsert_FD[drv], SIGNAL(triggered()), actionInsert_FD[drv]->binds, SLOT(insert_fd())); - connect(actionInsert_FD[drv]->binds, SIGNAL(sig_insert_fd(int)), this, SLOT(open_disk_dialog(int))); - connect(actionEject_FD[drv], SIGNAL(triggered()), actionEject_FD[drv]->binds, SLOT(eject_fd())); - connect(actionEject_FD[drv]->binds, SIGNAL(sig_eject_fd(int)), this, SLOT(eject_fd(int))); - // Translate Menu + connect(actionInsert_FD[drv], SIGNAL(triggered()), actionInsert_FD[drv]->binds, SLOT(insert_fd())); + connect(actionInsert_FD[drv]->binds, SIGNAL(sig_insert_fd(int)), this, SLOT(open_disk_dialog(int))); + connect(actionEject_FD[drv], SIGNAL(triggered()), actionEject_FD[drv]->binds, SLOT(eject_fd())); + connect(actionEject_FD[drv]->binds, SIGNAL(sig_eject_fd(int)), this, SLOT(eject_fd(int))); + // Translate Menu #endif } void Ui_MainWindow::retranslateFloppyMenu(int drv, int basedrv) { #ifdef USE_FD1 - QString drive_name = (QApplication::translate("MainWindow", "Floppy ", 0, QApplication::UnicodeUTF8)); - drive_name += QString::number(basedrv); + QString drive_name = (QApplication::translate("MainWindow", "Floppy ", 0, QApplication::UnicodeUTF8)); + drive_name += QString::number(basedrv); - if((drv < 0) || (drv >= 8)) return; - menuFD[drv]->setTitle(QApplication::translate("MainWindow", drive_name.toUtf8().constData() , 0, QApplication::UnicodeUTF8)); - actionInsert_FD[drv]->setText(QApplication::translate("MainWindow", "Insert", 0, QApplication::UnicodeUTF8)); - actionEject_FD[drv]->setText(QApplication::translate("MainWindow", "Eject", 0, QApplication::UnicodeUTF8)); + if((drv < 0) || (drv >= 8)) return; + menuFD[drv]->setTitle(QApplication::translate("MainWindow", drive_name.toUtf8().constData() , 0, QApplication::UnicodeUTF8)); + actionInsert_FD[drv]->setText(QApplication::translate("MainWindow", "Insert", 0, QApplication::UnicodeUTF8)); + actionEject_FD[drv]->setText(QApplication::translate("MainWindow", "Eject", 0, QApplication::UnicodeUTF8)); - menuFD_Recent[drv]->setTitle(QApplication::translate("MainWindow", "Recent Opened", 0, QApplication::UnicodeUTF8)); - menuFD_D88[drv]->setTitle(QApplication::translate("MainWindow", "Select D88 Image", 0, QApplication::UnicodeUTF8)); + menuFD_Recent[drv]->setTitle(QApplication::translate("MainWindow", "Recent Opened", 0, QApplication::UnicodeUTF8)); + menuFD_D88[drv]->setTitle(QApplication::translate("MainWindow", "Select D88 Image", 0, QApplication::UnicodeUTF8)); # if defined(USE_DISK_WRITE_PROTECT) - actionProtection_ON_FD[drv]->setText(QApplication::translate("MainWindow", "Protection ON", 0, QApplication::UnicodeUTF8)); - actionProtection_OFF_FD[drv]->setText(QApplication::translate("MainWindow", "Protection OFF", 0, QApplication::UnicodeUTF8)); - menuWrite_Protection_FD[drv]->setTitle(QApplication::translate("MainWindow", "Write Protection", 0, QApplication::UnicodeUTF8)); + actionProtection_ON_FD[drv]->setText(QApplication::translate("MainWindow", "Protection ON", 0, QApplication::UnicodeUTF8)); + actionProtection_OFF_FD[drv]->setText(QApplication::translate("MainWindow", "Protection OFF", 0, QApplication::UnicodeUTF8)); + menuWrite_Protection_FD[drv]->setTitle(QApplication::translate("MainWindow", "Write Protection", 0, QApplication::UnicodeUTF8)); # endif #endif } void Ui_MainWindow::ConfigFloppyMenu(void) { - #if defined(USE_FD1) - ConfigFloppyMenuSub(0); + ConfigFloppyMenuSub(0); #endif #if defined(USE_FD2) - ConfigFloppyMenuSub(1); + ConfigFloppyMenuSub(1); #endif #if defined(USE_FD3) - ConfigFloppyMenuSub(2); + ConfigFloppyMenuSub(2); #endif #if defined(USE_FD4) - ConfigFloppyMenuSub(3); + ConfigFloppyMenuSub(3); #endif #if defined(USE_FD5) - ConfigFloppyMenuSub(4); + ConfigFloppyMenuSub(4); #endif #if defined(USE_FD6) - ConfigFloppyMenuSub(5); + ConfigFloppyMenuSub(5); #endif #if defined(USE_FD7) - ConfigFloppyMenuSub(6); + ConfigFloppyMenuSub(6); #endif #if defined(USE_FD8) - ConfigFloppyMenuSub(7); + ConfigFloppyMenuSub(7); #endif - } QT_END_NAMESPACE diff --git a/source/src/qt/gui/menu_main.cpp b/source/src/qt/gui/menu_main.cpp index 20f125426..77e41ded6 100644 --- a/source/src/qt/gui/menu_main.cpp +++ b/source/src/qt/gui/menu_main.cpp @@ -18,8 +18,8 @@ QT_BEGIN_NAMESPACE Ui_MainWindow::Ui_MainWindow(QWidget *parent) : QMainWindow(parent) { - setupUi(); - createContextMenu(); + setupUi(); + createContextMenu(); } Ui_MainWindow::~Ui_MainWindow() @@ -28,16 +28,15 @@ Ui_MainWindow::~Ui_MainWindow() void Ui_MainWindow::setupUi(void) { - - // QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); - MainWindow = new QMainWindow(); - if (MainWindow->objectName().isEmpty()) - MainWindow->setObjectName(QString::fromUtf8("MainWindow")); - //MainWindow->resize(1288, 862); + // QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + MainWindow = new QMainWindow(); + if (MainWindow->objectName().isEmpty()) + MainWindow->setObjectName(QString::fromUtf8("MainWindow")); + //MainWindow->resize(1288, 862); ConfigControlMenu(); - ConfigFloppyMenu(); - ConfigCMTMenu(); + ConfigFloppyMenu(); + ConfigCMTMenu(); ConfigSoundMenu(); #if defined(USE_BINARY_FILE1) @@ -45,46 +44,46 @@ void Ui_MainWindow::setupUi(void) #endif #if defined(USE_QD1) || defined(USE_QD2) - ConfigQuickDiskMenu(); + ConfigQuickDiskMenu(); #endif ConfigScreenMenu(); #if defined(USE_CART1) || defined(USE_CART2) ConfigCartMenu(); #endif - actionAbout = new Action_Control(this); - actionAbout->setObjectName(QString::fromUtf8("actionAbout")); + actionAbout = new Action_Control(this); + actionAbout->setObjectName(QString::fromUtf8("actionAbout")); - graphicsView = new GLDrawClass(this); - graphicsView->setObjectName(QString::fromUtf8("graphicsView")); + graphicsView = new GLDrawClass(this); + graphicsView->setObjectName(QString::fromUtf8("graphicsView")); graphicsView->setMaximumSize(2560, 2560); // ? graphicsView->setMinimumSize(240, 192); // ? graphicsView->setFixedSize(1280, 800); - MainWindow->setCentralWidget(graphicsView); - + MainWindow->setCentralWidget(graphicsView); + MainWindow->centralWidget()->adjustSize(); MainWindow->adjustSize(); // graphicsView->setSizePolicy(sizePolicy); - statusbar = new QStatusBar(this); - statusbar->setObjectName(QString::fromUtf8("statusbar")); - MainWindow->setStatusBar(statusbar); - initStatusBar(); + statusbar = new QStatusBar(this); + statusbar->setObjectName(QString::fromUtf8("statusbar")); + MainWindow->setStatusBar(statusbar); + initStatusBar(); - menubar = new QMenuBar(this); - menubar->setObjectName(QString::fromUtf8("menubar")); - menubar->setGeometry(QRect(0, 0, 1288, 27)); - menuControl = new QMenu(menubar); - menuControl->setObjectName(QString::fromUtf8("menuControl")); - menuState = new QMenu(menuControl); - menuState->setObjectName(QString::fromUtf8("menuState")); - menuCopy_Paste = new QMenu(menuControl); - menuCopy_Paste->setObjectName(QString::fromUtf8("menuCopy_Paste")); - menuCpu_Speed = new QMenu(menuControl); - menuCpu_Speed->setObjectName(QString::fromUtf8("menuCpu_Speed")); - menuDebugger = new QMenu(menuControl); - menuDebugger->setObjectName(QString::fromUtf8("menuDebugger")); + menubar = new QMenuBar(this); + menubar->setObjectName(QString::fromUtf8("menubar")); + menubar->setGeometry(QRect(0, 0, 1288, 27)); + menuControl = new QMenu(menubar); + menuControl->setObjectName(QString::fromUtf8("menuControl")); + menuState = new QMenu(menuControl); + menuState->setObjectName(QString::fromUtf8("menuState")); + menuCopy_Paste = new QMenu(menuControl); + menuCopy_Paste->setObjectName(QString::fromUtf8("menuCopy_Paste")); + menuCpu_Speed = new QMenu(menuControl); + menuCpu_Speed->setObjectName(QString::fromUtf8("menuCpu_Speed")); + menuDebugger = new QMenu(menuControl); + menuDebugger->setObjectName(QString::fromUtf8("menuDebugger")); #ifdef USE_FD1 CreateFloppyMenu(0, 1); #endif @@ -111,67 +110,67 @@ void Ui_MainWindow::setupUi(void) #endif #if defined(USE_QD1) - CreateQuickDiskMenu(0, 1); + CreateQuickDiskMenu(0, 1); #endif #if defined(USE_QD2) - CreateQuickDiskMenu(1, 2); + CreateQuickDiskMenu(1, 2); #endif #ifdef USE_TAPE - CreateCMTMenu(); + CreateCMTMenu(); #endif CreateScreenMenu(); #if defined(USE_CART1) - CreateCartMenu(0, 1); + CreateCartMenu(0, 1); #endif #if defined(USE_CART2) - CreateCartMenu(1, 2); + CreateCartMenu(1, 2); #endif #if defined(USE_BINARY_FILE1) - CreateBinaryMenu(0, 1); + CreateBinaryMenu(0, 1); #endif #if defined(USE_BINARY_FILE2) - CreateBinaryMenu(1, 2); + CreateBinaryMenu(1, 2); #endif - menuMachine = new QMenu(menubar); - menuMachine->setObjectName(QString::fromUtf8("menuMachine")); + menuMachine = new QMenu(menubar); + menuMachine->setObjectName(QString::fromUtf8("menuMachine")); menuSound = new QMenu(menubar); menuSound->setObjectName(QString::fromUtf8("menuSound")); - menuEmulator = new QMenu(menubar); - menuEmulator->setObjectName(QString::fromUtf8("menuEmulator")); - menuHELP = new QMenu(menubar); - menuHELP->setObjectName(QString::fromUtf8("menuHELP")); - MainWindow->setMenuBar(menubar); + menuEmulator = new QMenu(menubar); + menuEmulator->setObjectName(QString::fromUtf8("menuEmulator")); + menuHELP = new QMenu(menubar); + menuHELP->setObjectName(QString::fromUtf8("menuHELP")); + MainWindow->setMenuBar(menubar); - menubar->addAction(menuControl->menuAction()); + menubar->addAction(menuControl->menuAction()); connectActions_ControlMenu(); #if defined(USE_FD1) - menubar->addAction(menuFD[0]->menuAction()); + menubar->addAction(menuFD[0]->menuAction()); #endif #if defined(USE_FD2) - menubar->addAction(menuFD[1]->menuAction()); + menubar->addAction(menuFD[1]->menuAction()); #endif #if defined(USE_FD3) - menubar->addAction(menuFD[2]->menuAction()); + menubar->addAction(menuFD[2]->menuAction()); #endif #if defined(USE_FD4) - menubar->addAction(menuFD[3]->menuAction()); + menubar->addAction(menuFD[3]->menuAction()); #endif #if defined(USE_FD5) - menubar->addAction(menuFD[4]->menuAction()); + menubar->addAction(menuFD[4]->menuAction()); #endif #if defined(USE_FD6) - menubar->addAction(menuFD[5]->menuAction()); + menubar->addAction(menuFD[5]->menuAction()); #endif #if defined(USE_FD7) - menubar->addAction(menuFD[6]->menuAction()); + menubar->addAction(menuFD[6]->menuAction()); #endif #if defined(USE_FD8) - menubar->addAction(menuFD[7]->menuAction()); + menubar->addAction(menuFD[7]->menuAction()); #endif #if defined(USE_QD1) menubar->addAction(menuQD[0]->menuAction()); @@ -180,87 +179,92 @@ void Ui_MainWindow::setupUi(void) menubar->addAction(menuQD[1]->menuAction()); #endif #if defined(USE_TAPE) - menubar->addAction(menuCMT->menuAction()); + menubar->addAction(menuCMT->menuAction()); #endif #if defined(USE_CART1) - menubar->addAction(menuCART[0]->menuAction()); + menubar->addAction(menuCART[0]->menuAction()); #endif #if defined(USE_CART2) - menubar->addAction(menuCART[1]->menuAction()); + menubar->addAction(menuCART[1]->menuAction()); #endif #if defined(USE_BINARY_FILE1) - menubar->addAction(menuBIN[0]->menuAction()); + menubar->addAction(menuBIN[0]->menuAction()); #endif #if defined(USE_BINARY_FILE2) - menubar->addAction(menuBIN[1]->menuAction()); + menubar->addAction(menuBIN[1]->menuAction()); #endif - menubar->addAction(menuMachine->menuAction()); + menubar->addAction(menuMachine->menuAction()); - menubar->addAction(menuSound->menuAction()); - menubar->addAction(menuScreen->menuAction()); -// menubar->addAction(menuRecord->menuAction()); - menubar->addAction(menuEmulator->menuAction()); - menubar->addAction(menuHELP->menuAction()); + menubar->addAction(menuSound->menuAction()); + menubar->addAction(menuScreen->menuAction()); +// menubar->addAction(menuRecord->menuAction()); + menubar->addAction(menuEmulator->menuAction()); + menubar->addAction(menuHELP->menuAction()); #if defined(USE_FD1) - CreateFloppyPulldownMenu(0); + CreateFloppyPulldownMenu(0); #endif #if defined(USE_FD2) - CreateFloppyPulldownMenu(1); + CreateFloppyPulldownMenu(1); #endif #if defined(USE_FD3) - CreateFloppyPulldownMenu(2); + CreateFloppyPulldownMenu(2); #endif #if defined(USE_FD4) - CreateFloppyPulldownMenu(3); + CreateFloppyPulldownMenu(3); #endif #if defined(USE_FD5) - CreateFloppyPulldownMenu(4); + CreateFloppyPulldownMenu(4); #endif #if defined(USE_FD6) - CreateFloppyPulldownMenu(5); + CreateFloppyPulldownMenu(5); #endif #if defined(USE_FD7) - CreateFloppyPulldownMenu(6); + CreateFloppyPulldownMenu(6); #endif #if defined(USE_FD8) - CreateFloppyPulldownMenu(7); + CreateFloppyPulldownMenu(7); #endif #ifdef USE_TAPE - CreateCMTPulldownMenu(); + CreateCMTPulldownMenu(); #endif #if defined(USE_QD1) - CreateQuickDiskPulldownMenu(0); + CreateQuickDiskPulldownMenu(0); #endif #if defined(USE_QD2) - CreateQuickDiskPulldownMenu(1); + CreateQuickDiskPulldownMenu(1); #endif #if defined(USE_CART1) - CreateCartPulldownMenu(0); + CreateCartPulldownMenu(0); #endif #if defined(USE_CART2) - CreateCartPulldownMenu(1); + CreateCartPulldownMenu(1); #endif #if defined(USE_BINARY_FILE1) - CreateBinaryPulldownMenu(0); + CreateBinaryPulldownMenu(0); #endif #if defined(USE_BINARY_FILE2) - CreateBinaryPulldownMenu(1); + CreateBinaryPulldownMenu(1); #endif CreateSoundMenu(); menuHELP->addAction(actionAbout); - menuHELP->addSeparator(); + menuHELP->addSeparator(); -// retranslateUi(); - QObject::connect(actionCRT_Filter, SIGNAL(toggled(bool)), actionCRT_Filter, SLOT(setChecked(bool))); - QObject::connect(actionExit_Emulator, SIGNAL(destroyed()), MainWindow, SLOT(close())); +// retranslateUi(); + QObject::connect(actionCRT_Filter, SIGNAL(toggled(bool)), + actionCRT_Filter, SLOT(setChecked(bool))); + QObject::connect(actionExit_Emulator, SIGNAL(destroyed()), + MainWindow, SLOT(close())); - - QObject::connect(this, SIGNAL(destroyed()), this, SLOT(on_actionExit_triggered())); - QObject::connect(this, SIGNAL(closed()), this, SLOT(on_actionExit_triggered())); - QObject::connect(MainWindow, SIGNAL(closed()), this, SLOT(on_actionExit_triggered())); - QObject::connect(MainWindow, SIGNAL(destroyed()), this, SLOT(on_actionExit_triggered())); - QMetaObject::connectSlotsByName(MainWindow); + QObject::connect(this, SIGNAL(destroyed()), + this, SLOT(on_actionExit_triggered())); + QObject::connect(this, SIGNAL(closed()), + this, SLOT(on_actionExit_triggered())); + QObject::connect(MainWindow, SIGNAL(closed()), + this, SLOT(on_actionExit_triggered())); + QObject::connect(MainWindow, SIGNAL(destroyed()), + this, SLOT(on_actionExit_triggered())); + QMetaObject::connectSlotsByName(MainWindow); } // setupUi @@ -268,28 +272,23 @@ void Ui_MainWindow::setupUi(void) // This code is example: by X1(TurboZ). void Ui_MainWindow::retranslateUi(void) { - retranslateControlMenu("NMI Reset", true); - retranslateFloppyMenu(0, 0); - retranslateFloppyMenu(1, 1); - retranslateCMTMenu(); - retranslateSoundMenu(); - retranslateScreenMenu(); - retranslateCartMenu(0, 1); - retranslateCartMenu(1, 2); - retranslateBinaryMenu(0, 1); - retranslateBinaryMenu(1, 2); + retranslateControlMenu("NMI Reset", true); + retranslateFloppyMenu(0, 0); + retranslateFloppyMenu(1, 1); + retranslateCMTMenu(); + retranslateSoundMenu(); + retranslateScreenMenu(); + retranslateCartMenu(0, 1); + retranslateCartMenu(1, 2); + retranslateBinaryMenu(0, 1); + retranslateBinaryMenu(1, 2); - this->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8)); - - - actionAbout->setText(QApplication::translate("MainWindow", "About...", 0, QApplication::UnicodeUTF8)); - - - - menuEmulator->setTitle(QApplication::translate("MainWindow", "Emulator", 0, QApplication::UnicodeUTF8)); - menuMachine->setTitle(QApplication::translate("MainWindow", "Machine", 0, QApplication::UnicodeUTF8)); + this->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8)); + actionAbout->setText(QApplication::translate("MainWindow", "About...", 0, QApplication::UnicodeUTF8)); + menuEmulator->setTitle(QApplication::translate("MainWindow", "Emulator", 0, QApplication::UnicodeUTF8)); + menuMachine->setTitle(QApplication::translate("MainWindow", "Machine", 0, QApplication::UnicodeUTF8)); - menuHELP->setTitle(QApplication::translate("MainWindow", "HELP", 0, QApplication::UnicodeUTF8)); + menuHELP->setTitle(QApplication::translate("MainWindow", "HELP", 0, QApplication::UnicodeUTF8)); } // retranslateUi QT_END_NAMESPACE diff --git a/source/src/qt/gui/menu_quickdisk.cpp b/source/src/qt/gui/menu_quickdisk.cpp index 295557284..528cf0786 100644 --- a/source/src/qt/gui/menu_quickdisk.cpp +++ b/source/src/qt/gui/menu_quickdisk.cpp @@ -13,28 +13,28 @@ QT_BEGIN_NAMESPACE #if defined(USE_QD1) || defined(USE_QD2) void Object_Menu_Control::insert_Qd(void) { - //write_protect = false; // Right? On D88, May be writing entry exists. - emit sig_insert_Qd(drive); + //write_protect = false; // Right? On D88, May be writing entry exists. + emit sig_insert_Qd(drive); } void Object_Menu_Control::eject_Qd(void) { - write_protect = false; - emit sig_eject_Qd(drive); + write_protect = false; + emit sig_eject_Qd(drive); } void Object_Menu_Control::on_recent_quick_disk(void){ - // write_protect = false; // Right? On D88, May be writing entry exists. - emit set_recent_quick_disk(drive, s_num); + // write_protect = false; // Right? On D88, May be writing entry exists. + emit set_recent_quick_disk(drive, s_num); } void CSP_FileParams::_open_quick_disk(QString s){ - // write_protect = false; // Right? On D88, May be writing entry exists. - emit do_open_quick_disk(getDrive(), s); + // write_protect = false; // Right? On D88, May be writing entry exists. + emit do_open_quick_disk(getDrive(), s); } void Object_Menu_Control::write_protect_Qd(void) { - write_protect = true; - emit sig_write_protect_Qd(drive, write_protect); + write_protect = true; + emit sig_write_protect_Qd(drive, write_protect); } void Object_Menu_Control::no_write_protect_Qd(void) { - write_protect = false; - emit sig_write_protect_Qd(drive, write_protect); + write_protect = false; + emit sig_write_protect_Qd(drive, write_protect); } #endif @@ -42,180 +42,181 @@ void Object_Menu_Control::no_write_protect_Qd(void) { void Ui_MainWindow::open_quick_disk_dialog(int drv) { #ifdef USE_QD1 - QString ext = "*.mzt *.q20 *.qdf"; - QString desc1 = "Quick DIsk"; - QString desc2; - CSP_DiskDialog dlg; - QString dirname; + QString ext = "*.mzt *.q20 *.qdf"; + QString desc1 = "Quick DIsk"; + QString desc2; + CSP_DiskDialog dlg; + QString dirname; - dlg.setWindowTitle("Open Quick Disk"); + dlg.setWindowTitle("Open Quick Disk"); - desc2 = desc1 + " (" + ext.toLower() + ")"; - desc1 = desc1 + " (" + ext.toUpper() + ")"; - if(config.initial_disk_dir != NULL) { - dirname = config.initial_quickdisk_dir; - } else { - char app[_MAX_PATH]; - QDir df; - dirname = df.currentPath(); - strncpy(app, dirname.toUtf8().constData(), _MAX_PATH); - dirname = get_parent_dir(app); - } - QStringList filter; - filter << desc1 << desc2; + desc2 = desc1 + " (" + ext.toLower() + ")"; + desc1 = desc1 + " (" + ext.toUpper() + ")"; + if(config.initial_disk_dir != NULL) { + dirname = config.initial_quickdisk_dir; + } else { + char app[_MAX_PATH]; + QDir df; + dirname = df.currentPath(); + strncpy(app, dirname.toUtf8().constData(), _MAX_PATH); + dirname = get_parent_dir(app); + } + QStringList filter; + filter << desc1 << desc2; - dlg.param->setDrive(drv); - dlg.setDirectory(dirname); - dlg.setNameFilters(filter); - QObject::connect(&dlg, SIGNAL(fileSelected(QString)), dlg.param, SLOT(_open_quick_disk(QString))); - QObject::connect(dlg.param, SIGNAL(do_open_quick_disk(int, QString)), this, SLOT(_open_quick_disk(int, QString))); - dlg.show(); - dlg.exec(); - return; + dlg.param->setDrive(drv); + dlg.setDirectory(dirname); + dlg.setNameFilters(filter); + QObject::connect(&dlg, SIGNAL(fileSelected(QString)), + dlg.param, SLOT(_open_quick_disk(QString))); + QObject::connect(dlg.param, SIGNAL(do_open_quick_disk(int, QString)), + this, SLOT(_open_quick_disk(int, QString))); + dlg.show(); + dlg.exec(); + return; #endif } void Ui_MainWindow::CreateQuickDiskMenu(int drv, int drv_base) { #ifdef USE_QD1 - QString drv_base_name = QString::number(drv_base); - menuQD[drv] = new QMenu(menubar); - menuQD[drv]->setObjectName(QString::fromUtf8("menuQD", -1) + drv_base_name); - menuWrite_Protection_QD[drv] = new QMenu(menuQD[drv]); - menuWrite_Protection_QD[drv]->setObjectName(QString::fromUtf8("menuWrite_Protection_QD", -1) + drv_base_name); + QString drv_base_name = QString::number(drv_base); + menuQD[drv] = new QMenu(menubar); + menuQD[drv]->setObjectName(QString::fromUtf8("menuQD", -1) + drv_base_name); + menuWrite_Protection_QD[drv] = new QMenu(menuQD[drv]); + menuWrite_Protection_QD[drv]->setObjectName(QString::fromUtf8("menuWrite_Protection_QD", -1) + drv_base_name); #endif } void Ui_MainWindow::CreateQuickDiskPulldownMenu(int drv) { #ifdef USE_QD1 - menuQD[drv]->addAction(actionInsert_QD[drv]); - menuQD[drv]->addAction(actionEject_QD[drv]); - menuQD[drv]->addSeparator(); - menuQD_Recent[drv] = new QMenu(menuQD[drv]); - menuQD_Recent[drv]->setObjectName(QString::fromUtf8("Recent_QD", -1) + QString::number(drv)); - menuQD[drv]->addAction(menuQD_Recent[drv]->menuAction()); - // menuQD[drv]->addAction(actionRecent_Opened_QD[0]); - { - int ii; - for(ii = 0; ii < MAX_HISTORY; ii++) { - menuQD_Recent[drv]->addAction(action_Recent_List_QD[drv][ii]); - action_Recent_List_QD[drv][ii]->setVisible(true); - } - - } - menuQD[drv]->addSeparator(); - menuQD[drv]->addAction(menuWrite_Protection_QD[drv]->menuAction()); - menuWrite_Protection_QD[drv]->addAction(actionProtection_ON_QD[drv]); - menuWrite_Protection_QD[drv]->addAction(actionProtection_OFF_QD[drv]); + menuQD[drv]->addAction(actionInsert_QD[drv]); + menuQD[drv]->addAction(actionEject_QD[drv]); + menuQD[drv]->addSeparator(); + menuQD_Recent[drv] = new QMenu(menuQD[drv]); + menuQD_Recent[drv]->setObjectName(QString::fromUtf8("Recent_QD", -1) + QString::number(drv)); + menuQD[drv]->addAction(menuQD_Recent[drv]->menuAction()); + // menuQD[drv]->addAction(actionRecent_Opened_QD[0]); + { + int ii; + for(ii = 0; ii < MAX_HISTORY; ii++) { + menuQD_Recent[drv]->addAction(action_Recent_List_QD[drv][ii]); + action_Recent_List_QD[drv][ii]->setVisible(true); + } + } + menuQD[drv]->addSeparator(); + menuQD[drv]->addAction(menuWrite_Protection_QD[drv]->menuAction()); + menuWrite_Protection_QD[drv]->addAction(actionProtection_ON_QD[drv]); + menuWrite_Protection_QD[drv]->addAction(actionProtection_OFF_QD[drv]); #endif } void Ui_MainWindow::ConfigQuickDiskMenuSub(int drv) { #ifdef USE_QD1 - QString drive_name = QString::number(drv); - - actionInsert_QD[drv] = new Action_Control(this); - actionInsert_QD[drv]->setObjectName(QString::fromUtf8("actionInsert_QD") + drive_name); - actionInsert_QD[drv]->binds->setDrive(drv); - actionInsert_QD[drv]->binds->setNumber(0); - - actionEject_QD[drv] = new Action_Control(this); - actionEject_QD[drv]->setObjectName(QString::fromUtf8("actionEject_QD") + drive_name); - actionEject_QD[drv]->binds->setDrive(drv); - actionEject_QD[drv]->binds->setNumber(0); - - actionGroup_Opened_QD[drv] = new QActionGroup(this); - actionRecent_Opened_QD[drv] = new Action_Control(this); - actionRecent_Opened_QD[drv]->setObjectName(QString::fromUtf8("actionRecent_Opened_QD") + drive_name); - actionRecent_Opened_QD[drv]->binds->setDrive(drv); - actionRecent_Opened_QD[drv]->binds->setNumber(0); + QString drive_name = QString::number(drv); - { - int ii; - actionGroup_Opened_QD[drv] = new QActionGroup(this); - actionGroup_Opened_QD[drv]->setExclusive(true); - - actionRecent_Opened_QD[drv] = new Action_Control(this); - actionRecent_Opened_QD[drv]->setObjectName(QString::fromUtf8("actionSelect_Recent_QD") + drive_name); - actionRecent_Opened_QD[drv]->binds->setDrive(drv); - actionRecent_Opened_QD[drv]->binds->setNumber(0); - for(ii = 0; ii < MAX_HISTORY; ii++) { - action_Recent_List_QD[drv][ii] = new Action_Control(this); - action_Recent_List_QD[drv][ii]->binds->setDrive(drv); - action_Recent_List_QD[drv][ii]->binds->setNumber(ii); - action_Recent_List_QD[drv][ii]->setText(QString::fromUtf8(config.recent_quickdisk_path[drv][ii])); - actionGroup_Opened_QD[drv]->addAction(action_Recent_List_QD[drv][ii]); - connect(action_Recent_List_QD[drv][ii], SIGNAL(triggered()), - action_Recent_List_QD[drv][ii]->binds, SLOT(on_recent_quick_disk())); - connect(action_Recent_List_QD[drv][ii]->binds, SIGNAL(set_recent_quick_disk(int, int)), - this, SLOT(set_recent_quick_disk(int, int))); - } - } - { - int ii; - actionGroup_Protect_QD[drv] = new QActionGroup(this); - actionGroup_Protect_QD[drv]->setExclusive(true); - actionProtection_ON_QD[drv] = new Action_Control(this); - actionProtection_ON_QD[drv]->setObjectName(QString::fromUtf8("actionProtection_ON_QD") + drive_name); - actionProtection_ON_QD[drv]->setCheckable(true); - actionProtection_ON_QD[drv]->setChecked(true); - actionProtection_ON_QD[drv]->binds->setDrive(drv); - actionProtection_ON_QD[drv]->binds->setNumber(0); - actionProtection_OFF_QD[drv] = new Action_Control(this); - actionProtection_OFF_QD[drv]->setObjectName(QString::fromUtf8("actionProtection_OFF_QD") + drive_name); - actionProtection_OFF_QD[drv]->setCheckable(true); - actionProtection_OFF_QD[drv]->binds->setDrive(drv); - actionProtection_OFF_QD[drv]->binds->setNumber(1); + actionInsert_QD[drv] = new Action_Control(this); + actionInsert_QD[drv]->setObjectName(QString::fromUtf8("actionInsert_QD") + drive_name); + actionInsert_QD[drv]->binds->setDrive(drv); + actionInsert_QD[drv]->binds->setNumber(0); - actionGroup_Protect_QD[drv]->addAction(actionProtection_ON_QD[drv]); - actionGroup_Protect_QD[drv]->addAction(actionProtection_OFF_QD[drv]); - - connect(actionProtection_ON_QD[drv], SIGNAL(triggered()), actionProtection_ON_QD[drv]->binds, SLOT(write_protect_Qd())); - connect(actionProtection_ON_QD[drv]->binds, SIGNAL(sig_write_protect_Qd(int, bool)), this, SLOT(write_protect_Qd(int, bool))); - connect(actionProtection_OFF_QD[drv], SIGNAL(triggered()), actionProtection_OFF_QD[drv]->binds, SLOT(no_write_protect_Qd())); - connect(actionProtection_OFF_QD[drv]->binds, SIGNAL(sig_write_protect_Qd(int, bool)), this, SLOT(write_protect_Qd(int, bool))); - } + actionEject_QD[drv] = new Action_Control(this); + actionEject_QD[drv]->setObjectName(QString::fromUtf8("actionEject_QD") + drive_name); + actionEject_QD[drv]->binds->setDrive(drv); + actionEject_QD[drv]->binds->setNumber(0); + actionGroup_Opened_QD[drv] = new QActionGroup(this); + actionRecent_Opened_QD[drv] = new Action_Control(this); + actionRecent_Opened_QD[drv]->setObjectName(QString::fromUtf8("actionRecent_Opened_QD") + drive_name); + actionRecent_Opened_QD[drv]->binds->setDrive(drv); + actionRecent_Opened_QD[drv]->binds->setNumber(0); - connect(actionInsert_QD[drv], SIGNAL(triggered()), actionInsert_QD[drv]->binds, SLOT(insert_Qd())); - connect(actionInsert_QD[drv]->binds, SIGNAL(sig_insert_Qd(int)), this, SLOT(open_quick_disk_dialog(int))); - connect(actionEject_QD[drv], SIGNAL(triggered()), actionEject_QD[drv]->binds, SLOT(eject_Qd())); - connect(actionEject_QD[drv]->binds, SIGNAL(sig_eject_Qd(int)), this, SLOT(eject_Qd(int))); - // Translate Menu + { + int ii; + actionGroup_Opened_QD[drv] = new QActionGroup(this); + actionGroup_Opened_QD[drv]->setExclusive(true); + + actionRecent_Opened_QD[drv] = new Action_Control(this); + actionRecent_Opened_QD[drv]->setObjectName(QString::fromUtf8("actionSelect_Recent_QD") + drive_name); + actionRecent_Opened_QD[drv]->binds->setDrive(drv); + actionRecent_Opened_QD[drv]->binds->setNumber(0); + for(ii = 0; ii < MAX_HISTORY; ii++) { + action_Recent_List_QD[drv][ii] = new Action_Control(this); + action_Recent_List_QD[drv][ii]->binds->setDrive(drv); + action_Recent_List_QD[drv][ii]->binds->setNumber(ii); + action_Recent_List_QD[drv][ii]->setText(QString::fromUtf8(config.recent_quickdisk_path[drv][ii])); + actionGroup_Opened_QD[drv]->addAction(action_Recent_List_QD[drv][ii]); + connect(action_Recent_List_QD[drv][ii], SIGNAL(triggered()), + action_Recent_List_QD[drv][ii]->binds, SLOT(on_recent_quick_disk())); + connect(action_Recent_List_QD[drv][ii]->binds, SIGNAL(set_recent_quick_disk(int, int)), + this, SLOT(set_recent_quick_disk(int, int))); + } + } + { + int ii; + actionGroup_Protect_QD[drv] = new QActionGroup(this); + actionGroup_Protect_QD[drv]->setExclusive(true); + actionProtection_ON_QD[drv] = new Action_Control(this); + actionProtection_ON_QD[drv]->setObjectName(QString::fromUtf8("actionProtection_ON_QD") + drive_name); + actionProtection_ON_QD[drv]->setCheckable(true); + actionProtection_ON_QD[drv]->setChecked(true); + actionProtection_ON_QD[drv]->binds->setDrive(drv); + actionProtection_ON_QD[drv]->binds->setNumber(0); + actionProtection_OFF_QD[drv] = new Action_Control(this); + actionProtection_OFF_QD[drv]->setObjectName(QString::fromUtf8("actionProtection_OFF_QD") + drive_name); + actionProtection_OFF_QD[drv]->setCheckable(true); + actionProtection_OFF_QD[drv]->binds->setDrive(drv); + actionProtection_OFF_QD[drv]->binds->setNumber(1); + + actionGroup_Protect_QD[drv]->addAction(actionProtection_ON_QD[drv]); + actionGroup_Protect_QD[drv]->addAction(actionProtection_OFF_QD[drv]); + + connect(actionProtection_ON_QD[drv], SIGNAL(triggered()), + actionProtection_ON_QD[drv]->binds, SLOT(write_protect_Qd())); + connect(actionProtection_ON_QD[drv]->binds, SIGNAL(sig_write_protect_Qd(int, bool)), + this, SLOT(write_protect_Qd(int, bool))); + connect(actionProtection_OFF_QD[drv], SIGNAL(triggered()), + actionProtection_OFF_QD[drv]->binds, SLOT(no_write_protect_Qd())); + connect(actionProtection_OFF_QD[drv]->binds, SIGNAL(sig_write_protect_Qd(int, bool)), + this, SLOT(write_protect_Qd(int, bool))); + } + connect(actionInsert_QD[drv], SIGNAL(triggered()), actionInsert_QD[drv]->binds, SLOT(insert_Qd())); + connect(actionInsert_QD[drv]->binds, SIGNAL(sig_insert_Qd(int)), this, SLOT(open_quick_disk_dialog(int))); + connect(actionEject_QD[drv], SIGNAL(triggered()), actionEject_QD[drv]->binds, SLOT(eject_Qd())); + connect(actionEject_QD[drv]->binds, SIGNAL(sig_eject_Qd(int)), this, SLOT(eject_Qd(int))); + // Translate Menu #endif } void Ui_MainWindow::retranslateQuickDiskMenu(int drv, int basedrv) { #ifdef USE_QD1 - QString drive_name = (QApplication::translate("MainWindow", "Quick Disk ", 0, QApplication::UnicodeUTF8)); - drive_name += QString::number(basedrv); + QString drive_name = (QApplication::translate("MainWindow", "Quick Disk ", 0, QApplication::UnicodeUTF8)); + drive_name += QString::number(basedrv); - if((drv < 0) || (drv >= 2)) return; - actionInsert_QD[drv]->setText(QApplication::translate("MainWindow", "Insert", 0, QApplication::UnicodeUTF8)); - actionEject_QD[drv]->setText(QApplication::translate("MainWindow", "Eject", 0, QApplication::UnicodeUTF8)); + if((drv < 0) || (drv >= 2)) return; + actionInsert_QD[drv]->setText(QApplication::translate("MainWindow", "Insert", 0, QApplication::UnicodeUTF8)); + actionEject_QD[drv]->setText(QApplication::translate("MainWindow", "Eject", 0, QApplication::UnicodeUTF8)); - menuQD_Recent[drv]->setTitle(QApplication::translate("MainWindow", "Recent Opened", 0, QApplication::UnicodeUTF8)); + menuQD_Recent[drv]->setTitle(QApplication::translate("MainWindow", "Recent Opened", 0, QApplication::UnicodeUTF8)); - actionProtection_ON_QD[drv]->setText(QApplication::translate("MainWindow", "Protection ON", 0, QApplication::UnicodeUTF8)); - actionProtection_OFF_QD[drv]->setText(QApplication::translate("MainWindow", "Protection OFF", 0, QApplication::UnicodeUTF8)); + actionProtection_ON_QD[drv]->setText(QApplication::translate("MainWindow", "Protection ON", 0, QApplication::UnicodeUTF8)); + actionProtection_OFF_QD[drv]->setText(QApplication::translate("MainWindow", "Protection OFF", 0, QApplication::UnicodeUTF8)); - menuQD[drv]->setTitle(QApplication::translate("MainWindow", drive_name.toUtf8().constData() , 0, QApplication::UnicodeUTF8)); - menuWrite_Protection_QD[drv]->setTitle(QApplication::translate("MainWindow", "Write Protection", 0, QApplication::UnicodeUTF8)); + menuQD[drv]->setTitle(QApplication::translate("MainWindow", drive_name.toUtf8().constData() , 0, QApplication::UnicodeUTF8)); + menuWrite_Protection_QD[drv]->setTitle(QApplication::translate("MainWindow", "Write Protection", 0, QApplication::UnicodeUTF8)); #endif } void Ui_MainWindow::ConfigQuickDiskMenu(void) { - #if defined(USE_QD1) - ConfigQuickDiskMenuSub(0); + ConfigQuickDiskMenuSub(0); #endif #if defined(USE_QD2) - ConfigQuickDiskMenuSub(1); + ConfigQuickDiskMenuSub(1); #endif - } QT_END_NAMESPACE diff --git a/source/src/qt/gui/menu_screen.cpp b/source/src/qt/gui/menu_screen.cpp index 7149e65a1..8bceb185d 100644 --- a/source/src/qt/gui/menu_screen.cpp +++ b/source/src/qt/gui/menu_screen.cpp @@ -13,96 +13,91 @@ #include "emu.h" #include "qt_main.h" - QT_BEGIN_NAMESPACE - - void Object_Menu_Control::set_screen_aspect(void) { - int num = getValue1(); - emit sig_screen_aspect(num); + int num = getValue1(); + emit sig_screen_aspect(num); } void Object_Menu_Control::set_screen_size(void) { - int w, h; - getSize(&w, &h); - emit sig_screen_size(w, h); + int w, h; + getSize(&w, &h); + emit sig_screen_size(w, h); } - void Ui_MainWindow::ConfigScreenMenu_List(void) { - int w, h; - QString tmps; - int i; + int w, h; + QString tmps; + int i; - actionGroup_ScreenSize = new QActionGroup(this); - actionGroup_ScreenSize->setExclusive(true); + actionGroup_ScreenSize = new QActionGroup(this); + actionGroup_ScreenSize->setExclusive(true); - for(i = 0; i < _SCREEN_MODE_NUM; i++) { - w = screen_mode_width[i]; - h = screen_mode_height[i]; - if((w <= 0) || (h <= 0)) { - break; - } - tmps = QString::number(i); - actionScreenSize[i] = new Action_Control(this); - actionScreenSize[i]->setObjectName(QString::fromUtf8("actionScreenSize", -1) + tmps); - actionScreenSize[i]->setCheckable(true); - - if((w == 1280) && (h == 800)) actionScreenSize[i]->setChecked(true); // OK? - - actionGroup_ScreenSize->addAction(actionScreenSize[i]); - actionScreenSize[i]->binds->setSize(w, h); - - connect(actionScreenSize[i], SIGNAL(triggered()), - actionScreenSize[i]->binds, SLOT(set_screen_size())); - connect(actionScreenSize[i]->binds, SIGNAL(sig_screen_size(int, int)), - this, SLOT(set_screen_size(int, int))); - } - for(; i < _SCREEN_MODE_NUM; i++) { - actionScreenSize[i] = NULL; - } + for(i = 0; i < _SCREEN_MODE_NUM; i++) { + w = screen_mode_width[i]; + h = screen_mode_height[i]; + if((w <= 0) || (h <= 0)) { + break; + } + tmps = QString::number(i); + actionScreenSize[i] = new Action_Control(this); + actionScreenSize[i]->setObjectName(QString::fromUtf8("actionScreenSize", -1) + tmps); + actionScreenSize[i]->setCheckable(true); + + if((w == 1280) && (h == 800)) actionScreenSize[i]->setChecked(true); // OK? + + actionGroup_ScreenSize->addAction(actionScreenSize[i]); + actionScreenSize[i]->binds->setSize(w, h); + + connect(actionScreenSize[i], SIGNAL(triggered()), + actionScreenSize[i]->binds, SLOT(set_screen_size())); + connect(actionScreenSize[i]->binds, SIGNAL(sig_screen_size(int, int)), + this, SLOT(set_screen_size(int, int))); + } + for(; i < _SCREEN_MODE_NUM; i++) { + actionScreenSize[i] = NULL; + } } void Ui_MainWindow::ConfigScreenMenu(void) { - - actionZoom = new Action_Control(this); - actionZoom->setObjectName(QString::fromUtf8("actionZoom")); - actionDisplay_Mode = new Action_Control(this); - actionDisplay_Mode->setObjectName(QString::fromUtf8("actionDisplay_Mode")); + actionZoom = new Action_Control(this); + actionZoom->setObjectName(QString::fromUtf8("actionZoom")); + actionDisplay_Mode = new Action_Control(this); + actionDisplay_Mode->setObjectName(QString::fromUtf8("actionDisplay_Mode")); #ifdef USE_SCANLINE - actionScanLine = new Action_Control(this); - actionScanLine->setObjectName(QString::fromUtf8("actionScanLine")); - actionScanLine->setCheckable(true); - if(config.scan_line != 0) { - actionScanLine->setChecked(true); + actionScanLine = new Action_Control(this); + actionScanLine->setObjectName(QString::fromUtf8("actionScanLine")); + actionScanLine->setCheckable(true); + if(config.scan_line != 0) { + actionScanLine->setChecked(true); } else { - actionScanLine->setChecked(false); + actionScanLine->setChecked(false); } connect(actionScanLine, SIGNAL(toggled(bool)), this, SLOT(set_scan_line(bool))); #endif - actionCRT_Filter = new Action_Control(this); - actionCRT_Filter->setObjectName(QString::fromUtf8("actionCRT_Filter")); - actionCRT_Filter->setEnabled(false); - - actionDot_by_Dot = new Action_Control(this); - actionDot_by_Dot->setObjectName(QString::fromUtf8("actionDot_by_Dot")); - actionDot_by_Dot->setCheckable(true); - if(config.stretch_type == 0) actionDot_by_Dot->setChecked(true); + actionCRT_Filter = new Action_Control(this); + actionCRT_Filter->setObjectName(QString::fromUtf8("actionCRT_Filter")); + actionCRT_Filter->setEnabled(false); + + actionDot_by_Dot = new Action_Control(this); + actionDot_by_Dot->setObjectName(QString::fromUtf8("actionDot_by_Dot")); + actionDot_by_Dot->setCheckable(true); + if(config.stretch_type == 0) actionDot_by_Dot->setChecked(true); actionDot_by_Dot->binds->setValue1(0); - actionKeep_Aspect = new Action_Control(this); - actionKeep_Aspect->setObjectName(QString::fromUtf8("actionKeep_Aspect")); - actionKeep_Aspect->setCheckable(true); + actionKeep_Aspect = new Action_Control(this); + actionKeep_Aspect->setObjectName(QString::fromUtf8("actionKeep_Aspect")); + actionKeep_Aspect->setCheckable(true); actionKeep_Aspect->binds->setValue1(1); if(config.stretch_type == 1) actionKeep_Aspect->setChecked(true); - actionFill_Display = new Action_Control(this); - actionFill_Display->setObjectName(QString::fromUtf8("actionFill_Display")); - actionFill_Display->setCheckable(true); + actionFill_Display = new Action_Control(this); + actionFill_Display->setObjectName(QString::fromUtf8("actionFill_Display")); + actionFill_Display->setCheckable(true); actionFill_Display->binds->setValue1(2); if(config.stretch_type == 2) actionFill_Display->setChecked(true); @@ -120,101 +115,96 @@ void Ui_MainWindow::ConfigScreenMenu(void) connect(actionFill_Display, SIGNAL(triggered()), actionFill_Display->binds, SLOT(set_screen_aspect())); connect(actionFill_Display->binds, SIGNAL(sig_screen_aspect(int)), this, SLOT(set_screen_aspect(int))); - actionCapture_Screen = new Action_Control(this); - actionCapture_Screen->setObjectName(QString::fromUtf8("actionCapture_Screen")); + actionCapture_Screen = new Action_Control(this); + actionCapture_Screen->setObjectName(QString::fromUtf8("actionCapture_Screen")); - actionStart_Record_Movie = new Action_Control(this); - actionStart_Record_Movie->setObjectName(QString::fromUtf8("actionStart_Record_Movie")); - actionStart_Record_Movie->setCheckable(true); + actionStart_Record_Movie = new Action_Control(this); + actionStart_Record_Movie->setObjectName(QString::fromUtf8("actionStart_Record_Movie")); + actionStart_Record_Movie->setCheckable(true); - actionStop_Record_Movie = new Action_Control(this); - actionStop_Record_Movie->setObjectName(QString::fromUtf8("actionStop_Record_Movie")); - actionStop_Record_Movie->setCheckable(false); + actionStop_Record_Movie = new Action_Control(this); + actionStop_Record_Movie->setObjectName(QString::fromUtf8("actionStop_Record_Movie")); + actionStop_Record_Movie->setCheckable(false); ConfigScreenMenu_List(); } void Ui_MainWindow::CreateScreenMenu(void) { - int i; - menuScreen = new QMenu(menubar); - menuScreen->setObjectName(QString::fromUtf8("menuScreen")); - menuStretch_Mode = new QMenu(menuScreen); - menuStretch_Mode->setObjectName(QString::fromUtf8("menuStretch_Mode")); + int i; + menuScreen = new QMenu(menubar); + menuScreen->setObjectName(QString::fromUtf8("menuScreen")); + menuStretch_Mode = new QMenu(menuScreen); + menuStretch_Mode->setObjectName(QString::fromUtf8("menuStretch_Mode")); menuScreenSize = new QMenu(menuScreen); menuScreenSize->setObjectName(QString::fromUtf8("menuScreen_Size")); - menuScreen->addSeparator(); - menuRecord_as_movie = new QMenu(menuScreen); - menuRecord_as_movie->setObjectName(QString::fromUtf8("menuRecord_as_movie")); + menuScreen->addSeparator(); + menuRecord_as_movie = new QMenu(menuScreen); + menuRecord_as_movie->setObjectName(QString::fromUtf8("menuRecord_as_movie")); - menuScreen->addAction(actionZoom); - menuScreen->addAction(menuScreenSize->menuAction()); + menuScreen->addAction(actionZoom); + menuScreen->addAction(menuScreenSize->menuAction()); for(i = 0; i < _SCREEN_MODE_NUM; i++) { - if(actionScreenSize[i] == NULL) continue; - menuScreenSize->addAction(actionScreenSize[i]); - actionScreenSize[i]->setVisible(true); + if(actionScreenSize[i] == NULL) continue; + menuScreenSize->addAction(actionScreenSize[i]); + actionScreenSize[i]->setVisible(true); } - menuScreen->addSeparator(); - menuScreen->addAction(menuStretch_Mode->menuAction()); + menuScreen->addSeparator(); + menuScreen->addAction(menuStretch_Mode->menuAction()); - menuStretch_Mode->addAction(actionDot_by_Dot); - menuStretch_Mode->addAction(actionKeep_Aspect); - menuStretch_Mode->addAction(actionFill_Display); + menuStretch_Mode->addAction(actionDot_by_Dot); + menuStretch_Mode->addAction(actionKeep_Aspect); + menuStretch_Mode->addAction(actionFill_Display); - menuScreen->addSeparator(); + menuScreen->addSeparator(); #ifdef USE_SCANLINE - menuScreen->addAction(actionScanLine); + menuScreen->addAction(actionScanLine); #endif - menuScreen->addAction(actionCRT_Filter); - menuScreen->addAction(actionCapture_Screen); - menuScreen->addSeparator(); - menuScreen->addAction(menuRecord_as_movie->menuAction()); - menuRecord_as_movie->addAction(actionStart_Record_Movie); - menuRecord_as_movie->addAction(actionStop_Record_Movie); - + menuScreen->addAction(actionCRT_Filter); + menuScreen->addAction(actionCapture_Screen); + menuScreen->addSeparator(); + menuScreen->addAction(menuRecord_as_movie->menuAction()); + menuRecord_as_movie->addAction(actionStart_Record_Movie); + menuRecord_as_movie->addAction(actionStop_Record_Movie); } void Ui_MainWindow::retranslateScreenMenu(void) { - int i; - QString tmps_w, tmps_h, tmps; - int w, h; - - actionZoom->setText(QApplication::translate("MainWindow", "Zoom Screen", 0, QApplication::UnicodeUTF8)); - actionDisplay_Mode->setText(QApplication::translate("MainWindow", "Display Mode", 0, QApplication::UnicodeUTF8)); + int i; + QString tmps_w, tmps_h, tmps; + int w, h; + actionZoom->setText(QApplication::translate("MainWindow", "Zoom Screen", 0, QApplication::UnicodeUTF8)); + actionDisplay_Mode->setText(QApplication::translate("MainWindow", "Display Mode", 0, QApplication::UnicodeUTF8)); #ifdef USE_SCANLINE - actionScanLine->setText(QApplication::translate("MainWindow", "Set ScanLine", 0, QApplication::UnicodeUTF8)); + actionScanLine->setText(QApplication::translate("MainWindow", "Set ScanLine", 0, QApplication::UnicodeUTF8)); #endif - actionCRT_Filter->setText(QApplication::translate("MainWindow", "CRT Filter", 0, QApplication::UnicodeUTF8)); - actionDot_by_Dot->setText(QApplication::translate("MainWindow", "Dot by Dot", 0, QApplication::UnicodeUTF8)); - actionKeep_Aspect->setText(QApplication::translate("MainWindow", "Keep Aspect", 0, QApplication::UnicodeUTF8)); - actionFill_Display->setText(QApplication::translate("MainWindow", "Fill Display", 0, QApplication::UnicodeUTF8)); + actionCRT_Filter->setText(QApplication::translate("MainWindow", "CRT Filter", 0, QApplication::UnicodeUTF8)); + actionDot_by_Dot->setText(QApplication::translate("MainWindow", "Dot by Dot", 0, QApplication::UnicodeUTF8)); + actionKeep_Aspect->setText(QApplication::translate("MainWindow", "Keep Aspect", 0, QApplication::UnicodeUTF8)); + actionFill_Display->setText(QApplication::translate("MainWindow", "Fill Display", 0, QApplication::UnicodeUTF8)); - actionCapture_Screen->setText(QApplication::translate("MainWindow", "Capture Screen", 0, QApplication::UnicodeUTF8)); - - menuScreen->setTitle(QApplication::translate("MainWindow", "Screen", 0, QApplication::UnicodeUTF8)); - menuStretch_Mode->setTitle(QApplication::translate("MainWindow", "Stretch Mode", 0, QApplication::UnicodeUTF8)); - - actionStart_Record_Movie->setText(QApplication::translate("MainWindow", "Start Record Movie", 0, QApplication::UnicodeUTF8)); - actionStop_Record_Movie->setText(QApplication::translate("MainWindow", "Stop Record Movie", 0, QApplication::UnicodeUTF8)); - - menuRecord_as_movie->setTitle(QApplication::translate("MainWindow", "Recoad as movie", 0, QApplication::UnicodeUTF8)); - - - menuScreenSize->setTitle(QApplication::translate("MainWindow", "Screen size", 0, QApplication::UnicodeUTF8)); - for(i = 0; i < _SCREEN_MODE_NUM; i++) { - if(actionScreenSize[i] == NULL) continue; - - actionScreenSize[i]->binds->getSize(&w, &h); - if((w <= 0) || (h <= 0)) continue; - - tmps_w = QString::number(w); - tmps_h = QString::number(h); - tmps = QString::fromUtf8("x", -1); - tmps = tmps_w + tmps + tmps_h; - actionScreenSize[i]->setText(tmps); - } - + actionCapture_Screen->setText(QApplication::translate("MainWindow", "Capture Screen", 0, QApplication::UnicodeUTF8)); + + menuScreen->setTitle(QApplication::translate("MainWindow", "Screen", 0, QApplication::UnicodeUTF8)); + menuStretch_Mode->setTitle(QApplication::translate("MainWindow", "Stretch Mode", 0, QApplication::UnicodeUTF8)); + + actionStart_Record_Movie->setText(QApplication::translate("MainWindow", "Start Record Movie", 0, QApplication::UnicodeUTF8)); + actionStop_Record_Movie->setText(QApplication::translate("MainWindow", "Stop Record Movie", 0, QApplication::UnicodeUTF8)); + + menuRecord_as_movie->setTitle(QApplication::translate("MainWindow", "Recoad as movie", 0, QApplication::UnicodeUTF8)); + + + menuScreenSize->setTitle(QApplication::translate("MainWindow", "Screen size", 0, QApplication::UnicodeUTF8)); + for(i = 0; i < _SCREEN_MODE_NUM; i++) { + if(actionScreenSize[i] == NULL) continue; + actionScreenSize[i]->binds->getSize(&w, &h); + if((w <= 0) || (h <= 0)) continue; + tmps_w = QString::number(w); + tmps_h = QString::number(h); + tmps = QString::fromUtf8("x", -1); + tmps = tmps_w + tmps + tmps_h; + actionScreenSize[i]->setText(tmps); + } } diff --git a/source/src/qt/gui/menu_sound.cpp b/source/src/qt/gui/menu_sound.cpp index 91c80d652..b6e604d62 100644 --- a/source/src/qt/gui/menu_sound.cpp +++ b/source/src/qt/gui/menu_sound.cpp @@ -32,92 +32,88 @@ void Object_Menu_Control::on_set_latency(void) { void Ui_MainWindow::CreateSoundMenu(void) { - int i; -// menuRecord = new QMenu(menuSound); -// menuRecord->setObjectName(QString::fromUtf8("menuRecord_Sound")); + int i; + // menuRecord = new QMenu(menuSound); + // menuRecord->setObjectName(QString::fromUtf8("menuRecord_Sound")); - menuSound->addAction(actionStart_Record); - menuSound->addSeparator(); - menuOutput_Frequency = new QMenu(menuSound); - menuOutput_Frequency->setObjectName(QString::fromUtf8("menuOutput_Frequency")); - menuSound->addAction(menuOutput_Frequency->menuAction()); - menuSound->addSeparator(); + menuSound->addAction(actionStart_Record); + menuSound->addSeparator(); + menuOutput_Frequency = new QMenu(menuSound); + menuOutput_Frequency->setObjectName(QString::fromUtf8("menuOutput_Frequency")); + menuSound->addAction(menuOutput_Frequency->menuAction()); + menuSound->addSeparator(); #ifdef DATAREC_SOUND - actionSoundCMT = new Action_Control(this); - actionSoundCMT->setObjectName(QString::fromUtf8("actionSoundCMT")); - actionSoundCMT->setCheckable(true); - if(config.tape_sound != 0) { - actionSoundCMT->setChecked(true); - } else { - actionSoundCMT->setChecked(false); - } - connect(actionSoundCMT, SIGNAL(toggled(bool)), - this, SLOT(set_cmt_sound(bool))); - menuSound->addAction(actionSoundCMT); + actionSoundCMT = new Action_Control(this); + actionSoundCMT->setObjectName(QString::fromUtf8("actionSoundCMT")); + actionSoundCMT->setCheckable(true); + if(config.tape_sound != 0) { + actionSoundCMT->setChecked(true); + } else { + actionSoundCMT->setChecked(false); + } + connect(actionSoundCMT, SIGNAL(toggled(bool)), + this, SLOT(set_cmt_sound(bool))); + menuSound->addAction(actionSoundCMT); #endif - - menuSound->addSeparator(); - for(i = 0; i < 8; i++) { - menuOutput_Frequency->addAction(action_Freq[i]); - connect(action_Freq[i], SIGNAL(triggered()), - action_Freq[i]->binds, SLOT(on_set_freq())); - connect(action_Freq[i]->binds, SIGNAL(sig_freq(int)), - this, SLOT(set_freq(int))); - - } - menuSound_Latency = new QMenu(menuSound); - menuSound_Latency->setObjectName(QString::fromUtf8("menuSound_Latency")); - menuSound->addAction(menuSound_Latency->menuAction()); - for(i = 0; i < 5; i++) { - menuSound_Latency->addAction(action_Latency[i]); - } -} + menuSound->addSeparator(); + for(i = 0; i < 8; i++) { + menuOutput_Frequency->addAction(action_Freq[i]); + connect(action_Freq[i], SIGNAL(triggered()), + action_Freq[i]->binds, SLOT(on_set_freq())); + connect(action_Freq[i]->binds, SIGNAL(sig_freq(int)), + this, SLOT(set_freq(int))); + } + menuSound_Latency = new QMenu(menuSound); + menuSound_Latency->setObjectName(QString::fromUtf8("menuSound_Latency")); + menuSound->addAction(menuSound_Latency->menuAction()); + for(i = 0; i < 5; i++) { + menuSound_Latency->addAction(action_Latency[i]); + } +} void Ui_MainWindow::ConfigSoundMenu(void) { - int i; - QString tmps; - double dval; - int freq = 48000; + int i; + QString tmps; + double dval; + int freq = 48000; - actionGroup_Sound_Freq = new QActionGroup(this); - actionGroup_Sound_Freq->setExclusive(true); - - for(i = 0; i < 8; i++) { - - action_Freq[i] = new Action_Control(this); - tmps.setNum(s_freq_table[i]); - tmps = QString::fromUtf8("action") + tmps + QString::fromUtf8("Hz"); - action_Freq[i]->setObjectName(tmps); - action_Freq[i]->setCheckable(true); - action_Freq[i]->binds->setNumber(i); - if(i == config.sound_frequency) { - action_Freq[i]->setChecked(true); - freq = s_freq_table[i]; - } - actionGroup_Sound_Freq->addAction(action_Freq[i]); + actionGroup_Sound_Freq = new QActionGroup(this); + actionGroup_Sound_Freq->setExclusive(true); + + for(i = 0; i < 8; i++) { + action_Freq[i] = new Action_Control(this); + tmps.setNum(s_freq_table[i]); + tmps = QString::fromUtf8("action") + tmps + QString::fromUtf8("Hz"); + action_Freq[i]->setObjectName(tmps); + action_Freq[i]->setCheckable(true); + action_Freq[i]->binds->setNumber(i); + if(i == config.sound_frequency) { + action_Freq[i]->setChecked(true); + freq = s_freq_table[i]; + } + actionGroup_Sound_Freq->addAction(action_Freq[i]); } - actionGroup_Sound_Latency = new QActionGroup(this); + actionGroup_Sound_Latency = new QActionGroup(this); actionGroup_Sound_Latency->setExclusive(true); for(i = 0; i < 5; i++) { - action_Latency[i] = new Action_Control(this); - dval = s_late_table[i]; - dval = dval * 1000.0; - tmps.setNum((int)dval); - tmps = QString::fromUtf8("action") + tmps + QString::fromUtf8("ms"); - action_Latency[i]->setObjectName(tmps); - action_Latency[i]->setCheckable(true); - action_Latency[i]->binds->setNumber(i); - if(i == config.sound_latency) action_Latency[i]->setChecked(true); - actionGroup_Sound_Latency->addAction(action_Latency[i]); + action_Latency[i] = new Action_Control(this); + dval = s_late_table[i]; + dval = dval * 1000.0; + tmps.setNum((int)dval); + tmps = QString::fromUtf8("action") + tmps + QString::fromUtf8("ms"); + action_Latency[i]->setObjectName(tmps); + action_Latency[i]->setCheckable(true); + action_Latency[i]->binds->setNumber(i); + if(i == config.sound_latency) action_Latency[i]->setChecked(true); + actionGroup_Sound_Latency->addAction(action_Latency[i]); } - - actionStart_Record = new Action_Control(this); - actionStart_Record->setObjectName(QString::fromUtf8("actionStart_Record")); - actionStart_Record->setCheckable(true); + actionStart_Record = new Action_Control(this); + actionStart_Record->setObjectName(QString::fromUtf8("actionStart_Record")); + actionStart_Record->setCheckable(true); actionStart_Record->setChecked(false); connect(actionStart_Record, SIGNAL(toggled(bool)), this, SLOT(start_record_sound(bool))); @@ -125,30 +121,29 @@ void Ui_MainWindow::ConfigSoundMenu(void) void Ui_MainWindow::retranslateSoundMenu(void) { - int i; - QString tmps; - double dval; + int i; + QString tmps; + double dval; - for(i = 0; i < 8; i++) { - tmps.setNum(s_freq_table[i]); - tmps = tmps + QApplication::translate("MainWindow", "Hz", 0, QApplication::UnicodeUTF8); - action_Freq[i]->setText(tmps); - } - for(i = 0; i < 5; i++) { - dval = s_late_table[i]; - dval = dval * 1000.0; - tmps.setNum((int)dval); - tmps = tmps + QApplication::translate("MainWindow", "mSec", 0, QApplication::UnicodeUTF8); - action_Latency[i]->setText(tmps); - } - actionStart_Record->setText(QApplication::translate("MainWindow", "Start Recording sound", 0, QApplication::UnicodeUTF8)); + for(i = 0; i < 8; i++) { + tmps.setNum(s_freq_table[i]); + tmps = tmps + QApplication::translate("MainWindow", "Hz", 0, QApplication::UnicodeUTF8); + action_Freq[i]->setText(tmps); + } + for(i = 0; i < 5; i++) { + dval = s_late_table[i]; + dval = dval * 1000.0; + tmps.setNum((int)dval); + tmps = tmps + QApplication::translate("MainWindow", "mSec", 0, QApplication::UnicodeUTF8); + action_Latency[i]->setText(tmps); + } + actionStart_Record->setText(QApplication::translate("MainWindow", "Start Recording sound", 0, QApplication::UnicodeUTF8)); #ifdef DATAREC_SOUND - actionSoundCMT->setText(QApplication::translate("MainWindow", "Sound CMT", 0, QApplication::UnicodeUTF8)); + actionSoundCMT->setText(QApplication::translate("MainWindow", "Sound CMT", 0, QApplication::UnicodeUTF8)); #endif - menuSound->setTitle(QApplication::translate("MainWindow", "Sound", 0, QApplication::UnicodeUTF8)); - menuOutput_Frequency->setTitle(QApplication::translate("MainWindow", "Output Frequency", 0, QApplication::UnicodeUTF8)); - menuSound_Latency->setTitle(QApplication::translate("MainWindow", "Sound Latency", 0, QApplication::UnicodeUTF8)); + menuSound->setTitle(QApplication::translate("MainWindow", "Sound", 0, QApplication::UnicodeUTF8)); + menuOutput_Frequency->setTitle(QApplication::translate("MainWindow", "Output Frequency", 0, QApplication::UnicodeUTF8)); + menuSound_Latency->setTitle(QApplication::translate("MainWindow", "Sound Latency", 0, QApplication::UnicodeUTF8)); } - - + QT_END_NAMESPACE diff --git a/source/src/qt/gui/qt_input.cpp b/source/src/qt/gui/qt_input.cpp index 51dcf3db1..06376370f 100644 --- a/source/src/qt/gui/qt_input.cpp +++ b/source/src/qt/gui/qt_input.cpp @@ -84,8 +84,6 @@ const struct QtKeyTable QtKeyMappings[] = { {0xBF, Qt::Key_Question}, //$2f {0xC0, Qt::Key_QuoteLeft}, //` {0xE2, Qt::Key_Underscore},//_\ - - // End. { VK_F1, Qt::Key_F1 }, { VK_F2, Qt::Key_F2 }, @@ -136,7 +134,6 @@ const struct QtKeyTable QtKeyMappings[] = { // { VK_MULTIPLY, Qt::Key_multiply }, // { VK_SUBTRACT, Qt::Key_Minus }, // { VK_ADD, Qt::Key_Plus }, - { VK_NUMLOCK, Qt::Key_NumLock }, { VK_CAPITAL, Qt::Key_Henkan }, // fixme : JP only { VK_SCROLL, Qt::Key_ScrollLock }, @@ -198,334 +195,318 @@ static int mouse_rely = 0; static uint32 mouse_buttons = 0; struct NativeScanCode { - uint32 vk; - uint32 scan; + uint32 vk; + uint32 scan; }; struct NativeScanCode convTable_QTScan106[] = { - // Line 0 - {VK_ESCAPE, 9}, - {VK_F1, 67}, - {VK_F2, 68}, - {VK_F3, 69}, - {VK_F4, 70}, - {VK_F5, 71}, - {VK_F6, 72}, - {VK_F7, 73}, - {VK_F8, 74}, - {VK_F9, 75}, - {VK_F10, 76}, - {VK_F11, 95}, - {VK_F12, 96}, - // Power, Sleep, Wake is not implemented, they are'nt safetey. - // Line 1 - {0xf3, 49}, // Hankaku/Zenkaku - {'0', 19}, - {'1', 10}, - {'2', 11}, - {'3', 12}, - {'4', 13}, - {'5', 14}, - {'6', 15}, - {'7', 16}, - {'8', 17}, - {'9', 18}, - {0xbd, 20}, // - = - {0xde, 21}, // ^~ - {0xdc, 132}, // \| - {VK_BACK, 22}, // Backspace - // Line 2 - {VK_TAB, 23}, - {'Q', 24}, - {'W', 25}, - {'E', 26}, - {'R', 27}, - {'T', 28}, - {'Y', 29}, - {'U', 30}, - {'I', 31}, - {'O', 32}, - {'P', 33}, - {0xc0, 34}, // @ - {VK_RETURN, 36}, // Enter (Full key) - {0xdb, 35}, // [ - // Line 3 - {0xf0, 66}, // CAPS Lock - {'A', 38}, - {'S', 39}, - {'D', 40}, - {'F', 41}, - {'G', 42}, - {'H', 43}, - {'J', 44}, - {'K', 45}, - {'L', 46}, - {0xbb, 47}, // ; - {0xba, 48}, // : - {0xdd, 51}, // ] - // Line 3 - {VK_LSHIFT, 50}, // LShift - {'Z', 52}, - {'X', 53}, - {'C', 54}, - {'V', 55}, - {'B', 56}, - {'N', 57}, - {'M', 58}, - {0xbc, 59}, // , - {0xbe, 60}, // . - {0xbf, 61}, // /(Slash) - {0xe2, 97}, //\_ - {VK_RSHIFT, 62}, - // Line 4 - {VK_LCONTROL, 37}, - {VK_LWIN, 133}, - {VK_LMENU, 64}, - {0x1d, 102}, // Muhenkan - {VK_SPACE, 65}, - {0xf3, 100}, // Henkan - {0xf2, 101}, // Katakana_Hiragana - {VK_RMENU, 108}, - {VK_RWIN, 134}, - {VK_APPS, 135}, - {VK_RCONTROL, 105}, - // Cursors - {VK_UP, 111}, - {VK_DOWN, 116}, - {VK_LEFT, 113}, - {VK_RIGHT,114}, - // -// {VK_PRINT, }, - {VK_SCROLL, 78}, - {VK_PAUSE, 127}, - {VK_INSERT, 118}, - {VK_HOME, 110}, - {VK_NEXT, 112}, - {VK_DELETE, 119}, - {VK_END, 115}, - {VK_PRIOR, 117}, - // TenKey - {VK_NUMPAD0, 90}, - {VK_NUMPAD1, 87}, - {VK_NUMPAD2, 88}, - {VK_NUMPAD3, 89}, - {VK_NUMPAD4, 83}, - {VK_NUMPAD5, 84}, - {VK_NUMPAD6, 85}, - {VK_NUMPAD7, 79}, - {VK_NUMPAD8, 80}, - {VK_NUMPAD9, 81}, - // - {VK_DECIMAL, 77}, // NumLock - {VK_DIVIDE, 106}, - {VK_MULTIPLY, 63}, - {VK_SUBTRACT, 82}, - {VK_ADD, 86}, - {VK_RETURN, 104}, // Enter(ten Key) - {0xffffffff, 0xffffffff} + // Line 0 + {VK_ESCAPE, 9}, + {VK_F1, 67}, + {VK_F2, 68}, + {VK_F3, 69}, + {VK_F4, 70}, + {VK_F5, 71}, + {VK_F6, 72}, + {VK_F7, 73}, + {VK_F8, 74}, + {VK_F9, 75}, + {VK_F10, 76}, + {VK_F11, 95}, + {VK_F12, 96}, + // Power, Sleep, Wake is not implemented, they are'nt safety. + // Line 1 + {0xf3, 49}, // Hankaku/Zenkaku + {'0', 19}, + {'1', 10}, + {'2', 11}, + {'3', 12}, + {'4', 13}, + {'5', 14}, + {'6', 15}, + {'7', 16}, + {'8', 17}, + {'9', 18}, + {0xbd, 20}, // - = + {0xde, 21}, // ^~ + {0xdc, 132}, // \| + {VK_BACK, 22}, // Backspace + // Line 2 + {VK_TAB, 23}, + {'Q', 24}, + {'W', 25}, + {'E', 26}, + {'R', 27}, + {'T', 28}, + {'Y', 29}, + {'U', 30}, + {'I', 31}, + {'O', 32}, + {'P', 33}, + {0xc0, 34}, // @ + {VK_RETURN, 36}, // Enter (Full key) + {0xdb, 35}, // [ + // Line 3 + {0xf0, 66}, // CAPS Lock + {'A', 38}, + {'S', 39}, + {'D', 40}, + {'F', 41}, + {'G', 42}, + {'H', 43}, + {'J', 44}, + {'K', 45}, + {'L', 46}, + {0xbb, 47}, // ; + {0xba, 48}, // : + {0xdd, 51}, // ] + // Line 3 + {VK_LSHIFT, 50}, // LShift + {'Z', 52}, + {'X', 53}, + {'C', 54}, + {'V', 55}, + {'B', 56}, + {'N', 57}, + {'M', 58}, + {0xbc, 59}, // , + {0xbe, 60}, // . + {0xbf, 61}, // /(Slash) + {0xe2, 97}, //\_ + {VK_RSHIFT, 62}, + // Line 4 + {VK_LCONTROL, 37}, + {VK_LWIN, 133}, + {VK_LMENU, 64}, + {0x1d, 102}, // Muhenkan + {VK_SPACE, 65}, + {0xf3, 100}, // Henkan + {0xf2, 101}, // Katakana_Hiragana + {VK_RMENU, 108}, + {VK_RWIN, 134}, + {VK_APPS, 135}, + {VK_RCONTROL, 105}, + // Cursors + {VK_UP, 111}, + {VK_DOWN, 116}, + {VK_LEFT, 113}, + {VK_RIGHT,114}, + // + // {VK_PRINT, }, + {VK_SCROLL, 78}, + {VK_PAUSE, 127}, + {VK_INSERT, 118}, + {VK_HOME, 110}, + {VK_NEXT, 112}, + {VK_DELETE, 119}, + {VK_END, 115}, + {VK_PRIOR, 117}, + // TenKey + {VK_NUMPAD0, 90}, + {VK_NUMPAD1, 87}, + {VK_NUMPAD2, 88}, + {VK_NUMPAD3, 89}, + {VK_NUMPAD4, 83}, + {VK_NUMPAD5, 84}, + {VK_NUMPAD6, 85}, + {VK_NUMPAD7, 79}, + {VK_NUMPAD8, 80}, + {VK_NUMPAD9, 81}, + // + {VK_DECIMAL, 77}, // NumLock + {VK_DIVIDE, 106}, + {VK_MULTIPLY, 63}, + {VK_SUBTRACT, 82}, + {VK_ADD, 86}, + {VK_RETURN, 104}, // Enter(ten Key) + {0xffffffff, 0xffffffff} }; uint32_t GLDrawClass::get106Scancode2VK(uint32_t data) { - uint32 val = 0; - uint32 vk; - int i = 0; - while(convTable_QTScan106[i].vk != 0xffffffff) { - val = convTable_QTScan106[i].scan; - if(val == data) break; - i++; - } - vk = convTable_QTScan106[i].vk; - //printf("SCAN=%02x VK=%02x\n", val, vk); - if(vk == 0xffffffff) return 0; - if((vk == VK_LSHIFT) || (vk == VK_RSHIFT)) vk = VK_SHIFT; - if((vk == VK_LCONTROL) || (vk == VK_RCONTROL)) vk = VK_CONTROL; - if((vk == VK_LMENU) || (vk == VK_RMENU)) vk = VK_MENU; - return vk; + uint32 val = 0; + uint32 vk; + int i = 0; + while(convTable_QTScan106[i].vk != 0xffffffff) { + val = convTable_QTScan106[i].scan; + if(val == data) break; + i++; + } + vk = convTable_QTScan106[i].vk; + //printf("SCAN=%02x VK=%02x\n", val, vk); + if(vk == 0xffffffff) return 0; + if((vk == VK_LSHIFT) || (vk == VK_RSHIFT)) vk = VK_SHIFT; + if((vk == VK_LCONTROL) || (vk == VK_RCONTROL)) vk = VK_CONTROL; + if((vk == VK_LMENU) || (vk == VK_RMENU)) vk = VK_MENU; + return vk; } void GLDrawClass::keyReleaseEvent(QKeyEvent *event) { - int key = event->key(); - uint32 mod = event->modifiers(); - uint32 scan = event->nativeScanCode(); - uint32 vk; - if(event->isAutoRepeat()) return; - vk = get106Scancode2VK(scan); - emu->LockVM(); - emu->key_mod(mod); - - // Note: Qt4 with 106KEY, event->modifier() don't get Shift key as KEYMOD. - // At least, linux. + int key = event->key(); + uint32 mod = event->modifiers(); + uint32 scan = event->nativeScanCode(); + uint32 vk; + if(event->isAutoRepeat()) return; + vk = get106Scancode2VK(scan); + emu->LockVM(); + emu->key_mod(mod); + // Note: Qt4 with 106KEY, event->modifier() don't get Shift key as KEYMOD. + // At least, linux. //#ifdef NOTIFY_KEY_DOWN - if(vk != 0) { - emu->key_up(vk); - } + if(vk != 0) { + emu->key_up(vk); + } //#endif - emu->UnlockVM(); + emu->UnlockVM(); } void GLDrawClass::keyPressEvent(QKeyEvent *event) { - int key = event->key(); - uint32 mod = event->modifiers();; - uint32 scan = event->nativeScanCode(); - uint32 vk; + int key = event->key(); + uint32 mod = event->modifiers();; + uint32 scan = event->nativeScanCode(); + uint32 vk; - if(event->isAutoRepeat()) return; - vk = get106Scancode2VK(scan); -// printf("Key: VK=%d SCAN=%d MOD=%08x\n", vk, scan, mod); - emu->LockVM(); - emu->key_mod(mod); + if(event->isAutoRepeat()) return; + vk = get106Scancode2VK(scan); + // printf("Key: VK=%d SCAN=%d MOD=%08x\n", vk, scan, mod); + emu->LockVM(); + emu->key_mod(mod); //#ifdef NOTIFY_KEY_DOWN - if(vk != 0) { - emu->key_down(vk, false); - } + if(vk != 0) { + emu->key_down(vk, false); + } //#endif - emu->UnlockVM(); + emu->UnlockVM(); } #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; - } + 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 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; - } + // 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_t GetAsyncKeyState(uint32_t vk, uint32_t mod) { - vk = vk & 0xff; // OK? - quint32 modstate = mod; + vk = vk & 0xff; // OK? + quint32 modstate = mod; //printf("Mod %d %08x\n", vk, mod); #if 1 - switch(vk) { - case VK_SHIFT: - if((modstate & Qt::ShiftModifier) != 0) return 0xffffffff; - break; - case VK_LSHIFT: - if((modstate & Qt::ShiftModifier) != 0) return 0xffffffff; - break; - case VK_RSHIFT: - if((modstate & Qt::ShiftModifier) != 0) return 0xffffffff; - break; - case VK_CONTROL: - if((modstate & Qt::ControlModifier) != 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; - } + switch(vk) { + case VK_SHIFT: + if((modstate & Qt::ShiftModifier) != 0) return 0xffffffff; + break; + case VK_LSHIFT: + if((modstate & Qt::ShiftModifier) != 0) return 0xffffffff; + break; + case VK_RSHIFT: + if((modstate & Qt::ShiftModifier) != 0) return 0xffffffff; + break; + case VK_CONTROL: + if((modstate & Qt::ControlModifier) != 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; + return 0; } -uint8_t convert_AGKey2VK(uint32_t sym) -{ - uint32 n; - int i = 0; - do { - if(QtKeyMappings[i].qtkey == sym) { - n = QtKeyMappings[i].vk; - return (uint8_t)n; - } - - i++; - } while(QtKeyMappings[i].vk != 0xffff); - - return 0; -} } diff --git a/source/src/qt/gui/util_cart.cpp b/source/src/qt/gui/util_cart.cpp index 7a7530fb4..395e27a04 100644 --- a/source/src/qt/gui/util_cart.cpp +++ b/source/src/qt/gui/util_cart.cpp @@ -18,28 +18,28 @@ QT_BEGIN_NAMESPACE void Ui_MainWindow::_open_cart(int drv, const QString fname) { - char path_shadow[PATH_MAX]; - int i; + char path_shadow[PATH_MAX]; + int i; #ifdef USE_CART1 - if(fname.length() <= 0) return; - 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); - - strncpy(path_shadow, fname.toUtf8().constData(), PATH_MAX); - for(i = 0; i < MAX_HISTORY; i++) { - if(action_Recent_List_CART[drv][i] != NULL) { - action_Recent_List_CART[drv][i]->setText(QString::fromUtf8(config.recent_cart_path[drv][i])); - //actiont_Recent_List_FD[drv][i]->changed(); - } - } + if(fname.length() <= 0) return; + 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); + + strncpy(path_shadow, fname.toUtf8().constData(), PATH_MAX); + for(i = 0; i < MAX_HISTORY; i++) { + if(action_Recent_List_CART[drv][i] != NULL) { + action_Recent_List_CART[drv][i]->setText(QString::fromUtf8(config.recent_cart_path[drv][i])); + //actiont_Recent_List_FD[drv][i]->changed(); + } + } - if(emu) { -// emu->LockVM(); - emu->open_cart(drv, path_shadow); -// emu->UnlockVM(); - } + if(emu) { + // emu->LockVM(); + emu->open_cart(drv, path_shadow); + // emu->UnlockVM(); + } #endif } @@ -47,43 +47,42 @@ void Ui_MainWindow::_open_cart(int drv, const QString fname) void Ui_MainWindow::eject_cart(int drv) { - if(emu) { -// emu->LockVM(); - emu->close_cart(drv); -// emu->UnlockVM(); - } - + if(emu) { + // emu->LockVM(); + emu->close_cart(drv); + // emu->UnlockVM(); + } } void Ui_MainWindow::set_recent_cart(int drv, int num) { - QString s_path; - char path_shadow[PATH_MAX]; - int i; - - if((num < 0) || (num >= MAX_HISTORY)) return; + QString s_path; + char path_shadow[PATH_MAX]; + int i; - s_path = QString::fromUtf8(config.recent_cart_path[drv][num]); - strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX); - UPDATE_HISTORY(path_shadow, config.recent_cart_path[drv]); - strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX); + if((num < 0) || (num >= MAX_HISTORY)) return; + + s_path = QString::fromUtf8(config.recent_cart_path[drv][num]); + strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX); + UPDATE_HISTORY(path_shadow, config.recent_cart_path[drv]); + strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX); - get_parent_dir(path_shadow); - strcpy(config.initial_cart_dir, path_shadow); - strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX); + get_parent_dir(path_shadow); + strcpy(config.initial_cart_dir, path_shadow); + strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX); - if(emu) { - eject_cart(drv); -// emu->LockVM(); - emu->open_cart(drv, path_shadow); - for(i = 0; i < MAX_HISTORY; i++) { - if(action_Recent_List_CART[drv][i] != NULL) { - action_Recent_List_CART[drv][i]->setText(QString::fromUtf8(config.recent_cart_path[drv][i])); - //actiont_Recent_List_FD[drv][i]->changed(); - } - } -// emu->UnlockVM(); - } + if(emu) { + eject_cart(drv); + // emu->LockVM(); + emu->open_cart(drv, path_shadow); + for(i = 0; i < MAX_HISTORY; i++) { + if(action_Recent_List_CART[drv][i] != NULL) { + action_Recent_List_CART[drv][i]->setText(QString::fromUtf8(config.recent_cart_path[drv][i])); + //actiont_Recent_List_FD[drv][i]->changed(); + } + } + // emu->UnlockVM(); + } } #endif diff --git a/source/src/qt/gui/util_cmt.cpp b/source/src/qt/gui/util_cmt.cpp index 50da623cb..213cc9172 100644 --- a/source/src/qt/gui/util_cmt.cpp +++ b/source/src/qt/gui/util_cmt.cpp @@ -14,78 +14,77 @@ #include "emu.h" #include "agar_logger.h" -//QT_BEGIN_NAMESPACE #ifdef USE_TAPE int Ui_MainWindow::set_recent_cmt(int num) { - QString s_path; - char path_shadow[PATH_MAX]; - int i; - if((num < 0) || (num >= MAX_HISTORY)) return -1; + QString s_path; + char path_shadow[PATH_MAX]; + int i; + if((num < 0) || (num >= MAX_HISTORY)) return -1; - s_path = QString::fromUtf8(config.recent_tape_path[num]); - strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX); - UPDATE_HISTORY(path_shadow, config.recent_tape_path); - strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX); + s_path = QString::fromUtf8(config.recent_tape_path[num]); + strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX); + UPDATE_HISTORY(path_shadow, config.recent_tape_path); + strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX); - get_parent_dir(path_shadow); - strcpy(config.initial_tape_dir, path_shadow); - strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX); -// for(int i = num; i > 0; i--) { - // strcpy(config.recent_tape_path[i], config.recent_tape_path[i - 1]); - // } -// strcpy(config.recent_tape_path[0], path.c_str()); - if(emu) { - AGAR_DebugLog(AGAR_LOG_DEBUG, "Tape: Open READ"); - emu->LockVM(); - emu->play_tape(path_shadow); // Play Readonly, to safety. - emu->UnlockVM(); - } - for(i = 0; i < MAX_HISTORY; i++) { - if(action_Recent_List_CMT[i] != NULL) { - action_Recent_List_CMT[i]->setText(QString::fromUtf8(config.recent_tape_path[i])); - //emit action_Recent_List_FD[drive][i]->changed(); - } - } - return 0; + get_parent_dir(path_shadow); + strcpy(config.initial_tape_dir, path_shadow); + strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX); + // for(int i = num; i > 0; i--) { + // strcpy(config.recent_tape_path[i], config.recent_tape_path[i - 1]); + // } + // strcpy(config.recent_tape_path[0], path.c_str()); + if(emu) { + AGAR_DebugLog(AGAR_LOG_DEBUG, "Tape: Open READ"); + emu->LockVM(); + emu->play_tape(path_shadow); // Play Readonly, to safety. + emu->UnlockVM(); + } + for(i = 0; i < MAX_HISTORY; i++) { + if(action_Recent_List_CMT[i] != NULL) { + action_Recent_List_CMT[i]->setText(QString::fromUtf8(config.recent_tape_path[i])); + //emit action_Recent_List_FD[drive][i]->changed(); + } + } + return 0; } void Ui_MainWindow::do_write_protect_cmt(bool flag) { - write_protect = flag; + write_protect = flag; } #ifdef USE_TAPE_BUTTON void Ui_MainWindow::do_push_play_tape(void) { - // Do notify? - if(emu) { - emu->LockVM(); - emu->push_play(); - emu->UnlockVM(); - } - actionPlay_Start->setChecked(true); + // Do notify? + if(emu) { + emu->LockVM(); + emu->push_play(); + emu->UnlockVM(); + } + actionPlay_Start->setChecked(true); } void Ui_MainWindow::do_push_stop_tape(void) { - // Do notify? - if(emu) { - emu->LockVM(); - emu->push_stop(); - emu->UnlockVM(); - } - actionPlay_Stop->setChecked(true); + // Do notify? + if(emu) { + emu->LockVM(); + emu->push_stop(); + emu->UnlockVM(); + } + actionPlay_Stop->setChecked(true); } void Ui_MainWindow::do_display_tape_play(bool flag) { - if(flag) { - actionPlay_Start->setChecked(true); - } else { - actionPlay_Stop->setChecked(true); - } + if(flag) { + actionPlay_Start->setChecked(true); + } else { + actionPlay_Stop->setChecked(true); + } } #endif @@ -94,83 +93,80 @@ void Ui_MainWindow::do_display_tape_play(bool flag) #ifdef USE_TAPE void Ui_MainWindow::set_wave_shaper(bool f) { - if(f) { - config.wave_shaper = 1; - } else { - config.wave_shaper = 0; - } + if(f) { + config.wave_shaper = 1; + } else { + config.wave_shaper = 0; + } } bool Ui_MainWindow::get_wave_shaper(void) { - if(config.wave_shaper == 0) return false; - return true; + if(config.wave_shaper == 0) return false; + return true; } #endif // USE_TAPE #ifdef USE_TAPE void Ui_MainWindow::set_direct_load_from_mzt(bool f) { - - if(f) { - config.direct_load_mzt = 1; - } else { - config.direct_load_mzt = 0; - } + if(f) { + config.direct_load_mzt = 1; + } else { + config.direct_load_mzt = 0; + } } bool Ui_MainWindow::get_direct_load_mzt(void) { - if(config.direct_load_mzt == 0) return false; - return true; + if(config.direct_load_mzt == 0) return false; + return true; } #endif // USE_TAPE void Ui_MainWindow::_open_cmt(bool mode, const QString path) { - char path_shadow[PATH_MAX]; - int play; - int i; + char path_shadow[PATH_MAX]; + int play; + int i; - play = (mode == false)? 0 : 1; + play = (mode == false)? 0 : 1; #ifdef USE_TAPE - if(path.length() <= 0) return; - 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); - // Copy filename again. - strncpy(path_shadow, path.toUtf8().constData(), PATH_MAX); - if(emu) { - emu->LockVM(); - if((play != false) || (write_protect != false)) { - AGAR_DebugLog(AGAR_LOG_DEBUG, "Tape: Open READ : filename = %s", path_shadow); - emu->play_tape(path_shadow); - } else { - AGAR_DebugLog(AGAR_LOG_DEBUG, "Tape: Open Write : filename = %s", path_shadow); - emu->rec_tape(path_shadow); - } - emu->UnlockVM(); - } - for(i = 0; i < MAX_HISTORY; i++) { - if(action_Recent_List_CMT[i] != NULL) { - action_Recent_List_CMT[i]->setText(QString::fromUtf8(config.recent_tape_path[i])); - //emit action_Recent_List_FD[drive][i]->changed(); - } - } - + if(path.length() <= 0) return; + 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); + // Copy filename again. + strncpy(path_shadow, path.toUtf8().constData(), PATH_MAX); + if(emu) { + emu->LockVM(); + if((play != false) || (write_protect != false)) { + AGAR_DebugLog(AGAR_LOG_DEBUG, "Tape: Open READ : filename = %s", path_shadow); + emu->play_tape(path_shadow); + } else { + AGAR_DebugLog(AGAR_LOG_DEBUG, "Tape: Open Write : filename = %s", path_shadow); + emu->rec_tape(path_shadow); + } + emu->UnlockVM(); + } + for(i = 0; i < MAX_HISTORY; i++) { + if(action_Recent_List_CMT[i] != NULL) { + action_Recent_List_CMT[i]->setText(QString::fromUtf8(config.recent_tape_path[i])); + //emit action_Recent_List_FD[drive][i]->changed(); + } + } #endif } void Ui_MainWindow::eject_cmt(void) { #ifdef USE_TAPE - if(emu) { - emu->LockVM(); - emu->close_tape(); - emu->UnlockVM(); - } + if(emu) { + emu->LockVM(); + emu->close_tape(); + emu->UnlockVM(); + } #endif } -//QT_END_NAMESPACE diff --git a/source/src/qt/gui/util_fd.cpp b/source/src/qt/gui/util_fd.cpp index 22ec06e7f..647ee26a2 100644 --- a/source/src/qt/gui/util_fd.cpp +++ b/source/src/qt/gui/util_fd.cpp @@ -14,236 +14,228 @@ #include "emu.h" #include "agar_logger.h" -QT_BEGIN_NAMESPACE - int Ui_MainWindow::write_protect_fd(int drv, bool flag) { #ifdef USE_FD1 - if((drv < 0) || (drv >= MAX_FD)) return -1; - if(emu) { - emu->write_protect_fd(drv, flag); - } + if((drv < 0) || (drv >= MAX_FD)) return -1; + if(emu) { + emu->write_protect_fd(drv, flag); + } #endif - return 0; + return 0; } #ifdef USE_FD1 int Ui_MainWindow::set_d88_slot(int drive, int num) { - if((num < 0) || (num >= MAX_D88_BANKS)) return -1; - if(emu && emu->d88_file[drive].cur_bank != num) { -// emu->open_disk(drive, emu->d88_file[drive].path, emu->d88_file[drive].bank[num].offset); - emu->open_disk(drive, emu->d88_file[drive].path, num); - if(emu->is_write_protected_fd(drive)) { - actionProtection_ON_FD[drive]->setChecked(true); - } else { - actionProtection_OFF_FD[drive]->setChecked(true); - } - action_D88_ListImage_FD[drive][num]->setChecked(true); - emu->d88_file[drive].cur_bank = num; - } - return 0; + if((num < 0) || (num >= MAX_D88_BANKS)) return -1; + if(emu && emu->d88_file[drive].cur_bank != num) { + // emu->open_disk(drive, emu->d88_file[drive].path, emu->d88_file[drive].bank[num].offset); + emu->open_disk(drive, emu->d88_file[drive].path, num); + if(emu->is_write_protected_fd(drive)) { + actionProtection_ON_FD[drive]->setChecked(true); + } else { + actionProtection_OFF_FD[drive]->setChecked(true); + } + action_D88_ListImage_FD[drive][num]->setChecked(true); + emu->d88_file[drive].cur_bank = num; + } + return 0; } + int Ui_MainWindow::set_recent_disk(int drv, int num) { - QString s_path; - char path_shadow[PATH_MAX]; - int i; - - if((num < 0) || (num >= MAX_HISTORY)) return -1; - - s_path = QString::fromUtf8(config.recent_disk_path[drv][num]); - strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX); - UPDATE_HISTORY(path_shadow, config.recent_disk_path[drv]); - strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX); + QString s_path; + char path_shadow[PATH_MAX]; + int i; + if((num < 0) || (num >= MAX_HISTORY)) return -1; + s_path = QString::fromUtf8(config.recent_disk_path[drv][num]); + strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX); + UPDATE_HISTORY(path_shadow, config.recent_disk_path[drv]); + strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX); - get_parent_dir(path_shadow); - strcpy(config.initial_disk_dir, path_shadow); - strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX); + get_parent_dir(path_shadow); + strcpy(config.initial_disk_dir, path_shadow); + strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX); - if(emu) { - close_disk(drv); - emu->LockVM(); - open_disk(drv, path_shadow, 0); - if((actionGroup_D88_Image_FD[drv] != NULL) && (emu != NULL)){ - for(i = 0; i < emu->d88_file[drv].bank_num; i++) { - if(action_D88_ListImage_FD[drv][i] != NULL) { - action_D88_ListImage_FD[drv][i]->setText(QString::fromUtf8(emu->d88_file[drv].disk_name[i])); - action_D88_ListImage_FD[drv][i]->setVisible(true); - if(i == 0) action_D88_ListImage_FD[drv][i]->setChecked(true); - //emit action_D88_ListImage_FD[drv][i]->changed(); - } - } - for(; i < MAX_D88_BANKS; i++) { - if(action_D88_ListImage_FD[drv][i] != NULL) { - action_D88_ListImage_FD[drv][i]->setVisible(false); - //emit action_D88_ListImage_FD[drv][i]->changed(); - } - } - actionSelect_D88_Image_FD[drv][0].setChecked(true); - } - for(i = 0; i < MAX_HISTORY; i++) { - if(action_Recent_List_FD[drv][i] != NULL) { - action_Recent_List_FD[drv][i]->setText(QString::fromUtf8(config.recent_disk_path[drv][i])); - //actiont_Recent_List_FD[drv][i]->changed(); - } - } + if(emu) { + close_disk(drv); + emu->LockVM(); + open_disk(drv, path_shadow, 0); + if((actionGroup_D88_Image_FD[drv] != NULL) && (emu != NULL)){ + for(i = 0; i < emu->d88_file[drv].bank_num; i++) { + if(action_D88_ListImage_FD[drv][i] != NULL) { + action_D88_ListImage_FD[drv][i]->setText(QString::fromUtf8(emu->d88_file[drv].disk_name[i])); + action_D88_ListImage_FD[drv][i]->setVisible(true); + if(i == 0) action_D88_ListImage_FD[drv][i]->setChecked(true); + //emit action_D88_ListImage_FD[drv][i]->changed(); + } + } + for(; i < MAX_D88_BANKS; i++) { + if(action_D88_ListImage_FD[drv][i] != NULL) { + action_D88_ListImage_FD[drv][i]->setVisible(false); + //emit action_D88_ListImage_FD[drv][i]->changed(); + } + } + actionSelect_D88_Image_FD[drv][0].setChecked(true); + } + for(i = 0; i < MAX_HISTORY; i++) { + if(action_Recent_List_FD[drv][i] != NULL) { + action_Recent_List_FD[drv][i]->setText(QString::fromUtf8(config.recent_disk_path[drv][i])); + //actiont_Recent_List_FD[drv][i]->changed(); + } + } # if defined(USE_DISK_WRITE_PROTECT) - if(emu->is_write_protected_fd(drv)) { - actionProtection_ON_FD[drv]->setChecked(true); - } else { - actionProtection_OFF_FD[drv]->setChecked(true); - } - emu->UnlockVM(); + if(emu->is_write_protected_fd(drv)) { + actionProtection_ON_FD[drv]->setChecked(true); + } else { + actionProtection_OFF_FD[drv]->setChecked(true); + } + emu->UnlockVM(); # endif # ifdef USE_FD2 - strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX); - if(check_file_extension(path_shadow, ".d88") || check_file_extension(path_shadow, ".d77")) { - if(((drv & 1) == 0) && (drv + 1 < MAX_FD) && (1 < emu->d88_file[drv].bank_num)) { - int drv2 = drv + 1; - close_disk(drv2); - emu->LockVM(); - open_disk(drv2, path_shadow, 1); - - if((actionGroup_D88_Image_FD[drv2] != NULL) && (emu != NULL)){ - for(i = 0; i < emu->d88_file[drv2].bank_num; i++) { - if(action_D88_ListImage_FD[drv2][i] != NULL) { - action_D88_ListImage_FD[drv2][i]->setText(QString::fromUtf8(emu->d88_file[drv2].disk_name[i])); - if(i == 1) action_D88_ListImage_FD[drv2][i]->setChecked(true); - action_D88_ListImage_FD[drv2][i]->setVisible(true); - } - } - for(; i < MAX_D88_BANKS; i++) { - if(action_D88_ListImage_FD[drv2][i] != NULL) { - action_D88_ListImage_FD[drv2][i]->setVisible(false); - } - } - actionSelect_D88_Image_FD[drv2][1].setChecked(true); - } + strncpy(path_shadow, s_path.toUtf8().constData(), PATH_MAX); + if(check_file_extension(path_shadow, ".d88") || check_file_extension(path_shadow, ".d77")) { + if(((drv & 1) == 0) && (drv + 1 < MAX_FD) && (1 < emu->d88_file[drv].bank_num)) { + int drv2 = drv + 1; + close_disk(drv2); + emu->LockVM(); + open_disk(drv2, path_shadow, 1); + + if((actionGroup_D88_Image_FD[drv2] != NULL) && (emu != NULL)){ + for(i = 0; i < emu->d88_file[drv2].bank_num; i++) { + if(action_D88_ListImage_FD[drv2][i] != NULL) { + action_D88_ListImage_FD[drv2][i]->setText(QString::fromUtf8(emu->d88_file[drv2].disk_name[i])); + if(i == 1) action_D88_ListImage_FD[drv2][i]->setChecked(true); + action_D88_ListImage_FD[drv2][i]->setVisible(true); + } + } + for(; i < MAX_D88_BANKS; i++) { + if(action_D88_ListImage_FD[drv2][i] != NULL) { + action_D88_ListImage_FD[drv2][i]->setVisible(false); + } + } + actionSelect_D88_Image_FD[drv2][1].setChecked(true); + } # if defined(USE_DISK_WRITE_PROTECT) - if(emu->is_write_protected_fd(drv2)) { - actionProtection_ON_FD[drv2]->setChecked(true); - } else { - actionProtection_OFF_FD[drv2]->setChecked(true); - } + if(emu->is_write_protected_fd(drv2)) { + actionProtection_ON_FD[drv2]->setChecked(true); + } else { + actionProtection_OFF_FD[drv2]->setChecked(true); + } # endif - emu->UnlockVM(); - } - } + emu->UnlockVM(); + } + } # endif - } - return 0; + } + return 0; } #endif void Ui_MainWindow::_open_disk(int drv, const QString fname) { - char path_shadow[PATH_MAX]; - int i; - + char path_shadow[PATH_MAX]; + int i; #ifdef USE_FD1 - - if(fname.length() <= 0) return; - drv = drv & 7; - 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); - // Update List - strncpy(path_shadow, fname.toUtf8().constData(), PATH_MAX); - if(emu) { - close_disk(drv); - emu->LockVM(); - open_disk(drv, path_shadow, 0); - if((actionGroup_D88_Image_FD[drv] != NULL) && (emu != NULL)){ - for(i = 0; i < emu->d88_file[drv].bank_num; i++) { - if(action_D88_ListImage_FD[drv][i] != NULL) { - action_D88_ListImage_FD[drv][i]->setText(QString::fromUtf8(emu->d88_file[drv].disk_name[i])); - if(i == 0) action_D88_ListImage_FD[drv][i]->setChecked(true); - action_D88_ListImage_FD[drv][i]->setVisible(true); - //emit action_D88_ListImage_FD[drv][i]->changed(); - } - } - for(; i < MAX_D88_BANKS; i++) { - if(action_D88_ListImage_FD[drv][i] != NULL) { - //actionSelect_D88_Image_FD[drv][i]->setText(emu->d88_file[drv].bank[i].name); - action_D88_ListImage_FD[drv][i]->setVisible(false); - //emit action_D88_ListImage_FD[drv][i]->changed(); - } - } - actionSelect_D88_Image_FD[drv][0].setChecked(true); - } - for(i = 0; i < MAX_HISTORY; i++) { - if(action_Recent_List_FD[drv][i] != NULL) { - action_Recent_List_FD[drv][i]->setText(QString::fromUtf8(config.recent_disk_path[drv][i])); - //actiont_Recent_List_FD[drv][i]->changed(); - } - } + if(fname.length() <= 0) return; + drv = drv & 7; + 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); + // Update List + strncpy(path_shadow, fname.toUtf8().constData(), PATH_MAX); + if(emu) { + close_disk(drv); + emu->LockVM(); + open_disk(drv, path_shadow, 0); + if((actionGroup_D88_Image_FD[drv] != NULL) && (emu != NULL)){ + for(i = 0; i < emu->d88_file[drv].bank_num; i++) { + if(action_D88_ListImage_FD[drv][i] != NULL) { + action_D88_ListImage_FD[drv][i]->setText(QString::fromUtf8(emu->d88_file[drv].disk_name[i])); + if(i == 0) action_D88_ListImage_FD[drv][i]->setChecked(true); + action_D88_ListImage_FD[drv][i]->setVisible(true); + //emit action_D88_ListImage_FD[drv][i]->changed(); + } + } + for(; i < MAX_D88_BANKS; i++) { + if(action_D88_ListImage_FD[drv][i] != NULL) { + //actionSelect_D88_Image_FD[drv][i]->setText(emu->d88_file[drv].bank[i].name); + action_D88_ListImage_FD[drv][i]->setVisible(false); + //emit action_D88_ListImage_FD[drv][i]->changed(); + } + } + actionSelect_D88_Image_FD[drv][0].setChecked(true); + } + for(i = 0; i < MAX_HISTORY; i++) { + if(action_Recent_List_FD[drv][i] != NULL) { + action_Recent_List_FD[drv][i]->setText(QString::fromUtf8(config.recent_disk_path[drv][i])); + //actiont_Recent_List_FD[drv][i]->changed(); + } + } # if defined(USE_DISK_WRITE_PROTECT) - if(emu->is_write_protected_fd(drv)) { - actionProtection_ON_FD[drv]->setChecked(true); - } else { - actionProtection_OFF_FD[drv]->setChecked(true); - } + if(emu->is_write_protected_fd(drv)) { + actionProtection_ON_FD[drv]->setChecked(true); + } else { + actionProtection_OFF_FD[drv]->setChecked(true); + } # endif - emu->UnlockVM(); - - } + emu->UnlockVM(); + } # ifdef USE_FD2 - if(check_file_extension(path_shadow, ".d88") || check_file_extension(path_shadow, ".d77")) { - if(((drv & 1) == 0) && (drv + 1 < MAX_FD) && (1 < emu->d88_file[drv].bank_num)) { - int drv2 = drv + 1; - close_disk(drv2); - emu->LockVM(); - strncpy(path_shadow, fname.toUtf8().constData(), PATH_MAX); - open_disk(drv2, path_shadow, 1); + if(check_file_extension(path_shadow, ".d88") || check_file_extension(path_shadow, ".d77")) { + if(((drv & 1) == 0) && (drv + 1 < MAX_FD) && (1 < emu->d88_file[drv].bank_num)) { + int drv2 = drv + 1; + close_disk(drv2); + emu->LockVM(); + strncpy(path_shadow, fname.toUtf8().constData(), PATH_MAX); + open_disk(drv2, path_shadow, 1); - if((actionGroup_D88_Image_FD[drv2] != NULL) && (emu != NULL)){ - for(i = 0; i < emu->d88_file[drv2].bank_num; i++) { - if(action_D88_ListImage_FD[drv2][i] != NULL) { - action_D88_ListImage_FD[drv2][i]->setText(QString::fromUtf8(emu->d88_file[drv2].disk_name[i])); - if(i == 1) action_D88_ListImage_FD[drv2][i]->setChecked(true); - action_D88_ListImage_FD[drv2][i]->setVisible(true); - } - } - for(; i < MAX_D88_BANKS; i++) { - if(action_D88_ListImage_FD[drv2][i] != NULL) { - action_D88_ListImage_FD[drv2][i]->setVisible(false); - } - } - actionSelect_D88_Image_FD[drv2][1].setChecked(true); - } + if((actionGroup_D88_Image_FD[drv2] != NULL) && (emu != NULL)){ + for(i = 0; i < emu->d88_file[drv2].bank_num; i++) { + if(action_D88_ListImage_FD[drv2][i] != NULL) { + action_D88_ListImage_FD[drv2][i]->setText(QString::fromUtf8(emu->d88_file[drv2].disk_name[i])); + if(i == 1) action_D88_ListImage_FD[drv2][i]->setChecked(true); + action_D88_ListImage_FD[drv2][i]->setVisible(true); + } + } + for(; i < MAX_D88_BANKS; i++) { + if(action_D88_ListImage_FD[drv2][i] != NULL) { + action_D88_ListImage_FD[drv2][i]->setVisible(false); + } + } + actionSelect_D88_Image_FD[drv2][1].setChecked(true); + } # if defined(USE_DISK_WRITE_PROTECT) - if(emu->is_write_protected_fd(drv2)) { - actionProtection_ON_FD[drv2]->setChecked(true); - } else { - actionProtection_OFF_FD[drv2]->setChecked(true); - } + if(emu->is_write_protected_fd(drv2)) { + actionProtection_ON_FD[drv2]->setChecked(true); + } else { + actionProtection_OFF_FD[drv2]->setChecked(true); + } # endif - emu->UnlockVM(); - } - } + emu->UnlockVM(); + } + } # endif #endif } void Ui_MainWindow::eject_fd(int drv) { - int i; + int i; #ifdef USE_FD1 - if(emu) { -// emu->LockVM(); - close_disk(drv); - for(i = 0; i < MAX_D88_BANKS; i++) { - if(action_D88_ListImage_FD[drv][i] != NULL) { - action_D88_ListImage_FD[drv][i]->setVisible(false); -// actionSelect_D88_Image_FD[drv][i].setChecked(false); - } - } -// emu->UnlockVM(); - } + if(emu) { + // emu->LockVM(); + close_disk(drv); + for(i = 0; i < MAX_D88_BANKS; i++) { + if(action_D88_ListImage_FD[drv][i] != NULL) { + action_D88_ListImage_FD[drv][i]->setVisible(false); + // actionSelect_D88_Image_FD[drv][i].setChecked(false); + } + } + // emu->UnlockVM(); + } #endif } - -QT_END_NAMESPACE diff --git a/source/src/qt/gui/util_qd.cpp b/source/src/qt/gui/util_qd.cpp index 3c803255a..60dd4f4b1 100644 --- a/source/src/qt/gui/util_qd.cpp +++ b/source/src/qt/gui/util_qd.cpp @@ -14,95 +14,90 @@ #include "emu.h" #include "agar_logger.h" -QT_BEGIN_NAMESPACE - int Ui_MainWindow::write_protect_Qd(int drv, bool flag) { #ifdef USE_QD1 - if((drv < 0) || (drv >= MAX_QD)) return -1; - if(emu) { -// emu->write_protect_Qd(drv, flag); - } + if((drv < 0) || (drv >= MAX_QD)) return -1; + if(emu) { + // emu->write_protect_Qd(drv, flag); + } #endif - return 0; + return 0; } int Ui_MainWindow::set_recent_quick_disk(int drv, int num) - { +{ #ifdef USE_QD1 - QString s_path; - char path_shadow[_MAX_PATH]; - int i; - if((num < 0) || (num >= MAX_HISTORY)) return -1; - s_path = QString::fromUtf8(config.recent_quickdisk_path[drv][num]); - strncpy(path_shadow, s_path.toUtf8().constData(), _MAX_PATH); - UPDATE_HISTORY(path_shadow, config.recent_quickdisk_path[drv]); + QString s_path; + char path_shadow[_MAX_PATH]; + int i; + if((num < 0) || (num >= MAX_HISTORY)) return -1; + s_path = QString::fromUtf8(config.recent_quickdisk_path[drv][num]); + strncpy(path_shadow, s_path.toUtf8().constData(), _MAX_PATH); + UPDATE_HISTORY(path_shadow, config.recent_quickdisk_path[drv]); - strncpy(path_shadow, s_path.toUtf8().constData(), _MAX_PATH); - get_parent_dir(path_shadow); - strncpy(config.initial_quickdisk_dir, path_shadow, _MAX_PATH); - strncpy(path_shadow, s_path.toUtf8().constData(), _MAX_PATH); + strncpy(path_shadow, s_path.toUtf8().constData(), _MAX_PATH); + get_parent_dir(path_shadow); + strncpy(config.initial_quickdisk_dir, path_shadow, _MAX_PATH); + strncpy(path_shadow, s_path.toUtf8().constData(), _MAX_PATH); - if(emu) { - emu->LockVM(); - emu->open_quickdisk(drv, path_shadow); - emu->UnlockVM(); - //if(emu->is_write_protected_Qd(drive)) { - // actionProtection_ON_QD[drive]->setChecked(true); - // } else { - actionProtection_OFF_QD[drv]->setChecked(true); - // } - } - for(i = 0; i < MAX_HISTORY; i++) { - if(action_Recent_List_QD[drv][i] != NULL) { - action_Recent_List_QD[drv][i]->setText(QString::fromUtf8(config.recent_quickdisk_path[drv][i])); - //emit action_Recent_List_QD[drive][i]->changed(); - } - } + if(emu) { + emu->LockVM(); + emu->open_quickdisk(drv, path_shadow); + emu->UnlockVM(); + //if(emu->is_write_protected_Qd(drive)) { + // actionProtection_ON_QD[drive]->setChecked(true); + // } else { + actionProtection_OFF_QD[drv]->setChecked(true); + // } + } + for(i = 0; i < MAX_HISTORY; i++) { + if(action_Recent_List_QD[drv][i] != NULL) { + action_Recent_List_QD[drv][i]->setText(QString::fromUtf8(config.recent_quickdisk_path[drv][i])); + //emit action_Recent_List_QD[drive][i]->changed(); + } + } #endif - return 0; + return 0; } void Ui_MainWindow::_open_quick_disk(int drv, const QString fname) { - char path_shadow[_MAX_PATH]; - QString s_name = fname; - int i; - + char path_shadow[_MAX_PATH]; + QString s_name = fname; + int i; #ifdef USE_QD1 - if(fname.length() <= 0) return; -// s_name = fname; - strncpy(path_shadow, s_name.toUtf8().constData(), _MAX_PATH); -// UPDATE_HISTORY(path_shadow, config.recent_quickdisk_path[drv]); - for(i = MAX_HISTORY - 1; i > 0; i--) { - strncpy(config.recent_quickdisk_path[drv][i], config.recent_quickdisk_path[drv][i -1], _MAX_PATH); - } - strncpy(config.recent_quickdisk_path[drv][0], path_shadow, _MAX_PATH); - - strncpy(path_shadow, s_name.toUtf8().constData(), _MAX_PATH); - get_parent_dir(path_shadow); - strncpy(config.initial_quickdisk_dir, path_shadow, _MAX_PATH); - strncpy(path_shadow, s_name.toUtf8().constData(), _MAX_PATH); + if(fname.length() <= 0) return; + // s_name = fname; + strncpy(path_shadow, s_name.toUtf8().constData(), _MAX_PATH); + // UPDATE_HISTORY(path_shadow, config.recent_quickdisk_path[drv]); + for(i = MAX_HISTORY - 1; i > 0; i--) { + strncpy(config.recent_quickdisk_path[drv][i], config.recent_quickdisk_path[drv][i -1], _MAX_PATH); + } + strncpy(config.recent_quickdisk_path[drv][0], path_shadow, _MAX_PATH); + + strncpy(path_shadow, s_name.toUtf8().constData(), _MAX_PATH); + get_parent_dir(path_shadow); + strncpy(config.initial_quickdisk_dir, path_shadow, _MAX_PATH); + strncpy(path_shadow, s_name.toUtf8().constData(), _MAX_PATH); - // Update List - if(emu) { - emu->LockVM(); - emu->open_quickdisk(drv, path_shadow); - emu->UnlockVM(); - } - - for(i = 0; i < MAX_HISTORY; i++) { - if(action_Recent_List_QD[drv][i] != NULL) { -// printf("%s\n", config.recent_quickdisk_path[drv][i]); - action_Recent_List_QD[drv][i]->setText(QString::fromUtf8(config.recent_quickdisk_path[drv][i])); - } - } -// if(emu->is_write_protected_Qd(drv)) { -// actionProtection_ON_QD[drv]->setChecked(true); -// } else { + // Update List + if(emu) { + emu->LockVM(); + emu->open_quickdisk(drv, path_shadow); + emu->UnlockVM(); + } + for(i = 0; i < MAX_HISTORY; i++) { + if(action_Recent_List_QD[drv][i] != NULL) { + // printf("%s\n", config.recent_quickdisk_path[drv][i]); + action_Recent_List_QD[drv][i]->setText(QString::fromUtf8(config.recent_quickdisk_path[drv][i])); + } + } + // if(emu->is_write_protected_Qd(drv)) { + // actionProtection_ON_QD[drv]->setChecked(true); + // } else { actionProtection_OFF_QD[drv]->setChecked(true); -// } - + // } #endif } @@ -111,13 +106,11 @@ void Ui_MainWindow::_open_quick_disk(int drv, const QString fname) void Ui_MainWindow::eject_Qd(int drv) { #ifdef USE_QD1 - if(emu) { - emu->LockVM(); - emu->close_quickdisk(drv); - emu->UnlockVM(); - } - + if(emu) { + emu->LockVM(); + emu->close_quickdisk(drv); + emu->UnlockVM(); + } #endif } -QT_END_NAMESPACE -- 2.11.0