summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/mconfig.h
Commit message (Collapse)AuthorAgeFilesLines
* Sync core fixes from MESS done by OG (nw) Miodrag Milanovic2012-02-111-2/+2
|
* Move devices into a proper hierarchy and handle naming Aaron Giles2012-01-241-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Added clearing of generic nvram handler and removed megadriv ifdefs (no ↵ Miodrag Milanovic2011-11-171-0/+2
| | | | whatsnew)
* Added hot/cold attributes. Made the MAME executable 1% smaller by using the Nathan Woods2011-11-061-4/+4
| | | | | cold attribute on setup functions
* "You have taken your first step into a larger world." ―Obi-Wan Kenobi smf-2011-05-061-0/+3
| | | | | | | | | | | | | Converted PlayStation DMA to an internal device to the CPU core. DMA to external devices can be set in the machine config, the old calls are still there until the rest of the code is converted. [smf] The following MAME core changes have been required to allow internal devices to be configurable by the main machine config & to work with internal memory maps. device.machine_config_additions() are now processed as soon as the device is added, so sub devices can be configured straight away. replacing or removing a device removes any devices owned by the device being removed, as now they are added straight away. device_t::subdevice() uses the machine config device list instead of the machine to find the device as the machine is not created until after all the devices have been created. devices in an internal address map are assumed to be owned by the CPU, while devices in a standard address maps are assumed to be siblings of the CPU. A code review and regression test would be a good idea.
* Collapsed device_config and device_t into one class. Updated all Aaron Giles2011-04-271-27/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix MT#04291 Aaron Giles2011-03-311-2/+12
| | | | | | | Added new macro MACHINE_CONFIG_DERIVED_CLASS() which works just like MACHINE_CONFIG_DERIVED() except you can specify an alternate driver_device class. Used this in the 8080bw.c games which require an _8080bw_state, but derive from mw8080bw_root which has the base class mw8080bw_state.
* Minor cleanups. Aaron Giles2011-03-301-1/+0
|
* BIG update. Aaron Giles2011-03-291-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove redundant machine items from address_space and device_t. Neither machine nor m_machine are directly accessible anymore. Instead a new getter machine() is available which returns a machine reference. So: space->machine->xxx ==> space->machine().xxx device->machine->yyy ==> device->machine().yyy Globally changed all running_machine pointers to running_machine references. Any function/method that takes a running_machine takes it as a required parameter (1 or 2 exceptions). Being consistent here gets rid of a lot of odd &machine or *machine, but it does mean a very large bulk change across the project. Structs which have a running_machine * now have that variable renamed to m_machine, and now have a shiny new machine() method that works like the space and device methods above. Since most of these are things that should eventually be devices anyway, consider this a step in that direction. 98% of the update was done with regex searches. The changes are architected such that the compiler will catch the remaining errors: // find things that use an embedded machine directly and replace // with a machine() getter call S: ->machine-> R: ->machine\(\)\. // do the same if via a reference S: \.machine-> R: \.machine\(\)\. // convert function parameters to running_machine & S: running_machine \*machine([^;]) R: running_machine \&machine\1 // replace machine-> with machine. S: machine-> R: machine\. // replace &machine() with machine() S: \&([()->a-z0-9_]+machine\(\)) R: \1 // sanity check: look for this used as a cast (running_machine &) // and change to this: *(running_machine *)
* Attached emu_options to the machine_config, and the running_machine Aaron Giles2011-03-101-1/+3
| | | | inherits it now.
* Converted core_options to a class. Removed a bunch of marginal Aaron Giles2011-03-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | functionality in favor of alternate mechanisms. Errors are now reported via an astring rather than via callbacks. Every option must now specify a type (command, integer, float, string, boolean, etc). Command behavior has changed so that only one command is permitted. [Aaron Giles] Changed fileio system to accept just a raw searchpath instead of an options/option name combination. [Aaron Giles] Created emu_options class dervied from core_options which wraps core emulator options. Added mechanisms to cleanly change the system name and add/remove system-specific options, versus the old way using callbacks. Also added read accessors for all the options, to ensure consistency in how parameters are handled. Changed most core systems to access emu_options instead of core_options. Also changed machine->options() to return emu_options. [Aaron Giles] Created cli_options class derived from emu_options which adds the command-line specific options. Updated clifront code to leverage the new class and the new core behaviors. cli_execute() now accepts a cli_options object when called. [Aaron Giles] Updated both SDL and Windows to have their own options classes, derived from cli_options, which add the OSD-specific options on top of everything else. Added accessors for all the options so that queries are strongly typed and simplified. [Aaron Giles] Out of whatsnew: I've surely screwed up some stuff, though I have smoke tested a bunch of things. Let me know if you hit anything odd. Also I know this change will impact the WINUI stuff, please let me know if there are issues. All the functionality necessary should still be present. If it's not obvious, please talk to me before adding stuff to the core_options class.
* Modified video update system. [Miodrag Milanovic] Miodrag Milanovic2011-02-241-6/+0
| | | | | | | | | | | | | | | | | | | | Screen update function is now per screen device (it was before but was attached to machine driver) MCFG_VIDEO_UPDATE -> MCFG_SCREEN_UPDATE MCFG_VIDEO_EOF -> MCFG_SCREEN_EOF EOF is now executed for all screens, so for all existing it is defined just for one screen. This part will be updated in future. Note that there are now screen_update and screen_eof virtual functions for "modern" drivers which are called same as they did before. All drivers are updated and in places where update function was separated per screen I did name separate function. This change will enable us to put screen definition fully into device.
* mame_file is now emu_file and is a class. It is required Aaron Giles2011-02-121-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | to pass a core_options object to the constructor, along with a search path. This required pushing either a running_machine or a core_options through some code that wasn't previously ready to handle it. emu_files can be reused over multiple open/close sessions, and a lot of core code cleaned up nicely as things were converted to them. Also created a file_enumerator class for iterating over files in a searchpath. This replaces the old mame_openpath functions. Changed machine->options() to return a reference. Removed public nvram_open() and fixed jchan/kaneko16 to stop directly saving NVRAM. Removed most of the mame_options() calls; this will soon go away entirely, so don't add any more. Added core_options to device_validity_check() so they can be used to validate things.
* Attotime bulk conversion step: Aaron Giles2011-02-031-2/+2
| | | | | | | | | | | | | | | | | | 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
* MDRV_* -> MCFG_* Aaron Giles2010-12-311-24/+24
| | | | | There hasn't been a machine driver for many years.
* Split the screen device into a separate module. Aaron Giles2010-12-021-0/+5
| | | | | Converted global video routines into a video_manager. Moved video manager initialization earlier in startup.
* Cleanups and version bump.mame0139u3 Aaron Giles2010-09-191-1/+1
|
* Moved auto-finding code down into the device_t object so it can be more Aaron Giles2010-09-141-1/+1
| | | | | | | | | | | | | | | | broadly used. Added memory interface to the intelfsh device so you can access/view the data in the debugger and via the standard memory interfaces. Removed the old memory() method in favor of new functions read_raw()/write_raw() which do direct reads/writes of the data. Cleaned up CPS3 No-CD sets to break up the "ROMs" into individual flash pieces which are automatically loaded by the intelfsh device on initialization. Also split the MACHINE_CONFIG to only populate the number of SIMMs actually present for each game, as documented in the top of the file. And replaced the NVRAM_HANDLER with an NVRAM device.
* Changed driver_device to expose the game_driver's ROMs through the Aaron Giles2010-09-031-1/+4
| | | | | | | | | | | | | | | | | device interface. This means all ROMs are now exposed via devices, and thus the process of enumerating ROMs gets simpler. Changed all instances of temporarily allocating machine_config objects to just put them on the stack for simplicity, letting the destructor handle the cleanup work automatically. Changed machine_config constructor to take a game_driver, from which the machine_config constructor is obtained. This also means the resulting machine_config holds a reference to the game_driver. Changed running_machine constructor to no longer take a game_driver, since the game_driver is now obtainable via the machine_config.
* Changed driver_data objects to be devices. Replaced the driver_data_t Aaron Giles2010-09-021-98/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | class with a new driver_device class, which is the base class for all driver_data objects now. The new driver devices are added as the first device in the device list, with a tag of "root"; all other devices are now owned by the driver device. Moved core callbacks (machine_start/_reset, sound_start/_reset, video_start/_reset/_eof/_update, and palette_init) into device configuration parameters on these new devices. The driver_device base class overrides device_start(), ensures all other devices have been started, and then calls, in order, the following overridable methods: find_devices() - new, used to locate devices prior to DRIVER_INIT DRIVER_INIT function from the game driver palette_init() - by default calls the MDRV_PALETTE_INIT function driver_start() - new machine_start() - by default calls the MDRV_MACHINE_START function sound_start() - by default calls the MDRV_SOUND_START function video_start() - by default calls the MDRV_VIDEO_START function Similarly, the driver_device class overrides device_reset() and then calls these methods in order: driver_reset() - new machine_reset() - by default calls the MDRV_MACHINE_RESET function sound_reset() - by default calls the MDRV_SOUND_RESET function video_reset() - by default calls the MDRV_VIDEO_RESET function To accommodate these changes, initialization order is slightly altered from before. The tilemap, video, sound, and debug systems are now initialized prior to the devices' start. And the user callbacks for DRIVER_INIT, PALETTE_INIT, MACHINE_START, SOUND_START, and VIDEO_START are all called back-to-back. The net effect should be similar, however. Added methods (optional_device and required_device) to the new driver_device class to find devices, intended to be used from the find_devices() callback. See harddriv.h and beathead.h for examples of usage. Changed device_t::subtag to only prepend a prefix if the device is not the 'root' device, in order to keep compatibility with existing tag searching. Changed device startup to actively reorder devices when they report missing dependencies. This ensures that the reset functions get called in the same order that the start functions did. Bulk updated drivers as follows: First removed the old static alloc function from the driver_data_t: S: [ \t]*static driver_device \*alloc *\( *running_machine *\&machine *\) *\{ *return auto_alloc_clear *\( *\&machine *, *[a-zA-Z0-9_]+_state *\( *machine *\) *\); *\}[\r\n]* R: Then switched from driver_data_t to driver_device: S: driver_data_t R: driver_device Then changed the constructors to pass the correct parameters: S: ([a-zA-Z0-9_]+)_state *\( *running_machine *\&machine *\)([\r\n\t ]+): *driver_device *\( *machine *\) R: \1_state\(running_machine \&machine, const driver_device_config_base \&config\)\2: driver_device\(machine, config\)
* Changed the MACHINE_DRIVER_* macros, as follows: Aaron Giles2010-09-011-11/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Renamed MACHINE_DRIVER_* to MACHINE_CONFIG_* to match the name of the object it actually describes. The MDRV_* prefix may eventually be bulk updated at some point, but not now. 2. MACHINE_CONFIG_START() now takes a driver_data_t-derived class as a required second parameter. This means that MDRV_DRIVER_DATA() is no longer required, and every "root" machine config *must* specify a driver data class (or driver_data_t itself if the driver has not yet been updated to use driver data). 3. New MACHINE_CONFIG_DERIVED() macro defines a machine_config that is derived from another machine_config. This takes the place of the very typical MACHINE_DRIVER_START()/MDRV_IMPORT_FROM() combination. 4. New MACHINE_CONFIG_FRAGMENT() macro defines a partial machine_config that can only be included in another "root" machine_config. This is also used for machine_configs that are specified as part of a device. 5. Changed MDRV_IMPORT_FROM() to MDRV_FRAGMENT_ADD() to more accurately describe what is happening. 6. Added asserts to the above three macros to ensure they are properly used. Updated all machine drivers to use the new macros. Search & replace lists below cover 99% of the changes, with just a few manual fixups. S: MACHINE_DRIVER_START\( *([a-zA-Z0-9_]+) *\)[\r\n\t ]*MDRV_DRIVER_DATA\( *([a-zA-Z0-9_]+) *\) R: MACHINE_CONFIG_START\( \1, \2 \) S: MACHINE_DRIVER_START\( *([a-zA-Z0-9_]+) *\)[\r\n\t ]*/\* driver data \*/[\r\n\t ]*MDRV_DRIVER_DATA\( *([a-zA-Z0-9_]+) *\) R: MACHINE_CONFIG_START\( \1, \2 \) S: MACHINE_DRIVER_START\( *([a-zA-Z0-9_]+) *\)[\r\n\t ]*MDRV_IMPORT_FROM\( *([a-zA-Z0-9_]+) *\) R: MACHINE_CONFIG_DERIVED\( \1, \2 \) S: MACHINE_DRIVER_START\( *([a-zA-Z0-9_]+) *\)[\r\n\t ]*/\* basic machine hardware \*/[\r\n\t ]*MDRV_IMPORT_FROM\( *([a-zA-Z0-9_]+) *\) R: MACHINE_CONFIG_DERIVED\( \1, \2 \)\r\n\r\n\t/\* basic machine hardware \*/ For all files outside of mame/drivers.... S: MACHINE_DRIVER_START R: MACHINE_CONFIG_FRAGMENT in all non-drivers For all files within mame/drivers.... S: MACHINE_DRIVER_START\( *([a-zA-Z0-9_]+) *\) R: MACHINE_CONFIG_START\( \1, driver_data_t \) S: MDRV_IMPORT_FROM R: MDRV_FRAGMENT_ADD S: MACHINE_DRIVER_END R: MACHINE_CONFIG_END S: MACHINE_DRIVER_NAME R: MACHINE_CONFIG_NAME S: MACHINE_DRIVER_EXTERN R: MACHINE_CONFIG_EXTERN Final step: run mame -valid and fix the incorrect macros at the lines where the asserts show up.
* De-converted MACHINE_DRIVER from tokens back to constructor functions, regaining Aaron Giles2010-08-261-211/+94
| | | | | | | | | | | type safety. If legacy devices still use inline data, those types are not checked. However, new devices no longer have access to the generic m_inline_data. Instead their MDRV_* macros should map to calls to static functions in the device config class which downcast a generic device_config to the specific device config, and then set the appropriate values. This is not to be done inline in order to prevent further code bloat in the constructors. See eeprom/7474/i2cmem/okim6295 for examples. #ifdef'ed several unused machine driver definitions that weren't referenced.
* (Wow, I had no idea quite so many drivers were using driver_data!) Aaron Giles2010-08-041-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Defined new class driver_data_t, which all driver_data classes must derive from. Updated all class definitions to inherit from the new class, and to call it in the constructor. Also changed the alloc() signature to return a driver_data_t pointer instead of a void *. Renamed and hid machine->driver_data as machine->m_driver_data. Added a new templatized method machine->driver_data<class> which returns a properly downcast'ed version of the driver data. Updated all code which looked like this: mydriver_state *state = (mydriver_state *)machine->driver_data; to this: mydriver_state *state = machine->driver_data<mydriver_state>(); The new function does a downcast<> which in debug builds dynamically verifies that you're actually casting to the right type. Changed atarigen_state to be a base class from which all the related Atari drivers derive their state from. For MESS: this was mostly a bulk search/replace, in 4 steps in src/mame: 1. Add ": public driver_data_t" to each driver state class definition: Search: (class [a-z0-9_]+_state)$ Replace: \1 : public driver_data_t 2. Change the static alloc function to return a driver_data_t *: Search: static void \*alloc\( Replace: static driver_data_t \*alloc\( 3. Change the constructor to initialize driver_data_t: Search: ([a-z0-9_]+_state\(running_machine \&machine\)) { } Replace: \1\r\n\t\t: driver_data_t(machine) { } 4. Replace the state fetchers to use the new templatized function: Search: \(([a-z0-9_]+_state) \*\)(.*)machine->driver_data Replace: \2machine->driver_data<\1>()
* Return to type safety. Changed address maps back into functions that build Aaron Giles2010-08-011-1/+1
| | | | | | | | | | | | | | | | | | | | | up the definition, rather than the whole tokenizing system, which lost type checking. Added a new module addrmap.c which implements the address map classes, and changed the macros to call methods on the address_map and address_map_entry classes which are strongly typed. Fixed a few incorrectly specified memory map entries along the way. Please double-check to make sure the behavior is expected in: twincobr.c, lordgun.c, galaxold.c. This change also means that since the address_maps are now constructor functions, they are detected when not used, so a number of #ifdef UNUSED_CODE were added around dangling address map definitions. Also included with this change: - removed cputag_clocks_to_attotime() and cputag_attotime_to_clocks() in favor of just expanding the class - same for cputag_suspend() and cputag_resume()
* Cleanups and version bump.mame0138u3 Aaron Giles2010-07-061-5/+5
|
* Created CPU-specific device types for all CPUs, using new macros Aaron Giles2010-07-031-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | DECLARE_LEGACY_CPU_DEVICE and DEFINE_LEGACY_CPU_DEVICE. Changed CPUs to be their own device types, rather than all of type CPU with a special internal subtype. Note that as part of this process I removed the CPU_ prefix from the ALL-CAPS device name, so CPU_Z80 is just plain old Z80 now. This required changing a couple of names like 8080 to I8080 so that there was an alphabetic first character. Added memory interfaces to the list of fast-access interfaces. To do this properly I had to add a separate method to devices which is called immediately after construction, when it is possible to perform dynamic_casts on fully-constructed objects. (This is just internal, no changes necessary to the devices themselves.) Some additional notes: * SH2 and SH4 had typedefs that conflicted with their CPU_-less names so I bulk renamed to structures to sh2_state and sh4_state; RB, feel free to choose alternate names if you don't like 'em * SCSP was caught doing something to the 3rd indexed CPU. Since several systems that use SCSP don't even have 3 CPUs, I had no idea what this was supposed to do, so I changed to it reference "audiocpu" assuming that stv was the assumed target. This is really gross and should be a configuration parameter, not a hard-coded assumption.
* Made the machine_config a proper object. Added detokenize method to Aaron Giles2010-06-281-62/+87
| | | | | | | | | | | | this object which can be called multiple times to append new devices after the initial machine configuration is set up. Updated member variables to match new naming convention. Changed the running_machine to take a constructed machine_config object in the constructor, instead of creating one itself, for consistency. Also added machine->total_colors() as a shortcut to machine->config->m_total_colors.
* Cleanups and version bump. Aaron Giles2010-06-171-2/+2
|
* WARNING: There are likely to be regressions in both functionality and Aaron Giles2010-06-081-110/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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]
* Changed all driver_data structs into classes with a simple Aaron Giles2010-02-251-3/+6
| | | | | | | | | | | | | | | | | | constructor and a static allocation function. Changed MDRV_DRIVER_DATA to reference driver_data::alloc instead of just providing a size. This function is called to allocate the driver data. This allows objects to be embedded in the state data and be properly initialized. Ideally, new driver_data constructors should perform initialization actions in the constructor, but for now most just use auto_alloc_clear() to blast everything to zero. Moved driver data allocation after device list construction so that devices can be found when the driver data is constructed.
* Correct a long-standing design flaw: device configuration state Aaron Giles2010-01-181-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* First round of an attempted cleanup of header files in the system. Aaron Giles2010-01-101-8/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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!)
* NOTE: This change requires two new osd functions: osd_malloc() and Aaron Giles2010-01-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | osd_free(). They take the same parameters as malloc() and free(). Renamed mamecore.h -> emucore.h. New C++-aware memory manager, implemented in emualloc.*. This is a simple manager that allows you to add any type of object to a resource pool. Most commonly, allocated objects are added, and so a set of allocation macros is provided to allow you to manage objects in a particular pool: pool_alloc(p, t) = allocate object of type 't' and add to pool 'p' pool_alloc_clear(p, t) = same as above, but clear the memory first pool_alloc_array(p, t, c) = allocate an array of 'c' objects of type 't' and add to pool 'p' pool_alloc_array_clear(p, t, c) = same, but with clearing pool_free(p, v) = free object 'v' and remove it from the pool Note that pool_alloc[_clear] is roughly equivalent to "new t" and pool_alloc_array[_clear] is roughly equivalent to "new t[c]". Also note that pool_free works for single objects and arrays. There is a single global_resource_pool defined which should be used for any global allocations. It has equivalent macros to the pool_* macros above that automatically target the global pool. In addition, the memory module defines global new/delete overrides that access file and line number parameters so that allocations can be tracked. Currently this tracking is only done if MAME_DEBUG is enabled. In debug builds, any unfreed memory will be printed at the end of the session. emualloc.h also has #defines to disable malloc/free/realloc/calloc. Since emualloc.h is included by emucore.h, this means pretty much all code within the emulator is forced to use the new allocators. Although straight new/delete do work, their use is discouraged, as any allocations made with them will not be tracked. Changed the familar auto_alloc_* macros to map to the resource pool model described above. The running_machine is now a class and contains a resource pool which is automatically destructed upon deletion. If you are a driver writer, all your allocations should be done with auto_alloc_*. Changed all drivers and files in the core using malloc/realloc or the old alloc_*_or_die macros to use (preferably) the auto_alloc_* macros instead, or the global_alloc_* macros if necessary. Added simple C++ wrappers for astring and bitmap_t, as these need proper constructors/destructors to be used for auto_alloc_astring and auto_alloc_bitmap. Removed references to the winalloc prefix file. Most of its functionality has moved into the core, save for the guard page allocations, which are now implemented in osd_alloc and osd_free.
* Results of running the latest srcclean. Aaron Giles2009-12-281-1/+1
|
* Added new module tagmap which is a simple hashed string map. Aaron Giles2009-11-231-1/+1
| | | | | | Updated device and input port lists to use the tagmap for tag searches. Also removed the whole "quark" thing from the validity checker in favor of using the tagmaps.
* Put minimum tag length back to 2 characters for now. Aaron Giles2009-11-191-2/+2
|
* Enforce a minimum tag length of 3 characters. This will enable Aaron Giles2009-11-151-1/+2
| | | | | | | | | | future lookup optimizations. By and large, the only things that used 2-character tags were bulk- converted sound chips which were generally mapped to "ym" or "ay" (and a few others). These were changed to "ymsnd" and "aysnd", mimicking the way CPUs were changed from "main" to "maincpu" a while back.
* > -----Original Message----- Aaron Giles2009-10-011-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > From: Atari Ace [mailto:atari_ace@verizon.net] > Sent: Sunday, September 27, 2009 7:58 AM > To: submit@mamedev.org > Cc: atariace@hotmail.com > Subject: [patch] More _NAME macros > > Hi mamedev, > > MAME's idiom for function/data macros is to first implement > <name>_NAME, then implement the other macros in terms of the _NAME > macro. Then in principle only a single line needs editing to change > the naming convention. > > This patchset implements this idiom more completely. The first patch > adds some missing _NAME macros and fixes cases in source files that > should be using the macros. The second patch then changes header > files where the macros should have been used, but weren't. This > required changing the idiom for removing a machine driver function > pointer from MDRV_<FUNCTION>(NULL) to MDRV_<FUNCTION>(0), to avoid > problems with NULL being macro expanded. This actually unifies the > handling of all such cases, as we already had ipt_0 and driver_init_0. > It also required reworking the devtempl.h implementation in a way that > triggered a warning on MSVC about using empty macros, so vconv.c > needed to be updated. The third patch then renames all the _NAME and > _0 macros to verify that all the cases have been covered, so it isn't > intended to be applied. > > ~aa
* Move address_map array from cpu_config to device_config. Added Aaron Giles2009-07-081-0/+15
| | | | | | | | MDRV macros in the device for specifying address maps. Changed the memory system to fetch the maps from the new location. This is just a small step toward the end goal of getting address maps into arbitrary devices.
* Removed device types from device queries that use tags, under the Aaron Giles2009-03-021-4/+2
| | | | | | | | | | | | | | | assumption that all device tags are unique. Specifically, the following no longer need to provide a device type: AM_DEVREAD/WRITE DEVCB_DEVICE_HANDLER devtag_get_device devtag_reset device_list_find_by_tag as well as several device interfaces that referenced other devices. Also fixed assertion due to overflow in the recent sound fix.
* Added the ability for devices to have their own custom inline config management. Aaron Giles2009-02-161-14/+16
| | | | | | | | | | | | This was primarily added to allow for sound routes to be supported in a way that is compatible with the current driver structure. A device can now define a DEVICE_CUSTOM_CONFIG callback which is called whenever one of the MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_* tokens is encountered. A special token MCONFIG_TOKEN_DEVICE_CONFIG_CUSTOM_FREE is defined to clean up memory allocated and/or reset the custom configuration, and is called when the device is torn down to allow for memory cleanup. Reimplemented the sound routing using this new mechanism.
* Ok, this is The Big One. Aaron Giles2009-02-111-113/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Please note: regression testing is in progress, but the first round of glaring regressions have already been taken care of. That said, there is likely to be a host of regressions as a result of this change. Also note: There are still a few rough edges in the interfaces. I will try to clean them up systematically once the basic system is working. All sound chips are now proper devices. Merged the sound chip interface into the device interface, removing any differences (such as the whole ALIASing concept). Modified every sound chip in the following ways: * updated to match the device interface * reduced read/write handlers down to the minimal number * added the use of get_safe_token() for ensuring correctness * other minor cleanup Removed the custom sound device. The additional work to just make custom sound cases into full devices is minimal, so I just converted them all over to be actual devices. Vastly simplified the sound interfaces, removing the ghastly sndti_* business and moving everyone over to using tags for sound identity. sndintrf, like cpuintrf, is now just a header file with no implementation. Modified each and every driver that references a sound chip: * all memory maps explicitly reference the targeted device via AM_DEVREAD/AM_DEVWRITE/AM_DEVREADWRITE * 16-bit and 32-bit accesses to 8-bit chips no longer use trampoline functions but instead use the 8-bit AM_DEVREAD/WRITE macros * all references to sound chips are now done via tags * note that these changes are brute force, not optimal; in many cases drivers should grab pointers to devices in MACHINE_START and stash them away
* From: Atari Ace [mailto:atari_ace@verizon.net] Aaron Giles2009-01-131-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sent: Monday, December 22, 2008 3:00 PM To: submit@mamedev.org Cc: atariace@hotmail.com Subject: [patch] Make SOUND_xxx pointers to SND_GET_INFO functions Hi mamedev, This patch probably should wait till after 0.129 goes out, but may be of interest regardless. It makes the treatment of SOUND_xxx the same as that of CPU_xxx. That is, they are function pointers to the SND_GET_INFO routine for the sound. The first patch just adds some missing include files and modifies a few cases where a sound_type was used as an integer. This could go in now. The second patch then adds the needed #defines to all the sound headers (it assumes the previous patch I sent to add the SND_GET_INFO declarations was applied), and modifies the sound code accordingly. It also moves the sound clock to the device object. Note that the dummy sound core is removed entirely. I cheated a bit and made VERIFY_SNDTI also declare and fill in the sndnum, making this an INLINE function would probably be more appropriate, but all of this code's days are numbered. There may be some performance loss in drivers that expect sndti_xxx routines to be fast, since sound_matrix has been removed. The performance however should be similar to looking up items in a devicelist, so those drivers will have to adjust eventually. ~aa
* Removed MDRV_INTERLEAVE(x), which specified the minimum scheduling Aaron Giles2008-12-201-5/+12
| | | | | | | | | | | | | | | | | | | | | | quantum in terms of "frames" (a dubious concept now with multiple screens and changing refresh rates). Replaced it with a new MDRV_QUANTUM_TIME(x) which specifies the minimum scheduling quantum as a time value. Time can be specified as HZ(x), NSEC(x), USEC(x), etc. Updated all drivers to use this, assuming 60 was the frame rate (this is not perfect but should work for almost all cases). Changed MDRV_WATCHDOG_INIT_TIME(x) to automatically prepend UINT64_ATTOTIME_IN_ to the parameter, ensuring there is no improper use of this macro and bringing it in line with the MDRV_QUANTUM_TIME() macro. Updated all callers. Added new MDRV_QUANTUM_PERFECT_CPU(x) to specify that the minimum quantum should be enough to ensure that the specified CPU tag only ever executes a single instruction at a time. This can be used to explicitly require "perfect" synchronization for drivers that have multiple CPUs with shared memory. Turned this on for the arknoid2 driver for now as a test (the interleave on that driver was already very close to perfect anyway).
* Made the concept of a "clock" native to devices. The clock is now Aaron Giles2008-12-181-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | specified when the device is added, and the clock is available in the device_config directly via device->clock. Updated all devices that have a clock to specify it when adding the device, rather than as part of their configuration. As part of this work, also created device-specific _ADD and _REMOVE macros to simplify configuration. Dfined a generic device execute function callback, though it is not used yet. The long term plan is that any device with an execute callback will be scheduled along with the CPUs. Now that CPUs are devices, their scheduling will be moved over to this logic eventually. Changed various NVRAM devices to fetch their default memory region from the device->region rather than specifying it in the configuration. Moved a number of CPUINFO_PTR_* constants to CPUINFO_FCT_*. Fixed several drivers that manually created their own gfx_elements to fill in the machine object, so they no longer crash. Fixed incorrect CPU display on info screen (recently broken). Moved device startup to *before* the DRIVER_INIT is called. This is to allow the DRIVER_INIT to configure devices that have been properly allocated. So far I don't see any negative effects, but be on the lookout if something weird shows up. Rewrote the device iteration logic to make use of the typenext field and the newly-introduced classnext field for iterating more efficiently through devices of a given type or class. Fixed behavior of MDRV_CPU_REPLACE so it does not delete and then re-add a CPU (causing the order to change).
* Made CPUs into proper devices. CPUs are now added in the Aaron Giles2008-12-161-67/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | machine configuration just as any other device, and the standard CPU configuration is performed via the inline configuration macros. Change cpu_type from an enumeration into a pointer to the CPU's get_info function, very similar to device behavior. For now all CPUs are declared in cpuintrf.h, but eventually they should be declared in the CPU's header file, and the driver should #include that header. Added function cpu_get_type() to return the CPU type. Changed several cpu_* functions into macros that call through to the equivalent device_* function. The device system now maintains a parallel list of devices based on type, for faster iteration through all devices of a given type. Cleaned up code that looped over CPUs via the machine->cpu array to now loop using the type-based device list. Removed start/stop/reset/nvram functions from the device_config in favor of grabbing them as needed. Cleaned up the generic interrupt_enable code to work with CPU devices instead of numbers. Mapped the devtag_* functions to device_* functions via macros instead of parallel implementations.
* Added macros to access ROM and MACHINE_DRIVER by name. Curt Coder2008-11-261-1/+4
|
* Massive API cleanup/change. The primary goal is that all CPU- Aaron Giles2008-11-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | related APIs now take a device pointer instead of an index. All functions that take a CPU device are prefixed with cpu_* All functions that are globally related to cpu execution are prefixed with cpuexec_*. Below is a list of some of the mappings: cpu_boost_interleave -> cpuexec_boost_interleave cpunum_suspend -> cpu_suspend cpunum_resume -> cpu_resume cpunum_is_suspended -> cpu_is_suspended cpunum_get_clock -> cpu_get_clock cpunum_set_clock -> cpu_set_clock cpunum_get_clockscale -> cpu_get_clockscale cpunum_set_clockscale -> cpu_set_clockscale cpunum_get_localtime -> cpu_get_local_time cpunum_gettotalcycles -> cpu_get_total_cycles activecpu_eat_cycles -> cpu_eat_cycles activecpu_adjust_icount -> cpu_adjust_icount cpu_trigger -> cpuexec_trigger cpu_triggertime -> cpuexec_triggertime cpunum_set_input_line -> cpu_set_input_line cpunum_set_irq_callback -> cpu_set_irq_callback In addition, a number of functions retain the same name but now require a specific CPU parameter to be passed in: cpu_yield cpu_spin cpu_spinuntil_time cpu_spinuntil_int cpu_spinuntil_trigger cpu_triggerint Merged cpuint.c into cpuexec.c. One side-effect of this change is that driver reset callbacks are called AFTER the CPUs and devices are reset. This means that if you make changes to the CPU state and expect the reset vectors to recognize the changes in your reset routine, you will need to manually reset the CPU after making the change (since it has already been reset). Added a number of inline helper functions to cpuintrf.h for managing addresses Removed cpu_gettotalcpu(). This information is rarely needed outside of the core and can be obtained by looking at the machine->cpu[] array. Changed CPU interrupt acknowledge callbacks to pass a CPU device instead of machine/cpunum pair. Changed VBLANK and periodic timer callbacks to pass a CPU device instead of machine/cpunum pair. Renamed all information getters from cpu_* to cpu_get_* and from cputype_* to cputype_get_*.
* Major cpuintrf changes: Aaron Giles2008-11-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | * added a set of cpu_* calls which accept a CPU device object; these are now the preferred means of manipulating a CPU * removed the cpunum_* calls; added an array of cpu[] to the running_machine object; converted all existing cpunum_* calls to cpu_* calls, pulling the CPU device object from the new array in the running_machine * removed the activecpu_* calls; added an activecpu member to the running_machine object; converted all existing activecpu_* calls to cpu_* calls, pulling the active CPU device object from the running_machine * changed cpuintrf_push_context() to cpu_push_context(), taking a CPU object pointer; changed cpuintrf_pop_context() to cpu_pop_context(); eventually these will go away * many other similar changes moving toward a model where all CPU references are done by the CPU object and not by index
* From: Atari Ace [mailto:atari_ace@verizon.net] Aaron Giles2008-11-081-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | Sent: Wednesday, November 05, 2008 8:22 AM To: submit@mamedev.org Cc: atariace@hotmail.com Subject: [patch] Add ADDRESS_MAP_NAME macro Hi mamedev, In theory, MAME's interface macros should completely hide the naming conventions from the drivers and sound/cpu cores. So as an experiment, I renamed all the core apis and looked to see what broke. The most common api coupling was with address maps in the CPU cores, which this patch addresses by introducing a new macro, ADDRESS_MAP_NAME (mimicing what is done in devintrf.h). There were a handful of related problems in some drivers which this patch also fixes. Some remaining issues I left alone (laserdisk apis reference rom, video_update, machine_config, ksys573 use of nvram_handler, megadriv use of ipt), in principle all the apis need _NAME variants to encode the conventions. ~aa