mirror of
https://github.com/holub/mame
synced 2025-04-09 18:17:44 +03:00
-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.
This commit is contained in:
parent
c4282feced
commit
b67b969bf0
@ -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
|
||||
|
||||
function dummy.startplugin()
|
||||
emu.register_start(function()
|
||||
emu.print_verbose("Starting " .. emu.gamename())
|
||||
end)
|
||||
local reset_subscription, stop_subscription
|
||||
|
||||
emu.register_stop(function()
|
||||
emu.print_verbose("Exiting " .. emu.gamename())
|
||||
end)
|
||||
function dummy.startplugin()
|
||||
reset_subscription = emu.add_machine_reset_notifier(
|
||||
function ()
|
||||
emu.print_info("Starting " .. 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -13,8 +13,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "bitmap.h"
|
||||
#include "aviio.h"
|
||||
#include "bitmap.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
TYPE DEFINITIONS
|
||||
@ -51,7 +57,7 @@ protected:
|
||||
TIMER_CALLBACK_MEMBER(frame_timer);
|
||||
|
||||
private:
|
||||
bitmap_argb32 *m_frame;
|
||||
std::unique_ptr<bitmap_argb32> m_frame;
|
||||
avi_file::ptr m_avi;
|
||||
|
||||
emu_timer *m_frame_timer;
|
||||
|
@ -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; }
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -13,9 +13,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cdrom.h"
|
||||
#include "softlist_dev.h"
|
||||
|
||||
#include "cdrom.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
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<cdrom_file> m_cdrom_handle;
|
||||
const char *m_extension_list;
|
||||
const char *m_interface;
|
||||
};
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -9,9 +9,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "harddriv.h"
|
||||
#include "softlist_dev.h"
|
||||
|
||||
#include "harddriv.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
|
||||
|
||||
#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<hard_disk_file> m_hard_disk_handle;
|
||||
|
||||
load_delegate m_device_image_load;
|
||||
unload_delegate m_device_image_unload;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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 <memory>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
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 <typename... T> void set_device_unload(T &&... args) { m_device_image_unload.set(std::forward<T>(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<hard_disk_file> m_hard_disk_handle;
|
||||
|
||||
load_delegate m_device_image_load;
|
||||
unload_delegate m_device_image_unload;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -20,7 +20,9 @@
|
||||
|
||||
#include "formats/mfm_hd.h"
|
||||
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
|
||||
|
||||
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)
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,11 @@
|
||||
|
||||
#include "diserial.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
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
|
||||
|
||||
|
@ -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()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,11 @@
|
||||
|
||||
#include "diserial.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <system_error>
|
||||
#include <utility>
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
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:
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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())
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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; };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user