Commit Graph

104 Commits

Author SHA1 Message Date
Couriersud
02cd248fef More cleanups for the discrete subsystem. No whatsnew. 2011-01-16 00:38:44 +00:00
Couriersud
156a1efd1c Discrete subsystem: Maintenance commit before I move from linked lists to dynamic arrays.
- Also fixes bzone regression.
- Contexts have disappeared now. All modules use class level private variables now.
- Reorganized code and added more include files.
- This is still work in progress. It is working though.
2011-01-15 13:49:27 +00:00
Couriersud
f420c226a4 Discrete sound system:
- all nodes are now class based
- removed all support for "legacy", i.e. procedural node functions.
- nodes are created using a class factory whose instances
  are set up in discrete blocks. There is no separation of
  node vs. module any longer.
- Custom modules are now just implemented like "normal" nodes.
- Converted all custom modules.
- Context variables can now be migrated to be private class members.
[Couriersud]
2011-01-11 00:21:43 +00:00
Couriersud
8ac0ed99d1 Discrete: some (temporary) visibility changes. Pass device to task class. No whatsnew. 2011-01-09 20:03:43 +00:00
Aaron Giles
08d14a29e8 MSVC compatibility. 2011-01-07 05:19:45 +00:00
Couriersud
ce7db8c6e5 Discrete: Most nodes now have a proper class, however this class just falls back to discrete_legacy_node. Put some more macro magic into discrete.c. The next (big) step is to move step and reset functions from "C" to "C++" member functions.
Afterwards we can start to migrate the contexts into private variables.
2011-01-06 02:34:29 +00:00
Couriersud
97ade28735 Discrete: Added a class node factory. Currently only creates discrete_legacy_nodes which is just a wrapper around pure "C" discrete implementations. No whatsnew. 2011-01-06 01:05:59 +00:00
Couriersud
dbb0cc1377 Bye discrete_info. Another round of discrete rewrites. No whatsnew. 2011-01-05 21:37:53 +00:00
Couriersud
bf5874a23b Converted discrete subsystem into "new-style" device. Still quite some work to do to remove legacy design, but working. No whatsnew. 2011-01-05 02:16:29 +00:00
Couriersud
5235212dc6 Start moving the discrete subsystem towards C++. Changed some structs to classes and most of the list processing now uses a linked list template which is type-safe. [Couriersud] 2011-01-04 23:03:45 +00:00
Aaron Giles
3b41606ca0 running_device -> device_t
They both already existed. No sense in having two names for the
same object type.
2010-12-31 21:42:55 +00:00
Derrick Renaud
c956d18f78 Atari Cops'n Robbers Updates [Derrick Renaud]
Converted controls to Positional type.
Started Discrete sounds. (Motor 2 & 3, Crash sounds implemented)

Optimized speed of DISCRETE_DAC_R1 [Derrick Renaud]
2010-11-01 03:31:24 +00:00
Derrick Renaud
13c39be494 Discrete Updates [Derrick Renaud]
Removed old DISCRETE_74LS624 code and replaced it with new 74LS629 based code.
Updated Mario to use new DISCRETE_74LS624 and DISCRETE_XTIME_logic modules.

----
Some not whats.new stuff:
I also fixed the regression to Galaxian.
I made a DISCRETE_DECLARE_CONTEXT() macro to clean up the discrete module code and make it easier for any future possible C++ conversion.
2010-10-27 02:09:13 +00:00
Derrick Renaud
03666c53d2 Discrete Sound - Added DISCRETE_XTIME_xxx logic modules. These allow you to do logic operations on nodes that use x_time anti-alias info. Added the ability to decode x_time to the DISCRETE_BIT_DECODE module. This means you can have an oscillator pass x_time onto a counter, get the counter bits decoded, pass that through the new logic modules and also have them convert the x_time to energy/anti-alaised voltage. Updated Donkey Kong Jr. to use these new modules. [Derrick Renaud] 2010-10-22 04:07:05 +00:00
R. Belmont
53b25817d0 MAMEdev kant spel (Ubuntu/Canonical cares about this) [wallyweek] 2010-07-08 14:10:23 +00:00
Aaron Giles
10f5966ea5 Split implementation for legacy devices into a separate macro. Updated all
devices to use this macro in their .c file. This greatly reduces the amount
of work the linker has to do to combine all the instances, and reduces the
final binary size when building with symbols. Unfortunately, in order to do
it I had to switch back to macros from templates, but I can live with that
for legacy devices.
2010-06-11 20:37:50 +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
Aaron Giles
e738b79785 Correct a long-standing design flaw: device configuration state
is now separate from runtime device state. I have larger plans
for devices, so there is some temporary scaffolding to hold
everything together, but this first step does separate things
out.

There is a new class 'running_device' which represents the
state of a live device. A list of these running_devices sits
in machine->devicelist and is created when a running_machine
is instantiated.

To access the configuration state, use device->baseconfig()
which returns a reference to the configuration.

The list of running_devices in machine->devicelist has a 1:1
correspondance with the list of device configurations in
machine->config->devicelist, and most navigation options work
equally on either (scanning by class, type, etc.)

For the most part, drivers will now deal with running_device
objects instead of const device_config objects. In fact, in
order to do this patch, I did the following global search &
replace:

  const device_config -> running_device
  device->static_config -> device->baseconfig().static_config
  device->inline_config -> device->baseconfig().inline_config

and then fixed up the compiler errors that fell out.

Some specifics:

  Removed device_get_info_* functions and replaced them with
  methods called get_config_*.
  
  Added methods for get_runtime_* to access runtime state from
  the running_device.
  
  DEVICE_GET_INFO callbacks are only passed a device_config *.
  This means they have no access to the token or runtime state
  at all. For most cases this is fine.
  
  Added new DEVICE_GET_RUNTIME_INFO callback that is passed
  the running_device for accessing data that is live at runtime.
  In the future this will go away to make room for a cleaner
  mechanism.
  
  Cleaned up the handoff of memory regions from the memory
  subsystem to the devices.
2010-01-18 09:34:43 +00:00
Aaron Giles
4498faacd9 First round of an attempted cleanup of header files in the system.
- Created new central header "emu.h"; this should be included
    by pretty much any driver or device as the first include. This
    file in turn includes pretty much everything a driver or device
    will need, minus any other devices it references. Note that
    emu.h should *never* be included by another header file.
 - Updated all files in the core (src/emu) to use emu.h.
 - Removed a ton of redundant and poorly-tracked header includes
    from within other header files.
 - Temporarily changed driver.h to map to emu.h until we update
    files outside of the core.

Added class wrapper around tagmap so it can be directly included
and accessed within objects that need it. Updated all users to
embed tagmap objects and changed them to call through the class.

Added nicer functions for finding devices, ports, and regions in
a machine:

   machine->device("tag") -- return the named device, or NULL
   machine->port("tag") -- return the named port, or NULL
   machine->region("tag"[, &length[, &flags]]) -- return the
      named region and optionally its length and flags
      
Made the device tag an astring. This required touching a lot of 
code that printed the device to explicitly fetch the C-string
from it. (Thank you gcc for flagging that issue!)
2010-01-10 00:29:26 +00:00
Aaron Giles
bd24fb23c1 Results of running the latest srcclean. 2009-12-28 09:04:00 +00:00
Derrick Renaud
c79245f95c DISCRETE_RC_CIRCUIT_1 - promoted skyraid custom charge to it's own module so it could be used with the same circuit in Battlezone.
Battlezone - updated to use new module.  Adjusted sound levels.  Adjusted engine frequency.  Remember there is a slider to adjust the frequency.

Donkey Kong Jr. - set noise clock to a fixed measured frequency.  (Speed optimization)
2009-10-21 04:34:00 +00:00
Derrick Renaud
b3d22182a0 Mario - added proper mixer to final output. This adds the missing filtering on the walking sounds.
This following is not worth mentioning yet.
Started the new 74LS624 code.  Called it DISCRETE_74LS629 for now, until it is ready to replace the old code.  You can enable it in dkongjr and mario using the USE_LS629 define.

I still need to work out the threshold/range relationship.  I'm having the old schrodinger's cat problem.  I need to measure the cap threshold, but doing so changes it.  I'll work it out.
2009-10-19 04:21:41 +00:00
Couriersud
a4054be2b3 - OSD_PROFILING is now an environment variable. No more recompiling to turn profiling on
- Added two asserts to task processing
2009-10-12 10:17:23 +00:00
Aaron Giles
2d22e450f2 Cleanups and version bump. 2009-10-12 08:45:25 +00:00
Couriersud
d05969d5fc Fix bug introduced with profiling changes 2009-10-09 23:07:56 +00:00
Couriersud
15534ae68b Better task processing
- tasks are now processed according to their dependency lists. Tasks
  can now start early and will only process samples which are 
  already available. This has most impact on drivers which have
  significant variance in the run-time of individual tasks.
- tasks now process samples in slices, currently max 240 samples / slice. 
- TASK_GROUP is now obsolete - Will update drivers at a later stage.
- step function pointer now back in node, modules may register 
  optimized step functions.
- profiling code now always compiled, introduced static int profiling = ... 
- some more EXPECTED/UNEXPECTED usage.
2009-10-09 22:57:56 +00:00
Derrick Renaud
1a8a712eed DISCRETE_CRFILTER, DISCRETE_RCFILTER
- revert vref change from rev 6979.
 - added capability for all values to be nodes.

Starship 1 - fixed motor sounds.
2009-10-06 00:45:35 +00:00
Couriersud
1a263d82f2 Discrete update
- fix some "const" weirdness I introduced
- fix VREF in CRFILTER_VREF and RCFILTER_VREF. VREF never got used since it was only a static parameter.
- Removed enable from CR_FILTER* and RC_FILTER*
- Updated drivers accordingly.
- Use EXPECTED/UNEXPECTED to help the compiler
2009-10-05 22:01:48 +00:00
Derrick Renaud
35323e6162 Fixed compile warning. 2009-10-04 22:15:59 +00:00
Aaron Giles
aff6be5877 Cleanups and version bump. 2009-10-04 05:08:50 +00:00
Couriersud
de55177d94 Discrete task groups
- DISCRETE_TASK_START now requires a parameter TASK_GROUP (>=0, <=9)
- Tasks are scheduled in the order of their task group
- Nodes are automatically buffered between task groups
- Discrete core determines nodes which need buffering to minimize overhead (information in DISCRETE_LOG)
- A discrete block list now must put each stepped node into a task if it uses tasks
- Drivers not using tasks will get one task allocated automatically
- Updated drivers accordingly
- Some more constification
2009-10-03 21:45:09 +00:00
Couriersud
fbbdb817d7 More changes in order to create task groups 2009-10-03 13:35:20 +00:00
Derrick Renaud
dffbe9eff3 Minor cleanup, not worth mentioning.
Just commiting so it does not clash with Couriersud's work.
2009-10-03 13:09:02 +00:00
Couriersud
994dde76eb implemented m:n logic for buffered task nodes
- preparation work so that a task node output buffer may be read by
  more than one following task.
- target: implementation of task groups: tasks in a task group run parallel, task groups serial. The current main task may than just be task (in the last task group)
2009-10-03 00:58:15 +00:00
Couriersud
cb21196ecd Maintenance work
- more descriptive names
- preparation for more general task definition
2009-10-03 00:30:57 +00:00
Derrick Renaud
ecffbf4c3b Discrete Updates:
Added DISCRETE_LOGIC_SHIFT - generic shift register
  Fixed DISCRETE_BIT_DECODE to apply proper voltage instead of clipping to INT.

Sky Raider - Partial discrete sound
2009-09-21 23:20:32 +00:00
Couriersud
214affb3ee Remove Enable input from dst_gain_step (DISCRETE_MULTADD, DISCRETE_MULTIPLY, ...) 2009-09-10 19:15:04 +00:00
Couriersud
4e3d674b2b Disable profiling again 2009-09-10 18:33:12 +00:00
Couriersud
fa0a81f9a3 discrete emulation / not worth mentioning
- DISCRETE_(DIS)CHARGE_EXP back to one parameter (RC term) after discussion with Derrick
- discrete.h indenting
2009-09-10 18:17:22 +00:00
Aaron Giles
50b4a43bfd Fix CPP_COMPILE (except for internal compiler error on snes.c). 2009-09-08 16:58:02 +00:00
Aaron Giles
8fbe10c91f Cleanups and version bump. 2009-09-07 01:34:34 +00:00
Aaron Giles
f60bbef070 Rename osd_profiling_ticks() to get_profile_ticks(). Moved implemention into
inline functions in eminline.h and the ei* functions. [couriersud, Aaron Giles]
2009-09-06 23:30:26 +00:00
Couriersud
1b22c69b58 Discrete emulation
- added node parameter to RC_(DIS)CHARGE_EXP
- added const where appropriate
- removed some dead code
2009-09-06 19:53:02 +00:00
Couriersud
64c1866c1b Good bye for node->node 2009-09-06 17:36:56 +00:00
Couriersud
ac6238dc59 DSO_TASK_END now builds it's own dependence list.
- now simply DSO_TASK_END() ends a task
- updated drivers accordingly
- fixed dependence on disc_sys.c in sound.mak
2009-09-06 14:54:10 +00:00
Curt Coder
872eabafb2 Fixed 64-bit MSVC compile. 2009-09-06 13:51:54 +00:00
Couriersud
dfbdaa0357 Cleaned up task processing a bit 2009-09-06 13:35:13 +00:00
Couriersud
9812bf4edf discrete wav and csv logs now are treated as nodes
- added DISCRETE_START and DISCRETE_STOP functions to be called at device start/stop
- used these to move log code in disc_sys.c
- As a side effect, profiling measures log overhead as well
2009-09-05 13:26:34 +00:00
Couriersud
e58e1a413a Added disc_syc.c as a container for core modules (output, task) currently. 2009-09-05 10:24:04 +00:00