From 6b9c752850531d3b3a5d039d4b851a539583accb Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Sat, 28 May 2016 15:10:28 +1000 Subject: [PATCH 01/11] misc fixes (nw) * fix a mismatched new[]/delete error in corealloc * _name massacre in corealloc while at it * add template/macro for delaring array with equivalent dimensions --- src/lib/util/corealloc.h | 64 ++++++++++++++++------------------------ src/osd/osdcomm.h | 11 +++++++ src/tools/chdman.cpp | 2 +- 3 files changed, 38 insertions(+), 39 deletions(-) diff --git a/src/lib/util/corealloc.h b/src/lib/util/corealloc.h index b5fc126cba5..12dea2fce67 100644 --- a/src/lib/util/corealloc.h +++ b/src/lib/util/corealloc.h @@ -31,12 +31,12 @@ //************************************************************************** // global allocation helpers -- use these instead of new and delete -#define global_alloc(_type) new _type -#define global_alloc_nothrow(_type) new (std::nothrow) _type -#define global_alloc_array(_type, _num) new _type[_num] -#define global_alloc_array_nothrow(_type, _num) new (std::nothrow) _type[_num] -#define global_free(_ptr) do { delete _ptr; } while (0) -#define global_free_array(_ptr) do { delete[] _ptr; } while (0) +#define global_alloc(Type) new Type +#define global_alloc_nothrow(Type) new (std::nothrow) Type +#define global_alloc_array(Type, Num) new Type[Num] +#define global_alloc_array_nothrow(Type, Num) new (std::nothrow) Type[Num] +#define global_free(Ptr) do { delete Ptr; } while (0) +#define global_free_array(Ptr) do { delete[] Ptr; } while (0) @@ -59,54 +59,42 @@ inline T* global_alloc_array_clear(std::size_t num) -template -struct _MakeUniqClear -{ - typedef std::unique_ptr<_Tp> __single_object; -}; +template struct MakeUniqClearT { typedef std::unique_ptr single_object; }; -template -struct _MakeUniqClear<_Tp[]> -{ - typedef std::unique_ptr<_Tp[]> __array; -}; +template struct MakeUniqClearT { typedef std::unique_ptr array; }; -template -struct _MakeUniqClear<_Tp[_Bound]> -{ - struct __invalid_type { }; -}; +template struct MakeUniqClearT { struct invalid_type { }; }; /// make_unique_clear for single objects -template -inline typename _MakeUniqClear<_Tp>::__single_object make_unique_clear(_Args&&... __args) +template +inline typename MakeUniqClearT::single_object make_unique_clear(Params&&... args) { - unsigned char* ptr = new unsigned char[sizeof(_Tp)]; // allocate memory - memset(ptr, 0, sizeof(_Tp)); - return std::unique_ptr<_Tp>(new(ptr) _Tp(std::forward<_Args>(__args)...)); + void *const ptr = ::operator new(sizeof(Tp)); // allocate memory + std::memset(ptr, 0, sizeof(Tp)); + return std::unique_ptr(new(ptr) Tp(std::forward(args)...)); } /// make_unique_clear for arrays of unknown bound -template -inline typename _MakeUniqClear<_Tp>::__array make_unique_clear(size_t __num) +template +inline typename MakeUniqClearT::array make_unique_clear(size_t num) { - auto size = sizeof(std::remove_extent_t<_Tp>) * __num; + auto size = sizeof(std::remove_extent_t) * num; unsigned char* ptr = new unsigned char[size]; // allocate memory - memset(ptr, 0, size); - return std::unique_ptr<_Tp>(new(ptr) std::remove_extent_t<_Tp>[__num]()); + std::memset(ptr, 0, size); + return std::unique_ptr(new(ptr) std::remove_extent_t[num]()); } -template -inline typename _MakeUniqClear<_Tp>::__array make_unique_clear(size_t __num) +template +inline typename MakeUniqClearT::array make_unique_clear(size_t num) { - auto size = sizeof(std::remove_extent_t<_Tp>) * __num; + auto size = sizeof(std::remove_extent_t) * num; unsigned char* ptr = new unsigned char[size]; // allocate memory - memset(ptr, _F, size); - return std::unique_ptr<_Tp>(new(ptr) std::remove_extent_t<_Tp>[__num]()); + std::memset(ptr, F, size); + return std::unique_ptr(new(ptr) std::remove_extent_t[num]()); } /// Disable make_unique_clear for arrays of known bound -template -inline typename _MakeUniqClear<_Tp>::__invalid_type make_unique_clear(_Args&&...) = delete; +template +inline typename MakeUniqClearT::invalid_type make_unique_clear(Params&&...) = delete; #endif // MAME_LIB_UTIL_COREALLOC_H diff --git a/src/osd/osdcomm.h b/src/osd/osdcomm.h index a376ee6b9bd..ff8ca667713 100644 --- a/src/osd/osdcomm.h +++ b/src/osd/osdcomm.h @@ -17,6 +17,8 @@ #include #include #include +#include + /*************************************************************************** COMPILER-SPECIFIC NASTINESS @@ -131,6 +133,15 @@ using FPTR = uintptr_t; // Highly useful template for compile-time knowledge of an array size template constexpr inline size_t ARRAY_LENGTH(T (&)[N]) { return N;} +// For declaring an array of the same dimensions as another array (including multi-dimensional arrays) +template struct equivalent_array_or_type { typedef T type; }; +template struct equivalent_array_or_type { typedef typename equivalent_array_or_type::type type[N]; }; +template using equivalent_array_or_type_t = typename equivalent_array_or_type::type; +template struct equivalent_array { }; +template struct equivalent_array { typedef equivalent_array_or_type_t type[N]; }; +template using equivalent_array_t = typename equivalent_array::type; +#define EQUIVALENT_ARRAY(a, T) equivalent_array_t > + /* Macros for normalizing data into big or little endian formats */ #define FLIPENDIAN_INT16(x) (((((UINT16) (x)) >> 8) | ((x) << 8)) & 0xffff) diff --git a/src/tools/chdman.cpp b/src/tools/chdman.cpp index addfe14a913..ee2bae66779 100644 --- a/src/tools/chdman.cpp +++ b/src/tools/chdman.cpp @@ -471,7 +471,7 @@ public: // loop over channels and read the samples int channels = MIN(m_info.channels, ARRAY_LENGTH(m_audio)); - INT16 *samplesptr[ARRAY_LENGTH(m_audio)]; + EQUIVALENT_ARRAY(m_audio, INT16 *) samplesptr; for (int chnum = 0; chnum < channels; chnum++) { // read the sound samples From 7db8fe18f768a62874234bf49fe8ef814b519c4b Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 28 May 2016 12:22:55 +0200 Subject: [PATCH 02/11] we are not using pipes so no problem, but there is something wrong here (nw) --- scripts/src/3rdparty.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/src/3rdparty.lua b/scripts/src/3rdparty.lua index 0a3a7be2a0f..f9cc862e9d7 100644 --- a/scripts/src/3rdparty.lua +++ b/scripts/src/3rdparty.lua @@ -1051,6 +1051,8 @@ project "uv" "-Wno-missing-braces", "-Wno-undef", "-Wno-unused-variable", + "-Wno-format-security", + "-Wno-format", } From b580bbecf7f7d4f1701eb83a1874c6527bb848ea Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 28 May 2016 13:11:56 +0200 Subject: [PATCH 03/11] update travis for osx (nw) --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2032949dd70..27866b22cd1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ script: else make -j4 OPTIMIZE=0 OVERRIDE_CC="gcc-5" OVERRIDE_CXX="g++-5" && ./$MAME -validate; fi elif [ $TRAVIS_OS_NAME == 'osx' ]; then - unset LDOPTS && make -j2 OPTIMIZE=0 MACOSX_USE_LIBSDL=1 && ./$MAME -validate; + unset LDOPTS && make -j2 OPTIMIZE=0 USE_LIBSDL=1 && ./$MAME -validate; fi sudo: required before_install: @@ -37,7 +37,7 @@ before_install: - "if [ ${TRAVIS_OS_NAME:-'linux'} = 'linux' ]; then sudo apt-get install -y --force-yes libsdl2-dev libsdl2-ttf-dev libasound2-dev qt55base qt55quickcontrols qt55declarative qt55tools qt55svg; fi" - "if [ ${TRAVIS_OS_NAME:-'linux'} = 'linux' ]; then source /opt/qt55/bin/qt55-env.sh; fi" - "if [ ${TRAVIS_OS_NAME:-'linux'} = 'osx' ]; then brew update; fi" - - "if [ ${TRAVIS_OS_NAME:-'linux'} = 'osx' ]; then brew install sdl2 sdl2_ttf; fi" + - "if [ ${TRAVIS_OS_NAME:-'linux'} = 'osx' ]; then brew install sdl2 sdl2_ttf pkg-config; fi" branches: only: - master From 2b0d9e8ad6a7bae459fb7417c96cc03b7e6ae27f Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 28 May 2016 13:15:12 +0200 Subject: [PATCH 04/11] pkg-config is already there (nw) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 27866b22cd1..a582da5666d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,7 +37,7 @@ before_install: - "if [ ${TRAVIS_OS_NAME:-'linux'} = 'linux' ]; then sudo apt-get install -y --force-yes libsdl2-dev libsdl2-ttf-dev libasound2-dev qt55base qt55quickcontrols qt55declarative qt55tools qt55svg; fi" - "if [ ${TRAVIS_OS_NAME:-'linux'} = 'linux' ]; then source /opt/qt55/bin/qt55-env.sh; fi" - "if [ ${TRAVIS_OS_NAME:-'linux'} = 'osx' ]; then brew update; fi" - - "if [ ${TRAVIS_OS_NAME:-'linux'} = 'osx' ]; then brew install sdl2 sdl2_ttf pkg-config; fi" + - "if [ ${TRAVIS_OS_NAME:-'linux'} = 'osx' ]; then brew install sdl2 sdl2_ttf; fi" branches: only: - master From 293103ce8c926f1e191c0515660a15cc32fc01ac Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 28 May 2016 13:22:03 +0200 Subject: [PATCH 05/11] proper patch already applied upstream (nw) --- 3rdparty/libuv/src/win/pipe.c | 2 +- scripts/src/3rdparty.lua | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/3rdparty/libuv/src/win/pipe.c b/3rdparty/libuv/src/win/pipe.c index a784325c589..2a949e79be3 100644 --- a/3rdparty/libuv/src/win/pipe.c +++ b/3rdparty/libuv/src/win/pipe.c @@ -85,7 +85,7 @@ static void eof_timer_close_cb(uv_handle_t* handle); static void uv_unique_pipe_name(char* ptr, char* name, size_t size) { - snprintf(name, size, "\\\\?\\pipe\\uv\\%p-%u", ptr, GetCurrentProcessId()); + snprintf(name, size, "\\\\?\\pipe\\uv\\%p-%lu", ptr, GetCurrentProcessId()); } diff --git a/scripts/src/3rdparty.lua b/scripts/src/3rdparty.lua index f9cc862e9d7..0a3a7be2a0f 100644 --- a/scripts/src/3rdparty.lua +++ b/scripts/src/3rdparty.lua @@ -1051,8 +1051,6 @@ project "uv" "-Wno-missing-braces", "-Wno-undef", "-Wno-unused-variable", - "-Wno-format-security", - "-Wno-format", } From 2e3656584f1ee8d6d5df167133d57eb7f80090be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Corr=C3=AAa=20da=20Silva=20Sanches?= Date: Fri, 27 May 2016 10:51:46 -0300 Subject: [PATCH 06/11] radm: Swap Lights_lamp and Wiper_lamp (these output signals were misassigned) --- src/mame/drivers/segas32.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mame/drivers/segas32.cpp b/src/mame/drivers/segas32.cpp index 8330600a67e..251f99639a1 100644 --- a/src/mame/drivers/segas32.cpp +++ b/src/mame/drivers/segas32.cpp @@ -4986,8 +4986,8 @@ void segas32_state::radm_sw2_output( int which, UINT16 data ) { if (which == 0) { - machine().output().set_value("Wiper_lamp", BIT(data, 0)); - machine().output().set_value("Lights_lamp", BIT(data, 1)); + machine().output().set_value("Lights_lamp", BIT(data, 0)); + machine().output().set_value("Wiper_lamp", BIT(data, 1)); } } From 9c5e9b7ea30aa15eeaaaeecd33fa94c2f7cdac8f Mon Sep 17 00:00:00 2001 From: r09 Date: Sat, 28 May 2016 15:34:04 +0200 Subject: [PATCH 07/11] fmtowns_cd.xml: Added N, O, P --- hash/fmtowns_cd.xml | 334 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 334 insertions(+) diff --git a/hash/fmtowns_cd.xml b/hash/fmtowns_cd.xml index 646e6bbcdae..b91d0f69335 100644 --- a/hash/fmtowns_cd.xml +++ b/hash/fmtowns_cd.xml @@ -2705,6 +2705,111 @@ User/save disks that can be created from the game itself are not included. + + Nihon no Rekishi: Kizoku-hen + 1990 + CRI + + + + + + + + + Nihon no Rekishi: Kodai-hen + 1990 + CRI + + + + + + + + + Nihon no Yachou + 1990 + Fujitsu + + + + + + + + + Ningyou Tsukai + 1993 + Forest + + + + + + + + + Nobunaga no Yabou: Haouden + 1993 + Koei + + + + + + + + + + + + + + + Nobunaga no Yabou: Tenshouki + 1995 + Koei + + + + + + + + + Nova + 1993 + Cat's Pro + + + + + + + + + OASYS/Win v2.0 + 1994 + Fujitsu + + + + + + + + + Okiraku TownsGEAR + 1994 + Softbank + + + + + + + Operation Wolf 1990 @@ -2716,6 +2821,28 @@ User/save disks that can be created from the game itself are not included. + + Oshare Cooking + 1989 + Misawa Home + + + + + + + + + Ougon no Rashinban + 1990 + Riverhill Soft + + + + + + + Panzer Division / Kikou Shidan 1990 @@ -2738,6 +2865,39 @@ User/save disks that can be created from the game itself are not included. + + Planet's Edge + 1993 + Ving + + + + + + + + + Princess Maker 2 + 1994 + Gainax + + + + + + + + + Ponkan + 1994 + Ponytail Soft + + + + + + + Populous & The Promised Lands 1990 @@ -2749,6 +2909,45 @@ User/save disks that can be created from the game itself are not included. + + + Power Dolls + 1994 + Kogado + + + + + + + + + + + + + + + + + + + Power Dolls 2 + 1995 + Kogado + + + + + + + Powermonger 1992 @@ -2792,6 +2991,141 @@ User/save disks that can be created from the game itself are not included. + + Pro Student G + 1993 + Alice Soft + + + + + + + + + + + + + + Provvidenza: Legenda la Spada di Alfa + 1991 + Sofcom + + + + + + + + + Psychic Detective Series Vol. 1: Invitation + 1989 + Data West + + + + + + + + + Psychic Detective Series Vol. 2: Memories + 1989 + Data West + + + + + + + + + Psychic Detective Series Vol. 3: Aya + 1990 + Data West + + + + + + + + + Psychic Detective Series Vol. 4: Orgel + 1991 + Data West + + + + + + + + + + + + + + Psychic Detective Series Vol. 5: Nightmare + 1991 + Data West + + + + + + + + + + + + + + Psychic Detective Series Final: Solitude Joukan + 1992 + Data West + + + + + + + + + + + + + + Psychic Detective Series Final: Solitude Gekan + 1993 + Data West + + + + + + + + + + + + + + Pu-Li-Ru-La + 1994 + Ving + + + + + + + Puyo Puyo 1994 From f37e28476652722cce7fd349400c98d10083f97f Mon Sep 17 00:00:00 2001 From: Scott Stone Date: Sat, 28 May 2016 09:56:38 -0400 Subject: [PATCH 08/11] Add missing recently added driver to mess (nw) --- src/mame/mess.flt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mame/mess.flt b/src/mame/mess.flt index 668c05c1187..e3dddf83677 100644 --- a/src/mame/mess.flt +++ b/src/mame/mess.flt @@ -19,6 +19,7 @@ advision.cpp aim65.cpp aim65_40.cpp alesis.cpp +alesis_qs.cpp alphasma.cpp alphatro.cpp altair.cpp From 6af3202119cf7ca821a6102012d8efd7250c76bb Mon Sep 17 00:00:00 2001 From: ImJezze Date: Sat, 28 May 2016 16:33:41 +0200 Subject: [PATCH 09/11] Fixed MT06222 - fixed offset of vector lines and clipping rectangle when vector primitives are prepared to be rendered into a texture (HLSL) instead of directly on the screen (GDI, D3D) --- src/emu/render.cpp | 49 +++++++++++++++++++++++++++++++++++----------- src/emu/render.h | 2 +- 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/emu/render.cpp b/src/emu/render.cpp index 2a6bd7e4760..f8cc9529f42 100644 --- a/src/emu/render.cpp +++ b/src/emu/render.cpp @@ -1376,7 +1376,7 @@ render_primitive_list &render_target::get_primitives() // if there is no associated element, it must be a screen element if (curitem.screen() != nullptr) - add_container_primitives(list, item_xform, curitem.screen()->container(), blendmode); + add_container_primitives(list, root_xform, item_xform, curitem.screen()->container(), blendmode); else add_element_primitives(list, item_xform, *curitem.element(), curitem.state(), blendmode); } @@ -1418,7 +1418,7 @@ render_primitive_list &render_target::get_primitives() ui_xform.no_center = true; // add UI elements - add_container_primitives(list, ui_xform, debug, BLENDMODE_ALPHA); + add_container_primitives(list, root_xform, ui_xform, debug, BLENDMODE_ALPHA); } // process the UI if we are the UI target @@ -1435,7 +1435,7 @@ render_primitive_list &render_target::get_primitives() ui_xform.no_center = false; // add UI elements - add_container_primitives(list, ui_xform, m_manager.ui_container(), BLENDMODE_ALPHA); + add_container_primitives(list, root_xform, ui_xform, m_manager.ui_container(), BLENDMODE_ALPHA); } // optimize the list before handing it off @@ -1745,7 +1745,7 @@ bool render_target::load_layout_file(const char *dirname, const char *filename) // based on the container //------------------------------------------------- -void render_target::add_container_primitives(render_primitive_list &list, const object_transform &xform, render_container &container, int blendmode) +void render_target::add_container_primitives(render_primitive_list &list, const object_transform &root_xform, const object_transform &xform, render_container &container, int blendmode) { // first update the palette for the container, if it is dirty container.update_palette(); @@ -1758,6 +1758,16 @@ void render_target::add_container_primitives(render_primitive_list &list, const cliprect.y1 = xform.yoffs + xform.yscale; sect_render_bounds(&cliprect, &m_bounds); + float root_xoffs = root_xform.xoffs + abs(root_xform.xscale - xform.xscale) * 0.5f; + float root_yoffs = root_xform.yoffs + abs(root_xform.yscale - xform.yscale) * 0.5f; + + render_bounds root_cliprect; + root_cliprect.x0 = root_xoffs; + root_cliprect.y0 = root_yoffs; + root_cliprect.x1 = root_xoffs + root_xform.xscale; + root_cliprect.y1 = root_yoffs + root_xform.yscale; + sect_render_bounds(&root_cliprect, &m_bounds); + // compute the container transform object_transform container_xform; container_xform.orientation = orientation_add(container.orientation(), xform.orientation); @@ -1797,22 +1807,32 @@ void render_target::add_container_primitives(render_primitive_list &list, const render_bounds bounds = curitem.bounds(); apply_orientation(bounds, container_xform.orientation); + float xscale = container_xform.xscale; + float yscale = container_xform.yscale; + float xoffs = container_xform.xoffs; + float yoffs = container_xform.yoffs; + if (!m_transform_container && PRIMFLAG_GET_VECTOR(curitem.flags())) + { + xoffs = root_xoffs; + yoffs = root_yoffs; + } + // allocate the primitive and set the transformed bounds/color data render_primitive *prim = list.alloc(render_primitive::INVALID); prim->container = &container; /* pass the container along for access to user_settings */ - prim->bounds.x0 = render_round_nearest(container_xform.xoffs + bounds.x0 * container_xform.xscale); - prim->bounds.y0 = render_round_nearest(container_xform.yoffs + bounds.y0 * container_xform.yscale); + prim->bounds.x0 = render_round_nearest(xoffs + bounds.x0 * xscale); + prim->bounds.y0 = render_round_nearest(yoffs + bounds.y0 * yscale); if (curitem.internal() & INTERNAL_FLAG_CHAR) { - prim->bounds.x1 = prim->bounds.x0 + render_round_nearest((bounds.x1 - bounds.x0) * container_xform.xscale); - prim->bounds.y1 = prim->bounds.y0 + render_round_nearest((bounds.y1 - bounds.y0) * container_xform.yscale); + prim->bounds.x1 = prim->bounds.x0 + render_round_nearest((bounds.x1 - bounds.x0) * xscale); + prim->bounds.y1 = prim->bounds.y0 + render_round_nearest((bounds.y1 - bounds.y0) * yscale); } else { - prim->bounds.x1 = render_round_nearest(container_xform.xoffs + bounds.x1 * container_xform.xscale); - prim->bounds.y1 = render_round_nearest(container_xform.yoffs + bounds.y1 * container_xform.yscale); + prim->bounds.x1 = render_round_nearest(xoffs + bounds.x1 * xscale); + prim->bounds.y1 = render_round_nearest(yoffs + bounds.y1 * yscale); } // compute the color of the primitive @@ -1841,7 +1861,14 @@ void render_target::add_container_primitives(render_primitive_list &list, const prim->flags |= curitem.flags(); // clip the primitive - clipped = render_clip_line(&prim->bounds, &cliprect); + if (!m_transform_container && PRIMFLAG_GET_VECTOR(curitem.flags())) + { + clipped = render_clip_line(&prim->bounds, &root_cliprect); + } + else + { + clipped = render_clip_line(&prim->bounds, &cliprect); + } break; case CONTAINER_ITEM_QUAD: diff --git a/src/emu/render.h b/src/emu/render.h index ccc0c5f6cd7..731830a767f 100644 --- a/src/emu/render.h +++ b/src/emu/render.h @@ -979,7 +979,7 @@ private: void load_layout_files(const internal_layout *layoutfile, bool singlefile); bool load_layout_file(const char *dirname, const char *filename); bool load_layout_file(const char *dirname, const internal_layout *layout_data); - void add_container_primitives(render_primitive_list &list, const object_transform &xform, render_container &container, int blendmode); + void add_container_primitives(render_primitive_list &list, const object_transform &root_xform, const object_transform &xform, render_container &container, int blendmode); void add_element_primitives(render_primitive_list &list, const object_transform &xform, layout_element &element, int state, int blendmode); bool map_point_internal(INT32 target_x, INT32 target_y, render_container *container, float &mapped_x, float &mapped_y, ioport_port *&mapped_input_port, ioport_value &mapped_input_mask); From 63132b3d01ee0ad797e797057687facf43f4f26d Mon Sep 17 00:00:00 2001 From: "therealmogminer@gmail.com" Date: Sat, 28 May 2016 15:36:50 +0200 Subject: [PATCH 10/11] More slider cleanup, nw --- src/frontend/mame/ui/slider.h | 7 +- src/frontend/mame/ui/sliderchangednotifier.h | 29 +++ src/frontend/mame/ui/sliders.cpp | 10 +- src/frontend/mame/ui/ui.cpp | 221 ++++++++++++------- src/frontend/mame/ui/ui.h | 86 +++++++- src/osd/modules/render/bgfx/chainmanager.cpp | 17 +- src/osd/modules/render/bgfx/chainmanager.h | 6 +- src/osd/modules/render/bgfx/inputpair.cpp | 12 +- src/osd/modules/render/bgfx/inputpair.h | 4 +- src/osd/modules/render/bgfx/slider.cpp | 9 +- src/osd/modules/render/bgfx/slider.h | 5 +- src/osd/modules/render/d3d/d3dhlsl.cpp | 11 +- src/osd/modules/render/d3d/d3dhlsl.h | 5 +- 13 files changed, 301 insertions(+), 121 deletions(-) create mode 100644 src/frontend/mame/ui/sliderchangednotifier.h diff --git a/src/frontend/mame/ui/slider.h b/src/frontend/mame/ui/slider.h index a7873db800a..7cd4b580831 100644 --- a/src/frontend/mame/ui/slider.h +++ b/src/frontend/mame/ui/slider.h @@ -14,16 +14,19 @@ #ifndef __UI_SLIDER__ #define __UI_SLIDER__ +#include + #include "emu.h" +#include "sliderchangednotifier.h" #define SLIDER_NOCHANGE 0x12345678 -typedef INT32(*slider_update)(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); +typedef std::function slider_update; struct slider_state { slider_state * next; /* pointer to next slider */ - slider_update update; /* callback */ + slider_update update; /* callback */ void * arg; /* argument */ INT32 minval; /* minimum value */ INT32 defval; /* default value */ diff --git a/src/frontend/mame/ui/sliderchangednotifier.h b/src/frontend/mame/ui/sliderchangednotifier.h new file mode 100644 index 00000000000..40e6df4b4bf --- /dev/null +++ b/src/frontend/mame/ui/sliderchangednotifier.h @@ -0,0 +1,29 @@ +// license:BSD-3-Clause +// copyright-holders:Ryan Holtz +//====================================================================== +// +// sliderchangednotifier.cpp - Interface for a slider-changed callback +// +//====================================================================== + +#pragma once + +#ifndef __SLIDER_CHANGED_NOTIFIER__ +#define __SLIDER_CHANGED_NOTIFIER__ + +#include +#include + +using INT32 = std::int32_t; + +class running_machine; + +class slider_changed_notifier +{ +public: + virtual ~slider_changed_notifier() { } + + virtual INT32 slider_changed(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) = 0; +}; + +#endif // __SLIDER_CHANGED_NOTIFIER__ diff --git a/src/frontend/mame/ui/sliders.cpp b/src/frontend/mame/ui/sliders.cpp index 920d2ede4b4..b94b8f00055 100644 --- a/src/frontend/mame/ui/sliders.cpp +++ b/src/frontend/mame/ui/sliders.cpp @@ -43,7 +43,7 @@ void menu_sliders::handle() if (menu_event->itemref != nullptr && menu_event->type == menu_item_type::SLIDER) { const slider_state *slider = (const slider_state *)menu_event->itemref; - INT32 curvalue = (*slider->update)(machine(), slider->arg, slider->id, nullptr, SLIDER_NOCHANGE); + INT32 curvalue = slider->update(machine(), slider->arg, slider->id, nullptr, SLIDER_NOCHANGE); INT32 increment = 0; bool alt_pressed = machine().input().code_pressed(KEYCODE_LALT) || machine().input().code_pressed(KEYCODE_RALT); bool ctrl_pressed = machine().input().code_pressed(KEYCODE_LCONTROL) || machine().input().code_pressed(KEYCODE_RCONTROL); @@ -105,7 +105,7 @@ void menu_sliders::handle() newvalue = slider->maxval; /* update the slider and recompute the menu */ - (*slider->update)(machine(), slider->arg, slider->id, nullptr, newvalue); + slider->update(machine(), slider->arg, slider->id, nullptr, newvalue); reset(reset_options::REMEMBER_REF); } } @@ -147,7 +147,7 @@ void menu_sliders::populate() if (item.type == menu_item_type::SLIDER) { slider_state* slider = reinterpret_cast(item.ref); - INT32 curval = (*slider->update)(machine(), slider->arg, slider->id, &tempstring, SLIDER_NOCHANGE); + INT32 curval = slider->update(machine(), slider->arg, slider->id, &tempstring, SLIDER_NOCHANGE); UINT32 flags = 0; if (curval > slider->minval) flags |= FLAG_LEFT_ARROW; @@ -170,7 +170,7 @@ void menu_sliders::populate() if (item.type == menu_item_type::SLIDER) { slider_state* slider = reinterpret_cast(item.ref); - INT32 curval = (*slider->update)(machine(), slider->arg, slider->id, &tempstring, SLIDER_NOCHANGE); + INT32 curval = slider->update(machine(), slider->arg, slider->id, &tempstring, SLIDER_NOCHANGE); UINT32 flags = 0; if (curval > slider->minval) flags |= FLAG_LEFT_ARROW; @@ -205,7 +205,7 @@ void menu_sliders::custom_render(void *selectedref, float top, float bottom, flo INT32 curval; /* determine the current value and text */ - curval = (*curslider->update)(machine(), curslider->arg, curslider->id, &tempstring, SLIDER_NOCHANGE); + curval = curslider->update(machine(), curslider->arg, curslider->id, &tempstring, SLIDER_NOCHANGE); /* compute the current and default percentages */ percentage = (float)(curval - curslider->minval) / (float)(curslider->maxval - curslider->minval); diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp index 4f01102abb4..08bcfa0ceac 100644 --- a/src/frontend/mame/ui/ui.cpp +++ b/src/frontend/mame/ui/ui.cpp @@ -125,39 +125,6 @@ std::vector mame_ui_manager::slider_list; slider_state *mame_ui_manager::slider_current; -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -// slider controls -static slider_state *slider_alloc(running_machine &machine, const char *title, INT32 minval, INT32 defval, INT32 maxval, INT32 incval, slider_update update, void *arg); -static INT32 slider_volume(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -static INT32 slider_mixervol(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -static INT32 slider_adjuster(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -static INT32 slider_overclock(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -static INT32 slider_refresh(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -static INT32 slider_brightness(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -static INT32 slider_contrast(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -static INT32 slider_gamma(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -static INT32 slider_xscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -static INT32 slider_yscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -static INT32 slider_xoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -static INT32 slider_yoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -static INT32 slider_overxscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -static INT32 slider_overyscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -static INT32 slider_overxoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -static INT32 slider_overyoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -static INT32 slider_flicker(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -static INT32 slider_beam_width_min(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -static INT32 slider_beam_width_max(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -static INT32 slider_beam_intensity_weight(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -static std::string slider_get_screen_desc(screen_device &screen); -#ifdef MAME_DEBUG -static INT32 slider_crossscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -static INT32 slider_crossoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); -#endif - - /*************************************************************************** INLINE FUNCTIONS ***************************************************************************/ @@ -1896,7 +1863,7 @@ std::vector& mame_ui_manager::get_slider_list(void) // slider_alloc - allocate a new slider entry //------------------------------------------------- -static slider_state *slider_alloc(running_machine &machine, const char *title, INT32 minval, INT32 defval, INT32 maxval, INT32 incval, slider_update update, void *arg) +slider_state* mame_ui_manager::slider_alloc(running_machine &machine, int id, const char *title, INT32 minval, INT32 defval, INT32 maxval, INT32 incval, void *arg) { int size = sizeof(slider_state) + strlen(title); slider_state *state = (slider_state *)auto_alloc_array_clear(machine, UINT8, size); @@ -1905,9 +1872,12 @@ static slider_state *slider_alloc(running_machine &machine, const char *title, I state->defval = defval; state->maxval = maxval; state->incval = incval; - state->update = update; + + using namespace std::placeholders; + state->update = std::bind(&mame_ui_manager::slider_changed, this, _1, _2, _3, _4, _5); + state->arg = arg; - state->id = -1; + state->id = id; strcpy(state->description, title); return state; @@ -1924,7 +1894,7 @@ std::vector mame_ui_manager::slider_init(running_machine &machine std::vector sliders; // add overall volume - sliders.push_back(slider_alloc(machine, _("Master Volume"), -32, 0, 0, 1, slider_volume, nullptr)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_VOLUME, _("Master Volume"), -32, 0, 0, 1, nullptr)); // add per-channel volume mixer_input info; @@ -1934,34 +1904,37 @@ std::vector mame_ui_manager::slider_init(running_machine &machine INT32 defval = 1000; std::string str = string_format(_("%1$s Volume"), info.stream->input_name(info.inputnum)); - sliders.push_back(slider_alloc(machine, str.c_str(), 0, defval, maxval, 20, slider_mixervol, (void *)(FPTR)item)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_MIXERVOL + item, str.c_str(), 0, defval, maxval, 20, (void *)(FPTR)item)); } // add analog adjusters + int slider_index = 0; for (ioport_port &port : machine.ioport().ports()) { for (ioport_field &field : port.fields()) { if (field.type() == IPT_ADJUSTER) { - sliders.push_back(slider_alloc(machine, field.name(), field.minval(), field.defvalue(), field.maxval(), 1, slider_adjuster, (void *)&field)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_ADJUSTER + slider_index++, field.name(), field.minval(), field.defvalue(), field.maxval(), 1, (void *)&field)); } } } // add CPU overclocking (cheat only) + slider_index = 0; if (machine.options().cheat()) { for (device_execute_interface &exec : execute_interface_iterator(machine.root_device())) { void *param = (void *)&exec.device(); std::string str = string_format(_("Overclock CPU %1$s"), exec.device().tag()); - sliders.push_back(slider_alloc(machine, str.c_str(), 10, 1000, 2000, 1, slider_overclock, param)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERCLOCK + slider_index++, str.c_str(), 10, 1000, 2000, 1, param)); } } // add screen parameters screen_device_iterator scriter(machine.root_device()); + slider_index = 0; for (screen_device &screen : scriter) { int defxscale = floor(screen.xscale() * 1000.0f + 0.5f); @@ -1975,28 +1948,30 @@ std::vector mame_ui_manager::slider_init(running_machine &machine if (machine.options().cheat()) { std::string str = string_format(_("%1$s Refresh Rate"), screen_desc); - sliders.push_back(slider_alloc(machine, str.c_str(), -10000, 0, 10000, 1000, slider_refresh, param)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_REFRESH + slider_index, str.c_str(), -10000, 0, 10000, 1000, param)); } // add standard brightness/contrast/gamma controls per-screen std::string str = string_format(_("%1$s Brightness"), screen_desc); - sliders.push_back(slider_alloc(machine, str.c_str(), 100, 1000, 2000, 10, slider_brightness, param)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_BRIGHTNESS + slider_index, str.c_str(), 100, 1000, 2000, 10, param)); str = string_format(_("%1$s Contrast"), screen_desc); - sliders.push_back(slider_alloc(machine, str.c_str(), 100, 1000, 2000, 50, slider_contrast, param)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_CONTRAST + slider_index, str.c_str(), 100, 1000, 2000, 50, param)); str = string_format(_("%1$s Gamma"), screen_desc); - sliders.push_back(slider_alloc(machine, str.c_str(), 100, 1000, 3000, 50, slider_gamma, param)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_GAMMA + slider_index, str.c_str(), 100, 1000, 3000, 50, param)); // add scale and offset controls per-screen str = string_format(_("%1$s Horiz Stretch"), screen_desc); - sliders.push_back(slider_alloc(machine, str.c_str(), 500, defxscale, 1500, 2, slider_xscale, param)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_XSCALE + slider_index, str.c_str(), 500, defxscale, 1500, 2, param)); str = string_format(_("%1$s Horiz Position"), screen_desc); - sliders.push_back(slider_alloc(machine, str.c_str(), -500, defxoffset, 500, 2, slider_xoffset, param)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_XOFFSET + slider_index, str.c_str(), -500, defxoffset, 500, 2, param)); str = string_format(_("%1$s Vert Stretch"), screen_desc); - sliders.push_back(slider_alloc(machine, str.c_str(), 500, defyscale, 1500, 2, slider_yscale, param)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_YSCALE + slider_index, str.c_str(), 500, defyscale, 1500, 2, param)); str = string_format(_("%1$s Vert Position"), screen_desc); - sliders.push_back(slider_alloc(machine, str.c_str(), -500, defyoffset, 500, 2, slider_yoffset, param)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_YOFFSET + slider_index, str.c_str(), -500, defyoffset, 500, 2, param)); + slider_index++; } + slider_index = 0; for (laserdisc_device &laserdisc : laserdisc_device_iterator(machine.root_device())) { if (laserdisc.overlay_configured()) @@ -2011,30 +1986,34 @@ std::vector mame_ui_manager::slider_init(running_machine &machine // add scale and offset controls per-overlay std::string str = string_format(_("Laserdisc '%1$s' Horiz Stretch"), laserdisc.tag()); - sliders.push_back(slider_alloc(machine, str.c_str(), 500, (defxscale == 0) ? 1000 : defxscale, 1500, 2, slider_overxscale, param)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERLAY_XSCALE + slider_index, str.c_str(), 500, (defxscale == 0) ? 1000 : defxscale, 1500, 2, param)); str = string_format(_("Laserdisc '%1$s' Horiz Position"), laserdisc.tag()); - sliders.push_back(slider_alloc(machine, str.c_str(), -500, defxoffset, 500, 2, slider_overxoffset, param)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERLAY_YSCALE + slider_index, str.c_str(), -500, defxoffset, 500, 2, param)); str = string_format(_("Laserdisc '%1$s' Vert Stretch"), laserdisc.tag()); - sliders.push_back(slider_alloc(machine, str.c_str(), 500, (defyscale == 0) ? 1000 : defyscale, 1500, 2, slider_overyscale, param)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERLAY_XOFFSET + slider_index, str.c_str(), 500, (defyscale == 0) ? 1000 : defyscale, 1500, 2, param)); str = string_format(_("Laserdisc '%1$s' Vert Position"), laserdisc.tag()); - sliders.push_back(slider_alloc(machine, str.c_str(), -500, defyoffset, 500, 2, slider_overyoffset, param)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_OVERLAY_YOFFSET + slider_index, str.c_str(), -500, defyoffset, 500, 2, param)); + slider_index++; } } + slider_index = 0; for (screen_device &screen : scriter) { if (screen.screen_type() == SCREEN_TYPE_VECTOR) { // add vector control - sliders.push_back(slider_alloc(machine, _("Vector Flicker"), 0, 0, 1000, 10, slider_flicker, nullptr)); - sliders.push_back(slider_alloc(machine, _("Beam Width Minimum"), 1, 100, 1000, 1, slider_beam_width_min, nullptr)); - sliders.push_back(slider_alloc(machine, _("Beam Width Maximum"), 1, 100, 1000, 1, slider_beam_width_max, nullptr)); - sliders.push_back(slider_alloc(machine, _("Beam Intensity Weight"), -1000, 0, 1000, 10, slider_beam_intensity_weight, nullptr)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_FLICKER + slider_index, _("Vector Flicker"), 0, 0, 1000, 10, nullptr)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_BEAM_WIDTH_MIN + slider_index, _("Beam Width Minimum"), 1, 100, 1000, 1, nullptr)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_BEAM_WIDTH_MAX + slider_index, _("Beam Width Maximum"), 1, 100, 1000, 1, nullptr)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_BEAM_INTENSITY + slider_index, _("Beam Intensity Weight"), -1000, 0, 1000, 10, nullptr)); + slider_index++; break; } } #ifdef MAME_DEBUG + slider_index = 0; // add crosshair adjusters for (ioport_port &port : machine.ioport().ports()) { @@ -2043,9 +2022,9 @@ std::vector mame_ui_manager::slider_init(running_machine &machine if (field.crosshair_axis() != CROSSHAIR_AXIS_NONE && field.player() == 0) { std::string str = string_format(_("Crosshair Scale %1$s"), (field.crosshair_axis() == CROSSHAIR_AXIS_X) ? _("X") : _("Y")); - sliders.push_back(slider_alloc(machine, str.c_str(), -3000, 1000, 3000, 100, slider_crossscale, (void *)&field)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_CROSSHAIR_SCALE + slider_index, str.c_str(), -3000, 1000, 3000, 100, (void *)&field)); str = string_format(_("Crosshair Offset %1$s"), (field.crosshair_axis() == CROSSHAIR_AXIS_X) ? _("X") : _("Y")); - sliders.push_back(slider_alloc(machine, str.c_str(), -3000, 0, 3000, 100, slider_crossoffset, (void *)&field)); + sliders.push_back(slider_alloc(machine, SLIDER_ID_CROSSHAIR_OFFSET + slider_index, str.c_str(), -3000, 0, 3000, 100, (void *)&field)); } } } @@ -2066,12 +2045,92 @@ std::vector mame_ui_manager::slider_init(running_machine &machine return items; } +//---------------------------------------------------- +// slider_changed - global slider-modified callback +//---------------------------------------------------- + +INT32 mame_ui_manager::slider_changed(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +{ + switch (id) + { + case SLIDER_ID_VOLUME: + return slider_volume(machine, arg, id, str, newval); + + case SLIDER_ID_MIXERVOL ... SLIDER_ID_MIXERVOL_LAST: + return slider_mixervol(machine, arg, id, str, newval); + + case SLIDER_ID_ADJUSTER ... SLIDER_ID_ADJUSTER_LAST: + return slider_adjuster(machine, arg, id, str, newval); + + case SLIDER_ID_OVERCLOCK ... SLIDER_ID_OVERCLOCK_LAST: + return slider_overclock(machine, arg, id, str, newval); + + case SLIDER_ID_REFRESH ... SLIDER_ID_REFRESH_LAST: + return slider_refresh(machine, arg, id, str, newval); + + case SLIDER_ID_BRIGHTNESS ... SLIDER_ID_BRIGHTNESS_LAST: + return slider_brightness(machine, arg, id, str, newval); + + case SLIDER_ID_CONTRAST ... SLIDER_ID_CONTRAST_LAST: + return slider_contrast(machine, arg, id, str, newval); + + case SLIDER_ID_GAMMA ... SLIDER_ID_GAMMA_LAST: + return slider_gamma(machine, arg, id, str, newval); + + case SLIDER_ID_XSCALE ... SLIDER_ID_XSCALE_LAST: + return slider_xscale(machine, arg, id, str, newval); + + case SLIDER_ID_YSCALE ... SLIDER_ID_YSCALE_LAST: + return slider_yscale(machine, arg, id, str, newval); + + case SLIDER_ID_XOFFSET ... SLIDER_ID_XOFFSET_LAST: + return slider_xoffset(machine, arg, id, str, newval); + + case SLIDER_ID_YOFFSET ... SLIDER_ID_YOFFSET_LAST: + return slider_yoffset(machine, arg, id, str, newval); + + case SLIDER_ID_OVERLAY_XSCALE ... SLIDER_ID_OVERLAY_XSCALE_LAST: + return slider_overxscale(machine, arg, id, str, newval); + + case SLIDER_ID_OVERLAY_YSCALE ... SLIDER_ID_OVERLAY_YSCALE_LAST: + return slider_overyscale(machine, arg, id, str, newval); + + case SLIDER_ID_OVERLAY_XOFFSET ... SLIDER_ID_OVERLAY_XOFFSET_LAST: + return slider_overxoffset(machine, arg, id, str, newval); + + case SLIDER_ID_OVERLAY_YOFFSET ... SLIDER_ID_OVERLAY_YOFFSET_LAST: + return slider_overyoffset(machine, arg, id, str, newval); + + case SLIDER_ID_FLICKER ... SLIDER_ID_FLICKER_LAST: + return slider_flicker(machine, arg, id, str, newval); + + case SLIDER_ID_BEAM_WIDTH_MIN ... SLIDER_ID_BEAM_WIDTH_MIN_LAST: + return slider_beam_width_min(machine, arg, id, str, newval); + + case SLIDER_ID_BEAM_WIDTH_MAX ... SLIDER_ID_BEAM_WIDTH_MAX_LAST: + return slider_beam_width_max(machine, arg, id, str, newval); + + case SLIDER_ID_BEAM_INTENSITY ... SLIDER_ID_BEAM_INTENSITY_LAST: + return slider_beam_intensity_weight(machine, arg, id, str, newval); + +#ifdef MAME_DEBUG + case SLIDER_ID_CROSSHAIR_SCALE ... SLIDER_ID_CROSSHAIR_SCALE_LAST: + return slider_crossscale(machine, arg, id, str, newval); + + case SLIDER_ID_CROSSHAIR_OFFSET ... SLIDER_ID_CROSSHAIR_OFFSET_LAST: + return slider_crossoffset(machine, arg, id, str, newval); +#endif + } + + return 0; +} + //------------------------------------------------- // slider_volume - global volume slider callback //------------------------------------------------- -static INT32 slider_volume(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_volume(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { if (newval != SLIDER_NOCHANGE) machine.sound().set_attenuation(newval); @@ -2086,7 +2145,7 @@ static INT32 slider_volume(running_machine &machine, void *arg, int id, std::str // slider callback //------------------------------------------------- -static INT32 slider_mixervol(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_mixervol(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { mixer_input info; if (!machine.sound().indexed_mixer_input((FPTR)arg, info)) @@ -2108,7 +2167,7 @@ static INT32 slider_mixervol(running_machine &machine, void *arg, int id, std::s // callback //------------------------------------------------- -static INT32 slider_adjuster(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_adjuster(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { ioport_field *field = (ioport_field *)arg; ioport_field::user_settings settings; @@ -2130,7 +2189,7 @@ static INT32 slider_adjuster(running_machine &machine, void *arg, int id, std::s // callback //------------------------------------------------- -static INT32 slider_overclock(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_overclock(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { device_t *cpu = (device_t *)arg; if (newval != SLIDER_NOCHANGE) @@ -2145,7 +2204,7 @@ static INT32 slider_overclock(running_machine &machine, void *arg, int id, std:: // slider_refresh - refresh rate slider callback //------------------------------------------------- -static INT32 slider_refresh(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_refresh(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { screen_device *screen = reinterpret_cast(arg); double defrefresh = ATTOSECONDS_TO_HZ(screen->refresh_attoseconds()); @@ -2170,7 +2229,7 @@ static INT32 slider_refresh(running_machine &machine, void *arg, int id, std::st // callback //------------------------------------------------- -static INT32 slider_brightness(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_brightness(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { screen_device *screen = reinterpret_cast(arg); render_container::user_settings settings; @@ -2192,7 +2251,7 @@ static INT32 slider_brightness(running_machine &machine, void *arg, int id, std: // callback //------------------------------------------------- -static INT32 slider_contrast(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_contrast(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { screen_device *screen = reinterpret_cast(arg); render_container::user_settings settings; @@ -2213,7 +2272,7 @@ static INT32 slider_contrast(running_machine &machine, void *arg, int id, std::s // slider_gamma - screen gamma slider callback //------------------------------------------------- -static INT32 slider_gamma(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_gamma(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { screen_device *screen = reinterpret_cast(arg); render_container::user_settings settings; @@ -2235,7 +2294,7 @@ static INT32 slider_gamma(running_machine &machine, void *arg, int id, std::stri // callback //------------------------------------------------- -static INT32 slider_xscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_xscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { screen_device *screen = reinterpret_cast(arg); render_container::user_settings settings; @@ -2257,7 +2316,7 @@ static INT32 slider_xscale(running_machine &machine, void *arg, int id, std::str // callback //------------------------------------------------- -static INT32 slider_yscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_yscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { screen_device *screen = reinterpret_cast(arg); render_container::user_settings settings; @@ -2279,7 +2338,7 @@ static INT32 slider_yscale(running_machine &machine, void *arg, int id, std::str // slider callback //------------------------------------------------- -static INT32 slider_xoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_xoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { screen_device *screen = reinterpret_cast(arg); render_container::user_settings settings; @@ -2301,7 +2360,7 @@ static INT32 slider_xoffset(running_machine &machine, void *arg, int id, std::st // slider callback //------------------------------------------------- -static INT32 slider_yoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_yoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { screen_device *screen = reinterpret_cast(arg); render_container::user_settings settings; @@ -2323,7 +2382,7 @@ static INT32 slider_yoffset(running_machine &machine, void *arg, int id, std::st // callback //------------------------------------------------- -static INT32 slider_overxscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_overxscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { laserdisc_device *laserdisc = (laserdisc_device *)arg; laserdisc_overlay_config settings; @@ -2345,7 +2404,7 @@ static INT32 slider_overxscale(running_machine &machine, void *arg, int id, std: // callback //------------------------------------------------- -static INT32 slider_overyscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_overyscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { laserdisc_device *laserdisc = (laserdisc_device *)arg; laserdisc_overlay_config settings; @@ -2367,7 +2426,7 @@ static INT32 slider_overyscale(running_machine &machine, void *arg, int id, std: // slider callback //------------------------------------------------- -static INT32 slider_overxoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_overxoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { laserdisc_device *laserdisc = (laserdisc_device *)arg; laserdisc_overlay_config settings; @@ -2389,7 +2448,7 @@ static INT32 slider_overxoffset(running_machine &machine, void *arg, int id, std // slider callback //------------------------------------------------- -static INT32 slider_overyoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_overyoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { laserdisc_device *laserdisc = (laserdisc_device *)arg; laserdisc_overlay_config settings; @@ -2411,7 +2470,7 @@ static INT32 slider_overyoffset(running_machine &machine, void *arg, int id, std // callback //------------------------------------------------- -static INT32 slider_flicker(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_flicker(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { if (newval != SLIDER_NOCHANGE) vector_options::s_flicker = (float)newval * 0.001f; @@ -2426,7 +2485,7 @@ static INT32 slider_flicker(running_machine &machine, void *arg, int id, std::st // callback //------------------------------------------------- -static INT32 slider_beam_width_min(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_beam_width_min(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { if (newval != SLIDER_NOCHANGE) vector_options::s_beam_width_min = MIN((float)newval * 0.01f, vector_options::s_beam_width_max); @@ -2441,7 +2500,7 @@ static INT32 slider_beam_width_min(running_machine &machine, void *arg, int id, // callback //------------------------------------------------- -static INT32 slider_beam_width_max(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_beam_width_max(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { if (newval != SLIDER_NOCHANGE) vector_options::s_beam_width_max = MAX((float)newval * 0.01f, vector_options::s_beam_width_min); @@ -2456,7 +2515,7 @@ static INT32 slider_beam_width_max(running_machine &machine, void *arg, int id, // callback //------------------------------------------------- -static INT32 slider_beam_intensity_weight(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_beam_intensity_weight(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { if (newval != SLIDER_NOCHANGE) vector_options::s_beam_intensity_weight = (float)newval * 0.001f; @@ -2471,7 +2530,7 @@ static INT32 slider_beam_intensity_weight(running_machine &machine, void *arg, i // description for a given screen //------------------------------------------------- -static std::string slider_get_screen_desc(screen_device &screen) +std::string mame_ui_manager::slider_get_screen_desc(screen_device &screen) { if (screen_device_iterator(screen.machine().root_device()).count() > 1) return string_format(_("Screen '%1$s'"), screen.tag()); @@ -2485,7 +2544,7 @@ static std::string slider_get_screen_desc(screen_device &screen) //------------------------------------------------- #ifdef MAME_DEBUG -static INT32 slider_crossscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_crossscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { ioport_field *field = (ioport_field *)arg; @@ -2504,7 +2563,7 @@ static INT32 slider_crossscale(running_machine &machine, void *arg, int id, std: //------------------------------------------------- #ifdef MAME_DEBUG -static INT32 slider_crossoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 mame_ui_manager::slider_crossoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { ioport_field *field = (ioport_field *)arg; diff --git a/src/frontend/mame/ui/ui.h b/src/frontend/mame/ui/ui.h index b81114c939c..299465e2d67 100644 --- a/src/frontend/mame/ui/ui.h +++ b/src/frontend/mame/ui/ui.h @@ -93,6 +93,59 @@ enum DRAW_OPAQUE }; +#define SLIDER_DEVICE_SPACING 0x0ff +#define SLIDER_SCREEN_SPACING 0x0f +#define SLIDER_INPUT_SPACING 0x0f + +enum +{ + SLIDER_ID_VOLUME = 0, + SLIDER_ID_MIXERVOL, + SLIDER_ID_MIXERVOL_LAST = SLIDER_ID_MIXERVOL + SLIDER_DEVICE_SPACING, + SLIDER_ID_ADJUSTER, + SLIDER_ID_ADJUSTER_LAST = SLIDER_ID_ADJUSTER + SLIDER_DEVICE_SPACING, + SLIDER_ID_OVERCLOCK, + SLIDER_ID_OVERCLOCK_LAST = SLIDER_ID_OVERCLOCK + SLIDER_DEVICE_SPACING, + SLIDER_ID_REFRESH, + SLIDER_ID_REFRESH_LAST = SLIDER_ID_REFRESH + SLIDER_SCREEN_SPACING, + SLIDER_ID_BRIGHTNESS, + SLIDER_ID_BRIGHTNESS_LAST = SLIDER_ID_BRIGHTNESS + SLIDER_SCREEN_SPACING, + SLIDER_ID_CONTRAST, + SLIDER_ID_CONTRAST_LAST = SLIDER_ID_CONTRAST + SLIDER_SCREEN_SPACING, + SLIDER_ID_GAMMA, + SLIDER_ID_GAMMA_LAST = SLIDER_ID_GAMMA + SLIDER_SCREEN_SPACING, + SLIDER_ID_XSCALE, + SLIDER_ID_XSCALE_LAST = SLIDER_ID_XSCALE + SLIDER_SCREEN_SPACING, + SLIDER_ID_YSCALE, + SLIDER_ID_YSCALE_LAST = SLIDER_ID_YSCALE + SLIDER_SCREEN_SPACING, + SLIDER_ID_XOFFSET, + SLIDER_ID_XOFFSET_LAST = SLIDER_ID_XOFFSET + SLIDER_SCREEN_SPACING, + SLIDER_ID_YOFFSET, + SLIDER_ID_YOFFSET_LAST = SLIDER_ID_YOFFSET + SLIDER_SCREEN_SPACING, + SLIDER_ID_OVERLAY_XSCALE, + SLIDER_ID_OVERLAY_XSCALE_LAST = SLIDER_ID_OVERLAY_XSCALE + SLIDER_SCREEN_SPACING, + SLIDER_ID_OVERLAY_YSCALE, + SLIDER_ID_OVERLAY_YSCALE_LAST = SLIDER_ID_OVERLAY_YSCALE + SLIDER_SCREEN_SPACING, + SLIDER_ID_OVERLAY_XOFFSET, + SLIDER_ID_OVERLAY_XOFFSET_LAST = SLIDER_ID_OVERLAY_XOFFSET + SLIDER_SCREEN_SPACING, + SLIDER_ID_OVERLAY_YOFFSET, + SLIDER_ID_OVERLAY_YOFFSET_LAST = SLIDER_ID_OVERLAY_YOFFSET + SLIDER_SCREEN_SPACING, + SLIDER_ID_FLICKER, + SLIDER_ID_FLICKER_LAST = SLIDER_ID_FLICKER + SLIDER_SCREEN_SPACING, + SLIDER_ID_BEAM_WIDTH_MIN, + SLIDER_ID_BEAM_WIDTH_MIN_LAST = SLIDER_ID_BEAM_WIDTH_MIN + SLIDER_SCREEN_SPACING, + SLIDER_ID_BEAM_WIDTH_MAX, + SLIDER_ID_BEAM_WIDTH_MAX_LAST = SLIDER_ID_BEAM_WIDTH_MAX + SLIDER_SCREEN_SPACING, + SLIDER_ID_BEAM_INTENSITY, + SLIDER_ID_BEAM_INTENSITY_LAST = SLIDER_ID_BEAM_INTENSITY + SLIDER_SCREEN_SPACING, + SLIDER_ID_CROSSHAIR_SCALE, + SLIDER_ID_CROSSHAIR_SCALE_LAST = SLIDER_ID_CROSSHAIR_SCALE + SLIDER_INPUT_SPACING, + SLIDER_ID_CROSSHAIR_OFFSET, + SLIDER_ID_CROSSHAIR_OFFSET_LAST = SLIDER_ID_CROSSHAIR_OFFSET + SLIDER_INPUT_SPACING, + + SLIDER_ID_CORE_LAST = SLIDER_ID_CROSSHAIR_OFFSET, + SLIDER_ID_CORE_COUNT +}; /*************************************************************************** TYPE DEFINITIONS @@ -103,7 +156,7 @@ typedef UINT32 (*ui_callback)(mame_ui_manager &, render_container *, UINT32); // ======================> mame_ui_manager -class mame_ui_manager : public ui_manager +class mame_ui_manager : public ui_manager, public slider_changed_notifier { public: // construction/destruction @@ -179,6 +232,7 @@ public: virtual void image_display(const device_type &type, device_image_interface *image) override; virtual void menu_reset() override; + private: // instance variables render_font * m_font; @@ -215,6 +269,36 @@ private: // private methods void exit(); + slider_state* slider_alloc(running_machine &machine, int id, const char *title, INT32 minval, INT32 defval, INT32 maxval, INT32 incval, void *arg); + + // slider controls + virtual INT32 slider_changed(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) override; + + INT32 slider_volume(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + INT32 slider_mixervol(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + INT32 slider_adjuster(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + INT32 slider_overclock(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + INT32 slider_refresh(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + INT32 slider_brightness(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + INT32 slider_contrast(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + INT32 slider_gamma(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + INT32 slider_xscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + INT32 slider_yscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + INT32 slider_xoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + INT32 slider_yoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + INT32 slider_overxscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + INT32 slider_overyscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + INT32 slider_overxoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + INT32 slider_overyoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + INT32 slider_flicker(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + INT32 slider_beam_width_min(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + INT32 slider_beam_width_max(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + INT32 slider_beam_intensity_weight(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + std::string slider_get_screen_desc(screen_device &screen); + #ifdef MAME_DEBUG + INT32 slider_crossscale(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + INT32 slider_crossoffset(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + #endif }; diff --git a/src/osd/modules/render/bgfx/chainmanager.cpp b/src/osd/modules/render/bgfx/chainmanager.cpp index d6e596cfc6b..34c891eb009 100644 --- a/src/osd/modules/render/bgfx/chainmanager.cpp +++ b/src/osd/modules/render/bgfx/chainmanager.cpp @@ -364,16 +364,7 @@ void chain_manager::update_screen_count(uint32_t screen_count) } } -static INT32 update_trampoline(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) -{ - if (arg != nullptr) - { - return reinterpret_cast(arg)->chain_changed(id, str, newval); - } - return 0; -} - -int32_t chain_manager::chain_changed(int32_t id, std::string *str, int32_t newval) +INT32 chain_manager::slider_changed(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { if (newval != SLIDER_NOCHANGE) { @@ -409,7 +400,9 @@ void chain_manager::create_selection_slider(uint32_t screen_index) state->defval = m_current_chain[screen_index]; state->maxval = m_available_chains.size() - 1; state->incval = 1; - state->update = update_trampoline; + + using namespace std::placeholders; + state->update = std::bind(&chain_manager::slider_changed, this, _1, _2, _3, _4, _5); state->arg = this; state->id = screen_index; strcpy(state->description, description.c_str()); @@ -461,7 +454,7 @@ uint32_t chain_manager::handle_screen_chains(uint32_t view, render_primitive *st } } } - + process_screen_quad(view + used_views, screen_index, prim, window); used_views += screen_chain(screen_index)->applicable_passes(); diff --git a/src/osd/modules/render/bgfx/chainmanager.h b/src/osd/modules/render/bgfx/chainmanager.h index a2531fdbc8f..083c93d634c 100644 --- a/src/osd/modules/render/bgfx/chainmanager.h +++ b/src/osd/modules/render/bgfx/chainmanager.h @@ -22,6 +22,7 @@ #include "targetmanager.h" #include "effectmanager.h" #include "../frontend/mame/ui/menuitem.h" +#include "../frontend/mame/ui/sliderchangednotifier.h" class running_machine; class osd_window; @@ -44,14 +45,13 @@ public: const std::string m_path; }; -class chain_manager +class chain_manager : public slider_changed_notifier { public: chain_manager(running_machine& machine, osd_options& options, texture_manager& textures, target_manager& targets, effect_manager& effects, uint32_t window_index, slider_dirty_notifier& slider_notifier); ~chain_manager(); uint32_t handle_screen_chains(uint32_t view, render_primitive *starting_prim, osd_window& window); - int32_t chain_changed(int32_t index, std::string *str, int32_t newval); // Getters running_machine& machine() const { return m_machine; } @@ -83,6 +83,8 @@ private: std::vector split_option_string(std::string chain_str) const; void update_screen_count(uint32_t screen_count); + + virtual INT32 slider_changed(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) override; void create_selection_slider(uint32_t screen_index); bool needs_sliders(); diff --git a/src/osd/modules/render/bgfx/inputpair.cpp b/src/osd/modules/render/bgfx/inputpair.cpp index b859667899e..bbe1ba503de 100644 --- a/src/osd/modules/render/bgfx/inputpair.cpp +++ b/src/osd/modules/render/bgfx/inputpair.cpp @@ -55,13 +55,9 @@ void bgfx_input_pair::bind(bgfx_effect *effect, const int32_t screen) const bgfx::setTexture(m_index, effect->uniform(m_sampler)->handle(), chains().textures().handle(name)); } -static INT32 update_trampoline(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 bgfx_input_pair::slider_changed(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) { - if (arg != nullptr) - { - return reinterpret_cast(arg)->texture_changed(id, str, newval); - } - return 0; + return texture_changed(id, str, newval); } int32_t bgfx_input_pair::texture_changed(int32_t id, std::string *str, int32_t newval) @@ -106,7 +102,9 @@ void bgfx_input_pair::create_selection_slider(uint32_t screen_index) state->defval = m_current_texture; state->maxval = m_available_textures.size() - 1; state->incval = 1; - state->update = update_trampoline; + + using namespace std::placeholders; + state->update = std::bind(&bgfx_input_pair::slider_changed, this, _1, _2, _3, _4, _5); state->arg = this; state->id = screen_index; strcpy(state->description, description.c_str()); diff --git a/src/osd/modules/render/bgfx/inputpair.h b/src/osd/modules/render/bgfx/inputpair.h index 4ec81552f19..37c890c3f13 100644 --- a/src/osd/modules/render/bgfx/inputpair.h +++ b/src/osd/modules/render/bgfx/inputpair.h @@ -17,11 +17,12 @@ #include #include "../frontend/mame/ui/menuitem.h" +#include "../frontend/mame/ui/sliderchangednotifier.h" class bgfx_effect; class chain_manager; -class bgfx_input_pair +class bgfx_input_pair : public slider_changed_notifier { public: bgfx_input_pair(int index, std::string sampler, std::string texture, std::vector available_textures, std::string selection, chain_manager& chains, uint32_t screen_index); @@ -36,6 +37,7 @@ public: std::vector get_slider_list(); private: + virtual INT32 slider_changed(running_machine &machine, void *arg, int /*id*/, std::string *str, INT32 newval) override; void create_selection_slider(uint32_t screen_index); bool needs_sliders(); diff --git a/src/osd/modules/render/bgfx/slider.cpp b/src/osd/modules/render/bgfx/slider.cpp index 29d7fd0f821..3b269eb08e6 100644 --- a/src/osd/modules/render/bgfx/slider.cpp +++ b/src/osd/modules/render/bgfx/slider.cpp @@ -37,7 +37,7 @@ bgfx_slider::~bgfx_slider() { } -static INT32 update_trampoline(running_machine &machine, void *arg, int /*id*/, std::string *str, INT32 newval) +INT32 bgfx_slider::slider_changed(running_machine& /*machine*/, void *arg, int /*id*/, std::string *str, INT32 newval) { if (arg != nullptr) { @@ -49,7 +49,7 @@ static INT32 update_trampoline(running_machine &machine, void *arg, int /*id*/, void bgfx_slider::import(float val) { m_value = val; - update_trampoline(m_machine, this, m_slider_state->id, nullptr, int32_t(floor(m_value / m_step + 0.5f))); + slider_changed(m_machine, this, m_slider_state->id, nullptr, int32_t(floor(m_value / m_step + 0.5f))); } slider_state* bgfx_slider::create_core_slider(running_machine& machine) @@ -61,7 +61,10 @@ slider_state* bgfx_slider::create_core_slider(running_machine& machine) state->defval = int32_t(floor(m_default / m_step + 0.5f)); state->maxval = int32_t(floor(m_max / m_step + 0.5f)); state->incval = int32_t(floor(m_step / m_step + 0.5f)); - state->update = update_trampoline; + + using namespace std::placeholders; + state->update = std::bind(&bgfx_slider::slider_changed, this, _1, _2, _3, _4, _5); + state->arg = this; state->id = 0; strcpy(state->description, m_description.c_str()); diff --git a/src/osd/modules/render/bgfx/slider.h b/src/osd/modules/render/bgfx/slider.h index fca9d43f6a8..88b8ef6b6cb 100644 --- a/src/osd/modules/render/bgfx/slider.h +++ b/src/osd/modules/render/bgfx/slider.h @@ -19,7 +19,7 @@ #include "emu.h" #include "../frontend/mame/ui/slider.h" -class bgfx_slider +class bgfx_slider : public slider_changed_notifier { public: enum slider_type @@ -44,7 +44,7 @@ public: }; bgfx_slider(running_machine& machine, std::string name, float min, float def, float max, float step, slider_type type, screen_type screen, std::string format, std::string description, std::vector& strings); - ~bgfx_slider(); + virtual ~bgfx_slider(); int32_t update(std::string *str, int32_t newval); @@ -61,6 +61,7 @@ public: void import(float val); protected: + virtual INT32 slider_changed(running_machine &machine, void *arg, int /*id*/, std::string *str, INT32 newval) override; slider_state* create_core_slider(running_machine &machine); int32_t as_int() const { return int32_t(floor(m_value / m_step + 0.5f)); } diff --git a/src/osd/modules/render/d3d/d3dhlsl.cpp b/src/osd/modules/render/d3d/d3dhlsl.cpp index a2496408d8d..2864d740bb7 100644 --- a/src/osd/modules/render/d3d/d3dhlsl.cpp +++ b/src/osd/modules/render/d3d/d3dhlsl.cpp @@ -2184,7 +2184,7 @@ static void get_vector(const char *data, int count, float *out, bool report_erro // be done in a more ideal way. //============================================================ -static slider_state *slider_alloc(running_machine &machine, int id, const char *title, INT32 minval, INT32 defval, INT32 maxval, INT32 incval, slider_update update, void *arg) +slider_state* shaders::slider_alloc(running_machine &machine, int id, const char *title, INT32 minval, INT32 defval, INT32 maxval, INT32 incval, void *arg) { int size = sizeof(slider_state) + strlen(title); slider_state *state = reinterpret_cast(auto_alloc_array_clear(machine, UINT8, size)); @@ -2193,7 +2193,10 @@ static slider_state *slider_alloc(running_machine &machine, int id, const char * state->defval = defval; state->maxval = maxval; state->incval = incval; - state->update = update; + + using namespace std::placeholders; + state->update = std::bind(&shaders::slider_changed, this, _1, _2, _3, _4, _5); + state->arg = arg; state->id = id; strcpy(state->description, title); @@ -2267,7 +2270,7 @@ INT32 slider::update(std::string *str, INT32 newval) return 0; } -static INT32 slider_update_trampoline(running_machine &machine, void *arg, int id, std::string *str, INT32 newval) +INT32 shaders::slider_changed(running_machine& /*machine*/, void *arg, int /*id*/, std::string *str, INT32 newval) { if (arg != nullptr) { @@ -2558,7 +2561,7 @@ std::vector shaders::init_slider_list() break; } - slider_state* core_slider = slider_alloc(*machine, desc->id, name.c_str(), desc->minval, desc->defval, desc->maxval, desc->step, slider_update_trampoline, slider_arg); + slider_state* core_slider = slider_alloc(*machine, desc->id, name.c_str(), desc->minval, desc->defval, desc->maxval, desc->step, slider_arg); ui::menu_item item; item.text = core_slider->description; diff --git a/src/osd/modules/render/d3d/d3dhlsl.h b/src/osd/modules/render/d3d/d3dhlsl.h index 96491c9491b..abf1e48a549 100644 --- a/src/osd/modules/render/d3d/d3dhlsl.h +++ b/src/osd/modules/render/d3d/d3dhlsl.h @@ -12,6 +12,7 @@ #include #include "aviio.h" #include "../frontend/mame/ui/menuitem.h" +#include "../frontend/mame/ui/slider.h" //============================================================ // CONSTANTS @@ -290,7 +291,7 @@ private: bool * m_dirty; }; -class shaders +class shaders : public slider_changed_notifier { friend class effect; friend class uniform; @@ -342,6 +343,8 @@ public: void delete_resources(bool reset); // slider-related functions + virtual INT32 slider_changed(running_machine &machine, void *arg, int /*id*/, std::string *str, INT32 newval) override; + slider_state* slider_alloc(running_machine &machine, int id, const char *title, INT32 minval, INT32 defval, INT32 maxval, INT32 incval, void *arg); std::vector init_slider_list(); void *get_slider_option(int id, int index = 0); From 88bb5e0deb3bc806ada4f7173f7d9e09aad89aa2 Mon Sep 17 00:00:00 2001 From: RobertoFresca Date: Sat, 28 May 2016 12:40:55 -0300 Subject: [PATCH 11/11] Magic Fly driver: Refactored PCB layout and pinout with new findings and PCB trace. Also added some technical notes [Roberto Fresca]. --- src/mame/drivers/magicfly.cpp | 179 +++++++++++++++++----------------- 1 file changed, 92 insertions(+), 87 deletions(-) diff --git a/src/mame/drivers/magicfly.cpp b/src/mame/drivers/magicfly.cpp index 2c91e42f84b..149f3864806 100644 --- a/src/mame/drivers/magicfly.cpp +++ b/src/mame/drivers/magicfly.cpp @@ -1,6 +1,6 @@ // license:BSD-3-Clause // copyright-holders:Roberto Fresca -// thanks-to:Iris Falbala,Rob Ragon +// thanks-to:Iris Falbala, Rob Ragon /****************************************************************************** MAGIC FLY @@ -66,103 +66,108 @@ PCB Layout: - _________________________________________________________________ + .-----------------------------------------------------------------. | | | | - | _________ _________ | - | | 74LS08N | | 74LS32 | | - | |_________| |_________| | - | _________ _________ | + | POWER .---------. .---------. | + | SUPPLY | 74LS08N | | 74LS32 | | + | '---------' '---------' | + | .---------. .---------. | | | 74LS138 | | 74HC00 | | - | |_________| |_________| | - | ______________ ______________________ | - | | | | | ____| - | | MK48Z02B-20 | | R6502P | | - | |______________| |______________________| | - | ________________ _________ ______________________ | - | | | | 74LS157 | | | |____ - | | AM27128 | |_________| | MC6845P | ____| - | |________________| _________ |______________________| ____| - | | 74LS157 | ________ _________ ____| - | |_________| | 74LS14 | | 74LS374 | ____| - | ____________ _________ |________| |_________| ____| - | | 74LS245 | | 74LS157 | _________ ____| - | |____________| |_________| | 74HC244 | ____| - | ____________ _________ |_________| ____| - | | 74LS245 | | 74LS32 | _______ ____| 30x2 - | |____________| |_________| | | | | | ____| connector - | ______________ |4|3|2|1| ____| - | | HM6116 | |_|_|_|_| ____| - | | o MSM2128 | ____| - | |______________| DIP SW x4 ____| - | ______________ ____| - | | HM6116 | ________ _________ ____| - | | o MSM2128 | | 74LS08 | | 74LS174 | ____| - | |______________| |________| |_________| ____| - | ________________ __________ ______ ____| - | | | | PAL16R4A | | TDA |- ____| - | | 2764 | |__________| | 2002 |- ____| - | |________________| __________ |______|- ____| - | ________________ | 74LS166 | ____| - | | | |__________| _ | - | | 2764 | __________ / \ | - | |________________| | 74LS166 | | pot | |____ - | ________________ |__________| \ _ / __| - | | | __________ _________ ______| | - | | 2764 | | 74LS166 | | 74LS05 | _ |ss112d|8 | 10 - | |________________| |__________| |_________| / \ |______|8 | pins - | ________ ______ __________ _________ | pot ||ss112d|8 | male - | | 74LS04 || osc. | | 74LS193 | | 74LS86 | \ _ / |______|8 | connector - | |________||10 MHz| |__________| |_________| |ss112d|8 | - | |______| |______|__| - |_________________________________________________________________| + | '---------' '---------' | + | .--------------. .----------------------. | + | | MK48Z02B-20 | | R6502P | .----' + | | | | | | + | '--------------' '----------------------' | + | .----------------. .---------. .----------------------. | + | | AM27128 | | 74LS157 | | MC6845P | '----. + | | | '---------' | | ----| + | '----------------' .---------. '----------------------' ----| + | | 74LS157 | .--------. .---------. ----| + | '---------' | 74LS14 | | 74LS374 | ----| + | .------------. .---------. '--------' '---------' ----| + | | 74LS245 | | 74LS157 | .---------. ----| + | '------------' '---------' | 74HC244 | ----| + | .------------. .---------. '---------' ----| + | | 74LS245 | | 74LS32 | .-------. ----| 30x2 + | '------------' '---------' | | | | | ----| connector + | .--------------. |4|3|2|1| ----| + | | HM6116 | | | | | | ----| + | | o MSM2128 | '-------' ----| + | '--------------' DIP SW x4 ----| + | .--------------. ----| + | | HM6116 | .--------. .---------. ----| + | | o MSM2128 | | 74LS08 | | 74LS174 | ----| + | '--------------' '--------' '---------' ----| + | .----------------. .----------. .------. ----| + | | 2764 | | PAL16R4A | | TDA | ----| + | | | '----------' | 2002 | ----| + | '----------------' .----------. '------' ----| + | .----------------. | 74LS166 | .---. .----' + | | 2764 | '----------' / POT \ | + | | | .----------. \ / | + | '----------------' | 74LS166 | '---' '----. + | .----------------. '----------' .--| + | | 2764 | .----------. .---------. .------| | + | | | | 74LS166 | | 74LS05 | .---. |SS112D|8 | 10 + | '----------------' '----------' '---------' / POT \|------|8 | pins + | .--------..------. .----------. .---------. \ /|SS112D|8 | male + | | 74LS04 ||10 MHz| | 74LS193 | | 74LS86 | '---' |------|8 | connector + | '--------'| XTAL | '----------' '---------' |SS112D|8 | + | '------' '------| | + | '--| + '-----------------------------------------------------------------' - Pinouts (from 7mezzo pinout sheet) - ---------------------------------- + Pinouts (from almost unreadable 7mezzo pinout sheet + PCB trace) + ---------------------------------------------------------------- *********** Edge connector ************ - solder side connector parts side + Solder side |Conn| Components side + ----------------+----+--------------------- + GND | 30 | GND + +10V. AC | 29 | +10V. AC + +10V. AC | 28 | +10V. AC + unused | 27 | unused + unused | 26 | unused + GND | 25 | GND + +12V. AC | 24 | +12V. AC + +12V. AC | 23 | +12V. AC + unused | 22 | unused + Common C (3) | 21 | Common A (1) + Common D (4) | 20 | Common B (2) + Deal | 19 | Double + Hold 1 | 18 | Cancel + Hold 2 | 17 | Hold 5 + Hold 3 | 16 | Hold 4 + Meters | 15 | Bet + Coupon | 14 | + | 13 | Coin 1 + (unreadable) | 12 | Coin 2 + Take | 11 | Payout + Small (play1) | 10 | Big (play3) + unused | 09 | unused + unused | 08 | unused + unused | 07 | unused + Green | 06 | Red + Sync | 05 | Blue + GND | 04 | GND + Speaker+ | 03 | Speaker+ + Speaker- (GND) | 02 | Speaker- (GND) + +5V. | 01 | +5V. - GND 30 GND - +10v. 29 +10v. - +10v. 28 +10v. - unused 27 unused - unused 26 unused - GND 25 GND - +12v. 24 +12v. - +12v. 23 +12v. - unused 22 unused - common C (3) 21 common A (1) - common D (4) 20 common B (2) - DEAL 19 DOUBLE - HOLD 1 18 (unreadable) - HOLD 2 17 HOLD 5 - HOLD 3 16 HOLD 4 - METER 15 BET - COUPON 14 - 13 COIN 1 - (unreadable) 12 COIN 2 - TAKE 11 PAY - SMALL (play1) 10 BIG (play3) - unused 09 unused - unused 08 unused - unused 07 unused - (unreadable) 06 (unreadable) - sync 05 (unreadable) - GND 04 GND - speaker+ 03 speaker+ - speaker- (GND) 02 speaker- (GND) - +5v. 01 +5v. + (1) = Double, Deal, Cancel, Bet, Meters. + (2) = Take, Small, Big, Pay. + (3) = Hold 1, Hold 2, Hold 3, Hold 4, Hold 5. + (4) = Coin 1, Coin 2, Coupon. - (1) = DOUBLE, DEAL, (unreadable), BET, METER - (2) = TAKE, SMALL, BIG, PAY - (3) = HOLD 1, HOLD 2, HOLD 3, HOLD 4, HOLD 5 - (4) = COIN 1, COIN 2, COUPON + Note: Each Common GND (A-B-C-D) are for their respective + multiplexed groups of inputs, since there are 4 groups + with 5 valid inputs each one. - **** Pins connector **** + **** 10-Pins connector **** pin 01: (soldered to pin 05) pin 02: @@ -242,7 +247,7 @@ Counters. ; Bits 4-5-6 are used for Coin1, Coin2, and Payout counters. Sound DAC, ; Bit 7 is used to transmit DAC data. - $C000 - $FFFF ROM space ; Program ROMs. + $C000 - $FFFF ROM space ; Program ROM. *******************************************************************************