summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/device.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'master' into time-experiments2 Aaron Giles2021-09-101-0/+2
|\
| * Allow devices to specify a parent for the purpose of searching for ROMs. Vas Crabb2021-09-061-0/+2
| |
* | Since I already had to touch all device_timer signatures, bite the bullet ↵ Aaron Giles2021-08-201-1/+1
| | | | | | | | and make device_timer callbacks match the native form to eliminate trampolines.
* | Remove timer_alloc from scheduler, keeping it exclusively in the device_t ↵ Aaron Giles2021-08-171-1/+1
| | | | | | | | class. Eventually we should replace all timer_allocs with persistent_timers embedded in the consumer.
* | Remove m_subseconds_per_clock from device_t, defering to attotime helpers ↵ Aaron Giles2021-08-161-18/+3
| | | | | | | | for necessary calculations.
* | You know, if I'm nice enough to give you an accessor, please use it. Aaron Giles2021-04-241-1/+1
| |
* | Move device timer initialization earlier since sometimes timers are primed ↵ Aaron Giles2021-04-151-3/+6
| | | | | | | | before we get there.
* | A few tweaks to realign with original code better. Aaron Giles2021-04-061-4/+4
| |
* | Rename raw_subseconds() to frac(). Create initial cut at new attotime ↵ Aaron Giles2021-04-041-1/+1
| | | | | | | | implementation. Still a couple of functions missing.
* | Switch out attoseconds in favor of more abstract subseconds. Update everyone ↵ Aaron Giles2021-04-021-6/+6
| | | | | | | | to use subseconds abstractly where possible. Builds, and many games work, but some are failing, so there be dragons here.
* | Major timer object reshuffling. timer_expired_delegate wraps the various ↵ Aaron Giles2021-03-261-24/+3
| | | | | | | | callback types. timer_callback is a class containing a timer_expired_delegate plus a user-supplied pointer, and accounting information for registration. timer_instance is a single active timer in the scheduler. persistent_timer is what you get back from timer_alloc() now, and has methods for dynamic changes. transient_timer_factory is what you use to create transient timers. Devices now own a transient_timer_factory for transient device timers. persistent_timers can be emedded and initialized directly.
* | Add scheduler object and accessor to device_t. Upgrade all 3 timer ↵ Aaron Giles2021-03-241-3/+4
| | | | | | | | parameters to u64. Change first parameter of device timers to be emu_timer const. Updated all device timers to follow suit.
* | Unsplit timer.h and just moved schedule.h up higher in the emu.h include ↵ Aaron Giles2021-03-241-8/+1
| | | | | | | | order. Created new timer_expired_delegate class which is based on a new native timer expired function signature, and which can convert the old function signature automatically via a trampoline. Added several other function signatures which can now be used directly as timer callbacks.
* | Fully deprecate unregistered timer_set/synchronize. Standardize on ↵ Aaron Giles2021-03-241-0/+10
| | | | | | | | emu_timer_cb for all timers internally. Split out timer-related classes into their own header timer.h, which is included before device.h. Devices now own their own emu_timer_cb for device timers.
* | Removed ptr parameter from temporary timers. Fixed a handful of places that ↵ Aaron Giles2021-03-221-2/+2
|/ | | | used it. Created timer_expired_registered_delegate for registering timer callbacks. Updated the callbacks in dcs.cpp to use them as a testbed.
* Much more core std::string_view modernization AJR2021-01-201-24/+66
| | | | | | | | | | | | | | | - Remove corestr.h from emu.h; update a few source files to not use it at all - Change strtrimspace, strtrimrightspace and core_filename_extract_* to be pure functions taking a std::string_view by value and returning the same type - Change strmakeupper and strmakelower to be pure functions taking a std::string_view and constructing a std::string - Remove the string-modifying version of zippath_parent - Change tag-based lookup functions in device_t to take std::string_view instead of const std::string & or const char * - Remove the subdevice tag cache from device_t (since device finders are now recommended) and replace it with a map covering directly owned subdevices only - Move the working directory setup method out of device_image_interface (only the UI seems to actually use the full version of this) - Change output_manager to use std::string_view for output name arguments - Change core_options to accept std::string_view for most name and value arguments (return values are still C strings for now) - Change miscellaneous other functions to accept std::string_view arguments - Remove a few string accessor macros from romload.h - Remove many unnecessary c_str() calls from logging/error messages
* -osd: Clean up inline maths utilities. Vas Crabb2021-01-181-1/+1
| | | | | | | | | | * Removed inline assembly for operations compilers handle well. * Added ARM and AArch64 implementation for a few operations. * Added unsigned integer add with carry out operations. -cpu/drccache.cpp: Detect whether RWX pages are supported. -dynax.cpp: Improved a few hanafuda DIP switch descriptions.
* Eliminate many unnecessary c_str calls AJR2020-12-211-1/+1
|
* device.cpp: Do a little less logging AJR2020-12-211-2/+3
|
* view: Save their state Olivier Galibert2020-12-211-0/+17
|
* -Switch to building MAME as C++17. Vas Crabb2020-11-151-2/+2
| | | | | | | * Updated sol2 to 3.2.2 * Updated pugixml to 1.10 * Increased minimum clang version to 6 * Cleaned up some stuff that can use new features
* validity.cpp, devfind.cpp: Catch missing required I/O ports in systems ↵ Vas Crabb2020-08-281-4/+4
| | | | (excluding slot cards)
* device.cpp, dimemory.cpp: Correct typos in comments AJR2020-07-211-2/+2
|
* device.cpp: initialized a couple of variables, fixes numerous bugs in ↵ Ivan Vangelista2020-05-131-4/+6
| | | | devnoclear debug build with bios roms in devices (nw)
* (nw) Cleanup on the way: Vas Crabb2020-03-101-1/+18
| | | | | | | | | | * Add doxygen comments for bit manipulation functions * Add an overload of BIT that works like the AArch64 UBFX instruction * Kill off some of the silly concatenating overloads for emu_file::open * Make searchpath acually useful for devices This is a checkpoint - I'm planning to improve ROM loading behaviour at least a little.
* fixed some clang-tidy warnings (nw) (#6236) Oliver Stöneberg2020-01-301-4/+4
| | | | | | | | | | | | | | | | * fixed some modernize-redundant-void-arg clang-tidy warnings (nw) * fixed some modernize-use-bool-literals clang-tidy warnings (nw) * fixed some modernize-use-emplace clang-tidy warnings (nw) * fixed some performance-move-const-arg clang-tidy warnings (nw) * fixed some readability-redundant-control-flow clang-tidy warnings (nw) * fixed some readability-redundant-string-cstr clang-tidy warnings (nw) * fixed some performance-unnecessary-value-param clang-tidy warnings (nw)
* Merge pull request #6195 from firewave/includes R. Belmont2020-01-221-1/+1
|\ | | | | use C++ library includes (nw)
| * use C++ library includes (nw) firewave2020-01-221-1/+1
| |
* | fixed some clang-tidy warnings (nw) (#6197) Oliver Stöneberg2020-01-221-3/+3
|/ | | | | | | | | | | | | | * fixed some bugprone-throw-keyword-missing clang-tidy warnings (nw) * fixed some modernize-use-nullptr clang-tidy warnings (nw) * fixed some readability-delete-null-pointer clang-tidy warnings (nw) * fixed some performance-faster-string-find clang-tidy warnings (nw) * fixed some performance-for-range-copy clang-tidy warnings (nw) * fixed some readability-redundant-string-cstr clang-tidy warnings (nw)
* These two should be noexcept as well (nw) AJR2019-11-091-2/+2
|
* Cleaned up Virtal Boy slot code. Vas Crabb2019-11-101-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | vboy.xml updates: * Set width and endianness for all ROM regions * Added width and endianness for SRAM, assuming all cartridges have 8k*32 SRAM for now * Removed mirroring - this is an implementation detail * Removed "slot" features - there's enough information to work this out anyway bus/vboy updates: * Made slot probe software part to determine cartridge type * Made cartridges responsible for installing themselves * Added support for arbitrary cartridge sizes, assuming simplistic decoding * Added support for 8-bit and 16-bit SRAM on LSBs * Added support for EXP space and INTCRO output * Fixed SRAM not being loaded bus/generic: added a helper for mapping non-power-of-two memory with simple decoding cpu/v810: send I/O accesses to program space if I/O space is unconfigured vboy.cpp: updated for changed slot and CPU code bus/wswan: added notes The Virtual Boy software list is still in pretty poor shape. It's assuming all carts with SRAM have 8k*32, there are a bunch of feature tags for ICs that don't actually give an IC type, making them useless, 3-D Tetris mentions a battery but doesn't have an SRAM data area, Virtual Fishing refers to a HY6254ALLJ-10 which isn't a real part (I assume it means HY6264ALLJ-10 which is an 8k*8 50µA standby SRAM).
* Make devdelegate more like devcb for configuration. This is a Vas Crabb2019-10-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fundamental change to show device delegates are configured. Device delegates are now aware of the current device during configuration and will resolve string tags relative to it. This means that device delegates need a device to be supplied on construction so they can find the machine configuration object. There's a one-dimensional array helper to make it easier to construct arrays of device delegates with the same owner. (I didn't make an n-dimensional one because I didn't hit a use case, but it would be a simple addition.) There's no more bind_relative_to member - just call resolve() like you would for a devcb. There's also no need to cast nullptr when creating a late bind device delegate. The flip side is that for an overloaded or non-capturing lambda you'll need to cast to the desired type. There is one less conditional branch in the hot path for calls for delegates bound to a function pointer of member function pointer. This comes at the cost of one additional unconditional branch in the hot path for calls to delegates bound to functoids (lambdas, functions that don't take an object reference, other callable objects). This applies to all delegates, not just device delegates. Address spaces will now print an error message if a late bind error is encountered while installing a handler. This will give the range and address range, hopefully making it easier to guess which memory map is faulty. For the simple case of allowing a device_delegate member to be configured, use a member like this: template <typename... T> void set_foo(T &&...args) { m_foo_cb.set(std::forward<T>(args)...); } For a case where different delegates need to be used depending on the function signature, see src/emu/screen.h (the screen update function setters). Device delegates now take a target specification and function pointer. The target may be: * Target omitted, implying the current device being configured. This can only be used during configuration. It will work as long as the current device is not removed/replaced. * A tag string relative to the current device being configured. This can only be used during configuration. It will not be callable until .resolve() is called. It will work as long as the current device is not removed/replaced. * A device finder (required_device/optional_device). The delegate will late bind to the current target of the device finder. It will not be callable until .resolve() is called. It will work properly if the target device is replaced, as long as the device finder's base object isn't removed/replaced. * A reference to an object. It will be callable immediately. It will work as long as the target object is not removed/replaced. The target types and restrictions are pretty similar to what you already have on object finders and devcb, so it shouldn't cause any surprises. Note that dereferencing a device finder will changes the effect. To illustrate this: ... required_device<some_device> m_dev; ... m_dev(*this, "dev") ... // will late bind to "dev" relative to *this // will work if "dev" hasn't been created yet or is replaced later // won't work if *this is removed/replaced // won't be callable until resolve() is called cb1.set(m_dev, FUNC(some_device::w)); ... // will bind to current target of m_dev // will not work if m_dev is not resolved // will not work if "dev" is replaced later // will be callable immediately cb2.set(*m_dev, FUNC(some_device::w)); ... The order of the target and name has been reversed for functoids (lambdas and other callable objects). This allows the NAME macro to be used on lambdas and functoids. For example: foo.set_something(NAME([this] (u8 data) { m_something = data; })); I realise the diagnostic messages get ugly if you use NAME on a large lambda. You can still give a literal name, you just have to place it after the lambda rather than before. This is uglier, but it's intentional. I'm trying to drive developers away from a certain style. While it's nice that you can put half the driver code in the memory map, it detracts from readability. It's hard to visualise the memory range mappings if the memory map functions are punctuated by large lambdas. There's also slightly higher overhead for calling a delegate bound to a functoid. If the code is prettier for trivial lambdas but uglier for non-trivial lambdas in address maps, it will hopefully steer people away from putting non-trivial lambdas in memory maps. There were some devices that were converted from using plain delegates without adding bind_relative_to calls. I fixed some of them (e.g. LaserDisc) but I probably missed some. These will likely crash on unresolved delegate calls. There are some devices that reset delegates at configuration complete or start time, preventing them from being set up during configuration (e.g. src/devices/video/ppu2c0x.cpp and src/devices/machine/68307.cpp). This goes against the design principles of how device delegates should be used, but I didn't change them because I don't trust myself to find all the places they're used. I've definitely broken some stuff with this (I know about asterix), so report issues and bear with me until I get it all fixed.
* Fix main fallout (nw) Olivier Galibert2018-08-261-24/+9
|
* emumem: Fix ioports/membanks in internal maps [O. Galibert] Olivier Galibert2018-08-261-8/+9
| | | | PS: That may break things, we'll see.
* devcb3 Vas Crabb2018-07-071-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are multiple issues with the current device callbacks: * They always dispatch through a pointer-to-member * Chained callbacks are a linked list so the branch unit can't predict the early * There's a runtime decision made on the left/right shift direction * There are runtime NULL checks on various objects * Binding a lambda isn't practical * Arbitrary transformations are not supported * When chaining callbacks it isn't clear what the MCFG_DEVCB_ modifiers apply to * It isn't possible to just append to a callback in derived configuration * The macros need a magic, hidden local called devcb * Moving code that uses the magic locals around is error-prone * Writing the MCFG_ macros to make a device usable is a pain * You can't discover applicable MCFG_ macros with intellisense * Macros are not scoped * Using an inappropriate macro isn't detected at compile time * Lots of other things This changeset overcomes the biggest obstacle to remving MCFG_ macros altogether. Essentially, to allow a devcb to be configured, call .bind() and expose the result (a bind target for the callback). Bind target methods starting with "set" repace the current callbacks; methods starting with "append" append to them. You can't reconfigure a callback after resolving it. There's no need to use a macro matching the handler signatures - use FUNC for everything. Current device is implied if no tag/finder is supplied (no need for explicit this). Lambdas are supported, and the memory space and offset are optional. These kinds of things work: * .read_cb().set([this] () { return something; }); * .read_cb().set([this] (offs_t offset) { return ~offset; }); * .write_cb().set([this] (offs_t offset, u8 data) { m_array[offset] = data; }); * .write_cb().set([this] (int state) { some_var = state; }); Arbitrary transforms are allowed, and they can modify offset/mask for example: * .read_cb().set(FUNC(my_state::handler)).transform([] (u8 data) { return bitswap<4>(data, 1, 3, 0, 2); }); * .read_cb().set(m_dev, FUNC(some_device::member)).transform([] (offs_t &offset, u8 data) { offset ^= 3; return data; }); It's possible to stack arbitrary transforms, at the cost of compile time (the whole transform stack gets inlined at compile time). Shifts count as an arbitrary transform, but mask/exor does not. Order of mask/shift/exor now matters. Modifications are applied in the specified order. These are NOT EQUIVALENT: * .read_cb().set(FUNC(my_state::handler)).mask(0x06).lshift(2); * .read_cb().set(FUNC(my_state::handler)).lshift(2).mask(0x06); The bit helper no longer reverses its behaviour for read callbacks, and I/O ports are no longer aware of the field mask. Binding a read callback to no-op is not supported - specify a constant. The GND and VCC aliases have been removed intentionally - they're TTL-centric, and were already being abused. Other quirks have been preserved, including write logger only logging when the data is non-zero (quite unhelpful in many of the cases where it's used). Legacy syntax is still supported for simple cases, but will be phased out. New devices should not have MCFG_ macros. I don't think I've missed any fundamental issues, but if I've broken something, let me know.
* Move ROM loading macros to romentry.h and remove romload.h from emu.h (nw) AJR2018-06-241-0/+1
|
* as if millions of this pointers suddenly cried out in terror, and were ↵ Vas Crabb2018-06-081-25/+19
| | | | | | | suddenly silenced * streamline templates in addrmap.h * get rid of overloads on read/write member names - this will become even more important in the near future
* Route sound relative to current device. Vas Crabb2018-05-011-3/+5
| | | | | | | | Also, look Ma - no magic prologue! Slot card additions run in the context of the slot itself, which isn't entirely intuitive. Slot configuration needs a bunch of other cleanup anyway.
* Make devopt menu localisable. Vas Crabb2018-04-281-0/+13
| | | | Make machine_config aware of device being configured so owner doesn't need to be passed everywhere.
* Sarayan made me do it. Vas Crabb2018-04-281-4/+4
| | | | | | | | | | Concrete device types now have a call operator that instantiates a device. This change means you *must* use DECLARE_DEVICE_TYPE to declare the public interface of your device, even if it's device_t. If you want to use private implementation classes, use DEFINE_DEVICE_TYPE_PRIVATE and instantiate the object finders.
* Allow machine configuration to specify BIOS easily, move default BIOS ↵ Vas Crabb2018-03-261-1/+50
| | | | selection into device configuration complete
* destaticify initializations (nw) (#3289) wilbertpol2018-03-041-6/+6
| | | | | | * destaticify initializations (nw) * fix this->set_screen (nw)
* Fixes (nw) Olivier Galibert2018-02-131-22/+36
|
* Move object finder resolution before device_start - should solve github #2759 Vas Crabb2017-10-281-2/+29
|
* finally got rid of machine_mconfig_additions (nw) Ivan Vangelista2017-06-141-17/+1
|
* There's no day like today. This just follows up on the last commit: game ↵ Vas Crabb2017-05-221-0/+14
| | | | drivers are less special special - they have configuration instantiated in the usual way.
* Move static data out of devices into the device types. This is a ↵ Vas Crabb2017-05-141-25/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | significant change, so please pay attention. The core changes are: * Short name, full name and source file are no longer members of device_t, they are part of the device type * MACHINE_COFIG_START no longer needs a driver class * MACHINE_CONFIG_DERIVED_CLASS is no longer necessary * Specify the state class you want in the GAME/COMP/CONS line * The compiler will work out the base class where the driver init member is declared * There is one static device type object per driver rather than one per machine configuration Use DECLARE_DEVICE_TYPE or DECLARE_DEVICE_TYPE_NS to declare device type. * DECLARE_DEVICE_TYPE forward-declares teh device type and class, and declares extern object finders. * DECLARE_DEVICE_TYPE_NS is for devices classes in namespaces - it doesn't forward-declare the device type. Use DEFINE_DEVICE_TYPE or DEFINE_DEVICE_TYPE_NS to define device types. * These macros declare storage for the static data, and instantiate the device type and device finder templates. The rest of the changes are mostly just moving stuff out of headers that shouldn't be there, renaming stuff for consistency, and scoping stuff down where appropriate. Things I've actually messed with substantially: * More descriptive names for a lot of devices * Untangled the fantasy sound from the driver state, which necessitates breaking up sound/flip writes * Changed DECO BSMT2000 ready callback into a device delegate * Untangled Microprose 3D noise from driver state * Used object finders for CoCo multipak, KC85 D002, and Irem sound subdevices * Started to get TI-99 stuff out of the TI-990 directory and arrange bus devices properly * Started to break out common parts of Samsung ARM SoC devices * Turned some of FM, SID, SCSP DSP, EPIC12 and Voodoo cores into something resmbling C++ * Tried to make Z180 table allocation/setup a bit safer * Converted generic keyboard/terminal to not use WRITE8 - space/offset aren't relevant * Dynamically allocate generic terminal buffer so derived devices (e.g. teleprinter) can specify size * Imporved encapsulation of Z80DART channels * Refactored the SPC7110 bit table generator loop to make it more readable * Added wrappers for SNES PPU operations so members can be made protected * Factored out some boilerplate for YM chips with PSG * toaplan2 gfx * stic/intv resolution * Video System video * Out Run/Y-board sprite alignment * GIC video hookup * Amstrad CPC ROM box members * IQ151 ROM cart region * MSX cart IRQ callback resolution time * SMS passthrough control devices starting subslots I've smoke-tested several drivers, but I've probably missed something. Things I've missed will likely blow up spectacularly with failure to bind errors and the like. Let me know if there's more subtle breakage (could have happened in FM or Voodoo). And can everyone please, please try to keep stuff clean. In particular, please stop polluting the global namespace. Keep things out of headers that don't need to be there, and use things that can be scoped down rather than macros. It feels like an uphill battle trying to get this stuff under control while more of it's added.
* Defend clocks_to_attotime and attotime_to_clocks against the possibility of ↵ AJR2017-04-211-2/+7
| | | | the device clock being 0 (nw)
* Mechanism for devices to generate clocks for other devices AJR2017-04-211-9/+44
| | | | | | - Have set_unscaled_clock and set_clock_scale not call notify_clock_changed unless the device has been started. - Owner-derived clocks are now updated whenever the owner's clock is changed, including at configuration time. This simplifies the configuration of various NES clones. - Add clock_update_delegate type to represent device-generated clock outputs that may be dynamically modified. The model implementation of this is the CLK output in I8085A.
* Self-registering devices. Vas Crabb2017-03-031-0/+56
| | | | | | * MAME now walks all devices when generating -lx output irrespective of whether they're actually instantiated anywhere or not. * -lx is at least 30% faster than previous implementation. * Only possible drawback is that filtering drivers no longer filters devices.