Commit Graph

24 Commits

Author SHA1 Message Date
Oliver Stöneberg
679e9323be added missing \n to some more fatalerror() calls (no whatsnew) 2012-09-08 11:47:17 +00:00
Aaron Giles
2a88e54278 ioport.c C++ conversion. Mostly internal changes, with no
intended differences from previous behavior. For drivers,
the main change is that input_port_read() no longer exists.
Instead, the port must be fetched from the appropriate device,
and then read() is called.

For member functions, this is actually simpler/cleaner:

  value = ioport("tag")->read()

For legacy functions which have a driver_data state, it goes:

  value = state->ioport("tag")->read()

For other legacy functions, they need to fetch the root device:

  value = machine.root_device().ioport("tag")->read()

The other big change for drivers is that IPT_VBLANK is gone.
Instead, it has been replaced by a device line callback on the
screen device. There's a new macro PORT_VBLANK("tag") which
automatically points things to the right spot.

Here's a set of imperfect search & replace strings to convert
the input_port_read calls and fix up IPT_VBLANK:

input_port_read( *\( *)(machine\(\)) *, *([^)]+ *\))
ioport\1\3->read\(\)

input_port_read( *\( *)(.*machine[()]*) *, *([^)]+ *\))
\2\.root_device\(\)\.ioport\1\3->read\(\)

(state = .*driver_data[^}]+)space->machine\(\)\.root_device\(\)\.
\1state->

(state = .*driver_data[^}]+)device->machine\(\)\.root_device\(\)\.
\1state->

input_port_read_safe( *\( *)(machine\(\)) *, *([^,]+), *([^)]+\))
ioport\1\3->read_safe\(\4\)

IPT_VBLANK( *\))
IPT_CUSTOM\1 PORT_VBLANK("screen")
2012-05-03 09:00:08 +00:00
Angelo Salese
ded30e907e Clean-ups and version bump 2012-04-22 14:10:44 +00:00
Aaron Giles
a0a0ffd5fe Only print mismatched width warnings for required pointers.
Gets rid of spurious messages in tons of drivers.
2012-04-22 05:18:20 +00:00
Aaron Giles
f3de08a9f8 Created ioport_manager and moved the port list to it.
Removed global port lookups, now all lookups must be
done through device_t::ioport().
2012-04-22 05:07:46 +00:00
Aaron Giles
5594694605 Make memory shares follow the same pattern as memory
regions and memory banks, accessible only via the device.
2012-04-20 19:57:41 +00:00
Aaron Giles
0466e27746 Cleaned up required_/optional_<object> templates.
Added new ones for memory banks and memory regions.
Removed debugging verbose printfs.
2012-04-20 16:08:24 +00:00
Aaron Giles
18f33f4eff Changed device->subregion to device->memregion. Moved
memory_region management into the memory manager instead
of directly in the machine. Hid the global region method;
now all regions must be looked up relative to a device.

If you're a member function, you can just use memregion("tag") 
directly. If you're a global function or a device referencing
global regions, use machine().root_device().memregion("tag")
to look up regions relative to the root.

S&R to convert all references:

machine([()]*)\.region
machine\1\.root_device\(\).subregion

Then remove redundant machine().root_device() within src/mame:

([ \t])machine\(\)\.root_device\(\)\.
\1

And use state->memregion() if we have a state variable present:

(state *= *[^;]+driver_data[^}]+)([^ \t]*)machine[()]*\.root_device\(\)\.
\1state->

Finally some cleanup:

screen.state->
state->

device->state->
state->

space->state->
state->

And a few hand-tweaks.
2012-04-20 05:54:39 +00:00
Aaron Giles
776d29c90f Memory banks are now device-relative only. Global lookups
are private. Renamed device_t::subbank to device_t::membank
and updated a few remaining users of the global lookup.
2012-04-19 20:59:50 +00:00
Aaron Giles
523c35daed Now that memory_bank is exposed as an object, removed all the global
bank manipulation APIs from memory_manager, and instead added a
memory_manager::bank("tag") function which will return a pointer to
the representative memory_bank. Operations can then be performed as
expected directly on the memory_bank. Most code did not need an update
yet, as I haven't done the search/replace to move away from global
functions (which still exist for now).

Added device_t::subbank("tag") to return a bank that is owned by the
given device.

Switched YM2151 interfaces over to devcb callbacks.

Created proper sound devices for the Williams NARC, CVSD and ADPCM
sound boards. Updated midyunit, midtunit, williams(joust2), and
mcr68(archrivl/pigskin/trisport) to use the new devices.
2012-04-18 19:40:59 +00:00
Aaron Giles
fe9fb6ff9f Fix most reported errors. 2012-04-16 08:28:56 +00:00
Aaron Giles
1dd1388ed8 A few key fixes. Also changed error reporting to list all missing
objects prior to fatalerror'ing.
2012-04-15 22:00:24 +00:00
Aaron Giles
2c2fc07d6b Add assertions to catch situations where AM_SHARE is used twice.
Fix existing situations.
2012-04-12 06:01:56 +00:00
Aaron Giles
9ecbecb503 Fixed bug where required shared pointers were not actually required.
Added optional/required_shared_ptr_array classes so that you can
populate an array of shared pointers. You provide a base tag name,
and each item in the array is populated with tag.n, where n is the
array index.

Updated a couple of drivers using arrays to either not use arrays
(where they weren't really providing any benefit) or to use the new
array classes.
2012-04-12 05:03:16 +00:00
Aaron Giles
e48e63d684 Add logic to ensure that shared pointers are checked to be of the
right width. The primary upshot is that if you declare AM_SHARE("paletteram")
in an 8-bit memory map, then only m_generic_paletteram_8 will be populated,
and m_generic_paletteram_16 will be NULL. But it applies to all
required_/optional_shared_ptrs declared, so make sure they are of the
right type.

The required_/optional_shared_ptr mechanism should be used to replace
AM_BASE_MEMBER and AM_SIZE_MEMBER, which are technically dangerous and
illegal in C++ but work today through some trickery.
2012-04-05 19:19:38 +00:00
Aaron Giles
f87e01ed81 Converted memory_private to memory_manager and moved global memory
operations into methods on it. Converted the less-popular cases over
in drivers that used them, leaving the bank management APIs global
for now.
2012-04-05 18:25:39 +00:00
Aaron Giles
194397db29 Moved all drivers to using the paletteram helpers defined in the
driver_device base class. The palette base is now specified via an
AM_SHARE of "paletteram" or "paletteram2". The driver_device base
class now finds these pointers and places them in 
m_generic_paletteram_8/_16/_32 and m_generic_paletteram2_8/_16/_32.

Removed machine.generic.paletteram*, and machine.generic entirely.
Removed AM_BASE_GENERIC/AM_SIZE_GENERIC as they don't apply anymore.

Changed required_/optional_shared_ptr to support set_target with
base and size for manually configuring a shared pointer, and a new
allocate method for dynamically allocating (and registering the
memory for save states).

A few subsequent cleanups are coming related to this, but wanted
to get this in before the next modern push.
2012-04-05 07:44:51 +00:00
Aaron Giles
388d53737e Create new devices buffered_spriteram<n>_device, which manage buffered
spriteram. Removed core support for legacy buffered spriteram, and
updated all drivers to use the new devices instead. [Aaron Giles]

Removed required/optional_shared_size helpers. Instead the existing
required/optional_shared_ptr helpers now have a bytes() method that
can be used to query the size of the shared region. [Aaron Giles]
2012-03-08 07:39:27 +00:00
Aaron Giles
1ff793a4a8 Create a new device_mixer_interface, derived from device_sound_interface,
which mixes all its inputs to a single output stream. Redefined the
SPEAKER device to use this and remove the duplicate underlying logic.
The main purpose of this new interface is to allow device-ification of
an entire sound board, which can itself become a mixer of all of its
sound components to a single output stream. This stream can then be
routed by the device's owner to the appropriate speakers. A real-life
example will show up soon.
2012-02-25 19:21:35 +00:00
Angelo Salese
505442d0a0 Clean-ups and version bump 2012-01-29 16:34:26 +00:00
Aaron Giles
96101a5bd0 Change device reset so that the resets proceed hierarchically. Added
a device_reset_after_children() hook for things that need to wait for
the children to finish. Moved calling the driver/machine/sound/video
reset callbacks to the after children time, to align more with how it
was happening before.

Fixed siblingdevice("") so that it returns the current device and not
the owner.
2012-01-26 21:16:17 +00:00
Aaron Giles
ed0207f126 Move devices into a proper hierarchy and handle naming
and paths consistently for devices, I/O ports, memory
regions, memory banks, and memory shares. [Aaron Giles]

NOTE: there are likely regressions lurking here, mostly
due to devices not being properly found. I have temporarily
added more logging to -verbose to help understand what's
going on. Please let me know ASAP if anything that is being
actively worked on got broken.

As before, the driver device is the root device and all 
other devices are owned by it. Previously all devices
were kept in a single master list, and the hierarchy was
purely logical. With this change, each device owns its
own list of subdevices, and the hierarchy is explicitly
manifest. This means when a device is removed, all of its
subdevices are automatically removed as well.

A side effect of this is that walking the device list is
no longer simple. To address this, a new set of iterator
classes is provided, which walks the device tree in a depth
first manner. There is a general device_iterator class for
walking all devices, plus templates for a device_type_iterator
and a device_interface_iterator which are used to build
iterators for identifying only devices of a given type or
with a given interface. Typedefs for commonly-used cases
(e.g., screen_device_iterator, memory_interface_iterator)
are provided. Iterators can also provide counts, and can
perform indexed lookups.

All device name lookups are now done relative to another 
device. The maching_config and running_machine classes now
have a root_device() method to get the root of the hierarchy. 
The  existing machine->device("name") is now equivalent to
machine->root_device().subdevice("name").

A proper and normalized device path structure is now
supported. Device names that start with a colon are
treated as absolute paths from the root device. Device
names can also use a caret (^) to refer to the owning
device. Querying the device's tag() returns the device's
full path from the root. A new method basetag() returns
just the final tag.

The new pathing system is built on top of the 
device_t::subtag() method, so anyone using that will 
automatically support the new pathing rules. Each device
has its own internal map to cache successful lookups so
that subsequent lookups should be very fast.

Updated every place I could find that referenced devices,
memory regions, I/O ports, memory banks and memory shares
to leverage subtag/subdevice (or siblingtag/siblingdevice
which are built on top).

Removed the device_list class, as it doesn't apply any
more. Moved some of its methods into running_machine
instead.

Simplified the device callback system since the new 
pathing can describe all of the special-case devices that
were previously handled manually.

Changed the core output function callbacks to be delegates.

Completely rewrote the validity checking mechanism. The
validity checker is now a proper C++ class, and temporarily
takes over the error and warning outputs. All errors and 
warnings are collected during a session, and then output in
a consistent manner, with an explicit driver and source file
listed for each one, as well as additional device and/or
I/O port contexts where appropriate. Validity checkers 
should no longer explicitly output this information, just
the error, assuming that the context is provided.

Rewrote the software_list_device as a modern device, getting
rid of the software_list_config abstraction and simplifying
things.

Changed the way FLAC compiles so that it works like other
external libraries, and also compiles successfully for MSVC
builds.
2012-01-24 20:18:55 +00:00
Aaron Giles
6bd42bd8df inptport.* -> ioport.*
Plus fix headers of device.*
2011-06-28 19:38:11 +00:00
Aaron Giles
cd1c840ba4 devintrf.* -> device.* 2011-06-28 19:30:32 +00:00