Commit Graph

33 Commits

Author SHA1 Message Date
Miodrag Milanovic
160bff7d79 In cases of debug optimized build tools return error on this, code however looks good but still there is special case with warning (nw) 2012-05-21 12:39:15 +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
Miodrag Milanovic
8dbb34e79e Made UI for BIOS selection where applicable, and moved info about current
system and default bios to device_t class (no whatsnew)
2012-04-30 13:39:32 +00:00
Angelo Salese
ded30e907e Clean-ups and version bump 2012-04-22 14:10:44 +00:00
Miodrag Milanovic
c0a5c0be4b Fix for older GCC, thanks to Robbbert (no whatsnew) 2012-04-22 09:28:27 +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
06fe858cf1 More fixes and a gcc warning fix. 2012-04-15 23:48:57 +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
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
96a29fba76 Clang fixes. 2012-04-09 03:43:48 +00:00
Angelo Salese
35e09dd41c Clean-ups and version bump 2012-04-08 14:12:02 +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
Angelo Salese
d2c052dbef Clean-ups and version bump (yes, I know, it's too late) 2012-03-11 17:17:00 +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
smf-
12656a2051 remove set_current, in case someone decides to use them again. 2012-02-01 00:45:55 +00:00
Angelo Salese
505442d0a0 Clean-ups and version bump 2012-01-29 16:34:26 +00:00
Aaron Giles
643793cce6 siblingdevice now checks for and removes a leading "^" to
indicate the owner. This allows "^" to be used to reference
the owning device in device callbacks, among other things.
2012-01-27 07:21:20 +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
e325b867ec More cleanup, and fixed bad bug from last update. 2012-01-13 23:02:46 +00:00
Aaron Giles
570b33a853 Some cleanup of the previous change. Added new template
device_delegate which wraps a regular delegate and includes
a string pointer to a device tag, which can be simply
resolved later. Converted the screen_update delegates to
to be based on this. Changed the mechanism by which screen
formats are auto-deduced. Converted SCREEN_EOF to use these
delegates as well, so now there is MCFG_SCREEN_EOF_STATIC/
DRIVER/DEVICE just like MCFG_SCREEN_UPDATE.
2012-01-13 22:06:59 +00:00
Aaron Giles
e4238fb654 Major bitmap-related changes throughout the system. There are
almost certainly some regressions lurking. Let me know if
something seems busted.

Bitmaps are now strongly typed based on format. bitmap_t still
exists as an abstract base class, but it is almost never used.
Instead, format-specific bitmap classes are provided:

   bitmap_ind8 == 8bpp indexed
   bitmap_ind16 == 16bpp indexed
   bitmap_ind32 == 32bpp indexed
   bitmap_ind64 == 64bpp indexed
   bitmap_rgb32 == 32bpp RGB
   bitmap_argb32 == 32bpp ARGB
   bitmap_yuy16 == 16bpp YUY

For each format, a generic pix() method is provided which
references pixels of the correct type. The old pix8/pix16/pix32/
pix64 methods still exist in the short term, but the only one
available is the one that matches the bitmap's pixel size. Note
also that the old RGB15 format bitmaps are no longer supported
at all.

Converted model1, megadriv, and stv drivers away from the RGB15
format bitmaps.

New auto_bitmap_<type>_alloc() macros are provided for allocating
the appropriate type of bitmap.

Screen update functions now must specify the correct bitmap type
as their input parameters. For static update functions the
SCREEN_UPDATE macro is now replaced with SCREEN_UPDATE_RGB32 and
SCREEN_UPDATE_IND16 macros. All existing drivers have been 
updated to use the correct macros. 

Screen update functions are now required for all screens; there
is no longer any default behavior of copying a "default" bitmap
to the screen (in fact the default bitmap has been deprecated).
Use one of the following to specify your screen_update callback:

   MCFG_SCREEN_UPDATE_STATIC(name) - static functions
   MCFG_SCREEN_UPDATE_DRIVER(class, func) - driver members
   MCFG_SCREEN_UPDATE_DEVICE(tag, class, func) - device members

Because the target bitmap format can now be deduced from the
screen update function itself, the MCFG_SCREEN_FORMAT macro is
no longer necessary, and has been removed. If you specify a
screen update callback that takes a bitmap_ind16, then the screen
will be configured to use a 16bpp indexed bitmap, and if you
specify a callback that takes a bitmap_rgb32, then a 32bpp RGB
bitmap will be provided.

Extended the bitmap classes to support wrapping a subregion of
another bitmap, and cleaner allocation/resetting. The preferred
use of bitmaps now is to define them directly in drivers/devices
and use allocate() or wrap() to set them up, rather than 
allocating them via auto_bitmap_*_alloc().

Several common devices needed overhauls or changes as a result
of the above changes:

 * Reorganized the laserdisc base driver and all the laserdisc 
    drivers as modern C++ devices, cleaning the code up 
    considerably. Merged ldsound device into the laserdsc
    device since modern devices are flexible enough to handle
    it.

 * Reorganized the v9938 device as a modern C++ device. Removed
    v9938mod.c in favor of template functions in v9938.c directly.

 * Added independent ind16 and rgb32 callbacks for TMS340x0 devices.

 * All video devices are now hard-coded to either ind16 or rgb32
    bitmaps. The most notable is the mc6845 which is rgb32, and
    required changes to a number of consumers.

 * Added screen_update methods to most video devices so they can be
    directly called via MCFG_SCREEN_UPDATE_DEVICE instead of creating
    tons of stub functions.
2012-01-12 21:19:49 +00:00
Nathan Woods
cdd0600db4 Added hot/cold attributes. Made the MAME executable 1% smaller by using the
cold attribute on setup functions
2011-11-06 11:06:58 +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