diff --git a/docs/source/debugger/cheats.rst b/docs/source/debugger/cheats.rst index 0e8bdea5c60..52f81259907 100644 --- a/docs/source/debugger/cheats.rst +++ b/docs/source/debugger/cheats.rst @@ -30,7 +30,6 @@ infinite lives cheat for Raiden (``raiden``): :ref:`cheatinit command `:: >cheatinit ub - MAME debugger version 0.237 (mame0237) 36928 cheat locations initialized for NEC V30 ':maincpu' program space * Allow the game to run, lose a life and break into the debugger. * Use the :ref:`cheatnext command ` to @@ -55,7 +54,7 @@ infinite lives cheat for Raiden (``raiden``): diff --git a/plugins/autofire/init.lua b/plugins/autofire/init.lua index 72ee65672d4..cfb055b7465 100644 --- a/plugins/autofire/init.lua +++ b/plugins/autofire/init.lua @@ -1,11 +1,11 @@ -- license:BSD-3-Clause -- copyright-holders:Jack Li -local exports = {} -exports.name = 'autofire' -exports.version = '0.0.3' -exports.description = 'Autofire plugin' -exports.license = 'The BSD 3-Clause License' -exports.author = { name = 'Jack Li' } +local exports = { + name = 'autofire', + version = '0.0.3', + description = 'Autofire plugin', + license = 'The BSD 3-Clause License', + author = { name = 'Jack Li' } } local autofire = exports diff --git a/plugins/autofire/plugin.json b/plugins/autofire/plugin.json index a803c8be09e..56c36ba751f 100644 --- a/plugins/autofire/plugin.json +++ b/plugins/autofire/plugin.json @@ -1,10 +1,10 @@ { - "plugin": { - "name": "autofire", - "description": "Autofire plugin", - "version": "0.0.3", - "author": "Jack Li", - "type": "plugin", - "start": "false" - } + "plugin": { + "name": "autofire", + "description": "Autofire plugin", + "version": "0.0.3", + "author": "Jack Li", + "type": "plugin", + "start": "false" + } } diff --git a/plugins/timer/init.lua b/plugins/timer/init.lua index f0ddabbcf50..07b3e20162b 100644 --- a/plugins/timer/init.lua +++ b/plugins/timer/init.lua @@ -91,16 +91,13 @@ function timer.startplugin() local function menu_populate() local time = os.time() - start_time - return {{ _("Current time"), "", "off" }, - { sectohms(time), "", "off" }, - { _("Total time"), "", "off" }, - { sectohms(total_time + time), "", "off" }, - { _("Play Count"), "", "off" }, - { play_count, "", "off" }} + return {{ _("Current time"), sectohms(time), "off" }, + { _("Total time"), sectohms(total_time + time), "off" }, + { _("Play Count"), play_count, "off" }} end local function menu_callback(index, event) - return true + return false end emu.register_menu(menu_callback, menu_populate, _("Timer")) diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp index 04cce880600..c9ee9c17e71 100644 --- a/src/emu/debug/debugcmd.cpp +++ b/src/emu/debug/debugcmd.cpp @@ -88,11 +88,11 @@ bool debugger_commands::cheat_address_is_valid(address_space &space, offs_t addr the current cheat width, if signed -------------------------------------------------*/ -u64 debugger_commands::cheat_sign_extend(const cheat_system *cheatsys, u64 value) +inline u64 debugger_commands::cheat_system::sign_extend(u64 value) const { - if (cheatsys->signed_cheat) + if (signed_cheat) { - switch (cheatsys->width) + switch (width) { case 1: value = s8(value); break; case 2: value = s16(value); break; @@ -106,11 +106,11 @@ u64 debugger_commands::cheat_sign_extend(const cheat_system *cheatsys, u64 value cheat_byte_swap - swap a value -------------------------------------------------*/ -u64 debugger_commands::cheat_byte_swap(const cheat_system *cheatsys, u64 value) +inline u64 debugger_commands::cheat_system::byte_swap(u64 value) const { - if (cheatsys->swapped_cheat) + if (swapped_cheat) { - switch (cheatsys->width) + switch (width) { case 2: value = swapendian_int16(value); break; case 4: value = swapendian_int32(value); break; @@ -126,21 +126,21 @@ u64 debugger_commands::cheat_byte_swap(const cheat_system *cheatsys, u64 value) and swapping if necessary -------------------------------------------------*/ -u64 debugger_commands::cheat_read_extended(const cheat_system *cheatsys, address_space &space, offs_t address) +u64 debugger_commands::cheat_system::read_extended(offs_t address) const { - address &= space.logaddrmask(); - u64 value = space.unmap(); - if (space.device().memory().translate(space.spacenum(), TRANSLATE_READ_DEBUG, address)) + address &= space->logaddrmask(); + u64 value = space->unmap(); + if (space->device().memory().translate(space->spacenum(), TRANSLATE_READ_DEBUG, address)) { - switch (cheatsys->width) + switch (width) { - case 1: value = space.read_byte(address); break; - case 2: value = space.read_word_unaligned(address); break; - case 4: value = space.read_dword_unaligned(address); break; - case 8: value = space.read_qword_unaligned(address); break; + case 1: value = space->read_byte(address); break; + case 2: value = space->read_word_unaligned(address); break; + case 4: value = space->read_dword_unaligned(address); break; + case 8: value = space->read_qword_unaligned(address); break; } } - return cheat_sign_extend(cheatsys, cheat_byte_swap(cheatsys, value)); + return sign_extend(byte_swap(value)); } debugger_commands::debugger_commands(running_machine& machine, debugger_cpu& cpu, debugger_console& console) @@ -3004,7 +3004,7 @@ void debugger_commands::execute_cheatrange(bool init, const std::vector 1 && !validate_number_parameter(params[1], comp_value)) return; - comp_value = cheat_sign_extend(&m_cheat, comp_value); + comp_value = m_cheat.sign_extend(comp_value); // decode condition u8 condition; @@ -3093,8 +3093,10 @@ void debugger_commands::execute_cheatnext(bool initial, const std::vector ¶ms } } + // get device/space syntax for memory access std::string tag(space->device().tag()); - char spaceletter; + std::string spaceletter; switch (space->spacenum()) { - case AS_PROGRAM: spaceletter = 'p'; break; - case AS_DATA: spaceletter = 'd'; break; - case AS_IO: spaceletter = 'i'; break; - case AS_OPCODES: spaceletter = '3'; break; - default: - tag.append(1, ':'); - tag.append(space->name()); - spaceletter = 'p'; + default: + tag.append(1, ':'); + tag.append(space->name()); + break; + case AS_PROGRAM: + spaceletter = "p"; + break; + case AS_DATA: + spaceletter = "d"; + break; + case AS_IO: + spaceletter = "i"; + break; + case AS_OPCODES: + spaceletter = "3"; + break; } + // get size syntax for memory access and formatting values + bool const octal = space->is_octal(); + int const addrchars = octal + ? ((2 + space->logaddr_width()) / 3) + : ((3 + space->logaddr_width()) / 4); + int const datachars = octal + ? ((2 + (m_cheat.width * 8)) / 3) + : ((3 + (m_cheat.width * 8)) / 4); + u64 const sizemask = util::make_bitmask(m_cheat.width * 8); char sizeletter; - u64 sizemask; switch (m_cheat.width) { - default: - case 1: sizeletter = 'b'; sizemask = 0xffU; break; - case 2: sizeletter = 'w'; sizemask = 0xffffU; break; - case 4: sizeletter = 'd'; sizemask = 0xffffffffU; break; - case 8: sizeletter = 'q'; sizemask = 0xffffffffffffffffU; break; + default: + case 1: sizeletter = 'b'; break; + case 2: sizeletter = 'w'; break; + case 4: sizeletter = 'd'; break; + case 8: sizeletter = 'q'; break; } // write the cheat list @@ -3250,7 +3269,8 @@ void debugger_commands::execute_cheatlist(const std::vector ¶ms { if (m_cheat.cheatmap[cheatindex].state == 1) { - u64 const value = cheat_byte_swap(&m_cheat, cheat_read_extended(&m_cheat, *space, m_cheat.cheatmap[cheatindex].offset)) & sizemask; + u64 const value = m_cheat.byte_swap(m_cheat.read_extended(m_cheat.cheatmap[cheatindex].offset)) & sizemask; + u64 const first_value = m_cheat.byte_swap(m_cheat.cheatmap[cheatindex].first_value) & sizemask; offs_t const address = space->byte_to_address(m_cheat.cheatmap[cheatindex].offset); if (!params.empty()) @@ -3260,23 +3280,31 @@ void debugger_commands::execute_cheatlist(const std::vector ¶ms output.rdbuf()->clear(); stream_format( output, - " \n" - " \n" - " \n\n", - active_cheat, space->logaddrchars(), address, m_cheat.width * 2, value, - tag, spaceletter, sizeletter, space->logaddrchars(), address, m_cheat.width * 2, cheat_byte_swap(&m_cheat, m_cheat.cheatmap[cheatindex].first_value) & sizemask); + octal ? + " \n" + " \n" + " \n\n" : + " \n" + " \n" + " \n\n", + active_cheat, addrchars, address, datachars, value, + tag, spaceletter, sizeletter, addrchars, address, datachars, first_value); auto const &text(output.vec()); fprintf(f, "%.*s", int(unsigned(text.size())), &text[0]); } else { m_console.printf( - "Address=%0*X Start=%0*X Current=%0*X\n", - space->logaddrchars(), address, - m_cheat.width * 2, cheat_byte_swap(&m_cheat, m_cheat.cheatmap[cheatindex].first_value) & sizemask, - m_cheat.width * 2, value); + octal + ? "Address=0%0*o Start=0%0*o Current=0%0*o\n" + : "Address=%0*X Start=%0*X Current=%0*X\n", + addrchars, address, + datachars, first_value, + datachars, value); } } } diff --git a/src/emu/debug/debugcmd.h b/src/emu/debug/debugcmd.h index 6c82ca143c1..fd0bcea673a 100644 --- a/src/emu/debug/debugcmd.h +++ b/src/emu/debug/debugcmd.h @@ -73,6 +73,10 @@ private: u8 swapped_cheat; std::vector cheatmap; u8 undo; + + u64 sign_extend(u64 value) const; + u64 byte_swap(u64 value) const; + u64 read_extended(offs_t address) const; }; struct cheat_region_map @@ -89,9 +93,6 @@ private: bool debug_command_parameter_command(const char *param); bool cheat_address_is_valid(address_space &space, offs_t address); - u64 cheat_sign_extend(const cheat_system *cheatsys, u64 value); - u64 cheat_byte_swap(const cheat_system *cheatsys, u64 value); - u64 cheat_read_extended(const cheat_system *cheatsys, address_space &space, offs_t address); u64 get_cpunum(); diff --git a/src/frontend/mame/ui/datmenu.cpp b/src/frontend/mame/ui/datmenu.cpp index 1d3ef0c7cff..10c5e3c9717 100644 --- a/src/frontend/mame/ui/datmenu.cpp +++ b/src/frontend/mame/ui/datmenu.cpp @@ -70,20 +70,20 @@ menu_dats_view::menu_dats_view(mame_ui_manager &mui, render_container &container // ctor //------------------------------------------------- -menu_dats_view::menu_dats_view(mame_ui_manager &mui, render_container &container, const ui_software_info *swinfo, const ui_system_info *system) +menu_dats_view::menu_dats_view(mame_ui_manager &mui, render_container &container, const ui_software_info &swinfo) : menu(mui, container) - , m_system(!system ? &system_list::instance().systems()[driver_list::find(mui.machine().system().name)] : system) - , m_swinfo(swinfo) + , m_system(nullptr) + , m_swinfo(&swinfo) , m_issoft(true) , m_layout() , m_actual(0) - , m_list(swinfo->listname) - , m_short(swinfo->shortname) - , m_long(swinfo->longname) - , m_parent(swinfo->parentname) + , m_list(swinfo.listname) + , m_short(swinfo.shortname) + , m_long(swinfo.longname) + , m_parent(swinfo.parentname) { - if (!swinfo->infotext.empty()) + if (!swinfo.infotext.empty()) m_items_list.emplace_back(_("Software List Info"), 0, ""); std::vector lua_list; if (mame_machine_manager::instance()->lua()->call_plugin("data_list", std::string(m_short).append(1, ',').append(m_list).c_str(), lua_list)) diff --git a/src/frontend/mame/ui/datmenu.h b/src/frontend/mame/ui/datmenu.h index ccc8bd8b2a4..9e81d9e2d2e 100644 --- a/src/frontend/mame/ui/datmenu.h +++ b/src/frontend/mame/ui/datmenu.h @@ -36,7 +36,7 @@ namespace ui { class menu_dats_view : public menu { public: - menu_dats_view(mame_ui_manager &mui, render_container &container, const ui_software_info *swinfo, const ui_system_info *system = nullptr); + menu_dats_view(mame_ui_manager &mui, render_container &container, const ui_software_info &swinfo); menu_dats_view(mame_ui_manager &mui, render_container &container, const ui_system_info *system = nullptr); virtual ~menu_dats_view() override; diff --git a/src/frontend/mame/ui/mainmenu.cpp b/src/frontend/mame/ui/mainmenu.cpp index 32240167318..73084728edb 100644 --- a/src/frontend/mame/ui/mainmenu.cpp +++ b/src/frontend/mame/ui/mainmenu.cpp @@ -159,8 +159,9 @@ void menu_main::populate(float &customtop, float &custombottom) if (machine().options().plugins() && !mame_machine_manager::instance()->lua()->get_menu().empty()) item_append(_("Plugin Options"), 0, (void *)PLUGINS); - if (mame_machine_manager::instance()->lua()->call_plugin_check("data_list", "", true)) - item_append(_("External DAT View"), 0, (void *)EXTERNAL_DATS); + if (machine().phase() >= machine_phase::RESET) + if (mame_machine_manager::instance()->lua()->call_plugin_check("data_list", "", true)) + item_append(_("External DAT View"), 0, (void *)EXTERNAL_DATS); item_append(menu_item_type::SEPARATOR); diff --git a/src/frontend/mame/ui/pluginopt.cpp b/src/frontend/mame/ui/pluginopt.cpp index 83faaa43603..d36503cdcee 100644 --- a/src/frontend/mame/ui/pluginopt.cpp +++ b/src/frontend/mame/ui/pluginopt.cpp @@ -72,40 +72,40 @@ void menu_plugin_opt::handle() { const event *menu_event = process(0); - if (menu_event && uintptr_t(menu_event->itemref)) + if (menu_event) { std::string key; switch (menu_event->iptkey) { - case IPT_UI_UP: - key = "up"; - break; - case IPT_UI_DOWN: - key = "down"; - break; - case IPT_UI_LEFT: - key = "left"; - break; - case IPT_UI_RIGHT: - key = "right"; - break; - case IPT_UI_SELECT: - key = "select"; - break; - case IPT_UI_DISPLAY_COMMENT: - key = "comment"; - break; - case IPT_UI_CLEAR: - key = "clear"; - break; - case IPT_UI_CANCEL: - key = "cancel"; - break; - case IPT_SPECIAL: - key = std::to_string((u32)menu_event->unichar); - break; - default: - return; + case IPT_UI_UP: + key = "up"; + break; + case IPT_UI_DOWN: + key = "down"; + break; + case IPT_UI_LEFT: + key = "left"; + break; + case IPT_UI_RIGHT: + key = "right"; + break; + case IPT_UI_SELECT: + key = "select"; + break; + case IPT_UI_DISPLAY_COMMENT: + key = "comment"; + break; + case IPT_UI_CLEAR: + key = "clear"; + break; + case IPT_UI_CANCEL: + key = "cancel"; + break; + case IPT_SPECIAL: + key = std::to_string((u32)menu_event->unichar); + break; + default: + return; } if (mame_machine_manager::instance()->lua()->menu_callback(m_menu, uintptr_t(menu_event->itemref), key)) reset(reset_options::REMEMBER_REF); diff --git a/src/frontend/mame/ui/selmenu.cpp b/src/frontend/mame/ui/selmenu.cpp index 303334de17b..c5718bdc564 100644 --- a/src/frontend/mame/ui/selmenu.cpp +++ b/src/frontend/mame/ui/selmenu.cpp @@ -856,7 +856,7 @@ void menu_select_launch::inkey_dats() ui_system_info const *system; get_selection(software, system); if (software && !software->startempty) - menu::stack_push(ui(), container(), software); + menu::stack_push(ui(), container(), *software); else if (system) menu::stack_push(ui(), container(), system); }