From b67b969bf0911d71396c77e42d85ddfe80de6f20 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Fri, 7 Apr 2023 06:20:40 +1000 Subject: -Improved some Lua APIs: * Moved several machine lifecycle callbacks to the notifier/subscriber model. The old callback registration model is still available for them for now, but prints a deprecation warning. * Added pre-save/post-load notifications. * Use a single allocated timer rather than one anonymous timer per waiter. Waiters no longer prevent saved states from being loaded. * Clean up outstanding waiters on stop or state load rather than just leaking them. * Started documenting parts of the emulator interface object that should be relatively stable. -imagedev/avivideo.cpp: Fixed an object leak on unload. Also changed some other media image devices to use smart pointers. --- docs/source/conf.py | 4 +- docs/source/plugins/dummy.rst | 5 +- docs/source/techspecs/luaengine.rst | 12 ++--- docs/source/techspecs/luareference.rst | 88 ++++++++++++++++++++++++++++++++-- plugins/autofire/init.lua | 6 ++- plugins/cheat/init.lua | 8 ++-- plugins/cheatfind/init.lua | 4 +- plugins/console/init.lua | 10 ++-- plugins/data/init.lua | 4 +- plugins/discord/init.lua | 20 ++++---- plugins/dummy/init.lua | 18 ++++--- plugins/gdbstub/init.lua | 18 +++---- plugins/hiscore/init.lua | 11 +++-- plugins/inputmacro/init.lua | 6 ++- plugins/layout/init.lua | 22 +++++---- plugins/timecode/init.lua | 6 ++- plugins/timer/init.lua | 11 +++-- src/devices/bus/isa/mcd.cpp | 2 +- src/devices/bus/qbus/pc11.h | 8 ++-- src/devices/bus/saturn/sat_slot.cpp | 14 +----- src/devices/bus/scv/slot.cpp | 9 ++-- src/devices/bus/sdk85/memexp.cpp | 8 ++-- src/devices/bus/sega8/sega8_slot.cpp | 11 ++--- src/devices/bus/snes/snes_slot.cpp | 16 +++---- src/devices/bus/spectrum/intf2.cpp | 2 +- src/devices/bus/ti99x/990_tap.cpp | 4 +- src/devices/bus/vc4000/slot.cpp | 4 +- src/devices/bus/vcs/vcs_slot.cpp | 4 +- src/devices/bus/vcs/vcs_slot.h | 8 ++-- src/devices/bus/vectrex/slot.cpp | 5 +- src/devices/bus/vic10/exp.cpp | 4 +- src/devices/bus/vic20/exp.cpp | 2 +- src/devices/bus/vidbrain/exp.cpp | 16 +++---- src/devices/bus/vsmile/vsmile_slot.cpp | 14 ++---- src/devices/bus/wswan/slot.cpp | 7 ++- src/devices/bus/wswan/slot.h | 8 ++-- src/devices/bus/z88/z88.cpp | 21 ++++---- src/devices/bus/z88/z88.h | 6 +-- src/devices/imagedev/avivideo.cpp | 23 +++------ src/devices/imagedev/avivideo.h | 10 +++- src/devices/imagedev/cassette.h | 4 +- src/devices/imagedev/chd_cd.cpp | 47 ++++++++---------- src/devices/imagedev/chd_cd.h | 17 +++++-- src/devices/imagedev/diablo.cpp | 57 ++++++++-------------- src/devices/imagedev/diablo.h | 17 +++++-- src/devices/imagedev/flopdrv.cpp | 7 +-- src/devices/imagedev/flopdrv.h | 2 +- src/devices/imagedev/floppy.h | 4 +- src/devices/imagedev/harddriv.cpp | 62 +++++++++--------------- src/devices/imagedev/harddriv.h | 23 +++++---- src/devices/imagedev/mfmhd.cpp | 31 ++++++------ src/devices/imagedev/mfmhd.h | 4 +- src/devices/imagedev/midiin.cpp | 20 ++++---- src/devices/imagedev/midiin.h | 11 +++-- src/devices/imagedev/midiout.cpp | 8 ++-- src/devices/imagedev/midiout.h | 11 +++-- src/devices/imagedev/picture.cpp | 5 +- src/devices/imagedev/printer.cpp | 4 +- src/devices/imagedev/snapquik.cpp | 4 +- src/devices/imagedev/wafadrive.cpp | 4 +- src/devices/imagedev/wafadrive.h | 4 +- src/devices/machine/pccard_sram.cpp | 2 +- src/devices/machine/smartmed.cpp | 3 +- src/devices/machine/smartmed.h | 2 +- 64 files changed, 436 insertions(+), 376 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 6b3b080952f..8251128d44c 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -63,9 +63,9 @@ copyright = u'1997-2023, MAMEdev and contributors' # built documents. # # The short X.Y version. -version = '0.253' +version = '0.254' # The full version, including alpha/beta/rc tags. -release = '0.253' +release = '0.254' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/source/plugins/dummy.rst b/docs/source/plugins/dummy.rst index 78cc262c53e..21c4c72309c 100644 --- a/docs/source/plugins/dummy.rst +++ b/docs/source/plugins/dummy.rst @@ -4,6 +4,5 @@ Dummy Test Plugin ================= This is a sample plugin that shows how to set necessary plugin metadata, -register callbacks, and display a simple menu. It prints status messages if the -:ref:`verbose ` option is on, and it adds a **Dummy** -option to the **Plugin Options** menu. +register callbacks, and display a simple menu. It prints status messages, and +it adds a **Dummy** option to the **Plugin Options** menu. diff --git a/docs/source/techspecs/luaengine.rst b/docs/source/techspecs/luaengine.rst index 5e97d4e3885..7f2ba99545a 100644 --- a/docs/source/techspecs/luaengine.rst +++ b/docs/source/techspecs/luaengine.rst @@ -53,9 +53,9 @@ Many of the classes are documented on the Usage ----- -MAME supports external scripting via Lua (>= 5.3) scripts, either entered at the +MAME supports external scripting via Lua scripts, either entered at the interactive console or loaded as a file. To reach the console, enable the -console plugin (e.g. run MAME with ``-plugin console``) and you will be greeted +console plugin (e.g. run MAME with ``-console``) and you will be greeted with a ``[MAME]>`` prompt where you can enter Lua script interactively. To load a whole script at once, store it in a plain text file and pass it using @@ -78,7 +78,7 @@ Let’s first run MAME in a terminal to reach the Lua console: :: - $ mame -console YOUR_ROM + $ mame -console YOUR_SYSTEM /| /| /| /| /| _______ / | / | / | / | / | / / / |/ | / | / |/ | / ____/ @@ -90,10 +90,10 @@ Let’s first run MAME in a terminal to reach the Lua console: / / / _/ - mame 0.227 + mame 0.254 Copyright (C) Nicola Salmoria and the MAME team - Lua 5.3 + Lua 5.4 Copyright (C) Lua.org, PUC-Rio [MAME]> @@ -113,7 +113,7 @@ You can check at runtime which version of MAME you are running, with: :: [MAME]> print(emu.app_name() .. " " .. emu.app_version()) - mame 0.227 + mame 0.254 We now start exploring screen related methods. First, let's enumerate available screens: diff --git a/docs/source/techspecs/luareference.rst b/docs/source/techspecs/luareference.rst index ec7727916db..967fc889729 100644 --- a/docs/source/techspecs/luareference.rst +++ b/docs/source/techspecs/luareference.rst @@ -55,6 +55,82 @@ c:index_of(v) value. +.. _luareference-globals: + +Global objects +-------------- + +.. _luareference-globals-emu: + +Emulator interface +~~~~~~~~~~~~~~~~~~ + +The emulator interface ``emu`` provides access to core functionality. Many +classes are also available as properties of the emulator interface. + +Methods +^^^^^^^ + +emu.wait(duration, …) + Yields for the specified duration in terms of emulated time. The duration + may be specified as an :ref:`attotime ` or a + number in seconds. Any additional arguments are returned to the caller. + Returns a Boolean indicating whether the duration expired normally. + + All outstanding calls to ``emu.wait`` will return ``false`` immediately if a + saved state is loaded or the emulation session ends. Calling this function + from callbacks that are not run as coroutines will raise an error. +emu.wait_next_update(…) + Yields until the next video/UI update. Any arguments are returned to the + caller. Calling this function from callbacks that are not run as coroutines + will raise an error. +emu.wait_next_frame(…) + Yields until the next emulated frame completes. Any arguments are returned + to the caller. Calling this function from callbacks that are not run as + coroutines will raise an error. +emu.add_machine_reset_notifier(callback) + Add a callback to receive notifications when the emulated system is reset. + Returns a :ref:`notifier subscription `. +emu.add_machine_stop_notifier(callback) + Add a callback to receive notifications when the emulated system is stopped. + Returns a :ref:`notifier subscription `. +emu.add_machine_pause_notifier(callback) + Add a callback to receive notifications when the emulated system is paused. + Returns a :ref:`notifier subscription `. +emu.add_machine_resume_notifier(callback) + Add a callback to receive notifications when the emulated system is resumed + after being paused. Returns a + :ref:`notifier subscription `. +emu.add_machine_frame_notifier(callback) + Add a callback to receive notifications when an emulated frame completes. + Returns a :ref:`notifier subscription `. +emu.add_machine_pre_save_notifier(callback) + Add a callback to receive notification before the emulated system state is + saved. Returns a + :ref:`notifier subscription `. +emu.add_machine_post_load_notifier(callback) + Add a callback to receive notification after the emulated system is restored + to a previously saved state. Returns a + :ref:`notifier subscription `. +emu.print_error(message) + Print an error message. +emu.print_warning(message) + Print a warning message. +emu.print_info(message) + Print an informational message. +emu.print_verbose(message) + Print a verbose diagnostic message (disabled by default). +emu.print_debug(message) + Print a debug message (only enabled for debug builds by default). +emu.lang_translate([context], message) + Look up a message with optional context in the current localised message + catalog. Returns the message unchanged if no corresponding localised + message is found. +emu.subst_env(string) + Substitute environment variables in a string. The syntax is dependent on + the host operating system. + + .. _luareference-core: Core classes @@ -1598,7 +1674,8 @@ Pass-through handler Tracks a pass-through handler installed in an :ref:`address space `. A memory pass-through handler receives notifications on accesses to a specified range of addresses, and can -modify the data that is read or written if desired. +modify the data that is read or written if desired. Note that pass-through handler +callbacks are not run as coroutines. Instantiation ^^^^^^^^^^^^^ @@ -3572,7 +3649,8 @@ Layout file ~~~~~~~~~~~ Wraps MAME’s ``layout_file`` class, representing the views loaded from a layout -file for use by a render target. +file for use by a render target. Note that layout file callbacks are not run as +coroutines. Instantiation ^^^^^^^^^^^^^ @@ -3616,7 +3694,8 @@ Layout view Wraps MAME’s ``layout_view`` class, representing a view that can be displayed in a render target. Views are created from XML layout files, which may be loaded from external artwork, internal to MAME, or automatically generated based on the -screens in the emulated system. +screens in the emulated system. Note that layout view callbacks are not run as +coroutines. Instantiation ^^^^^^^^^^^^^ @@ -3695,7 +3774,8 @@ Layout view item Wraps MAME’s ``layout_view_item`` class, representing an item in a view. An item is drawn as a rectangular textured surface. The texture is supplied by an -emulated screen or a layout element. +emulated screen or a layout element. Note that layout view item callbacks are +not run as coroutines. Instantiation ^^^^^^^^^^^^^ diff --git a/plugins/autofire/init.lua b/plugins/autofire/init.lua index ab5e7b11f47..35d37e69592 100644 --- a/plugins/autofire/init.lua +++ b/plugins/autofire/init.lua @@ -9,6 +9,8 @@ local exports = { local autofire = exports +local frame_subscription, stop_subscription + function autofire.startplugin() -- List of autofire buttons, each being a table with keys: @@ -104,9 +106,9 @@ function autofire.startplugin() end end - emu.register_frame(process_frame) + frame_subscription = emu.add_machine_frame_notifier(process_frame) emu.register_prestart(load_settings) - emu.register_stop(save_settings) + stop_subscription = emu.add_machine_stop_notifier(save_settings) emu.register_menu(menu_callback, menu_populate, _p('plugin-autofire', 'Autofire')) end diff --git a/plugins/cheat/init.lua b/plugins/cheat/init.lua index f76ffcdf62a..f2418fed7b6 100644 --- a/plugins/cheat/init.lua +++ b/plugins/cheat/init.lua @@ -73,6 +73,8 @@ exports.author = { name = "Carl" } local cheat = exports +local reset_subscription, stop_subscription, frame_subscription + function cheat.set_folder(path) cheat.path = path end @@ -809,7 +811,7 @@ function cheat.startplugin() return menu_populate() end, _("Cheat")) - emu.register_start(function() + reset_subscription = emu.add_machine_reset_notifier(function () if not stop then return end @@ -832,13 +834,13 @@ function cheat.startplugin() end end) - emu.register_stop(function() + stop_subscription = emu.add_machine_stop_notifier(function () stop = true consolelog = nil save_hotkeys() end) - emu.register_frame(function() + frame_subscription = emu.add_machine_frame_notifier(function () if stop then return end diff --git a/plugins/cheatfind/init.lua b/plugins/cheatfind/init.lua index d86315d7156..f36b4f5b2d5 100644 --- a/plugins/cheatfind/init.lua +++ b/plugins/cheatfind/init.lua @@ -10,6 +10,8 @@ exports.author = { name = "Carl" } local cheatfind = exports +local reset_subscription + function cheatfind.startplugin() local cheat = {} @@ -333,7 +335,7 @@ function cheatfind.startplugin() end end - emu.register_start(start) + reset_subscription = emu.add_machine_reset_notifier(start) local menu_is_showing = false local tabbed_out = false diff --git a/plugins/console/init.lua b/plugins/console/init.lua index 7c04184513d..a9835ae4ad4 100644 --- a/plugins/console/init.lua +++ b/plugins/console/init.lua @@ -13,6 +13,8 @@ local history_file = "console_history" local history_fullpath = nil +local reset_subscription, stop_subscription + function console.startplugin() local conth = emu.thread() local ln_started = false @@ -220,16 +222,18 @@ function console.startplugin() return table.concat(result, '\001') end - emu.register_start(function() + reset_subscription = emu.add_machine_reset_notifier(function () if not consolebuf and manager.machine.debugger then consolebuf = manager.machine.debugger.consolelog lastindex = 0 end end) - emu.register_stop(function() consolebuf = nil end) + stop_subscription = emu.add_machine_stop_notifier(function () + consolebuf = nil + end) - emu.register_periodic(function() + emu.register_periodic(function () if stopped then return end diff --git a/plugins/data/init.lua b/plugins/data/init.lua index eb3ad1ae9b3..0ce3dfa4631 100644 --- a/plugins/data/init.lua +++ b/plugins/data/init.lua @@ -15,6 +15,8 @@ local data = exports local plugindir +local reset_subscription + function data.set_folder(path) plugindir = path end @@ -25,7 +27,7 @@ function data.startplugin() local cur_set local cur_list - emu.register_start( + reset_subscription = emu.add_machine_reset_notifier( function () data_scr = {} for file in lfs.dir(plugindir) do diff --git a/plugins/discord/init.lua b/plugins/discord/init.lua index cc7d09582c5..9e077f5d656 100644 --- a/plugins/discord/init.lua +++ b/plugins/discord/init.lua @@ -1,14 +1,16 @@ -- license:BSD-3-Clause -- copyright-holders:Carl -local exports = {} -exports.name = "discord" -exports.version = "0.0.1" -exports.description = "Discord presence" -exports.license = "BSD-3-Clause" -exports.author = { name = "Carl" } +local exports = { + name = "discord", + version = "0.0.1", + description = "Discord presence", + license = "BSD-3-Clause", + author = { name = "Carl" } } local discord = exports +local reset_subscription, pause_subscription, resume_subscription + function discord.startplugin() local pipe = emu.file("rw") local json = require("json") @@ -98,16 +100,16 @@ function discord.startplugin() end end - emu.register_start(function() + reset_subscription = emu.add_machine_reset_notifier(function () starttime = os.time() update("Playing") end) - emu.register_pause(function() + pause_subscription = emu.add_machine_pause_notifier(function () update("Paused") end) - emu.register_resume(function() + resume_subscription = emu.add_machine_resume_notifier(function () update("Playing") end) end diff --git a/plugins/dummy/init.lua b/plugins/dummy/init.lua index 45f6d78d570..54d4f3d7fef 100644 --- a/plugins/dummy/init.lua +++ b/plugins/dummy/init.lua @@ -9,21 +9,25 @@ local exports = { local dummy = exports +local reset_subscription, stop_subscription + function dummy.startplugin() - emu.register_start(function() - emu.print_verbose("Starting " .. emu.gamename()) - end) + reset_subscription = emu.add_machine_reset_notifier( + function () + emu.print_info("Starting " .. emu.gamename()) + end) - emu.register_stop(function() - emu.print_verbose("Exiting " .. emu.gamename()) - end) + stop_subscription = emu.add_machine_stop_notifier( + function () + emu.print_info("Exiting " .. emu.gamename()) + end) local function menu_populate() return {{ "This is a", "test", "off" }, { "Also a", "test", "" }} end local function menu_callback(index, event) - emu.print_verbose("index: " .. index .. " event: " .. event) + emu.print_info("index: " .. index .. " event: " .. event) return false end diff --git a/plugins/gdbstub/init.lua b/plugins/gdbstub/init.lua index 8a28a68d8cc..1d358518965 100644 --- a/plugins/gdbstub/init.lua +++ b/plugins/gdbstub/init.lua @@ -1,11 +1,11 @@ -- license:BSD-3-Clause -- copyright-holders: Carl -local exports = {} -exports.name = "gdbstub" -exports.version = "0.0.1" -exports.description = "GDB stub plugin" -exports.license = "BSD-3-Clause" -exports.author = { name = "Carl" } +local exports = { + name = "gdbstub", + version = "0.0.1", + description = "GDB stub plugin", + license = "BSD-3-Clause", + author = { name = "Carl" } } local gdbstub = exports @@ -25,6 +25,8 @@ local regmaps = { regmaps.i486 = regmaps.i386 regmaps.pentium = regmaps.i386 +local reset_subscription, stop_subscription + function gdbstub.startplugin() local debugger local debug @@ -35,7 +37,7 @@ function gdbstub.startplugin() local consolelast local running - emu.register_start(function () + reset_subscription = emu.add_machine_reset_notifier(function () debugger = manager.machine.debugger if not debugger then print("gdbstub: debugger not enabled") @@ -56,7 +58,7 @@ function gdbstub.startplugin() running = false end) - emu.register_stop(function() + stop_subscription = emu.add_machine_stop_notifier(function () consolelog = nil cpu = nil debug = nil diff --git a/plugins/hiscore/init.lua b/plugins/hiscore/init.lua index 5f93b91bd1a..ae8ebf7568e 100644 --- a/plugins/hiscore/init.lua +++ b/plugins/hiscore/init.lua @@ -14,7 +14,8 @@ local exports = { local hiscore = exports -local hiscore_plugin_path = "" +local hiscore_plugin_path +local reset_subscription, frame_subscription, stop_subscription function hiscore.set_folder(path) hiscore_plugin_path = path @@ -328,7 +329,7 @@ function hiscore.startplugin() scores_have_been_read = false; end - emu.register_start(function() + reset_subscription = emu.add_machine_reset_notifier(function () found_hiscore_entry = false mem_check_passed = false scores_have_been_read = false; @@ -354,18 +355,18 @@ function hiscore.startplugin() end end) - emu.register_frame(function() + frame_subscription = emu.add_machine_frame_notifier(function () if found_hiscore_entry then tick() end end) - emu.register_stop(function() + stop_subscription = emu.add_machine_stop_notifier(function () reset() save_config() end) - emu.register_prestart(function() + emu.register_prestart(function () reset() end) diff --git a/plugins/inputmacro/init.lua b/plugins/inputmacro/init.lua index 15156bb159c..9c520f3a503 100644 --- a/plugins/inputmacro/init.lua +++ b/plugins/inputmacro/init.lua @@ -10,6 +10,8 @@ local exports = { local inputmacro = exports +local frame_subscription, stop_subscription + function inputmacro.startplugin() --[[ Configuration data: @@ -129,9 +131,9 @@ function inputmacro.startplugin() return menu:populate() end - emu.register_frame(process_frame) + frame_subscription = emu.add_machine_frame_notifier(process_frame) emu.register_prestart(start) - emu.register_stop(stop) + stop_subscription = emu.add_machine_stop_notifier(stop) emu.register_menu(menu_callback, menu_populate, _p('plugin-inputmacro', 'Input Macros')) end diff --git a/plugins/layout/init.lua b/plugins/layout/init.lua index 861e0a697b3..a7d3f7fb199 100644 --- a/plugins/layout/init.lua +++ b/plugins/layout/init.lua @@ -2,15 +2,17 @@ -- copyright-holders:Carl -- Layout scripts should return a table and a string. The table can have two optional keys reset and frame -- which have functions for values called on reset and frame draw respectively and the string is a unique name. -local exports = {} -exports.name = "layout" -exports.version = "0.0.1" -exports.description = "Layout helper plugin" -exports.license = "BSD-3-Clause" -exports.author = { name = "Carl" } +local exports = { + name = "layout", + version = "0.0.1", + description = "Layout helper plugin", + license = "BSD-3-Clause", + author = { name = "Carl" } } local layout = exports +local frame_subscription, stop_subscription + function layout.startplugin() local scripts = {} local function prepare_layout(file, script) @@ -45,7 +47,7 @@ function layout.startplugin() end emu.register_callback(prepare_layout, "layout") - emu.register_frame(function() + frame_subscription = emu.add_machine_frame_notifier(function () if manager.machine.paused then return end @@ -55,14 +57,16 @@ function layout.startplugin() end end end) - emu.register_start(function() + emu.register_prestart(function () for num, scr in pairs(scripts) do if scr.reset then scr.reset() end end end) - emu.register_stop(function() scripts = {} end) + stop_subscription = emu.add_machine_stop_notifier(function () + scripts = {} + end) end return exports diff --git a/plugins/timecode/init.lua b/plugins/timecode/init.lua index 93435ef2870..1de94c034ba 100644 --- a/plugins/timecode/init.lua +++ b/plugins/timecode/init.lua @@ -10,6 +10,8 @@ local exports = { local timecode = exports +local frame_subscription, stop_subscription + function timecode.startplugin() local file -- the timecode log file local write -- whether to record a timecode on the next emulated frame @@ -338,10 +340,10 @@ function timecode.startplugin() end - emu.register_frame(process_frame) + frame_subscription = emu.add_machine_frame_notifier(process_frame) emu.register_frame_done(process_frame_done) emu.register_prestart(start) - emu.register_stop(stop) + stop_subscription = emu.add_machine_stop_notifier(stop) emu.register_menu(menu_callback, menu_populate, _p('plugin-timecode', 'Timecode Recorder')) end diff --git a/plugins/timer/init.lua b/plugins/timer/init.lua index 35dbb6431ac..1d67472b3c2 100644 --- a/plugins/timer/init.lua +++ b/plugins/timer/init.lua @@ -1,5 +1,6 @@ -- license:BSD-3-Clause -- copyright-holders:Vas Crabb +-- TODO: track time properly across soft reset and state load local exports = { name = 'timer', version = '0.0.3', @@ -9,6 +10,8 @@ local exports = { local timer = exports +local reset_subscription, stop_subscription + function timer.startplugin() local total_time = 0 local start_time = 0 @@ -53,8 +56,8 @@ function timer.startplugin() end - emu.register_start( - function() + reset_subscription = emu.add_machine_reset_notifier( + function () if emu.romname() ~= '___empty' then start_time = os.time() local persister = require('timer/timer_persist') @@ -62,8 +65,8 @@ function timer.startplugin() end end) - emu.register_stop( - function() + stop_subscription = emu.add_machine_stop_notifier( + function () if emu.romname() ~= '___empty' then local persister = require('timer/timer_persist') persister:update_totals(start_time) diff --git a/src/devices/bus/isa/mcd.cpp b/src/devices/bus/isa/mcd.cpp index 9bb8b82a5da..4f37e26c8fa 100644 --- a/src/devices/bus/isa/mcd.cpp +++ b/src/devices/bus/isa/mcd.cpp @@ -84,7 +84,7 @@ bool mcd_isa_device::read_sector(bool first) if(m_cdrom_handle->get_track_type(m_cdrom_handle->get_track(lba)) == cdrom_file::CD_TRACK_AUDIO) { m_cdda->stop_audio(); - m_cdda->set_cdrom(m_cdrom_handle); + m_cdda->set_cdrom(get_cdrom_file()); m_cdda->start_audio(lba, m_readcount); return true; } diff --git a/src/devices/bus/qbus/pc11.h b/src/devices/bus/qbus/pc11.h index 2421e7de9b6..917a49388bb 100644 --- a/src/devices/bus/qbus/pc11.h +++ b/src/devices/bus/qbus/pc11.h @@ -36,7 +36,7 @@ public: // construction/destruction pc11_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - // image-level overrides + // device_image_interface implementation virtual const char *image_interface() const noexcept override { return "pdp11_ptap"; } virtual const char *file_extensions() const noexcept override { return "bin,bim,lda"; } @@ -47,11 +47,11 @@ public: void write(offs_t offset, uint16_t data); protected: - // device-level overrides + // device_t implementation virtual void device_start() override; virtual void device_reset() override; - // device_z80daisy_interface overrides + // device_z80daisy_interface implementation virtual int z80daisy_irq_state() override; virtual int z80daisy_irq_ack() override; virtual void z80daisy_irq_reti() override; @@ -81,4 +81,4 @@ private: // device type definition DECLARE_DEVICE_TYPE(DEC_PC11, pc11_device) -#endif +#endif // MAME_BUS_QBUS_PC11_H diff --git a/src/devices/bus/saturn/sat_slot.cpp b/src/devices/bus/saturn/sat_slot.cpp index dff115f5f5f..c5959bde1f7 100644 --- a/src/devices/bus/saturn/sat_slot.cpp +++ b/src/devices/bus/saturn/sat_slot.cpp @@ -145,10 +145,9 @@ std::error_condition sat_cart_slot_device::call_load() { // from fullpath, only ROM carts uint32_t len = loaded_through_softlist() ? get_software_region_length("rom") : length(); - uint32_t *ROM; m_cart->rom_alloc(len); - ROM = m_cart->get_rom_base(); + uint32_t *const ROM = m_cart->get_rom_base(); if (loaded_through_softlist()) memcpy(ROM, get_software_region("rom"), len); @@ -157,15 +156,7 @@ std::error_condition sat_cart_slot_device::call_load() // fix endianness.... for (int i = 0; i < len/4; i ++) - ROM[i] = bitswap<32>(ROM[i],7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24); -// { -// uint8_t tempa = ROM[i+0]; -// uint8_t tempb = ROM[i+1]; -// ROM[i+1] = ROM[i+2]; -// ROM[i+0] = ROM[i+3]; -// ROM[i+3] = tempa; -// ROM[i+2] = tempb; -// } + ROM[i] = big_endianize_int32(ROM[i]); } else { @@ -177,7 +168,6 @@ std::error_condition sat_cart_slot_device::call_load() if (get_software_region("dram1")) m_cart->dram1_alloc(get_software_region_length("dram1")); } - return std::error_condition(); } return std::error_condition(); diff --git a/src/devices/bus/scv/slot.cpp b/src/devices/bus/scv/slot.cpp index c6833ecee55..c312e6bfb7a 100644 --- a/src/devices/bus/scv/slot.cpp +++ b/src/devices/bus/scv/slot.cpp @@ -151,9 +151,8 @@ std::error_condition scv_cart_slot_device::call_load() { if (m_cart) { - uint8_t *ROM; - uint32_t len = !loaded_through_softlist() ? length() : get_software_region_length("rom"); - bool has_ram = loaded_through_softlist() && get_software_region("ram"); + uint32_t const len = !loaded_through_softlist() ? length() : get_software_region_length("rom"); + bool const has_ram = loaded_through_softlist() && get_software_region("ram"); if (len > 0x20000) { @@ -165,7 +164,7 @@ std::error_condition scv_cart_slot_device::call_load() if (has_ram) m_cart->ram_alloc(get_software_region_length("ram")); - ROM = m_cart->get_rom_base(); + uint8_t *const ROM = m_cart->get_rom_base(); if (!loaded_through_softlist()) fread(ROM, len); @@ -189,8 +188,6 @@ std::error_condition scv_cart_slot_device::call_load() m_type = SCV_128K_RAM; //printf("Type: %s\n", scv_get_slot(m_type)); - - return std::error_condition(); } return std::error_condition(); diff --git a/src/devices/bus/sdk85/memexp.cpp b/src/devices/bus/sdk85/memexp.cpp index 366d1aa83cc..74908bcc00e 100644 --- a/src/devices/bus/sdk85/memexp.cpp +++ b/src/devices/bus/sdk85/memexp.cpp @@ -24,11 +24,11 @@ sdk85_romexp_device::sdk85_romexp_device(const machine_config &mconfig, const ch std::error_condition sdk85_romexp_device::call_load() { - if (get_card_device() != nullptr) + if (get_card_device()) { - u32 size = loaded_through_softlist() ? get_software_region_length("rom") : length(); - u8 *base = get_card_device()->get_rom_base(size); - if (base == nullptr) + u32 const size = loaded_through_softlist() ? get_software_region_length("rom") : length(); + u8 *const base = get_card_device()->get_rom_base(size); + if (!base) return image_error::INTERNAL; if (loaded_through_softlist()) diff --git a/src/devices/bus/sega8/sega8_slot.cpp b/src/devices/bus/sega8/sega8_slot.cpp index 0106f28d572..5e53142a8f3 100644 --- a/src/devices/bus/sega8/sega8_slot.cpp +++ b/src/devices/bus/sega8/sega8_slot.cpp @@ -395,8 +395,6 @@ std::error_condition sega8_cart_slot_device::call_load() if (m_cart) { uint32_t len = !loaded_through_softlist() ? length() : get_software_region_length("rom"); - uint32_t offset = 0; - uint8_t *ROM; if (m_is_card && len > 0x8000) { @@ -405,18 +403,19 @@ std::error_condition sega8_cart_slot_device::call_load() } // check for header + uint32_t offset = 0; if ((len % 0x4000) == 512) { offset = 512; len -= 512; } - // make sure that we only get complete (0x4000) rom banks + // make sure that we only get complete (0x4000) ROM banks if (len & 0x3fff) len = ((len >> 14) + 1) << 14; m_cart->rom_alloc(len); - ROM = m_cart->get_rom_base(); + uint8_t *const ROM = m_cart->get_rom_base(); if (!loaded_through_softlist()) { @@ -426,7 +425,7 @@ std::error_condition sega8_cart_slot_device::call_load() else memcpy(ROM, get_software_region("rom"), get_software_region_length("rom")); - /* check the image */ + // check the image if (verify_cart(ROM, len)) logerror("Warning loading image: verify_cart failed\n"); @@ -455,8 +454,6 @@ std::error_condition sega8_cart_slot_device::call_load() //printf("Type: %s\n", sega8_get_slot(type)); internal_header_logging(ROM + offset, len, m_cart->get_ram_size()); - - return std::error_condition(); } return std::error_condition(); diff --git a/src/devices/bus/snes/snes_slot.cpp b/src/devices/bus/snes/snes_slot.cpp index 0bdd131a80b..9517edc61dd 100644 --- a/src/devices/bus/snes/snes_slot.cpp +++ b/src/devices/bus/snes/snes_slot.cpp @@ -653,11 +653,8 @@ std::error_condition base_sns_cart_slot_device::call_load() { if (m_cart) { - uint8_t *ROM; - uint32_t len, offset = 0; - const char *slot_name; - - /* Check for a header (512 bytes), and skip it if found */ + // Check for a header (512 bytes), and skip it if found + uint32_t offset = 0; if (!loaded_through_softlist()) { uint32_t tmplen = length(); @@ -667,10 +664,10 @@ std::error_condition base_sns_cart_slot_device::call_load() fseek(offset, SEEK_SET); } - len = !loaded_through_softlist() ? (length() - offset) : get_software_region_length("rom"); + uint32_t const len = !loaded_through_softlist() ? (length() - offset) : get_software_region_length("rom"); m_cart->rom_alloc(len); - ROM = m_cart->get_rom_base(); + uint8_t *const ROM = m_cart->get_rom_base(); if (!loaded_through_softlist()) fread(ROM, len); else @@ -693,13 +690,14 @@ std::error_condition base_sns_cart_slot_device::call_load() get_cart_type_addon(ROM, len, m_type, m_addon); else { + const char *slot_name; if ((slot_name = get_feature("slot")) == nullptr) m_type = SNES_MODE20; else m_type = sns_get_pcb_id(slot_name); if (m_type == SNES_DSP && len > 0x100000) - m_type = SNES_DSP_2MB; + m_type = SNES_DSP_2MB; } if (!loaded_through_softlist()) @@ -725,8 +723,6 @@ std::error_condition base_sns_cart_slot_device::call_load() //printf("Type %d\n", m_type); internal_header_logging(ROM, len); - - return std::error_condition(); } return std::error_condition(); diff --git a/src/devices/bus/spectrum/intf2.cpp b/src/devices/bus/spectrum/intf2.cpp index f60147176f2..01ac201433e 100644 --- a/src/devices/bus/spectrum/intf2.cpp +++ b/src/devices/bus/spectrum/intf2.cpp @@ -96,7 +96,7 @@ void spectrum_intf2_device::device_start() DEVICE_IMAGE_LOAD_MEMBER(spectrum_intf2_device::cart_load) { - uint32_t size = m_cart->common_get_size("rom"); + uint32_t const size = m_cart->common_get_size("rom"); if (size != 0x4000) { diff --git a/src/devices/bus/ti99x/990_tap.cpp b/src/devices/bus/ti99x/990_tap.cpp index 83bab21a682..be4cc7beb97 100644 --- a/src/devices/bus/ti99x/990_tap.cpp +++ b/src/devices/bus/ti99x/990_tap.cpp @@ -895,14 +895,14 @@ public: // construction/destruction ti990_tape_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - // image-level overrides + // device_image_interface implementation virtual const char *file_extensions() const noexcept override { return "tap"; } virtual std::error_condition call_load() override; virtual void call_unload() override; protected: - // device-level overrides + // device_t implementation virtual void device_start() override; private: diff --git a/src/devices/bus/vc4000/slot.cpp b/src/devices/bus/vc4000/slot.cpp index 6a97f444418..d7077325a8d 100644 --- a/src/devices/bus/vc4000/slot.cpp +++ b/src/devices/bus/vc4000/slot.cpp @@ -172,7 +172,7 @@ std::error_condition vc4000_cart_slot_device::call_load() { if (m_cart) { - uint32_t size = !loaded_through_softlist() ? length() : get_software_region_length("rom"); + uint32_t const size = !loaded_through_softlist() ? length() : get_software_region_length("rom"); if (size > 0x1800) { @@ -210,8 +210,6 @@ std::error_condition vc4000_cart_slot_device::call_load() } //printf("Type: %s\n", vc4000_get_slot(m_type)); - - return std::error_condition(); } return std::error_condition(); diff --git a/src/devices/bus/vcs/vcs_slot.cpp b/src/devices/bus/vcs/vcs_slot.cpp index d55f94df8ec..aa0812e22be 100644 --- a/src/devices/bus/vcs/vcs_slot.cpp +++ b/src/devices/bus/vcs/vcs_slot.cpp @@ -226,7 +226,7 @@ std::error_condition vcs_cart_slot_device::call_load() } m_cart->rom_alloc(len, tag()); - uint8_t *ROM = m_cart->get_rom_base(); + uint8_t *const ROM = m_cart->get_rom_base(); if (loaded_through_softlist()) { @@ -310,8 +310,6 @@ std::error_condition vcs_cart_slot_device::call_load() m_cart->setup_addon_ptr((uint8_t *)m_cart->get_rom_base() + 0x2000); m_cart->install_memory_handlers(m_address_space.target()); - - return std::error_condition(); } return std::error_condition(); diff --git a/src/devices/bus/vcs/vcs_slot.h b/src/devices/bus/vcs/vcs_slot.h index c5c075ee706..dab42192ff9 100644 --- a/src/devices/bus/vcs/vcs_slot.h +++ b/src/devices/bus/vcs/vcs_slot.h @@ -31,7 +31,7 @@ public: template void set_address_space(T &&tag, int no) { m_address_space.set_tag(std::forward(tag), no); } - // image-level overrides + // device_image_interface implementation virtual std::error_condition call_load() override; virtual void call_unload() override; @@ -39,18 +39,18 @@ public: virtual const char *image_interface() const noexcept override { return "a2600_cart"; } virtual const char *file_extensions() const noexcept override { return "bin,a26"; } - // slot interface overrides + // device_slot_interface implementation virtual std::string get_default_card_software(get_default_card_software_hook &hook) const override; int get_cart_type() { return m_type; } static int identify_cart_type(const uint8_t *ROM, uint32_t len); protected: - // device-level overrides + // device_t implementation virtual void device_start() override; private: - device_vcs_cart_interface* m_cart; + device_vcs_cart_interface *m_cart; int m_type; optional_address_space m_address_space; diff --git a/src/devices/bus/vectrex/slot.cpp b/src/devices/bus/vectrex/slot.cpp index d7785f98eff..d3c3aa59bcd 100644 --- a/src/devices/bus/vectrex/slot.cpp +++ b/src/devices/bus/vectrex/slot.cpp @@ -140,8 +140,7 @@ std::error_condition vectrex_cart_slot_device::call_load() { if (m_cart) { - uint32_t size = !loaded_through_softlist() ? length() : get_software_region_length("rom"); - uint8_t *ROM; + uint32_t const size = !loaded_through_softlist() ? length() : get_software_region_length("rom"); if (size > 0x10000) { @@ -150,7 +149,7 @@ std::error_condition vectrex_cart_slot_device::call_load() } m_cart->rom_alloc((size < 0x1000) ? 0x1000 : size); - ROM = m_cart->get_rom_base(); + uint8_t *const ROM = m_cart->get_rom_base(); if (!loaded_through_softlist()) fread(ROM, size); diff --git a/src/devices/bus/vic10/exp.cpp b/src/devices/bus/vic10/exp.cpp index 5c37878153e..e8a02972cb2 100644 --- a/src/devices/bus/vic10/exp.cpp +++ b/src/devices/bus/vic10/exp.cpp @@ -90,11 +90,9 @@ std::error_condition vic10_expansion_slot_device::call_load() { if (m_card) { - size_t size; - if (!loaded_through_softlist()) { - size = length(); + size_t const size = length(); if (is_filetype("80")) { diff --git a/src/devices/bus/vic20/exp.cpp b/src/devices/bus/vic20/exp.cpp index 5c26c7c28e3..901039ff58d 100644 --- a/src/devices/bus/vic20/exp.cpp +++ b/src/devices/bus/vic20/exp.cpp @@ -109,7 +109,7 @@ std::error_condition vic20_expansion_slot_device::call_load() // read the header uint8_t header[2]; fread(&header, 2); - uint16_t address = (header[1] << 8) | header[0]; + uint16_t const address = (header[1] << 8) | header[0]; switch (address) { diff --git a/src/devices/bus/vidbrain/exp.cpp b/src/devices/bus/vidbrain/exp.cpp index eddd384d511..00cf3c4e0ed 100644 --- a/src/devices/bus/vidbrain/exp.cpp +++ b/src/devices/bus/vidbrain/exp.cpp @@ -109,21 +109,21 @@ std::error_condition videobrain_expansion_slot_device::call_load() { if (m_cart) { - size_t size; - if (!loaded_through_softlist()) { - size = length(); + size_t const romsize = length(); - fread(m_cart->videobrain_rom_pointer(machine(), size), size); + fread(m_cart->videobrain_rom_pointer(machine(), romsize), romsize); } else { - size = get_software_region_length("rom"); - if (size) memcpy(m_cart->videobrain_rom_pointer(machine(), size), get_software_region("rom"), size); + size_t const romsize = get_software_region_length("rom"); + if (romsize) + memcpy(m_cart->videobrain_rom_pointer(machine(), romsize), get_software_region("rom"), romsize); - size = get_software_region_length("ram"); - if (size) memset(m_cart->videobrain_ram_pointer(machine(), size), 0, size); + size_t const ramsize = get_software_region_length("ram"); + if (ramsize) + memset(m_cart->videobrain_ram_pointer(machine(), ramsize), 0, ramsize); } } diff --git a/src/devices/bus/vsmile/vsmile_slot.cpp b/src/devices/bus/vsmile/vsmile_slot.cpp index 95ec9da38f8..e5121267bff 100644 --- a/src/devices/bus/vsmile/vsmile_slot.cpp +++ b/src/devices/bus/vsmile/vsmile_slot.cpp @@ -136,15 +136,15 @@ std::error_condition vsmile_cart_slot_device::call_load() { if (m_cart) { - uint32_t size = loaded_through_softlist() ? get_software_region_length("rom") : length(); - if (size > 0x1000000) + uint32_t const size = loaded_through_softlist() ? get_software_region_length("rom") : length(); + if (size > 0x100'0000) { osd_printf_error("%s: Attempted loading a cart larger than 16MB\n", basename()); return image_error::INVALIDLENGTH; } m_cart->rom_alloc(size); - uint8_t *rom = (uint8_t *)m_cart->get_rom_base(); + uint8_t *const rom = (uint8_t *)m_cart->get_rom_base(); if (!loaded_through_softlist()) { @@ -164,16 +164,10 @@ std::error_condition vsmile_cart_slot_device::call_load() } if (m_type == VSMILE_NVRAM) - { - m_cart->nvram_alloc(0x200000); - } + m_cart->nvram_alloc(0x20'0000); if (m_cart->get_nvram_size()) - { battery_load(m_cart->get_nvram_base(), m_cart->get_nvram_size(), 0x00); - } - - return std::error_condition(); } return std::error_condition(); diff --git a/src/devices/bus/wswan/slot.cpp b/src/devices/bus/wswan/slot.cpp index d5dc5125876..376ff0ab51a 100644 --- a/src/devices/bus/wswan/slot.cpp +++ b/src/devices/bus/wswan/slot.cpp @@ -154,18 +154,17 @@ std::error_condition ws_cart_slot_device::call_load() { if (m_cart) { - u16 *ROM; - u32 size = !loaded_through_softlist() ? length() : get_software_region_length("rom"); - u32 nvram_size = 0; + u32 const size = !loaded_through_softlist() ? length() : get_software_region_length("rom"); m_cart->rom_alloc(size); - ROM = m_cart->get_rom_base(); + u16 *const ROM = m_cart->get_rom_base(); if (!loaded_through_softlist()) fread(ROM, size); else memcpy(ROM, get_software_region("rom"), size); + u32 nvram_size = 0; if (!loaded_through_softlist()) { // get cart type and nvram length diff --git a/src/devices/bus/wswan/slot.h b/src/devices/bus/wswan/slot.h index 5ae7cb809ee..e5151303620 100644 --- a/src/devices/bus/wswan/slot.h +++ b/src/devices/bus/wswan/slot.h @@ -145,7 +145,7 @@ public: ws_cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock); virtual ~ws_cart_slot_device(); - // image-level overrides + // device_image_interface implementation virtual std::error_condition call_load() override; virtual void call_unload() override; @@ -153,7 +153,7 @@ public: virtual const char *image_interface() const noexcept override { return "wswan_cart"; } virtual const char *file_extensions() const noexcept override { return "ws,wsc,bin"; } - // slot interface overrides + // device_slot_interface implementation virtual std::string get_default_card_software(get_default_card_software_hook &hook) const override; int get_type() { return m_type; } @@ -172,11 +172,11 @@ public: virtual void write_io(offs_t offset, u16 data, u16 mem_mask); protected: - // device-level overrides + // device_t implementation virtual void device_start() override; int m_type; - device_ws_cart_interface* m_cart; + device_ws_cart_interface *m_cart; }; diff --git a/src/devices/bus/z88/z88.cpp b/src/devices/bus/z88/z88.cpp index 040d0f99a4e..0897f15ccba 100644 --- a/src/devices/bus/z88/z88.cpp +++ b/src/devices/bus/z88/z88.cpp @@ -99,24 +99,19 @@ std::error_condition z88cart_slot_device::call_load() { if (m_cart) { - uint8_t *cart_base = m_cart->get_cart_base(); + uint8_t *const cart_base = m_cart->get_cart_base(); + if (!cart_base) + return image_error::INTERNAL; - if (cart_base != nullptr) + if (!loaded_through_softlist()) { - if (!loaded_through_softlist()) - { - offs_t read_length = length(); - fread(cart_base + (m_cart->get_cart_size() - read_length), read_length); - } - else - { - offs_t read_length = get_software_region_length("rom"); - memcpy(cart_base + (m_cart->get_cart_size() - read_length), get_software_region("rom"), read_length); - } + offs_t read_length = length(); + fread(cart_base + (m_cart->get_cart_size() - read_length), read_length); } else { - return image_error::INTERNAL; + offs_t read_length = get_software_region_length("rom"); + memcpy(cart_base + (m_cart->get_cart_size() - read_length), get_software_region("rom"), read_length); } } diff --git a/src/devices/bus/z88/z88.h b/src/devices/bus/z88/z88.h index 349534aab00..94355823145 100644 --- a/src/devices/bus/z88/z88.h +++ b/src/devices/bus/z88/z88.h @@ -104,7 +104,7 @@ public: auto out_flp_callback() { return m_out_flp_cb.bind(); } - // image-level overrides + // device_image_interface implementation virtual std::error_condition call_load() override; virtual void call_unload() override; @@ -112,7 +112,7 @@ public: virtual const char *image_interface() const noexcept override { return "z88_cart"; } virtual const char *file_extensions() const noexcept override { return "epr,bin"; } - // slot interface overrides + // device_slot_interface implementation virtual std::string get_default_card_software(get_default_card_software_hook &hook) const override; // reading and writing @@ -122,7 +122,7 @@ public: uint8_t* get_cart_base(); protected: - // device-level overrides + // device_t implementation virtual void device_start() override; TIMER_CALLBACK_MEMBER(close_flap); diff --git a/src/devices/imagedev/avivideo.cpp b/src/devices/imagedev/avivideo.cpp index d366785661c..52308f4a301 100644 --- a/src/devices/imagedev/avivideo.cpp +++ b/src/devices/imagedev/avivideo.cpp @@ -26,8 +26,8 @@ DEFINE_DEVICE_TYPE(IMAGE_AVIVIDEO, avivideo_image_device, "avivideo_image", "AVI avivideo_image_device::avivideo_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, IMAGE_AVIVIDEO, tag, owner, clock), device_image_interface(mconfig, *this), - m_frame(nullptr), - m_avi(nullptr), + m_frame(), + m_avi(), m_frame_timer(nullptr), m_frame_count(0), m_frame_num(0) @@ -60,7 +60,7 @@ void avivideo_image_device::device_reset() TIMER_CALLBACK_MEMBER(avivideo_image_device::frame_timer) { - if (m_avi != nullptr) + if (m_avi) { avi_file::error avierr = m_avi->read_uncompressed_video_frame(m_frame_num, *m_frame); if (avierr != avi_file::error::NONE) @@ -82,12 +82,11 @@ TIMER_CALLBACK_MEMBER(avivideo_image_device::frame_timer) std::error_condition avivideo_image_device::call_load() { - m_frame = new bitmap_argb32; + m_frame.reset(new bitmap_argb32); avi_file::error avierr = avi_file::open(filename(), m_avi); if (avierr != avi_file::error::NONE) { - delete m_frame; - m_frame = nullptr; + m_frame.reset(); return image_error::UNSPECIFIED; } @@ -102,14 +101,6 @@ std::error_condition avivideo_image_device::call_load() void avivideo_image_device::call_unload() { - if (m_frame) - { - delete m_frame; - m_frame = nullptr; - } - if (m_avi) - { - m_avi.release(); - m_avi = nullptr; - } + m_frame.reset(); + m_avi.reset(); } diff --git a/src/devices/imagedev/avivideo.h b/src/devices/imagedev/avivideo.h index a39d6b40d84..1b61fda4068 100644 --- a/src/devices/imagedev/avivideo.h +++ b/src/devices/imagedev/avivideo.h @@ -13,8 +13,14 @@ #pragma once -#include "bitmap.h" #include "aviio.h" +#include "bitmap.h" + +#include +#include +#include +#include + /*************************************************************************** TYPE DEFINITIONS @@ -51,7 +57,7 @@ protected: TIMER_CALLBACK_MEMBER(frame_timer); private: - bitmap_argb32 *m_frame; + std::unique_ptr m_frame; avi_file::ptr m_avi; emu_timer *m_frame_timer; diff --git a/src/devices/imagedev/cassette.h b/src/devices/imagedev/cassette.h index 56fd8f79b1f..de413b24c57 100644 --- a/src/devices/imagedev/cassette.h +++ b/src/devices/imagedev/cassette.h @@ -57,7 +57,7 @@ public: void set_default_state(cassette_state default_state) { m_default_state = default_state; } void set_interface(const char *interface) { m_interface = interface; } - // image-level overrides + // device_image_interface implementation virtual std::error_condition call_load() override; virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; virtual void call_unload() override; @@ -105,7 +105,7 @@ public: device_sound_interface& set_stereo() { m_stereo = true; return *this; } protected: - // device-level overrides + // device_t implementation virtual void device_config_complete() override; virtual void device_start() override; virtual bool use_software_list_file_extension_for_filetype() const noexcept override { return true; } diff --git a/src/devices/imagedev/chd_cd.cpp b/src/devices/imagedev/chd_cd.cpp index d33689b2d27..44cb21e7201 100644 --- a/src/devices/imagedev/chd_cd.cpp +++ b/src/devices/imagedev/chd_cd.cpp @@ -27,11 +27,11 @@ cdrom_image_device::cdrom_image_device(const machine_config &mconfig, const char } cdrom_image_device::cdrom_image_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, type, tag, owner, clock), - device_image_interface(mconfig, *this), - m_cdrom_handle(nullptr), - m_extension_list(nullptr), - m_interface(nullptr) + : device_t(mconfig, type, tag, owner, clock) + , device_image_interface(mconfig, *this) + , m_cdrom_handle() + , m_extension_list(nullptr) + , m_interface(nullptr) { } //------------------------------------------------- @@ -62,22 +62,17 @@ void cdrom_image_device::device_config_complete() void cdrom_image_device::device_start() { // try to locate the CHD from a DISK_REGION - chd_file *chd = machine().rom_load().get_disk_handle(owner()->tag() ); - if( chd != nullptr ) - { - m_cdrom_handle = new cdrom_file( chd ); - } + chd_file *chd = machine().rom_load().get_disk_handle(owner()->tag()); + if (chd) + m_cdrom_handle.reset(new cdrom_file(chd)); else - { - m_cdrom_handle = nullptr; - } + m_cdrom_handle.reset(); } void cdrom_image_device::device_stop() { - if (m_cdrom_handle) - delete m_cdrom_handle; - if( m_self_chd.opened() ) + m_cdrom_handle.reset(); + if (m_self_chd.opened()) m_self_chd.close(); } @@ -86,8 +81,7 @@ std::error_condition cdrom_image_device::call_load() std::error_condition err; chd_file *chd = nullptr; - if (m_cdrom_handle) - delete m_cdrom_handle; + m_cdrom_handle.reset(); if (!loaded_through_softlist()) { if (is_filetype("chd") && is_loaded()) { @@ -103,12 +97,12 @@ std::error_condition cdrom_image_device::call_load() chd = device().machine().rom_load().get_disk_handle(device().subtag("cdrom").c_str()); } - /* open the CHD file */ - if (chd) { - m_cdrom_handle = new cdrom_file(chd); - } else { - m_cdrom_handle = new cdrom_file(filename()); - } + // open the CHD file + if (chd) + m_cdrom_handle.reset(new cdrom_file(chd)); + else + m_cdrom_handle.reset(new cdrom_file(filename())); + if (!m_cdrom_handle) goto error; @@ -126,8 +120,7 @@ error: void cdrom_image_device::call_unload() { assert(m_cdrom_handle); - delete m_cdrom_handle; - m_cdrom_handle = nullptr; - if( m_self_chd.opened() ) + m_cdrom_handle.reset(); + if (m_self_chd.opened()) m_self_chd.close(); } diff --git a/src/devices/imagedev/chd_cd.h b/src/devices/imagedev/chd_cd.h index 6eb3504c6a3..6c5142c9b48 100644 --- a/src/devices/imagedev/chd_cd.h +++ b/src/devices/imagedev/chd_cd.h @@ -13,9 +13,16 @@ #pragma once -#include "cdrom.h" #include "softlist_dev.h" +#include "cdrom.h" + +#include +#include +#include +#include + + /*************************************************************************** TYPE DEFINITIONS ***************************************************************************/ @@ -32,7 +39,7 @@ public: void set_interface(const char *interface) { m_interface = interface; } - // image-level overrides + // device_image_interface implementation virtual std::error_condition call_load() override; virtual void call_unload() override; @@ -46,12 +53,12 @@ public: virtual const char *image_brief_type_name() const noexcept override { return "cdrm"; } // specific implementation - cdrom_file *get_cdrom_file() { return m_cdrom_handle; } + cdrom_file *get_cdrom_file() { return m_cdrom_handle.get(); } protected: cdrom_image_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); - // device-level overrides + // device_t implementation virtual void device_config_complete() override; virtual void device_start() override; virtual void device_stop() override; @@ -60,7 +67,7 @@ protected: virtual const software_list_loader &get_software_list_loader() const override { return rom_software_list_loader::instance(); } chd_file m_self_chd; - cdrom_file *m_cdrom_handle; + std::unique_ptr m_cdrom_handle; const char *m_extension_list; const char *m_interface; }; diff --git a/src/devices/imagedev/diablo.cpp b/src/devices/imagedev/diablo.cpp index a50a58448c0..eabf9f204a4 100644 --- a/src/devices/imagedev/diablo.cpp +++ b/src/devices/imagedev/diablo.cpp @@ -35,12 +35,12 @@ DEFINE_DEVICE_TYPE(DIABLO, diablo_image_device, "diablo_image", "Diablo") //------------------------------------------------- diablo_image_device::diablo_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : harddisk_image_base_device(mconfig, DIABLO, tag, owner, clock), - m_chd(nullptr), - m_hard_disk_handle(nullptr), - m_device_image_load(*this), - m_device_image_unload(*this), - m_interface(nullptr) + : harddisk_image_base_device(mconfig, DIABLO, tag, owner, clock) + , m_chd(nullptr) + , m_hard_disk_handle() + , m_device_image_load(*this) + , m_device_image_unload(*this) + , m_interface(nullptr) { } @@ -81,20 +81,15 @@ void diablo_image_device::device_start() // try to locate the CHD from a DISK_REGION chd_file *handle = machine().rom_load().get_disk_handle(tag()); - if (handle != nullptr) - { - m_hard_disk_handle = new hard_disk_file(handle); - } + if (handle) + m_hard_disk_handle.reset(new hard_disk_file(handle)); else - { - m_hard_disk_handle = nullptr; - } + m_hard_disk_handle.reset(); } void diablo_image_device::device_stop() { - if (m_hard_disk_handle) - delete m_hard_disk_handle; + m_hard_disk_handle.reset(); } std::error_condition diablo_image_device::call_load() @@ -146,17 +141,11 @@ std::error_condition diablo_image_device::call_create(int create_format, util::o void diablo_image_device::call_unload() { - /* Check if there is an image_unload callback defined */ - if ( !m_device_image_unload.isnull() ) - { + // Check if there is an image_unload callback defined + if (!m_device_image_unload.isnull()) m_device_image_unload(*this); - } - if (m_hard_disk_handle != nullptr) - { - delete m_hard_disk_handle; - m_hard_disk_handle = nullptr; - } + m_hard_disk_handle.reset(); m_origchd.close(); m_diffchd.close(); @@ -212,10 +201,9 @@ std::error_condition diablo_image_device::internal_load_dsk() m_chd = nullptr; - if (m_hard_disk_handle) - delete m_hard_disk_handle; + m_hard_disk_handle.reset(); - /* open the CHD file */ + // open the CHD file if (loaded_through_softlist()) { m_chd = device().machine().rom_load().get_disk_handle(device().subtag("harddriv").c_str()); @@ -246,21 +234,18 @@ std::error_condition diablo_image_device::internal_load_dsk() } } - if (m_chd != nullptr) + if (m_chd) { - /* open the hard disk file */ - m_hard_disk_handle = new hard_disk_file(m_chd); - if (m_hard_disk_handle != nullptr) + // open the hard disk file + m_hard_disk_handle.reset(new hard_disk_file(m_chd)); + if (m_hard_disk_handle) return std::error_condition(); } - /* if we had an error, close out the CHD */ + // if we had an error, close out the CHD m_origchd.close(); m_diffchd.close(); m_chd = nullptr; - if (err) - return err; - else - return image_error::UNSPECIFIED; + return err ? err : image_error::UNSPECIFIED; } diff --git a/src/devices/imagedev/diablo.h b/src/devices/imagedev/diablo.h index 643496ae1d1..2d7b0287192 100644 --- a/src/devices/imagedev/diablo.h +++ b/src/devices/imagedev/diablo.h @@ -9,9 +9,16 @@ #pragma once -#include "harddriv.h" #include "softlist_dev.h" +#include "harddriv.h" + +#include +#include +#include +#include + + #define DIABLO_TAG(id) "diablo"#id /*************************************************************************** @@ -45,7 +52,7 @@ public: virtual const util::option_guide &create_option_guide() const override; // specific implementation - hard_disk_file *get_hard_disk_file() { return m_hard_disk_handle; } + hard_disk_file *get_hard_disk_file() { return m_hard_disk_handle.get(); } protected: // device_t implementation @@ -59,9 +66,9 @@ protected: std::error_condition internal_load_dsk(); chd_file *m_chd; - chd_file m_origchd; /* handle to the original CHD */ - chd_file m_diffchd; /* handle to the diff CHD */ - hard_disk_file *m_hard_disk_handle; + chd_file m_origchd; // handle to the original CHD + chd_file m_diffchd; // handle to the diff CHD + std::unique_ptr m_hard_disk_handle; load_delegate m_device_image_load; unload_delegate m_device_image_unload; diff --git a/src/devices/imagedev/flopdrv.cpp b/src/devices/imagedev/flopdrv.cpp index aeac08466c6..27d17f15d32 100644 --- a/src/devices/imagedev/flopdrv.cpp +++ b/src/devices/imagedev/flopdrv.cpp @@ -15,6 +15,7 @@ #include "emu.h" #include "flopdrv.h" + #include "softlist_dev.h" #include "formats/imageutl.h" @@ -22,9 +23,9 @@ #include "util/ioprocs.h" #include "util/ioprocsfilter.h" +//#define VERBOSE 1 +#include "logmacro.h" -#define VERBOSE 0 -#define LOG(x) do { if (VERBOSE) logerror x; } while (0) /*************************************************************************** CONSTANTS @@ -255,7 +256,7 @@ int legacy_floppy_image_device::floppy_drive_get_flag_state(int flag) void legacy_floppy_image_device::floppy_drive_seek(signed int signed_tracks) { - LOG(("seek from: %d delta: %d\n",m_current_track, signed_tracks)); + LOG("seek from: %d delta: %d\n", m_current_track, signed_tracks); /* update position */ m_current_track+=signed_tracks; diff --git a/src/devices/imagedev/flopdrv.h b/src/devices/imagedev/flopdrv.h index 78d986ff9f4..09b0976ac8c 100644 --- a/src/devices/imagedev/flopdrv.h +++ b/src/devices/imagedev/flopdrv.h @@ -165,7 +165,7 @@ private: protected: legacy_floppy_image_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); - // device overrides + // device_t implementation virtual void device_config_complete() override; virtual void device_start() override; diff --git a/src/devices/imagedev/floppy.h b/src/devices/imagedev/floppy.h index ac087aceb83..9ca327ef2d1 100644 --- a/src/devices/imagedev/floppy.h +++ b/src/devices/imagedev/floppy.h @@ -87,7 +87,7 @@ public: void init_fs(const fs_info *fs, const fs::meta_data &meta); - // image-level overrides + // device_image_interface implementation virtual std::error_condition call_load() override; virtual void call_unload() override; virtual std::error_condition call_create(int format_type, util::option_resolution *format_options) override; @@ -166,7 +166,7 @@ protected: floppy_image_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); - // device-level overrides + // device_t implementation virtual void device_start() override; virtual void device_reset() override; virtual void device_config_complete() override; diff --git a/src/devices/imagedev/harddriv.cpp b/src/devices/imagedev/harddriv.cpp index 8269c586213..af624d0791c 100644 --- a/src/devices/imagedev/harddriv.cpp +++ b/src/devices/imagedev/harddriv.cpp @@ -44,8 +44,8 @@ DEFINE_DEVICE_TYPE(HARDDISK, harddisk_image_device, "harddisk_image", "Harddisk" //------------------------------------------------- harddisk_image_base_device::harddisk_image_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, type, tag, owner, clock), - device_image_interface(mconfig, *this) + : device_t(mconfig, type, tag, owner, clock) + , device_image_interface(mconfig, *this) { } @@ -63,12 +63,12 @@ harddisk_image_device::harddisk_image_device(const machine_config &mconfig, cons //------------------------------------------------- harddisk_image_device::harddisk_image_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) - : harddisk_image_base_device(mconfig, type, tag, owner, clock), - m_chd(nullptr), - m_hard_disk_handle(nullptr), - m_device_image_load(*this), - m_device_image_unload(*this), - m_interface(nullptr) + : harddisk_image_base_device(mconfig, type, tag, owner, clock) + , m_chd(nullptr) + , m_hard_disk_handle() + , m_device_image_load(*this) + , m_device_image_unload(*this) + , m_interface(nullptr) { } @@ -109,33 +109,25 @@ void harddisk_image_device::device_start() // try to locate the CHD from a DISK_REGION chd_file *handle = machine().rom_load().get_disk_handle(tag()); - if (handle != nullptr) - { - m_hard_disk_handle = new hard_disk_file(handle); - } + if (handle) + m_hard_disk_handle.reset(new hard_disk_file(handle)); else - { - m_hard_disk_handle = nullptr; - } + m_hard_disk_handle.reset(); } void harddisk_image_device::device_stop() { - if (m_hard_disk_handle != nullptr) - { - delete m_hard_disk_handle; - m_hard_disk_handle = nullptr; - } + m_hard_disk_handle.reset(); } std::error_condition harddisk_image_device::call_load() { std::error_condition our_result = internal_load_hd(); - /* Check if there is an image_load callback defined */ + // Check if there is an image_load callback defined if (!our_result && !m_device_image_load.isnull()) { - /* Let the override do some additional work/checks */ + // Let the override do some additional work/checks our_result = m_device_image_load(*this); } return our_result; @@ -155,7 +147,7 @@ std::error_condition harddisk_image_device::call_create(int create_format, util: const uint32_t totalsectors = cylinders * heads * sectors; - /* create the CHD file */ + // create the CHD file chd_codec_type compression[4] = { CHD_CODEC_NONE }; util::core_file::ptr proxy; std::error_condition err = util::core_file::open_proxy(image_core_file(), proxy); @@ -164,7 +156,7 @@ std::error_condition harddisk_image_device::call_create(int create_format, util: if (err) return err; - /* if we created the image and hence, have metadata to set, set the metadata */ + // if we created the image and hence, have metadata to set, set the metadata err = m_origchd.write_metadata(HARD_DISK_METADATA_TAG, 0, string_format(HARD_DISK_METADATA_FORMAT, cylinders, heads, sectors, sectorsize)); m_origchd.close(); @@ -176,15 +168,11 @@ std::error_condition harddisk_image_device::call_create(int create_format, util: void harddisk_image_device::call_unload() { - /* Check if there is an image_unload callback defined */ + // Check if there is an image_unload callback defined if (!m_device_image_unload.isnull()) m_device_image_unload(*this); - if (m_hard_disk_handle) - { - delete m_hard_disk_handle; - m_hard_disk_handle = nullptr; - } + m_hard_disk_handle.reset(); if (m_chd) { @@ -243,13 +231,9 @@ std::error_condition harddisk_image_device::internal_load_hd() m_chd = nullptr; uint8_t header[64]; - if (m_hard_disk_handle) - { - delete m_hard_disk_handle; - m_hard_disk_handle = nullptr; - } + m_hard_disk_handle.reset(); - /* open the CHD file */ + // open the CHD file if (loaded_through_softlist()) { m_chd = machine().rom_load().get_disk_handle(device().subtag("harddriv").c_str()); @@ -291,8 +275,8 @@ std::error_condition harddisk_image_device::internal_load_hd() if (m_chd) { - /* open the hard disk file */ - m_hard_disk_handle = new hard_disk_file(m_chd); + // open the hard disk file + m_hard_disk_handle.reset(new hard_disk_file(m_chd)); if (m_hard_disk_handle) return std::error_condition(); } @@ -323,7 +307,7 @@ std::error_condition harddisk_image_device::internal_load_hd() } } - m_hard_disk_handle = new hard_disk_file(image_core_file(), skip); + m_hard_disk_handle.reset(new hard_disk_file(image_core_file(), skip)); if (m_hard_disk_handle) return std::error_condition(); } diff --git a/src/devices/imagedev/harddriv.h b/src/devices/imagedev/harddriv.h index 0d93a0259f5..e0803ae3692 100644 --- a/src/devices/imagedev/harddriv.h +++ b/src/devices/imagedev/harddriv.h @@ -11,9 +11,16 @@ #ifndef MAME_DEVICES_IMAGEDEV_HARDDRIV_H #define MAME_DEVICES_IMAGEDEV_HARDDRIV_H +#include "softlist_dev.h" + #include "chd.h" #include "harddisk.h" -#include "softlist_dev.h" + +#include +#include +#include +#include + /*************************************************************************** TYPE DEFINITIONS @@ -27,7 +34,7 @@ protected: // construction/destruction harddisk_image_base_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); - // image-level overrides + // device_image_interface implementation virtual bool is_readable() const noexcept override { return true; } virtual bool is_writeable() const noexcept override { return true; } virtual bool is_creatable() const noexcept override { return false; } @@ -57,7 +64,7 @@ public: template void set_device_unload(T &&... args) { m_device_image_unload.set(std::forward(args)...); } void set_interface(const char *interface) { m_interface = interface; } - // image-level overrides + // device_image_interface implementation virtual std::error_condition call_load() override; virtual std::error_condition call_create(int create_format, util::option_resolution *create_args) override; virtual void call_unload() override; @@ -68,12 +75,12 @@ public: virtual const util::option_guide &create_option_guide() const override; // specific implementation - hard_disk_file *get_hard_disk_file() { return m_hard_disk_handle; } + hard_disk_file *get_hard_disk_file() { return m_hard_disk_handle.get(); } protected: harddisk_image_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); - // device-level overrides + // device_t implementation virtual void device_config_complete() override; virtual void device_start() override; virtual void device_stop() override; @@ -84,9 +91,9 @@ protected: std::error_condition internal_load_hd(); chd_file *m_chd; - chd_file m_origchd; /* handle to the original CHD */ - chd_file m_diffchd; /* handle to the diff CHD */ - hard_disk_file *m_hard_disk_handle; + chd_file m_origchd; // handle to the original CHD + chd_file m_diffchd; // handle to the diff CHD + std::unique_ptr m_hard_disk_handle; load_delegate m_device_image_load; unload_delegate m_device_image_unload; diff --git a/src/devices/imagedev/mfmhd.cpp b/src/devices/imagedev/mfmhd.cpp index f2c04c7d273..d5c05d65f35 100644 --- a/src/devices/imagedev/mfmhd.cpp +++ b/src/devices/imagedev/mfmhd.cpp @@ -425,10 +425,10 @@ std::error_condition mfm_harddisk_device::call_load() else { auto io = util::random_read_write_fill(image_core_file(), 0xff); - if(!io) { + if (!io) return std::errc::not_enough_memory; - } - m_chd = new chd_file; + + m_chd = new chd_file; // FIXME: this is never deleted err = m_chd->open(std::move(io), true); } @@ -441,7 +441,7 @@ std::error_condition mfm_harddisk_device::call_load() { std::string metadata; - if (m_chd==nullptr) + if (!m_chd) { LOG("m_chd is null\n"); return image_error::UNSPECIFIED; @@ -472,6 +472,7 @@ std::error_condition mfm_harddisk_device::call_load() if (m_max_cylinders != 0 && (param.cylinders != m_max_cylinders || param.heads != m_max_heads)) { + // TODO: does this really need to be a fatal error? throw emu_fatalerror("Image geometry does not fit this kind of hard drive: drive=(%d,%d), image=(%d,%d)", m_max_cylinders, m_max_heads, param.cylinders, param.heads); } @@ -484,13 +485,9 @@ std::error_condition mfm_harddisk_device::call_load() state = m_chd->read_metadata(MFM_HARD_DISK_METADATA_TAG, 0, metadata); if (state) - { LOGMASKED(LOG_WARN, "Failed to read CHD sector arrangement/recording specs, applying defaults\n"); - } else - { sscanf(metadata.c_str(), MFMHD_REC_METADATA_FORMAT, ¶m.interleave, ¶m.cylskew, ¶m.headskew, ¶m.write_precomp_cylinder, ¶m.reduced_wcurr_cylinder); - } if (!param.sane_rec()) { @@ -498,18 +495,17 @@ std::error_condition mfm_harddisk_device::call_load() param.reset_rec(); } else - LOGMASKED(LOG_CONFIG, "MFM HD rec specs: interleave=%d, cylskew=%d, headskew=%d, wpcom=%d, rwc=%d\n", - param.interleave, param.cylskew, param.headskew, param.write_precomp_cylinder, param.reduced_wcurr_cylinder); + { + LOGMASKED(LOG_CONFIG, + "MFM HD rec specs: interleave=%d, cylskew=%d, headskew=%d, wpcom=%d, rwc=%d\n", + param.interleave, param.cylskew, param.headskew, param.write_precomp_cylinder, param.reduced_wcurr_cylinder); + } state = m_chd->read_metadata(MFM_HARD_DISK_METADATA_TAG, 1, metadata); if (state) - { LOGMASKED(LOG_WARN, "Failed to read CHD track gap specs, applying defaults\n"); - } else - { sscanf(metadata.c_str(), MFMHD_GAP_METADATA_FORMAT, ¶m.gap1, ¶m.gap2, ¶m.gap3, ¶m.sync, ¶m.headerlen, ¶m.ecctype); - } if (!param.sane_gap()) { @@ -517,8 +513,11 @@ std::error_condition mfm_harddisk_device::call_load() param.reset_gap(); } else - LOGMASKED(LOG_CONFIG, "MFM HD gap specs: gap1=%d, gap2=%d, gap3=%d, sync=%d, headerlen=%d, ecctype=%d\n", - param.gap1, param.gap2, param.gap3, param.sync, param.headerlen, param.ecctype); + { + LOGMASKED(LOG_CONFIG, + "MFM HD gap specs: gap1=%d, gap2=%d, gap3=%d, sync=%d, headerlen=%d, ecctype=%d\n", + param.gap1, param.gap2, param.gap3, param.sync, param.headerlen, param.ecctype); + } m_format->set_layout_params(param); diff --git a/src/devices/imagedev/mfmhd.h b/src/devices/imagedev/mfmhd.h index f3dade1a792..9d543f2e8d5 100644 --- a/src/devices/imagedev/mfmhd.h +++ b/src/devices/imagedev/mfmhd.h @@ -20,7 +20,9 @@ #include "formats/mfm_hd.h" +#include #include +#include class mfm_harddisk_device; @@ -262,7 +264,7 @@ private: mfmhd_enc_t m_encoding; int m_spinupms; int m_cachesize; - mfmhd_image_format_t* m_format; + mfmhd_image_format_t *m_format; }; DECLARE_DEVICE_TYPE(MFM_HD_CONNECTOR, mfm_harddisk_connector) diff --git a/src/devices/imagedev/midiin.cpp b/src/devices/imagedev/midiin.cpp index b5a5e06b197..611dd4ad59b 100644 --- a/src/devices/imagedev/midiin.cpp +++ b/src/devices/imagedev/midiin.cpp @@ -49,16 +49,16 @@ INPUT_PORTS_END -------------------------------------------------*/ midiin_device::midiin_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, MIDIIN, tag, owner, clock), - device_image_interface(mconfig, *this), - device_serial_interface(mconfig, *this), - m_midi(), - m_config(*this, "CFG"), - m_timer(nullptr), - m_input_cb(*this), - m_xmit_read(0), - m_xmit_write(0), - m_tx_busy(false) + : device_t(mconfig, MIDIIN, tag, owner, clock) + , device_image_interface(mconfig, *this) + , device_serial_interface(mconfig, *this) + , m_midi() + , m_config(*this, "CFG") + , m_timer(nullptr) + , m_input_cb(*this) + , m_xmit_read(0) + , m_xmit_write(0) + , m_tx_busy(false) { } diff --git a/src/devices/imagedev/midiin.h b/src/devices/imagedev/midiin.h index a95fde1570d..67b9f749c3e 100644 --- a/src/devices/imagedev/midiin.h +++ b/src/devices/imagedev/midiin.h @@ -15,6 +15,11 @@ #include "diserial.h" +#include +#include +#include +#include + /*************************************************************************** TYPE DEFINITIONS @@ -31,7 +36,7 @@ public: auto input_callback() { return m_input_cb.bind(); } - // image-level overrides + // device_image_interface implementation virtual std::error_condition call_load() override; virtual void call_unload() override; @@ -46,12 +51,12 @@ public: virtual const char *image_brief_type_name() const noexcept override { return "min"; } protected: - // device-level overrides + // device_t implementation virtual ioport_constructor device_input_ports() const override; virtual void device_start() override; virtual void device_reset() override; - // serial overrides + // device_serial_interface implementation virtual void tra_complete() override; // Tx completed sending byte virtual void tra_callback() override; // Tx send bit diff --git a/src/devices/imagedev/midiout.cpp b/src/devices/imagedev/midiout.cpp index 7b44dde0c95..29463a8ccec 100644 --- a/src/devices/imagedev/midiout.cpp +++ b/src/devices/imagedev/midiout.cpp @@ -23,10 +23,10 @@ DEFINE_DEVICE_TYPE(MIDIOUT, midiout_device, "midiout", "MIDI Out image device") -------------------------------------------------*/ midiout_device::midiout_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, MIDIOUT, tag, owner, clock), - device_image_interface(mconfig, *this), - device_serial_interface(mconfig, *this), - m_midi() + : device_t(mconfig, MIDIOUT, tag, owner, clock) + , device_image_interface(mconfig, *this) + , device_serial_interface(mconfig, *this) + , m_midi() { } diff --git a/src/devices/imagedev/midiout.h b/src/devices/imagedev/midiout.h index c52c79a3e55..b0d246d5302 100644 --- a/src/devices/imagedev/midiout.h +++ b/src/devices/imagedev/midiout.h @@ -15,6 +15,11 @@ #include "diserial.h" +#include +#include +#include +#include + /*************************************************************************** TYPE DEFINITIONS @@ -29,7 +34,7 @@ public: midiout_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); ~midiout_device(); - // image-level overrides + // device_image_interface implementation virtual std::error_condition call_load() override; virtual void call_unload() override; @@ -46,11 +51,11 @@ public: virtual void tx(uint8_t state) { rx_w(state); } protected: - // device-level overrides + // device_t implementation virtual void device_start() override; virtual void device_reset() override; - // serial overrides + // device_serial_interface implementation virtual void rcv_complete() override; // Rx completed receiving byte private: diff --git a/src/devices/imagedev/picture.cpp b/src/devices/imagedev/picture.cpp index e0d569d0922..af50691d85b 100644 --- a/src/devices/imagedev/picture.cpp +++ b/src/devices/imagedev/picture.cpp @@ -70,8 +70,5 @@ std::error_condition picture_image_device::call_load() void picture_image_device::call_unload() { - if (m_picture.valid()) - { - m_picture.reset(); - } + m_picture.reset(); } diff --git a/src/devices/imagedev/printer.cpp b/src/devices/imagedev/printer.cpp index 3189bd86d01..7d96ea0c83e 100644 --- a/src/devices/imagedev/printer.cpp +++ b/src/devices/imagedev/printer.cpp @@ -78,11 +78,11 @@ std::error_condition printer_image_device::call_create(int format_type, util::op -------------------------------------------------*/ std::error_condition printer_image_device::call_load() { - /* send notify that the printer is now online */ + // send notify that the printer is now online if (!m_online_cb.isnull()) m_online_cb(true); - /* we don't need to do anything special */ + // we don't need to do anything special return std::error_condition(); } diff --git a/src/devices/imagedev/snapquik.cpp b/src/devices/imagedev/snapquik.cpp index 5ceb095d2de..d865cb716cb 100644 --- a/src/devices/imagedev/snapquik.cpp +++ b/src/devices/imagedev/snapquik.cpp @@ -64,7 +64,7 @@ void snapshot_image_device::device_start() { m_load.resolve(); - /* allocate a timer */ + // allocate a timer m_timer = timer_alloc(FUNC(snapshot_image_device::process_snapshot_or_quickload), this); } @@ -73,7 +73,7 @@ void snapshot_image_device::device_start() -------------------------------------------------*/ std::error_condition snapshot_image_device::call_load() { - /* adjust the timer */ + // adjust the timer m_timer->adjust(m_delay, 0); return std::error_condition(); } diff --git a/src/devices/imagedev/wafadrive.cpp b/src/devices/imagedev/wafadrive.cpp index 342efe093d1..9e9e353da32 100644 --- a/src/devices/imagedev/wafadrive.cpp +++ b/src/devices/imagedev/wafadrive.cpp @@ -20,7 +20,7 @@ DEFINE_DEVICE_TYPE(WAFADRIVE_IMAGE, wafadrive_image_device, "wafadrive_image", "Sinclair Wafadrive Image") //------------------------------------------------- -// microdrive_image_device - constructor +// wafadrive_image_device - constructor //------------------------------------------------- wafadrive_image_device::wafadrive_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : @@ -29,7 +29,7 @@ wafadrive_image_device::wafadrive_image_device(const machine_config &mconfig, co } //------------------------------------------------- -// microdrive_image_device - destructor +// wafadrive_image_device - destructor //------------------------------------------------- wafadrive_image_device::~wafadrive_image_device() diff --git a/src/devices/imagedev/wafadrive.h b/src/devices/imagedev/wafadrive.h index 00203f4cded..bc8ae6d9767 100644 --- a/src/devices/imagedev/wafadrive.h +++ b/src/devices/imagedev/wafadrive.h @@ -29,7 +29,7 @@ public: wafadrive_image_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); virtual ~wafadrive_image_device(); - // image-level overrides + // device_image_interface implementation virtual std::error_condition call_load() override; virtual void call_unload() override; @@ -38,7 +38,7 @@ public: virtual const char *file_extensions() const noexcept override { return "wdr"; } protected: - // device-level overrides + // device_t implementation virtual void device_start() override; }; diff --git a/src/devices/machine/pccard_sram.cpp b/src/devices/machine/pccard_sram.cpp index 432b64e84fd..50c3ca0b226 100644 --- a/src/devices/machine/pccard_sram.cpp +++ b/src/devices/machine/pccard_sram.cpp @@ -280,7 +280,7 @@ std::error_condition pccard_centennial_sram_device::call_create(int format_type, // clear ram std::fill_n(&m_sram[0], m_sram.length(), 0); - // initialize eeprom data from default data + // initialize EEPROM data from default data std::copy_n(m_eeprom_default->base(), m_eeprom.length(), &m_eeprom[0]); if (fwrite(&m_sram[0], m_sram.bytes()) != m_sram.bytes()) diff --git a/src/devices/machine/smartmed.cpp b/src/devices/machine/smartmed.cpp index 4ba30d5d442..60b2f775b4f 100644 --- a/src/devices/machine/smartmed.cpp +++ b/src/devices/machine/smartmed.cpp @@ -219,9 +219,8 @@ std::error_condition smartmedia_image_device::smartmedia_format_2() std::error_condition smartmedia_image_device::call_load() { std::error_condition result; - uint64_t position; // try format 1 - position = ftell(); + uint64_t const position = ftell(); result = smartmedia_format_1(); if (result) { diff --git a/src/devices/machine/smartmed.h b/src/devices/machine/smartmed.h index 48e488d71f7..b9c7e662764 100644 --- a/src/devices/machine/smartmed.h +++ b/src/devices/machine/smartmed.h @@ -36,7 +36,7 @@ public: virtual void call_unload() override; // Because nand_device is a NVRAM device now, stub these to make it not do anything (read only) - virtual void nvram_default() override {}; + virtual void nvram_default() override { } virtual bool nvram_read(util::read_stream &file) override { return true; }; virtual bool nvram_write(util::write_stream &file) override { return false; }; -- cgit v1.2.3