Commit Graph

98 Commits

Author SHA1 Message Date
Miodrag Milanovic
715ac716d5 Autoboot command support added [Ben Geeves,Miodrag Milanovic] 2013-05-06 17:14:13 +00:00
Miodrag Milanovic
0e19f641d3 Cleanups and version bump 2013-01-11 07:32:46 +00:00
Oliver Stöneberg
14a9ce97cd log all unhandled exceptions in running_machine::run() / handle bad_cast exceptions thrown by dynaic_cast - gives proper error in osc1000b and pippin now (nw) 2013-01-01 17:49:06 +00:00
Oliver Stöneberg
aa5701fb9c handle binding_type_exception in running_machine::run() - gives proper error with apollo.c before assert (nw) 2013-01-01 17:18:39 +00:00
Aaron Giles
44e1b32f14 Don't re-register the watchdog VBLANK callback on every single
watchdog reset. That's silly.
2012-10-16 20:42:28 +00:00
Miodrag Milanovic
d690b74571 Fix for describe_context (no whatsnew) 2012-10-04 13:02:06 +00:00
Aaron Giles
621ac620ae Since nobody checks for NULLs anyway, make
device_memory_interface::space() assert against NULL and
return a reference, and pushed references throughout all 
address space usage in the system. Added a has_space() 
method to check for those rare case when it is ambiguous.
[Aaron Giles]

Also reinstated the generic space and added fatal error
handlers if anyone tries to actually read/write from it.
2012-09-19 19:48:09 +00:00
Michaël Banaan Ananas
cd5541a157 make ui_active a user option 2012-08-28 17:20:13 +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
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
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
332011b258 Merged watchdog back into running_machine.
Renamed driver overrides to MCFG_MACHINE/SOUND/VIDEO_START_OVERRIDE to
explicitly indicate they are overriding the default behavior.

Put liberatr back the way it used to be.
2012-04-12 08:33:20 +00:00
Aaron Giles
5181e3ea96 Moved soundlatch helpers into driver.c and removed emu/audio/generic.c.
Normalized soundlatch helper function names.

Created delegates for machine/sound/video_start/reset callbacks and
added necessary infrastructure to use them going forward.
2012-04-09 20:23:26 +00:00
Aaron Giles
7f5529c2cd Templatized the palette generators and made naming consistent.
Moved video/generic flip screen management into the base
driver_device class and updated all callers.
2012-04-09 17:30:29 +00:00
Aaron Giles
3324483130 Extracted driver_device base class from machine.* and into its
own file driver.*
2012-04-06 20:24:04 +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
1b3a299c0d Death to generic spriteram. 2012-03-08 09:54:00 +00:00
Angelo Salese
04145d0b62 Clean-ups and version bump 2012-02-26 14:31:24 +00:00
Aaron Giles
1db879e232 Removed rom_source abstraction, which was just mapping to devices
anyways. Updated everyone involved to just iterate over devices
directly.
2012-02-20 06:06:58 +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
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
051af55fa9 Rewrote tilemap.c as a C++ class. For now kept the global
functions and just inline mapped them to the class. Will do
a pass soon to actually update drivers to use the C++
methods directly. Also, the tilemap callbacks are now
delegates which should make for cleaner integrating into
modern devices and drivers going forward.
2012-01-16 05:08:31 +00:00
Aaron Giles
d57d1f3273 Added new method screen_device::register_screen_bitmap which
allocates a given bitmap to match the screen size and resizes
it as appropriate when the screen size changes. Updated all
the obvious spots in the code where this could be leveraged.

Move allocate/resize methods in the bitmap classes down into
bitmap_t because they no longer have any dependency on the
bitmap format or type.

Ensured that the bitmap's palette remains set across a resize
call (it is lost doing an allocate).
2012-01-15 01:13:13 +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
Aaron Giles
70a40085eb Removed machine.generic.tmpbitmap, VIDEO_START(generic_bitmapped),
and SCREEN_UPDATE(generic_bitmapped). In their place, each screen_device
now maintains a default bitmap which is automatically copied to the
screen on each update if no SCREEN_UPDATE function is provided and if
no driver_device::video_update override is present. This bitmap can be
found by querying the screen's new default_bitmap() method. [Aaron Giles]
2012-01-02 07:37:22 +00:00
Aaron Giles
80cd316a2a Bulk conversion of bitmap_t * to bitmap_t & . With this change the
parameters for the global SCREEN_UPDATE callback match the parameters
for the driver_device version. Added allocate() and deallocate()
methods to bitmap_t to permit cleaner handling of bitmaps in drivers
and modern devices. [Aaron Giles]
2012-01-02 04:59:11 +00:00
Aaron Giles
06da0b9b9f Change 'screen' parameter in SCREEN_UPDATE and SCREEN_EOF callbacks to a
reference. Remove redundant machine parameter from SCREEN_EOF. Remove old 
vestiges of driver_device video_eof override since it wasn't being used.
Update all multi-screen games to use separate functions for each screen 
(calling into common code where appropriate). [Aaron Giles]

(nw: equivalent MESS changes are ready, will send along shortly)
2011-12-29 18:29:06 +00:00
Miodrag Milanovic
6e79bb2629 Sync with MESS all credited there (no whatsnew) 2011-12-12 14:20:12 +00:00
Aaron Giles
c66acff675 Added generic helper read/write members to the driver_device base class.
Updated zodiack/zerozone to use them, removing the trampolines.
2011-11-22 00:57:52 +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
Scott Stone
6742160c25 Fixed some potential memory leaks and NULL pointer deferences as well as removing some redundant checks. [Oliver Stoneberg] 2011-06-15 21:37:25 +00:00
Aaron Giles
bdca1b980a Fix inverted check on anonymous timers prior to saving state. Also
fix bug where we fail to ignore the permanent non-expiring anonymous
timer. Added code to log timers, and we now log them at each save
attempt as well as at restore time. Should fix most recent save state
releated regressions. [Aaron Giles]
2011-06-05 16:01:42 +00:00
Aaron Giles
665d213ee4 (Finally found the time to finish this....)
Low-level input upgrade. Classes now exist for input_codes, input_items,
input_devices, and input_seqs. Also created an input_manager class to
hold machine-global state and made it accessible via machine.input().
Expanded the device index range (0-255, up from 0-16), and the OSD can
now specify the device index explicitly if they can better keep the 
indexes from varying run-to-run. [Aaron Giles]

Note that I've built and run SDL on Windows, but not all the code paths
were exercised. If you use mice/joysticks extensively double-check them
to be sure it all still works as expected.

This is mainly an OSD and core change. The only thing impacting drivers
is if they query for specific keys for debugging. The following S&Rs
took care of most of that:

S: input_code_pressed( *)\(( *)([^, ]+) *, *
R: \3\.input\(\)\.code_pressed\1\(\2

S: input_code_pressed_once( *)\(( *)([^, ]+) *, *
R: \3\.input\(\)\.code_pressed_once\1\(\2
2011-05-30 19:07:19 +00:00
Aaron Giles
d5af6b6a9b Switch input ports to use function-based constructors instead of tokens.
Remove the old tokenizing helpers. Add basic classes for ports, fields,
settings, and dip locations as a first step. These will be fully cleaned
up later. Added machine() method to field to hide all the necessary
indirection. Changed custom/changed handlers into generic read/write
handlers, and added wrappers to convert them to device read/write
lines. [Aaron Giles]
2011-05-10 22:20:27 +00:00
Angelo Salese
7878118446 Cleanups and version bump 2011-05-08 19:52:50 +00:00
Aaron Giles
ff1db593b7 Attach gamedrv's input ports to the driver_device, so that there's
no longer anything special about how they are processed. Removed
logic that handled the game inputs as a special case.
2011-05-05 07:02:28 +00:00
Aaron Giles
580b29ee33 Fix indeterminate order of calls. 2011-04-30 20:21:00 +00:00
Miodrag Milanovic
d4eaf26045 Fix adding dynamic device fixing coco and ti99_4 (no whatsnew) 2011-04-30 18:51:40 +00:00
Aaron Giles
af94c692bb Switch to using delegates for some callbacks:
- non-device timer callbacks
 - machine state changing callbacks
 - configuration callbacks
 - per-screen VBLANK callbacks
 - DRC backend callbacks

For the timer case only, I added wrappers for the old-style functions.
Over time, drivers should switch to device timers instead, reducing the
number of timers that are directly allocated through the scheduler.
2011-04-27 20:34:45 +00:00
Aaron Giles
919913f118 Collapsed device_config and device_t into one class. Updated all
existing modern devices and the legacy wrappers to work in this
environment. This in general greatly simplifies writing a modern
device. [Aaron Giles]

General notes:
 * some more cleanup probably needs to happen behind this change,
   but I needed to get it in before the next device modernization 
   or import from MESS  :)

 * new template function device_creator which automatically defines
   the static function that creates the device; use this instead of
   creating a static_alloc_device_config function

 * added device_stop() method which is called at around the time
   the previous device_t's destructor was called; if you auto_free
   anything, do it here because the machine is gone when the 
   destructor is called

 * changed the static_set_* calls to pass a device_t & instead of
   a device_config *

 * for many devices, the static config structure member names over-
   lapped the device's names for devcb_* functions; in these cases
   the members in the interface were renamed to have a _cb suffix

 * changed the driver_enumerator to only cache 100 machine_configs
   because caching them all took a ton of memory; fortunately this
   implementation detail is completely hidden behind the 
   driver_enumerator interface

 * got rid of the macros for creating derived classes; doing it
   manually is now clean enough that it isn't worth hiding the
   details in a macro
2011-04-27 05:11:18 +00:00
Aaron Giles
543fa08fd0 Rename state_manager -> save_manager since the term "state" is overloaded. 2011-04-20 15:14:54 +00:00
Aaron Giles
fecfc465df Switch from m_machine to machine() everywhere. In some cases this
meant adding a machine() accessor but it's worth it for consistency.
This will allow future changes from reference to pointer to happen
transparently for devices. [Aaron Giles]

Simple S&R:
m_machine( *[^ (!=;])
machine()\1
2011-04-18 20:06:43 +00:00
Angelo Salese
486fbfa555 Cleanups again 2011-04-18 00:06:50 +00:00
Aaron Giles
00d745ca77 (Big tangle of changes that all happened as I was looking into the ROM
loader rewrite, which is still in progress....)

Replaced mamedriv.c with a new driver list mechanism that is generated
by the build tools. The emulator core now expects the presence of a
file called src/$(TARGET)/$(SUBTARGET).lst which is just a raw list of
driver names, one per line. C and C++ comments are still permitted.
This file is parsed by a new build tool makelist which extracts the
driver names, sorts them, and generates a file called drivlist.c, which
is consumed by the core. [Aaron Giles]

Added new osdcore function osd_malloc_array() which is identical to
osd_malloc() but obviously hints that the underlying allocation is for
an array. Updated all callers to use the appropriate form. Modified the
Windows allocator to only use guard pages for array-style allocations,
allowing us to enable them once again in debug builds. [Aaron Giles]

Created new static class driver_list to wrap accesses to the list of
available drivers. Improved speed of driver lookups by relying on the
presorting done by makelist. [Aaron Giles]

Created helper class driver_enumerator as a helper for iterating through 
the list of drivers. This class supports basic filtering and iteration,
and also serves as a temporary cache of machine_configs. [Aaron Giles]

Created cli_frontend object to wrap all the CLI handling code in
clifront.c. Updated/simplified all the code to take advantage of the
driver_enumerator. [Aaron Giles]

Created media_auditor object to wrap all the auditing functions in
audit.c. Updated all users to the new interface. Note that the new
auditing mechanism is slightly out of sync with the romload code in
terms of finding ROMs owned by devices, so it may mis-report some
issues until the new ROM loading code is in. [Aaron Giles]

Added concept of a per-device searchpath. For most devices, their 
searchpath is just the short name of the device. For driver_devices, the
searchpath is driver[;parent[;bios]]. This searchpath will eventually be
used by the rom loader to find ROMs. For now it is used by the media
auditor only. [Aaron Giles]

Created info_xml_creator object to wrap all the info generation functions
in info.c. Converted the file to C++ and cleaned up the input processing
code. [Aaron Giles]

(not for whatsnew ... Known issues: auditing of CHDs appears busted, and 
debug builds report unfreed memory if you use the built-in game picker)
2011-04-13 20:31:00 +00:00
Aaron Giles
68958f72db Cleanups and version bump. 2011-04-03 05:49:24 +00:00
Aaron Giles
28fdb61512 Move overridable device->rom_region(), device->machine_config_additions(), and
device->input_ports() to protected methods. Added non-virtual wrappers around
them.
2011-03-30 06:27:49 +00:00