-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.
konami_53cf96
Vas Crabb 8 months ago
parent c4282feced
commit b67b969bf0
  1. 4
      docs/source/conf.py
  2. 5
      docs/source/plugins/dummy.rst
  3. 12
      docs/source/techspecs/luaengine.rst
  4. 88
      docs/source/techspecs/luareference.rst
  5. 6
      plugins/autofire/init.lua
  6. 8
      plugins/cheat/init.lua
  7. 4
      plugins/cheatfind/init.lua
  8. 10
      plugins/console/init.lua
  9. 4
      plugins/data/init.lua
  10. 20
      plugins/discord/init.lua
  11. 18
      plugins/dummy/init.lua
  12. 18
      plugins/gdbstub/init.lua
  13. 11
      plugins/hiscore/init.lua
  14. 6
      plugins/inputmacro/init.lua
  15. 22
      plugins/layout/init.lua
  16. 6
      plugins/timecode/init.lua
  17. 11
      plugins/timer/init.lua
  18. 2
      src/devices/bus/isa/mcd.cpp
  19. 8
      src/devices/bus/qbus/pc11.h
  20. 14
      src/devices/bus/saturn/sat_slot.cpp
  21. 9
      src/devices/bus/scv/slot.cpp
  22. 8
      src/devices/bus/sdk85/memexp.cpp
  23. 11
      src/devices/bus/sega8/sega8_slot.cpp
  24. 16
      src/devices/bus/snes/snes_slot.cpp
  25. 2
      src/devices/bus/spectrum/intf2.cpp
  26. 4
      src/devices/bus/ti99x/990_tap.cpp
  27. 4
      src/devices/bus/vc4000/slot.cpp
  28. 4
      src/devices/bus/vcs/vcs_slot.cpp
  29. 8
      src/devices/bus/vcs/vcs_slot.h
  30. 5
      src/devices/bus/vectrex/slot.cpp
  31. 4
      src/devices/bus/vic10/exp.cpp
  32. 2
      src/devices/bus/vic20/exp.cpp
  33. 16
      src/devices/bus/vidbrain/exp.cpp
  34. 14
      src/devices/bus/vsmile/vsmile_slot.cpp
  35. 7
      src/devices/bus/wswan/slot.cpp
  36. 8
      src/devices/bus/wswan/slot.h
  37. 21
      src/devices/bus/z88/z88.cpp
  38. 6
      src/devices/bus/z88/z88.h
  39. 23
      src/devices/imagedev/avivideo.cpp
  40. 10
      src/devices/imagedev/avivideo.h
  41. 4
      src/devices/imagedev/cassette.h
  42. 47
      src/devices/imagedev/chd_cd.cpp
  43. 17
      src/devices/imagedev/chd_cd.h
  44. 57
      src/devices/imagedev/diablo.cpp
  45. 17
      src/devices/imagedev/diablo.h
  46. 7
      src/devices/imagedev/flopdrv.cpp
  47. 2
      src/devices/imagedev/flopdrv.h
  48. 4
      src/devices/imagedev/floppy.h
  49. 62
      src/devices/imagedev/harddriv.cpp
  50. 23
      src/devices/imagedev/harddriv.h
  51. 31
      src/devices/imagedev/mfmhd.cpp
  52. 4
      src/devices/imagedev/mfmhd.h
  53. 20
      src/devices/imagedev/midiin.cpp
  54. 11
      src/devices/imagedev/midiin.h
  55. 8
      src/devices/imagedev/midiout.cpp
  56. 11
      src/devices/imagedev/midiout.h
  57. 5
      src/devices/imagedev/picture.cpp
  58. 4
      src/devices/imagedev/printer.cpp
  59. 4
      src/devices/imagedev/snapquik.cpp
  60. 4
      src/devices/imagedev/wafadrive.cpp
  61. 4
      src/devices/imagedev/wafadrive.h
  62. 2
      src/devices/machine/pccard_sram.cpp
  63. 3
      src/devices/machine/smartmed.cpp
  64. 2
      src/devices/machine/smartmed.h

@ -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.

@ -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 <mame-commandline-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.

@ -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:

@ -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 <luareference-core-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 <luareference-core-notifiersub>`.
emu.add_machine_stop_notifier(callback)
Add a callback to receive notifications when the emulated system is stopped.
Returns a :ref:`notifier subscription <luareference-core-notifiersub>`.
emu.add_machine_pause_notifier(callback)
Add a callback to receive notifications when the emulated system is paused.
Returns a :ref:`notifier subscription <luareference-core-notifiersub>`.
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 <luareference-core-notifiersub>`.
emu.add_machine_frame_notifier(callback)
Add a callback to receive notifications when an emulated frame completes.
Returns a :ref:`notifier subscription <luareference-core-notifiersub>`.
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 <luareference-core-notifiersub>`.
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 <luareference-core-notifiersub>`.
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 <luareference-mem-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
^^^^^^^^^^^^^

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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)

@ -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

@ -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

@ -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

@ -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)

@ -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;
}

@ -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

@ -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();

@ -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();

@ -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())

@ -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();

@ -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();

@ -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)
{

@ -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:

@ -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();

@ -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();

@ -31,7 +31,7 @@ public:
template <typename T> void set_address_space(T &&tag, int no) { m_address_space.set_tag(std::forward<T>(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;

@ -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);

@ -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"))
{

@ -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)
{

@ -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);
}
}

@ -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();

@ -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

@ -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;
};

@ -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);
}
}

6