Commit Graph

18 Commits

Author SHA1 Message Date
Aaron Giles
feb6e77be3 As promised, the bulk update of timer calls:
timer_adjust_oneshot(t,...)  => t->adjust(...)
timer_adjust_periodic(t,...) => t->adjust(...)
timer_reset(t,...)           => t->reset(...)
timer_enable(t,...)          => t->enable(...)
timer_enabled(t)             => t->enabled()
timer_get_param(t)           => t->param()
timer_get_ptr(t)             => t->ptr()
timer_set_param(t,...)       => t->set_param(...)
timer_set_ptr(t)             => t->set_ptr(...)
timer_timeelapsed(t)         => t->elapsed()
timer_timeleft(t)            => t->remaining()
timer_starttime(t)           => t->start()
timer_firetime(t)            => t->expire()

Also remove some stray legacy cpuexec* macros that were 
lurking in schedule.h):

cpuexec_describe_context(m)     => m->describe_context()
cpuexec_boost_interleave(m,...) => m->scheduler().boot_interleave(...)
cpuexec_trigger(m,...)          => m->scheduler().trigger(...)
cpuexec_triggertime(m,...)      => m->scheduler().trigger(...)

Specific regex'es used:

timer_adjust_oneshot( *)\(( *)([^,;]+), *
\3->adjust\1\(\2

timer_adjust_periodic( *)\(( *)([^,;]+), *
\3->adjust\1\(\2

(->adjust.*), *0( *)\)
\1\2\)

timer_reset( *)\(( *)([^,;]+), *
\3->reset\1\(\2

(->reset *\(.*)attotime::never
\1

timer_enable( *)\(( *)([^,;]+), *
\3->enable\1\(\2

timer_enabled( *)\(( *)([^,;)]+)\)
\3->enabled\1\(\2\)

timer_get_param( *)\(( *)([^,;)]+)\)
\3->param\1\(\2\)

timer_get_ptr( *)\(( *)([^,;)]+)\)
\3->ptr\1\(\2\)

timer_timeelapsed( *)\(( *)([^,;)]+)\)
\3->elapsed\1\(\2\)

timer_timeleft( *)\(( *)([^,;)]+)\)
\3->remaining\1\(\2\)

timer_starttime( *)\(( *)([^,;)]+)\)
\3->start\1\(\2\)

timer_firetime( *)\(( *)([^,;)]+)\)
\3->expire\1\(\2\)

timer_set_param( *)\(( *)([^,;]+), *
\3->set_param\1\(\2

timer_set_ptr( *)\(( *)([^,;]+), *
\3->set_ptr\1\(\2

cpuexec_describe_context( *)\(( *)([^,;)]+)\)
\3->describe_context\1\(\2\)

\&m_machine->describe_context
m_machine.describe_context

cpuexec_boost_interleave( *)\(( *)([^,;]+), *
\3->scheduler().boost_interleave\1\(\2

cpuexec_trigger( *)\(( *)([^,;]+), *
\3->scheduler().trigger\1\(\2

cpuexec_triggertime( *)\(( *)([^,;]+), *
\3->scheduler().trigger\1\(\2
2011-02-06 21:23:00 +00:00
Aaron Giles
0e627f1a54 Convert emu_timers to objects. Move implementation and management of
timers into the scheduler. Retain TIMER devices as a separate wrapper
in timer.c/.h. Inline wrappers are currently provided for all timer
operations; a future update will bulk clean these up.

Rather than using macros which hide generation of a string-ified name
for callback functions, the new methods require passing both a function
pointer plus a name string. A new macro FUNC() can be used to output
both, and another macro MFUNC() can be used to output a stub-wrapped
class member as a callback.

Also added a time() method on the machine, so that machine->time() gives
the current emulated time. A wrapper for timer_get_time is currently
provided but will be bulk replaced in the future.

For this update, convert all classic timer_alloc, timer_set, 
timer_pulse, and timer_call_after_resynch calls into method calls on 
the scheduler. 

For new device timers, added methods to the device_t class that make 
creating and managing these much simpler. Modern devices were updated
to use these.

Here are the regexes used; some manual cleanup (compiler-caught) will
be needed since regex doesn't handle nested parentheses cleanly

1. Convert timer_call_after_resynch calls
timer_call_after_resynch( *)\(( *)([^,;]+), *([^,;]+), *([^,;]+), *([^);]+)\)
\3->scheduler().synchronize\1\(\2FUNC(\6), \5, \4\)

2. Clean up trailing 0, NULL parameters
(synchronize[^;]+), 0, NULL\)
\1)

3. Clean up trailing NULL parameters
(synchronize[^;]+), NULL\)
\1)

4. Clean up completely empty parameter lists
synchronize\(FUNC\(NULL\)\)
synchronize()

5. Convert timer_set calls
timer_set( *)\(( *)([^,;]+), *([^,;]+), *([^,;]+), *([^,;]+), *([^);]+)\)
\3->scheduler().timer_set\1\(\2\4, FUNC(\7), \6, \5\)

6. Clean up trailing 0, NULL parameters
(timer_set[^;]+), 0, NULL\)
\1)

7. Clean up trailing NULL parameters
(timer_set[^;]+), NULL\)
\1)

8. Convert timer_set calls
timer_pulse( *)\(( *)([^,;]+), *([^,;]+), *([^,;]+), *([^,;]+), *([^);]+)\)
\3->scheduler().timer_pulse\1\(\2\4, FUNC(\7), \6, \5\)

9. Clean up trailing 0, NULL parameters
(timer_pulse[^;]+), 0, NULL\)
\1)

10. Clean up trailing NULL parameters
(timer_pulse[^;]+), NULL\)
\1)

11. Convert timer_alloc calls
timer_alloc( *)\(( *)([^,;]+), *([^,;]+), *([^);]+)\)
\3->scheduler().timer_alloc\1\(\2FUNC(\4), \5\)

12. Clean up trailing NULL parameters
(timer_alloc[^;]+), NULL\)
\1)

13. Clean up trailing 0 parameters
(timer_alloc[^;]+), 0\)
\1)

14. Fix oddities introduced
\&m_machine->scheduler()
m_machine.scheduler()
2011-02-06 07:15:01 +00:00
Aaron Giles
f534d245c0 Attotime bulk conversion step:
attotime_zero                 => attotime::zero
attotime_never                => attotime::never
ATTOTIME_IN_SEC(s)            => attotime::from_seconds(s)
ATTOTIME_IN_MSEC(m)           => attotime::from_msec(m)
ATTOTIME_IN_USEC(u)           => attotime::from_usec(u)
ATTOTIME_IN_NSEC(n)           => attotime::from_nsec(n)
ATTOTIME_IN_HZ(h)             => attotime::from_hz(h)

Also, changed the following MCFG macros to require a full
attotime specification:

MCFG_TIMER_ADD_PERIODIC
MCFG_QUANTUM_TIME
MCFG_WATCHDOG_TIME_INIT
2011-02-03 09:06:34 +00:00
Wilbert Pol
c8d7056b48 z80dart.c:
- The channel B modified interrupt vector can be read immediately after setting it.
- Reading from a read register other than 0 also masks out the register index.  [Wilbert Pol]
2010-12-26 08:19:09 +00:00
Curt Coder
638d008bc6 Z80DART changes: [Curt Coder]
- fixed asynchronous transmit mode
- fixed channel A interrupt vector
- improved logging
2010-12-21 20:56:55 +00:00
Aaron Giles
499a0d4161 Move device definitions out of the bottom of the file. They can be
declared with other variables at the top.
2010-09-19 20:57:20 +00:00
Aaron Giles
0e672ba6eb Cleanups and version bump. 2010-08-30 15:20:58 +00:00
Curt Coder
dff1e360a9 Z80DART changes: [Curt Coder]
- added SIO specific constants
- added sync character write registers
2010-08-22 15:29:52 +00:00
Curt Coder
6791eb9adb Expanded the Z80-DART interface to allow future implementation of Z80-SIO features: [Curt Coder]
- added separate clock inputs for channel B
- added SYNC inputs/outputs for both channels
2010-08-21 00:03:37 +00:00
Curt Coder
b5fabb049d Clear Z80 DART interrupts at constructor time. [Curt Coder] 2010-08-20 16:15:41 +00:00
Aaron Giles
30662dcdef Cleanups and version bump. 2010-07-06 17:30:28 +00:00
Miodrag Milanovic
63e8e8fe98 Modified way device_type constants are defined in order to get unidasm compile [Miodrag Milanovic] 2010-06-29 09:02:17 +00:00
Miodrag Milanovic
4849299a0d Fixed regression in z80dart device (no whatsnew) 2010-06-28 08:19:58 +00:00
Aaron Giles
50767de707 Changed device name from an overridable function to a parameter passed to
the device_config constructor. In situations where the proper name is not 
known at construction time, a generic name can be specified and then 
overridden later once the configuration is complete.
2010-06-25 15:30:51 +00:00
Aaron Giles
861db1eb49 Cleanups and version bump. 2010-06-17 06:55:54 +00:00
Aaron Giles
100564d412 WARNING: There are likely to be regressions in both functionality and
performance as a result of this change. Do not panic; report issues to the
list in the short term and I will look into them. There are probably also
some details I forgot to mention. Please ask questions if anything is not
clear.

NOTE: This is a major internal change to the way devices are handled in
MAME. There is a small impact on drivers, but the bulk of the changes are
to the devices themselves. Full documentation on the new device handling
is in progress at http://mamedev.org/devwiki/index.php/MAME_Device_Basics

Defined two new casting helpers: [Aaron Giles]

  downcast<type>(value) should be used for safe and efficient downcasting
  from a base class to a derived class. It wraps static_cast<> by adding
  an assert that a matching dynamic_cast<> returns the same result in 
  debug builds.
  
  crosscast<type>(value) should be used for safe casting from one type to
  another in multiple inheritance scenarios. It compiles to a 
  dynamic_cast<> plus an assert on the result. Since it does not optimize
  down to static_cast<>, you should prefer downcast<> over crosscast<>
  when you can.
  
Redefined running_device to be a proper C++ class (now called device_t).
Same for device_config (still called device_config). All devices and
device_configs must now be derived from these base classes. This means
each device type now has a pair of its own unique classes that describe
the device. Drivers are encouraged to use the specific device types
instead of the generic running_device or device_t classes. Drivers that
have a state class defined in their header file are encouraged to use
initializers off the constructor to locate devices. [Aaron Giles]

Removed the following fields from the device and device configuration
classes as they never were necessary or provided any use: device class,
device family, source file, version, credits. [Aaron Giles]

Added templatized variant of machine->device() which performs a downcast
as part of the device fetch. Thus machine->device<timer_device>("timer")
will locate a device named "timer", downcast it to a timer_device, and
assert if the downcast fails. [Aaron Giles]

Removed most publically accessible members of running_device/device_t in
favor of inline accessor functions. The only remaining public member is
machine. Thus all references to device->type are now device->type(), etc.
[Aaron Giles]

Created a number of device interface classes which are designed to be mix-
ins for the device classes, providing specific extended functionality and
information. There are standard interface classes for sound, execution,
state, nvram, memory, and disassembly. Devices can opt into 0 or more of
these classes. [Aaron Giles]

Converted the classic CPU device to a standard device that uses the
execution, state, memory, and disassembly interfaces. Used this new class
(cpu_device) to implement the existing CPU device interface. In the future
it will be possible to convert each CPU core to its own device type, but 
for now they are still all CPU devices with a cpu_type() that specifies
exactly which kind of CPU. [Aaron Giles] 

Created a new header devlegcy.h which wraps the old device interface using
some special template classes. To use these with an existing device,
simply remove from the device header the DEVICE_GET_INFO() declaration and
the #define mapping the ALL_CAPS name to the DEVICE_GET_INFO. In their
place #include "devlegcy.h" and use the DECLARE_LEGACY_DEVICE() macro.
In addition, there is a DECLARE_LEGACY_SOUND_DEVICE() macro for wrapping
existing sound devices into new-style devices, and a 
DECLARE_LEGACY_NVRAM_DEVICE() for wrapping NVRAM devices. Also moved the
token and inline_config members to the legacy device class, as these are
not used in modern devices. [Aaron Giles]

Converted the standard base devices (VIDEO_SCREEN, SPEAKER, and TIMER) 
from legacy devices to the new C++ style. Also renamed VIDEO_SCREEN to
simply SCREEN. The various global functions that were previously used to
access information or modify the state of these devices are now replaced
by methods on the device classes. Specifically:

  video_screen_configure()             == screen->configure()
  video_screen_set_visarea()           == screen->set_visible_area()
  video_screen_update_partial()        == screen->update_partial()
  video_screen_update_now()            == screen->update_now()
  video_screen_get_vpos()              == screen->vpos()
  video_screen_get_hpos()              == screen->hpos()
  video_screen_get_vblank()            == screen->vblank()
  video_screen_get_hblank()            == screen->hblank()
  video_screen_get_width()             == screen->width()
  video_screen_get_height()            == screen->height()
  video_screen_get_visible_area()      == screen->visible_area()
  video_screen_get_time_until_pos()    == screen->time_until_pos()
  video_screen_get_time_until_vblank_start() == 
                                 screen->time_until_vblank_start()
  video_screen_get_time_until_vblank_end() == 
                                 screen->time_until_vblank_end()
  video_screen_get_time_until_update() == screen->time_until_update()
  video_screen_get_scan_period()       == screen->scan_period()
  video_screen_get_frame_period()      == screen->frame_period()
  video_screen_get_frame_number()      == screen->frame_number()

  timer_device_adjust_oneshot()        == timer->adjust()
  timer_device_adjust_periodic()       == timer->adjust()
  timer_device_reset()                 == timer->reset()
  timer_device_enable()                == timer->enable()
  timer_device_enabled()               == timer->enabled()
  timer_device_get_param()             == timer->param()
  timer_device_set_param()             == timer->set_param()
  timer_device_get_ptr()               == timer->get_ptr()
  timer_device_set_ptr()               == timer->set_ptr()
  timer_device_timeelapsed()           == timer->time_elapsed()
  timer_device_timeleft()              == timer->time_left()
  timer_device_starttime()             == timer->start_time()
  timer_device_firetime()              == timer->fire_time()

Updated all drivers that use the above functions to fetch the specific
device type (timer_device or screen_device) and call the appropriate
method. [Aaron Giles]

Changed machine->primary_screen and the 'screen' parameter to VIDEO_UPDATE
to specifically pass in a screen_device object. [Aaron Giles]

Defined a new custom interface for the Z80 daisy chain. This interface
behaves like the standard interfaces, and can be added to any device that
implements the Z80 daisy chain behavior. Converted all existing Z80 daisy
chain devices to new-style devices that inherit this interface.
[Aaron Giles]

Changed the way CPU state tables are built up. Previously, these were data
structures defined by a CPU core which described all the registers and how
to output them. This functionality is now part of the state interface and
is implemented via the device_state_entry class. Updated all CPU cores
which were using the old data structure to use the new form. The syntax is
currently awkward, but will be cleaner for CPUs that are native new 
devices. [Aaron Giles]

Converted the okim6295 and eeprom devices to the new model. These were
necessary because they both require multiple interfaces to operate and it
didn't make sense to create legacy device templates for these single cases.
(okim6295 needs the sound interface and the memory interface, while eeprom
requires both the nvram and memory interfaces). [Aaron Giles]

Changed parameters in a few callback functions from pointers to references
in situations where they are guaranteed to never be NULL. [Aaron Giles]

Removed MDRV_CPU_FLAGS() which was only used for disabling a CPU. Changed
it to MDRV_DEVICE_DISABLE() instead. Updated drivers. [Aaron Giles]

Reorganized the token parsing for machine configurations. The core parsing
code knows how to create/replace/remove devices, but all device token
parsing is now handled in the device_config class, which in turn will make
use of any interface classes or device-specific token handling for custom
token processing. [Aaron Giles]

Moved many validity checks out of validity.c and into the device interface
classes. For example, address space validation is now part of the memory
interface class. [Aaron Giles]

Consolidated address space parameters (bus width, endianness, etc.) into
a single address_space_config class. Updated all code that queried for
address space parameters to use the new mechanism. [Aaron Giles]
2010-06-08 06:09:57 +00:00
Aaron Giles
ec586731b9 Made device->tag and devconfig->tag into private member variables (m_tag).
Added inline tag() function to return a const char * version. Updated
callers to use this instead of directly accessing tag.cstr() which
was awkward.
2010-03-08 17:06:27 +00:00
Curt Coder
5826c45ea4 Imported Z80 DART and Z80 STI from MESS. (no whatsnew) 2010-03-08 16:47:53 +00:00