Commit Graph

263 Commits

Author SHA1 Message Date
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
Aaron Giles
9afad3fd75 Use a tagged_list for memory_banks. 2012-04-24 04:47:27 +00:00
Angelo Salese
ded30e907e Clean-ups and version bump 2012-04-22 14:10:44 +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
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
b5b7808cb7 Remove global memory banking functions in favor of referencing
subbanks of a device and directly acting on them.

First round S&R:

memory_configure_bank( *)\(( *)([^,]+), *([^,]+), *
\3.root_device().subbank\1\(\2\4\2\)->configure_entries\1\(\2

memory_configure_bank_decrypted( *)\(( *)([^,]+), *([^,]+), *
\3.root_device().subbank\1\(\2\4\2\)->configure_decrypted_entries\1\(\2

memory_set_bank( *)\(( *)([^,]+), *([^,]+), *
\3.root_device().subbank\1\(\2\4\2\)->set_entry\1\(\2

memory_set_bankptr( *)\(( *)([^,]+), *([^,]+), *
\3.root_device().subbank\1\(\2\4\2\)->set_base\1\(\2


Then convert single entries to simpler form:

configure_entries( *\( *[^,]+, *)1 *, *([^,]+),[^)]+\)
configure_entry\1\2\)

configure_decrypted_entries( *\( *[^,]+, *)1 *, *([^,]+),[^)]+\)
configure_decrypted_entry\1\2\)


Remove renundant root_device lookup for methods:

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


Use state-> instead of root_device lookup where available (this
one must be done by hand unfortunately):

([^ \t]*)machine[()]*\.root_device\(\)\.
state->
2012-04-19 20:35:01 +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
3c0e321123 Remove AM_BASE in favor of AM_SHARED + required_shared_ptr.
This update passes validity checks but will certainly have
a number of drivers failing at startup because all pointers
are defaulted to required by the automated scripts used. 
Will fix problems once we get a regression run to find out 
which drivers need attention.
2012-04-15 05:44:22 +00:00
Aaron Giles
5352ec77d8 Remove AM_SIZE entirely. AM_BASE_SIZE still exists, though. 2012-04-11 23:14:33 +00:00
Angelo Salese
35e09dd41c Clean-ups and version bump 2012-04-08 14:12:02 +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
Scott Stone
a4098e8a3a Some cleanup of some observed #include redundancy from source files which use emu.h (nw) 2012-02-06 01:30:22 +00:00
Angelo Salese
505442d0a0 Clean-ups and version bump 2012-01-29 16:34:26 +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
Angelo Salese
5ee0c7d818 clean-ups and version bump 2011-10-10 21:17:54 +00:00
Miodrag Milanovic
4aae041c38 Simplified way of getting octal info (no whatsnew) 2011-10-04 17:16:07 +00:00
Miodrag Milanovic
6730bf8cc7 Added a way to handle output for debug messages and debugger itself into octal too, and made
a few CPU's to give octal output by default.
Note that for now just some functions things return octal, will add more, but since this change required clean compile better to put it sooner then later (no whatsnew)
2011-10-04 09:58:07 +00:00
R. Belmont
1d64e14960 Allow region tags starting with a : to mean "absolute" so devices can access the parent base driver's ROM regions [R. Belmont] 2011-09-17 18:47:02 +00:00
Olivier Galibert
c9fc846c46 memory: Fix an endianness issue when doing a device mapping on a big endian bus [O. Galibert] 2011-08-05 18:52:29 +00:00
Olivier Galibert
abc59bb3f8 addrmap: Allow adding device-sourced memory maps in the main map. [O. Galibert]
Device-side, it only works for modern device.  Declare the map with
DECLARE_ADDRESS_MAP(name, width).  It's a method which can be virtual
but not static.

In the implementation, define ADDRESS_MAP_MODERN, and define the map
starting with DEVICE_ADDRESS_MAP_START(name, width, device_class).
Rest is like a normal modern map.

To include it in the memory map use:
  AM_DEVICE( "device tag", devicea_class, name )

Or for device with differing widths:
  AM_DEVICE8(  "device tag", devicea_class, name, unitmask )
  AM_DEVICE16( "device tag", devicea_class, name, unitmask )
  AM_DEVICE32( "device tag", devicea_class, name, unitmask )
2011-07-05 04:41:06 +00:00
Curt Coder
f58d71ae0b Added device-relative functions for memory banking. [Curt Coder] 2011-06-23 13:27:35 +00:00
Miodrag Milanovic
742a3a92b3 Fix for remaining issues with validation of rom regions (no whatsnew) 2011-06-22 16:23:32 +00:00
Miodrag Milanovic
d0793e644d Fixed AM_REGION to be relative to device (no whatsnew) 2011-06-22 12:13:55 +00:00
Angelo Salese
e6050ace10 Cleanups and version bump 2011-06-19 19:29:25 +00:00
Wilbert Pol
d565bd41e6 memory.c: Fixed display of physical addresses in the debug memory viewer. [Wilbert Pol] 2011-06-14 20:20:48 +00:00
Olivier Galibert
58e656ed66 Duh! (nwn) 2011-06-12 21:14:45 +00:00
Olivier Galibert
e072ccc0f2 memory: Stop being stupid and call the extremely well written
populate_range_mirrored code through map_range when appropriate, which
is most of the time.  [O. Galibert]
2011-06-10 17:50:01 +00:00
Angelo Salese
a449c766a2 Cleanups and version bump 2011-06-05 22:35:20 +00:00
Olivier Galibert
87a6c3f7f8 memory: Change the gc into a refcounter, for speed reasons. [O. Galibert] 2011-06-05 09:03:31 +00:00
Olivier Galibert
b0a4945735 Revert "memory: Change the gc into a refcounter, for speed reasons. [O. Galibert]"
This reverts commit 5deef5b2c6fabdea8cd45ccf71c99f56940e88a2.

Broken, sorry.
2011-06-01 13:00:12 +00:00
Olivier Galibert
f90cbff557 memory: Change the gc into a refcounter, for speed reasons. [O. Galibert] 2011-06-01 12:56:00 +00:00
Olivier Galibert
459102e95f memory: Implement depopulate_unused(). [O. Galibert]
depopulate_unused is essentially the garbage collector for
bottom-level handlers.  The previous code was working around not
having it implemented yet by reusing handlers with the same start
address, end address and address mask.  The problem with that trick is
that it is slightly incorrect.  If you have a memory map with:
  AM_RANGE(0x0000, 0x0fff) AM_READ(up_r)
  AM_RANGE(0x0000, 0x0fff) AM_READ(down_r) AM_MIRROR(0x8000)

then the range 8000..8fff would have called up_r instead of down_r due
to the handler reuse.  The mirror value is not saved, hence not
compared.  New code doesn't use the trick, so doesn't call the wrong
handler, but OTOH eats handlers for breakfast.

It's important to note that such a memory map is so highly improbable
hardware-wise that it wasn't worth worrying about.  But it's a
behaviour change it is interesting to keep in mind.  In particular
since the up_r range can be added through an install_read_handler
instead of a static map.
2011-06-01 07:09:24 +00:00
Scott Stone
50c4a12869 Per OG: Change to allow debug to correctly build. (no whatsnew.txt) 2011-05-31 22:14:59 +00:00
Olivier Galibert
f8c1c71594 memory: Finally allow different handlers on different subunits of the same address. [O. Galibert] 2011-05-31 19:18:48 +00:00
Olivier Galibert
35df369f0f memory: Add a handler copy function which works on subunits-only handlers. [O. Galibert] 2011-05-31 19:18:42 +00:00
Olivier Galibert
a860700bbf memory: Make the proxy manage a list of handlers instead of a unique one. [O. Galibert] 2011-05-31 19:18:36 +00:00
Olivier Galibert
a511ce2d19 memory: Split the map_range function into a fixed entry mapping one and a dynamically allocating entry one. [O. Galibert] 2011-05-31 19:18:29 +00:00
Olivier Galibert
fb374c78fc memory: Tuck the unitmask into the proxy. [O. Galibert] 2011-05-31 19:18:23 +00:00
Olivier Galibert
afe9864d99 memory: Proxy the handler entry access when adding handlers. [O. Galibert] 2011-05-31 19:18:16 +00:00
Olivier Galibert
e5fb48ffdc memory: Combine the map_range and handler_read/write() operations into one. [O. Galibert] 2011-05-31 19:18:10 +00:00
Olivier Galibert
9d7efea985 memory: Add utility methods to clean up colliding subunit masks and testing if any are remaining. [O. Galibert] 2011-05-31 19:18:03 +00:00
Olivier Galibert
b1940a2cca memory: Make the memdump file include a description of every subunit. [O. Galibert] 2011-05-31 19:17:56 +00:00
Olivier Galibert
a8db172be1 memory: Split the subaccesses delegation information per-slot. [O. Galibert] 2011-05-31 19:17:48 +00:00
Olivier Galibert
8e73d99610 memory: Separate delegates for the main access and the subaccesses. [O. Galibert] 2011-05-31 19:17:37 +00:00
Olivier Galibert
587f1db003 memory: Build a structure with all possible delegate sizes [O. Galibert] 2011-05-31 19:17:30 +00:00
Olivier Galibert
617ca7a08a memory: Merge width-conversion functions together from the same source width. [O. Galibert] 2011-05-31 19:17:21 +00:00
Olivier Galibert
7d9f24728b memory: Pass the legacy object/handler as a set_delegate parameter. [O. Galibert] 2011-05-31 19:17:12 +00:00
Olivier Galibert
2740bad7dc memory: Store legacy object and handler together in the same structure. [O. Galibert] 2011-05-31 19:17:03 +00:00