diff options
author | andreasnaive <andreasnaive@gmail.com> | 2019-03-25 23:13:40 +0100 |
---|---|---|
committer | andreasnaive <andreasnaive@gmail.com> | 2019-03-25 23:13:40 +0100 |
commit | b380514764cf857469bae61c11143a19f79a74c5 (patch) | |
tree | 63c8012e262618f08a332da31dd714281aa2c5ed /src/osd | |
parent | c24473ddff715ecec2e258a6eb38960cf8c8e98e (diff) |
Revert "conflict resolution (nw)"
This reverts commit c24473ddff715ecec2e258a6eb38960cf8c8e98e, reversing
changes made to 009cba4fb8102102168ef32870892438327f3705.
Diffstat (limited to 'src/osd')
25 files changed, 166 insertions, 563 deletions
diff --git a/src/osd/eigccx86.h b/src/osd/eigccx86.h index 3c8f63aa47e..b3831d21524 100644 --- a/src/osd/eigccx86.h +++ b/src/osd/eigccx86.h @@ -456,40 +456,6 @@ _recip_approx(float value) #endif -/*------------------------------------------------- - mul_64x64 - perform a signed 64 bit x 64 bit - multiply and return the full 128 bit result --------------------------------------------------*/ - -#ifdef __x86_64__ -#define mul_64x64 _mul_64x64 -inline int64_t ATTR_FORCE_INLINE -_mul_64x64(int64_t a, int64_t b, int64_t *hi) -{ - __int128 const r(__int128(a) * b); - *hi = int64_t(uint64_t((unsigned __int128)r >> 64)); - return int64_t(uint64_t((unsigned __int128)r)); -} -#endif - - -/*------------------------------------------------- - mulu_64x64 - perform an unsigned 64 bit x 64 - bit multiply and return the full 128 bit result --------------------------------------------------*/ - -#ifdef __x86_64__ -#define mulu_64x64 _mulu_64x64 -inline uint64_t ATTR_FORCE_INLINE -_mulu_64x64(uint64_t a, uint64_t b, uint64_t *hi) -{ - unsigned __int128 const r((unsigned __int128)a * b); - *hi = uint64_t(r >> 64); - return uint64_t(r); -} -#endif - - /*************************************************************************** INLINE BIT MANIPULATION FUNCTIONS diff --git a/src/osd/eivcx86.h b/src/osd/eivcx86.h index 3fd3e70948c..f913ac94624 100644 --- a/src/osd/eivcx86.h +++ b/src/osd/eivcx86.h @@ -403,24 +403,4 @@ static inline float _recip_approx(float z) } #endif - -/*------------------------------------------------- - mul_64x64 - perform a signed 64 bit x 64 bit - multiply and return the full 128 bit result --------------------------------------------------*/ - -#ifdef PTR64 -#define mul_64x64 _mul128 -#endif - - -/*------------------------------------------------- - mulu_64x64 - perform an unsigned 64 bit x 64 - bit multiply and return the full 128 bit result --------------------------------------------------*/ - -#ifdef PTR64 -#define mulu_64x64 _umul128 -#endif - #endif // MAME_OSD_EIVCX86_H diff --git a/src/osd/eminline.h b/src/osd/eminline.h index eb8ffaa9748..bb0aec63468 100644 --- a/src/osd/eminline.h +++ b/src/osd/eminline.h @@ -260,64 +260,6 @@ inline float recip_approx(float value) #endif -/*------------------------------------------------- - mul_64x64 - perform a signed 64 bit x 64 bit - multiply and return the full 128 bit result --------------------------------------------------*/ - -#ifndef mul_64x64 -inline int64_t mul_64x64(int64_t a, int64_t b, int64_t *hi) -{ - uint64_t const a_hi = uint64_t(a) >> 32; - uint64_t const b_hi = uint64_t(b) >> 32; - uint64_t const a_lo = uint32_t(uint64_t(a)); - uint64_t const b_lo = uint32_t(uint64_t(b)); - - uint64_t const ab_lo = a_lo * b_lo; - uint64_t const ab_m1 = a_hi * b_lo; - uint64_t const ab_m2 = a_lo * b_hi; - uint64_t const ab_hi = a_hi * b_hi; - uint64_t const carry = ((ab_lo >> 32) + uint32_t(ab_m1) + uint32_t(ab_m2)) >> 32; - - *hi = ab_hi + (ab_m1 >> 32) + (ab_m2 >> 32) + carry; - - // adjust for sign - if (a < 0) - *hi -= b; - if (b < 0) - *hi -= a; - - return ab_lo + (ab_m1 << 32) + (ab_m2 << 32); -} -#endif - - -/*------------------------------------------------- - mulu_64x64 - perform an unsigned 64 bit x 64 - bit multiply and return the full 128 bit result --------------------------------------------------*/ - -#ifndef mulu_64x64 -inline uint64_t mulu_64x64(uint64_t a, uint64_t b, uint64_t *hi) -{ - uint64_t const a_hi = uint32_t(a >> 32); - uint64_t const b_hi = uint32_t(b >> 32); - uint64_t const a_lo = uint32_t(a); - uint64_t const b_lo = uint32_t(b); - - uint64_t const ab_lo = a_lo * b_lo; - uint64_t const ab_m1 = a_hi * b_lo; - uint64_t const ab_m2 = a_lo * b_hi; - uint64_t const ab_hi = a_hi * b_hi; - uint64_t const carry = ((ab_lo >> 32) + uint32_t(ab_m1) + uint32_t(ab_m2)) >> 32; - - *hi = ab_hi + (ab_m1 >> 32) + (ab_m2 >> 32) + carry; - - return ab_lo + (ab_m1 << 32) + (ab_m2 << 32); -} -#endif - - /*************************************************************************** INLINE BIT MANIPULATION FUNCTIONS diff --git a/src/osd/modules/debugger/qt/debuggerview.cpp b/src/osd/modules/debugger/qt/debuggerview.cpp index 7dc16c0a3de..71a736f6bb7 100644 --- a/src/osd/modules/debugger/qt/debuggerview.cpp +++ b/src/osd/modules/debugger/qt/debuggerview.cpp @@ -241,7 +241,7 @@ void DebuggerView::mousePressEvent(QMouseEvent* event) { QFontMetrics actualFont = fontMetrics(); const double fontWidth = actualFont.width(QString(100, '_')) / 100.; - const int fontHeight = std::max(1, actualFont.lineSpacing()); + const int fontHeight = std::max(1, actualFont.height()); debug_view_xy topLeft = m_view->visible_position(); debug_view_xy clickViewPosition; diff --git a/src/osd/modules/debugger/qt/memorywindow.cpp b/src/osd/modules/debugger/qt/memorywindow.cpp index c799ab66c65..19e3dee6785 100644 --- a/src/osd/modules/debugger/qt/memorywindow.cpp +++ b/src/osd/modules/debugger/qt/memorywindow.cpp @@ -329,7 +329,7 @@ void DebuggerMemView::mousePressEvent(QMouseEvent* event) { QFontMetrics actualFont = fontMetrics(); const double fontWidth = actualFont.width(QString(100, '_')) / 100.; - const int fontHeight = std::max(1, actualFont.lineSpacing()); + const int fontHeight = std::max(1, actualFont.height()); debug_view_xy topLeft = view()->visible_position(); debug_view_xy clickViewPosition; diff --git a/src/osd/modules/input/input_common.cpp b/src/osd/modules/input/input_common.cpp index ab51b6bbe34..7c952ac05a4 100644 --- a/src/osd/modules/input/input_common.cpp +++ b/src/osd/modules/input/input_common.cpp @@ -34,8 +34,8 @@ #elif defined(OSD_SDL) // SDL include #include <SDL2/SDL.h> -#define KEY_TRANS_ENTRY0(mame, sdlsc, sdlkey, disc, virtual, uwp, ascii, UI) { ITEM_ID_##mame, SDL_SCANCODE_ ## sdlsc, ascii, "ITEM_ID_"#mame, (char *) UI } -#define KEY_TRANS_ENTRY1(mame, sdlsc, sdlkey, disc, virtual, uwp, ascii) { ITEM_ID_##mame, SDL_SCANCODE_ ## sdlsc, ascii, "ITEM_ID_"#mame, (char*) #mame } +#define KEY_TRANS_ENTRY0(mame, sdlsc, sdlkey, disc, virtual, uwp, ascii, UI) { ITEM_ID_##mame, SDL_SCANCODE_ ## sdlsc, SDLK_ ## sdlkey, ascii, "ITEM_ID_"#mame, (char *) UI } +#define KEY_TRANS_ENTRY1(mame, sdlsc, sdlkey, disc, virtual, uwp, ascii) { ITEM_ID_##mame, SDL_SCANCODE_ ## sdlsc, SDLK_ ## sdlkey, ascii, "ITEM_ID_"#mame, (char*) #mame } #elif defined(OSD_UWP) #define KEY_TRANS_ENTRY0(mame, sdlsc, sdlkey, disc, virtual, uwp, ascii, UI) { ITEM_ID_##mame, KEY_ ## disc, Windows::System::VirtualKey:: ## uwp, ascii, "ITEM_ID_"#mame, (char *) UI } #define KEY_TRANS_ENTRY1(mame, sdlsc, sdlkey, disc, virtual, uwp, ascii) { ITEM_ID_##mame, KEY_ ## disc, Windows::System::VirtualKey:: ## uwp, ascii, "ITEM_ID_"#mame, (char*) #mame } @@ -43,8 +43,6 @@ // osd mini #endif -// FIXME: sdl_key can be removed from the table below. It is no longer used. - #if defined(OSD_WINDOWS) || defined(OSD_SDL) || defined(OSD_UWP) key_trans_entry keyboard_trans_table::s_default_table[] = { diff --git a/src/osd/modules/input/input_common.h b/src/osd/modules/input/input_common.h index b4005a6b76a..96a197f2543 100644 --- a/src/osd/modules/input/input_common.h +++ b/src/osd/modules/input/input_common.h @@ -358,6 +358,7 @@ struct key_trans_entry { #if defined(OSD_SDL) int sdl_scancode; + int sdl_key; #elif defined(OSD_WINDOWS) int scan_code; unsigned char virtual_key; diff --git a/src/osd/modules/input/input_sdl.cpp b/src/osd/modules/input/input_sdl.cpp index 40fe037f8c7..35dc665f8e2 100644 --- a/src/osd/modules/input/input_sdl.cpp +++ b/src/osd/modules/input/input_sdl.cpp @@ -63,265 +63,24 @@ struct key_lookup_table static key_lookup_table sdl_lookup_table[] = { - KE(UNKNOWN) - - KE(A) - KE(B) - KE(C) - KE(D) - KE(E) - KE(F) - KE(G) - KE(H) - KE(I) - KE(J) - KE(K) - KE(L) - KE(M) - KE(N) - KE(O) - KE(P) - KE(Q) - KE(R) - KE(S) - KE(T) - KE(U) - KE(V) - KE(W) - KE(X) - KE(Y) - KE(Z) - - KE(1) - KE(2) - KE(3) - KE(4) - KE(5) - KE(6) - KE(7) - KE(8) - KE(9) - KE(0) - - KE(RETURN) - KE(ESCAPE) - KE(BACKSPACE) - KE(TAB) + KE7(UNKNOWN, BACKSPACE, TAB, CLEAR, RETURN, PAUSE, ESCAPE) KE(SPACE) - - KE(MINUS) - KE(EQUALS) - KE(LEFTBRACKET) - KE(RIGHTBRACKET) - KE(BACKSLASH) - KE(NONUSHASH) - KE(SEMICOLON) - KE(APOSTROPHE) - KE(GRAVE) - KE(COMMA) - KE(PERIOD) - KE(SLASH) - - KE(CAPSLOCK) - - KE(F1) - KE(F2) - KE(F3) - KE(F4) - KE(F5) - KE(F6) - KE(F7) - KE(F8) - KE(F9) - KE(F10) - KE(F11) - KE(F12) - - KE(PRINTSCREEN) - KE(SCROLLLOCK) - KE(PAUSE) - KE(INSERT) - KE(HOME) - KE(PAGEUP) - KE(DELETE) - KE(END) - KE(PAGEDOWN) - KE(RIGHT) - KE(LEFT) - KE(DOWN) - KE(UP) - - KE(NUMLOCKCLEAR) - KE(KP_DIVIDE) - KE(KP_MULTIPLY) - KE(KP_MINUS) - KE(KP_PLUS) - KE(KP_ENTER) - KE(KP_1) - KE(KP_2) - KE(KP_3) - KE(KP_4) - KE(KP_5) - KE(KP_6) - KE(KP_7) - KE(KP_8) - KE(KP_9) - KE(KP_0) - KE(KP_PERIOD) - - KE(NONUSBACKSLASH) - KE(APPLICATION) - KE(POWER) - KE(KP_EQUALS) - KE(F13) - KE(F14) - KE(F15) - KE(F16) - KE(F17) - KE(F18) - KE(F19) - KE(F20) - KE(F21) - KE(F22) - KE(F23) - KE(F24) - KE(EXECUTE) - KE(HELP) - KE(MENU) - KE(SELECT) - KE(STOP) - KE(AGAIN) + KE5(COMMA, MINUS, PERIOD, SLASH, 0) + KE8(1, 2, 3, 4, 5, 6, 7, 8) + KE3(9, SEMICOLON, EQUALS) + KE5(LEFTBRACKET,BACKSLASH, RIGHTBRACKET, A, B) + KE8(C, D, E, F, G, H, I, J) + KE8(K, L, M, N, O, P, Q, R) + KE8(S, T, U, V, W, X, Y, Z) + KE8(DELETE, KP_0, KP_1, KP_2, KP_3, KP_4, KP_5, KP_6) + KE8(KP_7, KP_8, KP_9, KP_PERIOD, KP_DIVIDE, KP_MULTIPLY,KP_MINUS, KP_PLUS) + KE8(KP_ENTER, KP_EQUALS, UP, DOWN, RIGHT, LEFT, INSERT, HOME) + KE8(END, PAGEUP, PAGEDOWN, F1, F2, F3, F4, F5) + KE8(F6, F7, F8, F9, F10, F11, F12, F13) + KE8(F14, F15, NUMLOCKCLEAR, CAPSLOCK, SCROLLLOCK, RSHIFT, LSHIFT, RCTRL) + KE5(LCTRL, RALT, LALT, LGUI, RGUI) + KE8(GRAVE, LEFTBRACKET,RIGHTBRACKET, SEMICOLON, APOSTROPHE, BACKSLASH, PRINTSCREEN,MENU) KE(UNDO) - KE(CUT) - KE(COPY) - KE(PASTE) - KE(FIND) - KE(MUTE) - KE(VOLUMEUP) - KE(VOLUMEDOWN) - KE(KP_COMMA) - KE(KP_EQUALSAS400) - - KE(INTERNATIONAL1) - KE(INTERNATIONAL2) - KE(INTERNATIONAL3) - KE(INTERNATIONAL4) - KE(INTERNATIONAL5) - KE(INTERNATIONAL6) - KE(INTERNATIONAL7) - KE(INTERNATIONAL8) - KE(INTERNATIONAL9) - KE(LANG1) - KE(LANG2) - KE(LANG3) - KE(LANG4) - KE(LANG5) - KE(LANG6) - KE(LANG7) - KE(LANG8) - KE(LANG9) - - KE(ALTERASE) - KE(SYSREQ) - KE(CANCEL) - KE(CLEAR) - KE(PRIOR) - KE(RETURN2) - KE(SEPARATOR) - KE(OUT) - KE(OPER) - KE(CLEARAGAIN) - KE(CRSEL) - KE(EXSEL) - - KE(KP_00) - KE(KP_000) - KE(THOUSANDSSEPARATOR) - KE(DECIMALSEPARATOR) - KE(CURRENCYUNIT) - KE(CURRENCYSUBUNIT) - KE(KP_LEFTPAREN) - KE(KP_RIGHTPAREN) - KE(KP_LEFTBRACE) - KE(KP_RIGHTBRACE) - KE(KP_TAB) - KE(KP_BACKSPACE) - KE(KP_A) - KE(KP_B) - KE(KP_C) - KE(KP_D) - KE(KP_E) - KE(KP_F) - KE(KP_XOR) - KE(KP_POWER) - KE(KP_PERCENT) - KE(KP_LESS) - KE(KP_GREATER) - KE(KP_AMPERSAND) - KE(KP_DBLAMPERSAND) - KE(KP_VERTICALBAR) - KE(KP_DBLVERTICALBAR) - KE(KP_COLON) - KE(KP_HASH) - KE(KP_SPACE) - KE(KP_AT) - KE(KP_EXCLAM) - KE(KP_MEMSTORE) - KE(KP_MEMRECALL) - KE(KP_MEMCLEAR) - KE(KP_MEMADD) - KE(KP_MEMSUBTRACT) - KE(KP_MEMMULTIPLY) - KE(KP_MEMDIVIDE) - KE(KP_PLUSMINUS) - KE(KP_CLEAR) - KE(KP_CLEARENTRY) - KE(KP_BINARY) - KE(KP_OCTAL) - KE(KP_DECIMAL) - KE(KP_HEXADECIMAL) - - KE(LCTRL) - KE(LSHIFT) - KE(LALT) - KE(LGUI) - KE(RCTRL) - KE(RSHIFT) - KE(RALT) - KE(RGUI) - - KE(MODE) - KE(AUDIONEXT) - KE(AUDIOPREV) - KE(AUDIOSTOP) - KE(AUDIOPLAY) - KE(AUDIOMUTE) - KE(MEDIASELECT) - KE(WWW) - KE(MAIL) - KE(CALCULATOR) - KE(COMPUTER) - KE(AC_SEARCH) - KE(AC_HOME) - KE(AC_BACK) - KE(AC_FORWARD) - KE(AC_STOP) - KE(AC_REFRESH) - KE(AC_BOOKMARKS) - - KE(BRIGHTNESSDOWN) - KE(BRIGHTNESSUP) - KE(DISPLAYSWITCH) - KE(KBDILLUMTOGGLE) - KE(KBDILLUMDOWN) - KE(KBDILLUMUP) - KE(EJECT) - KE(SLEEP) - - KE(APP1) - KE(APP2) - - { -1, "" } @@ -367,6 +126,7 @@ protected: // sdl_keyboard_device //============================================================ +#define OSD_SDL_INDEX_KEYSYM(keysym) ((keysym)->scancode) class sdl_keyboard_device : public sdl_device { public: @@ -383,13 +143,13 @@ public: switch (sdlevent.type) { case SDL_KEYDOWN: - keyboard.state[sdlevent.key.keysym.scancode] = 0x80; + keyboard.state[OSD_SDL_INDEX_KEYSYM(&sdlevent.key.keysym)] = 0x80; if (sdlevent.key.keysym.sym < 0x20) machine().ui_input().push_char_event(osd_common_t::s_window_list.front()->target(), sdlevent.key.keysym.sym); break; case SDL_KEYUP: - keyboard.state[sdlevent.key.keysym.scancode] = 0x00; + keyboard.state[OSD_SDL_INDEX_KEYSYM(&sdlevent.key.keysym)] = 0x00; break; case SDL_TEXTINPUT: @@ -807,6 +567,11 @@ private: char *keymap_filename; FILE *keymap_file; int line = 1; + int index, len, sk, vk, ak; + char buf[256]; + char mks[41]; + char sks[41]; + char kns[41]; int sdl2section = 0; keyboard_trans_table &default_table = keyboard_trans_table::instance(); @@ -836,42 +601,41 @@ private: while (!feof(keymap_file)) { - char buf[256]; - char *ret = fgets(buf, 255, keymap_file); if (ret && buf[0] != '\n' && buf[0] != '#') { buf[255] = 0; - int len = strlen(buf); + len = strlen(buf); if (len && buf[len - 1] == '\n') buf[len - 1] = 0; if (strncmp(buf, "[SDL2]", 6) == 0) { sdl2section = 1; } - else if (sdl2section == 1) + else if (((SDLMAME_SDL2) ^ sdl2section) == 0) { - char mks[41] = {0}; - char sks[41] = {0}; - char kns[41] = {0}; - - int n = sscanf(buf, "%40s %40s %40c\n", mks, sks, kns); - if (n != 3) - osd_printf_error("Keymap: Error on line %d : Expected 3 parameters, got %d\n", line, n); + mks[0] = 0; + sks[0] = 0; + memset(kns, 0, ARRAY_LENGTH(kns)); + sscanf(buf, "%40s %40s %x %x %40c\n", + mks, sks, &vk, &ak, kns); - int index = default_table.lookup_mame_index(mks); - int sk = lookup_sdl_code(sks); + index = default_table.lookup_mame_index(mks); + sk = lookup_sdl_code(sks); if (sk >= 0 && index >= 0) { key_trans_entry &entry = (*custom_table)[index]; - entry.sdl_scancode = sk; + entry.sdl_key = sk; + // vk and ak are not really needed + //key_trans_table[index][VIRTUAL_KEY] = vk; + //key_trans_table[index][ASCII_KEY] = ak; entry.ui_name = auto_alloc_array(machine, char, strlen(kns) + 1); strcpy(entry.ui_name, kns); osd_printf_verbose("Keymap: Mapped <%s> to <%s> with ui-text <%s>\n", sks, mks, kns); } else - osd_printf_error("Keymap: Error on line %d - %s key not found: %s\n", line, (sk<0) ? "sdl" : "mame", buf); + osd_printf_warning("Keymap: Error on line %d - %s key not found: %s\n", line, (sk<0) ? "sdl" : "mame", buf); } } line++; diff --git a/src/osd/modules/input/input_x11.cpp b/src/osd/modules/input/input_x11.cpp index f7c48a10d87..0762b5ae35d 100644 --- a/src/osd/modules/input/input_x11.cpp +++ b/src/osd/modules/input/input_x11.cpp @@ -401,23 +401,7 @@ public: else if (xevent.type == button_press_type || xevent.type == button_release_type) { XDeviceButtonEvent *button = reinterpret_cast<XDeviceButtonEvent *>(&xevent); - - /* - * SDL/X11 Number the buttons 1,2,3, while windows and other parts of MAME - * like offscreen_reload expect 0,2,1. Transpose buttons 2 and 3, and then - * -1 the button number to align the numbering schemes. - */ - int button_number = button->button; - switch (button_number) - { - case 2: - button_number = 3; - break; - case 3: - button_number = 2; - break; - } - lightgun.buttons[button_number - 1] = (xevent.type == button_press_type) ? 0x80 : 0; + lightgun.buttons[button->button] = (xevent.type == button_press_type) ? 0x80 : 0; } } diff --git a/src/osd/modules/lib/osdobj_common.cpp b/src/osd/modules/lib/osdobj_common.cpp index d3f5f35192e..3cb67e6ded4 100644 --- a/src/osd/modules/lib/osdobj_common.cpp +++ b/src/osd/modules/lib/osdobj_common.cpp @@ -163,7 +163,7 @@ const options_entry osd_options::s_option_entries[] = }; osd_options::osd_options() - : emu_options() +: emu_options() { add_entries(osd_options::s_option_entries); } @@ -176,20 +176,20 @@ std::list<std::shared_ptr<osd_window>> osd_common_t::s_window_list; //------------------------------------------------- osd_common_t::osd_common_t(osd_options &options) - : osd_output(), m_machine(nullptr) - , m_options(options) - , m_print_verbose(false) - , m_font_module(nullptr) - , m_sound(nullptr) - , m_debugger(nullptr) - , m_midi(nullptr) - , m_keyboard_input(nullptr) - , m_mouse_input(nullptr) - , m_lightgun_input(nullptr) - , m_joystick_input(nullptr) - , m_output(nullptr) - , m_monitor_module(nullptr) - , m_watchdog(nullptr) + : osd_output(), m_machine(nullptr), + m_options(options), + m_print_verbose(false), + m_font_module(nullptr), + m_sound(nullptr), + m_debugger(nullptr), + m_midi(nullptr), + m_keyboard_input(nullptr), + m_mouse_input(nullptr), + m_lightgun_input(nullptr), + m_joystick_input(nullptr), + m_output(nullptr), + m_monitor_module(nullptr), + m_watchdog(nullptr) { osd_output::push(this); } @@ -409,6 +409,7 @@ void osd_common_t::output_callback(osd_output_channel channel, const char *msg, void osd_common_t::init(running_machine &machine) { + // // This function is responsible for initializing the OSD-specific // video and input functionality, and registering that functionality // with the MAME core. @@ -436,6 +437,7 @@ void osd_common_t::init(running_machine &machine) // // Audio initialization may eventually move into here as well, // instead of relying on independent callbacks from each system. + // m_machine = &machine; diff --git a/src/osd/modules/lib/osdobj_common.h b/src/osd/modules/lib/osdobj_common.h index af4d2d332bc..8c275ebf48d 100644 --- a/src/osd/modules/lib/osdobj_common.h +++ b/src/osd/modules/lib/osdobj_common.h @@ -245,12 +245,11 @@ public: // osd_output interface ... virtual void output_callback(osd_output_channel channel, const char *msg, va_list args) override; bool verbose() const { return m_print_verbose; } - virtual void set_verbose(bool print_verbose) override { m_print_verbose = print_verbose; } + void set_verbose(bool print_verbose) { m_print_verbose = print_verbose; } void notify(const char *outname, int32_t value) const { m_output->notify(outname, value); } static std::list<std::shared_ptr<osd_window>> s_window_list; - protected: virtual bool input_init(); virtual void input_pause(); diff --git a/src/osd/modules/osdhelper.h b/src/osd/modules/osdhelper.h index 093c392e249..463d8cdfb48 100644 --- a/src/osd/modules/osdhelper.h +++ b/src/osd/modules/osdhelper.h @@ -6,23 +6,23 @@ // //============================================================ -#ifndef MAME_OSD_MODULES_OSDHELPER_H -#define MAME_OSD_MODULES_OSDHELPER_H - #pragma once +#ifndef __OSDHELPER__ +#define __OSDHELPER__ + class osd_dim { public: - constexpr osd_dim() : m_w(0), m_h(0) { } - constexpr osd_dim(int w, int h) : m_w(w), m_h(h) { } - - constexpr int width() const { return m_w; } - constexpr int height() const { return m_h; } - - constexpr bool operator!=(const osd_dim &other) { return (m_w != other.width()) || (m_h != other.height()); } - constexpr bool operator==(const osd_dim &other) { return (m_w == other.width()) && (m_h == other.height()); } + osd_dim(const int &w, const int &h) + : m_w(w), m_h(h) + { + } + int width() const { return m_w; } + int height() const { return m_h; } + bool operator!=(const osd_dim &other) { return (m_w != other.width()) || (m_h != other.height()); } + bool operator==(const osd_dim &other) { return (m_w == other.width()) && (m_h == other.height()); } private: int m_w; int m_h; @@ -31,25 +31,30 @@ private: class osd_rect { public: - constexpr osd_rect() : m_x(0), m_y(0), m_d(0, 0) { } - constexpr osd_rect(int x, int y, int w, int h) : m_x(x), m_y(y), m_d(w, h) { } - constexpr osd_rect(int x, int y, const osd_dim &d) : m_x(x), m_y(y), m_d(d) { } - - constexpr int left() const { return m_x; } - constexpr int top() const { return m_y; } - constexpr int width() const { return m_d.width(); } - constexpr int height() const { return m_d.height(); } - - constexpr osd_dim dim() const { return m_d; } + osd_rect() + : m_x(0), m_y(0), m_d(0,0) + { + } + osd_rect(const int x, const int y, const int &w, const int &h) + : m_x(x), m_y(y), m_d(w,h) + { + } + osd_rect(const int x, const int y, const osd_dim &d) + : m_x(x), m_y(y), m_d(d) + { + } + int top() const { return m_y; } + int left() const { return m_x; } + int width() const { return m_d.width(); } + int height() const { return m_d.height(); } - constexpr int right() const { return m_x + m_d.width(); } - constexpr int bottom() const { return m_y + m_d.height(); } + osd_dim dim() const { return m_d; } - constexpr osd_rect move_by(int dx, int dy) const { return osd_rect(m_x + dx, m_y + dy, m_d); } - constexpr osd_rect resize(int w, int h) const { return osd_rect(m_x, m_y, w, h); } + int bottom() const { return m_y + m_d.height(); } + int right() const { return m_x + m_d.width(); } - constexpr bool operator!=(const osd_rect &other) { return (m_x != other.left()) || (m_y != other.top()) || (m_d != other.dim()); } - constexpr bool operator==(const osd_rect &other) { return (m_x == other.left()) && (m_y == other.top()) && (m_d == other.dim()); } + osd_rect move_by(int dx, int dy) const { return osd_rect(m_x + dx, m_y + dy, m_d); } + osd_rect resize(int w, int h) const { return osd_rect(m_x, m_y, w, h); } private: int m_x; @@ -57,4 +62,4 @@ private: osd_dim m_d; }; -#endif // MAME_OSD_MODULES_OSDHELPER_H +#endif // __OSDHELPER__ diff --git a/src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_chroma.sc b/src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_chroma.sc index 51bb14676d3..b76370c0aa9 100644 --- a/src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_chroma.sc +++ b/src/osd/modules/render/bgfx/shaders/chains/hlsl/fs_chroma.sc @@ -23,9 +23,9 @@ void main() vec4 cout = vec4(0.0, 0.0, 0.0, cin.a); mat3 xy = mat3(u_chroma_a.xyz, u_chroma_b.xyz, u_chroma_c.xyz); const mat3 XYZ_TO_sRGB = mat3( - 3.2406, -0.9689, 0.0557, - -1.5372, 1.8758, -0.2040, - -0.4986, 0.0415, 1.0570 + 3.2406, -1.5372, -0.4986, + -0.9689, 1.8758, 0.0415, + 0.0557, -0.2040, 1.0570 ); for (int i = 0; i < 3; ++i) { diff --git a/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv3-noblend.sc b/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv3-noblend.sc index 554c222db47..8d65128f8fc 100644 --- a/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv3-noblend.sc +++ b/src/osd/modules/render/bgfx/shaders/chains/xbr/fs_xbr-lv3-noblend.sc @@ -166,11 +166,11 @@ void main() // It uses CORNER_C if none of the others are defined. #ifdef CORNER_A vec4 interp_restriction_lv1 = interp_restriction_lv0; -#elif defined(CORNER_B) +#elif CORNER_B vec4 interp_restriction_lv1 = (interp_restriction_lv0 * (neq(f,b) * neq(h,d) + eq(e,i) * neq(f,i4) * neq(h,i5) + eq(e,g) + eq(e,c))); -#elif defined(CORNER_D) +#elif CORNER_D vec4 interp_restriction_lv1 = (interp_restriction_lv0 * (neq(f,b) * neq(h,d) + eq(e,i) * neq(f,i4) * neq(h,i5) + eq(e,g) + eq(e,c)) * (vec4(notEqual(f,f4)) * vec4(notEqual(f,i)) + vec4(notEqual(h,h5)) * vec4(notEqual(h,i)) + vec4(notEqual(h,g)) + vec4(notEqual(f,c)) + eq(b,c1) * eq(d,g0))); -#elif defined(CORNER_C) +#elif CORNER_C vec4 interp_restriction_lv1 = (interp_restriction_lv0 * (neq(f,b) * neq(f,c) + neq(h,d) * neq(h,g) + eq(e,i) * (neq(f,f4) * neq(f,i4) + neq(h,h5) * neq(h,i5)) + eq(e,g) + eq(e,c))); #endif diff --git a/src/osd/modules/render/bgfx/shaders/shader.mk b/src/osd/modules/render/bgfx/shaders/shader.mk index e7db3cdc242..84035e255fa 100644 --- a/src/osd/modules/render/bgfx/shaders/shader.mk +++ b/src/osd/modules/render/bgfx/shaders/shader.mk @@ -1,5 +1,5 @@ # -# Copyright 2011-2019 Branimir Karadzic. All rights reserved. +# Copyright 2011-2018 Branimir Karadzic. All rights reserved. # License: http://www.opensource.org/licenses/BSD-2-Clause # diff --git a/src/osd/modules/render/drawogl.cpp b/src/osd/modules/render/drawogl.cpp index 95345878cfd..98db62fdf1f 100644 --- a/src/osd/modules/render/drawogl.cpp +++ b/src/osd/modules/render/drawogl.cpp @@ -2056,9 +2056,8 @@ static inline void copyline_palette16(uint32_t *dst, const uint16_t *src, int wi for (x = 0; x < width; x++) { int srcpix = *src++; - uint32_t dstval = 0xff000000 | palette[srcpix]; for (int x2 = 0; x2 < xprescale; x2++) - *dst++ = dstval; + *dst++ = 0xff000000 | palette[srcpix]; } if (xborderpix) *dst++ = 0xff000000 | palette[*--src]; @@ -2080,9 +2079,8 @@ static inline void copyline_palettea16(uint32_t *dst, const uint16_t *src, int w for (x = 0; x < width; x++) { int srcpix = *src++; - uint32_t dstval = palette[srcpix]; for (int x2 = 0; x2 < xprescale; x2++) - *dst++ = dstval; + *dst++ = palette[srcpix]; } if (xborderpix) *dst++ = palette[*--src]; @@ -2111,9 +2109,10 @@ static inline void copyline_rgb32(uint32_t *dst, const uint32_t *src, int width, for (x = 0; x < width; x++) { rgb_t srcpix = *src++; - uint32_t dstval = 0xff000000 | palette[0x200 + srcpix.r()] | palette[0x100 + srcpix.g()] | palette[srcpix.b()]; for (int x2 = 0; x2 < xprescale; x2++) - *dst++ = dstval; + { + *dst++ = 0xff000000 | palette[0x200 + srcpix.r()] | palette[0x100 + srcpix.g()] | palette[srcpix.b()]; + } } if (xborderpix) { @@ -2130,9 +2129,11 @@ static inline void copyline_rgb32(uint32_t *dst, const uint32_t *src, int width, for (x = 0; x < width; x++) { rgb_t srcpix = *src++; - uint32_t dstval = 0xff000000 | srcpix; + for (int x2 = 0; x2 < xprescale; x2++) - *dst++ = dstval; + { + *dst++ = 0xff000000 | srcpix; + } } if (xborderpix) *dst++ = 0xff000000 | *--src; @@ -2160,9 +2161,8 @@ static inline void copyline_argb32(uint32_t *dst, const uint32_t *src, int width for (x = 0; x < width; x++) { rgb_t srcpix = *src++; - uint32_t dstval = (srcpix & 0xff000000) | palette[0x200 + srcpix.r()] | palette[0x100 + srcpix.g()] | palette[srcpix.b()]; for (int x2 = 0; x2 < xprescale; x2++) - *dst++ = dstval; + *dst++ = (srcpix & 0xff000000) | palette[0x200 + srcpix.r()] | palette[0x100 + srcpix.g()] | palette[srcpix.b()]; } if (xborderpix) { @@ -2257,12 +2257,10 @@ static inline void copyline_yuy16_to_argb(uint32_t *dst, const uint16_t *src, in uint16_t srcpix1 = *src++; uint8_t cb = srcpix0 & 0xff; uint8_t cr = srcpix1 & 0xff; - uint32_t dstval0 = ycc_to_rgb(palette[0x000 + (srcpix0 >> 8)], cb, cr); - uint32_t dstval1 = ycc_to_rgb(palette[0x000 + (srcpix1 >> 8)], cb, cr); for (int x2 = 0; x2 < xprescale; x2++) - *dst++ = dstval0; + *dst++ = ycc_to_rgb(palette[0x000 + (srcpix0 >> 8)], cb, cr); for (int x2 = 0; x2 < xprescale; x2++) - *dst++ = dstval1; + *dst++ = ycc_to_rgb(palette[0x000 + (srcpix1 >> 8)], cb, cr); } if (xborderpix) { @@ -2293,12 +2291,10 @@ static inline void copyline_yuy16_to_argb(uint32_t *dst, const uint16_t *src, in uint16_t srcpix1 = *src++; uint8_t cb = srcpix0 & 0xff; uint8_t cr = srcpix1 & 0xff; - uint32_t dstval0 = ycc_to_rgb(srcpix0 >> 8, cb, cr); - uint32_t dstval1 = ycc_to_rgb(srcpix1 >> 8, cb, cr); for (int x2 = 0; x2 < xprescale; x2++) - *dst++ = dstval0; + *dst++ = ycc_to_rgb(srcpix0 >> 8, cb, cr); for (int x2 = 0; x2 < xprescale; x2++) - *dst++ = dstval1; + *dst++ = ycc_to_rgb(srcpix1 >> 8, cb, cr); } if (xborderpix) { diff --git a/src/osd/modules/sound/sdl_sound.cpp b/src/osd/modules/sound/sdl_sound.cpp index 5ff8f2e6821..a04a44c0298 100644 --- a/src/osd/modules/sound/sdl_sound.cpp +++ b/src/osd/modules/sound/sdl_sound.cpp @@ -46,6 +46,7 @@ public: sound_sdl() : osd_module(OSD_SOUND_PROVIDER, "sdl"), sound_module(), stream_in_initialized(0), + stream_loop(0), attenuation(0), buf_locked(0), stream_buffer(nullptr), stream_buffer_size(0), buffer_underflows(0), buffer_overflows(0) { sdl_xfer_samples = SDL_XFER_SAMPLES; @@ -79,7 +80,7 @@ private: static void sdl_callback(void *userdata, Uint8 *stream, int len); - void lock_buffer(); + int lock_buffer(); void unlock_buffer(); void attenuate(int16_t *data, int bytes); void copy_sample_data(bool is_throttled, const int16_t *data, int bytes_to_copy); @@ -88,6 +89,7 @@ private: int sdl_xfer_samples; int stream_in_initialized; + int stream_loop; int attenuation; int buf_locked; @@ -177,7 +179,7 @@ int sound_sdl::ring_buffer::pop(void *data, size_t size) //============================================================ // lock_buffer //============================================================ -void sound_sdl::lock_buffer() +int sound_sdl::lock_buffer() { if (!buf_locked) SDL_LockAudio(); @@ -185,6 +187,8 @@ void sound_sdl::lock_buffer() if (LOG_SOUND) *sound_log << "locking\n"; + + return 0; } //============================================================ @@ -355,6 +359,7 @@ int sound_sdl::init(const osd_options &options) sdl_xfer_samples = SDL_XFER_SAMPLES; stream_in_initialized = 0; + stream_loop = 0; // set up the audio specs aspec.freq = sample_rate(); diff --git a/src/osd/osdepend.h b/src/osd/osdepend.h index 2587b93e560..07f6ddd99f1 100644 --- a/src/osd/osdepend.h +++ b/src/osd/osdepend.h @@ -7,11 +7,11 @@ OS-dependent code interface. *******************************************************************c********/ -#ifndef MAME_OSD_OSDEPEND_H -#define MAME_OSD_OSDEPEND_H #pragma once +#ifndef MAME_OSD_OSDEPEND_H +#define MAME_OSD_OSDEPEND_H #include "emucore.h" #include "osdcore.h" @@ -64,7 +64,6 @@ public: // general overridables virtual void init(running_machine &machine) = 0; virtual void update(bool skip_redraw) = 0; - virtual void set_verbose(bool print_verbose) = 0; // debugger overridables virtual void init_debugger() = 0; diff --git a/src/osd/sdl/sdlmain.cpp b/src/osd/sdl/sdlmain.cpp index 37d1434a2e8..f7d80a10484 100644 --- a/src/osd/sdl/sdlmain.cpp +++ b/src/osd/sdl/sdlmain.cpp @@ -375,7 +375,6 @@ static void osd_sdl_info(void) void sdl_osd_interface::video_register() { video_options_add("soft", nullptr); - video_options_add("accel", nullptr); #if USE_OPENGL video_options_add("opengl", nullptr); #endif diff --git a/src/osd/windows/video.h b/src/osd/windows/video.h index c012e42af9d..3f4b49efbe4 100644 --- a/src/osd/windows/video.h +++ b/src/osd/windows/video.h @@ -1,29 +1,19 @@ // license:BSD-3-Clause -// copyright-holders:Aaron Giles, Vas Crabb +// copyright-holders:Aaron Giles //============================================================ // -// video.h - Win32 video helpers +// video.h - Win32 implementation of MAME video routines // //============================================================ -#ifndef MAME_OSD_WINDOWS_VIDEO_H -#define MAME_OSD_WINDOWS_VIDEO_H -#pragma once +#ifndef __WIN_VIDEO__ +#define __WIN_VIDEO__ #include "modules/osdhelper.h" -#include <windows.h> - - -constexpr osd_rect RECT_to_osd_rect(RECT const &r) +inline osd_rect RECT_to_osd_rect(const RECT &r) { return osd_rect(r.left, r.top, r.right - r.left, r.bottom - r.top); } -inline RECT osd_rect_to_RECT(osd_rect const &r) -{ - RECT const result{ r.left(), r.top(), r.right(), r.bottom() }; - return result; -} - -#endif // MAME_OSD_WINDOWS_VIDEO_H +#endif diff --git a/src/osd/windows/window.cpp b/src/osd/windows/window.cpp index d331ec3f4d8..c3376b2fb0c 100644 --- a/src/osd/windows/window.cpp +++ b/src/osd/windows/window.cpp @@ -15,7 +15,6 @@ #include <process.h> #include <atomic> -#include <cstring> #include <chrono> #include <list> #include <memory> @@ -1664,7 +1663,7 @@ void win_window_info::minimize_window() RECT bounds; GetWindowRect(platform_window(), &bounds); - osd_rect newrect(bounds.left, bounds.top, newsize); + osd_rect newrect(bounds.left, bounds.top, newsize ); SetWindowPos(platform_window(), nullptr, newrect.left(), newrect.top(), newrect.width(), newrect.height(), SWP_NOZORDER); @@ -1716,35 +1715,17 @@ void win_window_info::adjust_window_position_after_major_change() if (video_config.keepaspect) newrect = constrain_to_aspect_ratio(newrect, WMSZ_BOTTOMRIGHT); } + + // in full screen, make sure it covers the primary display else { - // in full screen, make sure it covers the primary display std::shared_ptr<osd_monitor_info> monitor = monitor_from_rect(nullptr); newrect = monitor->position_size(); } - // restrict the window to one monitor and avoid toolbars if possible - HMONITOR const nearest_monitor = MonitorFromWindow(platform_window(), MONITOR_DEFAULTTONEAREST); - if (NULL != nearest_monitor) - { - MONITORINFO info; - std::memset(&info, 0, sizeof(info)); - info.cbSize = sizeof(info); - if (GetMonitorInfo(nearest_monitor, &info)) - { - if (newrect.right() > info.rcWork.right) - newrect = newrect.move_by(info.rcWork.right - newrect.right(), 0); - if (newrect.bottom() > info.rcWork.bottom) - newrect = newrect.move_by(0, info.rcWork.bottom - newrect.bottom()); - if (newrect.left() < info.rcWork.left) - newrect = newrect.move_by(info.rcWork.left - newrect.left(), 0); - if (newrect.top() < info.rcWork.top) - newrect = newrect.move_by(0, info.rcWork.top - newrect.top()); - } - } - // adjust the position if different - if (RECT_to_osd_rect(oldrect) != newrect) + if (oldrect.left != newrect.left() || oldrect.top != newrect.top() || + oldrect.right != newrect.right() || oldrect.bottom != newrect.bottom()) SetWindowPos(platform_window(), fullscreen() ? HWND_TOPMOST : HWND_TOP, newrect.left(), newrect.top(), newrect.width(), newrect.height(), 0); diff --git a/src/osd/windows/winmain.cpp b/src/osd/windows/winmain.cpp index 45d790aea78..9225acc0443 100644 --- a/src/osd/windows/winmain.cpp +++ b/src/osd/windows/winmain.cpp @@ -6,6 +6,20 @@ // //============================================================ +// only for oslog callback +#include <functional> + +// standard windows headers +#include <windows.h> +#include <commctrl.h> +#include <mmsystem.h> +#include <tchar.h> +#include <io.h> + +// standard C headers +#include <ctype.h> +#include <stdarg.h> + // MAME headers #include "emu.h" #include "emuopts.h" @@ -20,18 +34,6 @@ #include "modules/diagnostics/diagnostics_module.h" #include "modules/monitor/monitor_common.h" -// standard C headers -#include <ctype.h> -#include <stdarg.h> -#include <stdio.h> - -// standard windows headers -#include <windows.h> -#include <commctrl.h> -#include <mmsystem.h> -#include <tchar.h> -#include <io.h> - #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) #include <wrl/client.h> using namespace Windows::Storage; @@ -473,8 +475,6 @@ void windows_osd_interface::output_oslog(const char *buffer) { if (IsDebuggerPresent()) win_output_debug_string_utf8(buffer); - else - fputs(buffer, stderr); } @@ -573,7 +573,10 @@ void windows_osd_interface::init(running_machine &machine) // hook up the debugger log if (options.oslog()) - machine.add_logerror_callback(&windows_osd_interface::output_oslog); + { + using namespace std::placeholders; + machine.add_logerror_callback(std::bind(&windows_osd_interface::output_oslog, this, _1)); + } #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) // crank up the multimedia timer resolution to its max diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h index 5fb71fa9286..79e3b023b64 100644 --- a/src/osd/windows/winmain.h +++ b/src/osd/windows/winmain.h @@ -312,7 +312,7 @@ protected: private: virtual void osd_exit() override; - static void output_oslog(const char *buffer); + void output_oslog(const char *buffer); windows_options & m_options; diff --git a/src/osd/windows/winutf8.cpp b/src/osd/windows/winutf8.cpp index a056d694b89..1c076158ebe 100644 --- a/src/osd/windows/winutf8.cpp +++ b/src/osd/windows/winutf8.cpp @@ -6,15 +6,15 @@ // //============================================================ +// standard windows headers +#include <windows.h> +#include <shellapi.h> +#include <stdlib.h> + // MAMEOS headers #include "winutf8.h" #include "strconv.h" -#include <stdlib.h> - -// standard windows headers -#include <shellapi.h> - //============================================================ // win_output_debug_string_utf8 diff --git a/src/osd/windows/winutf8.h b/src/osd/windows/winutf8.h index 1ec5429cfab..a8d072ed2cc 100644 --- a/src/osd/windows/winutf8.h +++ b/src/osd/windows/winutf8.h @@ -6,15 +6,11 @@ // //============================================================ -#ifndef MAME_OSD_WINDOWS_WINUTF8_H -#define MAME_OSD_WINDOWS_WINUTF8_H - -#pragma once +#ifndef __WINUTF8__ +#define __WINUTF8__ #include "osdcore.h" -#include <windows.h> - // wrappers for kernel32.dll void win_output_debug_string_utf8(const char *string); @@ -22,15 +18,8 @@ void win_output_debug_string_utf8(const char *string); int win_message_box_utf8(HWND window, const char *text, const char *caption, UINT type); BOOL win_set_window_text_utf8(HWND window, const char *text); std::string win_get_window_text_utf8(HWND window); -HWND win_create_window_ex_utf8( - DWORD exstyle, - const char *classname, - const char *windowname, - DWORD style, - int x, int y, int width, int height, - HWND wndparent, - HMENU menu, - HINSTANCE instance, - void *param); +HWND win_create_window_ex_utf8(DWORD exstyle, const char* classname, const char* windowname, DWORD style, + int x, int y, int width, int height, HWND wndparent, HMENU menu, + HINSTANCE instance, void* param); -#endif // MAME_OSD_WINDOWS_WINUTF8_H +#endif // __WINUTF8__ |